@ray-js/robot-map-sdk 0.0.3-beta-57 → 0.0.3-beta-59

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.
Files changed (32) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.rjs.js +1 -1
  3. package/dist-app/assets/index-Bt11wZBY.js +1 -0
  4. package/dist-app/index.html +1 -1
  5. package/dist-docs/404.html +2 -2
  6. package/dist-docs/assets/{app.DMzJUpqg.js → app.Dr_S0_gI.js} +1 -1
  7. package/dist-docs/assets/chunks/@localSearchIndexroot.1ZlEhJI6.js +1 -0
  8. package/dist-docs/assets/chunks/{VPLocalSearchBox.HEVPP9qv.js → VPLocalSearchBox.BAv2_Fj0.js} +1 -1
  9. package/dist-docs/assets/chunks/{theme.BwkK5uAQ.js → theme.CC8BuCFP.js} +2 -2
  10. package/dist-docs/assets/{guide_advanced-usage.md.CCbPjI4f.js → guide_advanced-usage.md.BEPxsaJf.js} +41 -2
  11. package/dist-docs/assets/{guide_advanced-usage.md.CCbPjI4f.lean.js → guide_advanced-usage.md.BEPxsaJf.lean.js} +1 -1
  12. package/dist-docs/assets/{guide_getting-started.md.xZ4KViU0.js → guide_getting-started.md.Dp7gIMgV.js} +1 -1
  13. package/dist-docs/assets/reference_config.md.B3ToPPdP.js +61 -0
  14. package/dist-docs/assets/reference_config.md.B3ToPPdP.lean.js +1 -0
  15. package/dist-docs/guide/advanced-usage.html +44 -5
  16. package/dist-docs/guide/concepts.html +3 -3
  17. package/dist-docs/guide/getting-started.html +5 -5
  18. package/dist-docs/hashmap.json +1 -1
  19. package/dist-docs/index.html +3 -3
  20. package/dist-docs/reference/callbacks.html +3 -3
  21. package/dist-docs/reference/config.html +6 -6
  22. package/dist-docs/reference/data.html +3 -3
  23. package/dist-docs/reference/methods.html +3 -3
  24. package/dist-docs/reference/runtime.html +3 -3
  25. package/dist-docs/reference/types.html +3 -3
  26. package/dist-docs/reference/utils.html +3 -3
  27. package/package.json +1 -1
  28. package/dist-app/assets/index-BuYDmyTb.js +0 -1
  29. package/dist-docs/assets/chunks/@localSearchIndexroot.Dxh5fsqc.js +0 -1
  30. package/dist-docs/assets/reference_config.md.QMeuiX8X.js +0 -61
  31. package/dist-docs/assets/reference_config.md.QMeuiX8X.lean.js +0 -1
  32. /package/dist-docs/assets/{guide_getting-started.md.xZ4KViU0.lean.js → guide_getting-started.md.Dp7gIMgV.lean.js} +0 -0
package/dist/index.rjs.js CHANGED
@@ -1 +1 @@
1
- function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t="default"){return void 0===Is[t]&&(Is[t]=-1),++Is[t]}function i(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,1+((t|=t>>>8)|t>>>16)}function s(t){return!(t&t-1||!t)}function n(t){const e={};for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}function r(t,e,i){const{width:s,height:n}=i.orig,r=i.trim;if(r){const i=r.width,o=r.height;t.minX=r.x-e._x*s,t.maxX=t.minX+i,t.minY=r.y-e._y*n,t.maxY=t.minY+o}else t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}function o(...t){500!==xn&&xn++}function a(t,e,i){const s=t.length;let n;if(e>=s||0===i)return;const r=s-(i=e+i>s?s-e:i);for(n=e;n<r;++n)t[n]=t[n+i];t.length=r}function h(t,e,i){let s,n;return i.clear(),t.parent?e?s=t.parent.worldTransform:(n=Pn.get().identity(),s=c(t,n)):s=ps.IDENTITY,l(t,i,s,e),n&&Pn.return(n),i.isValid||i.set(0,0,0,0),i}function l(t,e,i,s){if(!t.visible||!t.measurable)return;let n;s?n=t.worldTransform:(t.updateLocalTransform(),n=Pn.get(),n.appendFrom(t.localTransform,i));const r=e,o=!!t.effects.length;if(o&&(e=En.get().clear()),t.boundsArea)e.addRect(t.boundsArea,n);else{const i=t.bounds;i&&!i.isEmpty()&&(e.matrix=n,e.addBounds(i));for(let i=0;i<t.children.length;i++)l(t.children[i],e,n,s)}if(o){for(let i=0;i<t.effects.length;i++)t.effects[i].addBounds?.(e);r.addBounds(e,ps.IDENTITY),En.return(e)}s||Pn.return(n)}function c(t,e){const i=t.parent;return i&&(c(i,e),i.updateLocalTransform(),e.append(i.localTransform)),e}function d(t,e){return 16777215!==t&&e?16777215!==e&&t?((t>>16&255)*(e>>16&255)/255<<16)+((t>>8&255)*(e>>8&255)/255<<8)+((255&t)*(255&e)/255|0):t:e}function u(t,e){return t===kn?e:e===kn?t:d(t,e)}function p(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}function g(t,e,i){return e.clear(),i||(i=ps.IDENTITY),f(t,e,i,t,!0),e.isValid||e.set(0,0,0,0),e}function f(t,e,i,s,n){let r;if(n)r=Pn.get(),r=i.copyTo(r);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;r=Pn.get(),r.appendFrom(e,i)}const o=e,a=!!t.effects.length;if(a&&(e=En.get().clear()),t.boundsArea)e.addRect(t.boundsArea,r);else{t.renderPipeId&&(e.matrix=r,e.addBounds(t.bounds));const i=t.children;for(let t=0;t<i.length;t++)f(i[t],e,r,s,!1)}if(a){for(let i=0;i<t.effects.length;i++)t.effects[i].addLocalBounds?.(e,s);o.addBounds(e,ps.IDENTITY),En.return(e)}Pn.return(r)}function m(t,e){const i=t.children;for(let t=0;t<i.length;t++){const s=i[t],n=s.uid,r=(65535&s._didViewChangeTick)<<16|65535&s._didContainerChangeTick,o=e.index;e.data[o]===n&&e.data[o+1]===r||(e.data[e.index]=n,e.data[e.index+1]=r,e.didChange=!0),e.index=o+2,s.children.length&&m(s,e)}return e.didChange}function y(t,e){return t._zIndex-e._zIndex}function x(t,e,i){const s=Qn;t.measurable=!0,h(t,i,s),e.addBoundsMask(s),t.measurable=!1}function b(t,e,i){const s=En.get();t.measurable=!0;const n=Pn.get().identity();g(t,s,v(t,i,n)),t.measurable=!1,e.addBoundsMask(s),Pn.return(n),En.return(s)}function v(t,e,i){return t?(t!==e&&(v(t.parent,e,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(o(),i)}async function _(){return hr??(hr=(async()=>{const t=ir.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),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(s),t.deleteTexture(i),t.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),hr}function w(t={}){const e=t&&t.resource,i=e?t.resource:t,s=e?t:{resource:t};for(let t=0;t<gr.length;t++){const e=gr[t];if(e.test(i))return new e(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function A(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function C(t){return t.split("?")[0].split("#")[0]}function S(t,e,i,s,n){const r=e[i];for(let o=0;o<r.length;o++){const a=r[o];i<e.length-1?S(t.replace(s[i],a),e,i+1,s,n):n.push(t.replace(s[i],a))}}function I(t){const e=t.match(/\{(.*?)\}/g),i=[];if(e){const s=[];e.forEach(t=>{const e=t.substring(1,t.length-1).split(",");s.push(e)}),S(t,s,0,e,i)}else i.push(t);return i}function M(t,e,i){const s={};if(t.forEach(t=>{s[t]=e}),Object.keys(e.textures).forEach(t=>{s[`${e.cachePrefix}${t}`]=e.textures[t]}),!i){const i=mr.dirname(t[0]);e.linkedSheets.forEach((t,n)=>{const r=M([`${i}/${e.data.meta.related_multi_packs[n]}`],t,!0);Object.assign(s,r)})}return s}function T(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=e.userAgent,s=i.split("[FBAN");void 0!==s[1]&&(i=s[0]),void 0!==(s=i.split("Twitter"))[1]&&(i=s[0]);var n=function(t){return function(e){return e.test(t)}}(i),r={apple:{phone:n(Ir)&&!n(Or),ipod:n(Mr),tablet:!n(Ir)&&(n(Tr)||zr(e))&&!n(Or),universal:n(Pr),device:(n(Ir)||n(Mr)||n(Tr)||n(Pr)||zr(e))&&!n(Or)},amazon:{phone:n(Rr),tablet:!n(Rr)&&n(kr),device:n(Rr)||n(kr)},android:{phone:!n(Or)&&n(Rr)||!n(Or)&&n(Er),tablet:!n(Or)&&!n(Rr)&&!n(Er)&&(n(kr)||n(Br)),device:!n(Or)&&(n(Rr)||n(kr)||n(Er)||n(Br))||n(/\bokhttp\b/i)},windows:{phone:n(Or),tablet:n(Dr),device:n(Or)||n(Dr)},other:{blackberry:n(Fr),blackberry10:n(Lr),opera:n(jr),firefox:n(Ur),chrome:n(Gr),device:n(Fr)||n(Lr)||n(jr)||n(Ur)||n(Gr)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}function P(t,e){let i=Jr[t];return void 0===i&&(void 0===Wr[e]&&(Wr[e]=1),Jr[t]=i=Wr[e]++),i}function E(){if(!Zr||Zr?.isContextLost()){const t=ir.get().createCanvas();Zr=t.getContext("webgl",{})}return Zr}function B(){if(!Xr){Xr="mediump";const t=E();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);Xr=e.precision?"highp":"mediump"}}return Xr}function R(t){return eo[t]??eo.float32}function k(t){const e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,r=/(\w+)\s*:\s*([\w\<\>]+)/g,o=/struct\s+(\w+)/,a=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map(t=>({group:parseInt(t.match(e)[1],10),binding:parseInt(t.match(i)[1],10),name:t.match(s)[2],isUniform:"<uniform>"===t.match(s)[1],type:t.match(n)[1]}));if(!a)return{groups:[],structs:[]};const h=t.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map(t=>{const e=t.match(o)[1],i=t.match(r).reduce((t,e)=>{const[i,s]=e.split(":");return t[i.trim()]=s.trim(),t},{});return i?{name:e,members:i}:null}).filter(({name:t})=>a.some(e=>e.type===t))??[];return{groups:a,structs:h}}function O(t,e){switch(t){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);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}function D(){if("boolean"==typeof vo)return vo;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");vo=!0===t({a:"b"},"a","b")}catch(t){vo=!1}return vo}function F(t,e,i=2){const s=e&&e.length,n=s?e[0]*i:t.length;let r=L(t,0,n,i,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(s&&(r=function(t,e,i,s){const n=[];for(let i=0,r=e.length;i<r;i++){const o=L(t,e[i]*s,i<r-1?e[i+1]*s:t.length,s,!1);o===o.next&&(o.steiner=!0),n.push(X(o))}n.sort(H);for(let t=0;t<n.length;t++)i=W(n[t],i);return i}(t,e,r,i)),t.length>80*i){a=t[0],h=t[1];let e=a,s=h;for(let r=i;r<n;r+=i){const i=t[r],n=t[r+1];i<a&&(a=i),n<h&&(h=n),i>e&&(e=i),n>s&&(s=n)}l=Math.max(e-a,s-h),l=0!==l?32767/l:0}return G(r,o,i,a,h,l,0),o}function L(t,e,i,s,n){let r;if(n===function(t,e,i,s){let n=0;for(let r=e,o=i-s;r<i;r+=s)n+=(t[o]-t[r])*(t[r+1]+t[o+1]),o=r;return n}(t,e,i,s)>0)for(let n=e;n<i;n+=s)r=rt(n/s|0,t[n],t[n+1],r);else for(let n=i-s;n>=e;n-=s)r=rt(n/s|0,t[n],t[n+1],r);return r&&$(r,r.next)&&(ot(r),r=r.next),r}function j(t,e){if(!t)return t;e||(e=t);let i,s=t;do{if(i=!1,s.steiner||!$(s,s.next)&&0!==q(s.prev,s,s.next))s=s.next;else{if(ot(s),s=e=s.prev,s===s.next)break;i=!0}}while(i||s!==e);return e}function G(t,e,i,s,n,r,o){if(!t)return;!o&&r&&function(t,e,i,s){let n=t;do{0===n.z&&(n.z=Z(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let e,i=1;do{let s,n=t;t=null;let r=null;for(e=0;n;){e++;let o=n,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let h=i;for(;a>0||h>0&&o;)0!==a&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,a--):(s=o,o=o.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;n=o}r.nextZ=null,i*=2}while(e>1)}(n)}(t,s,n,r);let a=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(r?z(t,s,n,r):U(t))e.push(h.i,t.i,l.i),ot(t),t=l.next,a=l.next;else if((t=l)===a){o?1===o?G(t=N(j(t),e),e,i,s,n,r,2):2===o&&V(t,e,i,s,n,r):G(j(t),e,i,s,n,r,1);break}}}function U(t){const e=t.prev,i=t,s=t.next;if(q(e,i,s)>=0)return!1;const n=e.x,r=i.x,o=s.x,a=e.y,h=i.y,l=s.y,c=Math.min(n,r,o),d=Math.min(a,h,l),u=Math.max(n,r,o),p=Math.max(a,h,l);let g=s.next;for(;g!==e;){if(g.x>=c&&g.x<=u&&g.y>=d&&g.y<=p&&K(n,a,r,h,o,l,g.x,g.y)&&q(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function z(t,e,i,s){const n=t.prev,r=t,o=t.next;if(q(n,r,o)>=0)return!1;const a=n.x,h=r.x,l=o.x,c=n.y,d=r.y,u=o.y,p=Math.min(a,h,l),g=Math.min(c,d,u),f=Math.max(a,h,l),m=Math.max(c,d,u),y=Z(p,g,e,i,s),x=Z(f,m,e,i,s);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=y&&v&&v.z<=x;){if(b.x>=p&&b.x<=f&&b.y>=g&&b.y<=m&&b!==n&&b!==o&&K(a,c,h,d,l,u,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=f&&v.y>=g&&v.y<=m&&v!==n&&v!==o&&K(a,c,h,d,l,u,v.x,v.y)&&q(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=f&&b.y>=g&&b.y<=m&&b!==n&&b!==o&&K(a,c,h,d,l,u,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=f&&v.y>=g&&v.y<=m&&v!==n&&v!==o&&K(a,c,h,d,l,u,v.x,v.y)&&q(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function N(t,e){let i=t;do{const s=i.prev,n=i.next.next;!$(s,n)&&tt(s,i,i.next,n)&&st(s,n)&&st(n,s)&&(e.push(s.i,i.i,n.i),ot(i),ot(i.next),i=t=n),i=i.next}while(i!==t);return j(i)}function V(t,e,i,s,n,r){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Q(o,t)){let a=nt(o,t);return o=j(o,o.next),a=j(a,a.next),G(o,e,i,s,n,r,0),void G(a,e,i,s,n,r,0)}t=t.next}o=o.next}while(o!==t)}function H(t,e){let i=t.x-e.x;return 0===i&&(i=t.y-e.y,0===i)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function W(t,e){const i=function(t,e){let i=e;const s=t.x,n=t.y;let r,o=-1/0;if($(t,i))return i;do{if($(t,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>o&&(o=t,r=i.x<i.next.x?i:i.next,t===s))return r}i=i.next}while(i!==e);if(!r)return null;const a=r,h=r.x,l=r.y;let c=1/0;i=r;do{if(s>=i.x&&i.x>=h&&s!==i.x&&Y(n<l?s:o,n,h,l,n<l?o:s,n,i.x,i.y)){const e=Math.abs(n-i.y)/(s-i.x);st(i,t)&&(e<c||e===c&&(i.x>r.x||i.x===r.x&&J(r,i)))&&(r=i,c=e)}i=i.next}while(i!==a);return r}(t,e);if(!i)return e;const s=nt(i,t);return j(s,s.next),j(i,i.next)}function J(t,e){return q(t.prev,t,e.prev)<0&&q(e.next,t,t.next)<0}function Z(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function X(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Y(t,e,i,s,n,r,o,a){return(n-o)*(e-a)>=(t-o)*(r-a)&&(t-o)*(s-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(n-o)*(s-a)}function K(t,e,i,s,n,r,o,a){return!(t===o&&e===a)&&Y(t,e,i,s,n,r,o,a)}function Q(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&tt(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(st(t,e)&&st(e,t)&&function(t,e){let i=t,s=!1;const n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)&&(q(t.prev,t,e.prev)||q(t,e.prev,e))||$(t,e)&&q(t.prev,t,t.next)>0&&q(e.prev,e,e.next)>0)}function q(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function $(t,e){return t.x===e.x&&t.y===e.y}function tt(t,e,i,s){const n=it(q(t,e,i)),r=it(q(t,e,s)),o=it(q(i,s,t)),a=it(q(i,s,e));return n!==r&&o!==a||!(0!==n||!et(t,i,e))||!(0!==r||!et(t,s,e))||!(0!==o||!et(i,t,s))||!(0!==a||!et(i,e,s))}function et(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function it(t){return t>0?1:t<0?-1:0}function st(t,e){return q(t.prev,t,t.next)<0?q(t,e,t.next)>=0&&q(t,t.prev,e)>=0:q(t,e,t.prev)<0||q(t,t.next,e)<0}function nt(t,e){const i=at(t.i,t.x,t.y),s=at(e.i,e.x,e.y),n=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,r.next=s,s.prev=r,s}function rt(t,e,i,s){const n=at(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function ot(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function at(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ht(t){return void 0!==Io||(Io=(()=>{const e={stencil:!0,failIfMajorPerformanceCaveat:t??To.defaultOptions.failIfMajorPerformanceCaveat};try{if(!ir.get().getWebGLRenderingContext())return!1;let t=ir.get().createCanvas().getContext("webgl",e);const i=!!t?.getContextAttributes()?.stencil;if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,i}catch(t){return!1}})()),Io}async function lt(t={}){return void 0!==Mo||(Mo=await(async()=>{const e=ir.get().getNavigator().gpu;if(!e)return!1;try{const i=await e.requestAdapter(t);return await i.requestDevice(),!0}catch(t){return!1}})()),Mo}function ct(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new jo(t,e,i)}function dt(t){const e="number"==typeof t.fontSize?`${t.fontSize}px`:t.fontSize;let i=t.fontFamily;Array.isArray(t.fontFamily)||(i=t.fontFamily.split(","));for(let t=i.length-1;t>=0;t--){let e=i[t].trim();/([\"\'])[^\'\"]+\1/.test(e)||Go.includes(e)||(e=`"${e}"`),i[t]=e}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${i.join(",")}`}function ut(t,e){for(let i=0;i<e.length;i++){const s=e[i];t.addColorStop(s.offset,s.color)}}function pt(t,e){const i=ir.get().createCanvas(t,e),s=i.getContext("2d");return{canvas:i,context:s}}function gt(t,e,i,s,n,r){const o=n-i,a=r-s,h=o*o+a*a;let l,c,d=-1;0!==h&&(d=((t-i)*o+(e-s)*a)/h),d<0?(l=i,c=s):d>1?(l=n,c=r):(l=i+d*o,c=s+d*a);const u=t-l,p=e-c;return u*u+p*p}function ft(t,e,i){let s=2166136261;for(let i=0;i<e;i++)s^=t[i].uid,s=Math.imul(s,16777619),s>>>=0;return ia[s]||function(t,e,i,s){const n={};let r=0;for(let i=0;i<s;i++){const s=i<e?t[i]:Gs.EMPTY.source;n[r++]=s.source,n[r++]=s.style}const o=new co(n);return ia[i]=o,o}(t,e,s,i)}function mt(t,e){const i=t.byteLength/8|0,s=new Float64Array(t,0,i);new Float64Array(e,0,i).set(s);const n=t.byteLength-8*i;if(n>0){const s=new Uint8Array(t,8*i,n);new Uint8Array(e,8*i,n).set(s)}}function yt(t,e){return"no-premultiply-alpha"===e.alphaMode&&na[t]||t}function xt(t){let e="";for(let i=0;i<t;++i)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(test == ${i}.0){}`);return e}function bt(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const i=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const s=oa.replace(/%forloop%/gi,xt(t));if(e.shaderSource(i,s),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))break;t=t/2|0}}finally{e.deleteShader(i)}return t}function vt(){return da>0?ca[--da]:new la}function _t(t){ca[da++]=t}function wt(t,e){if(!(t instanceof ma)){let i=e?fa.INDEX:fa.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),i=fa.INDEX|fa.COPY_DST):(t=new Float32Array(t),i=fa.VERTEX|fa.COPY_DST)),t=new ma({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:i})}return t}function At(t,e,i){if(t)for(const s in t){const n=e[s.toLocaleLowerCase()];if(n){let e=t[s];"header"===s&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),i&&n.push(`//----${i}----//`),n.push(e)}else o()}}function Ct(t){const e={};return(t.match(_a)?.map(t=>t.replace(/[{()}]/g,""))??[]).forEach(t=>{e[t]=[]}),e}function St(t,e){let i;const s=/@in\s+([^;]+);/g;for(;null!==(i=s.exec(t));)e.push(i[1])}function It(t,e,i=!1){const s=[];St(e,s),t.forEach(t=>{t.header&&St(t.header,s)});const n=s;i&&n.sort();const r=n.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${r}\n`),o}function Mt(t,e){let i;const s=/@out\s+([^;]+);/g;for(;null!==(i=s.exec(t));)e.push(i[1])}function Tt(t,e){let i=t;for(const t in e){const s=e[t];i=s.join("\n").length?i.replace(`{{${t}}}`,`//-----${t} START-----//\n${s.join("\n")}\n//----${t} FINISH----//`):i.replace(`{{${t}}}`,"")}return i}function Pt({template:t,bits:e}){const i=Et(t,e);return wa[i]||(wa[i]=Bt(t.vertex,t.fragment,e)),wa[i]}function Et(t,e){return e.map(t=>(Aa.has(t)||Aa.set(t,Ca++),Aa.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function Bt(t,e,i){const s=Ct(t),n=Ct(e);return i.forEach(t=>{At(t.vertex,s,t.name),At(t.fragment,n,t.name)}),{vertex:Tt(t,s),fragment:Tt(e,n)}}function Rt({bits:t,name:e}){const i=function({template:t,bits:e}){const i=Et(t,e);if(wa[i])return wa[i];const{vertex:s,fragment:n}=function(t,e){const i=e.map(t=>t.vertex).filter(t=>!!t),s=e.map(t=>t.fragment).filter(t=>!!t);let n=It(i,t.vertex,!0);return n=function(t,e){const i=[];Mt(e,i),t.forEach(t=>{t.header&&Mt(t.header,i)});let s=0;const n=i.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${s++}) ${t}`).join(",\n"),r=i.sort().map(t=>{return` var ${e=t,e.replace(/@.*?\s+/g,"")};`;var e}).join("\n"),o=`return VSOutput(\n ${i.sort().map(t=>` ${function(t){const e=/\b(\w+)\s*:/g.exec(t);return e?e[1]:""}(t)}`).join(",\n")});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`\n${n}\n`),a=a.replace("{{start}}",`\n${r}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(i,n),{vertex:n,fragment:It(s,t.fragment,!0)}}(t,e);return wa[i]=Bt(s,n,e),wa[i]}({template:{fragment:"\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n\n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n\n {{start}}\n\n var outColor:vec4<f32>;\n\n {{main}}\n\n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",vertex:"\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n\n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n"},bits:[Sa,...t]});return ro.from({name:e,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function kt({bits:t,name:e}){return new to({name:e,...Pt({template:{vertex:"\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n\n {{start}}\n\n vColor = vec4(1.);\n\n {{main}}\n\n vUV = uv;\n\n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",fragment:"\n\n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n\n {{start}}\n\n vec4 outColor;\n\n {{main}}\n\n finalColor = outColor * vColor;\n\n {{end}}\n }\n"},bits:[Ia,...t]})})}function Ot(t){const e=[];if(1===t)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let i=0;for(let s=0;s<t;s++)e.push(`@group(1) @binding(${i++}) var textureSource${s+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i++}) var textureSampler${s+1}: sampler;`)}return e.join("\n")}function Dt(t){const e=[];if(1===t)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let i=0;i<t;i++)i===t-1?e.push(" default:{"):e.push(` case ${i}:{`),e.push(` outColor = textureSampleGrad(textureSource${i+1}, textureSampler${i+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join("\n")}function Ft(t){return Pa[t]||(Pa[t]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${Ot(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${Dt(t)}\n `}}),Pa[t]}function Lt(t){const e=[];for(let i=0;i<t;i++)i>0&&e.push("else"),i<t-1&&e.push(`if(vTextureId < ${i}.5)`),e.push("{"),e.push(`\toutColor = texture(uTextures[${i}], vUV);`),e.push("}");return e.join("\n")}function jt(t){return Ea[t]||(Ea[t]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${t}];\n\n `,main:`\n\n ${Lt(t)}\n `}}),Ea[t]}function Gt(t){let e=ka[t];if(e)return e;const i=new Int32Array(t);for(let e=0;e<t;e++)i[e]=e;return e=ka[t]=new lo({uTextures:{value:i,type:"i32",size:t}},{isStatic:!0}),e}function Ut(t,e,i,s,n){const r=e.a,o=e.b,a=e.c,h=e.d,l=e.tx,c=e.ty;i||(i=0),s||(s=2),n||(n=t.length/s-i);let d=i*s;for(let e=0;e<n;e++){const e=t[d],i=t[d+1];t[d]=r*e+a*i+l,t[d+1]=o*e+h*i+c,d+=s}}function zt(t,e,i,s,n,r,o,a){let h,l;o?(h=s,l=-i):(h=-s,l=i);const c=t-i*n+h,d=e-s*n+l,u=t+i*r+h,p=e+s*r+l;return a.push(c,d),a.push(u,p),2}function Nt(t,e,i,s,n,r,o,a){const h=i-t,l=s-e;let c=Math.atan2(h,l),d=Math.atan2(n-t,r-e);a&&c<d?c+=2*Math.PI:!a&&c>d&&(d+=2*Math.PI);let u=c;const p=d-c,g=Math.abs(p),f=Math.sqrt(h*h+l*l),m=1+(15*g*Math.sqrt(f)/Math.PI|0),y=p/m;if(u+=y,a){o.push(t,e),o.push(i,s);for(let i=1,s=u;i<m;i++,s+=y)o.push(t,e),o.push(t+Math.sin(s)*f,e+Math.cos(s)*f);o.push(t,e),o.push(n,r)}else{o.push(i,s),o.push(t,e);for(let i=1,s=u;i<m;i++,s+=y)o.push(t+Math.sin(s)*f,e+Math.cos(s)*f),o.push(t,e);o.push(n,r),o.push(t,e)}return 2*m}function Vt(t,e,i,s,n,r,o){const a=_o(t,e,2);if(!a)return;for(let t=0;t<a.length;t+=3)r[o++]=a[t]+n,r[o++]=a[t+1]+n,r[o++]=a[t+2]+n;let h=n*s;for(let e=0;e<t.length;e+=2)i[h]=t[e],i[h+1]=t[e+1],h+=s}function Ht(t,e,i){const s=[],n=Ka.rectangle,r=Qa;r.x=t.dx,r.y=t.dy,r.width=t.dw,r.height=t.dh;const o=t.transform;if(!n.build(r,s))return;const{vertices:a,uvs:h,indices:l}=i,c=l.length,d=a.length/2;o&&Ut(s,o),n.triangulate(s,a,2,d,l,c);const u=t.image,p=u.uvs;h.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const g=_n.get(Ga);g.indexOffset=c,g.indexSize=l.length-c,g.attributeOffset=d,g.attributeSize=a.length/2-d,g.baseColor=t.style,g.alpha=t.alpha,g.texture=u,g.geometryData=i,e.push(g)}function Wt(t,e,i,s,n){const{vertices:r,uvs:o,indices:a}=n;t.shapePrimitives.forEach(({shape:t,transform:h,holes:l})=>{const c=[],d=Ka[t.type];if(!d.build(t,c))return;const u=a.length,p=r.length/2;let g="triangle-list";if(h&&Ut(c,h),i){const i=t.closePath??!0,s=e;s.pixelLine?(function(t,e,i,s){const n=Va;if(0===t.length)return;const r=t[0],o=t[1],a=t[t.length-2],h=t[t.length-1],l=e||Math.abs(r-a)<n&&Math.abs(o-h)<n,c=i,d=t.length/2,u=c.length/2;for(let e=0;e<d;e++)c.push(t[2*e]),c.push(t[2*e+1]);for(let t=0;t<d-1;t++)s.push(u+t,u+t+1);l&&s.push(u+d-1,u)}(c,i,r,a),g="line-list"):function(t,e,i,s,n,r){const o=Va;if(0===t.length)return;const a=e;let h=a.alignment;if(.5!==e.alignment){let e=function(t){const e=t.length;if(e<6)return 1;let i=0;for(let s=0,n=t[e-2],r=t[e-1];s<e;s+=2){const e=t[s],o=t[s+1];i+=(e-n)*(o+r),n=e,r=o}return i<0?-1:1}(t);h=(h-.5)*e+.5}const l=new ds(t[0],t[1]),c=new ds(t[t.length-2],t[t.length-1]),d=s,u=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(d){t=t.slice(),u&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(l.x+c.x),i=.5*(c.y+l.y);t.unshift(e,i),t.push(e,i)}const p=n,g=t.length/2;let f=t.length;const m=p.length/2,y=a.width/2,x=y*y,b=a.miterLimit*a.miterLimit;let v=t[0],_=t[1],w=t[2],A=t[3],C=0,S=0,I=-(_-A),M=v-w,T=0,P=0,E=Math.sqrt(I*I+M*M);I/=E,M/=E,I*=y,M*=y;const B=2*(1-h),R=2*h;d||("round"===a.cap?f+=Nt(v-I*(B-R)*.5,_-M*(B-R)*.5,v-I*B,_-M*B,v+I*R,_+M*R,p,!0)+2:"square"===a.cap&&(f+=zt(v,_,I,M,B,R,!0,p))),p.push(v-I*B,_-M*B),p.push(v+I*R,_+M*R);for(let e=1;e<g-1;++e){v=t[2*(e-1)],_=t[2*(e-1)+1],w=t[2*e],A=t[2*e+1],C=t[2*(e+1)],S=t[2*(e+1)+1],I=-(_-A),M=v-w,E=Math.sqrt(I*I+M*M),I/=E,M/=E,I*=y,M*=y,T=-(A-S),P=w-C,E=Math.sqrt(T*T+P*P),T/=E,P/=E,T*=y,P*=y;const i=w-v,s=_-A,n=w-C,r=S-A,o=i*n+s*r,h=s*n-r*i,l=h<0;if(Math.abs(h)<.001*Math.abs(o)){p.push(w-I*B,A-M*B),p.push(w+I*R,A+M*R),o>=0&&("round"===a.join?f+=Nt(w,A,w-I*B,A-M*B,w-T*B,A-P*B,p,!1)+4:f+=2,p.push(w-T*R,A-P*R),p.push(w+T*B,A+P*B));continue}const c=(-I+v)*(-M+A)-(-I+w)*(-M+_),d=(-T+C)*(-P+A)-(-T+w)*(-P+S),u=(i*d-n*c)/h,g=(r*c-s*d)/h,m=(u-w)*(u-w)+(g-A)*(g-A),k=w+(u-w)*B,O=A+(g-A)*B,D=w-(u-w)*R,F=A-(g-A)*R,L=l?B:R;m<=Math.min(i*i+s*s,n*n+r*r)+L*L*x?"bevel"===a.join||m/x>b?(l?(p.push(k,O),p.push(w+I*R,A+M*R),p.push(k,O),p.push(w+T*R,A+P*R)):(p.push(w-I*B,A-M*B),p.push(D,F),p.push(w-T*B,A-P*B),p.push(D,F)),f+=2):"round"===a.join?l?(p.push(k,O),p.push(w+I*R,A+M*R),f+=Nt(w,A,w+I*R,A+M*R,w+T*R,A+P*R,p,!0)+4,p.push(k,O),p.push(w+T*R,A+P*R)):(p.push(w-I*B,A-M*B),p.push(D,F),f+=Nt(w,A,w-I*B,A-M*B,w-T*B,A-P*B,p,!1)+4,p.push(w-T*B,A-P*B),p.push(D,F)):(p.push(k,O),p.push(D,F)):(p.push(w-I*B,A-M*B),p.push(w+I*R,A+M*R),"round"===a.join?f+=l?Nt(w,A,w+I*R,A+M*R,w+T*R,A+P*R,p,!0)+2:Nt(w,A,w-I*B,A-M*B,w-T*B,A-P*B,p,!1)+2:"miter"===a.join&&m/x<=b&&(l?(p.push(D,F),p.push(D,F)):(p.push(k,O),p.push(k,O)),f+=2),p.push(w-T*B,A-P*B),p.push(w+T*R,A+P*R),f+=2)}v=t[2*(g-2)],_=t[2*(g-2)+1],w=t[2*(g-1)],A=t[2*(g-1)+1],I=-(_-A),M=v-w,E=Math.sqrt(I*I+M*M),I/=E,M/=E,I*=y,M*=y,p.push(w-I*B,A-M*B),p.push(w+I*R,A+M*R),d||("round"===a.cap?f+=Nt(w-I*(B-R)*.5,A-M*(B-R)*.5,w-I*B,A-M*B,w+I*R,A+M*R,p,!1)+2:"square"===a.cap&&(f+=zt(w,A,I,M,B,R,!1,p)));for(let t=m;t<f+m-2;++t)v=p[2*t],_=p[2*t+1],w=p[2*(t+1)],A=p[2*(t+1)+1],C=p[2*(t+2)],S=p[2*(t+2)+1],Math.abs(v*(A-S)+w*(S-_)+C*(_-A))<1e-8||r.push(t,t+1,t+2)}(c,s,0,i,r,a)}else if(l){const t=[],e=c.slice();(function(t){const e=[];for(let i=0;i<t.length;i++){const s=t[i].shape,n=[];Ka[s.type].build(s,n)&&e.push(n)}return e})(l).forEach(i=>{t.push(e.length/2),e.push(...i)}),Vt(e,t,r,2,p,a,u)}else d.triangulate(c,r,2,p,a,u);const f=o.length/2,m=e.texture;if(m!==Gs.WHITE){const i=function(t,e,i,s){const n=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=i.getBounds(Ya);e.width&&t.pad(e.width);const{x:s,y:r}=t,o=1/t.width,a=1/t.height,h=-s*o,l=-r*a,c=n.a,d=n.b,u=n.c,p=n.d;n.a*=o,n.b*=o,n.c*=a,n.d*=a,n.tx=h*c+l*u+n.tx,n.ty=h*d+l*p+n.ty}else n.translate(e.texture.frame.x,e.texture.frame.y),n.scale(1/e.texture.source.width,1/e.texture.source.height);const r=e.texture.source.style;return e.fill instanceof Wo||"clamp-to-edge"!==r.addressMode||(r.addressMode="repeat",r.update()),s&&n.append(Xa.copyFrom(s).invert()),n}(qa,e,t,h);!function(t,e,i,s,n,r,o,a=null){let h=0;i*=e,n*=r;const l=a.a,c=a.b,d=a.c,u=a.d,p=a.tx,g=a.ty;for(;h<o;){const o=t[i],a=t[i+1];s[n]=l*o+d*a+p,s[n+1]=c*o+u*a+g,n+=r,i+=e,h++}}(r,2,p,o,f,2,r.length/2-p,i)}else!function(t,e,i,s){let n=0;for(e*=2;n<s;)t[e]=0,t[e+1]=0,e+=2,n++}(o,f,0,r.length/2-p);const y=_n.get(Ga);y.indexOffset=u,y.indexSize=a.length-u,y.attributeOffset=p,y.attributeSize=r.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=m,y.geometryData=n,y.topology=g,s.push(y)})}function Jt(t,e,i,s,n,r,o,a,h,l){let c=(1-Math.min(.99,Math.max(0,l??ih.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,i,s,n,r,o,a,h,l){Zt(t,e,i,s,n,r,o,a,h,l,0),h.push(o,a)}(e,i,s,n,r,o,a,h,t,c),t}function Zt(t,e,i,s,n,r,o,a,h,l,c){if(c>8)return;const d=(t+i)/2,u=(e+s)/2,p=(i+n)/2,g=(s+r)/2,f=(n+o)/2,m=(r+a)/2,y=(d+p)/2,x=(u+g)/2,b=(p+f)/2,v=(g+m)/2,_=(y+b)/2,w=(x+v)/2;if(c>0){let c=o-t,d=a-e;const u=Math.abs((i-o)*d-(s-a)*c),p=Math.abs((n-o)*d-(r-a)*c);if(u>sh&&p>sh){if((u+p)*(u+p)<=l*(c*c+d*d))return void h.push(_,w)}else if(u>sh){if(u*u<=l*(c*c+d*d))return void h.push(_,w)}else if(p>sh){if(p*p<=l*(c*c+d*d))return void h.push(_,w)}else if(c=_-(t+o)/2,d=w-(e+a)/2,c*c+d*d<=l)return void h.push(_,w)}Zt(t,e,d,u,y,x,_,w,h,l,c+1),Zt(_,w,b,v,f,m,o,a,h,l,c+1)}function Xt(t,e,i,s,n,r,o,a){let h=(1-Math.min(.99,Math.max(0,a??ih.defaultOptions.bezierSmoothness)))/1;return h*=h,function(t,e,i,s,n,r,o,a){Yt(o,t,e,i,s,n,r,a,0),o.push(n,r)}(e,i,s,n,r,o,t,h),t}function Yt(t,e,i,s,n,r,o,a,h){if(h>8)return;const l=(e+s)/2,c=(i+n)/2,d=(s+r)/2,u=(n+o)/2,p=(l+d)/2,g=(c+u)/2;let f=r-e,m=o-i;const y=Math.abs((s-r)*m-(n-o)*f);if(y>1.1920929e-7){if(y*y<=a*(f*f+m*m))return void t.push(p,g)}else if(f=p-(e+r)/2,m=g-(i+o)/2,f*f+m*m<=a)return void t.push(p,g);Yt(t,e,i,l,c,p,g,a,h+1),Yt(t,p,g,d,u,r,o,a,h+1)}function Kt(t,e,i,s,n,r,o,a){let h=Math.abs(n-r);(!o&&n>r||o&&r>n)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))));let l=h/(a=Math.max(a,3)),c=n;l*=o?-1:1;for(let n=0;n<a+1;n++){const n=e+Math.cos(c)*s,r=i+Math.sin(c)*s;t.push(n,r),c+=l}}function Qt(t,e){const i=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),s=1.5707963267948966===e?.551915024494:i,n=Math.cos(t),r=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:n-r*s,y:r+n*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}function qt(t,e){return t?t.prepend(e):e.clone()}function $t(t,e,i){const s=t.getAttribute(e);return s?Number(s):i}function te(t){const e=$t(t,"x1",0),i=$t(t,"y1",0),s=$t(t,"x2",1),n=$t(t,"y2",0),r=t.getAttribute("gradientUnits")||"objectBoundingBox",o=new Wo(e,i,s,n,"objectBoundingBox"===r?"local":"global");for(let e=0;e<t.children.length;e++){const i=t.children[e],s=$t(i,"offset",0),n=yn.shared.setValue(i.getAttribute("stop-color")).toNumber();o.addColorStop(s,n)}return o}function ee(t){return o(),new Wo(0,0,1,0)}function ie(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}function se(t,e){const i=t.getAttribute("style"),s={},n={},r={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const i in dh){const s=t.getAttribute(i);s&&ne(e,r,i,s.trim())}if(i){const t=i.split(";");for(let i=0;i<t.length;i++){const s=t[i].trim(),[n,o]=s.split(":");dh[n]&&ne(e,r,n,o.trim())}}return{strokeStyle:r.useStroke?s:null,fillStyle:r.useFill?n:null,useFill:r.useFill,useStroke:r.useStroke}}function ne(t,e,i,s){switch(i){case"stroke":if("none"!==s){if(s.startsWith("url(")){const i=ie(s);e.strokeStyle.fill=t.defs[i]}else e.strokeStyle.color=yn.shared.setValue(s).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(s);break;case"fill":if("none"!==s){if(s.startsWith("url(")){const i=ie(s);e.fillStyle.fill=t.defs[i]}else e.fillStyle.color=yn.shared.setValue(s).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(s);break;case"stroke-opacity":e.strokeStyle.alpha=Number(s);break;case"opacity":e.fillStyle.alpha=Number(s),e.strokeStyle.alpha=Number(s)}}function re(t){const e=t.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const i=e.map(Number),s=[],n=[];for(let t=0;t<i.length;t+=2)t+1<i.length&&(s.push(i[t]),n.push(i[t+1]));if(0===s.length||0===n.length)return 0;const r=Math.min(...s),o=Math.max(...s),a=Math.min(...n);return(o-r)*(Math.max(...n)-a)}function oe(t,e){const i=new ch(t,!1);for(const t of i.instructions)e.instructions.push(t)}function ae(t,e,i,s){const n=t.children,{fillStyle:r,strokeStyle:a}=se(t,e);r&&i?i={...i,...r}:r&&(i=r),a&&s?s={...s,...a}:a&&(s=a);const h=!i&&!s;let l,c,d,u,p,g,f,m,y,x,b,v,_,w,A,C,S;switch(h&&(i={color:0}),t.nodeName.toLowerCase()){case"path":{w=t.getAttribute("d");const n=t.getAttribute("fill-rule"),r=w.split(/(?=[Mm])/).filter(t=>t.trim().length>0),o="evenodd"===n,a=r.length>1;if(o&&a){const t=r.map(t=>({path:t,area:re(t)}));t.sort((t,e)=>e.area-t.area);const n=r.length>3||!function(t){if(t.length<=2)return!0;const e=t.map(t=>t.area).sort((t,e)=>e-t),[i,s]=e,n=e[e.length-1];return!(i/s>3&&s/n<2)}(t);if(n)for(let n=0;n<t.length;n++){const r=t[n],o=0===n;e.context.beginPath();const a=new ch(void 0,!0);oe(r.path,a),e.context.path(a),o?(i&&e.context.fill(i),s&&e.context.stroke(s)):e.context.cut()}else for(let n=0;n<t.length;n++){const r=t[n],o=n%2==1;e.context.beginPath();const a=new ch(void 0,!0);oe(r.path,a),e.context.path(a),o?e.context.cut():(i&&e.context.fill(i),s&&e.context.stroke(s))}}else A=new ch(w,!n||"evenodd"===n),e.context.path(A),i&&e.context.fill(i),s&&e.context.stroke(s);break}case"circle":f=$t(t,"cx",0),m=$t(t,"cy",0),y=$t(t,"r",0),e.context.ellipse(f,m,y,y),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"rect":l=$t(t,"x",0),c=$t(t,"y",0),C=$t(t,"width",0),S=$t(t,"height",0),x=$t(t,"rx",0),b=$t(t,"ry",0),x||b?e.context.roundRect(l,c,C,S,x||b):e.context.rect(l,c,C,S),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"ellipse":f=$t(t,"cx",0),m=$t(t,"cy",0),x=$t(t,"rx",0),b=$t(t,"ry",0),e.context.beginPath(),e.context.ellipse(f,m,x,b),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"line":d=$t(t,"x1",0),u=$t(t,"y1",0),p=$t(t,"x2",0),g=$t(t,"y2",0),e.context.beginPath(),e.context.moveTo(d,u),e.context.lineTo(p,g),s&&e.context.stroke(s);break;case"polygon":_=t.getAttribute("points"),v=_.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(v,!0),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"polyline":_=t.getAttribute("points"),v=_.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(v,!1),s&&e.context.stroke(s);break;case"g":case"svg":break;default:o(t.nodeName)}h&&(i=null);for(let t=0;t<n.length;t++)ae(n[t],e,i,s)}function he(t){return t instanceof Zo}function le(t){return t instanceof Wo}function ce(t,e,i){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,{...i,...t}}function de(t,e,i){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...i,...t}}function ue(t,e){if(null==t)return null;const i={},s=t;return function(t){return yn.isColorLike(t)}(t)?function(t,e,i){const s=yn.shared.setValue(e??0);return t.color=s.toNumber(),t.alpha=1===s.alpha?i.alpha:s.alpha,t.texture=Gs.WHITE,{...i,...t}}(i,t,e):function(t){return t instanceof Gs}(t)?function(t,e,i){return t.texture=e,{...i,...t}}(i,t,e):he(t)?ce(i,t,e):le(t)?de(i,t,e):s.fill&&he(s.fill)?ce(s,s.fill,e):s.fill&&le(s.fill)?de(s,s.fill,e):function(t,e){const i={...e,...t},s=yn.shared.setValue(i.color);return i.alpha*=s.alpha,i.color=s.toNumber(),i}(s,e)}function pe(t,e){const{width:i,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...h}=e,l=ue(t,h);return l?{width:i,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...l}:null}function ge(t,e,i,s=0){if(t.texture===Gs.WHITE&&!t.fill)return yn.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(!t.fill){const i=e.createPattern(t.texture.source.resource,"repeat"),s=t.matrix.copyTo(ps.shared);return s.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(s),i}if(t.fill instanceof Zo){const i=t.fill,s=e.createPattern(i.texture.source.resource,"repeat"),n=i.transform.copyTo(ps.shared);return n.scale(i.texture.frame.width,i.texture.frame.height),s.setTransform(n),s}if(t.fill instanceof Wo){const n=t.fill,r="linear"===n.type,o="local"===n.textureSpace;let a,h=1,l=1;o&&i&&(h=i.width+s,l=i.height+s);let c=!1;if(r){const{start:t,end:i}=n;a=e.createLinearGradient(t.x*h,t.y*l,i.x*h,i.y*l),c=Math.abs(i.x-t.x)<Math.abs(.1*(i.y-t.y))}else{const{center:t,innerRadius:i,outerCenter:s,outerRadius:r}=n;a=e.createRadialGradient(t.x*h,t.y*l,i*h,s.x*h,s.y*l,r*h)}if(c&&o&&i){const t=i.lineHeight/l;for(let e=0;e<i.lines.length;e++){const r=(e*i.lineHeight+s/2)/l;n.colorStops.forEach(e=>{const i=r+e.offset*t;a.addColorStop(Math.floor(i*bh)/bh,yn.shared.setValue(e.color).toHex())})}}else n.colorStops.forEach(t=>{a.addColorStop(t.offset,yn.shared.setValue(t.color).toHex())});return a}return o(),"red"}function fe(t,e,i,s){const n={width:0,height:0,offsetY:0,scale:e.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};n.offsetY=i.baseLineOffset;let r=n.lines[0],o=null,a=!0;const h={width:0,start:0,index:0,positions:[],chars:[]},l=i.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*l,d=e.wordWrapWidth*l,u=e.lineHeight?e.lineHeight*l:i.lineHeight,p=e.wordWrap&&e.breakWords,g=t=>{const e=r.width;for(let i=0;i<h.index;i++){const s=t.positions[i];r.chars.push(t.chars[i]),r.charPositions.push(s+e)}r.width+=t.width,a=!1,h.width=0,h.index=0,h.chars.length=0},f=()=>{let t=r.chars.length-1;if(s){let e=r.chars[t];for(;" "===e;)r.width-=i.chars[e].xAdvance,e=r.chars[--t]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,n.lines.push(r),n.height+=u},m=t=>t-c>d;for(let s=0;s<t.length+1;s++){let n;const l=s===t.length;l||(n=t[s]);const d=i.chars[n]||i.chars[" "];if(/(?:\s)/.test(n)||"\r"===n||"\n"===n||l){if(!a&&e.wordWrap&&m(r.width+h.width)?(f(),g(h),l||r.charPositions.push(0)):(h.start=r.width,g(h),l||r.charPositions.push(0)),"\r"===n||"\n"===n)f();else if(!l){const t=d.xAdvance+(d.kerning[o]||0)+c;r.width+=t,r.spaceWidth=t,r.spacesIndex.push(r.charPositions.length),r.chars.push(n)}}else{const t=d.kerning[o]||0,e=d.xAdvance+t+c;p&&m(r.width+h.width+e)&&(g(h),f()),h.positions[h.index++]=h.width+t,h.chars.push(n),h.width+=e}o=n}return f(),"center"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],s=t.width/2-i.width/2;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=s}}(n):"right"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],s=t.width-i.width;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=s}}(n):"justify"===e.align&&function(t){const e=t.width;for(let i=0;i<t.lines.length;i++){const s=t.lines[i];let n=0,r=s.spacesIndex[n++],o=0;const a=s.spacesIndex.length,h=(e-s.width)/a;for(let t=0;t<s.charPositions.length;t++)t===r&&(r=s.spacesIndex[n++],o+=h),s.charPositions[t]+=o}}(n),n}async function me(t){if("Image"in globalThis)return new Promise(e=>{const i=new Image;i.onload=()=>{e(!0)},i.onerror=()=>{e(!1)},i.src=t});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(t)).blob();await createImageBitmap(e)}catch(t){return!1}return!0}return!1}function ye(t){return!Dh&&""!==document.createElement("video").canPlayType(t)}function xe(t,e){if(Array.isArray(e)){for(const i of e)if(t.startsWith(`data:${i}`))return!0;return!1}return t.startsWith(`data:${e}`)}function be(t,e){const i=t.split("?")[0],s=mr.extname(i).toLowerCase();return Array.isArray(e)?e.includes(s):s===e}function ve(t){return Xh.test(t)?t:encodeURI(t)}function _e(t,e=1){const i=xr.RETINA_PREFIX?.exec(t);return i?parseFloat(i[1]):e}function we(t,e,i){t.label=i,t._sourceOrigin=i;const s=new Gs({source:t,label:i}),n=()=>{delete e.promiseCache[i],pr.has(i)&&pr.remove(i)};return s.source.once("destroy",()=>{e.promiseCache[i]&&(o(),n())}),s.once("destroy",()=>{t.destroyed||(o(),n())}),s}function Ae(t,e,i,s,n,r,o,a){const h=o-i,l=a-s,c=n-i,d=r-s,u=t-i,p=e-s,g=h*h+l*l,f=h*c+l*d,m=h*u+l*p,y=c*c+d*d,x=c*u+d*p,b=1/(g*y-f*f),v=(y*m-f*x)*b,_=(g*x-f*m)*b;return v>=0&&_>=0&&v+_<1}function Ce(t,e,i){for(let s=0,n=4*i*e;s<e;++s,n+=4)if(0!==t[n+3])return!1;return!0}function Se(t,e,i,s,n){const r=4*e;for(let e=s,o=s*r+4*i;e<=n;++e,o+=r)if(0!==t[o+3])return!1;return!0}function Ie(...t){let e=t[0];e.canvas||(e={canvas:t[0],resolution:t[1]});const{canvas:s}=e,n=Math.min(e.resolution??1,1),r=e.width??s.width,o=e.height??s.height;let a=e.output;if(function(t,e){Jl||(Jl=ir.get().createCanvas(256,128),Zl=Jl.getContext("2d",{willReadFrequently:!0}),Zl.globalCompositeOperation="copy",Zl.globalAlpha=1),(Jl.width<t||Jl.height<e)&&(Jl.width=i(t),Jl.height=i(e))}(r,o),!Zl)throw new TypeError("Failed to get canvas 2D context");Zl.drawImage(s,0,0,r,o,0,0,r*n,o*n);const h=Zl.getImageData(0,0,r,o).data;let l=0,c=0,d=r-1,u=o-1;for(;c<o&&Ce(h,r,c);)++c;if(c===o)return Ss.EMPTY;for(;Ce(h,r,u);)--u;for(;Se(h,r,l,c,u);)++l;for(;Se(h,r,d,c,u);)--d;return++d,++u,Zl.globalCompositeOperation="source-over",Zl.strokeRect(l,c,d-l,u-c),Zl.globalCompositeOperation="copy",a??(a=new Ss),a.set(l/n,c/n,(d-l)/n,(u-c)/n),a}function Me(t,e){for(const i in t.attributes){const s=t.attributes[i],n=e[i];n?(s.format??(s.format=n.format),s.offset??(s.offset=n.offset),s.instance??(s.instance=n.instance)):o()}!function(t){const{buffers:e,attributes:i}=t,s={},n={};for(const t in e){const i=e[t];s[i.uid]=0,n[i.uid]=0}for(const t in i){const e=i[t];s[e.buffer.uid]+=R(e.format).stride}for(const t in i){const e=i[t];e.stride??(e.stride=s[e.buffer.uid]),e.start??(e.start=n[e.buffer.uid]),n[e.buffer.uid]+=R(e.format).stride}}(t)}function Te(t){return Cc[t]??Cc.float32}function Pe(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0,s=0;for(let t=0;t<e.length;t++){const n=e[t];if(i=Lc[n.data.type],!i)throw new Error(`Unknown type ${n.data.type}`);n.data.size>1&&(i=Math.max(i,16)*n.data.size);const r=12===i?16:i;n.size=i;const o=s%16;s+=o>0&&16-o<r?(16-o)%16:(i-o%i)%i,n.offset=s,s+=i}return s=16*Math.ceil(s/16),{uboElements:e,size:s}}function Ee(t,e,i,s){const n=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let r=0;for(let o=0;o<t.length;o++){const a=t[o],h=a.data.name;let l=!1,c=0;for(let t=0;t<jc.length;t++)if(jc[t].test(a.data)){c=a.offset/4,n.push(`name = "${h}";`,`offset += ${c-r};`,jc[t][e]||jc[t].ubo),l=!0;break}if(!l)if(a.data.size>1)c=a.offset/4,n.push(i(a,c-r));else{const t=s[a.data.type];c=a.offset/4,n.push(`\n v = uv.${h};\n offset += ${c-r};\n ${t};\n `)}r=c}const o=n.join("\n");return new Function("uv","data","dataInt32","offset",o)}function Be(t,e){return`\n for (let i = 0; i < ${t*e}; i++) {\n data[offset + (((i / ${t})|0) * 4) + (i % ${t})] = v[i];\n }\n `}function Re(t,e){const i=Math.max(Lc[t.data.type]/16,1),s=t.data.value.length/t.data.size,n=(4-s%4)%4,r=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n offset += ${e};\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*i}; i++)\n {\n for(var j = 0; j < ${s}; j++)\n {\n ${r}[arrayOffset++] = v[t++];\n }\n ${0!==n?`arrayOffset += ${n};`:""}\n }\n `}function ke(t){return Ee(t,"uboStd40",Re,Gc)}function Oe(t,e){if(!Vc.has(t)){const i=new Gs({source:new sr({resource:t,...e})}),s=()=>{Vc.get(t)===i&&Vc.delete(t)};i.once("destroy",s),i.source.once("destroy",s),Vc.set(t,i)}return Vc.get(t)}function De(t,e,i){const s=t.createShader(e);return t.shaderSource(s,i),t.compileShader(s),s}function Fe(t){const e=new Array(t);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Le(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Fe(2*e);case"bvec3":return Fe(3*e);case"bvec4":return Fe(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}function je(t,e){if(!Kc){const e=Object.keys(Qc);Kc={};for(let i=0;i<e.length;++i){const s=e[i];Kc[t[s]]=Qc[s]}}return Kc[e]}function Ge(t,e){const i=je(t,e);return qc[i]||"float32"}function Ue(t,e){const i=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),s=t.getShaderInfoLog(e).split("\n"),n={},r=s.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||n[t]||(n[t]=!0,0))),o=[""];r.forEach(t=>{i[t-1]=`%c${i[t-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const a=i.join("\n");o[0]=a}function ze(t,e,i,s,n,r,o,a){const h=r;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const i=gd[o?"clamp-to-edge":t.addressModeU],s=gd[o?"clamp-to-edge":t.addressModeV],r=gd[o?"clamp-to-edge":t.addressModeW];e[n](h,e.TEXTURE_WRAP_S,i),e[n](h,e.TEXTURE_WRAP_T,s),e.TEXTURE_WRAP_R&&e[n](h,e.TEXTURE_WRAP_R,r)}if(a&&"linear"===t.magFilter||e[n](h,e.TEXTURE_MAG_FILTER,ud[t.magFilter]),i){if(!a||"linear"!==t.mipmapFilter){const i=pd[t.minFilter][t.mipmapFilter];e[n](h,e.TEXTURE_MIN_FILTER,i)}}else e[n](h,e.TEXTURE_MIN_FILTER,ud[t.minFilter]);if(s&&t.maxAnisotropy>1){const i=Math.min(t.maxAnisotropy,e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[n](h,s.TEXTURE_MAX_ANISOTROPY_EXT,i)}t.compare&&e[n](h,e.TEXTURE_COMPARE_FUNC,fd[t.compare])}function Ne(t,e){const i=t.instructionSet,s=i.instructions;for(let t=0;t<i.instructionSize;t++){const i=s[t];e[i.renderPipeId].execute(i)}}function Ve(t,e){e||(e=0);for(let i=e;i<t.length&&t[i];i++)t[i]=null}function He(t,e=!1){!function(t){const e=t.root;let i;if(t.renderGroupParent){const s=t.renderGroupParent;t.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),t.worldColor=u(e.groupColor,s.worldColor),i=e.groupAlpha*s.worldAlpha}else t.worldTransform.copyFrom(e.localTransform),t.worldColor=e.localColor,i=e.localAlpha;i=i<0?0:i>1?1:i,t.worldAlpha=i,t.worldColorAlpha=t.worldColor+(255*i<<24)}(t);const i=t.childrenToUpdate,s=t.updateTick++;for(const e in i){const n=Number(e),r=i[e],o=r.list,a=r.index;for(let e=0;e<a;e++){const i=o[e];i.parentRenderGroup===t&&i.relativeRenderGroupDepth===n&&We(i,s,0)}Ve(o,a),r.index=0}if(e)for(let i=0;i<t.renderGroupChildren.length;i++)He(t.renderGroupChildren[i],e)}function We(t,e,i){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const s=t.localTransform;t.updateLocalTransform();const n=t.parent;if(n&&!n.renderGroup?(i|=t._updateFlags,t.relativeGroupTransform.appendFrom(s,n.relativeGroupTransform),7&i&&Je(t,n,i)):(i=t._updateFlags,t.relativeGroupTransform.copyFrom(s),7&i&&Je(t,Ad,i)),!t.renderGroup){const s=t.children,n=s.length;for(let t=0;t<n;t++)We(s[t],e,i);const r=t.parentRenderGroup,o=t;o.renderPipeId&&!r.structureDidChange&&r.updateRenderable(o)}}function Je(t,e,i){if(1&i){t.groupColor=u(t.localColor,e.groupColor);let i=t.localAlpha*e.groupAlpha;i=i<0?0:i>1?1:i,t.groupAlpha=i,t.groupColorAlpha=t.groupColor+(255*i<<24)}2&i&&(t.groupBlendMode="inherit"===t.localBlendMode?e.groupBlendMode:t.localBlendMode),4&i&&(t.globalDisplayStatus=t.localDisplayStatus&e.globalDisplayStatus),t._updateFlags=0}function Ze(t,e,i){const s=(t>>24&255)/255;e[i++]=(255&t)/255*s,e[i++]=(t>>8&255)/255*s,e[i++]=(t>>16&255)/255*s,e[i++]=s}function Xe(t){let e=!1;for(const i in t)if(null==t[i]){e=!0;break}if(!e)return t;const i=Object.create(null);for(const e in t){const s=t[e];s&&(i[e]=s)}return i}function Ye(t){let e=0;for(let i=0;i<t.length;i++)null==t[i]?e++:t[i-e]=t[i];return t.length-=e,t}function Ke(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0;for(let t=0;t<e.length;t++){const s=e[t];let n=pu[s.data.type].size;const r=pu[s.data.type].align;if(!pu[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(n=Math.max(n,r)*s.data.size),i=Math.ceil(i/r)*r,s.size=n,s.offset=i,i+=n}return i=16*Math.ceil(i/16),{uboElements:e,size:i}}function Qe(t,e){const{size:i,align:s}=pu[t.data.type],n=(s-i)/4,r=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n ${0!==e?`offset += ${e};`:""}\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*(i/4)}; i++)\n {\n for(var j = 0; j < ${i/4}; j++)\n {\n ${r}[arrayOffset++] = v[t++];\n }\n ${0!==n?`arrayOffset += ${n};`:""}\n }\n `}function qe(t){return Ee(t,"uboWgsl",Qe,Uc)}function $e(t,e=null){const i=6*t;if(i>65535?e||(e=new Uint32Array(i)):e||(e=new Uint16Array(i)),e.length!==i)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${i}`);for(let t=0,s=0;t<i;t+=6,s+=4)e[t+0]=s+0,e[t+1]=s+1,e[t+2]=s+2,e[t+3]=s+0,e[t+4]=s+2,e[t+5]=s+3;return e}function ti(t,e){const i=[];i.push("\n\n var index = 0;\n\n for (let i = 0; i < ps.length; ++i)\n {\n const p = ps[i];\n\n ");let s=0;for(const n in t){const r=t[n];e===r.dynamic&&(i.push(`offset = index + ${s}`),i.push(r.code),s+=R(r.format).stride/4)}i.push("\n index += stride * 4;\n }\n "),i.unshift(`\n var stride = ${s};\n `);const n=i.join("\n");return new Function("ps","f32v","u32v",n)}function ei(t,e){e.groupTransform=t.groupTransform,e.groupColorAlpha=t.groupColorAlpha,e.groupColor=t.groupColor,e.groupBlendMode=t.groupBlendMode,e.globalDisplayStatus=t.globalDisplayStatus,e.groupTransform=t.groupTransform,e.localDisplayStatus=t.localDisplayStatus,e.groupAlpha=t.groupAlpha,e._roundPixels=t._roundPixels}function ii(t,e){const{texture:i,bounds:s}=t,n=e._style._getFinalPadding();r(s,e._anchor,i);const o=e._anchor._x*n*2,a=e._anchor._y*n*2;s.minX-=n-o,s.minY-=n-a,s.maxX-=n-o,s.maxY-=n-a}function si(t,e,i,s){const n=Ip;n.minX=0,n.minY=0,n.maxX=t.width/s|0,n.maxY=t.height/s|0;const r=Nn.getOptimalTexture(n.width,n.height,s,!1);return r.source.uploadMethodId="image",r.source.resource=t,r.source.alphaMode="premultiply-alpha-on-upload",r.frame.width=e/s,r.frame.height=i/s,r.source.emit("update",r.source),r.updateUvs(),r}function ni(t){return Xp[t>>4]+Xp[15&t]}function ri(t,e){return Np[(t>>e&3).toString(2).padStart(2,"0")]}function oi(t,e,i,s){let n=3&t,r=t>>2&63;if(1===n||62===r)i.push(e);else if(0===n&&r<=31)s.has(r)||s.set(r,[]),s.get(r).push(e);else if(0===n){let t;switch(r){case 60:t=Jp.NO_ROOM_DATA;break;case 61:t=Jp.ROOM_GAP;break;case 62:t=Jp.OBSTACLE_ROOM;break;case 63:t=Jp.UNKNOWN_ROOM}void 0!==t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}}function ai(t){switch(t){case 28:return Jp.NO_ROOM_DATA;case 29:return Jp.ROOM_GAP;case 30:return Jp.OBSTACLE_ROOM;case 31:return Jp.UNKNOWN_ROOM;default:return}}function hi(t,e,i,s,n){let r=7&t,o=t>>3&31;if(1===r||30===o)i.push(e);else if(2===r)if(s.push(e),o<=27)n.has(o)||n.set(o,[]),n.get(o).push(e);else{let t=ai(o);void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}else if(7===r)if(o<=27)n.has(o)||n.set(o,[]),n.get(o).push(e);else{let t=ai(o);void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}}function li(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Xg&&Xg in Object(t)?function(t){var e=Hg.call(t,Jg),i=t[Jg];try{t[Jg]=void 0;var s=!0}catch(t){}var n=Wg.call(t);return s&&(e?t[Jg]=i:delete t[Jg]),n}(t):function(t){return Zg.call(t)}(t)}function ci(t){return null!=t&&"object"==typeof t}function di(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ui(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||ci(t)&&"[object Symbol]"==li(t)}(t))return NaN;if(di(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=di(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;var i;t=(i=t)?i.slice(0,function(t){for(var e=t.length;e--&&Kg.test(t.charAt(e)););return e}(i)+1).replace(Qg,""):i;var s=$g.test(t);return s||tf.test(t)?ef(t.slice(2),s?2:8):qg.test(t)?NaN:+t}function pi(t){return t}function gi(t){if(!di(t))return!1;var e=li(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function fi(t){if(null!=t){try{return rf.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function mi(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!di(t)||(e=t,nf&&nf in e))&&(gi(t)?df:of).test(fi(t));var e}(i)?i:void 0}function yi(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&bf.test(t))&&t>-1&&t%1==0&&t<e}function xi(t,e,i){"__proto__"==e&&mf?mf(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function bi(t,e){return t===e||t!=t&&e!=e}function vi(t,e,i){var s=t[e];vf.call(t,e)&&bi(s,i)&&(void 0!==i||e in t)||xi(t,e,i)}function _i(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function wi(t){return null!=t&&_i(t.length)&&!gi(t)}function Ai(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||wf)}function Ci(t){return ci(t)&&"[object Arguments]"==li(t)}function Si(t,e){var i=Yg(t),s=!i&&If(t),n=!i&&!s&&Ef(t),r=!i&&!s&&!n&&jf(t),o=i||s||n||r,a=o?function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s}(t.length,String):[],h=a.length;for(var l in t)!e&&!Gf.call(t,l)||o&&("length"==l||n&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||yi(l,h))||a.push(l);return a}function Ii(t,e){return function(i){return t(e(i))}}function Mi(t){return wi(t)?Si(t,!0):function(t){if(!di(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=Ai(t),i=[];for(var s in t)("constructor"!=s||!e&&Nf.call(t,s))&&i.push(s);return i}(t)}function Ti(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function Pi(t,e){for(var i=t.length;i--;)if(bi(t[i][0],e))return i;return-1}function Ei(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function Bi(t,e){var i=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?i["string"==typeof e?"string":"hash"]:i.map}function Ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function ki(t){var e=this.__data__=new Ei(t);this.size=e.size}function Oi(t){return function(t,e,i){var s=function(t){return wi(t)?Si(t):function(t){if(!Ai(t))return Uf(t);var e=[];for(var i in Object(t))zf.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}(t);return Yg(t)?s:function(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t}(s,i(t))}(t,0,rm)}function Di(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Ri;++e<i;)this.add(t[e])}function Fi(t,e){for(var i=-1,s=null==t?0:t.length;++i<s;)if(e(t[i],i,t))return!0;return!1}function Li(t,e,i,s,n,r){var o=1&i,a=t.length,h=e.length;if(a!=h&&!(o&&h>a))return!1;var l=r.get(t),c=r.get(e);if(l&&c)return l==e&&c==t;var d=-1,u=!0,p=2&i?new Di:void 0;for(r.set(t,e),r.set(e,t);++d<a;){var g=t[d],f=e[d];if(s)var m=o?s(f,g,d,e,t,r):s(g,f,d,t,e,r);if(void 0!==m){if(m)continue;u=!1;break}if(p){if(!Fi(e,function(t,e){if(o=e,!p.has(o)&&(g===t||n(g,t,i,s,r)))return p.push(e);var o})){u=!1;break}}else if(g!==f&&!n(g,f,i,s,r)){u=!1;break}}return r.delete(t),r.delete(e),u}function ji(t){var e=-1,i=Array(t.size);return t.forEach(function(t,s){i[++e]=[s,t]}),i}function Gi(t){var e=-1,i=Array(t.size);return t.forEach(function(t){i[++e]=t}),i}function Ui(t,e,i,s,n){return t===e||(null==t||null==e||!ci(t)&&!ci(e)?t!=t&&e!=e:function(t,e,i,s,n,r){var o=Yg(t),a=Yg(e),h=o?Im:bm(t),l=a?Im:bm(e),c=(h=h==Sm?Mm:h)==Mm,d=(l=l==Sm?Mm:l)==Mm,u=h==l;if(u&&Ef(t)){if(!Ef(e))return!1;o=!0,c=!1}if(u&&!c)return r||(r=new ki),o||jf(t)?Li(t,e,i,s,n,r):function(t,e,i,s,n,r,o){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new vm(t),new vm(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return bi(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=ji;case"[object Set]":var h=1&s;if(a||(a=Gi),t.size!=e.size&&!h)return!1;var l=o.get(t);if(l)return l==e;s|=2,o.set(t,e);var c=Li(a(t),a(e),s,n,r,o);return o.delete(t),c;case"[object Symbol]":if(Am)return Am.call(t)==Am.call(e)}return!1}(t,e,h,i,s,n,r);if(!(1&i)){var p=c&&Tm.call(t,"__wrapped__"),g=d&&Tm.call(e,"__wrapped__");if(p||g){var f=p?t.value():t,m=g?e.value():e;return r||(r=new ki),n(f,m,i,s,r)}}return!!u&&(r||(r=new ki),function(t,e,i,s,n,r){var o=1&i,a=Oi(t),h=a.length;if(h!=Oi(e).length&&!o)return!1;for(var l=h;l--;){var c=a[l];if(!(o?c in e:Cm.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var p=!0;r.set(t,e),r.set(e,t);for(var g=o;++l<h;){var f=t[c=a[l]],m=e[c];if(s)var y=o?s(m,f,c,e,t,r):s(f,m,c,t,e,r);if(!(void 0===y?f===m||n(f,m,i,s,r):y)){p=!1;break}g||(g="constructor"==c)}if(p&&!g){var x=t.constructor,b=e.constructor;x==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(p=!1)}return r.delete(t),r.delete(e),p}(t,e,i,s,n,r))}(t,e,i,s,Ui,n))}function zi(t,e,i){function s(e){var i=h,s=l;return h=l=void 0,g=e,d=t.apply(s,i)}function n(t){var i=t-p;return void 0===p||i>=e||i<0||m&&t-g>=c}function r(){var t=Em();if(n(t))return o(t);u=setTimeout(r,function(t){var i=e-(t-p);return m?Rm(i,c-(t-g)):i}(t))}function o(t){return u=void 0,y&&h?s(t):(h=l=void 0,d)}function a(){var t=Em(),i=n(t);if(h=arguments,l=this,p=t,i){if(void 0===u)return function(t){return g=t,u=setTimeout(r,e),f?s(t):d}(p);if(m)return clearTimeout(u),u=setTimeout(r,e),s(p)}return void 0===u&&(u=setTimeout(r,e)),d}var h,l,c,d,u,p,g=0,f=!1,m=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return e=ui(e)||0,di(i)&&(f=!!i.leading,c=(m="maxWait"in i)?Bm(ui(i.maxWait)||0,e):c,y="trailing"in i?!!i.trailing:y),a.cancel=function(){void 0!==u&&clearTimeout(u),g=0,h=p=l=u=void 0},a.flush=function(){return void 0===u?d:o(Em())},a}function Ni(t,e,i){(void 0!==i&&!bi(t[e],i)||void 0===i&&!(e in t))&&xi(t,e,i)}function Vi(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Hi(t,e,i,s,n){t!==e&&Pm(e,function(r,o){if(n||(n=new ki),di(r))!function(t,e,i,s,n,r,o){var a=Vi(t,i),h=Vi(e,i),l=o.get(h);if(l)Ni(t,i,l);else{var c,d=r?r(a,h,i+"",t,e,o):void 0,u=void 0===d;if(u){var p=Yg(h),g=!p&&Ef(h),f=!p&&!g&&jf(h);d=h,p||g||f?Yg(a)?d=a:ci(c=a)&&wi(c)?d=function(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e}(a):g?(u=!1,d=h.slice()):f?(u=!1,d=function(t){var e=function(t){var e=new t.constructor(t.byteLength);return new vm(e).set(new vm(t)),e}(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(h)):d=[]:function(t){if(!ci(t)||"[object Object]"!=li(t))return!1;var e=Xf(t);if(null===e)return!0;var i=qf.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&Qf.call(i)==$f}(h)||If(h)?(d=a,If(a)?d=function(t){return function(t,e,i){var s=!i;i||(i={});for(var n=-1,r=e.length;++n<r;){var o=e[n],a=void 0;void 0===a&&(a=t[o]),s?xi(i,o,a):vi(i,o,a)}return i}(t,Mi(t))}(a):di(a)&&!gi(a)||(d=function(t){return"function"!=typeof t.constructor||Ai(t)?{}:gf(Xf(t))}(h))):u=!1}u&&(o.set(h,d),n(d,h,s,r,o),o.delete(h)),Ni(t,i,d)}}(t,e,o,i,Hi,s,n);else{var a=s?s(Vi(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Ni(t,o,a)}},Mi)}function Wi(t,e){return Ui(t,e)}function Ji(t,e,i){var s=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return di(i)&&(s="leading"in i?!!i.leading:s,n="trailing"in i?!!i.trailing:n),zi(t,e,{leading:s,maxWait:e,trailing:n})}function Zi(t={}){if(!Gm(t))throw new Error("object required");const e=Wm.get(t);if(e)return e;let i=Hm[0];const s=new Set,n=(t,e=++Hm[0])=>{i!==e&&(r=i=e,s.forEach(i=>i(t,e)))};let r=i;const o=t=>(e,i)=>{const s=[...e];s[1]=[t,...s[1]],n(s,i)},a=new Map;let h=!0;const l=Ym(()=>h,(t,e)=>{const i=!Nm.has(e)&&zm.get(e);if(i){if("production"!==(jm?"core":void 0)&&a.has(t))throw new Error("prop listener already exists");if(s.size){const e=i[2](o(t));a.set(t,[i,e])}else a.set(t,[i])}},t=>{var e;const i=a.get(t);i&&(a.delete(t),null==(e=i[1])||e.call(i))},n),c=Zm(t,l);Wm.set(t,c);const d=[t,(t=Hm[0])=>(r!==t&&(r=t,a.forEach(([e])=>{const s=e[1](t);s>i&&(i=s)})),i),t=>(s.add(t),1===s.size&&a.forEach(([t,e],i)=>{if("production"!==(jm?"core":void 0)&&e)throw new Error("remove already exists");const s=t[2](o(i));a.set(i,[t,s])}),()=>{s.delete(t),0===s.size&&a.forEach(([t,e],i)=>{e&&(e(),a.set(i,[t]))})})];return zm.set(c,d),Reflect.ownKeys(t).forEach(e=>{const i=Object.getOwnPropertyDescriptor(t,e);"value"in i&&i.writable&&(c[e]=t[e])}),h=!1,c}function Xi(t,e,i,s){let n=t[e];return function(t,e){const i=zm.get(t);let s;const n=[],r=i[2];let o=!1;const a=r(t=>{n.push(t),s||(s=Promise.resolve().then(()=>{s=void 0,o&&e(n.splice(0))}))});return o=!0,()=>{o=!1,a()}}(t,()=>{const s=t[e];Object.is(n,s)||i(n=s)})}function Yi(){return ry.getService()}function Ki(){return dx||(dx=1,Object.defineProperty(bx,"__esModule",{value:!0}),bx.loop=bx.conditional=bx.parse=void 0,bx.parse=function t(e,i){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s;if(Array.isArray(i))i.forEach(function(i){return t(e,i,s,n)});else if("function"==typeof i)i(e,s,n,t);else{var r=Object.keys(i)[0];Array.isArray(i[r])?(n[r]={},t(e,i[r],s,n[r])):n[r]=i[r](e,s,n,t)}return s},bx.conditional=function(t,e){return function(i,s,n,r){e(i,s,n)&&r(i,t,s,n)}},bx.loop=function(t,e){return function(i,s,n,r){for(var o=[],a=i.pos;e(i,s,n);){var h={};if(r(i,t,s,h),i.pos===a)break;a=i.pos,o.push(h)}return o}}),bx}function Qi(){if(ux)return vx;ux=1,Object.defineProperty(vx,"__esModule",{value:!0}),vx.readBits=vx.readArray=vx.readUnsigned=vx.readString=vx.peekBytes=vx.readBytes=vx.peekByte=vx.readByte=vx.buildStream=void 0,vx.buildStream=function(t){return{data:t,pos:0}},vx.readByte=function(){return function(t){return t.data[t.pos++]}},vx.peekByte=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e){return e.data[e.pos+t]}};var t=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};return vx.readBytes=t,vx.peekBytes=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}},vx.readString=function(e){return function(i){return Array.from(t(e)(i)).map(function(t){return String.fromCharCode(t)}).join("")}},vx.readUnsigned=function(e){return function(i){var s=t(2)(i);return e?(s[1]<<8)+s[0]:(s[0]<<8)+s[1]}},vx.readArray=function(e,i){return function(s,n,r){for(var o="function"==typeof i?i(s,n,r):i,a=t(e),h=new Array(o),l=0;l<o;l++)h[l]=a(s);return h}},vx.readBits=function(t){return function(e){for(var i=function(t){return t.data[t.pos++]}(e),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(e,i){var n=t[i];return n.length?e[i]=function(t,e,i){for(var s=0,n=0;n<i;n++)s+=t[e+n]&&Math.pow(2,i-n-1);return s}(s,n.index,n.length):e[i]=s[n.index],e},{})}},vx}var qi=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(qi||{});const $i=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},ts=(t,e)=>$i(t).priority??e,es={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map($i).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...t){return t.map($i).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,s=this._queue;i[e]?i[e]?.(t):(s[e]=s[e]||[],s[e]?.push(t))})}),this},handle(t,e,i){const s=this._addHandlers,n=this._removeHandlers;if(s[t]||n[t])throw new Error(`Extension type ${t} already has a handler`);s[t]=e,n[t]=i;const r=this._queue;return r[t]&&(r[t]?.forEach(t=>e(t)),delete r[t]),this},handleByMap(t,e){return this.handle(t,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(t,e,i=-1){return this.handle(t,t=>{e.findIndex(e=>e.name===t.name)>=0||(e.push({name:t.name,value:t.ref}),e.sort((t,e)=>ts(e.value,i)-ts(t.value,i)))},t=>{const i=e.findIndex(e=>e.name===t.name);-1!==i&&e.splice(i,1)})},handleByList(t,e,i=-1){return this.handle(t,t=>{e.includes(t.ref)||(e.push(t.ref),e.sort((t,e)=>ts(e,i)-ts(t,i)))},t=>{const i=e.indexOf(t.ref);-1!==i&&e.splice(i,1)})},mixin(t,...e){for(const i of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(i))}},is={extension:{type:qi.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>Nx)}},ss={extension:{type:qi.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then(()=>Vx)}};class ns{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ns(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=${this._x} y=${this._y} 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))}}var rs,os={exports:{}};const as=t((rs||(rs=1,function(t){function e(){}function i(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,s,n,r){if("function"!=typeof s)throw new TypeError("The listener must be a function");var o=new i(s,n||t,r),h=a?a+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function n(t,i){0===--t._eventsCount?t._events=new e:delete t._events[i]}function r(){this._events=new e,this._eventsCount=0}var o=Object.prototype.hasOwnProperty,a="~";Object.create&&(e.prototype=Object.create(null),(new e).__proto__||(a=!1)),r.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)o.call(t,e)&&i.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},r.prototype.listeners=function(t){var e=a?a+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,r=new Array(n);s<n;s++)r[s]=i[s].fn;return r},r.prototype.listenerCount=function(t){var e=a?a+t:t,i=this._events[e];return i?i.fn?1:i.length:0},r.prototype.emit=function(t,e,i,s,n,r){var o=a?a+t:t;if(!this._events[o])return!1;var h,l,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,s),!0;case 5:return c.fn.call(c.context,e,i,s,n),!0;case 6:return c.fn.call(c.context,e,i,s,n,r),!0}for(l=1,h=new Array(d-1);l<d;l++)h[l-1]=arguments[l];c.fn.apply(c.context,h)}else{var u,p=c.length;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),d){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,i);break;case 4:c[l].fn.call(c[l].context,e,i,s);break;default:if(!h)for(u=1,h=new Array(d-1);u<d;u++)h[u-1]=arguments[u];c[l].fn.apply(c[l].context,h)}}return!0},r.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},r.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},r.prototype.removeListener=function(t,e,i,s){var r=a?a+t:t;if(!this._events[r])return this;if(!e)return n(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||s&&!o.once||i&&o.context!==i||n(this,r);else{for(var h=0,l=[],c=o.length;h<c;h++)(o[h].fn!==e||s&&!o[h].once||i&&o[h].context!==i)&&l.push(o[h]);l.length?this._events[r]=1===l.length?l[0]:l:n(this,r)}return this},r.prototype.removeAllListeners=function(t){var i;return t?(i=a?a+t:t,this._events[i]&&n(this,i)):(this._events=new e,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=a,r.EventEmitter=r,t.exports=r}(os)),os.exports)),hs=2*Math.PI,ls=180/Math.PI,cs=Math.PI/180;class ds{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ds(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 us.x=0,us.y=0,us}}const us=new ds;class ps{constructor(t=1,e=0,i=0,s=1,n=0,r=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r}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,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,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 ds;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new ds;const i=this.a,s=this.b,n=this.c,r=this.d,o=this.tx,a=this.ty,h=1/(i*r+n*-s),l=t.x,c=t.y;return e.x=r*h*l+-n*h*c+(a*n-o*r)*h,e.y=i*h*c+-s*h*l+(-a*i+o*s)*h,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),s=this.a,n=this.c,r=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,r=t.d,o=t.tx,a=t.ty,h=e.a,l=e.b,c=e.c,d=e.d;return this.a=i*h+s*c,this.b=i*l+s*d,this.c=n*h+r*c,this.d=n*l+r*d,this.tx=o*h+a*c+e.tx,this.ty=o*l+a*d+e.ty,this}setTransform(t,e,i,s,n,r,o,a,h){return this.a=Math.cos(o+h)*n,this.b=Math.sin(o+h)*n,this.c=-Math.sin(o-a)*r,this.d=Math.cos(o-a)*r,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,r=t.pivot,o=-Math.atan2(-s,n),a=Math.atan2(i,e),h=Math.abs(o+a);return h<1e-5||Math.abs(hs-h)<1e-5?(t.rotation=a,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=a),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(r.x*e+r.y*s),t.position.y=this.ty+(r.x*i+r.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,r=t*s-e*i;return this.a=s/r,this.b=-e/r,this.c=-i/r,this.d=t/r,this.tx=(i*this.ty-s*n)/r,this.ty=-(t*this.ty-e*n)/r,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}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 ps;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 fs.identity()}static get shared(){return gs.identity()}}const gs=new ps,fs=new ps,ms=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ys=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],xs=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],bs=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],vs=[],_s=[],ws=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];vs.push(e);for(let i=0;i<16;i++){const s=ws(ms[t]*ms[i]+xs[t]*ys[i]),n=ws(ys[t]*ms[i]+bs[t]*ys[i]),r=ws(ms[t]*xs[i]+xs[t]*bs[i]),o=ws(ys[t]*xs[i]+bs[t]*bs[i]);for(let t=0;t<16;t++)if(ms[t]===s&&ys[t]===n&&xs[t]===r&&bs[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new ps;e.set(ms[t],ys[t],xs[t],bs[t],0,0),_s.push(e)}}();const As={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>ms[t],uY:t=>ys[t],vX:t=>xs[t],vY:t=>bs[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>vs[t][e],sub:(t,e)=>vs[t][As.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?As.S:As.N:2*Math.abs(e)<=Math.abs(t)?t>0?As.E:As.W:e>0?t>0?As.SE:As.SW:t>0?As.NE:As.NW,matrixAppendRotationInv:(t,e,i=0,s=0)=>{const n=_s[As.inv(e)];n.tx=i,n.ty=s,t.append(n)},transformRectCoords:(t,e,i,s)=>{const{x:n,y:r,width:o,height:a}=t,{x:h,y:l,width:c,height:d}=e;return i===As.E?(s.set(n+h,r+l,o,a),s):i===As.S?s.set(c-r-a+h,n+l,a,o):i===As.W?s.set(c-n-o+h,d-r-a+l,o,a):i===As.N?s.set(r+h,d-n-o+l,a,o):s.set(n+h,r+l,o,a)}},Cs=[new ds,new ds,new ds,new ds];class Ss{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}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 Ss(0,0,0,0)}clone(){return new Ss(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)&&t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:r}=this;if(n<=0||r<=0)return!1;const o=this.x,a=this.y,h=i*(1-s),l=i-h;return t>=o-h&&t<=o+n+h&&e>=a-h&&e<=a+r+h&&!(t>o+l&&t<o+n-l&&e>a+l&&e<a+r-l)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const i=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>i}const i=this.left,s=this.right,n=this.top,r=this.bottom;if(s<=i||r<=n)return!1;const o=Cs[0].set(t.left,t.top),a=Cs[1].set(t.left,t.bottom),h=Cs[2].set(t.right,t.top),l=Cs[3].set(t.right,t.bottom);if(h.x<=o.x||a.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(0===c)return!1;if(e.apply(o,o),e.apply(a,a),e.apply(h,h),e.apply(l,l),Math.max(o.x,a.x,h.x,l.x)<=i||Math.min(o.x,a.x,h.x,l.x)>=s||Math.max(o.y,a.y,h.y,l.y)<=n||Math.min(o.y,a.y,h.y,l.y)>=r)return!1;const d=c*(a.y-o.y),u=c*(o.x-a.x),p=d*i+u*n,g=d*s+u*n,f=d*i+u*r,m=d*s+u*r;if(Math.max(p,g,f,m)<=d*o.x+u*o.y||Math.min(p,g,f,m)>=d*l.x+u*l.y)return!1;const y=c*(o.y-h.y),x=c*(h.x-o.x),b=y*i+x*n,v=y*s+x*n,_=y*i+x*r,w=y*s+x*r;return!(Math.max(b,v,_,w)<=y*o.x+x*o.y||Math.min(b,v,_,w)>=y*l.x+x*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=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(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=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=i-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=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=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new Ss),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Is={default:-1},Ms=new Set,Ts={quiet:!1,noColor:!1},Ps=(t,e,i=3)=>{if(Ts.quiet||Ms.has(e))return;let s=(new Error).stack;"function"==typeof console.groupCollapsed&&Ts.noColor,void 0===s||(s=s.split("\n").splice(i).join("\n")),Ms.add(e)};Object.defineProperties(Ps,{quiet:{get:()=>Ts.quiet,set:t=>{Ts.quiet=t},enumerable:!0,configurable:!1},noColor:{get:()=>Ts.noColor,set:t=>{Ts.noColor=t},enumerable:!0,configurable:!1}});const Es=()=>{},Bs=Object.create(null),Rs=class t extends as{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...t.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){Ps(0,"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=function(t){const i=Bs[t];return void 0===i&&(Bs[t]=e("resource")),i}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Rs.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ks=Rs;const Os=class t extends as{constructor(i={}){super(),this.options=i,this.uid=e("textureSource"),this._resourceType="textureSource",this._resourceId=e("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,i={...t.defaultOptions,...i},this.label=i.label??"",this.resource=i.resource,this.autoGarbageCollect=i.autoGarbageCollect,this._resolution=i.resolution,i.width?this.pixelWidth=i.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,i.height?this.pixelHeight=i.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=i.format,this.dimension=i.dimensions,this.mipLevelCount=i.mipLevelCount,this.autoGenerateMipmaps=i.autoGenerateMipmaps,this.sampleCount=i.sampleCount,this.antialias=i.antialias,this.alphaMode=i.alphaMode,this.style=new ks(n(i)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}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=e("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,i,s){s||(s=this._resolution),t||(t=this.width),i||(i=this.height);const n=Math.round(t*s),r=Math.round(i*s);return this.width=n/s,this.height=r/s,this._resolution=s,(this.pixelWidth!==n||this.pixelHeight!==r)&&(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=e("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=s(this.pixelWidth)&&s(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Os.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ds=Os;class Fs extends Ds{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(i=e instanceof Float32Array?"rgba32float":e instanceof Int32Array||e instanceof Uint32Array?"rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?"rgba16uint":(Int8Array,"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}}Fs.extension=qi.TextureSource;const Ls=new ps;class js{constructor(t,e){this.mapCoord=new ps,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?t.width<10?0:.5:e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],r=t[s+1];e[s]=n*i.a+r*i.c+i.tx,e[s+1]=n*i.b+r*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,s=t.trim;s&&(Ls.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Ls));const n=t.source,r=this.uClampFrame,o=this.clampMargin/n._resolution,a=this.clampOffset/n._resolution;return r[0]=(t.frame.x+o+a)/n.width,r[1]=(t.frame.y+o+a)/n.height,r[2]=(t.frame.x+t.frame.width-o+a)/n.width,r[3]=(t.frame.y+t.frame.height-o+a)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&0===t.rotate,!0}}class Gs extends as{constructor({source:t,label:i,frame:s,orig:n,trim:r,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=e("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Ss,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=i,this.source=t?.source??new Ds,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=n||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!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 js(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:s}=this._source,n=e.x/i,r=e.y/s,o=e.width/i,a=e.height/s;let h=this.rotate;if(h){const e=o/2,i=a/2,s=n+e,l=r+i;h=As.add(h,As.NW),t.x0=s+e*As.uX(h),t.y0=l+i*As.uY(h),h=As.add(h,2),t.x1=s+e*As.uX(h),t.y1=l+i*As.uY(h),h=As.add(h,2),t.x2=s+e*As.uX(h),t.y2=l+i*As.uY(h),h=As.add(h,2),t.x3=s+e*As.uX(h),t.y3=l+i*As.uY(h)}else t.x0=n,t.y0=r,t.x1=n+o,t.y1=r,t.x2=n+o,t.y2=r+a,t.x3=n,t.y3=r+a}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 Ps(0,"Texture.baseTexture is now Texture.source"),this._source}}Gs.EMPTY=new Gs({label:"EMPTY",source:new Ds({label:"EMPTY"})}),Gs.EMPTY.destroy=Es,Gs.WHITE=new Gs({source:new Fs({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),Gs.WHITE.destroy=Es;const Us=new ps;class zs{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Us,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Ss);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=Us,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const r=n.a,o=n.b,a=n.c,h=n.d,l=n.tx,c=n.ty;let d=this.minX,u=this.minY,p=this.maxX,g=this.maxY,f=r*t+a*e+l,m=o*t+h*e+c;f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),f=r*i+a*e+l,m=o*i+h*e+c,f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),f=r*t+a*s+l,m=o*t+h*s+c,f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),f=r*i+a*s+l,m=o*i+h*s+c,f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),this.minX=d,this.minY=u,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,s=this.maxX,n=this.maxY,{a:r,b:o,c:a,d:h,tx:l,ty:c}=t;let d=r*e+a*i+l,u=o*e+h*i+c;this.minX=d,this.minY=u,this.maxX=d,this.maxY=u,d=r*s+a*i+l,u=o*s+h*i+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*e+a*n+l,u=o*e+h*n+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*s+a*n+l,u=o*s+h*n+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u: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,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),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 zs(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,s){let n=this.minX,r=this.minY,o=this.maxX,a=this.maxY;s||(s=this.matrix);const h=s.a,l=s.b,c=s.c,d=s.d,u=s.tx,p=s.ty;for(let s=e;s<i;s+=2){const e=t[s],i=t[s+1],g=h*e+c*i+u,f=l*e+d*i+p;n=g<n?g:n,r=f<r?f:r,o=g>o?g:o,a=f>a?f:a}this.minX=n,this.minY=r,this.maxX=o,this.maxY=a}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}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var Ns={grad:.9,turn:360,rad:360/(2*Math.PI)},Vs=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},Hs=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},Ws=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},Js=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Zs=function(t){return{r:Ws(t.r,0,255),g:Ws(t.g,0,255),b:Ws(t.b,0,255),a:Ws(t.a)}},Xs=function(t){return{r:Hs(t.r),g:Hs(t.g),b:Hs(t.b),a:Hs(t.a,3)}},Ys=/^#([0-9a-f]{3,8})$/i,Ks=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Qs=function(t){var e=t.r,i=t.g,s=t.b,n=t.a,r=Math.max(e,i,s),o=r-Math.min(e,i,s),a=o?r===e?(i-s)/o:r===i?2+(s-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:n}},qs=function(t){var e=t.h,i=t.s,s=t.v,n=t.a;e=e/360*6,i/=100,s/=100;var r=Math.floor(e),o=s*(1-i),a=s*(1-(e-r)*i),h=s*(1-(1-e+r)*i),l=r%6;return{r:255*[s,a,o,o,h,s][l],g:255*[h,s,s,a,o,o][l],b:255*[o,o,h,s,s,a][l],a:n}},$s=function(t){return{h:Js(t.h),s:Ws(t.s,0,100),l:Ws(t.l,0,100),a:Ws(t.a)}},tn=function(t){return{h:Hs(t.h),s:Hs(t.s),l:Hs(t.l),a:Hs(t.a,3)}},en=function(t){return qs((i=(e=t).s,{h:e.h,s:(i*=((s=e.l)<50?s:100-s)/100)>0?2*i/(s+i)*100:0,v:s+i,a:e.a}));var e,i,s},sn=function(t){return{h:(e=Qs(t)).h,s:(n=(200-(i=e.s))*(s=e.v)/100)>0&&n<200?i*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:e.a};var e,i,s,n},nn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hn={string:[[function(t){var e=Ys.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?Hs(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?Hs(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=on.exec(t)||an.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Zs({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=nn.exec(t)||rn.exec(t);if(!e)return null;var i,s,n=$s({h:(i=e[1],s=e[2],void 0===s&&(s="deg"),Number(i)*(Ns[s]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return en(n)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,s=t.b,n=t.a,r=void 0===n?1:n;return Vs(e)&&Vs(i)&&Vs(s)?Zs({r:Number(e),g:Number(i),b:Number(s),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,i=t.s,s=t.l,n=t.a,r=void 0===n?1:n;if(!Vs(e)||!Vs(i)||!Vs(s))return null;var o=$s({h:Number(e),s:Number(i),l:Number(s),a:Number(r)});return en(o)},"hsl"],[function(t){var e=t.h,i=t.s,s=t.v,n=t.a,r=void 0===n?1:n;if(!Vs(e)||!Vs(i)||!Vs(s))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(s),a:Number(r)},{h:Js(o.h),s:Ws(o.s,0,100),v:Ws(o.v,0,100),a:Ws(o.a)});return qs(a)},"hsv"]]},ln=function(t,e){for(var i=0;i<e.length;i++){var s=e[i][0](t);if(s)return[s,e[i][1]]}return[null,void 0]},cn=function(t,e){var i=sn(t);return{h:i.h,s:Ws(i.s+100*e,0,100),l:i.l,a:i.a}},dn=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},un=function(t,e){var i=sn(t);return{h:i.h,s:i.s,l:Ws(i.l+100*e,0,100),a:i.a}},pn=function(){function t(t){this.parsed=function(t){return"string"==typeof t?ln(t.trim(),hn.string):"object"==typeof t&&null!==t?ln(t,hn.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return Hs(dn(this.rgba),2)},t.prototype.isDark=function(){return dn(this.rgba)<.5},t.prototype.isLight=function(){return dn(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=Xs(this.rgba)).r,i=t.g,s=t.b,r=(n=t.a)<1?Ks(Hs(255*n)):"","#"+Ks(e)+Ks(i)+Ks(s)+r;var t,e,i,s,n,r},t.prototype.toRgb=function(){return Xs(this.rgba)},t.prototype.toRgbString=function(){return e=(t=Xs(this.rgba)).r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},t.prototype.toHsl=function(){return tn(sn(this.rgba))},t.prototype.toHslString=function(){return e=(t=tn(sn(this.rgba))).h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},t.prototype.toHsv=function(){return t=Qs(this.rgba),{h:Hs(t.h),s:Hs(t.s),v:Hs(t.v),a:Hs(t.a,3)};var t},t.prototype.invert=function(){return gn({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),gn(cn(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),gn(cn(this.rgba,-t))},t.prototype.grayscale=function(){return gn(cn(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),gn(un(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),gn(un(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?gn({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Hs(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=sn(this.rgba);return"number"==typeof t?gn({h:t,s:e.s,l:e.l,a:e.a}):Hs(e.h)},t.prototype.isEqual=function(t){return this.toHex()===gn(t).toHex()},t}(),gn=function(t){return t instanceof pn?t:new pn(t)},fn=[];[function(t,e){var i={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"},s={};for(var n in i)s[i[n]]=n;var r={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var n,o,a=s[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var h=this.toRgb(),l=1/0,c="black";if(!r.length)for(var d in i)r[d]=new t(i[d]).toRgb();for(var u in i){var p=(n=h,o=r[u],Math.pow(n.r-o.r,2)+Math.pow(n.g-o.g,2)+Math.pow(n.b-o.b,2));p<l&&(l=p,c=u)}return c}},e.string.push([function(e){var s=e.toLowerCase(),n="transparent"===s?"#0000":i[s];return n?new t(n).toRgb():null},"name"])}].forEach(function(t){fn.indexOf(t)<0&&(t(pn,hn),fn.push(t))});const mn=class t{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(e){if(e instanceof t)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,e)||(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every((t,i)=>t===e[i]);if(null!==t&&null!==e){const i=Object.keys(t),s=Object.keys(e);return i.length===s.length&&i.every(i=>t[i]===e[i])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}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,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*s),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,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)+(65280&t)+((255&t)<<16)}multiply(e){const[i,s,n,r]=t._temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=255&this._int;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(255*t<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(e){let i,s,n,r;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215)i=(e>>16&255)/255,s=(e>>8&255)/255,n=(255&e)/255,r=1;else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,s,n,r=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,s,n,r=255]=e,i/=255,s/=255,n/=255,r/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=gn(e);o.isValid()&&(({r:i,g:s,b:n,a:r}=o.rgba),i/=255,s/=255,n/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(e){return"number"==typeof e||"string"==typeof e||e instanceof Number||e instanceof t||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||void 0!==e.r&&void 0!==e.g&&void 0!==e.b||void 0!==e.r&&void 0!==e.g&&void 0!==e.b&&void 0!==e.a||void 0!==e.h&&void 0!==e.s&&void 0!==e.l||void 0!==e.h&&void 0!==e.s&&void 0!==e.l&&void 0!==e.a||void 0!==e.h&&void 0!==e.s&&void 0!==e.v||void 0!==e.h&&void 0!==e.s&&void 0!==e.v&&void 0!==e.a}};mn.shared=new mn,mn._temp=new mn,mn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let yn=mn,xn=0;const bn={_registeredResources:new Set,register(t){this._registeredResources.add(t)},unregister(t){this._registeredResources.delete(t)},release(){this._registeredResources.forEach(t=>t.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(t){return this._registeredResources.has(t)},reset(){this._registeredResources.clear()}};class vn{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){let e;return e=this._index>0?this._pool[--this._index]:new this._classType,e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}const _n=new class{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 vn(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}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}};bn.register(_n);const wn={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){Ps(0,"cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}},An={allowChildren:!0,removeChildren(t=0,e){const i=e??this.children.length,s=i-t,n=[];if(s>0&&s<=i){for(let e=i-1;e>=t;e--){const t=this.children[e];t&&(n.push(t),t.parent=null)}a(this.children,t,i);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(n);for(let t=0;t<n.length;++t){const e=n[t];e.parentRenderLayer?.detach(e),this.emit("childRemoved",e,this,t),n[t].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}if(0===s&&0===this.children.length)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||Ps(0,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:i}=this;if(e<0||e>i.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${i.length}`);if(t.parent){const i=t.parent.children.indexOf(t);if(t.parent===this&&i===e)return t;-1!==i&&t.parent.children.splice(i,1)}e===i.length?i.push(t):i.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(t),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",t,this,e),t.emit("added",this),t},swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...t){return 1===t.length?this.reparentChildAt(t[0],this.children.length):(t.forEach(t=>this.reparentChildAt(t,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const i=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const s=this.worldTransform.clone();return s.invert(),i.prepend(s),t.setFromMatrix(i),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},Cn={collectRenderables(t,e,i){this.parentRenderLayer&&this.parentRenderLayer!==i||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,i):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,i))},collectRenderablesSimple(t,e,i){const s=this.children,n=s.length;for(let r=0;r<n;r++)s[r].collectRenderables(t,e,i)},collectRenderablesWithEffects(t,e,i){const{renderPipes:s}=e;for(let e=0;e<this.effects.length;e++){const i=this.effects[e];s[i.pipe].push(i,this,t)}this.collectRenderablesSimple(t,e,i);for(let e=this.effects.length-1;e>=0;e--){const i=this.effects[e];s[i.pipe].pop(i,this,t)}}};class Sn{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}}const In=new class{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 _n.get(i.maskClass,t)}return t}returnMaskEffect(t){_n.return(t)}};es.handleByList(qi.MaskEffect,In._effectClasses);const Mn={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){-1===this.effects.indexOf(t)&&(this.effects.push(t),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);-1!==e&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;e?.mask!==t&&(e&&(this.removeEffect(e),In.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=In.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new Sn),i=t?.length>0,s=i!==e.filters?.length>0;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),s&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){return this._filterEffect?.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new Sn),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},Tn={label:null,get name(){return Ps(0,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){Ps(0,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const i=this.children;for(let e=0;e<i.length;e++){const s=i[e];if(s.label===t||t instanceof RegExp&&t.test(s.label))return s}if(e)for(let e=0;e<i.length;e++){const s=i[e].getChildByLabel(t,!0);if(s)return s}return null},getChildrenByLabel(t,e=!1,i=[]){const s=this.children;for(let e=0;e<s.length;e++){const n=s[e];(n.label===t||t instanceof RegExp&&t.test(n.label))&&i.push(n)}if(e)for(let e=0;e<s.length;e++)s[e].getChildrenByLabel(t,!0,i);return i}},Pn=_n.getPool(ps),En=_n.getPool(zs),Bn=new ps,Rn={getFastGlobalBounds(t,e){e||(e=new zs),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const i=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(i.worldTransform),e},_getGlobalBoundsRecursive(t,e,i){let s=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==i)return;if(7!==this.localDisplayStatus||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(s=En.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const t=this.bounds;s.addFrame(t.minX,t.minY,t.maxX,t.maxY,this.groupTransform)}const e=this.children;for(let n=0;n<e.length;n++)e[n]._getGlobalBoundsRecursive(t,s,i)}if(n){let t=!1;const i=this.renderGroup||this.parentRenderGroup;for(let e=0;e<this.effects.length;e++)this.effects[e].addBounds&&(t||(t=!0,s.applyMatrix(i.worldTransform)),this.effects[e].addBounds(s,!0));t&&s.applyMatrix(i.worldTransform.copyTo(Bn).invert()),e.addBounds(s),En.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),En.return(s))}},kn=16777215,On={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,i=this.parent;for(;i;)e*=i.alpha,i=i.parent;return e},getGlobalTransform(t=new ps,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=c(this,Pn.get().identity());return t.appendFrom(this.localTransform,i),Pn.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?p(this.renderGroup.worldColor):this.parentRenderGroup?p(u(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,i=this.parent;for(;i;)e=u(e,i.localColor),i=i.parent;return p(e)}},Dn=new ps,Fn={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const i=Math.sign(this.scale.x)||1;this.scale.x=0!==e?t/e*i:i},_setHeight(t,e){const i=Math.sign(this.scale.y)||1;this.scale.y=0!==e?t/e*i:i},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new zs});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),m(this,t),t.didChange&&g(this,t.localBounds,Dn),t.localBounds},getBounds(t,e){return h(this,t,e||new zs)}},Ln={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&e?.removeOnRender(this),void(this._onRender=null);this._onRender||e?.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},jn={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,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(y))}},Gn={getGlobalPosition(t=new ds,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,i=!1){const s=this.getGlobalTransform(Pn.get(),i);return e=s.apply(t,e),Pn.return(s),e},toLocal(t,e,i,s){e&&(t=e.toGlobal(t,i,s));const n=this.getGlobalTransform(Pn.get(),s);return i=n.applyInverse(t,i),Pn.return(n),i}};class Un{constructor(){this.uid=e("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize}}let zn=0;const Nn=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new ks(this.textureOptions)}createTexture(t,e,i){const s=new Ds({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new Gs({source:s,label:"texturePool_"+zn++})}getOptimalTexture(t,e,s=1,n){let r=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);r=i(r),o=i(o);const a=(r<<17)+(o<<1)+(n?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(r,o,n)),h.source._resolution=s,h.source.width=r/s,h.source.height=o/s,h.source.pixelWidth=r,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=!1!==t)for(const t in this._texturePool){const e=this._texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0)}this._texturePool={}}};bn.register(Nn);class Vn{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new ps,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Un,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let t=0;t<e.length;t++){const i=e[t];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Nn.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}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)return void this.addRenderGroupChild(t.renderGroup);t._onRender&&this.addOnRender(t);const e=t.children;for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup)return void this._removeRenderGroupChild(t.renderGroup);const e=t.children;for(let t=0;t<e.length;t++)this.removeChild(e[t])}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||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}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 t=0;t<i.length;t++)this._getChildren(i[t],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new ps),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new ps),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(4&this._matrixDirty))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new ps),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}const Hn=new ns(null),Wn=new ns(null),Jn=new ns(null,1,1),Zn=new ns(null);class Xn extends as{constructor(t={}){super(),this.uid=e("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.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new ps,this.relativeGroupTransform=new ps,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ns(this,0,0),this._scale=Jn,this._pivot=Wn,this._origin=Zn,this._skew=Hn,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._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],function(t,e,i={}){for(const s in e)i[s]||void 0===e[s]||(t[s]=e[s])}(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(t=>this.addChild(t)),t.parent?.addChild(this)}static mixin(t){Ps(0,"Container.mixin is deprecated, please use extensions.mixin instead."),es.mixin(Xn,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=4095&t}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...t){if(this.allowChildren||Ps(0,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let e=0;e<t.length;e++)this.addChild(t[e]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.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._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,0!==e._zIndex&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let e=0;e<t.length;e++)this.removeChild(t[e]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=_n.get(Vn,this),this.groupTransform=ps.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),_n.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new ps),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*ls}set angle(t){this.rotation=t*cs}get pivot(){return this._pivot===Wn&&(this._pivot=new ns(this,0,0)),this._pivot}set pivot(t){this._pivot===Wn&&(this._pivot=new ns(this,0,0),this._origin!==Zn&&o()),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Hn&&(this._skew=new ns(this,0,0)),this._skew}set skew(t){this._skew===Hn&&(this._skew=new ns(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Jn&&(this._scale=new ns(this,1,1)),this._scale}set scale(t){this._scale===Jn&&(this._scale=new ns(this,0,0)),"string"==typeof t&&(t=parseFloat(t)),"number"==typeof t?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Zn&&(this._origin=new ns(this,0,0)),this._origin}set origin(t){this._origin===Zn&&(this._origin=new ns(this,0,0),this._pivot!==Wn&&o()),"number"==typeof t?this._origin.set(t):this._origin.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();"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,i.width),void 0!==e&&this._setHeight(e,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("number"==typeof t.x?t.x:this.position.x,"number"==typeof t.y?t.y:this.position.y),this.scale.set("number"==typeof t.scaleX?t.scaleX||1:this.scale.x,"number"==typeof t.scaleY?t.scaleY||1:this.scale.y),this.rotation="number"==typeof t.rotation?t.rotation:this.rotation,this.skew.set("number"==typeof t.skewX?t.skewX:this.skew.x,"number"==typeof t.skewY?t.skewY:this.skew.y),this.pivot.set("number"==typeof t.pivotX?t.pivotX:this.pivot.x,"number"==typeof t.pivotY?t.pivotY:this.pivot.y),this.origin.set("number"==typeof t.originX?t.originX:this.origin.x,"number"==typeof t.originY?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,s=this._pivot,n=this._origin,r=this._position,o=i._x,a=i._y,h=s._x,l=s._y,c=-n._x,d=-n._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=r._x-(h*e.a+l*e.c)+(c*e.a+d*e.c)-c,e.ty=r._y-(h*e.b+l*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=yn.shared.setValue(t??16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=1,this._onUpdate())}get tint(){return p(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(t){const e=t?2:0;(2&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(t){const e=t?0:4;(4&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(t){const e=t?1:0;(1&this.localDisplayStatus)!==e&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;let e;if(this.destroyed=!0,this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),("boolean"==typeof t?t:t?.children)&&e)for(let i=0;i<e.length;++i)e[i].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}es.mixin(Xn,An,Rn,Gn,Ln,Fn,Mn,Tn,jn,{cullArea:null,cullable:!1,cullableChildren:!0},wn,On,Cn);class Yn extends Xn{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new zs(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:s}=t;return i>=e.minX&&i<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){super.destroy(t),this._bounds=null;for(const t in this._gpuData)this._gpuData[t].destroy?.();this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:s}=e;s.blendMode.pushBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,r=n.length;for(let s=0;s<r;s++)n[s].collectRenderables(t,e,i);s.blendMode.popBlendMode(t)}}class Kn extends Yn{constructor(t=Gs.EMPTY){t instanceof Gs&&(t={texture:t});const{texture:e=Gs.EMPTY,anchor:i,roundPixels:s,width:n,height:r,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new ns({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=s??!1,void 0!==n&&(this.width=n),void 0!==r&&(this.height=r)}static from(t,e=!1){return new Kn(t instanceof Gs?t:Gs.from(t,e))}set texture(t){t||(t=Gs.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._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return r(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return Ps(0,"Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:s,height:n}=e.orig;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}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){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const Qn=new zs;class qn{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Kn),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){this.inverse||x(this.mask,t,e)}addLocalBounds(t,e){b(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Kn}}qn.extension=qi.MaskEffect;class $n{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}$n.extension=qi.MaskEffect;class tr{constructor(t){this.priority=0,this.pipe="stencilMask",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){x(this.mask,t,e)}addLocalBounds(t,e){b(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Xn}}tr.extension=qi.MaskEffect;let er={createCanvas:(t,e)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,i},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const ir={get:()=>er,set(t){er=t}};class sr extends Ds{constructor(t){t.resource||(t.resource=ir.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,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(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 s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}sr.extension=qi.TextureSource;class nr extends Ds{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}nr.extension=qi.TextureSource;var rr=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(rr||{});class or{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,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 ar=class t{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 or(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=rr.NORMAL){return this._addListener(new or(t,e,i))}addOnce(t,e,i=rr.NORMAL){return this._addListener(new or(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():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(e=performance.now()){let i;if(e>this.lastTime){if(i=this.elapsedMS=e-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*t.targetFPMS;const s=this._head;let n=s.next;for(;n;)n=n.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const i=Math.min(this.maxFPS,e),s=Math.min(Math.max(0,i)/1e3,t.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};ar.targetFPMS=.06;let hr,lr=ar;const cr=class t extends Ds{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...t.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=e.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),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=lr.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 _(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,void 0!==e.preloadTimeoutMs&&(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&&(lr.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(lr.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(lr.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};cr.extension=qi.TextureSource,cr.defaultOptions={...Ds.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},cr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let dr=cr;const ur=(t,e,i=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||i?e(t):t):t),pr=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||o(),e}set(t,e){const i=ur(t);let s;for(let t=0;t<this.parsers.length;t++){const n=this.parsers[t];if(n.test(e)){s=n.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(t=>{n.set(t,e)});const r=[...n.keys()],a={cacheKeys:r,keys:i};i.forEach(t=>{this._cacheMap.set(t,a)}),r.forEach(t=>{const i=s?s[t]:e;this._cache.has(t)&&this._cache.get(t)!==i&&o(),this._cache.set(t,n.get(t))})}remove(t){if(!this._cacheMap.has(t))return void o();const e=this._cacheMap.get(t);e.cacheKeys.forEach(t=>{this._cache.delete(t)}),e.keys.forEach(t=>{this._cacheMap.delete(t)})}get parsers(){return this._parsers}},gr=[];es.handleByList(qi.TextureSource,gr),Gs.from=function(t,e=!1){return"string"==typeof t?pr.get(t):t instanceof Ds?new Gs({source:t}):function(t={},e=!1){const i=t&&t.resource,s=i?t.resource:t,n=i?t:{resource:t};if(!e&&pr.has(s))return pr.get(s);const r=new Gs({source:w(n)});return r.on("destroy",()=>{pr.has(s)&&pr.remove(s)}),e||pr.set(s,r),r}(t,e)},Ds.from=w,es.add(qn,$n,tr,dr,nr,sr,Fs);var fr=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(fr||{});const mr={toPosix:t=>t.replace(new RegExp("\\".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"/"),isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){A(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,e,i){if(A(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const s=C(this.toPosix(e??ir.get().getBaseUrl())),n=C(this.toPosix(i??this.rootname(s)));return(t=this.toPosix(t)).startsWith("/")?mr.join(n,t.slice(1)):this.isAbsolute(t)?t:this.join(s,t)},normalize(t){if(A(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const i=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const s=t.endsWith("/");return(t=function(t){let e="",i=0,s=-1,n=0,r=-1;for(let o=0;o<=t.length;++o){if(o<t.length)r=t.charCodeAt(o);else{if(47===r)break;r=47}if(47===r){if(s===o-1||1===n);else if(s!==o-1&&2===n){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",i=0):(e=e.slice(0,t),i=e.length-1-e.lastIndexOf("/")),s=o,n=0;continue}}else if(2===e.length||1===e.length){e="",i=0,s=o,n=0;continue}}else e.length>0?e+=`/${t.slice(s+1,o)}`:e=t.slice(s+1,o),i=o-s-1;s=o,n=0}else 46===r&&-1!==n?++n:n=-1}return e}(t)).length>0&&s&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return A(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const s=t[i];if(A(s),s.length>0)if(void 0===e)e=s;else{const n=t[i-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(A(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let s=-1,n=!0;const r=this.getProtocol(t),o=t;for(let i=(t=t.slice(r.length)).length-1;i>=1;--i)if(e=t.charCodeAt(i),47===e){if(!n){s=i;break}}else n=!1;return-1===s?i?"/":this.isUrl(o)?r+t:r:i&&1===s?"//":r+t.slice(0,s)},rootname(t){A(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",e.length);e=-1!==i?t.slice(0,i):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){A(t),e&&A(e),t=C(this.toPosix(t));let i,s=0,n=-1,r=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(i=t.length-1;i>=0;--i){const h=t.charCodeAt(i);if(47===h){if(!r){s=i+1;break}}else-1===a&&(r=!1,a=i+1),o>=0&&(h===e.charCodeAt(o)?-1===--o&&(n=i):(o=-1,n=a))}return s===n?n=a:-1===n&&(n=t.length),t.slice(s,n)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!r){s=i+1;break}}else-1===n&&(r=!1,n=i+1);return-1===n?"":t.slice(s,n)},extname(t){A(t);let e=-1,i=0,s=-1,n=!0,r=0;for(let o=(t=C(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===s&&(n=!1,s=o+1),46===a?-1===e?e=o:1!==r&&(r=1):-1!==e&&(r=-1);else if(!n){i=o+1;break}}return-1===e||-1===s||0===r||1===r&&e===s-1&&e===i+1?"":t.slice(e,s)},parse(t){A(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=C(this.toPosix(t))).charCodeAt(0);const s=this.isAbsolute(t);let n;e.root=this.rootname(t),n=s||this.hasProtocol(t)?1:0;let r=-1,o=0,a=-1,h=!0,l=t.length-1,c=0;for(;l>=n;--l)if(i=t.charCodeAt(l),47!==i)-1===a&&(h=!1,a=l+1),46===i?-1===r?r=l:1!==c&&(c=1):-1!==r&&(c=-1);else if(!h){o=l+1;break}return-1===r||-1===a||0===c||1===c&&r===a-1&&r===o+1?-1!==a&&(e.base=e.name=0===o&&s?t.slice(1,a):t.slice(o,a)):(0===o&&s?(e.name=t.slice(1,r),e.base=t.slice(1,a)):(e.name=t.slice(o,r),e.base=t.slice(o,a)),e.ext=t.slice(r,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]},yr=t=>!Array.isArray(t);class xr{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,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return ur(e||i,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>t?.src??t):t?.src?t.src:t,!0)}addManifest(t){this._manifest&&o(),this._manifest=t,t.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([t,e])=>"string"==typeof e||Array.isArray(e)?{alias:t,src:e}:{alias:t,...e})),s.forEach(e=>{const s=e.src,n=e.alias;let r;if("string"==typeof n){const e=this._createBundleAssetId(t,n);i.push(e),r=[n,e]}else{const e=n.map(e=>this._createBundleAssetId(t,e));i.push(...e),r=[...n,...e]}this.add({...e,alias:r,src:s})}),this._bundles[t]=i}add(t){const e=[];let i;Array.isArray(t)?e.push(...t):e.push(t),i=t=>{this.hasKey(t)&&o()},ur(e).forEach(t=>{const{src:e}=t;let{data:s,format:n,loadParser:r,parser:o}=t;const a=ur(e).map(t=>"string"==typeof t?I(t):Array.isArray(t)?t:[t]),h=this.getAlias(t);Array.isArray(h)?h.forEach(i):i(h);const l=[];a.forEach(e=>{e.forEach(e=>{let i={};if("object"!=typeof e){i.src=e;for(let t=0;t<this._parsers.length;t++){const s=this._parsers[t];if(s.test(e)){i=s.parse(e);break}}}else s=e.data??s,n=e.format??n,(e.loadParser||e.parser)&&(r=e.loadParser??r,o=e.parser??o),i={...i,...e};if(!h)throw new Error(`[Resolver] alias is undefined for this asset: ${i.src}`);i=this._buildResolvedAsset(i,{aliases:h,data:s,format:n,loadParser:r,parser:o,progressSize:t.progressSize}),l.push(i)})}),h.forEach(t=>{this._assetMap[t]=l})})}resolveBundle(t){const e=yr(t);t=ur(t);const i={};return t.forEach(t=>{const e=this._bundles[t];if(e){const s=this.resolve(e),n={};for(const e in s){const i=s[e];n[this._extractAssetIdFromBundle(t,e)]=i}i[t]=n}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if("string"!=typeof t){const t={};for(const i in e)t[i]=e[i].src;return t}return e.src}resolve(t){const e=yr(t);t=ur(t);const i={};return t.forEach(t=>{if(!this._resolverHash[t])if(this._assetMap[t]){let e=this._assetMap[t];const i=this._getPreferredOrder(e);i?.priority.forEach(t=>{i.params[t].forEach(i=>{const s=e.filter(e=>!!e[t]&&e[t]===i);s.length&&(e=s)})}),this._resolverHash[t]=e[0]}else this._resolverHash[t]=this._buildResolvedAsset({alias:[t],src:t},{});i[t]=this._resolverHash[t]}),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[e],s=this._preferredOrder.find(t=>t.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){return this._defaultSearchParams?`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`:t}_buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,parser:r,format:o,progressSize:a}=e;return(this._basePath||this._rootPath)&&(t.src=mr.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.parser=r??t.parser,t.format=o??t.format??t.src.split(".").pop().split("?").shift().split("#").shift(),void 0!==a&&(t.progressSize=a),t}}xr.RETINA_PREFIX=/@([0-9\.]+)x/;const br=(t,e)=>{const i=e.split("?")[1];return i&&(t+=`?${i}`),t},vr=class t{constructor(t,e){this.linkedSheets=[];let i=t;t?.source instanceof Ds&&(i={texture:t,data:e});const{texture:s,data:n,cachePrefix:r=""}=i;this.cachePrefix=r,this._texture=s instanceof Gs?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const o=parseFloat(n.meta.scale);o?(this.resolution=o,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=t.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let i=e;const s=t.BATCH_SIZE;for(;i-e<s&&i<this._frameKeys.length;){const t=this._frameKeys[i],e=this._frames[t],s=e.frame;if(s){let i=null,n=null;const r=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,o=new Ss(0,0,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution);i=e.rotated?new Ss(Math.floor(s.x)/this.resolution,Math.floor(s.y)/this.resolution,Math.floor(s.h)/this.resolution,Math.floor(s.w)/this.resolution):new Ss(Math.floor(s.x)/this.resolution,Math.floor(s.y)/this.resolution,Math.floor(s.w)/this.resolution,Math.floor(s.h)/this.resolution),!1!==e.trimmed&&e.spriteSourceSize&&(n=new Ss(Math.floor(e.spriteSourceSize.x)/this.resolution,Math.floor(e.spriteSourceSize.y)/this.resolution,Math.floor(s.w)/this.resolution,Math.floor(s.h)/this.resolution)),this.textures[t]=new Gs({source:this.textureSource,frame:i,orig:o,trim:n,rotate:e.rotated?2:0,defaultAnchor:e.anchor,defaultBorders:e.borders,label:t.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];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*t.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*t.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};vr.BATCH_SIZE=1e3;let _r=vr;const wr=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"],Ar={extension:qi.Asset,cache:{test:t=>t instanceof _r,getCacheableAssets:(t,e)=>M(t,e,!1)},resolver:{extension:{type:qi.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),s=e.pop();return"json"===i&&wr.includes(s)},parse:t=>{const e=t.split(".");return{resolution:parseFloat(xr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:qi.LoadParser,priority:fr.Normal,name:"spritesheetLoader"},testParse:async(t,e)=>".json"===mr.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,i){const{texture:s,imageFilename:n,textureOptions:r,cachePrefix:o}=e?.data??{};let a,h=mr.dirname(e.src);if(h&&h.lastIndexOf("/")!==h.length-1&&(h+="/"),s instanceof Gs)a=s;else{const s=br(h+(n??t.meta.image),e.src);a=(await i.load([{src:s,data:r}]))[s]}const l=new _r({texture:a.source,data:t,cachePrefix:o});await l.parse();const c=t?.meta?.related_multi_packs;if(Array.isArray(c)){const t=[];for(const s of c){if("string"!=typeof s)continue;let n=h+s;e.data?.ignoreMultiPack||(n=br(n,e.src),t.push(i.load({src:n,data:{textureOptions:r,ignoreMultiPack:!0}})))}const s=await Promise.all(t);l.linkedSheets=s,s.forEach(t=>{t.linkedSheets=[l].concat(l.linkedSheets.filter(e=>e!==t))})}return l},async unload(t,e,i){await i.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};es.add(Ar);class Cr{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),e=this._canvas.width,i=this._canvas.height,s=t.width/e*this._renderer.resolution,n=t.height/i*this._renderer.resolution,r=`translate(${t.left}px, ${t.top}px) scale(${s}, ${n})`;r!==this._lastTransform&&(this._domElement.style.transform=r,this._lastTransform=r)},this._domElement=t.domElement,this._renderer=t.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas||(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const t=this.canvas.width,i=this.canvas.height,s=e.contentRect.width/t*this._renderer.resolution,n=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==n)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=n)}}),this._observer.observe(this._canvas)):this._tickerAttached||lr.shared.add(this.updateTranslation,this,rr.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&lr.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class Sr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Sr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ds,this.page=new ds,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,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}}var Ir=/iPhone/i,Mr=/iPod/i,Tr=/iPad/i,Pr=/\biOS-universal(?:.+)Mac\b/i,Er=/\bAndroid(?:.+)Mobile\b/i,Br=/Android/i,Rr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,kr=/Silk/i,Or=/Windows Phone/i,Dr=/\bWindows(?:.+)ARM\b/i,Fr=/BlackBerry/i,Lr=/BB10/i,jr=/Opera Mini/i,Gr=/\b(CriOS|Chrome)(?:.+)Mobile/i,Ur=/Mobile(?:.+)Firefox\b/i,zr=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};const Nr=(T.default??T)(globalThis.navigator),Vr=class t{constructor(t,e=Nr){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.pointerEvents="none",this._div.style.zIndex=2..toString(),this._canvasObserver=new Cr({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;for(const t in this._pools)this._pools[t].forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),delete this._pools[t];this._div&&this._div.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let t=0;t<e.length;t++)this._updateAccessibleObjects(e[t])}init(e){const i={accessibilityOptions:{...t.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount)return;if(this._androidUpdateCount=t+this._androidUpdateFrequency,!(this._renderer.renderingToScreen&&this._renderer.view.canvas||this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const t of this._children)t._renderId===this._renderId&&e.add(this._children.indexOf(t))}for(let t=this._children.length-1;t>=0;t--){const i=this._children[t];e.has(t)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,a(this._children,t,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let t=0;t<this._children.length;t++){const e=this._children[t];if(!e._accessibleActive||!e._accessibleDiv)continue;const i=e._accessibleDiv,s=e.hitArea||e.getBounds().rectangle;if(e.hitArea){const t=e.worldTransform;i.style.left=`${t.tx+s.x*t.a}px`,i.style.top=`${t.ty+s.y*t.d}px`,i.style.width=s.width*t.a+"px",i.style.height=s.height*t.d+"px"}else this._capHitArea(s),i.style.left=`${s.x}px`,i.style.top=`${s.y}px`,i.style.width=`${s.width}px`,i.style.height=`${s.height}px`}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._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):("button"===t.accessibleType?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText="\n color: transparent;\n pointer-events: none;\n padding: 0;\n margin: 0;\n border: 0;\n outline: 0;\n background: transparent;\n box-sizing: border-box;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n ",t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title=`container ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:i}=t.target,s=this._renderer.events.rootBoundary,n=Object.assign(new Sr(s),{target:i});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>s.dispatchEvent(n,t))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){9===t.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};Vr.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"accessibility"},Vr.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Hr=Vr;const Wr=Object.create(null),Jr=Object.create(null);let Zr,Xr;const Yr={},Kr={},Qr={stripVersion:function(t,e){return e?t.replace("#version 300 es",""):t},ensurePrecision:function(t,e,i){const s=i?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if("precision"!==t.substring(0,9)){let n=i?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===n&&"highp"!==s&&(n="mediump"),`precision ${n} float;\n${t}`}return"highp"!==s&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t},addProgramDefines:function(t,e,i){return e?t:i?`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${t=t.replace("out vec4 finalColor;","")}\n `:`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${t}\n `},setProgramName:function(t,{name:e="pixi-program"},i=!0){e=e.replace(/\s+/g,"-");const s=i?Yr:Kr;return s[e+=i?"-fragment":"-vertex"]?(s[e]++,e+=`-${s[e]}`):s[e]=1,-1!==t.indexOf("#define SHADER_NAME")?t:`#define SHADER_NAME ${e}\n${t}`},insertVersion:function(t,e){return e?`#version 300 es\n${t}`:t}},qr=Object.create(null),$r=class t{constructor(e){const i=-1!==(e={...t.defaultOptions,...e}).fragment.indexOf("#version 300 es"),s={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:B()},setProgramName:{name:e.name},addProgramDefines:i,insertVersion:i};let n=e.fragment,r=e.vertex;Object.keys(Qr).forEach(t=>{const e=s[t];n=Qr[t](n,e,!0),r=Qr[t](r,e,!1)}),this.fragment=n,this.vertex=r,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=P(`${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,qr[this._cacheKey]=null}static from(e){const i=`${e.vertex}:${e.fragment}`;return qr[i]||(qr[i]=new t(e),qr[i]._cacheKey=i),qr[i]}};$r.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let to=$r;const eo={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}},io={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"};var so=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(so||{});const no=Object.create(null);class ro{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:s,gpuLayout:n,name:r}=t;if(this.name=r,this.fragment=e,this.vertex=i,e.source===i.source){const t=k(e.source);this.structsAndGroups=t}else{const t=k(i.source),s=k(e.source);this.structsAndGroups=function(t,e){const i=new Set,s=new Set;return{structs:[...t.structs,...e.structs].filter(t=>!i.has(t.name)&&(i.add(t.name),!0)),groups:[...t.groups,...e.groups].filter(t=>{const e=`${t.name}-${t.binding}`;return!s.has(e)&&(s.add(e),!0)})}}(t,s)}this.layout=s??function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const s=t[i];e[s.group]||(e[s.group]={}),e[s.group][s.name]=s.binding}return e}(this.structsAndGroups),this.gpuLayout=n??function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const s=t[i];e[s.group]||(e[s.group]=[]),s.isUniform?e[s.group].push({binding:s.binding,visibility:so.VERTEX|so.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===s.type?e[s.group].push({binding:s.binding,visibility:so.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===s.type&&e[s.group].push({binding:s.binding,visibility:so.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=P(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=function({source:t,entryPoint:e}){const i={},s=t.indexOf(`fn ${e}`);if(-1!==s){const e=t.indexOf("->",s);if(-1!==e){const n=t.substring(s,e),r=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;null!==(o=r.exec(n));){const t=io[o[3]]??"float32";i[o[2]]={location:parseInt(o[1],10),format:t,stride:R(t).stride,offset:0,instance:!1,start:0}}}}return i}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,no[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return no[e]||(no[e]=new ro(t),no[e]._cacheKey=e),no[e]}}const oo=["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>","vec2<i32>","vec3<i32>","vec4<i32>"],ao=oo.reduce((t,e)=>(t[e]=!0,t),{}),ho=class t{constructor(i,s){this._touched=0,this.uid=e("uniform"),this._resourceType="uniformGroup",this._resourceId=e("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,s={...t.defaultOptions,...s},this.uniformStructures=i;const n={};for(const t in i){const e=i[t];if(e.name=t,e.size=e.size??1,!ao[e.type]){const t=e.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(t){const[,i,s]=t;throw new Error(`Uniform type ${e.type} is not supported. Use type: '${i}', size: ${s} instead.`)}throw new Error(`Uniform type ${e.type} is not supported. Supported uniform types are: ${oo.join(", ")}`)}e.value??(e.value=O(e.type,e.size)),n[t]=e.value}this.uniforms=n,this._dirtyId=1,this.ubo=s.ubo,this.isStatic=s.isStatic,this._signature=P(Object.keys(n).map(t=>`${t}-${i[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};ho.defaultOptions={ubo:!1,isStatic:!1};let lo=ho;class co{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,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){const i=this.resources[e];t!==i&&(i&&t.off?.("change",this.onResourceChange,this),t.on?.("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(){const t=this.resources;for(const e in t){const i=t[e];i?.off?.("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 uo=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(uo||{});class po extends as{constructor(t){super(),this.uid=e("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:i,glProgram:s,groups:n,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=i,this.glProgram=s,void 0===o&&(o=0,i&&(o|=uo.WEBGPU),s&&(o|=uo.WEBGL)),this.compatibleRenderers=o;const h={};if(r||n||(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!i&&n&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!i&&n&&a)for(const t in a)for(const e in a[t]){const i=a[t][e];h[i]={group:t,binding:e,name:i}}else if(i&&n&&!a){const t=i.structsAndGroups.groups;a={},t.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t})}else if(r){n={},a={},i&&i.structsAndGroups.groups.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t});let t=0;for(const e in r)h[e]||(n[99]||(n[99]=new co,this._ownedBindGroups.push(n[99])),h[e]={group:99,binding:t,name:e},a[99]=a[99]||{},a[99][t]=e,t++);for(const t in r){const e=t;let i=r[t];i.source||i._resourceType||(i=new lo(i));const s=h[e];s&&(n[s.group]||(n[s.group]=new co,this._ownedBindGroups.push(n[s.group])),n[s.group].setResource(i,s.binding))}}this.groups=n,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new co,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get:()=>t[n.group].getResource(n.binding),set(e){t[n.group].setResource(e,n.binding)}})}return i}destroy(t=!1){this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...s}=t;let n,r;return e&&(n=ro.from(e)),i&&(r=to.from(i)),new po({gpuProgram:n,glProgram:r,...s})}}const go={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},fo=class t{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}set cullMode(t){"none"!==t?(this.culling=!0,this.clockwiseFrontFace="front"===t):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend="none"!==t,this._blendMode=t,this._blendModeId=go[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 e=new t;return e.depthTest=!1,e.blend=!0,e}};fo.default2d=fo.for2d();let mo=fo;const yo=class t extends po{constructor(e){super(e={...t.defaultOptions,...e}),this.enabled=!0,this._state=mo.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,"boolean"==typeof e.antialias?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(e){const{gpu:i,gl:s,...n}=e;let r,o;return i&&(r=ro.from(i)),s&&(o=to.from(s)),new t({gpuProgram:r,glProgram:o,...n})}};yo.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let xo=yo;const bo=[];let vo;es.handleByNamedList(qi.Environment,bo);const _o=F.default||F;var wo=(t=>(t[t.NONE=0]="NONE",t[t.COLOR=16384]="COLOR",t[t.STENCIL=1024]="STENCIL",t[t.DEPTH=256]="DEPTH",t[t.COLOR_DEPTH=16640]="COLOR_DEPTH",t[t.COLOR_STENCIL=17408]="COLOR_STENCIL",t[t.DEPTH_STENCIL=1280]="DEPTH_STENCIL",t[t.ALL=17664]="ALL",t))(wo||{});class Ao{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,r,o,a){const{name:h,items:l}=this;for(let c=0,d=l.length;c<d;c++)l[c][h](t,e,i,s,n,r,o,a);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-1!==e&&this.items.splice(e,1),this}contains(t){return-1!==this.items.indexOf(t)}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}const Co=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],So=class t extends as{constructor(t){super(),this.uid=e("renderer"),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,this.config=t;const i=[...Co,...this.config.runners??[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(e={}){const i=!0===e.skipExtensionImports||!1===e.manageImports;await async function(t){if(!t)for(let t=0;t<bo.length;t++){const e=bo[t];if(e.value.test())return void await e.value.load()}}(i),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash)e={...this._systemsHash[t].constructor.defaultOptions,...e};e={...t.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)await this.runners.init.items[t].init(e);this._initOptions=e}render(t,e){let i=t;if(i instanceof Xn&&(i={container:i},e&&(Ps(0,"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??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const t=Array.isArray(i.clearColor)&&4===i.clearColor.length;i.clearColor=t?i.clearColor:yn.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),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){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),void 0!==i&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){t.target||(t.target=this.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=wo.ALL);const{clear:e,clearColor:i,target:s}=t;yn.shared.setValue(i??this.background.colorRgba),this.renderTarget.clear(s,e,yn.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(t=>{this.runners[t]=new Ao(t)})}_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 t in this.runners)this.runners[t].add(i);return this}_addPipes(t,e){const i=e.reduce((t,e)=>(t[e.name]=e.value,t),{});t.forEach(t=>{const e=t.value,s=t.name,n=i[s];this.renderPipes[s]=new e(this,n?new n:null),this.runners.destroy.add(this.renderPipes[s])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(t=>{t.destroy()}),(!0===t||"object"==typeof t&&t.releaseGlobalResources)&&bn.release(),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!D())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};So.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Io,Mo,To=So;const Po=["webgl","webgpu","canvas"],Eo="8.14.0";class Bo{static init(){globalThis.__PIXI_APP_INIT__?.(this,Eo)}static destroy(){}}Bo.extension=qi.Application;class Ro{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Eo)}destroy(){this._renderer=null}}Ro.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"initHook",priority:-10};const ko=class t{constructor(...t){this.stage=new Xn,void 0!==t[0]&&Ps(0,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.renderer=await async function(t){let e,i=[];t.preference?(i.push(t.preference),Po.forEach(e=>{e!==t.preference&&i.push(e)})):i=Po.slice();let s={};for(let n=0;n<i.length;n++){const r=i[n];if("webgpu"===r&&await lt()){const{WebGPURenderer:i}=await Promise.resolve().then(()=>zu);e=i,s={...t,...t.webgpu};break}if("webgl"===r&&ht(t.failIfMajorPerformanceCaveat??To.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:i}=await Promise.resolve().then(()=>nu);e=i,s={...t,...t.webgl};break}if("canvas"===r)throw s={...t},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}(e),t._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return Ps(0,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,i=!1){const s=t._plugins.slice(0);s.reverse(),s.forEach(t=>{t.destroy.call(this)}),this.stage.destroy(i),this.stage=null,this.renderer.destroy(e),this.renderer=null}};ko._plugins=[];let Oo=ko;es.handleByList(qi.Application,Oo._plugins),es.add(Bo);class Do{static init(t){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;let t,e;if(this._cancelResize(),this._resizeTo===globalThis.window)t=globalThis.innerWidth,e=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:s}=this._resizeTo;t=i,e=s}this.renderer.resize(t,e),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Do.extension=qi.Application;class Fo{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,rr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?lr.shared:new lr,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Fo.extension=qi.Application;class Lo extends as{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.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return Ps(0,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return Ps(0,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return Ps(0,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return Ps(0,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return Ps(0,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture?.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}class jo{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(t=>[t,this.get(t)])}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0===--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(void 0!==e)return this.ttl>0&&e.expiry<=Date.now()?void this.delete(t):(this.moveToEnd(e),e.value)}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,null!==this.last&&(this.last.next=t),this.last=t,null===this.first&&(this.first=t))}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let s=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(s={...this.first},this.evict(!0));let i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};1===++this.size?this.first=i:this.last.next=i,this.last=i}return s}set(t,e,i=!1,s=this.resetTtl){let n=this.items[t];return i||void 0!==n?(n.value=e,!1===i&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1===++this.size?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){return t.map(t=>this.get(t))}}const Go=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Uo={willReadFrequently:!0},zo=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const i=ir.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,s,n,r,o,a,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=r,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=h}static measureText(e=" ",i,s=t._canvas,n=i.wordWrap){const r=`${e}-${i.styleKey}-wordWrap-${n}`;if(t._measurementCache.has(r))return t._measurementCache.get(r);const o=dt(i),a=t.measureFont(o);0===a.fontSize&&(a.fontSize=i.fontSize,a.ascent=i.fontSize);const h=t.__context;h.font=o;const l=(n?t._wordWrap(e,i,s):e).split(/(?:\r\n|\r|\n)/),c=new Array(l.length);let d=0;for(let e=0;e<l.length;e++){const s=t._measureText(l[e],i.letterSpacing,h);c[e]=s,d=Math.max(d,s)}const u=i._stroke?.width||0;let p=d+u;i.dropShadow&&(p+=i.dropShadow.distance);const g=i.lineHeight||a.fontSize;let f=Math.max(g,a.fontSize+u)+(l.length-1)*(g+i.leading);i.dropShadow&&(f+=i.dropShadow.distance);const m=new t(e,i,p,f,l,c,g+i.leading,d,a);return t._measurementCache.set(r,m),m}static _measureText(e,i,s){let n=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(s.letterSpacing=`${i}px`,s.textLetterSpacing=`${i}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const r=s.measureText(e);let o=r.width;const a=-r.actualBoundingBoxLeft;let h=r.actualBoundingBoxRight-a;if(o>0)if(n)o-=i,h-=i;else{const s=(t.graphemeSegmenter(e).length-1)*i;o+=s,h+=s}return Math.max(o,h)}static _wordWrap(e,i,s=t._canvas){const n=s.getContext("2d",Uo);let r=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=i,d=t._collapseSpaces(c),u=t._collapseNewlines(c);let p=!d;const g=i.wordWrapWidth+l,f=t._tokenize(e);for(let e=0;e<f.length;e++){let s=f[e];if(t._isNewline(s)){if(!u){a+=t._addLine(o),p=!d,o="",r=0;continue}s=" "}if(d){const e=t.isBreakingSpace(s),i=t.isBreakingSpace(o[o.length-1]);if(e&&i)continue}const c=t._getFromCache(s,l,h,n);if(c>g)if(""!==o&&(a+=t._addLine(o),o="",r=0),t.canBreakWords(s,i.breakWords)){const e=t.wordWrapSplit(s);for(let c=0;c<e.length;c++){let d=e[c],u=d,f=1;for(;e[c+f];){const n=e[c+f];if(t.canBreakChars(u,n,s,c,i.breakWords))break;d+=n,u=n,f++}c+=f-1;const m=t._getFromCache(d,l,h,n);m+r>g&&(a+=t._addLine(o),p=!1,o="",r=0),o+=d,r+=m}}else{o.length>0&&(a+=t._addLine(o),o="",r=0);const i=e===f.length-1;a+=t._addLine(s,!i),p=!1,o="",r=0}else c+r>g&&(p=!1,a+=t._addLine(o),o="",r=0),(o.length>0||!t.isBreakingSpace(s)||p)&&(o+=s,r+=c)}return a+=t._addLine(o,!1),a}static _addLine(e,i=!0){return e=t._trimRight(e),i?`${e}\n`:e}static _getFromCache(e,i,s,n){let r=s[e];return"number"!=typeof r&&(r=t._measureText(e,i,n)+i,s[e]=r),r}static _collapseSpaces(t){return"normal"===t||"pre-line"===t}static _collapseNewlines(t){return"normal"===t}static _trimRight(e){if("string"!=typeof e)return"";for(let i=e.length-1;i>=0;i--){const s=e[i];if(!t.isBreakingSpace(s))break;e=e.slice(0,-1)}return e}static _isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,i){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const i=[];let s="";if("string"!=typeof e)return i;for(let n=0;n<e.length;n++){const r=e[n],o=e[n+1];t.isBreakingSpace(r,o)||t._isNewline(r)?(""!==s&&(i.push(s),s=""),"\r"===r&&"\n"===o?(i.push("\r\n"),n++):i.push(r)):s+=r}return""!==s&&i.push(s),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const i=t._context;i.font=e;const s=i.measureText(t.METRICS_STRING+t.BASELINE_SYMBOL),n={ascent:s.actualBoundingBoxAscent,descent:s.actualBoundingBoxDescent,fontSize:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent};return t._fonts[e]=n,n}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let e;try{const i=new OffscreenCanvas(0,0),s=i.getContext("2d",Uo);if(s?.measureText)return t.__canvas=i,i;e=ir.get().createCanvas()}catch(t){e=ir.get().createCanvas()}e.width=e.height=10,t.__canvas=e}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",Uo)),t.__context}};zo.METRICS_STRING="|ÉqÅ",zo.BASELINE_SYMBOL="M",zo.BASELINE_MULTIPLIER=1.4,zo.HEIGHT_MULTIPLIER=2,zo.graphemeSegmenter=(()=>t=>[...t])(),zo.experimentalLetterSpacing=!1,zo._fonts={},zo._newlines=[10,13],zo._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],zo._measurementCache=ct(1e3);let No=zo;const Vo=[{offset:0,color:"white"},{offset:1,color:"black"}],Ho=class t{constructor(...i){this.uid=e("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let s=function(t){let e=t[0]??{};return("number"==typeof e||t[1])&&(Ps(0,"use options object instead"),e={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:t[5]??Wo.defaultLinearOptions.textureSize}),e}(i);s={..."radial"===s.type?t.defaultRadialOptions:t.defaultLinearOptions,...n(s)},this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,"radial"===s.type?(this.center=s.center,this.outerCenter=s.outerCenter??this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:yn.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:s}=this.end,n=i-t,r=s-e;const o=n<0||r<0;if("clamp-to-edge"===this._wrapMode){if(n<0){const e=t;t=i,i=e,n*=-1}if(r<0){const t=e;e=s,s=t,r*=-1}}const a=this.colorStops.length?this.colorStops:Vo,h=this._textureSize,{canvas:l,context:c}=pt(h,1),d=o?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);ut(d,a),c.fillStyle=d,c.fillRect(0,0,h,1),this.texture=new Gs({source:new nr({resource:l,addressMode:this._wrapMode})});const u=Math.sqrt(n*n+r*r),p=Math.atan2(r,n),g=new ps;g.scale(u/h,1),g.rotate(p),g.translate(t,e),"local"===this.textureSpace&&g.scale(h,h),this.transform=g}buildGradient(){this.texture||this._tick++,"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Vo,e=this._textureSize,{canvas:i,context:s}=pt(e,e),{x:n,y:r}=this.center,{x:o,y:a}=this.outerCenter,h=this.innerRadius,l=this.outerRadius,c=o-l,d=a-l,u=e/(2*l),p=(n-c)*u,g=(r-d)*u,f=s.createRadialGradient(p,g,h*u,(o-c)*u,(a-d)*u,l*u);ut(f,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=f,s.translate(p,g),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-p,-g),s.fillRect(0,0,e,e),this.texture=new Gs({source:new nr({resource:i,addressMode:this._wrapMode})});const m=new ps;m.scale(1/u,1/u),m.translate(c,d),"local"===this.textureSpace&&m.scale(e,e),this.transform=m}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Ho.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Ho.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Wo=Ho;const Jo={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 Zo{constructor(t,i){this.uid=e("fillPattern"),this._tick=0,this.transform=new ps,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),i&&(t.source.style.addressModeU=Jo[i].addressModeU,t.source.style.addressModeV=Jo[i].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),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var Xo,Yo;const Ko=t(function(){if(Yo)return Xo;Yo=1,Xo=function(s){var n=[];return s.replace(e,function(e,s,r){var o=s.toLowerCase();for(r=function(t){var e=t.match(i);return e?e.map(Number):[]}(r),"m"==o&&r.length>2&&(n.push([s].concat(r.splice(0,2))),o="l",s="m"==s?"l":"L");;){if(r.length==t[o])return r.unshift(s),n.push(r);if(r.length<t[o])throw new Error("malformed path data");n.push([s].concat(r.splice(0,t[o])))}}),n};var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=/([astvzqmhlc])([^astvzqmhlc]*)/gi,i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;return Xo}());class Qo{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Qo(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i,s=.5){if(0===this.radius)return!1;const n=this.x-t,r=this.y-e,o=this.radius,a=(1-s)*i,h=Math.sqrt(n*n+r*r);return h<=o+a&&h>o-(i-a)}getBounds(t){return t||(t=new Ss),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=2*this.radius,t.height=2*this.radius,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 qo{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new qo(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,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i,s=.5){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const o=i*(1-s),a=i-o,h=n-a,l=r-a,c=n+o,d=r+o,u=t-this.x,p=e-this.y;return u*u/(h*h)+p*p/(l*l)>1&&u*u/(c*c)+p*p/(d*d)<=1}getBounds(t){return t||(t=new Ss),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=2*this.halfWidth,t.height=2*this.halfHeight,t}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}]`}}class $o{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let i=0,s=e.length;i<s;i++)t.push(e[i].x,e[i].y);e=t}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let s=0;s<i;s+=2){const n=e[s],r=e[s+1];t+=(e[(s+2)%i]-n)*(e[(s+3)%i]+r)}return t<0}containsPolygon(t){const e=this.getBounds(void 0),i=t.getBounds(void 0);if(!e.containsRect(i))return!1;const s=t.points;for(let t=0;t<s.length;t+=2){const e=s[t],i=s[t+1];if(!this.contains(e,i))return!1}return!0}clone(){const t=this.points.slice(),e=new $o(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,r=s-1;n<s;r=n++){const s=this.points[2*n],o=this.points[2*n+1],a=this.points[2*r],h=this.points[2*r+1];o>e!=h>e&&t<(e-o)/(h-o)*(a-s)+s&&(i=!i)}return i}strokeContains(t,e,i,s=.5){const n=i*i,r=n*(1-s),o=n-r,{points:a}=this,h=a.length-(this.closePath?0:2);for(let i=0;i<h;i+=2){const s=a[i],n=a[i+1],h=a[(i+2)%a.length],l=a[(i+3)%a.length];if(gt(t,e,s,n,h,l)<=(Math.sign((h-s)*(e-n)-(l-n)*(t-s))<0?o:r))return!0}return!1}getBounds(t){t||(t=new Ss);const e=this.points;let i=1/0,s=-1/0,n=1/0,r=-1/0;for(let t=0,o=e.length;t<o;t+=2){const o=e[t],a=e[t+1];i=o<i?o:i,s=o>s?o:s,n=a<n?a:n,r=a>r?a:r}return t.x=i,t.width=s-i,t.y=n,t.height=r-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 Ps(0,"Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return Ps(0,"Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const ta=(t,e,i,s,n,r,o)=>{const a=t-i,h=e-s,l=Math.sqrt(a*a+h*h);return l>=n-r&&l<=n+o};class ea{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return t||(t=new Ss),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ea(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 s=t-(this.x+i),n=e-(this.y+i);const r=i*i;if(s*s+n*n<=r)return!0;if(s=t-(this.x+this.width-i),s*s+n*n<=r)return!0;if(n=e-(this.y+this.height-i),s*s+n*n<=r)return!0;if(s=t-(this.x+i),s*s+n*n<=r)return!0}return!1}strokeContains(t,e,i,s=.5){const{x:n,y:r,width:o,height:a,radius:h}=this,l=i*(1-s),c=i-l,d=n+h,u=r+h,p=n+o,g=r+a;return(t>=n-l&&t<=n+c||t>=p-c&&t<=p+l)&&e>=u&&e<=u+(a-2*h)||(e>=r-l&&e<=r+c||e>=g-c&&e<=g+l)&&t>=d&&t<=d+(o-2*h)||t<d&&e<u&&ta(t,e,d,u,h,c,l)||t>p-h&&e<u&&ta(t,e,p-h,u,h,c,l)||t>p-h&&e>g-h&&ta(t,e,p-h,g-h,h,c,l)||t<d&&e>g-h&&ta(t,e,d,g-h,h,c,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const ia={};class sa{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),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`)}}}const na={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ra=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(ra||{});const oa=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");let aa=null;class ha{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 la{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new ha,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const ca=[];let da=0;bn.register({clear:()=>{if(ca.length>0)for(const t of ca)t&&t.destroy();ca.length=0,da=0}});let ua=0;const pa=class t{constructor(i){this.uid=e("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(i={...t.defaultOptions,...i}).maxTextures||(Ps(0,"maxTextures is a required option for Batcher now, please pass it in the options"),i.maxTextures=function(){if(aa)return aa;const t=E();return aa=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),aa=bt(aa,t),t.getExtension("WEBGL_lose_context")?.loseContext(),aa}());const{maxTextures:s,attributesInitialSize:n,indicesInitialSize:r}=i;this.attributeBuffer=new sa(4*n),this.indexBuffer=new Uint16Array(r),this.maxTextures=s}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)_t(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!(!i&&0!==i||(t._textureId=i,t.texture=e,0))}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=vt(),s=i.textures;s.clear();const n=e[this.elementStart];let r=yt(n.blendMode,n.texture._source),o=n.topology;4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,u="startBatch";const p=this.maxTextures;for(let n=this.elementStart;n<this.elementSize;++n){const g=e[n];e[n]=null;const f=g.texture._source,m=yt(g.blendMode,f),y=r!==m||o!==g.topology;f._batchTick!==ua||y?(f._batchTick=ua,(s.count>=p||y)&&(this._finishBatch(i,d,c-d,s,r,o,t,u),u="renderBatch",d=c,r=m,o=g.topology,i=vt(),s=i.textures,s.clear(),++ua),g._textureId=f._textureBindLocation=s.count,s.ids[f.uid]=s.count,s.textures[s.count++]=f,g._batch=i,c+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,h,g._attributeStart,g._textureId),this.packQuadIndex(l,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,h,g._attributeStart,g._textureId),this.packIndex(g,l,g._indexStart,g._attributeStart/this.vertexSize))):(g._textureId=f._textureBindLocation,c+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,h,g._attributeStart,g._textureId),this.packQuadIndex(l,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,h,g._attributeStart,g._textureId),this.packIndex(g,l,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=i)}s.count>0&&(this._finishBatch(i,d,c-d,s,r,o,t,u),d=c,++ua),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,i,s,n,r,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=s,t.blendMode=n,t.topology=r,t.start=e,t.size=i,++ua,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){4*t<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*t)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,2*this.attributeBuffer.size),i=new sa(e);mt(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,1.5*e.length);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let t=0;t<e.length;t++)s[t]=e[t];else mt(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(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}packIndex(t,e,i,s){const n=t.indices,r=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let t=0;t<r;t++)e[i++]=s+n[t+o]-a}destroy(){if(null!==this.batches){for(let t=0;t<this.batches.length;t++)_t(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]&&(this._elements[t]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};pa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let ga=pa;var fa=(t=>(t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE",t[t.STATIC=1024]="STATIC",t))(fa||{});let ma=class extends as{constructor(t){let{data:i,size:s}=t;const{usage:n,label:r,shrinkToFit:o}=t;super(),this.uid=e("buffer"),this._resourceType="buffer",this._resourceId=e("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,i instanceof Array&&(i=new Float32Array(i)),this._data=i,s??(s=i?.byteLength);const a=!!i;this.descriptor={size:s,usage:n,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&fa.STATIC)}set static(t){t?this.descriptor.usage|=fa.STATIC:this.descriptor.usage&=~fa.STATIC}setDataWithSize(t,i,s){if(this._updateID++,this._updateSize=i*t.BYTES_PER_ELEMENT,this._data===t)return void(s&&this.emit("update",this));const n=this._data;this._data=t,this._dataInt32=null,n&&n.length===t.length||!this.shrinkToFit&&n&&t.byteLength<n.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=e("resource"),this.emit("change",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()}};class ya extends as{constructor(t={}){super(),this.uid=e("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new zs,this._boundsDirty=!0;const{attributes:i,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},i)for(const t in i)this.addAttribute(t,i[t]);this.instanceCount=t.instanceCount??1,s&&this.addIndex(s),this.topology=n||"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}addAttribute(t,e){const i=function(t){return(t instanceof ma||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=wt(t.buffer,!1),t}(e);-1===this.buffers.indexOf(i.buffer)&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=wt(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,i){const s=t.getAttribute("aPosition");if(!s)return i.minX=0,i.minY=0,i.maxX=0,i.maxY=0,i;const n=s.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=n.BYTES_PER_ELEMENT,c=(s.offset||0)/l,d=(s.stride||8)/l;for(let t=c;t<n.length;t+=d){const e=n[t],i=n[t+1];e>a&&(a=e),i>h&&(h=i),e<r&&(r=e),i<o&&(o=i)}return i.minX=r,i.minY=o,i.maxX=a,i.maxY=h,i}(this,0,this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(t=>t.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const xa=new Float32Array(1),ba=new Uint32Array(1);class va extends ya{constructor(){const t=new ma({data:xa,label:"attribute-batch-buffer",usage:fa.VERTEX|fa.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:new ma({data:ba,label:"index-batch-buffer",usage:fa.INDEX|fa.COPY_DST,shrinkToFit:!1})})}}const _a=/\{\{(.*?)\}\}/g,wa=Object.create(null),Aa=new Map;let Ca=0;const Sa={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},Ia={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}},Ma={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},Ta={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},Pa={},Ea={},Ba={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},Ra={name:"round-pixels-bit",vertex:{header:"\n vec2 roundPixels(vec2 position, vec2 targetSize)\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},ka={};class Oa extends po{constructor(t){super({glProgram:kt({name:"batch",bits:[Ta,jt(t),Ra]}),gpuProgram:Rt({name:"batch",bits:[Ma,Ft(t),Ba]}),resources:{batchSamplers:Gt(t)}})}}let Da=null;const Fa=class t extends ga{constructor(e){super(e),this.geometry=new va,this.name=t.extension.name,this.vertexSize=6,Da??(Da=new Oa(e.maxTextures)),this.shader=Da}packAttributes(t,e,i,s,n){const r=n<<16|65535&t.roundPixels,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,{positions:p,uvs:g}=t,f=t.color,m=t.attributeOffset,y=m+t.attributeSize;for(let t=m;t<y;t++){const n=2*t,o=p[n],m=p[n+1];e[s++]=a*o+l*m+d,e[s++]=c*m+h*o+u,e[s++]=g[n],e[s++]=g[n+1],i[s++]=f,i[s++]=r}}packQuadAttributes(t,e,i,s,n){const r=t.texture,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,p=t.bounds,g=p.maxX,f=p.minX,m=p.maxY,y=p.minY,x=r.uvs,b=t.color,v=n<<16|65535&t.roundPixels;e[s+0]=a*f+l*y+d,e[s+1]=c*y+h*f+u,e[s+2]=x.x0,e[s+3]=x.y0,i[s+4]=b,i[s+5]=v,e[s+6]=a*g+l*y+d,e[s+7]=c*y+h*g+u,e[s+8]=x.x1,e[s+9]=x.y1,i[s+10]=b,i[s+11]=v,e[s+12]=a*g+l*m+d,e[s+13]=c*m+h*g+u,e[s+14]=x.x2,e[s+15]=x.y2,i[s+16]=b,i[s+17]=v,e[s+18]=a*f+l*m+d,e[s+19]=c*m+h*f+u,e[s+20]=x.x3,e[s+21]=x.y3,i[s+22]=b,i[s+23]=v}};Fa.extension={type:[qi.Batcher],name:"default"};let La=Fa;const ja=new ps;class Ga{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|65280&t|(255&t)<<16,i=this.renderable;return i?d(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||ja}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const Ua={extension:{type:qi.ShapeBuilder,name:"circle"},build(t,e){let i,s,n,r,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;i=e.x,s=e.y,n=r=0}else if("ellipse"===t.type){const e=t;if(o=e.halfWidth,a=e.halfHeight,o<=0||a<=0)return!1;i=e.x,s=e.y,n=r=0}else{const e=t,h=e.width/2,l=e.height/2;i=e.x+h,s=e.y+l,o=a=Math.max(0,Math.min(e.radius,Math.min(h,l))),n=h-o,r=l-a}if(n<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=8*h+(n?4:0)+(r?4:0);if(0===l)return!1;if(0===h)return e[0]=e[6]=i+n,e[1]=e[3]=s+r,e[2]=e[4]=i-n,e[5]=e[7]=s-r,!0;let c=0,d=4*h+(n?2:0)+2,u=d,p=l,g=n+o,f=r,m=i+g,y=i-g,x=s+f;if(e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,r){const t=s-f;e[u++]=y,e[u++]=t,e[--p]=t,e[--p]=m}for(let t=1;t<h;t++){const l=Math.PI/2*(t/h),g=n+Math.cos(l)*o,f=r+Math.sin(l)*a,m=i+g,y=i-g,x=s+f,b=s-f;e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,e[u++]=y,e[u++]=b,e[--p]=b,e[--p]=m}g=n,f=r+a,m=i+g,y=i-g,x=s+f;const b=s-f;return e[c++]=m,e[c++]=x,e[--p]=b,e[--p]=m,n&&(e[c++]=y,e[c++]=x,e[--p]=b,e[--p]=y),!0},triangulate(t,e,i,s,n,r){if(0===t.length)return;let o=0,a=0;for(let e=0;e<t.length;e+=2)o+=t[e],a+=t[e+1];o/=t.length/2,a/=t.length/2;let h=s;e[h*i]=o,e[h*i+1]=a;const l=h++;for(let s=0;s<t.length;s+=2)e[h*i]=t[s],e[h*i+1]=t[s+1],s>0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},za={...Ua,extension:{...Ua.extension,name:"ellipse"}},Na={...Ua,extension:{...Ua.extension,name:"roundedRectangle"}},Va=1e-4,Ha=[],Wa={extension:{type:qi.ShapeBuilder,name:"polygon"},build(t,e){for(let i=0;i<t.points.length;i++)e[i]=t.points[i];return!0},triangulate(t,e,i,s,n,r){Vt(t,Ha,e,i,s,n,r)}},Ja={extension:{type:qi.ShapeBuilder,name:"rectangle"},build(t,e){const i=t,s=i.x,n=i.y,r=i.width,o=i.height;return r>0&&o>0&&(e[0]=s,e[1]=n,e[2]=s+r,e[3]=n,e[4]=s+r,e[5]=n+o,e[6]=s,e[7]=n+o,!0)},triangulate(t,e,i,s,n,r){let o=0;e[(s*=i)+o]=t[0],e[s+o+1]=t[1],o+=i,e[s+o]=t[2],e[s+o+1]=t[3],o+=i,e[s+o]=t[6],e[s+o+1]=t[7],o+=i,e[s+o]=t[4],e[s+o+1]=t[5],o+=i;const a=s/i;n[r++]=a,n[r++]=a+1,n[r++]=a+2,n[r++]=a+1,n[r++]=a+3,n[r++]=a+2}},Za={extension:{type:qi.ShapeBuilder,name:"triangle"},build:(t,e)=>(e[0]=t.x,e[1]=t.y,e[2]=t.x2,e[3]=t.y2,e[4]=t.x3,e[5]=t.y3,!0),triangulate(t,e,i,s,n,r){let o=0;e[(s*=i)+o]=t[0],e[s+o+1]=t[1],o+=i,e[s+o]=t[2],e[s+o+1]=t[3],o+=i,e[s+o]=t[4],e[s+o+1]=t[5];const a=s/i;n[r++]=a,n[r++]=a+1,n[r++]=a+2}},Xa=new ps,Ya=new Ss,Ka={};es.handleByMap(qi.ShapeBuilder,Ka),es.add(Ja,Wa,Za,Ua,za,Na);const Qa=new Ss,qa=new ps;class $a{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class th{constructor(){this.instructions=new Un}init(t){this.batcher=new La({maxTextures:t}),this.instructions.reset()}get geometry(){return Ps(0,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const eh=class t{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(e){t.defaultOptions.bezierSmoothness=e?.bezierSmoothness??t.defaultOptions.bezierSmoothness}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),function(t,e){const{geometryData:i,batches:s}=e;s.length=0,i.indices.length=0,i.vertices.length=0,i.uvs.length=0;for(let e=0;e<t.instructions.length;e++){const n=t.instructions[e];if("texture"===n.action)Ht(n.data,s,i);else if("fill"===n.action||"stroke"===n.action){const t="stroke"===n.action,e=n.data.path.shapePath,r=n.data.style,o=n.data.hole;t&&o&&Wt(o.shapePath,r,!0,s,i),o&&(e.shapePrimitives[e.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),Wt(e,r,t,s,i)}}}(t,e);const i=t.batchMode;t.customShader||"no-batch"===i?e.isBatchable=!1:e.isBatchable="auto"!==i||e.geometryData.vertices.length<400,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=_n.get(th,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:s}=this._gpuContextHash[t.uid],n=s.vertices.length,r=s.indices.length;for(let t=0;t<i.length;t++)i[t].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(n),o.ensureIndexBuffer(r),o.begin();for(let t=0;t<i.length;t++){const e=i[t];o.add(e)}o.finish(e.instructions);const a=o.geometry;a.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),a.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const h=o.batches;for(let t=0;t<h.length;t++){const e=h[t];e.bindGroup=ft(e.textures.textures,e.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new $a;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]&&(_n.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{_n.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};eh.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"graphicsContext"},eh.defaultOptions={bezierSmoothness:.5};let ih=eh;const sh=1.1920929e-7,nh=2*Math.PI,rh={centerX:0,centerY:0,ang1:0,ang2:0},oh=({x:t,y:e},i,s,n,r,o,a,h)=>{const l=n*(t*=i)-r*(e*=s),c=r*t+n*e;return h.x=l+o,h.y=c+a,h},ah=(t,e,i,s)=>{let n=t*i+e*s;return n>1&&(n=1),n<-1&&(n=-1),(t*s-e*i<0?-1:1)*Math.acos(n)},hh=new Ss;class lh{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new zs,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return s===t&&n===e||i.push(t,e),this}arc(t,e,i,s,n,r){return this._ensurePoly(!1),Kt(this._currentPoly.points,t,e,i,s,n,r),this}arcTo(t,e,i,s,n){return this._ensurePoly(),function(t,e,i,s,n,r){const o=t[t.length-2],a=t[t.length-1]-i,h=o-e,l=n-i,c=s-e,d=Math.abs(a*c-h*l);if(d<1e-8||0===r)return void(t[t.length-2]===e&&t[t.length-1]===i||t.push(e,i));const u=a*a+h*h,p=l*l+c*c,g=a*l+h*c,f=r*Math.sqrt(u)/d,m=r*Math.sqrt(p)/d,y=f*g/u,x=m*g/p,b=f*c+m*h,v=f*l+m*a,_=h*(m+y),w=a*(m+y),A=c*(f+x),C=l*(f+x);Kt(t,b+e,v+i,r,Math.atan2(w-v,_-b),Math.atan2(C-v,A-b),h*l>c*a)}(this._currentPoly.points,t,e,i,s,n),this}arcToSvg(t,e,i,s,n,r,o){return function(t,e,i,s,n,r,o,a=0,h=0,l=0){if(0===r||0===o)return;const c=Math.sin(a*nh/360),d=Math.cos(a*nh/360),u=d*(e-s)/2+c*(i-n)/2,p=-c*(e-s)/2+d*(i-n)/2;if(0===u&&0===p)return;r=Math.abs(r),o=Math.abs(o);const g=Math.pow(u,2)/Math.pow(r,2)+Math.pow(p,2)/Math.pow(o,2);g>1&&(r*=Math.sqrt(g),o*=Math.sqrt(g)),((t,e,i,s,n,r,o,a,h,l,c,d,u)=>{const p=Math.pow(n,2),g=Math.pow(r,2),f=Math.pow(c,2),m=Math.pow(d,2);let y=p*g-p*m-g*f;y<0&&(y=0),y/=p*m+g*f,y=Math.sqrt(y)*(o===a?-1:1);const x=y*n/r*d,b=y*-r/n*c,v=l*x-h*b+(t+i)/2,_=h*x+l*b+(e+s)/2,w=(c-x)/n,A=(d-b)/r,C=(-c-x)/n,S=(-d-b)/r,I=ah(1,0,w,A);let M=ah(w,A,C,S);0===a&&M>0&&(M-=nh),1===a&&M<0&&(M+=nh),u.centerX=v,u.centerY=_,u.ang1=I,u.ang2=M})(e,i,s,n,r,o,h,l,c,d,u,p,rh);let{ang1:f,ang2:m}=rh;const{centerX:y,centerY:x}=rh;let b=Math.abs(m)/(nh/4);Math.abs(1-b)<1e-7&&(b=1);const v=Math.max(Math.ceil(b),1);m/=v;let _=t[t.length-2],w=t[t.length-1];const A={x:0,y:0};for(let e=0;e<v;e++){const e=Qt(f,m),{x:i,y:s}=oh(e[0],r,o,d,c,y,x,A),{x:n,y:a}=oh(e[1],r,o,d,c,y,x,A),{x:h,y:l}=oh(e[2],r,o,d,c,y,x,A);Jt(t,_,w,i,s,n,a,h,l),_=h,w=l,f+=m}}(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,r,o,t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,r,o){this._ensurePoly();const a=this._currentPoly;return Jt(this._currentPoly.points,a.lastX,a.lastY,t,e,i,s,n,r,o),this}quadraticCurveTo(t,e,i,s,n){this._ensurePoly();const r=this._currentPoly;return Xt(this._currentPoly.points,r.lastX,r.lastY,t,e,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0)).transform(e);const i=this.shapePrimitives,s=i.length;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}if(t.checkForHoles&&i.length-s>1){let t=null;for(let e=s;e<i.length;e++){const s=i[e];if("polygon"===s.shape.type){const n=s.shape,r=t?.shape;r&&r.containsPolygon(n)?(t.holes||(t.holes=[]),t.holes.push(s),i.copyWithin(e,e+1),i.length--,e--):t=s}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,s,n){return this.drawShape(new Ss(t,e,i,s),n),this}circle(t,e,i,s){return this.drawShape(new Qo(t,e,i),s),this}poly(t,e,i){const s=new $o(t);return s.closePath=e,this.drawShape(s,i),this}regularPoly(t,e,i,s,n=0,r){s=Math.max(0|s,3);const o=-1*Math.PI/2+n,a=2*Math.PI/s,h=[];for(let n=0;n<s;n++){const s=o-n*a;h.push(t+i*Math.cos(s),e+i*Math.sin(s))}return this.poly(h,!0,r),this}roundPoly(t,e,i,s,n,r=0,o){if(s=Math.max(0|s,3),n<=0)return this.regularPoly(t,e,i,s,r);const a=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,a);const h=-1*Math.PI/2+r,l=2*Math.PI/s,c=(s-2)*Math.PI/s/2;for(let r=0;r<s;r++){const s=r*l+h,a=t+i*Math.cos(s),d=e+i*Math.sin(s),u=s+Math.PI+c,p=s-Math.PI-c,g=a+n*Math.cos(u),f=d+n*Math.sin(u),m=a+n*Math.cos(p),y=d+n*Math.sin(p);0===r?this.moveTo(g,f):this.lineTo(g,f),this.quadraticCurveTo(a,d,m,y,o)}return this.closePath()}roundShape(t,e,i=!1,s){return t.length<3?this:(i?function(t,e,i,s){const n=(t,e)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),r=(t,e,i)=>({x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}),o=e.length;for(let a=0;a<o;a++){const h=e[(a+1)%o],l=h.radius??i;if(l<=0){0===a?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y);continue}const c=e[a],d=e[(a+2)%o],u=n(c,h);let p;p=u<1e-4?h:r(h,c,Math.min(u/2,l)/u);const g=n(d,h);let f;f=g<1e-4?h:r(h,d,Math.min(g/2,l)/g),0===a?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y),t.quadraticCurveTo(h.x,h.y,f.x,f.y,s)}}(this,t,e,s):function(t,e,i){const s=(t,e)=>{const i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s);return{len:n,nx:i/n,ny:s/n}},n=(e,i)=>{0===e?t.moveTo(i.x,i.y):t.lineTo(i.x,i.y)};let r=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],h=a.radius??i;if(h<=0){n(o,a),r=a;continue}const l=e[(o+1)%e.length],c=s(a,r),d=s(a,l);if(c.len<1e-4||d.len<1e-4){n(o,a),r=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),p=1,g=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,p=-1,g=!0):u>0&&(p=-1,g=!0);const f=u/2;let m,y=Math.abs(Math.cos(f)*h/Math.sin(f));y>Math.min(c.len/2,d.len/2)?(y=Math.min(c.len/2,d.len/2),m=Math.abs(y*Math.sin(f)/Math.cos(f))):m=h;const x=a.x+d.nx*y+-d.ny*m*p,b=a.y+d.ny*y+d.nx*m*p,v=Math.atan2(c.ny,c.nx)+Math.PI/2*p,_=Math.atan2(d.ny,d.nx)-Math.PI/2*p;0===o&&t.moveTo(x+Math.cos(v)*m,b+Math.sin(v)*m),t.arc(x,b,m,v,_,g),r=a}}(this,t,e),this.closePath())}filletRect(t,e,i,s,n){if(0===n)return this.rect(t,e,i,s);const r=Math.min(i,s)/2,o=Math.min(r,Math.max(-r,n)),a=t+i,h=e+s,l=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+l,e+l,t+c,e,c).lineTo(a-c,e).arcTo(a-l,e+l,a,e+c,c).lineTo(a,h-c).arcTo(a-l,h-l,t+i-c,h,c).lineTo(t+c,h).arcTo(t+l,h-l,t,h-c,c).closePath()}chamferRect(t,e,i,s,n,r){if(n<=0)return this.rect(t,e,i,s);const o=Math.min(n,Math.min(i,s)/2),a=t+i,h=e+s,l=[t+o,e,a-o,e,a,e+o,a,h-o,a-o,h,t+o,h,t,h-o,t,e+o];for(let t=l.length-1;t>=2;t-=2)l[t]===l[t-2]&&l[t-1]===l[t-3]&&l.splice(t-1,2);return this.poly(l,!0,r)}ellipse(t,e,i,s,n){return this.drawShape(new qo(t,e,i,s),n),this}roundRect(t,e,i,s,n,r){return this.drawShape(new ea(t,e,i,s,n),r),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 $o,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 $o,t)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let e=t.shape.x,i=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const s=t.transform,n=e;e=s.a*e+s.c*i+s.tx,i=s.b*n+s.d*i+s.ty}this._currentPoly.points.push(e,i)}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 s=e[i],n=s.shape.getBounds(hh);s.transform?t.addRect(n,s.transform):t.addRect(n)}return t}}class ch{constructor(t,i=!1){this.instructions=[],this.uid=e("graphicsPath"),this._dirty=!0,this.checkForHoles=i,"string"==typeof t?function(t,e){const i=Ko(t),s=[];let n=null,r=0,a=0;for(let t=0;t<i.length;t++){const h=i[t],l=h[0],c=h;switch(l){case"M":r=c[1],a=c[2],e.moveTo(r,a);break;case"m":r+=c[1],a+=c[2],e.moveTo(r,a);break;case"H":r=c[1],e.lineTo(r,a);break;case"h":r+=c[1],e.lineTo(r,a);break;case"V":a=c[1],e.lineTo(r,a);break;case"v":a+=c[1],e.lineTo(r,a);break;case"L":r=c[1],a=c[2],e.lineTo(r,a);break;case"l":r+=c[1],a+=c[2],e.lineTo(r,a);break;case"C":r=c[5],a=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],r,a);break;case"c":e.bezierCurveTo(r+c[1],a+c[2],r+c[3],a+c[4],r+c[5],a+c[6]),r+=c[5],a+=c[6];break;case"S":r=c[3],a=c[4],e.bezierCurveToShort(c[1],c[2],r,a);break;case"s":e.bezierCurveToShort(r+c[1],a+c[2],r+c[3],a+c[4]),r+=c[3],a+=c[4];break;case"Q":r=c[3],a=c[4],e.quadraticCurveTo(c[1],c[2],r,a);break;case"q":e.quadraticCurveTo(r+c[1],a+c[2],r+c[3],a+c[4]),r+=c[3],a+=c[4];break;case"T":r=c[1],a=c[2],e.quadraticCurveToShort(r,a);break;case"t":r+=c[1],a+=c[2],e.quadraticCurveToShort(r,a);break;case"A":r=c[6],a=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,a);break;case"a":r+=c[6],a+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,a);break;case"Z":case"z":e.closePath(),s.length>0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:o()}"Z"!==l&&"z"!==l&&null===n&&(n={startX:r,startY:a},s.push(n))}}(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new lh(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,s,n){const r=this.instructions[this.instructions.length-1],o=this.getLastPoint(ds.shared);let a=0,h=0;if(r&&"bezierCurveTo"===r.action){a=r.data[2],h=r.data[3];const t=o.x,e=o.y;a=t+(t-a),h=e+(e-h)}else a=o.x,h=o.y;return this.instructions.push({action:"bezierCurveTo",data:[a,h,t,e,i,s,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 s=this.instructions[this.instructions.length-1],n=this.getLastPoint(ds.shared);let r=0,o=0;if(s&&"quadraticCurveTo"===s.action){r=s.data[0],o=s.data[1];const t=n.x,e=n.y;r=t+(t-r),o=e+(e-o)}else r=n.x,o=n.y;return this.instructions.push({action:"quadraticCurveTo",data:[r,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,s,n){return this.instructions.push({action:"rect",data:[t,e,i,s,n]}),this._dirty=!0,this}circle(t,e,i,s){return this.instructions.push({action:"circle",data:[t,e,i,s]}),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,s,n,r,o){n||(n=s/2);const a=-1*Math.PI/2+r,h=2*i,l=2*Math.PI/h,c=[];for(let i=0;i<h;i++){const r=i%2?n:s,o=i*l+a;c.push(t+r*Math.cos(o),e+r*Math.sin(o))}return this.poly(c,!0,o),this}clone(t=!1){const e=new ch;if(e.checkForHoles=this.checkForHoles,t)for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t];e.instructions.push({action:i.action,data:i.data.slice()})}else e.instructions=this.instructions.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,s=t.c,n=t.d,r=t.tx,a=t.ty;let h=0,l=0,c=0,d=0,u=0,p=0,g=0,f=0;for(let m=0;m<this.instructions.length;m++){const y=this.instructions[m],x=y.data;switch(y.action){case"moveTo":case"lineTo":h=x[0],l=x[1],x[0]=e*h+s*l+r,x[1]=i*h+n*l+a;break;case"bezierCurveTo":c=x[0],d=x[1],u=x[2],p=x[3],h=x[4],l=x[5],x[0]=e*c+s*d+r,x[1]=i*c+n*d+a,x[2]=e*u+s*p+r,x[3]=i*u+n*p+a,x[4]=e*h+s*l+r,x[5]=i*h+n*l+a;break;case"quadraticCurveTo":c=x[0],d=x[1],h=x[2],l=x[3],x[0]=e*c+s*d+r,x[1]=i*c+n*d+a,x[2]=e*h+s*l+r,x[3]=i*h+n*l+a;break;case"arcToSvg":h=x[5],l=x[6],g=x[0],f=x[1],x[0]=e*g+s*f,x[1]=i*g+n*f,x[5]=e*h+s*l+r,x[6]=i*h+n*l+a;break;case"circle":x[4]=qt(x[3],t);break;case"rect":x[4]=qt(x[4],t);break;case"ellipse":x[8]=qt(x[8],t);break;case"roundRect":x[5]=qt(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=qt(x[2],t);break;default:o(y.action)}}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(;"closePath"===i.action;){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)}return t}}const dh={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}},uh=new ds,ph=new ps,gh=class t extends as{constructor(){super(...arguments),this.uid=e("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ch,this._transform=new ps,this._fillStyle={...t.defaultFillStyle},this._strokeStyle={...t.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new zs,this._boundsDirty=!0}clone(){const e=new t;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=ue(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=pe(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=ue(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=ue(e,t.defaultStrokeStyle),this}texture(t,e,i,s,n,r){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:s||0,dw:n||t.frame.width,dh:r||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?yn.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ch,this}fill(e,i){let s;const n=this.instructions[this.instructions.length-1];return s=0===this._tick&&n&&"stroke"===n.action?n.data.path:this._activePath.clone(),s?(null!=e&&(void 0!==i&&"number"==typeof e&&(Ps(0,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:i}),this._fillStyle=ue(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(ds.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(e){let i;const s=this.instructions[this.instructions.length-1];return i=0===this._tick&&s&&"fill"===s.action?s.data.path:this._activePath.clone(),i?(null!=e&&(this._strokeStyle=pe(e,t.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:i}}),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&&("stroke"===e.action||"fill"===e.action)){if(!e.data.hole){e.data.hole=i;break}e.data.hole.addPath(i)}}return this._initNextPathLocation(),this}arc(t,e,i,s,n,r){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,s,n,r),this}arcTo(t,e,i,s,n){this._tick++;const r=this._transform;return this._activePath.arcTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*s+r.tx,r.b*i+r.d*s+r.ty,n),this}arcToSvg(t,e,i,s,n,r,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,i,s,n,a.a*r+a.c*o+a.tx,a.b*r+a.d*o+a.ty),this}bezierCurveTo(t,e,i,s,n,r,o){this._tick++;const a=this._transform;return this._activePath.bezierCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*s+a.tx,a.b*i+a.d*s+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,o),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,i,s){return this._tick++,this._activePath.ellipse(t,e,i,s,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,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,r=i.b*t+i.d*e+i.ty;return 1===s.length&&"moveTo"===s[0].action?(s[0].data[0]=n,s[0].data[1]=r,this):(this._activePath.moveTo(n,r),this)}quadraticCurveTo(t,e,i,s,n){this._tick++;const r=this._transform;return this._activePath.quadraticCurveTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*s+r.tx,r.b*i+r.d*s+r.ty,n),this}rect(t,e,i,s){return this._tick++,this._activePath.rect(t,e,i,s,this._transform.clone()),this}roundRect(t,e,i,s,n){return this._tick++,this._activePath.roundRect(t,e,i,s,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,s,n=0,r){return this._tick++,this._activePath.regularPoly(t,e,i,s,n,r),this}roundPoly(t,e,i,s,n,r){return this._tick++,this._activePath.roundPoly(t,e,i,s,n,r),this}roundShape(t,e,i,s){return this._tick++,this._activePath.roundShape(t,e,i,s),this}filletRect(t,e,i,s,n){return this._tick++,this._activePath.filletRect(t,e,i,s,n),this}chamferRect(t,e,i,s,n,r){return this._tick++,this._activePath.chamferRect(t,e,i,s,n,r),this}star(t,e,i,s,n=0,r=0){return this._tick++,this._activePath.star(t,e,i,s,n,r,this._transform.clone()),this}svg(t){return this._tick++,function(t,e){if("string"==typeof t){const e=document.createElement("div");e.innerHTML=t.trim(),t=e.querySelector("svg")}const i={context:e,defs:{},path:new ch};!function(t,e){const i=t.querySelectorAll("defs");for(let t=0;t<i.length;t++){const s=i[t];for(let t=0;t<s.children.length;t++){const i=s.children[t];switch(i.nodeName.toLowerCase()){case"lineargradient":e.defs[i.id]=te(i);break;case"radialgradient":e.defs[i.id]=ee()}}}}(t,i);const s=t.children,{fillStyle:n,strokeStyle:r}=se(t,i);for(let t=0;t<s.length;t++){const e=s[t];"defs"!==e.nodeName.toLowerCase()&&ae(e,i,n,r)}}(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,s,n,r){return t instanceof ps?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,s,n,r),this)}transform(t,e,i,s,n,r){return t instanceof ps?(this._transform.append(t),this):(ph.set(t,e,i,s,n,r),this._transform.append(ph),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._boundsDirty=!0,this.dirty||(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],s=i.action;if("fill"===s){const e=i.data;t.addBounds(e.path.bounds)}else if("texture"===s){const e=i.data;t.addFrame(e.dx,e.dy,e.dx+e.dw,e.dy+e.dh,e.transform)}if("stroke"===s){const e=i.data,s=e.style.alignment,n=e.style.width*(1-s),r=e.path.bounds;t.addFrame(r.minX-n,r.minY-n,r.maxX+n,r.maxY+n)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let s=0;s<e.length;s++){const n=e[s],r=n.data,o=r.path;if(!n.action||!o)continue;const a=r.style,h=o.shapePath.shapePrimitives;for(let e=0;e<h.length;e++){const s=h[e].shape;if(!a||!s)continue;const o=h[e].transform,l=o?o.applyInverse(t,uh):t;if("fill"===n.action)i=s.contains(l.x,l.y);else{const t=a;i=s.strokeContains(l.x,l.y,t.width,t.alignment)}const c=r.hole;if(c){const t=c.shapePath?.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(l.x,l.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(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};gh.defaultFillStyle={color:16777215,alpha:1,texture:Gs.WHITE,matrix:null,fill:null,textureSpace:"local"},gh.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Gs.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let fh=gh;const mh=class t extends as{constructor(i={}){super(),this.uid=e("textStyle"),this._tick=0,function(t){const e=t;if("boolean"==typeof e.dropShadow&&e.dropShadow){const i=yh.defaultDropShadow;t.dropShadow={alpha:e.dropShadowAlpha??i.alpha,angle:e.dropShadowAngle??i.angle,blur:e.dropShadowBlur??i.blur,color:e.dropShadowColor??i.color,distance:e.dropShadowDistance??i.distance}}if(void 0!==e.strokeThickness){Ps(0,"strokeThickness is now a part of stroke");const i=e.stroke;let s={};if(yn.isColorLike(i))s.color=i;else if(i instanceof Wo||i instanceof Zo)s.fill=i;else{if(!Object.hasOwnProperty.call(i,"color")&&!Object.hasOwnProperty.call(i,"fill"))throw new Error("Invalid stroke value.");s=i}t.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(Ps(0,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||0===e.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&o();const i=new Wo({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),n=e.fill.map(t=>yn.shared.setValue(t).toNumber());s.forEach((t,e)=>{i.addColorStop(t,n[e])}),t.fill={fill:i}}}(i);const s={...t.defaultTextStyle,...i};for(const t in s)this[t]=s[t];this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=null!==e&&"object"==typeof e?this._createProxy({...t.defaultDropShadow,...e}):e?this._createProxy({...t.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize="string"==typeof t?parseInt(t,10):t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...fh.defaultFillStyle,...t},()=>{this._fill=ue({...this._originalFill},fh.defaultFillStyle)})),this._fill=ue(0===t?"black":t,fh.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...fh.defaultStrokeStyle,...t},()=>{this._stroke=pe({...this._originalStroke},fh.defaultStrokeStyle)})),this._stroke=pe(t,fh.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const e=t.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new t({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,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,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){if(this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(e),this._originalFill?.texture&&this._originalFill.texture.destroy(e),this._stroke?.texture&&this._stroke.texture.destroy(e),this._originalStroke?.texture&&this._originalStroke.texture.destroy(e)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(t,i,s)=>(t[i]===s||(t[i]=s,e?.(i,s),this.update()),!0)})}_isFillStyle(t){return null!==(t??null)&&!(yn.isColorLike(t)||t instanceof Wo||t instanceof Zo)}};mh.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},mh.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 yh=mh;const xh=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=ir.get().createCanvas();i.width=t,i.height=e;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6);const n=((t=i(t))<<17)+((e=i(e))<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:s}=e,n=(i<<17)+(s<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,s),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}};bn.register(xh);const bh=1e5,vh=class t extends Lo{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const i={...t.defaultOptions,...e};this._textureSize=i.textureSize,this._mipmap=i.mipmap;const s=i.style.clone();i.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=Gs.WHITE,s._fill.fill=null),this.applyFillAsTint=i.overrideFill;const n=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const r=dt(s);i.overrideSize?s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/n):s.fontSize=this.baseRenderedFontSize=n,this._style=s,this._skipKerning=i.skipKerning??!1,this.resolution=i.resolution??1,this._padding=i.padding??4,i.textureStyle&&(this._textureStyle=i.textureStyle instanceof ks?i.textureStyle:new ks(i.textureStyle)),this.fontMetrics=No.measureFont(r),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){const e=No.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,i)=>i.indexOf(t)===e);if(!e.length)return;let i;this._currentChars=[...this._currentChars,...e],i=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:s,context:n}=i.canvasAndContext,r=i.texture.source;const o=this._style;let a=this._currentX,h=this._currentY,l=this._currentMaxCharHeight;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c;let u=!1;const p=s.width/this.resolution,g=s.height/this.resolution;for(let t=0;t<e.length;t++){const i=e[t],f=No.measureText(i,o,s,!1);f.lineHeight=f.height;const m=f.width*c,y=Math.ceil(("italic"===o.fontStyle?2:1)*m)+2*d,x=f.height*c+2*d;if(u=!1,"\n"!==i&&"\r"!==i&&"\t"!==i&&" "!==i&&(u=!0,l=Math.ceil(Math.max(x,l))),a+y>p&&(h+=l,l=x,a=0,h+l>g)){r.update();const t=this._nextPage();s=t.canvasAndContext.canvas,n=t.canvasAndContext.context,r=t.texture.source,a=0,h=0,l=0}const b=m/c-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[i]={id:i.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:b,kerning:{}},u){this._drawGlyph(n,f,a+d,h+d,c,o);const t=r.width*c,e=r.height*c,s=new Ss(a/t*r.width,h/e*r.height,y/t*r.width,x/e*r.height);this.chars[i].texture=new Gs({source:r,frame:s}),a+=Math.ceil(y)}}r.update(),this._currentX=a,this._currentY=h,this._currentMaxCharHeight=l,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return Ps(0,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let s=0;s<t.length;s++){const n=t[s];for(let t=0;t<this._currentChars.length;t++){const s=this._currentChars[t];let r=i[n];r||(r=i[n]=e.measureText(n).width);let o=i[s];o||(o=i[s]=e.measureText(s).width);let a=e.measureText(n+s).width,h=a-(r+o);h&&(this.chars[n].kerning[s]=h),a=e.measureText(n+s).width,h=a-(r+o),h&&(this.chars[s].kerning[n]=h)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=xh.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new Gs({source:new nr({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);const n={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=dt(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const s=e._stroke,n=s?.width??0;if(s&&(t.lineWidth=n,t.lineJoin=s.join,t.miterLimit=s.miterLimit,t.strokeStyle=ge(s,t)),e._fill&&(t.fillStyle=ge(e._fill,t)),e.dropShadow){const s=e.dropShadow,n=yn.shared.setValue(s.color).toArray(),r=s.blur*i,o=s.distance*i;t.shadowColor=`rgba(${255*n[0]},${255*n[1]},${255*n[2]},${s.alpha})`,t.shadowBlur=r,t.shadowOffsetX=Math.cos(s.angle)*o,t.shadowOffsetY=Math.sin(s.angle)*o}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,s,n,r){const o=e.text,a=e.fontProperties,h=r._stroke,l=(h?.width??0)*n,c=i+l/2,d=s-l/2,u=a.descent*n,p=e.lineHeight*n;let g=!1;r.stroke&&l&&(g=!0,t.strokeText(o,c,d+p-u));const{shadowBlur:f,shadowOffsetX:m,shadowOffsetY:y}=t;r._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(o,c,d+p-u)),g&&(t.shadowBlur=f,t.shadowOffsetX=m,t.shadowOffsetY=y)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];xh.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};vh.defaultOptions={textureSize:512,style:new yh,mipmap:!0};let _h=vh,wh=0;const Ah=new class{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,textureStyle:null},this.measureCache=ct(1e3)}getFont(t,e){let i=`${e.fontFamily}-bitmap`,s=!0;if(e._fill.fill&&!e._stroke?(i+=e._fill.fill.styleKey,s=!1):(e._stroke||e.dropShadow)&&(i=`${e.styleKey}-bitmap`,s=!1),!pr.has(i)){const t=Object.create(e);t.lineHeight=0;const n=new _h({style:t,overrideFill:s,overrideSize:!0,...this.defaultOptions});wh++,wh>50&&o(),n.once("destroy",()=>{wh--,pr.remove(i)}),pr.set(i,n)}const n=pr.get(i);return n.ensureCharacters?.(t),n}getLayout(t,e,i=!0){const s=this.getFont(t,e),n=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(n))return this.measureCache.get(n);const r=fe(No.graphemeSegmenter(t),e,s,i);return this.measureCache.set(n,r),r}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){let e=t[0];"string"==typeof e&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},Ps(0,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e?.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const s=e.style,n=s instanceof yh?s:new yh(s),r=e.dynamicFill??this._canUseTintForStyle(n),o=new _h({style:n,overrideFill:r,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),a=function(t){if(""===t)return[];"string"==typeof t&&(t=[t]);const e=[];for(let i=0,s=t.length;i<s;i++){const s=t[i];if(Array.isArray(s)){if(2!==s.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(0===s[0].length||0===s[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const t=s[0].charCodeAt(0),i=s[1].charCodeAt(0);if(i<t)throw new Error("[BitmapFont]: Invalid character range.");for(let s=t,n=i;s<=n;s++)e.push(String.fromCharCode(s))}else e.push(...Array.from(s))}if(0===e.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}(e.chars);return o.ensureCharacters(a.join("")),pr.set(`${i}-bitmap`,o),o.once("destroy",()=>pr.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=pr.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}};class Ch extends Lo{constructor(t,e){super();const{textures:i,data:s}=t;Object.keys(s.pages).forEach(t=>{const e=s.pages[parseInt(t,10)],n=i[e.id];this.pages.push({texture:n})}),Object.keys(s.chars).forEach(t=>{const e=s.chars[t],{frame:n,source:r,rotate:o}=i[e.page],a=As.transformRectCoords(e,n,o,new Ss),h=new Gs({frame:a,orig:new Ss(0,0,e.width,e.height),source:r,rotate:o});this.chars[t]={id:t.codePointAt(0),xOffset:e.xOffset,yOffset:e.yOffset,xAdvance:e.xAdvance,kerning:e.kerning??{},texture:h}}),this.baseRenderedFontSize=s.fontSize,this.baseMeasurementFontSize=s.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:s.fontSize},this.baseLineOffset=s.baseLineOffset,this.lineHeight=s.lineHeight,this.fontFamily=s.fontFamily,this.distanceField=s.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){Ah.install(t)}static uninstall(t){Ah.uninstall(t)}}const Sh={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const t in e){const s=e[t].match(/^[a-z]+/gm)[0],n=e[t].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),r={};for(const t in n){const e=n[t].split("="),i=e[0],s=e[1].replace(/"/gm,""),o=parseFloat(s),a=isNaN(o)?s:o;r[i]=a}i[s].push(r)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[n]=i.info,[r]=i.common,[o]=i.distanceField??[];o&&(s.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),s.fontSize=parseInt(n.size,10),s.fontFamily=n.face,s.lineHeight=parseInt(r.lineHeight,10);const a=i.page;for(let t=0;t<a.length;t++)s.pages.push({id:parseInt(a[t].id,10)||0,file:a[t].file});const h={};s.baseLineOffset=s.lineHeight-parseInt(r.base,10);const l=i.char;for(let t=0;t<l.length;t++){const e=l[t],i=parseInt(e.id,10);let n=e.letter??e.char??String.fromCharCode(i);"space"===n&&(n=" "),h[i]=n,s.chars[n]={id:i,page:parseInt(e.page,10)||0,x:parseInt(e.x,10),y:parseInt(e.y,10),width:parseInt(e.width,10),height:parseInt(e.height,10),xOffset:parseInt(e.xoffset,10),yOffset:parseInt(e.yoffset,10),xAdvance:parseInt(e.xadvance,10),kerning:{}}}const c=i.kerning||[];for(let t=0;t<c.length;t++){const e=parseInt(c[t].first,10),i=parseInt(c[t].second,10),n=parseInt(c[t].amount,10);s.chars[h[i]].kerning[h[e]]=n}return s}},Ih={test(t){const e=t;return"string"!=typeof e&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")},parse(t){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},i=t.getElementsByTagName("info")[0],s=t.getElementsByTagName("common")[0],n=t.getElementsByTagName("distanceField")[0];n&&(e.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const r=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning");e.fontSize=parseInt(i.getAttribute("size"),10),e.fontFamily=i.getAttribute("face"),e.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let t=0;t<r.length;t++)e.pages.push({id:parseInt(r[t].getAttribute("id"),10)||0,file:r[t].getAttribute("file")});const h={};e.baseLineOffset=e.lineHeight-parseInt(s.getAttribute("base"),10);for(let t=0;t<o.length;t++){const i=o[t],s=parseInt(i.getAttribute("id"),10);let n=i.getAttribute("letter")??i.getAttribute("char")??String.fromCharCode(s);"space"===n&&(n=" "),h[s]=n,e.chars[n]={id:s,page:parseInt(i.getAttribute("page"),10)||0,x:parseInt(i.getAttribute("x"),10),y:parseInt(i.getAttribute("y"),10),width:parseInt(i.getAttribute("width"),10),height:parseInt(i.getAttribute("height"),10),xOffset:parseInt(i.getAttribute("xoffset"),10),yOffset:parseInt(i.getAttribute("yoffset"),10),xAdvance:parseInt(i.getAttribute("xadvance"),10),kerning:{}}}for(let t=0;t<a.length;t++){const i=parseInt(a[t].getAttribute("first"),10),s=parseInt(a[t].getAttribute("second"),10),n=parseInt(a[t].getAttribute("amount"),10);e.chars[h[s]].kerning[h[i]]=n}return e}},Mh=[".xml",".fnt"],Th={extension:{type:qi.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof Ch,getCacheableAssets(t,e){const i={};return t.forEach(t=>{i[t]=e,i[`${t}-bitmap`]=e}),i[`${e.fontFamily}-bitmap`]=e,i}},Ph={extension:{type:qi.LoadParser,priority:fr.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>Mh.includes(mr.extname(t).toLowerCase()),testParse:async t=>Sh.test(t)||(t=>!("string"!=typeof t||!t.includes("<font>"))&&Ih.test(ir.get().parseXML(t)))(t),async parse(t,e,i){const s=Sh.test(t)?Sh.parse(t):(t=>Ih.parse(ir.get().parseXML(t)))(t),{src:n}=e,{pages:r}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<r.length;++t){const e=r[t].file;let i=mr.join(mr.dirname(n),e);i=br(i,n),o.push({src:i,data:a})}const h=await i.load(o),l=o.map(t=>h[t.src]);return new Ch({data:s,textures:l},n)},async load(t,e){const i=await ir.get().fetch(t);return await i.text()},async unload(t,e,i){await Promise.all(t.pages.map(t=>i.unload(t.texture.source._sourceOrigin))),t.destroy()}};class Eh{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(t=>{this._assetList.push(t)}),this.verbose,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 Bh={extension:{type:qi.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof Gs),getCacheableAssets:(t,e)=>{const i={};return t.forEach(t=>{e.forEach((e,s)=>{i[t+(0===s?"":s+1)]=e})}),i}},Rh={extension:{type:qi.DetectionParser,priority:1},test:async()=>me("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async t=>[...t,"avif"],remove:async t=>t.filter(t=>"avif"!==t)},kh=["png","jpg","jpeg"],Oh={extension:{type:qi.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async t=>[...t,...kh],remove:async t=>t.filter(t=>!kh.includes(t))},Dh="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope,Fh={extension:{type:qi.DetectionParser,priority:0},test:async()=>ye("video/mp4"),add:async t=>[...t,"mp4","m4v"],remove:async t=>t.filter(t=>"mp4"!==t&&"m4v"!==t)},Lh={extension:{type:qi.DetectionParser,priority:0},test:async()=>ye("video/ogg"),add:async t=>[...t,"ogv"],remove:async t=>t.filter(t=>"ogv"!==t)},jh={extension:{type:qi.DetectionParser,priority:0},test:async()=>ye("video/webm"),add:async t=>[...t,"webm"],remove:async t=>t.filter(t=>"webm"!==t)},Gh={extension:{type:qi.DetectionParser,priority:0},test:async()=>me("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async t=>[...t,"webp"],remove:async t=>t.filter(t=>"webp"!==t)},Uh=class t{constructor(){this.loadOptions={...t.defaultOptions},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()=>{let s=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&o(),n||o(e.parser||e.loadParser)),!n){for(let i=0;i<this.parsers.length;i++){const s=this.parsers[i];if(s.load&&s.test?.(t,e,this)){n=s;break}}if(!n)return o(),null}s=await n.load(t,e,this),i.parser=n;for(let t=0;t<this.parsers.length;t++){const n=this.parsers[t];n.parse&&n.parse&&await(n.testParse?.(s,e,this))&&(s=await n.parse(s,e,this)||s,i.parser=n)}return s})(),i}async load(e,i){this._parsersValidated||this._validateParsers();const s="function"==typeof i?{...t.defaultOptions,...this.loadOptions,onProgress:i}:{...t.defaultOptions,...this.loadOptions,...i||{}},{onProgress:n,onError:r,strategy:o,retryCount:a,retryDelay:h}=s;let l=0;const c={},d=yr(e),u=ur(e,t=>({alias:[t],src:t,data:{}})),p=u.reduce((t,e)=>t+(e.progressSize||1),0),g=u.map(async t=>{const e=mr.toAbsolute(t.src);c[t.src]||(await this._loadAssetWithRetry(e,t,{onProgress:n,onError:r,strategy:o,retryCount:a,retryDelay:h},c),l+=t.progressSize||1,n&&n(l/p))});return await Promise.all(g),d?c[u[0].src]:c}async unload(t){const e=ur(t,t=>({alias:[t],src:t})).map(async t=>{const e=mr.toAbsolute(t.src),i=this.promiseCache[e];if(i){const s=await i.promise;delete this.promiseCache[e],await(i.parser?.unload?.(s,t,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(e.name||e.id?(t[e.name]||t[e.id])&&o(e.id):o(),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,s){let n=0;const{onError:r,strategy:o,retryCount:a,retryDelay:h}=i,l=t=>new Promise(e=>setTimeout(e,t));for(;;)try{return this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),void(s[e.src]=await this.promiseCache[t].promise)}catch(i){if(delete this.promiseCache[t],delete s[e.src],n++,"retry"===o&&!("retry"!==o||n>a)){r&&r(i,e),await l(h);continue}if("skip"===o)return void(r&&r(i,e));throw r&&r(i,e),new Error(`[Loader.load] Failed to load ${t}.\n${i}`)}}};Uh.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let zh=Uh;const Nh={extension:{type:qi.LoadParser,priority:fr.Low},name:"loadJson",id:"json",test:t=>xe(t,"application/json")||be(t,".json"),async load(t){const e=await ir.get().fetch(t);return await e.json()}},Vh={name:"loadTxt",id:"text",extension:{type:qi.LoadParser,priority:fr.Low,name:"loadTxt"},test:t=>xe(t,"text/plain")||be(t,".txt"),async load(t){const e=await ir.get().fetch(t);return await e.text()}},Hh=["normal","bold","100","200","300","400","500","600","700","800","900"],Wh=[".ttf",".otf",".woff",".woff2"],Jh=["font/ttf","font/otf","font/woff","font/woff2"],Zh=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i,Xh=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/,Yh={extension:{type:qi.LoadParser,priority:fr.Low},name:"loadWebFont",id:"web-font",test:t=>xe(t,Jh)||be(t,Wh),async load(t,e){const i=ir.get().getFontFaceSet();if(i){const s=[],n=e.data?.family??function(t){const e=mr.extname(t),i=mr.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let s=i.length>0;for(const t of i)if(!t.match(Zh)){s=!1;break}let n=i.join(" ");return s||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}(t),r=e.data?.weights?.filter(t=>Hh.includes(t))??["normal"],o=e.data??{};for(let e=0;e<r.length;e++){const a=r[e],h=new FontFace(n,`url(${ve(t)})`,{...o,weight:a});await h.load(),i.add(h),s.push(h)}return pr.has(`${n}-and-url`)?pr.get(`${n}-and-url`).entries.push({url:t,faces:s}):pr.set(`${n}-and-url`,{entries:[{url:t,faces:s}]}),1===s.length?s[0]:s}return o(),null},unload(t){const e=Array.isArray(t)?t:[t],i=e[0].family,s=pr.get(`${i}-and-url`),n=s.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));n.faces=n.faces.filter(t=>-1===e.indexOf(t)),0===n.faces.length&&(s.entries=s.entries.filter(t=>t!==n)),e.forEach(t=>{ir.get().getFontFaceSet().delete(t)}),0===s.entries.length&&pr.remove(`${i}-and-url`)}},Kh={extension:{type:qi.LoadParser,priority:fr.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>xe(t,"image/svg+xml")||be(t,".svg"),async load(t,e,i){return e.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?async function(t){const e=await ir.get().fetch(t),i=await e.text(),s=new fh;return s.svg(i),s}(t):async function(t,e,i,s){const n=await ir.get().fetch(t),r=ir.get().createImage();r.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await n.text())}`,r.crossOrigin=s,await r.decode();const o=e.data?.width??r.width,a=e.data?.height??r.height,h=e.data?.resolution||_e(t),l=Math.ceil(o*h),c=Math.ceil(a*h),d=ir.get().createCanvas(l,c),u=d.getContext("2d");u.imageSmoothingEnabled=!0,u.imageSmoothingQuality="high",u.drawImage(r,0,0,o*h,a*h);const{parseAsGraphicsContext:p,...g}=e.data??{};return we(new nr({resource:d,alphaMode:"premultiply-alpha-on-upload",resolution:h,...g}),i,t)}(t,e,i,this.config.crossOrigin)},unload(t){t.destroy(!0)}};let Qh=null,qh=class{constructor(){Qh||(Qh=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";\n async function checkImageBitmap() {\n try {\n if (typeof createImageBitmap !== "function")\n return false;\n const response = await fetch(WHITE_PNG);\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n } catch (_e) {\n return false;\n }\n }\n void checkImageBitmap().then((result) => {\n self.postMessage(result);\n });\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(Qh)}};qh.revokeObjectURL=function(){Qh&&(URL.revokeObjectURL(Qh),Qh=null)};let $h=null;class tl{constructor(){$h||($h=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n async function loadImageBitmap(url, alphaMode) {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n }\n const imageBlob = await response.blob();\n return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);\n }\n self.onmessage = async (event) => {\n try {\n const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id\n }, [imageBitmap]);\n } catch (e) {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id\n });\n }\n };\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker($h)}}tl.revokeObjectURL=function(){$h&&(URL.revokeObjectURL($h),$h=null)};let el,il=0;const sl=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new qh;e.addEventListener("message",i=>{e.terminate(),qh.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){void 0===el&&(el=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<el&&(this._createdWorkers++,t=(new tl).worker,t.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){void 0!==t.error?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((i,s)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:s})});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[il]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:il++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},nl=[".jpeg",".jpg",".png",".webp",".avif"],rl=["image/jpeg","image/png","image/webp","image/avif"],ol={name:"loadTextures",id:"texture",extension:{type:qi.LoadParser,priority:fr.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>xe(t,rl)||be(t,nl),async load(t,e,i){let s=null;return s=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await sl.isImageBitmapSupported()?await sl.loadImageBitmap(t,e):await async function(t,e){const i=await ir.get().fetch(t);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${i.status} ${i.statusText}`);const s=await i.blob();return"premultiplied-alpha"===e?.data?.alphaMode?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}(t,e):await new Promise((e,i)=>{s=ir.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=t,s.complete?e(s):(s.onload=()=>{e(s)},s.onerror=i)}),we(new nr({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:e.data?.resolution||_e(t),...e.data}),i,t)},unload(t){t.destroy(!0)}},al=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let hl,ll;const cl={name:"loadVideo",id:"video",extension:{type:qi.LoadParser,name:"loadVideo"},test(t){if(!hl||!ll){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const i of al){const s=dr.MIME_TYPES[i.substring(1)]||`video/${i.substring(1)}`;ye(s)&&(t.push(i),e.includes(s)||e.push(s))}return{validVideoExtensions:t,validVideoMime:e}}();hl=t,ll=e}const e=xe(t,ll),i=be(t,hl);return e||i},async load(t,e,i){const s={...dr.defaultOptions,resolution:e.data?.resolution||_e(t),alphaMode:e.data?.alphaMode||await _(),...e.data},n=document.createElement("video"),r={preload:!1!==s.autoLoad?"auto":void 0,"webkit-playsinline":!1!==s.playsinline?"":void 0,playsinline:!1!==s.playsinline?"":void 0,muted:!0===s.muted?"":void 0,loop:!0===s.loop?"":void 0,autoplay:!1!==s.autoPlay?"":void 0};Object.keys(r).forEach(t=>{const e=r[t];void 0!==e&&n.setAttribute(t,e)}),!0===s.muted&&(n.muted=!0),function(t,e,i){void 0!==i||e.startsWith("data:")?!1!==i&&(t.crossOrigin="string"==typeof i?i:"anonymous"):t.crossOrigin=function(t,e=globalThis.location){if(t.startsWith("data:"))return"";e||(e=globalThis.location);const i=new URL(t,document.baseURI);return i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol?"anonymous":""}(e)}(n,t,s.crossorigin);const o=document.createElement("source");let a;if(s.mime)a=s.mime;else if(t.startsWith("data:"))a=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();a=dr.MIME_TYPES[e]||`video/${e}`}return o.src=t,a&&(o.type=a),new Promise(r=>{const a=async()=>{const o=new dr({...s,resource:n});var h;n.removeEventListener("canplay",a),e.data.preload&&await(h=n,new Promise((t,e)=>{function i(){n(),t()}function s(t){n(),e(t)}function n(){h.removeEventListener("canplaythrough",i),h.removeEventListener("error",s)}h.addEventListener("canplaythrough",i),h.addEventListener("error",s),h.load()})),r(we(o,i,t))};s.preload&&!s.autoPlay&&n.load(),n.addEventListener("canplay",a),n.appendChild(o)})},unload(t){t.destroy(!0)}},dl={extension:{type:qi.ResolveParser,name:"resolveTexture"},test:ol.test,parse:t=>({resolution:parseFloat(xr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:t.split(".").pop(),src:t})},ul={extension:{type:qi.ResolveParser,priority:-2,name:"resolveJson"},test:t=>xr.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:dl.parse},pl=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new xr,this.loader=new zh,this.cache=pr,this._backgroundLoader=new Eh(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized)return void o();if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let e=t.manifest;"string"==typeof e&&(e=await this.load(e)),this.resolver.addManifest(e)}const e=t.texturePreference?.resolution??1,i="number"==typeof e?[e]:e,s=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions})}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=yr(t),s=ur(t).map(t=>{if("string"!=typeof t){const e=this.resolver.getAlias(t);return e.some(t=>!this.resolver.hasKey(t))&&this.add(t),Array.isArray(e)?e[0]:e}return this.resolver.hasKey(t)||this.add({alias:t,src:t}),t}),n=this.resolver.resolve(s),r=await this._mapLoadToResolve(n,e);return i?r[s[0]]:r}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;"string"==typeof t&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},r=Object.keys(s);let o=0;const a=[],h=r.map((t,i)=>{const r=s[t],h=Object.values(r),l=[...new Set(h.flat())].reduce((t,e)=>t+(e.progressSize||1),0);return a.push(0),o+=l,this._mapLoadToResolve(r,t=>{a[i]=t*l,e?.(a.reduce((t,e)=>t+e,0)/o)}).then(e=>{n[t]=e})});return await Promise.all(h),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(t=>{this._backgroundLoader.add(Object.values(t))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return pr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=pr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(t=>{const e=s[t.src],i=[t.src];t.alias&&i.push(...t.alias),i.forEach(t=>{n[t]=e}),pr.set(i,e)}),n}async unload(t){this._initialized||await this.init();const e=ur(t).map(t=>"string"!=typeof t?t.src:t),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ur(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(t=>{pr.remove(t.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((t,i)=>e.indexOf(t)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(e=>e in t).forEach(i=>{e.config[i]=t[i]})})}};es.handleByList(qi.LoadParser,pl.loader.parsers).handleByList(qi.ResolveParser,pl.resolver.parsers).handleByList(qi.CacheParser,pl.cache.parsers).handleByList(qi.DetectionParser,pl.detections),es.add(Bh,Oh,Rh,Gh,Fh,Lh,jh,Nh,Vh,Yh,Kh,ol,cl,Ph,Th,dl,ul);const gl={loader:qi.LoadParser,resolver:qi.ResolveParser,cache:qi.CacheParser,detection:qi.DetectionParser};es.handle(qi.Asset,t=>{const e=t.ref;Object.entries(gl).filter(([t])=>!!e[t]).forEach(([t,i])=>es.add(Object.assign(e[t],{extension:e[t].extension??i})))},t=>{const e=t.ref;Object.keys(gl).filter(t=>!!e[t]).forEach(t=>es.remove(e[t]))});class fl extends Yn{constructor(t={}){const{element:e,anchor:i,...s}=t;super({label:"DOMContainer",...s}),this.renderPipeId="dom",this.batched=!1,this._anchor=new ds(0,0),i&&(this.anchor=i),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e)return t.minX=0,t.minY=0,t.maxX=0,void(t.maxY=0);const{offsetWidth:i,offsetHeight:s}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=s}destroy(t=!1){super.destroy(t),this._element?.parentNode?.removeChild(this._element),this._element=null,this._anchor=null}}class ml{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Cr({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(0!==t.length){this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const i=t[e],s=i.element;if(!i.parent||i.globalDisplayStatus<7)s?.remove(),t.splice(e,1),e--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const t=i.worldTransform,e=i._anchor,n=i.width*e.x,r=i.height*e.y;s.style.transformOrigin=`${n}px ${r}px`,s.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-n}, ${t.ty-r})`,s.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++){const e=this._attachedDomElements[t];e.element?.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}ml.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"dom"};const yl=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this._tickerAdded&&this.domElement&&(lr.system.add(this._tickerUpdate,this,rr.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(lr.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};class xl extends Sr{constructor(){super(...arguments),this.client=new ds,this.movement=new ds,this.offset=new ds,this.global=new ds,this.screen=new ds}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,s,n,r,o,a,h,l,c,d,u,p,g){throw new Error("Method not implemented.")}}class bl extends xl{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class vl extends xl{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}vl.DOM_DELTA_PIXEL=0,vl.DOM_DELTA_LINE=1,vl.DOM_DELTA_PAGE=2;const _l=new ds,wl=new ds;class Al{constructor(t){this.dispatch=new as,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((t,e)=>t.priority-e.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else o(t.type)}hitTest(t,e){yl.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,_l.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[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=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let e=i.length-1;e>=0;e--)s.forEach(s=>{t.currentTarget=i[e],this.notifyTarget(t,s)})}propagationPath(t){const e=[t];for(let i=0;i<2048&&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,s,n,r=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(yl.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let h=a.length-1;h>=0;h--){const l=a[h],c=this.hitTestMoveRecursive(l,this._isInteractive(e)?e:l.eventMode,i,s,n,r||n(t,i));if(c){if(c.length>0&&!c[c.length-1].parent)continue;const e=t.isInteractive();(c.length>0||e)&&(e&&this._allInteractiveElements.push(t),c.push(t)),0===this._hitElements.length&&(this._hitElements=c),o=!0}}}const a=this._isInteractive(e),h=t.isInteractive();return h&&h&&this._allInteractiveElements.push(t),r||this._hitElements.length>0?null:o?this._hitElements:a&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(yl.pauseUpdate=!1),t.interactiveChildren&&t.children){const r=t.children,o=i;for(let i=r.length-1;i>=0;i--){const a=r[i],h=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,s,n);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const e=t.isInteractive();return(h.length>0||e)&&h.push(t),h}}}const r=this._isInteractive(e),o=t.isInteractive();return r&&s(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&t.visible&&t.renderable&&t.measurable)||"none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,wl),!t.hitArea.contains(wl.x,wl.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const s=t.effects[i];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return!!t.hitArea||!!t?.containsPoint&&(t.worldTransform.applyInverse(e,wl),t.containsPoint(wl))}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);const i=`on${e}`;t.currentTarget[i]?.(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 bl))return void o();const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof bl))return void o();this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i="mouse"===e.pointerType||"pen"===e.pointerType,s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&n!==e.target){const s="mousemove"===t.type?"mouseout":"pointerout",r=this.createPointerEvent(t,s,n);if(this.dispatchEvent(r,"pointerout"),i&&this.dispatchEvent(r,"mouseout"),!e.composedPath().includes(n)){const s=this.createPointerEvent(t,"pointerleave",n);for(s.eventPhase=s.AT_TARGET;s.target&&!e.composedPath().includes(s.target);)s.currentTarget=s.target,this.notifyTarget(s),i&&this.notifyTarget(s,"mouseleave"),s.target=s.target.parent;this.freeEvent(s)}this.freeEvent(r)}if(n!==e.target){const s="mousemove"===t.type?"mouseover":"pointerover",r=this.clonePointerEvent(e,s);this.dispatchEvent(r,"pointerover"),i&&this.dispatchEvent(r,"mouseover");let o=n?.parent;for(;o&&o!==this.rootTarget.parent&&o!==e.target;)o=o.parent;if(!o||o===this.rootTarget.parent){const t=this.clonePointerEvent(e,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==n&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),i&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(r)}const r=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?r.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&r.push("globalpointermove"),"touch"===e.pointerType&&(this.moveOnAll?r.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&r.push("globaltouchmove")),i&&(this.moveOnAll?r.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&r.push("globalmousemove"),this.cursor=e.target?.cursor),r.length>0&&this.all(e,r),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof bl))return void o();const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=i.target?.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),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof bl))return void o();const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const r=this.createPointerEvent(t,"pointerleave",s);for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),i&&this.notifyTarget(r,"mouseleave"),r.target=r.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(r)}this.cursor=null}mapPointerUp(t){if(!(t instanceof bl))return void o();const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let r=n;if(n&&!i.composedPath().includes(n)){let e=n;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete s.pressTargetsByButton[t.button],r=e}if(r){const n=this.clonePointerEvent(i,"click");n.target=r,n.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:n.target,timeStamp:e});const o=s.clicksByButton[t.button];if(o.target===n.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=n.target,o.timeStamp=e,n.detail=o.clickCount,"mouse"===n.pointerType){const t=2===n.button;this.dispatchEvent(n,t?"rightclick":"click")}else"touch"===n.pointerType&&this.dispatchEvent(n,"tap");this.dispatchEvent(n,"pointertap"),this.freeEvent(n)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof bl))return void o();const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),"touch"===s.pointerType?this.notifyTarget(s,"touchendoutside"):"mouse"!==s.pointerType&&"pen"!==s.pointerType||this.notifyTarget(s,2===s.button?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof vl))return void o();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 s=this.allocateEvent(bl);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],"string"==typeof e&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(vl);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(bl);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 bl&&e instanceof bl&&(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 xl&&e instanceof xl&&(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.defaultPrevented=!1,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)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const Cl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Sl=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new Al(null),yl.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new bl(null),this._rootWheelEvent=new vl(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...t.defaultEventFeatures},{set:(t,e,i)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!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(e){const{canvas:i,resolution:s}=this.renderer;this.setTargetElement(i),this.resolution=s,t._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){yl.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)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)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 t=0,i=e.length;t<i;t++){const i=e[t],s=this._bootstrapEvent(this._rootPointerEvent,i);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,yl.pointerMoved();const e=this._normalizeToPointerData(t);for(let t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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":"",s=this._normalizeToPointerData(t);for(let t=0,e=s.length;t<e;t++){const e=this._bootstrapEvent(this._rootPointerEvent,s[t]);e.type+=i,this.rootBoundary.mapEvent(e)}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 t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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,yl.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;yl.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;yl.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 s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const s=t.changedTouches[i];void 0===s.button&&(s.button=0),void 0===s.buttons&&(s.buttons=1),void 0===s.isPrimary&&(s.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===s.width&&(s.width=s.radiusX||1),void 0===s.height&&(s.height=s.radiusY||1),void 0===s.tiltX&&(s.tiltX=0),void 0===s.tiltY&&(s.tiltY=0),void 0===s.pointerType&&(s.pointerType="touch"),void 0===s.pointerId&&(s.pointerId=s.identifier||0),void 0===s.pressure&&(s.pressure=s.force||.5),void 0===s.twist&&(s.twist=0),void 0===s.tangentialPressure&&(s.tangentialPressure=0),void 0===s.layerX&&(s.layerX=s.offsetX=s.clientX),void 0===s.layerY&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=t.type,e.push(s)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&!(this.supportsPointerEvents&&t instanceof globalThis.PointerEvent)){const i=t;void 0===i.isPrimary&&(i.isPrimary=!0),void 0===i.width&&(i.width=1),void 0===i.height&&(i.height=1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="mouse"),void 0===i.pointerId&&(i.pointerId=1),void 0===i.pressure&&(i.pressure=.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(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,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Cl[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}};Sl.extension={name:"events",type:[qi.WebGLSystem,qi.CanvasSystem,qi.WebGPUSystem],priority:-1},Sl.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Il=Sl;const Ml={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"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(t){this.eventMode=t?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Il.defaultEventMode},set eventMode(t){this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,i){const s="boolean"==typeof i&&i||"object"==typeof i&&i.capture,n="object"==typeof i?i.signal:void 0,r="object"==typeof i&&!0===i.once,o="function"==typeof e?void 0:e;t=s?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,h=this;n&&n.addEventListener("abort",()=>{h.off(t,a,o)}),r?h.once(t,a,o):h.on(t,a,o)},removeEventListener(t,e,i){const s="function"==typeof e?void 0:e;t="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,s)},dispatchEvent(t){if(!(t instanceof Sr))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};var Tl="struct GlobalFilterUniforms {\n uInputSize: vec4<f32>,\n uInputPixel: vec4<f32>,\n uInputClamp: vec4<f32>,\n uOutputFrame: vec4<f32>,\n uGlobalFrame: vec4<f32>,\n uOutputTexture: vec4<f32>,\n};\n\n@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler: sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>\n};\n\nfn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n";class Pl extends xo{constructor(){super({gpuProgram:ro.from({vertex:{source:Tl,entryPoint:"mainVertex"},fragment:{source:Tl,entryPoint:"mainFragment"},name:"passthrough-filter"}),glProgram:to.from({vertex:"in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n",fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n",name:"passthrough-filter"})})}}class El{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){"pushFilter"===t.action?this._renderer.filter.push(t):"popFilter"===t.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}El.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"filter"};const Bl=new ps,Rl=new ya({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class kl{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new zs,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class Ol{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new lo({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 co({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=i,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,r=n.resolution,o=n.antialias;if(i.every(t=>!t.enabled))return void(s.skip=!0);const a=s.bounds;if(this._calculateFilterArea(t,a),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,o,r,1),s.skip)return;const h=this._getPreviousFilterData(),l=this._findFilterResolution(r);let c=0,d=0;h&&(c=h.bounds.minX,d=h.bounds.minY),this._calculateGlobalFrame(s,c,d,l,n.width,n.height),this._setupFilterTextures(s,a,e,h)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const s=t.source,n=s.resolution,r=s.antialias;if(e.every(t=>!t.enabled))return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,r,n,0),i.skip)return t;const a=n;this._calculateGlobalFrame(i,0,0,a,s.width,s.height),i.outputRenderSurface=Nn.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=Gs.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const h=i.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&Nn.returnTexture(e.backTexture),Nn.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const s=t.colorTexture.source._resolution,n=Nn.getOptimalTexture(e.width,e.height,s,!1);let r=e.minX,o=e.minY;i&&(r-=i.minX,o-=i.minY),r=Math.floor(r*s),o=Math.floor(o*s);const a=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,n,{x:r,y:o},{width:a,height:h},{x:0,y:0}),n}applyFilter(t,e,i,s){const n=this.renderer,r=this._activeFilterData,o=r.outputRenderSurface===i,a=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,h=this._findFilterResolution(a);let l=0,c=0;if(o){const t=this._findPreviousFilterOffset();l=t.x,c=t.y}this._updateFilterUniforms(e,i,r,l,c,h,o,s);const d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,n)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,s=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(ps.shared),r=e.renderGroup||e.parentRenderGroup;return r&&r.cacheToLocalTransform&&n.prepend(r.cacheToLocalTransform),n.invert(),s.prepend(n),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new Pl),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const t=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(t,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:Rl,shader:t,state:t._state,topology:"triangle-list"}),i.type===uo.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,s){if(t.backTexture=Gs.EMPTY,t.inputTexture=Nn.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const n=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,s?.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,s,n,r){const o=t.globalFrame;o.x=e*s,o.y=i*s,o.width=n*s,o.height=r*s}_updateFilterUniforms(t,e,i,s,n,r,o,a){const h=this._filterGlobalUniforms.uniforms,l=h.uOutputFrame,c=h.uInputSize,d=h.uInputPixel,u=h.uInputClamp,p=h.uGlobalFrame,g=h.uOutputTexture;o?(l[0]=i.bounds.minX-s,l[1]=i.bounds.minY-n):(l[0]=0,l[1]=0),l[2]=t.frame.width,l[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],u[0]=.5*d[2],u[1]=.5*d[3],u[2]=t.frame.width*c[2]-.5*d[2],u[3]=t.frame.height*c[3]-.5*d[3];const f=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*r,p[1]=n*r,p[2]=f.source.width*r,p[3]=f.source.height*r,e instanceof Gs&&(e.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof Gs?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=m.width,g[1]=m.height),g[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const s=this._filterStack[i];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?function(t,e){e.clear();const i=e.matrix;for(let i=0;i<t.length;i++){const s=t[i];if(s.globalDisplayStatus<7)continue;const n=s.renderGroup??s.parentRenderGroup;e.matrix=n?.isCachedAsTexture?Bl.copyFrom(n.textureOffsetInverseTransform).append(s.worldTransform):n?._parentCacheAsTextureRenderGroup?Bl.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):s.worldTransform,e.addBounds(s.bounds)}e.matrix=i}(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,s=t.bounds,n=t.filters,r=t.firstEnabledIndex,o=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),r===o)n[r].apply(this,i,t.outputRenderSurface,e);else{let i=t.inputTexture;const a=Nn.getOptimalTexture(s.width,s.height,i.source._resolution,!1);let h=a;for(let t=r;t<o;t++){const e=n[t];if(!e.enabled)continue;e.apply(this,i,h,!0);const s=i;i=h,h=s}n[o].apply(this,i,t.outputRenderSurface,e),Nn.returnTexture(a)}}_calculateFilterBounds(t,e,i,s,n){const r=this.renderer,a=t.bounds,h=t.filters;let l=1/0,c=0,d=!0,u=!1,p=!1,g=!0,f=-1,m=-1;for(let t=0;t<h.length;t++){const e=h[t];if(e.enabled){if(-1===f&&(f=t),m=t,l=Math.min(l,"inherit"===e.resolution?s:e.resolution),c+=e.padding,"off"===e.antialias?d=!1:"inherit"===e.antialias&&d&&(d=i),e.clipToViewport||(g=!1),!(e.compatibleRenderers&r.type)){p=!1;break}if(e.blendRequired&&!(r.backBuffer?.useBackBuffer??1)){o(),p=!1;break}p=!0,u||(u=e.blendRequired)}}p?(g&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(l).ceil().scale(1/l).pad((0|c)*n),a.isPositive?(t.antialias=d,t.resolution=l,t.blendRequired=u,t.firstEnabledIndex=f,t.lastEnabledIndex=m):t.skip=!0):t.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new kl),this._filterStackIndex++,t}}Ol.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"filter"};var Dl="struct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\nstruct MaskUniforms {\n uFilterMatrix:mat3x3<f32>,\n uMaskClamp:vec4<f32>,\n uAlpha:f32,\n uInverse:f32,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler : sampler;\n\n@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;\n@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) filterUv : vec2<f32>,\n};\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);\n}\n\nfn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>\n{\n return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition),\n getFilterCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) filterUv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n\n var maskClamp = filterUniforms.uMaskClamp;\n var uAlpha = filterUniforms.uAlpha;\n\n var clip = step(3.5,\n step(maskClamp.x, filterUv.x) +\n step(maskClamp.y, filterUv.y) +\n step(filterUv.x, maskClamp.z) +\n step(filterUv.y, maskClamp.w));\n\n var mask = textureSample(uMaskTexture, uSampler, filterUv);\n var source = textureSample(uTexture, uSampler, uv);\n var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);\n\n var a: f32 = alphaMul * mask.r * uAlpha * clip;\n\n if (filterUniforms.uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n return source * a;\n}\n";class Fl extends xo{constructor(t){const{sprite:e,...i}=t,s=new js(e.texture),n=new lo({uFilterMatrix:{value:new ps,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}});super({...i,gpuProgram:ro.from({vertex:{source:Dl,entryPoint:"mainVertex"},fragment:{source:Dl,entryPoint:"mainFragment"}}),glProgram:to.from({vertex:"in vec2 aPosition;\n\nout vec2 vTextureCoord;\nout vec2 vMaskCoord;\n\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\nuniform mat3 uFilterMatrix;\n\nvec4 filterVertexPosition( vec2 aPosition )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( vec2 aPosition )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvec2 getFilterCoord( vec2 aPosition )\n{\n return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n} \n\nvoid main(void)\n{\n gl_Position = filterVertexPosition(aPosition);\n vTextureCoord = filterTextureCoord(aPosition);\n vMaskCoord = getFilterCoord(aPosition);\n}\n",fragment:"in vec2 vMaskCoord;\nin vec2 vTextureCoord;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMaskTexture;\n\nuniform float uAlpha;\nuniform vec4 uMaskClamp;\nuniform float uInverse;\n\nout vec4 finalColor;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(uMaskClamp.x, vMaskCoord.x) +\n step(uMaskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, uMaskClamp.z) +\n step(vMaskCoord.y, uMaskClamp.w));\n\n // TODO look into why this is needed\n float npmAlpha = uAlpha;\n vec4 original = texture(uTexture, vTextureCoord);\n vec4 masky = texture(uMaskTexture, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n float a = alphaMul * masky.r * npmAlpha * clip;\n\n if (uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n finalColor = original * a;\n}\n",name:"mask-filter"}),clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=s}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}apply(t,e,i,s){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,s)}}class Ll extends Yn{constructor(t){t instanceof fh&&(t={context:t});const{context:e,roundPixels:i,...s}=t||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",this._context=e||(this._ownedContext=new fh),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,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}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):!0!==t&&!0!==t?.context||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 Ll(this._context.clone()):(this._ownedContext=null,new Ll(this._context))}lineStyle(t,e,i){Ps(0,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){Ps(0,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return void 0!==t&&(i.color=t),void 0!==e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){Ps(0,"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===fh.defaultStrokeStyle.width&&t.color===fh.defaultStrokeStyle.color&&t.alpha===fh.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return Ps(0,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return Ps(0,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return Ps(0,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return Ps(0,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return Ps(0,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return Ps(0,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const jl=class t extends ya{constructor(...e){let i=e[0]??{};i instanceof Float32Array&&(Ps(0,"use new MeshGeometry({ positions, uvs, indices }) instead"),i={positions:i,uvs:e[1],indices:e[2]}),i={...t.defaultOptions,...i};const s=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=i.uvs;n||(n=i.positions?new Float32Array(s.length):new Float32Array([0,0,1,0,1,1,0,1]));const r=i.indices||new Uint32Array([0,1,2,0,2,3]),o=i.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new ma({data:s,label:"attribute-mesh-positions",shrinkToFit:o,usage:fa.VERTEX|fa.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new ma({data:n,label:"attribute-mesh-uvs",shrinkToFit:o,usage:fa.VERTEX|fa.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new ma({data:r,label:"index-mesh-buffer",shrinkToFit:o,usage:fa.INDEX|fa.COPY_DST}),topology:i.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}};jl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Gl=jl;class Ul extends Yn{constructor(...t){let e=t[0];e instanceof ya&&(Ps(0,"Mesh: use new Mesh({ geometry, shader }) instead"),e={geometry:e,shader:t[1]},t[3]&&(Ps(0,"Mesh: drawMode argument has been removed, use geometry.topology instead"),e.geometry.topology=t[3]));const{geometry:i,shader:s,texture:n,roundPixels:r,state:o,...a}=e;super({label:"Mesh",...a}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=n??s?.texture??Gs.WHITE,this.state=o??mo.for2d(),this._geometry=i,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=r??!1}get material(){return Ps(0,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){this._geometry!==t&&(this._geometry?.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=Gs.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.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return!this._shader&&!(12&this.state.data)&&this._geometry instanceof Gl&&("auto"===this._geometry.batchMode?this._geometry.positions.length/2<=100:"batch"===this._geometry.batchMode)}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){const t=this.geometry.getIndex().data,r=t.length;for(let o=0;o+2<r;o+=n){const n=2*t[o],r=2*t[o+1],a=2*t[o+2];if(Ae(e,i,s[n],s[n+1],s[r],s[r+1],s[a],s[a+1]))return!0}}else{const t=s.length/2;for(let r=0;r+2<t;r+=n){const t=2*r,n=2*(r+1),o=2*(r+2);if(Ae(e,i,s[t],s[t+1],s[n],s[n+1],s[o],s[o+1]))return!0}}return!1}destroy(t){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._geometry?.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}class zl extends Kn{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{animationSpeed:i=1,autoPlay:s=!1,autoUpdate:n=!0,loop:r=!0,onComplete:o=null,onFrameChange:a=null,onLoop:h=null,textures:l,updateAnchor:c=!1,...d}=e,[u]=l;super({...d,texture:u instanceof Gs?u:u.texture}),this._textures=null,this._durations=null,this._autoUpdate=n,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=r,this.updateAnchor=c,this.onComplete=o,this.onFrameChange=a,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=l,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(lr.shared.add(this.update,this,rr.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,s=this.currentFrame;if(null!==this._durations){let t=this._currentTime%1*this._durations[this.currentFrame];for(t+=i/60*1e3;t<0;)this._currentTime--,t+=this._durations[this.currentFrame];const s=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);t>=this._durations[this.currentFrame];)t-=this._durations[this.currentFrame]*s,this._currentTime+=s;this._currentTime+=t/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()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if("boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._textures.forEach(t=>{this.texture!==t&&t.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(Gs.from(t[i]));return new zl(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(Gs.from(t[i]));return new zl(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof Gs)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?(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(lr.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Nl{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t??new ps,this.observer=e,this.position=new ns(this,0,0),this.scale=new ns(this,1,1),this.pivot=new ns(this,0,0),this.skew=new ns(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty?(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.dirty=!1,t):t}_onUpdate(t){this.dirty=!0,t===this.skew&&this.updateSkew(),this.observer?._onUpdate(this)}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.dirty=!0}toString(){return`[pixi.js/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}) ]`}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}const Vl=class t extends Yn{constructor(...e){let i=e[0]||{};i instanceof Gs&&(i={texture:i}),e.length>1&&(Ps(0,"use new TilingSprite({ texture, width:100, height:100 }) instead"),i.width=e[1],i.height=e[2]),i={...t.defaultOptions,...i};const{texture:s,anchor:n,tilePosition:r,tileScale:o,tileRotation:a,width:h,height:l,applyAnchorToTexture:c,roundPixels:d,...u}=i??{};super({label:"TilingSprite",...u}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new ns({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=s,this._width=h??s.width,this._height=l??s.height,this._tileTransform=new Nl({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=r,this.tileScale=o,this.tileRotation=a,this.roundPixels=d??!1}static from(e,i={}){return new t("string"==typeof e?{texture:pr.get(e),...i}:{texture:e,...i})}get uvRespectAnchor(){return Ps(0,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Ps(0,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){"number"==typeof t?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=Gs.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}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){"object"==typeof t&&(e=t.height??t.width,t=t.width),this._width=t,this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}containsPoint(t){const e=this._width,i=this._height,s=-e*this._anchor._x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this._anchor._y,t.y>=n&&t.y<=n+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null}};Vl.defaultOptions={texture:Gs.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Hl=Vl;class Wl extends Yn{constructor(t,e){const{text:i,resolution:s,style:n,anchor:r,width:o,height:a,roundPixels:h,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=s??null,this.allowChildren=!1,this._anchor=new ns({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=h??!1,void 0!==o&&(this.width=o),void 0!==a&&(this.height=a)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=null===t,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){t||(t={}),this._style?.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 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){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this.bounds.width),void 0!==e&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,s=-e*this.anchor.x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,("boolean"==typeof t?t:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}let Jl=null,Zl=null;const Xl=new Ss,Yl=new class{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),r=No.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,r.width)+2*n)*s),a=Math.ceil(Math.ceil(Math.max(1,r.height)+2*n)*s),h=xh.getOptimalCanvasAndContext(o,a);return this._renderTextToCanvas(e,i,n,s,h),{canvasAndContext:h,frame:i.trim?Ie({canvas:h.canvas,width:o,height:a,resolution:1,output:Xl}):Xl.set(0,0,o,a)}}returnCanvasAndContext(t){xh.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){const{canvas:r,context:o}=n,a=dt(e),h=No.measureText(t||" ",e),l=h.lines,c=h.lineHeight,d=h.lineWidths,u=h.maxLineWidth,p=h.fontProperties,g=r.height;if(o.resetTransform(),o.scale(s,s),o.textBaseline=e.textBaseline,e._stroke?.width){const t=e._stroke;o.lineWidth=t.width,o.miterLimit=t.miterLimit,o.lineJoin=t.join,o.lineCap=t.cap}let f,m;o.font=a;const y=e.dropShadow?2:1;for(let t=0;t<y;++t){const r=e.dropShadow&&0===t,a=r?Math.ceil(Math.max(1,g)+2*i):0,y=a*s;if(r){o.fillStyle="black",o.strokeStyle="black";const t=e.dropShadow,i=t.color,n=t.alpha;o.shadowColor=yn.shared.setValue(i).setAlpha(n).toRgbaString();const r=t.blur*s,a=t.distance*s;o.shadowBlur=r,o.shadowOffsetX=Math.cos(t.angle)*a,o.shadowOffsetY=Math.sin(t.angle)*a+y}else{if(o.fillStyle=e._fill?ge(e._fill,o,h,2*i):null,e._stroke?.width){const t=.5*e._stroke.width+2*i;o.strokeStyle=ge(e._stroke,o,h,t)}o.shadowColor="black"}let x=(c-p.fontSize)/2;c-p.fontSize<0&&(x=0);const b=e._stroke?.width??0;for(let t=0;t<l.length;t++)f=b/2,m=b/2+t*c+p.ascent+x,"right"===e.align?f+=u-d[t]:"center"===e.align&&(f+=(u-d[t])/2),e._stroke?.width&&this._drawLetterSpacing(l[t],e,n,f+i,m+i-a,!0),void 0!==e._fill&&this._drawLetterSpacing(l[t],e,n,f+i,m+i-a)}}_drawLetterSpacing(t,e,i,s,n,r=!1){const{context:o}=i,a=e.letterSpacing;let h=!1;if(No.experimentalLetterSpacingSupported&&(No.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,h=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||h)return void(r?o.strokeText(t,s,n):o.fillText(t,s,n));let l=s;const c=No.graphemeSegmenter(t);let d=o.measureText(t).width,u=0;for(let t=0;t<c.length;++t){const e=c[t];r?o.strokeText(e,l,n):o.fillText(e,l,n);let i="";for(let e=t+1;e<c.length;++e)i+=c[e];u=o.measureText(i).width,l+=d-u+a,d=u}}};class Kl extends Wl{constructor(...t){const e=function(t){let e=t[0]??{};return("string"==typeof e||t[1])&&(Ps(0,'use new Text({ text: "hi!", style }) instead'),e={text:e,style:t[1]}),e}(t);super(e,yh),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof ks?e.textureStyle:new ks(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:t,canvasAndContext:e}=Yl.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Yl.returnCanvasAndContext(e),i=t.width,s=t.height}else{const t=No.measureText(this._text,this._style);i=t.width,s=t.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}const Ql="http://www.w3.org/2000/svg",ql="http://www.w3.org/1999/xhtml";class $l{constructor(){this.svgRoot=document.createElementNS(Ql,"svg"),this.foreignObject=document.createElementNS(Ql,"foreignObject"),this.domElement=document.createElementNS(ql,"div"),this.styleElement=document.createElementNS(ql,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(s),this.image=ir.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}let tc;class ec{constructor(){this._tempState=mo.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const s=t.renderer,n=this._didUploadHash[i.uid];s.shader.bind(i,n),n||(this._didUploadHash[i.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const s=e.textures.textures;for(let t=0;t<e.textures.count;t++)i.texture.bind(s[t],t);i.geometry.draw(e.topology,e.size,e.start)}}ec.extension={type:[qi.WebGLPipesAdaptor],name:"batch"};const ic=mo.for2d();class sc{start(t,e,i){const s=t.renderer,n=s.encoder,r=i.gpuProgram;this._shader=i,this._geometry=e,n.setGeometry(e,r),ic.blendMode="normal",s.pipeline.getPipeline(e,r,ic);const o=s.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,o,r)}execute(t,e){const i=this._shader.gpuProgram,s=t.renderer,n=s.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=ft(t.textures,t.count,s.limits.maxBatchableTextures)}ic.blendMode=e.blendMode;const r=s.bindGroup.getBindGroup(e.bindGroup,i,1),o=s.pipeline.getPipeline(this._geometry,i,ic,e.topology);e.bindGroup._touch(s.textureGC.count),n.setPipeline(o),n.renderPassEncoder.setBindGroup(1,r),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}sc.extension={type:[qi.WebGPUPipesAdaptor],name:"batch"};const nc=class t{constructor(t,e){this.state=mo.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init?.(this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new La({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const t in this._activeBatches)this._activeBatches[t].begin()}addToBatch(e,i){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(i);let s=this._activeBatches[e.batcherName];s||(s=this._activeBatches[e.batcherName]=t.getBatcher(e.batcherName),s.begin()),this._activeBatch=s}this._activeBatch.add(e)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const t in e){const i=e[t],s=i.geometry;s.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),s.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const t in e){const i=e[t],s=i.geometry;i.dirty&&(i.dirty=!1,s.buffers[0].update(4*i.attributeSize))}}execute(t){if("startBatch"===t.action){const e=t.batcher,i=e.geometry,s=e.shader;this._adaptor.start(this,i,s)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};nc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"batch"},nc._availableBatchers=Object.create(null);let rc=nc;es.handleByMap(qi.Batcher,rc._availableBatchers),es.add(La);const oc={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},ac={...oc,vertex:{...oc.vertex,header:oc.vertex.header.replace("group(1)","group(2)")}},hc={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}},lc={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},cc={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}},dc=new zs;class uc extends Sn{constructor(){super(),this.filters=[new Fl({sprite:new Kn(Gs.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}}class pc{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const s=this._renderer;if(s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const e=t.mask;e.includeInBuild=!0,e.collectRenderables(i,s,null),e.includeInBuild=!1}s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if("pushMaskBegin"===t.action){const s=_n.get(uc);if(s.inverse=t.inverse,i){t.mask.mask.measurable=!0;const i=h(t.mask.mask,!0,dc);t.mask.mask.measurable=!1,i.ceil();const n=e.renderTarget.renderTarget.colorTexture.source,r=Nn.getOptimalTexture(i.width,i.height,n._resolution,n.antialias);e.renderTarget.push(r,!0),e.globalUniforms.push({offset:i,worldColor:4294967295});const o=s.sprite;o.texture=r,o.worldTransform.tx=i.minX,o.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:r})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if("pushMaskEnd"===t.action){const t=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===uo.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:t.maskedContainer,filterEffect:t.filterEffect,canBundle:!1})}else if("popMaskEnd"===t.action){e.filter.pop();const t=this._activeMaskStage.pop();i&&Nn.returnTexture(t.filterTexture),_n.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}pc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"alphaMask"};class gc{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 s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;this._colorStackIndex--;const n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}gc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"colorMask"};class fc{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var s;const n=t,r=this._renderer;r.renderPipes.batch.break(i),r.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=n.mask;o.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(n);a.instructionsStart=i.instructionSize,o.collectRenderables(i,r,null),o.includeInBuild=!1,r.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const h=i.instructionSize-a.instructionsStart-1;a.instructionsLength=h;const l=r.renderTarget.renderTarget.uid;(s=this._maskStackHash)[l]??(s[l]=0)}pop(t,e,i){const s=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const r=this._maskHash.get(t);for(let t=0;t<r.instructionsLength;t++)i.instructions[i.instructionSize++]=i.instructions[r.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const i=this._renderer,s=i.renderTarget.renderTarget.uid;let n=(e=this._maskStackHash)[s]??(e[s]=0);"pushMaskBegin"===t.action?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(ra.RENDERING_MASK_ADD,n),n++,i.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?i.stencil.setStencilMode(ra.INVERSE_MASK_ACTIVE,n):i.stencil.setStencilMode(ra.MASK_ACTIVE,n),i.colorMask.setMask(15)):"popMaskBegin"===t.action?(i.colorMask.setMask(0),0!==n?i.stencil.setStencilMode(ra.RENDERING_MASK_REMOVE,n):(i.renderTarget.clear(null,wo.STENCIL),i.stencil.setStencilMode(ra.DISABLED,n)),n--):"popMaskEnd"===t.action&&(t.inverse?i.stencil.setStencilMode(ra.INVERSE_MASK_ACTIVE,n):i.stencil.setStencilMode(ra.MASK_ACTIVE,n),i.colorMask.setMask(15)),this._maskStackHash[s]=n}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}fc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"stencilMask"};var mc=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(mc||{});class yc{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class xc{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}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;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,i.bindBufferBase(i.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,s=this._nextBindBaseIndex;for(;i<2;){s>=this._maxBindings&&(s=this._minBaseLocation,i++);const t=this._boundBufferBases[s];if(!t||t._lastBindCallId!==this._bindCallId)break;s++}return e=s,this._nextBindBaseIndex=s+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,s){const{_gl:n}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,256*i,s||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 s=t.data,n=t.descriptor.usage&fa.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return s?i.byteLength>=s.byteLength?e.bufferSubData(i.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT):(i.byteLength=s.byteLength,e.bufferData(i.type,s,n)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,n)),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],s=this._gl;e||s.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=mc.ARRAY_BUFFER;t.descriptor.usage&fa.INDEX?i=mc.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&fa.UNIFORM&&(i=mc.UNIFORM_BUFFER);const s=new yc(e.createBuffer(),i);return this._gpuBuffers[t.uid]=s,t.on("destroy",this.onBufferDestroy,this),s}resetState(){this._boundBufferBases=Object.create(null)}}xc.extension={type:[qi.WebGLSystem],name:"buffer"};const bc=class t{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(e){e={...t.defaultOptions,...e};let i=this.multiView=e.multiView;if(e.context&&i&&(o(),i=!1),this.canvas=i?ir.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const t=this._renderer.background.alpha<1,i=e.premultipliedAlpha??!0,s=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:i,antialias:s,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&o());const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof ir.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 s=this.canvas;if(2===t&&(i=s.getContext("webgl2",e)),!i&&(i=s.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(1===this.webGLVersion)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(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&o();const i=this.supports,s=2===this.webGLVersion,n=this.extensions;i.uint32Indices=s||!!n.uint32ElementIndex,i.uniformBufferObject=s,i.vertexArrayObject=s||!!n.vertexArrayObject,i.srgbTextures=s||!!n.srgb,i.nonPowOf2wrapping=s,i.nonPowOf2mipmaps=s,i.msaa=s,i.uint32Indices||o()}};bc.extension={type:[qi.WebGLSystem],name:"context"},bc.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let vc=bc;var _c=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(_c||{}),wc=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(wc||{}),Ac=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(Ac||{});const Cc={uint8x2:Ac.UNSIGNED_BYTE,uint8x4:Ac.UNSIGNED_BYTE,sint8x2:Ac.BYTE,sint8x4:Ac.BYTE,unorm8x2:Ac.UNSIGNED_BYTE,unorm8x4:Ac.UNSIGNED_BYTE,snorm8x2:Ac.BYTE,snorm8x4:Ac.BYTE,uint16x2:Ac.UNSIGNED_SHORT,uint16x4:Ac.UNSIGNED_SHORT,sint16x2:Ac.SHORT,sint16x4:Ac.SHORT,unorm16x2:Ac.UNSIGNED_SHORT,unorm16x4:Ac.UNSIGNED_SHORT,snorm16x2:Ac.SHORT,snorm16x4:Ac.SHORT,float16x2:Ac.HALF_FLOAT,float16x4:Ac.HALF_FLOAT,float32:Ac.FLOAT,float32x2:Ac.FLOAT,float32x3:Ac.FLOAT,float32x4:Ac.FLOAT,uint32:Ac.UNSIGNED_INT,uint32x2:Ac.UNSIGNED_INT,uint32x3:Ac.UNSIGNED_INT,uint32x4:Ac.UNSIGNED_INT,sint32:Ac.INT,sint32x2:Ac.INT,sint32x3:Ac.INT,sint32x4:Ac.INT},Sc={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Ic{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}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=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(t,e,s,n)=>{i.drawArraysInstancedANGLE(t,e,s,n)},t.drawElementsInstanced=(t,e,s,n,r)=>{i.drawElementsInstancedANGLE(t,e,s,n,r)},t.vertexAttribDivisor=(t,e)=>i.vertexAttribDivisorANGLE(t,e)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,i.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.updateBuffer(s)}}checkCompatibility(t,e){const i=t.attributes,s=e._attributeData;for(const t in s)if(!i[t])throw new Error(`shader and geometry incompatible, geometry missing the "${t}" attribute`)}getSignature(t,e){const i=t.attributes,s=e._attributeData,n=["g",t.uid];for(const t in i)s[t]&&n.push(t,s[t].location);return n.join("-")}getVao(t,e){return this._geometryVaoHash[t.uid]?.[e._key]||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const s=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const r=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 a=o[r];if(a)return o[e._key]=a,a;Me(t,e._attributeData);const h=t.buffers;a=s.createVertexArray(),s.bindVertexArray(a);for(let t=0;t<h.length;t++){const e=h[t];n.bind(e)}return this.activateVao(t,e),o[e._key]=a,o[r]=a,s.bindVertexArray(null),a}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],s=this.gl;if(i){if(e)for(const t in i)this._activeVao!==i[t]&&this.unbind(),s.deleteVertexArray(i[t]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const t in this._geometryVaoHash[i]){const s=this._geometryVaoHash[i];this._activeVao!==s&&this.unbind(),e.deleteVertexArray(s[t])}this._geometryVaoHash[i]=null}}activateVao(t,e){const i=this._renderer.gl,s=this._renderer.buffer,n=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let r=null;for(const t in n){const o=n[t],a=o.buffer,h=s.getGlBuffer(a),l=e._attributeData[t];if(l){r!==h&&(s.bind(a),r=h);const t=l.location;i.enableVertexAttribArray(t);const e=R(o.format),n=Te(o.format);if("int"===l.format?.substring(1,4)?i.vertexAttribIPointer(t,e.size,n,o.stride,o.offset):i.vertexAttribPointer(t,e.size,n,e.normalised,o.stride,o.offset),o.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const e=o.divisor??1;i.vertexAttribDivisor(t,e)}}}}}draw(t,e,i,s){const{gl:n}=this._renderer,r=this._activeGeometry,o=Sc[t||r.topology];if(s??(s=r.instanceCount),r.indexBuffer){const t=r.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?n.UNSIGNED_SHORT:n.UNSIGNED_INT;1!==s?n.drawElementsInstanced(o,e||r.indexBuffer.data.length,a,(i||0)*t,s):n.drawElements(o,e||r.indexBuffer.data.length,a,(i||0)*t)}else 1!==s?n.drawArraysInstanced(o,i||0,e||r.getSize(),s):n.drawArrays(o,i||0,e||r.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,this._geometryVaoHash=null}}Ic.extension={type:[qi.WebGLSystem],name:"geometry"};const Mc=new ya({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Tc=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:i,antialias:s}={...t.defaultOptions,...e};this.useBackBuffer=i,this._antialias=s,this._renderer.context.supports.msaa||(o(),this._antialias=!1),this._state=mo.for2d();const n=new to({vertex:"\n attribute vec2 aPosition;\n out vec2 vUv;\n\n void main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n\n vUv = (aPosition + 1.0) / 2.0;\n\n // flip dem UVs\n vUv.y = 1.0 - vUv.y;\n }",fragment:"\n in vec2 vUv;\n out vec4 finalColor;\n\n uniform sampler2D uTexture;\n\n void main() {\n finalColor = texture(uTexture, vUv);\n }",name:"big-triangle"});this._bigTriangleShader=new po({glProgram:n,resources:{uTexture:Gs.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const e=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=e.colorTexture,t.target=this._getBackBufferTexture(e.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:Mc,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new Gs({source:new Ds({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)}};Tc.extension={type:[qi.WebGLSystem],name:"backBuffer",priority:1},Tc.defaultOptions={useBackBuffer:!1};let Pc=Tc;class Ec{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(8&t),!!(4&t),!!(2&t),!!(1&t)))}}Ec.extension={type:[qi.WebGLSystem],name:"colorMask"};class Bc{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:s,state:n,skipSync:r,topology:o,size:a,start:h,instanceCount:l}=t;e.shader.bind(s,r),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(o,a,h,l??i.instanceCount)}destroy(){this._renderer=null}}Bc.extension={type:[qi.WebGLSystem],name:"encoder"};class Rc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=bt(this.maxTextures,t);const e=2===this._renderer.context.webGLVersion;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}Rc.extension={type:[qi.WebGLSystem],name:"limits"};class kc{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const Oc=[];Oc[ra.NONE]=void 0,Oc[ra.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Oc[ra.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Oc[ra.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Oc[ra.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Oc[ra.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Dc{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:ra.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.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ra.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=ra.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=Oc[t],r=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t!==ra.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),t===r.stencilMode&&r.stencilReference===e||(r.stencilMode=t,r.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST))}}Dc.extension={type:[qi.WebGLSystem],name:"stencil"};class Fc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!D())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 ma({data:new Float32Array(e.layout.size/4),usage:fa.UNIFORM|fa.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 s=Object.keys(t.uniformStructures).map(e=>t.uniformStructures[e]),n=this._adaptor.createUboElements(s),r=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:r}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const s=this.getUniformGroupData(t);t.buffer||(t.buffer=new ma({data:new Float32Array(s.layout.size/4),usage:fa.UNIFORM|fa.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),i||(i=0),s.syncFunction(t.uniforms,e,n,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 Lc={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64},jc=[{type:"mat3x3<f32>",test:t=>void 0!==t.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:t=>"vec2<f32>"===t.type&&1===t.size&&void 0!==t.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:t=>"vec3<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}],Gc={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":Be(3,2),"mat4x2<f32>":Be(4,2),"mat2x3<f32>":Be(2,3),"mat4x3<f32>":Be(4,3),"mat2x4<f32>":Be(2,4),"mat3x4<f32>":Be(3,4)},Uc={...Gc,"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "};class zc extends Fc{constructor(){super({createUboElements:Pe,generateUboSync:ke})}}zc.extension={type:[qi.WebGLSystem],name:"ubo"};class Nc{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Ss}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Ss}copyToTexture(t,e,i,s,n){const r=this._renderTargetSystem,o=this._renderer,a=r.getGpuRenderTarget(t),h=o.gl;return this.finishRenderPass(t),h.bindFramebuffer(h.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),h.copyTexSubImage2D(h.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem,r=t.colorTexture,o=n.getGpuRenderTarget(t);let a=s.y;t.isRoot&&(a=r.pixelHeight-s.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,o.framebuffer);const l=this._viewPortCache;l.x===s.x&&l.y===a&&l.width===s.width&&l.height===s.height||(l.x=s.x,l.y=a,l.width=s.width,l.height=s.height,h.viewport(s.x,a,s.width,s.height)),o.depthStencilRenderBuffer||!t.stencil&&!t.depth||this._initStencil(o),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new kc;return t.colorTexture instanceof sr?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null),i)}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(t=>{e.deleteRenderbuffer(t)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const s=this._renderTargetSystem;"boolean"==typeof e&&(e=e?wo.ALL:wo.NONE);const n=this._renderer.gl;if(e&wo.COLOR){i??(i=s.defaultClearColor);const t=this._clearColorCache,e=i;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],n.clearColor(e[0],e[1],e[2],e[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();if(e.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,n)=>{const r=t.source;r.antialias&&(i.context.supports.msaa?e.msaa=!0:o()),i.texture.bindSource(r,0);const a=i.texture.getGlSource(r).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+n,3553,a,0)}),e.msaa){const i=s.createFramebuffer();e.framebuffer=i,s.bindFramebuffer(s.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const n=s.createRenderbuffer();e.msaaRenderBuffer[i]=n})}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((t,e)=>{0!==e&&t.source.resize(i.width,i.height,i._resolution)}),e.msaa){const i=this._renderer,s=i.gl,n=e.framebuffer;s.bindFramebuffer(s.FRAMEBUFFER,n),t.colorTextures.forEach((t,n)=>{const r=t.source;i.texture.bindSource(r,0);const o=i.texture.getGlSource(r).internalFormat,a=e.msaaRenderBuffer[n];s.bindRenderbuffer(s.RENDERBUFFER,a),s.renderbufferStorageMultisample(s.RENDERBUFFER,4,o,r.pixelWidth,r.pixelHeight),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+n,s.RENDERBUFFER,a)})}}_initStencil(t){if(null===t.framebuffer)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,2===this._renderer.context.webGLVersion?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&sr.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&sr.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}const Vc=new Map;bn.register(Vc);const Hc=class t{constructor(i={}){if(this.uid=e("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,i={...t.defaultOptions,...i},this.stencil=i.stencil,this.depth=i.depth,this.isRoot=i.isRoot,"number"==typeof i.colorTextures){this._managedColorTextures=!0;for(let t=0;t<i.colorTextures;t++)this.colorTextures.push(new Ds({width:i.width,height:i.height,resolution:i.resolution,antialias:i.antialias}))}else{this.colorTextures=[...i.colorTextures.map(t=>t.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(i.depthStencilTexture||this.stencil)&&(i.depthStencilTexture instanceof Gs||i.depthStencilTexture instanceof Ds?this.depthStencilTexture=i.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 Ds({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,r)=>{s&&0===r||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)}};Hc.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Wc=Hc;class Jc{constructor(t){this.rootViewPort=new Ss,this.viewport=new Ss,this.onRenderTargetChange=new Ao("onRenderTargetChange"),this.projectionMatrix=new ps,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=function(t){const e=t.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(t,e=!0,i,s){const n=this.getRenderTarget(t),r=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 a=n.colorTexture,h=this.viewport,l=a.pixelWidth,c=a.pixelHeight;if(!s&&t instanceof Gs&&(s=t.frame),s){const t=a._resolution;h.x=s.x*t+.5|0,h.y=s.y*t+.5|0,h.width=s.width*t+.5|0,h.height=s.height*t+.5|0}else h.x=0,h.y=0,h.width=l,h.height=c;return function(t,e,i,s,n,r){const o=r?1:-1;t.identity(),t.a=1/s*2,t.d=o*(1/n*2),t.tx=-1-0*t.a,t.ty=-o-0*t.d}(this.projectionMatrix,0,0,h.width/a.resolution,h.height/a.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,h),r&&this.onRenderTargetChange.emit(n),n}clear(t,e=wo.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=wo.ALL,i,s){const n=this.bind(t,e,i,s);return this._renderTargetStack.push({renderTarget:n,frame:s}),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,s,n){i.x<0&&(s.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(s.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:r,pixelHeight:o}=t;return s.width=Math.min(s.width,r-i.x),s.height=Math.min(s.height,o-i.y),this.adaptor.copyToTexture(t,e,i,s,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 sr.test(t)&&(t=Oe(t).source),t instanceof Wc?e=t:t instanceof Ds&&(e=new Wc({colorTextures:[t]}),t.source instanceof sr&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);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))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Zc extends Jc{constructor(t){super(t),this.adaptor=new Nc,this.adaptor.init(t,this)}}Zc.extension={type:[qi.WebGLSystem],name:"renderTarget"};class Xc extends as{constructor({buffer:t,offset:i,size:s}){super(),this.uid=e("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=e("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|i,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=e("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}class Yc{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}}let Kc=null;const Qc={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"},qc={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"},$c={textureCount:0,blockIndex:0};class td{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;$c.textureCount=0,$c.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,$c)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,$c)}bindUniformBlock(t,e,i=0){const s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),r=t._bufferResource;r||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=s.updateBuffer(o),h=s.freeLocationForBufferBase(a);if(r){const{offset:e,size:i}=t;0===e&&i===o.data.byteLength?s.bindBufferBase(a,h):s.bindBufferRange(a,h,e)}else s.getLastBindBaseLocation(a)!==h&&s.bindBufferBase(a,h);const l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==h&&(n.uniformBlockBindings[i]=h,this._renderer.gl.uniformBlockBinding(n.program,l,h))}_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]=function(t,e){const i=De(t,t.VERTEX_SHADER,e.vertex),s=De(t,t.FRAGMENT_SHADER,e.fragment),n=t.createProgram();t.attachShader(n,i),t.attachShader(n,s);const r=e.transformFeedbackVaryings;r&&("function"!=typeof t.transformFeedbackVaryings?o():t.transformFeedbackVaryings(n,r.names,"separate"===r.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||function(t,e,i,s){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||Ue(t,i),t.getShaderParameter(s,t.COMPILE_STATUS)||Ue(t,s),t.getProgramInfoLog(e))}(t,n,i,s),e._attributeData=function(t,e,i=!1){const s={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const n=e.getActiveAttrib(t,i);if(n.name.startsWith("gl_"))continue;const r=Ge(e,n.type);s[n.name]={location:0,format:r,stride:R(r).stride,offset:0,instance:!1,start:0}}const r=Object.keys(s);if(i){r.sort((t,e)=>t>e?1:-1);for(let i=0;i<r.length;i++)s[r[i]].location=i,e.bindAttribLocation(t,i,r[i]);e.linkProgram(t)}else for(let i=0;i<r.length;i++)s[r[i]].location=e.getAttribLocation(t,r[i]);return s}(n,t,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=function(t,e){const i={},s=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<s;n++){const s=e.getActiveUniform(t,n),r=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),a=je(e,s.type);i[r]={name:r,index:n,type:a,size:s.size,isArray:o,value:Le(a,s.size)}}return i}(n,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const i={},s=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let n=0;n<s;n++){const s=e.getActiveUniformBlockName(t,n),r=e.getUniformBlockIndex(t,s),o=e.getActiveUniformBlockParameter(t,n,e.UNIFORM_BLOCK_DATA_SIZE);i[s]={name:s,index:r,size:o}}return i}(n,t),t.deleteShader(i),t.deleteShader(s);const a={};for(const i in e._uniformData){const s=e._uniformData[i];a[i]={location:t.getUniformLocation(n,i),value:Le(s.type,s.size)}}return new Yc(n,a)}(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._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return function(t,e){const i=[],s=["\n var g = s.groups;\n var sS = r.shader;\n var p = s.glProgram;\n var ugS = r.uniformGroup;\n var resources;\n "];let n=!1,r=0;const o=e._getProgramData(t.glProgram);for(const a in t.groups){const h=t.groups[a];i.push(`\n resources = g[${a}].resources;\n `);for(const l in h.resources){const c=h.resources[l];if(c instanceof lo)if(c.ubo){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else i.push(`\n ugS.updateUniformGroup(resources[${l}], p, sD);\n `);else if(c instanceof Xc){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof Ds){const h=t._uniformBindMap[a][l],c=o.uniformData[h];c&&(n||(n=!0,s.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,r),i.push(`\n tS.bind(resources[${l}], ${r});\n `),r++)}}}const a=[...s,...i].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}td.extension={type:[qi.WebGLSystem],name:"shader"};const ed={f32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1f(location, v);\n }","vec2<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1]);\n }","vec3<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3f(location, v[0], v[1], v[2]);\n }","vec4<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",i32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",u32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1ui(location, v);\n }","vec2<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2ui(location, v[0], v[1]);\n }","vec3<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }","vec4<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},id={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);"};class sd{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const s=this._renderer.shader._getProgramData(e);t.isStatic&&t._dirtyId===s.uniformDirtyGroups[t.uid]||(s.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(s.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){return this._uniformGroupSyncHash[t._signature]?.[e._key]||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),s=this._getSignature(t,e._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[s],i[e._key]}_generateUniformsSync(t,e){return function(t,e){const i=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n var name = null;\n "];for(const s in t.uniforms){if(!e[s]){t.uniforms[s]instanceof lo?t.uniforms[s].ubo?i.push(`\n renderer.shader.bindUniformBlock(uv.${s}, "${s}");\n `):i.push(`\n renderer.shader.updateUniformGroup(uv.${s});\n `):t.uniforms[s]instanceof Xc&&i.push(`\n renderer.shader.bindBufferResource(uv.${s}, "${s}");\n `);continue}const n=t.uniformStructures[s];let r=!1;for(let t=0;t<jc.length;t++){const e=jc[t];if(n.type===e.type&&e.test(n)){i.push(`name = "${s}";`,jc[t].uniform),r=!0;break}}if(!r){const t=(1===n.size?ed:id)[n.type].replace("location",`ud["${s}"].location`);i.push(`\n cu = ud["${s}"];\n cv = cu.value;\n v = uv["${s}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",i.join("\n"))}(t,e)}_getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const t in s)n.push(t),e[t]&&n.push(e[t].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}sd.extension={type:[qi.WebGLSystem],name:"uniformGroup"};const nd=class t{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=mo.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=function(t){const e={};if(e.normal=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e.add=[t.ONE,t.ONE],e.multiply=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.screen=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e["screen-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.erase=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],t instanceof ir.get().getWebGLRenderingContext()){const i=t.getExtension("EXT_blend_minmax");i&&(e.min=[t.ONE,t.ONE,t.ONE,t.ONE,i.MIN_EXT,i.MIN_EXT],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,i.MAX_EXT,i.MAX_EXT])}else e.min=[t.ONE,t.ONE,t.ONE,t.ONE,t.MIN,t.MIN],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,t.MAX,t.MAX];return e}(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),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(e){this._updateCheck(t._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(t._checkPolygonOffset,e),this.gl[e?"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._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"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;2===e.length?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(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)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),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&&-1===i?this.checks.push(t):e||-1===i||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}};nd.extension={type:[qi.WebGLSystem],name:"state"};let rd=nd;class od{constructor(t){this.target=wc.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=Ac.UNSIGNED_BYTE,this.internalFormat=_c.RGBA,this.format=_c.RGBA,this.samplerType=0}}const ad={id:"buffer",upload(t,e,i){e.width===t.width||e.height===t.height?i.texSubImage2D(i.TEXTURE_2D,0,0,0,t.width,t.height,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,t.width,t.height,0,e.format,e.type,t.resource),e.width=t.width,e.height=t.height}},hd={"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},ld={id:"compressed",upload(t,e,i){i.pixelStorei(i.UNPACK_ALIGNMENT,4);let s=t.pixelWidth,n=t.pixelHeight;const r=!!hd[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];r?i.compressedTexImage2D(i.TEXTURE_2D,o,e.internalFormat,s,n,0,a):i.texImage2D(i.TEXTURE_2D,o,e.internalFormat,s,n,0,e.format,e.type,a),s=Math.max(s>>1,1),n=Math.max(n>>1,1)}}},cd={id:"image",upload(t,e,i,s){const n=e.width,r=e.height,o=t.pixelWidth,a=t.pixelHeight,h=t.resourceWidth,l=t.resourceHeight;h<o||l<a?(n===o&&r===a||i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,null),2===s?i.texSubImage2D(i.TEXTURE_2D,0,0,0,h,l,e.format,e.type,t.resource):i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):n===o&&r===a?i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource):2===s?i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,e.format,e.type,t.resource),e.width=o,e.height=a}},dd={id:"video",upload(t,e,i,s){t.isValid?cd.upload(t,e,i,s):i.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},ud={linear:9729,nearest:9728},pd={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},gd={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},fd={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};class md{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:cd,buffer:ad,video:dd,compressed:ld},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=function(t,e){let i={},s=t.RGBA;return t instanceof ir.get().getWebGLRenderingContext()?e.srgb&&(i={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(i={"rgba8unorm-srgb":t.SRGB8_ALPHA8,"bgra8unorm-srgb":t.SRGB8_ALPHA8},s=t.RGBA8),{r8unorm:t.R8,r8snorm:t.R8_SNORM,r8uint:t.R8UI,r8sint:t.R8I,r16uint:t.R16UI,r16sint:t.R16I,r16float:t.R16F,rg8unorm:t.RG8,rg8snorm:t.RG8_SNORM,rg8uint:t.RG8UI,rg8sint:t.RG8I,r32uint:t.R32UI,r32sint:t.R32I,r32float:t.R32F,rg16uint:t.RG16UI,rg16sint:t.RG16I,rg16float:t.RG16F,rgba8unorm:t.RGBA,...i,rgba8snorm:t.RGBA8_SNORM,rgba8uint:t.RGBA8UI,rgba8sint:t.RGBA8I,bgra8unorm:s,rgb9e5ufloat:t.RGB9_E5,rgb10a2unorm:t.RGB10_A2,rg11b10ufloat:t.R11F_G11F_B10F,rg32uint:t.RG32UI,rg32sint:t.RG32I,rg32float:t.RG32F,rgba16uint:t.RGBA16UI,rgba16sint:t.RGBA16I,rgba16float:t.RGBA16F,rgba32uint:t.RGBA32UI,rgba32sint:t.RGBA32I,rgba32float:t.RGBA32F,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT16,depth24plus:t.DEPTH_COMPONENT24,"depth24plus-stencil8":t.DEPTH24_STENCIL8,depth32float:t.DEPTH_COMPONENT32F,"depth32float-stencil8":t.DEPTH32F_STENCIL8,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}(t,this._renderer.context.extensions),this._mapFormatToType=function(t){return{r8unorm:t.UNSIGNED_BYTE,r8snorm:t.BYTE,r8uint:t.UNSIGNED_BYTE,r8sint:t.BYTE,r16uint:t.UNSIGNED_SHORT,r16sint:t.SHORT,r16float:t.HALF_FLOAT,rg8unorm:t.UNSIGNED_BYTE,rg8snorm:t.BYTE,rg8uint:t.UNSIGNED_BYTE,rg8sint:t.BYTE,r32uint:t.UNSIGNED_INT,r32sint:t.INT,r32float:t.FLOAT,rg16uint:t.UNSIGNED_SHORT,rg16sint:t.SHORT,rg16float:t.HALF_FLOAT,rgba8unorm:t.UNSIGNED_BYTE,"rgba8unorm-srgb":t.UNSIGNED_BYTE,rgba8snorm:t.BYTE,rgba8uint:t.UNSIGNED_BYTE,rgba8sint:t.BYTE,bgra8unorm:t.UNSIGNED_BYTE,"bgra8unorm-srgb":t.UNSIGNED_BYTE,rgb9e5ufloat:t.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:t.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:t.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:t.UNSIGNED_INT,rg32sint:t.INT,rg32float:t.FLOAT,rgba16uint:t.UNSIGNED_SHORT,rgba16sint:t.SHORT,rgba16float:t.HALF_FLOAT,rgba32uint:t.UNSIGNED_INT,rgba32sint:t.INT,rgba32float:t.FLOAT,stencil8:t.UNSIGNED_BYTE,depth16unorm:t.UNSIGNED_SHORT,depth24plus:t.UNSIGNED_INT,"depth24plus-stencil8":t.UNSIGNED_INT_24_8,depth32float:t.FLOAT,"depth32float-stencil8":t.FLOAT_32_UNSIGNED_INT_24_8_REV}}(t),this._mapFormatToFormat=function(t){return{r8unorm:t.RED,r8snorm:t.RED,r8uint:t.RED,r8sint:t.RED,r16uint:t.RED,r16sint:t.RED,r16float:t.RED,rg8unorm:t.RG,rg8snorm:t.RG,rg8uint:t.RG,rg8sint:t.RG,r32uint:t.RED,r32sint:t.RED,r32float:t.RED,rg16uint:t.RG,rg16sint:t.RG,rg16float:t.RG,rgba8unorm:t.RGBA,"rgba8unorm-srgb":t.RGBA,rgba8snorm:t.RGBA,rgba8uint:t.RGBA,rgba8sint:t.RGBA,bgra8unorm:t.RGBA,"bgra8unorm-srgb":t.RGBA,rgb9e5ufloat:t.RGB,rgb10a2unorm:t.RGBA,rg11b10ufloat:t.RGB,rg32uint:t.RG,rg32sint:t.RG,rg32float:t.RG,rgba16uint:t.RGBA,rgba16sint:t.RGBA,rgba16float:t.RGBA,rgba32uint:t.RGBA,rgba32sint:t.RGBA,rgba32float:t.RGBA,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT,depth24plus:t.DEPTH_COMPONENT,"depth24plus-stencil8":t.DEPTH_STENCIL,depth32float:t.DEPTH_COMPONENT,"depth32float-stencil8":t.DEPTH_STENCIL}}(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(Gs.EMPTY,t)}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=Gs.EMPTY.source);const s=this.getGlSource(t);i.bindTexture(s.target,s.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t)return this._boundSamplers[e]=null,void i.bindSampler(e,null);const s=this._getGlSampler(t);this._boundSamplers[e]!==s&&(this._boundSamplers[e]=s,i.bindSampler(e,s))}unbind(t){const e=t.source,i=this._boundTextures,s=this._gl;for(let t=0;t<i.length;t++)if(i[t]===e){this._activateLocation(t);const n=this.getGlSource(e);s.bindTexture(n.target,null),i[t]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new od(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 e=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(e))+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,s=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,ze(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;const s="premultiply-alpha-on-upload"===t.alphaMode;this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),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,ze(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:s}=this.getPixels(t),n=ir.get().createCanvas();n.width=i,n.height=s;const r=n.getContext("2d");if(r){const t=r.createImageData(i,s);t.data.set(e),r.putImageData(t,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,s=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),r=new Uint8Array(4*s*n),o=this._renderer,a=o.renderTarget.getRenderTarget(t),h=o.renderTarget.getGpuRenderTarget(a),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,h.resolveTargetFramebuffer),l.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,l.RGBA,l.UNSIGNED_BYTE,r),{pixels:new Uint8ClampedArray(r.buffer),width:s,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._glTextures=null,this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(Gs.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}md.extension={type:[qi.WebGLSystem],name:"texture"};class yd{contextChange(t){const e=new lo({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,s=kt({name:"graphics",bits:[Ta,jt(i),hc,Ra]});this.shader=new po({glProgram:s,resources:{localUniforms:e,batchSamplers:Gt(i)}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,r=n.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(o.geometry,s.glProgram);const h=a.instructions;for(let t=0;t<a.instructionSize;t++){const e=h[t];if(e.size){for(let t=0;t<e.textures.count;t++)n.texture.bind(e.textures.textures[t],t);n.geometry.draw(e.topology,e.size,e.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}yd.extension={type:[qi.WebGLPipesAdaptor],name:"graphics"};class xd{init(){const t=kt({name:"mesh",bits:[hc,cc,Ra]});this._shader=new po({glProgram:t,resources:{uTexture:Gs.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new ps}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return void o(e.shader)}else{s=this._shader;const t=e.texture,i=t.source;s.resources.uTexture=i,s.resources.uSampler=i.style,s.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}s.groups[100]=i.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}xd.extension={type:[qi.WebGLPipesAdaptor],name:"mesh"};class bd{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}bd.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"customRender"};class vd{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){}}const _d=new ps;class wd{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(_n.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){const i=t._batchableRenderGroup??(t._batchableRenderGroup=_n.get(vd));i.renderable=t.root,i.transform=t.root.relativeGroupTransform,i.texture=t.texture,i.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(i,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=_d.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),Ne(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),Ne(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}wd.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"renderGroup"};const Ad=new Xn,Cd=new ps;class Sd{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,s=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,r=Cd;e&&(r.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Ne(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(r),t.parent=i,t.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let i=t.renderGroupChildren.length-1;i>=0;i--)this._updateCachedRenderGroups(t.renderGroupChildren[i],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const i=t.texture;t.texture&&Nn.returnTexture(t.texture,!0);const s=this._renderer,n=t.textureOptions.resolution||s.view.resolution,r=t.textureOptions.antialias??s.view.antialias,o=t.textureOptions.scaleMode??"linear",a=Nn.getOptimalTexture(e.width,e.height,n,r);a._source.style=new ks({scaleMode:o}),t.texture=a,t._textureBounds||(t._textureBounds=new zs),t._textureBounds.copyFrom(e),i!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(Nn.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?Ve(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:i}=t.childrenRenderablesToUpdate;let s=!1;for(let n=0;n<t.childrenRenderablesToUpdate.index;n++){const t=i[n];if(s=e[t.renderPipeId].validateRenderable(t),s)break}t.structureDidChange=s}(t,i),He(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!t.isCachedAsTexture||t.textureNeedsUpdate)for(let e=0;e<t.renderGroupChildren.length;e++)this._updateRenderGroups(t.renderGroupChildren[e])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let s=0;s<i;s++){const i=e[s];i.didViewUpdate&&t.updateRenderable(i)}Ve(e,i)}_buildInstructions(t,e){const i=t.root,s=t.instructionSet;s.reset();const n=e.renderPipes?e:e.batch.renderer,r=n.renderPipes;r.batch.buildStart(s),r.blendMode.buildStart(),r.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(s,n,null),r.batch.buildEnd(s),r.blendMode.buildEnd(s)}}Sd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"renderGroup"};class Id{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new vd;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Id.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"sprite"};const Md=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new yn(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...t.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){yn.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&o(),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Md.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"background",priority:0},Md.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Td=Md;const Pd={};es.handle(qi.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");Pd[t.name]=t.ref},t=>{delete Pd[t.name]});class Ed{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,i){this._blendModeStack.push(e),this.setBlendMode(t,e,i)}popBlendMode(t){this._blendModeStack.pop();const e=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,e,t)}setBlendMode(t,e,i){const s=t instanceof Vn;this._activeBlendMode!==e?(this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!Pd[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))):this._isAdvanced&&t&&!s&&this._renderableList?.push(t)}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!Pd[i])return void o();const s=this._ensureFilterEffect(i),n=t instanceof Vn,r={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=r.renderables,e.add(r)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new Sn,e.filters=[new Pd[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,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}}Ed.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"blendMode"};const Bd={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Rd=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Xn||t instanceof Gs?{target:t,...e}:{...e,...t}}async image(t){const e=ir.get().createImage();return e.src=await this.base64(t),e}async base64(e){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:i,quality:s}=e,n=this.canvas(e);if(void 0!==n.toBlob)return new Promise((t,e)=>{n.toBlob(i=>{if(!i)return void e(new Error("ICanvas.toBlob failed!"));const s=new FileReader;s.onload=()=>t(s.result),s.onerror=e,s.readAsDataURL(i)},Bd[i],s)});if(void 0!==n.toDataURL)return n.toDataURL(Bd[i],s);if(void 0!==n.convertToBlob){const t=await n.convertToBlob({type:Bd[i],quality:s});return new Promise((e,i)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=i,s.readAsDataURL(t)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer;if(e instanceof Gs)return i.texture.generateCanvas(e);const s=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(s);return s.destroy(!0),n}pixels(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer,s=e instanceof Gs?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(s);return e instanceof Xn&&s.destroy(!0),n}texture(t){return(t=this._normalizeOptions(t)).target instanceof Gs?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),["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${this.canvas(t).toDataURL()}) no-repeat;`,"background-size: contain;"].join(" ")}destroy(){this._renderer=null}};Rd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"extract"},Rd.defaultImageOptions={format:"png",quality:1};let kd=Rd;class Od extends Gs{static create(t){return new Od({source:new Ds(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Dd=new Ss,Fd=new zs,Ld=[0,0,0,0];class jd{constructor(t){this._renderer=t}generateTexture(t){t instanceof Xn&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,s=t.target;let n=t.clearColor;n=n?Array.isArray(n)&&4===n.length?n:yn.shared.setValue(n).toArray():Ld;const r=t.frame?.copyTo(Dd)||g(s,Fd).rectangle;r.width=0|Math.max(r.width,1/e),r.height=0|Math.max(r.height,1/e);const o=Od.create({...t.textureSourceOptions,width:r.width,height:r.height,resolution:e,antialias:i}),a=ps.shared.translate(-r.x,-r.y);return this._renderer.render({container:s,transform:a,target:o,clearColor:n}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}jd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"textureGenerator"};class Gd{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:s,offset:n}){const r=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new ps,worldColor:4294967295,offset:new ds},a={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||r.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:s||o.worldColor,offset:n||o.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const l=h.uniforms;let c;l.uProjectionMatrix=a.projectionMatrix,l.uResolution=a.resolution,l.uWorldTransformMatrix.copyFrom(a.worldTransformMatrix),l.uWorldTransformMatrix.tx-=a.offset.x,l.uWorldTransformMatrix.ty-=a.offset.y,Ze(a.worldColor,l.uWorldColorAlpha,0),h.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(c=this._bindGroupPool.pop()||new co,this._activeBindGroups.push(c),c.setResource(h,0)),a.bindGroup=c,this._currentGlobalUniformData=a}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===uo.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new lo({uProjectionMatrix:{value:new ps,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Gd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"globalUniforms"};let Ud=1;class zd{constructor(){this._tasks=[],this._offset=0}init(){lr.system.add(this._update,this)}repeat(t,e,i=!0){const s=Ud++;let n=0;return i&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t)return void this._tasks.splice(e,1)}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const e=t-i.start;i.func(e),i.last=t}}}destroy(){lr.system.remove(this._update,this),this._tasks.length=0}}zd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"scheduler",priority:0};let Nd=!1;class Vd{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===uo.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!Nd){if(ir.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Eo} (${t}) http://www.pixijs.com/\n\n`,"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(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Eo} - ${t} - http://www.pixijs.com/`);Nd=!0}}(t)}}}Vd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"hello",priority:-2},Vd.defaultOptions={hello:!1};let Hd=0;const Wd=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e={...t.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime,this._frequency=e.renderableGCFrequency,this.enabled=e.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedHashes)t.context[t.hash]=Xe(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Ye(t.context[t.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=Hd++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(-1===t._lastUsed&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){const t=this._now,e=this._managedRenderables,i=this._renderer.renderPipes;let s=0;for(let n=0;n<e.length;n++){const r=e[n];if(null===r){s++;continue}const o=r.renderGroup??r.parentRenderGroup,a=o?.instructionSet?.gcTick??-1;if((o?.gcTick??0)===a&&(r._lastUsed=t),t-r._lastUsed>this.maxUnusedTime){if(!r.destroyed){const t=i;o&&(o.structureDidChange=!0),t[r.renderPipeId].destroyRenderable(r)}r._lastUsed=-1,s++,r.off("destroyed",this._removeRenderable,this)}else e[n-s]=r}e.length-=s}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}};Wd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"renderableGC",priority:0},Wd.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Jd=Wd;const Zd=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){e={...t.defaultOptions,...e},this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=e.textureGCAMaxIdle??e.textureGCMaxIdle,this.active=e.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}};Zd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"textureGC"},Zd.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Xd=Zd;const Yd=class t{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(e){(e={...t.defaultOptions,...e}).view&&(Ps(0,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new Ss(0,0,e.width,e.height),this.canvas=e.canvas||ir.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Oe(this.canvas,e),this.renderTarget=new Wc({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.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}destroy(t=!1){("boolean"==typeof t?t:!!t?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};Yd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"view",priority:0},Yd.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Kd=[Td,Gd,Vd,Yd,Sd,Xd,jd,kd,Ro,Jd,zd],Qd=[Ed,rc,Id,wd,pc,fc,gc,bd],qd=[...Kd,zc,Pc,vc,Rc,xc,md,Zc,Ic,sd,td,Bc,rd,Dc,Ec],$d=[...Qd],tu=[ec,xd,yd],eu=[],iu=[],su=[];es.handleByNamedList(qi.WebGLSystem,eu),es.handleByNamedList(qi.WebGLPipes,iu),es.handleByNamedList(qi.WebGLPipesAdaptor,su),es.add(...qd,...$d,...tu);const nu=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:class extends To{constructor(){super({name:"webgl",type:uo.WEBGL,systems:eu,renderPipes:iu,renderPipeAdaptors:su})}}},Symbol.toStringTag,{value:"Module"}));class ru{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}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 s=this._gpu.device,n=e.layout[i],r=[],o=this._renderer;for(const e in n){const i=t.resources[e]??t.resources[n[e]];let s;if("uniformGroup"===i._resourceType){const t=i;o.ubo.updateUniformGroup(t);const e=t.buffer;s={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if("buffer"===i._resourceType){const t=i;s={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===i._resourceType){const t=i;s={buffer:o.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===i._resourceType){const t=i;s=o.texture.getGpuSampler(t)}else if("textureSource"===i._resourceType){const t=i;s=o.texture.getGpuSource(t).createView({})}r.push({binding:n[e],resource:s})}const a=o.shader.getProgramData(e).bindGroups[i],h=s.createBindGroup({layout:a,entries:r});return this._hash[t._key]=h,h}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}ru.extension={type:[qi.WebGPUSystem],name:"bindGroup"};class ou{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}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),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(mt(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,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}}ou.extension={type:[qi.WebGPUSystem],name:"buffer"};class au{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: "+4*t);const e=this.byteIndex;let i=e+4*t;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>4*this.data.length)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.data=null}}class hu{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}}hu.extension={type:[qi.WebGPUSystem],name:"colorMask"};class lu{constructor(t){this._renderer=t}async init(t){return this._initPromise||(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)})),this._initPromise}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await ir.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(t=>e.features.has(t)),s=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}lu.extension={type:[qi.WebGPUSystem],name:"device"},lu.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class cu{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,s){const n=this._renderer.pipeline.getPipeline(t,e,i,s);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=2===t.data.BYTES_PER_ELEMENT?"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 s=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const e in i)this._setVertexBuffer(parseInt(e,10),t.attributes[i[e]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,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:s,topology:n,size:r,start:o,instanceCount:a,skipSync:h}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,s,n),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,h),e.indexBuffer?this.renderPassEncoder.drawIndexed(r||e.indexBuffer.data.length,a??e.instanceCount,o||0):this.renderPassEncoder.draw(r||e.getSize(),a??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},s=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();const r=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(r.x,r.y,r.width,r.height,0,1),this.setPipeline(e);for(const t in i)this._setVertexBuffer(t,i[t]);for(const t in n)this.setBindGroup(t,n[t],null);this._setIndexBuffer(s)}_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}}cu.extension={type:[qi.WebGPUSystem],name:"encoder",priority:1};class du{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}du.extension={type:[qi.WebGPUSystem],name:"limits"};class uu{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:ra.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 s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}uu.extension={type:[qi.WebGPUSystem],name:"stencil"};const pu={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}};class gu extends Fc{constructor(){super({createUboElements:Ke,generateUboSync:qe})}}gu.extension={type:[qi.WebGPUSystem],name:"ubo"};const fu=128;class mu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new au({minUniformOffsetAlignment:fu});for(let t=0;t<2;t++){let e=fa.UNIFORM|fa.COPY_DST;0===t&&(e|=fa.COPY_SRC),this._buffers.push(new ma({data:this._batchBuffer.data,usage:e}))}}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,s=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,s/4),this._bindGroupHash[t.uid]=this._getBindGroup(s/fu),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/fu)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/fu)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/fu;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Xc({buffer:e,offset:256*(t/2|0),size:fu})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new co({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 s=1;s<this._buffers.length;s++){const n=this._buffers[s];i.copyBufferToBuffer(t.getGPUBuffer(e),fu,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}}mu.extension={type:[qi.WebGPUPipes],name:"uniformBatch"};const yu={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class xu{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=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(ra.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=Oc[t],this._updatePipeHash())}setPipeline(t,e,i,s){const n=this.getPipeline(t,e,i);s.setPipeline(n)}getPipeline(t,e,i,s){t._layoutKey||(Me(t,e.attributeData),this._generateBufferKey(t)),s||(s=t.topology);const n=function(t,e,i,s,n){return t<<24|e<<16|i<<10|s<<5|n}(t._layoutKey,e._layoutKey,i.data,i._blendModeId,yu[s]);return this._pipeCache[n]||(this._pipeCache[n]=this._createPipeline(t,e,i,s)),this._pipeCache[n]}_createPipeline(t,e,i,s){const n=this._gpu.device,r=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===ra.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,h={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:r},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:s,cullMode:i.cullMode},layout:a,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(h.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}),n.createRenderPipeline(h)}_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 s=Object.keys(t.attributes).sort();for(let n=0;n<s.length;n++){const r=t.attributes[s[n]];e[i++]=r.offset,e[i++]=r.format,e[i++]=r.stride,e[i++]=r.instance}const n=e.join("|");return t._layoutKey=P(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const s=Object.keys(t.attributeData).sort();for(let n=0;n<s.length;n++){const r=t.attributeData[s[n]];e[i++]=r.location}const n=e.join("|");return t._attributeLocationsKey=P(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const s=this._createVertexBufferLayouts(t,e),n=Object.create(null),r=e.attributeData;for(let t=0;t<s.length;t++){const e=Object.values(s[t].attributes)[0].shaderLocation;for(const i in r)if(r[i].location===e){n[t]=i;break}}return this._bindingNamesCache[i]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const s=[];return t.buffers.forEach(i=>{const n={arrayStride:0,stepMode:"vertex",attributes:[]},r=n.attributes;for(const s in e.attributeData){const a=t.attributes[s];1!==(a.divisor??1)&&o(a.divisor),a.buffer===i&&(n.arrayStride=a.stride,n.stepMode=a.instance?"instance":"vertex",r.push({shaderLocation:e.attributeData[s].location,offset:a.offset,format:a.format}))}r.length&&s.push(n)}),this._bufferLayoutsCache[i]=s,s}_updatePipeHash(){const t=(e=this._stencilMode,i=this._multisampleCount,this._colorMask<<6|e<<3|this._depthStencilAttachment<<1|i);var e,i;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}xu.extension={type:[qi.WebGPUSystem],name:"pipeline"};class bu{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class vu{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){const r=this._renderer,o=this._getGpuColorTexture(t),a=r.texture.getGpuSource(e.source);return r.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:a,origin:n},s),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem.getGpuRenderTarget(t),r=this.getDescriptor(t,e,i);n.descriptor=r,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}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){"boolean"==typeof e&&(e=e?wo.ALL:wo.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),r=t.colorTextures.map((t,r)=>{const o=n.contexts[r];let a,h;a=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1}),n.msaaTextures[r]&&(h=a,a=this._renderer.texture.getTextureView(n.msaaTextures[r]));const l=e&wo.COLOR?"clear":"load";return i??(i=s.defaultClearColor),{view:a,resolveTarget:h,clearValue:i,storeOp:"store",loadOp:l}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const i=e&wo.STENCIL?"clear":"load",s=e&wo.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:i,depthClearValue:1,depthLoadOp:s,depthStoreOp:"store"}}return{colorAttachments:r,depthStencilAttachment:o}}clear(t,e=!0,i,s){if(!e)return;const{gpu:n,encoder:r}=this._renderer,o=n.device;if(null===r.commandEncoder){const n=o.createCommandEncoder(),r=this.getDescriptor(t,e,i),a=n.beginRenderPass(r);a.setViewport(s.x,s.y,s.width,s.height,0,1),a.end();const h=n.finish();o.queue.submit([h])}else this.startRenderPass(t,e,i,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new bu;return t.colorTextures.forEach((t,i)=>{if(t instanceof sr){const s=t.resource.getContext("webgpu"),n=t.transparent?"premultiplied":"opaque";try{s.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:n})}catch(t){}e.contexts[i]=s}if(e.msaa=t.source.antialias,t.source.antialias){const t=new Ds({width:0,height:0,sampleCount:4});e.msaaTextures[i]=t}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(t=>{t.unconfigure()}),t.msaaTextures.forEach(t=>{t.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((t,i)=>{const s=e.msaaTextures[i];s?.resize(t.source.width,t.source.height,t.source._resolution)})}}class _u extends Jc{constructor(t){super(t),this.adaptor=new vu,this.adaptor.init(t,this)}}_u.extension={type:[qi.WebGPUSystem],name:"renderTarget"};class wu{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(t=>e.createBindGroupLayout({entries:t})),s={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}wu.extension={type:[qi.WebGPUSystem],name:"shader"};const Au={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class Cu{constructor(){this.defaultState=new mo,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Au[t.blendMode]||Au.normal}]}destroy(){this.gpu=null}}Cu.extension={type:[qi.WebGPUSystem],name:"state"};const Su={type:"image",upload(t,e,i){const s=t.resource,n=(0|t.pixelWidth)*(0|t.pixelHeight),r=s.byteLength/n;i.device.queue.writeTexture({texture:e},s,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*r},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},Iu={"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}},Mu={blockBytes:4,blockWidth:1,blockHeight:1},Tu={type:"compressed",upload(t,e,i){let s=t.pixelWidth,n=t.pixelHeight;const r=Iu[t.format]||Mu;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],h=Math.ceil(s/r.blockWidth)*r.blockBytes;i.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:h},{width:Math.ceil(s/r.blockWidth)*r.blockWidth,height:Math.ceil(n/r.blockHeight)*r.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),n=Math.max(n>>1,1)}}},Pu={type:"image",upload(t,e,i){const s=t.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){const e=ir.get().createCanvas(s.width,s.height);e.getContext("2d").drawImage(s,0,0,s.width,s.height),t.resource=e,o()}const n=Math.min(e.width,t.resourceWidth||t.pixelWidth),r=Math.min(e.height,t.resourceHeight||t.pixelHeight),a="premultiply-alpha-on-upload"===t.alphaMode;i.device.queue.copyExternalImageToTexture({source:s},{texture:e,premultipliedAlpha:a},{width:n,height:r})}},Eu={type:"video",upload(t,e,i){Pu.upload(t,e,i)}};class Bu{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:"\n var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));\n\n struct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) texCoord : vec2<f32>,\n };\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {\n var output : VertexOutput;\n output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);\n return output;\n }\n\n @group(0) @binding(0) var imgSampler : sampler;\n @group(0) @binding(1) var img : texture_2d<f32>;\n\n @fragment\n fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(img, imgSampler, texCoord);\n }\n "})),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("3d"===t.dimension||"1d"===t.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const e={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(e)}const r=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let a=0;a<s;++a){let s=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),h=n?1:0;for(let n=1;n<t.mipLevelCount;++n){const t=i.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),n=r.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:s}]});n.setPipeline(e),n.setBindGroup(0,l),n.draw(3,1,0,0),n.end(),s=t}}if(!n){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s};for(let s=1;s<t.mipLevelCount;++s)r.copyTextureToTexture({texture:i,mipLevel:s-1},{texture:t,mipLevel:s},e),e.width=Math.ceil(e.width/2),e.height=Math.ceil(e.height/2)}return this.device.queue.submit([r.finish()]),n||i.destroy(),t}}class Ru{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:Pu,buffer:Su,video:Eu,compressed:Tu},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){return this._gpuSources[t.uid]?this._gpuSources[t.uid]:this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const e=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(e))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==t.uploadMethodId&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=Iu[t.format]||{blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,r={label:t.label,size:{width:s,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(r);return 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 Bu(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;return this._bindGroupHash[t.uid]=new co({0:e,1:e.style,2:new lo({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}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(),s=ir.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const n=s.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:ir.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([i.finish()]),s}getPixels(t){const e=this.generateCanvas(t),i=xh.getOptimalCanvasAndContext(e.width,e.height),s=i.context;s.drawImage(e,0,0);const{width:n,height:r}=e,o=s.getImageData(0,0,n,r),a=new Uint8ClampedArray(o.data.buffer);return xh.returnCanvasAndContext(i),{pixels:a,width:n,height:r}}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?.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}Ru.extension={type:[qi.WebGPUSystem],name:"texture"};class ku{constructor(){this._maxTextures=0}contextChange(t){const e=new lo({uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Rt({name:"graphics",bits:[Ma,Ft(this._maxTextures),ac,Ba]});this.shader=new po({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,r=n.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i),h=n.encoder;h.setGeometry(o.geometry,s.gpuProgram);const l=n.globalUniforms.bindGroup;h.setBindGroup(0,l,s.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);h.setBindGroup(2,c,s.gpuProgram);const d=a.instructions;let u=null;for(let e=0;e<a.instructionSize;e++){const i=d[e];if(i.topology!==u&&(u=i.topology,h.setPipelineFromGeometryProgramAndState(o.geometry,s.gpuProgram,t.state,i.topology)),s.groups[1]=i.bindGroup,!i.gpuBindGroup){const t=i.textures;i.bindGroup=ft(t.textures,t.count,this._maxTextures),i.gpuBindGroup=n.bindGroup.getBindGroup(i.bindGroup,s.gpuProgram,1)}h.setBindGroup(1,i.bindGroup,s.gpuProgram),h.renderPassEncoder.drawIndexed(i.size,1,i.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}ku.extension={type:[qi.WebGPUPipesAdaptor],name:"graphics"};class Ou{init(){const t=Rt({name:"mesh",bits:[oc,lc,Ba]});this._shader=new po({gpuProgram:t,resources:{uTexture:Gs.EMPTY._source,uSampler:Gs.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new ps}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.gpuProgram)return void o(e.shader)}else s=this._shader,s.groups[2]=i.texture.getTextureBindGroup(e.texture);const n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const e=t.localUniforms;s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(e,!0)}i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Ou.extension={type:[qi.WebGPUPipesAdaptor],name:"mesh"};const Du=[...Kd,gu,cu,lu,du,ou,Ru,_u,wu,Cu,xu,hu,uu,ru],Fu=[...Qd,mu],Lu=[sc,Ou,ku],ju=[],Gu=[],Uu=[];es.handleByNamedList(qi.WebGPUSystem,ju),es.handleByNamedList(qi.WebGPUPipes,Gu),es.handleByNamedList(qi.WebGPUPipesAdaptor,Uu),es.add(...Du,...Fu,...Lu);const zu=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:class extends To{constructor(){super({name:"webgpu",type:uo.WEBGPU,systems:ju,renderPipes:Gu,renderPipeAdaptors:Uu})}}},Symbol.toStringTag,{value:"Module"}));class Nu{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{_n.return(t)}),this.batches.length=0}}class Vu{constructor(t,e){this.state=mo.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!(!s.isBatchable&&i===s.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let t=0;t<e.length;t++){const i=e[t];i._batcher.updateElement(i)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const s=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=s.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let t=0;t<s.length;t++){const n=s[t];i.addToBatch(n,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Nu;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,s=this.renderer.graphicsContext.getGpuContext(i),n=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(e=>{const i=_n.get(Ga);return e.copyTo(i),i.renderable=t,i.roundPixels=n,i})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Vu.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"graphics"};const Hu=class t extends Gl{constructor(...t){super({});let e=t[0]??{};"number"==typeof e&&(Ps(0,"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(e){e={...t.defaultOptions,...e},this.verticesX=this.verticesX??e.verticesX,this.verticesY=this.verticesY??e.verticesY,this.width=this.width??e.width,this.height=this.height??e.height;const i=this.verticesX*this.verticesY,s=[],n=[],r=[],o=this.verticesX-1,a=this.verticesY-1,h=this.width/o,l=this.height/a;for(let t=0;t<i;t++){const e=t%this.verticesX,i=t/this.verticesX|0;s.push(e*h,i*l),n.push(e/o,i/a)}const c=o*a;for(let t=0;t<c;t++){const e=t%o,i=t/o|0,s=i*this.verticesX+e,n=i*this.verticesX+e+1,a=(i+1)*this.verticesX+e,h=(i+1)*this.verticesX+e+1;r.push(s,n,a,n,h,a)}this.buffers[0].data=new Float32Array(s),this.buffers[1].data=new Float32Array(n),this.indexBuffer.data=new Uint32Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Hu.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Wu=Hu;class Ju{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const s=this.texture.textureMatrix;return s.isSimple||(i=this._transformedUvs,this._textureMatrixUpdateId===s._updateID&&this._uvUpdateId===t._updateID||((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=s._updateID,this._uvUpdateId=t._updateID,s.multiplyUvs(e,i))),i}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class Zu{destroy(){}}class Xu{constructor(t,e){this.localUniforms=new lo({uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new co({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,s=t.batched;if(e.batched=s,i!==s)return!0;if(s){const i=t._geometry;if(i.indices.length!==e.indexSize||i.positions.length!==e.vertexSize)return e.indexSize=i.indices.length,e.vertexSize=i.positions.length,!0;const s=this._getBatchableMesh(t);return s.texture.uid!==t._texture.uid&&(s._textureMatrixUpdateId=-1),!s._batcher.checkAndUpdateTexture(s,t._texture)}return!1}addRenderable(t,e){const i=this.renderer.renderPipes.batch,s=this._getMeshData(t);if(t.didViewUpdate&&(s.indexSize=t._geometry.indices?.length,s.vertexSize=t._geometry.positions?.length),s.batched){const s=this._getBatchableMesh(t);s.setTexture(t._texture),s.geometry=t._geometry,i.addToBatch(s,e)}else i.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=yt(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Ze(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Zu),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Zu),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Ju;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Xu.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"mesh"};class Yu{execute(t,e){const i=t.state,s=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const r=s.gl,o=t.getBuffers(e);s.shader.bind(n),s.state.set(i),s.geometry.bind(o.geometry,n.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?r.UNSIGNED_SHORT:r.UNSIGNED_INT;r.drawElements(r.TRIANGLES,6*e.particleChildren.length,a,0)}}class Ku{execute(t,e){const i=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=i.texture.getTextureBindGroup(e.texture);const n=t.state,r=t.getBuffers(e);i.encoder.draw({geometry:r.geometry,shader:e.shader||t.defaultShader,state:n,size:6*e.particleChildren.length})}}class Qu{constructor(t){this._size=0,this._generateParticleUpdateCache={};const e=this._size=t.size??1e3,i=t.properties;let s=0,n=0;for(const t in i){const e=i[t],r=R(e.format);e.dynamic?n+=r.stride:s+=r.stride}this._dynamicStride=n/4,this._staticStride=s/4,this.staticAttributeBuffer=new sa(4*e*s),this.dynamicAttributeBuffer=new sa(4*e*n),this.indexBuffer=$e(e);const r=new ya;let o=0,a=0;this._staticBuffer=new ma({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:fa.VERTEX|fa.COPY_DST}),this._dynamicBuffer=new ma({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:fa.VERTEX|fa.COPY_DST});for(const t in i){const e=i[t],s=R(e.format);e.dynamic?(r.addAttribute(e.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*o,format:e.format}),o+=s.size):(r.addAttribute(e.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*a,format:e.format}),a+=s.size)}r.addIndex(this.indexBuffer);const h=this.getParticleUpdate(i);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=r}getParticleUpdate(t){const e=function(t){const e=[];for(const i in t){const s=t[i];e.push(i,s.code,s.dynamic?"d":"s")}return e.join("_")}(t);return this._generateParticleUpdateCache[e]||(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t)),this._generateParticleUpdateCache[e]}generateParticleUpdate(t){return function(t){return{dynamicUpdate:ti(t,!0),staticUpdate:ti(t,!1)}}(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,1.5*this._size|0),this.staticAttributeBuffer=new sa(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new sa(this._size*this._dynamicStride*4*4),this.indexBuffer=$e(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const e=this.staticAttributeBuffer;this._staticUpload(t,e.float32View,e.uint32View),this._staticBuffer.setDataWithSize(e.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}var qu="\nstruct ParticleUniforms {\n uTranslationMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n uResolution:vec2<f32>,\n};\n\nfn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n{\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\n@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;\n\n@group(1) @binding(0) var uTexture: texture_2d<f32>;\n@group(1) @binding(1) var uSampler : sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) color : vec4<f32>,\n };\n@vertex\nfn mainVertex(\n @location(0) aVertex: vec2<f32>,\n @location(1) aPosition: vec2<f32>,\n @location(2) aUV: vec2<f32>,\n @location(3) aColor: vec4<f32>,\n @location(4) aRotation: f32,\n) -> VSOutput {\n \n let v = vec2(\n aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),\n aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)\n ) + aPosition;\n\n var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uniforms.uRound == 1.0) {\n position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);\n }\n\n let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;\n\n return VSOutput(\n position,\n aUV,\n vColor,\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) color: vec4<f32>,\n @builtin(position) position: vec4<f32>,\n) -> @location(0) vec4<f32> {\n\n var sample = textureSample(uTexture, uSampler, uv) * color;\n \n return sample;\n}";class $u extends po{constructor(){super({glProgram:to.from({vertex:"attribute vec2 aVertex;\nattribute vec2 aUV;\nattribute vec4 aColor;\n\nattribute vec2 aPosition;\nattribute float aRotation;\n\nuniform mat3 uTranslationMatrix;\nuniform float uRound;\nuniform vec2 uResolution;\nuniform vec4 uColor;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 roundPixels(vec2 position, vec2 targetSize)\n{ \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\nvoid main(void){\n float cosRotation = cos(aRotation);\n float sinRotation = sin(aRotation);\n float x = aVertex.x * cosRotation - aVertex.y * sinRotation;\n float y = aVertex.x * sinRotation + aVertex.y * cosRotation;\n\n vec2 v = vec2(x, y);\n v = v + aPosition;\n\n gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uRound == 1.0)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n\n vUV = aUV;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;\n}\n",fragment:"varying vec2 vUV;\nvarying vec4 vColor;\n\nuniform sampler2D uTexture;\n\nvoid main(void){\n vec4 color = texture2D(uTexture, vUV) * vColor;\n gl_FragColor = color;\n}"}),gpuProgram:ro.from({fragment:{source:qu,entryPoint:"mainFragment"},vertex:{source:qu,entryPoint:"mainVertex"}}),resources:{uTexture:Gs.WHITE.source,uSampler:new ks({}),uniforms:{uTranslationMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new yn(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class tp{constructor(t,e){this.state=mo.for2d(),this.localUniforms=new lo({uTranslationMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new $u,this.state=mo.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new Qu({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(0===e.length)return;const i=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=yt(t.blendMode,t.texture._source);const r=this.localUniforms.uniforms,o=r.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(i.globalUniforms.globalUniformData.projectionMatrix),r.uResolution=i.globalUniforms.globalUniformData.resolution,r.uRound=i._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,r.uColor,0),this.adaptor.execute(this,t)}destroy(){this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class ep extends tp{constructor(t){super(t,new Yu)}}ep.extension={type:[qi.WebGLPipes],name:"particle"};class ip extends tp{constructor(t){super(t,new Ku)}}ip.extension={type:[qi.WebGPUPipes],name:"particle"};const sp=class t extends Wu{constructor(e={}){super({width:(e={...t.defaultOptions,...e}).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}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._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:s,_rightWidth:n,_topHeight:r,_bottomHeight:o,_anchorX:a,_anchorY:h}=this,l=s+n,c=e>l?1:e/l,d=r+o,u=i>d?1:i/d,p=Math.min(c,u),g=a*e,f=h*i;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=s*p-g,t[4]=t[12]=t[20]=t[28]=e-n*p-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-f,t[9]=t[11]=t[13]=t[15]=r*p-f,t[17]=t[19]=t[21]=t[23]=i-o*p-f,t[25]=t[27]=t[29]=t[31]=i-f,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()}};sp.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let np=sp;class rp extends Ju{constructor(){super(),this.geometry=new np}destroy(){this.geometry.destroy()}}class op{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new rp,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._renderer=null}}op.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"nineSliceSprite"};const ap={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n }\n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},hp={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n\n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n\n "}};let lp,cp;class dp extends po{constructor(){lp??(lp=Rt({name:"tiling-sprite-shader",bits:[oc,ap,Ba]})),cp??(cp=kt({name:"tiling-sprite-shader",bits:[hc,hp,Ra]}));const t=new lo({uMapCoord:{value:new ps,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 ps,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:cp,gpuProgram:lp,resources:{localUniforms:new lo({uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:Gs.EMPTY.source,uSampler:Gs.EMPTY.source.style}})}updateUniforms(t,e,i,s,n,r){const o=this.resources.tilingUniforms,a=r.width,h=r.height,l=r.textureMatrix,c=o.uniforms.uTextureTransform;c.set(i.a*a/t,i.b*a/e,i.c*h/t,i.d*h/e,i.tx/t,i.ty/e),c.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=s,o.uniforms.uSizeAnchor[3]=n,r&&(this.resources.uTexture=r.source,this.resources.uSampler=r.source.style)}}const up=new class extends Gl{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])})}};class pp{constructor(){this.canBatch=!0,this.geometry=new Gl({indices:up.indices.slice(),positions:up.positions.slice(),uvs:up.uvs.slice()})}destroy(){this.geometry.destroy(),this.shader?.destroy()}}class gp{constructor(t){this._state=mo.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const s=e.canBatch;if(s&&s===i){const{batchableMesh:i}=e;return!i._batcher.checkAndUpdateTexture(i,t.texture)}return i!==s}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const s=this._getTilingSpriteData(t),{geometry:n,canBatch:r}=s;if(r){s.batchableMesh||(s.batchableMesh=new Ju);const r=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),r.geometry=n,r.renderable=t,r.transform=t.groupTransform,r.setTexture(t._texture)),r.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(r,e)}else i.break(e),s.shader||(s.shader=new dp),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,i.uColor,0),this._state.blendMode=yt(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:up,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:i}=e;t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)}else if(t.didViewUpdate){const{shader:i}=e;i.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new pp;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,s=t.texture.source.style;"repeat"!==s.addressMode&&(s.addressMode="repeat",s.update()),function(t,e){const i=t.texture,s=i.frame.width,n=i.frame.height;let r=0,o=0;t.applyAnchorToTexture&&(r=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-r,e[2]=e[4]=1-r,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=ps.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/s,t.height/n),function(t,e,i,s){let n=0;const r=t.length/2,o=s.a,a=s.b,h=s.c,l=s.d,c=s.tx,d=s.ty;for(i*=2;n<r;){const e=t[i],s=t[i+1];t[i]=o*e+h*s+c,t[i+1]=a*e+l*s+d,i+=2,n++}}(e,0,0,a)}(t,i.uvs),function(t,e){const i=t.anchor.x,s=t.anchor.y;e[0]=-i*t.width,e[1]=-s*t.height,e[2]=(1-i)*t.width,e[3]=-s*t.height,e[4]=(1-i)*t.width,e[5]=(1-s)*t.height,e[6]=-i*t.width,e[7]=(1-s)*t.height}(t,i.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let s=!0;return this._renderer.type===uo.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),e.canBatch}}gp.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"tilingSprite"};const fp={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},mp={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:"\n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},yp={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n\n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n\n }\n "}},xp={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n\n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n }\n "}};let bp,vp;class _p extends po{constructor(t){const e=new lo({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});bp??(bp=Rt({name:"sdf-shader",bits:[Ma,Ft(t),fp,yp,Ba]})),vp??(vp=kt({name:"sdf-shader",bits:[Ta,jt(t),mp,xp,Ra]})),super({glProgram:vp,gpuProgram:bp,resources:{localUniforms:e,batchSamplers:Gt(t)}})}}class wp extends Ll{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Ap{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);ei(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);ei(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,s=Ah.getFont(t.text,t._style);i.clear(),"none"!==s.distanceField.type&&(i.customShader||(i.customShader=new _p(this._renderer.limits.maxBatchableTextures)));const n=No.graphemeSegmenter(t.text),r=t._style;let o=s.baseLineOffset;const a=fe(n,r,s,!0),h=r.padding,l=a.scale;let c=a.width,d=a.height+a.offsetY;r._stroke&&(c+=r._stroke.width/l,d+=r._stroke.width/l),i.translate(-t._anchor._x*c-h,-t._anchor._y*d-h).scale(l,l);const u=s.applyFillAsTint?r._fill.color:16777215;let p=s.fontMetrics.fontSize,g=s.lineHeight;r.lineHeight&&(p=r.fontSize/l,g=r.lineHeight/l);let f=(g-p)/2;f-s.baseLineOffset<0&&(f=0);for(let t=0;t<a.lines.length;t++){const e=a.lines[t];for(let t=0;t<e.charPositions.length;t++){const n=e.chars[t],r=s.chars[n];if(r?.texture){const s=r.texture;i.texture(s,u||"black",Math.round(e.charPositions[t]+r.xOffset),Math.round(o+r.yOffset+f),s.orig.width,s.orig.height)}}o+=g}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new wp;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,s=pr.get(`${i}-bitmap`),{a:n,b:r,c:o,d:a}=t.groupTransform,h=Math.sqrt(n*n+r*r),l=Math.sqrt(o*o+a*a),c=(Math.abs(h)+Math.abs(l))/2,d=s.baseRenderedFontSize/t._style.fontSize,u=c*s.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=u}destroy(){this._renderer=null}}Ap.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"bitmapText"};class Cp extends vd{constructor(t){super(),this.generatingTexture=!1,this.currentKey="--",this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{htmlText:t}=this._renderer;null===t.getReferenceCount(this.currentKey)?t.returnTexturePromise(this.texturePromise):t.decreaseReferenceCount(this.currentKey),this._renderer.runners.resolutionChange.remove(this),this.texturePromise=null,this._renderer=null}}class Sp{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const e=t._autoResolution?this._renderer.resolution:t.resolution;i.currentKey===t.styleKey&&t.resolution===e||this._updateGpuText(t).catch(t=>{}),t._didTextUpdate=!1,ii(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const i=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let s=this._renderer.htmlText.getTexturePromise(t);i&&(s=s.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=s,e.currentKey=t.styleKey,e.texture=await s;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,ii(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Cp(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=Gs.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Sp.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"htmlText"};const Ip=new zs,Mp=new Map;class Tp{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===uo.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const i=this._buildTexturePromise(t).then(t=>(this._activeTextures[e].texture=t,t));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){return this._activeTextures[t]?.usageCount??null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,0===e.usageCount&&(e.texture?this._cleanUp(e.texture):e.promise.then(t=>{e.texture=t,this._cleanUp(e.texture)}).catch(()=>{o()}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:s,textureStyle:n}=t,r=_n.get($l),o=function(t,e){function i(t){r[t]||(n.push(t),r[t]=!0)}const s=e.fontFamily,n=[],r={},o=t.match(/font-family:([^;"\s]+)/g);if(Array.isArray(s))for(let t=0;t<s.length;t++)i(s[t]);else i(s);o&&o.forEach(t=>{i(t.split(":")[1].trim())});for(const t in e.tagStyles)i(e.tagStyles[t].fontFamily);return n}(e,i),a=await async function(t){const e=t.filter(t=>pr.has(`${t}-and-url`)).map(t=>{if(!Mp.has(t)){const{entries:e}=pr.get(`${t}-and-url`),i=[];e.forEach(e=>{const s=e.url,n=e.faces.map(t=>({weight:t.weight,style:t.style}));i.push(...n.map(e=>async function(t,e){const i=await async function(t){const e=await ir.get().fetch(t),i=await e.blob(),s=new FileReader;return await new Promise((t,e)=>{s.onloadend=()=>t(s.result),s.onerror=e,s.readAsDataURL(i)})}(e);return`@font-face {\n font-family: "${t.fontFamily}";\n font-weight: ${t.fontWeight};\n font-style: ${t.fontStyle};\n src: url('${i}');\n }`}({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},s)))}),Mp.set(t,Promise.all(i).then(t=>t.join("\n")))}return Mp.get(t)});return(await Promise.all(e)).join("\n")}(o),h=function(t,e,i,s){s||(s=tc||(tc=new $l));const{domElement:n,styleElement:r,svgRoot:o}=s;n.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,n.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(r.textContent=i),document.body.appendChild(o);const a=n.getBoundingClientRect();o.remove();const h=2*e.padding;return{width:a.width-h,height:a.height-h}}(e,i,a,r),l=Math.ceil(Math.ceil(Math.max(1,h.width)+2*i.padding)*s),c=Math.ceil(Math.ceil(Math.max(1,h.height)+2*i.padding)*s),d=r.image;d.width=2+(0|l),d.height=2+(0|c);const u=function(t,e,i,s,n){const{domElement:r,styleElement:o,svgRoot:a}=n;r.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,r.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:h,height:l}=n.image;return a.setAttribute("width",h.toString()),a.setAttribute("height",l.toString()),(new XMLSerializer).serializeToString(a)}(e,i,s,a,r);await function(t,e,i){return new Promise(async s=>{i&&await new Promise(t=>setTimeout(t,100)),t.onload=()=>{s()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"})}(d,u,function(){const{userAgent:t}=ir.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const p=d;let g;this._createCanvas&&(g=function(t,e){const i=xh.getOptimalCanvasAndContext(t.width,t.height,e),{context:s}=i;return s.clearRect(0,0,t.width,t.height),s.drawImage(t,0,0),i}(d,s));const f=si(g?g.canvas:p,d.width-2,d.height-2,s);return n&&(f.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(f.source),xh.returnCanvasAndContext(g)),_n.return(r),f}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{o()})}_cleanUp(t){Nn.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}Tp.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"htmlText"};class Pp extends vd{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{canvasText:t}=this._renderer;t.getReferenceCount(this.currentKey)>0?t.decreaseReferenceCount(this.currentKey):this.texture&&t.returnTexture(this.texture),this._renderer.runners.resolutionChange.remove(this),this._renderer=null}}class Ep{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i||t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const e=t._autoResolution?this._renderer.resolution:t.resolution;i.currentKey===t.styleKey&&t.resolution===e||this._updateGpuText(t),t._didTextUpdate=!1,ii(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Pp(this._renderer);return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Ep.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"text"};class Bp{constructor(t){this._activeTextures={},this._renderer=t}getTexture(t,e,i,s){"string"==typeof t&&(Ps(0,"CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof yh||(t.style=new yh(t.style)),t.textureStyle instanceof ks||(t.textureStyle=new ks(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:n,style:r,textureStyle:o}=t,a=t.resolution??this._renderer.resolution,{frame:h,canvasAndContext:l}=Yl.getCanvasAndContext({text:n,style:r,resolution:a}),c=si(l.canvas,h.width,h.height,a);if(o&&(c.source.style=o),r.trim&&(h.pad(r.padding),c.frame.copyFrom(h),c.frame.scale(1/a),c.updateUvs()),r.filters){const t=this._applyFilters(c,r.filters);return this.returnTexture(c),Yl.returnCanvasAndContext(l),t}return this._renderer.texture.initSource(c._source),Yl.returnCanvasAndContext(l),c}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Nn.returnTexture(t,!0)}renderTextToCanvas(){Ps(0,"CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e.usageCount--,0===e.usageCount&&(this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){return this._activeTextures[t]?.usageCount??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}Bp.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"canvasText"},es.add(is,ss);var Rp=(t,e)=>Number((e/10**t).toFixed(t)),kp=t=>t>32767?t-65535:t,Op=(t,e)=>e+(t<<8),Dp=(t,e)=>Rp(t,kp(e)),Fp=t=>{try{let e=t.match(/.{1,2}/g);if(!e||0===e.length)return"";let i=new Uint8Array(e.length),s=0;for(let t=0;t<e.length;t++){let n=parseInt(e[t],16);n>31&&127!==n&&(i[s++]=n)}let n=i.slice(0,s);return Array.from(n).map(t=>String.fromCharCode(t)).join("")}catch(t){return""}},Lp=t=>{if(!t)return"";try{let e=t.match(/.{1,2}/g);if(!e)return"";let i=e.filter(t=>{let e=parseInt(t,16);return e>31&&127!==e});return 0===i.length?"":decodeURIComponent("%"+i.join("%"))}catch{return""}},jp=(t,e=1)=>{let i=[];for(let s=0;s<t.length;s+=2*e){let n=t.slice(s,s+2*e),r=parseInt(n,16);i.push(r)}return i},Gp=({chargeX:t,chargeY:e},{originX:i,originY:s})=>t<=0&&e<=0?null:{x:t-i,y:e-s},Up=(t,e)=>parseInt((t+e).slice(-8),2).toString(16).padStart(2,"0"),zp=t=>{let e=parseInt(t.slice(0,2),16),i=t.slice(0,3===e?52:48),s=2,n=parseInt(i.slice(s,s+4),16);s+=4;let r=1===parseInt(i.slice(s,s+2),16);s+=2;let o=parseInt(i.slice(s,s+4),16);s+=4;let a=parseInt(i.slice(s,s+4),16);s+=4;let h=Rp(1,parseInt(i.slice(s,s+4),16));s+=4;let l=Rp(1,parseInt(i.slice(s,s+4),16));s+=4;let c=Rp(2,parseInt(i.slice(s,s+4),16));s+=4;let d=Rp(1,parseInt(i.slice(s,s+4),16));s+=4;let u,p=Rp(1,parseInt(i.slice(s,s+4),16));3===e&&(s+=4,u=parseInt(i.slice(s,s+4),16)),s+=4;let g=parseInt(i.slice(s,s+8),16);s+=8;let f=parseInt(i.slice(s,s+4),16);return{mapHeaderStr:i,version:e,id:n,mapStable:r,mapWidth:o,mapHeight:a,originX:h,originY:l,mapResolution:c,chargeX:d,chargeY:p,chargeDirection:u,chargePositionTransformed:Gp({chargeX:d,chargeY:p},{originX:h,originY:l}),dataLengthBeforeCompress:g,dataLengthAfterCompress:f}},Np={"00":"00","01":"f1",10:"f2",11:"ff"},Vp={sweep:"00",barrier:"01",battery:"10",unknown:"11"},Hp={sweep:"111",barrier:"001",carpet:"010",unknown:"000"},Wp={0:{typeMap:Vp},1:{typeMap:Vp},2:{typeMap:Hp},3:{typeMap:Hp}},Jp={NO_ROOM_DATA:"NO_ROOM_DATA",ROOM_GAP:"ROOM_GAP",OBSTACLE_ROOM:"OBSTACLE_ROOM",UNKNOWN_ROOM:"UNKNOWN_ROOM"};Math.imul||(Math.imul=function(t,e){let i=65535&t,s=65535&e;return i*s+((t>>>16)*s+i*(e>>>16)<<16)|0});var Zp=(t,e=1048576)=>{let i=new Uint8Array(t),s=1073741824,n=e;if(e>s)return n=s,null;let r=new Uint8Array(n),o=function(t,e,i,s){for(var n=i=i||0,r=s=s||t.length-i,o=0;n<r;){let i=t[n++],s=i>>4;if(s>0){for(var a=s+240;255===a;)s+=a=t[n++];for(var h=n+s;n<h;)e[o++]=t[n++];if(n===r)return o}let l=t[n++]|t[n++]<<8;if(0===l||l>o)return-(n-2);let c=15&i;for(a=c+240;255===a;)c+=a=t[n++];let d=o-l;for(h=o+c+4;o<h;)e[o++]=e[d++]}return o}(i,r);return r=r.slice(0,o),r},Xp="0123456789abcdef",Yp=(t,e=1)=>{if(!t)return[];let i=parseInt(t.slice(2,4),16),s=t.slice(4),n=[],r=0;for(let t=0;t<i;t++){let t=s.slice(r,r+94),i=parseInt(t.slice(0,4),16),o=parseInt(t.slice(4,8),16),a=parseInt(t.slice(8,12),16),h=parseInt(t.slice(12,16),16),l=parseInt(t.slice(16,18),16),c=1===parseInt(t.slice(18,20),16),d=1===parseInt(t.slice(20,22),16),u=parseInt(t.slice(22,24),16),p=parseInt(t.slice(24,26),16),g=1===parseInt(t.slice(26,28),16),f=parseInt(t.slice(28,30),16),m=parseInt(t.slice(52,54),16),y=t.slice(54,54+2*m),x=m>0?Lp(y):"";r+=2*(47+4*parseInt(t.slice(92,94),16));let b=Up(i.toString(2),Wp[e].typeMap.sweep);n.push({roomId:i,pointHex:b,name:x,order:o,suction:u,cistern:p,colorOrder:l,sweepTimes:a,mopTimes:h,sweepForbidden:c,mopForbidden:d,yMop:g,floorMaterial:f,originStr:t,reservedStr:t.slice(30,52)})}return n},Kp=(t,e,i={})=>{let{mapWidth:s,mapHeight:n,dataLengthAfterCompress:r,dataLengthBeforeCompress:o,mapHeaderStr:a,version:h}=e,l=a.length,{pointsStructured:c=!1}=i,d=!c,u=c,p="",g="",f=s*n,m=[],y=[],x=new Map;if(r>0){let e=4*o,i=jp(t.slice(l,l+2*o)),r=Zp(i,e);if(!r)return{mapRooms:[],mapPointsStr:"",parsed:{obstacles:new Uint32Array,carpet:new Uint32Array,rooms:new Map,width:s,height:n,totalPixels:f}};let a=Array.from(r);if(0===h){let t=[];u&&x.set(Jp.NO_ROOM_DATA,[]);let e=u?x.get(Jp.NO_ROOM_DATA):null;for(let i=0;i<a.length;i++){let s=a[i];for(let n=0;n<8;n+=2){let r=4*i+n/2;if(r>=f)break;let o=s>>n&3;if(d&&t.push(ri(s,n)),u)switch(o){case 0:e.push(r);break;case 1:m.push(r)}}}d&&(p=t.join("").slice(0,2*f)),g=""}else{let t=a.slice(0,f),e=[];for(let i=0;i<t.length;i++){let s=t[i];d&&e.push(ni(s)),u&&(1===h?oi(s,i,m,x):hi(s,i,m,y,x))}d&&(p=e.join("")),g=a.slice(f).map(t=>ni(t)).join("")}}else if(0===h){let e=[],i=t.slice(l).match(/.{2}/g)||[];u&&x.set(Jp.NO_ROOM_DATA,[]);let s=u?x.get(Jp.NO_ROOM_DATA):null;for(let t=0;t<i.length;t++){let n=parseInt(i[t],16);for(let i=0;i<8;i+=2){let r=4*t+i/2;if(r>=f)break;let o=n>>i&3;if(d&&e.push(ri(n,i)),u)switch(o){case 0:s.push(r);break;case 1:m.push(r)}}}d&&(p=e.join("")),g=""}else{let e=t.slice(l,l+2*f),i=[];for(let t=0;t<f;t++){let s=e.slice(2*t,2*t+2);if(d&&i.push(s),u){let e=parseInt(s,16);1===h?oi(e,t,m,x):hi(e,t,m,y,x)}}d&&(p=i.join("")),g=t.slice(l+2*f)}d&&(p=p.toLowerCase(),s*n*2>p.length&&(p=p.padStart(s*n*2,"f")),s*n*2<p.length&&(p=p.slice(p.length-s*n*2)));let b=Yp(g,h),v=new Map;return u&&x.forEach((t,e)=>{t.length>0&&v.set(e,new Uint32Array(t))}),{mapRooms:b,mapPointsStr:p,parsed:{obstacles:u?new Uint32Array(m):new Uint32Array,carpet:u?new Uint32Array(y):new Uint32Array,rooms:v,width:s,height:n,totalPixels:f}}},Qp=t=>{try{if(!t)return null;let e=zp(t),{mapWidth:i,mapHeight:s,dataLengthAfterCompress:n,dataLengthBeforeCompress:r,mapHeaderStr:o,version:a}=e,h=o.length,l="",c=i*s;if(n>0){let e=4*r,i=jp(t.slice(h,h+2*r)),s=Zp(i,e);if(!s)return[];let n=Array.from(s);if(0===a)return[];l=n.slice(c).map(t=>t.toString(16).padStart(2,"0")).join("")}else{if(0===a)return[];l=t.slice(h+2*c)}return Yp(l,a)}catch(t){return null}},qp={"00":"common",10:"charge","01":"transitions",11:"mop"},$p=t=>{let e=t.slice(0,26);return{version:parseInt(e.slice(0,2),16),pathId:parseInt(e.slice(2,6),16),initFlag:parseInt(e.slice(6,8),16),type:parseInt(e.slice(8,10),16),count:parseInt(e.slice(10,18),16),direction:parseInt(e.slice(18,22),16),dataLengthAfterCompress:parseInt(e.slice(22,26),16)}},tg=(t,e)=>{let{dataLengthAfterCompress:i,count:s}=e,n=[];if(i>0){let e=4*s,i=jp(t.slice(26)),r=Zp(i,e);if(!r)return[];let o=Array.from(r);for(let t=0;t<o.length;t+=4){let e=Op(o[t],o[t+1]),i=Op(o[t+2],o[t+3]);n.push([e,i])}}else n=(t=>{if(!Array.isArray(t))return[];let e=[];for(let i=0;i<t.length;i+=2)e.push(t.slice(i,i+2));return e})(jp(t.slice(26),2));let r=[];for(let t=0;t<n.length;t++){let[e,i]=n[t],s=`${1&e}${1&i}`;r.push({x:Dp(1,-2&e),y:-Dp(1,-2&i),type:qp[s]})}return r};const eg=Object.freeze(Object.defineProperty({__proto__:null,BITMAP_TYPE_HEX_MAP:Np,BITMAP_TYPE_MAP:Vp,BITMAP_TYPE_MAP_V2:Hp,MAP_VERSION_MAP:Wp,PATH_HEADER_LENGTH:13,PATH_POINT_TYPE_MAP:qp,SPECIAL_ROOM_IDS:Jp,combineTwoBinaryToHex:Up,dealPL:kp,decodeMap:(t,e)=>{try{if(!t)return null;let i=zp(t);return{mapHeader:i,mapData:Kp(t,i,e)}}catch(t){return null}},decodeMapData:Kp,decodeMapHeader:zp,decodeMapRooms:Qp,decodeMapStructured:t=>{try{return JSON.parse(Fp(t))}catch(t){return{}}},decodePath:t=>{let e=$p(t);return{pathHeader:e,pathPoints:tg(t,e)}},decodePathData:tg,decodePathHeader:$p,hexStringToNumber:jp,hexToUTF8:Fp,hexToUriDecodedString:Lp,highLowToInt:Op,scaleNumber:Rp,transformChargeXY:Gp,transformXY:Dp},Symbol.toStringTag,{value:"Module"})),ig=(t,e)=>(Qp(t)??[]).map(t=>({id:t.roomId,name:t.name,cleanTimes:t.sweepTimes,order:t.order,floorType:t.floorMaterial,yMop:t.yMop?1:0,suction:t.suction,cistern:t.cistern,cleanMode:t.sweepForbidden||t.mopForbidden?t.sweepForbidden?2:1:0,...e?.(t.reservedStr)??{}})),sg=(t,e,i=20)=>{const s=[...t];let n=0;for(;n<i&&e.some(t=>{return i=t,(e=s).length===i.length&&e.every((t,e)=>{const s=i[e];return t.x===s.x&&t.y===s.y});var e,i});)n++,s.forEach(t=>{t.x+=5,t.y+=5});return s},ng={log(t,...e){},warn(t,...e){},error(t,...e){},debug(t,...e){},success(t,...e){}},rg=t=>{if(t.length<=1)return[...t];const e=og(t),i=e.slice(1).map((t,i)=>({prev:e[i],current:t})),s=new Map;return i.forEach(({prev:t,current:e})=>{ag(t,e).forEach(t=>{const e=`${t.x},${t.y}`;s.has(e)||s.set(e,t)})}),Array.from(s.values())},og=t=>{if(t.length<=1)return[...t];const e=t[0],i=t[t.length-1];return e.x===i.x&&e.y===i.y?[...t]:[...t,e]},ag=(t,e)=>{const i=[],s=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y),r=t.x<e.x?1:-1,o=t.y<e.y?1:-1;let a=s-n,h=t.x,l=t.y;for(;i.push({x:h,y:l}),h!==e.x||l!==e.y;){const t=2*a;t>-n&&(a-=n,h+=r),t<s&&(a+=s,l+=o)}return i},hg=(t,e)=>{let i=0,s=t.length-1;for(;i<=s;){const n=Math.floor((i+s)/2),r=t[n];if(r===e)return!0;r<e?i=n+1:s=n-1}return!1},lg=(t,e,i,s,n,r=8)=>{const o={x:(e+s)/2,y:(i+n)/2},a=s-e,h=n-i,l=Math.min(r,.2*Math.min(a,h));return gg(o,t)&&dg(o,t)>=l?o:cg(t,o,l)},cg=(t,e,i)=>{const{minX:s,minY:n,maxX:r,maxY:o}=yg(t),a=r-s,h=o-n,l=e.x,c=e.y,d=Math.min(.5,.05*Math.min(a,h)),u=[];if(gg({x:l,y:c},t)){const e=dg({x:l,y:c},t);u.push({point:{x:l,y:c},distance:e,centerDistance:0})}const p=.6*Math.max(a,h),g=Math.PI/16;let f=0,m=!1;for(let e=d;e<=p&&!m;e+=d){const d=g*(1+e/p);for(let p=0;p<2*Math.PI;p+=d){if(f++,f>1e4){ng.error(`[findBestInnerPoint] Iteration limit reached (${f}). Room size: ${a}x${h}`),m=!0;break}const d=l+e*Math.cos(p),g=c+e*Math.sin(p);if(d>=s&&d<=r&&g>=n&&g<=o){const e={x:d,y:g};if(gg(e,t)){const s=dg(e,t),n=_g({x:d,y:g},{x:l,y:c});s>=i&&u.push({point:e,distance:s,centerDistance:n})}}}if(u.length>=15)break}if(u.length>0){const t=u.map(t=>({...t,score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,e)=>e.score-t.score),t[0].point}if(0===u.length){let e={x:l,y:c},i=0;const u=2*d;let p=0;const g=5e3;let f=!1;for(let l=s;l<=r&&!f;l+=u)for(let s=n;s<=o;s+=u){if(p++,p>g){ng.error(`[findBestInnerPoint] Coarse search iteration limit reached. Room size: ${a}x${h}`),f=!0;break}const n={x:l,y:s};if(gg(n,t)){const s=dg(n,t);s>i&&(i=s,e=n)}}return e}return{x:l,y:c}},dg=(t,e)=>{let i=1/0;for(let s=0,n=e.length-1;s<e.length;n=s++){const r=e[n],o=e[s],a=pg(t,r,o);i=Math.min(i,a)}return i},ug=(t,e)=>1===e.length?_g(t,e[0]):2===e.length?pg(t,e[0],e[1]):4===e.length?gg(t,e)?0:dg(t,e):(ng.warn(`[Distance] Invalid geometry: expected 1, 2 or 4 points, got ${e.length}`),1/0),pg=(t,e,i)=>{const s=(e.x-i.x)**2+(e.y-i.y)**2;if(0===s)return _g(t,e);const n=Math.max(0,Math.min(1,((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/s)),r=e.x+n*(i.x-e.x),o=e.y+n*(i.y-e.y);return _g(t,{x:r,y:o})},gg=(t,e,i=!1)=>{if(e.length<3)return!1;if(i&&fg(t,e))return!0;let s=!1;for(let i=0,n=e.length-1;i<e.length;n=i++){const r=e[i].x,o=e[i].y,a=e[n].x,h=e[n].y;o>t.y!=h>t.y&&t.x<(a-r)*(t.y-o)/(h-o)+r&&(s=!s)}return s},fg=(t,e)=>{if(e.length<2)return!1;for(let i=0;i<e.length;i++){const s=(i+1)%e.length;if(mg(t,e[i],e[s]))return!0}return!1},mg=(t,e,i,s=.5)=>{if(pg(t,e,i)>s)return!1;const n=Math.min(e.x,i.x)-s,r=Math.max(e.x,i.x)+s,o=Math.min(e.y,i.y)-s,a=Math.max(e.y,i.y)+s;return t.x>=n&&t.x<=r&&t.y>=o&&t.y<=a},yg=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,i=1/0,s=-1/0,n=-1/0;for(const r of t)e=Math.min(e,r.x),i=Math.min(i,r.y),s=Math.max(s,r.x),n=Math.max(n,r.y);return{minX:e,minY:i,maxX:s,maxY:n}},xg=t=>{const e=t.reduce((t,e)=>({x:t.x+e.x,y:t.y+e.y}),{x:0,y:0});return{x:e.x/t.length,y:e.y/t.length}},bg=t=>{if(4!==t.length)return t;const e=xg(t),i=_g(t[0],t[1]),s=_g(t[1],t[2]),n=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),r=[{x:-i/2,y:-s/2},{x:i/2,y:-s/2},{x:i/2,y:s/2},{x:-i/2,y:s/2}],o=Math.cos(n),a=Math.sin(n);return r.map(t=>({x:t.x*o-t.y*a+e.x,y:t.x*a+t.y*o+e.y}))},vg=(t,e,i,s=10)=>{if(0===i)return 1;const n=(t.x*e.x+t.y*e.y)/i/i,r=s/i;return n<=0?r:Math.max(n,r)},_g=(t,e)=>{const i=t.x-e.x,s=t.y-e.y;return Math.sqrt(i*i+s*s)},wg=t=>Math.sqrt(t.x*t.x+t.y*t.y),Ag=(t,e)=>({x:e.x-t.x,y:e.y-t.y}),Cg=t=>{const e=wg(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},Sg=(t,e)=>{const i=Ag(t,e);return Cg(i)},Ig=t=>({x:-t.y,y:t.x}),Mg=(t,e)=>{const i=Sg(t,e);return Ig(i)},Tg=(t,e)=>{const i=Cg(t),s=Cg(e),n={x:(i.x+s.x)/2,y:(i.y+s.y)/2};return Cg(n)},Pg=(t,e)=>{const i=Ag(t,e);let s=Math.atan2(i.y,i.x);return(s>Math.PI/2||s<-Math.PI/2)&&(s+=Math.PI),s},Eg=(t,e,i)=>{if(0===_g(t,e))return[];const s=Mg(t,e),n=i/2;return[t.x+s.x*n,t.y+s.y*n,e.x+s.x*n,e.y+s.y*n,e.x-s.x*n,e.y-s.y*n,t.x-s.x*n,t.y-s.y*n]},Bg=(t,e,i,s)=>{const n=Ag(t,e),r=Ag(t,i),o=Tg(n,r),a=-o.x,h=-o.y;return{x:t.x+a*s,y:t.y+h*s}},Rg=(t,e,i,s)=>{const n=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),r=(t.x-s.x)*(e.y-s.y)-(t.y-s.y)*(e.x-s.x);if(n*r>=0)return null;const o=(i.x-t.x)*(s.y-t.y)-(i.y-t.y)*(s.x-t.x);if(o*(o+n-r)>=0)return null;const a=o/(r-n),h=a*(e.x-t.x),l=a*(e.y-t.y);return{x:t.x+h,y:t.y+l}},kg=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),Og=(t,e,i,s,n)=>t.x>=e&&t.x<=e+s&&t.y>=i&&t.y<=i+n,Dg=(t,e,i,s)=>{const n=i/2;return"horizontal"===s?[{x:t-n,y:e},{x:t+n,y:e}]:[{x:t,y:e-n},{x:t,y:e+n}]},Fg=(t,e,i)=>{const s=yg(t),n=yg(e),r=Math.max(0,Math.max(s.minX,n.minX)-Math.min(s.maxX,n.maxX)),o=Math.max(0,Math.max(s.minY,n.minY)-Math.min(s.maxY,n.maxY));if(r>i||o>i)return!1;let[a,h]=[t,e];e.length>t.length&&([a,h]=[e,t]);const l=Math.max(1,Math.floor(i)),c=new Map;for(const t of a){const e=`${Math.floor(t.x/l)},${Math.floor(t.y/l)}`;c.has(e)||c.set(e,[]),c.get(e).push(t)}const d=i*i;for(const t of h){const e=Math.floor(t.x/l),i=Math.floor(t.y/l);for(let s=-1;s<=1;s++)for(let n=-1;n<=1;n++){const r=`${e+s},${i+n}`,o=c.get(r);if(o)for(const e of o){const i=t.x-e.x,s=t.y-e.y;if(i*i+s*s<=d)return!0}}}return!1},Lg=(t,e,i,s)=>{let[n,r]=[t,e];e.length>t.length&&([n,r]=[e,t]);const o=new Set(n),a=s*s;for(let t=0;t<r.length;t++){const e=r[t],n=e%i,h=Math.floor(e/i);for(let t=-s;t<=s;t++)for(let e=-s;e<=s;e++){const s=(h+e)*i+(n+t);if(o.has(s)&&t*t+e*e<=a)return!0}}return!1},jg=(t,e)=>{if(t<=1)return!0;if(0===e.length)return!1;const i=Array.from({length:t},(t,e)=>e),s=Array(t).fill(0),n=t=>(i[t]!==t&&(i[t]=n(i[t])),i[t]),r=(t,e)=>{const r=n(t),o=n(e);r!==o&&(s[r]<s[o]?i[r]=o:s[r]>s[o]?i[o]=r:(i[o]=r,s[r]++))};for(const[t,i]of e)r(t,i);const o=n(0);for(let e=1;e<t;e++)if(n(e)!==o)return!1;return!0};var Gg="object"==typeof global&&global&&global.Object===Object&&global,Ug="object"==typeof self&&self&&self.Object===Object&&self,zg=Gg||Ug||Function("return this")(),Ng=zg.Symbol,Vg=Object.prototype,Hg=Vg.hasOwnProperty,Wg=Vg.toString,Jg=Ng?Ng.toStringTag:void 0,Zg=Object.prototype.toString,Xg=Ng?Ng.toStringTag:void 0,Yg=Array.isArray,Kg=/\s/,Qg=/^\s+/,qg=/^[-+]0x[0-9a-f]+$/i,$g=/^0b[01]+$/i,tf=/^0o[0-7]+$/i,ef=parseInt,sf=zg["__core-js_shared__"],nf=function(){var t=/[^.]+$/.exec(sf&&sf.keys&&sf.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),rf=Function.prototype.toString,of=/^\[object .+?Constructor\]$/,af=Function.prototype,hf=Object.prototype,lf=af.toString,cf=hf.hasOwnProperty,df=RegExp("^"+lf.call(cf).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),uf=mi(zg,"WeakMap"),pf=Object.create,gf=function(){function t(){}return function(e){if(!di(e))return{};if(pf)return pf(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),ff=Date.now,mf=function(){try{var t=mi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),yf=mf?function(t,e){return mf(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:pi,xf=function(t){var e=0,i=0;return function(){var s=ff(),n=16-(s-i);if(i=s,n>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(yf),bf=/^(?:0|[1-9]\d*)$/,vf=Object.prototype.hasOwnProperty,_f=Math.max,wf=Object.prototype,Af=Object.prototype,Cf=Af.hasOwnProperty,Sf=Af.propertyIsEnumerable,If=Ci(function(){return arguments}())?Ci:function(t){return ci(t)&&Cf.call(t,"callee")&&!Sf.call(t,"callee")},Mf="object"==typeof exports&&exports&&!exports.nodeType&&exports,Tf=Mf&&"object"==typeof module&&module&&!module.nodeType&&module,Pf=Tf&&Tf.exports===Mf?zg.Buffer:void 0,Ef=(Pf?Pf.isBuffer:void 0)||function(){return!1},Bf={};Bf["[object Float32Array]"]=Bf["[object Float64Array]"]=Bf["[object Int8Array]"]=Bf["[object Int16Array]"]=Bf["[object Int32Array]"]=Bf["[object Uint8Array]"]=Bf["[object Uint8ClampedArray]"]=Bf["[object Uint16Array]"]=Bf["[object Uint32Array]"]=!0,Bf["[object Arguments]"]=Bf["[object Array]"]=Bf["[object ArrayBuffer]"]=Bf["[object Boolean]"]=Bf["[object DataView]"]=Bf["[object Date]"]=Bf["[object Error]"]=Bf["[object Function]"]=Bf["[object Map]"]=Bf["[object Number]"]=Bf["[object Object]"]=Bf["[object RegExp]"]=Bf["[object Set]"]=Bf["[object String]"]=Bf["[object WeakMap]"]=!1;var Rf,kf="object"==typeof exports&&exports&&!exports.nodeType&&exports,Of=kf&&"object"==typeof module&&module&&!module.nodeType&&module,Df=Of&&Of.exports===kf&&Gg.process,Ff=function(){try{return Of&&Of.require&&Of.require("util").types||Df&&Df.binding&&Df.binding("util")}catch(t){}}(),Lf=Ff&&Ff.isTypedArray,jf=Lf?(Rf=Lf,function(t){return Rf(t)}):function(t){return ci(t)&&_i(t.length)&&!!Bf[li(t)]},Gf=Object.prototype.hasOwnProperty,Uf=Ii(Object.keys,Object),zf=Object.prototype.hasOwnProperty,Nf=Object.prototype.hasOwnProperty,Vf=mi(Object,"create"),Hf=Object.prototype.hasOwnProperty,Wf=Object.prototype.hasOwnProperty;Ti.prototype.clear=function(){this.__data__=Vf?Vf(null):{},this.size=0},Ti.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ti.prototype.get=function(t){var e=this.__data__;if(Vf){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Hf.call(e,t)?e[t]:void 0},Ti.prototype.has=function(t){var e=this.__data__;return Vf?void 0!==e[t]:Wf.call(e,t)},Ti.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Vf&&void 0===e?"__lodash_hash_undefined__":e,this};var Jf=Array.prototype.splice;Ei.prototype.clear=function(){this.__data__=[],this.size=0},Ei.prototype.delete=function(t){var e=this.__data__,i=Pi(e,t);return!(i<0||(i==e.length-1?e.pop():Jf.call(e,i,1),--this.size,0))},Ei.prototype.get=function(t){var e=this.__data__,i=Pi(e,t);return i<0?void 0:e[i][1]},Ei.prototype.has=function(t){return Pi(this.__data__,t)>-1},Ei.prototype.set=function(t,e){var i=this.__data__,s=Pi(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};var Zf=mi(zg,"Map");Ri.prototype.clear=function(){this.size=0,this.__data__={hash:new Ti,map:new(Zf||Ei),string:new Ti}},Ri.prototype.delete=function(t){var e=Bi(this,t).delete(t);return this.size-=e?1:0,e},Ri.prototype.get=function(t){return Bi(this,t).get(t)},Ri.prototype.has=function(t){return Bi(this,t).has(t)},Ri.prototype.set=function(t,e){var i=Bi(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};var Xf=Ii(Object.getPrototypeOf,Object),Yf=Function.prototype,Kf=Object.prototype,Qf=Yf.toString,qf=Kf.hasOwnProperty,$f=Qf.call(Object);ki.prototype.clear=function(){this.__data__=new Ei,this.size=0},ki.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},ki.prototype.get=function(t){return this.__data__.get(t)},ki.prototype.has=function(t){return this.__data__.has(t)},ki.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Ei){var s=i.__data__;if(!Zf||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new Ri(s)}return i.set(t,e),this.size=i.size,this};var tm="object"==typeof exports&&exports&&!exports.nodeType&&exports,em=tm&&"object"==typeof module&&module&&!module.nodeType&&module,im=em&&em.exports===tm?zg.Buffer:void 0;im&&im.allocUnsafe;var sm=Object.prototype.propertyIsEnumerable,nm=Object.getOwnPropertySymbols,rm=nm?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var o=t[i];e(o)&&(r[n++]=o)}return r}(nm(t),function(e){return sm.call(t,e)}))}:function(){return[]},om=mi(zg,"DataView"),am=mi(zg,"Promise"),hm=mi(zg,"Set"),lm="[object Map]",cm="[object Promise]",dm="[object Set]",um="[object WeakMap]",pm="[object DataView]",gm=fi(om),fm=fi(Zf),mm=fi(am),ym=fi(hm),xm=fi(uf),bm=li;(om&&bm(new om(new ArrayBuffer(1)))!=pm||Zf&&bm(new Zf)!=lm||am&&bm(am.resolve())!=cm||hm&&bm(new hm)!=dm||uf&&bm(new uf)!=um)&&(bm=function(t){var e=li(t),i="[object Object]"==e?t.constructor:void 0,s=i?fi(i):"";if(s)switch(s){case gm:return pm;case fm:return lm;case mm:return cm;case ym:return dm;case xm:return um}return e});var vm=zg.Uint8Array;Di.prototype.add=Di.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Di.prototype.has=function(t){return this.__data__.has(t)};var _m,wm=Ng?Ng.prototype:void 0,Am=wm?wm.valueOf:void 0,Cm=Object.prototype.hasOwnProperty,Sm="[object Arguments]",Im="[object Array]",Mm="[object Object]",Tm=Object.prototype.hasOwnProperty,Pm=function(t,e,i){for(var s=-1,n=Object(t),r=i(t),o=r.length;o--;){var a=r[++s];if(!1===e(n[a],a,n))break}return t},Em=function(){return zg.Date.now()},Bm=Math.max,Rm=Math.min,km=(_m=function(t,e,i,s){Hi(t,e,i,s)},function(t){return xf(function(t,e,i){return e=_f(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=_f(s.length-e,0),o=Array(r);++n<r;)o[n]=s[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=s[n];return a[e]=i(o),function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}(t,this,a)}}(t,void 0,pi),t+"")}(function(t,e){var i=-1,s=e.length,n=s>1?e[s-1]:void 0,r=s>2?e[2]:void 0;for(n=_m.length>3&&"function"==typeof n?(s--,n):void 0,r&&function(t,e,i){if(!di(i))return!1;var s=typeof e;return!!("number"==s?wi(i)&&yi(e,i.length):"string"==s&&e in i)&&bi(i[e],t)}(e[0],e[1],r)&&(n=s<3?void 0:n,s=1),t=Object(t);++i<s;){var o=e[i];o&&_m(t,o,i,n)}return t}));const Om=Symbol(),Dm=Object.getPrototypeOf,Fm=new WeakMap,Lm=(t,e=!0)=>{Fm.set(t,e)},jm={},Gm=t=>"object"==typeof t&&null!==t,Um=(t,e)=>{const i=Vm.get(t);if((null==i?void 0:i[0])===e)return i[1];const s=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Lm(s,!0),Vm.set(t,[e,s]),Reflect.ownKeys(t).forEach(e=>{if(Object.getOwnPropertyDescriptor(s,e))return;const i=Reflect.get(t,e),{enumerable:n}=Reflect.getOwnPropertyDescriptor(t,e),r={value:i,enumerable:n,configurable:!0};if(Nm.has(i))Lm(i,!1);else if(zm.has(i)){const[t,e]=zm.get(i);r.value=Um(t,e())}Object.defineProperty(s,e,r)}),Object.preventExtensions(s)},zm=new WeakMap,Nm=new WeakSet,Vm=new WeakMap,Hm=[1],Wm=new WeakMap;let Jm=Object.is,Zm=(t,e)=>new Proxy(t,e),Xm=Um,Ym=(t,e,i,s)=>({deleteProperty(t,e){const n=Reflect.get(t,e);i(e);const r=Reflect.deleteProperty(t,e);return r&&s(["delete",[e],n]),r},set(n,r,o,a){const h=!t()&&Reflect.has(n,r),l=Reflect.get(n,r,a);if(h&&(Jm(l,o)||Wm.has(o)&&Jm(l,Wm.get(o))))return!0;var c;i(r),Gm(o)&&(o=(t=>t&&(Fm.has(t)?Fm.get(t):Dm(t)===Object.prototype||Dm(t)===Array.prototype))(c=o)&&c[Om]||o);const d=zm.has(o)||!Gm(u=o)||Nm.has(u)||!Array.isArray(u)&&Symbol.iterator in u||u instanceof WeakMap||u instanceof WeakSet||u instanceof Error||u instanceof Number||u instanceof Date||u instanceof String||u instanceof RegExp||u instanceof ArrayBuffer||u instanceof Promise?o:Zi(o);var u;return e(r,d),Reflect.set(n,r,d,a),s(["set",[r],o,l]),!0}});class Km extends Xn{dragStart=null;initialTouchDistance=null;initialScale=null;activeTouches=new Map;firstTouchId=null;secondTouchId=null;taintedPointers=new Set;zoomFactor=.8;scaleMin=.2;scaleMax=5;originalPosition={x:0,y:0};targetPosition={x:0,y:0};centerPosition={x:0,y:0};originalScale={x:1,y:1};targetScale={x:1,y:1};defaultScale={x:1,y:1};transitionDuration=500;transitionStartTime=null;initialPinchCenter=null;isGestureValid=!0;lastTapTime=0;doubleTapDelay=300;doubleTapZoomFactor=1.5;lastTapPosition=null;tapDistanceThreshold=20;tapDetectionEnabled=!0;mapClickStartPosition=null;mapClickStartTime=0;mapClickTimeThreshold=300;mapClickMoveThreshold=10;shouldSuppressMapClick=!1;isGestureHijacked=!1;hijackedPointerId=null;isHijackPaused=!1;interactionGraphics;viewportBounds;boundResetAnimation;debouncedStopWheelRender;debouncedLogWheelScale;interactionState={isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set};throttledAntiScale;unsubscribeEnableInteraction=null;constructor(){super();const t=Yi(),e=t.getApp();this.viewportBounds=e.getViewportBounds(),this.eventMode="static",this.unsubscribeEnableInteraction=Xi(t.runtime,"enableInteraction",t=>{this.updateInteractionMode(t)}),this.updateInteractionMode(t.runtimeSnapshot.enableInteraction),this.interactionGraphics=new Ll,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=e.scaleMax,this.scaleMin=e.scaleMin,this.centerPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.originalPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.targetPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.throttledAntiScale=Ji(t=>{Yi().emitter.emit("antiScale",t)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=zi(()=>{e.stopRender("wheel")},300),this.debouncedLogWheelScale=zi(t=>{ng.debug("[Interaction] 滚轮缩放完成 - Scale:",t.toFixed(3))},500),this.setupInteraction()}updateInteractionMode(t){this.eventMode=t?"static":"none",ng.debug("[Interaction] 交互模式已更新: "+(t?"启用":"禁用"))}setupInteraction(){this.on("pointerdown",t=>this.onPointerDown(t)),this.on("pointerup",t=>this.onPointerUp(t)),this.on("pointerupoutside",t=>this.onPointerUp(t)),this.on("pointermove",t=>this.onPointerMove(t)),this.on("wheel",t=>this.onWheel(t)),Yi().emitter.on("gestureHijackStart",this.handleGestureHijacked),Yi().emitter.on("suppressMapClick",this.handleSuppressMapClick),document.addEventListener("pointercancel",()=>{this.clearTouches()})}resetPan(t){const e=Yi(),i=e.getApp(),s=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const n=this.centerPosition.x-t.x*s.scale.x,r=this.centerPosition.y-t.y*s.scale.y;this.originalPosition={x:s.x,y:s.y},this.targetPosition={x:n,y:r},this.originalScale={x:s.scale.x,y:s.scale.y},this.targetScale={x:s.scale.x,y:s.scale.y};const o=(a=Math.sqrt((s.x-n)**2+(s.y-r)**2),Math.pow(Math.min(1,a/1e3),.5));var a;this.transitionDuration=500+1e3*Math.min(1,Math.pow(o,2)),this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:e,setCenter:i=!1,setScale:s=!1}={},n=!0){const r=Yi(),o=r.getApp(),a=r.appContainer;if(i&&t&&(this.centerPosition={x:t.x,y:t.y},ng.debug("[Interaction] Set center position:",this.centerPosition)),s&&e&&(this.defaultScale={x:e.x,y:e.y},ng.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:a.x,y:a.y},this.originalScale={x:a.scale.x,y:a.scale.y},this.targetPosition=t||{x:this.centerPosition.x,y:this.centerPosition.y},this.targetScale=e||this.defaultScale,!n)return a.position.set(this.targetPosition.x,this.targetPosition.y),a.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),void ng.debug("[Interaction] 直接设置缩放完成 - Scale:",this.targetScale.x.toFixed(3));var h,l,c;const d=.8*(h=Math.sqrt((a.x-this.targetPosition.x)**2+(a.y-this.targetPosition.y)**2),Math.pow(Math.min(1,h/1e3),.5))+.2*(l=a.scale.x,c=this.targetScale.x,Math.pow(Math.min(1,Math.abs(l-c)/Math.abs(-.8)),.5));this.transitionDuration=500+1e3*Math.min(1,Math.pow(d,2)),null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,o.stopRender("animation")),this.interactionState.isAnimating=!0,o.requestRender("animation",!0),this.transitionStartTime=o.ticker.lastTime,o.ticker.add(this.boundResetAnimation)}clearTouches(){const t=Yi().getApp();this.activeTouches.clear(),this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.isGestureValid=!0,this.taintedPointers.clear(),null!==this.transitionStartTime&&(t.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting=!1,t.stopRender("interaction")}checkEventListeners(){return{wheel:this.listenerCount("wheel"),pointerdown:this.listenerCount("pointerdown"),pointerup:this.listenerCount("pointerup"),pointerupoutside:this.listenerCount("pointerupoutside"),pointermove:this.listenerCount("pointermove")}}destroy(){this.checkEventListeners(),this.interactionState.interactionTimer&&clearTimeout(this.interactionState.interactionTimer),this.interactionState.renderReasons.clear(),this.interactionState.isInteracting=!1,this.interactionState.isAnimating=!1,this.debouncedStopWheelRender.cancel(),this.debouncedLogWheelScale.cancel(),this.unsubscribeEnableInteraction&&(this.unsubscribeEnableInteraction(),this.unsubscribeEnableInteraction=null),Yi().emitter.off("gestureHijackStart",this.handleGestureHijacked),Yi().emitter.off("suppressMapClick",this.handleSuppressMapClick),super.destroy()}handleSuppressMapClick=()=>{this.shouldSuppressMapClick=!0};handleGestureHijacked=t=>{this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches();const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),this.firstTouchId=t.pointerId,this.dragStart={x:e,y:i}};exitGestureHijacked(){null===this.hijackedPointerId||this.isHijackPaused||(this.activeTouches.delete(this.hijackedPointerId),this.firstTouchId===this.hijackedPointerId&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===this.hijackedPointerId&&(this.secondTouchId=null)),this.isGestureHijacked=!1,this.hijackedPointerId=null,this.isHijackPaused=!1}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(t){this.throttledAntiScale(t)}resetAnimation(){const t=Yi(),e=t.getApp(),i=t.appContainer;if(null===this.transitionStartTime)return;const{targetPosition:s,targetScale:n}=this,r=e.ticker.lastTime,o=Math.min(1,(r-this.transitionStartTime)/this.transitionDuration);if(o>=1)i.position.set(s.x,s.y),i.scale.set(n.x,n.y),this.antiScale(n.x),e.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,e.stopRender("animation"),ng.debug("[Interaction] 动画缩放完成 - Scale:",i.scale.x.toFixed(3));else{const t=(a=o)<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,e=this.originalPosition.x+(s.x-this.originalPosition.x)*t,r=this.originalPosition.y+(s.y-this.originalPosition.y)*t,h=this.originalScale.x+(n.x-this.originalScale.x)*t,l=this.originalScale.y+(n.y-this.originalScale.y)*t;i.position.set(e,r),i.scale.set(h,l),this.antiScale(h)}var a}onWheel(t){const e=Yi();if(this.isGestureHijacked)return void ng.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});e.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:i,scaleMax:s}=this,n=e.appContainer;t.preventDefault();const r=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y,a=(r-n.x)/n.scale.x,h=(o-n.y)/n.scale.y,l=t.deltaY>0?.95:1.05;let c=n.scale.x*l,d=n.scale.y*l;if(c=Math.max(i,Math.min(s,c)),d=Math.max(i,Math.min(s,d)),c===n.scale.x&&d===n.scale.y)return;const u=r-a*c,p=o-h*d;try{n.scale.set(c,d),n.position.set(u,p),this.antiScale(c),this.debouncedLogWheelScale(c)}catch(t){ng.error("❌ [onWheel] 应用缩放时发生错误:",t)}}onPointerDown(t){const e=Yi();this.interactionState.isInteracting=!0,e.getApp().requestRender("interaction",!0),this.isGestureHijacked&&(t.pointerId===this.hijackedPointerId||this.isHijackPaused||this.pauseGestureHijack());const i=e.getApp(),s=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),0===this.activeTouches.size&&this.taintedPointers.size>0&&(ng.debug("[Interaction] 清除污染指针列表,准备新手势",Array.from(this.taintedPointers)),this.taintedPointers.clear()),0===this.activeTouches.size&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.dragStart=null,this.firstTouchId=null,this.secondTouchId=null),this.activeTouches.has(t.pointerId)&&1===this.activeTouches.size&&(this.isGestureValid=!0);const n=t.global.x-this.viewportBounds.x,r=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:n,y:r});const o=this.activeTouches.size-this.taintedPointers.size;if(this.taintedPointers.size>0)return ng.debug("[Interaction] 存在污染指针,阻止多点触摸手势",Array.from(this.taintedPointers)),void(1!==o||this.taintedPointers.has(t.pointerId)||(this.firstTouchId=t.pointerId,this.dragStart={x:n,y:r}));if(1===this.activeTouches.size)this.firstTouchId=t.pointerId,this.dragStart={x:n,y:r},this.mapClickStartPosition={x:n,y:r},this.mapClickStartTime=performance.now();else if(2===this.activeTouches.size){const e=Array.from(this.activeTouches.keys());this.secondTouchId=e.find(t=>t!==this.firstTouchId)||t.pointerId,this.setInitialScaleAndDistance(s),this.tapDetectionEnabled=!1}}onPointerUp(t){const e=Yi();if(this.taintedPointers.has(t.pointerId)&&(ng.debug("[Interaction] 移除污染指针",t.pointerId),this.taintedPointers.delete(t.pointerId)),this.isGestureHijacked){if(t.pointerId===this.hijackedPointerId)return e.emitter.emit("gestureHijackPointerUp",t),void this.exitGestureHijacked();this.isHijackPaused}if(!this.activeTouches.has(t.pointerId))return;const i=null!==this.initialTouchDistance&&null!==this.initialScale;if(this.activeTouches.delete(t.pointerId),i&&1===this.activeTouches.size){this.isGestureValid=!1;const t=Array.from(this.activeTouches.keys());Promise.resolve().then(()=>{this.isGestureValid||(ng.debug("[Interaction] 检测到潜在的幽灵指针,标记为污染并清理",t),t.forEach(t=>{this.activeTouches.has(t)&&(this.taintedPointers.add(t),this.activeTouches.delete(t),this.firstTouchId===t&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===t&&(this.secondTouchId=null))}))}),this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null}t.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,0===this.activeTouches.size&&this.tapDetectionEnabled&&this.detectDoubleTap(t),0!==this.activeTouches.size||i||this.detectMapClick(t)):t.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&1===this.activeTouches.size&&Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack(),0===this.activeTouches.size&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.tapDetectionEnabled=!0,this.interactionState.isInteracting=!1,e.getApp().stopRender("interaction"))}detectDoubleTap(t){const e=Yi(),{interactionConfig:i}=e;if(!i.enableDoubleTapZoom)return;const s=performance.now(),n={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};s-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&_g(n,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(n),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=s,this.lastTapPosition=n)}detectMapClick(t){const e=Yi();if(!e.runtimeSnapshot.enableMapClickCapture)return;if(!e.events?.onClickMap)return;if(!this.mapClickStartPosition)return;const i=performance.now()-this.mapClickStartTime,s={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y},n=_g(this.mapClickStartPosition,s);if(i<=this.mapClickTimeThreshold&&n<=this.mapClickMoveThreshold&&!this.shouldSuppressMapClick){const t=e.appContainer,r=e.mapState,o=(s.x-t.x)/t.scale.x,a=(s.y-t.y)/t.scale.y,h={x:o-(r?.origin.x||0),y:a-(r?.origin.y||0)};ng.debug("[Interaction] 地图点击捕获",{screenPosition:s,containerPosition:{x:o,y:a},origin:r?.origin,mapPosition:h,clickDuration:i,moveDistance:n}),e.events.onClickMap(h)}this.mapClickStartPosition=null,this.mapClickStartTime=0,this.shouldSuppressMapClick=!1}handleDoubleTap(t){const e=Yi(),i=e.getApp(),s=e.appContainer,{scaleMin:n,scaleMax:r,doubleTapZoomFactor:o}=this,a=t.x,h=t.y,l=(a-s.x)/s.scale.x,c=(h-s.y)/s.scale.y;let d=s.scale.x*o,u=s.scale.y*o;d=Math.max(n,Math.min(r,d)),u=Math.max(n,Math.min(r,u)),this.originalPosition={x:s.x,y:s.y},this.originalScale={x:s.scale.x,y:s.scale.y};const p=a-l*d,g=h-c*u;this.targetPosition={x:p,y:g},this.targetScale={x:d,y:u},this.interactionState.isAnimating=!0,i.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}onPointerMove(t){if(this.isGestureHijacked&&!this.isHijackPaused){if(t.pointerId===this.hijackedPointerId){const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;return this.activeTouches.set(t.pointerId,{x:e,y:i}),void Yi().emitter.emit("gestureHijackPointerMove",t)}return}if(!this.activeTouches.has(t.pointerId)||!this.isGestureValid)return;if(this.taintedPointers.size>0&&(null!==this.initialTouchDistance||null!==this.initialScale))return void ng.debug("[Interaction] 存在污染指针,阻止多点触摸手势移动");const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),2===this.activeTouches.size&&null!==this.initialTouchDistance&&null!==this.initialScale&&this.applyPinchZoom(),1!==this.activeTouches.size||null===this.initialTouchDistance&&null===this.initialScale||(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),1!==this.activeTouches.size||t.pointerId!==this.firstTouchId||null===this.dragStart||this.taintedPointers.has(t.pointerId)||this.applyPan(t)}applyPan(t){const e=Yi(),i=this.activeTouches.get(t.pointerId),s=e.appContainer,{x:n,y:r}=this.dragStart;s.position.set(s.x+i.x-n,s.y+i.y-r),this.dragStart={x:i.x,y:i.y}}applyPinchZoom(){const t=Yi().appContainer,e=Array.from(this.activeTouches.values());if(e.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const i=_g(e[0],e[1]),s={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},n=(s.x-t.position.x)/t.scale.x,r=(s.y-t.position.y)/t.scale.y,o=(i/this.initialTouchDistance)**this.zoomFactor,a=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*o)),h=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*o));t.scale.set(a,h);let l=s.x-n*a,c=s.y-r*h;l+=s.x-this.initialPinchCenter.x,c+=s.y-this.initialPinchCenter.y,t.position.set(l,c),this.antiScale(a),this.initialPinchCenter=s,Math.random()<.1&&ng.debug("[Interaction] 双指缩放中 - Scale:",a.toFixed(3))}setInitialScaleAndDistance(t){const e=Array.from(this.activeTouches.values());e.length<2||(this.initialTouchDistance=_g(e[0],e[1]),this.initialScale={x:t.scale.x,y:t.scale.y},this.initialPinchCenter={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2})}}const Qm="system-ui, -apple-system, sans-serif",qm=["#2563b8","#26966b","#7c3fb8","#d97706"],$m={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6"},map:{autoPaddingHorizontalPercent:.05,autoPaddingVerticalPercent:.05,adjacencyThreshold:3,originChangeAutoFitThreshold:2,sizeChangeAutoFitThreshold:10,obstacleColor:"#999999",freeColor:"#ebebeb"},room:{colors:{sortBy:"index",strategy:"priority",active:["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],inactive:["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],name:[...qm],propertyTheme:[...qm],selectionIndicatorBackground:[...qm],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[Jp.NO_ROOM_DATA]:"#ebebeb",[Jp.ROOM_GAP]:"#ebebeb",[Jp.OBSTACLE_ROOM]:"#ebebeb",[Jp.UNKNOWN_ROOM]:"#ebebeb"},nameLabel:{fontSize:12,fontFamily:Qm,fontWeight:"500"},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:14,iconHeight:14,foldable:!0,offsetX:0,offsetY:4,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:2,paddingHorizontal:2,borderRadius:16,tailHeight:2,tailWidth:10},suction:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAgH/fIL9gcEDvoBDPsJCPUDD8BuiCAAACCklEQVRo3u3Zza6bMBCG4Y/434aQzP1fbCt14SOZSac+zPQs/C4jwaME7ICN1Wq1Wq1W87VYd0dEe9gy7MqBvuQi9OusHp3PenqMPeiix31uZU5YiVTlB3PCk5jSTXChS9kTV2m3uG/mR0zEtt0Ce7qWKw873FK5livx+VvgRJdyIr6IW9ou5Ux8T2jKgYcrNOXMwwGq8qYM83IqLKws+8rB2jISA+vLkbmr9eUnM1mry819+GO0Hs8ZPdPx3NCzlB16pvKBnqkc0TOVPXqWskPPVH6iZyp79CzlHUM2csSQiewwZCNHDJnIAUM2cgOTosy35CUvecn/W37H83C/C8nbyT6FMhjqcnsE6pnJOdBFTVPu7FiEqvwOxJTAyeN1KrQf8Z/ck9gyZPLL0Z+cF7N+l6yX8rL3r7P0z8tb6jreLV7pLba77K01IWcR/MlNwIycxDsS/Er8lFwFrv/szslBAEeJK5fl8CFx5bIc3jn3AKblQwBzrmuYl5/fgD0wL78EcOEv8Lzsp6cPB3xDDhBUmZlyWpYenZgvPC8Lj27cfta8HCEq0Fi2eN7OzFjSlwMDq8u+MLC6nAYYsJGfw3aWlVyH6cNK3obpw0qOrrsehnLfN9299Zu7j4FKiD97zeBvcgKfqlwaDNukI1JT3mBalyNs26RzgZb8gnlxpxIyVqvVarVarb70C7CyrCEVukMsAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA3yC/EECAYM+f73CQr1Awj6BvNXOp4gAAAlpJREFUaN7s1t1ugzAMhmE7TgghgdL5/u91ndBK11SYfFonTcpzXl7yR0Nd13Vd13Xd/+VWVk6OAD7PzCxDIMCHbtrTQfQbR2o1oD/2q97A6agPBjrPsd4BU+ZZgfLehQcd9acMdKEXF31yoVNYX0uewAewb9mRtfFkmaHZcroDy1qZfMMCweULtEGCHprJlrU2kiXpsRXanPbG9mrJZIjQzxY12O/O0BoVNbFHTiPDe3q32lu6NtnzZAv257Zmn32bGP9LaBgfsh9VwameoCHbXRVgjWtTc1eLEZ71FNfa1WCEIxS2u0wWAcOO9UiknblBphLdTViKTMb7W12mEyJv2cHTLpRRd0PjRLGjU0IecvDVoLLo5ko3IY0yx2prGF2Qi/PI8lVzsj/TvLbg3YMl3cp6oHgC2MddjsMS6Bddnj8NAmQRw/OlJgBZxFUfpNf3Dsme6P1hCqx3k5SloYpO9XA//SWlVPLi6G1Cdev8K/I407Z3fUBweFnQLi5+tmcGOQzCMBA0EBKSllz4/1/b+x6QVXmqVp4PrBDGeHfP7ei7JX9LmXM1nlKHIwUK+JaMQbfHw1C6RCoMTQ57iEUMAkOTIwDiEGsCoGddMYouthdiiNFnmBJtQHQNohkWV7YRYJrol6wZ+DCE05kjBawteK4d0VnAbEGPfF8cTAvhPnAcq0VTHTkWIKwdLySsBQkgDBxBsjHJ2W6qB9zYskDADVbGpSB+Zru+NF4TEHb3UtUi2aHhUqq3aPn9H4XV4MLDU06PWgyhbaCsNlDjrbmcz8wzkyRJkuRDXlF2skMkf3lIAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA359AIL+QYBDvMIBwr6CPz1BvDk7raQAAAplJREFUaN7t2tuO3CAMBmDbQALkOOv3f9dKrVbWMiSQTHGqiu96oz94OGeh67qu67rP+JF2ZObdTQb0GMcscAQdnlgoRkfkdxM0ZyVXN5k4b4bGkPOChbb4yAAJreDgoSnkIwaaGpif6V6RjxAktJq8QGMr5zlobUTdYGFRsdTlZAIFRm+dKPewF2iw/CaCioVToMMojyYRdJdFMagsTuVaB9DilacP4RQqXf6REfSMCtuP8uRlQRE2GcTezLQ4t9D0isWFAu1fK+MWmIXbzOlIHuFA3JAZqfq9vgKnAr1nY6nQ23dFIlSZOAu/bNKecJ5L8qi/lSu2n9F2RSRTM97o6vj84PBv8eLMhnxqu5XL7n6D02QzE80WDpj0/f1HDZaq+YV/I59tLnFqLC6zRSSFzHdYs+Seutel05WIjk4Q3myBc3Y456qCY3Zfa8fNnTx1bq8q9fC+JBpCPgXnuCjYZFdNcu3WKFjm3TUJtoHbBn9PkGmpiYv228PYDaPNDjorT51wtzpXGIw/6vwEVcHTjRuOxUDK/5xAVi4yl6fq/P7BrjJl1sx3ePGAwHj4pnYmmqNsss+NFw8I5W1cXTJCkbmUK0a812Cx1vy9IUw3j3a43aXTDsvr+fYxxPRXxxu5ItZvWyFl1szOeIZKdkVmHGJ5yGX3+YP7OffYBvd6dFS01/TnADTLjPe5rXqU/CfH0zkZn2pQ9XZLmGSVVUPpAUFL+Dcu9J67wgygxPFDl6dqH1/KX/gsaHjpfvYRk9732/K2GzWKvfBDya7yEkohWKmHLfXXX206l/oXvvmp/wMxfAShKR/4CLQ1PBVsg26py92LoLWJ9abNcjJGUPB++CcPGtJoZ0CPmdzOzLjT6KHruq7ruo/8Ani9wIJR4hr/AAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAIN9A7xC/gGDPn3BQkK8wj6DdtO0oAAADPElEQVRo3u2Z2Y7rIAyGwWYnS8fv/7BHlTpi0gacsuTc8N1VivqDF2yMmEwmk8lk0h9nFJHfohT90HEDIlLG5f810C/GdZJFQwkrznnQH3yPXUtDB0CefkVHbLPuooguKAd649GoaylRUlb0TmjW/cQwlm7fc6RzHleEKdbHFeXYr3ypdK0wUA7D+LgttB3lceLI2nPLQHlAHEHqt2WkEu6KrU2V8EolzBXzqCphQ0XwyteyRthTkfXK11gj/EMJPmRVP2Ekuh5emk7RI5wc+FWCqEJC2dZ8NQliiDKy1kFRi/OUJ3LlxIgGtJRyX34YQzqmhtUjLZRCB5iFtSA/d12OaZCiEw5yB2KoOC5bolwyjU8/9HYq7NhS3I49OxAhoztKGVJo8brtxA8vhqH+TaBK6XJqaYViDBKOaUpHvBTDWNYQdaYHWMVtGEp4FPeBybtR3IBecH9ZHuiJt7pbGDkbjIcnxjwifgwKAF/S1kbsN3BR9M62vB/brrffDJ0T9DF3Vdfk2Q1l8U/lZUz6RCphj/cqKFsuQBqPcVgqot5uGaU4Mb+rW+rv4wl5EPbXGgdsaaZTGV4utHS7/a7VDZQn/QUc2xBtN2NMeESHuD/7YffwXzb3WrGWPtjFpl9lLFd4qIxyL49sf04uIJ6tzdJ+T8GwuD0tlgVa7qYqZvOPhxFWJWtJMU6YsgAymT9IeNUioa0hCDplAg/UmVrhySEDOo3EWEzVHNHLE900PtZADHwV27KlMGE+LjE7b+yloiR6nYsldz2+uMqI/A0bziqEqzi4uOjCfPLA4bmmBH7fBoRS+Gm2nvLJlEtKLFWR5fNprHoAZMsz562QJLYul86Tciu+t5hL7YsXl8BiaDHvHQ4aBk+xEFobF63SQv2F2eYXq3jvyeOubc0sbdMZNzB5gj/wcsUqvx0gKlIbZr3AnwwanXO76MXGZMowPPMoMgzmTXcYO3P+D2D0YLrqnuGHKXPlHhYxGFdxJRsrTFEMZaEcaqyfJdM3j0MVZjJDMUzjPIzI9HPD0IoRHoZlfDwOzzygD0MC/adKIf1tdYL3s9XiFuSriUyd5H3gap7iYFbUYjKZTCaTSRP/AEYn9FrTdrbUAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMA3yCAEGC/759AcFDPkDCvoI+BJCYaAAADo0lEQVRo3u2a2barIAyGCSQMjpX3f9izzunqoYoxbhD3jd9d6/CXEDJA1cPDw8PDw0MNYZkhxgh26VHdBhoXv/Ba3UPn4obljlGjjzlww6BtjL+iTHEfaG1tGxkW1RaIHIyx2wuPiqG1MKimvCJLW/cKvHCvmmJZYVJN0Y4T7lRbJs6/zOY+6vXFY36dEO6HusSlQ5hybzXiHC9VOTMsb6ta2j49Cl5tatKHtnyyx715DvuZxE0/06W190InLmdkwpugLE6j1cfL2SV/LkrWvP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UAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA3yBgv58Q74BwQK+PzzBQHgQBUQAAAqhJREFUaN7t2etu8yAMBmBO4ZgQ7v9qv2na+kpVEgKOqfQN/1vK+hRjE9KKGTNmzJgxYwY9VCrOKDE8lCxfIR+SYwjx3ki7le+Qz03iXvrW8hOe7tov9276QnlFJMO+lLuycoDpyyxvvBdyg1iocLk3CyzwU8u83ZKxwAhispdyS8YCYzC1m27JyMy6INn8MhbYCPxD5Jfj78tO4Q+MZZPRSTt6Hz3FJ6fXAr81v2aV0Umb/RmPoYwyOsm9rgfUGqNsfi+Ho2t8MmZ3NNwpLjmXQ0JjA+ORcXk/2Ws9s7yejlassrQY15BsuhwvbmyBUV6vBjvFJ9ujwRqNxiPXTxF6rIyxUg2WNW6Qg2Uke7CMZNvBssYZYayMZKvBsnLYOcfKHvU1WEYzD5YVmnmwjPoaK2OcEYNl/VR9GdUoy2dayhfZKOdHDiPWlWZ5wQDKhEurjJbypAl3yJ56l8Ijy9ZU21aSC9sgaS2yxuftCayWs439LInbl8eEW2QUdiBmOopGORP3TYc9qEVGrl2fm3GEapOR69wFa3RFq7zjQZpQW1k0y5mweSFfVjTLlnQQWVAhbTLqMlG6SYpWGWVt6HBdHgBXZCKM70tFh0wqrhVV3SLTq9pjq26QyX2M7Sf0fweoSXv1IrplRbw79cpOCFJZx145dcL6MtdaVeVAOHOdLlUosipb8imz7xkDbm+unTp6qSKTQp6usikccv1p15fCKWPKbn93eWVMuSR0c4TBJ0u8l1l1jDEsuMQp53IQQ+TwMdl/TE6fku32B+XlD1ZYdJ+SbRosI2K1xozgukte0lJXToCUiOaMTfvV2VPQw4bk3lGXtLo+9UbxSGS9Jim/p7KZVef6eTuIAQGZDNPlKMYF/TcZuiyVGB3Wy7ItSsyYMWPG/xD/AIrSnldXeREbAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEXRSTlMA5cgdcw7XjzlWrIFkup0rSDjdhakAAAKOSURBVGje7ZnbkqQgDEAj95va//+1W7u1NVGpHiEJPHEep0ZPJyYBERaLxWKxWPDRaXPphOnE7S8uwmTM9p9JZvT+YGAG6J1rRu9cM3rnmtE714zeuWb0zjWjl2vme5XaLhQYSLx5tUbz2Bl23r0Ad/MJg9Du4X2YnYYRoAS99R8HYGtFbbYgz1F7a/MB4pjKi2ZCO5MayZ2PYndDmqq+d4AHn2GlbdXvMZW6wOQLy7xVgAcxyvtt84aUERNr/5ZINeAx71Ujvcw1Jd/BoW0FMdJLUmn9gVo20eml9kWTXdo7VCvBAWbd6wNGAmmFfO3P3PXfHliEvlFolVR9paZEIx+hkEP3fbxMyBiws93j1TMCJswiIxFyrgN+R/FDto4yfCM/5HILmBByZJeWoe0LE5DQtIBBc3Nd6mHZ28uRmekAXQRmrt1PpgHpLC/eziMDUHMdWI/4A53gUlFYY8tCJ5aQLORg7J8UVhfj4oPREDunqD1047Eh+sF5yXkHWOIGOC2ROc9YSRSX4rwzJdYM4PTi3BkAmV4glrXfK/QlJlSLBPFq1m9m5CvR9y4WCOzUy60jFTV/zxar2UPdR6Qpu0TE0fbHodqP03PtaZcd/LdUTboqABGFR5ikl3mgEgknskXkYFF1n8hqxygtxPSemFnFChhRt5Pqd+8u9Ykgbk1m9CIBWPir+SXb+uo9RD8ofo9C/mNf2K5k2/gtPUh/nFfxSzFguNj2ImZUlypqjdqqk/gFhrgU9dV6bA88gLQZ5bvPxmSfcFJJejHbHRgQpLhmbwFRTtWmVRqEsbkpzRbkCelNmzDcmeoUYBwhf6syH2AsNvrKrXy0MAMd87Grf8r9yJ8TFovFYrFYcPgDfFESW2IpAiAAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g72AQn0Bwv4+vMM9QQt7wKQAAArJJREFUaN7tmtHOpCAMhbUgoqL2/Z92s5t/0/wtkRE4c8V3eTKZMy2lRZlpMBgMBoNBLS55n5zSdvb7OUFZ+C9+yWpAZv5hedRwvszzfy1mNKCvuNhfA/XFO1tf63IoDeVrXZLSwL7iEkhpYF9xccoZ5mudvdJAvsL285Hbau0snEH3q1lr7Zz8yCmbSmmNOM+PeCelrbQmHHEBcvaT1OwciItQkFpQWj2JPyBlljmBNlJ+O5PSABspv6mc0mo5PStKpT0rDVVYtphIaajCElZJttJes/ErNkm2aP06VnmZqXWZL34JZXYCYXZwfjfvSmseSWWc1JdosETbxK5KA1W0bVZOaS8InqsgJyFXTciDK1kl5Jo2ErkaCbmmvnbmtpCj0tABS3iX0sABS3iL0kC9w4bnlIYqaRteUhpuDwvB5podqGnZVhWUhistYZevUdojgZtxmcQ5cKYlr1Fp6ExLXrVWwnMzPhcBsHsIpx0UHMFLLKfaTWm4tiUc8lZEtPLTQ6fqiu+qi7gDV2ZOXN8wpkwn8gVj7kLuq4YxZo2tsf+asdPaMxfQGN9AUqaBpK+1zMWcAfFDYqkYEpE7ECvGYmCh7YC7aw1f1lfmKEPg5wipLae1EnenJV60hj/t+SC1xaIVWbtkeqLXT22xS6ad0cpQj9E0m9FUZulwtp12rnixSO2lFa2GfEKW4GatwUMmeaugrgjAqxwlZ7akgXs5ZVKWel0olu9iFqWB35NLUklpyJuB8kUM/k4i+MI47DuYZRAkpWGdpUtE6wvINuiPGdvnt6lb5nXVhvuDgL3wOJRWS5g/SnOw82WeGnE7F0jOnhR30eqJj9Z7tDfs+zL1IR6es9DqJu3r1zj1I8SVrOvvwG7/TwtTb9wyrxcRs6crzbdexXs/7nMaDAaDwWDwnj/NQlzrb+J5OQAAAABJRU5ErkJggg=="]},cleanMode:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAYN+fgL9AIO8QcFDPfzCQr49fa1RRAwAAAnlJREFUaN7t2NmumzAQgOHxvhEgnfd/17ZKDhMMSmobz+mR/F1Fraq/jAeywDAMwzAMwzB8N6EfHPBS+ORn4GRxY4CToLCED9jD4bYa8Q3hMOEfU+AMUxdRcYdXfFK8YYWbO2f4hi9uPGHqUpkrHDHziydsMednjrDz21/J7ZXrH3YvNXo9he5h83qV83b1qneYFnren3fsGxYUyjfc9gzTYml40jT6juFtmZaTp6fpFqYDlgE2QdL0O4UdTfV0/t71CdOgE+wkGnaXcKTFyiw07B5hQ3+Sm76GHa4P06QdkPyY79eFJ/iij4M+HoO7LGyy+2YCcjJs1SEMTk2TDh++e4Qrw5/R6mnusKPFZg3TJVveMJ2y4g3Tfe6Zw/TgdLxheq9IvGHaa8EdBnzQPyEsVvO0qr8Mhb3au7sLR33HAvLTjZwKtqKIhXORPukXPHMKxA/PTOgV1u/nNsE/c3oTxVGye+79oizAy3k6YlaKlp7VDWsemLN9ECf0UTjrVl0wlklnXbrgXrfTcW+dwbpfJBYsY7Kfjz1Wfjk3WCjQdkSDxJd1A5ay9NBo+Z0tYSlNO9XQBYWlTPb9sfR86Z8X8ie34RqgkMNyNt9KaWs+X5WL++0wAiqsWG79+k9LxElbqCKxnKeDClBpxhoOmkWsEaGZwRoKmmEVCa0sEtZDXrCOgEYT1lmgTUDCesgJa4XWT8PEKLXuLkotBonX2iNJ0ETu98Vm96rYD1dedsgOq8MGWogsnLK3IJuFLzvkNQuL7AOOexO20MBkYV0QTpeNWh/DkIWve5uIk5TSPCQAoV7cAOD5ctFaR4CotXhIMwzDMAzDMAz/j98ceskaOhA77AAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEnRSTlMA5VZzrI86yR0O12VHK4GeumR+Sig+AAAB1ElEQVRo3u3aYW+jMAyAYTuExEkItP//z550VHCVOGMzl02an6+b+i4hIRQNnHPOOed+KkoruNmAL7nAnQg3M9wp7OEMDA972MMe9vDvDkdgeNjDHvawhz38Xx72sIc9/H1hasNfLazGPZzDu8R8StG/XFIY4FCPFfERlC+XVBJ3cWZNeNKFA/u3N91S+upcx+2ntShGHDfLeGB4dzTVbxNyI2ImhGEbbnCnvIc7qNAUJFKBQ8+tu2iqZcgoNRIAs6wzKbpJluU/el7v7PSJbcy/tKcwtASqrtZotBP0ikG3ZNSbDMIjXtBOBkPCiba9yBQR61yAF9F6xJQlT0wJLyHBtZvsrzA+gVFFe66iXg3AwZdoPdO5y1bNDIym71YC3iQ5LGZ9OMielWs33kxZ9u2gFetdPIOJaH2z7LGKwos+fLqwPnRCzGePfLIRN9vFlcT/UjChWuKeZcSLr+jDD2ZIHbFOadXLyUVRG4twl0SyvXVhDvxZvAvW53FdhjCld+s8lLDEl4qIXb2hDBYdPdivMyUbh3eF39S9Xm6N/+qHKxe48jZm64Oq8mGgi+Vwfi7H01+5YuBFyVMDjfgJA5yj8LDO1qf8ZYSlVMA555xz7rv9AZlKFXj5dr43AAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAQCBggN+/nxDvcM8wkFCwoI+ASc+UAAACfUlEQVRo3u3Z7XajIBCAYWAAAVET7v9iN6my6CR0lmo+Np3nV3vSkzcKQmkFY4wxxhhj78EFfQVOPJDr05cgCpNmVjyQuo3IlEVRPDUsxePEV4UlhzmcfVy44zCHPzkMnx2GV4eHV4X1W4WVKDjMYQ6/fRh+TTiswnJ2TtkoVw7+FLqEVfqeFjecNsl3amc4JoKrnOq93BeWVFgKpEsz7/bdav0lwOzUmw1rI77glIU94XblFnXPDZdJMfw8HBTiBM3n8Eh+xuu4pYycw6MttKovAkZQhku3t4su0xlk8kJcwug5rtwvq8TBZKLKSneDFIeLxIN8BJVFuQCAgMLTkUX7zagPKGzEsxhqtc5gsnBk+ITCorhdtI07aNTLg0qtjJBnfRXo2blbTHZhspIZ8bTua5e0zAVLjBmtLMAeff/DsGrIzu9j18tHlaQ2GmgK+zzI9M6niU82pSYyXwv9G6cKQRLbWIMghCuXXxcVuebT8ArZ5xldv1ibB5eYfG2DPJBXbBIZ7lMjtdqSVf02Do76T08rWA2yrocjeUxq1ZU1p/r2LiWjZ6BqK3krs94nPNSeYWqRMamZ2+wT5jxGtTHfyd7MKuWY2o3EzECTqL+7YwcyQ+8T2O30Dbdhm9rZO+tsDwVu5HuNT1j7Bpk+7MC9M8VIJKh9IvOySvtkHPEwGV++vOjt3+9td+VX+4RvmY31hykot3n6DFpOYfPTU9PksPG2q9AQDShscbjsDU7V0QdMQOEJhU8ofNhfnCYUtv8YDnvDHoV7FB62r/uyT+wjEwobFNbb1w87LgW8geBlbzTLmV2Kq+XcBiB3ht0IMMqL6ARjjDHGGGP/qT+Hf7FSTq027wAAAABJRU5ErkJggg=="]},cleanTimes:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA378ggBAw78+fYECPcFCv86Xy/gAAAk9JREFUaN7t2WlPwzAMgGGnjnP2yP//tWgg0GavaVCOCpH3K1WfHWnjMpjNZrPZbDabzf5cZg8BYXTGq/TIBRgYBpd+8jAoCkt6aYURRZ9EBmQdvliZh77tKr3PQdd0Og16FtNNsL8LVv8OXu6C17tgfJYWNQ6G7ZtRHgEHwhDVJxsIAMAxuG8m7ObdWoMR/TkYg9Y7Qb6o143awto+DrQRMqFKj1ZqB9P34Raz7leOqmG5w6hTmRybLKpguaUqKtj+Yj0sb7dHwZyxNoKP9JyGN4X03NIFThuIjE3PHY3gcDUPI9vtdSOY2HkVigX9kqUy2MJVaJlM2XkuQBms4DLD5CM3OG/QDJayPl8BGlrCYOTbyr+keji/tOWCroelLJc2Oe42h6VMckGv0AOG7VVxyBe0hz4wc0QeKuAK2UEFXCE76gmDrnElXC8rhB6wlKXbHYY143aF4eCuRRgCo7yAx8B0F6w5rMbAxiaeHgGjTTLdB5ajrJS7wNKVbV1g6cpCF1i6sr0HLF2ZNV1gOdmpsDsm94GJMSieqhQ2gqXLH/uRyx1g//byMYnJzWF/csPYuNwY9qf7kWYyNYV1ZrJb+d8awjr7eTomN4Kla03+vuJbwVreG/Py2gaO1/uQ4RtGE/j6Z195UTWBXyeOpejrwBZw2WXq28Ou6MZEruhfbAf78HKFso0PVckFFX4zp6my8QZtyQ17+cWDDzr+EvMDtzL5k5UPaaTt43w7XGQ+347HgpOlA6EkMtEUHbdHhMtMjASz2Ww2m81ms9mIPgCfVZZTXlzW2AAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgCDf7xAwz0BwYL+fj1CvJC6qIwAAAtFJREFUaN7tmUlu7CAURelbg9n/av/kKyX7GnjGppRInGmED/AaoMIWi8VisVgsFou/gnE5hOAE+yIi7Lb8YLesGTLBassZFR2bjNjKNXPVmpc6cV64hSwtlGdz4KUHZ8BUL5rne+ebfaERXva6QkSKd+tIQvHw7FxIEczb1ABv4lPaqhx5dcnHj++Hb4s4b8m5nbnpGOUXxYcGnRiwH8xuzk5L3eul/jWvgPU0N3t/TRzKh9ifWpzStTghGAzJPAXd0TjOvatWsWGXxPJB4ZbJ/rEpIp7qHD7azutq+2mYtb3oubmfOBuuGL1FiWbFYqTkz0jTWzHGWCvCEcKvDzhh/4/LrIItHyyk5qkLIKFaFTyqYrkgtZit1VATu8CogZ6LdeybJxvvXiLl6P3EtO8QHhN66Hjrl7E9mQ0m9Ogh45oTFrJ5O+IP7osbTBjM1dQO4B1MLaVZ17xDQoOXRIR66Zl57Q9p/MotGMXsbyc0IlR/KG6pgeToeBELC6aYpcCEtvqON0HwiGb3zOuhUKrkAox7HUSuQXjv0SUU5CrF/Nwrbyaln+ClBYm/4dUSBg+a1T2vhcGDZmVu7bOFwaNmdy++w5NW5wKe40XkSRy/5HWYWjO9OPbD/kXv0HFo1HPvyEXLPfBq8NLNAZrdvZ4zavYPvaNm/qS5x9LCT/NuJ1Hey4HwHW/ALchTvAk2ltwQtideDi8Gmhm9asCLTdLAYrql4B94rSaXJ5ZCGPdKQU+chPeVxK/wWTebDkYytcyu3CCd1KGzV7bxbI/lDrb5cuF4YlWHa7IT16RV9endf52bm+JYD2FEL35fQIiJSIhg5znpK/ddcVOsQEz7ERVDJcdXvHdbIkbEQEUQSZViCrRfNCJuRR9s41u9kDC18XnvFX2j3bHLR/A2zSqzAzpzGh/tYdKy29xFhH9cPsZkxwho5wRbLBaLxWKxWCx+I/8ANf2/u2NhQhAAAAAASUVORK5CYII="]},cleanOrder:{color:"#ffffff",fontFamily:Qm,fontWeight:"400",fontSize:10,gapRight:2}},selectionIndicator:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGBAMAAACDAP+3AAAALVBMVEUAAAD///////////////////////////////////////////////////////+hSKubAAAADnRSTlMAEN+AIO/Pn2AwUI+/cOwbbqMAAAEBSURBVEjH7dJBTsJAFMbxj0Ci4GZCjF7AdeMJTHXjBdy4afQCRC9gOEHjxj1H8AiewCOwKGmBEL4zwLSEB0x5bweb/nZdzL+vb4pG43w6MSy3LEbQtQbkErobkpkzM+TIzJBDaL5odi7o5c7OzKC4Yun+4DseseOB3gR7elH+KU/t2kxKZk7PtBKSf3qmx7WFmsHl9qBkfhF05GRKbxrcYERvKE1+4NCY3vxoRmbI4m3mHZVws3fAD73CHb3ozHUTyQQG9N4kU6NfjZps3lmrE7G0mb3eEyuSCXWNTCnVM6W2lZE98sX+0/NvaP659gpVX83IHmcwPCdFDMu1Q6NxeivVcQUNhbcOPQAAAABJRU5ErkJggg==",iconWidth:14,iconHeight:14,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg=="],opacity:.1,scale:.2},enableElasticScale:!1,elasticMinScale:.6,elasticMaxScale:1.5},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{visible:!0,color:"#ffffff",width:.5},transitionPath:{visible:!1,color:"#ffffff",width:.5},chargePath:{visible:!1,color:"#ffffff",width:.5}},carpet:{src:"data:image/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VVVVhDw4EAAAAAID8XxtBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVXagwMSAAAAAEH/X/cjVAAAAABgINYXbaeVmwi+AAAAAElFTkSuQmCC",framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]},pulseCircle:{size:12,color:"#4cd964",strokeWidth:0,strokeColor:"#ffffff",duration:1e3,sizeFixed:!1,minScale:.5,maxScale:1,minAlpha:.5,maxAlpha:1}},chargingStation:{icon:{sizeFixed:!1,width:8,height:8,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAaVBMVEUAAAA3yFI4x1E3yFM4x1Q3yFI4x1I3yFM3ylVAz1BEzF44yFI3ylI3yFI2yVNGzF9GzGA3yFM4x1JKzWJY0nB62or///83yFL///+b46hQz2jN8dRp1n1Ey13y+/SC3ZPm+Om06r6n57PA80FIAAAAF3RSTlMA3yC/QO9grzAQ75+PcFDfz8+Ar2AwEAVwkmAAAANrSURBVGje1ZtpktowEEZbkiVvmG1m+Ixg1vsfMqnUVPWPkLG6W+DKu8CrJ7UBG5nEnLrtsQ1h5yIwOLcP45ReerovXWoPuIlrJ0/3wad2wI/Ep1S/PLUoIjQ13X4cUEzcNJW0TYCQUEP9zNpHqr2DHLvajzCwUY9ZcjARJ13uAWaCl3u3DhWI4p0+opTrwk7LlnmHYi74mb2/z0V0nbGAKzZ3DoLgRTFcVzhWUeB9n+daI5Yg4aNEDKRlbwOIgsvE2C7ub5QFl4pjV2WeOZjFgtk2e1/fWGwz7yHiPAvE2P3buwFkwSIxjtaB5mAWW0bb80ALglms3uYARhAsEONwyzuBEQSzWPkJ1kcwgmCZ2Hn1RHOwRoxRPdEcrBLDKyeLg5ViZw5WivFsDFaLgyn4a1aL0RiC82wQB0Pwp0UMr76G82wSj+oPrU+beNCudJ5tYiTlaF2s4vZ7pSHjOpvEPF4JMi42Ma/1EwRwsFbMay2c6YtNzHPtIYCDTWJ08p88F6OYN7mFAA7WinmTHSRc6ogP0quYg5nzDV6xwIleIOEyF3EpmK4kCy7jWnA3M60SjCONAu97tWC0oq+mj2rBCLR/bDCL3SrB2JFbJRiOBhTyWjMYkVDKuWYwQMXBb1WCWRzXCR7IrRPsaPfYYBaHVYKxp7BKMAK1qwRjpOMqwZhou0owEnWrBOOFTljm/fw3X6Zg9EQHqMimYCf+Qc9iU3ArvktlsSUY029xBxVZG8x35gM0ZEtwJFJvcrYEPxGpNzlrg/lRhIeGbAhGT/q1zobgQKRf66wL5ue32rnO+uDY0zcj5GRVMB+UUI9XVgej0TwoZ7E6OKj+GmCxJdiSnC3BzDOkZFMw4yAk24L1g52twdprOSuvYfPpvGz80GISRGRV8EQ3OEBCVn8tGRc7K4Kjp5tsISArghvbQT0Wc7Buopkdisni4H2dQ0ZZEFz1eFPmYInXfpAsy4Jjxw7baGdZcFPtsGAWPgAooIlFYkFw3FY8EJrLg11X8whsLg52ksO3+2VxafDOk4TNorgw+CiQ8oiZcVsS4wPMHDxpmKIxN5GSfgMDo6/7OoroInq4Ojz/vy/h/FFvBGM2jJ7q0Zdmt4lq06enuNDapru91za1Djc5tKmj+9K/pGkMe+cGILpdCO1x251Iyi/g4vimU9Z1kQAAAABJRU5ErkJggg=="},rotationCorrection:0,ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]}},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enableDoubleTapZoom:!0},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",rotateIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",scaleIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",moveIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",moveButtonOffset:30,textFontSize:12,textFontFamily:Qm,textFontWeight:"400",forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",showRotateButton:!0,textColor:"#ff4444",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},forbiddenMopZone:{minSize:1,iconWrapperFillColor:"#fe8a07",strokeColor:"#fe8a07",strokeWidth:2,fillColor:"rgba(254, 138, 7, 0.1)",outlineOffset:16,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",showRotateButton:!0,textColor:"#fe8a07",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:16,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},spot:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAAqFBMVEUAAAD////////////////////////////////////////////////09P////+vt//Kzv/f4f/z9P/y8//o6P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buWmYQnfEYSnvAZSSjjoxPaB0JD+fY6EppUXy4TmsoHhKbyAaGpfEBoKt8noV/zfAV8xhH653yGEV7gM4rwIp9BhFf4jCG8ymcI4Rd8RhB+yWcAoYTv2wl18wGhqXxAaCofEJrKB4Sm8gGhqXxAaCqfZXWkhD5tftUaoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8QGgqHxCaygeEpvIBoal8n4TG8u0JDefbExrOtyc0nG9PaDjfntBwvj1h03z/ABD9FUIpArU6AAAAAElFTkSuQmCC",iconSize:8,size:1,strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",showText:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0],showIcon:!0},normal:{isDashed:!1,dashArray:[0,0],showIcon:!1}},wayPoint:{showOrder:!0,normal:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////+Kior///+ZmZmRkZHw8PDFxcXT09Onp6fq6uq2trb4+Pjx8fG9vb2goKDi4uLMzMyvr6/39/fg4OC+vr7b29uYmJjRFtxTAAAAEnRSTlMAIN+A778QcGDPMJ9AkKCwUH/CxK06AAAEhUlEQVR42u2biZLaMAyGc5BACEcrxXEOjgW2u+//hjUsRdPJDLEti810+j3BP9Kvw04ccVgu0nKbJDM0zJIiK9Mfy+gbyBfr4iZiQLb+kUcvJP6Z4VOyeRy9hHyeoQXFQl7PqpyhLaWsnNXfQakb3Z8/PxUY1Oex7fVH93e6VhEhJ2X3fmgVEER7eEcik4lOXpKSxgh5xrnZiSZr/vDK+0HBKKp/JCyZR2GJs4eUFixpm4ecWCAsJMWO6o+cWbjg5Gv8Yt+CI+c9frEOlaLiblsNHuigqVomeKOrwItqH07N8m6XExB+wZmxJ/rinqIeGPQXvLEIomVPKWKkiqlmSVrCqGFkKv7yS6eAjeqYvokT0hJADa+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QFfkfLf5QIQTC38XashLQ37jThfzRS0PAZDQ1rYr9X5ak60NLC18NVoAM0YjoGHptY+w1FKzSS0GDUT0mLUTEiLUTMhLUbNhLQYNRPSYtSE0fIbFg3xTdS8kE8AAAAASUVORK5CYII=",iconSize:32,orderText:{fontSize:10,fontFamily:Qm,fontWeight:"600",color:"#8a8a8a"},orderContainer:{size:12,backgroundColor:"#ffffff",offsetY:20,offsetX:0}},editing:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAdVBMVEUAAAD/////////////////////////////////////////////////////////////////RET/////W1v/6Oj/oqL/ubn/c3P/UFD/8/P/3Nz/ior/0ND/5+f/ra3/f3//T0//lZX/lpb/Z2f/xcX/9PT/aGguCk8uAAAAEXRSTlMAIN+A77+fEHDPMEBgkLBfUGJvpxAAAASDSURBVHja7ZyJkpswDIa5Cbla2WAI5Gqyu+//iCUhjaYzmdhGEst0+j3BP9KvwyZOQGG5jrNtFCWqJ4mKNIt/LoNvIF9vikS9It38zIMJCeNUvSVdhMEk5ItUOVCs5fWsskS5ksnKWf0dlNJU3UnrM/Sc9bXuqo/273StAkROym5/qc/wivqyV0gqE508QyUGhbzkZHaiyVo8vbK/nMHKuXsmLFoEvITpU0oNjtTmKScUCAtKcUP/kZPwBSffqIFDDZ6cDmpgw5Wi4mHbCkZQsaZqGak7rYZR6AOfmuXDLke4QwhOQp7oPx4p6oBA9+g6P1i0HDSQ0AcGNUvUwqOGkKlw8Et7BjJNS/RNGKEWBjW0mkItjGqKcTvpZvDLGZhoDuN78eKNd0kuXow1704DI3p3N3E40jAdsNIN29+4JFXAzBET5VvVB2CnvSfKr6KGfRcNw2ybzCswMknCEe5zhEkxSewcPD28UjdOIEKNoXEPjAEh9l6hCd3dKx+aTC4wGJrMJzA1iFF79Jq16mlBkL17Gy5wKAlxQQu7ZGnXgCDNvQ2HriPSgChG9cSuTeYEotSOecrVDZAD82Svp5+qZw9yYD2t3dbwXyDMxW01T107Ht00RWADLSNJc2/CTqfrFsQp8eRt8e8HiGNcHBzjvilK5dL2MvfBRD9BZbMoJoCT6tm6jOwriKNVT+RyqtXggryYRPU0IAo2mln0vB5147+Yf0HMrKopcu8z8jvEVn4Dxg6czmLR+7PqzeCgcuMDD5WWq5kSxGldbiJyNck8aJTTWaWYxMEnLCarg48gjEH/Wk2zA2FKt8urPJlg17sOC4SddIKV3AxLp531BHkqHweVOeTJ41IvEz/HGffrzpV039M+F8GFsIUr3GXsxPQrRrp90cKie0Tn96EyFh3dpbt9cXR3IEKn8BLYiYwaGnpgkFA9XfPtgelDI1VQzSMws/hiWvkGBnuNBma08g0M9hoDzJhxv6GJJb7HXRXeK/qQRwI3wqVlKlmG9y9+966DEaTcHtaf6F5fwoT5a4/BsvYn5k1Uh+4dQ8GZKG1xr5uH9zNI0o0NX6IuhCRhs+FJlP58Jun7E1VikqiJOgKRCpNEoeCYUbWiJwlbX9mQDINJIrKg2+YDfypIZUut7wo3KjJ5RLPNF9sv/bG+S00yzDKgQ7dNi1XNQ4rdZpxhtgEfeTTWxJc3hqE9Etld/Y8m2GH4WIwysS4tHYY0pNpGyLzyJj4q/ETASxj5nr8ri3npJlad3wKehIEIa+VTUvoTzStB7FFSukTzypAp1+WmGbRsAjnywnVKta6FRC8pYy1qj0IiPwarGIua/kyusmtRy0CctbK1m05hUUsTq/dr6JfCopYnftv8vj4n1ILtRr9pdlkwGQWqea2lCKYjRzUvtUTT/mdG9HLXakpKg6GrYXxFSn+XC4AQtdB3LYNaDPmNOF3NHLQ8B4NBLR6X8VJqjrg0kLXQ1VQAFWE4Mg/NqiIMR3Y1s9DSq5mRll7NjLT0amakpVczIy29mhlp6dXwaPkN5W7InuRCZwAAAAAASUVORK5CYII=",iconSize:38,orderText:{fontSize:14,fontFamily:Qm,fontWeight:"600",color:"#ff4444"},orderContainer:{size:16,backgroundColor:"#ffffff",offsetY:23,offsetX:0}}}},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!1,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:window?.devicePixelRatio||1}},ty={dividingRoomId:-1,enableRoomSelection:!1,enableInteraction:!0,enableMapClickCapture:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingVirtualWallIds:[],editingSpotIds:[],editingWayPointIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",mapRotation:0,selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showPath:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1,showRobotPulseCircle:!1,unit:"meter",unitLabel:"m"},ey=["areRoomsAdjacent","getForbiddenSweepZones","getForbiddenMopZones","getCleanZones","getVirtualWalls","getSpots","getWayPoints","getViewportCenterPoint","getMapCenterPoint","getWallPointsByViewportCenter","getForbiddenSweepZonePointsByViewportCenter","getForbiddenMopZonePointsByViewportCenter","getCleanZonePointsByViewportCenter","getSpotPointByViewportCenter","getEffectiveDividerPoints","getDividerEndPoints","isNearChargerOrRobot","isPointInAnyRoom","isWallIntersectsAnyRoom","isZoneIntersectsAnyRoom","resetPanZoom","snapshot","snapshotByData"],iy=["onMapFirstDrawed","onMapDrawed","onPathDrawed","onRoomPropertiesDrawed","onClickRoom","onClickRoomProperties","onRemoveForbiddenSweepZone","onRemoveForbiddenMopZone","onRemoveCleanZone","onRemoveVirtualWall","onUpdateForbiddenSweepZone","onUpdateForbiddenMopZone","onUpdateCleanZone","onUpdateVirtualWall","onUpdateSpot","onUpdateWayPoint","onUpdateDivider","onClickForbiddenSweepZone","onClickForbiddenMopZone","onClickCleanZone","onClickVirtualWall","onClickSpot","onClickWayPoint","onClickDetectedObject","onClickCustomElement","onClickMap"],sy="MAIN",ny=5e3;class ry{static contextStack=[];static instanceMap=new Map;static serviceCache=new WeakMap;static registerInstance(t,e){this.instanceMap.set(t,e)}static unregisterInstance(t){this.instanceMap.delete(t)}static getService(){const t=this.useContext();let e=this.serviceCache.get(t);return e||(e=new oy,this.serviceCache.set(t,e)),e}static provide(t,e){this.contextStack.push(t);try{return e()}finally{this.contextStack.pop()}}static async provideAsync(t,e){this.contextStack.push(t);try{return await e()}finally{this.contextStack.pop()}}static useContext(){const t=this.contextStack[this.contextStack.length-1];if(!t){const t=this.instanceMap.get(sy);if(!t)throw new Error("No MapApplication context found. Make sure you are calling useAppService() within a MapApplication context.");return t}return t}static hasContext(){return this.contextStack.length>0||this.instanceMap.has(sy)}static clear(){this.contextStack.length=0,this.instanceMap.clear()}}class oy{getApp(){return ry.useContext()}getConfig(){return this.getApp().config}getDebuggerMode(){return!1}getRoomData(t){return this.getApp().managers.roomsManager.getRoomPropertyById(t)}metersToPixels(t){return this.getApp().metersToPixels(t)}pixelsToMeters(t){return this.getApp().pixelsToMeters(t)}metersToDisplayUnit(t){const{unit:e}=this.runtimeSnapshot;switch(e){case"feet":return 3.28084*t;case"centimeter":return 100*t;default:return t}}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}get gloalConfig(){return this.getConfig().global}get mapConfig(){return this.getConfig().map}get roomConfig(){return this.getConfig().room}get heatMapConfig(){return this.getConfig().heatmap}get pathConfig(){return this.getConfig().path}get carpetConfig(){return this.getConfig().carpet}get robotConfig(){return this.getConfig().robot}get chargingStationConfig(){return this.getConfig().chargingStation}get interactionConfig(){return this.getConfig().interaction}get controlsConfig(){return this.getConfig().controls}get dividerConfig(){return this.getConfig().divider}get detectedObjectConfig(){return this.getConfig().detectedObject}get snapshotConfig(){return this.getConfig().snapshot}get appContainer(){return this.getApp().components.appContainer}get interaction(){return this.getApp().components.interaction}get viewportContainer(){return this.getApp().components.viewportContainer}get mapManager(){return this.getApp().managers.mapManager}get pathManager(){return this.getApp().managers.pathManager}get heatmapManager(){return this.getApp().managers.heatmapManager}get controlsManager(){return this.getApp().managers.controlsManager}get detectedObjectManager(){return this.getApp().managers.detectedObjectManager}get customElementsManager(){return this.getApp().managers.customElementsManager}get roomsManager(){return this.getApp().managers.roomsManager}get runtime(){return this.getApp().runtime}get runtimeSnapshot(){return function(t){const e=zm.get(t),[i,s]=e;return Xm(i,s())}(this.getApp().runtime)}isInteractionEnabled(){return this.runtimeSnapshot.enableInteraction}get events(){return this.getApp().events}get baseScale(){return this.getApp().components.interaction.targetScale.x}get currentScale(){return this.getApp().components.appContainer.scale.x}get emitter(){return this.getApp().emitter}getChargerPosition(){const t=this.mapState;return t?{x:t.charger.x-t.origin.x,y:t.charger.y-t.origin.y}:null}getRobotPosition(){const t=this.pathManager.robot;return t?t.getCurrentPosition():null}}class ay extends Xn{viewportBounds={x:0,y:0,width:0,height:0};maskGraphics=null;containerElement=null;constructor(t,e){super(),this.containerElement=e||window,this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(t){const{containerTop:e,containerLeft:i,containerWidth:s,containerHeight:n}=t,{width:r,height:o}=this.getContainerSize(),a=this.parseSize(i,r),h=this.parseSize(e,o),l=this.parseSize(s,r),c=this.parseSize(n,o);this.viewportBounds={x:a,y:h,width:l,height:c}}getContainerSize(){if(!this.containerElement)return{width:window.innerWidth,height:window.innerHeight};if(this.containerElement===window)return{width:window.innerWidth,height:window.innerHeight};const t=this.containerElement;return{width:t.clientWidth||window.innerWidth,height:t.clientHeight||window.innerHeight}}createMask(){this.maskGraphics=new Ll,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(t,e){if(!isNaN(Number(t)))return Number(t);if((t=t.trim()).endsWith("%"))return e*(parseFloat(t)/100);if(t.endsWith("vw")){const e=parseFloat(t)/100;return window.innerWidth*e}if(t.endsWith("vh")){const e=parseFloat(t)/100;return window.innerHeight*e}return t.endsWith("rpx")?parseFloat(t)*(window.innerWidth/750):t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(ng.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(t){this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.maskGraphics?.clear(),this.maskGraphics?.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const hy="roomFill",ly="free",cy="roomFloorType",dy="carpet",uy="obstacle",py="heatmap",gy="path",fy="controls",my="roomInfo",yy="detectedObject",xy="customElement",by="customElementGif",vy="chargingStation",_y="robot",wy=["interaction",hy,ly,cy,dy,uy,py,gy,my,yy,xy,by,vy,_y,fy];class Ay extends Xn{layers=new Map;mapRotation=0;constructor(){super();const t=Yi().getApp().getViewportBounds();this.position.set(Math.round(t.width/2),Math.round(t.height/2)),this.pivot.set(0,0),this.initializeLayers()}initializeLayers(){Object.values(wy).forEach(t=>{const e=new Xn;e.label=t,t===fy&&(e.isRenderGroup=!0),t!==cy&&t!==dy||(e.eventMode="none"),this.layers.set(t,e),this.addChild(e)})}getLayer(t){return this.layers.get(t)}addToLayer(t,e,i){const s=this.layers.get(t);return s?(void 0!==i&&(e.zIndex=i),s.addChild(e),!0):(ng.warn("[AppContainer Debug] Layer not found:",t),!1)}removeFromLayer(t,e){const i=this.layers.get(t);return!!i&&e.parent===i&&(i.removeChild(e),!0)}clearLayer(t){const e=this.layers.get(t);return!!e&&(e.removeChildren(),!0)}setLayerVisibility(t,e){const i=this.layers.get(t);return!!i&&(i.visible=e,!0)}getLayerVisibility(t){const e=this.layers.get(t);return!!e&&e.visible}setMapRotation(t){this.mapRotation=t*Math.PI/180,this.rotation=this.mapRotation}getMapRotation(){return 180*this.mapRotation/Math.PI}getMapRotationRadians(){return this.mapRotation}}class Cy extends Ll{constructor(){super(),Yi().appContainer.addToLayer(uy,this)}draw(t){const e=Yi();this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const e of t){const t=e.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],s=t[e+1];this.rect(i,s,1,1)}}this.fill()}drawRaster(t,e){const i=Yi();if(this.clear(),0!==t.length){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let s=0;s<t.length;s+=ny){const n=Math.min(s+ny,t.length);for(let i=s;i<n;i++){const s=t[i],n=s%e,r=Math.floor(s/e);this.rect(n,r,1,1)}this.fill(),n<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class Sy{target;isPointerDown=!1;pointerDownPos=null;clickThreshold;stopPropagation;clickCallback=null;constructor(t,e={}){this.target=t,this.clickThreshold=e.clickThreshold??10,this.stopPropagation=e.stopPropagation??!1,this.clickCallback=e.onClick||null,this.setup()}setup(){this.target.interactive=!0,this.target.eventMode="static",this.target.on("pointerdown",this.handlePointerDown.bind(this)),this.target.on("pointermove",this.handlePointerMove.bind(this)),this.target.on("pointerup",this.handlePointerUp.bind(this)),this.target.on("pointerupoutside",this.handlePointerUpOutside.bind(this))}handlePointerDown(t){this.stopPropagation&&t.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:t.globalX,y:t.globalY}}handlePointerMove(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(t,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(t){return this.clickCallback=t,this}setClickThreshold(t){return this.clickThreshold=t,this}getTarget(){return this.target}isInteracting(){return this.isPointerDown}destroy(){this.target.off("pointerdown",this.handlePointerDown),this.target.off("pointermove",this.handlePointerMove),this.target.off("pointerup",this.handlePointerUp),this.target.off("pointerupoutside",this.handlePointerUpOutside),this.clickCallback=null}}class Iy extends Xn{roomGraphicsMap=new Map;roomContextMap=new Map;roomClickHandlerMap=new Map;unsubscribeFns=[];mapWidth=0;rasterRoomDataMap=new Map;constructor(){super({isRenderGroup:!0}),Yi().appContainer.addToLayer(hy,this)}draw(t){const e=Yi();this.clearRooms();const i=e.roomConfig,{selectRoomIds:s,enableRoomSelection:n}=e.runtimeSnapshot;t.forEach(t=>{const e=t.id>=255,r=new Ll,o=new fh,a=new fh;if(e)o.setFillStyle({color:t.color}),a.setFillStyle({color:t.color});else{const e=t.colorIndex??0,s=i.colors.active[e%i.colors.active.length],n=i.colors.inactive[e%i.colors.inactive.length];o.setFillStyle({color:s}),a.setFillStyle({color:n})}if(o.poly(t.polyPoints).fill(),a.poly(t.polyPoints).fill(),t.outlinePoints.forEach(t=>{o.rect(t.x,t.y,1,1).fill(),a.rect(t.x,t.y,1,1).fill()}),r.context=e?o:n&&!s.includes(t.id)?a:o,!e){const e=new Sy(r,{clickThreshold:10,onClick:()=>{this.handleRoomClick(t.id)}});this.roomClickHandlerMap.set(t.id,e)}this.roomGraphicsMap.set(t.id,r),this.roomContextMap.set(t.id,{activeContext:o,inactiveContext:a}),this.addChild(r)})}drawRaster(t){const e=Yi();if(this.clearRooms(),this.mapWidth=t.width,0===t.sortedRooms.length)return;const{selectRoomIds:i,enableRoomSelection:s}=e.runtimeSnapshot;t.sortedRooms.forEach(t=>{this.drawRasterRoom(t,s,i)})}drawRasterRoom(t,e,i){const{roomId:s,pixelIndices:n,activeColor:r,inactiveColor:o}=t,a=new Ll,h=new fh,l=new fh;h.setFillStyle({color:r}),l.setFillStyle({color:o}),this.drawPixelPointsInBatches(h,n,ny,this.mapWidth),this.drawPixelPointsInBatches(l,n,ny,this.mapWidth);const c="number"==typeof s,d=!e||c&&i.includes(s);if(a.context=e&&c&&!d?l:h,c){const t=new Sy(a,{clickThreshold:10,onClick:()=>{this.handleRoomClick(s)}});this.roomClickHandlerMap.set(s,t)}this.roomGraphicsMap.set(s,a),this.roomContextMap.set(s,{activeContext:h,inactiveContext:l}),this.rasterRoomDataMap.set(s,t),this.addChild(a)}drawPixelPointsInBatches(t,e,i,s){for(let n=0;n<e.length;n+=i){const r=Math.min(n+i,e.length);for(let i=n;i<r;i++){const n=e[i],r=n%s,o=Math.floor(n/s);t.rect(r,o,1,1)}t.fill()}}handleRoomClick(t){const e=Yi();e.events?.onClickRoom?.(e.getRoomData(t)??{id:t})}setRoomStateBySelectIds(t){const e=Yi(),{enableRoomSelection:i}=e.runtimeSnapshot;this.roomGraphicsMap.forEach((e,s)=>{if("number"==typeof s){const n=!i||t.includes(s),r=this.roomContextMap.get(s);r&&(e.context=n?r.activeContext:r.inactiveContext)}})}setRoomState(t,e){const i=this.roomGraphicsMap.get(t),s=this.roomContextMap.get(t);i&&s?"number"==typeof t&&(i.context=e?s.activeContext:s.inactiveContext):ng.warn(`Room ${t} not found`)}setAllRoomsState(t){this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&this.setRoomState(i,t)})}getRoomGraphicsMap(){const t=new Map;return this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&t.set(i,e)}),t}getRasterRoomData(t){return this.rasterRoomDataMap.get(t)||null}getMapWidth(){return this.mapWidth}isWallIntersectsAnyRoom(t){const e=Yi().getApp().mapState;if(!e)return ng.warn("[RoomFill] Map state not available"),!1;if(!t||2!==t.length)return ng.warn("[RoomFill] Invalid wall points provided"),!1;const[i,s]=t,n={x:i.x+e.origin.x,y:i.y+e.origin.y},r={x:s.x+e.origin.x,y:s.y+e.origin.y};return"raster"===e.mapType?this.isWallIntersectsAnyRoomRaster(n,r):this.isWallIntersectsAnyRoomStructured(n,r)}isZoneIntersectsAnyRoom(t){const e=Yi().getApp().mapState;if(!e)return ng.warn("[RoomFill] Map state not available"),!1;if(!t||4!==t.length)return ng.warn("[RoomFill] Invalid zone points provided"),!1;const i=t.map(t=>({x:t.x+e.origin.x,y:t.y+e.origin.y}));return"raster"===e.mapType?this.isZoneIntersectsAnyRoomRaster(i):this.isZoneIntersectsAnyRoomStructured(i)}isWallIntersectsAnyRoomRaster(t,e){if(0===this.mapWidth||0===this.rasterRoomDataMap.size)return!1;const i=this.getLinePixels(t,e);for(const t of this.rasterRoomDataMap.values())for(const e of i)if(hg(t.pixelIndices,e))return!0;return!1}isWallIntersectsAnyRoomStructured(t,e){const i=Yi().mapManager.getAllRooms();for(const s of i)if(s.outlinePoints&&!(s.outlinePoints.length<3)){if(gg(t,s.outlinePoints,!0)||gg(e,s.outlinePoints,!0))return!0;for(let i=0;i<s.outlinePoints.length;i++){const n=s.outlinePoints[i],r=s.outlinePoints[(i+1)%s.outlinePoints.length];if(Rg(t,e,n,r))return!0}}return!1}isZoneIntersectsAnyRoomRaster(t){if(0===this.mapWidth||0===this.rasterRoomDataMap.size)return!1;const e=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const[t,i]of e)if(this.isWallIntersectsAnyRoomRaster(t,i))return!0;const i=this.rasterRoomDataMap.values().next().value;if(i&&i.pixelIndices.length>0){const e=i.pixelIndices[0],s=e%this.mapWidth,n=Math.floor(e/this.mapWidth);if(gg({x:s,y:n},t,!0))return!0}return!1}isZoneIntersectsAnyRoomStructured(t){const e=Yi().mapManager.getAllRooms(),i=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const s of e)if(s.outlinePoints&&!(s.outlinePoints.length<3)){for(const e of t)if(gg(e,s.outlinePoints,!0))return!0;for(const e of s.outlinePoints)if(gg(e,t,!0))return!0;for(const[t,e]of i)for(let i=0;i<s.outlinePoints.length;i++){const n=s.outlinePoints[i],r=s.outlinePoints[(i+1)%s.outlinePoints.length];if(Rg(t,e,n,r))return!0}}return!1}getLinePixels(t,e){const i=Yi().getApp().mapState;if(!i)return[];const s=i.height,n=[],r=Math.round(t.x),o=Math.round(t.y),a=Math.round(e.x),h=Math.round(e.y),l=Math.abs(a-r),c=Math.abs(h-o),d=r<a?1:-1,u=o<h?1:-1;let p=l-c,g=r,f=o;for(;;){if(g>=0&&g<this.mapWidth&&f>=0&&f<s){const t=f*this.mapWidth+g;n.push(t)}if(g===a&&f===h)break;const t=2*p;t>-c&&(p-=c,g+=d),t<l&&(p+=l,f+=u)}return n}getZonePixels(t,e,i,s){const n=Yi().getApp().mapState;if(!n)return[];const r=n.height,o=[],a=Math.max(0,Math.floor(t)),h=Math.min(this.mapWidth-1,Math.ceil(i)),l=Math.max(0,Math.floor(e)),c=Math.min(r-1,Math.ceil(s));for(let t=l;t<=c;t++)for(let e=a;e<=h;e++){const i=t*this.mapWidth+e;o.push(i)}return o}clearRooms(){0===this.children.length&&0===this.roomGraphicsMap.size||(this.removeChildren(),this.roomClickHandlerMap.forEach(t=>{try{t.destroy()}catch(t){ng.warn("Error destroying click handler:",t)}}),this.roomClickHandlerMap.clear(),this.roomGraphicsMap.clear(),this.roomContextMap.clear(),this.rasterRoomDataMap.clear())}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class My extends Xn{carpetSprite=null;carpetMask=null;constructor(){super({isRenderGroup:!0}),Yi().appContainer.addToLayer(dy,this)}async createCarpetFromRasterData(t,e){const i=Yi();if(!i.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:s,opacity:n,scale:r}=i.carpetConfig,o=await pl.load(s);if(!o)return void ng.warn(`Carpet texture not found: ${s}`);const a=this.createCarpetGraphics(t,e),h=a.getLocalBounds();if(0===h.width||0===h.height)return;const l=new Hl({texture:o,width:h.width,height:h.height});l.x=h.x,l.y=h.y,l.alpha=n,l.tileScale.set(r);const c=new Xn;c.addChild(a),l.mask=c,this.addChild(l),this.carpetSprite=l,this.carpetMask=c,i.getApp().renderOnceNextFrame()}createCarpetGraphics(t,e){const i=new Ll;for(let s=0;s<t.length;s++){const n=t[s],r=n%e,o=Math.floor(n/e);i.rect(r,o,1,1)}return i.fill(16777215),i}clearCarpet(){if(this.carpetSprite){try{this.removeChild(this.carpetSprite),this.carpetSprite.destroy()}catch(t){ng.warn("Error destroying carpet sprite:",t)}this.carpetSprite=null}if(this.carpetMask){try{this.carpetMask.destroy()}catch(t){ng.warn("Error destroying carpet mask:",t)}this.carpetMask=null}}async createCarpetFromStructuredData(t){const e=Yi();if(!e.runtimeSnapshot.showCarpet||!t)return;if(this.clearCarpet(),0===t.length)return;const{src:i,opacity:s,scale:n}=e.carpetConfig,r=await pl.load(i);if(!r)return void ng.warn(`Carpet texture not found: ${i}`);const o=this.createCarpetGraphicsFromStructuredData(t),a=o.getLocalBounds();if(0===a.width||0===a.height)return;const h=new Hl({texture:r,width:a.width,height:a.height});h.x=a.x,h.y=a.y,h.alpha=s,h.tileScale.set(n);const l=new Xn;l.addChild(o),h.mask=l,this.addChild(h),this.carpetSprite=h,this.carpetMask=l,e.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(t){const e=new Ll;for(const i of t){const t=i.coordinates;for(let i=0;i<t.length;i+=2){const s=t[i],n=t[i+1];e.rect(s,n,1,1)}}return e.fill(16777215),e}destroy(){this.clearCarpet(),super.destroy()}}class Ty extends Ll{constructor(){super(),Yi().appContainer.addToLayer(ly,this)}draw(t){const e=Yi();this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const e of t){const t=e.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],s=t[e+1];this.rect(i,s,1,1)}}this.fill()}destroy(t){super.destroy(t)}}class Py extends Kn{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?ng.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?ng.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Yi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=t.currentScale;if(0===s)return;const n=e/s,r=i/s;this.scale&&super.scale.set(n,r)}else this.scale&&super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}async loadTextureAndSetSize(t,e){try{const i=Yi(),s=await pl.load(t);this.texture=s,void 0!==e.sizeFixed&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),i.getApp().renderOnceNextFrame()}catch(e){ng.error(`Failed to load texture "${t}":`,e)}}draw(t,e){const{x:i,y:s,rotation:n=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=n,this.position.set(i,s)}set texture(t){super.texture=t,this.isFixedSizeSet&&t&&t.width>0&&t.height>0&&this.applySize()}get texture(){return super.texture}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ey extends Py{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Yi();await this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)}async draw({x:t,y:e,rotation:i}){const s=Yi();super.draw({x:t,y:e,rotation:i},()=>s.runtimeSnapshot.showChargingStation)}}class By extends Ll{currentPosition=null;config;constructor(t){super(),this.setupAntiScaleListener(),this.config=t.config}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.handleScaleChange)}handleScaleChange=()=>{this.redraw()};draw(t){const e=Yi();this.currentPosition=t;const{size:i,color:s,strokeWidth:n,strokeColor:r,strokeDashed:o,strokeDashArray:a}=this.config;this.clear();const h=e.metersToPixels(i),l=e.getApp().toFixedSize(n);this.setFillStyle({color:s}),o&&a.length>=2?this.drawDashedCircle(t,h,r,l,a):this.circle(t.x,t.y,h).fill().stroke({color:r,width:l,cap:"round",join:"round"})}drawDashedCircle(t,e,i,s,n){const r=Yi();this.circle(t.x,t.y,e).fill();const o=r.getApp().toFixedSize(n[0]),a=r.getApp().toFixedSize(n[1]),h=2*Math.PI*e,l=o+a,c=Math.floor(h/l);if(0===c)return void this.circle(t.x,t.y,e).stroke({color:i,width:s,cap:"round",join:"round"});const d=h/c,u=d*(o/l);for(let i=0;i<c;i++){const s=i*d/e,n=(i*d+u)/e,r=Math.max(4,Math.ceil(Math.abs(n-s)*e/2)),o=(n-s)/r;for(let i=0;i<=r;i++){const n=s+o*i,r=t.x+e*Math.cos(n),a=t.y+e*Math.sin(n);0===i?this.moveTo(r,a):this.lineTo(r,a)}}this.stroke({color:i,width:s,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){Yi().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Ry extends Xn{chargingStation;ring;unsubscribeFns=[];constructor(){super();const t=Yi();t.appContainer.addToLayer(vy,this),this.ring=new By({config:t.chargingStationConfig.ring}),this.ring.visible=t.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new Ey,this.addChild(this.chargingStation);const e=Xi(t.runtime,"showChargingStationRing",t=>{ng.log(`[runtime] showChargingStationRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}async draw({x:t,y:e,rotation:i}){0!==t||0!==e?(this.visible=!0,this.ring.draw({x:t,y:e}),await this.chargingStation.draw({x:t,y:e,rotation:i})):this.visible=!1}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),super.destroy()}}class ky{obstacle=new Cy;free=new Ty;roomFill=new Iy;carpet=new My;chargingStation=new Ry;mapBounds={minX:0,minY:0,maxX:0,maxY:0};lastMapId=null;lastOrigin=null;lastSize=null;lastStatus=null;roomGeometryMap=new Map;rasterRoomPixelsMap=new Map;fourColorCache=null;carpetData=null;unsubscribeFns=[];constructor(){const t=Yi();this.validateColorConfig();const e=Xi(t.runtime,"enableRoomSelection",e=>{if(ng.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const e=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(e)}else this.roomFill.setAllRoomsState(!0)}),i=Xi(t.runtime,"selectRoomIds",t=>{ng.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),s=Xi(t.runtime,"showChargingStation",t=>{ng.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),n=Xi(t.runtime,"showCarpet",t=>{ng.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,s,n)}async drawMap(t){const e=Yi(),{id:i,obstacles:s,free:n,rooms:r,charger:o,carpet:a,status:h,origin:l,size:c}=t;this.clearComponents(),this.resetGeometryData();const d=this.processRoomsGeometry(r);this.roomFill.draw(d),n&&this.free.draw(n),s&&this.obstacle.draw(s),this.carpetData={type:"structured",carpetData:a},this.createCarpet();const u=this.mergeLayerBounds();Wi(u,this.mapBounds)||(ng.debug("[Map] Map bounds updated:",u),this.mapBounds=u,this.shouldFitMapToView(i,1===h,{x:l[0],y:l[1]},{x:c[0],y:c[1]})&&(e.getApp().fitMapToView(this.mapBounds),this.lastMapId=i,this.lastOrigin={x:l[0],y:l[1]},this.lastSize={x:c[0],y:c[1]},this.lastStatus=1===h));const p=((t.charger.angle??0)+e.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.coordinate[0],y:o.coordinate[1],rotation:p}),await e.roomsManager.refresh(),!0}async drawRasterMap(t,e){const i=Yi();this.clearComponents();const{id:s,width:n,height:r,charger:o,chargerDirection:a,status:h,origin:l}=e;ng.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,n),this.carpetData={type:"raster",carpetPixels:t.carpet,mapWidth:n},this.createCarpet();const c=this.processRasterData(t);this.roomFill.drawRaster(c);const d=((t,e,i)=>{let s=1/0,n=1/0,r=-1/0,o=-1/0;for(let i=0;i<t.obstacles.length;i++){const a=t.obstacles[i],h=a%e,l=Math.floor(a/e);s=Math.min(s,h),n=Math.min(n,l),r=Math.max(r,h),o=Math.max(o,l)}return t.rooms.forEach(t=>{for(let i=0;i<t.length;i++){const a=t[i],h=a%e,l=Math.floor(a/e);s=Math.min(s,h),n=Math.min(n,l),r=Math.max(r,h),o=Math.max(o,l)}}),s===1/0?{minX:0,minY:0,maxX:e,maxY:i}:{minX:Math.max(0,s),minY:Math.max(0,n),maxX:Math.min(e,r),maxY:Math.min(i,o)}})(t,n,r);Wi(d,this.mapBounds)||(ng.debug("[Map] Raster map bounds updated:",d),this.mapBounds=d,this.shouldFitMapToView(s,h,l,{x:n,y:r})&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=s,this.lastOrigin={...l},this.lastSize={x:n,y:r},this.lastStatus=h));const u=(a+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.x,y:o.y,rotation:u}),this.generateRoomGeometryFromRaster(t),await i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.fourColorCache=null,this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}shouldFitMapToView(t,e,i,s){const n=Yi(),{originChangeAutoFitThreshold:r,sizeChangeAutoFitThreshold:o}=n.getApp().config.map;if(this.lastMapId!==t)return ng.debug("[Map] Map ID changed, triggering fitMapToView"),!0;if(null!==this.lastStatus&&this.lastStatus!==e)return ng.debug(`[Map] Map status changed (${this.lastStatus} -> ${e}), triggering fitMapToView`),!0;if(this.lastOrigin&&i){const t=Math.abs(i.x-this.lastOrigin.x),e=Math.abs(i.y-this.lastOrigin.y);if(t>r||e>r)return ng.debug(`[Map] Origin change exceeded threshold (deltaX: ${t}, deltaY: ${e}, threshold: ${r}), triggering fitMapToView`),!0}if(this.lastSize&&s){const t=Math.abs(s.x-this.lastSize.x),e=Math.abs(s.y-this.lastSize.y);if(t>o||e>o)return ng.debug(`[Map] Size change exceeded threshold (deltaX: ${t}, deltaY: ${e}, threshold: ${o}), triggering fitMapToView`),!0}return!1}async createCarpet(){if(Yi().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:e}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,e)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const e=Yi(),{active:i}=e.roomConfig.colors,s=e.roomConfig.colors[Jp.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((t,e)=>Number(t)-Number(e)),r=n.filter(t=>Number(t)<255),o=n.filter(t=>Number(t)>=255),a=[],h=[];r.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const s=i.filter(t=>!isFinite(t));if(s.length>0)return void ng.error(`[Room ${e}] Contains ${s.length} invalid coordinates (NaN/Infinity)`);const n=Number(e);let r=1/0,o=1/0,a=-1/0,l=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],s=i[t+1];r=Math.min(r,e),o=Math.min(o,s),a=Math.max(a,e),l=Math.max(l,s),c.push({x:e,y:s})}const d=a-r,u=l-o;if(0===d||0===u)return void ng.error(`[Room ${e}] Degenerate polygon (${d}x${u}). Skipping.`);if(d<2||u<2)return void ng.warn(`[Room ${e}] Room too small (${d}x${u}), skipping`);const p=new Ss(r,o,a-r+1,l-o+1),g=rg(c),f=g.flatMap(t=>[t.x+.5,t.y+.5]),m=lg(g,r,o,a,l);h.push({id:n,points:c,outlinePoints:g,polyPoints:f,centerPoint:m,boundingBox:p}),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,a),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)});const l=[...h].sort((t,i)=>{if("area"===e.roomConfig.colors.sortBy){const e=t.outlinePoints.length;return i.outlinePoints.length-e}return t.id-i.id}),c=this.assignColorsUsingFourColorAlgorithm(l,i.length,"structured");return h.forEach(t=>{const e=c.get(t.id)||0,s=i[e],n={id:t.id,color:s,colorIndex:e,boundingBox:t.boundingBox,points:t.points,outlinePoints:t.outlinePoints,polyPoints:t.polyPoints,centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,n),a.push(n)}),o.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const n=Number(e);let r=1/0,o=1/0,h=-1/0,l=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],s=i[t+1];r=Math.min(r,e),o=Math.min(o,s),h=Math.max(h,e),l=Math.max(l,s),c.push({x:e,y:s})}const d=h-r,u=l-o;if(0===d||0===u)return void ng.error(`[Unknown Room ${e}] Degenerate polygon (${d}x${u}). Skipping.`);if(d<2||u<2)return void ng.warn(`[Unknown Room ${e}] Room too small (${d}x${u}), skipping`);const p=new Ss(r,o,h-r+1,l-o+1),g=rg(c),f=g.flatMap(t=>[t.x+.5,t.y+.5]),m=lg(g,r,o,h,l),y={id:n,color:s,boundingBox:p,points:c,outlinePoints:g,polyPoints:f,centerPoint:m};a.push(y),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,h),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),a}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=kg(t,this.obstacle.bounds)),this.free.bounds&&(t=kg(t,this.free.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=kg(t,{minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}isWallIntersectsAnyRoom(t){return this.roomFill.isWallIntersectsAnyRoom(t)}isZoneIntersectsAnyRoom(t){return this.roomFill.isZoneIntersectsAnyRoom(t)}areRoomsAdjacent(t){const e=Yi(),i=e.mapConfig.adjacencyThreshold;if(!t||0===t.length)return ng.warn("[MapManager] No room IDs provided"),!1;if(1===t.length)return!0;const s=Array.from(new Set(t));if(1===s.length)return!0;const n=e.getApp().mapState;return"raster"===(n?.mapType??"structured")?this.areRasterRoomsAdjacentInternal(s,i):this.areStructuredRoomsAdjacentInternal(s,i)}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const e of t){const t=this.getRoomById(e);if(!t)return ng.warn(`[MapManager] Room ${e} not found in map`),!1;if(!t.outlinePoints||0===t.outlinePoints.length)return ng.warn(`[MapManager] Room ${e} has no outline points`),!1;i.push({id:e,points:t.outlinePoints})}const s=[];for(let t=0;t<i.length;t++)for(let n=t+1;n<i.length;n++){const r=i[t],o=i[n];Fg(r.points,o.points,e)&&s.push([t,n])}return jg(i.length,s)}areRasterRoomsAdjacentInternal(t,e){const i=Yi().getApp().mapState;if(!i)return ng.warn("[MapManager] Map state not available"),!1;const s=i.width,n=[];for(const e of t){const t=this.getRasterRoomPixels(e);if(!t)return ng.warn(`[MapManager] Room ${e} pixel data not found in raster map`),!1;n.push({id:e,pixels:t})}const r=[];for(let t=0;t<n.length;t++)for(let i=t+1;i<n.length;i++){const o=n[t],a=n[i];Lg(o.pixels,a.pixels,s,e)&&r.push([t,i])}return jg(n.length,r)}isPointInAnyRoom(t){const e=Yi().getApp().mapState;return e?"raster"===(e.mapType??"structured")?this.isPointInAnyRoomRasterInternal(t,e):this.isPointInAnyRoomStructuredInternal(t,e):(ng.warn("[MapManager] Map state not available"),null)}isPointInAnyRoomStructuredInternal(t,e){const i={x:t.x+e.origin.x,y:t.y+e.origin.y},s=this.getAllRooms();for(const t of s)if(t.outlinePoints&&t.outlinePoints.length>=3&&gg(i,t.outlinePoints))return Yi().roomsManager.getRoomPropertyById(t.id)||(ng.warn(`[MapManager] Room ${t.id} found in geometry but not in RoomManager`),null);return null}isPointInAnyRoomRasterInternal(t,e){const i=e.width,s=e.height,n=t.x+e.origin.x,r=t.y+e.origin.y,o=Math.round(n),a=Math.round(r);if(o<0||o>=i||a<0||a>=s)return ng.warn(`[MapManager] Point (${o}, ${a}) is out of map bounds (${i}x${s})`),null;const h=a*i+o,l=this.getAllRooms();for(const t of l){const e=this.getRasterRoomPixels(t.id);if(e&&e.length>0&&hg(e,h))return Yi().roomsManager.getRoomPropertyById(t.id)||(ng.warn(`[MapManager] Room ${t.id} found in geometry but not in RoomManager`),null)}return null}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new Cy,this.free.clear(),this.free.destroy(),this.free=new Ty,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new Iy}processRasterData(t){const e=Yi().roomConfig,i=[],s=[];t.rooms.forEach((t,e)=>{"number"==typeof e?i.push([e,t]):s.push([e,t])}),i.sort(([t],[e])=>t-e);const n=i.map(([t,e])=>({id:t,pixels:e})).sort((t,i)=>"area"===e.colors.sortBy?i.pixels.length-t.pixels.length:t.id-i.id),r=this.assignColorsUsingFourColorAlgorithm(n,e.colors.active.length,"raster"),o=[...i.map(([t,i])=>{const s=r.get(t)||0;return{roomId:t,pixelIndices:i,activeColor:e.colors.active[s],inactiveColor:e.colors.inactive[s%e.colors.inactive.length],colorIndex:s}}),...s.map(([t,i])=>{const s=e.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:i,activeColor:s,inactiveColor:s}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:o,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=Yi();this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=e.roomConfig.colors,s=[];t.rooms.forEach((t,e)=>{"number"==typeof e&&s.push(e)}),s.sort((t,e)=>t-e);const n=[];s.forEach(e=>{const i=t.rooms.get(e);this.rasterRoomPixelsMap.set(e,i);let s=1/0,r=1/0,o=-1/0,a=-1/0;for(let e=0;e<i.length;e++){const n=i[e],h=n%t.width,l=Math.floor(n/t.width);s=Math.min(s,h),r=Math.min(r,l),o=Math.max(o,h),a=Math.max(a,l)}const h=((t,e,i,s,n,r)=>{const o=new Set(t),a=((t,e)=>{let i=0,s=0;for(let n=0;n<t.length;n++){const r=t[n];i+=r%e,s+=Math.floor(r/e)}return{x:i/t.length,y:s/t.length}})(t,e),h=((t,e,i,s,n,r,o)=>{const a={x:s-10,y:t.y},h={x:r+10,y:t.y},l={x:r,y:n},c={x:r,y:o},d=Rg(a,h,{x:s,y:n},{x:s,y:o}),u=Rg(a,h,l,c);if(!d||!u)return null;const p=[],g=Math.max(s,Math.min(d.x,u.x)),f=Math.min(r,Math.max(d.x,u.x)),m=Math.round(t.y);for(let t=Math.round(g);t<=Math.round(f);t++){const s=m*i+t;e.has(s)&&p.push({x:t,y:m})}if(p.length>=2){const t=(t=>{if(!t||0===t.length)return{min:{x:0,y:0},max:{x:0,y:0}};let e=t[0],i=t[0];const s=t=>t.x-t.y;for(let n=1;n<t.length;n++){const r=t[n];s(r)<s(e)&&(e=r),s(r)>s(i)&&(i=r)}return{min:e,max:i}})(p),s={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},n=Math.round(s.y)*i+Math.round(s.x);if(e.has(n))return s}return null})(a,o,e,i,s,n,r);return h||a})(i,t.width,s,r,o,a),l=new Ss(s,r,o-s+1,a-r+1);n.push({id:e,pixelIndices:i,boundingBox:l,centerPoint:h})});const r=[...n].sort((t,i)=>"area"===e.roomConfig.colors.sortBy?i.pixelIndices.length-t.pixelIndices.length:t.id-i.id),o=this.assignColorsUsingFourColorAlgorithm(r,i.length,"raster");n.forEach(t=>{const e=o.get(t.id)||0,s=i[e],n={id:t.id,color:s,colorIndex:e,boundingBox:t.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,n)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}validateColorConfig(){const t=Yi().roomConfig.colors,e=t.active.length,i=t.inactive.length,s=t.name.length,n=t.propertyTheme.length,r=t.selectionIndicatorBackground.length,o=t.selectionIndicatorIcon.length;e<4&&ng.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${e}. Adjacent rooms may have the same color.`),i!==e&&ng.warn(`[FourColor] room.colors.inactive length (${i}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),s!==e&&ng.warn(`[FourColor] room.colors.name length (${s}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),n!==e&&ng.warn(`[FourColor] room.colors.propertyTheme length (${n}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),r!==e&&ng.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${r}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),o!==e&&ng.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${o}) does not match room.colors.active length (${e}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(t,e,i){const s=Yi(),n=s.mapState?.id??null;if(this.fourColorCache&&this.fourColorCache.mapId===n&&this.fourColorCache.colorMap.size===t.length)return ng.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const r=s.getApp().config.map.adjacencyThreshold||3,o=s.roomConfig.colors.strategy;ng.debug(`[FourColor] Starting algorithm for ${t.length} rooms with ${e} colors, strategy: ${o}`);const a=((t,e,i,s="priority")=>{const n=new Map;if(0===t.length)return n;if(1===t.length)return n.set(t[0].id,0),n;const r=new Map;for(let i=0;i<t.length;i++){const s=t[i];r.has(s.id)||r.set(s.id,new Set);for(let n=i+1;n<t.length;n++){const i=t[n];e(s,i)&&(r.get(s.id).add(i.id),r.has(i.id)||r.set(i.id,new Set),r.get(i.id).add(s.id))}}const o=new Array(i).fill(0),a=[...t].sort((e,i)=>{const s=(r.get(e.id)||new Set).size,n=(r.get(i.id)||new Set).size,o=t.indexOf(e);return.5*-t.indexOf(i)+.5*n-(.5*-o+.5*s)});for(const t of a){const e=r.get(t.id)||new Set,a=new Set;for(const t of e){const e=n.get(t);void 0!==e&&a.add(e)}let h=-1;if("priority"===s){let t=-1,e=-1/0;for(let s=0;s<i;s++)if(!a.has(s)){const n=i-s-.7*o[s];(n>e||n===e&&s<t)&&(e=n,t=s)}h=t,-1===h&&(h=0),o[h]++}else{const t=[];for(let e=0;e<i;e++)a.has(e)||t.push(e);if(0===t.length){let t=1/0,e=0;for(let s=0;s<i;s++)(o[s]<t||o[s]===t&&s<e)&&(t=o[s],e=s);h=e}else{h=t[0];let e=o[h];for(const i of t)(o[i]<e||o[i]===e&&i<h)&&(h=i,e=o[i])}o[h]++}n.set(t.id,h)}return n})(t,(t,e)=>{if("structured"===i){const i=t.outlinePoints,s=e.outlinePoints;return!(!i||!s)&&Fg(i,s,r)}{const i=t.pixels,n=e.pixels;if(!i||!n)return!1;const o=s.mapState?.width||0;return Lg(i,n,o,r)}},e,o);this.fourColorCache={mapId:n,colorMap:a};const h=new Array(e).fill(0);return a.forEach(t=>{h[t]++}),ng.debug("[FourColor] Color distribution:",h),a}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.fourColorCache=null}}class Oy extends Xn{commonPath;chargePath;transitionsPath;mopPath;debugPoints;pathData=null;lastPointCount=0;lastDrawnPosition=null;isRealTimeDrawing=!1;throttledUpdateLineWidth;throttledHandleRobotPosition;constructor(){super({isRenderGroup:!0});const t=Yi();t.appContainer.addToLayer(gy,this),this.eventMode="none",this.commonPath=new Ll,this.chargePath=new Ll,this.transitionsPath=new Ll,this.mopPath=new Ll,this.debugPoints=new Ll,this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.addChild(this.debugPoints),this.visible=t.runtimeSnapshot.showPath,this.commonPath.visible=t.pathConfig.commonPath.visible,this.chargePath.visible=t.pathConfig.chargePath.visible,this.transitionsPath.visible=t.pathConfig.transitionPath.visible,this.mopPath.visible=!1,this.throttledUpdateLineWidth=Ji(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=Ji(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=Yi();t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete)}handleRobotAnimationComplete=()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()};handleRobotPositionUpdate(t){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;let e;switch(t.pathType||"common"){case"common":default:e=this.commonPath;break;case"charge":e=this.chargePath;break;case"transitions":e=this.transitionsPath;break;case"mop":e=this.mopPath}e.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),e.lineTo(t.x,t.y),e.stroke(),this.lastDrawnPosition={x:t.x,y:t.y}}updateLineWidth(){const t=Yi();this.pathData&&t.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(t){const{pathPoints:e}=t;e&&0!==e.length&&(this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.setupPathStyles(),this.drawPathSegments(e),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPath.stroke(),Yi().getDebuggerMode()&&this.drawDebugPoints(e))}setupPathStyles(){const t=Yi(),e=t.pathConfig,i=i=>e.lineWidthFixed?t.getApp().toFixedSize(i):i;this.commonPath.setStrokeStyle({width:i(e.commonPath.width),color:e.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:i(e.chargePath.width),color:e.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:i(e.transitionPath.width),color:e.transitionPath.color,join:"round",cap:"round"}),this.mopPath.setStrokeStyle({width:0,color:0,alpha:0,join:"round",cap:"round"})}drawPathSegments(t){let e=null,i=null;for(let s=0;s<t.length;s++){const n=t[s],r=n.type||"common";let o;switch(r){case"common":default:o=this.commonPath;break;case"charge":o=this.chargePath;break;case"transitions":o=this.transitionsPath;break;case"mop":o=this.mopPath}0===s||r!==e?o.moveTo(n.x,n.y):o===i&&o.lineTo(n.x,n.y),e=r,i=o}}drawDebugPoints(t){const e={common:16711935,charge:65535,transitions:16776960,mop:65280};for(const i of t){const t=e[i.type||"common"];this.debugPoints.rect(i.x-.5,i.y-.5,1,1),this.debugPoints.fill(t)}}updatePositionByOrigin(t,e){this.position.set(t,e)}drawFull(t){ng.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=t.pathPoints?.length||0}drawIncremental(t){const e=Yi(),i=this.lastPointCount,s=t.pathPoints?.slice(i)||[];if(s.length>0)if(this.setupPathStyles(),ng.debug("[Path] Draw Incremental Path",s),e.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,i>0&&this.pathData?.pathPoints){const t=this.pathData.pathPoints[i-1];this.lastDrawnPosition={x:t.x,y:t.y}}}else this.drawNewPathSegments(s,i,t.pathPoints,this.pathData?.pathPoints);this.pathData=t,this.lastPointCount=t.pathPoints?.length||0}drawNewPathSegments(t,e,i,s){if(!i||0===t.length)return;let n=null;e>0&&(s&&s[e-1]?n=s[e-1]:i[e-1]&&(n=i[e-1]));let r=null,o=null,a=!1;for(let e=0;e<t.length;e++){const i=t[e],s=i.type||"common";let h;switch(s){case"common":default:h=this.commonPath;break;case"charge":h=this.chargePath;break;case"transitions":h=this.transitionsPath;break;case"mop":h=this.mopPath}s!==r||0===e?(o&&a&&o.stroke(),r=s,o=h,a=!0,n&&0===e&&n.type===s?(h.moveTo(n.x,n.y),h.lineTo(i.x,i.y)):h.moveTo(i.x,i.y)):h.lineTo(i.x,i.y)}o&&a&&o.stroke()}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}clear(){this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.pathData=null,this.lastPointCount=0,this.lastDrawnPosition=null,this.isRealTimeDrawing=!1}destroy(t){const{emitter:e}=Yi();e.off("antiScale",this.throttledUpdateLineWidth),e.off("robotPositionUpdate",this.throttledHandleRobotPosition),e.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.stopRealTimeDrawing(),super.destroy(t)}}class Dy extends Py{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Yi();await this.loadTextureAndSetSize("robot",t.robotConfig.icon)}async draw({x:t,y:e,rotation:i}){super.draw({x:t,y:e,rotation:i})}}class Fy extends zl{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;static animationTicker=null;static animatedSprites=new Set;constructor(t){super(t||[]),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet||this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet||this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||0===this.textures.length||!this.textures[0]||0===this.textures[0].width||0===this.textures[0].height)return;const t=Yi(),e=this.textures[0],i=this.fixedWidth/e.width,s=this.fixedHeight/e.height;if(this.sizeFixed){const e=t.currentScale;if(0===e||!isFinite(e)){const t=i,e=s;return void super.scale.set(t,e)}const n=i/e,r=s/e;super.scale.set(n,r)}else super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static async loadAnimationTextures(t,e,i="sleep_",s=96){try{const n=await fetch(t),r=await n.json();r.meta&&(r.meta.image=e),await pl.load(e);const o=Gs.from(e),a=new _r(o.source,r);await a.parse();const h=[];for(let t=0;t<s;t++){const e=`${i}${t.toString().padStart(3,"0")}.png`,s=a.textures[e];s?h.push(s):ng.warn(`[EnhancedAnimatedSprite] Frame not found: ${e}`)}return h}catch(t){return ng.error("[EnhancedAnimatedSprite] Failed to load textures:",t),[]}}setupAnimation(t){void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,ng.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(t,e){const{x:i,y:s}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.position.set(i,s)}play(){this.textures&&this.textures.length>0&&(super.play(),Fy.animatedSprites.add(this),Fy.startAnimationTicker())}stop(){super.stop(),Fy.animatedSprites.delete(this),Fy.updateAnimationTicker()}set textures(t){super.textures=t,this.isFixedSizeSet&&t&&t.length>0&&t[0]&&t[0].width>0&&t[0].height>0&&this.applySize()}get textures(){return super.textures}static startAnimationTicker(){Fy.animationTicker?.started||(Fy.animationTicker||(Fy.animationTicker=new lr,Fy.animationTicker.maxFPS=24,Fy.animationTicker.add(()=>{Fy.updateAnimations()})),Fy.animationTicker.start(),ng.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){Fy.animatedSprites.size>0?Fy.startAnimationTicker():Fy.stopAnimationTicker()}static stopAnimationTicker(){Fy.animationTicker?.started&&(ng.log("⏸️ [AnimationTicker] Stopped animation ticker"),Fy.animationTicker.stop())}static updateAnimations(){if(0===Fy.animatedSprites.size)return;const t=Yi().getApp();t.renderer.render(t.stage)}destroy(t){Fy.animatedSprites.delete(this),Fy.updateAnimationTicker(),Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Ly extends Fy{unsubscribeFns=[];throttledUpdateOffset;fixedOffsetX=0;fixedOffsetY=0;constructor(t){super(t),this.throttledUpdateOffset=Ji(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(){const t=Yi().robotConfig,e=await Fy.loadAnimationTextures(t.sleepAnimation.jsonSrc,t.sleepAnimation.imageSrc,t.sleepAnimation.framePrefix,t.sleepAnimation.frameCount);0===e.length&&(ng.warn("No textures loaded for sleep animation"),e.push(Gs.EMPTY));const i=new Ly(e);return i.setupAnimation({width:t.sleepAnimation.width,height:t.sleepAnimation.height,sizeFixed:t.sleepAnimation.sizeFixed}),i}initializeAnimation(){const t=Yi();this.visible=!1,this.fixedOffsetX=t.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=t.robotConfig.sleepAnimation.offsetY,t.emitter.on("antiScale",this.throttledUpdateOffset);const e=Xi(t.runtime,"showRobotSleepAnimation",t=>{ng.log(`[runtime] showRobotSleepAnimation: ${t}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const t=Yi().runtimeSnapshot.showRobotSleepAnimation,e=this.parent,i=!!e&&e.visible,s=e&&(0!==e.x||0!==e.y);return t&&i&&!!s}updateVisibility(){const t=this.shouldShow();t&&!this.visible?(this.visible=!0,this.textures&&this.textures.length>0&&this.play()):!t&&this.visible?(this.visible=!1,this.stop()):!t&&this.playing&&this.stop()}updateOffset(t){}draw(t){const e=Yi(),i=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetX),s=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetY),n={...t,x:t.x+i,y:t.y+s};super.draw(n,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(t){const e=super.visible;super.visible=t,t&&!e&&this.textures&&this.textures.length>0?this.play():!t&&e&&this.playing&&this.stop()}get visible(){return super.visible}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class jy extends Ll{currentPosition=null;animationStartTime=0;isAnimating=!1;constructor(){super(),this.setupAntiScaleListener()}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.handleScaleChange)}handleScaleChange=()=>{this.redraw()};draw(t){this.currentPosition=t,this.isAnimating||this.startAnimation(),this.redraw()}startAnimation(){const t=Yi();this.isAnimating||(this.isAnimating=!0,this.animationStartTime=Date.now(),t.getApp().ticker.add(this.updateAnimation,this),t.getApp().requestRender("pulse-circle-animation",!0))}stopAnimation(){const t=Yi();this.isAnimating&&(this.isAnimating=!1,t.getApp().ticker.remove(this.updateAnimation,this),t.getApp().stopRender("pulse-circle-animation"))}updateAnimation=()=>{if(!this.currentPosition||!this.isAnimating||!this.visible)return;const t=Yi(),e=t.robotConfig.pulseCircle,i=(Date.now()-this.animationStartTime)%e.duration/e.duration,{minScale:s,maxScale:n,minAlpha:r,maxAlpha:o}=e,a=s+(n-s)*(.5*Math.sin(i*Math.PI*2)+.5),h=o-(o-r)*(a-s)/(n-s);super.clear();const{size:l,color:c,strokeWidth:d,strokeColor:u,sizeFixed:p}=e,g=(p?t.getApp().toFixedSize(l/2):l/2)*a,f=t.getApp().toFixedSize(d);this.setFillStyle({color:c,alpha:h}),this.circle(this.currentPosition.x,this.currentPosition.y,g).fill().stroke({color:u,width:f,alpha:h,cap:"round",join:"round"})};redraw(){this.currentPosition&&this.isAnimating&&this.updateAnimation()}clearCircle(){super.clear()}remove(){this.stopAnimation(),this.clearCircle(),this.currentPosition=null}destroy(){this.stopAnimation(),Yi().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Gy extends Xn{robot;ring;pulseCircle;sleepAnimation=null;unsubscribeFns=[];targetPosition=null;targetRotation=null;isMoving=!1;pathQueue=[];lastPosition=null;currentPathType=void 0;lastUpdateTime=0;isCleared=!1;constructor(){super();const t=Yi();t.appContainer.addToLayer(_y,this),this.visible=t.runtime.showPath,this.ring=new By({config:t.robotConfig.ring}),this.ring.visible=t.runtime.showRobotRing,this.addChild(this.ring),this.pulseCircle=new jy,this.pulseCircle.visible=t.runtime.showRobotPulseCircle,this.addChild(this.pulseCircle),this.robot=new Dy,this.addChild(this.robot),this.lastUpdateTime=Date.now(),t.robotConfig.speed>0&&t.getApp().ticker.add(this.update,this);const e=Xi(t.runtime,"showRobotRing",t=>{ng.log(`[runtime] showRobotRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e);const i=Xi(t.runtime,"showRobotPulseCircle",t=>{ng.log(`[runtime] showRobotPulseCircle: ${t}`),t?(this.lastPosition&&this.pulseCircle.draw(this.lastPosition),this.pulseCircle.visible=!0):(this.pulseCircle.remove(),this.pulseCircle.visible=!1)});this.unsubscribeFns.push(i)}async initializeSleepAnimation(){try{this.sleepAnimation=await Ly.create(),this.addChild(this.sleepAnimation),ng.log("Sleep animation added to robot")}catch(t){ng.error("Failed to initialize sleep animation:",t)}}updatePositionByOrigin(t,e){this.position.set(t,e)}async draw({x:t,y:e,rotation:i}){if(this.isCleared){this.robot.visible=!0;const t=Yi();this.ring.visible=t.runtime.showRobotRing,this.pulseCircle.visible=t.runtime.showRobotPulseCircle,this.sleepAnimation&&(this.sleepAnimation.visible=!0),this.isCleared=!1}this.ring.draw({x:t,y:e}),this.pulseCircle.draw({x:t,y:e}),await this.robot.draw({x:t,y:e,rotation:i}),this.sleepAnimation||await this.initializeSleepAnimation(),this.sleepAnimation.draw({x:t,y:e}),this.lastPosition={x:t,y:e}}getCurrentPosition(){return this.lastPosition?{...this.lastPosition}:null}moveTo(t){this.pathQueue.push(t),this.isMoving||this.processNextPathPoint()}batchProcessQueue(t=!1){if(0===this.pathQueue.length)return;const e=[...this.pathQueue];if(t){const t=e[e.length-1];this.robot.position.set(t.x,t.y),void 0!==t.rotation&&(this.robot.rotation=t.rotation),this.lastPosition={x:t.x,y:t.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,e.length),0===this.pathQueue.length?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(0===this.pathQueue.length)return this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),void Yi().emitter.emit("robotAnimationComplete");this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const t=this.pathQueue[0];this.targetPosition={x:t.x,y:t.y},this.currentPathType=t.type,void 0!==t.rotation&&(this.targetRotation=t.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const t=Yi(),e=Date.now();if(0===this.lastUpdateTime)return void(this.lastUpdateTime=e);let i=e-this.lastUpdateTime;if(this.lastUpdateTime=e,i>500&&(i=16.67),this.targetPosition){const e=this.targetPosition.x-this.robot.x,s=this.targetPosition.y-this.robot.y,n=Math.sqrt(e*e+s*s),r=t.robotConfig.speed,o=t.getApp().metersToPixels(r);if(0===r)return this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),void this.processNextPathPoint();const a=o*(i/1e3);n<a?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint()):(this.robot.x+=e*(a/n),this.robot.y+=s*(a/n),Yi().emitter.emit("robotPositionUpdate",{x:this.robot.x,y:this.robot.y,pathType:this.currentPathType}),this.lastPosition={x:this.robot.x,y:this.robot.y})}}startRobotAnimation(){Yi().getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){Yi().getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}clear(){this.remove(),this.robot.visible=!1,this.ring.visible=!1,this.pulseCircle.remove(),this.sleepAnimation&&(this.sleepAnimation.visible=!1),this.lastPosition=null,this.isCleared=!0}destroy(t){const e=Yi();this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stopRobotAnimation(),e.robotConfig.speed>0&&e.getApp().ticker.remove(this.update,this),this.ring.destroy(),this.pulseCircle.destroy(),super.destroy(t)}}class Uy{path;robot;unsubscribeFns=[];lastDrawnPathData=null;constructor(){const t=Yi();this.path=new Oy,this.robot=new Gy;const e=Xi(t.runtime,"showPath",t=>{ng.log(`[runtime] showPath: ${t}`),this.path.visible=t,this.robot.visible=t});this.unsubscribeFns.push(e)}draw(t){this.shouldUseIncrementalDraw(t)?this.incrementalDraw(t):this.fullDraw(t),this.lastDrawnPathData=t}shouldUseIncrementalDraw(t){const e=Yi();if(!this.lastDrawnPathData)return!1;const i=t.pathHeader?.pathId,s=this.lastDrawnPathData.pathHeader?.pathId;if(i!==s)return!1;const n=(t.pathPoints?.length||0)-(this.lastDrawnPathData.pathPoints?.length||0),r=e.pathConfig.incrementalThreshold;return!(n<=0||n>r)}fullDraw(t){if(this.path.stopRealTimeDrawing(),this.path.drawFull(t),t.pathPoints&&t.pathPoints.length>0){const e=t.pathPoints[t.pathPoints.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}convertToRobotPoint(t,e){const i=e+Yi().robotConfig.rotationCorrection;return{x:t.x,y:t.y,rotation:i*Math.PI/180,type:t.type}}moveRobotToPoint(t,e,i=!0){const s=this.convertToRobotPoint(t,e);i?this.robot.moveTo(s):(this.robot.remove(),this.robot.draw(s))}incrementalDraw(t){const e=Yi();if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const i=this.lastDrawnPathData.pathPoints?.length||0,s=t.pathPoints.slice(i);if(0!==s.length)if(e.robotConfig.speed>0)s.forEach(e=>{this.moveRobotToPoint(e,t.pathHeader.direction,!0)});else{const e=s[s.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}batchProcessRobotQueue(t=!1){this.robot.batchProcessQueue(t)}updatePositionByOrigin(t,e){this.path.updatePositionByOrigin(t,e),this.robot.updatePositionByOrigin(t,e)}clear(){this.lastDrawnPathData=null,this.path.clear(),this.robot.clear()}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class zy extends Xn{colorGradients=[];cellSize=2;constructor(){super();const t=Yi();t.appContainer.addToLayer(py,this);const e=t.heatMapConfig;this.colorGradients=e.colorGradients.map(t=>new yn(t).toArray().slice(0,3).join(",")),this.cellSize=e.cellSize}draw(t,e=!0,i=.8){this.removeChildren();const s=e?this.gradientDrawing(t):this.gridDrawing(t);this.croppingHeatmap(s),s.alpha=i,this.addChild(s)}croppingHeatmap(t){const e=Yi().mapManager.roomFill.children.filter(t=>t instanceof Ll),i=new Ll;for(const t of e)i.context.instructions.push(...t.context.instructions);i.context.dirty=!0,t.setMask({mask:i}),this.addChild(i)}gridDrawing(t){const e=[],i=[],s=t.length,n=t[0].length;for(let r=0;r<s;r++)for(let s=0;s<n;s++){const n=t[r][s],o=this.cellSize/2,a=n.x-o,h=n.y-o,l=n.x+o,c=n.y+o;e.push(a,h),i.push(n.signal),e.push(l,h),i.push(n.signal),e.push(l,c),i.push(n.signal),e.push(a,h),i.push(n.signal),e.push(l,c),i.push(n.signal),e.push(a,c),i.push(n.signal)}const r=new ya({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new po({glProgram:new to({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n void main() {\n vec3 color;\n \n if (vSignal > 0.875) {\n color = vec3(${this.colorGradients[0]});\n } else if (vSignal > 0.75) {\n color = vec3(${this.colorGradients[1]});\n } else if (vSignal > 0.625) {\n color = vec3(${this.colorGradients[2]});\n } else if (vSignal > 0.5) {\n color = vec3(${this.colorGradients[3]});\n } else if (vSignal > 0.375) {\n color = vec3(${this.colorGradients[4]});\n } else if (vSignal > 0.25) {\n color = vec3(${this.colorGradients[5]});\n } else if (vSignal > 0.125) {\n color = vec3(${this.colorGradients[6]});\n } else {\n color = vec3(${this.colorGradients[7]});\n }\n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new Ul({geometry:r,shader:o});return a.alpha=.8,a}gradientDrawing(t){const e=[],i=[],s=t.length,n=t[0].length;for(let r=0;r<s;r++)for(let o=0;o<n;o++){const a=t[r][o],h=this.cellSize/2,l=(e,i)=>e<0||e>=s||i<0||i>=n?a.signal:t[e][i].signal,c=(l(r-1,o-1)+l(r-1,o)+l(r,o-1)+a.signal)/4,d=(l(r-1,o)+l(r-1,o+1)+a.signal+l(r,o+1))/4,u=(a.signal+l(r,o+1)+l(r+1,o)+l(r+1,o+1))/4,p=(l(r,o-1)+a.signal+l(r+1,o-1)+l(r+1,o))/4,g=a.x-h,f=a.y-h,m=a.x+h,y=a.y+h;e.push(g,f,m,f,m,y),i.push(c,d,u),e.push(g,f,m,y,g,y),i.push(c,u,p)}const r=new ya({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new po({glProgram:new to({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n // 颜色插值函数\n vec3 interpolateColor(vec3 color1, vec3 color2, float t) {\n return mix(color1, color2, t);\n }\n \n void main() {\n vec3 color;\n float signal = clamp(vSignal, 0.0, 1.0);\n \n vec3 color1 = vec3(${this.colorGradients[7]});\n vec3 color2 = vec3(${this.colorGradients[6]});\n vec3 color3 = vec3(${this.colorGradients[5]});\n vec3 color4 = vec3(${this.colorGradients[4]});\n vec3 color5 = vec3(${this.colorGradients[3]});\n vec3 color6 = vec3(${this.colorGradients[2]});\n vec3 color7 = vec3(${this.colorGradients[1]});\n vec3 color8 = vec3(${this.colorGradients[0]});\n \n if (signal <= 0.125) {\n float t = signal / 0.125;\n color = interpolateColor(color1, color2, t);\n } else if (signal <= 0.25) {\n float t = (signal - 0.125) / 0.125;\n color = interpolateColor(color2, color3, t);\n } else if (signal <= 0.375) {\n float t = (signal - 0.25) / 0.125;\n color = interpolateColor(color3, color4, t);\n } else if (signal <= 0.5) {\n float t = (signal - 0.375) / 0.125;\n color = interpolateColor(color4, color5, t);\n } else if (signal <= 0.625) {\n float t = (signal - 0.5) / 0.125;\n color = interpolateColor(color5, color6, t);\n } else if (signal <= 0.75) {\n float t = (signal - 0.625) / 0.125;\n color = interpolateColor(color6, color7, t);\n } else if (signal <= 0.875) {\n float t = (signal - 0.75) / 0.125;\n color = interpolateColor(color7, color8, t);\n } else {\n color = color8;\n }\n \n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new Ul({geometry:r,shader:o});return a.alpha=.8,a}}class Ny{heatmap=new zy;pointsTopLeftOrigin=[];signalGrid=[];cellSize=2;maxDistance=14;smoothIterations=10;heatmapAlpha=.8;constructor(){const t=Yi().heatMapConfig;this.cellSize=t.cellSize,this.maxDistance=t.maxDistance,this.smoothIterations=t.smoothIterations,this.heatmapAlpha=t.heatmapAlpha}draw({mapData:t,heatmapPoints:e,useGradient:i=!0}){const s=Yi(),n=t.origin[0],r=t.origin[1],{minX:o,minY:a}=s.mapManager.mapBounds,h=e.map(t=>({x:+(n+t.x-o).toFixed(0),y:+(r+t.y-a).toFixed(0),signal:t.signal}));this.signalGrid=this.calculateInterpolatedSignal(h),this.heatmap.draw(this.signalGrid,i,this.heatmapAlpha)}calculateInterpolatedSignal(t){const e=Yi(),{minX:i,minY:s,maxX:n,maxY:r}=e.mapManager.mapBounds,o=Math.ceil((r-s)/this.cellSize),a=Math.ceil((n-i)/this.cellSize),h=Array(o).fill(null).map(()=>Array(a).fill(null));for(let e=0;e<o;e++){const o=s+e*this.cellSize+this.cellSize/2,l=Math.min(this.cellSize,r-(o-this.cellSize/2));for(let s=0;s<a;s++){const r=i+s*this.cellSize+this.cellSize/2,a=Math.min(this.cellSize,n-(r-this.cellSize/2));let c=0,d=!1;for(let e=0;e<t.length;e++){const i=t[e];if(Math.abs(r-i.x)<=a/2&&Math.abs(o-i.y)<=l/2){const t=1-i.signal/7;c=Math.round(10*Math.max(c,t))/10,d=!0}}h[e][s]={x:r,y:o,signal:c,hasPoint:d}}}const l=(e,i)=>{if(0===t.length)return 0;let s=0,n=0;for(const r of t){const t=Math.sqrt((e-r.x)**2+(i-r.y)**2);if(t<=this.maxDistance){const e=1/(1+t);n+=e*(1-r.signal/7),s+=e}}return 0===s?0:Math.round(n/s*1e3)/1e3};for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=h[t][e];i.hasPoint||(i.signal=l(i.x,i.y))}return((t,e=1)=>{for(let i=0;i<e;i++){const e=t.map(t=>[...t]);for(let i=1;i<o-1;i++)for(let s=1;s<a-1;s++)if(!t[i][s].hasPoint){let n=0,r=0;const h=4;for(let e=-h;e<=h;e++)for(let l=-h;l<=h;l++){if(0===e&&0===l)continue;const h=i+e,c=s+l;if(h>=0&&h<o&&c>=0&&c<a){const i=1/(1+.3*Math.sqrt(e*e+l*l));n+=t[h][c].signal*i,r+=i}}if(r>0){const o=n/r,a=.6,h=.4;e[i][s].signal=t[i][s].signal*a+o*h,e[i][s].signal>.1&&(e[i][s].signal=Math.max(e[i][s].signal,.2))}}for(let i=0;i<o;i++)for(let s=0;s<a;s++)t[i][s].signal=e[i][s].signal}})(h,this.smoothIterations),h}}class Vy extends Xn{throttledUpdateScale;constructor(){super(),this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0});const t=Yi();this.updateScale(t.currentScale),this.registerScaleListener()}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){0!==t&&this.scale.set(1/t)}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Hy extends Vy{background;icon;options;constructor(t){super(),this.options=t,this.background=new Ll,this.addChild(this.background),this.icon=new Py,this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=Yi().controlsConfig,e=t.iconWrapperWidth+16,i=t.iconWrapperHeight+16;this.hitArea=new Ss(-e/2,-i/2,e,i)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const t=Yi().controlsConfig;this.background.clear(),this.background.roundRect(-t.iconWrapperWidth/2,-t.iconWrapperHeight/2,t.iconWrapperWidth,t.iconWrapperHeight,t.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const t=Yi().controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:t.iconWidth,height:t.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){ng.error(`Failed to load icon: ${this.options.iconAlias}`,t)}}destroy(){super.destroy()}}class Wy extends Hy{isRotating=!1;rotationCenter={x:0,y:0};lastAngle=0;constructor(t){super(t),this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=Yi();Yi().emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleRotationPointerMove),t.off("gestureHijackPointerUp",this.handleRotationPointerUp),t.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startRotation(t)}startRotation(t){this.isRotating=!0;const e=this.options.getTargetPoints();this.rotationCenter=xg(e);const i=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),this.options.onRotationStart?.(this.rotationCenter),Yi().emitter.emit("gestureHijackStart",t)}handleRotationPointerMove=t=>{if(!this.isRotating)return;const e=this.parent.toLocal(t.global),i=Math.atan2(e.y-this.rotationCenter.y,e.x-this.rotationCenter.x),s=i-this.lastAngle;this.options.onRotationMove?.(s),this.lastAngle=i};handleRotationPointerUp=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};handleRotationCancel=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};isCurrentlyRotating(){return this.isRotating}stopRotation(){this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())}destroy(){this.stopRotation(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Jy extends Hy{clickHandler=null;constructor(t){super(t)}setupEvents(){this.clickHandler=new Sy(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){this.clickHandler?.destroy(),super.destroy()}}class Zy extends Hy{isScaling=!1;initialButtonPosition=null;dragStartPosition=null;constructor(t){super(t),this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleScalePointerMove),t.off("gestureHijackPointerUp",this.handleScalePointerUp),t.off("gestureHijackCancel",this.handleScaleCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startScaling(t)}startScaling(t){this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global);const e=this.options.getTargetPoints(),i=this.options.getButtonIndex();i>=0&&i<e.length&&(this.initialButtonPosition={...e[i]}),this.options.onScaleStart?.(i),Yi().emitter.emit("gestureHijackStart",t)}handleScalePointerMove=t=>{if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,s=e.y-this.dragStartPosition.y,n={x:this.initialButtonPosition.x+i,y:this.initialButtonPosition.y+s};this.options.onScaleMove?.(n)};handleScalePointerUp=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};handleScaleCancel=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};isCurrentlyScaling(){return this.isScaling}stopScaling(){this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Xy extends Hy{isMoving=!1;dragStartPosition=null;constructor(t){super(t),this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleMovePointerMove),t.off("gestureHijackPointerUp",this.handleMovePointerUp),t.off("gestureHijackCancel",this.handleMoveCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startMoving(t)}startMoving(t){this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.options.onMoveStart?.(),Yi().emitter.emit("gestureHijackStart",t)}handleMovePointerMove=t=>{this.isMoving&&this.dragStartPosition&&this.options.onMoveMove?.(t)};handleMovePointerUp=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};handleMoveCancel=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Yy extends Ll{fillOptions;isDragging=!1;dragStartPosition=null;constructor(t){super(),this.fillOptions=t,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){this.isDragging=!0;const e=this.parent.toLocal(t.global);this.dragStartPosition={x:e.x,y:e.y},this.fillOptions.onDragStart?.(t),Yi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.fillOptions.onDragMove?.(t)};handleDragPointerUp=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};handleDragCancel=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};draw(){const{points:t,fillColor:e}=this.fillOptions;if(t.length<3)return;this.clear();const i=t.flatMap(t=>[t.x,t.y]);this.setFillStyle({color:e}).poly(i).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(t){this.fillOptions={...this.fillOptions,...t},void 0!==t.enableInteraction&&(this.off("pointerdown",this.handlePointerDown),this.setupInteraction()),this.draw()}updatePoints(t){this.fillOptions.points=t,this.draw()}updateFillColor(t){this.fillOptions.fillColor=t,this.draw()}stopDragging(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null)}isCurrentlyDragging(){return this.isDragging}setInteractionEnabled(t){this.fillOptions.enableInteraction=t,t?(this.eventMode="static",this.on("pointerdown",this.handlePointerDown)):(this.eventMode="auto",this.off("pointerdown",this.handlePointerDown),this.isDragging&&this.stopDragging())}destroy(){this.stopDragging(),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Ky extends Xn{borderOptions;solidLine=null;dashGraphics=null;fillGraphics=null;constructor(t){super(),this.borderOptions={...t},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.handleAntiScale)}handleAntiScale=()=>{this.drawBorder()};drawBorder(){const{points:t=[],closePath:e=!1,style:i}=this.borderOptions;t.length<2||(this.clearBorder(),void 0!==i.fillColor&&e&&this.drawFill(t,i),i.isDashed?this.drawContinuousDashedBorder(t,e,i):this.drawSolidBorder(t,e,i))}drawFill(t,e){if(e.fillColor&&!(t.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new Ll,this.fillGraphics.setFillStyle({color:e.fillColor}),this.fillGraphics.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.fillGraphics.lineTo(t[e].x,t[e].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(t,e,i){const s=Yi();this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new Ll;const n=s.getApp().toFixedSize(i.width);this.solidLine.setStrokeStyle({color:i.color,width:n}),this.solidLine.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.solidLine.lineTo(t[e].x,t[e].y);e&&this.solidLine.lineTo(t[0].x,t[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(t,e,i){if(t.length<2)return;if(!i.dashArray||2!==i.dashArray.length||i.dashArray[0]<=0||i.dashArray[1]<=0)return void ng.warn("Invalid dashArray:",i.dashArray);const s=Yi();this.dashGraphics=new Ll;const n=s.getApp().toFixedSize(i.width);this.dashGraphics.setStrokeStyle({color:i.color,width:n});const r=Math.max(s.getApp().toFixedSize(i.dashArray[0]),1),o=Math.max(s.getApp().toFixedSize(i.dashArray[1]),1),a=e?[...t,t[0]]:t;this.drawContinuousPathDashes(this.dashGraphics,a,r,o),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(t,e,i,s){if(e.length<2)return;if(i<=0||s<=0)return void ng.warn("Invalid dash parameters:",{dashLength:i,gapLength:s});const n=this.calculatePathSegments(e),r=n.reduce((t,e)=>t+e.length,0);if(0===r)return;const o=i+s;let a=0;for(;a<r;){const e=a+i;e<=r?this.drawContinuousDashSegment(t,n,a,e):this.drawContinuousDashSegment(t,n,a,r),a+=o}}calculatePathSegments(t){const e=[];for(let i=0;i<t.length-1;i++){const s=t[i],n=t[i+1],r=n.x-s.x,o=n.y-s.y,a=Math.sqrt(r*r+o*o);e.push({start:s,end:n,length:a})}return e}drawContinuousDashSegment(t,e,i,s){if(i>=s)return;let n=0,r=!1,o=null;for(const a of e){const e=n,h=n+a.length;if(h>i&&e<s){const n=Math.max(i,e),l=Math.min(s,h),c=(n-e)/a.length,d=(l-e)/a.length,u={x:a.start.x+(a.end.x-a.start.x)*c,y:a.start.y+(a.end.y-a.start.y)*c},p={x:a.start.x+(a.end.x-a.start.x)*d,y:a.start.y+(a.end.y-a.start.y)*d};r?o&&Math.sqrt(Math.pow(u.x-o.x,2)+Math.pow(u.y-o.y,2))>.1&&t.lineTo(u.x,u.y):(t.moveTo(u.x,u.y),r=!0),t.lineTo(p.x,p.y),o=p}if(n+=a.length,n>=s)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(t){this.borderOptions.style={...this.borderOptions.style,...t},this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){Yi().emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class Qy extends Kl{throttledUpdateScale;constructor({text:t,style:e}){super({text:t,style:e}),this.throttledUpdateScale=Ji(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(Yi().currentScale)}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){t<=0||this.scale.set(1/t)}setBaseFontSize(t){this.style.fontSize=t}updateText(t){this.text=t}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class qy extends Xn{static BUTTON_INDICES={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};zoneData;zoneType;zoneConfig;controlsConfig;zoneEvents;controlFill;zoneBorder;outlineBorder;moveLine;sizeText;controlButtons;deleteButton=null;rotateButton=null;scaleButton=null;moveButton=null;totalRotationAngle=0;rotationCenter=null;initialZonePoints=[];clickHandler=null;throttledUpdateOutline;constructor(t){super();const{zoneData:e,zoneType:i,events:s={}}=t;this.zoneType=i,this.zoneEvents=s,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const n=this.validateAndCorrectZoneSize(e.points),r=bg(n);this.zoneData={...e,points:r},this.throttledUpdateOutline=Ji(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const t=Yi(),{controls:e}=t.getConfig();return e[this.zoneType]}getControlsConfig(){const t=Yi(),{controls:e}=t.getConfig();return e}validateAndCorrectZoneSize(t){const e=Yi();if(t.length<4)return t;const i=e.metersToPixels(this.zoneConfig.minSize),[s,n,,r]=t,o=_g(s,n),a=_g(s,r);if(o>=i&&a>=i)return t;const h=xg(t),l=Cg(Ag(s,n)),c=Cg(Ag(s,r)),d=Math.max(o,i)/2,u=Math.max(a,i)/2;return[{x:h.x-l.x*d-c.x*u,y:h.y-l.y*d-c.y*u},{x:h.x+l.x*d-c.x*u,y:h.y+l.y*d-c.y*u},{x:h.x+l.x*d+c.x*u,y:h.y+l.y*d+c.y*u},{x:h.x-l.x*d+c.x*u,y:h.y-l.y*d+c.y*u}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":default:return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds"}}isEditingEnabled(){const t=this.getEditingIdsKey();return Yi().runtimeSnapshot[t].includes(this.zoneData.id)}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.controlFill=this.createControlFill(),this.addChild(this.controlFill),this.zoneBorder=this.createBorder(),this.addChild(this.zoneBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new Xn,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;this.deleteButton=new Jy({iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(t[qy.BUTTON_INDICES.REMOVE].x,t[qy.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new Wy({iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(t[qy.BUTTON_INDICES.ROTATE].x,t[qy.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Zy({iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>qy.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[qy.BUTTON_INDICES.SCALE].x,t[qy.BUTTON_INDICES.SCALE].y);const e=this.calculateMoveButtonPosition();this.moveButton=new Xy({iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(e.x,e.y),this.controlButtons.addChild(this.deleteButton),this.rotateButton&&this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const t=this.isEditingEnabled();return new Yy({points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const t=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new Ky({points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:t.isDashed,dashArray:t.dashArray}})}createOutlineBorder(){const t=this.calculateOutlinePoints();return new Ky({points:t,closePath:!0,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray,fillColor:this.zoneConfig.outlineFillColor}})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new Ky({points:e,closePath:!1,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray}})}calculateOutlinePoints(){const{points:t}=this.zoneData;return t.length<4?t:((t,e)=>{if(t.length<3)return t;const i=[];for(let s=0;s<t.length;s++){const n=t[s],r=t[(s+1)%t.length],o=t[(s-1+t.length)%t.length],a=Ag(n,r);if(0===wg(a)){i.push(n);continue}const h=Cg(a),l={x:h.y,y:-h.x},c=Ag(o,n);let d={x:0,y:0};if(wg(c)>0){const t=Cg(c);d={x:t.y,y:-t.x}}const u=Tg(d,l),p=d.x*l.x+d.y*l.y,g=1/Math.max(.1,Math.sqrt((1+p)/2)),f={x:n.x+u.x*e*g,y:n.y+u.y*e*g};i.push(f)}return i})(t,Yi().getApp().toFixedSize(this.zoneConfig.outlineOffset))}calculateMoveLinePoints(t){return t.length<4?[]:[t[qy.BUTTON_INDICES.MOVE],this.calculateMoveButtonPosition()]}createSizeText(){const t=this.calculateZoneSizeText(),e=new Qy({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();e.position.set(i.x,i.y);const s=this.calculateSizeTextRotation();return e.rotation=s,e.eventMode="none",e}calculateZoneSizeText(){const{points:t}=this.zoneData;if(t.length<4)return"0m*0m";const[e,i,,s]=t,n=_g(e,i),r=_g(e,s),o=Yi(),a=o.pixelsToMeters(n),h=o.pixelsToMeters(r),l=o.metersToDisplayUnit(a),c=o.metersToDisplayUnit(h),d=o.runtimeSnapshot.unitLabel;return`${l.toFixed(1)}${d}*${c.toFixed(1)}${d}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[e,i,s,n]=t,{textPosition:r,textOffset:o}=this.zoneConfig,a=Yi().getApp().toFixedSize(o);let h,l;switch(r){case"top":{h={x:(e.x+i.x)/2,y:(e.y+i.y)/2};const t=Cg(Ag(i,e)),s={x:t.y,y:-t.x};l={x:s.x*a,y:s.y*a};break}case"right":{h={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const t=Cg(Ag(i,s)),e={x:t.y,y:-t.x};l={x:e.x*a,y:e.y*a};break}case"bottom":{h={x:(n.x+s.x)/2,y:(n.y+s.y)/2};const t=Cg(Ag(n,s)),e={x:-t.y,y:t.x};l={x:e.x*a,y:e.y*a};break}case"left":{h={x:(e.x+n.x)/2,y:(e.y+n.y)/2};const t=Cg(Ag(n,e)),i={x:t.y,y:-t.x};l={x:i.x*a,y:i.y*a};break}default:h={x:(e.x+i.x)/2,y:(e.y+i.y)/2},l={x:0,y:a}}return{x:h.x+l.x,y:h.y+l.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[e,i,s,n]=t,{textPosition:r}=this.zoneConfig;let o,a;switch(r){case"top":default:o=e,a=i;break;case"right":o=i,a=s;break;case"bottom":o=s,a=n;break;case"left":o=n,a=e}return Pg(o,a)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const e=Yi(),{controls:i}=e.getConfig(),s=t[qy.BUTTON_INDICES.MOVE],n=t[2],r=t[0],o=e.getApp().toFixedSize(i.moveButtonOffset);return Bg(s,n,r,o)}handleDragStart=()=>{if(!this.isEditingEnabled())return;const t=Yi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-drag",!0)};handleDragMove=t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleDragEnd=()=>{const t=Yi();this.initialZonePoints=[],t.getApp().stopRender("zone-drag"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyTranslation(t,e){this.zoneData.points=this.initialZonePoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawZone(),this.updateControlButtonsPosition()}handleRotationStart=t=>{const e=Yi();this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(t=>({...t})),e.getApp().requestRender("zone-rotate",!0)};handleRotationMove=t=>{this.totalRotationAngle+=t,this.applyRotation(t)};handleRotationEnd=()=>{const t=Yi();this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],t.getApp().stopRender("zone-rotate"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyRotation(t){this.rotationCenter&&(this.zoneData.points=((t,e,i)=>t.map(t=>((t,e,i)=>{const s=Math.cos(i),n=Math.sin(i),r=t.x-e.x,o=t.y-e.y;return{x:r*s-o*n+e.x,y:r*n+o*s+e.y}})(t,e,i)))(this.zoneData.points,this.rotationCenter,t),this.drawZone(),this.updateControlButtonsPosition())}handleScaleStart=()=>{const t=Yi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-scale",!0)};handleScaleMove=t=>{0!==this.initialZonePoints.length&&this.applyEdgeBasedScale(t)};handleScaleEnd=()=>{const t=Yi();this.initialZonePoints=[],t.getApp().stopRender("zone-scale"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyEdgeBasedScale(t){if(this.initialZonePoints.length<4)return;const e=Yi(),{FIXED:i}=qy.BUTTON_INDICES,{x:s,y:n}=this.initialZonePoints[i],[,r,,o]=this.initialZonePoints,a={x:s,y:n},h=Ag(a,r),l=Ag(a,o),c=Ag(a,t),d=wg(h),u=wg(l);if(0===d||0===u)return;const p=e.metersToPixels(this.zoneConfig.minSize),[g,f]=[vg(c,h,d,p),vg(c,l,u,p)];this.zoneData.points=[a,{x:s+h.x*g,y:n+h.y*g},{x:s+h.x*g+l.x*f,y:n+h.y*g+l.y*f},{x:s+l.x*f,y:n+l.y*f}],this.drawZone(),this.updateControlButtonsPosition()}handleMoveStart=()=>{const t=Yi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-move",!0)};handleMove=t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.moveButton?.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleMoveEnd=()=>{const t=Yi();this.initialZonePoints=[],t.getApp().stopRender("zone-move"),this.zoneEvents.onUpdate?.(this.getZoneData())};handleDelete=()=>{this.zoneEvents.onRemove?.(this.zoneData.id)};setupClickHandler(){this.clickHandler=new Sy(this,{onClick:()=>{this.isEditingEnabled()||this.zoneEvents?.onClick?.(this.getZoneData())},stopPropagation:!1})}drawZone(){const{points:t}=this.zoneData;t.length<4||(this.controlFill.updatePoints(t),this.zoneBorder.updatePoints(t),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText())}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t)}updateMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateSizeText(){if(!this.sizeText)return;const t=this.calculateZoneSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const e=this.calculateSizeTextRotation();this.sizeText.rotation=e}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,ROTATE:i,SCALE:s}=qy.BUTTON_INDICES,n=this.calculateMoveButtonPosition(),r=[{button:this.deleteButton,point:t[e]},{button:this.scaleButton,point:t[s]},{button:this.moveButton,point:n}];this.rotateButton&&r.push({button:this.rotateButton,point:t[i]}),r.forEach(({button:t,point:e})=>t.position.set(e.x,e.y))}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,!t&&this.getCurrentOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=t,this.moveLine.visible=t,this.sizeText&&(this.sizeText.visible=t),t&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition()),this.controlFill.setInteractionEnabled(t),this.updateBorderStyle(t?this.zoneConfig.editing:this.zoneConfig.normal),this.zIndex=t?1e3:0}updateBorderStyle(t){this.zoneBorder.updateStyle({isDashed:t.isDashed,dashArray:t.dashArray})}getCurrentOperationState(){const t=this.controlFill.isCurrentlyDragging(),e=this.scaleButton?.isCurrentlyScaling()||!1,i=this.rotateButton?.isCurrentlyRotating()||!1,s=this.moveButton?.isCurrentlyMoving()||!1;return{isDragging:t,isScaling:e,isRotating:i,isMoving:s,hasAnyOperation:t||e||i||s}}stopAllOperations(){this.controlFill.stopDragging(),this.scaleButton?.stopScaling(),this.rotateButton?.stopRotation(),this.moveButton?.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){this.scaleButton?.stopScaling()}stopRotating(){this.rotateButton?.stopRotation()}stopMoving(){this.moveButton?.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){return this.scaleButton?.isCurrentlyScaling()||!1}isCurrentlyRotating(){return this.rotateButton?.isCurrentlyRotating()||!1}isCurrentlyMoving(){return this.moveButton?.isCurrentlyMoving()||!1}updateZoneData(t){const e=this.validateAndCorrectZoneSize(t.points),i=bg(e);this.zoneData={...t,points:i},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}refreshDisplay(){this.drawZone()}destroy(){Yi().emitter.off("antiScale",this.throttledUpdateOutline),this.clickHandler?.destroy(),this.clickHandler=null,this.deleteButton?.destroy(),this.rotateButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.zoneBorder?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.sizeText?.destroy(),this.controlFill?.destroy(),this.controlButtons?.destroy(),super.destroy()}}class $y extends qy{constructor(t){const e=Yi();super({zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenSweepZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenSweepZone?.(t)},onClick:t=>{e.events?.onClickForbiddenSweepZone?.(t)}}})}static create(t){return new $y({zoneData:t})}}class tx extends qy{constructor(t){const e=Yi();super({zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenMopZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenMopZone?.(t)},onClick:t=>{e.events?.onClickForbiddenMopZone?.(t)}}})}static create(t){return new tx({zoneData:t})}}class ex extends qy{constructor(t){const e=Yi();super({zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:t=>{e.events?.onRemoveCleanZone?.(t)},onUpdate:t=>{e.events?.onUpdateCleanZone?.(t)},onClick:t=>{e.events?.onClickCleanZone?.(t)}}})}static create(t){return new ex({zoneData:t})}}class ix extends Ll{lineOptions;strokeContext=null;constructor(t){super(),this.lineOptions={...t},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.drawDashLine)}drawDashLine=()=>{const{start:t,end:e,style:i}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const s=Yi();this.strokeContext=new fh;const n=s.getApp().toFixedSize(i.width);this.strokeContext.setStrokeStyle({color:i.color,width:n}),this.drawDashedLineToContext(this.strokeContext,t.x,t.y,e.x,e.y,i.dashArray[0],i.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext};drawDashedLineToContext(t,e,i,s,n,r,o){const a=s-e,h=n-i,l=Math.sqrt(a*a+h*h);if(0===l)return;const c=Yi(),d=c.getApp().toFixedSize(r),u=d+c.getApp().toFixedSize(o),p=l/u,g=Math.round(p);if(0===g)return t.moveTo(e,i),void t.lineTo(s,n);const f=l/g,m=f*(d/u),y=a/l,x=h/l;for(let s=0;s<g;s++){const n=s*f,r=n+m;if(n>=l)break;const o=Math.min(r,l),a=e+n*y,h=i+n*x,c=e+o*y,d=i+o*x;t.moveTo(a,h),t.lineTo(c,d)}}updatePoints(t,e){this.lineOptions.start=t,this.lineOptions.end=e,this.drawDashLine()}updateStyle(t){this.lineOptions.style={...this.lineOptions.style,...t},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){Yi().emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}class sx extends Xn{static BUTTON_INDICES={REMOVE:0,SCALE:2,MOVE:3};wallData;wallConfig;controlsConfig;wallEvents;wallLine;outlineBorder;moveLine;lengthText;controlButtons;removeButton=null;scaleButton=null;moveButton=null;initialWallPoints=[];isDragging=!1;dragStartPosition=null;throttledUpdateOutline;throttledHandleScaleChange;wallLineClickHandler=null;constructor(t){super();const{wallData:e,events:i={}}=t;this.wallEvents=i;const s=Yi();this.wallConfig=s.controlsConfig.virtualWall,this.controlsConfig=s.controlsConfig,this.wallData={...e,points:this.validateAndCorrectWallLength(e.points)},this.throttledHandleScaleChange=Ji(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=Ji(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}validateAndCorrectWallLength(t){const e=Yi();if(t.length<2)return t;const[i,s]=t,n=e.metersToPixels(this.wallConfig.minWidth),r=_g(i,s);if(r>=n)return t;if(0===r)return[i,{x:i.x+n,y:i.y}];const o=Cg(Ag(i,s));return[i,{x:i.x+o.x*n,y:i.y+o.y*n}]}isEditingEnabled(){return Yi().runtimeSnapshot.editingVirtualWallIds.includes(this.wallData.id)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition())}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.createWallLine(!1),this.addChild(this.wallLine),this.lengthText=this.createLengthText(),this.addChild(this.lengthText),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.controlButtons=new Xn,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(t=!0){const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:s,editing:n,normal:r}=this.wallConfig,o=this.isEditingEnabled()?n:r;o.isDashed?this.wallLine=new ix({start:e[0],end:e[1],style:{color:s.toString(),width:i,dashArray:o.dashArray}}):this.wallLine=this.createSolidLine(e[0],e[1],i,s.toString()),t&&this.setupWallLineInteraction()}createLengthText(){const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t),i=new Qy({text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateTextPosition();i.position.set(s.x,s.y);const n=this.calculateTextRotation();return i.rotation=n,i.eventMode="none",i}calculateWallLengthInMeters(){const t=Yi(),{points:e}=this.wallData;if(e.length<2)return 0;const i=_g(e[0],e[1]);return t.pixelsToMeters(i)}formatLengthText(t){const e=Yi(),i=e.metersToDisplayUnit(t),s=e.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}`}calculateTextPosition(){const t=Yi(),{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,s]=e;return((t,e,i)=>{const s=xg([t,e]),n=Mg(t,e);return{x:s.x+n.x*i,y:s.y+n.y*i}})(i,s,t.getApp().toFixedSize(this.wallConfig.textOffset))}calculateTextRotation(){const{points:t}=this.wallData;if(t.length<2)return 0;const[e,i]=t;return Pg(e,i)}getOutlineStyle(){return{color:this.wallConfig.outlineStrokeColor,width:this.wallConfig.outlineStrokeWidth,isDashed:this.wallConfig.outlineDashed,dashArray:this.wallConfig.outlineDashArray,fillColor:this.wallConfig.outlineFillColor}}createOutlineBorder(){const t=this.calculateOutlinePoints();return new Ky({points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new Ky({points:e,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const e=Yi(),i=t||this.wallData.points;if(i.length<2)return i;const s=e.getApp().toFixedSize(this.wallConfig.outlineOffset),n=((t,e,i)=>{if(0===_g(t,e))return[t,t,t,t];const s=Sg(t,e),n=Ig(s),r=t.x-s.x*i,o=t.y-s.y*i,a=e.x+s.x*i,h=e.y+s.y*i;return[{x:r+n.x*i,y:o+n.y*i},{x:a+n.x*i,y:h+n.y*i},{x:a-n.x*i,y:h-n.y*i},{x:r-n.x*i,y:o-n.y*i}]})(i[0],i[1],s);return[n[3],n[2],n[1],n[0]]}calculateMoveLinePoints(t){if(t.length<4)return[];const{MOVE:e}=sx.BUTTON_INDICES;return[t[e],this.calculateMoveButtonPosition()]}calculateMoveButtonPosition(){const t=Yi(),{moveButtonOffset:e}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:s}=sx.BUTTON_INDICES,n=i[s],r=i[(s+3)%4],o=i[(s+1)%4],a=t.getApp().toFixedSize(e);return Bg(n,o,r,a)}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=sx.BUTTON_INDICES;this.removeButton=new Jy({iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton=new Zy({iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>i,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[i].x,t[i].y);const s=this.calculateMoveButtonPosition();this.moveButton=new Xy({iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(s.x,s.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}handleRemove=()=>{this.wallEvents.onRemove?.(this.wallData.id)};initializeOperation=()=>{this.initialWallPoints=this.wallData.points.map(t=>({...t}))};finalizeOperation=()=>{this.initialWallPoints=[],this.wallEvents.onUpdate?.(this.getWallData())};handleScaleStart=()=>{const t=Yi();this.initializeOperation(),t.getApp().requestRender("virtualwall-scale",!0)};handleScaleMove=t=>{0!==this.initialWallPoints.length&&this.applyScaleAndRotation(t)};handleScaleEnd=()=>{const t=Yi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-scale")};handleMoveStart=()=>{const t=Yi();this.initializeOperation(),t.getApp().requestRender("virtualwall-move",!0)};handleMove=t=>{if(0===this.initialWallPoints.length)return;const e=this.parent.toLocal(t.global),i=this.getDragStartPosition()||this.moveButton?.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleMoveEnd=()=>{const t=Yi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-move")};applyScaleAndRotation(t){const e=Yi();if(this.initialWallPoints.length<2)return;const[i,s]=this.initialWallPoints,n=i,r=this.calculateOutlinePoints(this.initialWallPoints);if(r.length<4)return;const o=r[sx.BUTTON_INDICES.SCALE],a=Ag(s,o),h={x:t.x-a.x,y:t.y-a.y},l=Ag(n,h),c=_g(n,h),d=e.metersToPixels(this.wallConfig.minWidth);let u;if(c<d)if(0===c)u={x:n.x+d,y:n.y};else{const t=Cg(l);u={x:n.x+t.x*d,y:n.y+t.y*d}}else u=h;this.wallData.points=[n,u],this.drawVirtualWall(),this.updateControlButtonsPosition()}applyTranslation(t,e){this.wallData.points=this.initialWallPoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawVirtualWall(),this.updateControlButtonsPosition()}drawVirtualWall(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:t}=this.wallData;t.length<2||(this.wallLine instanceof ix?this.wallLine.updatePoints(t[0],t[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t);this.lengthText.updateText(e),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const t=this.calculateTextPosition();this.lengthText.position.set(t.x,t.y);const e=this.calculateTextRotation();this.lengthText.rotation=e}updateOutlineComponents(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t);const e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=sx.BUTTON_INDICES,s=this.calculateMoveButtonPosition();this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton.position.set(t[i].x,t[i].y),this.moveButton.position.set(s.x,s.y)}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.lengthText&&(this.lengthText.visible=t),t&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=t?1e3:0}createSolidLine(t,e,i,s){const n=Yi(),r=new Ll;r.eventMode="static";const o=n.getApp().toFixedSize(i);return r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.stroke({color:s,width:o}),r}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:e,normal:i,lineWidth:s,lineColor:n}=this.wallConfig,r=t?e:i;this.wallLine instanceof ix!==r.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof ix?this.wallLine.updateStyle({color:n.toString(),width:s,dashArray:r.dashArray}):this.redrawSolidLine()}registerScaleListener(){const{emitter:t}=Yi();t.on("antiScale",this.throttledUpdateOutline),t.on("antiScale",this.throttledHandleScaleChange)}redrawSolidLine(){const t=Yi();if(!this.wallLine||this.wallLine instanceof ix)return;const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:s}=this.wallConfig,n=t.getApp().toFixedSize(i);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:s.toString(),width:n}).moveTo(e[0].x,e[0].y).lineTo(e[1].x,e[1].y).stroke()}handleScaleChange=()=>{this.redrawSolidLine(),this.setupWallLineHitArea()};setupWallLineInteraction(){if(!this.wallLine)return;this.setupWallLineHitArea();const t=this.isEditingEnabled();this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),t?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new Sy(this.wallLine,{onClick:()=>{Yi().emitter.emit("suppressMapClick"),this.wallEvents?.onClick?.(this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handleWallLinePointerDown=t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))};startDragging(t){const e=Yi();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initializeOperation(),e.getApp().requestRender("virtualwall-drag",!0),Yi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.handleMove(t)};handleDragPointerUp=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())};handleDragCancel=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())};getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){const t=Yi();if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,s=t.getApp().toFixedSize(i),n=Eg(e[0],e[1],s);if(0===n.length)return;const r=new $o(n);this.wallLine.hitArea=r}getWallData(){return{...this.wallData}}updateWallData(t){this.wallData={...t,points:this.validateAndCorrectWallLength(t.points)},this.drawVirtualWall(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}refreshDisplay(){this.drawVirtualWall()}destroy(){Yi().emitter.off("antiScale",this.throttledUpdateOutline),Yi().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine?.destroy(),this.lengthText?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.controlButtons?.destroy(),this.removeButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}}class nx extends Xn{spotData;spotConfig;controlsConfig;spotEvents;controlFill;spotBorder;centerIcon;sizeText;clickHandler=null;initialSpotPoint=null;throttledUpdateScale;constructor(t){super();const{spotData:e,events:i={}}=t,s=Yi();this.spotData=e,this.spotEvents=i,this.controlsConfig=s.controlsConfig,this.spotConfig=s.controlsConfig.spot,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.sizeText&&this.updateSizeTextPosition()}isEditingEnabled(){return Yi().runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}shouldShowIcon(){return(this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal).showIcon}calculateRectanglePoints(){const t=Yi(),{point:e}=this.spotData,{size:i}=this.spotConfig;if(0===i)return[e,e,e,e];const s=t.metersToPixels(i)/2;return[{x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s},{x:e.x-s,y:e.y+s}]}initializeComponents(){const t=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill=this.createControlFill(t),this.addChild(this.controlFill),this.spotBorder=this.createBorder(t),this.addChild(this.spotBorder)),this.centerIcon=this.createCenterIcon(),this.addChild(this.centerIcon),this.spotConfig.showText&&(this.sizeText=this.createSizeText(),this.addChild(this.sizeText)),this.drawSpot()}createControlFill(t){const e=this.isEditingEnabled();return new Yy({points:t,fillColor:this.spotConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(t){const e=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new Ky({points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:e.isDashed,dashArray:e.dashArray}})}createCenterIcon(){const t=new Py;return this.loadIconTexture(t),t.position.set(this.spotData.point.x,this.spotData.point.y),t.eventMode=0===this.spotConfig.size?"static":"none",0===this.spotConfig.size&&this.setupIconDrag(t),t.visible=!1,t}async loadIconTexture(t){const{iconSize:e}=this.spotConfig;await t.loadTextureAndSetSize("spotIcon",{width:e,height:e,sizeFixed:!1}),t.visible=this.shouldShowIcon()}setupIconDrag(t){let e=null,i=!1;const s=t=>{if(!i||!this.initialSpotPoint||!e)return;const s=this.parent.toLocal(t.global),n=s.x-e.x,r=s.y-e.y;this.applyTranslation(n,r)},n=()=>{if(!i)return;const t=Yi();i=!1,this.initialSpotPoint=null,e=null,t.getApp().stopRender("spot-drag"),t.emitter.off("gestureHijackPointerMove",s),t.emitter.off("gestureHijackPointerUp",r),t.emitter.off("gestureHijackCancel",n)},r=()=>{if(!i)return;const t=Yi();i=!1,this.initialSpotPoint=null,e=null,t.getApp().stopRender("spot-drag"),this.spotEvents.onUpdate?.(this.getSpotData()),t.emitter.off("gestureHijackPointerMove",s),t.emitter.off("gestureHijackPointerUp",r),t.emitter.off("gestureHijackCancel",n)};t.on("pointerdown",t=>{if(!this.isEditingEnabled())return;t.stopPropagation();const o=Yi();i=!0,this.initialSpotPoint={...this.spotData.point},e=this.parent.toLocal(t.global),o.getApp().requestRender("spot-drag",!0),o.emitter.emit("gestureHijackStart",t),o.emitter.on("gestureHijackPointerMove",s),o.emitter.on("gestureHijackPointerUp",r),o.emitter.on("gestureHijackCancel",n)})}createSizeText(){const t=this.calculateSpotSizeText(),e=new Qy({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();return e.position.set(i.x,i.y),e.eventMode="none",e}calculateSpotSizeText(){const t=Yi(),{size:e}=this.spotConfig,i=t.metersToDisplayUnit(e),s=t.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}*${i.toFixed(1)}${s}`}calculateSizeTextPosition(){const t=Yi(),e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,s,n,r]=e,{textPosition:o,textOffset:a}=this.spotConfig,h=t.getApp().toFixedSize(a);let l,c;switch(o){case"top":default:l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},c={x:l.x,y:l.y+h};break;case"right":l={x:(s.x+n.x)/2,y:(s.y+n.y)/2},c={x:l.x+h,y:l.y};break;case"bottom":l={x:(r.x+n.x)/2,y:(r.y+n.y)/2},c={x:l.x,y:l.y+h};break;case"left":l={x:(i.x+r.x)/2,y:(i.y+r.y)/2},c={x:l.x-h,y:l.y}}return c}handleDragStart=()=>{const t=Yi();this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},t.getApp().requestRender("spot-drag",!0))};handleDragMove=t=>{if(!this.isEditingEnabled()||!this.initialSpotPoint)return;if(!this.controlFill)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleDragEnd=()=>{const t=Yi();this.initialSpotPoint=null,t.getApp().stopRender("spot-drag"),this.spotEvents.onUpdate?.(this.getSpotData())};applyTranslation(t,e){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+e},this.drawSpot())}setupClickHandler(){const t=this.spotConfig.size>0?this:this.centerIcon;this.clickHandler=new Sy(t,{onClick:()=>{this.isEditingEnabled()||(Yi().emitter.emit("suppressMapClick"),this.spotEvents?.onClick?.(this.getSpotData()))},stopPropagation:!1})}drawSpot(){const t=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill&&this.controlFill.updatePoints(t),this.spotBorder&&this.spotBorder.updatePoints(t)),this.centerIcon.position.set(this.spotData.point.x,this.spotData.point.y),this.spotConfig.showText&&this.sizeText&&this.updateSizeText()}updateSizeText(){if(!this.sizeText)return;const t=this.calculateSpotSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y)}updateEditState(){const t=this.isEditingEnabled(),e=t?this.spotConfig.editing:this.spotConfig.normal;this.sizeText&&(this.sizeText.visible=t&&this.spotConfig.showText),this.centerIcon&&(this.centerIcon.visible=this.shouldShowIcon()),this.controlFill&&this.controlFill.setInteractionEnabled(t),this.spotBorder&&this.spotBorder.updateStyle({isDashed:e.isDashed,dashArray:e.dashArray}),this.zIndex=t?1e3:0}updateSpotData(t){this.spotData={...t},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}refreshDisplay(){this.drawSpot()}destroy(){Yi().emitter.off("antiScale",this.throttledUpdateScale),this.clickHandler?.destroy(),this.clickHandler=null,this.centerIcon&&0===this.spotConfig.size&&this.centerIcon.removeAllListeners(),this.controlFill?.destroy(),this.spotBorder?.destroy(),this.centerIcon?.destroy(),this.sizeText?.destroy(),super.destroy()}static create(t){const e=Yi();return new nx({spotData:t,events:{onUpdate:t=>{e.events?.onUpdateSpot?.(t)},onClick:t=>{e.events?.onClickSpot?.(t)}}})}}class rx extends Vy{wayPointData;order;wayPointConfig;controlsConfig;wayPointEvents;icon;orderContainer;orderBackground;orderText;clickHandler=null;initialWayPointPoint=null;constructor(t){super();const{wayPointData:e,order:i,events:s={}}=t,n=Yi();this.wayPointData=e,this.order=i,this.wayPointEvents=s,this.controlsConfig=n.controlsConfig,this.wayPointConfig=n.controlsConfig.wayPoint,this.position.set(e.point.x,e.point.y),this.initializeComponents(),this.updateEditState(),this.setupClickHandler()}isEditingEnabled(){return(Yi().runtimeSnapshot.editingWayPointIds||[]).includes(this.wayPointData.id)}initializeComponents(){this.icon=this.createIcon(),this.addChild(this.icon),this.wayPointConfig.showOrder&&(this.createOrderContainer(),this.addChild(this.orderContainer))}createIcon(){const t=new Py;return this.loadIconTexture(t),t.position.set(0,0),t.anchor.set(.5,1),t.eventMode="static",this.setupIconDrag(t),t}async loadIconTexture(t){const e=this.isEditingEnabled(),i=e?this.wayPointConfig.editing:this.wayPointConfig.normal,{iconSize:s}=i,n=e?"wayPointActive":"wayPoint";await t.loadTextureAndSetSize(n,{width:s,height:s,sizeFixed:!1}),t.visible=!0,this.orderContainer&&this.updateOrderPosition()}createOrderContainer(){const t=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{orderContainer:e,orderText:i}=t;this.orderContainer=new Xn,this.orderBackground=new Ll,this.orderText=new Kl({text:this.order.toString(),style:new yh({fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWeight,fill:i.color,align:"center",trim:!0})}),this.orderBackground.clear(),this.orderBackground.circle(0,0,e.size/2),this.orderBackground.fill({color:e.backgroundColor}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.orderContainer.eventMode="none",this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}updateOrderPosition(){if(!this.orderContainer)return;const t=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{offsetX:e,offsetY:i}=t.orderContainer;this.orderContainer.position.set(e,-i)}setupIconDrag(t){let e=null,i=null,s=!1;const n=t=>{if(s&&e&&i&&this.parent){const s=this.parent.toLocal(t.global),n=s.x-e.x,r=s.y-e.y,o={x:i.x+n,y:i.y+r};this.wayPointData.point=o,this.position.set(o.x,o.y),this.orderContainer&&this.updateOrderPosition()}},r=()=>{if(!s)return;s=!1,e=null,i=null;const t=Yi();this.wayPointEvents.onUpdate?.(this.wayPointData),t.emitter.off("gestureHijackPointerMove",n),t.emitter.off("gestureHijackPointerUp",r),t.emitter.emit("gestureHijackCancel")};t.on("pointerdown",t=>{if(!this.isEditingEnabled())return;t.stopPropagation();const o=Yi();i={...this.wayPointData.point},this.parent&&(e=this.parent.toLocal(t.global)),s=!0,this.parent&&(o.emitter.emit("gestureHijackStart",t),o.emitter.on("gestureHijackPointerMove",n),o.emitter.on("gestureHijackPointerUp",r))})}setupClickHandler(){this.clickHandler=new Sy(this.icon,{stopPropagation:!1,onClick:()=>{Yi().emitter.emit("suppressMapClick"),this.wayPointEvents.onClick?.(this.wayPointData)}})}updateWayPoint(t){this.wayPointData=t,this.drawWayPoint()}updateOrder(t){this.order=t,this.orderText&&(this.orderText.text=t.toString())}getWayPointData(){return{...this.wayPointData}}drawWayPoint(){this.position.set(this.wayPointData.point.x,this.wayPointData.point.y),this.orderContainer&&this.updateOrderPosition()}updateEditState(){if(this.loadIconTexture(this.icon),this.orderContainer&&this.orderText&&this.orderBackground){const t=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal;this.orderText.style=new yh({fontSize:t.orderText.fontSize,fontFamily:t.orderText.fontFamily,fontWeight:t.orderText.fontWeight,fill:t.orderText.color,align:"center",trim:!0});const{size:e,backgroundColor:i}=t.orderContainer;this.orderBackground.clear(),this.orderBackground.circle(0,0,e/2).fill(i),this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}}onEditStateChange(){this.updateEditState()}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.icon&&this.icon.removeAllListeners(),super.destroy()}}class ox extends Ll{constructor(t){super(),this.options=t,this.initialPosition={...t.position},this.position.set(t.position.x,t.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}isDragging=!1;dragStartPosition=null;initialPosition;draw(){const t=Yi(),{config:e}=this.options,i=t.getApp().toFixedSize(e.endPointSize),s=t.getApp().toFixedSize(e.endPointStrokeWidth);this.clear(),this.circle(0,0,i/2),this.fill({color:e.endPointColor}),this.stroke({color:e.endPointStrokeColor,width:s}),this.setupHitArea()}setupHitArea(){const t=Yi(),{config:e}=this.options,i=Math.max(e.endPointSize/2+10,20),s=t.getApp().toFixedSize(i);this.hitArea=new Qo(0,0,s)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(t){t.stopPropagation(),this.startDragging(t)}startDragging(t){const e=Yi();this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},this.options.onDragStart?.(),e.getApp().requestRender("endpoint-drag",!0),Yi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{if(!this.isDragging||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,s=e.y-this.dragStartPosition.y,n={x:this.initialPosition.x+i,y:this.initialPosition.y+s};this.position.set(n.x,n.y),this.options.onDragMove?.(n)};handleDragPointerUp=()=>{if(!this.isDragging)return;const t=Yi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};handleDragCancel=()=>{if(!this.isDragging)return;const t=Yi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};updatePosition(t){this.position.set(t.x,t.y),this.initialPosition={...t}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class ax extends Xn{endPoints;dividerConfig;dividerEvents;roomId;roomGeometry=null;dashLine;solidLine=null;startEndPoint;endEndPoint;solidLinePoints=null;initialDividerPoints=[];isDragging=!1;dragStartPosition=null;throttledHandleScaleChange;constructor(t){super();const{endPoints:e,roomId:i,events:s={}}=t;this.dividerEvents=s,this.roomId=i;const n=Yi();this.dividerConfig=n.dividerConfig,this.roomGeometry=n.mapManager.getRoomById(this.roomId)||null,this.endPoints=e?this.validateDividerPoints(e):this.createDefaultdividerPoints(),this.throttledHandleScaleChange=Ji(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.calculateAndCreateSolidLine(),this.registerScaleListener(),this.setupDragEventListeners()}validateDividerPoints(t){if(t.length>=2)return t.slice(0,2);const e=t[0]||{x:0,y:0};return[e,{x:e.x+50,y:e.y}]}createDefaultdividerPoints(){if(!this.roomGeometry)return ng.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=Yi(),e=t.getApp().mapState;if(!e)return ng.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,s=t.getApp().toFixedSize(this.dividerConfig.defaultExtension),n=this.dividerConfig.defaultDirection,r=i.x+i.width/2,o=i.y+i.height/2,a="horizontal"===n?i.width+2*s:i.height+2*s;return Dg(r,o,a,n).map(t=>({x:t.x-e.origin.x,y:t.y-e.origin.y}))}initializeComponents(){this.createDashLine(),this.addChild(this.dashLine),this.createEndPoints(),this.addChild(this.startEndPoint),this.addChild(this.endEndPoint),this.setupDashLineInteraction()}createDashLine(){const t=this.endPoints;if(t.length<2)return;const{dashLineWidth:e,dashLineDashArray:i,lineColor:s}=this.dividerConfig;this.dashLine=new ix({start:t[0],end:t[1],style:{color:s.toString(),width:e,dashArray:i}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new ox({position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(0,t),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new ox({position:t[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(1,t),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){const t=Yi();if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,s=t.getApp().toFixedSize(i),n=Eg(e[0],e[1],s);if(0===n.length)return;const r=new $o(n);this.dashLine.hitArea=r}handleEndPointDragStart=()=>{const t=Yi();this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),t.getApp().requestRender("divider-endpoint-drag",!0)};handleEndPointDragMove=(t,e)=>{0!==this.initialDividerPoints.length&&(this.endPoints[t]=e,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())};handleEndPointDragEnd=()=>{const t=Yi();this.initialDividerPoints=[],t.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints())};handleDashLinePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){const e=Yi();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),e.getApp().requestRender("divider-drag",!0),Yi().emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handleDragPointerMove=t=>{if(!this.isDragging||!this.dragStartPosition||0===this.initialDividerPoints.length)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,s=e.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(t=>({x:t.x+i,y:t.y+s})),this.updateAllComponents()};handleDragPointerUp=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};handleDragCancel=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};updateAllComponents(){this.updateDashLine(),this.updateSolidLine(),this.updateEndPoints(),this.setupDashLineHitArea()}updateDashLine(){const t=this.endPoints;t.length<2||!this.dashLine||this.dashLine.updatePoints(t[0],t[1])}updateSolidLine(){if(!this.solidLine||!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:e}=this.dividerConfig,i=Yi().getApp().toFixedSize(t);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:e.toString(),width:i}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke()}updateEndPoints(){const t=this.endPoints;this.startEndPoint&&this.startEndPoint.updatePosition(t[0]),this.endEndPoint&&this.endEndPoint.updatePosition(t[1])}registerScaleListener(){const{emitter:t}=Yi();t.on("antiScale",this.throttledHandleScaleChange)}handleScaleChange=()=>{this.startEndPoint?.redraw(),this.endEndPoint?.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()};getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),"number"!=typeof this.roomId)return;if(!this.getRoomGraphics())return;const t=this.calculateLineRoomIntersection();t&&t.length>=2&&(this.solidLinePoints=[t[0],t[t.length-1]],this.createSolidLine())}getRoomGraphics(){const t=Yi().mapManager.roomFill;return t&&"number"==typeof this.roomId&&t.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const t=this.endPoints;if(t.length<2)return null;if("number"!=typeof this.roomId)return null;const[e,i]=t,s=this.isPointInRoomFill(e),n=this.isPointInRoomFill(i);if(s||n)return null;const r=((t,e,i=1,s=2e3)=>{const n=[],r=e.x-t.x,o=e.y-t.y,a=Math.sqrt(r*r+o*o);if(0===a)return[t];const h=Math.min(Math.max(Math.ceil(a/i),2),s);for(let e=0;e<=h;e++){const i=e/h,s={x:t.x+i*r,y:t.y+i*o};n.push(s)}return n})(e,i),o=[];for(const t of r)this.isPointInRoomFill(t)&&o.push(t);if(0===o.length)return null;const a=o[0],h=o[o.length-1];if(_g(a,h)<3)return null;const l=((t,e,i)=>{const s=e.x-t.x,n=e.y-t.y,r=Math.sqrt(s*s+n*n);if(0===r)return[t,e];const o=s/r,a=n/r;return[{x:t.x-o*i,y:t.y-a*i},{x:e.x+o*i,y:e.y+a*i}]})(a,h,.5);return l}isPointInRoomFill(t){if("number"!=typeof this.roomId)return!1;const e=Yi().getApp().mapState;if(!e)return!1;const i={x:t.x+e.origin.x,y:t.y+e.origin.y};return"raster"===e.mapType?this.isPointInRasterRoomFill(i):this.isPointInStructuredRoomFill(i)}isPointInRasterRoomFill(t){t.x-=.5,t.y-=.5;const e=Yi(),i=e.getApp().mapState,s=e.mapManager.roomFill;if(!i||!s)return!1;const n=s.getRasterRoomData(this.roomId);if(!n)return!1;const r=s.getMapWidth();if(0===r)return!1;const o=Math.round(t.y)*r+Math.round(t.x);for(let t=0;t<n.pixelIndices.length;t++)if(n.pixelIndices[t]===o)return!0;return!1}isPointInStructuredRoomFill(t){const e={x:Math.round(t.x),y:Math.round(t.y)},i=Yi(),s=i.getApp().mapState,n=i.mapManager.getRoomById(this.roomId);return!!(s&&n&&n.outlinePoints)&&gg(e,n.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:t}=this.roomGeometry,e=this.endPoints;if(e.length<2)return!1;const i=Yi().getApp().mapState;return!!i&&!((t,e,i,s,n,r)=>{const o=i+n,a=s+r,h=Math.min(t.x,e.x),l=Math.max(t.x,e.x),c=Math.min(t.y,e.y),d=Math.max(t.y,e.y);if(l<i||h>o||d<s||c>a)return!1;if(Og(t,i,s,n,r)||Og(e,i,s,n,r))return!0;const u=[{x:i,y:s},{x:o,y:s},{x:o,y:a},{x:i,y:a}];for(let i=0;i<4;i++)if(Rg(t,e,u[i],u[(i+1)%4]))return!0;return!1})({x:e[0].x+i.origin.x,y:e[0].y+i.origin.y},{x:e[1].x+i.origin.x,y:e[1].y+i.origin.y},t.x,t.y,t.width,t.height)}checkAndResetIfOutOfRoom(){const t=Yi(),{resetDividerWhenOutOfRoom:e}=t.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),this.dividerEvents.onUpdate?.(this.endPoints)}updateComponents(){const t=this.endPoints;t.length>=2&&(this.dashLine.updatePoints(t[0],t[1]),this.startEndPoint.position.set(t[0].x,t[0].y),this.endEndPoint.position.set(t[1].x,t[1].y),this.setupDashLineInteraction())}createSolidLine(){if(!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:e}=this.dividerConfig,i=Yi();this.solidLine=new Ll,this.solidLine.eventMode="none";const s=i.getApp().toFixedSize(t);this.solidLine.setStrokeStyle({color:e.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke(),this.addChildAt(this.solidLine,0)}clearSolidLine(){this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.solidLinePoints=null}updatedividerPoints(t){this.endPoints=this.validateDividerPoints(t),this.updateAllComponents(),this.calculateAndCreateSolidLine()}destroy(){Yi().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[]),this.dashLine&&this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.clearSolidLine(),this.dashLine?.destroy(),this.startEndPoint?.destroy(),this.endEndPoint?.destroy(),super.destroy()}}class hx{forbiddenSweepZoneMap=new Map;forbiddenMopZoneMap=new Map;cleanZoneMap=new Map;virtualWallMap=new Map;spotMap=new Map;wayPointMap=new Map;divider=null;unsubscribeFns=[];constructor(){const t=Yi(),e=Xi(t.runtime,"editingForbiddenSweepZoneIds",t=>{ng.log(`[runtime] editingForbiddenSweepZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=Xi(t.runtime,"editingForbiddenMopZoneIds",t=>{ng.log(`[runtime] editingForbiddenMopZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),s=Xi(t.runtime,"editingCleanZoneIds",t=>{ng.log(`[runtime] editingCleanZoneIds: ${t}`),this.updateZonesEditState(this.cleanZoneMap)}),n=Xi(t.runtime,"editingVirtualWallIds",t=>{ng.log(`[runtime] editingVirtualWallIds: ${t}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),r=Xi(t.runtime,"editingSpotIds",t=>{ng.log(`[runtime] editingSpotIds: ${t}`),this.updateSpotsEditState(this.spotMap)}),o=Xi(t.runtime,"editingWayPointIds",t=>{ng.log(`[runtime] editingWayPointIds: ${t}`),this.updateWayPointsEditState(this.wayPointMap)}),a=Xi(t.runtime,"dividingRoomId",t=>{ng.log(`[runtime] dividingRoomId: ${t}`),this.handleDividingRoomIdChange(t)}),h=Xi(t.runtime,"unit",t=>{ng.log(`[runtime] unit changed: ${t}`),this.handleUnitChange()}),l=Xi(t.runtime,"unitLabel",t=>{ng.log(`[runtime] unitLabel changed: ${t}`),this.handleUnitChange()});this.unsubscribeFns.push(e,i,s,n,r,o,a,h,l)}updatePositionByOrigin(t,e){const i=Yi().appContainer.getLayer(fy);i&&i.position.set(t,e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,t=>$y.create(t))}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,t=>tx.create(t))}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,t=>ex.create(t))}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){const e=Yi(),i=this.virtualWallMap,s=new Set(t.map(t=>t.id));for(const[t,n]of i)s.has(t)||(e.appContainer.removeFromLayer(fy,n),n.destroy(),i.delete(t));t.forEach(t=>{const s=i.get(t.id);if(s)this.isWallDataEqual(s.getWallData(),t)||s.updateWallData(t);else{const s=new sx({wallData:t,events:{onRemove:t=>{e.events?.onRemoveVirtualWall?.(t)},onUpdate:t=>{e.events?.onUpdateVirtualWall?.(t)},onClick:t=>{e.events?.onClickVirtualWall?.(t)}}});i.set(t.id,s),e.appContainer.addToLayer(fy,s)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(t){const e=this.spotMap;if(!t||0===t.length)return void this.clearAllSpotsInternal(e);const i=new Set(e.keys()),s=new Set(t.map(t=>t.id));for(const t of i)s.has(t)||this.removeSpot(t,e);t.forEach(t=>{const i=e.get(t.id);i?this.isSpotDataEqual(i.getSpotData(),t)||i.updateSpotData(t):this.addNewSpot(t,e)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}drawZones(t,e,i){if(!t||0===t.length)return void this.clearAllZones(e);const s=new Set(e.keys()),n=new Set(t.map(t=>t.id));for(const t of s)n.has(t)||this.removeZone(t,e);t.forEach(t=>{const s=e.get(t.id);s?this.isZoneDataEqual(s.getZoneData(),t)||s.updateZoneData(t):this.addNewZone(t,e,i)})}addNewZone(t,e,i){const s=Yi(),n=i(t);e.set(t.id,n),s.appContainer.addToLayer(fy,n)}removeZone(t,e){const i=Yi(),s=e.get(t);s&&(i.appContainer.removeFromLayer(fy,s),s.destroy(),e.delete(t))}getZonesData(t){const e=[];return t.forEach(t=>{e.push(t.getZoneData())}),e}clearAllZones(t){t.forEach((e,i)=>{const s=t.get(i);s&&(s.parent?.removeChild(s),s.destroy())}),t.clear()}updateZonesEditState(t){t.forEach(t=>{t.updateEditState()})}updateVirtualWallsEditState(t){t.forEach(t=>{t.updateEditingState()})}isZoneDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}getWallsData(t){return Array.from(t.values()).map(t=>t.getWallData())}clearAllWalls(t){for(const e of t.values())e.destroy();t.clear()}isWallDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}addNewSpot(t,e){const i=Yi(),s=nx.create(t);e.set(t.id,s),i.appContainer.addToLayer(fy,s)}removeSpot(t,e){const i=Yi(),s=e.get(t);s&&(i.appContainer.removeFromLayer(fy,s),s.destroy(),e.delete(t))}getSpotsData(t){const e=[];return t.forEach(t=>{e.push(t.getSpotData())}),e}clearAllSpotsInternal(t){t.forEach((e,i)=>{const s=t.get(i);s&&(s.parent?.removeChild(s),s.destroy())}),t.clear()}updateSpotsEditState(t){t.forEach(t=>{t.updateEditState()})}isSpotDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}drawWayPoints(t){ng.log("[ControlsManager] drawWayPoints",t);const e=Array.from(this.wayPointMap.keys()),i=t.map(t=>t.id);e.filter(t=>!i.includes(t)).forEach(t=>{this.removeWayPoint(t,this.wayPointMap)}),t.forEach((t,e)=>{const i=e+1,s=this.wayPointMap.get(t.id);s?(this.isWayPointDataEqual(s.getWayPointData(),t)||s.updateWayPoint(t),s.updateOrder(i)):this.addNewWayPoint(t,i,this.wayPointMap)})}clearAllWayPoints(){ng.log("[ControlsManager] clearAllWayPoints"),this.clearAllWayPointsInternal(this.wayPointMap)}getWayPoints(){return this.getWayPointsData(this.wayPointMap)}addNewWayPoint(t,e,i){const s=Yi(),n=new rx({wayPointData:t,order:e,events:{onUpdate:s.events?.onUpdateWayPoint,onClick:s.events?.onClickWayPoint}});i.set(t.id,n),s.appContainer.addToLayer(fy,n)}removeWayPoint(t,e){const i=Yi(),s=e.get(t);s&&(i.appContainer.removeFromLayer(fy,s),s.destroy(),e.delete(t))}getWayPointsData(t){const e=[];return t.forEach(t=>{e.push(t.getWayPointData())}),e}clearAllWayPointsInternal(t){t.forEach((e,i)=>{const s=t.get(i);s&&(s.parent?.removeChild(s),s.destroy())}),t.clear()}updateWayPointsEditState(t){t.forEach(t=>{t.onEditStateChange()})}isWayPointDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}handleDividingRoomIdChange(t){null!=t&&-1!==t&&this.getRoomGeometry(t)?this.createDefaultDivider(t):this.clearDivider()}getRoomGeometry(t){return Yi().mapManager.getRoomById(t)}createDefaultDivider(t){const e=Yi();this.clearDivider(),this.divider=new ax({roomId:t,events:{onUpdate:t=>{e.events?.onUpdateDivider?.(t)}}}),e.appContainer.addToLayer(fy,this.divider)}clearDivider(){this.divider&&(Yi().appContainer.removeFromLayer(fy,this.divider),this.divider.destroy(),this.divider=null)}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}handleUnitChange(){ng.debug("[ControlsManager] Unit changed, refreshing all size texts"),this.forbiddenSweepZoneMap.forEach(t=>{t.refreshDisplay()}),this.forbiddenMopZoneMap.forEach(t=>{t.refreshDisplay()}),this.cleanZoneMap.forEach(t=>{t.refreshDisplay()}),this.virtualWallMap.forEach(t=>{t.refreshDisplay()}),this.spotMap.forEach(t=>{t.refreshDisplay()})}destroy(){this.clearAllForbiddenSweepZones(),this.clearAllForbiddenMopZones(),this.clearAllCleanZones(),this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class lx extends Py{objectData;clickHandler=null;unsubscribeMapRotation=null;constructor(t){super(),this.objectData=t}async initializeSprite(){const t=Yi(),e=t.detectedObjectConfig,i=this.objectData.width||e.width,s=this.objectData.height||e.height;await this.loadTextureAndSetSize(this.objectData.src,{width:i,height:s}),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,this.applyAntiRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyAntiRotation(t)}),e.interactive?this.setupClickHandler():this.eventMode="none"}applyAntiRotation(t){const e=-t*Math.PI/180;this.rotation=e}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new Sy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Yi();t.events?.onClickDetectedObject?.(this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(t){const e=Yi(),i=this.objectData;this.objectData=t;const s=e.detectedObjectConfig;if(i.src!==t.src){const e=t.width||s.width,i=t.height||s.height;await this.loadTextureAndSetSize(t.src,{width:e,height:i})}if(i.width!==t.width||i.height!==t.height){const e=t.width||s.width,i=t.height||s.height;this.setFixedSize(e,i)}this.position.set(t.x,t.y),s.interactive?this.clickHandler||this.setupClickHandler():this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null)}isSameData(t){return this.objectData.id===t.id&&this.objectData.src===t.src&&this.objectData.x===t.x&&this.objectData.y===t.y&&this.objectData.width===t.width&&this.objectData.height===t.height}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class cx{detectedObjectMap=new Map;updatePositionByOrigin(t,e){const i=Yi().appContainer.getLayer(yy);i&&i.position.set(t,e)}async drawDetectedObjects(t){if(!t||0===t.length)return void this.clearAllDetectedObjects();const e=new Set(t.map(t=>t.id)),i=Array.from(this.detectedObjectMap.keys());for(const t of i)e.has(t)||this.removeDetectedObject(t);for(const e of t){const t=this.detectedObjectMap.get(e.id);t?t.isSameData(e)||await t.updateObjectData(e):await this.addNewDetectedObject(e)}}clearAllDetectedObjects(){const t=Yi();this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(yy,e),e.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(t){const e=Yi(),i=new lx(t);await i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(yy,i)}removeDetectedObject(t){const e=Yi(),i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(yy,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.clearAllDetectedObjects()}}var dx,ux,px,gx,fx,mx,yx={},xx={},bx={},vx={},_x={},wx={},Ax=function(){if(mx)return yx;mx=1,Object.defineProperty(yx,"__esModule",{value:!0}),yx.decompressFrames=yx.decompressFrame=yx.parseGIF=void 0;var t,e=(px||(px=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=Ki(),i=Qi(),s={blocks:function(t){for(var e=[],s=t.data.length,n=0,r=(0,i.readByte)()(t);0!==r&&r;r=(0,i.readByte)()(t)){if(t.pos+r>=s){var o=s-t.pos;e.push((0,i.readBytes)(o)(t)),n+=o;break}e.push((0,i.readBytes)(r)(t)),n+=r}for(var a=new Uint8Array(n),h=0,l=0;l<e.length;l++)a.set(e[l],h),h+=e[l].length;return a}},n=(0,e.conditional)({gce:[{codes:(0,i.readBytes)(2)},{byteSize:(0,i.readByte)()},{extras:(0,i.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,i.readUnsigned)(!0)},{transparentColorIndex:(0,i.readByte)()},{terminator:(0,i.readByte)()}]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&249===e[1]}),r=(0,e.conditional)({image:[{code:(0,i.readByte)()},{descriptor:[{left:(0,i.readUnsigned)(!0)},{top:(0,i.readUnsigned)(!0)},{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{lct:(0,i.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,e.conditional)({lct:(0,i.readArray)(3,function(t,e,i){return Math.pow(2,i.descriptor.lct.size+1)})},function(t,e,i){return i.descriptor.lct.exists}),{data:[{minCodeSize:(0,i.readByte)()},s]}]},function(t){return 44===(0,i.peekByte)()(t)}),o=(0,e.conditional)({text:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{preData:function(t,e,s){return(0,i.readBytes)(s.text.blockSize)(t)}},s]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&1===e[1]}),a=(0,e.conditional)({application:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{id:function(t,e,s){return(0,i.readString)(s.blockSize)(t)}},s]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&255===e[1]}),h=(0,e.conditional)({comment:[{codes:(0,i.readBytes)(2)},s]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&254===e[1]}),l=[{header:[{signature:(0,i.readString)(3)},{version:(0,i.readString)(3)}]},{lsd:[{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{gct:(0,i.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,i.readByte)()},{pixelAspectRatio:(0,i.readByte)()}]},(0,e.conditional)({gct:(0,i.readArray)(3,function(t,e){return Math.pow(2,e.lsd.gct.size+1)})},function(t,e){return e.lsd.gct.exists}),{frames:(0,e.loop)([n,a,h,r,o],function(t){var e=(0,i.peekByte)()(t);return 33===e||44===e})}];t.default=l}(xx)),(t=xx)&&t.__esModule?t:{default:t}),i=Ki(),s=Qi(),n=(gx||(gx=1,Object.defineProperty(_x,"__esModule",{value:!0}),_x.deinterlace=void 0,_x.deinterlace=function(t,e){for(var i=new Array(t.length),s=t.length/e,n=function(s,n){var r=t.slice(n*e,(n+1)*e);i.splice.apply(i,[s*e,e].concat(r))},r=[0,4,2,1],o=[8,8,4,2],a=0,h=0;h<4;h++)for(var l=r[h];l<s;l+=o[h])n(l,a),a++;return i}),_x),r=(fx||(fx=1,Object.defineProperty(wx,"__esModule",{value:!0}),wx.lzw=void 0,wx.lzw=function(t,e,i){var s,n,r,o,a,h,l,c,d,u,p,g,f,m,y,x,b=4096,v=i,_=new Array(i),w=new Array(b),A=new Array(b),C=new Array(4097);for(a=1+(n=1<<(u=t)),s=n+2,l=-1,r=(1<<(o=u+1))-1,c=0;c<n;c++)w[c]=0,A[c]=c;for(p=g=f=m=y=x=0,d=0;d<v;){if(0===m){if(g<o){p+=e[x]<<g,g+=8,x++;continue}if(c=p&r,p>>=o,g-=o,c>s||c==a)break;if(c==n){r=(1<<(o=u+1))-1,s=n+2,l=-1;continue}if(-1==l){C[m++]=A[c],l=c,f=c;continue}for(h=c,c==s&&(C[m++]=f,c=l);c>n;)C[m++]=A[c],c=w[c];f=255&A[c],C[m++]=f,s<b&&(w[s]=l,A[s]=f,0===(++s&r)&&s<b&&(o++,r+=s)),l=h}m--,_[y++]=C[m],d++}for(d=y;d<v;d++)_[d]=0;return _}),wx);yx.parseGIF=function(t){var n=new Uint8Array(t);return(0,i.parse)((0,s.buildStream)(n),e.default)};var o=function(t,e,i){if(t.image){var s=t.image,o=s.descriptor.width*s.descriptor.height,a=(0,r.lzw)(s.data.minCodeSize,s.data.blocks,o);s.descriptor.lct.interlaced&&(a=(0,n.deinterlace)(a,s.descriptor.width));var h={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?h.colorTable=s.lct:h.colorTable=e,t.gce&&(h.delay=10*(t.gce.delay||10),h.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(h.transparentIndex=t.gce.transparentColorIndex)),i&&(h.patch=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(4*e),s=0;s<e;s++){var n=4*s,r=t.pixels[s],o=t.colorTable[r]||[0,0,0];i[n]=o[0],i[n+1]=o[1],i[n+2]=o[2],i[n+3]=r!==t.transparentIndex?255:0}return i}(h)),h}};return yx.decompressFrame=o,yx.decompressFrames=function(t,e){return t.frames.filter(function(t){return t.image}).map(function(i){return o(i,t.gct,e)})},yx}();class Cx{constructor(t){if(!t||!t.length)throw new Error("Invalid frames");const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(t=>t.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(t,e){if(!t||0===t.byteLength)throw new Error("Invalid buffer");const i=Ax.parseGIF(t);(t=>{let e=null;for(const i of t.frames)e=i.gce??e,"image"in i&&!("gce"in i)&&(i.gce=e)})(i);const s=Ax.decompressFrames(i,!0),n=[],r=i.lsd.width,o=i.lsd.height,a=ir.get().createCanvas(r,o),h=a.getContext("2d",{willReadFrequently:!0}),l=ir.get().createCanvas(),c=l.getContext("2d");let d=0,u=null;const{fps:p=30,...g}=e??{},f=1e3/p;for(let t=0;t<s.length;t++){const{disposalType:e=2,delay:i=f,patch:a,dims:{width:p,height:m,left:y,top:x}}=s[t];l.width=p,l.height=m,c.clearRect(0,0,p,m);const b=c.createImageData(p,m);b.data.set(a),c.putImageData(b,0,0),3===e&&(u=h.getImageData(0,0,r,o)),h.drawImage(l,y,x);const v=h.getImageData(0,0,r,o);2===e?h.clearRect(0,0,r,o):3===e&&h.putImageData(u,0,0);const _=ir.get().createCanvas(v.width,v.height);_.getContext("2d").putImageData(v,0,0),n.push({start:d,end:d+i,texture:new Gs({source:new sr({resource:_,...g})})}),d+=i}return a.width=a.height=0,l.width=l.height=0,new Cx(n)}}const Sx={extension:qi.Asset,detection:{test:async()=>!0,add:async t=>[...t,"gif"],remove:async t=>t.filter(t=>"gif"!==t)},loader:{name:"gifLoader",id:"gif",test:t=>".gif"===mr.extname(t)||t.startsWith("data:image/gif"),load:async(t,e)=>{const i=await ir.get().fetch(t),s=await i.arrayBuffer();return Cx.from(s,e?.data)},unload:async t=>{t.destroy()}}},Ix=class t extends Kn{constructor(...e){const i=e[0]instanceof Cx?{source:e[0]}:e[0],{source:s,fps:n,loop:r,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d,...u}=Object.assign({},t.defaultOptions,i);super({texture:Gs.EMPTY,...u}),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(),this.texture=s.textures[0],this.duration=s.frames[s.frames.length-1].end,this._source=s,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:n,loop:r,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d}),this.currentFrame=0,a&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(lr.shared.add(this.update,this,rr.HIGH),this._isConnectedToTicker=!0),this.loop||this.currentFrame!==this._source.frames.length-1||(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(t){if(!this._playing)return;const e=this.animationSpeed*t.deltaTime/lr.targetFPMS,i=this._currentTime+e,s=i%this.duration,n=this._source.frames.findIndex(t=>t.start<=s&&t.end>s);i>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(n),this.onLoop?.()):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),this.onComplete?.(),this.stop()):(this._currentTime=s,this._updateFrameIndex(n))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(lr.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,this.onFrameChange?.(t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const e=new t({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return e.dirty=!0,e}};Ix.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let Mx=Ix;es.add(Sx);class Tx extends Mx{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?ng.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?ng.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Yi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=t.currentScale;if(0===s)return;const n=e/s,r=i/s;super.scale.set(n,r)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static async createFromSrc(t,e){try{const i=await pl.load(t),s=new Tx({source:i});return void 0!==e.sizeFixed&&s.setSizeFixed(e.sizeFixed),s.setFixedSize(e.width,e.height),s}catch(e){throw ng.error(`Failed to load GIF "${t}":`,e),e}}draw(t,e){const{x:i,y:s,rotation:n=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=n,this.position.set(i,s)}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Px extends Tx{elementData;clickHandler=null;unsubscribeMapRotation=null;userRotation=0;constructor(t,e){super({source:t}),this.elementData=e}async initialize(){const t=Yi();void 0!==this.elementData.sizeFixed&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.userRotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.applyRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const e=-t*Math.PI/180;this.rotation=this.userRotation+e}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new Sy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Yi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;if(this.elementData=t,e.src!==t.src)throw new Error("GIF source change requires recreation of instance");if(e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height),this.position.set(t.x,t.y),void 0!==t.rotation){this.userRotation=t.rotation;const e=Yi();this.applyRotation(e.runtime.mapRotation)}void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Ex extends Py{elementData;clickHandler=null;unsubscribeMapRotation=null;userRotation=0;constructor(t){super(),this.elementData=t}async initialize(){const t=Yi();await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed}),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.userRotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.applyRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const e=-t*Math.PI/180;this.rotation=this.userRotation+e}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new Sy(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Yi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;if(this.elementData=t,e.src!==t.src?await this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height,sizeFixed:t.sizeFixed}):(e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height)),this.position.set(t.x,t.y),void 0!==t.rotation){this.userRotation=t.rotation;const e=Yi();this.applyRotation(e.runtime.mapRotation)}void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Bx extends fl{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;userCenterX=0;userCenterY=0;sizeFixed=!0;constructor(t){super(t),this.anchor.set(0,0),this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applyFixedSize(),this.updatePositionFromCenter()}setCenterPosition(t,e){this.userCenterX=t,this.userCenterY=e,this.updatePositionFromCenter()}setSizeFixed(t){this.sizeFixed=t,this.isFixedSizeSet&&(this.applyFixedSize(),this.updatePositionFromCenter())}getIsFixedSizeSet(){return this.isFixedSizeSet}updatePositionFromCenter(){if(!this.isFixedSizeSet)return void this.position.set(this.userCenterX,this.userCenterY);const t=Yi().currentScale;let e,i;this.sizeFixed?(e=this.fixedWidth/2/t,i=this.fixedHeight/2/t):(e=this.fixedWidth/2,i=this.fixedHeight/2),this.position.set(this.userCenterX-e,this.userCenterY-i)}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const t=Yi().currentScale;if(0!==t){if(this.sizeFixed){const e=1/t;this.scale.set(e)}else this.scale.set(1);this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}}updateScale(t){this.isFixedSizeSet&&0!==t&&(this.applyFixedSize(),this.updatePositionFromCenter())}updateTransform(t){return super.updateTransform(t)}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Rx extends Bx{elementData;domClickHandler=null;resizeObserver=null;debugMarker=null;unsubscribeMapRotation=null;userRotation=0;constructor(t){const e=document.createElement("div");Rx.setupDefaultStyles(e,t),e.innerHTML=t.htmlContent,super({element:e}),this.elementData=t}async initialize(){const t=Yi();this.alpha=0,this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.waitForElementInsertion()):(this.position.set(this.elementData.x,this.elementData.y),this.setupAutoSize()),void 0!==this.elementData.rotation&&(this.userRotation=this.elementData.rotation),this.applyRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const e=-t*Math.PI/180;this.rotation=this.userRotation+e}setupAutoSize(){this.element&&(this.element.style.width="auto",this.element.style.height="auto",this.waitForElementDimensions())}waitForElementInsertion(){if(!this.element)return;const t=()=>{this.element&&(this.element.isConnected?this.showElement():requestAnimationFrame(t))};requestAnimationFrame(t)}waitForElementDimensions(){this.element&&("undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(t=>{const e=t[0];e&&e.contentRect.width>0&&e.contentRect.height>0&&(this.setFixedSize(e.contentRect.width,e.contentRect.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),0===this.alpha&&this.showElement(),this.resizeObserver?.disconnect(),this.resizeObserver=null)}),this.resizeObserver.observe(this.element)):this.pollForElementDimensions())}pollForElementDimensions(){if(!this.element)return;const t=()=>{if(!this.element)return;if(!this.element.isConnected)return void requestAnimationFrame(t);const e=this.element.getBoundingClientRect();e.width>0&&e.height>0?(this.setFixedSize(e.width,e.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),0===this.alpha&&this.showElement()):requestAnimationFrame(t)};requestAnimationFrame(t)}showElement(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none")),Yi().getApp().renderOnceNextFrame()}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){const t=Yi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;this.elementData=t,e.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,t.width&&t.height||this.waitForElementDimensions()),e.width===t.width&&e.height===t.height||(t.width&&t.height?(this.setFixedSize(t.width,t.height),this.element&&(this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`)):this.setupAutoSize()),t.width&&t.height||this.getIsFixedSizeSet()?this.setCenterPosition(t.x,t.y):this.position.set(t.x,t.y),e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.userRotation=t.rotation??0;const i=Yi();this.applyRotation(i.runtime.mapRotation),this.alpha=t.opacity??1,t.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.htmlContent===t.htmlContent&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}static setupDefaultStyles(t,e){const i={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto"};e.width&&e.height?(i.width=`${e.width}px`,i.height=`${e.height}px`,i.overflow="hidden"):(i.width=e.width?`${e.width}px`:"auto",i.height=e.height?`${e.height}px`:"auto",i.overflow="visible"),Object.assign(t.style,i),t.style.setProperty("-webkit-tap-highlight-color","transparent"),t.style.setProperty("-webkit-touch-callout","none")}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),this.debugMarker&&(this.debugMarker.destroy(),this.debugMarker=null),super.destroy()}}class kx{customElementsMap=new Map;gifTicker=null;gifElements=new Set;constructor(){}updatePositionByOrigin(t,e){const i=Yi(),s=i.appContainer.getLayer(xy),n=i.appContainer.getLayer(by);s&&s.position.set(t,e),n&&n.position.set(t,e)}async drawCustomElements(t){if(!t||0===t.length)return void this.clearAllCustomElements();const e=new Set(t.map(t=>t.id)),i=Array.from(this.customElementsMap.keys());for(const t of i)e.has(t)||this.removeCustomElement(t);const s=t.map(async t=>{const e=this.customElementsMap.get(t.id);e?this.isSameData(e,t)||("gif"===t.type&&e.getElementData().src!==t.src?(this.removeCustomElement(t.id),await this.addNewCustomElement(t)):await this.updateElementData(e,t)):await this.addNewCustomElement(t)});await Promise.all(s),this.updateGifTicker()}clearAllCustomElements(){const t=Yi();this.customElementsMap.forEach(e=>{e instanceof Px?t.appContainer.removeFromLayer(by,e):t.appContainer.removeFromLayer(xy,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(t){const e=Yi();let i;switch(t.type){case"image":i=new Ex(t);break;case"gif":{const e=await pl.load(t.src);i=new Px(e,t);break}case"html":i=new Rx(t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}await i.initialize(),this.customElementsMap.set(t.id,i),i instanceof Px?(e.appContainer.addToLayer(by,i),this.gifElements.add(i)):e.appContainer.addToLayer(xy,i)}removeCustomElement(t){const e=Yi(),i=this.customElementsMap.get(t);i&&(i instanceof Px?(this.gifElements.delete(i),e.appContainer.removeFromLayer(by,i)):e.appContainer.removeFromLayer(xy,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type===e.type&&("image"===e.type&&t instanceof Ex||"gif"===e.type&&t instanceof Px||"html"===e.type&&t instanceof Rx)&&t.isSameData(e)}async updateElementData(t,e){if("image"===e.type&&t instanceof Ex)await t.updateElementData(e);else if("gif"===e.type&&t instanceof Px)await t.updateElementData(e);else{if(!("html"===e.type&&t instanceof Rx))throw new Error("Element type mismatch during update");await t.updateElementData(e)}}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){this.gifTicker?.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new lr,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){this.gifTicker?.started&&(ng.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=Yi();if(0===this.gifElements.size)return;const e=t.getApp();e.renderer.render(e.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class Ox extends Kl{roomId;roomIndex;constructor(t){const e=Yi(),{nameLabel:i,colors:s}=e.roomConfig,n=t.colorIndex??t.index,r=s.name[n%s.name.length],o=new yh({fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWeight,fill:r,align:"center"});super({text:t.name||"Unknown",style:o}),this.roomId=t.id,this.roomIndex=t.index,this.anchor.set(.5)}updateName(t){this.text=t}refreshColor(t){const e=Yi(),{colors:i}=e.roomConfig,s=e.getRoomData(this.roomId),n=s?.colorIndex??this.roomIndex,r=t??i.name[n%i.name.length];this.style.fill=r}}class Dx extends Xn{background;foldedIndicator;propertyIcons=new Map;orderContainer;orderBackground;orderText;isFolded=!1;roomId;roomIndex;constructor(t){super();const e=Yi(),i=e.roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new Ll,this.foldedIndicator=new Ll,this.foldedIndicator.visible=!1;const{property:s,colors:{propertyTheme:n}}=i,r=n[(t.colorIndex??t.index)%n.length];this.initializePropertyIcons(s.displayOrders,r),this.orderContainer=new Xn,this.orderBackground=new Ll,this.orderText=new Kl({text:"",style:new yh({fontSize:s.cleanOrder.fontSize,fontFamily:s.cleanOrder.fontFamily,fontWeight:s.cleanOrder.fontWeight,fill:s.cleanOrder.color,align:"center",trim:!0})}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.addChild(this.background),this.addChild(this.foldedIndicator),this.propertyIcons.forEach(({sprite:t})=>{this.addChild(t)}),this.addChild(this.orderContainer),this.visible=e.runtimeSnapshot.showRoomProperty}initializePropertyIcons(t,e){const i=["cleanMode","suction","cistern","cleanTimes"];t.forEach(t=>{const s=i.includes(t),n=new Py;n.tint=e,n.anchor.set(0,0),this.propertyIcons.set(t,{fieldName:t,sprite:n,isBuiltin:s})})}async updateProperty(t){await this.updateIcons(t),this.updateBackground()}getFieldValue(t,e){if(["cleanMode","suction","cistern","cleanTimes"].includes(e))return t[e]??null;if(t.customData&&e in t.customData){const i=t.customData[e];return"number"==typeof i?i:null}return null}getAssetAlias(t,e){const i={cleanMode:t=>`cleanMode_${t}`,suction:t=>`fan_${t}`,cistern:t=>`water_${t}`,cleanTimes:t=>`cleanTimes${t}`};return t in i?i[t](e):`custom_${t}_${e}`}shouldShowField(t,e,i){const s=Yi(),{showRoomProperty:n}=s.runtimeSnapshot;return!(null===i||!n||"cleanTimes"===e&&i<=0)}getDisplayElements(t){const e=Yi(),{displayOrders:i}=e.roomConfig.property,{showRoomOrder:s}=e.runtimeSnapshot,n=t.order||0,r=[];return s&&n>0&&r.push({element:this.orderContainer,show:!0,isOrder:!0,fieldName:"order"}),i.forEach(e=>{const i=this.propertyIcons.get(e);if(!i)return;const s=this.getFieldValue(t,e);this.shouldShowField(t,e,s)&&null!==s&&r.push({element:i.sprite,show:!0,isOrder:!1,fieldName:e,value:s})}),{elementsToShow:r,orderValue:n}}async updateIcons(t){const e=Yi();if(this.isFolded)return;const{iconWidth:i,iconHeight:s,container:n,cleanOrder:r,iconGap:o}=e.roomConfig.property,{propertyTheme:a}=e.roomConfig.colors,{paddingHorizontal:h,paddingVertical:l}=n,{elementsToShow:c,orderValue:d}=this.getDisplayElements(t);this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:t})=>{t.visible=!1});const u=[];c.forEach(e=>{if(e.isOrder){this.orderContainer.visible=!0,this.orderText.text=d.toString();const e=t.colorIndex??this.roomIndex;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:a[e%a.length]}),this.orderBackground.circle(i/2,s/2,i/2).fill(),this.orderText.position.set(i/2,s/2)}else{const t=this.propertyIcons.get(e.fieldName);if(t){t.sprite.visible=!0;const n=this.getAssetAlias(e.fieldName,e.value);u.push(t.sprite.loadTextureAndSetSize(n,{width:i,height:s,sizeFixed:!1}))}}}),await Promise.all(u);let p=h;c.forEach((t,e)=>{const{element:s,isOrder:n}=t;s.position.set(p,l),p+=i,e<c.length-1&&(p+=n?r.gapRight:o)})}updateBackground(){const t=Yi();if(this.isFolded)return;const e=t.roomConfig,{container:i,foldable:s}=e.property,{borderRadius:n,tailHeight:r,tailWidth:o,backgroundColor:a}=i,h=this.calculateContentWidth(),l=this.calculateContentHeight(),c=Math.min(o,h/2);if(this.background.clear(),this.background.setFillStyle({color:a}),this.background.roundRect(0,0,h,l,n),s){const t=(h-c)/2;this.background.poly([t,l-1,t+c,l-1,t+c/2,l+r])}this.background.fill()}calculateContentWidth(){const t=Yi(),{iconWidth:e,container:i,cleanOrder:s,iconGap:n}=t.roomConfig.property,{paddingHorizontal:r}=i,o=t.getRoomData(this.roomId);if(!o)return 2*r;const{elementsToShow:a}=this.getDisplayElements(o);let h=r;return a.forEach((t,i)=>{const{isOrder:r}=t;h+=e,i<a.length-1&&(h+=r?s.gapRight:n)}),h+=r,h}calculateContentHeight(){const t=Yi().roomConfig,{iconHeight:e,container:i}=t.property;return i.paddingVertical+e+i.paddingVertical}getTotalHeight(){const t=Yi(),{foldable:e,container:i}=t.roomConfig.property,{tailHeight:s}=i;return this.isFolded?s:this.calculateContentHeight()+(e?s:0)}getTotalWidth(){if(this.isFolded){const t=Yi(),{tailWidth:e}=t.roomConfig.property.container,i=this.calculateContentWidth();return Math.min(e,i/2)}return this.calculateContentWidth()}async setFolded(t){const e=Yi(),{foldable:i}=e.roomConfig.property;if(i)if(this.isFolded=t,t)this.background.visible=!1,this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:t})=>{t.visible=!1}),this.foldedIndicator.visible=!0,this.updateFoldedIndicator();else{this.background.visible=!0,this.foldedIndicator.visible=!1,this.foldedIndicator.position.set(0,0),this.updateBackground();const t=e.getRoomData(this.roomId);t&&await this.updateIcons(t)}}isFoldedState(){const t=Yi(),{foldable:e}=t.roomConfig.property;return!!e&&this.isFolded}updateFoldedIndicator(){const t=Yi().roomConfig,{tailHeight:e,tailWidth:i,backgroundColor:s}=t.property.container,n=this.calculateContentWidth(),r=Math.min(i,n/2);this.foldedIndicator.clear(),this.foldedIndicator.setFillStyle({color:s}),this.foldedIndicator.poly([0,e,r,e,r/2,0]).fill(),this.foldedIndicator.position.set(0,0)}refreshColor(){const t=Yi(),{propertyTheme:e}=t.roomConfig.colors,i=t.getRoomData(this.roomId),s=i?.colorIndex??this.roomIndex,n=e[s%e.length];if(this.propertyIcons.forEach(({sprite:t})=>{t.tint=n}),this.orderBackground&&this.orderBackground.visible){const{property:i}=t.roomConfig,n=i.iconWidth,r=i.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:e[s%e.length]}),this.orderBackground.circle(n/2,r/2,n/2).fill()}}destroy(){this.propertyIcons.forEach(({sprite:t})=>{t.destroy()}),this.propertyIcons.clear(),super.destroy()}}class Fx extends Xn{background;checkmarkIcon;bubble;roomIndex;roomId;constructor(t){super();const e=Yi().roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new Ll,this.bubble=new Ll;const{colors:{selectionIndicatorIcon:i}}=e;this.checkmarkIcon=new Py,this.checkmarkIcon.tint=i[t.index%i.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon)}async updateIndicator(t){const e=Yi(),{roomSelectionMode:i,enableRoomSelection:s,selectRoomIds:n}=e.runtimeSnapshot;if(!s||"checkmark"!==i)return void(this.visible=!1);const r=n.includes(t.id);await this.showCheckmarkMode(r),this.updateBackground()}async showCheckmarkMode(t){const e=Yi(),{selectionIndicator:i}=e.roomConfig,{iconWidth:s,iconHeight:n}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:s,height:n,sizeFixed:!1});const t=i.containerWidth/2,e=i.containerHeight/2;this.checkmarkIcon.position.set(t-s/2,e-n/2)}else this.visible=!1}updateBackground(){const t=Yi(),{selectionIndicator:e,colors:i}=t.roomConfig,{containerWidth:s,containerHeight:n,strokeWidth:r,strokeColor:o,borderRadius:a,tailHeight:h,tailWidth:l}=e,c=t.getRoomData(this.roomId),d=c?.colorIndex??this.roomIndex,u=i.selectionIndicatorBackground[d%i.selectionIndicatorBackground.length],p="auto"===o?u:o;if(this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:u}).roundRect(0,0,s,n,a).fill().setStrokeStyle({color:p,width:r,alignment:0}).stroke(),h>0&&l>0){const t=(s-l)/2;this.bubble.setFillStyle({color:p});const e=n+r;this.bubble.poly([t,e-1,t+l,e-1,t+l/2,e+h]).fill()}}getTotalHeight(){const t=Yi(),{selectionIndicator:e}=t.roomConfig,{containerHeight:i,tailHeight:s,strokeWidth:n}=e;return i+n+(s>0?s:0)}getTotalWidth(){const t=Yi(),{selectionIndicator:e}=t.roomConfig;return e.containerWidth}async refreshColor(){const t=Yi().getRoomData(this.roomId);t&&await this.updateIndicator(t)}destroy(){this.checkmarkIcon?.destroy(),super.destroy()}}class Lx extends Xn{roomId;roomName;roomProperty=null;roomSelectionIndicator=null;clickHandler=null;unsubscribeMapRotation=null;targetElasticScale=1;currentElasticScale=1;isAnimatingScale=!1;scaleAnimationBound=null;updateScaleBound=null;constructor(t){super();const e=Yi();this.enableRenderGroup(),this.roomId=t.id,this.initializeElasticScale(e.currentScale),this.updateScaleBound=t=>this.updateScale(t),e.emitter.on("antiScale",this.updateScaleBound),this.updateScale(e.currentScale),t.centerPoint&&this.position.set(t.centerPoint.x,t.centerPoint.y),this.roomName=new Ox(t),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.createRoomProperty(t),this.createRoomSelectionIndicator(t),this.updateLayout(),this.applyAntiRotation(e.runtime.mapRotation),this.unsubscribeMapRotation=Xi(e.runtime,"mapRotation",t=>{this.applyAntiRotation(t)}),this.clickHandler=new Sy(this,{onClick:()=>{e.events?.onClickRoomProperties?.(t)}})}applyAntiRotation(t){const e=-t*Math.PI/180;this.rotation=e}initializeElasticScale(t){const e=Yi(),{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=e.roomConfig;if(!i)return;let r;r=t<=1?s:t>=5?n:1,this.targetElasticScale=r,this.currentElasticScale=r}updateScale(t){const e=Yi(),{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=e.roomConfig;if(!i)return void(0!==t&&this.scale.set(1/t));if(0===t)return;let r;r=t<=1?s:t>=5?n:1;const o=1/t*r;Math.abs(this.targetElasticScale-r)>.01?(this.targetElasticScale=r,this.startScaleAnimation()):this.scale.set(o)}startScaleAnimation(){const t=Yi();this.scaleAnimationBound||(this.scaleAnimationBound=this.animateScale.bind(this)),this.isAnimatingScale||(this.isAnimatingScale=!0,t.getApp().ticker.add(this.scaleAnimationBound))}animateScale(){const t=Yi();this.currentElasticScale+=.3*(this.targetElasticScale-this.currentElasticScale);const e=1/t.currentScale*this.currentElasticScale;this.scale.set(e),Math.abs(this.currentElasticScale-this.targetElasticScale)<.001&&(this.currentElasticScale=this.targetElasticScale,this.isAnimatingScale=!1,this.scaleAnimationBound&&t.getApp().ticker.remove(this.scaleAnimationBound))}shouldShowRoomProperty(){const t=Yi(),{showRoomOrder:e,showRoomProperty:i,selectRoomIds:s,enableRoomSelection:n,roomSelectionMode:r}=t.runtimeSnapshot,o=t.getRoomData(this.roomId);if(!o)return!1;if(n&&"checkmark"===r&&s.includes(this.roomId))return!1;const a=e&&(o.order||0)>0;let h=!1;if(i){const{displayOrders:e}=t.roomConfig.property;h=e.some(t=>"suction"===t&&null!=o.suction||"cistern"===t&&null!=o.cistern||"cleanMode"===t&&null!=o.cleanMode||"cleanTimes"===t&&o.cleanTimes>0||!(!o.customData||!(t in o.customData)||"number"!=typeof o.customData[t]||null==o.customData[t]))}return a||h}shouldShowRoomSelectionIndicator(){const t=Yi(),{enableRoomSelection:e,roomSelectionMode:i}=t.runtimeSnapshot;return e&&"checkmark"===i}async updateRoomPropertyVisibility(){const t=Yi();if(this.roomProperty){if(this.shouldShowRoomProperty()){this.roomProperty.visible=!0;const e=t.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);await this.roomProperty.setFolded(e);const i=t.getRoomData(this.roomId);i&&await this.roomProperty.updateProperty(i)}else this.roomProperty.visible=!1;this.updateLayout()}}async updateRoomSelectionIndicatorVisibility(){const t=Yi();if(this.roomSelectionIndicator){if(this.shouldShowRoomSelectionIndicator()){const e=t.getRoomData(this.roomId);e&&await this.roomSelectionIndicator.updateIndicator(e)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}}async createRoomProperty(t){this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new Dx(t),await this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),await this.updateRoomPropertyVisibility(),this.updateLayout()}async createRoomSelectionIndicator(t){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new Fx(t),await this.updateRoomSelectionIndicatorVisibility(),this.addChild(this.roomSelectionIndicator)}updateLayout(){const t=Yi(),{property:{offsetY:e,offsetX:i},selectionIndicator:{offsetY:s,offsetX:n}}=t.roomConfig,r=this.roomProperty?.visible||!1,o=this.roomName.visible,a=this.roomSelectionIndicator?.visible||!1;if(r&&this.roomProperty){const t=this.roomProperty.getTotalHeight(),s=this.roomProperty.getTotalWidth();if(this.roomProperty.isFoldedState()){const n=-s/2+i,r=-t/2-e;this.roomProperty.position.set(n,r)}else o?(this.roomProperty.position.set(-s/2+i,-e-t),this.roomName.position.set(0,0)):this.roomProperty.position.set(-s/2+i,-t/2-e)}if(a&&this.roomSelectionIndicator){const t=this.roomSelectionIndicator.getTotalHeight(),e=this.roomSelectionIndicator.getTotalWidth();o?(this.roomSelectionIndicator.position.set(-e/2+n,-s-t),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-e/2+n,-t/2-s)}!o||r||a||this.roomName.position.set(0,0)}updateName(t){this.roomName.updateName(t)}updateRoomNameVisibility(t){this.roomName.visible=t,this.updateLayout()}updatePosition(t){this.position.set(t.x,t.y)}async refreshColor(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&await this.roomSelectionIndicator.refreshColor()}destroy(){const t=Yi();this.clickHandler?.destroy(),this.clickHandler=null,this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.isAnimatingScale&&this.scaleAnimationBound&&(t.getApp().ticker.remove(this.scaleAnimationBound),this.isAnimatingScale=!1),this.scaleAnimationBound=null,this.updateScaleBound&&(t.emitter.off("antiScale",this.updateScaleBound),this.updateScaleBound=null),this.roomProperty?.destroy(),this.roomProperty=null,this.roomSelectionIndicator?.destroy(),this.roomSelectionIndicator=null,this.roomName?.destroy(),super.destroy()}}class jx extends Xn{floorTypeMap=new Map;floorTypeMasks=new Map;floorTypeToRooms=new Map;constructor(){super({isRenderGroup:!0}),Yi().appContainer.addToLayer(cy,this)}async createFloorTypes(t){if(!Yi().runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const e=this.groupRoomsByFloorType(t),i=[];for(const[t,s]of e)i.push(this.createMergedFloorType(t,s));await Promise.all(i)}groupRoomsByFloorType(t){const e=new Map,i=Yi();return t.forEach((t,s)=>{const n=i.getRoomData(s),r=n?.floorType||0;r>=0&&(e.has(r)||e.set(r,[]),e.get(r).push({roomId:s,graphics:t}))}),e}async createMergedFloorType(t,e){const i=Yi(),{assets:s,opacity:n,scale:r}=i.roomConfig.floorType,o=t%s.length,a=`floorType${o}`;if(!s[o])return void ng.warn(`No texture asset configured for floorType: ${t}`);const h=await pl.load(a);if(!h)return void ng.warn(`Floor material texture not found: ${a}`);const l=(t=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let e=t[0].x,i=t[0].y,s=t[0].x+t[0].width,n=t[0].y+t[0].height;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),s=Math.max(s,t.x+t.width),n=Math.max(n,t.y+t.height)}),{x:e,y:i,width:s-e,height:n-i}})(e.map(({graphics:t})=>t.getLocalBounds())),c=new Hl({texture:h,width:l.width,height:l.height});c.x=l.x,c.y=l.y,c.alpha=n,c.tileScale.set(r);const d=this.createMergedMask(e.map(({graphics:t})=>t));c.mask=d,this.addChild(c),this.floorTypeMap.set(t,c),this.floorTypeMasks.set(t,d),this.floorTypeToRooms.set(t,new Set(e.map(({roomId:t})=>t)))}createMergedMask(t){const e=new Xn;return t.forEach(t=>{const i=new Ll;i.context=t.context.clone(),e.addChild(i)}),e}clearFloorTypes(){this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(t){ng.warn("Error destroying floor material:",t)}}),this.floorTypeMap.clear(),this.floorTypeMasks.forEach(t=>{try{t.destroy()}catch(t){ng.warn("Error destroying floor mask:",t)}}),this.floorTypeMasks.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class Gx{unsubscribeFns=[];roomInfoContainer=new Xn;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new jx;constructor(){const t=Yi();t.appContainer.addToLayer(my,this.roomInfoContainer);const e=Xi(t.runtime,"showRoomFloorType",t=>{ng.log(`[runtime] showRoomFloorType: ${t}`),t?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=Xi(t.runtime,"showRoomProperty",t=>{ng.log(`[runtime] showRoomProperty: ${t}`),this.updateAllRoomPropertyVisibility()}),s=Xi(t.runtime,"showRoomOrder",t=>{ng.log(`[runtime] showRoomOrder: ${t}`),this.updateAllRoomPropertyVisibility()}),n=Xi(t.runtime,"roomPropertyFoldIds",t=>{ng.log(`[runtime] roomPropertyFoldIds: ${t}`),this.updateAllRoomPropertyVisibility()}),r=Xi(t.runtime,"showRoomName",t=>{ng.log(`[runtime] showRoomName: ${t}`),this.updateAllRoomNameVisibility(t)}),o=Xi(t.runtime,"enableRoomSelection",t=>{ng.log(`[runtime] enableRoomSelection: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),a=Xi(t.runtime,"selectRoomIds",t=>{ng.log(`[runtime] selectRoomIds: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),h=Xi(t.runtime,"roomSelectionMode",t=>{ng.log(`[runtime] roomSelectionMode: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(e,i,s,n,r,o,a,h)}async drawRoomProperty(t){const e=Yi();return this.roomDisplayMap.clear(),t.forEach((t,i)=>{const s=e.mapManager.getRoomById(t.id),n={...t,centerPoint:s?.centerPoint||null,index:i,colorIndex:s?.colorIndex};this.roomDisplayMap.set(t.id,n)}),await this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}async updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return void(0===Yi().mapManager.getAllRooms().length&&this.clearRoomInfos());const t=Array.from(this.roomDisplayMap.values()).filter(t=>null!==t.centerPoint);this.clearRoomInfos(),await Promise.all(t.map(t=>this.createRoomInfo(t)))}async createRoomInfo(t){const e=new Lx(t);this.roomInfoContainer.addChild(e),this.roomInfoMap.set(t.id,e)}updateRoomName(t,e){const i=this.roomInfoMap.get(t);i&&i.updateName(e)}updateRoomPosition(t,e){const i=this.roomDisplayMap.get(t);i&&(i.centerPoint=e);const s=this.roomInfoMap.get(t);s&&s.updatePosition(e)}clearRoomInfos(){this.roomInfoMap.forEach(t=>{t.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(t){return this.roomDisplayMap.get(t)}async refresh(){const t=Yi();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const s=t.mapManager.getRoomById(i),n=s?.centerPoint||null;if(e.centerPoint!==n){e.centerPoint=n;const t=this.roomInfoMap.get(i);t&&n&&t.updatePosition(n)}const r=s?.colorIndex;if(e.colorIndex!==r&&void 0!==r){e.colorIndex=r;const t=this.roomInfoMap.get(i);t&&t.refreshColor()}}),await this.updateRoomInfoDisplay(),this.updateFloorTypes()}async updateAllRoomPropertyVisibility(){0!==this.roomInfoMap.size&&await Promise.all(Array.from(this.roomInfoMap.values()).map(async t=>{try{await t.updateRoomPropertyVisibility()}catch(t){}}))}updateAllRoomNameVisibility(t){0!==this.roomInfoMap.size&&this.roomInfoMap.forEach(e=>{e.updateRoomNameVisibility(t)})}updateAllRoomSelectionIndicatorVisibility(){0!==this.roomInfoMap.size&&this.roomInfoMap.forEach(t=>{t.updateRoomSelectionIndicatorVisibility()})}async updateFloorTypes(){const t=Yi(),e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0?(await this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame()):0===t.mapManager.getAllRooms().length&&this.roomFloorType.clearFloorTypes()}clear(){this.clearRoomInfos(),this.roomInfoContainer.removeChildren(),this.roomInfoMap.clear(),this.roomDisplayMap.clear(),this.roomFloorType.clearFloorTypes()}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}navigator?.userAgent?.includes("tuya-ark-ide")||navigator?.userAgent?.includes("miniProgram");const Ux=()=>{if(!Nr.any)return!0;const t=navigator.userAgent.toLowerCase();let e=!1;if(/iphone|ipad|ipod/.test(t)){const i=t.match(/os (\d+)_/)?.[1];e=(i?parseInt(i):0)>=12}else if(/android/.test(t)){const i=t.match(/android (\d+)/)?.[1];e=(i?parseInt(i):0)>=10}return e&&(()=>{const t=navigator.deviceMemory;return!t||t>=4})()};class zx extends Oo{mapState=null;components={};managers={};config=$m;runtime;scaleMin=.5;scaleMax=5;events={};instanceKey;containerElement;emitter=function(t){return{all:t=t||new Map,on:function(e,i){var s=t.get(e);s?s.push(i):t.set(e,[i])},off:function(e,i){var s=t.get(e);s&&(i?s.splice(s.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var s=t.get(e);s&&s.slice().map(function(t){t(i)}),(s=t.get("*"))&&s.slice().map(function(t){t(e,i)})}}}();tickerState={renderReasons:new Set,renderTimer:null};pendingAsyncRender=!1;isFirstMapDraw=!0;constructor(t=sy){super(),this.instanceKey=t,ry.registerInstance(t,this),globalThis.__PIXI_APP__=this}async initialize(t){return ry.provideAsync(this,async()=>{const{resizeTo:e,events:i,config:s,runtime:n={},...r}=t;this.config=km(this.config,s??{},(t,e)=>{if(Array.isArray(e))return e}),ng.log("Applying config",this.config,s),this.runtime=Zi(Object.assign({},ty,n));const o=this.instanceKey===sy;this.containerElement=e;const a=o?{textureGCMaxIdle:Nr.any?180:3600,textureGCCheckCountMax:Nr.any?100:50,autoStart:!1,eventFeatures:{move:!0,globalMove:!1,click:!0,wheel:!0}}:{textureGCMaxIdle:60,textureGCCheckCountMax:10,autoStart:!1,eventFeatures:{move:!1,globalMove:!1,click:!1,wheel:!1}};await this.init({resizeTo:o?e:void 0,preferWebGLVersion:2,resolution:window.devicePixelRatio||1,antialias:Ux(),autoDensity:!0,backgroundColor:this.config.global.backgroundColor,...a,...r}),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=i,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new ky,this.managers.heatmapManager=new Ny,this.managers.pathManager=new Uy,this.managers.controlsManager=new hx,this.managers.detectedObjectManager=new cx,this.managers.customElementsManager=new kx,this.managers.roomsManager=new Gx,this.setupMapRotationListener(),document.addEventListener("visibilitychange",this.onVisibilityChange)})}async drawMap(t){return ry.provideAsync(this,async()=>{ng.log("[Map] drawMap",t);const{size:e,resolution:i,origin:s}=t;s[0]===this.mapState?.origin.x&&s[1]===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(...s),this.managers.controlsManager.updatePositionByOrigin(...s),this.managers.detectedObjectManager.updatePositionByOrigin(...s),this.managers.customElementsManager.updatePositionByOrigin(...s)),this.mapState={id:t.id,status:1===t.status,origin:{x:s[0],y:s[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:t.charger.angle??0,resolution:i,width:e[0],height:e[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawMap(t),0!==e[0]&&0!==e[1]||(ng.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear()),this.renderOnce()})}async drawRasterMap(t){return ry.provideAsync(this,async()=>{ng.log("[Map] drawRasterMap",t);const{mapHeader:e,mapData:i}=t,{originX:s,originY:n}=e;s===this.mapState?.origin.x&&n===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(s,n),this.managers.controlsManager.updatePositionByOrigin(s,n),this.managers.detectedObjectManager.updatePositionByOrigin(s,n),this.managers.customElementsManager.updatePositionByOrigin(s,n)),this.mapState={id:e.id,status:e.mapStable,origin:{x:s,y:n},charger:{x:e.chargeX,y:e.chargeY},chargerDirection:e.chargeDirection??0,resolution:100*e.mapResolution,width:e.mapWidth,height:e.mapHeight,version:e.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawRasterMap(i.parsed,this.mapState),0!==e.mapWidth&&0!==e.mapHeight||(ng.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear()),this.renderOnce()})}drawPath(t){return ry.provide(this,()=>{ng.log("[Path] drawPath",t),this.events?.onPathDrawed?.({id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:t.pathPoints[t.pathPoints.length-1]??null}),this.managers.pathManager.draw(t),this.renderOnce()})}async drawRoomProperty(t){return ry.provideAsync(this,async()=>{ng.log("[Room] drawRoomProperty",t),this.events?.onRoomPropertiesDrawed?.(t),await this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()})}drawHeatmap({mapData:t,heatmapPoints:e,useGradient:i=!0}){return ry.provide(this,()=>{ng.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw({mapData:t,heatmapPoints:e,useGradient:i}),this.renderOnce()})}drawForbiddenSweepZones(t){return ry.provide(this,()=>{ng.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()})}drawForbiddenMopZones(t){return ry.provide(this,()=>{ng.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()})}drawCleanZones(t){return ry.provide(this,()=>{ng.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()})}drawVirtualWalls(t){return ry.provide(this,()=>{ng.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()})}drawSpots(t){return ry.provide(this,()=>{ng.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()})}drawWayPoints(t){return ry.provide(this,()=>{ng.log("[Controls] drawWayPoints",t),this.managers.controlsManager.drawWayPoints(t),this.renderOnceNextFrame()})}async drawDetectedObjects(t){return ry.provideAsync(this,async()=>{ng.log("[DetectedObject] drawDetectedObjects",t),await this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()})}async drawCustomElements(t){return ry.provideAsync(this,async()=>{ng.log("[CustomElements] drawCustomElements",t),await this.managers.customElementsManager.drawCustomElements(t),this.renderOnceNextFrame()})}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getWayPoints(){return this.managers.controlsManager.getWayPoints()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}fitMapToView(t,e=!1){return ry.provide(this,()=>{if(!t||t.minX===t.maxX||t.minY===t.maxY)return;const i=this.config.map.autoPaddingVerticalPercent,s=this.config.map.autoPaddingHorizontalPercent,n=this.getViewportBounds(),r=this.components.appContainer.getMapRotationRadians(),o=this.calculateRotatedBounds(t,r),a=o.maxX-o.minX,h=o.maxY-o.minY,l=n.width,c=n.height,d=l*(1-2*s)/a,u=c*(1-2*i)/h,p=Math.min(d,u),g=Math.max(this.config.interaction.fitMinScale,this.scaleMin),f=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),m=Math.max(g,Math.min(f,p)),y=t.minX+(t.maxX-t.minX)/2,x=t.minY+(t.maxY-t.minY)/2,b=l/2,v=c/2,_=Math.cos(r),w=Math.sin(r),A=b-(y*_-x*w)*m,C=v-(y*w+x*_)*m;ng.debug("[MapApplication] fitMapToView calculated:",{rotation:this.components.appContainer.getMapRotation(),originalBounds:t,rotatedBounds:o,finalScale:m,position:{x:A,y:C}}),this.components.interaction.setPanZoom({targetPosition:{x:A,y:C},targetScale:{x:m,y:m},setCenter:!0,setScale:!0},e)})}calculateRotatedBounds(t,e){if(0===e)return t;const i=(t.minX+t.maxX)/2,s=(t.minY+t.maxY)/2,n=[{x:t.minX-i,y:t.minY-s},{x:t.maxX-i,y:t.minY-s},{x:t.maxX-i,y:t.maxY-s},{x:t.minX-i,y:t.maxY-s}],r=Math.cos(e),o=Math.sin(e),a=n.map(t=>({x:t.x*r-t.y*o,y:t.x*o+t.y*r}));let h=1/0,l=1/0,c=-1/0,d=-1/0;return a.forEach(t=>{h=Math.min(h,t.x),l=Math.min(l,t.y),c=Math.max(c,t.x),d=Math.max(d,t.y)}),{minX:h+i,minY:l+s,maxX:c+i,maxY:d+s}}getViewportBounds(){return this.components.viewportContainer?.getViewportBounds()||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),ng.log("[runtime] runtime updated",t),this.renderOnceNextFrame()}metersToPixels(t){return this.mapState?.resolution?t*(1/(this.mapState.resolution/100)):(ng.warn("Map resolution not available, using default resolution (5cm/pixel)"),20*t)}pixelsToMeters(t){return this.mapState?.resolution?t*(this.mapState.resolution/100):(ng.warn("Map resolution not available, using default resolution (5cm/pixel)"),.05*t)}toFixedSize(t,e){return t/(e??this.components.appContainer.scale.x)}fromFixedSize(t,e){return t*(e??this.components.appContainer.scale.x)}getViewportCenterPoint(){if(!this.mapState)return ng.warn("Map state not available, cannot calculate center point"),null;const t=this.getViewportBounds(),e=t.x+t.width/2,i=t.y+t.height/2,s=this.components.appContainer,n=s.scale.x,r=s.getMapRotationRadians(),o=(e-s.x)/n,a=(i-s.y)/n,h=Math.cos(r),l=Math.sin(r),c=-o*l+a*h;return{x:o*h+a*l-this.mapState.origin.x,y:c-this.mapState.origin.y}}getMapCenterPoint(){if(!this.mapState)return ng.warn("Map state not available, cannot calculate map center point"),null;const t=this.managers.mapManager.mapBounds;if(t.minX===1/0||t.minY===1/0||t.maxX===-1/0||t.maxY===-1/0)return ng.warn("Invalid map bounds, cannot calculate map center point"),null;const e=(t.minX+t.maxX)/2,i=(t.minY+t.maxY)/2;return{x:e-this.mapState.origin.x,y:i-this.mapState.origin.y}}getWallPointsByViewportCenter(t){const{width:e=this.config.controls.virtualWall.minWidth,direction:i="horizontal",offsetX:s=0,offsetY:n=0}=t||{},r=this.getViewportCenterPoint()||{x:0,y:0},o=this.metersToPixels(e);return Dg(r.x,r.y,o,i).map(t=>({x:t.x+s,y:t.y+n}))}getForbiddenSweepZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenSweepZone,{size:i=e.minSize,offsetX:s=0,offsetY:n=0}=t||{};return this.generateZonePoints(i,s,n)}getForbiddenMopZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenMopZone,{size:i=e.minSize,offsetX:s=0,offsetY:n=0}=t||{};return this.generateZonePoints(i,s,n)}getCleanZonePointsByViewportCenter(t){const e=this.config.controls.cleanZone,{size:i=e.minSize,offsetX:s=0,offsetY:n=0}=t||{};return this.generateZonePoints(i,s,n)}getSpotPointByViewportCenter(t){const{offsetX:e=0,offsetY:i=0}=t||{},s=this.getViewportCenterPoint()||{x:0,y:0};return{x:s.x+e,y:s.y+i}}areRoomsAdjacent(t){return ry.provide(this,()=>t&&0!==t.length?this.managers.mapManager.areRoomsAdjacent(t):(ng.warn("[Room] No room IDs provided"),!1))}isPointInAnyRoom(t){return ry.provide(this,()=>t&&"number"==typeof t.x&&"number"==typeof t.y?this.mapState?this.managers.mapManager.isPointInAnyRoom(t):(ng.warn("[Room] Map state not available"),null):(ng.warn("[Room] Invalid point provided"),null))}isWallIntersectsAnyRoom(t){return ry.provide(this,()=>t&&2===t.length&&t[0]&&t[1]&&"number"==typeof t[0].x&&"number"==typeof t[0].y&&"number"==typeof t[1].x&&"number"==typeof t[1].y?this.mapState?this.managers.mapManager.isWallIntersectsAnyRoom(t):(ng.warn("[Room] Map state not available"),!1):(ng.warn("[Room] Invalid wall points provided"),!1))}isZoneIntersectsAnyRoom(t){return ry.provide(this,()=>t&&4===t.length&&t[0]&&t[1]&&t[2]&&t[3]&&"number"==typeof t[0].x&&"number"==typeof t[0].y&&"number"==typeof t[1].x&&"number"==typeof t[1].y&&"number"==typeof t[2].x&&"number"==typeof t[2].y&&"number"==typeof t[3].x&&"number"==typeof t[3].y?this.mapState?this.managers.mapManager.isZoneIntersectsAnyRoom(t):(ng.warn("[Room] Map state not available"),!1):(ng.warn("[Room] Invalid zone points provided"),!1))}isNearChargerOrRobot(t,e,i){return ry.provide(this,()=>{if(!t||t.length<1)return ng.warn("[Distance] Invalid points array: must have at least 1 point"),!1;if(1!==t.length&&2!==t.length&&4!==t.length)return ng.warn("[Distance] Invalid points array: must have exactly 1 (point), 2 (wall) or 4 (zone) points"),!1;if(e<=0)return ng.warn("[Distance] Invalid threshold: must be greater than 0"),!1;if(!this.mapState)return ng.warn("[Distance] Map state not available"),!1;const{checkCharger:s=!0,checkRobot:n=!1}=i||{};if(!s&&!n)return ng.warn("[Distance] At least one of checkCharger or checkRobot must be true"),!1;const r=this.metersToPixels(e);if(s){const e=ry.getService().getChargerPosition();if(e){const i=ug(e,t);if(i<=r)return ng.log(`[Distance] Too close to charger: ${i.toFixed(2)} pixels (threshold: ${r.toFixed(2)} pixels)`),!0}else ng.warn("[Distance] Charger position not available")}if(n){const e=ry.getService().getRobotPosition();if(e){const i=ug(e,t);if(i<=r)return ng.log(`[Distance] Too close to robot: ${i.toFixed(2)} pixels (threshold: ${r.toFixed(2)} pixels)`),!0}else ng.warn("[Distance] Robot position not available")}return!1})}async snapshot(){this.render(),await new Promise(t=>setTimeout(t,0));const{snapshot:t}=this.config;return await this.renderer.extract.base64({target:this.components.appContainer,format:t.format,quality:t.quality,resolution:t.resolution,antialias:t.antialias})}async snapshotByData({map:t,path:e,roomProperties:i,customElements:s,forbiddenSweepZones:n,forbiddenMopZones:r,virtualWalls:o,detectedObjects:a},h={}){const l=`SNAPSHOT_${((t=21)=>{let e="",i=0|t;for(;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e})()}`;ng.log(`[MapApplication] ${l} snapshot start`);const c=new zx(l);try{if(await c.initialize({config:this.config,runtime:h}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const{decodeMapStructured:e}=await Promise.resolve().then(()=>eg),i=e(t);await c.drawMap(i)}else{const{decodeMap:e}=await Promise.resolve().then(()=>eg),i=e(t,{pointsStructured:!0});if(!i)throw new Error("Failed to decode raster map data");await c.drawRasterMap(i)}if(e){const{decodePath:t}=await Promise.resolve().then(()=>eg),i=t(e);c.drawPath(i)}i&&i.length>0&&c.drawRoomProperty(i),n&&n.length>0&&c.drawForbiddenSweepZones(n),r&&r.length>0&&c.drawForbiddenMopZones(r),o&&o.length>0&&c.drawVirtualWalls(o),a&&a.length>0&&await c.drawDetectedObjects(a),s&&s.length>0&&await c.drawCustomElements(s);const d=await c.snapshot();return ng.log(`[MapApplication] ${l} snapshot completed successfully`),d}catch(t){throw ng.error(`[MapApplication] ${l} snapshot other map failed:`,t),t}finally{ng.log(`[MapApplication] ${l} destroy`),c.destroy()}}renderOnce(){ng.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{ng.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,e=!1){e?(this.tickerState.renderReasons.add(t),this.ticker.started||(ng.debug(`🎬 [Ticker] START: ${t}`),this.ticker.start())):this.renderOnceNextFrame()}stopRender(t){this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&this.scheduleStopRender("final",100)}destroy(){this.tickerState.renderTimer&&(clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=null),this.tickerState.renderReasons.clear(),this.emitter.all.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange),this.managers.pathManager.destroy(),this.managers.mapManager.destroy(),this.managers.controlsManager.destroy(),this.managers.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),super.destroy(),ry.unregisterInstance(this.instanceKey)}initializeViewportContainer(){this.components.viewportContainer=new ay(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer)}initializeAppContainer(){this.components.appContainer=new Ay,this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new Km,this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(t,e){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&(ng.debug("⏸️ [Ticker] STOP"),this.ticker&&this.ticker.stop())},e)}generateZonePoints(t,e,i){const s=this.getViewportCenterPoint()||{x:0,y:0},n=this.metersToPixels(t)/2,r=s.x+e,o=s.y+i;return[{x:r-n,y:o-n},{x:r+n,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}]}preloadAssets(){const t=this.config.robot.icon.src,e=this.config.chargingStation.icon.src,i=[];pl.add({alias:"robot",src:t}),i.push("robot"),pl.add({alias:"chargingStation",src:e}),i.push("chargingStation"),pl.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),i.push("deleteIcon"),pl.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),i.push("rotateIcon"),pl.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),i.push("scaleIcon"),pl.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),i.push("moveIcon"),pl.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),i.push("checkmark"),pl.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),i.push("spotIcon"),pl.add({alias:"wayPoint",src:this.config.controls.wayPoint.normal.iconSrc}),i.push("wayPoint"),pl.add({alias:"wayPointActive",src:this.config.controls.wayPoint.editing.iconSrc}),i.push("wayPointActive"),this.config.room.property.cleanMode.assets.forEach((t,e)=>{const s=`cleanMode_${e}`;pl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.suction.assets.forEach((t,e)=>{const s=`fan_${e}`;pl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.cistern.assets.forEach((t,e)=>{const s=`water_${e}`;pl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.cleanTimes.assets.forEach((t,e)=>{const s=`cleanTimes${e+1}`;pl.add({alias:s,src:t}),i.push(s)}),this.config.room.floorType.assets.forEach((t,e)=>{if(!t)return;const s=`floorType${e}`;pl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.customAssets&&Object.entries(this.config.room.property.customAssets).forEach(([t,e])=>{e.forEach((e,s)=>{const n=`custom_${t}_${s}`;pl.add({alias:n,src:e}),i.push(n)})}),pl.backgroundLoad(i)}setupMapRotationListener(){this.applyMapRotation(this.runtime.mapRotation),Xi(this.runtime,"mapRotation",t=>{ry.provide(this,()=>{this.applyMapRotation(t)})})}applyMapRotation(t){const e=(t%360+360)%360;ng.log(`[MapApplication] Applying map rotation: ${e}°`),this.components.appContainer.setMapRotation(e);const i=this.managers.mapManager.mapBounds;i&&i.minX!==1/0&&i.maxX!==-1/0&&this.fitMapToView(i,!1),this.renderOnce()}onVisibilityChange=()=>{"visible"===document.visibilityState||this.components.interaction?.clearTouches()}}es.add(Hr),es.mixin(Xn,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),es.add(Do),es.add(Fo),es.add(Il),es.mixin(Xn,Ml),es.add(ml),es.add(Vu),es.add(ih),es.add(Xu),es.add(ep),es.add(ip),es.add(Bp),es.add(Ep),es.add(Ap),es.add(Tp),es.add(Sp),es.add(gp),es.add(op),es.add(Ol),es.add(El);const Nx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Vx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{ry as AppContext,ey as MAP_API_METHODS,iy as MAP_CALLBACK_METHODS,zx as MapApplication,ig as decodeRoomProperties,sg as offsetPointsToAvoidOverlap,Yi as useAppService};
1
+ function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function e(t="default"){return void 0===Is[t]&&(Is[t]=-1),++Is[t]}function i(t){return t+=0===t?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,1+((t|=t>>>8)|t>>>16)}function s(t){return!(t&t-1||!t)}function n(t){const e={};for(const i in t)void 0!==t[i]&&(e[i]=t[i]);return e}function r(t,e,i){const{width:s,height:n}=i.orig,r=i.trim;if(r){const i=r.width,o=r.height;t.minX=r.x-e._x*s,t.maxX=t.minX+i,t.minY=r.y-e._y*n,t.maxY=t.minY+o}else t.minX=-e._x*s,t.maxX=t.minX+s,t.minY=-e._y*n,t.maxY=t.minY+n}function o(...t){500!==xn&&xn++}function a(t,e,i){const s=t.length;let n;if(e>=s||0===i)return;const r=s-(i=e+i>s?s-e:i);for(n=e;n<r;++n)t[n]=t[n+i];t.length=r}function h(t,e,i){let s,n;return i.clear(),t.parent?e?s=t.parent.worldTransform:(n=Pn.get().identity(),s=c(t,n)):s=ps.IDENTITY,l(t,i,s,e),n&&Pn.return(n),i.isValid||i.set(0,0,0,0),i}function l(t,e,i,s){if(!t.visible||!t.measurable)return;let n;s?n=t.worldTransform:(t.updateLocalTransform(),n=Pn.get(),n.appendFrom(t.localTransform,i));const r=e,o=!!t.effects.length;if(o&&(e=En.get().clear()),t.boundsArea)e.addRect(t.boundsArea,n);else{const i=t.bounds;i&&!i.isEmpty()&&(e.matrix=n,e.addBounds(i));for(let i=0;i<t.children.length;i++)l(t.children[i],e,n,s)}if(o){for(let i=0;i<t.effects.length;i++)t.effects[i].addBounds?.(e);r.addBounds(e,ps.IDENTITY),En.return(e)}s||Pn.return(n)}function c(t,e){const i=t.parent;return i&&(c(i,e),i.updateLocalTransform(),e.append(i.localTransform)),e}function d(t,e){return 16777215!==t&&e?16777215!==e&&t?((t>>16&255)*(e>>16&255)/255<<16)+((t>>8&255)*(e>>8&255)/255<<8)+((255&t)*(255&e)/255|0):t:e}function u(t,e){return t===kn?e:e===kn?t:d(t,e)}function p(t){return((255&t)<<16)+(65280&t)+(t>>16&255)}function g(t,e,i){return e.clear(),i||(i=ps.IDENTITY),f(t,e,i,t,!0),e.isValid||e.set(0,0,0,0),e}function f(t,e,i,s,n){let r;if(n)r=Pn.get(),r=i.copyTo(r);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const e=t.localTransform;r=Pn.get(),r.appendFrom(e,i)}const o=e,a=!!t.effects.length;if(a&&(e=En.get().clear()),t.boundsArea)e.addRect(t.boundsArea,r);else{t.renderPipeId&&(e.matrix=r,e.addBounds(t.bounds));const i=t.children;for(let t=0;t<i.length;t++)f(i[t],e,r,s,!1)}if(a){for(let i=0;i<t.effects.length;i++)t.effects[i].addLocalBounds?.(e,s);o.addBounds(e,ps.IDENTITY),En.return(e)}Pn.return(r)}function m(t,e){const i=t.children;for(let t=0;t<i.length;t++){const s=i[t],n=s.uid,r=(65535&s._didViewChangeTick)<<16|65535&s._didContainerChangeTick,o=e.index;e.data[o]===n&&e.data[o+1]===r||(e.data[e.index]=n,e.data[e.index+1]=r,e.didChange=!0),e.index=o+2,s.children.length&&m(s,e)}return e.didChange}function y(t,e){return t._zIndex-e._zIndex}function x(t,e,i){const s=Qn;t.measurable=!0,h(t,i,s),e.addBoundsMask(s),t.measurable=!1}function b(t,e,i){const s=En.get();t.measurable=!0;const n=Pn.get().identity();g(t,s,v(t,i,n)),t.measurable=!1,e.addBoundsMask(s),Pn.return(n),En.return(s)}function v(t,e,i){return t?(t!==e&&(v(t.parent,e,i),t.updateLocalTransform(),i.append(t.localTransform)),i):(o(),i)}async function _(){return hr??(hr=(async()=>{const t=ir.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(t=>{const e=document.createElement("video");e.onloadeddata=()=>t(e),e.onerror=()=>t(null),e.autoplay=!1,e.crossOrigin="anonymous",e.preload="auto",e.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",e.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const s=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,s),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(s),t.deleteTexture(i),t.getExtension("WEBGL_lose_context")?.loseContext(),n[0]<=n[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),hr}function w(t={}){const e=t&&t.resource,i=e?t.resource:t,s=e?t:{resource:t};for(let t=0;t<gr.length;t++){const e=gr[t];if(e.test(i))return new e(s)}throw new Error(`Could not find a source type for resource: ${s.resource}`)}function A(t){if("string"!=typeof t)throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function C(t){return t.split("?")[0].split("#")[0]}function S(t,e,i,s,n){const r=e[i];for(let o=0;o<r.length;o++){const a=r[o];i<e.length-1?S(t.replace(s[i],a),e,i+1,s,n):n.push(t.replace(s[i],a))}}function I(t){const e=t.match(/\{(.*?)\}/g),i=[];if(e){const s=[];e.forEach(t=>{const e=t.substring(1,t.length-1).split(",");s.push(e)}),S(t,s,0,e,i)}else i.push(t);return i}function M(t,e,i){const s={};if(t.forEach(t=>{s[t]=e}),Object.keys(e.textures).forEach(t=>{s[`${e.cachePrefix}${t}`]=e.textures[t]}),!i){const i=mr.dirname(t[0]);e.linkedSheets.forEach((t,n)=>{const r=M([`${i}/${e.data.meta.related_multi_packs[n]}`],t,!0);Object.assign(s,r)})}return s}function T(t){var e={userAgent:"",platform:"",maxTouchPoints:0};t||"undefined"==typeof navigator?"string"==typeof t?e.userAgent=t:t&&t.userAgent&&(e={userAgent:t.userAgent,platform:t.platform,maxTouchPoints:t.maxTouchPoints||0}):e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=e.userAgent,s=i.split("[FBAN");void 0!==s[1]&&(i=s[0]),void 0!==(s=i.split("Twitter"))[1]&&(i=s[0]);var n=function(t){return function(e){return e.test(t)}}(i),r={apple:{phone:n(Ir)&&!n(Or),ipod:n(Mr),tablet:!n(Ir)&&(n(Tr)||zr(e))&&!n(Or),universal:n(Pr),device:(n(Ir)||n(Mr)||n(Tr)||n(Pr)||zr(e))&&!n(Or)},amazon:{phone:n(Rr),tablet:!n(Rr)&&n(kr),device:n(Rr)||n(kr)},android:{phone:!n(Or)&&n(Rr)||!n(Or)&&n(Er),tablet:!n(Or)&&!n(Rr)&&!n(Er)&&(n(kr)||n(Br)),device:!n(Or)&&(n(Rr)||n(kr)||n(Er)||n(Br))||n(/\bokhttp\b/i)},windows:{phone:n(Or),tablet:n(Dr),device:n(Or)||n(Dr)},other:{blackberry:n(Fr),blackberry10:n(Lr),opera:n(jr),firefox:n(Ur),chrome:n(Gr),device:n(Fr)||n(Lr)||n(jr)||n(Ur)||n(Gr)},any:!1,phone:!1,tablet:!1};return r.any=r.apple.device||r.android.device||r.windows.device||r.other.device,r.phone=r.apple.phone||r.android.phone||r.windows.phone,r.tablet=r.apple.tablet||r.android.tablet||r.windows.tablet,r}function P(t,e){let i=Jr[t];return void 0===i&&(void 0===Wr[e]&&(Wr[e]=1),Jr[t]=i=Wr[e]++),i}function E(){if(!Zr||Zr?.isContextLost()){const t=ir.get().createCanvas();Zr=t.getContext("webgl",{})}return Zr}function B(){if(!Xr){Xr="mediump";const t=E();if(t&&t.getShaderPrecisionFormat){const e=t.getShaderPrecisionFormat(t.FRAGMENT_SHADER,t.HIGH_FLOAT);Xr=e.precision?"highp":"mediump"}}return Xr}function R(t){return eo[t]??eo.float32}function k(t){const e=/@group\((\d+)\)/,i=/@binding\((\d+)\)/,s=/var(<[^>]+>)? (\w+)/,n=/:\s*(\w+)/,r=/(\w+)\s*:\s*([\w\<\>]+)/g,o=/struct\s+(\w+)/,a=t.match(/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g)?.map(t=>({group:parseInt(t.match(e)[1],10),binding:parseInt(t.match(i)[1],10),name:t.match(s)[2],isUniform:"<uniform>"===t.match(s)[1],type:t.match(n)[1]}));if(!a)return{groups:[],structs:[]};const h=t.match(/struct\s+(\w+)\s*{([^}]+)}/g)?.map(t=>{const e=t.match(o)[1],i=t.match(r).reduce((t,e)=>{const[i,s]=e.split(":");return t[i.trim()]=s.trim(),t},{});return i?{name:e,members:i}:null}).filter(({name:t})=>a.some(e=>e.type===t))??[];return{groups:a,structs:h}}function O(t,e){switch(t){case"f32":return 0;case"vec2<f32>":return new Float32Array(2*e);case"vec3<f32>":return new Float32Array(3*e);case"vec4<f32>":return new Float32Array(4*e);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}function D(){if("boolean"==typeof vo)return vo;try{const t=new Function("param1","param2","param3","return param1[param2] === param3;");vo=!0===t({a:"b"},"a","b")}catch(t){vo=!1}return vo}function F(t,e,i=2){const s=e&&e.length,n=s?e[0]*i:t.length;let r=L(t,0,n,i,!0);const o=[];if(!r||r.next===r.prev)return o;let a,h,l;if(s&&(r=function(t,e,i,s){const n=[];for(let i=0,r=e.length;i<r;i++){const o=L(t,e[i]*s,i<r-1?e[i+1]*s:t.length,s,!1);o===o.next&&(o.steiner=!0),n.push(X(o))}n.sort(H);for(let t=0;t<n.length;t++)i=W(n[t],i);return i}(t,e,r,i)),t.length>80*i){a=t[0],h=t[1];let e=a,s=h;for(let r=i;r<n;r+=i){const i=t[r],n=t[r+1];i<a&&(a=i),n<h&&(h=n),i>e&&(e=i),n>s&&(s=n)}l=Math.max(e-a,s-h),l=0!==l?32767/l:0}return G(r,o,i,a,h,l,0),o}function L(t,e,i,s,n){let r;if(n===function(t,e,i,s){let n=0;for(let r=e,o=i-s;r<i;r+=s)n+=(t[o]-t[r])*(t[r+1]+t[o+1]),o=r;return n}(t,e,i,s)>0)for(let n=e;n<i;n+=s)r=rt(n/s|0,t[n],t[n+1],r);else for(let n=i-s;n>=e;n-=s)r=rt(n/s|0,t[n],t[n+1],r);return r&&$(r,r.next)&&(ot(r),r=r.next),r}function j(t,e){if(!t)return t;e||(e=t);let i,s=t;do{if(i=!1,s.steiner||!$(s,s.next)&&0!==q(s.prev,s,s.next))s=s.next;else{if(ot(s),s=e=s.prev,s===s.next)break;i=!0}}while(i||s!==e);return e}function G(t,e,i,s,n,r,o){if(!t)return;!o&&r&&function(t,e,i,s){let n=t;do{0===n.z&&(n.z=Z(n.x,n.y,e,i,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){let e,i=1;do{let s,n=t;t=null;let r=null;for(e=0;n;){e++;let o=n,a=0;for(let t=0;t<i&&(a++,o=o.nextZ,o);t++);let h=i;for(;a>0||h>0&&o;)0!==a&&(0===h||!o||n.z<=o.z)?(s=n,n=n.nextZ,a--):(s=o,o=o.nextZ,h--),r?r.nextZ=s:t=s,s.prevZ=r,r=s;n=o}r.nextZ=null,i*=2}while(e>1)}(n)}(t,s,n,r);let a=t;for(;t.prev!==t.next;){const h=t.prev,l=t.next;if(r?z(t,s,n,r):U(t))e.push(h.i,t.i,l.i),ot(t),t=l.next,a=l.next;else if((t=l)===a){o?1===o?G(t=N(j(t),e),e,i,s,n,r,2):2===o&&V(t,e,i,s,n,r):G(j(t),e,i,s,n,r,1);break}}}function U(t){const e=t.prev,i=t,s=t.next;if(q(e,i,s)>=0)return!1;const n=e.x,r=i.x,o=s.x,a=e.y,h=i.y,l=s.y,c=Math.min(n,r,o),d=Math.min(a,h,l),u=Math.max(n,r,o),p=Math.max(a,h,l);let g=s.next;for(;g!==e;){if(g.x>=c&&g.x<=u&&g.y>=d&&g.y<=p&&K(n,a,r,h,o,l,g.x,g.y)&&q(g.prev,g,g.next)>=0)return!1;g=g.next}return!0}function z(t,e,i,s){const n=t.prev,r=t,o=t.next;if(q(n,r,o)>=0)return!1;const a=n.x,h=r.x,l=o.x,c=n.y,d=r.y,u=o.y,p=Math.min(a,h,l),g=Math.min(c,d,u),f=Math.max(a,h,l),m=Math.max(c,d,u),y=Z(p,g,e,i,s),x=Z(f,m,e,i,s);let b=t.prevZ,v=t.nextZ;for(;b&&b.z>=y&&v&&v.z<=x;){if(b.x>=p&&b.x<=f&&b.y>=g&&b.y<=m&&b!==n&&b!==o&&K(a,c,h,d,l,u,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=f&&v.y>=g&&v.y<=m&&v!==n&&v!==o&&K(a,c,h,d,l,u,v.x,v.y)&&q(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=f&&b.y>=g&&b.y<=m&&b!==n&&b!==o&&K(a,c,h,d,l,u,b.x,b.y)&&q(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=f&&v.y>=g&&v.y<=m&&v!==n&&v!==o&&K(a,c,h,d,l,u,v.x,v.y)&&q(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function N(t,e){let i=t;do{const s=i.prev,n=i.next.next;!$(s,n)&&tt(s,i,i.next,n)&&st(s,n)&&st(n,s)&&(e.push(s.i,i.i,n.i),ot(i),ot(i.next),i=t=n),i=i.next}while(i!==t);return j(i)}function V(t,e,i,s,n,r){let o=t;do{let t=o.next.next;for(;t!==o.prev;){if(o.i!==t.i&&Q(o,t)){let a=nt(o,t);return o=j(o,o.next),a=j(a,a.next),G(o,e,i,s,n,r,0),void G(a,e,i,s,n,r,0)}t=t.next}o=o.next}while(o!==t)}function H(t,e){let i=t.x-e.x;return 0===i&&(i=t.y-e.y,0===i)&&(i=(t.next.y-t.y)/(t.next.x-t.x)-(e.next.y-e.y)/(e.next.x-e.x)),i}function W(t,e){const i=function(t,e){let i=e;const s=t.x,n=t.y;let r,o=-1/0;if($(t,i))return i;do{if($(t,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const t=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(t<=s&&t>o&&(o=t,r=i.x<i.next.x?i:i.next,t===s))return r}i=i.next}while(i!==e);if(!r)return null;const a=r,h=r.x,l=r.y;let c=1/0;i=r;do{if(s>=i.x&&i.x>=h&&s!==i.x&&Y(n<l?s:o,n,h,l,n<l?o:s,n,i.x,i.y)){const e=Math.abs(n-i.y)/(s-i.x);st(i,t)&&(e<c||e===c&&(i.x>r.x||i.x===r.x&&J(r,i)))&&(r=i,c=e)}i=i.next}while(i!==a);return r}(t,e);if(!i)return e;const s=nt(i,t);return j(s,s.next),j(i,i.next)}function J(t,e){return q(t.prev,t,e.prev)<0&&q(e.next,t,t.next)<0}function Z(t,e,i,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function X(t){let e=t,i=t;do{(e.x<i.x||e.x===i.x&&e.y<i.y)&&(i=e),e=e.next}while(e!==t);return i}function Y(t,e,i,s,n,r,o,a){return(n-o)*(e-a)>=(t-o)*(r-a)&&(t-o)*(s-a)>=(i-o)*(e-a)&&(i-o)*(r-a)>=(n-o)*(s-a)}function K(t,e,i,s,n,r,o,a){return!(t===o&&e===a)&&Y(t,e,i,s,n,r,o,a)}function Q(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){let i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==e.i&&i.next.i!==e.i&&tt(i,i.next,t,e))return!0;i=i.next}while(i!==t);return!1}(t,e)&&(st(t,e)&&st(e,t)&&function(t,e){let i=t,s=!1;const n=(t.x+e.x)/2,r=(t.y+e.y)/2;do{i.y>r!=i.next.y>r&&i.next.y!==i.y&&n<(i.next.x-i.x)*(r-i.y)/(i.next.y-i.y)+i.x&&(s=!s),i=i.next}while(i!==t);return s}(t,e)&&(q(t.prev,t,e.prev)||q(t,e.prev,e))||$(t,e)&&q(t.prev,t,t.next)>0&&q(e.prev,e,e.next)>0)}function q(t,e,i){return(e.y-t.y)*(i.x-e.x)-(e.x-t.x)*(i.y-e.y)}function $(t,e){return t.x===e.x&&t.y===e.y}function tt(t,e,i,s){const n=it(q(t,e,i)),r=it(q(t,e,s)),o=it(q(i,s,t)),a=it(q(i,s,e));return n!==r&&o!==a||!(0!==n||!et(t,i,e))||!(0!==r||!et(t,s,e))||!(0!==o||!et(i,t,s))||!(0!==a||!et(i,e,s))}function et(t,e,i){return e.x<=Math.max(t.x,i.x)&&e.x>=Math.min(t.x,i.x)&&e.y<=Math.max(t.y,i.y)&&e.y>=Math.min(t.y,i.y)}function it(t){return t>0?1:t<0?-1:0}function st(t,e){return q(t.prev,t,t.next)<0?q(t,e,t.next)>=0&&q(t,t.prev,e)>=0:q(t,e,t.prev)<0||q(t,t.next,e)<0}function nt(t,e){const i=at(t.i,t.x,t.y),s=at(e.i,e.x,e.y),n=t.next,r=e.prev;return t.next=e,e.prev=t,i.next=n,n.prev=i,s.next=i,i.prev=s,r.next=s,s.prev=r,s}function rt(t,e,i,s){const n=at(t,e,i);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function ot(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function at(t,e,i){return{i:t,x:e,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function ht(t){return void 0!==Io||(Io=(()=>{const e={stencil:!0,failIfMajorPerformanceCaveat:t??To.defaultOptions.failIfMajorPerformanceCaveat};try{if(!ir.get().getWebGLRenderingContext())return!1;let t=ir.get().createCanvas().getContext("webgl",e);const i=!!t?.getContextAttributes()?.stencil;if(t){const e=t.getExtension("WEBGL_lose_context");e&&e.loseContext()}return t=null,i}catch(t){return!1}})()),Io}async function lt(t={}){return void 0!==Mo||(Mo=await(async()=>{const e=ir.get().getNavigator().gpu;if(!e)return!1;try{const i=await e.requestAdapter(t);return await i.requestDevice(),!0}catch(t){return!1}})()),Mo}function ct(t=1e3,e=0,i=!1){if(isNaN(t)||t<0)throw new TypeError("Invalid max value");if(isNaN(e)||e<0)throw new TypeError("Invalid ttl value");if("boolean"!=typeof i)throw new TypeError("Invalid resetTtl value");return new jo(t,e,i)}function dt(t){const e="number"==typeof t.fontSize?`${t.fontSize}px`:t.fontSize;let i=t.fontFamily;Array.isArray(t.fontFamily)||(i=t.fontFamily.split(","));for(let t=i.length-1;t>=0;t--){let e=i[t].trim();/([\"\'])[^\'\"]+\1/.test(e)||Go.includes(e)||(e=`"${e}"`),i[t]=e}return`${t.fontStyle} ${t.fontVariant} ${t.fontWeight} ${e} ${i.join(",")}`}function ut(t,e){for(let i=0;i<e.length;i++){const s=e[i];t.addColorStop(s.offset,s.color)}}function pt(t,e){const i=ir.get().createCanvas(t,e),s=i.getContext("2d");return{canvas:i,context:s}}function gt(t,e,i,s,n,r){const o=n-i,a=r-s,h=o*o+a*a;let l,c,d=-1;0!==h&&(d=((t-i)*o+(e-s)*a)/h),d<0?(l=i,c=s):d>1?(l=n,c=r):(l=i+d*o,c=s+d*a);const u=t-l,p=e-c;return u*u+p*p}function ft(t,e,i){let s=2166136261;for(let i=0;i<e;i++)s^=t[i].uid,s=Math.imul(s,16777619),s>>>=0;return ia[s]||function(t,e,i,s){const n={};let r=0;for(let i=0;i<s;i++){const s=i<e?t[i]:Gs.EMPTY.source;n[r++]=s.source,n[r++]=s.style}const o=new co(n);return ia[i]=o,o}(t,e,s,i)}function mt(t,e){const i=t.byteLength/8|0,s=new Float64Array(t,0,i);new Float64Array(e,0,i).set(s);const n=t.byteLength-8*i;if(n>0){const s=new Uint8Array(t,8*i,n);new Uint8Array(e,8*i,n).set(s)}}function yt(t,e){return"no-premultiply-alpha"===e.alphaMode&&na[t]||t}function xt(t){let e="";for(let i=0;i<t;++i)i>0&&(e+="\nelse "),i<t-1&&(e+=`if(test == ${i}.0){}`);return e}function bt(t,e){if(0===t)throw new Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");const i=e.createShader(e.FRAGMENT_SHADER);try{for(;;){const s=oa.replace(/%forloop%/gi,xt(t));if(e.shaderSource(i,s),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS))break;t=t/2|0}}finally{e.deleteShader(i)}return t}function vt(){return da>0?ca[--da]:new la}function _t(t){ca[da++]=t}function wt(t,e){if(!(t instanceof ma)){let i=e?fa.INDEX:fa.VERTEX;t instanceof Array&&(e?(t=new Uint32Array(t),i=fa.INDEX|fa.COPY_DST):(t=new Float32Array(t),i=fa.VERTEX|fa.COPY_DST)),t=new ma({data:t,label:e?"index-mesh-buffer":"vertex-mesh-buffer",usage:i})}return t}function At(t,e,i){if(t)for(const s in t){const n=e[s.toLocaleLowerCase()];if(n){let e=t[s];"header"===s&&(e=e.replace(/@in\s+[^;]+;\s*/g,"").replace(/@out\s+[^;]+;\s*/g,"")),i&&n.push(`//----${i}----//`),n.push(e)}else o()}}function Ct(t){const e={};return(t.match(_a)?.map(t=>t.replace(/[{()}]/g,""))??[]).forEach(t=>{e[t]=[]}),e}function St(t,e){let i;const s=/@in\s+([^;]+);/g;for(;null!==(i=s.exec(t));)e.push(i[1])}function It(t,e,i=!1){const s=[];St(e,s),t.forEach(t=>{t.header&&St(t.header,s)});const n=s;i&&n.sort();const r=n.map((t,e)=>` @location(${e}) ${t},`).join("\n");let o=e.replace(/@in\s+[^;]+;\s*/g,"");return o=o.replace("{{in}}",`\n${r}\n`),o}function Mt(t,e){let i;const s=/@out\s+([^;]+);/g;for(;null!==(i=s.exec(t));)e.push(i[1])}function Tt(t,e){let i=t;for(const t in e){const s=e[t];i=s.join("\n").length?i.replace(`{{${t}}}`,`//-----${t} START-----//\n${s.join("\n")}\n//----${t} FINISH----//`):i.replace(`{{${t}}}`,"")}return i}function Pt({template:t,bits:e}){const i=Et(t,e);return wa[i]||(wa[i]=Bt(t.vertex,t.fragment,e)),wa[i]}function Et(t,e){return e.map(t=>(Aa.has(t)||Aa.set(t,Ca++),Aa.get(t))).sort((t,e)=>t-e).join("-")+t.vertex+t.fragment}function Bt(t,e,i){const s=Ct(t),n=Ct(e);return i.forEach(t=>{At(t.vertex,s,t.name),At(t.fragment,n,t.name)}),{vertex:Tt(t,s),fragment:Tt(e,n)}}function Rt({bits:t,name:e}){const i=function({template:t,bits:e}){const i=Et(t,e);if(wa[i])return wa[i];const{vertex:s,fragment:n}=function(t,e){const i=e.map(t=>t.vertex).filter(t=>!!t),s=e.map(t=>t.fragment).filter(t=>!!t);let n=It(i,t.vertex,!0);return n=function(t,e){const i=[];Mt(e,i),t.forEach(t=>{t.header&&Mt(t.header,i)});let s=0;const n=i.sort().map(t=>t.indexOf("builtin")>-1?t:`@location(${s++}) ${t}`).join(",\n"),r=i.sort().map(t=>{return` var ${e=t,e.replace(/@.*?\s+/g,"")};`;var e}).join("\n"),o=`return VSOutput(\n ${i.sort().map(t=>` ${function(t){const e=/\b(\w+)\s*:/g.exec(t);return e?e[1]:""}(t)}`).join(",\n")});`;let a=e.replace(/@out\s+[^;]+;\s*/g,"");return a=a.replace("{{struct}}",`\n${n}\n`),a=a.replace("{{start}}",`\n${r}\n`),a=a.replace("{{return}}",`\n${o}\n`),a}(i,n),{vertex:n,fragment:It(s,t.fragment,!0)}}(t,e);return wa[i]=Bt(s,n,e),wa[i]}({template:{fragment:"\n @in vUV : vec2<f32>;\n @in vColor : vec4<f32>;\n\n {{header}}\n\n @fragment\n fn main(\n {{in}}\n ) -> @location(0) vec4<f32> {\n\n {{start}}\n\n var outColor:vec4<f32>;\n\n {{main}}\n\n var finalColor:vec4<f32> = outColor * vColor;\n\n {{end}}\n\n return finalColor;\n };\n",vertex:"\n @in aPosition: vec2<f32>;\n @in aUV: vec2<f32>;\n\n @out @builtin(position) vPosition: vec4<f32>;\n @out vUV : vec2<f32>;\n @out vColor : vec4<f32>;\n\n {{header}}\n\n struct VSOutput {\n {{struct}}\n };\n\n @vertex\n fn main( {{in}} ) -> VSOutput {\n\n var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;\n var modelMatrix = mat3x3<f32>(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n var position = aPosition;\n var uv = aUV;\n\n {{start}}\n\n vColor = vec4<f32>(1., 1., 1., 1.);\n\n {{main}}\n\n vUV = uv;\n\n var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= globalUniforms.uWorldColorAlpha;\n\n {{end}}\n\n {{return}}\n };\n"},bits:[Sa,...t]});return ro.from({name:e,vertex:{source:i.vertex,entryPoint:"main"},fragment:{source:i.fragment,entryPoint:"main"}})}function kt({bits:t,name:e}){return new to({name:e,...Pt({template:{vertex:"\n in vec2 aPosition;\n in vec2 aUV;\n\n out vec4 vColor;\n out vec2 vUV;\n\n {{header}}\n\n void main(void){\n\n mat3 worldTransformMatrix = uWorldTransformMatrix;\n mat3 modelMatrix = mat3(\n 1.0, 0.0, 0.0,\n 0.0, 1.0, 0.0,\n 0.0, 0.0, 1.0\n );\n vec2 position = aPosition;\n vec2 uv = aUV;\n\n {{start}}\n\n vColor = vec4(1.);\n\n {{main}}\n\n vUV = uv;\n\n mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;\n\n gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);\n\n vColor *= uWorldColorAlpha;\n\n {{end}}\n }\n",fragment:"\n\n in vec4 vColor;\n in vec2 vUV;\n\n out vec4 finalColor;\n\n {{header}}\n\n void main(void) {\n\n {{start}}\n\n vec4 outColor;\n\n {{main}}\n\n finalColor = outColor * vColor;\n\n {{end}}\n }\n"},bits:[Ia,...t]})})}function Ot(t){const e=[];if(1===t)e.push("@group(1) @binding(0) var textureSource1: texture_2d<f32>;"),e.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let i=0;for(let s=0;s<t;s++)e.push(`@group(1) @binding(${i++}) var textureSource${s+1}: texture_2d<f32>;`),e.push(`@group(1) @binding(${i++}) var textureSampler${s+1}: sampler;`)}return e.join("\n")}function Dt(t){const e=[];if(1===t)e.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{e.push("switch vTextureId {");for(let i=0;i<t;i++)i===t-1?e.push(" default:{"):e.push(` case ${i}:{`),e.push(` outColor = textureSampleGrad(textureSource${i+1}, textureSampler${i+1}, vUV, uvDx, uvDy);`),e.push(" break;}");e.push("}")}return e.join("\n")}function Ft(t){return Pa[t]||(Pa[t]={name:"texture-batch-bit",vertex:{header:"\n @in aTextureIdAndRound: vec2<u32>;\n @out @interpolate(flat) vTextureId : u32;\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1)\n {\n vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:`\n @in @interpolate(flat) vTextureId: u32;\n\n ${Ot(t)}\n `,main:`\n var uvDx = dpdx(vUV);\n var uvDy = dpdy(vUV);\n\n ${Dt(t)}\n `}}),Pa[t]}function Lt(t){const e=[];for(let i=0;i<t;i++)i>0&&e.push("else"),i<t-1&&e.push(`if(vTextureId < ${i}.5)`),e.push("{"),e.push(`\toutColor = texture(uTextures[${i}], vUV);`),e.push("}");return e.join("\n")}function jt(t){return Ea[t]||(Ea[t]={name:"texture-batch-bit",vertex:{header:"\n in vec2 aTextureIdAndRound;\n out float vTextureId;\n\n ",main:"\n vTextureId = aTextureIdAndRound.y;\n ",end:"\n if(aTextureIdAndRound.x == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:`\n in float vTextureId;\n\n uniform sampler2D uTextures[${t}];\n\n `,main:`\n\n ${Lt(t)}\n `}}),Ea[t]}function Gt(t){let e=ka[t];if(e)return e;const i=new Int32Array(t);for(let e=0;e<t;e++)i[e]=e;return e=ka[t]=new lo({uTextures:{value:i,type:"i32",size:t}},{isStatic:!0}),e}function Ut(t,e,i,s,n){const r=e.a,o=e.b,a=e.c,h=e.d,l=e.tx,c=e.ty;i||(i=0),s||(s=2),n||(n=t.length/s-i);let d=i*s;for(let e=0;e<n;e++){const e=t[d],i=t[d+1];t[d]=r*e+a*i+l,t[d+1]=o*e+h*i+c,d+=s}}function zt(t,e,i,s,n,r,o,a){let h,l;o?(h=s,l=-i):(h=-s,l=i);const c=t-i*n+h,d=e-s*n+l,u=t+i*r+h,p=e+s*r+l;return a.push(c,d),a.push(u,p),2}function Nt(t,e,i,s,n,r,o,a){const h=i-t,l=s-e;let c=Math.atan2(h,l),d=Math.atan2(n-t,r-e);a&&c<d?c+=2*Math.PI:!a&&c>d&&(d+=2*Math.PI);let u=c;const p=d-c,g=Math.abs(p),f=Math.sqrt(h*h+l*l),m=1+(15*g*Math.sqrt(f)/Math.PI|0),y=p/m;if(u+=y,a){o.push(t,e),o.push(i,s);for(let i=1,s=u;i<m;i++,s+=y)o.push(t,e),o.push(t+Math.sin(s)*f,e+Math.cos(s)*f);o.push(t,e),o.push(n,r)}else{o.push(i,s),o.push(t,e);for(let i=1,s=u;i<m;i++,s+=y)o.push(t+Math.sin(s)*f,e+Math.cos(s)*f),o.push(t,e);o.push(n,r),o.push(t,e)}return 2*m}function Vt(t,e,i,s,n,r,o){const a=_o(t,e,2);if(!a)return;for(let t=0;t<a.length;t+=3)r[o++]=a[t]+n,r[o++]=a[t+1]+n,r[o++]=a[t+2]+n;let h=n*s;for(let e=0;e<t.length;e+=2)i[h]=t[e],i[h+1]=t[e+1],h+=s}function Ht(t,e,i){const s=[],n=Ka.rectangle,r=Qa;r.x=t.dx,r.y=t.dy,r.width=t.dw,r.height=t.dh;const o=t.transform;if(!n.build(r,s))return;const{vertices:a,uvs:h,indices:l}=i,c=l.length,d=a.length/2;o&&Ut(s,o),n.triangulate(s,a,2,d,l,c);const u=t.image,p=u.uvs;h.push(p.x0,p.y0,p.x1,p.y1,p.x3,p.y3,p.x2,p.y2);const g=_n.get(Ga);g.indexOffset=c,g.indexSize=l.length-c,g.attributeOffset=d,g.attributeSize=a.length/2-d,g.baseColor=t.style,g.alpha=t.alpha,g.texture=u,g.geometryData=i,e.push(g)}function Wt(t,e,i,s,n){const{vertices:r,uvs:o,indices:a}=n;t.shapePrimitives.forEach(({shape:t,transform:h,holes:l})=>{const c=[],d=Ka[t.type];if(!d.build(t,c))return;const u=a.length,p=r.length/2;let g="triangle-list";if(h&&Ut(c,h),i){const i=t.closePath??!0,s=e;s.pixelLine?(function(t,e,i,s){const n=Va;if(0===t.length)return;const r=t[0],o=t[1],a=t[t.length-2],h=t[t.length-1],l=e||Math.abs(r-a)<n&&Math.abs(o-h)<n,c=i,d=t.length/2,u=c.length/2;for(let e=0;e<d;e++)c.push(t[2*e]),c.push(t[2*e+1]);for(let t=0;t<d-1;t++)s.push(u+t,u+t+1);l&&s.push(u+d-1,u)}(c,i,r,a),g="line-list"):function(t,e,i,s,n,r){const o=Va;if(0===t.length)return;const a=e;let h=a.alignment;if(.5!==e.alignment){let e=function(t){const e=t.length;if(e<6)return 1;let i=0;for(let s=0,n=t[e-2],r=t[e-1];s<e;s+=2){const e=t[s],o=t[s+1];i+=(e-n)*(o+r),n=e,r=o}return i<0?-1:1}(t);h=(h-.5)*e+.5}const l=new ds(t[0],t[1]),c=new ds(t[t.length-2],t[t.length-1]),d=s,u=Math.abs(l.x-c.x)<o&&Math.abs(l.y-c.y)<o;if(d){t=t.slice(),u&&(t.pop(),t.pop(),c.set(t[t.length-2],t[t.length-1]));const e=.5*(l.x+c.x),i=.5*(c.y+l.y);t.unshift(e,i),t.push(e,i)}const p=n,g=t.length/2;let f=t.length;const m=p.length/2,y=a.width/2,x=y*y,b=a.miterLimit*a.miterLimit;let v=t[0],_=t[1],w=t[2],A=t[3],C=0,S=0,I=-(_-A),M=v-w,T=0,P=0,E=Math.sqrt(I*I+M*M);I/=E,M/=E,I*=y,M*=y;const B=2*(1-h),R=2*h;d||("round"===a.cap?f+=Nt(v-I*(B-R)*.5,_-M*(B-R)*.5,v-I*B,_-M*B,v+I*R,_+M*R,p,!0)+2:"square"===a.cap&&(f+=zt(v,_,I,M,B,R,!0,p))),p.push(v-I*B,_-M*B),p.push(v+I*R,_+M*R);for(let e=1;e<g-1;++e){v=t[2*(e-1)],_=t[2*(e-1)+1],w=t[2*e],A=t[2*e+1],C=t[2*(e+1)],S=t[2*(e+1)+1],I=-(_-A),M=v-w,E=Math.sqrt(I*I+M*M),I/=E,M/=E,I*=y,M*=y,T=-(A-S),P=w-C,E=Math.sqrt(T*T+P*P),T/=E,P/=E,T*=y,P*=y;const i=w-v,s=_-A,n=w-C,r=S-A,o=i*n+s*r,h=s*n-r*i,l=h<0;if(Math.abs(h)<.001*Math.abs(o)){p.push(w-I*B,A-M*B),p.push(w+I*R,A+M*R),o>=0&&("round"===a.join?f+=Nt(w,A,w-I*B,A-M*B,w-T*B,A-P*B,p,!1)+4:f+=2,p.push(w-T*R,A-P*R),p.push(w+T*B,A+P*B));continue}const c=(-I+v)*(-M+A)-(-I+w)*(-M+_),d=(-T+C)*(-P+A)-(-T+w)*(-P+S),u=(i*d-n*c)/h,g=(r*c-s*d)/h,m=(u-w)*(u-w)+(g-A)*(g-A),k=w+(u-w)*B,O=A+(g-A)*B,D=w-(u-w)*R,F=A-(g-A)*R,L=l?B:R;m<=Math.min(i*i+s*s,n*n+r*r)+L*L*x?"bevel"===a.join||m/x>b?(l?(p.push(k,O),p.push(w+I*R,A+M*R),p.push(k,O),p.push(w+T*R,A+P*R)):(p.push(w-I*B,A-M*B),p.push(D,F),p.push(w-T*B,A-P*B),p.push(D,F)),f+=2):"round"===a.join?l?(p.push(k,O),p.push(w+I*R,A+M*R),f+=Nt(w,A,w+I*R,A+M*R,w+T*R,A+P*R,p,!0)+4,p.push(k,O),p.push(w+T*R,A+P*R)):(p.push(w-I*B,A-M*B),p.push(D,F),f+=Nt(w,A,w-I*B,A-M*B,w-T*B,A-P*B,p,!1)+4,p.push(w-T*B,A-P*B),p.push(D,F)):(p.push(k,O),p.push(D,F)):(p.push(w-I*B,A-M*B),p.push(w+I*R,A+M*R),"round"===a.join?f+=l?Nt(w,A,w+I*R,A+M*R,w+T*R,A+P*R,p,!0)+2:Nt(w,A,w-I*B,A-M*B,w-T*B,A-P*B,p,!1)+2:"miter"===a.join&&m/x<=b&&(l?(p.push(D,F),p.push(D,F)):(p.push(k,O),p.push(k,O)),f+=2),p.push(w-T*B,A-P*B),p.push(w+T*R,A+P*R),f+=2)}v=t[2*(g-2)],_=t[2*(g-2)+1],w=t[2*(g-1)],A=t[2*(g-1)+1],I=-(_-A),M=v-w,E=Math.sqrt(I*I+M*M),I/=E,M/=E,I*=y,M*=y,p.push(w-I*B,A-M*B),p.push(w+I*R,A+M*R),d||("round"===a.cap?f+=Nt(w-I*(B-R)*.5,A-M*(B-R)*.5,w-I*B,A-M*B,w+I*R,A+M*R,p,!1)+2:"square"===a.cap&&(f+=zt(w,A,I,M,B,R,!1,p)));for(let t=m;t<f+m-2;++t)v=p[2*t],_=p[2*t+1],w=p[2*(t+1)],A=p[2*(t+1)+1],C=p[2*(t+2)],S=p[2*(t+2)+1],Math.abs(v*(A-S)+w*(S-_)+C*(_-A))<1e-8||r.push(t,t+1,t+2)}(c,s,0,i,r,a)}else if(l){const t=[],e=c.slice();(function(t){const e=[];for(let i=0;i<t.length;i++){const s=t[i].shape,n=[];Ka[s.type].build(s,n)&&e.push(n)}return e})(l).forEach(i=>{t.push(e.length/2),e.push(...i)}),Vt(e,t,r,2,p,a,u)}else d.triangulate(c,r,2,p,a,u);const f=o.length/2,m=e.texture;if(m!==Gs.WHITE){const i=function(t,e,i,s){const n=e.matrix?t.copyFrom(e.matrix).invert():t.identity();if("local"===e.textureSpace){const t=i.getBounds(Ya);e.width&&t.pad(e.width);const{x:s,y:r}=t,o=1/t.width,a=1/t.height,h=-s*o,l=-r*a,c=n.a,d=n.b,u=n.c,p=n.d;n.a*=o,n.b*=o,n.c*=a,n.d*=a,n.tx=h*c+l*u+n.tx,n.ty=h*d+l*p+n.ty}else n.translate(e.texture.frame.x,e.texture.frame.y),n.scale(1/e.texture.source.width,1/e.texture.source.height);const r=e.texture.source.style;return e.fill instanceof Wo||"clamp-to-edge"!==r.addressMode||(r.addressMode="repeat",r.update()),s&&n.append(Xa.copyFrom(s).invert()),n}(qa,e,t,h);!function(t,e,i,s,n,r,o,a=null){let h=0;i*=e,n*=r;const l=a.a,c=a.b,d=a.c,u=a.d,p=a.tx,g=a.ty;for(;h<o;){const o=t[i],a=t[i+1];s[n]=l*o+d*a+p,s[n+1]=c*o+u*a+g,n+=r,i+=e,h++}}(r,2,p,o,f,2,r.length/2-p,i)}else!function(t,e,i,s){let n=0;for(e*=2;n<s;)t[e]=0,t[e+1]=0,e+=2,n++}(o,f,0,r.length/2-p);const y=_n.get(Ga);y.indexOffset=u,y.indexSize=a.length-u,y.attributeOffset=p,y.attributeSize=r.length/2-p,y.baseColor=e.color,y.alpha=e.alpha,y.texture=m,y.geometryData=n,y.topology=g,s.push(y)})}function Jt(t,e,i,s,n,r,o,a,h,l){let c=(1-Math.min(.99,Math.max(0,l??ih.defaultOptions.bezierSmoothness)))/1;return c*=c,function(t,e,i,s,n,r,o,a,h,l){Zt(t,e,i,s,n,r,o,a,h,l,0),h.push(o,a)}(e,i,s,n,r,o,a,h,t,c),t}function Zt(t,e,i,s,n,r,o,a,h,l,c){if(c>8)return;const d=(t+i)/2,u=(e+s)/2,p=(i+n)/2,g=(s+r)/2,f=(n+o)/2,m=(r+a)/2,y=(d+p)/2,x=(u+g)/2,b=(p+f)/2,v=(g+m)/2,_=(y+b)/2,w=(x+v)/2;if(c>0){let c=o-t,d=a-e;const u=Math.abs((i-o)*d-(s-a)*c),p=Math.abs((n-o)*d-(r-a)*c);if(u>sh&&p>sh){if((u+p)*(u+p)<=l*(c*c+d*d))return void h.push(_,w)}else if(u>sh){if(u*u<=l*(c*c+d*d))return void h.push(_,w)}else if(p>sh){if(p*p<=l*(c*c+d*d))return void h.push(_,w)}else if(c=_-(t+o)/2,d=w-(e+a)/2,c*c+d*d<=l)return void h.push(_,w)}Zt(t,e,d,u,y,x,_,w,h,l,c+1),Zt(_,w,b,v,f,m,o,a,h,l,c+1)}function Xt(t,e,i,s,n,r,o,a){let h=(1-Math.min(.99,Math.max(0,a??ih.defaultOptions.bezierSmoothness)))/1;return h*=h,function(t,e,i,s,n,r,o,a){Yt(o,t,e,i,s,n,r,a,0),o.push(n,r)}(e,i,s,n,r,o,t,h),t}function Yt(t,e,i,s,n,r,o,a,h){if(h>8)return;const l=(e+s)/2,c=(i+n)/2,d=(s+r)/2,u=(n+o)/2,p=(l+d)/2,g=(c+u)/2;let f=r-e,m=o-i;const y=Math.abs((s-r)*m-(n-o)*f);if(y>1.1920929e-7){if(y*y<=a*(f*f+m*m))return void t.push(p,g)}else if(f=p-(e+r)/2,m=g-(i+o)/2,f*f+m*m<=a)return void t.push(p,g);Yt(t,e,i,l,c,p,g,a,h+1),Yt(t,p,g,d,u,r,o,a,h+1)}function Kt(t,e,i,s,n,r,o,a){let h=Math.abs(n-r);(!o&&n>r||o&&r>n)&&(h=2*Math.PI-h),a||(a=Math.max(6,Math.floor(6*Math.pow(s,1/3)*(h/Math.PI))));let l=h/(a=Math.max(a,3)),c=n;l*=o?-1:1;for(let n=0;n<a+1;n++){const n=e+Math.cos(c)*s,r=i+Math.sin(c)*s;t.push(n,r),c+=l}}function Qt(t,e){const i=-1.5707963267948966===e?-.551915024494:4/3*Math.tan(e/4),s=1.5707963267948966===e?.551915024494:i,n=Math.cos(t),r=Math.sin(t),o=Math.cos(t+e),a=Math.sin(t+e);return[{x:n-r*s,y:r+n*s},{x:o+a*s,y:a-o*s},{x:o,y:a}]}function qt(t,e){return t?t.prepend(e):e.clone()}function $t(t,e,i){const s=t.getAttribute(e);return s?Number(s):i}function te(t){const e=$t(t,"x1",0),i=$t(t,"y1",0),s=$t(t,"x2",1),n=$t(t,"y2",0),r=t.getAttribute("gradientUnits")||"objectBoundingBox",o=new Wo(e,i,s,n,"objectBoundingBox"===r?"local":"global");for(let e=0;e<t.children.length;e++){const i=t.children[e],s=$t(i,"offset",0),n=yn.shared.setValue(i.getAttribute("stop-color")).toNumber();o.addColorStop(s,n)}return o}function ee(t){return o(),new Wo(0,0,1,0)}function ie(t){const e=t.match(/url\s*\(\s*['"]?\s*#([^'"\s)]+)\s*['"]?\s*\)/i);return e?e[1]:""}function se(t,e){const i=t.getAttribute("style"),s={},n={},r={strokeStyle:s,fillStyle:n,useFill:!1,useStroke:!1};for(const i in dh){const s=t.getAttribute(i);s&&ne(e,r,i,s.trim())}if(i){const t=i.split(";");for(let i=0;i<t.length;i++){const s=t[i].trim(),[n,o]=s.split(":");dh[n]&&ne(e,r,n,o.trim())}}return{strokeStyle:r.useStroke?s:null,fillStyle:r.useFill?n:null,useFill:r.useFill,useStroke:r.useStroke}}function ne(t,e,i,s){switch(i){case"stroke":if("none"!==s){if(s.startsWith("url(")){const i=ie(s);e.strokeStyle.fill=t.defs[i]}else e.strokeStyle.color=yn.shared.setValue(s).toNumber();e.useStroke=!0}break;case"stroke-width":e.strokeStyle.width=Number(s);break;case"fill":if("none"!==s){if(s.startsWith("url(")){const i=ie(s);e.fillStyle.fill=t.defs[i]}else e.fillStyle.color=yn.shared.setValue(s).toNumber();e.useFill=!0}break;case"fill-opacity":e.fillStyle.alpha=Number(s);break;case"stroke-opacity":e.strokeStyle.alpha=Number(s);break;case"opacity":e.fillStyle.alpha=Number(s),e.strokeStyle.alpha=Number(s)}}function re(t){const e=t.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!e||e.length<4)return 0;const i=e.map(Number),s=[],n=[];for(let t=0;t<i.length;t+=2)t+1<i.length&&(s.push(i[t]),n.push(i[t+1]));if(0===s.length||0===n.length)return 0;const r=Math.min(...s),o=Math.max(...s),a=Math.min(...n);return(o-r)*(Math.max(...n)-a)}function oe(t,e){const i=new ch(t,!1);for(const t of i.instructions)e.instructions.push(t)}function ae(t,e,i,s){const n=t.children,{fillStyle:r,strokeStyle:a}=se(t,e);r&&i?i={...i,...r}:r&&(i=r),a&&s?s={...s,...a}:a&&(s=a);const h=!i&&!s;let l,c,d,u,p,g,f,m,y,x,b,v,_,w,A,C,S;switch(h&&(i={color:0}),t.nodeName.toLowerCase()){case"path":{w=t.getAttribute("d");const n=t.getAttribute("fill-rule"),r=w.split(/(?=[Mm])/).filter(t=>t.trim().length>0),o="evenodd"===n,a=r.length>1;if(o&&a){const t=r.map(t=>({path:t,area:re(t)}));t.sort((t,e)=>e.area-t.area);const n=r.length>3||!function(t){if(t.length<=2)return!0;const e=t.map(t=>t.area).sort((t,e)=>e-t),[i,s]=e,n=e[e.length-1];return!(i/s>3&&s/n<2)}(t);if(n)for(let n=0;n<t.length;n++){const r=t[n],o=0===n;e.context.beginPath();const a=new ch(void 0,!0);oe(r.path,a),e.context.path(a),o?(i&&e.context.fill(i),s&&e.context.stroke(s)):e.context.cut()}else for(let n=0;n<t.length;n++){const r=t[n],o=n%2==1;e.context.beginPath();const a=new ch(void 0,!0);oe(r.path,a),e.context.path(a),o?e.context.cut():(i&&e.context.fill(i),s&&e.context.stroke(s))}}else A=new ch(w,!n||"evenodd"===n),e.context.path(A),i&&e.context.fill(i),s&&e.context.stroke(s);break}case"circle":f=$t(t,"cx",0),m=$t(t,"cy",0),y=$t(t,"r",0),e.context.ellipse(f,m,y,y),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"rect":l=$t(t,"x",0),c=$t(t,"y",0),C=$t(t,"width",0),S=$t(t,"height",0),x=$t(t,"rx",0),b=$t(t,"ry",0),x||b?e.context.roundRect(l,c,C,S,x||b):e.context.rect(l,c,C,S),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"ellipse":f=$t(t,"cx",0),m=$t(t,"cy",0),x=$t(t,"rx",0),b=$t(t,"ry",0),e.context.beginPath(),e.context.ellipse(f,m,x,b),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"line":d=$t(t,"x1",0),u=$t(t,"y1",0),p=$t(t,"x2",0),g=$t(t,"y2",0),e.context.beginPath(),e.context.moveTo(d,u),e.context.lineTo(p,g),s&&e.context.stroke(s);break;case"polygon":_=t.getAttribute("points"),v=_.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(v,!0),i&&e.context.fill(i),s&&e.context.stroke(s);break;case"polyline":_=t.getAttribute("points"),v=_.match(/\d+/g).map(t=>parseInt(t,10)),e.context.poly(v,!1),s&&e.context.stroke(s);break;case"g":case"svg":break;default:o(t.nodeName)}h&&(i=null);for(let t=0;t<n.length;t++)ae(n[t],e,i,s)}function he(t){return t instanceof Zo}function le(t){return t instanceof Wo}function ce(t,e,i){return t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,{...i,...t}}function de(t,e,i){return e.buildGradient(),t.fill=e,t.color=16777215,t.texture=e.texture,t.matrix=e.transform,t.textureSpace=e.textureSpace,{...i,...t}}function ue(t,e){if(null==t)return null;const i={},s=t;return function(t){return yn.isColorLike(t)}(t)?function(t,e,i){const s=yn.shared.setValue(e??0);return t.color=s.toNumber(),t.alpha=1===s.alpha?i.alpha:s.alpha,t.texture=Gs.WHITE,{...i,...t}}(i,t,e):function(t){return t instanceof Gs}(t)?function(t,e,i){return t.texture=e,{...i,...t}}(i,t,e):he(t)?ce(i,t,e):le(t)?de(i,t,e):s.fill&&he(s.fill)?ce(s,s.fill,e):s.fill&&le(s.fill)?de(s,s.fill,e):function(t,e){const i={...e,...t},s=yn.shared.setValue(i.color);return i.alpha*=s.alpha,i.color=s.toNumber(),i}(s,e)}function pe(t,e){const{width:i,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...h}=e,l=ue(t,h);return l?{width:i,alignment:s,miterLimit:n,cap:r,join:o,pixelLine:a,...l}:null}function ge(t,e,i,s=0){if(t.texture===Gs.WHITE&&!t.fill)return yn.shared.setValue(t.color).setAlpha(t.alpha??1).toHexa();if(!t.fill){const i=e.createPattern(t.texture.source.resource,"repeat"),s=t.matrix.copyTo(ps.shared);return s.scale(t.texture.frame.width,t.texture.frame.height),i.setTransform(s),i}if(t.fill instanceof Zo){const i=t.fill,s=e.createPattern(i.texture.source.resource,"repeat"),n=i.transform.copyTo(ps.shared);return n.scale(i.texture.frame.width,i.texture.frame.height),s.setTransform(n),s}if(t.fill instanceof Wo){const n=t.fill,r="linear"===n.type,o="local"===n.textureSpace;let a,h=1,l=1;o&&i&&(h=i.width+s,l=i.height+s);let c=!1;if(r){const{start:t,end:i}=n;a=e.createLinearGradient(t.x*h,t.y*l,i.x*h,i.y*l),c=Math.abs(i.x-t.x)<Math.abs(.1*(i.y-t.y))}else{const{center:t,innerRadius:i,outerCenter:s,outerRadius:r}=n;a=e.createRadialGradient(t.x*h,t.y*l,i*h,s.x*h,s.y*l,r*h)}if(c&&o&&i){const t=i.lineHeight/l;for(let e=0;e<i.lines.length;e++){const r=(e*i.lineHeight+s/2)/l;n.colorStops.forEach(e=>{const i=r+e.offset*t;a.addColorStop(Math.floor(i*bh)/bh,yn.shared.setValue(e.color).toHex())})}}else n.colorStops.forEach(t=>{a.addColorStop(t.offset,yn.shared.setValue(t.color).toHex())});return a}return o(),"red"}function fe(t,e,i,s){const n={width:0,height:0,offsetY:0,scale:e.fontSize/i.baseMeasurementFontSize,lines:[{width:0,charPositions:[],spaceWidth:0,spacesIndex:[],chars:[]}]};n.offsetY=i.baseLineOffset;let r=n.lines[0],o=null,a=!0;const h={width:0,start:0,index:0,positions:[],chars:[]},l=i.baseMeasurementFontSize/e.fontSize,c=e.letterSpacing*l,d=e.wordWrapWidth*l,u=e.lineHeight?e.lineHeight*l:i.lineHeight,p=e.wordWrap&&e.breakWords,g=t=>{const e=r.width;for(let i=0;i<h.index;i++){const s=t.positions[i];r.chars.push(t.chars[i]),r.charPositions.push(s+e)}r.width+=t.width,a=!1,h.width=0,h.index=0,h.chars.length=0},f=()=>{let t=r.chars.length-1;if(s){let e=r.chars[t];for(;" "===e;)r.width-=i.chars[e].xAdvance,e=r.chars[--t]}n.width=Math.max(n.width,r.width),r={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},a=!0,n.lines.push(r),n.height+=u},m=t=>t-c>d;for(let s=0;s<t.length+1;s++){let n;const l=s===t.length;l||(n=t[s]);const d=i.chars[n]||i.chars[" "];if(/(?:\s)/.test(n)||"\r"===n||"\n"===n||l){if(!a&&e.wordWrap&&m(r.width+h.width)?(f(),g(h),l||r.charPositions.push(0)):(h.start=r.width,g(h),l||r.charPositions.push(0)),"\r"===n||"\n"===n)f();else if(!l){const t=d.xAdvance+(d.kerning[o]||0)+c;r.width+=t,r.spaceWidth=t,r.spacesIndex.push(r.charPositions.length),r.chars.push(n)}}else{const t=d.kerning[o]||0,e=d.xAdvance+t+c;p&&m(r.width+h.width+e)&&(g(h),f()),h.positions[h.index++]=h.width+t,h.chars.push(n),h.width+=e}o=n}return f(),"center"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],s=t.width/2-i.width/2;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=s}}(n):"right"===e.align?function(t){for(let e=0;e<t.lines.length;e++){const i=t.lines[e],s=t.width-i.width;for(let t=0;t<i.charPositions.length;t++)i.charPositions[t]+=s}}(n):"justify"===e.align&&function(t){const e=t.width;for(let i=0;i<t.lines.length;i++){const s=t.lines[i];let n=0,r=s.spacesIndex[n++],o=0;const a=s.spacesIndex.length,h=(e-s.width)/a;for(let t=0;t<s.charPositions.length;t++)t===r&&(r=s.spacesIndex[n++],o+=h),s.charPositions[t]+=o}}(n),n}async function me(t){if("Image"in globalThis)return new Promise(e=>{const i=new Image;i.onload=()=>{e(!0)},i.onerror=()=>{e(!1)},i.src=t});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const e=await(await fetch(t)).blob();await createImageBitmap(e)}catch(t){return!1}return!0}return!1}function ye(t){return!Dh&&""!==document.createElement("video").canPlayType(t)}function xe(t,e){if(Array.isArray(e)){for(const i of e)if(t.startsWith(`data:${i}`))return!0;return!1}return t.startsWith(`data:${e}`)}function be(t,e){const i=t.split("?")[0],s=mr.extname(i).toLowerCase();return Array.isArray(e)?e.includes(s):s===e}function ve(t){return Xh.test(t)?t:encodeURI(t)}function _e(t,e=1){const i=xr.RETINA_PREFIX?.exec(t);return i?parseFloat(i[1]):e}function we(t,e,i){t.label=i,t._sourceOrigin=i;const s=new Gs({source:t,label:i}),n=()=>{delete e.promiseCache[i],pr.has(i)&&pr.remove(i)};return s.source.once("destroy",()=>{e.promiseCache[i]&&(o(),n())}),s.once("destroy",()=>{t.destroyed||(o(),n())}),s}function Ae(t,e,i,s,n,r,o,a){const h=o-i,l=a-s,c=n-i,d=r-s,u=t-i,p=e-s,g=h*h+l*l,f=h*c+l*d,m=h*u+l*p,y=c*c+d*d,x=c*u+d*p,b=1/(g*y-f*f),v=(y*m-f*x)*b,_=(g*x-f*m)*b;return v>=0&&_>=0&&v+_<1}function Ce(t,e,i){for(let s=0,n=4*i*e;s<e;++s,n+=4)if(0!==t[n+3])return!1;return!0}function Se(t,e,i,s,n){const r=4*e;for(let e=s,o=s*r+4*i;e<=n;++e,o+=r)if(0!==t[o+3])return!1;return!0}function Ie(...t){let e=t[0];e.canvas||(e={canvas:t[0],resolution:t[1]});const{canvas:s}=e,n=Math.min(e.resolution??1,1),r=e.width??s.width,o=e.height??s.height;let a=e.output;if(function(t,e){Zl||(Zl=ir.get().createCanvas(256,128),Xl=Zl.getContext("2d",{willReadFrequently:!0}),Xl.globalCompositeOperation="copy",Xl.globalAlpha=1),(Zl.width<t||Zl.height<e)&&(Zl.width=i(t),Zl.height=i(e))}(r,o),!Xl)throw new TypeError("Failed to get canvas 2D context");Xl.drawImage(s,0,0,r,o,0,0,r*n,o*n);const h=Xl.getImageData(0,0,r,o).data;let l=0,c=0,d=r-1,u=o-1;for(;c<o&&Ce(h,r,c);)++c;if(c===o)return Ss.EMPTY;for(;Ce(h,r,u);)--u;for(;Se(h,r,l,c,u);)++l;for(;Se(h,r,d,c,u);)--d;return++d,++u,Xl.globalCompositeOperation="source-over",Xl.strokeRect(l,c,d-l,u-c),Xl.globalCompositeOperation="copy",a??(a=new Ss),a.set(l/n,c/n,(d-l)/n,(u-c)/n),a}function Me(t,e){for(const i in t.attributes){const s=t.attributes[i],n=e[i];n?(s.format??(s.format=n.format),s.offset??(s.offset=n.offset),s.instance??(s.instance=n.instance)):o()}!function(t){const{buffers:e,attributes:i}=t,s={},n={};for(const t in e){const i=e[t];s[i.uid]=0,n[i.uid]=0}for(const t in i){const e=i[t];s[e.buffer.uid]+=R(e.format).stride}for(const t in i){const e=i[t];e.stride??(e.stride=s[e.buffer.uid]),e.start??(e.start=n[e.buffer.uid]),n[e.buffer.uid]+=R(e.format).stride}}(t)}function Te(t){return Sc[t]??Sc.float32}function Pe(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0,s=0;for(let t=0;t<e.length;t++){const n=e[t];if(i=jc[n.data.type],!i)throw new Error(`Unknown type ${n.data.type}`);n.data.size>1&&(i=Math.max(i,16)*n.data.size);const r=12===i?16:i;n.size=i;const o=s%16;s+=o>0&&16-o<r?(16-o)%16:(i-o%i)%i,n.offset=s,s+=i}return s=16*Math.ceil(s/16),{uboElements:e,size:s}}function Ee(t,e,i,s){const n=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let r=0;for(let o=0;o<t.length;o++){const a=t[o],h=a.data.name;let l=!1,c=0;for(let t=0;t<Gc.length;t++)if(Gc[t].test(a.data)){c=a.offset/4,n.push(`name = "${h}";`,`offset += ${c-r};`,Gc[t][e]||Gc[t].ubo),l=!0;break}if(!l)if(a.data.size>1)c=a.offset/4,n.push(i(a,c-r));else{const t=s[a.data.type];c=a.offset/4,n.push(`\n v = uv.${h};\n offset += ${c-r};\n ${t};\n `)}r=c}const o=n.join("\n");return new Function("uv","data","dataInt32","offset",o)}function Be(t,e){return`\n for (let i = 0; i < ${t*e}; i++) {\n data[offset + (((i / ${t})|0) * 4) + (i % ${t})] = v[i];\n }\n `}function Re(t,e){const i=Math.max(jc[t.data.type]/16,1),s=t.data.value.length/t.data.size,n=(4-s%4)%4,r=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n offset += ${e};\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*i}; i++)\n {\n for(var j = 0; j < ${s}; j++)\n {\n ${r}[arrayOffset++] = v[t++];\n }\n ${0!==n?`arrayOffset += ${n};`:""}\n }\n `}function ke(t){return Ee(t,"uboStd40",Re,Uc)}function Oe(t,e){if(!Hc.has(t)){const i=new Gs({source:new sr({resource:t,...e})}),s=()=>{Hc.get(t)===i&&Hc.delete(t)};i.once("destroy",s),i.source.once("destroy",s),Hc.set(t,i)}return Hc.get(t)}function De(t,e,i){const s=t.createShader(e);return t.shaderSource(s,i),t.compileShader(s),s}function Fe(t){const e=new Array(t);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Le(t,e){switch(t){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return Fe(2*e);case"bvec3":return Fe(3*e);case"bvec4":return Fe(4*e);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}function je(t,e){if(!Qc){const e=Object.keys(qc);Qc={};for(let i=0;i<e.length;++i){const s=e[i];Qc[t[s]]=qc[s]}}return Qc[e]}function Ge(t,e){const i=je(t,e);return $c[i]||"float32"}function Ue(t,e){const i=t.getShaderSource(e).split("\n").map((t,e)=>`${e}: ${t}`),s=t.getShaderInfoLog(e).split("\n"),n={},r=s.map(t=>parseFloat(t.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(t=>!(!t||n[t]||(n[t]=!0,0))),o=[""];r.forEach(t=>{i[t-1]=`%c${i[t-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const a=i.join("\n");o[0]=a}function ze(t,e,i,s,n,r,o,a){const h=r;if(!a||"repeat"!==t.addressModeU||"repeat"!==t.addressModeV||"repeat"!==t.addressModeW){const i=fd[o?"clamp-to-edge":t.addressModeU],s=fd[o?"clamp-to-edge":t.addressModeV],r=fd[o?"clamp-to-edge":t.addressModeW];e[n](h,e.TEXTURE_WRAP_S,i),e[n](h,e.TEXTURE_WRAP_T,s),e.TEXTURE_WRAP_R&&e[n](h,e.TEXTURE_WRAP_R,r)}if(a&&"linear"===t.magFilter||e[n](h,e.TEXTURE_MAG_FILTER,pd[t.magFilter]),i){if(!a||"linear"!==t.mipmapFilter){const i=gd[t.minFilter][t.mipmapFilter];e[n](h,e.TEXTURE_MIN_FILTER,i)}}else e[n](h,e.TEXTURE_MIN_FILTER,pd[t.minFilter]);if(s&&t.maxAnisotropy>1){const i=Math.min(t.maxAnisotropy,e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[n](h,s.TEXTURE_MAX_ANISOTROPY_EXT,i)}t.compare&&e[n](h,e.TEXTURE_COMPARE_FUNC,md[t.compare])}function Ne(t,e){const i=t.instructionSet,s=i.instructions;for(let t=0;t<i.instructionSize;t++){const i=s[t];e[i.renderPipeId].execute(i)}}function Ve(t,e){e||(e=0);for(let i=e;i<t.length&&t[i];i++)t[i]=null}function He(t,e=!1){!function(t){const e=t.root;let i;if(t.renderGroupParent){const s=t.renderGroupParent;t.worldTransform.appendFrom(e.relativeGroupTransform,s.worldTransform),t.worldColor=u(e.groupColor,s.worldColor),i=e.groupAlpha*s.worldAlpha}else t.worldTransform.copyFrom(e.localTransform),t.worldColor=e.localColor,i=e.localAlpha;i=i<0?0:i>1?1:i,t.worldAlpha=i,t.worldColorAlpha=t.worldColor+(255*i<<24)}(t);const i=t.childrenToUpdate,s=t.updateTick++;for(const e in i){const n=Number(e),r=i[e],o=r.list,a=r.index;for(let e=0;e<a;e++){const i=o[e];i.parentRenderGroup===t&&i.relativeRenderGroupDepth===n&&We(i,s,0)}Ve(o,a),r.index=0}if(e)for(let i=0;i<t.renderGroupChildren.length;i++)He(t.renderGroupChildren[i],e)}function We(t,e,i){if(e===t.updateTick)return;t.updateTick=e,t.didChange=!1;const s=t.localTransform;t.updateLocalTransform();const n=t.parent;if(n&&!n.renderGroup?(i|=t._updateFlags,t.relativeGroupTransform.appendFrom(s,n.relativeGroupTransform),7&i&&Je(t,n,i)):(i=t._updateFlags,t.relativeGroupTransform.copyFrom(s),7&i&&Je(t,Cd,i)),!t.renderGroup){const s=t.children,n=s.length;for(let t=0;t<n;t++)We(s[t],e,i);const r=t.parentRenderGroup,o=t;o.renderPipeId&&!r.structureDidChange&&r.updateRenderable(o)}}function Je(t,e,i){if(1&i){t.groupColor=u(t.localColor,e.groupColor);let i=t.localAlpha*e.groupAlpha;i=i<0?0:i>1?1:i,t.groupAlpha=i,t.groupColorAlpha=t.groupColor+(255*i<<24)}2&i&&(t.groupBlendMode="inherit"===t.localBlendMode?e.groupBlendMode:t.localBlendMode),4&i&&(t.globalDisplayStatus=t.localDisplayStatus&e.globalDisplayStatus),t._updateFlags=0}function Ze(t,e,i){const s=(t>>24&255)/255;e[i++]=(255&t)/255*s,e[i++]=(t>>8&255)/255*s,e[i++]=(t>>16&255)/255*s,e[i++]=s}function Xe(t){let e=!1;for(const i in t)if(null==t[i]){e=!0;break}if(!e)return t;const i=Object.create(null);for(const e in t){const s=t[e];s&&(i[e]=s)}return i}function Ye(t){let e=0;for(let i=0;i<t.length;i++)null==t[i]?e++:t[i-e]=t[i];return t.length-=e,t}function Ke(t){const e=t.map(t=>({data:t,offset:0,size:0}));let i=0;for(let t=0;t<e.length;t++){const s=e[t];let n=gu[s.data.type].size;const r=gu[s.data.type].align;if(!gu[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(n=Math.max(n,r)*s.data.size),i=Math.ceil(i/r)*r,s.size=n,s.offset=i,i+=n}return i=16*Math.ceil(i/16),{uboElements:e,size:i}}function Qe(t,e){const{size:i,align:s}=gu[t.data.type],n=(s-i)/4,r=t.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${t.data.name};\n ${0!==e?`offset += ${e};`:""}\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${t.data.size*(i/4)}; i++)\n {\n for(var j = 0; j < ${i/4}; j++)\n {\n ${r}[arrayOffset++] = v[t++];\n }\n ${0!==n?`arrayOffset += ${n};`:""}\n }\n `}function qe(t){return Ee(t,"uboWgsl",Qe,zc)}function $e(t,e=null){const i=6*t;if(i>65535?e||(e=new Uint32Array(i)):e||(e=new Uint16Array(i)),e.length!==i)throw new Error(`Out buffer length is incorrect, got ${e.length} and expected ${i}`);for(let t=0,s=0;t<i;t+=6,s+=4)e[t+0]=s+0,e[t+1]=s+1,e[t+2]=s+2,e[t+3]=s+0,e[t+4]=s+2,e[t+5]=s+3;return e}function ti(t,e){const i=[];i.push("\n\n var index = 0;\n\n for (let i = 0; i < ps.length; ++i)\n {\n const p = ps[i];\n\n ");let s=0;for(const n in t){const r=t[n];e===r.dynamic&&(i.push(`offset = index + ${s}`),i.push(r.code),s+=R(r.format).stride/4)}i.push("\n index += stride * 4;\n }\n "),i.unshift(`\n var stride = ${s};\n `);const n=i.join("\n");return new Function("ps","f32v","u32v",n)}function ei(t,e){e.groupTransform=t.groupTransform,e.groupColorAlpha=t.groupColorAlpha,e.groupColor=t.groupColor,e.groupBlendMode=t.groupBlendMode,e.globalDisplayStatus=t.globalDisplayStatus,e.groupTransform=t.groupTransform,e.localDisplayStatus=t.localDisplayStatus,e.groupAlpha=t.groupAlpha,e._roundPixels=t._roundPixels}function ii(t,e){const{texture:i,bounds:s}=t,n=e._style._getFinalPadding();r(s,e._anchor,i);const o=e._anchor._x*n*2,a=e._anchor._y*n*2;s.minX-=n-o,s.minY-=n-a,s.maxX-=n-o,s.maxY-=n-a}function si(t,e,i,s){const n=Mp;n.minX=0,n.minY=0,n.maxX=t.width/s|0,n.maxY=t.height/s|0;const r=Nn.getOptimalTexture(n.width,n.height,s,!1);return r.source.uploadMethodId="image",r.source.resource=t,r.source.alphaMode="premultiply-alpha-on-upload",r.frame.width=e/s,r.frame.height=i/s,r.source.emit("update",r.source),r.updateUvs(),r}function ni(t){return Yp[t>>4]+Yp[15&t]}function ri(t,e){return Vp[(t>>e&3).toString(2).padStart(2,"0")]}function oi(t,e,i,s){let n=3&t,r=t>>2&63;if(1===n||62===r)i.push(e);else if(0===n&&r<=31)s.has(r)||s.set(r,[]),s.get(r).push(e);else if(0===n){let t;switch(r){case 60:t=Zp.NO_ROOM_DATA;break;case 61:t=Zp.ROOM_GAP;break;case 62:t=Zp.OBSTACLE_ROOM;break;case 63:t=Zp.UNKNOWN_ROOM}void 0!==t&&(s.has(t)||s.set(t,[]),s.get(t).push(e))}}function ai(t){switch(t){case 28:return Zp.NO_ROOM_DATA;case 29:return Zp.ROOM_GAP;case 30:return Zp.OBSTACLE_ROOM;case 31:return Zp.UNKNOWN_ROOM;default:return}}function hi(t,e,i,s,n){let r=7&t,o=t>>3&31;if(1===r||30===o)i.push(e);else if(2===r)if(s.push(e),o<=27)n.has(o)||n.set(o,[]),n.get(o).push(e);else{let t=ai(o);void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}else if(7===r)if(o<=27)n.has(o)||n.set(o,[]),n.get(o).push(e);else{let t=ai(o);void 0!==t&&(n.has(t)||n.set(t,[]),n.get(t).push(e))}}function li(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":Qg&&Qg in Object(t)?function(t){var e=Zg.call(t,Yg),i=t[Yg];try{t[Yg]=void 0;var s=!0}catch(t){}var n=Xg.call(t);return s&&(e?t[Yg]=i:delete t[Yg]),n}(t):function(t){return Kg.call(t)}(t)}function ci(t){return null!=t&&"object"==typeof t}function di(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function ui(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||ci(t)&&"[object Symbol]"==li(t)}(t))return NaN;if(di(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=di(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;var i;t=(i=t)?i.slice(0,function(t){for(var e=t.length;e--&&$g.test(t.charAt(e)););return e}(i)+1).replace(tf,""):i;var s=sf.test(t);return s||nf.test(t)?rf(t.slice(2),s?2:8):ef.test(t)?NaN:+t}function pi(t){return t}function gi(t){if(!di(t))return!1;var e=li(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function fi(t){if(null!=t){try{return hf.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function mi(t,e){var i=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!di(t)||(e=t,af&&af in e))&&(gi(t)?gf:lf).test(fi(t));var e}(i)?i:void 0}function yi(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&wf.test(t))&&t>-1&&t%1==0&&t<e}function xi(t,e,i){"__proto__"==e&&bf?bf(t,e,{configurable:!0,enumerable:!0,value:i,writable:!0}):t[e]=i}function bi(t,e){return t===e||t!=t&&e!=e}function vi(t,e,i){var s=t[e];Af.call(t,e)&&bi(s,i)&&(void 0!==i||e in t)||xi(t,e,i)}function _i(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}function wi(t){return null!=t&&_i(t.length)&&!gi(t)}function Ai(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Sf)}function Ci(t){return ci(t)&&"[object Arguments]"==li(t)}function Si(t,e){var i=qg(t),s=!i&&Pf(t),n=!i&&!s&&kf(t),r=!i&&!s&&!n&&zf(t),o=i||s||n||r,a=o?function(t,e){for(var i=-1,s=Array(t);++i<t;)s[i]=e(i);return s}(t.length,String):[],h=a.length;for(var l in t)!e&&!Nf.call(t,l)||o&&("length"==l||n&&("offset"==l||"parent"==l)||r&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||yi(l,h))||a.push(l);return a}function Ii(t,e){return function(i){return t(e(i))}}function Mi(t){return wi(t)?Si(t,!0):function(t){if(!di(t))return function(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e}(t);var e=Ai(t),i=[];for(var s in t)("constructor"!=s||!e&&Wf.call(t,s))&&i.push(s);return i}(t)}function Ti(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function Pi(t,e){for(var i=t.length;i--;)if(bi(t[i][0],e))return i;return-1}function Ei(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function Bi(t,e){var i=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?i["string"==typeof e?"string":"hash"]:i.map}function Ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var s=t[e];this.set(s[0],s[1])}}function ki(t){var e=this.__data__=new Ei(t);this.size=e.size}function Oi(t){return function(t,e,i){var s=function(t){return wi(t)?Si(t):function(t){if(!Ai(t))return Vf(t);var e=[];for(var i in Object(t))Hf.call(t,i)&&"constructor"!=i&&e.push(i);return e}(t)}(t);return qg(t)?s:function(t,e){for(var i=-1,s=e.length,n=t.length;++i<s;)t[n+i]=e[i];return t}(s,i(t))}(t,0,hm)}function Di(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new Ri;++e<i;)this.add(t[e])}function Fi(t,e){for(var i=-1,s=null==t?0:t.length;++i<s;)if(e(t[i],i,t))return!0;return!1}function Li(t,e,i,s,n,r){var o=1&i,a=t.length,h=e.length;if(a!=h&&!(o&&h>a))return!1;var l=r.get(t),c=r.get(e);if(l&&c)return l==e&&c==t;var d=-1,u=!0,p=2&i?new Di:void 0;for(r.set(t,e),r.set(e,t);++d<a;){var g=t[d],f=e[d];if(s)var m=o?s(f,g,d,e,t,r):s(g,f,d,t,e,r);if(void 0!==m){if(m)continue;u=!1;break}if(p){if(!Fi(e,function(t,e){if(o=e,!p.has(o)&&(g===t||n(g,t,i,s,r)))return p.push(e);var o})){u=!1;break}}else if(g!==f&&!n(g,f,i,s,r)){u=!1;break}}return r.delete(t),r.delete(e),u}function ji(t){var e=-1,i=Array(t.size);return t.forEach(function(t,s){i[++e]=[s,t]}),i}function Gi(t){var e=-1,i=Array(t.size);return t.forEach(function(t){i[++e]=t}),i}function Ui(t,e,i,s,n){return t===e||(null==t||null==e||!ci(t)&&!ci(e)?t!=t&&e!=e:function(t,e,i,s,n,r){var o=qg(t),a=qg(e),h=o?Pm:wm(t),l=a?Pm:wm(e),c=(h=h==Tm?Em:h)==Em,d=(l=l==Tm?Em:l)==Em,u=h==l;if(u&&kf(t)){if(!kf(e))return!1;o=!0,c=!1}if(u&&!c)return r||(r=new ki),o||zf(t)?Li(t,e,i,s,n,r):function(t,e,i,s,n,r,o){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!r(new Am(t),new Am(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return bi(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=ji;case"[object Set]":var h=1&s;if(a||(a=Gi),t.size!=e.size&&!h)return!1;var l=o.get(t);if(l)return l==e;s|=2,o.set(t,e);var c=Li(a(t),a(e),s,n,r,o);return o.delete(t),c;case"[object Symbol]":if(Im)return Im.call(t)==Im.call(e)}return!1}(t,e,h,i,s,n,r);if(!(1&i)){var p=c&&Bm.call(t,"__wrapped__"),g=d&&Bm.call(e,"__wrapped__");if(p||g){var f=p?t.value():t,m=g?e.value():e;return r||(r=new ki),n(f,m,i,s,r)}}return!!u&&(r||(r=new ki),function(t,e,i,s,n,r){var o=1&i,a=Oi(t),h=a.length;if(h!=Oi(e).length&&!o)return!1;for(var l=h;l--;){var c=a[l];if(!(o?c in e:Mm.call(e,c)))return!1}var d=r.get(t),u=r.get(e);if(d&&u)return d==e&&u==t;var p=!0;r.set(t,e),r.set(e,t);for(var g=o;++l<h;){var f=t[c=a[l]],m=e[c];if(s)var y=o?s(m,f,c,e,t,r):s(f,m,c,t,e,r);if(!(void 0===y?f===m||n(f,m,i,s,r):y)){p=!1;break}g||(g="constructor"==c)}if(p&&!g){var x=t.constructor,b=e.constructor;x==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof x&&x instanceof x&&"function"==typeof b&&b instanceof b||(p=!1)}return r.delete(t),r.delete(e),p}(t,e,i,s,n,r))}(t,e,i,s,Ui,n))}function zi(t,e,i){function s(e){var i=h,s=l;return h=l=void 0,g=e,d=t.apply(s,i)}function n(t){var i=t-p;return void 0===p||i>=e||i<0||m&&t-g>=c}function r(){var t=km();if(n(t))return o(t);u=setTimeout(r,function(t){var i=e-(t-p);return m?Dm(i,c-(t-g)):i}(t))}function o(t){return u=void 0,y&&h?s(t):(h=l=void 0,d)}function a(){var t=km(),i=n(t);if(h=arguments,l=this,p=t,i){if(void 0===u)return function(t){return g=t,u=setTimeout(r,e),f?s(t):d}(p);if(m)return clearTimeout(u),u=setTimeout(r,e),s(p)}return void 0===u&&(u=setTimeout(r,e)),d}var h,l,c,d,u,p,g=0,f=!1,m=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return e=ui(e)||0,di(i)&&(f=!!i.leading,c=(m="maxWait"in i)?Om(ui(i.maxWait)||0,e):c,y="trailing"in i?!!i.trailing:y),a.cancel=function(){void 0!==u&&clearTimeout(u),g=0,h=p=l=u=void 0},a.flush=function(){return void 0===u?d:o(km())},a}function Ni(t,e,i){(void 0!==i&&!bi(t[e],i)||void 0===i&&!(e in t))&&xi(t,e,i)}function Vi(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}function Hi(t,e,i,s,n){t!==e&&Rm(e,function(r,o){if(n||(n=new ki),di(r))!function(t,e,i,s,n,r,o){var a=Vi(t,i),h=Vi(e,i),l=o.get(h);if(l)Ni(t,i,l);else{var c,d=r?r(a,h,i+"",t,e,o):void 0,u=void 0===d;if(u){var p=qg(h),g=!p&&kf(h),f=!p&&!g&&zf(h);d=h,p||g||f?qg(a)?d=a:ci(c=a)&&wi(c)?d=function(t,e){var i=-1,s=t.length;for(e||(e=Array(s));++i<s;)e[i]=t[i];return e}(a):g?(u=!1,d=h.slice()):f?(u=!1,d=function(t){var e=function(t){var e=new t.constructor(t.byteLength);return new Am(e).set(new Am(t)),e}(t.buffer);return new t.constructor(e,t.byteOffset,t.length)}(h)):d=[]:function(t){if(!ci(t)||"[object Object]"!=li(t))return!1;var e=Qf(t);if(null===e)return!0;var i=em.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&tm.call(i)==im}(h)||Pf(h)?(d=a,Pf(a)?d=function(t){return function(t,e,i){var s=!i;i||(i={});for(var n=-1,r=e.length;++n<r;){var o=e[n],a=void 0;void 0===a&&(a=t[o]),s?xi(i,o,a):vi(i,o,a)}return i}(t,Mi(t))}(a):di(a)&&!gi(a)||(d=function(t){return"function"!=typeof t.constructor||Ai(t)?{}:yf(Qf(t))}(h))):u=!1}u&&(o.set(h,d),n(d,h,s,r,o),o.delete(h)),Ni(t,i,d)}}(t,e,o,i,Hi,s,n);else{var a=s?s(Vi(t,o),r,o+"",t,e,n):void 0;void 0===a&&(a=r),Ni(t,o,a)}},Mi)}function Wi(t,e){return Ui(t,e)}function Ji(t,e,i){var s=!0,n=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return di(i)&&(s="leading"in i?!!i.leading:s,n="trailing"in i?!!i.trailing:n),zi(t,e,{leading:s,maxWait:e,trailing:n})}function Zi(t={}){if(!Nm(t))throw new Error("object required");const e=Xm.get(t);if(e)return e;let i=Zm[0];const s=new Set,n=(t,e=++Zm[0])=>{i!==e&&(r=i=e,s.forEach(i=>i(t,e)))};let r=i;const o=t=>(e,i)=>{const s=[...e];s[1]=[t,...s[1]],n(s,i)},a=new Map;let h=!0;const l=qm(()=>h,(t,e)=>{const i=!Wm.has(e)&&Hm.get(e);if(i){if("production"!==(zm?"core":void 0)&&a.has(t))throw new Error("prop listener already exists");if(s.size){const e=i[2](o(t));a.set(t,[i,e])}else a.set(t,[i])}},t=>{var e;const i=a.get(t);i&&(a.delete(t),null==(e=i[1])||e.call(i))},n),c=Km(t,l);Xm.set(t,c);const d=[t,(t=Zm[0])=>(r!==t&&(r=t,a.forEach(([e])=>{const s=e[1](t);s>i&&(i=s)})),i),t=>(s.add(t),1===s.size&&a.forEach(([t,e],i)=>{if("production"!==(zm?"core":void 0)&&e)throw new Error("remove already exists");const s=t[2](o(i));a.set(i,[t,s])}),()=>{s.delete(t),0===s.size&&a.forEach(([t,e],i)=>{e&&(e(),a.set(i,[t]))})})];return Hm.set(c,d),Reflect.ownKeys(t).forEach(e=>{const i=Object.getOwnPropertyDescriptor(t,e);"value"in i&&i.writable&&(c[e]=t[e])}),h=!1,c}function Xi(t,e,i,s){let n=t[e];return function(t,e){const i=Hm.get(t);let s;const n=[],r=i[2];let o=!1;const a=r(t=>{n.push(t),s||(s=Promise.resolve().then(()=>{s=void 0,o&&e(n.splice(0))}))});return o=!0,()=>{o=!1,a()}}(t,()=>{const s=t[e];Object.is(n,s)||i(n=s)})}function Yi(){return hy.getService()}function Ki(){return gx||(gx=1,Object.defineProperty(wx,"__esModule",{value:!0}),wx.loop=wx.conditional=wx.parse=void 0,wx.parse=function t(e,i){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:s;if(Array.isArray(i))i.forEach(function(i){return t(e,i,s,n)});else if("function"==typeof i)i(e,s,n,t);else{var r=Object.keys(i)[0];Array.isArray(i[r])?(n[r]={},t(e,i[r],s,n[r])):n[r]=i[r](e,s,n,t)}return s},wx.conditional=function(t,e){return function(i,s,n,r){e(i,s,n)&&r(i,t,s,n)}},wx.loop=function(t,e){return function(i,s,n,r){for(var o=[],a=i.pos;e(i,s,n);){var h={};if(r(i,t,s,h),i.pos===a)break;a=i.pos,o.push(h)}return o}}),wx}function Qi(){if(fx)return Ax;fx=1,Object.defineProperty(Ax,"__esModule",{value:!0}),Ax.readBits=Ax.readArray=Ax.readUnsigned=Ax.readString=Ax.peekBytes=Ax.readBytes=Ax.peekByte=Ax.readByte=Ax.buildStream=void 0,Ax.buildStream=function(t){return{data:t,pos:0}},Ax.readByte=function(){return function(t){return t.data[t.pos++]}},Ax.peekByte=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function(e){return e.data[e.pos+t]}};var t=function(t){return function(e){return e.data.subarray(e.pos,e.pos+=t)}};return Ax.readBytes=t,Ax.peekBytes=function(t){return function(e){return e.data.subarray(e.pos,e.pos+t)}},Ax.readString=function(e){return function(i){return Array.from(t(e)(i)).map(function(t){return String.fromCharCode(t)}).join("")}},Ax.readUnsigned=function(e){return function(i){var s=t(2)(i);return e?(s[1]<<8)+s[0]:(s[0]<<8)+s[1]}},Ax.readArray=function(e,i){return function(s,n,r){for(var o="function"==typeof i?i(s,n,r):i,a=t(e),h=new Array(o),l=0;l<o;l++)h[l]=a(s);return h}},Ax.readBits=function(t){return function(e){for(var i=function(t){return t.data[t.pos++]}(e),s=new Array(8),n=0;n<8;n++)s[7-n]=!!(i&1<<n);return Object.keys(t).reduce(function(e,i){var n=t[i];return n.length?e[i]=function(t,e,i){for(var s=0,n=0;n<i;n++)s+=t[e+n]&&Math.pow(2,i-n-1);return s}(s,n.index,n.length):e[i]=s[n.index],e},{})}},Ax}var qi=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(qi||{});const $i=t=>{if("function"==typeof t||"object"==typeof t&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={..."object"!=typeof t.extension?{type:t.extension}:t.extension,ref:t}}if("object"!=typeof t)throw new Error("Invalid extension type");return"string"==typeof(t={...t}).type&&(t.type=[t.type]),t},ts=(t,e)=>$i(t).priority??e,es={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map($i).forEach(t=>{t.type.forEach(e=>this._removeHandlers[e]?.(t))}),this},add(...t){return t.map($i).forEach(t=>{t.type.forEach(e=>{const i=this._addHandlers,s=this._queue;i[e]?i[e]?.(t):(s[e]=s[e]||[],s[e]?.push(t))})}),this},handle(t,e,i){const s=this._addHandlers,n=this._removeHandlers;if(s[t]||n[t])throw new Error(`Extension type ${t} already has a handler`);s[t]=e,n[t]=i;const r=this._queue;return r[t]&&(r[t]?.forEach(t=>e(t)),delete r[t]),this},handleByMap(t,e){return this.handle(t,t=>{t.name&&(e[t.name]=t.ref)},t=>{t.name&&delete e[t.name]})},handleByNamedList(t,e,i=-1){return this.handle(t,t=>{e.findIndex(e=>e.name===t.name)>=0||(e.push({name:t.name,value:t.ref}),e.sort((t,e)=>ts(e.value,i)-ts(t.value,i)))},t=>{const i=e.findIndex(e=>e.name===t.name);-1!==i&&e.splice(i,1)})},handleByList(t,e,i=-1){return this.handle(t,t=>{e.includes(t.ref)||(e.push(t.ref),e.sort((t,e)=>ts(e,i)-ts(t,i)))},t=>{const i=e.indexOf(t.ref);-1!==i&&e.splice(i,1)})},mixin(t,...e){for(const i of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(i))}},is={extension:{type:qi.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(()=>Wx)}},ss={extension:{type:qi.Environment,name:"webworker",priority:0},test:()=>"undefined"!=typeof self&&void 0!==self.WorkerGlobalScope,load:async()=>{await Promise.resolve().then(()=>Jx)}};class ns{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new ns(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=${this._x} y=${this._y} 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))}}var rs,os={exports:{}};const as=t((rs||(rs=1,function(t){function e(){}function i(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function s(t,e,s,n,r){if("function"!=typeof s)throw new TypeError("The listener must be a function");var o=new i(s,n||t,r),h=a?a+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function n(t,i){0===--t._eventsCount?t._events=new e:delete t._events[i]}function r(){this._events=new e,this._eventsCount=0}var o=Object.prototype.hasOwnProperty,a="~";Object.create&&(e.prototype=Object.create(null),(new e).__proto__||(a=!1)),r.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)o.call(t,e)&&i.push(a?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},r.prototype.listeners=function(t){var e=a?a+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var s=0,n=i.length,r=new Array(n);s<n;s++)r[s]=i[s].fn;return r},r.prototype.listenerCount=function(t){var e=a?a+t:t,i=this._events[e];return i?i.fn?1:i.length:0},r.prototype.emit=function(t,e,i,s,n,r){var o=a?a+t:t;if(!this._events[o])return!1;var h,l,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,s),!0;case 5:return c.fn.call(c.context,e,i,s,n),!0;case 6:return c.fn.call(c.context,e,i,s,n,r),!0}for(l=1,h=new Array(d-1);l<d;l++)h[l-1]=arguments[l];c.fn.apply(c.context,h)}else{var u,p=c.length;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(t,c[l].fn,void 0,!0),d){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,e);break;case 3:c[l].fn.call(c[l].context,e,i);break;case 4:c[l].fn.call(c[l].context,e,i,s);break;default:if(!h)for(u=1,h=new Array(d-1);u<d;u++)h[u-1]=arguments[u];c[l].fn.apply(c[l].context,h)}}return!0},r.prototype.on=function(t,e,i){return s(this,t,e,i,!1)},r.prototype.once=function(t,e,i){return s(this,t,e,i,!0)},r.prototype.removeListener=function(t,e,i,s){var r=a?a+t:t;if(!this._events[r])return this;if(!e)return n(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||s&&!o.once||i&&o.context!==i||n(this,r);else{for(var h=0,l=[],c=o.length;h<c;h++)(o[h].fn!==e||s&&!o[h].once||i&&o[h].context!==i)&&l.push(o[h]);l.length?this._events[r]=1===l.length?l[0]:l:n(this,r)}return this},r.prototype.removeAllListeners=function(t){var i;return t?(i=a?a+t:t,this._events[i]&&n(this,i)):(this._events=new e,this._eventsCount=0),this},r.prototype.off=r.prototype.removeListener,r.prototype.addListener=r.prototype.on,r.prefixed=a,r.EventEmitter=r,t.exports=r}(os)),os.exports)),hs=2*Math.PI,ls=180/Math.PI,cs=Math.PI/180;class ds{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new ds(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 us.x=0,us.y=0,us}}const us=new ds;class ps{constructor(t=1,e=0,i=0,s=1,n=0,r=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r}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,s,n,r){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=n,this.ty=r,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 ds;const i=t.x,s=t.y;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||new ds;const i=this.a,s=this.b,n=this.c,r=this.d,o=this.tx,a=this.ty,h=1/(i*r+n*-s),l=t.x,c=t.y;return e.x=r*h*l+-n*h*c+(a*n-o*r)*h,e.y=i*h*c+-s*h*l+(-a*i+o*s)*h,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),s=this.a,n=this.c,r=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=n*e-this.d*i,this.d=n*i+this.d*e,this.tx=r*e-this.ty*i,this.ty=r*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,n=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*n,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*n,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*n+this.ty,this}appendFrom(t,e){const i=t.a,s=t.b,n=t.c,r=t.d,o=t.tx,a=t.ty,h=e.a,l=e.b,c=e.c,d=e.d;return this.a=i*h+s*c,this.b=i*l+s*d,this.c=n*h+r*c,this.d=n*l+r*d,this.tx=o*h+a*c+e.tx,this.ty=o*l+a*d+e.ty,this}setTransform(t,e,i,s,n,r,o,a,h){return this.a=Math.cos(o+h)*n,this.b=Math.sin(o+h)*n,this.c=-Math.sin(o-a)*r,this.d=Math.cos(o-a)*r,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,s=this.c,n=this.d,r=t.pivot,o=-Math.atan2(-s,n),a=Math.atan2(i,e),h=Math.abs(o+a);return h<1e-5||Math.abs(hs-h)<1e-5?(t.rotation=a,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=a),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+n*n),t.position.x=this.tx+(r.x*e+r.y*s),t.position.y=this.ty+(r.x*i+r.y*n),t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,n=this.tx,r=t*s-e*i;return this.a=s/r,this.b=-e/r,this.c=-i/r,this.d=t/r,this.tx=(i*this.ty-s*n)/r,this.ty=-(t*this.ty-e*n)/r,this}isIdentity(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d&&0===this.tx&&0===this.ty}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 ps;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 fs.identity()}static get shared(){return gs.identity()}}const gs=new ps,fs=new ps,ms=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],ys=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],xs=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],bs=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],vs=[],_s=[],ws=Math.sign;!function(){for(let t=0;t<16;t++){const e=[];vs.push(e);for(let i=0;i<16;i++){const s=ws(ms[t]*ms[i]+xs[t]*ys[i]),n=ws(ys[t]*ms[i]+bs[t]*ys[i]),r=ws(ms[t]*xs[i]+xs[t]*bs[i]),o=ws(ys[t]*xs[i]+bs[t]*bs[i]);for(let t=0;t<16;t++)if(ms[t]===s&&ys[t]===n&&xs[t]===r&&bs[t]===o){e.push(t);break}}}for(let t=0;t<16;t++){const e=new ps;e.set(ms[t],ys[t],xs[t],bs[t],0,0),_s.push(e)}}();const As={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>ms[t],uY:t=>ys[t],vX:t=>xs[t],vY:t=>bs[t],inv:t=>8&t?15&t:7&-t,add:(t,e)=>vs[t][e],sub:(t,e)=>vs[t][As.inv(e)],rotate180:t=>4^t,isVertical:t=>2==(3&t),byDirection:(t,e)=>2*Math.abs(t)<=Math.abs(e)?e>=0?As.S:As.N:2*Math.abs(e)<=Math.abs(t)?t>0?As.E:As.W:e>0?t>0?As.SE:As.SW:t>0?As.NE:As.NW,matrixAppendRotationInv:(t,e,i=0,s=0)=>{const n=_s[As.inv(e)];n.tx=i,n.ty=s,t.append(n)},transformRectCoords:(t,e,i,s)=>{const{x:n,y:r,width:o,height:a}=t,{x:h,y:l,width:c,height:d}=e;return i===As.E?(s.set(n+h,r+l,o,a),s):i===As.S?s.set(c-r-a+h,n+l,a,o):i===As.W?s.set(c-n-o+h,d-r-a+l,o,a):i===As.N?s.set(r+h,d-n-o+l,a,o):s.set(n+h,r+l,o,a)}},Cs=[new ds,new ds,new ds,new ds];class Ss{constructor(t=0,e=0,i=0,s=0){this.type="rectangle",this.x=Number(t),this.y=Number(e),this.width=Number(i),this.height=Number(s)}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 Ss(0,0,0,0)}clone(){return new Ss(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)&&t>=this.x&&t<this.x+this.width&&e>=this.y&&e<this.y+this.height}strokeContains(t,e,i,s=.5){const{width:n,height:r}=this;if(n<=0||r<=0)return!1;const o=this.x,a=this.y,h=i*(1-s),l=i-h;return t>=o-h&&t<=o+n+h&&e>=a-h&&e<=a+r+h&&!(t>o+l&&t<o+n-l&&e>a+l&&e<a+r-l)}intersects(t,e){if(!e){const e=this.x<t.x?t.x:this.x;if((this.right>t.right?t.right:this.right)<=e)return!1;const i=this.y<t.y?t.y:this.y;return(this.bottom>t.bottom?t.bottom:this.bottom)>i}const i=this.left,s=this.right,n=this.top,r=this.bottom;if(s<=i||r<=n)return!1;const o=Cs[0].set(t.left,t.top),a=Cs[1].set(t.left,t.bottom),h=Cs[2].set(t.right,t.top),l=Cs[3].set(t.right,t.bottom);if(h.x<=o.x||a.y<=o.y)return!1;const c=Math.sign(e.a*e.d-e.b*e.c);if(0===c)return!1;if(e.apply(o,o),e.apply(a,a),e.apply(h,h),e.apply(l,l),Math.max(o.x,a.x,h.x,l.x)<=i||Math.min(o.x,a.x,h.x,l.x)>=s||Math.max(o.y,a.y,h.y,l.y)<=n||Math.min(o.y,a.y,h.y,l.y)>=r)return!1;const d=c*(a.y-o.y),u=c*(o.x-a.x),p=d*i+u*n,g=d*s+u*n,f=d*i+u*r,m=d*s+u*r;if(Math.max(p,g,f,m)<=d*o.x+u*o.y||Math.min(p,g,f,m)>=d*l.x+u*l.y)return!1;const y=c*(o.y-h.y),x=c*(h.x-o.x),b=y*i+x*n,v=y*s+x*n,_=y*i+x*r,w=y*s+x*r;return!(Math.max(b,v,_,w)<=y*o.x+x*o.y||Math.min(b,v,_,w)>=y*l.x+x*l.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=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(i-e,0),this.y=s,this.height=Math.max(n-s,0),this}ceil(t=1,e=.001){const i=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=i-this.x,this.height=s-this.y,this}scale(t,e=t){return this.x*=t,this.y*=e,this.width*=t,this.height*=e,this}enlarge(t){const e=Math.min(this.x,t.x),i=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=i-e,this.y=s,this.height=n-s,this}getBounds(t){return t||(t=new Ss),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,s=t.x+t.width,n=t.y+t.height;return e>=this.x&&e<this.x+this.width&&i>=this.y&&i<this.y+this.height&&s>=this.x&&s<this.x+this.width&&n>=this.y&&n<this.y+this.height}set(t,e,i,s){return this.x=t,this.y=e,this.width=i,this.height=s,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const Is={default:-1},Ms=new Set,Ts={quiet:!1,noColor:!1},Ps=(t,e,i=3)=>{if(Ts.quiet||Ms.has(e))return;let s=(new Error).stack;"function"==typeof console.groupCollapsed&&Ts.noColor,void 0===s||(s=s.split("\n").splice(i).join("\n")),Ms.add(e)};Object.defineProperties(Ps,{quiet:{get:()=>Ts.quiet,set:t=>{Ts.quiet=t},enumerable:!0,configurable:!1},noColor:{get:()=>Ts.noColor,set:t=>{Ts.noColor=t},enumerable:!0,configurable:!1}});const Es=()=>{},Bs=Object.create(null),Rs=class t extends as{constructor(e={}){super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,e={...t.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){Ps(0,"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=function(t){const i=Bs[t];return void 0===i&&(Bs[t]=e("resource")),i}(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Rs.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let ks=Rs;const Os=class t extends as{constructor(i={}){super(),this.options=i,this.uid=e("textureSource"),this._resourceType="textureSource",this._resourceId=e("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,i={...t.defaultOptions,...i},this.label=i.label??"",this.resource=i.resource,this.autoGarbageCollect=i.autoGarbageCollect,this._resolution=i.resolution,i.width?this.pixelWidth=i.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,i.height?this.pixelHeight=i.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=i.format,this.dimension=i.dimensions,this.mipLevelCount=i.mipLevelCount,this.autoGenerateMipmaps=i.autoGenerateMipmaps,this.sampleCount=i.sampleCount,this.antialias=i.antialias,this.alphaMode=i.alphaMode,this.style=new ks(n(i)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){this.style!==t&&(this._style?.off("change",this._onStyleChange,this),this._style=t,this._style?.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(t){this._style.maxAnisotropy=t}get maxAnisotropy(){return this._style.maxAnisotropy}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=e("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,i,s){s||(s=this._resolution),t||(t=this.width),i||(i=this.height);const n=Math.round(t*s),r=Math.round(i*s);return this.width=n/s,this.height=r/s,this._resolution=s,(this.pixelWidth!==n||this.pixelHeight!==r)&&(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=r,this.emit("resize",this),this._resourceId=e("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=s(this.pixelWidth)&&s(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Os.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let Ds=Os;class Fs extends Ds{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(i=e instanceof Float32Array?"rgba32float":e instanceof Int32Array||e instanceof Uint32Array?"rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?"rgba16uint":(Int8Array,"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}}Fs.extension=qi.TextureSource;const Ls=new ps;class js{constructor(t,e){this.mapCoord=new ps,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._textureID=-1,this._updateID=0,this.clampOffset=0,this.clampMargin=void 0===e?t.width<10?0:.5:e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){this.texture!==t&&(this._texture?.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this),this.update())}multiplyUvs(t,e){void 0===e&&(e=t);const i=this.mapCoord;for(let s=0;s<t.length;s+=2){const n=t[s],r=t[s+1];e[s]=n*i.a+r*i.c+i.tx,e[s+1]=n*i.b+r*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,s=t.trim;s&&(Ls.set(i.width/s.width,0,0,i.height/s.height,-s.x/s.width,-s.y/s.height),this.mapCoord.append(Ls));const n=t.source,r=this.uClampFrame,o=this.clampMargin/n._resolution,a=this.clampOffset/n._resolution;return r[0]=(t.frame.x+o+a)/n.width,r[1]=(t.frame.y+o+a)/n.height,r[2]=(t.frame.x+t.frame.width-o+a)/n.width,r[3]=(t.frame.y+t.frame.height-o+a)/n.height,this.uClampOffset[0]=this.clampOffset/n.pixelWidth,this.uClampOffset[1]=this.clampOffset/n.pixelHeight,this.isSimple=t.frame.width===n.width&&t.frame.height===n.height&&0===t.rotate,!0}}class Gs extends as{constructor({source:t,label:i,frame:s,orig:n,trim:r,defaultAnchor:o,defaultBorders:a,rotate:h,dynamic:l}={}){if(super(),this.uid=e("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new Ss,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=i,this.source=t?.source??new Ds,this.noFrame=!s,s)this.frame.copyFrom(s);else{const{width:t,height:e}=this._source;this.frame.width=t,this.frame.height=e}this.orig=n||this.frame,this.trim=r,this.rotate=h??0,this.defaultAnchor=o,this.defaultBorders=a,this.destroyed=!1,this.dynamic=l||!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 js(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:s}=this._source,n=e.x/i,r=e.y/s,o=e.width/i,a=e.height/s;let h=this.rotate;if(h){const e=o/2,i=a/2,s=n+e,l=r+i;h=As.add(h,As.NW),t.x0=s+e*As.uX(h),t.y0=l+i*As.uY(h),h=As.add(h,2),t.x1=s+e*As.uX(h),t.y1=l+i*As.uY(h),h=As.add(h,2),t.x2=s+e*As.uX(h),t.y2=l+i*As.uY(h),h=As.add(h,2),t.x3=s+e*As.uX(h),t.y3=l+i*As.uY(h)}else t.x0=n,t.y0=r,t.x1=n+o,t.y1=r,t.x2=n+o,t.y2=r+a,t.x3=n,t.y3=r+a}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 Ps(0,"Texture.baseTexture is now Texture.source"),this._source}}Gs.EMPTY=new Gs({label:"EMPTY",source:new Ds({label:"EMPTY"})}),Gs.EMPTY.destroy=Es,Gs.WHITE=new Gs({source:new Fs({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"}),Gs.WHITE.destroy=Es;const Us=new ps;class zs{constructor(t=1/0,e=1/0,i=-1/0,s=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=Us,this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new Ss);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=Us,this}set(t,e,i,s){this.minX=t,this.minY=e,this.maxX=i,this.maxY=s}addFrame(t,e,i,s,n){n||(n=this.matrix);const r=n.a,o=n.b,a=n.c,h=n.d,l=n.tx,c=n.ty;let d=this.minX,u=this.minY,p=this.maxX,g=this.maxY,f=r*t+a*e+l,m=o*t+h*e+c;f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),f=r*i+a*e+l,m=o*i+h*e+c,f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),f=r*t+a*s+l,m=o*t+h*s+c,f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),f=r*i+a*s+l,m=o*i+h*s+c,f<d&&(d=f),m<u&&(u=m),f>p&&(p=f),m>g&&(g=m),this.minX=d,this.minY=u,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,s=this.maxX,n=this.maxY,{a:r,b:o,c:a,d:h,tx:l,ty:c}=t;let d=r*e+a*i+l,u=o*e+h*i+c;this.minX=d,this.minY=u,this.maxX=d,this.maxY=u,d=r*s+a*i+l,u=o*s+h*i+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*e+a*n+l,u=o*e+h*n+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u:this.maxY,d=r*s+a*n+l,u=o*s+h*n+c,this.minX=d<this.minX?d:this.minX,this.minY=u<this.minY?u:this.minY,this.maxX=d>this.maxX?d:this.maxX,this.maxY=u>this.maxY?u: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,s){return this.minX<t&&(this.minX=t),this.maxX>e&&(this.maxX=e),this.minY<i&&(this.minY=i),this.maxY>s&&(this.maxY=s),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 zs(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,s){let n=this.minX,r=this.minY,o=this.maxX,a=this.maxY;s||(s=this.matrix);const h=s.a,l=s.b,c=s.c,d=s.d,u=s.tx,p=s.ty;for(let s=e;s<i;s+=2){const e=t[s],i=t[s+1],g=h*e+c*i+u,f=l*e+d*i+p;n=g<n?g:n,r=f<r?f:r,o=g>o?g:o,a=f>a?f:a}this.minX=n,this.minY=r,this.maxX=o,this.maxY=a}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}]`}copyFrom(t){return this.minX=t.minX,this.minY=t.minY,this.maxX=t.maxX,this.maxY=t.maxY,this}}var Ns={grad:.9,turn:360,rad:360/(2*Math.PI)},Vs=function(t){return"string"==typeof t?t.length>0:"number"==typeof t},Hs=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=Math.pow(10,e)),Math.round(i*t)/i+0},Ws=function(t,e,i){return void 0===e&&(e=0),void 0===i&&(i=1),t>i?i:t>e?t:e},Js=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Zs=function(t){return{r:Ws(t.r,0,255),g:Ws(t.g,0,255),b:Ws(t.b,0,255),a:Ws(t.a)}},Xs=function(t){return{r:Hs(t.r),g:Hs(t.g),b:Hs(t.b),a:Hs(t.a,3)}},Ys=/^#([0-9a-f]{3,8})$/i,Ks=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Qs=function(t){var e=t.r,i=t.g,s=t.b,n=t.a,r=Math.max(e,i,s),o=r-Math.min(e,i,s),a=o?r===e?(i-s)/o:r===i?2+(s-e)/o:4+(e-i)/o:0;return{h:60*(a<0?a+6:a),s:r?o/r*100:0,v:r/255*100,a:n}},qs=function(t){var e=t.h,i=t.s,s=t.v,n=t.a;e=e/360*6,i/=100,s/=100;var r=Math.floor(e),o=s*(1-i),a=s*(1-(e-r)*i),h=s*(1-(1-e+r)*i),l=r%6;return{r:255*[s,a,o,o,h,s][l],g:255*[h,s,s,a,o,o][l],b:255*[o,o,h,s,s,a][l],a:n}},$s=function(t){return{h:Js(t.h),s:Ws(t.s,0,100),l:Ws(t.l,0,100),a:Ws(t.a)}},tn=function(t){return{h:Hs(t.h),s:Hs(t.s),l:Hs(t.l),a:Hs(t.a,3)}},en=function(t){return qs((i=(e=t).s,{h:e.h,s:(i*=((s=e.l)<50?s:100-s)/100)>0?2*i/(s+i)*100:0,v:s+i,a:e.a}));var e,i,s},sn=function(t){return{h:(e=Qs(t)).h,s:(n=(200-(i=e.s))*(s=e.v)/100)>0&&n<200?i*s/100/(n<=100?n:200-n)*100:0,l:n/2,a:e.a};var e,i,s,n},nn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hn={string:[[function(t){var e=Ys.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:4===t.length?Hs(parseInt(t[3]+t[3],16)/255,2):1}:6===t.length||8===t.length?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:8===t.length?Hs(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=on.exec(t)||an.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Zs({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:void 0===e[7]?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=nn.exec(t)||rn.exec(t);if(!e)return null;var i,s,n=$s({h:(i=e[1],s=e[2],void 0===s&&(s="deg"),Number(i)*(Ns[s]||1)),s:Number(e[3]),l:Number(e[4]),a:void 0===e[5]?1:Number(e[5])/(e[6]?100:1)});return en(n)},"hsl"]],object:[[function(t){var e=t.r,i=t.g,s=t.b,n=t.a,r=void 0===n?1:n;return Vs(e)&&Vs(i)&&Vs(s)?Zs({r:Number(e),g:Number(i),b:Number(s),a:Number(r)}):null},"rgb"],[function(t){var e=t.h,i=t.s,s=t.l,n=t.a,r=void 0===n?1:n;if(!Vs(e)||!Vs(i)||!Vs(s))return null;var o=$s({h:Number(e),s:Number(i),l:Number(s),a:Number(r)});return en(o)},"hsl"],[function(t){var e=t.h,i=t.s,s=t.v,n=t.a,r=void 0===n?1:n;if(!Vs(e)||!Vs(i)||!Vs(s))return null;var o,a=(o={h:Number(e),s:Number(i),v:Number(s),a:Number(r)},{h:Js(o.h),s:Ws(o.s,0,100),v:Ws(o.v,0,100),a:Ws(o.a)});return qs(a)},"hsv"]]},ln=function(t,e){for(var i=0;i<e.length;i++){var s=e[i][0](t);if(s)return[s,e[i][1]]}return[null,void 0]},cn=function(t,e){var i=sn(t);return{h:i.h,s:Ws(i.s+100*e,0,100),l:i.l,a:i.a}},dn=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},un=function(t,e){var i=sn(t);return{h:i.h,s:i.s,l:Ws(i.l+100*e,0,100),a:i.a}},pn=function(){function t(t){this.parsed=function(t){return"string"==typeof t?ln(t.trim(),hn.string):"object"==typeof t&&null!==t?ln(t,hn.object):[null,void 0]}(t)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return null!==this.parsed},t.prototype.brightness=function(){return Hs(dn(this.rgba),2)},t.prototype.isDark=function(){return dn(this.rgba)<.5},t.prototype.isLight=function(){return dn(this.rgba)>=.5},t.prototype.toHex=function(){return e=(t=Xs(this.rgba)).r,i=t.g,s=t.b,r=(n=t.a)<1?Ks(Hs(255*n)):"","#"+Ks(e)+Ks(i)+Ks(s)+r;var t,e,i,s,n,r},t.prototype.toRgb=function(){return Xs(this.rgba)},t.prototype.toRgbString=function(){return e=(t=Xs(this.rgba)).r,i=t.g,s=t.b,(n=t.a)<1?"rgba("+e+", "+i+", "+s+", "+n+")":"rgb("+e+", "+i+", "+s+")";var t,e,i,s,n},t.prototype.toHsl=function(){return tn(sn(this.rgba))},t.prototype.toHslString=function(){return e=(t=tn(sn(this.rgba))).h,i=t.s,s=t.l,(n=t.a)<1?"hsla("+e+", "+i+"%, "+s+"%, "+n+")":"hsl("+e+", "+i+"%, "+s+"%)";var t,e,i,s,n},t.prototype.toHsv=function(){return t=Qs(this.rgba),{h:Hs(t.h),s:Hs(t.s),v:Hs(t.v),a:Hs(t.a,3)};var t},t.prototype.invert=function(){return gn({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},t.prototype.saturate=function(t){return void 0===t&&(t=.1),gn(cn(this.rgba,t))},t.prototype.desaturate=function(t){return void 0===t&&(t=.1),gn(cn(this.rgba,-t))},t.prototype.grayscale=function(){return gn(cn(this.rgba,-1))},t.prototype.lighten=function(t){return void 0===t&&(t=.1),gn(un(this.rgba,t))},t.prototype.darken=function(t){return void 0===t&&(t=.1),gn(un(this.rgba,-t))},t.prototype.rotate=function(t){return void 0===t&&(t=15),this.hue(this.hue()+t)},t.prototype.alpha=function(t){return"number"==typeof t?gn({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Hs(this.rgba.a,3);var e},t.prototype.hue=function(t){var e=sn(this.rgba);return"number"==typeof t?gn({h:t,s:e.s,l:e.l,a:e.a}):Hs(e.h)},t.prototype.isEqual=function(t){return this.toHex()===gn(t).toHex()},t}(),gn=function(t){return t instanceof pn?t:new pn(t)},fn=[];[function(t,e){var i={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"},s={};for(var n in i)s[i[n]]=n;var r={};t.prototype.toName=function(e){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var n,o,a=s[this.toHex()];if(a)return a;if(null==e?void 0:e.closest){var h=this.toRgb(),l=1/0,c="black";if(!r.length)for(var d in i)r[d]=new t(i[d]).toRgb();for(var u in i){var p=(n=h,o=r[u],Math.pow(n.r-o.r,2)+Math.pow(n.g-o.g,2)+Math.pow(n.b-o.b,2));p<l&&(l=p,c=u)}return c}},e.string.push([function(e){var s=e.toLowerCase(),n="transparent"===s?"#0000":i[s];return n?new t(n).toRgb():null},"name"])}].forEach(function(t){fn.indexOf(t)<0&&(t(pn,hn),fn.push(t))});const mn=class t{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(e){if(e instanceof t)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(null===e)throw new Error("Cannot set Color#value to null");null!==this._value&&this._isSourceEqual(this._value,e)||(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return"string"==typeof t||"number"==typeof t||t instanceof Number||null===t?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):"object"==typeof t&&null!==t?{...t}:t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if("number"===i||"string"===i||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length===e.length&&t.every((t,i)=>t===e[i]);if(null!==t&&null!==e){const i=Object.keys(t),s=Object.keys(e);return i.length===s.length&&i.every(i=>t[i]===e[i])}return t===e}toRgba(){const[t,e,i,s]=this._components;return{r:t,g:e,b:i,a:s}}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,s]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(255*e),t[1]=Math.round(255*i),t[2]=Math.round(255*s),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,s,n]=this._components;return t[0]=e,t[1]=i,t[2]=s,t[3]=n,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,s]=this._components;return t[0]=e,t[1]=i,t[2]=s,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)+(65280&t)+((255&t)<<16)}multiply(e){const[i,s,n,r]=t._temp.setValue(e)._components;return this._components[0]*=i,this._components[1]*=s,this._components[2]*=n,this._components[3]*=r,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(1===t)return(255<<24)+this._int;if(0===t)return e?0:this._int;let i=this._int>>16&255,s=this._int>>8&255,n=255&this._int;return e&&(i=i*t+.5|0,s=s*t+.5|0,n=n*t+.5|0),(255*t<<24)+(i<<16)+(s<<8)+n}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(255*this._components[3]).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this}_normalize(e){let i,s,n,r;if(("number"==typeof e||e instanceof Number)&&e>=0&&e<=16777215)i=(e>>16&255)/255,s=(e>>8&255)/255,n=(255&e)/255,r=1;else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[i,s,n,r=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[i,s,n,r=255]=e,i/=255,s/=255,n/=255,r/=255;else if("string"==typeof e||"object"==typeof e){if("string"==typeof e){const i=t.HEX_PATTERN.exec(e);i&&(e=`#${i[2]}`)}const o=gn(e);o.isValid()&&(({r:i,g:s,b:n,a:r}=o.rgba),i/=255,s/=255,n/=255)}if(void 0===i)throw new Error(`Unable to convert color ${e}`);this._components[0]=i,this._components[1]=s,this._components[2]=n,this._components[3]=r,this._refreshInt()}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(255*t<<16)+(255*e<<8)+(255*i|0)}_clamp(t,e=0,i=1){return"number"==typeof t?Math.min(Math.max(t,e),i):(t.forEach((s,n)=>{t[n]=Math.min(Math.max(s,e),i)}),t)}static isColorLike(e){return"number"==typeof e||"string"==typeof e||e instanceof Number||e instanceof t||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||void 0!==e.r&&void 0!==e.g&&void 0!==e.b||void 0!==e.r&&void 0!==e.g&&void 0!==e.b&&void 0!==e.a||void 0!==e.h&&void 0!==e.s&&void 0!==e.l||void 0!==e.h&&void 0!==e.s&&void 0!==e.l&&void 0!==e.a||void 0!==e.h&&void 0!==e.s&&void 0!==e.v||void 0!==e.h&&void 0!==e.s&&void 0!==e.v&&void 0!==e.a}};mn.shared=new mn,mn._temp=new mn,mn.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let yn=mn,xn=0;const bn={_registeredResources:new Set,register(t){this._registeredResources.add(t)},unregister(t){this._registeredResources.delete(t)},release(){this._registeredResources.forEach(t=>t.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(t){return this._registeredResources.has(t)},reset(){this._registeredResources.clear()}};class vn{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){let e;return e=this._index>0?this._pool[--this._index]:new this._classType,e.init?.(t),e}return(t){t.reset?.(),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t<this._index;t++)this._pool[t].destroy();this._pool.length=0,this._count=0,this._index=0}}const _n=new class{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 vn(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}clear(){this._poolsByClass.forEach(t=>t.clear()),this._poolsByClass.clear()}};bn.register(_n);const wn={get isCachedAsTexture(){return!!this.renderGroup?.isCachedAsTexture},cacheAsTexture(t){"boolean"==typeof t&&!1===t?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(!0===t?{}:t))},updateCacheTexture(){this.renderGroup?.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){Ps(0,"cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}},An={allowChildren:!0,removeChildren(t=0,e){const i=e??this.children.length,s=i-t,n=[];if(s>0&&s<=i){for(let e=i-1;e>=t;e--){const t=this.children[e];t&&(n.push(t),t.parent=null)}a(this.children,t,i);const e=this.renderGroup||this.parentRenderGroup;e&&e.removeChildren(n);for(let t=0;t<n.length;++t){const e=n[t];e.parentRenderLayer?.detach(e),this.emit("childRemoved",e,this,t),n[t].emit("removed",this)}return n.length>0&&this._didViewChangeTick++,n}if(0===s&&0===this.children.length)return n;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(-1===e)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||Ps(0,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:i}=this;if(e<0||e>i.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${i.length}`);if(t.parent){const i=t.parent.children.indexOf(t);if(t.parent===this&&i===e)return t;-1!==i&&t.parent.children.splice(i,1)}e===i.length?i.push(t):i.splice(e,0,t),t.parent=this,t.didChange=!0,t._updateFlags=15;const s=this.renderGroup||this.parentRenderGroup;return s&&s.addChild(t),this.sortableChildren&&(this.sortDirty=!0),this.emit("childAdded",t,this,e),t.emit("added",this),t},swapChildren(t,e){if(t===e)return;const i=this.getChildIndex(t),s=this.getChildIndex(e);this.children[i]=e,this.children[s]=t;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){this.parent?.removeChild(this)},reparentChild(...t){return 1===t.length?this.reparentChildAt(t[0],this.children.length):(t.forEach(t=>this.reparentChildAt(t,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const i=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const s=this.worldTransform.clone();return s.invert(),i.prepend(s),t.setFromMatrix(i),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},Cn={collectRenderables(t,e,i){this.parentRenderLayer&&this.parentRenderLayer!==i||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,i):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,i))},collectRenderablesSimple(t,e,i){const s=this.children,n=s.length;for(let r=0;r<n;r++)s[r].collectRenderables(t,e,i)},collectRenderablesWithEffects(t,e,i){const{renderPipes:s}=e;for(let e=0;e<this.effects.length;e++){const i=this.effects[e];s[i.pipe].push(i,this,t)}this.collectRenderablesSimple(t,e,i);for(let e=this.effects.length-1;e>=0;e--){const i=this.effects[e];s[i.pipe].pop(i,this,t)}}};class Sn{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}}const In=new class{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 _n.get(i.maskClass,t)}return t}returnMaskEffect(t){_n.return(t)}};es.handleByList(qi.MaskEffect,In._effectClasses);const Mn={_maskEffect:null,_maskOptions:{inverse:!1},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){-1===this.effects.indexOf(t)&&(this.effects.push(t),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);-1!==e&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;e?.mask!==t&&(e&&(this.removeEffect(e),In.returnMaskEffect(e),this._maskEffect=null),null!=t&&(this._maskEffect=In.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){return this._maskEffect?.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new Sn),i=t?.length>0,s=i!==e.filters?.length>0;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),s&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){return this._filterEffect?.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new Sn),this._filterEffect.filterArea=t},get filterArea(){return this._filterEffect?.filterArea}},Tn={label:null,get name(){return Ps(0,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){Ps(0,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const i=this.children;for(let e=0;e<i.length;e++){const s=i[e];if(s.label===t||t instanceof RegExp&&t.test(s.label))return s}if(e)for(let e=0;e<i.length;e++){const s=i[e].getChildByLabel(t,!0);if(s)return s}return null},getChildrenByLabel(t,e=!1,i=[]){const s=this.children;for(let e=0;e<s.length;e++){const n=s[e];(n.label===t||t instanceof RegExp&&t.test(n.label))&&i.push(n)}if(e)for(let e=0;e<s.length;e++)s[e].getChildrenByLabel(t,!0,i);return i}},Pn=_n.getPool(ps),En=_n.getPool(zs),Bn=new ps,Rn={getFastGlobalBounds(t,e){e||(e=new zs),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const i=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(i.worldTransform),e},_getGlobalBoundsRecursive(t,e,i){let s=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==i)return;if(7!==this.localDisplayStatus||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(s=En.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const t=this.bounds;s.addFrame(t.minX,t.minY,t.maxX,t.maxY,this.groupTransform)}const e=this.children;for(let n=0;n<e.length;n++)e[n]._getGlobalBoundsRecursive(t,s,i)}if(n){let t=!1;const i=this.renderGroup||this.parentRenderGroup;for(let e=0;e<this.effects.length;e++)this.effects[e].addBounds&&(t||(t=!0,s.applyMatrix(i.worldTransform)),this.effects[e].addBounds(s,!0));t&&s.applyMatrix(i.worldTransform.copyTo(Bn).invert()),e.addBounds(s),En.return(s)}else this.renderGroup&&(e.addBounds(s,this.relativeGroupTransform),En.return(s))}},kn=16777215,On={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,i=this.parent;for(;i;)e*=i.alpha,i=i.parent;return e},getGlobalTransform(t=new ps,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const i=c(this,Pn.get().identity());return t.appendFrom(this.localTransform,i),Pn.return(i),t},getGlobalTint(t){if(t)return this.renderGroup?p(this.renderGroup.worldColor):this.parentRenderGroup?p(u(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,i=this.parent;for(;i;)e=u(e,i.localColor),i=i.parent;return p(e)}},Dn=new ps,Fn={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const i=Math.sign(this.scale.x)||1;this.scale.x=0!==e?t/e*i:i},_setHeight(t,e){const i=Math.sign(this.scale.y)||1;this.scale.y=0!==e?t/e*i:i},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new zs});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),m(this,t),t.didChange&&g(this,t.localBounds,Dn),t.localBounds},getBounds(t,e){return h(this,t,e||new zs)}},Ln={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t)return this._onRender&&e?.removeOnRender(this),void(this._onRender=null);this._onRender||e?.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},jn={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,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(y))}},Gn={getGlobalPosition(t=new ds,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,i=!1){const s=this.getGlobalTransform(Pn.get(),i);return e=s.apply(t,e),Pn.return(s),e},toLocal(t,e,i,s){e&&(t=e.toGlobal(t,i,s));const n=this.getGlobalTransform(Pn.get(),s);return i=n.applyInverse(t,i),Pn.return(n),i}};class Un{constructor(){this.uid=e("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(t){this.instructions[this.instructionSize++]=t}log(){this.instructions.length=this.instructionSize}}let zn=0;const Nn=new class{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new ks(this.textureOptions)}createTexture(t,e,i){const s=new Ds({...this.textureOptions,width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1});return new Gs({source:s,label:"texturePool_"+zn++})}getOptimalTexture(t,e,s=1,n){let r=Math.ceil(t*s-1e-6),o=Math.ceil(e*s-1e-6);r=i(r),o=i(o);const a=(r<<17)+(o<<1)+(n?1:0);this._texturePool[a]||(this._texturePool[a]=[]);let h=this._texturePool[a].pop();return h||(h=this.createTexture(r,o,n)),h.source._resolution=s,h.source.width=r/s,h.source.height=o/s,h.source.pixelWidth=r,h.source.pixelHeight=o,h.frame.x=0,h.frame.y=0,h.frame.width=t,h.frame.height=e,h.updateUvs(),this._poolKeyHash[h.uid]=a,h}getSameSizeTexture(t,e=!1){const i=t.source;return this.getOptimalTexture(t.width,t.height,i._resolution,e)}returnTexture(t,e=!1){const i=this._poolKeyHash[t.uid];e&&(t.source.style=this.textureStyle),this._texturePool[i].push(t)}clear(t){if(t=!1!==t)for(const t in this._texturePool){const e=this._texturePool[t];if(e)for(let t=0;t<e.length;t++)e[t].destroy(!0)}this._texturePool={}}};bn.register(Nn);class Vn{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new ps,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new Un,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(t){this.root=t,t._onRender&&this.addOnRender(t),t.didChange=!0;const e=t.children;for(let t=0;t<e.length;t++){const i=e[t];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(t={}){this.textureOptions=t,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(Nn.returnTexture(this.texture,!0),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const t=this._parentCacheAsTextureRenderGroup;t&&!t.textureNeedsUpdate&&t.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const t in this.childrenToUpdate){const e=this.childrenToUpdate[t];e.list.fill(null),e.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}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)return void this.addRenderGroupChild(t.renderGroup);t._onRender&&this.addOnRender(t);const e=t.children;for(let t=0;t<e.length;t++)this.addChild(e[t])}removeChild(t){if(this.structureDidChange=!0,t._onRender&&(t.renderGroup||this.removeOnRender(t)),t.parentRenderGroup=null,t.renderGroup)return void this._removeRenderGroupChild(t.renderGroup);const e=t.children;for(let t=0;t<e.length;t++)this.removeChild(e[t])}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||(this.instructionSet.renderPipes[t.renderPipeId].updateRenderable(t),t.didViewUpdate=!1)}onChildViewUpdate(t){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=t}get isRenderable(){return 7===this.root.localDisplayStatus&&this.worldAlpha>0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;e<this._onRenderContainers.length;e++)this._onRenderContainers[e]._onRender(t)}destroy(){this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,this.instructionSet=null}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 t=0;t<i.length;t++)this._getChildren(i[t],e);return e}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return 1&this._matrixDirty?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new ps),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return 2&this._matrixDirty?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new ps),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(4&this._matrixDirty))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const t=this._parentCacheAsTextureRenderGroup;return t?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new ps),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(t.inverseWorldTransform).translate(-t._textureBounds.x,-t._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}const Hn=new ns(null),Wn=new ns(null),Jn=new ns(null,1,1),Zn=new ns(null);class Xn extends as{constructor(t={}){super(),this.uid=e("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.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new ps,this.relativeGroupTransform=new ps,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new ns(this,0,0),this._scale=Jn,this._pivot=Wn,this._origin=Zn,this._skew=Hn,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._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],function(t,e,i={}){for(const s in e)i[s]||void 0===e[s]||(t[s]=e[s])}(this,t,{children:!0,parent:!0,effects:!0}),t.children?.forEach(t=>this.addChild(t)),t.parent?.addChild(this)}static mixin(t){Ps(0,"Container.mixin is deprecated, please use extensions.mixin instead."),es.mixin(Xn,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=4095&t}get _didChangeId(){return 4095&this._didContainerChangeTick|(4095&this._didViewChangeTick)<<12}addChild(...t){if(this.allowChildren||Ps(0,"addChild: Only Containers will be allowed to add children in v8.0.0"),t.length>1){for(let e=0;e<t.length;e++)this.addChild(t[e]);return t[0]}const e=t[0],i=this.renderGroup||this.parentRenderGroup;return e.parent===this?(this.children.splice(this.children.indexOf(e),1),this.children.push(e),i&&(i.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._updateFlags=15,i&&i.addChild(e),this.emit("childAdded",e,this,this.children.length-1),e.emit("added",this),this._didViewChangeTick++,0!==e._zIndex&&e.depthOfChildModified(),e)}removeChild(...t){if(t.length>1){for(let e=0;e<t.length;e++)this.removeChild(t[e]);return t[0]}const e=t[0],i=this.children.indexOf(e);return i>-1&&(this._didViewChangeTick++,this.children.splice(i,1),this.renderGroup?this.renderGroup.removeChild(e):this.parentRenderGroup&&this.parentRenderGroup.removeChild(e),e.parentRenderLayer&&e.parentRenderLayer.detach(e),e.parent=null,this.emit("childRemoved",e,this,i),e.emit("removed",this)),e}_onUpdate(t){t&&t===this._skew&&this._updateSkew(),this._didContainerChangeTick++,this.didChange||(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(t){!!this.renderGroup!==t&&(t?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),this.renderGroup=_n.get(Vn,this),this.groupTransform=ps.IDENTITY,t?.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t?.removeChild(this),_n.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t?.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&0===this.effects.length}get worldTransform(){return this._worldTransform||(this._worldTransform=new ps),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*ls}set angle(t){this.rotation=t*cs}get pivot(){return this._pivot===Wn&&(this._pivot=new ns(this,0,0)),this._pivot}set pivot(t){this._pivot===Wn&&(this._pivot=new ns(this,0,0),this._origin!==Zn&&o()),"number"==typeof t?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===Hn&&(this._skew=new ns(this,0,0)),this._skew}set skew(t){this._skew===Hn&&(this._skew=new ns(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Jn&&(this._scale=new ns(this,1,1)),this._scale}set scale(t){this._scale===Jn&&(this._scale=new ns(this,0,0)),"string"==typeof t&&(t=parseFloat(t)),"number"==typeof t?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Zn&&(this._origin=new ns(this,0,0)),this._origin}set origin(t){this._origin===Zn&&(this._origin=new ns(this,0,0),this._pivot!==Wn&&o()),"number"==typeof t?this._origin.set(t):this._origin.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();"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,i.width),void 0!==e&&this._setHeight(e,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("number"==typeof t.x?t.x:this.position.x,"number"==typeof t.y?t.y:this.position.y),this.scale.set("number"==typeof t.scaleX?t.scaleX||1:this.scale.x,"number"==typeof t.scaleY?t.scaleY||1:this.scale.y),this.rotation="number"==typeof t.rotation?t.rotation:this.rotation,this.skew.set("number"==typeof t.skewX?t.skewX:this.skew.x,"number"==typeof t.skewY?t.skewY:this.skew.y),this.pivot.set("number"==typeof t.pivotX?t.pivotX:this.pivot.x,"number"==typeof t.pivotY?t.pivotY:this.pivot.y),this.origin.set("number"==typeof t.originX?t.originX:this.origin.x,"number"==typeof t.originY?t.originY:this.origin.y),this}setFromMatrix(t){t.decompose(this)}updateLocalTransform(){const t=this._didContainerChangeTick;if(this._didLocalTransformChangeId===t)return;this._didLocalTransformChangeId=t;const e=this.localTransform,i=this._scale,s=this._pivot,n=this._origin,r=this._position,o=i._x,a=i._y,h=s._x,l=s._y,c=-n._x,d=-n._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*a,e.d=this._sy*a,e.tx=r._x-(h*e.a+l*e.c)+(c*e.a+d*e.c)-c,e.ty=r._y-(h*e.b+l*e.d)+(c*e.b+d*e.d)-d}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=1,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=yn.shared.setValue(t??16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=1,this._onUpdate())}get tint(){return p(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=2,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(2&this.localDisplayStatus)}set visible(t){const e=t?2:0;(2&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate())}get culled(){return!(4&this.localDisplayStatus)}set culled(t){const e=t?0:4;(4&this.localDisplayStatus)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(1&this.localDisplayStatus)}set renderable(t){const e=t?1:0;(1&this.localDisplayStatus)!==e&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return 7===this.localDisplayStatus&&this.groupAlpha>0}destroy(t=!1){if(this.destroyed)return;let e;if(this.destroyed=!0,this.children.length&&(e=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),("boolean"==typeof t?t:t?.children)&&e)for(let i=0;i<e.length;++i)e[i].destroy(t);this.renderGroup?.destroy(),this.renderGroup=null}}es.mixin(Xn,An,Rn,Gn,Ln,Fn,Mn,Tn,jn,{cullArea:null,cullable:!1,cullableChildren:!0},wn,On,Cn);class Yn extends Xn{constructor(t){super(t),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this._bounds=new zs(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(t){this._roundPixels=t?1:0}containsPoint(t){const e=this.bounds,{x:i,y:s}=t;return i>=e.minX&&i<=e.maxX&&s>=e.minY&&s<=e.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const t=this.renderGroup||this.parentRenderGroup;t&&t.onChildViewUpdate(this)}destroy(t){super.destroy(t),this._bounds=null;for(const t in this._gpuData)this._gpuData[t].destroy?.();this._gpuData=null}collectRenderablesSimple(t,e,i){const{renderPipes:s}=e;s.blendMode.pushBlendMode(this,this.groupBlendMode,t),s[this.renderPipeId].addRenderable(this,t),this.didViewUpdate=!1;const n=this.children,r=n.length;for(let s=0;s<r;s++)n[s].collectRenderables(t,e,i);s.blendMode.popBlendMode(t)}}class Kn extends Yn{constructor(t=Gs.EMPTY){t instanceof Gs&&(t={texture:t});const{texture:e=Gs.EMPTY,anchor:i,roundPixels:s,width:n,height:r,...o}=t;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new ns({_onUpdate:()=>{this.onViewUpdate()}}),i?this.anchor=i:e.defaultAnchor&&(this.anchor=e.defaultAnchor),this.texture=e,this.allowChildren=!1,this.roundPixels=s??!1,void 0!==n&&(this.width=n),void 0!==r&&(this.height=r)}static from(t,e=!1){return new Kn(t instanceof Gs?t:Gs.from(t,e))}set texture(t){t||(t=Gs.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._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return r(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return Ps(0,"Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:s,height:n}=e.orig;i.minX=-t._x*s,i.maxX=i.minX+s,i.minY=-t._y*n,i.maxY=i.minY+n}destroy(t=!1){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null,this._gpuData=null}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(t){this._setWidth(t,this._texture.orig.width),this._width=t}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(t){this._setHeight(t,this._texture.orig.height),this._height=t}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){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this._texture.orig.width),void 0!==e&&this._setHeight(e,this._texture.orig.height)}}const Qn=new zs;class qn{constructor(t){this.priority=0,this.inverse=!1,this.pipe="alphaMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof Kn),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){this.inverse||x(this.mask,t,e)}addLocalBounds(t,e){b(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Kn}}qn.extension=qi.MaskEffect;class $n{constructor(t){this.priority=0,this.pipe="colorMask",t?.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return"number"==typeof t}}$n.extension=qi.MaskEffect;class tr{constructor(t){this.priority=0,this.pipe="stencilMask",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){x(this.mask,t,e)}addLocalBounds(t,e){b(this.mask,t,e)}containsPoint(t,e){return e(this.mask,t)}destroy(){this.reset()}static test(t){return t instanceof Xn}}tr.extension=qi.MaskEffect;let er={createCanvas:(t,e)=>{const i=document.createElement("canvas");return i.width=t,i.height=e,i},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>(new DOMParser).parseFromString(t,"text/xml")};const ir={get:()=>er,set(t){er=t}};class sr extends Ds{constructor(t){t.resource||(t.resource=ir.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,this.resizeCanvas(),this.transparent=!!t.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(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 s=super.resize(t,e,i);return s&&this.resizeCanvas(),s}static test(t){return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&t instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}sr.extension=qi.TextureSource;class nr extends Ds{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||"undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}nr.extension=qi.TextureSource;var rr=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(rr||{});class or{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,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 ar=class t{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 or(null,null,1/0),this.deltaMS=1/t.targetFPMS,this.elapsedMS=1/t.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&null===this._requestId&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){null===this._requestId&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){null!==this._requestId&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=rr.NORMAL){return this._addListener(new or(t,e,i))}addOnce(t,e,i=rr.NORMAL){return this._addListener(new or(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(e){for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}else t.connect(i);return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i=i.match(t,e)?i.destroy():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(e=performance.now()){let i;if(e>this.lastTime){if(i=this.elapsedMS=e-this.lastTime,i>this._maxElapsedMS&&(i=this._maxElapsedMS),i*=this.speed,this._minElapsedMS){const t=e-this._lastFrame|0;if(t<this._minElapsedMS)return;this._lastFrame=e-t%this._minElapsedMS}this.deltaMS=i,this.deltaTime=this.deltaMS*t.targetFPMS;const s=this._head;let n=s.next;for(;n;)n=n.emit(this);s.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const i=Math.min(this.maxFPS,e),s=Math.min(Math.max(0,i)/1e3,t.targetFPMS);this._maxElapsedMS=1/s}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(0===t)this._minElapsedMS=0;else{const e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!t._shared){const e=t._shared=new t;e.autoStart=!0,e._protected=!0}return t._shared}static get system(){if(!t._system){const e=t._system=new t;e.autoStart=!0,e._protected=!0}return t._system}};ar.targetFPMS=.06;let hr,lr=ar;const cr=class t extends Ds{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...t.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=!1!==e.autoPlay,this.alphaMode=e.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),!1!==e.autoLoad&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=lr.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 _(),this._load=new Promise((i,s)=>{this.isValid?i(this):(this._resolve=i,this._reject=s,void 0!==e.preloadTimeoutMs&&(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&&(lr.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),null===this._videoFrameRequestCallbackHandle&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(lr.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(null!==this._videoFrameRequestCallbackHandle&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(lr.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};cr.extension=qi.TextureSource,cr.defaultOptions={...Ds.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1},cr.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let dr=cr;const ur=(t,e,i=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(t=>"string"==typeof t||i?e(t):t):t),pr=new class{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(t){return this._cache.has(t)}get(t){const e=this._cache.get(t);return e||o(),e}set(t,e){const i=ur(t);let s;for(let t=0;t<this.parsers.length;t++){const n=this.parsers[t];if(n.test(e)){s=n.getCacheableAssets(i,e);break}}const n=new Map(Object.entries(s||{}));s||i.forEach(t=>{n.set(t,e)});const r=[...n.keys()],a={cacheKeys:r,keys:i};i.forEach(t=>{this._cacheMap.set(t,a)}),r.forEach(t=>{const i=s?s[t]:e;this._cache.has(t)&&this._cache.get(t)!==i&&o(),this._cache.set(t,n.get(t))})}remove(t){if(!this._cacheMap.has(t))return void o();const e=this._cacheMap.get(t);e.cacheKeys.forEach(t=>{this._cache.delete(t)}),e.keys.forEach(t=>{this._cacheMap.delete(t)})}get parsers(){return this._parsers}},gr=[];es.handleByList(qi.TextureSource,gr),Gs.from=function(t,e=!1){return"string"==typeof t?pr.get(t):t instanceof Ds?new Gs({source:t}):function(t={},e=!1){const i=t&&t.resource,s=i?t.resource:t,n=i?t:{resource:t};if(!e&&pr.has(s))return pr.get(s);const r=new Gs({source:w(n)});return r.on("destroy",()=>{pr.has(s)&&pr.remove(s)}),e||pr.set(s,r),r}(t,e)},Ds.from=w,es.add(qn,$n,tr,dr,nr,sr,Fs);var fr=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(fr||{});const mr={toPosix:t=>t.replace(new RegExp("\\".replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),"/"),isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl:t=>/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t),isBlobUrl:t=>t.startsWith("blob:"),hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){A(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const i=/^[^/:]+:\/{0,2}/.exec(t);return i?i[0]:""},toAbsolute(t,e,i){if(A(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const s=C(this.toPosix(e??ir.get().getBaseUrl())),n=C(this.toPosix(i??this.rootname(s)));return(t=this.toPosix(t)).startsWith("/")?mr.join(n,t.slice(1)):this.isAbsolute(t)?t:this.join(s,t)},normalize(t){if(A(t),0===t.length)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;let e="";const i=(t=this.toPosix(t)).startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const s=t.endsWith("/");return(t=function(t){let e="",i=0,s=-1,n=0,r=-1;for(let o=0;o<=t.length;++o){if(o<t.length)r=t.charCodeAt(o);else{if(47===r)break;r=47}if(47===r){if(s===o-1||1===n);else if(s!==o-1&&2===n){if(e.length<2||2!==i||46!==e.charCodeAt(e.length-1)||46!==e.charCodeAt(e.length-2))if(e.length>2){const t=e.lastIndexOf("/");if(t!==e.length-1){-1===t?(e="",i=0):(e=e.slice(0,t),i=e.length-1-e.lastIndexOf("/")),s=o,n=0;continue}}else if(2===e.length||1===e.length){e="",i=0,s=o,n=0;continue}}else e.length>0?e+=`/${t.slice(s+1,o)}`:e=t.slice(s+1,o),i=o-s-1;s=o,n=0}else 46===r&&-1!==n?++n:n=-1}return e}(t)).length>0&&s&&(t+="/"),i?`/${t}`:e+t},isAbsolute(t){return A(t),t=this.toPosix(t),!!this.hasProtocol(t)||t.startsWith("/")},join(...t){if(0===t.length)return".";let e;for(let i=0;i<t.length;++i){const s=t[i];if(A(s),s.length>0)if(void 0===e)e=s;else{const n=t[i-1]??"";this.joinExtensions.includes(this.extname(n).toLowerCase())?e+=`/../${s}`:e+=`/${s}`}}return void 0===e?".":this.normalize(e)},dirname(t){if(A(t),0===t.length)return".";let e=(t=this.toPosix(t)).charCodeAt(0);const i=47===e;let s=-1,n=!0;const r=this.getProtocol(t),o=t;for(let i=(t=t.slice(r.length)).length-1;i>=1;--i)if(e=t.charCodeAt(i),47===e){if(!n){s=i;break}}else n=!1;return-1===s?i?"/":this.isUrl(o)?r+t:r:i&&1===s?"//":r+t.slice(0,s)},rootname(t){A(t);let e="";if(e=(t=this.toPosix(t)).startsWith("/")?"/":this.getProtocol(t),this.isUrl(t)){const i=t.indexOf("/",e.length);e=-1!==i?t.slice(0,i):t,e.endsWith("/")||(e+="/")}return e},basename(t,e){A(t),e&&A(e),t=C(this.toPosix(t));let i,s=0,n=-1,r=!0;if(void 0!==e&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let o=e.length-1,a=-1;for(i=t.length-1;i>=0;--i){const h=t.charCodeAt(i);if(47===h){if(!r){s=i+1;break}}else-1===a&&(r=!1,a=i+1),o>=0&&(h===e.charCodeAt(o)?-1===--o&&(n=i):(o=-1,n=a))}return s===n?n=a:-1===n&&(n=t.length),t.slice(s,n)}for(i=t.length-1;i>=0;--i)if(47===t.charCodeAt(i)){if(!r){s=i+1;break}}else-1===n&&(r=!1,n=i+1);return-1===n?"":t.slice(s,n)},extname(t){A(t);let e=-1,i=0,s=-1,n=!0,r=0;for(let o=(t=C(this.toPosix(t))).length-1;o>=0;--o){const a=t.charCodeAt(o);if(47!==a)-1===s&&(n=!1,s=o+1),46===a?-1===e?e=o:1!==r&&(r=1):-1!==e&&(r=-1);else if(!n){i=o+1;break}}return-1===e||-1===s||0===r||1===r&&e===s-1&&e===i+1?"":t.slice(e,s)},parse(t){A(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(0===t.length)return e;let i=(t=C(this.toPosix(t))).charCodeAt(0);const s=this.isAbsolute(t);let n;e.root=this.rootname(t),n=s||this.hasProtocol(t)?1:0;let r=-1,o=0,a=-1,h=!0,l=t.length-1,c=0;for(;l>=n;--l)if(i=t.charCodeAt(l),47!==i)-1===a&&(h=!1,a=l+1),46===i?-1===r?r=l:1!==c&&(c=1):-1!==r&&(c=-1);else if(!h){o=l+1;break}return-1===r||-1===a||0===c||1===c&&r===a-1&&r===o+1?-1!==a&&(e.base=e.name=0===o&&s?t.slice(1,a):t.slice(o,a)):(0===o&&s?(e.name=t.slice(1,r),e.base=t.slice(1,a)):(e.name=t.slice(o,r),e.base=t.slice(o,a)),e.ext=t.slice(r,a)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]},yr=t=>!Array.isArray(t);class xr{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,"bar"!==this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar")))throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(t=>{this._preferredOrder.push(t),t.priority||(t.priority=Object.keys(t.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if("string"==typeof t)this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return ur(e||i,t=>"string"==typeof t?t:Array.isArray(t)?t.map(t=>t?.src??t):t?.src?t.src:t,!0)}addManifest(t){this._manifest&&o(),this._manifest=t,t.bundles.forEach(t=>{this.addBundle(t.name,t.assets)})}addBundle(t,e){const i=[];let s=e;Array.isArray(e)||(s=Object.entries(e).map(([t,e])=>"string"==typeof e||Array.isArray(e)?{alias:t,src:e}:{alias:t,...e})),s.forEach(e=>{const s=e.src,n=e.alias;let r;if("string"==typeof n){const e=this._createBundleAssetId(t,n);i.push(e),r=[n,e]}else{const e=n.map(e=>this._createBundleAssetId(t,e));i.push(...e),r=[...n,...e]}this.add({...e,alias:r,src:s})}),this._bundles[t]=i}add(t){const e=[];let i;Array.isArray(t)?e.push(...t):e.push(t),i=t=>{this.hasKey(t)&&o()},ur(e).forEach(t=>{const{src:e}=t;let{data:s,format:n,loadParser:r,parser:o}=t;const a=ur(e).map(t=>"string"==typeof t?I(t):Array.isArray(t)?t:[t]),h=this.getAlias(t);Array.isArray(h)?h.forEach(i):i(h);const l=[];a.forEach(e=>{e.forEach(e=>{let i={};if("object"!=typeof e){i.src=e;for(let t=0;t<this._parsers.length;t++){const s=this._parsers[t];if(s.test(e)){i=s.parse(e);break}}}else s=e.data??s,n=e.format??n,(e.loadParser||e.parser)&&(r=e.loadParser??r,o=e.parser??o),i={...i,...e};if(!h)throw new Error(`[Resolver] alias is undefined for this asset: ${i.src}`);i=this._buildResolvedAsset(i,{aliases:h,data:s,format:n,loadParser:r,parser:o,progressSize:t.progressSize}),l.push(i)})}),h.forEach(t=>{this._assetMap[t]=l})})}resolveBundle(t){const e=yr(t);t=ur(t);const i={};return t.forEach(t=>{const e=this._bundles[t];if(e){const s=this.resolve(e),n={};for(const e in s){const i=s[e];n[this._extractAssetIdFromBundle(t,e)]=i}i[t]=n}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if("string"!=typeof t){const t={};for(const i in e)t[i]=e[i].src;return t}return e.src}resolve(t){const e=yr(t);t=ur(t);const i={};return t.forEach(t=>{if(!this._resolverHash[t])if(this._assetMap[t]){let e=this._assetMap[t];const i=this._getPreferredOrder(e);i?.priority.forEach(t=>{i.params[t].forEach(i=>{const s=e.filter(e=>!!e[t]&&e[t]===i);s.length&&(e=s)})}),this._resolverHash[t]=e[0]}else this._resolverHash[t]=this._buildResolvedAsset({alias:[t],src:t},{});i[t]=this._resolverHash[t]}),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[e],s=this._preferredOrder.find(t=>t.params.format.includes(i.format));if(s)return s}return this._preferredOrder[0]}_appendDefaultSearchParams(t){return this._defaultSearchParams?`${t}${/\?/.test(t)?"&":"?"}${this._defaultSearchParams}`:t}_buildResolvedAsset(t,e){const{aliases:i,data:s,loadParser:n,parser:r,format:o,progressSize:a}=e;return(this._basePath||this._rootPath)&&(t.src=mr.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=i??t.alias??[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data={...s||{},...t.data},t.loadParser=n??t.loadParser,t.parser=r??t.parser,t.format=o??t.format??t.src.split(".").pop().split("?").shift().split("#").shift(),void 0!==a&&(t.progressSize=a),t}}xr.RETINA_PREFIX=/@([0-9\.]+)x/;const br=(t,e)=>{const i=e.split("?")[1];return i&&(t+=`?${i}`),t},vr=class t{constructor(t,e){this.linkedSheets=[];let i=t;t?.source instanceof Ds&&(i={texture:t,data:e});const{texture:s,data:n,cachePrefix:r=""}=i;this.cachePrefix=r,this._texture=s instanceof Gs?s:null,this.textureSource=s.source,this.textures={},this.animations={},this.data=n;const o=parseFloat(n.meta.scale);o?(this.resolution=o,s.source.resolution=this.resolution):this.resolution=s.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=t.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}_processFrames(e){let i=e;const s=t.BATCH_SIZE;for(;i-e<s&&i<this._frameKeys.length;){const t=this._frameKeys[i],e=this._frames[t],s=e.frame;if(s){let i=null,n=null;const r=!1!==e.trimmed&&e.sourceSize?e.sourceSize:e.frame,o=new Ss(0,0,Math.floor(r.w)/this.resolution,Math.floor(r.h)/this.resolution);i=e.rotated?new Ss(Math.floor(s.x)/this.resolution,Math.floor(s.y)/this.resolution,Math.floor(s.h)/this.resolution,Math.floor(s.w)/this.resolution):new Ss(Math.floor(s.x)/this.resolution,Math.floor(s.y)/this.resolution,Math.floor(s.w)/this.resolution,Math.floor(s.h)/this.resolution),!1!==e.trimmed&&e.spriteSourceSize&&(n=new Ss(Math.floor(e.spriteSourceSize.x)/this.resolution,Math.floor(e.spriteSourceSize.y)/this.resolution,Math.floor(s.w)/this.resolution,Math.floor(s.h)/this.resolution)),this.textures[t]=new Gs({source:this.textureSource,frame:i,orig:o,trim:n,rotate:e.rotated?2:0,defaultAnchor:e.anchor,defaultBorders:e.borders,label:t.toString()})}i++}}_processAnimations(){const t=this.data.animations||{};for(const e in t){this.animations[e]=[];for(let i=0;i<t[e].length;i++){const s=t[e][i];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*t.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*t.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(t=!1){for(const t in this.textures)this.textures[t].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,t&&(this._texture?.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};vr.BATCH_SIZE=1e3;let _r=vr;const wr=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"],Ar={extension:qi.Asset,cache:{test:t=>t instanceof _r,getCacheableAssets:(t,e)=>M(t,e,!1)},resolver:{extension:{type:qi.ResolveParser,name:"resolveSpritesheet"},test:t=>{const e=t.split("?")[0].split("."),i=e.pop(),s=e.pop();return"json"===i&&wr.includes(s)},parse:t=>{const e=t.split(".");return{resolution:parseFloat(xr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:qi.LoadParser,priority:fr.Normal,name:"spritesheetLoader"},testParse:async(t,e)=>".json"===mr.extname(e.src).toLowerCase()&&!!t.frames,async parse(t,e,i){const{texture:s,imageFilename:n,textureOptions:r,cachePrefix:o}=e?.data??{};let a,h=mr.dirname(e.src);if(h&&h.lastIndexOf("/")!==h.length-1&&(h+="/"),s instanceof Gs)a=s;else{const s=br(h+(n??t.meta.image),e.src);a=(await i.load([{src:s,data:r}]))[s]}const l=new _r({texture:a.source,data:t,cachePrefix:o});await l.parse();const c=t?.meta?.related_multi_packs;if(Array.isArray(c)){const t=[];for(const s of c){if("string"!=typeof s)continue;let n=h+s;e.data?.ignoreMultiPack||(n=br(n,e.src),t.push(i.load({src:n,data:{textureOptions:r,ignoreMultiPack:!0}})))}const s=await Promise.all(t);l.linkedSheets=s,s.forEach(t=>{t.linkedSheets=[l].concat(l.linkedSheets.filter(e=>e!==t))})}return l},async unload(t,e,i){await i.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};es.add(Ar);class Cr{constructor(t){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),e=this._canvas.width,i=this._canvas.height,s=t.width/e*this._renderer.resolution,n=t.height/i*this._renderer.resolution,r=`translate(${t.left}px, ${t.top}px) scale(${s}, ${n})`;r!==this._lastTransform&&(this._domElement.style.transform=r,this._lastTransform=r)},this._domElement=t.domElement,this._renderer=t.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas||(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(t=>{for(const e of t){if(e.target!==this._canvas)continue;const t=this.canvas.width,i=this.canvas.height,s=e.contentRect.width/t*this._renderer.resolution,n=e.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==n)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=n)}}),this._observer.observe(this._canvas)):this._tickerAttached||lr.shared.add(this.updateTranslation,this,rr.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&lr.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class Sr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Sr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new ds,this.page=new ds,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,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}}var Ir=/iPhone/i,Mr=/iPod/i,Tr=/iPad/i,Pr=/\biOS-universal(?:.+)Mac\b/i,Er=/\bAndroid(?:.+)Mobile\b/i,Br=/Android/i,Rr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,kr=/Silk/i,Or=/Windows Phone/i,Dr=/\bWindows(?:.+)ARM\b/i,Fr=/BlackBerry/i,Lr=/BB10/i,jr=/Opera Mini/i,Gr=/\b(CriOS|Chrome)(?:.+)Mobile/i,Ur=/Mobile(?:.+)Firefox\b/i,zr=function(t){return void 0!==t&&"MacIntel"===t.platform&&"number"==typeof t.maxTouchPoints&&t.maxTouchPoints>1&&"undefined"==typeof MSStream};const Nr=(T.default??T)(globalThis.navigator),Vr=class t{constructor(t,e=Nr){this._mobileInfo=e,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(e.tablet||e.phone)&&this._createTouchHook(),this._renderer=t}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const t=document.createElement("button");t.style.width="1px",t.style.height="1px",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.zIndex=2..toString(),t.style.backgroundColor="#FF0000",t.title="select to enable accessibility for this content",t.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(t),this._hookDiv=t}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.pointerEvents="none",this._div.style.zIndex=2..toString(),this._canvasObserver=new Cr({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const t=this._renderer.view.canvas;if(t.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const e=new MutationObserver(()=>{t.parentNode&&(e.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});e.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const t of this._children)t._accessibleDiv&&t._accessibleDiv.parentNode&&(t._accessibleDiv.parentNode.removeChild(t._accessibleDiv),t._accessibleDiv=null),t._accessibleActive=!1;for(const t in this._pools)this._pools[t].forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),delete this._pools[t];this._div&&this._div.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(t){if(!t.visible||!t.accessibleChildren)return;t.accessible&&(t._accessibleActive||this._addChild(t),t._renderId=this._renderId);const e=t.children;if(e)for(let t=0;t<e.length;t++)this._updateAccessibleObjects(e[t])}init(e){const i={accessibilityOptions:{...t.defaultOptions,...e?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const t=performance.now();if(this._mobileInfo.android.device&&t<this._androidUpdateCount)return;if(this._androidUpdateCount=t+this._androidUpdateFrequency,!(this._renderer.renderingToScreen&&this._renderer.view.canvas||this._isRunningTests))return;const e=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const t of this._children)t._renderId===this._renderId&&e.add(this._children.indexOf(t))}for(let t=this._children.length-1;t>=0;t--){const i=this._children[t];e.has(t)||(i._accessibleDiv&&i._accessibleDiv.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1,a(this._children,t,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let t=0;t<this._children.length;t++){const e=this._children[t];if(!e._accessibleActive||!e._accessibleDiv)continue;const i=e._accessibleDiv,s=e.hitArea||e.getBounds().rectangle;if(e.hitArea){const t=e.worldTransform;i.style.left=`${t.tx+s.x*t.a}px`,i.style.top=`${t.ty+s.y*t.d}px`,i.style.width=s.width*t.a+"px",i.style.height=s.height*t.d+"px"}else this._capHitArea(s),i.style.left=`${s.x}px`,i.style.top=`${s.y}px`,i.style.width=`${s.width}px`,i.style.height=`${s.height}px`}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._getPool(t.accessibleType).pop();e?(e.innerHTML="",e.removeAttribute("title"),e.removeAttribute("aria-label"),e.tabIndex=0):("button"===t.accessibleType?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText="\n color: transparent;\n pointer-events: none;\n padding: 0;\n margin: 0;\n border: 0;\n outline: 0;\n background: transparent;\n box-sizing: border-box;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n ",t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width="100px",e.style.height="100px",e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=2..toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&null!==t.accessibleTitle?e.title=t.accessibleTitle:t.accessibleHint&&null!==t.accessibleHint||(e.title=`container ${t.tabIndex}`),t.accessibleHint&&null!==t.accessibleHint&&e.setAttribute("aria-label",t.accessibleHint),t.interactive?e.tabIndex=t.tabIndex:e.tabIndex=0,this.debug&&this._updateDebugHTML(e),t._accessibleActive=!0,t._accessibleDiv=e,e.container=t,this._children.push(t),this._div.appendChild(t._accessibleDiv)}_dispatchEvent(t,e){const{container:i}=t.target,s=this._renderer.events.rootBoundary,n=Object.assign(new Sr(s),{target:i});s.rootTarget=this._renderer.lastObjectRendered,e.forEach(t=>s.dispatchEvent(n,t))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){9===t.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(t){0===t.movementX&&0===t.movementY||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(t){t?this._activate():this._deactivate()}_getPool(t){return this._pools[t]||(this._pools[t]=[]),this._pools[t]}};Vr.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"accessibility"},Vr.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let Hr=Vr;const Wr=Object.create(null),Jr=Object.create(null);let Zr,Xr;const Yr={},Kr={},Qr={stripVersion:function(t,e){return e?t.replace("#version 300 es",""):t},ensurePrecision:function(t,e,i){const s=i?e.maxSupportedFragmentPrecision:e.maxSupportedVertexPrecision;if("precision"!==t.substring(0,9)){let n=i?e.requestedFragmentPrecision:e.requestedVertexPrecision;return"highp"===n&&"highp"!==s&&(n="mediump"),`precision ${n} float;\n${t}`}return"highp"!==s&&"precision highp"===t.substring(0,15)?t.replace("precision highp","precision mediump"):t},addProgramDefines:function(t,e,i){return e?t:i?`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in varying\n #define finalColor gl_FragColor\n #define texture texture2D\n #endif\n ${t=t.replace("out vec4 finalColor;","")}\n `:`\n\n #ifdef GL_ES // This checks if it is WebGL1\n #define in attribute\n #define out varying\n #endif\n ${t}\n `},setProgramName:function(t,{name:e="pixi-program"},i=!0){e=e.replace(/\s+/g,"-");const s=i?Yr:Kr;return s[e+=i?"-fragment":"-vertex"]?(s[e]++,e+=`-${s[e]}`):s[e]=1,-1!==t.indexOf("#define SHADER_NAME")?t:`#define SHADER_NAME ${e}\n${t}`},insertVersion:function(t,e){return e?`#version 300 es\n${t}`:t}},qr=Object.create(null),$r=class t{constructor(e){const i=-1!==(e={...t.defaultOptions,...e}).fragment.indexOf("#version 300 es"),s={stripVersion:i,ensurePrecision:{requestedFragmentPrecision:e.preferredFragmentPrecision,requestedVertexPrecision:e.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:B()},setProgramName:{name:e.name},addProgramDefines:i,insertVersion:i};let n=e.fragment,r=e.vertex;Object.keys(Qr).forEach(t=>{const e=s[t];n=Qr[t](n,e,!0),r=Qr[t](r,e,!1)}),this.fragment=n,this.vertex=r,this.transformFeedbackVaryings=e.transformFeedbackVaryings,this._key=P(`${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,qr[this._cacheKey]=null}static from(e){const i=`${e.vertex}:${e.fragment}`;return qr[i]||(qr[i]=new t(e),qr[i]._cacheKey=i),qr[i]}};$r.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let to=$r;const eo={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}},io={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"};var so=(t=>(t[t.VERTEX=1]="VERTEX",t[t.FRAGMENT=2]="FRAGMENT",t[t.COMPUTE=4]="COMPUTE",t))(so||{});const no=Object.create(null);class ro{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;const{fragment:e,vertex:i,layout:s,gpuLayout:n,name:r}=t;if(this.name=r,this.fragment=e,this.vertex=i,e.source===i.source){const t=k(e.source);this.structsAndGroups=t}else{const t=k(i.source),s=k(e.source);this.structsAndGroups=function(t,e){const i=new Set,s=new Set;return{structs:[...t.structs,...e.structs].filter(t=>!i.has(t.name)&&(i.add(t.name),!0)),groups:[...t.groups,...e.groups].filter(t=>{const e=`${t.name}-${t.binding}`;return!s.has(e)&&(s.add(e),!0)})}}(t,s)}this.layout=s??function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const s=t[i];e[s.group]||(e[s.group]={}),e[s.group][s.name]=s.binding}return e}(this.structsAndGroups),this.gpuLayout=n??function({groups:t}){const e=[];for(let i=0;i<t.length;i++){const s=t[i];e[s.group]||(e[s.group]=[]),s.isUniform?e[s.group].push({binding:s.binding,visibility:so.VERTEX|so.FRAGMENT,buffer:{type:"uniform"}}):"sampler"===s.type?e[s.group].push({binding:s.binding,visibility:so.FRAGMENT,sampler:{type:"filtering"}}):"texture_2d"===s.type&&e[s.group].push({binding:s.binding,visibility:so.FRAGMENT,texture:{sampleType:"float",viewDimension:"2d",multisampled:!1}})}return e}(this.structsAndGroups),this.autoAssignGlobalUniforms=!(void 0===this.layout[0]?.globalUniforms),this.autoAssignLocalUniforms=!(void 0===this.layout[1]?.localUniforms),this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=P(i,"program")}get attributeData(){return this._attributeData??(this._attributeData=function({source:t,entryPoint:e}){const i={},s=t.indexOf(`fn ${e}`);if(-1!==s){const e=t.indexOf("->",s);if(-1!==e){const n=t.substring(s,e),r=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|$)/g;let o;for(;null!==(o=r.exec(n));){const t=io[o[3]]??"float32";i[o[2]]={location:parseInt(o[1],10),format:t,stride:R(t).stride,offset:0,instance:!1,start:0}}}}return i}(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,no[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return no[e]||(no[e]=new ro(t),no[e]._cacheKey=e),no[e]}}const oo=["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>","vec2<i32>","vec3<i32>","vec4<i32>"],ao=oo.reduce((t,e)=>(t[e]=!0,t),{}),ho=class t{constructor(i,s){this._touched=0,this.uid=e("uniform"),this._resourceType="uniformGroup",this._resourceId=e("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1,s={...t.defaultOptions,...s},this.uniformStructures=i;const n={};for(const t in i){const e=i[t];if(e.name=t,e.size=e.size??1,!ao[e.type]){const t=e.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(t){const[,i,s]=t;throw new Error(`Uniform type ${e.type} is not supported. Use type: '${i}', size: ${s} instead.`)}throw new Error(`Uniform type ${e.type} is not supported. Supported uniform types are: ${oo.join(", ")}`)}e.value??(e.value=O(e.type,e.size)),n[t]=e.value}this.uniforms=n,this._dirtyId=1,this.ubo=s.ubo,this.isStatic=s.isStatic,this._signature=P(Object.keys(n).map(t=>`${t}-${i[t].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};ho.defaultOptions={ubo:!1,isStatic:!1};let lo=ho;class co{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const s=t[i];this.setResource(s,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){const i=this.resources[e];t!==i&&(i&&t.off?.("change",this.onResourceChange,this),t.on?.("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(){const t=this.resources;for(const e in t){const i=t[e];i?.off?.("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 uo=(t=>(t[t.WEBGL=1]="WEBGL",t[t.WEBGPU=2]="WEBGPU",t[t.BOTH=3]="BOTH",t))(uo||{});class po extends as{constructor(t){super(),this.uid=e("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[];let{gpuProgram:i,glProgram:s,groups:n,resources:r,compatibleRenderers:o,groupMap:a}=t;this.gpuProgram=i,this.glProgram=s,void 0===o&&(o=0,i&&(o|=uo.WEBGPU),s&&(o|=uo.WEBGL)),this.compatibleRenderers=o;const h={};if(r||n||(r={}),r&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!i&&n&&!a)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!i&&n&&a)for(const t in a)for(const e in a[t]){const i=a[t][e];h[i]={group:t,binding:e,name:i}}else if(i&&n&&!a){const t=i.structsAndGroups.groups;a={},t.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t})}else if(r){n={},a={},i&&i.structsAndGroups.groups.forEach(t=>{a[t.group]=a[t.group]||{},a[t.group][t.binding]=t.name,h[t.name]=t});let t=0;for(const e in r)h[e]||(n[99]||(n[99]=new co,this._ownedBindGroups.push(n[99])),h[e]={group:99,binding:t,name:e},a[99]=a[99]||{},a[99][t]=e,t++);for(const t in r){const e=t;let i=r[t];i.source||i._resourceType||(i=new lo(i));const s=h[e];s&&(n[s.group]||(n[s.group]=new co,this._ownedBindGroups.push(n[s.group])),n[s.group].setResource(i,s.binding))}}this.groups=n,this._uniformBindMap=a,this.resources=this._buildResourceAccessor(n,h)}addResource(t,e,i){var s,n;(s=this._uniformBindMap)[e]||(s[e]={}),(n=this._uniformBindMap[e])[i]||(n[i]=t),this.groups[e]||(this.groups[e]=new co,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const s in e){const n=e[s];Object.defineProperty(i,n.name,{get:()=>t[n.group].getResource(n.binding),set(e){t[n.group].setResource(e,n.binding)}})}return i}destroy(t=!1){this.emit("destroy",this),t&&(this.gpuProgram?.destroy(),this.glProgram?.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(t=>{t.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null}static from(t){const{gpu:e,gl:i,...s}=t;let n,r;return e&&(n=ro.from(e)),i&&(r=to.from(i)),new po({gpuProgram:n,glProgram:r,...s})}}const go={normal:0,add:1,multiply:2,screen:3,overlay:4,erase:5,"normal-npm":6,"add-npm":7,"screen-npm":8,min:9,max:10},fo=class t{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(1&this.data)}set blend(t){!!(1&this.data)!==t&&(this.data^=1)}get offsets(){return!!(2&this.data)}set offsets(t){!!(2&this.data)!==t&&(this.data^=2)}set cullMode(t){"none"!==t?(this.culling=!0,this.clockwiseFrontFace="front"===t):this.culling=!1}get cullMode(){return this.culling?this.clockwiseFrontFace?"front":"back":"none"}get culling(){return!!(4&this.data)}set culling(t){!!(4&this.data)!==t&&(this.data^=4)}get depthTest(){return!!(8&this.data)}set depthTest(t){!!(8&this.data)!==t&&(this.data^=8)}get depthMask(){return!!(32&this.data)}set depthMask(t){!!(32&this.data)!==t&&(this.data^=32)}get clockwiseFrontFace(){return!!(16&this.data)}set clockwiseFrontFace(t){!!(16&this.data)!==t&&(this.data^=16)}get blendMode(){return this._blendMode}set blendMode(t){this.blend="none"!==t,this._blendMode=t,this._blendModeId=go[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 e=new t;return e.depthTest=!1,e.blend=!0,e}};fo.default2d=fo.for2d();let mo=fo;const yo=class t extends po{constructor(e){super(e={...t.defaultOptions,...e}),this.enabled=!0,this._state=mo.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,"boolean"==typeof e.antialias?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1)}apply(t,e,i,s){t.applyFilter(this,e,i,s)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(e){const{gpu:i,gl:s,...n}=e;let r,o;return i&&(r=ro.from(i)),s&&(o=to.from(s)),new t({gpuProgram:r,glProgram:o,...n})}};yo.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let xo=yo;const bo=[];let vo;es.handleByNamedList(qi.Environment,bo);const _o=F.default||F;var wo=(t=>(t[t.NONE=0]="NONE",t[t.COLOR=16384]="COLOR",t[t.STENCIL=1024]="STENCIL",t[t.DEPTH=256]="DEPTH",t[t.COLOR_DEPTH=16640]="COLOR_DEPTH",t[t.COLOR_STENCIL=17408]="COLOR_STENCIL",t[t.DEPTH_STENCIL=1280]="DEPTH_STENCIL",t[t.ALL=17664]="ALL",t))(wo||{});class Ao{constructor(t){this.items=[],this._name=t}emit(t,e,i,s,n,r,o,a){const{name:h,items:l}=this;for(let c=0,d=l.length;c<d;c++)l[c][h](t,e,i,s,n,r,o,a);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-1!==e&&this.items.splice(e,1),this}contains(t){return-1!==this.items.indexOf(t)}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return 0===this.items.length}get name(){return this._name}}const Co=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],So=class t extends as{constructor(t){super(),this.uid=e("renderer"),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,this.config=t;const i=[...Co,...this.config.runners??[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(e={}){const i=!0===e.skipExtensionImports||!1===e.manageImports;await async function(t){if(!t)for(let t=0;t<bo.length;t++){const e=bo[t];if(e.value.test())return void await e.value.load()}}(i),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const t in this._systemsHash)e={...this._systemsHash[t].constructor.defaultOptions,...e};e={...t.defaultOptions,...e},this._roundPixels=e.roundPixels?1:0;for(let t=0;t<this.runners.init.items.length;t++)await this.runners.init.items[t].init(e);this._initOptions=e}render(t,e){let i=t;if(i instanceof Xn&&(i={container:i},e&&(Ps(0,"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??(i.clearColor=this.background.colorRgba),i.clear??(i.clear=this.background.clearBeforeRender)),i.clearColor){const t=Array.isArray(i.clearColor)&&4===i.clearColor.length;i.clearColor=t?i.clearColor:yn.shared.setValue(i.clearColor).toArray()}i.transform||(i.container.updateLocalTransform(),i.transform=i.container.localTransform),i.container.visible&&(i.container.enableRenderGroup(),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){const s=this.view.resolution;this.view.resize(t,e,i),this.emit("resize",this.view.screen.width,this.view.screen.height,this.view.resolution),void 0!==i&&i!==s&&this.runners.resolutionChange.emit(i)}clear(t={}){t.target||(t.target=this.renderTarget.renderTarget),t.clearColor||(t.clearColor=this.background.colorRgba),t.clear??(t.clear=wo.ALL);const{clear:e,clearColor:i,target:s}=t;yn.shared.setValue(i??this.background.colorRgba),this.renderTarget.clear(s,e,yn.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(t=>{this.runners[t]=new Ao(t)})}_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 t in this.runners)this.runners[t].add(i);return this}_addPipes(t,e){const i=e.reduce((t,e)=>(t[e.name]=e.value,t),{});t.forEach(t=>{const e=t.value,s=t.name,n=i[s];this.renderPipes[s]=new e(this,n?new n:null),this.runners.destroy.add(this.renderPipes[s])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),Object.values(this.runners).forEach(t=>{t.destroy()}),(!0===t||"object"==typeof t&&t.releaseGlobalResources)&&bn.release(),this._systemsHash=null,this.renderPipes=null}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!D())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}resetState(){this.runners.resetState.emit()}};So.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Io,Mo,To=So;const Po=["webgl","webgpu","canvas"],Eo="8.14.0";class Bo{static init(){globalThis.__PIXI_APP_INIT__?.(this,Eo)}static destroy(){}}Bo.extension=qi.Application;class Ro{constructor(t){this._renderer=t}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,Eo)}destroy(){this._renderer=null}}Ro.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"initHook",priority:-10};const ko=class t{constructor(...t){this.stage=new Xn,void 0!==t[0]&&Ps(0,"Application constructor options are deprecated, please use Application.init() instead.")}async init(e){e={...e},this.renderer=await async function(t){let e,i=[];t.preference?(i.push(t.preference),Po.forEach(e=>{e!==t.preference&&i.push(e)})):i=Po.slice();let s={};for(let n=0;n<i.length;n++){const r=i[n];if("webgpu"===r&&await lt()){const{WebGPURenderer:i}=await Promise.resolve().then(()=>Nu);e=i,s={...t,...t.webgpu};break}if("webgl"===r&&ht(t.failIfMajorPerformanceCaveat??To.defaultOptions.failIfMajorPerformanceCaveat)){const{WebGLRenderer:i}=await Promise.resolve().then(()=>ru);e=i,s={...t,...t.webgl};break}if("canvas"===r)throw s={...t},new Error("CanvasRenderer is not yet implemented")}if(delete s.webgpu,delete s.webgl,!e)throw new Error("No available renderer for the current environment");const n=new e;return await n.init(s),n}(e),t._plugins.forEach(t=>{t.init.call(this,e)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return Ps(0,"Application.view is deprecated, please use Application.canvas instead."),this.renderer.canvas}get screen(){return this.renderer.screen}destroy(e=!1,i=!1){const s=t._plugins.slice(0);s.reverse(),s.forEach(t=>{t.destroy.call(this)}),this.stage.destroy(i),this.stage=null,this.renderer.destroy(e),this.renderer=null}};ko._plugins=[];let Oo=ko;es.handleByList(qi.Application,Oo._plugins),es.add(Bo);class Do{static init(t){Object.defineProperty(this,"resizeTo",{set(t){globalThis.removeEventListener("resize",this.queueResize),this._resizeTo=t,t&&(globalThis.addEventListener("resize",this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;let t,e;if(this._cancelResize(),this._resizeTo===globalThis.window)t=globalThis.innerWidth,e=globalThis.innerHeight;else{const{clientWidth:i,clientHeight:s}=this._resizeTo;t=i,e=s}this.renderer.resize(t,e),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Do.extension=qi.Application;class Fo{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(t){this._ticker&&this._ticker.remove(this.render,this),this._ticker=t,t&&t.add(this.render,this,rr.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?lr.shared:new lr,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Fo.extension=qi.Application;class Lo extends as{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.applyFillAsTint=!0,this.baseMeasurementFontSize=100,this.baseRenderedFontSize=100}get font(){return Ps(0,"BitmapFont.font is deprecated, please use BitmapFont.fontFamily instead."),this.fontFamily}get pageTextures(){return Ps(0,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}get size(){return Ps(0,"BitmapFont.size is deprecated, please use BitmapFont.fontMetrics.fontSize instead."),this.fontMetrics.fontSize}get distanceFieldRange(){return Ps(0,"BitmapFont.distanceFieldRange is deprecated, please use BitmapFont.distanceField.range instead."),this.distanceField.range}get distanceFieldType(){return Ps(0,"BitmapFont.distanceFieldType is deprecated, please use BitmapFont.distanceField.type instead."),this.distanceField.type}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners();for(const t in this.chars)this.chars[t].texture?.destroy();this.chars=null,t&&(this.pages.forEach(t=>t.texture.destroy(!0)),this.pages=null)}}class jo{constructor(t=0,e=0,i=!1){this.first=null,this.items=Object.create(null),this.last=null,this.max=t,this.resetTtl=i,this.size=0,this.ttl=e}clear(){return this.first=null,this.items=Object.create(null),this.last=null,this.size=0,this}delete(t){if(this.has(t)){const e=this.items[t];delete this.items[t],this.size--,null!==e.prev&&(e.prev.next=e.next),null!==e.next&&(e.next.prev=e.prev),this.first===e&&(this.first=e.next),this.last===e&&(this.last=e.prev)}return this}entries(t=this.keys()){return t.map(t=>[t,this.get(t)])}evict(t=!1){if(t||this.size>0){const t=this.first;delete this.items[t.key],0===--this.size?(this.first=null,this.last=null):(this.first=t.next,this.first.prev=null)}return this}expiresAt(t){let e;return this.has(t)&&(e=this.items[t].expiry),e}get(t){const e=this.items[t];if(void 0!==e)return this.ttl>0&&e.expiry<=Date.now()?void this.delete(t):(this.moveToEnd(e),e.value)}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(null!==t.prev&&(t.prev.next=t.next),null!==t.next&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,null!==this.last&&(this.last.next=t),this.last=t,null===this.first&&(this.first=t))}keys(){const t=[];let e=this.first;for(;null!==e;)t.push(e.key),e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let s=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(s={...this.first},this.evict(!0));let i=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};1===++this.size?this.first=i:this.last.next=i,this.last=i}return s}set(t,e,i=!1,s=this.resetTtl){let n=this.items[t];return i||void 0!==n?(n.value=e,!1===i&&s&&(n.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(n)):(this.max>0&&this.size===this.max&&this.evict(!0),n=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},1===++this.size?this.first=n:this.last.next=n,this.last=n),this}values(t=this.keys()){return t.map(t=>this.get(t))}}const Go=["serif","sans-serif","monospace","cursive","fantasy","system-ui"],Uo={willReadFrequently:!0},zo=class t{static get experimentalLetterSpacingSupported(){let e=t._experimentalLetterSpacingSupported;if(void 0===e){const i=ir.get().getCanvasRenderingContext2D().prototype;e=t._experimentalLetterSpacingSupported="letterSpacing"in i||"textLetterSpacing"in i}return e}constructor(t,e,i,s,n,r,o,a,h){this.text=t,this.style=e,this.width=i,this.height=s,this.lines=n,this.lineWidths=r,this.lineHeight=o,this.maxLineWidth=a,this.fontProperties=h}static measureText(e=" ",i,s=t._canvas,n=i.wordWrap){const r=`${e}-${i.styleKey}-wordWrap-${n}`;if(t._measurementCache.has(r))return t._measurementCache.get(r);const o=dt(i),a=t.measureFont(o);0===a.fontSize&&(a.fontSize=i.fontSize,a.ascent=i.fontSize);const h=t.__context;h.font=o;const l=(n?t._wordWrap(e,i,s):e).split(/(?:\r\n|\r|\n)/),c=new Array(l.length);let d=0;for(let e=0;e<l.length;e++){const s=t._measureText(l[e],i.letterSpacing,h);c[e]=s,d=Math.max(d,s)}const u=i._stroke?.width||0;let p=d+u;i.dropShadow&&(p+=i.dropShadow.distance);const g=i.lineHeight||a.fontSize;let f=Math.max(g,a.fontSize+u)+(l.length-1)*(g+i.leading);i.dropShadow&&(f+=i.dropShadow.distance);const m=new t(e,i,p,f,l,c,g+i.leading,d,a);return t._measurementCache.set(r,m),m}static _measureText(e,i,s){let n=!1;t.experimentalLetterSpacingSupported&&(t.experimentalLetterSpacing?(s.letterSpacing=`${i}px`,s.textLetterSpacing=`${i}px`,n=!0):(s.letterSpacing="0px",s.textLetterSpacing="0px"));const r=s.measureText(e);let o=r.width;const a=-r.actualBoundingBoxLeft;let h=r.actualBoundingBoxRight-a;if(o>0)if(n)o-=i,h-=i;else{const s=(t.graphemeSegmenter(e).length-1)*i;o+=s,h+=s}return Math.max(o,h)}static _wordWrap(e,i,s=t._canvas){const n=s.getContext("2d",Uo);let r=0,o="",a="";const h=Object.create(null),{letterSpacing:l,whiteSpace:c}=i,d=t._collapseSpaces(c),u=t._collapseNewlines(c);let p=!d;const g=i.wordWrapWidth+l,f=t._tokenize(e);for(let e=0;e<f.length;e++){let s=f[e];if(t._isNewline(s)){if(!u){a+=t._addLine(o),p=!d,o="",r=0;continue}s=" "}if(d){const e=t.isBreakingSpace(s),i=t.isBreakingSpace(o[o.length-1]);if(e&&i)continue}const c=t._getFromCache(s,l,h,n);if(c>g)if(""!==o&&(a+=t._addLine(o),o="",r=0),t.canBreakWords(s,i.breakWords)){const e=t.wordWrapSplit(s);for(let c=0;c<e.length;c++){let d=e[c],u=d,f=1;for(;e[c+f];){const n=e[c+f];if(t.canBreakChars(u,n,s,c,i.breakWords))break;d+=n,u=n,f++}c+=f-1;const m=t._getFromCache(d,l,h,n);m+r>g&&(a+=t._addLine(o),p=!1,o="",r=0),o+=d,r+=m}}else{o.length>0&&(a+=t._addLine(o),o="",r=0);const i=e===f.length-1;a+=t._addLine(s,!i),p=!1,o="",r=0}else c+r>g&&(p=!1,a+=t._addLine(o),o="",r=0),(o.length>0||!t.isBreakingSpace(s)||p)&&(o+=s,r+=c)}return a+=t._addLine(o,!1),a}static _addLine(e,i=!0){return e=t._trimRight(e),i?`${e}\n`:e}static _getFromCache(e,i,s,n){let r=s[e];return"number"!=typeof r&&(r=t._measureText(e,i,n)+i,s[e]=r),r}static _collapseSpaces(t){return"normal"===t||"pre-line"===t}static _collapseNewlines(t){return"normal"===t}static _trimRight(e){if("string"!=typeof e)return"";for(let i=e.length-1;i>=0;i--){const s=e[i];if(!t.isBreakingSpace(s))break;e=e.slice(0,-1)}return e}static _isNewline(e){return"string"==typeof e&&t._newlines.includes(e.charCodeAt(0))}static isBreakingSpace(e,i){return"string"==typeof e&&t._breakingSpaces.includes(e.charCodeAt(0))}static _tokenize(e){const i=[];let s="";if("string"!=typeof e)return i;for(let n=0;n<e.length;n++){const r=e[n],o=e[n+1];t.isBreakingSpace(r,o)||t._isNewline(r)?(""!==s&&(i.push(s),s=""),"\r"===r&&"\n"===o?(i.push("\r\n"),n++):i.push(r)):s+=r}return""!==s&&i.push(s),i}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,s,n){return!0}static wordWrapSplit(e){return t.graphemeSegmenter(e)}static measureFont(e){if(t._fonts[e])return t._fonts[e];const i=t._context;i.font=e;const s=i.measureText(t.METRICS_STRING+t.BASELINE_SYMBOL),n={ascent:s.actualBoundingBoxAscent,descent:s.actualBoundingBoxDescent,fontSize:s.actualBoundingBoxAscent+s.actualBoundingBoxDescent};return t._fonts[e]=n,n}static clearMetrics(e=""){e?delete t._fonts[e]:t._fonts={}}static get _canvas(){if(!t.__canvas){let e;try{const i=new OffscreenCanvas(0,0),s=i.getContext("2d",Uo);if(s?.measureText)return t.__canvas=i,i;e=ir.get().createCanvas()}catch(t){e=ir.get().createCanvas()}e.width=e.height=10,t.__canvas=e}return t.__canvas}static get _context(){return t.__context||(t.__context=t._canvas.getContext("2d",Uo)),t.__context}};zo.METRICS_STRING="|ÉqÅ",zo.BASELINE_SYMBOL="M",zo.BASELINE_MULTIPLIER=1.4,zo.HEIGHT_MULTIPLIER=2,zo.graphemeSegmenter=(()=>t=>[...t])(),zo.experimentalLetterSpacing=!1,zo._fonts={},zo._newlines=[10,13],zo._breakingSpaces=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],zo._measurementCache=ct(1e3);let No=zo;const Vo=[{offset:0,color:"white"},{offset:1,color:"black"}],Ho=class t{constructor(...i){this.uid=e("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];let s=function(t){let e=t[0]??{};return("number"==typeof e||t[1])&&(Ps(0,"use options object instead"),e={type:"linear",start:{x:t[0],y:t[1]},end:{x:t[2],y:t[3]},textureSpace:t[4],textureSize:t[5]??Wo.defaultLinearOptions.textureSize}),e}(i);s={..."radial"===s.type?t.defaultRadialOptions:t.defaultLinearOptions,...n(s)},this._textureSize=s.textureSize,this._wrapMode=s.wrapMode,"radial"===s.type?(this.center=s.center,this.outerCenter=s.outerCenter??this.center,this.innerRadius=s.innerRadius,this.outerRadius=s.outerRadius,this.scale=s.scale,this.rotation=s.rotation):(this.start=s.start,this.end=s.end),this.textureSpace=s.textureSpace,this.type=s.type,s.colorStops.forEach(t=>{this.addColorStop(t.offset,t.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:yn.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:s}=this.end,n=i-t,r=s-e;const o=n<0||r<0;if("clamp-to-edge"===this._wrapMode){if(n<0){const e=t;t=i,i=e,n*=-1}if(r<0){const t=e;e=s,s=t,r*=-1}}const a=this.colorStops.length?this.colorStops:Vo,h=this._textureSize,{canvas:l,context:c}=pt(h,1),d=o?c.createLinearGradient(this._textureSize,0,0,0):c.createLinearGradient(0,0,this._textureSize,0);ut(d,a),c.fillStyle=d,c.fillRect(0,0,h,1),this.texture=new Gs({source:new nr({resource:l,addressMode:this._wrapMode})});const u=Math.sqrt(n*n+r*r),p=Math.atan2(r,n),g=new ps;g.scale(u/h,1),g.rotate(p),g.translate(t,e),"local"===this.textureSpace&&g.scale(h,h),this.transform=g}buildGradient(){this.texture||this._tick++,"linear"===this.type?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:Vo,e=this._textureSize,{canvas:i,context:s}=pt(e,e),{x:n,y:r}=this.center,{x:o,y:a}=this.outerCenter,h=this.innerRadius,l=this.outerRadius,c=o-l,d=a-l,u=e/(2*l),p=(n-c)*u,g=(r-d)*u,f=s.createRadialGradient(p,g,h*u,(o-c)*u,(a-d)*u,l*u);ut(f,t),s.fillStyle=t[t.length-1].color,s.fillRect(0,0,e,e),s.fillStyle=f,s.translate(p,g),s.rotate(this.rotation),s.scale(1,this.scale),s.translate(-p,-g),s.fillRect(0,0,e,e),this.texture=new Gs({source:new nr({resource:i,addressMode:this._wrapMode})});const m=new ps;m.scale(1/u,1/u),m.translate(c,d),"local"===this.textureSpace&&m.scale(e,e),this.transform=m}destroy(){this.texture?.destroy(!0),this.texture=null,this.transform=null,this.colorStops=[],this.start=null,this.end=null,this.center=null,this.outerCenter=null}get styleKey(){return`fill-gradient-${this.uid}-${this._tick}`}};Ho.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},Ho.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let Wo=Ho;const Jo={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 Zo{constructor(t,i){this.uid=e("fillPattern"),this._tick=0,this.transform=new ps,this.texture=t,this.transform.scale(1/t.frame.width,1/t.frame.height),i&&(t.source.style.addressModeU=Jo[i].addressModeU,t.source.style.addressModeV=Jo[i].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),this._tick++}get texture(){return this._texture}set texture(t){this._texture!==t&&(this._texture=t,this._tick++)}get styleKey(){return`fill-pattern-${this.uid}-${this._tick}`}destroy(){this.texture.destroy(!0),this.texture=null}}var Xo,Yo;const Ko=t(function(){if(Yo)return Xo;Yo=1,Xo=function(s){var n=[];return s.replace(e,function(e,s,r){var o=s.toLowerCase();for(r=function(t){var e=t.match(i);return e?e.map(Number):[]}(r),"m"==o&&r.length>2&&(n.push([s].concat(r.splice(0,2))),o="l",s="m"==s?"l":"L");;){if(r.length==t[o])return r.unshift(s),n.push(r);if(r.length<t[o])throw new Error("malformed path data");n.push([s].concat(r.splice(0,t[o])))}}),n};var t={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},e=/([astvzqmhlc])([^astvzqmhlc]*)/gi,i=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;return Xo}());class Qo{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Qo(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,n=this.y-e;return s*=s,n*=n,s+n<=i}strokeContains(t,e,i,s=.5){if(0===this.radius)return!1;const n=this.x-t,r=this.y-e,o=this.radius,a=(1-s)*i,h=Math.sqrt(n*n+r*r);return h<=o+a&&h>o-(i-a)}getBounds(t){return t||(t=new Ss),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=2*this.radius,t.height=2*this.radius,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 qo{constructor(t=0,e=0,i=0,s=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=s}clone(){return new qo(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,s=(e-this.y)/this.halfHeight;return i*=i,s*=s,i+s<=1}strokeContains(t,e,i,s=.5){const{halfWidth:n,halfHeight:r}=this;if(n<=0||r<=0)return!1;const o=i*(1-s),a=i-o,h=n-a,l=r-a,c=n+o,d=r+o,u=t-this.x,p=e-this.y;return u*u/(h*h)+p*p/(l*l)>1&&u*u/(c*c)+p*p/(d*d)<=1}getBounds(t){return t||(t=new Ss),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=2*this.halfWidth,t.height=2*this.halfHeight,t}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}]`}}class $o{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if("number"!=typeof e[0]){const t=[];for(let i=0,s=e.length;i<s;i++)t.push(e[i].x,e[i].y);e=t}this.points=e,this.closePath=!0}isClockwise(){let t=0;const e=this.points,i=e.length;for(let s=0;s<i;s+=2){const n=e[s],r=e[s+1];t+=(e[(s+2)%i]-n)*(e[(s+3)%i]+r)}return t<0}containsPolygon(t){const e=this.getBounds(void 0),i=t.getBounds(void 0);if(!e.containsRect(i))return!1;const s=t.points;for(let t=0;t<s.length;t+=2){const e=s[t],i=s[t+1];if(!this.contains(e,i))return!1}return!0}clone(){const t=this.points.slice(),e=new $o(t);return e.closePath=this.closePath,e}contains(t,e){let i=!1;const s=this.points.length/2;for(let n=0,r=s-1;n<s;r=n++){const s=this.points[2*n],o=this.points[2*n+1],a=this.points[2*r],h=this.points[2*r+1];o>e!=h>e&&t<(e-o)/(h-o)*(a-s)+s&&(i=!i)}return i}strokeContains(t,e,i,s=.5){const n=i*i,r=n*(1-s),o=n-r,{points:a}=this,h=a.length-(this.closePath?0:2);for(let i=0;i<h;i+=2){const s=a[i],n=a[i+1],h=a[(i+2)%a.length],l=a[(i+3)%a.length];if(gt(t,e,s,n,h,l)<=(Math.sign((h-s)*(e-n)-(l-n)*(t-s))<0?o:r))return!0}return!1}getBounds(t){t||(t=new Ss);const e=this.points;let i=1/0,s=-1/0,n=1/0,r=-1/0;for(let t=0,o=e.length;t<o;t+=2){const o=e[t],a=e[t+1];i=o<i?o:i,s=o>s?o:s,n=a<n?a:n,r=a>r?a:r}return t.x=i,t.width=s-i,t.y=n,t.height=r-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 Ps(0,"Polygon.lastX is deprecated, please use Polygon.lastX instead."),this.points[this.points.length-2]}get y(){return Ps(0,"Polygon.y is deprecated, please use Polygon.lastY instead."),this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const ta=(t,e,i,s,n,r,o)=>{const a=t-i,h=e-s,l=Math.sqrt(a*a+h*h);return l>=n-r&&l<=n+o};class ea{constructor(t=0,e=0,i=0,s=0,n=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=s,this.radius=n}getBounds(t){return t||(t=new Ss),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new ea(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 s=t-(this.x+i),n=e-(this.y+i);const r=i*i;if(s*s+n*n<=r)return!0;if(s=t-(this.x+this.width-i),s*s+n*n<=r)return!0;if(n=e-(this.y+this.height-i),s*s+n*n<=r)return!0;if(s=t-(this.x+i),s*s+n*n<=r)return!0}return!1}strokeContains(t,e,i,s=.5){const{x:n,y:r,width:o,height:a,radius:h}=this,l=i*(1-s),c=i-l,d=n+h,u=r+h,p=n+o,g=r+a;return(t>=n-l&&t<=n+c||t>=p-c&&t<=p+l)&&e>=u&&e<=u+(a-2*h)||(e>=r-l&&e<=r+c||e>=g-c&&e<=g+l)&&t>=d&&t<=d+(o-2*h)||t<d&&e<u&&ta(t,e,d,u,h,c,l)||t>p-h&&e<u&&ta(t,e,p-h,u,h,c,l)||t>p-h&&e>g-h&&ta(t,e,p-h,g-h,h,c,l)||t<d&&e>g-h&&ta(t,e,d,g-h,h,c,l)}toString(){return`[pixi.js/math:RoundedRectangle x=${this.x} y=${this.y}width=${this.width} height=${this.height} radius=${this.radius}]`}}const ia={};class sa{constructor(t){"number"==typeof t?this.rawBinaryData=new ArrayBuffer(t):t instanceof Uint8Array?this.rawBinaryData=t.buffer:this.rawBinaryData=t,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),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`)}}}const na={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var ra=(t=>(t[t.DISABLED=0]="DISABLED",t[t.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",t[t.MASK_ACTIVE=2]="MASK_ACTIVE",t[t.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",t[t.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",t[t.NONE=5]="NONE",t))(ra||{});const oa=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join("\n");let aa=null;class ha{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 la{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new ha,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null}}const ca=[];let da=0;bn.register({clear:()=>{if(ca.length>0)for(const t of ca)t&&t.destroy();ca.length=0,da=0}});let ua=0;const pa=class t{constructor(i){this.uid=e("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],(i={...t.defaultOptions,...i}).maxTextures||(Ps(0,"maxTextures is a required option for Batcher now, please pass it in the options"),i.maxTextures=function(){if(aa)return aa;const t=E();return aa=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),aa=bt(aa,t),t.getExtension("WEBGL_lose_context")?.loseContext(),aa}());const{maxTextures:s,attributesInitialSize:n,indicesInitialSize:r}=i;this.attributeBuffer=new sa(4*n),this.indexBuffer=new Uint16Array(r),this.maxTextures=s}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;t<this.batchIndex;t++)_t(this.batches[t]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(t){this._elements[this.elementSize++]=t,t._indexStart=this.indexSize,t._attributeStart=this.attributeSize,t._batcher=this,this.indexSize+=t.indexSize,this.attributeSize+=t.attributeSize*this.vertexSize}checkAndUpdateTexture(t,e){const i=t._batch.textures.ids[e._source.uid];return!(!i&&0!==i||(t._textureId=i,t.texture=e,0))}updateElement(t){this.dirty=!0;const e=this.attributeBuffer;t.packAsQuad?this.packQuadAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId):this.packAttributes(t,e.float32View,e.uint32View,t._attributeStart,t._textureId)}break(t){const e=this._elements;if(!e[this.elementStart])return;let i=vt(),s=i.textures;s.clear();const n=e[this.elementStart];let r=yt(n.blendMode,n.texture._source),o=n.topology;4*this.attributeSize>this.attributeBuffer.size&&this._resizeAttributeBuffer(4*this.attributeSize),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const a=this.attributeBuffer.float32View,h=this.attributeBuffer.uint32View,l=this.indexBuffer;let c=this._batchIndexSize,d=this._batchIndexStart,u="startBatch";const p=this.maxTextures;for(let n=this.elementStart;n<this.elementSize;++n){const g=e[n];e[n]=null;const f=g.texture._source,m=yt(g.blendMode,f),y=r!==m||o!==g.topology;f._batchTick!==ua||y?(f._batchTick=ua,(s.count>=p||y)&&(this._finishBatch(i,d,c-d,s,r,o,t,u),u="renderBatch",d=c,r=m,o=g.topology,i=vt(),s=i.textures,s.clear(),++ua),g._textureId=f._textureBindLocation=s.count,s.ids[f.uid]=s.count,s.textures[s.count++]=f,g._batch=i,c+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,h,g._attributeStart,g._textureId),this.packQuadIndex(l,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,h,g._attributeStart,g._textureId),this.packIndex(g,l,g._indexStart,g._attributeStart/this.vertexSize))):(g._textureId=f._textureBindLocation,c+=g.indexSize,g.packAsQuad?(this.packQuadAttributes(g,a,h,g._attributeStart,g._textureId),this.packQuadIndex(l,g._indexStart,g._attributeStart/this.vertexSize)):(this.packAttributes(g,a,h,g._attributeStart,g._textureId),this.packIndex(g,l,g._indexStart,g._attributeStart/this.vertexSize)),g._batch=i)}s.count>0&&(this._finishBatch(i,d,c-d,s,r,o,t,u),d=c,++ua),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=c}_finishBatch(t,e,i,s,n,r,o,a){t.gpuBindGroup=null,t.bindGroup=null,t.action=a,t.batcher=this,t.textures=s,t.blendMode=n,t.topology=r,t.start=e,t.size=i,++ua,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){4*t<=this.attributeBuffer.size||this._resizeAttributeBuffer(4*t)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,2*this.attributeBuffer.size),i=new sa(e);mt(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,1.5*e.length);i+=i%2;const s=i>65535?new Uint32Array(i):new Uint16Array(i);if(s.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let t=0;t<e.length;t++)s[t]=e[t];else mt(e.buffer,s.buffer);this.indexBuffer=s}packQuadIndex(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}packIndex(t,e,i,s){const n=t.indices,r=t.indexSize,o=t.indexOffset,a=t.attributeOffset;for(let t=0;t<r;t++)e[i++]=s+n[t+o]-a}destroy(){if(null!==this.batches){for(let t=0;t<this.batches.length;t++)_t(this.batches[t]);this.batches=null;for(let t=0;t<this._elements.length;t++)this._elements[t]&&(this._elements[t]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};pa.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};let ga=pa;var fa=(t=>(t[t.MAP_READ=1]="MAP_READ",t[t.MAP_WRITE=2]="MAP_WRITE",t[t.COPY_SRC=4]="COPY_SRC",t[t.COPY_DST=8]="COPY_DST",t[t.INDEX=16]="INDEX",t[t.VERTEX=32]="VERTEX",t[t.UNIFORM=64]="UNIFORM",t[t.STORAGE=128]="STORAGE",t[t.INDIRECT=256]="INDIRECT",t[t.QUERY_RESOLVE=512]="QUERY_RESOLVE",t[t.STATIC=1024]="STATIC",t))(fa||{});let ma=class extends as{constructor(t){let{data:i,size:s}=t;const{usage:n,label:r,shrinkToFit:o}=t;super(),this.uid=e("buffer"),this._resourceType="buffer",this._resourceId=e("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,i instanceof Array&&(i=new Float32Array(i)),this._data=i,s??(s=i?.byteLength);const a=!!i;this.descriptor={size:s,usage:n,mappedAtCreation:a,label:r},this.shrinkToFit=o??!0}get data(){return this._data}set data(t){this.setDataWithSize(t,t.length,!0)}get dataInt32(){return this._dataInt32||(this._dataInt32=new Int32Array(this.data.buffer)),this._dataInt32}get static(){return!!(this.descriptor.usage&fa.STATIC)}set static(t){t?this.descriptor.usage|=fa.STATIC:this.descriptor.usage&=~fa.STATIC}setDataWithSize(t,i,s){if(this._updateID++,this._updateSize=i*t.BYTES_PER_ELEMENT,this._data===t)return void(s&&this.emit("update",this));const n=this._data;this._data=t,this._dataInt32=null,n&&n.length===t.length||!this.shrinkToFit&&n&&t.byteLength<n.byteLength?s&&this.emit("update",this):(this.descriptor.size=t.byteLength,this._resourceId=e("resource"),this.emit("change",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()}};class ya extends as{constructor(t={}){super(),this.uid=e("geometry"),this._layoutKey=0,this.instanceCount=1,this._bounds=new zs,this._boundsDirty=!0;const{attributes:i,indexBuffer:s,topology:n}=t;if(this.buffers=[],this.attributes={},i)for(const t in i)this.addAttribute(t,i[t]);this.instanceCount=t.instanceCount??1,s&&this.addIndex(s),this.topology=n||"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}addAttribute(t,e){const i=function(t){return(t instanceof ma||Array.isArray(t)||t.BYTES_PER_ELEMENT)&&(t={buffer:t}),t.buffer=wt(t.buffer,!1),t}(e);-1===this.buffers.indexOf(i.buffer)&&(this.buffers.push(i.buffer),i.buffer.on("update",this.onBufferUpdate,this),i.buffer.on("change",this.onBufferUpdate,this)),this.attributes[t]=i}addIndex(t){this.indexBuffer=wt(t,!0),this.buffers.push(this.indexBuffer)}get bounds(){return this._boundsDirty?(this._boundsDirty=!1,function(t,e,i){const s=t.getAttribute("aPosition");if(!s)return i.minX=0,i.minY=0,i.maxX=0,i.maxY=0,i;const n=s.buffer.data;let r=1/0,o=1/0,a=-1/0,h=-1/0;const l=n.BYTES_PER_ELEMENT,c=(s.offset||0)/l,d=(s.stride||8)/l;for(let t=c;t<n.length;t+=d){const e=n[t],i=n[t+1];e>a&&(a=e),i>h&&(h=i),e<r&&(r=e),i<o&&(o=i)}return i.minX=r,i.minY=o,i.maxX=a,i.maxY=h,i}(this,0,this._bounds)):this._bounds}destroy(t=!1){this.emit("destroy",this),this.removeAllListeners(),t&&this.buffers.forEach(t=>t.destroy()),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const xa=new Float32Array(1),ba=new Uint32Array(1);class va extends ya{constructor(){const t=new ma({data:xa,label:"attribute-batch-buffer",usage:fa.VERTEX|fa.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:t,format:"float32x2",stride:24,offset:0},aUV:{buffer:t,format:"float32x2",stride:24,offset:8},aColor:{buffer:t,format:"unorm8x4",stride:24,offset:16},aTextureIdAndRound:{buffer:t,format:"uint16x2",stride:24,offset:20}},indexBuffer:new ma({data:ba,label:"index-batch-buffer",usage:fa.INDEX|fa.COPY_DST,shrinkToFit:!1})})}}const _a=/\{\{(.*?)\}\}/g,wa=Object.create(null),Aa=new Map;let Ca=0;const Sa={name:"global-uniforms-bit",vertex:{header:"\n struct GlobalUniforms {\n uProjectionMatrix:mat3x3<f32>,\n uWorldTransformMatrix:mat3x3<f32>,\n uWorldColorAlpha: vec4<f32>,\n uResolution: vec2<f32>,\n }\n\n @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;\n "}},Ia={name:"global-uniforms-bit",vertex:{header:"\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform vec4 uWorldColorAlpha;\n uniform vec2 uResolution;\n "}},Ma={name:"color-bit",vertex:{header:"\n @in aColor: vec4<f32>;\n ",main:"\n vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);\n "}},Ta={name:"color-bit",vertex:{header:"\n in vec4 aColor;\n ",main:"\n vColor *= vec4(aColor.rgb * aColor.a, aColor.a);\n "}},Pa={},Ea={},Ba={name:"round-pixels-bit",vertex:{header:"\n fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},Ra={name:"round-pixels-bit",vertex:{header:"\n vec2 roundPixels(vec2 position, vec2 targetSize)\n {\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n }\n "}},ka={};class Oa extends po{constructor(t){super({glProgram:kt({name:"batch",bits:[Ta,jt(t),Ra]}),gpuProgram:Rt({name:"batch",bits:[Ma,Ft(t),Ba]}),resources:{batchSamplers:Gt(t)}})}}let Da=null;const Fa=class t extends ga{constructor(e){super(e),this.geometry=new va,this.name=t.extension.name,this.vertexSize=6,Da??(Da=new Oa(e.maxTextures)),this.shader=Da}packAttributes(t,e,i,s,n){const r=n<<16|65535&t.roundPixels,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,{positions:p,uvs:g}=t,f=t.color,m=t.attributeOffset,y=m+t.attributeSize;for(let t=m;t<y;t++){const n=2*t,o=p[n],m=p[n+1];e[s++]=a*o+l*m+d,e[s++]=c*m+h*o+u,e[s++]=g[n],e[s++]=g[n+1],i[s++]=f,i[s++]=r}}packQuadAttributes(t,e,i,s,n){const r=t.texture,o=t.transform,a=o.a,h=o.b,l=o.c,c=o.d,d=o.tx,u=o.ty,p=t.bounds,g=p.maxX,f=p.minX,m=p.maxY,y=p.minY,x=r.uvs,b=t.color,v=n<<16|65535&t.roundPixels;e[s+0]=a*f+l*y+d,e[s+1]=c*y+h*f+u,e[s+2]=x.x0,e[s+3]=x.y0,i[s+4]=b,i[s+5]=v,e[s+6]=a*g+l*y+d,e[s+7]=c*y+h*g+u,e[s+8]=x.x1,e[s+9]=x.y1,i[s+10]=b,i[s+11]=v,e[s+12]=a*g+l*m+d,e[s+13]=c*m+h*g+u,e[s+14]=x.x2,e[s+15]=x.y2,i[s+16]=b,i[s+17]=v,e[s+18]=a*f+l*m+d,e[s+19]=c*m+h*f+u,e[s+20]=x.x3,e[s+21]=x.y3,i[s+22]=b,i[s+23]=v}};Fa.extension={type:[qi.Batcher],name:"default"};let La=Fa;const ja=new ps;class Ga{constructor(){this.packAsQuad=!1,this.batcherName="default",this.topology="triangle-list",this.applyTransform=!0,this.roundPixels=0,this._batcher=null,this._batch=null}get uvs(){return this.geometryData.uvs}get positions(){return this.geometryData.vertices}get indices(){return this.geometryData.indices}get blendMode(){return this.renderable&&this.applyTransform?this.renderable.groupBlendMode:"normal"}get color(){const t=this.baseColor,e=t>>16|65280&t|(255&t)<<16,i=this.renderable;return i?d(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(255*this.alpha<<24)}get transform(){return this.renderable?.groupTransform||ja}copyTo(t){t.indexOffset=this.indexOffset,t.indexSize=this.indexSize,t.attributeOffset=this.attributeOffset,t.attributeSize=this.attributeSize,t.baseColor=this.baseColor,t.alpha=this.alpha,t.texture=this.texture,t.geometryData=this.geometryData,t.topology=this.topology}reset(){this.applyTransform=!0,this.renderable=null,this.topology="triangle-list"}destroy(){this.renderable=null,this.texture=null,this.geometryData=null,this._batcher=null,this._batch=null}}const Ua={extension:{type:qi.ShapeBuilder,name:"circle"},build(t,e){let i,s,n,r,o,a;if("circle"===t.type){const e=t;if(o=a=e.radius,o<=0)return!1;i=e.x,s=e.y,n=r=0}else if("ellipse"===t.type){const e=t;if(o=e.halfWidth,a=e.halfHeight,o<=0||a<=0)return!1;i=e.x,s=e.y,n=r=0}else{const e=t,h=e.width/2,l=e.height/2;i=e.x+h,s=e.y+l,o=a=Math.max(0,Math.min(e.radius,Math.min(h,l))),n=h-o,r=l-a}if(n<0||r<0)return!1;const h=Math.ceil(2.3*Math.sqrt(o+a)),l=8*h+(n?4:0)+(r?4:0);if(0===l)return!1;if(0===h)return e[0]=e[6]=i+n,e[1]=e[3]=s+r,e[2]=e[4]=i-n,e[5]=e[7]=s-r,!0;let c=0,d=4*h+(n?2:0)+2,u=d,p=l,g=n+o,f=r,m=i+g,y=i-g,x=s+f;if(e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,r){const t=s-f;e[u++]=y,e[u++]=t,e[--p]=t,e[--p]=m}for(let t=1;t<h;t++){const l=Math.PI/2*(t/h),g=n+Math.cos(l)*o,f=r+Math.sin(l)*a,m=i+g,y=i-g,x=s+f,b=s-f;e[c++]=m,e[c++]=x,e[--d]=x,e[--d]=y,e[u++]=y,e[u++]=b,e[--p]=b,e[--p]=m}g=n,f=r+a,m=i+g,y=i-g,x=s+f;const b=s-f;return e[c++]=m,e[c++]=x,e[--p]=b,e[--p]=m,n&&(e[c++]=y,e[c++]=x,e[--p]=b,e[--p]=y),!0},triangulate(t,e,i,s,n,r){if(0===t.length)return;let o=0,a=0;for(let e=0;e<t.length;e+=2)o+=t[e],a+=t[e+1];o/=t.length/2,a/=t.length/2;let h=s;e[h*i]=o,e[h*i+1]=a;const l=h++;for(let s=0;s<t.length;s+=2)e[h*i]=t[s],e[h*i+1]=t[s+1],s>0&&(n[r++]=h,n[r++]=l,n[r++]=h-1),h++;n[r++]=l+1,n[r++]=l,n[r++]=h-1}},za={...Ua,extension:{...Ua.extension,name:"ellipse"}},Na={...Ua,extension:{...Ua.extension,name:"roundedRectangle"}},Va=1e-4,Ha=[],Wa={extension:{type:qi.ShapeBuilder,name:"polygon"},build(t,e){for(let i=0;i<t.points.length;i++)e[i]=t.points[i];return!0},triangulate(t,e,i,s,n,r){Vt(t,Ha,e,i,s,n,r)}},Ja={extension:{type:qi.ShapeBuilder,name:"rectangle"},build(t,e){const i=t,s=i.x,n=i.y,r=i.width,o=i.height;return r>0&&o>0&&(e[0]=s,e[1]=n,e[2]=s+r,e[3]=n,e[4]=s+r,e[5]=n+o,e[6]=s,e[7]=n+o,!0)},triangulate(t,e,i,s,n,r){let o=0;e[(s*=i)+o]=t[0],e[s+o+1]=t[1],o+=i,e[s+o]=t[2],e[s+o+1]=t[3],o+=i,e[s+o]=t[6],e[s+o+1]=t[7],o+=i,e[s+o]=t[4],e[s+o+1]=t[5],o+=i;const a=s/i;n[r++]=a,n[r++]=a+1,n[r++]=a+2,n[r++]=a+1,n[r++]=a+3,n[r++]=a+2}},Za={extension:{type:qi.ShapeBuilder,name:"triangle"},build:(t,e)=>(e[0]=t.x,e[1]=t.y,e[2]=t.x2,e[3]=t.y2,e[4]=t.x3,e[5]=t.y3,!0),triangulate(t,e,i,s,n,r){let o=0;e[(s*=i)+o]=t[0],e[s+o+1]=t[1],o+=i,e[s+o]=t[2],e[s+o+1]=t[3],o+=i,e[s+o]=t[4],e[s+o+1]=t[5];const a=s/i;n[r++]=a,n[r++]=a+1,n[r++]=a+2}},Xa=new ps,Ya=new Ss,Ka={};es.handleByMap(qi.ShapeBuilder,Ka),es.add(Ja,Wa,Za,Ua,za,Na);const Qa=new Ss,qa=new ps;class $a{constructor(){this.batches=[],this.geometryData={vertices:[],uvs:[],indices:[]}}}class th{constructor(){this.instructions=new Un}init(t){this.batcher=new La({maxTextures:t}),this.instructions.reset()}get geometry(){return Ps(0,"GraphicsContextRenderData#geometry is deprecated, please use batcher.geometry instead."),this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const eh=class t{constructor(t){this._gpuContextHash={},this._graphicsDataContextHash=Object.create(null),this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuContextHash"),t.renderableGC.addManagedHash(this,"_graphicsDataContextHash")}init(e){t.defaultOptions.bezierSmoothness=e?.bezierSmoothness??t.defaultOptions.bezierSmoothness}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),function(t,e){const{geometryData:i,batches:s}=e;s.length=0,i.indices.length=0,i.vertices.length=0,i.uvs.length=0;for(let e=0;e<t.instructions.length;e++){const n=t.instructions[e];if("texture"===n.action)Ht(n.data,s,i);else if("fill"===n.action||"stroke"===n.action){const t="stroke"===n.action,e=n.data.path.shapePath,r=n.data.style,o=n.data.hole;t&&o&&Wt(o.shapePath,r,!0,s,i),o&&(e.shapePrimitives[e.shapePrimitives.length-1].holes=o.shapePath.shapePrimitives),Wt(e,r,t,s,i)}}}(t,e);const i=t.batchMode;t.customShader||"no-batch"===i?e.isBatchable=!1:e.isBatchable="auto"!==i||e.geometryData.vertices.length<400,t.dirty=!1}return e}getGpuContext(t){return this._gpuContextHash[t.uid]||this._initContext(t)}_initContextRenderData(t){const e=_n.get(th,{maxTextures:this._renderer.limits.maxBatchableTextures}),{batches:i,geometryData:s}=this._gpuContextHash[t.uid],n=s.vertices.length,r=s.indices.length;for(let t=0;t<i.length;t++)i[t].applyTransform=!1;const o=e.batcher;o.ensureAttributeBuffer(n),o.ensureIndexBuffer(r),o.begin();for(let t=0;t<i.length;t++){const e=i[t];o.add(e)}o.finish(e.instructions);const a=o.geometry;a.indexBuffer.setDataWithSize(o.indexBuffer,o.indexSize,!0),a.buffers[0].setDataWithSize(o.attributeBuffer.float32View,o.attributeSize,!0);const h=o.batches;for(let t=0;t<h.length;t++){const e=h[t];e.bindGroup=ft(e.textures.textures,e.textures.count,this._renderer.limits.maxBatchableTextures)}return this._graphicsDataContextHash[t.uid]=e,e}_initContext(t){const e=new $a;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]&&(_n.return(this.getContextRenderData(t)),this._graphicsDataContextHash[t.uid]=null),e.batches&&e.batches.forEach(t=>{_n.return(t)})}destroy(){for(const t in this._gpuContextHash)this._gpuContextHash[t]&&this.onGraphicsContextDestroy(this._gpuContextHash[t].context)}};eh.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"graphicsContext"},eh.defaultOptions={bezierSmoothness:.5};let ih=eh;const sh=1.1920929e-7,nh=2*Math.PI,rh={centerX:0,centerY:0,ang1:0,ang2:0},oh=({x:t,y:e},i,s,n,r,o,a,h)=>{const l=n*(t*=i)-r*(e*=s),c=r*t+n*e;return h.x=l+o,h.y=c+a,h},ah=(t,e,i,s)=>{let n=t*i+e*s;return n>1&&(n=1),n<-1&&(n=-1),(t*s-e*i<0?-1:1)*Math.acos(n)},hh=new Ss;class lh{constructor(t){this.shapePrimitives=[],this._currentPoly=null,this._bounds=new zs,this._graphicsPath2D=t,this.signed=t.checkForHoles}moveTo(t,e){return this.startPoly(t,e),this}lineTo(t,e){this._ensurePoly();const i=this._currentPoly.points,s=i[i.length-2],n=i[i.length-1];return s===t&&n===e||i.push(t,e),this}arc(t,e,i,s,n,r){return this._ensurePoly(!1),Kt(this._currentPoly.points,t,e,i,s,n,r),this}arcTo(t,e,i,s,n){return this._ensurePoly(),function(t,e,i,s,n,r){const o=t[t.length-2],a=t[t.length-1]-i,h=o-e,l=n-i,c=s-e,d=Math.abs(a*c-h*l);if(d<1e-8||0===r)return void(t[t.length-2]===e&&t[t.length-1]===i||t.push(e,i));const u=a*a+h*h,p=l*l+c*c,g=a*l+h*c,f=r*Math.sqrt(u)/d,m=r*Math.sqrt(p)/d,y=f*g/u,x=m*g/p,b=f*c+m*h,v=f*l+m*a,_=h*(m+y),w=a*(m+y),A=c*(f+x),C=l*(f+x);Kt(t,b+e,v+i,r,Math.atan2(w-v,_-b),Math.atan2(C-v,A-b),h*l>c*a)}(this._currentPoly.points,t,e,i,s,n),this}arcToSvg(t,e,i,s,n,r,o){return function(t,e,i,s,n,r,o,a=0,h=0,l=0){if(0===r||0===o)return;const c=Math.sin(a*nh/360),d=Math.cos(a*nh/360),u=d*(e-s)/2+c*(i-n)/2,p=-c*(e-s)/2+d*(i-n)/2;if(0===u&&0===p)return;r=Math.abs(r),o=Math.abs(o);const g=Math.pow(u,2)/Math.pow(r,2)+Math.pow(p,2)/Math.pow(o,2);g>1&&(r*=Math.sqrt(g),o*=Math.sqrt(g)),((t,e,i,s,n,r,o,a,h,l,c,d,u)=>{const p=Math.pow(n,2),g=Math.pow(r,2),f=Math.pow(c,2),m=Math.pow(d,2);let y=p*g-p*m-g*f;y<0&&(y=0),y/=p*m+g*f,y=Math.sqrt(y)*(o===a?-1:1);const x=y*n/r*d,b=y*-r/n*c,v=l*x-h*b+(t+i)/2,_=h*x+l*b+(e+s)/2,w=(c-x)/n,A=(d-b)/r,C=(-c-x)/n,S=(-d-b)/r,I=ah(1,0,w,A);let M=ah(w,A,C,S);0===a&&M>0&&(M-=nh),1===a&&M<0&&(M+=nh),u.centerX=v,u.centerY=_,u.ang1=I,u.ang2=M})(e,i,s,n,r,o,h,l,c,d,u,p,rh);let{ang1:f,ang2:m}=rh;const{centerX:y,centerY:x}=rh;let b=Math.abs(m)/(nh/4);Math.abs(1-b)<1e-7&&(b=1);const v=Math.max(Math.ceil(b),1);m/=v;let _=t[t.length-2],w=t[t.length-1];const A={x:0,y:0};for(let e=0;e<v;e++){const e=Qt(f,m),{x:i,y:s}=oh(e[0],r,o,d,c,y,x,A),{x:n,y:a}=oh(e[1],r,o,d,c,y,x,A),{x:h,y:l}=oh(e[2],r,o,d,c,y,x,A);Jt(t,_,w,i,s,n,a,h,l),_=h,w=l,f+=m}}(this._currentPoly.points,this._currentPoly.lastX,this._currentPoly.lastY,r,o,t,e,i,s,n),this}bezierCurveTo(t,e,i,s,n,r,o){this._ensurePoly();const a=this._currentPoly;return Jt(this._currentPoly.points,a.lastX,a.lastY,t,e,i,s,n,r,o),this}quadraticCurveTo(t,e,i,s,n){this._ensurePoly();const r=this._currentPoly;return Xt(this._currentPoly.points,r.lastX,r.lastY,t,e,i,s,n),this}closePath(){return this.endPoly(!0),this}addPath(t,e){this.endPoly(),e&&!e.isIdentity()&&(t=t.clone(!0)).transform(e);const i=this.shapePrimitives,s=i.length;for(let e=0;e<t.instructions.length;e++){const i=t.instructions[e];this[i.action](...i.data)}if(t.checkForHoles&&i.length-s>1){let t=null;for(let e=s;e<i.length;e++){const s=i[e];if("polygon"===s.shape.type){const n=s.shape,r=t?.shape;r&&r.containsPolygon(n)?(t.holes||(t.holes=[]),t.holes.push(s),i.copyWithin(e,e+1),i.length--,e--):t=s}}}return this}finish(t=!1){this.endPoly(t)}rect(t,e,i,s,n){return this.drawShape(new Ss(t,e,i,s),n),this}circle(t,e,i,s){return this.drawShape(new Qo(t,e,i),s),this}poly(t,e,i){const s=new $o(t);return s.closePath=e,this.drawShape(s,i),this}regularPoly(t,e,i,s,n=0,r){s=Math.max(0|s,3);const o=-1*Math.PI/2+n,a=2*Math.PI/s,h=[];for(let n=0;n<s;n++){const s=o-n*a;h.push(t+i*Math.cos(s),e+i*Math.sin(s))}return this.poly(h,!0,r),this}roundPoly(t,e,i,s,n,r=0,o){if(s=Math.max(0|s,3),n<=0)return this.regularPoly(t,e,i,s,r);const a=i*Math.sin(Math.PI/s)-.001;n=Math.min(n,a);const h=-1*Math.PI/2+r,l=2*Math.PI/s,c=(s-2)*Math.PI/s/2;for(let r=0;r<s;r++){const s=r*l+h,a=t+i*Math.cos(s),d=e+i*Math.sin(s),u=s+Math.PI+c,p=s-Math.PI-c,g=a+n*Math.cos(u),f=d+n*Math.sin(u),m=a+n*Math.cos(p),y=d+n*Math.sin(p);0===r?this.moveTo(g,f):this.lineTo(g,f),this.quadraticCurveTo(a,d,m,y,o)}return this.closePath()}roundShape(t,e,i=!1,s){return t.length<3?this:(i?function(t,e,i,s){const n=(t,e)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),r=(t,e,i)=>({x:t.x+(e.x-t.x)*i,y:t.y+(e.y-t.y)*i}),o=e.length;for(let a=0;a<o;a++){const h=e[(a+1)%o],l=h.radius??i;if(l<=0){0===a?t.moveTo(h.x,h.y):t.lineTo(h.x,h.y);continue}const c=e[a],d=e[(a+2)%o],u=n(c,h);let p;p=u<1e-4?h:r(h,c,Math.min(u/2,l)/u);const g=n(d,h);let f;f=g<1e-4?h:r(h,d,Math.min(g/2,l)/g),0===a?t.moveTo(p.x,p.y):t.lineTo(p.x,p.y),t.quadraticCurveTo(h.x,h.y,f.x,f.y,s)}}(this,t,e,s):function(t,e,i){const s=(t,e)=>{const i=e.x-t.x,s=e.y-t.y,n=Math.sqrt(i*i+s*s);return{len:n,nx:i/n,ny:s/n}},n=(e,i)=>{0===e?t.moveTo(i.x,i.y):t.lineTo(i.x,i.y)};let r=e[e.length-1];for(let o=0;o<e.length;o++){const a=e[o%e.length],h=a.radius??i;if(h<=0){n(o,a),r=a;continue}const l=e[(o+1)%e.length],c=s(a,r),d=s(a,l);if(c.len<1e-4||d.len<1e-4){n(o,a),r=a;continue}let u=Math.asin(c.nx*d.ny-c.ny*d.nx),p=1,g=!1;c.nx*d.nx-c.ny*-d.ny<0?u<0?u=Math.PI+u:(u=Math.PI-u,p=-1,g=!0):u>0&&(p=-1,g=!0);const f=u/2;let m,y=Math.abs(Math.cos(f)*h/Math.sin(f));y>Math.min(c.len/2,d.len/2)?(y=Math.min(c.len/2,d.len/2),m=Math.abs(y*Math.sin(f)/Math.cos(f))):m=h;const x=a.x+d.nx*y+-d.ny*m*p,b=a.y+d.ny*y+d.nx*m*p,v=Math.atan2(c.ny,c.nx)+Math.PI/2*p,_=Math.atan2(d.ny,d.nx)-Math.PI/2*p;0===o&&t.moveTo(x+Math.cos(v)*m,b+Math.sin(v)*m),t.arc(x,b,m,v,_,g),r=a}}(this,t,e),this.closePath())}filletRect(t,e,i,s,n){if(0===n)return this.rect(t,e,i,s);const r=Math.min(i,s)/2,o=Math.min(r,Math.max(-r,n)),a=t+i,h=e+s,l=o<0?-o:0,c=Math.abs(o);return this.moveTo(t,e+c).arcTo(t+l,e+l,t+c,e,c).lineTo(a-c,e).arcTo(a-l,e+l,a,e+c,c).lineTo(a,h-c).arcTo(a-l,h-l,t+i-c,h,c).lineTo(t+c,h).arcTo(t+l,h-l,t,h-c,c).closePath()}chamferRect(t,e,i,s,n,r){if(n<=0)return this.rect(t,e,i,s);const o=Math.min(n,Math.min(i,s)/2),a=t+i,h=e+s,l=[t+o,e,a-o,e,a,e+o,a,h-o,a-o,h,t+o,h,t,h-o,t,e+o];for(let t=l.length-1;t>=2;t-=2)l[t]===l[t-2]&&l[t-1]===l[t-3]&&l.splice(t-1,2);return this.poly(l,!0,r)}ellipse(t,e,i,s,n){return this.drawShape(new qo(t,e,i,s),n),this}roundRect(t,e,i,s,n,r){return this.drawShape(new ea(t,e,i,s,n),r),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 $o,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 $o,t)){const t=this.shapePrimitives[this.shapePrimitives.length-1];if(t){let e=t.shape.x,i=t.shape.y;if(t.transform&&!t.transform.isIdentity()){const s=t.transform,n=e;e=s.a*e+s.c*i+s.tx,i=s.b*n+s.d*i+s.ty}this._currentPoly.points.push(e,i)}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 s=e[i],n=s.shape.getBounds(hh);s.transform?t.addRect(n,s.transform):t.addRect(n)}return t}}class ch{constructor(t,i=!1){this.instructions=[],this.uid=e("graphicsPath"),this._dirty=!0,this.checkForHoles=i,"string"==typeof t?function(t,e){const i=Ko(t),s=[];let n=null,r=0,a=0;for(let t=0;t<i.length;t++){const h=i[t],l=h[0],c=h;switch(l){case"M":r=c[1],a=c[2],e.moveTo(r,a);break;case"m":r+=c[1],a+=c[2],e.moveTo(r,a);break;case"H":r=c[1],e.lineTo(r,a);break;case"h":r+=c[1],e.lineTo(r,a);break;case"V":a=c[1],e.lineTo(r,a);break;case"v":a+=c[1],e.lineTo(r,a);break;case"L":r=c[1],a=c[2],e.lineTo(r,a);break;case"l":r+=c[1],a+=c[2],e.lineTo(r,a);break;case"C":r=c[5],a=c[6],e.bezierCurveTo(c[1],c[2],c[3],c[4],r,a);break;case"c":e.bezierCurveTo(r+c[1],a+c[2],r+c[3],a+c[4],r+c[5],a+c[6]),r+=c[5],a+=c[6];break;case"S":r=c[3],a=c[4],e.bezierCurveToShort(c[1],c[2],r,a);break;case"s":e.bezierCurveToShort(r+c[1],a+c[2],r+c[3],a+c[4]),r+=c[3],a+=c[4];break;case"Q":r=c[3],a=c[4],e.quadraticCurveTo(c[1],c[2],r,a);break;case"q":e.quadraticCurveTo(r+c[1],a+c[2],r+c[3],a+c[4]),r+=c[3],a+=c[4];break;case"T":r=c[1],a=c[2],e.quadraticCurveToShort(r,a);break;case"t":r+=c[1],a+=c[2],e.quadraticCurveToShort(r,a);break;case"A":r=c[6],a=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,a);break;case"a":r+=c[6],a+=c[7],e.arcToSvg(c[1],c[2],c[3],c[4],c[5],r,a);break;case"Z":case"z":e.closePath(),s.length>0&&(n=s.pop(),n?(r=n.startX,a=n.startY):(r=0,a=0)),n=null;break;default:o()}"Z"!==l&&"z"!==l&&null===n&&(n={startX:r,startY:a},s.push(n))}}(t,this):this.instructions=t?.slice()??[]}get shapePath(){return this._shapePath||(this._shapePath=new lh(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,s,n){const r=this.instructions[this.instructions.length-1],o=this.getLastPoint(ds.shared);let a=0,h=0;if(r&&"bezierCurveTo"===r.action){a=r.data[2],h=r.data[3];const t=o.x,e=o.y;a=t+(t-a),h=e+(e-h)}else a=o.x,h=o.y;return this.instructions.push({action:"bezierCurveTo",data:[a,h,t,e,i,s,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 s=this.instructions[this.instructions.length-1],n=this.getLastPoint(ds.shared);let r=0,o=0;if(s&&"quadraticCurveTo"===s.action){r=s.data[0],o=s.data[1];const t=n.x,e=n.y;r=t+(t-r),o=e+(e-o)}else r=n.x,o=n.y;return this.instructions.push({action:"quadraticCurveTo",data:[r,o,t,e,i]}),this._dirty=!0,this}rect(t,e,i,s,n){return this.instructions.push({action:"rect",data:[t,e,i,s,n]}),this._dirty=!0,this}circle(t,e,i,s){return this.instructions.push({action:"circle",data:[t,e,i,s]}),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,s,n,r,o){n||(n=s/2);const a=-1*Math.PI/2+r,h=2*i,l=2*Math.PI/h,c=[];for(let i=0;i<h;i++){const r=i%2?n:s,o=i*l+a;c.push(t+r*Math.cos(o),e+r*Math.sin(o))}return this.poly(c,!0,o),this}clone(t=!1){const e=new ch;if(e.checkForHoles=this.checkForHoles,t)for(let t=0;t<this.instructions.length;t++){const i=this.instructions[t];e.instructions.push({action:i.action,data:i.data.slice()})}else e.instructions=this.instructions.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,s=t.c,n=t.d,r=t.tx,a=t.ty;let h=0,l=0,c=0,d=0,u=0,p=0,g=0,f=0;for(let m=0;m<this.instructions.length;m++){const y=this.instructions[m],x=y.data;switch(y.action){case"moveTo":case"lineTo":h=x[0],l=x[1],x[0]=e*h+s*l+r,x[1]=i*h+n*l+a;break;case"bezierCurveTo":c=x[0],d=x[1],u=x[2],p=x[3],h=x[4],l=x[5],x[0]=e*c+s*d+r,x[1]=i*c+n*d+a,x[2]=e*u+s*p+r,x[3]=i*u+n*p+a,x[4]=e*h+s*l+r,x[5]=i*h+n*l+a;break;case"quadraticCurveTo":c=x[0],d=x[1],h=x[2],l=x[3],x[0]=e*c+s*d+r,x[1]=i*c+n*d+a,x[2]=e*h+s*l+r,x[3]=i*h+n*l+a;break;case"arcToSvg":h=x[5],l=x[6],g=x[0],f=x[1],x[0]=e*g+s*f,x[1]=i*g+n*f,x[5]=e*h+s*l+r,x[6]=i*h+n*l+a;break;case"circle":x[4]=qt(x[3],t);break;case"rect":x[4]=qt(x[4],t);break;case"ellipse":x[8]=qt(x[8],t);break;case"roundRect":x[5]=qt(x[5],t);break;case"addPath":x[0].transform(t);break;case"poly":x[2]=qt(x[2],t);break;default:o(y.action)}}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(;"closePath"===i.action;){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)}return t}}const dh={fill:{type:"paint",default:0},"fill-opacity":{type:"number",default:1},stroke:{type:"paint",default:0},"stroke-width":{type:"number",default:1},"stroke-opacity":{type:"number",default:1},"stroke-linecap":{type:"string",default:"butt"},"stroke-linejoin":{type:"string",default:"miter"},"stroke-miterlimit":{type:"number",default:10},"stroke-dasharray":{type:"string",default:"none"},"stroke-dashoffset":{type:"number",default:0},opacity:{type:"number",default:1}},uh=new ds,ph=new ps,gh=class t extends as{constructor(){super(...arguments),this.uid=e("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this._activePath=new ch,this._transform=new ps,this._fillStyle={...t.defaultFillStyle},this._strokeStyle={...t.defaultStrokeStyle},this._stateStack=[],this._tick=0,this._bounds=new zs,this._boundsDirty=!0}clone(){const e=new t;return e.batchMode=this.batchMode,e.instructions=this.instructions.slice(),e._activePath=this._activePath.clone(),e._transform=this._transform.clone(),e._fillStyle={...this._fillStyle},e._strokeStyle={...this._strokeStyle},e._stateStack=this._stateStack.slice(),e._bounds=this._bounds.clone(),e._boundsDirty=!0,e}get fillStyle(){return this._fillStyle}set fillStyle(e){this._fillStyle=ue(e,t.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(e){this._strokeStyle=pe(e,t.defaultStrokeStyle)}setFillStyle(e){return this._fillStyle=ue(e,t.defaultFillStyle),this}setStrokeStyle(e){return this._strokeStyle=ue(e,t.defaultStrokeStyle),this}texture(t,e,i,s,n,r){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:s||0,dw:n||t.frame.width,dh:r||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e?yn.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ch,this}fill(e,i){let s;const n=this.instructions[this.instructions.length-1];return s=0===this._tick&&n&&"stroke"===n.action?n.data.path:this._activePath.clone(),s?(null!=e&&(void 0!==i&&"number"==typeof e&&(Ps(0,"GraphicsContext.fill(color, alpha) is deprecated, use GraphicsContext.fill({ color, alpha }) instead"),e={color:e,alpha:i}),this._fillStyle=ue(e,t.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:s}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(ds.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(e){let i;const s=this.instructions[this.instructions.length-1];return i=0===this._tick&&s&&"fill"===s.action?s.data.path:this._activePath.clone(),i?(null!=e&&(this._strokeStyle=pe(e,t.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:i}}),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&&("stroke"===e.action||"fill"===e.action)){if(!e.data.hole){e.data.hole=i;break}e.data.hole.addPath(i)}}return this._initNextPathLocation(),this}arc(t,e,i,s,n,r){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,s,n,r),this}arcTo(t,e,i,s,n){this._tick++;const r=this._transform;return this._activePath.arcTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*s+r.tx,r.b*i+r.d*s+r.ty,n),this}arcToSvg(t,e,i,s,n,r,o){this._tick++;const a=this._transform;return this._activePath.arcToSvg(t,e,i,s,n,a.a*r+a.c*o+a.tx,a.b*r+a.d*o+a.ty),this}bezierCurveTo(t,e,i,s,n,r,o){this._tick++;const a=this._transform;return this._activePath.bezierCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*s+a.tx,a.b*i+a.d*s+a.ty,a.a*n+a.c*r+a.tx,a.b*n+a.d*r+a.ty,o),this}closePath(){return this._tick++,this._activePath?.closePath(),this}ellipse(t,e,i,s){return this._tick++,this._activePath.ellipse(t,e,i,s,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,s=this._activePath.instructions,n=i.a*t+i.c*e+i.tx,r=i.b*t+i.d*e+i.ty;return 1===s.length&&"moveTo"===s[0].action?(s[0].data[0]=n,s[0].data[1]=r,this):(this._activePath.moveTo(n,r),this)}quadraticCurveTo(t,e,i,s,n){this._tick++;const r=this._transform;return this._activePath.quadraticCurveTo(r.a*t+r.c*e+r.tx,r.b*t+r.d*e+r.ty,r.a*i+r.c*s+r.tx,r.b*i+r.d*s+r.ty,n),this}rect(t,e,i,s){return this._tick++,this._activePath.rect(t,e,i,s,this._transform.clone()),this}roundRect(t,e,i,s,n){return this._tick++,this._activePath.roundRect(t,e,i,s,n,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,s,n=0,r){return this._tick++,this._activePath.regularPoly(t,e,i,s,n,r),this}roundPoly(t,e,i,s,n,r){return this._tick++,this._activePath.roundPoly(t,e,i,s,n,r),this}roundShape(t,e,i,s){return this._tick++,this._activePath.roundShape(t,e,i,s),this}filletRect(t,e,i,s,n){return this._tick++,this._activePath.filletRect(t,e,i,s,n),this}chamferRect(t,e,i,s,n,r){return this._tick++,this._activePath.chamferRect(t,e,i,s,n,r),this}star(t,e,i,s,n=0,r=0){return this._tick++,this._activePath.star(t,e,i,s,n,r,this._transform.clone()),this}svg(t){return this._tick++,function(t,e){if("string"==typeof t){const e=document.createElement("div");e.innerHTML=t.trim(),t=e.querySelector("svg")}const i={context:e,defs:{},path:new ch};!function(t,e){const i=t.querySelectorAll("defs");for(let t=0;t<i.length;t++){const s=i[t];for(let t=0;t<s.children.length;t++){const i=s.children[t];switch(i.nodeName.toLowerCase()){case"lineargradient":e.defs[i.id]=te(i);break;case"radialgradient":e.defs[i.id]=ee()}}}}(t,i);const s=t.children,{fillStyle:n,strokeStyle:r}=se(t,i);for(let t=0;t<s.length;t++){const e=s[t];"defs"!==e.nodeName.toLowerCase()&&ae(e,i,n,r)}}(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,s,n,r){return t instanceof ps?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,s,n,r),this)}transform(t,e,i,s,n,r){return t instanceof ps?(this._transform.append(t),this):(ph.set(t,e,i,s,n,r),this._transform.append(ph),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._boundsDirty=!0,this.dirty||(this.emit("update",this,16),this.dirty=!0)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e<this.instructions.length;e++){const i=this.instructions[e],s=i.action;if("fill"===s){const e=i.data;t.addBounds(e.path.bounds)}else if("texture"===s){const e=i.data;t.addFrame(e.dx,e.dy,e.dx+e.dw,e.dy+e.dh,e.transform)}if("stroke"===s){const e=i.data,s=e.style.alignment,n=e.style.width*(1-s),r=e.path.bounds;t.addFrame(r.minX-n,r.minY-n,r.maxX+n,r.maxY+n)}}return t}containsPoint(t){if(!this.bounds.containsPoint(t.x,t.y))return!1;const e=this.instructions;let i=!1;for(let s=0;s<e.length;s++){const n=e[s],r=n.data,o=r.path;if(!n.action||!o)continue;const a=r.style,h=o.shapePath.shapePrimitives;for(let e=0;e<h.length;e++){const s=h[e].shape;if(!a||!s)continue;const o=h[e].transform,l=o?o.applyInverse(t,uh):t;if("fill"===n.action)i=s.contains(l.x,l.y);else{const t=a;i=s.strokeContains(l.x,l.y,t.width,t.alignment)}const c=r.hole;if(c){const t=c.shapePath?.shapePrimitives;if(t)for(let e=0;e<t.length;e++)t[e].shape.contains(l.x,l.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(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fillStyle.texture&&(this._fillStyle.fill&&"uid"in this._fillStyle.fill?this._fillStyle.fill.destroy():this._fillStyle.texture.destroy(e)),this._strokeStyle.texture&&(this._strokeStyle.fill&&"uid"in this._strokeStyle.fill?this._strokeStyle.fill.destroy():this._strokeStyle.texture.destroy(e))}this._fillStyle=null,this._strokeStyle=null,this.instructions=null,this._activePath=null,this._bounds=null,this._stateStack=null,this.customShader=null,this._transform=null}};gh.defaultFillStyle={color:16777215,alpha:1,texture:Gs.WHITE,matrix:null,fill:null,textureSpace:"local"},gh.defaultStrokeStyle={width:1,color:16777215,alpha:1,alignment:.5,miterLimit:10,cap:"butt",join:"miter",texture:Gs.WHITE,matrix:null,fill:null,textureSpace:"local",pixelLine:!1};let fh=gh;const mh=class t extends as{constructor(i={}){super(),this.uid=e("textStyle"),this._tick=0,function(t){const e=t;if("boolean"==typeof e.dropShadow&&e.dropShadow){const i=yh.defaultDropShadow;t.dropShadow={alpha:e.dropShadowAlpha??i.alpha,angle:e.dropShadowAngle??i.angle,blur:e.dropShadowBlur??i.blur,color:e.dropShadowColor??i.color,distance:e.dropShadowDistance??i.distance}}if(void 0!==e.strokeThickness){Ps(0,"strokeThickness is now a part of stroke");const i=e.stroke;let s={};if(yn.isColorLike(i))s.color=i;else if(i instanceof Wo||i instanceof Zo)s.fill=i;else{if(!Object.hasOwnProperty.call(i,"color")&&!Object.hasOwnProperty.call(i,"fill"))throw new Error("Invalid stroke value.");s=i}t.stroke={...s,width:e.strokeThickness}}if(Array.isArray(e.fillGradientStops)){if(Ps(0,"gradient fill is now a fill pattern: `new FillGradient(...)`"),!Array.isArray(e.fill)||0===e.fill.length)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");e.fill.length!==e.fillGradientStops.length&&o();const i=new Wo({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),s=e.fillGradientStops.slice(),n=e.fill.map(t=>yn.shared.setValue(t).toNumber());s.forEach((t,e)=>{i.addColorStop(t,n[e])}),t.fill={fill:i}}}(i);const s={...t.defaultTextStyle,...i};for(const t in s)this[t]=s[t];this.update(),this._tick=0}get align(){return this._align}set align(t){this._align!==t&&(this._align=t,this.update())}get breakWords(){return this._breakWords}set breakWords(t){this._breakWords!==t&&(this._breakWords=t,this.update())}get dropShadow(){return this._dropShadow}set dropShadow(e){this._dropShadow!==e&&(this._dropShadow=null!==e&&"object"==typeof e?this._createProxy({...t.defaultDropShadow,...e}):e?this._createProxy({...t.defaultDropShadow}):null,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(t){this._fontFamily!==t&&(this._fontFamily=t,this.update())}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize!==t&&(this._fontSize="string"==typeof t?parseInt(t,10):t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._fontStyle=t.toLowerCase(),this.update())}get fontVariant(){return this._fontVariant}set fontVariant(t){this._fontVariant!==t&&(this._fontVariant=t,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(t){this._fontWeight!==t&&(this._fontWeight=t,this.update())}get leading(){return this._leading}set leading(t){this._leading!==t&&(this._leading=t,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(t){this._letterSpacing!==t&&(this._letterSpacing=t,this.update())}get lineHeight(){return this._lineHeight}set lineHeight(t){this._lineHeight!==t&&(this._lineHeight=t,this.update())}get padding(){return this._padding}set padding(t){this._padding!==t&&(this._padding=t,this.update())}get filters(){return this._filters}set filters(t){this._filters!==t&&(this._filters=Object.freeze(t),this.update())}get trim(){return this._trim}set trim(t){this._trim!==t&&(this._trim=t,this.update())}get textBaseline(){return this._textBaseline}set textBaseline(t){this._textBaseline!==t&&(this._textBaseline=t,this.update())}get whiteSpace(){return this._whiteSpace}set whiteSpace(t){this._whiteSpace!==t&&(this._whiteSpace=t,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(t){this._wordWrap!==t&&(this._wordWrap=t,this.update())}get wordWrapWidth(){return this._wordWrapWidth}set wordWrapWidth(t){this._wordWrapWidth!==t&&(this._wordWrapWidth=t,this.update())}get fill(){return this._originalFill}set fill(t){t!==this._originalFill&&(this._originalFill=t,this._isFillStyle(t)&&(this._originalFill=this._createProxy({...fh.defaultFillStyle,...t},()=>{this._fill=ue({...this._originalFill},fh.defaultFillStyle)})),this._fill=ue(0===t?"black":t,fh.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy({...fh.defaultStrokeStyle,...t},()=>{this._stroke=pe({...this._originalStroke},fh.defaultStrokeStyle)})),this._stroke=pe(t,fh.defaultStrokeStyle),this.update())}update(){this._tick++,this.emit("update",this)}reset(){const e=t.defaultTextStyle;for(const t in e)this[t]=e[t]}get styleKey(){return`${this.uid}-${this._tick}`}clone(){return new t({align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?{...this._dropShadow}:null,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,filters:this._filters?[...this._filters]:void 0})}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e<this._filters.length;e++)t+=this._filters[e].padding;return Math.max(this._padding,t)}destroy(t=!1){if(this.removeAllListeners(),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._fill?.texture&&this._fill.texture.destroy(e),this._originalFill?.texture&&this._originalFill.texture.destroy(e),this._stroke?.texture&&this._stroke.texture.destroy(e),this._originalStroke?.texture&&this._originalStroke.texture.destroy(e)}this._fill=null,this._stroke=null,this.dropShadow=null,this._originalStroke=null,this._originalFill=null}_createProxy(t,e){return new Proxy(t,{set:(t,i,s)=>(t[i]===s||(t[i]=s,e?.(i,s),this.update()),!0)})}_isFillStyle(t){return null!==(t??null)&&!(yn.isColorLike(t)||t instanceof Wo||t instanceof Zo)}};mh.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},mh.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 yh=mh;const xh=new class{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=ir.get().createCanvas();i.width=t,i.height=e;const s=i.getContext("2d");return{canvas:i,context:s}}getOptimalCanvasAndContext(t,e,s=1){t=Math.ceil(t*s-1e-6),e=Math.ceil(e*s-1e-6);const n=((t=i(t))<<17)+((e=i(e))<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let r=this._canvasPool[n].pop();return r||(r=this._createCanvasAndContext(t,e)),r}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:s}=e,n=(i<<17)+(s<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,s),this._canvasPool[n].push(t)}clear(){this._canvasPool={}}};bn.register(xh);const bh=1e5,vh=class t extends Lo{constructor(e){super(),this.resolution=1,this.pages=[],this._padding=0,this._measureCache=Object.create(null),this._currentChars=[],this._currentX=0,this._currentY=0,this._currentMaxCharHeight=0,this._currentPageIndex=-1,this._skipKerning=!1;const i={...t.defaultOptions,...e};this._textureSize=i.textureSize,this._mipmap=i.mipmap;const s=i.style.clone();i.overrideFill&&(s._fill.color=16777215,s._fill.alpha=1,s._fill.texture=Gs.WHITE,s._fill.fill=null),this.applyFillAsTint=i.overrideFill;const n=s.fontSize;s.fontSize=this.baseMeasurementFontSize;const r=dt(s);i.overrideSize?s._stroke&&(s._stroke.width*=this.baseRenderedFontSize/n):s.fontSize=this.baseRenderedFontSize=n,this._style=s,this._skipKerning=i.skipKerning??!1,this.resolution=i.resolution??1,this._padding=i.padding??4,i.textureStyle&&(this._textureStyle=i.textureStyle instanceof ks?i.textureStyle:new ks(i.textureStyle)),this.fontMetrics=No.measureFont(r),this.lineHeight=s.lineHeight||this.fontMetrics.fontSize||s.fontSize}ensureCharacters(t){const e=No.graphemeSegmenter(t).filter(t=>!this._currentChars.includes(t)).filter((t,e,i)=>i.indexOf(t)===e);if(!e.length)return;let i;this._currentChars=[...this._currentChars,...e],i=-1===this._currentPageIndex?this._nextPage():this.pages[this._currentPageIndex];let{canvas:s,context:n}=i.canvasAndContext,r=i.texture.source;const o=this._style;let a=this._currentX,h=this._currentY,l=this._currentMaxCharHeight;const c=this.baseRenderedFontSize/this.baseMeasurementFontSize,d=this._padding*c;let u=!1;const p=s.width/this.resolution,g=s.height/this.resolution;for(let t=0;t<e.length;t++){const i=e[t],f=No.measureText(i,o,s,!1);f.lineHeight=f.height;const m=f.width*c,y=Math.ceil(("italic"===o.fontStyle?2:1)*m)+2*d,x=f.height*c+2*d;if(u=!1,"\n"!==i&&"\r"!==i&&"\t"!==i&&" "!==i&&(u=!0,l=Math.ceil(Math.max(x,l))),a+y>p&&(h+=l,l=x,a=0,h+l>g)){r.update();const t=this._nextPage();s=t.canvasAndContext.canvas,n=t.canvasAndContext.context,r=t.texture.source,a=0,h=0,l=0}const b=m/c-(o.dropShadow?.distance??0)-(o._stroke?.width??0);if(this.chars[i]={id:i.codePointAt(0),xOffset:-this._padding,yOffset:-this._padding,xAdvance:b,kerning:{}},u){this._drawGlyph(n,f,a+d,h+d,c,o);const t=r.width*c,e=r.height*c,s=new Ss(a/t*r.width,h/e*r.height,y/t*r.width,x/e*r.height);this.chars[i].texture=new Gs({source:r,frame:s}),a+=Math.ceil(y)}}r.update(),this._currentX=a,this._currentY=h,this._currentMaxCharHeight=l,this._skipKerning&&this._applyKerning(e,n)}get pageTextures(){return Ps(0,"BitmapFont.pageTextures is deprecated, please use BitmapFont.pages instead."),this.pages}_applyKerning(t,e){const i=this._measureCache;for(let s=0;s<t.length;s++){const n=t[s];for(let t=0;t<this._currentChars.length;t++){const s=this._currentChars[t];let r=i[n];r||(r=i[n]=e.measureText(n).width);let o=i[s];o||(o=i[s]=e.measureText(s).width);let a=e.measureText(n+s).width,h=a-(r+o);h&&(this.chars[n].kerning[s]=h),a=e.measureText(n+s).width,h=a-(r+o),h&&(this.chars[s].kerning[n]=h)}}}_nextPage(){this._currentPageIndex++;const t=this.resolution,e=xh.getOptimalCanvasAndContext(this._textureSize,this._textureSize,t);this._setupContext(e.context,this._style,t);const i=t*(this.baseRenderedFontSize/this.baseMeasurementFontSize),s=new Gs({source:new nr({resource:e.canvas,resolution:i,alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:this._mipmap})});this._textureStyle&&(s.source.style=this._textureStyle);const n={canvasAndContext:e,texture:s};return this.pages[this._currentPageIndex]=n,n}_setupContext(t,e,i){e.fontSize=this.baseRenderedFontSize,t.scale(i,i),t.font=dt(e),e.fontSize=this.baseMeasurementFontSize,t.textBaseline=e.textBaseline;const s=e._stroke,n=s?.width??0;if(s&&(t.lineWidth=n,t.lineJoin=s.join,t.miterLimit=s.miterLimit,t.strokeStyle=ge(s,t)),e._fill&&(t.fillStyle=ge(e._fill,t)),e.dropShadow){const s=e.dropShadow,n=yn.shared.setValue(s.color).toArray(),r=s.blur*i,o=s.distance*i;t.shadowColor=`rgba(${255*n[0]},${255*n[1]},${255*n[2]},${s.alpha})`,t.shadowBlur=r,t.shadowOffsetX=Math.cos(s.angle)*o,t.shadowOffsetY=Math.sin(s.angle)*o}else t.shadowColor="black",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0}_drawGlyph(t,e,i,s,n,r){const o=e.text,a=e.fontProperties,h=r._stroke,l=(h?.width??0)*n,c=i+l/2,d=s-l/2,u=a.descent*n,p=e.lineHeight*n;let g=!1;r.stroke&&l&&(g=!0,t.strokeText(o,c,d+p-u));const{shadowBlur:f,shadowOffsetX:m,shadowOffsetY:y}=t;r._fill&&(g&&(t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0),t.fillText(o,c,d+p-u)),g&&(t.shadowBlur=f,t.shadowOffsetX=m,t.shadowOffsetY=y)}destroy(){super.destroy();for(let t=0;t<this.pages.length;t++){const{canvasAndContext:e,texture:i}=this.pages[t];xh.returnCanvasAndContext(e),i.destroy(!0)}this.pages=null}};vh.defaultOptions={textureSize:512,style:new yh,mipmap:!0};let _h=vh,wh=0;const Ah=new class{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,textureStyle:null},this.measureCache=ct(1e3)}getFont(t,e){let i=`${e.fontFamily}-bitmap`,s=!0;if(e._fill.fill&&!e._stroke?(i+=e._fill.fill.styleKey,s=!1):(e._stroke||e.dropShadow)&&(i=`${e.styleKey}-bitmap`,s=!1),!pr.has(i)){const t=Object.create(e);t.lineHeight=0;const n=new _h({style:t,overrideFill:s,overrideSize:!0,...this.defaultOptions});wh++,wh>50&&o(),n.once("destroy",()=>{wh--,pr.remove(i)}),pr.set(i,n)}const n=pr.get(i);return n.ensureCharacters?.(t),n}getLayout(t,e,i=!0){const s=this.getFont(t,e),n=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(n))return this.measureCache.get(n);const r=fe(No.graphemeSegmenter(t),e,s,i);return this.measureCache.set(n,r),r}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){let e=t[0];"string"==typeof e&&(e={name:e,style:t[1],chars:t[2]?.chars,resolution:t[2]?.resolution,padding:t[2]?.padding,skipKerning:t[2]?.skipKerning},Ps(0,"BitmapFontManager.install(name, style, options) is deprecated, use BitmapFontManager.install({name, style, ...options})"));const i=e?.name;if(!i)throw new Error("[BitmapFontManager] Property `name` is required.");e={...this.defaultOptions,...e};const s=e.style,n=s instanceof yh?s:new yh(s),r=e.dynamicFill??this._canUseTintForStyle(n),o=new _h({style:n,overrideFill:r,skipKerning:e.skipKerning,padding:e.padding,resolution:e.resolution,overrideSize:!1,textureStyle:e.textureStyle}),a=function(t){if(""===t)return[];"string"==typeof t&&(t=[t]);const e=[];for(let i=0,s=t.length;i<s;i++){const s=t[i];if(Array.isArray(s)){if(2!==s.length)throw new Error(`[BitmapFont]: Invalid character range length, expecting 2 got ${s.length}.`);if(0===s[0].length||0===s[1].length)throw new Error("[BitmapFont]: Invalid character delimiter.");const t=s[0].charCodeAt(0),i=s[1].charCodeAt(0);if(i<t)throw new Error("[BitmapFont]: Invalid character range.");for(let s=t,n=i;s<=n;s++)e.push(String.fromCharCode(s))}else e.push(...Array.from(s))}if(0===e.length)throw new Error("[BitmapFont]: Empty set when resolving characters.");return e}(e.chars);return o.ensureCharacters(a.join("")),pr.set(`${i}-bitmap`,o),o.once("destroy",()=>pr.remove(`${i}-bitmap`)),o}uninstall(t){const e=`${t}-bitmap`,i=pr.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!(t._stroke||t.dropShadow&&0!==t.dropShadow.color||t._fill.fill||16777215!==t._fill.color)}};class Ch extends Lo{constructor(t,e){super();const{textures:i,data:s}=t;Object.keys(s.pages).forEach(t=>{const e=s.pages[parseInt(t,10)],n=i[e.id];this.pages.push({texture:n})}),Object.keys(s.chars).forEach(t=>{const e=s.chars[t],{frame:n,source:r,rotate:o}=i[e.page],a=As.transformRectCoords(e,n,o,new Ss),h=new Gs({frame:a,orig:new Ss(0,0,e.width,e.height),source:r,rotate:o});this.chars[t]={id:t.codePointAt(0),xOffset:e.xOffset,yOffset:e.yOffset,xAdvance:e.xAdvance,kerning:e.kerning??{},texture:h}}),this.baseRenderedFontSize=s.fontSize,this.baseMeasurementFontSize=s.fontSize,this.fontMetrics={ascent:0,descent:0,fontSize:s.fontSize},this.baseLineOffset=s.baseLineOffset,this.lineHeight=s.lineHeight,this.fontFamily=s.fontFamily,this.distanceField=s.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){Ah.install(t)}static uninstall(t){Ah.uninstall(t)}}const Sh={test:t=>"string"==typeof t&&t.startsWith("info face="),parse(t){const e=t.match(/^[a-z]+\s+.+$/gm),i={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const t in e){const s=e[t].match(/^[a-z]+/gm)[0],n=e[t].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),r={};for(const t in n){const e=n[t].split("="),i=e[0],s=e[1].replace(/"/gm,""),o=parseFloat(s),a=isNaN(o)?s:o;r[i]=a}i[s].push(r)}const s={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[n]=i.info,[r]=i.common,[o]=i.distanceField??[];o&&(s.distanceField={range:parseInt(o.distanceRange,10),type:o.fieldType}),s.fontSize=parseInt(n.size,10),s.fontFamily=n.face,s.lineHeight=parseInt(r.lineHeight,10);const a=i.page;for(let t=0;t<a.length;t++)s.pages.push({id:parseInt(a[t].id,10)||0,file:a[t].file});const h={};s.baseLineOffset=s.lineHeight-parseInt(r.base,10);const l=i.char;for(let t=0;t<l.length;t++){const e=l[t],i=parseInt(e.id,10);let n=e.letter??e.char??String.fromCharCode(i);"space"===n&&(n=" "),h[i]=n,s.chars[n]={id:i,page:parseInt(e.page,10)||0,x:parseInt(e.x,10),y:parseInt(e.y,10),width:parseInt(e.width,10),height:parseInt(e.height,10),xOffset:parseInt(e.xoffset,10),yOffset:parseInt(e.yoffset,10),xAdvance:parseInt(e.xadvance,10),kerning:{}}}const c=i.kerning||[];for(let t=0;t<c.length;t++){const e=parseInt(c[t].first,10),i=parseInt(c[t].second,10),n=parseInt(c[t].amount,10);s.chars[h[i]].kerning[h[e]]=n}return s}},Ih={test(t){const e=t;return"string"!=typeof e&&"getElementsByTagName"in e&&e.getElementsByTagName("page").length&&null!==e.getElementsByTagName("info")[0].getAttribute("face")},parse(t){const e={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},i=t.getElementsByTagName("info")[0],s=t.getElementsByTagName("common")[0],n=t.getElementsByTagName("distanceField")[0];n&&(e.distanceField={type:n.getAttribute("fieldType"),range:parseInt(n.getAttribute("distanceRange"),10)});const r=t.getElementsByTagName("page"),o=t.getElementsByTagName("char"),a=t.getElementsByTagName("kerning");e.fontSize=parseInt(i.getAttribute("size"),10),e.fontFamily=i.getAttribute("face"),e.lineHeight=parseInt(s.getAttribute("lineHeight"),10);for(let t=0;t<r.length;t++)e.pages.push({id:parseInt(r[t].getAttribute("id"),10)||0,file:r[t].getAttribute("file")});const h={};e.baseLineOffset=e.lineHeight-parseInt(s.getAttribute("base"),10);for(let t=0;t<o.length;t++){const i=o[t],s=parseInt(i.getAttribute("id"),10);let n=i.getAttribute("letter")??i.getAttribute("char")??String.fromCharCode(s);"space"===n&&(n=" "),h[s]=n,e.chars[n]={id:s,page:parseInt(i.getAttribute("page"),10)||0,x:parseInt(i.getAttribute("x"),10),y:parseInt(i.getAttribute("y"),10),width:parseInt(i.getAttribute("width"),10),height:parseInt(i.getAttribute("height"),10),xOffset:parseInt(i.getAttribute("xoffset"),10),yOffset:parseInt(i.getAttribute("yoffset"),10),xAdvance:parseInt(i.getAttribute("xadvance"),10),kerning:{}}}for(let t=0;t<a.length;t++){const i=parseInt(a[t].getAttribute("first"),10),s=parseInt(a[t].getAttribute("second"),10),n=parseInt(a[t].getAttribute("amount"),10);e.chars[h[s]].kerning[h[i]]=n}return e}},Mh=[".xml",".fnt"],Th={extension:{type:qi.CacheParser,name:"cacheBitmapFont"},test:t=>t instanceof Ch,getCacheableAssets(t,e){const i={};return t.forEach(t=>{i[t]=e,i[`${t}-bitmap`]=e}),i[`${e.fontFamily}-bitmap`]=e,i}},Ph={extension:{type:qi.LoadParser,priority:fr.Normal},name:"loadBitmapFont",id:"bitmap-font",test:t=>Mh.includes(mr.extname(t).toLowerCase()),testParse:async t=>Sh.test(t)||(t=>!("string"!=typeof t||!t.includes("<font>"))&&Ih.test(ir.get().parseXML(t)))(t),async parse(t,e,i){const s=Sh.test(t)?Sh.parse(t):(t=>Ih.parse(ir.get().parseXML(t)))(t),{src:n}=e,{pages:r}=s,o=[],a=s.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let t=0;t<r.length;++t){const e=r[t].file;let i=mr.join(mr.dirname(n),e);i=br(i,n),o.push({src:i,data:a})}const h=await i.load(o),l=o.map(t=>h[t.src]);return new Ch({data:s,textures:l},n)},async load(t,e){const i=await ir.get().fetch(t);return await i.text()},async unload(t,e,i){await Promise.all(t.pages.map(t=>i.unload(t.texture.source._sourceOrigin))),t.destroy()}};class Eh{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(t=>{this._assetList.push(t)}),this.verbose,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 Bh={extension:{type:qi.CacheParser,name:"cacheTextureArray"},test:t=>Array.isArray(t)&&t.every(t=>t instanceof Gs),getCacheableAssets:(t,e)=>{const i={};return t.forEach(t=>{e.forEach((e,s)=>{i[t+(0===s?"":s+1)]=e})}),i}},Rh={extension:{type:qi.DetectionParser,priority:1},test:async()=>me("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async t=>[...t,"avif"],remove:async t=>t.filter(t=>"avif"!==t)},kh=["png","jpg","jpeg"],Oh={extension:{type:qi.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async t=>[...t,...kh],remove:async t=>t.filter(t=>!kh.includes(t))},Dh="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope,Fh={extension:{type:qi.DetectionParser,priority:0},test:async()=>ye("video/mp4"),add:async t=>[...t,"mp4","m4v"],remove:async t=>t.filter(t=>"mp4"!==t&&"m4v"!==t)},Lh={extension:{type:qi.DetectionParser,priority:0},test:async()=>ye("video/ogg"),add:async t=>[...t,"ogv"],remove:async t=>t.filter(t=>"ogv"!==t)},jh={extension:{type:qi.DetectionParser,priority:0},test:async()=>ye("video/webm"),add:async t=>[...t,"webm"],remove:async t=>t.filter(t=>"webm"!==t)},Gh={extension:{type:qi.DetectionParser,priority:0},test:async()=>me("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async t=>[...t,"webp"],remove:async t=>t.filter(t=>"webp"!==t)},Uh=class t{constructor(){this.loadOptions={...t.defaultOptions},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()=>{let s=null,n=null;if((e.parser||e.loadParser)&&(n=this._parserHash[e.parser||e.loadParser],e.loadParser&&o(),n||o(e.parser||e.loadParser)),!n){for(let i=0;i<this.parsers.length;i++){const s=this.parsers[i];if(s.load&&s.test?.(t,e,this)){n=s;break}}if(!n)return o(),null}s=await n.load(t,e,this),i.parser=n;for(let t=0;t<this.parsers.length;t++){const n=this.parsers[t];n.parse&&n.parse&&await(n.testParse?.(s,e,this))&&(s=await n.parse(s,e,this)||s,i.parser=n)}return s})(),i}async load(e,i){this._parsersValidated||this._validateParsers();const s="function"==typeof i?{...t.defaultOptions,...this.loadOptions,onProgress:i}:{...t.defaultOptions,...this.loadOptions,...i||{}},{onProgress:n,onError:r,strategy:o,retryCount:a,retryDelay:h}=s;let l=0;const c={},d=yr(e),u=ur(e,t=>({alias:[t],src:t,data:{}})),p=u.reduce((t,e)=>t+(e.progressSize||1),0),g=u.map(async t=>{const e=mr.toAbsolute(t.src);c[t.src]||(await this._loadAssetWithRetry(e,t,{onProgress:n,onError:r,strategy:o,retryCount:a,retryDelay:h},c),l+=t.progressSize||1,n&&n(l/p))});return await Promise.all(g),d?c[u[0].src]:c}async unload(t){const e=ur(t,t=>({alias:[t],src:t})).map(async t=>{const e=mr.toAbsolute(t.src),i=this.promiseCache[e];if(i){const s=await i.promise;delete this.promiseCache[e],await(i.parser?.unload?.(s,t,this))}});await Promise.all(e)}_validateParsers(){this._parsersValidated=!0,this._parserHash=this._parsers.filter(t=>t.name||t.id).reduce((t,e)=>(e.name||e.id?(t[e.name]||t[e.id])&&o(e.id):o(),t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,s){let n=0;const{onError:r,strategy:o,retryCount:a,retryDelay:h}=i,l=t=>new Promise(e=>setTimeout(e,t));for(;;)try{return this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),void(s[e.src]=await this.promiseCache[t].promise)}catch(i){if(delete this.promiseCache[t],delete s[e.src],n++,"retry"===o&&!("retry"!==o||n>a)){r&&r(i,e),await l(h);continue}if("skip"===o)return void(r&&r(i,e));throw r&&r(i,e),new Error(`[Loader.load] Failed to load ${t}.\n${i}`)}}};Uh.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let zh=Uh;const Nh={extension:{type:qi.LoadParser,priority:fr.Low},name:"loadJson",id:"json",test:t=>xe(t,"application/json")||be(t,".json"),async load(t){const e=await ir.get().fetch(t);return await e.json()}},Vh={name:"loadTxt",id:"text",extension:{type:qi.LoadParser,priority:fr.Low,name:"loadTxt"},test:t=>xe(t,"text/plain")||be(t,".txt"),async load(t){const e=await ir.get().fetch(t);return await e.text()}},Hh=["normal","bold","100","200","300","400","500","600","700","800","900"],Wh=[".ttf",".otf",".woff",".woff2"],Jh=["font/ttf","font/otf","font/woff","font/woff2"],Zh=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i,Xh=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/,Yh={extension:{type:qi.LoadParser,priority:fr.Low},name:"loadWebFont",id:"web-font",test:t=>xe(t,Jh)||be(t,Wh),async load(t,e){const i=ir.get().getFontFaceSet();if(i){const s=[],n=e.data?.family??function(t){const e=mr.extname(t),i=mr.basename(t,e).replace(/(-|_)/g," ").toLowerCase().split(" ").map(t=>t.charAt(0).toUpperCase()+t.slice(1));let s=i.length>0;for(const t of i)if(!t.match(Zh)){s=!1;break}let n=i.join(" ");return s||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}(t),r=e.data?.weights?.filter(t=>Hh.includes(t))??["normal"],o=e.data??{};for(let e=0;e<r.length;e++){const a=r[e],h=new FontFace(n,`url(${ve(t)})`,{...o,weight:a});await h.load(),i.add(h),s.push(h)}return pr.has(`${n}-and-url`)?pr.get(`${n}-and-url`).entries.push({url:t,faces:s}):pr.set(`${n}-and-url`,{entries:[{url:t,faces:s}]}),1===s.length?s[0]:s}return o(),null},unload(t){const e=Array.isArray(t)?t:[t],i=e[0].family,s=pr.get(`${i}-and-url`),n=s.entries.find(t=>t.faces.some(t=>-1!==e.indexOf(t)));n.faces=n.faces.filter(t=>-1===e.indexOf(t)),0===n.faces.length&&(s.entries=s.entries.filter(t=>t!==n)),e.forEach(t=>{ir.get().getFontFaceSet().delete(t)}),0===s.entries.length&&pr.remove(`${i}-and-url`)}},Kh="image/svg+xml",Qh={extension:{type:qi.LoadParser,priority:fr.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test:t=>xe(t,Kh)||be(t,".svg"),async load(t,e,i){return e.data?.parseAsGraphicsContext??this.config.parseAsGraphicsContext?async function(t){let e;if(xe(t,Kh))if(t.includes(";base64,"))e=function(t){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let i="",s=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");s<t.length;){const n=e.indexOf(t.charAt(s++)),r=e.indexOf(t.charAt(s++)),o=e.indexOf(t.charAt(s++)),a=e.indexOf(t.charAt(s++)),h=n<<2|r>>4,l=(15&r)<<4|o>>2,c=(3&o)<<6|a;i+=String.fromCharCode(h),64!==o&&(i+=String.fromCharCode(l)),64!==a&&(i+=String.fromCharCode(c))}return i}(t.split(";base64,")[1]);else{const i=t.split(",")[1];e=decodeURIComponent(i)}else{const i=await ir.get().fetch(t);e=await i.text()}const i=new fh;return i.svg(e),i}(t):async function(t,e,i,s){xe(t,Kh);const n=ir.get().createImage();n.crossOrigin=s,n.src=t,await new Promise((t,e)=>{n.complete?t(n):(n.onload=()=>t(n),n.onerror=e)}),await n.decode();const r=e.data?.width??n.width,o=e.data?.height??n.height,a=e.data?.resolution||_e(t),h=Math.ceil(r*a),l=Math.ceil(o*a),c=ir.get().createCanvas(h,l),d=c.getContext("2d");d.imageSmoothingEnabled=!0,d.imageSmoothingQuality="high",d.drawImage(n,0,0,r*a,o*a);const{parseAsGraphicsContext:u,...p}=e.data??{};return we(new nr({resource:c,alphaMode:"premultiply-alpha-on-upload",resolution:a,...p}),i,t)}(t,e,i,this.config.crossOrigin)},unload(t){t.destroy(!0)}};let qh=null,$h=class{constructor(){qh||(qh=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n const WHITE_PNG = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";\n async function checkImageBitmap() {\n try {\n if (typeof createImageBitmap !== "function")\n return false;\n const response = await fetch(WHITE_PNG);\n const imageBlob = await response.blob();\n const imageBitmap = await createImageBitmap(imageBlob);\n return imageBitmap.width === 1 && imageBitmap.height === 1;\n } catch (_e) {\n return false;\n }\n }\n void checkImageBitmap().then((result) => {\n self.postMessage(result);\n });\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(qh)}};$h.revokeObjectURL=function(){qh&&(URL.revokeObjectURL(qh),qh=null)};let tl=null;class el{constructor(){tl||(tl=URL.createObjectURL(new Blob(['(function () {\n \'use strict\';\n\n async function loadImageBitmap(url, alphaMode) {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${url}: ${response.status} ${response.statusText}`);\n }\n const imageBlob = await response.blob();\n return alphaMode === "premultiplied-alpha" ? createImageBitmap(imageBlob, { premultiplyAlpha: "none" }) : createImageBitmap(imageBlob);\n }\n self.onmessage = async (event) => {\n try {\n const imageBitmap = await loadImageBitmap(event.data.data[0], event.data.data[1]);\n self.postMessage({\n data: imageBitmap,\n uuid: event.data.uuid,\n id: event.data.id\n }, [imageBitmap]);\n } catch (e) {\n self.postMessage({\n error: e,\n uuid: event.data.uuid,\n id: event.data.id\n });\n }\n };\n\n})();\n'],{type:"application/javascript"}))),this.worker=new Worker(tl)}}el.revokeObjectURL=function(){tl&&(URL.revokeObjectURL(tl),tl=null)};let il,sl=0;const nl=new class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return void 0!==this._isImageBitmapSupported||(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new $h;e.addEventListener("message",i=>{e.terminate(),$h.revokeObjectURL(),t(i.data)})})),this._isImageBitmapSupported}loadImageBitmap(t,e){return this._run("loadImageBitmap",[t,e?.data?.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){void 0===il&&(il=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers<il&&(this._createdWorkers++,t=(new el).worker,t.addEventListener("message",t=>{this._complete(t.data),this._returnWorker(t.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){void 0!==t.error?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),this._resolveHash[t.uuid]=null}async _run(t,e){await this._initWorkers();const i=new Promise((i,s)=>{this._queue.push({id:t,arguments:e,resolve:i,reject:s})});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[sl]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:sl++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t?.(new Error("WorkerManager destroyed"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}},rl=[".jpeg",".jpg",".png",".webp",".avif"],ol=["image/jpeg","image/png","image/webp","image/avif"],al={name:"loadTextures",id:"texture",extension:{type:qi.LoadParser,priority:fr.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test:t=>xe(t,ol)||be(t,rl),async load(t,e,i){let s=null;return s=globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await nl.isImageBitmapSupported()?await nl.loadImageBitmap(t,e):await async function(t,e){const i=await ir.get().fetch(t);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${t}: ${i.status} ${i.statusText}`);const s=await i.blob();return"premultiplied-alpha"===e?.data?.alphaMode?createImageBitmap(s,{premultiplyAlpha:"none"}):createImageBitmap(s)}(t,e):await new Promise((e,i)=>{s=ir.get().createImage(),s.crossOrigin=this.config.crossOrigin,s.src=t,s.complete?e(s):(s.onload=()=>{e(s)},s.onerror=i)}),we(new nr({resource:s,alphaMode:"premultiply-alpha-on-upload",resolution:e.data?.resolution||_e(t),...e.data}),i,t)},unload(t){t.destroy(!0)}},hl=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let ll,cl;const dl={name:"loadVideo",id:"video",extension:{type:qi.LoadParser,name:"loadVideo"},test(t){if(!ll||!cl){const{validVideoExtensions:t,validVideoMime:e}=function(){const t=[],e=[];for(const i of hl){const s=dr.MIME_TYPES[i.substring(1)]||`video/${i.substring(1)}`;ye(s)&&(t.push(i),e.includes(s)||e.push(s))}return{validVideoExtensions:t,validVideoMime:e}}();ll=t,cl=e}const e=xe(t,cl),i=be(t,ll);return e||i},async load(t,e,i){const s={...dr.defaultOptions,resolution:e.data?.resolution||_e(t),alphaMode:e.data?.alphaMode||await _(),...e.data},n=document.createElement("video"),r={preload:!1!==s.autoLoad?"auto":void 0,"webkit-playsinline":!1!==s.playsinline?"":void 0,playsinline:!1!==s.playsinline?"":void 0,muted:!0===s.muted?"":void 0,loop:!0===s.loop?"":void 0,autoplay:!1!==s.autoPlay?"":void 0};Object.keys(r).forEach(t=>{const e=r[t];void 0!==e&&n.setAttribute(t,e)}),!0===s.muted&&(n.muted=!0),function(t,e,i){void 0!==i||e.startsWith("data:")?!1!==i&&(t.crossOrigin="string"==typeof i?i:"anonymous"):t.crossOrigin=function(t,e=globalThis.location){if(t.startsWith("data:"))return"";e||(e=globalThis.location);const i=new URL(t,document.baseURI);return i.hostname!==e.hostname||i.port!==e.port||i.protocol!==e.protocol?"anonymous":""}(e)}(n,t,s.crossorigin);const o=document.createElement("source");let a;if(s.mime)a=s.mime;else if(t.startsWith("data:"))a=t.slice(5,t.indexOf(";"));else if(!t.startsWith("blob:")){const e=t.split("?")[0].slice(t.lastIndexOf(".")+1).toLowerCase();a=dr.MIME_TYPES[e]||`video/${e}`}return o.src=t,a&&(o.type=a),new Promise(r=>{const a=async()=>{const o=new dr({...s,resource:n});var h;n.removeEventListener("canplay",a),e.data.preload&&await(h=n,new Promise((t,e)=>{function i(){n(),t()}function s(t){n(),e(t)}function n(){h.removeEventListener("canplaythrough",i),h.removeEventListener("error",s)}h.addEventListener("canplaythrough",i),h.addEventListener("error",s),h.load()})),r(we(o,i,t))};s.preload&&!s.autoPlay&&n.load(),n.addEventListener("canplay",a),n.appendChild(o)})},unload(t){t.destroy(!0)}},ul={extension:{type:qi.ResolveParser,name:"resolveTexture"},test:al.test,parse:t=>({resolution:parseFloat(xr.RETINA_PREFIX.exec(t)?.[1]??"1"),format:t.split(".").pop(),src:t})},pl={extension:{type:qi.ResolveParser,priority:-2,name:"resolveJson"},test:t=>xr.RETINA_PREFIX.test(t)&&t.endsWith(".json"),parse:ul.parse},gl=new class{constructor(){this._detections=[],this._initialized=!1,this.resolver=new xr,this.loader=new zh,this.cache=pr,this._backgroundLoader=new Eh(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){if(this._initialized)return void o();if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let e=t.manifest;"string"==typeof e&&(e=await this.load(e)),this.resolver.addManifest(e)}const e=t.texturePreference?.resolution??1,i="number"==typeof e?[e]:e,s=await this._detectFormats({preferredFormats:t.texturePreference?.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:s,resolution:i}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...t.loadOptions})}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=yr(t),s=ur(t).map(t=>{if("string"!=typeof t){const e=this.resolver.getAlias(t);return e.some(t=>!this.resolver.hasKey(t))&&this.add(t),Array.isArray(e)?e[0]:e}return this.resolver.hasKey(t)||this.add({alias:t,src:t}),t}),n=this.resolver.resolve(s),r=await this._mapLoadToResolve(n,e);return i?r[s[0]]:r}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;"string"==typeof t&&(i=!0,t=[t]);const s=this.resolver.resolveBundle(t),n={},r=Object.keys(s);let o=0;const a=[],h=r.map((t,i)=>{const r=s[t],h=Object.values(r),l=[...new Set(h.flat())].reduce((t,e)=>t+(e.progressSize||1),0);return a.push(0),o+=l,this._mapLoadToResolve(r,t=>{a[i]=t*l,e?.(a.reduce((t,e)=>t+e,0)/o)}).then(e=>{n[t]=e})});return await Promise.all(h),i?n[t[0]]:n}async backgroundLoad(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),"string"==typeof t&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(t=>{this._backgroundLoader.add(Object.values(t))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if("string"==typeof t)return pr.get(t);const e={};for(let i=0;i<t.length;i++)e[i]=pr.get(t[i]);return e}async _mapLoadToResolve(t,e){const i=[...new Set(Object.values(t))];this._backgroundLoader.active=!1;const s=await this.loader.load(i,e);this._backgroundLoader.active=!0;const n={};return i.forEach(t=>{const e=s[t.src],i=[t.src];t.alias&&i.push(...t.alias),i.forEach(t=>{n[t]=e}),pr.set(i,e)}),n}async unload(t){this._initialized||await this.init();const e=ur(t).map(t=>"string"!=typeof t?t.src:t),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=ur(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(t=>this._unloadFromResolved(e[t]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(t=>{pr.remove(t.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((t,i)=>e.indexOf(t)===i),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(e=>e in t).forEach(i=>{e.config[i]=t[i]})})}};es.handleByList(qi.LoadParser,gl.loader.parsers).handleByList(qi.ResolveParser,gl.resolver.parsers).handleByList(qi.CacheParser,gl.cache.parsers).handleByList(qi.DetectionParser,gl.detections),es.add(Bh,Oh,Rh,Gh,Fh,Lh,jh,Nh,Vh,Yh,Qh,al,dl,Ph,Th,ul,pl);const fl={loader:qi.LoadParser,resolver:qi.ResolveParser,cache:qi.CacheParser,detection:qi.DetectionParser};es.handle(qi.Asset,t=>{const e=t.ref;Object.entries(fl).filter(([t])=>!!e[t]).forEach(([t,i])=>es.add(Object.assign(e[t],{extension:e[t].extension??i})))},t=>{const e=t.ref;Object.keys(fl).filter(t=>!!e[t]).forEach(t=>es.remove(e[t]))});class ml extends Yn{constructor(t={}){const{element:e,anchor:i,...s}=t;super({label:"DOMContainer",...s}),this.renderPipeId="dom",this.batched=!1,this._anchor=new ds(0,0),i&&(this.anchor=i),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set element(t){this._element!==t&&(this._element=t,this.onViewUpdate())}get element(){return this._element}updateBounds(){const t=this._bounds,e=this._element;if(!e)return t.minX=0,t.minY=0,t.maxX=0,void(t.maxY=0);const{offsetWidth:i,offsetHeight:s}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=s}destroy(t=!1){super.destroy(t),this._element?.parentNode?.removeChild(this._element),this._element=null,this._anchor=null}}class yl{constructor(t){this._attachedDomElements=[],this._renderer=t,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new Cr({domElement:this._domElement,renderer:this._renderer})}addRenderable(t,e){this._attachedDomElements.includes(t)||this._attachedDomElements.push(t)}updateRenderable(t){}validateRenderable(t){return!0}postrender(){const t=this._attachedDomElements;if(0!==t.length){this._canvasObserver.ensureAttached();for(let e=0;e<t.length;e++){const i=t[e],s=i.element;if(!i.parent||i.globalDisplayStatus<7)s?.remove(),t.splice(e,1),e--;else{this._domElement.contains(s)||(s.style.position="absolute",s.style.pointerEvents="auto",this._domElement.appendChild(s));const t=i.worldTransform,e=i._anchor,n=i.width*e.x,r=i.height*e.y;s.style.transformOrigin=`${n}px ${r}px`,s.style.transform=`matrix(${t.a}, ${t.b}, ${t.c}, ${t.d}, ${t.tx-n}, ${t.ty-r})`,s.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){this._renderer.runners.postrender.remove(this);for(let t=0;t<this._attachedDomElements.length;t++){const e=this._attachedDomElements[t];e.element?.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}yl.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"dom"};const xl=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(t){this.removeTickerListener(),this.events=t,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(t){this._pauseUpdate=t}addTickerListener(){!this._tickerAdded&&this.domElement&&(lr.system.add(this._tickerUpdate,this,rr.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(lr.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===t.pointerType||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:t.clientX,clientY:t.clientY,pointerType:t.pointerType,pointerId:t.pointerId}):new MouseEvent("mousemove",{clientX:t.clientX,clientY:t.clientY}))}_tickerUpdate(t){this._deltaTime+=t.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};class bl extends Sr{constructor(){super(...arguments),this.client=new ds,this.movement=new ds,this.offset=new ds,this.global=new ds,this.screen=new ds}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,s,n,r,o,a,h,l,c,d,u,p,g){throw new Error("Method not implemented.")}}class vl extends bl{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class _l extends bl{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}_l.DOM_DELTA_PIXEL=0,_l.DOM_DELTA_LINE=1,_l.DOM_DELTA_PAGE=2;const wl=new ds,Al=new ds;class Cl{constructor(t){this.dispatch=new as,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=t,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(t,e){this.mappingTable[t]||(this.mappingTable[t]=[]),this.mappingTable[t].push({fn:e,priority:0}),this.mappingTable[t].sort((t,e)=>t.priority-e.priority)}dispatchEvent(t,e){t.propagationStopped=!1,t.propagationImmediatelyStopped=!1,this.propagate(t,e),this.dispatch.emit(e||t.type,t)}mapEvent(t){if(!this.rootTarget)return;const e=this.mappingTable[t.type];if(e)for(let i=0,s=e.length;i<s;i++)e[i].fn(t);else o(t.type)}hitTest(t,e){xl.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,wl.set(t,e),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(t,e){if(!t.target)return;const i=t.composedPath();t.eventPhase=t.CAPTURING_PHASE;for(let s=0,n=i.length-1;s<n;s++)if(t.currentTarget=i[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=i.length-2;s>=0;s--)if(t.currentTarget=i[s],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(0===i.length)return;t.eventPhase=t.BUBBLING_PHASE;const s=Array.isArray(e)?e:[e];for(let e=i.length-1;e>=0;e--)s.forEach(s=>{t.currentTarget=i[e],this.notifyTarget(t,s)})}propagationPath(t){const e=[t];for(let i=0;i<2048&&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,s,n,r=!1){let o=!1;if(this._interactivePrune(t))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(xl.pauseUpdate=!1),t.interactiveChildren&&t.children){const a=t.children;for(let h=a.length-1;h>=0;h--){const l=a[h],c=this.hitTestMoveRecursive(l,this._isInteractive(e)?e:l.eventMode,i,s,n,r||n(t,i));if(c){if(c.length>0&&!c[c.length-1].parent)continue;const e=t.isInteractive();(c.length>0||e)&&(e&&this._allInteractiveElements.push(t),c.push(t)),0===this._hitElements.length&&(this._hitElements=c),o=!0}}}const a=this._isInteractive(e),h=t.isInteractive();return h&&h&&this._allInteractiveElements.push(t),r||this._hitElements.length>0?null:o?this._hitElements:a&&!n(t,i)&&s(t,i)?h?[t]:[]:null}hitTestRecursive(t,e,i,s,n){if(this._interactivePrune(t)||n(t,i))return null;if("dynamic"!==t.eventMode&&"dynamic"!==e||(xl.pauseUpdate=!1),t.interactiveChildren&&t.children){const r=t.children,o=i;for(let i=r.length-1;i>=0;i--){const a=r[i],h=this.hitTestRecursive(a,this._isInteractive(e)?e:a.eventMode,o,s,n);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const e=t.isInteractive();return(h.length>0||e)&&h.push(t),h}}}const r=this._isInteractive(e),o=t.isInteractive();return r&&s(t,i)?o?[t]:[]:null}_isInteractive(t){return"static"===t||"dynamic"===t}_interactivePrune(t){return!(t&&t.visible&&t.renderable&&t.measurable)||"none"===t.eventMode||"passive"===t.eventMode&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,Al),!t.hitArea.contains(Al.x,Al.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i<t.effects.length;i++){const s=t.effects[i];if(s.containsPoint&&!s.containsPoint(e,this.hitTestFn))return!0}return!1}hitTestFn(t,e){return!!t.hitArea||!!t?.containsPoint&&(t.worldTransform.applyInverse(e,Al),t.containsPoint(Al))}notifyTarget(t,e){if(!t.currentTarget.isInteractive())return;e??(e=t.type);const i=`on${e}`;t.currentTarget[i]?.(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 vl))return void o();const e=this.createPointerEvent(t);if(this.dispatchEvent(e,"pointerdown"),"touch"===e.pointerType)this.dispatchEvent(e,"touchstart");else if("mouse"===e.pointerType||"pen"===e.pointerType){const t=2===e.button;this.dispatchEvent(e,t?"rightdown":"mousedown")}this.trackingData(t.pointerId).pressTargetsByButton[t.button]=e.composedPath(),this.freeEvent(e)}mapPointerMove(t){if(!(t instanceof vl))return void o();this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const e=this.createPointerEvent(t);this._isPointerMoveEvent=!1;const i="mouse"===e.pointerType||"pen"===e.pointerType,s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.overTargets);if(s.overTargets?.length>0&&n!==e.target){const s="mousemove"===t.type?"mouseout":"pointerout",r=this.createPointerEvent(t,s,n);if(this.dispatchEvent(r,"pointerout"),i&&this.dispatchEvent(r,"mouseout"),!e.composedPath().includes(n)){const s=this.createPointerEvent(t,"pointerleave",n);for(s.eventPhase=s.AT_TARGET;s.target&&!e.composedPath().includes(s.target);)s.currentTarget=s.target,this.notifyTarget(s),i&&this.notifyTarget(s,"mouseleave"),s.target=s.target.parent;this.freeEvent(s)}this.freeEvent(r)}if(n!==e.target){const s="mousemove"===t.type?"mouseover":"pointerover",r=this.clonePointerEvent(e,s);this.dispatchEvent(r,"pointerover"),i&&this.dispatchEvent(r,"mouseover");let o=n?.parent;for(;o&&o!==this.rootTarget.parent&&o!==e.target;)o=o.parent;if(!o||o===this.rootTarget.parent){const t=this.clonePointerEvent(e,"pointerenter");for(t.eventPhase=t.AT_TARGET;t.target&&t.target!==n&&t.target!==this.rootTarget.parent;)t.currentTarget=t.target,this.notifyTarget(t),i&&this.notifyTarget(t,"mouseenter"),t.target=t.target.parent;this.freeEvent(t)}this.freeEvent(r)}const r=[],a=this.enableGlobalMoveEvents??!0;this.moveOnAll?r.push("pointermove"):this.dispatchEvent(e,"pointermove"),a&&r.push("globalpointermove"),"touch"===e.pointerType&&(this.moveOnAll?r.splice(1,0,"touchmove"):this.dispatchEvent(e,"touchmove"),a&&r.push("globaltouchmove")),i&&(this.moveOnAll?r.splice(1,0,"mousemove"):this.dispatchEvent(e,"mousemove"),a&&r.push("globalmousemove"),this.cursor=e.target?.cursor),r.length>0&&this.all(e,r),this._allInteractiveElements.length=0,this._hitElements.length=0,s.overTargets=e.composedPath(),this.freeEvent(e)}mapPointerOver(t){if(!(t instanceof vl))return void o();const e=this.trackingData(t.pointerId),i=this.createPointerEvent(t),s="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),s&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=i.target?.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),s&&this.notifyTarget(n,"mouseenter"),n.target=n.target.parent;e.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(n)}mapPointerOut(t){if(!(t instanceof vl))return void o();const e=this.trackingData(t.pointerId);if(e.overTargets){const i="mouse"===t.pointerType||"pen"===t.pointerType,s=this.findMountedTarget(e.overTargets),n=this.createPointerEvent(t,"pointerout",s);this.dispatchEvent(n),i&&this.dispatchEvent(n,"mouseout");const r=this.createPointerEvent(t,"pointerleave",s);for(r.eventPhase=r.AT_TARGET;r.target&&r.target!==this.rootTarget.parent;)r.currentTarget=r.target,this.notifyTarget(r),i&&this.notifyTarget(r,"mouseleave"),r.target=r.target.parent;e.overTargets=null,this.freeEvent(n),this.freeEvent(r)}this.cursor=null}mapPointerUp(t){if(!(t instanceof vl))return void o();const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.dispatchEvent(i,t?"rightup":"mouseup")}const s=this.trackingData(t.pointerId),n=this.findMountedTarget(s.pressTargetsByButton[t.button]);let r=n;if(n&&!i.composedPath().includes(n)){let e=n;for(;e&&!i.composedPath().includes(e);){if(i.currentTarget=e,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const t=2===i.button;this.notifyTarget(i,t?"rightupoutside":"mouseupoutside")}e=e.parent}delete s.pressTargetsByButton[t.button],r=e}if(r){const n=this.clonePointerEvent(i,"click");n.target=r,n.path=null,s.clicksByButton[t.button]||(s.clicksByButton[t.button]={clickCount:0,target:n.target,timeStamp:e});const o=s.clicksByButton[t.button];if(o.target===n.target&&e-o.timeStamp<200?++o.clickCount:o.clickCount=1,o.target=n.target,o.timeStamp=e,n.detail=o.clickCount,"mouse"===n.pointerType){const t=2===n.button;this.dispatchEvent(n,t?"rightclick":"click")}else"touch"===n.pointerType&&this.dispatchEvent(n,"tap");this.dispatchEvent(n,"pointertap"),this.freeEvent(n)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof vl))return void o();const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),s=this.createPointerEvent(t);if(i){let n=i;for(;n;)s.currentTarget=n,this.notifyTarget(s,"pointerupoutside"),"touch"===s.pointerType?this.notifyTarget(s,"touchendoutside"):"mouse"!==s.pointerType&&"pen"!==s.pointerType||this.notifyTarget(s,2===s.button?"rightupoutside":"mouseupoutside"),n=n.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(s)}mapWheel(t){if(!(t instanceof _l))return void o();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 s=this.allocateEvent(vl);return this.copyPointerData(t,s),this.copyMouseData(t,s),this.copyData(t,s),s.nativeEvent=t.nativeEvent,s.originalEvent=t,s.target=i??this.hitTest(s.global.x,s.global.y)??this._hitElements[0],"string"==typeof e&&(s.type=e),s}createWheelEvent(t){const e=this.allocateEvent(_l);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(vl);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 vl&&e instanceof vl&&(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 bl&&e instanceof bl&&(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.defaultPrevented=!1,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)if("fn"in i)i.once&&t.currentTarget.removeListener(e,i.fn,void 0,!0),i.fn.call(i.context,t);else for(let s=0,n=i.length;s<n&&!t.propagationImmediatelyStopped;s++)i[s].once&&t.currentTarget.removeListener(e,i[s].fn,void 0,!0),i[s].fn.call(i[s].context,t)}}const Sl={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Il=class t{constructor(e){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=e,this.rootBoundary=new Cl(null),xl.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new vl(null),this._rootWheelEvent=new _l(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...t.defaultEventFeatures},{set:(t,e,i)=>("globalMove"===e&&(this.rootBoundary.enableGlobalMoveEvents=i),t[e]=i,!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(e){const{canvas:i,resolution:s}=this.renderer;this.setTargetElement(i),this.resolution=s,t._defaultEventMode=e.eventMode??"passive",Object.assign(this.features,e.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){xl.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)}else e&&"string"==typeof t&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)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 t=0,i=e.length;t<i;t++){const i=e[t],s=this._bootstrapEvent(this._rootPointerEvent,i);this.rootBoundary.mapEvent(s)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(t){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,xl.pointerMoved();const e=this._normalizeToPointerData(t);for(let t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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":"",s=this._normalizeToPointerData(t);for(let t=0,e=s.length;t<e;t++){const e=this._bootstrapEvent(this._rootPointerEvent,s[t]);e.type+=i,this.rootBoundary.mapEvent(e)}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 t=0,i=e.length;t<i;t++){const i=this._bootstrapEvent(this._rootPointerEvent,e[t]);this.rootBoundary.mapEvent(i)}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,xl.domElement=t,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;xl.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;xl.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 s=this.domElement.isConnected?this.domElement.getBoundingClientRect():{width:this.domElement.width,height:this.domElement.height,left:0,top:0},n=1/this.resolution;t.x=(e-s.left)*(this.domElement.width/s.width)*n,t.y=(i-s.top)*(this.domElement.height/s.height)*n}_normalizeToPointerData(t){const e=[];if(this.supportsTouchEvents&&t instanceof TouchEvent)for(let i=0,s=t.changedTouches.length;i<s;i++){const s=t.changedTouches[i];void 0===s.button&&(s.button=0),void 0===s.buttons&&(s.buttons=1),void 0===s.isPrimary&&(s.isPrimary=1===t.touches.length&&"touchstart"===t.type),void 0===s.width&&(s.width=s.radiusX||1),void 0===s.height&&(s.height=s.radiusY||1),void 0===s.tiltX&&(s.tiltX=0),void 0===s.tiltY&&(s.tiltY=0),void 0===s.pointerType&&(s.pointerType="touch"),void 0===s.pointerId&&(s.pointerId=s.identifier||0),void 0===s.pressure&&(s.pressure=s.force||.5),void 0===s.twist&&(s.twist=0),void 0===s.tangentialPressure&&(s.tangentialPressure=0),void 0===s.layerX&&(s.layerX=s.offsetX=s.clientX),void 0===s.layerY&&(s.layerY=s.offsetY=s.clientY),s.isNormalized=!0,s.type=t.type,e.push(s)}else if(!globalThis.MouseEvent||t instanceof MouseEvent&&!(this.supportsPointerEvents&&t instanceof globalThis.PointerEvent)){const i=t;void 0===i.isPrimary&&(i.isPrimary=!0),void 0===i.width&&(i.width=1),void 0===i.height&&(i.height=1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="mouse"),void 0===i.pointerId&&(i.pointerId=1),void 0===i.pressure&&(i.pressure=.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(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,"pointerleave"===t.type&&(t.type="pointerout"),t.type.startsWith("mouse")&&(t.type=t.type.replace("mouse","pointer")),t.type.startsWith("touch")&&(t.type=Sl[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}};Il.extension={name:"events",type:[qi.WebGLSystem,qi.CanvasSystem,qi.WebGPUSystem],priority:-1},Il.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let Ml=Il;const Tl={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"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(t){this.eventMode=t?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??Ml.defaultEventMode},set eventMode(t){this._internalEventMode=t},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(t,e,i){const s="boolean"==typeof i&&i||"object"==typeof i&&i.capture,n="object"==typeof i?i.signal:void 0,r="object"==typeof i&&!0===i.once,o="function"==typeof e?void 0:e;t=s?`${t}capture`:t;const a="function"==typeof e?e:e.handleEvent,h=this;n&&n.addEventListener("abort",()=>{h.off(t,a,o)}),r?h.once(t,a,o):h.on(t,a,o)},removeEventListener(t,e,i){const s="function"==typeof e?void 0:e;t="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${t}capture`:t,e="function"==typeof e?e:e.handleEvent,this.off(t,e,s)},dispatchEvent(t){if(!(t instanceof Sr))throw new Error("Container cannot propagate events outside of the Federated Events API");return t.defaultPrevented=!1,t.path=null,t.target=this,t.manager.dispatchEvent(t),!t.defaultPrevented}};var Pl="struct GlobalFilterUniforms {\n uInputSize: vec4<f32>,\n uInputPixel: vec4<f32>,\n uInputClamp: vec4<f32>,\n uOutputFrame: vec4<f32>,\n uGlobalFrame: vec4<f32>,\n uOutputTexture: vec4<f32>,\n};\n\n@group(0) @binding(0) var <uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler: sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: vec2<f32>\n};\n\nfn filterVertexPosition(aPosition: vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0 * gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord(aPosition: vec2<f32>) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n";class El extends xo{constructor(){super({gpuProgram:ro.from({vertex:{source:Pl,entryPoint:"mainVertex"},fragment:{source:Pl,entryPoint:"mainFragment"},name:"passthrough-filter"}),glProgram:to.from({vertex:"in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n",fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n",name:"passthrough-filter"})})}}class Bl{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){"pushFilter"===t.action?this._renderer.filter.push(t):"popFilter"===t.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}Bl.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"filter"};const Rl=new ps,kl=new ya({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class Ol{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new zs,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class Dl{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new lo({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 co({}),this.renderer=t}get activeBackTexture(){return this._activeFilterData?.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,s=this._pushFilterData();s.skip=!1,s.filters=i,s.container=t.container,s.outputRenderSurface=e.renderTarget.renderSurface;const n=e.renderTarget.renderTarget.colorTexture.source,r=n.resolution,o=n.antialias;if(i.every(t=>!t.enabled))return void(s.skip=!0);const a=s.bounds;if(this._calculateFilterArea(t,a),this._calculateFilterBounds(s,e.renderTarget.rootViewPort,o,r,1),s.skip)return;const h=this._getPreviousFilterData(),l=this._findFilterResolution(r);let c=0,d=0;h&&(c=h.bounds.minX,d=h.bounds.minY),this._calculateGlobalFrame(s,c,d,l,n.width,n.height),this._setupFilterTextures(s,a,e,h)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const s=t.source,n=s.resolution,r=s.antialias;if(e.every(t=>!t.enabled))return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,r,n,0),i.skip)return t;const a=n;this._calculateGlobalFrame(i,0,0,a,s.width,s.height),i.outputRenderSurface=Nn.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=Gs.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const h=i.outputRenderSurface;return h.source.alphaMode="premultiplied-alpha",h}pop(){const t=this.renderer,e=this._popFilterData();e.skip||(t.globalUniforms.pop(),t.renderTarget.finishRenderPass(),this._activeFilterData=e,this._applyFiltersToTexture(e,!1),e.blendRequired&&Nn.returnTexture(e.backTexture),Nn.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const s=t.colorTexture.source._resolution,n=Nn.getOptimalTexture(e.width,e.height,s,!1);let r=e.minX,o=e.minY;i&&(r-=i.minX,o-=i.minY),r=Math.floor(r*s),o=Math.floor(o*s);const a=Math.ceil(e.width*s),h=Math.ceil(e.height*s);return this.renderer.renderTarget.copyToTexture(t,n,{x:r,y:o},{width:a,height:h},{x:0,y:0}),n}applyFilter(t,e,i,s){const n=this.renderer,r=this._activeFilterData,o=r.outputRenderSurface===i,a=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,h=this._findFilterResolution(a);let l=0,c=0;if(o){const t=this._findPreviousFilterOffset();l=t.x,c=t.y}this._updateFilterUniforms(e,i,r,l,c,h,o,s);const d=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(d,e,n)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,s=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),n=e.worldTransform.copyTo(ps.shared),r=e.renderGroup||e.parentRenderGroup;return r&&r.cacheToLocalTransform&&n.prepend(r.cacheToLocalTransform),n.invert(),s.prepend(n),s.scale(1/e.texture.orig.width,1/e.texture.orig.height),s.translate(e.anchor.x,e.anchor.y),s}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new El),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const t=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(t,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(e.source,1),this._globalFilterBindGroup.setResource(e.source.style,2),t.groups[0]=this._globalFilterBindGroup,i.encoder.draw({geometry:kl,shader:t,state:t._state,topology:"triangle-list"}),i.type===uo.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,s){if(t.backTexture=Gs.EMPTY,t.inputTexture=Nn.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const n=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(n,e,s?.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,s,n,r){const o=t.globalFrame;o.x=e*s,o.y=i*s,o.width=n*s,o.height=r*s}_updateFilterUniforms(t,e,i,s,n,r,o,a){const h=this._filterGlobalUniforms.uniforms,l=h.uOutputFrame,c=h.uInputSize,d=h.uInputPixel,u=h.uInputClamp,p=h.uGlobalFrame,g=h.uOutputTexture;o?(l[0]=i.bounds.minX-s,l[1]=i.bounds.minY-n):(l[0]=0,l[1]=0),l[2]=t.frame.width,l[3]=t.frame.height,c[0]=t.source.width,c[1]=t.source.height,c[2]=1/c[0],c[3]=1/c[1],d[0]=t.source.pixelWidth,d[1]=t.source.pixelHeight,d[2]=1/d[0],d[3]=1/d[1],u[0]=.5*d[2],u[1]=.5*d[3],u[2]=t.frame.width*c[2]-.5*d[2],u[3]=t.frame.height*c[3]-.5*d[3];const f=this.renderer.renderTarget.rootRenderTarget.colorTexture;p[0]=s*r,p[1]=n*r,p[2]=f.source.width*r,p[3]=f.source.height*r,e instanceof Gs&&(e.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!a),e instanceof Gs?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=m.width,g[1]=m.height),g[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(t){let e=this._filterStackIndex-1;for(;e>0&&this._filterStack[e].skip;)--e;return e>0&&this._filterStack[e].inputTexture?this._filterStack[e].inputTexture.source._resolution:t}_findPreviousFilterOffset(){let t=0,e=0,i=this._filterStackIndex;for(;i>0;){i--;const s=this._filterStack[i];if(!s.skip){t=s.bounds.minX,e=s.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?function(t,e){e.clear();const i=e.matrix;for(let i=0;i<t.length;i++){const s=t[i];if(s.globalDisplayStatus<7)continue;const n=s.renderGroup??s.parentRenderGroup;e.matrix=n?.isCachedAsTexture?Rl.copyFrom(n.textureOffsetInverseTransform).append(s.worldTransform):n?._parentCacheAsTextureRenderGroup?Rl.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(s.groupTransform):s.worldTransform,e.addBounds(s.bounds)}e.matrix=i}(t.renderables,e):t.filterEffect.filterArea?(e.clear(),e.addRect(t.filterEffect.filterArea),e.applyMatrix(t.container.worldTransform)):t.container.getFastGlobalBounds(!0,e),t.container){const i=(t.container.renderGroup||t.container.parentRenderGroup).cacheToLocalTransform;i&&e.applyMatrix(i)}}_applyFiltersToTexture(t,e){const i=t.inputTexture,s=t.bounds,n=t.filters,r=t.firstEnabledIndex,o=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),r===o)n[r].apply(this,i,t.outputRenderSurface,e);else{let i=t.inputTexture;const a=Nn.getOptimalTexture(s.width,s.height,i.source._resolution,!1);let h=a;for(let t=r;t<o;t++){const e=n[t];if(!e.enabled)continue;e.apply(this,i,h,!0);const s=i;i=h,h=s}n[o].apply(this,i,t.outputRenderSurface,e),Nn.returnTexture(a)}}_calculateFilterBounds(t,e,i,s,n){const r=this.renderer,a=t.bounds,h=t.filters;let l=1/0,c=0,d=!0,u=!1,p=!1,g=!0,f=-1,m=-1;for(let t=0;t<h.length;t++){const e=h[t];if(e.enabled){if(-1===f&&(f=t),m=t,l=Math.min(l,"inherit"===e.resolution?s:e.resolution),c+=e.padding,"off"===e.antialias?d=!1:"inherit"===e.antialias&&d&&(d=i),e.clipToViewport||(g=!1),!(e.compatibleRenderers&r.type)){p=!1;break}if(e.blendRequired&&!(r.backBuffer?.useBackBuffer??1)){o(),p=!1;break}p=!0,u||(u=e.blendRequired)}}p?(g&&a.fitBounds(0,e.width/s,0,e.height/s),a.scale(l).ceil().scale(1/l).pad((0|c)*n),a.isPositive?(t.antialias=d,t.resolution=l,t.blendRequired=u,t.firstEnabledIndex=f,t.lastEnabledIndex=m):t.skip=!0):t.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let t,e=this._filterStackIndex-1;for(;e>0&&(e--,t=this._filterStack[e],t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new Ol),this._filterStackIndex++,t}}Dl.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"filter"};var Fl="struct GlobalFilterUniforms {\n uInputSize:vec4<f32>,\n uInputPixel:vec4<f32>,\n uInputClamp:vec4<f32>,\n uOutputFrame:vec4<f32>,\n uGlobalFrame:vec4<f32>,\n uOutputTexture:vec4<f32>,\n};\n\nstruct MaskUniforms {\n uFilterMatrix:mat3x3<f32>,\n uMaskClamp:vec4<f32>,\n uAlpha:f32,\n uInverse:f32,\n};\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler : sampler;\n\n@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;\n@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) filterUv : vec2<f32>,\n};\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);\n}\n\nfn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>\n{\n return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n}\n\nfn getSize() -> vec2<f32>\n{\n return gfu.uGlobalFrame.zw;\n}\n\n@vertex\nfn mainVertex(\n @location(0) aPosition : vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition),\n getFilterCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) filterUv: vec2<f32>,\n @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n\n var maskClamp = filterUniforms.uMaskClamp;\n var uAlpha = filterUniforms.uAlpha;\n\n var clip = step(3.5,\n step(maskClamp.x, filterUv.x) +\n step(maskClamp.y, filterUv.y) +\n step(filterUv.x, maskClamp.z) +\n step(filterUv.y, maskClamp.w));\n\n var mask = textureSample(uMaskTexture, uSampler, filterUv);\n var source = textureSample(uTexture, uSampler, uv);\n var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);\n\n var a: f32 = alphaMul * mask.r * uAlpha * clip;\n\n if (filterUniforms.uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n return source * a;\n}\n";class Ll extends xo{constructor(t){const{sprite:e,...i}=t,s=new js(e.texture),n=new lo({uFilterMatrix:{value:new ps,type:"mat3x3<f32>"},uMaskClamp:{value:s.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"}});super({...i,gpuProgram:ro.from({vertex:{source:Fl,entryPoint:"mainVertex"},fragment:{source:Fl,entryPoint:"mainFragment"}}),glProgram:to.from({vertex:"in vec2 aPosition;\n\nout vec2 vTextureCoord;\nout vec2 vMaskCoord;\n\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\nuniform mat3 uFilterMatrix;\n\nvec4 filterVertexPosition( vec2 aPosition )\n{\n vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n \n position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord( vec2 aPosition )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvec2 getFilterCoord( vec2 aPosition )\n{\n return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;\n} \n\nvoid main(void)\n{\n gl_Position = filterVertexPosition(aPosition);\n vTextureCoord = filterTextureCoord(aPosition);\n vMaskCoord = getFilterCoord(aPosition);\n}\n",fragment:"in vec2 vMaskCoord;\nin vec2 vTextureCoord;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMaskTexture;\n\nuniform float uAlpha;\nuniform vec4 uMaskClamp;\nuniform float uInverse;\n\nout vec4 finalColor;\n\nvoid main(void)\n{\n float clip = step(3.5,\n step(uMaskClamp.x, vMaskCoord.x) +\n step(uMaskClamp.y, vMaskCoord.y) +\n step(vMaskCoord.x, uMaskClamp.z) +\n step(vMaskCoord.y, uMaskClamp.w));\n\n // TODO look into why this is needed\n float npmAlpha = uAlpha;\n vec4 original = texture(uTexture, vTextureCoord);\n vec4 masky = texture(uMaskTexture, vMaskCoord);\n float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n float a = alphaMul * masky.r * npmAlpha * clip;\n\n if (uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n finalColor = original * a;\n}\n",name:"mask-filter"}),clipToViewport:!1,resources:{filterUniforms:n,uMaskTexture:e.texture.source}}),this.sprite=e,this._textureMatrix=s}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}apply(t,e,i,s){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,s)}}class jl extends Yn{constructor(t){t instanceof fh&&(t={context:t});const{context:e,roundPixels:i,...s}=t||{};super({label:"Graphics",...s}),this.renderPipeId="graphics",this._context=e||(this._ownedContext=new fh),this._context.on("update",this.onViewUpdate,this),this.didViewUpdate=!0,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}updateBounds(){}containsPoint(t){return this._context.containsPoint(t)}destroy(t){this._ownedContext&&!t?this._ownedContext.destroy(t):!0!==t&&!0!==t?.context||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 jl(this._context.clone()):(this._ownedContext=null,new jl(this._context))}lineStyle(t,e,i){Ps(0,"Graphics#lineStyle is no longer needed. Use Graphics#setStrokeStyle to set the stroke style.");const s={};return t&&(s.width=t),e&&(s.color=e),i&&(s.alpha=i),this.context.strokeStyle=s,this}beginFill(t,e){Ps(0,"Graphics#beginFill is no longer needed. Use Graphics#fill to fill the shape with the desired style.");const i={};return void 0!==t&&(i.color=t),void 0!==e&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){Ps(0,"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===fh.defaultStrokeStyle.width&&t.color===fh.defaultStrokeStyle.color&&t.alpha===fh.defaultStrokeStyle.alpha||this.context.stroke(),this}drawCircle(...t){return Ps(0,"Graphics#drawCircle has been renamed to Graphics#circle"),this._callContextMethod("circle",t)}drawEllipse(...t){return Ps(0,"Graphics#drawEllipse has been renamed to Graphics#ellipse"),this._callContextMethod("ellipse",t)}drawPolygon(...t){return Ps(0,"Graphics#drawPolygon has been renamed to Graphics#poly"),this._callContextMethod("poly",t)}drawRect(...t){return Ps(0,"Graphics#drawRect has been renamed to Graphics#rect"),this._callContextMethod("rect",t)}drawRoundedRect(...t){return Ps(0,"Graphics#drawRoundedRect has been renamed to Graphics#roundRect"),this._callContextMethod("roundRect",t)}drawStar(...t){return Ps(0,"Graphics#drawStar has been renamed to Graphics#star"),this._callContextMethod("star",t)}}const Gl=class t extends ya{constructor(...e){let i=e[0]??{};i instanceof Float32Array&&(Ps(0,"use new MeshGeometry({ positions, uvs, indices }) instead"),i={positions:i,uvs:e[1],indices:e[2]}),i={...t.defaultOptions,...i};const s=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let n=i.uvs;n||(n=i.positions?new Float32Array(s.length):new Float32Array([0,0,1,0,1,1,0,1]));const r=i.indices||new Uint32Array([0,1,2,0,2,3]),o=i.shrinkBuffersToFit;super({attributes:{aPosition:{buffer:new ma({data:s,label:"attribute-mesh-positions",shrinkToFit:o,usage:fa.VERTEX|fa.COPY_DST}),format:"float32x2",stride:8,offset:0},aUV:{buffer:new ma({data:n,label:"attribute-mesh-uvs",shrinkToFit:o,usage:fa.VERTEX|fa.COPY_DST}),format:"float32x2",stride:8,offset:0}},indexBuffer:new ma({data:r,label:"index-mesh-buffer",shrinkToFit:o,usage:fa.INDEX|fa.COPY_DST}),topology:i.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}};Gl.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let Ul=Gl;class zl extends Yn{constructor(...t){let e=t[0];e instanceof ya&&(Ps(0,"Mesh: use new Mesh({ geometry, shader }) instead"),e={geometry:e,shader:t[1]},t[3]&&(Ps(0,"Mesh: drawMode argument has been removed, use geometry.topology instead"),e.geometry.topology=t[3]));const{geometry:i,shader:s,texture:n,roundPixels:r,state:o,...a}=e;super({label:"Mesh",...a}),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=s??null,this.texture=n??s?.texture??Gs.WHITE,this.state=o??mo.for2d(),this._geometry=i,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=r??!1}get material(){return Ps(0,"mesh.material property has been removed, use mesh.shader instead"),this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){this._geometry!==t&&(this._geometry?.off("update",this.onViewUpdate,this),t.on("update",this.onViewUpdate,this),this._geometry=t,this.onViewUpdate())}get geometry(){return this._geometry}set texture(t){t||(t=Gs.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.shader&&(this.shader.texture=t),this._texture=t,this.onViewUpdate())}get texture(){return this._texture}get batched(){return!this._shader&&!(12&this.state.data)&&this._geometry instanceof Ul&&("auto"===this._geometry.batchMode?this._geometry.positions.length/2<=100:"batch"===this._geometry.batchMode)}get bounds(){return this._geometry.bounds}updateBounds(){this._bounds=this._geometry.bounds}containsPoint(t){const{x:e,y:i}=t;if(!this.bounds.containsPoint(e,i))return!1;const s=this.geometry.getBuffer("aPosition").data,n="triangle-strip"===this.geometry.topology?3:1;if(this.geometry.getIndex()){const t=this.geometry.getIndex().data,r=t.length;for(let o=0;o+2<r;o+=n){const n=2*t[o],r=2*t[o+1],a=2*t[o+2];if(Ae(e,i,s[n],s[n+1],s[r],s[r+1],s[a],s[a+1]))return!0}}else{const t=s.length/2;for(let r=0;r+2<t;r+=n){const t=2*r,n=2*(r+1),o=2*(r+2);if(Ae(e,i,s[t],s[t+1],s[n],s[n+1],s[o],s[o+1]))return!0}}return!1}destroy(t){if(super.destroy(t),"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._geometry?.off("update",this.onViewUpdate,this),this._texture=null,this._geometry=null,this._shader=null,this._gpuData=null}}class Nl extends Kn{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const{animationSpeed:i=1,autoPlay:s=!1,autoUpdate:n=!0,loop:r=!0,onComplete:o=null,onFrameChange:a=null,onLoop:h=null,textures:l,updateAnchor:c=!1,...d}=e,[u]=l;super({...d,texture:u instanceof Gs?u:u.texture}),this._textures=null,this._durations=null,this._autoUpdate=n,this._isConnectedToTicker=!1,this.animationSpeed=i,this.loop=r,this.updateAnchor=c,this.onComplete=o,this.onFrameChange=a,this.onLoop=h,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=l,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(lr.shared.add(this.update,this,rr.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,s=this.currentFrame;if(null!==this._durations){let t=this._currentTime%1*this._durations[this.currentFrame];for(t+=i/60*1e3;t<0;)this._currentTime--,t+=this._durations[this.currentFrame];const s=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);t>=this._durations[this.currentFrame];)t-=this._durations[this.currentFrame]*s,this._currentTime+=s;this._currentTime+=t/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()):s!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFrame<s||this.animationSpeed<0&&this.currentFrame>s)&&this.onLoop(),this._updateTexture())}_updateTexture(){const t=this.currentFrame;this._previousFrame!==t&&(this._previousFrame=t,this.texture=this._textures[t],this.updateAnchor&&this.texture.defaultAnchor&&this.anchor.copyFrom(this.texture.defaultAnchor),this.onFrameChange&&this.onFrameChange(this.currentFrame))}destroy(t=!1){if("boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._textures.forEach(t=>{this.texture!==t&&t.destroy(e)})}this._textures=[],this._durations=null,this.stop(),super.destroy(t),this.onComplete=null,this.onFrameChange=null,this.onLoop=null}static fromFrames(t){const e=[];for(let i=0;i<t.length;++i)e.push(Gs.from(t[i]));return new Nl(e)}static fromImages(t){const e=[];for(let i=0;i<t.length;++i)e.push(Gs.from(t[i]));return new Nl(e)}get totalFrames(){return this._textures.length}get textures(){return this._textures}set textures(t){if(t[0]instanceof Gs)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?(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(lr.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class Vl{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t??new ps,this.observer=e,this.position=new ns(this,0,0),this.scale=new ns(this,1,1),this.pivot=new ns(this,0,0),this.skew=new ns(this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1}get matrix(){const t=this._matrix;return this.dirty?(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.dirty=!1,t):t}_onUpdate(t){this.dirty=!0,t===this.skew&&this.updateSkew(),this.observer?._onUpdate(this)}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.dirty=!0}toString(){return`[pixi.js/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}) ]`}setFromMatrix(t){t.decompose(this),this.dirty=!0}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this._onUpdate(this.skew))}}const Hl=class t extends Yn{constructor(...e){let i=e[0]||{};i instanceof Gs&&(i={texture:i}),e.length>1&&(Ps(0,"use new TilingSprite({ texture, width:100, height:100 }) instead"),i.width=e[1],i.height=e[2]),i={...t.defaultOptions,...i};const{texture:s,anchor:n,tilePosition:r,tileScale:o,tileRotation:a,width:h,height:l,applyAnchorToTexture:c,roundPixels:d,...u}=i??{};super({label:"TilingSprite",...u}),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new ns({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=c,this.texture=s,this._width=h??s.width,this._height=l??s.height,this._tileTransform=new Vl({observer:{_onUpdate:()=>this.onViewUpdate()}}),n&&(this.anchor=n),this.tilePosition=r,this.tileScale=o,this.tileRotation=a,this.roundPixels=d??!1}static from(e,i={}){return new t("string"==typeof e?{texture:pr.get(e),...i}:{texture:e,...i})}get uvRespectAnchor(){return Ps(0,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Ps(0,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture=t}get clampMargin(){return this._texture.textureMatrix.clampMargin}set clampMargin(t){this._texture.textureMatrix.clampMargin=t}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}get tilePosition(){return this._tileTransform.position}set tilePosition(t){this._tileTransform.position.copyFrom(t)}get tileScale(){return this._tileTransform.scale}set tileScale(t){"number"==typeof t?this._tileTransform.scale.set(t):this._tileTransform.scale.copyFrom(t)}set tileRotation(t){this._tileTransform.rotation=t}get tileRotation(){return this._tileTransform.rotation}get tileTransform(){return this._tileTransform}set texture(t){t||(t=Gs.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}set width(t){this._width=t,this.onViewUpdate()}get width(){return this._width}set height(t){this._height=t,this.onViewUpdate()}get height(){return this._height}setSize(t,e){"object"==typeof t&&(e=t.height??t.width,t=t.width),this._width=t,this._height=e??t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,s=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}containsPoint(t){const e=this._width,i=this._height,s=-e*this._anchor._x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this._anchor._y,t.y>=n&&t.y<=n+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,"boolean"==typeof t?t:t?.texture){const e="boolean"==typeof t?t:t?.textureSource;this._texture.destroy(e)}this._texture=null}};Hl.defaultOptions={texture:Gs.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Wl=Hl;class Jl extends Yn{constructor(t,e){const{text:i,resolution:s,style:n,anchor:r,width:o,height:a,roundPixels:h,...l}=t;super({...l}),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=i??"",this.style=n,this.resolution=s??null,this.allowChildren=!1,this._anchor=new ns({_onUpdate:()=>{this.onViewUpdate()}}),r&&(this.anchor=r),this.roundPixels=h??!1,void 0!==o&&(this.width=o),void 0!==a&&(this.height=a)}get anchor(){return this._anchor}set anchor(t){"number"==typeof t?this._anchor.set(t):this._anchor.copyFrom(t)}set text(t){t=t.toString(),this._text!==t&&(this._text=t,this.onViewUpdate())}get text(){return this._text}set resolution(t){this._autoResolution=null===t,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){t||(t={}),this._style?.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 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){"object"==typeof t?(e=t.height??t.width,t=t.width):e??(e=t),void 0!==t&&this._setWidth(t,this.bounds.width),void 0!==e&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,s=-e*this.anchor.x;let n=0;return t.x>=s&&t.x<=s+e&&(n=-i*this.anchor.y,t.y>=n&&t.y<=n+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,("boolean"==typeof t?t:t?.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}let Zl=null,Xl=null;const Yl=new Ss,Kl=new class{getCanvasAndContext(t){const{text:e,style:i,resolution:s=1}=t,n=i._getFinalPadding(),r=No.measureText(e||" ",i),o=Math.ceil(Math.ceil(Math.max(1,r.width)+2*n)*s),a=Math.ceil(Math.ceil(Math.max(1,r.height)+2*n)*s),h=xh.getOptimalCanvasAndContext(o,a);return this._renderTextToCanvas(e,i,n,s,h),{canvasAndContext:h,frame:i.trim?Ie({canvas:h.canvas,width:o,height:a,resolution:1,output:Yl}):Yl.set(0,0,o,a)}}returnCanvasAndContext(t){xh.returnCanvasAndContext(t)}_renderTextToCanvas(t,e,i,s,n){const{canvas:r,context:o}=n,a=dt(e),h=No.measureText(t||" ",e),l=h.lines,c=h.lineHeight,d=h.lineWidths,u=h.maxLineWidth,p=h.fontProperties,g=r.height;if(o.resetTransform(),o.scale(s,s),o.textBaseline=e.textBaseline,e._stroke?.width){const t=e._stroke;o.lineWidth=t.width,o.miterLimit=t.miterLimit,o.lineJoin=t.join,o.lineCap=t.cap}let f,m;o.font=a;const y=e.dropShadow?2:1;for(let t=0;t<y;++t){const r=e.dropShadow&&0===t,a=r?Math.ceil(Math.max(1,g)+2*i):0,y=a*s;if(r){o.fillStyle="black",o.strokeStyle="black";const t=e.dropShadow,i=t.color,n=t.alpha;o.shadowColor=yn.shared.setValue(i).setAlpha(n).toRgbaString();const r=t.blur*s,a=t.distance*s;o.shadowBlur=r,o.shadowOffsetX=Math.cos(t.angle)*a,o.shadowOffsetY=Math.sin(t.angle)*a+y}else{if(o.fillStyle=e._fill?ge(e._fill,o,h,2*i):null,e._stroke?.width){const t=.5*e._stroke.width+2*i;o.strokeStyle=ge(e._stroke,o,h,t)}o.shadowColor="black"}let x=(c-p.fontSize)/2;c-p.fontSize<0&&(x=0);const b=e._stroke?.width??0;for(let t=0;t<l.length;t++)f=b/2,m=b/2+t*c+p.ascent+x,"right"===e.align?f+=u-d[t]:"center"===e.align&&(f+=(u-d[t])/2),e._stroke?.width&&this._drawLetterSpacing(l[t],e,n,f+i,m+i-a,!0),void 0!==e._fill&&this._drawLetterSpacing(l[t],e,n,f+i,m+i-a)}}_drawLetterSpacing(t,e,i,s,n,r=!1){const{context:o}=i,a=e.letterSpacing;let h=!1;if(No.experimentalLetterSpacingSupported&&(No.experimentalLetterSpacing?(o.letterSpacing=`${a}px`,o.textLetterSpacing=`${a}px`,h=!0):(o.letterSpacing="0px",o.textLetterSpacing="0px")),0===a||h)return void(r?o.strokeText(t,s,n):o.fillText(t,s,n));let l=s;const c=No.graphemeSegmenter(t);let d=o.measureText(t).width,u=0;for(let t=0;t<c.length;++t){const e=c[t];r?o.strokeText(e,l,n):o.fillText(e,l,n);let i="";for(let e=t+1;e<c.length;++e)i+=c[e];u=o.measureText(i).width,l+=d-u+a,d=u}}};class Ql extends Jl{constructor(...t){const e=function(t){let e=t[0]??{};return("string"==typeof e||t[1])&&(Ps(0,'use new Text({ text: "hi!", style }) instead'),e={text:e,style:t[1]}),e}(t);super(e,yh),this.renderPipeId="text",e.textureStyle&&(this.textureStyle=e.textureStyle instanceof ks?e.textureStyle:new ks(e.textureStyle))}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,s=0;if(this._style.trim){const{frame:t,canvasAndContext:e}=Kl.getCanvasAndContext({text:this.text,style:this._style,resolution:1});Kl.returnCanvasAndContext(e),i=t.width,s=t.height}else{const t=No.measureText(this._text,this._style);i=t.width,s=t.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*s,t.maxY=t.minY+s}}const ql="http://www.w3.org/2000/svg",$l="http://www.w3.org/1999/xhtml";class tc{constructor(){this.svgRoot=document.createElementNS(ql,"svg"),this.foreignObject=document.createElementNS(ql,"foreignObject"),this.domElement=document.createElementNS($l,"div"),this.styleElement=document.createElementNS($l,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:s}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(s),this.image=ir.get().createImage()}destroy(){this.svgRoot.remove(),this.foreignObject.remove(),this.styleElement.remove(),this.domElement.remove(),this.image.src="",this.image.remove(),this.svgRoot=null,this.foreignObject=null,this.styleElement=null,this.domElement=null,this.image=null,this.canvasAndContext=null}}let ec;class ic{constructor(){this._tempState=mo.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const s=t.renderer,n=this._didUploadHash[i.uid];s.shader.bind(i,n),n||(this._didUploadHash[i.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const s=e.textures.textures;for(let t=0;t<e.textures.count;t++)i.texture.bind(s[t],t);i.geometry.draw(e.topology,e.size,e.start)}}ic.extension={type:[qi.WebGLPipesAdaptor],name:"batch"};const sc=mo.for2d();class nc{start(t,e,i){const s=t.renderer,n=s.encoder,r=i.gpuProgram;this._shader=i,this._geometry=e,n.setGeometry(e,r),sc.blendMode="normal",s.pipeline.getPipeline(e,r,sc);const o=s.globalUniforms.bindGroup;n.resetBindGroup(1),n.setBindGroup(0,o,r)}execute(t,e){const i=this._shader.gpuProgram,s=t.renderer,n=s.encoder;if(!e.bindGroup){const t=e.textures;e.bindGroup=ft(t.textures,t.count,s.limits.maxBatchableTextures)}sc.blendMode=e.blendMode;const r=s.bindGroup.getBindGroup(e.bindGroup,i,1),o=s.pipeline.getPipeline(this._geometry,i,sc,e.topology);e.bindGroup._touch(s.textureGC.count),n.setPipeline(o),n.renderPassEncoder.setBindGroup(1,r),n.renderPassEncoder.drawIndexed(e.size,1,e.start)}}nc.extension={type:[qi.WebGPUPipesAdaptor],name:"batch"};const rc=class t{constructor(t,e){this.state=mo.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=t,this._adaptor=e,this._adaptor.init?.(this)}static getBatcher(t){return new this._availableBatchers[t]}buildStart(t){let e=this._batchersByInstructionSet[t.uid];e||(e=this._batchersByInstructionSet[t.uid]=Object.create(null),e.default||(e.default=new La({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=e,this._activeBatch=this._activeBatches.default;for(const t in this._activeBatches)this._activeBatches[t].begin()}addToBatch(e,i){if(this._activeBatch.name!==e.batcherName){this._activeBatch.break(i);let s=this._activeBatches[e.batcherName];s||(s=this._activeBatches[e.batcherName]=t.getBatcher(e.batcherName),s.begin()),this._activeBatch=s}this._activeBatch.add(e)}break(t){this._activeBatch.break(t)}buildEnd(t){this._activeBatch.break(t);const e=this._activeBatches;for(const t in e){const i=e[t],s=i.geometry;s.indexBuffer.setDataWithSize(i.indexBuffer,i.indexSize,!0),s.buffers[0].setDataWithSize(i.attributeBuffer.float32View,i.attributeSize,!1)}}upload(t){const e=this._batchersByInstructionSet[t.uid];for(const t in e){const i=e[t],s=i.geometry;i.dirty&&(i.dirty=!1,s.buffers[0].update(4*i.attributeSize))}}execute(t){if("startBatch"===t.action){const e=t.batcher,i=e.geometry,s=e.shader;this._adaptor.start(this,i,s)}this._adaptor.execute(this,t)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const t in this._activeBatches)this._activeBatches[t].destroy();this._activeBatches=null}};rc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"batch"},rc._availableBatchers=Object.create(null);let oc=rc;es.handleByMap(qi.Batcher,oc._availableBatchers),es.add(La);const ac={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},hc={...ac,vertex:{...ac.vertex,header:ac.vertex.header.replace("group(1)","group(2)")}},lc={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}},cc={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},dc={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}},uc=new zs;class pc extends Sn{constructor(){super(),this.filters=[new Ll({sprite:new Kn(Gs.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(t){this.filters[0].sprite=t}get inverse(){return this.filters[0].inverse}set inverse(t){this.filters[0].inverse=t}}class gc{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){const s=this._renderer;if(s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1,maskedContainer:e}),t.inverse=e._maskOptions.inverse,t.renderMaskToTexture){const e=t.mask;e.includeInBuild=!0,e.collectRenderables(i,s,null),e.includeInBuild=!1}s.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:t,maskedContainer:e,inverse:e._maskOptions.inverse,canBundle:!1})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1})}execute(t){const e=this._renderer,i=t.mask.renderMaskToTexture;if("pushMaskBegin"===t.action){const s=_n.get(pc);if(s.inverse=t.inverse,i){t.mask.mask.measurable=!0;const i=h(t.mask.mask,!0,uc);t.mask.mask.measurable=!1,i.ceil();const n=e.renderTarget.renderTarget.colorTexture.source,r=Nn.getOptimalTexture(i.width,i.height,n._resolution,n.antialias);e.renderTarget.push(r,!0),e.globalUniforms.push({offset:i,worldColor:4294967295});const o=s.sprite;o.texture=r,o.worldTransform.tx=i.minX,o.worldTransform.ty=i.minY,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer,filterTexture:r})}else s.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:s,maskedContainer:t.maskedContainer})}else if("pushMaskEnd"===t.action){const t=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===uo.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:t.maskedContainer,filterEffect:t.filterEffect,canBundle:!1})}else if("popMaskEnd"===t.action){e.filter.pop();const t=this._activeMaskStage.pop();i&&Nn.returnTexture(t.filterTexture),_n.return(t.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}gc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"alphaMask"};class fc{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 s=this._colorStack;s[this._colorStackIndex]=s[this._colorStackIndex-1]&t.mask;const n=this._colorStack[this._colorStackIndex];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const s=this._colorStack;this._colorStackIndex--;const n=s[this._colorStackIndex-1];n!==this._currentColor&&(this._currentColor=n,i.add({renderPipeId:"colorMask",colorMask:n,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}fc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"colorMask"};class mc{constructor(t){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=t}push(t,e,i){var s;const n=t,r=this._renderer;r.renderPipes.batch.break(i),r.renderPipes.blendMode.setBlendMode(n.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const o=n.mask;o.includeInBuild=!0,this._maskHash.has(n)||this._maskHash.set(n,{instructionsStart:0,instructionsLength:0});const a=this._maskHash.get(n);a.instructionsStart=i.instructionSize,o.collectRenderables(i,r,null),o.includeInBuild=!1,r.renderPipes.batch.break(i),i.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:t,inverse:e._maskOptions.inverse,canBundle:!1});const h=i.instructionSize-a.instructionsStart-1;a.instructionsLength=h;const l=r.renderTarget.renderTarget.uid;(s=this._maskStackHash)[l]??(s[l]=0)}pop(t,e,i){const s=t,n=this._renderer;n.renderPipes.batch.break(i),n.renderPipes.blendMode.setBlendMode(s.mask,"none",i),i.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:e._maskOptions.inverse,canBundle:!1});const r=this._maskHash.get(t);for(let t=0;t<r.instructionsLength;t++)i.instructions[i.instructionSize++]=i.instructions[r.instructionsStart++];i.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(t){var e;const i=this._renderer,s=i.renderTarget.renderTarget.uid;let n=(e=this._maskStackHash)[s]??(e[s]=0);"pushMaskBegin"===t.action?(i.renderTarget.ensureDepthStencil(),i.stencil.setStencilMode(ra.RENDERING_MASK_ADD,n),n++,i.colorMask.setMask(0)):"pushMaskEnd"===t.action?(t.inverse?i.stencil.setStencilMode(ra.INVERSE_MASK_ACTIVE,n):i.stencil.setStencilMode(ra.MASK_ACTIVE,n),i.colorMask.setMask(15)):"popMaskBegin"===t.action?(i.colorMask.setMask(0),0!==n?i.stencil.setStencilMode(ra.RENDERING_MASK_REMOVE,n):(i.renderTarget.clear(null,wo.STENCIL),i.stencil.setStencilMode(ra.DISABLED,n)),n--):"popMaskEnd"===t.action&&(t.inverse?i.stencil.setStencilMode(ra.INVERSE_MASK_ACTIVE,n):i.stencil.setStencilMode(ra.MASK_ACTIVE,n),i.colorMask.setMask(15)),this._maskStackHash[s]=n}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}mc.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"stencilMask"};var yc=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(yc||{});class xc{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}}class bc{constructor(t){this._gpuBuffers=Object.create(null),this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_gpuBuffers")}destroy(){this._renderer=null,this._gl=null,this._gpuBuffers=null,this._boundBufferBases=null}contextChange(){this._gl=this._renderer.gl,this._gpuBuffers=Object.create(null),this._maxBindings=this._renderer.limits.maxUniformBindings}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;this._boundBufferBases[e]!==t&&(this._boundBufferBases[e]=t,t._lastBindBaseLocation=e,i.bindBufferBase(i.UNIFORM_BUFFER,e,t.buffer))}nextBindBase(t){this._bindCallId++,this._minBaseLocation=0,t&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(t){let e=this.getLastBindBaseLocation(t);if(e>=this._minBaseLocation)return t._lastBindCallId=this._bindCallId,e;let i=0,s=this._nextBindBaseIndex;for(;i<2;){s>=this._maxBindings&&(s=this._minBaseLocation,i++);const t=this._boundBufferBases[s];if(!t||t._lastBindCallId!==this._bindCallId)break;s++}return e=s,this._nextBindBaseIndex=s+1,i>=2?-1:(t._lastBindCallId=this._bindCallId,this._boundBufferBases[e]=null,e)}getLastBindBaseLocation(t){const e=t._lastBindBaseLocation;return this._boundBufferBases[e]===t?e:-1}bindBufferRange(t,e,i,s){const{_gl:n}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,n.bindBufferRange(n.UNIFORM_BUFFER,e||0,t.buffer,256*i,s||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 s=t.data,n=t.descriptor.usage&fa.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return s?i.byteLength>=s.byteLength?e.bufferSubData(i.type,0,s,0,t._updateSize/s.BYTES_PER_ELEMENT):(i.byteLength=s.byteLength,e.bufferData(i.type,s,n)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,n)),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],s=this._gl;e||s.deleteBuffer(i.buffer),this._gpuBuffers[t.uid]=null}createGLBuffer(t){const{_gl:e}=this;let i=yc.ARRAY_BUFFER;t.descriptor.usage&fa.INDEX?i=yc.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&fa.UNIFORM&&(i=yc.UNIFORM_BUFFER);const s=new xc(e.createBuffer(),i);return this._gpuBuffers[t.uid]=s,t.on("destroy",this.onBufferDestroy,this),s}resetState(){this._boundBufferBases=Object.create(null)}}bc.extension={type:[qi.WebGLSystem],name:"buffer"};const vc=class t{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(e){e={...t.defaultOptions,...e};let i=this.multiView=e.multiView;if(e.context&&i&&(o(),i=!1),this.canvas=i?ir.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const t=this._renderer.background.alpha<1,i=e.premultipliedAlpha??!0,s=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:t,premultipliedAlpha:i,antialias:s,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(t){if(!this.multiView)return void(t!==this.canvas&&o());const{canvas:e}=this;(e.width<t.width||e.height<t.height)&&(e.width=Math.max(t.width,t.width),e.height=Math.max(t.height,t.height))}initFromContext(t){this.gl=t,this.webGLVersion=t instanceof ir.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 s=this.canvas;if(2===t&&(i=s.getContext("webgl2",e)),!i&&(i=s.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(1===this.webGLVersion)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(()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const t=this._renderer.view.canvas;this._renderer=null,t.removeEventListener("webglcontextlost",this.handleContextLost),t.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&!e.stencil&&o();const i=this.supports,s=2===this.webGLVersion,n=this.extensions;i.uint32Indices=s||!!n.uint32ElementIndex,i.uniformBufferObject=s,i.vertexArrayObject=s||!!n.vertexArrayObject,i.srgbTextures=s||!!n.srgb,i.nonPowOf2wrapping=s,i.nonPowOf2mipmaps=s,i.msaa=s,i.uint32Indices||o()}};vc.extension={type:[qi.WebGLSystem],name:"context"},vc.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let _c=vc;var wc=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(wc||{}),Ac=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(Ac||{}),Cc=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(Cc||{});const Sc={uint8x2:Cc.UNSIGNED_BYTE,uint8x4:Cc.UNSIGNED_BYTE,sint8x2:Cc.BYTE,sint8x4:Cc.BYTE,unorm8x2:Cc.UNSIGNED_BYTE,unorm8x4:Cc.UNSIGNED_BYTE,snorm8x2:Cc.BYTE,snorm8x4:Cc.BYTE,uint16x2:Cc.UNSIGNED_SHORT,uint16x4:Cc.UNSIGNED_SHORT,sint16x2:Cc.SHORT,sint16x4:Cc.SHORT,unorm16x2:Cc.UNSIGNED_SHORT,unorm16x4:Cc.UNSIGNED_SHORT,snorm16x2:Cc.SHORT,snorm16x4:Cc.SHORT,float16x2:Cc.HALF_FLOAT,float16x4:Cc.HALF_FLOAT,float32:Cc.FLOAT,float32x2:Cc.FLOAT,float32x3:Cc.FLOAT,float32x4:Cc.FLOAT,uint32:Cc.UNSIGNED_INT,uint32x2:Cc.UNSIGNED_INT,uint32x3:Cc.UNSIGNED_INT,uint32x4:Cc.UNSIGNED_INT,sint32:Cc.INT,sint32x2:Cc.INT,sint32x3:Cc.INT,sint32x4:Cc.INT},Ic={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class Mc{constructor(t){this._geometryVaoHash=Object.create(null),this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._renderer.renderableGC.addManagedHash(this,"_geometryVaoHash")}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=t=>e.bindVertexArrayOES(t),t.deleteVertexArray=t=>e.deleteVertexArrayOES(t));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(t,e,s,n)=>{i.drawArraysInstancedANGLE(t,e,s,n)},t.drawElementsInstanced=(t,e,s,n,r)=>{i.drawElementsInstancedANGLE(t,e,s,n,r)},t.vertexAttribDivisor=(t,e)=>i.vertexAttribDivisorANGLE(t,e)),this._activeGeometry=null,this._activeVao=null,this._geometryVaoHash=Object.create(null)}bind(t,e){const i=this.gl;this._activeGeometry=t;const s=this.getVao(t,e);this._activeVao!==s&&(this._activeVao=s,i.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;i<t.buffers.length;i++){const s=t.buffers[i];e.updateBuffer(s)}}checkCompatibility(t,e){const i=t.attributes,s=e._attributeData;for(const t in s)if(!i[t])throw new Error(`shader and geometry incompatible, geometry missing the "${t}" attribute`)}getSignature(t,e){const i=t.attributes,s=e._attributeData,n=["g",t.uid];for(const t in i)s[t]&&n.push(t,s[t].location);return n.join("-")}getVao(t,e){return this._geometryVaoHash[t.uid]?.[e._key]||this.initGeometryVao(t,e)}initGeometryVao(t,e,i=!0){const s=this._renderer.gl,n=this._renderer.buffer;this._renderer.shader._getProgramData(e),this.checkCompatibility(t,e);const r=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 a=o[r];if(a)return o[e._key]=a,a;Me(t,e._attributeData);const h=t.buffers;a=s.createVertexArray(),s.bindVertexArray(a);for(let t=0;t<h.length;t++){const e=h[t];n.bind(e)}return this.activateVao(t,e),o[e._key]=a,o[r]=a,s.bindVertexArray(null),a}onGeometryDestroy(t,e){const i=this._geometryVaoHash[t.uid],s=this.gl;if(i){if(e)for(const t in i)this._activeVao!==i[t]&&this.unbind(),s.deleteVertexArray(i[t]);this._geometryVaoHash[t.uid]=null}}destroyAll(t=!1){const e=this.gl;for(const i in this._geometryVaoHash){if(t)for(const t in this._geometryVaoHash[i]){const s=this._geometryVaoHash[i];this._activeVao!==s&&this.unbind(),e.deleteVertexArray(s[t])}this._geometryVaoHash[i]=null}}activateVao(t,e){const i=this._renderer.gl,s=this._renderer.buffer,n=t.attributes;t.indexBuffer&&s.bind(t.indexBuffer);let r=null;for(const t in n){const o=n[t],a=o.buffer,h=s.getGlBuffer(a),l=e._attributeData[t];if(l){r!==h&&(s.bind(a),r=h);const t=l.location;i.enableVertexAttribArray(t);const e=R(o.format),n=Te(o.format);if("int"===l.format?.substring(1,4)?i.vertexAttribIPointer(t,e.size,n,o.stride,o.offset):i.vertexAttribPointer(t,e.size,n,e.normalised,o.stride,o.offset),o.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const e=o.divisor??1;i.vertexAttribDivisor(t,e)}}}}}draw(t,e,i,s){const{gl:n}=this._renderer,r=this._activeGeometry,o=Ic[t||r.topology];if(s??(s=r.instanceCount),r.indexBuffer){const t=r.indexBuffer.data.BYTES_PER_ELEMENT,a=2===t?n.UNSIGNED_SHORT:n.UNSIGNED_INT;1!==s?n.drawElementsInstanced(o,e||r.indexBuffer.data.length,a,(i||0)*t,s):n.drawElements(o,e||r.indexBuffer.data.length,a,(i||0)*t)}else 1!==s?n.drawArraysInstanced(o,i||0,e||r.getSize(),s):n.drawArrays(o,i||0,e||r.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,this._geometryVaoHash=null}}Mc.extension={type:[qi.WebGLSystem],name:"geometry"};const Tc=new ya({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),Pc=class t{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(e={}){const{useBackBuffer:i,antialias:s}={...t.defaultOptions,...e};this.useBackBuffer=i,this._antialias=s,this._renderer.context.supports.msaa||(o(),this._antialias=!1),this._state=mo.for2d();const n=new to({vertex:"\n attribute vec2 aPosition;\n out vec2 vUv;\n\n void main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n\n vUv = (aPosition + 1.0) / 2.0;\n\n // flip dem UVs\n vUv.y = 1.0 - vUv.y;\n }",fragment:"\n in vec2 vUv;\n out vec4 finalColor;\n\n uniform sampler2D uTexture;\n\n void main() {\n finalColor = texture(uTexture, vUv);\n }",name:"big-triangle"});this._bigTriangleShader=new po({glProgram:n,resources:{uTexture:Gs.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const e=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=e.colorTexture,t.target=this._getBackBufferTexture(e.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:Tc,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new Gs({source:new Ds({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)}};Pc.extension={type:[qi.WebGLSystem],name:"backBuffer",priority:1},Pc.defaultOptions={useBackBuffer:!1};let Ec=Pc;class Bc{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(8&t),!!(4&t),!!(2&t),!!(1&t)))}}Bc.extension={type:[qi.WebGLSystem],name:"colorMask"};class Rc{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:s,state:n,skipSync:r,topology:o,size:a,start:h,instanceCount:l}=t;e.shader.bind(s,r),e.geometry.bind(i,e.shader._activeProgram),n&&e.state.set(n),e.geometry.draw(o,a,h,l??i.instanceCount)}destroy(){this._renderer=null}}Rc.extension={type:[qi.WebGLSystem],name:"encoder"};class kc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=bt(this.maxTextures,t);const e=2===this._renderer.context.webGLVersion;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}kc.extension={type:[qi.WebGLSystem],name:"limits"};class Oc{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this.msaaRenderBuffer=[]}}const Dc=[];Dc[ra.NONE]=void 0,Dc[ra.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Dc[ra.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Dc[ra.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Dc[ra.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Dc[ra.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class Fc{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:ra.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.resetState()}onRenderTargetChange(t){if(this._activeRenderTarget===t)return;this._activeRenderTarget=t;let e=this._renderTargetStencilState[t.uid];e||(e=this._renderTargetStencilState[t.uid]={stencilMode:ra.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=ra.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,n=Dc[t],r=this._stencilCache;i.stencilMode=t,i.stencilReference=e,t!==ra.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),t===r.stencilMode&&r.stencilReference===e||(r.stencilMode=t,r.stencilReference=e,s.stencilFunc(this._comparisonFuncMapping[n.stencilBack.compare],e,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[n.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST))}}Fc.extension={type:[qi.WebGLSystem],name:"stencil"};class Lc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!D())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 ma({data:new Float32Array(e.layout.size/4),usage:fa.UNIFORM|fa.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 s=Object.keys(t.uniformStructures).map(e=>t.uniformStructures[e]),n=this._adaptor.createUboElements(s),r=this._generateUboSync(n.uboElements);i=this._syncFunctionHash[e]={layout:n,syncFunction:r}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const s=this.getUniformGroupData(t);t.buffer||(t.buffer=new ma({data:new Float32Array(s.layout.size/4),usage:fa.UNIFORM|fa.COPY_DST}));let n=null;return e||(e=t.buffer.data,n=t.buffer.dataInt32),i||(i=0),s.syncFunction(t.uniforms,e,n,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 jc={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64},Gc=[{type:"mat3x3<f32>",test:t=>void 0!==t.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:t=>"vec2<f32>"===t.type&&1===t.size&&void 0!==t.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:t=>"vec4<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:t=>"vec3<f32>"===t.type&&1===t.size&&void 0!==t.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}],Uc={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":Be(3,2),"mat4x2<f32>":Be(4,2),"mat2x3<f32>":Be(2,3),"mat4x3<f32>":Be(4,3),"mat2x4<f32>":Be(2,4),"mat3x4<f32>":Be(3,4)},zc={...Uc,"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "};class Nc extends Lc{constructor(){super({createUboElements:Pe,generateUboSync:ke})}}Nc.extension={type:[qi.WebGLSystem],name:"ubo"};class Vc{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Ss}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new Ss}copyToTexture(t,e,i,s,n){const r=this._renderTargetSystem,o=this._renderer,a=r.getGpuRenderTarget(t),h=o.gl;return this.finishRenderPass(t),h.bindFramebuffer(h.FRAMEBUFFER,a.resolveTargetFramebuffer),o.texture.bind(e,0),h.copyTexSubImage2D(h.TEXTURE_2D,0,n.x,n.y,i.x,i.y,s.width,s.height),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem,r=t.colorTexture,o=n.getGpuRenderTarget(t);let a=s.y;t.isRoot&&(a=r.pixelHeight-s.height),t.colorTextures.forEach(t=>{this._renderer.texture.unbind(t)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,o.framebuffer);const l=this._viewPortCache;l.x===s.x&&l.y===a&&l.width===s.width&&l.height===s.height||(l.x=s.x,l.y=a,l.width=s.width,l.height=s.height,h.viewport(s.x,a,s.width,s.height)),o.depthStencilRenderBuffer||!t.stencil&&!t.depth||this._initStencil(o),this.clear(t,e,i)}finishRenderPass(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);if(!e.msaa)return;const i=this._renderer.gl;i.bindFramebuffer(i.FRAMEBUFFER,e.resolveTargetFramebuffer),i.bindFramebuffer(i.READ_FRAMEBUFFER,e.framebuffer),i.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,i.COLOR_BUFFER_BIT,i.NEAREST),i.bindFramebuffer(i.FRAMEBUFFER,e.framebuffer)}initGpuRenderTarget(t){const e=this._renderer.gl,i=new Oc;return t.colorTexture instanceof sr?(this._renderer.context.ensureCanvasSize(t.colorTexture.resource),i.framebuffer=null,i):(this._initColor(t,i),e.bindFramebuffer(e.FRAMEBUFFER,null),i)}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(t=>{e.deleteRenderbuffer(t)}),t.msaaRenderBuffer=null}clear(t,e,i){if(!e)return;const s=this._renderTargetSystem;"boolean"==typeof e&&(e=e?wo.ALL:wo.NONE);const n=this._renderer.gl;if(e&wo.COLOR){i??(i=s.defaultClearColor);const t=this._clearColorCache,e=i;t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]||(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],n.clearColor(e[0],e[1],e[2],e[3]))}n.clear(e)}resizeGpuRenderTarget(t){if(t.isRoot)return;const e=this._renderTargetSystem.getGpuRenderTarget(t);this._resizeColor(t,e),(t.stencil||t.depth)&&this._resizeStencil(e)}_initColor(t,e){const i=this._renderer,s=i.gl,n=s.createFramebuffer();if(e.resolveTargetFramebuffer=n,s.bindFramebuffer(s.FRAMEBUFFER,n),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((t,n)=>{const r=t.source;r.antialias&&(i.context.supports.msaa?e.msaa=!0:o()),i.texture.bindSource(r,0);const a=i.texture.getGlSource(r).texture;s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+n,3553,a,0)}),e.msaa){const i=s.createFramebuffer();e.framebuffer=i,s.bindFramebuffer(s.FRAMEBUFFER,i),t.colorTextures.forEach((t,i)=>{const n=s.createRenderbuffer();e.msaaRenderBuffer[i]=n})}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((t,e)=>{0!==e&&t.source.resize(i.width,i.height,i._resolution)}),e.msaa){const i=this._renderer,s=i.gl,n=e.framebuffer;s.bindFramebuffer(s.FRAMEBUFFER,n),t.colorTextures.forEach((t,n)=>{const r=t.source;i.texture.bindSource(r,0);const o=i.texture.getGlSource(r).internalFormat,a=e.msaaRenderBuffer[n];s.bindRenderbuffer(s.RENDERBUFFER,a),s.renderbufferStorageMultisample(s.RENDERBUFFER,4,o,r.pixelWidth,r.pixelHeight),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+n,s.RENDERBUFFER,a)})}}_initStencil(t){if(null===t.framebuffer)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,2===this._renderer.context.webGLVersion?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&sr.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&sr.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}}const Hc=new Map;bn.register(Hc);const Wc=class t{constructor(i={}){if(this.uid=e("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,i={...t.defaultOptions,...i},this.stencil=i.stencil,this.depth=i.depth,this.isRoot=i.isRoot,"number"==typeof i.colorTextures){this._managedColorTextures=!0;for(let t=0;t<i.colorTextures;t++)this.colorTextures.push(new Ds({width:i.width,height:i.height,resolution:i.resolution,antialias:i.antialias}))}else{this.colorTextures=[...i.colorTextures.map(t=>t.source)];const t=this.colorTexture.source;this.resize(t.width,t.height,t._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(i.depthStencilTexture||this.stencil)&&(i.depthStencilTexture instanceof Gs||i.depthStencilTexture instanceof Ds?this.depthStencilTexture=i.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 Ds({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,s=!1){this.dirtyId++,this.colorTextures.forEach((n,r)=>{s&&0===r||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)}};Wc.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Jc=Wc;class Zc{constructor(t){this.rootViewPort=new Ss,this.viewport=new Ss,this.onRenderTargetChange=new Ao("onRenderTargetChange"),this.projectionMatrix=new ps,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuRenderTargetHash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:s}){this._renderTargetStack.length=0,this.push(t,e,i,s),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=function(t){const e=t.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement&&document.body.contains(e)}(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(t,e=!0,i,s){const n=this.getRenderTarget(t),r=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 a=n.colorTexture,h=this.viewport,l=a.pixelWidth,c=a.pixelHeight;if(!s&&t instanceof Gs&&(s=t.frame),s){const t=a._resolution;h.x=s.x*t+.5|0,h.y=s.y*t+.5|0,h.width=s.width*t+.5|0,h.height=s.height*t+.5|0}else h.x=0,h.y=0,h.width=l,h.height=c;return function(t,e,i,s,n,r){const o=r?1:-1;t.identity(),t.a=1/s*2,t.d=o*(1/n*2),t.tx=-1-0*t.a,t.ty=-o-0*t.d}(this.projectionMatrix,0,0,h.width/a.resolution,h.height/a.resolution,!n.isRoot),this.adaptor.startRenderPass(n,e,i,h),r&&this.onRenderTargetChange.emit(n),n}clear(t,e=wo.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=wo.ALL,i,s){const n=this.bind(t,e,i,s);return this._renderTargetStack.push({renderTarget:n,frame:s}),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,s,n){i.x<0&&(s.width+=i.x,n.x-=i.x,i.x=0),i.y<0&&(s.height+=i.y,n.y-=i.y,i.y=0);const{pixelWidth:r,pixelHeight:o}=t;return s.width=Math.min(s.width,r-i.x),s.height=Math.min(s.height,o-i.y),this.adaptor.copyToTexture(t,e,i,s,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 sr.test(t)&&(t=Oe(t).source),t instanceof Jc?e=t:t instanceof Ds&&(e=new Jc({colorTextures:[t]}),t.source instanceof sr&&(e.isRoot=!0),t.once("destroy",()=>{e.destroy(),this._renderSurfaceToRenderTargetHash.delete(t);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))}resetState(){this.renderTarget=null,this.renderSurface=null}}class Xc extends Zc{constructor(t){super(t),this.adaptor=new Vc,this.adaptor.init(t,this)}}Xc.extension={type:[qi.WebGLSystem],name:"renderTarget"};class Yc extends as{constructor({buffer:t,offset:i,size:s}){super(),this.uid=e("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=e("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=0|i,this.size=s,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=e("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null}}class Kc{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}}let Qc=null;const qc={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"},$c={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"},td={textureCount:0,blockIndex:0};class ed{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_programDataHash")}contextChange(t){this._gl=t,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(t,e){if(this._setProgram(t.glProgram),e)return;td.textureCount=0,td.blockIndex=0;let i=this._shaderSyncFunctions[t.glProgram._key];i||(i=this._shaderSyncFunctions[t.glProgram._key]=this._generateShaderSync(t,this)),this._renderer.buffer.nextBindBase(!!t.glProgram.transformFeedbackVaryings),i(this._renderer,t,td)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,td)}bindUniformBlock(t,e,i=0){const s=this._renderer.buffer,n=this._getProgramData(this._activeProgram),r=t._bufferResource;r||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,a=s.updateBuffer(o),h=s.freeLocationForBufferBase(a);if(r){const{offset:e,size:i}=t;0===e&&i===o.data.byteLength?s.bindBufferBase(a,h):s.bindBufferRange(a,h,e)}else s.getLastBindBaseLocation(a)!==h&&s.bindBufferBase(a,h);const l=this._activeProgram._uniformBlockData[e].index;n.uniformBlockBindings[i]!==h&&(n.uniformBlockBindings[i]=h,this._renderer.gl.uniformBlockBinding(n.program,l,h))}_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]=function(t,e){const i=De(t,t.VERTEX_SHADER,e.vertex),s=De(t,t.FRAGMENT_SHADER,e.fragment),n=t.createProgram();t.attachShader(n,i),t.attachShader(n,s);const r=e.transformFeedbackVaryings;r&&("function"!=typeof t.transformFeedbackVaryings?o():t.transformFeedbackVaryings(n,r.names,"separate"===r.bufferMode?t.SEPARATE_ATTRIBS:t.INTERLEAVED_ATTRIBS)),t.linkProgram(n),t.getProgramParameter(n,t.LINK_STATUS)||function(t,e,i,s){t.getProgramParameter(e,t.LINK_STATUS)||(t.getShaderParameter(i,t.COMPILE_STATUS)||Ue(t,i),t.getShaderParameter(s,t.COMPILE_STATUS)||Ue(t,s),t.getProgramInfoLog(e))}(t,n,i,s),e._attributeData=function(t,e,i=!1){const s={},n=e.getProgramParameter(t,e.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const n=e.getActiveAttrib(t,i);if(n.name.startsWith("gl_"))continue;const r=Ge(e,n.type);s[n.name]={location:0,format:r,stride:R(r).stride,offset:0,instance:!1,start:0}}const r=Object.keys(s);if(i){r.sort((t,e)=>t>e?1:-1);for(let i=0;i<r.length;i++)s[r[i]].location=i,e.bindAttribLocation(t,i,r[i]);e.linkProgram(t)}else for(let i=0;i<r.length;i++)s[r[i]].location=e.getAttribLocation(t,r[i]);return s}(n,t,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=function(t,e){const i={},s=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let n=0;n<s;n++){const s=e.getActiveUniform(t,n),r=s.name.replace(/\[.*?\]$/,""),o=!!s.name.match(/\[.*?\]$/),a=je(e,s.type);i[r]={name:r,index:n,type:a,size:s.size,isArray:o,value:Le(a,s.size)}}return i}(n,t),e._uniformBlockData=function(t,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const i={},s=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let n=0;n<s;n++){const s=e.getActiveUniformBlockName(t,n),r=e.getUniformBlockIndex(t,s),o=e.getActiveUniformBlockParameter(t,n,e.UNIFORM_BLOCK_DATA_SIZE);i[s]={name:s,index:r,size:o}}return i}(n,t),t.deleteShader(i),t.deleteShader(s);const a={};for(const i in e._uniformData){const s=e._uniformData[i];a[i]={location:t.getUniformLocation(n,i),value:Le(s.type,s.size)}}return new Kc(n,a)}(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._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return function(t,e){const i=[],s=["\n var g = s.groups;\n var sS = r.shader;\n var p = s.glProgram;\n var ugS = r.uniformGroup;\n var resources;\n "];let n=!1,r=0;const o=e._getProgramData(t.glProgram);for(const a in t.groups){const h=t.groups[a];i.push(`\n resources = g[${a}].resources;\n `);for(const l in h.resources){const c=h.resources[l];if(c instanceof lo)if(c.ubo){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else i.push(`\n ugS.updateUniformGroup(resources[${l}], p, sD);\n `);else if(c instanceof Yc){const e=t._uniformBindMap[a][Number(l)];i.push(`\n sS.bindUniformBlock(\n resources[${l}],\n '${e}',\n ${t.glProgram._uniformBlockData[e].index}\n );\n `)}else if(c instanceof Ds){const h=t._uniformBindMap[a][l],c=o.uniformData[h];c&&(n||(n=!0,s.push("\n var tS = r.texture;\n ")),e._gl.uniform1i(c.location,r),i.push(`\n tS.bind(resources[${l}], ${r});\n `),r++)}}}const a=[...s,...i].join("\n");return new Function("r","s","sD",a)}(t,e)}resetState(){this._activeProgram=null}}ed.extension={type:[qi.WebGLSystem],name:"shader"};const id={f32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1f(location, v);\n }","vec2<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1]);\n }","vec3<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3f(location, v[0], v[1], v[2]);\n }","vec4<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",i32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",u32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1ui(location, v);\n }","vec2<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2ui(location, v[0], v[1]);\n }","vec3<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }","vec4<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},sd={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);"};class nd{constructor(t){this._cache={},this._uniformGroupSyncHash={},this._renderer=t,this.gl=null,this._cache={}}contextChange(t){this.gl=t}updateUniformGroup(t,e,i){const s=this._renderer.shader._getProgramData(e);t.isStatic&&t._dirtyId===s.uniformDirtyGroups[t.uid]||(s.uniformDirtyGroups[t.uid]=t._dirtyId,this._getUniformSyncFunction(t,e)(s.uniformData,t.uniforms,this._renderer,i))}_getUniformSyncFunction(t,e){return this._uniformGroupSyncHash[t._signature]?.[e._key]||this._createUniformSyncFunction(t,e)}_createUniformSyncFunction(t,e){const i=this._uniformGroupSyncHash[t._signature]||(this._uniformGroupSyncHash[t._signature]={}),s=this._getSignature(t,e._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(t,e._uniformData)),i[e._key]=this._cache[s],i[e._key]}_generateUniformsSync(t,e){return function(t,e){const i=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n var name = null;\n "];for(const s in t.uniforms){if(!e[s]){t.uniforms[s]instanceof lo?t.uniforms[s].ubo?i.push(`\n renderer.shader.bindUniformBlock(uv.${s}, "${s}");\n `):i.push(`\n renderer.shader.updateUniformGroup(uv.${s});\n `):t.uniforms[s]instanceof Yc&&i.push(`\n renderer.shader.bindBufferResource(uv.${s}, "${s}");\n `);continue}const n=t.uniformStructures[s];let r=!1;for(let t=0;t<Gc.length;t++){const e=Gc[t];if(n.type===e.type&&e.test(n)){i.push(`name = "${s}";`,Gc[t].uniform),r=!0;break}}if(!r){const t=(1===n.size?id:sd)[n.type].replace("location",`ud["${s}"].location`);i.push(`\n cu = ud["${s}"];\n cv = cu.value;\n v = uv["${s}"];\n ${t};`)}}return new Function("ud","uv","renderer","syncData",i.join("\n"))}(t,e)}_getSignature(t,e,i){const s=t.uniforms,n=[`${i}-`];for(const t in s)n.push(t),e[t]&&n.push(e[t].type);return n.join("-")}destroy(){this._renderer=null,this._cache=null}}nd.extension={type:[qi.WebGLSystem],name:"uniformGroup"};const rd=class t{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=mo.for2d(),t.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(t){this._invertFrontFace=!t.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(t){this.gl=t,this.blendModesMap=function(t){const e={};if(e.normal=[t.ONE,t.ONE_MINUS_SRC_ALPHA],e.add=[t.ONE,t.ONE],e.multiply=[t.DST_COLOR,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.screen=[t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[t.SRC_ALPHA,t.ONE,t.ONE,t.ONE],e["screen-npm"]=[t.SRC_ALPHA,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA],e.erase=[t.ZERO,t.ONE_MINUS_SRC_ALPHA],t instanceof ir.get().getWebGLRenderingContext()){const i=t.getExtension("EXT_blend_minmax");i&&(e.min=[t.ONE,t.ONE,t.ONE,t.ONE,i.MIN_EXT,i.MIN_EXT],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,i.MAX_EXT,i.MAX_EXT])}else e.min=[t.ONE,t.ONE,t.ONE,t.ONE,t.MIN,t.MIN],e.max=[t.ONE,t.ONE,t.ONE,t.ONE,t.MAX,t.MAX];return e}(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)1&e&&this.map[i].call(this,!!(t.data&1<<i)),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(e){this._updateCheck(t._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(t._checkPolygonOffset,e),this.gl[e?"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._cullFace=t,this.gl[t?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(t){this._frontFace=t,this._frontFaceDirty=!1;const e=this._invertFrontFace?!t:t;this._glFrontFace!==e&&(this._glFrontFace=e,this.gl.frontFace(this.gl[e?"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;2===e.length?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),6===e.length?(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)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),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&&-1===i?this.checks.push(t):e||-1===i||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}};rd.extension={type:[qi.WebGLSystem],name:"state"};let od=rd;class ad{constructor(t){this.target=Ac.TEXTURE_2D,this.texture=t,this.width=-1,this.height=-1,this.type=Cc.UNSIGNED_BYTE,this.internalFormat=wc.RGBA,this.format=wc.RGBA,this.samplerType=0}}const hd={id:"buffer",upload(t,e,i){e.width===t.width||e.height===t.height?i.texSubImage2D(i.TEXTURE_2D,0,0,0,t.width,t.height,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,t.width,t.height,0,e.format,e.type,t.resource),e.width=t.width,e.height=t.height}},ld={"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},cd={id:"compressed",upload(t,e,i){i.pixelStorei(i.UNPACK_ALIGNMENT,4);let s=t.pixelWidth,n=t.pixelHeight;const r=!!ld[t.format];for(let o=0;o<t.resource.length;o++){const a=t.resource[o];r?i.compressedTexImage2D(i.TEXTURE_2D,o,e.internalFormat,s,n,0,a):i.texImage2D(i.TEXTURE_2D,o,e.internalFormat,s,n,0,e.format,e.type,a),s=Math.max(s>>1,1),n=Math.max(n>>1,1)}}},dd={id:"image",upload(t,e,i,s){const n=e.width,r=e.height,o=t.pixelWidth,a=t.pixelHeight,h=t.resourceWidth,l=t.resourceHeight;h<o||l<a?(n===o&&r===a||i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,null),2===s?i.texSubImage2D(i.TEXTURE_2D,0,0,0,h,l,e.format,e.type,t.resource):i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource)):n===o&&r===a?i.texSubImage2D(i.TEXTURE_2D,0,0,0,e.format,e.type,t.resource):2===s?i.texImage2D(e.target,0,e.internalFormat,o,a,0,e.format,e.type,t.resource):i.texImage2D(e.target,0,e.internalFormat,e.format,e.type,t.resource),e.width=o,e.height=a}},ud={id:"video",upload(t,e,i,s){t.isValid?dd.upload(t,e,i,s):i.texImage2D(e.target,0,e.internalFormat,1,1,0,e.format,e.type,null)}},pd={linear:9729,nearest:9728},gd={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},fd={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},md={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};class yd{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:dd,buffer:hd,video:ud,compressed:cd},this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_glTextures"),this._renderer.renderableGC.addManagedHash(this,"_glSamplers")}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=function(t,e){let i={},s=t.RGBA;return t instanceof ir.get().getWebGLRenderingContext()?e.srgb&&(i={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(i={"rgba8unorm-srgb":t.SRGB8_ALPHA8,"bgra8unorm-srgb":t.SRGB8_ALPHA8},s=t.RGBA8),{r8unorm:t.R8,r8snorm:t.R8_SNORM,r8uint:t.R8UI,r8sint:t.R8I,r16uint:t.R16UI,r16sint:t.R16I,r16float:t.R16F,rg8unorm:t.RG8,rg8snorm:t.RG8_SNORM,rg8uint:t.RG8UI,rg8sint:t.RG8I,r32uint:t.R32UI,r32sint:t.R32I,r32float:t.R32F,rg16uint:t.RG16UI,rg16sint:t.RG16I,rg16float:t.RG16F,rgba8unorm:t.RGBA,...i,rgba8snorm:t.RGBA8_SNORM,rgba8uint:t.RGBA8UI,rgba8sint:t.RGBA8I,bgra8unorm:s,rgb9e5ufloat:t.RGB9_E5,rgb10a2unorm:t.RGB10_A2,rg11b10ufloat:t.R11F_G11F_B10F,rg32uint:t.RG32UI,rg32sint:t.RG32I,rg32float:t.RG32F,rgba16uint:t.RGBA16UI,rgba16sint:t.RGBA16I,rgba16float:t.RGBA16F,rgba32uint:t.RGBA32UI,rgba32sint:t.RGBA32I,rgba32float:t.RGBA32F,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT16,depth24plus:t.DEPTH_COMPONENT24,"depth24plus-stencil8":t.DEPTH24_STENCIL8,depth32float:t.DEPTH_COMPONENT32F,"depth32float-stencil8":t.DEPTH32F_STENCIL8,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}(t,this._renderer.context.extensions),this._mapFormatToType=function(t){return{r8unorm:t.UNSIGNED_BYTE,r8snorm:t.BYTE,r8uint:t.UNSIGNED_BYTE,r8sint:t.BYTE,r16uint:t.UNSIGNED_SHORT,r16sint:t.SHORT,r16float:t.HALF_FLOAT,rg8unorm:t.UNSIGNED_BYTE,rg8snorm:t.BYTE,rg8uint:t.UNSIGNED_BYTE,rg8sint:t.BYTE,r32uint:t.UNSIGNED_INT,r32sint:t.INT,r32float:t.FLOAT,rg16uint:t.UNSIGNED_SHORT,rg16sint:t.SHORT,rg16float:t.HALF_FLOAT,rgba8unorm:t.UNSIGNED_BYTE,"rgba8unorm-srgb":t.UNSIGNED_BYTE,rgba8snorm:t.BYTE,rgba8uint:t.UNSIGNED_BYTE,rgba8sint:t.BYTE,bgra8unorm:t.UNSIGNED_BYTE,"bgra8unorm-srgb":t.UNSIGNED_BYTE,rgb9e5ufloat:t.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:t.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:t.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:t.UNSIGNED_INT,rg32sint:t.INT,rg32float:t.FLOAT,rgba16uint:t.UNSIGNED_SHORT,rgba16sint:t.SHORT,rgba16float:t.HALF_FLOAT,rgba32uint:t.UNSIGNED_INT,rgba32sint:t.INT,rgba32float:t.FLOAT,stencil8:t.UNSIGNED_BYTE,depth16unorm:t.UNSIGNED_SHORT,depth24plus:t.UNSIGNED_INT,"depth24plus-stencil8":t.UNSIGNED_INT_24_8,depth32float:t.FLOAT,"depth32float-stencil8":t.FLOAT_32_UNSIGNED_INT_24_8_REV}}(t),this._mapFormatToFormat=function(t){return{r8unorm:t.RED,r8snorm:t.RED,r8uint:t.RED,r8sint:t.RED,r16uint:t.RED,r16sint:t.RED,r16float:t.RED,rg8unorm:t.RG,rg8snorm:t.RG,rg8uint:t.RG,rg8sint:t.RG,r32uint:t.RED,r32sint:t.RED,r32float:t.RED,rg16uint:t.RG,rg16sint:t.RG,rg16float:t.RG,rgba8unorm:t.RGBA,"rgba8unorm-srgb":t.RGBA,rgba8snorm:t.RGBA,rgba8uint:t.RGBA,rgba8sint:t.RGBA,bgra8unorm:t.RGBA,"bgra8unorm-srgb":t.RGBA,rgb9e5ufloat:t.RGB,rgb10a2unorm:t.RGBA,rg11b10ufloat:t.RGB,rg32uint:t.RG,rg32sint:t.RG,rg32float:t.RG,rgba16uint:t.RGBA,rgba16sint:t.RGBA,rgba16float:t.RGBA,rgba32uint:t.RGBA,rgba32sint:t.RGBA,rgba32float:t.RGBA,stencil8:t.STENCIL_INDEX8,depth16unorm:t.DEPTH_COMPONENT,depth24plus:t.DEPTH_COMPONENT,"depth24plus-stencil8":t.DEPTH_STENCIL,depth32float:t.DEPTH_COMPONENT,"depth32float-stencil8":t.DEPTH_STENCIL}}(t)),this._glTextures=Object.create(null),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(Gs.EMPTY,t)}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=Gs.EMPTY.source);const s=this.getGlSource(t);i.bindTexture(s.target,s.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t)return this._boundSamplers[e]=null,void i.bindSampler(e,null);const s=this._getGlSampler(t);this._boundSamplers[e]!==s&&(this._boundSamplers[e]=s,i.bindSampler(e,s))}unbind(t){const e=t.source,i=this._boundTextures,s=this._gl;for(let t=0;t<i.length;t++)if(i[t]===e){this._activateLocation(t);const n=this.getGlSource(e);s.bindTexture(n.target,null),i[t]=null}}_activateLocation(t){this._activeTextureLocation!==t&&(this._activeTextureLocation=t,this._gl.activeTexture(this._gl.TEXTURE0+t))}_initSource(t){const e=this._gl,i=new ad(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 e=Math.max(t.width,t.height);t.mipLevelCount=Math.floor(Math.log2(e))+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,s=this.getGlSource(t);i.bindTexture(i.TEXTURE_2D,s.texture),this._boundTextures[this._activeTextureLocation]=t,ze(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;const s="premultiply-alpha-on-upload"===t.alphaMode;this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),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,ze(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:s}=this.getPixels(t),n=ir.get().createCanvas();n.width=i,n.height=s;const r=n.getContext("2d");if(r){const t=r.createImageData(i,s);t.data.set(e),r.putImageData(t,0,0)}return n}getPixels(t){const e=t.source.resolution,i=t.frame,s=Math.max(Math.round(i.width*e),1),n=Math.max(Math.round(i.height*e),1),r=new Uint8Array(4*s*n),o=this._renderer,a=o.renderTarget.getRenderTarget(t),h=o.renderTarget.getGpuRenderTarget(a),l=o.gl;return l.bindFramebuffer(l.FRAMEBUFFER,h.resolveTargetFramebuffer),l.readPixels(Math.round(i.x*e),Math.round(i.y*e),s,n,l.RGBA,l.UNSIGNED_BYTE,r),{pixels:new Uint8ClampedArray(r.buffer),width:s,height:n}}destroy(){this.managedTextures.slice().forEach(t=>this.onSourceDestroy(t)),this.managedTextures=null,this._glTextures=null,this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(Gs.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}yd.extension={type:[qi.WebGLSystem],name:"texture"};class xd{contextChange(t){const e=new lo({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,s=kt({name:"graphics",bits:[Ta,jt(i),lc,Ra]});this.shader=new po({glProgram:s,resources:{localUniforms:e,batchSamplers:Gt(i)}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,r=n.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i);s.groups[0]=n.globalUniforms.bindGroup,n.state.set(t.state),n.shader.bind(s),n.geometry.bind(o.geometry,s.glProgram);const h=a.instructions;for(let t=0;t<a.instructionSize;t++){const e=h[t];if(e.size){for(let t=0;t<e.textures.count;t++)n.texture.bind(e.textures.textures[t],t);n.geometry.draw(e.topology,e.size,e.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}xd.extension={type:[qi.WebGLPipesAdaptor],name:"graphics"};class bd{init(){const t=kt({name:"mesh",bits:[lc,dc,Ra]});this._shader=new po({glProgram:t,resources:{uTexture:Gs.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new ps}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.glProgram)return void o(e.shader)}else{s=this._shader;const t=e.texture,i=t.source;s.resources.uTexture=i,s.resources.uSampler=i.style,s.resources.textureUniforms.uniforms.uTextureMatrix=t.textureMatrix.mapCoord}s.groups[100]=i.globalUniforms.bindGroup,s.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}bd.extension={type:[qi.WebGLPipesAdaptor],name:"mesh"};class vd{constructor(t){this._renderer=t}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}execute(t){t.isRenderable&&t.render(this._renderer)}destroy(){this._renderer=null}}vd.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"customRender"};class _d{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){}}const wd=new ps;class Ad{constructor(t){this._renderer=t}addRenderGroup(t,e){t.isCachedAsTexture?this._addRenderableCacheAsTexture(t,e):this._addRenderableDirect(t,e)}execute(t){t.isRenderable&&(t.isCachedAsTexture?this._executeCacheAsTexture(t):this._executeDirect(t))}destroy(){this._renderer=null}_addRenderableDirect(t,e){this._renderer.renderPipes.batch.break(e),t._batchableRenderGroup&&(_n.return(t._batchableRenderGroup),t._batchableRenderGroup=null),e.add(t)}_addRenderableCacheAsTexture(t,e){const i=t._batchableRenderGroup??(t._batchableRenderGroup=_n.get(_d));i.renderable=t.root,i.transform=t.root.relativeGroupTransform,i.texture=t.texture,i.bounds=t._textureBounds,e.add(t),this._renderer.renderPipes.blendMode.pushBlendMode(t,t.root.groupBlendMode,e),this._renderer.renderPipes.batch.addToBatch(i,e),this._renderer.renderPipes.blendMode.popBlendMode(e)}_executeCacheAsTexture(t){if(t.textureNeedsUpdate){t.textureNeedsUpdate=!1;const e=wd.identity().translate(-t._textureBounds.x,-t._textureBounds.y);this._renderer.renderTarget.push(t.texture,!0,null,t.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:e,worldColor:4294967295,offset:{x:0,y:0}}),Ne(t,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}t._batchableRenderGroup._batcher.updateElement(t._batchableRenderGroup),t._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(t){this._renderer.globalUniforms.push({worldTransformMatrix:t.inverseParentTextureTransform,worldColor:t.worldColorAlpha}),Ne(t,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}Ad.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"renderGroup"};const Cd=new Xn,Sd=new ps;class Id{constructor(t){this._renderer=t}render({container:t,transform:e}){const i=t.parent,s=t.renderGroup.renderGroupParent;t.parent=null,t.renderGroup.renderGroupParent=null;const n=this._renderer,r=Sd;e&&(r.copyFrom(t.renderGroup.localTransform),t.renderGroup.localTransform.copyFrom(e));const o=n.renderPipes;this._updateCachedRenderGroups(t.renderGroup,null),this._updateRenderGroups(t.renderGroup),n.globalUniforms.start({worldTransformMatrix:e?t.renderGroup.localTransform:t.renderGroup.worldTransform,worldColor:t.renderGroup.worldColorAlpha}),Ne(t.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),e&&t.renderGroup.localTransform.copyFrom(r),t.parent=i,t.renderGroup.renderGroupParent=s}destroy(){this._renderer=null}_updateCachedRenderGroups(t,e){if(t._parentCacheAsTextureRenderGroup=e,t.isCachedAsTexture){if(!t.textureNeedsUpdate)return;e=t}for(let i=t.renderGroupChildren.length-1;i>=0;i--)this._updateCachedRenderGroups(t.renderGroupChildren[i],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const e=t.root.getLocalBounds();e.ceil();const i=t.texture;t.texture&&Nn.returnTexture(t.texture,!0);const s=this._renderer,n=t.textureOptions.resolution||s.view.resolution,r=t.textureOptions.antialias??s.view.antialias,o=t.textureOptions.scaleMode??"linear",a=Nn.getOptimalTexture(e.width,e.height,n,r);a._source.style=new ks({scaleMode:o}),t.texture=a,t._textureBounds||(t._textureBounds=new zs),t._textureBounds.copyFrom(e),i!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(Nn.returnTexture(t.texture,!0),t.texture=null)}_updateRenderGroups(t){const e=this._renderer,i=e.renderPipes;if(t.runOnRender(e),t.instructionSet.renderPipes=i,t.structureDidChange?Ve(t.childrenRenderablesToUpdate.list,0):function(t,e){const{list:i}=t.childrenRenderablesToUpdate;let s=!1;for(let n=0;n<t.childrenRenderablesToUpdate.index;n++){const t=i[n];if(s=e[t.renderPipeId].validateRenderable(t),s)break}t.structureDidChange=s}(t,i),He(t),t.structureDidChange?(t.structureDidChange=!1,this._buildInstructions(t,e)):this._updateRenderables(t),t.childrenRenderablesToUpdate.index=0,e.renderPipes.batch.upload(t.instructionSet),!t.isCachedAsTexture||t.textureNeedsUpdate)for(let e=0;e<t.renderGroupChildren.length;e++)this._updateRenderGroups(t.renderGroupChildren[e])}_updateRenderables(t){const{list:e,index:i}=t.childrenRenderablesToUpdate;for(let s=0;s<i;s++){const i=e[s];i.didViewUpdate&&t.updateRenderable(i)}Ve(e,i)}_buildInstructions(t,e){const i=t.root,s=t.instructionSet;s.reset();const n=e.renderPipes?e:e.batch.renderer,r=n.renderPipes;r.batch.buildStart(s),r.blendMode.buildStart(),r.colorMask.buildStart(),i.sortableChildren&&i.sortChildren(),i.collectRenderablesWithEffects(s,n,null),r.batch.buildEnd(s),r.blendMode.buildEnd(s)}}Id.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"renderGroup"};class Md{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.bounds=t.visualBounds,e.texture=t._texture}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=new _d;return e.renderable=t,e.transform=t.groupTransform,e.texture=t._texture,e.bounds=t.visualBounds,e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Md.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"sprite"};const Td=class t{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new yn(0),this.color=this._backgroundColor,this.alpha=1}init(e){e={...t.defaultOptions,...e},this.clearBeforeRender=e.clearBeforeRender,this.color=e.background||e.backgroundColor||this._backgroundColor,this.alpha=e.backgroundAlpha,this._backgroundColor.setAlpha(e.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){yn.shared.setValue(t).alpha<1&&1===this._backgroundColor.alpha&&o(),this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Td.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"background",priority:0},Td.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let Pd=Td;const Ed={};es.handle(qi.BlendMode,t=>{if(!t.name)throw new Error("BlendMode extension must have a name property");Ed[t.name]=t.ref},t=>{delete Ed[t.name]});class Bd{constructor(t){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=t,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(t,e,i){this._blendModeStack.push(e),this.setBlendMode(t,e,i)}popBlendMode(t){this._blendModeStack.pop();const e=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,e,t)}setBlendMode(t,e,i){const s=t instanceof Vn;this._activeBlendMode!==e?(this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!Ed[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))):this._isAdvanced&&t&&!s&&this._renderableList?.push(t)}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!Ed[i])return void o();const s=this._ensureFilterEffect(i),n=t instanceof Vn,r={renderPipeId:"filter",action:"pushFilter",filterEffect:s,renderables:n?null:[t],container:n?t.root:null,canBundle:!1};this._renderableList=r.renderables,e.add(r)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new Sn,e.filters=[new Ed[t]]),e}_endAdvancedBlendMode(t){this._isAdvanced=!1,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}}Bd.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"blendMode"};const Rd={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},kd=class t{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof Xn||t instanceof Gs?{target:t,...e}:{...e,...t}}async image(t){const e=ir.get().createImage();return e.src=await this.base64(t),e}async base64(e){e=this._normalizeOptions(e,t.defaultImageOptions);const{format:i,quality:s}=e,n=this.canvas(e);if(void 0!==n.toBlob)return new Promise((t,e)=>{n.toBlob(i=>{if(!i)return void e(new Error("ICanvas.toBlob failed!"));const s=new FileReader;s.onload=()=>t(s.result),s.onerror=e,s.readAsDataURL(i)},Rd[i],s)});if(void 0!==n.toDataURL)return n.toDataURL(Rd[i],s);if(void 0!==n.convertToBlob){const t=await n.convertToBlob({type:Rd[i],quality:s});return new Promise((e,i)=>{const s=new FileReader;s.onload=()=>e(s.result),s.onerror=i,s.readAsDataURL(t)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer;if(e instanceof Gs)return i.texture.generateCanvas(e);const s=i.textureGenerator.generateTexture(t),n=i.texture.generateCanvas(s);return s.destroy(!0),n}pixels(t){const e=(t=this._normalizeOptions(t)).target,i=this._renderer,s=e instanceof Gs?e:i.textureGenerator.generateTexture(t),n=i.texture.getPixels(s);return e instanceof Xn&&s.destroy(!0),n}texture(t){return(t=this._normalizeOptions(t)).target instanceof Gs?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),["font-size: 1px;",`padding: ${e}px 300px;`,`background: url(${this.canvas(t).toDataURL()}) no-repeat;`,"background-size: contain;"].join(" ")}destroy(){this._renderer=null}};kd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"extract"},kd.defaultImageOptions={format:"png",quality:1};let Od=kd;class Dd extends Gs{static create(t){return new Dd({source:new Ds(t)})}resize(t,e,i){return this.source.resize(t,e,i),this}}const Fd=new Ss,Ld=new zs,jd=[0,0,0,0];class Gd{constructor(t){this._renderer=t}generateTexture(t){t instanceof Xn&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const e=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,s=t.target;let n=t.clearColor;n=n?Array.isArray(n)&&4===n.length?n:yn.shared.setValue(n).toArray():jd;const r=t.frame?.copyTo(Fd)||g(s,Ld).rectangle;r.width=0|Math.max(r.width,1/e),r.height=0|Math.max(r.height,1/e);const o=Dd.create({...t.textureSourceOptions,width:r.width,height:r.height,resolution:e,antialias:i}),a=ps.shared.translate(-r.x,-r.y);return this._renderer.render({container:s,transform:a,target:o,clearColor:n}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}Gd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"textureGenerator"};class Ud{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:s,offset:n}){const r=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{worldTransformMatrix:new ps,worldColor:4294967295,offset:new ds},a={projectionMatrix:e||this._renderer.renderTarget.projectionMatrix,resolution:t||r.size,worldTransformMatrix:i||o.worldTransformMatrix,worldColor:s||o.worldColor,offset:n||o.offset,bindGroup:null},h=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(h);const l=h.uniforms;let c;l.uProjectionMatrix=a.projectionMatrix,l.uResolution=a.resolution,l.uWorldTransformMatrix.copyFrom(a.worldTransformMatrix),l.uWorldTransformMatrix.tx-=a.offset.x,l.uWorldTransformMatrix.ty-=a.offset.y,Ze(a.worldColor,l.uWorldColorAlpha,0),h.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(h,!1):(c=this._bindGroupPool.pop()||new co,this._activeBindGroups.push(c),c.setResource(h,0)),a.bindGroup=c,this._currentGlobalUniformData=a}push(t){this.bind(t),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===uo.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new lo({uProjectionMatrix:{value:new ps,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}Ud.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"globalUniforms"};let zd=1;class Nd{constructor(){this._tasks=[],this._offset=0}init(){lr.system.add(this._update,this)}repeat(t,e,i=!0){const s=zd++;let n=0;return i&&(this._offset+=1e3,n=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:n,last:performance.now(),repeat:!0,id:s}),s}cancel(t){for(let e=0;e<this._tasks.length;e++)if(this._tasks[e].id===t)return void this._tasks.splice(e,1)}_update(){const t=performance.now();for(let e=0;e<this._tasks.length;e++){const i=this._tasks[e];if(t-i.offset-i.last>=i.duration){const e=t-i.start;i.func(e),i.last=t}}}destroy(){lr.system.remove(this._update,this),this._tasks.length=0}}Nd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"scheduler",priority:0};let Vd=!1;class Hd{constructor(t){this._renderer=t}init(t){if(t.hello){let t=this._renderer.name;this._renderer.type===uo.WEBGL&&(t+=` ${this._renderer.context.webGLVersion}`),function(t){if(!Vd){if(ir.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const e=[`%c %c %c %c %c PixiJS %c v${Eo} (${t}) http://www.pixijs.com/\n\n`,"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(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${Eo} - ${t} - http://www.pixijs.com/`);Vd=!0}}(t)}}}Hd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"hello",priority:-2},Hd.defaultOptions={hello:!1};let Wd=0;const Jd=class t{constructor(t){this._managedRenderables=[],this._managedHashes=[],this._managedArrays=[],this._renderer=t}init(e){e={...t.defaultOptions,...e},this.maxUnusedTime=e.renderableGCMaxUnusedTime,this._frequency=e.renderableGCFrequency,this.enabled=e.renderableGCActive}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>this.run(),this._frequency,!1),this._hashHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedHashes)t.context[t.hash]=Xe(t.context[t.hash])},this._frequency),this._arrayHandler=this._renderer.scheduler.repeat(()=>{for(const t of this._managedArrays)Ye(t.context[t.hash])},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._hashHandler),this._renderer.scheduler.cancel(this._arrayHandler)))}addManagedHash(t,e){this._managedHashes.push({context:t,hash:e})}addManagedArray(t,e){this._managedArrays.push({context:t,hash:e})}prerender({container:t}){this._now=performance.now(),t.renderGroup.gcTick=Wd++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}addRenderable(t){this.enabled&&(-1===t._lastUsed&&(this._managedRenderables.push(t),t.once("destroyed",this._removeRenderable,this)),t._lastUsed=this._now)}run(){const t=this._now,e=this._managedRenderables,i=this._renderer.renderPipes;let s=0;for(let n=0;n<e.length;n++){const r=e[n];if(null===r){s++;continue}const o=r.renderGroup??r.parentRenderGroup,a=o?.instructionSet?.gcTick??-1;if((o?.gcTick??0)===a&&(r._lastUsed=t),t-r._lastUsed>this.maxUnusedTime){if(!r.destroyed){const t=i;o&&(o.structureDidChange=!0),t[r.renderPipeId].destroyRenderable(r)}r._lastUsed=-1,s++,r.off("destroyed",this._removeRenderable,this)}else e[n-s]=r}e.length-=s}destroy(){this.enabled=!1,this._renderer=null,this._managedRenderables.length=0,this._managedHashes.length=0,this._managedArrays.length=0}_removeRenderable(t){const e=this._managedRenderables.indexOf(t);e>=0&&(t.off("destroyed",this._removeRenderable,this),this._managedRenderables[e]=null)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}};Jd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"renderableGC",priority:0},Jd.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let Zd=Jd;const Xd=class t{constructor(t){this._renderer=t,this.count=0,this.checkCount=0}init(e){e={...t.defaultOptions,...e},this.checkCountMax=e.textureGCCheckCountMax,this.maxIdle=e.textureGCAMaxIdle??e.textureGCMaxIdle,this.active=e.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}};Xd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem],name:"textureGC"},Xd.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let Yd=Xd;const Kd=class t{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(t){this.texture.source.autoDensity=t}get resolution(){return this.texture.source._resolution}set resolution(t){this.texture.source.resize(this.texture.source.width,this.texture.source.height,t)}init(e){(e={...t.defaultOptions,...e}).view&&(Ps(0,"ViewSystem.view has been renamed to ViewSystem.canvas"),e.canvas=e.view),this.screen=new Ss(0,0,e.width,e.height),this.canvas=e.canvas||ir.get().createCanvas(),this.antialias=!!e.antialias,this.texture=Oe(this.canvas,e),this.renderTarget=new Jc({colorTextures:[this.texture],depth:!!e.depth,isRoot:!0}),this.texture.source.transparent=e.backgroundAlpha<1,this.resolution=e.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}destroy(t=!1){("boolean"==typeof t?t:!!t?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};Kd.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"view",priority:0},Kd.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const Qd=[Pd,Ud,Hd,Kd,Id,Yd,Gd,Od,Ro,Zd,Nd],qd=[Bd,oc,Md,Ad,gc,mc,fc,vd],$d=[...Qd,Nc,Ec,_c,kc,bc,yd,Xc,Mc,nd,ed,Rc,od,Fc,Bc],tu=[...qd],eu=[ic,bd,xd],iu=[],su=[],nu=[];es.handleByNamedList(qi.WebGLSystem,iu),es.handleByNamedList(qi.WebGLPipes,su),es.handleByNamedList(qi.WebGLPipesAdaptor,nu),es.add(...$d,...tu,...eu);const ru=Object.freeze(Object.defineProperty({__proto__:null,WebGLRenderer:class extends To{constructor(){super({name:"webgl",type:uo.WEBGL,systems:iu,renderPipes:su,renderPipeAdaptors:nu})}}},Symbol.toStringTag,{value:"Module"}));class ou{constructor(t){this._hash=Object.create(null),this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_hash")}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 s=this._gpu.device,n=e.layout[i],r=[],o=this._renderer;for(const e in n){const i=t.resources[e]??t.resources[n[e]];let s;if("uniformGroup"===i._resourceType){const t=i;o.ubo.updateUniformGroup(t);const e=t.buffer;s={buffer:o.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if("buffer"===i._resourceType){const t=i;s={buffer:o.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("bufferResource"===i._resourceType){const t=i;s={buffer:o.buffer.getGPUBuffer(t.buffer),offset:t.offset,size:t.size}}else if("textureSampler"===i._resourceType){const t=i;s=o.texture.getGpuSampler(t)}else if("textureSource"===i._resourceType){const t=i;s=o.texture.getGpuSource(t).createView({})}r.push({binding:n[e],resource:s})}const a=o.shader.getProgramData(e).bindGroups[i],h=s.createBindGroup({layout:a,entries:r});return this._hash[t._key]=h,h}destroy(){for(const t of Object.keys(this._hash))this._hash[t]=null;this._hash=null,this._renderer=null}}ou.extension={type:[qi.WebGPUSystem],name:"bindGroup"};class au{constructor(t){this._gpuBuffers=Object.create(null),this._managedBuffers=[],t.renderableGC.addManagedHash(this,"_gpuBuffers")}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),this._managedBuffers.push(t));const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t.data&&(mt(t.data.buffer,e.getMappedRange()),e.unmap()),this._gpuBuffers[t.uid]=e,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}}au.extension={type:[qi.WebGPUSystem],name:"buffer"};class hu{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: "+4*t);const e=this.byteIndex;let i=e+4*t;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>4*this.data.length)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.data=null}}class lu{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}}lu.extension={type:[qi.WebGPUSystem],name:"colorMask"};class cu{constructor(t){this._renderer=t}async init(t){return this._initPromise||(this._initPromise=(t.gpu?Promise.resolve(t.gpu):this._createDeviceAndAdaptor(t)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)})),this._initPromise}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await ir.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(t=>e.features.has(t)),s=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:s}}destroy(){this.gpu=null,this._renderer=null}}cu.extension={type:[qi.WebGPUSystem],name:"device"},cu.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class du{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,s){const n=this._renderer.pipeline.getPipeline(t,e,i,s);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=2===t.data.BYTES_PER_ELEMENT?"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 s=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,s)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const e in i)this._setVertexBuffer(parseInt(e,10),t.attributes[i[e]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const s=t.groups[i];e||this._syncBindGroup(s),this.setBindGroup(i,s,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:s,topology:n,size:r,start:o,instanceCount:a,skipSync:h}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,s,n),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,h),e.indexBuffer?this.renderPassEncoder.drawIndexed(r||e.indexBuffer.data.length,a??e.instanceCount,o||0):this.renderPassEncoder.draw(r||e.getSize(),a??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},s=this._boundIndexBuffer,n={...this._boundBindGroup};this._clearCache();const r=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(r.x,r.y,r.width,r.height,0,1),this.setPipeline(e);for(const t in i)this._setVertexBuffer(t,i[t]);for(const t in n)this.setBindGroup(t,n[t],null);this._setIndexBuffer(s)}_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}}du.extension={type:[qi.WebGPUSystem],name:"encoder",priority:1};class uu{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}uu.extension={type:[qi.WebGPUSystem],name:"limits"};class pu{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:ra.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 s=this._renderer;s.pipeline.setStencilMode(t),s.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}pu.extension={type:[qi.WebGPUSystem],name:"stencil"};const gu={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}};class fu extends Lc{constructor(){super({createUboElements:Ke,generateUboSync:qe})}}fu.extension={type:[qi.WebGPUSystem],name:"ubo"};const mu=128;class yu{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._renderer.renderableGC.addManagedHash(this,"_bindGroupHash"),this._batchBuffer=new hu({minUniformOffsetAlignment:mu});for(let t=0;t<2;t++){let e=fa.UNIFORM|fa.COPY_DST;0===t&&(e|=fa.COPY_SRC),this._buffers.push(new ma({data:this._batchBuffer.data,usage:e}))}}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,s=this._batchBuffer.addEmptyGroup(i.length);return this._renderer.ubo.syncUniformGroup(t,this._batchBuffer.data,s/4),this._bindGroupHash[t.uid]=this._getBindGroup(s/mu),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/mu)}getArrayBindGroup(t){const e=this._batchBuffer.addGroup(t);return this._getBindGroup(e/mu)}getArrayBufferResource(t){const e=this._batchBuffer.addGroup(t)/mu;return this._getBufferResource(e)}_getBufferResource(t){if(!this._bufferResources[t]){const e=this._buffers[t%2];this._bufferResources[t]=new Yc({buffer:e,offset:256*(t/2|0),size:mu})}return this._bufferResources[t]}_getBindGroup(t){if(!this._bindGroups[t]){const e=new co({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 s=1;s<this._buffers.length;s++){const n=this._buffers[s];i.copyBufferToBuffer(t.getGPUBuffer(e),mu,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}}yu.extension={type:[qi.WebGPUPipes],name:"uniformBatch"};const xu={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class bu{constructor(t){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=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(ra.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=Dc[t],this._updatePipeHash())}setPipeline(t,e,i,s){const n=this.getPipeline(t,e,i);s.setPipeline(n)}getPipeline(t,e,i,s){t._layoutKey||(Me(t,e.attributeData),this._generateBufferKey(t)),s||(s=t.topology);const n=function(t,e,i,s,n){return t<<24|e<<16|i<<10|s<<5|n}(t._layoutKey,e._layoutKey,i.data,i._blendModeId,xu[s]);return this._pipeCache[n]||(this._pipeCache[n]=this._createPipeline(t,e,i,s)),this._pipeCache[n]}_createPipeline(t,e,i,s){const n=this._gpu.device,r=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i);o[0].writeMask=this._stencilMode===ra.RENDERING_MASK_ADD?0:this._colorMask;const a=this._renderer.shader.getProgramData(e).pipeline,h={vertex:{module:this._getModule(e.vertex.source),entryPoint:e.vertex.entryPoint,buffers:r},fragment:{module:this._getModule(e.fragment.source),entryPoint:e.fragment.entryPoint,targets:o},primitive:{topology:s,cullMode:i.cullMode},layout:a,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};return this._depthStencilAttachment&&(h.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:i.depthTest,depthCompare:i.depthTest?"less":"always"}),n.createRenderPipeline(h)}_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 s=Object.keys(t.attributes).sort();for(let n=0;n<s.length;n++){const r=t.attributes[s[n]];e[i++]=r.offset,e[i++]=r.format,e[i++]=r.stride,e[i++]=r.instance}const n=e.join("|");return t._layoutKey=P(n,"geometry"),t._layoutKey}_generateAttributeLocationsKey(t){const e=[];let i=0;const s=Object.keys(t.attributeData).sort();for(let n=0;n<s.length;n++){const r=t.attributeData[s[n]];e[i++]=r.location}const n=e.join("|");return t._attributeLocationsKey=P(n,"programAttributes"),t._attributeLocationsKey}getBufferNamesToBind(t,e){const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bindingNamesCache[i])return this._bindingNamesCache[i];const s=this._createVertexBufferLayouts(t,e),n=Object.create(null),r=e.attributeData;for(let t=0;t<s.length;t++){const e=Object.values(s[t].attributes)[0].shaderLocation;for(const i in r)if(r[i].location===e){n[t]=i;break}}return this._bindingNamesCache[i]=n,n}_createVertexBufferLayouts(t,e){e._attributeLocationsKey||this._generateAttributeLocationsKey(e);const i=t._layoutKey<<16|e._attributeLocationsKey;if(this._bufferLayoutsCache[i])return this._bufferLayoutsCache[i];const s=[];return t.buffers.forEach(i=>{const n={arrayStride:0,stepMode:"vertex",attributes:[]},r=n.attributes;for(const s in e.attributeData){const a=t.attributes[s];1!==(a.divisor??1)&&o(a.divisor),a.buffer===i&&(n.arrayStride=a.stride,n.stepMode=a.instance?"instance":"vertex",r.push({shaderLocation:e.attributeData[s].location,offset:a.offset,format:a.format}))}r.length&&s.push(n)}),this._bufferLayoutsCache[i]=s,s}_updatePipeHash(){const t=(e=this._stencilMode,i=this._multisampleCount,this._colorMask<<6|e<<3|this._depthStencilAttachment<<1|i);var e,i;this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}bu.extension={type:[qi.WebGPUSystem],name:"pipeline"};class vu{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class _u{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,s,n){const r=this._renderer,o=this._getGpuColorTexture(t),a=r.texture.getGpuSource(e.source);return r.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:a,origin:n},s),e}startRenderPass(t,e=!0,i,s){const n=this._renderTargetSystem.getGpuRenderTarget(t),r=this.getDescriptor(t,e,i);n.descriptor=r,this._renderer.pipeline.setRenderTarget(n),this._renderer.encoder.beginRenderPass(n),this._renderer.encoder.setViewport(s)}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){"boolean"==typeof e&&(e=e?wo.ALL:wo.NONE);const s=this._renderTargetSystem,n=s.getGpuRenderTarget(t),r=t.colorTextures.map((t,r)=>{const o=n.contexts[r];let a,h;a=o?o.getCurrentTexture().createView():this._renderer.texture.getGpuSource(t).createView({mipLevelCount:1}),n.msaaTextures[r]&&(h=a,a=this._renderer.texture.getTextureView(n.msaaTextures[r]));const l=e&wo.COLOR?"clear":"load";return i??(i=s.defaultClearColor),{view:a,resolveTarget:h,clearValue:i,storeOp:"store",loadOp:l}});let o;if(!t.stencil&&!t.depth||t.depthStencilTexture||(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=n.msaa?4:1),t.depthStencilTexture){const i=e&wo.STENCIL?"clear":"load",s=e&wo.DEPTH?"clear":"load";o={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView(),stencilStoreOp:"store",stencilLoadOp:i,depthClearValue:1,depthLoadOp:s,depthStoreOp:"store"}}return{colorAttachments:r,depthStencilAttachment:o}}clear(t,e=!0,i,s){if(!e)return;const{gpu:n,encoder:r}=this._renderer,o=n.device;if(null===r.commandEncoder){const n=o.createCommandEncoder(),r=this.getDescriptor(t,e,i),a=n.beginRenderPass(r);a.setViewport(s.x,s.y,s.width,s.height,0,1),a.end();const h=n.finish();o.queue.submit([h])}else this.startRenderPass(t,e,i,s)}initGpuRenderTarget(t){t.isRoot=!0;const e=new vu;return t.colorTextures.forEach((t,i)=>{if(t instanceof sr){const s=t.resource.getContext("webgpu"),n=t.transparent?"premultiplied":"opaque";try{s.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:n})}catch(t){}e.contexts[i]=s}if(e.msaa=t.source.antialias,t.source.antialias){const t=new Ds({width:0,height:0,sampleCount:4});e.msaaTextures[i]=t}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(t=>{t.unconfigure()}),t.msaaTextures.forEach(t=>{t.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((t,i)=>{const s=e.msaaTextures[i];s?.resize(t.source.width,t.source.height,t.source._resolution)})}}class wu extends Zc{constructor(t){super(t),this.adaptor=new _u,this.adaptor.init(t,this)}}wu.extension={type:[qi.WebGPUSystem],name:"renderTarget"};class Au{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(t=>e.createBindGroupLayout({entries:t})),s={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(s)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}Au.extension={type:[qi.WebGPUSystem],name:"shader"};const Cu={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class Su{constructor(){this.defaultState=new mo,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t){return[{format:"bgra8unorm",writeMask:0,blend:Cu[t.blendMode]||Cu.normal}]}destroy(){this.gpu=null}}Su.extension={type:[qi.WebGPUSystem],name:"state"};const Iu={type:"image",upload(t,e,i){const s=t.resource,n=(0|t.pixelWidth)*(0|t.pixelHeight),r=s.byteLength/n;i.device.queue.writeTexture({texture:e},s,{offset:0,rowsPerImage:t.pixelHeight,bytesPerRow:t.pixelHeight*r},{width:t.pixelWidth,height:t.pixelHeight,depthOrArrayLayers:1})}},Mu={"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}},Tu={blockBytes:4,blockWidth:1,blockHeight:1},Pu={type:"compressed",upload(t,e,i){let s=t.pixelWidth,n=t.pixelHeight;const r=Mu[t.format]||Tu;for(let o=0;o<t.resource.length;o++){const a=t.resource[o],h=Math.ceil(s/r.blockWidth)*r.blockBytes;i.device.queue.writeTexture({texture:e,mipLevel:o},a,{offset:0,bytesPerRow:h},{width:Math.ceil(s/r.blockWidth)*r.blockWidth,height:Math.ceil(n/r.blockHeight)*r.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),n=Math.max(n>>1,1)}}},Eu={type:"image",upload(t,e,i){const s=t.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){const e=ir.get().createCanvas(s.width,s.height);e.getContext("2d").drawImage(s,0,0,s.width,s.height),t.resource=e,o()}const n=Math.min(e.width,t.resourceWidth||t.pixelWidth),r=Math.min(e.height,t.resourceHeight||t.pixelHeight),a="premultiply-alpha-on-upload"===t.alphaMode;i.device.queue.copyExternalImageToTexture({source:s},{texture:e,premultipliedAlpha:a},{width:n,height:r})}},Bu={type:"video",upload(t,e,i){Eu.upload(t,e,i)}};class Ru{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:"\n var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));\n\n struct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) texCoord : vec2<f32>,\n };\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {\n var output : VertexOutput;\n output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);\n return output;\n }\n\n @group(0) @binding(0) var imgSampler : sampler;\n @group(0) @binding(1) var img : texture_2d<f32>;\n\n @fragment\n fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(img, imgSampler, texCoord);\n }\n "})),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("3d"===t.dimension||"1d"===t.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const s=t.depthOrArrayLayers||1,n=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!n){const e={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(e)}const r=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let a=0;a<s;++a){let s=t.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),h=n?1:0;for(let n=1;n<t.mipLevelCount;++n){const t=i.createView({baseMipLevel:h++,mipLevelCount:1,dimension:"2d",baseArrayLayer:a,arrayLayerCount:1}),n=r.beginRenderPass({colorAttachments:[{view:t,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),l=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.sampler},{binding:1,resource:s}]});n.setPipeline(e),n.setBindGroup(0,l),n.draw(3,1,0,0),n.end(),s=t}}if(!n){const e={width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:s};for(let s=1;s<t.mipLevelCount;++s)r.copyTextureToTexture({texture:i,mipLevel:s-1},{texture:t,mipLevel:s},e),e.width=Math.ceil(e.width/2),e.height=Math.ceil(e.height/2)}return this.device.queue.submit([r.finish()]),n||i.destroy(),t}}class ku{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:Eu,buffer:Iu,video:Bu,compressed:Pu},this._renderer=t,t.renderableGC.addManagedHash(this,"_gpuSources"),t.renderableGC.addManagedHash(this,"_gpuSamplers"),t.renderableGC.addManagedHash(this,"_bindGroupHash"),t.renderableGC.addManagedHash(this,"_textureViewHash")}contextChange(t){this._gpu=t}initSource(t){return this._gpuSources[t.uid]?this._gpuSources[t.uid]:this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const e=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(e))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==t.uploadMethodId&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=Mu[t.format]||{blockWidth:1,blockHeight:1},s=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,n=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,r={label:t.label,size:{width:s,height:n},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpuSources[t.uid]=this._gpu.device.createTexture(r);return 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 Ru(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;return this._bindGroupHash[t.uid]=new co({0:e,1:e.style,2:new lo({uTextureMatrix:{type:"mat3x3<f32>",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}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(),s=ir.get().createCanvas();s.width=t.source.pixelWidth,s.height=t.source.pixelHeight;const n=s.getContext("webgpu");return n.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:ir.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:n.getCurrentTexture()},{width:s.width,height:s.height}),e.gpu.device.queue.submit([i.finish()]),s}getPixels(t){const e=this.generateCanvas(t),i=xh.getOptimalCanvasAndContext(e.width,e.height),s=i.context;s.drawImage(e,0,0);const{width:n,height:r}=e,o=s.getImageData(0,0,n,r),a=new Uint8ClampedArray(o.data.buffer);return xh.returnCanvasAndContext(i),{pixels:a,width:n,height:r}}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?.destroy(),this._bindGroupHash[e]=null}this._gpu=null,this._mipmapGenerator=null,this._gpuSources=null,this._bindGroupHash=null,this._textureViewHash=null,this._gpuSamplers=null}}ku.extension={type:[qi.WebGPUSystem],name:"texture"};class Ou{constructor(){this._maxTextures=0}contextChange(t){const e=new lo({uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Rt({name:"graphics",bits:[Ma,Ft(this._maxTextures),hc,Ba]});this.shader=new po({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,s=i.customShader||this.shader,n=t.renderer,r=n.graphicsContext,{batcher:o,instructions:a}=r.getContextRenderData(i),h=n.encoder;h.setGeometry(o.geometry,s.gpuProgram);const l=n.globalUniforms.bindGroup;h.setBindGroup(0,l,s.gpuProgram);const c=n.renderPipes.uniformBatch.getUniformBindGroup(s.resources.localUniforms,!0);h.setBindGroup(2,c,s.gpuProgram);const d=a.instructions;let u=null;for(let e=0;e<a.instructionSize;e++){const i=d[e];if(i.topology!==u&&(u=i.topology,h.setPipelineFromGeometryProgramAndState(o.geometry,s.gpuProgram,t.state,i.topology)),s.groups[1]=i.bindGroup,!i.gpuBindGroup){const t=i.textures;i.bindGroup=ft(t.textures,t.count,this._maxTextures),i.gpuBindGroup=n.bindGroup.getBindGroup(i.bindGroup,s.gpuProgram,1)}h.setBindGroup(1,i.bindGroup,s.gpuProgram),h.renderPassEncoder.drawIndexed(i.size,1,i.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}Ou.extension={type:[qi.WebGPUPipesAdaptor],name:"graphics"};class Du{init(){const t=Rt({name:"mesh",bits:[ac,cc,Ba]});this._shader=new po({gpuProgram:t,resources:{uTexture:Gs.EMPTY._source,uSampler:Gs.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new ps}}}})}execute(t,e){const i=t.renderer;let s=e._shader;if(s){if(!s.gpuProgram)return void o(e.shader)}else s=this._shader,s.groups[2]=i.texture.getTextureBindGroup(e.texture);const n=s.gpuProgram;if(n.autoAssignGlobalUniforms&&(s.groups[0]=i.globalUniforms.bindGroup),n.autoAssignLocalUniforms){const e=t.localUniforms;s.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(e,!0)}i.encoder.draw({geometry:e._geometry,shader:s,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Du.extension={type:[qi.WebGPUPipesAdaptor],name:"mesh"};const Fu=[...Qd,fu,du,cu,uu,au,ku,wu,Au,Su,bu,lu,pu,ou],Lu=[...qd,yu],ju=[nc,Du,Ou],Gu=[],Uu=[],zu=[];es.handleByNamedList(qi.WebGPUSystem,Gu),es.handleByNamedList(qi.WebGPUPipes,Uu),es.handleByNamedList(qi.WebGPUPipesAdaptor,zu),es.add(...Fu,...Lu,...ju);const Nu=Object.freeze(Object.defineProperty({__proto__:null,WebGPURenderer:class extends To{constructor(){super({name:"webgpu",type:uo.WEBGPU,systems:Gu,renderPipes:Uu,renderPipeAdaptors:zu})}}},Symbol.toStringTag,{value:"Module"}));class Vu{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{_n.return(t)}),this.batches.length=0}}class Hu{constructor(t,e){this.state=mo.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this)}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,s=this.renderer.graphicsContext.updateGpuContext(e);return!(!s.isBatchable&&i===s.isBatchable)}addRenderable(t,e){const i=this.renderer.graphicsContext.updateGpuContext(t.context);t.didViewUpdate&&this._rebuild(t),i.isBatchable?this._addToBatcher(t,e):(this.renderer.renderPipes.batch.break(e),e.add(t))}updateRenderable(t){const e=this._getGpuDataForRenderable(t).batches;for(let t=0;t<e.length;t++){const i=e[t];i._batcher.updateElement(i)}}execute(t){if(!t.isRenderable)return;const e=this.renderer,i=t.context;if(!e.graphicsContext.getGpuContext(i).batches.length)return;const s=i.customShader||this._adaptor.shader;this.state.blendMode=t.groupBlendMode;const n=s.resources.localUniforms.uniforms;n.uTransformMatrix=t.groupTransform,n.uRound=e._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,n.uColor,0),this._adaptor.execute(this,t)}_rebuild(t){const e=this._getGpuDataForRenderable(t),i=this.renderer.graphicsContext.updateGpuContext(t.context);e.destroy(),i.isBatchable&&this._updateBatchesForRenderable(t,e)}_addToBatcher(t,e){const i=this.renderer.renderPipes.batch,s=this._getGpuDataForRenderable(t).batches;for(let t=0;t<s.length;t++){const n=s[t];i.addToBatch(n,e)}}_getGpuDataForRenderable(t){return t._gpuData[this.renderer.uid]||this._initGpuDataForRenderable(t)}_initGpuDataForRenderable(t){const e=new Vu;return t._gpuData[this.renderer.uid]=e,e}_updateBatchesForRenderable(t,e){const i=t.context,s=this.renderer.graphicsContext.getGpuContext(i),n=this.renderer._roundPixels|t._roundPixels;e.batches=s.batches.map(e=>{const i=_n.get(Ga);return e.copyTo(i),i.renderable=t,i.roundPixels=n,i})}destroy(){this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Hu.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"graphics"};const Wu=class t extends Ul{constructor(...t){super({});let e=t[0]??{};"number"==typeof e&&(Ps(0,"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(e){e={...t.defaultOptions,...e},this.verticesX=this.verticesX??e.verticesX,this.verticesY=this.verticesY??e.verticesY,this.width=this.width??e.width,this.height=this.height??e.height;const i=this.verticesX*this.verticesY,s=[],n=[],r=[],o=this.verticesX-1,a=this.verticesY-1,h=this.width/o,l=this.height/a;for(let t=0;t<i;t++){const e=t%this.verticesX,i=t/this.verticesX|0;s.push(e*h,i*l),n.push(e/o,i/a)}const c=o*a;for(let t=0;t<c;t++){const e=t%o,i=t/o|0,s=i*this.verticesX+e,n=i*this.verticesX+e+1,a=(i+1)*this.verticesX+e,h=(i+1)*this.verticesX+e+1;r.push(s,n,a,n,h,a)}this.buffers[0].data=new Float32Array(s),this.buffers[1].data=new Float32Array(n),this.indexBuffer.data=new Uint32Array(r),this.buffers[0].update(),this.buffers[1].update(),this.indexBuffer.update()}};Wu.defaultOptions={width:100,height:100,verticesX:10,verticesY:10};let Ju=Wu;class Zu{constructor(){this.batcherName="default",this.packAsQuad=!1,this.indexOffset=0,this.attributeOffset=0,this.roundPixels=0,this._batcher=null,this._batch=null,this._textureMatrixUpdateId=-1,this._uvUpdateId=-1}get blendMode(){return this.renderable.groupBlendMode}get topology(){return this._topology||this.geometry.topology}set topology(t){this._topology=t}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.geometry=null,this._uvUpdateId=-1,this._textureMatrixUpdateId=-1}setTexture(t){this.texture!==t&&(this.texture=t,this._textureMatrixUpdateId=-1)}get uvs(){const t=this.geometry.getBuffer("aUV"),e=t.data;let i=e;const s=this.texture.textureMatrix;return s.isSimple||(i=this._transformedUvs,this._textureMatrixUpdateId===s._updateID&&this._uvUpdateId===t._updateID||((!i||i.length<e.length)&&(i=this._transformedUvs=new Float32Array(e.length)),this._textureMatrixUpdateId=s._updateID,this._uvUpdateId=t._updateID,s.multiplyUvs(e,i))),i}get positions(){return this.geometry.positions}get indices(){return this.geometry.indices}get color(){return this.renderable.groupColorAlpha}get groupTransform(){return this.renderable.groupTransform}get attributeSize(){return this.geometry.positions.length/2}get indexSize(){return this.geometry.indices.length}}class Xu{destroy(){}}class Yu{constructor(t,e){this.localUniforms=new lo({uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new co({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,s=t.batched;if(e.batched=s,i!==s)return!0;if(s){const i=t._geometry;if(i.indices.length!==e.indexSize||i.positions.length!==e.vertexSize)return e.indexSize=i.indices.length,e.vertexSize=i.positions.length,!0;const s=this._getBatchableMesh(t);return s.texture.uid!==t._texture.uid&&(s._textureMatrixUpdateId=-1),!s._batcher.checkAndUpdateTexture(s,t._texture)}return!1}addRenderable(t,e){const i=this.renderer.renderPipes.batch,s=this._getMeshData(t);if(t.didViewUpdate&&(s.indexSize=t._geometry.indices?.length,s.vertexSize=t._geometry.positions?.length),s.batched){const s=this._getBatchableMesh(t);s.setTexture(t._texture),s.geometry=t._geometry,i.addToBatch(s,e)}else i.break(e),e.add(t)}updateRenderable(t){if(t.batched){const e=this._getBatchableMesh(t);e.setTexture(t._texture),e.geometry=t._geometry,e._batcher.updateElement(e)}}execute(t){if(!t.isRenderable)return;t.state.blendMode=yt(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Ze(t.groupColorAlpha,e.uniforms.uColor,0),this._adaptor.execute(this,t)}_getMeshData(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Xu),t._gpuData[this.renderer.uid].meshData||this._initMeshData(t)}_initMeshData(t){return t._gpuData[this.renderer.uid].meshData={batched:t.batched,indexSize:0,vertexSize:0},t._gpuData[this.renderer.uid].meshData}_getBatchableMesh(t){var e,i;return(e=t._gpuData)[i=this.renderer.uid]||(e[i]=new Xu),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new Zu;return e.renderable=t,e.setTexture(t._texture),e.transform=t.groupTransform,e.roundPixels=this.renderer._roundPixels|t._roundPixels,t._gpuData[this.renderer.uid].batchableMesh=e,e}destroy(){this.localUniforms=null,this.localUniformsBindGroup=null,this._adaptor.destroy(),this._adaptor=null,this.renderer=null}}Yu.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"mesh"};class Ku{execute(t,e){const i=t.state,s=t.renderer,n=e.shader||t.defaultShader;n.resources.uTexture=e.texture._source,n.resources.uniforms=t.localUniforms;const r=s.gl,o=t.getBuffers(e);s.shader.bind(n),s.state.set(i),s.geometry.bind(o.geometry,n.glProgram);const a=2===o.geometry.indexBuffer.data.BYTES_PER_ELEMENT?r.UNSIGNED_SHORT:r.UNSIGNED_INT;r.drawElements(r.TRIANGLES,6*e.particleChildren.length,a,0)}}class Qu{execute(t,e){const i=t.renderer,s=e.shader||t.defaultShader;s.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),s.groups[1]=i.texture.getTextureBindGroup(e.texture);const n=t.state,r=t.getBuffers(e);i.encoder.draw({geometry:r.geometry,shader:e.shader||t.defaultShader,state:n,size:6*e.particleChildren.length})}}class qu{constructor(t){this._size=0,this._generateParticleUpdateCache={};const e=this._size=t.size??1e3,i=t.properties;let s=0,n=0;for(const t in i){const e=i[t],r=R(e.format);e.dynamic?n+=r.stride:s+=r.stride}this._dynamicStride=n/4,this._staticStride=s/4,this.staticAttributeBuffer=new sa(4*e*s),this.dynamicAttributeBuffer=new sa(4*e*n),this.indexBuffer=$e(e);const r=new ya;let o=0,a=0;this._staticBuffer=new ma({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:fa.VERTEX|fa.COPY_DST}),this._dynamicBuffer=new ma({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:fa.VERTEX|fa.COPY_DST});for(const t in i){const e=i[t],s=R(e.format);e.dynamic?(r.addAttribute(e.attributeName,{buffer:this._dynamicBuffer,stride:4*this._dynamicStride,offset:4*o,format:e.format}),o+=s.size):(r.addAttribute(e.attributeName,{buffer:this._staticBuffer,stride:4*this._staticStride,offset:4*a,format:e.format}),a+=s.size)}r.addIndex(this.indexBuffer);const h=this.getParticleUpdate(i);this._dynamicUpload=h.dynamicUpdate,this._staticUpload=h.staticUpdate,this.geometry=r}getParticleUpdate(t){const e=function(t){const e=[];for(const i in t){const s=t[i];e.push(i,s.code,s.dynamic?"d":"s")}return e.join("_")}(t);return this._generateParticleUpdateCache[e]||(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t)),this._generateParticleUpdateCache[e]}generateParticleUpdate(t){return function(t){return{dynamicUpdate:ti(t,!0),staticUpdate:ti(t,!1)}}(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,1.5*this._size|0),this.staticAttributeBuffer=new sa(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new sa(this._size*this._dynamicStride*4*4),this.indexBuffer=$e(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));const i=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,i.float32View,i.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){const e=this.staticAttributeBuffer;this._staticUpload(t,e.float32View,e.uint32View),this._staticBuffer.setDataWithSize(e.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}var $u="\nstruct ParticleUniforms {\n uTranslationMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n uResolution:vec2<f32>,\n};\n\nfn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>\n{\n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\n@group(0) @binding(0) var<uniform> uniforms: ParticleUniforms;\n\n@group(1) @binding(0) var uTexture: texture_2d<f32>;\n@group(1) @binding(1) var uSampler : sampler;\n\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv : vec2<f32>,\n @location(1) color : vec4<f32>,\n };\n@vertex\nfn mainVertex(\n @location(0) aVertex: vec2<f32>,\n @location(1) aPosition: vec2<f32>,\n @location(2) aUV: vec2<f32>,\n @location(3) aColor: vec4<f32>,\n @location(4) aRotation: f32,\n) -> VSOutput {\n \n let v = vec2(\n aVertex.x * cos(aRotation) - aVertex.y * sin(aRotation),\n aVertex.x * sin(aRotation) + aVertex.y * cos(aRotation)\n ) + aPosition;\n\n var position = vec4((uniforms.uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uniforms.uRound == 1.0) {\n position = vec4(roundPixels(position.xy, uniforms.uResolution), position.zw);\n }\n\n let vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uniforms.uColor;\n\n return VSOutput(\n position,\n aUV,\n vColor,\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n @location(1) color: vec4<f32>,\n @builtin(position) position: vec4<f32>,\n) -> @location(0) vec4<f32> {\n\n var sample = textureSample(uTexture, uSampler, uv) * color;\n \n return sample;\n}";class tp extends po{constructor(){super({glProgram:to.from({vertex:"attribute vec2 aVertex;\nattribute vec2 aUV;\nattribute vec4 aColor;\n\nattribute vec2 aPosition;\nattribute float aRotation;\n\nuniform mat3 uTranslationMatrix;\nuniform float uRound;\nuniform vec2 uResolution;\nuniform vec4 uColor;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n\nvec2 roundPixels(vec2 position, vec2 targetSize)\n{ \n return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;\n}\n\nvoid main(void){\n float cosRotation = cos(aRotation);\n float sinRotation = sin(aRotation);\n float x = aVertex.x * cosRotation - aVertex.y * sinRotation;\n float y = aVertex.x * sinRotation + aVertex.y * cosRotation;\n\n vec2 v = vec2(x, y);\n v = v + aPosition;\n\n gl_Position = vec4((uTranslationMatrix * vec3(v, 1.0)).xy, 0.0, 1.0);\n\n if(uRound == 1.0)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n\n vUV = aUV;\n vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor;\n}\n",fragment:"varying vec2 vUV;\nvarying vec4 vColor;\n\nuniform sampler2D uTexture;\n\nvoid main(void){\n vec4 color = texture2D(uTexture, vUV) * vColor;\n gl_FragColor = color;\n}"}),gpuProgram:ro.from({fragment:{source:$u,entryPoint:"mainFragment"},vertex:{source:$u,entryPoint:"mainVertex"}}),resources:{uTexture:Gs.WHITE.source,uSampler:new ks({}),uniforms:{uTranslationMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new yn(16777215),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}}})}}class ep{constructor(t,e){this.state=mo.for2d(),this.localUniforms=new lo({uTranslationMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array(4),type:"vec4<f32>"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2<f32>"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new tp,this.state=mo.for2d()}validateRenderable(t){return!1}addRenderable(t,e){this.renderer.renderPipes.batch.break(e),e.add(t)}getBuffers(t){return t._gpuData[this.renderer.uid]||this._initBuffer(t)}_initBuffer(t){return t._gpuData[this.renderer.uid]=new qu({size:t.particleChildren.length,properties:t._properties}),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(0===e.length)return;const i=this.renderer,s=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const n=this.state;s.update(e,t._childrenDirty),t._childrenDirty=!1,n.blendMode=yt(t.blendMode,t.texture._source);const r=this.localUniforms.uniforms,o=r.uTranslationMatrix;t.worldTransform.copyTo(o),o.prepend(i.globalUniforms.globalUniformData.projectionMatrix),r.uResolution=i.globalUniforms.globalUniformData.resolution,r.uRound=i._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,r.uColor,0),this.adaptor.execute(this,t)}destroy(){this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}class ip extends ep{constructor(t){super(t,new Ku)}}ip.extension={type:[qi.WebGLPipes],name:"particle"};class sp extends ep{constructor(t){super(t,new Qu)}}sp.extension={type:[qi.WebGPUPipes],name:"particle"};const np=class t extends Ju{constructor(e={}){super({width:(e={...t.defaultOptions,...e}).width,height:e.height,verticesX:4,verticesY:4}),this.update(e)}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._anchorX=t.anchor?.x,this._anchorY=t.anchor?.y,this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:s,_rightWidth:n,_topHeight:r,_bottomHeight:o,_anchorX:a,_anchorY:h}=this,l=s+n,c=e>l?1:e/l,d=r+o,u=i>d?1:i/d,p=Math.min(c,u),g=a*e,f=h*i;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=s*p-g,t[4]=t[12]=t[20]=t[28]=e-n*p-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-f,t[9]=t[11]=t[13]=t[15]=r*p-f,t[17]=t[19]=t[21]=t[23]=i-o*p-f,t[25]=t[27]=t[29]=t[31]=i-f,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()}};np.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let rp=np;class op extends Zu{constructor(){super(),this.geometry=new rp}destroy(){this.geometry.destroy()}}class ap{constructor(t){this._renderer=t}addRenderable(t,e){const i=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,i),this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuSprite(t);t.didViewUpdate&&this._updateBatchableSprite(t,e),e._batcher.updateElement(e)}validateRenderable(t){const e=this._getGpuSprite(t);return!e._batcher.checkAndUpdateTexture(e,t._texture)}_updateBatchableSprite(t,e){e.geometry.update(t),e.setTexture(t._texture)}_getGpuSprite(t){return t._gpuData[this._renderer.uid]||this._initGPUSprite(t)}_initGPUSprite(t){const e=t._gpuData[this._renderer.uid]=new op,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._renderer=null}}ap.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"nineSliceSprite"};const hp={name:"tiling-bit",vertex:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n uv = (tilingUniforms.uTextureTransform * vec3(uv, 1.0)).xy;\n\n position = (position - tilingUniforms.uSizeAnchor.zw) * tilingUniforms.uSizeAnchor.xy;\n "},fragment:{header:"\n struct TilingUniforms {\n uMapCoord:mat3x3<f32>,\n uClampFrame:vec4<f32>,\n uClampOffset:vec2<f32>,\n uTextureTransform:mat3x3<f32>,\n uSizeAnchor:vec4<f32>\n };\n\n @group(2) @binding(0) var<uniform> tilingUniforms: TilingUniforms;\n @group(2) @binding(1) var uTexture: texture_2d<f32>;\n @group(2) @binding(2) var uSampler: sampler;\n ",main:"\n\n var coord = vUV + ceil(tilingUniforms.uClampOffset - vUV);\n coord = (tilingUniforms.uMapCoord * vec3(coord, 1.0)).xy;\n var unclamped = coord;\n coord = clamp(coord, tilingUniforms.uClampFrame.xy, tilingUniforms.uClampFrame.zw);\n\n var bias = 0.;\n\n if(unclamped.x == coord.x && unclamped.y == coord.y)\n {\n bias = -32.;\n }\n\n outColor = textureSampleBias(uTexture, uSampler, coord, bias);\n "}},lp={name:"tiling-bit",vertex:{header:"\n uniform mat3 uTextureTransform;\n uniform vec4 uSizeAnchor;\n\n ",main:"\n uv = (uTextureTransform * vec3(aUV, 1.0)).xy;\n\n position = (position - uSizeAnchor.zw) * uSizeAnchor.xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n uniform mat3 uMapCoord;\n uniform vec4 uClampFrame;\n uniform vec2 uClampOffset;\n ",main:"\n\n vec2 coord = vUV + ceil(uClampOffset - vUV);\n coord = (uMapCoord * vec3(coord, 1.0)).xy;\n vec2 unclamped = coord;\n coord = clamp(coord, uClampFrame.xy, uClampFrame.zw);\n\n outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0\n\n "}};let cp,dp;class up extends po{constructor(){cp??(cp=Rt({name:"tiling-sprite-shader",bits:[ac,hp,Ba]})),dp??(dp=kt({name:"tiling-sprite-shader",bits:[lc,lp,Ra]}));const t=new lo({uMapCoord:{value:new ps,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 ps,type:"mat3x3<f32>"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4<f32>"}});super({glProgram:dp,gpuProgram:cp,resources:{localUniforms:new lo({uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:Gs.EMPTY.source,uSampler:Gs.EMPTY.source.style}})}updateUniforms(t,e,i,s,n,r){const o=this.resources.tilingUniforms,a=r.width,h=r.height,l=r.textureMatrix,c=o.uniforms.uTextureTransform;c.set(i.a*a/t,i.b*a/e,i.c*h/t,i.d*h/e,i.tx/t,i.ty/e),c.invert(),o.uniforms.uMapCoord=l.mapCoord,o.uniforms.uClampFrame=l.uClampFrame,o.uniforms.uClampOffset=l.uClampOffset,o.uniforms.uTextureTransform=c,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=s,o.uniforms.uSizeAnchor[3]=n,r&&(this.resources.uTexture=r.source,this.resources.uSampler=r.source.style)}}const pp=new class extends Ul{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])})}};class gp{constructor(){this.canBatch=!0,this.geometry=new Ul({indices:pp.indices.slice(),positions:pp.positions.slice(),uvs:pp.uvs.slice()})}destroy(){this.geometry.destroy(),this.shader?.destroy()}}class fp{constructor(t){this._state=mo.default2d,this._renderer=t}validateRenderable(t){const e=this._getTilingSpriteData(t),i=e.canBatch;this._updateCanBatch(t);const s=e.canBatch;if(s&&s===i){const{batchableMesh:i}=e;return!i._batcher.checkAndUpdateTexture(i,t.texture)}return i!==s}addRenderable(t,e){const i=this._renderer.renderPipes.batch;this._updateCanBatch(t);const s=this._getTilingSpriteData(t),{geometry:n,canBatch:r}=s;if(r){s.batchableMesh||(s.batchableMesh=new Zu);const r=s.batchableMesh;t.didViewUpdate&&(this._updateBatchableMesh(t),r.geometry=n,r.renderable=t,r.transform=t.groupTransform,r.setTexture(t._texture)),r.roundPixels=this._renderer._roundPixels|t._roundPixels,i.addToBatch(r,e)}else i.break(e),s.shader||(s.shader=new up),this.updateRenderable(t),e.add(t)}execute(t){const{shader:e}=this._getTilingSpriteData(t);e.groups[0]=this._renderer.globalUniforms.bindGroup;const i=e.resources.localUniforms.uniforms;i.uTransformMatrix=t.groupTransform,i.uRound=this._renderer._roundPixels|t._roundPixels,Ze(t.groupColorAlpha,i.uColor,0),this._state.blendMode=yt(t.groupBlendMode,t.texture._source),this._renderer.encoder.draw({geometry:pp,shader:e,state:this._state})}updateRenderable(t){const e=this._getTilingSpriteData(t),{canBatch:i}=e;if(i){const{batchableMesh:i}=e;t.didViewUpdate&&this._updateBatchableMesh(t),i._batcher.updateElement(i)}else if(t.didViewUpdate){const{shader:i}=e;i.updateUniforms(t.width,t.height,t._tileTransform.matrix,t.anchor.x,t.anchor.y,t.texture)}}_getTilingSpriteData(t){return t._gpuData[this._renderer.uid]||this._initTilingSpriteData(t)}_initTilingSpriteData(t){const e=new gp;return e.renderable=t,t._gpuData[this._renderer.uid]=e,e}_updateBatchableMesh(t){const e=this._getTilingSpriteData(t),{geometry:i}=e,s=t.texture.source.style;"repeat"!==s.addressMode&&(s.addressMode="repeat",s.update()),function(t,e){const i=t.texture,s=i.frame.width,n=i.frame.height;let r=0,o=0;t.applyAnchorToTexture&&(r=t.anchor.x,o=t.anchor.y),e[0]=e[6]=-r,e[2]=e[4]=1-r,e[1]=e[3]=-o,e[5]=e[7]=1-o;const a=ps.shared;a.copyFrom(t._tileTransform.matrix),a.tx/=t.width,a.ty/=t.height,a.invert(),a.scale(t.width/s,t.height/n),function(t,e,i,s){let n=0;const r=t.length/2,o=s.a,a=s.b,h=s.c,l=s.d,c=s.tx,d=s.ty;for(i*=2;n<r;){const e=t[i],s=t[i+1];t[i]=o*e+h*s+c,t[i+1]=a*e+l*s+d,i+=2,n++}}(e,0,0,a)}(t,i.uvs),function(t,e){const i=t.anchor.x,s=t.anchor.y;e[0]=-i*t.width,e[1]=-s*t.height,e[2]=(1-i)*t.width,e[3]=-s*t.height,e[4]=(1-i)*t.width,e[5]=(1-s)*t.height,e[6]=-i*t.width,e[7]=(1-s)*t.height}(t,i.positions)}destroy(){this._renderer=null}_updateCanBatch(t){const e=this._getTilingSpriteData(t),i=t.texture;let s=!0;return this._renderer.type===uo.WEBGL&&(s=this._renderer.context.supports.nonPowOf2wrapping),e.canBatch=i.textureMatrix.isSimple&&(s||i.source.isPowerOfTwo),e.canBatch}}fp.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"tilingSprite"};const mp={name:"local-uniform-msdf-bit",vertex:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32,\n uRound:f32,\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "},fragment:{header:"\n struct LocalUniforms {\n uColor:vec4<f32>,\n uTransformMatrix:mat3x3<f32>,\n uDistance: f32\n }\n\n @group(2) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n outColor = vec4<f32>(calculateMSDFAlpha(outColor, localUniforms.uColor, localUniforms.uDistance));\n "}},yp={name:"local-uniform-msdf-bit",vertex:{header:"\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix *= uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "},fragment:{header:"\n uniform float uDistance;\n ",main:"\n outColor = vec4(calculateMSDFAlpha(outColor, vColor, uDistance));\n "}},xp={name:"msdf-bit",fragment:{header:"\n fn calculateMSDFAlpha(msdfColor:vec4<f32>, shapeColor:vec4<f32>, distance:f32) -> f32 {\n\n // MSDF\n var median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n var screenPxDistance = distance * (median - 0.5);\n var alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n var luma: f32 = dot(shapeColor.rgb, vec3<f32>(0.299, 0.587, 0.114));\n var gamma: f32 = mix(1.0, 1.0 / 2.2, luma);\n var coverage: f32 = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n\n }\n "}},bp={name:"msdf-bit",fragment:{header:"\n float calculateMSDFAlpha(vec4 msdfColor, vec4 shapeColor, float distance) {\n\n // MSDF\n float median = msdfColor.r + msdfColor.g + msdfColor.b -\n min(msdfColor.r, min(msdfColor.g, msdfColor.b)) -\n max(msdfColor.r, max(msdfColor.g, msdfColor.b));\n\n // SDF\n median = min(median, msdfColor.a);\n\n float screenPxDistance = distance * (median - 0.5);\n float alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\n if (median < 0.01) {\n alpha = 0.0;\n } else if (median > 0.99) {\n alpha = 1.0;\n }\n\n // Gamma correction for coverage-like alpha\n float luma = dot(shapeColor.rgb, vec3(0.299, 0.587, 0.114));\n float gamma = mix(1.0, 1.0 / 2.2, luma);\n float coverage = pow(shapeColor.a * alpha, gamma);\n\n return coverage;\n }\n "}};let vp,_p;class wp extends po{constructor(t){const e=new lo({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new ps,type:"mat3x3<f32>"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});vp??(vp=Rt({name:"sdf-shader",bits:[Ma,Ft(t),mp,xp,Ba]})),_p??(_p=kt({name:"sdf-shader",bits:[Ta,jt(t),yp,bp,Ra]})),super({glProgram:_p,gpuProgram:vp,resources:{localUniforms:e,batchSamplers:Gt(t)}})}}class Ap extends jl{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class Cp{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);ei(t,i),t._didTextUpdate&&(t._didTextUpdate=!1,this._updateContext(t,i)),this._renderer.renderPipes.graphics.addRenderable(i,e),i.context.customShader&&this._updateDistanceField(t)}updateRenderable(t){const e=this._getGpuBitmapText(t);ei(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,s=Ah.getFont(t.text,t._style);i.clear(),"none"!==s.distanceField.type&&(i.customShader||(i.customShader=new wp(this._renderer.limits.maxBatchableTextures)));const n=No.graphemeSegmenter(t.text),r=t._style;let o=s.baseLineOffset;const a=fe(n,r,s,!0),h=r.padding,l=a.scale;let c=a.width,d=a.height+a.offsetY;r._stroke&&(c+=r._stroke.width/l,d+=r._stroke.width/l),i.translate(-t._anchor._x*c-h,-t._anchor._y*d-h).scale(l,l);const u=s.applyFillAsTint?r._fill.color:16777215;let p=s.fontMetrics.fontSize,g=s.lineHeight;r.lineHeight&&(p=r.fontSize/l,g=r.lineHeight/l);let f=(g-p)/2;f-s.baseLineOffset<0&&(f=0);for(let t=0;t<a.lines.length;t++){const e=a.lines[t];for(let t=0;t<e.charPositions.length;t++){const n=e.chars[t],r=s.chars[n];if(r?.texture){const s=r.texture;i.texture(s,u||"black",Math.round(e.charPositions[t]+r.xOffset),Math.round(o+r.yOffset+f),s.orig.width,s.orig.height)}}o+=g}}_getGpuBitmapText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Ap;return t._gpuData[this._renderer.uid]=e,this._updateContext(t,e),e}_updateDistanceField(t){const e=this._getGpuBitmapText(t).context,i=t._style.fontFamily,s=pr.get(`${i}-bitmap`),{a:n,b:r,c:o,d:a}=t.groupTransform,h=Math.sqrt(n*n+r*r),l=Math.sqrt(o*o+a*a),c=(Math.abs(h)+Math.abs(l))/2,d=s.baseRenderedFontSize/t._style.fontSize,u=c*s.distanceField.range*(1/d);e.customShader.resources.localUniforms.uniforms.uDistance=u}destroy(){this._renderer=null}}Cp.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"bitmapText"};class Sp extends _d{constructor(t){super(),this.generatingTexture=!1,this.currentKey="--",this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{htmlText:t}=this._renderer;null===t.getReferenceCount(this.currentKey)?t.returnTexturePromise(this.texturePromise):t.decreaseReferenceCount(this.currentKey),this._renderer.runners.resolutionChange.remove(this),this.texturePromise=null,this._renderer=null}}class Ip{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const e=t._autoResolution?this._renderer.resolution:t.resolution;i.currentKey===t.styleKey&&t.resolution===e||this._updateGpuText(t).catch(t=>{}),t._didTextUpdate=!1,ii(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}async _updateGpuText(t){t._didTextUpdate=!1;const e=this._getGpuText(t);if(e.generatingTexture)return;const i=e.texturePromise;e.texturePromise=null,e.generatingTexture=!0,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;let s=this._renderer.htmlText.getTexturePromise(t);i&&(s=s.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=s,e.currentKey=t.styleKey,e.texture=await s;const n=t.renderGroup||t.parentRenderGroup;n&&(n.structureDidChange=!0),e.generatingTexture=!1,ii(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Sp(this._renderer);return e.renderable=t,e.transform=t.groupTransform,e.texture=Gs.EMPTY,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Ip.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"htmlText"};const Mp=new zs,Tp=new Map;class Pp{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===uo.WEBGPU}getTexture(t){return this.getTexturePromise(t)}getManagedTexture(t){const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].promise;const i=this._buildTexturePromise(t).then(t=>(this._activeTextures[e].texture=t,t));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){return this._activeTextures[t]?.usageCount??null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,0===e.usageCount&&(e.texture?this._cleanUp(e.texture):e.promise.then(t=>{e.texture=t,this._cleanUp(e.texture)}).catch(()=>{o()}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:s,textureStyle:n}=t,r=_n.get(tc),o=function(t,e){function i(t){r[t]||(n.push(t),r[t]=!0)}const s=e.fontFamily,n=[],r={},o=t.match(/font-family:([^;"\s]+)/g);if(Array.isArray(s))for(let t=0;t<s.length;t++)i(s[t]);else i(s);o&&o.forEach(t=>{i(t.split(":")[1].trim())});for(const t in e.tagStyles)i(e.tagStyles[t].fontFamily);return n}(e,i),a=await async function(t){const e=t.filter(t=>pr.has(`${t}-and-url`)).map(t=>{if(!Tp.has(t)){const{entries:e}=pr.get(`${t}-and-url`),i=[];e.forEach(e=>{const s=e.url,n=e.faces.map(t=>({weight:t.weight,style:t.style}));i.push(...n.map(e=>async function(t,e){const i=await async function(t){const e=await ir.get().fetch(t),i=await e.blob(),s=new FileReader;return await new Promise((t,e)=>{s.onloadend=()=>t(s.result),s.onerror=e,s.readAsDataURL(i)})}(e);return`@font-face {\n font-family: "${t.fontFamily}";\n font-weight: ${t.fontWeight};\n font-style: ${t.fontStyle};\n src: url('${i}');\n }`}({fontWeight:e.weight,fontStyle:e.style,fontFamily:t},s)))}),Tp.set(t,Promise.all(i).then(t=>t.join("\n")))}return Tp.get(t)});return(await Promise.all(e)).join("\n")}(o),h=function(t,e,i,s){s||(s=ec||(ec=new tc));const{domElement:n,styleElement:r,svgRoot:o}=s;n.innerHTML=`<style>${e.cssStyle};</style><div style='padding:0'>${t}</div>`,n.setAttribute("style","transform-origin: top left; display: inline-block"),i&&(r.textContent=i),document.body.appendChild(o);const a=n.getBoundingClientRect();o.remove();const h=2*e.padding;return{width:a.width-h,height:a.height-h}}(e,i,a,r),l=Math.ceil(Math.ceil(Math.max(1,h.width)+2*i.padding)*s),c=Math.ceil(Math.ceil(Math.max(1,h.height)+2*i.padding)*s),d=r.image;d.width=2+(0|l),d.height=2+(0|c);const u=function(t,e,i,s,n){const{domElement:r,styleElement:o,svgRoot:a}=n;r.innerHTML=`<style>${e.cssStyle}</style><div style='padding:0;'>${t}</div>`,r.setAttribute("style",`transform: scale(${i});transform-origin: top left; display: inline-block`),o.textContent=s;const{width:h,height:l}=n.image;return a.setAttribute("width",h.toString()),a.setAttribute("height",l.toString()),(new XMLSerializer).serializeToString(a)}(e,i,s,a,r);await function(t,e,i){return new Promise(async s=>{i&&await new Promise(t=>setTimeout(t,100)),t.onload=()=>{s()},t.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(e)}`,t.crossOrigin="anonymous"})}(d,u,function(){const{userAgent:t}=ir.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}()&&o.length>0);const p=d;let g;this._createCanvas&&(g=function(t,e){const i=xh.getOptimalCanvasAndContext(t.width,t.height,e),{context:s}=i;return s.clearRect(0,0,t.width,t.height),s.drawImage(t,0,0),i}(d,s));const f=si(g?g.canvas:p,d.width-2,d.height-2,s);return n&&(f.source.style=n),this._createCanvas&&(this._renderer.texture.initSource(f.source),xh.returnCanvasAndContext(g)),_n.return(r),f}returnTexturePromise(t){t.then(t=>{this._cleanUp(t)}).catch(()=>{o()})}_cleanUp(t){Nn.returnTexture(t,!0),t.source.resource=null,t.source.uploadMethodId="unknown"}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexturePromise(this._activeTextures[t].promise);this._activeTextures=null}}Pp.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"htmlText"};class Ep extends _d{constructor(t){super(),this._renderer=t,t.runners.resolutionChange.add(this)}resolutionChange(){const t=this.renderable;t._autoResolution&&t.onViewUpdate()}destroy(){const{canvasText:t}=this._renderer;t.getReferenceCount(this.currentKey)>0?t.decreaseReferenceCount(this.currentKey):this.texture&&t.returnTexture(this.texture),this._renderer.runners.resolutionChange.remove(this),this._renderer=null}}class Bp{constructor(t){this._renderer=t}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i||t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const e=t._autoResolution?this._renderer.resolution:t.resolution;i.currentKey===t.styleKey&&t.resolution===e||this._updateGpuText(t),t._didTextUpdate=!1,ii(i,t)}this._renderer.renderPipes.batch.addToBatch(i,e)}updateRenderable(t){const e=this._getGpuText(t);e._batcher.updateElement(e)}_updateGpuText(t){const e=this._getGpuText(t);e.texture&&this._renderer.canvasText.decreaseReferenceCount(e.currentKey),t._resolution=t._autoResolution?this._renderer.resolution:t.resolution,e.texture=this._renderer.canvasText.getManagedTexture(t),e.currentKey=t.styleKey}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Ep(this._renderer);return e.currentKey="--",e.renderable=t,e.transform=t.groupTransform,e.bounds={minX:0,maxX:1,minY:0,maxY:0},e.roundPixels=this._renderer._roundPixels|t._roundPixels,t._gpuData[this._renderer.uid]=e,e}destroy(){this._renderer=null}}Bp.extension={type:[qi.WebGLPipes,qi.WebGPUPipes,qi.CanvasPipes],name:"text"};class Rp{constructor(t){this._activeTextures={},this._renderer=t}getTexture(t,e,i,s){"string"==typeof t&&(Ps(0,"CanvasTextSystem.getTexture: Use object TextOptions instead of separate arguments"),t={text:t,style:i,resolution:e}),t.style instanceof yh||(t.style=new yh(t.style)),t.textureStyle instanceof ks||(t.textureStyle=new ks(t.textureStyle)),"string"!=typeof t.text&&(t.text=t.text.toString());const{text:n,style:r,textureStyle:o}=t,a=t.resolution??this._renderer.resolution,{frame:h,canvasAndContext:l}=Kl.getCanvasAndContext({text:n,style:r,resolution:a}),c=si(l.canvas,h.width,h.height,a);if(o&&(c.source.style=o),r.trim&&(h.pad(r.padding),c.frame.copyFrom(h),c.frame.scale(1/a),c.updateUvs()),r.filters){const t=this._applyFilters(c,r.filters);return this.returnTexture(c),Kl.returnCanvasAndContext(l),t}return this._renderer.texture.initSource(c._source),Kl.returnCanvasAndContext(l),c}returnTexture(t){const e=t.source;e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",Nn.returnTexture(t,!0)}renderTextToCanvas(){Ps(0,"CanvasTextSystem.renderTextToCanvas: no longer supported, use CanvasTextSystem.getTexture instead")}getManagedTexture(t){t._resolution=t._autoResolution?this._renderer.resolution:t.resolution;const e=t.styleKey;if(this._activeTextures[e])return this._increaseReferenceCount(e),this._activeTextures[e].texture;const i=this.getTexture({text:t.text,style:t.style,resolution:t._resolution,textureStyle:t.textureStyle});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e.usageCount--,0===e.usageCount&&(this.returnTexture(e.texture),this._activeTextures[t]=null)}getReferenceCount(t){return this._activeTextures[t]?.usageCount??0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,s=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),s}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}Rp.extension={type:[qi.WebGLSystem,qi.WebGPUSystem,qi.CanvasSystem],name:"canvasText"},es.add(is,ss);var kp=(t,e)=>Number((e/10**t).toFixed(t)),Op=t=>t>32767?t-65535:t,Dp=(t,e)=>e+(t<<8),Fp=(t,e)=>kp(t,Op(e)),Lp=t=>{try{let e=t.match(/.{1,2}/g);if(!e||0===e.length)return"";let i=new Uint8Array(e.length),s=0;for(let t=0;t<e.length;t++){let n=parseInt(e[t],16);n>31&&127!==n&&(i[s++]=n)}let n=i.slice(0,s);return Array.from(n).map(t=>String.fromCharCode(t)).join("")}catch(t){return""}},jp=t=>{if(!t)return"";try{let e=t.match(/.{1,2}/g);if(!e)return"";let i=e.filter(t=>{let e=parseInt(t,16);return e>31&&127!==e});return 0===i.length?"":decodeURIComponent("%"+i.join("%"))}catch{return""}},Gp=(t,e=1)=>{let i=[];for(let s=0;s<t.length;s+=2*e){let n=t.slice(s,s+2*e),r=parseInt(n,16);i.push(r)}return i},Up=({chargeX:t,chargeY:e},{originX:i,originY:s})=>t<=0&&e<=0?null:{x:t-i,y:e-s},zp=(t,e)=>parseInt((t+e).slice(-8),2).toString(16).padStart(2,"0"),Np=t=>{let e=parseInt(t.slice(0,2),16),i=t.slice(0,3===e?52:48),s=2,n=parseInt(i.slice(s,s+4),16);s+=4;let r=1===parseInt(i.slice(s,s+2),16);s+=2;let o=parseInt(i.slice(s,s+4),16);s+=4;let a=parseInt(i.slice(s,s+4),16);s+=4;let h=kp(1,parseInt(i.slice(s,s+4),16));s+=4;let l=kp(1,parseInt(i.slice(s,s+4),16));s+=4;let c=kp(2,parseInt(i.slice(s,s+4),16));s+=4;let d=kp(1,parseInt(i.slice(s,s+4),16));s+=4;let u,p=kp(1,parseInt(i.slice(s,s+4),16));3===e&&(s+=4,u=parseInt(i.slice(s,s+4),16)),s+=4;let g=parseInt(i.slice(s,s+8),16);s+=8;let f=parseInt(i.slice(s,s+4),16);return{mapHeaderStr:i,version:e,id:n,mapStable:r,mapWidth:o,mapHeight:a,originX:h,originY:l,mapResolution:c,chargeX:d,chargeY:p,chargeDirection:u,chargePositionTransformed:Up({chargeX:d,chargeY:p},{originX:h,originY:l}),dataLengthBeforeCompress:g,dataLengthAfterCompress:f}},Vp={"00":"00","01":"f1",10:"f2",11:"ff"},Hp={sweep:"00",barrier:"01",battery:"10",unknown:"11"},Wp={sweep:"111",barrier:"001",carpet:"010",unknown:"000"},Jp={0:{typeMap:Hp},1:{typeMap:Hp},2:{typeMap:Wp},3:{typeMap:Wp}},Zp={NO_ROOM_DATA:"NO_ROOM_DATA",ROOM_GAP:"ROOM_GAP",OBSTACLE_ROOM:"OBSTACLE_ROOM",UNKNOWN_ROOM:"UNKNOWN_ROOM"};Math.imul||(Math.imul=function(t,e){let i=65535&t,s=65535&e;return i*s+((t>>>16)*s+i*(e>>>16)<<16)|0});var Xp=(t,e=1048576)=>{let i=new Uint8Array(t),s=1073741824,n=e;if(e>s)return n=s,null;let r=new Uint8Array(n),o=function(t,e,i,s){for(var n=i=i||0,r=s=s||t.length-i,o=0;n<r;){let i=t[n++],s=i>>4;if(s>0){for(var a=s+240;255===a;)s+=a=t[n++];for(var h=n+s;n<h;)e[o++]=t[n++];if(n===r)return o}let l=t[n++]|t[n++]<<8;if(0===l||l>o)return-(n-2);let c=15&i;for(a=c+240;255===a;)c+=a=t[n++];let d=o-l;for(h=o+c+4;o<h;)e[o++]=e[d++]}return o}(i,r);return r=r.slice(0,o),r},Yp="0123456789abcdef",Kp=(t,e=1)=>{if(!t)return[];let i=parseInt(t.slice(2,4),16),s=t.slice(4),n=[],r=0;for(let t=0;t<i;t++){let t=s.slice(r,r+94),i=parseInt(t.slice(0,4),16),o=parseInt(t.slice(4,8),16),a=parseInt(t.slice(8,12),16),h=parseInt(t.slice(12,16),16),l=parseInt(t.slice(16,18),16),c=1===parseInt(t.slice(18,20),16),d=1===parseInt(t.slice(20,22),16),u=parseInt(t.slice(22,24),16),p=parseInt(t.slice(24,26),16),g=1===parseInt(t.slice(26,28),16),f=parseInt(t.slice(28,30),16),m=parseInt(t.slice(52,54),16),y=t.slice(54,54+2*m),x=m>0?jp(y):"";r+=2*(47+4*parseInt(t.slice(92,94),16));let b=zp(i.toString(2),Jp[e].typeMap.sweep);n.push({roomId:i,pointHex:b,name:x,order:o,suction:u,cistern:p,colorOrder:l,sweepTimes:a,mopTimes:h,sweepForbidden:c,mopForbidden:d,yMop:g,floorMaterial:f,originStr:t,reservedStr:t.slice(30,52)})}return n},Qp=(t,e,i={})=>{let{mapWidth:s,mapHeight:n,dataLengthAfterCompress:r,dataLengthBeforeCompress:o,mapHeaderStr:a,version:h}=e,l=a.length,{pointsStructured:c=!1}=i,d=!c,u=c,p="",g="",f=s*n,m=[],y=[],x=new Map;if(r>0){let e=4*o,i=Gp(t.slice(l,l+2*o)),r=Xp(i,e);if(!r)return{mapRooms:[],mapPointsStr:"",parsed:{obstacles:new Uint32Array,carpet:new Uint32Array,rooms:new Map,width:s,height:n,totalPixels:f}};let a=Array.from(r);if(0===h){let t=[];u&&x.set(Zp.NO_ROOM_DATA,[]);let e=u?x.get(Zp.NO_ROOM_DATA):null;for(let i=0;i<a.length;i++){let s=a[i];for(let n=0;n<8;n+=2){let r=4*i+n/2;if(r>=f)break;let o=s>>n&3;if(d&&t.push(ri(s,n)),u)switch(o){case 0:e.push(r);break;case 1:m.push(r)}}}d&&(p=t.join("").slice(0,2*f)),g=""}else{let t=a.slice(0,f),e=[];for(let i=0;i<t.length;i++){let s=t[i];d&&e.push(ni(s)),u&&(1===h?oi(s,i,m,x):hi(s,i,m,y,x))}d&&(p=e.join("")),g=a.slice(f).map(t=>ni(t)).join("")}}else if(0===h){let e=[],i=t.slice(l).match(/.{2}/g)||[];u&&x.set(Zp.NO_ROOM_DATA,[]);let s=u?x.get(Zp.NO_ROOM_DATA):null;for(let t=0;t<i.length;t++){let n=parseInt(i[t],16);for(let i=0;i<8;i+=2){let r=4*t+i/2;if(r>=f)break;let o=n>>i&3;if(d&&e.push(ri(n,i)),u)switch(o){case 0:s.push(r);break;case 1:m.push(r)}}}d&&(p=e.join("")),g=""}else{let e=t.slice(l,l+2*f),i=[];for(let t=0;t<f;t++){let s=e.slice(2*t,2*t+2);if(d&&i.push(s),u){let e=parseInt(s,16);1===h?oi(e,t,m,x):hi(e,t,m,y,x)}}d&&(p=i.join("")),g=t.slice(l+2*f)}d&&(p=p.toLowerCase(),s*n*2>p.length&&(p=p.padStart(s*n*2,"f")),s*n*2<p.length&&(p=p.slice(p.length-s*n*2)));let b=Kp(g,h),v=new Map;return u&&x.forEach((t,e)=>{t.length>0&&v.set(e,new Uint32Array(t))}),{mapRooms:b,mapPointsStr:p,parsed:{obstacles:u?new Uint32Array(m):new Uint32Array,carpet:u?new Uint32Array(y):new Uint32Array,rooms:v,width:s,height:n,totalPixels:f}}},qp=t=>{try{return JSON.parse(Lp(t))}catch(t){return{}}},$p=(t,e)=>{try{if(!t)return null;let i=Np(t);return{mapHeader:i,mapData:Qp(t,i,e)}}catch(t){return null}},tg=t=>{try{if(!t)return null;let e=Np(t),{mapWidth:i,mapHeight:s,dataLengthAfterCompress:n,dataLengthBeforeCompress:r,mapHeaderStr:o,version:a}=e,h=o.length,l="",c=i*s;if(n>0){let e=4*r,i=Gp(t.slice(h,h+2*r)),s=Xp(i,e);if(!s)return[];let n=Array.from(s);if(0===a)return[];l=n.slice(c).map(t=>t.toString(16).padStart(2,"0")).join("")}else{if(0===a)return[];l=t.slice(h+2*c)}return Kp(l,a)}catch(t){return null}},eg={"00":"common",10:"charge","01":"transitions",11:"mop"},ig=t=>{let e=t.slice(0,26);return{version:parseInt(e.slice(0,2),16),pathId:parseInt(e.slice(2,6),16),initFlag:parseInt(e.slice(6,8),16),type:parseInt(e.slice(8,10),16),count:parseInt(e.slice(10,18),16),direction:parseInt(e.slice(18,22),16),dataLengthAfterCompress:parseInt(e.slice(22,26),16)}},sg=(t,e)=>{let{dataLengthAfterCompress:i,count:s}=e,n=[];if(i>0){let e=4*s,i=Gp(t.slice(26)),r=Xp(i,e);if(!r)return[];let o=Array.from(r);for(let t=0;t<o.length;t+=4){let e=Dp(o[t],o[t+1]),i=Dp(o[t+2],o[t+3]);n.push([e,i])}}else n=(t=>{if(!Array.isArray(t))return[];let e=[];for(let i=0;i<t.length;i+=2)e.push(t.slice(i,i+2));return e})(Gp(t.slice(26),2));let r=[];for(let t=0;t<n.length;t++){let[e,i]=n[t],s=`${1&e}${1&i}`;r.push({x:Fp(1,-2&e),y:-Fp(1,-2&i),type:eg[s]})}return r};const ng=Object.freeze(Object.defineProperty({__proto__:null,BITMAP_TYPE_HEX_MAP:Vp,BITMAP_TYPE_MAP:Hp,BITMAP_TYPE_MAP_V2:Wp,MAP_VERSION_MAP:Jp,PATH_HEADER_LENGTH:13,PATH_POINT_TYPE_MAP:eg,SPECIAL_ROOM_IDS:Zp,combineTwoBinaryToHex:zp,dealPL:Op,decodeMap:$p,decodeMapData:Qp,decodeMapHeader:Np,decodeMapRooms:tg,decodeMapStructured:qp,decodePath:t=>{let e=ig(t);return{pathHeader:e,pathPoints:sg(t,e)}},decodePathData:sg,decodePathHeader:ig,hexStringToNumber:Gp,hexToUTF8:Lp,hexToUriDecodedString:jp,highLowToInt:Dp,scaleNumber:kp,transformChargeXY:Up,transformXY:Fp},Symbol.toStringTag,{value:"Module"})),rg=(t,e)=>(tg(t)??[]).map(t=>({id:t.roomId,name:t.name,cleanTimes:t.sweepTimes,order:t.order,floorType:t.floorMaterial,yMop:t.yMop?1:0,suction:t.suction,cistern:t.cistern,cleanMode:t.sweepForbidden||t.mopForbidden?t.sweepForbidden?2:1:0,...e?.(t.reservedStr)??{}})),og=(t,e,i=20)=>{const s=[...t];let n=0;for(;n<i&&e.some(t=>{return i=t,(e=s).length===i.length&&e.every((t,e)=>{const s=i[e];return t.x===s.x&&t.y===s.y});var e,i});)n++,s.forEach(t=>{t.x+=5,t.y+=5});return s},ag={log(t,...e){},warn(t,...e){},error(t,...e){},debug(t,...e){},success(t,...e){}},hg=t=>{if(t.length<=1)return[...t];const e=lg(t),i=e.slice(1).map((t,i)=>({prev:e[i],current:t})),s=new Map;return i.forEach(({prev:t,current:e})=>{cg(t,e).forEach(t=>{const e=`${t.x},${t.y}`;s.has(e)||s.set(e,t)})}),Array.from(s.values())},lg=t=>{if(t.length<=1)return[...t];const e=t[0],i=t[t.length-1];return e.x===i.x&&e.y===i.y?[...t]:[...t,e]},cg=(t,e)=>{const i=[],s=Math.abs(e.x-t.x),n=Math.abs(e.y-t.y),r=t.x<e.x?1:-1,o=t.y<e.y?1:-1;let a=s-n,h=t.x,l=t.y;for(;i.push({x:h,y:l}),h!==e.x||l!==e.y;){const t=2*a;t>-n&&(a-=n,h+=r),t<s&&(a+=s,l+=o)}return i},dg=(t,e)=>{let i=0,s=t.length-1;for(;i<=s;){const n=Math.floor((i+s)/2),r=t[n];if(r===e)return!0;r<e?i=n+1:s=n-1}return!1},ug=(t,e,i,s,n,r=8)=>{const o={x:(e+s)/2,y:(i+n)/2},a=s-e,h=n-i,l=Math.min(r,.2*Math.min(a,h));return yg(o,t)&&gg(o,t)>=l?o:pg(t,o,l)},pg=(t,e,i)=>{const{minX:s,minY:n,maxX:r,maxY:o}=vg(t),a=r-s,h=o-n,l=e.x,c=e.y,d=Math.min(.5,.05*Math.min(a,h)),u=[];if(yg({x:l,y:c},t)){const e=gg({x:l,y:c},t);u.push({point:{x:l,y:c},distance:e,centerDistance:0})}const p=.6*Math.max(a,h),g=Math.PI/16;let f=0,m=!1;for(let e=d;e<=p&&!m;e+=d){const d=g*(1+e/p);for(let p=0;p<2*Math.PI;p+=d){if(f++,f>1e4){ag.error(`[findBestInnerPoint] Iteration limit reached (${f}). Room size: ${a}x${h}`),m=!0;break}const d=l+e*Math.cos(p),g=c+e*Math.sin(p);if(d>=s&&d<=r&&g>=n&&g<=o){const e={x:d,y:g};if(yg(e,t)){const s=gg(e,t),n=Cg({x:d,y:g},{x:l,y:c});s>=i&&u.push({point:e,distance:s,centerDistance:n})}}}if(u.length>=15)break}if(u.length>0){const t=u.map(t=>({...t,score:1.5*t.distance-.5*t.centerDistance}));return t.sort((t,e)=>e.score-t.score),t[0].point}if(0===u.length){let e={x:l,y:c},i=0;const u=2*d;let p=0;const g=5e3;let f=!1;for(let l=s;l<=r&&!f;l+=u)for(let s=n;s<=o;s+=u){if(p++,p>g){ag.error(`[findBestInnerPoint] Coarse search iteration limit reached. Room size: ${a}x${h}`),f=!0;break}const n={x:l,y:s};if(yg(n,t)){const s=gg(n,t);s>i&&(i=s,e=n)}}return e}return{x:l,y:c}},gg=(t,e)=>{let i=1/0;for(let s=0,n=e.length-1;s<e.length;n=s++){const r=e[n],o=e[s],a=mg(t,r,o);i=Math.min(i,a)}return i},fg=(t,e)=>1===e.length?Cg(t,e[0]):2===e.length?mg(t,e[0],e[1]):4===e.length?yg(t,e)?0:gg(t,e):(ag.warn(`[Distance] Invalid geometry: expected 1, 2 or 4 points, got ${e.length}`),1/0),mg=(t,e,i)=>{const s=(e.x-i.x)**2+(e.y-i.y)**2;if(0===s)return Cg(t,e);const n=Math.max(0,Math.min(1,((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/s)),r=e.x+n*(i.x-e.x),o=e.y+n*(i.y-e.y);return Cg(t,{x:r,y:o})},yg=(t,e,i=!1)=>{if(e.length<3)return!1;if(i&&xg(t,e))return!0;let s=!1;for(let i=0,n=e.length-1;i<e.length;n=i++){const r=e[i].x,o=e[i].y,a=e[n].x,h=e[n].y;o>t.y!=h>t.y&&t.x<(a-r)*(t.y-o)/(h-o)+r&&(s=!s)}return s},xg=(t,e)=>{if(e.length<2)return!1;for(let i=0;i<e.length;i++){const s=(i+1)%e.length;if(bg(t,e[i],e[s]))return!0}return!1},bg=(t,e,i,s=.5)=>{if(mg(t,e,i)>s)return!1;const n=Math.min(e.x,i.x)-s,r=Math.max(e.x,i.x)+s,o=Math.min(e.y,i.y)-s,a=Math.max(e.y,i.y)+s;return t.x>=n&&t.x<=r&&t.y>=o&&t.y<=a},vg=t=>{if(0===t.length)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,i=1/0,s=-1/0,n=-1/0;for(const r of t)e=Math.min(e,r.x),i=Math.min(i,r.y),s=Math.max(s,r.x),n=Math.max(n,r.y);return{minX:e,minY:i,maxX:s,maxY:n}},_g=t=>{const e=t.reduce((t,e)=>({x:t.x+e.x,y:t.y+e.y}),{x:0,y:0});return{x:e.x/t.length,y:e.y/t.length}},wg=t=>{if(4!==t.length)return t;const e=_g(t),i=Cg(t[0],t[1]),s=Cg(t[1],t[2]),n=Math.atan2(t[1].y-t[0].y,t[1].x-t[0].x),r=[{x:-i/2,y:-s/2},{x:i/2,y:-s/2},{x:i/2,y:s/2},{x:-i/2,y:s/2}],o=Math.cos(n),a=Math.sin(n);return r.map(t=>({x:t.x*o-t.y*a+e.x,y:t.x*a+t.y*o+e.y}))},Ag=(t,e,i,s=10)=>{if(0===i)return 1;const n=(t.x*e.x+t.y*e.y)/i/i,r=s/i;return n<=0?r:Math.max(n,r)},Cg=(t,e)=>{const i=t.x-e.x,s=t.y-e.y;return Math.sqrt(i*i+s*s)},Sg=t=>Math.sqrt(t.x*t.x+t.y*t.y),Ig=(t,e)=>({x:e.x-t.x,y:e.y-t.y}),Mg=t=>{const e=Sg(t);return 0===e?{x:0,y:0}:{x:t.x/e,y:t.y/e}},Tg=(t,e)=>{const i=Ig(t,e);return Mg(i)},Pg=t=>({x:-t.y,y:t.x}),Eg=(t,e)=>{const i=Tg(t,e);return Pg(i)},Bg=(t,e)=>{const i=Mg(t),s=Mg(e),n={x:(i.x+s.x)/2,y:(i.y+s.y)/2};return Mg(n)},Rg=(t,e)=>{const i=Ig(t,e);let s=Math.atan2(i.y,i.x);return(s>Math.PI/2||s<-Math.PI/2)&&(s+=Math.PI),s},kg=(t,e,i)=>{if(0===Cg(t,e))return[];const s=Eg(t,e),n=i/2;return[t.x+s.x*n,t.y+s.y*n,e.x+s.x*n,e.y+s.y*n,e.x-s.x*n,e.y-s.y*n,t.x-s.x*n,t.y-s.y*n]},Og=(t,e,i,s)=>{const n=Ig(t,e),r=Ig(t,i),o=Bg(n,r),a=-o.x,h=-o.y;return{x:t.x+a*s,y:t.y+h*s}},Dg=(t,e,i,s)=>{const n=(t.x-i.x)*(e.y-i.y)-(t.y-i.y)*(e.x-i.x),r=(t.x-s.x)*(e.y-s.y)-(t.y-s.y)*(e.x-s.x);if(n*r>=0)return null;const o=(i.x-t.x)*(s.y-t.y)-(i.y-t.y)*(s.x-t.x);if(o*(o+n-r)>=0)return null;const a=o/(r-n),h=a*(e.x-t.x),l=a*(e.y-t.y);return{x:t.x+h,y:t.y+l}},Fg=(t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),Lg=(t,e,i,s,n)=>t.x>=e&&t.x<=e+s&&t.y>=i&&t.y<=i+n,jg=(t,e,i,s)=>{const n=i/2;return"horizontal"===s?[{x:t-n,y:e},{x:t+n,y:e}]:[{x:t,y:e-n},{x:t,y:e+n}]},Gg=(t,e,i)=>{const s=vg(t),n=vg(e),r=Math.max(0,Math.max(s.minX,n.minX)-Math.min(s.maxX,n.maxX)),o=Math.max(0,Math.max(s.minY,n.minY)-Math.min(s.maxY,n.maxY));if(r>i||o>i)return!1;let[a,h]=[t,e];e.length>t.length&&([a,h]=[e,t]);const l=Math.max(1,Math.floor(i)),c=new Map;for(const t of a){const e=`${Math.floor(t.x/l)},${Math.floor(t.y/l)}`;c.has(e)||c.set(e,[]),c.get(e).push(t)}const d=i*i;for(const t of h){const e=Math.floor(t.x/l),i=Math.floor(t.y/l);for(let s=-1;s<=1;s++)for(let n=-1;n<=1;n++){const r=`${e+s},${i+n}`,o=c.get(r);if(o)for(const e of o){const i=t.x-e.x,s=t.y-e.y;if(i*i+s*s<=d)return!0}}}return!1},Ug=(t,e,i,s)=>{let[n,r]=[t,e];e.length>t.length&&([n,r]=[e,t]);const o=new Set(n),a=s*s;for(let t=0;t<r.length;t++){const e=r[t],n=e%i,h=Math.floor(e/i);for(let t=-s;t<=s;t++)for(let e=-s;e<=s;e++){const s=(h+e)*i+(n+t);if(o.has(s)&&t*t+e*e<=a)return!0}}return!1},zg=(t,e)=>{if(t<=1)return!0;if(0===e.length)return!1;const i=Array.from({length:t},(t,e)=>e),s=Array(t).fill(0),n=t=>(i[t]!==t&&(i[t]=n(i[t])),i[t]),r=(t,e)=>{const r=n(t),o=n(e);r!==o&&(s[r]<s[o]?i[r]=o:s[r]>s[o]?i[o]=r:(i[o]=r,s[r]++))};for(const[t,i]of e)r(t,i);const o=n(0);for(let e=1;e<t;e++)if(n(e)!==o)return!1;return!0};var Ng="object"==typeof global&&global&&global.Object===Object&&global,Vg="object"==typeof self&&self&&self.Object===Object&&self,Hg=Ng||Vg||Function("return this")(),Wg=Hg.Symbol,Jg=Object.prototype,Zg=Jg.hasOwnProperty,Xg=Jg.toString,Yg=Wg?Wg.toStringTag:void 0,Kg=Object.prototype.toString,Qg=Wg?Wg.toStringTag:void 0,qg=Array.isArray,$g=/\s/,tf=/^\s+/,ef=/^[-+]0x[0-9a-f]+$/i,sf=/^0b[01]+$/i,nf=/^0o[0-7]+$/i,rf=parseInt,of=Hg["__core-js_shared__"],af=function(){var t=/[^.]+$/.exec(of&&of.keys&&of.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),hf=Function.prototype.toString,lf=/^\[object .+?Constructor\]$/,cf=Function.prototype,df=Object.prototype,uf=cf.toString,pf=df.hasOwnProperty,gf=RegExp("^"+uf.call(pf).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ff=mi(Hg,"WeakMap"),mf=Object.create,yf=function(){function t(){}return function(e){if(!di(e))return{};if(mf)return mf(e);t.prototype=e;var i=new t;return t.prototype=void 0,i}}(),xf=Date.now,bf=function(){try{var t=mi(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),vf=bf?function(t,e){return bf(t,"toString",{configurable:!0,enumerable:!1,value:(i=e,function(){return i}),writable:!0});var i}:pi,_f=function(t){var e=0,i=0;return function(){var s=xf(),n=16-(s-i);if(i=s,n>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(vf),wf=/^(?:0|[1-9]\d*)$/,Af=Object.prototype.hasOwnProperty,Cf=Math.max,Sf=Object.prototype,If=Object.prototype,Mf=If.hasOwnProperty,Tf=If.propertyIsEnumerable,Pf=Ci(function(){return arguments}())?Ci:function(t){return ci(t)&&Mf.call(t,"callee")&&!Tf.call(t,"callee")},Ef="object"==typeof exports&&exports&&!exports.nodeType&&exports,Bf=Ef&&"object"==typeof module&&module&&!module.nodeType&&module,Rf=Bf&&Bf.exports===Ef?Hg.Buffer:void 0,kf=(Rf?Rf.isBuffer:void 0)||function(){return!1},Of={};Of["[object Float32Array]"]=Of["[object Float64Array]"]=Of["[object Int8Array]"]=Of["[object Int16Array]"]=Of["[object Int32Array]"]=Of["[object Uint8Array]"]=Of["[object Uint8ClampedArray]"]=Of["[object Uint16Array]"]=Of["[object Uint32Array]"]=!0,Of["[object Arguments]"]=Of["[object Array]"]=Of["[object ArrayBuffer]"]=Of["[object Boolean]"]=Of["[object DataView]"]=Of["[object Date]"]=Of["[object Error]"]=Of["[object Function]"]=Of["[object Map]"]=Of["[object Number]"]=Of["[object Object]"]=Of["[object RegExp]"]=Of["[object Set]"]=Of["[object String]"]=Of["[object WeakMap]"]=!1;var Df,Ff="object"==typeof exports&&exports&&!exports.nodeType&&exports,Lf=Ff&&"object"==typeof module&&module&&!module.nodeType&&module,jf=Lf&&Lf.exports===Ff&&Ng.process,Gf=function(){try{return Lf&&Lf.require&&Lf.require("util").types||jf&&jf.binding&&jf.binding("util")}catch(t){}}(),Uf=Gf&&Gf.isTypedArray,zf=Uf?(Df=Uf,function(t){return Df(t)}):function(t){return ci(t)&&_i(t.length)&&!!Of[li(t)]},Nf=Object.prototype.hasOwnProperty,Vf=Ii(Object.keys,Object),Hf=Object.prototype.hasOwnProperty,Wf=Object.prototype.hasOwnProperty,Jf=mi(Object,"create"),Zf=Object.prototype.hasOwnProperty,Xf=Object.prototype.hasOwnProperty;Ti.prototype.clear=function(){this.__data__=Jf?Jf(null):{},this.size=0},Ti.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Ti.prototype.get=function(t){var e=this.__data__;if(Jf){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return Zf.call(e,t)?e[t]:void 0},Ti.prototype.has=function(t){var e=this.__data__;return Jf?void 0!==e[t]:Xf.call(e,t)},Ti.prototype.set=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=Jf&&void 0===e?"__lodash_hash_undefined__":e,this};var Yf=Array.prototype.splice;Ei.prototype.clear=function(){this.__data__=[],this.size=0},Ei.prototype.delete=function(t){var e=this.__data__,i=Pi(e,t);return!(i<0||(i==e.length-1?e.pop():Yf.call(e,i,1),--this.size,0))},Ei.prototype.get=function(t){var e=this.__data__,i=Pi(e,t);return i<0?void 0:e[i][1]},Ei.prototype.has=function(t){return Pi(this.__data__,t)>-1},Ei.prototype.set=function(t,e){var i=this.__data__,s=Pi(i,t);return s<0?(++this.size,i.push([t,e])):i[s][1]=e,this};var Kf=mi(Hg,"Map");Ri.prototype.clear=function(){this.size=0,this.__data__={hash:new Ti,map:new(Kf||Ei),string:new Ti}},Ri.prototype.delete=function(t){var e=Bi(this,t).delete(t);return this.size-=e?1:0,e},Ri.prototype.get=function(t){return Bi(this,t).get(t)},Ri.prototype.has=function(t){return Bi(this,t).has(t)},Ri.prototype.set=function(t,e){var i=Bi(this,t),s=i.size;return i.set(t,e),this.size+=i.size==s?0:1,this};var Qf=Ii(Object.getPrototypeOf,Object),qf=Function.prototype,$f=Object.prototype,tm=qf.toString,em=$f.hasOwnProperty,im=tm.call(Object);ki.prototype.clear=function(){this.__data__=new Ei,this.size=0},ki.prototype.delete=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i},ki.prototype.get=function(t){return this.__data__.get(t)},ki.prototype.has=function(t){return this.__data__.has(t)},ki.prototype.set=function(t,e){var i=this.__data__;if(i instanceof Ei){var s=i.__data__;if(!Kf||s.length<199)return s.push([t,e]),this.size=++i.size,this;i=this.__data__=new Ri(s)}return i.set(t,e),this.size=i.size,this};var sm="object"==typeof exports&&exports&&!exports.nodeType&&exports,nm=sm&&"object"==typeof module&&module&&!module.nodeType&&module,rm=nm&&nm.exports===sm?Hg.Buffer:void 0;rm&&rm.allocUnsafe;var om=Object.prototype.propertyIsEnumerable,am=Object.getOwnPropertySymbols,hm=am?function(t){return null==t?[]:(t=Object(t),function(t,e){for(var i=-1,s=null==t?0:t.length,n=0,r=[];++i<s;){var o=t[i];e(o)&&(r[n++]=o)}return r}(am(t),function(e){return om.call(t,e)}))}:function(){return[]},lm=mi(Hg,"DataView"),cm=mi(Hg,"Promise"),dm=mi(Hg,"Set"),um="[object Map]",pm="[object Promise]",gm="[object Set]",fm="[object WeakMap]",mm="[object DataView]",ym=fi(lm),xm=fi(Kf),bm=fi(cm),vm=fi(dm),_m=fi(ff),wm=li;(lm&&wm(new lm(new ArrayBuffer(1)))!=mm||Kf&&wm(new Kf)!=um||cm&&wm(cm.resolve())!=pm||dm&&wm(new dm)!=gm||ff&&wm(new ff)!=fm)&&(wm=function(t){var e=li(t),i="[object Object]"==e?t.constructor:void 0,s=i?fi(i):"";if(s)switch(s){case ym:return mm;case xm:return um;case bm:return pm;case vm:return gm;case _m:return fm}return e});var Am=Hg.Uint8Array;Di.prototype.add=Di.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Di.prototype.has=function(t){return this.__data__.has(t)};var Cm,Sm=Wg?Wg.prototype:void 0,Im=Sm?Sm.valueOf:void 0,Mm=Object.prototype.hasOwnProperty,Tm="[object Arguments]",Pm="[object Array]",Em="[object Object]",Bm=Object.prototype.hasOwnProperty,Rm=function(t,e,i){for(var s=-1,n=Object(t),r=i(t),o=r.length;o--;){var a=r[++s];if(!1===e(n[a],a,n))break}return t},km=function(){return Hg.Date.now()},Om=Math.max,Dm=Math.min,Fm=(Cm=function(t,e,i,s){Hi(t,e,i,s)},function(t){return _f(function(t,e,i){return e=Cf(void 0===e?t.length-1:e,0),function(){for(var s=arguments,n=-1,r=Cf(s.length-e,0),o=Array(r);++n<r;)o[n]=s[e+n];n=-1;for(var a=Array(e+1);++n<e;)a[n]=s[n];return a[e]=i(o),function(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)}(t,this,a)}}(t,void 0,pi),t+"")}(function(t,e){var i=-1,s=e.length,n=s>1?e[s-1]:void 0,r=s>2?e[2]:void 0;for(n=Cm.length>3&&"function"==typeof n?(s--,n):void 0,r&&function(t,e,i){if(!di(i))return!1;var s=typeof e;return!!("number"==s?wi(i)&&yi(e,i.length):"string"==s&&e in i)&&bi(i[e],t)}(e[0],e[1],r)&&(n=s<3?void 0:n,s=1),t=Object(t);++i<s;){var o=e[i];o&&Cm(t,o,i,n)}return t}));const Lm=Symbol(),jm=Object.getPrototypeOf,Gm=new WeakMap,Um=(t,e=!0)=>{Gm.set(t,e)},zm={},Nm=t=>"object"==typeof t&&null!==t,Vm=(t,e)=>{const i=Jm.get(t);if((null==i?void 0:i[0])===e)return i[1];const s=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return Um(s,!0),Jm.set(t,[e,s]),Reflect.ownKeys(t).forEach(e=>{if(Object.getOwnPropertyDescriptor(s,e))return;const i=Reflect.get(t,e),{enumerable:n}=Reflect.getOwnPropertyDescriptor(t,e),r={value:i,enumerable:n,configurable:!0};if(Wm.has(i))Um(i,!1);else if(Hm.has(i)){const[t,e]=Hm.get(i);r.value=Vm(t,e())}Object.defineProperty(s,e,r)}),Object.preventExtensions(s)},Hm=new WeakMap,Wm=new WeakSet,Jm=new WeakMap,Zm=[1],Xm=new WeakMap;let Ym=Object.is,Km=(t,e)=>new Proxy(t,e),Qm=Vm,qm=(t,e,i,s)=>({deleteProperty(t,e){const n=Reflect.get(t,e);i(e);const r=Reflect.deleteProperty(t,e);return r&&s(["delete",[e],n]),r},set(n,r,o,a){const h=!t()&&Reflect.has(n,r),l=Reflect.get(n,r,a);if(h&&(Ym(l,o)||Xm.has(o)&&Ym(l,Xm.get(o))))return!0;var c;i(r),Nm(o)&&(o=(t=>t&&(Gm.has(t)?Gm.get(t):jm(t)===Object.prototype||jm(t)===Array.prototype))(c=o)&&c[Lm]||o);const d=Hm.has(o)||!Nm(u=o)||Wm.has(u)||!Array.isArray(u)&&Symbol.iterator in u||u instanceof WeakMap||u instanceof WeakSet||u instanceof Error||u instanceof Number||u instanceof Date||u instanceof String||u instanceof RegExp||u instanceof ArrayBuffer||u instanceof Promise?o:Zi(o);var u;return e(r,d),Reflect.set(n,r,d,a),s(["set",[r],o,l]),!0}});class $m extends Xn{dragStart=null;initialTouchDistance=null;initialScale=null;activeTouches=new Map;firstTouchId=null;secondTouchId=null;taintedPointers=new Set;zoomFactor=.8;scaleMin=.2;scaleMax=5;originalPosition={x:0,y:0};targetPosition={x:0,y:0};centerPosition={x:0,y:0};originalScale={x:1,y:1};targetScale={x:1,y:1};defaultScale={x:1,y:1};transitionDuration=500;transitionStartTime=null;initialPinchCenter=null;isGestureValid=!0;lastTapTime=0;doubleTapDelay=300;doubleTapZoomFactor=1.5;lastTapPosition=null;tapDistanceThreshold=20;tapDetectionEnabled=!0;mapClickStartPosition=null;mapClickStartTime=0;mapClickTimeThreshold=300;mapClickMoveThreshold=10;shouldSuppressMapClick=!1;isGestureHijacked=!1;hijackedPointerId=null;isHijackPaused=!1;interactionGraphics;viewportBounds;boundResetAnimation;debouncedStopWheelRender;debouncedLogWheelScale;interactionState={isInteracting:!1,isAnimating:!1,interactionTimer:null,renderReasons:new Set};throttledAntiScale;unsubscribeEnableInteraction=null;constructor(){super();const t=Yi(),e=t.getApp();this.viewportBounds=e.getViewportBounds(),this.eventMode="static",this.unsubscribeEnableInteraction=Xi(t.runtime,"enableInteraction",t=>{this.updateInteractionMode(t)}),this.updateInteractionMode(t.runtimeSnapshot.enableInteraction),this.interactionGraphics=new jl,this.interactionGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill({color:"#ffffff",alpha:0}),this.addChild(this.interactionGraphics),this.scaleMax=e.scaleMax,this.scaleMin=e.scaleMin,this.centerPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.originalPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.targetPosition={x:Math.round(this.viewportBounds.width/2),y:Math.round(this.viewportBounds.height/2)},this.throttledAntiScale=Ji(t=>{Yi().emitter.emit("antiScale",t)},16,{leading:!0,trailing:!0}),this.boundResetAnimation=this.resetAnimation.bind(this),this.debouncedStopWheelRender=zi(()=>{e.stopRender("wheel")},300),this.debouncedLogWheelScale=zi(t=>{ag.debug("[Interaction] 滚轮缩放完成 - Scale:",t.toFixed(3))},500),this.setupInteraction()}updateInteractionMode(t){this.eventMode=t?"static":"none",ag.debug("[Interaction] 交互模式已更新: "+(t?"启用":"禁用"))}setupInteraction(){this.on("pointerdown",t=>this.onPointerDown(t)),this.on("pointerup",t=>this.onPointerUp(t)),this.on("pointerupoutside",t=>this.onPointerUp(t)),this.on("pointermove",t=>this.onPointerMove(t)),this.on("wheel",t=>this.onWheel(t)),Yi().emitter.on("gestureHijackStart",this.handleGestureHijacked),Yi().emitter.on("suppressMapClick",this.handleSuppressMapClick),document.addEventListener("pointercancel",()=>{this.clearTouches()})}resetPan(t){const e=Yi(),i=e.getApp(),s=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null);const n=this.centerPosition.x-t.x*s.scale.x,r=this.centerPosition.y-t.y*s.scale.y;this.originalPosition={x:s.x,y:s.y},this.targetPosition={x:n,y:r},this.originalScale={x:s.scale.x,y:s.scale.y},this.targetScale={x:s.scale.x,y:s.scale.y};const o=(a=Math.sqrt((s.x-n)**2+(s.y-r)**2),Math.pow(Math.min(1,a/1e3),.5));var a;this.transitionDuration=500+1e3*Math.min(1,Math.pow(o,2)),this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}setPanZoom({targetPosition:t,targetScale:e,setCenter:i=!1,setScale:s=!1}={},n=!0){const r=Yi(),o=r.getApp(),a=r.appContainer;if(i&&t&&(this.centerPosition={x:t.x,y:t.y},ag.debug("[Interaction] Set center position:",this.centerPosition)),s&&e&&(this.defaultScale={x:e.x,y:e.y},ag.debug("[Interaction] Set scale:",this.defaultScale)),this.originalPosition={x:a.x,y:a.y},this.originalScale={x:a.scale.x,y:a.scale.y},this.targetPosition=t||{x:this.centerPosition.x,y:this.centerPosition.y},this.targetScale=e||this.defaultScale,!n)return a.position.set(this.targetPosition.x,this.targetPosition.y),a.scale.set(this.targetScale.x,this.targetScale.y),this.antiScale(this.targetScale.x),null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),void ag.debug("[Interaction] 直接设置缩放完成 - Scale:",this.targetScale.x.toFixed(3));var h,l,c;const d=.8*(h=Math.sqrt((a.x-this.targetPosition.x)**2+(a.y-this.targetPosition.y)**2),Math.pow(Math.min(1,h/1e3),.5))+.2*(l=a.scale.x,c=this.targetScale.x,Math.pow(Math.min(1,Math.abs(l-c)/Math.abs(-.8)),.5));this.transitionDuration=500+1e3*Math.min(1,Math.pow(d,2)),null!==this.transitionStartTime&&(o.ticker.remove(this.boundResetAnimation),this.interactionState.isAnimating=!1,o.stopRender("animation")),this.interactionState.isAnimating=!0,o.requestRender("animation",!0),this.transitionStartTime=o.ticker.lastTime,o.ticker.add(this.boundResetAnimation)}clearTouches(){const t=Yi().getApp();this.activeTouches.clear(),this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.isGestureValid=!0,this.taintedPointers.clear(),null!==this.transitionStartTime&&(t.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),this.interactionState.isInteracting=!1,t.stopRender("interaction")}checkEventListeners(){return{wheel:this.listenerCount("wheel"),pointerdown:this.listenerCount("pointerdown"),pointerup:this.listenerCount("pointerup"),pointerupoutside:this.listenerCount("pointerupoutside"),pointermove:this.listenerCount("pointermove")}}destroy(){this.checkEventListeners(),this.interactionState.interactionTimer&&clearTimeout(this.interactionState.interactionTimer),this.interactionState.renderReasons.clear(),this.interactionState.isInteracting=!1,this.interactionState.isAnimating=!1,this.debouncedStopWheelRender.cancel(),this.debouncedLogWheelScale.cancel(),this.unsubscribeEnableInteraction&&(this.unsubscribeEnableInteraction(),this.unsubscribeEnableInteraction=null),Yi().emitter.off("gestureHijackStart",this.handleGestureHijacked),Yi().emitter.off("suppressMapClick",this.handleSuppressMapClick),super.destroy()}handleSuppressMapClick=()=>{this.shouldSuppressMapClick=!0};handleGestureHijacked=t=>{this.isGestureHijacked=!0,this.hijackedPointerId=t.pointerId,this.isHijackPaused=!1,this.clearTouches();const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),this.firstTouchId=t.pointerId,this.dragStart={x:e,y:i}};exitGestureHijacked(){null===this.hijackedPointerId||this.isHijackPaused||(this.activeTouches.delete(this.hijackedPointerId),this.firstTouchId===this.hijackedPointerId&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===this.hijackedPointerId&&(this.secondTouchId=null)),this.isGestureHijacked=!1,this.hijackedPointerId=null,this.isHijackPaused=!1}pauseGestureHijack(){this.isHijackPaused=!0}resumeGestureHijack(){this.isHijackPaused=!1}antiScale(t){this.throttledAntiScale(t)}resetAnimation(){const t=Yi(),e=t.getApp(),i=t.appContainer;if(null===this.transitionStartTime)return;const{targetPosition:s,targetScale:n}=this,r=e.ticker.lastTime,o=Math.min(1,(r-this.transitionStartTime)/this.transitionDuration);if(o>=1)i.position.set(s.x,s.y),i.scale.set(n.x,n.y),this.antiScale(n.x),e.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null,this.interactionState.isAnimating=!1,e.stopRender("animation"),ag.debug("[Interaction] 动画缩放完成 - Scale:",i.scale.x.toFixed(3));else{const t=(a=o)<.5?4*a*a*a:(a-1)*(2*a-2)*(2*a-2)+1,e=this.originalPosition.x+(s.x-this.originalPosition.x)*t,r=this.originalPosition.y+(s.y-this.originalPosition.y)*t,h=this.originalScale.x+(n.x-this.originalScale.x)*t,l=this.originalScale.y+(n.y-this.originalScale.y)*t;i.position.set(e,r),i.scale.set(h,l),this.antiScale(h)}var a}onWheel(t){const e=Yi();if(this.isGestureHijacked)return void ag.warn("⚠️ [onWheel] 被手势劫持阻止执行",{isGestureHijacked:this.isGestureHijacked,hijackedPointerId:this.hijackedPointerId,isHijackPaused:this.isHijackPaused});e.getApp().requestRender("wheel",!0),this.debouncedStopWheelRender();const{scaleMin:i,scaleMax:s}=this,n=e.appContainer;t.preventDefault();const r=t.global.x-this.viewportBounds.x,o=t.global.y-this.viewportBounds.y,a=(r-n.x)/n.scale.x,h=(o-n.y)/n.scale.y,l=t.deltaY>0?.95:1.05;let c=n.scale.x*l,d=n.scale.y*l;if(c=Math.max(i,Math.min(s,c)),d=Math.max(i,Math.min(s,d)),c===n.scale.x&&d===n.scale.y)return;const u=r-a*c,p=o-h*d;try{n.scale.set(c,d),n.position.set(u,p),this.antiScale(c),this.debouncedLogWheelScale(c)}catch(t){ag.error("❌ [onWheel] 应用缩放时发生错误:",t)}}onPointerDown(t){const e=Yi();this.interactionState.isInteracting=!0,e.getApp().requestRender("interaction",!0),this.isGestureHijacked&&(t.pointerId===this.hijackedPointerId||this.isHijackPaused||this.pauseGestureHijack());const i=e.getApp(),s=e.appContainer;null!==this.transitionStartTime&&(i.ticker.remove(this.boundResetAnimation),this.transitionStartTime=null),0===this.activeTouches.size&&this.taintedPointers.size>0&&(ag.debug("[Interaction] 清除污染指针列表,准备新手势",Array.from(this.taintedPointers)),this.taintedPointers.clear()),0===this.activeTouches.size&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.dragStart=null,this.firstTouchId=null,this.secondTouchId=null),this.activeTouches.has(t.pointerId)&&1===this.activeTouches.size&&(this.isGestureValid=!0);const n=t.global.x-this.viewportBounds.x,r=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:n,y:r});const o=this.activeTouches.size-this.taintedPointers.size;if(this.taintedPointers.size>0)return ag.debug("[Interaction] 存在污染指针,阻止多点触摸手势",Array.from(this.taintedPointers)),void(1!==o||this.taintedPointers.has(t.pointerId)||(this.firstTouchId=t.pointerId,this.dragStart={x:n,y:r}));if(1===this.activeTouches.size)this.firstTouchId=t.pointerId,this.dragStart={x:n,y:r},this.mapClickStartPosition={x:n,y:r},this.mapClickStartTime=performance.now();else if(2===this.activeTouches.size){const e=Array.from(this.activeTouches.keys());this.secondTouchId=e.find(t=>t!==this.firstTouchId)||t.pointerId,this.setInitialScaleAndDistance(s),this.tapDetectionEnabled=!1}}onPointerUp(t){const e=Yi();if(this.taintedPointers.has(t.pointerId)&&(ag.debug("[Interaction] 移除污染指针",t.pointerId),this.taintedPointers.delete(t.pointerId)),this.isGestureHijacked){if(t.pointerId===this.hijackedPointerId)return e.emitter.emit("gestureHijackPointerUp",t),void this.exitGestureHijacked();this.isHijackPaused}if(!this.activeTouches.has(t.pointerId))return;const i=null!==this.initialTouchDistance&&null!==this.initialScale;if(this.activeTouches.delete(t.pointerId),i&&1===this.activeTouches.size){this.isGestureValid=!1;const t=Array.from(this.activeTouches.keys());Promise.resolve().then(()=>{this.isGestureValid||(ag.debug("[Interaction] 检测到潜在的幽灵指针,标记为污染并清理",t),t.forEach(t=>{this.activeTouches.has(t)&&(this.taintedPointers.add(t),this.activeTouches.delete(t),this.firstTouchId===t&&(this.firstTouchId=null,this.dragStart=null),this.secondTouchId===t&&(this.secondTouchId=null))}))}),this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null}t.pointerId===this.firstTouchId?(this.firstTouchId=null,this.dragStart=null,0===this.activeTouches.size&&this.tapDetectionEnabled&&this.detectDoubleTap(t),0!==this.activeTouches.size||i||this.detectMapClick(t)):t.pointerId===this.secondTouchId&&(this.secondTouchId=null),this.isGestureHijacked&&this.isHijackPaused&&1===this.activeTouches.size&&Array.from(this.activeTouches.keys())[0]===this.hijackedPointerId&&this.resumeGestureHijack(),0===this.activeTouches.size&&(this.isGestureValid=!0,this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.firstTouchId=null,this.secondTouchId=null,this.dragStart=null,this.tapDetectionEnabled=!0,this.interactionState.isInteracting=!1,e.getApp().stopRender("interaction"))}detectDoubleTap(t){const e=Yi(),{interactionConfig:i}=e;if(!i.enableDoubleTapZoom)return;const s=performance.now(),n={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y};s-this.lastTapTime<this.doubleTapDelay&&this.lastTapPosition&&Cg(n,this.lastTapPosition)<this.tapDistanceThreshold?(this.handleDoubleTap(n),this.lastTapTime=0,this.lastTapPosition=null):(this.lastTapTime=s,this.lastTapPosition=n)}detectMapClick(t){const e=Yi();if(!e.runtimeSnapshot.enableMapClickCapture)return;if(!e.events?.onClickMap)return;if(!this.mapClickStartPosition)return;const i=performance.now()-this.mapClickStartTime,s={x:t.global.x-this.viewportBounds.x,y:t.global.y-this.viewportBounds.y},n=Cg(this.mapClickStartPosition,s);if(i<=this.mapClickTimeThreshold&&n<=this.mapClickMoveThreshold&&!this.shouldSuppressMapClick){const t=e.appContainer,r=e.mapState,o=(s.x-t.x)/t.scale.x,a=(s.y-t.y)/t.scale.y,h={x:o-(r?.origin.x||0),y:a-(r?.origin.y||0)};ag.debug("[Interaction] 地图点击捕获",{screenPosition:s,containerPosition:{x:o,y:a},origin:r?.origin,mapPosition:h,clickDuration:i,moveDistance:n}),e.events.onClickMap(h)}this.mapClickStartPosition=null,this.mapClickStartTime=0,this.shouldSuppressMapClick=!1}handleDoubleTap(t){const e=Yi(),i=e.getApp(),s=e.appContainer,{scaleMin:n,scaleMax:r,doubleTapZoomFactor:o}=this,a=t.x,h=t.y,l=(a-s.x)/s.scale.x,c=(h-s.y)/s.scale.y;let d=s.scale.x*o,u=s.scale.y*o;d=Math.max(n,Math.min(r,d)),u=Math.max(n,Math.min(r,u)),this.originalPosition={x:s.x,y:s.y},this.originalScale={x:s.scale.x,y:s.scale.y};const p=a-l*d,g=h-c*u;this.targetPosition={x:p,y:g},this.targetScale={x:d,y:u},this.interactionState.isAnimating=!0,i.requestRender("animation",!0),this.transitionDuration=300,this.transitionStartTime=i.ticker.lastTime,i.ticker.add(this.boundResetAnimation)}onPointerMove(t){if(this.isGestureHijacked&&!this.isHijackPaused){if(t.pointerId===this.hijackedPointerId){const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;return this.activeTouches.set(t.pointerId,{x:e,y:i}),void Yi().emitter.emit("gestureHijackPointerMove",t)}return}if(!this.activeTouches.has(t.pointerId)||!this.isGestureValid)return;if(this.taintedPointers.size>0&&(null!==this.initialTouchDistance||null!==this.initialScale))return void ag.debug("[Interaction] 存在污染指针,阻止多点触摸手势移动");const e=t.global.x-this.viewportBounds.x,i=t.global.y-this.viewportBounds.y;this.activeTouches.set(t.pointerId,{x:e,y:i}),2===this.activeTouches.size&&null!==this.initialTouchDistance&&null!==this.initialScale&&this.applyPinchZoom(),1!==this.activeTouches.size||null===this.initialTouchDistance&&null===this.initialScale||(this.initialTouchDistance=null,this.initialScale=null,this.initialPinchCenter=null,this.secondTouchId=null),1!==this.activeTouches.size||t.pointerId!==this.firstTouchId||null===this.dragStart||this.taintedPointers.has(t.pointerId)||this.applyPan(t)}applyPan(t){const e=Yi(),i=this.activeTouches.get(t.pointerId),s=e.appContainer,{x:n,y:r}=this.dragStart;s.position.set(s.x+i.x-n,s.y+i.y-r),this.dragStart={x:i.x,y:i.y}}applyPinchZoom(){const t=Yi().appContainer,e=Array.from(this.activeTouches.values());if(e.length<2||!this.initialTouchDistance||!this.initialScale||!this.initialPinchCenter)return;const i=Cg(e[0],e[1]),s={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},n=(s.x-t.position.x)/t.scale.x,r=(s.y-t.position.y)/t.scale.y,o=(i/this.initialTouchDistance)**this.zoomFactor,a=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.x*o)),h=Math.max(this.scaleMin,Math.min(this.scaleMax,this.initialScale.y*o));t.scale.set(a,h);let l=s.x-n*a,c=s.y-r*h;l+=s.x-this.initialPinchCenter.x,c+=s.y-this.initialPinchCenter.y,t.position.set(l,c),this.antiScale(a),this.initialPinchCenter=s,Math.random()<.1&&ag.debug("[Interaction] 双指缩放中 - Scale:",a.toFixed(3))}setInitialScaleAndDistance(t){const e=Array.from(this.activeTouches.values());e.length<2||(this.initialTouchDistance=Cg(e[0],e[1]),this.initialScale={x:t.scale.x,y:t.scale.y},this.initialPinchCenter={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2})}}const ty="system-ui, -apple-system, sans-serif",ey=["#2563b8","#26966b","#7c3fb8","#d97706"],iy={global:{containerTop:"0px",containerLeft:"0px",containerWidth:"100%",containerHeight:"100%",backgroundColor:"#f6f6f6",backgroundAlpha:1},map:{autoPaddingHorizontalPercent:.05,autoPaddingVerticalPercent:.05,adjacencyThreshold:3,originChangeAutoFitThreshold:2,sizeChangeAutoFitThreshold:10,obstacleColor:"#999999",freeColor:"#ebebeb"},room:{colors:{sortBy:"index",strategy:"priority",active:["#a8c8f5","#9de5c7","#d4b9f7","#ffd399"],inactive:["#d6e7fc","#d1f4e5","#ece0fb","#fff0d9"],name:[...ey],propertyTheme:[...ey],selectionIndicatorBackground:[...ey],selectionIndicatorIcon:["#ffffff","#ffffff","#ffffff","#ffffff"],[Zp.NO_ROOM_DATA]:"#ebebeb",[Zp.ROOM_GAP]:"#ebebeb",[Zp.OBSTACLE_ROOM]:"#ebebeb",[Zp.UNKNOWN_ROOM]:"#ebebeb"},nameLabel:{fontSize:12,fontFamily:ty,fontWeight:"500"},property:{displayOrders:["cleanMode","suction","cistern","cleanTimes"],iconWidth:14,iconHeight:14,foldable:!0,offsetX:0,offsetY:4,iconGap:0,container:{backgroundColor:"#ffffff",paddingVertical:2,paddingHorizontal:2,borderRadius:16,tailHeight:2,tailWidth:10},suction:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAgH/fIL9gcEDvoBDPsJCPUDD8BuiCAAACCklEQVRo3u3Zza6bMBCG4Y/434aQzP1fbCt14SOZSac+zPQs/C4jwaME7ICN1Wq1Wq1W87VYd0dEe9gy7MqBvuQi9OusHp3PenqMPeiix31uZU5YiVTlB3PCk5jSTXChS9kTV2m3uG/mR0zEtt0Ce7qWKw873FK5livx+VvgRJdyIr6IW9ou5Ux8T2jKgYcrNOXMwwGq8qYM83IqLKws+8rB2jISA+vLkbmr9eUnM1mry819+GO0Hs8ZPdPx3NCzlB16pvKBnqkc0TOVPXqWskPPVH6iZyp79CzlHUM2csSQiewwZCNHDJnIAUM2cgOTosy35CUvecn/W37H83C/C8nbyT6FMhjqcnsE6pnJOdBFTVPu7FiEqvwOxJTAyeN1KrQf8Z/ck9gyZPLL0Z+cF7N+l6yX8rL3r7P0z8tb6jreLV7pLba77K01IWcR/MlNwIycxDsS/Er8lFwFrv/szslBAEeJK5fl8CFx5bIc3jn3AKblQwBzrmuYl5/fgD0wL78EcOEv8Lzsp6cPB3xDDhBUmZlyWpYenZgvPC8Lj27cfta8HCEq0Fi2eN7OzFjSlwMDq8u+MLC6nAYYsJGfw3aWlVyH6cNK3obpw0qOrrsehnLfN9299Zu7j4FKiD97zeBvcgKfqlwaDNukI1JT3mBalyNs26RzgZb8gnlxpxIyVqvVarVarb70C7CyrCEVukMsAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA3yC/EECAYM+f73CQr1Awj6BvNXOp4gAAAlpJREFUaN7s1t1ugzAMhmE7TgghgdL5/u91ndBK11SYfFonTcpzXl7yR0Nd13Vd13Xd/+VWVk6OAD7PzCxDIMCHbtrTQfQbR2o1oD/2q97A6agPBjrPsd4BU+ZZgfLehQcd9acMdKEXF31yoVNYX0uewAewb9mRtfFkmaHZcroDy1qZfMMCweULtEGCHprJlrU2kiXpsRXanPbG9mrJZIjQzxY12O/O0BoVNbFHTiPDe3q32lu6NtnzZAv257Zmn32bGP9LaBgfsh9VwameoCHbXRVgjWtTc1eLEZ71FNfa1WCEIxS2u0wWAcOO9UiknblBphLdTViKTMb7W12mEyJv2cHTLpRRd0PjRLGjU0IecvDVoLLo5ko3IY0yx2prGF2Qi/PI8lVzsj/TvLbg3YMl3cp6oHgC2MddjsMS6Bddnj8NAmQRw/OlJgBZxFUfpNf3Dsme6P1hCqx3k5SloYpO9XA//SWlVPLi6G1Cdev8K/I407Z3fUBweFnQLi5+tmcGOQzCMBA0EBKSllz4/1/b+x6QVXmqVp4PrBDGeHfP7ei7JX9LmXM1nlKHIwUK+JaMQbfHw1C6RCoMTQ57iEUMAkOTIwDiEGsCoGddMYouthdiiNFnmBJtQHQNohkWV7YRYJrol6wZ+DCE05kjBawteK4d0VnAbEGPfF8cTAvhPnAcq0VTHTkWIKwdLySsBQkgDBxBsjHJ2W6qB9zYskDADVbGpSB+Zru+NF4TEHb3UtUi2aHhUqq3aPn9H4XV4MLDU06PWgyhbaCsNlDjrbmcz8wzkyRJkuRDXlF2skMkf3lIAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMA359AIL+QYBDvMIBwr6CPz1BvDk7raQAAAplJREFUaN7t2tuO3CAMBmDbQALkOOv3f9dKrVbWMiSQTHGqiu96oz94OGeh67qu67rP+JF2ZObdTQb0GMcscAQdnlgoRkfkdxM0ZyVXN5k4b4bGkPOChbb4yAAJreDgoSnkIwaaGpif6V6RjxAktJq8QGMr5zlobUTdYGFRsdTlZAIFRm+dKPewF2iw/CaCioVToMMojyYRdJdFMagsTuVaB9DilacP4RQqXf6REfSMCtuP8uRlQRE2GcTezLQ4t9D0isWFAu1fK+MWmIXbzOlIHuFA3JAZqfq9vgKnAr1nY6nQ23dFIlSZOAu/bNKecJ5L8qi/lSu2n9F2RSRTM97o6vj84PBv8eLMhnxqu5XL7n6D02QzE80WDpj0/f1HDZaq+YV/I59tLnFqLC6zRSSFzHdYs+Seutel05WIjk4Q3myBc3Y456qCY3Zfa8fNnTx1bq8q9fC+JBpCPgXnuCjYZFdNcu3WKFjm3TUJtoHbBn9PkGmpiYv228PYDaPNDjorT51wtzpXGIw/6vwEVcHTjRuOxUDK/5xAVi4yl6fq/P7BrjJl1sx3ePGAwHj4pnYmmqNsss+NFw8I5W1cXTJCkbmUK0a812Cx1vy9IUw3j3a43aXTDsvr+fYxxPRXxxu5ItZvWyFl1szOeIZKdkVmHGJ5yGX3+YP7OffYBvd6dFS01/TnADTLjPe5rXqU/CfH0zkZn2pQ9XZLmGSVVUPpAUFL+Dcu9J67wgygxPFDl6dqH1/KX/gsaHjpfvYRk9732/K2GzWKvfBDya7yEkohWKmHLfXXX206l/oXvvmp/wMxfAShKR/4CLQ1PBVsg26py92LoLWJ9abNcjJGUPB++CcPGtJoZ0CPmdzOzLjT6KHruq7ruo/8Ani9wIJR4hr/AAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAIN9A7xC/gGDPn3BQkK8wj6DdtO0oAAADPElEQVRo3u2Z2Y7rIAyGwWYnS8fv/7BHlTpi0gacsuTc8N1VivqDF2yMmEwmk8lk0h9nFJHfohT90HEDIlLG5f810C/GdZJFQwkrznnQH3yPXUtDB0CefkVHbLPuooguKAd649GoaylRUlb0TmjW/cQwlm7fc6RzHleEKdbHFeXYr3ypdK0wUA7D+LgttB3lceLI2nPLQHlAHEHqt2WkEu6KrU2V8EolzBXzqCphQ0XwyteyRthTkfXK11gj/EMJPmRVP2Ekuh5emk7RI5wc+FWCqEJC2dZ8NQliiDKy1kFRi/OUJ3LlxIgGtJRyX34YQzqmhtUjLZRCB5iFtSA/d12OaZCiEw5yB2KoOC5bolwyjU8/9HYq7NhS3I49OxAhoztKGVJo8brtxA8vhqH+TaBK6XJqaYViDBKOaUpHvBTDWNYQdaYHWMVtGEp4FPeBybtR3IBecH9ZHuiJt7pbGDkbjIcnxjwifgwKAF/S1kbsN3BR9M62vB/brrffDJ0T9DF3Vdfk2Q1l8U/lZUz6RCphj/cqKFsuQBqPcVgqot5uGaU4Mb+rW+rv4wl5EPbXGgdsaaZTGV4utHS7/a7VDZQn/QUc2xBtN2NMeESHuD/7YffwXzb3WrGWPtjFpl9lLFd4qIxyL49sf04uIJ6tzdJ+T8GwuD0tlgVa7qYqZvOPhxFWJWtJMU6YsgAymT9IeNUioa0hCDplAg/UmVrhySEDOo3EWEzVHNHLE900PtZADHwV27KlMGE+LjE7b+yloiR6nYsldz2+uMqI/A0bziqEqzi4uOjCfPLA4bmmBH7fBoRS+Gm2nvLJlEtKLFWR5fNprHoAZMsz562QJLYul86Tciu+t5hL7YsXl8BiaDHvHQ4aBk+xEFobF63SQv2F2eYXq3jvyeOubc0sbdMZNzB5gj/wcsUqvx0gKlIbZr3AnwwanXO76MXGZMowPPMoMgzmTXcYO3P+D2D0YLrqnuGHKXPlHhYxGFdxJRsrTFEMZaEcaqyfJdM3j0MVZjJDMUzjPIzI9HPD0IoRHoZlfDwOzzygD0MC/adKIf1tdYL3s9XiFuSriUyd5H3gap7iYFbUYjKZTCaTSRP/AEYn9FrTdrbUAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMA3yCAEGC/759AcFDPkDCvoI+BJCYaAAADo0lEQVRo3u2a2barIAyGCSQMjpX3f9izzunqoYoxbhD3jd9d6/CXEDJA1cPDw8PDw0MNYZkhxgh26VHdBhoXv/Ba3UPn4obljlGjjzlww6BtjL+iTHEfaG1tGxkW1RaIHIyx2wuPiqG1MKimvCJLW/cKvHCvmmJZYVJN0Y4T7lRbJs6/zOY+6vXFY36dEO6HusSlQ5hybzXiHC9VOTMsb6ta2j49Cl5tatKHtnyyx715DvuZxE0/06W190InLmdkwpugLE6j1cfL2SV/LkrWvPtArxJ9/sOSsbhLMr24YNDxF7vioKZPxIiR9y1TnLl85PC8e+Fq/ouGrGOUlZGdR4w5tmDAnLUtNyYqTdYYDzH7k6yPixQqqGCZ0NgztjTFFZkXhJ3eMQwJDjKX1xgJm5sUpJU4KBkXJbpU920GjEMsF44iDpMvrAc8C1aqFI7jZjZJdI+53tRpyHbzVpyF2RFI0yS8J6S0l+a3orMyp2yd7rQ6+XPNFKeMJ4fs6WV9yNdRaZKYkrIbvDHeDkINLen6s/l4/hRa+LFCP67Ew490B1Rn0Z33Y8D1d2TZEXhBt5ik7WJ0b0MHD2BJTmgjqkvQeuX8Fo+bVwjqWug7emg20hhUFwMrR3P3yK6NO+7Xw85eYuSJusV7b/q88vb/PsN6Zj3VDxb7ZciaqGkbPnX3vsnBPJJW1WBnd8MQup32VGuNF83k7LjAaxrubwV7lGperfZttRX28GhosmDIyckV9X//62hSMpXVAO0fFoDv2+qOfDfttssXzQzDfH55kZjk+A7AmoD/t40+XmFKG/PEC9+3LNYSWw8P1nu/Woq+dsCv790Gn7olkVNjHqTHzfdHPCXsUNbVki6t3+ZOKYeKzXCT5+J1i15Z4ZKgS5ulNV01ySSsX8jCdlNh2Lvssl37mrZtYjcgcp+fsr28irMSPPzBeu/rWRaeyk61gNlL9OsNbB5XmCKIiS5u1ejV9m3TQWOtmbjQV0xxwvKGImaVCA4G6hSB7+hn9oqR45bMyL5+EPapK49acWCiFh55TXfBqbaG/WGFw5dOwIbLMmV/dFphmadEXVkZ9KE1jRADTGmpOWih/DRHBZvrSs5NIVWImbuzJ4AE2TlZgTbK/xHIOyiaP3V2UBdhzv7zJfR0RVcjL1Wj2kJ82muLFhJ9O4BPA20xvyWMrqBTaOnXoJpjCpZTO2Wj7oCA2RtuDhIwm7TtCaP9Kw6zCerh4eHh4eFq/gDsgRtLdqAVbwAAAABJRU5ErkJggg=="]},cistern:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA3yBgv58Q74BwQK+PzzBQHgQBUQAAAqhJREFUaN7t2etu8yAMBmBO4ZgQ7v9qv2na+kpVEgKOqfQN/1vK+hRjE9KKGTNmzJgxYwY9VCrOKDE8lCxfIR+SYwjx3ki7le+Qz03iXvrW8hOe7tov9276QnlFJMO+lLuycoDpyyxvvBdyg1iocLk3CyzwU8u83ZKxwAhispdyS8YCYzC1m27JyMy6INn8MhbYCPxD5Jfj78tO4Q+MZZPRSTt6Hz3FJ6fXAr81v2aV0Umb/RmPoYwyOsm9rgfUGqNsfi+Ho2t8MmZ3NNwpLjmXQ0JjA+ORcXk/2Ws9s7yejlassrQY15BsuhwvbmyBUV6vBjvFJ9ujwRqNxiPXTxF6rIyxUg2WNW6Qg2Uke7CMZNvBssYZYayMZKvBsnLYOcfKHvU1WEYzD5YVmnmwjPoaK2OcEYNl/VR9GdUoy2dayhfZKOdHDiPWlWZ5wQDKhEurjJbypAl3yJ56l8Ijy9ZU21aSC9sgaS2yxuftCayWs439LInbl8eEW2QUdiBmOopGORP3TYc9qEVGrl2fm3GEapOR69wFa3RFq7zjQZpQW1k0y5mweSFfVjTLlnQQWVAhbTLqMlG6SYpWGWVt6HBdHgBXZCKM70tFh0wqrhVV3SLTq9pjq26QyX2M7Sf0fweoSXv1IrplRbw79cpOCFJZx145dcL6MtdaVeVAOHOdLlUosipb8imz7xkDbm+unTp6qSKTQp6usikccv1p15fCKWPKbn93eWVMuSR0c4TBJ0u8l1l1jDEsuMQp53IQQ+TwMdl/TE6fku32B+XlD1ZYdJ+SbRosI2K1xozgukte0lJXToCUiOaMTfvV2VPQw4bk3lGXtLo+9UbxSGS9Jim/p7KZVef6eTuIAQGZDNPlKMYF/TcZuiyVGB3Wy7ItSsyYMWPG/xD/AIrSnldXeREbAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEXRSTlMA5cgdcw7XjzlWrIFkup0rSDjdhakAAAKOSURBVGje7ZnbkqQgDEAj95va//+1W7u1NVGpHiEJPHEep0ZPJyYBERaLxWKxWPDRaXPphOnE7S8uwmTM9p9JZvT+YGAG6J1rRu9cM3rnmtE714zeuWb0zjWjl2vme5XaLhQYSLx5tUbz2Bl23r0Ad/MJg9Du4X2YnYYRoAS99R8HYGtFbbYgz1F7a/MB4pjKi2ZCO5MayZ2PYndDmqq+d4AHn2GlbdXvMZW6wOQLy7xVgAcxyvtt84aUERNr/5ZINeAx71Ujvcw1Jd/BoW0FMdJLUmn9gVo20eml9kWTXdo7VCvBAWbd6wNGAmmFfO3P3PXfHliEvlFolVR9paZEIx+hkEP3fbxMyBiws93j1TMCJswiIxFyrgN+R/FDto4yfCM/5HILmBByZJeWoe0LE5DQtIBBc3Nd6mHZ28uRmekAXQRmrt1PpgHpLC/eziMDUHMdWI/4A53gUlFYY8tCJ5aQLORg7J8UVhfj4oPREDunqD1047Eh+sF5yXkHWOIGOC2ROc9YSRSX4rwzJdYM4PTi3BkAmV4glrXfK/QlJlSLBPFq1m9m5CvR9y4WCOzUy60jFTV/zxar2UPdR6Qpu0TE0fbHodqP03PtaZcd/LdUTboqABGFR5ikl3mgEgknskXkYFF1n8hqxygtxPSemFnFChhRt5Pqd+8u9Ykgbk1m9CIBWPir+SXb+uo9RD8ofo9C/mNf2K5k2/gtPUh/nFfxSzFguNj2ImZUlypqjdqqk/gFhrgU9dV6bA88gLQZ5bvPxmSfcFJJejHbHRgQpLhmbwFRTtWmVRqEsbkpzRbkCelNmzDcmeoUYBwhf6syH2AsNvrKrXy0MAMd87Grf8r9yJ8TFovFYrFYcPgDfFESW2IpAiAAAAAASUVORK5CYII=","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g7xBgcECfj6+/zzBQ4swJLwAAAaxJREFUaN7t2lluwzAMBFBq9SLbnfuftigQYD5SZLGpaQPoXWBgiqQdKDYMwzAMw3Wp5dySyVX8yNXEAm5kycy9CabAXG0yc7XJzNUmM1ebzFxtMnPVyczVJzP33mQdVRD132EHHjqsk5TxUE7WRYp4InZJLhFPxWL+Gl7QjPoMkmycK0DCoToySNjabCxxgzW8YTE3E94yeW8s+THveFNUTrD/NB84IWkLTdG9o2ULrGSc4PCGXAESrpEZJO2vDact4gempH1gWsS7g5K2pWkRzzAV7dKiqm0t2k5WGpclbaWpOlRaWOuMy7J4e9ChPWKatGuL1vO/HvTdFeFg9whWfW3CxQj+z2f8Z8G7Y7B+gbRPWpkTHFTtrwiatZ9cVOyEXfuOoFXbW/QlPmLKuCgXO2XRVppmcaUpahc1VfG3LUWX1lLv62AXRO0JU3VoafEsN9cLReVdzCEuNAWcMH3ynQRfzPorr1X8vBTEuTRlvChP5ojzrP+bQAl4QSjmL214oiXrY34Yvc3Wz7xm/Couyfoq8xLvU6tJpBqWPUYgx72Fr2TDMAzDMFzxDf7xFoVjSQNhAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgN8g72AQn0Bwv4+vMM9QQt7wKQAAArJJREFUaN7tmtHOpCAMhbUgoqL2/Z92s5t/0/wtkRE4c8V3eTKZMy2lRZlpMBgMBoNBLS55n5zSdvb7OUFZ+C9+yWpAZv5hedRwvszzfy1mNKCvuNhfA/XFO1tf63IoDeVrXZLSwL7iEkhpYF9xccoZ5mudvdJAvsL285Hbau0snEH3q1lr7Zz8yCmbSmmNOM+PeCelrbQmHHEBcvaT1OwciItQkFpQWj2JPyBlljmBNlJ+O5PSABspv6mc0mo5PStKpT0rDVVYtphIaajCElZJttJes/ErNkm2aP06VnmZqXWZL34JZXYCYXZwfjfvSmseSWWc1JdosETbxK5KA1W0bVZOaS8InqsgJyFXTciDK1kl5Jo2ErkaCbmmvnbmtpCj0tABS3iX0sABS3iL0kC9w4bnlIYqaRteUhpuDwvB5podqGnZVhWUhistYZevUdojgZtxmcQ5cKYlr1Fp6ExLXrVWwnMzPhcBsHsIpx0UHMFLLKfaTWm4tiUc8lZEtPLTQ6fqiu+qi7gDV2ZOXN8wpkwn8gVj7kLuq4YxZo2tsf+asdPaMxfQGN9AUqaBpK+1zMWcAfFDYqkYEpE7ECvGYmCh7YC7aw1f1lfmKEPg5wipLae1EnenJV60hj/t+SC1xaIVWbtkeqLXT22xS6ad0cpQj9E0m9FUZulwtp12rnixSO2lFa2GfEKW4GatwUMmeaugrgjAqxwlZ7akgXs5ZVKWel0olu9iFqWB35NLUklpyJuB8kUM/k4i+MI47DuYZRAkpWGdpUtE6wvINuiPGdvnt6lb5nXVhvuDgL3wOJRWS5g/SnOw82WeGnE7F0jOnhR30eqJj9Z7tDfs+zL1IR6es9DqJu3r1zj1I8SVrOvvwG7/TwtTb9wyrxcRs6crzbdexXs/7nMaDAaDwWDwnj/NQlzrb+J5OQAAAABJRU5ErkJggg=="]},cleanMode:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAPFBMVEUAAAD////////////////////////////////////////////////////////////////////////////YSWgTAAAAE3RSTlMAYN+fgL9AIO8QcFDPfzCQr49fa1RRAwAAAnlJREFUaN7t2NmumzAQgOHxvhEgnfd/17ZKDhMMSmobz+mR/F1Fraq/jAeywDAMwzAMwzB8N6EfHPBS+ORn4GRxY4CToLCED9jD4bYa8Q3hMOEfU+AMUxdRcYdXfFK8YYWbO2f4hi9uPGHqUpkrHDHziydsMednjrDz21/J7ZXrH3YvNXo9he5h83qV83b1qneYFnren3fsGxYUyjfc9gzTYml40jT6juFtmZaTp6fpFqYDlgE2QdL0O4UdTfV0/t71CdOgE+wkGnaXcKTFyiw07B5hQ3+Sm76GHa4P06QdkPyY79eFJ/iij4M+HoO7LGyy+2YCcjJs1SEMTk2TDh++e4Qrw5/R6mnusKPFZg3TJVveMJ2y4g3Tfe6Zw/TgdLxheq9IvGHaa8EdBnzQPyEsVvO0qr8Mhb3au7sLR33HAvLTjZwKtqKIhXORPukXPHMKxA/PTOgV1u/nNsE/c3oTxVGye+79oizAy3k6YlaKlp7VDWsemLN9ECf0UTjrVl0wlklnXbrgXrfTcW+dwbpfJBYsY7Kfjz1Wfjk3WCjQdkSDxJd1A5ay9NBo+Z0tYSlNO9XQBYWlTPb9sfR86Z8X8ie34RqgkMNyNt9KaWs+X5WL++0wAiqsWG79+k9LxElbqCKxnKeDClBpxhoOmkWsEaGZwRoKmmEVCa0sEtZDXrCOgEYT1lmgTUDCesgJa4XWT8PEKLXuLkotBonX2iNJ0ETu98Vm96rYD1dedsgOq8MGWogsnLK3IJuFLzvkNQuL7AOOexO20MBkYV0QTpeNWh/DkIWve5uIk5TSPCQAoV7cAOD5ctFaR4CotXhIMwzDMAzDMAz/j98ceskaOhA77AAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAYJ+Av0Df7xBwIJBQz68wzE7woAAAAVNJREFUaN7t2d1ugzAMhmHHSUj4Kfj+r3asmxrIClKYlwzpe8446XuQgi0gAAAAgNuIxj4ZqmsI8s1RVSwvnmpyKWzpBMIII4zwWdjQCYQRRhhhhBE+hDDCCCOMMHX/IOzpxG3D0fJeSGHHe0b35VKBntSMUqLTvHlKhFZhGUiLsVu9ecNvENxP9MlkfurtzkRaeml0I89SJpKSIGUM6fBSaCQdVgo99J6YTQ45SjFPGiYpNtaexrofox5SLGgc8iDS5pCNJFX3LpYLnOIKXXvvWuSSRWMktjnkWS5hjZHY5JC9XDTUHYmJqTsSE1YciczcycbMHCRxlvU2vin7Kc4eyJ0klrzeMsBZ2GVhdxw2eiPxTXg+Do8KIzGFuyzMWVhr41vycMjCYxZW+3e5LCxZ2B6Gw0S/Mbjuk3tar3lrDfvXhbWeol2ZL5EAAAAAAOCvfQALwYE8tktFzgAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAANlBMVEUAAAD////////////////////////////////////////////////////////////////////xY8b8AAAAEnRSTlMA5VZzrI86yR0O12VHK4GeumR+Sig+AAAB1ElEQVRo3u3aYW+jMAyAYTuExEkItP//z550VHCVOGMzl02an6+b+i4hIRQNnHPOOed+KkoruNmAL7nAnQg3M9wp7OEMDA972MMe9vDvDkdgeNjDHvawhz38Xx72sIc9/H1hasNfLazGPZzDu8R8StG/XFIY4FCPFfERlC+XVBJ3cWZNeNKFA/u3N91S+upcx+2ntShGHDfLeGB4dzTVbxNyI2ImhGEbbnCnvIc7qNAUJFKBQ8+tu2iqZcgoNRIAs6wzKbpJluU/el7v7PSJbcy/tKcwtASqrtZotBP0ikG3ZNSbDMIjXtBOBkPCiba9yBQR61yAF9F6xJQlT0wJLyHBtZvsrzA+gVFFe66iXg3AwZdoPdO5y1bNDIym71YC3iQ5LGZ9OMielWs33kxZ9u2gFetdPIOJaH2z7LGKwos+fLqwPnRCzGePfLIRN9vFlcT/UjChWuKeZcSLr+jDD2ZIHbFOadXLyUVRG4twl0SyvXVhDvxZvAvW53FdhjCld+s8lLDEl4qIXb2hDBYdPdivMyUbh3eF39S9Xm6N/+qHKxe48jZm64Oq8mGgi+Vwfi7H01+5YuBFyVMDjfgJA5yj8LDO1qf8ZYSlVMA555xz7rv9AZlKFXj5dr43AAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAOVBMVEUAAAD///////////////////////////////////////////////////////////////////////8KOjVvAAAAEnRSTlMAQCBggN+/nxDvcM8wkFCwoI+ASc+UAAACfUlEQVRo3u3Z7XajIBCAYWAAAVET7v9iN6my6CR0lmo+Np3nV3vSkzcKQmkFY4wxxhhj78EFfQVOPJDr05cgCpNmVjyQuo3IlEVRPDUsxePEV4UlhzmcfVy44zCHPzkMnx2GV4eHV4X1W4WVKDjMYQ6/fRh+TTiswnJ2TtkoVw7+FLqEVfqeFjecNsl3amc4JoKrnOq93BeWVFgKpEsz7/bdav0lwOzUmw1rI77glIU94XblFnXPDZdJMfw8HBTiBM3n8Eh+xuu4pYycw6MttKovAkZQhku3t4su0xlk8kJcwug5rtwvq8TBZKLKSneDFIeLxIN8BJVFuQCAgMLTkUX7zagPKGzEsxhqtc5gsnBk+ITCorhdtI07aNTLg0qtjJBnfRXo2blbTHZhspIZ8bTua5e0zAVLjBmtLMAeff/DsGrIzu9j18tHlaQ2GmgK+zzI9M6niU82pSYyXwv9G6cKQRLbWIMghCuXXxcVuebT8ArZ5xldv1ibB5eYfG2DPJBXbBIZ7lMjtdqSVf02Do76T08rWA2yrocjeUxq1ZU1p/r2LiWjZ6BqK3krs94nPNSeYWqRMamZ2+wT5jxGtTHfyd7MKuWY2o3EzECTqL+7YwcyQ+8T2O30Dbdhm9rZO+tsDwVu5HuNT1j7Bpk+7MC9M8VIJKh9IvOySvtkHPEwGV++vOjt3+9td+VX+4RvmY31hykot3n6DFpOYfPTU9PksPG2q9AQDShscbjsDU7V0QdMQOEJhU8ofNhfnCYUtv8YDnvDHoV7FB62r/uyT+wjEwobFNbb1w87LgW8geBlbzTLmV2Kq+XcBiB3ht0IMMqL6ARjjDHGGGP/qT+Hf7FSTq027wAAAABJRU5ErkJggg=="]},cleanTimes:{assets:["data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA378ggBAw78+fYECPcFCv86Xy/gAAAk9JREFUaN7t2WlPwzAMgGGnjnP2yP//tWgg0GavaVCOCpH3K1WfHWnjMpjNZrPZbDabzf5cZg8BYXTGq/TIBRgYBpd+8jAoCkt6aYURRZ9EBmQdvliZh77tKr3PQdd0Og16FtNNsL8LVv8OXu6C17tgfJYWNQ6G7ZtRHgEHwhDVJxsIAMAxuG8m7ObdWoMR/TkYg9Y7Qb6o143awto+DrQRMqFKj1ZqB9P34Raz7leOqmG5w6hTmRybLKpguaUqKtj+Yj0sb7dHwZyxNoKP9JyGN4X03NIFThuIjE3PHY3gcDUPI9vtdSOY2HkVigX9kqUy2MJVaJlM2XkuQBms4DLD5CM3OG/QDJayPl8BGlrCYOTbyr+keji/tOWCroelLJc2Oe42h6VMckGv0AOG7VVxyBe0hz4wc0QeKuAK2UEFXCE76gmDrnElXC8rhB6wlKXbHYY143aF4eCuRRgCo7yAx8B0F6w5rMbAxiaeHgGjTTLdB5ajrJS7wNKVbV1g6cpCF1i6sr0HLF2ZNV1gOdmpsDsm94GJMSieqhQ2gqXLH/uRyx1g//byMYnJzWF/csPYuNwY9qf7kWYyNYV1ZrJb+d8awjr7eTomN4Kla03+vuJbwVreG/Py2gaO1/uQ4RtGE/j6Z195UTWBXyeOpejrwBZw2WXq28Ou6MZEruhfbAf78HKFso0PVckFFX4zp6my8QZtyQ17+cWDDzr+EvMDtzL5k5UPaaTt43w7XGQ+347HgpOlA6EkMtEUHbdHhMtMjASz2Ww2m81ms9mIPgCfVZZTXlzW2AAAAABJRU5ErkJggg==","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAMAAAAOusbgAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMAgCDf7xAwz0BwYL+fj1CvJC6qIwAAAtFJREFUaN7tmUlu7CAURelbg9n/av/kKyX7GnjGppRInGmED/AaoMIWi8VisVgsFou/gnE5hOAE+yIi7Lb8YLesGTLBassZFR2bjNjKNXPVmpc6cV64hSwtlGdz4KUHZ8BUL5rne+ebfaERXva6QkSKd+tIQvHw7FxIEczb1ABv4lPaqhx5dcnHj++Hb4s4b8m5nbnpGOUXxYcGnRiwH8xuzk5L3eul/jWvgPU0N3t/TRzKh9ifWpzStTghGAzJPAXd0TjOvatWsWGXxPJB4ZbJ/rEpIp7qHD7azutq+2mYtb3oubmfOBuuGL1FiWbFYqTkz0jTWzHGWCvCEcKvDzhh/4/LrIItHyyk5qkLIKFaFTyqYrkgtZit1VATu8CogZ6LdeybJxvvXiLl6P3EtO8QHhN66Hjrl7E9mQ0m9Ogh45oTFrJ5O+IP7osbTBjM1dQO4B1MLaVZ17xDQoOXRIR66Zl57Q9p/MotGMXsbyc0IlR/KG6pgeToeBELC6aYpcCEtvqON0HwiGb3zOuhUKrkAox7HUSuQXjv0SUU5CrF/Nwrbyaln+ClBYm/4dUSBg+a1T2vhcGDZmVu7bOFwaNmdy++w5NW5wKe40XkSRy/5HWYWjO9OPbD/kXv0HFo1HPvyEXLPfBq8NLNAZrdvZ4zavYPvaNm/qS5x9LCT/NuJ1Hey4HwHW/ALchTvAk2ltwQtideDi8Gmhm9asCLTdLAYrql4B94rSaXJ5ZCGPdKQU+chPeVxK/wWTebDkYytcyu3CCd1KGzV7bxbI/lDrb5cuF4YlWHa7IT16RV9endf52bm+JYD2FEL35fQIiJSIhg5znpK/ddcVOsQEz7ERVDJcdXvHdbIkbEQEUQSZViCrRfNCJuRR9s41u9kDC18XnvFX2j3bHLR/A2zSqzAzpzGh/tYdKy29xFhH9cPsZkxwho5wRbLBaLxWKxWCx+I/8ANf2/u2NhQhAAAAAASUVORK5CYII="]},cleanOrder:{color:"#ffffff",fontFamily:ty,fontWeight:"400",fontSize:10,gapRight:2}},selectionIndicator:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABGBAMAAACDAP+3AAAALVBMVEUAAAD///////////////////////////////////////////////////////+hSKubAAAADnRSTlMAEN+AIO/Pn2AwUI+/cOwbbqMAAAEBSURBVEjH7dJBTsJAFMbxj0Ci4GZCjF7AdeMJTHXjBdy4afQCRC9gOEHjxj1H8AiewCOwKGmBEL4zwLSEB0x5bweb/nZdzL+vb4pG43w6MSy3LEbQtQbkErobkpkzM+TIzJBDaL5odi7o5c7OzKC4Yun+4DseseOB3gR7elH+KU/t2kxKZk7PtBKSf3qmx7WFmsHl9qBkfhF05GRKbxrcYERvKE1+4NCY3vxoRmbI4m3mHZVws3fAD73CHb3ozHUTyQQG9N4kU6NfjZps3lmrE7G0mb3eEyuSCXWNTCnVM6W2lZE98sX+0/NvaP659gpVX83IHmcwPCdFDMu1Q6NxeivVcQUNhbcOPQAAAABJRU5ErkJggg==",iconWidth:14,iconHeight:14,containerWidth:16,containerHeight:16,strokeWidth:2,strokeColor:"#ffffff",borderRadius:16,offsetY:4,offsetX:0,tailHeight:2,tailWidth:6},floorType:{assets:["","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAPElEQVR4AezXMQoAMAgDwND//9n2B51EhxNcQ7gtJ7NX0wWiAAECBAgQIECAAAECBAgQWCFQb6G3/Sc7FwAA//+f4+OPAAAABklEQVQDAI04ICFaxIVcAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwAgMAAACTeJdcAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAiSURBVDjLY2hgwA5GJUYliJBYhQMwOAwWF45KDEUJXOkKAA7xNyG+w0wTAAAAAElFTkSuQmCC","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAABgAgMAAAAm4hnjAAAACVBMVEUAAAAAAAAAAACDY+nAAAAAAnRSTlMAgJsrThgAAAAjSURBVDjLY1gFBg4MQMAExGBqlDPKoS0HkuoGjXNGOcOVAwDBxwm1N3ts8gAAAABJRU5ErkJggg=="],opacity:.1,scale:.2},enableElasticScale:!1,elasticMinScale:.6,elasticMaxScale:1.5},path:{lineWidthFixed:!1,incrementalThreshold:5,commonPath:{visible:!0,color:"#ffffff",width:.5},transitionPath:{visible:!1,color:"#ffffff",width:.5},chargePath:{visible:!1,color:"#ffffff",width:.5}},carpet:{src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAOklEQVR4AeySSQoAMAgDp/3/n9v4ABc8eRCSUyAwmgu8xIp9WYGfFpItgBk3OPpW5HAnMxBE0NciwAcAAP//bVPdOAAAAAZJREFUAwDM4hAZDjaEjwAAAABJRU5ErkJggg==",opacity:.5,scale:.2},robot:{icon:{sizeFixed:!1,width:8,height:8,src:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJAAAACQCAMAAADQmBKKAAAC91BMVEUAAABc9fZg//9c/v9Y8vJc//9c/v9V8PFc/P5c/v9b/f1c/f5X8vNc/v9a+fpb/P1a+Plc/P1d/v9c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PWwpYEDy4aBa7tUAmh3XwZiYJm6jAAHFmSPEGmFEOoHMwPmhffF25aBDz0F8og5zIJweJ3QKBXSl+LRlwcmsH3c3Y+CCCzzzVRfTDB1mrUCnCci6L6QeTE+fna+BcHEzR3Zg0R1NIIpYoYMUpoIg/si5/FX7y7AeequQTihqo1wmtnkjfsWZkaeL9r7YwLnvdxvyB48VKUQTJgdyCAhEmXfvuXV+9MKbt7hfhdk35fqrMB5ZsY7L1jYvjSfvY9KMOLuE3nAmCoySD3MArtgtS0XrN/ao3dlWiA/SoZcYOb6Bd53geb6VmB9gXef4b1/NSLkAj2YcBp+gZ7Bb4QQsrSy300W8Q28QA93tfmLFNQCLcCrNrZTAweWDQPX0ftzmBlqr2x+eiGCFNNl8JaB+QI6ok8F8gFePMCBBziwYgLHhb6/PwI/MIHtdEACy4Up/a02Lv/DC51SSimllFJKKaWU0g/24EAAAAAAAMj/tRFUVVVVVVVVVVVVVVVVVVXYsWMbAEAghoHo2X9nOmZA5m4FK00AAAAAAAAAAACAl8y1KBL4DwK36dumb5y+bQbcpm+bvm36xunb5smKm9kCAwAAAAAAAAAAAAAAAACHPTgQAAAAAADyf20EVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVhDw4EAAAAAID8XxtBVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVXagwMSAAAAAEH/X/cjVAAAAABgINYXbaeVmwi+AAAAAElFTkSuQmCC",framePrefix:"sleep_",width:16,height:16,sizeFixed:!1,frameCount:96,offsetX:8,offsetY:-8},ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]},pulseCircle:{size:12,color:"#4cd964",strokeWidth:0,strokeColor:"#ffffff",duration:1e3,sizeFixed:!1,minScale:.5,maxScale:1,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M0ZEtwJFJvcrYEPxGpNzlrg/lRhIeGbAhGT/q1zobgQKRf66wL5ue32rnO+uDY0zcj5GRVMB+UUI9XVgej0TwoZ7E6OKj+GmCxJdiSnC3BzDOkZFMw4yAk24L1g52twdprOSuvYfPpvGz80GISRGRV8EQ3OEBCVn8tGRc7K4Kjp5tsISArghvbQT0Wc7Buopkdisni4H2dQ0ZZEFz1eFPmYInXfpAsy4Jjxw7baGdZcFPtsGAWPgAooIlFYkFw3FY8EJrLg11X8whsLg52ksO3+2VxafDOk4TNorgw+CiQ8oiZcVsS4wPMHDxpmKIxN5GSfgMDo6/7OoroInq4Ojz/vy/h/FFvBGM2jJ7q0Zdmt4lq06enuNDapru91za1Djc5tKmj+9K/pGkMe+cGILpdCO1x251Iyi/g4vimU9Z1kQAAAABJRU5ErkJggg=="},rotationCorrection:0,ring:{size:1,color:"rgba(255, 68, 68, 0.2)",strokeWidth:1,strokeColor:"#ffffff",strokeDashed:!0,strokeDashArray:[4,4]}},interaction:{zoomRange:{min:.5,max:8},fitMinScale:1,fitMaxScale:4,enableDoubleTapZoom:!0},controls:{iconWrapperWidth:24,iconWrapperHeight:24,iconWrapperBorderRadius:16,iconWidth:12,iconHeight:12,deleteIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAG1BMVEUAAAD////////////////////////////////rTT7CAAAACHRSTlMAgL9g36+fQGFJCmkAAADFSURBVDjL3dS7DcJAEIRhniJ1SIgEBSAqQFRARguEJBTgxJqy7cDeX7ZGmtwX+fbu8+t2d7Pqsb99lqHH617XX6mZr26lrrCkdr58ljTxnTRxsHQZJwfBwXqWhoP1rmfDwfrVFA5mO3Ozm4DHRCwmZDExjwlaDPcYDrYcbDnYcrDlYM/BnoM9b+Jyvnl+tfxh+beA4elIwoGmdAjJlFIxJHIqg1hEuQRzAZ9c+dN6jmB4bj2hcYW2F5omLfe6PMH/0HLXPHpWgenjpk040QAAAABJRU5ErkJggg==",rotateIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAMAAAANIilAAAAAM1BMVEUAAAD///////////////////////////////////////////////////////////////+3leKCAAAAEHRSTlMA32CAIEAQ779wz4+fUDCvilaH/gAAAZdJREFUSMftltuOxCAIhsWiVqst7/+0m5jsEIUqm72d/64M33BSWvfVP9WgzKZ4wqRyayhWojwbMwlVhfVAdAnrIeHmVK/TGWAvfOJDRAn3cGqSLURc8AJOSrcqcdIrGBT26r8EFd4FbsSBN2kDzgUnnsAOJohKwZSiBZ6PQpBG+5xP6gpWGGRgiksYDhGax0TFrWBAVzn03GqqK7igcwgces46L+DSS/IfuHDWopBBvrNdHBrdaAnuRdlH/p8xzfj7fLutkLr4JN+cyV7P535MqQQDzHnff4eRRu+DZ2dQ4Y4N8GGBK3sPa/mxwJnhoWawwG2EAxlnNXpnbqC5Yzg5Jz41VpgHe3LeVpg3hxebLV7HDgZ+Hi1YiNqmYZX339B/hNXlnpvrOTR2dgFfYlnCh66dXcCPGIwnThxoCSd5A4FYSzhwYLZZ4UO7+pcRTupRBBMciLQPFwQLfL68HTDt4fD2Jr4N8Ply91oSaeuBS9SO7BaOoLMHGeCq15tJwppTyk6qGuBG9KC6Hk6Y9ERRGXj31f/0A2zyPsVxnMRtAAAAAElFTkSuQmCC",scaleIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAIVBMVEUAAAD////////////////////////////////////////PIev5AAAACnRSTlMA7zC/QN+fgCAQTQcGNgAAAMRJREFUOMvd0jEKwkAURdFPBEkdsLFKyAYk2UIqO1uXYOUSXIJbCCiCqzTDe8Ei3qmDrz3caebH+7tHLLZ6fvZpHfFYhwaPV8jOiZ0zn5QTd3vlwIdGOXGhnDiUIytHdk7sHNk5sXNi53dg5a9lPQxDHc6vQUu5YlqjmFbGv++W1W2V5ctY5+L534vpt37E89lspr9eaKmzIfbVIfvqzJSbKTdjLsZczLkYczHmrZjyXWLKtaDcTLkZc+K2TzsTH/Xu2vkDlC8AMDsTJN8AAAAASUVORK5CYII=",moveIconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8BAMAAADI0sRBAAAAJFBMVEUAAAD///////////////////////////////////////////+0CY3pAAAAC3RSTlMAYIDvMBDPv4+fcLUOqFYAAAEWSURBVDjLvZW9isJAFIXHkLCw1S5ss9ikt00h2ETyAqn0CaxsbHwCSyvfwN7KEUQ8L2dilJPE4Z5GPFXgy5efOzP3um6i1FkZeYtGQGrJgDflSrfkSjdk6kGZekimHpTHwIZ6Xz5Ngb9JWB8C2QD4KYBrAM9wymscT7AI4GSZuRq74ly6QOZ5g+O1C6fBzHvwd9nHSfu20aKPZ75dsHPZxckSKWVg1cVfgG9XO+/iuK485az/7uKpUyamTpmYOmVi6o18+X3kH9g9r7d3PYKRtJKNeIHFw8WniR8TZRFFFUsiFlRsB7mZ9FZ0g9eNvP/AIdIHWB9/3TwObD1H0bhE2xNNU7Rc0bAN3ethoUeNHlR6zIkheQMcOzccp+sDkgAAAABJRU5ErkJggg==",moveButtonOffset:30,textFontSize:12,textFontFamily:ty,textFontWeight:"400",forbiddenSweepZone:{minSize:1,iconWrapperFillColor:"#ff4444",strokeColor:"#ff4444",strokeWidth:2,fillColor:"rgba(255, 68, 68, 0.1)",outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",showRotateButton:!0,textColor:"#ff4444",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},forbiddenMopZone:{minSize:1,iconWrapperFillColor:"#fe8a07",strokeColor:"#fe8a07",strokeWidth:2,fillColor:"rgba(254, 138, 7, 0.1)",outlineOffset:16,outlineStrokeColor:"#fe8a07",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(254, 138, 7, 0.05)",showRotateButton:!0,textColor:"#fe8a07",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},cleanZone:{minSize:1,iconWrapperFillColor:"#5d68fe",strokeColor:"#5d68fe",strokeWidth:2,fillColor:"rgba(93, 104, 254, 0.1)",outlineOffset:16,outlineStrokeColor:"#5d68fe",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(93, 104, 254, 0.05)",showRotateButton:!0,textColor:"#5d68fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},virtualWall:{iconWrapperFillColor:"#ff4444",lineWidth:2,lineColor:"#ff4444",hitAreaThickness:30,outlineOffset:16,outlineStrokeColor:"#ff4444",outlineStrokeWidth:2,outlineDashed:!0,outlineDashArray:[4,3],outlineFillColor:"rgba(255, 68, 68, 0.05)",minWidth:1,textColor:"#ff4444",textOffset:8,editing:{isDashed:!1,dashArray:[0,0]},normal:{isDashed:!1,dashArray:[0,0]}},spot:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAACgCAMAAAC8EZcfAAAAqFBMVEUAAAD////////////////////////////////////////////////09P////+vt//Kzv/f4f/z9P/y8//o6P/HzP/////z9P/i5P/////v8f/t7//k5P/m6P/w8v/q6//o6f/S1f/X2v9gbP/b3/+vs/+Vmv9daP7///+us/+aof7r7P9xe/719f+Fjv7W2f9ncv7Cxv+4vf+kqv57hP7h4/+Ql/7M0P8zzBhqAAAAJ3RSTlMAn4Ag3xC/70Bgz3Aw748gMJ/iv3BeUM+/r5+PYHCvgN+FQBWPQDAOL4ZsAAAGb0lEQVR42s2b2XbaMBCGbWzMvmUpJXuatpJteQXM+79ZOTZkKAeiGdlW9F9zlM+zSTNSrEY0vx9NV97SnUScRxP3zVtNn58cywjNn+xhxC8qunl4nlvfKWfwMuESTeznrvUtcu48jpQ30s84uOUURd5AJ6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fe",textPosition:"bottom",textOffset:8,editing:{isDashed:!1,dashArray:[0,0],showIcon:!0},normal:{isDashed:!1,dashArray:[0,0],showIcon:!1}},wayPoint:{showOrder:!0,normal:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAeFBMVEUAAAD///////////////////////////////////////////////////////////////////+Kior///+ZmZmRkZHw8PDFxcXT09Onp6fq6uq2trb4+Pjx8fG9vb2goKDi4uLMzMyvr6/39/fg4OC+vr7b29uYmJjRFtxTAAAAEnRSTlMAIN+A778QcGDPMJ9AkKCwUH/CxK06AAAEhUlEQVR42u2biZLaMAyGc5BACEcrxXEOjgW2u+//hjUsRdPJDLEti810+j3BP9Kvw04ccVgu0nKbJDM0zJIiK9Mfy+gbyBfr4iZiQLb+kUcvJP6Z4VOyeRy9hHyeoQXFQl7PqpyhLaWsnNXfQakb3Z8/PxUY1Oex7fVH93e6VhEhJ2X3fmgVEER7eEcik4lOXpKSxgh5xrnZiSZr/vDK+0HBKKp/JCyZR2GJs4eUFixpm4ecWCAsJMWO6o+cWbjg5Gv8Yt+CI+c9frEOlaLiblsNHuigqVomeKOrwItqH07N8m6XExB+wZmxJ/rinqIeGPQXvLEIomVPKWKkiqlmSVrCqGFkKv7yS6eAjeqYvokT0hJADa+mSEtANYXfTrr+8ouCQKi9fy+eD7wbyMVzX/PuKghIdbmZOPY0TA9B6fFK5pckDYE5UaJcq3oPweluiXKrqBKvkGEC26Z0CoxMkmiEuxxhMkpScPaOHl7hlTOI0FJo7APTgBBvTqGJ7d0rH5pSLjAUmtIlMC2I0VKvsVs1OxDkzb4NFzSUhDiQhW2ytFMgiLq14dh2RDYgSoOG1LbJnEGU1jJPOV4BOShP4/X0Aw3vIAfV08JuDT+AMAe71TyT6nhD0xTRGGQZSdStCVudrjsQp6aT94h/P0CcxsbBKe2bomibtreRG0zDE1Q5iWICOKNhazOyjyBOhYbE5lT7CTbIi5mhQYEo1Ggm0fMMeOW/mH9BzKSqKbHvM/I7xFZ+A6YOnE1i0fuz6k3goHLlgw6VI1czNYjT2dxE5PiSeaDQ6qxSSDuY/FvYHVVOIExD/h01zQ6Eqe0ur/LZC3a9Iy0Qz8lkV3LK0tbq4ko+T/X9oDKFPDlc6m3Ez3GN/XXnSrrvVS4XwYWwhTXtMuOk/CtGvn3JwqJ7RO/2oTIVHd21vX1pdPcgQo90CWzFRig0FBjnz4K/wPDtgTGhkSoodQ/MJL6YatfAUK+pIDAVugaGek0DgWn8/qFJJb7HHZHuFV3IE4Eb4Zqmkhur8OWt/X9Jy4J6mP6DYPyL9hbQvVTW7qRhE9WTe30oQiaqGrjXx8NvE0jSlXW4RB0YSaJmEyZR1eWRpO9PVE1J4ibqBEw0JYlDEWJGtchPErW+WrEMQ0liMufb5oN+FeSy5da3HmxUnPrm2eY4+CuZX991xTLMMuLDt01HVR2GzL/baBxcmbFt42viw8AwoR6J7I5+RxOMo6DMvUxc1SMdhjWkOiVkXnkTn3DsEwHzfYZ2LSQyb3gTY++2gM/iSIQFupRUdSHzSpA6lFRVk3ll2KDtcqNqepgiRF7YTqlOqpCGJdWMFrVcIQ0fg+mARc1/JqfHteAyEmeBY+2mRypqaVJ8voYekYpanvRp8ztePLTw2031pNltopdRkJqBlkGDkSb/S81QS5JHXPjvPVXNaTB8NQFfkfLf5QIQTC38XashLQ37jThfzRS0PAZDQ1rYr9X5ak60NLC18NVoAM0YjoGHptY+w1FKzSS0GDUT0mLUTEiLUTMhLUbNhLQYNRPSYtSE0fIbFg3xTdS8kE8AAAAASUVORK5CYII=",iconSize:32,orderText:{fontSize:10,fontFamily:ty,fontWeight:"600",color:"#8a8a8a"},orderContainer:{size:12,backgroundColor:"#ffffff",offsetY:20,offsetX:0}},editing:{iconSrc:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAACMCAMAAACZHrEMAAAAdVBMVEUAAAD/////////////////////////////////////////////////////////////////RET/////W1v/6Oj/oqL/ubn/c3P/UFD/8/P/3Nz/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7HXRXeK/qQRwI3wqVlKlmG9y9+966DEaTcHtaf6F5fwoT5a4/BsvYn5k1Uh+4dQ8GZKG1xr5uH9zNI0o0NX6IuhCRhs+FJlP58Jun7E1VikqiJOgKRCpNEoeCYUbWiJwlbX9mQDINJIrKg2+YDfypIZUut7wo3KjJ5RLPNF9sv/bG+S00yzDKgQ7dNi1XNQ4rdZpxhtgEfeTTWxJc3hqE9Etld/Y8m2GH4WIwysS4tHYY0pNpGyLzyJj4q/ETASxj5nr8ri3npJlad3wKehIEIa+VTUvoTzStB7FFSukTzypAp1+WmGbRsAjnywnVKta6FRC8pYy1qj0IiPwarGIua/kyusmtRy0CctbK1m05hUUsTq/dr6JfCopYnftv8vj4n1ILtRr9pdlkwGQWqea2lCKYjRzUvtUTT/mdG9HLXakpKg6GrYXxFSn+XC4AQtdB3LYNaDPmNOF3NHLQ8B4NBLR6X8VJqjrg0kLXQ1VQAFWE4Mg/NqiIMR3Y1s9DSq5mRll7NjLT0amakpVczIy29mhlp6dXwaPkN5W7InuRCZwAAAAAASUVORK5CYII=",iconSize:38,orderText:{fontSize:14,fontFamily:ty,fontWeight:"600",color:"#ff4444"},orderContainer:{size:16,backgroundColor:"#ffffff",offsetY:23,offsetX:0}}}},divider:{lineColor:"#ff4444",dashLineWidth:2,dashLineDashArray:[4,3],solidLineWidth:2,endPointSize:12,endPointColor:"#ff4444",endPointStrokeColor:"#ffffff",endPointStrokeWidth:2,hitAreaThickness:30,resetDividerWhenOutOfRoom:!1,defaultExtension:20,defaultDirection:"horizontal"},detectedObject:{height:43,width:38,interactive:!1},heatmap:{cellSize:2,maxDistance:14,smoothIterations:10,heatmapAlpha:.8,colorGradients:["#FF3B30","#FF7A00","#FFA100","#FFD700","#99DD70","#2EC070","#40E0D0","#88D0E9"]},snapshot:{format:"png",quality:1,antialias:!0,resolution:window?.devicePixelRatio||1}},sy={dividingRoomId:-1,enableRoomSelection:!1,enableInteraction:!0,enableMapClickCapture:!1,editingForbiddenSweepZoneIds:[],editingForbiddenMopZoneIds:[],editingCleanZoneIds:[],editingVirtualWallIds:[],editingSpotIds:[],editingWayPointIds:[],roomPropertyFoldIds:[],roomSelectionMode:"checkmark",mapRotation:0,selectRoomIds:[],showRoomProperty:!1,showRoomOrder:!0,showRoomName:!0,showPath:!0,showChargingStation:!0,showRoomFloorType:!0,showCarpet:!0,showChargingStationRing:!1,showRobotRing:!1,showRobotSleepAnimation:!1,showRobotPulseCircle:!1,unit:"meter",unitLabel:"m"},ny=["areRoomsAdjacent","getForbiddenSweepZones","getForbiddenMopZones","getCleanZones","getVirtualWalls","getSpots","getWayPoints","getViewportCenterPoint","getMapCenterPoint","getWallPointsByViewportCenter","getForbiddenSweepZonePointsByViewportCenter","getForbiddenMopZonePointsByViewportCenter","getCleanZonePointsByViewportCenter","getSpotPointByViewportCenter","getEffectiveDividerPoints","getDividerEndPoints","isNearChargerOrRobot","isPointInAnyRoom","isWallIntersectsAnyRoom","isZoneIntersectsAnyRoom","resetPanZoom","snapshot","snapshotByData"],ry=["onMapFirstDrawed","onMapDrawed","onPathDrawed","onRoomPropertiesDrawed","onClickRoom","onClickRoomProperties","onRemoveForbiddenSweepZone","onRemoveForbiddenMopZone","onRemoveCleanZone","onRemoveVirtualWall","onUpdateForbiddenSweepZone","onUpdateForbiddenMopZone","onUpdateCleanZone","onUpdateVirtualWall","onUpdateSpot","onUpdateWayPoint","onUpdateDivider","onClickForbiddenSweepZone","onClickForbiddenMopZone","onClickCleanZone","onClickVirtualWall","onClickSpot","onClickWayPoint","onClickDetectedObject","onClickCustomElement","onClickMap"],oy="MAIN",ay=5e3;class hy{static contextStack=[];static instanceMap=new Map;static serviceCache=new WeakMap;static registerInstance(t,e){this.instanceMap.set(t,e)}static unregisterInstance(t){this.instanceMap.delete(t)}static getService(){const t=this.useContext();let e=this.serviceCache.get(t);return e||(e=new ly,this.serviceCache.set(t,e)),e}static provide(t,e){this.contextStack.push(t);try{return e()}finally{this.contextStack.pop()}}static async provideAsync(t,e){this.contextStack.push(t);try{return await e()}finally{this.contextStack.pop()}}static useContext(){const t=this.contextStack[this.contextStack.length-1];if(!t){const t=this.instanceMap.get(oy);if(!t)throw new Error("No MapApplication context found. Make sure you are calling useAppService() within a MapApplication context.");return t}return t}static hasContext(){return this.contextStack.length>0||this.instanceMap.has(oy)}static clear(){this.contextStack.length=0,this.instanceMap.clear()}}class ly{getApp(){return hy.useContext()}getConfig(){return this.getApp().config}getDebuggerMode(){return!1}getRoomData(t){return this.getApp().managers.roomsManager.getRoomPropertyById(t)}metersToPixels(t){return this.getApp().metersToPixels(t)}pixelsToMeters(t){return this.getApp().pixelsToMeters(t)}metersToDisplayUnit(t){const{unit:e}=this.runtimeSnapshot;switch(e){case"feet":return 3.28084*t;case"centimeter":return 100*t;default:return t}}get ticker(){return this.getApp().ticker}get mapState(){return this.getApp().mapState}get gloalConfig(){return this.getConfig().global}get mapConfig(){return this.getConfig().map}get roomConfig(){return this.getConfig().room}get heatMapConfig(){return this.getConfig().heatmap}get pathConfig(){return this.getConfig().path}get carpetConfig(){return this.getConfig().carpet}get robotConfig(){return this.getConfig().robot}get chargingStationConfig(){return this.getConfig().chargingStation}get interactionConfig(){return this.getConfig().interaction}get controlsConfig(){return this.getConfig().controls}get dividerConfig(){return this.getConfig().divider}get detectedObjectConfig(){return this.getConfig().detectedObject}get snapshotConfig(){return this.getConfig().snapshot}get appContainer(){return this.getApp().components.appContainer}get interaction(){return this.getApp().components.interaction}get viewportContainer(){return this.getApp().components.viewportContainer}get mapManager(){return this.getApp().managers.mapManager}get pathManager(){return this.getApp().managers.pathManager}get heatmapManager(){return this.getApp().managers.heatmapManager}get controlsManager(){return this.getApp().managers.controlsManager}get detectedObjectManager(){return this.getApp().managers.detectedObjectManager}get customElementsManager(){return this.getApp().managers.customElementsManager}get roomsManager(){return this.getApp().managers.roomsManager}get runtime(){return this.getApp().runtime}get runtimeSnapshot(){return function(t){const e=Hm.get(t),[i,s]=e;return Qm(i,s())}(this.getApp().runtime)}isInteractionEnabled(){return this.runtimeSnapshot.enableInteraction}get events(){return this.getApp().events}get baseScale(){return this.getApp().components.interaction.targetScale.x}get currentScale(){return this.getApp().components.appContainer.scale.x}get emitter(){return this.getApp().emitter}getChargerPosition(){const t=this.mapState;return t?{x:t.charger.x-t.origin.x,y:t.charger.y-t.origin.y}:null}getRobotPosition(){const t=this.pathManager.robot;return t?t.getCurrentPosition():null}}class cy extends Xn{viewportBounds={x:0,y:0,width:0,height:0};maskGraphics=null;containerElement=null;constructor(t,e){super(),this.containerElement=e||window,this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.createMask()}calculateViewportBounds(t){const{containerTop:e,containerLeft:i,containerWidth:s,containerHeight:n}=t,{width:r,height:o}=this.getContainerSize(),a=this.parseSize(i,r),h=this.parseSize(e,o),l=this.parseSize(s,r),c=this.parseSize(n,o);this.viewportBounds={x:a,y:h,width:l,height:c}}getContainerSize(){if(!this.containerElement)return{width:window.innerWidth,height:window.innerHeight};if(this.containerElement===window)return{width:window.innerWidth,height:window.innerHeight};const t=this.containerElement;return{width:t.clientWidth||window.innerWidth,height:t.clientHeight||window.innerHeight}}createMask(){this.maskGraphics=new jl,this.maskGraphics.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215),this.addChild(this.maskGraphics),this.mask=this.maskGraphics}parseSize(t,e){if(!isNaN(Number(t)))return Number(t);if((t=t.trim()).endsWith("%"))return e*(parseFloat(t)/100);if(t.endsWith("vw")){const e=parseFloat(t)/100;return window.innerWidth*e}if(t.endsWith("vh")){const e=parseFloat(t)/100;return window.innerHeight*e}return t.endsWith("rpx")?parseFloat(t)*(window.innerWidth/750):t.endsWith("px")||!isNaN(parseFloat(t))?parseFloat(t):(ag.warn(`Cannot parse size value: ${t}`),0)}getViewportBounds(){return{...this.viewportBounds}}updateViewport(t){this.calculateViewportBounds(t.global),this.position.set(this.viewportBounds.x,this.viewportBounds.y),this.maskGraphics?.clear(),this.maskGraphics?.rect(0,0,this.viewportBounds.width,this.viewportBounds.height).fill(16777215)}addContent(t){this.addChild(t)}}const dy="roomFill",uy="free",py="roomFloorType",gy="carpet",fy="obstacle",my="heatmap",yy="path",xy="controls",by="roomInfo",vy="detectedObject",_y="customElement",wy="customElementGif",Ay="chargingStation",Cy="robot",Sy=["interaction",dy,uy,py,gy,fy,my,yy,by,vy,_y,wy,Ay,Cy,xy];class Iy extends Xn{layers=new Map;mapRotation=0;constructor(){super();const t=Yi().getApp().getViewportBounds();this.position.set(Math.round(t.width/2),Math.round(t.height/2)),this.pivot.set(0,0),this.initializeLayers()}initializeLayers(){Object.values(Sy).forEach(t=>{const e=new Xn;e.label=t,t===xy&&(e.isRenderGroup=!0),t!==py&&t!==gy||(e.eventMode="none"),this.layers.set(t,e),this.addChild(e)})}getLayer(t){return this.layers.get(t)}addToLayer(t,e,i){const s=this.layers.get(t);return s?(void 0!==i&&(e.zIndex=i),s.addChild(e),!0):(ag.warn("[AppContainer Debug] Layer not found:",t),!1)}removeFromLayer(t,e){const i=this.layers.get(t);return!!i&&e.parent===i&&(i.removeChild(e),!0)}clearLayer(t){const e=this.layers.get(t);return!!e&&(e.removeChildren(),!0)}setLayerVisibility(t,e){const i=this.layers.get(t);return!!i&&(i.visible=e,!0)}getLayerVisibility(t){const e=this.layers.get(t);return!!e&&e.visible}setMapRotation(t){this.mapRotation=t*Math.PI/180,this.rotation=this.mapRotation}getMapRotation(){return 180*this.mapRotation/Math.PI}getMapRotationRadians(){return this.mapRotation}}class My extends jl{constructor(){super(),Yi().appContainer.addToLayer(fy,this)}draw(t){const e=Yi();this.clear(),this.setFillStyle({color:e.mapConfig.obstacleColor});for(const e of t){const t=e.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],s=t[e+1];this.rect(i,s,1,1)}}this.fill()}drawRaster(t,e){const i=Yi();if(this.clear(),0!==t.length){this.setFillStyle({color:i.mapConfig.obstacleColor});for(let s=0;s<t.length;s+=ay){const n=Math.min(s+ay,t.length);for(let i=s;i<n;i++){const s=t[i],n=s%e,r=Math.floor(s/e);this.rect(n,r,1,1)}this.fill(),n<t.length&&this.setFillStyle({color:i.mapConfig.obstacleColor})}}}destroy(t){super.destroy(t)}}class Ty{target;isPointerDown=!1;pointerDownPos=null;clickThreshold;stopPropagation;clickCallback=null;constructor(t,e={}){this.target=t,this.clickThreshold=e.clickThreshold??10,this.stopPropagation=e.stopPropagation??!1,this.clickCallback=e.onClick||null,this.setup()}setup(){this.target.interactive=!0,this.target.eventMode="static",this.target.on("pointerdown",this.handlePointerDown.bind(this)),this.target.on("pointermove",this.handlePointerMove.bind(this)),this.target.on("pointerup",this.handlePointerUp.bind(this)),this.target.on("pointerupoutside",this.handlePointerUpOutside.bind(this))}handlePointerDown(t){this.stopPropagation&&t.stopPropagation(),this.isPointerDown=!0,this.pointerDownPos={x:t.globalX,y:t.globalY}}handlePointerMove(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)>this.clickThreshold&&(this.isPointerDown=!1,this.pointerDownPos=null)}}handlePointerUp(t){if(this.stopPropagation&&t.stopPropagation(),this.isPointerDown&&this.pointerDownPos){const e=t.globalX-this.pointerDownPos.x,i=t.globalY-this.pointerDownPos.y;Math.sqrt(e*e+i*i)<=this.clickThreshold&&this.clickCallback&&this.clickCallback(t,this.target)}this.isPointerDown=!1,this.pointerDownPos=null}handlePointerUpOutside(){this.isPointerDown=!1,this.pointerDownPos=null}setClickCallback(t){return this.clickCallback=t,this}setClickThreshold(t){return this.clickThreshold=t,this}getTarget(){return this.target}isInteracting(){return this.isPointerDown}destroy(){this.target.off("pointerdown",this.handlePointerDown),this.target.off("pointermove",this.handlePointerMove),this.target.off("pointerup",this.handlePointerUp),this.target.off("pointerupoutside",this.handlePointerUpOutside),this.clickCallback=null}}class Py extends Xn{roomGraphicsMap=new Map;roomContextMap=new Map;roomClickHandlerMap=new Map;unsubscribeFns=[];mapWidth=0;rasterRoomDataMap=new Map;constructor(){super({isRenderGroup:!0}),Yi().appContainer.addToLayer(dy,this)}draw(t){const e=Yi();this.clearRooms();const i=e.roomConfig,{selectRoomIds:s,enableRoomSelection:n}=e.runtimeSnapshot;t.forEach(t=>{const e=t.id>=255,r=new jl,o=new fh,a=new fh;if(e)o.setFillStyle({color:t.color}),a.setFillStyle({color:t.color});else{const e=t.colorIndex??0,s=i.colors.active[e%i.colors.active.length],n=i.colors.inactive[e%i.colors.inactive.length];o.setFillStyle({color:s}),a.setFillStyle({color:n})}if(o.poly(t.polyPoints).fill(),a.poly(t.polyPoints).fill(),t.outlinePoints.forEach(t=>{o.rect(t.x,t.y,1,1).fill(),a.rect(t.x,t.y,1,1).fill()}),r.context=e?o:n&&!s.includes(t.id)?a:o,!e){const e=new Ty(r,{clickThreshold:10,onClick:()=>{this.handleRoomClick(t.id)}});this.roomClickHandlerMap.set(t.id,e)}this.roomGraphicsMap.set(t.id,r),this.roomContextMap.set(t.id,{activeContext:o,inactiveContext:a}),this.addChild(r)})}drawRaster(t){const e=Yi();if(this.clearRooms(),this.mapWidth=t.width,0===t.sortedRooms.length)return;const{selectRoomIds:i,enableRoomSelection:s}=e.runtimeSnapshot;t.sortedRooms.forEach(t=>{this.drawRasterRoom(t,s,i)})}drawRasterRoom(t,e,i){const{roomId:s,pixelIndices:n,activeColor:r,inactiveColor:o}=t,a=new jl,h=new fh,l=new fh;h.setFillStyle({color:r}),l.setFillStyle({color:o}),this.drawPixelPointsInBatches(h,n,ay,this.mapWidth),this.drawPixelPointsInBatches(l,n,ay,this.mapWidth);const c="number"==typeof s,d=!e||c&&i.includes(s);if(a.context=e&&c&&!d?l:h,c){const t=new Ty(a,{clickThreshold:10,onClick:()=>{this.handleRoomClick(s)}});this.roomClickHandlerMap.set(s,t)}this.roomGraphicsMap.set(s,a),this.roomContextMap.set(s,{activeContext:h,inactiveContext:l}),this.rasterRoomDataMap.set(s,t),this.addChild(a)}drawPixelPointsInBatches(t,e,i,s){for(let n=0;n<e.length;n+=i){const r=Math.min(n+i,e.length);for(let i=n;i<r;i++){const n=e[i],r=n%s,o=Math.floor(n/s);t.rect(r,o,1,1)}t.fill()}}handleRoomClick(t){const e=Yi();e.events?.onClickRoom?.(e.getRoomData(t)??{id:t})}setRoomStateBySelectIds(t){const e=Yi(),{enableRoomSelection:i}=e.runtimeSnapshot;this.roomGraphicsMap.forEach((e,s)=>{if("number"==typeof s){const n=!i||t.includes(s),r=this.roomContextMap.get(s);r&&(e.context=n?r.activeContext:r.inactiveContext)}})}setRoomState(t,e){const i=this.roomGraphicsMap.get(t),s=this.roomContextMap.get(t);i&&s?"number"==typeof t&&(i.context=e?s.activeContext:s.inactiveContext):ag.warn(`Room ${t} not found`)}setAllRoomsState(t){this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&this.setRoomState(i,t)})}getRoomGraphicsMap(){const t=new Map;return this.roomGraphicsMap.forEach((e,i)=>{"number"==typeof i&&t.set(i,e)}),t}getRasterRoomData(t){return this.rasterRoomDataMap.get(t)||null}getMapWidth(){return this.mapWidth}isWallIntersectsAnyRoom(t){const e=Yi().getApp().mapState;if(!e)return ag.warn("[RoomFill] Map state not available"),!1;if(!t||2!==t.length)return ag.warn("[RoomFill] Invalid wall points provided"),!1;const[i,s]=t,n={x:i.x+e.origin.x,y:i.y+e.origin.y},r={x:s.x+e.origin.x,y:s.y+e.origin.y};return"raster"===e.mapType?this.isWallIntersectsAnyRoomRaster(n,r):this.isWallIntersectsAnyRoomStructured(n,r)}isZoneIntersectsAnyRoom(t){const e=Yi().getApp().mapState;if(!e)return ag.warn("[RoomFill] Map state not available"),!1;if(!t||4!==t.length)return ag.warn("[RoomFill] Invalid zone points provided"),!1;const i=t.map(t=>({x:t.x+e.origin.x,y:t.y+e.origin.y}));return"raster"===e.mapType?this.isZoneIntersectsAnyRoomRaster(i):this.isZoneIntersectsAnyRoomStructured(i)}isWallIntersectsAnyRoomRaster(t,e){if(0===this.mapWidth||0===this.rasterRoomDataMap.size)return!1;const i=this.getLinePixels(t,e);for(const t of this.rasterRoomDataMap.values())for(const e of i)if(dg(t.pixelIndices,e))return!0;return!1}isWallIntersectsAnyRoomStructured(t,e){const i=Yi().mapManager.getAllRooms();for(const s of i)if(s.outlinePoints&&!(s.outlinePoints.length<3)){if(yg(t,s.outlinePoints,!0)||yg(e,s.outlinePoints,!0))return!0;for(let i=0;i<s.outlinePoints.length;i++){const n=s.outlinePoints[i],r=s.outlinePoints[(i+1)%s.outlinePoints.length];if(Dg(t,e,n,r))return!0}}return!1}isZoneIntersectsAnyRoomRaster(t){if(0===this.mapWidth||0===this.rasterRoomDataMap.size)return!1;const e=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const[t,i]of e)if(this.isWallIntersectsAnyRoomRaster(t,i))return!0;const i=this.rasterRoomDataMap.values().next().value;if(i&&i.pixelIndices.length>0){const e=i.pixelIndices[0],s=e%this.mapWidth,n=Math.floor(e/this.mapWidth);if(yg({x:s,y:n},t,!0))return!0}return!1}isZoneIntersectsAnyRoomStructured(t){const e=Yi().mapManager.getAllRooms(),i=[[t[0],t[1]],[t[1],t[2]],[t[2],t[3]],[t[3],t[0]]];for(const s of e)if(s.outlinePoints&&!(s.outlinePoints.length<3)){for(const e of t)if(yg(e,s.outlinePoints,!0))return!0;for(const e of s.outlinePoints)if(yg(e,t,!0))return!0;for(const[t,e]of i)for(let i=0;i<s.outlinePoints.length;i++){const n=s.outlinePoints[i],r=s.outlinePoints[(i+1)%s.outlinePoints.length];if(Dg(t,e,n,r))return!0}}return!1}getLinePixels(t,e){const i=Yi().getApp().mapState;if(!i)return[];const s=i.height,n=[],r=Math.round(t.x),o=Math.round(t.y),a=Math.round(e.x),h=Math.round(e.y),l=Math.abs(a-r),c=Math.abs(h-o),d=r<a?1:-1,u=o<h?1:-1;let p=l-c,g=r,f=o;for(;;){if(g>=0&&g<this.mapWidth&&f>=0&&f<s){const t=f*this.mapWidth+g;n.push(t)}if(g===a&&f===h)break;const t=2*p;t>-c&&(p-=c,g+=d),t<l&&(p+=l,f+=u)}return n}getZonePixels(t,e,i,s){const n=Yi().getApp().mapState;if(!n)return[];const r=n.height,o=[],a=Math.max(0,Math.floor(t)),h=Math.min(this.mapWidth-1,Math.ceil(i)),l=Math.max(0,Math.floor(e)),c=Math.min(r-1,Math.ceil(s));for(let t=l;t<=c;t++)for(let e=a;e<=h;e++){const i=t*this.mapWidth+e;o.push(i)}return o}clearRooms(){0===this.children.length&&0===this.roomGraphicsMap.size||(this.removeChildren(),this.roomClickHandlerMap.forEach(t=>{try{t.destroy()}catch(t){ag.warn("Error destroying click handler:",t)}}),this.roomClickHandlerMap.clear(),this.roomGraphicsMap.clear(),this.roomContextMap.clear(),this.rasterRoomDataMap.clear())}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.clearRooms(),super.destroy()}}class Ey extends Xn{carpetSprite=null;carpetMask=null;constructor(){super({isRenderGroup:!0}),Yi().appContainer.addToLayer(gy,this)}async createCarpetFromRasterData(t,e){const i=Yi();if(!i.runtimeSnapshot.showCarpet)return;if(this.clearCarpet(),0===t.length)return;const{src:s,opacity:n,scale:r}=i.carpetConfig,o=await gl.load(s);if(!o)return void ag.warn(`Carpet texture not found: ${s}`);const a=this.createCarpetGraphics(t,e),h=a.getLocalBounds();if(0===h.width||0===h.height)return;const l=new Wl({texture:o,width:h.width,height:h.height});l.x=h.x,l.y=h.y,l.alpha=n,l.tileScale.set(r);const c=new Xn;c.addChild(a),l.mask=c,this.addChild(l),this.carpetSprite=l,this.carpetMask=c,i.getApp().renderOnceNextFrame()}createCarpetGraphics(t,e){const i=new jl;for(let s=0;s<t.length;s++){const n=t[s],r=n%e,o=Math.floor(n/e);i.rect(r,o,1,1)}return i.fill(16777215),i}clearCarpet(){if(this.carpetSprite){try{this.removeChild(this.carpetSprite),this.carpetSprite.destroy()}catch(t){ag.warn("Error destroying carpet sprite:",t)}this.carpetSprite=null}if(this.carpetMask){try{this.carpetMask.destroy()}catch(t){ag.warn("Error destroying carpet mask:",t)}this.carpetMask=null}}async createCarpetFromStructuredData(t){const e=Yi();if(!e.runtimeSnapshot.showCarpet||!t)return;if(this.clearCarpet(),0===t.length)return;const{src:i,opacity:s,scale:n}=e.carpetConfig,r=await gl.load(i);if(!r)return void ag.warn(`Carpet texture not found: ${i}`);const o=this.createCarpetGraphicsFromStructuredData(t),a=o.getLocalBounds();if(0===a.width||0===a.height)return;const h=new Wl({texture:r,width:a.width,height:a.height});h.x=a.x,h.y=a.y,h.alpha=s,h.tileScale.set(n);const l=new Xn;l.addChild(o),h.mask=l,this.addChild(h),this.carpetSprite=h,this.carpetMask=l,e.getApp().renderOnceNextFrame()}createCarpetGraphicsFromStructuredData(t){const e=new jl;for(const i of t){const t=i.coordinates;for(let i=0;i<t.length;i+=2){const s=t[i],n=t[i+1];e.rect(s,n,1,1)}}return e.fill(16777215),e}destroy(){this.clearCarpet(),super.destroy()}}class By extends jl{constructor(){super(),Yi().appContainer.addToLayer(uy,this)}draw(t){const e=Yi();this.clear(),this.setFillStyle({color:e.mapConfig.freeColor});for(const e of t){const t=e.coordinates;for(let e=0;e<t.length;e+=2){const i=t[e],s=t[e+1];this.rect(i,s,1,1)}}this.fill()}destroy(t){super.destroy(t)}}class Ry extends Kn{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?ag.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?ag.warn("EnhancedSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Yi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=t.currentScale;if(0===s)return;const n=e/s,r=i/s;this.scale&&super.scale.set(n,r)}else this.scale&&super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}async loadTextureAndSetSize(t,e){try{const i=Yi(),s=await gl.load(t);this.texture=s,void 0!==e.sizeFixed&&this.setSizeFixed(e.sizeFixed),this.setFixedSize(e.width,e.height),i.getApp().renderOnceNextFrame()}catch(e){ag.error(`Failed to load texture "${t}":`,e)}}draw(t,e){const{x:i,y:s,rotation:n=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=n,this.position.set(i,s)}set texture(t){super.texture=t,this.isFixedSizeSet&&t&&t.width>0&&t.height>0&&this.applySize()}get texture(){return super.texture}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class ky extends Ry{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Yi();await this.loadTextureAndSetSize("chargingStation",t.chargingStationConfig.icon)}async draw({x:t,y:e,rotation:i}){const s=Yi();super.draw({x:t,y:e,rotation:i},()=>s.runtimeSnapshot.showChargingStation)}}class Oy extends jl{currentPosition=null;config;constructor(t){super(),this.setupAntiScaleListener(),this.config=t.config}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.handleScaleChange)}handleScaleChange=()=>{this.redraw()};draw(t){const e=Yi();this.currentPosition=t;const{size:i,color:s,strokeWidth:n,strokeColor:r,strokeDashed:o,strokeDashArray:a}=this.config;this.clear();const h=e.metersToPixels(i),l=e.getApp().toFixedSize(n);this.setFillStyle({color:s}),o&&a.length>=2?this.drawDashedCircle(t,h,r,l,a):this.circle(t.x,t.y,h).fill().stroke({color:r,width:l,cap:"round",join:"round"})}drawDashedCircle(t,e,i,s,n){const r=Yi();this.circle(t.x,t.y,e).fill();const o=r.getApp().toFixedSize(n[0]),a=r.getApp().toFixedSize(n[1]),h=2*Math.PI*e,l=o+a,c=Math.floor(h/l);if(0===c)return void this.circle(t.x,t.y,e).stroke({color:i,width:s,cap:"round",join:"round"});const d=h/c,u=d*(o/l);for(let i=0;i<c;i++){const s=i*d/e,n=(i*d+u)/e,r=Math.max(4,Math.ceil(Math.abs(n-s)*e/2)),o=(n-s)/r;for(let i=0;i<=r;i++){const n=s+o*i,r=t.x+e*Math.cos(n),a=t.y+e*Math.sin(n);0===i?this.moveTo(r,a):this.lineTo(r,a)}}this.stroke({color:i,width:s,cap:"round",join:"round"})}redraw(){this.currentPosition&&this.draw(this.currentPosition)}destroy(){Yi().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Dy extends Xn{chargingStation;ring;unsubscribeFns=[];constructor(){super();const t=Yi();t.appContainer.addToLayer(Ay,this),this.ring=new Oy({config:t.chargingStationConfig.ring}),this.ring.visible=t.runtimeSnapshot.showChargingStationRing,this.addChild(this.ring),this.chargingStation=new ky,this.addChild(this.chargingStation);const e=Xi(t.runtime,"showChargingStationRing",t=>{ag.log(`[runtime] showChargingStationRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e)}async draw({x:t,y:e,rotation:i}){0!==t||0!==e?(this.visible=!0,this.ring.draw({x:t,y:e}),await this.chargingStation.draw({x:t,y:e,rotation:i})):this.visible=!1}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.ring.destroy(),super.destroy()}}class Fy{obstacle=new My;free=new By;roomFill=new Py;carpet=new Ey;chargingStation=new Dy;mapBounds={minX:0,minY:0,maxX:0,maxY:0};lastMapId=null;lastOrigin=null;lastSize=null;lastStatus=null;roomGeometryMap=new Map;rasterRoomPixelsMap=new Map;fourColorCache=null;carpetData=null;unsubscribeFns=[];constructor(){const t=Yi();this.validateColorConfig();const e=Xi(t.runtime,"enableRoomSelection",e=>{if(ag.log(`[runtime] enableRoomSelection: ${e}`),e){this.roomFill.setAllRoomsState(!1);const e=t.runtimeSnapshot.selectRoomIds;this.roomFill.setRoomStateBySelectIds(e)}else this.roomFill.setAllRoomsState(!0)}),i=Xi(t.runtime,"selectRoomIds",t=>{ag.log(`[runtime] selectRoomIds: ${t}`),this.roomFill.setRoomStateBySelectIds(t)}),s=Xi(t.runtime,"showChargingStation",t=>{ag.log(`[runtime] showChargingStation: ${t}`),this.chargingStation.visible=t}),n=Xi(t.runtime,"showCarpet",t=>{ag.log(`[runtime] showCarpet: ${t}`),t?this.createCarpet():this.carpet.clearCarpet()});this.unsubscribeFns.push(e,i,s,n)}async drawMap(t){const e=Yi(),{id:i,obstacles:s,free:n,rooms:r,charger:o,carpet:a,status:h,origin:l,size:c}=t;this.clearComponents(),this.resetGeometryData();const d=this.processRoomsGeometry(r);this.roomFill.draw(d),n&&this.free.draw(n),s&&this.obstacle.draw(s),this.carpetData={type:"structured",carpetData:a},this.createCarpet();const u=this.mergeLayerBounds();Wi(u,this.mapBounds)||(ag.debug("[Map] Map bounds updated:",u),this.mapBounds=u,this.shouldFitMapToView(i,1===h,{x:l[0],y:l[1]},{x:c[0],y:c[1]})&&(e.getApp().fitMapToView(this.mapBounds),this.lastMapId=i,this.lastOrigin={x:l[0],y:l[1]},this.lastSize={x:c[0],y:c[1]},this.lastStatus=1===h));const p=((t.charger.angle??0)+e.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.coordinate[0],y:o.coordinate[1],rotation:p}),await e.roomsManager.refresh(),!0}async drawRasterMap(t,e){const i=Yi();this.clearComponents();const{id:s,width:n,height:r,charger:o,chargerDirection:a,status:h,origin:l}=e;ag.debug("[Map] Parsed Raster Map Data",t),this.obstacle.drawRaster(t.obstacles,n),this.carpetData={type:"raster",carpetPixels:t.carpet,mapWidth:n},this.createCarpet();const c=this.processRasterData(t);this.roomFill.drawRaster(c);const d=((t,e,i)=>{let s=1/0,n=1/0,r=-1/0,o=-1/0;for(let i=0;i<t.obstacles.length;i++){const a=t.obstacles[i],h=a%e,l=Math.floor(a/e);s=Math.min(s,h),n=Math.min(n,l),r=Math.max(r,h),o=Math.max(o,l)}return t.rooms.forEach(t=>{for(let i=0;i<t.length;i++){const a=t[i],h=a%e,l=Math.floor(a/e);s=Math.min(s,h),n=Math.min(n,l),r=Math.max(r,h),o=Math.max(o,l)}}),s===1/0?{minX:0,minY:0,maxX:e,maxY:i}:{minX:Math.max(0,s),minY:Math.max(0,n),maxX:Math.min(e,r),maxY:Math.min(i,o)}})(t,n,r);Wi(d,this.mapBounds)||(ag.debug("[Map] Raster map bounds updated:",d),this.mapBounds=d,this.shouldFitMapToView(s,h,l,{x:n,y:r})&&(i.getApp().fitMapToView(this.mapBounds),this.lastMapId=s,this.lastOrigin={...l},this.lastSize={x:n,y:r},this.lastStatus=h));const u=(a+i.chargingStationConfig.rotationCorrection)*Math.PI/180;return await this.chargingStation.draw({x:o.x,y:o.y,rotation:u}),this.generateRoomGeometryFromRaster(t),await i.roomsManager.refresh(),!0}resetGeometryData(){this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear(),this.fourColorCache=null,this.mapBounds={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}shouldFitMapToView(t,e,i,s){const n=Yi(),{originChangeAutoFitThreshold:r,sizeChangeAutoFitThreshold:o}=n.getApp().config.map;if(this.lastMapId!==t)return ag.debug("[Map] Map ID changed, triggering fitMapToView"),!0;if(null!==this.lastStatus&&this.lastStatus!==e)return ag.debug(`[Map] Map status changed (${this.lastStatus} -> ${e}), triggering fitMapToView`),!0;if(this.lastOrigin&&i){const t=Math.abs(i.x-this.lastOrigin.x),e=Math.abs(i.y-this.lastOrigin.y);if(t>r||e>r)return ag.debug(`[Map] Origin change exceeded threshold (deltaX: ${t}, deltaY: ${e}, threshold: ${r}), triggering fitMapToView`),!0}if(this.lastSize&&s){const t=Math.abs(s.x-this.lastSize.x),e=Math.abs(s.y-this.lastSize.y);if(t>o||e>o)return ag.debug(`[Map] Size change exceeded threshold (deltaX: ${t}, deltaY: ${e}, threshold: ${o}), triggering fitMapToView`),!0}return!1}async createCarpet(){if(Yi().runtimeSnapshot.showCarpet&&this.carpetData)if("raster"===this.carpetData.type){const{carpetPixels:t,mapWidth:e}=this.carpetData;await this.carpet.createCarpetFromRasterData(t,e)}else if("structured"===this.carpetData.type){const{carpetData:t}=this.carpetData;await this.carpet.createCarpetFromStructuredData(t)}}processRoomsGeometry(t){if(!t)return[];const e=Yi(),{active:i}=e.roomConfig.colors,s=e.roomConfig.colors[Zp.UNKNOWN_ROOM];if(0===Object.keys(t).length)return this.mapBounds={minX:0,minY:0,maxX:0,maxY:0},[];const n=Object.keys(t).sort((t,e)=>Number(t)-Number(e)),r=n.filter(t=>Number(t)<255),o=n.filter(t=>Number(t)>=255),a=[],h=[];r.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const s=i.filter(t=>!isFinite(t));if(s.length>0)return void ag.error(`[Room ${e}] Contains ${s.length} invalid coordinates (NaN/Infinity)`);const n=Number(e);let r=1/0,o=1/0,a=-1/0,l=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],s=i[t+1];r=Math.min(r,e),o=Math.min(o,s),a=Math.max(a,e),l=Math.max(l,s),c.push({x:e,y:s})}const d=a-r,u=l-o;if(0===d||0===u)return void ag.error(`[Room ${e}] Degenerate polygon (${d}x${u}). Skipping.`);if(d<2||u<2)return void ag.warn(`[Room ${e}] Room too small (${d}x${u}), skipping`);const p=new Ss(r,o,a-r+1,l-o+1),g=hg(c),f=g.flatMap(t=>[t.x+.5,t.y+.5]),m=ug(g,r,o,a,l);h.push({id:n,points:c,outlinePoints:g,polyPoints:f,centerPoint:m,boundingBox:p}),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,a),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)});const l=[...h].sort((t,i)=>{if("area"===e.roomConfig.colors.sortBy){const e=t.outlinePoints.length;return i.outlinePoints.length-e}return t.id-i.id}),c=this.assignColorsUsingFourColorAlgorithm(l,i.length,"structured");return h.forEach(t=>{const e=c.get(t.id)||0,s=i[e],n={id:t.id,color:s,colorIndex:e,boundingBox:t.boundingBox,points:t.points,outlinePoints:t.outlinePoints,polyPoints:t.polyPoints,centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,n),a.push(n)}),o.forEach(e=>{const{coordinates:i}=t[e];if(i.length<4)return;const n=Number(e);let r=1/0,o=1/0,h=-1/0,l=-1/0;const c=[];for(let t=0;t<i.length;t+=2){const e=i[t],s=i[t+1];r=Math.min(r,e),o=Math.min(o,s),h=Math.max(h,e),l=Math.max(l,s),c.push({x:e,y:s})}const d=h-r,u=l-o;if(0===d||0===u)return void ag.error(`[Unknown Room ${e}] Degenerate polygon (${d}x${u}). Skipping.`);if(d<2||u<2)return void ag.warn(`[Unknown Room ${e}] Room too small (${d}x${u}), skipping`);const p=new Ss(r,o,h-r+1,l-o+1),g=hg(c),f=g.flatMap(t=>[t.x+.5,t.y+.5]),m=ug(g,r,o,h,l),y={id:n,color:s,boundingBox:p,points:c,outlinePoints:g,polyPoints:f,centerPoint:m};a.push(y),this.mapBounds.minX=Math.min(this.mapBounds.minX,r),this.mapBounds.minY=Math.min(this.mapBounds.minY,o),this.mapBounds.maxX=Math.max(this.mapBounds.maxX,h),this.mapBounds.maxY=Math.max(this.mapBounds.maxY,l)}),a}mergeLayerBounds(){let t={...this.mapBounds};if(this.obstacle.bounds&&(t=Fg(t,this.obstacle.bounds)),this.free.bounds&&(t=Fg(t,this.free.bounds)),this.roomFill.children.length>0){const e=this.roomFill.getLocalBounds();e.width>0&&e.height>0&&(t=Fg(t,{minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height}))}return t}getRoomById(t){return this.roomGeometryMap.get(t)}getAllRooms(){return Array.from(this.roomGeometryMap.values())}isWallIntersectsAnyRoom(t){return this.roomFill.isWallIntersectsAnyRoom(t)}isZoneIntersectsAnyRoom(t){return this.roomFill.isZoneIntersectsAnyRoom(t)}areRoomsAdjacent(t){const e=Yi(),i=e.mapConfig.adjacencyThreshold;if(!t||0===t.length)return ag.warn("[MapManager] No room IDs provided"),!1;if(1===t.length)return!0;const s=Array.from(new Set(t));if(1===s.length)return!0;const n=e.getApp().mapState;return"raster"===(n?.mapType??"structured")?this.areRasterRoomsAdjacentInternal(s,i):this.areStructuredRoomsAdjacentInternal(s,i)}areStructuredRoomsAdjacentInternal(t,e){const i=[];for(const e of t){const t=this.getRoomById(e);if(!t)return ag.warn(`[MapManager] Room ${e} not found in map`),!1;if(!t.outlinePoints||0===t.outlinePoints.length)return ag.warn(`[MapManager] Room ${e} has no outline points`),!1;i.push({id:e,points:t.outlinePoints})}const s=[];for(let t=0;t<i.length;t++)for(let n=t+1;n<i.length;n++){const r=i[t],o=i[n];Gg(r.points,o.points,e)&&s.push([t,n])}return zg(i.length,s)}areRasterRoomsAdjacentInternal(t,e){const i=Yi().getApp().mapState;if(!i)return ag.warn("[MapManager] Map state not available"),!1;const s=i.width,n=[];for(const e of t){const t=this.getRasterRoomPixels(e);if(!t)return ag.warn(`[MapManager] Room ${e} pixel data not found in raster map`),!1;n.push({id:e,pixels:t})}const r=[];for(let t=0;t<n.length;t++)for(let i=t+1;i<n.length;i++){const o=n[t],a=n[i];Ug(o.pixels,a.pixels,s,e)&&r.push([t,i])}return zg(n.length,r)}isPointInAnyRoom(t){const e=Yi().getApp().mapState;return e?"raster"===(e.mapType??"structured")?this.isPointInAnyRoomRasterInternal(t,e):this.isPointInAnyRoomStructuredInternal(t,e):(ag.warn("[MapManager] Map state not available"),null)}isPointInAnyRoomStructuredInternal(t,e){const i={x:t.x+e.origin.x,y:t.y+e.origin.y},s=this.getAllRooms();for(const t of s)if(t.outlinePoints&&t.outlinePoints.length>=3&&yg(i,t.outlinePoints))return Yi().roomsManager.getRoomPropertyById(t.id)||(ag.warn(`[MapManager] Room ${t.id} found in geometry but not in RoomManager`),null);return null}isPointInAnyRoomRasterInternal(t,e){const i=e.width,s=e.height,n=t.x+e.origin.x,r=t.y+e.origin.y,o=Math.round(n),a=Math.round(r);if(o<0||o>=i||a<0||a>=s)return ag.warn(`[MapManager] Point (${o}, ${a}) is out of map bounds (${i}x${s})`),null;const h=a*i+o,l=this.getAllRooms();for(const t of l){const e=this.getRasterRoomPixels(t.id);if(e&&e.length>0&&dg(e,h))return Yi().roomsManager.getRoomPropertyById(t.id)||(ag.warn(`[MapManager] Room ${t.id} found in geometry but not in RoomManager`),null)}return null}clearComponents(){this.obstacle.clear(),this.obstacle.destroy(),this.obstacle=new My,this.free.clear(),this.free.destroy(),this.free=new By,this.carpet.clearCarpet(),this.carpetData=null,this.roomFill.removeChildren(),this.roomFill.destroy(),this.roomFill=new Py}processRasterData(t){const e=Yi().roomConfig,i=[],s=[];t.rooms.forEach((t,e)=>{"number"==typeof e?i.push([e,t]):s.push([e,t])}),i.sort(([t],[e])=>t-e);const n=i.map(([t,e])=>({id:t,pixels:e})).sort((t,i)=>"area"===e.colors.sortBy?i.pixels.length-t.pixels.length:t.id-i.id),r=this.assignColorsUsingFourColorAlgorithm(n,e.colors.active.length,"raster"),o=[...i.map(([t,i])=>{const s=r.get(t)||0;return{roomId:t,pixelIndices:i,activeColor:e.colors.active[s],inactiveColor:e.colors.inactive[s%e.colors.inactive.length],colorIndex:s}}),...s.map(([t,i])=>{const s=e.colors[t]||"#ebebeb";return{roomId:t,pixelIndices:i,activeColor:s,inactiveColor:s}})];return{obstacles:t.obstacles,carpet:t.carpet,sortedRooms:o,width:t.width,height:t.height,totalPixels:t.totalPixels}}generateRoomGeometryFromRaster(t){const e=Yi();this.roomGeometryMap.clear(),this.rasterRoomPixelsMap.clear();const{active:i}=e.roomConfig.colors,s=[];t.rooms.forEach((t,e)=>{"number"==typeof e&&s.push(e)}),s.sort((t,e)=>t-e);const n=[];s.forEach(e=>{const i=t.rooms.get(e);this.rasterRoomPixelsMap.set(e,i);let s=1/0,r=1/0,o=-1/0,a=-1/0;for(let e=0;e<i.length;e++){const n=i[e],h=n%t.width,l=Math.floor(n/t.width);s=Math.min(s,h),r=Math.min(r,l),o=Math.max(o,h),a=Math.max(a,l)}const h=((t,e,i,s,n,r)=>{const o=new Set(t),a=((t,e)=>{let i=0,s=0;for(let n=0;n<t.length;n++){const r=t[n];i+=r%e,s+=Math.floor(r/e)}return{x:i/t.length,y:s/t.length}})(t,e),h=((t,e,i,s,n,r,o)=>{const a={x:s-10,y:t.y},h={x:r+10,y:t.y},l={x:r,y:n},c={x:r,y:o},d=Dg(a,h,{x:s,y:n},{x:s,y:o}),u=Dg(a,h,l,c);if(!d||!u)return null;const p=[],g=Math.max(s,Math.min(d.x,u.x)),f=Math.min(r,Math.max(d.x,u.x)),m=Math.round(t.y);for(let t=Math.round(g);t<=Math.round(f);t++){const s=m*i+t;e.has(s)&&p.push({x:t,y:m})}if(p.length>=2){const t=(t=>{if(!t||0===t.length)return{min:{x:0,y:0},max:{x:0,y:0}};let e=t[0],i=t[0];const s=t=>t.x-t.y;for(let n=1;n<t.length;n++){const r=t[n];s(r)<s(e)&&(e=r),s(r)>s(i)&&(i=r)}return{min:e,max:i}})(p),s={x:(t.min.x+t.max.x)/2,y:(t.min.y+t.max.y)/2},n=Math.round(s.y)*i+Math.round(s.x);if(e.has(n))return s}return null})(a,o,e,i,s,n,r);return h||a})(i,t.width,s,r,o,a),l=new Ss(s,r,o-s+1,a-r+1);n.push({id:e,pixelIndices:i,boundingBox:l,centerPoint:h})});const r=[...n].sort((t,i)=>"area"===e.roomConfig.colors.sortBy?i.pixelIndices.length-t.pixelIndices.length:t.id-i.id),o=this.assignColorsUsingFourColorAlgorithm(r,i.length,"raster");n.forEach(t=>{const e=o.get(t.id)||0,s=i[e],n={id:t.id,color:s,colorIndex:e,boundingBox:t.boundingBox,points:[],outlinePoints:[],polyPoints:[],centerPoint:t.centerPoint};this.roomGeometryMap.set(t.id,n)})}getRasterRoomPixels(t){return this.rasterRoomPixelsMap.get(t)}validateColorConfig(){const t=Yi().roomConfig.colors,e=t.active.length,i=t.inactive.length,s=t.name.length,n=t.propertyTheme.length,r=t.selectionIndicatorBackground.length,o=t.selectionIndicatorIcon.length;e<4&&ag.warn(`[FourColor] room.colors.active requires at least 4 colors for the four-color theorem, but got ${e}. Adjacent rooms may have the same color.`),i!==e&&ag.warn(`[FourColor] room.colors.inactive length (${i}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),s!==e&&ag.warn(`[FourColor] room.colors.name length (${s}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),n!==e&&ag.warn(`[FourColor] room.colors.propertyTheme length (${n}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),r!==e&&ag.warn(`[FourColor] room.colors.selectionIndicatorBackground length (${r}) does not match room.colors.active length (${e}). Using modulo for color assignment.`),o!==e&&ag.warn(`[FourColor] room.colors.selectionIndicatorIcon length (${o}) does not match room.colors.active length (${e}). Using modulo for color assignment.`)}assignColorsUsingFourColorAlgorithm(t,e,i){const s=Yi(),n=s.mapState?.id??null;if(this.fourColorCache&&this.fourColorCache.mapId===n&&this.fourColorCache.colorMap.size===t.length)return ag.debug("[FourColor] Using cached color map"),this.fourColorCache.colorMap;const r=s.getApp().config.map.adjacencyThreshold||3,o=s.roomConfig.colors.strategy;ag.debug(`[FourColor] Starting algorithm for ${t.length} rooms with ${e} colors, strategy: ${o}`);const a=((t,e,i,s="priority")=>{const n=new Map;if(0===t.length)return n;if(1===t.length)return n.set(t[0].id,0),n;const r=new Map;for(let i=0;i<t.length;i++){const s=t[i];r.has(s.id)||r.set(s.id,new Set);for(let n=i+1;n<t.length;n++){const i=t[n];e(s,i)&&(r.get(s.id).add(i.id),r.has(i.id)||r.set(i.id,new Set),r.get(i.id).add(s.id))}}const o=new Array(i).fill(0),a=[...t].sort((e,i)=>{const s=(r.get(e.id)||new Set).size,n=(r.get(i.id)||new Set).size,o=t.indexOf(e);return.5*-t.indexOf(i)+.5*n-(.5*-o+.5*s)});for(const t of a){const e=r.get(t.id)||new Set,a=new Set;for(const t of e){const e=n.get(t);void 0!==e&&a.add(e)}let h=-1;if("priority"===s){let t=-1,e=-1/0;for(let s=0;s<i;s++)if(!a.has(s)){const n=i-s-.7*o[s];(n>e||n===e&&s<t)&&(e=n,t=s)}h=t,-1===h&&(h=0),o[h]++}else{const t=[];for(let e=0;e<i;e++)a.has(e)||t.push(e);if(0===t.length){let t=1/0,e=0;for(let s=0;s<i;s++)(o[s]<t||o[s]===t&&s<e)&&(t=o[s],e=s);h=e}else{h=t[0];let e=o[h];for(const i of t)(o[i]<e||o[i]===e&&i<h)&&(h=i,e=o[i])}o[h]++}n.set(t.id,h)}return n})(t,(t,e)=>{if("structured"===i){const i=t.outlinePoints,s=e.outlinePoints;return!(!i||!s)&&Gg(i,s,r)}{const i=t.pixels,n=e.pixels;if(!i||!n)return!1;const o=s.mapState?.width||0;return Ug(i,n,o,r)}},e,o);this.fourColorCache={mapId:n,colorMap:a};const h=new Array(e).fill(0);return a.forEach(t=>{h[t]++}),ag.debug("[FourColor] Color distribution:",h),a}destroy(){this.obstacle.destroy(),this.free.destroy(),this.roomFill.destroy(),this.carpet.destroy(),this.chargingStation.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.fourColorCache=null}}class Ly extends Xn{commonPath;chargePath;transitionsPath;mopPath;debugPoints;pathData=null;lastPointCount=0;lastDrawnPosition=null;isRealTimeDrawing=!1;throttledUpdateLineWidth;throttledHandleRobotPosition;constructor(){super({isRenderGroup:!0});const t=Yi();t.appContainer.addToLayer(yy,this),this.eventMode="none",this.commonPath=new jl,this.chargePath=new jl,this.transitionsPath=new jl,this.mopPath=new jl,this.debugPoints=new jl,this.addChild(this.commonPath),this.addChild(this.chargePath),this.addChild(this.transitionsPath),this.addChild(this.mopPath),this.addChild(this.debugPoints),this.visible=t.runtimeSnapshot.showPath,this.commonPath.visible=t.pathConfig.commonPath.visible,this.chargePath.visible=t.pathConfig.chargePath.visible,this.transitionsPath.visible=t.pathConfig.transitionPath.visible,this.mopPath.visible=!1,this.throttledUpdateLineWidth=Ji(()=>{this.updateLineWidth()},50,{leading:!0,trailing:!0}),this.throttledHandleRobotPosition=Ji(this.handleRobotPositionUpdate.bind(this),0),this.registerEventListeners()}registerEventListeners(){const{emitter:t}=Yi();t.on("antiScale",this.throttledUpdateLineWidth),t.on("robotPositionUpdate",this.throttledHandleRobotPosition),t.on("robotAnimationComplete",this.handleRobotAnimationComplete)}handleRobotAnimationComplete=()=>{this.isRealTimeDrawing&&this.stopRealTimeDrawing()};handleRobotPositionUpdate(t){if(!this.isRealTimeDrawing||!this.lastDrawnPosition)return;let e;switch(t.pathType||"common"){case"common":default:e=this.commonPath;break;case"charge":e=this.chargePath;break;case"transitions":e=this.transitionsPath;break;case"mop":e=this.mopPath}e.moveTo(this.lastDrawnPosition.x,this.lastDrawnPosition.y),e.lineTo(t.x,t.y),e.stroke(),this.lastDrawnPosition={x:t.x,y:t.y}}updateLineWidth(){const t=Yi();this.pathData&&t.pathConfig.lineWidthFixed&&this.redrawPaths(this.pathData)}redrawPaths(t){const{pathPoints:e}=t;e&&0!==e.length&&(this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.setupPathStyles(),this.drawPathSegments(e),this.commonPath.stroke(),this.chargePath.stroke(),this.transitionsPath.stroke(),this.mopPath.stroke(),Yi().getDebuggerMode()&&this.drawDebugPoints(e))}setupPathStyles(){const t=Yi(),e=t.pathConfig,i=i=>e.lineWidthFixed?t.getApp().toFixedSize(i):i;this.commonPath.setStrokeStyle({width:i(e.commonPath.width),color:e.commonPath.color,join:"round",cap:"round"}),this.chargePath.setStrokeStyle({width:i(e.chargePath.width),color:e.chargePath.color,join:"round",cap:"round"}),this.transitionsPath.setStrokeStyle({width:i(e.transitionPath.width),color:e.transitionPath.color,join:"round",cap:"round"}),this.mopPath.setStrokeStyle({width:0,color:0,alpha:0,join:"round",cap:"round"})}drawPathSegments(t){let e=null,i=null;for(let s=0;s<t.length;s++){const n=t[s],r=n.type||"common";let o;switch(r){case"common":default:o=this.commonPath;break;case"charge":o=this.chargePath;break;case"transitions":o=this.transitionsPath;break;case"mop":o=this.mopPath}0===s||r!==e?o.moveTo(n.x,n.y):o===i&&o.lineTo(n.x,n.y),e=r,i=o}}drawDebugPoints(t){const e={common:16711935,charge:65535,transitions:16776960,mop:65280};for(const i of t){const t=e[i.type||"common"];this.debugPoints.rect(i.x-.5,i.y-.5,1,1),this.debugPoints.fill(t)}}updatePositionByOrigin(t,e){this.position.set(t,e)}drawFull(t){ag.debug("[Path] Draw Full Path",t),this.pathData=t,this.redrawPaths(t),this.lastPointCount=t.pathPoints?.length||0}drawIncremental(t){const e=Yi(),i=this.lastPointCount,s=t.pathPoints?.slice(i)||[];if(s.length>0)if(this.setupPathStyles(),ag.debug("[Path] Draw Incremental Path",s),e.robotConfig.speed>0){if(this.isRealTimeDrawing=!0,i>0&&this.pathData?.pathPoints){const t=this.pathData.pathPoints[i-1];this.lastDrawnPosition={x:t.x,y:t.y}}}else this.drawNewPathSegments(s,i,t.pathPoints,this.pathData?.pathPoints);this.pathData=t,this.lastPointCount=t.pathPoints?.length||0}drawNewPathSegments(t,e,i,s){if(!i||0===t.length)return;let n=null;e>0&&(s&&s[e-1]?n=s[e-1]:i[e-1]&&(n=i[e-1]));let r=null,o=null,a=!1;for(let e=0;e<t.length;e++){const i=t[e],s=i.type||"common";let h;switch(s){case"common":default:h=this.commonPath;break;case"charge":h=this.chargePath;break;case"transitions":h=this.transitionsPath;break;case"mop":h=this.mopPath}s!==r||0===e?(o&&a&&o.stroke(),r=s,o=h,a=!0,n&&0===e&&n.type===s?(h.moveTo(n.x,n.y),h.lineTo(i.x,i.y)):h.moveTo(i.x,i.y)):h.lineTo(i.x,i.y)}o&&a&&o.stroke()}stopRealTimeDrawing(){this.isRealTimeDrawing=!1,this.lastDrawnPosition=null}clear(){this.commonPath.clear(),this.chargePath.clear(),this.transitionsPath.clear(),this.mopPath.clear(),this.debugPoints.clear(),this.pathData=null,this.lastPointCount=0,this.lastDrawnPosition=null,this.isRealTimeDrawing=!1}destroy(t){const{emitter:e}=Yi();e.off("antiScale",this.throttledUpdateLineWidth),e.off("robotPositionUpdate",this.throttledHandleRobotPosition),e.off("robotAnimationComplete",this.handleRobotAnimationComplete),this.stopRealTimeDrawing(),super.destroy(t)}}class jy extends Ry{constructor(){super(),this.initializeSprite()}async initializeSprite(){const t=Yi();await this.loadTextureAndSetSize("robot",t.robotConfig.icon)}async draw({x:t,y:e,rotation:i}){super.draw({x:t,y:e,rotation:i})}}class Gy extends Nl{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;static animationTicker=null;static animatedSprites=new Set;constructor(t){super(t||[]),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet||this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet||this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.textures||0===this.textures.length||!this.textures[0]||0===this.textures[0].width||0===this.textures[0].height)return;const t=Yi(),e=this.textures[0],i=this.fixedWidth/e.width,s=this.fixedHeight/e.height;if(this.sizeFixed){const e=t.currentScale;if(0===e||!isFinite(e)){const t=i,e=s;return void super.scale.set(t,e)}const n=i/e,r=s/e;super.scale.set(n,r)}else super.scale.set(i/this.baselineScale,s/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static async loadAnimationTextures(t,e,i="sleep_",s=96){try{const n=await fetch(t),r=await n.json();r.meta&&(r.meta.image=e),await gl.load(e);const o=Gs.from(e),a=new _r(o.source,r);await a.parse();const h=[];for(let t=0;t<s;t++){const e=`${i}${t.toString().padStart(3,"0")}.png`,s=a.textures[e];s?h.push(s):ag.warn(`[EnhancedAnimatedSprite] Frame not found: ${e}`)}return h}catch(t){return ag.error("[EnhancedAnimatedSprite] Failed to load textures:",t),[]}}setupAnimation(t){void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.setFixedSize(t.width,t.height),this.animationSpeed=.5,this.loop=!0,ag.log(`Animation setup complete, visible=${this.visible}, scale=(${this.scale.x.toFixed(3)}, ${this.scale.y.toFixed(3)})`)}draw(t,e){const{x:i,y:s}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.position.set(i,s)}play(){this.textures&&this.textures.length>0&&(super.play(),Gy.animatedSprites.add(this),Gy.startAnimationTicker())}stop(){super.stop(),Gy.animatedSprites.delete(this),Gy.updateAnimationTicker()}set textures(t){super.textures=t,this.isFixedSizeSet&&t&&t.length>0&&t[0]&&t[0].width>0&&t[0].height>0&&this.applySize()}get textures(){return super.textures}static startAnimationTicker(){Gy.animationTicker?.started||(Gy.animationTicker||(Gy.animationTicker=new lr,Gy.animationTicker.maxFPS=24,Gy.animationTicker.add(()=>{Gy.updateAnimations()})),Gy.animationTicker.start(),ag.log("🎬 [AnimationTicker] Started animation ticker"))}static updateAnimationTicker(){Gy.animatedSprites.size>0?Gy.startAnimationTicker():Gy.stopAnimationTicker()}static stopAnimationTicker(){Gy.animationTicker?.started&&(ag.log("⏸️ [AnimationTicker] Stopped animation ticker"),Gy.animationTicker.stop())}static updateAnimations(){if(0===Gy.animatedSprites.size)return;const t=Yi().getApp();t.renderer.render(t.stage)}destroy(t){Gy.animatedSprites.delete(this),Gy.updateAnimationTicker(),Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Uy extends Gy{unsubscribeFns=[];throttledUpdateOffset;fixedOffsetX=0;fixedOffsetY=0;constructor(t){super(t),this.throttledUpdateOffset=Ji(this.updateOffset.bind(this),30,{leading:!0,trailing:!0}),this.initializeAnimation()}static async create(){const t=Yi().robotConfig,e=await Gy.loadAnimationTextures(t.sleepAnimation.jsonSrc,t.sleepAnimation.imageSrc,t.sleepAnimation.framePrefix,t.sleepAnimation.frameCount);0===e.length&&(ag.warn("No textures loaded for sleep animation"),e.push(Gs.EMPTY));const i=new Uy(e);return i.setupAnimation({width:t.sleepAnimation.width,height:t.sleepAnimation.height,sizeFixed:t.sleepAnimation.sizeFixed}),i}initializeAnimation(){const t=Yi();this.visible=!1,this.fixedOffsetX=t.robotConfig.sleepAnimation.offsetX,this.fixedOffsetY=t.robotConfig.sleepAnimation.offsetY,t.emitter.on("antiScale",this.throttledUpdateOffset);const e=Xi(t.runtime,"showRobotSleepAnimation",t=>{ag.log(`[runtime] showRobotSleepAnimation: ${t}`),this.updateVisibility()});this.unsubscribeFns.push(e)}shouldShow(){const t=Yi().runtimeSnapshot.showRobotSleepAnimation,e=this.parent,i=!!e&&e.visible,s=e&&(0!==e.x||0!==e.y);return t&&i&&!!s}updateVisibility(){const t=this.shouldShow();t&&!this.visible?(this.visible=!0,this.textures&&this.textures.length>0&&this.play()):!t&&this.visible?(this.visible=!1,this.stop()):!t&&this.playing&&this.stop()}updateOffset(t){}draw(t){const e=Yi(),i=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetX),s=e.getApp().toFixedSize(e.robotConfig.sleepAnimation.offsetY),n={...t,x:t.x+i,y:t.y+s};super.draw(n,()=>this.shouldShow()),this.updateVisibility()}onRobotVisibilityChanged(){this.updateVisibility()}set visible(t){const e=super.visible;super.visible=t,t&&!e&&this.textures&&this.textures.length>0?this.play():!t&&e&&this.playing&&this.stop()}get visible(){return super.visible}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateOffset),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stop(),super.destroy(t)}}class zy extends jl{currentPosition=null;animationStartTime=0;isAnimating=!1;constructor(){super(),this.setupAntiScaleListener()}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.handleScaleChange)}handleScaleChange=()=>{this.redraw()};draw(t){this.currentPosition=t,this.isAnimating||this.startAnimation(),this.redraw()}startAnimation(){const t=Yi();this.isAnimating||(this.isAnimating=!0,this.animationStartTime=Date.now(),t.getApp().ticker.add(this.updateAnimation,this),t.getApp().requestRender("pulse-circle-animation",!0))}stopAnimation(){const t=Yi();this.isAnimating&&(this.isAnimating=!1,t.getApp().ticker.remove(this.updateAnimation,this),t.getApp().stopRender("pulse-circle-animation"))}updateAnimation=()=>{if(!this.currentPosition||!this.isAnimating||!this.visible)return;const t=Yi(),e=t.robotConfig.pulseCircle,i=(Date.now()-this.animationStartTime)%e.duration/e.duration,{minScale:s,maxScale:n,minAlpha:r,maxAlpha:o}=e,a=s+(n-s)*(.5*Math.sin(i*Math.PI*2)+.5),h=o-(o-r)*(a-s)/(n-s);super.clear();const{size:l,color:c,strokeWidth:d,strokeColor:u,sizeFixed:p}=e,g=(p?t.getApp().toFixedSize(l/2):l/2)*a,f=t.getApp().toFixedSize(d);this.setFillStyle({color:c,alpha:h}),this.circle(this.currentPosition.x,this.currentPosition.y,g).fill().stroke({color:u,width:f,alpha:h,cap:"round",join:"round"})};redraw(){this.currentPosition&&this.isAnimating&&this.updateAnimation()}clearCircle(){super.clear()}remove(){this.stopAnimation(),this.clearCircle(),this.currentPosition=null}destroy(){this.stopAnimation(),Yi().emitter.off("antiScale",this.handleScaleChange),super.destroy()}}class Ny extends Xn{robot;ring;pulseCircle;sleepAnimation=null;unsubscribeFns=[];targetPosition=null;targetRotation=null;isMoving=!1;pathQueue=[];lastPosition=null;currentPathType=void 0;lastUpdateTime=0;isCleared=!1;constructor(){super();const t=Yi();t.appContainer.addToLayer(Cy,this),this.visible=t.runtime.showPath,this.ring=new Oy({config:t.robotConfig.ring}),this.ring.visible=t.runtime.showRobotRing,this.addChild(this.ring),this.pulseCircle=new zy,this.pulseCircle.visible=t.runtime.showRobotPulseCircle,this.addChild(this.pulseCircle),this.robot=new jy,this.addChild(this.robot),this.lastUpdateTime=Date.now(),t.robotConfig.speed>0&&t.getApp().ticker.add(this.update,this);const e=Xi(t.runtime,"showRobotRing",t=>{ag.log(`[runtime] showRobotRing: ${t}`),this.ring.visible=t});this.unsubscribeFns.push(e);const i=Xi(t.runtime,"showRobotPulseCircle",t=>{ag.log(`[runtime] showRobotPulseCircle: ${t}`),t?(this.lastPosition&&this.pulseCircle.draw(this.lastPosition),this.pulseCircle.visible=!0):(this.pulseCircle.remove(),this.pulseCircle.visible=!1)});this.unsubscribeFns.push(i)}async initializeSleepAnimation(){try{this.sleepAnimation=await Uy.create(),this.addChild(this.sleepAnimation),ag.log("Sleep animation added to robot")}catch(t){ag.error("Failed to initialize sleep animation:",t)}}updatePositionByOrigin(t,e){this.position.set(t,e)}async draw({x:t,y:e,rotation:i}){if(this.isCleared){this.robot.visible=!0;const t=Yi();this.ring.visible=t.runtime.showRobotRing,this.pulseCircle.visible=t.runtime.showRobotPulseCircle,this.sleepAnimation&&(this.sleepAnimation.visible=!0),this.isCleared=!1}this.ring.draw({x:t,y:e}),this.pulseCircle.draw({x:t,y:e}),await this.robot.draw({x:t,y:e,rotation:i}),this.sleepAnimation||await this.initializeSleepAnimation(),this.sleepAnimation.draw({x:t,y:e}),this.lastPosition={x:t,y:e}}getCurrentPosition(){return this.lastPosition?{...this.lastPosition}:null}moveTo(t){this.pathQueue.push(t),this.isMoving||this.processNextPathPoint()}batchProcessQueue(t=!1){if(0===this.pathQueue.length)return;const e=[...this.pathQueue];if(t){const t=e[e.length-1];this.robot.position.set(t.x,t.y),void 0!==t.rotation&&(this.robot.rotation=t.rotation),this.lastPosition={x:t.x,y:t.y},this.pathQueue=[],this.isMoving=!1,this.targetPosition=null}else this.pathQueue.splice(0,e.length),0===this.pathQueue.length?(this.isMoving=!1,this.targetPosition=null):this.processNextPathPoint()}processNextPathPoint(){if(0===this.pathQueue.length)return this.isMoving=!1,this.currentPathType=void 0,this.stopRobotAnimation(),void Yi().emitter.emit("robotAnimationComplete");this.isMoving||this.startRobotAnimation(),this.isMoving=!0;const t=this.pathQueue[0];this.targetPosition={x:t.x,y:t.y},this.currentPathType=t.type,void 0!==t.rotation&&(this.targetRotation=t.rotation),this.lastPosition||(this.lastPosition={x:this.robot.x,y:this.robot.y})}update(){const t=Yi(),e=Date.now();if(0===this.lastUpdateTime)return void(this.lastUpdateTime=e);let i=e-this.lastUpdateTime;if(this.lastUpdateTime=e,i>500&&(i=16.67),this.targetPosition){const e=this.targetPosition.x-this.robot.x,s=this.targetPosition.y-this.robot.y,n=Math.sqrt(e*e+s*s),r=t.robotConfig.speed,o=t.getApp().metersToPixels(r);if(0===r)return this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),void this.processNextPathPoint();const a=o*(i/1e3);n<a?(this.robot.position.set(this.targetPosition.x,this.targetPosition.y),null!==this.targetRotation&&(this.robot.rotation=this.targetRotation,this.targetRotation=null),this.targetPosition=null,this.lastPosition={x:this.robot.x,y:this.robot.y},this.pathQueue.shift(),this.processNextPathPoint()):(this.robot.x+=e*(a/n),this.robot.y+=s*(a/n),Yi().emitter.emit("robotPositionUpdate",{x:this.robot.x,y:this.robot.y,pathType:this.currentPathType}),this.lastPosition={x:this.robot.x,y:this.robot.y})}}startRobotAnimation(){Yi().getApp().requestRender("robot-animation",!0)}set visible(t){super.visible=t,this.sleepAnimation&&this.sleepAnimation.onRobotVisibilityChanged()}get visible(){return super.visible}stopRobotAnimation(){Yi().getApp().stopRender("robot-animation")}remove(){this.pathQueue=[],this.isMoving=!1,this.targetPosition=null,this.stopRobotAnimation()}clear(){this.remove(),this.robot.visible=!1,this.ring.visible=!1,this.pulseCircle.remove(),this.sleepAnimation&&(this.sleepAnimation.visible=!1),this.lastPosition=null,this.isCleared=!0}destroy(t){const e=Yi();this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.stopRobotAnimation(),e.robotConfig.speed>0&&e.getApp().ticker.remove(this.update,this),this.ring.destroy(),this.pulseCircle.destroy(),super.destroy(t)}}class Vy{path;robot;unsubscribeFns=[];lastDrawnPathData=null;constructor(){const t=Yi();this.path=new Ly,this.robot=new Ny;const e=Xi(t.runtime,"showPath",t=>{ag.log(`[runtime] showPath: ${t}`),this.path.visible=t,this.robot.visible=t});this.unsubscribeFns.push(e)}draw(t){this.shouldUseIncrementalDraw(t)?this.incrementalDraw(t):this.fullDraw(t),this.lastDrawnPathData=t}shouldUseIncrementalDraw(t){const e=Yi();if(!this.lastDrawnPathData)return!1;const i=t.pathHeader?.pathId,s=this.lastDrawnPathData.pathHeader?.pathId;if(i!==s)return!1;const n=(t.pathPoints?.length||0)-(this.lastDrawnPathData.pathPoints?.length||0),r=e.pathConfig.incrementalThreshold;return!(n<=0||n>r)}fullDraw(t){if(this.path.stopRealTimeDrawing(),this.path.drawFull(t),t.pathPoints&&t.pathPoints.length>0){const e=t.pathPoints[t.pathPoints.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}convertToRobotPoint(t,e){const i=e+Yi().robotConfig.rotationCorrection;return{x:t.x,y:t.y,rotation:i*Math.PI/180,type:t.type}}moveRobotToPoint(t,e,i=!0){const s=this.convertToRobotPoint(t,e);i?this.robot.moveTo(s):(this.robot.remove(),this.robot.draw(s))}incrementalDraw(t){const e=Yi();if(!this.lastDrawnPathData||!t.pathPoints)return;this.path.drawIncremental(t);const i=this.lastDrawnPathData.pathPoints?.length||0,s=t.pathPoints.slice(i);if(0!==s.length)if(e.robotConfig.speed>0)s.forEach(e=>{this.moveRobotToPoint(e,t.pathHeader.direction,!0)});else{const e=s[s.length-1];this.moveRobotToPoint(e,t.pathHeader.direction,!1)}}batchProcessRobotQueue(t=!1){this.robot.batchProcessQueue(t)}updatePositionByOrigin(t,e){this.path.updatePositionByOrigin(t,e),this.robot.updatePositionByOrigin(t,e)}clear(){this.lastDrawnPathData=null,this.path.clear(),this.robot.clear()}destroy(){this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[],this.path.destroy(),this.robot.destroy()}}class Hy extends Xn{colorGradients=[];cellSize=2;constructor(){super();const t=Yi();t.appContainer.addToLayer(my,this);const e=t.heatMapConfig;this.colorGradients=e.colorGradients.map(t=>new yn(t).toArray().slice(0,3).join(",")),this.cellSize=e.cellSize}draw(t,e=!0,i=.8){this.removeChildren();const s=e?this.gradientDrawing(t):this.gridDrawing(t);this.croppingHeatmap(s),s.alpha=i,this.addChild(s)}croppingHeatmap(t){const e=Yi().mapManager.roomFill.children.filter(t=>t instanceof jl),i=new jl;for(const t of e)i.context.instructions.push(...t.context.instructions);i.context.dirty=!0,t.setMask({mask:i}),this.addChild(i)}gridDrawing(t){const e=[],i=[],s=t.length,n=t[0].length;for(let r=0;r<s;r++)for(let s=0;s<n;s++){const n=t[r][s],o=this.cellSize/2,a=n.x-o,h=n.y-o,l=n.x+o,c=n.y+o;e.push(a,h),i.push(n.signal),e.push(l,h),i.push(n.signal),e.push(l,c),i.push(n.signal),e.push(a,h),i.push(n.signal),e.push(l,c),i.push(n.signal),e.push(a,c),i.push(n.signal)}const r=new ya({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new po({glProgram:new to({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n void main() {\n vec3 color;\n \n if (vSignal > 0.875) {\n color = vec3(${this.colorGradients[0]});\n } else if (vSignal > 0.75) {\n color = vec3(${this.colorGradients[1]});\n } else if (vSignal > 0.625) {\n color = vec3(${this.colorGradients[2]});\n } else if (vSignal > 0.5) {\n color = vec3(${this.colorGradients[3]});\n } else if (vSignal > 0.375) {\n color = vec3(${this.colorGradients[4]});\n } else if (vSignal > 0.25) {\n color = vec3(${this.colorGradients[5]});\n } else if (vSignal > 0.125) {\n color = vec3(${this.colorGradients[6]});\n } else {\n color = vec3(${this.colorGradients[7]});\n }\n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new zl({geometry:r,shader:o});return a.alpha=.8,a}gradientDrawing(t){const e=[],i=[],s=t.length,n=t[0].length;for(let r=0;r<s;r++)for(let o=0;o<n;o++){const a=t[r][o],h=this.cellSize/2,l=(e,i)=>e<0||e>=s||i<0||i>=n?a.signal:t[e][i].signal,c=(l(r-1,o-1)+l(r-1,o)+l(r,o-1)+a.signal)/4,d=(l(r-1,o)+l(r-1,o+1)+a.signal+l(r,o+1))/4,u=(a.signal+l(r,o+1)+l(r+1,o)+l(r+1,o+1))/4,p=(l(r,o-1)+a.signal+l(r+1,o-1)+l(r+1,o))/4,g=a.x-h,f=a.y-h,m=a.x+h,y=a.y+h;e.push(g,f,m,f,m,y),i.push(c,d,u),e.push(g,f,m,y,g,y),i.push(c,u,p)}const r=new ya({attributes:{aPosition:new Float32Array(e),aSignal:new Float32Array(i)}}),o=new po({glProgram:new to({vertex:"\n in vec2 aPosition;\n in float aSignal;\n uniform mat3 uProjectionMatrix;\n uniform mat3 uWorldTransformMatrix;\n uniform mat3 uTransformMatrix;\n \n out float vSignal;\n \n void main() {\n mat3 mvp = uProjectionMatrix * uWorldTransformMatrix * uTransformMatrix;\n gl_Position = vec4((mvp * vec3(aPosition, 1.0)).xy, 0.0, 1.0);\n vSignal = aSignal;\n }\n ",fragment:`\n precision mediump float;\n \n in float vSignal;\n \n // 颜色插值函数\n vec3 interpolateColor(vec3 color1, vec3 color2, float t) {\n return mix(color1, color2, t);\n }\n \n void main() {\n vec3 color;\n float signal = clamp(vSignal, 0.0, 1.0);\n \n vec3 color1 = vec3(${this.colorGradients[7]});\n vec3 color2 = vec3(${this.colorGradients[6]});\n vec3 color3 = vec3(${this.colorGradients[5]});\n vec3 color4 = vec3(${this.colorGradients[4]});\n vec3 color5 = vec3(${this.colorGradients[3]});\n vec3 color6 = vec3(${this.colorGradients[2]});\n vec3 color7 = vec3(${this.colorGradients[1]});\n vec3 color8 = vec3(${this.colorGradients[0]});\n \n if (signal <= 0.125) {\n float t = signal / 0.125;\n color = interpolateColor(color1, color2, t);\n } else if (signal <= 0.25) {\n float t = (signal - 0.125) / 0.125;\n color = interpolateColor(color2, color3, t);\n } else if (signal <= 0.375) {\n float t = (signal - 0.25) / 0.125;\n color = interpolateColor(color3, color4, t);\n } else if (signal <= 0.5) {\n float t = (signal - 0.375) / 0.125;\n color = interpolateColor(color4, color5, t);\n } else if (signal <= 0.625) {\n float t = (signal - 0.5) / 0.125;\n color = interpolateColor(color5, color6, t);\n } else if (signal <= 0.75) {\n float t = (signal - 0.625) / 0.125;\n color = interpolateColor(color6, color7, t);\n } else if (signal <= 0.875) {\n float t = (signal - 0.75) / 0.125;\n color = interpolateColor(color7, color8, t);\n } else {\n color = color8;\n }\n \n gl_FragColor = vec4(color, 1.0);\n }\n `})}),a=new zl({geometry:r,shader:o});return a.alpha=.8,a}}class Wy{heatmap=new Hy;pointsTopLeftOrigin=[];signalGrid=[];cellSize=2;maxDistance=14;smoothIterations=10;heatmapAlpha=.8;constructor(){const t=Yi().heatMapConfig;this.cellSize=t.cellSize,this.maxDistance=t.maxDistance,this.smoothIterations=t.smoothIterations,this.heatmapAlpha=t.heatmapAlpha}draw({mapData:t,heatmapPoints:e,useGradient:i=!0}){const s=Yi(),n=t.origin[0],r=t.origin[1],{minX:o,minY:a}=s.mapManager.mapBounds,h=e.map(t=>({x:+(n+t.x-o).toFixed(0),y:+(r+t.y-a).toFixed(0),signal:t.signal}));this.signalGrid=this.calculateInterpolatedSignal(h),this.heatmap.draw(this.signalGrid,i,this.heatmapAlpha)}calculateInterpolatedSignal(t){const e=Yi(),{minX:i,minY:s,maxX:n,maxY:r}=e.mapManager.mapBounds,o=Math.ceil((r-s)/this.cellSize),a=Math.ceil((n-i)/this.cellSize),h=Array(o).fill(null).map(()=>Array(a).fill(null));for(let e=0;e<o;e++){const o=s+e*this.cellSize+this.cellSize/2,l=Math.min(this.cellSize,r-(o-this.cellSize/2));for(let s=0;s<a;s++){const r=i+s*this.cellSize+this.cellSize/2,a=Math.min(this.cellSize,n-(r-this.cellSize/2));let c=0,d=!1;for(let e=0;e<t.length;e++){const i=t[e];if(Math.abs(r-i.x)<=a/2&&Math.abs(o-i.y)<=l/2){const t=1-i.signal/7;c=Math.round(10*Math.max(c,t))/10,d=!0}}h[e][s]={x:r,y:o,signal:c,hasPoint:d}}}const l=(e,i)=>{if(0===t.length)return 0;let s=0,n=0;for(const r of t){const t=Math.sqrt((e-r.x)**2+(i-r.y)**2);if(t<=this.maxDistance){const e=1/(1+t);n+=e*(1-r.signal/7),s+=e}}return 0===s?0:Math.round(n/s*1e3)/1e3};for(let t=0;t<o;t++)for(let e=0;e<a;e++){const i=h[t][e];i.hasPoint||(i.signal=l(i.x,i.y))}return((t,e=1)=>{for(let i=0;i<e;i++){const e=t.map(t=>[...t]);for(let i=1;i<o-1;i++)for(let s=1;s<a-1;s++)if(!t[i][s].hasPoint){let n=0,r=0;const h=4;for(let e=-h;e<=h;e++)for(let l=-h;l<=h;l++){if(0===e&&0===l)continue;const h=i+e,c=s+l;if(h>=0&&h<o&&c>=0&&c<a){const i=1/(1+.3*Math.sqrt(e*e+l*l));n+=t[h][c].signal*i,r+=i}}if(r>0){const o=n/r,a=.6,h=.4;e[i][s].signal=t[i][s].signal*a+o*h,e[i][s].signal>.1&&(e[i][s].signal=Math.max(e[i][s].signal,.2))}}for(let i=0;i<o;i++)for(let s=0;s<a;s++)t[i][s].signal=e[i][s].signal}})(h,this.smoothIterations),h}}class Jy extends Xn{throttledUpdateScale;constructor(){super(),this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0});const t=Yi();this.updateScale(t.currentScale),this.registerScaleListener()}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){0!==t&&this.scale.set(1/t)}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Zy extends Jy{background;icon;options;constructor(t){super(),this.options=t,this.background=new jl,this.addChild(this.background),this.icon=new Ry,this.addChild(this.icon),this.eventMode="static",this.render(),this.setupHitArea(),this.setupEvents()}setupHitArea(){const t=Yi().controlsConfig,e=t.iconWrapperWidth+16,i=t.iconWrapperHeight+16;this.hitArea=new Ss(-e/2,-i/2,e,i)}async render(){this.renderBackground(),this.renderIcon()}renderBackground(){const t=Yi().controlsConfig;this.background.clear(),this.background.roundRect(-t.iconWrapperWidth/2,-t.iconWrapperHeight/2,t.iconWrapperWidth,t.iconWrapperHeight,t.iconWrapperBorderRadius).fill(this.options.backgroundColor)}async renderIcon(){try{const t=Yi().controlsConfig;await this.icon.loadTextureAndSetSize(this.options.iconAlias,{width:t.iconWidth,height:t.iconHeight,sizeFixed:!1}),this.icon.visible=!0}catch(t){ag.error(`Failed to load icon: ${this.options.iconAlias}`,t)}}destroy(){super.destroy()}}class Xy extends Zy{isRotating=!1;rotationCenter={x:0,y:0};lastAngle=0;constructor(t){super(t),this.setupRotationEventListeners()}setupRotationEventListeners(){const{emitter:t}=Yi();Yi().emitter.on("gestureHijackPointerMove",this.handleRotationPointerMove),t.on("gestureHijackPointerUp",this.handleRotationPointerUp),t.on("gestureHijackCancel",this.handleRotationCancel)}cleanupRotationEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleRotationPointerMove),t.off("gestureHijackPointerUp",this.handleRotationPointerUp),t.off("gestureHijackCancel",this.handleRotationCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startRotation(t)}startRotation(t){this.isRotating=!0;const e=this.options.getTargetPoints();this.rotationCenter=_g(e);const i=this.parent.toLocal(t.global);this.lastAngle=Math.atan2(i.y-this.rotationCenter.y,i.x-this.rotationCenter.x),this.options.onRotationStart?.(this.rotationCenter),Yi().emitter.emit("gestureHijackStart",t)}handleRotationPointerMove=t=>{if(!this.isRotating)return;const e=this.parent.toLocal(t.global),i=Math.atan2(e.y-this.rotationCenter.y,e.x-this.rotationCenter.x),s=i-this.lastAngle;this.options.onRotationMove?.(s),this.lastAngle=i};handleRotationPointerUp=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};handleRotationCancel=()=>{this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())};isCurrentlyRotating(){return this.isRotating}stopRotation(){this.isRotating&&(this.isRotating=!1,this.options.onRotationEnd?.())}destroy(){this.stopRotation(),this.cleanupRotationEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Yy extends Zy{clickHandler=null;constructor(t){super(t)}setupEvents(){this.clickHandler=new Ty(this,{onClick:this.options.onClick,stopPropagation:!0})}destroy(){this.clickHandler?.destroy(),super.destroy()}}class Ky extends Zy{isScaling=!1;initialButtonPosition=null;dragStartPosition=null;constructor(t){super(t),this.setupScaleEventListeners()}setupScaleEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleScalePointerMove),t.on("gestureHijackPointerUp",this.handleScalePointerUp),t.on("gestureHijackCancel",this.handleScaleCancel)}cleanupScaleEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleScalePointerMove),t.off("gestureHijackPointerUp",this.handleScalePointerUp),t.off("gestureHijackCancel",this.handleScaleCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startScaling(t)}startScaling(t){this.isScaling=!0,this.dragStartPosition=this.parent.toLocal(t.global);const e=this.options.getTargetPoints(),i=this.options.getButtonIndex();i>=0&&i<e.length&&(this.initialButtonPosition={...e[i]}),this.options.onScaleStart?.(i),Yi().emitter.emit("gestureHijackStart",t)}handleScalePointerMove=t=>{if(!this.isScaling||!this.initialButtonPosition||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,s=e.y-this.dragStartPosition.y,n={x:this.initialButtonPosition.x+i,y:this.initialButtonPosition.y+s};this.options.onScaleMove?.(n)};handleScalePointerUp=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};handleScaleCancel=()=>{this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())};isCurrentlyScaling(){return this.isScaling}stopScaling(){this.isScaling&&(this.isScaling=!1,this.initialButtonPosition=null,this.dragStartPosition=null,this.options.onScaleEnd?.())}destroy(){this.stopScaling(),this.cleanupScaleEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class Qy extends Zy{isMoving=!1;dragStartPosition=null;constructor(t){super(t),this.setupMoveEventListeners()}setupMoveEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleMovePointerMove),t.on("gestureHijackPointerUp",this.handleMovePointerUp),t.on("gestureHijackCancel",this.handleMoveCancel)}cleanupMoveEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleMovePointerMove),t.off("gestureHijackPointerUp",this.handleMovePointerUp),t.off("gestureHijackCancel",this.handleMoveCancel)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}handlePointerDown(t){t.stopPropagation(),this.startMoving(t)}startMoving(t){this.isMoving=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.options.onMoveStart?.(),Yi().emitter.emit("gestureHijackStart",t)}handleMovePointerMove=t=>{this.isMoving&&this.dragStartPosition&&this.options.onMoveMove?.(t)};handleMovePointerUp=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};handleMoveCancel=()=>{this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())};isCurrentlyMoving(){return this.isMoving}getDragStartPosition(){return this.dragStartPosition?{...this.dragStartPosition}:null}stopMoving(){this.isMoving&&(this.isMoving=!1,this.dragStartPosition=null,this.options.onMoveEnd?.())}destroy(){this.stopMoving(),this.cleanupMoveEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class qy extends jl{fillOptions;isDragging=!1;dragStartPosition=null;constructor(t){super(),this.fillOptions=t,this.setupInteraction(),this.setupDragEventListeners(),this.draw()}setupInteraction(){this.fillOptions.enableInteraction&&(this.eventMode="static",this.on("pointerdown",this.handlePointerDown))}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){this.isDragging=!0;const e=this.parent.toLocal(t.global);this.dragStartPosition={x:e.x,y:e.y},this.fillOptions.onDragStart?.(t),Yi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.fillOptions.onDragMove?.(t)};handleDragPointerUp=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};handleDragCancel=()=>{this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.fillOptions.onDragEnd?.())};draw(){const{points:t,fillColor:e}=this.fillOptions;if(t.length<3)return;this.clear();const i=t.flatMap(t=>[t.x,t.y]);this.setFillStyle({color:e}).poly(i).fill()}getDragStartPosition(){return this.dragStartPosition}updateOptions(t){this.fillOptions={...this.fillOptions,...t},void 0!==t.enableInteraction&&(this.off("pointerdown",this.handlePointerDown),this.setupInteraction()),this.draw()}updatePoints(t){this.fillOptions.points=t,this.draw()}updateFillColor(t){this.fillOptions.fillColor=t,this.draw()}stopDragging(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null)}isCurrentlyDragging(){return this.isDragging}setInteractionEnabled(t){this.fillOptions.enableInteraction=t,t?(this.eventMode="static",this.on("pointerdown",this.handlePointerDown)):(this.eventMode="auto",this.off("pointerdown",this.handlePointerDown),this.isDragging&&this.stopDragging())}destroy(){this.stopDragging(),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class $y extends Xn{borderOptions;solidLine=null;dashGraphics=null;fillGraphics=null;constructor(t){super(),this.borderOptions={...t},this.drawBorder(),this.setupAntiScaleListener(),this.eventMode="none"}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.handleAntiScale)}handleAntiScale=()=>{this.drawBorder()};drawBorder(){const{points:t=[],closePath:e=!1,style:i}=this.borderOptions;t.length<2||(this.clearBorder(),void 0!==i.fillColor&&e&&this.drawFill(t,i),i.isDashed?this.drawContinuousDashedBorder(t,e,i):this.drawSolidBorder(t,e,i))}drawFill(t,e){if(e.fillColor&&!(t.length<3)){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy()),this.fillGraphics=new jl,this.fillGraphics.setFillStyle({color:e.fillColor}),this.fillGraphics.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.fillGraphics.lineTo(t[e].x,t[e].y);this.fillGraphics.closePath(),this.fillGraphics.fill(),this.addChild(this.fillGraphics)}}drawSolidBorder(t,e,i){const s=Yi();this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy()),this.solidLine=new jl;const n=s.getApp().toFixedSize(i.width);this.solidLine.setStrokeStyle({color:i.color,width:n}),this.solidLine.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++)this.solidLine.lineTo(t[e].x,t[e].y);e&&this.solidLine.lineTo(t[0].x,t[0].y),this.solidLine.stroke(),this.addChild(this.solidLine)}drawContinuousDashedBorder(t,e,i){if(t.length<2)return;if(!i.dashArray||2!==i.dashArray.length||i.dashArray[0]<=0||i.dashArray[1]<=0)return void ag.warn("Invalid dashArray:",i.dashArray);const s=Yi();this.dashGraphics=new jl;const n=s.getApp().toFixedSize(i.width);this.dashGraphics.setStrokeStyle({color:i.color,width:n});const r=Math.max(s.getApp().toFixedSize(i.dashArray[0]),1),o=Math.max(s.getApp().toFixedSize(i.dashArray[1]),1),a=e?[...t,t[0]]:t;this.drawContinuousPathDashes(this.dashGraphics,a,r,o),this.dashGraphics.stroke(),this.addChild(this.dashGraphics)}drawContinuousPathDashes(t,e,i,s){if(e.length<2)return;if(i<=0||s<=0)return void ag.warn("Invalid dash parameters:",{dashLength:i,gapLength:s});const n=this.calculatePathSegments(e),r=n.reduce((t,e)=>t+e.length,0);if(0===r)return;const o=i+s;let a=0;for(;a<r;){const e=a+i;e<=r?this.drawContinuousDashSegment(t,n,a,e):this.drawContinuousDashSegment(t,n,a,r),a+=o}}calculatePathSegments(t){const e=[];for(let i=0;i<t.length-1;i++){const s=t[i],n=t[i+1],r=n.x-s.x,o=n.y-s.y,a=Math.sqrt(r*r+o*o);e.push({start:s,end:n,length:a})}return e}drawContinuousDashSegment(t,e,i,s){if(i>=s)return;let n=0,r=!1,o=null;for(const a of e){const e=n,h=n+a.length;if(h>i&&e<s){const n=Math.max(i,e),l=Math.min(s,h),c=(n-e)/a.length,d=(l-e)/a.length,u={x:a.start.x+(a.end.x-a.start.x)*c,y:a.start.y+(a.end.y-a.start.y)*c},p={x:a.start.x+(a.end.x-a.start.x)*d,y:a.start.y+(a.end.y-a.start.y)*d};r?o&&Math.sqrt(Math.pow(u.x-o.x,2)+Math.pow(u.y-o.y,2))>.1&&t.lineTo(u.x,u.y):(t.moveTo(u.x,u.y),r=!0),t.lineTo(p.x,p.y),o=p}if(n+=a.length,n>=s)break}}clearBorder(){this.fillGraphics&&(this.removeChild(this.fillGraphics),this.fillGraphics.destroy(),this.fillGraphics=null),this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.dashGraphics&&(this.removeChild(this.dashGraphics),this.dashGraphics.destroy(),this.dashGraphics=null)}updateStyle(t){this.borderOptions.style={...this.borderOptions.style,...t},this.drawBorder()}updatePoints(t){this.borderOptions.points=t,this.drawBorder()}setClosePath(t){this.borderOptions.closePath=t,this.drawBorder()}getOptions(){return{...this.borderOptions}}destroy(){Yi().emitter.off("antiScale",this.handleAntiScale),this.clearBorder(),super.destroy()}}class tx extends Ql{throttledUpdateScale;constructor({text:t,style:e}){super({text:t,style:e}),this.throttledUpdateScale=Ji(this.updateScale.bind(this),20,{leading:!0,trailing:!0}),this.registerScaleListener(),this.updateScale(Yi().currentScale)}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(t){t<=0||this.scale.set(1/t)}setBaseFontSize(t){this.style.fontSize=t}updateText(t){this.text=t}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class ex extends Xn{static BUTTON_INDICES={REMOVE:0,ROTATE:1,SCALE:2,MOVE:3,FIXED:0};zoneData;zoneType;zoneConfig;controlsConfig;zoneEvents;controlFill;zoneBorder;outlineBorder;moveLine;sizeText;controlButtons;deleteButton=null;rotateButton=null;scaleButton=null;moveButton=null;totalRotationAngle=0;rotationCenter=null;initialZonePoints=[];clickHandler=null;throttledUpdateOutline;constructor(t){super();const{zoneData:e,zoneType:i,events:s={}}=t;this.zoneType=i,this.zoneEvents=s,this.zoneConfig=this.getZoneConfig(),this.controlsConfig=this.getControlsConfig();const n=this.validateAndCorrectZoneSize(e.points),r=wg(n);this.zoneData={...e,points:r},this.throttledUpdateOutline=Ji(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.createControlButtons(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateOutline)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition())}getZoneConfig(){const t=Yi(),{controls:e}=t.getConfig();return e[this.zoneType]}getControlsConfig(){const t=Yi(),{controls:e}=t.getConfig();return e}validateAndCorrectZoneSize(t){const e=Yi();if(t.length<4)return t;const i=e.metersToPixels(this.zoneConfig.minSize),[s,n,,r]=t,o=Cg(s,n),a=Cg(s,r);if(o>=i&&a>=i)return t;const h=_g(t),l=Mg(Ig(s,n)),c=Mg(Ig(s,r)),d=Math.max(o,i)/2,u=Math.max(a,i)/2;return[{x:h.x-l.x*d-c.x*u,y:h.y-l.y*d-c.y*u},{x:h.x+l.x*d-c.x*u,y:h.y+l.y*d-c.y*u},{x:h.x+l.x*d+c.x*u,y:h.y+l.y*d+c.y*u},{x:h.x-l.x*d+c.x*u,y:h.y-l.y*d+c.y*u}]}getEditingIdsKey(){switch(this.zoneType){case"forbiddenSweepZone":default:return"editingForbiddenSweepZoneIds";case"forbiddenMopZone":return"editingForbiddenMopZoneIds";case"cleanZone":return"editingCleanZoneIds"}}isEditingEnabled(){const t=this.getEditingIdsKey();return Yi().runtimeSnapshot[t].includes(this.zoneData.id)}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.controlFill=this.createControlFill(),this.addChild(this.controlFill),this.zoneBorder=this.createBorder(),this.addChild(this.zoneBorder),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.sizeText=this.createSizeText(),this.addChild(this.sizeText),this.controlButtons=new Xn,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.drawZone()}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;this.deleteButton=new Yy({iconAlias:"deleteIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onClick:this.handleDelete}),this.deleteButton.position.set(t[ex.BUTTON_INDICES.REMOVE].x,t[ex.BUTTON_INDICES.REMOVE].y),this.zoneConfig.showRotateButton&&(this.rotateButton=new Xy({iconAlias:"rotateIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,onRotationStart:this.handleRotationStart,onRotationMove:this.handleRotationMove,onRotationEnd:this.handleRotationEnd}),this.rotateButton.position.set(t[ex.BUTTON_INDICES.ROTATE].x,t[ex.BUTTON_INDICES.ROTATE].y)),this.scaleButton=new Ky({iconAlias:"scaleIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,getTargetPoints:()=>this.zoneData.points,getButtonIndex:()=>ex.BUTTON_INDICES.SCALE,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[ex.BUTTON_INDICES.SCALE].x,t[ex.BUTTON_INDICES.SCALE].y);const e=this.calculateMoveButtonPosition();this.moveButton=new Qy({iconAlias:"moveIcon",backgroundColor:this.zoneConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(e.x,e.y),this.controlButtons.addChild(this.deleteButton),this.rotateButton&&this.controlButtons.addChild(this.rotateButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}createControlFill(){const t=this.isEditingEnabled();return new qy({points:this.zoneData.points,fillColor:this.zoneConfig.fillColor,enableInteraction:t,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(){const t=this.isEditingEnabled()?this.zoneConfig.editing:this.zoneConfig.normal;return new $y({points:this.zoneData.points,closePath:!0,style:{color:this.zoneConfig.strokeColor,width:this.zoneConfig.strokeWidth,isDashed:t.isDashed,dashArray:t.dashArray}})}createOutlineBorder(){const t=this.calculateOutlinePoints();return new $y({points:t,closePath:!0,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray,fillColor:this.zoneConfig.outlineFillColor}})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new $y({points:e,closePath:!1,style:{color:this.zoneConfig.outlineStrokeColor,width:this.zoneConfig.outlineStrokeWidth,isDashed:this.zoneConfig.outlineDashed,dashArray:this.zoneConfig.outlineDashArray}})}calculateOutlinePoints(){const{points:t}=this.zoneData;return t.length<4?t:((t,e)=>{if(t.length<3)return t;const i=[];for(let s=0;s<t.length;s++){const n=t[s],r=t[(s+1)%t.length],o=t[(s-1+t.length)%t.length],a=Ig(n,r);if(0===Sg(a)){i.push(n);continue}const h=Mg(a),l={x:h.y,y:-h.x},c=Ig(o,n);let d={x:0,y:0};if(Sg(c)>0){const t=Mg(c);d={x:t.y,y:-t.x}}const u=Bg(d,l),p=d.x*l.x+d.y*l.y,g=1/Math.max(.1,Math.sqrt((1+p)/2)),f={x:n.x+u.x*e*g,y:n.y+u.y*e*g};i.push(f)}return i})(t,Yi().getApp().toFixedSize(this.zoneConfig.outlineOffset))}calculateMoveLinePoints(t){return t.length<4?[]:[t[ex.BUTTON_INDICES.MOVE],this.calculateMoveButtonPosition()]}createSizeText(){const t=this.calculateZoneSizeText(),e=new tx({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.zoneConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();e.position.set(i.x,i.y);const s=this.calculateSizeTextRotation();return e.rotation=s,e.eventMode="none",e}calculateZoneSizeText(){const{points:t}=this.zoneData;if(t.length<4)return"0m*0m";const[e,i,,s]=t,n=Cg(e,i),r=Cg(e,s),o=Yi(),a=o.pixelsToMeters(n),h=o.pixelsToMeters(r),l=o.metersToDisplayUnit(a),c=o.metersToDisplayUnit(h),d=o.runtimeSnapshot.unitLabel;return`${l.toFixed(1)}${d}*${c.toFixed(1)}${d}`}calculateSizeTextPosition(){const{points:t}=this.zoneData;if(t.length<4)return{x:0,y:0};const[e,i,s,n]=t,{textPosition:r,textOffset:o}=this.zoneConfig,a=Yi().getApp().toFixedSize(o);let h,l;switch(r){case"top":{h={x:(e.x+i.x)/2,y:(e.y+i.y)/2};const t=Mg(Ig(i,e)),s={x:t.y,y:-t.x};l={x:s.x*a,y:s.y*a};break}case"right":{h={x:(i.x+s.x)/2,y:(i.y+s.y)/2};const t=Mg(Ig(i,s)),e={x:t.y,y:-t.x};l={x:e.x*a,y:e.y*a};break}case"bottom":{h={x:(n.x+s.x)/2,y:(n.y+s.y)/2};const t=Mg(Ig(n,s)),e={x:-t.y,y:t.x};l={x:e.x*a,y:e.y*a};break}case"left":{h={x:(e.x+n.x)/2,y:(e.y+n.y)/2};const t=Mg(Ig(n,e)),i={x:t.y,y:-t.x};l={x:i.x*a,y:i.y*a};break}default:h={x:(e.x+i.x)/2,y:(e.y+i.y)/2},l={x:0,y:a}}return{x:h.x+l.x,y:h.y+l.y}}calculateSizeTextRotation(){const{points:t}=this.zoneData;if(t.length<4)return 0;const[e,i,s,n]=t,{textPosition:r}=this.zoneConfig;let o,a;switch(r){case"top":default:o=e,a=i;break;case"right":o=i,a=s;break;case"bottom":o=s,a=n;break;case"left":o=n,a=e}return Rg(o,a)}calculateMoveButtonPosition(){const t=this.calculateOutlinePoints();if(t.length<4)return{x:0,y:0};const e=Yi(),{controls:i}=e.getConfig(),s=t[ex.BUTTON_INDICES.MOVE],n=t[2],r=t[0],o=e.getApp().toFixedSize(i.moveButtonOffset);return Og(s,n,r,o)}handleDragStart=()=>{if(!this.isEditingEnabled())return;const t=Yi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-drag",!0)};handleDragMove=t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleDragEnd=()=>{const t=Yi();this.initialZonePoints=[],t.getApp().stopRender("zone-drag"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyTranslation(t,e){this.zoneData.points=this.initialZonePoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawZone(),this.updateControlButtonsPosition()}handleRotationStart=t=>{const e=Yi();this.totalRotationAngle=0,this.rotationCenter=t,this.initialZonePoints=this.zoneData.points.map(t=>({...t})),e.getApp().requestRender("zone-rotate",!0)};handleRotationMove=t=>{this.totalRotationAngle+=t,this.applyRotation(t)};handleRotationEnd=()=>{const t=Yi();this.rotationCenter=null,this.totalRotationAngle=0,this.initialZonePoints=[],t.getApp().stopRender("zone-rotate"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyRotation(t){this.rotationCenter&&(this.zoneData.points=((t,e,i)=>t.map(t=>((t,e,i)=>{const s=Math.cos(i),n=Math.sin(i),r=t.x-e.x,o=t.y-e.y;return{x:r*s-o*n+e.x,y:r*n+o*s+e.y}})(t,e,i)))(this.zoneData.points,this.rotationCenter,t),this.drawZone(),this.updateControlButtonsPosition())}handleScaleStart=()=>{const t=Yi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-scale",!0)};handleScaleMove=t=>{0!==this.initialZonePoints.length&&this.applyEdgeBasedScale(t)};handleScaleEnd=()=>{const t=Yi();this.initialZonePoints=[],t.getApp().stopRender("zone-scale"),this.zoneEvents.onUpdate?.(this.getZoneData())};applyEdgeBasedScale(t){if(this.initialZonePoints.length<4)return;const e=Yi(),{FIXED:i}=ex.BUTTON_INDICES,{x:s,y:n}=this.initialZonePoints[i],[,r,,o]=this.initialZonePoints,a={x:s,y:n},h=Ig(a,r),l=Ig(a,o),c=Ig(a,t),d=Sg(h),u=Sg(l);if(0===d||0===u)return;const p=e.metersToPixels(this.zoneConfig.minSize),[g,f]=[Ag(c,h,d,p),Ag(c,l,u,p)];this.zoneData.points=[a,{x:s+h.x*g,y:n+h.y*g},{x:s+h.x*g+l.x*f,y:n+h.y*g+l.y*f},{x:s+l.x*f,y:n+l.y*f}],this.drawZone(),this.updateControlButtonsPosition()}handleMoveStart=()=>{const t=Yi();this.initialZonePoints=this.zoneData.points.map(t=>({...t})),t.getApp().requestRender("zone-move",!0)};handleMove=t=>{if(!this.isEditingEnabled()||0===this.initialZonePoints.length)return;const e=this.parent.toLocal(t.global),i=this.moveButton?.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleMoveEnd=()=>{const t=Yi();this.initialZonePoints=[],t.getApp().stopRender("zone-move"),this.zoneEvents.onUpdate?.(this.getZoneData())};handleDelete=()=>{this.zoneEvents.onRemove?.(this.zoneData.id)};setupClickHandler(){this.clickHandler=new Ty(this,{onClick:()=>{this.isEditingEnabled()||this.zoneEvents?.onClick?.(this.getZoneData())},stopPropagation:!1})}drawZone(){const{points:t}=this.zoneData;t.length<4||(this.controlFill.updatePoints(t),this.zoneBorder.updatePoints(t),this.updateOutlineBorder(),this.updateMoveLine(),this.updateSizeText())}updateOutlineBorder(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t)}updateMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateSizeText(){if(!this.sizeText)return;const t=this.calculateZoneSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y);const e=this.calculateSizeTextRotation();this.sizeText.rotation=e}updateControlButtonsPosition(){if(!this.deleteButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,ROTATE:i,SCALE:s}=ex.BUTTON_INDICES,n=this.calculateMoveButtonPosition(),r=[{button:this.deleteButton,point:t[e]},{button:this.scaleButton,point:t[s]},{button:this.moveButton,point:n}];this.rotateButton&&r.push({button:this.rotateButton,point:t[i]}),r.forEach(({button:t,point:e})=>t.position.set(e.x,e.y))}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,!t&&this.getCurrentOperationState().hasAnyOperation&&this.stopAllOperations(),this.outlineBorder.visible=t,this.moveLine.visible=t,this.sizeText&&(this.sizeText.visible=t),t&&(this.updateOutlineBorder(),this.updateMoveLine(),this.updateControlButtonsPosition(),this.updateSizeTextPosition()),this.controlFill.setInteractionEnabled(t),this.updateBorderStyle(t?this.zoneConfig.editing:this.zoneConfig.normal),this.zIndex=t?1e3:0}updateBorderStyle(t){this.zoneBorder.updateStyle({isDashed:t.isDashed,dashArray:t.dashArray})}getCurrentOperationState(){const t=this.controlFill.isCurrentlyDragging(),e=this.scaleButton?.isCurrentlyScaling()||!1,i=this.rotateButton?.isCurrentlyRotating()||!1,s=this.moveButton?.isCurrentlyMoving()||!1;return{isDragging:t,isScaling:e,isRotating:i,isMoving:s,hasAnyOperation:t||e||i||s}}stopAllOperations(){this.controlFill.stopDragging(),this.scaleButton?.stopScaling(),this.rotateButton?.stopRotation(),this.moveButton?.stopMoving()}stopDragging(){this.controlFill.stopDragging()}stopScaling(){this.scaleButton?.stopScaling()}stopRotating(){this.rotateButton?.stopRotation()}stopMoving(){this.moveButton?.stopMoving()}isCurrentlyDragging(){return this.controlFill.isCurrentlyDragging()}isCurrentlyScaling(){return this.scaleButton?.isCurrentlyScaling()||!1}isCurrentlyRotating(){return this.rotateButton?.isCurrentlyRotating()||!1}isCurrentlyMoving(){return this.moveButton?.isCurrentlyMoving()||!1}updateZoneData(t){const e=this.validateAndCorrectZoneSize(t.points),i=wg(e);this.zoneData={...t,points:i},this.drawZone(),this.updateControlButtonsPosition(),this.updateEditState()}getZoneData(){return{...this.zoneData}}refreshDisplay(){this.drawZone()}destroy(){Yi().emitter.off("antiScale",this.throttledUpdateOutline),this.clickHandler?.destroy(),this.clickHandler=null,this.deleteButton?.destroy(),this.rotateButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.deleteButton=null,this.rotateButton=null,this.scaleButton=null,this.moveButton=null,this.zoneBorder?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.sizeText?.destroy(),this.controlFill?.destroy(),this.controlButtons?.destroy(),super.destroy()}}class ix extends ex{constructor(t){const e=Yi();super({zoneData:t.zoneData,zoneType:"forbiddenSweepZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenSweepZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenSweepZone?.(t)},onClick:t=>{e.events?.onClickForbiddenSweepZone?.(t)}}})}static create(t){return new ix({zoneData:t})}}class sx extends ex{constructor(t){const e=Yi();super({zoneData:t.zoneData,zoneType:"forbiddenMopZone",events:{onRemove:t=>{e.events?.onRemoveForbiddenMopZone?.(t)},onUpdate:t=>{e.events?.onUpdateForbiddenMopZone?.(t)},onClick:t=>{e.events?.onClickForbiddenMopZone?.(t)}}})}static create(t){return new sx({zoneData:t})}}class nx extends ex{constructor(t){const e=Yi();super({zoneData:t.zoneData,zoneType:"cleanZone",events:{onRemove:t=>{e.events?.onRemoveCleanZone?.(t)},onUpdate:t=>{e.events?.onUpdateCleanZone?.(t)},onClick:t=>{e.events?.onClickCleanZone?.(t)}}})}static create(t){return new nx({zoneData:t})}}class rx extends jl{lineOptions;strokeContext=null;constructor(t){super(),this.lineOptions={...t},this.eventMode="static",this.drawDashLine(),this.setupAntiScaleListener()}setupAntiScaleListener(){Yi().emitter.on("antiScale",this.drawDashLine)}drawDashLine=()=>{const{start:t,end:e,style:i}=this.lineOptions;this.clear(),this.strokeContext&&this.strokeContext.destroy();const s=Yi();this.strokeContext=new fh;const n=s.getApp().toFixedSize(i.width);this.strokeContext.setStrokeStyle({color:i.color,width:n}),this.drawDashedLineToContext(this.strokeContext,t.x,t.y,e.x,e.y,i.dashArray[0],i.dashArray[1]),this.strokeContext.stroke(),this.context=this.strokeContext};drawDashedLineToContext(t,e,i,s,n,r,o){const a=s-e,h=n-i,l=Math.sqrt(a*a+h*h);if(0===l)return;const c=Yi(),d=c.getApp().toFixedSize(r),u=d+c.getApp().toFixedSize(o),p=l/u,g=Math.round(p);if(0===g)return t.moveTo(e,i),void t.lineTo(s,n);const f=l/g,m=f*(d/u),y=a/l,x=h/l;for(let s=0;s<g;s++){const n=s*f,r=n+m;if(n>=l)break;const o=Math.min(r,l),a=e+n*y,h=i+n*x,c=e+o*y,d=i+o*x;t.moveTo(a,h),t.lineTo(c,d)}}updatePoints(t,e){this.lineOptions.start=t,this.lineOptions.end=e,this.drawDashLine()}updateStyle(t){this.lineOptions.style={...this.lineOptions.style,...t},this.drawDashLine()}getOptions(){return{...this.lineOptions}}destroy(){Yi().emitter.off("antiScale",this.drawDashLine),this.strokeContext&&this.strokeContext.destroy(),super.destroy()}}class ox extends Xn{static BUTTON_INDICES={REMOVE:0,SCALE:2,MOVE:3};wallData;wallConfig;controlsConfig;wallEvents;wallLine;outlineBorder;moveLine;lengthText;controlButtons;removeButton=null;scaleButton=null;moveButton=null;initialWallPoints=[];isDragging=!1;dragStartPosition=null;throttledUpdateOutline;throttledHandleScaleChange;wallLineClickHandler=null;constructor(t){super();const{wallData:e,events:i={}}=t;this.wallEvents=i;const s=Yi();this.wallConfig=s.controlsConfig.virtualWall,this.controlsConfig=s.controlsConfig,this.wallData={...e,points:this.validateAndCorrectWallLength(e.points)},this.throttledHandleScaleChange=Ji(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.throttledUpdateOutline=Ji(this.updateOutlineForScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.registerScaleListener(),this.setupDragEventListeners()}validateAndCorrectWallLength(t){const e=Yi();if(t.length<2)return t;const[i,s]=t,n=e.metersToPixels(this.wallConfig.minWidth),r=Cg(i,s);if(r>=n)return t;if(0===r)return[i,{x:i.x+n,y:i.y}];const o=Mg(Ig(i,s));return[i,{x:i.x+o.x*n,y:i.y+o.y*n}]}isEditingEnabled(){return Yi().runtimeSnapshot.editingVirtualWallIds.includes(this.wallData.id)}updateOutlineForScale(){this.isEditingEnabled()&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition())}initializeComponents(){this.outlineBorder=this.createOutlineBorder(),this.addChild(this.outlineBorder),this.createWallLine(!1),this.addChild(this.wallLine),this.lengthText=this.createLengthText(),this.addChild(this.lengthText),this.moveLine=this.createMoveLine(),this.addChild(this.moveLine),this.controlButtons=new Xn,this.controlButtons.visible=this.isEditingEnabled(),this.addChild(this.controlButtons),this.createControlButtons()}createWallLine(t=!0){const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:s,editing:n,normal:r}=this.wallConfig,o=this.isEditingEnabled()?n:r;o.isDashed?this.wallLine=new rx({start:e[0],end:e[1],style:{color:s.toString(),width:i,dashArray:o.dashArray}}):this.wallLine=this.createSolidLine(e[0],e[1],i,s.toString()),t&&this.setupWallLineInteraction()}createLengthText(){const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t),i=new tx({text:e,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.wallConfig.textColor,align:"center"}});i.anchor.set(.5);const s=this.calculateTextPosition();i.position.set(s.x,s.y);const n=this.calculateTextRotation();return i.rotation=n,i.eventMode="none",i}calculateWallLengthInMeters(){const t=Yi(),{points:e}=this.wallData;if(e.length<2)return 0;const i=Cg(e[0],e[1]);return t.pixelsToMeters(i)}formatLengthText(t){const e=Yi(),i=e.metersToDisplayUnit(t),s=e.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}`}calculateTextPosition(){const t=Yi(),{points:e}=this.wallData;if(e.length<2)return{x:0,y:0};const[i,s]=e;return((t,e,i)=>{const s=_g([t,e]),n=Eg(t,e);return{x:s.x+n.x*i,y:s.y+n.y*i}})(i,s,t.getApp().toFixedSize(this.wallConfig.textOffset))}calculateTextRotation(){const{points:t}=this.wallData;if(t.length<2)return 0;const[e,i]=t;return Rg(e,i)}getOutlineStyle(){return{color:this.wallConfig.outlineStrokeColor,width:this.wallConfig.outlineStrokeWidth,isDashed:this.wallConfig.outlineDashed,dashArray:this.wallConfig.outlineDashArray,fillColor:this.wallConfig.outlineFillColor}}createOutlineBorder(){const t=this.calculateOutlinePoints();return new $y({points:t,closePath:!0,style:this.getOutlineStyle()})}createMoveLine(){const t=this.calculateOutlinePoints(),e=this.calculateMoveLinePoints(t);return new $y({points:e,closePath:!1,style:this.getOutlineStyle()})}calculateOutlinePoints(t){const e=Yi(),i=t||this.wallData.points;if(i.length<2)return i;const s=e.getApp().toFixedSize(this.wallConfig.outlineOffset),n=((t,e,i)=>{if(0===Cg(t,e))return[t,t,t,t];const s=Tg(t,e),n=Pg(s),r=t.x-s.x*i,o=t.y-s.y*i,a=e.x+s.x*i,h=e.y+s.y*i;return[{x:r+n.x*i,y:o+n.y*i},{x:a+n.x*i,y:h+n.y*i},{x:a-n.x*i,y:h-n.y*i},{x:r-n.x*i,y:o-n.y*i}]})(i[0],i[1],s);return[n[3],n[2],n[1],n[0]]}calculateMoveLinePoints(t){if(t.length<4)return[];const{MOVE:e}=ox.BUTTON_INDICES;return[t[e],this.calculateMoveButtonPosition()]}calculateMoveButtonPosition(){const t=Yi(),{moveButtonOffset:e}=this.controlsConfig,i=this.calculateOutlinePoints();if(i.length<4)return{x:0,y:0};const{MOVE:s}=ox.BUTTON_INDICES,n=i[s],r=i[(s+3)%4],o=i[(s+1)%4],a=t.getApp().toFixedSize(e);return Og(n,o,r,a)}createControlButtons(){const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=ox.BUTTON_INDICES;this.removeButton=new Yy({iconAlias:"deleteIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onClick:this.handleRemove}),this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton=new Ky({iconAlias:"scaleIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,getTargetPoints:()=>this.calculateOutlinePoints(),getButtonIndex:()=>i,onScaleStart:this.handleScaleStart,onScaleMove:this.handleScaleMove,onScaleEnd:this.handleScaleEnd}),this.scaleButton.position.set(t[i].x,t[i].y);const s=this.calculateMoveButtonPosition();this.moveButton=new Qy({iconAlias:"moveIcon",backgroundColor:this.wallConfig.iconWrapperFillColor,onMoveStart:this.handleMoveStart,onMoveMove:this.handleMove,onMoveEnd:this.handleMoveEnd}),this.moveButton.position.set(s.x,s.y),this.controlButtons.addChild(this.removeButton),this.controlButtons.addChild(this.scaleButton),this.controlButtons.addChild(this.moveButton)}handleRemove=()=>{this.wallEvents.onRemove?.(this.wallData.id)};initializeOperation=()=>{this.initialWallPoints=this.wallData.points.map(t=>({...t}))};finalizeOperation=()=>{this.initialWallPoints=[],this.wallEvents.onUpdate?.(this.getWallData())};handleScaleStart=()=>{const t=Yi();this.initializeOperation(),t.getApp().requestRender("virtualwall-scale",!0)};handleScaleMove=t=>{0!==this.initialWallPoints.length&&this.applyScaleAndRotation(t)};handleScaleEnd=()=>{const t=Yi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-scale")};handleMoveStart=()=>{const t=Yi();this.initializeOperation(),t.getApp().requestRender("virtualwall-move",!0)};handleMove=t=>{if(0===this.initialWallPoints.length)return;const e=this.parent.toLocal(t.global),i=this.getDragStartPosition()||this.moveButton?.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleMoveEnd=()=>{const t=Yi();this.finalizeOperation(),t.getApp().stopRender("virtualwall-move")};applyScaleAndRotation(t){const e=Yi();if(this.initialWallPoints.length<2)return;const[i,s]=this.initialWallPoints,n=i,r=this.calculateOutlinePoints(this.initialWallPoints);if(r.length<4)return;const o=r[ox.BUTTON_INDICES.SCALE],a=Ig(s,o),h={x:t.x-a.x,y:t.y-a.y},l=Ig(n,h),c=Cg(n,h),d=e.metersToPixels(this.wallConfig.minWidth);let u;if(c<d)if(0===c)u={x:n.x+d,y:n.y};else{const t=Mg(l);u={x:n.x+t.x*d,y:n.y+t.y*d}}else u=h;this.wallData.points=[n,u],this.drawVirtualWall(),this.updateControlButtonsPosition()}applyTranslation(t,e){this.wallData.points=this.initialWallPoints.map(i=>({x:i.x+t,y:i.y+e})),this.drawVirtualWall(),this.updateControlButtonsPosition()}drawVirtualWall(){this.updateWallLine(),this.updateLengthText(),this.updateOutlineComponents()}updateWallLine(){const{points:t}=this.wallData;t.length<2||(this.wallLine instanceof rx?this.wallLine.updatePoints(t[0],t[1]):this.redrawSolidLine(),this.setupWallLineHitArea())}updateLengthText(){if(!this.lengthText)return;const t=this.calculateWallLengthInMeters(),e=this.formatLengthText(t);this.lengthText.updateText(e),this.updateLengthTextPosition()}updateLengthTextPosition(){if(!this.lengthText)return;const t=this.calculateTextPosition();this.lengthText.position.set(t.x,t.y);const e=this.calculateTextRotation();this.lengthText.rotation=e}updateOutlineComponents(){const t=this.calculateOutlinePoints();this.outlineBorder.updatePoints(t);const e=this.calculateMoveLinePoints(t);this.moveLine.updatePoints(e)}updateControlButtonsPosition(){if(!this.removeButton||!this.scaleButton||!this.moveButton)return;const t=this.calculateOutlinePoints();if(t.length<4)return;const{REMOVE:e,SCALE:i}=ox.BUTTON_INDICES,s=this.calculateMoveButtonPosition();this.removeButton.position.set(t[e].x,t[e].y),this.scaleButton.position.set(t[i].x,t[i].y),this.moveButton.position.set(s.x,s.y)}updateEditState(){const t=this.isEditingEnabled();this.controlButtons.visible=t,this.outlineBorder.visible=t,this.moveLine.visible=t,this.lengthText&&(this.lengthText.visible=t),t&&(this.updateOutlineComponents(),this.updateControlButtonsPosition(),this.updateLengthTextPosition()),this.updateWallLineStyle(),this.setupWallLineInteraction(),this.zIndex=t?1e3:0}createSolidLine(t,e,i,s){const n=Yi(),r=new jl;r.eventMode="static";const o=n.getApp().toFixedSize(i);return r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.stroke({color:s,width:o}),r}updateWallLineStyle(){const t=this.isEditingEnabled(),{editing:e,normal:i,lineWidth:s,lineColor:n}=this.wallConfig,r=t?e:i;this.wallLine instanceof rx!==r.isDashed?(this.removeChild(this.wallLine),this.wallLine.destroy(),this.createWallLine(!1),this.addChild(this.wallLine)):this.wallLine instanceof rx?this.wallLine.updateStyle({color:n.toString(),width:s,dashArray:r.dashArray}):this.redrawSolidLine()}registerScaleListener(){const{emitter:t}=Yi();t.on("antiScale",this.throttledUpdateOutline),t.on("antiScale",this.throttledHandleScaleChange)}redrawSolidLine(){const t=Yi();if(!this.wallLine||this.wallLine instanceof rx)return;const{points:e}=this.wallData;if(e.length<2)return;const{lineWidth:i,lineColor:s}=this.wallConfig,n=t.getApp().toFixedSize(i);this.wallLine.clear(),this.wallLine.setStrokeStyle({color:s.toString(),width:n}).moveTo(e[0].x,e[0].y).lineTo(e[1].x,e[1].y).stroke()}handleScaleChange=()=>{this.redrawSolidLine(),this.setupWallLineHitArea()};setupWallLineInteraction(){if(!this.wallLine)return;this.setupWallLineHitArea();const t=this.isEditingEnabled();this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine.off("pointerdown",this.handleWallLinePointerDown),t?this.wallLine.on("pointerdown",this.handleWallLinePointerDown):this.wallLineClickHandler=new Ty(this.wallLine,{onClick:()=>{Yi().emitter.emit("suppressMapClick"),this.wallEvents?.onClick?.(this.getWallData())},stopPropagation:!1})}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handleWallLinePointerDown=t=>{this.isEditingEnabled()&&(t.stopPropagation(),this.startDragging(t))};startDragging(t){const e=Yi();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initializeOperation(),e.getApp().requestRender("virtualwall-drag",!0),Yi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{this.isDragging&&this.dragStartPosition&&this.handleMove(t)};handleDragPointerUp=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.finalizeOperation())};handleDragCancel=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("virtualwall-drag"),this.handleMoveEnd())};getDragStartPosition(){return this.dragStartPosition}setupWallLineHitArea(){const t=Yi();if(!this.wallLine)return;const{points:e}=this.wallData;if(e.length<2)return;const{hitAreaThickness:i}=this.wallConfig,s=t.getApp().toFixedSize(i),n=kg(e[0],e[1],s);if(0===n.length)return;const r=new $o(n);this.wallLine.hitArea=r}getWallData(){return{...this.wallData}}updateWallData(t){this.wallData={...t,points:this.validateAndCorrectWallLength(t.points)},this.drawVirtualWall(),this.updateControlButtonsPosition()}updateEditingState(){this.updateEditState()}refreshDisplay(){this.drawVirtualWall()}destroy(){Yi().emitter.off("antiScale",this.throttledUpdateOutline),Yi().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.wallLine&&this.wallLine.off("pointerdown",this.handleWallLinePointerDown),this.wallLineClickHandler?.destroy(),this.wallLineClickHandler=null,this.wallLine?.destroy(),this.lengthText?.destroy(),this.outlineBorder?.destroy(),this.moveLine?.destroy(),this.controlButtons?.destroy(),this.removeButton?.destroy(),this.scaleButton?.destroy(),this.moveButton?.destroy(),this.removeButton=null,this.scaleButton=null,this.moveButton=null,super.destroy()}}class ax extends Xn{spotData;spotConfig;controlsConfig;spotEvents;controlFill;spotBorder;centerIcon;sizeText;clickHandler=null;initialSpotPoint=null;throttledUpdateScale;constructor(t){super();const{spotData:e,events:i={}}=t,s=Yi();this.spotData=e,this.spotEvents=i,this.controlsConfig=s.controlsConfig,this.spotConfig=s.controlsConfig.spot,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.updateEditState(),this.setupClickHandler(),this.registerScaleListener()}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}updateScale(){this.isEditingEnabled()&&this.sizeText&&this.updateSizeTextPosition()}isEditingEnabled(){return Yi().runtimeSnapshot.editingSpotIds.includes(this.spotData.id)}shouldShowIcon(){return(this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal).showIcon}calculateRectanglePoints(){const t=Yi(),{point:e}=this.spotData,{size:i}=this.spotConfig;if(0===i)return[e,e,e,e];const s=t.metersToPixels(i)/2;return[{x:e.x-s,y:e.y-s},{x:e.x+s,y:e.y-s},{x:e.x+s,y:e.y+s},{x:e.x-s,y:e.y+s}]}initializeComponents(){const t=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill=this.createControlFill(t),this.addChild(this.controlFill),this.spotBorder=this.createBorder(t),this.addChild(this.spotBorder)),this.centerIcon=this.createCenterIcon(),this.addChild(this.centerIcon),this.spotConfig.showText&&(this.sizeText=this.createSizeText(),this.addChild(this.sizeText)),this.drawSpot()}createControlFill(t){const e=this.isEditingEnabled();return new qy({points:t,fillColor:this.spotConfig.fillColor,enableInteraction:e,onDragStart:this.handleDragStart,onDragMove:this.handleDragMove,onDragEnd:this.handleDragEnd})}createBorder(t){const e=this.isEditingEnabled()?this.spotConfig.editing:this.spotConfig.normal;return new $y({points:t,closePath:!0,style:{color:this.spotConfig.strokeColor,width:this.spotConfig.strokeWidth,isDashed:e.isDashed,dashArray:e.dashArray}})}createCenterIcon(){const t=new Ry;return this.loadIconTexture(t),t.position.set(this.spotData.point.x,this.spotData.point.y),t.eventMode=0===this.spotConfig.size?"static":"none",0===this.spotConfig.size&&this.setupIconDrag(t),t.visible=!1,t}async loadIconTexture(t){const{iconSize:e}=this.spotConfig;await t.loadTextureAndSetSize("spotIcon",{width:e,height:e,sizeFixed:!1}),t.visible=this.shouldShowIcon()}setupIconDrag(t){let e=null,i=!1;const s=t=>{if(!i||!this.initialSpotPoint||!e)return;const s=this.parent.toLocal(t.global),n=s.x-e.x,r=s.y-e.y;this.applyTranslation(n,r)},n=()=>{if(!i)return;const t=Yi();i=!1,this.initialSpotPoint=null,e=null,t.getApp().stopRender("spot-drag"),t.emitter.off("gestureHijackPointerMove",s),t.emitter.off("gestureHijackPointerUp",r),t.emitter.off("gestureHijackCancel",n)},r=()=>{if(!i)return;const t=Yi();i=!1,this.initialSpotPoint=null,e=null,t.getApp().stopRender("spot-drag"),this.spotEvents.onUpdate?.(this.getSpotData()),t.emitter.off("gestureHijackPointerMove",s),t.emitter.off("gestureHijackPointerUp",r),t.emitter.off("gestureHijackCancel",n)};t.on("pointerdown",t=>{if(!this.isEditingEnabled())return;t.stopPropagation();const o=Yi();i=!0,this.initialSpotPoint={...this.spotData.point},e=this.parent.toLocal(t.global),o.getApp().requestRender("spot-drag",!0),o.emitter.emit("gestureHijackStart",t),o.emitter.on("gestureHijackPointerMove",s),o.emitter.on("gestureHijackPointerUp",r),o.emitter.on("gestureHijackCancel",n)})}createSizeText(){const t=this.calculateSpotSizeText(),e=new tx({text:t,style:{fontSize:this.controlsConfig.textFontSize,fontFamily:this.controlsConfig.textFontFamily,fontWeight:this.controlsConfig.textFontWeight,fill:this.spotConfig.textColor,align:"center"}});e.anchor.set(.5);const i=this.calculateSizeTextPosition();return e.position.set(i.x,i.y),e.eventMode="none",e}calculateSpotSizeText(){const t=Yi(),{size:e}=this.spotConfig,i=t.metersToDisplayUnit(e),s=t.runtimeSnapshot.unitLabel;return`${i.toFixed(1)}${s}*${i.toFixed(1)}${s}`}calculateSizeTextPosition(){const t=Yi(),e=this.calculateRectanglePoints();if(e.length<4)return{x:0,y:0};const[i,s,n,r]=e,{textPosition:o,textOffset:a}=this.spotConfig,h=t.getApp().toFixedSize(a);let l,c;switch(o){case"top":default:l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},c={x:l.x,y:l.y+h};break;case"right":l={x:(s.x+n.x)/2,y:(s.y+n.y)/2},c={x:l.x+h,y:l.y};break;case"bottom":l={x:(r.x+n.x)/2,y:(r.y+n.y)/2},c={x:l.x,y:l.y+h};break;case"left":l={x:(i.x+r.x)/2,y:(i.y+r.y)/2},c={x:l.x-h,y:l.y}}return c}handleDragStart=()=>{const t=Yi();this.isEditingEnabled()&&(this.initialSpotPoint={...this.spotData.point},t.getApp().requestRender("spot-drag",!0))};handleDragMove=t=>{if(!this.isEditingEnabled()||!this.initialSpotPoint)return;if(!this.controlFill)return;const e=this.parent.toLocal(t.global),i=this.controlFill.getDragStartPosition();if(!i)return;const s=e.x-i.x,n=e.y-i.y;this.applyTranslation(s,n)};handleDragEnd=()=>{const t=Yi();this.initialSpotPoint=null,t.getApp().stopRender("spot-drag"),this.spotEvents.onUpdate?.(this.getSpotData())};applyTranslation(t,e){this.initialSpotPoint&&(this.spotData.point={x:this.initialSpotPoint.x+t,y:this.initialSpotPoint.y+e},this.drawSpot())}setupClickHandler(){const t=this.spotConfig.size>0?this:this.centerIcon;this.clickHandler=new Ty(t,{onClick:()=>{this.isEditingEnabled()||(Yi().emitter.emit("suppressMapClick"),this.spotEvents?.onClick?.(this.getSpotData()))},stopPropagation:!1})}drawSpot(){const t=this.calculateRectanglePoints();this.spotConfig.size>0&&(this.controlFill&&this.controlFill.updatePoints(t),this.spotBorder&&this.spotBorder.updatePoints(t)),this.centerIcon.position.set(this.spotData.point.x,this.spotData.point.y),this.spotConfig.showText&&this.sizeText&&this.updateSizeText()}updateSizeText(){if(!this.sizeText)return;const t=this.calculateSpotSizeText();this.sizeText.updateText(t),this.updateSizeTextPosition()}updateSizeTextPosition(){if(!this.sizeText)return;const t=this.calculateSizeTextPosition();this.sizeText.position.set(t.x,t.y)}updateEditState(){const t=this.isEditingEnabled(),e=t?this.spotConfig.editing:this.spotConfig.normal;this.sizeText&&(this.sizeText.visible=t&&this.spotConfig.showText),this.centerIcon&&(this.centerIcon.visible=this.shouldShowIcon()),this.controlFill&&this.controlFill.setInteractionEnabled(t),this.spotBorder&&this.spotBorder.updateStyle({isDashed:e.isDashed,dashArray:e.dashArray}),this.zIndex=t?1e3:0}updateSpotData(t){this.spotData={...t},this.drawSpot(),this.updateEditState()}getSpotData(){return{...this.spotData}}refreshDisplay(){this.drawSpot()}destroy(){Yi().emitter.off("antiScale",this.throttledUpdateScale),this.clickHandler?.destroy(),this.clickHandler=null,this.centerIcon&&0===this.spotConfig.size&&this.centerIcon.removeAllListeners(),this.controlFill?.destroy(),this.spotBorder?.destroy(),this.centerIcon?.destroy(),this.sizeText?.destroy(),super.destroy()}static create(t){const e=Yi();return new ax({spotData:t,events:{onUpdate:t=>{e.events?.onUpdateSpot?.(t)},onClick:t=>{e.events?.onClickSpot?.(t)}}})}}class hx extends Jy{wayPointData;order;wayPointConfig;controlsConfig;wayPointEvents;icon;orderContainer;orderBackground;orderText;clickHandler=null;initialWayPointPoint=null;constructor(t){super();const{wayPointData:e,order:i,events:s={}}=t,n=Yi();this.wayPointData=e,this.order=i,this.wayPointEvents=s,this.controlsConfig=n.controlsConfig,this.wayPointConfig=n.controlsConfig.wayPoint,this.position.set(e.point.x,e.point.y),this.initializeComponents(),this.updateEditState(),this.setupClickHandler()}isEditingEnabled(){return(Yi().runtimeSnapshot.editingWayPointIds||[]).includes(this.wayPointData.id)}initializeComponents(){this.icon=this.createIcon(),this.addChild(this.icon),this.wayPointConfig.showOrder&&(this.createOrderContainer(),this.addChild(this.orderContainer))}createIcon(){const t=new Ry;return this.loadIconTexture(t),t.position.set(0,0),t.anchor.set(.5,1),t.eventMode="static",this.setupIconDrag(t),t}async loadIconTexture(t){const e=this.isEditingEnabled(),i=e?this.wayPointConfig.editing:this.wayPointConfig.normal,{iconSize:s}=i,n=e?"wayPointActive":"wayPoint";await t.loadTextureAndSetSize(n,{width:s,height:s,sizeFixed:!1}),t.visible=!0,this.orderContainer&&this.updateOrderPosition()}createOrderContainer(){const t=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{orderContainer:e,orderText:i}=t;this.orderContainer=new Xn,this.orderBackground=new jl,this.orderText=new Ql({text:this.order.toString(),style:new yh({fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWeight,fill:i.color,align:"center",trim:!0})}),this.orderBackground.clear(),this.orderBackground.circle(0,0,e.size/2),this.orderBackground.fill({color:e.backgroundColor}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.orderContainer.eventMode="none",this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}updateOrderPosition(){if(!this.orderContainer)return;const t=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal,{offsetX:e,offsetY:i}=t.orderContainer;this.orderContainer.position.set(e,-i)}setupIconDrag(t){let e=null,i=null,s=!1;const n=t=>{if(s&&e&&i&&this.parent){const s=this.parent.toLocal(t.global),n=s.x-e.x,r=s.y-e.y,o={x:i.x+n,y:i.y+r};this.wayPointData.point=o,this.position.set(o.x,o.y),this.orderContainer&&this.updateOrderPosition()}},r=()=>{if(!s)return;s=!1,e=null,i=null;const t=Yi();this.wayPointEvents.onUpdate?.(this.wayPointData),t.emitter.off("gestureHijackPointerMove",n),t.emitter.off("gestureHijackPointerUp",r),t.emitter.emit("gestureHijackCancel")};t.on("pointerdown",t=>{if(!this.isEditingEnabled())return;t.stopPropagation();const o=Yi();i={...this.wayPointData.point},this.parent&&(e=this.parent.toLocal(t.global)),s=!0,this.parent&&(o.emitter.emit("gestureHijackStart",t),o.emitter.on("gestureHijackPointerMove",n),o.emitter.on("gestureHijackPointerUp",r))})}setupClickHandler(){this.clickHandler=new Ty(this.icon,{stopPropagation:!1,onClick:()=>{Yi().emitter.emit("suppressMapClick"),this.wayPointEvents.onClick?.(this.wayPointData)}})}updateWayPoint(t){this.wayPointData=t,this.drawWayPoint()}updateOrder(t){this.order=t,this.orderText&&(this.orderText.text=t.toString())}getWayPointData(){return{...this.wayPointData}}drawWayPoint(){this.position.set(this.wayPointData.point.x,this.wayPointData.point.y),this.orderContainer&&this.updateOrderPosition()}updateEditState(){if(this.loadIconTexture(this.icon),this.orderContainer&&this.orderText&&this.orderBackground){const t=this.isEditingEnabled()?this.wayPointConfig.editing:this.wayPointConfig.normal;this.orderText.style=new yh({fontSize:t.orderText.fontSize,fontFamily:t.orderText.fontFamily,fontWeight:t.orderText.fontWeight,fill:t.orderText.color,align:"center",trim:!0});const{size:e,backgroundColor:i}=t.orderContainer;this.orderBackground.clear(),this.orderBackground.circle(0,0,e/2).fill(i),this.orderContainer.visible=this.wayPointConfig.showOrder,this.updateOrderPosition()}}onEditStateChange(){this.updateEditState()}destroy(){this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.icon&&this.icon.removeAllListeners(),super.destroy()}}class lx extends jl{constructor(t){super(),this.options=t,this.initialPosition={...t.position},this.position.set(t.position.x,t.position.y),this.eventMode="static",this.cursor="pointer",this.setupEvents(),this.draw(),this.setupDragEventListeners()}isDragging=!1;dragStartPosition=null;initialPosition;draw(){const t=Yi(),{config:e}=this.options,i=t.getApp().toFixedSize(e.endPointSize),s=t.getApp().toFixedSize(e.endPointStrokeWidth);this.clear(),this.circle(0,0,i/2),this.fill({color:e.endPointColor}),this.stroke({color:e.endPointStrokeColor,width:s}),this.setupHitArea()}setupHitArea(){const t=Yi(),{config:e}=this.options,i=Math.max(e.endPointSize/2+10,20),s=t.getApp().toFixedSize(i);this.hitArea=new Qo(0,0,s)}setupEvents(){this.on("pointerdown",this.handlePointerDown.bind(this))}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handlePointerDown(t){t.stopPropagation(),this.startDragging(t)}startDragging(t){const e=Yi();this.isDragging=!0,this.dragStartPosition=this.parent.toLocal(t.global),this.initialPosition={x:this.x,y:this.y},this.options.onDragStart?.(),e.getApp().requestRender("endpoint-drag",!0),Yi().emitter.emit("gestureHijackStart",t)}handleDragPointerMove=t=>{if(!this.isDragging||!this.dragStartPosition)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,s=e.y-this.dragStartPosition.y,n={x:this.initialPosition.x+i,y:this.initialPosition.y+s};this.position.set(n.x,n.y),this.options.onDragMove?.(n)};handleDragPointerUp=()=>{if(!this.isDragging)return;const t=Yi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};handleDragCancel=()=>{if(!this.isDragging)return;const t=Yi();this.isDragging=!1,this.dragStartPosition=null,t.getApp().stopRender("endpoint-drag"),this.options.onDragEnd?.()};updatePosition(t){this.position.set(t.x,t.y),this.initialPosition={...t}}getPosition(){return{x:this.x,y:this.y}}redraw(){this.draw()}destroy(){this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null),this.cleanupDragEventListeners(),this.off("pointerdown",this.handlePointerDown),super.destroy()}}class cx extends Xn{endPoints;dividerConfig;dividerEvents;roomId;roomGeometry=null;dashLine;solidLine=null;startEndPoint;endEndPoint;solidLinePoints=null;initialDividerPoints=[];isDragging=!1;dragStartPosition=null;throttledHandleScaleChange;constructor(t){super();const{endPoints:e,roomId:i,events:s={}}=t;this.dividerEvents=s,this.roomId=i;const n=Yi();this.dividerConfig=n.dividerConfig,this.roomGeometry=n.mapManager.getRoomById(this.roomId)||null,this.endPoints=e?this.validateDividerPoints(e):this.createDefaultdividerPoints(),this.throttledHandleScaleChange=Ji(this.handleScaleChange.bind(this),30,{leading:!0,trailing:!0}),this.initializeComponents(),this.calculateAndCreateSolidLine(),this.registerScaleListener(),this.setupDragEventListeners()}validateDividerPoints(t){if(t.length>=2)return t.slice(0,2);const e=t[0]||{x:0,y:0};return[e,{x:e.x+50,y:e.y}]}createDefaultdividerPoints(){if(!this.roomGeometry)return ag.warn("Room geometry not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const t=Yi(),e=t.getApp().mapState;if(!e)return ag.warn("Map state not available, creating fallback divider"),[{x:0,y:0},{x:100,y:0}];const{boundingBox:i}=this.roomGeometry,s=t.getApp().toFixedSize(this.dividerConfig.defaultExtension),n=this.dividerConfig.defaultDirection,r=i.x+i.width/2,o=i.y+i.height/2,a="horizontal"===n?i.width+2*s:i.height+2*s;return jg(r,o,a,n).map(t=>({x:t.x-e.origin.x,y:t.y-e.origin.y}))}initializeComponents(){this.createDashLine(),this.addChild(this.dashLine),this.createEndPoints(),this.addChild(this.startEndPoint),this.addChild(this.endEndPoint),this.setupDashLineInteraction()}createDashLine(){const t=this.endPoints;if(t.length<2)return;const{dashLineWidth:e,dashLineDashArray:i,lineColor:s}=this.dividerConfig;this.dashLine=new rx({start:t[0],end:t[1],style:{color:s.toString(),width:e,dashArray:i}})}createEndPoints(){const t=this.endPoints;this.startEndPoint=new lx({position:t[0],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(0,t),onDragEnd:this.handleEndPointDragEnd}),this.endEndPoint=new lx({position:t[1],config:this.dividerConfig,onDragStart:this.handleEndPointDragStart,onDragMove:t=>this.handleEndPointDragMove(1,t),onDragEnd:this.handleEndPointDragEnd})}setupDashLineInteraction(){this.dashLine&&(this.setupDashLineHitArea(),this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.dashLine.on("pointerdown",this.handleDashLinePointerDown))}setupDashLineHitArea(){const t=Yi();if(!this.dashLine)return;const e=this.endPoints;if(e.length<2)return;const{hitAreaThickness:i}=this.dividerConfig,s=t.getApp().toFixedSize(i),n=kg(e[0],e[1],s);if(0===n.length)return;const r=new $o(n);this.dashLine.hitArea=r}handleEndPointDragStart=()=>{const t=Yi();this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),t.getApp().requestRender("divider-endpoint-drag",!0)};handleEndPointDragMove=(t,e)=>{0!==this.initialDividerPoints.length&&(this.endPoints[t]=e,this.updateDashLine(),this.updateSolidLine(),this.setupDashLineHitArea())};handleEndPointDragEnd=()=>{const t=Yi();this.initialDividerPoints=[],t.getApp().stopRender("divider-endpoint-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints())};handleDashLinePointerDown=t=>{t.stopPropagation(),this.startDragging(t)};startDragging(t){const e=Yi();this.isDragging=!0;const i=this.parent.toLocal(t.global);this.dragStartPosition={x:i.x,y:i.y},this.initialDividerPoints=this.endPoints.map(t=>({...t})),this.clearSolidLine(),e.getApp().requestRender("divider-drag",!0),Yi().emitter.emit("gestureHijackStart",t)}setupDragEventListeners(){const{emitter:t}=Yi();t.on("gestureHijackPointerMove",this.handleDragPointerMove),t.on("gestureHijackPointerUp",this.handleDragPointerUp),t.on("gestureHijackCancel",this.handleDragCancel)}cleanupDragEventListeners(){const{emitter:t}=Yi();t.off("gestureHijackPointerMove",this.handleDragPointerMove),t.off("gestureHijackPointerUp",this.handleDragPointerUp),t.off("gestureHijackCancel",this.handleDragCancel)}handleDragPointerMove=t=>{if(!this.isDragging||!this.dragStartPosition||0===this.initialDividerPoints.length)return;const e=this.parent.toLocal(t.global),i=e.x-this.dragStartPosition.x,s=e.y-this.dragStartPosition.y;this.endPoints=this.initialDividerPoints.map(t=>({x:t.x+i,y:t.y+s})),this.updateAllComponents()};handleDragPointerUp=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};handleDragCancel=()=>{const t=Yi();this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[],t.getApp().stopRender("divider-drag"),this.calculateAndCreateSolidLine(),this.checkAndResetIfOutOfRoom(),this.dividerEvents.onUpdate?.(this.getDividerEndPoints()))};updateAllComponents(){this.updateDashLine(),this.updateSolidLine(),this.updateEndPoints(),this.setupDashLineHitArea()}updateDashLine(){const t=this.endPoints;t.length<2||!this.dashLine||this.dashLine.updatePoints(t[0],t[1])}updateSolidLine(){if(!this.solidLine||!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:e}=this.dividerConfig,i=Yi().getApp().toFixedSize(t);this.solidLine.clear(),this.solidLine.setStrokeStyle({color:e.toString(),width:i}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke()}updateEndPoints(){const t=this.endPoints;this.startEndPoint&&this.startEndPoint.updatePosition(t[0]),this.endEndPoint&&this.endEndPoint.updatePosition(t[1])}registerScaleListener(){const{emitter:t}=Yi();t.on("antiScale",this.throttledHandleScaleChange)}handleScaleChange=()=>{this.startEndPoint?.redraw(),this.endEndPoint?.redraw(),this.updateSolidLine(),this.setupDashLineHitArea()};getDividerEndPoints(){return[...this.endPoints]}getEffectiveDividerPoints(){return this.solidLinePoints?[...this.solidLinePoints]:null}calculateAndCreateSolidLine(){if(this.clearSolidLine(),"number"!=typeof this.roomId)return;if(!this.getRoomGraphics())return;const t=this.calculateLineRoomIntersection();t&&t.length>=2&&(this.solidLinePoints=[t[0],t[t.length-1]],this.createSolidLine())}getRoomGraphics(){const t=Yi().mapManager.roomFill;return t&&"number"==typeof this.roomId&&t.getRoomGraphicsMap().get(this.roomId)||null}calculateLineRoomIntersection(){const t=this.endPoints;if(t.length<2)return null;if("number"!=typeof this.roomId)return null;const[e,i]=t,s=this.isPointInRoomFill(e),n=this.isPointInRoomFill(i);if(s||n)return null;const r=((t,e,i=1,s=2e3)=>{const n=[],r=e.x-t.x,o=e.y-t.y,a=Math.sqrt(r*r+o*o);if(0===a)return[t];const h=Math.min(Math.max(Math.ceil(a/i),2),s);for(let e=0;e<=h;e++){const i=e/h,s={x:t.x+i*r,y:t.y+i*o};n.push(s)}return n})(e,i),o=[];for(const t of r)this.isPointInRoomFill(t)&&o.push(t);if(0===o.length)return null;const a=o[0],h=o[o.length-1];if(Cg(a,h)<3)return null;const l=((t,e,i)=>{const s=e.x-t.x,n=e.y-t.y,r=Math.sqrt(s*s+n*n);if(0===r)return[t,e];const o=s/r,a=n/r;return[{x:t.x-o*i,y:t.y-a*i},{x:e.x+o*i,y:e.y+a*i}]})(a,h,.5);return l}isPointInRoomFill(t){if("number"!=typeof this.roomId)return!1;const e=Yi().getApp().mapState;if(!e)return!1;const i={x:t.x+e.origin.x,y:t.y+e.origin.y};return"raster"===e.mapType?this.isPointInRasterRoomFill(i):this.isPointInStructuredRoomFill(i)}isPointInRasterRoomFill(t){t.x-=.5,t.y-=.5;const e=Yi(),i=e.getApp().mapState,s=e.mapManager.roomFill;if(!i||!s)return!1;const n=s.getRasterRoomData(this.roomId);if(!n)return!1;const r=s.getMapWidth();if(0===r)return!1;const o=Math.round(t.y)*r+Math.round(t.x);for(let t=0;t<n.pixelIndices.length;t++)if(n.pixelIndices[t]===o)return!0;return!1}isPointInStructuredRoomFill(t){const e={x:Math.round(t.x),y:Math.round(t.y)},i=Yi(),s=i.getApp().mapState,n=i.mapManager.getRoomById(this.roomId);return!!(s&&n&&n.outlinePoints)&&yg(e,n.outlinePoints,!0)}isDividerCompletelyOutOfRoom(){if(!this.roomGeometry)return!1;const{boundingBox:t}=this.roomGeometry,e=this.endPoints;if(e.length<2)return!1;const i=Yi().getApp().mapState;return!!i&&!((t,e,i,s,n,r)=>{const o=i+n,a=s+r,h=Math.min(t.x,e.x),l=Math.max(t.x,e.x),c=Math.min(t.y,e.y),d=Math.max(t.y,e.y);if(l<i||h>o||d<s||c>a)return!1;if(Lg(t,i,s,n,r)||Lg(e,i,s,n,r))return!0;const u=[{x:i,y:s},{x:o,y:s},{x:o,y:a},{x:i,y:a}];for(let i=0;i<4;i++)if(Dg(t,e,u[i],u[(i+1)%4]))return!0;return!1})({x:e[0].x+i.origin.x,y:e[0].y+i.origin.y},{x:e[1].x+i.origin.x,y:e[1].y+i.origin.y},t.x,t.y,t.width,t.height)}checkAndResetIfOutOfRoom(){const t=Yi(),{resetDividerWhenOutOfRoom:e}=t.dividerConfig;e&&this.isDividerCompletelyOutOfRoom()&&this.resetToDefaultState()}resetToDefaultState(){this.endPoints=this.createDefaultdividerPoints(),this.calculateAndCreateSolidLine(),this.updateComponents(),this.dividerEvents.onUpdate?.(this.endPoints)}updateComponents(){const t=this.endPoints;t.length>=2&&(this.dashLine.updatePoints(t[0],t[1]),this.startEndPoint.position.set(t[0].x,t[0].y),this.endEndPoint.position.set(t[1].x,t[1].y),this.setupDashLineInteraction())}createSolidLine(){if(!this.solidLinePoints)return;const{solidLineWidth:t,lineColor:e}=this.dividerConfig,i=Yi();this.solidLine=new jl,this.solidLine.eventMode="none";const s=i.getApp().toFixedSize(t);this.solidLine.setStrokeStyle({color:e.toString(),width:s}).moveTo(this.solidLinePoints[0].x,this.solidLinePoints[0].y).lineTo(this.solidLinePoints[1].x,this.solidLinePoints[1].y).stroke(),this.addChildAt(this.solidLine,0)}clearSolidLine(){this.solidLine&&(this.removeChild(this.solidLine),this.solidLine.destroy(),this.solidLine=null),this.solidLinePoints=null}updatedividerPoints(t){this.endPoints=this.validateDividerPoints(t),this.updateAllComponents(),this.calculateAndCreateSolidLine()}destroy(){Yi().emitter.off("antiScale",this.throttledHandleScaleChange),this.cleanupDragEventListeners(),this.isDragging&&(this.isDragging=!1,this.dragStartPosition=null,this.initialDividerPoints=[]),this.dashLine&&this.dashLine.off("pointerdown",this.handleDashLinePointerDown),this.clearSolidLine(),this.dashLine?.destroy(),this.startEndPoint?.destroy(),this.endEndPoint?.destroy(),super.destroy()}}class dx{forbiddenSweepZoneMap=new Map;forbiddenMopZoneMap=new Map;cleanZoneMap=new Map;virtualWallMap=new Map;spotMap=new Map;wayPointMap=new Map;divider=null;unsubscribeFns=[];constructor(){const t=Yi(),e=Xi(t.runtime,"editingForbiddenSweepZoneIds",t=>{ag.log(`[runtime] editingForbiddenSweepZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenSweepZoneMap)}),i=Xi(t.runtime,"editingForbiddenMopZoneIds",t=>{ag.log(`[runtime] editingForbiddenMopZoneIds: ${t}`),this.updateZonesEditState(this.forbiddenMopZoneMap)}),s=Xi(t.runtime,"editingCleanZoneIds",t=>{ag.log(`[runtime] editingCleanZoneIds: ${t}`),this.updateZonesEditState(this.cleanZoneMap)}),n=Xi(t.runtime,"editingVirtualWallIds",t=>{ag.log(`[runtime] editingVirtualWallIds: ${t}`),this.updateVirtualWallsEditState(this.virtualWallMap)}),r=Xi(t.runtime,"editingSpotIds",t=>{ag.log(`[runtime] editingSpotIds: ${t}`),this.updateSpotsEditState(this.spotMap)}),o=Xi(t.runtime,"editingWayPointIds",t=>{ag.log(`[runtime] editingWayPointIds: ${t}`),this.updateWayPointsEditState(this.wayPointMap)}),a=Xi(t.runtime,"dividingRoomId",t=>{ag.log(`[runtime] dividingRoomId: ${t}`),this.handleDividingRoomIdChange(t)}),h=Xi(t.runtime,"unit",t=>{ag.log(`[runtime] unit changed: ${t}`),this.handleUnitChange()}),l=Xi(t.runtime,"unitLabel",t=>{ag.log(`[runtime] unitLabel changed: ${t}`),this.handleUnitChange()});this.unsubscribeFns.push(e,i,s,n,r,o,a,h,l)}updatePositionByOrigin(t,e){const i=Yi().appContainer.getLayer(xy);i&&i.position.set(t,e)}drawForbiddenSweepZones(t){this.drawZones(t,this.forbiddenSweepZoneMap,t=>ix.create(t))}getForbiddenSweepZones(){return this.getZonesData(this.forbiddenSweepZoneMap)}clearAllForbiddenSweepZones(){this.clearAllZones(this.forbiddenSweepZoneMap)}drawForbiddenMopZones(t){this.drawZones(t,this.forbiddenMopZoneMap,t=>sx.create(t))}getForbiddenMopZones(){return this.getZonesData(this.forbiddenMopZoneMap)}clearAllForbiddenMopZones(){this.clearAllZones(this.forbiddenMopZoneMap)}drawCleanZones(t){this.drawZones(t,this.cleanZoneMap,t=>nx.create(t))}getCleanZones(){return this.getZonesData(this.cleanZoneMap)}clearAllCleanZones(){this.clearAllZones(this.cleanZoneMap)}drawVirtualWalls(t){const e=Yi(),i=this.virtualWallMap,s=new Set(t.map(t=>t.id));for(const[t,n]of i)s.has(t)||(e.appContainer.removeFromLayer(xy,n),n.destroy(),i.delete(t));t.forEach(t=>{const s=i.get(t.id);if(s)this.isWallDataEqual(s.getWallData(),t)||s.updateWallData(t);else{const s=new ox({wallData:t,events:{onRemove:t=>{e.events?.onRemoveVirtualWall?.(t)},onUpdate:t=>{e.events?.onUpdateVirtualWall?.(t)},onClick:t=>{e.events?.onClickVirtualWall?.(t)}}});i.set(t.id,s),e.appContainer.addToLayer(xy,s)}})}getVirtualWalls(){return this.getWallsData(this.virtualWallMap)}clearAllVirtualWalls(){this.clearAllWalls(this.virtualWallMap)}drawSpots(t){const e=this.spotMap;if(!t||0===t.length)return void this.clearAllSpotsInternal(e);const i=new Set(e.keys()),s=new Set(t.map(t=>t.id));for(const t of i)s.has(t)||this.removeSpot(t,e);t.forEach(t=>{const i=e.get(t.id);i?this.isSpotDataEqual(i.getSpotData(),t)||i.updateSpotData(t):this.addNewSpot(t,e)})}getSpots(){return this.getSpotsData(this.spotMap)}clearAllSpots(){this.clearAllSpotsInternal(this.spotMap)}drawZones(t,e,i){if(!t||0===t.length)return void this.clearAllZones(e);const s=new Set(e.keys()),n=new Set(t.map(t=>t.id));for(const t of s)n.has(t)||this.removeZone(t,e);t.forEach(t=>{const s=e.get(t.id);s?this.isZoneDataEqual(s.getZoneData(),t)||s.updateZoneData(t):this.addNewZone(t,e,i)})}addNewZone(t,e,i){const s=Yi(),n=i(t);e.set(t.id,n),s.appContainer.addToLayer(xy,n)}removeZone(t,e){const i=Yi(),s=e.get(t);s&&(i.appContainer.removeFromLayer(xy,s),s.destroy(),e.delete(t))}getZonesData(t){const e=[];return t.forEach(t=>{e.push(t.getZoneData())}),e}clearAllZones(t){t.forEach((e,i)=>{const s=t.get(i);s&&(s.parent?.removeChild(s),s.destroy())}),t.clear()}updateZonesEditState(t){t.forEach(t=>{t.updateEditState()})}updateVirtualWallsEditState(t){t.forEach(t=>{t.updateEditingState()})}isZoneDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}getWallsData(t){return Array.from(t.values()).map(t=>t.getWallData())}clearAllWalls(t){for(const e of t.values())e.destroy();t.clear()}isWallDataEqual(t,e){if(t.id!==e.id)return!1;if(t.points.length!==e.points.length)return!1;for(let i=0;i<t.points.length;i++){const s=t.points[i],n=e.points[i];if(Math.abs(s.x-n.x)>.1||Math.abs(s.y-n.y)>.1)return!1}return!0}addNewSpot(t,e){const i=Yi(),s=ax.create(t);e.set(t.id,s),i.appContainer.addToLayer(xy,s)}removeSpot(t,e){const i=Yi(),s=e.get(t);s&&(i.appContainer.removeFromLayer(xy,s),s.destroy(),e.delete(t))}getSpotsData(t){const e=[];return t.forEach(t=>{e.push(t.getSpotData())}),e}clearAllSpotsInternal(t){t.forEach((e,i)=>{const s=t.get(i);s&&(s.parent?.removeChild(s),s.destroy())}),t.clear()}updateSpotsEditState(t){t.forEach(t=>{t.updateEditState()})}isSpotDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}drawWayPoints(t){ag.log("[ControlsManager] drawWayPoints",t);const e=Array.from(this.wayPointMap.keys()),i=t.map(t=>t.id);e.filter(t=>!i.includes(t)).forEach(t=>{this.removeWayPoint(t,this.wayPointMap)}),t.forEach((t,e)=>{const i=e+1,s=this.wayPointMap.get(t.id);s?(this.isWayPointDataEqual(s.getWayPointData(),t)||s.updateWayPoint(t),s.updateOrder(i)):this.addNewWayPoint(t,i,this.wayPointMap)})}clearAllWayPoints(){ag.log("[ControlsManager] clearAllWayPoints"),this.clearAllWayPointsInternal(this.wayPointMap)}getWayPoints(){return this.getWayPointsData(this.wayPointMap)}addNewWayPoint(t,e,i){const s=Yi(),n=new hx({wayPointData:t,order:e,events:{onUpdate:s.events?.onUpdateWayPoint,onClick:s.events?.onClickWayPoint}});i.set(t.id,n),s.appContainer.addToLayer(xy,n)}removeWayPoint(t,e){const i=Yi(),s=e.get(t);s&&(i.appContainer.removeFromLayer(xy,s),s.destroy(),e.delete(t))}getWayPointsData(t){const e=[];return t.forEach(t=>{e.push(t.getWayPointData())}),e}clearAllWayPointsInternal(t){t.forEach((e,i)=>{const s=t.get(i);s&&(s.parent?.removeChild(s),s.destroy())}),t.clear()}updateWayPointsEditState(t){t.forEach(t=>{t.onEditStateChange()})}isWayPointDataEqual(t,e){if(t.id!==e.id)return!1;const i=t.point,s=e.point;return!(Math.abs(i.x-s.x)>.1||Math.abs(i.y-s.y)>.1)}handleDividingRoomIdChange(t){null!=t&&-1!==t&&this.getRoomGeometry(t)?this.createDefaultDivider(t):this.clearDivider()}getRoomGeometry(t){return Yi().mapManager.getRoomById(t)}createDefaultDivider(t){const e=Yi();this.clearDivider(),this.divider=new cx({roomId:t,events:{onUpdate:t=>{e.events?.onUpdateDivider?.(t)}}}),e.appContainer.addToLayer(xy,this.divider)}clearDivider(){this.divider&&(Yi().appContainer.removeFromLayer(xy,this.divider),this.divider.destroy(),this.divider=null)}getDividerEndPoints(){return this.divider?this.divider.getDividerEndPoints():null}getEffectiveDividerPoints(){return this.divider?this.divider.getEffectiveDividerPoints():null}handleUnitChange(){ag.debug("[ControlsManager] Unit changed, refreshing all size texts"),this.forbiddenSweepZoneMap.forEach(t=>{t.refreshDisplay()}),this.forbiddenMopZoneMap.forEach(t=>{t.refreshDisplay()}),this.cleanZoneMap.forEach(t=>{t.refreshDisplay()}),this.virtualWallMap.forEach(t=>{t.refreshDisplay()}),this.spotMap.forEach(t=>{t.refreshDisplay()})}destroy(){this.clearAllForbiddenSweepZones(),this.clearAllForbiddenMopZones(),this.clearAllCleanZones(),this.clearAllVirtualWalls(),this.clearAllSpots(),this.clearDivider(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}class ux extends Ry{objectData;clickHandler=null;unsubscribeMapRotation=null;constructor(t){super(),this.objectData=t}async initializeSprite(){const t=Yi(),e=t.detectedObjectConfig,i=this.objectData.width||e.width,s=this.objectData.height||e.height;await this.loadTextureAndSetSize(this.objectData.src,{width:i,height:s}),this.position.set(this.objectData.x,this.objectData.y),this.visible=!0,this.applyAntiRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyAntiRotation(t)}),e.interactive?this.setupClickHandler():this.eventMode="none"}applyAntiRotation(t){const e=-t*Math.PI/180;this.rotation=e}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new Ty(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Yi();t.events?.onClickDetectedObject?.(this.getObjectData())}getObjectData(){return{...this.objectData}}async updateObjectData(t){const e=Yi(),i=this.objectData;this.objectData=t;const s=e.detectedObjectConfig;if(i.src!==t.src){const e=t.width||s.width,i=t.height||s.height;await this.loadTextureAndSetSize(t.src,{width:e,height:i})}if(i.width!==t.width||i.height!==t.height){const e=t.width||s.width,i=t.height||s.height;this.setFixedSize(e,i)}this.position.set(t.x,t.y),s.interactive?this.clickHandler||this.setupClickHandler():this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null)}isSameData(t){return this.objectData.id===t.id&&this.objectData.src===t.src&&this.objectData.x===t.x&&this.objectData.y===t.y&&this.objectData.width===t.width&&this.objectData.height===t.height}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class px{detectedObjectMap=new Map;updatePositionByOrigin(t,e){const i=Yi().appContainer.getLayer(vy);i&&i.position.set(t,e)}async drawDetectedObjects(t){if(!t||0===t.length)return void this.clearAllDetectedObjects();const e=new Set(t.map(t=>t.id)),i=Array.from(this.detectedObjectMap.keys());for(const t of i)e.has(t)||this.removeDetectedObject(t);for(const e of t){const t=this.detectedObjectMap.get(e.id);t?t.isSameData(e)||await t.updateObjectData(e):await this.addNewDetectedObject(e)}}clearAllDetectedObjects(){const t=Yi();this.detectedObjectMap.forEach(e=>{t.appContainer.removeFromLayer(vy,e),e.destroy()}),this.detectedObjectMap.clear()}async addNewDetectedObject(t){const e=Yi(),i=new ux(t);await i.initializeSprite(),this.detectedObjectMap.set(t.id,i),e.appContainer.addToLayer(vy,i)}removeDetectedObject(t){const e=Yi(),i=this.detectedObjectMap.get(t);i&&(e.appContainer.removeFromLayer(vy,i),i.destroy(),this.detectedObjectMap.delete(t))}destroy(){this.clearAllDetectedObjects()}}var gx,fx,mx,yx,xx,bx,vx={},_x={},wx={},Ax={},Cx={},Sx={},Ix=function(){if(bx)return vx;bx=1,Object.defineProperty(vx,"__esModule",{value:!0}),vx.decompressFrames=vx.decompressFrame=vx.parseGIF=void 0;var t,e=(mx||(mx=1,function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var e=Ki(),i=Qi(),s={blocks:function(t){for(var e=[],s=t.data.length,n=0,r=(0,i.readByte)()(t);0!==r&&r;r=(0,i.readByte)()(t)){if(t.pos+r>=s){var o=s-t.pos;e.push((0,i.readBytes)(o)(t)),n+=o;break}e.push((0,i.readBytes)(r)(t)),n+=r}for(var a=new Uint8Array(n),h=0,l=0;l<e.length;l++)a.set(e[l],h),h+=e[l].length;return a}},n=(0,e.conditional)({gce:[{codes:(0,i.readBytes)(2)},{byteSize:(0,i.readByte)()},{extras:(0,i.readBits)({future:{index:0,length:3},disposal:{index:3,length:3},userInput:{index:6},transparentColorGiven:{index:7}})},{delay:(0,i.readUnsigned)(!0)},{transparentColorIndex:(0,i.readByte)()},{terminator:(0,i.readByte)()}]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&249===e[1]}),r=(0,e.conditional)({image:[{code:(0,i.readByte)()},{descriptor:[{left:(0,i.readUnsigned)(!0)},{top:(0,i.readUnsigned)(!0)},{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{lct:(0,i.readBits)({exists:{index:0},interlaced:{index:1},sort:{index:2},future:{index:3,length:2},size:{index:5,length:3}})}]},(0,e.conditional)({lct:(0,i.readArray)(3,function(t,e,i){return Math.pow(2,i.descriptor.lct.size+1)})},function(t,e,i){return i.descriptor.lct.exists}),{data:[{minCodeSize:(0,i.readByte)()},s]}]},function(t){return 44===(0,i.peekByte)()(t)}),o=(0,e.conditional)({text:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{preData:function(t,e,s){return(0,i.readBytes)(s.text.blockSize)(t)}},s]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&1===e[1]}),a=(0,e.conditional)({application:[{codes:(0,i.readBytes)(2)},{blockSize:(0,i.readByte)()},{id:function(t,e,s){return(0,i.readString)(s.blockSize)(t)}},s]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&255===e[1]}),h=(0,e.conditional)({comment:[{codes:(0,i.readBytes)(2)},s]},function(t){var e=(0,i.peekBytes)(2)(t);return 33===e[0]&&254===e[1]}),l=[{header:[{signature:(0,i.readString)(3)},{version:(0,i.readString)(3)}]},{lsd:[{width:(0,i.readUnsigned)(!0)},{height:(0,i.readUnsigned)(!0)},{gct:(0,i.readBits)({exists:{index:0},resolution:{index:1,length:3},sort:{index:4},size:{index:5,length:3}})},{backgroundColorIndex:(0,i.readByte)()},{pixelAspectRatio:(0,i.readByte)()}]},(0,e.conditional)({gct:(0,i.readArray)(3,function(t,e){return Math.pow(2,e.lsd.gct.size+1)})},function(t,e){return e.lsd.gct.exists}),{frames:(0,e.loop)([n,a,h,r,o],function(t){var e=(0,i.peekByte)()(t);return 33===e||44===e})}];t.default=l}(_x)),(t=_x)&&t.__esModule?t:{default:t}),i=Ki(),s=Qi(),n=(yx||(yx=1,Object.defineProperty(Cx,"__esModule",{value:!0}),Cx.deinterlace=void 0,Cx.deinterlace=function(t,e){for(var i=new Array(t.length),s=t.length/e,n=function(s,n){var r=t.slice(n*e,(n+1)*e);i.splice.apply(i,[s*e,e].concat(r))},r=[0,4,2,1],o=[8,8,4,2],a=0,h=0;h<4;h++)for(var l=r[h];l<s;l+=o[h])n(l,a),a++;return i}),Cx),r=(xx||(xx=1,Object.defineProperty(Sx,"__esModule",{value:!0}),Sx.lzw=void 0,Sx.lzw=function(t,e,i){var s,n,r,o,a,h,l,c,d,u,p,g,f,m,y,x,b=4096,v=i,_=new Array(i),w=new Array(b),A=new Array(b),C=new Array(4097);for(a=1+(n=1<<(u=t)),s=n+2,l=-1,r=(1<<(o=u+1))-1,c=0;c<n;c++)w[c]=0,A[c]=c;for(p=g=f=m=y=x=0,d=0;d<v;){if(0===m){if(g<o){p+=e[x]<<g,g+=8,x++;continue}if(c=p&r,p>>=o,g-=o,c>s||c==a)break;if(c==n){r=(1<<(o=u+1))-1,s=n+2,l=-1;continue}if(-1==l){C[m++]=A[c],l=c,f=c;continue}for(h=c,c==s&&(C[m++]=f,c=l);c>n;)C[m++]=A[c],c=w[c];f=255&A[c],C[m++]=f,s<b&&(w[s]=l,A[s]=f,0===(++s&r)&&s<b&&(o++,r+=s)),l=h}m--,_[y++]=C[m],d++}for(d=y;d<v;d++)_[d]=0;return _}),Sx);vx.parseGIF=function(t){var n=new Uint8Array(t);return(0,i.parse)((0,s.buildStream)(n),e.default)};var o=function(t,e,i){if(t.image){var s=t.image,o=s.descriptor.width*s.descriptor.height,a=(0,r.lzw)(s.data.minCodeSize,s.data.blocks,o);s.descriptor.lct.interlaced&&(a=(0,n.deinterlace)(a,s.descriptor.width));var h={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?h.colorTable=s.lct:h.colorTable=e,t.gce&&(h.delay=10*(t.gce.delay||10),h.disposalType=t.gce.extras.disposal,t.gce.extras.transparentColorGiven&&(h.transparentIndex=t.gce.transparentColorIndex)),i&&(h.patch=function(t){for(var e=t.pixels.length,i=new Uint8ClampedArray(4*e),s=0;s<e;s++){var n=4*s,r=t.pixels[s],o=t.colorTable[r]||[0,0,0];i[n]=o[0],i[n+1]=o[1],i[n+2]=o[2],i[n+3]=r!==t.transparentIndex?255:0}return i}(h)),h}};return vx.decompressFrame=o,vx.decompressFrames=function(t,e){return t.frames.filter(function(t){return t.image}).map(function(i){return o(i,t.gct,e)})},vx}();class Mx{constructor(t){if(!t||!t.length)throw new Error("Invalid frames");const[{texture:{width:e,height:i}}]=t;this.width=e,this.height=i,this.frames=t,this.textures=this.frames.map(t=>t.texture),this.totalFrames=this.frames.length,this.duration=this.frames[this.totalFrames-1].end}destroy(){for(const t of this.textures)t.destroy(!0);for(const t of this.frames)t.texture=null;this.frames.length=0,this.textures.length=0,Object.assign(this,{frames:null,textures:null,width:0,height:0,duration:0,totalFrames:0})}static from(t,e){if(!t||0===t.byteLength)throw new Error("Invalid buffer");const i=Ix.parseGIF(t);(t=>{let e=null;for(const i of t.frames)e=i.gce??e,"image"in i&&!("gce"in i)&&(i.gce=e)})(i);const s=Ix.decompressFrames(i,!0),n=[],r=i.lsd.width,o=i.lsd.height,a=ir.get().createCanvas(r,o),h=a.getContext("2d",{willReadFrequently:!0}),l=ir.get().createCanvas(),c=l.getContext("2d");let d=0,u=null;const{fps:p=30,...g}=e??{},f=1e3/p;for(let t=0;t<s.length;t++){const{disposalType:e=2,delay:i=f,patch:a,dims:{width:p,height:m,left:y,top:x}}=s[t];l.width=p,l.height=m,c.clearRect(0,0,p,m);const b=c.createImageData(p,m);b.data.set(a),c.putImageData(b,0,0),3===e&&(u=h.getImageData(0,0,r,o)),h.drawImage(l,y,x);const v=h.getImageData(0,0,r,o);2===e?h.clearRect(0,0,r,o):3===e&&h.putImageData(u,0,0);const _=ir.get().createCanvas(v.width,v.height);_.getContext("2d").putImageData(v,0,0),n.push({start:d,end:d+i,texture:new Gs({source:new sr({resource:_,...g})})}),d+=i}return a.width=a.height=0,l.width=l.height=0,new Mx(n)}}const Tx={extension:qi.Asset,detection:{test:async()=>!0,add:async t=>[...t,"gif"],remove:async t=>t.filter(t=>"gif"!==t)},loader:{name:"gifLoader",id:"gif",test:t=>".gif"===mr.extname(t)||t.startsWith("data:image/gif"),load:async(t,e)=>{const i=await ir.get().fetch(t),s=await i.arrayBuffer();return Mx.from(s,e?.data)},unload:async t=>{t.destroy()}}},Px=class t extends Kn{constructor(...e){const i=e[0]instanceof Mx?{source:e[0]}:e[0],{source:s,fps:n,loop:r,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d,...u}=Object.assign({},t.defaultOptions,i);super({texture:Gs.EMPTY,...u}),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(),this.texture=s.textures[0],this.duration=s.frames[s.frames.length-1].end,this._source=s,this._playing=!1,this._currentTime=0,this._isConnectedToTicker=!1,Object.assign(this,{fps:n,loop:r,animationSpeed:o,autoPlay:a,autoUpdate:h,onComplete:l,onFrameChange:c,onLoop:d}),this.currentFrame=0,a&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(lr.shared.add(this.update,this,rr.HIGH),this._isConnectedToTicker=!0),this.loop||this.currentFrame!==this._source.frames.length-1||(this._currentTime=0))}get progress(){return this._currentTime/this.duration}get playing(){return this._playing}update(t){if(!this._playing)return;const e=this.animationSpeed*t.deltaTime/lr.targetFPMS,i=this._currentTime+e,s=i%this.duration,n=this._source.frames.findIndex(t=>t.start<=s&&t.end>s);i>=this.duration?this.loop?(this._currentTime=s,this._updateFrameIndex(n),this.onLoop?.()):(this._currentTime=this.duration,this._updateFrameIndex(this.totalFrames-1),this.onComplete?.(),this.stop()):(this._currentTime=s,this._updateFrameIndex(n))}_updateFrame(){this.dirty&&(this.texture=this._source.frames[this._currentFrame].texture,this.dirty=!1)}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(lr.shared.add(this.update,this),this._isConnectedToTicker=!0))}get currentFrame(){return this._currentFrame}set currentFrame(t){this._updateFrameIndex(t),this._currentTime=this._source.frames[t].start}get source(){return this._source}_updateFrameIndex(t){if(t<0||t>=this.totalFrames)throw new Error(`Frame index out of range, expecting 0 to ${this.totalFrames}, got ${t}`);this._currentFrame!==t&&(this._currentFrame=t,this.dirty=!0,this.onFrameChange?.(t))}get totalFrames(){return this._source.totalFrames}destroy(t=!1){this.stop(),super.destroy(),t&&this._source.destroy();const e=null;this._source=e,this.onComplete=e,this.onFrameChange=e,this.onLoop=e}clone(){const e=new t({source:this._source,autoUpdate:this._autoUpdate,loop:this.loop,autoPlay:this.autoPlay,animationSpeed:this.animationSpeed,onComplete:this.onComplete,onFrameChange:this.onFrameChange,onLoop:this.onLoop});return e.dirty=!0,e}};Px.defaultOptions={fps:30,loop:!0,animationSpeed:1,autoPlay:!0,autoUpdate:!0,onComplete:null,onFrameChange:null,onLoop:null};let Ex=Px;es.add(Tx);class Bx extends Ex{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;sizeFixed=!0;baselineScale=1;constructor(t){super(t),this.anchor.set(.5),this.visible=!1,this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applySize()}setSizeFixed(t){this.sizeFixed=t,this.baselineScale=1,(t&&this.isFixedSizeSet||!t&&this.isFixedSizeSet)&&this.applySize()}set width(t){this.isFixedSizeSet?ag.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置宽度"):this.setFixedSize(t,this.fixedHeight||t)}set height(t){this.isFixedSizeSet?ag.warn("EnhancedGifSprite: 使用 setFixedSize() 方法来设置高度"):this.setFixedSize(this.fixedWidth||t,t)}get width(){return this.fixedWidth||super.width}get height(){return this.fixedHeight||super.height}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applySize(){if(!this.isFixedSizeSet||!this.texture||0===this.texture.width||0===this.texture.height)return;const t=Yi(),e=this.fixedWidth/this.texture.width,i=this.fixedHeight/this.texture.height;if(this.sizeFixed){const s=t.currentScale;if(0===s)return;const n=e/s,r=i/s;super.scale.set(n,r)}else super.scale.set(e/this.baselineScale,i/this.baselineScale)}updateScale(t){this.sizeFixed&&(this.isFixedSizeSet?this.applySize():0!==t&&super.scale.set(1/t))}static async createFromSrc(t,e){try{const i=await gl.load(t),s=new Bx({source:i});return void 0!==e.sizeFixed&&s.setSizeFixed(e.sizeFixed),s.setFixedSize(e.width,e.height),s}catch(e){throw ag.error(`Failed to load GIF "${t}":`,e),e}}draw(t,e){const{x:i,y:s,rotation:n=0}=t;e&&!this.visible?this.visible=e():e||this.visible||(this.visible=!0),this.rotation=n,this.position.set(i,s)}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Rx extends Bx{elementData;clickHandler=null;unsubscribeMapRotation=null;userRotation=0;constructor(t,e){super({source:t}),this.elementData=e}async initialize(){const t=Yi();void 0!==this.elementData.sizeFixed&&this.setSizeFixed(this.elementData.sizeFixed),this.setFixedSize(this.elementData.width,this.elementData.height),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.userRotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.applyRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const e=-t*Math.PI/180;this.rotation=this.userRotation+e}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new Ty(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Yi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;if(this.elementData=t,e.src!==t.src)throw new Error("GIF source change requires recreation of instance");if(e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height),this.position.set(t.x,t.y),void 0!==t.rotation){this.userRotation=t.rotation;const e=Yi();this.applyRotation(e.runtime.mapRotation)}void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class kx extends Ry{elementData;clickHandler=null;unsubscribeMapRotation=null;userRotation=0;constructor(t){super(),this.elementData=t}async initialize(){const t=Yi();await this.loadTextureAndSetSize(this.elementData.src,{width:this.elementData.width,height:this.elementData.height,sizeFixed:this.elementData.sizeFixed}),this.position.set(this.elementData.x,this.elementData.y),void 0!==this.elementData.rotation&&(this.userRotation=this.elementData.rotation),void 0!==this.elementData.opacity&&(this.alpha=this.elementData.opacity),this.applyRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.visible=!0,this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const e=-t*Math.PI/180;this.rotation=this.userRotation+e}setupClickHandler(){this.clickHandler&&this.clickHandler.destroy(),this.clickHandler=new Ty(this,{onClick:()=>this.handleClick(),stopPropagation:!1})}handleClick(){const t=Yi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;if(this.elementData=t,e.src!==t.src?await this.loadTextureAndSetSize(t.src,{width:t.width,height:t.height,sizeFixed:t.sizeFixed}):(e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),e.width===t.width&&e.height===t.height||this.setFixedSize(t.width,t.height)),this.position.set(t.x,t.y),void 0!==t.rotation){this.userRotation=t.rotation;const e=Yi();this.applyRotation(e.runtime.mapRotation)}void 0!==t.opacity&&(this.alpha=t.opacity),t.interactive?this.clickHandler||this.setupClickHandler():(this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),this.eventMode="none")}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.src===t.src&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.clickHandler&&(this.clickHandler.destroy(),this.clickHandler=null),super.destroy()}}class Ox extends ml{throttledUpdateScale;fixedWidth=0;fixedHeight=0;isFixedSizeSet=!1;userCenterX=0;userCenterY=0;sizeFixed=!0;constructor(t){super(t),this.anchor.set(0,0),this.throttledUpdateScale=Ji(this.updateScale.bind(this),30,{leading:!0,trailing:!0}),this.registerScaleListener()}setFixedSize(t,e){this.fixedWidth=t,this.fixedHeight=e,this.isFixedSizeSet=!0,this.applyFixedSize(),this.updatePositionFromCenter()}setCenterPosition(t,e){this.userCenterX=t,this.userCenterY=e,this.updatePositionFromCenter()}setSizeFixed(t){this.sizeFixed=t,this.isFixedSizeSet&&(this.applyFixedSize(),this.updatePositionFromCenter())}getIsFixedSizeSet(){return this.isFixedSizeSet}updatePositionFromCenter(){if(!this.isFixedSizeSet)return void this.position.set(this.userCenterX,this.userCenterY);const t=Yi().currentScale;let e,i;this.sizeFixed?(e=this.fixedWidth/2/t,i=this.fixedHeight/2/t):(e=this.fixedWidth/2,i=this.fixedHeight/2),this.position.set(this.userCenterX-e,this.userCenterY-i)}registerScaleListener(){Yi().emitter.on("antiScale",this.throttledUpdateScale)}applyFixedSize(){if(!this.isFixedSizeSet)return;const t=Yi().currentScale;if(0!==t){if(this.sizeFixed){const e=1/t;this.scale.set(e)}else this.scale.set(1);this.element&&(this.element.style.width=`${this.fixedWidth}px`,this.element.style.height=`${this.fixedHeight}px`)}}updateScale(t){this.isFixedSizeSet&&0!==t&&(this.applyFixedSize(),this.updatePositionFromCenter())}updateTransform(t){return super.updateTransform(t)}destroy(t){Yi().emitter.off("antiScale",this.throttledUpdateScale),super.destroy(t)}}class Dx extends Ox{elementData;domClickHandler=null;resizeObserver=null;debugMarker=null;unsubscribeMapRotation=null;userRotation=0;constructor(t){const e=document.createElement("div");Dx.setupDefaultStyles(e,t),e.innerHTML=t.htmlContent,super({element:e}),this.elementData=t}async initialize(){const t=Yi();this.alpha=0,this.elementData.width&&this.elementData.height?(this.setFixedSize(this.elementData.width,this.elementData.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),this.waitForElementInsertion()):(this.position.set(this.elementData.x,this.elementData.y),this.setupAutoSize()),void 0!==this.elementData.rotation&&(this.userRotation=this.elementData.rotation),this.applyRotation(t.runtime.mapRotation),this.unsubscribeMapRotation=Xi(t.runtime,"mapRotation",t=>{this.applyRotation(t)}),this.elementData.interactive?this.setupClickHandler():this.eventMode="none"}applyRotation(t){const e=-t*Math.PI/180;this.rotation=this.userRotation+e}setupAutoSize(){this.element&&(this.element.style.width="auto",this.element.style.height="auto",this.waitForElementDimensions())}waitForElementInsertion(){if(!this.element)return;const t=()=>{this.element&&(this.element.isConnected?this.showElement():requestAnimationFrame(t))};requestAnimationFrame(t)}waitForElementDimensions(){this.element&&("undefined"!=typeof ResizeObserver?(this.resizeObserver=new ResizeObserver(t=>{const e=t[0];e&&e.contentRect.width>0&&e.contentRect.height>0&&(this.setFixedSize(e.contentRect.width,e.contentRect.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),0===this.alpha&&this.showElement(),this.resizeObserver?.disconnect(),this.resizeObserver=null)}),this.resizeObserver.observe(this.element)):this.pollForElementDimensions())}pollForElementDimensions(){if(!this.element)return;const t=()=>{if(!this.element)return;if(!this.element.isConnected)return void requestAnimationFrame(t);const e=this.element.getBoundingClientRect();e.width>0&&e.height>0?(this.setFixedSize(e.width,e.height),this.setCenterPosition(this.elementData.x,this.elementData.y),this.setSizeFixed(this.elementData.sizeFixed??!0),0===this.alpha&&this.showElement()):requestAnimationFrame(t)};requestAnimationFrame(t)}showElement(){this.alpha=this.elementData.opacity??1,this.element.style.pointerEvents=this.elementData.interactive?"auto":"none",this.interactive=this.elementData.interactive??!1,this.elementData.interactive&&this.element&&(this.element.style.setProperty("-webkit-tap-highlight-color","transparent"),this.element.style.setProperty("-webkit-touch-callout","none")),Yi().getApp().renderOnceNextFrame()}setupClickHandler(){this.element&&(this.domClickHandler=t=>{t.preventDefault(),t.stopPropagation(),this.handleClick()},this.element.addEventListener("click",this.domClickHandler))}handleClick(){const t=Yi();t.events?.onClickCustomElement?.(this.getElementData())}getElementData(){return{...this.elementData}}async updateElementData(t){const e=this.elementData;this.elementData=t,e.htmlContent!==t.htmlContent&&this.element&&(this.element.innerHTML=t.htmlContent,t.width&&t.height||this.waitForElementDimensions()),e.width===t.width&&e.height===t.height||(t.width&&t.height?(this.setFixedSize(t.width,t.height),this.element&&(this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`)):this.setupAutoSize()),t.width&&t.height||this.getIsFixedSizeSet()?this.setCenterPosition(t.x,t.y):this.position.set(t.x,t.y),e.sizeFixed!==t.sizeFixed&&void 0!==t.sizeFixed&&this.setSizeFixed(t.sizeFixed),this.userRotation=t.rotation??0;const i=Yi();this.applyRotation(i.runtime.mapRotation),this.alpha=t.opacity??1,t.interactive?this.domClickHandler||this.setupClickHandler():(this.eventMode="none",this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null))}isSameData(t){return this.elementData.id===t.id&&this.elementData.type===t.type&&this.elementData.htmlContent===t.htmlContent&&this.elementData.x===t.x&&this.elementData.y===t.y&&this.elementData.width===t.width&&this.elementData.height===t.height&&this.elementData.rotation===t.rotation&&this.elementData.opacity===t.opacity&&this.elementData.interactive===t.interactive&&this.elementData.sizeFixed===t.sizeFixed}static setupDefaultStyles(t,e){const i={position:"relative",boxSizing:"border-box",webkitFontSmoothing:"antialiased",textRendering:"optimizeLegibility",background:"transparent",userSelect:"auto",webkitUserSelect:"auto"};e.width&&e.height?(i.width=`${e.width}px`,i.height=`${e.height}px`,i.overflow="hidden"):(i.width=e.width?`${e.width}px`:"auto",i.height=e.height?`${e.height}px`:"auto",i.overflow="visible"),Object.assign(t.style,i),t.style.setProperty("-webkit-tap-highlight-color","transparent"),t.style.setProperty("-webkit-touch-callout","none")}destroy(){this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.domClickHandler&&this.element&&(this.element.removeEventListener("click",this.domClickHandler),this.domClickHandler=null),this.debugMarker&&(this.debugMarker.destroy(),this.debugMarker=null),super.destroy()}}class Fx{customElementsMap=new Map;gifTicker=null;gifElements=new Set;constructor(){}updatePositionByOrigin(t,e){const i=Yi(),s=i.appContainer.getLayer(_y),n=i.appContainer.getLayer(wy);s&&s.position.set(t,e),n&&n.position.set(t,e)}async drawCustomElements(t){if(!t||0===t.length)return void this.clearAllCustomElements();const e=new Set(t.map(t=>t.id)),i=Array.from(this.customElementsMap.keys());for(const t of i)e.has(t)||this.removeCustomElement(t);const s=t.map(async t=>{const e=this.customElementsMap.get(t.id);e?this.isSameData(e,t)||("gif"===t.type&&e.getElementData().src!==t.src?(this.removeCustomElement(t.id),await this.addNewCustomElement(t)):await this.updateElementData(e,t)):await this.addNewCustomElement(t)});await Promise.all(s),this.updateGifTicker()}clearAllCustomElements(){const t=Yi();this.customElementsMap.forEach(e=>{e instanceof Rx?t.appContainer.removeFromLayer(wy,e):t.appContainer.removeFromLayer(_y,e),e.destroy()}),this.customElementsMap.clear(),this.gifElements.clear(),this.stopGifTicker()}async addNewCustomElement(t){const e=Yi();let i;switch(t.type){case"image":i=new kx(t);break;case"gif":{const e=await gl.load(t.src);i=new Rx(e,t);break}case"html":i=new Dx(t);break;default:throw new Error(`Unsupported custom element type: ${t.type}`)}await i.initialize(),this.customElementsMap.set(t.id,i),i instanceof Rx?(e.appContainer.addToLayer(wy,i),this.gifElements.add(i)):e.appContainer.addToLayer(_y,i)}removeCustomElement(t){const e=Yi(),i=this.customElementsMap.get(t);i&&(i instanceof Rx?(this.gifElements.delete(i),e.appContainer.removeFromLayer(wy,i)):e.appContainer.removeFromLayer(_y,i),i.destroy(),this.customElementsMap.delete(t))}isSameData(t,e){return t.getElementData().type===e.type&&("image"===e.type&&t instanceof kx||"gif"===e.type&&t instanceof Rx||"html"===e.type&&t instanceof Dx)&&t.isSameData(e)}async updateElementData(t,e){if("image"===e.type&&t instanceof kx)await t.updateElementData(e);else if("gif"===e.type&&t instanceof Rx)await t.updateElementData(e);else{if(!("html"===e.type&&t instanceof Dx))throw new Error("Element type mismatch during update");await t.updateElementData(e)}}updateGifTicker(){this.gifElements.size>0?this.startGifTicker():this.stopGifTicker()}startGifTicker(){this.gifTicker?.started||(this.gifTicker?this.gifTicker.maxFPS=1:(this.gifTicker=new lr,this.gifTicker.maxFPS=1,this.gifTicker.add(()=>{this.renderGifContainer()})),this.gifTicker.start())}stopGifTicker(){this.gifTicker?.started&&(ag.log("⏸️ [GifTicker] 停止 GIF 专用渲染"),this.gifTicker.stop())}renderGifContainer(){const t=Yi();if(0===this.gifElements.size)return;const e=t.getApp();e.renderer.render(e.stage)}destroy(){this.stopGifTicker(),this.gifTicker&&(this.gifTicker.destroy(),this.gifTicker=null),this.clearAllCustomElements()}}class Lx extends Ql{roomId;roomIndex;constructor(t){const e=Yi(),{nameLabel:i,colors:s}=e.roomConfig,n=t.colorIndex??t.index,r=s.name[n%s.name.length],o=new yh({fontSize:i.fontSize,fontFamily:i.fontFamily,fontWeight:i.fontWeight,fill:r,align:"center"});super({text:t.name||"Unknown",style:o}),this.roomId=t.id,this.roomIndex=t.index,this.anchor.set(.5)}updateName(t){this.text=t}refreshColor(t){const e=Yi(),{colors:i}=e.roomConfig,s=e.getRoomData(this.roomId),n=s?.colorIndex??this.roomIndex,r=t??i.name[n%i.name.length];this.style.fill=r}}class jx extends Xn{background;foldedIndicator;propertyIcons=new Map;orderContainer;orderBackground;orderText;isFolded=!1;roomId;roomIndex;constructor(t){super();const e=Yi(),i=e.roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new jl,this.foldedIndicator=new jl,this.foldedIndicator.visible=!1;const{property:s,colors:{propertyTheme:n}}=i,r=n[(t.colorIndex??t.index)%n.length];this.initializePropertyIcons(s.displayOrders,r),this.orderContainer=new Xn,this.orderBackground=new jl,this.orderText=new Ql({text:"",style:new yh({fontSize:s.cleanOrder.fontSize,fontFamily:s.cleanOrder.fontFamily,fontWeight:s.cleanOrder.fontWeight,fill:s.cleanOrder.color,align:"center",trim:!0})}),this.orderText.anchor.set(.5,.5),this.orderContainer.addChild(this.orderBackground),this.orderContainer.addChild(this.orderText),this.addChild(this.background),this.addChild(this.foldedIndicator),this.propertyIcons.forEach(({sprite:t})=>{this.addChild(t)}),this.addChild(this.orderContainer),this.visible=e.runtimeSnapshot.showRoomProperty}initializePropertyIcons(t,e){const i=["cleanMode","suction","cistern","cleanTimes"];t.forEach(t=>{const s=i.includes(t),n=new Ry;n.tint=e,n.anchor.set(0,0),this.propertyIcons.set(t,{fieldName:t,sprite:n,isBuiltin:s})})}async updateProperty(t){await this.updateIcons(t),this.updateBackground()}getFieldValue(t,e){if(["cleanMode","suction","cistern","cleanTimes"].includes(e))return t[e]??null;if(t.customData&&e in t.customData){const i=t.customData[e];return"number"==typeof i?i:null}return null}getAssetAlias(t,e){const i={cleanMode:t=>`cleanMode_${t}`,suction:t=>`fan_${t}`,cistern:t=>`water_${t}`,cleanTimes:t=>`cleanTimes${t}`};return t in i?i[t](e):`custom_${t}_${e}`}shouldShowField(t,e,i){const s=Yi(),{showRoomProperty:n}=s.runtimeSnapshot;return!(null===i||!n||"cleanTimes"===e&&i<=0)}getDisplayElements(t){const e=Yi(),{displayOrders:i}=e.roomConfig.property,{showRoomOrder:s}=e.runtimeSnapshot,n=t.order||0,r=[];return s&&n>0&&r.push({element:this.orderContainer,show:!0,isOrder:!0,fieldName:"order"}),i.forEach(e=>{const i=this.propertyIcons.get(e);if(!i)return;const s=this.getFieldValue(t,e);this.shouldShowField(t,e,s)&&null!==s&&r.push({element:i.sprite,show:!0,isOrder:!1,fieldName:e,value:s})}),{elementsToShow:r,orderValue:n}}async updateIcons(t){const e=Yi();if(this.isFolded)return;const{iconWidth:i,iconHeight:s,container:n,cleanOrder:r,iconGap:o}=e.roomConfig.property,{propertyTheme:a}=e.roomConfig.colors,{paddingHorizontal:h,paddingVertical:l}=n,{elementsToShow:c,orderValue:d}=this.getDisplayElements(t);this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:t})=>{t.visible=!1});const u=[];c.forEach(e=>{if(e.isOrder){this.orderContainer.visible=!0,this.orderText.text=d.toString();const e=t.colorIndex??this.roomIndex;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:a[e%a.length]}),this.orderBackground.circle(i/2,s/2,i/2).fill(),this.orderText.position.set(i/2,s/2)}else{const t=this.propertyIcons.get(e.fieldName);if(t){t.sprite.visible=!0;const n=this.getAssetAlias(e.fieldName,e.value);u.push(t.sprite.loadTextureAndSetSize(n,{width:i,height:s,sizeFixed:!1}))}}}),await Promise.all(u);let p=h;c.forEach((t,e)=>{const{element:s,isOrder:n}=t;s.position.set(p,l),p+=i,e<c.length-1&&(p+=n?r.gapRight:o)})}updateBackground(){const t=Yi();if(this.isFolded)return;const e=t.roomConfig,{container:i,foldable:s}=e.property,{borderRadius:n,tailHeight:r,tailWidth:o,backgroundColor:a}=i,h=this.calculateContentWidth(),l=this.calculateContentHeight(),c=Math.min(o,h/2);if(this.background.clear(),this.background.setFillStyle({color:a}),this.background.roundRect(0,0,h,l,n),s){const t=(h-c)/2;this.background.poly([t,l-1,t+c,l-1,t+c/2,l+r])}this.background.fill()}calculateContentWidth(){const t=Yi(),{iconWidth:e,container:i,cleanOrder:s,iconGap:n}=t.roomConfig.property,{paddingHorizontal:r}=i,o=t.getRoomData(this.roomId);if(!o)return 2*r;const{elementsToShow:a}=this.getDisplayElements(o);let h=r;return a.forEach((t,i)=>{const{isOrder:r}=t;h+=e,i<a.length-1&&(h+=r?s.gapRight:n)}),h+=r,h}calculateContentHeight(){const t=Yi().roomConfig,{iconHeight:e,container:i}=t.property;return i.paddingVertical+e+i.paddingVertical}getTotalHeight(){const t=Yi(),{foldable:e,container:i}=t.roomConfig.property,{tailHeight:s}=i;return this.isFolded?s:this.calculateContentHeight()+(e?s:0)}getTotalWidth(){if(this.isFolded){const t=Yi(),{tailWidth:e}=t.roomConfig.property.container,i=this.calculateContentWidth();return Math.min(e,i/2)}return this.calculateContentWidth()}async setFolded(t){const e=Yi(),{foldable:i}=e.roomConfig.property;if(i)if(this.isFolded=t,t)this.background.visible=!1,this.orderContainer.visible=!1,this.propertyIcons.forEach(({sprite:t})=>{t.visible=!1}),this.foldedIndicator.visible=!0,this.updateFoldedIndicator();else{this.background.visible=!0,this.foldedIndicator.visible=!1,this.foldedIndicator.position.set(0,0),this.updateBackground();const t=e.getRoomData(this.roomId);t&&await this.updateIcons(t)}}isFoldedState(){const t=Yi(),{foldable:e}=t.roomConfig.property;return!!e&&this.isFolded}updateFoldedIndicator(){const t=Yi().roomConfig,{tailHeight:e,tailWidth:i,backgroundColor:s}=t.property.container,n=this.calculateContentWidth(),r=Math.min(i,n/2);this.foldedIndicator.clear(),this.foldedIndicator.setFillStyle({color:s}),this.foldedIndicator.poly([0,e,r,e,r/2,0]).fill(),this.foldedIndicator.position.set(0,0)}refreshColor(){const t=Yi(),{propertyTheme:e}=t.roomConfig.colors,i=t.getRoomData(this.roomId),s=i?.colorIndex??this.roomIndex,n=e[s%e.length];if(this.propertyIcons.forEach(({sprite:t})=>{t.tint=n}),this.orderBackground&&this.orderBackground.visible){const{property:i}=t.roomConfig,n=i.iconWidth,r=i.iconHeight;this.orderBackground.clear(),this.orderBackground.setFillStyle({color:e[s%e.length]}),this.orderBackground.circle(n/2,r/2,n/2).fill()}}destroy(){this.propertyIcons.forEach(({sprite:t})=>{t.destroy()}),this.propertyIcons.clear(),super.destroy()}}class Gx extends Xn{background;checkmarkIcon;bubble;roomIndex;roomId;constructor(t){super();const e=Yi().roomConfig;this.roomId=t.id,this.roomIndex=t.index,this.background=new jl,this.bubble=new jl;const{colors:{selectionIndicatorIcon:i}}=e;this.checkmarkIcon=new Ry,this.checkmarkIcon.tint=i[t.index%i.length],this.checkmarkIcon.anchor.set(0,0),this.addChild(this.background),this.addChild(this.bubble),this.addChild(this.checkmarkIcon)}async updateIndicator(t){const e=Yi(),{roomSelectionMode:i,enableRoomSelection:s,selectRoomIds:n}=e.runtimeSnapshot;if(!s||"checkmark"!==i)return void(this.visible=!1);const r=n.includes(t.id);await this.showCheckmarkMode(r),this.updateBackground()}async showCheckmarkMode(t){const e=Yi(),{selectionIndicator:i}=e.roomConfig,{iconWidth:s,iconHeight:n}=i;if(t){this.visible=!0,this.checkmarkIcon.visible=!0,await this.checkmarkIcon.loadTextureAndSetSize("checkmark",{width:s,height:n,sizeFixed:!1});const t=i.containerWidth/2,e=i.containerHeight/2;this.checkmarkIcon.position.set(t-s/2,e-n/2)}else this.visible=!1}updateBackground(){const t=Yi(),{selectionIndicator:e,colors:i}=t.roomConfig,{containerWidth:s,containerHeight:n,strokeWidth:r,strokeColor:o,borderRadius:a,tailHeight:h,tailWidth:l}=e,c=t.getRoomData(this.roomId),d=c?.colorIndex??this.roomIndex,u=i.selectionIndicatorBackground[d%i.selectionIndicatorBackground.length],p="auto"===o?u:o;if(this.background.clear(),this.bubble.clear(),this.background.setFillStyle({color:u}).roundRect(0,0,s,n,a).fill().setStrokeStyle({color:p,width:r,alignment:0}).stroke(),h>0&&l>0){const t=(s-l)/2;this.bubble.setFillStyle({color:p});const e=n+r;this.bubble.poly([t,e-1,t+l,e-1,t+l/2,e+h]).fill()}}getTotalHeight(){const t=Yi(),{selectionIndicator:e}=t.roomConfig,{containerHeight:i,tailHeight:s,strokeWidth:n}=e;return i+n+(s>0?s:0)}getTotalWidth(){const t=Yi(),{selectionIndicator:e}=t.roomConfig;return e.containerWidth}async refreshColor(){const t=Yi().getRoomData(this.roomId);t&&await this.updateIndicator(t)}destroy(){this.checkmarkIcon?.destroy(),super.destroy()}}class Ux extends Xn{roomId;roomName;roomProperty=null;roomSelectionIndicator=null;clickHandler=null;unsubscribeMapRotation=null;targetElasticScale=1;currentElasticScale=1;isAnimatingScale=!1;scaleAnimationBound=null;updateScaleBound=null;constructor(t){super();const e=Yi();this.enableRenderGroup(),this.roomId=t.id,this.initializeElasticScale(e.currentScale),this.updateScaleBound=t=>this.updateScale(t),e.emitter.on("antiScale",this.updateScaleBound),this.updateScale(e.currentScale),t.centerPoint&&this.position.set(t.centerPoint.x,t.centerPoint.y),this.roomName=new Lx(t),this.roomName.visible=e.runtimeSnapshot.showRoomName,this.createRoomProperty(t),this.createRoomSelectionIndicator(t),this.updateLayout(),this.applyAntiRotation(e.runtime.mapRotation),this.unsubscribeMapRotation=Xi(e.runtime,"mapRotation",t=>{this.applyAntiRotation(t)}),this.clickHandler=new Ty(this,{onClick:()=>{e.events?.onClickRoomProperties?.(t)}})}applyAntiRotation(t){const e=-t*Math.PI/180;this.rotation=e}initializeElasticScale(t){const e=Yi(),{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=e.roomConfig;if(!i)return;let r;r=t<=1?s:t>=5?n:1,this.targetElasticScale=r,this.currentElasticScale=r}updateScale(t){const e=Yi(),{enableElasticScale:i,elasticMinScale:s,elasticMaxScale:n}=e.roomConfig;if(!i)return void(0!==t&&this.scale.set(1/t));if(0===t)return;let r;r=t<=1?s:t>=5?n:1;const o=1/t*r;Math.abs(this.targetElasticScale-r)>.01?(this.targetElasticScale=r,this.startScaleAnimation()):this.scale.set(o)}startScaleAnimation(){const t=Yi();this.scaleAnimationBound||(this.scaleAnimationBound=this.animateScale.bind(this)),this.isAnimatingScale||(this.isAnimatingScale=!0,t.getApp().ticker.add(this.scaleAnimationBound))}animateScale(){const t=Yi();this.currentElasticScale+=.3*(this.targetElasticScale-this.currentElasticScale);const e=1/t.currentScale*this.currentElasticScale;this.scale.set(e),Math.abs(this.currentElasticScale-this.targetElasticScale)<.001&&(this.currentElasticScale=this.targetElasticScale,this.isAnimatingScale=!1,this.scaleAnimationBound&&t.getApp().ticker.remove(this.scaleAnimationBound))}shouldShowRoomProperty(){const t=Yi(),{showRoomOrder:e,showRoomProperty:i,selectRoomIds:s,enableRoomSelection:n,roomSelectionMode:r}=t.runtimeSnapshot,o=t.getRoomData(this.roomId);if(!o)return!1;if(n&&"checkmark"===r&&s.includes(this.roomId))return!1;const a=e&&(o.order||0)>0;let h=!1;if(i){const{displayOrders:e}=t.roomConfig.property;h=e.some(t=>"suction"===t&&null!=o.suction||"cistern"===t&&null!=o.cistern||"cleanMode"===t&&null!=o.cleanMode||"cleanTimes"===t&&o.cleanTimes>0||!(!o.customData||!(t in o.customData)||"number"!=typeof o.customData[t]||null==o.customData[t]))}return a||h}shouldShowRoomSelectionIndicator(){const t=Yi(),{enableRoomSelection:e,roomSelectionMode:i}=t.runtimeSnapshot;return e&&"checkmark"===i}async updateRoomPropertyVisibility(){const t=Yi();if(this.roomProperty){if(this.shouldShowRoomProperty()){this.roomProperty.visible=!0;const e=t.runtimeSnapshot.roomPropertyFoldIds.includes(this.roomId);await this.roomProperty.setFolded(e);const i=t.getRoomData(this.roomId);i&&await this.roomProperty.updateProperty(i)}else this.roomProperty.visible=!1;this.updateLayout()}}async updateRoomSelectionIndicatorVisibility(){const t=Yi();if(this.roomSelectionIndicator){if(this.shouldShowRoomSelectionIndicator()){const e=t.getRoomData(this.roomId);e&&await this.roomSelectionIndicator.updateIndicator(e)}else this.roomSelectionIndicator.visible=!1;this.updateLayout()}}async createRoomProperty(t){this.roomProperty&&(this.removeChild(this.roomProperty),this.roomProperty.destroy()),this.roomProperty=new jx(t),await this.roomProperty.updateProperty(t),this.addChild(this.roomProperty),this.addChild(this.roomName),await this.updateRoomPropertyVisibility(),this.updateLayout()}async createRoomSelectionIndicator(t){this.roomSelectionIndicator&&(this.removeChild(this.roomSelectionIndicator),this.roomSelectionIndicator.destroy()),this.roomSelectionIndicator=new Gx(t),await this.updateRoomSelectionIndicatorVisibility(),this.addChild(this.roomSelectionIndicator)}updateLayout(){const t=Yi(),{property:{offsetY:e,offsetX:i},selectionIndicator:{offsetY:s,offsetX:n}}=t.roomConfig,r=this.roomProperty?.visible||!1,o=this.roomName.visible,a=this.roomSelectionIndicator?.visible||!1;if(r&&this.roomProperty){const t=this.roomProperty.getTotalHeight(),s=this.roomProperty.getTotalWidth();if(this.roomProperty.isFoldedState()){const n=-s/2+i,r=-t/2-e;this.roomProperty.position.set(n,r)}else o?(this.roomProperty.position.set(-s/2+i,-e-t),this.roomName.position.set(0,0)):this.roomProperty.position.set(-s/2+i,-t/2-e)}if(a&&this.roomSelectionIndicator){const t=this.roomSelectionIndicator.getTotalHeight(),e=this.roomSelectionIndicator.getTotalWidth();o?(this.roomSelectionIndicator.position.set(-e/2+n,-s-t),this.roomName.position.set(0,0)):this.roomSelectionIndicator.position.set(-e/2+n,-t/2-s)}!o||r||a||this.roomName.position.set(0,0)}updateName(t){this.roomName.updateName(t)}updateRoomNameVisibility(t){this.roomName.visible=t,this.updateLayout()}updatePosition(t){this.position.set(t.x,t.y)}async refreshColor(){this.roomName&&this.roomName.refreshColor(),this.roomProperty&&this.roomProperty.refreshColor(),this.roomSelectionIndicator&&await this.roomSelectionIndicator.refreshColor()}destroy(){const t=Yi();this.clickHandler?.destroy(),this.clickHandler=null,this.unsubscribeMapRotation&&(this.unsubscribeMapRotation(),this.unsubscribeMapRotation=null),this.isAnimatingScale&&this.scaleAnimationBound&&(t.getApp().ticker.remove(this.scaleAnimationBound),this.isAnimatingScale=!1),this.scaleAnimationBound=null,this.updateScaleBound&&(t.emitter.off("antiScale",this.updateScaleBound),this.updateScaleBound=null),this.roomProperty?.destroy(),this.roomProperty=null,this.roomSelectionIndicator?.destroy(),this.roomSelectionIndicator=null,this.roomName?.destroy(),super.destroy()}}class zx extends Xn{floorTypeMap=new Map;floorTypeMasks=new Map;floorTypeToRooms=new Map;constructor(){super({isRenderGroup:!0}),Yi().appContainer.addToLayer(py,this)}async createFloorTypes(t){if(!Yi().runtimeSnapshot.showRoomFloorType)return;this.clearFloorTypes();const e=this.groupRoomsByFloorType(t),i=[];for(const[t,s]of e)i.push(this.createMergedFloorType(t,s));await Promise.all(i)}groupRoomsByFloorType(t){const e=new Map,i=Yi();return t.forEach((t,s)=>{const n=i.getRoomData(s),r=n?.floorType||0;r>=0&&(e.has(r)||e.set(r,[]),e.get(r).push({roomId:s,graphics:t}))}),e}async createMergedFloorType(t,e){const i=Yi(),{assets:s,opacity:n,scale:r}=i.roomConfig.floorType,o=t%s.length,a=`floorType${o}`;if(!s[o])return void ag.warn(`No texture asset configured for floorType: ${t}`);const h=await gl.load(a);if(!h)return void ag.warn(`Floor material texture not found: ${a}`);const l=(t=>{if(0===t.length)return{x:0,y:0,width:0,height:0};let e=t[0].x,i=t[0].y,s=t[0].x+t[0].width,n=t[0].y+t[0].height;return t.forEach(t=>{e=Math.min(e,t.x),i=Math.min(i,t.y),s=Math.max(s,t.x+t.width),n=Math.max(n,t.y+t.height)}),{x:e,y:i,width:s-e,height:n-i}})(e.map(({graphics:t})=>t.getLocalBounds())),c=new Wl({texture:h,width:l.width,height:l.height});c.x=l.x,c.y=l.y,c.alpha=n,c.tileScale.set(r);const d=this.createMergedMask(e.map(({graphics:t})=>t));c.mask=d,this.addChild(c),this.floorTypeMap.set(t,c),this.floorTypeMasks.set(t,d),this.floorTypeToRooms.set(t,new Set(e.map(({roomId:t})=>t)))}createMergedMask(t){const e=new Xn;return t.forEach(t=>{const i=new jl;i.context=t.context.clone(),e.addChild(i)}),e}clearFloorTypes(){this.floorTypeMap.forEach(t=>{try{this.removeChild(t),t.destroy()}catch(t){ag.warn("Error destroying floor material:",t)}}),this.floorTypeMap.clear(),this.floorTypeMasks.forEach(t=>{try{t.destroy()}catch(t){ag.warn("Error destroying floor mask:",t)}}),this.floorTypeMasks.clear(),this.floorTypeToRooms.clear()}destroy(){this.clearFloorTypes(),super.destroy()}}class Nx{unsubscribeFns=[];roomInfoContainer=new Xn;roomInfoMap=new Map;roomDisplayMap=new Map;roomFloorType=new zx;constructor(){const t=Yi();t.appContainer.addToLayer(by,this.roomInfoContainer);const e=Xi(t.runtime,"showRoomFloorType",t=>{ag.log(`[runtime] showRoomFloorType: ${t}`),t?this.updateFloorTypes():this.roomFloorType.clearFloorTypes()}),i=Xi(t.runtime,"showRoomProperty",t=>{ag.log(`[runtime] showRoomProperty: ${t}`),this.updateAllRoomPropertyVisibility()}),s=Xi(t.runtime,"showRoomOrder",t=>{ag.log(`[runtime] showRoomOrder: ${t}`),this.updateAllRoomPropertyVisibility()}),n=Xi(t.runtime,"roomPropertyFoldIds",t=>{ag.log(`[runtime] roomPropertyFoldIds: ${t}`),this.updateAllRoomPropertyVisibility()}),r=Xi(t.runtime,"showRoomName",t=>{ag.log(`[runtime] showRoomName: ${t}`),this.updateAllRoomNameVisibility(t)}),o=Xi(t.runtime,"enableRoomSelection",t=>{ag.log(`[runtime] enableRoomSelection: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),a=Xi(t.runtime,"selectRoomIds",t=>{ag.log(`[runtime] selectRoomIds: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()}),h=Xi(t.runtime,"roomSelectionMode",t=>{ag.log(`[runtime] roomSelectionMode: ${t}`),this.updateAllRoomPropertyVisibility(),this.updateAllRoomSelectionIndicatorVisibility()});this.unsubscribeFns.push(e,i,s,n,r,o,a,h)}async drawRoomProperty(t){const e=Yi();return this.roomDisplayMap.clear(),t.forEach((t,i)=>{const s=e.mapManager.getRoomById(t.id),n={...t,centerPoint:s?.centerPoint||null,index:i,colorIndex:s?.colorIndex};this.roomDisplayMap.set(t.id,n)}),await this.updateRoomInfoDisplay(),this.updateFloorTypes(),!0}async updateRoomInfoDisplay(){if(0===this.roomDisplayMap.size)return void(0===Yi().mapManager.getAllRooms().length&&this.clearRoomInfos());const t=Array.from(this.roomDisplayMap.values()).filter(t=>null!==t.centerPoint);this.clearRoomInfos(),await Promise.all(t.map(t=>this.createRoomInfo(t)))}async createRoomInfo(t){const e=new Ux(t);this.roomInfoContainer.addChild(e),this.roomInfoMap.set(t.id,e)}updateRoomName(t,e){const i=this.roomInfoMap.get(t);i&&i.updateName(e)}updateRoomPosition(t,e){const i=this.roomDisplayMap.get(t);i&&(i.centerPoint=e);const s=this.roomInfoMap.get(t);s&&s.updatePosition(e)}clearRoomInfos(){this.roomInfoMap.forEach(t=>{t.destroy()}),this.roomInfoMap.clear(),this.roomInfoContainer.removeChildren()}getRoomPropertyById(t){return this.roomDisplayMap.get(t)}async refresh(){const t=Yi();this.roomFloorType.clearFloorTypes(),this.roomDisplayMap.forEach((e,i)=>{const s=t.mapManager.getRoomById(i),n=s?.centerPoint||null;if(e.centerPoint!==n){e.centerPoint=n;const t=this.roomInfoMap.get(i);t&&n&&t.updatePosition(n)}const r=s?.colorIndex;if(e.colorIndex!==r&&void 0!==r){e.colorIndex=r;const t=this.roomInfoMap.get(i);t&&t.refreshColor()}}),await this.updateRoomInfoDisplay(),this.updateFloorTypes()}async updateAllRoomPropertyVisibility(){0!==this.roomInfoMap.size&&await Promise.all(Array.from(this.roomInfoMap.values()).map(async t=>{try{await t.updateRoomPropertyVisibility()}catch(t){}}))}updateAllRoomNameVisibility(t){0!==this.roomInfoMap.size&&this.roomInfoMap.forEach(e=>{e.updateRoomNameVisibility(t)})}updateAllRoomSelectionIndicatorVisibility(){0!==this.roomInfoMap.size&&this.roomInfoMap.forEach(t=>{t.updateRoomSelectionIndicatorVisibility()})}async updateFloorTypes(){const t=Yi(),e=t.mapManager.roomFill.getRoomGraphicsMap();e.size>0?(await this.roomFloorType.createFloorTypes(e),t.getApp().renderOnceNextFrame()):0===t.mapManager.getAllRooms().length&&this.roomFloorType.clearFloorTypes()}clear(){this.clearRoomInfos(),this.roomInfoContainer.removeChildren(),this.roomInfoMap.clear(),this.roomDisplayMap.clear(),this.roomFloorType.clearFloorTypes()}destroy(){this.clearRoomInfos(),this.roomInfoContainer.destroy(),this.roomFloorType.destroy(),this.unsubscribeFns.forEach(t=>t()),this.unsubscribeFns=[]}}navigator?.userAgent?.includes("tuya-ark-ide")||navigator?.userAgent?.includes("miniProgram");const Vx=()=>{if(!Nr.any)return!0;const t=navigator.userAgent.toLowerCase();let e=!1;if(/iphone|ipad|ipod/.test(t)){const i=t.match(/os (\d+)_/)?.[1];e=(i?parseInt(i):0)>=12}else if(/android/.test(t)){const i=t.match(/android (\d+)/)?.[1];e=(i?parseInt(i):0)>=10}return e&&(()=>{const t=navigator.deviceMemory;return!t||t>=4})()};class Hx extends Oo{mapState=null;components={};managers={};config=iy;runtime;scaleMin=.5;scaleMax=5;events={};instanceKey;containerElement;emitter=function(t){return{all:t=t||new Map,on:function(e,i){var s=t.get(e);s?s.push(i):t.set(e,[i])},off:function(e,i){var s=t.get(e);s&&(i?s.splice(s.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var s=t.get(e);s&&s.slice().map(function(t){t(i)}),(s=t.get("*"))&&s.slice().map(function(t){t(e,i)})}}}();tickerState={renderReasons:new Set,renderTimer:null};pendingAsyncRender=!1;isFirstMapDraw=!0;constructor(t=oy){super(),this.instanceKey=t,hy.registerInstance(t,this),globalThis.__PIXI_APP__=this}async initialize(t){return hy.provideAsync(this,async()=>{const{resizeTo:e,events:i,config:s,runtime:n={},...r}=t;this.config=Fm(this.config,s??{},(t,e)=>{if(Array.isArray(e))return e}),ag.log("Applying config",this.config,s),this.runtime=Zi(Object.assign({},sy,n));const o=this.instanceKey===oy;this.containerElement=e;const a=o?{textureGCMaxIdle:Nr.any?180:3600,textureGCCheckCountMax:Nr.any?100:50,autoStart:!1,eventFeatures:{move:!0,globalMove:!1,click:!0,wheel:!0}}:{textureGCMaxIdle:60,textureGCCheckCountMax:10,autoStart:!1,eventFeatures:{move:!1,globalMove:!1,click:!1,wheel:!1}};await this.init({resizeTo:o?e:void 0,preferWebGLVersion:2,resolution:window.devicePixelRatio||1,antialias:Vx(),autoDensity:!0,backgroundColor:this.config.global.backgroundColor,backgroundAlpha:this.config.global.backgroundAlpha,...a,...r}),this.preloadAssets(),this.scaleMax=this.config.interaction.zoomRange.max,this.scaleMin=this.config.interaction.zoomRange.min,this.events=i,this.initializeViewportContainer(),this.initializeInteraction(),this.initializeAppContainer(),this.managers.mapManager=new Fy,this.managers.heatmapManager=new Wy,this.managers.pathManager=new Vy,this.managers.controlsManager=new dx,this.managers.detectedObjectManager=new px,this.managers.customElementsManager=new Fx,this.managers.roomsManager=new Nx,this.setupMapRotationListener(),document.addEventListener("visibilitychange",this.onVisibilityChange)})}async drawMap(t){return hy.provideAsync(this,async()=>{ag.log("[Map] drawMap",t);const{size:e,resolution:i,origin:s}=t;s[0]===this.mapState?.origin.x&&s[1]===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(...s),this.managers.controlsManager.updatePositionByOrigin(...s),this.managers.detectedObjectManager.updatePositionByOrigin(...s),this.managers.customElementsManager.updatePositionByOrigin(...s)),this.mapState={id:t.id,status:1===t.status,origin:{x:s[0],y:s[1]},charger:{x:t.charger.coordinate[0],y:t.charger.coordinate[1]},chargerDirection:t.charger.angle??0,resolution:i,width:e[0],height:e[1],mapType:"structured"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawMap(t),0!==e[0]&&0!==e[1]||(ag.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear()),this.renderOnce()})}async drawRasterMap(t){return hy.provideAsync(this,async()=>{ag.log("[Map] drawRasterMap",t);const{mapHeader:e,mapData:i}=t,{originX:s,originY:n}=e;s===this.mapState?.origin.x&&n===this.mapState?.origin.y||(this.managers.pathManager.updatePositionByOrigin(s,n),this.managers.controlsManager.updatePositionByOrigin(s,n),this.managers.detectedObjectManager.updatePositionByOrigin(s,n),this.managers.customElementsManager.updatePositionByOrigin(s,n)),this.mapState={id:e.id,status:e.mapStable,origin:{x:s,y:n},charger:{x:e.chargeX,y:e.chargeY},chargerDirection:e.chargeDirection??0,resolution:100*e.mapResolution,width:e.mapWidth,height:e.mapHeight,version:e.version,mapType:"raster"},this.isFirstMapDraw&&(this.isFirstMapDraw=!1,this.events?.onMapFirstDrawed?.(this.mapState)),this.events?.onMapDrawed?.(this.mapState),await this.managers.mapManager.drawRasterMap(i.parsed,this.mapState),0!==e.mapWidth&&0!==e.mapHeight||(ag.log("[Map] Map cleared, clearing path and room data"),this.managers.pathManager.clear(),this.managers.roomsManager.clear()),this.renderOnce()})}drawPath(t){return hy.provide(this,()=>{ag.log("[Path] drawPath",t),this.events?.onPathDrawed?.({id:t.pathHeader.pathId,type:t.pathHeader.type,direction:t.pathHeader.direction,count:t.pathHeader.count,initFlag:t.pathHeader.initFlag,robotPosition:t.pathPoints[t.pathPoints.length-1]??null}),this.managers.pathManager.draw(t),this.renderOnce()})}async drawRoomProperty(t){return hy.provideAsync(this,async()=>{ag.log("[Room] drawRoomProperty",t),this.events?.onRoomPropertiesDrawed?.(t),await this.managers.roomsManager.drawRoomProperty(t),this.renderOnceNextFrame()})}drawHeatmap({mapData:t,heatmapPoints:e,useGradient:i=!0}){return hy.provide(this,()=>{ag.log("[Heatmap] drawHeatmap",e),this.managers.heatmapManager.draw({mapData:t,heatmapPoints:e,useGradient:i}),this.renderOnce()})}drawForbiddenSweepZones(t){return hy.provide(this,()=>{ag.log("[Controls] drawForbiddenSweepZones",t),this.managers.controlsManager.drawForbiddenSweepZones(t),this.renderOnceNextFrame()})}drawForbiddenMopZones(t){return hy.provide(this,()=>{ag.log("[Controls] drawForbiddenMopZones",t),this.managers.controlsManager.drawForbiddenMopZones(t),this.renderOnceNextFrame()})}drawCleanZones(t){return hy.provide(this,()=>{ag.log("[Controls] drawCleanZones",t),this.managers.controlsManager.drawCleanZones(t),this.renderOnceNextFrame()})}drawVirtualWalls(t){return hy.provide(this,()=>{ag.log("[Controls] drawVirtualWalls",t),this.managers.controlsManager.drawVirtualWalls(t),this.renderOnceNextFrame()})}drawSpots(t){return hy.provide(this,()=>{ag.log("[Controls] drawSpots",t),this.managers.controlsManager.drawSpots(t),this.renderOnceNextFrame()})}drawWayPoints(t){return hy.provide(this,()=>{ag.log("[Controls] drawWayPoints",t),this.managers.controlsManager.drawWayPoints(t),this.renderOnceNextFrame()})}async drawDetectedObjects(t){return hy.provideAsync(this,async()=>{ag.log("[DetectedObject] drawDetectedObjects",t),await this.managers.detectedObjectManager.drawDetectedObjects(t),this.renderOnceNextFrame()})}async drawCustomElements(t){return hy.provideAsync(this,async()=>{ag.log("[CustomElements] drawCustomElements",t),await this.managers.customElementsManager.drawCustomElements(t),this.renderOnceNextFrame()})}getForbiddenSweepZones(){return this.managers.controlsManager.getForbiddenSweepZones()}getForbiddenMopZones(){return this.managers.controlsManager.getForbiddenMopZones()}getCleanZones(){return this.managers.controlsManager.getCleanZones()}getVirtualWalls(){return this.managers.controlsManager.getVirtualWalls()}getSpots(){return this.managers.controlsManager.getSpots()}getWayPoints(){return this.managers.controlsManager.getWayPoints()}getEffectiveDividerPoints(){return this.managers.controlsManager.getEffectiveDividerPoints()}getDividerEndPoints(){return this.managers.controlsManager.getDividerEndPoints()}resetPanZoom(){this.components.interaction.setPanZoom()}fitMapToView(t,e=!1){return hy.provide(this,()=>{if(!t||t.minX===t.maxX||t.minY===t.maxY)return;const i=this.config.map.autoPaddingVerticalPercent,s=this.config.map.autoPaddingHorizontalPercent,n=this.getViewportBounds(),r=this.components.appContainer.getMapRotationRadians(),o=this.calculateRotatedBounds(t,r),a=o.maxX-o.minX,h=o.maxY-o.minY,l=n.width,c=n.height,d=l*(1-2*s)/a,u=c*(1-2*i)/h,p=Math.min(d,u),g=Math.max(this.config.interaction.fitMinScale,this.scaleMin),f=Math.min(this.config.interaction.fitMaxScale,this.scaleMax),m=Math.max(g,Math.min(f,p)),y=t.minX+(t.maxX-t.minX)/2,x=t.minY+(t.maxY-t.minY)/2,b=l/2,v=c/2,_=Math.cos(r),w=Math.sin(r),A=b-(y*_-x*w)*m,C=v-(y*w+x*_)*m;ag.debug("[MapApplication] fitMapToView calculated:",{rotation:this.components.appContainer.getMapRotation(),originalBounds:t,rotatedBounds:o,finalScale:m,position:{x:A,y:C}}),this.components.interaction.setPanZoom({targetPosition:{x:A,y:C},targetScale:{x:m,y:m},setCenter:!0,setScale:!0},e)})}calculateRotatedBounds(t,e){if(0===e)return t;const i=(t.minX+t.maxX)/2,s=(t.minY+t.maxY)/2,n=[{x:t.minX-i,y:t.minY-s},{x:t.maxX-i,y:t.minY-s},{x:t.maxX-i,y:t.maxY-s},{x:t.minX-i,y:t.maxY-s}],r=Math.cos(e),o=Math.sin(e),a=n.map(t=>({x:t.x*r-t.y*o,y:t.x*o+t.y*r}));let h=1/0,l=1/0,c=-1/0,d=-1/0;return a.forEach(t=>{h=Math.min(h,t.x),l=Math.min(l,t.y),c=Math.max(c,t.x),d=Math.max(d,t.y)}),{minX:h+i,minY:l+s,maxX:c+i,maxY:d+s}}getViewportBounds(){return this.components.viewportContainer?.getViewportBounds()||{x:0,y:0,width:this.renderer.width,height:this.renderer.height}}updateRuntime(t){Object.assign(this.runtime,t),ag.log("[runtime] runtime updated",t),this.renderOnceNextFrame()}metersToPixels(t){return this.mapState?.resolution?t*(1/(this.mapState.resolution/100)):(ag.warn("Map resolution not available, using default resolution (5cm/pixel)"),20*t)}pixelsToMeters(t){return this.mapState?.resolution?t*(this.mapState.resolution/100):(ag.warn("Map resolution not available, using default resolution (5cm/pixel)"),.05*t)}toFixedSize(t,e){return t/(e??this.components.appContainer.scale.x)}fromFixedSize(t,e){return t*(e??this.components.appContainer.scale.x)}getViewportCenterPoint(){if(!this.mapState)return ag.warn("Map state not available, cannot calculate center point"),null;const t=this.getViewportBounds(),e=t.x+t.width/2,i=t.y+t.height/2,s=this.components.appContainer,n=s.scale.x,r=s.getMapRotationRadians(),o=(e-s.x)/n,a=(i-s.y)/n,h=Math.cos(r),l=Math.sin(r),c=-o*l+a*h;return{x:o*h+a*l-this.mapState.origin.x,y:c-this.mapState.origin.y}}getMapCenterPoint(){if(!this.mapState)return ag.warn("Map state not available, cannot calculate map center point"),null;const t=this.managers.mapManager.mapBounds;if(t.minX===1/0||t.minY===1/0||t.maxX===-1/0||t.maxY===-1/0)return ag.warn("Invalid map bounds, cannot calculate map center point"),null;const e=(t.minX+t.maxX)/2,i=(t.minY+t.maxY)/2;return{x:e-this.mapState.origin.x,y:i-this.mapState.origin.y}}getWallPointsByViewportCenter(t){const{width:e=this.config.controls.virtualWall.minWidth,direction:i="horizontal",offsetX:s=0,offsetY:n=0}=t||{},r=this.getViewportCenterPoint()||{x:0,y:0},o=this.metersToPixels(e);return jg(r.x,r.y,o,i).map(t=>({x:t.x+s,y:t.y+n}))}getForbiddenSweepZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenSweepZone,{size:i=e.minSize,offsetX:s=0,offsetY:n=0}=t||{};return this.generateZonePoints(i,s,n)}getForbiddenMopZonePointsByViewportCenter(t){const e=this.config.controls.forbiddenMopZone,{size:i=e.minSize,offsetX:s=0,offsetY:n=0}=t||{};return this.generateZonePoints(i,s,n)}getCleanZonePointsByViewportCenter(t){const e=this.config.controls.cleanZone,{size:i=e.minSize,offsetX:s=0,offsetY:n=0}=t||{};return this.generateZonePoints(i,s,n)}getSpotPointByViewportCenter(t){const{offsetX:e=0,offsetY:i=0}=t||{},s=this.getViewportCenterPoint()||{x:0,y:0};return{x:s.x+e,y:s.y+i}}areRoomsAdjacent(t){return hy.provide(this,()=>t&&0!==t.length?this.managers.mapManager.areRoomsAdjacent(t):(ag.warn("[Room] No room IDs provided"),!1))}isPointInAnyRoom(t){return hy.provide(this,()=>t&&"number"==typeof t.x&&"number"==typeof t.y?this.mapState?this.managers.mapManager.isPointInAnyRoom(t):(ag.warn("[Room] Map state not available"),null):(ag.warn("[Room] Invalid point provided"),null))}isWallIntersectsAnyRoom(t){return hy.provide(this,()=>t&&2===t.length&&t[0]&&t[1]&&"number"==typeof t[0].x&&"number"==typeof t[0].y&&"number"==typeof t[1].x&&"number"==typeof t[1].y?this.mapState?this.managers.mapManager.isWallIntersectsAnyRoom(t):(ag.warn("[Room] Map state not available"),!1):(ag.warn("[Room] Invalid wall points provided"),!1))}isZoneIntersectsAnyRoom(t){return hy.provide(this,()=>t&&4===t.length&&t[0]&&t[1]&&t[2]&&t[3]&&"number"==typeof t[0].x&&"number"==typeof t[0].y&&"number"==typeof t[1].x&&"number"==typeof t[1].y&&"number"==typeof t[2].x&&"number"==typeof t[2].y&&"number"==typeof t[3].x&&"number"==typeof t[3].y?this.mapState?this.managers.mapManager.isZoneIntersectsAnyRoom(t):(ag.warn("[Room] Map state not available"),!1):(ag.warn("[Room] Invalid zone points provided"),!1))}isNearChargerOrRobot(t,e,i){return hy.provide(this,()=>{if(!t||t.length<1)return ag.warn("[Distance] Invalid points array: must have at least 1 point"),!1;if(1!==t.length&&2!==t.length&&4!==t.length)return ag.warn("[Distance] Invalid points array: must have exactly 1 (point), 2 (wall) or 4 (zone) points"),!1;if(e<=0)return ag.warn("[Distance] Invalid threshold: must be greater than 0"),!1;if(!this.mapState)return ag.warn("[Distance] Map state not available"),!1;const{checkCharger:s=!0,checkRobot:n=!1}=i||{};if(!s&&!n)return ag.warn("[Distance] At least one of checkCharger or checkRobot must be true"),!1;const r=this.metersToPixels(e);if(s){const e=hy.getService().getChargerPosition();if(e){const i=fg(e,t);if(i<=r)return ag.log(`[Distance] Too close to charger: ${i.toFixed(2)} pixels (threshold: ${r.toFixed(2)} pixels)`),!0}else ag.warn("[Distance] Charger position not available")}if(n){const e=hy.getService().getRobotPosition();if(e){const i=fg(e,t);if(i<=r)return ag.log(`[Distance] Too close to robot: ${i.toFixed(2)} pixels (threshold: ${r.toFixed(2)} pixels)`),!0}else ag.warn("[Distance] Robot position not available")}return!1})}async snapshot(){this.render(),await new Promise(t=>setTimeout(t,0));const{snapshot:t}=this.config;return await this.renderer.extract.base64({target:this.components.appContainer,format:t.format,quality:t.quality,resolution:t.resolution,antialias:t.antialias})}async snapshotByData({map:t,path:e,roomProperties:i,customElements:s,forbiddenSweepZones:n,forbiddenMopZones:r,virtualWalls:o,detectedObjects:a},h={}){const l=`SNAPSHOT_${((t=21)=>{let e="",i=0|t;for(;i--;)e+="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict"[64*Math.random()|0];return e})()}`;ag.log(`[MapApplication] ${l} snapshot start`);const c=new Hx(l);try{if(await c.initialize({config:this.config,runtime:h}),!t)throw new Error("Map data is required");if(t.startsWith("7b22")){const e=qp(t);await c.drawMap(e)}else{const e=$p(t,{pointsStructured:!0});if(!e)throw new Error("Failed to decode raster map data");await c.drawRasterMap(e)}if(e){const{decodePath:t}=await Promise.resolve().then(()=>ng),i=t(e);c.drawPath(i)}i&&i.length>0&&await c.drawRoomProperty(i),n&&n.length>0&&c.drawForbiddenSweepZones(n),r&&r.length>0&&c.drawForbiddenMopZones(r),o&&o.length>0&&c.drawVirtualWalls(o),a&&a.length>0&&await c.drawDetectedObjects(a),s&&s.length>0&&await c.drawCustomElements(s);const d=await c.snapshot();return ag.log(`[MapApplication] ${l} snapshot completed successfully`),d}catch(t){throw ag.error(`[MapApplication] ${l} snapshot other map failed:`,t),t}finally{ag.log(`[MapApplication] ${l} destroy`),c.destroy()}}renderOnce(){ag.log("[Pixi] renderOnce"),this.render()}renderOnceNextFrame(){this.pendingAsyncRender||(this.pendingAsyncRender=!0,requestAnimationFrame(()=>{ag.log("[Pixi] renderOnceNextFrame"),this.render(),this.pendingAsyncRender=!1}))}requestRender(t,e=!1){e?(this.tickerState.renderReasons.add(t),this.ticker.started||(ag.debug(`🎬 [Ticker] START: ${t}`),this.ticker.start())):this.renderOnceNextFrame()}stopRender(t){this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&this.scheduleStopRender("final",100)}destroy(){this.tickerState.renderTimer&&(clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=null),this.tickerState.renderReasons.clear(),this.emitter.all.clear(),document.removeEventListener("visibilitychange",this.onVisibilityChange),this.managers.pathManager.destroy(),this.managers.mapManager.destroy(),this.managers.controlsManager.destroy(),this.managers.detectedObjectManager.destroy(),this.managers.customElementsManager.destroy(),this.managers.roomsManager.destroy(),this.components.interaction.destroy(),this.components.viewportContainer.destroy(),this.components.appContainer.destroy(),super.destroy(),hy.unregisterInstance(this.instanceKey)}initializeViewportContainer(){this.components.viewportContainer=new cy(this.config,this.containerElement),this.stage.addChild(this.components.viewportContainer)}initializeAppContainer(){this.components.appContainer=new Iy,this.components.interaction.addChild(this.components.appContainer)}initializeInteraction(){this.components.interaction=new $m,this.components.viewportContainer.addChild(this.components.interaction)}scheduleStopRender(t,e){this.tickerState.renderTimer&&clearTimeout(this.tickerState.renderTimer),this.tickerState.renderTimer=setTimeout(()=>{this.tickerState.renderReasons.delete(t),0===this.tickerState.renderReasons.size&&(ag.debug("⏸️ [Ticker] STOP"),this.ticker&&this.ticker.stop())},e)}generateZonePoints(t,e,i){const s=this.getViewportCenterPoint()||{x:0,y:0},n=this.metersToPixels(t)/2,r=s.x+e,o=s.y+i;return[{x:r-n,y:o-n},{x:r+n,y:o-n},{x:r+n,y:o+n},{x:r-n,y:o+n}]}preloadAssets(){const t=this.config.robot.icon.src,e=this.config.chargingStation.icon.src,i=[];gl.add({alias:"robot",src:t}),i.push("robot"),gl.add({alias:"chargingStation",src:e}),i.push("chargingStation"),gl.add({alias:"deleteIcon",src:this.config.controls.deleteIconSrc}),i.push("deleteIcon"),gl.add({alias:"rotateIcon",src:this.config.controls.rotateIconSrc}),i.push("rotateIcon"),gl.add({alias:"scaleIcon",src:this.config.controls.scaleIconSrc}),i.push("scaleIcon"),gl.add({alias:"moveIcon",src:this.config.controls.moveIconSrc}),i.push("moveIcon"),gl.add({alias:"checkmark",src:this.config.room.selectionIndicator.iconSrc}),i.push("checkmark"),gl.add({alias:"spotIcon",src:this.config.controls.spot.iconSrc}),i.push("spotIcon"),gl.add({alias:"wayPoint",src:this.config.controls.wayPoint.normal.iconSrc}),i.push("wayPoint"),gl.add({alias:"wayPointActive",src:this.config.controls.wayPoint.editing.iconSrc}),i.push("wayPointActive"),this.config.room.property.cleanMode.assets.forEach((t,e)=>{const s=`cleanMode_${e}`;gl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.suction.assets.forEach((t,e)=>{const s=`fan_${e}`;gl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.cistern.assets.forEach((t,e)=>{const s=`water_${e}`;gl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.cleanTimes.assets.forEach((t,e)=>{const s=`cleanTimes${e+1}`;gl.add({alias:s,src:t}),i.push(s)}),this.config.room.floorType.assets.forEach((t,e)=>{if(!t)return;const s=`floorType${e}`;gl.add({alias:s,src:t}),i.push(s)}),this.config.room.property.customAssets&&Object.entries(this.config.room.property.customAssets).forEach(([t,e])=>{e.forEach((e,s)=>{const n=`custom_${t}_${s}`;gl.add({alias:n,src:e}),i.push(n)})}),gl.backgroundLoad(i)}setupMapRotationListener(){this.applyMapRotation(this.runtime.mapRotation),Xi(this.runtime,"mapRotation",t=>{hy.provide(this,()=>{this.applyMapRotation(t)})})}applyMapRotation(t){const e=(t%360+360)%360;ag.log(`[MapApplication] Applying map rotation: ${e}°`),this.components.appContainer.setMapRotation(e);const i=this.managers.mapManager.mapBounds;i&&i.minX!==1/0&&i.maxX!==-1/0&&this.fitMapToView(i,!1),this.renderOnce()}onVisibilityChange=()=>{"visible"===document.visibilityState||this.components.interaction?.clearTouches()}}es.add(Hr),es.mixin(Xn,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1}),es.add(Do),es.add(Fo),es.add(Ml),es.mixin(Xn,Tl),es.add(yl),es.add(Hu),es.add(ih),es.add(Yu),es.add(ip),es.add(sp),es.add(Rp),es.add(Bp),es.add(Cp),es.add(Pp),es.add(Ip),es.add(fp),es.add(ap),es.add(Dl),es.add(Bl);const Wx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Jx=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));export{hy as AppContext,ny as MAP_API_METHODS,ry as MAP_CALLBACK_METHODS,Hx as MapApplication,rg as decodeRoomProperties,og as offsetPointsToAvoidOverlap,Yi as useAppService};