@sepveneto/dao 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/Application.d.ts +2 -2
- package/dist/assets/Assets.d.ts +4 -4
- package/dist/assets/loader/Loader.d.ts +2 -2
- package/dist/dao.cjs +1 -1
- package/dist/dao.cjs.map +1 -1
- package/dist/dao.js +1941 -1686
- package/dist/dao.js.map +1 -1
- package/dist/events/FederatedEvent.d.ts +2 -2
- package/dist/events/FederatedEventMap.d.ts +2 -2
- package/dist/main.d.ts +5 -5
- package/dist/maths/Bounds.d.ts +6 -3
- package/dist/maths/Matrix.d.ts +6 -10
- package/dist/maths/Point.d.ts +1 -1
- package/dist/maths/getLocalBounds.d.ts +4 -0
- package/dist/maths/index.d.ts +2 -2
- package/dist/maths/shapes/Polygon.d.ts +5 -2
- package/dist/maths/shapes/Rectangle.d.ts +3 -1
- package/dist/maths/utils.d.ts +17 -0
- package/dist/renderer/CanvasPool.d.ts +2 -2
- package/dist/renderer/RenderPipe.d.ts +1 -1
- package/dist/renderer/index.d.ts +15 -15
- package/dist/renderer/texture/RenderTexture.d.ts +1 -1
- package/dist/renderer/texture/Texture.d.ts +1 -1
- package/dist/renderer/texture/TextureSource.d.ts +3 -3
- package/dist/scene/ViewContainer.d.ts +3 -3
- package/dist/scene/batcher/Batcher.d.ts +1 -1
- package/dist/scene/batcher/BatcherPipe.d.ts +6 -6
- package/dist/scene/container/Container.d.ts +20 -20
- package/dist/scene/container/RenderGroup.d.ts +3 -3
- package/dist/scene/container/__tests__/DummyEffect.d.ts +1 -1
- package/dist/scene/container/__tests__/DummyView.d.ts +1 -1
- package/dist/scene/container/mixins/childrenHelperMixin.d.ts +1 -1
- package/dist/scene/container/mixins/effectMixin.d.ts +3 -3
- package/dist/scene/container/mixins/measureMixin.d.ts +1 -1
- package/dist/scene/graphics/Graphics.d.ts +7 -2
- package/dist/scene/graphics/GraphicsContext.d.ts +18 -32
- package/dist/scene/graphics/GraphicsPipe.d.ts +2 -2
- package/dist/scene/graphics/__tests__/Graphics.Bounds.test.d.ts +1 -0
- package/dist/scene/graphics/__tests__/Graphics.test.d.ts +1 -0
- package/dist/scene/graphics/__tests__/bounds.test.d.ts +1 -0
- package/dist/scene/graphics/path/GraphicsPath.d.ts +2 -2
- package/dist/scene/graphics/path/ShapePath.d.ts +5 -3
- package/dist/scene/graphics/utils/FillTypes.d.ts +28 -0
- package/dist/scene/graphics/utils/convertInputToStyle.d.ts +15 -0
- package/dist/scene/graphics/utils/getMaxMiterRatio.d.ts +11 -0
- package/dist/scene/index.d.ts +1 -1
- package/dist/scene/mask/StencilMask.d.ts +2 -2
- package/dist/scene/mask/StencilMaskPipe.d.ts +1 -1
- package/dist/scene/sprite/Sprite.d.ts +2 -2
- package/dist/scene/sprite/SpritePipe.d.ts +1 -1
- package/dist/scene/text/Text.d.ts +4 -4
- package/dist/scene/text/TextPipe.d.ts +3 -3
- package/dist/scene/text/TextStyle.d.ts +3 -3
- package/dist/scene/text/TextSystem.d.ts +1 -1
- package/dist/scene/text/utils.d.ts +18 -18
- package/dist/system/CanvasContextSystem.d.ts +1 -1
- package/dist/system/EventSystem.d.ts +10 -5
- package/dist/system/ExtractSystem.d.ts +2 -2
- package/dist/system/ViewSystem.d.ts +2 -2
- package/dist/ticker/Ticker.d.ts +243 -243
- package/dist/ticker/TickerListener.d.ts +5 -5
- package/dist/utils/color.d.ts +8 -0
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/pool/Pool.d.ts +17 -0
- package/dist/utils/pool/PoolGroup.d.ts +6 -0
- package/package.json +20 -26
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ResizePluginOptions } from './ResizePlugin';
|
|
2
|
+
import { RendererOptions, CanvasRenderer } from '../renderer';
|
|
2
3
|
import { Container } from '../scene';
|
|
3
4
|
import { Ticker } from '../ticker';
|
|
4
|
-
import { ResizePluginOptions } from './ResizePlugin';
|
|
5
5
|
export interface ApplicationOptions extends RendererOptions, ResizePluginOptions {
|
|
6
6
|
}
|
|
7
7
|
export declare class Application {
|
package/dist/assets/Assets.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { LoadOptions, ProgressCallback, Loader } from './loader/Loader';
|
|
2
|
+
import { Texture } from '../renderer/texture/Texture';
|
|
1
3
|
import { ArrayOr } from '../utils/type';
|
|
2
|
-
import { Loader, LoadOptions, ProgressCallback } from './loader/Loader';
|
|
3
4
|
import { Cache } from './cache/Cache';
|
|
4
|
-
|
|
5
|
-
export type UnresolvedAsset<T = any> = {
|
|
5
|
+
export interface UnresolvedAsset<T = any> {
|
|
6
6
|
alias: ArrayOr<T>;
|
|
7
7
|
src: string;
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
export interface AssetInitOptions {
|
|
10
10
|
basePath?: string;
|
|
11
11
|
loadOptions?: Partial<LoadOptions>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { TextureSource } from '../../renderer/texture/TextureSource';
|
|
2
|
-
import { Texture } from '../../renderer/texture/Texture';
|
|
3
1
|
import { UnresolvedAsset } from '../Assets';
|
|
2
|
+
import { Texture } from '../../renderer/texture/Texture';
|
|
3
|
+
import { TextureSource } from '../../renderer/texture/TextureSource';
|
|
4
4
|
export interface ResolvedAsset {
|
|
5
5
|
alias: string[];
|
|
6
6
|
src: string;
|
package/dist/dao.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const l=Math.PI*2;var u=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}static append(t,n){return new e(n.a*t.a+n.b*t.c,n.a*t.b+n.b*t.d,n.c*t.a+n.d*t.c,n.c*t.b+n.d*t.d,n.tx*t.a+n.ty*t.c+t.tx,n.tx*t.b+n.ty*t.d+t.ty)}apply(e){let{x:t,y:n}=e;return new f(t*this.a+n*this.c+this.tx,t*this.b+n*this.d+this.ty)}translate(e,t){return this.tx+=e,this.ty+=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d,f=t.tx,p=t.ty;this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+f,this.ty=o*l+s*d+p}set(e,t,n,r,i,a){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}applyInverse(e,t){t=t||new f;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(l-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+a.x*t+a.y*r,e.position.y=this.ty+a.x*n+a.y*i,e}clone(){let t=new e;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}},d=class e{constructor(e=0,t=0,n=0,r=0){this.type=`rectangle`,this.x=e,this.y=t,this.width=n,this.height=r}getBounds(){let t=new e;return t.copyFrom(this),t}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}},f=class{constructor(e=0,t=0){this.x=e,this.y=t}set(e,t){t==null?this.x=this.y=e:(this.x=e,this.y=t)}copyFrom(e){return this.set(e.x,e.y),this}};function p(e){return e+=e===0?1:0,--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}var m=class{constructor(e){this.global=new f,this.screen=new f,this.system=e}getLocalPosition(e,t){return e.worldTransform.applyInverse(t||this.global)}composedPath(){return(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.system.propagationPath(this.target):[]),this.path}},h,g=2048,_=class{constructor(e){this.domElement=null,this.rootTarget=null,this.resolution=1,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.mappingState={trackingData:{}},this.renderer=e,this.resolution=e.resolution,this._rootPointerEvent=new m(null),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.init()}get pointer(){return this._rootPointerEvent}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTargets:null}),this.mappingState.trackingData[e]}init(){let e=this.renderer.canvas;this.setTargetElement(e)}setTargetElement(e){this._removeEvents(),this.domElement=e,this._addEvents()}dispatchEvent(e,t){if(!e.target)return;let n=e.composedPath();for(let r=0;r<n.length-1;++r)e.currentTarget=n[r],this._notifyTarget(e,t);e.currentTarget=e.target,this._notifyTarget(e,t)}_notifyTarget(e,t){t!=null||(t=e.type);let n=e.currentTarget._events[t];if(n)if(`fn`in n)n.once&&e.target.removeListener(t,n.fn,void 0,!0),n.fn.call(n.context,e);else for(let r=0;r<n.length;++r){let i=n[r];i.once&&e.target.removeListener(t,i.fn,void 0,!0),i.fn.call(i.context,e)}}propagationPath(e){let t=[e];for(let n=0;n<g&&(e!==this.rootTarget||e.parent);++n){if(!e.parent)throw Error(`Cannot find propagation path to disconnected target`);t.push(e.parent),e=e.parent}return t.reverse(),t}_removeEvents(){let e=this.domElement;e&&(globalThis.document.removeEventListener(`pointermove`,this._onPointerMove,!0),e.removeEventListener(`pointerdown`,this._onPointerDown,!0),e.removeEventListener(`pointerleave`,this._onPointerOverOut,!0),e.removeEventListener(`pointerover`,this._onPointerOverOut,!0),globalThis.document.removeEventListener(`pointerup`,this._onPointerUp,!0))}_addEvents(){let e=this.domElement;if(!e)return;let t=e.style;t&&(t.touchAction=`none`),globalThis.document.addEventListener(`pointermove`,this._onPointerMove,!0),e.addEventListener(`pointerdown`,this._onPointerDown,!0),e.addEventListener(`pointerleave`,this._onPointerOverOut,!0),e.addEventListener(`pointerover`,this._onPointerOverOut,!0),globalThis.document.addEventListener(`pointerup`,this._onPointerUp,!0)}_onPointerMove(e){var t;if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;this._isPointerMoveEvent=!0,this._allInteractiveElements.length=0,this._hitElements.length=0;let n=this._bootstrapEvent(this._rootPointerEvent,e),r=this.createPointEvent(n);this._isPointerMoveEvent=!1;let i=this.trackingData(e.pointerId),a=v(i.overTargets);if(((t=i.overTargets)==null?void 0:t.length)>0&&a!==r.target){let e=this.createPointEvent(n,`pointerout`,a);this.dispatchEvent(e,`pointerout`);let t=r.composedPath();if(!t.includes(a)){let e=this.createPointEvent(n,`pointerleave`,a);for(;e.target&&!t.includes(e.target);)e.currentTarget=e.target,this._notifyTarget(e),e.target=e.target.parent}}if(a!==r.target){let e=`pointerover`,t=this.clonePointEvent(r,e);this.dispatchEvent(t,e);let n=a==null?void 0:a.parent;for(;n&&n!==this.rootTarget.parent&&n!==r.target;)n=n.parent;if(!n||n===this.rootTarget.parent){let e=this.clonePointEvent(r,`pointerenter`);for(;e.target&&e.target!==a&&e.target!==this.rootTarget.parent;)e.currentTarget=e.target,this._notifyTarget(e),e.target=e.target.parent}}this.dispatchEvent(r,`pointermove`);let o=this._allInteractiveElements;for(let e=o.length-1;e>=0;--e)r.currentTarget=o[e],this._notifyTarget(r,`globalpointermove`);this._allInteractiveElements.length=0,this._hitElements.length=0,i.overTargets=r.composedPath()}_onPointerDown(e){if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;let t=this._bootstrapEvent(this._rootPointerEvent,e),n=this.createPointEvent(t);this.dispatchEvent(n,`pointerdown`);let r=this.trackingData(e.pointerId);r.pressTargetsByButton[e.button]=n.composedPath()}_onPointerOverOut(e){if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;let t=this._bootstrapEvent(this._rootPointerEvent,e),n=this.createPointEvent(t);this.dispatchEvent(n,`pointerout`)}_onPointerUp(e){if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;let t=e.target;e.composedPath&&e.composedPath().length>1&&(t=e.composedPath()[0]);let n=this._bootstrapEvent(this._rootPointerEvent,e),r=t===this.domElement?``:`outside`,i=this.createPointEvent(n);this.dispatchEvent(i,`pointerup${r}`)}_isInteractive(e){return e===`static`}_bootstrapEvent(e,t){return e.nativeEvent=t,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),t.type===`pointerleave`?e.type=`pointerout`:e.type=t.type,e}createPointEvent(e,t,n){var r;let i=new m(this);return i.global.copyFrom(e.global),i.screen.copyFrom(e.screen),i.nativeEvent=e.nativeEvent,i.target=(r=n==null?this.hitTest(i.global.x,i.global.y):n)==null?this._hitElements[0]:r,t&&(i.type=t),i}clonePointEvent(e,t){let n=new m(this);return n.nativeEvent=e.nativeEvent,n.global=e.global,n.type=t==null?e.type:t,n.path=e.composedPath().slice(),n.target=e.target,n}mapPositionToPoint(e,t,n){let r=this.domElement,i=r.isConnected?r.getBoundingClientRect():{x:0,y:0,width:r.width,height:r.height,left:0,top:0},a=1/this.resolution;return e.x=(t-i.left)*(r.width/i.width)*a,e.y=(n-i.top)*(r.height/i.height)*a,e}hitTest(e,t){let n=this._isPointerMoveEvent,r=this[n?`hitTestMoveRecursive`:`hitTestRecursive`](this.rootTarget,this.rootTarget.eventMode,new f(e,t));return r&&r[0]}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode===`none`}hitTestMoveRecursive(e,t,n){let r=!1;if(this._interactivePrune(e))return;let i=e.children;if(i&&i.length>0)for(let a=i.length-1;a>=0;--a){let o=i[a],s=this.hitTestMoveRecursive(o,this._isInteractive(t)?t:o.eventMode,n);if(s){if(s.length>0&&!s[s.length-1].parent)continue;let t=this._isInteractive(e.eventMode);(s.length>0||t)&&(t&&this._allInteractiveElements.push(e),s.push(e)),this._hitElements.length===0&&(this._hitElements=s),r=!0}}let a=this._isInteractive(t),o=this._isInteractive(e.eventMode);if(o&&this._allInteractiveElements.push(e),!(this._hitElements.length>0)){if(r)return this._hitElements;if(a&&this.hitTestFn(e,n))return o?[e]:[]}}hitTestRecursive(e,t,n){if(this._interactivePrune(e))return;let r=e.children;for(let i=r.length-1;i>=0;i--){let a=r[i],o=this.hitTestRecursive(a,this._isInteractive(t)?t:a.eventMode,n);if(o){let t=this._isInteractive(e.eventMode);return(o.length>0||t)&&o.push(e),o}}let i=this._isInteractive(t),a=this._isInteractive(e.eventMode);return i&&this.hitTestFn(e,n)?a?[e]:[]:null}hitTestFn(e,t){if(e.hitArea)return!0;if(e.containsPoint){let n=e.worldTransform.applyInverse(t);return e.containsPoint(n)}return!1}};h=_,h.desc={name:`events`};function v(e){if(!e)return;let t=e[0];for(let n=1;n<e.length&&e[n].parent===t;++n)t=e[n];return t}function y(e,t){t||(t=0);for(let n=t;n<e.length&&e[n];++n)e[n]=null}function b(e,t,n={}){for(let r in t)!n[r]&&t[r]!==void 0&&(e[r]=t[r])}var x=class{constructor(){this.instructions=[],this.instructionSize=0}reset(){this.instructionSize=0}add(e){this.instructions[this.instructionSize++]=e}},S=class{constructor(e){this.worldTransform=new u,this.localTransform=new u,this.root=null,this.instructionSet=new x,this.structureDidChange=!0,this.renderGroupParent=null,this.renderGroupChildren=[],this.childrenToUpdate=Object.create(null),this.childrenRenderablesToUpdate={list:[],index:0},this._onRenderContainers=[],this.init(e)}init(e){this.root=e;let t=e.children;for(let e=0;e<t.length;++e)this.addChild(t[e])}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);let t=e.children;for(let e=0;e<t.length;++e)this.addChild(t[e])}removeChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}let t=e.children;for(let e=0;e<t.length;++e)this.removeChild(t[e])}removeChildren(e){for(let t=0;t<e.length;++t)this.removeChild(e[t])}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){let t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addOnRender(e){this._onRenderContainers.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;++t)this._onRenderContainers[t]._onRender(e)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}destroy(){this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this._onRenderContainers=null,this.renderGroupChildren=null,this.instructionSet=null}},C={default:-1};function w(e=`default`){return C[e]===void 0&&(C[e]=-1),++C[e]}function ee(e,t,n){let{width:r,height:i}=n.orig;e.minX=-t.x*r,e.minY=-t.y*i,e.maxX=e.minX+r,e.maxY=e.minY+i}function te(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}var T=class{constructor(e,t,n){this._x=t||0,this._y=n||0,this._observer=e}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}copyFrom(e){return(this.x!==e.x||this.y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}toVector2(){return new f(this.x,this.y)}};const ne=180/Math.PI,re=Math.PI/180;var ie=o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)})),ae=c(ie(),1),E=ae.default,D=class e{constructor(e=1/0,t=1/0,n=-1/0,r=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=new u,this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}clone(){return new e(this.minX,this.minY,this.maxX,this.maxY)}isEmpty(){return this.minX>=this.maxX||this.minY>=this.maxY}clear(){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isValid(){return this.minX+this.minY!==1/0}set(e,t,n,r){this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addRect(e,t){this.addFrame(e.x,e.y,e.width+e.x,e.height+e.y,t)}addFrame(e,t,n,r,i){i||(i=this.matrix);let a=i.a,o=i.b,s=i.c,c=i.d,l=i.tx,u=i.ty;O(a*e+s*t+l,o*e+c*t+u,this),O(a*n+s*t+l,o*n+c*t+u,this),O(a*e+s*r+l,o*e+c*r+u,this),O(a*n+s*r+l,o*n+c*r+u,this)}get rectangle(){this._rectangle||(this._rectangle=new d);let e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):(e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY),e}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}};function O(e,t,n){e<n.minX&&(n.minX=e),e>n.maxX&&(n.maxX=e),t<n.minY&&(n.minY=t),t>n.maxY&&(n.maxY=t)}function k(e,t,n){return t.clear(),n||(n=new u),oe(e,t,n,e,!0),t.isValid||t.set(0,0,0,0),t}function oe(e,t,n,r,i){let a=new u;if(i)a.copyFrom(n);else{if(!e.visible||!e.measurable)return;e.updateLocalTransform(),a.appendFrom(e.localTransform,n)}let o=t,s=!!e.effects.length;if(s&&(t=new D),e.boundsArea)t.addRect(e.boundsArea,a);else{e.renderPipeId&&(t.matrix=a,t.addBounds(e.bounds));let n=e.children;for(let e=0;e<n.length;e++)oe(n[e],t,a,r,!1);if(s){for(let n=0;n<e.effects.length;++n){var c,l;(c=(l=e.effects[n]).addLocalBounds)==null||c.call(l,t,r)}o.addBounds(t,new u)}}return t}var se=class{constructor(e){this.pipe=`stencilMask`,this.mask=e,e.includeInBuild=!1,e.measurable=!1}addLocalBounds(e,t){let n=new D;this.mask.measurable=!0;let r=ce(this.mask,t);k(this.mask,n,r),this.mask.measurable=!1,e.addBoundsMask(n)}};function ce(e,t,n){return n||(n=new u),e===t?n:(n=ce(e.parent,t,n),e.updateLocalTransform(),u.append(n,e.localTransform))}const le={effects:[],_maskEffect:null,addEffect(e){this.effects.push(e),this._updateIsSimple()},removeEffect(e){let t=this.effects.indexOf(e);t===-1&&this.effects.splice(t,1),this._updateIsSimple()},set mask(e){let t=this._maskEffect;e!==(t==null?void 0:t.mask)&&(t&&(this.removeEffect(t),this._maskEffect=null),e!=null&&(this._maskEffect=new se(e),this.addEffect(this._maskEffect)))},get mask(){var e;return(e=this._maskEffect)==null?void 0:e.mask}},ue={_zIndex:0,sortableChildren:!1,sortDirty:!1},de={_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new D});let e=this._localBoundsCacheData;return e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick&&(e.didChange=!0,e.data[0]=this._didViewChangeTick),fe(this,e),e.didChange&&k(this,e.localBounds),e.localBounds}};function fe(e,t){let n=e.children;for(let e=0;e<n.length;++e){let r=n[e],i=r.uid,a=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,o=t.index;(t.data[o]!==i||t.data[o+1]!==a)&&(t.data[o]=i,t.data[o+1]=a,t.didChange=!0),t.index+=2,r.children.length&&fe(r,t)}return t.didChange}const pe={removeChildren(e=0,t){let n=t==null?this.children.length:t,r=n-e,i=[];if(r>0&&r<=n){for(let t=n-1;t>=e;--t){let e=this.children[t];e&&(i.push(e),e.parent=null)}me(this.children,e,n);let t=this.renderGroup||this.parentRenderGroup;return t&&t.removeChildren(i),i.length>0&&this._didViewChangeTick++,i}else if(r===0&&this.children.length===0)return i;throw Error(`removeChildren: numeric values are outside the acceptable range.`)}};function me(e,t,n){let r=e.length,i;if(t>=r||n===0)return;n=t+n>r?r-t:n;let a=r-n;for(i=t;i<a;++i)e[i]=e[i+n];e.length=a}const he=1,ge=2,_e=4,ve=8;var A=new T(null),j=new T(null),M=new T(null,1,1),N=new T(null),P=class extends E{constructor(e={}){var t,n;super(),this.uid=w(`renderable`),this.destroyed=!1,this.renderGroup=null,this.parentRenderGroup=null,this.parent=null,this.eventMode=`passive`,this.hitArea=null,this._position=new T(this,0,0),this.includeInBuild=!0,this.didChange=!1,this.didViewUpdate=!1,this.isSimple=!0,this.measurable=!0,this.relativeRenderGroupDepth=0,this._didViewChangeTick=0,this._didContainerChangeTick=0,this._localTransformUpdateTick=0,this._updateFlags=15,this.localDisplayStatus=7,this.globalDisplayStatus=7,this.children=[],this.localTransform=new u,this.relativeGroupTransform=new u,this.groupTransform=this.relativeGroupTransform,this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._skew=A,this._scale=M,this._origin=j,this._pivot=N,this.localAlpha=1,this.groupColor=16777215,this.localColor=16777215,this.groupAlpha=1,this.groupColorAlpha=4294967295,b(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(e=>this.addChild(e)),(n=e.parent)==null||n.addChild(this),this.effects=[]}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=e?1:0;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate(),this.emit(`visibleChanged`,e))}get isRenderGroup(){return!!this.renderGroup}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get zIndex(){return this._zIndex}set zIndex(e){e!==this._zIndex&&(this._zIndex=e,this.depthOfChildModified())}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length==0}sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(be))}depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=new S(this),this.groupTransform=new u,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}collectRenderables(e,t){this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderableSimple(e,t):this.renderGroup||this.collectRenderablesWithEffects(e,t))}collectRenderablesWithEffects(e,t){for(let n=0;n<this.effects.length;++n){let r=this.effects[n];e[r.pipe].push(r,t)}this.collectRenderableSimple(e,t);for(let n=0;n<this.effects.length;++n){let r=this.effects[n];e[r.pipe].pop(r,t)}}collectRenderableSimple(e,t){let n=this.children;for(let r=0;r<n.length;++r)n[r].collectRenderables(e,t)}setFromMatrix(e){e.decompose(this)}_updateSkew(){let e=this.rotation,t=this.skew;this._cx=Math.cos(e+t.y),this._sx=Math.sin(e+t.y),this._cy=-Math.sin(e-t.x),this._sy=Math.cos(e-t.x)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._localTransformUpdateTick===e)return;this._localTransformUpdateTick=e,this._updateSkew();let t=this.position,n=this.localTransform,r=this._scale.x,i=this._scale.y,a=-this._origin.x,o=-this._origin.y,s=this._pivot.x,c=this._pivot.y;n.a=this._cx*r,n.b=this._sx*r,n.c=this._cy*i,n.d=this._sy*i,n.tx=t.x-(s*n.a+c*n.c)+(a*n.a+o*n.c)-a,n.ty=t.y-(s*n.b+c*n.d)+(a*n.b+o*n.d)-o}get alpha(){return this.localAlpha}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=1,this._onUpdate())}get root(){let e=this.parent,t=this.parent;for(;e;)e.parent||(t=e),e=e.parent;return t}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(e){this._position.x=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get y(){return this._position.y}set y(e){this._position.y=e}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*ne}set angle(e){this.rotation=e*re}get skew(){return this._skew===A&&(this._skew=new T(this,0,0)),this._skew}set skew(e){this._skew===A&&(this._skew=new T(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===M&&(this._scale=new T(this,1,1)),this._scale}set scale(e){this._scale===M&&(this._scale=new T(this,1,1)),this._scale.copyFrom(e)}get pivot(){return this._pivot===N&&(this._pivot=new T(this,0,0)),this._pivot}set pivot(e){this._pivot===N&&(this._pivot=new T(this,0,0)),this._pivot.copyFrom(e)}get origin(){return this._origin===j&&(this._origin=new T(this,0,0)),this._origin}set origin(e){this._origin===j&&(this._origin=new T(this,0,0)),typeof e==`number`?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){}addChild(...e){if(e.length>1){for(let t=0;t<e.length;++t)this.addChild(e[t]);return e[0]}let t=e[0],n=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),n&&(n.structureDidChange=!0),t):(this.sortableChildren&&(this.sortDirty=!0),t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=7,n&&n.addChild(t),this._didViewChangeTick++,t._zIndex!=0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let t=0;t<e.length;++t)this.removeChild(e[t]);return e[0]}let t=e[0];if(!t)return t;let n=this.children.indexOf(t);return n>-1&&(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parent=null),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}toGlobal(e,t){return this.getGlobalTransform(t).apply(e)}toLocal(e,t,n){let r;return t&&(r=t.toGlobal(e)),r=this.getGlobalTransform(n).applyInverse(e),r}getGlobalTransform(e=!1){if(e)return this.worldTransform.clone();this.updateLocalTransform();let t=new u,n=ye(this,t);return t.appendFrom(this.localTransform,n),t}getGlobalPosition(e=!1){return this.parent?this.parent.toGlobal(this._position,e):this._position.toVector2()}destroy(e=!1){var t,n;if(this.destroyed)return;this.destroyed=!0;let r;if(this.children.length&&(r=this.removeChildren(0,this.children.length)),(t=this.parent)==null||t.removeChild(this),this.parent=null,this._maskEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,(typeof e==`boolean`?e:e!=null&&e.children)&&r)for(let t=0;t<r.length;++t)r[t].destroy(e);(n=this.renderGroup)==null||n.destroy(),this.renderGroup=null}};function ye(e,t){let n=e.parent;if(n){ye(n,t),n.updateLocalTransform();let e=u.append(t,n.localTransform);t.copyFrom(e)}return t}function be(e,t){return e._zIndex-t._zIndex}te(P,ue,le,de,pe);var xe=7;function Se(e,t=!1){let n=e.root;e.worldTransform.copyFrom(n.localTransform);let r=e.childrenToUpdate;for(let t in r){let n=Number(t),i=r[n],a=i.list,o=i.index;for(let t=0;t<o;++t){let r=a[t];r.parentRenderGroup===e&&r.relativeRenderGroupDepth===n&&Ce(r,0)}y(a,o),i.index=0}if(t)for(let n=0;n<e.renderGroupChildren.length;++n)Se(e.renderGroupChildren[n],t)}function Ce(e,t){e.didChange=!1;let n=e.parent,r=e.localTransform;e.updateLocalTransform(),n&&(t|=e._updateFlags,e.relativeGroupTransform.appendFrom(r,n.relativeGroupTransform),t&xe&&we(e,n,t));let i=e.children;for(let e=0;e<i.length;e++)Ce(i[e],t)}function we(e,t,n){if(n&1){e.groupColor=t.groupColor;let n=e.localAlpha*t.groupAlpha;n=n<0?0:n>1?1:n,e.groupAlpha=n,e.groupColorAlpha=e.groupColor+((n*255|0)<<24)}n&4&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}function Te(e,t){let{list:n,index:r}=e.childrenRenderablesToUpdate,i=!1;for(let e=0;e<r;++e){let r=n[e];if(i=t[r.renderPipeId].validateRenderable(r),i)break}return e.structureDidChange=i,i}var Ee,De=class{constructor(e){this.renderer=e}_updateRenderGroup(e){let t=this.renderer,n=t.renderPipes;e.runOnRender(t),e.instructionSet.renderPipes=n,e.structureDidChange?y(e.childrenRenderablesToUpdate.list,0):Te(e,n),Se(e),e.structureDidChange&&(e.structureDidChange=!1,this._buildInstructions(e,t)),e.childrenRenderablesToUpdate.index=0}render({container:e,transform:t}){let n=this.renderer;t&&e.renderGroup.localTransform.copyFrom(t),n.canvasContext.globalTransform=t?e.renderGroup.localTransform:e.renderGroup.worldTransform,this._updateRenderGroup(e.renderGroup),Oe(e.renderGroup,n.renderPipes)}_buildInstructions(e,t){let n=t.renderPipes,r=e.root;e.instructionSet.reset(),r.sortableChildren&&r.sortChildren(),n.batch.buildStart(),r.collectRenderablesWithEffects(n,e.instructionSet),n.batch.buildEnd(e.instructionSet)}};Ee=De,Ee.desc={name:`renderGroup`};function Oe(e,t){let{instructionSet:n}=e,r=n.instructions;for(let e=0;e<n.instructionSize;e++){let n=r[e];t[n.renderPipeId].execute(n)}}var ke,Ae=class{constructor(e){this._renderer=e}addRenderable(e,t){let n=this._getRuntimeSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n,t)}_updateBatchableSprite(e,t){t.texture=e._texture,t.bounds=e.bounds}validateRenderable(e){return this._getRuntimeSprite(e).texture._source.uid!==e._texture._source.uid}_getRuntimeSprite(e){return e._runtimeData[this._renderer.uid]||this._initCacheSprite(e)}_initCacheSprite(e){let t={renderable:e,texture:e.texture,transform:e.relativeGroupTransform,bounds:e.bounds,roundPixels:this._renderer._roundPixels|e._roundPixels,destroy:function(){this.renderable=null,this.texture=null,this.transform=null,this.bounds=null}};return e._runtimeData[this._renderer.uid]=t,t}destroy(){this._renderer=null}};ke=Ae,ke.desc={name:`sprite`};var je,F=class{constructor(e){this._renderer=e}addRenderable(e,t){let n=this._getRuntimeText(e);if(e._didTextUpdate){let t=e._autoResolution?this._renderer.resolution:e.resolution;(n.currentKey!==e.styleKey||e._resolution!==t)&&this._updateRuntimeText(e),e._didTextUpdate=!1,ee(n.bounds,e._anchor,n.texture)}this._renderer.renderPipes.batch.addToBatch(n,t)}validateRenderable(e){let t=this._getRuntimeText(e),n=e.styleKey;return t.currentKey===n?e._didTextUpdate:!0}initCacheText(e){let t={currentKey:`--`,transform:e.relativeGroupTransform,bounds:e.bounds,roundPixels:this._renderer._roundPixels|e._roundPixels,renderable:e,texture:null,destroy:function(){this.renderable=null,this.texture=null,this.bounds=null}};return e._runtimeData[this._renderer.uid]=t,t}_getRuntimeText(e){return e._runtimeData[this._renderer.uid]||this.initCacheText(e)}_updateRuntimeText(e){let t=this._getRuntimeText(e);t.texture,e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.text.getManagedTexture(e),t.currentKey=e.styleKey}destroy(){this._renderer=null}};je=F,je.desc={name:`text`};var I=class extends P{constructor(...e){super(...e),this._runtimeData=Object.create(null),this._roundPixels=0,this._bounds=new D(0,1,0,0),this._boundsDirty=!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}collectRenderableSimple(e,t){let n=e[this.renderPipeId];n&&n.addRenderable&&n.addRenderable(this,t),this.didViewUpdate=!1;let r=this.children;for(let n=0;n<r.length;++n)r[n].collectRenderables(e,t)}containsPoint(e){let t=this.bounds,{x:n,y:r}=e;return n>t.minX&&n<t.maxX&&r>t.minY&&r<t.maxY}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}destroy(e=!1){for(let e in this._runtimeData)this._runtimeData[e].destroy();this._runtimeData=Object.create(null),this.onViewUpdate(),super.destroy(e),this._bounds=null}},Me=class{constructor(){this.points=[],this.type=`polygon`}construction(){}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}getBounds(){let e=new d,t=this.points,n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e<t.length;e+=2){let o=t[e],s=t[e+1];n=Math.min(n,o),r=Math.min(r,s),i=Math.max(i,o),a=Math.max(a,s)}return e.x=n,e.width=i-n,e.y=r,e.height=a-r,e}},Ne=8,L=1.1920929e-7,Pe=1,R=.01,z=0,B=0;function Fe(e,t,n,r,i,a,o,s,c,l){let u=(Pe-Math.min(.99,Math.max(0,l==null?.5:l)))/1;return u*=u,Ie(t,n,r,i,a,o,s,c,e,u),e}function Ie(e,t,n,r,i,a,o,s,c,l){V(e,t,n,r,i,a,o,s,c,l,0),c.push(o,s)}function V(e,t,n,r,i,a,o,s,c,l,u){if(u>Ne)return;let d=Math.PI,f=(e+n)/2,p=(t+r)/2,m=(n+i)/2,h=(r+a)/2,g=(i+o)/2,_=(a+s)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(h+_)/2,S=(v+b)/2,C=(y+x)/2;if(u>0){let u=o-e,f=s-t,p=Math.abs((n-o)*f-(r-s)*u),m=Math.abs((i-o)*f-(a-s)*u),h,g;if(p>L&&m>L){if((p+m)*(p+m)<=l*(u*u+f*f)){if(z<R){c.push(S,C);return}let l=Math.atan2(a-r,i-n);if(h=Math.abs(l-Math.atan2(r-t,n-e)),g=Math.abs(Math.atan2(s-a,o-i)-l),h>=d&&(h=2*d-h),g>=d&&(g=2*d-g),h+g<z){c.push(S,C);return}if(B!==0){if(h>B){c.push(n,r);return}if(g>B){c.push(i,a);return}}}}else if(p>L){if(p*p<=l*(u*u+f*f)){if(z<R){c.push(S,C);return}if(h=Math.abs(Math.atan2(a-r,i-n)-Math.atan2(r-t,n-e)),h>=d&&(h=2*d-h),h<z){c.push(n,r),c.push(i,a);return}if(B!==0&&h>B){c.push(n,r);return}}}else if(m>L){if(m*m<=l*(u*u+f*f)){if(z<R){c.push(S,C);return}if(h=Math.abs(Math.atan2(s-a,o-i)-Math.atan2(a-r,i-n)),h>=d&&(h=2*d-h),h<z){c.push(n,r),c.push(i,a);return}if(B!==0&&h>B){c.push(i,a);return}}}else if(u=S-(e+o)/2,f=C-(t+s)/2,u*u+f*f<=l){c.push(S,C);return}}V(e,t,f,p,v,y,S,C,c,l,u+1),V(S,C,b,x,g,_,o,s,c,l,u+1)}var Le=class{constructor(e){this.shapePrimitives=[],this._bounds=new D,this._graphicsPath=e}_ensurePoly(e=!0){this._currentPoly||(this._currentPoly=new Me,e&&this._currentPoly.points.push(0,0))}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,r=n[n.length-2],i=n[n.length-1];return(r!==e||i!==t)&&n.push(e,t),this}rect(e,t,n,r){return this.drawShape(new d(e,t,n,r)),this}drawShape(e){return this.endPloy(),this.shapePrimitives.push({shape:e}),this}moveTo(e,t){return this.startPoly(e,t),this}bezierCurveTo(e,t,n,r,i,a,o){this._ensurePoly();let s=this._currentPoly.points;return Fe(s,this._currentPoly.lastX,this._currentPoly.lastY,e,t,n,r,i,a,o),this}startPoly(e,t){return this._currentPoly&&this.endPloy(),this._currentPoly=new Me,this._currentPoly.points.push(e,t),this}endPloy(e=!1){let t=this._currentPoly;t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null}closePath(){return this.endPloy(!0),this}buildPath(){let e=this._graphicsPath;for(let t=0;t<e.instructions.length;++t){let n=e.instructions[t];this[n.action](...n.data)}return this}get bounds(){let e=this._bounds;e.clear();let t=this.shapePrimitives;for(let n=0;n<t.length;++n){let r=t[n].shape.getBounds();e.addRect(r)}return e}},Re=class e{constructor(){this.instructions=[],this._dirty=!0}rect(e,t,n,r){return this.instructions.push({action:`rect`,data:[e,t,n,r]}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:`lineTo`,data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:`bezierCurveTo`,data:e}),this}moveTo(...e){return this.instructions.push({action:`moveTo`,data:e}),this}closePath(){return this.instructions.push({action:`closePath`,data:[]}),this._dirty=!0,this}get shapePath(){return this._shapePath||(this._shapePath=new Le(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}get bounds(){return this.shapePath.bounds}getLastPoint(){let e=this.instructions.length-1,t=this.instructions[e];if(!t)return{x:0,y:0};switch(t.action){case`moveTo`:case`lineTo`:return{x:t.data[0],y:t.data[1]}}return{x:0,y:0}}clear(){this.instructions.length=0,this._dirty=!0}clone(){let t=new e;return t.instructions=this.instructions.slice(),t}},ze,H=class e{constructor(){this._activePath=new Re,this._bounds=new D,this._boundsDirty=!0,this.instructions=[]}setStrokeStyle(t){this._strokeStyle=Be(t,e.defaultStrokeStyle)}clear(){return this._activePath.clear(),this.instructions.length=0,this.onUpdate(),this}onUpdate(){this._boundsDirty=!0}moveTo(e,t){return this._activePath.moveTo(e,t),this}lineTo(e,t){return this._activePath.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a,o){return this._activePath.bezierCurveTo(e,t,n,r,i,a,o),this}rect(e,t,n,r){return this._activePath.rect(e,t,n,r),this}beginPath(){return this._activePath=new Re,this}closePath(){return this._activePath.closePath(),this}fill(t){let n={...e.defaultStrokeStyle,color:t};return this.instructions.push({action:`fill`,data:{style:n,path:this._activePath.clone()}}),this}stroke(){this.instructions.push({action:`stroke`,data:{style:this._strokeStyle,path:this._activePath.clone()}}),this._initNextPathLocation()}_initNextPathLocation(){let{x:e,y:t}=this._activePath.getLastPoint();this._activePath.clear(),this._activePath.moveTo(e,t)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;++t){let n=this.instructions[t],r=n.action;if(r===`fill`){let t=n.data;e.addBounds(t.path.bounds)}else if(r===`stroke`){let t=n.data,r=t.style.alignment,i=t.style.width*(1-r);t.style.join;let a=t.path.bounds;e.addFrame(a.minX-i,a.minY-i,a.maxX+i,a.maxY+i)}}return e.isValid||e.set(0,0,0,0),e}clone(){let t=new e;return t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._bounds=this._bounds.clone(),t._strokeStyle={...this._strokeStyle},t}};ze=H,ze.defaultStrokeStyle={width:1,color:`#ffffff`,alignment:.5,miterLimit:10,cap:`butt`,join:`miter`,pixelLine:!1,alpha:1};function Be(e,t){return{...t,...e}}var Ve=class extends I{constructor(e){e instanceof H&&(e={context:e});let{context:t,...n}=e||{};super({label:`Graphics`,...n}),this.renderPipeId=`graphics`,t?this.context=t:this.context=new H,this.didViewUpdate=!0}get context(){return this._context}set context(e){e!==this._context&&(this._context=e,this.onViewUpdate())}setStrokeStyle(...e){return this._callContextMethod(`setStrokeStyle`,e)}rect(...e){return this._callContextMethod(`rect`,e)}bezierCurveTo(...e){return this._callContextMethod(`bezierCurveTo`,e)}lineTo(...e){return this._callContextMethod(`lineTo`,e)}moveTo(...e){return this._callContextMethod(`moveTo`,e)}stroke(...e){return this._callContextMethod(`stroke`,e)}beginPath(){return this._callContextMethod(`beginPath`,[])}closePath(){return this._callContextMethod(`closePath`,[])}fill(e){return this._callContextMethod(`fill`,[e])}_callContextMethod(e,t){return this.context[e](...t),this}updateBounds(){}get bounds(){return this._context.bounds}clear(){return this._callContextMethod(`clear`,[])}},He,U=class{constructor(e){this._renderer=e}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}validateRenderable(e){return!1}execute(e){let t=this._renderer,n=t.canvasContext,r=n.activeConext,i=t.roundPixels,a=(e.groupColorAlpha>>>24&255)/255;if(!(a<=0)){r.save(),n.setContextTransform(e.relativeGroupTransform,i);for(let t=0;t<e.context.instructions.length;++t){let n=e.context.instructions[t],i=n.data.style,o=i.alpha*a;if(o<=0)continue;r.globalAlpha=o;let s=n.action===`stroke`;if(s){let e=i.color;r.lineWidth=i.width,r.lineCap=i.cap,r.lineJoin=i.join,r.miterLimit=i.miterLimit,r.strokeStyle=e}else r.fillStyle=n.data.style.color;let c=n.data.path.shapePath.shapePrimitives;for(let e=0;e<c.length;++e){let t=c[e];t.shape&&(r.beginPath(),W(r,t.shape),s?r.stroke():r.fill())}}r.restore()}}destroy(){this._renderer=null}};He=U,He.desc={name:`graphics`};function W(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`polygon`:{let n=t,r=n.points;if(!r.length)return;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}var Ue,We=class{constructor(){this.renderPipeId=`batch`,this.elements=[]}},Ge=class{constructor(e){this._renderer=e}get batch(){return this._activeBatch}buildStart(){this._activeBatch=new Ke}buildEnd(e){this.break(e)}break(e){this._activeBatch.build(e)}addToBatch(e,t){this._activeBatch.add({...e,getColor:()=>e.renderable.groupColorAlpha})}execute(e){let t=e.elements;if(!t||!t.length)return;let n=this._renderer.canvasContext,r=n.activeConext;for(let e=0;e<t.length;e++){let i=t[e],a=i.roundPixels,o=(i.getColor()>>>24&255)/255;if(o<=0)continue;r.globalAlpha=o,n.setContextTransform(i.transform,a===1);let s=i.bounds,c=i.texture,l=c.frame,u=c.source._resolution||1,d=l.x*u,f=l.y*u,p=l.width*u,m=l.height*u,h=s.minX,g=s.minY,_=s.maxX-s.minX,v=s.maxY-s.minY,y=h,b=g,x=_,S=v;r.drawImage(c.source.resource,d,f,p,m,y,b,x,S)}}destroy(){var e;this._renderer=null,(e=this._activeBatch)==null||e.destroy(),this._activeBatch=null}};Ue=Ge,Ue.desc={name:`batch`};var Ke=class{constructor(){this.renderPipeId=`batch`,this.elements=[],this.elementSize=0}add(e){this.elements[this.elementSize++]=e}build(e){let t=new We,n=this.elements;if(n[0]){for(let e=0;e<n.length;e++){let r=n[e];this.elements[e]=null,t.elements.push(r)}e.add(t)}}destroy(){this.elements=null}},qe=class{constructor(){this._canvasPool=Object.create(null)}getOptimalCanvasAndContext(e,t,n=1){let r=p(e*n-1e-6),i=p(t*n-1e-6),a=r<<17+i<<1;this._canvasPool[a]||(this._canvasPool[a]=[]);let o=this._canvasPool[a].pop();if(o)return o;{let e=document.createElement(`canvas`);return e.width=r,e.height=i,{canvas:e,context:e.getContext(`2d`)}}}};const Je=new qe;var Ye,G=class e{constructor(t){this.uid=w(`textStyle`),this._tick=0;let n={...e.defaultStyle,...t};for(let e in n){let t=e;this[t]=n[e]}}get styleKey(){return`${this.uid}-${this._tick}`}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.update())}get fill(){return this._fill}set fill(e){this._fill!==e&&(this._fill=e,this.update())}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get wordWarp(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline=e,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=Ze(this)),this._cachedFontString}update(){this._tick++,this._cachedFontString=null}destroy(e=!1){this._fill=null}};Ye=G,Ye.defaultStyle={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};var Xe=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`];function Ze(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/([\"\'])[^\'\"]+\1/.test(t)&&!Xe.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var K;const Qe=/(?:\r\n|\r|\n)/;var q=class e{constructor(e,t,n,r,i,a,o,s,c){this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c}static get canvas(){if(!e._canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,{willReadFrequently:!0}).measureText)return e._canvas=n,n;t=J(10,10)}catch(e){t=J(10,10)}e._canvas=t}return e._canvas}static get context(){return e._context||(e._context=e.canvas.getContext(`2d`,{willReadFrequently:!0})),e._context}static measureText(t,n){let r=`${t}-${n.styleKey}`;if(e._measurementCache.has(r))return e._measurementCache.get(r);let i=n._fontString,a=e.measureFont(i);a.fontSize===0&&(a.fontSize=n.fontSize,a.ascent=n.fontSize,a.descent=0);let o=e.context;o.font=i;let s=t.split(Qe),c=Array(s.length),l=0;for(let t=0;t<s.length;++t){let r=e._measureText(s[t],n.letterSpacing);c[t]=r,l=Math.max(l,r)}let u=n.lineHeight||a.fontSize,d=new e(t,n,l,Math.max(u,a.fontSize+(s.length-1)*(u+n.leading)),s,c,u,l,a);return e._measurementCache.set(r,d),d}static _measureText(t,n){var r,i;let a=e.context;a.letterSpacing=`0px`,a.textLetterSpacing=n;let o=a.measureText(t),s=o.width,c=0;s>0&&(c=(e.graphemeSegmenter(t).length-1)*n,s+=c);let l=-((r=o.actualBoundingBoxLeft)==null?0:r),u=((i=o.actualBoundingBoxRight)==null?0:i)-l;return o.width>0&&(u+=c),Math.max(s,u)}static measureFont(t){var n,r;if(e._fonts[t])return e._fonts[t];let i=e.context;i.font=t;let a=i.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),o=(n=a.actualBoundingBoxAscent)==null?0:n,s=(r=a.actualBoundingBoxDescent)==null?0:r,c={ascent:o,descent:s,fontSize:o+s};return e._fonts[t]=c,c}};K=q,K.METRICS_STRING=`|ÉqÅ`,K.BASELINE_SYMBOL=`M`,K._measurementCache=new Map,K._fonts={},K.graphemeSegmenter=(()=>{var e;if(typeof((e=Intl)==null?void 0:e.Segmenter)==`function`){let e=new Intl.Segmenter;return t=>{let n=e.segment(t),r=[],i=0;for(let e of n)r[i++]=e.segment;return r}}return e=>[...e]})();function J(e,t){let n=document.createElement(`canvas`);return n.width=e,n.height=t,n}function $e(e){let{text:t,style:n,resolution:r=1,padding:i=0}=e,a=q.measureText(t,n),o=Math.ceil(Math.ceil(Math.max(1,a.width)+i*2)*r),s=Math.ceil(Math.ceil(Math.max(1,a.height)+i*2)*r),c=Je.getOptimalCanvasAndContext(o,s);return et(n,r,i,c,a),{canvasAndContext:c,frame:new d(0,0,o,s)}}function et(e,t,n,r,i){let{context:a}=r,o=Ze(e),{lines:s,lineHeight:c,lineWidths:l,maxLineWidth:u,fontProperties:d}=i;a.resetTransform(),a.scale(t,t),a.textBaseline=e.textBaseline,a.font=o;let f=Math.min(0,(c-d.fontSize)/2);a.fillStyle=e.fill;for(let t=0;t<s.length;++t){let i=tt(l[t],u,e.align),a=t*c+d.ascent+f,o=0;if(e.align===`justify`&&e.wordWrap&&t<s.length-1){let e=nt(s[t]);e>0&&(o=(u-l[t])/e)}rt(s[t],e,r,i+n,a+n,!1,o)}}function tt(e,t,n){return n===`right`?t-e:n===`center`?(t-e)/2:0}function nt(e){let t=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===32&&t++;return t}function rt(e,t,n,r,i,a=!1,o=0){let s=n.context,c=t.letterSpacing;if(c===0&&o===0){s.fillText(e,r,i);return}if(o!==0&&c===0){let t=e.split(` `),n=r,a=s.measureText(` `).width;for(let e=0;e<t.length;++e)s.fillText(t[e],n,i),n+=s.measureText(t[e]).width+a+o;return}let l=r,u=q.graphemeSegmenter(e),d=s.measureText(e).width,f=0;for(let e=0;e<u.length;++e){let t=u[e];s.fillText(t,l,i);let n=``;for(let t=e+1;t<u.length;++t)n+=u[t];f=s.measureText(n).width,l+=d-f+c,t===``&&(l+=o),d=f}}var it,Y=class e extends E{constructor(t){super(),this.uid=w(`textureSource`),this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1;let n={...e.defaultOptions,...t};this.label=t.label,this.resource=n.resource,this._resolution=n.resolution,n.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&this.resourceWidth||1,n.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&this.resourceHeight||1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.destroyed=!1}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}get resourceWidth(){let e=this.resource;return e.naturalWidth||e.width}get resourceHeight(){let e=this.resource;return e.naturalHeight||e.height}resize(e,t,n){n||(n=this._resolution),e||(e=this.width),t||(t=this.height);let r=Math.round(e*n),i=Math.round(t*n);return this.width=r/n,this.height=i/n,this._resolution=n,this.pixelWidth===r&&this.pixelHeight===i?!1:(this.pixelWidth=r,this.pixelHeight=i,this.emit(`resize`,this),!0)}destroy(){this.destroyed=!0,this.resource=null,this.emit(`destroy`,this),this.removeAllListeners()}};it=Y,it.defaultOptions={resolution:1};var at=class extends Y{constructor(e){e.resource||(e.resource=J()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.autoDensity=e.autoDensity,this.resizeCanvas()}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,t=this.height,n=this._resolution){let r=super.resize(e,t,n);return r&&this.resizeCanvas(),r}},X=class extends E{constructor({source:e,label:t,frame:n,orig:r,rotate:i}={}){if(super(),this.frame=new d,this.noFrame=!1,this.label=t,this.source=e,n)this.frame.copyFrom(n);else{this.noFrame=!0;let{width:t,height:n}=e;this.frame.width=t,this.frame.height=n}this.orig=r||this.frame,this.rotate=i==null?0:i,this.destroyed=!1}get source(){return this._source}set source(e){this._source&&this._source.off(`resize`,this.update,this),this._source=e,e.on(`resize`,this.update,this)}get width(){return this.orig.width}get height(){return this.orig.height}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height)}destroy(e=!1){this._source&&(this._source.off(`resize`,this.update,this),e&&(this._source.destroy(),this._source=null)),this.destroyed=!0,this.emit(`destroy`,this),this.removeAllListeners()}};X.EMPTY=new X({label:`EMPTY`,source:new Y({label:`EMPTY`})});var ot,st=class{constructor(e){this._activeTexture={},this.renderer=e}getManagedTexture(e){e._resolution=e._autoResolution?this.renderer.resolution:e.resolution;let t=e.styleKey;if(this._activeTexture[t])return this._activeTexture[t];let n=this.getTexture({text:e.text,style:e.style,resolution:e._resolution});return this._activeTexture[t]=n,n}getTexture(e){let{text:t,style:n}=e,r=e.resolution||this.renderer.resolution,{frame:i,canvasAndContext:a}=$e({text:t,style:n,resolution:r}),o=a.canvas,s=new X({source:new Y({resource:o,resolution:r})});return s.frame.width=i.width/r,s.frame.height=i.height/r,s}};ot=st,ot.desc={name:`text`};var ct,lt=class{constructor(e){this._canvasMaskStack=[],this._renderer=e}push(e,t){t.add({renderPipeId:`stencilMask`,action:`pushMaskBegin`,mask:e})}pop(e,t){this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:`stencilMask`,action:`popMaskEnd`,mask:e})}execute(e){if(e.action!==`pushMaskBegin`&&e.action!==`popMaskEnd`)return;let t=this._renderer.canvasContext,n=t.activeConext;if(e.action===`popMaskEnd`){this._canvasMaskStack.pop()&&n.restore();return}let r=e.mask.mask,i=r.context.instructions,a=r._roundPixels===1;n.save(),t.setContextTransform(r.relativeGroupTransform,a),n.beginPath();for(let e=0;e<i.length;++e){let t=i[e],r=t.action;if(r!==`fill`&&r!==`stroke`)return;let a=t.data.path.shapePath.shapePrimitives;for(let e=0;e<a.length;++e){let t=a[e].shape;W(n,t)}}n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null}};ct=lt,ct.desc={name:`stencilMask`};var ut=class e extends X{static create(t){return new e({source:new Y(t)})}},dt=class extends I{constructor(e=X.EMPTY){e instanceof X&&(e={texture:e});let{texture:t=X.EMPTY,width:n,height:r,...i}=e;super({label:`Sprite`,...i}),this.renderPipeId=`sprite`,this.texture=t,this.anchor=new f,n!=null&&(this.width=n),r!=null&&(this.height=r)}set texture(e){e||(e=X.EMPTY),this._texture!==e&&(this._texture=e,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 height(){return Math.abs(this.scale.y)*this.texture.orig.height}set height(e){let t=this.texture.orig.height,n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n,this._height=e}get width(){return Math.abs(this.scale.x)*this.texture.orig.width}set width(e){let t=this.texture.orig.width,n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n,this._width=e}updateBounds(){let e=this._bounds,{width:t,height:n}=this.texture.orig;e.minX=-this.anchor.x*t,e.maxX=e.minX+t,e.minY=-this.anchor.y*n,e.maxY=e.minY+n}},ft=class extends I{constructor(e){var t;let{text:n,resolution:r,style:i,width:a,height:o,...s}=e;super(s),this.renderPipeId=`text`,this._didTextUpdate=!0,this._resolution=null,this._autoResolution=!0,this._anchor=new T({_onUpdate:()=>{this.onViewUpdate()}},0,0),this.text=(t=e.text)==null?``:t,this.style=i,this.resolution=r==null?null:r,a!=null&&(this.width=a),o!=null&&(this.height=o)}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get anchor(){return this._anchor}set anchor(e){this._anchor.copyFrom(e)}get text(){return this._text}set text(e){let t=String(e);this._text!==t&&(this._text=t,this.onViewUpdate())}get style(){return this._style}set style(e){e||(e={}),e instanceof G?this._style=e:this._style=new G(e),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}updateBounds(){let e=this._bounds,t=this._anchor,n=q.measureText(this._text,this._style),r=n.width,i=n.height;e.minX=-t._x*r,e.minY=-t._y*i,e.maxX=e.minX+r,e.maxY=e.minY+i}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}destroy(e=!1){super.destroy(e),this._bounds=null,this._anchor=null,(typeof e==`boolean`?e:e!=null&&e.style)&&this._style.destroy(e),this._style=null,this._text=null}},pt,mt=class{constructor(e){this._renderer=e}texture(e){return this._generateTexture(e)}_generateTexture(e){e instanceof P&&(e={target:e});let t=e.resolution||this._renderer.resolution,n=e.target,r=new D,i=e.frame||k(n,r).rectangle;i.width=Math.max(i.width,1/t)|0,i.height=Math.max(i.height,1/t)|0;let a=ut.create({width:i.width,height:i.height,resolution:t}),o=new u;return o.tx=-i.x,o.ty=-i.y,this._renderer.render({clearColor:`transparent`,container:n,transform:o,target:a}),a}};pt=mt,pt.desc={name:`extract`};var ht,gt=class{constructor(e){this.activeResolution=1,this.globalTransform=new u,this._renderer=e}init(){this.activeConext=this._renderer.canvas.getContext(`2d`),this.rootContext=this.activeConext,this.activeResolution=this._renderer.resolution}setContextTransform(e,t,n){let r=this.activeResolution,i=u.append(this.globalTransform,e);n||(n=this.activeResolution),t?this.activeConext.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*r|0,i.ty*r|0):this.activeConext.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*r,i.ty*r)}};ht=gt,ht.desc={name:`canvasContext`};var Z,_t=class e{get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(t){t={...e.defaultOptions,...t},this.screen=new d(0,0,t.width,t.height),this.canvas=J(),this.texture=new X({source:new at({resource:this.canvas,...t})}),this.resolution=t.resolution}resize(e,t,n){this.texture.source.resize(e,t,n),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}};Z=_t,Z.desc={name:`view`},Z.defaultOptions={width:800,height:600,autoDensity:!1};var Q=[_t,_,De,st,mt,gt],vt=[Ge,U,F,Ae,lt],yt=class extends E{constructor(){super(),this.uid=w(`renderer`),this.renderedObject=null,this.renderPipes={},this.background={color:`#000000`}}get canvas(){return this.view.canvas}_addPipes(){vt.forEach(e=>{this.renderPipes[e.desc.name]=new e(this)})}_addSystems(){Q.forEach(e=>{this[e.desc.name]=new e(this)})}async init(e){this.resolution=e.resolution||1,this._addSystems(),this._addPipes();for(let r=0;r<Q.length;++r){var t,n;await((t=(n=this[Q[r].desc.name]).init)==null?void 0:t.call(n,e))}e.backgroundColor&&(this.background.color=e.backgroundColor),this._roundPixels=e.roundPixels?1:0}get roundPixels(){return!!this._roundPixels}render(e){let t=e;if(t instanceof P&&(t={container:t}),this.renderedObject=t.container,t.transform||(t.container.updateLocalTransform(),t.transform=t.container.localTransform),t.clearColor!=null||(t.clearColor=this.background.color),!t.container.visible)return;t.container.enableRenderGroup();let n=t.container.renderGroup;if(this.activeRenderGroup=n,this.canvasContext.globalTransform=n.worldTransform,this.canvasContext.activeConext=this.canvasContext.rootContext,t.target){let{context:e}=bt(t.target.source);this.canvasContext.activeConext=e}this.clear(t),Q.forEach(e=>{var n,r;(n=(r=this[e.desc.name]).render)==null||n.call(r,t)})}clear(e){let t=this.canvasContext.activeConext;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,this.canvas.width,this.canvas.height),t.globalAlpha=1,t.fillStyle=e.clearColor,t.fillRect(0,0,this.canvas.width,this.canvas.height),t.globalAlpha=1}destroy(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),vt.forEach(e=>{var t;(t=this.renderPipes[e.desc.name])==null||t.destroy()}),this.renderPipes=null}resize(e,t,n){this.view.resize(e,t,n),this.emit(`resize`,this.view.screen.width,this.view.screen.height,this.view.resolution)}};function bt(e){let t=e.resource;return t||(t=J(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight),{canvas:t,context:t.getContext(`2d`)}}var xt=class{constructor(e,t,n=0,r=!1){this.next=null,this.previous=null,this.priority=0,this._destroyed=!1,this._fn=e,this._context=t,this.priority=n,this._once=r}match(e,t){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));let t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}destroy(e){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let t=this.next;return this.next=e?null:t,this.previous=null,t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}},St,Ct=class e{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._lastFrame=-1,this._head=null,this._head=new xt(null,null,1/0),this.deltaMS=1/e.targetFPMS,this.elapsedMS=this.deltaMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&(this._requestId=requestAnimationFrame(this._tick)))}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){let e=t-this._lastFrame|0;if(e<this._minElapsedMS)return;this._lastFrame=t-e%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*e.targetFPMS;let r=this._head,i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){this._maxElapsedMS=1/Math.min(Math.max(0,t)/1e3,e.targetFPMS),this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}add(e,t,n=0){let r=new xt(e,t,n),i=this._head.next,a=this._head;if(!i)r.connect(a);else{for(;i;){if(r.priority>i.priority){r.connect(a);break}a=i,i=i.next}r.previous||r.connect(a)}return this._startIfPossible(),this}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}remove(e,t){let n=this._head.next;for(;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}_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)}destroy(){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}};St=Ct,St.targetFPMS=.06;var wt=class{static init(e){Object.defineProperty(this,`resizeTo`,{configurable:!0,set(e){globalThis.removeEventListener(`resize`,this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener(`resize`,this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,t;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,t=globalThis.innerHeight;else{let{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,t=r}this.renderer.resize(e,t),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener(`resize`,this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}},Tt=[wt],Et=class{constructor(){this.stage=new P}async init(e={}){e={...e},this.stage||(this.stage=new P),this.renderer=new yt,await this.renderer.init(e),Tt.forEach(t=>{t.init.call(this,e)}),this.ticker=new Ct,(e.autoStart||e.autoStart==null)&&this._ticker.start()}get canvas(){return this.renderer.canvas}get screen(){return this.renderer.view.screen}get ticker(){return this._ticker}set ticker(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this)}render(){this.renderer.render({container:this.stage})}destroy(){let e=Tt.slice(0);if(e.reverse(),e.forEach(e=>{e.destroy.call(this)}),this.stage.destroy(),this.stage=null,this.renderer.destroy(),this.renderer=null,this._ticker){let e=this._ticker;this._ticker=null,e.destroy()}}},Dt=class{constructor(){this._cache=new Map,this._cacheMap=new Map}reset(){this._cache.clear(),this._cacheMap.clear()}has(e){return this._cache.has(e)}get(e){let t=this._cache.get(e);if(!t)throw Error(`Asset ${e} not found`);return t}set(e,t){let n=Array.isArray(e)?e:[e],r=new Map;n.forEach(e=>{r.set(e,t)});let i=[...r.keys()],a={cacheKeys:i,keys:n};n.forEach(e=>{this._cacheMap.set(e,a)}),i.forEach(e=>{this._cache.has(e)&&this._cache.has(e),this._cache.set(e,r.get(e))})}remove(e){if(!this._cacheMap.has(e))return;let t=this._cacheMap.get(e);((t==null?void 0:t.cacheKeys)||[]).forEach(e=>{this._cache.delete(e)}),t==null||t.keys.forEach(e=>{this._cacheMap.delete(e)})}};const $=new Dt;var Ot,kt=class e{constructor(){this.promiseCache={},this.loadOptions={...e.defaultOptions}}getAlias(e){let{alias:t,src:n}=e,r=t||n;return(Array.isArray(r)?r:[r]).map(e=>typeof e==`string`?e:Array.isArray(e)?e.map(e=>{var t;return(t=e.src)==null?e:t}):e!=null&&e.src?e.src:e)}async load(t,n){let{onProgress:r,onError:i,strategy:a,retryCount:o,retryDelay:s}=typeof n==`function`?{...e.defaultOptions,...this.loadOptions,onProgress:n}:{...e.defaultOptions,...this.loadOptions,...n||{}},c=0,l={},u=t.reduce((e,t)=>e+(t.progressSize||1),0),d=t.map(async e=>{if(l[e.src])return;let t=e.src;await this._loadAssetWithRetry(t,e,{onProgress:r,onError:i,strategy:a,retryCount:o,retryDelay:s},l),c+=e.progressSize||1,r&&r(c/u)});return await Promise.all(d),l}async unload(e){let t=e.map(async e=>{let t=e.src,n=this.promiseCache[t];if(n){let e=await n;delete this.promiseCache[t],e.destroy(!0)}});await Promise.all(t)}_getLoadPromise(e,t){return(async()=>await At(e,t,this))()}async _loadAssetWithRetry(e,t,n,r){let i=0,{onError:a,strategy:o,retryCount:s,retryDelay:c}=n,l=e=>new Promise(t=>setTimeout(t,e));for(;;)try{this.promiseCache[e]||(this.promiseCache[e]=this._getLoadPromise(e,t)),r[t.src]=await this.promiseCache[e];return}catch(n){if(delete this.promiseCache[e],delete r[t.src],i++,o===`retry`&&!(o!==`retry`||i>s)){a&&a(n,t.src),await l(c);continue}if(o===`skip`){a&&a(n,t.src);return}a&&a(n,t.src);let u=Error(`[Loader.load] Failed to load ${e}.\n${n}`);throw n instanceof Error&&n.stack&&(u.stack=n.stack),u}}reset(){this.promiseCache={}}};Ot=kt,Ot.defaultOptions={strategy:`throw`,retryCount:3,retryDelay:250};async function At(e,t,n){let r=null;return r=globalThis.createImageBitmap?await jt(e):await new Promise((t,n)=>{r=new Image,r.crossOrigin=`anonymous`,r.src=e,r.complete?t(r):(r.onload=()=>{t(r)},r.onerror=n)}),Mt(new Y({resource:r}),n,e)}async function jt(e){let t=await window.fetch(e);if(t.headers.get(`content-type`)===`text/html`||!t.ok)throw Error(`[loadImageBitmap] Failed to fetch ${e}: ${t.status} ${t.statusText}`);let n=await t.blob();return window.createImageBitmap(n)}function Mt(e,t,n){e.label=n;let r=new X({source:e,label:n}),i=()=>{delete t.promiseCache[n],$.has(n)&&$.remove(n)};return r.source.on(`destroy`,()=>{t.promiseCache[n]&&i()}),r.on(`destroy`,()=>{e.destroyed||i()}),r}var Nt=class{constructor(){this._initialized=!1,this.loader=new kt,this.cache=$}init(e={}){this._initialized||(this._initialized=!0,e.basePath&&(this.basePath=e.basePath),e.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...e.loadOptions}))}async load(e,t){this._initialized||this.init();let n=e.map(e=>({...e,src:Ft(e.src,this.basePath)}));return await this._mapLoadToResolve(n,t)}async _mapLoadToResolve(e,t){let n=Object.values(e),r=await this.loader.load(n,t),i={};return n.forEach(e=>{let t=r[e.src],n=Array.isArray(e.alias)?e.alias:[e.alias],a=[e.src,...n];a.forEach(e=>{i[e]=t}),$.set(a,t)}),i}reset(){this._initialized=!1,this.cache.reset(),this.loader.reset()}};const Pt=new Nt;function Ft(e,t){return e.startsWith(`http`)||!t?e:e.startsWith(`/`)&&t.endsWith(`/`)?t+e.slice(1):e.startsWith(`/`)&&!t.endsWith(`/`)||!e.startsWith(`/`)&&t.endsWith(`/`)?t+e:`${t}/${e}`}exports.Application=Et,exports.Assets=Pt,exports.AssetsClass=Nt,exports.CanvasRenderer=yt,exports.Container=P,exports.Graphics=Ve,exports.GraphicsContext=H,exports.GraphicsPipe=U,exports.Matrix=u,exports.PI_2=l,exports.Rectangle=d,exports.RenderGroup=S,exports.RenderTexture=ut,exports.Sprite=dt,exports.Text=ft,exports.TextPipe=F,exports.Texture=X,exports.Ticker=Ct,exports.TickerListener=xt,exports.UPDATE_BLEND=2,exports.UPDATE_COLOR=1,exports.UPDATE_TRANSFORM=8,exports.UPDATE_VISIBLE=4,exports.Vector2=f,exports.ViewContainer=I,exports.buildShapePath=W,exports.nextPow2=p;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=((n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)))(o(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1).default;function l(e){"@babel/helpers - typeof";return l=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},l(e)}function u(e,t){if(l(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(l(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function d(e){var t=u(e,`string`);return l(t)==`symbol`?t:t+``}function f(e,t,n){return(t=d(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var p=class{constructor(){f(this,`renderPipeId`,`batch`),f(this,`elements`,[])}},m=class{constructor(e){f(this,`_renderer`,void 0),f(this,`_activeBatch`,void 0),this._renderer=e}get batch(){return this._activeBatch}buildStart(){this._activeBatch=new h}buildEnd(e){this.break(e)}break(e){this._activeBatch.build(e)}addToBatch(e,t){this._activeBatch.add({...e,getColor:()=>e.renderable.groupColorAlpha})}execute(e){let t=e.elements;if(!t||!t.length)return;let n=this._renderer.canvasContext,r=n.activeConext;for(let e=0;e<t.length;e++){let i=t[e],a=i.roundPixels,o=(i.getColor()>>>24&255)/255;if(o<=0)continue;r.globalAlpha=o,n.setContextTransform(i.transform,a===1);let s=i.bounds,c=i.texture,l=c.frame,u=c.source._resolution||1,d=l.x*u,f=l.y*u,p=l.width*u,m=l.height*u,h=s.minX,g=s.minY,_=s.maxX-s.minX,v=s.maxY-s.minY,y=h,b=g,x=_,S=v;r.drawImage(c.source.resource,d,f,p,m,y,b,x,S)}}destroy(){var e;this._renderer=null,(e=this._activeBatch)==null||e.destroy(),this._activeBatch=null}};f(m,`desc`,{name:`batch`});var h=class{constructor(){f(this,`renderPipeId`,`batch`),f(this,`elements`,[]),f(this,`elementSize`,0)}add(e){this.elements[this.elementSize++]=e}build(e){let t=new p,n=this.elements;if(n[0]){for(let e=0;e<n.length;e++){let r=n[e];this.elements[e]=null,t.elements.push(r)}e.add(t)}}destroy(){this.elements=null}},g=Math.PI*2,_=class e{constructor(e=1,t=0,n=0,r=1,i=0,a=0){f(this,`a`,void 0),f(this,`b`,void 0),f(this,`c`,void 0),f(this,`d`,void 0),f(this,`tx`,void 0),f(this,`ty`,void 0),this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}static get IDENTITY(){return v.identity()}static append(t,n){return new e(n.a*t.a+n.b*t.c,n.a*t.b+n.b*t.d,n.c*t.a+n.d*t.c,n.c*t.b+n.d*t.d,n.tx*t.a+n.ty*t.c+t.tx,n.tx*t.b+n.ty*t.d+t.ty)}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}apply(e,t){t||(t=new b);let{x:n,y:r}=e;return t.x=n*this.a+r*this.c+this.tx,t.y=n*this.b+r*this.d+this.ty,t}translate(e,t){return this.tx+=e,this.ty+=t,this}rotate(e){let t=Math.cos(e),n=Math.sin(e),r=this.a,i=this.c,a=this.tx;return this.a=r*t-this.b*n,this.b=r*n+this.b*t,this.c=i*t-this.d*n,this.d=i*n+this.d*t,this.tx=a*t-this.ty*n,this.ty=a*n+this.ty*t,this}scale(e,t){return this.a*=e,this.d*=t,this.c*=e,this.b*=t,this.tx*=e,this.ty*=t,this}appendFrom(e,t){let n=e.a,r=e.b,i=e.c,a=e.d,o=e.tx,s=e.ty,c=t.a,l=t.b,u=t.c,d=t.d,f=t.tx,p=t.ty;return this.a=n*c+r*u,this.b=n*l+r*d,this.c=i*c+a*u,this.d=i*l+a*d,this.tx=o*c+s*u+f,this.ty=o*l+s*d+p,this}set(e,t,n,r,i,a){this.a=e,this.b=t,this.c=n,this.d=r,this.tx=i,this.ty=a}applyInverse(e,t){t=t||new b;let n=this.a,r=this.b,i=this.c,a=this.d,o=this.tx,s=this.ty,c=1/(n*a+i*-r),l=e.x,u=e.y;return t.x=a*c*l+-i*c*u+(s*i-o*a)*c,t.y=n*c*u+-r*c*l+(-s*n+o*r)*c,t}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}decompose(e){let t=this.a,n=this.b,r=this.c,i=this.d,a=e.pivot,o=-Math.atan2(-r,i),s=Math.atan2(n,t),c=Math.abs(o+s);return c<1e-5||Math.abs(g-c)<1e-5?(e.rotation=s,e.skew.x=e.skew.y=0):(e.rotation=0,e.skew.x=o,e.skew.y=s),e.scale.x=Math.sqrt(t*t+n*n),e.scale.y=Math.sqrt(r*r+i*i),e.position.x=this.tx+a.x*t+a.y*r,e.position.y=this.ty+a.x*n+a.y*i,e}clone(){let t=new e;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}},v=new _,y=class e{constructor(e=0,t=0,n=0,r=0){f(this,`x`,void 0),f(this,`y`,void 0),f(this,`width`,void 0),f(this,`height`,void 0),f(this,`type`,`rectangle`),this.x=e,this.y=t,this.width=n,this.height=r}getBounds(){let t=new e;return t.copyFrom(this),t}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}strokeContains(e,t,n,r=.5){let{width:i,height:a}=this;if(i<=0||a<=0)return!1;let o=this.x,s=this.y,c=n*(1-r),l=n-c,u=o-c,d=o+i+c,f=s-c,p=s+a+c,m=o+l,h=o+i-l,g=s+l,_=s+a-l;return e>=u&&e<=d&&t>=f&&t<=p&&!(e>m&&e<h&&t>g&&t<_)}contains(e,t){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&t>=this.y&&t<this.y+this.height}},b=class{constructor(e=0,t=0){f(this,`x`,void 0),f(this,`y`,void 0),this.x=e,this.y=t}set(e,t){t==null?this.x=this.y=e:(this.x=e,this.y=t)}copyFrom(e){return this.set(e.x,e.y),this}};function x(e){return e+=+(e===0),--e,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e+1}var S=180/Math.PI,ee=Math.PI/180,C=class{constructor(e,t,n){f(this,`_x`,void 0),f(this,`_y`,void 0),f(this,`_observer`,void 0),this._x=t||0,this._y=n||0,this._observer=e}set(e=0,t=e){return(this._x!==e||this._y!==t)&&(this._x=e,this._y=t,this._observer._onUpdate(this)),this}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}copyFrom(e){return(this.x!==e.x||this.y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}toVector2(){return new b(this.x,this.y)}},te=class{constructor(e){f(this,`_classType`,void 0),f(this,`_pool`,[]),f(this,`_index`,0),f(this,`_count`,0),this._classType=e}get(e){var t;let n;return this._index>0?n=this._pool[--this._index]:(n=new this._classType,this._count++),(t=n.init)==null||t.call(n,e),n}return(e){var t;(t=e.reset)==null||t.call(e),this._pool[this._index++]=e}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;++e)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}},ne=new class{constructor(){f(this,`_poolsByClass`,new Map)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new te(e)),this._poolsByClass.get(e)}},w=class e{constructor(e=1/0,t=1/0,n=-1/0,r=-1/0){f(this,`minX`,1/0),f(this,`minY`,1/0),f(this,`maxX`,-1/0),f(this,`maxY`,-1/0),f(this,`matrix`,new _),f(this,`_rectangle`,void 0),this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}get x(){return this.minX}set x(e){let t=this.maxX-this.minX;this.minX=e,this.maxX=e+t}get y(){return this.minY}set y(e){let t=this.maxY-this.minY;this.minY=e,this.maxY=e+t}clone(){return new e(this.minX,this.minY,this.maxX,this.maxY)}isEmpty(){return this.minX>=this.maxX||this.minY>=this.maxY}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this}pad(e,t=e){return this.minX-=e,this.maxX+=e,this.minY-=t,this.maxY+=t,this}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isValid(){return this.minX+this.minY!==1/0}set(e,t,n,r){this.minX=e,this.minY=t,this.maxX=n,this.maxY=r}addBounds(e,t){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,t)}addRect(e,t){this.addFrame(e.x,e.y,e.width+e.x,e.height+e.y,t)}addFrame(e,t,n,r,i){i||(i=this.matrix);let a=i.a,o=i.b,s=i.c,c=i.d,l=i.tx,u=i.ty,d=this.minX,f=this.minY,p=this.maxX,m=this.maxY,h=a*e+s*t+l,g=o*e+c*t+u;h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*t+l,g=o*n+c*t+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*e+s*r+l,g=o*e+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),h=a*n+s*r+l,g=o*n+c*r+u,h<d&&(d=h),g<f&&(f=g),h>p&&(p=h),g>m&&(m=g),this.minX=d,this.minY=f,this.maxX=p,this.maxY=m}get rectangle(){this._rectangle||(this._rectangle=new y);let e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):(e.x=this.minX,e.y=this.minY,e.width=this.maxX-this.minX,e.height=this.maxY-this.minY),e}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}containsPoint(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}},T=ne.getPool(_),re=ne.getPool(w);function ie(e,t,n,r,i,a){let o=e-n,s=t-r,c=i-n,l=a-r,u=o*c+s*l,d=c*c+l*l,f=-1;d!==0&&(f=u/d);let p,m;f<0?(p=n,m=r):f>1?(p=i,m=a):(p=n+f*c,m=r+f*l);let h=e-p,g=t-m;return h*h+g*g}var E={default:-1};function D(e=`default`){return E[e]===void 0&&(E[e]=-1),++E[e]}function ae(e,t,n){let{width:r,height:i}=n.orig;e.minX=-t.x*r,e.minY=-t.y*i,e.maxX=e.minX+r,e.maxY=e.minY+i}function oe(e,...t){for(let n of t)Object.defineProperties(e.prototype,Object.getOwnPropertyDescriptors(n))}var se={removeChildren(e=0,t){let n=t==null?this.children.length:t,r=n-e,i=[];if(r>0&&r<=n){for(let t=n-1;t>=e;--t){let e=this.children[t];e&&(i.push(e),e.parent=null)}ce(this.children,e,n);let t=this.renderGroup||this.parentRenderGroup;return t&&t.removeChildren(i),i.length>0&&this._didViewChangeTick++,i}else if(r===0&&this.children.length===0)return i;throw Error(`removeChildren: numeric values are outside the acceptable range.`)}};function ce(e,t,n){let r=e.length,i;if(t>=r||n===0)return;n=t+n>r?r-t:n;let a=r-n;for(i=t;i<a;++i)e[i]=e[i+n];e.length=a}function O(e,t,n){return t.clear(),n||(n=new _),le(e,t,n,e,!0),t.isValid||t.set(0,0,0,0),t}function le(e,t,n,r,i){let a;if(i)a=T.get(),a.copyFrom(n);else{if(!e.visible||!e.measurable)return;e.updateLocalTransform(),a=T.get(),a.appendFrom(e.localTransform,n)}let o=t,s=!!e.effects.length;if(s&&(t=re.get().clear()),e.boundsArea)t.addRect(e.boundsArea,a);else{e.renderPipeId&&(t.matrix=a,t.addBounds(e.bounds));let n=e.children;for(let e=0;e<n.length;e++)le(n[e],t,a,r,!1);if(s){for(let n=0;n<e.effects.length;++n){var c,l;(c=(l=e.effects[n]).addLocalBounds)==null||c.call(l,t,r)}o.addBounds(t,_.IDENTITY),re.return(t)}}T.return(a)}var ue=class{constructor(e){f(this,`pipe`,`stencilMask`),f(this,`mask`,void 0),this.mask=e,e.includeInBuild=!1,e.measurable=!1}addLocalBounds(e,t){let n=new w;this.mask.measurable=!0;let r=de(this.mask,t);O(this.mask,n,r),this.mask.measurable=!1,e.addBoundsMask(n)}};function de(e,t,n){return n||(n=new _),e===t?n:(n=de(e.parent,t,n),e.updateLocalTransform(),_.append(n,e.localTransform))}var fe={effects:[],_maskEffect:null,addEffect(e){this.effects.push(e),this._updateIsSimple()},removeEffect(e){let t=this.effects.indexOf(e);t===-1&&this.effects.splice(t,1),this._updateIsSimple()},set mask(e){let t=this._maskEffect;e!==(t==null?void 0:t.mask)&&(t&&(this.removeEffect(t),this._maskEffect=null),e!=null&&(this._maskEffect=new ue(e),this.addEffect(this._maskEffect)))},get mask(){var e;return(e=this._maskEffect)==null?void 0:e.mask}},pe={_localBoundsCacheData:null,_setWidth(e,t){let n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n},_setHeight(e,t){let n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new w});let e=this._localBoundsCacheData;return e.index=1,e.didChange=!1,e.data[0]!==this._didViewChangeTick&&(e.didChange=!0,e.data[0]=this._didViewChangeTick),me(this,e),e.didChange&&O(this,e.localBounds),e.localBounds}};function me(e,t){let n=e.children;for(let e=0;e<n.length;++e){let r=n[e],i=r.uid,a=(r._didViewChangeTick&65535)<<16|r._didContainerChangeTick&65535,o=t.index;(t.data[o]!==i||t.data[o+1]!==a)&&(t.data[o]=i,t.data[o+1]=a,t.didChange=!0),t.index+=2,r.children.length&&me(r,t)}return t.didChange}var he={_zIndex:0,sortableChildren:!1,sortDirty:!1},ge=class{constructor(){f(this,`instructions`,[]),f(this,`instructionSize`,0),f(this,`renderPipes`,void 0)}reset(){this.instructionSize=0}add(e){this.instructions[this.instructionSize++]=e}},_e=class{constructor(e){f(this,`worldTransform`,new _),f(this,`localTransform`,new _),f(this,`root`,null),f(this,`instructionSet`,new ge),f(this,`structureDidChange`,!0),f(this,`renderGroupParent`,null),f(this,`renderGroupChildren`,[]),f(this,`childrenToUpdate`,Object.create(null)),f(this,`childrenRenderablesToUpdate`,{list:[],index:0}),f(this,`_onRenderContainers`,[]),this.init(e)}init(e){this.root=e;let t=e.children;for(let e=0;e<t.length;++e)this.addChild(t[e])}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);let t=e.children;for(let e=0;e<t.length;++e)this.addChild(t[e])}removeChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}let t=e.children;for(let e=0;e<t.length;++e)this.removeChild(t[e])}removeChildren(e){for(let t=0;t<e.length;++t)this.removeChild(e[t])}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){let t=this.renderGroupChildren.indexOf(e);t>-1&&this.renderGroupChildren.splice(t,1),e.renderGroupParent=null}addOnRender(e){this._onRenderContainers.push(e)}removeOnRender(e){this._onRenderContainers.splice(this._onRenderContainers.indexOf(e),1)}runOnRender(e){for(let t=0;t<this._onRenderContainers.length;++t)this._onRenderContainers[t]._onRender(e)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}onChildUpdate(e){let t=this.childrenToUpdate[e.relativeRenderGroupDepth];t||(t=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),t.list[t.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}destroy(){this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this._onRenderContainers=null,this.renderGroupChildren=null,this.instructionSet=null}};function ve(e,t){t||(t=0);for(let n=t;n<e.length&&e[n];++n)e[n]=null}function ye(e,t,n={}){for(let r in t)!n[r]&&t[r]!==void 0&&(e[r]=t[r])}var be=1,xe=2,Se=4,Ce=8,k=new C(null),A=new C(null),j=new C(null,1,1),M=new C(null),N=class extends c{constructor(e={}){var t,n;super(),f(this,`uid`,D(`renderable`)),f(this,`label`,void 0),f(this,`destroyed`,!1),f(this,`renderGroup`,null),f(this,`parentRenderGroup`,null),f(this,`parent`,null),f(this,`eventMode`,`passive`),f(this,`hitArea`,null),f(this,`boundsArea`,void 0),f(this,`_position`,new C(this,0,0)),f(this,`includeInBuild`,!0),f(this,`renderPipeId`,void 0),f(this,`didChange`,!1),f(this,`didViewUpdate`,!1),f(this,`isSimple`,!0),f(this,`measurable`,!0),f(this,`relativeRenderGroupDepth`,0),f(this,`_didViewChangeTick`,0),f(this,`_didContainerChangeTick`,0),f(this,`_localTransformUpdateTick`,0),f(this,`_updateFlags`,15),f(this,`localDisplayStatus`,7),f(this,`globalDisplayStatus`,7),f(this,`children`,[]),f(this,`localTransform`,new _),f(this,`relativeGroupTransform`,new _),f(this,`groupTransform`,this.relativeGroupTransform),f(this,`_rotation`,0),f(this,`_worldTransform`,void 0),f(this,`_cx`,1),f(this,`_sx`,0),f(this,`_cy`,0),f(this,`_sy`,1),f(this,`_skew`,k),f(this,`_scale`,j),f(this,`_origin`,A),f(this,`_pivot`,M),f(this,`localAlpha`,1),f(this,`groupColor`,16777215),f(this,`localColor`,16777215),f(this,`groupAlpha`,1),f(this,`groupColorAlpha`,4294967295),ye(this,e,{children:!0,parent:!0,effects:!0}),(t=e.children)==null||t.forEach(e=>this.addChild(e)),(n=e.parent)==null||n.addChild(this),this.effects=[]}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){let t=+!!e;(this.localDisplayStatus&1)!==t&&(this._updateFlags|=4,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){let t=e?2:0;(this.localDisplayStatus&2)!==t&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=4,this.localDisplayStatus^=2,this._onUpdate(),this.emit(`visibleChanged`,e))}get isRenderGroup(){return!!this.renderGroup}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get zIndex(){return this._zIndex}set zIndex(e){e!==this._zIndex&&(this._zIndex=e,this.depthOfChildModified())}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(Te))}depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)}enableRenderGroup(){if(this.renderGroup)return;let e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=new _e(this),this.groupTransform=_.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;let e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}collectRenderables(e,t){this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderableSimple(e,t):this.renderGroup||this.collectRenderablesWithEffects(e,t))}collectRenderablesWithEffects(e,t){for(let n=0;n<this.effects.length;++n){let r=this.effects[n];e[r.pipe].push(r,t)}this.collectRenderableSimple(e,t);for(let n=0;n<this.effects.length;++n){let r=this.effects[n];e[r.pipe].pop(r,t)}}collectRenderableSimple(e,t){let n=this.children;for(let r=0;r<n.length;++r)n[r].collectRenderables(e,t)}setFromMatrix(e){e.decompose(this)}_updateSkew(){let e=this.rotation,t=this.skew;this._cx=Math.cos(e+t.y),this._sx=Math.sin(e+t.y),this._cy=-Math.sin(e-t.x),this._sy=Math.cos(e-t.x)}updateLocalTransform(){let e=this._didContainerChangeTick;if(this._localTransformUpdateTick===e)return;this._localTransformUpdateTick=e,this._updateSkew();let t=this.position,n=this.localTransform,r=this._scale.x,i=this._scale.y,a=-this._origin.x,o=-this._origin.y,s=this._pivot.x,c=this._pivot.y;n.a=this._cx*r,n.b=this._sx*r,n.c=this._cy*i,n.d=this._sy*i,n.tx=t.x-(s*n.a+c*n.c)+(a*n.a+o*n.c)-a,n.ty=t.y-(s*n.b+c*n.d)+(a*n.b+o*n.d)-o}get alpha(){return this.localAlpha}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=1,this._onUpdate())}get root(){let e=this.parent,t=this.parent;for(;e;)e.parent||(t=e),e=e.parent;return t}get worldTransform(){return this._worldTransform||(this._worldTransform=new _),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(e){this._position.x=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get y(){return this._position.y}set y(e){this._position.y=e}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*S}set angle(e){this.rotation=e*ee}get skew(){return this._skew===k&&(this._skew=new C(this,0,0)),this._skew}set skew(e){this._skew===k&&(this._skew=new C(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===j&&(this._scale=new C(this,1,1)),this._scale}set scale(e){this._scale===j&&(this._scale=new C(this,1,1)),this._scale.copyFrom(e)}get pivot(){return this._pivot===M&&(this._pivot=new C(this,0,0)),this._pivot}set pivot(e){this._pivot===M&&(this._pivot=new C(this,0,0)),this._pivot.copyFrom(e)}get origin(){return this._origin===A&&(this._origin=new C(this,0,0)),this._origin}set origin(e){this._origin===A&&(this._origin=new C(this,0,0)),typeof e==`number`?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){}addChild(...e){if(e.length>1){for(let t=0;t<e.length;++t)this.addChild(e[t]);return e[0]}let t=e[0],n=this.renderGroup||this.parentRenderGroup;return t.parent===this?(this.children.splice(this.children.indexOf(t),1),this.children.push(t),n&&(n.structureDidChange=!0),t):(this.sortableChildren&&(this.sortDirty=!0),t.parent&&t.parent.removeChild(t),this.children.push(t),this.sortableChildren&&(this.sortDirty=!0),t.parent=this,t.didChange=!0,t._updateFlags=7,n&&n.addChild(t),this._didViewChangeTick++,t._zIndex!==0&&t.depthOfChildModified(),t)}removeChild(...e){if(e.length>1){for(let t=0;t<e.length;++t)this.removeChild(e[t]);return e[0]}let t=e[0];if(!t)return t;let n=this.children.indexOf(t);return n>-1&&(this._didViewChangeTick++,this.children.splice(n,1),this.renderGroup?this.renderGroup.removeChild(t):this.parentRenderGroup&&this.parentRenderGroup.removeChild(t),t.parent=null),t}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}toGlobal(e,t,n){let r=this.getGlobalTransform(T.get(),n);return t=r.apply(e,t),T.return(r),t}toLocal(e,t,n,r){t&&(e=t.toGlobal(e,n,r));let i=this.getGlobalTransform(T.get(),r);return n=i.applyInverse(e,n),T.return(i),n}getGlobalTransform(e=new _,t=!1){if(t)return this.worldTransform.clone();this.updateLocalTransform();let n=we(this,T.get().identity());return e.appendFrom(this.localTransform,n),T.return(n),e}getGlobalPosition(e=new b,t=!1){return this.parent?this.parent.toGlobal(this._position,e,t):(e.x=this._position.x,e.y=this._position.y),e}destroy(e=!1){var t,n;if(this.destroyed)return;this.destroyed=!0;let r;if(this.children.length&&(r=this.removeChildren(0,this.children.length)),(t=this.parent)==null||t.removeChild(this),this.parent=null,this._maskEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,(typeof e==`boolean`?e:e!=null&&e.children)&&r)for(let t=0;t<r.length;++t)r[t].destroy(e);(n=this.renderGroup)==null||n.destroy(),this.renderGroup=null}};function we(e,t){let n=e.parent;if(n){we(n,t),n.updateLocalTransform();let e=_.append(t,n.localTransform);t.copyFrom(e)}return t}function Te(e,t){return e._zIndex-t._zIndex}oe(N,he,fe,pe,se);var P=class extends N{constructor(...e){super(...e),f(this,`_runtimeData`,Object.create(null)),f(this,`_resolution`,void 0),f(this,`_roundPixels`,0),f(this,`_bounds`,new w(0,1,0,0)),f(this,`_boundsDirty`,!0)}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;let e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}collectRenderableSimple(e,t){let n=e[this.renderPipeId];n&&n.addRenderable&&n.addRenderable(this,t),this.didViewUpdate=!1;let r=this.children;for(let n=0;n<r.length;++n)r[n].collectRenderables(e,t)}containsPoint(e){let t=this.bounds,{x:n,y:r}=e;return n>t.minX&&n<t.maxX&&r>t.minY&&r<t.maxY}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=+!!e}destroy(e=!1){for(let e in this._runtimeData)this._runtimeData[e].destroy();this._runtimeData=Object.create(null),this.onViewUpdate(),super.destroy(e),this._bounds=null}},Ee=class{constructor(){f(this,`points`,[]),f(this,`closePath`,void 0),f(this,`type`,`polygon`)}construction(){}get lastX(){return this.points[this.points.length-2]}get lastY(){return this.points[this.points.length-1]}strokeContains(e,t,n,r=.5){let i=n*n,a=i*(1-r),o=i-a,{points:s}=this,c=s.length-(this.closePath?0:2);for(let n=0;n<c;n+=2){let r=s[n],i=s[n+1],c=s[(n+2)%s.length],l=s[(n+3)%s.length];if(ie(e,t,r,i,c,l)<=(Math.sign((c-r)*(t-i)-(l-i)*(e-r))<0?o:a))return!0}return!1}contains(e,t){let n=!1,r=this.points.length/2;for(let i=0,a=r-1;i<r;a=i++){let r=this.points[i*2],o=this.points[i*2+1],s=this.points[a*2],c=this.points[a*2+1];o>t!=c>t&&e<(s-r)*((t-o)/(c-o))+r&&(n=!n)}return n}getBounds(e){e||(e=new y);let t=this.points,n=1/0,r=1/0,i=-1/0,a=-1/0;for(let e=0;e<t.length;e+=2){let o=t[e],s=t[e+1];n=o<n?o:n,r=s<r?s:r,i=o>i?o:i,a=s>a?s:a}return e.x=n,e.width=i-n,e.y=r,e.height=a-r,e}},De=8,F=1.1920929e-7,Oe=1;function ke(e,t,n,r,i,a,o,s,c,l){let u=(Oe-Math.min(.99,Math.max(0,l==null?.5:l)))/1;return u*=u,Ae(t,n,r,i,a,o,s,c,e,u),e}function Ae(e,t,n,r,i,a,o,s,c,l){I(e,t,n,r,i,a,o,s,c,l,0),c.push(o,s)}function I(e,t,n,r,i,a,o,s,c,l,u){if(u>De)return;let d=(e+n)/2,f=(t+r)/2,p=(n+i)/2,m=(r+a)/2,h=(i+o)/2,g=(a+s)/2,_=(d+p)/2,v=(f+m)/2,y=(p+h)/2,b=(m+g)/2,x=(_+y)/2,S=(v+b)/2;if(u>0){let u=o-e,d=s-t,f=Math.abs((n-o)*d-(r-s)*u),p=Math.abs((i-o)*d-(a-s)*u);if(f>F&&p>F){if((f+p)*(f+p)<=l*(u*u+d*d)){c.push(x,S);return}}else if(f>F){if(f*f<=l*(u*u+d*d)){c.push(x,S);return}}else if(p>F){if(p*p<=l*(u*u+d*d)){c.push(x,S);return}}else if(u=x-(e+o)/2,d=S-(t+s)/2,u*u+d*d<=l){c.push(x,S);return}}I(e,t,d,f,_,v,x,S,c,l,u+1),I(x,S,y,b,h,g,o,s,c,l,u+1)}var je=new y,Me=class{constructor(e){f(this,`_currentPoly`,void 0),f(this,`shapePrimitives`,[]),f(this,`_graphicsPath`,void 0),f(this,`_bounds`,new w),this._graphicsPath=e}_ensurePoly(e=!0){this._currentPoly||(this._currentPoly=new Ee,e&&this._currentPoly.points.push(0,0))}lineTo(e,t){this._ensurePoly();let n=this._currentPoly.points,r=n[n.length-2],i=n[n.length-1];return(r!==e||i!==t)&&n.push(e,t),this}rect(e,t,n,r){return this.drawShape(new y(e,t,n,r)),this}drawShape(e){return this.endPloy(),this.shapePrimitives.push({shape:e}),this}moveTo(e,t){return this.startPoly(e,t),this}bezierCurveTo(e,t,n,r,i,a,o){this._ensurePoly();let s=this._currentPoly.points;return ke(s,this._currentPoly.lastX,this._currentPoly.lastY,e,t,n,r,i,a,o),this}startPoly(e,t){return this._currentPoly&&this.endPloy(),this._currentPoly=new Ee,this._currentPoly.points.push(e,t),this}endPloy(e=!1){let t=this._currentPoly;return t&&t.points.length>2&&(t.closePath=e,this.shapePrimitives.push({shape:t})),this._currentPoly=null,this}closePath(){return this.endPloy(!0),this}buildPath(){let e=this._graphicsPath;for(let t=0;t<e.instructions.length;++t){let n=e.instructions[t];this[n.action](...n.data)}return this.endPloy(!1),this}get bounds(){let e=this._bounds;e.clear();let t=this.shapePrimitives;for(let n=0;n<t.length;++n){let r=t[n].shape.getBounds(je);e.addRect(r)}return e}},Ne=class e{constructor(){f(this,`instructions`,[]),f(this,`_dirty`,!0),f(this,`_shapePath`,void 0)}rect(e,t,n,r){return this.instructions.push({action:`rect`,data:[e,t,n,r]}),this._dirty=!0,this}lineTo(...e){return this.instructions.push({action:`lineTo`,data:e}),this._dirty=!0,this}bezierCurveTo(...e){return this.instructions.push({action:`bezierCurveTo`,data:e}),this}moveTo(...e){return this.instructions.push({action:`moveTo`,data:e}),this}closePath(){return this.instructions.push({action:`closePath`,data:[]}),this._dirty=!0,this}get shapePath(){return this._shapePath||(this._shapePath=new Me(this)),this._dirty&&(this._dirty=!1,this._shapePath.buildPath()),this._shapePath}get bounds(){return this.shapePath.bounds}getLastPoint(){let e=this.instructions.length-1,t=this.instructions[e];if(!t)return{x:0,y:0};switch(t.action){case`moveTo`:case`lineTo`:return{x:t.data[0],y:t.data[1]}}return{x:0,y:0}}clear(){this.instructions.length=0,this._dirty=!0}clone(){let t=new e;return t.instructions=this.instructions.slice(),t}};function Pe(e){let t=e.replace(`#`,``),n=t;t.length===4&&(n=t.split(``).map(e=>e+e).join(``));let r=n.substring(0,2),i=n.substring(2,4),a=n.substring(4,6),o=n.substring(6,8)||`ff`,s=Number.parseInt(r,16),c=Number.parseInt(i,16),l=Number.parseInt(a,16);return{r:s,g:c,b:l,a:+(Number.parseInt(o,16)/255).toFixed(2),rgb:`rgb(${s}, ${c}, ${l})`,hex:`#${r}${i}${a}`}}function L(e,t){return{...t,...e}}function Fe(e,t){if(e==null)return null;let n={...t,...e};if(n.color.startsWith(`#`)){let{a:e,hex:t}=Pe(n.color);n.alpha*=e,n.color=t}return n}function Ie(e,t){let n=1,r=e.shapePath.shapePrimitives;for(let e=0;e<r.length;e++){let i=r[e].shape;if(i.type!==`polygon`)continue;let a=i.points,o=a.length;if(o<6)continue;let s=i.closePath;for(let e=0;e<o;e+=2){if(!s&&(e===0||e===o-2))continue;let r=(e-2+o)%o,i=(e+2)%o,c=a[r],l=a[r+1],u=a[e],d=a[e+1],f=a[i],p=a[i+1],m=c-u,h=l-d,g=f-u,_=p-d,v=m*m+h*h,y=g*g+_*_;if(v<1e-12||y<1e-12)continue;let b=(m*g+h*_)/Math.sqrt(v*y);b<-1?b=-1:b>1&&(b=1);let x=Math.sqrt((1-b)*.5);if(x<1e-6)continue;let S=Math.min(1/x,t);S>n&&(n=S)}}return n}var R=class e{constructor(){f(this,`_strokeStyle`,{...e.defaultStrokeStyle}),f(this,`_fillStyle`,{...e.defaultFillStyle}),f(this,`_activePath`,new Ne),f(this,`_bounds`,new w),f(this,`_boundsDirty`,!0),f(this,`_tick`,0),f(this,`instructions`,[])}setStrokeStyle(t){this._strokeStyle=L(t,e.defaultStrokeStyle)}clear(){return this._activePath.clear(),this.instructions.length=0,this.onUpdate(),this}onUpdate(){this._boundsDirty=!0}moveTo(e,t){return++this._tick,this._activePath.moveTo(e,t),this}lineTo(e,t){return++this._tick,this._activePath.lineTo(e,t),this}bezierCurveTo(e,t,n,r,i,a,o){return++this._tick,this._activePath.bezierCurveTo(e,t,n,r,i,a,o),this}rect(e,t,n,r){return++this._tick,this._activePath.rect(e,t,n,r),this}beginPath(){return this._activePath=new Ne,this}closePath(){return++this._tick,this._activePath.closePath(),this}get fillStyle(){return this._fillStyle}set fillStyle(t){this._fillStyle=Fe(t,e.defaultFillStyle)}get strokeStyle(){return this._strokeStyle}set strokeStyle(t){this._strokeStyle=L(t,e.defaultStrokeStyle)}fill(t){let n=this.instructions[this.instructions.length-1],r;return r=this._tick===0&&(n==null?void 0:n.action)===`stroke`?n.data.path:this._activePath.clone(),r?(t!=null&&(this._fillStyle=Fe(t,e.defaultFillStyle)),this.instructions.push({action:`fill`,data:{style:this.fillStyle,path:r}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}stroke(t){let n,r=this.instructions[this.instructions.length-1];return n=this._tick===0&&(r==null?void 0:r.action)===`fill`?r.data.path:this._activePath.clone(),n?(t!=null&&(this._strokeStyle=L(t,e.defaultStrokeStyle)),this.instructions.push({action:`stroke`,data:{style:this.strokeStyle,path:n}}),this.onUpdate(),this._initNextPathLocation(),this._tick=0,this):this}_initNextPathLocation(){let{x:e,y:t}=this._activePath.getLastPoint();this._activePath.clear(),this._activePath.moveTo(e,t)}get bounds(){if(!this._boundsDirty)return this._bounds;this._boundsDirty=!1;let e=this._bounds;e.clear();for(let t=0;t<this.instructions.length;++t){let n=this.instructions[t],r=n.action;if(r===`fill`){let t=n.data;e.addBounds(t.path.bounds)}else if(r===`stroke`){let t=n.data,r=t.style.alignment,i=t.style.width*(1-r);t.style.join===`miter`&&(i*=Ie(t.path,t.style.miterLimit));let a=t.path.bounds;e.addFrame(a.minX-i,a.minY-i,a.maxX+i,a.maxY+i)}}return e.isValid||e.set(0,0,0,0),e}containsPoint(e){if(!this.bounds.containsPoint(e.x,e.y))return!1;let t=this.instructions,n=!1;for(let r=0;r<t.length;++r){let i=t[r],a=i.data,o=a.path;if(!i.action||!o)continue;let s=a.style,c=o.shapePath.shapePrimitives;for(let t=0;t<c.length;++t){let t=c[r].shape;if(!s||!t)continue;let a=e;if(i.action===`fill`)n=t.contains(a.x,a.y);else{let e=s;n=t.strokeContains(a.x,a.y,e.width,e.alignment)}if(n)return!0}}return n}clone(){let t=new e;return t.instructions=this.instructions.slice(),t._activePath=this._activePath.clone(),t._bounds=this._bounds.clone(),t._strokeStyle={...this._strokeStyle},t}};f(R,`defaultStrokeStyle`,{width:1,color:`#ffffff`,alignment:.5,miterLimit:10,cap:`butt`,join:`miter`,pixelLine:!1,alpha:1}),f(R,`defaultFillStyle`,{color:`#ffffff`,alpha:1});var Le=class extends P{constructor(e){e instanceof R&&(e={context:e});let{context:t,...n}=e||{};super({label:`Graphics`,...n}),f(this,`renderPipeId`,`graphics`),f(this,`_context`,void 0),t?this.context=t:this.context=new R,this.didViewUpdate=!0}get context(){return this._context}set context(e){e!==this._context&&(this._context=e,this.onViewUpdate())}get fillStyle(){return this._context.fillStyle}set fillStyle(e){this._context.fillStyle=e}get strokeStyle(){return this._context.strokeStyle}set strokeStyle(e){this._context.strokeStyle=e}setStrokeStyle(...e){return this._callContextMethod(`setStrokeStyle`,e)}rect(...e){return this._callContextMethod(`rect`,e)}bezierCurveTo(...e){return this._callContextMethod(`bezierCurveTo`,e)}lineTo(...e){return this._callContextMethod(`lineTo`,e)}moveTo(...e){return this._callContextMethod(`moveTo`,e)}stroke(...e){return this._callContextMethod(`stroke`,e)}beginPath(){return this._callContextMethod(`beginPath`,[])}closePath(){return this._callContextMethod(`closePath`,[])}fill(...e){return this._callContextMethod(`fill`,e)}_callContextMethod(e,t){return this.context[e](...t),this}updateBounds(){}get bounds(){return this._context.bounds}clear(){return this._callContextMethod(`clear`,[])}},z=class{constructor(e){f(this,`_renderer`,void 0),this._renderer=e}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}validateRenderable(e){return!1}execute(e){let t=this._renderer,n=t.canvasContext,r=n.activeConext,i=t.roundPixels,a=(e.groupColorAlpha>>>24&255)/255;if(!(a<=0)){r.save(),n.setContextTransform(e.relativeGroupTransform,i);for(let t=0;t<e.context.instructions.length;++t){let n=e.context.instructions[t],i=n.data.style,o=i.alpha*a;if(o<=0)continue;r.globalAlpha=o;let s=n.action===`stroke`;if(s){let e=i.color;r.lineWidth=i.width,r.lineCap=i.cap,r.lineJoin=i.join,r.miterLimit=i.miterLimit,r.strokeStyle=e}else r.fillStyle=n.data.style.color;let c=n.data.path.shapePath.shapePrimitives;for(let e=0;e<c.length;++e){let t=c[e];t.shape&&(r.beginPath(),B(r,t.shape),s?r.stroke():r.fill())}}r.restore()}}destroy(){this._renderer=null}};f(z,`desc`,{name:`graphics`});function B(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`polygon`:{let n=t,r=n.points;if(!r.length)return;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}var Re=class{constructor(e){f(this,`_renderer`,void 0),f(this,`_canvasMaskStack`,[]),this._renderer=e}push(e,t){t.add({renderPipeId:`stencilMask`,action:`pushMaskBegin`,mask:e})}pop(e,t){this._renderer.renderPipes.batch.break(t),t.add({renderPipeId:`stencilMask`,action:`popMaskEnd`,mask:e})}execute(e){if(e.action!==`pushMaskBegin`&&e.action!==`popMaskEnd`)return;let t=this._renderer.canvasContext,n=t.activeConext;if(e.action===`popMaskEnd`){this._canvasMaskStack.pop()&&n.restore();return}let r=e.mask.mask,i=r.context.instructions,a=r._roundPixels===1;n.save(),t.setContextTransform(r.relativeGroupTransform,a),n.beginPath();for(let e=0;e<i.length;++e){let t=i[e],r=t.action;if(r!==`fill`&&r!==`stroke`)return;let a=t.data.path.shapePath.shapePrimitives;for(let e=0;e<a.length;++e){let t=a[e].shape;B(n,t)}}n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null}};f(Re,`desc`,{name:`stencilMask`});var ze=class{constructor(e){f(this,`_renderer`,void 0),this._renderer=e}addRenderable(e,t){let n=this._getRuntimeSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n,t)}_updateBatchableSprite(e,t){t.texture=e._texture,t.bounds=e.bounds}validateRenderable(e){return this._getRuntimeSprite(e).texture._source.uid!==e._texture._source.uid}_getRuntimeSprite(e){return e._runtimeData[this._renderer.uid]||this._initCacheSprite(e)}_initCacheSprite(e){let t={renderable:e,texture:e.texture,transform:e.relativeGroupTransform,bounds:e.bounds,roundPixels:this._renderer._roundPixels|e._roundPixels,destroy(){this.renderable=null,this.texture=null,this.transform=null,this.bounds=null}};return e._runtimeData[this._renderer.uid]=t,t}destroy(){this._renderer=null}};f(ze,`desc`,{name:`sprite`});var V=class{constructor(e){f(this,`_renderer`,void 0),this._renderer=e}addRenderable(e,t){let n=this._getRuntimeText(e);if(e._didTextUpdate){let t=e._autoResolution?this._renderer.resolution:e.resolution;(n.currentKey!==e.styleKey||e._resolution!==t)&&this._updateRuntimeText(e),e._didTextUpdate=!1,ae(n.bounds,e._anchor,n.texture)}this._renderer.renderPipes.batch.addToBatch(n,t)}validateRenderable(e){let t=this._getRuntimeText(e),n=e.styleKey;return t.currentKey===n?e._didTextUpdate:!0}initCacheText(e){let t={currentKey:`--`,transform:e.relativeGroupTransform,bounds:e.bounds,roundPixels:this._renderer._roundPixels|e._roundPixels,renderable:e,texture:null,destroy(){this.renderable=null,this.texture=null,this.bounds=null}};return e._runtimeData[this._renderer.uid]=t,t}_getRuntimeText(e){return e._runtimeData[this._renderer.uid]||this.initCacheText(e)}_updateRuntimeText(e){let t=this._getRuntimeText(e);t.texture,e._resolution=e._autoResolution?this._renderer.resolution:e.resolution,t.texture=this._renderer.text.getManagedTexture(e),t.currentKey=e.styleKey}destroy(){this._renderer=null}};f(V,`desc`,{name:`text`});var Be=new class{constructor(){f(this,`_canvasPool`,void 0),this._canvasPool=Object.create(null)}getOptimalCanvasAndContext(e,t,n=1){let r=x(e*n-1e-6),i=x(t*n-1e-6),a=r<<17+i<<1;this._canvasPool[a]||(this._canvasPool[a]=[]);let o=this._canvasPool[a].pop();if(o)return o;{let e=document.createElement(`canvas`);return e.width=r,e.height=i,{canvas:e,context:e.getContext(`2d`)}}}},H=class e{constructor(t){f(this,`uid`,D(`textStyle`)),f(this,`_cachedFontString`,void 0),f(this,`_fontSize`,void 0),f(this,`_fontFamily`,void 0),f(this,`_fontStyle`,void 0),f(this,`_lineHeight`,void 0),f(this,`_leading`,void 0),f(this,`_fontVariant`,void 0),f(this,`_fontWeight`,void 0),f(this,`_letterSpacing`,void 0),f(this,`_textBaseline`,void 0),f(this,`_align`,void 0),f(this,`_wordWrap`,void 0),f(this,`_fill`,void 0),f(this,`_tick`,0);let n={...e.defaultStyle,...t};for(let e in n){let t=e;this[t]=n[e]}}get styleKey(){return`${this.uid}-${this._tick}`}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize!==e&&(this._fontSize=e,this.update())}get fill(){return this._fill}set fill(e){this._fill!==e&&(this._fill=e,this.update())}get align(){return this._align}set align(e){this._align!==e&&(this._align=e,this.update())}get wordWrap(){return this._wordWrap}set wordWrap(e){this._wordWrap!==e&&(this._wordWrap=e,this.update())}get fontFamily(){return this._fontFamily}set fontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.update())}get leading(){return this._leading}set leading(e){this._leading!==e&&(this._leading=e,this.update())}get fontStyle(){return this._fontStyle}set fontStyle(e){this._fontStyle!==e&&(this._fontStyle=e.toLowerCase(),this.update())}get textBaseline(){return this._textBaseline}set textBaseline(e){this._textBaseline=e,this.update()}get lineHeight(){return this._lineHeight}set lineHeight(e){this._lineHeight!==e&&(this._lineHeight=e,this.update())}get letterSpacing(){return this._letterSpacing}set letterSpacing(e){this._letterSpacing!==e&&(this._letterSpacing=e,this.update())}get fontVariant(){return this._fontVariant}set fontVariant(e){this._fontVariant!==e&&(this._fontVariant=e,this.update())}get fontWeight(){return this._fontWeight}set fontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.update())}get _fontString(){return this._cachedFontString===null&&(this._cachedFontString=He(this)),this._cachedFontString}update(){this._tick++,this._cachedFontString=null}destroy(e=!1){this._fill=null}};f(H,`defaultStyle`,{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});var Ve=[`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`];function He(e){let t=typeof e.fontSize==`number`?`${e.fontSize}px`:e.fontSize,n=e.fontFamily;Array.isArray(e.fontFamily)||(n=e.fontFamily.split(`,`));for(let e=n.length-1;e>=0;e--){let t=n[e].trim();!/(["'])[^'"]+\1/.test(t)&&!Ve.includes(t)&&(t=`"${t}"`),n[e]=t}return`${e.fontStyle} ${e.fontVariant} ${e.fontWeight} ${t} ${n.join(`,`)}`}var Ue=/(?:\r\n|\r|\n)/,U=class e{constructor(e,t,n,r,i,a,o,s,c){f(this,`text`,void 0),f(this,`style`,void 0),f(this,`width`,void 0),f(this,`height`,void 0),f(this,`lines`,void 0),f(this,`lineWidths`,void 0),f(this,`lineHeight`,void 0),f(this,`maxLineWidth`,void 0),f(this,`fontProperties`,void 0),this.text=e,this.style=t,this.width=n,this.height=r,this.lines=i,this.lineWidths=a,this.lineHeight=o,this.maxLineWidth=s,this.fontProperties=c}static get canvas(){if(!e._canvas){let t;try{let n=new OffscreenCanvas(0,0);if(n.getContext(`2d`,{willReadFrequently:!0}).measureText)return e._canvas=n,n;t=W(10,10)}catch(e){t=W(10,10)}e._canvas=t}return e._canvas}static get context(){return e._context||(e._context=e.canvas.getContext(`2d`,{willReadFrequently:!0})),e._context}static measureText(t,n){let r=`${t}-${n.styleKey}`;if(e._measurementCache.has(r))return e._measurementCache.get(r);let i=n._fontString,a=e.measureFont(i);a.fontSize===0&&(a.fontSize=n.fontSize,a.ascent=n.fontSize,a.descent=0);let o=e.context;o.font=i;let s=t.split(Ue),c=Array.from({length:s.length}),l=0;for(let t=0;t<s.length;++t){let r=e._measureText(s[t],n.letterSpacing);c[t]=r,l=Math.max(l,r)}let u=n.lineHeight||a.fontSize,d=new e(t,n,l,Math.max(u,a.fontSize+(s.length-1)*(u+n.leading)),s,c,u,l,a);return e._measurementCache.set(r,d),d}static _measureText(t,n){var r,i;let a=e.context;a.letterSpacing=`0px`,a.textLetterSpacing=n;let o=a.measureText(t),s=o.width,c=0;s>0&&(c=(e.graphemeSegmenter(t).length-1)*n,s+=c);let l=-((r=o.actualBoundingBoxLeft)==null?0:r),u=((i=o.actualBoundingBoxRight)==null?0:i)-l;return o.width>0&&(u+=c),Math.max(s,u)}static measureFont(t){var n,r;if(e._fonts[t])return e._fonts[t];let i=e.context;i.font=t;let a=i.measureText(e.METRICS_STRING+e.BASELINE_SYMBOL),o=(n=a.actualBoundingBoxAscent)==null?0:n,s=(r=a.actualBoundingBoxDescent)==null?0:r,c={ascent:o,descent:s,fontSize:o+s};return e._fonts[t]=c,c}};f(U,`METRICS_STRING`,`|ÉqÅ`),f(U,`BASELINE_SYMBOL`,`M`),f(U,`_canvas`,void 0),f(U,`_context`,void 0),f(U,`_measurementCache`,new Map),f(U,`_fonts`,{}),f(U,`graphemeSegmenter`,(()=>{var e;if(typeof((e=Intl)==null?void 0:e.Segmenter)==`function`){let e=new Intl.Segmenter;return t=>{let n=e.segment(t),r=[],i=0;for(let e of n)r[i++]=e.segment;return r}}return e=>[...e]})());function W(e,t){let n=document.createElement(`canvas`);return n.width=e,n.height=t,n}function We(e){let{text:t,style:n,resolution:r=1,padding:i=0}=e,a=U.measureText(t,n),o=Math.ceil(Math.ceil(Math.max(1,a.width)+i*2)*r),s=Math.ceil(Math.ceil(Math.max(1,a.height)+i*2)*r),c=Be.getOptimalCanvasAndContext(o,s);return Ge(n,r,i,c,a),{canvasAndContext:c,frame:new y(0,0,o,s)}}function Ge(e,t,n,r,i){let{context:a}=r,o=He(e),{lines:s,lineHeight:c,lineWidths:l,maxLineWidth:u,fontProperties:d}=i;a.resetTransform(),a.scale(t,t),a.textBaseline=e.textBaseline,a.font=o;let f=Math.min(0,(c-d.fontSize)/2);a.fillStyle=e.fill;for(let t=0;t<s.length;++t){let i=Ke(l[t],u,e.align),a=t*c+d.ascent+f,o=0;if(e.align===`justify`&&e.wordWrap&&t<s.length-1){let e=qe(s[t]);e>0&&(o=(u-l[t])/e)}Je(s[t],e,r,i+n,a+n,!1,o)}}function Ke(e,t,n){return n===`right`?t-e:n===`center`?(t-e)/2:0}function qe(e){let t=0;for(let n=0;n<e.length;n++)e.charCodeAt(n)===32&&t++;return t}function Je(e,t,n,r,i,a=!1,o=0){let s=n.context,c=t.letterSpacing;if(c===0&&o===0){s.fillText(e,r,i);return}if(o!==0&&c===0){let t=e.split(` `),n=r,a=s.measureText(` `).width;for(let e=0;e<t.length;++e)s.fillText(t[e],n,i),n+=s.measureText(t[e]).width+a+o;return}let l=r,u=U.graphemeSegmenter(e),d=s.measureText(e).width,f=0;for(let e=0;e<u.length;++e){let t=u[e];s.fillText(t,l,i);let n=``;for(let t=e+1;t<u.length;++t)n+=u[t];f=s.measureText(n).width,l+=d-f+c,t===``&&(l+=o),d=f}}var G=class e extends c{constructor(t){super(),f(this,`uid`,D(`textureSource`)),f(this,`label`,void 0),f(this,`_resolution`,1),f(this,`pixelWidth`,1),f(this,`pixelHeight`,1),f(this,`width`,1),f(this,`height`,1),f(this,`resource`,void 0),f(this,`destroyed`,void 0);let n={...e.defaultOptions,...t};this.label=t.label,this.resource=n.resource,this._resolution=n.resolution,n.width?this.pixelWidth=t.width*this._resolution:this.pixelWidth=this.resource&&this.resourceWidth||1,n.height?this.pixelHeight=t.height*this._resolution:this.pixelHeight=this.resource&&this.resourceHeight||1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.destroyed=!1}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}get resourceWidth(){let e=this.resource;return e.naturalWidth||e.width}get resourceHeight(){let e=this.resource;return e.naturalHeight||e.height}resize(e,t,n){n||(n=this._resolution),e||(e=this.width),t||(t=this.height);let r=Math.round(e*n),i=Math.round(t*n);return this.width=r/n,this.height=i/n,this._resolution=n,this.pixelWidth===r&&this.pixelHeight===i?!1:(this.pixelWidth=r,this.pixelHeight=i,this.emit(`resize`,this),!0)}destroy(){this.destroyed=!0,this.resource=null,this.emit(`destroy`,this),this.removeAllListeners()}};f(G,`defaultOptions`,{resolution:1});var Ye=class extends G{constructor(e){e.resource||(e.resource=W()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),f(this,`autoDensity`,void 0),this.autoDensity=e.autoDensity,this.resizeCanvas()}resizeCanvas(){this.autoDensity&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,t=this.height,n=this._resolution){let r=super.resize(e,t,n);return r&&this.resizeCanvas(),r}},K=class extends c{constructor({source:e,label:t,frame:n,orig:r,rotate:i}={}){if(super(),f(this,`label`,void 0),f(this,`_source`,void 0),f(this,`orig`,void 0),f(this,`frame`,new y),f(this,`rotate`,void 0),f(this,`destroyed`,void 0),f(this,`noFrame`,!1),this.label=t,this.source=e,n)this.frame.copyFrom(n);else{this.noFrame=!0;let{width:t,height:n}=e;this.frame.width=t,this.frame.height=n}this.orig=r||this.frame,this.rotate=i==null?0:i,this.destroyed=!1}get source(){return this._source}set source(e){this._source&&this._source.off(`resize`,this.update,this),this._source=e,e.on(`resize`,this.update,this)}get width(){return this.orig.width}get height(){return this.orig.height}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height)}destroy(e=!1){this._source&&(this._source.off(`resize`,this.update,this),e&&(this._source.destroy(),this._source=null)),this.destroyed=!0,this.emit(`destroy`,this),this.removeAllListeners()}};f(K,`EMPTY`,void 0),K.EMPTY=new K({label:`EMPTY`,source:new G({label:`EMPTY`})});var Xe=class{constructor(e){f(this,`renderer`,void 0),f(this,`_activeTexture`,{}),this.renderer=e}getManagedTexture(e){e._resolution=e._autoResolution?this.renderer.resolution:e.resolution;let t=e.styleKey;if(this._activeTexture[t])return this._activeTexture[t];let n=this.getTexture({text:e.text,style:e.style,resolution:e._resolution});return this._activeTexture[t]=n,n}getTexture(e){let{text:t,style:n}=e,r=e.resolution||this.renderer.resolution,{frame:i,canvasAndContext:a}=We({text:t,style:n,resolution:r}),o=a.canvas,s=new K({source:new G({resource:o,resolution:r})});return s.frame.width=i.width/r,s.frame.height=i.height/r,s}};f(Xe,`desc`,{name:`text`});var Ze=class{constructor(e){f(this,`_renderer`,void 0),f(this,`rootContext`,void 0),f(this,`activeConext`,void 0),f(this,`activeResolution`,1),f(this,`globalTransform`,new _),this._renderer=e}init(){this.activeConext=this._renderer.canvas.getContext(`2d`),this.rootContext=this.activeConext,this.activeResolution=this._renderer.resolution}setContextTransform(e,t,n){let r=this.activeResolution,i=_.append(this.globalTransform,e);n||(n=this.activeResolution),t?this.activeConext.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*r|0,i.ty*r|0):this.activeConext.setTransform(i.a*n,i.b*n,i.c*n,i.d*n,i.tx*r,i.ty*r)}};f(Ze,`desc`,{name:`canvasContext`});var Qe=class e extends K{static create(t){return new e({source:new G(t)})}},$e=class extends P{constructor(e=K.EMPTY){e instanceof K&&(e={texture:e});let{texture:t=K.EMPTY,width:n,height:r,...i}=e;super({label:`Sprite`,...i}),f(this,`_texture`,void 0),f(this,`anchor`,void 0),f(this,`renderPipeId`,`sprite`),f(this,`_width`,void 0),f(this,`_height`,void 0),this.texture=t,this.anchor=new b,n!=null&&(this.width=n),r!=null&&(this.height=r)}set texture(e){e||(e=K.EMPTY),this._texture!==e&&(this._texture=e,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 height(){return Math.abs(this.scale.y)*this.texture.orig.height}set height(e){let t=this.texture.orig.height,n=Math.sign(this.scale.y)||1;t===0?this.scale.y=n:this.scale.y=e/t*n,this._height=e}get width(){return Math.abs(this.scale.x)*this.texture.orig.width}set width(e){let t=this.texture.orig.width,n=Math.sign(this.scale.x)||1;t===0?this.scale.x=n:this.scale.x=e/t*n,this._width=e}updateBounds(){let e=this._bounds,{width:t,height:n}=this.texture.orig;e.minX=-this.anchor.x*t,e.maxX=e.minX+t,e.minY=-this.anchor.y*n,e.maxY=e.minY+n}},et=class extends P{constructor(e){var t;let{text:n,resolution:r,style:i,width:a,height:o,...s}=e;super(s),f(this,`renderPipeId`,`text`),f(this,`_anchor`,void 0),f(this,`_didTextUpdate`,!0),f(this,`_resolution`,null),f(this,`_autoResolution`,!0),f(this,`_text`,void 0),f(this,`_style`,void 0),this._anchor=new C({_onUpdate:()=>{this.onViewUpdate()}},0,0),this.text=(t=e.text)==null?``:t,this.style=i,this.resolution=r==null?null:r,a!=null&&(this.width=a),o!=null&&(this.height=o)}set resolution(e){this._autoResolution=e===null,this._resolution=e,this.onViewUpdate()}get resolution(){return this._resolution}get anchor(){return this._anchor}set anchor(e){this._anchor.copyFrom(e)}get text(){return this._text}set text(e){let t=String(e);this._text!==t&&(this._text=t,this.onViewUpdate())}get style(){return this._style}set style(e){e||(e={}),e instanceof H?this._style=e:this._style=new H(e),this.onViewUpdate()}get width(){return Math.abs(this.scale.x)*this.bounds.width}set width(e){this._setWidth(e,this.bounds.width)}get height(){return Math.abs(this.scale.y)*this.bounds.height}set height(e){this._setHeight(e,this.bounds.height)}onViewUpdate(){this.didViewUpdate||(this._didTextUpdate=!0),super.onViewUpdate()}updateBounds(){let e=this._bounds,t=this._anchor,n=U.measureText(this._text,this._style),r=n.width,i=n.height;e.minX=-t._x*r,e.minY=-t._y*i,e.maxX=e.minX+r,e.maxY=e.minY+i}get styleKey(){return`${this._text}:${this._style.styleKey}:${this._resolution}`}destroy(e=!1){super.destroy(e),this._bounds=null,this._anchor=null,(typeof e==`boolean`?e:e!=null&&e.style)&&this._style.destroy(e),this._style=null,this._text=null}},tt=class{constructor(e){f(this,`_renderer`,void 0),this._renderer=e}texture(e){return this._generateTexture(e)}_generateTexture(e){e instanceof N&&(e={target:e});let t=e.resolution||this._renderer.resolution,n=e.target,r=new w,i=e.frame||O(n,r).rectangle;i.width=Math.max(i.width,1/t)|0,i.height=Math.max(i.height,1/t)|0;let a=Qe.create({width:i.width,height:i.height,resolution:t}),o=T.get();return o.tx=-i.x,o.ty=-i.y,this._renderer.render({clearColor:`transparent`,container:n,transform:o,target:a}),T.return(o),a}};f(tt,`desc`,{name:`extract`});var q=class e{constructor(){f(this,`canvas`,void 0),f(this,`screen`,void 0),f(this,`texture`,void 0)}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(t){t={...e.defaultOptions,...t},this.screen=new y(0,0,t.width,t.height),this.canvas=W(),this.texture=new K({source:new Ye({resource:this.canvas,...t})}),this.resolution=t.resolution}resize(e,t,n){this.texture.source.resize(e,t,n),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}};f(q,`desc`,{name:`view`}),f(q,`defaultOptions`,{width:800,height:600,autoDensity:!1});var J=class{constructor(e){f(this,`system`,void 0),f(this,`target`,void 0),f(this,`currentTarget`,void 0),f(this,`nativeEvent`,void 0),f(this,`type`,void 0),f(this,`global`,new b),f(this,`screen`,new b),f(this,`path`,void 0),this.system=e}getLocalPosition(e,t){return e.worldTransform.applyInverse(t||this.global)}composedPath(){return(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.system.propagationPath(this.target):[]),this.path}},nt=2048,rt=class{constructor(e){f(this,`renderer`,void 0),f(this,`domElement`,null),f(this,`rootTarget`,null),f(this,`resolution`,1),f(this,`eventPool`,new Map),f(this,`_allInteractiveElements`,[]),f(this,`_hitElements`,[]),f(this,`_rootPointerEvent`,void 0),f(this,`_isPointerMoveEvent`,!1),f(this,`mappingState`,{trackingData:{}}),this.renderer=e,this.resolution=e.resolution,this._rootPointerEvent=new J(null),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.init()}get pointer(){return this._rootPointerEvent}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTargets:null}),this.mappingState.trackingData[e]}init(){let e=this.renderer.canvas;this.setTargetElement(e)}setTargetElement(e){this._removeEvents(),this.domElement=e,this._addEvents()}dispatchEvent(e,t){if(!e.target)return;let n=e.composedPath();for(let r=0;r<n.length-1;++r)e.currentTarget=n[r],this._notifyTarget(e,t);e.currentTarget=e.target,this._notifyTarget(e,t)}_notifyTarget(e,t){t!=null||(t=e.type);let n=e.currentTarget._events[t];if(n)if(`fn`in n)n.once&&e.target.removeListener(t,n.fn,void 0,!0),n.fn.call(n.context,e);else for(let r=0;r<n.length;++r){let i=n[r];i.once&&e.target.removeListener(t,i.fn,void 0,!0),i.fn.call(i.context,e)}}propagationPath(e){let t=[e];for(let n=0;n<nt&&(e!==this.rootTarget||e.parent);++n){if(!e.parent)throw Error(`Cannot find propagation path to disconnected target`);t.push(e.parent),e=e.parent}return t.reverse(),t}_removeEvents(){let e=this.domElement;e&&(globalThis.document.removeEventListener(`pointermove`,this._onPointerMove,!0),e.removeEventListener(`pointerdown`,this._onPointerDown,!0),e.removeEventListener(`pointerleave`,this._onPointerOverOut,!0),e.removeEventListener(`pointerover`,this._onPointerOverOut,!0),globalThis.document.removeEventListener(`pointerup`,this._onPointerUp,!0))}_addEvents(){let e=this.domElement;if(!e)return;let t=e.style;t&&(t.touchAction=`none`),globalThis.document.addEventListener(`pointermove`,this._onPointerMove,!0),e.addEventListener(`pointerdown`,this._onPointerDown,!0),e.addEventListener(`pointerleave`,this._onPointerOverOut,!0),e.addEventListener(`pointerover`,this._onPointerOverOut,!0),globalThis.document.addEventListener(`pointerup`,this._onPointerUp,!0)}_onPointerMove(e){var t;if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;this._isPointerMoveEvent=!0,this._allInteractiveElements.length=0,this._hitElements.length=0;let n=this._bootstrapEvent(this._rootPointerEvent,e),r=this.createPointEvent(n);this._isPointerMoveEvent=!1;let i=this.trackingData(e.pointerId),a=it(i.overTargets);if(((t=i.overTargets)==null?void 0:t.length)>0&&a!==r.target){let e=this.createPointEvent(n,`pointerout`,a);this.dispatchEvent(e,`pointerout`);let t=r.composedPath();if(!t.includes(a)){let e=this.createPointEvent(n,`pointerleave`,a);for(;e.target&&!t.includes(e.target);)e.currentTarget=e.target,this._notifyTarget(e),e.target=e.target.parent}}if(a!==r.target){let e=`pointerover`,t=this.clonePointEvent(r,e);this.dispatchEvent(t,e);let n=a==null?void 0:a.parent;for(;n&&n!==this.rootTarget.parent&&n!==r.target;)n=n.parent;if(!n||n===this.rootTarget.parent){let e=this.clonePointEvent(r,`pointerenter`);for(;e.target&&e.target!==a&&e.target!==this.rootTarget.parent;)e.currentTarget=e.target,this._notifyTarget(e),e.target=e.target.parent}this.freeEvent(t)}this.dispatchEvent(r,`pointermove`);let o=this._allInteractiveElements;for(let e=o.length-1;e>=0;--e)r.currentTarget=o[e],this._notifyTarget(r,`globalpointermove`);this._allInteractiveElements.length=0,this._hitElements.length=0,i.overTargets=r.composedPath(),this.freeEvent(r)}_onPointerDown(e){if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;let t=this._bootstrapEvent(this._rootPointerEvent,e),n=this.createPointEvent(t);this.dispatchEvent(n,`pointerdown`);let r=this.trackingData(e.pointerId);r.pressTargetsByButton[e.button]=n.composedPath(),this.freeEvent(n)}_onPointerOverOut(e){if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;let t=this._bootstrapEvent(this._rootPointerEvent,e),n=this.createPointEvent(t);this.dispatchEvent(n,`pointerout`),this.freeEvent(n)}_onPointerUp(e){if(this.rootTarget=this.renderer.renderedObject,!this.rootTarget)return;let t=e.target;e.composedPath&&e.composedPath().length>1&&(t=e.composedPath()[0]);let n=this._bootstrapEvent(this._rootPointerEvent,e),r=t===this.domElement?``:`outside`,i=this.createPointEvent(n);this.dispatchEvent(i,`pointerup${r}`),this.freeEvent(i)}_isInteractive(e){return e===`static`}_bootstrapEvent(e,t){return e.nativeEvent=t,this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),t.type===`pointerleave`?e.type=`pointerout`:e.type=t.type,e}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);let t=this.eventPool.get(e).pop()||new e(this);return t.currentTarget=null,t.path=null,t.target=null,t}freeEvent(e){let t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}createPointEvent(e,t,n){var r;let i=this.allocateEvent(J);return i.global.copyFrom(e.global),i.screen.copyFrom(e.screen),i.nativeEvent=e.nativeEvent,i.target=(r=n==null?this.hitTest(i.global.x,i.global.y):n)==null?this._hitElements[0]:r,t&&(i.type=t),i}clonePointEvent(e,t){let n=this.allocateEvent(J);return n.nativeEvent=e.nativeEvent,n.global=e.global,n.type=t==null?e.type:t,n.path=e.composedPath().slice(),n.target=e.target,n}mapPositionToPoint(e,t,n){let r=this.domElement,i=r.isConnected?r.getBoundingClientRect():{x:0,y:0,width:r.width,height:r.height,left:0,top:0},a=1/this.resolution;return e.x=(t-i.left)*(r.width/i.width)*a,e.y=(n-i.top)*(r.height/i.height)*a,e}hitTest(e,t){let n=this._isPointerMoveEvent,r=this[n?`hitTestMoveRecursive`:`hitTestRecursive`](this.rootTarget,this.rootTarget.eventMode,new b(e,t));return r&&r[0]}_interactivePrune(e){return!e||!e.visible||!e.renderable||!e.measurable||e.eventMode===`none`}hitTestMoveRecursive(e,t,n){let r=!1;if(this._interactivePrune(e))return;let i=e.children;if(i&&i.length>0)for(let a=i.length-1;a>=0;--a){let o=i[a],s=this.hitTestMoveRecursive(o,this._isInteractive(t)?t:o.eventMode,n);if(s){if(s.length>0&&!s[s.length-1].parent)continue;let t=this._isInteractive(e.eventMode);(s.length>0||t)&&(t&&this._allInteractiveElements.push(e),s.push(e)),this._hitElements.length===0&&(this._hitElements=s),r=!0}}let a=this._isInteractive(t),o=this._isInteractive(e.eventMode);if(o&&this._allInteractiveElements.push(e),!(this._hitElements.length>0)){if(r)return this._hitElements;if(a&&this.hitTestFn(e,n))return o?[e]:[]}}hitTestRecursive(e,t,n){if(this._interactivePrune(e))return;let r=e.children;for(let i=r.length-1;i>=0;i--){let a=r[i],o=this.hitTestRecursive(a,this._isInteractive(t)?t:a.eventMode,n);if(o){let t=this._isInteractive(e.eventMode);return(o.length>0||t)&&o.push(e),o}}let i=this._isInteractive(t),a=this._isInteractive(e.eventMode);return i&&this.hitTestFn(e,n)?a?[e]:[]:null}hitTestFn(e,t){if(e.hitArea)return!0;if(e.containsPoint){let n=e.worldTransform.applyInverse(t);return e.containsPoint(n)}return!1}};f(rt,`desc`,{name:`events`});function it(e){if(!e)return;let t=e[0];for(let n=1;n<e.length&&e[n].parent===t;++n)t=e[n];return t}var at=7;function ot(e,t=!1){let n=e.root;e.worldTransform.copyFrom(n.localTransform);let r=e.childrenToUpdate;for(let t in r){let n=Number(t),i=r[n],a=i.list,o=i.index;for(let t=0;t<o;++t){let r=a[t];r.parentRenderGroup===e&&r.relativeRenderGroupDepth===n&&st(r,0)}ve(a,o),i.index=0}if(t)for(let n=0;n<e.renderGroupChildren.length;++n)ot(e.renderGroupChildren[n],t)}function st(e,t){e.didChange=!1;let n=e.parent,r=e.localTransform;e.updateLocalTransform(),n&&(t|=e._updateFlags,e.relativeGroupTransform.appendFrom(r,n.relativeGroupTransform),t&at&&ct(e,n,t));let i=e.children;for(let e=0;e<i.length;e++)st(i[e],t)}function ct(e,t,n){if(n&1){e.groupColor=t.groupColor;let n=e.localAlpha*t.groupAlpha;n=n<0?0:n>1?1:n,e.groupAlpha=n,e.groupColorAlpha=e.groupColor+((n*255|0)<<24)}n&4&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}function lt(e,t){let{list:n,index:r}=e.childrenRenderablesToUpdate,i=!1;for(let e=0;e<r;++e){let r=n[e];if(i=t[r.renderPipeId].validateRenderable(r),i)break}return e.structureDidChange=i,i}var ut=class{constructor(e){f(this,`renderer`,void 0),this.renderer=e}_updateRenderGroup(e){let t=this.renderer,n=t.renderPipes;e.runOnRender(t),e.instructionSet.renderPipes=n,e.structureDidChange?ve(e.childrenRenderablesToUpdate.list,0):lt(e,n),ot(e),e.structureDidChange&&(e.structureDidChange=!1,this._buildInstructions(e,t)),e.childrenRenderablesToUpdate.index=0}render({container:e,transform:t}){let n=this.renderer;t&&e.renderGroup.localTransform.copyFrom(t),n.canvasContext.globalTransform=t?e.renderGroup.localTransform:e.renderGroup.worldTransform,this._updateRenderGroup(e.renderGroup),dt(e.renderGroup,n.renderPipes)}_buildInstructions(e,t){let n=t.renderPipes,r=e.root;e.instructionSet.reset(),r.sortableChildren&&r.sortChildren(),n.batch.buildStart(),r.collectRenderablesWithEffects(n,e.instructionSet),n.batch.buildEnd(e.instructionSet)}};f(ut,`desc`,{name:`renderGroup`});function dt(e,t){let{instructionSet:n}=e,r=n.instructions;for(let e=0;e<n.instructionSize;e++){let n=r[e];t[n.renderPipeId].execute(n)}}var Y=[q,rt,ut,Xe,tt,Ze],ft=[m,z,V,ze,Re],pt=class extends c{constructor(){super(),f(this,`uid`,D(`renderer`)),f(this,`context`,void 0),f(this,`background`,void 0),f(this,`renderedObject`,null),f(this,`_roundPixels`,void 0),f(this,`resolution`,void 0),f(this,`activeRenderGroup`,void 0),f(this,`renderPipes`,{}),this.background={color:`#000000`}}get canvas(){return this.view.canvas}_addPipes(){ft.forEach(e=>{this.renderPipes[e.desc.name]=new e(this)})}_addSystems(){Y.forEach(e=>{this[e.desc.name]=new e(this)})}async init(e){this.resolution=e.resolution||1,this._addSystems(),this._addPipes();for(let r=0;r<Y.length;++r){var t,n;await((t=(n=this[Y[r].desc.name]).init)==null?void 0:t.call(n,e))}e.backgroundColor&&(this.background.color=e.backgroundColor),this._roundPixels=+!!e.roundPixels}get roundPixels(){return!!this._roundPixels}render(e){let t=e;if(t instanceof N&&(t={container:t}),this.renderedObject=t.container,t.transform||(t.container.updateLocalTransform(),t.transform=t.container.localTransform),t.clearColor!=null||(t.clearColor=this.background.color),!t.container.visible)return;t.container.enableRenderGroup();let n=t.container.renderGroup;if(this.activeRenderGroup=n,this.canvasContext.globalTransform=n.worldTransform,this.canvasContext.activeConext=this.canvasContext.rootContext,t.target){let{context:e}=mt(t.target.source);this.canvasContext.activeConext=e}this.clear(t),Y.forEach(e=>{var n,r;(n=(r=this[e.desc.name]).render)==null||n.call(r,t)})}clear(e){let t=this.canvasContext.activeConext;t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,this.canvas.width,this.canvas.height),t.globalAlpha=1,t.fillStyle=e.clearColor,t.fillRect(0,0,this.canvas.width,this.canvas.height),t.globalAlpha=1}destroy(){this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),ft.forEach(e=>{var t;(t=this.renderPipes[e.desc.name])==null||t.destroy()}),this.renderPipes=null}resize(e,t,n){this.view.resize(e,t,n),this.emit(`resize`,this.view.screen.width,this.view.screen.height,this.view.resolution)}};function mt(e){let t=e.resource;return t||(t=W(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight),{canvas:t,context:t.getContext(`2d`)}}var X=class{constructor(e,t,n=0,r=!1){f(this,`next`,null),f(this,`previous`,null),f(this,`priority`,0),f(this,`_fn`,void 0),f(this,`_context`,void 0),f(this,`_once`,void 0),f(this,`_destroyed`,!1),this._fn=e,this._context=t,this.priority=n,this._once=r}match(e,t){return this._fn===e&&this._context===t}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));let t=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),t}destroy(e){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let t=this.next;return this.next=e?null:t,this.previous=null,t}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}},Z=class e{constructor(){f(this,`autoStart`,!1),f(this,`deltaTime`,1),f(this,`deltaMS`,void 0),f(this,`elapsedMS`,void 0),f(this,`lastTime`,-1),f(this,`speed`,1),f(this,`started`,!1),f(this,`_tick`,void 0),f(this,`_requestId`,null),f(this,`_maxElapsedMS`,100),f(this,`_minElapsedMS`,0),f(this,`_lastFrame`,-1),f(this,`_head`,null),this._head=new X(null,null,1/0),this.deltaMS=1/e.targetFPMS,this.elapsedMS=this.deltaMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&(this._requestId=requestAnimationFrame(this._tick)))}}update(t=performance.now()){let n;if(t>this.lastTime){if(n=this.elapsedMS=t-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){let e=t-this._lastFrame|0;if(e<this._minElapsedMS)return;this._lastFrame=t-e%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*e.targetFPMS;let r=this._head,i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let n=Math.min(Math.max(0,t)/1e3,e.targetFPMS);this._maxElapsedMS=1/n,this._minElapsedMS&&t>this.maxFPS&&(this.maxFPS=t)}add(e,t,n=0){let r=new X(e,t,n),i=this._head.next,a=this._head;if(!i)r.connect(a);else{for(;i;){if(r.priority>i.priority){r.connect(a);break}a=i,i=i.next}r.previous||r.connect(a)}return this._startIfPossible(),this}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}remove(e,t){let n=this._head.next;for(;n;)n=n.match(e,t)?n.destroy():n.next;return this._head.next||this._cancelIfNeeded(),this}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}_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)}destroy(){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}};f(Z,`targetFPMS`,.06);var Q=class{static init(e){Object.defineProperty(this,"resizeTo",{configurable:!0,set(e){globalThis.removeEventListener(`resize`,this.queueResize),this._resizeTo=e,e&&(globalThis.addEventListener(`resize`,this.queueResize),this.resize())},get(){return this._resizeTo}}),this.queueResize=()=>{this._resizeTo&&(this._cancelResize(),this._resizeId=requestAnimationFrame(()=>this.resize))},this._cancelResize=()=>{this._resizeId&&(cancelAnimationFrame(this._resizeId),this._resizeId=null)},this.resize=()=>{if(!this._resizeTo)return;this._cancelResize();let e,t;if(this._resizeTo===globalThis.window)e=globalThis.innerWidth,t=globalThis.innerHeight;else{let{clientWidth:n,clientHeight:r}=this._resizeTo;e=n,t=r}this.renderer.resize(e,t),this.render()},this._resizeId=null,this._resizeTo=null,this.resizeTo=e.resizeTo||null}static destroy(){globalThis.removeEventListener(`resize`,this.queueResize),this._cancelResize(),this._cancelResize=null,this.queueResize=null,this.resizeTo=null,this.resize=null}};f(Q,`resizeTo`,void 0),f(Q,`queueResize`,void 0),f(Q,`_resizeTo`,void 0),f(Q,`_resizeId`,void 0),f(Q,`resize`,void 0),f(Q,`_cancelResize`,void 0),f(Q,`renderer`,void 0),f(Q,`render`,void 0);var ht=[Q],gt=class{constructor(){f(this,`renderer`,void 0),f(this,`stage`,new N),f(this,`_ticker`,void 0)}async init(e={}){e={...e},this.stage||(this.stage=new N),this.renderer=new pt,await this.renderer.init(e),ht.forEach(t=>{t.init.call(this,e)}),this.ticker=new Z,(e.autoStart||e.autoStart==null)&&this._ticker.start()}get canvas(){return this.renderer.canvas}get screen(){return this.renderer.view.screen}get ticker(){return this._ticker}set ticker(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this)}render(){this.renderer.render({container:this.stage})}destroy(){let e=ht.slice(0);if(e.reverse(),e.forEach(e=>{e.destroy.call(this)}),this.stage.destroy(),this.stage=null,this.renderer.destroy(),this.renderer=null,this._ticker){let e=this._ticker;this._ticker=null,e.destroy()}}},$=new class{constructor(){this._cache=new Map,this._cacheMap=new Map}reset(){this._cache.clear(),this._cacheMap.clear()}has(e){return this._cache.has(e)}get(e){let t=this._cache.get(e);if(!t)throw Error(`Asset ${e} not found`);return t}set(e,t){let n=Array.isArray(e)?e:[e],r=new Map;n.forEach(e=>{r.set(e,t)});let i=[...r.keys()],a={cacheKeys:i,keys:n};n.forEach(e=>{this._cacheMap.set(e,a)}),i.forEach(e=>{this._cache.set(e,r.get(e))})}remove(e){if(!this._cacheMap.has(e))return;let t=this._cacheMap.get(e);((t==null?void 0:t.cacheKeys)||[]).forEach(e=>{this._cache.delete(e)}),t==null||t.keys.forEach(e=>{this._cacheMap.delete(e)})}},_t=class e{constructor(){f(this,`promiseCache`,{}),f(this,`loadOptions`,{...e.defaultOptions})}getAlias(e){let{alias:t,src:n}=e,r=t||n;return(Array.isArray(r)?r:[r]).map(e=>typeof e==`string`?e:Array.isArray(e)?e.map(e=>{var t;return(t=e.src)==null?e:t}):e!=null&&e.src?e.src:e)}async load(t,n){let{onProgress:r,onError:i,strategy:a,retryCount:o,retryDelay:s}=typeof n==`function`?{...e.defaultOptions,...this.loadOptions,onProgress:n}:{...e.defaultOptions,...this.loadOptions,...n||{}},c=0,l={},u=t.reduce((e,t)=>e+(t.progressSize||1),0),d=t.map(async e=>{if(l[e.src])return;let t=e.src;await this._loadAssetWithRetry(t,e,{onProgress:r,onError:i,strategy:a,retryCount:o,retryDelay:s},l),c+=e.progressSize||1,r&&r(c/u)});return await Promise.all(d),l}async unload(e){let t=e.map(async e=>{let t=e.src,n=this.promiseCache[t];if(n){let e=await n;delete this.promiseCache[t],e.destroy(!0)}});await Promise.all(t)}_getLoadPromise(e,t){return(async()=>await vt(e,t,this))()}async _loadAssetWithRetry(e,t,n,r){let i=0,{onError:a,strategy:o,retryCount:s,retryDelay:c}=n,l=e=>new Promise(t=>setTimeout(t,e));for(;;)try{this.promiseCache[e]||(this.promiseCache[e]=this._getLoadPromise(e,t)),r[t.src]=await this.promiseCache[e];return}catch(n){if(delete this.promiseCache[e],delete r[t.src],i++,o===`retry`&&!(o!==`retry`||i>s)){a&&a(n,t.src),await l(c);continue}if(o===`skip`){a&&a(n,t.src);return}a&&a(n,t.src);let u=Error(`[Loader.load] Failed to load ${e}.\n${n}`);throw n instanceof Error&&n.stack&&(u.stack=n.stack),u}}reset(){this.promiseCache={}}};f(_t,`defaultOptions`,{strategy:`throw`,retryCount:3,retryDelay:250});async function vt(e,t,n){let r=null;return r=globalThis.createImageBitmap?await yt(e):await new Promise((t,n)=>{r=new Image,r.crossOrigin=`anonymous`,r.src=e,r.complete?t(r):(r.onload=()=>{t(r)},r.onerror=n)}),bt(new G({resource:r}),n,e)}async function yt(e){let t=await window.fetch(e);if(t.headers.get(`content-type`)===`text/html`||!t.ok)throw Error(`[loadImageBitmap] Failed to fetch ${e}: ${t.status} ${t.statusText}`);let n=await t.blob();return window.createImageBitmap(n)}function bt(e,t,n){e.label=n;let r=new K({source:e,label:n}),i=()=>{delete t.promiseCache[n],$.has(n)&&$.remove(n)};return r.source.on(`destroy`,()=>{t.promiseCache[n]&&i()}),r.on(`destroy`,()=>{e.destroyed||i()}),r}var xt=class{constructor(){f(this,`cache`,void 0),f(this,`loader`,void 0),f(this,`basePath`,void 0),f(this,`_initialized`,!1),this.loader=new _t,this.cache=$}init(e={}){this._initialized||(this._initialized=!0,e.basePath&&(this.basePath=e.basePath),e.loadOptions&&(this.loader.loadOptions={...this.loader.loadOptions,...e.loadOptions}))}async load(e,t){this._initialized||this.init();let n=e.map(e=>({...e,src:Ct(e.src,this.basePath)}));return await this._mapLoadToResolve(n,t)}async _mapLoadToResolve(e,t){let n=Object.values(e),r=await this.loader.load(n,t),i={};return n.forEach(e=>{let t=r[e.src],n=Array.isArray(e.alias)?e.alias:[e.alias],a=[e.src,...n];a.forEach(e=>{i[e]=t}),$.set(a,t)}),i}reset(){this._initialized=!1,this.cache.reset(),this.loader.reset()}},St=new xt;function Ct(e,t){return e.startsWith(`http`)||!t?e:e.startsWith(`/`)&&t.endsWith(`/`)?t+e.slice(1):e.startsWith(`/`)&&!t.endsWith(`/`)||!e.startsWith(`/`)&&t.endsWith(`/`)?t+e:`${t}/${e}`}exports.Application=gt,exports.Assets=St,exports.AssetsClass=xt,exports.CanvasRenderer=pt,exports.Container=N,exports.Graphics=Le,exports.GraphicsContext=R,exports.GraphicsPipe=z,exports.Matrix=_,exports.PI_2=g,exports.Rectangle=y,exports.RenderGroup=_e,exports.RenderTexture=Qe,exports.Sprite=$e,exports.Text=et,exports.TextPipe=V,exports.Texture=K,exports.Ticker=Z,exports.TickerListener=X,exports.UPDATE_BLEND=xe,exports.UPDATE_COLOR=be,exports.UPDATE_TRANSFORM=Ce,exports.UPDATE_VISIBLE=Se,exports.Vector2=b,exports.ViewContainer=P,exports.buildShapePath=B,exports.nextPow2=x;
|
|
2
2
|
//# sourceMappingURL=dao.cjs.map
|