From 3c41482c5694cb4a24fc8ccd6a0f948941a723db Mon Sep 17 00:00:00 2001 From: prismiwi2015 Date: Mon, 27 Jul 2026 16:49:17 +0200 Subject: [PATCH 01/12] Add a canvas stage that renders the desktop through HTML-in-Canvas MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Puts the whole shell inside a `` and mirrors it into a PixiJS texture via the experimental HTML-in-Canvas API, so fragment shaders can post-process every pixel of the desktop at once. Ships three effects — scanlines, a CRT tube, and pixel art — behind a new OS Settings → Experimental tab, switchable live. The shell is moved, not cloned. `layoutsubtree` keeps the canvas's direct children laid out, hit-tested and in the accessibility tree, so windows, iframes, text fields and links keep working untouched: the canvas is a display surface, never an input surface. Three constraints shaped the design: - The wrap must happen in JS. Content inside a `` is fallback content, so emitting the wrapper server-side would blank the desktop for every browser without the API. - Moving the shell re-parents every iframe, which reloads it. The wrap therefore happens at boot before any window exists, and session restore is gated on it. At runtime the master toggle only wraps live when no iframe window is open; otherwise it offers a reload. - The stage proves it can upload before touching the shell. PixiJS uploads from inside the browser's paint event, where a throw is uncatchable and repeats every frame, so a failure there would leave a blank desktop. A pre-flight probe plus a runtime failsafe (unwrap after repeated upload errors) make that unreachable. Includes a shim for a real API mismatch: PixiJS 8.19 still calls the legacy 6-argument `texElementImage2D`, while Chromium 150+ implements the finalised 3-argument signature. Chrome's own PixiJS demo carries the same patch. It installs only when the browser has the new signature, and only rewrites legacy-shaped calls. Extensibility follows the house pattern: a shared-store registry, a `wp.desktop.stage.*` API, and `desktop_mode_register_screen_effect_script()` so a plugin's effect appears live on activation without an F5. Accessibility: effects honour `prefers-reduced-motion`, and the CRT's flicker rate is capped at 3 Hz (WCAG 2.3.1) — an earlier revision ran at a fixed 10 Hz, squarely in the photosensitivity range. Bumps pixi.js to 8.19.0 and vendors its `html-source` browser bundle. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_015sKW1mu1SGg5k9oSHgxv5s --- AGENTS.md | 1 + assets/css/os-settings.css | 36 + assets/css/stage.css | 45 ++ assets/vendor/pixi-html-source.min.js | 8 + assets/vendor/pixi.min.js | 192 ++--- desktop-mode.php | 1 + docs/README.md | 2 + docs/api-index.md | 6 + docs/architecture.md | 64 ++ docs/examples/README.md | 1 + docs/examples/register-screen-effect.md | 187 +++++ docs/hooks-reference.md | 34 + docs/javascript-reference.md | 64 +- docs/screen-effects.md | 324 ++++++++ includes/assets.php | 15 + includes/core/payload.php | 2 + includes/os-settings.php | 61 ++ includes/render/assets.php | 7 + includes/screen-effects.php | 161 ++++ package-lock.json | 18 +- package.json | 7 +- src/api/facade.ts | 46 ++ src/boot/menu-refresh.ts | 6 + src/desktop.ts | 116 ++- src/hooks.ts | 22 + src/menu-refresh-apply.ts | 20 + src/settings/constants.ts | 2 + src/settings/index.ts | 5 + src/settings/panel.ts | 15 + src/settings/registry.ts | 16 + src/settings/sections/experimental.ts | 300 ++++++++ src/settings/state.ts | 9 + src/settings/types.ts | 22 + src/stage/chain.ts | 199 +++++ src/stage/effects/crt.ts | 258 +++++++ src/stage/effects/pixel-art.ts | 111 +++ src/stage/effects/scanlines.ts | 128 ++++ src/stage/effects/shared.ts | 83 ++ src/stage/entry.ts | 54 ++ src/stage/feature-detect.ts | 374 +++++++++ src/stage/index.ts | 86 +++ src/stage/loader.ts | 275 +++++++ src/stage/registry.ts | 220 ++++++ src/stage/server-sync.ts | 86 +++ src/stage/stage.ts | 885 ++++++++++++++++++++++ src/stage/types.ts | 153 ++++ src/stage/webgl-compat.ts | 149 ++++ src/types.ts | 46 ++ tests/phpunit/tests/osSettings.php | 160 ++++ tests/phpunit/tests/screenEffects.php | 122 +++ tests/vitest/stage-chain.test.ts | 250 ++++++ tests/vitest/stage-feature-detect.test.ts | 178 +++++ tests/vitest/stage-registry.test.ts | 216 ++++++ tests/vitest/stage-webgl-compat.test.ts | 281 +++++++ vite.config.js | 10 + 55 files changed, 6024 insertions(+), 115 deletions(-) create mode 100644 assets/css/stage.css create mode 100644 assets/vendor/pixi-html-source.min.js create mode 100644 docs/examples/register-screen-effect.md create mode 100644 docs/screen-effects.md create mode 100644 includes/screen-effects.php create mode 100644 src/settings/sections/experimental.ts create mode 100644 src/stage/chain.ts create mode 100644 src/stage/effects/crt.ts create mode 100644 src/stage/effects/pixel-art.ts create mode 100644 src/stage/effects/scanlines.ts create mode 100644 src/stage/effects/shared.ts create mode 100644 src/stage/entry.ts create mode 100644 src/stage/feature-detect.ts create mode 100644 src/stage/index.ts create mode 100644 src/stage/loader.ts create mode 100644 src/stage/registry.ts create mode 100644 src/stage/server-sync.ts create mode 100644 src/stage/stage.ts create mode 100644 src/stage/types.ts create mode 100644 src/stage/webgl-compat.ts create mode 100644 tests/phpunit/tests/screenEffects.php create mode 100644 tests/vitest/stage-chain.test.ts create mode 100644 tests/vitest/stage-feature-detect.test.ts create mode 100644 tests/vitest/stage-registry.test.ts create mode 100644 tests/vitest/stage-webgl-compat.test.ts diff --git a/AGENTS.md b/AGENTS.md index 8b26d29a4..b93d5389f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -256,6 +256,7 @@ The full index lives in [`docs/README.md`](docs/README.md). Quick reference: | `docs/plugin-compat-layer.md` | A chromeless-CSS shim, offset neutralizer, or dock-builder adaptation for a third-party plugin shape is added/changed. | | `docs/dock-customization.md` | Dock rendering, ordering, or decoration hooks change. | | `docs/desktop-themes.md` | The desktop-theme manifest format, icon/texture slot lists, value grammar, or fallback semantics change. **Slot names must stay equal on both sides** (`desktop_mode_desktop_theme_icon_slots()` ↔ `src/desktop-themes/slots.ts`). | +| `docs/screen-effects.md` | The canvas stage, the `ScreenEffectDef` contract, shader conventions, or the HTML-in-Canvas browser requirement changes. **`src/stage/` is the implementation; the built-in shaders live in `src/stage/effects/`.** | | `docs/files-on-desktop.md` | Desktop file/folder behavior, tile metadata, or placement changes. | | `docs/folder-sharing.md` | Folder-sharing API, ACL model, or REST routes change. | | `docs/migration-*.md` | A breaking change ships, write a migration note here in the same PR. | diff --git a/assets/css/os-settings.css b/assets/css/os-settings.css index c7f859e69..b469ada80 100644 --- a/assets/css/os-settings.css +++ b/assets/css/os-settings.css @@ -1417,3 +1417,39 @@ font-size: 22px; line-height: 1; } + +/* + * Experimental tab — canvas stage + screen effects. + * + * Each effect is a checkbox with an optional description and, when + * ticked, a stack of parameter sliders. The sliders are indented under + * their checkbox so a chain of several effects still reads as a list of + * effects rather than a wall of controls. + */ +.desktop-mode-experimental__effect { + display: flex; + flex-direction: column; + gap: 6px; + padding-block: 10px; + border-block-start: 1px solid var( --wpd-border-subtle, rgba( 0, 0, 0, 0.08 ) ); +} + +.desktop-mode-experimental__effect:first-child { + border-block-start: 0; + padding-block-start: 0; +} + +.desktop-mode-experimental__hint { + margin: 0; + font-size: 12px; + color: var( --wpd-fg-muted, #50575e ); + line-height: 1.5; +} + +.desktop-mode-experimental__params { + display: flex; + flex-direction: column; + gap: 10px; + margin-block-start: 4px; + padding-inline-start: 24px; +} diff --git a/assets/css/stage.css b/assets/css/stage.css new file mode 100644 index 000000000..4a6b4f432 --- /dev/null +++ b/assets/css/stage.css @@ -0,0 +1,45 @@ +/** + * Desktop Mode — canvas stage. + * + * Styles the `` that + * `src/stage/stage.ts` wraps `#desktop-mode-shell` in when the user + * turns on OS Settings → Experimental → "Render the desktop in a + * canvas". + * + * **Most of the stage's geometry is NOT here.** The canvas's fixed + * placement, its insets, and the shell's `position: absolute; inset: 0` + * are set inline by `_wrap()` in `stage.ts`. That is deliberate: the + * renderer sizes its backing store from `canvas.clientWidth`, so a + * stylesheet that failed to reach the page — not enqueued, blocked, + * stale in cache — would leave the canvas at its intrinsic size and + * render the entire desktop into a corner at the wrong scale. Layout + * the element cannot function without belongs with the code that + * creates it. + * + * What remains here is the one rule that is genuinely stateful and + * belongs in the cascade: the fullscreen-window override. It needs + * `!important` to beat the inline value. + */ + +/* + * Mirrors `body.desktop-mode-has-fullscreen-window .desktop-mode-shell` + * in desktop.css. A fullscreen window hides the admin bar, so the + * canvas has to reclaim those 32px or the desktop would sit below a + * band of the classic admin page. + * + * `!important` because `_wrap()` sets `inset-block-start` inline. + */ +body.desktop-mode-has-fullscreen-window .desktop-mode-stage { + inset-block-start: 0 !important; +} + +/* + * Marker class for the shell while it lives inside the canvas. + * + * Carries no geometry of its own — `_wrap()` sets `position: absolute` + * and `inset: 0` inline for the reason above. It exists so plugin CSS + * and DevTools can tell a staged shell from a normal one. + */ +.desktop-mode-shell--staged { + z-index: auto; +} diff --git a/assets/vendor/pixi-html-source.min.js b/assets/vendor/pixi-html-source.min.js new file mode 100644 index 000000000..572142eb9 --- /dev/null +++ b/assets/vendor/pixi-html-source.min.js @@ -0,0 +1,8 @@ +/*! + * PixiJS - v8.19.0 + * Compiled Thu, 04 Jun 2026 08:22:17 UTC + * + * PixiJS is licensed under the MIT License. + * http://www.opensource.org/licenses/mit-license + */this.PIXI=this.PIXI||{};var html_source_js=(function(o){"use strict";"use strict";function I(t){const e=globalThis.ElementImage;return!!e&&t instanceof e}class h extends PIXI.TextureSource{constructor(e){if(!e.resource)throw new Error("[ElementImageSource] resource is required.");super(e),this.uploadMethodId="html",this.isReady=!0,this._autoClose=e.autoClose===!0}static test(e){return I(e)}get resourceWidth(){return Math.ceil(this.resource.width)}get resourceHeight(){return Math.ceil(this.resource.height)}destroy(){const e=this.resource;super.destroy(),this._autoClose&&e&&e.close()}}h.extension={type:PIXI.ExtensionType.TextureSource,priority:-10};function E(t,e,r,n,s){e.width===n&&e.height===s||(t.texImage2D(r,0,e.internalFormat,n,s,0,e.format,e.type,null),e.width=n,e.height=s)}const p={extension:{type:PIXI.ExtensionType.TextureUploaderWebGL,name:"html"},id:"html",upload(t,e,r,n,s){var i;const a=r.texElementImage2D;if(!a)throw new Error("[HTMLSource] WebGLRenderingContext.texElementImage2D is not available. Enable the browser HTML-in-Canvas API before using HTMLSource.");const u=s!=null?s:e.target,l=t.pixelWidth,c=t.pixelHeight;if(!t.isReady){E(r,e,u,l,c),(i=t.requestPaint)==null||i.call(t);return}a.call(r,u,0,e.internalFormat,e.format,e.type,t.resource),e.width=l,e.height=c}},m={extension:{type:PIXI.ExtensionType.TextureUploaderWebGPU,name:"html"},type:"html",upload(t,e,r,n=0){var s;const i=r.device.queue,a=i.copyElementImageToTexture;if(!a)throw new Error("[HTMLSource] GPUQueue.copyElementImageToTexture is not available. Enable the browser HTML-in-Canvas API before using HTMLSource.");if(!t.isReady){(s=t.requestPaint)==null||s.call(t);return}const u=t.alphaMode==="premultiply-alpha-on-upload",l={texture:e,origin:{x:0,y:0,z:n},premultipliedAlpha:u},c=Math.min(e.width,t.pixelWidth),H=Math.min(e.height,t.pixelHeight);a.call(i,t.resource,c,H,l)}};var P=Object.defineProperty,g=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable,f=(t,e,r)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,T=(t,e)=>{for(var r in e||(e={}))b.call(e,r)&&f(t,r,e[r]);if(g)for(var r of g(e))M.call(e,r)&&f(t,r,e[r]);return t};function L(t){return!!globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}const d=class y extends PIXI.TextureSource{constructor(e){var r;if(e=T(T({},y.defaultOptions),e),!e.resource)throw new Error("[HTMLSource] resource is required.");super(e),this.uploadMethodId="html";const n=(r=e.canvas)!=null?r:this._inferCanvas(e.resource);if(!n)throw new Error("[HTMLSource] Could not determine the owning canvas. Append the element to the canvas before constructing this source, or pass the `canvas` option.");if(e.resource.parentElement!==n)throw new Error("[HTMLSource] resource must be a direct child of the owning canvas. Append the element to the canvas before constructing this source.");this.canvas=n,this._autoUpdate=e.autoUpdate!==!1,this._onPaintBound=this._onPaint.bind(this),this._isReady=!this._autoUpdate||!n.requestPaint,e.autoLayout!==!1&&n.setAttribute("layoutsubtree",""),this._autoUpdate&&n.addEventListener("paint",this._onPaintBound),e.autoRequestPaint!==!1&&this.requestPaint()}static test(e){return!!globalThis.HTMLElement&&e instanceof HTMLElement&&!(e instanceof HTMLImageElement)&&!(e instanceof HTMLVideoElement)&&!(e instanceof HTMLCanvasElement)}get isReady(){return this._isReady}requestPaint(){var e;return(e=this.canvas)!=null&&e.requestPaint?(this.canvas.requestPaint(),!0):!1}destroy(){this.canvas&&this._autoUpdate&&this.canvas.removeEventListener("paint",this._onPaintBound),this.canvas=null,super.destroy()}get resourceWidth(){return this.resource.offsetWidth||1}get resourceHeight(){return this.resource.offsetHeight||1}_inferCanvas(e){return L(e.parentElement)?e.parentElement:null}_onPaint(e){const r=e.changedElements;r!=null&&r.length&&!r.includes(this.resource)||(this._isReady=!0,this.update())}};d.extension={type:PIXI.ExtensionType.TextureSource,priority:-10},d.defaultOptions={autoLayout:!0,autoUpdate:!0,autoRequestPaint:!0};let v=d;return PIXI.extensions.add(v,h,p,m),o.ElementImageSource=h,o.HTMLSource=v,o.glUploadHTMLResource=p,o.gpuUploadHTMLResource=m,o})({});Object.assign(this.PIXI,html_source_js); +//# sourceMappingURL=html-source.min.js.map diff --git a/assets/vendor/pixi.min.js b/assets/vendor/pixi.min.js index b78c8b8dd..e6684e3e0 100644 --- a/assets/vendor/pixi.min.js +++ b/assets/vendor/pixi.min.js @@ -1,10 +1,10 @@ -var CB=Object.defineProperty;var S1=Object.getOwnPropertySymbols;var MB=Object.prototype.hasOwnProperty,RB=Object.prototype.propertyIsEnumerable;var w1=(d,ie,ne)=>ie in d?CB(d,ie,{enumerable:!0,configurable:!0,writable:!0,value:ne}):d[ie]=ne,P1=(d,ie)=>{for(var ne in ie||(ie={}))MB.call(ie,ne)&&w1(d,ne,ie[ne]);if(S1)for(var ne of S1(ie))RB.call(ie,ne)&&w1(d,ne,ie[ne]);return d};/*! - * PixiJS - v8.18.1 - * Compiled Tue, 14 Apr 2026 20:01:42 UTC +var IB=Object.defineProperty;var E1=Object.getOwnPropertySymbols;var BB=Object.prototype.hasOwnProperty,FB=Object.prototype.propertyIsEnumerable;var P1=(d,ie,ne)=>ie in d?IB(d,ie,{enumerable:!0,configurable:!0,writable:!0,value:ne}):d[ie]=ne,A1=(d,ie)=>{for(var ne in ie||(ie={}))BB.call(ie,ne)&&P1(d,ne,ie[ne]);if(E1)for(var ne of E1(ie))FB.call(ie,ne)&&P1(d,ne,ie[ne]);return d};/*! + * PixiJS - v8.19.0 + * Compiled Thu, 04 Jun 2026 08:22:17 UTC * * PixiJS is licensed under the MIT License. * http://www.opensource.org/licenses/mit-license - */var PIXI=(function(d){"use strict";"use strict";var ie=Object.defineProperty,ne=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,Oh=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,nS=Object.prototype.propertyIsEnumerable,Gh=(r,t,e)=>t in r?ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ih=(r,t)=>{for(var e in t||(t={}))iS.call(t,e)&&Gh(r,e,t[e]);if(Oh)for(var e of Oh(t))nS.call(t,e)&&Gh(r,e,t[e]);return r},sS=(r,t)=>ne(r,rS(t)),S=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(S||{});const Ea=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=sS(Ih({},t),{ref:r})}if(typeof r=="object")r=Ih({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},ni=(r,t)=>{var e;return(e=Ea(r).priority)!=null?e:t},X={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Ea).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...r){return r.map(Ea).forEach(t=>{t.type.forEach(e=>{var i,n;const s=this._addHandlers,a=this._queue;s[e]?(n=s[e])==null||n.call(s,t):(a[e]=a[e]||[],(i=a[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const n=this._addHandlers,s=this._removeHandlers;n[r]=t,s[r]=e;const a=this._queue;return a[r]&&((i=a[r])==null||i.forEach(o=>t(o)),delete a[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,s)=>ni(s.value,e)-ni(n.value,e)))},i=>{const n=t.findIndex(s=>s.name===i.name);n!==-1&&t.splice(n,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,s)=>ni(s,e)-ni(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var OB=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Bh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function GB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function IB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function BB(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function i(){var n=!1;try{n=this instanceof i}catch(s){}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),e}var rn={exports:{}},FB=rn.exports,Fh;function aS(){return Fh||(Fh=1,(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,h||l,p),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)t.call(c,h)&&u.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},o.prototype.listeners=function(u){var c=e?e+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,f=h.length,m=new Array(f);p0:typeof r=="number"},Gt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},se=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Dh=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},Uh=function(r){return{r:se(r.r,0,255),g:se(r.g,0,255),b:se(r.b,0,255),a:se(r.a)}},Aa=function(r){return{r:Gt(r.r),g:Gt(r.g),b:Gt(r.b),a:Gt(r.a,3)}},uS=/^#([0-9a-f]{3,8})$/i,nn=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},$h=function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=Math.max(t,e,i),a=s-Math.min(t,e,i),o=a?s===t?(e-i)/a:s===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:s?a/s*100:0,v:s/255*100,a:n}},kh=function(r){var t=r.h,e=r.s,i=r.v,n=r.a;t=t/360*6,e/=100,i/=100;var s=Math.floor(t),a=i*(1-e),o=i*(1-(t-s)*e),l=i*(1-(1-t+s)*e),u=s%6;return{r:255*[i,o,a,a,l,i][u],g:255*[l,i,i,o,a,a][u],b:255*[a,a,l,i,i,o][u],a:n}},Lh=function(r){return{h:Dh(r.h),s:se(r.s,0,100),l:se(r.l,0,100),a:se(r.a)}},Nh=function(r){return{h:Gt(r.h),s:Gt(r.s),l:Gt(r.l),a:Gt(r.a,3)}},Xh=function(r){return kh((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},si=function(r){return{h:(t=$h(r)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},cS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,hS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,dS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ca={string:[[function(r){var t=uS.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Gt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Gt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=dS.exec(r)||pS.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:Uh({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=cS.exec(r)||hS.exec(r);if(!t)return null;var e,i,n=Lh({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(lS[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return Xh(n)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=n===void 0?1:n;return Re(t)&&Re(e)&&Re(i)?Uh({r:Number(t),g:Number(e),b:Number(i),a:Number(s)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,n=r.a,s=n===void 0?1:n;if(!Re(t)||!Re(e)||!Re(i))return null;var a=Lh({h:Number(t),s:Number(e),l:Number(i),a:Number(s)});return Xh(a)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,n=r.a,s=n===void 0?1:n;if(!Re(t)||!Re(e)||!Re(i))return null;var a=(function(o){return{h:Dh(o.h),s:se(o.s,0,100),v:se(o.v,0,100),a:se(o.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(s)});return kh(a)},"hsv"]]},jh=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=Aa(this.rgba),e=t.r,i=t.g,n=t.b,a=(s=t.a)<1?nn(Gt(255*s)):"","#"+nn(e)+nn(i)+nn(n)+a;var t,e,i,n,s,a},r.prototype.toRgb=function(){return Aa(this.rgba)},r.prototype.toRgbString=function(){return t=Aa(this.rgba),e=t.r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},r.prototype.toHsl=function(){return Nh(si(this.rgba))},r.prototype.toHslString=function(){return t=Nh(si(this.rgba)),e=t.h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},r.prototype.toHsv=function(){return t=$h(this.rgba),{h:Gt(t.h),s:Gt(t.s),v:Gt(t.v),a:Gt(t.a,3)};var t},r.prototype.invert=function(){return be({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),be(Ma(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),be(Ma(this.rgba,-t))},r.prototype.grayscale=function(){return be(Ma(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),be(zh(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),be(zh(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?be({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Gt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=si(this.rgba);return typeof t=="number"?be({h:t,s:e.s,l:e.l,a:e.a}):Gt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===be(t).toHex()},r})(),be=function(r){return r instanceof sn?r:new sn(r)},Wh=[],fS=function(r){r.forEach(function(t){Wh.indexOf(t)<0&&(t(sn,Ca),Wh.push(t))})},UB=function(){return new sn({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function mS(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in e)i[e[n]]=n;var s={};r.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,l,u=i[this.toHex()];if(u)return u;if(a!=null&&a.closest){var c=this.toRgb(),h=1/0,p="black";if(!s.length)for(var f in e)s[f]=new r(e[f]).toRgb();for(var m in e){var g=(o=c,l=s[m],Math.pow(o.r-l.r,2)+Math.pow(o.g-l.g,2)+Math.pow(o.b-l.b,2));gt in r?gS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,bS=(r,t)=>{for(var e in t||(t={}))_S.call(t,e)&&Yh(r,e,t[e]);if(Vh)for(var e of Vh(t))yS.call(t,e)&&Yh(r,e,t[e]);return r};fS([mS]);const vr=class tn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof tn)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?bS({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,s)=>n===e[s]);if(t!==null&&e!==null){const n=Object.keys(t),s=Object.keys(e);return n.length!==s.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}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,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,n,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,n,s]=tn._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=s,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,s=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,i,n,s;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,n=(a&255)/255,s=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,s=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,s=255]=t,e/=255,i/=255,n/=255,s/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=tn.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=be(t);a.isValid()&&({r:e,g:i,b:n,a:s}=a.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=s,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((n,s)=>{t[s]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof tn||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};vr.shared=new vr,vr._temp=new vr,vr.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let tt=vr;const Kh={cullArea:null,cullable:!1,cullableChildren:!0},qh=Math.PI*2,Zh=180/Math.PI,Qh=Math.PI/180;class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(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}static get shared(){return Oa.x=0,Oa.y=0,Oa}}const Oa=new lt;class U{constructor(t=1,e=0,i=0,n=1,s=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,n,s,a){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new lt;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new lt;const i=this.a,n=this.b,s=this.c,a=this.d,o=this.tx,l=this.ty,u=1/(i*a+s*-n),c=t.x,h=t.y;return e.x=a*u*c+-s*u*h+(l*s-o*a)*u,e.y=i*u*h+-n*u*c+(-l*i+o*n)*u,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),n=this.a,s=this.c,a=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,s=t.c,a=t.d,o=t.tx,l=t.ty,u=e.a,c=e.b,h=e.c,p=e.d;return this.a=i*u+n*h,this.b=i*c+n*p,this.c=s*u+a*h,this.d=s*c+a*p,this.tx=o*u+l*h+e.tx,this.ty=o*c+l*p+e.ty,this}setTransform(t,e,i,n,s,a,o,l,u){return this.a=Math.cos(o+u)*s,this.b=Math.sin(o+u)*s,this.c=-Math.sin(o-l)*a,this.d=Math.cos(o-l)*a,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,n=this.c,s=this.d,a=t.pivot,o=-Math.atan2(-n,s),l=Math.atan2(i,e),u=Math.abs(o+l);return u<1e-5||Math.abs(qh-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(n*n+s*s),t.position.x=this.tx+(a.x*e+a.y*n),t.position.y=this.ty+(a.x*i+a.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,a=t*n-e*i;return this.a=n/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-n*s)/a,this.ty=-(t*this.ty-e*s)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new U;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}static get IDENTITY(){return xS.identity()}static get shared(){return vS.identity()}}const vS=new U,xS=new U;class bt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new bt(t!=null?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}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))}}const ai={default:-1};function ht(r="default"){return ai[r]===void 0&&(ai[r]=-1),++ai[r]}function TS(){for(const r in ai)delete ai[r]}const qe={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class Jh{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?i=this._pool[--this._index]:(i=new this._classType,this._count++),(e=i.init)==null||e.call(i,t),i}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t{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()}}const Et=new td;qe.register(Et);const ed={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function Ga(r,t,e){const i=r.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const s=i-e;for(n=t;n0&&n<=i){for(let o=i-1;o>=r;o--){const l=this.children[o];l&&(s.push(l),l.parent=null)}Ga(this.children,r,i);const a=this.renderGroup||this.parentRenderGroup;a&&a.removeChildren(s);for(let o=0;o0&&this._didViewChangeTick++,s}else if(n===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const i=r.parent===this;if(r.parent){const s=r.parent.children.indexOf(r);if(i){if(s===t)return r;r.parent.children.splice(s,1)}else r.removeFromParent()}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(r),this.sortableChildren&&(this.sortDirty=!0),i||(this.emit("childAdded",r,this,t),r.emit("added",this)),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},id={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const i=this.children,n=i.length;for(let s=0;s=0;n--){const s=this.effects[n];i[s.pipe].pop(s,this,r)}}};class oi{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;et in r?SS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,od=(r,t)=>{for(var e in t||(t={}))wS.call(t,e)&&ad(r,e,t[e]);if(sd)for(var e of sd(t))PS.call(t,e)&&ad(r,e,t[e]);return r};const ld={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),an.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=an.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=od(od({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new oi);r=r;const i=(r==null?void 0:r.length)>0,n=((t=e.filters)==null?void 0:t.length)>0,s=i!==n;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),s&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new oi),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},ud={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let i=0;i=this.x&&t=this.y&&e=h&&t<=p&&e>=f&&e<=m&&!(t>g&&t<_&&e>y&&et.right?t.right:this.right)<=E)return!1;const M=this.yt.bottom?t.bottom:this.bottom)>M}const i=this.left,n=this.right,s=this.top,a=this.bottom;if(n<=i||a<=s)return!1;const o=on[0].set(t.left,t.top),l=on[1].set(t.left,t.bottom),u=on[2].set(t.right,t.top),c=on[3].set(t.right,t.bottom);if(u.x<=o.x||l.y<=o.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(o,o),e.apply(l,l),e.apply(u,u),e.apply(c,c),Math.max(o.x,l.x,u.x,c.x)<=i||Math.min(o.x,l.x,u.x,c.x)>=n||Math.max(o.y,l.y,u.y,c.y)<=s||Math.min(o.y,l.y,u.y,c.y)>=a))return!1;const p=h*(l.y-o.y),f=h*(o.x-l.x),m=p*i+f*s,g=p*n+f*s,_=p*i+f*a,y=p*n+f*a;if(Math.max(m,g,_,y)<=p*o.x+f*o.y||Math.min(m,g,_,y)>=p*c.x+f*c.y)return!1;const b=h*(o.y-u.y),x=h*(u.x-o.x),v=b*i+x*s,w=b*n+x*s,T=b*i+x*a,P=b*n+x*a;return!(Math.max(v,w,T,P)<=b*o.x+x*o.y||Math.min(v,w,T,P)>=b*c.x+x*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(s-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=n-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),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}getBounds(t){return t||(t=new ut),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,n=t.x+t.width,s=t.y+t.height;return e>=this.x&&e=this.y&&i=this.x&&n=this.y&&sthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new ut);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=cd,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,s){s||(s=this.matrix);const a=s.a,o=s.b,l=s.c,u=s.d,c=s.tx,h=s.ty;let p=this.minX,f=this.minY,m=this.maxX,g=this.maxY,_=a*t+l*e+c,y=o*t+u*e+h;_m&&(m=_),y>g&&(g=y),_=a*i+l*e+c,y=o*i+u*e+h,_m&&(m=_),y>g&&(g=y),_=a*t+l*n+c,y=o*t+u*n+h,_m&&(m=_),y>g&&(g=y),_=a*i+l*n+c,y=o*i+u*n+h,_m&&(m=_),y>g&&(g=y),this.minX=p,this.minY=f,this.maxX=m,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.maxXthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=a*e+l*s+c,f=o*e+u*s+h,this.minX=pthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=a*n+l*s+c,f=o*n+u*s+h,this.minX=pthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,n){return this.minXe&&(this.maxX=e),this.minYn&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Mt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,n){let s=this.minX,a=this.minY,o=this.maxX,l=this.maxY;n||(n=this.matrix);const u=n.a,c=n.b,h=n.c,p=n.d,f=n.tx,m=n.ty;for(let g=e;go?b:o,l=x>l?x:l}this.minX=s,this.minY=a,this.maxX=o,this.maxY=l}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}}const Dt=Et.getPool(U),ve=Et.getPool(Mt),ES=new U,hd={getFastGlobalBounds(r,t){t||(t=new Mt),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let i=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(i=ve.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const a=this.bounds;i.addFrame(a.minX,a.minY,a.maxX,a.maxY,this.groupTransform)}const s=this.children;for(let a=0;a>16&255,i=r>>8&255,n=r&255,s=t>>16&255,a=t>>8&255,o=t&255,l=e*s/255|0,u=i*a/255|0,c=n*o/255|0;return(l<<16)+(u<<8)+c}const pd=16777215;function ui(r,t){return r===pd?t:t===pd?r:Oe(r,t)}function xe(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const fd={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new U,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=ln(this,Dt.get().identity());return r.appendFrom(this.localTransform,e),Dt.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?xe(this.renderGroup.worldColor):this.parentRenderGroup?xe(ui(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=ui(t,e.localColor),e=e.parent;return xe(t)}};function un(r,t,e){return t.clear(),e||(e=U.IDENTITY),md(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function md(r,t,e,i,n){var s,a;let o;if(n)o=Dt.get(),o=e.copyTo(o);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;o=Dt.get(),o.appendFrom(c,e)}const l=t,u=!!r.effects.length;if(u&&(t=ve.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.renderPipeId&&(t.matrix=o,t.addBounds(r.bounds));const c=r.children;for(let h=0;h>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Ba(r){return!(r&r-1)&&!!r}function MS(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function he(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var RS=Object.defineProperty,vd=Object.getOwnPropertySymbols,OS=Object.prototype.hasOwnProperty,GS=Object.prototype.propertyIsEnumerable,xd=(r,t,e)=>t in r?RS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Td=(r,t)=>{for(var e in t||(t={}))OS.call(t,e)&&xd(r,e,t[e]);if(vd)for(var e of vd(t))GS.call(t,e)&&xd(r,e,t[e]);return r};const Sd=Object.create(null);function IS(r){const t=Sd[r];return t===void 0&&(Sd[r]=ht("resource")),t}const wd=class E1 extends Nt{constructor(t={}){var e,i,n,s,a,o,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Td(Td({},E1.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(i=t.addressModeV)!=null?i:this.addressModeV,this.addressModeW=(n=t.addressModeW)!=null?n:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(s=t.magFilter)!=null?s:this.magFilter,this.minFilter=(a=t.minFilter)!=null?a:this.minFilter,this.mipmapFilter=(o=t.mipmapFilter)!=null?o:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){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._sharedResourceId=null,this.emit("change",this)}_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=IS(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};wd.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Jt=wd;var BS=Object.defineProperty,Pd=Object.getOwnPropertySymbols,FS=Object.prototype.hasOwnProperty,DS=Object.prototype.propertyIsEnumerable,Ed=(r,t,e)=>t in r?BS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ad=(r,t)=>{for(var e in t||(t={}))FS.call(t,e)&&Ed(r,e,t[e]);if(Pd)for(var e of Pd(t))DS.call(t,e)&&Ed(r,e,t[e]);return r};const Cd=class A1 extends Nt{constructor(t={}){var e,i,n,s;super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ht("textureSource"),this._resourceType="textureSource",this._resourceId=ht("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.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Ad(Ad({},A1.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(i=this.resourceWidth)!=null?i:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(n=this.resourceHeight)!=null?n:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=(s=t.viewDimension)!=null?s:t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.alphaMode=t.alphaMode,this.style=new Jt(he(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}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.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=ht("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*i),s=Math.round(e*i);return this.width=n/i,this.height=s/i,this._resolution=i,this.pixelWidth===n&&this.pixelHeight===s?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=s,this.emit("resize",this),this._resourceId=ht("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=Ba(this.pixelWidth)&&Ba(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Cd.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ft=Cd;const Qe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Je=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],tr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],er=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Fa=[],Md=[],hn=Math.sign;function US(){for(let r=0;r<16;r++){const t=[];Fa.push(t);for(let e=0;e<16;e++){const i=hn(Qe[r]*Qe[e]+tr[r]*Je[e]),n=hn(Je[r]*Qe[e]+er[r]*Je[e]),s=hn(Qe[r]*tr[e]+tr[r]*er[e]),a=hn(Je[r]*tr[e]+er[r]*er[e]);for(let o=0;o<16;o++)if(Qe[o]===i&&Je[o]===n&&tr[o]===s&&er[o]===a){t.push(o);break}}}for(let r=0;r<16;r++){const t=new U;t.set(Qe[r],Je[r],tr[r],er[r],0,0),Md.push(t)}}US();const W={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:r=>Qe[r],uY:r=>Je[r],vX:r=>tr[r],vY:r=>er[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Fa[r][t],sub:(r,t)=>Fa[r][W.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?W.S:W.N:Math.abs(t)*2<=Math.abs(r)?r>0?W.E:W.W:t>0?r>0?W.SE:W.SW:r>0?W.NE:W.NW,matrixAppendRotationInv:(r,t,e=0,i=0,n=0,s=0)=>{const a=Md[W.inv(t)],o=a.a,l=a.b,u=a.c,c=a.d,h=e-Math.min(0,o*n,u*s,o*n+u*s),p=i-Math.min(0,l*n,c*s,l*n+c*s),f=r.a,m=r.b,g=r.c,_=r.d;r.a=o*f+l*g,r.b=o*m+l*_,r.c=u*f+c*g,r.d=u*m+c*_,r.tx=h*f+p*g+r.tx,r.ty=h*m+p*_+r.ty},transformRectCoords:(r,t,e,i)=>{const{x:n,y:s,width:a,height:o}=r,{x:l,y:u,width:c,height:h}=t;return e===W.E?(i.set(n+l,s+u,a,o),i):e===W.S?i.set(c-s-o+l,n+u,o,a):e===W.W?i.set(c-n-a+l,h-s-o+u,a,o):e===W.N?i.set(s+l,h-n-a+u,o,a):i.set(n+l,s+u,a,o)}},Da=()=>{};var $S=Object.defineProperty,kS=Object.defineProperties,LS=Object.getOwnPropertyDescriptors,Rd=Object.getOwnPropertySymbols,NS=Object.prototype.hasOwnProperty,XS=Object.prototype.propertyIsEnumerable,Od=(r,t,e)=>t in r?$S(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jS=(r,t)=>{for(var e in t||(t={}))NS.call(t,e)&&Od(r,e,t[e]);if(Rd)for(var e of Rd(t))XS.call(t,e)&&Od(r,e,t[e]);return r},HS=(r,t)=>kS(r,LS(t));class dn extends ft{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super(HS(jS({},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}}dn.extension=S.TextureSource;const Gd=new U;class Ua{constructor(t,e){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this._texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let n=0;nt in r?zS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qS=(r,t)=>{for(var e in t||(t={}))YS.call(t,e)&&Bd(r,e,t[e]);if(Id)for(var e of Id(t))KS.call(t,e)&&Bd(r,e,t[e]);return r},ZS=(r,t)=>WS(r,VS(t));let QS=0;class Fd{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Jt(this.textureOptions)}createTexture(t,e,i,n){const s=new ft(ZS(qS({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1,autoGenerateMipmaps:n}));return new D({source:s,label:`texturePool_${QS++}`})}getOptimalTexture(t,e,i=1,n,s=!1){let a=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);a=Ze(a),o=Ze(o);const l=n?1:0,u=s?1:0,c=(a<<17)+(o<<2)+(u<<1)+l;this._texturePool[c]||(this._texturePool[c]=[]);let h=this._texturePool[c].pop();return h||(h=this.createTexture(a,o,n,s)),h.source._resolution=i,h.source.width=a/i,h.source.height=o/i,h.source.pixelWidth=a,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]=c,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=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let n=0;n-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;ethis.addChild(n)),(i=t.parent)==null||i.addChild(this)}static mixin(t){X.mixin(dt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let n=0;n1){for(let n=0;n-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==null||t.removeChild(this),this.renderGroup=Et.get(pn,this),this.groupTransform=U.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Et.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new U),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*Zh}set angle(t){this.rotation=t*Qh}get pivot(){return this._pivot===ka&&(this._pivot=new bt(this,0,0)),this._pivot}set pivot(t){this._pivot===ka&&(this._pivot=new bt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===$a&&(this._skew=new bt(this,0,0)),this._skew}set skew(t){this._skew===$a&&(this._skew=new bt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===La&&(this._scale=new bt(this,1,1)),this._scale}set scale(t){this._scale===La&&(this._scale=new bt(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Na&&(this._origin=new bt(this,0,0)),this._origin}set origin(t){this._origin===Na&&(this._origin=new bt(this,0,0)),typeof t=="number"?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){var i;const n=this.getLocalBounds();typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,n.width),e!==void 0&&this._setHeight(e,n.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX||1:this.scale.x,typeof t.scaleY=="number"?t.scaleY||1:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?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,n=this._pivot,s=this._origin,a=this._position,o=i._x,l=i._y,u=n._x,c=n._y,h=-s._x,p=-s._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*l,e.d=this._sy*l,e.tx=a._x-(u*e.a+c*e.c)+(h*e.a+p*e.c)-h,e.ty=a._y-(u*e.b+c*e.d)+(h*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=ci,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=tt.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=ci,this._onUpdate())}get tint(){return xe(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=mn,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=xr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=xr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=xr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let i;if(this.children.length&&(i=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(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&i)for(let n=0;n(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Te||{});class gn{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}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 Dd=class re{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 gn(null,null,1/0),this.deltaMS=1/re.targetFPMS,this.elapsedMS=1/re.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Te.NORMAL){return this._addListener(new gn(t,e,i))}addOnce(t,e,i=Te.NORMAL){return this._addListener(new gn(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const s=t-this._lastFrame|0;if(sthis.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),i=this._canvas.width,n=this._canvas.height,s=e.width/i*this._renderer.resolution,a=e.height/n*this._renderer.resolution,o=e.left,l=e.top,u=`translate(${o}px, ${l}px) scale(${s}, ${a})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},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 i=this.canvas.width,n=this.canvas.height,s=e.contentRect.width/i*this._renderer.resolution,a=e.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==a)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=a)}}),this._observer.observe(this._canvas)):this._tickerAttached||Ot.shared.add(this.updateTranslation,this,Te.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Ot.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 Tr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Tr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,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,n,s){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 ja=/iPhone/i,Ud=/iPod/i,$d=/iPad/i,kd=/\biOS-universal(?:.+)Mac\b/i,Ha=/\bAndroid(?:.+)Mobile\b/i,Ld=/Android/i,Sr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,_n=/Silk/i,Ge=/Windows Phone/i,Nd=/\bWindows(?:.+)ARM\b/i,Xd=/BlackBerry/i,jd=/BB10/i,Hd=/Opera Mini/i,zd=/\b(CriOS|Chrome)(?:.+)Mobile/i,Wd=/Mobile(?:.+)Firefox\b/i,Vd=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function t2(r){return function(t){return t.test(r)}}function Yd(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]!="undefined"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]!="undefined"&&(e=i[0]);var n=t2(e),s={apple:{phone:n(ja)&&!n(Ge),ipod:n(Ud),tablet:!n(ja)&&(n($d)||Vd(t))&&!n(Ge),universal:n(kd),device:(n(ja)||n(Ud)||n($d)||n(kd)||Vd(t))&&!n(Ge)},amazon:{phone:n(Sr),tablet:!n(Sr)&&n(_n),device:n(Sr)||n(_n)},android:{phone:!n(Ge)&&n(Sr)||!n(Ge)&&n(Ha),tablet:!n(Ge)&&!n(Sr)&&!n(Ha)&&(n(_n)||n(Ld)),device:!n(Ge)&&(n(Sr)||n(_n)||n(Ha)||n(Ld))||n(/\bokhttp\b/i)},windows:{phone:n(Ge),tablet:n(Nd),device:n(Ge)||n(Nd)},other:{blackberry:n(Xd),blackberry10:n(jd),opera:n(Hd),firefox:n(Wd),chrome:n(zd),device:n(Xd)||n(jd)||n(Hd)||n(Wd)||n(zd)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}var Kd;const qd=((Kd=Yd.default)!=null?Kd:Yd)(globalThis.navigator);var e2=Object.defineProperty,Zd=Object.getOwnPropertySymbols,r2=Object.prototype.hasOwnProperty,i2=Object.prototype.propertyIsEnumerable,Qd=(r,t,e)=>t in r?e2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jd=(r,t)=>{for(var e in t||(t={}))r2.call(t,e)&&Qd(r,e,t[e]);if(Zd)for(var e of Zd(t))i2.call(t,e)&&Qd(r,e,t[e]);return r};const n2=9,tp=100,s2=0,a2=0,ep=2,rp=1,o2=-1e3,l2=-1e3,u2=2,za=class C1{constructor(t,e=qd){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=`${rp}px`,t.style.height=`${rp}px`,t.style.position="absolute",t.style.top=`${o2}px`,t.style.left=`${l2}px`,t.style.zIndex=u2.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=`${s2}px`,this._div.style.left=`${a2}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=ep.toString(),this._canvasObserver=new Xa({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(){var t,e;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 i of this._children)(t=i._accessibleDiv)!=null&&t.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(e=this._div)!=null&&e.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 i=0;i=0;i--){const n=this._children[i];e.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,Ga(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i title : ${t.title}
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):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=` + */var PIXI=(function(d){"use strict";"use strict";var ie=Object.defineProperty,ne=Object.defineProperties,aS=Object.getOwnPropertyDescriptors,Ih=Object.getOwnPropertySymbols,oS=Object.prototype.hasOwnProperty,lS=Object.prototype.propertyIsEnumerable,Bh=(r,t,e)=>t in r?ie(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fh=(r,t)=>{for(var e in t||(t={}))oS.call(t,e)&&Bh(r,e,t[e]);if(Ih)for(var e of Ih(t))lS.call(t,e)&&Bh(r,e,t[e]);return r},uS=(r,t)=>ne(r,aS(t)),S=(r=>(r.Application="application",r.WebGLPipes="webgl-pipes",r.WebGLPipesAdaptor="webgl-pipes-adaptor",r.WebGLSystem="webgl-system",r.WebGPUPipes="webgpu-pipes",r.WebGPUPipesAdaptor="webgpu-pipes-adaptor",r.WebGPUSystem="webgpu-system",r.CanvasSystem="canvas-system",r.CanvasPipesAdaptor="canvas-pipes-adaptor",r.CanvasPipes="canvas-pipes",r.Asset="asset",r.LoadParser="load-parser",r.ResolveParser="resolve-parser",r.CacheParser="cache-parser",r.DetectionParser="detection-parser",r.MaskEffect="mask-effect",r.BlendMode="blend-mode",r.TextureSource="texture-source",r.TextureUploaderWebGL="texture-uploader-webgl",r.TextureUploaderWebGPU="texture-uploader-webgpu",r.Environment="environment",r.ShapeBuilder="shape-builder",r.Batcher="batcher",r))(S||{});const Aa=r=>{if(typeof r=="function"||typeof r=="object"&&r.extension){const t=typeof r.extension!="object"?{type:r.extension}:r.extension;r=uS(Fh({},t),{ref:r})}if(typeof r=="object")r=Fh({},r);else throw new Error("Invalid extension type");return typeof r.type=="string"&&(r.type=[r.type]),r},ni=(r,t)=>{var e;return(e=Aa(r).priority)!=null?e:t},N={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...r){return r.map(Aa).forEach(t=>{t.type.forEach(e=>{var i,n;return(n=(i=this._removeHandlers)[e])==null?void 0:n.call(i,t)})}),this},add(...r){return r.map(Aa).forEach(t=>{t.type.forEach(e=>{var i,n;const s=this._addHandlers,a=this._queue;s[e]?(n=s[e])==null||n.call(s,t):(a[e]=a[e]||[],(i=a[e])==null||i.push(t))})}),this},handle(r,t,e){var i;const n=this._addHandlers,s=this._removeHandlers;n[r]=t,s[r]=e;const a=this._queue;return a[r]&&((i=a[r])==null||i.forEach(o=>t(o)),delete a[r]),this},handleByMap(r,t){return this.handle(r,e=>{e.name&&(t[e.name]=e.ref)},e=>{e.name&&delete t[e.name]})},handleByNamedList(r,t,e=-1){return this.handle(r,i=>{t.findIndex(n=>n.name===i.name)>=0||(t.push({name:i.name,value:i.ref}),t.sort((n,s)=>ni(s.value,e)-ni(n.value,e)))},i=>{const n=t.findIndex(s=>s.name===i.name);n!==-1&&t.splice(n,1)})},handleByList(r,t,e=-1){return this.handle(r,i=>{t.includes(i.ref)||(t.push(i.ref),t.sort((n,s)=>ni(s,e)-ni(n,e)))},i=>{const n=t.indexOf(i.ref);n!==-1&&t.splice(n,1)})},mixin(r,...t){for(const e of t)Object.defineProperties(r.prototype,Object.getOwnPropertyDescriptors(e))}};var DB=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function cS(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function UB(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function $B(r){return r&&Object.prototype.hasOwnProperty.call(r,"default")&&Object.keys(r).length===1?r.default:r}function kB(r){if(Object.prototype.hasOwnProperty.call(r,"__esModule"))return r;var t=r.default;if(typeof t=="function"){var e=function i(){var n=!1;try{n=this instanceof i}catch(s){}return n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};e.prototype=t.prototype}else e={};return Object.defineProperty(e,"__esModule",{value:!0}),Object.keys(r).forEach(function(i){var n=Object.getOwnPropertyDescriptor(r,i);Object.defineProperty(e,i,n.get?n:{enumerable:!0,get:function(){return r[i]}})}),e}var sn={exports:{}},LB=sn.exports,Dh;function hS(){return Dh||(Dh=1,(function(r){"use strict";var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function n(l,u,c){this.fn=l,this.context=u,this.once=c||!1}function s(l,u,c,h,p){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new n(c,h||l,p),m=e?e+u:u;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,u){--l._eventsCount===0?l._events=new i:delete l._events[u]}function o(){this._events=new i,this._eventsCount=0}o.prototype.eventNames=function(){var u=[],c,h;if(this._eventsCount===0)return u;for(h in c=this._events)t.call(c,h)&&u.push(e?h.slice(1):h);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(c)):u},o.prototype.listeners=function(u){var c=e?e+u:u,h=this._events[c];if(!h)return[];if(h.fn)return[h.fn];for(var p=0,f=h.length,m=new Array(f);p0:typeof r=="number"},Gt=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=Math.pow(10,t)),Math.round(e*r)/e+0},se=function(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=1),r>e?e:r>t?r:t},Uh=function(r){return(r=isFinite(r)?r%360:0)>0?r:r+360},$h=function(r){return{r:se(r.r,0,255),g:se(r.g,0,255),b:se(r.b,0,255),a:se(r.a)}},Ca=function(r){return{r:Gt(r.r),g:Gt(r.g),b:Gt(r.b),a:Gt(r.a,3)}},fS=/^#([0-9a-f]{3,8})$/i,an=function(r){var t=r.toString(16);return t.length<2?"0"+t:t},kh=function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=Math.max(t,e,i),a=s-Math.min(t,e,i),o=a?s===t?(e-i)/a:s===e?2+(i-t)/a:4+(t-e)/a:0;return{h:60*(o<0?o+6:o),s:s?a/s*100:0,v:s/255*100,a:n}},Lh=function(r){var t=r.h,e=r.s,i=r.v,n=r.a;t=t/360*6,e/=100,i/=100;var s=Math.floor(t),a=i*(1-e),o=i*(1-(t-s)*e),l=i*(1-(1-t+s)*e),u=s%6;return{r:255*[i,o,a,a,l,i][u],g:255*[l,i,i,o,a,a][u],b:255*[a,a,l,i,i,o][u],a:n}},Nh=function(r){return{h:Uh(r.h),s:se(r.s,0,100),l:se(r.l,0,100),a:se(r.a)}},Xh=function(r){return{h:Gt(r.h),s:Gt(r.s),l:Gt(r.l),a:Gt(r.a,3)}},jh=function(r){return Lh((e=(t=r).s,{h:t.h,s:(e*=((i=t.l)<50?i:100-i)/100)>0?2*e/(i+e)*100:0,v:i+e,a:t.a}));var t,e,i},si=function(r){return{h:(t=kh(r)).h,s:(n=(200-(e=t.s))*(i=t.v)/100)>0&&n<200?e*i/100/(n<=100?n:200-n)*100:0,l:n/2,a:t.a};var t,e,i,n},mS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,gS=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,_S=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,yS=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Ma={string:[[function(r){var t=fS.exec(r);return t?(r=t[1]).length<=4?{r:parseInt(r[0]+r[0],16),g:parseInt(r[1]+r[1],16),b:parseInt(r[2]+r[2],16),a:r.length===4?Gt(parseInt(r[3]+r[3],16)/255,2):1}:r.length===6||r.length===8?{r:parseInt(r.substr(0,2),16),g:parseInt(r.substr(2,2),16),b:parseInt(r.substr(4,2),16),a:r.length===8?Gt(parseInt(r.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(r){var t=_S.exec(r)||yS.exec(r);return t?t[2]!==t[4]||t[4]!==t[6]?null:$h({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:t[7]===void 0?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(r){var t=mS.exec(r)||gS.exec(r);if(!t)return null;var e,i,n=Nh({h:(e=t[1],i=t[2],i===void 0&&(i="deg"),Number(e)*(pS[i]||1)),s:Number(t[3]),l:Number(t[4]),a:t[5]===void 0?1:Number(t[5])/(t[6]?100:1)});return jh(n)},"hsl"]],object:[[function(r){var t=r.r,e=r.g,i=r.b,n=r.a,s=n===void 0?1:n;return Re(t)&&Re(e)&&Re(i)?$h({r:Number(t),g:Number(e),b:Number(i),a:Number(s)}):null},"rgb"],[function(r){var t=r.h,e=r.s,i=r.l,n=r.a,s=n===void 0?1:n;if(!Re(t)||!Re(e)||!Re(i))return null;var a=Nh({h:Number(t),s:Number(e),l:Number(i),a:Number(s)});return jh(a)},"hsl"],[function(r){var t=r.h,e=r.s,i=r.v,n=r.a,s=n===void 0?1:n;if(!Re(t)||!Re(e)||!Re(i))return null;var a=(function(o){return{h:Uh(o.h),s:se(o.s,0,100),v:se(o.v,0,100),a:se(o.a)}})({h:Number(t),s:Number(e),v:Number(i),a:Number(s)});return Lh(a)},"hsv"]]},Hh=function(r,t){for(var e=0;e=.5},r.prototype.toHex=function(){return t=Ca(this.rgba),e=t.r,i=t.g,n=t.b,a=(s=t.a)<1?an(Gt(255*s)):"","#"+an(e)+an(i)+an(n)+a;var t,e,i,n,s,a},r.prototype.toRgb=function(){return Ca(this.rgba)},r.prototype.toRgbString=function(){return t=Ca(this.rgba),e=t.r,i=t.g,n=t.b,(s=t.a)<1?"rgba("+e+", "+i+", "+n+", "+s+")":"rgb("+e+", "+i+", "+n+")";var t,e,i,n,s},r.prototype.toHsl=function(){return Xh(si(this.rgba))},r.prototype.toHslString=function(){return t=Xh(si(this.rgba)),e=t.h,i=t.s,n=t.l,(s=t.a)<1?"hsla("+e+", "+i+"%, "+n+"%, "+s+")":"hsl("+e+", "+i+"%, "+n+"%)";var t,e,i,n,s},r.prototype.toHsv=function(){return t=kh(this.rgba),{h:Gt(t.h),s:Gt(t.s),v:Gt(t.v),a:Gt(t.a,3)};var t},r.prototype.invert=function(){return be({r:255-(t=this.rgba).r,g:255-t.g,b:255-t.b,a:t.a});var t},r.prototype.saturate=function(t){return t===void 0&&(t=.1),be(Ra(this.rgba,t))},r.prototype.desaturate=function(t){return t===void 0&&(t=.1),be(Ra(this.rgba,-t))},r.prototype.grayscale=function(){return be(Ra(this.rgba,-1))},r.prototype.lighten=function(t){return t===void 0&&(t=.1),be(Wh(this.rgba,t))},r.prototype.darken=function(t){return t===void 0&&(t=.1),be(Wh(this.rgba,-t))},r.prototype.rotate=function(t){return t===void 0&&(t=15),this.hue(this.hue()+t)},r.prototype.alpha=function(t){return typeof t=="number"?be({r:(e=this.rgba).r,g:e.g,b:e.b,a:t}):Gt(this.rgba.a,3);var e},r.prototype.hue=function(t){var e=si(this.rgba);return typeof t=="number"?be({h:t,s:e.s,l:e.l,a:e.a}):Gt(e.h)},r.prototype.isEqual=function(t){return this.toHex()===be(t).toHex()},r})(),be=function(r){return r instanceof on?r:new on(r)},Vh=[],bS=function(r){r.forEach(function(t){Vh.indexOf(t)<0&&(t(on,Ma),Vh.push(t))})},XB=function(){return new on({r:255*Math.random(),g:255*Math.random(),b:255*Math.random()})};function vS(r,t){var e={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},i={};for(var n in e)i[e[n]]=n;var s={};r.prototype.toName=function(a){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,l,u=i[this.toHex()];if(u)return u;if(a!=null&&a.closest){var c=this.toRgb(),h=1/0,p="black";if(!s.length)for(var f in e)s[f]=new r(e[f]).toRgb();for(var m in e){var g=(o=c,l=s[m],Math.pow(o.r-l.r,2)+Math.pow(o.g-l.g,2)+Math.pow(o.b-l.b,2));gt in r?xS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wS=(r,t)=>{for(var e in t||(t={}))TS.call(t,e)&&Kh(r,e,t[e]);if(Yh)for(var e of Yh(t))SS.call(t,e)&&Kh(r,e,t[e]);return r};bS([vS]);const vr=class rn{constructor(t=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=t}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(t){return this.value=t,this}set value(t){if(t instanceof rn)this._value=this._cloneSource(t._value),this._int=t._int,this._components.set(t._components);else{if(t===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,t))&&(this._value=this._cloneSource(t),this._normalize(this._value))}}get value(){return this._value}_cloneSource(t){return typeof t=="string"||typeof t=="number"||t instanceof Number||t===null?t:Array.isArray(t)||ArrayBuffer.isView(t)?t.slice(0):typeof t=="object"&&t!==null?wS({},t):t}_isSourceEqual(t,e){const i=typeof t;if(i!==typeof e)return!1;if(i==="number"||i==="string"||t instanceof Number)return t===e;if(Array.isArray(t)&&Array.isArray(e)||ArrayBuffer.isView(t)&&ArrayBuffer.isView(e))return t.length!==e.length?!1:t.every((n,s)=>n===e[s]);if(t!==null&&e!==null){const n=Object.keys(t),s=Object.keys(e);return n.length!==s.length?!1:n.every(a=>t[a]===e[a])}return t===e}toRgba(){const[t,e,i,n]=this._components;return{r:t,g:e,b:i,a:n}}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,n]=this._components;return this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb),t[0]=Math.round(e*255),t[1]=Math.round(i*255),t[2]=Math.round(n*255),t}toArray(t){this._arrayRgba||(this._arrayRgba=[]),t||(t=this._arrayRgba);const[e,i,n,s]=this._components;return t[0]=e,t[1]=i,t[2]=n,t[3]=s,t}toRgbArray(t){this._arrayRgb||(this._arrayRgb=[]),t||(t=this._arrayRgb);const[e,i,n]=this._components;return t[0]=e,t[1]=i,t[2]=n,t}toNumber(){return this._int}toBgrNumber(){const[t,e,i]=this.toUint8RgbArray();return(i<<16)+(e<<8)+t}toLittleEndianNumber(){const t=this._int;return(t>>16)+(t&65280)+((t&255)<<16)}multiply(t){const[e,i,n,s]=rn._temp.setValue(t)._components;return this._components[0]*=e,this._components[1]*=i,this._components[2]*=n,this._components[3]*=s,this._refreshInt(),this._value=null,this}premultiply(t,e=!0){return e&&(this._components[0]*=t,this._components[1]*=t,this._components[2]*=t),this._components[3]=t,this._refreshInt(),this._value=null,this}toPremultiplied(t,e=!0){if(t===1)return(255<<24)+this._int;if(t===0)return e?0:this._int;let i=this._int>>16&255,n=this._int>>8&255,s=this._int&255;return e&&(i=i*t+.5|0,n=n*t+.5|0,s=s*t+.5|0),(t*255<<24)+(i<<16)+(n<<8)+s}toHex(){const t=this._int.toString(16);return`#${"000000".substring(0,6-t.length)+t}`}toHexa(){const t=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-t.length)+t}setAlpha(t){return this._components[3]=this._clamp(t),this._value=null,this}_normalize(t){let e,i,n,s;if((typeof t=="number"||t instanceof Number)&&t>=0&&t<=16777215){const a=t;e=(a>>16&255)/255,i=(a>>8&255)/255,n=(a&255)/255,s=1}else if((Array.isArray(t)||t instanceof Float32Array)&&t.length>=3&&t.length<=4)t=this._clamp(t),[e,i,n,s=1]=t;else if((t instanceof Uint8Array||t instanceof Uint8ClampedArray)&&t.length>=3&&t.length<=4)t=this._clamp(t,0,255),[e,i,n,s=255]=t,e/=255,i/=255,n/=255,s/=255;else if(typeof t=="string"||typeof t=="object"){if(typeof t=="string"){const o=rn.HEX_PATTERN.exec(t);o&&(t=`#${o[2]}`)}const a=be(t);a.isValid()&&({r:e,g:i,b:n,a:s}=a.rgba,e/=255,i/=255,n/=255)}if(e!==void 0)this._components[0]=e,this._components[1]=i,this._components[2]=n,this._components[3]=s,this._refreshInt();else throw new Error(`Unable to convert color ${t}`)}_refreshInt(){this._clamp(this._components);const[t,e,i]=this._components;this._int=(t*255<<16)+(e*255<<8)+(i*255|0)}_clamp(t,e=0,i=1){return typeof t=="number"?Math.min(Math.max(t,e),i):(t.forEach((n,s)=>{t[s]=Math.min(Math.max(n,e),i)}),t)}static isColorLike(t){return typeof t=="number"||typeof t=="string"||t instanceof Number||t instanceof rn||Array.isArray(t)||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Float32Array||t.r!==void 0&&t.g!==void 0&&t.b!==void 0||t.r!==void 0&&t.g!==void 0&&t.b!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0||t.h!==void 0&&t.s!==void 0&&t.l!==void 0&&t.a!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0||t.h!==void 0&&t.s!==void 0&&t.v!==void 0&&t.a!==void 0}};vr.shared=new vr,vr._temp=new vr,vr.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let tt=vr;const qh={cullArea:null,cullable:!1,cullableChildren:!0},Zh=Math.PI*2,Qh=180/Math.PI,Jh=Math.PI/180;class lt{constructor(t=0,e=0){this.x=0,this.y=0,this.x=t,this.y=e}clone(){return new lt(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}static get shared(){return Ga.x=0,Ga.y=0,Ga}}const Ga=new lt;class U{constructor(t=1,e=0,i=0,n=1,s=0,a=0){this.array=null,this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=a}fromArray(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]}set(t,e,i,n,s,a){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=s,this.ty=a,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||new lt;const i=t.x,n=t.y;return e.x=this.a*i+this.c*n+this.tx,e.y=this.b*i+this.d*n+this.ty,e}applyInverse(t,e){e=e||new lt;const i=this.a,n=this.b,s=this.c,a=this.d,o=this.tx,l=this.ty,u=1/(i*a+s*-n),c=t.x,h=t.y;return e.x=a*u*c+-s*u*h+(l*s-o*a)*u,e.y=i*u*h+-n*u*c+(-l*i+o*n)*u,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),n=this.a,s=this.c,a=this.tx;return this.a=n*e-this.b*i,this.b=n*i+this.b*e,this.c=s*e-this.d*i,this.d=s*i+this.d*e,this.tx=a*e-this.ty*i,this.ty=a*i+this.ty*e,this}append(t){const e=this.a,i=this.b,n=this.c,s=this.d;return this.a=t.a*e+t.b*n,this.b=t.a*i+t.b*s,this.c=t.c*e+t.d*n,this.d=t.c*i+t.d*s,this.tx=t.tx*e+t.ty*n+this.tx,this.ty=t.tx*i+t.ty*s+this.ty,this}appendFrom(t,e){const i=t.a,n=t.b,s=t.c,a=t.d,o=t.tx,l=t.ty,u=e.a,c=e.b,h=e.c,p=e.d;return this.a=i*u+n*h,this.b=i*c+n*p,this.c=s*u+a*h,this.d=s*c+a*p,this.tx=o*u+l*h+e.tx,this.ty=o*c+l*p+e.ty,this}setTransform(t,e,i,n,s,a,o,l,u){return this.a=Math.cos(o+u)*s,this.b=Math.sin(o+u)*s,this.c=-Math.sin(o-l)*a,this.d=Math.cos(o-l)*a,this.tx=t-(i*this.a+n*this.c),this.ty=e-(i*this.b+n*this.d),this}prepend(t){const e=this.tx;if(t.a!==1||t.b!==0||t.c!==0||t.d!==1){const i=this.a,n=this.c;this.a=i*t.a+this.b*t.c,this.b=i*t.b+this.b*t.d,this.c=n*t.a+this.d*t.c,this.d=n*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const e=this.a,i=this.b,n=this.c,s=this.d,a=t.pivot,o=-Math.atan2(-n,s),l=Math.atan2(i,e),u=Math.abs(o+l);return u<1e-5||Math.abs(Zh-u)<1e-5?(t.rotation=l,t.skew.x=t.skew.y=0):(t.rotation=0,t.skew.x=o,t.skew.y=l),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(n*n+s*s),t.position.x=this.tx+(a.x*e+a.y*n),t.position.y=this.ty+(a.x*i+a.y*s),t}invert(){const t=this.a,e=this.b,i=this.c,n=this.d,s=this.tx,a=t*n-e*i;return this.a=n/a,this.b=-e/a,this.c=-i/a,this.d=t/a,this.tx=(i*this.ty-n*s)/a,this.ty=-(t*this.ty-e*s)/a,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const t=new U;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}static get IDENTITY(){return PS.identity()}static get shared(){return ES.identity()}}const ES=new U,PS=new U;class bt{constructor(t,e,i){this._x=e||0,this._y=i||0,this._observer=t}clone(t){return new bt(t!=null?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}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))}}const ai={default:-1};function ht(r="default"){return ai[r]===void 0&&(ai[r]=-1),++ai[r]}function AS(){for(const r in ai)delete ai[r]}const qe={_registeredResources:new Set,register(r){this._registeredResources.add(r)},unregister(r){this._registeredResources.delete(r)},release(){this._registeredResources.forEach(r=>r.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(r){return this._registeredResources.has(r)},reset(){this._registeredResources.clear()}};class td{constructor(t,e){this._pool=[],this._count=0,this._index=0,this._classType=t,e&&this.prepopulate(e)}prepopulate(t){for(let e=0;e0?i=this._pool[--this._index]:(i=new this._classType,this._count++),(e=i.init)==null||e.call(i,t),i}return(t){var e;(e=t.reset)==null||e.call(t),this._pool[this._index++]=t}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let t=0;t{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()}}const Pt=new ed;qe.register(Pt);const rd={get isCachedAsTexture(){var r;return!!((r=this.renderGroup)!=null&&r.isCachedAsTexture)},cacheAsTexture(r){typeof r=="boolean"&&r===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(r===!0?{}:r))},updateCacheTexture(){var r;(r=this.renderGroup)==null||r.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(r){this.cacheAsTexture(r)}};function Ia(r,t,e){const i=r.length;let n;if(t>=i||e===0)return;e=t+e>i?i-t:e;const s=i-e;for(n=t;n0&&n<=i){for(let o=i-1;o>=r;o--){const l=this.children[o];l&&(s.push(l),l.parent=null)}Ia(this.children,r,i);const a=this.renderGroup||this.parentRenderGroup;a&&a.removeChildren(s);for(let o=0;o0&&this._didViewChangeTick++,s}else if(n===0&&this.children.length===0)return s;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(r){const t=this.getChildAt(r);return this.removeChild(t)},getChildAt(r){if(r<0||r>=this.children.length)throw new Error(`getChildAt: Index (${r}) does not exist.`);return this.children[r]},setChildIndex(r,t){if(t<0||t>=this.children.length)throw new Error(`The index ${t} supplied is out of bounds ${this.children.length}`);this.getChildIndex(r),this.addChildAt(r,t)},getChildIndex(r){const t=this.children.indexOf(r);if(t===-1)throw new Error("The supplied Container must be a child of the caller");return t},addChildAt(r,t){const{children:e}=this;if(t<0||t>e.length)throw new Error(`${r}addChildAt: The index ${t} supplied is out of bounds ${e.length}`);const i=r.parent===this;if(r.parent){const s=r.parent.children.indexOf(r);if(i){if(s===t)return r;r.parent.children.splice(s,1)}else r.removeFromParent()}t===e.length?e.push(r):e.splice(t,0,r),r.parent=this,r.didChange=!0,r._updateFlags=15;const n=this.renderGroup||this.parentRenderGroup;return n&&n.addChild(r),this.sortableChildren&&(this.sortDirty=!0),i||(this.emit("childAdded",r,this,t),r.emit("added",this)),r},swapChildren(r,t){if(r===t)return;const e=this.getChildIndex(r),i=this.getChildIndex(t);this.children[e]=t,this.children[i]=r;const n=this.renderGroup||this.parentRenderGroup;n&&(n.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var r;(r=this.parent)==null||r.removeChild(this)},reparentChild(...r){return r.length===1?this.reparentChildAt(r[0],this.children.length):(r.forEach(t=>this.reparentChildAt(t,this.children.length)),r[0])},reparentChildAt(r,t){if(r.parent===this)return this.setChildIndex(r,t),r;const e=r.worldTransform.clone();r.removeFromParent(),this.addChildAt(r,t);const i=this.worldTransform.clone();return i.invert(),e.prepend(i),r.setFromMatrix(e),r},replaceChild(r,t){r.updateLocalTransform(),this.addChildAt(t,this.getChildIndex(r)),t.setFromMatrix(r.localTransform),t.updateLocalTransform(),this.removeChild(r)}},nd={collectRenderables(r,t,e){this.parentRenderLayer&&this.parentRenderLayer!==e||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(r,t,e):this.renderGroup?t.renderPipes.renderGroup.addRenderGroup(this.renderGroup,r):this.collectRenderablesWithEffects(r,t,e))},collectRenderablesSimple(r,t,e){const i=this.children,n=i.length;for(let s=0;s=0;n--){const s=this.effects[n];i[s.pipe].pop(s,this,r)}}};class oi{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let t=0;t{this.add({test:t.test,maskClass:t})}))}add(t){this._tests.push(t)}getMaskEffect(t){this._initialized||this.init();for(let e=0;et in r?CS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ld=(r,t)=>{for(var e in t||(t={}))MS.call(t,e)&&od(r,e,t[e]);if(ad)for(var e of ad(t))RS.call(t,e)&&od(r,e,t[e]);return r};const ud={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const r=this.renderGroup||this.parentRenderGroup;r&&(r.structureDidChange=!0)},addEffect(r){this.effects.indexOf(r)===-1&&(this.effects.push(r),this.effects.sort((t,e)=>t.priority-e.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(r){const t=this.effects.indexOf(r);t!==-1&&(this.effects.splice(t,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(r){const t=this._maskEffect;(t==null?void 0:t.mask)!==r&&(t&&(this.removeEffect(t),ln.returnMaskEffect(t),this._maskEffect=null),r!=null&&(this._maskEffect=ln.getMaskEffect(r),this.addEffect(this._maskEffect)))},get mask(){var r;return(r=this._maskEffect)==null?void 0:r.mask},setMask(r){this._maskOptions=ld(ld({},this._maskOptions),r),r.mask&&(this.mask=r.mask),this._markStructureAsChanged()},set filters(r){var t;!Array.isArray(r)&&r&&(r=[r]);const e=this._filterEffect||(this._filterEffect=new oi);r=r;const i=(r==null?void 0:r.length)>0,n=((t=e.filters)==null?void 0:t.length)>0,s=i!==n;r=Array.isArray(r)?r.slice(0):r,e.filters=Object.freeze(r),s&&(i?this.addEffect(e):(this.removeEffect(e),e.filters=r!=null?r:null))},get filters(){var r;return(r=this._filterEffect)==null?void 0:r.filters},set filterArea(r){this._filterEffect||(this._filterEffect=new oi),this._filterEffect.filterArea=r},get filterArea(){var r;return(r=this._filterEffect)==null?void 0:r.filterArea}},cd={label:null,get name(){return this.label},set name(r){this.label=r},getChildByName(r,t=!1){return this.getChildByLabel(r,t)},getChildByLabel(r,t=!1){const e=this.children;for(let i=0;i=this.x&&t=this.y&&e=h&&t<=p&&e>=f&&e<=m&&!(t>g&&t<_&&e>y&&et.right?t.right:this.right)<=P)return!1;const M=this.yt.bottom?t.bottom:this.bottom)>M}const i=this.left,n=this.right,s=this.top,a=this.bottom;if(n<=i||a<=s)return!1;const o=un[0].set(t.left,t.top),l=un[1].set(t.left,t.bottom),u=un[2].set(t.right,t.top),c=un[3].set(t.right,t.bottom);if(u.x<=o.x||l.y<=o.y)return!1;const h=Math.sign(e.a*e.d-e.b*e.c);if(h===0||(e.apply(o,o),e.apply(l,l),e.apply(u,u),e.apply(c,c),Math.max(o.x,l.x,u.x,c.x)<=i||Math.min(o.x,l.x,u.x,c.x)>=n||Math.max(o.y,l.y,u.y,c.y)<=s||Math.min(o.y,l.y,u.y,c.y)>=a))return!1;const p=h*(l.y-o.y),f=h*(o.x-l.x),m=p*i+f*s,g=p*n+f*s,_=p*i+f*a,y=p*n+f*a;if(Math.max(m,g,_,y)<=p*o.x+f*o.y||Math.min(m,g,_,y)>=p*c.x+f*c.y)return!1;const b=h*(o.y-u.y),x=h*(u.x-o.x),v=b*i+x*s,w=b*n+x*s,T=b*i+x*a,E=b*n+x*a;return!(Math.max(v,w,T,E)<=b*o.x+x*o.y||Math.min(v,w,T,E)>=b*c.x+x*c.y)}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=t*2,this.height+=e*2,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),n=Math.max(this.y,t.y),s=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=n,this.height=Math.max(s-n,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,n=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=n-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),n=Math.min(this.y,t.y),s=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=n,this.height=s-n,this}getBounds(t){return t||(t=new ut),t.copyFrom(this),t}containsRect(t){if(this.width<=0||this.height<=0)return!1;const e=t.x,i=t.y,n=t.x+t.width,s=t.y+t.height;return e>=this.x&&e=this.y&&i=this.x&&n=this.y&&sthis.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new ut);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=hd,this}set(t,e,i,n){this.minX=t,this.minY=e,this.maxX=i,this.maxY=n}addFrame(t,e,i,n,s){s||(s=this.matrix);const a=s.a,o=s.b,l=s.c,u=s.d,c=s.tx,h=s.ty;let p=this.minX,f=this.minY,m=this.maxX,g=this.maxY,_=a*t+l*e+c,y=o*t+u*e+h;_m&&(m=_),y>g&&(g=y),_=a*i+l*e+c,y=o*i+u*e+h,_m&&(m=_),y>g&&(g=y),_=a*t+l*n+c,y=o*t+u*n+h,_m&&(m=_),y>g&&(g=y),_=a*i+l*n+c,y=o*i+u*n+h,_m&&(m=_),y>g&&(g=y),this.minX=p,this.minY=f,this.maxX=m,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.maxXthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=a*e+l*s+c,f=o*e+u*s+h,this.minX=pthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY,p=a*n+l*s+c,f=o*n+u*s+h,this.minX=pthis.maxX?p:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(t){return this.minXt.right&&(this.maxX=t.right),this.minYt.bottom&&(this.maxY=t.bottom),this}fitBounds(t,e,i,n){return this.minXe&&(this.maxX=e),this.minYn&&(this.maxY=n),this}pad(t,e=t){return this.minX-=t,this.maxX+=t,this.minY-=e,this.maxY+=e,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Mt(this.minX,this.minY,this.maxX,this.maxY)}scale(t,e=t){return this.minX*=t,this.minY*=e,this.maxX*=t,this.maxY*=e,this}get x(){return this.minX}set x(t){const e=this.maxX-this.minX;this.minX=t,this.maxX=t+e}get y(){return this.minY}set y(t){const e=this.maxY-this.minY;this.minY=t,this.maxY=t+e}get width(){return this.maxX-this.minX}set width(t){this.maxX=this.minX+t}get height(){return this.maxY-this.minY}set height(t){this.maxY=this.minY+t}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(t,e,i,n){let s=this.minX,a=this.minY,o=this.maxX,l=this.maxY;n||(n=this.matrix);const u=n.a,c=n.b,h=n.c,p=n.d,f=n.tx,m=n.ty;for(let g=e;go?b:o,l=x>l?x:l}this.minX=s,this.minY=a,this.maxX=o,this.maxY=l}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}}const Dt=Pt.getPool(U),ve=Pt.getPool(Mt),OS=new U,dd={getFastGlobalBounds(r,t){t||(t=new Mt),t.clear(),this._getGlobalBoundsRecursive(!!r,t,this.parentRenderLayer),t.isValid||t.set(0,0,0,0);const e=this.renderGroup||this.parentRenderGroup;return t.applyMatrix(e.worldTransform),t},_getGlobalBoundsRecursive(r,t,e){let i=t;if(r&&this.parentRenderLayer&&this.parentRenderLayer!==e||this.localDisplayStatus!==7||!this.measurable)return;const n=!!this.effects.length;if((this.renderGroup||n)&&(i=ve.get().clear()),this.boundsArea)t.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const a=this.bounds;i.addFrame(a.minX,a.minY,a.maxX,a.maxY,this.groupTransform)}const s=this.children;for(let a=0;a>16&255,i=r>>8&255,n=r&255,s=t>>16&255,a=t>>8&255,o=t&255,l=e*s/255|0,u=i*a/255|0,c=n*o/255|0;return(l<<16)+(u<<8)+c}const fd=16777215;function ui(r,t){return r===fd?t:t===fd?r:Oe(r,t)}function xe(r){return((r&255)<<16)+(r&65280)+(r>>16&255)}const md={getGlobalAlpha(r){if(r)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let t=this.alpha,e=this.parent;for(;e;)t*=e.alpha,e=e.parent;return t},getGlobalTransform(r=new U,t){if(t)return r.copyFrom(this.worldTransform);this.updateLocalTransform();const e=cn(this,Dt.get().identity());return r.appendFrom(this.localTransform,e),Dt.return(e),r},getGlobalTint(r){if(r)return this.renderGroup?xe(this.renderGroup.worldColor):this.parentRenderGroup?xe(ui(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let t=this.localColor,e=this.parent;for(;e;)t=ui(t,e.localColor),e=e.parent;return xe(t)}};function hn(r,t,e){return t.clear(),e||(e=U.IDENTITY),gd(r,t,e,r,!0),t.isValid||t.set(0,0,0,0),t}function gd(r,t,e,i,n){var s,a;let o;if(n)o=Dt.get(),o=e.copyTo(o);else{if(!r.visible||!r.measurable)return;r.updateLocalTransform();const c=r.localTransform;o=Dt.get(),o.appendFrom(c,e)}const l=t,u=!!r.effects.length;if(u&&(t=ve.get().clear()),r.boundsArea)t.addRect(r.boundsArea,o);else{r.renderPipeId&&(t.matrix=o,t.addBounds(r.bounds));const c=r.children;for(let h=0;h>>1,r|=r>>>2,r|=r>>>4,r|=r>>>8,r|=r>>>16,r+1}function Fa(r){return!(r&r-1)&&!!r}function BS(r){let t=(r>65535?1:0)<<4;r>>>=t;let e=(r>255?1:0)<<3;return r>>>=e,t|=e,e=(r>15?1:0)<<2,r>>>=e,t|=e,e=(r>3?1:0)<<1,r>>>=e,t|=e,t|r>>1}function he(r){const t={};for(const e in r)r[e]!==void 0&&(t[e]=r[e]);return t}var FS=Object.defineProperty,xd=Object.getOwnPropertySymbols,DS=Object.prototype.hasOwnProperty,US=Object.prototype.propertyIsEnumerable,Td=(r,t,e)=>t in r?FS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Sd=(r,t)=>{for(var e in t||(t={}))DS.call(t,e)&&Td(r,e,t[e]);if(xd)for(var e of xd(t))US.call(t,e)&&Td(r,e,t[e]);return r};const wd=Object.create(null);function $S(r){const t=wd[r];return t===void 0&&(wd[r]=ht("resource")),t}const Ed=class C1 extends Nt{constructor(t={}){var e,i,n,s,a,o,l;super(),this._resourceType="textureSampler",this._touched=0,this._maxAnisotropy=1,this.destroyed=!1,t=Sd(Sd({},C1.defaultOptions),t),this.addressMode=t.addressMode,this.addressModeU=(e=t.addressModeU)!=null?e:this.addressModeU,this.addressModeV=(i=t.addressModeV)!=null?i:this.addressModeV,this.addressModeW=(n=t.addressModeW)!=null?n:this.addressModeW,this.scaleMode=t.scaleMode,this.magFilter=(s=t.magFilter)!=null?s:this.magFilter,this.minFilter=(a=t.minFilter)!=null?a:this.minFilter,this.mipmapFilter=(o=t.mipmapFilter)!=null?o:this.mipmapFilter,this.lodMinClamp=t.lodMinClamp,this.lodMaxClamp=t.lodMaxClamp,this.compare=t.compare,this.maxAnisotropy=(l=t.maxAnisotropy)!=null?l:1}set addressMode(t){this.addressModeU=t,this.addressModeV=t,this.addressModeW=t}get addressMode(){return this.addressModeU}set wrapMode(t){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._sharedResourceId=null,this.emit("change",this)}_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=$S(t),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};Ed.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Jt=Ed;var kS=Object.defineProperty,Pd=Object.getOwnPropertySymbols,LS=Object.prototype.hasOwnProperty,NS=Object.prototype.propertyIsEnumerable,Ad=(r,t,e)=>t in r?kS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Cd=(r,t)=>{for(var e in t||(t={}))LS.call(t,e)&&Ad(r,e,t[e]);if(Pd)for(var e of Pd(t))NS.call(t,e)&&Ad(r,e,t[e]);return r};const Md=class M1 extends Nt{constructor(t={}){var e,i,n,s,a;super(),this.options=t,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=ht("textureSource"),this._resourceType="textureSource",this._resourceId=ht("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.viewDimension="2d",this.arrayLayerCount=1,this.antialias=!1,this.transient=!1,this._touched=0,this._batchTick=-1,this._textureBindLocation=-1,t=Cd(Cd({},M1.defaultOptions),t),this.label=(e=t.label)!=null?e:"",this.resource=t.resource,this.autoGarbageCollect=t.autoGarbageCollect,this._resolution=t.resolution,t.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&(i=this.resourceWidth)!=null?i:1,t.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&(n=this.resourceHeight)!=null?n:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=t.format,this.dimension=t.dimensions,this.viewDimension=(s=t.viewDimension)!=null?s:t.dimensions,this.arrayLayerCount=t.arrayLayerCount,this.mipLevelCount=t.mipLevelCount,this.autoGenerateMipmaps=t.autoGenerateMipmaps,this.sampleCount=t.sampleCount,this.antialias=t.antialias,this.transient=(a=t.transient)!=null?a:!1,this.alphaMode=t.alphaMode,this.style=new Jt(he(t)),this.destroyed=!1,this._refreshPOT()}get source(){return this}get style(){return this._style}set style(t){var e,i;this.style!==t&&((e=this._style)==null||e.off("change",this._onStyleChange,this),this._style=t,(i=this._style)==null||i.on("change",this._onStyleChange,this),this._onStyleChange())}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.unload(),this.emit("destroy",this),this._style&&(this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var t,e;this._resourceId=ht("resource"),this.emit("change",this),this.emit("unload",this);for(const i in this._gpuData)(e=(t=this._gpuData[i])==null?void 0:t.destroy)==null||e.call(t);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:t}=this;return t.naturalWidth||t.videoWidth||t.displayWidth||t.width}get resourceHeight(){const{resource:t}=this;return t.naturalHeight||t.videoHeight||t.displayHeight||t.height}get resolution(){return this._resolution}set resolution(t){this._resolution!==t&&(this._resolution=t,this.width=this.pixelWidth/t,this.height=this.pixelHeight/t)}resize(t,e,i){i||(i=this._resolution),t||(t=this.width),e||(e=this.height);const n=Math.round(t*i),s=Math.round(e*i);return this.width=n/i,this.height=s/i,this._resolution=i,this.pixelWidth===n&&this.pixelHeight===s?!1:(this._refreshPOT(),this.pixelWidth=n,this.pixelHeight=s,this.emit("resize",this),this._resourceId=ht("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=Fa(this.pixelWidth)&&Fa(this.pixelHeight)}static test(t){throw new Error("Unimplemented")}};Md.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",dimensions:"2d",viewDimension:"2d",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let ft=Md;const Qe=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Je=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],tr=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],er=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],Da=[],Rd=[],pn=Math.sign;function XS(){for(let r=0;r<16;r++){const t=[];Da.push(t);for(let e=0;e<16;e++){const i=pn(Qe[r]*Qe[e]+tr[r]*Je[e]),n=pn(Je[r]*Qe[e]+er[r]*Je[e]),s=pn(Qe[r]*tr[e]+tr[r]*er[e]),a=pn(Je[r]*tr[e]+er[r]*er[e]);for(let o=0;o<16;o++)if(Qe[o]===i&&Je[o]===n&&tr[o]===s&&er[o]===a){t.push(o);break}}}for(let r=0;r<16;r++){const t=new U;t.set(Qe[r],Je[r],tr[r],er[r],0,0),Rd.push(t)}}XS();const W={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:r=>Qe[r],uY:r=>Je[r],vX:r=>tr[r],vY:r=>er[r],inv:r=>r&8?r&15:-r&7,add:(r,t)=>Da[r][t],sub:(r,t)=>Da[r][W.inv(t)],rotate180:r=>r^4,isVertical:r=>(r&3)===2,byDirection:(r,t)=>Math.abs(r)*2<=Math.abs(t)?t>=0?W.S:W.N:Math.abs(t)*2<=Math.abs(r)?r>0?W.E:W.W:t>0?r>0?W.SE:W.SW:r>0?W.NE:W.NW,matrixAppendRotationInv:(r,t,e=0,i=0,n=0,s=0)=>{const a=Rd[W.inv(t)],o=a.a,l=a.b,u=a.c,c=a.d,h=e-Math.min(0,o*n,u*s,o*n+u*s),p=i-Math.min(0,l*n,c*s,l*n+c*s),f=r.a,m=r.b,g=r.c,_=r.d;r.a=o*f+l*g,r.b=o*m+l*_,r.c=u*f+c*g,r.d=u*m+c*_,r.tx=h*f+p*g+r.tx,r.ty=h*m+p*_+r.ty},transformRectCoords:(r,t,e,i)=>{const{x:n,y:s,width:a,height:o}=r,{x:l,y:u,width:c,height:h}=t;return e===W.E?(i.set(n+l,s+u,a,o),i):e===W.S?i.set(c-s-o+l,n+u,o,a):e===W.W?i.set(c-n-a+l,h-s-o+u,a,o):e===W.N?i.set(s+l,h-n-a+u,o,a):i.set(n+l,s+u,a,o)}},Ua=()=>{};var jS=Object.defineProperty,HS=Object.defineProperties,zS=Object.getOwnPropertyDescriptors,Od=Object.getOwnPropertySymbols,WS=Object.prototype.hasOwnProperty,VS=Object.prototype.propertyIsEnumerable,Gd=(r,t,e)=>t in r?jS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,YS=(r,t)=>{for(var e in t||(t={}))WS.call(t,e)&&Gd(r,e,t[e]);if(Od)for(var e of Od(t))VS.call(t,e)&&Gd(r,e,t[e]);return r},KS=(r,t)=>HS(r,zS(t));class fn extends ft{constructor(t){const e=t.resource||new Float32Array(t.width*t.height*4);let i=t.format;i||(e instanceof Float32Array?i="rgba32float":e instanceof Int32Array||e instanceof Uint32Array?i="rgba32uint":e instanceof Int16Array||e instanceof Uint16Array?i="rgba16uint":(e instanceof Int8Array,i="bgra8unorm")),super(KS(YS({},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}}fn.extension=S.TextureSource;const Id=new U;class $a{constructor(t,e){this.mapCoord=new U,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof e=="undefined"?this.clampMargin=t.width<10?0:.5:this.clampMargin=e,this.isSimple=!1,this.texture=t}get texture(){return this._texture}set texture(t){var e;this._texture!==t&&((e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=t,this._texture.addListener("update",this.update,this)),this.update()}multiplyUvs(t,e){e===void 0&&(e=t);const i=this.mapCoord;for(let n=0;nt in r?qS(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,e2=(r,t)=>{for(var e in t||(t={}))JS.call(t,e)&&Fd(r,e,t[e]);if(Bd)for(var e of Bd(t))t2.call(t,e)&&Fd(r,e,t[e]);return r},r2=(r,t)=>ZS(r,QS(t));let i2=0;class Dd{constructor(t){this._poolKeyHash=Object.create(null),this._texturePool={},this.textureOptions=t||{},this.enableFullScreen=!1,this.textureStyle=new Jt(this.textureOptions)}createTexture(t,e,i,n){const s=new ft(r2(e2({},this.textureOptions),{width:t,height:e,resolution:1,antialias:i,autoGarbageCollect:!1,autoGenerateMipmaps:n}));return new D({source:s,label:`texturePool_${i2++}`})}getOptimalTexture(t,e,i=1,n,s=!1){let a=Math.ceil(t*i-1e-6),o=Math.ceil(e*i-1e-6);a=Ze(a),o=Ze(o);const l=n?1:0,u=s?1:0,c=(a<<17)+(o<<2)+(u<<1)+l;this._texturePool[c]||(this._texturePool[c]=[]);let h=this._texturePool[c].pop();return h||(h=this.createTexture(a,o,n,s)),h.source._resolution=i,h.source.width=a/i,h.source.height=o/i,h.source.pixelWidth=a,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]=c,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=t!==!1,t)for(const e in this._texturePool){const i=this._texturePool[e];if(i)for(let n=0;n-1&&this.renderGroupChildren.splice(e,1),t.renderGroupParent=null}addChild(t){if(this.structureDidChange=!0,t.parentRenderGroup=this,t.updateTick=-1,t.parent===this.root?t.relativeRenderGroupDepth=1:t.relativeRenderGroupDepth=t.parent.relativeRenderGroupDepth+1,t.didChange=!0,this.onChildUpdate(t),t.renderGroup){this.addRenderGroupChild(t.renderGroup);return}t._onRender&&this.addOnRender(t);const e=t.children;for(let i=0;i0}addOnRender(t){this._onRenderContainers.push(t)}removeOnRender(t){this._onRenderContainers.splice(this._onRenderContainers.indexOf(t),1)}runOnRender(t){for(let e=0;ethis.addChild(n)),(i=t.parent)==null||i.addChild(this)}static mixin(t){N.mixin(dt,t)}set _didChangeId(t){this._didViewChangeTick=t>>12&4095,this._didContainerChangeTick=t&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...t){if(t.length>1){for(let n=0;n1){for(let n=0;n-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==null||t.removeChild(this),this.renderGroup=Pt.get(mn,this),this.groupTransform=U.IDENTITY,t==null||t.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const t=this.parentRenderGroup;t==null||t.removeChild(this),Pt.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,t==null||t.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new U),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*Qh}set angle(t){this.rotation=t*Jh}get pivot(){return this._pivot===La&&(this._pivot=new bt(this,0,0)),this._pivot}set pivot(t){this._pivot===La&&(this._pivot=new bt(this,0,0)),typeof t=="number"?this._pivot.set(t):this._pivot.copyFrom(t)}get skew(){return this._skew===ka&&(this._skew=new bt(this,0,0)),this._skew}set skew(t){this._skew===ka&&(this._skew=new bt(this,0,0)),this._skew.copyFrom(t)}get scale(){return this._scale===Na&&(this._scale=new bt(this,1,1)),this._scale}set scale(t){this._scale===Na&&(this._scale=new bt(this,0,0)),typeof t=="string"&&(t=parseFloat(t)),typeof t=="number"?this._scale.set(t):this._scale.copyFrom(t)}get origin(){return this._origin===Xa&&(this._origin=new bt(this,0,0)),this._origin}set origin(t){this._origin===Xa&&(this._origin=new bt(this,0,0)),typeof t=="number"?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){var i;const n=this.getLocalBounds();typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,n.width),e!==void 0&&this._setHeight(e,n.height)}_updateSkew(){const t=this._rotation,e=this._skew;this._cx=Math.cos(t+e._y),this._sx=Math.sin(t+e._y),this._cy=-Math.sin(t-e._x),this._sy=Math.cos(t-e._x)}updateTransform(t){return this.position.set(typeof t.x=="number"?t.x:this.position.x,typeof t.y=="number"?t.y:this.position.y),this.scale.set(typeof t.scaleX=="number"?t.scaleX:this.scale.x,typeof t.scaleY=="number"?t.scaleY:this.scale.y),this.rotation=typeof t.rotation=="number"?t.rotation:this.rotation,this.skew.set(typeof t.skewX=="number"?t.skewX:this.skew.x,typeof t.skewY=="number"?t.skewY:this.skew.y),this.pivot.set(typeof t.pivotX=="number"?t.pivotX:this.pivot.x,typeof t.pivotY=="number"?t.pivotY:this.pivot.y),this.origin.set(typeof t.originX=="number"?t.originX:this.origin.x,typeof t.originY=="number"?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,n=this._pivot,s=this._origin,a=this._position,o=i._x,l=i._y,u=n._x,c=n._y,h=-s._x,p=-s._y;e.a=this._cx*o,e.b=this._sx*o,e.c=this._cy*l,e.d=this._sy*l,e.tx=a._x-(u*e.a+c*e.c)+(h*e.a+p*e.c)-h,e.ty=a._y-(u*e.b+c*e.d)+(h*e.b+p*e.d)-p}set alpha(t){t!==this.localAlpha&&(this.localAlpha=t,this._updateFlags|=ci,this._onUpdate())}get alpha(){return this.localAlpha}set tint(t){const e=tt.shared.setValue(t!=null?t:16777215).toBgrNumber();e!==this.localColor&&(this.localColor=e,this._updateFlags|=ci,this._onUpdate())}get tint(){return xe(this.localColor)}set blendMode(t){this.localBlendMode!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=_n,this.localBlendMode=t,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(t){const e=t?2:0;(this.localDisplayStatus&2)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=xr,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",t))}get culled(){return!(this.localDisplayStatus&4)}set culled(t){const e=t?0:4;(this.localDisplayStatus&4)!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=xr,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(t){const e=t?1:0;(this.localDisplayStatus&1)!==e&&(this._updateFlags|=xr,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(t=!1){var e;if(this.destroyed)return;this.destroyed=!0;let i;if(this.children.length&&(i=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(),(typeof t=="boolean"?t:t==null?void 0:t.children)&&i)for(let n=0;n(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(Te||{});class yn{constructor(t,e=null,i=0,n=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=t,this._context=e,this.priority=i,this._once=n}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 Ud=class re{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 yn(null,null,1/0),this.deltaMS=1/re.targetFPMS,this.elapsedMS=1/re.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=Te.NORMAL){return this._addListener(new yn(t,e,i))}addOnce(t,e,i=Te.NORMAL){return this._addListener(new yn(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){const s=t-this._lastFrame|0;if(sthis.maxFPS&&(this.maxFPS=t)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){t===0?this._minElapsedMS=0:(t{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),i=this._canvas.width,n=this._canvas.height,s=e.width/i*this._renderer.resolution,a=e.height/n*this._renderer.resolution,o=e.left,l=e.top,u=`translate(${o}px, ${l}px) scale(${s}, ${a})`;u!==this._lastTransform&&(this._domElement.style.transform=u,this._lastTransform=u)},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 i=this.canvas.width,n=this.canvas.height,s=e.contentRect.width/i*this._renderer.resolution,a=e.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==a)&&(this.updateTranslation(),this._lastScaleX=s,this._lastScaleY=a)}}),this._observer.observe(this._canvas)):this._tickerAttached||Ot.shared.add(this.updateTranslation,this,Te.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&Ot.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 Tr{constructor(t){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=Tr.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new lt,this.page=new lt,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,n,s){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 Ha=/iPhone/i,$d=/iPod/i,kd=/iPad/i,Ld=/\biOS-universal(?:.+)Mac\b/i,za=/\bAndroid(?:.+)Mobile\b/i,Nd=/Android/i,Sr=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,bn=/Silk/i,Ge=/Windows Phone/i,Xd=/\bWindows(?:.+)ARM\b/i,jd=/BlackBerry/i,Hd=/BB10/i,zd=/Opera Mini/i,Wd=/\b(CriOS|Chrome)(?:.+)Mobile/i,Vd=/Mobile(?:.+)Firefox\b/i,Yd=function(r){return typeof r!="undefined"&&r.platform==="MacIntel"&&typeof r.maxTouchPoints=="number"&&r.maxTouchPoints>1&&typeof MSStream=="undefined"};function s2(r){return function(t){return t.test(r)}}function Kd(r){var t={userAgent:"",platform:"",maxTouchPoints:0};!r&&typeof navigator!="undefined"?t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof r=="string"?t.userAgent=r:r&&r.userAgent&&(t={userAgent:r.userAgent,platform:r.platform,maxTouchPoints:r.maxTouchPoints||0});var e=t.userAgent,i=e.split("[FBAN");typeof i[1]!="undefined"&&(e=i[0]),i=e.split("Twitter"),typeof i[1]!="undefined"&&(e=i[0]);var n=s2(e),s={apple:{phone:n(Ha)&&!n(Ge),ipod:n($d),tablet:!n(Ha)&&(n(kd)||Yd(t))&&!n(Ge),universal:n(Ld),device:(n(Ha)||n($d)||n(kd)||n(Ld)||Yd(t))&&!n(Ge)},amazon:{phone:n(Sr),tablet:!n(Sr)&&n(bn),device:n(Sr)||n(bn)},android:{phone:!n(Ge)&&n(Sr)||!n(Ge)&&n(za),tablet:!n(Ge)&&!n(Sr)&&!n(za)&&(n(bn)||n(Nd)),device:!n(Ge)&&(n(Sr)||n(bn)||n(za)||n(Nd))||n(/\bokhttp\b/i)},windows:{phone:n(Ge),tablet:n(Xd),device:n(Ge)||n(Xd)},other:{blackberry:n(jd),blackberry10:n(Hd),opera:n(zd),firefox:n(Vd),chrome:n(Wd),device:n(jd)||n(Hd)||n(zd)||n(Vd)||n(Wd)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}var qd;const Zd=((qd=Kd.default)!=null?qd:Kd)(globalThis.navigator);var a2=Object.defineProperty,Qd=Object.getOwnPropertySymbols,o2=Object.prototype.hasOwnProperty,l2=Object.prototype.propertyIsEnumerable,Jd=(r,t,e)=>t in r?a2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,tp=(r,t)=>{for(var e in t||(t={}))o2.call(t,e)&&Jd(r,e,t[e]);if(Qd)for(var e of Qd(t))l2.call(t,e)&&Jd(r,e,t[e]);return r};const u2=9,ep=100,c2=0,h2=0,rp=2,ip=1,d2=-1e3,p2=-1e3,f2=2,Wa=class R1{constructor(t,e=Zd){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=`${ip}px`,t.style.height=`${ip}px`,t.style.position="absolute",t.style.top=`${d2}px`,t.style.left=`${p2}px`,t.style.zIndex=f2.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=`${c2}px`,this._div.style.left=`${h2}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=rp.toString(),this._canvasObserver=new ja({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(){var t,e;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 i of this._children)(t=i._accessibleDiv)!=null&&t.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(e=this._div)!=null&&e.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 i=0;i=0;i--){const n=this._children[i];e.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,Ia(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i title : ${t.title}
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):(t.accessibleType==="button"?e=document.createElement("button"):(e=document.createElement(t.accessibleType),e.style.cssText=` color: transparent; pointer-events: none; padding: 0; @@ -17,7 +17,7 @@ var CB=Object.defineProperty;var S1=Object.getOwnPropertySymbols;var MB=Object.p -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; - `,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${tp}px`,e.style.height=`${tp}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=ep.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),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,n=this._renderer.events.rootBoundary,s=Object.assign(new Tr(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(a=>n.dispatchEvent(s,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==n2||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.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]}};za.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"accessibility"},za.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let ip=za;const np={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};X.add(ip),X.mixin(dt,np);class Wa{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 Xa({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(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e=e.minX&&i<=e.maxX&&n>=e.minY&&n<=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)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const s=n[this.renderPipeId];s!=null&&s.addRenderable&&s.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,o=a.length;for(let l=0;lt in r?c2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,h2=(r,t)=>{for(var e in t||(t={}))sp.call(t,e)&&op(r,e,t[e]);if(yn)for(var e of yn(t))ap.call(t,e)&&op(r,e,t[e]);return r},d2=(r,t)=>{var e={};for(var i in r)sp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&yn)for(var i of yn(r))t.indexOf(i)<0&&ap.call(r,i)&&(e[i]=r[i]);return e};class p2 extends Se{constructor(t={}){const e=t,{element:i,anchor:n}=e,s=d2(e,["element","anchor"]);super(h2({label:"DOMContainer"},s)),this.renderPipeId="dom",this.batched=!1,this._anchor=new lt(0,0),n&&(this.anchor=n),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:i,offsetHeight:n}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=n}destroy(t=!1){var e,i;super.destroy(t),(i=(e=this._element)==null?void 0:e.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}X.add(Wa);let f2=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||(Ot.system.add(this._tickerUpdate,this,Te.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Ot.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(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._deltaTimei.priority-n.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,n=e.length;i=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)n.forEach(a=>{t.currentTarget=i[s],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i=0;h--){const p=c[h],f=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,n,s,a||s(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const m=t.isInteractive();(f.length>0||m)&&(m&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:l&&!s(t,i)&&n(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=i;for(let c=l.length-1;c>=0;c--){const h=l[c],p=this.hitTestRecursive(h,this._isInteractive(e)?e:h.eventMode,u,n,s);if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();return(p.length>0||f)&&p.push(t),p}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&n(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,di),!t.hitArea.contains(di.x,di.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i0&&l!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,h,l);if(this.dispatchEvent(p,"pointerout"),a&&this.dispatchEvent(p,"mouseout"),!s.composedPath().includes(l)){const f=this.createPointerEvent(t,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!s.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),a&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(p)}if(l!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(s,h);this.dispatchEvent(p,"pointerover"),a&&this.dispatchEvent(p,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==s.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const m=this.clonePointerEvent(s,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==l&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),a&&this.notifyTarget(m,"mouseenter"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(p)}const u=[],c=(i=this.enableGlobalMoveEvents)!=null?i:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&u.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&u.push("globaltouchmove")),a&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&u.push("globalmousemove"),this.cursor=(n=s.target)==null?void 0:n.cursor),u.length>0&&this.all(s,u),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof ae))return;const i=this.trackingData(t.pointerId),n=this.createPointerEvent(t),s=n.pointerType==="mouse"||n.pointerType==="pen";this.dispatchEvent(n,"pointerover"),s&&this.dispatchEvent(n,"mouseover"),n.pointerType==="mouse"&&(this.cursor=(e=n.target)==null?void 0:e.cursor);const a=this.clonePointerEvent(n,"pointerenter");for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),s&&this.notifyTarget(a,"mouseenter"),a.target=a.target.parent;i.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(a)}mapPointerOut(t){if(!(t instanceof ae))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const a=this.createPointerEvent(t,"pointerleave",n);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof ae))return;const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let a=s;if(s&&!i.composedPath().includes(s)){let o=s;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}o=o.parent}delete n.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const l=n.clicksByButton[t.button];if(l.target===o.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=o.target,l.timeStamp=e,o.detail=l.clickCount,o.pointerType==="mouse"){const u=o.button===2;this.dispatchEvent(o,u?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof ae))return;const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof rr))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;it in r?_2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,v2=(r,t)=>{for(var e in t||(t={}))y2.call(t,e)&&cp(r,e,t[e]);if(up)for(var e of up(t))b2.call(t,e)&&cp(r,e,t[e]);return r};const x2=1,T2={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Va=class xh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new lp(null),we.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new ae(null),this._rootWheelEvent=new rr(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(v2({},xh.defaultEventFeatures),{set:(e,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),e[i]=n,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,i;const{canvas:n,resolution:s}=this.renderer;this.setTargetElement(n),this.resolution=s,xh._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(i=t.eventFeatures)!=null?i:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){we.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,n=e.length;i0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",n=this._normalizeToPointerData(t);for(let s=0,a=n.length;s{l.off(r,o,a)}),s?l.once(r,o,a):l.on(r,o,a)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,n=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,n)},dispatchEvent(r){if(!(r instanceof Tr))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};X.add(Ya),X.mixin(dt,hp);var te=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(te||{});const dp={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let pp=dp;const H={get(){return pp},set(r){pp=r}};function de(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function pi(r){return r.split("?")[0].split("#")[0]}function S2(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function w2(r,t,e){return r.replace(new RegExp(S2(t),"g"),e)}function P2(r,t){let e="",i=0,n=-1,s=0,a=-1;for(let o=0;o<=r.length;++o){if(o2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),n=o,s=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=o,s=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(n+1,o)}`:e=r.slice(n+1,o),i=o-n-1;n=o,s=0}else a===46&&s!==-1?++s:s=-1}return e}const zt={toPosix(r){return w2(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){de(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(de(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=pi(this.toPosix(t!=null?t:H.get().getBaseUrl())),n=pi(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?zt.join(n,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(de(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=P2(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return de(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let i=0;i0)if(e===void 0)e=n;else{const s=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${n}`:e+=`/${n}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(de(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,n=!0;const s=this.getProtocol(r),a=r;r=r.slice(s.length);for(let o=r.length-1;o>=1;--o)if(t=r.charCodeAt(o),t===47){if(!n){i=o;break}}else n=!1;return i===-1?e?"/":this.isUrl(a)?s+r:s:e&&i===1?"//":s+r.slice(0,i)},rootname(r){de(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){de(r),t&&de(t),r=pi(this.toPosix(r));let e=0,i=-1,n=!0,s;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let a=t.length-1,o=-1;for(s=r.length-1;s>=0;--s){const l=r.charCodeAt(s);if(l===47){if(!n){e=s+1;break}}else o===-1&&(n=!1,o=s+1),a>=0&&(l===t.charCodeAt(a)?--a===-1&&(i=s):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=r.length),r.slice(e,i)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===47){if(!n){e=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(e,i)},extname(r){de(r),r=pi(this.toPosix(r));let t=-1,e=0,i=-1,n=!0,s=0;for(let a=r.length-1;a>=0;--a){const o=r.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}i===-1&&(n=!1,i=a+1),o===46?t===-1?t=a:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||i===-1||s===0||s===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){de(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=pi(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let n;const s="";t.root=this.rootname(r),i||this.hasProtocol(r)?n=1:n=0;let a=-1,o=0,l=-1,u=!0,c=r.length-1,h=0;for(;c>=n;--c){if(e=r.charCodeAt(c),e===47){if(!u){o=c+1;break}continue}l===-1&&(u=!1,l=c+1),e===46?a===-1?a=c:h!==1&&(h=1):a!==-1&&(h=-1)}return a===-1||l===-1||h===0||h===1&&a===l-1&&a===o+1?l!==-1&&(o===0&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(o,l)):(o===0&&i?(t.name=r.slice(1,a),t.base=r.slice(1,l)):(t.name=r.slice(o,a),t.base=r.slice(o,l)),t.ext=r.slice(a,l)),t.dir=this.dirname(r),s&&(t.dir=s+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},oe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function fp(r,t,e,i,n){const s=t[e];for(let a=0;a{const a=s.substring(1,s.length-1).split(",");n.push(a)}),fp(r,n,0,e,i)}else i.push(r);return i}const fi=r=>!Array.isArray(r);var E2=Object.defineProperty,A2=Object.defineProperties,C2=Object.getOwnPropertyDescriptors,gp=Object.getOwnPropertySymbols,M2=Object.prototype.hasOwnProperty,R2=Object.prototype.propertyIsEnumerable,_p=(r,t,e)=>t in r?E2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ir=(r,t)=>{for(var e in t||(t={}))M2.call(t,e)&&_p(r,e,t[e]);if(gp)for(var e of gp(t))R2.call(t,e)&&_p(r,e,t[e]);return r},O2=(r,t)=>A2(r,C2(t));class $e{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,n;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(n=t.extractAssetIdFromBundle)!=null?n:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return oe(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(s=>{var a;return(a=s==null?void 0:s.src)!=null?a:s}):n!=null&&n.src?n.src:n,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([s,a])=>typeof a=="string"||Array.isArray(a)?{alias:s,src:a}:ir({alias:s},a))),n.forEach(s=>{const a=s.src,o=s.alias;let l;if(typeof o=="string"){const u=this._createBundleAssetId(t,o);i.push(u),l=[o,u]}else{const u=o.map(c=>this._createBundleAssetId(t,c));i.push(...u),l=[...o,...u]}this.add(O2(ir({},s),{alias:l,src:a}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;oe(e).forEach(n=>{const{src:s}=n;let{data:a,format:o,loadParser:l,parser:u}=n;const c=oe(s).map(m=>typeof m=="string"?mp(m):Array.isArray(m)?m:[m]),h=this.getAlias(n),p=[],f=m=>{const g=this._parsers.find(_=>_.test(m));return ir({src:m},g==null?void 0:g.parse(m))};c.forEach(m=>{m.forEach(g=>{var _,y,b,x;let v={};if(typeof g!="object"?v=f(g):(a=(_=g.data)!=null?_:a,o=(y=g.format)!=null?y:o,(g.loadParser||g.parser)&&(l=(b=g.loadParser)!=null?b:l,u=(x=g.parser)!=null?x:u),v=ir(ir({},f(g.src)),g)),!h)throw new Error(`[Resolver] alias is undefined for this asset: ${v.src}`);v=this._buildResolvedAsset(v,{aliases:h,data:a,format:o,loadParser:l,parser:u,progressSize:n.progressSize}),p.push(v)})}),h.forEach(m=>{this._assetMap[m]=p})})}resolveBundle(t){const e=fi(t);t=oe(t);const i={};return t.forEach(n=>{const s=this._bundles[n];if(s){const a=this.resolve(s),o={};for(const l in a){const u=a[l];o[this._extractAssetIdFromBundle(n,l)]=u}i[n]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=fi(t);t=oe(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let s=this._assetMap[n];const a=this._getPreferredOrder(s);a==null||a.priority.forEach(o=>{a.params[o].forEach(l=>{const u=s.filter(c=>c[o]?c[o]===l:!1);u.length&&(s=u)})}),this._resolverHash[n]=s[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;es.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,n;const{aliases:s,data:a,loadParser:o,parser:l,format:u,progressSize:c}=e;return(this._basePath||this._rootPath)&&(t.src=zt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=s!=null?s:t.alias)!=null?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=ir(ir({},a||{}),t.data),t.loadParser=o!=null?o:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(n=u!=null?u:t.format)!=null?n:yp(t.src),c!==void 0&&(t.progressSize=c),t}}$e.RETINA_PREFIX=/@([0-9\.]+)x/;function yp(r){return r.split(".").pop().split("?").shift().split("#").shift()}const bn=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},bp=class en{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof ft&&(i={texture:t,data:e});const{texture:n,data:s,cachePrefix:a=""}=i;this.cachePrefix=a,this._texture=n instanceof D?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=s;const o=parseFloat(s.meta.scale);o?(this.resolution=o,n.source.resolution=this.resolution):this.resolution=n.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=en.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let i=t;const n=e?1/0:en.BATCH_SIZE;for(;i-t{this._batchIndex*en.BATCH_SIZE{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=zt.dirname(r[0]);t.linkedSheets.forEach((s,a)=>{const o=vp([`${n}/${t.data.meta.related_multi_packs[a]}`],s,!0);Object.assign(i,o)})}return i}const xp={extension:S.Asset,cache:{test:r=>r instanceof Ka,getCacheableAssets:(r,t)=>vp(r,t,!1)},resolver:{extension:{type:S.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&G2.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:S.LoadParser,priority:te.Normal,name:"spritesheetLoader"},async testParse(r,t){return zt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,n,s;const{texture:a,imageFilename:o,textureOptions:l,cachePrefix:u}=(i=t==null?void 0:t.data)!=null?i:{};let c=zt.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let h;if(a instanceof D)h=a;else{const m=bn(c+(o!=null?o:r.meta.image),t.src);h=(await e.load([{src:m,data:l}]))[m]}const p=new Ka({texture:h.source,data:r,cachePrefix:u});await p.parse();const f=(n=r==null?void 0:r.meta)==null?void 0:n.related_multi_packs;if(Array.isArray(f)){const m=[];for(const _ of f){if(typeof _!="string")continue;let y=c+_;(s=t.data)!=null&&s.ignoreMultiPack||(y=bn(y,t.src),m.push(e.load({src:y,data:{textureOptions:l,ignoreMultiPack:!0}})))}const g=await Promise.all(m);p.linkedSheets=g,g.forEach(_=>{_.linkedSheets=[p].concat(p.linkedSheets.filter(y=>y!==_))})}return p},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};X.add(xp);function qa(r,t,e){const{width:i,height:n}=e.orig,s=e.trim;if(s){const a=s.width,o=s.height;r.minX=s.x-t._x*i,r.maxX=r.minX+a,r.minY=s.y-t._y*n,r.maxY=r.minY+o}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*n,r.maxY=r.minY+n}var I2=Object.defineProperty,vn=Object.getOwnPropertySymbols,Tp=Object.prototype.hasOwnProperty,Sp=Object.prototype.propertyIsEnumerable,wp=(r,t,e)=>t in r?I2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,B2=(r,t)=>{for(var e in t||(t={}))Tp.call(t,e)&&wp(r,e,t[e]);if(vn)for(var e of vn(t))Sp.call(t,e)&&wp(r,e,t[e]);return r},F2=(r,t)=>{var e={};for(var i in r)Tp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&vn)for(var i of vn(r))t.indexOf(i)<0&&Sp.call(r,i)&&(e[i]=r[i]);return e};class pe extends Se{constructor(t=D.EMPTY){t instanceof D&&(t={texture:t});const e=t,{texture:i=D.EMPTY,anchor:n,roundPixels:s,width:a,height:o}=e,l=F2(e,["texture","anchor","roundPixels","width","height"]);super(B2({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=s!=null?s:!1,a!==void 0&&(this.width=a),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof D?new pe(t):new pe(D.from(t,e))}set texture(t){t||(t=D.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 qa(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:s}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*s,i.maxY=i.minY+s}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const D2=new Mt;function xn(r,t,e){const i=D2;r.measurable=!0,li(r,e,i),t.addBoundsMask(i),r.measurable=!1}function Tn(r,t,e){const i=ve.get();r.measurable=!0;const n=Dt.get().identity(),s=Pp(r,e,n);un(r,i,s),r.measurable=!1,t.addBoundsMask(i),Dt.return(n),ve.return(i)}function Pp(r,t,e){return r&&r!==t&&(Pp(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Za{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof pe),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||xn(this.mask,t,e)}addLocalBounds(t,e){Tn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof pe}}Za.extension=S.MaskEffect;class Qa{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Qa.extension=S.MaskEffect;class Ja{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){xn(this.mask,t,e)}addLocalBounds(t,e){Tn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}Ja.extension=S.MaskEffect;class fe extends ft{constructor(t){t.resource||(t.resource=H.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 n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}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"))}}fe.extension=S.TextureSource;class ke extends ft{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ke.extension=S.TextureSource;let to;async function eo(){return to!=null||(to=(async()=>{var r;const t=H.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),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 s=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,s),t.deleteFramebuffer(n),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),to}var U2=Object.defineProperty,$2=Object.defineProperties,k2=Object.getOwnPropertyDescriptors,Ep=Object.getOwnPropertySymbols,L2=Object.prototype.hasOwnProperty,N2=Object.prototype.propertyIsEnumerable,Ap=(r,t,e)=>t in r?U2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ro=(r,t)=>{for(var e in t||(t={}))L2.call(t,e)&&Ap(r,e,t[e]);if(Ep)for(var e of Ep(t))N2.call(t,e)&&Ap(r,e,t[e]);return r},X2=(r,t)=>$2(r,k2(t));const Sn=class M1 extends ft{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=ro(ro({},M1.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ot.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await eo(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),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.isValid&&(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("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Ot.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};Sn.extension=S.TextureSource,Sn.defaultOptions=X2(ro({},ft.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),Sn.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let wr=Sn,j2=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){return this._cache.get(t)}set(t,e){const i=oe(t);let n;for(let l=0;l{s.set(l,e)});const a=[...s.keys()],o={cacheKeys:a,keys:i};i.forEach(l=>{this._cacheMap.set(l,o)}),a.forEach(l=>{const u=n?n[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,s.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}};const it=new j2,io=[];X.handleByList(S.TextureSource,io);function H2(r={}){return no(r)}function no(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let n=0;n{it.has(i)&&it.remove(i)}),t||it.set(i,s),s}function Mp(r,t=!1){return typeof r=="string"?it.get(r):r instanceof ft?new D({source:r}):Cp(r,t)}D.from=Mp,ft.from=no,X.add(Za,Qa,Ja,wr,ke,fe,dn);let Pr;function Rp(r){const t=H.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function so(){if(Pr!==void 0)return Pr;try{const r=Rp("#ff00ff"),t=Rp("#ffff00"),e=H.get().createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const i=e.getImageData(2,0,1,1);if(!i)Pr=!1;else{const n=i.data;Pr=n[0]===255&&n[1]===0&&n[2]===0}}catch(r){Pr=!1}return Pr}const Q={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:so(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{var t,e;const i=r.source,n=i==null?void 0:i.resource;if(!n)return null;const s=i.alphaMode==="premultiplied-alpha",a=(t=i.resourceWidth)!=null?t:i.pixelWidth,o=(e=i.resourceHeight)!=null?e:i.pixelHeight,l=a!==i.pixelWidth||o!==i.pixelHeight;if(s){if((n instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&n instanceof OffscreenCanvas)&&!l)return n;const u=Q._unpremultipliedCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){const u=Q._canvasSourceCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas;const c=H.get().createCanvas(i.pixelWidth,i.pixelHeight),h=c.getContext("2d"),p=h.createImageData(i.pixelWidth,i.pixelHeight),f=p.data,m=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(i.format==="bgra8unorm")for(let g=0;g0){const g=255/m;p[f]=Math.min(255,p[f]*g+.5),p[f+1]=Math.min(255,p[f+1]*g+.5),p[f+2]=Math.min(255,p[f+2]*g+.5)}}return c.putImageData(h,0,0),Q._unpremultipliedCache.set(i,{canvas:u,resourceId:i._resourceId}),u}if(l){const u=Q._canvasSourceCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas;const c=H.get().createCanvas(i.pixelWidth,i.pixelHeight),h=c.getContext("2d");return c.width=i.pixelWidth,c.height=i.pixelHeight,h.drawImage(n,0,0),Q._canvasSourceCache.set(i,{canvas:c,resourceId:i._resourceId}),c}return n},getTintedCanvas:(r,t)=>{const e=r.texture,i=tt.shared.setValue(t).toHex(),n=e.tintCache||(e.tintCache={}),s=n[i],a=e.source._resourceId;if((s==null?void 0:s.tintId)===a)return s;const o=s&&"getContext"in s?s:H.get().createCanvas();if(Q.tintMethod(e,t,o),o.tintId=a,Q.convertTintToImage&&o.toDataURL!==void 0){const l=H.get().createImage();l.src=o.toDataURL(),l.tintId=a,n[i]=l}else n[i]=o;return n[i]},getTintedPattern:(r,t)=>{const e=tt.shared.setValue(t).toHex(),i=r.patternCache||(r.patternCache={}),n=r.source._resourceId;let s=i[e];return(s==null?void 0:s.tintId)===n||(Q.canvas||(Q.canvas=H.get().createCanvas()),Q.tintMethod(r,t,Q.canvas),s=Q.canvas.getContext("2d").createPattern(Q.canvas,"repeat"),s.tintId=n,i[e]=s),s},applyPatternTransform:(r,t,e=!0)=>{if(!t)return;const i=r;if(!i.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([t.a,t.b,t.c,t.d,t.tx,t.ty]);i.setTransform(e?s.inverse():s)},tintWithMultiply:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.fillStyle=tt.shared.setValue(t).toHex(),s.fillRect(0,0,c,h),s.globalCompositeOperation="multiply";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.globalCompositeOperation="destination-atop",s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore()},tintWithOverlay:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy",s.fillStyle=tt.shared.setValue(t).toHex(),s.fillRect(0,0,c,h),s.globalCompositeOperation="destination-atop";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore()},tintWithPerPixel:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore();const f=t>>16&255,m=t>>8&255,g=t&255,_=s.getImageData(0,0,c,h),y=_.data;for(let b=0;b{const n=W.inv(t),s=W.uX(n),a=W.uY(n),o=W.vX(n),l=W.vY(n),u=-Math.min(0,s*e,o*i,s*e+o*i),c=-Math.min(0,a*e,l*i,a*e+l*i);r.transform(s,a,o,l,u,c)}};Q.tintMethod=Q.canUseMultiply?Q.tintWithMultiply:Q.tintWithPerPixel;class Op{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=H.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Ze(t),e=Ze(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let s=this._canvasPool[n].pop();return s||(s=this._createCanvasAndContext(t,e)),s}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,s=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[s].push(t)}clear(){this._canvasPool={}}}const me=new Op;qe.register(me);function mi(r,t,e,i,n,s){const a=r-e,o=t-i,l=n-e,u=s-i,c=a*l+o*u,h=l*l+u*u;let p=-1;h!==0&&(p=c/h);let f,m;p<0?(f=e,m=i):p>1?(f=n,m=s):(f=e+p*l,m=i+p*u);const g=r-f,_=t-m;return g*g+_*_}function ao(r,t,e,i,n,s,a,o){const l=a-e,u=o-i,c=n-e,h=s-i,p=r-e,f=t-i,m=l*l+u*u,g=l*c+u*h,_=l*p+u*f,y=c*c+h*h,b=c*p+h*f,x=1/(m*y-g*g),v=(y*_-g*b)*x,w=(m*b-g*_)*x;return v>=0&&w>=0&&v+w<1}class wn{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new wn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,s=this.y-e;return n*=n,s*=s,n+s<=i}strokeContains(t,e,i,n=.5){if(this.radius===0)return!1;const s=this.x-t,a=this.y-e,o=this.radius,l=(1-n)*i,u=Math.sqrt(s*s+a*a);return u<=o+l&&u>o-(i-l)}getBounds(t){return t||(t=new ut),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class Pn{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new Pn(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,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i,n=.5){const{halfWidth:s,halfHeight:a}=this;if(s<=0||a<=0)return!1;const o=i*(1-n),l=i-o,u=s-l,c=a-l,h=s+o,p=a+o,f=t-this.x,m=e-this.y,g=f*f/(u*u)+m*m/(c*c),_=f*f/(h*h)+m*m/(p*p);return g>1&&_<=1}getBounds(t){return t||(t=new ut),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,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}}let z2,W2;class Er{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,s=e.length;ne!=c>e&&t<(u-o)*((e-l)/(c-l))+o&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const s=i*i,a=s*(1-n),o=s-a,{points:l}=this,u=l.length-(this.closePath?0:2);for(let c=0;cn?u:n,s=ca?c:a}return t.x=i,t.width=n-i,t.y=s,t.height=a-s,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const En=(r,t,e,i,n,s,a)=>{const o=r-e,l=t-i,u=Math.sqrt(o*o+l*l);return u>=n-s&&u<=n+a};class An{constructor(t=0,e=0,i=0,n=0,s=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s}getBounds(t){return t||(t=new ut),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new An(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 n=t-(this.x+i),s=e-(this.y+i);const a=i*i;if(n*n+s*s<=a||(n=t-(this.x+this.width-i),n*n+s*s<=a)||(s=e-(this.y+this.height-i),n*n+s*s<=a)||(n=t-(this.x+i),n*n+s*s<=a))return!0}return!1}strokeContains(t,e,i,n=.5){const{x:s,y:a,width:o,height:l,radius:u}=this,c=i*(1-n),h=i-c,p=s+u,f=a+u,m=o-u*2,g=l-u*2,_=s+o,y=a+l;return(t>=s-c&&t<=s+h||t>=_-h&&t<=_+c)&&e>=f&&e<=f+g||(e>=a-c&&e<=a+h||e>=y-h&&e<=y+c)&&t>=p&&t<=p+m?!0:t_-u&&e_-u&&e>y-u&&En(t,e,_-u,y-u,u,h,c)||ty-u&&En(t,e,p,y-u,u,h,c)}}class oo{constructor(t=0,e=0,i=0,n=0,s=0,a=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=n,this.x3=s,this.y3=a}contains(t,e){const i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),n=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(i<0!=n<0&&i!==0&&n!==0)return!1;const s=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return s===0||s<0==i+n<=0}strokeContains(t,e,i,n=.5){const s=i/2,a=s*s,{x:o,x2:l,x3:u,y:c,y2:h,y3:p}=this;return mi(t,e,o,c,l,p)<=a||mi(t,e,l,h,u,p)<=a||mi(t,e,u,p,o,c)<=a}clone(){return new oo(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new ut);const e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),n=Math.min(this.y,this.y2,this.y3),s=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=n,t.width=i-e,t.height=s-n,t}}const Gp=new U;function lo(r,t){var e;t.clear();const i=t.matrix;for(let n=0;n!l.enabled)){e.skip=!0;return}const n=[],s=1;for(const l of i){if(!l.enabled)continue;if(!uo(l)){this._warnUnsupportedFilter(l);continue}const u=l.getCanvasFilterString();if(u===null){this._warnUnsupportedFilter(l);continue}u&&n.push(u)}if(n.length===0&&s===1){e.skip=!0;return}e.cssFilterString=n.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;const a=this.renderer.canvasContext.activeContext,o=a.filter||"none";if(this._savedStates.push({filter:o,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;a.save(),a.setTransform(1,0,0,1,0,0),a.beginPath(),a.rect(e.bounds.x*l,e.bounds.y*l,e.bounds.width*l,e.bounds.height*l),a.clip()}else e.useClip=!1;s!==1&&(this._alphaMultiplier*=s),e.cssFilterString&&(a.filter=o!=="none"?`${o} ${e.cssFilterString}`:e.cssFilterString)}pop(){const t=this._popFilterFrame();if(t.skip)return;const e=this._savedStates.pop();if(!e)return;const i=this.renderer.canvasContext.activeContext;t.useClip?i.restore():i.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){var i,n;if(!(e!=null&&e.length)||e.every(x=>!x.enabled))return t;const s=[],a=1;for(const x of e){if(!x.enabled)continue;if(!uo(x)){this._warnUnsupportedFilter(x);continue}const v=x.getCanvasFilterString();if(v===null){this._warnUnsupportedFilter(x);continue}v&&s.push(v)}if(s.length===0&&a===1)return t;const o=Q.getCanvasSource(t);if(!o)return t;const l=t.frame,u=(n=(i=t.source._resolution)!=null?i:t.source.resolution)!=null?n:1,c=l.width,h=l.height,p=me.getOptimalCanvasAndContext(c,h,u),{canvas:f,context:m}=p;m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,f.width,f.height),s.length&&(m.filter=s.join(" ")),a!==1&&(m.globalAlpha=a);const g=l.x*u,_=l.y*u,y=c*u,b=h*u;return m.drawImage(o,g,_,y,b,0,0,y,b),m.filter="none",m.globalAlpha=1,Cn(f,c,h,u)}_calculateFilterArea(t,e){if(t.renderables?lo(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,n=i==null?void 0:i.cacheToLocalTransform;n&&e.applyMatrix(n)}}_warnUnsupportedFilter(t){var e;const i=((e=t==null?void 0:t.constructor)==null?void 0:e.name)||"Filter";this._warnedFilterTypes.has(i)||(this._warnedFilterTypes.add(i),console.warn(`CanvasRenderer: filter "${i}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new Y2),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}co.extension={type:[S.CanvasSystem],name:"filter"};class ho{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}ho.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};const po=Object.create(null),Ip=Object.create(null);function Ar(r,t){let e=Ip[r];return e===void 0&&(po[t]===void 0&&(po[t]=1),Ip[r]=e=po[t]++),e}let gi;function fo(){return(!gi||gi!=null&&gi.isContextLost())&&(gi=H.get().createCanvas().getContext("webgl",{})),gi}let Mn;function Bp(){if(!Mn){Mn="mediump";const r=fo();r&&r.getShaderPrecisionFormat&&(Mn=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return Mn}function Fp(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),` + `,t.accessibleText&&(e.innerText=t.accessibleText)),e.style.width=`${ep}px`,e.style.height=`${ep}px`,e.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",e.style.position="absolute",e.style.zIndex=rp.toString(),e.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?e.setAttribute("aria-live","off"):e.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?e.setAttribute("aria-relevant","additions"):e.setAttribute("aria-relevant","text"),e.addEventListener("click",this._onClick.bind(this)),e.addEventListener("focus",this._onFocus.bind(this)),e.addEventListener("focusout",this._onFocusOut.bind(this))),e.style.pointerEvents=t.accessiblePointerEvents,e.type=t.accessibleType,t.accessibleTitle&&t.accessibleTitle!==null?e.title=t.accessibleTitle:(!t.accessibleHint||t.accessibleHint===null)&&(e.title=`container ${t.tabIndex}`),t.accessibleHint&&t.accessibleHint!==null&&e.setAttribute("aria-label",t.accessibleHint),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,n=this._renderer.events.rootBoundary,s=Object.assign(new Tr(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,e.forEach(a=>n.dispatchEvent(s,a))}_onClick(t){this._dispatchEvent(t,["click","pointertap","tap"])}_onFocus(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","assertive"),this._dispatchEvent(t,["mouseover"])}_onFocusOut(t){t.target.getAttribute("aria-live")||t.target.setAttribute("aria-live","polite"),this._dispatchEvent(t,["mouseout"])}_onKeyDown(t){t.keyCode!==u2||!this._activateOnTab||this._activate()}_onMouseMove(t){t.movementX===0&&t.movementY===0||this._deactivate()}destroy(){var t;this._deactivate(),this._destroyTouchHook(),(t=this._canvasObserver)==null||t.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]}};Wa.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"accessibility"},Wa.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let np=Wa;const sp={accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1};N.add(np),N.mixin(dt,sp);class Va{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 ja({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(t.length===0){this._domElement.remove();return}this._canvasObserver.ensureAttached();for(let e=0;e=e.minX&&i<=e.maxX&&n>=e.minY&&n<=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)}unload(){var t;this.emit("unload",this);for(const e in this._gpuData)(t=this._gpuData[e])==null||t.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(t){this.unload(),super.destroy(t),this._bounds=null}collectRenderablesSimple(t,e,i){const{renderPipes:n}=e;n.blendMode.pushBlendMode(this,this.groupBlendMode,t);const s=n[this.renderPipeId];s!=null&&s.addRenderable&&s.addRenderable(this,t),this.didViewUpdate=!1;const a=this.children,o=a.length;for(let l=0;lt in r?m2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,g2=(r,t)=>{for(var e in t||(t={}))ap.call(t,e)&&lp(r,e,t[e]);if(vn)for(var e of vn(t))op.call(t,e)&&lp(r,e,t[e]);return r},_2=(r,t)=>{var e={};for(var i in r)ap.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&vn)for(var i of vn(r))t.indexOf(i)<0&&op.call(r,i)&&(e[i]=r[i]);return e};class y2 extends Se{constructor(t={}){const e=t,{element:i,anchor:n}=e,s=_2(e,["element","anchor"]);super(g2({label:"DOMContainer"},s)),this.renderPipeId="dom",this.batched=!1,this._anchor=new lt(0,0),n&&(this.anchor=n),this.element=t.element||document.createElement("div")}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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){t.minX=0,t.minY=0,t.maxX=0,t.maxY=0;return}const{offsetWidth:i,offsetHeight:n}=e;t.minX=0,t.maxX=i,t.minY=0,t.maxY=n}destroy(t=!1){var e,i;super.destroy(t),(i=(e=this._element)==null?void 0:e.parentNode)==null||i.removeChild(this._element),this._element=null,this._anchor=null}}N.add(Va);let b2=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||(Ot.system.add(this._tickerUpdate,this,Te.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(Ot.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove){this._didMove=!1;return}const t=this.events._rootPointerEvent;this.events.supportsTouchEvents&&t.pointerType==="touch"||globalThis.document.dispatchEvent(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._deltaTimei.priority-n.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,n=e.length;i=0;n--)if(t.currentTarget=i[n],this.notifyTarget(t,e),t.propagationStopped||t.propagationImmediatelyStopped)return}}all(t,e,i=this._allInteractiveElements){if(i.length===0)return;t.eventPhase=t.BUBBLING_PHASE;const n=Array.isArray(e)?e:[e];for(let s=i.length-1;s>=0;s--)n.forEach(a=>{t.currentTarget=i[s],this.notifyTarget(t,a)})}propagationPath(t){const e=[t];for(let i=0;i=0;h--){const p=c[h],f=this.hitTestMoveRecursive(p,this._isInteractive(e)?e:p.eventMode,i,n,s,a||s(t,i));if(f){if(f.length>0&&!f[f.length-1].parent)continue;const m=t.isInteractive();(f.length>0||m)&&(m&&this._allInteractiveElements.push(t),f.push(t)),this._hitElements.length===0&&(this._hitElements=f),o=!0}}}const l=this._isInteractive(e),u=t.isInteractive();return u&&u&&this._allInteractiveElements.push(t),a||this._hitElements.length>0?null:o?this._hitElements:l&&!s(t,i)&&n(t,i)?u?[t]:[]:null}hitTestRecursive(t,e,i,n,s){if(this._interactivePrune(t)||s(t,i))return null;if((t.eventMode==="dynamic"||e==="dynamic")&&(we.pauseUpdate=!1),t.interactiveChildren&&t.children){const l=t.children,u=i;for(let c=l.length-1;c>=0;c--){const h=l[c],p=this.hitTestRecursive(h,this._isInteractive(e)?e:h.eventMode,u,n,s);if(p){if(p.length>0&&!p[p.length-1].parent)continue;const f=t.isInteractive();return(p.length>0||f)&&p.push(t),p}}}const a=this._isInteractive(e),o=t.isInteractive();return a&&n(t,i)?o?[t]:[]:null}_isInteractive(t){return t==="static"||t==="dynamic"}_interactivePrune(t){return!t||!t.visible||!t.renderable||!t.measurable||t.eventMode==="none"||t.eventMode==="passive"&&!t.interactiveChildren}hitPruneFn(t,e){if(t.hitArea&&(t.worldTransform.applyInverse(e,di),!t.hitArea.contains(di.x,di.y)))return!0;if(t.effects&&t.effects.length)for(let i=0;i0&&l!==s.target){const h=t.type==="mousemove"?"mouseout":"pointerout",p=this.createPointerEvent(t,h,l);if(this.dispatchEvent(p,"pointerout"),a&&this.dispatchEvent(p,"mouseout"),!s.composedPath().includes(l)){const f=this.createPointerEvent(t,"pointerleave",l);for(f.eventPhase=f.AT_TARGET;f.target&&!s.composedPath().includes(f.target);)f.currentTarget=f.target,this.notifyTarget(f),a&&this.notifyTarget(f,"mouseleave"),f.target=f.target.parent;this.freeEvent(f)}this.freeEvent(p)}if(l!==s.target){const h=t.type==="mousemove"?"mouseover":"pointerover",p=this.clonePointerEvent(s,h);this.dispatchEvent(p,"pointerover"),a&&this.dispatchEvent(p,"mouseover");let f=l==null?void 0:l.parent;for(;f&&f!==this.rootTarget.parent&&f!==s.target;)f=f.parent;if(!f||f===this.rootTarget.parent){const m=this.clonePointerEvent(s,"pointerenter");for(m.eventPhase=m.AT_TARGET;m.target&&m.target!==l&&m.target!==this.rootTarget.parent;)m.currentTarget=m.target,this.notifyTarget(m),a&&this.notifyTarget(m,"mouseenter"),m.target=m.target.parent;this.freeEvent(m)}this.freeEvent(p)}const u=[],c=(i=this.enableGlobalMoveEvents)!=null?i:!0;this.moveOnAll?u.push("pointermove"):this.dispatchEvent(s,"pointermove"),c&&u.push("globalpointermove"),s.pointerType==="touch"&&(this.moveOnAll?u.splice(1,0,"touchmove"):this.dispatchEvent(s,"touchmove"),c&&u.push("globaltouchmove")),a&&(this.moveOnAll?u.splice(1,0,"mousemove"):this.dispatchEvent(s,"mousemove"),c&&u.push("globalmousemove"),this.cursor=(n=s.target)==null?void 0:n.cursor),u.length>0&&this.all(s,u),this._allInteractiveElements.length=0,this._hitElements.length=0,o.overTargets=s.composedPath(),this.freeEvent(s)}mapPointerOver(t){var e;if(!(t instanceof ae))return;const i=this.trackingData(t.pointerId),n=this.createPointerEvent(t),s=n.pointerType==="mouse"||n.pointerType==="pen";this.dispatchEvent(n,"pointerover"),s&&this.dispatchEvent(n,"mouseover"),n.pointerType==="mouse"&&(this.cursor=(e=n.target)==null?void 0:e.cursor);const a=this.clonePointerEvent(n,"pointerenter");for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),s&&this.notifyTarget(a,"mouseenter"),a.target=a.target.parent;i.overTargets=n.composedPath(),this.freeEvent(n),this.freeEvent(a)}mapPointerOut(t){if(!(t instanceof ae))return;const e=this.trackingData(t.pointerId);if(e.overTargets){const i=t.pointerType==="mouse"||t.pointerType==="pen",n=this.findMountedTarget(e.overTargets),s=this.createPointerEvent(t,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const a=this.createPointerEvent(t,"pointerleave",n);for(a.eventPhase=a.AT_TARGET;a.target&&a.target!==this.rootTarget.parent;)a.currentTarget=a.target,this.notifyTarget(a),i&&this.notifyTarget(a,"mouseleave"),a.target=a.target.parent;e.overTargets=null,this.freeEvent(s),this.freeEvent(a)}this.cursor=null}mapPointerUp(t){if(!(t instanceof ae))return;const e=performance.now(),i=this.createPointerEvent(t);if(this.dispatchEvent(i,"pointerup"),i.pointerType==="touch")this.dispatchEvent(i,"touchend");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const o=i.button===2;this.dispatchEvent(i,o?"rightup":"mouseup")}const n=this.trackingData(t.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[t.button]);let a=s;if(s&&!i.composedPath().includes(s)){let o=s;for(;o&&!i.composedPath().includes(o);){if(i.currentTarget=o,this.notifyTarget(i,"pointerupoutside"),i.pointerType==="touch")this.notifyTarget(i,"touchendoutside");else if(i.pointerType==="mouse"||i.pointerType==="pen"){const l=i.button===2;this.notifyTarget(i,l?"rightupoutside":"mouseupoutside")}o=o.parent}delete n.pressTargetsByButton[t.button],a=o}if(a){const o=this.clonePointerEvent(i,"click");o.target=a,o.path=null,n.clicksByButton[t.button]||(n.clicksByButton[t.button]={clickCount:0,target:o.target,timeStamp:e});const l=n.clicksByButton[t.button];if(l.target===o.target&&e-l.timeStamp<200?++l.clickCount:l.clickCount=1,l.target=o.target,l.timeStamp=e,o.detail=l.clickCount,o.pointerType==="mouse"){const u=o.button===2;this.dispatchEvent(o,u?"rightclick":"click")}else o.pointerType==="touch"&&this.dispatchEvent(o,"tap");this.dispatchEvent(o,"pointertap"),this.freeEvent(o)}this.freeEvent(i)}mapPointerUpOutside(t){if(!(t instanceof ae))return;const e=this.trackingData(t.pointerId),i=this.findMountedTarget(e.pressTargetsByButton[t.button]),n=this.createPointerEvent(t);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),n.pointerType==="touch"?this.notifyTarget(n,"touchendoutside"):(n.pointerType==="mouse"||n.pointerType==="pen")&&this.notifyTarget(n,n.button===2?"rightupoutside":"mouseupoutside"),s=s.parent;delete e.pressTargetsByButton[t.button]}this.freeEvent(n)}mapWheel(t){if(!(t instanceof rr))return;const e=this.createWheelEvent(t);this.dispatchEvent(e),this.freeEvent(e)}findMountedTarget(t){if(!t)return null;let e=t[0];for(let i=1;it in r?T2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,E2=(r,t)=>{for(var e in t||(t={}))S2.call(t,e)&&hp(r,e,t[e]);if(cp)for(var e of cp(t))w2.call(t,e)&&hp(r,e,t[e]);return r};const P2=1,A2={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},Ya=class Sh{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new up(null),we.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new ae(null),this._rootWheelEvent=new rr(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy(E2({},Sh.defaultEventFeatures),{set:(e,i,n)=>(i==="globalMove"&&(this.rootBoundary.enableGlobalMoveEvents=n),e[i]=n,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){var e,i;const{canvas:n,resolution:s}=this.renderer;this.setTargetElement(n),this.resolution=s,Sh._defaultEventMode=(e=t.eventMode)!=null?e:"passive",Object.assign(this.features,(i=t.eventFeatures)!=null?i:{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(t){this.resolution=t}destroy(){we.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(t){t||(t="default");let e=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(e=!1),this._currentCursor===t)return;this._currentCursor=t;const i=this.cursorStyles[t];if(i)switch(typeof i){case"string":e&&(this.domElement.style.cursor=i);break;case"function":i(t);break;case"object":e&&Object.assign(this.domElement.style,i);break}else e&&typeof t=="string"&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,t)&&(this.domElement.style.cursor=t)}get pointer(){return this._rootPointerEvent}_onPointerDown(t){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const e=this._normalizeToPointerData(t);this.autoPreventDefault&&e[0].isNormalized&&(t.cancelable||!("cancelable"in t))&&t.preventDefault();for(let i=0,n=e.length;i0&&(e=t.composedPath()[0]);const i=e!==this.domElement?"outside":"",n=this._normalizeToPointerData(t);for(let s=0,a=n.length;s{l.off(r,o,a)}),s?l.once(r,o,a):l.on(r,o,a)},removeEventListener(r,t,e){const i=typeof e=="boolean"&&e||typeof e=="object"&&e.capture,n=typeof t=="function"?void 0:t;r=i?`${r}capture`:r,t=typeof t=="function"?t:t.handleEvent,this.off(r,t,n)},dispatchEvent(r){if(!(r instanceof Tr))throw new Error("Container cannot propagate events outside of the Federated Events API");return r.defaultPrevented=!1,r.path=null,r.target=this,r.manager.dispatchEvent(r),!r.defaultPrevented}};N.add(Ka),N.mixin(dt,dp);var te=(r=>(r[r.Low=0]="Low",r[r.Normal=1]="Normal",r[r.High=2]="High",r))(te||{});const pp={createCanvas:(r,t)=>{const e=document.createElement("canvas");return e.width=r,e.height=t,e},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>{var r;return(r=document.baseURI)!=null?r:window.location.href},getFontFaceSet:()=>document.fonts,fetch:(r,t)=>fetch(r,t),parseXML:r=>new DOMParser().parseFromString(r,"text/xml")};let fp=pp;const H={get(){return fp},set(r){fp=r}};function de(r){if(typeof r!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(r)}`)}function pi(r){return r.split("?")[0].split("#")[0]}function C2(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function M2(r,t,e){return r.replace(new RegExp(C2(t),"g"),e)}function R2(r,t){let e="",i=0,n=-1,s=0,a=-1;for(let o=0;o<=r.length;++o){if(o2){const l=e.lastIndexOf("/");if(l!==e.length-1){l===-1?(e="",i=0):(e=e.slice(0,l),i=e.length-1-e.lastIndexOf("/")),n=o,s=0;continue}}else if(e.length===2||e.length===1){e="",i=0,n=o,s=0;continue}}t&&(e.length>0?e+="/..":e="..",i=2)}else e.length>0?e+=`/${r.slice(n+1,o)}`:e=r.slice(n+1,o),i=o-n-1;n=o,s=0}else a===46&&s!==-1?++s:s=-1}return e}const zt={toPosix(r){return M2(r,"\\","/")},isUrl(r){return/^https?:/.test(this.toPosix(r))},isDataUrl(r){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(r)},isBlobUrl(r){return r.startsWith("blob:")},hasProtocol(r){return/^[^/:]+:/.test(this.toPosix(r))},getProtocol(r){de(r),r=this.toPosix(r);const t=/^file:\/\/\//.exec(r);if(t)return t[0];const e=/^[^/:]+:\/{0,2}/.exec(r);return e?e[0]:""},toAbsolute(r,t,e){if(de(r),this.isDataUrl(r)||this.isBlobUrl(r))return r;const i=pi(this.toPosix(t!=null?t:H.get().getBaseUrl())),n=pi(this.toPosix(e!=null?e:this.rootname(i)));return r=this.toPosix(r),r.startsWith("/")?zt.join(n,r.slice(1)):this.isAbsolute(r)?r:this.join(i,r)},normalize(r){if(de(r),r.length===0)return".";if(this.isDataUrl(r)||this.isBlobUrl(r))return r;r=this.toPosix(r);let t="";const e=r.startsWith("/");this.hasProtocol(r)&&(t=this.rootname(r),r=r.slice(t.length));const i=r.endsWith("/");return r=R2(r,!1),r.length>0&&i&&(r+="/"),e?`/${r}`:t+r},isAbsolute(r){return de(r),r=this.toPosix(r),this.hasProtocol(r)?!0:r.startsWith("/")},join(...r){var t;if(r.length===0)return".";let e;for(let i=0;i0)if(e===void 0)e=n;else{const s=(t=r[i-1])!=null?t:"";this.joinExtensions.includes(this.extname(s).toLowerCase())?e+=`/../${n}`:e+=`/${n}`}}return e===void 0?".":this.normalize(e)},dirname(r){if(de(r),r.length===0)return".";r=this.toPosix(r);let t=r.charCodeAt(0);const e=t===47;let i=-1,n=!0;const s=this.getProtocol(r),a=r;r=r.slice(s.length);for(let o=r.length-1;o>=1;--o)if(t=r.charCodeAt(o),t===47){if(!n){i=o;break}}else n=!1;return i===-1?e?"/":this.isUrl(a)?s+r:s:e&&i===1?"//":s+r.slice(0,i)},rootname(r){de(r),r=this.toPosix(r);let t="";if(r.startsWith("/")?t="/":t=this.getProtocol(r),this.isUrl(r)){const e=r.indexOf("/",t.length);e!==-1?t=r.slice(0,e):t=r,t.endsWith("/")||(t+="/")}return t},basename(r,t){de(r),t&&de(t),r=pi(this.toPosix(r));let e=0,i=-1,n=!0,s;if(t!==void 0&&t.length>0&&t.length<=r.length){if(t.length===r.length&&t===r)return"";let a=t.length-1,o=-1;for(s=r.length-1;s>=0;--s){const l=r.charCodeAt(s);if(l===47){if(!n){e=s+1;break}}else o===-1&&(n=!1,o=s+1),a>=0&&(l===t.charCodeAt(a)?--a===-1&&(i=s):(a=-1,i=o))}return e===i?i=o:i===-1&&(i=r.length),r.slice(e,i)}for(s=r.length-1;s>=0;--s)if(r.charCodeAt(s)===47){if(!n){e=s+1;break}}else i===-1&&(n=!1,i=s+1);return i===-1?"":r.slice(e,i)},extname(r){de(r),r=pi(this.toPosix(r));let t=-1,e=0,i=-1,n=!0,s=0;for(let a=r.length-1;a>=0;--a){const o=r.charCodeAt(a);if(o===47){if(!n){e=a+1;break}continue}i===-1&&(n=!1,i=a+1),o===46?t===-1?t=a:s!==1&&(s=1):t!==-1&&(s=-1)}return t===-1||i===-1||s===0||s===1&&t===i-1&&t===e+1?"":r.slice(t,i)},parse(r){de(r);const t={root:"",dir:"",base:"",ext:"",name:""};if(r.length===0)return t;r=pi(this.toPosix(r));let e=r.charCodeAt(0);const i=this.isAbsolute(r);let n;const s="";t.root=this.rootname(r),i||this.hasProtocol(r)?n=1:n=0;let a=-1,o=0,l=-1,u=!0,c=r.length-1,h=0;for(;c>=n;--c){if(e=r.charCodeAt(c),e===47){if(!u){o=c+1;break}continue}l===-1&&(u=!1,l=c+1),e===46?a===-1?a=c:h!==1&&(h=1):a!==-1&&(h=-1)}return a===-1||l===-1||h===0||h===1&&a===l-1&&a===o+1?l!==-1&&(o===0&&i?t.base=t.name=r.slice(1,l):t.base=t.name=r.slice(o,l)):(o===0&&i?(t.name=r.slice(1,a),t.base=r.slice(1,l)):(t.name=r.slice(o,a),t.base=r.slice(o,l)),t.ext=r.slice(a,l)),t.dir=this.dirname(r),s&&(t.dir=s+t.dir),t},sep:"/",delimiter:":",joinExtensions:[".html"]},oe=(r,t,e=!1)=>(Array.isArray(r)||(r=[r]),t?r.map(i=>typeof i=="string"||e?t(i):i):r);function mp(r,t,e,i,n){const s=t[e];for(let a=0;a{const a=s.substring(1,s.length-1).split(",");n.push(a)}),mp(r,n,0,e,i)}else i.push(r);return i}const fi=r=>!Array.isArray(r);var O2=Object.defineProperty,G2=Object.defineProperties,I2=Object.getOwnPropertyDescriptors,_p=Object.getOwnPropertySymbols,B2=Object.prototype.hasOwnProperty,F2=Object.prototype.propertyIsEnumerable,yp=(r,t,e)=>t in r?O2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ir=(r,t)=>{for(var e in t||(t={}))B2.call(t,e)&&yp(r,e,t[e]);if(_p)for(var e of _p(t))F2.call(t,e)&&yp(r,e,t[e]);return r},D2=(r,t)=>G2(r,I2(t));class $e{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(t,e)=>`${t}${this._bundleIdConnector}${e}`,extractAssetIdFromBundle:(t,e)=>e.replace(`${t}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(t){var e,i,n;if(this._bundleIdConnector=(e=t.connector)!=null?e:this._bundleIdConnector,this._createBundleAssetId=(i=t.createBundleAssetId)!=null?i:this._createBundleAssetId,this._extractAssetIdFromBundle=(n=t.extractAssetIdFromBundle)!=null?n:this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...t){t.forEach(e=>{this._preferredOrder.push(e),e.priority||(e.priority=Object.keys(e.params))}),this._resolverHash={}}set basePath(t){this._basePath=t}get basePath(){return this._basePath}set rootPath(t){this._rootPath=t}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(t){if(typeof t=="string")this._defaultSearchParams=t;else{const e=t;this._defaultSearchParams=Object.keys(e).map(i=>`${encodeURIComponent(i)}=${encodeURIComponent(e[i])}`).join("&")}}getAlias(t){const{alias:e,src:i}=t;return oe(e||i,n=>typeof n=="string"?n:Array.isArray(n)?n.map(s=>{var a;return(a=s==null?void 0:s.src)!=null?a:s}):n!=null&&n.src?n.src:n,!0)}removeAlias(t,e){this._assetMap[t]&&(e&&e!==this._resolverHash[t]||(delete this._resolverHash[t],delete this._assetMap[t]))}addManifest(t){this._manifest,this._manifest=t,t.bundles.forEach(e=>{this.addBundle(e.name,e.assets)})}addBundle(t,e){const i=[];let n=e;Array.isArray(e)||(n=Object.entries(e).map(([s,a])=>typeof a=="string"||Array.isArray(a)?{alias:s,src:a}:ir({alias:s},a))),n.forEach(s=>{const a=s.src,o=s.alias;let l;if(typeof o=="string"){const u=this._createBundleAssetId(t,o);i.push(u),l=[o,u]}else{const u=o.map(c=>this._createBundleAssetId(t,c));i.push(...u),l=[...o,...u]}this.add(D2(ir({},s),{alias:l,src:a}))}),this._bundles[t]=i}add(t){const e=[];Array.isArray(t)?e.push(...t):e.push(t);let i;oe(e).forEach(n=>{const{src:s}=n;let{data:a,format:o,loadParser:l,parser:u}=n;const c=oe(s).map(m=>typeof m=="string"?gp(m):Array.isArray(m)?m:[m]),h=this.getAlias(n),p=[],f=m=>{const g=this._parsers.find(_=>_.test(m));return ir({src:m},g==null?void 0:g.parse(m))};c.forEach(m=>{m.forEach(g=>{var _,y,b,x;let v={};if(typeof g!="object"?v=f(g):(a=(_=g.data)!=null?_:a,o=(y=g.format)!=null?y:o,(g.loadParser||g.parser)&&(l=(b=g.loadParser)!=null?b:l,u=(x=g.parser)!=null?x:u),v=ir(ir({},f(g.src)),g)),!h)throw new Error(`[Resolver] alias is undefined for this asset: ${v.src}`);v=this._buildResolvedAsset(v,{aliases:h,data:a,format:o,loadParser:l,parser:u,progressSize:n.progressSize}),p.push(v)})}),h.forEach(m=>{this._assetMap[m]=p})})}resolveBundle(t){const e=fi(t);t=oe(t);const i={};return t.forEach(n=>{const s=this._bundles[n];if(s){const a=this.resolve(s),o={};for(const l in a){const u=a[l];o[this._extractAssetIdFromBundle(n,l)]=u}i[n]=o}}),e?i[t[0]]:i}resolveUrl(t){const e=this.resolve(t);if(typeof t!="string"){const i={};for(const n in e)i[n]=e[n].src;return i}return e.src}resolve(t){const e=fi(t);t=oe(t);const i={};return t.forEach(n=>{if(!this._resolverHash[n])if(this._assetMap[n]){let s=this._assetMap[n];const a=this._getPreferredOrder(s);a==null||a.priority.forEach(o=>{a.params[o].forEach(l=>{const u=s.filter(c=>c[o]?c[o]===l:!1);u.length&&(s=u)})}),this._resolverHash[n]=s[0]}else this._resolverHash[n]=this._buildResolvedAsset({alias:[n],src:n},{});i[n]=this._resolverHash[n]}),e?i[t[0]]:i}hasKey(t){return!!this._assetMap[t]}hasBundle(t){return!!this._bundles[t]}_getPreferredOrder(t){for(let e=0;es.params.format.includes(i.format));if(n)return n}return this._preferredOrder[0]}_appendDefaultSearchParams(t){if(!this._defaultSearchParams)return t;const e=/\?/.test(t)?"&":"?";return`${t}${e}${this._defaultSearchParams}`}_buildResolvedAsset(t,e){var i,n;const{aliases:s,data:a,loadParser:o,parser:l,format:u,progressSize:c}=e;return(this._basePath||this._rootPath)&&(t.src=zt.toAbsolute(t.src,this._basePath,this._rootPath)),t.alias=(i=s!=null?s:t.alias)!=null?i:[t.src],t.src=this._appendDefaultSearchParams(t.src),t.data=ir(ir({},a||{}),t.data),t.loadParser=o!=null?o:t.loadParser,t.parser=l!=null?l:t.parser,t.format=(n=u!=null?u:t.format)!=null?n:bp(t.src),c!==void 0&&(t.progressSize=c),t}}$e.RETINA_PREFIX=/@([0-9\.]+)x/;function bp(r){return r.split(".").pop().split("?").shift().split("#").shift()}const xn=(r,t)=>{const e=t.split("?")[1];return e&&(r+=`?${e}`),r},vp=class nn{constructor(t,e){this.linkedSheets=[];let i=t;(t==null?void 0:t.source)instanceof ft&&(i={texture:t,data:e});const{texture:n,data:s,cachePrefix:a=""}=i;this.cachePrefix=a,this._texture=n instanceof D?n:null,this.textureSource=n.source,this.textures={},this.animations={},this.data=s;const o=parseFloat(s.meta.scale);o?(this.resolution=o,n.source.resolution=this.resolution):this.resolution=n.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(t=>{this._callback=t,this._batchIndex=0,this._frameKeys.length<=nn.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(t,e=!1){let i=t;const n=e?1/0:nn.BATCH_SIZE;for(;i-t{this._batchIndex*nn.BATCH_SIZE{i[n]=t}),Object.keys(t.textures).forEach(n=>{i[`${t.cachePrefix}${n}`]=t.textures[n]}),!e){const n=zt.dirname(r[0]);t.linkedSheets.forEach((s,a)=>{const o=xp([`${n}/${t.data.meta.related_multi_packs[a]}`],s,!0);Object.assign(i,o)})}return i}const Tp={extension:S.Asset,cache:{test:r=>r instanceof qa,getCacheableAssets:(r,t)=>xp(r,t,!1)},resolver:{extension:{type:S.ResolveParser,name:"resolveSpritesheet"},test:r=>{const t=r.split("?")[0].split("."),e=t.pop(),i=t.pop();return e==="json"&&U2.includes(i)},parse:r=>{var t,e;const i=r.split(".");return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i[i.length-2],src:r}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:S.LoadParser,priority:te.Normal,name:"spritesheetLoader"},async testParse(r,t){return zt.extname(t.src).toLowerCase()===".json"&&!!r.frames},async parse(r,t,e){var i,n,s;const{texture:a,imageFilename:o,textureOptions:l,cachePrefix:u}=(i=t==null?void 0:t.data)!=null?i:{};let c=zt.dirname(t.src);c&&c.lastIndexOf("/")!==c.length-1&&(c+="/");let h;if(a instanceof D)h=a;else{const m=xn(c+(o!=null?o:r.meta.image),t.src);h=(await e.load([{src:m,data:l}]))[m]}const p=new qa({texture:h.source,data:r,cachePrefix:u});await p.parse();const f=(n=r==null?void 0:r.meta)==null?void 0:n.related_multi_packs;if(Array.isArray(f)){const m=[];for(const _ of f){if(typeof _!="string")continue;let y=c+_;(s=t.data)!=null&&s.ignoreMultiPack||(y=xn(y,t.src),m.push(e.load({src:y,data:{textureOptions:l,ignoreMultiPack:!0}})))}const g=await Promise.all(m);p.linkedSheets=g,g.forEach(_=>{_.linkedSheets=[p].concat(p.linkedSheets.filter(y=>y!==_))})}return p},async unload(r,t,e){await e.unload(r.textureSource._sourceOrigin),r.destroy(!1)}}};N.add(Tp);function Za(r,t,e){const{width:i,height:n}=e.orig,s=e.trim;if(s){const a=s.width,o=s.height;r.minX=s.x-t._x*i,r.maxX=r.minX+a,r.minY=s.y-t._y*n,r.maxY=r.minY+o}else r.minX=-t._x*i,r.maxX=r.minX+i,r.minY=-t._y*n,r.maxY=r.minY+n}var $2=Object.defineProperty,Tn=Object.getOwnPropertySymbols,Sp=Object.prototype.hasOwnProperty,wp=Object.prototype.propertyIsEnumerable,Ep=(r,t,e)=>t in r?$2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,k2=(r,t)=>{for(var e in t||(t={}))Sp.call(t,e)&&Ep(r,e,t[e]);if(Tn)for(var e of Tn(t))wp.call(t,e)&&Ep(r,e,t[e]);return r},L2=(r,t)=>{var e={};for(var i in r)Sp.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Tn)for(var i of Tn(r))t.indexOf(i)<0&&wp.call(r,i)&&(e[i]=r[i]);return e};class pe extends Se{constructor(t=D.EMPTY){t instanceof D&&(t={texture:t});const e=t,{texture:i=D.EMPTY,anchor:n,roundPixels:s,width:a,height:o}=e,l=L2(e,["texture","anchor","roundPixels","width","height"]);super(k2({label:"Sprite"},l)),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),n?this.anchor=n:i.defaultAnchor&&(this.anchor=i.defaultAnchor),this.texture=i,this.allowChildren=!1,this.roundPixels=s!=null?s:!1,a!==void 0&&(this.width=a),o!==void 0&&(this.height=o)}static from(t,e=!1){return t instanceof D?new pe(t):new pe(D.from(t,e))}set texture(t){t||(t=D.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 Za(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return this.visualBounds}updateBounds(){const t=this._anchor,e=this._texture,i=this._bounds,{width:n,height:s}=e.orig;i.minX=-t._x*n,i.maxX=i.minX+n,i.minY=-t._y*s,i.maxY=i.minY+s}destroy(t=!1){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this._texture.orig.width),e!==void 0&&this._setHeight(e,this._texture.orig.height)}}const N2=new Mt;function Sn(r,t,e){const i=N2;r.measurable=!0,li(r,e,i),t.addBoundsMask(i),r.measurable=!1}function wn(r,t,e){const i=ve.get();r.measurable=!0;const n=Dt.get().identity(),s=Pp(r,e,n);hn(r,i,s),r.measurable=!1,t.addBoundsMask(i),Dt.return(n),ve.return(i)}function Pp(r,t,e){return r&&r!==t&&(Pp(r.parent,t,e),r.updateLocalTransform(),e.append(r.localTransform)),e}class Qa{constructor(t){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.renderMaskToTexture=!(t instanceof pe),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(t,e){this.inverse||Sn(this.mask,t,e)}addLocalBounds(t,e){wn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof pe}}Qa.extension=S.MaskEffect;class Ja{constructor(t){this.priority=0,this.pipe="colorMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t}destroy(){}static test(t){return typeof t=="number"}}Ja.extension=S.MaskEffect;class to{constructor(t){this.priority=0,this.pipe="stencilMask",t!=null&&t.mask&&this.init(t.mask)}init(t){this.mask=t,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(t,e){Sn(this.mask,t,e)}addLocalBounds(t,e){wn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}destroy(){this.reset()}static test(t){return t instanceof dt}}to.extension=S.MaskEffect;class fe extends ft{constructor(t){t.resource||(t.resource=H.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 n=super.resize(t,e,i);return n&&this.resizeCanvas(),n}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"))}}fe.extension=S.TextureSource;class ke extends ft{constructor(t){super(t),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(t){return globalThis.HTMLImageElement&&t instanceof HTMLImageElement||typeof ImageBitmap!="undefined"&&t instanceof ImageBitmap||globalThis.VideoFrame&&t instanceof VideoFrame}}ke.extension=S.TextureSource;let eo;async function ro(){return eo!=null||(eo=(async()=>{var r;const t=H.get().createCanvas(1,1).getContext("webgl");if(!t)return"premultiply-alpha-on-upload";const e=await new Promise(a=>{const o=document.createElement("video");o.onloadeddata=()=>a(o),o.onerror=()=>a(null),o.autoplay=!1,o.crossOrigin="anonymous",o.preload="auto",o.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",o.load()});if(!e)return"premultiply-alpha-on-upload";const i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i);const n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),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 s=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,s),t.deleteFramebuffer(n),t.deleteTexture(i),(r=t.getExtension("WEBGL_lose_context"))==null||r.loseContext(),s[0]<=s[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),eo}var X2=Object.defineProperty,j2=Object.defineProperties,H2=Object.getOwnPropertyDescriptors,Ap=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,W2=Object.prototype.propertyIsEnumerable,Cp=(r,t,e)=>t in r?X2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,io=(r,t)=>{for(var e in t||(t={}))z2.call(t,e)&&Cp(r,e,t[e]);if(Ap)for(var e of Ap(t))W2.call(t,e)&&Cp(r,e,t[e]);return r},V2=(r,t)=>j2(r,H2(t));const En=class O1 extends ft{constructor(t){var e;super(t),this.isReady=!1,this.uploadMethodId="video",t=io(io({},O1.defaultOptions),t),this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=t.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=t.autoPlay!==!1,this.alphaMode=(e=t.alphaMode)!=null?e:"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),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),t.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const t=Ot.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-t)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const t=this.resource,e=this.options;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(e.preload||t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlayThrough),t.addEventListener("error",this._onError,!0)),this.isValid||t.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await ro(),this._load=new Promise((i,n)=>{this.isValid?i(this):(this._resolve=i,this._reject=n,e.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${e.preloadTimeoutMs}ms`))})),t.load())}),this._load}_onError(t){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){const t=this.resource;return!t.paused&&!t.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),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.isValid&&(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("loadedmetadata",this._onLoadedMetadata),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(Ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(Ot.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(Ot.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement}};En.extension=S.TextureSource,En.defaultOptions=V2(io({},ft.defaultOptions),{autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1}),En.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let wr=En,Y2=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){return this._cache.get(t)}set(t,e){const i=oe(t);let n;for(let l=0;l{s.set(l,e)});const a=[...s.keys()],o={cacheKeys:a,keys:i};i.forEach(l=>{this._cacheMap.set(l,o)}),a.forEach(l=>{const u=n?n[l]:e;this._cache.has(l)&&this._cache.get(l),this._cache.set(l,s.get(l))})}remove(t){if(!this._cacheMap.has(t))return;const e=this._cacheMap.get(t);e.cacheKeys.forEach(i=>{this._cache.delete(i)}),e.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}};const it=new Y2,no=[];N.handleByList(S.TextureSource,no);function K2(r={}){return so(r)}function so(r={}){const t=r&&r.resource,e=t?r.resource:r,i=t?r:{resource:r};for(let n=0;n{it.has(i)&&it.remove(i)}),t||it.set(i,s),s}function Rp(r,t=!1){return typeof r=="string"?it.get(r):r instanceof ft?new D({source:r}):Mp(r,t)}D.from=Rp,ft.from=so,N.add(Qa,Ja,to,wr,ke,fe,fn);let Er;function Op(r){const t=H.get().createCanvas(6,1),e=t.getContext("2d");return e.fillStyle=r,e.fillRect(0,0,6,1),t}function ao(){if(Er!==void 0)return Er;try{const r=Op("#ff00ff"),t=Op("#ffff00"),e=H.get().createCanvas(6,1).getContext("2d");e.globalCompositeOperation="multiply",e.drawImage(r,0,0),e.drawImage(t,2,0);const i=e.getImageData(2,0,1,1);if(!i)Er=!1;else{const n=i.data;Er=n[0]===255&&n[1]===0&&n[2]===0}}catch(r){Er=!1}return Er}const Q={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:ao(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:r=>{var t,e;const i=r.source,n=i==null?void 0:i.resource;if(!n)return null;const s=i.alphaMode==="premultiplied-alpha",a=(t=i.resourceWidth)!=null?t:i.pixelWidth,o=(e=i.resourceHeight)!=null?e:i.pixelHeight,l=a!==i.pixelWidth||o!==i.pixelHeight;if(s){if((n instanceof HTMLCanvasElement||typeof OffscreenCanvas!="undefined"&&n instanceof OffscreenCanvas)&&!l)return n;const u=Q._unpremultipliedCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){const u=Q._canvasSourceCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas;const c=H.get().createCanvas(i.pixelWidth,i.pixelHeight),h=c.getContext("2d"),p=h.createImageData(i.pixelWidth,i.pixelHeight),f=p.data,m=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(i.format==="bgra8unorm")for(let g=0;g0){const g=255/m;p[f]=Math.min(255,p[f]*g+.5),p[f+1]=Math.min(255,p[f+1]*g+.5),p[f+2]=Math.min(255,p[f+2]*g+.5)}}return c.putImageData(h,0,0),Q._unpremultipliedCache.set(i,{canvas:u,resourceId:i._resourceId}),u}if(l){const u=Q._canvasSourceCache.get(i);if((u==null?void 0:u.resourceId)===i._resourceId)return u.canvas;const c=H.get().createCanvas(i.pixelWidth,i.pixelHeight),h=c.getContext("2d");return c.width=i.pixelWidth,c.height=i.pixelHeight,h.drawImage(n,0,0),Q._canvasSourceCache.set(i,{canvas:c,resourceId:i._resourceId}),c}return n},getTintedCanvas:(r,t)=>{const e=r.texture,i=tt.shared.setValue(t).toHex(),n=e.tintCache||(e.tintCache={}),s=n[i],a=e.source._resourceId;if((s==null?void 0:s.tintId)===a)return s;const o=s&&"getContext"in s?s:H.get().createCanvas();if(Q.tintMethod(e,t,o),o.tintId=a,Q.convertTintToImage&&o.toDataURL!==void 0){const l=H.get().createImage();l.src=o.toDataURL(),l.tintId=a,n[i]=l}else n[i]=o;return n[i]},getTintedPattern:(r,t)=>{const e=tt.shared.setValue(t).toHex(),i=r.patternCache||(r.patternCache={}),n=r.source._resourceId;let s=i[e];return(s==null?void 0:s.tintId)===n||(Q.canvas||(Q.canvas=H.get().createCanvas()),Q.tintMethod(r,t,Q.canvas),s=Q.canvas.getContext("2d").createPattern(Q.canvas,"repeat"),s.tintId=n,i[e]=s),s},applyPatternTransform:(r,t,e=!0)=>{if(!t)return;const i=r;if(!i.setTransform)return;const n=globalThis.DOMMatrix;if(!n)return;const s=new n([t.a,t.b,t.c,t.d,t.tx,t.ty]);i.setTransform(e?s.inverse():s)},tintWithMultiply:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.fillStyle=tt.shared.setValue(t).toHex(),s.fillRect(0,0,c,h),s.globalCompositeOperation="multiply";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.globalCompositeOperation="destination-atop",s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore()},tintWithOverlay:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy",s.fillStyle=tt.shared.setValue(t).toHex(),s.fillRect(0,0,c,h),s.globalCompositeOperation="destination-atop";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore()},tintWithPerPixel:(r,t,e)=>{var i,n;const s=e.getContext("2d"),a=r.frame.clone(),o=(n=(i=r.source._resolution)!=null?i:r.source.resolution)!=null?n:1,l=r.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;const u=W.isVertical(l),c=u?a.height:a.width,h=u?a.width:a.height;e.width=Math.ceil(c),e.height=Math.ceil(h),s.save(),s.globalCompositeOperation="copy";const p=Q.getCanvasSource(r);if(!p){s.restore();return}l&&Q._applyInverseRotation(s,l,a.width,a.height),s.drawImage(p,a.x,a.y,a.width,a.height,0,0,a.width,a.height),s.restore();const f=t>>16&255,m=t>>8&255,g=t&255,_=s.getImageData(0,0,c,h),y=_.data;for(let b=0;b{const n=W.inv(t),s=W.uX(n),a=W.uY(n),o=W.vX(n),l=W.vY(n),u=-Math.min(0,s*e,o*i,s*e+o*i),c=-Math.min(0,a*e,l*i,a*e+l*i);r.transform(s,a,o,l,u,c)}};Q.tintMethod=Q.canUseMultiply?Q.tintWithMultiply:Q.tintWithPerPixel;class Gp{constructor(t){this._canvasPool=Object.create(null),this.canvasOptions=t||{},this.enableFullScreen=!1}_createCanvasAndContext(t,e){const i=H.get().createCanvas();i.width=t,i.height=e;const n=i.getContext("2d");return{canvas:i,context:n}}getOptimalCanvasAndContext(t,e,i=1){t=Math.ceil(t*i-1e-6),e=Math.ceil(e*i-1e-6),t=Ze(t),e=Ze(e);const n=(t<<17)+(e<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let s=this._canvasPool[n].pop();return s||(s=this._createCanvasAndContext(t,e)),s}returnCanvasAndContext(t){const e=t.canvas,{width:i,height:n}=e,s=(i<<17)+(n<<1);t.context.resetTransform(),t.context.clearRect(0,0,i,n),this._canvasPool[s].push(t)}clear(){this._canvasPool={}}}const me=new Gp;qe.register(me);function mi(r,t,e,i,n,s){const a=r-e,o=t-i,l=n-e,u=s-i,c=a*l+o*u,h=l*l+u*u;let p=-1;h!==0&&(p=c/h);let f,m;p<0?(f=e,m=i):p>1?(f=n,m=s):(f=e+p*l,m=i+p*u);const g=r-f,_=t-m;return g*g+_*_}function oo(r,t,e,i,n,s,a,o){const l=a-e,u=o-i,c=n-e,h=s-i,p=r-e,f=t-i,m=l*l+u*u,g=l*c+u*h,_=l*p+u*f,y=c*c+h*h,b=c*p+h*f,x=1/(m*y-g*g),v=(y*_-g*b)*x,w=(m*b-g*_)*x;return v>=0&&w>=0&&v+w<1}class Pn{constructor(t=0,e=0,i=0){this.type="circle",this.x=t,this.y=e,this.radius=i}clone(){return new Pn(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let n=this.x-t,s=this.y-e;return n*=n,s*=s,n+s<=i}strokeContains(t,e,i,n=.5){if(this.radius===0)return!1;const s=this.x-t,a=this.y-e,o=this.radius,l=(1-n)*i,u=Math.sqrt(s*s+a*a);return u<=o+l&&u>o-(i-l)}getBounds(t){return t||(t=new ut),t.x=this.x-this.radius,t.y=this.y-this.radius,t.width=this.radius*2,t.height=this.radius*2,t}copyFrom(t){return this.x=t.x,this.y=t.y,this.radius=t.radius,this}copyTo(t){return t.copyFrom(this),t}}class An{constructor(t=0,e=0,i=0,n=0){this.type="ellipse",this.x=t,this.y=e,this.halfWidth=i,this.halfHeight=n}clone(){return new An(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,n=(e-this.y)/this.halfHeight;return i*=i,n*=n,i+n<=1}strokeContains(t,e,i,n=.5){const{halfWidth:s,halfHeight:a}=this;if(s<=0||a<=0)return!1;const o=i*(1-n),l=i-o,u=s-l,c=a-l,h=s+o,p=a+o,f=t-this.x,m=e-this.y,g=f*f/(u*u)+m*m/(c*c),_=f*f/(h*h)+m*m/(p*p);return g>1&&_<=1}getBounds(t){return t||(t=new ut),t.x=this.x-this.halfWidth,t.y=this.y-this.halfHeight,t.width=this.halfWidth*2,t.height=this.halfHeight*2,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}}let q2,Z2;class Pr{constructor(...t){this.type="polygon";let e=Array.isArray(t[0])?t[0]:t;if(typeof e[0]!="number"){const i=[];for(let n=0,s=e.length;ne!=c>e&&t<(u-o)*((e-l)/(c-l))+o&&(i=!i)}return i}strokeContains(t,e,i,n=.5){const s=i*i,a=s*(1-n),o=s-a,{points:l}=this,u=l.length-(this.closePath?0:2);for(let c=0;cn?u:n,s=ca?c:a}return t.x=i,t.width=n-i,t.y=s,t.height=a-s,t}copyFrom(t){return this.points=t.points.slice(),this.closePath=t.closePath,this}copyTo(t){return t.copyFrom(this),t}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}get x(){return this.points[this.points.length-2]}get y(){return this.points[this.points.length-1]}get startX(){return this.points[0]}get startY(){return this.points[1]}}const Cn=(r,t,e,i,n,s,a)=>{const o=r-e,l=t-i,u=Math.sqrt(o*o+l*l);return u>=n-s&&u<=n+a};class Mn{constructor(t=0,e=0,i=0,n=0,s=20){this.type="roundedRectangle",this.x=t,this.y=e,this.width=i,this.height=n,this.radius=s}getBounds(t){return t||(t=new ut),t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}clone(){return new Mn(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 n=t-(this.x+i),s=e-(this.y+i);const a=i*i;if(n*n+s*s<=a||(n=t-(this.x+this.width-i),n*n+s*s<=a)||(s=e-(this.y+this.height-i),n*n+s*s<=a)||(n=t-(this.x+i),n*n+s*s<=a))return!0}return!1}strokeContains(t,e,i,n=.5){const{x:s,y:a,width:o,height:l,radius:u}=this,c=i*(1-n),h=i-c,p=s+u,f=a+u,m=o-u*2,g=l-u*2,_=s+o,y=a+l;return(t>=s-c&&t<=s+h||t>=_-h&&t<=_+c)&&e>=f&&e<=f+g||(e>=a-c&&e<=a+h||e>=y-h&&e<=y+c)&&t>=p&&t<=p+m?!0:t_-u&&e_-u&&e>y-u&&Cn(t,e,_-u,y-u,u,h,c)||ty-u&&Cn(t,e,p,y-u,u,h,c)}}class lo{constructor(t=0,e=0,i=0,n=0,s=0,a=0){this.type="triangle",this.x=t,this.y=e,this.x2=i,this.y2=n,this.x3=s,this.y3=a}contains(t,e){const i=(this.x-this.x3)*(e-this.y3)-(this.y-this.y3)*(t-this.x3),n=(this.x2-this.x)*(e-this.y)-(this.y2-this.y)*(t-this.x);if(i<0!=n<0&&i!==0&&n!==0)return!1;const s=(this.x3-this.x2)*(e-this.y2)-(this.y3-this.y2)*(t-this.x2);return s===0||s<0==i+n<=0}strokeContains(t,e,i,n=.5){const s=i/2,a=s*s,{x:o,x2:l,x3:u,y:c,y2:h,y3:p}=this;return mi(t,e,o,c,l,p)<=a||mi(t,e,l,h,u,p)<=a||mi(t,e,u,p,o,c)<=a}clone(){return new lo(this.x,this.y,this.x2,this.y2,this.x3,this.y3)}copyFrom(t){return this.x=t.x,this.y=t.y,this.x2=t.x2,this.y2=t.y2,this.x3=t.x3,this.y3=t.y3,this}copyTo(t){return t.copyFrom(this),t}getBounds(t){t||(t=new ut);const e=Math.min(this.x,this.x2,this.x3),i=Math.max(this.x,this.x2,this.x3),n=Math.min(this.y,this.y2,this.y3),s=Math.max(this.y,this.y2,this.y3);return t.x=e,t.y=n,t.width=i-e,t.height=s-n,t}}const Ip=new U;function uo(r,t){var e;t.clear();const i=t.matrix;for(let n=0;n!l.enabled)){e.skip=!0;return}const n=[],s=1;for(const l of i){if(!l.enabled)continue;if(!co(l)){this._warnUnsupportedFilter(l);continue}const u=l.getCanvasFilterString();if(u===null){this._warnUnsupportedFilter(l);continue}u&&n.push(u)}if(n.length===0&&s===1){e.skip=!0;return}e.cssFilterString=n.join(" "),this._calculateFilterArea(t,e.bounds),e.useClip=!!t.filterEffect.filterArea;const a=this.renderer.canvasContext.activeContext,o=a.filter||"none";if(this._savedStates.push({filter:o,alphaMultiplier:this._alphaMultiplier}),e.useClip&&Number.isFinite(e.bounds.width)&&Number.isFinite(e.bounds.height)&&e.bounds.width>0&&e.bounds.height>0){const l=this.renderer.canvasContext.activeResolution||1;a.save(),a.setTransform(1,0,0,1,0,0),a.beginPath(),a.rect(e.bounds.x*l,e.bounds.y*l,e.bounds.width*l,e.bounds.height*l),a.clip()}else e.useClip=!1;s!==1&&(this._alphaMultiplier*=s),e.cssFilterString&&(a.filter=o!=="none"?`${o} ${e.cssFilterString}`:e.cssFilterString)}pop(){const t=this._popFilterFrame();if(t.skip)return;const e=this._savedStates.pop();if(!e)return;const i=this.renderer.canvasContext.activeContext;t.useClip?i.restore():i.filter=e.filter,this._alphaMultiplier=e.alphaMultiplier}generateFilteredTexture({texture:t,filters:e}){var i,n;if(!(e!=null&&e.length)||e.every(x=>!x.enabled))return t;const s=[],a=1;for(const x of e){if(!x.enabled)continue;if(!co(x)){this._warnUnsupportedFilter(x);continue}const v=x.getCanvasFilterString();if(v===null){this._warnUnsupportedFilter(x);continue}v&&s.push(v)}if(s.length===0&&a===1)return t;const o=Q.getCanvasSource(t);if(!o)return t;const l=t.frame,u=(n=(i=t.source._resolution)!=null?i:t.source.resolution)!=null?n:1,c=l.width,h=l.height,p=me.getOptimalCanvasAndContext(c,h,u),{canvas:f,context:m}=p;m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,f.width,f.height),s.length&&(m.filter=s.join(" ")),a!==1&&(m.globalAlpha=a);const g=l.x*u,_=l.y*u,y=c*u,b=h*u;return m.drawImage(o,g,_,y,b,0,0,y,b),m.filter="none",m.globalAlpha=1,Rn(f,c,h,u)}_calculateFilterArea(t,e){if(t.renderables?uo(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,n=i==null?void 0:i.cacheToLocalTransform;n&&e.applyMatrix(n)}}_warnUnsupportedFilter(t){var e;const i=((e=t==null?void 0:t.constructor)==null?void 0:e.name)||"Filter";this._warnedFilterTypes.has(i)||(this._warnedFilterTypes.add(i),console.warn(`CanvasRenderer: filter "${i}" is not supported in Canvas2D and will be skipped.`))}get alphaMultiplier(){return this._alphaMultiplier}_pushFilterFrame(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new J2),this._filterStackIndex++,t}_popFilterFrame(){return this._filterStackIndex<=0?this._filterStack[0]:(this._filterStackIndex--,this._filterStack[this._filterStackIndex])}destroy(){this._filterStack=null,this._savedStates=null,this._warnedFilterTypes=null,this._alphaMultiplier=1}}ho.extension={type:[S.CanvasSystem],name:"filter"};class po{constructor(t){this._renderer=t}push(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:e,filterEffect:t})}pop(t,e,i){this._renderer.renderPipes.batch.break(i),i.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(t){t.action==="pushFilter"?this._renderer.filter.push(t):t.action==="popFilter"&&this._renderer.filter.pop()}destroy(){this._renderer=null}}po.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"filter"};const fo=Object.create(null),Bp=Object.create(null);function Ar(r,t){let e=Bp[r];return e===void 0&&(fo[t]===void 0&&(fo[t]=1),Bp[r]=e=fo[t]++),e}let gi;function mo(){return(!gi||gi!=null&&gi.isContextLost())&&(gi=H.get().createCanvas().getContext("webgl",{})),gi}let On;function Fp(){if(!On){On="mediump";const r=mo();r&&r.getShaderPrecisionFormat&&(On=r.getShaderPrecisionFormat(r.FRAGMENT_SHADER,r.HIGH_FLOAT).precision?"highp":"mediump")}return On}function Dp(r,t,e){return t?r:e?(r=r.replace("out vec4 finalColor;",""),` #ifdef GL_ES // This checks if it is WebGL1 #define in varying @@ -32,10 +32,10 @@ var CB=Object.defineProperty;var S1=Object.getOwnPropertySymbols;var MB=Object.p #define out varying #endif ${r} - `}function Dp(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float; -${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function Up(r,t){return t?`#version 300 es -${r}`:r}const K2={},q2={};function $p(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?K2:q2;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} -${r}`}function kp(r,t){return t?r.replace("#version 300 es",""):r}var Z2=Object.defineProperty,Lp=Object.getOwnPropertySymbols,Q2=Object.prototype.hasOwnProperty,J2=Object.prototype.propertyIsEnumerable,Np=(r,t,e)=>t in r?Z2(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xp=(r,t)=>{for(var e in t||(t={}))Q2.call(t,e)&&Np(r,e,t[e]);if(Lp)for(var e of Lp(t))J2.call(t,e)&&Np(r,e,t[e]);return r};const mo={stripVersion:kp,ensurePrecision:Dp,addProgramDefines:Fp,setProgramName:$p,insertVersion:Up},_i=Object.create(null),jp=class Th{constructor(t){t=Xp(Xp({},Th.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Bp()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,s=t.vertex;Object.keys(mo).forEach(a=>{const o=i[a];n=mo[a](n,o,!0),s=mo[a](s,o,!1)}),this.fragment=n,this.vertex=s,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ar(`${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,_i[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return _i[e]||(_i[e]=new Th(t),_i[e]._cacheKey=e),_i[e]}};jp.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Wt=jp;const Hp={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Ie(r){var t;return(t=Hp[r])!=null?t:Hp.float32}const tw={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"},zp=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Wp(r,t){var e;let i;for(;(i=zp.exec(r))!==null;){const n=(e=tw[i[3]])!=null?e:"float32";t[i[2]]={location:parseInt(i[1],10),format:n,stride:Ie(n).stride,offset:0,instance:!1,start:0}}zp.lastIndex=0}function ew(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Vp({source:r,entryPoint:t}){const e={},i=ew(r),n=i.indexOf(`fn ${t}(`);if(n===-1)return e;const s=i.indexOf("->",n);if(s===-1)return e;const a=i.substring(n,s);if(Wp(a,e),Object.keys(e).length===0){const o=a.match(/\(\s*\w+\s*:\s*(\w+)/);if(o){const l=o[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=i.match(u);c&&Wp(c[1],e)}}return e}function Rn(r){var t,e,i;const n=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,s=/@group\((\d+)\)/,a=/@binding\((\d+)\)/,o=/var(<[^>]+>)? (\w+)/,l=/:\s*([\w<>]+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,p=(t=r.match(n))==null?void 0:t.map(m=>({group:parseInt(m.match(s)[1],10),binding:parseInt(m.match(a)[1],10),name:m.match(o)[2],isUniform:m.match(o)[1]==="",type:m.match(l)[1]}));if(!p)return{groups:[],structs:[]};const f=(i=(e=r.match(u))==null?void 0:e.map(m=>{const g=m.match(h)[1],_=m.match(c).reduce((y,b)=>{const[x,v]=b.split(":");return y[x.trim()]=v.trim(),y},{});return _?{name:g,members:_}:null}).filter(({name:m})=>p.some(g=>g.type===m||g.type.includes(`<${m}>`))))!=null?i:[];return{groups:p,structs:f}}var Le=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Le||{});function Yp({groups:r}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),s=[...r.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:n,groups:s}}const yi=Object.create(null);class Xt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,i;const{fragment:n,vertex:s,layout:a,gpuLayout:o,name:l}=t;if(this.name=l,this.fragment=n,this.vertex=s,n.source===s.source){const u=Rn(n.source);this.structsAndGroups=u}else{const u=Rn(s.source),c=Rn(n.source);this.structsAndGroups=qp(u,c)}this.layout=a!=null?a:Kp(this.structsAndGroups),this.gpuLayout=o!=null?o:Yp(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((i=this.layout[1])==null?void 0:i.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ar(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Vp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,yi[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return yi[e]||(yi[e]=new Xt(t),yi[e]._cacheKey=e),yi[e]}}class Pe{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,n;const s=this.resources[e];t!==s&&((i=s==null?void 0:s.off)==null||i.call(s,"change",this.onResourceChange,this),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const n in i)i[n]._gcLastUsed=t,i[n]._touched=e}destroy(){var t;const e=this.resources;for(const i in e){const n=e[i];(t=n==null?void 0:n.off)==null||t.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var It=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(It||{});const go=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4"],Zp=go.reduce((r,t)=>(r[t]=!0,r),{});function Qp(r,t){switch(r){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var rw=Object.defineProperty,Jp=Object.getOwnPropertySymbols,iw=Object.prototype.hasOwnProperty,nw=Object.prototype.propertyIsEnumerable,tf=(r,t,e)=>t in r?rw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ef=(r,t)=>{for(var e in t||(t={}))iw.call(t,e)&&tf(r,e,t[e]);if(Jp)for(var e of Jp(t))nw.call(t,e)&&tf(r,e,t[e]);return r};const rf=class R1{constructor(t,e){this._touched=0,this.uid=ht("uniform"),this._resourceType="uniformGroup",this._resourceId=ht("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,n;e=ef(ef({},R1.defaultOptions),e),this.uniformStructures=t;const s={};for(const a in t){const o=t[a];if(o.name=a,o.size=(i=o.size)!=null?i:1,!Zp[o.type]){const l=o.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,c]=l;throw new Error(`Uniform type ${o.type} is not supported. Use type: '${u}', size: ${c} instead.`)}throw new Error(`Uniform type ${o.type} is not supported. Supported uniform types are: ${go.join(", ")}`)}(n=o.value)!=null||(o.value=Qp(o.type,o.size)),s[a]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ar(Object.keys(s).map(a=>`${a}-${t[a].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};rf.defaultOptions={ubo:!1,isStatic:!1};let At=rf;var sw=Object.defineProperty,On=Object.getOwnPropertySymbols,nf=Object.prototype.hasOwnProperty,sf=Object.prototype.propertyIsEnumerable,af=(r,t,e)=>t in r?sw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aw=(r,t)=>{for(var e in t||(t={}))nf.call(t,e)&&af(r,e,t[e]);if(On)for(var e of On(t))sf.call(t,e)&&af(r,e,t[e]);return r},ow=(r,t)=>{var e={};for(var i in r)nf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&On)for(var i of On(r))t.indexOf(i)<0&&sf.call(r,i)&&(e[i]=r[i]);return e};class ee extends Nt{constructor(t){super(),this.uid=ht("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:n,resources:s,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=It.WEBGPU),i&&(a|=It.WEBGL)),this.compatibleRenderers=a;const l={};if(!s&&!n&&(s={}),s&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const u in o)for(const c in o[u]){const h=o[u][c];l[h]={group:u,binding:c,name:h}}else if(e&&n&&!o){const u=e.structsAndGroups.groups;o={},u.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c})}else if(s){n={},o={},e&&e.structsAndGroups.groups.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c});let u=0;for(const c in s)l[c]||(n[99]||(n[99]=new Pe,this._ownedBindGroups.push(n[99])),l[c]={group:99,binding:u,name:c},o[99]=o[99]||{},o[99][u]=c,u++);for(const c in s){const h=c;let p=s[c];!p.source&&!p._resourceType&&(p=new At(p));const f=l[h];f&&(n[f.group]||(n[f.group]=new Pe,this._ownedBindGroups.push(n[f.group])),n[f.group].setResource(p,f.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,l)}addResource(t,e,i){var n,s;(n=this._uniformBindMap)[e]||(n[e]={}),(s=this._uniformBindMap[e])[i]||(s[i]=t),this.groups[e]||(this.groups[e]=new Pe,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const s=e[n];Object.defineProperty(i,s.name,{get(){return t[s.group].getResource(s.binding)},set(a){t[s.group].setResource(a,s.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const e=t,{gpu:i,gl:n}=e,s=ow(e,["gpu","gl"]);let a,o;return i&&(a=Xt.from(i)),n&&(o=Wt.from(n)),new ee(aw({gpuProgram:a,glProgram:o},s))}}const lw={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},_o=0,yo=1,bo=2,vo=3,xo=4,To=5,So=class O1{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<<_o)}set blend(t){!!(this.data&1<<_o)!==t&&(this.data^=1<<_o)}get offsets(){return!!(this.data&1<t in r?uw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,wo=(r,t)=>{for(var e in t||(t={}))of.call(t,e)&&uf(r,e,t[e]);if(Gn)for(var e of Gn(t))lf.call(t,e)&&uf(r,e,t[e]);return r},cw=(r,t)=>{var e={};for(var i in r)of.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Gn)for(var i of Gn(r))t.indexOf(i)<0&&lf.call(r,i)&&(e[i]=r[i]);return e};const cf=class Sh extends ee{constructor(t){t=wo(wo({},Sh.defaultOptions),t),super(t),this.enabled=!0,this._state=Vt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,n){t.applyFilter(this,e,i,n)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:i,gl:n}=e,s=cw(e,["gpu","gl"]);let a,o;return i&&(a=Xt.from(i)),n&&(o=Wt.from(n)),new Sh(wo({gpuProgram:a,glProgram:o},s))}};cf.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Ee=cf;var bi=`in vec2 aPosition; + `}function Up(r,t,e){const i=e?t.maxSupportedFragmentPrecision:t.maxSupportedVertexPrecision;if(r.substring(0,9)!=="precision"){let n=e?t.requestedFragmentPrecision:t.requestedVertexPrecision;return n==="highp"&&i!=="highp"&&(n="mediump"),`precision ${n} float; +${r}`}else if(i!=="highp"&&r.substring(0,15)==="precision highp")return r.replace("precision highp","precision mediump");return r}function $p(r,t){return t?`#version 300 es +${r}`:r}const tw={},ew={};function kp(r,{name:t="pixi-program"},e=!0){t=t.replace(/\s+/g,"-"),t+=e?"-fragment":"-vertex";const i=e?tw:ew;return i[t]?(i[t]++,t+=`-${i[t]}`):i[t]=1,r.indexOf("#define SHADER_NAME")!==-1?r:`${`#define SHADER_NAME ${t}`} +${r}`}function Lp(r,t){return t?r.replace("#version 300 es",""):r}var rw=Object.defineProperty,Np=Object.getOwnPropertySymbols,iw=Object.prototype.hasOwnProperty,nw=Object.prototype.propertyIsEnumerable,Xp=(r,t,e)=>t in r?rw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jp=(r,t)=>{for(var e in t||(t={}))iw.call(t,e)&&Xp(r,e,t[e]);if(Np)for(var e of Np(t))nw.call(t,e)&&Xp(r,e,t[e]);return r};const go={stripVersion:Lp,ensurePrecision:Up,addProgramDefines:Dp,setProgramName:kp,insertVersion:$p},_i=Object.create(null),Hp=class wh{constructor(t){t=jp(jp({},wh.defaultOptions),t);const e=t.fragment.indexOf("#version 300 es")!==-1,i={stripVersion:e,ensurePrecision:{requestedFragmentPrecision:t.preferredFragmentPrecision,requestedVertexPrecision:t.preferredVertexPrecision,maxSupportedVertexPrecision:"highp",maxSupportedFragmentPrecision:Fp()},setProgramName:{name:t.name},addProgramDefines:e,insertVersion:e};let n=t.fragment,s=t.vertex;Object.keys(go).forEach(a=>{const o=i[a];n=go[a](n,o,!0),s=go[a](s,o,!1)}),this.fragment=n,this.vertex=s,this.transformFeedbackVaryings=t.transformFeedbackVaryings,this._key=Ar(`${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,_i[this._cacheKey]=null}static from(t){const e=`${t.vertex}:${t.fragment}`;return _i[e]||(_i[e]=new wh(t),_i[e]._cacheKey=e),_i[e]}};Hp.defaultOptions={preferredVertexPrecision:"highp",preferredFragmentPrecision:"mediump"};let Wt=Hp;const zp={uint8x2:{size:2,stride:2,normalised:!1},uint8x4:{size:4,stride:4,normalised:!1},sint8x2:{size:2,stride:2,normalised:!1},sint8x4:{size:4,stride:4,normalised:!1},unorm8x2:{size:2,stride:2,normalised:!0},unorm8x4:{size:4,stride:4,normalised:!0},snorm8x2:{size:2,stride:2,normalised:!0},snorm8x4:{size:4,stride:4,normalised:!0},uint16x2:{size:2,stride:4,normalised:!1},uint16x4:{size:4,stride:8,normalised:!1},sint16x2:{size:2,stride:4,normalised:!1},sint16x4:{size:4,stride:8,normalised:!1},unorm16x2:{size:2,stride:4,normalised:!0},unorm16x4:{size:4,stride:8,normalised:!0},snorm16x2:{size:2,stride:4,normalised:!0},snorm16x4:{size:4,stride:8,normalised:!0},float16x2:{size:2,stride:4,normalised:!1},float16x4:{size:4,stride:8,normalised:!1},float32:{size:1,stride:4,normalised:!1},float32x2:{size:2,stride:8,normalised:!1},float32x3:{size:3,stride:12,normalised:!1},float32x4:{size:4,stride:16,normalised:!1},uint32:{size:1,stride:4,normalised:!1},uint32x2:{size:2,stride:8,normalised:!1},uint32x3:{size:3,stride:12,normalised:!1},uint32x4:{size:4,stride:16,normalised:!1},sint32:{size:1,stride:4,normalised:!1},sint32x2:{size:2,stride:8,normalised:!1},sint32x3:{size:3,stride:12,normalised:!1},sint32x4:{size:4,stride:16,normalised:!1}};function Ie(r){var t;return(t=zp[r])!=null?t:zp.float32}const sw={f32:"float32","vec2":"float32x2","vec3":"float32x3","vec4":"float32x4",vec2f:"float32x2",vec3f:"float32x3",vec4f:"float32x4",i32:"sint32","vec2":"sint32x2","vec3":"sint32x3","vec4":"sint32x4",vec2i:"sint32x2",vec3i:"sint32x3",vec4i:"sint32x4",u32:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4",vec2u:"uint32x2",vec3u:"uint32x3",vec4u:"uint32x4",bool:"uint32","vec2":"uint32x2","vec3":"uint32x3","vec4":"uint32x4"},Wp=/@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;function Vp(r,t){var e;let i;for(;(i=Wp.exec(r))!==null;){const n=(e=sw[i[3]])!=null?e:"float32";t[i[2]]={location:parseInt(i[1],10),format:n,stride:Ie(n).stride,offset:0,instance:!1,start:0}}Wp.lastIndex=0}function aw(r){return r.replace(/\/\/.*$/gm,"").replace(/\/\*[\s\S]*?\*\//g,"")}function Yp({source:r,entryPoint:t}){const e={},i=aw(r),n=i.indexOf(`fn ${t}(`);if(n===-1)return e;const s=i.indexOf("->",n);if(s===-1)return e;const a=i.substring(n,s);if(Vp(a,e),Object.keys(e).length===0){const o=a.match(/\(\s*\w+\s*:\s*(\w+)/);if(o){const l=o[1],u=new RegExp(`struct\\s+${l}\\s*\\{([^}]+)\\}`,"s"),c=i.match(u);c&&Vp(c[1],e)}}return e}function Gn(r){var t,e,i;const n=/(^|[^/])@(group|binding)\(\d+\)[^;]+;/g,s=/@group\((\d+)\)/,a=/@binding\((\d+)\)/,o=/var(<[^>]+>)? (\w+)/,l=/:\s*([\w<>]+)/,u=/struct\s+(\w+)\s*{([^}]+)}/g,c=/(\w+)\s*:\s*([\w\<\>]+)/g,h=/struct\s+(\w+)/,p=(t=r.match(n))==null?void 0:t.map(m=>({group:parseInt(m.match(s)[1],10),binding:parseInt(m.match(a)[1],10),name:m.match(o)[2],isUniform:m.match(o)[1]==="",type:m.match(l)[1]}));if(!p)return{groups:[],structs:[]};const f=(i=(e=r.match(u))==null?void 0:e.map(m=>{const g=m.match(h)[1],_=m.match(c).reduce((y,b)=>{const[x,v]=b.split(":");return y[x.trim()]=v.trim(),y},{});return _?{name:g,members:_}:null}).filter(({name:m})=>p.some(g=>g.type===m||g.type.includes(`<${m}>`))))!=null?i:[];return{groups:p,structs:f}}var Le=(r=>(r[r.VERTEX=1]="VERTEX",r[r.FRAGMENT=2]="FRAGMENT",r[r.COMPUTE=4]="COMPUTE",r))(Le||{});function Kp({groups:r}){const t=[];for(let e=0;ee.has(a.name)?!1:(e.add(a.name),!0)),s=[...r.groups,...t.groups].filter(a=>{const o=`${a.name}-${a.binding}`;return i.has(o)?!1:(i.add(o),!0)});return{structs:n,groups:s}}const yi=Object.create(null);class Xt{constructor(t){this._layoutKey=0,this._attributeLocationsKey=0;var e,i;const{fragment:n,vertex:s,layout:a,gpuLayout:o,name:l}=t;if(this.name=l,this.fragment=n,this.vertex=s,n.source===s.source){const u=Gn(n.source);this.structsAndGroups=u}else{const u=Gn(s.source),c=Gn(n.source);this.structsAndGroups=Zp(u,c)}this.layout=a!=null?a:qp(this.structsAndGroups),this.gpuLayout=o!=null?o:Kp(this.structsAndGroups),this.autoAssignGlobalUniforms=((e=this.layout[0])==null?void 0:e.globalUniforms)!==void 0,this.autoAssignLocalUniforms=((i=this.layout[1])==null?void 0:i.localUniforms)!==void 0,this._generateProgramKey()}_generateProgramKey(){const{vertex:t,fragment:e}=this,i=t.source+e.source+t.entryPoint+e.entryPoint;this._layoutKey=Ar(i,"program")}get attributeData(){var t;return(t=this._attributeData)!=null||(this._attributeData=Yp(this.vertex)),this._attributeData}destroy(){this.gpuLayout=null,this.layout=null,this.structsAndGroups=null,this.fragment=null,this.vertex=null,yi[this._cacheKey]=null}static from(t){const e=`${t.vertex.source}:${t.fragment.source}:${t.fragment.entryPoint}:${t.vertex.entryPoint}`;return yi[e]||(yi[e]=new Xt(t),yi[e]._cacheKey=e),yi[e]}}class Ee{constructor(t){this.resources=Object.create(null),this._dirty=!0;let e=0;for(const i in t){const n=t[i];this.setResource(n,e++)}this._updateKey()}_updateKey(){if(!this._dirty)return;this._dirty=!1;const t=[];let e=0;for(const i in this.resources)t[e++]=this.resources[i]._resourceId;this._key=t.join("|")}setResource(t,e){var i,n;const s=this.resources[e];t!==s&&((i=s==null?void 0:s.off)==null||i.call(s,"change",this.onResourceChange,this),(n=t.on)==null||n.call(t,"change",this.onResourceChange,this),this.resources[e]=t,this._dirty=!0)}getResource(t){return this.resources[t]}_touch(t,e){const i=this.resources;for(const n in i)i[n]._gcLastUsed=t,i[n]._touched=e}destroy(){var t;const e=this.resources;for(const i in e){const n=e[i];(t=n==null?void 0:n.off)==null||t.call(n,"change",this.onResourceChange,this)}this.resources=null}onResourceChange(t){this._dirty=!0,t.destroyed?this.destroy():this._updateKey()}}var It=(r=>(r[r.WEBGL=1]="WEBGL",r[r.WEBGPU=2]="WEBGPU",r[r.CANVAS=4]="CANVAS",r[r.BOTH=3]="BOTH",r))(It||{});const _o=["f32","i32","vec2","vec3","vec4","mat2x2","mat3x3","mat4x4","mat3x2","mat4x2","mat2x3","mat4x3","mat2x4","mat3x4","vec2","vec3","vec4"],Qp=_o.reduce((r,t)=>(r[t]=!0,r),{});function Jp(r,t){switch(r){case"f32":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"mat2x2":return new Float32Array([1,0,0,1]);case"mat3x3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4x4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}var ow=Object.defineProperty,tf=Object.getOwnPropertySymbols,lw=Object.prototype.hasOwnProperty,uw=Object.prototype.propertyIsEnumerable,ef=(r,t,e)=>t in r?ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rf=(r,t)=>{for(var e in t||(t={}))lw.call(t,e)&&ef(r,e,t[e]);if(tf)for(var e of tf(t))uw.call(t,e)&&ef(r,e,t[e]);return r};const nf=class G1{constructor(t,e){this._touched=0,this.uid=ht("uniform"),this._resourceType="uniformGroup",this._resourceId=ht("resource"),this.isUniformGroup=!0,this._dirtyId=0,this.destroyed=!1;var i,n;e=rf(rf({},G1.defaultOptions),e),this.uniformStructures=t;const s={};for(const a in t){const o=t[a];if(o.name=a,o.size=(i=o.size)!=null?i:1,!Qp[o.type]){const l=o.type.match(/^array<(\w+(?:<\w+>)?),\s*(\d+)>$/);if(l){const[,u,c]=l;throw new Error(`Uniform type ${o.type} is not supported. Use type: '${u}', size: ${c} instead.`)}throw new Error(`Uniform type ${o.type} is not supported. Supported uniform types are: ${_o.join(", ")}`)}(n=o.value)!=null||(o.value=Jp(o.type,o.size)),s[a]=o.value}this.uniforms=s,this._dirtyId=1,this.ubo=e.ubo,this.isStatic=e.isStatic,this._signature=Ar(Object.keys(s).map(a=>`${a}-${t[a].type}`).join("-"),"uniform-group")}update(){this._dirtyId++}};nf.defaultOptions={ubo:!1,isStatic:!1};let At=nf;var cw=Object.defineProperty,In=Object.getOwnPropertySymbols,sf=Object.prototype.hasOwnProperty,af=Object.prototype.propertyIsEnumerable,of=(r,t,e)=>t in r?cw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hw=(r,t)=>{for(var e in t||(t={}))sf.call(t,e)&&of(r,e,t[e]);if(In)for(var e of In(t))af.call(t,e)&&of(r,e,t[e]);return r},dw=(r,t)=>{var e={};for(var i in r)sf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&In)for(var i of In(r))t.indexOf(i)<0&&af.call(r,i)&&(e[i]=r[i]);return e};class ee extends Nt{constructor(t){super(),this.uid=ht("shader"),this._uniformBindMap=Object.create(null),this._ownedBindGroups=[],this._destroyed=!1;let{gpuProgram:e,glProgram:i,groups:n,resources:s,compatibleRenderers:a,groupMap:o}=t;this.gpuProgram=e,this.glProgram=i,a===void 0&&(a=0,e&&(a|=It.WEBGPU),i&&(a|=It.WEBGL)),this.compatibleRenderers=a;const l={};if(!s&&!n&&(s={}),s&&n)throw new Error("[Shader] Cannot have both resources and groups");if(!e&&n&&!o)throw new Error("[Shader] No group map or WebGPU shader provided - consider using resources instead.");if(!e&&n&&o)for(const u in o)for(const c in o[u]){const h=o[u][c];l[h]={group:u,binding:c,name:h}}else if(e&&n&&!o){const u=e.structsAndGroups.groups;o={},u.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c})}else if(s){n={},o={},e&&e.structsAndGroups.groups.forEach(c=>{o[c.group]=o[c.group]||{},o[c.group][c.binding]=c.name,l[c.name]=c});let u=0;for(const c in s)l[c]||(n[99]||(n[99]=new Ee,this._ownedBindGroups.push(n[99])),l[c]={group:99,binding:u,name:c},o[99]=o[99]||{},o[99][u]=c,u++);for(const c in s){const h=c;let p=s[c];!p.source&&!p._resourceType&&(p=new At(p));const f=l[h];f&&(n[f.group]||(n[f.group]=new Ee,this._ownedBindGroups.push(n[f.group])),n[f.group].setResource(p,f.binding))}}this.groups=n,this._uniformBindMap=o,this.resources=this._buildResourceAccessor(n,l)}addResource(t,e,i){var n,s;(n=this._uniformBindMap)[e]||(n[e]={}),(s=this._uniformBindMap[e])[i]||(s[i]=t),this.groups[e]||(this.groups[e]=new Ee,this._ownedBindGroups.push(this.groups[e]))}_buildResourceAccessor(t,e){const i={};for(const n in e){const s=e[n];Object.defineProperty(i,s.name,{get(){return t[s.group].getResource(s.binding)},set(a){t[s.group].setResource(a,s.binding)}})}return i}destroy(t=!1){var e,i;this._destroyed||(this._destroyed=!0,this.emit("destroy",this),t&&((e=this.gpuProgram)==null||e.destroy(),(i=this.glProgram)==null||i.destroy()),this.gpuProgram=null,this.glProgram=null,this.removeAllListeners(),this._uniformBindMap=null,this._ownedBindGroups.forEach(n=>{n.destroy()}),this._ownedBindGroups=null,this.resources=null,this.groups=null)}static from(t){const e=t,{gpu:i,gl:n}=e,s=dw(e,["gpu","gl"]);let a,o;return i&&(a=Xt.from(i)),n&&(o=Wt.from(n)),new ee(hw({gpuProgram:a,glProgram:o},s))}}const pw={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},yo=0,bo=1,vo=2,xo=3,To=4,So=5,wo=class I1{constructor(){this.data=0,this.blendMode="normal",this.polygonOffset=0,this.blend=!0,this.depthMask=!0}get blend(){return!!(this.data&1<t in r?fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Eo=(r,t)=>{for(var e in t||(t={}))lf.call(t,e)&&cf(r,e,t[e]);if(Bn)for(var e of Bn(t))uf.call(t,e)&&cf(r,e,t[e]);return r},mw=(r,t)=>{var e={};for(var i in r)lf.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Bn)for(var i of Bn(r))t.indexOf(i)<0&&uf.call(r,i)&&(e[i]=r[i]);return e};const hf=class Eh extends ee{constructor(t){t=Eo(Eo({},Eh.defaultOptions),t),super(t),this.enabled=!0,this._state=Vt.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,typeof t.antialias=="boolean"?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(t,e,i,n){t.applyFilter(this,e,i,n)}get blendMode(){return this._state.blendMode}set blendMode(t){this._state.blendMode=t}static from(t){const e=t,{gpu:i,gl:n}=e,s=mw(e,["gpu","gl"]);let a,o;return i&&(a=Xt.from(i)),n&&(o=Wt.from(n)),new Eh(Eo({gpuProgram:a,glProgram:o},s))}};hf.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let Pe=hf;var bi=`in vec2 aPosition; out vec2 vTextureCoord; uniform vec4 uInputSize; @@ -62,7 +62,7 @@ void main(void) gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } -`,hf=`in vec2 vTextureCoord; +`,df=`in vec2 vTextureCoord; out vec4 finalColor; uniform sampler2D uTexture; void main() { @@ -117,30 +117,30 @@ fn mainFragment( ) -> @location(0) vec4 { return textureSample(uTexture, uSampler, uv); } -`;class df extends Ee{constructor(){const t=Xt.from({vertex:{source:Po,entryPoint:"mainVertex"},fragment:{source:Po,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=Wt.from({vertex:bi,fragment:hf,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}var at=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(at||{});class Yt extends Nt{constructor(t){let{data:e,size:i}=t;const{usage:n,label:s,shrinkToFit:a}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ht("buffer"),this._resourceType="buffer",this._resourceId=ht("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i!=null||(i=e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:o,label:s},this.shrinkToFit=a!=null?a:!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&at.STATIC)}set static(t){t?this.descriptor.usage|=at.STATIC:this.descriptor.usage&=~at.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLengtho&&(o=f),m>l&&(l=m),fi.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const dw=new nr({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])});let pw=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new Mt,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 Ao{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new At({uInputSize:{value:new Float32Array(4),type:"vec4"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Pe({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,n=this._pushFilterData();n.skip=!1,n.filters=i,n.container=t.container,n.outputRenderSurface=e.renderTarget.renderSurface;const s=e.renderTarget.renderTarget.colorTexture.source,a=s.resolution,o=s.antialias;if(i.every(f=>!f.enabled)){n.skip=!0;return}const l=n.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(n,e.renderTarget.rootViewPort,o,a,1),n.skip)return;const u=this._getPreviousFilterData(),c=this._findFilterResolution(a);let h=0,p=0;u&&(h=u.bounds.minX,p=u.bounds.minY),this._calculateGlobalFrame(n,h,p,c,s.width,s.height),this._setupFilterTextures(n,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,s=n.resolution,a=n.antialias;if(e.every(c=>!c.enabled))return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,a,s,0),i.skip)return t;const l=s;this._calculateGlobalFrame(i,0,0,l,n.width,n.height),i.outputRenderSurface=vt.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=D.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const u=i.outputRenderSurface;return u.source.alphaMode="premultiplied-alpha",u}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&&vt.returnTexture(e.backTexture),vt.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,s=vt.getOptimalTexture(e.width,e.height,n,!1);let a=e.minX,o=e.minY;i&&(a-=i.minX,o-=i.minY),a=Math.floor(a*n),o=Math.floor(o*n);const l=Math.ceil(e.width*n),u=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,s,{x:a,y:o},{width:l,height:u},{x:0,y:0}),s}applyFilter(t,e,i,n){const s=this.renderer,a=this._activeFilterData,o=a.outputRenderSurface===i,l=s.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let c=0,h=0;if(o){const f=this._findPreviousFilterOffset();c=f.x,h=f.y}this._updateFilterUniforms(e,i,a,c,h,u,o,n);const p=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(p,e,s)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,n=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),s=e.worldTransform.copyTo(U.shared),a=e.renderGroup||e.parentRenderGroup;return a&&a.cacheToLocalTransform&&s.prepend(a.cacheToLocalTransform),s.invert(),n.prepend(s),n.scale(1/e.texture.orig.width,1/e.texture.orig.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new df),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const n=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(n,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:dw,shader:t,state:t._state,topology:"triangle-list"}),i.type===It.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=D.EMPTY,t.inputTexture=vt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const s=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(s,e,n==null?void 0:n.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,n,s,a){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=s*n,o.height=a*n}_updateFilterUniforms(t,e,i,n,s,a,o,l){const u=this._filterGlobalUniforms.uniforms,c=u.uOutputFrame,h=u.uInputSize,p=u.uInputPixel,f=u.uInputClamp,m=u.uGlobalFrame,g=u.uOutputTexture;o?(c[0]=i.bounds.minX-n,c[1]=i.bounds.minY-s):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,h[0]=t.source.width,h[1]=t.source.height,h[2]=1/h[0],h[3]=1/h[1],p[0]=t.source.pixelWidth,p[1]=t.source.pixelHeight,p[2]=1/p[0],p[3]=1/p[1],f[0]=.5*p[2],f[1]=.5*p[3],f[2]=t.frame.width*h[2]-.5*p[2],f[3]=t.frame.height*h[3]-.5*p[3];const _=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=n*a,m[1]=s*a,m[2]=_.source.width*a,m[3]=_.source.height*a,e instanceof D&&(e.source.resource=null);const y=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof D?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=y.width,g[1]=y.height),g[2]=y.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 n=this._filterStack[i];if(!n.skip){t=n.bounds.minX,e=n.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?lo(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,n=t.bounds,s=t.filters,a=t.firstEnabledIndex,o=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),a===o)s[a].apply(this,i,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=vt.getOptimalTexture(n.width,n.height,l.source._resolution,!1);let c=u;for(let h=a;h0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new pw),this._filterStackIndex++,t}}Ao.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"},X.add(Ao,co),X.add(ho);var fw={__proto__:null};const Co=[];X.handleByNamedList(S.Environment,Co);async function Mo(r){if(!r)for(let t=0;t80*e){o=r[0],l=r[1];let c=o,h=l;for(let p=e;pc&&(c=f),m>h&&(h=m)}u=Math.max(c-o,h-l),u=u!==0?32767/u:0}return xi(s,a,e,o,l,u,0),a}function mf(r,t,e,i,n){let s;if(n===Io(r,t,e,i)>0)for(let a=t;a=t;a-=i)s=bf(a/i|0,r[a],r[a+1],s);return s&&Cr(s,s.next)&&(wi(s),s=s.next),s}function sr(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(Cr(e,e.next)||xt(e.prev,e,e.next)===0)){if(wi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function xi(r,t,e,i,n,s,a){if(!r)return;!a&&s&&Pw(r,i,n,s);let o=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(s?_w(r,i,n,s):gw(r)){t.push(l.i,r.i,u.i),wi(r),r=u.next,o=u.next;continue}if(r=u,r===o){a?a===1?(r=yw(sr(r),t),xi(r,t,e,i,n,s,2)):a===2&&bw(r,t,e,i,n,s):xi(sr(r),t,e,i,n,s,1);break}}}function gw(r){const t=r.prev,e=r,i=r.next;if(xt(t,e,i)>=0)return!1;const n=t.x,s=e.x,a=i.x,o=t.y,l=e.y,u=i.y,c=Math.min(n,s,a),h=Math.min(o,l,u),p=Math.max(n,s,a),f=Math.max(o,l,u);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=f&&Ti(n,o,s,l,a,u,m.x,m.y)&&xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function _w(r,t,e,i){const n=r.prev,s=r,a=r.next;if(xt(n,s,a)>=0)return!1;const o=n.x,l=s.x,u=a.x,c=n.y,h=s.y,p=a.y,f=Math.min(o,l,u),m=Math.min(c,h,p),g=Math.max(o,l,u),_=Math.max(c,h,p),y=Oo(f,m,t,e,i),b=Oo(g,_,t,e,i);let x=r.prevZ,v=r.nextZ;for(;x&&x.z>=y&&v&&v.z<=b;){if(x.x>=f&&x.x<=g&&x.y>=m&&x.y<=_&&x!==n&&x!==a&&Ti(o,c,l,h,u,p,x.x,x.y)&&xt(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=f&&v.x<=g&&v.y>=m&&v.y<=_&&v!==n&&v!==a&&Ti(o,c,l,h,u,p,v.x,v.y)&&xt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=g&&x.y>=m&&x.y<=_&&x!==n&&x!==a&&Ti(o,c,l,h,u,p,x.x,x.y)&&xt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=b;){if(v.x>=f&&v.x<=g&&v.y>=m&&v.y<=_&&v!==n&&v!==a&&Ti(o,c,l,h,u,p,v.x,v.y)&&xt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function yw(r,t){let e=r;do{const i=e.prev,n=e.next.next;!Cr(i,n)&&_f(i,e,e.next,n)&&Si(i,n)&&Si(n,i)&&(t.push(i.i,e.i,n.i),wi(e),wi(e.next),e=r=n),e=e.next}while(e!==r);return sr(e)}function bw(r,t,e,i,n,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Cw(a,o)){let l=yf(a,o);a=sr(a,a.next),l=sr(l,l.next),xi(a,t,e,i,n,s,0),xi(l,t,e,i,n,s,0);return}o=o.next}a=a.next}while(a!==r)}function vw(r,t,e,i){const n=[];for(let s=0,a=t.length;s=e.next.y&&e.next.y!==e.y){const h=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=i&&h>s&&(s=h,a=e.x=e.x&&e.x>=l&&i!==e.x&&gf(na.x||e.x===a.x&&ww(a,e)))&&(a=e,c=h)}e=e.next}while(e!==o);return a}function ww(r,t){return xt(r.prev,r,t.prev)<0&&xt(t.next,r,r.next)<0}function Pw(r,t,e,i){let n=r;do n.z===0&&(n.z=Oo(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,Ew(n)}function Ew(r){let t,e=1;do{let i=r,n;r=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let u=0;u0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;i=a}s.nextZ=null,e*=2}while(t>1);return r}function Oo(r,t,e,i,n){return r=(r-e)*n|0,t=(t-i)*n|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Aw(r){let t=r,e=r;do(t.x=(r-a)*(s-o)&&(r-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(s-o)>=(n-a)*(i-o)}function Ti(r,t,e,i,n,s,a,o){return!(r===a&&t===o)&&gf(r,t,e,i,n,s,a,o)}function Cw(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Mw(r,t)&&(Si(r,t)&&Si(t,r)&&Rw(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Cr(r,t)&&xt(r.prev,r,r.next)>0&&xt(t.prev,t,t.next)>0)}function xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Cr(r,t){return r.x===t.x&&r.y===t.y}function _f(r,t,e,i){const n=Bn(xt(r,t,e)),s=Bn(xt(r,t,i)),a=Bn(xt(e,i,r)),o=Bn(xt(e,i,t));return!!(n!==s&&a!==o||n===0&&In(r,e,t)||s===0&&In(r,i,t)||a===0&&In(e,r,i)||o===0&&In(e,t,i))}function In(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Bn(r){return r>0?1:r<0?-1:0}function Mw(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&_f(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Si(r,t){return xt(r.prev,r,r.next)<0?xt(r,t,r.next)>=0&&xt(r,r.prev,t)>=0:xt(r,t,r.prev)<0||xt(r,r.next,t)<0}function Rw(r,t){let e=r,i=!1;const n=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function yf(r,t){const e=Go(r.i,r.x,r.y),i=Go(t.i,t.x,t.y),n=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function bf(r,t,e,i){const n=Go(r,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function wi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Go(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function kB(r,t,e,i){const n=t&&t.length,s=n?t[0]*e:r.length;let a=Math.abs(Io(r,0,s,e));if(n)for(let l=0,u=t.length;l(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Kt||{});class Bo{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,s,a,o,l){const{name:u,items:c}=this;for(let h=0,p=c.length;ht in r?Ow(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Fn=(r,t)=>{for(var e in t||(t={}))Gw.call(t,e)&&Tf(r,e,t[e]);if(xf)for(var e of xf(t))Iw.call(t,e)&&Tf(r,e,t[e]);return r};const Bw=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],Sf=class G1 extends Nt{constructor(t){var e;super(),this.tick=0,this.uid=ht("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=[...Bw,...(e=this.config.runners)!=null?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Mo(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){const n=this._systemsHash[i].constructor.defaultOptions;t=Fn(Fn({},n),t)}t=Fn(Fn({},G1.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let i=0;i{this.runners[e]=new Bo(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((n,s)=>(n[s.name]=s.value,n),{});t.forEach(n=>{const s=n.value,a=n.name,o=i[a];this.renderPipes[a]=new s(this,o?new o:null),this.runners.destroy.add(this.renderPipes[a])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&qe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Ro())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()}};Sf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Mr=Sf,Fo;function Pi(r){return Fo!==void 0||(Fo=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Mr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!H.get().getWebGLRenderingContext())return!1;let i=H.get().createCanvas().getContext("webgl",e);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,n}catch(i){return!1}})()),Fo}let Do;async function Ei(r={}){return Do!==void 0||(Do=await(async()=>{const t=H.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),Do}var Fw=Object.defineProperty,wf=Object.getOwnPropertySymbols,Dw=Object.prototype.hasOwnProperty,Uw=Object.prototype.propertyIsEnumerable,Pf=(r,t,e)=>t in r?Fw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rr=(r,t)=>{for(var e in t||(t={}))Dw.call(t,e)&&Pf(r,e,t[e]);if(wf)for(var e of wf(t))Uw.call(t,e)&&Pf(r,e,t[e]);return r};const Ef=["webgl","webgpu","canvas"];async function Af(r){var t;let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Ef.forEach(a=>{a!==r.preference&&e.push(a)})):e=Ef.slice();let i,n={};for(let a=0;a{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:s}=this._resizeTo;e=n,i=s}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}ko.extension=S.Application;class Lo{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Te.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ot.shared:new Ot,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}Lo.extension=S.Application,X.add(ko),X.add(Lo);var kw=Object.defineProperty,Cf=Object.getOwnPropertySymbols,Lw=Object.prototype.hasOwnProperty,Nw=Object.prototype.propertyIsEnumerable,Mf=(r,t,e)=>t in r?kw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xw=(r,t)=>{for(var e in t||(t={}))Lw.call(t,e)&&Mf(r,e,t[e]);if(Cf)for(var e of Cf(t))Nw.call(t,e)&&Mf(r,e,t[e]);return r};const Rf=class wh{constructor(...t){this.stage=new dt}async init(t){t=Xw({},t),this.stage||(this.stage=new dt),this.renderer=await Af(t),wh._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const i=wh._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Rf._plugins=[];let Of=Rf;X.handleByList(S.Application,Of._plugins),X.add(Uo);const Dn={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,i;const n=r.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in n){const g=n[m].match(/^[a-z]+/gm)[0],_=n[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),y={};for(const b in _){const x=_[b].split("="),v=x[0],w=x[1].replace(/"/gm,""),T=parseFloat(w),P=isNaN(T)?w:T;y[v]=P}s[g].push(y)}const a={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[o]=s.info,[l]=s.common,[u]=(t=s.distanceField)!=null?t:[];u&&(a.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),a.fontSize=parseInt(o.size,10),a.fontFamily=o.face,a.lineHeight=parseInt(l.lineHeight,10);const c=s.page;for(let m=0;m)/)?No.test(H.get().parseXML(r)):!1},parse(r){return No.parse(H.get().parseXML(r))}},jw=[".xml",".fnt"],Gf={extension:{type:S.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string"&&r.fontFamily!=="",getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},If={extension:{type:S.LoadParser,priority:te.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return jw.includes(zt.extname(r).toLowerCase())},async testParse(r){return Dn.test(r)||Xo.test(r)},async parse(r,t,e){const i=Dn.test(r)?Dn.parse(r):Xo.parse(r),{src:n}=t,{pages:s}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let h=0;hl[h.src]);return new u({data:i,textures:c},n)},async load(r,t){return await(await H.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Bf{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;iArray.isArray(r)&&r.every(t=>t instanceof D),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((n,s)=>{e[i+(s===0?"":s+1)]=n})}),e}};async function jo(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}const Df={extension:{type:S.DetectionParser,priority:1},test:async()=>jo("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},Uf=["png","jpg","jpeg"],$f={extension:{type:S.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...Uf],remove:async r=>r.filter(t=>!Uf.includes(t))},Hw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ci(r){return Hw?!1:document.createElement("video").canPlayType(r)!==""}const kf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},Lf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Nf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},Xf={extension:{type:S.DetectionParser,priority:0},test:async()=>jo("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var zw=Object.defineProperty,Ww=Object.defineProperties,Vw=Object.getOwnPropertyDescriptors,jf=Object.getOwnPropertySymbols,Yw=Object.prototype.hasOwnProperty,Kw=Object.prototype.propertyIsEnumerable,Hf=(r,t,e)=>t in r?zw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Or=(r,t)=>{for(var e in t||(t={}))Yw.call(t,e)&&Hf(r,e,t[e]);if(jf)for(var e of jf(t))Kw.call(t,e)&&Hf(r,e,t[e]);return r},qw=(r,t)=>Ww(r,Vw(t));const zf=class va{constructor(){this.loadOptions=Or({},va.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()=>{var n,s;let a=null,o=null;if((e.parser||e.loadParser)&&(o=this._parserHash[e.parser||e.loadParser]),!o){for(let l=0;l({alias:[g],src:g,data:{}})),f=p.reduce((g,_)=>g+(_.progressSize||1),0),m=p.map(async g=>{const _=zt.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(_,g,{onProgress:n,onError:s,strategy:a,retryCount:o,retryDelay:l},c),u+=g.progressSize||1,n&&n(u/f))});return await Promise.all(m),h?c[p[0].src]:c}async unload(t){const e=oe(t,i=>({alias:[i],src:i})).map(async i=>{var n,s;const a=zt.toAbsolute(i.src),o=this.promiseCache[a];if(o){const l=await o.promise;delete this.promiseCache[a],await((s=(n=o.parser)==null?void 0:n.unload)==null?void 0:s.call(n,l,i,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],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,n){let s=0;const{onError:a,strategy:o,retryCount:l,retryDelay:u}=i,c=h=>new Promise(p=>setTimeout(p,h));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),n[e.src]=await this.promiseCache[t].promise;return}catch(h){delete this.promiseCache[t],delete n[e.src],s++;const p=o!=="retry"||s>l;if(o==="retry"&&!p){a&&a(h,e),await c(u);continue}if(o==="skip"){a&&a(h,e);return}a&&a(h,e);const f=new Error(`[Loader.load] Failed to load ${t}. -${h}`);throw h instanceof Error&&h.stack&&(f.stack=h.stack),f}}};zf.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let Wf=zf;function ar(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function le(r,t){const e=r.split("?")[0],i=zt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const Zw=".json",Qw="application/json",Vf={extension:{type:S.LoadParser,priority:te.Low},name:"loadJson",id:"json",test(r){return ar(r,Qw)||le(r,Zw)},async load(r){return await(await H.get().fetch(r)).json()}},Jw=".txt",tP="text/plain",Yf={name:"loadTxt",id:"text",extension:{type:S.LoadParser,priority:te.Low,name:"loadTxt"},test(r){return ar(r,tP)||le(r,Jw)},async load(r){return await(await H.get().fetch(r)).text()}};var eP=Object.defineProperty,rP=Object.defineProperties,iP=Object.getOwnPropertyDescriptors,Kf=Object.getOwnPropertySymbols,nP=Object.prototype.hasOwnProperty,sP=Object.prototype.propertyIsEnumerable,qf=(r,t,e)=>t in r?eP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aP=(r,t)=>{for(var e in t||(t={}))nP.call(t,e)&&qf(r,e,t[e]);if(Kf)for(var e of Kf(t))sP.call(t,e)&&qf(r,e,t[e]);return r},oP=(r,t)=>rP(r,iP(t));const lP=["normal","bold","100","200","300","400","500","600","700","800","900"],uP=[".ttf",".otf",".woff",".woff2"],cP=["font/ttf","font/otf","font/woff","font/woff2"],hP=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Zf(r){const t=zt.extname(r),e=zt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=e.length>0;for(const s of e)if(!s.match(hP)){i=!1;break}let n=e.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const dP=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function pP(r){return dP.test(r)?r:encodeURI(r)}const Qf={extension:{type:S.LoadParser,priority:te.Low},name:"loadWebFont",id:"web-font",test(r){return ar(r,cP)||le(r,uP)},async load(r,t){var e,i,n,s,a,o;const l=H.get().getFontFaceSet();if(l){const u=[],c=(i=(e=t.data)==null?void 0:e.family)!=null?i:Zf(r),h=(a=(s=(n=t.data)==null?void 0:n.weights)==null?void 0:s.filter(f=>lP.includes(f)))!=null?a:["normal"],p=(o=t.data)!=null?o:{};for(let f=0;fs.faces.some(a=>t.indexOf(a)!==-1));n.faces=n.faces.filter(s=>t.indexOf(s)===-1),n.faces.length===0&&(i.entries=i.entries.filter(s=>s!==n)),t.forEach(s=>{H.get().getFontFaceSet().delete(s)}),i.entries.length===0&&it.remove(`${e}-and-url`)}};var Ho,Jf;function fP(){if(Jf)return Ho;Jf=1,Ho=e;var r={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},t=/([astvzqmhlc])([^astvzqmhlc]*)/ig;function e(s){var a=[];return s.replace(t,function(o,l,u){var c=l.toLowerCase();for(u=n(u),c=="m"&&u.length>2&&(a.push([l].concat(u.splice(0,2))),c="l",l=l=="m"?"l":"L");;){if(u.length==r[c])return u.unshift(l),a.push(u);if(u.length0&&(n=i.pop(),n?(s=n.startX,a=n.startY):(s=0,a=0)),n=null;break;default:}u!=="Z"&&u!=="z"&&n===null&&(n={startX:s,startY:a},i.push(n))}return t}const em={};function Un(r,t,e){let i=2166136261;for(let n=0;n>>=0;return em[i]||_P(r,t,i,e)}function _P(r,t,e,i){const n={};let s=0;for(let o=0;o{if(Gr.quiet||rm.has(t))return;let i=new Error().stack;const n=`${t} +`;class pf extends Pe{constructor(){const t=Xt.from({vertex:{source:Po,entryPoint:"mainVertex"},fragment:{source:Po,entryPoint:"mainFragment"},name:"passthrough-filter"}),e=Wt.from({vertex:bi,fragment:df,name:"passthrough-filter"});super({gpuProgram:t,glProgram:e})}}var at=(r=>(r[r.MAP_READ=1]="MAP_READ",r[r.MAP_WRITE=2]="MAP_WRITE",r[r.COPY_SRC=4]="COPY_SRC",r[r.COPY_DST=8]="COPY_DST",r[r.INDEX=16]="INDEX",r[r.VERTEX=32]="VERTEX",r[r.UNIFORM=64]="UNIFORM",r[r.STORAGE=128]="STORAGE",r[r.INDIRECT=256]="INDIRECT",r[r.QUERY_RESOLVE=512]="QUERY_RESOLVE",r[r.STATIC=1024]="STATIC",r))(at||{});class Yt extends Nt{constructor(t){let{data:e,size:i}=t;const{usage:n,label:s,shrinkToFit:a}=t;super(),this._gpuData=Object.create(null),this._gcLastUsed=-1,this.autoGarbageCollect=!0,this.uid=ht("buffer"),this._resourceType="buffer",this._resourceId=ht("resource"),this._touched=0,this._updateID=1,this._dataInt32=null,this.shrinkToFit=!0,this.destroyed=!1,e instanceof Array&&(e=new Float32Array(e)),this._data=e,i!=null||(i=e==null?void 0:e.byteLength);const o=!!e;this.descriptor={size:i,usage:n,mappedAtCreation:o,label:s},this.shrinkToFit=a!=null?a:!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&at.STATIC)}set static(t){t?this.descriptor.usage|=at.STATIC:this.descriptor.usage&=~at.STATIC}setDataWithSize(t,e,i){if(this._updateID++,this._updateSize=e*t.BYTES_PER_ELEMENT,this._data===t){i&&this.emit("update",this);return}const n=this._data;if(this._data=t,this._dataInt32=null,!n||n.length!==t.length){!this.shrinkToFit&&n&&t.byteLengtho&&(o=f),m>l&&(l=m),fi.destroy()),this.unload(),(e=this.indexBuffer)==null||e.destroy(),this.attributes=null,this.buffers=null,this.indexBuffer=null,this._bounds=null}}const _w=new nr({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])});let yw=class{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new Mt,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 Co{constructor(t){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new At({uInputSize:{value:new Float32Array(4),type:"vec4"},uInputPixel:{value:new Float32Array(4),type:"vec4"},uInputClamp:{value:new Float32Array(4),type:"vec4"},uOutputFrame:{value:new Float32Array(4),type:"vec4"},uGlobalFrame:{value:new Float32Array(4),type:"vec4"},uOutputTexture:{value:new Float32Array(4),type:"vec4"}}),this._globalFilterBindGroup=new Ee({}),this.renderer=t}get activeBackTexture(){var t;return(t=this._activeFilterData)==null?void 0:t.backTexture}push(t){const e=this.renderer,i=t.filterEffect.filters,n=this._pushFilterData();n.skip=!1,n.filters=i,n.container=t.container,n.outputRenderSurface=e.renderTarget.renderSurface;const s=e.renderTarget.renderTarget.colorTexture.source,a=s.resolution,o=s.antialias;if(i.every(f=>!f.enabled)){n.skip=!0;return}const l=n.bounds;if(this._calculateFilterArea(t,l),this._calculateFilterBounds(n,e.renderTarget.rootViewPort,o,a,1),n.skip)return;const u=this._getPreviousFilterData(),c=this._findFilterResolution(a);let h=0,p=0;u&&(h=u.bounds.minX,p=u.bounds.minY),this._calculateGlobalFrame(n,h,p,c,s.width,s.height),this._setupFilterTextures(n,l,e,u)}generateFilteredTexture({texture:t,filters:e}){const i=this._pushFilterData();this._activeFilterData=i,i.skip=!1,i.filters=e;const n=t.source,s=n.resolution,a=n.antialias;if(e.every(c=>!c.enabled))return i.skip=!0,t;const o=i.bounds;if(o.addRect(t.frame),this._calculateFilterBounds(i,o.rectangle,a,s,0),i.skip)return t;const l=s;this._calculateGlobalFrame(i,0,0,l,n.width,n.height),i.outputRenderSurface=vt.getOptimalTexture(o.width,o.height,i.resolution,i.antialias),i.backTexture=D.EMPTY,i.inputTexture=t,this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(i,!0);const u=i.outputRenderSurface;return u.source.alphaMode="premultiplied-alpha",u}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&&vt.returnTexture(e.backTexture),vt.returnTexture(e.inputTexture))}getBackTexture(t,e,i){const n=t.colorTexture.source._resolution,s=vt.getOptimalTexture(e.width,e.height,n,!1);let a=e.minX,o=e.minY;i&&(a-=i.minX,o-=i.minY),a=Math.floor(a*n),o=Math.floor(o*n);const l=Math.ceil(e.width*n),u=Math.ceil(e.height*n);return this.renderer.renderTarget.copyToTexture(t,s,{x:a,y:o},{width:l,height:u},{x:0,y:0}),s}applyFilter(t,e,i,n){const s=this.renderer,a=this._activeFilterData,o=a.outputRenderSurface===i,l=s.renderTarget.rootRenderTarget.colorTexture.source._resolution,u=this._findFilterResolution(l);let c=0,h=0;if(o){const f=this._findPreviousFilterOffset();c=f.x,h=f.y}this._updateFilterUniforms(e,i,a,c,h,u,o,n);const p=t.enabled?t:this._getPassthroughFilter();this._setupBindGroupsAndRender(p,e,s)}calculateSpriteMatrix(t,e){const i=this._activeFilterData,n=t.set(i.inputTexture._source.width,0,0,i.inputTexture._source.height,i.bounds.minX,i.bounds.minY),s=e.worldTransform.copyTo(U.shared),a=e.renderGroup||e.parentRenderGroup;return a&&a.cacheToLocalTransform&&s.prepend(a.cacheToLocalTransform),s.invert(),n.prepend(s),n.scale(1/e.texture.orig.width,1/e.texture.orig.height),n.translate(e.anchor.x,e.anchor.y),n}destroy(){var t;(t=this._passthroughFilter)==null||t.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){var t;return(t=this._passthroughFilter)!=null||(this._passthroughFilter=new pf),this._passthroughFilter}_setupBindGroupsAndRender(t,e,i){if(i.renderPipes.uniformBatch){const n=i.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(n,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:_w,shader:t,state:t._state,topology:"triangle-list"}),i.type===It.WEBGL&&i.renderTarget.finishRenderPass()}_setupFilterTextures(t,e,i,n){if(t.backTexture=D.EMPTY,t.inputTexture=vt.getOptimalTexture(e.width,e.height,t.resolution,t.antialias),t.blendRequired){i.renderTarget.finishRenderPass();const s=i.renderTarget.getRenderTarget(t.outputRenderSurface);t.backTexture=this.getBackTexture(s,e,n==null?void 0:n.bounds)}i.renderTarget.bind(t.inputTexture,!0),i.globalUniforms.push({offset:e})}_calculateGlobalFrame(t,e,i,n,s,a){const o=t.globalFrame;o.x=e*n,o.y=i*n,o.width=s*n,o.height=a*n}_updateFilterUniforms(t,e,i,n,s,a,o,l){const u=this._filterGlobalUniforms.uniforms,c=u.uOutputFrame,h=u.uInputSize,p=u.uInputPixel,f=u.uInputClamp,m=u.uGlobalFrame,g=u.uOutputTexture;o?(c[0]=i.bounds.minX-n,c[1]=i.bounds.minY-s):(c[0]=0,c[1]=0),c[2]=t.frame.width,c[3]=t.frame.height,h[0]=t.source.width,h[1]=t.source.height,h[2]=1/h[0],h[3]=1/h[1],p[0]=t.source.pixelWidth,p[1]=t.source.pixelHeight,p[2]=1/p[0],p[3]=1/p[1],f[0]=.5*p[2],f[1]=.5*p[3],f[2]=t.frame.width*h[2]-.5*p[2],f[3]=t.frame.height*h[3]-.5*p[3];const _=this.renderer.renderTarget.rootRenderTarget.colorTexture;m[0]=n*a,m[1]=s*a,m[2]=_.source.width*a,m[3]=_.source.height*a,e instanceof D&&(e.source.resource=null);const y=this.renderer.renderTarget.getRenderTarget(e);this.renderer.renderTarget.bind(e,!!l),e instanceof D?(g[0]=e.frame.width,g[1]=e.frame.height):(g[0]=y.width,g[1]=y.height),g[2]=y.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 n=this._filterStack[i];if(!n.skip){t=n.bounds.minX,e=n.bounds.minY;break}}return{x:t,y:e}}_calculateFilterArea(t,e){if(t.renderables?uo(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,n=t.bounds,s=t.filters,a=t.firstEnabledIndex,o=t.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(i.source.style,2),this._globalFilterBindGroup.setResource(t.backTexture.source,3),a===o)s[a].apply(this,i,t.outputRenderSurface,e);else{let l=t.inputTexture;const u=vt.getOptimalTexture(n.width,n.height,l.source._resolution,!1);let c=u;for(let h=a;h0&&(e--,t=this._filterStack[e],!!t.skip););return t}_pushFilterData(){let t=this._filterStack[this._filterStackIndex];return t||(t=this._filterStack[this._filterStackIndex]=new yw),this._filterStackIndex++,t}}Co.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"filter"},N.add(Co,ho),N.add(po);var bw={__proto__:null};const Mo=[];N.handleByNamedList(S.Environment,Mo);async function Ro(r){if(!r)for(let t=0;t80*e){o=r[0],l=r[1];let c=o,h=l;for(let p=e;pc&&(c=f),m>h&&(h=m)}u=Math.max(c-o,h-l),u=u!==0?32767/u:0}return xi(s,a,e,o,l,u,0),a}function gf(r,t,e,i,n){let s;if(n===Bo(r,t,e,i)>0)for(let a=t;a=t;a-=i)s=vf(a/i|0,r[a],r[a+1],s);return s&&Cr(s,s.next)&&(wi(s),s=s.next),s}function sr(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(Cr(e,e.next)||xt(e.prev,e,e.next)===0)){if(wi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function xi(r,t,e,i,n,s,a){if(!r)return;!a&&s&&Rw(r,i,n,s);let o=r;for(;r.prev!==r.next;){const l=r.prev,u=r.next;if(s?Tw(r,i,n,s):xw(r)){t.push(l.i,r.i,u.i),wi(r),r=u.next,o=u.next;continue}if(r=u,r===o){a?a===1?(r=Sw(sr(r),t),xi(r,t,e,i,n,s,2)):a===2&&ww(r,t,e,i,n,s):xi(sr(r),t,e,i,n,s,1);break}}}function xw(r){const t=r.prev,e=r,i=r.next;if(xt(t,e,i)>=0)return!1;const n=t.x,s=e.x,a=i.x,o=t.y,l=e.y,u=i.y,c=Math.min(n,s,a),h=Math.min(o,l,u),p=Math.max(n,s,a),f=Math.max(o,l,u);let m=i.next;for(;m!==t;){if(m.x>=c&&m.x<=p&&m.y>=h&&m.y<=f&&Ti(n,o,s,l,a,u,m.x,m.y)&&xt(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Tw(r,t,e,i){const n=r.prev,s=r,a=r.next;if(xt(n,s,a)>=0)return!1;const o=n.x,l=s.x,u=a.x,c=n.y,h=s.y,p=a.y,f=Math.min(o,l,u),m=Math.min(c,h,p),g=Math.max(o,l,u),_=Math.max(c,h,p),y=Go(f,m,t,e,i),b=Go(g,_,t,e,i);let x=r.prevZ,v=r.nextZ;for(;x&&x.z>=y&&v&&v.z<=b;){if(x.x>=f&&x.x<=g&&x.y>=m&&x.y<=_&&x!==n&&x!==a&&Ti(o,c,l,h,u,p,x.x,x.y)&&xt(x.prev,x,x.next)>=0||(x=x.prevZ,v.x>=f&&v.x<=g&&v.y>=m&&v.y<=_&&v!==n&&v!==a&&Ti(o,c,l,h,u,p,v.x,v.y)&&xt(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;x&&x.z>=y;){if(x.x>=f&&x.x<=g&&x.y>=m&&x.y<=_&&x!==n&&x!==a&&Ti(o,c,l,h,u,p,x.x,x.y)&&xt(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;v&&v.z<=b;){if(v.x>=f&&v.x<=g&&v.y>=m&&v.y<=_&&v!==n&&v!==a&&Ti(o,c,l,h,u,p,v.x,v.y)&&xt(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Sw(r,t){let e=r;do{const i=e.prev,n=e.next.next;!Cr(i,n)&&yf(i,e,e.next,n)&&Si(i,n)&&Si(n,i)&&(t.push(i.i,e.i,n.i),wi(e),wi(e.next),e=r=n),e=e.next}while(e!==r);return sr(e)}function ww(r,t,e,i,n,s){let a=r;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Iw(a,o)){let l=bf(a,o);a=sr(a,a.next),l=sr(l,l.next),xi(a,t,e,i,n,s,0),xi(l,t,e,i,n,s,0);return}o=o.next}a=a.next}while(a!==r)}function Ew(r,t,e,i){const n=[];for(let s=0,a=t.length;s=e.next.y&&e.next.y!==e.y){const h=e.x+(n-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=i&&h>s&&(s=h,a=e.x=e.x&&e.x>=l&&i!==e.x&&_f(na.x||e.x===a.x&&Mw(a,e)))&&(a=e,c=h)}e=e.next}while(e!==o);return a}function Mw(r,t){return xt(r.prev,r,t.prev)<0&&xt(t.next,r,r.next)<0}function Rw(r,t,e,i){let n=r;do n.z===0&&(n.z=Go(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,Ow(n)}function Ow(r){let t,e=1;do{let i=r,n;r=null;let s=null;for(t=0;i;){t++;let a=i,o=0;for(let u=0;u0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(n=i,i=i.nextZ,o--):(n=a,a=a.nextZ,l--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;i=a}s.nextZ=null,e*=2}while(t>1);return r}function Go(r,t,e,i,n){return r=(r-e)*n|0,t=(t-i)*n|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Gw(r){let t=r,e=r;do(t.x=(r-a)*(s-o)&&(r-a)*(i-o)>=(e-a)*(t-o)&&(e-a)*(s-o)>=(n-a)*(i-o)}function Ti(r,t,e,i,n,s,a,o){return!(r===a&&t===o)&&_f(r,t,e,i,n,s,a,o)}function Iw(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Bw(r,t)&&(Si(r,t)&&Si(t,r)&&Fw(r,t)&&(xt(r.prev,r,t.prev)||xt(r,t.prev,t))||Cr(r,t)&&xt(r.prev,r,r.next)>0&&xt(t.prev,t,t.next)>0)}function xt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function Cr(r,t){return r.x===t.x&&r.y===t.y}function yf(r,t,e,i){const n=Dn(xt(r,t,e)),s=Dn(xt(r,t,i)),a=Dn(xt(e,i,r)),o=Dn(xt(e,i,t));return!!(n!==s&&a!==o||n===0&&Fn(r,e,t)||s===0&&Fn(r,i,t)||a===0&&Fn(e,r,i)||o===0&&Fn(e,t,i))}function Fn(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function Dn(r){return r>0?1:r<0?-1:0}function Bw(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&yf(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Si(r,t){return xt(r.prev,r,r.next)<0?xt(r,t,r.next)>=0&&xt(r,r.prev,t)>=0:xt(r,t,r.prev)<0||xt(r,r.next,t)<0}function Fw(r,t){let e=r,i=!1;const n=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function bf(r,t){const e=Io(r.i,r.x,r.y),i=Io(t.i,t.x,t.y),n=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function vf(r,t,e,i){const n=Io(r,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function wi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function Io(r,t,e){return{i:r,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function HB(r,t,e,i){const n=t&&t.length,s=n?t[0]*e:r.length;let a=Math.abs(Bo(r,0,s,e));if(n)for(let l=0,u=t.length;l(r[r.NONE=0]="NONE",r[r.COLOR=16384]="COLOR",r[r.STENCIL=1024]="STENCIL",r[r.DEPTH=256]="DEPTH",r[r.COLOR_DEPTH=16640]="COLOR_DEPTH",r[r.COLOR_STENCIL=17408]="COLOR_STENCIL",r[r.DEPTH_STENCIL=1280]="DEPTH_STENCIL",r[r.ALL=17664]="ALL",r))(Kt||{});class Fo{constructor(t){this.items=[],this._name=t}emit(t,e,i,n,s,a,o,l){const{name:u,items:c}=this;for(let h=0,p=c.length;ht in r?Dw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Un=(r,t)=>{for(var e in t||(t={}))Uw.call(t,e)&&Sf(r,e,t[e]);if(Tf)for(var e of Tf(t))$w.call(t,e)&&Sf(r,e,t[e]);return r};const kw=["init","destroy","contextChange","resolutionChange","resetState","renderEnd","renderStart","render","update","postrender","prerender"],wf=class B1 extends Nt{constructor(t){var e;super(),this.tick=0,this.uid=ht("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=[...kw,...(e=this.config.runners)!=null?e:[]];this._addRunners(...i),this._unsafeEvalCheck()}async init(t={}){const e=t.skipExtensionImports===!0?!0:t.manageImports===!1;await Ro(e),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(const i in this._systemsHash){const n=this._systemsHash[i].constructor.defaultOptions;t=Un(Un({},n),t)}t=Un(Un({},B1.defaultOptions),t),this._roundPixels=t.roundPixels?1:0;for(let i=0;i{this.runners[e]=new Fo(e)})}_addSystems(t){let e;for(e in t){const i=t[e];this._addSystem(i.value,i.name)}}_addSystem(t,e){const i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(const n in this.runners)this.runners[n].add(i);return this}_addPipes(t,e){const i=e.reduce((n,s)=>(n[s.name]=s.value,n),{});t.forEach(n=>{const s=n.value,a=n.name,o=i[a];this.renderPipes[a]=new s(this,o?new o:null),this.runners.destroy.add(this.renderPipes[a])})}destroy(t=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(t),(t===!0||typeof t=="object"&&t.releaseGlobalResources)&&qe.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(t){return this.textureGenerator.generateTexture(t)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!Oo())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()}};wf.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};let Mr=wf,Do;function Ei(r){return Do!==void 0||(Do=(()=>{var t;const e={stencil:!0,failIfMajorPerformanceCaveat:r!=null?r:Mr.defaultOptions.failIfMajorPerformanceCaveat};try{if(!H.get().getWebGLRenderingContext())return!1;let i=H.get().createCanvas().getContext("webgl",e);const n=!!((t=i==null?void 0:i.getContextAttributes())!=null&&t.stencil);if(i){const s=i.getExtension("WEBGL_lose_context");s&&s.loseContext()}return i=null,n}catch(i){return!1}})()),Do}let Uo;async function Pi(r={}){return Uo!==void 0||(Uo=await(async()=>{const t=H.get().getNavigator().gpu;if(!t)return!1;try{return await(await t.requestAdapter(r)).requestDevice(),!0}catch(e){return!1}})()),Uo}var Lw=Object.defineProperty,Ef=Object.getOwnPropertySymbols,Nw=Object.prototype.hasOwnProperty,Xw=Object.prototype.propertyIsEnumerable,Pf=(r,t,e)=>t in r?Lw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Rr=(r,t)=>{for(var e in t||(t={}))Nw.call(t,e)&&Pf(r,e,t[e]);if(Ef)for(var e of Ef(t))Xw.call(t,e)&&Pf(r,e,t[e]);return r};const Af=["webgl","webgpu","canvas"];async function Cf(r){var t;let e=[];r.preference?Array.isArray(r.preference)?e=r.preference.slice():(e.push(r.preference),Af.forEach(a=>{a!==r.preference&&e.push(a)})):e=Af.slice();let i,n={};for(let a=0;a{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize()))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,i;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,i=globalThis.innerHeight;else{const{clientWidth:n,clientHeight:s}=this._resizeTo;e=n,i=s}this.renderer.resize(e,i),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=t.resizeTo||null}static destroy(){globalThis.removeEventListener("resize",this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}}Lo.extension=S.Application;class No{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{configurable:!0,set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,Te.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?Ot.shared:new Ot,t.autoStart&&this.start()}static destroy(){if(this._ticker){const t=this._ticker;this.ticker=null,t.destroy()}}}No.extension=S.Application,N.add(Lo),N.add(No);var Hw=Object.defineProperty,Mf=Object.getOwnPropertySymbols,zw=Object.prototype.hasOwnProperty,Ww=Object.prototype.propertyIsEnumerable,Rf=(r,t,e)=>t in r?Hw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vw=(r,t)=>{for(var e in t||(t={}))zw.call(t,e)&&Rf(r,e,t[e]);if(Mf)for(var e of Mf(t))Ww.call(t,e)&&Rf(r,e,t[e]);return r};const Of=class Ph{constructor(...t){this.stage=new dt}async init(t){t=Vw({},t),this.stage||(this.stage=new dt),this.renderer=await Cf(t),Ph._plugins.forEach(e=>{e.init.call(this,t)})}render(){this.renderer.render({container:this.stage})}get canvas(){return this.renderer.canvas}get view(){return this.renderer.canvas}get screen(){return this.renderer.screen}get domContainerRoot(){var t;return(t=this.renderer.renderPipes.dom)==null?void 0:t._domElement}destroy(t=!1,e=!1){const i=Ph._plugins.slice(0);i.reverse(),i.forEach(n=>{n.destroy.call(this)}),this.stage.destroy(e),this.stage=null,this.renderer.destroy(t),this.renderer=null}};Of._plugins=[];let Gf=Of;N.handleByList(S.Application,Gf._plugins),N.add($o);const $n={test(r){return typeof r=="string"&&r.startsWith("info face=")},parse(r){var t,e,i;const n=r.match(/^[a-z]+\s+.+$/gm),s={info:[],common:[],page:[],char:[],chars:[],kerning:[],kernings:[],distanceField:[]};for(const m in n){const g=n[m].match(/^[a-z]+/gm)[0],_=n[m].match(/[a-zA-Z]+=([^\s"']+|"([^"]*)")/gm),y={};for(const b in _){const x=_[b].split("="),v=x[0],w=x[1].replace(/"/gm,""),T=parseFloat(w),E=isNaN(T)?w:T;y[v]=E}s[g].push(y)}const a={chars:{},pages:[],lineHeight:0,fontSize:0,fontFamily:"",distanceField:null,baseLineOffset:0},[o]=s.info,[l]=s.common,[u]=(t=s.distanceField)!=null?t:[];u&&(a.distanceField={range:parseInt(u.distanceRange,10),type:u.fieldType}),a.fontSize=parseInt(o.size,10),a.fontFamily=o.face,a.lineHeight=parseInt(l.lineHeight,10);const c=s.page;for(let m=0;m)/)?Xo.test(H.get().parseXML(r)):!1},parse(r){return Xo.parse(H.get().parseXML(r))}},Yw=[".xml",".fnt"],If={extension:{type:S.CacheParser,name:"cacheBitmapFont"},test:r=>!!(r!=null&&r.pages)&&!!(r!=null&&r.chars)&&typeof(r==null?void 0:r.fontFamily)=="string"&&r.fontFamily!=="",getCacheableAssets(r,t){const e={};return r.forEach(i=>{e[i]=t,e[`${i}-bitmap`]=t}),e[`${t.fontFamily}-bitmap`]=t,e}},Bf={extension:{type:S.LoadParser,priority:te.Normal},name:"loadBitmapFont",id:"bitmap-font",test(r){return Yw.includes(zt.extname(r).toLowerCase())},async testParse(r){return $n.test(r)||jo.test(r)},async parse(r,t,e){const i=$n.test(r)?$n.parse(r):jo.parse(r),{src:n}=t,{pages:s}=i,a=[],o=i.distanceField?{scaleMode:"linear",alphaMode:"premultiply-alpha-on-upload",autoGenerateMipmaps:!1,resolution:1}:{};for(let h=0;hl[h.src]);return new u({data:i,textures:c},n)},async load(r,t){return await(await H.get().fetch(r)).text()},async unload(r,t,e){await Promise.all(r.pages.map(i=>e.unload(i.texture.source._sourceOrigin))),r.destroy()}};class Ff{constructor(t,e=!1){this._loader=t,this._assetList=[],this._isLoading=!1,this._maxConcurrent=1,this.verbose=e}add(t){t.forEach(e=>{this._assetList.push(e)}),this.verbose&&console.log("[BackgroundLoader] assets: ",this._assetList),this._isActive&&!this._isLoading&&this._next()}async _next(){if(this._assetList.length&&this._isActive){this._isLoading=!0;const t=[],e=Math.min(this._assetList.length,this._maxConcurrent);for(let i=0;iArray.isArray(r)&&r.every(t=>t instanceof D),getCacheableAssets:(r,t)=>{const e={};return r.forEach(i=>{t.forEach((n,s)=>{e[i+(s===0?"":s+1)]=n})}),e}};async function Ho(r){if("Image"in globalThis)return new Promise(t=>{const e=new Image;e.onload=()=>{t(!0)},e.onerror=()=>{t(!1)},e.src=r});if("createImageBitmap"in globalThis&&"fetch"in globalThis){try{const t=await(await fetch(r)).blob();await createImageBitmap(t)}catch(t){return!1}return!0}return!1}const Uf={extension:{type:S.DetectionParser,priority:1},test:async()=>Ho("data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAB0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAIAAAACAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQ0MAAAAABNjb2xybmNseAACAAIAAYAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAACVtZGF0EgAKCBgANogQEAwgMg8f8D///8WfhwB8+ErK42A="),add:async r=>[...r,"avif"],remove:async r=>r.filter(t=>t!=="avif")},$f=["png","jpg","jpeg"],kf={extension:{type:S.DetectionParser,priority:-1},test:()=>Promise.resolve(!0),add:async r=>[...r,...$f],remove:async r=>r.filter(t=>!$f.includes(t))},Kw="WorkerGlobalScope"in globalThis&&globalThis instanceof globalThis.WorkerGlobalScope;function Ci(r){return Kw?!1:document.createElement("video").canPlayType(r)!==""}const Lf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/mp4"),add:async r=>[...r,"mp4","m4v"],remove:async r=>r.filter(t=>t!=="mp4"&&t!=="m4v")},Nf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/ogg"),add:async r=>[...r,"ogv"],remove:async r=>r.filter(t=>t!=="ogv")},Xf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ci("video/webm"),add:async r=>[...r,"webm"],remove:async r=>r.filter(t=>t!=="webm")},jf={extension:{type:S.DetectionParser,priority:0},test:async()=>Ho("data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA="),add:async r=>[...r,"webp"],remove:async r=>r.filter(t=>t!=="webp")};var qw=Object.defineProperty,Zw=Object.defineProperties,Qw=Object.getOwnPropertyDescriptors,Hf=Object.getOwnPropertySymbols,Jw=Object.prototype.hasOwnProperty,tE=Object.prototype.propertyIsEnumerable,zf=(r,t,e)=>t in r?qw(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Or=(r,t)=>{for(var e in t||(t={}))Jw.call(t,e)&&zf(r,e,t[e]);if(Hf)for(var e of Hf(t))tE.call(t,e)&&zf(r,e,t[e]);return r},eE=(r,t)=>Zw(r,Qw(t));const Wf=class xa{constructor(){this.loadOptions=Or({},xa.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()=>{var n,s;let a=null,o=null;if((e.parser||e.loadParser)&&(o=this._parserHash[e.parser||e.loadParser]),!o){for(let l=0;l({alias:[g],src:g,data:{}})),f=p.reduce((g,_)=>g+(_.progressSize||1),0),m=p.map(async g=>{const _=zt.toAbsolute(g.src);c[g.src]||(await this._loadAssetWithRetry(_,g,{onProgress:n,onError:s,strategy:a,retryCount:o,retryDelay:l},c),u+=g.progressSize||1,n&&n(u/f))});return await Promise.all(m),h?c[p[0].src]:c}async unload(t){const e=oe(t,i=>({alias:[i],src:i})).map(async i=>{var n,s;const a=zt.toAbsolute(i.src),o=this.promiseCache[a];if(o){const l=await o.promise;delete this.promiseCache[a],await((s=(n=o.parser)==null?void 0:n.unload)==null?void 0:s.call(n,l,i,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],t[e.name]=e,e.id&&(t[e.id]=e),t),{})}async _loadAssetWithRetry(t,e,i,n){let s=0;const{onError:a,strategy:o,retryCount:l,retryDelay:u}=i,c=h=>new Promise(p=>setTimeout(p,h));for(;;)try{this.promiseCache[t]||(this.promiseCache[t]=this._getLoadPromiseAndParser(t,e)),n[e.src]=await this.promiseCache[t].promise;return}catch(h){delete this.promiseCache[t],delete n[e.src],s++;const p=o!=="retry"||s>l;if(o==="retry"&&!p){a&&a(h,e),await c(u);continue}if(o==="skip"){a&&a(h,e);return}a&&a(h,e);const f=new Error(`[Loader.load] Failed to load ${t}. +${h}`);throw h instanceof Error&&h.stack&&(f.stack=h.stack),f}}};Wf.defaultOptions={onProgress:void 0,onError:void 0,strategy:"throw",retryCount:3,retryDelay:250};let Vf=Wf;function ar(r,t){if(Array.isArray(t)){for(const e of t)if(r.startsWith(`data:${e}`))return!0;return!1}return r.startsWith(`data:${t}`)}function le(r,t){const e=r.split("?")[0],i=zt.extname(e).toLowerCase();return Array.isArray(t)?t.includes(i):i===t}const rE=".json",iE="application/json",Yf={extension:{type:S.LoadParser,priority:te.Low},name:"loadJson",id:"json",test(r){return ar(r,iE)||le(r,rE)},async load(r){return await(await H.get().fetch(r)).json()}},nE=".txt",sE="text/plain",Kf={name:"loadTxt",id:"text",extension:{type:S.LoadParser,priority:te.Low,name:"loadTxt"},test(r){return ar(r,sE)||le(r,nE)},async load(r){return await(await H.get().fetch(r)).text()}};var aE=Object.defineProperty,oE=Object.defineProperties,lE=Object.getOwnPropertyDescriptors,qf=Object.getOwnPropertySymbols,uE=Object.prototype.hasOwnProperty,cE=Object.prototype.propertyIsEnumerable,Zf=(r,t,e)=>t in r?aE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hE=(r,t)=>{for(var e in t||(t={}))uE.call(t,e)&&Zf(r,e,t[e]);if(qf)for(var e of qf(t))cE.call(t,e)&&Zf(r,e,t[e]);return r},dE=(r,t)=>oE(r,lE(t));const pE=["normal","bold","100","200","300","400","500","600","700","800","900"],fE=[".ttf",".otf",".woff",".woff2"],mE=["font/ttf","font/otf","font/woff","font/woff2"],gE=/^(--|-?[A-Z_])[0-9A-Z_-]*$/i;function Qf(r){const t=zt.extname(r),e=zt.basename(r,t).replace(/(-|_)/g," ").toLowerCase().split(" ").map(s=>s.charAt(0).toUpperCase()+s.slice(1));let i=e.length>0;for(const s of e)if(!s.match(gE)){i=!1;break}let n=e.join(" ");return i||(n=`"${n.replace(/[\\"]/g,"\\$&")}"`),n}const _E=/^[0-9A-Za-z%:/?#\[\]@!\$&'()\*\+,;=\-._~]*$/;function yE(r){return _E.test(r)?r:encodeURI(r)}const Jf={extension:{type:S.LoadParser,priority:te.Low},name:"loadWebFont",id:"web-font",test(r){return ar(r,mE)||le(r,fE)},async load(r,t){var e,i,n,s,a,o;const l=H.get().getFontFaceSet();if(l){const u=[],c=(i=(e=t.data)==null?void 0:e.family)!=null?i:Qf(r),h=(a=(s=(n=t.data)==null?void 0:n.weights)==null?void 0:s.filter(f=>pE.includes(f)))!=null?a:["normal"],p=(o=t.data)!=null?o:{};for(let f=0;fs.faces.some(a=>t.indexOf(a)!==-1));n.faces=n.faces.filter(s=>t.indexOf(s)===-1),n.faces.length===0&&(i.entries=i.entries.filter(s=>s!==n)),t.forEach(s=>{H.get().getFontFaceSet().delete(s)}),i.entries.length===0&&it.remove(`${e}-and-url`)}},zo={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},bE=/([astvzqmhlc])([^astvzqmhlc]*)/gi,vE=/-?[0-9]*\.?[0-9]+(?:e[-+]?\d+)?/gi;function xE(r){const t=[];return r.replace(bE,(e,i,n)=>{let s=i.toLowerCase(),a=i;const o=TE(n);for(s==="m"&&o.length>2&&(t.push([a,...o.splice(0,2)]),s="l",a=a==="m"?"l":"L");;){if(o.length===zo[s])return t.push([a,...o]),"";if(o.length0&&(n=i.pop(),n?(s=n.startX,a=n.startY):(s=0,a=0)),n=null;break;default:}u!=="Z"&&u!=="z"&&n===null&&(n={startX:s,startY:a},i.push(n))}return t}const em={};function kn(r,t,e){let i=2166136261;for(let n=0;n>>=0;return em[i]||SE(r,t,i,e)}function SE(r,t,e,i){const n={};let s=0;for(let o=0;o{if(Gr.quiet||rm.has(t))return;let i=new Error().stack;const n=`${t} Deprecated since v${r}`,s=typeof console.groupCollapsed=="function"&&!Gr.noColor;typeof i=="undefined"?console.warn("PixiJS Deprecation Warning: ",n):(i=i.split(` `).splice(e).join(` -`),s?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(i))),rm.add(t)});Object.defineProperties(Mi,{quiet:{get:()=>Gr.quiet,set:r=>{Gr.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Gr.noColor,set:r=>{Gr.noColor=r},enumerable:!0,configurable:!1}});function $n(r,t,e,i){if(e!=null||(e=0),i!=null||(i=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(i&7)){const n=i/8;new Float64Array(t,0,n).set(new Float64Array(r,e,n))}else if(!(e&3)&&!(i&3)){const n=i/4;new Float32Array(t,0,n).set(new Float32Array(r,e,n))}else new Uint8Array(t).set(new Uint8Array(r,e,i))}const im={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var wt=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(wt||{});function Ir(r,t){return t.alphaMode==="no-premultiply-alpha"&&im[r]||r}const bP=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` -`);function vP(r){let t="";for(let e=0;e0&&(t+=` -else `),et in r?xP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lm=(r,t)=>{for(var e in t||(t={}))TP.call(t,e)&&om(r,e,t[e]);if(am)for(var e of am(t))SP.call(t,e)&&om(r,e,t[e]);return r};class um{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new sm,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Ri=[];let kn=0;qe.register({clear:()=>{if(Ri.length>0)for(const r of Ri)r&&r.destroy();Ri.length=0,kn=0}});function cm(){return kn>0?Ri[--kn]:new um}function hm(r){r.elements=null,Ri[kn++]=r}let Oi=0;const dm=class I1{constructor(t){this.uid=ht("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=lm(lm({},I1.defaultOptions),t),t.maxTextures||(Mi("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=nm());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new or(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer;let h=this._batchIndexSize,p=this._batchIndexStart,f="startBatch",m=[];const g=this.maxTextures;for(let _=this.elementStart;_=g||v)&&(this._finishBatch(i,p,h-p,n,a,o,t,f,m),f="renderBatch",p=h,a=x,o=y.topology,i=cm(),n=i.textures,n.clear(),m=[],++Oi),y._textureId=b._textureBindLocation=n.count,n.ids[b.uid]=n.count,n.textures[n.count++]=b,y._batch=i,m.push(y),h+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,l,u,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,l,u,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(i,p,h-p,n,a,o,t,f,m),p=h,++Oi),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=h}_finishBatch(t,e,i,n,s,a,o,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=n,t.blendMode=s,t.topology=a,t.start=e,t.size=i,t.elements=u,++Oi,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new or(e);$n(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let s=0;sn.replace(/[{()}]/g,"")))!=null?e:[]).forEach(n=>{i[n]=[]}),i}function mm(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function Ko(r,t,e=!1){const i=[];mm(t,i),r.forEach(o=>{o.header&&mm(o.header,i)});const n=i;e&&n.sort();const s=n.map((o,l)=>` @location(${l}) ${o},`).join(` +`),s?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",n),console.warn(i),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",n),console.warn(i))),rm.add(t)});Object.defineProperties(Mi,{quiet:{get:()=>Gr.quiet,set:r=>{Gr.quiet=r},enumerable:!0,configurable:!1},noColor:{get:()=>Gr.noColor,set:r=>{Gr.noColor=r},enumerable:!0,configurable:!1}});function Ln(r,t,e,i){if(e!=null||(e=0),i!=null||(i=Math.min(r.byteLength-e,t.byteLength)),!(e&7)&&!(i&7)){const n=i/8;new Float64Array(t,0,n).set(new Float64Array(r,e,n))}else if(!(e&3)&&!(i&3)){const n=i/4;new Float32Array(t,0,n).set(new Float32Array(r,e,n))}else new Uint8Array(t).set(new Uint8Array(r,e,i))}const im={normal:"normal-npm",add:"add-npm",screen:"screen-npm"};var wt=(r=>(r[r.DISABLED=0]="DISABLED",r[r.RENDERING_MASK_ADD=1]="RENDERING_MASK_ADD",r[r.MASK_ACTIVE=2]="MASK_ACTIVE",r[r.INVERSE_MASK_ACTIVE=3]="INVERSE_MASK_ACTIVE",r[r.RENDERING_MASK_REMOVE=4]="RENDERING_MASK_REMOVE",r[r.NONE=5]="NONE",r))(wt||{});function Ir(r,t){return t.alphaMode==="no-premultiply-alpha"&&im[r]||r}const EE=["precision mediump float;","void main(void){","float test = 0.1;","%forloop%","gl_FragColor = vec4(0.0);","}"].join(` +`);function PE(r){let t="";for(let e=0;e0&&(t+=` +else `),et in r?AE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lm=(r,t)=>{for(var e in t||(t={}))CE.call(t,e)&&om(r,e,t[e]);if(am)for(var e of am(t))ME.call(t,e)&&om(r,e,t[e]);return r};class um{constructor(){this.renderPipeId="batch",this.action="startBatch",this.start=0,this.size=0,this.textures=new sm,this.blendMode="normal",this.topology="triangle-strip",this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}}const Ri=[];let Nn=0;qe.register({clear:()=>{if(Ri.length>0)for(const r of Ri)r&&r.destroy();Ri.length=0,Nn=0}});function cm(){return Nn>0?Ri[--Nn]:new um}function hm(r){r.elements=null,Ri[Nn++]=r}let Oi=0;const dm=class F1{constructor(t){this.uid=ht("batcher"),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t=lm(lm({},F1.defaultOptions),t),t.maxTextures||(Mi("v8.8.0","maxTextures is a required option for Batcher now, please pass it in the options"),t.maxTextures=nm());const{maxTextures:e,attributesInitialSize:i,indicesInitialSize:n}=t;this.attributeBuffer=new or(i*4),this.indexBuffer=new Uint16Array(n),this.maxTextures=e}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let t=0;tthis.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);const l=this.attributeBuffer.float32View,u=this.attributeBuffer.uint32View,c=this.indexBuffer;let h=this._batchIndexSize,p=this._batchIndexStart,f="startBatch",m=[];const g=this.maxTextures;for(let _=this.elementStart;_=g||v)&&(this._finishBatch(i,p,h-p,n,a,o,t,f,m),f="renderBatch",p=h,a=x,o=y.topology,i=cm(),n=i.textures,n.clear(),m=[],++Oi),y._textureId=b._textureBindLocation=n.count,n.ids[b.uid]=n.count,n.textures[n.count++]=b,y._batch=i,m.push(y),h+=y.indexSize,y.packAsQuad?(this.packQuadAttributes(y,l,u,y._attributeStart,y._textureId),this.packQuadIndex(c,y._indexStart,y._attributeStart/this.vertexSize)):(this.packAttributes(y,l,u,y._attributeStart,y._textureId),this.packIndex(y,c,y._indexStart,y._attributeStart/this.vertexSize))}n.count>0&&(this._finishBatch(i,p,h-p,n,a,o,t,f,m),p=h,++Oi),this.elementStart=this.elementSize,this._batchIndexStart=p,this._batchIndexSize=h}_finishBatch(t,e,i,n,s,a,o,l,u){t.gpuBindGroup=null,t.bindGroup=null,t.action=l,t.batcher=this,t.textures=n,t.blendMode=s,t.topology=a,t.start=e,t.size=i,t.elements=u,++Oi,this.batches[this.batchIndex++]=t,o.add(t)}finish(t){this.break(t)}ensureAttributeBuffer(t){t*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(t*4)}ensureIndexBuffer(t){t<=this.indexBuffer.length||this._resizeIndexBuffer(t)}_resizeAttributeBuffer(t){const e=Math.max(t,this.attributeBuffer.size*2),i=new or(e);Ln(this.attributeBuffer.rawBinaryData,i.rawBinaryData),this.attributeBuffer=i}_resizeIndexBuffer(t){const e=this.indexBuffer;let i=Math.max(t,e.length*1.5);i+=i%2;const n=i>65535?new Uint32Array(i):new Uint16Array(i);if(n.BYTES_PER_ELEMENT!==e.BYTES_PER_ELEMENT)for(let s=0;sn.replace(/[{()}]/g,"")))!=null?e:[]).forEach(n=>{i[n]=[]}),i}function mm(r,t){let e;const i=/@in\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function qo(r,t,e=!1){const i=[];mm(t,i),r.forEach(o=>{o.header&&mm(o.header,i)});const n=i;e&&n.sort();const s=n.map((o,l)=>` @location(${l}) ${o},`).join(` `);let a=t.replace(/@in\s+[^;]+;\s*/g,"");return a=a.replace("{{in}}",` ${s} -`),a}function gm(r,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function AP(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function CP(r){const t=/@.*?\s+/g;return r.replace(t,"")}function _m(r,t){const e=[];gm(t,e),r.forEach(l=>{l.header&&gm(l.header,e)});let i=0;const n=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`, -`),s=e.sort().map(l=>` var ${CP(l)};`).join(` +`),a}function gm(r,t){let e;const i=/@out\s+([^;]+);/g;for(;(e=i.exec(r))!==null;)t.push(e[1])}function IE(r){const t=/\b(\w+)\s*:/g.exec(r);return t?t[1]:""}function BE(r){const t=/@.*?\s+/g;return r.replace(t,"")}function _m(r,t){const e=[];gm(t,e),r.forEach(l=>{l.header&&gm(l.header,e)});let i=0;const n=e.sort().map(l=>l.indexOf("builtin")>-1?l:`@location(${i++}) ${l}`).join(`, +`),s=e.sort().map(l=>` var ${BE(l)};`).join(` `),a=`return VSOutput( - ${e.sort().map(l=>` ${AP(l)}`).join(`, + ${e.sort().map(l=>` ${IE(l)}`).join(`, `)});`;let o=t.replace(/@out\s+[^;]+;\s*/g,"");return o=o.replace("{{struct}}",` ${n} `),o=o.replace("{{start}}",` ${s} `),o=o.replace("{{return}}",` ${a} -`),o}function qo(r,t){let e=r;for(const i in t){const n=t[i];n.join(` +`),o}function Zo(r,t){let e=r;for(const i in t){const n=t[i];n.join(` `).length?e=e.replace(`{{${i}}}`,`//-----${i} START-----// ${n.join(` `)} -//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const lr=Object.create(null),Zo=new Map;let MP=0;function ym({template:r,bits:t}){const e=vm(r,t);if(lr[e])return lr[e];const{vertex:i,fragment:n}=RP(r,t);return lr[e]=xm(i,n,t),lr[e]}function bm({template:r,bits:t}){const e=vm(r,t);return lr[e]||(lr[e]=xm(r.vertex,r.fragment,t)),lr[e]}function RP(r,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let n=Ko(e,r.vertex,!0);n=_m(e,n);const s=Ko(i,r.fragment,!0);return{vertex:n,fragment:s}}function vm(r,t){return t.map(e=>(Zo.has(e)||Zo.set(e,MP++),Zo.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function xm(r,t,e){const i=Yo(r),n=Yo(t);return e.forEach(s=>{Vo(s.vertex,i,s.name),Vo(s.fragment,n,s.name)}),{vertex:qo(r,i),fragment:qo(t,n)}}const Tm=` +//----${i} FINISH----//`):e=e.replace(`{{${i}}}`,"")}return e}const lr=Object.create(null),Qo=new Map;let FE=0;function ym({template:r,bits:t}){const e=vm(r,t);if(lr[e])return lr[e];const{vertex:i,fragment:n}=DE(r,t);return lr[e]=xm(i,n,t),lr[e]}function bm({template:r,bits:t}){const e=vm(r,t);return lr[e]||(lr[e]=xm(r.vertex,r.fragment,t)),lr[e]}function DE(r,t){const e=t.map(a=>a.vertex).filter(a=>!!a),i=t.map(a=>a.fragment).filter(a=>!!a);let n=qo(e,r.vertex,!0);n=_m(e,n);const s=qo(i,r.fragment,!0);return{vertex:n,fragment:s}}function vm(r,t){return t.map(e=>(Qo.has(e)||Qo.set(e,FE++),Qo.get(e))).sort((e,i)=>e-i).join("-")+r.vertex+r.fragment}function xm(r,t,e){const i=Ko(r),n=Ko(t);return e.forEach(s=>{Yo(s.vertex,i,s.name),Yo(s.fragment,n,s.name)}),{vertex:Zo(r,i),fragment:Zo(t,n)}}const Tm=` @in aPosition: vec2; @in aUV: vec2; @@ -243,7 +243,7 @@ ${n.join(` {{end}} } -`,Pm=` +`,Em=` in vec4 vColor; in vec2 vUV; @@ -264,7 +264,7 @@ ${n.join(` {{end}} } -`,Em={name:"global-uniforms-bit",vertex:{header:` +`,Pm={name:"global-uniforms-bit",vertex:{header:` struct GlobalUniforms { uProjectionMatrix:mat3x3, uWorldTransformMatrix:mat3x3, @@ -273,7 +273,7 @@ ${n.join(` } @group(0) @binding(0) var globalUniforms : GlobalUniforms; - `}},OP={name:"global-uniforms-ubo-bit",vertex:{header:` + `}},UE={name:"global-uniforms-ubo-bit",vertex:{header:` uniform globalUniforms { mat3 uProjectionMatrix; mat3 uWorldTransformMatrix; @@ -285,17 +285,17 @@ ${n.join(` uniform mat3 uWorldTransformMatrix; uniform vec4 uWorldColorAlpha; uniform vec2 uResolution; - `}};var GP=Object.defineProperty,Cm=Object.getOwnPropertySymbols,IP=Object.prototype.hasOwnProperty,BP=Object.prototype.propertyIsEnumerable,Mm=(r,t,e)=>t in r?GP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FP=(r,t)=>{for(var e in t||(t={}))IP.call(t,e)&&Mm(r,e,t[e]);if(Cm)for(var e of Cm(t))BP.call(t,e)&&Mm(r,e,t[e]);return r};function Fr({bits:r,name:t}){const e=ym({template:{fragment:Sm,vertex:Tm},bits:[Em,...r]});return Xt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Dr({bits:r,name:t}){return new Wt(FP({name:t},bm({template:{vertex:wm,fragment:Pm},bits:[Am,...r]})))}const Ln={name:"color-bit",vertex:{header:` + `}};var $E=Object.defineProperty,Cm=Object.getOwnPropertySymbols,kE=Object.prototype.hasOwnProperty,LE=Object.prototype.propertyIsEnumerable,Mm=(r,t,e)=>t in r?$E(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,NE=(r,t)=>{for(var e in t||(t={}))kE.call(t,e)&&Mm(r,e,t[e]);if(Cm)for(var e of Cm(t))LE.call(t,e)&&Mm(r,e,t[e]);return r};function Fr({bits:r,name:t}){const e=ym({template:{fragment:Sm,vertex:Tm},bits:[Pm,...r]});return Xt.from({name:t,vertex:{source:e.vertex,entryPoint:"main"},fragment:{source:e.fragment,entryPoint:"main"}})}function Dr({bits:r,name:t}){return new Wt(NE({name:t},bm({template:{vertex:wm,fragment:Em},bits:[Am,...r]})))}const Xn={name:"color-bit",vertex:{header:` @in aColor: vec4; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}},Nn={name:"color-bit",vertex:{header:` + `}},jn={name:"color-bit",vertex:{header:` in vec4 aColor; `,main:` vColor *= vec4(aColor.rgb * aColor.a, aColor.a); - `}},Qo={};function DP(r){const t=[];if(r===1)t.push("@group(1) @binding(0) var textureSource1: texture_2d;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` -`)}function UP(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e;"),t.push("@group(1) @binding(1) var textureSampler1: sampler;");else{let e=0;for(let i=0;i;`),t.push(`@group(1) @binding(${e++}) var textureSampler${i+1}: sampler;`)}return t.join(` +`)}function jE(r){const t=[];if(r===1)t.push("outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);");else{t.push("switch vTextureId {");for(let e=0;e; @out @interpolate(flat) vTextureId : u32; `,main:` @@ -308,14 +308,14 @@ ${n.join(` `},fragment:{header:` @in @interpolate(flat) vTextureId: u32; - ${DP(r)} + ${XE(r)} `,main:` var uvDx = dpdx(vUV); var uvDy = dpdy(vUV); - ${UP(r)} - `}}),Qo[r]}const Jo={};function $P(r){const t=[];for(let e=0;e0&&t.push("else"),e0&&t.push("else"),e, targetSize: vec2) -> vec2 { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; @@ -344,9 +344,9 @@ ${n.join(` { return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0; } - `}},Rm={};function Hn(r){let t=Rm[r];if(t)return t;const e=new Int32Array(r);for(let i=0;ie&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function el(r,t,e,i,n,s,a,o=null){let l=0;e*=t,n*=s;const u=o.a,c=o.b,h=o.c,p=o.d,f=o.tx,m=o.ty;for(;l>16|t&65280|(t&255)<<16,i=this.renderable;return i?Oe(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||kP}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}}var LP=Object.defineProperty,NP=Object.defineProperties,XP=Object.getOwnPropertyDescriptors,Gm=Object.getOwnPropertySymbols,jP=Object.prototype.hasOwnProperty,HP=Object.prototype.propertyIsEnumerable,Im=(r,t,e)=>t in r?LP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yn=(r,t)=>{for(var e in t||(t={}))jP.call(t,e)&&Im(r,e,t[e]);if(Gm)for(var e of Gm(t))HP.call(t,e)&&Im(r,e,t[e]);return r},Kn=(r,t)=>NP(r,XP(t));const kr={extension:{type:S.ShapeBuilder,name:"circle"},build(r,t){let e,i,n,s,a,o;if(r.type==="circle"){const v=r;if(a=o=v.radius,a<=0)return!1;e=v.x,i=v.y,n=s=0}else if(r.type==="ellipse"){const v=r;if(a=v.halfWidth,o=v.halfHeight,a<=0||o<=0)return!1;e=v.x,i=v.y,n=s=0}else{const v=r,w=v.width/2,T=v.height/2;e=v.x+w,i=v.y+T,a=o=Math.max(0,Math.min(v.radius,Math.min(w,T))),n=w-a,s=T-o}if(n<0||s<0)return!1;const l=Math.ceil(2.3*Math.sqrt(a+o)),u=l*8+(n?4:0)+(s?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+n,t[1]=t[3]=i+s,t[2]=t[4]=e-n,t[5]=t[7]=i-s,!0;let c=0,h=l*4+(n?2:0)+2,p=h,f=u,m=n+a,g=s,_=e+m,y=e-m,b=i+g;if(t[c++]=_,t[c++]=b,t[--h]=b,t[--h]=y,s){const v=i-g;t[p++]=y,t[p++]=v,t[--f]=v,t[--f]=_}for(let v=1;v0&&(n[s++]=l,n[s++]=u,n[s++]=l-1),l++;n[s++]=u+1,n[s++]=u,n[s++]=l-1}},Bm=Kn(Yn({},kr),{extension:Kn(Yn({},kr.extension),{name:"ellipse"})}),Fm=Kn(Yn({},kr),{extension:Kn(Yn({},kr.extension),{name:"roundedRectangle"})}),il=1e-4,nl=1e-4;function Dm(r){const t=r.length;if(t<6)return 1;let e=0;for(let i=0,n=r[t-2],s=r[t-1];ih&&(h+=Math.PI*2);let p=c;const f=h-c,m=Math.abs(f),g=Math.sqrt(l*l+u*u),_=(15*m*Math.sqrt(g)/Math.PI>>0)+1,y=f/_;if(p+=y,o){a.push(r,t),a.push(e,i);for(let b=1,x=p;b<_;b++,x+=y)a.push(r,t),a.push(r+Math.sin(x)*g,t+Math.cos(x)*g);a.push(r,t),a.push(n,s)}else{a.push(e,i),a.push(r,t);for(let b=1,x=p;b<_;b++,x+=y)a.push(r+Math.sin(x)*g,t+Math.cos(x)*g),a.push(r,t);a.push(n,s),a.push(r,t)}return _*2}function qn(r,t,e,i,n,s){const a=il;if(r.length===0)return;const o=t;let l=o.alignment;if(t.alignment!==.5){let j=Dm(r);e&&(j*=-1),l=(l-.5)*j+.5}const u=new lt(r[0],r[1]),c=new lt(r[r.length-2],r[r.length-1]),h=i,p=Math.abs(u.x-c.x)=0&&(o.join==="round"?g+=ur(T,P,T-C*O,P-A*O,T-G*O,P-F*O,f,!1)+4:g+=2,f.push(T-G*I,P-F*I),f.push(T+G*O,P+F*O));continue}const _t=(-C+v)*(-A+P)-(-C+T)*(-A+w),et=(-G+E)*(-F+P)-(-G+T)*(-F+M),st=(J*et-N*_t)/z,nt=(k*_t-K*et)/z,ot=(st-T)*(st-T)+(nt-P)*(nt-P),gt=T+(st-T)*O,yt=P+(nt-P)*O,pt=T-(st-T)*I,Y=P-(nt-P)*I,Rt=Math.min(J*J+K*K,N*N+k*k),Ct=rt?O:I,ce=Rt+Ct*Ct*b;ot<=ce?o.join==="bevel"||ot/b>x?(rt?(f.push(gt,yt),f.push(T+C*I,P+A*I),f.push(gt,yt),f.push(T+G*I,P+F*I)):(f.push(T-C*O,P-A*O),f.push(pt,Y),f.push(T-G*O,P-F*O),f.push(pt,Y)),g+=2):o.join==="round"?rt?(f.push(gt,yt),f.push(T+C*I,P+A*I),g+=ur(T,P,T+C*I,P+A*I,T+G*I,P+F*I,f,!0)+4,f.push(gt,yt),f.push(T+G*I,P+F*I)):(f.push(T-C*O,P-A*O),f.push(pt,Y),g+=ur(T,P,T-C*O,P-A*O,T-G*O,P-F*O,f,!1)+4,f.push(T-G*O,P-F*O),f.push(pt,Y)):(f.push(gt,yt),f.push(pt,Y)):(f.push(T-C*O,P-A*O),f.push(T+C*I,P+A*I),o.join==="round"?rt?g+=ur(T,P,T+C*I,P+A*I,T+G*I,P+F*I,f,!0)+2:g+=ur(T,P,T-C*O,P-A*O,T-G*O,P-F*O,f,!1)+2:o.join==="miter"&&ot/b<=x&&(rt?(f.push(pt,Y),f.push(pt,Y)):(f.push(gt,yt),f.push(gt,yt)),g+=2),f.push(T-G*O,P-F*O),f.push(T+G*I,P+F*I),g+=2)}v=r[(m-2)*2],w=r[(m-2)*2+1],T=r[(m-1)*2],P=r[(m-1)*2+1],C=-(w-P),A=v-T,R=Math.sqrt(C*C+A*A),C/=R,A/=R,C*=y,A*=y,f.push(T-C*O,P-A*O),f.push(T+C*I,P+A*I),h||(o.cap==="round"?g+=ur(T-C*(O-I)*.5,P-A*(O-I)*.5,T-C*O,P-A*O,T+C*I,P+A*I,f,!1)+2:o.cap==="square"&&(g+=Um(T,P,C,A,O,I,!1,f)));const L=nl*nl;for(let j=_;j0&&a>0?(t[0]=i,t[1]=n,t[2]=i+s,t[3]=n,t[4]=i+s,t[5]=n+a,t[6]=i,t[7]=n+a,!0):!1},triangulate(r,t,e,i,n,s){let a=0;i*=e,t[i+a]=r[0],t[i+a+1]=r[1],a+=e,t[i+a]=r[2],t[i+a+1]=r[3],a+=e,t[i+a]=r[6],t[i+a+1]=r[7],a+=e,t[i+a]=r[4],t[i+a+1]=r[5],a+=e;const o=i/e;n[s++]=o,n[s++]=o+1,n[s++]=o+2,n[s++]=o+1,n[s++]=o+3,n[s++]=o+2}},Nm={extension:{type:S.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,i,n,s){let a=0;i*=e,t[i+a]=r[0],t[i+a+1]=r[1],a+=e,t[i+a]=r[2],t[i+a+1]=r[3],a+=e,t[i+a]=r[4],t[i+a+1]=r[5];const o=i/e;n[s++]=o,n[s++]=o+1,n[s++]=o+2}};var WP=Object.defineProperty,Xm=Object.getOwnPropertySymbols,VP=Object.prototype.hasOwnProperty,YP=Object.prototype.propertyIsEnumerable,jm=(r,t,e)=>t in r?WP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hm=(r,t)=>{for(var e in t||(t={}))VP.call(t,e)&&jm(r,e,t[e]);if(Xm)for(var e of Xm(t))YP.call(t,e)&&jm(r,e,t[e]);return r};const zm=[{offset:0,color:"white"},{offset:1,color:"black"}],al=class Ph{constructor(...t){this.uid=ht("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let i=KP(t);const n=i.type==="radial"?Ph.defaultRadialOptions:Ph.defaultLinearOptions;i=Hm(Hm({},n),he(i)),this._textureSize=i.textureSize,this._wrapMode=i.wrapMode,i.type==="radial"?(this.center=i.center,this.outerCenter=(e=i.outerCenter)!=null?e:this.center,this.innerRadius=i.innerRadius,this.outerRadius=i.outerRadius,this.scale=i.scale,this.rotation=i.rotation):(this.start=i.start,this.end=i.end),this.textureSpace=i.textureSpace,this.type=i.type,i.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:tt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,s=i-t,a=n-e;const o=s<0||a<0;if(this._wrapMode==="clamp-to-edge"){if(s<0){const _=t;t=i,i=_,s*=-1}if(a<0){const _=e;e=n,n=_,a*=-1}}const l=this.colorStops.length?this.colorStops:zm,u=this._textureSize,{canvas:c,context:h}=Vm(u,1),p=o?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);Wm(p,l),h.fillStyle=p,h.fillRect(0,0,u,1),this.texture=new D({source:new ke({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(s*s+a*a),m=Math.atan2(a,s),g=new U;g.scale(f/u,1),g.rotate(m),g.translate(t,e),this.textureSpace==="local"&&g.scale(u,u),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:zm,e=this._textureSize,{canvas:i,context:n}=Vm(e,e),{x:s,y:a}=this.center,{x:o,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=o-c,p=l-c,f=e/(c*2),m=(s-h)*f,g=(a-p)*f,_=n.createRadialGradient(m,g,u*f,(o-h)*f,(l-p)*f,c*f);Wm(_,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=_,n.translate(m,g),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-m,-g),n.fillRect(0,0,e,e),this.texture=new D({source:new ke({resource:i,addressMode:this._wrapMode})});const y=new U;y.scale(1/f,1/f),y.translate(h,p),this.textureSpace==="local"&&y.scale(e,e),this.transform=y}destroy(){var t;(t=this.texture)==null||t.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}`}};al.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},al.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let $t=al;function Wm(r,t){for(let e=0;e{var h;const p=[],f=Ne[l.type];if(!f.build(l,p))return;const m=o.length,g=s.length/2;let _="triangle-list";if(u&&Wn(p,u),e){const v=(h=l.closePath)!=null?h:!0,w=t;w.pixelLine?($m(p,v,s,o),_="line-list"):qn(p,w,!1,v,s,o)}else if(c){const v=[],w=p.slice();eE(c).forEach(T=>{v.push(w.length/2),w.push(...T)}),sl(w,v,s,2,g,o,m)}else f.triangulate(p,s,2,g,o,m);const y=a.length/2,b=t.texture;if(b!==D.WHITE){const v=ol(JP,t,l,u);el(s,2,g,a,y,2,s.length/2-g,v)}else rl(a,y,2,s.length/2-g);const x=Et.get(Vn);x.indexOffset=m,x.indexSize=o.length-m,x.attributeOffset=g,x.attributeSize=s.length/2-g,x.baseColor=t.color,x.alpha=t.alpha,x.texture=b,x.geometryData=n,x.topology=_,i.push(x)})}function eE(r){const t=[];for(let e=0;e{Et.return(t)}),this.graphicsData&&Et.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Zm{constructor(){this.instructions=new cn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new zn({maxTextures:e}),this.instructions.reset()}get geometry(){return this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const ll=class Eh{constructor(t){this._renderer=t,this._managedContexts=new Ut({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;Eh.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Eh.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),Ym(t,i);const n=t.batchMode;t.customShader||n==="no-batch"?i.isBatchable=!1:n==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=Et.get(Zm,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:n,geometryData:s}=i;i.graphicsData=e;const a=s.vertices.length,o=s.indices.length;for(let h=0;hrE)return;const h=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+n)/2,g=(i+s)/2,_=(n+a)/2,y=(s+o)/2,b=(p+m)/2,x=(f+g)/2,v=(m+_)/2,w=(g+y)/2,T=(b+v)/2,P=(x+w)/2;if(c>0){let E=a-r,M=o-t;const C=Math.abs((e-a)*M-(i-o)*E),A=Math.abs((n-a)*M-(s-o)*E);let G,F;if(C>Qn&&A>Qn){if((C+A)*(C+A)<=u*(E*E+M*M)){if(Lr=h&&(G=2*h-G),F>=h&&(F=2*h-F),G+Fcr){l.push(e,i);return}if(F>cr){l.push(n,s);return}}}}else if(C>Qn){if(C*C<=u*(E*E+M*M)){if(Lr=h&&(G=2*h-G),Gcr){l.push(e,i);return}}}else if(A>Qn){if(A*A<=u*(E*E+M*M)){if(Lr=h&&(G=2*h-G),Gcr){l.push(n,s);return}}}else if(E=T-(r+a)/2,M=P-(t+o)/2,E*E+M*M<=u){l.push(T,P);return}}hl(r,t,p,f,b,x,T,P,l,u,c+1),hl(T,P,v,w,_,y,a,o,l,u,c+1)}const sE=8,aE=11920929e-14,oE=1,lE=.01,Qm=0;function Jm(r,t,e,i,n,s,a,o){const l=Math.min(.99,Math.max(0,o!=null?o:Zn.defaultOptions.bezierSmoothness));let u=(oE-l)/1;return u*=u,uE(t,e,i,n,s,a,r,u),r}function uE(r,t,e,i,n,s,a,o){dl(a,r,t,e,i,n,s,o,0),a.push(n,s)}function dl(r,t,e,i,n,s,a,o,l){if(l>sE)return;const u=Math.PI,c=(t+i)/2,h=(e+n)/2,p=(i+s)/2,f=(n+a)/2,m=(c+p)/2,g=(h+f)/2;let _=s-t,y=a-e;const b=Math.abs((i-s)*y-(n-a)*_);if(b>aE){if(b*b<=o*(_*_+y*y)){if(Qm=u&&(x=2*u-x),xs||a&&s>n)&&(l=2*Math.PI-l),o||(o=Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(l/Math.PI)))),o=Math.max(o,3);let u=l/o,c=n;u*=a?-1:1;for(let h=0;hc*o)}const Ii=Math.PI*2,fl={centerX:0,centerY:0,ang1:0,ang2:0},ml=({x:r,y:t},e,i,n,s,a,o,l)=>{r*=e,t*=i;const u=n*r-s*t,c=s*r+n*t;return l.x=u+a,l.y=c+o,l};function cE(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,n=Math.cos(r),s=Math.sin(r),a=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-s*i,y:s+n*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const eg=(r,t,e,i)=>{const n=r*i-t*e<0?-1:1;let s=r*e+t*i;return s>1&&(s=1),s<-1&&(s=-1),n*Math.acos(s)},hE=(r,t,e,i,n,s,a,o,l,u,c,h,p)=>{const f=Math.pow(n,2),m=Math.pow(s,2),g=Math.pow(c,2),_=Math.pow(h,2);let y=f*m-f*_-m*g;y<0&&(y=0),y/=f*_+m*g,y=Math.sqrt(y)*(a===o?-1:1);const b=y*n/s*h,x=y*-s/n*c,v=u*b-l*x+(r+e)/2,w=l*b+u*x+(t+i)/2,T=(c-b)/n,P=(h-x)/s,E=(-c-b)/n,M=(-h-x)/s,C=eg(1,0,T,P);let A=eg(T,P,E,M);o===0&&A>0&&(A-=Ii),o===1&&A<0&&(A+=Ii),p.centerX=v,p.centerY=w,p.ang1=C,p.ang2=A};function rg(r,t,e,i,n,s,a,o=0,l=0,u=0){if(s===0||a===0)return;const c=Math.sin(o*Ii/360),h=Math.cos(o*Ii/360),p=h*(t-i)/2+c*(e-n)/2,f=-c*(t-i)/2+h*(e-n)/2;if(p===0&&f===0)return;s=Math.abs(s),a=Math.abs(a);const m=Math.pow(p,2)/Math.pow(s,2)+Math.pow(f,2)/Math.pow(a,2);m>1&&(s*=Math.sqrt(m),a*=Math.sqrt(m)),hE(t,e,i,n,s,a,l,u,c,h,p,f,fl);let{ang1:g,ang2:_}=fl;const{centerX:y,centerY:b}=fl;let x=Math.abs(_)/(Ii/4);Math.abs(1-x)<1e-7&&(x=1);const v=Math.max(Math.ceil(x),1);_/=v;let w=r[r.length-2],T=r[r.length-1];const P={x:0,y:0};for(let E=0;E{const u=l.x-o.x,c=l.y-o.y,h=Math.sqrt(u*u+c*c),p=u/h,f=c/h;return{len:h,nx:p,ny:f}},s=(o,l)=>{o===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let a=t[t.length-1];for(let o=0;o0&&(m=-1,g=!0);const _=f/2;let y,b=Math.abs(Math.cos(_)*u/Math.sin(_));b>Math.min(h.len/2,p.len/2)?(b=Math.min(h.len/2,p.len/2),y=Math.abs(b*Math.sin(_)/Math.cos(_))):y=u;const x=l.x+p.nx*b+-p.ny*y*m,v=l.y+p.ny*b+p.nx*y*m,w=Math.atan2(h.ny,h.nx)+Math.PI/2*m,T=Math.atan2(p.ny,p.nx)-Math.PI/2*m;o===0&&r.moveTo(x+Math.cos(w)*y,v+Math.sin(w)*y),r.arc(x,v,y,w,T,g),a=l}}function ng(r,t,e,i){var n;const s=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),a=(l,u,c)=>({x:l.x+(u.x-l.x)*c,y:l.y+(u.y-l.y)*c}),o=t.length;for(let l=0;l1){let s=null;for(let a=n;a=2;h-=2)c[h]===c[h-2]&&c[h-1]===c[h-3]&&c.splice(h-1,2);return this.poly(c,!0,a)}ellipse(t,e,i,n,s){return this.drawShape(new Pn(t,e,i,n),s),this}roundRect(t,e,i,n,s,a){return this.drawShape(new An(t,e,i,n,s),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Er,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 Er,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const s=e.transform,a=i;i=s.a*i+s.c*n+s.tx,n=s.b*a+s.d*n+s.ty}this._currentPoly.points.push(i,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eo.area).sort((o,l)=>l-o),[e,i]=t,n=t[t.length-1],s=e/i,a=i/n;return!(s>3&&a<2)}function mE(r,t=0){const e=r.instructions[t];if(!e||e.action!=="fill")throw new Error(`Expected fill instruction at index ${t}, got ${(e==null?void 0:e.action)||"undefined"}`);return e.data}function cg(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function hg(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],n=[];for(let u=0;ut in r?gE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Jn=(r,t)=>{for(var e in t||(t={}))_E.call(t,e)&&pg(r,e,t[e]);if(dg)for(var e of dg(t))yE.call(t,e)&&pg(r,e,t[e]);return r};function fg(r,t){if(typeof r=="string"){const a=document.createElement("div");a.innerHTML=r.trim(),r=a.querySelector("svg")}const e={context:t,defs:{},path:new ge};og(r,e);const i=r.children,{fillStyle:n,strokeStyle:s}=bl(r,e);for(let a=0;a1;if(A&&G){const F=C.map(R=>({path:R,area:hg(R)}));if(F.sort((R,B)=>B.area-R.area),C.length>3||!ug(F))for(let R=0;RparseInt(M,10)),t.context.poly(x,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":v=r.getAttribute("points"),x=v.match(/-?\d+/g).map(M=>parseInt(M,10)),t.context.poly(x,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{ue(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}o&&(e=null);for(let M=0;Mt in r?bE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_e=(r,t)=>{for(var e in t||(t={}))_g.call(t,e)&&bg(r,e,t[e]);if(ts)for(var e of ts(t))yg.call(t,e)&&bg(r,e,t[e]);return r},vE=(r,t)=>{var e={};for(var i in r)_g.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ts)for(var i of ts(r))t.indexOf(i)<0&&yg.call(r,i)&&(e[i]=r[i]);return e};function xE(r){return tt.isColorLike(r)}function vg(r){return r instanceof Xr}function xg(r){return r instanceof $t}function TE(r){return r instanceof D}function SE(r,t,e){const i=tt.shared.setValue(t!=null?t:0);return r.color=i.toNumber(),r.alpha=i.alpha===1?e.alpha:i.alpha,r.texture=D.WHITE,_e(_e({},e),r)}function wE(r,t,e){return r.texture=t,_e(_e({},e),r)}function Tg(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,_e(_e({},e),r)}function Sg(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,_e(_e({},e),r)}function PE(r,t){const e=_e(_e({},t),r),i=tt.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function Xe(r,t){if(r==null)return null;const e={},i=r;return xE(r)?SE(e,r,t):TE(r)?wE(e,r,t):vg(r)?Tg(e,r,t):xg(r)?Sg(e,r,t):i.fill&&vg(i.fill)?Tg(i,i.fill,t):i.fill&&xg(i.fill)?Sg(i,i.fill,t):PE(i,t)}function Bi(r,t){const e=t,{width:i,alignment:n,miterLimit:s,cap:a,join:o,pixelLine:l}=e,u=vE(e,["width","alignment","miterLimit","cap","join","pixelLine"]),c=Xe(r,u);return c?_e({width:i,alignment:n,miterLimit:s,cap:a,join:o,pixelLine:l},c):null}function wg(r,t){let e=1;const i=r.shapePath.shapePrimitives;for(let n=0;n1&&(E=1);const M=Math.sqrt((1-E)*.5);if(M<1e-6)continue;const C=Math.min(1/M,t);C>e&&(e=C)}}return e}var EE=Object.defineProperty,Pg=Object.getOwnPropertySymbols,AE=Object.prototype.hasOwnProperty,CE=Object.prototype.propertyIsEnumerable,Eg=(r,t,e)=>t in r?EE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jr=(r,t)=>{for(var e in t||(t={}))AE.call(t,e)&&Eg(r,e,t[e]);if(Pg)for(var e of Pg(t))CE.call(t,e)&&Eg(r,e,t[e]);return r};const ME=new lt,Ag=new U,xl=class Me extends Nt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ht("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new ge,this._transform=new U,this._fillStyle=jr({},Me.defaultFillStyle),this._strokeStyle=jr({},Me.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new Mt,this._boundsDirty=!0}clone(){const t=new Me;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=jr({},this._fillStyle),t._strokeStyle=jr({},this._strokeStyle),t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=Xe(t,Me.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Bi(t,Me.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Xe(t,Me.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Xe(t,Me.defaultStrokeStyle),this}texture(t,e,i,n,s,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:s||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?tt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ge,this}fill(t,e){let i;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="stroke"?i=n.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=Xe(t,Me.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(lt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Bi(t,Me.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,n,s,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,n,s,a),this}arcTo(t,e,i,n,s){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,s),this}arcToSvg(t,e,i,n,s,a,o){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,i,n,s,l.a*a+l.c*o+l.tx,l.b*a+l.d*o+l.ty),this}bezierCurveTo(t,e,i,n,s,a,o){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*i+l.c*n+l.tx,l.b*i+l.d*n+l.ty,l.a*s+l.c*a+l.tx,l.b*s+l.d*a+l.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,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,n=this._activePath.instructions,s=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=s,n[0].data[1]=a,this):(this._activePath.moveTo(s,a),this)}quadraticCurveTo(t,e,i,n,s){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,s),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,s){return this._tick++,this._activePath.roundRect(t,e,i,n,s,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,s=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,n,s,a),this}roundPoly(t,e,i,n,s,a){return this._tick++,this._activePath.roundPoly(t,e,i,n,s,a),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,s){return this._tick++,this._activePath.filletRect(t,e,i,n,s),this}chamferRect(t,e,i,n,s,a){return this._tick++,this._activePath.chamferRect(t,e,i,n,s,a),this}star(t,e,i,n,s=0,a=0){return this._tick++,this._activePath.star(t,e,i,n,s,a,this._transform.clone()),this}svg(t){return this._tick++,fg(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:jr({},this._fillStyle),strokeStyle:jr({},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,n,s,a){return t instanceof U?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,s,a),this)}transform(t,e,i,n,s,a){return t instanceof U?(this._transform.append(t),this):(Ag.set(t,e,i,n,s,a),this._transform.append(Ag),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=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e{delete t.promiseCache[e],it.has(e)&&it.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&n()}),i.once("destroy",()=>{r.destroyed||n()}),i}var RE=Object.defineProperty,es=Object.getOwnPropertySymbols,Cg=Object.prototype.hasOwnProperty,Mg=Object.prototype.propertyIsEnumerable,Rg=(r,t,e)=>t in r?RE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,OE=(r,t)=>{for(var e in t||(t={}))Cg.call(t,e)&&Rg(r,e,t[e]);if(es)for(var e of es(t))Mg.call(t,e)&&Rg(r,e,t[e]);return r},GE=(r,t)=>{var e={};for(var i in r)Cg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&es)for(var i of es(r))t.indexOf(i)<0&&Mg.call(r,i)&&(e[i]=r[i]);return e};const IE=".svg",BE="image/svg+xml",Og={extension:{type:S.LoadParser,priority:te.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return ar(r,BE)||le(r,IE)},async load(r,t,e){var i,n;return((n=(i=t.data)==null?void 0:i.parseAsGraphicsContext)!=null?n:this.config.parseAsGraphicsContext)?DE(r):FE(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function FE(r,t,e,i){var n,s,a,o,l,u;const c=await H.get().fetch(r),h=H.get().createImage();h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await c.text())}`,h.crossOrigin=i,await h.decode();const p=(s=(n=t.data)==null?void 0:n.width)!=null?s:h.width,f=(o=(a=t.data)==null?void 0:a.height)!=null?o:h.height,m=((l=t.data)==null?void 0:l.resolution)||je(r),g=Math.ceil(p*m),_=Math.ceil(f*m),y=H.get().createCanvas(g,_),b=y.getContext("2d");b.imageSmoothingEnabled=!0,b.imageSmoothingQuality="high",b.drawImage(h,0,0,p*m,f*m);const x=(u=t.data)!=null?u:{},{parseAsGraphicsContext:v}=x,w=GE(x,["parseAsGraphicsContext"]),T=new ke(OE({resource:y,alphaMode:"premultiply-alpha-on-upload",resolution:m},w));return He(T,e,r)}async function DE(r){const t=await(await H.get().fetch(r)).text(),e=new kt;return e.svg(t),e}const UE=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})(); -`;let Hr=null,Tl=class{constructor(){Hr||(Hr=URL.createObjectURL(new Blob([UE],{type:"application/javascript"}))),this.worker=new Worker(Hr)}};Tl.revokeObjectURL=function(){Hr&&(URL.revokeObjectURL(Hr),Hr=null)};const $E='(function(){"use strict";async function s(a,t){const e=await fetch(a);if(!e.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${a}: ${e.status} ${e.statusText}`);const i=await e.blob();return t==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}self.onmessage=async a=>{try{const t=await s(a.data.data[0],a.data.data[1]);self.postMessage({data:t,uuid:a.data.uuid,id:a.data.id},[t])}catch(t){self.postMessage({error:t,uuid:a.data.uuid,id:a.data.id})}}})();\n';let zr=null,Gg=class{constructor(){zr||(zr=URL.createObjectURL(new Blob([$E],{type:"application/javascript"}))),this.worker=new Worker(zr)}};Gg.revokeObjectURL=function(){zr&&(URL.revokeObjectURL(zr),zr=null)};let Ig=0,Sl,kE=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Tl;e.addEventListener("message",i=>{e.terminate(),Tl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){Sl===void 0&&(Sl=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const i=new Promise((n,s)=>{this._queue.push({id:t,arguments:e,resolve:n,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[Ig]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ig++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};const wl=new kE;var LE=Object.defineProperty,Bg=Object.getOwnPropertySymbols,NE=Object.prototype.hasOwnProperty,XE=Object.prototype.propertyIsEnumerable,Fg=(r,t,e)=>t in r?LE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jE=(r,t)=>{for(var e in t||(t={}))NE.call(t,e)&&Fg(r,e,t[e]);if(Bg)for(var e of Bg(t))XE.call(t,e)&&Fg(r,e,t[e]);return r};const HE=[".jpeg",".jpg",".png",".webp",".avif"],zE=["image/jpeg","image/png","image/webp","image/avif"];async function Dg(r,t){var e;const i=await H.get().fetch(r);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} ${i.statusText}`);const n=await i.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(n,{premultiplyAlpha:"none"}):createImageBitmap(n)}const Pl={name:"loadTextures",id:"texture",extension:{type:S.LoadParser,priority:te.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return ar(r,zE)||le(r,HE)},async load(r,t,e){var i;let n=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await wl.isImageBitmapSupported()?n=await wl.loadImageBitmap(r,t):n=await Dg(r,t):n=await new Promise((a,o)=>{n=H.get().createImage(),n.crossOrigin=this.config.crossOrigin,n.src=r,n.complete?a(n):(n.onload=()=>{a(n)},n.onerror=o)});const s=new ke(jE({resource:n,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||je(r)},t.data));return He(s,e,r)},unload(r){r.destroy(!0)}};var WE=Object.defineProperty,VE=Object.defineProperties,YE=Object.getOwnPropertyDescriptors,Ug=Object.getOwnPropertySymbols,KE=Object.prototype.hasOwnProperty,qE=Object.prototype.propertyIsEnumerable,$g=(r,t,e)=>t in r?WE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,El=(r,t)=>{for(var e in t||(t={}))KE.call(t,e)&&$g(r,e,t[e]);if(Ug)for(var e of Ug(t))qE.call(t,e)&&$g(r,e,t[e]);return r},kg=(r,t)=>VE(r,YE(t));const ZE=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Al,Cl;function Lg(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Xg(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Ng(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",n),r.load();function i(){s(),t()}function n(a){s(),e(a)}function s(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",n)}})}function Xg(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function QE(){const r=[],t=[];for(const e of ZE){const i=wr.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ci(i)&&(r.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:r,validVideoMime:t}}const jg={name:"loadVideo",id:"video",extension:{type:S.LoadParser,name:"loadVideo"},test(r){if(!Al||!Cl){const{validVideoExtensions:i,validVideoMime:n}=QE();Al=i,Cl=n}const t=ar(r,Cl),e=le(r,Al);return t||e},async load(r,t,e){var i,n;const s=El(kg(El({},wr.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r),alphaMode:((n=t.data)==null?void 0:n.alphaMode)||await eo()}),t.data),a=document.createElement("video"),o={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(o).forEach(c=>{const h=o[c];h!==void 0&&a.setAttribute(c,h)}),s.muted===!0&&(a.muted=!0),Lg(a,r,s.crossorigin);const l=document.createElement("source");let u;if(s.mime)u=s.mime;else if(r.startsWith("data:"))u=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=wr.MIME_TYPES[c]||`video/${c}`}return l.src=r,u&&(l.type=u),new Promise((c,h)=>{s.preload&&!s.autoPlay&&a.load(),a.addEventListener("canplay",p),a.addEventListener("error",f),l.addEventListener("error",f),a.appendChild(l);async function p(){const g=new wr(kg(El({},s),{resource:a}));m(),t.data.preload&&await Ng(a),c(He(g,e,r))}function f(g){m(),h(g)}function m(){a.removeEventListener("canplay",p),a.removeEventListener("error",f),l.removeEventListener("error",f)}})},unload(r){r.destroy(!0)}},Ml={extension:{type:S.ResolveParser,name:"resolveTexture"},test:Pl.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Hg={extension:{type:S.ResolveParser,priority:-2,name:"resolveJson"},test:r=>$e.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Ml.parse};var JE=Object.defineProperty,zg=Object.getOwnPropertySymbols,tA=Object.prototype.hasOwnProperty,eA=Object.prototype.propertyIsEnumerable,Wg=(r,t,e)=>t in r?JE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vg=(r,t)=>{for(var e in t||(t={}))tA.call(t,e)&&Wg(r,e,t[e]);if(zg)for(var e of zg(t))eA.call(t,e)&&Wg(r,e,t[e]);return r};class Yg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new $e,this.loader=new Wf,this.cache=it,this._backgroundLoader=new Bf(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,n;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const s=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,a=typeof s=="number"?[s]:s,o=await this._detectFormats({preferredFormats:(n=t.texturePreference)==null?void 0:n.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:a}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions=Vg(Vg({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=fi(t),n=oe(t).map(o=>{if(typeof o!="string"){const l=this.resolver.getAlias(o);return l.some(u=>!this.resolver.hasKey(u))&&this.add(o),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),s=this.resolver.resolve(n),a=await this._mapLoadToResolve(s,e);return i?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),s={},a=Object.keys(n);let o=0;const l=[],u=()=>{e==null||e(l.reduce((h,p)=>h+p,0)/o)},c=a.map((h,p)=>{const f=n[h],m=Object.values(f),g=[...new Set(m.flat())].reduce((_,y)=>_+(y.progressSize||1),0);return l.push(0),o+=g,this._mapLoadToResolve(f,_=>{l[p]=_*g,u()}).then(_=>{s[h]=_})});return await Promise.all(c),i?s[t[0]]:s}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return it.get(t);const e={};for(let i=0;i{const o=n[a.src],l=[a.src];a.alias&&l.push(...a.alias),l.forEach(u=>{s[u]=o}),it.set(l,o)}),s}async unload(t){this._initialized||await this.init();const e=oe(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=oe(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{it.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,n)=>e.indexOf(i)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Fi=new Yg;X.handleByList(S.LoadParser,Fi.loader.parsers).handleByList(S.ResolveParser,Fi.resolver.parsers).handleByList(S.CacheParser,Fi.cache.parsers).handleByList(S.DetectionParser,Fi.detections),X.add(Ff,$f,Df,Xf,kf,Lf,Nf,Vf,Yf,Qf,Og,Pl,jg,If,Gf,Ml,Hg);const Kg={loader:S.LoadParser,resolver:S.ResolveParser,cache:S.CacheParser,detection:S.DetectionParser};X.handle(S.Asset,r=>{const t=r.ref;Object.entries(Kg).filter(([e])=>!!t[e]).forEach(([e,i])=>{var n;return X.add(Object.assign(t[e],{extension:(n=t[e].extension)!=null?n:i}))})},r=>{const t=r.ref;Object.keys(Kg).filter(e=>!!t[e]).forEach(e=>X.remove(t[e]))});const rA={extension:{type:S.DetectionParser,priority:3},test:async()=>!!(await Ei()||Pi()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};var iA=Object.defineProperty,nA=Object.defineProperties,sA=Object.getOwnPropertyDescriptors,qg=Object.getOwnPropertySymbols,aA=Object.prototype.hasOwnProperty,oA=Object.prototype.propertyIsEnumerable,Zg=(r,t,e)=>t in r?iA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lA=(r,t)=>{for(var e in t||(t={}))aA.call(t,e)&&Zg(r,e,t[e]);if(qg)for(var e of qg(t))oA.call(t,e)&&Zg(r,e,t[e]);return r},uA=(r,t)=>nA(r,sA(t));class Di extends ft{constructor(t){super(uA(lA({},t),{mipLevelCount:t.resource.length})),this.uploadMethodId="compressed"}}let rs;function Rl(){if(rs)return rs;const r=H.get().createCanvas(1,1).getContext("webgl");return r?(rs=[...r.getExtension("EXT_texture_compression_bptc")?["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc")?["bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc_srgb")?["bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"]:[],...r.getExtension("EXT_texture_compression_rgtc")?["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"]:[],...r.getExtension("WEBGL_compressed_texture_etc")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","eac-r11unorm","eac-rg11unorm"]:[],...r.getExtension("WEBGL_compressed_texture_astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],rs):[]}let is;async function Ol(){if(is)return is;const r=await H.get().getNavigator().gpu.requestAdapter();return is=[...r.features.has("texture-compression-bc")?["bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.features.has("texture-compression-etc2")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"]:[],...r.features.has("texture-compression-astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],is}let Gl;async function Il(){return Gl!==void 0||(Gl=await(async()=>{const r=await Ei(),t=Pi();if(r&&t){const e=await Ol(),i=Rl();return e.filter(n=>i.includes(n))}else{if(r)return await Ol();if(t)return Rl()}return[]})()),Gl}const Qg=["r8unorm","r8snorm","r8uint","r8sint","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32uint","r32sint","r32float","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb9e5ufloat","rgb10a2unorm","rg11b10ufloat","rg32uint","rg32sint","rg32float","rgba16uint","rgba16sint","rgba16float","rgba32uint","rgba32sint","rgba32float","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"];let ns;async function Ui(){if(ns!==void 0)return ns;const r=await Il();return ns=[...Qg,...r],ns}const cA='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=(async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)})})();\n';let Wr=null,Jg=class{constructor(){Wr||(Wr=URL.createObjectURL(new Blob([cA],{type:"application/javascript"}))),this.worker=new Worker(Wr)}};Jg.revokeObjectURL=function(){Wr&&(URL.revokeObjectURL(Wr),Wr=null)};const ss={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.wasm"};function hA(r){Object.assign(ss,r)}let $i;const t_={};function dA(r){return $i||($i=new Jg().worker,$i.onmessage=t=>{const{success:e,url:i,textureOptions:n}=t.data;e||console.warn("Failed to load Basis texture",i),t_[i](n)},$i.postMessage({type:"init",jsUrl:ss.jsUrl,wasmUrl:ss.wasmUrl,supportedTextures:r})),$i}function e_(r,t){const e=dA(t);return new Promise(i=>{t_[r]=i,e.postMessage({type:"load",url:r})})}var pA=Object.defineProperty,fA=Object.defineProperties,mA=Object.getOwnPropertyDescriptors,r_=Object.getOwnPropertySymbols,gA=Object.prototype.hasOwnProperty,_A=Object.prototype.propertyIsEnumerable,i_=(r,t,e)=>t in r?pA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,yA=(r,t)=>{for(var e in t||(t={}))gA.call(t,e)&&i_(r,e,t[e]);if(r_)for(var e of r_(t))_A.call(t,e)&&i_(r,e,t[e]);return r},bA=(r,t)=>fA(r,mA(t));const vA={extension:{type:S.LoadParser,priority:te.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return le(r,[".basis"])},async load(r,t,e){var i;const n=await Ui(),s=await e_(r,n),a=new Di(bA(yA({},s),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function xA(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const n=[];for(let s=0;s(r[r.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",r[r.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",r[r.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",r[r.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",r[r.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",r[r.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",r[r.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",r[r.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",r[r.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",r[r.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",r[r.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",r[r.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",r[r.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",r[r.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",r[r.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",r[r.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",r[r.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",r[r.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",r[r.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",r[r.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",r[r.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",r[r.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",r[r.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",r[r.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",r[r.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",r[r.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",r[r.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",r[r.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",r[r.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",r[r.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",r[r.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",r[r.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",r[r.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",r[r.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",r[r.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",r[r.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",r[r.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",r[r.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",r[r.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",r[r.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",r[r.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",r[r.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",r[r.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",r[r.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",r[r.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",r[r.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",r[r.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",r[r.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",r[r.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",r[r.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",r[r.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",r[r.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",r[r.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",r[r.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",r[r.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",r[r.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",r[r.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",r[r.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",r[r.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",r[r.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",r[r.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",r[r.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",r[r.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",r[r.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",r[r.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",r[r.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",r[r.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",r[r.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",r[r.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",r[r.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",r[r.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",r[r.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",r[r.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",r[r.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",r[r.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",r[r.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",r[r.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",r[r.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",r[r.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",r[r.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",r[r.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",r[r.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",r[r.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",r[r.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",r[r.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",r[r.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",r[r.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",r[r.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",r[r.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",r[r.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",r[r.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",r[r.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",r[r.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",r[r.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",r[r.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",r[r.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",r[r.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",r[r.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",r[r.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",r[r.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",r[r.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",r[r.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",r[r.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",r[r.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",r[r.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",r[r.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",r[r.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",r[r.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",r[r.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",r[r.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",r[r.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",r[r.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",r))(Bl||{}),Fl=(r=>(r[r.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",r[r.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",r[r.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",r))(Fl||{});function Bt(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var qt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=Bt("UYVY")]="UYVY",r[r.R8G8_B8G8=Bt("RGBG")]="R8G8_B8G8",r[r.YUY2=Bt("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=Bt("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=Bt("DXT1")]="DXT1",r[r.DXT2=Bt("DXT2")]="DXT2",r[r.DXT3=Bt("DXT3")]="DXT3",r[r.DXT4=Bt("DXT4")]="DXT4",r[r.DXT5=Bt("DXT5")]="DXT5",r[r.ATI1=Bt("ATI1")]="ATI1",r[r.AT1N=Bt("AT1N")]="AT1N",r[r.ATI2=Bt("ATI2")]="ATI2",r[r.AT2N=Bt("AT2N")]="AT2N",r[r.BC4U=Bt("BC4U")]="BC4U",r[r.BC4S=Bt("BC4S")]="BC4S",r[r.BC5U=Bt("BC5U")]="BC5U",r[r.BC5S=Bt("BC5S")]="BC5S",r[r.DX10=Bt("DX10")]="DX10",r))(qt||{});const Dl={[qt.DXT1]:"bc1-rgba-unorm",[qt.DXT2]:"bc2-rgba-unorm",[qt.DXT3]:"bc2-rgba-unorm",[qt.DXT4]:"bc3-rgba-unorm",[qt.DXT5]:"bc3-rgba-unorm",[qt.ATI1]:"bc4-r-unorm",[qt.BC4U]:"bc4-r-unorm",[qt.BC4S]:"bc4-r-snorm",[qt.ATI2]:"bc5-rg-unorm",[qt.BC5U]:"bc5-rg-unorm",[qt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Zt={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},Z={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:wA,HEADER_DX10_FIELDS:PA,DXGI_FORMAT:Bl,D3D10_RESOURCE_DIMENSION:Fl,D3DFMT:qt},n_={"bc1-rgba-unorm":8,"bc1-rgba-unorm-srgb":8,"bc2-rgba-unorm":16,"bc2-rgba-unorm-srgb":16,"bc3-rgba-unorm":16,"bc3-rgba-unorm-srgb":16,"bc4-r-unorm":8,"bc4-r-snorm":8,"bc5-rg-unorm":16,"bc5-rg-snorm":16,"bc6h-rgb-ufloat":16,"bc6h-rgb-float":16,"bc7-rgba-unorm":16,"bc7-rgba-unorm-srgb":16};function s_(r,t){const{format:e,fourCC:i,width:n,height:s,dataOffset:a,mipmapCount:o}=AA(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(o<=1)return{format:e,width:n,height:s,resource:[new Uint8Array(r,a)],alphaMode:"no-premultiply-alpha"};const l=EA(e,n,s,a,o,r);return{format:e,width:n,height:s,resource:l,alphaMode:"no-premultiply-alpha"}}function EA(r,t,e,i,n,s){const a=[],o=n_[r];let l=t,u=e,c=i;for(let h=0;h>1,1),u=Math.max(u>>1,1)}return a}function AA(r){const t=new Uint32Array(r,0,Z.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[Z.HEADER_FIELDS.MAGIC]!==Z.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[Z.HEADER_FIELDS.HEIGHT],i=t[Z.HEADER_FIELDS.WIDTH],n=Math.max(1,t[Z.HEADER_FIELDS.MIPMAP_COUNT]),s=t[Z.HEADER_FIELDS.PF_FLAGS],a=t[Z.HEADER_FIELDS.FOURCC],o=CA(t,s,a,r),l=Z.MAGIC_SIZE+Z.HEADER_SIZE+(a===Z.D3DFMT.DX10?Z.HEADER_DX10_SIZE:0);return{format:o,fourCC:a,width:i,height:e,dataOffset:l,mipmapCount:n}}function CA(r,t,e,i){if(t&Z.PIXEL_FORMAT_FLAGS.FOURCC){if(e===Z.D3DFMT.DX10){const n=new Uint32Array(i,Z.MAGIC_SIZE+Z.HEADER_SIZE,Z.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(n[Z.HEADER_DX10_FIELDS.MISC_FLAG]===Z.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(n[Z.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===Z.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const s=n[Z.HEADER_DX10_FIELDS.DXGI_FORMAT];if(s in Zt)return Zt[s];throw new Error(`DDSParser cannot parse texture data with DXGI format ${s}`)}if(e in Dl)return Dl[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&Z.PIXEL_FORMAT_FLAGS.RGB||t&Z.PIXEL_FORMAT_FLAGS.RGBA)return MA(r);throw t&Z.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&Z.PIXEL_FORMAT_FLAGS.LUMINANCE||t&Z.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&Z.PIXEL_FORMAT_FLAGS.ALPHA||t&Z.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function MA(r){const t=r[Z.HEADER_FIELDS.RGB_BITCOUNT],e=r[Z.HEADER_FIELDS.R_BIT_MASK],i=r[Z.HEADER_FIELDS.G_BIT_MASK],n=r[Z.HEADER_FIELDS.B_BIT_MASK],s=r[Z.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&i===65280&&n===16711680&&s===4278190080)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&n===255&&s===4278190080)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&n===1023&&s===3221225472)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&n===31&&s===32768)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&n===31&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&n===15&&s===61440)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&n===0&&s===65280)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration: - bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${s}`)}var RA=Object.defineProperty,OA=Object.defineProperties,GA=Object.getOwnPropertyDescriptors,a_=Object.getOwnPropertySymbols,IA=Object.prototype.hasOwnProperty,BA=Object.prototype.propertyIsEnumerable,o_=(r,t,e)=>t in r?RA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FA=(r,t)=>{for(var e in t||(t={}))IA.call(t,e)&&o_(r,e,t[e]);if(a_)for(var e of a_(t))BA.call(t,e)&&o_(r,e,t[e]);return r},DA=(r,t)=>OA(r,GA(t));const UA={extension:{type:S.LoadParser,priority:te.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return le(r,[".dds"])},async load(r,t,e){var i;const n=await Ui(),s=await(await fetch(r)).arrayBuffer(),a=s_(s,n),o=new Di(DA(FA({},a),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var l_=(r=>(r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGBA=6408]="RGBA",r[r.RGBA8UI=36220]="RGBA8UI",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.RGBA8I=36238]="RGBA8I",r[r.RGBA8=32856]="RGBA8",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(l_||{}),$A=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))($A||{}),kA=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(kA||{});const Pt={FILE_HEADER_SIZE:64,FILE_IDENTIFIER:[171,75,84,88,32,49,49,187,13,10,26,10],FORMATS_TO_COMPONENTS:{6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:{33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,36283:.5,36284:.5,36285:1,36286:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,37808:1,37840:1,37809:.8,37841:.8,37810:.64,37842:.64,37811:.53375,37843:.53375,37812:.445,37844:.445,37813:.4,37845:.4,37814:.33375,37846:.33375,37815:.25,37847:.25,37816:.32,37848:.32,37817:.26625,37849:.26625,37818:.2,37850:.2,37819:.16,37851:.16,37820:.13375,37852:.13375,37821:.11125,37853:.11125,36492:1,36493:1,36494:1,36495:1},INTERNAL_FORMAT_TO_TEXTURE_FORMATS:{33776:"bc1-rgba-unorm",33777:"bc1-rgba-unorm",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",35916:"bc1-rgba-unorm-srgb",35917:"bc1-rgba-unorm-srgb",35918:"bc2-rgba-unorm-srgb",35919:"bc3-rgba-unorm-srgb",36283:"bc4-r-unorm",36284:"bc4-r-snorm",36285:"bc5-rg-unorm",36286:"bc5-rg-snorm",37488:"eac-r11unorm",37490:"eac-rg11snorm",37492:"etc2-rgb8unorm",37496:"etc2-rgba8unorm",37493:"etc2-rgb8unorm-srgb",37497:"etc2-rgba8unorm-srgb",37494:"etc2-rgb8a1unorm",37495:"etc2-rgb8a1unorm-srgb",37808:"astc-4x4-unorm",37840:"astc-4x4-unorm-srgb",37809:"astc-5x4-unorm",37841:"astc-5x4-unorm-srgb",37810:"astc-5x5-unorm",37842:"astc-5x5-unorm-srgb",37811:"astc-6x5-unorm",37843:"astc-6x5-unorm-srgb",37812:"astc-6x6-unorm",37844:"astc-6x6-unorm-srgb",37813:"astc-8x5-unorm",37845:"astc-8x5-unorm-srgb",37814:"astc-8x6-unorm",37846:"astc-8x6-unorm-srgb",37815:"astc-8x8-unorm",37847:"astc-8x8-unorm-srgb",37816:"astc-10x5-unorm",37848:"astc-10x5-unorm-srgb",37817:"astc-10x6-unorm",37849:"astc-10x6-unorm-srgb",37818:"astc-10x8-unorm",37850:"astc-10x8-unorm-srgb",37819:"astc-10x10-unorm",37851:"astc-10x10-unorm-srgb",37820:"astc-12x10-unorm",37852:"astc-12x10-unorm-srgb",37821:"astc-12x12-unorm",37853:"astc-12x12-unorm-srgb",36492:"bc7-rgba-unorm",36493:"bc7-rgba-unorm-srgb",36494:"bc6h-rgb-float",36495:"bc6h-rgb-ufloat",35907:"rgba8unorm-srgb",36759:"rgba8snorm",36220:"rgba8uint",36238:"rgba8sint",6408:"rgba8unorm"},FIELDS:{FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},TYPES_TO_BYTES_PER_COMPONENT:{5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},TYPES_TO_BYTES_PER_PIXEL:{32819:2,32820:2,33635:2},ENDIANNESS:67305985};function u_(r,t){const e=new DataView(r);if(!jA(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:n,glFormat:s,glInternalFormat:a,pixelWidth:o,pixelHeight:l,numberOfMipmapLevels:u,offset:c}=XA(e),h=Pt.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[a];if(!h)throw new Error(`Unknown texture format ${a}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const p=NA(n,s,a),f=LA(e,n,p,o,l,c,u,i);return{format:h,width:o,height:l,resource:f,alphaMode:"no-premultiply-alpha"}}function LA(r,t,e,i,n,s,a,o){const l=i+3&-4,u=n+3&-4;let c=i*n;t===0&&(c=l*u);let h=c*e,p=i,f=n,m=l,g=u,_=s;const y=new Array(a);for(let b=0;b>1||1,f=f>>1||1,m=p+4-1&-4,g=f+4-1&-4,h=m*g*e}return y}function NA(r,t,e){let i=Pt.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(Pt.TYPES_TO_BYTES_PER_COMPONENT[r]?i=Pt.TYPES_TO_BYTES_PER_COMPONENT[r]*Pt.FORMATS_TO_COMPONENTS[t]:i=Pt.TYPES_TO_BYTES_PER_PIXEL[r]),i===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return i}function XA(r){const t=r.getUint32(Pt.FIELDS.ENDIANNESS,!0)===Pt.ENDIANNESS,e=r.getUint32(Pt.FIELDS.GL_TYPE,t),i=r.getUint32(Pt.FIELDS.GL_FORMAT,t),n=r.getUint32(Pt.FIELDS.GL_INTERNAL_FORMAT,t),s=r.getUint32(Pt.FIELDS.PIXEL_WIDTH,t),a=r.getUint32(Pt.FIELDS.PIXEL_HEIGHT,t)||1,o=r.getUint32(Pt.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(Pt.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(Pt.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(Pt.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(Pt.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(a===0||o!==1)throw new Error("Only 2D textures are supported");if(u!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(l!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:n,pixelWidth:s,pixelHeight:a,numberOfMipmapLevels:c,offset:Pt.FILE_HEADER_SIZE+h}}function jA(r){for(let t=0;tt in r?HA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KA=(r,t)=>{for(var e in t||(t={}))VA.call(t,e)&&h_(r,e,t[e]);if(c_)for(var e of c_(t))YA.call(t,e)&&h_(r,e,t[e]);return r},qA=(r,t)=>zA(r,WA(t));const ZA={extension:{type:S.LoadParser,priority:te.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return le(r,".ktx")},async load(r,t,e){var i;const n=await Ui(),s=await(await fetch(r)).arrayBuffer(),a=u_(s,n),o=new Di(qA(KA({},a),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},QA='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=T(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=(async r=>{var t;const n=r.data;try{const o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}catch(o){self.postMessage({type:"error",err:o,url:n.url})}})})();\n';let Vr=null;class d_{constructor(){Vr||(Vr=URL.createObjectURL(new Blob([QA],{type:"application/javascript"}))),this.worker=new Worker(Vr)}}d_.revokeObjectURL=function(){Vr&&(URL.revokeObjectURL(Vr),Vr=null)};const as={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.wasm"};function JA(r){Object.assign(as,r)}let ki;const p_={},f_={};function tC(r){return ki||(ki=new d_().worker,ki.onmessage=t=>{const{err:e,success:i,url:n,textureOptions:s}=t.data;if(e){f_[n](e);return}i||console.warn("Failed to load KTX texture",n),p_[n](s)},ki.postMessage({type:"init",jsUrl:as.jsUrl,wasmUrl:as.wasmUrl,supportedTextures:r})),ki}function m_(r,t){const e=tC(t);return new Promise((i,n)=>{p_[r]=i,f_[r]=n,e.postMessage({type:"load",url:r})})}var eC=Object.defineProperty,rC=Object.defineProperties,iC=Object.getOwnPropertyDescriptors,g_=Object.getOwnPropertySymbols,nC=Object.prototype.hasOwnProperty,sC=Object.prototype.propertyIsEnumerable,__=(r,t,e)=>t in r?eC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aC=(r,t)=>{for(var e in t||(t={}))nC.call(t,e)&&__(r,e,t[e]);if(g_)for(var e of g_(t))sC.call(t,e)&&__(r,e,t[e]);return r},oC=(r,t)=>rC(r,iC(t));const lC={extension:{type:S.LoadParser,priority:te.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return le(r,".ktx2")},async load(r,t,e){var i;const n=await Ui(),s=await m_(r,n),a=new Di(oC(aC({},s),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(a,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},Ul={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:y_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:y_}};function uC(r){const t=r.format;if(Ul[t]){const e=Ul[t].convertFunction,i=r.resource;for(let n=0;nle(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const n=r.split(".");if(n.length>2){const s=n[n.length-2];os.includes(s)&&(i=s)}else i=n[n.length-1];return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let ls;const _C={extension:{type:S.DetectionParser,priority:2},test:async()=>!!(await Ei()||Pi()),add:async r=>{const t=await Il();return ls=yC(t),[...ls,...r]},remove:async r=>ls?r.filter(t=>!(t in ls)):r};function yC(r){const t=["basis"],e={};return r.forEach(i=>{const n=i.split("-")[0];n&&!e[n]&&(e[n]=!0,t.push(n))}),t.sort((i,n)=>{const s=os.indexOf(i),a=os.indexOf(n);return s===-1?1:a===-1?-1:s-a}),t}const bC=new Mt,vC=new U,Li=new ut,$l=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){if(t.cullable&&t.measurable&&t.includeInBuild)if(t.cullArea){Li.x=e.x,Li.y=e.y,Li.width=e.width,Li.height=e.height;const n=i?t.worldTransform:t.getGlobalTransform(vC,i);t.culled=!Li.intersects(t.cullArea,n)}else{const n=li(t,i,bC);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{var e;const i=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;x_.shared.cull(this.stage,this.renderer.screen,i),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}T_.extension={priority:10,type:S.Application,name:"culler"};const xC={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return fw})}};var S_=` + `}},Rm={};function Wn(r){let t=Rm[r];if(t)return t;const e=new Int32Array(r);for(let i=0;ie&&this.remove(e,...t))}destroy(...t){this.removeAll(...t),this.items=Object.create(null),this._renderer=null,this._onUnload=null}}function rl(r,t,e,i,n,s,a,o=null){let l=0;e*=t,n*=s;const u=o.a,c=o.b,h=o.c,p=o.d,f=o.tx,m=o.ty;for(;l>16|t&65280|(t&255)<<16,i=this.renderable;return i?Oe(e,i.groupColor)+(this.alpha*i.groupAlpha*255<<24):e+(this.alpha*255<<24)}get transform(){var t;return((t=this.renderable)==null?void 0:t.groupTransform)||zE}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}}var WE=Object.defineProperty,VE=Object.defineProperties,YE=Object.getOwnPropertyDescriptors,Gm=Object.getOwnPropertySymbols,KE=Object.prototype.hasOwnProperty,qE=Object.prototype.propertyIsEnumerable,Im=(r,t,e)=>t in r?WE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qn=(r,t)=>{for(var e in t||(t={}))KE.call(t,e)&&Im(r,e,t[e]);if(Gm)for(var e of Gm(t))qE.call(t,e)&&Im(r,e,t[e]);return r},Zn=(r,t)=>VE(r,YE(t));const kr={extension:{type:S.ShapeBuilder,name:"circle"},build(r,t){let e,i,n,s,a,o;if(r.type==="circle"){const v=r;if(a=o=v.radius,a<=0)return!1;e=v.x,i=v.y,n=s=0}else if(r.type==="ellipse"){const v=r;if(a=v.halfWidth,o=v.halfHeight,a<=0||o<=0)return!1;e=v.x,i=v.y,n=s=0}else{const v=r,w=v.width/2,T=v.height/2;e=v.x+w,i=v.y+T,a=o=Math.max(0,Math.min(v.radius,Math.min(w,T))),n=w-a,s=T-o}if(n<0||s<0)return!1;const l=Math.ceil(2.3*Math.sqrt(a+o)),u=l*8+(n?4:0)+(s?4:0);if(u===0)return!1;if(l===0)return t[0]=t[6]=e+n,t[1]=t[3]=i+s,t[2]=t[4]=e-n,t[5]=t[7]=i-s,!0;let c=0,h=l*4+(n?2:0)+2,p=h,f=u,m=n+a,g=s,_=e+m,y=e-m,b=i+g;if(t[c++]=_,t[c++]=b,t[--h]=b,t[--h]=y,s){const v=i-g;t[p++]=y,t[p++]=v,t[--f]=v,t[--f]=_}for(let v=1;v0&&(n[s++]=l,n[s++]=u,n[s++]=l-1),l++;n[s++]=u+1,n[s++]=u,n[s++]=l-1}},Bm=Zn(qn({},kr),{extension:Zn(qn({},kr.extension),{name:"ellipse"})}),Fm=Zn(qn({},kr),{extension:Zn(qn({},kr.extension),{name:"roundedRectangle"})}),nl=1e-4,sl=1e-4;function Dm(r){const t=r.length;if(t<6)return 1;let e=0;for(let i=0,n=r[t-2],s=r[t-1];ih&&(h+=Math.PI*2);let p=c;const f=h-c,m=Math.abs(f),g=Math.sqrt(l*l+u*u),_=(15*m*Math.sqrt(g)/Math.PI>>0)+1,y=f/_;if(p+=y,o){a.push(r,t),a.push(e,i);for(let b=1,x=p;b<_;b++,x+=y)a.push(r,t),a.push(r+Math.sin(x)*g,t+Math.cos(x)*g);a.push(r,t),a.push(n,s)}else{a.push(e,i),a.push(r,t);for(let b=1,x=p;b<_;b++,x+=y)a.push(r+Math.sin(x)*g,t+Math.cos(x)*g),a.push(r,t);a.push(n,s),a.push(r,t)}return _*2}function Qn(r,t,e,i,n,s){const a=nl;if(r.length===0)return;const o=t;let l=o.alignment;if(t.alignment!==.5){let j=Dm(r);e&&(j*=-1),l=(l-.5)*j+.5}const u=new lt(r[0],r[1]),c=new lt(r[r.length-2],r[r.length-1]),h=i,p=Math.abs(u.x-c.x)=0&&(o.join==="round"?g+=ur(T,E,T-C*O,E-A*O,T-G*O,E-F*O,f,!1)+4:g+=2,f.push(T-G*I,E-F*I),f.push(T+G*O,E+F*O));continue}const _t=(-C+v)*(-A+E)-(-C+T)*(-A+w),et=(-G+P)*(-F+E)-(-G+T)*(-F+M),st=(J*et-X*_t)/z,nt=(k*_t-K*et)/z,ot=(st-T)*(st-T)+(nt-E)*(nt-E),gt=T+(st-T)*O,yt=E+(nt-E)*O,pt=T-(st-T)*I,Y=E-(nt-E)*I,Rt=Math.min(J*J+K*K,X*X+k*k),Ct=rt?O:I,ce=Rt+Ct*Ct*b;ot<=ce?o.join==="bevel"||ot/b>x?(rt?(f.push(gt,yt),f.push(T+C*I,E+A*I),f.push(gt,yt),f.push(T+G*I,E+F*I)):(f.push(T-C*O,E-A*O),f.push(pt,Y),f.push(T-G*O,E-F*O),f.push(pt,Y)),g+=2):o.join==="round"?rt?(f.push(gt,yt),f.push(T+C*I,E+A*I),g+=ur(T,E,T+C*I,E+A*I,T+G*I,E+F*I,f,!0)+4,f.push(gt,yt),f.push(T+G*I,E+F*I)):(f.push(T-C*O,E-A*O),f.push(pt,Y),g+=ur(T,E,T-C*O,E-A*O,T-G*O,E-F*O,f,!1)+4,f.push(T-G*O,E-F*O),f.push(pt,Y)):(f.push(gt,yt),f.push(pt,Y)):(f.push(T-C*O,E-A*O),f.push(T+C*I,E+A*I),o.join==="round"?rt?g+=ur(T,E,T+C*I,E+A*I,T+G*I,E+F*I,f,!0)+2:g+=ur(T,E,T-C*O,E-A*O,T-G*O,E-F*O,f,!1)+2:o.join==="miter"&&ot/b<=x&&(rt?(f.push(pt,Y),f.push(pt,Y)):(f.push(gt,yt),f.push(gt,yt)),g+=2),f.push(T-G*O,E-F*O),f.push(T+G*I,E+F*I),g+=2)}v=r[(m-2)*2],w=r[(m-2)*2+1],T=r[(m-1)*2],E=r[(m-1)*2+1],C=-(w-E),A=v-T,R=Math.sqrt(C*C+A*A),C/=R,A/=R,C*=y,A*=y,f.push(T-C*O,E-A*O),f.push(T+C*I,E+A*I),h||(o.cap==="round"?g+=ur(T-C*(O-I)*.5,E-A*(O-I)*.5,T-C*O,E-A*O,T+C*I,E+A*I,f,!1)+2:o.cap==="square"&&(g+=Um(T,E,C,A,O,I,!1,f)));const L=sl*sl;for(let j=_;j0&&a>0?(t[0]=i,t[1]=n,t[2]=i+s,t[3]=n,t[4]=i+s,t[5]=n+a,t[6]=i,t[7]=n+a,!0):!1},triangulate(r,t,e,i,n,s){let a=0;i*=e,t[i+a]=r[0],t[i+a+1]=r[1],a+=e,t[i+a]=r[2],t[i+a+1]=r[3],a+=e,t[i+a]=r[6],t[i+a+1]=r[7],a+=e,t[i+a]=r[4],t[i+a+1]=r[5],a+=e;const o=i/e;n[s++]=o,n[s++]=o+1,n[s++]=o+2,n[s++]=o+1,n[s++]=o+3,n[s++]=o+2}},Nm={extension:{type:S.ShapeBuilder,name:"triangle"},build(r,t){return t[0]=r.x,t[1]=r.y,t[2]=r.x2,t[3]=r.y2,t[4]=r.x3,t[5]=r.y3,!0},triangulate(r,t,e,i,n,s){let a=0;i*=e,t[i+a]=r[0],t[i+a+1]=r[1],a+=e,t[i+a]=r[2],t[i+a+1]=r[3],a+=e,t[i+a]=r[4],t[i+a+1]=r[5];const o=i/e;n[s++]=o,n[s++]=o+1,n[s++]=o+2}};var QE=Object.defineProperty,Xm=Object.getOwnPropertySymbols,JE=Object.prototype.hasOwnProperty,tP=Object.prototype.propertyIsEnumerable,jm=(r,t,e)=>t in r?QE(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Hm=(r,t)=>{for(var e in t||(t={}))JE.call(t,e)&&jm(r,e,t[e]);if(Xm)for(var e of Xm(t))tP.call(t,e)&&jm(r,e,t[e]);return r};const zm=[{offset:0,color:"white"},{offset:1,color:"black"}],ol=class Ah{constructor(...t){this.uid=ht("fillGradient"),this._tick=0,this.type="linear",this.colorStops=[];var e;let i=eP(t);const n=i.type==="radial"?Ah.defaultRadialOptions:Ah.defaultLinearOptions;i=Hm(Hm({},n),he(i)),this._textureSize=i.textureSize,this._wrapMode=i.wrapMode,i.type==="radial"?(this.center=i.center,this.outerCenter=(e=i.outerCenter)!=null?e:this.center,this.innerRadius=i.innerRadius,this.outerRadius=i.outerRadius,this.scale=i.scale,this.rotation=i.rotation):(this.start=i.start,this.end=i.end),this.textureSpace=i.textureSpace,this.type=i.type,i.colorStops.forEach(s=>{this.addColorStop(s.offset,s.color)})}addColorStop(t,e){return this.colorStops.push({offset:t,color:tt.shared.setValue(e).toHexa()}),this}buildLinearGradient(){if(this.texture)return;let{x:t,y:e}=this.start,{x:i,y:n}=this.end,s=i-t,a=n-e;const o=s<0||a<0;if(this._wrapMode==="clamp-to-edge"){if(s<0){const _=t;t=i,i=_,s*=-1}if(a<0){const _=e;e=n,n=_,a*=-1}}const l=this.colorStops.length?this.colorStops:zm,u=this._textureSize,{canvas:c,context:h}=Vm(u,1),p=o?h.createLinearGradient(this._textureSize,0,0,0):h.createLinearGradient(0,0,this._textureSize,0);Wm(p,l),h.fillStyle=p,h.fillRect(0,0,u,1),this.texture=new D({source:new ke({resource:c,addressMode:this._wrapMode})});const f=Math.sqrt(s*s+a*a),m=Math.atan2(a,s),g=new U;g.scale(f/u,1),g.rotate(m),g.translate(t,e),this.textureSpace==="local"&&g.scale(u,u),this.transform=g}buildGradient(){this.texture||this._tick++,this.type==="linear"?this.buildLinearGradient():this.buildRadialGradient()}buildRadialGradient(){if(this.texture)return;const t=this.colorStops.length?this.colorStops:zm,e=this._textureSize,{canvas:i,context:n}=Vm(e,e),{x:s,y:a}=this.center,{x:o,y:l}=this.outerCenter,u=this.innerRadius,c=this.outerRadius,h=o-c,p=l-c,f=e/(c*2),m=(s-h)*f,g=(a-p)*f,_=n.createRadialGradient(m,g,u*f,(o-h)*f,(l-p)*f,c*f);Wm(_,t),n.fillStyle=t[t.length-1].color,n.fillRect(0,0,e,e),n.fillStyle=_,n.translate(m,g),n.rotate(this.rotation),n.scale(1,this.scale),n.translate(-m,-g),n.fillRect(0,0,e,e),this.texture=new D({source:new ke({resource:i,addressMode:this._wrapMode})});const y=new U;this.textureSpace==="local"?y.scale(2*c,2*c):y.scale(1/f,1/f),y.translate(h,p),this.transform=y}destroy(){var t;(t=this.texture)==null||t.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}`}};ol.defaultLinearOptions={start:{x:0,y:0},end:{x:0,y:1},colorStops:[],textureSpace:"local",type:"linear",textureSize:256,wrapMode:"clamp-to-edge"},ol.defaultRadialOptions={center:{x:.5,y:.5},innerRadius:0,outerRadius:.5,colorStops:[],scale:1,rotation:0,textureSpace:"local",type:"radial",textureSize:256,wrapMode:"clamp-to-edge"};let $t=ol;function Wm(r,t){for(let e=0;e{var h;const p=[],f=Ne[l.type];if(!f.build(l,p))return;const m=o.length,g=s.length/2;let _="triangle-list";if(u&&Yn(p,u),e){const v=(h=l.closePath)!=null?h:!0,w=t;w.pixelLine?($m(p,v,s,o),_="line-list"):Qn(p,w,!1,v,s,o)}else if(c){const v=[],w=p.slice();oP(c).forEach(T=>{v.push(w.length/2),w.push(...T)}),al(w,v,s,2,g,o,m)}else f.triangulate(p,s,2,g,o,m);const y=a.length/2,b=t.texture;if(b!==D.WHITE){const v=ll(sP,t,l,u);rl(s,2,g,a,y,2,s.length/2-g,v)}else il(a,y,2,s.length/2-g);const x=Pt.get(Kn);x.indexOffset=m,x.indexSize=o.length-m,x.attributeOffset=g,x.attributeSize=s.length/2-g,x.baseColor=t.color,x.alpha=t.alpha,x.texture=b,x.geometryData=n,x.topology=_,i.push(x)})}function oP(r){const t=[];for(let e=0;e{Pt.return(t)}),this.graphicsData&&Pt.return(this.graphicsData),this.isBatchable=!1,this.context=null,this.batches.length=0,this.geometryData.indices.length=0,this.geometryData.vertices.length=0,this.geometryData.uvs.length=0,this.graphicsData=null}destroy(){this.reset(),this.batches=null,this.geometryData=null}}class Zm{constructor(){this.instructions=new dn}init(t){const e=t.maxTextures;this.batcher?this.batcher._updateMaxTextures(e):this.batcher=new Vn({maxTextures:e}),this.instructions.reset()}get geometry(){return this.batcher.geometry}destroy(){this.batcher.destroy(),this.instructions.destroy(),this.batcher=null,this.instructions=null}}const ul=class Ch{constructor(t){this._renderer=t,this._managedContexts=new Ut({renderer:t,type:"resource",name:"graphicsContext"})}init(t){var e;Ch.defaultOptions.bezierSmoothness=(e=t==null?void 0:t.bezierSmoothness)!=null?e:Ch.defaultOptions.bezierSmoothness}getContextRenderData(t){return t._gpuData[this._renderer.uid].graphicsData||this._initContextRenderData(t)}updateGpuContext(t){const e=!!t._gpuData[this._renderer.uid],i=t._gpuData[this._renderer.uid]||this._initContext(t);if(t.dirty||!e){e&&i.reset(),Ym(t,i);const n=t.batchMode;t.customShader||n==="no-batch"?i.isBatchable=!1:n==="auto"?i.isBatchable=i.geometryData.vertices.length<400:i.isBatchable=!0,t.dirty=!1}return i}getGpuContext(t){return t._gpuData[this._renderer.uid]||this._initContext(t)}_initContextRenderData(t){const e=Pt.get(Zm,{maxTextures:this._renderer.limits.maxBatchableTextures}),i=t._gpuData[this._renderer.uid],{batches:n,geometryData:s}=i;i.graphicsData=e;const a=s.vertices.length,o=s.indices.length;for(let h=0;hlP)return;const h=Math.PI,p=(r+e)/2,f=(t+i)/2,m=(e+n)/2,g=(i+s)/2,_=(n+a)/2,y=(s+o)/2,b=(p+m)/2,x=(f+g)/2,v=(m+_)/2,w=(g+y)/2,T=(b+v)/2,E=(x+w)/2;if(c>0){let P=a-r,M=o-t;const C=Math.abs((e-a)*M-(i-o)*P),A=Math.abs((n-a)*M-(s-o)*P);let G,F;if(C>ts&&A>ts){if((C+A)*(C+A)<=u*(P*P+M*M)){if(Lr=h&&(G=2*h-G),F>=h&&(F=2*h-F),G+Fcr){l.push(e,i);return}if(F>cr){l.push(n,s);return}}}}else if(C>ts){if(C*C<=u*(P*P+M*M)){if(Lr=h&&(G=2*h-G),Gcr){l.push(e,i);return}}}else if(A>ts){if(A*A<=u*(P*P+M*M)){if(Lr=h&&(G=2*h-G),Gcr){l.push(n,s);return}}}else if(P=T-(r+a)/2,M=E-(t+o)/2,P*P+M*M<=u){l.push(T,E);return}}dl(r,t,p,f,b,x,T,E,l,u,c+1),dl(T,E,v,w,_,y,a,o,l,u,c+1)}const hP=8,dP=11920929e-14,pP=1,fP=.01,Qm=0;function Jm(r,t,e,i,n,s,a,o){const l=Math.min(.99,Math.max(0,o!=null?o:Jn.defaultOptions.bezierSmoothness));let u=(pP-l)/1;return u*=u,mP(t,e,i,n,s,a,r,u),r}function mP(r,t,e,i,n,s,a,o){pl(a,r,t,e,i,n,s,o,0),a.push(n,s)}function pl(r,t,e,i,n,s,a,o,l){if(l>hP)return;const u=Math.PI,c=(t+i)/2,h=(e+n)/2,p=(i+s)/2,f=(n+a)/2,m=(c+p)/2,g=(h+f)/2;let _=s-t,y=a-e;const b=Math.abs((i-s)*y-(n-a)*_);if(b>dP){if(b*b<=o*(_*_+y*y)){if(Qm=u&&(x=2*u-x),xs||a&&s>n)&&(l=2*Math.PI-l),o||(o=Math.max(6,Math.floor(6*Math.pow(i,.3333333333333333)*(l/Math.PI)))),o=Math.max(o,3);let u=l/o,c=n;u*=a?-1:1;for(let h=0;hc*o)}const Ii=Math.PI*2,ml={centerX:0,centerY:0,ang1:0,ang2:0},gl=({x:r,y:t},e,i,n,s,a,o,l)=>{r*=e,t*=i;const u=n*r-s*t,c=s*r+n*t;return l.x=u+a,l.y=c+o,l};function gP(r,t){const e=t===-1.5707963267948966?-.551915024494:1.3333333333333333*Math.tan(t/4),i=t===1.5707963267948966?.551915024494:e,n=Math.cos(r),s=Math.sin(r),a=Math.cos(r+t),o=Math.sin(r+t);return[{x:n-s*i,y:s+n*i},{x:a+o*i,y:o-a*i},{x:a,y:o}]}const eg=(r,t,e,i)=>{const n=r*i-t*e<0?-1:1;let s=r*e+t*i;return s>1&&(s=1),s<-1&&(s=-1),n*Math.acos(s)},_P=(r,t,e,i,n,s,a,o,l,u,c,h,p)=>{const f=Math.pow(n,2),m=Math.pow(s,2),g=Math.pow(c,2),_=Math.pow(h,2);let y=f*m-f*_-m*g;y<0&&(y=0),y/=f*_+m*g,y=Math.sqrt(y)*(a===o?-1:1);const b=y*n/s*h,x=y*-s/n*c,v=u*b-l*x+(r+e)/2,w=l*b+u*x+(t+i)/2,T=(c-b)/n,E=(h-x)/s,P=(-c-b)/n,M=(-h-x)/s,C=eg(1,0,T,E);let A=eg(T,E,P,M);o===0&&A>0&&(A-=Ii),o===1&&A<0&&(A+=Ii),p.centerX=v,p.centerY=w,p.ang1=C,p.ang2=A};function rg(r,t,e,i,n,s,a,o=0,l=0,u=0){if(s===0||a===0)return;const c=Math.sin(o*Ii/360),h=Math.cos(o*Ii/360),p=h*(t-i)/2+c*(e-n)/2,f=-c*(t-i)/2+h*(e-n)/2;if(p===0&&f===0)return;s=Math.abs(s),a=Math.abs(a);const m=Math.pow(p,2)/Math.pow(s,2)+Math.pow(f,2)/Math.pow(a,2);m>1&&(s*=Math.sqrt(m),a*=Math.sqrt(m)),_P(t,e,i,n,s,a,l,u,c,h,p,f,ml);let{ang1:g,ang2:_}=ml;const{centerX:y,centerY:b}=ml;let x=Math.abs(_)/(Ii/4);Math.abs(1-x)<1e-7&&(x=1);const v=Math.max(Math.ceil(x),1);_/=v;let w=r[r.length-2],T=r[r.length-1];const E={x:0,y:0};for(let P=0;P{const u=l.x-o.x,c=l.y-o.y,h=Math.sqrt(u*u+c*c),p=u/h,f=c/h;return{len:h,nx:p,ny:f}},s=(o,l)=>{o===0?r.moveTo(l.x,l.y):r.lineTo(l.x,l.y)};let a=t[t.length-1];for(let o=0;o0&&(m=-1,g=!0);const _=f/2;let y,b=Math.abs(Math.cos(_)*u/Math.sin(_));b>Math.min(h.len/2,p.len/2)?(b=Math.min(h.len/2,p.len/2),y=Math.abs(b*Math.sin(_)/Math.cos(_))):y=u;const x=l.x+p.nx*b+-p.ny*y*m,v=l.y+p.ny*b+p.nx*y*m,w=Math.atan2(h.ny,h.nx)+Math.PI/2*m,T=Math.atan2(p.ny,p.nx)-Math.PI/2*m;o===0&&r.moveTo(x+Math.cos(w)*y,v+Math.sin(w)*y),r.arc(x,v,y,w,T,g),a=l}}function ng(r,t,e,i){var n;const s=(l,u)=>Math.sqrt((l.x-u.x)**2+(l.y-u.y)**2),a=(l,u,c)=>({x:l.x+(u.x-l.x)*c,y:l.y+(u.y-l.y)*c}),o=t.length;for(let l=0;l1){let s=null;for(let a=n;a=2;h-=2)c[h]===c[h-2]&&c[h-1]===c[h-3]&&c.splice(h-1,2);return this.poly(c,!0,a)}ellipse(t,e,i,n,s){return this.drawShape(new An(t,e,i,n),s),this}roundRect(t,e,i,n,s,a){return this.drawShape(new Mn(t,e,i,n,s),a),this}drawShape(t,e){return this.endPoly(),this.shapePrimitives.push({shape:t,transform:e}),this}startPoly(t,e){let i=this._currentPoly;return i&&this.endPoly(),i=new Pr,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 Pr,t)){const e=this.shapePrimitives[this.shapePrimitives.length-1];if(e){let i=e.shape.x,n=e.shape.y;if(e.transform&&!e.transform.isIdentity()){const s=e.transform,a=i;i=s.a*i+s.c*n+s.tx,n=s.b*a+s.d*n+s.ty}this._currentPoly.points.push(i,n)}else this._currentPoly.points.push(0,0)}}buildPath(){const t=this._graphicsPath2D;this.shapePrimitives.length=0,this._currentPoly=null;for(let e=0;eo.area).sort((o,l)=>l-o),[e,i]=t,n=t[t.length-1],s=e/i,a=i/n;return!(s>3&&a<2)}function xP(r,t=0){const e=r.instructions[t];if(!e||e.action!=="fill")throw new Error(`Expected fill instruction at index ${t}, got ${(e==null?void 0:e.action)||"undefined"}`);return e.data}function cg(r){return r.split(/(?=[Mm])/).filter(t=>t.trim().length>0)}function hg(r){const t=r.match(/[-+]?[0-9]*\.?[0-9]+/g);if(!t||t.length<4)return 0;const e=t.map(Number),i=[],n=[];for(let u=0;ut in r?TP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,es=(r,t)=>{for(var e in t||(t={}))SP.call(t,e)&&pg(r,e,t[e]);if(dg)for(var e of dg(t))wP.call(t,e)&&pg(r,e,t[e]);return r};function fg(r,t){if(typeof r=="string"){const a=document.createElement("div");a.innerHTML=r.trim(),r=a.querySelector("svg")}const e={context:t,defs:{},path:new ge};og(r,e);const i=r.children,{fillStyle:n,strokeStyle:s}=vl(r,e);for(let a=0;a1;if(A&&G){const F=C.map(R=>({path:R,area:hg(R)}));if(F.sort((R,B)=>B.area-R.area),C.length>3||!ug(F))for(let R=0;RparseInt(M,10)),t.context.poly(x,!0),e&&t.context.fill(e),i&&t.context.stroke(i);break;case"polyline":v=r.getAttribute("points"),x=v.match(/-?\d+/g).map(M=>parseInt(M,10)),t.context.poly(x,!1),i&&t.context.stroke(i);break;case"g":case"svg":break;default:{ue(`[SVG parser] <${r.nodeName}> elements unsupported`);break}}o&&(e=null);for(let M=0;Mt in r?PP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_e=(r,t)=>{for(var e in t||(t={}))_g.call(t,e)&&bg(r,e,t[e]);if(rs)for(var e of rs(t))yg.call(t,e)&&bg(r,e,t[e]);return r},AP=(r,t)=>{var e={};for(var i in r)_g.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&rs)for(var i of rs(r))t.indexOf(i)<0&&yg.call(r,i)&&(e[i]=r[i]);return e};function CP(r){return tt.isColorLike(r)}function vg(r){return r instanceof Xr}function xg(r){return r instanceof $t}function MP(r){return r instanceof D}function RP(r,t,e){const i=tt.shared.setValue(t!=null?t:0);return r.color=i.toNumber(),r.alpha=i.alpha===1?e.alpha:i.alpha,r.texture=D.WHITE,_e(_e({},e),r)}function OP(r,t,e){return r.texture=t,_e(_e({},e),r)}function Tg(r,t,e){return r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,_e(_e({},e),r)}function Sg(r,t,e){return t.buildGradient(),r.fill=t,r.color=16777215,r.texture=t.texture,r.matrix=t.transform,r.textureSpace=t.textureSpace,_e(_e({},e),r)}function GP(r,t){const e=_e(_e({},t),r),i=tt.shared.setValue(e.color);return e.alpha*=i.alpha,e.color=i.toNumber(),e}function Xe(r,t){if(r==null)return null;const e={},i=r;return CP(r)?RP(e,r,t):MP(r)?OP(e,r,t):vg(r)?Tg(e,r,t):xg(r)?Sg(e,r,t):i.fill&&vg(i.fill)?Tg(i,i.fill,t):i.fill&&xg(i.fill)?Sg(i,i.fill,t):GP(i,t)}function Bi(r,t){const e=t,{width:i,alignment:n,miterLimit:s,cap:a,join:o,pixelLine:l}=e,u=AP(e,["width","alignment","miterLimit","cap","join","pixelLine"]),c=Xe(r,u);return c?_e({width:i,alignment:n,miterLimit:s,cap:a,join:o,pixelLine:l},c):null}function wg(r,t){let e=1;const i=r.shapePath.shapePrimitives;for(let n=0;n1&&(P=1);const M=Math.sqrt((1-P)*.5);if(M<1e-6)continue;const C=Math.min(1/M,t);C>e&&(e=C)}}return e}var IP=Object.defineProperty,Eg=Object.getOwnPropertySymbols,BP=Object.prototype.hasOwnProperty,FP=Object.prototype.propertyIsEnumerable,Pg=(r,t,e)=>t in r?IP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jr=(r,t)=>{for(var e in t||(t={}))BP.call(t,e)&&Pg(r,e,t[e]);if(Eg)for(var e of Eg(t))FP.call(t,e)&&Pg(r,e,t[e]);return r};const DP=new lt,Ag=new U,Tl=class Me extends Nt{constructor(){super(...arguments),this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this.uid=ht("graphicsContext"),this.dirty=!0,this.batchMode="auto",this.instructions=[],this.destroyed=!1,this._activePath=new ge,this._transform=new U,this._fillStyle=jr({},Me.defaultFillStyle),this._strokeStyle=jr({},Me.defaultStrokeStyle),this._stateStack=[],this._tick=0,this._bounds=new Mt,this._boundsDirty=!0}clone(){const t=new Me;return t.batchMode=this.batchMode,t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._transform=this._transform.clone(),t._fillStyle=jr({},this._fillStyle),t._strokeStyle=jr({},this._strokeStyle),t._stateStack=this._stateStack.slice(),t._bounds=this._bounds.clone(),t._boundsDirty=!0,t}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=Xe(t,Me.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=Bi(t,Me.defaultStrokeStyle)}setFillStyle(t){return this._fillStyle=Xe(t,Me.defaultFillStyle),this}setStrokeStyle(t){return this._strokeStyle=Xe(t,Me.defaultStrokeStyle),this}texture(t,e,i,n,s,a){return this.instructions.push({action:"texture",data:{image:t,dx:i||0,dy:n||0,dw:s||t.frame.width,dh:a||t.frame.height,transform:this._transform.clone(),alpha:this._fillStyle.alpha,style:e||e===0?tt.shared.setValue(e).toNumber():16777215}}),this.onUpdate(),this}beginPath(){return this._activePath=new ge,this}fill(t,e){let i;const n=this.instructions[this.instructions.length-1];return this._tick===0&&(n==null?void 0:n.action)==="stroke"?i=n.data.path:i=this._activePath.clone(),i?(t!=null&&(e!==void 0&&typeof t=="number"&&(t={color:t,alpha:e}),this._fillStyle=Xe(t,Me.defaultFillStyle)),this.instructions.push({action:"fill",data:{style:this.fillStyle,path:i}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){const{x:t,y:e}=this._activePath.getLastPoint(lt.shared);this._activePath.clear(),this._activePath.moveTo(t,e)}stroke(t){let e;const i=this.instructions[this.instructions.length-1];return this._tick===0&&(i==null?void 0:i.action)==="fill"?e=i.data.path:e=this._activePath.clone(),e?(t!=null&&(this._strokeStyle=Bi(t,Me.defaultStrokeStyle)),this.instructions.push({action:"stroke",data:{style:this.strokeStyle,path:e}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}cut(){for(let t=0;t<2;t++){const e=this.instructions[this.instructions.length-1-t],i=this._activePath.clone();if(e&&(e.action==="stroke"||e.action==="fill"))if(e.data.hole)e.data.hole.addPath(i);else{e.data.hole=i;break}}return this._initNextPathLocation(),this}arc(t,e,i,n,s,a){this._tick++;const o=this._transform;return this._activePath.arc(o.a*t+o.c*e+o.tx,o.b*t+o.d*e+o.ty,i,n,s,a),this}arcTo(t,e,i,n,s){this._tick++;const a=this._transform;return this._activePath.arcTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,s),this}arcToSvg(t,e,i,n,s,a,o){this._tick++;const l=this._transform;return this._activePath.arcToSvg(t,e,i,n,s,l.a*a+l.c*o+l.tx,l.b*a+l.d*o+l.ty),this}bezierCurveTo(t,e,i,n,s,a,o){this._tick++;const l=this._transform;return this._activePath.bezierCurveTo(l.a*t+l.c*e+l.tx,l.b*t+l.d*e+l.ty,l.a*i+l.c*n+l.tx,l.b*i+l.d*n+l.ty,l.a*s+l.c*a+l.tx,l.b*s+l.d*a+l.ty,o),this}closePath(){var t;return this._tick++,(t=this._activePath)==null||t.closePath(),this}ellipse(t,e,i,n){return this._tick++,this._activePath.ellipse(t,e,i,n,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,n=this._activePath.instructions,s=i.a*t+i.c*e+i.tx,a=i.b*t+i.d*e+i.ty;return n.length===1&&n[0].action==="moveTo"?(n[0].data[0]=s,n[0].data[1]=a,this):(this._activePath.moveTo(s,a),this)}quadraticCurveTo(t,e,i,n,s){this._tick++;const a=this._transform;return this._activePath.quadraticCurveTo(a.a*t+a.c*e+a.tx,a.b*t+a.d*e+a.ty,a.a*i+a.c*n+a.tx,a.b*i+a.d*n+a.ty,s),this}rect(t,e,i,n){return this._tick++,this._activePath.rect(t,e,i,n,this._transform.clone()),this}roundRect(t,e,i,n,s){return this._tick++,this._activePath.roundRect(t,e,i,n,s,this._transform.clone()),this}poly(t,e){return this._tick++,this._activePath.poly(t,e,this._transform.clone()),this}regularPoly(t,e,i,n,s=0,a){return this._tick++,this._activePath.regularPoly(t,e,i,n,s,a),this}roundPoly(t,e,i,n,s,a){return this._tick++,this._activePath.roundPoly(t,e,i,n,s,a),this}roundShape(t,e,i,n){return this._tick++,this._activePath.roundShape(t,e,i,n),this}filletRect(t,e,i,n,s){return this._tick++,this._activePath.filletRect(t,e,i,n,s),this}chamferRect(t,e,i,n,s,a){return this._tick++,this._activePath.chamferRect(t,e,i,n,s,a),this}star(t,e,i,n,s=0,a=0){return this._tick++,this._activePath.star(t,e,i,n,s,a,this._transform.clone()),this}svg(t){return this._tick++,fg(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:jr({},this._fillStyle),strokeStyle:jr({},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,n,s,a){return t instanceof U?(this._transform.set(t.a,t.b,t.c,t.d,t.tx,t.ty),this):(this._transform.set(t,e,i,n,s,a),this)}transform(t,e,i,n,s,a){return t instanceof U?(this._transform.append(t),this):(Ag.set(t,e,i,n,s,a),this._transform.append(Ag),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=!0,this.emit("update",this,16)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;const t=this._bounds;t.clear();for(let e=0;e{delete t.promiseCache[e],it.has(e)&&it.remove(e)};return i.source.once("destroy",()=>{t.promiseCache[e]&&n()}),i.once("destroy",()=>{r.destroyed||n()}),i}var UP=Object.defineProperty,is=Object.getOwnPropertySymbols,Cg=Object.prototype.hasOwnProperty,Mg=Object.prototype.propertyIsEnumerable,Rg=(r,t,e)=>t in r?UP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,$P=(r,t)=>{for(var e in t||(t={}))Cg.call(t,e)&&Rg(r,e,t[e]);if(is)for(var e of is(t))Mg.call(t,e)&&Rg(r,e,t[e]);return r},kP=(r,t)=>{var e={};for(var i in r)Cg.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&is)for(var i of is(r))t.indexOf(i)<0&&Mg.call(r,i)&&(e[i]=r[i]);return e};const LP=".svg",NP="image/svg+xml",Og={extension:{type:S.LoadParser,priority:te.Low,name:"loadSVG"},name:"loadSVG",id:"svg",config:{crossOrigin:"anonymous",parseAsGraphicsContext:!1},test(r){return ar(r,NP)||le(r,LP)},async load(r,t,e){var i,n;return((n=(i=t.data)==null?void 0:i.parseAsGraphicsContext)!=null?n:this.config.parseAsGraphicsContext)?jP(r):XP(r,t,e,this.config.crossOrigin)},unload(r){r.destroy(!0)}};async function XP(r,t,e,i){var n,s,a,o,l,u;const c=await H.get().fetch(r),h=H.get().createImage();h.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await c.text())}`,h.crossOrigin=i,await h.decode();const p=(s=(n=t.data)==null?void 0:n.width)!=null?s:h.width,f=(o=(a=t.data)==null?void 0:a.height)!=null?o:h.height,m=((l=t.data)==null?void 0:l.resolution)||je(r),g=Math.ceil(p*m),_=Math.ceil(f*m),y=H.get().createCanvas(g,_),b=y.getContext("2d");b.imageSmoothingEnabled=!0,b.imageSmoothingQuality="high",b.drawImage(h,0,0,p*m,f*m);const x=(u=t.data)!=null?u:{},{parseAsGraphicsContext:v}=x,w=kP(x,["parseAsGraphicsContext"]),T=new ke($P({resource:y,alphaMode:"premultiply-alpha-on-upload",resolution:m},w));return He(T,e,r)}async function jP(r){const t=await(await H.get().fetch(r)).text(),e=new kt;return e.svg(t),e}const HP=`(function(){"use strict";const e="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+ip1sAAAAASUVORK5CYII=";async function a(){try{if(typeof createImageBitmap!="function")return!1;const A=await(await fetch(e)).blob(),t=await createImageBitmap(A);return t.width===1&&t.height===1}catch(A){return!1}}a().then(A=>{self.postMessage(A)})})(); +`;let Hr=null,Sl=class{constructor(){Hr||(Hr=URL.createObjectURL(new Blob([HP],{type:"application/javascript"}))),this.worker=new Worker(Hr)}};Sl.revokeObjectURL=function(){Hr&&(URL.revokeObjectURL(Hr),Hr=null)};const zP='(function(){"use strict";async function s(a,t){const e=await fetch(a);if(!e.ok)throw new Error(`[WorkerManager.loadImageBitmap] Failed to fetch ${a}: ${e.status} ${e.statusText}`);const i=await e.blob();return t==="premultiplied-alpha"?createImageBitmap(i,{premultiplyAlpha:"none"}):createImageBitmap(i)}self.onmessage=async a=>{try{const t=await s(a.data.data[0],a.data.data[1]);self.postMessage({data:t,uuid:a.data.uuid,id:a.data.id},[t])}catch(t){self.postMessage({error:t,uuid:a.data.uuid,id:a.data.id})}}})();\n';let zr=null,Gg=class{constructor(){zr||(zr=URL.createObjectURL(new Blob([zP],{type:"application/javascript"}))),this.worker=new Worker(zr)}};Gg.revokeObjectURL=function(){zr&&(URL.revokeObjectURL(zr),zr=null)};let Ig=0,wl,WP=class{constructor(){this._initialized=!1,this._createdWorkers=0,this._workerPool=[],this._queue=[],this._resolveHash={}}isImageBitmapSupported(){return this._isImageBitmapSupported!==void 0?this._isImageBitmapSupported:(this._isImageBitmapSupported=new Promise(t=>{const{worker:e}=new Sl;e.addEventListener("message",i=>{e.terminate(),Sl.revokeObjectURL(),t(i.data)})}),this._isImageBitmapSupported)}loadImageBitmap(t,e){var i;return this._run("loadImageBitmap",[t,(i=e==null?void 0:e.data)==null?void 0:i.alphaMode])}async _initWorkers(){this._initialized||(this._initialized=!0)}_getWorker(){wl===void 0&&(wl=navigator.hardwareConcurrency||4);let t=this._workerPool.pop();return!t&&this._createdWorkers{this._complete(e.data),this._returnWorker(e.target),this._next()})),t}_returnWorker(t){this._workerPool.push(t)}_complete(t){this._resolveHash[t.uuid]&&(t.error!==void 0?this._resolveHash[t.uuid].reject(t.error):this._resolveHash[t.uuid].resolve(t.data),delete this._resolveHash[t.uuid])}async _run(t,e){await this._initWorkers();const i=new Promise((n,s)=>{this._queue.push({id:t,arguments:e,resolve:n,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[Ig]={resolve:e.resolve,reject:e.reject},t.postMessage({data:e.arguments,uuid:Ig++,id:i})}reset(){this._workerPool.forEach(t=>t.terminate()),this._workerPool.length=0,Object.values(this._resolveHash).forEach(({reject:t})=>{t==null||t(new Error("WorkerManager has been reset before completion"))}),this._resolveHash={},this._queue.length=0,this._initialized=!1,this._createdWorkers=0}};const El=new WP;var VP=Object.defineProperty,Bg=Object.getOwnPropertySymbols,YP=Object.prototype.hasOwnProperty,KP=Object.prototype.propertyIsEnumerable,Fg=(r,t,e)=>t in r?VP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qP=(r,t)=>{for(var e in t||(t={}))YP.call(t,e)&&Fg(r,e,t[e]);if(Bg)for(var e of Bg(t))KP.call(t,e)&&Fg(r,e,t[e]);return r};const ZP=[".jpeg",".jpg",".png",".webp",".avif"],QP=["image/jpeg","image/png","image/webp","image/avif"];async function Dg(r,t){var e;const i=await H.get().fetch(r);if(!i.ok)throw new Error(`[loadImageBitmap] Failed to fetch ${r}: ${i.status} ${i.statusText}`);const n=await i.blob();return((e=t==null?void 0:t.data)==null?void 0:e.alphaMode)==="premultiplied-alpha"?createImageBitmap(n,{premultiplyAlpha:"none"}):createImageBitmap(n)}const Pl={name:"loadTextures",id:"texture",extension:{type:S.LoadParser,priority:te.High,name:"loadTextures"},config:{preferWorkers:!0,preferCreateImageBitmap:!0,crossOrigin:"anonymous"},test(r){return ar(r,QP)||le(r,ZP)},async load(r,t,e){var i;let n=null;globalThis.createImageBitmap&&this.config.preferCreateImageBitmap?this.config.preferWorkers&&await El.isImageBitmapSupported()?n=await El.loadImageBitmap(r,t):n=await Dg(r,t):n=await new Promise((a,o)=>{n=H.get().createImage(),n.crossOrigin=this.config.crossOrigin,n.src=r,n.complete?a(n):(n.onload=()=>{a(n)},n.onerror=o)});const s=new ke(qP({resource:n,alphaMode:"premultiply-alpha-on-upload",resolution:((i=t.data)==null?void 0:i.resolution)||je(r)},t.data));return He(s,e,r)},unload(r){r.destroy(!0)}};var JP=Object.defineProperty,tA=Object.defineProperties,eA=Object.getOwnPropertyDescriptors,Ug=Object.getOwnPropertySymbols,rA=Object.prototype.hasOwnProperty,iA=Object.prototype.propertyIsEnumerable,$g=(r,t,e)=>t in r?JP(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Al=(r,t)=>{for(var e in t||(t={}))rA.call(t,e)&&$g(r,e,t[e]);if(Ug)for(var e of Ug(t))iA.call(t,e)&&$g(r,e,t[e]);return r},kg=(r,t)=>tA(r,eA(t));const nA=[".mp4",".m4v",".webm",".ogg",".ogv",".h264",".avi",".mov"];let Cl,Ml;function Lg(r,t,e){e===void 0&&!t.startsWith("data:")?r.crossOrigin=Xg(t):e!==!1&&(r.crossOrigin=typeof e=="string"?e:"anonymous")}function Ng(r){return new Promise((t,e)=>{r.addEventListener("canplaythrough",i),r.addEventListener("error",n),r.load();function i(){s(),t()}function n(a){s(),e(a)}function s(){r.removeEventListener("canplaythrough",i),r.removeEventListener("error",n)}})}function Xg(r,t=globalThis.location){if(r.startsWith("data:"))return"";t||(t=globalThis.location);const e=new URL(r,document.baseURI);return e.hostname!==t.hostname||e.port!==t.port||e.protocol!==t.protocol?"anonymous":""}function sA(){const r=[],t=[];for(const e of nA){const i=wr.MIME_TYPES[e.substring(1)]||`video/${e.substring(1)}`;Ci(i)&&(r.push(e),t.includes(i)||t.push(i))}return{validVideoExtensions:r,validVideoMime:t}}const jg={name:"loadVideo",id:"video",extension:{type:S.LoadParser,name:"loadVideo"},test(r){if(!Cl||!Ml){const{validVideoExtensions:i,validVideoMime:n}=sA();Cl=i,Ml=n}const t=ar(r,Ml),e=le(r,Cl);return t||e},async load(r,t,e){var i,n;const s=Al(kg(Al({},wr.defaultOptions),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r),alphaMode:((n=t.data)==null?void 0:n.alphaMode)||await ro()}),t.data),a=document.createElement("video"),o={preload:s.autoLoad!==!1?"auto":void 0,"webkit-playsinline":s.playsinline!==!1?"":void 0,playsinline:s.playsinline!==!1?"":void 0,muted:s.muted===!0?"":void 0,loop:s.loop===!0?"":void 0,autoplay:s.autoPlay!==!1?"":void 0};Object.keys(o).forEach(c=>{const h=o[c];h!==void 0&&a.setAttribute(c,h)}),s.muted===!0&&(a.muted=!0),Lg(a,r,s.crossorigin);const l=document.createElement("source");let u;if(s.mime)u=s.mime;else if(r.startsWith("data:"))u=r.slice(5,r.indexOf(";"));else if(!r.startsWith("blob:")){const c=r.split("?")[0].slice(r.lastIndexOf(".")+1).toLowerCase();u=wr.MIME_TYPES[c]||`video/${c}`}return l.src=r,u&&(l.type=u),new Promise((c,h)=>{s.preload&&!s.autoPlay&&a.load(),a.addEventListener("canplay",p),a.addEventListener("error",f),l.addEventListener("error",f),a.appendChild(l);async function p(){const g=new wr(kg(Al({},s),{resource:a}));m(),t.data.preload&&await Ng(a),c(He(g,e,r))}function f(g){m(),h(g)}function m(){a.removeEventListener("canplay",p),a.removeEventListener("error",f),l.removeEventListener("error",f)}})},unload(r){r.destroy(!0)}},Rl={extension:{type:S.ResolveParser,name:"resolveTexture"},test:Pl.test,parse:r=>{var t,e;return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:r.split(".").pop(),src:r}}},Hg={extension:{type:S.ResolveParser,priority:-2,name:"resolveJson"},test:r=>$e.RETINA_PREFIX.test(r)&&r.endsWith(".json"),parse:Rl.parse};var aA=Object.defineProperty,zg=Object.getOwnPropertySymbols,oA=Object.prototype.hasOwnProperty,lA=Object.prototype.propertyIsEnumerable,Wg=(r,t,e)=>t in r?aA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vg=(r,t)=>{for(var e in t||(t={}))oA.call(t,e)&&Wg(r,e,t[e]);if(zg)for(var e of zg(t))lA.call(t,e)&&Wg(r,e,t[e]);return r};class Yg{constructor(){this._detections=[],this._initialized=!1,this.resolver=new $e,this.loader=new Vf,this.cache=it,this._backgroundLoader=new Ff(this.loader),this._backgroundLoader.active=!0,this.reset()}async init(t={}){var e,i,n;if(this._initialized)return;if(this._initialized=!0,t.defaultSearchParams&&this.resolver.setDefaultSearchParams(t.defaultSearchParams),t.basePath&&(this.resolver.basePath=t.basePath),t.bundleIdentifier&&this.resolver.setBundleIdentifier(t.bundleIdentifier),t.manifest){let l=t.manifest;typeof l=="string"&&(l=await this.load(l)),this.resolver.addManifest(l)}const s=(i=(e=t.texturePreference)==null?void 0:e.resolution)!=null?i:1,a=typeof s=="number"?[s]:s,o=await this._detectFormats({preferredFormats:(n=t.texturePreference)==null?void 0:n.format,skipDetections:t.skipDetections,detections:this._detections});this.resolver.prefer({params:{format:o,resolution:a}}),t.preferences&&this.setPreferences(t.preferences),t.loadOptions&&(this.loader.loadOptions=Vg(Vg({},this.loader.loadOptions),t.loadOptions))}add(t){this.resolver.add(t)}async load(t,e){this._initialized||await this.init();const i=fi(t),n=oe(t).map(o=>{if(typeof o!="string"){const l=this.resolver.getAlias(o);return l.some(u=>!this.resolver.hasKey(u))&&this.add(o),Array.isArray(l)?l[0]:l}return this.resolver.hasKey(o)||this.add({alias:o,src:o}),o}),s=this.resolver.resolve(n),a=await this._mapLoadToResolve(s,e);return i?a[n[0]]:a}addBundle(t,e){this.resolver.addBundle(t,e)}async loadBundle(t,e){this._initialized||await this.init();let i=!1;typeof t=="string"&&(i=!0,t=[t]);const n=this.resolver.resolveBundle(t),s={},a=Object.keys(n);let o=0;const l=[],u=()=>{e==null||e(l.reduce((h,p)=>h+p,0)/o)},c=a.map((h,p)=>{const f=n[h],m=Object.values(f),g=[...new Set(m.flat())].reduce((_,y)=>_+(y.progressSize||1),0);return l.push(0),o+=g,this._mapLoadToResolve(f,_=>{l[p]=_*g,u()}).then(_=>{s[h]=_})});return await Promise.all(c),i?s[t[0]]:s}async backgroundLoad(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolve(t);this._backgroundLoader.add(Object.values(e))}async backgroundLoadBundle(t){this._initialized||await this.init(),typeof t=="string"&&(t=[t]);const e=this.resolver.resolveBundle(t);Object.values(e).forEach(i=>{this._backgroundLoader.add(Object.values(i))})}reset(){this.resolver.reset(),this.loader.reset(),this.cache.reset(),this._initialized=!1}get(t){if(typeof t=="string")return it.get(t);const e={};for(let i=0;i{const o=n[a.src],l=[a.src];a.alias&&l.push(...a.alias),l.forEach(u=>{s[u]=o}),it.set(l,o)}),s}async unload(t){this._initialized||await this.init();const e=oe(t).map(n=>typeof n!="string"?n.src:n),i=this.resolver.resolve(e);await this._unloadFromResolved(i)}async unloadBundle(t){this._initialized||await this.init(),t=oe(t);const e=this.resolver.resolveBundle(t),i=Object.keys(e).map(n=>this._unloadFromResolved(e[n]));await Promise.all(i)}async _unloadFromResolved(t){const e=Object.values(t);e.forEach(i=>{it.remove(i.src)}),await this.loader.unload(e)}async _detectFormats(t){let e=[];t.preferredFormats&&(e=Array.isArray(t.preferredFormats)?t.preferredFormats:[t.preferredFormats]);for(const i of t.detections)t.skipDetections||await i.test()?e=await i.add(e):t.skipDetections||(e=await i.remove(e));return e=e.filter((i,n)=>e.indexOf(i)===n),e}get detections(){return this._detections}setPreferences(t){this.loader.parsers.forEach(e=>{e.config&&Object.keys(e.config).filter(i=>i in t).forEach(i=>{e.config[i]=t[i]})})}}const Fi=new Yg;N.handleByList(S.LoadParser,Fi.loader.parsers).handleByList(S.ResolveParser,Fi.resolver.parsers).handleByList(S.CacheParser,Fi.cache.parsers).handleByList(S.DetectionParser,Fi.detections),N.add(Df,kf,Uf,jf,Lf,Nf,Xf,Yf,Kf,Jf,Og,Pl,jg,Bf,If,Rl,Hg);const Kg={loader:S.LoadParser,resolver:S.ResolveParser,cache:S.CacheParser,detection:S.DetectionParser};N.handle(S.Asset,r=>{const t=r.ref;Object.entries(Kg).filter(([e])=>!!t[e]).forEach(([e,i])=>{var n;return N.add(Object.assign(t[e],{extension:(n=t[e].extension)!=null?n:i}))})},r=>{const t=r.ref;Object.keys(Kg).filter(e=>!!t[e]).forEach(e=>N.remove(t[e]))});const uA={extension:{type:S.DetectionParser,priority:3},test:async()=>!!(await Pi()||Ei()),add:async r=>[...r,"basis"],remove:async r=>r.filter(t=>t!=="basis")};var cA=Object.defineProperty,hA=Object.defineProperties,dA=Object.getOwnPropertyDescriptors,qg=Object.getOwnPropertySymbols,pA=Object.prototype.hasOwnProperty,fA=Object.prototype.propertyIsEnumerable,Zg=(r,t,e)=>t in r?cA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mA=(r,t)=>{for(var e in t||(t={}))pA.call(t,e)&&Zg(r,e,t[e]);if(qg)for(var e of qg(t))fA.call(t,e)&&Zg(r,e,t[e]);return r},gA=(r,t)=>hA(r,dA(t));class Di extends ft{constructor(t){super(gA(mA({},t),{mipLevelCount:t.resource.length})),this.uploadMethodId="compressed"}}let ns;function Ol(){if(ns)return ns;const r=H.get().createCanvas(1,1).getContext("webgl");return r?(ns=[...r.getExtension("EXT_texture_compression_bptc")?["bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc")?["bc1-rgba-unorm","bc2-rgba-unorm","bc3-rgba-unorm"]:[],...r.getExtension("WEBGL_compressed_texture_s3tc_srgb")?["bc1-rgba-unorm-srgb","bc2-rgba-unorm-srgb","bc3-rgba-unorm-srgb"]:[],...r.getExtension("EXT_texture_compression_rgtc")?["bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm"]:[],...r.getExtension("WEBGL_compressed_texture_etc")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","eac-r11unorm","eac-rg11unorm"]:[],...r.getExtension("WEBGL_compressed_texture_astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],ns):[]}let ss;async function Gl(){if(ss)return ss;const r=await H.get().getNavigator().gpu.requestAdapter();return ss=[...r.features.has("texture-compression-bc")?["bc1-rgba-unorm","bc1-rgba-unorm-srgb","bc2-rgba-unorm","bc2-rgba-unorm-srgb","bc3-rgba-unorm","bc3-rgba-unorm-srgb","bc4-r-unorm","bc4-r-snorm","bc5-rg-unorm","bc5-rg-snorm","bc6h-rgb-ufloat","bc6h-rgb-float","bc7-rgba-unorm","bc7-rgba-unorm-srgb"]:[],...r.features.has("texture-compression-etc2")?["etc2-rgb8unorm","etc2-rgb8unorm-srgb","etc2-rgb8a1unorm","etc2-rgb8a1unorm-srgb","etc2-rgba8unorm","etc2-rgba8unorm-srgb","eac-r11unorm","eac-r11snorm","eac-rg11unorm","eac-rg11snorm"]:[],...r.features.has("texture-compression-astc")?["astc-4x4-unorm","astc-4x4-unorm-srgb","astc-5x4-unorm","astc-5x4-unorm-srgb","astc-5x5-unorm","astc-5x5-unorm-srgb","astc-6x5-unorm","astc-6x5-unorm-srgb","astc-6x6-unorm","astc-6x6-unorm-srgb","astc-8x5-unorm","astc-8x5-unorm-srgb","astc-8x6-unorm","astc-8x6-unorm-srgb","astc-8x8-unorm","astc-8x8-unorm-srgb","astc-10x5-unorm","astc-10x5-unorm-srgb","astc-10x6-unorm","astc-10x6-unorm-srgb","astc-10x8-unorm","astc-10x8-unorm-srgb","astc-10x10-unorm","astc-10x10-unorm-srgb","astc-12x10-unorm","astc-12x10-unorm-srgb","astc-12x12-unorm","astc-12x12-unorm-srgb"]:[]],ss}let Il;async function Bl(){return Il!==void 0||(Il=await(async()=>{const r=await Pi(),t=Ei();if(r&&t){const e=await Gl(),i=Ol();return e.filter(n=>i.includes(n))}else{if(r)return await Gl();if(t)return Ol()}return[]})()),Il}const Qg=["r8unorm","r8snorm","r8uint","r8sint","r16uint","r16sint","r16float","rg8unorm","rg8snorm","rg8uint","rg8sint","r32uint","r32sint","r32float","rg16uint","rg16sint","rg16float","rgba8unorm","rgba8unorm-srgb","rgba8snorm","rgba8uint","rgba8sint","bgra8unorm","bgra8unorm-srgb","rgb9e5ufloat","rgb10a2unorm","rg11b10ufloat","rg32uint","rg32sint","rg32float","rgba16uint","rgba16sint","rgba16float","rgba32uint","rgba32sint","rgba32float","stencil8","depth16unorm","depth24plus","depth24plus-stencil8","depth32float","depth32float-stencil8"];let as;async function Ui(){if(as!==void 0)return as;const r=await Bl();return as=[...Qg,...r],as}const _A='(function(){"use strict";function g(r,a){const t=r.getNumImages(),s=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const m=[];for(let e=0;e{BASIS({locateFile:s=>a}).then(s=>{s.initializeBasis(),t(s.BasisFile)})})}return c}async function b(r,a){const t=await fetch(r);if(t.ok){const s=await t.arrayBuffer();return new a(new Uint8Array(s))}throw new Error(`Failed to load Basis texture: ${r}`)}const h=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function p(r){const a=await l(),t=await b(r,a),s=g(t,u);return{width:t.getImageWidth(0,0),height:t.getImageHeight(0,0),format:i,resource:s,alphaMode:"no-premultiply-alpha"}}async function y(r,a,t){r&&(n.jsUrl=r),a&&(n.wasmUrl=a),i=h.filter(s=>t.includes(s))[0],u=d(i),await l()}const U={init:async r=>{const{jsUrl:a,wasmUrl:t,supportedTextures:s}=r;await y(a,t,s)},load:async r=>{var a;try{const t=await p(r.url);return{type:"load",url:r.url,success:!0,textureOptions:t,transferables:(a=t.resource)==null?void 0:a.map(s=>s.buffer)}}catch(t){throw t}}};self.onmessage=(async r=>{const a=r.data,t=await U[a.type](a);t&&self.postMessage(t,t.transferables)})})();\n';let Wr=null,Jg=class{constructor(){Wr||(Wr=URL.createObjectURL(new Blob([_A],{type:"application/javascript"}))),this.worker=new Worker(Wr)}};Jg.revokeObjectURL=function(){Wr&&(URL.revokeObjectURL(Wr),Wr=null)};const os={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/basis/basis_transcoder.wasm"};function yA(r){Object.assign(os,r)}let $i;const t_={};function bA(r){return $i||($i=new Jg().worker,$i.onmessage=t=>{const{success:e,url:i,textureOptions:n}=t.data;e||console.warn("Failed to load Basis texture",i),t_[i](n)},$i.postMessage({type:"init",jsUrl:os.jsUrl,wasmUrl:os.wasmUrl,supportedTextures:r})),$i}function e_(r,t){const e=bA(t);return new Promise(i=>{t_[r]=i,e.postMessage({type:"load",url:r})})}var vA=Object.defineProperty,xA=Object.defineProperties,TA=Object.getOwnPropertyDescriptors,r_=Object.getOwnPropertySymbols,SA=Object.prototype.hasOwnProperty,wA=Object.prototype.propertyIsEnumerable,i_=(r,t,e)=>t in r?vA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,EA=(r,t)=>{for(var e in t||(t={}))SA.call(t,e)&&i_(r,e,t[e]);if(r_)for(var e of r_(t))wA.call(t,e)&&i_(r,e,t[e]);return r},PA=(r,t)=>xA(r,TA(t));const AA={extension:{type:S.LoadParser,priority:te.High,name:"loadBasis"},name:"loadBasis",id:"basis",test(r){return le(r,[".basis"])},async load(r,t,e){var i;const n=await Ui(),s=await e_(r,n),a=new Di(PA(EA({},s),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(a,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};function CA(r,t){const e=r.getNumImages(),i=r.getNumLevels(0);if(!r.startTranscoding())throw new Error("startTranscoding failed");const n=[];for(let s=0;s(r[r.DXGI_FORMAT_UNKNOWN=0]="DXGI_FORMAT_UNKNOWN",r[r.DXGI_FORMAT_R32G32B32A32_TYPELESS=1]="DXGI_FORMAT_R32G32B32A32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32A32_FLOAT=2]="DXGI_FORMAT_R32G32B32A32_FLOAT",r[r.DXGI_FORMAT_R32G32B32A32_UINT=3]="DXGI_FORMAT_R32G32B32A32_UINT",r[r.DXGI_FORMAT_R32G32B32A32_SINT=4]="DXGI_FORMAT_R32G32B32A32_SINT",r[r.DXGI_FORMAT_R32G32B32_TYPELESS=5]="DXGI_FORMAT_R32G32B32_TYPELESS",r[r.DXGI_FORMAT_R32G32B32_FLOAT=6]="DXGI_FORMAT_R32G32B32_FLOAT",r[r.DXGI_FORMAT_R32G32B32_UINT=7]="DXGI_FORMAT_R32G32B32_UINT",r[r.DXGI_FORMAT_R32G32B32_SINT=8]="DXGI_FORMAT_R32G32B32_SINT",r[r.DXGI_FORMAT_R16G16B16A16_TYPELESS=9]="DXGI_FORMAT_R16G16B16A16_TYPELESS",r[r.DXGI_FORMAT_R16G16B16A16_FLOAT=10]="DXGI_FORMAT_R16G16B16A16_FLOAT",r[r.DXGI_FORMAT_R16G16B16A16_UNORM=11]="DXGI_FORMAT_R16G16B16A16_UNORM",r[r.DXGI_FORMAT_R16G16B16A16_UINT=12]="DXGI_FORMAT_R16G16B16A16_UINT",r[r.DXGI_FORMAT_R16G16B16A16_SNORM=13]="DXGI_FORMAT_R16G16B16A16_SNORM",r[r.DXGI_FORMAT_R16G16B16A16_SINT=14]="DXGI_FORMAT_R16G16B16A16_SINT",r[r.DXGI_FORMAT_R32G32_TYPELESS=15]="DXGI_FORMAT_R32G32_TYPELESS",r[r.DXGI_FORMAT_R32G32_FLOAT=16]="DXGI_FORMAT_R32G32_FLOAT",r[r.DXGI_FORMAT_R32G32_UINT=17]="DXGI_FORMAT_R32G32_UINT",r[r.DXGI_FORMAT_R32G32_SINT=18]="DXGI_FORMAT_R32G32_SINT",r[r.DXGI_FORMAT_R32G8X24_TYPELESS=19]="DXGI_FORMAT_R32G8X24_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT_S8X24_UINT=20]="DXGI_FORMAT_D32_FLOAT_S8X24_UINT",r[r.DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS=21]="DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS",r[r.DXGI_FORMAT_X32_TYPELESS_G8X24_UINT=22]="DXGI_FORMAT_X32_TYPELESS_G8X24_UINT",r[r.DXGI_FORMAT_R10G10B10A2_TYPELESS=23]="DXGI_FORMAT_R10G10B10A2_TYPELESS",r[r.DXGI_FORMAT_R10G10B10A2_UNORM=24]="DXGI_FORMAT_R10G10B10A2_UNORM",r[r.DXGI_FORMAT_R10G10B10A2_UINT=25]="DXGI_FORMAT_R10G10B10A2_UINT",r[r.DXGI_FORMAT_R11G11B10_FLOAT=26]="DXGI_FORMAT_R11G11B10_FLOAT",r[r.DXGI_FORMAT_R8G8B8A8_TYPELESS=27]="DXGI_FORMAT_R8G8B8A8_TYPELESS",r[r.DXGI_FORMAT_R8G8B8A8_UNORM=28]="DXGI_FORMAT_R8G8B8A8_UNORM",r[r.DXGI_FORMAT_R8G8B8A8_UNORM_SRGB=29]="DXGI_FORMAT_R8G8B8A8_UNORM_SRGB",r[r.DXGI_FORMAT_R8G8B8A8_UINT=30]="DXGI_FORMAT_R8G8B8A8_UINT",r[r.DXGI_FORMAT_R8G8B8A8_SNORM=31]="DXGI_FORMAT_R8G8B8A8_SNORM",r[r.DXGI_FORMAT_R8G8B8A8_SINT=32]="DXGI_FORMAT_R8G8B8A8_SINT",r[r.DXGI_FORMAT_R16G16_TYPELESS=33]="DXGI_FORMAT_R16G16_TYPELESS",r[r.DXGI_FORMAT_R16G16_FLOAT=34]="DXGI_FORMAT_R16G16_FLOAT",r[r.DXGI_FORMAT_R16G16_UNORM=35]="DXGI_FORMAT_R16G16_UNORM",r[r.DXGI_FORMAT_R16G16_UINT=36]="DXGI_FORMAT_R16G16_UINT",r[r.DXGI_FORMAT_R16G16_SNORM=37]="DXGI_FORMAT_R16G16_SNORM",r[r.DXGI_FORMAT_R16G16_SINT=38]="DXGI_FORMAT_R16G16_SINT",r[r.DXGI_FORMAT_R32_TYPELESS=39]="DXGI_FORMAT_R32_TYPELESS",r[r.DXGI_FORMAT_D32_FLOAT=40]="DXGI_FORMAT_D32_FLOAT",r[r.DXGI_FORMAT_R32_FLOAT=41]="DXGI_FORMAT_R32_FLOAT",r[r.DXGI_FORMAT_R32_UINT=42]="DXGI_FORMAT_R32_UINT",r[r.DXGI_FORMAT_R32_SINT=43]="DXGI_FORMAT_R32_SINT",r[r.DXGI_FORMAT_R24G8_TYPELESS=44]="DXGI_FORMAT_R24G8_TYPELESS",r[r.DXGI_FORMAT_D24_UNORM_S8_UINT=45]="DXGI_FORMAT_D24_UNORM_S8_UINT",r[r.DXGI_FORMAT_R24_UNORM_X8_TYPELESS=46]="DXGI_FORMAT_R24_UNORM_X8_TYPELESS",r[r.DXGI_FORMAT_X24_TYPELESS_G8_UINT=47]="DXGI_FORMAT_X24_TYPELESS_G8_UINT",r[r.DXGI_FORMAT_R8G8_TYPELESS=48]="DXGI_FORMAT_R8G8_TYPELESS",r[r.DXGI_FORMAT_R8G8_UNORM=49]="DXGI_FORMAT_R8G8_UNORM",r[r.DXGI_FORMAT_R8G8_UINT=50]="DXGI_FORMAT_R8G8_UINT",r[r.DXGI_FORMAT_R8G8_SNORM=51]="DXGI_FORMAT_R8G8_SNORM",r[r.DXGI_FORMAT_R8G8_SINT=52]="DXGI_FORMAT_R8G8_SINT",r[r.DXGI_FORMAT_R16_TYPELESS=53]="DXGI_FORMAT_R16_TYPELESS",r[r.DXGI_FORMAT_R16_FLOAT=54]="DXGI_FORMAT_R16_FLOAT",r[r.DXGI_FORMAT_D16_UNORM=55]="DXGI_FORMAT_D16_UNORM",r[r.DXGI_FORMAT_R16_UNORM=56]="DXGI_FORMAT_R16_UNORM",r[r.DXGI_FORMAT_R16_UINT=57]="DXGI_FORMAT_R16_UINT",r[r.DXGI_FORMAT_R16_SNORM=58]="DXGI_FORMAT_R16_SNORM",r[r.DXGI_FORMAT_R16_SINT=59]="DXGI_FORMAT_R16_SINT",r[r.DXGI_FORMAT_R8_TYPELESS=60]="DXGI_FORMAT_R8_TYPELESS",r[r.DXGI_FORMAT_R8_UNORM=61]="DXGI_FORMAT_R8_UNORM",r[r.DXGI_FORMAT_R8_UINT=62]="DXGI_FORMAT_R8_UINT",r[r.DXGI_FORMAT_R8_SNORM=63]="DXGI_FORMAT_R8_SNORM",r[r.DXGI_FORMAT_R8_SINT=64]="DXGI_FORMAT_R8_SINT",r[r.DXGI_FORMAT_A8_UNORM=65]="DXGI_FORMAT_A8_UNORM",r[r.DXGI_FORMAT_R1_UNORM=66]="DXGI_FORMAT_R1_UNORM",r[r.DXGI_FORMAT_R9G9B9E5_SHAREDEXP=67]="DXGI_FORMAT_R9G9B9E5_SHAREDEXP",r[r.DXGI_FORMAT_R8G8_B8G8_UNORM=68]="DXGI_FORMAT_R8G8_B8G8_UNORM",r[r.DXGI_FORMAT_G8R8_G8B8_UNORM=69]="DXGI_FORMAT_G8R8_G8B8_UNORM",r[r.DXGI_FORMAT_BC1_TYPELESS=70]="DXGI_FORMAT_BC1_TYPELESS",r[r.DXGI_FORMAT_BC1_UNORM=71]="DXGI_FORMAT_BC1_UNORM",r[r.DXGI_FORMAT_BC1_UNORM_SRGB=72]="DXGI_FORMAT_BC1_UNORM_SRGB",r[r.DXGI_FORMAT_BC2_TYPELESS=73]="DXGI_FORMAT_BC2_TYPELESS",r[r.DXGI_FORMAT_BC2_UNORM=74]="DXGI_FORMAT_BC2_UNORM",r[r.DXGI_FORMAT_BC2_UNORM_SRGB=75]="DXGI_FORMAT_BC2_UNORM_SRGB",r[r.DXGI_FORMAT_BC3_TYPELESS=76]="DXGI_FORMAT_BC3_TYPELESS",r[r.DXGI_FORMAT_BC3_UNORM=77]="DXGI_FORMAT_BC3_UNORM",r[r.DXGI_FORMAT_BC3_UNORM_SRGB=78]="DXGI_FORMAT_BC3_UNORM_SRGB",r[r.DXGI_FORMAT_BC4_TYPELESS=79]="DXGI_FORMAT_BC4_TYPELESS",r[r.DXGI_FORMAT_BC4_UNORM=80]="DXGI_FORMAT_BC4_UNORM",r[r.DXGI_FORMAT_BC4_SNORM=81]="DXGI_FORMAT_BC4_SNORM",r[r.DXGI_FORMAT_BC5_TYPELESS=82]="DXGI_FORMAT_BC5_TYPELESS",r[r.DXGI_FORMAT_BC5_UNORM=83]="DXGI_FORMAT_BC5_UNORM",r[r.DXGI_FORMAT_BC5_SNORM=84]="DXGI_FORMAT_BC5_SNORM",r[r.DXGI_FORMAT_B5G6R5_UNORM=85]="DXGI_FORMAT_B5G6R5_UNORM",r[r.DXGI_FORMAT_B5G5R5A1_UNORM=86]="DXGI_FORMAT_B5G5R5A1_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_UNORM=87]="DXGI_FORMAT_B8G8R8A8_UNORM",r[r.DXGI_FORMAT_B8G8R8X8_UNORM=88]="DXGI_FORMAT_B8G8R8X8_UNORM",r[r.DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM=89]="DXGI_FORMAT_R10G10B10_XR_BIAS_A2_UNORM",r[r.DXGI_FORMAT_B8G8R8A8_TYPELESS=90]="DXGI_FORMAT_B8G8R8A8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8A8_UNORM_SRGB=91]="DXGI_FORMAT_B8G8R8A8_UNORM_SRGB",r[r.DXGI_FORMAT_B8G8R8X8_TYPELESS=92]="DXGI_FORMAT_B8G8R8X8_TYPELESS",r[r.DXGI_FORMAT_B8G8R8X8_UNORM_SRGB=93]="DXGI_FORMAT_B8G8R8X8_UNORM_SRGB",r[r.DXGI_FORMAT_BC6H_TYPELESS=94]="DXGI_FORMAT_BC6H_TYPELESS",r[r.DXGI_FORMAT_BC6H_UF16=95]="DXGI_FORMAT_BC6H_UF16",r[r.DXGI_FORMAT_BC6H_SF16=96]="DXGI_FORMAT_BC6H_SF16",r[r.DXGI_FORMAT_BC7_TYPELESS=97]="DXGI_FORMAT_BC7_TYPELESS",r[r.DXGI_FORMAT_BC7_UNORM=98]="DXGI_FORMAT_BC7_UNORM",r[r.DXGI_FORMAT_BC7_UNORM_SRGB=99]="DXGI_FORMAT_BC7_UNORM_SRGB",r[r.DXGI_FORMAT_AYUV=100]="DXGI_FORMAT_AYUV",r[r.DXGI_FORMAT_Y410=101]="DXGI_FORMAT_Y410",r[r.DXGI_FORMAT_Y416=102]="DXGI_FORMAT_Y416",r[r.DXGI_FORMAT_NV12=103]="DXGI_FORMAT_NV12",r[r.DXGI_FORMAT_P010=104]="DXGI_FORMAT_P010",r[r.DXGI_FORMAT_P016=105]="DXGI_FORMAT_P016",r[r.DXGI_FORMAT_420_OPAQUE=106]="DXGI_FORMAT_420_OPAQUE",r[r.DXGI_FORMAT_YUY2=107]="DXGI_FORMAT_YUY2",r[r.DXGI_FORMAT_Y210=108]="DXGI_FORMAT_Y210",r[r.DXGI_FORMAT_Y216=109]="DXGI_FORMAT_Y216",r[r.DXGI_FORMAT_NV11=110]="DXGI_FORMAT_NV11",r[r.DXGI_FORMAT_AI44=111]="DXGI_FORMAT_AI44",r[r.DXGI_FORMAT_IA44=112]="DXGI_FORMAT_IA44",r[r.DXGI_FORMAT_P8=113]="DXGI_FORMAT_P8",r[r.DXGI_FORMAT_A8P8=114]="DXGI_FORMAT_A8P8",r[r.DXGI_FORMAT_B4G4R4A4_UNORM=115]="DXGI_FORMAT_B4G4R4A4_UNORM",r[r.DXGI_FORMAT_P208=116]="DXGI_FORMAT_P208",r[r.DXGI_FORMAT_V208=117]="DXGI_FORMAT_V208",r[r.DXGI_FORMAT_V408=118]="DXGI_FORMAT_V408",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE=119]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIN_MIP_OPAQUE",r[r.DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE=120]="DXGI_FORMAT_SAMPLER_FEEDBACK_MIP_REGION_USED_OPAQUE",r[r.DXGI_FORMAT_FORCE_UINT=121]="DXGI_FORMAT_FORCE_UINT",r))(Fl||{}),Dl=(r=>(r[r.DDS_DIMENSION_TEXTURE1D=2]="DDS_DIMENSION_TEXTURE1D",r[r.DDS_DIMENSION_TEXTURE2D=3]="DDS_DIMENSION_TEXTURE2D",r[r.DDS_DIMENSION_TEXTURE3D=6]="DDS_DIMENSION_TEXTURE3D",r))(Dl||{});function Bt(r){return r.charCodeAt(0)+(r.charCodeAt(1)<<8)+(r.charCodeAt(2)<<16)+(r.charCodeAt(3)<<24)}var qt=(r=>(r[r.UNKNOWN=0]="UNKNOWN",r[r.R8G8B8=20]="R8G8B8",r[r.A8R8G8B8=21]="A8R8G8B8",r[r.X8R8G8B8=22]="X8R8G8B8",r[r.R5G6B5=23]="R5G6B5",r[r.X1R5G5B5=24]="X1R5G5B5",r[r.A1R5G5B5=25]="A1R5G5B5",r[r.A4R4G4B4=26]="A4R4G4B4",r[r.R3G3B2=27]="R3G3B2",r[r.A8=28]="A8",r[r.A8R3G3B2=29]="A8R3G3B2",r[r.X4R4G4B4=30]="X4R4G4B4",r[r.A2B10G10R10=31]="A2B10G10R10",r[r.A8B8G8R8=32]="A8B8G8R8",r[r.X8B8G8R8=33]="X8B8G8R8",r[r.G16R16=34]="G16R16",r[r.A2R10G10B10=35]="A2R10G10B10",r[r.A16B16G16R16=36]="A16B16G16R16",r[r.A8P8=40]="A8P8",r[r.P8=41]="P8",r[r.L8=50]="L8",r[r.A8L8=51]="A8L8",r[r.A4L4=52]="A4L4",r[r.V8U8=60]="V8U8",r[r.L6V5U5=61]="L6V5U5",r[r.X8L8V8U8=62]="X8L8V8U8",r[r.Q8W8V8U8=63]="Q8W8V8U8",r[r.V16U16=64]="V16U16",r[r.A2W10V10U10=67]="A2W10V10U10",r[r.Q16W16V16U16=110]="Q16W16V16U16",r[r.R16F=111]="R16F",r[r.G16R16F=112]="G16R16F",r[r.A16B16G16R16F=113]="A16B16G16R16F",r[r.R32F=114]="R32F",r[r.G32R32F=115]="G32R32F",r[r.A32B32G32R32F=116]="A32B32G32R32F",r[r.UYVY=Bt("UYVY")]="UYVY",r[r.R8G8_B8G8=Bt("RGBG")]="R8G8_B8G8",r[r.YUY2=Bt("YUY2")]="YUY2",r[r.D3DFMT_G8R8_G8B8=Bt("GRGB")]="D3DFMT_G8R8_G8B8",r[r.DXT1=Bt("DXT1")]="DXT1",r[r.DXT2=Bt("DXT2")]="DXT2",r[r.DXT3=Bt("DXT3")]="DXT3",r[r.DXT4=Bt("DXT4")]="DXT4",r[r.DXT5=Bt("DXT5")]="DXT5",r[r.ATI1=Bt("ATI1")]="ATI1",r[r.AT1N=Bt("AT1N")]="AT1N",r[r.ATI2=Bt("ATI2")]="ATI2",r[r.AT2N=Bt("AT2N")]="AT2N",r[r.BC4U=Bt("BC4U")]="BC4U",r[r.BC4S=Bt("BC4S")]="BC4S",r[r.BC5U=Bt("BC5U")]="BC5U",r[r.BC5S=Bt("BC5S")]="BC5S",r[r.DX10=Bt("DX10")]="DX10",r))(qt||{});const Ul={[qt.DXT1]:"bc1-rgba-unorm",[qt.DXT2]:"bc2-rgba-unorm",[qt.DXT3]:"bc2-rgba-unorm",[qt.DXT4]:"bc3-rgba-unorm",[qt.DXT5]:"bc3-rgba-unorm",[qt.ATI1]:"bc4-r-unorm",[qt.BC4U]:"bc4-r-unorm",[qt.BC4S]:"bc4-r-snorm",[qt.ATI2]:"bc5-rg-unorm",[qt.BC5U]:"bc5-rg-unorm",[qt.BC5S]:"bc5-rg-snorm",36:"rgba16uint",110:"rgba16sint",111:"r16float",112:"rg16float",113:"rgba16float",114:"r32float",115:"rg32float",116:"rgba32float"},Zt={70:"bc1-rgba-unorm",71:"bc1-rgba-unorm",72:"bc1-rgba-unorm-srgb",73:"bc2-rgba-unorm",74:"bc2-rgba-unorm",75:"bc2-rgba-unorm-srgb",76:"bc3-rgba-unorm",77:"bc3-rgba-unorm",78:"bc3-rgba-unorm-srgb",79:"bc4-r-unorm",80:"bc4-r-unorm",81:"bc4-r-snorm",82:"bc5-rg-unorm",83:"bc5-rg-unorm",84:"bc5-rg-snorm",94:"bc6h-rgb-ufloat",95:"bc6h-rgb-ufloat",96:"bc6h-rgb-float",97:"bc7-rgba-unorm",98:"bc7-rgba-unorm",99:"bc7-rgba-unorm-srgb",28:"rgba8unorm",29:"rgba8unorm-srgb",87:"bgra8unorm",91:"bgra8unorm-srgb",41:"r32float",49:"rg8unorm",56:"r16uint",61:"r8unorm",24:"rgb10a2unorm",11:"rgba16uint",13:"rgba16sint",10:"rgba16float",54:"r16float",34:"rg16float",16:"rg32float",2:"rgba32float"},Z={MAGIC_VALUE:542327876,MAGIC_SIZE:4,HEADER_SIZE:124,HEADER_DX10_SIZE:20,PIXEL_FORMAT_FLAGS:{ALPHAPIXELS:1,ALPHA:2,FOURCC:4,RGB:64,RGBA:65,YUV:512,LUMINANCE:131072,LUMINANCEA:131073},RESOURCE_MISC_TEXTURECUBE:4,HEADER_FIELDS:OA,HEADER_DX10_FIELDS:GA,DXGI_FORMAT:Fl,D3D10_RESOURCE_DIMENSION:Dl,D3DFMT:qt},n_={"bc1-rgba-unorm":8,"bc1-rgba-unorm-srgb":8,"bc2-rgba-unorm":16,"bc2-rgba-unorm-srgb":16,"bc3-rgba-unorm":16,"bc3-rgba-unorm-srgb":16,"bc4-r-unorm":8,"bc4-r-snorm":8,"bc5-rg-unorm":16,"bc5-rg-snorm":16,"bc6h-rgb-ufloat":16,"bc6h-rgb-float":16,"bc7-rgba-unorm":16,"bc7-rgba-unorm-srgb":16};function s_(r,t){const{format:e,fourCC:i,width:n,height:s,dataOffset:a,mipmapCount:o}=BA(r);if(!t.includes(e))throw new Error(`Unsupported texture format: ${i} ${e}, supported: ${t}`);if(o<=1)return{format:e,width:n,height:s,resource:[new Uint8Array(r,a)],alphaMode:"no-premultiply-alpha"};const l=IA(e,n,s,a,o,r);return{format:e,width:n,height:s,resource:l,alphaMode:"no-premultiply-alpha"}}function IA(r,t,e,i,n,s){const a=[],o=n_[r];let l=t,u=e,c=i;for(let h=0;h>1,1),u=Math.max(u>>1,1)}return a}function BA(r){const t=new Uint32Array(r,0,Z.HEADER_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(t[Z.HEADER_FIELDS.MAGIC]!==Z.MAGIC_VALUE)throw new Error("Invalid magic number in DDS header");const e=t[Z.HEADER_FIELDS.HEIGHT],i=t[Z.HEADER_FIELDS.WIDTH],n=Math.max(1,t[Z.HEADER_FIELDS.MIPMAP_COUNT]),s=t[Z.HEADER_FIELDS.PF_FLAGS],a=t[Z.HEADER_FIELDS.FOURCC],o=FA(t,s,a,r),l=Z.MAGIC_SIZE+Z.HEADER_SIZE+(a===Z.D3DFMT.DX10?Z.HEADER_DX10_SIZE:0);return{format:o,fourCC:a,width:i,height:e,dataOffset:l,mipmapCount:n}}function FA(r,t,e,i){if(t&Z.PIXEL_FORMAT_FLAGS.FOURCC){if(e===Z.D3DFMT.DX10){const n=new Uint32Array(i,Z.MAGIC_SIZE+Z.HEADER_SIZE,Z.HEADER_DX10_SIZE/Uint32Array.BYTES_PER_ELEMENT);if(n[Z.HEADER_DX10_FIELDS.MISC_FLAG]===Z.RESOURCE_MISC_TEXTURECUBE)throw new Error("DDSParser does not support cubemap textures");if(n[Z.HEADER_DX10_FIELDS.RESOURCE_DIMENSION]===Z.D3D10_RESOURCE_DIMENSION.DDS_DIMENSION_TEXTURE3D)throw new Error("DDSParser does not supported 3D texture data");const s=n[Z.HEADER_DX10_FIELDS.DXGI_FORMAT];if(s in Zt)return Zt[s];throw new Error(`DDSParser cannot parse texture data with DXGI format ${s}`)}if(e in Ul)return Ul[e];throw new Error(`DDSParser cannot parse texture data with fourCC format ${e}`)}if(t&Z.PIXEL_FORMAT_FLAGS.RGB||t&Z.PIXEL_FORMAT_FLAGS.RGBA)return DA(r);throw t&Z.PIXEL_FORMAT_FLAGS.YUV?new Error("DDSParser does not supported YUV uncompressed texture data."):t&Z.PIXEL_FORMAT_FLAGS.LUMINANCE||t&Z.PIXEL_FORMAT_FLAGS.LUMINANCEA?new Error("DDSParser does not support single-channel (lumninance) texture data!"):t&Z.PIXEL_FORMAT_FLAGS.ALPHA||t&Z.PIXEL_FORMAT_FLAGS.ALPHAPIXELS?new Error("DDSParser does not support single-channel (alpha) texture data!"):new Error("DDSParser failed to load a texture file due to an unknown reason!")}function DA(r){const t=r[Z.HEADER_FIELDS.RGB_BITCOUNT],e=r[Z.HEADER_FIELDS.R_BIT_MASK],i=r[Z.HEADER_FIELDS.G_BIT_MASK],n=r[Z.HEADER_FIELDS.B_BIT_MASK],s=r[Z.HEADER_FIELDS.A_BIT_MASK];switch(t){case 32:if(e===255&&i===65280&&n===16711680&&s===4278190080)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM];if(e===16711680&&i===65280&&n===255&&s===4278190080)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B8G8R8A8_UNORM];if(e===1072693248&&i===1047552&&n===1023&&s===3221225472)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R10G10B10A2_UNORM];if(e===65535&&i===4294901760&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R16G16_UNORM];if(e===4294967295&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R32_FLOAT];break;case 24:break;case 16:if(e===31744&&i===992&&n===31&&s===32768)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B5G5R5A1_UNORM];if(e===63488&&i===2016&&n===31&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B5G6R5_UNORM];if(e===3840&&i===240&&n===15&&s===61440)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_B4G4R4A4_UNORM];if(e===255&&i===0&&n===0&&s===65280)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8G8_UNORM];if(e===65535&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R16_UNORM];break;case 8:if(e===255&&i===0&&n===0&&s===0)return Zt[Z.DXGI_FORMAT.DXGI_FORMAT_R8_UNORM];break}throw new Error(`DDSParser does not support uncompressed texture with configuration: + bitCount = ${t}, rBitMask = ${e}, gBitMask = ${i}, aBitMask = ${s}`)}var UA=Object.defineProperty,$A=Object.defineProperties,kA=Object.getOwnPropertyDescriptors,a_=Object.getOwnPropertySymbols,LA=Object.prototype.hasOwnProperty,NA=Object.prototype.propertyIsEnumerable,o_=(r,t,e)=>t in r?UA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,XA=(r,t)=>{for(var e in t||(t={}))LA.call(t,e)&&o_(r,e,t[e]);if(a_)for(var e of a_(t))NA.call(t,e)&&o_(r,e,t[e]);return r},jA=(r,t)=>$A(r,kA(t));const HA={extension:{type:S.LoadParser,priority:te.High,name:"loadDDS"},name:"loadDDS",id:"dds",test(r){return le(r,[".dds"])},async load(r,t,e){var i;const n=await Ui(),s=await(await fetch(r)).arrayBuffer(),a=s_(s,n),o=new Di(jA(XA({},a),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}};var l_=(r=>(r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGBA=6408]="RGBA",r[r.RGBA8UI=36220]="RGBA8UI",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.RGBA8I=36238]="RGBA8I",r[r.RGBA8=32856]="RGBA8",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r))(l_||{}),zA=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(zA||{}),WA=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(WA||{});const Et={FILE_HEADER_SIZE:64,FILE_IDENTIFIER:[171,75,84,88,32,49,49,187,13,10,26,10],FORMATS_TO_COMPONENTS:{6408:4,6407:3,33319:2,6403:1,6409:1,6410:2,6406:1},INTERNAL_FORMAT_TO_BYTES_PER_PIXEL:{33776:.5,33777:.5,33778:1,33779:1,35916:.5,35917:.5,35918:1,35919:1,36283:.5,36284:.5,36285:1,36286:1,37488:.5,37489:.5,37490:1,37491:1,37492:.5,37496:1,37493:.5,37497:1,37494:.5,37495:.5,37808:1,37840:1,37809:.8,37841:.8,37810:.64,37842:.64,37811:.53375,37843:.53375,37812:.445,37844:.445,37813:.4,37845:.4,37814:.33375,37846:.33375,37815:.25,37847:.25,37816:.32,37848:.32,37817:.26625,37849:.26625,37818:.2,37850:.2,37819:.16,37851:.16,37820:.13375,37852:.13375,37821:.11125,37853:.11125,36492:1,36493:1,36494:1,36495:1},INTERNAL_FORMAT_TO_TEXTURE_FORMATS:{33776:"bc1-rgba-unorm",33777:"bc1-rgba-unorm",33778:"bc2-rgba-unorm",33779:"bc3-rgba-unorm",35916:"bc1-rgba-unorm-srgb",35917:"bc1-rgba-unorm-srgb",35918:"bc2-rgba-unorm-srgb",35919:"bc3-rgba-unorm-srgb",36283:"bc4-r-unorm",36284:"bc4-r-snorm",36285:"bc5-rg-unorm",36286:"bc5-rg-snorm",37488:"eac-r11unorm",37490:"eac-rg11snorm",37492:"etc2-rgb8unorm",37496:"etc2-rgba8unorm",37493:"etc2-rgb8unorm-srgb",37497:"etc2-rgba8unorm-srgb",37494:"etc2-rgb8a1unorm",37495:"etc2-rgb8a1unorm-srgb",37808:"astc-4x4-unorm",37840:"astc-4x4-unorm-srgb",37809:"astc-5x4-unorm",37841:"astc-5x4-unorm-srgb",37810:"astc-5x5-unorm",37842:"astc-5x5-unorm-srgb",37811:"astc-6x5-unorm",37843:"astc-6x5-unorm-srgb",37812:"astc-6x6-unorm",37844:"astc-6x6-unorm-srgb",37813:"astc-8x5-unorm",37845:"astc-8x5-unorm-srgb",37814:"astc-8x6-unorm",37846:"astc-8x6-unorm-srgb",37815:"astc-8x8-unorm",37847:"astc-8x8-unorm-srgb",37816:"astc-10x5-unorm",37848:"astc-10x5-unorm-srgb",37817:"astc-10x6-unorm",37849:"astc-10x6-unorm-srgb",37818:"astc-10x8-unorm",37850:"astc-10x8-unorm-srgb",37819:"astc-10x10-unorm",37851:"astc-10x10-unorm-srgb",37820:"astc-12x10-unorm",37852:"astc-12x10-unorm-srgb",37821:"astc-12x12-unorm",37853:"astc-12x12-unorm-srgb",36492:"bc7-rgba-unorm",36493:"bc7-rgba-unorm-srgb",36494:"bc6h-rgb-float",36495:"bc6h-rgb-ufloat",35907:"rgba8unorm-srgb",36759:"rgba8snorm",36220:"rgba8uint",36238:"rgba8sint",6408:"rgba8unorm"},FIELDS:{FILE_IDENTIFIER:0,ENDIANNESS:12,GL_TYPE:16,GL_TYPE_SIZE:20,GL_FORMAT:24,GL_INTERNAL_FORMAT:28,GL_BASE_INTERNAL_FORMAT:32,PIXEL_WIDTH:36,PIXEL_HEIGHT:40,PIXEL_DEPTH:44,NUMBER_OF_ARRAY_ELEMENTS:48,NUMBER_OF_FACES:52,NUMBER_OF_MIPMAP_LEVELS:56,BYTES_OF_KEY_VALUE_DATA:60},TYPES_TO_BYTES_PER_COMPONENT:{5121:1,5123:2,5124:4,5125:4,5126:4,36193:8},TYPES_TO_BYTES_PER_PIXEL:{32819:2,32820:2,33635:2},ENDIANNESS:67305985};function u_(r,t){const e=new DataView(r);if(!qA(e))throw new Error("Invalid KTX identifier in header");const{littleEndian:i,glType:n,glFormat:s,glInternalFormat:a,pixelWidth:o,pixelHeight:l,numberOfMipmapLevels:u,offset:c}=KA(e),h=Et.INTERNAL_FORMAT_TO_TEXTURE_FORMATS[a];if(!h)throw new Error(`Unknown texture format ${a}`);if(!t.includes(h))throw new Error(`Unsupported texture format: ${h}, supportedFormats: ${t}`);const p=YA(n,s,a),f=VA(e,n,p,o,l,c,u,i);return{format:h,width:o,height:l,resource:f,alphaMode:"no-premultiply-alpha"}}function VA(r,t,e,i,n,s,a,o){const l=i+3&-4,u=n+3&-4;let c=i*n;t===0&&(c=l*u);let h=c*e,p=i,f=n,m=l,g=u,_=s;const y=new Array(a);for(let b=0;b>1||1,f=f>>1||1,m=p+4-1&-4,g=f+4-1&-4,h=m*g*e}return y}function YA(r,t,e){let i=Et.INTERNAL_FORMAT_TO_BYTES_PER_PIXEL[e];if(r!==0&&(Et.TYPES_TO_BYTES_PER_COMPONENT[r]?i=Et.TYPES_TO_BYTES_PER_COMPONENT[r]*Et.FORMATS_TO_COMPONENTS[t]:i=Et.TYPES_TO_BYTES_PER_PIXEL[r]),i===void 0)throw new Error("Unable to resolve the pixel format stored in the *.ktx file!");return i}function KA(r){const t=r.getUint32(Et.FIELDS.ENDIANNESS,!0)===Et.ENDIANNESS,e=r.getUint32(Et.FIELDS.GL_TYPE,t),i=r.getUint32(Et.FIELDS.GL_FORMAT,t),n=r.getUint32(Et.FIELDS.GL_INTERNAL_FORMAT,t),s=r.getUint32(Et.FIELDS.PIXEL_WIDTH,t),a=r.getUint32(Et.FIELDS.PIXEL_HEIGHT,t)||1,o=r.getUint32(Et.FIELDS.PIXEL_DEPTH,t)||1,l=r.getUint32(Et.FIELDS.NUMBER_OF_ARRAY_ELEMENTS,t)||1,u=r.getUint32(Et.FIELDS.NUMBER_OF_FACES,t),c=r.getUint32(Et.FIELDS.NUMBER_OF_MIPMAP_LEVELS,t),h=r.getUint32(Et.FIELDS.BYTES_OF_KEY_VALUE_DATA,t);if(a===0||o!==1)throw new Error("Only 2D textures are supported");if(u!==1)throw new Error("CubeTextures are not supported by KTXLoader yet!");if(l!==1)throw new Error("WebGL does not support array textures");return{littleEndian:t,glType:e,glFormat:i,glInternalFormat:n,pixelWidth:s,pixelHeight:a,numberOfMipmapLevels:c,offset:Et.FILE_HEADER_SIZE+h}}function qA(r){for(let t=0;tt in r?ZA(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rC=(r,t)=>{for(var e in t||(t={}))tC.call(t,e)&&h_(r,e,t[e]);if(c_)for(var e of c_(t))eC.call(t,e)&&h_(r,e,t[e]);return r},iC=(r,t)=>QA(r,JA(t));const nC={extension:{type:S.LoadParser,priority:te.High,name:"loadKTX"},name:"loadKTX",id:"ktx",test(r){return le(r,".ktx")},async load(r,t,e){var i;const n=await Ui(),s=await(await fetch(r)).arrayBuffer(),a=u_(s,n),o=new Di(iC(rC({},a),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(o,e,r)},unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},sC='(function(){"use strict";const s={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:i},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:i}};function f(r){const t=r.format;if(s[t]){const n=s[t].convertFunction,o=r.resource;for(let e=0;e{LIBKTX({locateFile:o=>t}).then(o=>{n(o)})})}return c}async function v(r,t){const n=await fetch(r);if(n.ok){const o=await n.arrayBuffer();return new t.ktxTexture(new Uint8Array(o))}throw new Error(`Failed to load KTX(2) texture: ${r}`)}const x=["bc7-rgba-unorm","astc-4x4-unorm","etc2-rgba8unorm","bc3-rgba-unorm","rgba8unorm"];async function B(r){const t=await g(),n=await v(r,t);let o;if(n.needsTranscoding){o=u;const R=t.TranscodeTarget[l];if(n.transcodeBasis(R,0)!==t.ErrorCode.SUCCESS)throw new Error("Unable to transcode basis texture.")}else o=U(n);const e=d(n),b={width:n.baseWidth,height:n.baseHeight,format:o,mipLevelCount:n.numLevels,resource:e,alphaMode:"no-premultiply-alpha"};return f(b),b}async function A(r,t,n){r&&(a.jsUrl=r),t&&(a.wasmUrl=t),u=x.filter(o=>n.includes(o))[0],l=T(u),await g()}const m={init:async r=>{const{jsUrl:t,wasmUrl:n,supportedTextures:o}=r;await A(t,n,o)},load:async r=>{var t;try{const n=await B(r.url);return{type:"load",url:r.url,success:!0,textureOptions:n,transferables:(t=n.resource)==null?void 0:t.map(o=>o.buffer)}}catch(n){throw n}}};self.onmessage=(async r=>{var t;const n=r.data;try{const o=await((t=m[n.type])==null?void 0:t.call(m,n));o&&self.postMessage(o,o.transferables)}catch(o){self.postMessage({type:"error",err:o,url:n.url})}})})();\n';let Vr=null;class d_{constructor(){Vr||(Vr=URL.createObjectURL(new Blob([sC],{type:"application/javascript"}))),this.worker=new Worker(Vr)}}d_.revokeObjectURL=function(){Vr&&(URL.revokeObjectURL(Vr),Vr=null)};const ls={jsUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.js",wasmUrl:"https://cdn.jsdelivr.net/npm/pixi.js/transcoders/ktx/libktx.wasm"};function aC(r){Object.assign(ls,r)}let ki;const p_={},f_={};function oC(r){return ki||(ki=new d_().worker,ki.onmessage=t=>{const{err:e,success:i,url:n,textureOptions:s}=t.data;if(e){f_[n](e);return}i||console.warn("Failed to load KTX texture",n),p_[n](s)},ki.postMessage({type:"init",jsUrl:ls.jsUrl,wasmUrl:ls.wasmUrl,supportedTextures:r})),ki}function m_(r,t){const e=oC(t);return new Promise((i,n)=>{p_[r]=i,f_[r]=n,e.postMessage({type:"load",url:r})})}var lC=Object.defineProperty,uC=Object.defineProperties,cC=Object.getOwnPropertyDescriptors,g_=Object.getOwnPropertySymbols,hC=Object.prototype.hasOwnProperty,dC=Object.prototype.propertyIsEnumerable,__=(r,t,e)=>t in r?lC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pC=(r,t)=>{for(var e in t||(t={}))hC.call(t,e)&&__(r,e,t[e]);if(g_)for(var e of g_(t))dC.call(t,e)&&__(r,e,t[e]);return r},fC=(r,t)=>uC(r,cC(t));const mC={extension:{type:S.LoadParser,priority:te.High,name:"loadKTX2"},name:"loadKTX2",id:"ktx2",test(r){return le(r,".ktx2")},async load(r,t,e){var i;const n=await Ui(),s=await m_(r,n),a=new Di(fC(pC({},s),{resolution:((i=t.data)==null?void 0:i.resolution)||je(r)}));return He(a,e,r)},async unload(r){Array.isArray(r)?r.forEach(t=>t.destroy(!0)):r.destroy(!0)}},$l={rgb8unorm:{convertedFormat:"rgba8unorm",convertFunction:y_},"rgb8unorm-srgb":{convertedFormat:"rgba8unorm-srgb",convertFunction:y_}};function gC(r){const t=r.format;if($l[t]){const e=$l[t].convertFunction,i=r.resource;for(let n=0;nle(r,[".ktx",".ktx2",".dds"]),parse:r=>{var t,e;let i;const n=r.split(".");if(n.length>2){const s=n[n.length-2];us.includes(s)&&(i=s)}else i=n[n.length-1];return{resolution:parseFloat((e=(t=$e.RETINA_PREFIX.exec(r))==null?void 0:t[1])!=null?e:"1"),format:i,src:r}}};let cs;const wC={extension:{type:S.DetectionParser,priority:2},test:async()=>!!(await Pi()||Ei()),add:async r=>{const t=await Bl();return cs=EC(t),[...cs,...r]},remove:async r=>cs?r.filter(t=>!(t in cs)):r};function EC(r){const t=["basis"],e={};return r.forEach(i=>{const n=i.split("-")[0];n&&!e[n]&&(e[n]=!0,t.push(n))}),t.sort((i,n)=>{const s=us.indexOf(i),a=us.indexOf(n);return s===-1?1:a===-1?-1:s-a}),t}const PC=new Mt,AC=new U,Li=new ut,kl=class{cull(t,e,i=!0){this._cullRecursive(t,e,i)}_cullRecursive(t,e,i=!0){if(t.cullable&&t.measurable&&t.includeInBuild)if(t.cullArea){Li.x=e.x,Li.y=e.y,Li.width=e.width,Li.height=e.height;const n=i?t.worldTransform:t.getGlobalTransform(AC,i);t.culled=!Li.intersects(t.cullArea,n)}else{const n=li(t,i,PC);t.culled=n.x>=e.x+e.width||n.y>=e.y+e.height||n.x+n.width<=e.x||n.y+n.height<=e.y}else t.culled=!1;if(!(!t.cullableChildren||t.culled||!t.renderable||!t.measurable||!t.includeInBuild))for(let n=0;n{var e;const i=((e=t==null?void 0:t.culler)==null?void 0:e.updateTransform)!==!0;x_.shared.cull(this.stage,this.renderer.screen,i),this.renderer.render({container:this.stage})}}static destroy(){this.render=this._renderRef}}T_.extension={priority:10,type:S.Application,name:"culler"};const CC={extension:{type:S.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Promise.resolve().then(function(){return bw})}};var S_=` in vec2 vTextureCoord; in vec4 vColor; @@ -395,7 +395,7 @@ void main(void) gl_Position = filterVertexPosition(); vTextureCoord = filterTextureCoord(); } -`,P_=` +`,E_=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, @@ -469,7 +469,7 @@ fn mainFragment( {MAIN} return out; -}`,TC=Object.defineProperty,E_=Object.getOwnPropertySymbols,SC=Object.prototype.hasOwnProperty,wC=Object.prototype.propertyIsEnumerable,A_=(r,t,e)=>t in r?TC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C_=(r,t)=>{for(var e in t||(t={}))SC.call(t,e)&&A_(r,e,t[e]);if(E_)for(var e of E_(t))wC.call(t,e)&&A_(r,e,t[e]);return r};class PC extends Ee{constructor(t){const e=t.gpu,i=M_(C_({source:P_},e)),n=Xt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),s=t.gl,a=M_(C_({source:S_},s)),o=Wt.from({vertex:w_,fragment:a}),l=new At({uBlend:{value:1,type:"f32"}});super({gpuProgram:n,glProgram:o,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:D.EMPTY}})}}function M_(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const EC=` +}`,MC=Object.defineProperty,P_=Object.getOwnPropertySymbols,RC=Object.prototype.hasOwnProperty,OC=Object.prototype.propertyIsEnumerable,A_=(r,t,e)=>t in r?MC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,C_=(r,t)=>{for(var e in t||(t={}))RC.call(t,e)&&A_(r,e,t[e]);if(P_)for(var e of P_(t))OC.call(t,e)&&A_(r,e,t[e]);return r};class GC extends Pe{constructor(t){const e=t.gpu,i=M_(C_({source:E_},e)),n=Xt.from({vertex:{source:i,entryPoint:"mainVertex"},fragment:{source:i,entryPoint:"mainFragment"}}),s=t.gl,a=M_(C_({source:S_},s)),o=Wt.from({vertex:w_,fragment:a}),l=new At({uBlend:{value:1,type:"f32"}});super({gpuProgram:n,glProgram:o,blendRequired:!0,resources:{blendUniforms:l,uBackTexture:D.EMPTY}})}}function M_(r){const{source:t,functions:e,main:i}=r;return t.replace("{FUNCTIONS}",e).replace("{MAIN}",i)}const IC=` float getLuminosity(vec3 c) { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } @@ -548,7 +548,7 @@ fn mainFragment( return color; } - `,AC=` + `,BC=` fn getLuminosity(c: vec3) -> f32 { return 0.3*c.r + 0.59*c.g + 0.11*c.b; @@ -657,7 +657,7 @@ void main() { finalColor = texture(uTexture, vTextureCoord) * uAlpha; } -`,kl=`struct GlobalFilterUniforms { +`,Ll=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, @@ -725,9 +725,9 @@ fn mainFragment( var sample = textureSample(uTexture, uSampler, uv); return sample * alphaUniforms.uAlpha; -}`,CC=Object.defineProperty,MC=Object.defineProperties,RC=Object.getOwnPropertyDescriptors,us=Object.getOwnPropertySymbols,O_=Object.prototype.hasOwnProperty,G_=Object.prototype.propertyIsEnumerable,I_=(r,t,e)=>t in r?CC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ll=(r,t)=>{for(var e in t||(t={}))O_.call(t,e)&&I_(r,e,t[e]);if(us)for(var e of us(t))G_.call(t,e)&&I_(r,e,t[e]);return r},OC=(r,t)=>MC(r,RC(t)),GC=(r,t)=>{var e={};for(var i in r)O_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&us)for(var i of us(r))t.indexOf(i)<0&&G_.call(r,i)&&(e[i]=r[i]);return e};const B_=class F1 extends Ee{constructor(t){t=Ll(Ll({},F1.defaultOptions),t);const e=Xt.from({vertex:{source:kl,entryPoint:"mainVertex"},fragment:{source:kl,entryPoint:"mainFragment"}}),i=Wt.from({vertex:bi,fragment:R_,name:"alpha-filter"}),n=t,{alpha:s}=n,a=GC(n,["alpha"]),o=new At({uAlpha:{value:s,type:"f32"}});super(OC(Ll({},a),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:o}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};B_.defaultOptions={alpha:1};let IC=B_;const Nl={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},BC=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(` -`);function F_(r){const t=Nl[r],e=t.length;let i="";const n="finalColor = ",s=" + ",a="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let o=0;ot in r?FC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Nl=(r,t)=>{for(var e in t||(t={}))O_.call(t,e)&&I_(r,e,t[e]);if(hs)for(var e of hs(t))G_.call(t,e)&&I_(r,e,t[e]);return r},$C=(r,t)=>DC(r,UC(t)),kC=(r,t)=>{var e={};for(var i in r)O_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&hs)for(var i of hs(r))t.indexOf(i)<0&&G_.call(r,i)&&(e[i]=r[i]);return e};const B_=class U1 extends Pe{constructor(t){t=Nl(Nl({},U1.defaultOptions),t);const e=Xt.from({vertex:{source:Ll,entryPoint:"mainVertex"},fragment:{source:Ll,entryPoint:"mainFragment"}}),i=Wt.from({vertex:bi,fragment:R_,name:"alpha-filter"}),n=t,{alpha:s}=n,a=kC(n,["alpha"]),o=new At({uAlpha:{value:s,type:"f32"}});super($C(Nl({},a),{gpuProgram:e,glProgram:i,resources:{alphaUniforms:o}}))}get alpha(){return this.resources.alphaUniforms.uniforms.uAlpha}set alpha(t){this.resources.alphaUniforms.uniforms.uAlpha=t}};B_.defaultOptions={alpha:1};let LC=B_;const Xl={5:[.153388,.221461,.250301],7:[.071303,.131514,.189879,.214607],9:[.028532,.067234,.124009,.179044,.20236],11:[.0093,.028002,.065984,.121703,.175713,.198596],13:[.002406,.009255,.027867,.065666,.121117,.174868,.197641],15:[489e-6,.002403,.009246,.02784,.065602,.120999,.174697,.197448]},NC=["in vec2 vBlurTexCoords[%size%];","uniform sampler2D uTexture;","out vec4 finalColor;","void main(void)","{"," %blur%","}"].join(` +`);function F_(r){const t=Xl[r],e=t.length;let i="";const n="finalColor = ",s=" + ",a="texture(uTexture, vBlurTexCoords[%index%]) * %value%";for(let o=0;o,`,r?s[h]=`filteredCord + vec2(${h-i+1} * pixelStrength, 0.0),`:s[h]=`filteredCord + vec2(0.0, ${h-i+1} * pixelStrength),`;const p=h,`,r?s[h]=`filteredCord + vec2(${h-i+1} * pixelStrength, 0.0),`:s[h]=`filteredCord + vec2(0.0, ${h-i+1} * pixelStrength),`;const p=ht in r?DC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xl=(r,t)=>{for(var e in t||(t={}))UC.call(t,e)&&N_(r,e,t[e]);if(L_)for(var e of L_(t))$C.call(t,e)&&N_(r,e,t[e]);return r};const X_=class D1 extends Ee{constructor(t){var e;t=Xl(Xl({},D1.defaultOptions),t);const i=U_(t.horizontal,t.kernelSize),n=k_(t.horizontal,t.kernelSize);super(Xl({glProgram:i,gpuProgram:n,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this.legacy=(e=t.legacy)!=null?e:!1,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(t,e,i,n){this.legacy?this._applyLegacy(t,e,i,n):this._applyOptimized(t,e,i,n)}_applyLegacy(t,e,i,n){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,i,n);else{const s=vt.getSameSizeTexture(e);let a=e,o=s;this._state.blend=!1;const l=t.renderer.type===It.WEBGPU;for(let u=0;ut in r?kC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ni=(r,t)=>{for(var e in t||(t={}))j_.call(t,e)&&z_(r,e,t[e]);if(hs)for(var e of hs(t))H_.call(t,e)&&z_(r,e,t[e]);return r},XC=(r,t)=>LC(r,NC(t)),jC=(r,t)=>{var e={};for(var i in r)j_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&hs)for(var i of hs(r))t.indexOf(i)<0&&H_.call(r,i)&&(e[i]=r[i]);return e};class W_ extends Ee{constructor(...t){var e;let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={strength:i},t[1]!==void 0&&(i.quality=t[1]),t[2]!==void 0&&(i.resolution=t[2]||"inherit"),t[3]!==void 0&&(i.kernelSize=t[3])),i=Ni(Ni({},cs.defaultOptions),i);const n=i,{strength:s,strengthX:a,strengthY:o,quality:l}=n,u=jC(n,["strength","strengthX","strengthY","quality"]);super(XC(Ni({},u),{compatibleRenderers:It.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new cs(Ni({horizontal:!0},i)),this.blurYFilter=new cs(Ni({horizontal:!1},i)),this.quality=l,this.strengthX=a!=null?a:s,this.strengthY=o!=null?o:s,this.repeatEdgePixels=!1}apply(t,e,i,n){const s=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(s&&a){const o=vt.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,o,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,o,i,n),vt.returnTexture(o)}else a?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,i,n)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,i,n))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}W_.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var V_=` +`),c=$_.replace("%blur-struct%",o).replace("%blur-vertex-out%",l).replace("%blur-fragment-in%",o).replace("%blur-sampling%",u).replace("%dimension%",r?"z":"w");return Xt.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}})}var jC=Object.defineProperty,L_=Object.getOwnPropertySymbols,HC=Object.prototype.hasOwnProperty,zC=Object.prototype.propertyIsEnumerable,N_=(r,t,e)=>t in r?jC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jl=(r,t)=>{for(var e in t||(t={}))HC.call(t,e)&&N_(r,e,t[e]);if(L_)for(var e of L_(t))zC.call(t,e)&&N_(r,e,t[e]);return r};const X_=class $1 extends Pe{constructor(t){var e;t=jl(jl({},$1.defaultOptions),t);const i=U_(t.horizontal,t.kernelSize),n=k_(t.horizontal,t.kernelSize);super(jl({glProgram:i,gpuProgram:n,resources:{blurUniforms:{uStrength:{value:0,type:"f32"}}}},t)),this.horizontal=t.horizontal,this.legacy=(e=t.legacy)!=null?e:!1,this._quality=0,this.quality=t.quality,this.blur=t.strength,this._blurUniforms=this.resources.blurUniforms,this._uniforms=this._blurUniforms.uniforms}apply(t,e,i,n){this.legacy?this._applyLegacy(t,e,i,n):this._applyOptimized(t,e,i,n)}_applyLegacy(t,e,i,n){if(this._uniforms.uStrength=this.strength/this.passes,this.passes===1)t.applyFilter(this,e,i,n);else{const s=vt.getSameSizeTexture(e);let a=e,o=s;this._state.blend=!1;const l=t.renderer.type===It.WEBGPU;for(let u=0;ut in r?WC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ni=(r,t)=>{for(var e in t||(t={}))j_.call(t,e)&&z_(r,e,t[e]);if(ps)for(var e of ps(t))H_.call(t,e)&&z_(r,e,t[e]);return r},KC=(r,t)=>VC(r,YC(t)),qC=(r,t)=>{var e={};for(var i in r)j_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ps)for(var i of ps(r))t.indexOf(i)<0&&H_.call(r,i)&&(e[i]=r[i]);return e};class W_ extends Pe{constructor(...t){var e;let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={strength:i},t[1]!==void 0&&(i.quality=t[1]),t[2]!==void 0&&(i.resolution=t[2]||"inherit"),t[3]!==void 0&&(i.kernelSize=t[3])),i=Ni(Ni({},ds.defaultOptions),i);const n=i,{strength:s,strengthX:a,strengthY:o,quality:l}=n,u=qC(n,["strength","strengthX","strengthY","quality"]);super(KC(Ni({},u),{compatibleRenderers:It.BOTH,resources:{}})),this._repeatEdgePixels=!1,this.blurXFilter=new ds(Ni({horizontal:!0},i)),this.blurYFilter=new ds(Ni({horizontal:!1},i)),this.quality=l,this.strengthX=a!=null?a:s,this.strengthY=o!=null?o:s,this.repeatEdgePixels=!1}apply(t,e,i,n){const s=Math.abs(this.blurXFilter.strength),a=Math.abs(this.blurYFilter.strength);if(s&&a){const o=vt.getSameSizeTexture(e);this.blurXFilter.blendMode="normal",this.blurXFilter.apply(t,e,o,!0),this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,o,i,n),vt.returnTexture(o)}else a?(this.blurYFilter.blendMode=this.blendMode,this.blurYFilter.apply(t,e,i,n)):(this.blurXFilter.blendMode=this.blendMode,this.blurXFilter.apply(t,e,i,n))}updatePadding(){this._repeatEdgePixels?this.padding=0:this.padding=Math.max(Math.abs(this.blurXFilter.blur),Math.abs(this.blurYFilter.blur))*2}get strength(){if(this.strengthX!==this.strengthY)throw new Error("BlurFilter's strengthX and strengthY are different");return this.strengthX}set strength(t){this.blurXFilter.blur=this.blurYFilter.blur=t,this.updatePadding()}get quality(){return this.blurXFilter.quality}set quality(t){this.blurXFilter.quality=this.blurYFilter.quality=t}get strengthX(){return this.blurXFilter.blur}set strengthX(t){this.blurXFilter.blur=t,this.updatePadding()}get strengthY(){return this.blurYFilter.blur}set strengthY(t){this.blurYFilter.blur=t,this.updatePadding()}get blur(){return this.strength}set blur(t){this.strength=t}get blurX(){return this.strengthX}set blurX(t){this.strengthX=t}get blurY(){return this.strengthY}set blurY(t){this.strengthY=t}get repeatEdgePixels(){return this._repeatEdgePixels}set repeatEdgePixels(t){this._repeatEdgePixels=t,this.updatePadding()}}W_.defaultOptions={strength:8,quality:4,kernelSize:5,legacy:!1};var V_=` in vec2 vTextureCoord; in vec4 vColor; @@ -909,7 +909,7 @@ void main() finalColor = vec4(rgb, result.a); } -`,jl=`struct GlobalFilterUniforms { +`,Hl=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, @@ -1017,7 +1017,7 @@ fn mainFragment( rgb.b *= result.a; return vec4(rgb, result.a); -}`,HC=Object.defineProperty,zC=Object.defineProperties,WC=Object.getOwnPropertyDescriptors,Y_=Object.getOwnPropertySymbols,VC=Object.prototype.hasOwnProperty,YC=Object.prototype.propertyIsEnumerable,K_=(r,t,e)=>t in r?HC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,KC=(r,t)=>{for(var e in t||(t={}))VC.call(t,e)&&K_(r,e,t[e]);if(Y_)for(var e of Y_(t))YC.call(t,e)&&K_(r,e,t[e]);return r},qC=(r,t)=>zC(r,WC(t));class ZC extends Ee{constructor(t={}){const e=new At({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),i=Xt.from({vertex:{source:jl,entryPoint:"mainVertex"},fragment:{source:jl,entryPoint:"mainFragment"}}),n=Wt.from({vertex:bi,fragment:V_,name:"color-matrix-filter"});super(qC(KC({},t),{gpuProgram:i,glProgram:n,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){if(e){const i=[...t];this._multiply(i,this.matrix,t),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i}else this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t;this.resources.colorMatrixUniforms.update()}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,n,s]=tt.shared.setValue(t).toArray(),a=[i,0,0,0,0,0,n,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(a,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),n=Math.sin(t),s=Math.sqrt,a=1/3,o=s(a),l=i+(1-i)*a,u=a*(1-i)-o*n,c=a*(1-i)+o*n,h=a*(1-i)+o*n,p=i+a*(1-i),f=a*(1-i)-o*n,m=a*(1-i)-o*n,g=a*(1-i)+o*n,_=i+a*(1-i),y=[l,u,c,0,0,h,p,f,0,0,m,g,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,n=-.5*(i-1),s=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=t*2/3+1,n=(i-1)*-.5,s=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(s,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,.046249425232852304,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.2758903984886823,-.231103377548616,-.7501899197440212,1.847597816108189,0,.12137623870388682,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,.24991995145868634,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,.09698983488904393,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,.13972481597886063,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,.1860075629647401,-.037703249837783157,.8609577587992641,.15059552388459913,0,-.14497417640467167,.24113635128153335,-.07441037908422492,.44972182064877153,0,-.029655197167024642,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,.037848179746251466,.02578397704808868,.6441188644374771,.03259127616149294,0,.029265996770472907,.0466055556782719,-.0851232987247891,.5241648018700465,0,.020232119953863904,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,n,s){t||(t=.2),e||(e=.15),i||(i=16770432),n||(n=3375104);const a=tt.shared,[o,l,u]=a.setValue(i).toArray(),[c,h,p]=a.setValue(n).toArray(),f=[.3,.59,.11,0,0,o,l,u,t,0,c,h,p,e,0,o-c,l-h,u-p,0,0];this._loadMatrix(f,s)}night(t,e){t||(t=.1);const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var q_=` +}`,ZC=Object.defineProperty,QC=Object.defineProperties,JC=Object.getOwnPropertyDescriptors,Y_=Object.getOwnPropertySymbols,tM=Object.prototype.hasOwnProperty,eM=Object.prototype.propertyIsEnumerable,K_=(r,t,e)=>t in r?ZC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,rM=(r,t)=>{for(var e in t||(t={}))tM.call(t,e)&&K_(r,e,t[e]);if(Y_)for(var e of Y_(t))eM.call(t,e)&&K_(r,e,t[e]);return r},iM=(r,t)=>QC(r,JC(t));class nM extends Pe{constructor(t={}){const e=new At({uColorMatrix:{value:[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],type:"f32",size:20},uAlpha:{value:1,type:"f32"}}),i=Xt.from({vertex:{source:Hl,entryPoint:"mainVertex"},fragment:{source:Hl,entryPoint:"mainFragment"}}),n=Wt.from({vertex:bi,fragment:V_,name:"color-matrix-filter"});super(iM(rM({},t),{gpuProgram:i,glProgram:n,resources:{colorMatrixUniforms:e}})),this.alpha=1}_loadMatrix(t,e=!1){if(e){const i=[...t];this._multiply(i,this.matrix,t),this.resources.colorMatrixUniforms.uniforms.uColorMatrix=i}else this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t;this.resources.colorMatrixUniforms.update()}_multiply(t,e,i){return t[0]=e[0]*i[0]+e[1]*i[5]+e[2]*i[10]+e[3]*i[15],t[1]=e[0]*i[1]+e[1]*i[6]+e[2]*i[11]+e[3]*i[16],t[2]=e[0]*i[2]+e[1]*i[7]+e[2]*i[12]+e[3]*i[17],t[3]=e[0]*i[3]+e[1]*i[8]+e[2]*i[13]+e[3]*i[18],t[4]=e[0]*i[4]+e[1]*i[9]+e[2]*i[14]+e[3]*i[19]+e[4],t[5]=e[5]*i[0]+e[6]*i[5]+e[7]*i[10]+e[8]*i[15],t[6]=e[5]*i[1]+e[6]*i[6]+e[7]*i[11]+e[8]*i[16],t[7]=e[5]*i[2]+e[6]*i[7]+e[7]*i[12]+e[8]*i[17],t[8]=e[5]*i[3]+e[6]*i[8]+e[7]*i[13]+e[8]*i[18],t[9]=e[5]*i[4]+e[6]*i[9]+e[7]*i[14]+e[8]*i[19]+e[9],t[10]=e[10]*i[0]+e[11]*i[5]+e[12]*i[10]+e[13]*i[15],t[11]=e[10]*i[1]+e[11]*i[6]+e[12]*i[11]+e[13]*i[16],t[12]=e[10]*i[2]+e[11]*i[7]+e[12]*i[12]+e[13]*i[17],t[13]=e[10]*i[3]+e[11]*i[8]+e[12]*i[13]+e[13]*i[18],t[14]=e[10]*i[4]+e[11]*i[9]+e[12]*i[14]+e[13]*i[19]+e[14],t[15]=e[15]*i[0]+e[16]*i[5]+e[17]*i[10]+e[18]*i[15],t[16]=e[15]*i[1]+e[16]*i[6]+e[17]*i[11]+e[18]*i[16],t[17]=e[15]*i[2]+e[16]*i[7]+e[17]*i[12]+e[18]*i[17],t[18]=e[15]*i[3]+e[16]*i[8]+e[17]*i[13]+e[18]*i[18],t[19]=e[15]*i[4]+e[16]*i[9]+e[17]*i[14]+e[18]*i[19]+e[19],t}brightness(t,e){const i=[t,0,0,0,0,0,t,0,0,0,0,0,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}tint(t,e){const[i,n,s]=tt.shared.setValue(t).toArray(),a=[i,0,0,0,0,0,n,0,0,0,0,0,s,0,0,0,0,0,1,0];this._loadMatrix(a,e)}greyscale(t,e){const i=[t,t,t,0,0,t,t,t,0,0,t,t,t,0,0,0,0,0,1,0];this._loadMatrix(i,e)}grayscale(t,e){this.greyscale(t,e)}blackAndWhite(t){const e=[.3,.6,.1,0,0,.3,.6,.1,0,0,.3,.6,.1,0,0,0,0,0,1,0];this._loadMatrix(e,t)}hue(t,e){t=(t||0)/180*Math.PI;const i=Math.cos(t),n=Math.sin(t),s=Math.sqrt,a=1/3,o=s(a),l=i+(1-i)*a,u=a*(1-i)-o*n,c=a*(1-i)+o*n,h=a*(1-i)+o*n,p=i+a*(1-i),f=a*(1-i)-o*n,m=a*(1-i)-o*n,g=a*(1-i)+o*n,_=i+a*(1-i),y=[l,u,c,0,0,h,p,f,0,0,m,g,_,0,0,0,0,0,1,0];this._loadMatrix(y,e)}contrast(t,e){const i=(t||0)+1,n=-.5*(i-1),s=[i,0,0,0,n,0,i,0,0,n,0,0,i,0,n,0,0,0,1,0];this._loadMatrix(s,e)}saturate(t=0,e){const i=t*2/3+1,n=(i-1)*-.5,s=[i,n,n,0,0,n,i,n,0,0,n,n,i,0,0,0,0,0,1,0];this._loadMatrix(s,e)}desaturate(){this.saturate(-1)}negative(t){const e=[-1,0,0,1,0,0,-1,0,1,0,0,0,-1,1,0,0,0,0,1,0];this._loadMatrix(e,t)}sepia(t){const e=[.393,.7689999,.18899999,0,0,.349,.6859999,.16799999,0,0,.272,.5339999,.13099999,0,0,0,0,0,1,0];this._loadMatrix(e,t)}technicolor(t){const e=[1.9125277891456083,-.8545344976951645,-.09155508482755585,0,.046249425232852304,-.3087833385928097,1.7658908555458428,-.10601743074722245,0,-.2758903984886823,-.231103377548616,-.7501899197440212,1.847597816108189,0,.12137623870388682,0,0,0,1,0];this._loadMatrix(e,t)}polaroid(t){const e=[1.438,-.062,-.062,0,0,-.122,1.378,-.122,0,0,-.016,-.016,1.483,0,0,0,0,0,1,0];this._loadMatrix(e,t)}toBGR(t){const e=[0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,1,0];this._loadMatrix(e,t)}kodachrome(t){const e=[1.1285582396593525,-.3967382283601348,-.03992559172921793,0,.24991995145868634,-.16404339962244616,1.0835251566291304,-.05498805115633132,0,.09698983488904393,-.16786010706155763,-.5603416277695248,1.6014850761964943,0,.13972481597886063,0,0,0,1,0];this._loadMatrix(e,t)}browni(t){const e=[.5997023498159715,.34553243048391263,-.2708298674538042,0,.1860075629647401,-.037703249837783157,.8609577587992641,.15059552388459913,0,-.14497417640467167,.24113635128153335,-.07441037908422492,.44972182064877153,0,-.029655197167024642,0,0,0,1,0];this._loadMatrix(e,t)}vintage(t){const e=[.6279345635605994,.3202183420819367,-.03965408211312453,0,.037848179746251466,.02578397704808868,.6441188644374771,.03259127616149294,0,.029265996770472907,.0466055556782719,-.0851232987247891,.5241648018700465,0,.020232119953863904,0,0,0,1,0];this._loadMatrix(e,t)}colorTone(t,e,i,n,s){t||(t=.2),e||(e=.15),i||(i=16770432),n||(n=3375104);const a=tt.shared,[o,l,u]=a.setValue(i).toArray(),[c,h,p]=a.setValue(n).toArray(),f=[.3,.59,.11,0,0,o,l,u,t,0,c,h,p,e,0,o-c,l-h,u-p,0,0];this._loadMatrix(f,s)}night(t,e){t||(t=.1);const i=[t*-2,-t,0,0,0,-t,0,t,0,0,0,t,t*2,0,0,0,0,0,1,0];this._loadMatrix(i,e)}predator(t,e){const i=[11.224130630493164*t,-4.794486999511719*t,-2.8746118545532227*t,0*t,.40342438220977783*t,-3.6330697536468506*t,9.193157196044922*t,-2.951810836791992*t,0*t,-1.316135048866272*t,-3.2184197902679443*t,-4.2375030517578125*t,7.476448059082031*t,0*t,.8044459223747253*t,0,0,0,1,0];this._loadMatrix(i,e)}lsd(t){const e=[2,-.4,.5,0,0,-.5,2,-.4,0,0,-.4,-.5,3,0,0,0,0,0,1,0];this._loadMatrix(e,t)}reset(){const t=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];this._loadMatrix(t,!1)}get matrix(){return this.resources.colorMatrixUniforms.uniforms.uColorMatrix}set matrix(t){this.resources.colorMatrixUniforms.uniforms.uColorMatrix=t}get alpha(){return this.resources.colorMatrixUniforms.uniforms.uAlpha}set alpha(t){this.resources.colorMatrixUniforms.uniforms.uAlpha=t}}var q_=` in vec2 vTextureCoord; in vec2 vFilterUv; @@ -1077,7 +1077,7 @@ void main(void) vTextureCoord = filterTextureCoord(); vFilterUv = getFilterCoord(); } -`,Hl=` +`,zl=` struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, @@ -1164,7 +1164,7 @@ fn mainFragment( var offset = gfu.uInputSize.zw * (filterUniforms.uRotation * (map.xy - 0.5)) * filterUniforms.uScale; return textureSample(uTexture, uSampler, clamp(uv + offset, gfu.uInputClamp.xy, gfu.uInputClamp.zw)); -}`,QC=Object.defineProperty,JC=Object.defineProperties,tM=Object.getOwnPropertyDescriptors,ds=Object.getOwnPropertySymbols,Q_=Object.prototype.hasOwnProperty,J_=Object.prototype.propertyIsEnumerable,ty=(r,t,e)=>t in r?QC(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,eM=(r,t)=>{for(var e in t||(t={}))Q_.call(t,e)&&ty(r,e,t[e]);if(ds)for(var e of ds(t))J_.call(t,e)&&ty(r,e,t[e]);return r},rM=(r,t)=>JC(r,tM(t)),iM=(r,t)=>{var e={};for(var i in r)Q_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ds)for(var i of ds(r))t.indexOf(i)<0&&J_.call(r,i)&&(e[i]=r[i]);return e};class nM extends Ee{constructor(...t){let e=t[0];e instanceof pe&&(e={sprite:e,scale:t[1]});const i=e,{sprite:n,scale:s}=i,a=iM(i,["sprite","scale"]);let o=s!=null?s:20;typeof o=="number"&&(o=new lt(o,o));const l=new At({uFilterMatrix:{value:new U,type:"mat3x3"},uScale:{value:o,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),u=Wt.from({vertex:Z_,fragment:q_,name:"displacement-filter"}),c=Xt.from({vertex:{source:Hl,entryPoint:"mainVertex"},fragment:{source:Hl,entryPoint:"mainFragment"}}),h=n.texture.source;super(rM(eM({},a),{gpuProgram:c,glProgram:u,resources:{filterUniforms:l,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,n){const s=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(s.uFilterMatrix,this._sprite);const a=this._sprite.worldTransform,o=Math.sqrt(a.a*a.a+a.b*a.b),l=Math.sqrt(a.c*a.c+a.d*a.d);o!==0&&l!==0&&(s.uRotation[0]=a.a/o,s.uRotation[1]=a.b/o,s.uRotation[2]=a.c/l,s.uRotation[3]=a.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,n)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var ey=` +}`,sM=Object.defineProperty,aM=Object.defineProperties,oM=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,Q_=Object.prototype.hasOwnProperty,J_=Object.prototype.propertyIsEnumerable,ty=(r,t,e)=>t in r?sM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,lM=(r,t)=>{for(var e in t||(t={}))Q_.call(t,e)&&ty(r,e,t[e]);if(fs)for(var e of fs(t))J_.call(t,e)&&ty(r,e,t[e]);return r},uM=(r,t)=>aM(r,oM(t)),cM=(r,t)=>{var e={};for(var i in r)Q_.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fs)for(var i of fs(r))t.indexOf(i)<0&&J_.call(r,i)&&(e[i]=r[i]);return e};class hM extends Pe{constructor(...t){let e=t[0];e instanceof pe&&(e={sprite:e,scale:t[1]});const i=e,{sprite:n,scale:s}=i,a=cM(i,["sprite","scale"]);let o=s!=null?s:20;typeof o=="number"&&(o=new lt(o,o));const l=new At({uFilterMatrix:{value:new U,type:"mat3x3"},uScale:{value:o,type:"vec2"},uRotation:{value:new Float32Array([0,0,0,0]),type:"mat2x2"}}),u=Wt.from({vertex:Z_,fragment:q_,name:"displacement-filter"}),c=Xt.from({vertex:{source:zl,entryPoint:"mainVertex"},fragment:{source:zl,entryPoint:"mainFragment"}}),h=n.texture.source;super(uM(lM({},a),{gpuProgram:c,glProgram:u,resources:{filterUniforms:l,uMapTexture:h,uMapSampler:h.style}})),this._sprite=e.sprite,this._sprite.renderable=!1}apply(t,e,i,n){const s=this.resources.filterUniforms.uniforms;t.calculateSpriteMatrix(s.uFilterMatrix,this._sprite);const a=this._sprite.worldTransform,o=Math.sqrt(a.a*a.a+a.b*a.b),l=Math.sqrt(a.c*a.c+a.d*a.d);o!==0&&l!==0&&(s.uRotation[0]=a.a/o,s.uRotation[1]=a.b/o,s.uRotation[2]=a.c/l,s.uRotation[3]=a.d/l),this.resources.uMapTexture=this._sprite.texture.source,t.applyFilter(this,e,i,n)}get scale(){return this.resources.filterUniforms.uniforms.uScale}}var ey=` in vec2 vTextureCoord; in vec4 vColor; @@ -1199,7 +1199,7 @@ void main() finalColor = color; } -`,zl=` +`,Wl=` struct GlobalFilterUniforms { uInputSize:vec4, @@ -1298,7 +1298,7 @@ fn mainFragment( sample.b *= sample.a; return sample; -}`,sM=Object.defineProperty,aM=Object.defineProperties,oM=Object.getOwnPropertyDescriptors,ps=Object.getOwnPropertySymbols,ry=Object.prototype.hasOwnProperty,iy=Object.prototype.propertyIsEnumerable,ny=(r,t,e)=>t in r?sM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wl=(r,t)=>{for(var e in t||(t={}))ry.call(t,e)&&ny(r,e,t[e]);if(ps)for(var e of ps(t))iy.call(t,e)&&ny(r,e,t[e]);return r},lM=(r,t)=>aM(r,oM(t)),uM=(r,t)=>{var e={};for(var i in r)ry.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ps)for(var i of ps(r))t.indexOf(i)<0&&iy.call(r,i)&&(e[i]=r[i]);return e};const sy=class U1 extends Ee{constructor(t={}){t=Wl(Wl({},U1.defaultOptions),t);const e=Xt.from({vertex:{source:zl,entryPoint:"mainVertex"},fragment:{source:zl,entryPoint:"mainFragment"}}),i=Wt.from({vertex:bi,fragment:ey,name:"noise-filter"}),n=t,{noise:s,seed:a}=n,o=uM(n,["noise","seed"]);super(lM(Wl({},o),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new At({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=s,this.seed=a!=null?a:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};sy.defaultOptions={noise:.5};let cM=sy;var ay=`in vec2 vMaskCoord; +}`,dM=Object.defineProperty,pM=Object.defineProperties,fM=Object.getOwnPropertyDescriptors,ms=Object.getOwnPropertySymbols,ry=Object.prototype.hasOwnProperty,iy=Object.prototype.propertyIsEnumerable,ny=(r,t,e)=>t in r?dM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Vl=(r,t)=>{for(var e in t||(t={}))ry.call(t,e)&&ny(r,e,t[e]);if(ms)for(var e of ms(t))iy.call(t,e)&&ny(r,e,t[e]);return r},mM=(r,t)=>pM(r,fM(t)),gM=(r,t)=>{var e={};for(var i in r)ry.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ms)for(var i of ms(r))t.indexOf(i)<0&&iy.call(r,i)&&(e[i]=r[i]);return e};const sy=class k1 extends Pe{constructor(t={}){t=Vl(Vl({},k1.defaultOptions),t);const e=Xt.from({vertex:{source:Wl,entryPoint:"mainVertex"},fragment:{source:Wl,entryPoint:"mainFragment"}}),i=Wt.from({vertex:bi,fragment:ey,name:"noise-filter"}),n=t,{noise:s,seed:a}=n,o=gM(n,["noise","seed"]);super(mM(Vl({},o),{gpuProgram:e,glProgram:i,resources:{noiseUniforms:new At({uNoise:{value:1,type:"f32"},uSeed:{value:1,type:"f32"}})}})),this.noise=s,this.seed=a!=null?a:Math.random()}get noise(){return this.resources.noiseUniforms.uniforms.uNoise}set noise(t){this.resources.noiseUniforms.uniforms.uNoise=t}get seed(){return this.resources.noiseUniforms.uniforms.uSeed}set seed(t){this.resources.noiseUniforms.uniforms.uSeed=t}};sy.defaultOptions={noise:.5};let _M=sy;var ay=`in vec2 vMaskCoord; in vec2 vTextureCoord; uniform sampler2D uTexture; @@ -1375,7 +1375,7 @@ void main(void) vTextureCoord = filterTextureCoord(aPosition); vMaskCoord = getFilterCoord(aPosition); } -`,Vl=`struct GlobalFilterUniforms { +`,Yl=`struct GlobalFilterUniforms { uInputSize:vec4, uInputPixel:vec4, uInputClamp:vec4, @@ -1479,7 +1479,7 @@ fn mainFragment( return source * a; } -`,hM=Object.defineProperty,dM=Object.defineProperties,pM=Object.getOwnPropertyDescriptors,fs=Object.getOwnPropertySymbols,ly=Object.prototype.hasOwnProperty,uy=Object.prototype.propertyIsEnumerable,cy=(r,t,e)=>t in r?hM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fM=(r,t)=>{for(var e in t||(t={}))ly.call(t,e)&&cy(r,e,t[e]);if(fs)for(var e of fs(t))uy.call(t,e)&&cy(r,e,t[e]);return r},mM=(r,t)=>dM(r,pM(t)),gM=(r,t)=>{var e={};for(var i in r)ly.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fs)for(var i of fs(r))t.indexOf(i)<0&&uy.call(r,i)&&(e[i]=r[i]);return e};class hy extends Ee{constructor(t){const e=t,{sprite:i}=e,n=gM(e,["sprite"]),s=new Ua(i.texture),a=new At({uFilterMatrix:{value:new U,type:"mat3x3"},uMaskClamp:{value:s.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"},uChannel:{value:t.channel==="alpha"?1:0,type:"f32"}}),o=Xt.from({vertex:{source:Vl,entryPoint:"mainVertex"},fragment:{source:Vl,entryPoint:"mainFragment"}}),l=Wt.from({vertex:oy,fragment:ay,name:"mask-filter"});super(mM(fM({},n),{gpuProgram:o,glProgram:l,clipToViewport:!1,resources:{filterUniforms:a,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=s}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(t){this.resources.filterUniforms.uniforms.uChannel=t==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(t,e,i,n){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,n)}}var _M=`fn getLuminosity(c: vec3) -> f32 { +`,yM=Object.defineProperty,bM=Object.defineProperties,vM=Object.getOwnPropertyDescriptors,gs=Object.getOwnPropertySymbols,ly=Object.prototype.hasOwnProperty,uy=Object.prototype.propertyIsEnumerable,cy=(r,t,e)=>t in r?yM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xM=(r,t)=>{for(var e in t||(t={}))ly.call(t,e)&&cy(r,e,t[e]);if(gs)for(var e of gs(t))uy.call(t,e)&&cy(r,e,t[e]);return r},TM=(r,t)=>bM(r,vM(t)),SM=(r,t)=>{var e={};for(var i in r)ly.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&gs)for(var i of gs(r))t.indexOf(i)<0&&uy.call(r,i)&&(e[i]=r[i]);return e};class hy extends Pe{constructor(t){const e=t,{sprite:i}=e,n=SM(e,["sprite"]),s=new $a(i.texture),a=new At({uFilterMatrix:{value:new U,type:"mat3x3"},uMaskClamp:{value:s.uClampFrame,type:"vec4"},uAlpha:{value:1,type:"f32"},uInverse:{value:t.inverse?1:0,type:"f32"},uChannel:{value:t.channel==="alpha"?1:0,type:"f32"}}),o=Xt.from({vertex:{source:Yl,entryPoint:"mainVertex"},fragment:{source:Yl,entryPoint:"mainFragment"}}),l=Wt.from({vertex:oy,fragment:ay,name:"mask-filter"});super(TM(xM({},n),{gpuProgram:o,glProgram:l,clipToViewport:!1,resources:{filterUniforms:a,uMaskTexture:i.texture.source}})),this.sprite=i,this._textureMatrix=s}set inverse(t){this.resources.filterUniforms.uniforms.uInverse=t?1:0}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(t){this.resources.filterUniforms.uniforms.uChannel=t==="alpha"?1:0}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?"alpha":"red"}apply(t,e,i,n){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,n)}}var wM=`fn getLuminosity(c: vec3) -> f32 { return 0.3 * c.r + 0.59 * c.g + 0.11 * c.b; } @@ -1550,7 +1550,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { } return result; -}`;const dy=class $1{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let i=0;for(;e.length&&i<$1.uploadsPerFrame;){const n=e.shift();this.uploadQueueItem(n),i++}e.length?Ot.system.addOnce(this._tick,this,Te.UTILITY):this._resolve()},this.renderer=t,this.queue=[],this.resolves=[]}getQueue(){return[...this.queue]}add(t){const e=Array.isArray(t)?t:[t];for(const i of e)i instanceof dt?this._addContainer(i):this.resolveQueueItem(i,this.queue);return this}_addContainer(t){this.resolveQueueItem(t,this.queue);for(const e of t.children)this._addContainer(e)}upload(t){return t&&this.add(t),new Promise(e=>{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),Ot.system.addOnce(this._tick,this,Te.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;i>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(r&255)/255,e[i++]=t}function Yr(r,t,e){const i=(r>>24&255)/255;t[e++]=(r&255)/255*i,t[e++]=(r>>8&255)/255*i,t[e++]=(r>>16&255)/255*i,t[e++]=i}class my{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Et.return(t)}),this.batches.length=0}}class ql{constructor(t,e){this.state=Vt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Ut({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!!(n.isBatchable||i!==n.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 i=0;i{const o=Et.get(Vn);return a.copyTo(o),o.renderable=t,o.roundPixels=s,o})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}ql.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"graphics"},X.add(Kl),X.add(ql),X.add(fy),X.add(Zn);var xM=Object.defineProperty,ms=Object.getOwnPropertySymbols,gy=Object.prototype.hasOwnProperty,_y=Object.prototype.propertyIsEnumerable,yy=(r,t,e)=>t in r?xM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,TM=(r,t)=>{for(var e in t||(t={}))gy.call(t,e)&&yy(r,e,t[e]);if(ms)for(var e of ms(t))_y.call(t,e)&&yy(r,e,t[e]);return r},SM=(r,t)=>{var e={};for(var i in r)gy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ms)for(var i of ms(r))t.indexOf(i)<0&&_y.call(r,i)&&(e[i]=r[i]);return e};class hr extends Se{constructor(t){t instanceof kt&&(t={context:t});const e=t||{},{context:i,roundPixels:n}=e,s=SM(e,["context","roundPixels"]);super(TM({label:"Graphics"},s)),this.renderPipeId="graphics",i?this.context=i:(this.context=this._ownedContext=new kt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=n!=null?n:!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,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):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=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 hr(this._context.clone()):(this._ownedContext=null,new hr(this._context))}lineStyle(t,e,i){const n={};return t&&(n.width=t),e&&(n.color=e),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(t,e){const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==kt.defaultStrokeStyle.width||t.color!==kt.defaultStrokeStyle.color||t.alpha!==kt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}var wM=Object.defineProperty,by=Object.getOwnPropertySymbols,PM=Object.prototype.hasOwnProperty,EM=Object.prototype.propertyIsEnumerable,vy=(r,t,e)=>t in r?wM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xy=(r,t)=>{for(var e in t||(t={}))PM.call(t,e)&&vy(r,e,t[e]);if(by)for(var e of by(t))EM.call(t,e)&&vy(r,e,t[e]);return r};const Ty=class k1 extends nr{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=xy(xy({},k1.defaultOptions),i);const n=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=i.uvs;s||(i.positions?s=new Float32Array(n.length):s=new Float32Array([0,0,1,0,1,1,0,1]));const a=i.indices||new Uint32Array([0,1,2,0,2,3]),o=i.shrinkBuffersToFit,l=new Yt({data:n,label:"attribute-mesh-positions",shrinkToFit:o,usage:at.VERTEX|at.COPY_DST}),u=new Yt({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:at.VERTEX|at.COPY_DST}),c=new Yt({data:a,label:"index-mesh-buffer",shrinkToFit:o,usage:at.INDEX|at.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:8,offset:0},aUV:{buffer:u,format:"float32x2",stride:8,offset:0}},indexBuffer:c,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}};Ty.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ze=Ty;class gs{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 n=this.texture.textureMatrix;return n.isSimple||(i=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!i||i.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Pe({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,n=t.batched;if(e.batched=n,i!==n)return!0;if(n){const s=t._geometry;if(s.indices.length!==e.indexSize||s.positions.length!==e.vertexSize)return e.indexSize=s.indices.length,e.vertexSize=s.positions.length,!0;const a=this._getBatchableMesh(t);return a.texture.uid!==t._texture.uid&&(a._textureMatrixUpdateId=-1),!a._batcher.checkAndUpdateTexture(a,t._texture)}return!1}addRenderable(t,e){var i,n;const s=this.renderer.renderPipes.batch,a=this._getMeshData(t);if(t.didViewUpdate&&(a.indexSize=(i=t._geometry.indices)==null?void 0:i.length,a.vertexSize=(n=t._geometry.positions)==null?void 0:n.length),a.batched){const o=this._getBatchableMesh(t);o.setTexture(t._texture),o.geometry=t._geometry,s.addToBatch(o,e)}else s.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=Ir(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Yr(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 Zl),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 Zl),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new gs;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}}Ql.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"mesh"},X.add(Ql);var AM=Object.defineProperty,_s=Object.getOwnPropertySymbols,Sy=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable,Py=(r,t,e)=>t in r?AM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,CM=(r,t)=>{for(var e in t||(t={}))Sy.call(t,e)&&Py(r,e,t[e]);if(_s)for(var e of _s(t))wy.call(t,e)&&Py(r,e,t[e]);return r},MM=(r,t)=>{var e={};for(var i in r)Sy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&_s)for(var i of _s(r))t.indexOf(i)<0&&wy.call(r,i)&&(e[i]=r[i]);return e};class Kr extends Se{constructor(...t){var e;let i=t[0];i instanceof nr&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const n=i,{geometry:s,shader:a,texture:o,roundPixels:l,state:u}=n,c=MM(n,["geometry","shader","texture","roundPixels","state"]);super(CM({label:"Mesh"},c)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=a!=null?a:null,this.texture=(e=o!=null?o:a==null?void 0:a.texture)!=null?e:D.WHITE,this.state=u!=null?u:Vt.for2d(),this._geometry=s,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=l!=null?l:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.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=D.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||(this.state.data&12)!==0?!1:this._geometry instanceof ze?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}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 n=this.geometry.getBuffer("aPosition").data,s=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const a=this.geometry.getIndex().data,o=a.length;for(let l=0;l+2t in r?RM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,IM=(r,t)=>{for(var e in t||(t={}))Ey.call(t,e)&&Cy(r,e,t[e]);if(ys)for(var e of ys(t))Ay.call(t,e)&&Cy(r,e,t[e]);return r},BM=(r,t)=>OM(r,GM(t)),FM=(r,t)=>{var e={};for(var i in r)Ey.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ys)for(var i of ys(r))t.indexOf(i)<0&&Ay.call(r,i)&&(e[i]=r[i]);return e};class Xi extends pe{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:n=1,autoPlay:s=!1,autoUpdate:a=!0,loop:o=!0,onComplete:l=null,onFrameChange:u=null,onLoop:c=null,textures:h,updateAnchor:p=!1}=i,f=FM(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[m]=h;super(BM(IM({},f),{texture:m instanceof D?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=a,this._isConnectedToTicker=!1,this.animationSpeed=n,this.loop=o,this.updateAnchor=p,this.onComplete=l,this.onFrameChange=u,this.onLoop=c,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=h,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ot.shared.add(this.update,this,Te.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,n=this.currentFrame;if(this._durations!==null){let s=this._currentTime%1*this._durations[this.currentFrame];for(s+=i/60*1e3;s<0;)this._currentTime--,s+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);s>=this._durations[this.currentFrame];)s-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=s/this._durations[this.currentFrame]}else this._currentTime+=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()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramen)&&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(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(i=>{this.texture!==i&&i.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;ithis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class My{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new U,this.observer=e,this.position=new bt(this,0,0),this.scale=new bt(this,1,1),this.pivot=new bt(this,0,0),this.skew=new bt(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}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._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}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 bs=new U,Be=new U,Ae=[new lt,new lt,new lt,new lt];class Jl{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,i,n,s,a,o;const l=this._renderer,u=l.canvasContext,c=u.activeContext;c.save(),u.setBlendMode(t.groupBlendMode);const h=(i=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?i:4294967295,p=t.groupColorAlpha,f=(h>>>24&255)/255,m=(p>>>24&255)/255,g=(s=(n=l.filter)==null?void 0:n.alphaMultiplier)!=null?s:1,_=f*m*g;if(_<=0){c.restore();return}c.globalAlpha=_;const y=h&16777215,b=p&16777215,x=xe(Oe(b,y)),v=t.texture,w=Q.getTintedPattern(v,x),T=t.width,P=t.height,E=t.groupTransform,M=(o=(a=v.source._resolution)!=null?a:v.source.resolution)!=null?o:1;Be.copyFrom(t._tileTransform.matrix),t.applyAnchorToTexture||Be.translate(-t.anchor.x*T,-t.anchor.y*P);const C=Be.tx,A=Be.ty;Be.scale(1/M,1/M),Be.tx=C,Be.ty=A,bs.identity(),bs.prepend(Be),bs.prepend(E);const G=l._roundPixels|t._roundPixels;u.setContextTransform(bs,G===1),c.fillStyle=w;const F=t.anchor.x*-T,R=t.anchor.y*-P;Ae[0].set(F,R),Ae[1].set(F+T,R),Ae[2].set(F+T,R+P),Ae[3].set(F,R+P);for(let B=0;B<4;B++)Be.applyInverse(Ae[B],Ae[B]);c.beginPath(),c.moveTo(Ae[0].x,Ae[0].y);for(let B=1;B<4;B++)c.lineTo(Ae[B].x,Ae[B].y);c.closePath(),c.fill(),c.restore()}destroy(){this._renderer=null}}Jl.extension={type:[S.CanvasPipes],name:"tilingSprite"};var DM=Object.defineProperty,UM=Object.defineProperties,$M=Object.getOwnPropertyDescriptors,Ry=Object.getOwnPropertySymbols,kM=Object.prototype.hasOwnProperty,LM=Object.prototype.propertyIsEnumerable,Oy=(r,t,e)=>t in r?DM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gy=(r,t)=>{for(var e in t||(t={}))kM.call(t,e)&&Oy(r,e,t[e]);if(Ry)for(var e of Ry(t))LM.call(t,e)&&Oy(r,e,t[e]);return r},Iy=(r,t)=>UM(r,$M(t));const qr={name:"local-uniform-bit",vertex:{header:` +}`;const dy=class L1{constructor(t){this._tick=()=>{this._destroyed||(this.timeout=setTimeout(this._processQueue,0))},this._processQueue=()=>{if(this._destroyed)return;const{queue:e}=this;let i=0;for(;e.length&&i{this.queue.length?(this.resolves.push(e),this.dedupeQueue(),Ot.system.addOnce(this._tick,this,Te.UTILITY)):e()})}dedupeQueue(){const t=Object.create(null);let e=0;for(let i=0;i>16&255)/255,e[i++]=(r>>8&255)/255,e[i++]=(r&255)/255,e[i++]=t}function Yr(r,t,e){const i=(r>>24&255)/255;t[e++]=(r&255)/255*i,t[e++]=(r>>8&255)/255*i,t[e++]=(r>>16&255)/255*i,t[e++]=i}class my{constructor(){this.batches=[],this.batched=!1}destroy(){this.batches.forEach(t=>{Pt.return(t)}),this.batches.length=0}}class Zl{constructor(t,e){this.state=Vt.for2d(),this.renderer=t,this._adaptor=e,this.renderer.runners.contextChange.add(this),this._managedGraphics=new Ut({renderer:t,type:"renderable",priority:-1,name:"graphics"})}contextChange(){this._adaptor.contextChange(this.renderer)}validateRenderable(t){const e=t.context,i=!!t._gpuData,n=this.renderer.graphicsContext.updateGpuContext(e);return!!(n.isBatchable||i!==n.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 i=0;i{const o=Pt.get(Kn);return a.copyTo(o),o.renderable=t,o.roundPixels=s,o})}destroy(){this._managedGraphics.destroy(),this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this.state=null}}Zl.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"graphics"},N.add(ql),N.add(Zl),N.add(fy),N.add(Jn);var CM=Object.defineProperty,_s=Object.getOwnPropertySymbols,gy=Object.prototype.hasOwnProperty,_y=Object.prototype.propertyIsEnumerable,yy=(r,t,e)=>t in r?CM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,MM=(r,t)=>{for(var e in t||(t={}))gy.call(t,e)&&yy(r,e,t[e]);if(_s)for(var e of _s(t))_y.call(t,e)&&yy(r,e,t[e]);return r},RM=(r,t)=>{var e={};for(var i in r)gy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&_s)for(var i of _s(r))t.indexOf(i)<0&&_y.call(r,i)&&(e[i]=r[i]);return e};class hr extends Se{constructor(t){t instanceof kt&&(t={context:t});const e=t||{},{context:i,roundPixels:n}=e,s=RM(e,["context","roundPixels"]);super(MM({label:"Graphics"},s)),this.renderPipeId="graphics",i?this.context=i:(this.context=this._ownedContext=new kt,this.context.autoGarbageCollect=this.autoGarbageCollect),this.didViewUpdate=!0,this.allowChildren=!1,this.roundPixels=n!=null?n:!1}set context(t){t!==this._context&&(this._context&&(this._context.off("update",this.onViewUpdate,this),this._context.off("unload",this.unload,this)),this._context=t,this._context.on("update",this.onViewUpdate,this),this._context.on("unload",this.unload,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):(t===!0||(t==null?void 0:t.context)===!0)&&this._context.destroy(t),this._ownedContext=null,this._context=null,super.destroy(t)}_onTouch(t){this._gcLastUsed=t,this._context._gcLastUsed=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 hr(this._context.clone()):(this._ownedContext=null,new hr(this._context))}lineStyle(t,e,i){const n={};return t&&(n.width=t),e&&(n.color=e),i&&(n.alpha=i),this.context.strokeStyle=n,this}beginFill(t,e){const i={};return t!==void 0&&(i.color=t),e!==void 0&&(i.alpha=e),this.context.fillStyle=i,this}endFill(){this.context.fill();const t=this.context.strokeStyle;return(t.width!==kt.defaultStrokeStyle.width||t.color!==kt.defaultStrokeStyle.color||t.alpha!==kt.defaultStrokeStyle.alpha)&&this.context.stroke(),this}drawCircle(...t){return this._callContextMethod("circle",t)}drawEllipse(...t){return this._callContextMethod("ellipse",t)}drawPolygon(...t){return this._callContextMethod("poly",t)}drawRect(...t){return this._callContextMethod("rect",t)}drawRoundedRect(...t){return this._callContextMethod("roundRect",t)}drawStar(...t){return this._callContextMethod("star",t)}}var OM=Object.defineProperty,by=Object.getOwnPropertySymbols,GM=Object.prototype.hasOwnProperty,IM=Object.prototype.propertyIsEnumerable,vy=(r,t,e)=>t in r?OM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,xy=(r,t)=>{for(var e in t||(t={}))GM.call(t,e)&&vy(r,e,t[e]);if(by)for(var e of by(t))IM.call(t,e)&&vy(r,e,t[e]);return r};const Ty=class N1 extends nr{constructor(...t){var e;let i=(e=t[0])!=null?e:{};i instanceof Float32Array&&(i={positions:i,uvs:t[1],indices:t[2]}),i=xy(xy({},N1.defaultOptions),i);const n=i.positions||new Float32Array([0,0,1,0,1,1,0,1]);let s=i.uvs;s||(i.positions?s=new Float32Array(n.length):s=new Float32Array([0,0,1,0,1,1,0,1]));const a=i.indices||new Uint32Array([0,1,2,0,2,3]),o=i.shrinkBuffersToFit,l=new Yt({data:n,label:"attribute-mesh-positions",shrinkToFit:o,usage:at.VERTEX|at.COPY_DST}),u=new Yt({data:s,label:"attribute-mesh-uvs",shrinkToFit:o,usage:at.VERTEX|at.COPY_DST}),c=new Yt({data:a,label:"index-mesh-buffer",shrinkToFit:o,usage:at.INDEX|at.COPY_DST});super({attributes:{aPosition:{buffer:l,format:"float32x2",stride:8,offset:0},aUV:{buffer:u,format:"float32x2",stride:8,offset:0}},indexBuffer:c,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}};Ty.defaultOptions={topology:"triangle-list",shrinkBuffersToFit:!1};let ze=Ty;class ys{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 n=this.texture.textureMatrix;return n.isSimple||(i=this._transformedUvs,(this._textureMatrixUpdateId!==n._updateID||this._uvUpdateId!==t._updateID)&&((!i||i.length"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),this.localUniformsBindGroup=new Ee({0:this.localUniforms}),this.renderer=t,this._adaptor=e,this._adaptor.init()}validateRenderable(t){const e=this._getMeshData(t),i=e.batched,n=t.batched;if(e.batched=n,i!==n)return!0;if(n){const s=t._geometry;if(s.indices.length!==e.indexSize||s.positions.length!==e.vertexSize)return e.indexSize=s.indices.length,e.vertexSize=s.positions.length,!0;const a=this._getBatchableMesh(t);return a.texture.uid!==t._texture.uid&&(a._textureMatrixUpdateId=-1),!a._batcher.checkAndUpdateTexture(a,t._texture)}return!1}addRenderable(t,e){var i,n;const s=this.renderer.renderPipes.batch,a=this._getMeshData(t);if(t.didViewUpdate&&(a.indexSize=(i=t._geometry.indices)==null?void 0:i.length,a.vertexSize=(n=t._geometry.positions)==null?void 0:n.length),a.batched){const o=this._getBatchableMesh(t);o.setTexture(t._texture),o.geometry=t._geometry,s.addToBatch(o,e)}else s.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=Ir(t.groupBlendMode,t.texture._source);const e=this.localUniforms;e.uniforms.uTransformMatrix=t.groupTransform,e.uniforms.uRound=this.renderer._roundPixels|t._roundPixels,e.update(),Yr(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 Ql),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 Ql),t._gpuData[this.renderer.uid].batchableMesh||this._initBatchableMesh(t)}_initBatchableMesh(t){const e=new ys;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}}Jl.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"mesh"},N.add(Jl);var BM=Object.defineProperty,bs=Object.getOwnPropertySymbols,Sy=Object.prototype.hasOwnProperty,wy=Object.prototype.propertyIsEnumerable,Ey=(r,t,e)=>t in r?BM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,FM=(r,t)=>{for(var e in t||(t={}))Sy.call(t,e)&&Ey(r,e,t[e]);if(bs)for(var e of bs(t))wy.call(t,e)&&Ey(r,e,t[e]);return r},DM=(r,t)=>{var e={};for(var i in r)Sy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&bs)for(var i of bs(r))t.indexOf(i)<0&&wy.call(r,i)&&(e[i]=r[i]);return e};class Kr extends Se{constructor(...t){var e;let i=t[0];i instanceof nr&&(i={geometry:i,shader:t[1]},t[3]&&(i.geometry.topology=t[3]));const n=i,{geometry:s,shader:a,texture:o,roundPixels:l,state:u}=n,c=DM(n,["geometry","shader","texture","roundPixels","state"]);super(FM({label:"Mesh"},c)),this.renderPipeId="mesh",this._shader=null,this.allowChildren=!1,this.shader=a!=null?a:null,this.texture=(e=o!=null?o:a==null?void 0:a.texture)!=null?e:D.WHITE,this.state=u!=null?u:Vt.for2d(),this._geometry=s,this._geometry.on("update",this.onViewUpdate,this),this.roundPixels=l!=null?l:!1}get material(){return this._shader}set shader(t){this._shader!==t&&(this._shader=t,this.onViewUpdate())}get shader(){return this._shader}set geometry(t){var e;this._geometry!==t&&((e=this._geometry)==null||e.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=D.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||(this.state.data&12)!==0?!1:this._geometry instanceof ze?this._geometry.batchMode==="auto"?this._geometry.positions.length/2<=100:this._geometry.batchMode==="batch":!1}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 n=this.geometry.getBuffer("aPosition").data,s=this.geometry.topology==="triangle-strip"?3:1;if(this.geometry.getIndex()){const a=this.geometry.getIndex().data,o=a.length;for(let l=0;l+2t in r?UM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,LM=(r,t)=>{for(var e in t||(t={}))Py.call(t,e)&&Cy(r,e,t[e]);if(vs)for(var e of vs(t))Ay.call(t,e)&&Cy(r,e,t[e]);return r},NM=(r,t)=>$M(r,kM(t)),XM=(r,t)=>{var e={};for(var i in r)Py.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&vs)for(var i of vs(r))t.indexOf(i)<0&&Ay.call(r,i)&&(e[i]=r[i]);return e};class Xi extends pe{constructor(...t){let e=t[0];Array.isArray(t[0])&&(e={textures:t[0],autoUpdate:t[1]});const i=e,{animationSpeed:n=1,autoPlay:s=!1,autoUpdate:a=!0,loop:o=!0,onComplete:l=null,onFrameChange:u=null,onLoop:c=null,textures:h,updateAnchor:p=!1}=i,f=XM(i,["animationSpeed","autoPlay","autoUpdate","loop","onComplete","onFrameChange","onLoop","textures","updateAnchor"]),[m]=h;super(NM(LM({},f),{texture:m instanceof D?m:m.texture})),this._textures=null,this._durations=null,this._autoUpdate=a,this._isConnectedToTicker=!1,this.animationSpeed=n,this.loop=o,this.updateAnchor=p,this.onComplete=l,this.onFrameChange=u,this.onLoop=c,this._currentTime=0,this._playing=!1,this._previousFrame=null,this.textures=h,s&&this.play()}stop(){this._playing&&(this._playing=!1,this._autoUpdate&&this._isConnectedToTicker&&(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1))}play(){this._playing||(this._playing=!0,this._autoUpdate&&!this._isConnectedToTicker&&(Ot.shared.add(this.update,this,Te.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,n=this.currentFrame;if(this._durations!==null){let s=this._currentTime%1*this._durations[this.currentFrame];for(s+=i/60*1e3;s<0;)this._currentTime--,s+=this._durations[this.currentFrame];const a=Math.sign(this.animationSpeed*e);for(this._currentTime=Math.floor(this._currentTime);s>=this._durations[this.currentFrame];)s-=this._durations[this.currentFrame]*a,this._currentTime+=a;this._currentTime+=s/this._durations[this.currentFrame]}else this._currentTime+=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()):n!==this.currentFrame&&(this.loop&&this.onLoop&&(this.animationSpeed>0&&this.currentFramen)&&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(typeof t=="boolean"?t:t!=null&&t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._textures.forEach(i=>{this.texture!==i&&i.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;ithis.totalFrames-1)throw new Error(`[AnimatedSprite]: Invalid frame index value ${t}, expected to be between 0 and totalFrames ${this.totalFrames}.`);const e=this.currentFrame;this._currentTime=t,e!==this.currentFrame&&this._updateTexture()}get playing(){return this._playing}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,!this._autoUpdate&&this._isConnectedToTicker?(Ot.shared.remove(this.update,this),this._isConnectedToTicker=!1):this._autoUpdate&&!this._isConnectedToTicker&&this._playing&&(Ot.shared.add(this.update,this),this._isConnectedToTicker=!0))}}class My{constructor({matrix:t,observer:e}={}){this.dirty=!0,this._matrix=t!=null?t:new U,this.observer=e,this.position=new bt(this,0,0),this.scale=new bt(this,1,1),this.pivot=new bt(this,0,0),this.skew=new bt(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}_onUpdate(t){var e;this.dirty=!0,t===this.skew&&this.updateSkew(),(e=this.observer)==null||e._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}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 xs=new U,Be=new U,Ae=[new lt,new lt,new lt,new lt];class tu{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,i,n,s,a,o;const l=this._renderer,u=l.canvasContext,c=u.activeContext;c.save(),u.setBlendMode(t.groupBlendMode);const h=(i=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?i:4294967295,p=t.groupColorAlpha,f=(h>>>24&255)/255,m=(p>>>24&255)/255,g=(s=(n=l.filter)==null?void 0:n.alphaMultiplier)!=null?s:1,_=f*m*g;if(_<=0){c.restore();return}c.globalAlpha=_;const y=h&16777215,b=p&16777215,x=xe(Oe(b,y)),v=t.texture,w=Q.getTintedPattern(v,x),T=t.width,E=t.height,P=t.groupTransform,M=(o=(a=v.source._resolution)!=null?a:v.source.resolution)!=null?o:1;Be.copyFrom(t._tileTransform.matrix),t.applyAnchorToTexture||Be.translate(-t.anchor.x*T,-t.anchor.y*E);const C=Be.tx,A=Be.ty;Be.scale(1/M,1/M),Be.tx=C,Be.ty=A,xs.identity(),xs.prepend(Be),xs.prepend(P);const G=l._roundPixels|t._roundPixels;u.setContextTransform(xs,G===1),c.fillStyle=w;const F=t.anchor.x*-T,R=t.anchor.y*-E;Ae[0].set(F,R),Ae[1].set(F+T,R),Ae[2].set(F+T,R+E),Ae[3].set(F,R+E);for(let B=0;B<4;B++)Be.applyInverse(Ae[B],Ae[B]);c.beginPath(),c.moveTo(Ae[0].x,Ae[0].y);for(let B=1;B<4;B++)c.lineTo(Ae[B].x,Ae[B].y);c.closePath(),c.fill(),c.restore()}destroy(){this._renderer=null}}tu.extension={type:[S.CanvasPipes],name:"tilingSprite"};var jM=Object.defineProperty,HM=Object.defineProperties,zM=Object.getOwnPropertyDescriptors,Ry=Object.getOwnPropertySymbols,WM=Object.prototype.hasOwnProperty,VM=Object.prototype.propertyIsEnumerable,Oy=(r,t,e)=>t in r?jM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Gy=(r,t)=>{for(var e in t||(t={}))WM.call(t,e)&&Oy(r,e,t[e]);if(Ry)for(var e of Ry(t))VM.call(t,e)&&Oy(r,e,t[e]);return r},Iy=(r,t)=>HM(r,zM(t));const qr={name:"local-uniform-bit",vertex:{header:` struct LocalUniforms { uTransformMatrix:mat3x3, @@ -1567,7 +1567,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { { vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw); } - `}},By=Iy(Gy({},qr),{vertex:Iy(Gy({},qr.vertex),{header:qr.vertex.header.replace("group(1)","group(2)")})}),vs={name:"local-uniform-bit",vertex:{header:` + `}},By=Iy(Gy({},qr),{vertex:Iy(Gy({},qr.vertex),{header:qr.vertex.header.replace("group(1)","group(2)")})}),Ts={name:"local-uniform-bit",vertex:{header:` uniform mat3 uTransformMatrix; uniform vec4 uColor; @@ -1645,23 +1645,23 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { outColor = texture(uTexture, coord, unclamped == coord ? 0.0 : -32.0);// lod-bias very negative to force lod 0 - `}};let tu,eu;class Uy extends ee{constructor(){tu!=null||(tu=Fr({name:"tiling-sprite-shader",bits:[qr,Fy,Ur]})),eu!=null||(eu=Dr({name:"tiling-sprite-shader",bits:[vs,Dy,$r]}));const t=new At({uMapCoord:{value:new U,type:"mat3x3"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new U,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:eu,gpuProgram:tu,resources:{localUniforms:new At({uTransformMatrix:{value:new U,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:D.EMPTY.source,uSampler:D.EMPTY.source.style}})}updateUniforms(t,e,i,n,s,a){const o=this.resources.tilingUniforms,l=a.width,u=a.height,c=a.textureMatrix,h=o.uniforms.uTextureTransform;h.set(i.a*l/t,i.b*l/e,i.c*u/t,i.d*u/e,i.tx/t,i.ty/e),h.invert(),o.uniforms.uMapCoord=c.mapCoord,o.uniforms.uClampFrame=c.uClampFrame,o.uniforms.uClampOffset=c.uClampOffset,o.uniforms.uTextureTransform=h,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=s,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}}class $y extends ze{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function ky(r,t){const e=r.anchor.x,i=r.anchor.y;t[0]=-e*r.width,t[1]=-i*r.height,t[2]=(1-e)*r.width,t[3]=-i*r.height,t[4]=(1-e)*r.width,t[5]=(1-i)*r.height,t[6]=-e*r.width,t[7]=(1-i)*r.height}function Ly(r,t,e,i){let n=0;const s=r.length/(t||2),a=i.a,o=i.b,l=i.c,u=i.d,c=i.tx,h=i.ty;for(e*=t;nt in r?NM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ji=(r,t)=>{for(var e in t||(t={}))jy.call(t,e)&&zy(r,e,t[e]);if(Ts)for(var e of Ts(t))Hy.call(t,e)&&zy(r,e,t[e]);return r},XM=(r,t)=>{var e={};for(var i in r)jy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ts)for(var i of Ts(r))t.indexOf(i)<0&&Hy.call(r,i)&&(e[i]=r[i]);return e};const Wy=class xa extends Se{constructor(...t){let e=t[0]||{};e instanceof D&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=ji(ji({},xa.defaultOptions),e);const i=e!=null?e:{},{texture:n,anchor:s,tilePosition:a,tileScale:o,tileRotation:l,width:u,height:c,applyAnchorToTexture:h,roundPixels:p}=i,f=XM(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(ji({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=h,this.texture=n,this._width=u!=null?u:n.width,this._height=c!=null?c:n.height,this._tileTransform=new My({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=a,this.tileScale=o,this.tileRotation=l,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new xa(ji({texture:it.get(t)},e)):new xa(ji({texture:t},e))}get uvRespectAnchor(){return Mi(zo,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Mi(zo,"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){typeof t=="number"?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){typeof t=="number"?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=D.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){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?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,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}containsPoint(t){const e=this._width,i=this._height,n=-e*this._anchor._x;let s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this._anchor._y,t.y>=s&&t.y<=s+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};Wy.defaultOptions={texture:D.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Vy=Wy;var jM=Object.defineProperty,Ss=Object.getOwnPropertySymbols,Yy=Object.prototype.hasOwnProperty,Ky=Object.prototype.propertyIsEnumerable,qy=(r,t,e)=>t in r?jM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,HM=(r,t)=>{for(var e in t||(t={}))Yy.call(t,e)&&qy(r,e,t[e]);if(Ss)for(var e of Ss(t))Ky.call(t,e)&&qy(r,e,t[e]);return r},zM=(r,t)=>{var e={};for(var i in r)Yy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ss)for(var i of Ss(r))t.indexOf(i)<0&&Ky.call(r,i)&&(e[i]=r[i]);return e};class ws extends Se{constructor(t,e){const i=t,{text:n,resolution:s,style:a,anchor:o,width:l,height:u,roundPixels:c}=i,h=zM(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(HM({},h)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=n!=null?n:"",this.style=a,this.resolution=s!=null?s:null,this.allowChildren=!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=c!=null?c:!1,l!==void 0&&(this.width=l),u!==void 0&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get 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){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,n=-e*this.anchor.x;let s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this.anchor.y,t.y>=s&&t.y<=s+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function Ps(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}let dr=null,Fe=null;function WM(r,t){dr||(dr=H.get().createCanvas(256,128),Fe=dr.getContext("2d",{willReadFrequently:!0}),Fe.globalCompositeOperation="copy",Fe.globalAlpha=1),(dr.width"},uClampFrame:{value:new Float32Array([0,0,1,1]),type:"vec4"},uClampOffset:{value:new Float32Array([0,0]),type:"vec2"},uTextureTransform:{value:new U,type:"mat3x3"},uSizeAnchor:{value:new Float32Array([100,100,.5,.5]),type:"vec4"}});super({glProgram:ru,gpuProgram:eu,resources:{localUniforms:new At({uTransformMatrix:{value:new U,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}}),tilingUniforms:t,uTexture:D.EMPTY.source,uSampler:D.EMPTY.source.style}})}updateUniforms(t,e,i,n,s,a){const o=this.resources.tilingUniforms,l=a.width,u=a.height,c=a.textureMatrix,h=o.uniforms.uTextureTransform;h.set(i.a*l/t,i.b*l/e,i.c*u/t,i.d*u/e,i.tx/t,i.ty/e),h.invert(),o.uniforms.uMapCoord=c.mapCoord,o.uniforms.uClampFrame=c.uClampFrame,o.uniforms.uClampOffset=c.uClampOffset,o.uniforms.uTextureTransform=h,o.uniforms.uSizeAnchor[0]=t,o.uniforms.uSizeAnchor[1]=e,o.uniforms.uSizeAnchor[2]=n,o.uniforms.uSizeAnchor[3]=s,a&&(this.resources.uTexture=a.source,this.resources.uSampler=a.source.style)}}class $y extends ze{constructor(){super({positions:new Float32Array([0,0,1,0,1,1,0,1]),uvs:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])})}}function ky(r,t){const e=r.anchor.x,i=r.anchor.y;t[0]=-e*r.width,t[1]=-i*r.height,t[2]=(1-e)*r.width,t[3]=-i*r.height,t[4]=(1-e)*r.width,t[5]=(1-i)*r.height,t[6]=-e*r.width,t[7]=(1-i)*r.height}function Ly(r,t,e,i){let n=0;const s=r.length/(t||2),a=i.a,o=i.b,l=i.c,u=i.d,c=i.tx,h=i.ty;for(e*=t;nt in r?YM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ji=(r,t)=>{for(var e in t||(t={}))jy.call(t,e)&&zy(r,e,t[e]);if(ws)for(var e of ws(t))Hy.call(t,e)&&zy(r,e,t[e]);return r},KM=(r,t)=>{var e={};for(var i in r)jy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ws)for(var i of ws(r))t.indexOf(i)<0&&Hy.call(r,i)&&(e[i]=r[i]);return e};const Wy=class Ta extends Se{constructor(...t){let e=t[0]||{};e instanceof D&&(e={texture:e}),t.length>1&&(e.width=t[1],e.height=t[2]),e=ji(ji({},Ta.defaultOptions),e);const i=e!=null?e:{},{texture:n,anchor:s,tilePosition:a,tileScale:o,tileRotation:l,width:u,height:c,applyAnchorToTexture:h,roundPixels:p}=i,f=KM(i,["texture","anchor","tilePosition","tileScale","tileRotation","width","height","applyAnchorToTexture","roundPixels"]);super(ji({label:"TilingSprite"},f)),this.renderPipeId="tilingSprite",this.batched=!0,this.allowChildren=!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),this.applyAnchorToTexture=h,this.texture=n,this._width=u!=null?u:n.width,this._height=c!=null?c:n.height,this._tileTransform=new My({observer:{_onUpdate:()=>this.onViewUpdate()}}),s&&(this.anchor=s),this.tilePosition=a,this.tileScale=o,this.tileRotation=l,this.roundPixels=p!=null?p:!1}static from(t,e={}){return typeof t=="string"?new Ta(ji({texture:it.get(t)},e)):new Ta(ji({texture:t},e))}get uvRespectAnchor(){return Mi(Wo,"uvRespectAnchor is deprecated, please use applyAnchorToTexture instead"),this.applyAnchorToTexture}set uvRespectAnchor(t){Mi(Wo,"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){typeof t=="number"?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){typeof t=="number"?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=D.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){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?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,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}containsPoint(t){const e=this._width,i=this._height,n=-e*this._anchor._x;let s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this._anchor._y,t.y>=s&&t.y<=s+i)}destroy(t=!1){if(super.destroy(t),this._anchor=null,this._tileTransform=null,this._bounds=null,typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}};Wy.defaultOptions={texture:D.EMPTY,anchor:{x:0,y:0},tilePosition:{x:0,y:0},tileScale:{x:1,y:1},tileRotation:0,applyAnchorToTexture:!1};let Vy=Wy;var qM=Object.defineProperty,Es=Object.getOwnPropertySymbols,Yy=Object.prototype.hasOwnProperty,Ky=Object.prototype.propertyIsEnumerable,qy=(r,t,e)=>t in r?qM(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ZM=(r,t)=>{for(var e in t||(t={}))Yy.call(t,e)&&qy(r,e,t[e]);if(Es)for(var e of Es(t))Ky.call(t,e)&&qy(r,e,t[e]);return r},QM=(r,t)=>{var e={};for(var i in r)Yy.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Es)for(var i of Es(r))t.indexOf(i)<0&&Ky.call(r,i)&&(e[i]=r[i]);return e};class Ps extends Se{constructor(t,e){const i=t,{text:n,resolution:s,style:a,anchor:o,width:l,height:u,roundPixels:c}=i,h=QM(i,["text","resolution","style","anchor","width","height","roundPixels"]);super(ZM({},h)),this.batched=!0,this._resolution=null,this._autoResolution=!0,this._didTextUpdate=!0,this._styleClass=e,this.text=n!=null?n:"",this.style=a,this.resolution=s!=null?s:null,this.allowChildren=!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),o&&(this.anchor=o),this.roundPixels=c!=null?c:!1,l!==void 0&&(this.width=l),u!==void 0&&(this.height=u)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?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=t===null,this._resolution=t,this.onViewUpdate()}get resolution(){return this._resolution}get style(){return this._style}set style(t){var e;t||(t={}),(e=this._style)==null||e.off("update",this.onViewUpdate,this),t instanceof this._styleClass?this._style=t:this._style=new this._styleClass(t),this._style.on("update",this.onViewUpdate,this),this.onViewUpdate()}get 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){var i;typeof t=="object"?(e=(i=t.height)!=null?i:t.width,t=t.width):e!=null||(e=t),t!==void 0&&this._setWidth(t,this.bounds.width),e!==void 0&&this._setHeight(e,this.bounds.height)}containsPoint(t){const e=this.bounds.width,i=this.bounds.height,n=-e*this.anchor.x;let s=0;return t.x>=n&&t.x<=n+e&&(s=-i*this.anchor.y,t.y>=s&&t.y<=s+i)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}destroy(t=!1){super.destroy(t),this.owner=null,this._bounds=null,this._anchor=null,(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._text=null}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}}function As(r,t){var e;let i=(e=r[0])!=null?e:{};return(typeof i=="string"||r[1])&&(i={text:i,style:r[1]}),i}let dr=null,Fe=null;function JM(r,t){dr||(dr=H.get().createCanvas(256,128),Fe=dr.getContext("2d",{willReadFrequently:!0}),Fe.globalCompositeOperation="copy",Fe.globalAlpha=1),(dr.width * @license BSD-3-Clause * @version 11.4.7 - */class VM{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--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(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()){const e=new Array(t.length);for(let i=0;i0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.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(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,i=0;for(;e!==null;)t[i++]=e.key,e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let n=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(n=P1({},this.first),this.evict(!0));let s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=s:this.last.next=s,this.last=s}return n}set(t,e,i=!1,n=this.resetTtl){let s=this.items[t];return i||s!==void 0?(s.value=e,i===!1&&n&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(s)):(this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=s:this.last.next=s,this.last=s),this}values(t=this.keys()){const e=new Array(t.length);for(let i=0;i0}function As(r){return r.includes("<")}function YM(r,t){return r.clone().assign(t)}function iu(r,t){const e=[],i=t.tagStyles;if(!Es(t)||!As(r))return e.push({text:r,style:t}),e;const n=[t],s=[];let a="",o=0;for(;o",o);if(u===-1){a+=l,o++;continue}const c=r.indexOf("<",o+1);if(c!==-1&&c0&&s[s.length-1]===p){a.length>0&&(e.push({text:a,style:n[n.length-1]}),a=""),n.pop(),s.pop(),o=u+1;continue}else{a+=r.slice(o,u+1),o=u+1;continue}}else{const p=h.trim();if(i[p]){a.length>0&&(e.push({text:a,style:n[n.length-1]}),a="");const f=n[n.length-1],m=YM(f,i[p]);n.push(m),s.push(p),o=u+1;continue}else{a+=r.slice(o,u+1),o=u+1;continue}}}else a+=l,o++}return a.length>0&&e.push({text:a,style:n[n.length-1]}),e}function KM(r,t){return!Es(t)||!As(r)?r:iu(r,t).map(e=>e.text).join("")}const eb=[10,13],rb=new Set(eb),ib=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],nb=new Set(ib),sb=[9,32],ab=new Set(sb),ob=[45,8208,8211,8212,173],lb=new Set(ob),ub=/(\r\n|\r|\n)/,cb=/(?:\r\n|\r|\n)/;function Hi(r){return typeof r!="string"?!1:rb.has(r.charCodeAt(0))}function Qt(r,t){return typeof r!="string"?!1:nb.has(r.charCodeAt(0))}function nu(r){return typeof r!="string"?!1:ab.has(r.charCodeAt(0))}function su(r){return typeof r!="string"?!1:lb.has(r.charCodeAt(0))}function Cs(r){return r==="normal"||r==="pre-line"}function Ms(r){return r==="normal"}function Ce(r){if(typeof r!="string")return"";let t=r.length-1;for(;t>=0&&Qt(r[t]);)t--;return t0&&(t.push(e.join("")),e.length=0),n==="\r"&&s===` + */class tR{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--,e.prev!==null&&(e.prev.next=e.next),e.next!==null&&(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()){const e=new Array(t.length);for(let i=0;i0){const e=this.first;delete this.items[e.key],--this.size===0?(this.first=null,this.last=null):(this.first=e.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(e!==void 0){if(this.ttl>0&&e.expiry<=Date.now()){this.delete(t);return}return this.moveToEnd(e),e.value}}has(t){return t in this.items}moveToEnd(t){this.last!==t&&(t.prev!==null&&(t.prev.next=t.next),t.next!==null&&(t.next.prev=t.prev),this.first===t&&(this.first=t.next),t.prev=this.last,t.next=null,this.last!==null&&(this.last.next=t),this.last=t,this.first===null&&(this.first=t))}keys(){const t=new Array(this.size);let e=this.first,i=0;for(;e!==null;)t[i++]=e.key,e=e.next;return t}setWithEvicted(t,e,i=this.resetTtl){let n=null;if(this.has(t))this.set(t,e,!0,i);else{this.max>0&&this.size===this.max&&(n=A1({},this.first),this.evict(!0));let s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e};++this.size===1?this.first=s:this.last.next=s,this.last=s}return n}set(t,e,i=!1,n=this.resetTtl){let s=this.items[t];return i||s!==void 0?(s.value=e,i===!1&&n&&(s.expiry=this.ttl>0?Date.now()+this.ttl:this.ttl),this.moveToEnd(s)):(this.max>0&&this.size===this.max&&this.evict(!0),s=this.items[t]={expiry:this.ttl>0?Date.now()+this.ttl:this.ttl,key:t,prev:this.last,next:null,value:e},++this.size===1?this.first=s:this.last.next=s,this.last=s),this}values(t=this.keys()){const e=new Array(t.length);for(let i=0;i0}function Ms(r){return r.includes("<")}function eR(r,t){return r.clone().assign(t)}function nu(r,t){const e=[],i=t.tagStyles;if(!Cs(t)||!Ms(r))return e.push({text:r,style:t}),e;const n=[t],s=[];let a="",o=0;for(;o",o);if(u===-1){a+=l,o++;continue}const c=r.indexOf("<",o+1);if(c!==-1&&c0&&s[s.length-1]===p){a.length>0&&(e.push({text:a,style:n[n.length-1]}),a=""),n.pop(),s.pop(),o=u+1;continue}else{a+=r.slice(o,u+1),o=u+1;continue}}else{const p=h.trim();if(i[p]){a.length>0&&(e.push({text:a,style:n[n.length-1]}),a="");const f=n[n.length-1],m=eR(f,i[p]);n.push(m),s.push(p),o=u+1;continue}else{a+=r.slice(o,u+1),o=u+1;continue}}}else a+=l,o++}return a.length>0&&e.push({text:a,style:n[n.length-1]}),e}function rR(r,t){return!Cs(t)||!Ms(r)?r:nu(r,t).map(e=>e.text).join("")}const eb=[10,13],rb=new Set(eb),ib=[9,32,8192,8193,8194,8195,8196,8197,8198,8200,8201,8202,8287,12288],nb=new Set(ib),sb=[9,32],ab=new Set(sb),ob=[45,8208,8211,8212,173],lb=new Set(ob),ub=/(\r\n|\r|\n)/,cb=/(?:\r\n|\r|\n)/;function Hi(r){return typeof r!="string"?!1:rb.has(r.charCodeAt(0))}function Qt(r,t){return typeof r!="string"?!1:nb.has(r.charCodeAt(0))}function su(r){return typeof r!="string"?!1:ab.has(r.charCodeAt(0))}function au(r){return typeof r!="string"?!1:lb.has(r.charCodeAt(0))}function Rs(r){return r==="normal"||r==="pre-line"}function Os(r){return r==="normal"}function Ce(r){if(typeof r!="string")return"";let t=r.length-1;for(;t>=0&&Qt(r[t]);)t--;return t0&&(t.push(e.join("")),e.length=0),n==="\r"&&s===` `?(t.push(`\r -`),i++):t.push(n);continue}e.push(n),su(n)&&s&&!Qt(s)&&!Hi(s)&&(t.push(e.join("")),e.length=0)}return e.length>0&&t.push(e.join("")),t}function ou(r,t,e,i){const n=e(r),s=[];for(let a=0;a0&&t.push(e.join("")),t}function lu(r,t,e,i){const n=e(r),s=[];for(let a=0;a0&&f.push({text:L,style:B.style})}}(f.length>0||p.length===0)&&p.push(f);const m=e?db(p,t,i,s,o,l):p,g=[],_=[],y=[],b=[],x=[];let v=0;const w=t._fontString,T=a(w);T.fontSize===0&&(T.fontSize=t.fontSize,T.ascent=t.fontSize);let P="",E=!!t.dropShadow,M=((u=t._stroke)==null?void 0:u.width)||0;for(const B of m){let O=0,I=T.ascent,L=T.descent,j="";for(const K of B){const N=K.style._fontString,k=a(N);N!==P&&(i.font=N,P=N);const $=n(K.text,K.style.letterSpacing,i);O+=$,I=Math.max(I,k.ascent),L=Math.max(L,k.descent),j+=K.text;const z=((c=K.style._stroke)==null?void 0:c.width)||0;z>M&&(M=z),!E&&K.style.dropShadow&&(E=!0)}B.length===0&&(I=T.ascent,L=T.descent),g.push(O),_.push(I),y.push(L),x.push(j);const J=t.lineHeight||I+L;b.push(J+t.leading),v=Math.max(v,O)}const C=M,A=v+C+(t.dropShadow?t.dropShadow.distance:0);let G=0;for(let B=0;B{const w=`${x}|${v.styleKey}`;let T=g[w];if(T===void 0){const P=v._fontString;P!==_&&(e.font=P,_=P),T=i(x,v.letterSpacing,e)+v.letterSpacing,g[w]=T}return T},b=[];for(const x of r){const v=pb(x),w=b.length,T=R=>{let B=0,O=R;do{const{token:I,style:L}=v[O];B+=y(I,L),O++}while(O{const B=[];let O=R;do B.push({token:v[O].token,style:v[O].style}),O++;while(O{A&&A.text.length>0&&E.push(A),A=null},F=()=>{if(G(),E.length>0){const R=E[E.length-1];R.text=Ce(R.text),R.text.length===0&&E.pop()}b.push(E),E=[],M=0,C=!1};for(let R=0;Rm&&j)if(M>0&&F(),p){const K=P(R);for(let N=0;Nm&&F(),!A||A.style!==$?(G(),A={text:rt,style:$}):A.text+=rt,M+=_t}}R+=K.length-1}else{const K=P(R);G(),b.push(K.map(N=>({text:N.token,style:N.style}))),C=!1,R+=K.length-1}else if(J+M>m&&j){if(Qt(B)){C=!1;continue}F(),A={text:B,style:O},M=L}else if(I&&!p)!A||A.style!==O?(G(),A={text:B,style:O}):A.text+=B,M+=L;else{const K=Qt(B);if(M===0&&K&&!C)continue;!A||A.style!==O?(G(),A={text:B,style:O}):A.text+=B,M+=L}}if(G(),E.length>0){const R=E[E.length-1];R.text=Ce(R.text),R.text.length===0&&E.pop()}(E.length>0||b.length===w)&&b.push(E)}return b}function pb(r){const t=[];let e=!1;for(const i of r){const n=au(i.text);let s=!0;for(const a of n){const o=Qt(a)||Hi(a),l=s&&e&&!o;t.push({token:a,style:i.style,continuesFromPrevious:l}),e=!o,s=!1}}return t}const ZM={willReadFrequently:!0};function fb(r,t,e,i,n){let s=e[r];return typeof s!="number"&&(s=n(r,t,i)+t,e[r]=s),s}function mb(r,t,e,i,n,s,a){const o=e.getContext("2d",ZM);o.font=t._fontString;let l=0,u="";const c=[],h=Object.create(null),{letterSpacing:p,whiteSpace:f}=t,m=Cs(f),g=Ms(f);let _=!m;const y=t.wordWrapWidth+p,b=au(r);for(let v=0;vy)if(u!==""&&(c.push(Ce(u)),u="",l=0),n(w,t.breakWords)){const P=ou(w,t.breakWords,a,s);for(const E of P){const M=fb(E,p,h,o,i);M+l>y&&(c.push(Ce(u)),_=!1,u="",l=0),u+=E,l+=M}}else u.length>0&&(c.push(Ce(u)),u="",l=0),c.push(Ce(w)),_=!1,u="",l=0;else T+l>y&&(_=!1,c.push(Ce(u)),u="",l=0),(u.length>0||!Qt(w)||_)&&(u+=w,l+=T)}const x=Ce(u);return x.length>0&&c.push(x),c.join(` -`)}const gb={willReadFrequently:!0},De=class q{static get experimentalLetterSpacingSupported(){let t=q._experimentalLetterSpacingSupported;if(t===void 0){const e=H.get().getCanvasRenderingContext2D().prototype;t=q._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,s,a,o,l,u,c){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=l,this.fontProperties=u,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=q._canvas,n=e.wordWrap){var s,a;const o=`${t}-${e.styleKey}-wordWrap-${n}`;if(q._measurementCache.has(o))return q._measurementCache.get(o);if(Es(e)&&As(t)){const v=hb(t,e,n,q._context,q._measureText,q._measureTextAdvance,q.measureFont,q.canBreakChars,q.wordWrapSplit),w=new q(t,e,v.width,v.height,v.lines,v.lineWidths,v.lineHeight,v.maxLineWidth,v.fontProperties,{runsByLine:v.runsByLine,lineAscents:v.lineAscents,lineDescents:v.lineDescents,lineHeights:v.lineHeights,hasDropShadow:v.hasDropShadow});return q._measurementCache.set(o,w),w}const l=e._fontString,u=q.measureFont(l);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize,u.descent=0);const c=q._context;c.font=l;const h=(n?q._wordWrap(t,e,i):t).split(cb),p=new Array(h.length);let f=0;for(let v=0;v0&&(c+=l),Math.max(a,c)}static _measureTextAdvance(t,e,i){return q._measureTextCore(t,e,i).metricWidth}static _measureTextCore(t,e,i){let n=!1;q.experimentalLetterSpacingSupported&&(q.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const s=i.measureText(t);let a=s.width,o=0;return a>0&&(n?o=-e:o=(q.graphemeSegmenter(t).length-1)*e,a+=o),{metricWidth:a,metrics:s,letterSpacingVal:o}}static _wordWrap(t,e,i=q._canvas){return mb(t,e,i,q._measureTextAdvance,q.canBreakWords,q.canBreakChars,q.wordWrapSplit)}static isBreakingSpace(t,e){return Qt(t,e)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){return!0}static wordWrapSplit(t){return q.graphemeSegmenter(t)}static measureFont(t){var e,i;if(q._fonts[t])return q._fonts[t];const n=q._context;n.font=t;const s=n.measureText(q.METRICS_STRING+q.BASELINE_SYMBOL),a=(e=s.actualBoundingBoxAscent)!=null?e:0,o=(i=s.actualBoundingBoxDescent)!=null?i:0,l={ascent:a,descent:o,fontSize:a+o};return q._fonts[t]=l,l}static clearMetrics(t=""){t?delete q._fonts[t]:q._fonts={}}static get _canvas(){if(!q.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",gb);if(i!=null&&i.measureText)return q.__canvas=e,e;t=H.get().createCanvas()}catch(e){t=H.get().createCanvas()}t.width=t.height=10,q.__canvas=t}return q.__canvas}static get _context(){return q.__context||(q.__context=q._canvas.getContext("2d",gb)),q.__context}};De.METRICS_STRING="|\xC9q\xC5",De.BASELINE_SYMBOL="M",De.BASELINE_MULTIPLIER=1.4,De.HEIGHT_MULTIPLIER=2,De.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),i=[];let n=0;for(const s of e)i[n++]=s.segment;return i}}return r=>[...r]})(),De.experimentalLetterSpacing=!1,De._fonts={},De._measurementCache=tb(1e3);let St=De;const QM=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Zr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!QM.includes(n)&&(n=`"${n}"`),e[i]=n}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const _b=1e5;function pr(r,t,e,i=0,n=0,s=0){var a;if(r.texture===D.WHITE&&!r.fill)return tt.shared.setValue(r.color).setAlpha((a=r.alpha)!=null?a:1).toHexa();if(r.fill){if(r.fill instanceof Xr){const o=r.fill,l=t.createPattern(o.texture.source.resource,"repeat"),u=o.transform.copyTo(U.shared);return u.scale(o.texture.source.pixelWidth,o.texture.source.pixelHeight),l.setTransform(u),l}else if(r.fill instanceof $t){const o=r.fill,l=o.type==="linear",u=o.textureSpace==="local";let c=1,h=1;u&&e&&(c=e.width+i,h=e.height+i);let p,f=!1;if(l){const{start:m,end:g}=o;p=t.createLinearGradient(m.x*c+n,m.y*h+s,g.x*c+n,g.y*h+s),f=Math.abs(g.x-m.x){let b=_+y.offset*m;b=Math.max(0,Math.min(1,b)),p.addColorStop(Math.floor(b*_b)/_b,tt.shared.setValue(y.color).toHex())})}}else o.colorStops.forEach(m=>{p.addColorStop(m.offset,tt.shared.setValue(m.color).toHex())});return p}}else{const o=t.createPattern(r.texture.source.resource,"repeat"),l=r.matrix.copyTo(U.shared);return l.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(l),o}return"red"}const yb=new ut;function Qr(r){let t=0;for(let e=0;e0){this._renderTaggedTextToCanvas(s,t,e,i,n);return}const{canvas:p,context:f}=n,m=Zr(t),g=s.lines,_=s.lineHeight,y=s.lineWidths,b=s.maxLineWidth,x=s.fontProperties,v=p.height;if(f.resetTransform(),f.scale(i,i),f.textBaseline=t.textBaseline,(a=t._stroke)!=null&&a.width){const C=t._stroke;f.lineWidth=C.width,f.miterLimit=C.miterLimit,f.lineJoin=C.join,f.lineCap=C.cap}f.font=m;let w,T;const P=t.dropShadow?2:1,E=((l=(o=t._stroke)==null?void 0:o.width)!=null?l:0)/2;let M=(_-x.fontSize)/2;_-x.fontSize<0&&(M=0);for(let C=0;C0&&(B=(b-y[R])/O)}(h=t._stroke)!=null&&h.width&&this._drawLetterSpacing(g[R],t,n,w+e,T+e-G,!0,B),t._fill!==void 0&&this._drawLetterSpacing(g[R],t,n,w+e,T+e-G,!1,B)}}}_renderTaggedTextToCanvas(t,e,i,n,s){var a,o,l,u,c;const{canvas:h,context:p}=s,{runsByLine:f,lineWidths:m,maxLineWidth:g,lineAscents:_,lineHeights:y,hasDropShadow:b}=t,x=h.height;p.resetTransform(),p.scale(n,n),p.textBaseline=e.textBaseline;const v=b?2:1;let w=(o=(a=e._stroke)==null?void 0:a.width)!=null?o:0;for(const E of f)for(const M of E){const C=(u=(l=M.style._stroke)==null?void 0:l.width)!=null?u:0;C>w&&(w=C)}const T=w/2,P=[];for(let E=0;E0&&(J=(g-B)/k)}const K=G+O;let N=j+i;for(let k=0;kt in r?tR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lt=(r,t)=>{for(var e in t||(t={}))iR.call(t,e)&&vb(r,e,t[e]);if(bb)for(var e of bb(t))nR.call(t,e)&&vb(r,e,t[e]);return r},sR=(r,t)=>eR(r,rR(t));const lu=class yr extends Nt{constructor(t={}){var e;super(),this.uid=ht("textStyle"),this._tick=0,this._cachedFontString=null,aR(t),t instanceof yr&&(t=t._toObject());const i=Lt(Lt({},yr.defaultTextStyle),t);for(const n in i){const s=n;this[s]=i[n]}this._tagStyles=(e=t.tagStyles)!=null?e:void 0,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(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Lt(Lt({},yr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Lt({},yr.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&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._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(Lt(Lt({},kt.defaultFillStyle),t),()=>{this._fill=Xe(Lt({},this._originalFill),kt.defaultFillStyle)})),this._fill=Xe(t===0?"black":t,kt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Lt(Lt({},kt.defaultStrokeStyle),t),()=>{this._stroke=Bi(Lt({},this._originalStroke),kt.defaultStrokeStyle)})),this._stroke=Bi(t,kt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=yr.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Zr(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Lt({},this._dropShadow):null,fill:this._fill?Lt({},this._fill):void 0,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?Lt({},this._stroke):void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?Lt({},this._tagStyles):void 0}}clone(){return new yr(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e(i[n]===s||(i[n]=s,e==null||e(n,s),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(tt.isColorLike(t)||t instanceof $t||t instanceof Xr)}};lu.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},lu.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 jt=lu;function aR(r){var t,e,i,n,s;const a=r;if(typeof a.dropShadow=="boolean"&&a.dropShadow){const o=jt.defaultDropShadow;r.dropShadow={alpha:(t=a.dropShadowAlpha)!=null?t:o.alpha,angle:(e=a.dropShadowAngle)!=null?e:o.angle,blur:(i=a.dropShadowBlur)!=null?i:o.blur,color:(n=a.dropShadowColor)!=null?n:o.color,distance:(s=a.dropShadowDistance)!=null?s:o.distance}}if(a.strokeThickness!==void 0){const o=a.stroke;let l={};if(tt.isColorLike(o))l.color=o;else if(o instanceof $t||o instanceof Xr)l.fill=o;else if(Object.hasOwnProperty.call(o,"color")||Object.hasOwnProperty.call(o,"fill"))l=o;else throw new Error("Invalid stroke value.");r.stroke=sR(Lt({},l),{width:a.strokeThickness})}if(Array.isArray(a.fillGradientStops)){if(!Array.isArray(a.fill)||a.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");a.fill.length,a.fillGradientStops.length;const o=new $t({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=a.fillGradientStops.slice(),u=a.fill.map(c=>tt.shared.setValue(c).toNumber());l.forEach((c,h)=>{o.addColorStop(c,u[h])}),r.fill={fill:o}}}function Rs(r,t){const{texture:e,bounds:i}=r,n=t._style._getFinalPadding();qa(i,t._anchor,e);const s=t._anchor._x*n*2,a=t._anchor._y*n*2;i.minX-=n-s,i.minY-=n-a,i.maxX-=n-s,i.maxY-=n-a}class zi{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(){this.reset()}}class xb extends zi{}class uu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Ut({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,Rs(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 xb;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,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}uu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};class cu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,n){var s;typeof t=="string"&&(t={text:t,style:i,resolution:e}),t.style instanceof jt||(t.style=new jt(t.style)),t.textureStyle instanceof Jt||(t.textureStyle=new Jt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:a,style:o,textureStyle:l,autoGenerateMipmaps:u}=t,c=(s=t.resolution)!=null?s:this._renderer.resolution,{frame:h,canvasAndContext:p}=ye.getCanvasAndContext({text:a,style:o,resolution:c}),f=Cn(p.canvas,h.width,h.height,c,u);if(l&&(f.source.style=l),o.trim&&(h.pad(o.padding),f.frame.copyFrom(h),f.frame.scale(1/c),f.updateUvs()),o.filters){const m=this._applyFilters(f,o.filters);return this.returnTexture(f),ye.returnCanvasAndContext(p),m}return this._renderer.texture.initSource(f._source),this._retainCanvasContext||ye.returnCanvasAndContext(p),f}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&i!=null&&i.getContext){const n=i.getContext("2d");n&&ye.returnCanvasAndContext({canvas:i,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",vt.returnTexture(t,!0)}renderTextToCanvas(){}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,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class hu extends cu{constructor(t){super(t,!0)}}hu.extension={type:[S.CanvasSystem],name:"canvasText"};class du extends cu{constructor(t){super(t,!1)}}du.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"canvasText"},X.add(hu),X.add(du),X.add(uu);class Wi extends ws{constructor(...t){var e;const i=Ps(t,"Text");super(i,jt),this.renderPipeId="text",i.textureStyle&&(this.textureStyle=i.textureStyle instanceof Jt?i.textureStyle:new Jt(i.textureStyle)),this.autoGenerateMipmaps=(e=i.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:s,canvasAndContext:a}=ye.getCanvasAndContext({text:this.text,style:this._style,resolution:1});ye.returnCanvasAndContext(a),i=s.width,n=s.height}else{const s=St.measureText(this._text,this._style);i=s.width,n=s.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}class Tb extends py{resolveQueueItem(t,e){return t instanceof dt?this.resolveContainerQueueItem(t,e):t instanceof ft||t instanceof D?e.push(t.source):t instanceof kt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof pe||t instanceof Vy||t instanceof Kr?e.push(t.texture.source):t instanceof Wi?e.push(t):t instanceof hr?e.push(t.context):t instanceof Xi&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:n}=i.data;return n.source}else if(i.action==="fill"){const{texture:n}=i.data.style;return n.source}return null}}class pu extends Nt{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 this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}var oR=Object.defineProperty,Sb=Object.getOwnPropertySymbols,lR=Object.prototype.hasOwnProperty,uR=Object.prototype.propertyIsEnumerable,wb=(r,t,e)=>t in r?oR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Pb=(r,t)=>{for(var e in t||(t={}))lR.call(t,e)&&wb(r,e,t[e]);if(Sb)for(var e of Sb(t))uR.call(t,e)&&wb(r,e,t[e]);return r};const Eb=class L1 extends pu{constructor(t){var e,i,n;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 s=Pb(Pb({},L1.defaultOptions),t);this._textureSize=s.textureSize,this._mipmap=s.mipmap;const a=s.style.clone();s.overrideFill&&(a._fill.color=16777215,a._fill.alpha=1,a._fill.texture=D.WHITE,a._fill.fill=null),this.applyFillAsTint=s.overrideFill;const o=a.fontSize;a.fontSize=this.baseMeasurementFontSize;const l=Zr(a);s.overrideSize?(a._stroke&&(a._stroke.width*=this.baseRenderedFontSize/o),a.dropShadow&&(a.dropShadow.blur*=this.baseRenderedFontSize/o,a.dropShadow.distance*=this.baseRenderedFontSize/o)):a.fontSize=this.baseRenderedFontSize=o,this._style=a,this._skipKerning=(e=s.skipKerning)!=null?e:!1,this.resolution=(i=s.resolution)!=null?i:1,this._padding=(n=s.padding)!=null?n:4,s.textureStyle&&(this._textureStyle=s.textureStyle instanceof Jt?s.textureStyle:new Jt(s.textureStyle)),this.fontMetrics=St.measureFont(l),this.lineHeight=a.lineHeight||this.fontMetrics.fontSize||a.fontSize}ensureCharacters(t){var e,i,n,s;const a=St.graphemeSegmenter(t).filter(w=>!this._currentChars.includes(w)).filter((w,T,P)=>P.indexOf(w)===T);if(!a.length)return;this._currentChars=[...this._currentChars,...a];let o;this._currentPageIndex===-1?o=this._nextPage():o=this.pages[this._currentPageIndex];let{canvas:l,context:u}=o.canvasAndContext,c=o.texture.source;const h=this._style;let p=this._currentX,f=this._currentY,m=this._currentMaxCharHeight;const g=this.baseRenderedFontSize/this.baseMeasurementFontSize,_=((i=(e=h.dropShadow)==null?void 0:e.distance)!=null?i:0)+((s=(n=h._stroke)==null?void 0:n.width)!=null?s:0),y=this._padding+_;let b=!1;const x=l.width/this.resolution,v=l.height/this.resolution;for(let w=0;wx&&(f+=m,m=G,p=0,f+m>v)){c.update();const R=this._nextPage();l=R.canvasAndContext.canvas,u=R.canvasAndContext.context,c=R.texture.source,p=0,f=0,m=0}const F=u.measureText(T).width/g;if(this.chars[T]={id:T.codePointAt(0),xOffset:-(y/g),yOffset:-(y/g),xAdvance:F,kerning:{}},b){this._drawGlyph(u,P,p+y,f+y,g,h);const R=c.width*g,B=c.height*g,O=new ut(p/R*c.width,f/B*c.height,A/R*c.width,G/B*c.height);this.chars[T].texture=new D({source:c,frame:O}),p+=Math.ceil(A)}}c.update(),this._currentX=p,this._currentY=f,this._currentMaxCharHeight=m,this._skipKerning||this._applyKerning(a,u,g)}get pageTextures(){return this.pages}_applyKerning(t,e,i){const n=this._measureCache;for(let s=0;s{const T=o.width;for(let P=0;P0||!_)&&(u=!1),c.width=0,c.index=0,c.chars.length=0},x=()=>{let w=o.chars.length-1;if(i){let T=o.chars[w];for(;nu(T);)o.width-=e.chars[T].xAdvance,o.spacesIndex.pop(),T=o.chars[--w]}a.width=Math.max(a.width,o.width),o={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},u=!0,a.lines.push(o),a.height+=m},v=w=>w-p>f;for(let w=0;wt in r?pR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mu=(r,t)=>{for(var e in t||(t={}))fR.call(t,e)&&Mb(r,e,t[e]);if(Cb)for(var e of Cb(t))mR.call(t,e)&&Mb(r,e,t[e]);return r};let Gs=0,gR=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=tb(1e3)}getFont(t,e){var i,n;let s=`${e.fontFamily}-bitmap`,a=!0;if(it.has(s)){const l=it.get(s);return(i=l.ensureCharacters)==null||i.call(l,t),l}if(e._fill.fill&&!e._stroke?(s+=e._fill.fill.styleKey,a=!1):(e._stroke||e.dropShadow)&&(s=`${e.styleKey}-bitmap`,a=!1),s+=`-${e.fontStyle}`,s+=`-${e.fontVariant}`,s+=`-${e.fontWeight}`,!it.has(s)){const l=Object.create(e);l._lineHeight=0;const u=new fu(mu({style:l,overrideFill:a,overrideSize:!0},this.defaultOptions));Gs++,Gs>50&&ue("BitmapText",`You have dynamically created ${Gs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),u.once("destroy",()=>{Gs--,it.remove(s)}),it.set(s,u)}const o=it.get(s);return(n=o.ensureCharacters)==null||n.call(o,t),o}getLayout(t,e,i=!0){const n=this.getFont(t,e),s=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(s))return this.measureCache.get(s);const a=St.graphemeSegmenter(t),o=Os(a,e,n,i);return this.measureCache.set(s,o),o}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,n,s,a;let o=t[0];typeof o=="string"&&(o={name:o,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(i=t[2])==null?void 0:i.resolution,padding:(n=t[2])==null?void 0:n.padding,skipKerning:(s=t[2])==null?void 0:s.skipKerning});const l=o==null?void 0:o.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");o=mu(mu({},this.defaultOptions),o);const u=o.style,c=u instanceof jt?u:new jt(u),h=(a=o.dynamicFill)!=null?a:this._canUseTintForStyle(c),p=new fu({style:c,overrideFill:h,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1,textureStyle:o.textureStyle}),f=Ab(o.chars);return p.ensureCharacters(f.join("")),it.set(`${l}-bitmap`,p),p.once("destroy",()=>it.remove(`${l}-bitmap`)),p}uninstall(t){const e=`${t}-bitmap`,i=it.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const Jr=new gR;class Rb extends hr{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class gu{constructor(t){this._renderer=t,this._managedBitmapTexts=new Ut({renderer:t,type:"renderable",priority:-2,name:"bitmapText"})}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Ob(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);Ob(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=Jr.getFont(t.text,t._style);if(i.clear(),n.distanceField.type!=="none"){const y=this.getSdfShader();y&&(i.customShader||(i.customShader=y))}const s=St.graphemeSegmenter(t.text),a=t._style;let o=n.baseLineOffset;const l=Os(s,a,n,!0),u=a.padding,c=l.scale;let h=l.width,p=l.height+l.offsetY;a._stroke&&(h+=a._stroke.width/c,p+=a._stroke.width/c),i.translate(-t._anchor._x*h-u,-t._anchor._y*p-u).scale(c,c);const f=n.applyFillAsTint?a._fill.color:16777215;let m=n.fontMetrics.fontSize,g=n.lineHeight;a.lineHeight&&(m=a.fontSize/c,g=a.lineHeight/c);let _=(g-m)/2;_-n.baseLineOffset<0&&(_=0);for(let y=0;y0&&f.push({text:L,style:B.style})}}(f.length>0||p.length===0)&&p.push(f);const m=e?db(p,t,i,s,o,l):p,g=[],_=[],y=[],b=[],x=[];let v=0;const w=t._fontString,T=a(w);T.fontSize===0&&(T.fontSize=t.fontSize,T.ascent=t.fontSize);let E="",P=!!t.dropShadow,M=((u=t._stroke)==null?void 0:u.width)||0;for(const B of m){let O=0,I=T.ascent,L=T.descent,j="";for(const K of B){const X=K.style._fontString,k=a(X);X!==E&&(i.font=X,E=X);const $=n(K.text,K.style.letterSpacing,i);O+=$,I=Math.max(I,k.ascent),L=Math.max(L,k.descent),j+=K.text;const z=((c=K.style._stroke)==null?void 0:c.width)||0;z>M&&(M=z),!P&&K.style.dropShadow&&(P=!0)}B.length===0&&(I=T.ascent,L=T.descent),g.push(O),_.push(I),y.push(L),x.push(j);const J=t.lineHeight||I+L;b.push(J+t.leading),v=Math.max(v,O)}const C=M,A=v+C+(t.dropShadow?t.dropShadow.distance:0);let G=0;for(let B=0;B{const w=`${x}|${v.styleKey}`;let T=g[w];if(T===void 0){const E=v._fontString;E!==_&&(e.font=E,_=E),T=i(x,v.letterSpacing,e)+v.letterSpacing,g[w]=T}return T},b=[];for(const x of r){const v=pb(x),w=b.length,T=R=>{let B=0,O=R;do{const{token:I,style:L}=v[O];B+=y(I,L),O++}while(O{const B=[];let O=R;do B.push({token:v[O].token,style:v[O].style}),O++;while(O{A&&A.text.length>0&&P.push(A),A=null},F=()=>{if(G(),P.length>0){const R=P[P.length-1];R.text=Ce(R.text),R.text.length===0&&P.pop()}b.push(P),P=[],M=0,C=!1};for(let R=0;Rm&&j)if(M>0&&F(),p){const K=E(R);for(let X=0;Xm&&F(),!A||A.style!==$?(G(),A={text:rt,style:$}):A.text+=rt,M+=_t}}R+=K.length-1}else{const K=E(R);G(),b.push(K.map(X=>({text:X.token,style:X.style}))),C=!1,R+=K.length-1}else if(J+M>m&&j){if(Qt(B)){C=!1;continue}F(),A={text:B,style:O},M=L}else if(I&&!p)!A||A.style!==O?(G(),A={text:B,style:O}):A.text+=B,M+=L;else{const K=Qt(B);if(M===0&&K&&!C)continue;!A||A.style!==O?(G(),A={text:B,style:O}):A.text+=B,M+=L}}if(G(),P.length>0){const R=P[P.length-1];R.text=Ce(R.text),R.text.length===0&&P.pop()}(P.length>0||b.length===w)&&b.push(P)}return b}function pb(r){const t=[];let e=!1;for(const i of r){const n=ou(i.text);let s=!0;for(const a of n){const o=Qt(a)||Hi(a),l=s&&e&&!o;t.push({token:a,style:i.style,continuesFromPrevious:l}),e=!o,s=!1}}return t}const nR={willReadFrequently:!0};function fb(r,t,e,i,n){let s=e[r];return typeof s!="number"&&(s=n(r,t,i)+t,e[r]=s),s}function mb(r,t,e,i,n,s,a){const o=e.getContext("2d",nR);o.font=t._fontString;let l=0,u="";const c=[],h=Object.create(null),{letterSpacing:p,whiteSpace:f}=t,m=Rs(f),g=Os(f);let _=!m;const y=t.wordWrapWidth+p,b=ou(r);for(let v=0;vy)if(u!==""&&(c.push(Ce(u)),u="",l=0),n(w,t.breakWords)){const E=lu(w,t.breakWords,a,s);for(const P of E){const M=fb(P,p,h,o,i);M+l>y&&(c.push(Ce(u)),_=!1,u="",l=0),u+=P,l+=M}}else u.length>0&&(c.push(Ce(u)),u="",l=0),c.push(Ce(w)),_=!1,u="",l=0;else T+l>y&&(_=!1,c.push(Ce(u)),u="",l=0),(u.length>0||!Qt(w)||_)&&(u+=w,l+=T)}const x=Ce(u);return x.length>0&&c.push(x),c.join(` +`)}const gb={willReadFrequently:!0},De=class q{static get experimentalLetterSpacingSupported(){let t=q._experimentalLetterSpacingSupported;if(t===void 0){const e=H.get().getCanvasRenderingContext2D().prototype;t=q._experimentalLetterSpacingSupported="letterSpacing"in e||"textLetterSpacing"in e}return t}constructor(t,e,i,n,s,a,o,l,u,c){this.text=t,this.style=e,this.width=i,this.height=n,this.lines=s,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=l,this.fontProperties=u,c&&(this.runsByLine=c.runsByLine,this.lineAscents=c.lineAscents,this.lineDescents=c.lineDescents,this.lineHeights=c.lineHeights,this.hasDropShadow=c.hasDropShadow)}static measureText(t=" ",e,i=q._canvas,n=e.wordWrap){var s,a;const o=`${t}-${e.styleKey}-wordWrap-${n}`;if(q._measurementCache.has(o))return q._measurementCache.get(o);if(Cs(e)&&Ms(t)){const v=hb(t,e,n,q._context,q._measureText,q._measureTextAdvance,q.measureFont,q.canBreakChars,q.wordWrapSplit),w=new q(t,e,v.width,v.height,v.lines,v.lineWidths,v.lineHeight,v.maxLineWidth,v.fontProperties,{runsByLine:v.runsByLine,lineAscents:v.lineAscents,lineDescents:v.lineDescents,lineHeights:v.lineHeights,hasDropShadow:v.hasDropShadow});return q._measurementCache.set(o,w),w}const l=e._fontString,u=q.measureFont(l);u.fontSize===0&&(u.fontSize=e.fontSize,u.ascent=e.fontSize,u.descent=0);const c=q._context;c.font=l;const h=(n?q._wordWrap(t,e,i):t).split(cb),p=new Array(h.length);let f=0;for(let v=0;v0&&(c+=l),Math.max(a,c)}static _measureTextAdvance(t,e,i){return q._measureTextCore(t,e,i).metricWidth}static _measureTextCore(t,e,i){let n=!1;q.experimentalLetterSpacingSupported&&(q.experimentalLetterSpacing?(i.letterSpacing=`${e}px`,i.textLetterSpacing=`${e}px`,n=!0):(i.letterSpacing="0px",i.textLetterSpacing="0px"));const s=i.measureText(t);let a=s.width,o=0;return a>0&&(n?o=-e:o=(q.graphemeSegmenter(t).length-1)*e,a+=o),{metricWidth:a,metrics:s,letterSpacingVal:o}}static _wordWrap(t,e,i=q._canvas){return mb(t,e,i,q._measureTextAdvance,q.canBreakWords,q.canBreakChars,q.wordWrapSplit)}static isBreakingSpace(t,e){return Qt(t,e)}static canBreakWords(t,e){return e}static canBreakChars(t,e,i,n,s){return!0}static wordWrapSplit(t){return q.graphemeSegmenter(t)}static measureFont(t){var e,i;if(q._fonts[t])return q._fonts[t];const n=q._context;n.font=t;const s=n.measureText(q.METRICS_STRING+q.BASELINE_SYMBOL),a=(e=s.actualBoundingBoxAscent)!=null?e:0,o=(i=s.actualBoundingBoxDescent)!=null?i:0,l={ascent:a,descent:o,fontSize:a+o};return q._fonts[t]=l,l}static clearMetrics(t=""){t?delete q._fonts[t]:q._fonts={}}static get _canvas(){if(!q.__canvas){let t;try{const e=new OffscreenCanvas(0,0),i=e.getContext("2d",gb);if(i!=null&&i.measureText)return q.__canvas=e,e;t=H.get().createCanvas()}catch(e){t=H.get().createCanvas()}t.width=t.height=10,q.__canvas=t}return q.__canvas}static get _context(){return q.__context||(q.__context=q._canvas.getContext("2d",gb)),q.__context}};De.METRICS_STRING="|\xC9q\xC5",De.BASELINE_SYMBOL="M",De.BASELINE_MULTIPLIER=1.4,De.HEIGHT_MULTIPLIER=2,De.graphemeSegmenter=(()=>{if(typeof(Intl==null?void 0:Intl.Segmenter)=="function"){const r=new Intl.Segmenter;return t=>{const e=r.segment(t),i=[];let n=0;for(const s of e)i[n++]=s.segment;return i}}return r=>[...r]})(),De.experimentalLetterSpacing=!1,De._fonts={},De._measurementCache=tb(1e3);let St=De;const sR=["serif","sans-serif","monospace","cursive","fantasy","system-ui"];function Zr(r){const t=typeof r.fontSize=="number"?`${r.fontSize}px`:r.fontSize;let e=r.fontFamily;Array.isArray(r.fontFamily)||(e=r.fontFamily.split(","));for(let i=e.length-1;i>=0;i--){let n=e[i].trim();!/([\"\'])[^\'\"]+\1/.test(n)&&!sR.includes(n)&&(n=`"${n}"`),e[i]=n}return`${r.fontStyle} ${r.fontVariant} ${r.fontWeight} ${t} ${e.join(",")}`}const _b=1e5;function pr(r,t,e,i=0,n=0,s=0){var a;if(r.texture===D.WHITE&&!r.fill)return tt.shared.setValue(r.color).setAlpha((a=r.alpha)!=null?a:1).toHexa();if(r.fill){if(r.fill instanceof Xr){const o=r.fill,l=t.createPattern(o.texture.source.resource,"repeat");return Q.applyPatternTransform(l,o.transform,!1),l}else if(r.fill instanceof $t){const o=r.fill,l=o.type==="linear",u=o.textureSpace==="local";let c=1,h=1;u&&e&&(c=e.width+i,h=e.height+i);let p,f=!1;if(l){const{start:m,end:g}=o;p=t.createLinearGradient(m.x*c+n,m.y*h+s,g.x*c+n,g.y*h+s),f=Math.abs(g.x-m.x){let b=_+y.offset*m;b=Math.max(0,Math.min(1,b)),p.addColorStop(Math.floor(b*_b)/_b,tt.shared.setValue(y.color).toHex())})}}else o.colorStops.forEach(m=>{p.addColorStop(m.offset,tt.shared.setValue(m.color).toHex())});return p}}else{const o=t.createPattern(r.texture.source.resource,"repeat"),l=r.matrix.copyTo(U.shared);return l.scale(r.texture.source.pixelWidth,r.texture.source.pixelHeight),o.setTransform(l),o}return"red"}const yb=new ut;function Qr(r){let t=0;for(let e=0;e0){this._renderTaggedTextToCanvas(s,t,e,i,n);return}const{canvas:p,context:f}=n,m=Zr(t),g=s.lines,_=s.lineHeight,y=s.lineWidths,b=s.maxLineWidth,x=s.fontProperties,v=p.height;if(f.resetTransform(),f.scale(i,i),f.textBaseline=t.textBaseline,(a=t._stroke)!=null&&a.width){const C=t._stroke;f.lineWidth=C.width,f.miterLimit=C.miterLimit,f.lineJoin=C.join,f.lineCap=C.cap}f.font=m;let w,T;const E=t.dropShadow?2:1,P=((l=(o=t._stroke)==null?void 0:o.width)!=null?l:0)/2;let M=(_-x.fontSize)/2;_-x.fontSize<0&&(M=0);for(let C=0;C0&&(B=(b-y[R])/O)}(h=t._stroke)!=null&&h.width&&this._drawLetterSpacing(g[R],t,n,w+e,T+e-G,!0,B),t._fill!==void 0&&this._drawLetterSpacing(g[R],t,n,w+e,T+e-G,!1,B)}}}_renderTaggedTextToCanvas(t,e,i,n,s){var a,o,l,u,c;const{canvas:h,context:p}=s,{runsByLine:f,lineWidths:m,maxLineWidth:g,lineAscents:_,lineHeights:y,hasDropShadow:b}=t,x=h.height;p.resetTransform(),p.scale(n,n),p.textBaseline=e.textBaseline;const v=b?2:1;let w=(o=(a=e._stroke)==null?void 0:a.width)!=null?o:0;for(const P of f)for(const M of P){const C=(u=(l=M.style._stroke)==null?void 0:l.width)!=null?u:0;C>w&&(w=C)}const T=w/2,E=[];for(let P=0;P0&&(J=(g-B)/k)}const K=G+O;let X=j+i;for(let k=0;kt in r?oR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Lt=(r,t)=>{for(var e in t||(t={}))cR.call(t,e)&&vb(r,e,t[e]);if(bb)for(var e of bb(t))hR.call(t,e)&&vb(r,e,t[e]);return r},dR=(r,t)=>lR(r,uR(t));const uu=class yr extends Nt{constructor(t={}){var e;super(),this.uid=ht("textStyle"),this._tick=0,this._cachedFontString=null,pR(t),t instanceof yr&&(t=t._toObject());const i=Lt(Lt({},yr.defaultTextStyle),t);for(const n in i){const s=n;this[s]=i[n]}this._tagStyles=(e=t.tagStyles)!=null?e:void 0,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(t){this._dropShadow!==t&&(t!==null&&typeof t=="object"?this._dropShadow=this._createProxy(Lt(Lt({},yr.defaultDropShadow),t)):this._dropShadow=t?this._createProxy(Lt({},yr.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&&(typeof t=="string"?this._fontSize=parseInt(t,10):this._fontSize=t,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(t){this._fontStyle!==t&&(this._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(Lt(Lt({},kt.defaultFillStyle),t),()=>{this._fill=Xe(Lt({},this._originalFill),kt.defaultFillStyle)})),this._fill=Xe(t===0?"black":t,kt.defaultFillStyle),this.update())}get stroke(){return this._originalStroke}set stroke(t){t!==this._originalStroke&&(this._originalStroke=t,this._isFillStyle(t)&&(this._originalStroke=this._createProxy(Lt(Lt({},kt.defaultStrokeStyle),t),()=>{this._stroke=Bi(Lt({},this._originalStroke),kt.defaultStrokeStyle)})),this._stroke=Bi(t,kt.defaultStrokeStyle),this.update())}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:void 0,this.update())}update(){this._tick++,this._cachedFontString=null,this.emit("update",this)}reset(){const t=yr.defaultTextStyle;for(const e in t)this[e]=t[e]}assign(t){for(const e in t){const i=e;this[i]=t[e]}return this}get styleKey(){return`${this.uid}-${this._tick}`}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Zr(this)),this._cachedFontString}_toObject(){return{align:this.align,breakWords:this.breakWords,dropShadow:this._dropShadow?Lt({},this._dropShadow):null,fill:this._fill?Lt({},this._fill):void 0,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?Lt({},this._stroke):void 0,textBaseline:this.textBaseline,trim:this.trim,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,filters:this._filters?[...this._filters]:void 0,tagStyles:this._tagStyles?Lt({},this._tagStyles):void 0}}clone(){return new yr(this._toObject())}_getFinalPadding(){let t=0;if(this._filters)for(let e=0;e(i[n]===s||(i[n]=s,e==null||e(n,s),this.update()),!0)})}_isFillStyle(t){return(t!=null?t:null)!==null&&!(tt.isColorLike(t)||t instanceof $t||t instanceof Xr)}};uu.defaultDropShadow={alpha:1,angle:Math.PI/6,blur:0,color:"black",distance:5},uu.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 jt=uu;function pR(r){var t,e,i,n,s;const a=r;if(typeof a.dropShadow=="boolean"&&a.dropShadow){const o=jt.defaultDropShadow;r.dropShadow={alpha:(t=a.dropShadowAlpha)!=null?t:o.alpha,angle:(e=a.dropShadowAngle)!=null?e:o.angle,blur:(i=a.dropShadowBlur)!=null?i:o.blur,color:(n=a.dropShadowColor)!=null?n:o.color,distance:(s=a.dropShadowDistance)!=null?s:o.distance}}if(a.strokeThickness!==void 0){const o=a.stroke;let l={};if(tt.isColorLike(o))l.color=o;else if(o instanceof $t||o instanceof Xr)l.fill=o;else if(Object.hasOwnProperty.call(o,"color")||Object.hasOwnProperty.call(o,"fill"))l=o;else throw new Error("Invalid stroke value.");r.stroke=dR(Lt({},l),{width:a.strokeThickness})}if(Array.isArray(a.fillGradientStops)){if(!Array.isArray(a.fill)||a.fill.length===0)throw new Error("Invalid fill value. Expected an array of colors for gradient fill.");a.fill.length,a.fillGradientStops.length;const o=new $t({start:{x:0,y:0},end:{x:0,y:1},textureSpace:"local"}),l=a.fillGradientStops.slice(),u=a.fill.map(c=>tt.shared.setValue(c).toNumber());l.forEach((c,h)=>{o.addColorStop(c,u[h])}),r.fill={fill:o}}}function Gs(r,t){const{texture:e,bounds:i}=r,n=t._style._getFinalPadding();Za(i,t._anchor,e);const s=t._anchor._x*n*2,a=t._anchor._y*n*2;i.minX-=n-s,i.minY-=n-a,i.maxX-=n-s,i.maxY-=n-a}class zi{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(){this.reset()}}class xb extends zi{}class cu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Ut({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"canvasText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}validateRenderable(t){const e=this._getGpuText(t),i=t.styleKey;return e.currentKey!==i?!0:t._didTextUpdate}addRenderable(t,e){const i=this._getGpuText(t);if(t._didTextUpdate){const n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t._resolution!==n)&&this._updateGpuText(t),t._didTextUpdate=!1,Gs(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 xb;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,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{canvasText:i}=this._renderer;i.getReferenceCount(e.currentKey)>0?i.decreaseReferenceCount(e.currentKey):e.texture&&i.returnTexture(e.texture)}destroy(){this._managedTexts.destroy(),this._renderer=null}}cu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"text"};class hu{constructor(t,e){this._activeTextures={},this._renderer=t,this._retainCanvasContext=e}getTexture(t,e,i,n){var s;typeof t=="string"&&(t={text:t,style:i,resolution:e}),t.style instanceof jt||(t.style=new jt(t.style)),t.textureStyle instanceof Jt||(t.textureStyle=new Jt(t.textureStyle)),typeof t.text!="string"&&(t.text=t.text.toString());const{text:a,style:o,textureStyle:l,autoGenerateMipmaps:u}=t,c=(s=t.resolution)!=null?s:this._renderer.resolution,{frame:h,canvasAndContext:p}=ye.getCanvasAndContext({text:a,style:o,resolution:c}),f=Rn(p.canvas,h.width,h.height,c,u);if(l&&(f.source.style=l),o.trim&&(h.pad(o.padding),f.frame.copyFrom(h),f.frame.scale(1/c),f.updateUvs()),o.filters){const m=this._applyFilters(f,o.filters);return this.returnTexture(f),ye.returnCanvasAndContext(p),m}return this._renderer.texture.initSource(f._source),this._retainCanvasContext||ye.returnCanvasAndContext(p),f}returnTexture(t){const e=t.source,i=e.resource;if(this._retainCanvasContext&&i!=null&&i.getContext){const n=i.getContext("2d");n&&ye.returnCanvasAndContext({canvas:i,context:n})}e.resource=null,e.uploadMethodId="unknown",e.alphaMode="no-premultiply-alpha",vt.returnTexture(t,!0)}renderTextToCanvas(){}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,autoGenerateMipmaps:t.autoGenerateMipmaps});return this._activeTextures[e]={texture:i,usageCount:1},i}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(this.returnTexture(e.texture),this._activeTextures[t]=null))}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:0}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}_applyFilters(t,e){const i=this._renderer.renderTarget.renderTarget,n=this._renderer.filter.generateFilteredTexture({texture:t,filters:e});return this._renderer.renderTarget.bind(i,!1),n}destroy(){this._renderer=null;for(const t in this._activeTextures)this._activeTextures[t]&&this.returnTexture(this._activeTextures[t].texture);this._activeTextures=null}}class du extends hu{constructor(t){super(t,!0)}}du.extension={type:[S.CanvasSystem],name:"canvasText"};class pu extends hu{constructor(t){super(t,!1)}}pu.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"canvasText"},N.add(du),N.add(pu),N.add(cu);class Wi extends Ps{constructor(...t){var e;const i=As(t,"Text");super(i,jt),this.renderPipeId="text",i.textureStyle&&(this.textureStyle=i.textureStyle instanceof Jt?i.textureStyle:new Jt(i.textureStyle)),this.autoGenerateMipmaps=(e=i.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor;let i=0,n=0;if(this._style.trim){const{frame:s,canvasAndContext:a}=ye.getCanvasAndContext({text:this.text,style:this._style,resolution:1});ye.returnCanvasAndContext(a),i=s.width,n=s.height}else{const s=St.measureText(this._text,this._style);i=s.width,n=s.height}t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}}class Tb extends py{resolveQueueItem(t,e){return t instanceof dt?this.resolveContainerQueueItem(t,e):t instanceof ft||t instanceof D?e.push(t.source):t instanceof kt&&e.push(t),null}resolveContainerQueueItem(t,e){t instanceof pe||t instanceof Vy||t instanceof Kr?e.push(t.texture.source):t instanceof Wi?e.push(t):t instanceof hr?e.push(t.context):t instanceof Xi&&t.textures.forEach(i=>{i.source?e.push(i.source):e.push(i.texture.source)})}resolveGraphicsContextQueueItem(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:n}=i.data;return n.source}else if(i.action==="fill"){const{texture:n}=i.data.style;return n.source}return null}}class fu extends Nt{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 this.fontFamily}get pageTextures(){return this.pages}get size(){return this.fontMetrics.fontSize}get distanceFieldRange(){return this.distanceField.range}get distanceFieldType(){return this.distanceField.type}destroy(t=!1){var e;this.emit("destroy",this),this.removeAllListeners();for(const i in this.chars)(e=this.chars[i].texture)==null||e.destroy();this.chars=null,t&&(this.pages.forEach(i=>i.texture.destroy(!0)),this.pages=null)}}var fR=Object.defineProperty,Sb=Object.getOwnPropertySymbols,mR=Object.prototype.hasOwnProperty,gR=Object.prototype.propertyIsEnumerable,wb=(r,t,e)=>t in r?fR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Eb=(r,t)=>{for(var e in t||(t={}))mR.call(t,e)&&wb(r,e,t[e]);if(Sb)for(var e of Sb(t))gR.call(t,e)&&wb(r,e,t[e]);return r};const Pb=class X1 extends fu{constructor(t){var e,i,n;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 s=Eb(Eb({},X1.defaultOptions),t);this._textureSize=s.textureSize,this._mipmap=s.mipmap;const a=s.style.clone();s.overrideFill&&(a._fill.color=16777215,a._fill.alpha=1,a._fill.texture=D.WHITE,a._fill.fill=null),this.applyFillAsTint=s.overrideFill;const o=a.fontSize;a.fontSize=this.baseMeasurementFontSize;const l=Zr(a);s.overrideSize?(a._stroke&&(a._stroke.width*=this.baseRenderedFontSize/o),a.dropShadow&&(a.dropShadow.blur*=this.baseRenderedFontSize/o,a.dropShadow.distance*=this.baseRenderedFontSize/o)):a.fontSize=this.baseRenderedFontSize=o,this._style=a,this._skipKerning=(e=s.skipKerning)!=null?e:!1,this.resolution=(i=s.resolution)!=null?i:1,this._padding=(n=s.padding)!=null?n:4,s.textureStyle&&(this._textureStyle=s.textureStyle instanceof Jt?s.textureStyle:new Jt(s.textureStyle)),this.fontMetrics=St.measureFont(l),this.lineHeight=a.lineHeight||this.fontMetrics.fontSize||a.fontSize}ensureCharacters(t){var e,i,n,s;const a=St.graphemeSegmenter(t).filter(w=>!this._currentChars.includes(w)).filter((w,T,E)=>E.indexOf(w)===T);if(!a.length)return;this._currentChars=[...this._currentChars,...a];let o;this._currentPageIndex===-1?o=this._nextPage():o=this.pages[this._currentPageIndex];let{canvas:l,context:u}=o.canvasAndContext,c=o.texture.source;const h=this._style;let p=this._currentX,f=this._currentY,m=this._currentMaxCharHeight;const g=this.baseRenderedFontSize/this.baseMeasurementFontSize,_=((i=(e=h.dropShadow)==null?void 0:e.distance)!=null?i:0)+((s=(n=h._stroke)==null?void 0:n.width)!=null?s:0),y=this._padding+_;let b=!1;const x=l.width/this.resolution,v=l.height/this.resolution;for(let w=0;wx&&(f+=m,m=G,p=0,f+m>v)){c.update();const R=this._nextPage();l=R.canvasAndContext.canvas,u=R.canvasAndContext.context,c=R.texture.source,p=0,f=0,m=0}const F=u.measureText(T).width/g;if(this.chars[T]={id:T.codePointAt(0),xOffset:-(y/g),yOffset:-(y/g),xAdvance:F,kerning:{}},b){this._drawGlyph(u,E,p+y,f+y,g,h);const R=c.width*g,B=c.height*g,O=new ut(p/R*c.width,f/B*c.height,A/R*c.width,G/B*c.height);this.chars[T].texture=new D({source:c,frame:O}),p+=Math.ceil(A)}}c.update(),this._currentX=p,this._currentY=f,this._currentMaxCharHeight=m,this._skipKerning||this._applyKerning(a,u,g)}get pageTextures(){return this.pages}_applyKerning(t,e,i){const n=this._measureCache;for(let s=0;s{const T=o.width;for(let E=0;E0||!_)&&(u=!1),c.width=0,c.index=0,c.chars.length=0},x=()=>{let w=o.chars.length-1;if(i){let T=o.chars[w];for(;su(T);)o.width-=e.chars[T].xAdvance,o.spacesIndex.pop(),T=o.chars[--w]}a.width=Math.max(a.width,o.width),o={width:0,charPositions:[],chars:[],spaceWidth:0,spacesIndex:[]},u=!0,a.lines.push(o),a.height+=m},v=w=>w-p>f;for(let w=0;wt in r?vR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,gu=(r,t)=>{for(var e in t||(t={}))xR.call(t,e)&&Mb(r,e,t[e]);if(Cb)for(var e of Cb(t))TR.call(t,e)&&Mb(r,e,t[e]);return r};let Bs=0,SR=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=tb(1e3)}getFont(t,e){var i,n;let s=`${e.fontFamily}-bitmap`,a=!0;if(it.has(s)){const l=it.get(s);return(i=l.ensureCharacters)==null||i.call(l,t),l}if(e._fill.fill&&!e._stroke?(s+=e._fill.fill.styleKey,a=!1):(e._stroke||e.dropShadow)&&(s=`${e.styleKey}-bitmap`,a=!1),s+=`-${e.fontStyle}`,s+=`-${e.fontVariant}`,s+=`-${e.fontWeight}`,!it.has(s)){const l=Object.create(e);l._lineHeight=0;const u=new mu(gu({style:l,overrideFill:a,overrideSize:!0},this.defaultOptions));Bs++,Bs>50&&ue("BitmapText",`You have dynamically created ${Bs} bitmap fonts, this can be inefficient. Try pre installing your font styles using \`BitmapFont.install({name:"style1", style})\``),u.once("destroy",()=>{Bs--,it.remove(s)}),it.set(s,u)}const o=it.get(s);return(n=o.ensureCharacters)==null||n.call(o,t),o}getLayout(t,e,i=!0){const n=this.getFont(t,e),s=`${t}-${e.styleKey}-${i}`;if(this.measureCache.has(s))return this.measureCache.get(s);const a=St.graphemeSegmenter(t),o=Is(a,e,n,i);return this.measureCache.set(s,o),o}measureText(t,e,i=!0){return this.getLayout(t,e,i)}install(...t){var e,i,n,s,a;let o=t[0];typeof o=="string"&&(o={name:o,style:t[1],chars:(e=t[2])==null?void 0:e.chars,resolution:(i=t[2])==null?void 0:i.resolution,padding:(n=t[2])==null?void 0:n.padding,skipKerning:(s=t[2])==null?void 0:s.skipKerning});const l=o==null?void 0:o.name;if(!l)throw new Error("[BitmapFontManager] Property `name` is required.");o=gu(gu({},this.defaultOptions),o);const u=o.style,c=u instanceof jt?u:new jt(u),h=(a=o.dynamicFill)!=null?a:this._canUseTintForStyle(c),p=new mu({style:c,overrideFill:h,skipKerning:o.skipKerning,padding:o.padding,resolution:o.resolution,overrideSize:!1,textureStyle:o.textureStyle}),f=Ab(o.chars);return p.ensureCharacters(f.join("")),it.set(`${l}-bitmap`,p),p.once("destroy",()=>it.remove(`${l}-bitmap`)),p}uninstall(t){const e=`${t}-bitmap`,i=it.get(e);i&&i.destroy()}_canUseTintForStyle(t){return!t._stroke&&(!t.dropShadow||t.dropShadow.color===0)&&!t._fill.fill&&t._fill.color===16777215}};const Jr=new SR;class Rb extends hr{destroy(){this.context.customShader&&this.context.customShader.destroy(),super.destroy()}}class _u{constructor(t){this._renderer=t,this._managedBitmapTexts=new Ut({renderer:t,type:"renderable",priority:-2,name:"bitmapText"})}validateRenderable(t){const e=this._getGpuBitmapText(t);return this._renderer.renderPipes.graphics.validateRenderable(e)}addRenderable(t,e){const i=this._getGpuBitmapText(t);Ob(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);Ob(t,e),this._renderer.renderPipes.graphics.updateRenderable(e),e.context.customShader&&this._updateDistanceField(t)}_updateContext(t,e){const{context:i}=e,n=Jr.getFont(t.text,t._style);if(i.clear(),n.distanceField.type!=="none"){const y=this.getSdfShader();y&&(i.customShader||(i.customShader=y))}const s=St.graphemeSegmenter(t.text),a=t._style;let o=n.baseLineOffset;const l=Is(s,a,n,!0),u=a.padding,c=l.scale;let h=l.width,p=l.height+l.offsetY;a._stroke&&(h+=a._stroke.width/c,p+=a._stroke.width/c),i.translate(-t._anchor._x*h-u,-t._anchor._y*p-u).scale(c,c);const f=n.applyFillAsTint?a._fill.color:16777215;let m=n.fontMetrics.fontSize,g=n.lineHeight;a.lineHeight&&(m=a.fontSize/c,g=a.lineHeight/c);let _=(g-m)/2;_-n.baseLineOffset<0&&(_=0);for(let y=0;y, uTransformMatrix:mat3x3, @@ -1758,14 +1758,14 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { return coverage; } - `}};let yu,bu;class Db extends ee{constructor(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new U,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});yu!=null||(yu=Fr({name:"sdf-shader",bits:[Ln,Xn(t),Gb,Bb,Ur]})),bu!=null||(bu=Dr({name:"sdf-shader",bits:[Nn,jn(t),Ib,Fb,$r]})),super({glProgram:bu,gpuProgram:yu,resources:{localUniforms:e,batchSamplers:Hn(t)}})}}class vu extends gu{getSdfShader(){return new Db(this._renderer.limits.maxBatchableTextures)}}vu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"bitmapText"},X.add(_u),X.add(vu);class xu extends ws{constructor(...t){var e,i,n;const s=Ps(t,"BitmapText");(e=s.style)!=null||(s.style=s.style||{}),(n=(i=s.style).fill)!=null||(i.fill=16777215),super(s,jt),this.renderPipeId="bitmapText"}_onTouch(t){var e;this._gcLastUsed=t;for(const i in this._gpuData)(e=this._gpuData[i])==null||e._onTouch(t)}updateBounds(){const t=this._bounds,e=this._anchor,i=Jr.measureText(this.text,this._style),n=i.scale,s=i.offsetY*n;let a=i.width*n,o=i.height*n;const l=this._style._stroke;l&&(a+=l.width,o+=l.width),t.minX=-e._x*a,t.maxX=t.minX+a,t.minY=-e._y*(o+s),t.maxY=t.minY+o}set resolution(t){}get resolution(){return this._resolution}}var _R=Object.defineProperty,Ub=Object.getOwnPropertySymbols,yR=Object.prototype.hasOwnProperty,bR=Object.prototype.propertyIsEnumerable,$b=(r,t,e)=>t in r?_R(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Tu=(r,t)=>{for(var e in t||(t={}))yR.call(t,e)&&$b(r,e,t[e]);if(Ub)for(var e of Ub(t))bR.call(t,e)&&$b(r,e,t[e]);return r};function kb(r){var t;const e=r._stroke,i=r._fill,n=[`div { ${[`color: ${tt.shared.setValue(i.color).setAlpha((t=i.alpha)!=null?t:1).toHexa()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-break: ${r.breakWords?"break-word":"normal"}`,`max-width: ${r.wordWrapWidth}px`]:[],...e?[Lb(e)]:[],...r.dropShadow?[Su(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return vR(r.tagStyles,n),n.join(" ")}function Su(r){var t;const e=Tu({},r),i=tt.shared.setValue(e.color).setAlpha((t=e.alpha)!=null?t:1).toHexa(),n=Math.round(Math.cos(e.angle)*e.distance),s=Math.round(Math.sin(e.angle)*e.distance),a=`${n}px ${s}px`;return e.blur>0?`text-shadow: ${a} ${e.blur}px ${i}`:`text-shadow: ${a} ${i}`}function Lb(r){var t;const e=tt.shared.setValue(r.color).setAlpha((t=r.alpha)!=null?t:1).toHexa();return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${e}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${e}`,"paint-order: stroke"].join(";")}const Nb={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Xb={fill:r=>`color: ${tt.shared.setValue(r).toHexa()}`,breakWords:r=>`word-break: ${r?"break-all":"normal"}`,stroke:Lb,dropShadow:r=>r===!0?Su(jt.defaultDropShadow):r&&typeof r=="object"?Su(Tu(Tu({},jt.defaultDropShadow),r)):""};function vR(r,t){for(const e in r){const i=r[e],n=[];for(const s in i)Xb[s]?n.push(Xb[s](i[s])):Nb[s]&&n.push(Nb[s].replace("{{VALUE}}",i[s]));t.push(`${e} { ${n.join(";")} }`)}}var xR=Object.defineProperty,jb=Object.getOwnPropertySymbols,TR=Object.prototype.hasOwnProperty,SR=Object.prototype.propertyIsEnumerable,Hb=(r,t,e)=>t in r?xR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zb=(r,t)=>{for(var e in t||(t={}))TR.call(t,e)&&Hb(r,e,t[e]);if(jb)for(var e of jb(t))SR.call(t,e)&&Hb(r,e,t[e]);return r};class Is extends jt{constructor(t={}){var e,i;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(i=t.tagStyles)!=null?i:{}}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:{},this.update())}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new Is({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?zb({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:zb({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=kb(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}const Wb="http://www.w3.org/2000/svg",Vb="http://www.w3.org/1999/xhtml";class wu{constructor(){this.svgRoot=document.createElementNS(Wb,"svg"),this.foreignObject=document.createElementNS(Wb,"foreignObject"),this.domElement=document.createElementNS(Vb,"div"),this.styleElement=document.createElementNS(Vb,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:n}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(n),this.image=H.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 Yb;function Pu(r,t,e,i){i||(i=Yb||(Yb=new wu));const{domElement:n,styleElement:s,svgRoot:a}=i;n.innerHTML=`
${r}
`,n.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(s.textContent=e),document.body.appendChild(a);let o=n.scrollWidth,l=n.scrollHeight;if(a.remove(),t.dropShadow){const{distance:c,angle:h,blur:p}=t.dropShadow,f=Math.abs(Math.round(Math.cos(h)*c)),m=Math.abs(Math.round(Math.sin(h)*c));o+=f+p,l+=m+p}const u=t.padding*2;return{width:o-u,height:l-u}}class Kb extends zi{constructor(){super(...arguments),this.generatingTexture=!1,this.currentKey="--"}destroy(){this.texturePromise=null,this.generatingTexture=!1,this.currentKey="--",super.destroy()}}class Eu{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Ut({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"htmlText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}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 n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==n)&&this._updateGpuText(t).catch(s=>{console.error(s)}),t._didTextUpdate=!1,Rs(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 n=this._renderer.htmlText.getTexturePromise(t);i&&(n=n.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=n,e.currentKey=t.styleKey,e.texture=await n;const s=t.renderGroup||t.parentRenderGroup;s&&(s.structureDidChange=!0),e.generatingTexture=!1,Rs(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Kb;return e.renderable=t,e.transform=t.groupTransform,e.texture=D.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,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{htmlText:i}=this._renderer;i.getReferenceCount(e.currentKey)===null?i.returnTexturePromise(e.texturePromise):i.decreaseReferenceCount(e.currentKey)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Eu.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"htmlText"};function Au(){const{userAgent:r}=H.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}function qb(r,t){const e=t.fontFamily,i=[],n={},s=/font-family:([^;"\s]+)/g,a=r.match(s);function o(l){n[l]||(i.push(l),n[l]=!0)}if(Array.isArray(e))for(let l=0;l{const u=l.split(":")[1].trim();o(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;o(u)}return i}async function Zb(r){const t=await(await H.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,n)=>{e.onloadend=()=>i(e.result),e.onerror=n,e.readAsDataURL(t)})}async function Qb(r,t){const e=await Zb(t);return`@font-face { + `}};let bu,vu;class Db extends ee{constructor(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new U,type:"mat3x3"},uDistance:{value:4,type:"f32"},uRound:{value:0,type:"f32"}});bu!=null||(bu=Fr({name:"sdf-shader",bits:[Xn,Hn(t),Gb,Bb,Ur]})),vu!=null||(vu=Dr({name:"sdf-shader",bits:[jn,zn(t),Ib,Fb,$r]})),super({glProgram:vu,gpuProgram:bu,resources:{localUniforms:e,batchSamplers:Wn(t)}})}}class xu extends _u{getSdfShader(){return new Db(this._renderer.limits.maxBatchableTextures)}}xu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"bitmapText"},N.add(yu),N.add(xu);class Tu extends Ps{constructor(...t){var e,i,n;const s=As(t,"BitmapText");(e=s.style)!=null||(s.style=s.style||{}),(n=(i=s.style).fill)!=null||(i.fill=16777215),super(s,jt),this.renderPipeId="bitmapText"}_onTouch(t){var e;this._gcLastUsed=t;for(const i in this._gpuData)(e=this._gpuData[i])==null||e._onTouch(t)}updateBounds(){const t=this._bounds,e=this._anchor,i=Jr.measureText(this.text,this._style),n=i.scale,s=i.offsetY*n;let a=i.width*n,o=i.height*n;const l=this._style._stroke;l&&(a+=l.width,o+=l.width),t.minX=-e._x*a,t.maxX=t.minX+a,t.minY=-e._y*(o+s),t.maxY=t.minY+o}set resolution(t){}get resolution(){return this._resolution}}var wR=Object.defineProperty,Ub=Object.getOwnPropertySymbols,ER=Object.prototype.hasOwnProperty,PR=Object.prototype.propertyIsEnumerable,$b=(r,t,e)=>t in r?wR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Su=(r,t)=>{for(var e in t||(t={}))ER.call(t,e)&&$b(r,e,t[e]);if(Ub)for(var e of Ub(t))PR.call(t,e)&&$b(r,e,t[e]);return r};function kb(r){var t;const e=r._stroke,i=r._fill,n=[`div { ${[`color: ${tt.shared.setValue(i.color).setAlpha((t=i.alpha)!=null?t:1).toHexa()}`,`font-size: ${r.fontSize}px`,`font-family: ${r.fontFamily}`,`font-weight: ${r.fontWeight}`,`font-style: ${r.fontStyle}`,`font-variant: ${r.fontVariant}`,`letter-spacing: ${r.letterSpacing}px`,`text-align: ${r.align}`,`padding: ${r.padding}px`,`white-space: ${r.whiteSpace==="pre"&&r.wordWrap?"pre-wrap":r.whiteSpace}`,...r.lineHeight?[`line-height: ${r.lineHeight}px`]:[],...r.wordWrap?[`word-break: ${r.breakWords?"break-word":"normal"}`,`max-width: ${r.wordWrapWidth}px`]:[],...e?[Lb(e)]:[],...r.dropShadow?[wu(r.dropShadow)]:[],...r.cssOverrides].join(";")} }`];return AR(r.tagStyles,n),n.join(" ")}function wu(r){var t;const e=Su({},r),i=tt.shared.setValue(e.color).setAlpha((t=e.alpha)!=null?t:1).toHexa(),n=Math.round(Math.cos(e.angle)*e.distance),s=Math.round(Math.sin(e.angle)*e.distance),a=`${n}px ${s}px`;return e.blur>0?`text-shadow: ${a} ${e.blur}px ${i}`:`text-shadow: ${a} ${i}`}function Lb(r){var t;const e=tt.shared.setValue(r.color).setAlpha((t=r.alpha)!=null?t:1).toHexa();return[`-webkit-text-stroke-width: ${r.width}px`,`-webkit-text-stroke-color: ${e}`,`text-stroke-width: ${r.width}px`,`text-stroke-color: ${e}`,"paint-order: stroke"].join(";")}const Nb={fontSize:"font-size: {{VALUE}}px",fontFamily:"font-family: {{VALUE}}",fontWeight:"font-weight: {{VALUE}}",fontStyle:"font-style: {{VALUE}}",fontVariant:"font-variant: {{VALUE}}",letterSpacing:"letter-spacing: {{VALUE}}px",align:"text-align: {{VALUE}}",padding:"padding: {{VALUE}}px",whiteSpace:"white-space: {{VALUE}}",lineHeight:"line-height: {{VALUE}}px",wordWrapWidth:"max-width: {{VALUE}}px"},Xb={fill:r=>`color: ${tt.shared.setValue(r).toHexa()}`,breakWords:r=>`word-break: ${r?"break-all":"normal"}`,stroke:Lb,dropShadow:r=>r===!0?wu(jt.defaultDropShadow):r&&typeof r=="object"?wu(Su(Su({},jt.defaultDropShadow),r)):""};function AR(r,t){for(const e in r){const i=r[e],n=[];for(const s in i)Xb[s]?n.push(Xb[s](i[s])):Nb[s]&&n.push(Nb[s].replace("{{VALUE}}",i[s]));t.push(`${e} { ${n.join(";")} }`)}}var CR=Object.defineProperty,jb=Object.getOwnPropertySymbols,MR=Object.prototype.hasOwnProperty,RR=Object.prototype.propertyIsEnumerable,Hb=(r,t,e)=>t in r?CR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zb=(r,t)=>{for(var e in t||(t={}))MR.call(t,e)&&Hb(r,e,t[e]);if(jb)for(var e of jb(t))RR.call(t,e)&&Hb(r,e,t[e]);return r};class Fs extends jt{constructor(t={}){var e,i;super(t),this._cssOverrides=[],this.cssOverrides=(e=t.cssOverrides)!=null?e:[],this.tagStyles=(i=t.tagStyles)!=null?i:{}}get tagStyles(){return this._tagStyles}set tagStyles(t){this._tagStyles!==t&&(this._tagStyles=t!=null?t:{},this.update())}set cssOverrides(t){this._cssOverrides=t instanceof Array?t:[t],this.update()}get cssOverrides(){return this._cssOverrides}update(){this._cssStyle=null,super.update()}clone(){return new Fs({align:this.align,breakWords:this.breakWords,dropShadow:this.dropShadow?zb({},this.dropShadow):null,fill:this._fill,fontFamily:this.fontFamily,fontSize:this.fontSize,fontStyle:this.fontStyle,fontVariant:this.fontVariant,fontWeight:this.fontWeight,letterSpacing:this.letterSpacing,lineHeight:this.lineHeight,padding:this.padding,stroke:this._stroke,whiteSpace:this.whiteSpace,wordWrap:this.wordWrap,wordWrapWidth:this.wordWrapWidth,cssOverrides:this.cssOverrides,tagStyles:zb({},this.tagStyles)})}get cssStyle(){return this._cssStyle||(this._cssStyle=kb(this)),this._cssStyle}addOverride(...t){const e=t.filter(i=>!this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides.push(...e),this.update())}removeOverride(...t){const e=t.filter(i=>this.cssOverrides.includes(i));e.length>0&&(this.cssOverrides=this.cssOverrides.filter(i=>!e.includes(i)),this.update())}set fill(t){super.fill=t}set stroke(t){super.stroke=t}}const Wb="http://www.w3.org/2000/svg",Vb="http://www.w3.org/1999/xhtml";class Eu{constructor(){this.svgRoot=document.createElementNS(Wb,"svg"),this.foreignObject=document.createElementNS(Wb,"foreignObject"),this.domElement=document.createElementNS(Vb,"div"),this.styleElement=document.createElementNS(Vb,"style");const{foreignObject:t,svgRoot:e,styleElement:i,domElement:n}=this;t.setAttribute("width","10000"),t.setAttribute("height","10000"),t.style.overflow="hidden",e.appendChild(t),t.appendChild(i),t.appendChild(n),this.image=H.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 Yb;function Pu(r,t,e,i){i||(i=Yb||(Yb=new Eu));const{domElement:n,styleElement:s,svgRoot:a}=i;n.innerHTML=`
${r}
`,n.setAttribute("style","transform-origin: top left; display: inline-block"),e&&(s.textContent=e),document.body.appendChild(a);let o=n.scrollWidth,l=n.scrollHeight;if(a.remove(),t.dropShadow){const{distance:c,angle:h,blur:p}=t.dropShadow,f=Math.abs(Math.round(Math.cos(h)*c)),m=Math.abs(Math.round(Math.sin(h)*c));o+=f+p,l+=m+p}const u=t.padding*2;return{width:o-u,height:l-u}}class Kb extends zi{constructor(){super(...arguments),this.generatingTexture=!1,this.currentKey="--"}destroy(){this.texturePromise=null,this.generatingTexture=!1,this.currentKey="--",super.destroy()}}class Au{constructor(t){this._renderer=t,t.runners.resolutionChange.add(this),this._managedTexts=new Ut({renderer:t,type:"renderable",onUnload:this.onTextUnload.bind(this),name:"htmlText"})}resolutionChange(){for(const t in this._managedTexts.items){const e=this._managedTexts.items[t];e!=null&&e._autoResolution&&e.onViewUpdate()}}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 n=t._autoResolution?this._renderer.resolution:t.resolution;(i.currentKey!==t.styleKey||t.resolution!==n)&&this._updateGpuText(t).catch(s=>{console.error(s)}),t._didTextUpdate=!1,Gs(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 n=this._renderer.htmlText.getTexturePromise(t);i&&(n=n.finally(()=>{this._renderer.htmlText.decreaseReferenceCount(e.currentKey),this._renderer.htmlText.returnTexturePromise(i)})),e.texturePromise=n,e.currentKey=t.styleKey,e.texture=await n;const s=t.renderGroup||t.parentRenderGroup;s&&(s.structureDidChange=!0),e.generatingTexture=!1,Gs(e,t)}_getGpuText(t){return t._gpuData[this._renderer.uid]||this.initGpuText(t)}initGpuText(t){const e=new Kb;return e.renderable=t,e.transform=t.groupTransform,e.texture=D.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,this._managedTexts.add(t),e}onTextUnload(t){const e=t._gpuData[this._renderer.uid];if(!e)return;const{htmlText:i}=this._renderer;i.getReferenceCount(e.currentKey)===null?i.returnTexturePromise(e.texturePromise):i.decreaseReferenceCount(e.currentKey)}destroy(){this._managedTexts.destroy(),this._renderer=null}}Au.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"htmlText"};function Cu(){const{userAgent:r}=H.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}function qb(r,t){const e=t.fontFamily,i=[],n={},s=/font-family:([^;"\s]+)/g,a=r.match(s);function o(l){n[l]||(i.push(l),n[l]=!0)}if(Array.isArray(e))for(let l=0;l{const u=l.split(":")[1].trim();o(u)});for(const l in t.tagStyles){const u=t.tagStyles[l].fontFamily;o(u)}return i}async function Zb(r){const t=await(await H.get().fetch(r)).blob(),e=new FileReader;return await new Promise((i,n)=>{e.onloadend=()=>i(e.result),e.onerror=n,e.readAsDataURL(t)})}async function Qb(r,t){const e=await Zb(t);return`@font-face { font-family: "${r.fontFamily}"; font-weight: ${r.fontWeight}; font-style: ${r.fontStyle}; src: url('${e}'); - }`}const Bs=new Map;async function Jb(r){const t=r.filter(e=>it.has(`${e}-and-url`)).map(e=>{if(!Bs.has(e)){const{entries:i}=it.get(`${e}-and-url`),n=[];i.forEach(s=>{const a=s.url,o=s.faces.map(l=>({weight:l.weight,style:l.style}));n.push(...o.map(l=>Qb({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},a)))}),Bs.set(e,Promise.all(n).then(s=>s.join(` -`)))}return Bs.get(e)});return(await Promise.all(t)).join(` -`)}function tv(r,t,e,i,n){const{domElement:s,styleElement:a,svgRoot:o}=n;s.innerHTML=`
${r}
`,s.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),a.textContent=i;const{width:l,height:u}=n.image;return o.setAttribute("width",l.toString()),o.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(o)}function ev(r,t){const e=me.getOptimalCanvasAndContext(r.width,r.height,t),{context:i}=e;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),e}function rv(r,t,e){return new Promise(async i=>{e&&await new Promise(n=>setTimeout(n,100)),r.onload=()=>{i()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}class Cu{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===It.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(n=>(this._activeTextures[e].texture=n,n));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(i=>{e.texture=i,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:n,textureStyle:s,autoGenerateMipmaps:a}=t,o=Et.get(wu),l=qb(e,i),u=await Jb(l),c=Pu(e,i,u,o),h=Math.ceil(Math.ceil(Math.max(1,c.width)+i.padding*2)*n),p=Math.ceil(Math.ceil(Math.max(1,c.height)+i.padding*2)*n),f=o.image,m=2;f.width=(h|0)+m,f.height=(p|0)+m;const g=tv(e,i,n,u,o);await rv(f,g,Au()&&l.length>0);const _=f;let y;this._createCanvas&&(y=ev(f,n));const b=Cn(y?y.canvas:_,f.width-m,f.height-m,n,a);return s&&(b.source.style=s),this._createCanvas&&(this._renderer.texture.initSource(b.source),me.returnCanvasAndContext(y)),Et.return(o),b}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){vt.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}}Cu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"htmlText"},X.add(Cu),X.add(Eu);class iv extends ws{constructor(...t){var e;const i=Ps(t,"HtmlText");super(i,Is),this.renderPipeId="htmlText",i.textureStyle&&(this.textureStyle=i.textureStyle instanceof Jt?i.textureStyle:new Jt(i.textureStyle)),this.autoGenerateMipmaps=(e=i.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor,i=Pu(this.text,this._style),{width:n,height:s}=i;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*s,t.maxY=t.minY+s}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," "))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class nv extends Tb{uploadQueueItem(t){t instanceof ft?this.uploadTextureSource(t):t instanceof Wi?this.uploadText(t):t instanceof iv?this.uploadHTMLText(t):t instanceof xu?this.uploadBitmapText(t):t instanceof kt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:n}=i.data;this.uploadTextureSource(n.source)}else if(i.action==="fill"){const{texture:n}=i.data.style;this.uploadTextureSource(n.source)}return null}}class sv extends nv{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}sv.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"prepare"};const Mu=class br{static _getPatternRepeat(t,e){const i=t&&t!=="clamp-to-edge",n=e&&e!=="clamp-to-edge";return i&&n?"repeat":i?"repeat-x":n?"repeat-y":"no-repeat"}start(t,e,i){}execute(t,e){var i,n,s,a,o,l,u,c,h,p;const f=e.elements;if(!f||!f.length)return;const m=t.renderer,g=m.canvasContext,_=g.activeContext;for(let y=0;y>>24&255)/255,G=(C>>>24&255)/255,F=(a=(s=m.filter)==null?void 0:s.alphaMultiplier)!=null?a:1,R=A*G*F;if(R<=0)continue;_.globalAlpha=R;const B=M&16777215,O=C&16777215,I=xe(Oe(O,B)),L=v.frame,j=(o=T.addressModeU)!=null?o:T.addressMode,J=(l=T.addressModeV)!=null?l:T.addressMode,K=br._getPatternRepeat(j,J),N=(c=(u=v.source._resolution)!=null?u:v.source.resolution)!=null?c:1,k=(p=(h=x.renderable)==null?void 0:h.renderGroup)==null?void 0:p.isCachedAsTexture,$=L.x*N,z=L.y*N,rt=L.width*N,_t=L.height*N,et=x.bounds,st=m.renderTarget.renderTarget.isRoot,nt=et.minX,ot=et.minY,gt=et.maxX-et.minX,yt=et.maxY-et.minY,pt=v.rotate,Y=v.uvs,Rt=Math.min(Y.x0,Y.x1,Y.x2,Y.x3,Y.y0,Y.y1,Y.y2,Y.y3),Ct=Math.max(Y.x0,Y.x1,Y.x2,Y.x3,Y.y0,Y.y1,Y.y2,Y.y3),ce=K!=="no-repeat"&&(Rt<0||Ct>1),mh=pt&&!(!ce&&(I!==16777215||pt));mh?(br._tempPatternMatrix.copyFrom(x.transform),W.matrixAppendRotationInv(br._tempPatternMatrix,pt,nt,ot,gt,yt),g.setContextTransform(br._tempPatternMatrix,x.roundPixels===1,void 0,k&&st)):g.setContextTransform(x.transform,x.roundPixels===1,void 0,k&&st);const ya=mh?0:nt,ba=mh?0:ot,gh=gt,_h=yt;if(ce){let _r=w;const ii=I!==16777215&&!pt,PB=L.width<=v.source.width&&L.height<=v.source.height;ii&&PB&&(_r=Q.getTintedCanvas({texture:v},I));const yh=_.createPattern(_r,K);if(!yh)continue;const m1=gh,g1=_h;if(m1===0||g1===0)continue;const _1=1/m1,y1=1/g1,b1=(Y.x1-Y.x0)*_1,v1=(Y.y1-Y.y0)*_1,x1=(Y.x3-Y.x0)*y1,T1=(Y.y3-Y.y0)*y1,EB=Y.x0-b1*ya-x1*ba,AB=Y.y0-v1*ya-T1*ba,bh=v.source.pixelWidth,vh=v.source.pixelHeight;br._tempPatternMatrix.set(b1*bh,v1*vh,x1*bh,T1*vh,EB*bh,AB*vh),Q.applyPatternTransform(yh,br._tempPatternMatrix),_.fillStyle=yh,_.fillRect(ya,ba,gh,_h)}else{const _r=I!==16777215||pt?Q.getTintedCanvas({texture:v},I):w,ii=_r!==w;_.drawImage(_r,ii?0:$,ii?0:z,ii?_r.width:rt,ii?_r.height:_t,ya,ba,gh,_h)}}}};Mu._tempPatternMatrix=new U,Mu.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let av=Mu;class Ru{constructor(){this._tempState=Vt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,s=this._didUploadHash[i.uid];n.shader.bind(i,s),s||(this._didUploadHash[i.uid]=!0),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const n=e.textures.textures;for(let s=0;si.trim()).filter(i=>i.length);let e="";return t.map(i=>{let n=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),n=e+i),n}).join(` + }`}const Ds=new Map;async function Jb(r){const t=r.filter(e=>it.has(`${e}-and-url`)).map(e=>{if(!Ds.has(e)){const{entries:i}=it.get(`${e}-and-url`),n=[];i.forEach(s=>{const a=s.url,o=s.faces.map(l=>({weight:l.weight,style:l.style}));n.push(...o.map(l=>Qb({fontWeight:l.weight,fontStyle:l.style,fontFamily:e},a)))}),Ds.set(e,Promise.all(n).then(s=>s.join(` +`)))}return Ds.get(e)});return(await Promise.all(t)).join(` +`)}function tv(r,t,e,i,n){const{domElement:s,styleElement:a,svgRoot:o}=n;s.innerHTML=`
${r}
`,s.setAttribute("style",`transform: scale(${e});transform-origin: top left; display: inline-block`),a.textContent=i;const{width:l,height:u}=n.image;return o.setAttribute("width",l.toString()),o.setAttribute("height",u.toString()),new XMLSerializer().serializeToString(o)}function ev(r,t){const e=me.getOptimalCanvasAndContext(r.width,r.height,t),{context:i}=e;return i.clearRect(0,0,r.width,r.height),i.drawImage(r,0,0),e}function rv(r,t,e){return new Promise(async i=>{e&&await new Promise(n=>setTimeout(n,100)),r.onload=()=>{i()},r.src=`data:image/svg+xml;charset=utf8,${encodeURIComponent(t)}`,r.crossOrigin="anonymous"})}class Mu{constructor(t){this._activeTextures={},this._renderer=t,this._createCanvas=t.type===It.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(n=>(this._activeTextures[e].texture=n,n));return this._activeTextures[e]={texture:null,promise:i,usageCount:1},i}getReferenceCount(t){var e,i;return(i=(e=this._activeTextures[t])==null?void 0:e.usageCount)!=null?i:null}_increaseReferenceCount(t){this._activeTextures[t].usageCount++}decreaseReferenceCount(t){const e=this._activeTextures[t];e&&(e.usageCount--,e.usageCount===0&&(e.texture?this._cleanUp(e.texture):e.promise.then(i=>{e.texture=i,this._cleanUp(e.texture)}).catch(()=>{}),this._activeTextures[t]=null))}getTexturePromise(t){return this._buildTexturePromise(t)}async _buildTexturePromise(t){const{text:e,style:i,resolution:n,textureStyle:s,autoGenerateMipmaps:a}=t,o=Pt.get(Eu),l=qb(e,i),u=await Jb(l),c=Pu(e,i,u,o),h=Math.ceil(Math.ceil(Math.max(1,c.width)+i.padding*2)*n),p=Math.ceil(Math.ceil(Math.max(1,c.height)+i.padding*2)*n),f=o.image,m=2;f.width=(h|0)+m,f.height=(p|0)+m;const g=tv(e,i,n,u,o);await rv(f,g,Cu()&&l.length>0);const _=f;let y;this._createCanvas&&(y=ev(f,n));const b=Rn(y?y.canvas:_,f.width-m,f.height-m,n,a);return s&&(b.source.style=s),this._createCanvas&&(this._renderer.texture.initSource(b.source),me.returnCanvasAndContext(y)),Pt.return(o),b}returnTexturePromise(t){t.then(e=>{this._cleanUp(e)}).catch(()=>{})}_cleanUp(t){vt.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}}Mu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"htmlText"},N.add(Mu),N.add(Au);class iv extends Ps{constructor(...t){var e;const i=As(t,"HtmlText");super(i,Fs),this.renderPipeId="htmlText",i.textureStyle&&(this.textureStyle=i.textureStyle instanceof Jt?i.textureStyle:new Jt(i.textureStyle)),this.autoGenerateMipmaps=(e=i.autoGenerateMipmaps)!=null?e:ft.defaultOptions.autoGenerateMipmaps}updateBounds(){const t=this._bounds,e=this._anchor,i=Pu(this.text,this._style),{width:n,height:s}=i;t.minX=-e._x*n,t.maxX=t.minX+n,t.minY=-e._y*s,t.maxY=t.minY+s}get text(){return this._text}set text(t){const e=this._sanitiseText(t.toString());super.text=e}_sanitiseText(t){return this._removeInvalidHtmlTags(t.replace(/
/gi,"
").replace(/
/gi,"
").replace(/ /gi," "))}_removeInvalidHtmlTags(t){const e=/<[^>]*?(?=<|$)/g;return t.replace(e,"")}}class nv extends Tb{uploadQueueItem(t){t instanceof ft?this.uploadTextureSource(t):t instanceof Wi?this.uploadText(t):t instanceof iv?this.uploadHTMLText(t):t instanceof Tu?this.uploadBitmapText(t):t instanceof kt&&this.uploadGraphicsContext(t)}uploadTextureSource(t){this.renderer.texture.initSource(t)}uploadText(t){this.renderer.renderPipes.text.initGpuText(t)}uploadBitmapText(t){this.renderer.renderPipes.bitmapText.initGpuText(t)}uploadHTMLText(t){this.renderer.renderPipes.htmlText.initGpuText(t)}uploadGraphicsContext(t){this.renderer.graphicsContext.getGpuContext(t);const{instructions:e}=t;for(const i of e)if(i.action==="texture"){const{image:n}=i.data;this.uploadTextureSource(n.source)}else if(i.action==="fill"){const{texture:n}=i.data.style;this.uploadTextureSource(n.source)}return null}}class sv extends nv{destroy(){super.destroy(),clearTimeout(this.timeout),this.renderer=null,this.queue=null,this.resolves=null}}sv.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"prepare"};const Ru=class br{static _getPatternRepeat(t,e){const i=t&&t!=="clamp-to-edge",n=e&&e!=="clamp-to-edge";return i&&n?"repeat":i?"repeat-x":n?"repeat-y":"no-repeat"}start(t,e,i){}execute(t,e){var i,n,s,a,o,l,u,c,h,p;const f=e.elements;if(!f||!f.length)return;const m=t.renderer,g=m.canvasContext,_=g.activeContext;for(let y=0;y>>24&255)/255,G=(C>>>24&255)/255,F=(a=(s=m.filter)==null?void 0:s.alphaMultiplier)!=null?a:1,R=A*G*F;if(R<=0)continue;_.globalAlpha=R;const B=M&16777215,O=C&16777215,I=xe(Oe(O,B)),L=v.frame,j=(o=T.addressModeU)!=null?o:T.addressMode,J=(l=T.addressModeV)!=null?l:T.addressMode,K=br._getPatternRepeat(j,J),X=(c=(u=v.source._resolution)!=null?u:v.source.resolution)!=null?c:1,k=(p=(h=x.renderable)==null?void 0:h.renderGroup)==null?void 0:p.isCachedAsTexture,$=L.x*X,z=L.y*X,rt=L.width*X,_t=L.height*X,et=x.bounds,st=m.renderTarget.renderTarget.isRoot,nt=et.minX,ot=et.minY,gt=et.maxX-et.minX,yt=et.maxY-et.minY,pt=v.rotate,Y=v.uvs,Rt=Math.min(Y.x0,Y.x1,Y.x2,Y.x3,Y.y0,Y.y1,Y.y2,Y.y3),Ct=Math.max(Y.x0,Y.x1,Y.x2,Y.x3,Y.y0,Y.y1,Y.y2,Y.y3),ce=K!=="no-repeat"&&(Rt<0||Ct>1),va=pt&&!(!ce&&(I!==16777215||pt));va?(br._tempPatternMatrix.copyFrom(x.transform),W.matrixAppendRotationInv(br._tempPatternMatrix,pt,nt,ot,gt,yt),g.setContextTransform(br._tempPatternMatrix,x.roundPixels===1,void 0,k&&st)):g.setContextTransform(x.transform,x.roundPixels===1,void 0,k&&st);const yh=gt,bh=yt;let tn=va?0:nt,en=va?0:ot;if(!va&&x.roundPixels===1&&(tn|=0,en|=0),ce){let _r=w;const ii=I!==16777215&&!pt,RB=L.width<=v.source.width&&L.height<=v.source.height;ii&&RB&&(_r=Q.getTintedCanvas({texture:v},I));const vh=_.createPattern(_r,K);if(!vh)continue;const _1=yh,y1=bh;if(_1===0||y1===0)continue;const b1=1/_1,v1=1/y1,x1=(Y.x1-Y.x0)*b1,T1=(Y.y1-Y.y0)*b1,S1=(Y.x3-Y.x0)*v1,w1=(Y.y3-Y.y0)*v1,OB=Y.x0-x1*tn-S1*en,GB=Y.y0-T1*tn-w1*en,xh=v.source.pixelWidth,Th=v.source.pixelHeight;br._tempPatternMatrix.set(x1*xh,T1*Th,S1*xh,w1*Th,OB*xh,GB*Th),Q.applyPatternTransform(vh,br._tempPatternMatrix),_.fillStyle=vh,_.fillRect(tn,en,yh,bh)}else{const _r=I!==16777215||pt?Q.getTintedCanvas({texture:v},I):w,ii=_r!==w;_.drawImage(_r,ii?0:$,ii?0:z,ii?_r.width:rt,ii?_r.height:_t,tn,en,yh,bh)}}}};Ru._tempPatternMatrix=new U,Ru.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let av=Ru;class Ou{constructor(){this._tempState=Vt.for2d(),this._didUploadHash={}}init(t){t.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(t,e,i){const n=t.renderer,s=this._didUploadHash[i.uid];n.shader.bind(i,s),s||(this._didUploadHash[i.uid]=!0),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(e,i.glProgram)}execute(t,e){const i=t.renderer;this._tempState.blendMode=e.blendMode,i.state.set(this._tempState);const n=e.textures.textures;for(let s=0;si.trim()).filter(i=>i.length);let e="";return t.map(i=>{let n=e+i;return i==="{"?e+=" ":i==="}"&&(e=e.substr(0,e.length-4),n=e+i),n}).join(` `)}const ov={name:"texture-bit",vertex:{header:` struct TextureUniforms { @@ -1792,9 +1792,9 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { `,main:` outColor = texture(uTexture, vUV); - `}},AR=new Mt;let CR=class extends oi{constructor(){super(),this.filters=[new hy({sprite:new pe(D.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}get channel(){return this.filters[0].channel}set channel(t){this.filters[0].channel=t}};class Us{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){var n;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.channel=(n=e._maskOptions.channel)!=null?n:"red",t.renderMaskToTexture){const a=t.mask;a.includeInBuild=!0,a.collectRenderables(i,s,null),a.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(t.action==="pushMaskBegin"){const n=Et.get(CR);if(n.inverse=t.inverse,n.channel=t.mask.channel,i){t.mask.mask.measurable=!0;const s=li(t.mask.mask,!0,AR);t.mask.mask.measurable=!1,s.ceil();const a=e.renderTarget.renderTarget.colorTexture.source,o=vt.getOptimalTexture(s.width,s.height,a._resolution,a.antialias);e.renderTarget.push(o,!0),e.globalUniforms.push({offset:s,worldColor:4294967295});const l=n.sprite;l.texture=o,l.worldTransform.tx=s.minX,l.worldTransform.ty=s.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:o})}else n.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const n=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===It.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:n.maskedContainer,filterEffect:n.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const n=this._activeMaskStage.pop();i&&vt.returnTexture(n.filterTexture),Et.return(n.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}Us.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"alphaMask"};class Iu{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}}Iu.extension={type:[S.CanvasPipes],name:"colorMask"};class Bu{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Bu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"colorMask"};class MR{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){xn(this.mask,t,e)}addLocalBounds(t,e){Tn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}destroy(){this.reset()}}function RR(r,t,e,i,n,s){s=Math.max(0,Math.min(s,Math.min(i,n)/2)),r.moveTo(t+s,e),r.lineTo(t+i-s,e),r.quadraticCurveTo(t+i,e,t+i,e+s),r.lineTo(t+i,e+n-s),r.quadraticCurveTo(t+i,e+n,t+i-s,e+n),r.lineTo(t+s,e+n),r.quadraticCurveTo(t,e+n,t,e+n-s),r.lineTo(t,e+s),r.quadraticCurveTo(t,e,t+s,e)}function uv(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;RR(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.moveTo(e.x+e.radius,e.y),r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?(r.moveTo(e.x+e.halfWidth,e.y),r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}default:{const e=t,i=e.points;if(!(i!=null&&i.length))break;r.moveTo(i[0],i[1]);for(let n=2;n>>24&255)/255,T=(v>>>24&255)/255,P=(a=(s=g.filter)==null?void 0:s.alphaMultiplier)!=null?a:1,E=w*T*P;if(E<=0)return;const M=x&16777215,C=v&16777215,A=xe(Oe(C,M)),G=g._roundPixels|e._roundPixels;y.save(),_.setContextTransform(b,G===1),_.setBlendMode(e.groupBlendMode);const F=e.context.instructions;for(let R=0;R{if(!r.name)throw new Error("BlendMode extension must have a name property");Vi[r.name]=r.ref},r=>{delete Vi[r.name]});class Hs{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){var e;this._blendModeStack.pop();const i=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,i,t)}setBlendMode(t,e,i){var n;const s=t instanceof pn;if(this._activeBlendMode===e){this._isAdvanced&&t&&!s&&((n=this._renderableList)==null||n.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!Vi[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!Vi[i])return;const n=this._ensureFilterEffect(i),s=t instanceof pn,a={renderPipeId:"filter",action:"pushFilter",filterEffect:n,renderables:s?null:[t],container:s?t.root:null,canBundle:!1};this._renderableList=a.renderables,e.add(a)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new oi,e.filters=[new Vi[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}}Hs.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"blendMode"};function zs(r,t){t||(t=0);for(let e=t;e1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function Xu(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const n=r.parent;if(n&&!n.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,n.relativeGroupTransform),e&hv&&pv(r,n,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&hv&&pv(r,XR,e)),!r.renderGroup){const s=r.children,a=s.length;for(let u=0;u1?1:i,r.groupAlpha=i,r.groupColorAlpha=r.groupColor+((i*255|0)<<24)}e&mn&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&xr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function fv(r,t){const{list:e}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;n=0;s--)this._updateCachedRenderGroups(t.renderGroupChildren[s],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const s=t.root.getLocalBounds(),a=this._renderer,o=t.textureOptions.resolution||a.view.resolution,l=(i=t.textureOptions.antialias)!=null?i:a.view.antialias,u=(n=t.textureOptions.scaleMode)!=null?n:"linear",c=t.texture;s.ceil(),t.texture&&vt.returnTexture(t.texture,!0);const h=vt.getOptimalTexture(s.width,s.height,o,l);h._source.style=new Jt({scaleMode:u}),t.texture=h,t._textureBounds||(t._textureBounds=new Mt),t._textureBounds.copyFrom(s),c!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(vt.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?zs(t.childrenRenderablesToUpdate.list,0):fv(t,i),Nu(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 n=0;nt in r?HR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_v=(r,t)=>{for(var e in t||(t={}))zR.call(t,e)&&gv(r,e,t[e]);if(mv)for(var e of mv(t))WR.call(t,e)&&gv(r,e,t[e]);return r};const Hu=class X1{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new tt(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=_v(_v({},X1.defaultOptions),t),this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};Hu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"background",priority:0},Hu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let yv=Hu;var VR=Object.defineProperty,bv=Object.getOwnPropertySymbols,YR=Object.prototype.hasOwnProperty,KR=Object.prototype.propertyIsEnumerable,vv=(r,t,e)=>t in r?VR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zu=(r,t)=>{for(var e in t||(t={}))YR.call(t,e)&&vv(r,e,t[e]);if(bv)for(var e of bv(t))KR.call(t,e)&&vv(r,e,t[e]);return r};const Wu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Vu=class j1{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof dt||t instanceof D?zu({target:t},e):zu(zu({},e),t)}async image(t){const e=H.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,j1.defaultImageOptions);const{format:e,quality:i}=t,n=this.canvas(t);if(n.toBlob!==void 0)return new Promise((s,a)=>{n.toBlob(o=>{if(!o){a(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>s(l.result),l.onerror=a,l.readAsDataURL(o)},Wu[e],i)});if(n.toDataURL!==void 0)return n.toDataURL(Wu[e],i);if(n.convertToBlob!==void 0){const s=await n.convertToBlob({type:Wu[e],quality:i});return new Promise((a,o)=>{const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(s)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof D)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),s=i.texture.generateCanvas(n);return n.destroy(!0),s}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,n=e instanceof D?e:i.textureGenerator.generateTexture(t),s=i.texture.getPixels(n);return e instanceof dt&&n.destroy(!0),s}texture(t){return t=this._normalizeOptions(t),t.target instanceof D?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),n=document.createElement("a");n.download=(e=t.filename)!=null?e:"image.png",n.href=i.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const n=this.canvas(t),s=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);const a=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",a)}destroy(){this._renderer=null}};Vu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"extract"},Vu.defaultImageOptions={format:"png",quality:1};let xv=Vu;var qR=Object.defineProperty,ZR=Object.defineProperties,QR=Object.getOwnPropertyDescriptors,Ws=Object.getOwnPropertySymbols,Tv=Object.prototype.hasOwnProperty,Sv=Object.prototype.propertyIsEnumerable,wv=(r,t,e)=>t in r?qR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,JR=(r,t)=>{for(var e in t||(t={}))Tv.call(t,e)&&wv(r,e,t[e]);if(Ws)for(var e of Ws(t))Sv.call(t,e)&&wv(r,e,t[e]);return r},tO=(r,t)=>ZR(r,QR(t)),eO=(r,t)=>{var e={};for(var i in r)Tv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ws)for(var i of Ws(r))t.indexOf(i)<0&&Sv.call(r,i)&&(e[i]=r[i]);return e};class Vs extends D{static create(t){const e=t,{dynamic:i,textureOptions:n}=e,s=eO(e,["dynamic","textureOptions"]);return new Vs(tO(JR({},n),{source:new ft(s),dynamic:i!=null?i:!1}))}resize(t,e,i){return this.source.resize(t,e,i),this}}var rO=Object.defineProperty,iO=Object.defineProperties,nO=Object.getOwnPropertyDescriptors,Pv=Object.getOwnPropertySymbols,sO=Object.prototype.hasOwnProperty,aO=Object.prototype.propertyIsEnumerable,Ev=(r,t,e)=>t in r?rO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oO=(r,t)=>{for(var e in t||(t={}))sO.call(t,e)&&Ev(r,e,t[e]);if(Pv)for(var e of Pv(t))aO.call(t,e)&&Ev(r,e,t[e]);return r},lO=(r,t)=>iO(r,nO(t));const uO=new ut,cO=new Mt,hO=[0,0,0,0];class Yu{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof dt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,n=t.antialias||this._renderer.view.antialias,s=t.target;let a=t.clearColor;a?a=Array.isArray(a)&&a.length===4?a:tt.shared.setValue(a).toArray():a=hO;const o=((e=t.frame)==null?void 0:e.copyTo(uO))||un(s,cO).rectangle,l=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};o.width=Math.max(o.width,1/i)|0,o.height=Math.max(o.height,1/i)|0;const u=Vs.create(lO(oO({},t.textureSourceOptions),{width:o.width,height:o.height,resolution:i,antialias:n,textureOptions:l})),c=U.shared.translate(-o.x,-o.y);return this._renderer.render({container:s,transform:c,target:u,clearColor:a}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}Yu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"textureGenerator"};function Av(r){let t=!1;for(const i in r)if(r[i]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const i in r){const n=r[i];n&&(e[i]=n)}return e}function Cv(r){let t=0;for(let e=0;et in r?dO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ov=(r,t)=>{for(var e in t||(t={}))pO.call(t,e)&&Rv(r,e,t[e]);if(Mv)for(var e of Mv(t))fO.call(t,e)&&Rv(r,e,t[e]);return r};const Ku=class H1{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=t}init(t){t=Ov(Ov({},H1.defaultOptions),t),this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedCollections){const{context:i,collection:n,type:s}=e;s==="hash"?i[n]=Av(i[n]):i[n]=Cv(i[n])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e,t.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}addCollection(t,e,i){this._managedCollections.push({context:t,collection:e,type:i})}addResource(t,e){var i,n;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now);return}const s=this._managedResources.length;t._gcData={index:s,type:e},t._gcLastUsed=this.now,(n=t._onTouch)==null||n.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const i=e.index,n=this._managedResources.length-1;if(i!==n){const s=this._managedResources[n];this._managedResources[i]=s,s._gcData.index=i}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,i,n=0){this._managedResourceHashes.push({context:t,hash:e,type:i,priority:n}),this._managedResourceHashes.sort((s,a)=>s.priority-a.priority)}run(){const t=performance.now(),e=this._managedResourceHashes;for(const n of e)this.runOnHash(n,t);let i=0;for(let n=0;n{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};Ku.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"gc",priority:0},Ku.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Gv=Ku;class qu{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"},uWorldTransformMatrix:{value:new U,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{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}}qu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"globalUniforms"};let mO=1;class Zu{constructor(){this._tasks=[],this._offset=0}init(){Ot.system.add(this._update,this)}repeat(t,e,i=!0){const n=mO++;let s=0;return i&&(this._offset+=1e3,s=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:s,last:performance.now(),repeat:!0,id:n}),n}cancel(t){for(let e=0;e=i.duration){const n=t-i.start;i.func(n),i.last=t}}}destroy(){Ot.system.remove(this._update,this),this._tasks.length=0}}Zu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"scheduler",priority:0};let Iv=!1;function Bv(r){if(!Iv){if(H.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Ai} (${r}) http://www.pixijs.com/ + `}},BR=new Mt;let FR=class extends oi{constructor(){super(),this.filters=[new hy({sprite:new pe(D.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}get channel(){return this.filters[0].channel}set channel(t){this.filters[0].channel=t}};class ks{constructor(t){this._activeMaskStage=[],this._renderer=t}push(t,e,i){var n;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.channel=(n=e._maskOptions.channel)!=null?n:"red",t.renderMaskToTexture){const a=t.mask;a.includeInBuild=!0,a.collectRenderables(i,s,null),a.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(t.action==="pushMaskBegin"){const n=Pt.get(FR);if(n.inverse=t.inverse,n.channel=t.mask.channel,i){t.mask.mask.measurable=!0;const s=li(t.mask.mask,!0,BR);t.mask.mask.measurable=!1,s.ceil();const a=e.renderTarget.renderTarget.colorTexture.source,o=vt.getOptimalTexture(s.width,s.height,a._resolution,a.antialias);e.renderTarget.push(o,!0),e.globalUniforms.push({offset:s,worldColor:4294967295});const l=n.sprite;l.texture=o,l.worldTransform.tx=s.minX,l.worldTransform.ty=s.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer,filterTexture:o})}else n.sprite=t.mask.mask,this._activeMaskStage.push({filterEffect:n,maskedContainer:t.maskedContainer})}else if(t.action==="pushMaskEnd"){const n=this._activeMaskStage[this._activeMaskStage.length-1];i&&(e.type===It.WEBGL&&e.renderTarget.finishRenderPass(),e.renderTarget.pop(),e.globalUniforms.pop()),e.filter.push({renderPipeId:"filter",action:"pushFilter",container:n.maskedContainer,filterEffect:n.filterEffect,canBundle:!1})}else if(t.action==="popMaskEnd"){e.filter.pop();const n=this._activeMaskStage.pop();i&&vt.returnTexture(n.filterTexture),Pt.return(n.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}ks.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"alphaMask"};class Bu{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){}destroy(){this._renderer=null,this._colorStack=null}}Bu.extension={type:[S.CanvasPipes],name:"colorMask"};class Fu{constructor(t){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=t}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&t.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(t,e,i){this._renderer.renderPipes.batch.break(i);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,i.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(t){this._renderer.colorMask.setMask(t.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}Fu.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"colorMask"};class DR{constructor(t){this.priority=0,this.pipe="scissorMask",this.mask=t,this.mask.renderable=!1,this.mask.measurable=!1}addBounds(t,e){Sn(this.mask,t,e)}addLocalBounds(t,e){wn(this.mask,t,e)}containsPoint(t,e){const i=this.mask;return e(i,t)}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}destroy(){this.reset()}}function UR(r,t,e,i,n,s){s=Math.max(0,Math.min(s,Math.min(i,n)/2)),r.moveTo(t+s,e),r.lineTo(t+i-s,e),r.quadraticCurveTo(t+i,e,t+i,e+s),r.lineTo(t+i,e+n-s),r.quadraticCurveTo(t+i,e+n,t+i-s,e+n),r.lineTo(t+s,e+n),r.quadraticCurveTo(t,e+n,t,e+n-s),r.lineTo(t,e+s),r.quadraticCurveTo(t,e,t+s,e)}function uv(r,t){switch(t.type){case"rectangle":{const e=t;r.rect(e.x,e.y,e.width,e.height);break}case"roundedRectangle":{const e=t;UR(r,e.x,e.y,e.width,e.height,e.radius);break}case"circle":{const e=t;r.moveTo(e.x+e.radius,e.y),r.arc(e.x,e.y,e.radius,0,Math.PI*2);break}case"ellipse":{const e=t;r.ellipse?(r.moveTo(e.x+e.halfWidth,e.y),r.ellipse(e.x,e.y,e.halfWidth,e.halfHeight,0,0,Math.PI*2)):(r.save(),r.translate(e.x,e.y),r.scale(e.halfWidth,e.halfHeight),r.moveTo(1,0),r.arc(0,0,1,0,Math.PI*2),r.restore());break}case"triangle":{const e=t;r.moveTo(e.x,e.y),r.lineTo(e.x2,e.y2),r.lineTo(e.x3,e.y3),r.closePath();break}default:{const e=t,i=e.points;if(!(i!=null&&i.length))break;r.moveTo(i[0],i[1]);for(let n=2;n>>24&255)/255,T=(v>>>24&255)/255,E=(a=(s=g.filter)==null?void 0:s.alphaMultiplier)!=null?a:1,P=w*T*E;if(P<=0)return;const M=x&16777215,C=v&16777215,A=xe(Oe(C,M)),G=g._roundPixels|e._roundPixels;y.save(),_.setContextTransform(b,G===1),_.setBlendMode(e.groupBlendMode);const F=e.context.instructions;for(let R=0;R{if(!r.name)throw new Error("BlendMode extension must have a name property");Vi[r.name]=r.ref},r=>{delete Vi[r.name]});class Ws{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){var e;this._blendModeStack.pop();const i=(e=this._blendModeStack[this._activeBlendMode.length-1])!=null?e:"normal";this.setBlendMode(null,i,t)}setBlendMode(t,e,i){var n;const s=t instanceof mn;if(this._activeBlendMode===e){this._isAdvanced&&t&&!s&&((n=this._renderableList)==null||n.push(t));return}this._isAdvanced&&this._endAdvancedBlendMode(i),this._activeBlendMode=e,t&&(this._isAdvanced=!!Vi[e],this._isAdvanced&&this._beginAdvancedBlendMode(t,i))}_beginAdvancedBlendMode(t,e){this._renderer.renderPipes.batch.break(e);const i=this._activeBlendMode;if(!Vi[i])return;const n=this._ensureFilterEffect(i),s=t instanceof mn,a={renderPipeId:"filter",action:"pushFilter",filterEffect:n,renderables:s?null:[t],container:s?t.root:null,canBundle:!1};this._renderableList=a.renderables,e.add(a)}_ensureFilterEffect(t){let e=this._filterHash[t];return e||(e=this._filterHash[t]=new oi,e.filters=[new Vi[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}}Ws.extension={type:[S.WebGLPipes,S.WebGPUPipes,S.CanvasPipes],name:"blendMode"};function Vs(r,t){t||(t=0);for(let e=t;e1?1:e,r.worldAlpha=e,r.worldColorAlpha=r.worldColor+((e*255|0)<<24)}function ju(r,t,e){if(t===r.updateTick)return;r.updateTick=t,r.didChange=!1;const i=r.localTransform;r.updateLocalTransform();const n=r.parent;if(n&&!n.renderGroup?(e|=r._updateFlags,r.relativeGroupTransform.appendFrom(i,n.relativeGroupTransform),e&hv&&pv(r,n,e)):(e=r._updateFlags,r.relativeGroupTransform.copyFrom(i),e&hv&&pv(r,KR,e)),!r.renderGroup){const s=r.children,a=s.length;for(let u=0;u1?1:i,r.groupAlpha=i,r.groupColorAlpha=r.groupColor+((i*255|0)<<24)}e&_n&&(r.groupBlendMode=r.localBlendMode==="inherit"?t.groupBlendMode:r.localBlendMode),e&xr&&(r.globalDisplayStatus=r.localDisplayStatus&t.globalDisplayStatus),r._updateFlags=0}function fv(r,t){const{list:e}=r.childrenRenderablesToUpdate;let i=!1;for(let n=0;n=0;s--)this._updateCachedRenderGroups(t.renderGroupChildren[s],e);if(t.invalidateMatrices(),t.isCachedAsTexture){if(t.textureNeedsUpdate){const s=t.root.getLocalBounds(),a=this._renderer,o=t.textureOptions.resolution||a.view.resolution,l=(i=t.textureOptions.antialias)!=null?i:a.view.antialias,u=(n=t.textureOptions.scaleMode)!=null?n:"linear",c=t.texture;s.ceil(),t.texture&&vt.returnTexture(t.texture,!0);const h=vt.getOptimalTexture(s.width,s.height,o,l);h._source.style=new Jt({scaleMode:u}),t.texture=h,t._textureBounds||(t._textureBounds=new Mt),t._textureBounds.copyFrom(s),c!==t.texture&&t.renderGroupParent&&(t.renderGroupParent.structureDidChange=!0)}}else t.texture&&(vt.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?Vs(t.childrenRenderablesToUpdate.list,0):fv(t,i),Xu(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 n=0;nt in r?ZR(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_v=(r,t)=>{for(var e in t||(t={}))QR.call(t,e)&&gv(r,e,t[e]);if(mv)for(var e of mv(t))JR.call(t,e)&&gv(r,e,t[e]);return r};const zu=class H1{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new tt(0),this.color=this._backgroundColor,this.alpha=1}init(t){t=_v(_v({},H1.defaultOptions),t),this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(t){this._backgroundColor.setValue(t)}get alpha(){return this._backgroundColor.alpha}set alpha(t){this._backgroundColor.setAlpha(t)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};zu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"background",priority:0},zu.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let yv=zu;var tO=Object.defineProperty,bv=Object.getOwnPropertySymbols,eO=Object.prototype.hasOwnProperty,rO=Object.prototype.propertyIsEnumerable,vv=(r,t,e)=>t in r?tO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Wu=(r,t)=>{for(var e in t||(t={}))eO.call(t,e)&&vv(r,e,t[e]);if(bv)for(var e of bv(t))rO.call(t,e)&&vv(r,e,t[e]);return r};const Vu={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Yu=class z1{constructor(t){this._renderer=t}_normalizeOptions(t,e={}){return t instanceof dt||t instanceof D?Wu({target:t},e):Wu(Wu({},e),t)}async image(t){const e=H.get().createImage();return e.src=await this.base64(t),e}async base64(t){t=this._normalizeOptions(t,z1.defaultImageOptions);const{format:e,quality:i}=t,n=this.canvas(t);if(n.toBlob!==void 0)return new Promise((s,a)=>{n.toBlob(o=>{if(!o){a(new Error("ICanvas.toBlob failed!"));return}const l=new FileReader;l.onload=()=>s(l.result),l.onerror=a,l.readAsDataURL(o)},Vu[e],i)});if(n.toDataURL!==void 0)return n.toDataURL(Vu[e],i);if(n.convertToBlob!==void 0){const s=await n.convertToBlob({type:Vu[e],quality:i});return new Promise((a,o)=>{const l=new FileReader;l.onload=()=>a(l.result),l.onerror=o,l.readAsDataURL(s)})}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer;if(e instanceof D)return i.texture.generateCanvas(e);const n=i.textureGenerator.generateTexture(t),s=i.texture.generateCanvas(n);return n.destroy(!0),s}pixels(t){t=this._normalizeOptions(t);const e=t.target,i=this._renderer,n=e instanceof D?e:i.textureGenerator.generateTexture(t),s=i.texture.getPixels(n);return e instanceof dt&&n.destroy(!0),s}texture(t){return t=this._normalizeOptions(t),t.target instanceof D?t.target:this._renderer.textureGenerator.generateTexture(t)}download(t){var e;t=this._normalizeOptions(t);const i=this.canvas(t),n=document.createElement("a");n.download=(e=t.filename)!=null?e:"image.png",n.href=i.toDataURL("image/png"),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(t){var e;const i=(e=t.width)!=null?e:200;t=this._normalizeOptions(t);const n=this.canvas(t),s=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);const a=["font-size: 1px;",`padding: ${i}px 300px;`,`background: url(${s}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",a)}destroy(){this._renderer=null}};Yu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"extract"},Yu.defaultImageOptions={format:"png",quality:1};let xv=Yu;var iO=Object.defineProperty,nO=Object.defineProperties,sO=Object.getOwnPropertyDescriptors,Ys=Object.getOwnPropertySymbols,Tv=Object.prototype.hasOwnProperty,Sv=Object.prototype.propertyIsEnumerable,wv=(r,t,e)=>t in r?iO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aO=(r,t)=>{for(var e in t||(t={}))Tv.call(t,e)&&wv(r,e,t[e]);if(Ys)for(var e of Ys(t))Sv.call(t,e)&&wv(r,e,t[e]);return r},oO=(r,t)=>nO(r,sO(t)),lO=(r,t)=>{var e={};for(var i in r)Tv.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&Ys)for(var i of Ys(r))t.indexOf(i)<0&&Sv.call(r,i)&&(e[i]=r[i]);return e};class Ks extends D{static create(t){const e=t,{dynamic:i,textureOptions:n}=e,s=lO(e,["dynamic","textureOptions"]);return new Ks(oO(aO({},n),{source:new ft(s),dynamic:i!=null?i:!1}))}resize(t,e,i){return this.source.resize(t,e,i),this}}var uO=Object.defineProperty,cO=Object.defineProperties,hO=Object.getOwnPropertyDescriptors,Ev=Object.getOwnPropertySymbols,dO=Object.prototype.hasOwnProperty,pO=Object.prototype.propertyIsEnumerable,Pv=(r,t,e)=>t in r?uO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fO=(r,t)=>{for(var e in t||(t={}))dO.call(t,e)&&Pv(r,e,t[e]);if(Ev)for(var e of Ev(t))pO.call(t,e)&&Pv(r,e,t[e]);return r},mO=(r,t)=>cO(r,hO(t));const gO=new ut,_O=new Mt,yO=[0,0,0,0];class Ku{constructor(t){this._renderer=t}generateTexture(t){var e;t instanceof dt&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});const i=t.resolution||this._renderer.resolution,n=t.antialias||this._renderer.view.antialias,s=t.target;let a=t.clearColor;a?a=Array.isArray(a)&&a.length===4?a:tt.shared.setValue(a).toArray():a=yO;const o=((e=t.frame)==null?void 0:e.copyTo(gO))||hn(s,_O).rectangle,l=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};o.width=Math.max(o.width,1/i)|0,o.height=Math.max(o.height,1/i)|0;const u=Ks.create(mO(fO({},t.textureSourceOptions),{width:o.width,height:o.height,resolution:i,antialias:n,textureOptions:l})),c=U.shared.translate(-o.x,-o.y);return this._renderer.render({container:s,transform:c,target:u,clearColor:a}),u.source.updateMipmaps(),u}destroy(){this._renderer=null}}Ku.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"textureGenerator"};function Av(r){let t=!1;for(const i in r)if(r[i]==null){t=!0;break}if(!t)return r;const e=Object.create(null);for(const i in r){const n=r[i];n&&(e[i]=n)}return e}function Cv(r){let t=0;for(let e=0;et in r?bO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ov=(r,t)=>{for(var e in t||(t={}))vO.call(t,e)&&Rv(r,e,t[e]);if(Mv)for(var e of Mv(t))xO.call(t,e)&&Rv(r,e,t[e]);return r};const qu=class W1{constructor(t){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=t}init(t){t=Ov(Ov({},W1.defaultOptions),t),this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(t){this.enabled!==t&&(t?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(const e of this._managedCollections){const{context:i,collection:n,type:s}=e;s==="hash"?i[n]=Av(i[n]):i[n]=Cv(i[n])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:t}){this.now=performance.now(),t.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(t.renderGroup,t.renderGroup.gcTick)}postrender(){!this._ready||!this.enabled||(this.run(),this._ready=!1)}_updateInstructionGCTick(t,e){t.instructionSet.gcTick=e,t.gcTick=e;for(const i of t.renderGroupChildren)this._updateInstructionGCTick(i,e)}addCollection(t,e,i){this._managedCollections.push({context:t,collection:e,type:i})}addResource(t,e){var i,n;if(t._gcLastUsed!==-1){t._gcLastUsed=this.now,(i=t._onTouch)==null||i.call(t,this.now);return}const s=this._managedResources.length;t._gcData={index:s,type:e},t._gcLastUsed=this.now,(n=t._onTouch)==null||n.call(t,this.now),t.once("unload",this.removeResource,this),this._managedResources.push(t)}removeResource(t){const e=t._gcData;if(!e)return;const i=e.index,n=this._managedResources.length-1;if(i!==n){const s=this._managedResources[n];this._managedResources[i]=s,s._gcData.index=i}this._managedResources.length--,t._gcData=null,t._gcLastUsed=-1}addResourceHash(t,e,i,n=0){this._managedResourceHashes.push({context:t,hash:e,type:i,priority:n}),this._managedResourceHashes.sort((s,a)=>s.priority-a.priority)}run(){const t=performance.now(),e=this._managedResourceHashes;for(const n of e)this.runOnHash(n,t);let i=0;for(let n=0;n{t.off("unload",this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};qu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"gc",priority:0},qu.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Gv=qu;class Zu{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"},uWorldTransformMatrix:{value:new U,type:"mat3x3"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4"},uResolution:{value:[0,0],type:"vec2"}},{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}}Zu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"globalUniforms"};let TO=1;class Qu{constructor(){this._tasks=[],this._offset=0}init(){Ot.system.add(this._update,this)}repeat(t,e,i=!0){const n=TO++;let s=0;return i&&(this._offset+=1e3,s=this._offset),this._tasks.push({func:t,duration:e,start:performance.now(),offset:s,last:performance.now(),repeat:!0,id:n}),n}cancel(t){for(let e=0;e=i.duration){const n=t-i.start;i.func(n),i.last=t}}}destroy(){Ot.system.remove(this._update,this),this._tasks.length=0}}Qu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"scheduler",priority:0};let Iv=!1;function Bv(r){if(!Iv){if(H.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${Ai} (${r}) http://www.pixijs.com/ -`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Ai} - ${r} - http://www.pixijs.com/`);Iv=!0}}class Ys{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===It.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Bv(e)}}}Ys.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"hello",priority:-2},Ys.defaultOptions={hello:!1};var gO=Object.defineProperty,Fv=Object.getOwnPropertySymbols,_O=Object.prototype.hasOwnProperty,yO=Object.prototype.propertyIsEnumerable,Dv=(r,t,e)=>t in r?gO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uv=(r,t)=>{for(var e in t||(t={}))_O.call(t,e)&&Dv(r,e,t[e]);if(Fv)for(var e of Fv(t))yO.call(t,e)&&Dv(r,e,t[e]);return r};const Qu=class z1{constructor(t){this._renderer=t}init(t){t=Uv(Uv({},z1.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return this._renderer.gc.enabled}set enabled(t){this._renderer.gc.enabled=t}addManagedHash(t,e){this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){this._renderer.gc.addResource(t,"renderable")}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Qu.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderableGC",priority:0},Qu.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let $v=Qu;const Ju=class Ta{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){}get active(){return this._renderer.gc.enabled}set active(t){this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==Ta.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==Ta.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==Ta.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Ju.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"textureGC"},Ju.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let kv=Ju;var bO=Object.defineProperty,Lv=Object.getOwnPropertySymbols,vO=Object.prototype.hasOwnProperty,xO=Object.prototype.propertyIsEnumerable,Nv=(r,t,e)=>t in r?bO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xv=(r,t)=>{for(var e in t||(t={}))vO.call(t,e)&&Nv(r,e,t[e]);if(Lv)for(var e of Lv(t))xO.call(t,e)&&Nv(r,e,t[e]);return r};const jv=class W1{constructor(t={}){if(this.uid=ht("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Xv(Xv({},W1.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;ei.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof D||t.depthStencilTexture instanceof ft?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ft({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,n=!1){this.dirtyId++,this.colorTextures.forEach((s,a)=>{n&&a===0||s.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)}};jv.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Ks=jv;var TO=Object.defineProperty,Hv=Object.getOwnPropertySymbols,SO=Object.prototype.hasOwnProperty,wO=Object.prototype.propertyIsEnumerable,zv=(r,t,e)=>t in r?TO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PO=(r,t)=>{for(var e in t||(t={}))SO.call(t,e)&&zv(r,e,t[e]);if(Hv)for(var e of Hv(t))wO.call(t,e)&&zv(r,e,t[e]);return r};const fr=new Map;qe.register(fr);function tc(r,t){if(!fr.has(r)){const e=new D({source:new fe(PO({resource:r},t))}),i=()=>{fr.get(r)===e&&fr.delete(r)};e.once("destroy",i),e.source.once("destroy",i),fr.set(r,e)}return fr.get(r)}function EO(r){return fr.has(r)}var AO=Object.defineProperty,Wv=Object.getOwnPropertySymbols,CO=Object.prototype.hasOwnProperty,MO=Object.prototype.propertyIsEnumerable,Vv=(r,t,e)=>t in r?AO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yv=(r,t)=>{for(var e in t||(t={}))CO.call(t,e)&&Vv(r,e,t[e]);if(Wv)for(var e of Wv(t))MO.call(t,e)&&Vv(r,e,t[e]);return r};const ec=class V1{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(t){t=Yv(Yv({},V1.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new ut(0,0,t.width,t.height),this.canvas=t.canvas||H.get().createCanvas(),this.antialias=!!t.antialias,this.texture=tc(this.canvas,t),this.renderTarget=new Ks({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};ec.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"view",priority:0},ec.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Kv=ec;const qs=[yv,qu,Ys,Kv,ju,Gv,kv,Yu,xv,$o,$v,Zu],rc=[Hs,Ds,js,Ls,Us,Du,Bu,$s];function qv(r,t,e,i,n,s){const a=s?1:-1;return r.identity(),r.a=1/i*2,r.d=a*(1/n*2),r.tx=-1-t*r.a,r.ty=-a-e*r.d,r}function Zv(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}class Zs{constructor(t){this.rootViewPort=new ut,this.viewport=new ut,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Bo("onRenderTargetChange"),this.projectionMatrix=new U,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:n,mipLevel:s,layer:a}){var o,l;this._renderTargetStack.length=0,this.push(t,e,i,n,s!=null?s:0,a!=null?a:0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Zv(this.rootRenderTarget),(l=(o=this.adaptor).prerender)==null||l.call(o,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,n,s=0,a=0){const o=this.getRenderTarget(t),l=this.renderTarget!==o;this.renderTarget=o,this.renderSurface=t;const u=this.getGpuRenderTarget(o);(o.pixelWidth!==u.width||o.pixelHeight!==u.height)&&(this.adaptor.resizeGpuRenderTarget(o),u.width=o.pixelWidth,u.height=o.pixelHeight);const c=o.colorTexture,h=this.viewport,p=c.arrayLayerCount||1;if((a|0)!==a&&(a|=0),a<0||a>=p)throw new Error(`[RenderTargetSystem] layer ${a} is out of bounds (arrayLayerCount=${p}).`);this.mipLevel=s|0,this.layer=a|0;const f=Math.max(c.pixelWidth>>s,1),m=Math.max(c.pixelHeight>>s,1);if(!n&&t instanceof D&&(n=t.frame),n){const g=c._resolution,_=1<{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return fe.test(t)&&(t=tc(t).source),t instanceof Ks?e=t:t instanceof ft&&(e=new Ks({colorTextures:[t]}),t.source instanceof fe&&(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 Qv{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:i,context:n}=this._ensureCanvas(e);return{canvas:i,context:n,width:i.width,height:i.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:i}=this._ensureCanvas(e);i.width=t.pixelWidth,i.height=t.pixelHeight}startRenderPass(t,e,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,i,n)}clear(t,e,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t).context,a=n||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(s.setTransform(1,0,0,1,0,0),s.clearRect(a.x,a.y,a.width,a.height),i){const o=tt.shared.setValue(i);o.alpha>0&&(s.globalAlpha=o.alpha,s.fillStyle=o.toHex(),s.fillRect(a.x,a.y,a.width,a.height),s.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,i,n,s){var a,o;const l=this._renderTargetSystem.getGpuRenderTarget(t).canvas,u=e.source,{context:c}=this._ensureCanvas(u),h=(a=s==null?void 0:s.x)!=null?a:0,p=(o=s==null?void 0:s.y)!=null?o:0;return c.drawImage(l,i.x,i.y,n.width,n.height,h,p,n.width,n.height),u.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!fe.test(e))&&(e=H.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const i=e.getContext("2d");return{canvas:e,context:i}}}class ic extends Zs{constructor(t){super(t),this.adaptor=new Qv,this.adaptor.init(t,this)}}ic.extension={type:[S.CanvasSystem],name:"renderTarget"};class nc{constructor(t){}init(){}initSource(t){}generateCanvas(t){var e,i;const n=H.get().createCanvas(),s=n.getContext("2d"),a=Q.getCanvasSource(t);if(!a)return n;const o=t.frame,l=(i=(e=t.source._resolution)!=null?e:t.source.resolution)!=null?i:1,u=o.x*l,c=o.y*l,h=o.width*l,p=o.height*l;return n.width=Math.ceil(h),n.height=Math.ceil(p),s.drawImage(a,u,c,h,p,0,0,h,p),n}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}nc.extension={type:[S.CanvasSystem],name:"texture"};const RO=[...qs,Uu,$u,nc,ic],OO=[Hs,Ds,js,Ls,Us,Fu,Iu,$s],GO=[av,Lu],Jv=[],tx=[],ex=[];X.handleByNamedList(S.CanvasSystem,Jv),X.handleByNamedList(S.CanvasPipes,tx),X.handleByNamedList(S.CanvasPipesAdaptor,ex),X.add(...RO,...OO,...GO);class rx extends Mr{constructor(){const t={name:"canvas",type:It.CANVAS,systems:Jv,renderPipes:tx,renderPipeAdaptors:ex};super(t)}}var IO={__proto__:null,CanvasRenderer:rx},Yi=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Yi||{});class ix{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class sc{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new Ut({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.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,n=this._nextBindBaseIndex;for(;i<2;){n>=this._maxBindings&&(n=this._minBaseLocation,i++);const s=this._boundBufferBases[n];if(s&&s._lastBindCallId===this._bindCallId){n++;continue}break}return e=n,this._nextBindBaseIndex=n+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,n){const{_gl:s}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,s.bindBufferRange(s.UNIFORM_BUFFER,e||0,t.buffer,i*256,n||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 n=t.data,s=t.descriptor.usage&at.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return n?i.byteLength>=n.byteLength?e.bufferSubData(i.type,0,n,0,t._updateSize/n.BYTES_PER_ELEMENT):(i.byteLength=n.byteLength,e.bufferData(i.type,n,s)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,s)),i}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||this._gl.deleteBuffer(i.buffer))}createGLBuffer(t){const{_gl:e}=this;let i=Yi.ARRAY_BUFFER;t.descriptor.usage&at.INDEX?i=Yi.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&at.UNIFORM&&(i=Yi.UNIFORM_BUFFER);const n=new ix(e.createBuffer(),i);return t._gpuData[this._renderer.uid]=n,this._managedBuffers.add(t),n}resetState(){this._boundBufferBases=Object.create(null)}}sc.extension={type:[S.WebGLSystem],name:"buffer"};var BO=Object.defineProperty,FO=Object.defineProperties,DO=Object.getOwnPropertyDescriptors,nx=Object.getOwnPropertySymbols,UO=Object.prototype.hasOwnProperty,$O=Object.prototype.propertyIsEnumerable,sx=(r,t,e)=>t in r?BO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qs=(r,t)=>{for(var e in t||(t={}))UO.call(t,e)&&sx(r,e,t[e]);if(nx)for(var e of nx(t))$O.call(t,e)&&sx(r,e,t[e]);return r},ax=(r,t)=>FO(r,DO(t));const ac=class Y1{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,i;t=Qs(Qs({},Y1.defaultOptions),t);let n=this.multiView=t.multiView;if(t.context&&n&&(ue("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),n=!1),n?this.canvas=H.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const s=this._renderer.background.alpha<1,a=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:a,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&ue("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const i=this.supports,n=this.webGLVersion===2,s=this.extensions;i.uint32Indices=n||!!s.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!s.vertexArrayObject,i.srgbTextures=n||!!s.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices}};ac.extension={type:[S.WebGLSystem],name:"context"},ac.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let ox=ac;function oc(r,t){var e,i,n;for(const s in r.attributes){const a=r.attributes[s],o=t[s];o?((e=a.format)!=null||(a.format=o.format),(i=a.offset)!=null||(a.offset=o.offset),(n=a.instance)!=null||(a.instance=o.instance)):ue(`Attribute ${s} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}kO(r)}function kO(r){var t,e;const{buffers:i,attributes:n}=r,s={},a={};for(const o in i){const l=i[o];s[l.uid]=0,a[l.uid]=0}for(const o in n){const l=n[o];s[l.buffer.uid]+=Ie(l.format).stride}for(const o in n){const l=n[o];(t=l.stride)!=null||(l.stride=s[l.buffer.uid]),(e=l.start)!=null||(l.start=a[l.buffer.uid]),a[l.buffer.uid]+=Ie(l.format).stride}}var Js=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(Js||{}),ta=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(ta||{}),lx=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(lx||{}),ct=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(ct||{});const ux={uint8x2:ct.UNSIGNED_BYTE,uint8x4:ct.UNSIGNED_BYTE,sint8x2:ct.BYTE,sint8x4:ct.BYTE,unorm8x2:ct.UNSIGNED_BYTE,unorm8x4:ct.UNSIGNED_BYTE,snorm8x2:ct.BYTE,snorm8x4:ct.BYTE,uint16x2:ct.UNSIGNED_SHORT,uint16x4:ct.UNSIGNED_SHORT,sint16x2:ct.SHORT,sint16x4:ct.SHORT,unorm16x2:ct.UNSIGNED_SHORT,unorm16x4:ct.UNSIGNED_SHORT,snorm16x2:ct.SHORT,snorm16x4:ct.SHORT,float16x2:ct.HALF_FLOAT,float16x4:ct.HALF_FLOAT,float32:ct.FLOAT,float32x2:ct.FLOAT,float32x3:ct.FLOAT,float32x4:ct.FLOAT,uint32:ct.UNSIGNED_INT,uint32x2:ct.UNSIGNED_INT,uint32x3:ct.UNSIGNED_INT,uint32x4:ct.UNSIGNED_INT,sint32:ct.INT,sint32x2:ct.INT,sint32x3:ct.INT,sint32x4:ct.INT};function cx(r){var t;return(t=ux[r])!=null?t:ux.float32}const LO={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class hx{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class lc{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new Ut({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}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");this.destroyAll(!0);const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=n=>e.bindVertexArrayOES(n),t.deleteVertexArray=n=>e.deleteVertexArrayOES(n));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(n,s,a,o)=>{i.drawArraysInstancedANGLE(n,s,a,o)},t.drawElementsInstanced=(n,s,a,o,l)=>{i.drawElementsInstancedANGLE(n,s,a,o,l)},t.vertexAttribDivisor=(n,s)=>i.vertexAttribDivisorANGLE(n,s)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const i=this.gl;this._activeGeometry=t;const n=this.getVao(t,e);this._activeVao!==n&&(this._activeVao=n,i.bindVertexArray(n)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;it in r?NO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fx=(r,t)=>{for(var e in t||(t={}))XO.call(t,e)&&px(r,e,t[e]);if(dx)for(var e of dx(t))jO.call(t,e)&&px(r,e,t[e]);return r};const HO=new nr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),uc=class K1{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=fx(fx({},K1.defaultOptions),t);this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(ue("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Vt.for2d();const n=new Wt({vertex:` +`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${Ai} - ${r} - http://www.pixijs.com/`);Iv=!0}}class qs{constructor(t){this._renderer=t}init(t){if(t.hello){let e=this._renderer.name;this._renderer.type===It.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),Bv(e)}}}qs.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"hello",priority:-2},qs.defaultOptions={hello:!1};var SO=Object.defineProperty,Fv=Object.getOwnPropertySymbols,wO=Object.prototype.hasOwnProperty,EO=Object.prototype.propertyIsEnumerable,Dv=(r,t,e)=>t in r?SO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Uv=(r,t)=>{for(var e in t||(t={}))wO.call(t,e)&&Dv(r,e,t[e]);if(Fv)for(var e of Fv(t))EO.call(t,e)&&Dv(r,e,t[e]);return r};const Ju=class V1{constructor(t){this._renderer=t}init(t){t=Uv(Uv({},V1.defaultOptions),t),this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return this._renderer.gc.enabled}set enabled(t){this._renderer.gc.enabled=t}addManagedHash(t,e){this._renderer.gc.addCollection(t,e,"hash")}addManagedArray(t,e){this._renderer.gc.addCollection(t,e,"array")}addRenderable(t){this._renderer.gc.addResource(t,"renderable")}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};Ju.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"renderableGC",priority:0},Ju.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let $v=Ju;const tc=class Sa{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(t){this._checkCount=t}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(t){this._renderer.gc.maxUnusedTime=t/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(t){}get active(){return this._renderer.gc.enabled}set active(t){this._renderer.gc.enabled=t}constructor(t){this._renderer=t,this._checkCount=0}init(t){t.textureGCActive!==Sa.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==Sa.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==Sa.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){this._renderer.gc.run()}destroy(){this._renderer=null}};tc.extension={type:[S.WebGLSystem,S.WebGPUSystem],name:"textureGC"},tc.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let kv=tc;var PO=Object.defineProperty,Lv=Object.getOwnPropertySymbols,AO=Object.prototype.hasOwnProperty,CO=Object.prototype.propertyIsEnumerable,Nv=(r,t,e)=>t in r?PO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Xv=(r,t)=>{for(var e in t||(t={}))AO.call(t,e)&&Nv(r,e,t[e]);if(Lv)for(var e of Lv(t))CO.call(t,e)&&Nv(r,e,t[e]);return r};const jv=class Y1{constructor(t={}){if(this.uid=ht("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t=Xv(Xv({},Y1.defaultOptions),t),this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,typeof t.colorTextures=="number"){this._managedColorTextures=!0;for(let e=0;ei.source)];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof D||t.depthStencilTexture instanceof ft?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const t=this._size;return t[0]=this.pixelWidth,t[1]=this.pixelHeight,t}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(t){this.resize(t.width,t.height,t._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new ft({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(t,e,i=this.resolution,n=!1){this.dirtyId++,this.colorTextures.forEach((s,a)=>{n&&a===0||s.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)}};jv.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let Zs=jv;var MO=Object.defineProperty,Hv=Object.getOwnPropertySymbols,RO=Object.prototype.hasOwnProperty,OO=Object.prototype.propertyIsEnumerable,zv=(r,t,e)=>t in r?MO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,GO=(r,t)=>{for(var e in t||(t={}))RO.call(t,e)&&zv(r,e,t[e]);if(Hv)for(var e of Hv(t))OO.call(t,e)&&zv(r,e,t[e]);return r};const fr=new Map;qe.register(fr);function ec(r,t){if(!fr.has(r)){const e=new D({source:new fe(GO({resource:r},t))}),i=()=>{fr.get(r)===e&&fr.delete(r)};e.once("destroy",i),e.source.once("destroy",i),fr.set(r,e)}return fr.get(r)}function IO(r){return fr.has(r)}var BO=Object.defineProperty,Wv=Object.getOwnPropertySymbols,FO=Object.prototype.hasOwnProperty,DO=Object.prototype.propertyIsEnumerable,Vv=(r,t,e)=>t in r?BO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Yv=(r,t)=>{for(var e in t||(t={}))FO.call(t,e)&&Vv(r,e,t[e]);if(Wv)for(var e of Wv(t))DO.call(t,e)&&Vv(r,e,t[e]);return r};const rc=class K1{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(t){t=Yv(Yv({},K1.defaultOptions),t),t.view&&(t.canvas=t.view),this.screen=new ut(0,0,t.width,t.height),this.canvas=t.canvas||H.get().createCanvas(),this.antialias=!!t.antialias,this.texture=ec(this.canvas,t),this.renderTarget=new Zs({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(t,e,i){this.texture.source.resize(t,e,i),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(t=!1){(typeof t=="boolean"?t:t!=null&&t.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};rc.extension={type:[S.WebGLSystem,S.WebGPUSystem,S.CanvasSystem],name:"view",priority:0},rc.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};let Kv=rc;const Qs=[yv,Zu,qs,Kv,Hu,Gv,kv,Ku,xv,ko,$v,Qu],ic=[Ws,$s,zs,Xs,ks,Uu,Fu,Ls];function qv(r,t,e,i,n,s){const a=s?1:-1;return r.identity(),r.a=1/i*2,r.d=a*(1/n*2),r.tx=-1-t*r.a,r.ty=-a-e*r.d,r}function Zv(r){const t=r.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}class Js{constructor(t){this.rootViewPort=new ut,this.viewport=new ut,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new Fo("onRenderTargetChange"),this.projectionMatrix=new U,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=t,t.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:t,clear:e,clearColor:i,frame:n,mipLevel:s,layer:a}){var o,l;this._renderTargetStack.length=0,this.push(t,e,i,n,s!=null?s:0,a!=null?a:0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Zv(this.rootRenderTarget),(l=(o=this.adaptor).prerender)==null||l.call(o,this.rootRenderTarget)}postrender(){var t,e;(e=(t=this.adaptor).postrender)==null||e.call(t,this.rootRenderTarget)}bind(t,e=!0,i,n,s=0,a=0){const o=this.getRenderTarget(t),l=this.renderTarget!==o;this.renderTarget=o,this.renderSurface=t;const u=this.getGpuRenderTarget(o);(o.pixelWidth!==u.width||o.pixelHeight!==u.height)&&(this.adaptor.resizeGpuRenderTarget(o),u.width=o.pixelWidth,u.height=o.pixelHeight);const c=o.colorTexture,h=this.viewport,p=c.arrayLayerCount||1;if((a|0)!==a&&(a|=0),a<0||a>=p)throw new Error(`[RenderTargetSystem] layer ${a} is out of bounds (arrayLayerCount=${p}).`);this.mipLevel=s|0,this.layer=a|0;const f=Math.max(c.pixelWidth>>s,1),m=Math.max(c.pixelHeight>>s,1);if(!n&&t instanceof D&&(n=t.frame),n){const g=c._resolution,_=1<{t!==e&&t.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(t){let e=null;return fe.test(t)&&(t=ec(t).source),t instanceof Zs?e=t:t instanceof ft&&(e=new Zs({colorTextures:[t]}),t.source instanceof fe&&(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 Qv{init(t,e){this._renderer=t,this._renderTargetSystem=e}initGpuRenderTarget(t){const e=t.colorTexture,{canvas:i,context:n}=this._ensureCanvas(e);return{canvas:i,context:n,width:i.width,height:i.height}}resizeGpuRenderTarget(t){const e=t.colorTexture,{canvas:i}=this._ensureCanvas(e);i.width=t.pixelWidth,i.height=t.pixelHeight}startRenderPass(t,e,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t);this._renderer.canvasContext.activeContext=s.context,this._renderer.canvasContext.activeResolution=t.resolution,e&&this.clear(t,e,i,n)}clear(t,e,i,n){const s=this._renderTargetSystem.getGpuRenderTarget(t).context,a=n||{x:0,y:0,width:t.pixelWidth,height:t.pixelHeight};if(s.setTransform(1,0,0,1,0,0),s.clearRect(a.x,a.y,a.width,a.height),i){const o=tt.shared.setValue(i);o.alpha>0&&(s.globalAlpha=o.alpha,s.fillStyle=o.toHex(),s.fillRect(a.x,a.y,a.width,a.height),s.globalAlpha=1)}}finishRenderPass(){}copyToTexture(t,e,i,n,s){var a,o;const l=this._renderTargetSystem.getGpuRenderTarget(t).canvas,u=e.source,{context:c}=this._ensureCanvas(u),h=(a=s==null?void 0:s.x)!=null?a:0,p=(o=s==null?void 0:s.y)!=null?o:0;return c.drawImage(l,i.x,i.y,n.width,n.height,h,p,n.width,n.height),u.update(),e}destroyGpuRenderTarget(t){}_ensureCanvas(t){let e=t.resource;(!e||!fe.test(e))&&(e=H.get().createCanvas(t.pixelWidth,t.pixelHeight),t.resource=e),(e.width!==t.pixelWidth||e.height!==t.pixelHeight)&&(e.width=t.pixelWidth,e.height=t.pixelHeight);const i=e.getContext("2d");return{canvas:e,context:i}}}class nc extends Js{constructor(t){super(t),this.adaptor=new Qv,this.adaptor.init(t,this)}}nc.extension={type:[S.CanvasSystem],name:"renderTarget"};class sc{constructor(t){}init(){}initSource(t){}generateCanvas(t){var e,i;const n=H.get().createCanvas(),s=n.getContext("2d"),a=Q.getCanvasSource(t);if(!a)return n;const o=t.frame,l=(i=(e=t.source._resolution)!=null?e:t.source.resolution)!=null?i:1,u=o.x*l,c=o.y*l,h=o.width*l,p=o.height*l;return n.width=Math.ceil(h),n.height=Math.ceil(p),s.drawImage(a,u,c,h,p,0,0,h,p),n}getPixels(t){const e=this.generateCanvas(t);return{pixels:e.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,e.width,e.height).data,width:e.width,height:e.height}}destroy(){}}sc.extension={type:[S.CanvasSystem],name:"texture"};const UO=[...Qs,$u,ku,sc,nc],$O=[Ws,$s,zs,Xs,ks,Du,Bu,Ls],kO=[av,Nu],Jv=[],tx=[],ex=[];N.handleByNamedList(S.CanvasSystem,Jv),N.handleByNamedList(S.CanvasPipes,tx),N.handleByNamedList(S.CanvasPipesAdaptor,ex),N.add(...UO,...$O,...kO);class rx extends Mr{constructor(){const t={name:"canvas",type:It.CANVAS,systems:Jv,renderPipes:tx,renderPipeAdaptors:ex};super(t)}}var LO={__proto__:null,CanvasRenderer:rx},Yi=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(Yi||{});class ix{constructor(t,e){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.type=e}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ac{constructor(t){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=t,this._managedBuffers=new Ut({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(t){return t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.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,n=this._nextBindBaseIndex;for(;i<2;){n>=this._maxBindings&&(n=this._minBaseLocation,i++);const s=this._boundBufferBases[n];if(s&&s._lastBindCallId===this._bindCallId){n++;continue}break}return e=n,this._nextBindBaseIndex=n+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,n){const{_gl:s}=this;i||(i=0),e||(e=0),this._boundBufferBases[e]=null,s.bindBufferRange(s.UNIFORM_BUFFER,e||0,t.buffer,i*256,n||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 n=t.data,s=t.descriptor.usage&at.STATIC?e.STATIC_DRAW:e.DYNAMIC_DRAW;return n?i.byteLength>=n.byteLength?e.bufferSubData(i.type,0,n,0,t._updateSize/n.BYTES_PER_ELEMENT):(i.byteLength=n.byteLength,e.bufferData(i.type,n,s)):(i.byteLength=t.descriptor.size,e.bufferData(i.type,i.byteLength,s)),i}destroyAll(t=!1){this._managedBuffers.removeAll(t)}onBufferUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||this._gl.deleteBuffer(i.buffer))}createGLBuffer(t){const{_gl:e}=this;let i=Yi.ARRAY_BUFFER;t.descriptor.usage&at.INDEX?i=Yi.ELEMENT_ARRAY_BUFFER:t.descriptor.usage&at.UNIFORM&&(i=Yi.UNIFORM_BUFFER);const n=new ix(e.createBuffer(),i);return t._gpuData[this._renderer.uid]=n,this._managedBuffers.add(t),n}resetState(){this._boundBufferBases=Object.create(null)}}ac.extension={type:[S.WebGLSystem],name:"buffer"};var NO=Object.defineProperty,XO=Object.defineProperties,jO=Object.getOwnPropertyDescriptors,nx=Object.getOwnPropertySymbols,HO=Object.prototype.hasOwnProperty,zO=Object.prototype.propertyIsEnumerable,sx=(r,t,e)=>t in r?NO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ta=(r,t)=>{for(var e in t||(t={}))HO.call(t,e)&&sx(r,e,t[e]);if(nx)for(var e of nx(t))zO.call(t,e)&&sx(r,e,t[e]);return r},ax=(r,t)=>XO(r,jO(t));const oc=class q1{constructor(t){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=t,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(t){this.gl=t,this._renderer.gl=t}init(t){var e,i;t=ta(ta({},q1.defaultOptions),t);let n=this.multiView=t.multiView;if(t.context&&n&&(ue("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),n=!1),n?this.canvas=H.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const s=this._renderer.background.alpha<1,a=(e=t.premultipliedAlpha)!=null?e:!0,o=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:s,premultipliedAlpha:a,antialias:o,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:(i=t.powerPreference)!=null?i:"default"})}}ensureCanvasSize(t){if(!this.multiView){t!==this.canvas&&ue("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:e}=this;(e.width{var e;this.gl.isContextLost()&&((e=this.extensions.loseContext)==null||e.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var t;(t=this.extensions.loseContext)==null||t.loseContext(),this._contextLossForced=!0}validateContext(t){const e=t.getContextAttributes();e&&e.stencil;const i=this.supports,n=this.webGLVersion===2,s=this.extensions;i.uint32Indices=n||!!s.uint32ElementIndex,i.uniformBufferObject=n,i.vertexArrayObject=n||!!s.vertexArrayObject,i.srgbTextures=n||!!s.srgb,i.nonPowOf2wrapping=n,i.nonPowOf2mipmaps=n,i.msaa=n,i.uint32Indices}};oc.extension={type:[S.WebGLSystem],name:"context"},oc.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let ox=oc;function lc(r,t){var e,i,n;for(const s in r.attributes){const a=r.attributes[s],o=t[s];o?((e=a.format)!=null||(a.format=o.format),(i=a.offset)!=null||(a.offset=o.offset),(n=a.instance)!=null||(a.instance=o.instance)):ue(`Attribute ${s} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}WO(r)}function WO(r){var t,e;const{buffers:i,attributes:n}=r,s={},a={};for(const o in i){const l=i[o];s[l.uid]=0,a[l.uid]=0}for(const o in n){const l=n[o];s[l.buffer.uid]+=Ie(l.format).stride}for(const o in n){const l=n[o];(t=l.stride)!=null||(l.stride=s[l.buffer.uid]),(e=l.start)!=null||(l.start=a[l.buffer.uid]),a[l.buffer.uid]+=Ie(l.format).stride}}var ea=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(ea||{}),ra=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(ra||{}),lx=(r=>(r[r.CLAMP=33071]="CLAMP",r[r.REPEAT=10497]="REPEAT",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r))(lx||{}),ct=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(ct||{});const ux={uint8x2:ct.UNSIGNED_BYTE,uint8x4:ct.UNSIGNED_BYTE,sint8x2:ct.BYTE,sint8x4:ct.BYTE,unorm8x2:ct.UNSIGNED_BYTE,unorm8x4:ct.UNSIGNED_BYTE,snorm8x2:ct.BYTE,snorm8x4:ct.BYTE,uint16x2:ct.UNSIGNED_SHORT,uint16x4:ct.UNSIGNED_SHORT,sint16x2:ct.SHORT,sint16x4:ct.SHORT,unorm16x2:ct.UNSIGNED_SHORT,unorm16x4:ct.UNSIGNED_SHORT,snorm16x2:ct.SHORT,snorm16x4:ct.SHORT,float16x2:ct.HALF_FLOAT,float16x4:ct.HALF_FLOAT,float32:ct.FLOAT,float32x2:ct.FLOAT,float32x3:ct.FLOAT,float32x4:ct.FLOAT,uint32:ct.UNSIGNED_INT,uint32x2:ct.UNSIGNED_INT,uint32x3:ct.UNSIGNED_INT,uint32x4:ct.UNSIGNED_INT,sint32:ct.INT,sint32x2:ct.INT,sint32x3:ct.INT,sint32x4:ct.INT};function cx(r){var t;return(t=ux[r])!=null?t:ux.float32}const VO={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class hx{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class uc{constructor(t){this._renderer=t,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new Ut({renderer:t,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}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");this.destroyAll(!0);const e=this._renderer.context.extensions.vertexArrayObject;e&&(t.createVertexArray=()=>e.createVertexArrayOES(),t.bindVertexArray=n=>e.bindVertexArrayOES(n),t.deleteVertexArray=n=>e.deleteVertexArrayOES(n));const i=this._renderer.context.extensions.vertexAttribDivisorANGLE;i&&(t.drawArraysInstanced=(n,s,a,o)=>{i.drawArraysInstancedANGLE(n,s,a,o)},t.drawElementsInstanced=(n,s,a,o,l)=>{i.drawElementsInstancedANGLE(n,s,a,o,l)},t.vertexAttribDivisor=(n,s)=>i.vertexAttribDivisorANGLE(n,s)),this._activeGeometry=null,this._activeVao=null}bind(t,e){const i=this.gl;this._activeGeometry=t;const n=this.getVao(t,e);this._activeVao!==n&&(this._activeVao=n,i.bindVertexArray(n)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const t=this._activeGeometry,e=this._renderer.buffer;for(let i=0;it in r?YO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,fx=(r,t)=>{for(var e in t||(t={}))KO.call(t,e)&&px(r,e,t[e]);if(dx)for(var e of dx(t))qO.call(t,e)&&px(r,e,t[e]);return r};const ZO=new nr({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),cc=class Z1{constructor(t){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=t}init(t={}){const{useBackBuffer:e,antialias:i}=fx(fx({},Z1.defaultOptions),t);this.useBackBuffer=e,this._antialias=i,this._renderer.context.supports.msaa||(ue("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=Vt.for2d();const n=new Wt({vertex:` attribute vec2 aPosition; out vec2 vUv; @@ -1813,7 +1813,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { void main() { finalColor = texture(uTexture, vUv); - }`,name:"big-triangle"});this._bigTriangleShader=new ee({glProgram:n,resources:{uTexture:D.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:HO,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new D({source:new ft({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)}};uc.extension={type:[S.WebGLSystem],name:"backBuffer",priority:1},uc.defaultOptions={useBackBuffer:!1};let mx=uc;class cc{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}cc.extension={type:[S.WebGLSystem],name:"colorMask"};class hc{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:n,state:s,skipSync:a,topology:o,size:l,start:u,instanceCount:c}=t;e.shader.bind(n,a),e.geometry.bind(i,e.shader._activeProgram),s&&e.state.set(s),e.geometry.draw(o,l,u,c!=null?c:i.instanceCount)}destroy(){this._renderer=null}}hc.extension={type:[S.WebGLSystem],name:"encoder"};class dc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Wo(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}dc.extension={type:[S.WebGLSystem],name:"limits"};class gx{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const Ue=[];Ue[wt.NONE]=void 0,Ue[wt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Ue[wt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Ue[wt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Ue[wt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Ue[wt.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}};class pc{constructor(t){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:wt.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:wt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=wt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,s=Ue[t],a=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===wt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),(t!==a.stencilMode||a.stencilReference!==e)&&(a.stencilMode=t,a.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[s.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[s.stencilBack.passOp]))}}pc.extension={type:[S.WebGLSystem],name:"stencil"};class fc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Ro())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 Yt({data:new Float32Array(e.layout.size/4),usage:at.UNIFORM|at.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 n=Object.keys(t.uniformStructures).map(o=>t.uniformStructures[o]),s=this._adaptor.createUboElements(n),a=this._generateUboSync(s.uboElements);i=this._syncFunctionHash[e]={layout:s,syncFunction:a}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const n=this.getUniformGroupData(t);t.buffer||(t.buffer=new Yt({data:new Float32Array(n.layout.size/4),usage:at.UNIFORM|at.COPY_DST}));let s=null;return e||(e=t.buffer.data,s=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,s,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 mc={f32:4,i32:4,"vec2":8,"vec3":12,"vec4":16,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function _x(r){const t=r.map(s=>({data:s,offset:0,size:0})),e=16;let i=0,n=0;for(let s=0;s1&&(i=Math.max(i,e)*a.data.size);const o=i===12?16:i;a.size=i;const l=n%e;l>0&&e-l",test:r=>r.value.a!==void 0,ubo:` + }`,name:"big-triangle"});this._bigTriangleShader=new ee({glProgram:n,resources:{uTexture:D.WHITE.source}})}renderStart(t){const e=this._renderer.renderTarget.getRenderTarget(t.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!e.isRoot,this._useBackBufferThisRender){const i=this._renderer.renderTarget.getRenderTarget(t.target);this._targetTexture=i.colorTexture,t.target=this._getBackBufferTexture(i.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const t=this._renderer;t.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(t.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,t.encoder.draw({geometry:ZO,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(t){return this._backBufferTexture=this._backBufferTexture||new D({source:new ft({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)}};cc.extension={type:[S.WebGLSystem],name:"backBuffer",priority:1},cc.defaultOptions={useBackBuffer:!1};let mx=cc;class hc{constructor(t){this._colorMaskCache=15,this._renderer=t}setMask(t){this._colorMaskCache!==t&&(this._colorMaskCache=t,this._renderer.gl.colorMask(!!(t&8),!!(t&4),!!(t&2),!!(t&1)))}}hc.extension={type:[S.WebGLSystem],name:"colorMask"};class dc{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:n,state:s,skipSync:a,topology:o,size:l,start:u,instanceCount:c}=t;e.shader.bind(n,a),e.geometry.bind(i,e.shader._activeProgram),s&&e.state.set(s),e.geometry.draw(o,l,u,c!=null?c:i.instanceCount)}destroy(){this._renderer=null}}dc.extension={type:[S.WebGLSystem],name:"encoder"};class pc{constructor(t){this._renderer=t}contextChange(){const t=this._renderer.gl;this.maxTextures=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Vo(this.maxTextures,t);const e=this._renderer.context.webGLVersion===2;this.maxUniformBindings=e?t.getParameter(t.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}pc.extension={type:[S.WebGLSystem],name:"limits"};class gx{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}const Ue=[];Ue[wt.NONE]=void 0,Ue[wt.DISABLED]={stencilWriteMask:0,stencilReadMask:0},Ue[wt.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},Ue[wt.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},Ue[wt.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},Ue[wt.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:wt.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:wt.DISABLED,stencilReference:0}),this.setStencilMode(e.stencilMode,e.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=wt.NONE,this._stencilCache.stencilReference=0}setStencilMode(t,e){const i=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,s=Ue[t],a=this._stencilCache;if(i.stencilMode=t,i.stencilReference=e,t===wt.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),(t!==a.stencilMode||a.stencilReference!==e)&&(a.stencilMode=t,a.stencilReference=e,n.stencilFunc(this._comparisonFuncMapping[s.stencilBack.compare],e,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[s.stencilBack.passOp]))}}fc.extension={type:[S.WebGLSystem],name:"stencil"};class mc{constructor(t){this._syncFunctionHash=Object.create(null),this._adaptor=t,this._systemCheck()}_systemCheck(){if(!Oo())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 Yt({data:new Float32Array(e.layout.size/4),usage:at.UNIFORM|at.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 n=Object.keys(t.uniformStructures).map(o=>t.uniformStructures[o]),s=this._adaptor.createUboElements(n),a=this._generateUboSync(s.uboElements);i=this._syncFunctionHash[e]={layout:s,syncFunction:a}}return this._syncFunctionHash[e]}_generateUboSync(t){return this._adaptor.generateUboSync(t)}syncUniformGroup(t,e,i){const n=this.getUniformGroupData(t);t.buffer||(t.buffer=new Yt({data:new Float32Array(n.layout.size/4),usage:at.UNIFORM|at.COPY_DST}));let s=null;return e||(e=t.buffer.data,s=t.buffer.dataInt32),i||(i=0),n.syncFunction(t.uniforms,e,s,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 gc={f32:4,i32:4,"vec2":8,"vec3":12,"vec4":16,"vec2":8,"vec3":12,"vec4":16,"mat2x2":32,"mat3x3":48,"mat4x4":64};function _x(r){const t=r.map(s=>({data:s,offset:0,size:0})),e=16;let i=0,n=0;for(let s=0;s1&&(i=Math.max(i,e)*a.data.size);const o=i===12?16:i;a.size=i;const l=n%e;l>0&&e-l",test:r=>r.value.a!==void 0,ubo:` var matrix = uv[name].toArray(true); data[offset] = matrix[0]; data[offset + 1] = matrix[1]; @@ -1884,7 +1884,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { cv[2] = v.blue; gl.uniform3f(ud[name].location, v.red, v.green, v.blue); } - `}];function gc(r,t,e,i){const n=[` + `}];function _c(r,t,e,i){const n=[` var v = null; var v2 = null; var t = 0; @@ -1896,11 +1896,11 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { offset += ${h-s}; ${p}; `)}s=h}const a=n.join(` -`);return new Function("uv","data","dataInt32","offset",a)}var zO=Object.defineProperty,WO=Object.defineProperties,VO=Object.getOwnPropertyDescriptors,yx=Object.getOwnPropertySymbols,YO=Object.prototype.hasOwnProperty,KO=Object.prototype.propertyIsEnumerable,bx=(r,t,e)=>t in r?zO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,qO=(r,t)=>{for(var e in t||(t={}))YO.call(t,e)&&bx(r,e,t[e]);if(yx)for(var e of yx(t))KO.call(t,e)&&bx(r,e,t[e]);return r},ZO=(r,t)=>WO(r,VO(t));function ti(r,t){return` +`);return new Function("uv","data","dataInt32","offset",a)}var QO=Object.defineProperty,JO=Object.defineProperties,t3=Object.getOwnPropertyDescriptors,yx=Object.getOwnPropertySymbols,e3=Object.prototype.hasOwnProperty,r3=Object.prototype.propertyIsEnumerable,bx=(r,t,e)=>t in r?QO(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,i3=(r,t)=>{for(var e in t||(t={}))e3.call(t,e)&&bx(r,e,t[e]);if(yx)for(var e of yx(t))r3.call(t,e)&&bx(r,e,t[e]);return r},n3=(r,t)=>JO(r,t3(t));function ti(r,t){return` for (let i = 0; i < ${r*t}; i++) { data[offset + (((i / ${r})|0) * 4) + (i % ${r})] = v[i]; } - `}const _c={f32:` + `}const yc={f32:` data[offset] = v;`,i32:` dataInt32[offset] = v;`,"vec2":` data[offset] = v[0]; @@ -1936,12 +1936,12 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { data[offset + 10] = v[8];`,"mat4x4":` for (let i = 0; i < 16; i++) { data[offset + i] = v[i]; - }`,"mat3x2":ti(3,2),"mat4x2":ti(4,2),"mat2x3":ti(2,3),"mat4x3":ti(4,3),"mat2x4":ti(2,4),"mat3x4":ti(3,4)},vx=ZO(qO({},_c),{"mat2x2":` + }`,"mat3x2":ti(3,2),"mat4x2":ti(4,2),"mat2x3":ti(2,3),"mat4x3":ti(4,3),"mat2x4":ti(2,4),"mat3x4":ti(3,4)},vx=n3(i3({},yc),{"mat2x2":` data[offset] = v[0]; data[offset + 1] = v[1]; data[offset + 2] = v[2]; data[offset + 3] = v[3]; - `});function xx(r,t){const e=Math.max(mc[r.data.type]/16,1),i=r.data.value.length/r.data.size,n=(4-i%4)%4,s=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return` + `});function xx(r,t){const e=Math.max(gc[r.data.type]/16,1),i=r.data.value.length/r.data.size,n=(4-i%4)%4,s=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return` v = uv.${r.data.name}; offset += ${t}; @@ -1957,7 +1957,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { } ${n!==0?`arrayOffset += ${n};`:""} } - `}function Tx(r){return gc(r,"uboStd40",xx,_c)}class yc extends fc{constructor(){super({createUboElements:_x,generateUboSync:Tx})}}yc.extension={type:[S.WebGLSystem],name:"ubo"};class Sx{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(i,n)=>t.COLOR_ATTACHMENT0+n)}copyToTexture(t,e,i,n,s){const a=this._renderTargetSystem,o=this._renderer,l=a.getGpuRenderTarget(t),u=o.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),o.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,s.x,s.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n,s=0,a=0){const o=this._renderTargetSystem,l=t.colorTexture,u=o.getGpuRenderTarget(t);if(a!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(s>0){if(u.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let c=n.y;t.isRoot&&(c=l.pixelHeight-n.height-n.y),t.colorTextures.forEach(f=>{this._renderer.texture.unbind(f)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,u.framebuffer),!t.isRoot&&(u._attachedMipLevel!==s||u._attachedLayer!==a)&&(t.colorTextures.forEach((f,m)=>{const g=this._renderer.texture.getGlSource(f);if(g.target===h.TEXTURE_2D){if(a!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,h.TEXTURE_2D,g.texture,s)}else if(g.target===h.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");h.framebufferTextureLayer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,g.texture,s,a)}else if(g.target===h.TEXTURE_CUBE_MAP){if(a<0||a>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,h.TEXTURE_CUBE_MAP_POSITIVE_X+a,g.texture,s)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),u._attachedMipLevel=s,u._attachedLayer=a),t.colorTextures.length>1&&this._setDrawBuffers(t,h);const p=this._viewPortCache;(p.x!==n.x||p.y!==c||p.width!==n.width||p.height!==n.height)&&(p.x=n.x,p.y=c,p.width=n.width,p.height=n.height,h.viewport(n.x,c,n.width,n.height)),!u.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(u),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 gx;return i._attachedMipLevel=0,i._attachedLayer=0,t.colorTexture instanceof fe?(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(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i,n,s=0,a=0){if(!e)return;if(a!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const o=this._renderTargetSystem;typeof e=="boolean"&&(e=e?Kt.ALL:Kt.NONE);const l=this._renderer.gl;if(e&Kt.COLOR){i!=null||(i=o.defaultClearColor);const u=this._clearColorCache,c=i;(u[0]!==c[0]||u[1]!==c[1]||u[2]!==c[2]||u[3]!==c[3])&&(u[0]=c[0],u[1]=c[1],u[2]=c[2],u[3]=c[3],l.clearColor(c[0],c[1],c[2],c[3]))}l.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,n=i.gl,s=n.createFramebuffer();if(e.resolveTargetFramebuffer=s,n.bindFramebuffer(n.FRAMEBUFFER,s),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,o)=>{const l=a.source;l.antialias&&(i.context.supports.msaa?e.msaa=!0:ue("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(l,0);const u=i.texture.getGlSource(l),c=u.texture;if(u.target===n.TEXTURE_2D)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.TEXTURE_2D,c,0);else if(u.target===n.TEXTURE_2D_ARRAY){if(i.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");n.framebufferTextureLayer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,c,0,0)}else if(u.target===n.TEXTURE_CUBE_MAP)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.TEXTURE_CUBE_MAP_POSITIVE_X,c,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){const a=n.createFramebuffer();e.framebuffer=a,n.bindFramebuffer(n.FRAMEBUFFER,a),t.colorTextures.forEach((o,l)=>{const u=n.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=s;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,e._attachedMipLevel=0,e._attachedLayer=0,t.colorTextures.forEach((n,s)=>{s!==0&&n.source.resize(i.width,i.height,i._resolution)}),e.msaa){const n=this._renderer,s=n.gl,a=e.framebuffer;s.bindFramebuffer(s.FRAMEBUFFER,a),t.colorTextures.forEach((o,l)=>{const u=o.source;n.texture.bindSource(u,0);const c=n.texture.getGlSource(u).internalFormat,h=e.msaaRenderBuffer[l];s.bindRenderbuffer(s.RENDERBUFFER,h),s.renderbufferStorageMultisample(s.RENDERBUFFER,4,c,u.pixelWidth,u.pixelHeight),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+l,s.RENDERBUFFER,h)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&fe.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&fe.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}_setDrawBuffers(t,e){const i=t.colorTextures.length,n=this._drawBuffersCache[i];if(this._renderer.context.webGLVersion===1){const s=this._renderer.context.extensions.drawBuffers;s?s.drawBuffersWEBGL(n):ue("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(n)}}class bc extends Zs{constructor(t){super(t),this.adaptor=new Sx,this.adaptor.init(t,this)}}bc.extension={type:[S.WebGLSystem],name:"renderTarget"};class ea extends Nt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=ht("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=ht("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=ht("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function wx(r,t){const e=[],i=[` + `}function Tx(r){return _c(r,"uboStd40",xx,yc)}class bc extends mc{constructor(){super({createUboElements:_x,generateUboSync:Tx})}}bc.extension={type:[S.WebGLSystem],name:"ubo"};class Sx{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut}init(t,e){this._renderer=t,this._renderTargetSystem=e,t.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ut;const t=this._renderer.gl;this._drawBuffersCache=[];for(let e=1;e<=16;e++)this._drawBuffersCache[e]=Array.from({length:e},(i,n)=>t.COLOR_ATTACHMENT0+n)}copyToTexture(t,e,i,n,s){const a=this._renderTargetSystem,o=this._renderer,l=a.getGpuRenderTarget(t),u=o.gl;return this.finishRenderPass(t),u.bindFramebuffer(u.FRAMEBUFFER,l.resolveTargetFramebuffer),o.texture.bind(e,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,s.x,s.y,i.x,i.y,n.width,n.height),e}startRenderPass(t,e=!0,i,n,s=0,a=0){const o=this._renderTargetSystem,l=t.colorTexture,u=o.getGpuRenderTarget(t);if(a!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(s>0){if(u.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let c=n.y;t.isRoot&&(c=l.pixelHeight-n.height-n.y),t.colorTextures.forEach(f=>{this._renderer.texture.unbind(f)});const h=this._renderer.gl;h.bindFramebuffer(h.FRAMEBUFFER,u.framebuffer),!t.isRoot&&(u._attachedMipLevel!==s||u._attachedLayer!==a)&&(t.colorTextures.forEach((f,m)=>{const g=this._renderer.texture.getGlSource(f);if(g.target===h.TEXTURE_2D){if(a!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,h.TEXTURE_2D,g.texture,s)}else if(g.target===h.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");h.framebufferTextureLayer(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,g.texture,s,a)}else if(g.target===h.TEXTURE_CUBE_MAP){if(a<0||a>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0+m,h.TEXTURE_CUBE_MAP_POSITIVE_X+a,g.texture,s)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),u._attachedMipLevel=s,u._attachedLayer=a),t.colorTextures.length>1&&this._setDrawBuffers(t,h);const p=this._viewPortCache;(p.x!==n.x||p.y!==c||p.width!==n.width||p.height!==n.height)&&(p.x=n.x,p.y=c,p.width=n.width,p.height=n.height,h.viewport(n.x,c,n.width,n.height)),!u.depthStencilRenderBuffer&&(t.stencil||t.depth)&&this._initStencil(u),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 gx;return i._attachedMipLevel=0,i._attachedLayer=0,t.colorTexture instanceof fe?(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(i=>{e.deleteRenderbuffer(i)}),t.msaaRenderBuffer=null}clear(t,e,i,n,s=0,a=0){if(!e)return;if(a!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const o=this._renderTargetSystem;typeof e=="boolean"&&(e=e?Kt.ALL:Kt.NONE);const l=this._renderer.gl;if(e&Kt.COLOR){i!=null||(i=o.defaultClearColor);const u=this._clearColorCache,c=i;(u[0]!==c[0]||u[1]!==c[1]||u[2]!==c[2]||u[3]!==c[3])&&(u[0]=c[0],u[1]=c[1],u[2]=c[2],u[3]=c[3],l.clearColor(c[0],c[1],c[2],c[3]))}l.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,n=i.gl,s=n.createFramebuffer();if(e.resolveTargetFramebuffer=s,n.bindFramebuffer(n.FRAMEBUFFER,s),e.width=t.colorTexture.source.pixelWidth,e.height=t.colorTexture.source.pixelHeight,t.colorTextures.forEach((a,o)=>{const l=a.source;l.antialias&&(i.context.supports.msaa?e.msaa=!0:ue("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),i.texture.bindSource(l,0);const u=i.texture.getGlSource(l),c=u.texture;if(u.target===n.TEXTURE_2D)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.TEXTURE_2D,c,0);else if(u.target===n.TEXTURE_2D_ARRAY){if(i.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");n.framebufferTextureLayer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,c,0,0)}else if(u.target===n.TEXTURE_CUBE_MAP)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+o,n.TEXTURE_CUBE_MAP_POSITIVE_X,c,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),e.msaa){const a=n.createFramebuffer();e.framebuffer=a,n.bindFramebuffer(n.FRAMEBUFFER,a),t.colorTextures.forEach((o,l)=>{const u=n.createRenderbuffer();e.msaaRenderBuffer[l]=u})}else e.framebuffer=s;this._resizeColor(t,e)}_resizeColor(t,e){const i=t.colorTexture.source;if(e.width=i.pixelWidth,e.height=i.pixelHeight,e._attachedMipLevel=0,e._attachedLayer=0,t.colorTextures.forEach((n,s)=>{s!==0&&n.source.resize(i.width,i.height,i._resolution)}),e.msaa){const n=this._renderer,s=n.gl,a=e.framebuffer;s.bindFramebuffer(s.FRAMEBUFFER,a),t.colorTextures.forEach((o,l)=>{const u=o.source;n.texture.bindSource(u,0);const c=n.texture.getGlSource(u).internalFormat,h=e.msaaRenderBuffer[l];s.bindRenderbuffer(s.RENDERBUFFER,h),s.renderbufferStorageMultisample(s.RENDERBUFFER,4,c,u.pixelWidth,u.pixelHeight),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+l,s.RENDERBUFFER,h)})}}_initStencil(t){if(t.framebuffer===null)return;const e=this._renderer.gl,i=e.createRenderbuffer();t.depthStencilRenderBuffer=i,e.bindRenderbuffer(e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,i),this._resizeStencil(t)}_resizeStencil(t){const e=this._renderer.gl;e.bindRenderbuffer(e.RENDERBUFFER,t.depthStencilRenderBuffer),t.msaa?e.renderbufferStorageMultisample(e.RENDERBUFFER,4,e.DEPTH24_STENCIL8,t.width,t.height):e.renderbufferStorage(e.RENDERBUFFER,this._renderer.context.webGLVersion===2?e.DEPTH24_STENCIL8:e.DEPTH_STENCIL,t.width,t.height)}prerender(t){const e=t.colorTexture.resource;this._renderer.context.multiView&&fe.test(e)&&this._renderer.context.ensureCanvasSize(e)}postrender(t){if(this._renderer.context.multiView&&fe.test(t.colorTexture.resource)){const e=this._renderer.context.canvas,i=t.colorTexture;i.context2D.drawImage(e,0,i.pixelHeight-e.height)}}_setDrawBuffers(t,e){const i=t.colorTextures.length,n=this._drawBuffersCache[i];if(this._renderer.context.webGLVersion===1){const s=this._renderer.context.extensions.drawBuffers;s?s.drawBuffersWEBGL(n):ue("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else e.drawBuffers(n)}}class vc extends Js{constructor(t){super(t),this.adaptor=new Sx,this.adaptor.init(t,this)}}vc.extension={type:[S.WebGLSystem],name:"renderTarget"};class ia extends Nt{constructor({buffer:t,offset:e,size:i}){super(),this.uid=ht("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=ht("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=t,this.offset=e|0,this.size=i,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=ht("resource"),this.emit("change",this)}destroy(t=!1){this.destroyed=!0,t&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}function wx(r,t){const e=[],i=[` var g = s.groups; var sS = r.shader; var p = s.glProgram; @@ -1973,7 +1973,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { ); `)}else e.push(` ugS.updateUniformGroup(resources[${c}], p, sD); - `);else if(h instanceof ea){const p=r._uniformBindMap[l][Number(c)];e.push(` + `);else if(h instanceof ia){const p=r._uniformBindMap[l][Number(c)];e.push(` sS.bindUniformBlock( resources[${c}], '${p}', @@ -1984,10 +1984,10 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { `)),t._gl.uniform1i(f.location,s),e.push(` tS.bind(resources[${c}], ${s}); `),s++)}}}const o=[...i,...e].join(` -`);return new Function("r","s","sD",o)}class QO{}class Px{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function vc(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function xc(r){const t=new Array(r);for(let e=0;ea>o?1:-1);for(let a=0;a`${c}: ${u}`),i=r.getShaderInfoLog(t),n=i.split(` -`),s={},a=n.map(u=>parseFloat(u.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(u=>u&&!s[u]?(s[u]=!0,!0):!1),o=[""];a.forEach(u=>{e[u-1]=`%c${e[u-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const l=e.join(` -`);o[0]=l,console.error(i),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function Gx(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Ox(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Ox(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function Ix(r,t){const e=vc(r,r.VERTEX_SHADER,t.vertex),i=vc(r,r.FRAGMENT_SHADER,t.fragment),n=r.createProgram();r.attachShader(n,e),r.attachShader(n,i);const s=t.transformFeedbackVaryings;s&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(n),r.getProgramParameter(n,r.LINK_STATUS)||Gx(r,n,e,i),t._attributeData=Cx(n,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Rx(n,r),t._uniformBlockData=Mx(n,r),r.deleteShader(e),r.deleteShader(i);const a={};for(const o in t._uniformData){const l=t._uniformData[o];a[o]={location:r.getUniformLocation(n,o),value:Tc(l.type,l.size)}}return new Px(n,a)}const ia={textureCount:0,blockIndex:0};class wc{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}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;ia.textureCount=0,ia.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,ia)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,ia)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,s=this._getProgramData(this._activeProgram),a=t._bufferResource;a||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,l=n.updateBuffer(o),u=n.freeLocationForBufferBase(l);if(a){const{offset:h,size:p}=t;h===0&&p===o.data.byteLength?n.bindBufferBase(l,u):n.bindBufferRange(l,u,h)}else n.getLastBindBaseLocation(l)!==u&&n.bindBufferBase(l,u);const c=this._activeProgram._uniformBlockData[e].index;s.uniformBlockBindings[i]!==u&&(s.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(s.program,c,u))}_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]=Ix(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return wx(t,e)}resetState(){this._activeProgram=null}}wc.extension={type:[S.WebGLSystem],name:"shader"};const Bx={f32:`if (cv !== v) { +`);return new Function("r","s","sD",o)}class s3{}class Ex{constructor(t,e){this.program=t,this.uniformData=e,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function xc(r,t,e){const i=r.createShader(t);return r.shaderSource(i,e),r.compileShader(i),i}function Tc(r){const t=new Array(r);for(let e=0;ea>o?1:-1);for(let a=0;a`${p}: ${h}`),s=(e=r.getShaderInfoLog(t))!=null?e:"",a=s.split(` +`),o={},l=a.map(h=>parseFloat(h.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(h=>h&&!o[h]?(o[h]=!0,!0):!1),u=[""];l.forEach(h=>{n[h-1]=`%c${n[h-1]}%c`,u.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const c=n.join(` +`);u[0]=c,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...u),console.groupEnd()}function Gx(r,t,e,i){r.getProgramParameter(t,r.LINK_STATUS)||(r.getShaderParameter(e,r.COMPILE_STATUS)||Ox(r,e),r.getShaderParameter(i,r.COMPILE_STATUS)||Ox(r,i),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(t)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(t)))}function Ix(r,t){const e=xc(r,r.VERTEX_SHADER,t.vertex),i=xc(r,r.FRAGMENT_SHADER,t.fragment),n=r.createProgram();r.attachShader(n,e),r.attachShader(n,i);const s=t.transformFeedbackVaryings;s&&(typeof r.transformFeedbackVaryings!="function"||r.transformFeedbackVaryings(n,s.names,s.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(n),r.getProgramParameter(n,r.LINK_STATUS)||Gx(r,n,e,i),t._attributeData=Cx(n,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=Rx(n,r),t._uniformBlockData=Mx(n,r),r.deleteShader(e),r.deleteShader(i);const a={};for(const o in t._uniformData){const l=t._uniformData[o];a[o]={location:r.getUniformLocation(n,o),value:Sc(l.type,l.size)}}return new Ex(n,a)}const sa={textureCount:0,blockIndex:0};class Ec{constructor(t){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=t}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;sa.textureCount=0,sa.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,sa)}updateUniformGroup(t){this._renderer.uniformGroup.updateUniformGroup(t,this._activeProgram,sa)}bindUniformBlock(t,e,i=0){const n=this._renderer.buffer,s=this._getProgramData(this._activeProgram),a=t._bufferResource;a||this._renderer.ubo.updateUniformGroup(t);const o=t.buffer,l=n.updateBuffer(o),u=n.freeLocationForBufferBase(l);if(a){const{offset:h,size:p}=t;h===0&&p===o.data.byteLength?n.bindBufferBase(l,u):n.bindBufferRange(l,u,h)}else n.getLastBindBaseLocation(l)!==u&&n.bindBufferBase(l,u);const c=this._activeProgram._uniformBlockData[e].index;s.uniformBlockBindings[i]!==u&&(s.uniformBlockBindings[i]=u,this._renderer.gl.uniformBlockBinding(s.program,c,u))}_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]=Ix(this._gl,t),this._programDataHash[e]}destroy(){for(const t of Object.keys(this._programDataHash))this._programDataHash[t].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(t,e){return wx(t,e)}resetState(){this._activeProgram=null}}Ec.extension={type:[S.WebGLSystem],name:"shader"};const Bx={f32:`if (cv !== v) { cu.value = v; gl.uniform1f(location, v); }`,"vec2":`if (cv[0] !== v[0] || cv[1] !== v[1]) { @@ -2070,17 +2070,17 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { renderer.shader.bindUniformBlock(uv.${i}, "${i}"); `):e.push(` renderer.shader.updateUniformGroup(uv.${i}); - `):r.uniforms[i]instanceof ea&&e.push(` + `):r.uniforms[i]instanceof ia&&e.push(` renderer.shader.bindBufferResource(uv.${i}, "${i}"); `);continue}const n=r.uniformStructures[i];let s=!1;for(let a=0;a>=1,i++;this.stateId=t.data}for(let e=0;e>1,1),l=Math.max(l>>1,1)}}},Xx=["right","left","top","bottom","front","back"];function jx(r){return{id:"cube",upload(t,e,i,n){const s=t.faces;for(let a=0;a=o&&c>=l,m=r.resource;(h?c3:h3)(e,a,t,o,l,u,c,m,p,f),t.width=o,t.height=l}};function c3(r,t,e,i,n,s,a,o,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,s,a,e.format,e.type,o);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,o)}function h3(r,t,e,i,n,s,a,o,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}r.texImage2D(t,0,e.internalFormat,e.format,e.type,o)}const d3=Au(),Hx={id:"video",upload(r,t,e,i,n,s=d3){if(!r.isValid){const a=n!=null?n:t.target;e.texImage2D(a,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Ac.upload(r,t,e,i,n,s)}},Cc={linear:9729,nearest:9728},zx={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},na={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Wx={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Mc(r,t,e,i,n,s,a,o){const l=s;if(!o||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=na[a?"clamp-to-edge":r.addressModeU],c=na[a?"clamp-to-edge":r.addressModeV],h=na[a?"clamp-to-edge":r.addressModeW];t[n](l,t.TEXTURE_WRAP_S,u),t[n](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[n](l,t.TEXTURE_WRAP_R,h)}if((!o||r.magFilter!=="linear")&&t[n](l,t.TEXTURE_MAG_FILTER,Cc[r.magFilter]),e){if(!o||r.mipmapFilter!=="linear"){const u=zx[r.minFilter][r.mipmapFilter];t[n](l,t.TEXTURE_MIN_FILTER,u)}}else t[n](l,t.TEXTURE_MIN_FILTER,Cc[r.minFilter]);if(i&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[n](l,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[n](l,t.TEXTURE_COMPARE_FUNC,Wx[r.compare])}function Vx(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}var p3=Object.defineProperty,f3=Object.defineProperties,m3=Object.getOwnPropertyDescriptors,Yx=Object.getOwnPropertySymbols,g3=Object.prototype.hasOwnProperty,_3=Object.prototype.propertyIsEnumerable,Kx=(r,t,e)=>t in r?p3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mr=(r,t)=>{for(var e in t||(t={}))g3.call(t,e)&&Kx(r,e,t[e]);if(Yx)for(var e of Yx(t))_3.call(t,e)&&Kx(r,e,t[e]);return r},y3=(r,t)=>f3(r,m3(t));function qx(r,t){let e={},i=r.RGBA;return r instanceof H.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},i=r.RGBA8),mr(mr(mr(mr(mr(mr(y3(mr({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:i,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function Zx(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function Qx(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}function b3(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;et in r?v3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P3=(r,t)=>{for(var e in t||(t={}))S3.call(t,e)&&t0(r,e,t[e]);if(Jx)for(var e of Jx(t))w3.call(t,e)&&t0(r,e,t[e]);return r},E3=(r,t)=>x3(r,T3(t));const A3=4;class Rc{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new Ut({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const e={image:Ac,buffer:Lx,video:Hx,compressed:Nx};this._uploads=E3(P3({},e),{cube:jx(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=qx(t,this._renderer.context.extensions),this._mapFormatToType=Zx(t),this._mapFormatToFormat=Vx(t),this._mapViewDimensionToGlTarget=Qx(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(D.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=D.EMPTY.source);const n=this.getGlSource(t);i.bindTexture(n.target,n.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const n=this._getGlSampler(t);this._boundSamplers[e]!==n&&(this._boundSamplers[e]=n,i.bindSampler(e,n))}unbind(t){const e=t.source,i=this._boundTextures,n=this._gl;for(let s=0;s1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",n.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||(this.unbind(t),this._gl.deleteTexture(i.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=t;const n=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==n&&(this._premultiplyAlpha=n,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion);else if(i.target===e.TEXTURE_2D)this._initEmptyTexture2D(i,t);else if(i.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(i,t);else if(i.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(i,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(i,t),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)}_initEmptyTexture2D(t,e){const i=this._gl;i.texImage2D(i.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),s=Math.max(e.pixelHeight>>1,1);for(let a=1;a>1,1),s=Math.max(s>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const i=this._gl,n=Math.max(e.arrayLayerCount|0,1);i.texImage3D(i.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,n,0,t.format,t.type,null);let s=Math.max(e.pixelWidth>>1,1),a=Math.max(e.pixelHeight>>1,1);for(let o=1;o>1,1),a=Math.max(a>>1,1)}_initEmptyTextureCube(t,e){const i=this._gl,n=6;for(let o=0;o>1,1),a=Math.max(e.pixelHeight>>1,1);for(let o=1;o>1,1),a=Math.max(a>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2||e.mipLevelCount<=1)return;const i=this._gl,n=Math.max((e.mipLevelCount|0)-1,0);i.texParameteri(t.target,i.TEXTURE_BASE_LEVEL,0),i.texParameteri(t.target,i.TEXTURE_MAX_LEVEL,n)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Mc(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 t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:n}=this.getPixels(t),s=H.get().createCanvas();s.width=i,s.height=n;const a=s.getContext("2d");if(a){const o=a.createImageData(i,n);o.data.set(e),a.putImageData(o,0,0)}return s}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),s=Math.max(Math.round(i.height*e),1),a=new Uint8Array(A3*n*s),o=this._renderer,l=o.renderTarget.getRenderTarget(t),u=o.renderTarget.getGpuRenderTarget(l),c=o.gl;return c.bindFramebuffer(c.FRAMEBUFFER,u.resolveTargetFramebuffer),c.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,s,c.RGBA,c.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:n,height:s}}destroy(){this._managedTextures.destroy(),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(D.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}Rc.extension={type:[S.WebGLSystem],name:"texture"};class Oc{contextChange(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new U,type:"mat3x3"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=Dr({name:"graphics",bits:[Nn,jn(i),vs,$r]});this.shader=new ee({glProgram:n,resources:{localUniforms:e,batchSamplers:Hn(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,a=s.graphicsContext,{batcher:o,instructions:l}=a.getContextRenderData(i);n.groups[0]=s.globalUniforms.bindGroup,s.state.set(t.state),s.shader.bind(n),s.geometry.bind(o.geometry,n.glProgram);const u=l.instructions;for(let c=0;c",value:new U}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return}else{n=this._shader;const s=e.texture,a=s.source;n.resources.uTexture=a,n.resources.uSampler=a.style,n.resources.textureUniforms.uniforms.uTextureMatrix=s.textureMatrix.mapCoord}n.groups[100]=i.globalUniforms.bindGroup,n.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Gc.extension={type:[S.WebGLPipesAdaptor],name:"mesh"};const C3=[...qs,yc,mx,ox,dc,sc,Rc,bc,lc,Pc,wc,hc,kx,pc,cc],M3=[...rc],R3=[Ru,Gc,Oc],e0=[],r0=[],i0=[];X.handleByNamedList(S.WebGLSystem,e0),X.handleByNamedList(S.WebGLPipes,r0),X.handleByNamedList(S.WebGLPipesAdaptor,i0),X.add(...C3,...M3,...R3);class n0 extends Mr{constructor(){const t={name:"webgl",type:It.WEBGL,systems:e0,renderPipes:r0,renderPipeAdaptors:i0};super(t)}}var O3={__proto__:null,WebGLRenderer:n0};class Ic{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var n;const s=this._gpu.device,a=e.layout[i],o=[],l=this._renderer;for(const h in a){const p=(n=t.resources[h])!=null?n:t.resources[a[h]];let f;if(p._resourceType==="uniformGroup"){const m=p;l.ubo.updateUniformGroup(m);const g=m.buffer;f={buffer:l.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(p._resourceType==="buffer"){const m=p;f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(p._resourceType==="bufferResource"){const m=p;f={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if(p._resourceType==="textureSampler"){const m=p;f=l.texture.getGpuSampler(m)}else if(p._resourceType==="textureSource"){const m=p;f=l.texture.getTextureView(m)}o.push({binding:a[h],resource:f})}const u=l.shader.getProgramData(e).bindGroups[i],c=s.createBindGroup({layout:u,entries:o});return this._hash[t._key]=c,c}destroy(){this._hash=null,this._renderer=null}}Ic.extension={type:[S.WebGPUSystem],name:"bindGroup"};class s0{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Bc{constructor(t){this._renderer=t,this._managedBuffers=new Ut({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuBuffer)||this.createGPUBuffer(t)}updateBuffer(t){const e=this.getGPUBuffer(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(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=ht("resource"),t.data&&($n(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new s0(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Bc.extension={type:[S.WebGPUSystem],name:"buffer"};class a0{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await H.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(s=>e.features.has(s)),n=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}}destroy(){this.gpu=null,this._renderer=null}}sa.extension={type:[S.WebGPUSystem],name:"device"},sa.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var G3=Object.defineProperty,o0=Object.getOwnPropertySymbols,I3=Object.prototype.hasOwnProperty,B3=Object.prototype.propertyIsEnumerable,l0=(r,t,e)=>t in r?G3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,u0=(r,t)=>{for(var e in t||(t={}))I3.call(t,e)&&l0(r,e,t[e]);if(o0)for(var e of o0(t))B3.call(t,e)&&l0(r,e,t[e]);return r};class Dc{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,n){const s=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(s)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.gc.now,this._renderer.tick);const n=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,n)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const n in i)this._setVertexBuffer(parseInt(n,10),t.attributes[i[n]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const n=t.groups[i];e||this._syncBindGroup(n),this.setBindGroup(i,n,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:n,topology:s,size:a,start:o,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,s),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(a||e.indexBuffer.data.length,l!=null?l:e.instanceCount,o||0):this.renderPassEncoder.draw(a||e.getSize(),l!=null?l: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._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=u0({},this._boundVertexBuffer),n=this._boundIndexBuffer,s=u0({},this._boundBindGroup);this._clearCache();const a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in s)this.setBindGroup(o,s[o],null);this._setIndexBuffer(n)}_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}}Dc.extension={type:[S.WebGPUSystem],name:"encoder",priority:1};class Uc{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}Uc.extension={type:[S.WebGPUSystem],name:"limits"};class $c{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:wt.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 n=this._renderer;n.pipeline.setStencilMode(t),n.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}$c.extension={type:[S.WebGPUSystem],name:"stencil"};const Ki={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function c0(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i1&&(s=Math.max(s,a)*n.data.size),e=Math.ceil(e/a)*a,n.size=s,n.offset=e,e+=s}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function h0(r,t){const{size:e,align:i}=Ki[r.data.type],n=(i-e)/4,s=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return` + `,r}const l3={float:1,vec2:2,vec3:3,vec4:4,int:1,ivec2:2,ivec3:3,ivec4:4,uint:1,uvec2:2,uvec3:3,uvec4:4,bool:1,bvec2:2,bvec3:3,bvec4:4,mat2:4,mat3:9,mat4:16,sampler2D:1};function u3(r){return l3[r]}function Ux(r){const t={};if(t.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t.add=[r.ONE,r.ONE],t.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof H.get().getWebGLRenderingContext()))t.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const e=r.getExtension("EXT_blend_minmax");e&&(t.min=[r.ONE,r.ONE,r.ONE,r.ONE,e.MIN_EXT,e.MIN_EXT],t.max=[r.ONE,r.ONE,r.ONE,r.ONE,e.MAX_EXT,e.MAX_EXT])}return t}const c3=0,h3=1,d3=2,p3=3,f3=4,m3=5,$x=class Rh{constructor(t){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[c3]=this.setBlend,this.map[h3]=this.setOffset,this.map[d3]=this.setCullFace,this.map[p3]=this.setDepthTest,this.map[f3]=this.setFrontFace,this.map[m3]=this.setDepthMask,this.checks=[],this.defaultState=Vt.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=Ux(t),this.resetState()}set(t){if(t||(t=this.defaultState),this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<>=1,i++;this.stateId=t.data}for(let e=0;e>1,1),l=Math.max(l>>1,1)}}},Xx=["right","left","top","bottom","front","back"];function jx(r){return{id:"cube",upload(t,e,i,n){const s=t.faces;for(let a=0;a=o&&c>=l,m=r.resource;(h?_3:y3)(e,a,t,o,l,u,c,m,p,f),t.width=o,t.height=l}};function _3(r,t,e,i,n,s,a,o,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,s,a,e.format,e.type,o);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,o)}function y3(r,t,e,i,n,s,a,o,l,u){if(!u){l&&r.texImage2D(t,0,e.internalFormat,i,n,0,e.format,e.type,null),r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}if(!l){r.texSubImage2D(t,0,0,0,e.format,e.type,o);return}r.texImage2D(t,0,e.internalFormat,e.format,e.type,o)}const b3=Cu(),Hx={id:"video",upload(r,t,e,i,n,s=b3){if(!r.isValid){const a=n!=null?n:t.target;e.texImage2D(a,0,t.internalFormat,1,1,0,t.format,t.type,null);return}Cc.upload(r,t,e,i,n,s)}},Mc={linear:9729,nearest:9728},zx={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},aa={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Wx={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function Rc(r,t,e,i,n,s,a,o){const l=s;if(!o||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=aa[a?"clamp-to-edge":r.addressModeU],c=aa[a?"clamp-to-edge":r.addressModeV],h=aa[a?"clamp-to-edge":r.addressModeW];t[n](l,t.TEXTURE_WRAP_S,u),t[n](l,t.TEXTURE_WRAP_T,c),t.TEXTURE_WRAP_R&&t[n](l,t.TEXTURE_WRAP_R,h)}if((!o||r.magFilter!=="linear")&&t[n](l,t.TEXTURE_MAG_FILTER,Mc[r.magFilter]),e){if(!o||r.mipmapFilter!=="linear"){const u=zx[r.minFilter][r.mipmapFilter];t[n](l,t.TEXTURE_MIN_FILTER,u)}}else t[n](l,t.TEXTURE_MIN_FILTER,Mc[r.minFilter]);if(i&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,t.getParameter(i.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[n](l,i.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare&&t[n](l,t.TEXTURE_COMPARE_FUNC,Wx[r.compare])}function Vx(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}var v3=Object.defineProperty,x3=Object.defineProperties,T3=Object.getOwnPropertyDescriptors,Yx=Object.getOwnPropertySymbols,S3=Object.prototype.hasOwnProperty,w3=Object.prototype.propertyIsEnumerable,Kx=(r,t,e)=>t in r?v3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mr=(r,t)=>{for(var e in t||(t={}))S3.call(t,e)&&Kx(r,e,t[e]);if(Yx)for(var e of Yx(t))w3.call(t,e)&&Kx(r,e,t[e]);return r},E3=(r,t)=>x3(r,T3(t));function qx(r,t){let e={},i=r.RGBA;return r instanceof H.get().getWebGLRenderingContext()?t.srgb&&(e={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(e={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},i=r.RGBA8),mr(mr(mr(mr(mr(mr(E3(mr({r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA},e),{rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:i,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8}),t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{}),t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{}),t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{}),t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{}),t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{}),t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{})}function Zx(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function Qx(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":(r==null?void 0:r.TEXTURE_3D)||null,"2d-array":(r==null?void 0:r.TEXTURE_2D_ARRAY)||null,"cube-array":(r==null?void 0:r.TEXTURE_CUBE_MAP_ARRAY)||null}}function P3(r){r instanceof Uint8ClampedArray&&(r=new Uint8Array(r.buffer));const t=r.length;for(let e=0;et in r?A3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,e0=(r,t)=>{for(var e in t||(t={}))R3.call(t,e)&&t0(r,e,t[e]);if(Jx)for(var e of Jx(t))O3.call(t,e)&&t0(r,e,t[e]);return r},G3=(r,t)=>C3(r,M3(t));const I3=4,Oc=class Q1{constructor(t){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=t,this._managedTextures=new Ut({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const e=e0({image:Cc,buffer:Lx,video:Hx,compressed:Nx},Q1.uploadExtensions);this._uploads=G3(e0({},e),{cube:jx(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gl=t,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=qx(t,this._renderer.context.extensions),this._mapFormatToType=Zx(t),this._mapFormatToFormat=Vx(t),this._mapViewDimensionToGlTarget=Qx(t)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(D.EMPTY,e)}initSource(t){this.bind(t)}bind(t,e=0){const i=t.source;t?(this.bindSource(i,e),this._useSeparateSamplers&&this._bindSampler(i.style,e)):(this.bindSource(null,e),this._useSeparateSamplers&&this._bindSampler(null,e))}bindSource(t,e=0){const i=this._gl;if(t._gcLastUsed=this._renderer.gc.now,this._boundTextures[e]!==t){this._boundTextures[e]=t,this._activateLocation(e),t||(t=D.EMPTY.source);const n=this.getGlSource(t);i.bindTexture(n.target,n.texture)}}_bindSampler(t,e=0){const i=this._gl;if(!t){this._boundSamplers[e]=null,i.bindSampler(e,null);return}const n=this._getGlSampler(t);this._boundSamplers[e]!==n&&(this._boundSamplers[e]=n,i.bindSampler(e,n))}unbind(t){const e=t.source,i=this._boundTextures,n=this._gl;for(let s=0;s1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",n.target,!this._renderer.context.supports.nonPowOf2wrapping&&!t.isPowerOfTwo,e)}onSourceUnload(t,e=!1){const i=t._gpuData[this._renderer.uid];i&&(e||(this.unbind(t),this._gl.deleteTexture(i.texture)),t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceUpdate,this),t.off("styleChange",this.onStyleChange,this),t.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(t){const e=this._gl,i=this.getGlSource(t);e.bindTexture(i.target,i.texture),this._boundTextures[this._activeTextureLocation]=t;const n=t.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==n&&(this._premultiplyAlpha=n,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n)),this._uploads[t.uploadMethodId])this._uploads[t.uploadMethodId].upload(t,i,e,this._renderer.context.webGLVersion);else if(i.target===e.TEXTURE_2D)this._initEmptyTexture2D(i,t);else if(i.target===e.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(i,t);else if(i.target===e.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(i,t);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(i,t),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)}_initEmptyTexture2D(t,e){const i=this._gl;i.texImage2D(i.TEXTURE_2D,0,t.internalFormat,e.pixelWidth,e.pixelHeight,0,t.format,t.type,null);let n=Math.max(e.pixelWidth>>1,1),s=Math.max(e.pixelHeight>>1,1);for(let a=1;a>1,1),s=Math.max(s>>1,1)}_initEmptyTexture2DArray(t,e){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const i=this._gl,n=Math.max(e.arrayLayerCount|0,1);i.texImage3D(i.TEXTURE_2D_ARRAY,0,t.internalFormat,e.pixelWidth,e.pixelHeight,n,0,t.format,t.type,null);let s=Math.max(e.pixelWidth>>1,1),a=Math.max(e.pixelHeight>>1,1);for(let o=1;o>1,1),a=Math.max(a>>1,1)}_initEmptyTextureCube(t,e){const i=this._gl,n=6;for(let o=0;o>1,1),a=Math.max(e.pixelHeight>>1,1);for(let o=1;o>1,1),a=Math.max(a>>1,1)}}_applyMipRange(t,e){if(this._renderer.context.webGLVersion!==2||e.mipLevelCount<=1)return;const i=this._gl,n=Math.max((e.mipLevelCount|0)-1,0);i.texParameteri(t.target,i.TEXTURE_BASE_LEVEL,0),i.texParameteri(t.target,i.TEXTURE_MAX_LEVEL,n)}_initSampler(t){const e=this._gl,i=this._gl.createSampler();return this._glSamplers[t._resourceId]=i,Rc(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 t._gcLastUsed=this._renderer.gc.now,t._gpuData[this._renderer.uid]||this._initSource(t)}generateCanvas(t){const{pixels:e,width:i,height:n}=this.getPixels(t),s=H.get().createCanvas();s.width=i,s.height=n;const a=s.getContext("2d");if(a){const o=a.createImageData(i,n);o.data.set(e),a.putImageData(o,0,0)}return s}getPixels(t){const e=t.source.resolution,i=t.frame,n=Math.max(Math.round(i.width*e),1),s=Math.max(Math.round(i.height*e),1),a=new Uint8Array(I3*n*s),o=this._renderer,l=o.renderTarget.getRenderTarget(t),u=o.renderTarget.getGpuRenderTarget(l),c=o.gl;return c.bindFramebuffer(c.FRAMEBUFFER,u.resolveTargetFramebuffer),c.readPixels(Math.round(i.x*e),Math.round(i.y*e),n,s,c.RGBA,c.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:n,height:s}}destroy(){this._managedTextures.destroy(),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(D.EMPTY.source),this._boundSamplers=Object.create(null);const t=this._gl;this._premultiplyAlpha=!1,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}};Oc.extension={type:[S.WebGLSystem],name:"texture"},Oc.uploadExtensions=Object.create(null);let Gc=Oc;N.handleByMap(S.TextureUploaderWebGL,Gc.uploadExtensions);class Ic{contextChange(t){const e=new At({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uTransformMatrix:{value:new U,type:"mat3x3"},uRound:{value:0,type:"f32"}}),i=t.limits.maxBatchableTextures,n=Dr({name:"graphics",bits:[jn,zn(i),Ts,$r]});this.shader=new ee({glProgram:n,resources:{localUniforms:e,batchSamplers:Wn(i)}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,a=s.graphicsContext,{batcher:o,instructions:l}=a.getContextRenderData(i);n.groups[0]=s.globalUniforms.bindGroup,s.state.set(t.state),s.shader.bind(n),s.geometry.bind(o.geometry,n.glProgram);const u=l.instructions;for(let c=0;c",value:new U}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(n){if(!n.glProgram)return}else{n=this._shader;const s=e.texture,a=s.source;n.resources.uTexture=a,n.resources.uSampler=a.style,n.resources.textureUniforms.uniforms.uTextureMatrix=s.textureMatrix.mapCoord}n.groups[100]=i.globalUniforms.bindGroup,n.groups[101]=t.localUniformsBindGroup,i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Bc.extension={type:[S.WebGLPipesAdaptor],name:"mesh"};const B3=[...Qs,bc,mx,ox,pc,ac,Gc,vc,uc,Pc,Ec,dc,kx,fc,hc],F3=[...ic],D3=[Ou,Bc,Ic],r0=[],i0=[],n0=[];N.handleByNamedList(S.WebGLSystem,r0),N.handleByNamedList(S.WebGLPipes,i0),N.handleByNamedList(S.WebGLPipesAdaptor,n0),N.add(...B3,...F3,...D3);class s0 extends Mr{constructor(){const t={name:"webgl",type:It.WEBGL,systems:r0,renderPipes:i0,renderPipeAdaptors:n0};super(t)}}var U3={__proto__:null,WebGLRenderer:s0};class Fc{constructor(t){this._hash=Object.create(null),this._renderer=t}contextChange(t){this._gpu=t}getBindGroup(t,e,i){return t._updateKey(),this._hash[t._key]||this._createBindGroup(t,e,i)}_createBindGroup(t,e,i){var n;const s=this._gpu.device,a=e.layout[i],o=[],l=this._renderer;for(const h in a){const p=(n=t.resources[h])!=null?n:t.resources[a[h]];let f;if(p._resourceType==="uniformGroup"){const m=p;l.ubo.updateUniformGroup(m);const g=m.buffer;f={buffer:l.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(p._resourceType==="buffer"){const m=p;f={buffer:l.buffer.getGPUBuffer(m),offset:0,size:m.descriptor.size}}else if(p._resourceType==="bufferResource"){const m=p;f={buffer:l.buffer.getGPUBuffer(m.buffer),offset:m.offset,size:m.size}}else if(p._resourceType==="textureSampler"){const m=p;f=l.texture.getGpuSampler(m)}else if(p._resourceType==="textureSource"){const m=p;f=l.texture.getTextureView(m)}o.push({binding:a[h],resource:f})}const u=l.shader.getProgramData(e).bindGroups[i],c=s.createBindGroup({layout:u,entries:o});return this._hash[t._key]=c,c}destroy(){this._hash=null,this._renderer=null}}Fc.extension={type:[S.WebGPUSystem],name:"bindGroup"};class a0{constructor(t){this.gpuBuffer=t}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class Dc{constructor(t){this._renderer=t,this._managedBuffers=new Ut({renderer:t,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(t){this._gpu=t}getGPUBuffer(t){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuBuffer)||this.createGPUBuffer(t)}updateBuffer(t){const e=this.getGPUBuffer(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(){this._managedBuffers.removeAll()}onBufferUnload(t){t.off("update",this.updateBuffer,this),t.off("change",this.onBufferChange,this)}createGPUBuffer(t){const e=this._gpu.device.createBuffer(t.descriptor);return t._updateID=0,t._resourceId=ht("resource"),t.data&&(Ln(t.data.buffer,e.getMappedRange(),t.data.byteOffset,t.data.byteLength),e.unmap()),t._gpuData[this._renderer.uid]=new a0(e),this._managedBuffers.add(t)&&(t.on("update",this.updateBuffer,this),t.on("change",this.onBufferChange,this)),e}onBufferChange(t){this._managedBuffers.remove(t),t._updateID=0,this.createGPUBuffer(t)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}Dc.extension={type:[S.WebGPUSystem],name:"buffer"};class o0{constructor({minUniformOffsetAlignment:t}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=t,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(t){if(t>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${t*4}`);const e=this.byteIndex;let i=e+t*4;if(i=Math.ceil(i/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,i>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=i,e}addGroup(t){const e=this.addEmptyGroup(t.length);for(let i=0;i{this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT=="number"},this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(t){this._renderer.gpu=t}async _createDeviceAndAdaptor(t){const e=await H.get().getNavigator().gpu.requestAdapter({powerPreference:t.powerPreference,forceFallbackAdapter:t.forceFallbackAdapter}),i=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(s=>e.features.has(s)),n=await e.requestDevice({requiredFeatures:i});return{adapter:e,device:n}}destroy(){this.gpu=null,this.extensions=null,this._renderer=null}}oa.extension={type:[S.WebGPUSystem],name:"device"},oa.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};var $3=Object.defineProperty,l0=Object.getOwnPropertySymbols,k3=Object.prototype.hasOwnProperty,L3=Object.prototype.propertyIsEnumerable,u0=(r,t,e)=>t in r?$3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,c0=(r,t)=>{for(var e in t||(t={}))k3.call(t,e)&&u0(r,e,t[e]);if(l0)for(var e of l0(t))L3.call(t,e)&&u0(r,e,t[e]);return r};class $c{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,n){const s=this._renderer.pipeline.getPipeline(t,e,i,n);this.setPipeline(s)}setPipeline(t){this._boundPipeline!==t&&(this._boundPipeline=t,this.renderPassEncoder.setPipeline(t))}_setVertexBuffer(t,e){this._boundVertexBuffer[t]!==e&&(this._boundVertexBuffer[t]=e,this.renderPassEncoder.setVertexBuffer(t,this._renderer.buffer.updateBuffer(e)))}_setIndexBuffer(t){if(this._boundIndexBuffer===t)return;this._boundIndexBuffer=t;const e=t.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(t),e)}resetBindGroup(t){this._boundBindGroup[t]=null}setBindGroup(t,e,i){if(this._boundBindGroup[t]===e)return;this._boundBindGroup[t]=e,e._touch(this._renderer.gc.now,this._renderer.tick);const n=this._renderer.bindGroup.getBindGroup(e,i,t);this.renderPassEncoder.setBindGroup(t,n)}setGeometry(t,e){const i=this._renderer.pipeline.getBufferNamesToBind(t,e);for(const n in i)this._setVertexBuffer(parseInt(n,10),t.attributes[i[n]].buffer);t.indexBuffer&&this._setIndexBuffer(t.indexBuffer)}_setShaderBindGroups(t,e){for(const i in t.groups){const n=t.groups[i];e||this._syncBindGroup(n),this.setBindGroup(i,n,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:n,topology:s,size:a,start:o,instanceCount:l,skipSync:u}=t;this.setPipelineFromGeometryProgramAndState(e,i.gpuProgram,n,s),this.setGeometry(e,i.gpuProgram),this._setShaderBindGroups(i,u),e.indexBuffer?this.renderPassEncoder.drawIndexed(a||e.indexBuffer.data.length,l!=null?l:e.instanceCount,o||0):this.renderPassEncoder.draw(a||e.getSize(),l!=null?l: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._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(t);const e=this._boundPipeline,i=c0({},this._boundVertexBuffer),n=this._boundIndexBuffer,s=c0({},this._boundBindGroup);this._clearCache();const a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(e);for(const o in i)this._setVertexBuffer(o,i[o]);for(const o in s)this.setBindGroup(o,s[o],null);this._setIndexBuffer(n)}_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}}$c.extension={type:[S.WebGPUSystem],name:"encoder",priority:1};class kc{constructor(t){this._renderer=t}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}kc.extension={type:[S.WebGPUSystem],name:"limits"};class Lc{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:wt.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 n=this._renderer;n.pipeline.setStencilMode(t),n.encoder.renderPassEncoder.setStencilReference(e)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Lc.extension={type:[S.WebGPUSystem],name:"stencil"};const Ki={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:8,size:8},"vec2":{align:4,size:4},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:16,size:12},"vec3":{align:8,size:6},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:16,size:16},"vec4":{align:8,size:8},"mat2x2":{align:8,size:16},"mat2x2":{align:4,size:8},"mat3x2":{align:8,size:24},"mat3x2":{align:4,size:12},"mat4x2":{align:8,size:32},"mat4x2":{align:4,size:16},"mat2x3":{align:16,size:32},"mat2x3":{align:8,size:16},"mat3x3":{align:16,size:48},"mat3x3":{align:8,size:24},"mat4x3":{align:16,size:64},"mat4x3":{align:8,size:32},"mat2x4":{align:16,size:32},"mat2x4":{align:8,size:16},"mat3x4":{align:16,size:48},"mat3x4":{align:8,size:24},"mat4x4":{align:16,size:64},"mat4x4":{align:8,size:32}};function h0(r){const t=r.map(i=>({data:i,offset:0,size:0}));let e=0;for(let i=0;i1&&(s=Math.max(s,a)*n.data.size),e=Math.ceil(e/a)*a,n.size=s,n.offset=e,e+=s}return e=Math.ceil(e/16)*16,{uboElements:t,size:e}}function d0(r,t){const{size:e,align:i}=Ki[r.data.type],n=(i-e)/4,s=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return` v = uv.${r.data.name}; ${t!==0?`offset += ${t};`:""} @@ -2096,7 +2096,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { } ${n!==0?`arrayOffset += ${n};`:""} } - `}function d0(r){return gc(r,"uboWgsl",h0,vx)}class kc extends fc{constructor(){super({createUboElements:c0,generateUboSync:d0})}}kc.extension={type:[S.WebGPUSystem],name:"ubo"};const Ve=128;class Lc{constructor(t){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=t,this._batchBuffer=new a0({minUniformOffsetAlignment:Ve});const e=256/Ve;for(let i=0;it in r?F3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,L3=(r,t)=>{for(var e in t||(t={}))$3.call(t,e)&&f0(r,e,t[e]);if(p0)for(var e of p0(t))k3.call(t,e)&&f0(r,e,t[e]);return r},N3=(r,t)=>D3(r,U3(t));const X3={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function j3(r,t,e,i,n){return r<<24|t<<16|e<<10|i<<5|n}function H3(r,t,e,i,n){return e<<8|r<<5|i<<3|n<<1|t}class Nc{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._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(wt.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._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=Ue[t],this._updatePipeHash())}setPipeline(t,e,i,n){const s=this.getPipeline(t,e,i);n.setPipeline(s)}getPipeline(t,e,i,n){t._layoutKey||(oc(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const s=j3(t._layoutKey,e._layoutKey,i.data,i._blendModeId,X3[n]);return this._pipeCache[s]?this._pipeCache[s]:(this._pipeCache[s]=this._createPipeline(t,e,i,n),this._pipeCache[s])}_createPipeline(t,e,i,n){const s=this._gpu.device,a=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i,this._colorTargetCount),l=this._stencilMode===wt.RENDERING_MASK_ADD?0:this._colorMask;for(let h=0;h{var a;const o={arrayStride:0,stepMode:"vertex",attributes:[]},l=o.attributes;for(const u in e.attributeData){const c=t.attributes[u];((a=c.divisor)!=null?a:1)!==1&&ue(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===s&&(o.arrayStride=c.stride,o.stepMode=c.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:c.offset,format:c.format}))}l.length&&n.push(o)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=H3(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}Nc.extension={type:[S.WebGPUSystem],name:"pipeline"};class m0{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class g0{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,s){const a=this._renderer,o=this._getGpuColorTexture(t),l=a.texture.getGpuSource(e.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:l,origin:s},n),e}startRenderPass(t,e=!0,i,n,s=0,a=0){var o,l;const u=this._renderTargetSystem.getGpuRenderTarget(t);if(a!==0&&(o=u.msaaTextures)!=null&&o.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(s>0&&(l=u.msaaTextures)!=null&&l.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const c=this.getDescriptor(t,e,i,s,a);u.descriptor=c,this._renderer.pipeline.setRenderTarget(u),this._renderer.encoder.beginRenderPass(u),this._renderer.encoder.setViewport(n)}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,n=0,s=0){typeof e=="boolean"&&(e=e?Kt.ALL:Kt.NONE);const a=this._renderTargetSystem,o=a.getGpuRenderTarget(t),l=t.colorTextures.map((c,h)=>{const p=o.contexts[h];let f,m;if(p){if(s!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");f=p.getCurrentTexture().createView()}else f=this._renderer.texture.getGpuSource(c).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1});o.msaaTextures[h]&&(m=f,f=this._renderer.texture.getTextureView(o.msaaTextures[h]));const g=e&Kt.COLOR?"clear":"load";return i!=null||(i=a.defaultClearColor),{view:f,resolveTarget:m,clearValue:i,storeOp:"store",loadOp:g}});let u;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=o.msaa?4:1),t.depthStencilTexture){const c=e&Kt.STENCIL?"clear":"load",h=e&Kt.DEPTH?"clear":"load";u={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1}),stencilStoreOp:"store",stencilLoadOp:c,depthClearValue:1,depthLoadOp:h,depthStoreOp:"store"}}return{colorAttachments:l,depthStencilAttachment:u}}clear(t,e=!0,i,n,s=0,a=0){if(!e)return;const{gpu:o,encoder:l}=this._renderer,u=o.device;if(l.commandEncoder===null){const c=u.createCommandEncoder(),h=this.getDescriptor(t,e,i,s,a),p=c.beginRenderPass(h);p.setViewport(n.x,n.y,n.width,n.height,0,1),p.end();const f=c.finish();u.queue.submit([f])}else this.startRenderPass(t,e,i,n,s,a)}initGpuRenderTarget(t){t.isRoot=!0;const e=new m0;return e.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((i,n)=>{if(i instanceof fe){const s=i.resource.getContext("webgpu"),a=i.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:a})}catch(o){console.error(o)}e.contexts[n]=s}if(e.msaa=i.source.antialias,i.source.antialias){const s=new ft({width:0,height:0,sampleCount:4,arrayLayerCount:i.source.arrayLayerCount});e.msaaTextures[n]=s}}),e.msaa&&(e.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4)),e}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,n)=>{const s=e.msaaTextures[n];s==null||s.resize(i.source.width,i.source.height,i.source._resolution)})}}class Xc extends Zs{constructor(t){super(t),this.adaptor=new g0,this.adaptor.init(t,this)}}Xc.extension={type:[S.WebGPUSystem],name:"renderTarget"};class jc{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(s=>e.createBindGroupLayout({entries:s})),n={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(n)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}jc.extension={type:[S.WebGPUSystem],name:"shader"};const Ht={};Ht.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Ht.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Ht["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Ht["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Ht.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},Ht.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},Ht.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Hc{constructor(){this.defaultState=new Vt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){const i=Ht[t.blendMode]||Ht.normal,n=[],s={format:"bgra8unorm",writeMask:0,blend:i};for(let a=0;a>1,1),s=Math.max(s>>1,1)}}},b0=["right","left","top","bottom","front","back"];function v0(r){return{type:"cube",upload(t,e,i){const n=t.faces;for(let s=0;st in r?N3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W3=(r,t)=>{for(var e in t||(t={}))H3.call(t,e)&&m0(r,e,t[e]);if(f0)for(var e of f0(t))z3.call(t,e)&&m0(r,e,t[e]);return r},V3=(r,t)=>X3(r,j3(t));const Y3={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};function K3(r,t,e,i,n){return r<<24|t<<16|e<<10|i<<5|n}function q3(r,t,e,i,n){return e<<8|r<<5|i<<3|n<<1|t}class jc{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._colorTargetCount=1,this._renderer=t}contextChange(t){this._gpu=t,this.setStencilMode(wt.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._colorTargetCount=t.colorTargetCount,this._updatePipeHash()}setColorMask(t){this._colorMask!==t&&(this._colorMask=t,this._updatePipeHash())}setStencilMode(t){this._stencilMode!==t&&(this._stencilMode=t,this._stencilState=Ue[t],this._updatePipeHash())}setPipeline(t,e,i,n){const s=this.getPipeline(t,e,i);n.setPipeline(s)}getPipeline(t,e,i,n){t._layoutKey||(lc(t,e.attributeData),this._generateBufferKey(t)),n||(n=t.topology);const s=K3(t._layoutKey,e._layoutKey,i.data,i._blendModeId,Y3[n]);return this._pipeCache[s]?this._pipeCache[s]:(this._pipeCache[s]=this._createPipeline(t,e,i,n),this._pipeCache[s])}_createPipeline(t,e,i,n){const s=this._gpu.device,a=this._createVertexBufferLayouts(t,e),o=this._renderer.state.getColorTargets(i,this._colorTargetCount),l=this._stencilMode===wt.RENDERING_MASK_ADD?0:this._colorMask;for(let h=0;h{var a;const o={arrayStride:0,stepMode:"vertex",attributes:[]},l=o.attributes;for(const u in e.attributeData){const c=t.attributes[u];((a=c.divisor)!=null?a:1)!==1&&ue(`Attribute ${u} has an invalid divisor value of '${c.divisor}'. WebGPU only supports a divisor value of 1`),c.buffer===s&&(o.arrayStride=c.stride,o.stepMode=c.instance?"instance":"vertex",l.push({shaderLocation:e.attributeData[u].location,offset:c.offset,format:c.format}))}l.length&&n.push(o)}),this._bufferLayoutsCache[i]=n,n}_updatePipeHash(){const t=q3(this._stencilMode,this._multisampleCount,this._colorMask,this._depthStencilAttachment,this._colorTargetCount);this._pipeStateCaches[t]||(this._pipeStateCaches[t]=Object.create(null)),this._pipeCache=this._pipeStateCaches[t]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}jc.extension={type:[S.WebGPUSystem],name:"pipeline"};class g0{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class _0{init(t,e){this._renderer=t,this._renderTargetSystem=e}copyToTexture(t,e,i,n,s){const a=this._renderer,o=this._getGpuColorTexture(t),l=a.texture.getGpuSource(e.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:o,origin:i},{texture:l,origin:s},n),e}startRenderPass(t,e=!0,i,n,s=0,a=0){var o,l;const u=this._renderTargetSystem.getGpuRenderTarget(t);if(a!==0&&(o=u.msaaTextures)!=null&&o.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(s>0&&(l=u.msaaTextures)!=null&&l.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const c=this.getDescriptor(t,e,i,s,a);u.descriptor=c,this._renderer.pipeline.setRenderTarget(u),this._renderer.encoder.beginRenderPass(u),this._renderer.encoder.setViewport(n)}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,n=0,s=0){var a;typeof e=="boolean"&&(e=e?Kt.ALL:Kt.NONE);const o=this._renderTargetSystem,l=o.getGpuRenderTarget(t),u=t.colorTextures.map((h,p)=>{const f=l.contexts[p];let m,g;if(f){if(s!==0)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");m=f.getCurrentTexture().createView()}else m=this._renderer.texture.getGpuSource(h).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1});let _=!1;l.msaaTextures[p]&&(g=m,m=this._renderer.texture.getTextureView(l.msaaTextures[p]),_=l.msaaTextures[p].transient);const y=e&Kt.COLOR?"clear":"load";return i!=null||(i=o.defaultClearColor),{view:m,resolveTarget:g,clearValue:i,storeOp:_?"discard":"store",loadOp:y}});let c;if((t.stencil||t.depth)&&!t.depthStencilTexture&&(t.ensureDepthStencilTexture(),t.depthStencilTexture.source.sampleCount=l.msaa?4:1,t.depthStencilTexture.source.transient=!!((a=l.msaaTextures[0])!=null&&a.transient)),t.depthStencilTexture){const h=e&Kt.STENCIL?"clear":"load",p=e&Kt.DEPTH?"clear":"load",f=t.depthStencilTexture.source.transient?"discard":"store";c={view:this._renderer.texture.getGpuSource(t.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1}),stencilStoreOp:f,stencilLoadOp:h,depthClearValue:1,depthLoadOp:p,depthStoreOp:f}}return{colorAttachments:u,depthStencilAttachment:c}}clear(t,e=!0,i,n,s=0,a=0){if(!e)return;const{gpu:o,encoder:l}=this._renderer,u=o.device;if(l.commandEncoder===null){const c=u.createCommandEncoder(),h=this.getDescriptor(t,e,i,s,a),p=c.beginRenderPass(h);p.setViewport(n.x,n.y,n.width,n.height,0,1),p.end();const f=c.finish();u.queue.submit([f])}else this.startRenderPass(t,e,i,n,s,a)}initGpuRenderTarget(t){var e;t.isRoot=!0;const i=new g0;return i.colorTargetCount=t.colorTextures.length,t.colorTextures.forEach((n,s)=>{if(n instanceof fe){const a=n.resource.getContext("webgpu"),o=n.transparent?"premultiplied":"opaque";try{a.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:o})}catch(l){console.error(l)}i.contexts[s]=a}if(i.msaa=n.source.antialias,n.source.antialias){const a=new ft({width:0,height:0,sampleCount:4,transient:n.source.transient,arrayLayerCount:n.source.arrayLayerCount});i.msaaTextures[s]=a}}),i.msaa&&(i.msaaSamples=4,t.depthStencilTexture&&(t.depthStencilTexture.source.sampleCount=4,t.depthStencilTexture.source.transient=!!((e=i.msaaTextures[0])!=null&&e.transient))),i}destroyGpuRenderTarget(t){t.contexts.forEach(e=>{e.unconfigure()}),t.msaaTextures.forEach(e=>{e.destroy()}),t.msaaTextures.length=0,t.contexts.length=0}ensureDepthStencilTexture(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);t.depthStencilTexture&&e.msaa&&(t.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(t){const e=this._renderTargetSystem.getGpuRenderTarget(t);e.width=t.width,e.height=t.height,e.msaa&&t.colorTextures.forEach((i,n)=>{const s=e.msaaTextures[n];s==null||s.resize(i.source.width,i.source.height,i.source._resolution)})}}class Hc extends Js{constructor(t){super(t),this.adaptor=new _0,this.adaptor.init(t,this)}}Hc.extension={type:[S.WebGPUSystem],name:"renderTarget"};class zc{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(s=>e.createBindGroupLayout({entries:s})),n={bindGroupLayouts:i};return this._gpuProgramData[t._layoutKey]={bindGroups:i,pipeline:e.createPipelineLayout(n)},this._gpuProgramData[t._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}zc.extension={type:[S.WebGPUSystem],name:"shader"};const Ht={};Ht.normal={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.add={alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},Ht.multiply={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht.screen={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.overlay={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},Ht.none={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},Ht["normal-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},Ht["add-npm"]={alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},Ht["screen-npm"]={alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},Ht.erase={alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},Ht.min={alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},Ht.max={alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}};class Wc{constructor(){this.defaultState=new Vt,this.defaultState.blend=!0}contextChange(t){this.gpu=t}getColorTargets(t,e){const i=Ht[t.blendMode]||Ht.normal,n=[],s={format:"bgra8unorm",writeMask:0,blend:i};for(let a=0;a>1,1),s=Math.max(s>>1,1)}}},v0=["right","left","top","bottom","front","back"];function x0(r){return{type:"cube",upload(t,e,i){const n=t.faces;for(let s=0;s pos : array, 3> = array, 3>( vec2(-1.0, -1.0), vec2(-1.0, 3.0), vec2(3.0, -1.0)); @@ -2120,7 +2120,7 @@ fn setSaturation(c: vec3, s: f32) -> vec3 { fn fragmentMain(@location(0) texCoord : vec2) -> @location(0) vec4 { return textureSample(img, imgSampler, texCoord); } - `})),e=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:t}]}}),this.pipelines[t]=e),e}generateMipmap(t){const e=this._getMipmapPipeline(t.format);if(t.dimension==="3d"||t.dimension==="1d")throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let i=t;const n=t.depthOrArrayLayers||1,s=t.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!s){const l={size:{width:Math.ceil(t.width/2),height:Math.ceil(t.height/2),depthOrArrayLayers:n},format:t.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:t.mipLevelCount-1};i=this.device.createTexture(l)}const a=this.device.createCommandEncoder({}),o=e.getBindGroupLayout(0);for(let l=0;lt in r?W3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Z3=(r,t)=>{for(var e in t||(t={}))K3.call(t,e)&&w0(r,e,t[e]);if(S0)for(var e of S0(t))q3.call(t,e)&&w0(r,e,t[e]);return r},Q3=(r,t)=>V3(r,Y3(t));class Vc{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class Yc{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new Ut({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const e={image:Wc,buffer:_0,video:x0,compressed:y0};this._uploads=Q3(Z3({},e),{cube:v0(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){var e;return((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC);const i=zc[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,s=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,a={label:t.label,size:{width:n,height:s,depthOrArrayLayers:t.arrayLayerCount},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpu.device.createTexture(a);return t._gpuData[this._renderer.uid]=new Vc(o),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),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))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new T0(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;const e=t._gpuData[this._renderer.uid],i=e==null?void 0:e.gpuTexture;i?(i.width!==t.pixelWidth||i.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,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){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||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 Pe({0:e,1:e.style,2:new At({uTextureMatrix:{type:"mat3x3",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;e._gcLastUsed=this._renderer.gc.now;let i=e._gpuData[this._renderer.uid];return i||(this.initSource(e),i=e._gpuData[this._renderer.uid]),i.textureView||(i.textureView=i.gpuTexture.createView({dimension:e.viewDimension})),i.textureView}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),n=H.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const s=n.getContext("webgpu");return s.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:H.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:s.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=me.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:s,height:a}=e,o=n.getImageData(0,0,s,a),l=new Uint8ClampedArray(o.data.buffer);return me.returnCanvasAndContext(i),{pixels:l,width:s,height:a}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}Yc.extension={type:[S.WebGPUSystem],name:"texture"};class Kc{constructor(){this._maxTextures=0}contextChange(t){const e=new At({uTransformMatrix:{value:new U,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Fr({name:"graphics",bits:[Ln,Xn(this._maxTextures),By,Ur]});this.shader=new ee({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,a=s.graphicsContext,{batcher:o,instructions:l}=a.getContextRenderData(i),u=s.encoder;u.setGeometry(o.geometry,n.gpuProgram);const c=s.globalUniforms.bindGroup;u.setBindGroup(0,c,n.gpuProgram);const h=s.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);u.setBindGroup(2,h,n.gpuProgram);const p=l.instructions;let f=null;for(let m=0;m",value:new U}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(!n)n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);else if(!n.gpuProgram)return;const s=n.gpuProgram;if(s.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),s.autoAssignLocalUniforms){const a=t.localUniforms;n.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(a,!0)}i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}qc.extension={type:[S.WebGPUPipesAdaptor],name:"mesh"};const J3=[...qs,kc,Dc,sa,Uc,Bc,Yc,Xc,jc,Hc,Nc,Fc,$c,Ic],tG=[...rc,Lc],eG=[Ou,qc,Kc],P0=[],E0=[],A0=[];X.handleByNamedList(S.WebGPUSystem,P0),X.handleByNamedList(S.WebGPUPipes,E0),X.handleByNamedList(S.WebGPUPipesAdaptor,A0),X.add(...J3,...tG,...eG);class C0 extends Mr{constructor(){const t={name:"webgpu",type:It.WEBGPU,systems:P0,renderPipes:E0,renderPipeAdaptors:A0};super(t)}}var rG={__proto__:null,WebGPURenderer:C0};const iG={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},nG=new Proxy(iG,{get(r,t){return r[t]}});var Zc=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(Zc||{});const sG=new Proxy(Zc,{get(r,t){return r[t]}});var Qc=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(Qc||{});const aG=new Proxy(Qc,{get(r,t){return r[t]}});var oG=Object.defineProperty,lG=Object.defineProperties,uG=Object.getOwnPropertyDescriptors,aa=Object.getOwnPropertySymbols,M0=Object.prototype.hasOwnProperty,R0=Object.prototype.propertyIsEnumerable,O0=(r,t,e)=>t in r?oG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,cG=(r,t)=>{for(var e in t||(t={}))M0.call(t,e)&&O0(r,e,t[e]);if(aa)for(var e of aa(t))R0.call(t,e)&&O0(r,e,t[e]);return r},hG=(r,t)=>lG(r,uG(t)),dG=(r,t)=>{var e={};for(var i in r)M0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&aa)for(var i of aa(r))t.indexOf(i)<0&&R0.call(r,i)&&(e[i]=r[i]);return e};class ei extends ft{constructor(t){const e=t,{faces:i}=e,n=dG(e,["faces"]);ei._validateFaces(i);const s=i.right,a=s.resolution,o=s.format,l=s.alphaMode;super(hG(cG({},n),{resource:i,width:s.width,height:s.height,dimensions:"2d",viewDimension:"cube",arrayLayerCount:6,resolution:a,format:o,alphaMode:l})),this.uploadMethodId="cube",this.faces=i;for(const u of Object.keys(i)){const c=i[u];c.on("update",this._onFaceUpdate,this),c.on("resize",this._onFaceResize,this),c.on("unload",this._onFaceUpdate,this)}}destroy(){const t=this.faces;if(t)for(const e of Object.keys(t)){const i=t[e];i.off("update",this._onFaceUpdate,this),i.off("resize",this._onFaceResize,this),i.off("unload",this._onFaceUpdate,this)}super.destroy()}_onFaceUpdate(){this.emit("update",this)}_onFaceResize(t){ei._validateFaces(this.faces),this.resize(t.width,t.height,t.resolution)}static _validateFaces(t){if(!t.right||!t.left||!t.top||!t.bottom||!t.front||!t.back)throw new Error("[CubeTextureSource] Requires { left, right, top, bottom, front, back } faces.");const e=t.right,i=e.pixelWidth,n=e.pixelHeight,s=e.format,a=e.alphaMode,o=e.resolution;for(const l of Object.keys(t)){const u=t[l];if(u.pixelWidth!==i||u.pixelHeight!==n)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different size. All faces must match.`);if(u.format!==s)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different format. All faces must match.`);if(u.alphaMode!==a)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different alphaMode. All faces must match.`);if(u.resolution!==o)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different resolution. All faces must match.`)}}}var pG=Object.defineProperty,fG=Object.defineProperties,mG=Object.getOwnPropertyDescriptors,oa=Object.getOwnPropertySymbols,G0=Object.prototype.hasOwnProperty,I0=Object.prototype.propertyIsEnumerable,B0=(r,t,e)=>t in r?pG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,F0=(r,t)=>{for(var e in t||(t={}))G0.call(t,e)&&B0(r,e,t[e]);if(oa)for(var e of oa(t))I0.call(t,e)&&B0(r,e,t[e]);return r},gG=(r,t)=>fG(r,mG(t)),_G=(r,t)=>{var e={};for(var i in r)G0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&oa)for(var i of oa(r))t.indexOf(i)<0&&I0.call(r,i)&&(e[i]=r[i]);return e};const Jc=["left","right","top","bottom","front","back"];function yG(r,t){const e=t?F0({},t):{};delete e.label;const i=Object.keys(e).sort(),n=i.length?`|${i.map(s=>`${s}=${String(e[s])}`).join("&")}`:"";return`cube:${Jc.map(s=>r[s]).join(",")}${n}`}class la extends Nt{constructor(t){var e;super(),this.uid=ht("cubeTexture"),this.destroyed=!1;const{label:i,source:n}=t;this.label=i,this.source=n,this.source.label=(e=this.label)!=null?e:this.source.label}static from(t,e=!1){if(t instanceof ei)return new la({source:t});const i=t,{faces:n}=i,s=_G(i,["faces"]);let a=null;const o=Jc.every(h=>typeof n[h]=="string");if(!e&&o&&(a=yG(n,s),it.has(a)))return it.get(a);const l=h=>h.isTexture?h:D.from(h),u={};for(const h of Jc)u[h]=l(n[h]).source;const c=new la({source:new ei(gG(F0({},s),{faces:u})),label:s.label});return a&&(it.set(a,c),c.once("destroy",()=>{it.has(a)&&it.remove(a)})),c}destroy(t=!1){this.destroyed||(this.destroyed=!0,t&&this.source.destroy(),this.emit("destroy",this),this.removeAllListeners())}}const th=Object.create(null),eh=Object.create(null);function bG(r){var t;if(r.type===It.WEBGPU)return eh[t=r.uid]||(eh[t]=r.gpu.device.createTexture({label:"ExternalSource placeholder",size:{width:1,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST})),eh[r.uid];if(!th[r.uid]){const e=r.gl,i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null),th[r.uid]=i}return th[r.uid]}class vG extends ft{constructor({resource:t,renderer:e,label:i,width:n,height:s}){var a,o;t||(t=bG(e)),n||(n=(a=n!=null?n:t==null?void 0:t.width)!=null?a:1),s||(s=(o=s!=null?s:t==null?void 0:t.height)!=null?o:1),super({resource:t,width:n,height:s,label:i,autoGarbageCollect:!1}),this._renderer=e,this._initGpuData(t)}static test(t){return globalThis.GPUTexture&&t instanceof GPUTexture||globalThis.WebGLTexture&&t instanceof WebGLTexture}_validateTexture(t){const e=this._renderer,i=!!e.gpu,n=globalThis.GPUTexture&&t instanceof GPUTexture,s=globalThis.WebGLTexture&&t instanceof WebGLTexture;if(i&&s)throw new Error("Cannot use WebGLTexture with a WebGPU renderer");if(!i&&n)throw new Error("Cannot use GPUTexture with a WebGL renderer");if(!i){const a=e.gl;if(a&&!a.isTexture(t))throw new Error("WebGLTexture does not belong to this renderer's WebGL context")}}_initGpuData(t){const e=this._renderer;this._validateTexture(t),e.gpu?this._gpuData[e.uid]=new Vc(t):this._gpuData[e.uid]=new Ec(t)}updateGPUTexture(t,e,i){const n=this._renderer,s=this._gpuData[n.uid];if(this.resource=t,n.gpu){this._validateTexture(t);const a=s;if(a.gpuTexture!==t){a.gpuTexture=t,a.textureView=null;const u=n.texture;u!=null&&u._bindGroupHash&&(u._bindGroupHash[this.uid]=null)}const o=e!=null?e:t.width,l=i!=null?i:t.height;this.resize(o,l)}else{this._validateTexture(t);const a=s;a.texture=t,e!==void 0&&i!==void 0&&this.resize(e,i)}this.emit("update",this)}destroy(){const t=this._renderer;delete this._gpuData[t.uid],super.destroy()}}class xG{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const n=e.width,s=e.height;if(i){const a=t.width/2/n,o=t.height/2/s,l=t.x/n+a,u=t.y/s+o;i=W.add(i,W.NW),this.x0=l+a*W.uX(i),this.y0=u+o*W.uY(i),i=W.add(i,2),this.x1=l+a*W.uX(i),this.y1=u+o*W.uY(i),i=W.add(i,2),this.x2=l+a*W.uX(i),this.y2=u+o*W.uY(i),i=W.add(i,2),this.x3=l+a*W.uX(i),this.y3=u+o*W.uY(i)}else this.x0=t.x/n,this.y0=t.y/s,this.x1=(t.x+t.width)/n,this.y1=t.y/s,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/s,this.x3=t.x/n,this.y3=(t.y+t.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function TG(r){const t=r.toString(),e=t.indexOf("{"),i=t.lastIndexOf("}");if(e===-1||i===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,i).trim()}function SG(r,t){return r.getFastGlobalBounds(!0,t)}var wG=Object.defineProperty,ua=Object.getOwnPropertySymbols,D0=Object.prototype.hasOwnProperty,U0=Object.prototype.propertyIsEnumerable,$0=(r,t,e)=>t in r?wG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,PG=(r,t)=>{for(var e in t||(t={}))D0.call(t,e)&&$0(r,e,t[e]);if(ua)for(var e of ua(t))U0.call(t,e)&&$0(r,e,t[e]);return r},EG=(r,t)=>{var e={};for(var i in r)D0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ua)for(var i of ua(r))t.indexOf(i)<0&&U0.call(r,i)&&(e[i]=r[i]);return e};class AG extends Se{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const n=t,{render:s}=n,a=EG(n,["render"]);super(PG({label:"RenderContainer"},a)),this.renderPipeId="customRender",this.batched=!1,s&&(this.render=s),this.containsPoint=(e=t.containsPoint)!=null?e:(()=>!1),this.addBounds=(i=t.addBounds)!=null?i:(()=>!1)}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function CG(r,t,e){const i=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,i,null)}function MG(r,t){const e=t._scale,i=t._pivot,n=t._position,s=e._x,a=e._y,o=i._x,l=i._y;r.a=t._cx*s,r.b=t._sx*s,r.c=t._cy*a,r.d=t._sy*a,r.tx=n._x-(o*r.a+l*r.c),r.ty=n._y-(o*r.b+l*r.d)}function RG(r,t,e){const i=r.a,n=r.b,s=r.c,a=r.d,o=r.tx,l=r.ty,u=t.a,c=t.b,h=t.c,p=t.d;e.a=i*u+n*h,e.b=i*c+n*p,e.c=s*u+a*h,e.d=s*c+a*p,e.tx=o*u+l*h+t.tx,e.ty=o*c+l*p+t.ty}class k0{constructor(){this._gradients=[],this._nextId=0}addStyle(t){var e;if(!(t.fill instanceof $t))return null;const i=`pixi-grad-${this._nextId++}`;return this._gradients.push({id:i,gradient:t.fill,textureSpace:(e=t.textureSpace)!=null?e:"local"}),`url(#${i})`}build(){var t,e,i,n,s,a,o,l,u,c,h,p,f,m,g,_,y;if(this._gradients.length===0)return"";const b=[""];for(const{id:x,gradient:v,textureSpace:w}of this._gradients){const T=w==="global"?"userSpaceOnUse":"objectBoundingBox",P=OG(v.colorStops);if(v.type==="radial"){const E=(e=(t=v.outerCenter)==null?void 0:t.x)!=null?e:.5,M=(n=(i=v.outerCenter)==null?void 0:i.y)!=null?n:.5,C=(s=v.outerRadius)!=null?s:.5,A=(o=(a=v.center)==null?void 0:a.x)!=null?o:E,G=(u=(l=v.center)==null?void 0:l.y)!=null?u:M;b.push(``,P,"")}else{const E=(h=(c=v.start)==null?void 0:c.x)!=null?h:0,M=(f=(p=v.start)==null?void 0:p.y)!=null?f:0,C=(g=(m=v.end)==null?void 0:m.x)!=null?g:1,A=(y=(_=v.end)==null?void 0:_.y)!=null?y:0;b.push(``,P,"")}}return b.push(""),b.join("")}}function OG(r){return r.map(t=>{const e=tt.shared.setValue(t.color).toHex();return``}).join("")}const gr=Math.PI*2,GG=new Set(["regularPoly","roundPoly","roundShape","filletRect","chamferRect","arcTo"]);function Ye(r,t=2,e=!1){var i,n,s;if(r.instructions.some(l=>GG.has(l.action)))return DG(r,t,e);const a=[];let o=!1;for(let l=0;l0&&(i-=gr):i<0&&(i+=gr),Math.abs(i)>=gr-1e-6}function V(r,t){return parseFloat(r.toFixed(t)).toString()}function Ft(r,t,e,i){if(e&&!e.isIdentity()){const n=e.a*r+e.c*t+e.tx,s=e.b*r+e.d*t+e.ty;return`${V(n,i)} ${V(s,i)}`}return`${V(r,i)} ${V(t,i)}`}function BG(r,t,e,i,n,s,a,o,l=!1){let u=n-i;if(s?u>0&&(u-=gr):u<0&&(u+=gr),Math.abs(u)>=gr-1e-6)return qi(r,t,e,e,null,o,l);if(l){const _=[];for(let y=0;y<=32;y++){const b=i+y/32*u,x=r+e*Math.cos(b),v=t+e*Math.sin(b),w=y===0?a?"L":"M":"L";_.push(`${w}${V(x,o)} ${V(v,o)}`)}return _.join("")}const c=r+e*Math.cos(i),h=t+e*Math.sin(i),p=r+e*Math.cos(n),f=t+e*Math.sin(n),m=Math.abs(u)>Math.PI?1:0,g=s?0:1;return`${a?"L":"M"}${V(c,o)} ${V(h,o)}A${V(e,o)} ${V(e,o)} 0 ${m} ${g} ${V(p,o)} ${V(f,o)}`}function qi(r,t,e,i,n,s,a=!1){const o=n&&!n.isIdentity()?n:null;if(!o&&!a)return`M${V(r-e,s)} ${V(t,s)}A${V(e,s)} ${V(i,s)} 0 1 1 ${V(r+e,s)} ${V(t,s)}A${V(e,s)} ${V(i,s)} 0 1 1 ${V(r-e,s)} ${V(t,s)}Z`;const l=64,u=[];for(let c=0;c`);break}case"stroke":{const g=m;let _=Ye(g.data.path,t);g.data.hole&&(_+=Ye(g.data.hole,t,!0));const y=j0(g.data.style,i);n.push(``);break}case"texture":break}a++}const o=e.bounds,l=parseFloat(o.minX.toFixed(t)),u=parseFloat(o.minY.toFixed(t)),c=parseFloat((o.maxX-o.minX).toFixed(t)),h=parseFloat((o.maxY-o.minY).toFixed(t)),p=i.build(),f=n.join("");return`${p}${f}`}function $G(r){r instanceof ge&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],n=r.path.shapePath,s=r.textureMatrix;n.shapePrimitives.forEach(({shape:o,transform:l})=>{const u=i.length,c=t.length/2,h=[],p=Ne[o.type];p.build(o,h),l&&Wn(h,l),p.triangulate(h,t,2,c,i,u);const f=e.length/2;s?(l&&s.append(l.clone().invert()),el(t,2,c,e,f,2,t.length/2-c,s)):rl(e,f,2,t.length/2-c)});const a=r.out;return a?(a.positions=new Float32Array(t),a.uvs=new Float32Array(e),a.indices=new Uint32Array(i),a):new ze({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})}var kG=Object.defineProperty,H0=Object.getOwnPropertySymbols,LG=Object.prototype.hasOwnProperty,NG=Object.prototype.propertyIsEnumerable,z0=(r,t,e)=>t in r?kG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,W0=(r,t)=>{for(var e in t||(t={}))LG.call(t,e)&&z0(r,e,t[e]);if(H0)for(var e of H0(t))NG.call(t,e)&&z0(r,e,t[e]);return r};const V0=class q1 extends dt{constructor(t={}){t=W0(W0({},q1.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;er.zIndex-t.zIndex};let XG=V0;var jG=Object.defineProperty,Y0=Object.getOwnPropertySymbols,HG=Object.prototype.hasOwnProperty,zG=Object.prototype.propertyIsEnumerable,K0=(r,t,e)=>t in r?jG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,q0=(r,t)=>{for(var e in t||(t={}))HG.call(t,e)&&K0(r,e,t[e]);if(Y0)for(var e of Y0(t))zG.call(t,e)&&K0(r,e,t[e]);return r};const Z0=class Z1 extends ze{constructor(...t){var e;super({});let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){var e,i,n,s;t=q0(q0({},Z1.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(n=this.width)!=null?n:t.width,this.height=(s=this.height)!=null?s:t.height;const a=this.verticesX*this.verticesY,o=[],l=[],u=[],c=this.verticesX-1,h=this.verticesY-1,p=this.width/c,f=this.height/h;for(let g=0;gt in r?ZG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ih=(r,t)=>{for(var e in t||(t={}))nT.call(t,e)&&aT(r,e,t[e]);if(da)for(var e of da(t))sT.call(t,e)&&aT(r,e,t[e]);return r},tI=(r,t)=>QG(r,JG(t)),eI=(r,t)=>{var e={};for(var i in r)nT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&da)for(var i of da(r))t.indexOf(i)<0&&sT.call(r,i)&&(e[i]=r[i]);return e};const oT=class Q1 extends Kr{constructor(t){t=ih(ih({},Q1.defaultOptions),t);const e=t,{texture:i,verticesX:n,verticesY:s}=e,a=eI(e,["texture","verticesX","verticesY"]),o=new iT(he({width:i.width,height:i.height,verticesX:n,verticesY:s}));super(he(tI(ih({},a),{geometry:o}))),this._texture=i,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height:i}=this.texture;(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,i,n,s,a,o,l){this.geometry.setCorners(t,e,i,n,s,a,o,l)}};oT.defaultOptions={texture:D.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let rI=oT;var iI=Object.defineProperty,nI=Object.defineProperties,sI=Object.getOwnPropertyDescriptors,pa=Object.getOwnPropertySymbols,lT=Object.prototype.hasOwnProperty,uT=Object.prototype.propertyIsEnumerable,cT=(r,t,e)=>t in r?iI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,aI=(r,t)=>{for(var e in t||(t={}))lT.call(t,e)&&cT(r,e,t[e]);if(pa)for(var e of pa(t))uT.call(t,e)&&cT(r,e,t[e]);return r},oI=(r,t)=>nI(r,sI(t)),lI=(r,t)=>{var e={};for(var i in r)lT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&pa)for(var i of pa(r))t.indexOf(i)<0&&uT.call(r,i)&&(e[i]=r[i]);return e};class uI extends Kr{constructor(t){const e=t,{texture:i,verticesX:n,verticesY:s}=e,a=lI(e,["texture","verticesX","verticesY"]),o=new ca(he({width:i.width,height:i.height,verticesX:n,verticesY:s}));super(he(oI(aI({},a),{geometry:o,texture:i}))),this.texture=i,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:i}=this.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var cI=Object.defineProperty,hT=Object.getOwnPropertySymbols,hI=Object.prototype.hasOwnProperty,dI=Object.prototype.propertyIsEnumerable,dT=(r,t,e)=>t in r?cI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,pT=(r,t)=>{for(var e in t||(t={}))hI.call(t,e)&&dT(r,e,t[e]);if(hT)for(var e of hT(t))dI.call(t,e)&&dT(r,e,t[e]);return r};const fT=class J1 extends ze{constructor(t){const{width:e,points:i,textureScale:n}=pT(pT({},J1.defaultOptions),t);super({positions:new Float32Array(i.length*4),uvs:new Float32Array(i.length*4),indices:new Uint32Array((i.length-1)*6)}),this.points=i,this._width=e,this.textureScale=n,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),n=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),n.data=new Uint16Array((t.length-1)*6));const s=i.data,a=n.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let o=0,l=t[0];const u=this._width*this.textureScale,c=t.length;for(let p=0;p0){const m=l.x-t[p].x,g=l.y-t[p].y,_=Math.sqrt(m*m+g*g);l=t[p],o+=_/u}else o=p/(c-1);s[f]=o,s[f+1]=0,s[f+2]=o,s[f+3]=1}let h=0;for(let p=0;p0?this.textureScale*this._width/2:this._width/2;for(let u=0;u1&&(p=1);const f=Math.sqrt(n*n+s*s);f<1e-6?(n=0,s=0):(n/=f,s/=f,n*=l,s*=l),a[h]=c.x+n,a[h+1]=c.y+s,a[h+2]=c.x-n,a[h+3]=c.y-s,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};fT.defaultOptions={width:200,points:[],textureScale:0};let mT=fT;var pI=Object.defineProperty,fI=Object.defineProperties,mI=Object.getOwnPropertyDescriptors,fa=Object.getOwnPropertySymbols,gT=Object.prototype.hasOwnProperty,_T=Object.prototype.propertyIsEnumerable,yT=(r,t,e)=>t in r?pI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,nh=(r,t)=>{for(var e in t||(t={}))gT.call(t,e)&&yT(r,e,t[e]);if(fa)for(var e of fa(t))_T.call(t,e)&&yT(r,e,t[e]);return r},gI=(r,t)=>fI(r,mI(t)),_I=(r,t)=>{var e={};for(var i in r)gT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fa)for(var i of fa(r))t.indexOf(i)<0&&_T.call(r,i)&&(e[i]=r[i]);return e};const bT=class tS extends Kr{constructor(t){const e=nh(nh({},tS.defaultOptions),t),{width:i,texture:n,points:s,textureScale:a}=e,o=_I(e,["width","texture","points","textureScale"]),l=new mT(he({width:i!=null?i:n.height,points:s,textureScale:a}));a>0&&(n.source.style.addressMode="repeat"),super(he(gI(nh({},o),{texture:n,geometry:l}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};bT.defaultOptions={textureScale:0};let yI=bT;var bI=Object.defineProperty,vI=Object.defineProperties,xI=Object.getOwnPropertyDescriptors,ma=Object.getOwnPropertySymbols,vT=Object.prototype.hasOwnProperty,xT=Object.prototype.propertyIsEnumerable,TT=(r,t,e)=>t in r?bI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,TI=(r,t)=>{for(var e in t||(t={}))vT.call(t,e)&&TT(r,e,t[e]);if(ma)for(var e of ma(t))xT.call(t,e)&&TT(r,e,t[e]);return r},SI=(r,t)=>vI(r,xI(t)),wI=(r,t)=>{var e={};for(var i in r)vT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ma)for(var i of ma(r))t.indexOf(i)<0&&xT.call(r,i)&&(e[i]=r[i]);return e};class PI extends Kr{constructor(t){const e=t,{texture:i,vertices:n,uvs:s,indices:a,topology:o}=e,l=wI(e,["texture","vertices","uvs","indices","topology"]),u=new ze(he({positions:n,uvs:s,indices:a,topology:o}));super(he(SI(TI({},l),{texture:i,geometry:u}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function EI(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}class ST{execute(t,e){var i,n,s;const a=t.renderer,o=a.canvasContext.activeContext,l=e.particleChildren,u=e.texture;o.save(),a.canvasContext.setContextTransform(e.worldTransform,e.roundPixels),a.canvasContext.setBlendMode(e.groupBlendMode);const c=e.groupColorAlpha,h=(n=(i=a.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,p=(c>>>24&255)/255*h;for(let f=0;f>>24&255)/255*p;if(y<=0)continue;const b=_&16777215,x=((b&255)<<16)+(b&65280)+(b>>16&255);let v=g.source.resource;x!==16777215&&(v=Q.getTintedCanvas({texture:g},x));const w=g.frame,T=g.source.resolution,P=w.x*T,E=w.y*T,M=w.width*T,C=w.height*T;o.globalAlpha=y;const A=-m.anchorX*w.width,G=-m.anchorY*w.height;m.rotation!==0||m.scaleX!==1||m.scaleY!==1?(o.save(),o.translate(m.x,m.y),o.rotate(m.rotation),o.scale(m.scaleX,m.scaleY),o.drawImage(v,P,E,M,C,A,G,w.width,w.height),o.restore()):o.drawImage(v,P,E,M,C,m.x+A,m.y+G,w.width,w.height)}o.restore()}}function sh(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,n=0;it in r?Q3(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,P0=(r,t)=>{for(var e in t||(t={}))eG.call(t,e)&&E0(r,e,t[e]);if(w0)for(var e of w0(t))rG.call(t,e)&&E0(r,e,t[e]);return r},iG=(r,t)=>J3(r,tG(t));class Kc{constructor(t){this.textureView=null,this.gpuTexture=t}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}const qc=class J1{constructor(t){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=t,t.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new Ut({renderer:t,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const e=P0({image:Yc,buffer:y0,video:T0,compressed:b0},J1.uploadExtensions);this._uploads=iG(P0({},e),{cube:x0(e)})}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(t){this._gpu=t}initSource(t){var e;return((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||this._initSource(t)}_initSource(t){if(t.autoGenerateMipmaps){const l=Math.max(t.pixelWidth,t.pixelHeight);t.mipLevelCount=Math.floor(Math.log2(l))+1}let e;t.sampleCount>1?(e=GPUTextureUsage.RENDER_ATTACHMENT,t.transient&&this._renderer.device.extensions.transientAttachment&&(e|=GPUTextureUsage.TRANSIENT_ATTACHMENT)):(e=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,t.uploadMethodId!=="compressed"&&(e|=GPUTextureUsage.RENDER_ATTACHMENT,e|=GPUTextureUsage.COPY_SRC));const i=Vc[t.format]||{blockBytes:4,blockWidth:1,blockHeight:1},n=Math.ceil(t.pixelWidth/i.blockWidth)*i.blockWidth,s=Math.ceil(t.pixelHeight/i.blockHeight)*i.blockHeight,a={label:t.label,size:{width:n,height:s,depthOrArrayLayers:t.arrayLayerCount},format:t.format,sampleCount:t.sampleCount,mipLevelCount:t.mipLevelCount,dimension:t.dimension,usage:e},o=this._gpu.device.createTexture(a);return t._gpuData[this._renderer.uid]=new Kc(o),this._managedTextures.add(t)&&(t.on("update",this.onSourceUpdate,this),t.on("resize",this.onSourceResize,this),t.on("updateMipmaps",this.onUpdateMipmaps,this)),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))}onUpdateMipmaps(t){this._mipmapGenerator||(this._mipmapGenerator=new S0(this._gpu.device));const e=this.getGpuSource(t);this._mipmapGenerator.generateMipmap(e)}onSourceUnload(t){t.off("update",this.onSourceUpdate,this),t.off("resize",this.onSourceResize,this),t.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(t){t._gcLastUsed=this._renderer.gc.now;const e=t._gpuData[this._renderer.uid],i=e==null?void 0:e.gpuTexture;i?(i.width!==t.pixelWidth||i.height!==t.pixelHeight)&&(e.destroy(),this._bindGroupHash[t.uid]=null,t._gpuData[this._renderer.uid]=null,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){var e;return t._gcLastUsed=this._renderer.gc.now,((e=t._gpuData[this._renderer.uid])==null?void 0:e.gpuTexture)||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 Ee({0:e,1:e.style,2:new At({uTextureMatrix:{type:"mat3x3",value:t.textureMatrix.mapCoord}})}),this._bindGroupHash[t.uid]}getTextureView(t){const e=t.source;e._gcLastUsed=this._renderer.gc.now;let i=e._gpuData[this._renderer.uid];return i||(this.initSource(e),i=e._gpuData[this._renderer.uid]),i.textureView||(i.textureView=i.gpuTexture.createView({dimension:e.viewDimension})),i.textureView}generateCanvas(t){const e=this._renderer,i=e.gpu.device.createCommandEncoder(),n=H.get().createCanvas();n.width=t.source.pixelWidth,n.height=t.source.pixelHeight;const s=n.getContext("webgpu");return s.configure({device:e.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:H.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),i.copyTextureToTexture({texture:e.texture.getGpuSource(t.source),origin:{x:0,y:0}},{texture:s.getCurrentTexture()},{width:n.width,height:n.height}),e.gpu.device.queue.submit([i.finish()]),n}getPixels(t){const e=this.generateCanvas(t),i=me.getOptimalCanvasAndContext(e.width,e.height),n=i.context;n.drawImage(e,0,0);const{width:s,height:a}=e,o=n.getImageData(0,0,s,a),l=new Uint8ClampedArray(o.data.buffer);return me.returnCanvasAndContext(i),{pixels:l,width:s,height:a}}destroy(){this._managedTextures.destroy();for(const t of Object.keys(this._bindGroupHash)){const e=Number(t),i=this._bindGroupHash[e];i==null||i.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}};qc.extension={type:[S.WebGPUSystem],name:"texture"},qc.uploadExtensions=Object.create(null);let Zc=qc;N.handleByMap(S.TextureUploaderWebGPU,Zc.uploadExtensions);class Qc{constructor(){this._maxTextures=0}contextChange(t){const e=new At({uTransformMatrix:{value:new U,type:"mat3x3"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4"},uRound:{value:0,type:"f32"}});this._maxTextures=t.limits.maxBatchableTextures;const i=Fr({name:"graphics",bits:[Xn,Hn(this._maxTextures),By,Ur]});this.shader=new ee({gpuProgram:i,resources:{localUniforms:e}})}execute(t,e){const i=e.context,n=i.customShader||this.shader,s=t.renderer,a=s.graphicsContext,{batcher:o,instructions:l}=a.getContextRenderData(i),u=s.encoder;u.setGeometry(o.geometry,n.gpuProgram);const c=s.globalUniforms.bindGroup;u.setBindGroup(0,c,n.gpuProgram);const h=s.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);u.setBindGroup(2,h,n.gpuProgram);const p=l.instructions;let f=null;for(let m=0;m",value:new U}}}})}execute(t,e){const i=t.renderer;let n=e._shader;if(!n)n=this._shader,n.groups[2]=i.texture.getTextureBindGroup(e.texture);else if(!n.gpuProgram)return;const s=n.gpuProgram;if(s.autoAssignGlobalUniforms&&(n.groups[0]=i.globalUniforms.bindGroup),s.autoAssignLocalUniforms){const a=t.localUniforms;n.groups[1]=i.renderPipes.uniformBatch.getUniformBindGroup(a,!0)}i.encoder.draw({geometry:e._geometry,shader:n,state:e.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Jc.extension={type:[S.WebGPUPipesAdaptor],name:"mesh"};const nG=[...Qs,Nc,$c,oa,kc,Dc,Zc,Hc,zc,Wc,jc,Uc,Lc,Fc],sG=[...ic,Xc],aG=[Gu,Jc,Qc],A0=[],C0=[],M0=[];N.handleByNamedList(S.WebGPUSystem,A0),N.handleByNamedList(S.WebGPUPipes,C0),N.handleByNamedList(S.WebGPUPipesAdaptor,M0),N.add(...nG,...sG,...aG);class R0 extends Mr{constructor(){const t={name:"webgpu",type:It.WEBGPU,systems:A0,renderPipes:C0,renderPipeAdaptors:M0};super(t)}}var oG={__proto__:null,WebGPURenderer:R0};const lG={POINTS:"point-list",LINES:"line-list",LINE_STRIP:"line-strip",TRIANGLES:"triangle-list",TRIANGLE_STRIP:"triangle-strip"},uG=new Proxy(lG,{get(r,t){return r[t]}});var th=(r=>(r.CLAMP="clamp-to-edge",r.REPEAT="repeat",r.MIRRORED_REPEAT="mirror-repeat",r))(th||{});const cG=new Proxy(th,{get(r,t){return r[t]}});var eh=(r=>(r.NEAREST="nearest",r.LINEAR="linear",r))(eh||{});const hG=new Proxy(eh,{get(r,t){return r[t]}});var dG=Object.defineProperty,pG=Object.defineProperties,fG=Object.getOwnPropertyDescriptors,la=Object.getOwnPropertySymbols,O0=Object.prototype.hasOwnProperty,G0=Object.prototype.propertyIsEnumerable,I0=(r,t,e)=>t in r?dG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mG=(r,t)=>{for(var e in t||(t={}))O0.call(t,e)&&I0(r,e,t[e]);if(la)for(var e of la(t))G0.call(t,e)&&I0(r,e,t[e]);return r},gG=(r,t)=>pG(r,fG(t)),_G=(r,t)=>{var e={};for(var i in r)O0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&la)for(var i of la(r))t.indexOf(i)<0&&G0.call(r,i)&&(e[i]=r[i]);return e};class ei extends ft{constructor(t){const e=t,{faces:i}=e,n=_G(e,["faces"]);ei._validateFaces(i);const s=i.right,a=s.resolution,o=s.format,l=s.alphaMode;super(gG(mG({},n),{resource:i,width:s.width,height:s.height,dimensions:"2d",viewDimension:"cube",arrayLayerCount:6,resolution:a,format:o,alphaMode:l})),this.uploadMethodId="cube",this.faces=i;for(const u of Object.keys(i)){const c=i[u];c.on("update",this._onFaceUpdate,this),c.on("resize",this._onFaceResize,this),c.on("unload",this._onFaceUpdate,this)}}destroy(){const t=this.faces;if(t)for(const e of Object.keys(t)){const i=t[e];i.off("update",this._onFaceUpdate,this),i.off("resize",this._onFaceResize,this),i.off("unload",this._onFaceUpdate,this)}super.destroy()}_onFaceUpdate(){this.emit("update",this)}_onFaceResize(t){ei._validateFaces(this.faces),this.resize(t.width,t.height,t.resolution)}static _validateFaces(t){if(!t.right||!t.left||!t.top||!t.bottom||!t.front||!t.back)throw new Error("[CubeTextureSource] Requires { left, right, top, bottom, front, back } faces.");const e=t.right,i=e.pixelWidth,n=e.pixelHeight,s=e.format,a=e.alphaMode,o=e.resolution;for(const l of Object.keys(t)){const u=t[l];if(u.pixelWidth!==i||u.pixelHeight!==n)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different size. All faces must match.`);if(u.format!==s)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different format. All faces must match.`);if(u.alphaMode!==a)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different alphaMode. All faces must match.`);if(u.resolution!==o)throw new Error(`[CubeTextureSource] Face '${String(l)}' has a different resolution. All faces must match.`)}}}var yG=Object.defineProperty,bG=Object.defineProperties,vG=Object.getOwnPropertyDescriptors,ua=Object.getOwnPropertySymbols,B0=Object.prototype.hasOwnProperty,F0=Object.prototype.propertyIsEnumerable,D0=(r,t,e)=>t in r?yG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,U0=(r,t)=>{for(var e in t||(t={}))B0.call(t,e)&&D0(r,e,t[e]);if(ua)for(var e of ua(t))F0.call(t,e)&&D0(r,e,t[e]);return r},xG=(r,t)=>bG(r,vG(t)),TG=(r,t)=>{var e={};for(var i in r)B0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ua)for(var i of ua(r))t.indexOf(i)<0&&F0.call(r,i)&&(e[i]=r[i]);return e};const rh=["left","right","top","bottom","front","back"];function SG(r,t){const e=t?U0({},t):{};delete e.label;const i=Object.keys(e).sort(),n=i.length?`|${i.map(s=>`${s}=${String(e[s])}`).join("&")}`:"";return`cube:${rh.map(s=>r[s]).join(",")}${n}`}class ca extends Nt{constructor(t){var e;super(),this.uid=ht("cubeTexture"),this.destroyed=!1;const{label:i,source:n}=t;this.label=i,this.source=n,this.source.label=(e=this.label)!=null?e:this.source.label}static from(t,e=!1){if(t instanceof ei)return new ca({source:t});const i=t,{faces:n}=i,s=TG(i,["faces"]);let a=null;const o=rh.every(h=>typeof n[h]=="string");if(!e&&o&&(a=SG(n,s),it.has(a)))return it.get(a);const l=h=>h.isTexture?h:D.from(h),u={};for(const h of rh)u[h]=l(n[h]).source;const c=new ca({source:new ei(xG(U0({},s),{faces:u})),label:s.label});return a&&(it.set(a,c),c.once("destroy",()=>{it.has(a)&&it.remove(a)})),c}destroy(t=!1){this.destroyed||(this.destroyed=!0,t&&this.source.destroy(),this.emit("destroy",this),this.removeAllListeners())}}const ih=Object.create(null),nh=Object.create(null);function wG(r){var t;if(r.type===It.WEBGPU)return nh[t=r.uid]||(nh[t]=r.gpu.device.createTexture({label:"ExternalSource placeholder",size:{width:1,height:1},format:"rgba8unorm",usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST})),nh[r.uid];if(!ih[r.uid]){const e=r.gl,i=e.createTexture();e.bindTexture(e.TEXTURE_2D,i),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,null),ih[r.uid]=i}return ih[r.uid]}class EG extends ft{constructor({resource:t,renderer:e,label:i,width:n,height:s}){var a,o;t||(t=wG(e)),n||(n=(a=n!=null?n:t==null?void 0:t.width)!=null?a:1),s||(s=(o=s!=null?s:t==null?void 0:t.height)!=null?o:1),super({resource:t,width:n,height:s,label:i,autoGarbageCollect:!1}),this._renderer=e,this._initGpuData(t)}static test(t){return globalThis.GPUTexture&&t instanceof GPUTexture||globalThis.WebGLTexture&&t instanceof WebGLTexture}_validateTexture(t){const e=this._renderer,i=!!e.gpu,n=globalThis.GPUTexture&&t instanceof GPUTexture,s=globalThis.WebGLTexture&&t instanceof WebGLTexture;if(i&&s)throw new Error("Cannot use WebGLTexture with a WebGPU renderer");if(!i&&n)throw new Error("Cannot use GPUTexture with a WebGL renderer");if(!i){const a=e.gl;if(a&&!a.isTexture(t))throw new Error("WebGLTexture does not belong to this renderer's WebGL context")}}_initGpuData(t){const e=this._renderer;this._validateTexture(t),e.gpu?this._gpuData[e.uid]=new Kc(t):this._gpuData[e.uid]=new Ac(t)}updateGPUTexture(t,e,i){const n=this._renderer,s=this._gpuData[n.uid];if(this.resource=t,n.gpu){this._validateTexture(t);const a=s;if(a.gpuTexture!==t){a.gpuTexture=t,a.textureView=null;const u=n.texture;u!=null&&u._bindGroupHash&&(u._bindGroupHash[this.uid]=null)}const o=e!=null?e:t.width,l=i!=null?i:t.height;this.resize(o,l)}else{this._validateTexture(t);const a=s;a.texture=t,e!==void 0&&i!==void 0&&this.resize(e,i)}this.emit("update",this)}destroy(){const t=this._renderer;delete this._gpuData[t.uid],super.destroy()}}class PG{constructor(){this.x0=0,this.y0=0,this.x1=1,this.y1=0,this.x2=1,this.y2=1,this.x3=0,this.y3=1,this.uvsFloat32=new Float32Array(8)}set(t,e,i){const n=e.width,s=e.height;if(i){const a=t.width/2/n,o=t.height/2/s,l=t.x/n+a,u=t.y/s+o;i=W.add(i,W.NW),this.x0=l+a*W.uX(i),this.y0=u+o*W.uY(i),i=W.add(i,2),this.x1=l+a*W.uX(i),this.y1=u+o*W.uY(i),i=W.add(i,2),this.x2=l+a*W.uX(i),this.y2=u+o*W.uY(i),i=W.add(i,2),this.x3=l+a*W.uX(i),this.y3=u+o*W.uY(i)}else this.x0=t.x/n,this.y0=t.y/s,this.x1=(t.x+t.width)/n,this.y1=t.y/s,this.x2=(t.x+t.width)/n,this.y2=(t.y+t.height)/s,this.x3=t.x/n,this.y3=(t.y+t.height)/s;this.uvsFloat32[0]=this.x0,this.uvsFloat32[1]=this.y0,this.uvsFloat32[2]=this.x1,this.uvsFloat32[3]=this.y1,this.uvsFloat32[4]=this.x2,this.uvsFloat32[5]=this.y2,this.uvsFloat32[6]=this.x3,this.uvsFloat32[7]=this.y3}}function AG(r){const t=r.toString(),e=t.indexOf("{"),i=t.lastIndexOf("}");if(e===-1||i===-1)throw new Error("getFunctionBody: No body found in function definition");return t.slice(e+1,i).trim()}function CG(r,t){return r.getFastGlobalBounds(!0,t)}var MG=Object.defineProperty,ha=Object.getOwnPropertySymbols,$0=Object.prototype.hasOwnProperty,k0=Object.prototype.propertyIsEnumerable,L0=(r,t,e)=>t in r?MG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,RG=(r,t)=>{for(var e in t||(t={}))$0.call(t,e)&&L0(r,e,t[e]);if(ha)for(var e of ha(t))k0.call(t,e)&&L0(r,e,t[e]);return r},OG=(r,t)=>{var e={};for(var i in r)$0.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ha)for(var i of ha(r))t.indexOf(i)<0&&k0.call(r,i)&&(e[i]=r[i]);return e};class GG extends Se{constructor(t){var e,i;typeof t=="function"&&(t={render:t});const n=t,{render:s}=n,a=OG(n,["render"]);super(RG({label:"RenderContainer"},a)),this.renderPipeId="customRender",this.batched=!1,s&&(this.render=s),this.containsPoint=(e=t.containsPoint)!=null?e:(()=>!1),this.addBounds=(i=t.addBounds)!=null?i:(()=>!1)}updateBounds(){this._bounds.clear(),this.addBounds(this._bounds)}render(t){}}function IG(r,t,e){const i=e.renderPipes?e:e.batch.renderer;return r.collectRenderables(t,i,null)}function BG(r,t){const e=t._scale,i=t._pivot,n=t._position,s=e._x,a=e._y,o=i._x,l=i._y;r.a=t._cx*s,r.b=t._sx*s,r.c=t._cy*a,r.d=t._sy*a,r.tx=n._x-(o*r.a+l*r.c),r.ty=n._y-(o*r.b+l*r.d)}function FG(r,t,e){const i=r.a,n=r.b,s=r.c,a=r.d,o=r.tx,l=r.ty,u=t.a,c=t.b,h=t.c,p=t.d;e.a=i*u+n*h,e.b=i*c+n*p,e.c=s*u+a*h,e.d=s*c+a*p,e.tx=o*u+l*h+t.tx,e.ty=o*c+l*p+t.ty}class N0{constructor(){this._gradients=[],this._nextId=0}addStyle(t){var e;if(!(t.fill instanceof $t))return null;const i=`pixi-grad-${this._nextId++}`;return this._gradients.push({id:i,gradient:t.fill,textureSpace:(e=t.textureSpace)!=null?e:"local"}),`url(#${i})`}build(){var t,e,i,n,s,a,o,l,u,c,h,p,f,m,g,_,y;if(this._gradients.length===0)return"";const b=[""];for(const{id:x,gradient:v,textureSpace:w}of this._gradients){const T=w==="global"?"userSpaceOnUse":"objectBoundingBox",E=DG(v.colorStops);if(v.type==="radial"){const P=(e=(t=v.outerCenter)==null?void 0:t.x)!=null?e:.5,M=(n=(i=v.outerCenter)==null?void 0:i.y)!=null?n:.5,C=(s=v.outerRadius)!=null?s:.5,A=(o=(a=v.center)==null?void 0:a.x)!=null?o:P,G=(u=(l=v.center)==null?void 0:l.y)!=null?u:M;b.push(``,E,"")}else{const P=(h=(c=v.start)==null?void 0:c.x)!=null?h:0,M=(f=(p=v.start)==null?void 0:p.y)!=null?f:0,C=(g=(m=v.end)==null?void 0:m.x)!=null?g:1,A=(y=(_=v.end)==null?void 0:_.y)!=null?y:0;b.push(``,E,"")}}return b.push(""),b.join("")}}function DG(r){return r.map(t=>{const e=tt.shared.setValue(t.color).toHex();return``}).join("")}const gr=Math.PI*2,UG=new Set(["regularPoly","roundPoly","roundShape","filletRect","chamferRect","arcTo"]);function Ye(r,t=2,e=!1){var i,n,s;if(r.instructions.some(l=>UG.has(l.action)))return NG(r,t,e);const a=[];let o=!1;for(let l=0;l0&&(i-=gr):i<0&&(i+=gr),Math.abs(i)>=gr-1e-6}function V(r,t){return parseFloat(r.toFixed(t)).toString()}function Ft(r,t,e,i){if(e&&!e.isIdentity()){const n=e.a*r+e.c*t+e.tx,s=e.b*r+e.d*t+e.ty;return`${V(n,i)} ${V(s,i)}`}return`${V(r,i)} ${V(t,i)}`}function kG(r,t,e,i,n,s,a,o,l=!1){let u=n-i;if(s?u>0&&(u-=gr):u<0&&(u+=gr),Math.abs(u)>=gr-1e-6)return qi(r,t,e,e,null,o,l);if(l){const _=[];for(let y=0;y<=32;y++){const b=i+y/32*u,x=r+e*Math.cos(b),v=t+e*Math.sin(b),w=y===0?a?"L":"M":"L";_.push(`${w}${V(x,o)} ${V(v,o)}`)}return _.join("")}const c=r+e*Math.cos(i),h=t+e*Math.sin(i),p=r+e*Math.cos(n),f=t+e*Math.sin(n),m=Math.abs(u)>Math.PI?1:0,g=s?0:1;return`${a?"L":"M"}${V(c,o)} ${V(h,o)}A${V(e,o)} ${V(e,o)} 0 ${m} ${g} ${V(p,o)} ${V(f,o)}`}function qi(r,t,e,i,n,s,a=!1){const o=n&&!n.isIdentity()?n:null;if(!o&&!a)return`M${V(r-e,s)} ${V(t,s)}A${V(e,s)} ${V(i,s)} 0 1 1 ${V(r+e,s)} ${V(t,s)}A${V(e,s)} ${V(i,s)} 0 1 1 ${V(r-e,s)} ${V(t,s)}Z`;const l=64,u=[];for(let c=0;c`);break}case"stroke":{const g=m;let _=Ye(g.data.path,t);g.data.hole&&(_+=Ye(g.data.hole,t,!0));const y=z0(g.data.style,i);n.push(``);break}case"texture":break}a++}const o=e.bounds,l=parseFloat(o.minX.toFixed(t)),u=parseFloat(o.minY.toFixed(t)),c=parseFloat((o.maxX-o.minX).toFixed(t)),h=parseFloat((o.maxY-o.minY).toFixed(t)),p=i.build(),f=n.join("");return`${p}${f}`}function jG(r){r instanceof ge&&(r={path:r,textureMatrix:null,out:null});const t=[],e=[],i=[],n=r.path.shapePath,s=r.textureMatrix;n.shapePrimitives.forEach(({shape:o,transform:l})=>{const u=i.length,c=t.length/2,h=[],p=Ne[o.type];p.build(o,h),l&&Yn(h,l),p.triangulate(h,t,2,c,i,u);const f=e.length/2;s?(l&&s.append(l.clone().invert()),rl(t,2,c,e,f,2,t.length/2-c,s)):il(e,f,2,t.length/2-c)});const a=r.out;return a?(a.positions=new Float32Array(t),a.uvs=new Float32Array(e),a.indices=new Uint32Array(i),a):new ze({positions:new Float32Array(t),uvs:new Float32Array(e),indices:new Uint32Array(i)})}var HG=Object.defineProperty,W0=Object.getOwnPropertySymbols,zG=Object.prototype.hasOwnProperty,WG=Object.prototype.propertyIsEnumerable,V0=(r,t,e)=>t in r?HG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Y0=(r,t)=>{for(var e in t||(t={}))zG.call(t,e)&&V0(r,e,t[e]);if(W0)for(var e of W0(t))WG.call(t,e)&&V0(r,e,t[e]);return r};const K0=class tS extends dt{constructor(t={}){t=Y0(Y0({},tS.defaultOptions),t),super(),this.renderLayerChildren=[],this.sortableChildren=t.sortableChildren,this.sortFunction=t.sortFunction}attach(...t){for(let e=0;er.zIndex-t.zIndex};let VG=K0;var YG=Object.defineProperty,q0=Object.getOwnPropertySymbols,KG=Object.prototype.hasOwnProperty,qG=Object.prototype.propertyIsEnumerable,Z0=(r,t,e)=>t in r?YG(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Q0=(r,t)=>{for(var e in t||(t={}))KG.call(t,e)&&Z0(r,e,t[e]);if(q0)for(var e of q0(t))qG.call(t,e)&&Z0(r,e,t[e]);return r};const J0=class eS extends ze{constructor(...t){var e;super({});let i=(e=t[0])!=null?e:{};typeof i=="number"&&(i={width:i,height:t[1],verticesX:t[2],verticesY:t[3]}),this.build(i)}build(t){var e,i,n,s;t=Q0(Q0({},eS.defaultOptions),t),this.verticesX=(e=this.verticesX)!=null?e:t.verticesX,this.verticesY=(i=this.verticesY)!=null?i:t.verticesY,this.width=(n=this.width)!=null?n:t.width,this.height=(s=this.height)!=null?s:t.height;const a=this.verticesX*this.verticesY,o=[],l=[],u=[],c=this.verticesX-1,h=this.verticesY-1,p=this.width/c,f=this.height/h;for(let g=0;gt in r?rI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ah=(r,t)=>{for(var e in t||(t={}))aT.call(t,e)&&lT(r,e,t[e]);if(fa)for(var e of fa(t))oT.call(t,e)&&lT(r,e,t[e]);return r},sI=(r,t)=>iI(r,nI(t)),aI=(r,t)=>{var e={};for(var i in r)aT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&fa)for(var i of fa(r))t.indexOf(i)<0&&oT.call(r,i)&&(e[i]=r[i]);return e};const uT=class rS extends Kr{constructor(t){t=ah(ah({},rS.defaultOptions),t);const e=t,{texture:i,verticesX:n,verticesY:s}=e,a=aI(e,["texture","verticesX","verticesY"]),o=new sT(he({width:i.width,height:i.height,verticesX:n,verticesY:s}));super(he(sI(ah({},a),{geometry:o}))),this._texture=i,this.geometry.setCorners(t.x0,t.y0,t.x1,t.y1,t.x2,t.y2,t.x3,t.y3)}textureUpdated(){const t=this.geometry;if(!t)return;const{width:e,height:i}=this.texture;(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.updateProjection())}set texture(t){this._texture!==t&&(super.texture=t,this.textureUpdated())}get texture(){return this._texture}setCorners(t,e,i,n,s,a,o,l){this.geometry.setCorners(t,e,i,n,s,a,o,l)}};uT.defaultOptions={texture:D.WHITE,verticesX:10,verticesY:10,x0:0,y0:0,x1:100,y1:0,x2:100,y2:100,x3:0,y3:100};let oI=uT;var lI=Object.defineProperty,uI=Object.defineProperties,cI=Object.getOwnPropertyDescriptors,ma=Object.getOwnPropertySymbols,cT=Object.prototype.hasOwnProperty,hT=Object.prototype.propertyIsEnumerable,dT=(r,t,e)=>t in r?lI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,hI=(r,t)=>{for(var e in t||(t={}))cT.call(t,e)&&dT(r,e,t[e]);if(ma)for(var e of ma(t))hT.call(t,e)&&dT(r,e,t[e]);return r},dI=(r,t)=>uI(r,cI(t)),pI=(r,t)=>{var e={};for(var i in r)cT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ma)for(var i of ma(r))t.indexOf(i)<0&&hT.call(r,i)&&(e[i]=r[i]);return e};class fI extends Kr{constructor(t){const e=t,{texture:i,verticesX:n,verticesY:s}=e,a=pI(e,["texture","verticesX","verticesY"]),o=new da(he({width:i.width,height:i.height,verticesX:n,verticesY:s}));super(he(dI(hI({},a),{geometry:o,texture:i}))),this.texture=i,this.autoResize=!0}textureUpdated(){const t=this.geometry,{width:e,height:i}=this.texture;this.autoResize&&(t.width!==e||t.height!==i)&&(t.width=e,t.height=i,t.build({}))}set texture(t){var e;(e=this._texture)==null||e.off("update",this.textureUpdated,this),super.texture=t,t.on("update",this.textureUpdated,this),this.textureUpdated()}get texture(){return this._texture}destroy(t){this.texture.off("update",this.textureUpdated,this),super.destroy(t)}}var mI=Object.defineProperty,pT=Object.getOwnPropertySymbols,gI=Object.prototype.hasOwnProperty,_I=Object.prototype.propertyIsEnumerable,fT=(r,t,e)=>t in r?mI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,mT=(r,t)=>{for(var e in t||(t={}))gI.call(t,e)&&fT(r,e,t[e]);if(pT)for(var e of pT(t))_I.call(t,e)&&fT(r,e,t[e]);return r};const gT=class iS extends ze{constructor(t){const{width:e,points:i,textureScale:n}=mT(mT({},iS.defaultOptions),t);super({positions:new Float32Array(i.length*4),uvs:new Float32Array(i.length*4),indices:new Uint32Array((i.length-1)*6)}),this.points=i,this._width=e,this.textureScale=n,this._build()}get width(){return this._width}_build(){const t=this.points;if(!t)return;const e=this.getBuffer("aPosition"),i=this.getBuffer("aUV"),n=this.getIndex();if(t.length<1)return;e.data.length/4!==t.length&&(e.data=new Float32Array(t.length*4),i.data=new Float32Array(t.length*4),n.data=new Uint16Array((t.length-1)*6));const s=i.data,a=n.data;s[0]=0,s[1]=0,s[2]=0,s[3]=1;let o=0,l=t[0];const u=this._width*this.textureScale,c=t.length;for(let p=0;p0){const m=l.x-t[p].x,g=l.y-t[p].y,_=Math.sqrt(m*m+g*g);l=t[p],o+=_/u}else o=p/(c-1);s[f]=o,s[f+1]=0,s[f+2]=o,s[f+3]=1}let h=0;for(let p=0;p0?this.textureScale*this._width/2:this._width/2;for(let u=0;u1&&(p=1);const f=Math.sqrt(n*n+s*s);f<1e-6?(n=0,s=0):(n/=f,s/=f,n*=l,s*=l),a[h]=c.x+n,a[h+1]=c.y+s,a[h+2]=c.x-n,a[h+3]=c.y-s,e=c}this.buffers[0].update()}update(){this.textureScale>0?this._build():this.updateVertices()}};gT.defaultOptions={width:200,points:[],textureScale:0};let _T=gT;var yI=Object.defineProperty,bI=Object.defineProperties,vI=Object.getOwnPropertyDescriptors,ga=Object.getOwnPropertySymbols,yT=Object.prototype.hasOwnProperty,bT=Object.prototype.propertyIsEnumerable,vT=(r,t,e)=>t in r?yI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,oh=(r,t)=>{for(var e in t||(t={}))yT.call(t,e)&&vT(r,e,t[e]);if(ga)for(var e of ga(t))bT.call(t,e)&&vT(r,e,t[e]);return r},xI=(r,t)=>bI(r,vI(t)),TI=(r,t)=>{var e={};for(var i in r)yT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ga)for(var i of ga(r))t.indexOf(i)<0&&bT.call(r,i)&&(e[i]=r[i]);return e};const xT=class nS extends Kr{constructor(t){const e=oh(oh({},nS.defaultOptions),t),{width:i,texture:n,points:s,textureScale:a}=e,o=TI(e,["width","texture","points","textureScale"]),l=new _T(he({width:i!=null?i:n.height,points:s,textureScale:a}));a>0&&(n.source.style.addressMode="repeat"),super(he(xI(oh({},o),{texture:n,geometry:l}))),this.autoUpdate=!0,this.onRender=this._render}_render(){const t=this.geometry;(this.autoUpdate||t._width!==this.texture.height)&&(t._width=this.texture.height,t.update())}};xT.defaultOptions={textureScale:0};let SI=xT;var wI=Object.defineProperty,EI=Object.defineProperties,PI=Object.getOwnPropertyDescriptors,_a=Object.getOwnPropertySymbols,TT=Object.prototype.hasOwnProperty,ST=Object.prototype.propertyIsEnumerable,wT=(r,t,e)=>t in r?wI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,AI=(r,t)=>{for(var e in t||(t={}))TT.call(t,e)&&wT(r,e,t[e]);if(_a)for(var e of _a(t))ST.call(t,e)&&wT(r,e,t[e]);return r},CI=(r,t)=>EI(r,PI(t)),MI=(r,t)=>{var e={};for(var i in r)TT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&_a)for(var i of _a(r))t.indexOf(i)<0&&ST.call(r,i)&&(e[i]=r[i]);return e};class RI extends Kr{constructor(t){const e=t,{texture:i,vertices:n,uvs:s,indices:a,topology:o}=e,l=MI(e,["texture","vertices","uvs","indices","topology"]),u=new ze(he({positions:n,uvs:s,indices:a,topology:o}));super(he(CI(AI({},l),{texture:i,geometry:u}))),this.autoUpdate=!0,this.onRender=this._render}get vertices(){return this.geometry.getBuffer("aPosition").data}set vertices(t){this.geometry.getBuffer("aPosition").data=t}_render(){this.autoUpdate&&this.geometry.getBuffer("aPosition").update()}}function OI(r,t){const{width:e,height:i}=r.frame;return t.scale(1/e,1/i),t}class ET{execute(t,e){var i,n,s;const a=t.renderer,o=a.canvasContext.activeContext,l=e.particleChildren,u=e.texture;o.save(),a.canvasContext.setContextTransform(e.worldTransform,e.roundPixels),a.canvasContext.setBlendMode(e.groupBlendMode);const c=e.groupColorAlpha,h=(n=(i=a.filter)==null?void 0:i.alphaMultiplier)!=null?n:1,p=(c>>>24&255)/255*h;for(let f=0;f>>24&255)/255*p;if(y<=0)continue;const b=_&16777215,x=((b&255)<<16)+(b&65280)+(b>>16&255);let v=g.source.resource;x!==16777215&&(v=Q.getTintedCanvas({texture:g},x));const w=g.frame,T=g.source.resolution,E=w.x*T,P=w.y*T,M=w.width*T,C=w.height*T;o.globalAlpha=y;const A=-m.anchorX*w.width,G=-m.anchorY*w.height;m.rotation!==0||m.scaleX!==1||m.scaleY!==1?(o.save(),o.translate(m.x,m.y),o.rotate(m.rotation),o.scale(m.scaleX,m.scaleY),o.drawImage(v,E,P,M,C,A,G,w.width,w.height),o.restore()):o.drawImage(v,E,P,M,C,m.x+A,m.y+G,w.width,w.height)}o.restore()}}function lh(r,t=null){const e=r*6;if(e>65535?t||(t=new Uint32Array(e)):t||(t=new Uint16Array(e)),t.length!==e)throw new Error(`Out buffer length is incorrect, got ${t.length} and expected ${e}`);for(let i=0,n=0;i, s: f32) -> vec3 { `),e.unshift(` var stride = ${i}; `);const n=e.join(` -`);return new Function("ps","f32v","u32v",n)}class ET{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const i=this._size=(e=t.size)!=null?e:1e3,n=t.properties;let s=0,a=0;for(const h in n){const p=n[h],f=Ie(p.format);p.dynamic?a+=f.stride:s+=f.stride}this._dynamicStride=a/4,this._staticStride=s/4,this.staticAttributeBuffer=new or(i*4*s),this.dynamicAttributeBuffer=new or(i*4*a),this.indexBuffer=sh(i);const o=new nr;let l=0,u=0;this._staticBuffer=new Yt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:at.VERTEX|at.COPY_DST}),this._dynamicBuffer=new Yt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:at.VERTEX|at.COPY_DST});for(const h in n){const p=n[h],f=Ie(p.format);p.dynamic?(o.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:p.format}),l+=f.size):(o.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:p.format}),u+=f.size)}o.addIndex(this.indexBuffer);const c=this.getParticleUpdate(n);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=o}getParticleUpdate(t){const e=AI(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return wT(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new or(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new or(this._size*this._dynamicStride*4*4),this.indexBuffer=sh(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 n=this.staticAttributeBuffer;this._staticUpload(t,n.float32View,n.uint32View),this._staticBuffer.setDataWithSize(n.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function AI(r){const t=[];for(const e in r){const i=r[e];t.push(e,i.code,i.dynamic?"d":"s")}return t.join("_")}var AT=`varying vec2 vUV; +`);return new Function("ps","f32v","u32v",n)}class CT{constructor(t){this._size=0,this._generateParticleUpdateCache={};var e;const i=this._size=(e=t.size)!=null?e:1e3,n=t.properties;let s=0,a=0;for(const h in n){const p=n[h],f=Ie(p.format);p.dynamic?a+=f.stride:s+=f.stride}this._dynamicStride=a/4,this._staticStride=s/4,this.staticAttributeBuffer=new or(i*4*s),this.dynamicAttributeBuffer=new or(i*4*a),this.indexBuffer=lh(i);const o=new nr;let l=0,u=0;this._staticBuffer=new Yt({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:at.VERTEX|at.COPY_DST}),this._dynamicBuffer=new Yt({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:at.VERTEX|at.COPY_DST});for(const h in n){const p=n[h],f=Ie(p.format);p.dynamic?(o.addAttribute(p.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:l*4,format:p.format}),l+=f.size):(o.addAttribute(p.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:u*4,format:p.format}),u+=f.size)}o.addIndex(this.indexBuffer);const c=this.getParticleUpdate(n);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=o}getParticleUpdate(t){const e=GI(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return PT(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new or(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new or(this._size*this._dynamicStride*4*4),this.indexBuffer=lh(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 n=this.staticAttributeBuffer;this._staticUpload(t,n.float32View,n.uint32View),this._staticBuffer.setDataWithSize(n.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}}function GI(r){const t=[];for(const e in r){const i=r[e];t.push(e,i.code,i.dynamic?"d":"s")}return t.join("_")}var MT=`varying vec2 vUV; varying vec4 vColor; uniform sampler2D uTexture; @@ -2142,7 +2142,7 @@ uniform sampler2D uTexture; void main(void){ vec4 color = texture2D(uTexture, vUV) * vColor; gl_FragColor = color; -}`,CT=`attribute vec2 aVertex; +}`,RT=`attribute vec2 aVertex; attribute vec2 aUV; attribute vec4 aColor; @@ -2181,7 +2181,7 @@ void main(void){ vUV = aUV; vColor = vec4(aColor.rgb * aColor.a, aColor.a) * uColor; } -`,ah=` +`,uh=` struct ParticleUniforms { uTranslationMatrix:mat3x3, uColor:vec4, @@ -2243,7 +2243,7 @@ fn mainFragment( var sample = textureSample(uTexture, uSampler, uv) * color; return sample; -}`;class MT extends ee{constructor(){const t=Wt.from({vertex:CT,fragment:AT}),e=Xt.from({fragment:{source:ah,entryPoint:"mainFragment"},vertex:{source:ah,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:D.WHITE.source,uSampler:new Jt({}),uniforms:{uTranslationMatrix:{value:new U,type:"mat3x3"},uColor:{value:new tt(16777215),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}}})}}class Zi{constructor(t,e){this.state=Vt.for2d(),this.localUniforms=new At({uTranslationMatrix:{value:new U,type:"mat3x3"},uColor:{value:new Float32Array(4),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new MT,this.state=Vt.for2d(),this._managedContainers=new Ut({renderer:t,type:"renderable",name:"particleContainer"})}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 ET({size:t.particleChildren.length,properties:t._properties}),this._managedContainers.add(t),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const i=this.renderer,n=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const s=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,s.blendMode=Ir(t.blendMode,t.texture._source);const a=this.localUniforms.uniforms,o=a.uTranslationMatrix;t.worldTransform.copyTo(o);const l=i.globalUniforms.globalUniformData;o.tx-=l.offset.x,o.ty-=l.offset.y,o.prepend(l.projectionMatrix),a.uResolution=l.resolution,a.uRound=i._roundPixels|t._roundPixels,Yr(t.groupColorAlpha,a.uColor,0),this.adaptor.execute(this,t)}destroy(){this._managedContainers.destroy(),this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}Zi.extension={type:[S.CanvasPipes],name:"particle"};class oh extends Zi{constructor(t){super(t,new ST)}}oh.extension={type:[S.CanvasPipes],name:"particle"};class RT{execute(t,e){const i=t.state,n=t.renderer,s=e.shader||t.defaultShader;s.resources.uTexture=e.texture._source,s.resources.uniforms=t.localUniforms;const a=n.gl,o=t.getBuffers(e);n.shader.bind(s),n.state.set(i),n.geometry.bind(o.geometry,s.glProgram);const l=o.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;a.drawElements(a.TRIANGLES,e.particleChildren.length*6,l,0)}}class lh extends Zi{constructor(t){super(t,new RT)}}lh.extension={type:[S.WebGLPipes],name:"particle"};class OT{execute(t,e){const i=t.renderer,n=e.shader||t.defaultShader;n.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),n.groups[1]=i.texture.getTextureBindGroup(e.texture);const s=t.state,a=t.getBuffers(e);i.encoder.draw({geometry:a.geometry,shader:e.shader||t.defaultShader,state:s,size:e.particleChildren.length*6})}}class uh extends Zi{constructor(t){super(t,new OT)}}uh.extension={type:[S.WebGPUPipes],name:"particle"};var CI=Object.defineProperty,GT=Object.getOwnPropertySymbols,MI=Object.prototype.hasOwnProperty,RI=Object.prototype.propertyIsEnumerable,IT=(r,t,e)=>t in r?CI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,BT=(r,t)=>{for(var e in t||(t={}))MI.call(t,e)&&IT(r,e,t[e]);if(GT)for(var e of GT(t))RI.call(t,e)&&IT(r,e,t[e]);return r};const FT=class Mh{constructor(t){if(t instanceof D)this.texture=t,fn(this,Mh.defaultOptions,{});else{const e=BT(BT({},Mh.defaultOptions),t);fn(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return xe(this._tint)}set tint(t){this._tint=tt.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};FT.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let OI=FT;const ch={vertex:{attributeName:"aVertex",format:"float32x2",code:` +}`;class OT extends ee{constructor(){const t=Wt.from({vertex:RT,fragment:MT}),e=Xt.from({fragment:{source:uh,entryPoint:"mainFragment"},vertex:{source:uh,entryPoint:"mainVertex"}});super({glProgram:t,gpuProgram:e,resources:{uTexture:D.WHITE.source,uSampler:new Jt({}),uniforms:{uTranslationMatrix:{value:new U,type:"mat3x3"},uColor:{value:new tt(16777215),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}}})}}class Zi{constructor(t,e){this.state=Vt.for2d(),this.localUniforms=new At({uTranslationMatrix:{value:new U,type:"mat3x3"},uColor:{value:new Float32Array(4),type:"vec4"},uRound:{value:1,type:"f32"},uResolution:{value:[0,0],type:"vec2"}}),this.renderer=t,this.adaptor=e,this.defaultShader=new OT,this.state=Vt.for2d(),this._managedContainers=new Ut({renderer:t,type:"renderable",name:"particleContainer"})}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 CT({size:t.particleChildren.length,properties:t._properties}),this._managedContainers.add(t),t._gpuData[this.renderer.uid]}updateRenderable(t){}execute(t){const e=t.particleChildren;if(e.length===0)return;const i=this.renderer,n=this.getBuffers(t);t.texture||(t.texture=e[0].texture);const s=this.state;n.update(e,t._childrenDirty),t._childrenDirty=!1,s.blendMode=Ir(t.groupBlendMode,t.texture._source);const a=this.localUniforms.uniforms,o=a.uTranslationMatrix;t.worldTransform.copyTo(o);const l=i.globalUniforms.globalUniformData;o.tx-=l.offset.x,o.ty-=l.offset.y,o.prepend(l.projectionMatrix),a.uResolution=l.resolution,a.uRound=i._roundPixels|t._roundPixels,Yr(t.groupColorAlpha,a.uColor,0),this.adaptor.execute(this,t)}destroy(){this._managedContainers.destroy(),this.renderer=null,this.defaultShader&&(this.defaultShader.destroy(),this.defaultShader=null)}}Zi.extension={type:[S.CanvasPipes],name:"particle"};class ch extends Zi{constructor(t){super(t,new ET)}}ch.extension={type:[S.CanvasPipes],name:"particle"};class GT{execute(t,e){const i=t.state,n=t.renderer,s=e.shader||t.defaultShader;s.resources.uTexture=e.texture._source,s.resources.uniforms=t.localUniforms;const a=n.gl,o=t.getBuffers(e);n.shader.bind(s),n.state.set(i),n.geometry.bind(o.geometry,s.glProgram);const l=o.geometry.indexBuffer.data.BYTES_PER_ELEMENT===2?a.UNSIGNED_SHORT:a.UNSIGNED_INT;a.drawElements(a.TRIANGLES,e.particleChildren.length*6,l,0)}}class hh extends Zi{constructor(t){super(t,new GT)}}hh.extension={type:[S.WebGLPipes],name:"particle"};class IT{execute(t,e){const i=t.renderer,n=e.shader||t.defaultShader;n.groups[0]=i.renderPipes.uniformBatch.getUniformBindGroup(t.localUniforms,!0),n.groups[1]=i.texture.getTextureBindGroup(e.texture);const s=t.state,a=t.getBuffers(e);i.encoder.draw({geometry:a.geometry,shader:e.shader||t.defaultShader,state:s,size:e.particleChildren.length*6})}}class dh extends Zi{constructor(t){super(t,new IT)}}dh.extension={type:[S.WebGPUPipes],name:"particle"};var II=Object.defineProperty,BT=Object.getOwnPropertySymbols,BI=Object.prototype.hasOwnProperty,FI=Object.prototype.propertyIsEnumerable,FT=(r,t,e)=>t in r?II(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,DT=(r,t)=>{for(var e in t||(t={}))BI.call(t,e)&&FT(r,e,t[e]);if(BT)for(var e of BT(t))FI.call(t,e)&&FT(r,e,t[e]);return r};const UT=class Oh{constructor(t){if(t instanceof D)this.texture=t,gn(this,Oh.defaultOptions,{});else{const e=DT(DT({},Oh.defaultOptions),t);gn(this,e,{})}}get alpha(){return this._alpha}set alpha(t){this._alpha=Math.min(Math.max(t,0),1),this._updateColor()}get tint(){return xe(this._tint)}set tint(t){this._tint=tt.shared.setValue(t!=null?t:16777215).toBgrNumber(),this._updateColor()}_updateColor(){this.color=this._tint+((this._alpha*255|0)<<24)}};UT.defaultOptions={anchorX:0,anchorY:0,x:0,y:0,scaleX:1,scaleY:1,rotation:0,tint:16777215,alpha:1};let DI=UT;const ph={vertex:{attributeName:"aVertex",format:"float32x2",code:` const texture = p.texture; const sx = p.scaleX; const sy = p.scaleY; @@ -2323,7 +2323,7 @@ fn mainFragment( u32v[offset + stride] = c; u32v[offset + (stride * 2)] = c; u32v[offset + (stride * 3)] = c; - `,dynamic:!1}};X.add(lh),X.add(uh),X.add(oh);var GI=Object.defineProperty,II=Object.defineProperties,BI=Object.getOwnPropertyDescriptors,ga=Object.getOwnPropertySymbols,DT=Object.prototype.hasOwnProperty,UT=Object.prototype.propertyIsEnumerable,$T=(r,t,e)=>t in r?GI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ri=(r,t)=>{for(var e in t||(t={}))DT.call(t,e)&&$T(r,e,t[e]);if(ga)for(var e of ga(t))UT.call(t,e)&&$T(r,e,t[e]);return r},kT=(r,t)=>II(r,BI(t)),FI=(r,t)=>{var e={};for(var i in r)DT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ga)for(var i of ga(r))t.indexOf(i)<0&&UT.call(r,i)&&(e[i]=r[i]);return e};const DI=new Mt(0,0,0,0),LT=class Rh extends Se{constructor(t={}){t=kT(ri(ri({},Rh.defaultOptions),t),{dynamicProperties:ri(ri({},Rh.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:i,shader:n,roundPixels:s,texture:a,particles:o}=e,l=FI(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(ri({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=a||null,this.shader=n,this._properties={};for(const u in ch){const c=ch[u],h=i[u];this._properties[u]=kT(ri({},c),{dynamic:h})}this.allowChildren=!0,this.roundPixels=s!=null?s:!1,this.particleChildren=o!=null?o:[]}addParticle(...t){for(let e=0;e-1&&(this.particleChildren.splice(n,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return DI}updateBounds(){}destroy(t=!1){var e,i,n;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource,a=(i=this.texture)!=null?i:(e=this.particleChildren[0])==null?void 0:e.texture;a&&a.destroy(s)}this.texture=null,(n=this.shader)==null||n.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const i=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),i}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};LT.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let UI=LT;class hh{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,i,n,s,a,o;const l=this._renderer,u=l.canvasContext,c=u.activeContext;c.save();const h=t.groupTransform,p=l._roundPixels|t._roundPixels;u.setContextTransform(h,p===1),u.setBlendMode(t.groupBlendMode);const f=(i=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?i:4294967295,m=t.groupColorAlpha,g=(f>>>24&255)/255,_=(m>>>24&255)/255,y=(s=(n=l.filter)==null?void 0:n.alphaMultiplier)!=null?s:1,b=g*_*y;if(b<=0){c.restore();return}c.globalAlpha=b;const x=f&16777215,v=m&16777215,w=xe(Oe(v,x)),T=t.texture,P=Q.getCanvasSource(T);if(!P){c.restore();return}const E=u.smoothProperty,M=T.source.style.scaleMode!=="nearest";c[E]!==M&&(c[E]=M);const C=w!==16777215||T.rotate!==0,A=C?Q.getTintedCanvas({texture:T},w):P,{leftWidth:G,topHeight:F,rightWidth:R,bottomHeight:B,width:O,height:I}=t,L=G+R,j=F+B,J=Math.min(L>O?O/L:1,j>I?I/j:1,1),K=G*J,N=R*J,k=F*J,$=B*J,z=Math.max(0,O-K-N),rt=Math.max(0,I-k-$),_t=t.anchor,et=(o=(a=T.source._resolution)!=null?a:T.source.resolution)!=null?o:1;let st=T.frame.x*et,nt=T.frame.y*et;const ot=-_t.x*O,gt=-_t.y*I,yt=G*et,pt=F*et,Y=R*et,Rt=B*et;let Ct=T.frame.width*et,ce=T.frame.height*et;C&&(st=0,nt=0,Ct=A.width,ce=A.height),c.drawImage(A,st,nt,yt,pt,ot,gt,K,k),c.drawImage(A,st+yt,nt,Ct-yt-Y,pt,ot+K,gt,z,k),c.drawImage(A,st+Ct-Y,nt,Y,pt,ot+O-N,gt,N,k),c.drawImage(A,st,nt+pt,yt,ce-pt-Rt,ot,gt+k,K,rt),c.drawImage(A,st+yt,nt+pt,Ct-yt-Y,ce-pt-Rt,ot+K,gt+k,z,rt),c.drawImage(A,st+Ct-Y,nt+pt,Y,ce-pt-Rt,ot+O-N,gt+k,N,rt),c.drawImage(A,st,nt+ce-Rt,yt,Rt,ot,gt+I-$,K,$),c.drawImage(A,st+yt,nt+ce-Rt,Ct-yt-Y,Rt,ot+K,gt+I-$,z,$),c.drawImage(A,st+Ct-Y,nt+ce-Rt,Y,Rt,ot+O-N,gt+I-$,N,$),c.restore()}destroy(){this._renderer=null}}hh.extension={type:[S.CanvasPipes],name:"nineSliceSprite"};var $I=Object.defineProperty,NT=Object.getOwnPropertySymbols,kI=Object.prototype.hasOwnProperty,LI=Object.prototype.propertyIsEnumerable,XT=(r,t,e)=>t in r?$I(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,jT=(r,t)=>{for(var e in t||(t={}))kI.call(t,e)&&XT(r,e,t[e]);if(NT)for(var e of NT(t))LI.call(t,e)&&XT(r,e,t[e]);return r};const HT=class Sa extends ca{constructor(t={}){var e,i;t=jT(jT({},Sa.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this._trimX=0,this._trimY=0,this._trimWidth=(e=t.originalWidth)!=null?e:Sa.defaultOptions.originalWidth,this._trimHeight=(i=t.originalHeight)!=null?i:Sa.defaultOptions.originalHeight,this.update(t)}update(t){var e,i,n,s,a,o,l,u,c,h,p,f,m,g,_,y,b,x;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(n=t.originalWidth)!=null?n:this._originalWidth,this._originalHeight=(s=t.originalHeight)!=null?s:this._originalHeight,this._leftWidth=(a=t.leftWidth)!=null?a:this._leftWidth,this._rightWidth=(o=t.rightWidth)!=null?o:this._rightWidth,this._topHeight=(l=t.topHeight)!=null?l:this._topHeight,this._bottomHeight=(u=t.bottomHeight)!=null?u:this._bottomHeight,this._anchorX=(c=t.anchor)==null?void 0:c.x,this._anchorY=(h=t.anchor)==null?void 0:h.y,t.trim!==void 0?(this._trimX=(f=(p=t.trim)==null?void 0:p.x)!=null?f:0,this._trimY=(g=(m=t.trim)==null?void 0:m.y)!=null?g:0,this._trimWidth=(y=(_=t.trim)==null?void 0:_.width)!=null?y:this._originalWidth,this._trimHeight=(x=(b=t.trim)==null?void 0:b.height)!=null?x:this._originalHeight):(this._trimWidth=this._originalWidth,this._trimHeight=this._originalHeight),this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:s,_topHeight:a,_bottomHeight:o,_anchorX:l,_anchorY:u}=this,c=n+s,h=e>c?1:e/c,p=a+o,f=i>p?1:i/p,m=Math.min(h,f),g=l*e,_=u*i;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=n*m-g,t[4]=t[12]=t[20]=t[28]=e-s*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-_,t[9]=t[11]=t[13]=t[15]=a*m-_,t[17]=t[19]=t[21]=t[23]=i-o*m-_,t[25]=t[27]=t[29]=t[31]=i-_,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs,e=this._originalWidth,i=this._originalHeight,n=this._trimX/e,s=this._trimY/i,a=(this._trimX+this._trimWidth)/e,o=(this._trimY+this._trimHeight)/i;t[0]=t[8]=t[16]=t[24]=n,t[1]=t[3]=t[5]=t[7]=s,t[6]=t[14]=t[22]=t[30]=a,t[25]=t[27]=t[29]=t[31]=o;const l=1/e,u=1/i;t[2]=t[10]=t[18]=t[26]=n+l*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s+u*this._topHeight,t[4]=t[12]=t[20]=t[28]=a-l*this._rightWidth,t[17]=t[19]=t[21]=t[23]=o-u*this._bottomHeight,this.getBuffer("aUV").update()}};HT.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Ke=HT;class zT extends gs{constructor(){super(),this.geometry=new Ke}destroy(){this.geometry.destroy()}}class dh{constructor(t){this._renderer=t,this._managedSprites=new Ut({renderer:t,type:"renderable",name:"nineSliceSprite"})}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 zT,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._managedSprites.add(t),t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._managedSprites.destroy(),this._renderer=null}}dh.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"nineSliceSprite"},X.add(hh),X.add(dh);var NI=Object.defineProperty,_a=Object.getOwnPropertySymbols,WT=Object.prototype.hasOwnProperty,VT=Object.prototype.propertyIsEnumerable,YT=(r,t,e)=>t in r?NI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,XI=(r,t)=>{for(var e in t||(t={}))WT.call(t,e)&&YT(r,e,t[e]);if(_a)for(var e of _a(t))VT.call(t,e)&&YT(r,e,t[e]);return r},jI=(r,t)=>{var e={};for(var i in r)WT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&_a)for(var i of _a(r))t.indexOf(i)<0&&VT.call(r,i)&&(e[i]=r[i]);return e};const KT=class eS extends Se{constructor(t){var e,i,n,s,a,o,l,u,c,h;t instanceof D&&(t={texture:t});const p=t,{width:f,height:m,anchor:g,leftWidth:_,rightWidth:y,topHeight:b,bottomHeight:x,texture:v,roundPixels:w}=p,T=jI(p,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(XI({label:"NineSliceSprite"},T)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(i=_!=null?_:(e=v==null?void 0:v.defaultBorders)==null?void 0:e.left)!=null?i:Ke.defaultOptions.leftWidth,this._topHeight=(s=b!=null?b:(n=v==null?void 0:v.defaultBorders)==null?void 0:n.top)!=null?s:Ke.defaultOptions.topHeight,this._rightWidth=(o=y!=null?y:(a=v==null?void 0:v.defaultBorders)==null?void 0:a.right)!=null?o:Ke.defaultOptions.rightWidth,this._bottomHeight=(u=x!=null?x:(l=v==null?void 0:v.defaultBorders)==null?void 0:l.bottom)!=null?u:Ke.defaultOptions.bottomHeight,this._width=(c=f!=null?f:v.width)!=null?c:Ke.defaultOptions.width,this._height=(h=m!=null?m:v.height)!=null?h:Ke.defaultOptions.height,this.allowChildren=!1,this.texture=v!=null?v:eS.defaultOptions.texture,this.roundPixels=w!=null?w:!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),g?this.anchor=g:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=D.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 originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}get trim(){var t;return(t=this._texture.trim)!=null?t:null}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}};KT.defaultOptions={texture:D.EMPTY};let qT=KT;class HI extends qT{constructor(...t){let e=t[0];e instanceof D&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}class ZT extends pu{constructor(t,e){var i;super();const{textures:n,data:s}=t;Object.keys(s.pages).forEach(a=>{const o=s.pages[parseInt(a,10)],l=n[o.id];this.pages.push({texture:l})}),Object.keys(s.chars).forEach(a=>{var o;const l=s.chars[a],{frame:u,source:c,rotate:h}=n[l.page],p=W.transformRectCoords(l,u,h,new ut),f=new D({frame:p,orig:new ut(0,0,l.width,l.height),source:c,rotate:h});this.chars[a]={id:a.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(o=l.kerning)!=null?o:{},texture:f}}),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=(i=s.distanceField)!=null?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t0?(T=i.shift(),T.text=x,T.style=n,T.label=`char-${x}`,T.x=m.charPositions[b]*l-m.charPositions[y]*l):T=new xu({text:x,style:n,label:`char-${x}`,x:m.charPositions[b]*l-m.charPositions[y]*l}),v||(u.push(T),_.addChild(T)),(v||w)&&_.children.length>0&&(_.x=m.charPositions[y]*l,c.push(_),g.addChild(_),_=new dt({label:"word"}),y=b+1)}f+=p}return{chars:u,lines:h,words:c}}var JT=Object.getOwnPropertySymbols,WI=Object.prototype.hasOwnProperty,VI=Object.prototype.propertyIsEnumerable,YI=(r,t)=>{var e={};for(var i in r)WI.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&JT)for(var i of JT(r))t.indexOf(i)<0&&VI.call(r,i)&&(e[i]=r[i]);return e};class ph extends dt{constructor(t){const e=t,{text:i,style:n,autoSplit:s,lineAnchor:a,wordAnchor:o,charAnchor:l}=e,u=YI(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=i,this._autoSplit=s,this._lineAnchor=a,this._wordAnchor=o,this._charAnchor=l,this.style=n}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,i){let n;typeof t=="number"?n={x:t,y:t}:n={x:t.x,y:t.y},e.forEach(s=>{const a=s.getLocalBounds(),o=a.minX+a.width*n.x,l=a.minY+a.height*n.y;s.origin.set(o,l)}),this[i]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new jt(t),this.styleChanged()}styleChanged(){this.words.forEach(t=>t.destroy()),this.words.length=0,this.lines.forEach(t=>t.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var KI=Object.defineProperty,qI=Object.defineProperties,ZI=Object.getOwnPropertyDescriptors,t1=Object.getOwnPropertySymbols,QI=Object.prototype.hasOwnProperty,JI=Object.prototype.propertyIsEnumerable,e1=(r,t,e)=>t in r?KI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qi=(r,t)=>{for(var e in t||(t={}))QI.call(t,e)&&e1(r,e,t[e]);if(t1)for(var e of t1(t))JI.call(t,e)&&e1(r,e,t[e]);return r},tB=(r,t)=>qI(r,ZI(t));const r1=class wa extends ph{constructor(t){var e,i,n;const s=Qi(Qi({},wa.defaultOptions),t);(e=s.style)!=null||(s.style={}),(n=(i=s.style).fill)!=null||(i.fill=16777215),super(s)}static from(t,e){const i=tB(Qi(Qi({},wa.defaultOptions),e),{text:t.text,style:new jt(t.style)});t.style.tagStyles&&(t.style._tagStyles=void 0);const n=new wa(Qi({},i)),s=t.anchor;return(s.x!==0||s.y!==0)&&n.pivot.set(n.width*s.x,n.height*s.y),n}splitFn(){return QT({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};r1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let eB=r1;function i1(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;default:return 0}}function fh(r){return r==="\r"||r===` + `,dynamic:!1}};N.add(hh),N.add(dh),N.add(ch);var UI=Object.defineProperty,$I=Object.defineProperties,kI=Object.getOwnPropertyDescriptors,ya=Object.getOwnPropertySymbols,$T=Object.prototype.hasOwnProperty,kT=Object.prototype.propertyIsEnumerable,LT=(r,t,e)=>t in r?UI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,ri=(r,t)=>{for(var e in t||(t={}))$T.call(t,e)&<(r,e,t[e]);if(ya)for(var e of ya(t))kT.call(t,e)&<(r,e,t[e]);return r},NT=(r,t)=>$I(r,kI(t)),LI=(r,t)=>{var e={};for(var i in r)$T.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ya)for(var i of ya(r))t.indexOf(i)<0&&kT.call(r,i)&&(e[i]=r[i]);return e};const NI=new Mt(0,0,0,0),XT=class Gh extends Se{constructor(t={}){t=NT(ri(ri({},Gh.defaultOptions),t),{dynamicProperties:ri(ri({},Gh.defaultOptions.dynamicProperties),t==null?void 0:t.dynamicProperties)});const e=t,{dynamicProperties:i,shader:n,roundPixels:s,texture:a,particles:o}=e,l=LI(e,["dynamicProperties","shader","roundPixels","texture","particles"]);super(ri({label:"ParticleContainer"},l)),this.renderPipeId="particle",this.batched=!1,this._childrenDirty=!1,this.texture=a||null,this.shader=n,this._properties={};for(const u in ph){const c=ph[u],h=i[u];this._properties[u]=NT(ri({},c),{dynamic:h})}this.allowChildren=!0,this.roundPixels=s!=null?s:!1,this.particleChildren=o!=null?o:[]}addParticle(...t){for(let e=0;e-1&&(this.particleChildren.splice(n,1),e=!0)}return e&&this.onViewUpdate(),t[0]}update(){this._childrenDirty=!0}onViewUpdate(){this._childrenDirty=!0,super.onViewUpdate()}get bounds(){return NI}updateBounds(){}destroy(t=!1){var e,i,n;if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const s=typeof t=="boolean"?t:t==null?void 0:t.textureSource,a=(i=this.texture)!=null?i:(e=this.particleChildren[0])==null?void 0:e.texture;a&&a.destroy(s)}this.texture=null,(n=this.shader)==null||n.destroy()}removeParticles(t,e){t!=null||(t=0),e!=null||(e=this.particleChildren.length);const i=this.particleChildren.splice(t,e-t);return this.onViewUpdate(),i}removeParticleAt(t){const e=this.particleChildren.splice(t,1);return this.onViewUpdate(),e[0]}addParticleAt(t,e){return this.particleChildren.splice(e,0,t),this.onViewUpdate(),t}addChild(...t){throw new Error("ParticleContainer.addChild() is not available. Please use ParticleContainer.addParticle()")}removeChild(...t){throw new Error("ParticleContainer.removeChild() is not available. Please use ParticleContainer.removeParticle()")}removeChildren(t,e){throw new Error("ParticleContainer.removeChildren() is not available. Please use ParticleContainer.removeParticles()")}removeChildAt(t){throw new Error("ParticleContainer.removeChildAt() is not available. Please use ParticleContainer.removeParticleAt()")}getChildAt(t){throw new Error("ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()")}setChildIndex(t,e){throw new Error("ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()")}getChildIndex(t){throw new Error("ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()")}addChildAt(t,e){throw new Error("ParticleContainer.addChildAt() is not available. Please use ParticleContainer.addParticleAt()")}swapChildren(t,e){throw new Error("ParticleContainer.swapChildren() is not available. Please use ParticleContainer.swapParticles()")}reparentChild(...t){throw new Error("ParticleContainer.reparentChild() is not available with the particle container")}reparentChildAt(t,e){throw new Error("ParticleContainer.reparentChildAt() is not available with the particle container")}};XT.defaultOptions={dynamicProperties:{vertex:!1,position:!0,rotation:!1,uvs:!1,color:!1},roundPixels:!1};let XI=XT;class fh{constructor(t){this._renderer=t}validateRenderable(t){return!1}addRenderable(t,e){this._renderer.renderPipes.batch.break(e),e.add(t)}updateRenderable(t){}execute(t){var e,i,n,s,a,o;const l=this._renderer,u=l.canvasContext,c=u.activeContext;c.save();const h=t.groupTransform,p=l._roundPixels|t._roundPixels;u.setContextTransform(h,p===1),u.setBlendMode(t.groupBlendMode);const f=(i=(e=l.globalUniforms.globalUniformData)==null?void 0:e.worldColor)!=null?i:4294967295,m=t.groupColorAlpha,g=(f>>>24&255)/255,_=(m>>>24&255)/255,y=(s=(n=l.filter)==null?void 0:n.alphaMultiplier)!=null?s:1,b=g*_*y;if(b<=0){c.restore();return}c.globalAlpha=b;const x=f&16777215,v=m&16777215,w=xe(Oe(v,x)),T=t.texture,E=Q.getCanvasSource(T);if(!E){c.restore();return}const P=u.smoothProperty,M=T.source.style.scaleMode!=="nearest";c[P]!==M&&(c[P]=M);const C=w!==16777215||T.rotate!==0,A=C?Q.getTintedCanvas({texture:T},w):E,{leftWidth:G,topHeight:F,rightWidth:R,bottomHeight:B,width:O,height:I}=t,L=G+R,j=F+B,J=Math.min(L>O?O/L:1,j>I?I/j:1,1),K=G*J,X=R*J,k=F*J,$=B*J,z=Math.max(0,O-K-X),rt=Math.max(0,I-k-$),_t=t.anchor,et=(o=(a=T.source._resolution)!=null?a:T.source.resolution)!=null?o:1;let st=T.frame.x*et,nt=T.frame.y*et;const ot=-_t.x*O,gt=-_t.y*I,yt=G*et,pt=F*et,Y=R*et,Rt=B*et;let Ct=T.frame.width*et,ce=T.frame.height*et;C&&(st=0,nt=0,Ct=A.width,ce=A.height),c.drawImage(A,st,nt,yt,pt,ot,gt,K,k),c.drawImage(A,st+yt,nt,Ct-yt-Y,pt,ot+K,gt,z,k),c.drawImage(A,st+Ct-Y,nt,Y,pt,ot+O-X,gt,X,k),c.drawImage(A,st,nt+pt,yt,ce-pt-Rt,ot,gt+k,K,rt),c.drawImage(A,st+yt,nt+pt,Ct-yt-Y,ce-pt-Rt,ot+K,gt+k,z,rt),c.drawImage(A,st+Ct-Y,nt+pt,Y,ce-pt-Rt,ot+O-X,gt+k,X,rt),c.drawImage(A,st,nt+ce-Rt,yt,Rt,ot,gt+I-$,K,$),c.drawImage(A,st+yt,nt+ce-Rt,Ct-yt-Y,Rt,ot+K,gt+I-$,z,$),c.drawImage(A,st+Ct-Y,nt+ce-Rt,Y,Rt,ot+O-X,gt+I-$,X,$),c.restore()}destroy(){this._renderer=null}}fh.extension={type:[S.CanvasPipes],name:"nineSliceSprite"};var jI=Object.defineProperty,jT=Object.getOwnPropertySymbols,HI=Object.prototype.hasOwnProperty,zI=Object.prototype.propertyIsEnumerable,HT=(r,t,e)=>t in r?jI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,zT=(r,t)=>{for(var e in t||(t={}))HI.call(t,e)&&HT(r,e,t[e]);if(jT)for(var e of jT(t))zI.call(t,e)&&HT(r,e,t[e]);return r};const WT=class wa extends da{constructor(t={}){var e,i;t=zT(zT({},wa.defaultOptions),t),super({width:t.width,height:t.height,verticesX:4,verticesY:4}),this._trimX=0,this._trimY=0,this._trimWidth=(e=t.originalWidth)!=null?e:wa.defaultOptions.originalWidth,this._trimHeight=(i=t.originalHeight)!=null?i:wa.defaultOptions.originalHeight,this.update(t)}update(t){var e,i,n,s,a,o,l,u,c,h,p,f,m,g,_,y,b,x;this.width=(e=t.width)!=null?e:this.width,this.height=(i=t.height)!=null?i:this.height,this._originalWidth=(n=t.originalWidth)!=null?n:this._originalWidth,this._originalHeight=(s=t.originalHeight)!=null?s:this._originalHeight,this._leftWidth=(a=t.leftWidth)!=null?a:this._leftWidth,this._rightWidth=(o=t.rightWidth)!=null?o:this._rightWidth,this._topHeight=(l=t.topHeight)!=null?l:this._topHeight,this._bottomHeight=(u=t.bottomHeight)!=null?u:this._bottomHeight,this._anchorX=(c=t.anchor)==null?void 0:c.x,this._anchorY=(h=t.anchor)==null?void 0:h.y,t.trim!==void 0?(this._trimX=(f=(p=t.trim)==null?void 0:p.x)!=null?f:0,this._trimY=(g=(m=t.trim)==null?void 0:m.y)!=null?g:0,this._trimWidth=(y=(_=t.trim)==null?void 0:_.width)!=null?y:this._originalWidth,this._trimHeight=(x=(b=t.trim)==null?void 0:b.height)!=null?x:this._originalHeight):(this._trimWidth=this._originalWidth,this._trimHeight=this._originalHeight),this.updateUvs(),this.updatePositions()}updatePositions(){const t=this.positions,{width:e,height:i,_leftWidth:n,_rightWidth:s,_topHeight:a,_bottomHeight:o,_anchorX:l,_anchorY:u}=this,c=n+s,h=e>c?1:e/c,p=a+o,f=i>p?1:i/p,m=Math.min(h,f),g=l*e,_=u*i;t[0]=t[8]=t[16]=t[24]=-g,t[2]=t[10]=t[18]=t[26]=n*m-g,t[4]=t[12]=t[20]=t[28]=e-s*m-g,t[6]=t[14]=t[22]=t[30]=e-g,t[1]=t[3]=t[5]=t[7]=-_,t[9]=t[11]=t[13]=t[15]=a*m-_,t[17]=t[19]=t[21]=t[23]=i-o*m-_,t[25]=t[27]=t[29]=t[31]=i-_,this.getBuffer("aPosition").update()}updateUvs(){const t=this.uvs,e=this._originalWidth,i=this._originalHeight,n=this._trimX/e,s=this._trimY/i,a=(this._trimX+this._trimWidth)/e,o=(this._trimY+this._trimHeight)/i;t[0]=t[8]=t[16]=t[24]=n,t[1]=t[3]=t[5]=t[7]=s,t[6]=t[14]=t[22]=t[30]=a,t[25]=t[27]=t[29]=t[31]=o;const l=1/e,u=1/i;t[2]=t[10]=t[18]=t[26]=n+l*this._leftWidth,t[9]=t[11]=t[13]=t[15]=s+u*this._topHeight,t[4]=t[12]=t[20]=t[28]=a-l*this._rightWidth,t[17]=t[19]=t[21]=t[23]=o-u*this._bottomHeight,this.getBuffer("aUV").update()}};WT.defaultOptions={width:100,height:100,leftWidth:10,topHeight:10,rightWidth:10,bottomHeight:10,originalWidth:100,originalHeight:100};let Ke=WT;class VT extends ys{constructor(){super(),this.geometry=new Ke}destroy(){this.geometry.destroy()}}class mh{constructor(t){this._renderer=t,this._managedSprites=new Ut({renderer:t,type:"renderable",name:"nineSliceSprite"})}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 VT,i=e;return i.renderable=t,i.transform=t.groupTransform,i.texture=t._texture,i.roundPixels=this._renderer._roundPixels|t._roundPixels,this._managedSprites.add(t),t.didViewUpdate||this._updateBatchableSprite(t,i),e}destroy(){this._managedSprites.destroy(),this._renderer=null}}mh.extension={type:[S.WebGLPipes,S.WebGPUPipes],name:"nineSliceSprite"},N.add(fh),N.add(mh);var WI=Object.defineProperty,ba=Object.getOwnPropertySymbols,YT=Object.prototype.hasOwnProperty,KT=Object.prototype.propertyIsEnumerable,qT=(r,t,e)=>t in r?WI(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,VI=(r,t)=>{for(var e in t||(t={}))YT.call(t,e)&&qT(r,e,t[e]);if(ba)for(var e of ba(t))KT.call(t,e)&&qT(r,e,t[e]);return r},YI=(r,t)=>{var e={};for(var i in r)YT.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&ba)for(var i of ba(r))t.indexOf(i)<0&&KT.call(r,i)&&(e[i]=r[i]);return e};const ZT=class sS extends Se{constructor(t){var e,i,n,s,a,o,l,u,c,h;t instanceof D&&(t={texture:t});const p=t,{width:f,height:m,anchor:g,leftWidth:_,rightWidth:y,topHeight:b,bottomHeight:x,texture:v,roundPixels:w}=p,T=YI(p,["width","height","anchor","leftWidth","rightWidth","topHeight","bottomHeight","texture","roundPixels"]);super(VI({label:"NineSliceSprite"},T)),this.renderPipeId="nineSliceSprite",this.batched=!0,this._leftWidth=(i=_!=null?_:(e=v==null?void 0:v.defaultBorders)==null?void 0:e.left)!=null?i:Ke.defaultOptions.leftWidth,this._topHeight=(s=b!=null?b:(n=v==null?void 0:v.defaultBorders)==null?void 0:n.top)!=null?s:Ke.defaultOptions.topHeight,this._rightWidth=(o=y!=null?y:(a=v==null?void 0:v.defaultBorders)==null?void 0:a.right)!=null?o:Ke.defaultOptions.rightWidth,this._bottomHeight=(u=x!=null?x:(l=v==null?void 0:v.defaultBorders)==null?void 0:l.bottom)!=null?u:Ke.defaultOptions.bottomHeight,this._width=(c=f!=null?f:v.width)!=null?c:Ke.defaultOptions.width,this._height=(h=m!=null?m:v.height)!=null?h:Ke.defaultOptions.height,this.allowChildren=!1,this.texture=v!=null?v:sS.defaultOptions.texture,this.roundPixels=w!=null?w:!1,this._anchor=new bt({_onUpdate:()=>{this.onViewUpdate()}}),g?this.anchor=g:this.texture.defaultAnchor&&(this.anchor=this.texture.defaultAnchor)}get anchor(){return this._anchor}set anchor(t){typeof t=="number"?this._anchor.set(t):this._anchor.copyFrom(t)}get width(){return this._width}set width(t){this._width=t,this.onViewUpdate()}get height(){return this._height}set height(t){this._height=t,this.onViewUpdate()}setSize(t,e){var i;typeof t=="object"&&(e=(i=t.height)!=null?i:t.width,t=t.width),this._width=t,this._height=e!=null?e:t,this.onViewUpdate()}getSize(t){return t||(t={}),t.width=this._width,t.height=this._height,t}get leftWidth(){return this._leftWidth}set leftWidth(t){this._leftWidth=t,this.onViewUpdate()}get topHeight(){return this._topHeight}set topHeight(t){this._topHeight=t,this.onViewUpdate()}get rightWidth(){return this._rightWidth}set rightWidth(t){this._rightWidth=t,this.onViewUpdate()}get bottomHeight(){return this._bottomHeight}set bottomHeight(t){this._bottomHeight=t,this.onViewUpdate()}get texture(){return this._texture}set texture(t){t||(t=D.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 originalWidth(){return this._texture.width}get originalHeight(){return this._texture.height}get trim(){var t;return(t=this._texture.trim)!=null?t:null}destroy(t){if(super.destroy(t),typeof t=="boolean"?t:t==null?void 0:t.texture){const e=typeof t=="boolean"?t:t==null?void 0:t.textureSource;this._texture.destroy(e)}this._texture=null}updateBounds(){const t=this._bounds,e=this._anchor,i=this._width,n=this._height;t.minX=-e._x*i,t.maxX=t.minX+i,t.minY=-e._y*n,t.maxY=t.minY+n}};ZT.defaultOptions={texture:D.EMPTY};let QT=ZT;class KI extends QT{constructor(...t){let e=t[0];e instanceof D&&(e={texture:e,leftWidth:t[1],topHeight:t[2],rightWidth:t[3],bottomHeight:t[4]}),super(e)}}class JT extends fu{constructor(t,e){var i;super();const{textures:n,data:s}=t;Object.keys(s.pages).forEach(a=>{const o=s.pages[parseInt(a,10)],l=n[o.id];this.pages.push({texture:l})}),Object.keys(s.chars).forEach(a=>{var o;const l=s.chars[a],{frame:u,source:c,rotate:h}=n[l.page],p=W.transformRectCoords(l,u,h,new ut),f=new D({frame:p,orig:new ut(0,0,l.width,l.height),source:c,rotate:h});this.chars[a]={id:a.codePointAt(0),xOffset:l.xOffset,yOffset:l.yOffset,xAdvance:l.xAdvance,kerning:(o=l.kerning)!=null?o:{},texture:f}}),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=(i=s.distanceField)!=null?i:{type:"none",range:0},this.url=e}destroy(){super.destroy();for(let t=0;t0?(T=i.shift(),T.text=x,T.style=n,T.label=`char-${x}`,T.x=m.charPositions[b]*l-m.charPositions[y]*l):T=new Tu({text:x,style:n,label:`char-${x}`,x:m.charPositions[b]*l-m.charPositions[y]*l}),v||(u.push(T),_.addChild(T)),(v||w)&&_.children.length>0&&(_.x=m.charPositions[y]*l,c.push(_),g.addChild(_),_=new dt({label:"word"}),y=b+1)}f+=p}return{chars:u,lines:h,words:c}}var e1=Object.getOwnPropertySymbols,ZI=Object.prototype.hasOwnProperty,QI=Object.prototype.propertyIsEnumerable,JI=(r,t)=>{var e={};for(var i in r)ZI.call(r,i)&&t.indexOf(i)<0&&(e[i]=r[i]);if(r!=null&&e1)for(var i of e1(r))t.indexOf(i)<0&&QI.call(r,i)&&(e[i]=r[i]);return e};class gh extends dt{constructor(t){const e=t,{text:i,style:n,autoSplit:s,lineAnchor:a,wordAnchor:o,charAnchor:l}=e,u=JI(e,["text","style","autoSplit","lineAnchor","wordAnchor","charAnchor"]);super(u),this._dirty=!1,this._canReuseChars=!1,this.chars=[],this.words=[],this.lines=[],this._originalText=i,this._autoSplit=s,this._lineAnchor=a,this._wordAnchor=o,this._charAnchor=l,this.style=n}split(){const t=this.splitFn();this.chars=t.chars,this.words=t.words,this.lines=t.lines,this.addChild(...this.lines),this.charAnchor=this._charAnchor,this.wordAnchor=this._wordAnchor,this.lineAnchor=this._lineAnchor,this._dirty=!1,this._canReuseChars=!0}get text(){return this._originalText}set text(t){this._originalText=t,this.lines.forEach(e=>e.destroy({children:!0})),this.lines.length=0,this.words.length=0,this.chars.length=0,this._canReuseChars=!1,this.onTextUpdate()}_setOrigin(t,e,i){let n;typeof t=="number"?n={x:t,y:t}:n={x:t.x,y:t.y},e.forEach(s=>{const a=s.getLocalBounds(),o=a.minX+a.width*n.x,l=a.minY+a.height*n.y;s.origin.set(o,l)}),this[i]=t}get lineAnchor(){return this._lineAnchor}set lineAnchor(t){this._setOrigin(t,this.lines,"_lineAnchor")}get wordAnchor(){return this._wordAnchor}set wordAnchor(t){this._setOrigin(t,this.words,"_wordAnchor")}get charAnchor(){return this._charAnchor}set charAnchor(t){this._setOrigin(t,this.chars,"_charAnchor")}get style(){return this._style}set style(t){t||(t={}),this._style=new jt(t),this.styleChanged()}styleChanged(){this.words.forEach(t=>t.destroy()),this.words.length=0,this.lines.forEach(t=>t.destroy()),this.lines.length=0,this._canReuseChars=!0,this.onTextUpdate()}onTextUpdate(){this._dirty=!0,this._autoSplit&&this.split()}destroy(t){super.destroy(t),this.chars=[],this.words=[],this.lines=[],(typeof t=="boolean"?t:t!=null&&t.style)&&this._style.destroy(t),this._style=null,this._originalText=""}}var tB=Object.defineProperty,eB=Object.defineProperties,rB=Object.getOwnPropertyDescriptors,r1=Object.getOwnPropertySymbols,iB=Object.prototype.hasOwnProperty,nB=Object.prototype.propertyIsEnumerable,i1=(r,t,e)=>t in r?tB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Qi=(r,t)=>{for(var e in t||(t={}))iB.call(t,e)&&i1(r,e,t[e]);if(r1)for(var e of r1(t))nB.call(t,e)&&i1(r,e,t[e]);return r},sB=(r,t)=>eB(r,rB(t));const n1=class Ea extends gh{constructor(t){var e,i,n;const s=Qi(Qi({},Ea.defaultOptions),t);(e=s.style)!=null||(s.style={}),(n=(i=s.style).fill)!=null||(i.fill=16777215),super(s)}static from(t,e){const i=sB(Qi(Qi({},Ea.defaultOptions),e),{text:t.text,style:new jt(t.style)});t.style.tagStyles&&(t.style._tagStyles=void 0);const n=new Ea(Qi({},i)),s=t.anchor;return(s.x!==0||s.y!==0)&&n.pivot.set(n.width*s.x,n.height*s.y),n}splitFn(){return t1({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};n1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let aB=n1;function s1(r,t,e){switch(r){case"center":return(e-t)/2;case"right":return e-t;default:return 0}}function _h(r){return r==="\r"||r===` `||r===`\r -`}const rB=/^\s*$/;function iB(r,t){const e=[];let i=t.lines[0],n="",s=[],a=0;return r.forEach(o=>{const l=rB.test(o),u=fh(o),c=n.length===0&&l;l&&!u&&c||(u||(n+=o),s.push(o),n.length>=i.length&&(e.push({line:n,chars:s}),s=[],n="",a++,i=t.lines[a]))}),e}function n1(r){var t,e;const{text:i,style:n,chars:s}=r,a=n,o=St.measureText(i,a);if(o.runsByLine&&o.runsByLine.length>0)return nB(o,a,s,i);const l=St.graphemeSegmenter(i),u=iB(l,o),c=a.align,h=o.lineWidths.reduce((F,R)=>Math.max(F,R),0),p=(t=a._fill)==null?void 0:t.fill,f=(e=a._stroke)==null?void 0:e.fill,m=p instanceof $t,g=f instanceof $t,_=m||g,y=m&&p.textureSpace==="local"||g&&f.textureSpace==="local",b=o.width,x=o.height,v=a.clone();v.align="left";let w=0,T=0;if(v.trim){const{frame:F,canvasAndContext:R}=ye.getCanvasAndContext({text:i,style:a,resolution:1});ye.returnCanvasAndContext(R),w=-F.x,T=-F.y,v.trim=!1}const P=[],E=[],M=[];let C=0,A=0;const G=y?{width:b,height:x}:null;return u.forEach((F,R)=>{const B=new dt({label:`line-${R}`});B.y=C+T,E.push(B);const O=o.lineWidths[R];let I=i1(c,O,h),L=new dt({label:"word"});L.x=I+w;const j=St._context;j.font=v._fontString,St.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let J=F.line,K=j.measureText(J).width;if(F.chars.forEach(N=>{if(fh(N))return;J=J.slice(N.length);const k=J.length>0?j.measureText(J).width:0,$=K-k;if(K=k,$!==0)if(N===" ")L.children.length>0&&(M.push(L),B.addChild(L)),I+=$+a.letterSpacing,L=new dt({label:"word"}),L.x=I+w;else{let z=v;_&&(z=v.clone(),z._gradientOffset={x:-I,y:-C},G&&(z._gradientBounds=G));let rt;A0&&(M.push(L),B.addChild(L)),c==="justify"&&a.wordWrap&&R0){const $=(h-O)/k;for(let z=1;zMath.max(m,g),0);let o=0,l=0;if(t.trim){const{frame:m,canvasAndContext:g}=ye.getCanvasAndContext({text:i,style:t,resolution:1});ye.returnCanvasAndContext(g),o=-m.x,l=-m.y}const u=[],c=[],h=[];let p=0,f=0;return n.forEach((m,g)=>{var _,y,b,x;const v=new dt({label:`line-${g}`});v.y=p+l,c.push(v);const w=r.lineWidths[g];let T=i1(s,w,a),P=new dt({label:"word"});P.x=T+o;for(const M of m){const C=M.style,A=(_=C._fill)==null?void 0:_.fill,G=(y=C._stroke)==null?void 0:y.fill,F=A instanceof $t,R=G instanceof $t,B=F||R,O=F&&A.textureSpace==="local"||R&&G.textureSpace==="local",I=St.graphemeSegmenter(M.text),L=C.clone();L.align="left",L.wordWrap=!1,L.trim&&(L.trim=!1),L.tagStyles=void 0,L._lineHeight=0;const j=St._context;j.font=L._fontString,St.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let J=M.text,K=j.measureText(J).width;const N=T,k=K,$=St.measureFont(L._fontString),z=C.lineHeight||$.fontSize,rt=O?{width:k,height:z}:null;for(const _t of I){J=J.slice(_t.length);const et=J.length>0?j.measureText(J).width:0,st=K-et;if(K=et,!fh(_t)&&st!==0)if(_t===" ")P.children.length>0&&(h.push(P),v.addChild(P)),T+=st+C.letterSpacing,P=new dt({label:"word"}),P.x=T+o;else{let nt=L;B&&(nt=L.clone(),O?(nt._gradientOffset={x:-(T-N),y:0},nt._gradientBounds=rt):nt._gradientOffset={x:-(T-N),y:0});let ot;f0&&(h.push(P),v.addChild(P)),s==="justify"&&t.wordWrap&&g0){const A=(a-w)/C;for(let G=1;Gt in r?sB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ji=(r,t)=>{for(var e in t||(t={}))lB.call(t,e)&&a1(r,e,t[e]);if(s1)for(var e of s1(t))uB.call(t,e)&&a1(r,e,t[e]);return r},cB=(r,t)=>aB(r,oB(t));const o1=class Pa extends ph{constructor(t){const e=Ji(Ji({},Pa.defaultOptions),t);super(e)}static from(t,e){const i=cB(Ji(Ji({},Pa.defaultOptions),e),{text:t.text,style:new jt(t.style)}),n=new Pa(Ji({},i)),s=t.anchor;return(s.x!==0||s.y!==0)&&n.pivot.set(n.width*s.x,n.height*s.y),n}splitFn(){return n1({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};o1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let hB=o1;const l1=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function dB(r){const t=[];let e=0;for(let i=0;it in r?_B(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,d1=(r,t)=>{for(var e in t||(t={}))vB.call(t,e)&&h1(r,e,t[e]);if(c1)for(var e of c1(t))xB.call(t,e)&&h1(r,e,t[e]);return r},TB=(r,t)=>yB(r,bB(t));const SB=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let wB=0;function p1(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=SB[wB++]);let i="";for(let a=0;a{const l=oB.test(o),u=_h(o),c=n.length===0&&l;l&&!u&&c&&(!i||!i.startsWith(o))||(u||(n+=o),s.push(o),n.length>=i.length&&(e.push({line:n,chars:s}),s=[],n="",a++,i=t.lines[a]))}),e}function a1(r){var t,e;const{text:i,style:n,chars:s}=r,a=n,o=St.measureText(i,a);if(o.runsByLine&&o.runsByLine.length>0)return uB(o,a,s,i);const l=St.graphemeSegmenter(i),u=lB(l,o),c=a.align,h=o.lineWidths.reduce((F,R)=>Math.max(F,R),0),p=(t=a._fill)==null?void 0:t.fill,f=(e=a._stroke)==null?void 0:e.fill,m=p instanceof $t,g=f instanceof $t,_=m||g,y=m&&p.textureSpace==="local"||g&&f.textureSpace==="local",b=o.width,x=o.height,v=a.clone();v.align="left";let w=0,T=0;if(v.trim){const{frame:F,canvasAndContext:R}=ye.getCanvasAndContext({text:i,style:a,resolution:1});ye.returnCanvasAndContext(R),w=-F.x,T=-F.y,v.trim=!1}const E=[],P=[],M=[];let C=0,A=0;const G=y?{width:b,height:x}:null;return u.forEach((F,R)=>{const B=new dt({label:`line-${R}`});B.y=C+T,P.push(B);const O=o.lineWidths[R];let I=s1(c,O,h),L=new dt({label:"word"});L.x=I+w;const j=St._context;j.font=v._fontString,St.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let J=F.line,K=j.measureText(J).width;if(F.chars.forEach(X=>{if(_h(X))return;J=J.slice(X.length);const k=J.length>0?j.measureText(J).width:0,$=K-k;if(K=k,$!==0)if(X===" ")L.children.length>0&&(M.push(L),B.addChild(L)),I+=$+a.letterSpacing,L=new dt({label:"word"}),L.x=I+w;else{let z=v;_&&(z=v.clone(),z._gradientOffset={x:-I,y:-C},G&&(z._gradientBounds=G));let rt;A0&&(M.push(L),B.addChild(L)),c==="justify"&&a.wordWrap&&R0){const $=(h-O)/k;for(let z=1;zMath.max(m,g),0);let o=0,l=0;if(t.trim){const{frame:m,canvasAndContext:g}=ye.getCanvasAndContext({text:i,style:t,resolution:1});ye.returnCanvasAndContext(g),o=-m.x,l=-m.y}const u=[],c=[],h=[];let p=0,f=0;return n.forEach((m,g)=>{var _,y,b,x;const v=new dt({label:`line-${g}`});v.y=p+l,c.push(v);const w=r.lineWidths[g];let T=s1(s,w,a),E=new dt({label:"word"});E.x=T+o;for(const M of m){const C=M.style,A=(_=C._fill)==null?void 0:_.fill,G=(y=C._stroke)==null?void 0:y.fill,F=A instanceof $t,R=G instanceof $t,B=F||R,O=F&&A.textureSpace==="local"||R&&G.textureSpace==="local",I=St.graphemeSegmenter(M.text),L=C.clone();L.align="left",L.wordWrap=!1,L.trim&&(L.trim=!1),L.tagStyles=void 0,L._lineHeight=0;const j=St._context;j.font=L._fontString,St.experimentalLetterSpacingSupported&&(j.letterSpacing="0px",j.textLetterSpacing="0px");let J=M.text,K=j.measureText(J).width;const X=T,k=K,$=St.measureFont(L._fontString),z=C.lineHeight||$.fontSize,rt=O?{width:k,height:z}:null;for(const _t of I){J=J.slice(_t.length);const et=J.length>0?j.measureText(J).width:0,st=K-et;if(K=et,!_h(_t)&&st!==0)if(_t===" ")E.children.length>0&&(h.push(E),v.addChild(E)),T+=st+C.letterSpacing,E=new dt({label:"word"}),E.x=T+o;else{let nt=L;B&&(nt=L.clone(),O?(nt._gradientOffset={x:-(T-X),y:0},nt._gradientBounds=rt):nt._gradientOffset={x:-(T-X),y:0});let ot;f0&&(h.push(E),v.addChild(E)),s==="justify"&&t.wordWrap&&g0){const A=(a-w)/C;for(let G=1;Gt in r?cB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,Ji=(r,t)=>{for(var e in t||(t={}))pB.call(t,e)&&l1(r,e,t[e]);if(o1)for(var e of o1(t))fB.call(t,e)&&l1(r,e,t[e]);return r},mB=(r,t)=>hB(r,dB(t));const u1=class Pa extends gh{constructor(t){const e=Ji(Ji({},Pa.defaultOptions),t);super(e)}static from(t,e){const i=mB(Ji(Ji({},Pa.defaultOptions),e),{text:t.text,style:new jt(t.style)}),n=new Pa(Ji({},i)),s=t.anchor;return(s.x!==0||s.y!==0)&&n.pivot.set(n.width*s.x,n.height*s.y),n}splitFn(){return a1({text:this._originalText,style:this._style,chars:this._canReuseChars?this.chars:[]})}};u1.defaultOptions={autoSplit:!0,lineAnchor:0,wordAnchor:0,charAnchor:0};let gB=u1;const c1=["align","breakWords","cssOverrides","fontVariant","fontWeight","leading","letterSpacing","lineHeight","padding","textBaseline","trim","whiteSpace","wordWrap","wordWrapWidth","fontFamily","fontStyle","fontSize"];function _B(r){const t=[];let e=0;for(let i=0;it in r?TB(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,f1=(r,t)=>{for(var e in t||(t={}))EB.call(t,e)&&p1(r,e,t[e]);if(d1)for(var e of d1(t))PB.call(t,e)&&p1(r,e,t[e]);return r},AB=(r,t)=>SB(r,wB(t));const CB=["#000080","#228B22","#8B0000","#4169E1","#008080","#800000","#9400D3","#FF8C00","#556B2F","#8B008B"];let MB=0;function m1(r,t=0,e={color:"#000000"}){r.renderGroup&&(e.color=CB[MB++]);let i="";for(let a=0;a` through the WICG HTML-in-Canvas API, with PixiJS fragment shaders over it — scanlines, a CRT tube, pixel art, and a registry for your own. The DOM underneath stays live, hit-tested and accessible; only the pixels take a detour through the GPU. Chrome 148+ behind a flag, no fallback. Read before writing a shader or touching `src/stage/`. See also [examples/register-screen-effect.md](./examples/register-screen-effect.md). 13. **[Folder Sharing](./folder-sharing.md)** — *Experimental (since 0.18.0).* Per-principal read / write grants on desktop folders with first-sight opt-in, polymorphic `target_type` schema, If-Match conflict detection, and a ``-based Share Settings UI. 13. **[Progressive Web App (PWA)](./pwa.md)** — *Stable (since 0.8.0).* Web app manifest, service worker (root-scope, narrow fetch handler), install affordance, and `wp.desktop.notify()` for local notifications. Phase-4 Web Push wiring lands later without breaking the v1 call surface. 14. **[Migration 0.7 → 0.8.1](./migration-0.7-to-0.8.1.md)** — what landed in the architecture-0.8.1 refactor: the `@core` / `@api` / `@protocol` / `@layout` / `@ui` path aliases, the registry / server-sync / api-client primitives, the public-API facade home, and the PHP slicing of `helpers.php` / `components.php` / `render.php`. Read once before adopting any of the new modules in your plugin. diff --git a/docs/api-index.md b/docs/api-index.md index 56bcdad9a..8f1110681 100644 --- a/docs/api-index.md +++ b/docs/api-index.md @@ -103,6 +103,12 @@ The full surface is documented in [`javascript-reference.md`](./javascript-refer | `registerUnfocusEffect` | `( def: UnfocusEffectDef ) => void` | Experimental *(0.9.1)* | | `unregisterUnfocusEffect` | `( id: string ) => void` | Experimental *(0.9.1)* | | `listUnfocusEffects` | `() => UnfocusEffectDef[]` | Experimental *(0.9.1)* | +| `stage.isSupported` | `() => boolean` | Experimental *(0.9.8)* | +| `stage.isActive` | `() => boolean` | Experimental *(0.9.8)* | +| `stage.registerScreenEffect` | `( def: ScreenEffectDef ) => void` | Experimental *(0.9.8)* | +| `stage.unregisterScreenEffect` | `( id: string ) => void` | Experimental *(0.9.8)* | +| `stage.listScreenEffects` | `() => ScreenEffectDef[]` | Experimental *(0.9.8)* | +| `stage.subscribeScreenEffects` | `( cb: () => void ) => () => void` | Experimental *(0.9.8)* | | `registerWindowLinkRenderer` | `( def: WindowLinkRendererDef ) => void` | Experimental *(0.9.4)* | | `unregisterWindowLinkRenderer` | `( id: string ) => void` | Experimental *(0.9.4)* | | `listWindowLinkRenderers` | `() => WindowLinkRendererDef[]` | Experimental *(0.9.4)* | diff --git a/docs/architecture.md b/docs/architecture.md index af01060c8..53223d963 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -88,12 +88,76 @@ Key server-side entry points: 4. The shell's Vite-built TypeScript bundle (`desktop.js` in dev, `desktop.min.js` in prod) initializes: - Creates the `WindowManager`. - Creates the **layout dispatcher** which owns the dock(s) for the active `desktopLayout` (see [Desktop layout modes](#desktop-layout-modes)). + - Starts the **canvas stage** if the user has it on (see [Canvas stage](#canvas-stage-html-in-canvas)). This must complete before any window opens, so session restore chains off its promise. - Restores the saved session (if one exists). Then `shouldAutoOpenCurrentPage()` (see `src/boot/auto-open.ts`) decides whether to ALSO open `currentPage`. The decision: open when `fromPortal=false` (direct nav) **or** `fromPortalIntent=true` (portal redirected here from a user-clicked link). Suppress on bare portal entries that landed via the default-window / session-focused fallback so a restored stack isn't disturbed. - Wires persistence — debounced `POST /wp-json/desktop-mode/v1/session`. 5. When a dock icon is clicked, the manager opens a window whose iframe `src` is the admin URL with `?desktop_mode_chromeless=1` appended. 6. The iframe renders WordPress normally, but the chromeless stylesheet hides the admin bar, side menu, and wp-footer. 7. The iframe `postMessage`s its title, navigation, and screen-meta state up to the parent. +## Canvas stage (HTML-in-Canvas) + +*Experimental, since 0.9.8. Off by default.* + +A second rendering path for the whole shell. When the user turns on +**OS Settings → Experimental → Render the desktop in a canvas** and the +browser supports the WICG [HTML-in-Canvas](https://github.com/WICG/html-in-canvas) +API (Chrome 148+, `chrome://flags/#canvas-draw-element`), +`#desktop-mode-shell` is **moved inside** a +`` and mirrored into a +PixiJS texture, so fragment shaders can post-process every pixel of the +desktop at once. + +``` + + #wpadminbar ← outside; unaffected + ← the visible pixels + #desktop-mode-shell ← the real, live DOM + +``` + +`layoutsubtree` makes the canvas's direct children lay out, hit-test and +appear in the accessibility tree exactly as before — they just paint +invisibly, and Pixi paints them instead through `gl.texElementImage2D`. +The canvas is therefore a display surface, never an input surface: +clicks, focus, scrolling and iframe content all reach the real shell. + +Three constraints shape the implementation: + +- **The wrap must be done in JS, not PHP.** Content inside a `` + is fallback content — a browser without `layoutsubtree` renders none + of it. Emitting the wrapper server-side would blank the desktop for + every non-Chrome user, so the shell feature-detects first + (`src/stage/feature-detect.ts`) and only then wraps. +- **Moving the shell re-parents every `