bard-legends-framework 1.0.9 → 1.1.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/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as actions_lib from 'actions-lib';
|
|
2
|
-
import { IDAttachable, Attachable, SingleEvent,
|
|
2
|
+
import { IDAttachable, Attachable, SingleEvent, Sequence, Action, Notifier, Reducer, Variable } from 'actions-lib';
|
|
3
3
|
import { Vector, Radian, Vec2, RGBColor, Rectangle, Grid, GridNeighborType, Line } from 'helpers-lib';
|
|
4
4
|
import * as Pixi from 'pixi.js';
|
|
5
5
|
|
|
@@ -142,7 +142,7 @@ declare abstract class ContainerAttributes extends IDAttachable {
|
|
|
142
142
|
set x(value: number);
|
|
143
143
|
get y(): number;
|
|
144
144
|
set y(value: number);
|
|
145
|
-
on(eventType: ContainerEventType
|
|
145
|
+
on(eventType: ContainerEventType): Sequence;
|
|
146
146
|
setRotation(value: Radian): this;
|
|
147
147
|
get rotation(): Radian;
|
|
148
148
|
set rotation(value: Radian);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as actions_lib from 'actions-lib';
|
|
2
|
-
import { IDAttachable, Attachable, SingleEvent,
|
|
2
|
+
import { IDAttachable, Attachable, SingleEvent, Sequence, Action, Notifier, Reducer, Variable } from 'actions-lib';
|
|
3
3
|
import { Vector, Radian, Vec2, RGBColor, Rectangle, Grid, GridNeighborType, Line } from 'helpers-lib';
|
|
4
4
|
import * as Pixi from 'pixi.js';
|
|
5
5
|
|
|
@@ -142,7 +142,7 @@ declare abstract class ContainerAttributes extends IDAttachable {
|
|
|
142
142
|
set x(value: number);
|
|
143
143
|
get y(): number;
|
|
144
144
|
set y(value: number);
|
|
145
|
-
on(eventType: ContainerEventType
|
|
145
|
+
on(eventType: ContainerEventType): Sequence;
|
|
146
146
|
setRotation(value: Radian): this;
|
|
147
147
|
get rotation(): Radian;
|
|
148
148
|
set rotation(value: Radian);
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var actionsLib=require('actions-lib');require('reflect-metadata');var helpersLib=require('helpers-lib'),W=require('p2'),V=require('pixi.js'),scriptEngineLib=require('script-engine-lib');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var W__default=/*#__PURE__*/_interopDefault(W);var V__namespace=/*#__PURE__*/_interopNamespace(V);var cr=Object.defineProperty;var h=(o,t)=>cr(o,"name",{value:t,configurable:true});var G=class{static{h(this,"BardLegendsHardReset");}static{this.ƀes=new actionsLib.Action;}static{this.onHardReset=this.ƀes.notifier;}static hardReset(){actionsLib.ActionLib.hardReset(),this.ƀes.trigger();}};function d(){return function(o){let t=P.ƀec(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var P=class{static{h(this,"Service");}static{this.ƀir=new Map;}static get(t){let e=this.ƀir.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀid([],t.$meta.paramtypes);e=new t(...i),this.ƀir.set(t,e);}return e}static ƀec(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e}static ƀid(t,e){let i=[...t];if(e.length>t.length){let s=e.slice(t.length).map(n=>{if(n&&n.$meta?.type==="service")return this.get(n)});i.push(...s);}return i}};G.onHardReset.subscribe(()=>{P.ƀir=new Map;}).attachToRoot();var U=class{static{h(this,"ControllerLink");}constructor(){this.ƀbm=[],this.ƀic=[];}trigger(t,...e){let i=this.ƀbm.find(r=>!!r[t]);if(i)return i[t](...e);throw new Error(`ServiceLink: no defined function with the name: "${t}", found in the linked controllers!`)}registerController(t){Reflect.ownKeys(t.constructor.prototype).filter(e=>e!=="constructor").map(e=>e.toString()).forEach(e=>{if(this.ƀic.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀic.push(e);}),this.ƀbm.push(t);}};function q(o){return function(t){let e=P.ƀec(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=P.ƀid([],e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);o.controllerLink.registerController(r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var y=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new actionsLib.Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀij=new actionsLib.Action;}static{this.sceneUpdateAction=this.ƀij.notifier;}static{this.ƀf=new actionsLib.Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀjv=0;}static{this.ƀkd=void 0;}static wait(t){let e=this.ƀjv+t;return actionsLib.SingleEvent.create(i=>{let r=o.beforeSceneUpdateAction.subscribe(s=>{s.time>=e&&i();}).attachToRoot();return ()=>r.destroy()})}static registerUpdateModifier(t){if(!this.ƀkd)this.ƀkd=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkd=void 0;}static triggerUpdateTick(t){this.ƀkd&&(t=this.ƀkd(this.ƀjv,t)),this.ƀjv+=t,this.ƀfr=t,t>0&&(o.ƀad.trigger({time:this.ƀjv,delta:t}),o.ƀij.trigger({time:this.ƀjv,delta:t}),o.ƀf.trigger({time:this.ƀjv,delta:t}));}static get lastDelta(){return this.ƀfr}static{this.ƀfr=0;}};G.onHardReset.subscribe(()=>{y.ƀad.clear(),y.ƀij.clear(),y.ƀf.clear(),y.ƀkd=void 0,y.ƀjv=0;}).attachToRoot();var _=class o{static{h(this,"EntityStoreHelper");}static{this.ƀaw=new Map;}static registerEntityClass(t){this.ƀaw.set(t.id,new Map);}static registerEntity(t){this.ƀaw.get(t.classID).set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀaw.get(i)?.delete(e);}static getEntity(t,e){return this.ƀaw.get(t.id)?.get(e)}static getSingleton(t){let e=o.getEntities(t);if(e.length>1)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has multiple instances! Name: "${this.name}"`);return e[0]}static getSingletonOrFail(t){let e=this.getSingleton(t);if(!e)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has no instance! Name: "${this.name}"`);return e}static getEntities(t){let e=this.ƀaw.get(t.id);return Array.from(e.values())}};G.onHardReset.subscribe(()=>{_.ƀaw.clear();}).attachToRoot();var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀkm=new Map;}static registerView(t,e){o.ƀkm.has(e)||o.ƀkm.set(e,[]);let i=o.ƀkm.get(e);i&&i.push(t),_.getEntities(e).forEach(s=>{this.ƀch(s,t);});}static ƀch(t,e){try{let i=P.ƀid([this],e.$meta.paramtypes);o.entityID=t.id;let r=new e(t,...i.slice(1));t.destroyed?r.destroy():t.ƀkl.ƀkn.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcw=t,this.ƀkn=[];}createViews(){if(!this.ƀcw.destroyed){let t=o.ƀkm.get(this.ƀcw.constructor);t&&t.forEach(e=>{o.ƀch(this.ƀcw,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkn.length;i++){let r=this.ƀkn[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkn.forEach(t=>{t.destroy();});}};G.onHardReset.subscribe(()=>{rt.ƀkm=new Map;}).attachToRoot();function dt(){return function(o){o.$meta={type:"entity"},_.registerEntityClass(o);}}h(dt,"EntityDecorator");var $=class extends actionsLib.IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return _.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=_.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return _.getEntities(this)}constructor(){super(),this.ƀkl=new rt(this),_.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀkl.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀkl.destroyViews(),_.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀkl.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀkl.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀkl.createViews(),this}update(t,e){}};var ut=class extends ${static{h(this,"SingletonEntity");}static getInstance(){return _.getSingleton(this)}static getInstanceOrFail(){return _.getSingletonOrFail(this)}constructor(){if(super(),this.constructor.getEntities().length>1)throw this.attachToRoot(),new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! "${this}"`)}};function wr(){return function(o){return o.$meta={paramtypes:P.ƀec(o),type:"scene"},o}}h(wr,"SceneDecorator");var Pt=class o extends actionsLib.IDAttachable{static{h(this,"Scene");}static{this.ƀii=false;}static{this.ƀb=new actionsLib.Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveScene(){return o.ƀb.value}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static isActive(){return o.ƀb.value instanceof this}static getInstance(){return o.ƀb.value instanceof this?o.ƀb.value:void 0}static getInstanceOrFail(){if(!o.ƀb.value)throw new Error("Scene: getInstance is called when there is no active scene!");if(!(o.ƀb.value instanceof this))throw new Error(`Scene: getInstance is called while "${this.name}" was not the active scene. Current scene is: "${o.ƀb.value}"!`);return o.ƀb.value}static open(...t){if(o.ƀii)throw new Error("Scene: you cannot open a scene while a scene is transitioning!");if(o.ƀb.value)throw new Error("Scene: you cannot open a scene while there is already another active scene!");let e=t[0];o.ƀii=true;let i=P.ƀid([],this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀii=false,r)).chainToRoot()}constructor(){super(),this.ƀgn=new actionsLib.Action,this.onClose=this.ƀgn.notifier,y.sceneUpdateAction.subscribe(t=>this.update(t.time,t.delta)).attach(this);}close(...t){if(o.ƀb.value!==this)throw new Error("Internal Error: Scene instance is accessed while it is not the active scene!");if(o.ƀii)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀii=true;let e=t[0];return this.prepareToClose().map(()=>(super.destroy(),o.ƀb.set(void 0),o.ƀii=false,this.ƀgn.trigger(e),e)).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};G.onHardReset.subscribe(()=>{Pt.ƀb.set(void 0);}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:P.ƀec(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var Ht=class extends actionsLib.IDAttachable{static{h(this,"View");}static getInstance(t){return this.$meta.entity.validateID(t)?this.$meta.viewInstances.get(t):void 0}static getInstanceOrFail(t){if(!this.$meta.entity.validateID(t))throw new Error(`View: getInstance is called with entity id: "${t}", that is not belonging to the class: "${this.$meta.entity}"`);let i=this.$meta.viewInstances.get(t);if(!i)throw new Error(`View: getInstanceOrFail is called with entity id: "${t}", that is not found!`);return i}constructor(){super(),this.attachToRoot(),this.ƀcx=rt.entityID,this.ƀei().set(this.ƀcx,this);}destroy(){this.destroyed||(super.destroy(),this.ƀei().delete(this.ƀcx));}update(t,e){}ƀei(){return this.constructor.$meta.viewInstances}};var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return helpersLib.Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new helpersLib.Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new W__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Sr=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},J=new U,St=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return J.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return J.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return J.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return J.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return J.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return J.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return J.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return J.trigger("subscribeToPhysicsStep",t,e)}};St=Sr([d()],St);var b=class o extends ${static{h(this,"PhysicsEntity");}static{this.ƀhb=new Map;}static{this.ƀhi=new Map;}static getFromP2BodyID(t){return o.ƀhb.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhb.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhi.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhi.values())}get area(){return this.ƀu}get mass(){return this.ƀgd}get collisions(){return this.ƀay}constructor(t,e,i){super(),this.ƀgo=new actionsLib.Action,this.onCollision=this.ƀgo.notifier,this.type="dynamic",this.ƀu=0,this.ƀgd=0,this.ƀay=[],this.physicsWorldID=t,this.ƀhk=P.get(St);let r=this.ƀhk.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhk.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀhj=this.ƀhk.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhl=this.ƀhk.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhk.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgd=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhk.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhb.set(this.p2Body.id,this),o.ƀhi.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhk.removeBody(this.physicsWorldID,this.p2Body),o.ƀhb.delete(this.p2Body.id),o.ƀhi.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀhj,this.ƀhl,t.ƀhj,t.ƀhl)}ƀis(t){this.ƀay=t,t.length>0&&this.ƀgo.trigger(t);}};var Wt=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new helpersLib.Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:helpersLib.Vector.zero,rotationalSpeed:0}}};var Xe=class extends ${static{h(this,"MovableEntity");}constructor(){super(),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),y.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀjk(t,e);}).attach(this);}ƀjk(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new helpersLib.Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ke=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),this.ƀez=false,this.ƀfa=false,this.ƀfc=false,this.ƀfb=false,this.ƀhf(),this.ƀfx(),P.get(St).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjk(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀjk(t,e){this.ƀez=true,this.ƀfa=true,this.ƀfc=true,this.ƀfb=true,this.ƀhf();}ƀhf(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new helpersLib.Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀfx(){this.position.subscribe(t=>{this.ƀez?this.ƀez=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfa?this.ƀfa=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfb?this.ƀfb=false:this.p2Body.angularVelocity=t;}).attach(this);}};var Ze=10.8,Qe=10.01;exports.PhysicsShapeType=void 0;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(exports.PhysicsShapeType||(exports.PhysicsShapeType={}));var st="border";var Y=class{static{h(this,"AnimationInterpolationFunctions");}static boomerangTime(t){return 1-Math.abs(t-.5)*2}static lineer(t){return t}static easeIn(t){return Math.pow(t,2)}static easeOut(t){return 1-Math.pow(1-t,2)}static easeInOut(t){return t<.5?2*t*t:(t-=1,1-2*t*t)}static easeInOutCubic(t){let e=2*t-2;return t<.5?4*Math.pow(t,3):(t-1)*Math.pow(e,2)+1}},Rr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return Y.lineer(t)}},Ir=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return Y.easeIn(t)}},Ar=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return Y.easeOut(t)}},Or=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return Y.easeInOut(t)}},Mr=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return Y.easeInOutCubic(t)}},Ai=class{static{h(this,"AnimationFlicker");}start(){this.ƀjw=new Array(10).fill(0),helpersLib.Random.integerBetween(0,9),this.ƀjw[helpersLib.Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(helpersLib.Random.integerBetween(0,9),this.ƀjw[helpersLib.Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(helpersLib.Random.integerBetween(0,9),this.ƀjw[helpersLib.Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀjw[e]}},S=class{static{h(this,"Animations");}static{this.lineer=new Rr;}static{this.easeIn=new Ir;}static{this.easeOut=new Ar;}static{this.easeInOut=new Or;}static{this.easeInOutCubic=new Mr;}};exports.ReAnimateHandlingType=void 0;(function(o){o[o.ThrowError=1]="ThrowError",o[o.IgnoreNewAnimation=2]="IgnoreNewAnimation",o[o.CompletePrevious=3]="CompletePrevious";})(exports.ReAnimateHandlingType||(exports.ReAnimateHandlingType={}));exports.AnimationsCompletionHandlingType=void 0;(function(o){o[o.ReturnToOriginal=1]="ReturnToOriginal",o[o.StayInCurrentState=2]="StayInCurrentState",o[o.JumpToEnd=3]="JumpToEnd",o[o.Loop=4]="Loop";})(exports.AnimationsCompletionHandlingType||(exports.AnimationsCompletionHandlingType={}));var A=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdj(t){let e=o.ƀk.get(t);return e||(e=new helpersLib.MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀgx!==void 0}get target(){return this.ƀjn}get value(){return this.ƀkf||(this.ƀkf=new actionsLib.Variable(this.ƀjn)),this.ƀkf.notifier}constructor(t,e,i){this.ƀfl=false,this.ƀiz=false,this.ƀjn=t,this.ƀha={duration:200,animation:S.lineer,reAnimateHandling:exports.ReAnimateHandlingType.ThrowError,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState,...i},this.ƀl=helpersLib.Comparator.isArray(e)?e:[e],this.ƀfy(t,this.ƀl);}animate(t,e){let i={...this.ƀha,...e};if(this.ƀgx)switch(i.reAnimateHandling){case exports.ReAnimateHandlingType.ThrowError:throw new Error("Animator: new animation triggered while another is not complete yet.");case exports.ReAnimateHandlingType.IgnoreNewAnimation:return actionsLib.SingleEvent.instant();case exports.ReAnimateHandlingType.CompletePrevious:this.ƀit(i.completionHandling,this.ƀgx.ƀhu,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return actionsLib.SingleEvent.create(s=>{this.ƀfl&&(this.ƀiz=true);let n=this.ƀl.reduce((c,p)=>(c[p]={ƀjh:this.ƀjn[p],ƀjp:t[p]},c),{}),a={ƀcs:i.duration,ƀct:0,ƀhu:n,ƀbf:i.completionHandling,ƀm:i.animation,ƀbe:s};if(a.ƀbf!==exports.AnimationsCompletionHandlingType.Loop&&this.ƀfj(a)){this.ƀgx=void 0,s();return}else a.ƀm.start();let l=this.ƀgx;return this.ƀgx=a,this.ƀcv(),l?.ƀbe(),()=>{this.ƀgx===a&&(this.ƀjn instanceof actionsLib.Attachable&&this.ƀjn.destroyed||this.ƀit(a.ƀbf,a.ƀhu,true),this.ƀgx=void 0,this.ƀkc?.destroy(),this.ƀkc=void 0);}})}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r]&&(e=true,this.ƀjn[r]=t[r]);}e&&this.ƀkf?.set(this.ƀjn),this.ƀgx?.ƀbe();}completeAnimation(t){if(this.ƀgx){t=t??this.ƀgx.ƀbf,this.ƀit(t,this.ƀgx.ƀhu,true);let e=this.ƀgx.ƀbe;this.ƀgx=void 0,e();}}ƀcv(){this.ƀkc||(this.ƀkc=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfl=true;try{let e=this.ƀgx;if(!e)return;e.ƀct+=t.delta;let i=e.ƀct>=e.ƀcs;if(i)if(e.ƀbf===exports.AnimationsCompletionHandlingType.Loop)e.ƀct%=e.ƀcs,e.ƀm.start(),i=!1;else {this.ƀit(e.ƀbf,e.ƀhu,!1),this.ƀgx=void 0,e.ƀbe(),this.ƀgx||(this.ƀkc?.destroy(),this.ƀkc=void 0);return}if(!i){let r=e.ƀm.multiplierFunction(e.ƀct/e.ƀcs),s=!1;for(let n=0;n<this.ƀl.length;n++){let a=this.ƀl[n],l=e.ƀhu[a],p=(l.ƀjp-l.ƀjh)*r+l.ƀjh;p!==this.ƀjn[a]&&(s=!0,this.ƀjn[a]=p);}s&&this.ƀkf?.set(this.ƀjn);}}finally{this.ƀfl=false,this.ƀiz&&(this.ƀiz=false,this.ƀkc?.destroy(),this.ƀkc=void 0,this.ƀcv());}}).attachToRoot());}ƀfj(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjn[i]!==t.ƀhu[i].ƀjp)return false}return true}ƀit(t,e,i){switch(t){case exports.AnimationsCompletionHandlingType.ReturnToOriginal:this.ƀif(e);break;case exports.AnimationsCompletionHandlingType.StayInCurrentState:i||this.ƀfo(e);break;case exports.AnimationsCompletionHandlingType.JumpToEnd:this.ƀfo(e);break;case exports.AnimationsCompletionHandlingType.Loop:this.ƀif(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀif(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjh&&(e=true,this.ƀjn[r]=t[r].ƀjh);}e&&this.ƀkf?.set(this.ƀjn);}ƀfo(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjp&&(e=true,this.ƀjn[r]=t[r].ƀjp);}e&&this.ƀkf?.set(this.ƀjn);}ƀfy(t,e){let i=o.ƀdj(t);for(let r of e){if(i.has(r))throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(t,void 0,2)}", Property: "${r}"`);i.set(r,this);}}};exports.ContainerEventType=void 0;(function(o){o.Click="click",o.MouseOver="mouseover",o.MouseOut="mouseout",o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerUpOutside="pointerupoutside",o.PointerMove="pointermove",o.PointerCancel="pointercancel",o.PointerOver="pointerover",o.PointerOut="pointerout",o.PointerEnter="pointerenter",o.PointerLeave="pointerleave",o.Added="added",o.Removed="removed",o.Update="update",o.Change="change";})(exports.ContainerEventType||(exports.ContainerEventType={}));exports.Cursor=void 0;(function(o){o.Default="default",o.Pointer="pointer";})(exports.Cursor||(exports.Cursor={}));var ue=class extends actionsLib.IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgh=false,this.ƀdc=false,this.ƀig=1,this.ƀw=1,this.pixiContainer=new V__namespace.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new helpersLib.Vector(this.pixiContainer.width,this.pixiContainer.height)}setSize(t){return this.pixiContainer.width=t.x,this.pixiContainer.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.pixiContainer.getLocalBounds(),r=new helpersLib.Vector(this.pixiContainer.scale.x,this.pixiContainer.scale.y),s=new helpersLib.Vector(i.x,i.y).multiply(r),n=new helpersLib.Vector(i.width,i.height).multiply(r),a=s.add(n.multiply(e.holdFrom));t=t.subtract(a);}return e?.round!==false&&(t=t.round({rollHalfsDown:true})),this.position=t,this}get position(){return new helpersLib.Vector(this.pixiContainer.x,this.pixiContainer.y)}set position(t){this.pixiContainer.position=t;}get x(){return this.pixiContainer.x}set x(t){this.pixiContainer.x=t;}get y(){return this.pixiContainer.y}set y(t){this.pixiContainer.y=t;}on(t,e){let i=h(r=>e(),"handle");return this.pixiContainer.on(t,i),new actionsLib.ActionSubscription(()=>{this.pixiContainer.off(t,i);})}setRotation(t){return this.rotation=t,this}get rotation(){return new helpersLib.Radian(this.pixiContainer.rotation)}set rotation(t){this.pixiContainer.rotation=t.value;}get rotationValue(){return this.rotation.value}set rotationValue(t){this.rotation=new helpersLib.Radian(t);}setZIndex(t){return this.zIndex=t,this}get zIndex(){return this.pixiContainer.zIndex}set zIndex(t){this.pixiContainer.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new helpersLib.Radian(this.pixiContainer.skew.x)}set skewX(t){this.pixiContainer.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new helpersLib.Radian(this.pixiContainer.skew.y)}set skewY(t){this.pixiContainer.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.pixiContainer.sortableChildren}set sortableChildren(t){this.pixiContainer.sortableChildren=t;}setAlpha(t){return this.pixiContainer.alpha=t,this}get alpha(){return this.pixiContainer.alpha}set alpha(t){this.pixiContainer.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.pixiContainer.interactive}set interactive(t){t?this.pixiContainer.eventMode="dynamic":this.pixiContainer.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.pixiContainer.cursor}set cursor(t){this.pixiContainer.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.pixiContainer.addChild(t.pixiContainer),this.pixiContainer.mask=t.getMask(),this.ƀgb=t):(this.ƀgb&&this.pixiContainer.removeChild(this.ƀgb.pixiContainer),this.pixiContainer.mask=null),this}hitTest(t){if(this.pixiContainer.parent)if(this.pixiContainer.hitArea){let e=this.pixiContainer.toLocal(t);return this.pixiContainer.hitArea.contains(e.x,e.y)}else return this.pixiContainer.getBounds().contains(t.x,t.y);else return false}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgh}set mirror(t){this.ƀgh=t,this.ƀke();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdc}set flip(t){this.ƀdc=t,this.ƀke();}setScale(t){return this.scale=t,this}get scale(){return this.ƀig}set scale(t){this.ƀig=t,this.ƀke();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀke();}ƀke(){this.pixiContainer.scale.set(this.ƀig,this.ƀig),this.ƀw<1?this.pixiContainer.scale.x*=this.ƀw:this.ƀw>1&&(this.pixiContainer.scale.y/=this.ƀw),this.ƀgh&&(this.pixiContainer.scale.x*=-1),this.ƀdc&&(this.pixiContainer.scale.y*=-1);}};var O=2;exports.BlendMode=void 0;(function(o){o[o.Normal=0]="Normal",o[o.Add=1]="Add",o[o.Screen=3]="Screen",o[o.Luminosity=16]="Luminosity",o[o.ColorDodge=7]="ColorDodge";})(exports.BlendMode||(exports.BlendMode={}));var fe=class{static{h(this,"GaussianValuesHelper");}static ƀdh(t,e){let i=e*e,r=1/(helpersLib.PI_360*i),s=-(t*t)/(2*i);return r*Math.exp(s)}static getValuesForLinearSamplingPascal(t){let e=t*2,i=Math.pow(2,e),r=.005*i,s=helpersLib.NumberHelper.pascalTriangleRow(e).slice(t).filter(l=>{if(l<r)i-=l*2;else return true}),n=1/i,a=s.map(l=>l*n);return this.ƀbr(a)}static getValuesForLinearSamplingGauss(t){if(t===0)return [{offset:0,multiplier:1}];if(t===1)return [{offset:0,multiplier:.5},{offset:1,multiplier:.25}];{let e=helpersLib.ArrayHelper.createIntegerArray(Math.ceil(t*.75)).map(r=>this.ƀdh(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbr(e)}}static ƀbr(t){let e=[{offset:0,multiplier:t[0]}];for(let i=1;i<t.length-1;i+=2){let r=t[i]+t[i+1],s=i+t[i+1]/r;e.push({offset:s,multiplier:r});}if(t.length%2===0){let i=t[t.length-1],r=t.length-1;e.push({offset:r,multiplier:i});}return e}};var Di=class ti extends V__namespace.Filter{static{h(this,"BlurFilterPass");}static ƀeh(){return `
|
|
1
|
+
'use strict';var actionsLib=require('actions-lib');require('reflect-metadata');var helpersLib=require('helpers-lib'),W=require('p2'),V=require('pixi.js'),scriptEngineLib=require('script-engine-lib');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var W__default=/*#__PURE__*/_interopDefault(W);var V__namespace=/*#__PURE__*/_interopNamespace(V);var cr=Object.defineProperty;var h=(o,t)=>cr(o,"name",{value:t,configurable:true});var G=class{static{h(this,"BardLegendsHardReset");}static{this.ƀes=new actionsLib.Action;}static{this.onHardReset=this.ƀes.notifier;}static hardReset(){actionsLib.ActionLib.hardReset(),this.ƀes.trigger();}};function d(){return function(o){let t=P.ƀec(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var P=class{static{h(this,"Service");}static{this.ƀir=new Map;}static get(t){let e=this.ƀir.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀid([],t.$meta.paramtypes);e=new t(...i),this.ƀir.set(t,e);}return e}static ƀec(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e}static ƀid(t,e){let i=[...t];if(e.length>t.length){let s=e.slice(t.length).map(n=>{if(n&&n.$meta?.type==="service")return this.get(n)});i.push(...s);}return i}};G.onHardReset.subscribe(()=>{P.ƀir=new Map;}).attachToRoot();var U=class{static{h(this,"ControllerLink");}constructor(){this.ƀbm=[],this.ƀic=[];}trigger(t,...e){let i=this.ƀbm.find(r=>!!r[t]);if(i)return i[t](...e);throw new Error(`ServiceLink: no defined function with the name: "${t}", found in the linked controllers!`)}registerController(t){Reflect.ownKeys(t.constructor.prototype).filter(e=>e!=="constructor").map(e=>e.toString()).forEach(e=>{if(this.ƀic.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀic.push(e);}),this.ƀbm.push(t);}};function q(o){return function(t){let e=P.ƀec(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=P.ƀid([],e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);o.controllerLink.registerController(r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var y=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new actionsLib.Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀij=new actionsLib.Action;}static{this.sceneUpdateAction=this.ƀij.notifier;}static{this.ƀf=new actionsLib.Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀjv=0;}static{this.ƀkd=void 0;}static wait(t){let e=this.ƀjv+t;return actionsLib.SingleEvent.create(i=>{let r=o.beforeSceneUpdateAction.subscribe(s=>{s.time>=e&&i();}).attachToRoot();return ()=>r.destroy()})}static registerUpdateModifier(t){if(!this.ƀkd)this.ƀkd=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkd=void 0;}static triggerUpdateTick(t){this.ƀkd&&(t=this.ƀkd(this.ƀjv,t)),this.ƀjv+=t,this.ƀfr=t,t>0&&(o.ƀad.trigger({time:this.ƀjv,delta:t}),o.ƀij.trigger({time:this.ƀjv,delta:t}),o.ƀf.trigger({time:this.ƀjv,delta:t}));}static get lastDelta(){return this.ƀfr}static{this.ƀfr=0;}};G.onHardReset.subscribe(()=>{y.ƀad.clear(),y.ƀij.clear(),y.ƀf.clear(),y.ƀkd=void 0,y.ƀjv=0;}).attachToRoot();var _=class o{static{h(this,"EntityStoreHelper");}static{this.ƀaw=new Map;}static registerEntityClass(t){this.ƀaw.set(t.id,new Map);}static registerEntity(t){this.ƀaw.get(t.classID).set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀaw.get(i)?.delete(e);}static getEntity(t,e){return this.ƀaw.get(t.id)?.get(e)}static getSingleton(t){let e=o.getEntities(t);if(e.length>1)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has multiple instances! Name: "${this.name}"`);return e[0]}static getSingletonOrFail(t){let e=this.getSingleton(t);if(!e)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has no instance! Name: "${this.name}"`);return e}static getEntities(t){let e=this.ƀaw.get(t.id);return Array.from(e.values())}};G.onHardReset.subscribe(()=>{_.ƀaw.clear();}).attachToRoot();var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀkm=new Map;}static registerView(t,e){o.ƀkm.has(e)||o.ƀkm.set(e,[]);let i=o.ƀkm.get(e);i&&i.push(t),_.getEntities(e).forEach(s=>{this.ƀch(s,t);});}static ƀch(t,e){try{let i=P.ƀid([this],e.$meta.paramtypes);o.entityID=t.id;let r=new e(t,...i.slice(1));t.destroyed?r.destroy():t.ƀkl.ƀkn.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcw=t,this.ƀkn=[];}createViews(){if(!this.ƀcw.destroyed){let t=o.ƀkm.get(this.ƀcw.constructor);t&&t.forEach(e=>{o.ƀch(this.ƀcw,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkn.length;i++){let r=this.ƀkn[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkn.forEach(t=>{t.destroy();});}};G.onHardReset.subscribe(()=>{rt.ƀkm=new Map;}).attachToRoot();function dt(){return function(o){o.$meta={type:"entity"},_.registerEntityClass(o);}}h(dt,"EntityDecorator");var $=class extends actionsLib.IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return _.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=_.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return _.getEntities(this)}constructor(){super(),this.ƀkl=new rt(this),_.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀkl.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀkl.destroyViews(),_.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀkl.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀkl.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀkl.createViews(),this}update(t,e){}};var ut=class extends ${static{h(this,"SingletonEntity");}static getInstance(){return _.getSingleton(this)}static getInstanceOrFail(){return _.getSingletonOrFail(this)}constructor(){if(super(),this.constructor.getEntities().length>1)throw this.attachToRoot(),new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! "${this}"`)}};function wr(){return function(o){return o.$meta={paramtypes:P.ƀec(o),type:"scene"},o}}h(wr,"SceneDecorator");var Pt=class o extends actionsLib.IDAttachable{static{h(this,"Scene");}static{this.ƀii=false;}static{this.ƀb=new actionsLib.Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveScene(){return o.ƀb.value}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static isActive(){return o.ƀb.value instanceof this}static getInstance(){return o.ƀb.value instanceof this?o.ƀb.value:void 0}static getInstanceOrFail(){if(!o.ƀb.value)throw new Error("Scene: getInstance is called when there is no active scene!");if(!(o.ƀb.value instanceof this))throw new Error(`Scene: getInstance is called while "${this.name}" was not the active scene. Current scene is: "${o.ƀb.value}"!`);return o.ƀb.value}static open(...t){if(o.ƀii)throw new Error("Scene: you cannot open a scene while a scene is transitioning!");if(o.ƀb.value)throw new Error("Scene: you cannot open a scene while there is already another active scene!");let e=t[0];o.ƀii=true;let i=P.ƀid([],this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀii=false,r)).chainToRoot()}constructor(){super(),this.ƀgn=new actionsLib.Action,this.onClose=this.ƀgn.notifier,y.sceneUpdateAction.subscribe(t=>this.update(t.time,t.delta)).attach(this);}close(...t){if(o.ƀb.value!==this)throw new Error("Internal Error: Scene instance is accessed while it is not the active scene!");if(o.ƀii)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀii=true;let e=t[0];return this.prepareToClose().map(()=>(super.destroy(),o.ƀb.set(void 0),o.ƀii=false,this.ƀgn.trigger(e),e)).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};G.onHardReset.subscribe(()=>{Pt.ƀb.set(void 0);}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:P.ƀec(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var Ht=class extends actionsLib.IDAttachable{static{h(this,"View");}static getInstance(t){return this.$meta.entity.validateID(t)?this.$meta.viewInstances.get(t):void 0}static getInstanceOrFail(t){if(!this.$meta.entity.validateID(t))throw new Error(`View: getInstance is called with entity id: "${t}", that is not belonging to the class: "${this.$meta.entity}"`);let i=this.$meta.viewInstances.get(t);if(!i)throw new Error(`View: getInstanceOrFail is called with entity id: "${t}", that is not found!`);return i}constructor(){super(),this.attachToRoot(),this.ƀcx=rt.entityID,this.ƀei().set(this.ƀcx,this);}destroy(){this.destroyed||(super.destroy(),this.ƀei().delete(this.ƀcx));}update(t,e){}ƀei(){return this.constructor.$meta.viewInstances}};var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return helpersLib.Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new helpersLib.Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new W__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Sr=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},J=new U,St=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return J.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return J.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return J.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return J.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return J.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return J.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return J.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return J.trigger("subscribeToPhysicsStep",t,e)}};St=Sr([d()],St);var b=class o extends ${static{h(this,"PhysicsEntity");}static{this.ƀhb=new Map;}static{this.ƀhi=new Map;}static getFromP2BodyID(t){return o.ƀhb.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhb.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhi.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhi.values())}get area(){return this.ƀu}get mass(){return this.ƀgd}get collisions(){return this.ƀay}constructor(t,e,i){super(),this.ƀgo=new actionsLib.Action,this.onCollision=this.ƀgo.notifier,this.type="dynamic",this.ƀu=0,this.ƀgd=0,this.ƀay=[],this.physicsWorldID=t,this.ƀhk=P.get(St);let r=this.ƀhk.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhk.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀhj=this.ƀhk.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhl=this.ƀhk.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhk.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgd=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhk.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhb.set(this.p2Body.id,this),o.ƀhi.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhk.removeBody(this.physicsWorldID,this.p2Body),o.ƀhb.delete(this.p2Body.id),o.ƀhi.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀhj,this.ƀhl,t.ƀhj,t.ƀhl)}ƀis(t){this.ƀay=t,t.length>0&&this.ƀgo.trigger(t);}};var Wt=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new helpersLib.Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:helpersLib.Vector.zero,rotationalSpeed:0}}};var Xe=class extends ${static{h(this,"MovableEntity");}constructor(){super(),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),y.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀjk(t,e);}).attach(this);}ƀjk(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new helpersLib.Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ke=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.rotation=new actionsLib.Variable(helpersLib.Radian.get0),this.velocity=new actionsLib.Variable(helpersLib.Vector.zero),this.rotationalSpeed=new actionsLib.Variable(0),this.ƀez=false,this.ƀfa=false,this.ƀfc=false,this.ƀfb=false,this.ƀhf(),this.ƀfx(),P.get(St).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjk(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀjk(t,e){this.ƀez=true,this.ƀfa=true,this.ƀfc=true,this.ƀfb=true,this.ƀhf();}ƀhf(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new helpersLib.Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀfx(){this.position.subscribe(t=>{this.ƀez?this.ƀez=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfa?this.ƀfa=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfb?this.ƀfb=false:this.p2Body.angularVelocity=t;}).attach(this);}};var Ze=10.8,Qe=10.01;exports.PhysicsShapeType=void 0;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(exports.PhysicsShapeType||(exports.PhysicsShapeType={}));var st="border";var Y=class{static{h(this,"AnimationInterpolationFunctions");}static boomerangTime(t){return 1-Math.abs(t-.5)*2}static lineer(t){return t}static easeIn(t){return Math.pow(t,2)}static easeOut(t){return 1-Math.pow(1-t,2)}static easeInOut(t){return t<.5?2*t*t:(t-=1,1-2*t*t)}static easeInOutCubic(t){let e=2*t-2;return t<.5?4*Math.pow(t,3):(t-1)*Math.pow(e,2)+1}},Rr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return Y.lineer(t)}},Ir=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return Y.easeIn(t)}},Ar=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return Y.easeOut(t)}},Or=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return Y.easeInOut(t)}},Mr=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return Y.easeInOutCubic(t)}},Ai=class{static{h(this,"AnimationFlicker");}start(){this.ƀjw=new Array(10).fill(0),helpersLib.Random.integerBetween(0,9),this.ƀjw[helpersLib.Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(helpersLib.Random.integerBetween(0,9),this.ƀjw[helpersLib.Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(helpersLib.Random.integerBetween(0,9),this.ƀjw[helpersLib.Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀjw[e]}},S=class{static{h(this,"Animations");}static{this.lineer=new Rr;}static{this.easeIn=new Ir;}static{this.easeOut=new Ar;}static{this.easeInOut=new Or;}static{this.easeInOutCubic=new Mr;}};exports.ReAnimateHandlingType=void 0;(function(o){o[o.ThrowError=1]="ThrowError",o[o.IgnoreNewAnimation=2]="IgnoreNewAnimation",o[o.CompletePrevious=3]="CompletePrevious";})(exports.ReAnimateHandlingType||(exports.ReAnimateHandlingType={}));exports.AnimationsCompletionHandlingType=void 0;(function(o){o[o.ReturnToOriginal=1]="ReturnToOriginal",o[o.StayInCurrentState=2]="StayInCurrentState",o[o.JumpToEnd=3]="JumpToEnd",o[o.Loop=4]="Loop";})(exports.AnimationsCompletionHandlingType||(exports.AnimationsCompletionHandlingType={}));var A=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdj(t){let e=o.ƀk.get(t);return e||(e=new helpersLib.MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀgx!==void 0}get target(){return this.ƀjn}get value(){return this.ƀkf||(this.ƀkf=new actionsLib.Variable(this.ƀjn)),this.ƀkf.notifier}constructor(t,e,i){this.ƀfl=false,this.ƀiz=false,this.ƀjn=t,this.ƀha={duration:200,animation:S.lineer,reAnimateHandling:exports.ReAnimateHandlingType.ThrowError,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState,...i},this.ƀl=helpersLib.Comparator.isArray(e)?e:[e],this.ƀfy(t,this.ƀl);}animate(t,e){let i={...this.ƀha,...e};if(this.ƀgx)switch(i.reAnimateHandling){case exports.ReAnimateHandlingType.ThrowError:throw new Error("Animator: new animation triggered while another is not complete yet.");case exports.ReAnimateHandlingType.IgnoreNewAnimation:return actionsLib.SingleEvent.instant();case exports.ReAnimateHandlingType.CompletePrevious:this.ƀit(i.completionHandling,this.ƀgx.ƀhu,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return actionsLib.SingleEvent.create(s=>{this.ƀfl&&(this.ƀiz=true);let n=this.ƀl.reduce((c,p)=>(c[p]={ƀjh:this.ƀjn[p],ƀjp:t[p]},c),{}),a={ƀcs:i.duration,ƀct:0,ƀhu:n,ƀbf:i.completionHandling,ƀm:i.animation,ƀbe:s};if(a.ƀbf!==exports.AnimationsCompletionHandlingType.Loop&&this.ƀfj(a)){this.ƀgx=void 0,s();return}else a.ƀm.start();let l=this.ƀgx;return this.ƀgx=a,this.ƀcv(),l?.ƀbe(),()=>{this.ƀgx===a&&(this.ƀjn instanceof actionsLib.Attachable&&this.ƀjn.destroyed||this.ƀit(a.ƀbf,a.ƀhu,true),this.ƀgx=void 0,this.ƀkc?.destroy(),this.ƀkc=void 0);}})}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r]&&(e=true,this.ƀjn[r]=t[r]);}e&&this.ƀkf?.set(this.ƀjn),this.ƀgx?.ƀbe();}completeAnimation(t){if(this.ƀgx){t=t??this.ƀgx.ƀbf,this.ƀit(t,this.ƀgx.ƀhu,true);let e=this.ƀgx.ƀbe;this.ƀgx=void 0,e();}}ƀcv(){this.ƀkc||(this.ƀkc=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfl=true;try{let e=this.ƀgx;if(!e)return;e.ƀct+=t.delta;let i=e.ƀct>=e.ƀcs;if(i)if(e.ƀbf===exports.AnimationsCompletionHandlingType.Loop)e.ƀct%=e.ƀcs,e.ƀm.start(),i=!1;else {this.ƀit(e.ƀbf,e.ƀhu,!1),this.ƀgx=void 0,e.ƀbe(),this.ƀgx||(this.ƀkc?.destroy(),this.ƀkc=void 0);return}if(!i){let r=e.ƀm.multiplierFunction(e.ƀct/e.ƀcs),s=!1;for(let n=0;n<this.ƀl.length;n++){let a=this.ƀl[n],l=e.ƀhu[a],p=(l.ƀjp-l.ƀjh)*r+l.ƀjh;p!==this.ƀjn[a]&&(s=!0,this.ƀjn[a]=p);}s&&this.ƀkf?.set(this.ƀjn);}}finally{this.ƀfl=false,this.ƀiz&&(this.ƀiz=false,this.ƀkc?.destroy(),this.ƀkc=void 0,this.ƀcv());}}).attachToRoot());}ƀfj(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjn[i]!==t.ƀhu[i].ƀjp)return false}return true}ƀit(t,e,i){switch(t){case exports.AnimationsCompletionHandlingType.ReturnToOriginal:this.ƀif(e);break;case exports.AnimationsCompletionHandlingType.StayInCurrentState:i||this.ƀfo(e);break;case exports.AnimationsCompletionHandlingType.JumpToEnd:this.ƀfo(e);break;case exports.AnimationsCompletionHandlingType.Loop:this.ƀif(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀif(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjh&&(e=true,this.ƀjn[r]=t[r].ƀjh);}e&&this.ƀkf?.set(this.ƀjn);}ƀfo(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjp&&(e=true,this.ƀjn[r]=t[r].ƀjp);}e&&this.ƀkf?.set(this.ƀjn);}ƀfy(t,e){let i=o.ƀdj(t);for(let r of e){if(i.has(r))throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(t,void 0,2)}", Property: "${r}"`);i.set(r,this);}}};exports.ContainerEventType=void 0;(function(o){o.Click="click",o.MouseOver="mouseover",o.MouseOut="mouseout",o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerUpOutside="pointerupoutside",o.PointerMove="pointermove",o.PointerCancel="pointercancel",o.PointerOver="pointerover",o.PointerOut="pointerout",o.PointerEnter="pointerenter",o.PointerLeave="pointerleave",o.Added="added",o.Removed="removed",o.Update="update",o.Change="change";})(exports.ContainerEventType||(exports.ContainerEventType={}));exports.Cursor=void 0;(function(o){o.Default="default",o.Pointer="pointer";})(exports.Cursor||(exports.Cursor={}));var ue=class extends actionsLib.IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgh=false,this.ƀdc=false,this.ƀig=1,this.ƀw=1,this.pixiContainer=new V__namespace.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new helpersLib.Vector(this.pixiContainer.width,this.pixiContainer.height)}setSize(t){return this.pixiContainer.width=t.x,this.pixiContainer.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.pixiContainer.getLocalBounds(),r=new helpersLib.Vector(this.pixiContainer.scale.x,this.pixiContainer.scale.y),s=new helpersLib.Vector(i.x,i.y).multiply(r),n=new helpersLib.Vector(i.width,i.height).multiply(r),a=s.add(n.multiply(e.holdFrom));t=t.subtract(a);}return e?.round!==false&&(t=t.round({rollHalfsDown:true})),this.position=t,this}get position(){return new helpersLib.Vector(this.pixiContainer.x,this.pixiContainer.y)}set position(t){this.pixiContainer.position=t;}get x(){return this.pixiContainer.x}set x(t){this.pixiContainer.x=t;}get y(){return this.pixiContainer.y}set y(t){this.pixiContainer.y=t;}on(t){return actionsLib.Sequence.create(e=>{let i=h(r=>e(),"handle");return this.pixiContainer.on(t,i),()=>this.pixiContainer.off(t,i)})}setRotation(t){return this.rotation=t,this}get rotation(){return new helpersLib.Radian(this.pixiContainer.rotation)}set rotation(t){this.pixiContainer.rotation=t.value;}get rotationValue(){return this.rotation.value}set rotationValue(t){this.rotation=new helpersLib.Radian(t);}setZIndex(t){return this.zIndex=t,this}get zIndex(){return this.pixiContainer.zIndex}set zIndex(t){this.pixiContainer.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new helpersLib.Radian(this.pixiContainer.skew.x)}set skewX(t){this.pixiContainer.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new helpersLib.Radian(this.pixiContainer.skew.y)}set skewY(t){this.pixiContainer.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.pixiContainer.sortableChildren}set sortableChildren(t){this.pixiContainer.sortableChildren=t;}setAlpha(t){return this.pixiContainer.alpha=t,this}get alpha(){return this.pixiContainer.alpha}set alpha(t){this.pixiContainer.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.pixiContainer.interactive}set interactive(t){t?this.pixiContainer.eventMode="dynamic":this.pixiContainer.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.pixiContainer.cursor}set cursor(t){this.pixiContainer.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.pixiContainer.addChild(t.pixiContainer),this.pixiContainer.mask=t.getMask(),this.ƀgb=t):(this.ƀgb&&this.pixiContainer.removeChild(this.ƀgb.pixiContainer),this.pixiContainer.mask=null),this}hitTest(t){if(this.pixiContainer.parent)if(this.pixiContainer.hitArea){let e=this.pixiContainer.toLocal(t);return this.pixiContainer.hitArea.contains(e.x,e.y)}else return this.pixiContainer.getBounds().contains(t.x,t.y);else return false}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgh}set mirror(t){this.ƀgh=t,this.ƀke();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdc}set flip(t){this.ƀdc=t,this.ƀke();}setScale(t){return this.scale=t,this}get scale(){return this.ƀig}set scale(t){this.ƀig=t,this.ƀke();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀke();}ƀke(){this.pixiContainer.scale.set(this.ƀig,this.ƀig),this.ƀw<1?this.pixiContainer.scale.x*=this.ƀw:this.ƀw>1&&(this.pixiContainer.scale.y/=this.ƀw),this.ƀgh&&(this.pixiContainer.scale.x*=-1),this.ƀdc&&(this.pixiContainer.scale.y*=-1);}};var O=2;exports.BlendMode=void 0;(function(o){o[o.Normal=0]="Normal",o[o.Add=1]="Add",o[o.Screen=3]="Screen",o[o.Luminosity=16]="Luminosity",o[o.ColorDodge=7]="ColorDodge";})(exports.BlendMode||(exports.BlendMode={}));var fe=class{static{h(this,"GaussianValuesHelper");}static ƀdh(t,e){let i=e*e,r=1/(helpersLib.PI_360*i),s=-(t*t)/(2*i);return r*Math.exp(s)}static getValuesForLinearSamplingPascal(t){let e=t*2,i=Math.pow(2,e),r=.005*i,s=helpersLib.NumberHelper.pascalTriangleRow(e).slice(t).filter(l=>{if(l<r)i-=l*2;else return true}),n=1/i,a=s.map(l=>l*n);return this.ƀbr(a)}static getValuesForLinearSamplingGauss(t){if(t===0)return [{offset:0,multiplier:1}];if(t===1)return [{offset:0,multiplier:.5},{offset:1,multiplier:.25}];{let e=helpersLib.ArrayHelper.createIntegerArray(Math.ceil(t*.75)).map(r=>this.ƀdh(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbr(e)}}static ƀbr(t){let e=[{offset:0,multiplier:t[0]}];for(let i=1;i<t.length-1;i+=2){let r=t[i]+t[i+1],s=i+t[i+1]/r;e.push({offset:s,multiplier:r});}if(t.length%2===0){let i=t[t.length-1],r=t.length-1;e.push({offset:r,multiplier:i});}return e}};var Di=class ti extends V__namespace.Filter{static{h(this,"BlurFilterPass");}static ƀeh(){return `
|
|
2
2
|
attribute vec2 aVertexPosition;
|
|
3
3
|
attribute vec2 aTextureCoord;
|
|
4
4
|
|
|
@@ -64,4 +64,4 @@
|
|
|
64
64
|
highestAlpha = centerColor.a;`,e+=`
|
|
65
65
|
|
|
66
66
|
gl_FragColor = vec4(color, 1.0) * highestAlpha;
|
|
67
|
-
}`,e}constructor(t,e){if(super(o.ƀeh(),o.ƀdq(t*O)),this.ƀcy=t,this.resolution=O,this.ƀcy=t*O,this.ƀcy<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcy>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀcy)||(this.ƀcy=Math.floor(this.ƀcy));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcy*this.ƀcy,this.padding=this.ƀcy;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*O),1/(e.height*O)]),t.applyFilter(this,e,i,r);}};var Te=class extends V__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=O;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀcz=new Ce(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Et(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=V__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀcz.apply(t,e,s,V__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀek=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbd(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀds(t.texture,s,r.expand,r.color,i),a=new V__namespace.Sprite(n);return this.ƀiu(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀds(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀek.has(n))return o.ƀek.get(n);{let a=this.ƀdt(t,e,i,r);return o.ƀek.set(n,a),a}}else return this.ƀdt(t,e,i,r)}static ƀdt(t,e,i,r){let s=new V__namespace.Sprite(t);this.ƀdb(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀiu(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdb(t,e){if(t.isSprite){let s=new V__namespace.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbd(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};G.onHardReset.subscribe(()=>{Zt.ƀek.clear();}).attachToRoot();var X=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=w.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.pixiContainer,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:V__namespace.SCALE_MODES.LINEAR,multisample:V__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,boundingShapes:void 0,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀju=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjd=t,this.pixiSprite=new V__namespace.Sprite(M.getAsset(t.id)),this.pixiContainer.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgc?.destroy(),this.ƀak?.destroy(),this.ƀjd.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjd.id),this.ƀhq&&M.destroyAsset(this.ƀhq.texture.id)),this.ƀhq&&!this.ƀhq.destroyed&&this.ƀhq.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀju}set textureScale(t){this.ƀju=t,this.pixiSprite.scale.set(t);}get size(){return new helpersLib.Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀjd.boundingShapes&&!this.pixiContainer.hitArea&&(this.pixiContainer.hitArea=new we(this.ƀjd.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀjd.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===V__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=V__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=V__namespace.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new V__namespace.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀhq)return this.ƀhq.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhq)this.ƀhq.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀjd.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhq&&(this.ƀhq.destroy(),this.ƀhq=void 0),t&&(this.ƀhq=Zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjd.destroyAssetOnDestroy),this.ƀhq.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhq.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.pixiContainer.addChild(this.ƀhq)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbt().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgc){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgc=this.ƀbt(),this.ƀgc.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgc.pixiSprite.renderable=false,this.ƀgc.displayParent(this);}return this.ƀgc}ƀbt(){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀjd.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.pixiContainer);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}};var Ee=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=helpersLib.Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,m=Math.floor(c/p),g=c-p*m;m>=1&&g<i.dashLength&&(g+=p,m--);let E=s.normalize(g/2),vt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(E)}),l=l.add(E),m>0){let ne=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(vt),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(vt),a.push({from:l,to:l.add(E)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcr=new Map;}static createArrow(t,e){let i=new V__namespace.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new V__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:helpersLib.ColorHelper.white,...i},s=new V__namespace.Graphics;return s.lineStyle(r.width,r.color),Ee.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new V__namespace.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(helpersLib.ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new V__namespace.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=helpersLib.ColorHelper.white){let i=new V__namespace.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new V__namespace.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new V__namespace.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new V__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new V__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new V__namespace.Graphics,s=new helpersLib.Radian(helpersLib.PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.pixiContainer.addChild(t),this.pixiGraphics=t,this.ƀam=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀam,cache:false,...t},i=this.ƀee(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},boundingShapes:void 0,destroyAssetOnDestroy:!e.cache},s=new X(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀee(t,e){if(e){let i=o.ƀcr.get(t);return i||(i=this.ƀcf(),o.ƀcr.set(t,i)),i}else return this.ƀcf()}ƀcf(){let t=w.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {assetID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var ai=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀhr=new V__namespace.Graphics,this.ƀhr.beginFill(0,1e-9),this.ƀhr.drawRect(0,0,t.x,t.y),this.ƀhr.endFill(),this.pixiContainer.addChild(this.ƀhr);}destroy(){this.destroyed||(super.destroy(),this.ƀhr.destroy());}};var Ot=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:helpersLib.ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:helpersLib.Radian.get60,distance:10,color:helpersLib.ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:helpersLib.ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return {fontFamily:e.fontFamily,fill:helpersLib.ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r}}};var Ie=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=scriptEngineLib.RichTextSeparator.process(t,i),s=this.ƀfe(r,e),n=this.ƀs(s);return this.ƀjb(n)}static ƀfe(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Ot.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdo(a.tags,e,i),p=s(l,c),m=V__namespace.TextMetrics.measureText(" ",new V__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdo(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbb(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbb(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀjb(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀjc(s.text).map(a=>{let l=new V__namespace.TextStyle(s.pixiStyle),c=V__namespace.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀjc(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Ae=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new helpersLib.Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new helpersLib.Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀkr(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀkr(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀkr(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀci.length===0}get remainingWidth(){return this.ƀkq-this.ƀck}constructor(t,e){if(this.ƀkq=t,this.ƀfu=[],this.ƀci=[],this.ƀck=0,this.ƀft=new helpersLib.Vector(0,0),this.ƀcj=0,this.ƀew=e?.horizontalAlignment??"left",this.ƀki=e?.verticalAlignment??"bottom",e?.rectangleCutOption){if(e.rectangleCutOption.position.x<0||e.rectangleCutOption.position.x>=this.ƀkq||e.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcl={direction:e.rectangleCutOption.direction,rectangle:this.ƀbp(e.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcj,t.y),i=this.ƀdw(this.ƀft.y,this.ƀft.y+e);return this.ƀck+t.x<=i}insertWord(t){let e=Math.max(this.ƀcj,t.style.height);if(this.ƀci.length===0){let i=this.ƀdx(this.ƀft.y,this.ƀft.y+e);this.ƀft=new helpersLib.Vector(i,this.ƀft.y),this.ƀck=this.ƀft.x;}this.ƀci.push({chunk:t,position:new helpersLib.Vector(this.ƀck,this.ƀft.y)}),this.ƀcj=e,this.ƀck+=t.style.width;}newLine(){let t=this.ƀft.y+this.ƀcj,e=this.ƀdx(t,t);this.ƀdd(),this.ƀft=new helpersLib.Vector(e,t),this.ƀck=this.ƀft.x,this.ƀcj=0;}print(){return this.ƀdd(),this.ƀfu}ƀdd(){this.ƀci.length>0&&(this.ƀfu.push(this.ƀg(this.ƀci)),this.ƀci=[]);}ƀg(t){return t=this.ƀkk(t),t=this.ƀey(t),t}ƀey(t){if(this.ƀew==="left")return t;let e=this.ƀft.y+this.ƀcj,i=this.ƀdx(this.ƀft.y,e),s=this.ƀdw(this.ƀft.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀew==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new helpersLib.Vector(l.position.x+a,l.position.y)},l))}ƀkk(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀki){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀdx(t,e){return this.ƀcl&&(this.ƀcl.direction==="topLeft"||this.ƀcl.direction==="bottomLeft")&&(this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀcl.rectangle.bottomRight.x:0}ƀdw(t,e){return this.ƀcl&&(this.ƀcl.direction==="topRight"||this.ƀcl.direction==="bottomRight")&&(this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(this.ƀkq,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(this.ƀkq,e),{includeEdges:false}))?this.ƀcl.rectangle.topLeft.x:this.ƀkq}ƀbp(t){let e,i;switch(t.direction){case "topRight":e=new helpersLib.Vector(t.position.x,-1/0),i=new helpersLib.Vector(1/0,t.position.y);break;case "topLeft":e=new helpersLib.Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new helpersLib.Vector(1/0,1/0);break;case "bottomLeft":e=new helpersLib.Vector(-1/0,t.position.y),i=new helpersLib.Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new helpersLib.Rectangle(e,i)}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgg(t),t=this.ƀka(t),this.ƀav(t)}static ƀgg(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀka(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀav(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ie.process(t,e),r=new Oe(e.default.wordWrapWidth??1/0,{rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=Ae.wrapText(i,r);return Me.process(s)}};var Cs=1,$i=1/Cs,te=class extends u{static{h(this,"Text");}get ƀjs(){if(!this.ƀjt){let t=new V__namespace.TextStyle(this.ƀht);this.ƀjt=V__namespace.TextMetrics.measureText(this.ƀjr,t);}return this.ƀjt}get ascent(){return this.ƀjs.fontProperties.ascent}constructor(t,e){super(),this.ƀht=Ot.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhs.destroyed&&this.ƀhs.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀhs.anchor.x,this.ƀhs.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhs.anchor.set(t.x,t.y);}setPosition(t,e){if(e?.holdFrom){let i=this.ƀht.dropShadowDistance??0,r=new helpersLib.Vector(e.holdFrom.x*i,e.holdFrom.y*i);t=t.add(r);}return super.setPosition(t,e),this}setText(t){return this.ƀjr!==t&&(this.ƀjr=t,this.ƀia()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀht.fill!==e&&(this.ƀht.fill=e,this.ƀia()),this}ƀia(){this.ƀhs?.destroy(),this.ƀjm?.destroy(),this.ƀjm=void 0,this.ƀjt=void 0;let t=new V__namespace.TextStyle(this.ƀht);this.ƀhs=new V__namespace.Text(this.ƀjr,t),this.ƀi&&this.ƀhs.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhs.scale.set($i,$i),this.pixiContainer.addChild(this.ƀhs),this.ƀht.lineThrough&&(this.ƀjm=this.ƀe(this.ƀhs,this.ƀht.fill),this.pixiContainer.addChild(this.ƀjm));}ƀe(t,e){let i=V__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new V__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=V__namespace.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,g=0;t.style.align==="center"?g=0+(t.width-p.width)*.5:t.style.align==="right"&&(g=0+t.width-p.width),g=Math.floor(g),n.moveTo(Math.floor(g),m),n.lineTo(Math.floor(g+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var hi=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new te(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var li=class extends u{static{h(this,"UpdatableContainer");}},ci=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbv=t,this.ƀco=new Map,this.ƀha={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀco.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀha.trackBy(r,s),a;this.ƀco.has(n)?(a=this.ƀco.get(n),e.delete(n),a.update(r)):(a=this.ƀbv(r).displayParent(this).attach(this),this.ƀco.set(n,a)),this.ƀha.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀha.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀha.positioning.spacing);}),e.forEach(r=>{this.ƀco.get(r).destroy(),this.ƀco.delete(r);});}};var Dt=class o extends u{static{h(this,"Menu");}static{this.ƀjy=false;}static closeAll(){return o.ƀgz?o.ƀgz.close():actionsLib.SingleEvent.instant()}constructor(t,e){super(),this.ƀgs=new actionsLib.SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new actionsLib.SingleAction,this.onClose=this.ƀgn.notifier;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,darkeningAlpha:.3,...e};this.setZIndex(100).setAlpha(0),this.ƀo=new A(this,"alpha",{animation:S.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaa=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.darkeningAlpha).setInteractive(true).displayParent(this).attach(this),this.ƀgf=X.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(r=>{this.ƀaa.aspectRatio=r.x/r.y,this.ƀaa.scale=Math.max(r.x,r.y),this.ƀaa.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(r.multiplyNumber(.5));}).attach(this),o.ƀgz=this,this.onDestroy().tap(()=>{o.ƀgz=void 0;}).attachToRoot(),i.closeOnBackgroundClick&&this.ƀaa.on(exports.ContainerEventType.Click,()=>{o.ƀjy||this.ƀq(false);}).attach(this),this.ƀq(true);}getBoundingMask(){return this.ƀgf.getBoundingMask()}close(){return this.ƀq(false)}ƀq(t){if(o.ƀjy)throw new Error("WindowUI: cannot iterate while in transition");return o.ƀjy=true,this.ƀo.animate({alpha:t?1:0}).chain(this).tap(()=>{o.ƀjy=false,t?this.ƀgs.resolve():(this.ƀgn.resolve(),this.destroy());}).chainToRoot()}};var di=class extends ut{static{h(this,"MenuEntity");}constructor(t,e){super(),this.ƀgq=new actionsLib.SingleAction,this.onCreate=this.ƀgq.notifier,this.ƀgs=new actionsLib.SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new actionsLib.SingleAction,this.onClose=this.ƀgn.notifier,Dt.closeAll().tap(()=>{if(!Pt.getActiveScene())throw new Error("WindowEntity: constructor is called when there is no active scene!");w.pause.effect(true).attach(this),this.ƀgf=new Dt(t,e).displayParent(w.camera.layers.foregroundScreen).attach(this),this.ƀgq.resolve(this.ƀgf),this.ƀgf.onOpen.subscribe(()=>this.ƀgs.resolve()).attach(this),this.ƀgf.onClose.subscribe(()=>{this.destroy(),this.ƀgn.resolve();}).attach(this);}).attach(this);}getMenuEvents(){return {onOpen:this.onOpen.toSingleEvent().destroyIfNotAttached(),onClose:this.onClose.toSingleEvent().destroyIfNotAttached()}}close(){if(this.ƀgf){let t=this.onClose.toSingleEvent().destroyIfNotAttached();return this.ƀgf.close(),t}else return this.onCreate.asyncMapQueue(()=>this.close()).singleChain(this)}};var Rs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Is=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class mt{static{h(this,"MouseService");}get initialMouseMoveHappened(){return this.ƀfg.value}getStagePosition(){return this.ƀje.value}getScreenPosition(){return this.ƀik.value}getMainButtonState(){return this.ƀfz.value}getSecondaryButtonState(){return this.ƀiq.value}constructor(){this.ƀfg=new actionsLib.Variable(false),this.onInitialMouseMove=this.ƀfg.notifier,this.ƀje=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀje.notifier,this.ƀik=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀik.notifier,this.ƀfz=new actionsLib.Variable(false),this.mainButtonState=this.ƀfz.notifier,this.ƀiq=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀiq.notifier,this.ƀjf(),window.addEventListener("mousedown",t=>{t.button===0?this.ƀfz.value=true:t.button===2&&(this.ƀiq.value=true);}),window.addEventListener("mouseup",t=>{t.button===0?this.ƀfz.value=false:t.button===2&&(this.ƀiq.value=false);}),window.addEventListener("blur",()=>{this.ƀfz.value=false,this.ƀiq.value=false;});}ƀjf(){let t=helpersLib.Vector.zero;window.addEventListener("mousemove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfg.value=true;}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀik.value=t;}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀik.value);e.isEqual(this.ƀje.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:this.ƀik.value.x,clientY:this.ƀik.value.y,pointerType:"mouse"})):this.ƀje.value=e;}).attachToRoot();}};exports.MouseService=Rs([d(),Is("design:paramtypes",[])],exports.MouseService);var ie=class extends u{static{h(this,"MouseWheelListenerUI");}constructor(t){super(),this.ƀgw=new actionsLib.Action,this.onWheel=this.ƀgw.notifier,this.ƀer=(e=>{let i=P.get(exports.MouseService).getScreenPosition(),r=this.ƀkp.getBounds();i.x>=r.x&&i.x<=r.x+r.width&&i.y>=r.y&&i.y<=r.y+r.height&&this.ƀgw.trigger(e.deltaY);}).bind(this),this.ƀkp=new V__namespace.Graphics,this.ƀkp.beginFill(0,1e-9),this.ƀkp.drawRect(0,0,t.x,t.y),this.ƀkp.endFill(),this.pixiContainer.addChild(this.ƀkp),window.addEventListener("wheel",this.ƀer);}destroy(){this.destroyed||(super.destroy(),this.ƀkp.destroy(),window.removeEventListener("wheel",this.ƀer));}};var Ms=.65,Ds=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀio}get contentSize(){return this.ƀbi.size.ceil()}constructor(t,e,i,r){this.ƀbi=t,this.ƀv=e,this.ƀhc=i,this.ƀja=r,this.ƀfh=false,this.ƀio=e-i*2,this.ƀbi.y=i,this.ƀjn=i;}onWheel(t){this.setTarget(this.ƀjn-t*Ms);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjn=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀhc-this.contentSize.y,this.ƀhc);}jumpToTarget(){this.ƀbi.y=this.ƀjn;}update(t){let e=this.contentSize;if(e.y<=this.ƀio){switch(this.ƀja){case "start":this.ƀjn=this.ƀhc;break;case "center":this.ƀjn=(this.ƀv-e.y)*.5;break;case "end":this.ƀjn=this.ƀv-e.y-this.ƀhc;break;default:{this.ƀja;throw new Error(`Unexpected case! "${this.ƀja}"`)}}this.ƀfh||(this.ƀbi.y=this.ƀjn);}this.ƀfh=true;let i=this.ƀjn-this.ƀbi.y;this.ƀbi.y=this.ƀbi.y+i*Ds*t;}};var fi=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},gt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcr=new Map;}constructor(t,e,i,r=exports.ScrollDirection.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===exports.ScrollDirection.Horizontal?this.ƀbz(e,i,s):this.ƀcg(e,i,s),this.ƀgc=X.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgc);}ƀcg(t,e,i){e>0&&this.ƀbw(new helpersLib.Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x,t.y-e*2),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀbz(t,e,i){e>0&&this.ƀbw(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(0,t.y),{round:false}).setRotation(helpersLib.Radian.get270).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x-e*2,t.y),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbw(t){let i={id:this.ƀbx(t.y),scale:1,size:t,anchor:{x:0,y:0},boundingShapes:void 0};return new X(i,{textureSize:t,ignoreAnchor:true})}ƀbx(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcr.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new fi;helpersLib.ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=V__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcr.set(e,i);}else throw new Error("Canvas context is null")}return i}};var _s=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbj}get contentSize(){return this.ƀip.contentSize}constructor(t,e={}){super();let i={padding:_s,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new gt(r,t,i.padding).attach(this);let s=new u().displayParent(r).attach(this);this.ƀip=new Ge(s,t.y,i.padding,i.smallContentAlign),this.ƀbj=new helpersLib.Vector(t.x,this.ƀip.scrollHeight),new ie(t).displayParent(r).attach(this).onWheel.subscribe(a=>this.ƀip.onWheel(a)).attach(this),y.afterSceneUpdateAction.subscribe(a=>this.ƀip.update(a.delta)).attach(this),this.addChildTo=s;}scrollToTop(t){this.ƀip.scrollToTop(),t?.instant&&this.ƀip.jumpToTarget();}scrollToBottom(t){this.ƀip.scrollToBottom(),t?.instant&&this.ƀip.jumpToTarget();}};var Fs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ls=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class gi{static{h(this,"KeyboardService");}constructor(){this.ƀfp=new actionsLib.Action,this.keyPressed=this.ƀfp.notifier,this.ƀfq=new actionsLib.Action,this.keyReleased=this.ƀfq.notifier,this.ƀfw=new Set,this.ƀfv=new Set,window.addEventListener("keydown",t=>{this.ƀfw.add(t.key),this.ƀfv.add(t.key),!t.repeat&&this.ƀfp.trigger(t.key);}),window.addEventListener("keyup",t=>{this.ƀfw.delete(t.key),this.ƀfq.trigger(t.key);}),window.addEventListener("blur",()=>{this.ƀfw.clear();}),y.afterSceneUpdateAction.subscribe(()=>{this.ƀfv.clear();}).attachToRoot();}isKeyDown(t){return this.ƀfw.has(t)}isKeyJustPressed(t){return this.ƀfv.has(t)}};exports.KeyboardService=Fs([d(),Ls("design:paramtypes",[])],exports.KeyboardService);var Vs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ns=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class yi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀde}get lastFocusedPosition(){return this.ƀfs}constructor(t){this.ƀgi=t,this.ƀgu=new actionsLib.Action,this.onTargetFocus=this.ƀgu.notifier,this.ƀjx=0,this.ƀjz=false,this.ƀde=false,this.ƀfs=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀkb(e.delta)).attachToRoot();}ƀkb(t){if(this.ƀgj){let e=this.ƀed(this.ƀgi.getStagePosition(),this.ƀgj);this.ƀhe===void 0?this.ƀhe=e:this.ƀau(e,t);}this.ƀgj=this.ƀgi.getStagePosition();}ƀau(t,e){this.ƀhe-t>10?(this.ƀjx=Math.max(250,this.ƀjx),this.ƀjz=true):this.ƀjx>1e3&&(this.ƀjz=true);let i=this.ƀjx>=300&&this.ƀjz;this.ƀfn(i,t,e);}ƀfn(t,e,i){(t||e>this.ƀhe)&&(this.ƀhe=e),t?(this.ƀjz=false,this.ƀjx=0,this.ƀde=true,this.ƀfs=this.ƀgi.getStagePosition(),this.ƀgu.trigger(this.ƀfs)):(this.ƀjx+=i,this.ƀde=false);}ƀed(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=Vs([d(),Ns("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var x;(function(o){o[o.Hidden=1]="Hidden",o[o.Visible=2]="Visible",o[o.Appearing=3]="Appearing",o[o.Disappearing=4]="Disappearing",o[o.DisappearToChange=5]="DisappearToChange";})(x||(x={}));var _e=class extends actionsLib.Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgt=new actionsLib.Action,this.ƀgv=new actionsLib.Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀj.value=0,this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀo.completeAnimation(),this.ƀn=t!==void 0?x.Visible:x.Hidden,this.ƀhv=void 0;let i=t!==void 0?1:0,r=this.ƀji!==t;r&&(this.ƀji=t,this.ƀgt.trigger(this.ƀji)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀgv.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):(this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji)));break;case x.Disappearing:t===this.ƀji?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀhv=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0):t===this.ƀji?(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀhv&&(this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀgv.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀhv!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀji=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀhv===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀji=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};var Zi=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbv=t;let i={duration:200,animation:S.easeInOut,...e};this.alpha=0,this.ƀjj=new _e(i).onStateChange(r=>{this.ƀbi?.destroy(),this.ƀbi=void 0,r!==void 0&&(this.ƀbi=new u().displayParent(this).attach(this),this.ƀbv({state:r,container:this.ƀbi}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjj.setState(t,e),this}};var I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var Fe=class extends actionsLib.Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,nextState:this.ƀgl,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgt=new actionsLib.Action,this.ƀgv=new actionsLib.Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀji===void 0)this.ƀji=t,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀji=t,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀji&&(this.ƀn=I.Transitioning,this.ƀgl=t,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case I.Transitioning:t!==this.ƀgl&&(t===this.ƀji?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;case I.Reverting:t!==this.ƀji&&(t===this.ƀgl?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀji=this.ƀgl,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀji=this.ƀgl,this.ƀgl=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀji===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var C;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(C||(C={}));var Le=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=C.Idle,this.ƀgt=new actionsLib.Action,this.ƀgv=new actionsLib.Action,this.ƀha={duration:500,animation:S.easeInOutCubic,...t},this.ƀjj=new Fe({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((e,i)=>this.ƀep(e,i)).onValueChange(e=>this.ƀeq(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀff===void 0?(this.ƀff=t,this.ƀgt.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀjj.setState(t,e)):this.ƀff!==t?this.ƀgk!==t?this.ƀn===C.Idle?(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀgk=t,this.ƀgt.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀgk}),this.ƀjj.setState(t,e)):this.ƀjj.setState(t,e):this.ƀn===C.Reverting&&this.ƀgk===t&&(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀjj.setState(t,e)):(this.ƀn===C.TransitionForward||this.ƀn===C.TransitionBackward)&&(this.ƀn=C.Reverting,this.ƀjj.setState(t,e));}ƀep(t,e){switch(this.ƀff!==void 0&&this.ƀff!==t&&this.ƀff!==e&&this.ƀgt.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgk!==t&&this.ƀgk!==e&&this.ƀgt.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀgk}),e!==void 0&&e!==this.ƀff&&e!==this.ƀgk&&this.ƀgt.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀn){case C.Idle:break;case C.TransitionForward:case C.TransitionBackward:e===void 0?(this.ƀn=C.Idle,this.ƀff=this.ƀgk,this.ƀgk=void 0):this.ƀff!==t&&this.ƀen(t,e);break;case C.Reverting:e===void 0?(this.ƀn=C.Idle,this.ƀgk=void 0):this.ƀff!==e&&this.ƀen(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀeq(t){let e=1;(this.ƀn===C.TransitionBackward||this.ƀn===C.Reverting&&this.ƀff!==void 0&&this.ƀgk!==void 0&&this.ƀff>this.ƀgk)&&(e=-1),(this.ƀn===C.Idle||t!==0)&&this.ƀgv.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgv.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgk});}ƀen(t,e){this.ƀff=t,this.ƀgk=e,this.ƀgv.trigger({value:0,index:this.ƀff}),this.ƀn=this.ƀff<this.ƀgk?C.TransitionForward:C.TransitionBackward;}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e.value,e.index)).attach(this),this}};exports.ScrollDirection=void 0;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(exports.ScrollDirection||(exports.ScrollDirection={}));var wi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbv=t,this.ƀcm="x",this.ƀbk=new Map,this.ƀha={duration:300,animation:S.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀha.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀha.size.x+this.ƀha.margin*2,this.ƀha.size.y):new helpersLib.Vector(this.ƀha.size.x,this.ƀha.size.y+this.ƀha.margin*2),r=new u().setPosition(this.ƀha.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀha.margin,0):new helpersLib.Vector(0,-this.ƀha.margin),{round:false}).displayParent(this).attach(this);this.ƀca(i,this.ƀha.margin,this.ƀha.direction,r),this.ƀcm=this.ƀha.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀjj=new Le({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbk.set(n,a),this.ƀbv({index:n,container:a});}else {let a=this.ƀbk.get(n);a&&(a.destroy(),this.ƀbk.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbk.get(n);if(a){let l={x:0,y:0};l[this.ƀcm]=i[this.ƀcm]*s+this.ƀha.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjj.setIndex(t,e),this}ƀca(t,e,i,r){new gt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},er=class extends wi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var wt=class{static{h(this,"VectorSet");}constructor(){this.ƀkg=new Map;}add(t){let e=this.ƀkg.get(t.x);e||(e=new Set,this.ƀkg.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀkg.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀkg.get(t.x);return e?e.delete(t.y):false}};var xi=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var B=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new helpersLib.Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new helpersLib.Vector(.5,.5)).multiplyNumber(e)}};var re=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new helpersLib.Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=B.areaToGridArea(e,i);if(this.ƀat(t,s))return helpersLib.Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=helpersLib.Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=helpersLib.Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new helpersLib.Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new wt,s=new helpersLib.Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new helpersLib.Rectangle(n,n.add(i));if(this.ƀat(t,a))return helpersLib.Vector.fromTo(e,n);t.getNeighborPositions(n,helpersLib.GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀat(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new helpersLib.Vector(r,i)))return false;return true}};var ir=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return helpersLib.Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},to=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀem=t,this.ƀjg=e,this.ƀgy=new helpersLib.BinaryHeap("min"),this.ƀax=[],this.ƀgm=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new ir(this.ƀjg,0,Number.MAX_SAFE_INTEGER);this.ƀgy.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀgy.size>0}getNeighbors(t,e){return this.ƀem.getNeighborPositions(t.position,e).filter(i=>this.ƀem.get(i)).map(i=>this.ƀgm.get(i)||this.ƀcb(i))}popLowestPathCostNode(){let t=this.ƀgy.pop();return this.ƀgy.delete(t),t.closed=true,this.ƀax.push(t),t}changeNodeCost(t,e,i,r){this.ƀgy.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀgy.add(t.pathLength,t);}getBestClosedNode(){return this.ƀax.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcb(t){let e=new ir(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgm.set(t,e),this.ƀgy.add(e.pathLength,e),e}},se=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new to(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var oe=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjo=t,this.ƀx=e,this.ƀet=this.ƀdv(this.ƀx.size),this.ƀko=new helpersLib.Grid({size:this.ƀx.size,defaultValue:this.ƀet}),this.ƀcn=new helpersLib.Grid({size:this.ƀx.size,defaultValue:void 0});let i=new wt,r=new helpersLib.Queue;for(this.ƀdk(this.ƀx.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀko.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀko.getOrFail(n);this.ƀea(n,this.ƀx).forEach(l=>{if(!i.has(l.position)){let c=this.ƀko.getOrFail(l.position),p=a+l.distance;this.ƀx.getOrFail(l.position)&&p<c&&(this.ƀko.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjo)){if(t=this.ƀko.movePositionInsideGrid(t),this.ƀcn.has(t))return this.ƀcn.get(t);{let e=this.ƀea(t,this.ƀx),i;return this.ƀko.getOrFail(t)>=this.ƀet?e.some(s=>this.ƀx.get(s.position))&&(e.some(n=>!this.ƀx.get(n.position))?i=this.ƀdp(e):i=this.ƀdl(t,e)):i=this.ƀdl(t,e),this.ƀcn.set(t,i),i}}}ƀdp(t){let e=t.filter(i=>this.ƀx.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdl(t,e){let i=e.filter(r=>this.ƀko.getOrFail(r.position)<this.ƀet).reduce((r,s)=>{let n=this.ƀko.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀet}).bestDirections;return this.ƀef(i,t)}ƀef(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀfk(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfk(t,e){let i=t.add(this.ƀkh(e));return this.ƀx.isPointWithinBounds(i)&&this.ƀx.getOrFail(i)}ƀea(t,e){return this.ƀko.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdk(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new helpersLib.Vector(r,i));return e}ƀkh(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀdv(t){return (t.x+t.y)*20}};var oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},no=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends ${static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new actionsLib.Variable(false),this.lastP2Time=new actionsLib.Variable(0),this.onPhysicsStep=new actionsLib.Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=oo([dt(),no("design:paramtypes",[helpersLib.Vector,Boolean,W__default.default.World,Map,Map,Map,Map])],v);var co=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},K=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};K=co([d()],K);var po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},uo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ve=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhh=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhh.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};Ve=po([d(),uo("design:paramtypes",[K])],Ve);var fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},nt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhh=t,this.ƀy=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀy.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Bt){return e.aabbNeedsUpdate=true,e.updateAABB(),re.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀy.get(t,e,i);return r||(r=this.ƀby(t,e,i),this.ƀy.set(t,e,i,r)),r}ƀby(t,e,i){let r=new helpersLib.Grid({size:new helpersLib.Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀhh.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdu(s,e);r.setArea(a,false);}}),r}ƀdu(t,e){let i=f.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=fo([d(),mo("design:paramtypes",[K,Ve])],nt);var wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},xo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Bt=50,Gt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhg=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Bt);let n=v.getInstanceByIDOrFail(t),a,l;helpersLib.Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhg.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let E=f.aabbToBoundingBox(l.aabb),vt=B.areaToGridArea(E,s.gridCellSize);m.setArea(vt,true);}let g=se.findPath(m,c,p,s.neighborType);return g.path=g.path.map(E=>B.gridPositionToPosition(E,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Bt){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(g.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=B.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let g=this.ƀhg.getAvilabilityGrid(n,s,r);p=new oe(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};Gt=wo([d(),xo("design:paramtypes",[nt])],Gt);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=new U;exports.PhysicsGateway=class bi{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return j.trigger("createPhysicsWorld",t)}getMapSize(t){return j.trigger("getMapSize",t)}setPaused(t,e){return j.trigger("setPaused",t,e)}hitTest(t,e){return j.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return j.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return j.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return j.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return j.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return j.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Bt){return j.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};exports.PhysicsGateway=Po([d()],exports.PhysicsGateway);var So=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Co=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Q=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀz=t,this.ƀhd=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀz.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhd.findPathDirection(t,c.position,i,r),m;p===void 0?m=T.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=T.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new A(m,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,helpersLib.ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new A(a,"alpha",{duration:n,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,helpersLib.ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let m=p.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new A(l,"alpha",{duration:a,animation:S.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new helpersLib.Radian(t.angle),n=i?.color??helpersLib.ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcq(c,n).displayParent(a).attachToRoot();}),new A(a,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcq(t,e){switch(t.type){case W__default.default.Shape.PARTICLE:throw new Error("Not implemented");case W__default.default.Shape.LINE:throw new Error("Not implemented");case W__default.default.Shape.PLANE:throw new Error("Not implemented");case W__default.default.Shape.CIRCLE:throw new Error("Not implemented");case W__default.default.Shape.CAPSULE:throw new Error("Not implemented");case W__default.default.Shape.BOX:throw new Error("Not implemented");case W__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case W__default.default.Shape.CONVEX:return this.ƀcp(t,e);default:throw new Error("Not implemented")}}ƀcp(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Q=So([d(),Co("design:paramtypes",[nt,Gt])],Q);var Ro=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Io=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ne=class{static{h(this,"HitTestService");}constructor(t){this.ƀjq=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdi(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new W__default.default.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?helpersLib.ColorHelper.red:helpersLib.ColorHelper.green;this.ƀjq.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdi(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Ro([d(),Io("design:paramtypes",[Q])],Ne);var Oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀib(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀay=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀib(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀeo(r.p2Body),r.entity.ƀis(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀeo(t){let e=f.arrayToVector(t.velocity);e.length>10.8&&(e=e.normalize(10.8),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-10.01),10.01);}ƀib(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdn(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdn(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeb(i);return {collisionDetailsA:this.ƀdm(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdm(s,i.bodyB.mass,a,c,e.area)}}ƀdm(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeb(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=Oo([d()],je);var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Do=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends Wt{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Mo([dt(),Do("design:paramtypes",[Number,Object])],He);var Bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},H=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbs(t,new helpersLib.Vector(e.x/2,-H/2),new helpersLib.Vector(e.x+H*2,H),i),this.ƀbs(t,new helpersLib.Vector(e.x/2,e.y+H/2),new helpersLib.Vector(e.x+H*2,H),i),this.ƀbs(t,new helpersLib.Vector(-H/2,e.y/2),new helpersLib.Vector(H,e.y+H*2),i),this.ƀbs(t,new helpersLib.Vector(e.x+H/2,e.y/2),new helpersLib.Vector(H,e.y+H*2),i);}ƀbs(t,e,i,r){return new He(t,{shapeDefinition:{materialName:st,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Bo([d()],We);var _o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ar=new W__default.default.Material,Fo={id:st,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},_t=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new W__default.default.Material),n.set(a.id,a);}),s.has(st))throw new Error(`Material with name ${st} cannot be defined, pick another name for the material.`);return s.set(st,ar),n.set(st,Fo),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdz(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdy(e,i.materialDefinitions)}ƀdz(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀdy(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀdr(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀdz(n.materialA,s),l=this.ƀdz(n.materialB,s);t.addContactMaterial(new W__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀdr(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀdz(s.id,r);t.addContactMaterial(new W__default.default.ContactMaterial(n,ar,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};_t=_o([d()],_t);var Lo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ft=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀge=t,this.ƀaj=e,this.ƀz=i,this.ƀaz=r,this.ƀhh=s;}createPhysicsWorld(t){let e=new W__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀge.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhh.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&y.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀaz.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjk(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjk(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀz.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjk(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀaz.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ft=Lo([d(),Vo("design:paramtypes",[_t,We,nt,je,K])],Ft);var jo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vt=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new W__default.default.RaycastResult,s=new W__default.default.Ray({mode:W__default.default.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbn(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new W__default.default.Ray({mode:W__default.default.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbn(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbn(n,e));},"callback")});return t.p2World.raycast(new W__default.default.RaycastResult,s),Array.from(r.values())}ƀbn(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Vt=jo([d()],Vt);var Ho=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},lt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};lt=Ho([d()],lt);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Nt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbo(r,t.length))}ƀbo(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:helpersLib.Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Nt=Wo([d()],Nt);var $o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Yo=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcd(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀhw.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀjq.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...E}=m;return E})}ƀcd(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(helpersLib.Radian.get90).vector,p=c.normalize(i.x);a.push(new helpersLib.Line(t,t.add(p))),a.push(new helpersLib.Line(t,t.add(p.multiplyNumber(-1))));let m=l.normalize(i.y);a.push(new helpersLib.Line(t,t.add(m))),a.push(new helpersLib.Line(t,t.add(m.multiplyNumber(-1))));let g=Math.round(i.y/Yo),E=i.y/(g*2+1)*2,vt=l.normalize(E),ne=i.x,lr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(g).forEach(pt=>{let bt=E*(pt+1),Ci=vt.multiplyNumber(pt+1),ae=c.normalize(this.ƀej(ne,lr,bt)),he=t.add(Ci);a.push(new helpersLib.Line(he,he.add(ae))),a.push(new helpersLib.Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ci.multiplyNumber(-1));a.push(new helpersLib.Line(le,le.add(ae))),a.push(new helpersLib.Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(pt=>{if(s){let bt=this.ƀhx.castClosest(n,pt,r);return {line:pt,hits:bt?[bt]:[]}}else {let bt=this.ƀhx.castAllFirstContacts(n,pt,r);return {line:pt,hits:bt}}})}ƀej(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀfd.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=$o([d(),zo("design:paramtypes",[Vt,Q,Nt,lt])],$e);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ze=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeg(i),c=this.ƀcd(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀhw.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀjq.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcd(t,e,i,r,s,n){let a=new helpersLib.Radian(helpersLib.PI_360/r),l=new helpersLib.Vector(0,-e),c=a.vector;return helpersLib.ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new helpersLib.Line(t,p)}).map(p=>{if(s){let m=this.ƀhx.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀhx.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfd.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=helpersLib.Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀfd.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeg(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ze=Xo([d(),Ko("design:paramtypes",[Vt,Q,Nt,lt])],ze);var en=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},jt=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};jt=en([d()],jt);var rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀho=t,this.ƀhd=e,this.ƀjq=i,this.ƀda=r,this.ƀcu=s,this.ƀeu=n,this.ƀhn=a,this.ƀfd=l;}createPhysicsWorld(t){return this.ƀho.createPhysicsWorld(t)}getMapSize(t){return this.ƀhn.getMapSize(t)}setPaused(t,e){this.ƀho.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀeu.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhd.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhd.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfd.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀda.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcu.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n){this.ƀjq.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=rn([q({controllerLink:j}),sn("design:paramtypes",[Ft,Gt,Q,ze,$e,Ne,jt,lt])],Pi);var on=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ke=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case exports.PhysicsShapeType.Point:return this.ƀbu(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbu(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcc(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀce(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbu(t,e,i,r,s,n){let a=new W__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcc(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new W__default.default.Convex({vertices:g.map(E=>[E.x,E.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,E)=>g+E.area,0),m=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(g=>m.addShape(g)),m.setDensity(r.density),m}ƀce(t,e,i,r,s,n){let a=new W__default.default.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ke=on([d()],ke);var nn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},an=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀho=t,this.ƀhm=e,this.ƀix=i,this.ƀhn=r,this.ƀhh=s;}createBody(t,e,i,r,s){return this.ƀix.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀhm.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀhm.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhh.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhh.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀho.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀho.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhn.subscribeToPhysicsStep(t,e)}};Si=nn([q({controllerLink:J}),an("design:paramtypes",[Ft,_t,ke,jt,K])],Si);exports.AnimationFlicker=Ai;exports.AnimationInterpolationFunctions=Y;exports.Animations=S;exports.Animator=A;exports.BORDER_MATERIAL_NAME=st;exports.BardLegendsHardReset=G;exports.Camera=Xt;exports.ClosestAvailableSpaceHelper=re;exports.Container=u;exports.ControllerDecorator=q;exports.ControllerLink=U;exports.DEFAULT_SHADER_RESOLUTION=O;exports.DeltaTime=xi;exports.DisplayObjectArray=ci;exports.Entity=$;exports.EntityDecorator=dt;exports.FadeInContent=Zi;exports.FadeInStateAnimation=_e;exports.Game=w;exports.Graphics=T;exports.ImmovablePhysicsEntity=Wt;exports.Menu=Dt;exports.MenuEntity=di;exports.MouseWheelListenerUI=ie;exports.MovableEntity=Xe;exports.MovablePhysicsEntity=Ke;exports.PathFinder=se;exports.PhysicsEntity=b;exports.Placeholder=ai;exports.PositionConversionHelper=kt;exports.ROTATIONAL_SPEED_LIMIT=Qe;exports.RichText=hi;exports.SPEED_LIMIT=Ze;exports.Scene=Pt;exports.SceneDecorator=wr;exports.ScrollAreaUI=mi;exports.ScrollMaskUI=gt;exports.Service=P;exports.ServiceDecorator=d;exports.SingletonEntity=ut;exports.SlideInContent=er;exports.SlideInContentByIndex=wi;exports.SlideStateAnimation=Le;exports.Sprite=X;exports.StateAnimation=Fe;exports.Text=te;exports.UpdatableContainer=li;exports.UpdateCycle=y;exports.VectorFieldPathFinder=oe;exports.VectorSet=wt;exports.View=Ht;exports.ViewDecorator=Ye;
|
|
67
|
+
}`,e}constructor(t,e){if(super(o.ƀeh(),o.ƀdq(t*O)),this.ƀcy=t,this.resolution=O,this.ƀcy=t*O,this.ƀcy<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcy>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀcy)||(this.ƀcy=Math.floor(this.ƀcy));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcy*this.ƀcy,this.padding=this.ƀcy;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*O),1/(e.height*O)]),t.applyFilter(this,e,i,r);}};var Te=class extends V__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=O;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀcz=new Ce(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Et(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=V__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀcz.apply(t,e,s,V__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀek=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbd(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀds(t.texture,s,r.expand,r.color,i),a=new V__namespace.Sprite(n);return this.ƀiu(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀds(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀek.has(n))return o.ƀek.get(n);{let a=this.ƀdt(t,e,i,r);return o.ƀek.set(n,a),a}}else return this.ƀdt(t,e,i,r)}static ƀdt(t,e,i,r){let s=new V__namespace.Sprite(t);this.ƀdb(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀiu(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdb(t,e){if(t.isSprite){let s=new V__namespace.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbd(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};G.onHardReset.subscribe(()=>{Zt.ƀek.clear();}).attachToRoot();var X=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=w.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.pixiContainer,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:V__namespace.SCALE_MODES.LINEAR,multisample:V__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,boundingShapes:void 0,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀju=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjd=t,this.pixiSprite=new V__namespace.Sprite(M.getAsset(t.id)),this.pixiContainer.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgc?.destroy(),this.ƀak?.destroy(),this.ƀjd.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjd.id),this.ƀhq&&M.destroyAsset(this.ƀhq.texture.id)),this.ƀhq&&!this.ƀhq.destroyed&&this.ƀhq.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀju}set textureScale(t){this.ƀju=t,this.pixiSprite.scale.set(t);}get size(){return new helpersLib.Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀjd.boundingShapes&&!this.pixiContainer.hitArea&&(this.pixiContainer.hitArea=new we(this.ƀjd.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀjd.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===V__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=V__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=V__namespace.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new V__namespace.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀhq)return this.ƀhq.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhq)this.ƀhq.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀjd.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhq&&(this.ƀhq.destroy(),this.ƀhq=void 0),t&&(this.ƀhq=Zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjd.destroyAssetOnDestroy),this.ƀhq.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhq.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.pixiContainer.addChild(this.ƀhq)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbt().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgc){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgc=this.ƀbt(),this.ƀgc.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgc.pixiSprite.renderable=false,this.ƀgc.displayParent(this);}return this.ƀgc}ƀbt(){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀjd.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.pixiContainer);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}};var Ee=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=helpersLib.Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,m=Math.floor(c/p),g=c-p*m;m>=1&&g<i.dashLength&&(g+=p,m--);let E=s.normalize(g/2),vt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(E)}),l=l.add(E),m>0){let ne=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(vt),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(vt),a.push({from:l,to:l.add(E)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcr=new Map;}static createArrow(t,e){let i=new V__namespace.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new V__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:helpersLib.ColorHelper.white,...i},s=new V__namespace.Graphics;return s.lineStyle(r.width,r.color),Ee.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new V__namespace.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(helpersLib.ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new V__namespace.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=helpersLib.ColorHelper.white){let i=new V__namespace.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new V__namespace.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new V__namespace.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new V__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new V__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new V__namespace.Graphics,s=new helpersLib.Radian(helpersLib.PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.pixiContainer.addChild(t),this.pixiGraphics=t,this.ƀam=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀam,cache:false,...t},i=this.ƀee(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},boundingShapes:void 0,destroyAssetOnDestroy:!e.cache},s=new X(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀee(t,e){if(e){let i=o.ƀcr.get(t);return i||(i=this.ƀcf(),o.ƀcr.set(t,i)),i}else return this.ƀcf()}ƀcf(){let t=w.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {assetID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var ai=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀhr=new V__namespace.Graphics,this.ƀhr.beginFill(0,1e-9),this.ƀhr.drawRect(0,0,t.x,t.y),this.ƀhr.endFill(),this.pixiContainer.addChild(this.ƀhr);}destroy(){this.destroyed||(super.destroy(),this.ƀhr.destroy());}};var Ot=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:helpersLib.ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:helpersLib.Radian.get60,distance:10,color:helpersLib.ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:helpersLib.ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return {fontFamily:e.fontFamily,fill:helpersLib.ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r}}};var Ie=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=scriptEngineLib.RichTextSeparator.process(t,i),s=this.ƀfe(r,e),n=this.ƀs(s);return this.ƀjb(n)}static ƀfe(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Ot.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdo(a.tags,e,i),p=s(l,c),m=V__namespace.TextMetrics.measureText(" ",new V__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdo(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbb(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbb(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀjb(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀjc(s.text).map(a=>{let l=new V__namespace.TextStyle(s.pixiStyle),c=V__namespace.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀjc(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Ae=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new helpersLib.Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new helpersLib.Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀkr(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀkr(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀkr(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀci.length===0}get remainingWidth(){return this.ƀkq-this.ƀck}constructor(t,e){if(this.ƀkq=t,this.ƀfu=[],this.ƀci=[],this.ƀck=0,this.ƀft=new helpersLib.Vector(0,0),this.ƀcj=0,this.ƀew=e?.horizontalAlignment??"left",this.ƀki=e?.verticalAlignment??"bottom",e?.rectangleCutOption){if(e.rectangleCutOption.position.x<0||e.rectangleCutOption.position.x>=this.ƀkq||e.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcl={direction:e.rectangleCutOption.direction,rectangle:this.ƀbp(e.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcj,t.y),i=this.ƀdw(this.ƀft.y,this.ƀft.y+e);return this.ƀck+t.x<=i}insertWord(t){let e=Math.max(this.ƀcj,t.style.height);if(this.ƀci.length===0){let i=this.ƀdx(this.ƀft.y,this.ƀft.y+e);this.ƀft=new helpersLib.Vector(i,this.ƀft.y),this.ƀck=this.ƀft.x;}this.ƀci.push({chunk:t,position:new helpersLib.Vector(this.ƀck,this.ƀft.y)}),this.ƀcj=e,this.ƀck+=t.style.width;}newLine(){let t=this.ƀft.y+this.ƀcj,e=this.ƀdx(t,t);this.ƀdd(),this.ƀft=new helpersLib.Vector(e,t),this.ƀck=this.ƀft.x,this.ƀcj=0;}print(){return this.ƀdd(),this.ƀfu}ƀdd(){this.ƀci.length>0&&(this.ƀfu.push(this.ƀg(this.ƀci)),this.ƀci=[]);}ƀg(t){return t=this.ƀkk(t),t=this.ƀey(t),t}ƀey(t){if(this.ƀew==="left")return t;let e=this.ƀft.y+this.ƀcj,i=this.ƀdx(this.ƀft.y,e),s=this.ƀdw(this.ƀft.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀew==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new helpersLib.Vector(l.position.x+a,l.position.y)},l))}ƀkk(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀki){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀdx(t,e){return this.ƀcl&&(this.ƀcl.direction==="topLeft"||this.ƀcl.direction==="bottomLeft")&&(this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀcl.rectangle.bottomRight.x:0}ƀdw(t,e){return this.ƀcl&&(this.ƀcl.direction==="topRight"||this.ƀcl.direction==="bottomRight")&&(this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(this.ƀkq,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(this.ƀkq,e),{includeEdges:false}))?this.ƀcl.rectangle.topLeft.x:this.ƀkq}ƀbp(t){let e,i;switch(t.direction){case "topRight":e=new helpersLib.Vector(t.position.x,-1/0),i=new helpersLib.Vector(1/0,t.position.y);break;case "topLeft":e=new helpersLib.Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new helpersLib.Vector(1/0,1/0);break;case "bottomLeft":e=new helpersLib.Vector(-1/0,t.position.y),i=new helpersLib.Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new helpersLib.Rectangle(e,i)}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgg(t),t=this.ƀka(t),this.ƀav(t)}static ƀgg(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀka(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀav(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ie.process(t,e),r=new Oe(e.default.wordWrapWidth??1/0,{rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=Ae.wrapText(i,r);return Me.process(s)}};var Cs=1,$i=1/Cs,te=class extends u{static{h(this,"Text");}get ƀjs(){if(!this.ƀjt){let t=new V__namespace.TextStyle(this.ƀht);this.ƀjt=V__namespace.TextMetrics.measureText(this.ƀjr,t);}return this.ƀjt}get ascent(){return this.ƀjs.fontProperties.ascent}constructor(t,e){super(),this.ƀht=Ot.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhs.destroyed&&this.ƀhs.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀhs.anchor.x,this.ƀhs.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhs.anchor.set(t.x,t.y);}setPosition(t,e){if(e?.holdFrom){let i=this.ƀht.dropShadowDistance??0,r=new helpersLib.Vector(e.holdFrom.x*i,e.holdFrom.y*i);t=t.add(r);}return super.setPosition(t,e),this}setText(t){return this.ƀjr!==t&&(this.ƀjr=t,this.ƀia()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀht.fill!==e&&(this.ƀht.fill=e,this.ƀia()),this}ƀia(){this.ƀhs?.destroy(),this.ƀjm?.destroy(),this.ƀjm=void 0,this.ƀjt=void 0;let t=new V__namespace.TextStyle(this.ƀht);this.ƀhs=new V__namespace.Text(this.ƀjr,t),this.ƀi&&this.ƀhs.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhs.scale.set($i,$i),this.pixiContainer.addChild(this.ƀhs),this.ƀht.lineThrough&&(this.ƀjm=this.ƀe(this.ƀhs,this.ƀht.fill),this.pixiContainer.addChild(this.ƀjm));}ƀe(t,e){let i=V__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new V__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=V__namespace.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,g=0;t.style.align==="center"?g=0+(t.width-p.width)*.5:t.style.align==="right"&&(g=0+t.width-p.width),g=Math.floor(g),n.moveTo(Math.floor(g),m),n.lineTo(Math.floor(g+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var hi=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new te(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var li=class extends u{static{h(this,"UpdatableContainer");}},ci=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbv=t,this.ƀco=new Map,this.ƀha={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀco.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀha.trackBy(r,s),a;this.ƀco.has(n)?(a=this.ƀco.get(n),e.delete(n),a.update(r)):(a=this.ƀbv(r).displayParent(this).attach(this),this.ƀco.set(n,a)),this.ƀha.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀha.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀha.positioning.spacing);}),e.forEach(r=>{this.ƀco.get(r).destroy(),this.ƀco.delete(r);});}};var Dt=class o extends u{static{h(this,"Menu");}static{this.ƀjy=false;}static closeAll(){return o.ƀgz?o.ƀgz.close():actionsLib.SingleEvent.instant()}constructor(t,e){super(),this.ƀgs=new actionsLib.SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new actionsLib.SingleAction,this.onClose=this.ƀgn.notifier;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,darkeningAlpha:.3,...e};this.setZIndex(100).setAlpha(0),this.ƀo=new A(this,"alpha",{animation:S.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaa=T.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.darkeningAlpha).setInteractive(true).displayParent(this).attach(this),this.ƀgf=X.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(r=>{this.ƀaa.aspectRatio=r.x/r.y,this.ƀaa.scale=Math.max(r.x,r.y),this.ƀaa.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(r.multiplyNumber(.5));}).attach(this),o.ƀgz=this,this.onDestroy().tap(()=>{o.ƀgz=void 0;}).attachToRoot(),i.closeOnBackgroundClick&&this.ƀaa.on(exports.ContainerEventType.Click).filter(()=>!o.ƀjy).tap(()=>this.ƀq(false)).take(1).attach(this),this.ƀq(true);}getBoundingMask(){return this.ƀgf.getBoundingMask()}close(){return this.ƀq(false)}ƀq(t){if(o.ƀjy)throw new Error("WindowUI: cannot iterate while in transition");return o.ƀjy=true,this.ƀo.animate({alpha:t?1:0}).chain(this).tap(()=>{o.ƀjy=false,t?this.ƀgs.resolve():(this.ƀgn.resolve(),this.destroy());}).chainToRoot()}};var di=class extends ut{static{h(this,"MenuEntity");}constructor(t,e){super(),this.ƀgq=new actionsLib.SingleAction,this.onCreate=this.ƀgq.notifier,this.ƀgs=new actionsLib.SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new actionsLib.SingleAction,this.onClose=this.ƀgn.notifier,Dt.closeAll().tap(()=>{if(!Pt.getActiveScene())throw new Error("WindowEntity: constructor is called when there is no active scene!");w.pause.effect(true).attach(this),this.ƀgf=new Dt(t,e).displayParent(w.camera.layers.foregroundScreen).attach(this),this.ƀgq.resolve(this.ƀgf),this.ƀgf.onOpen.subscribe(()=>this.ƀgs.resolve()).attach(this),this.ƀgf.onClose.subscribe(()=>{this.destroy(),this.ƀgn.resolve();}).attach(this);}).attach(this);}getMenuEvents(){return {onOpen:this.onOpen.toSingleEvent().destroyIfNotAttached(),onClose:this.onClose.toSingleEvent().destroyIfNotAttached()}}close(){if(this.ƀgf){let t=this.onClose.toSingleEvent().destroyIfNotAttached();return this.ƀgf.close(),t}else return this.onCreate.asyncMapQueue(()=>this.close()).singleChain(this)}};var Rs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Is=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class mt{static{h(this,"MouseService");}get initialMouseMoveHappened(){return this.ƀfg.value}getStagePosition(){return this.ƀje.value}getScreenPosition(){return this.ƀik.value}getMainButtonState(){return this.ƀfz.value}getSecondaryButtonState(){return this.ƀiq.value}constructor(){this.ƀfg=new actionsLib.Variable(false),this.onInitialMouseMove=this.ƀfg.notifier,this.ƀje=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀje.notifier,this.ƀik=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀik.notifier,this.ƀfz=new actionsLib.Variable(false),this.mainButtonState=this.ƀfz.notifier,this.ƀiq=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀiq.notifier,this.ƀjf(),window.addEventListener("mousedown",t=>{t.button===0?this.ƀfz.value=true:t.button===2&&(this.ƀiq.value=true);}),window.addEventListener("mouseup",t=>{t.button===0?this.ƀfz.value=false:t.button===2&&(this.ƀiq.value=false);}),window.addEventListener("blur",()=>{this.ƀfz.value=false,this.ƀiq.value=false;});}ƀjf(){let t=helpersLib.Vector.zero;window.addEventListener("mousemove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfg.value=true;}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀik.value=t;}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀik.value);e.isEqual(this.ƀje.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:this.ƀik.value.x,clientY:this.ƀik.value.y,pointerType:"mouse"})):this.ƀje.value=e;}).attachToRoot();}};exports.MouseService=Rs([d(),Is("design:paramtypes",[])],exports.MouseService);var ie=class extends u{static{h(this,"MouseWheelListenerUI");}constructor(t){super(),this.ƀgw=new actionsLib.Action,this.onWheel=this.ƀgw.notifier,this.ƀer=(e=>{let i=P.get(exports.MouseService).getScreenPosition(),r=this.ƀkp.getBounds();i.x>=r.x&&i.x<=r.x+r.width&&i.y>=r.y&&i.y<=r.y+r.height&&this.ƀgw.trigger(e.deltaY);}).bind(this),this.ƀkp=new V__namespace.Graphics,this.ƀkp.beginFill(0,1e-9),this.ƀkp.drawRect(0,0,t.x,t.y),this.ƀkp.endFill(),this.pixiContainer.addChild(this.ƀkp),window.addEventListener("wheel",this.ƀer);}destroy(){this.destroyed||(super.destroy(),this.ƀkp.destroy(),window.removeEventListener("wheel",this.ƀer));}};var Ms=.65,Ds=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀio}get contentSize(){return this.ƀbi.size.ceil()}constructor(t,e,i,r){this.ƀbi=t,this.ƀv=e,this.ƀhc=i,this.ƀja=r,this.ƀfh=false,this.ƀio=e-i*2,this.ƀbi.y=i,this.ƀjn=i;}onWheel(t){this.setTarget(this.ƀjn-t*Ms);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjn=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀhc-this.contentSize.y,this.ƀhc);}jumpToTarget(){this.ƀbi.y=this.ƀjn;}update(t){let e=this.contentSize;if(e.y<=this.ƀio){switch(this.ƀja){case "start":this.ƀjn=this.ƀhc;break;case "center":this.ƀjn=(this.ƀv-e.y)*.5;break;case "end":this.ƀjn=this.ƀv-e.y-this.ƀhc;break;default:{this.ƀja;throw new Error(`Unexpected case! "${this.ƀja}"`)}}this.ƀfh||(this.ƀbi.y=this.ƀjn);}this.ƀfh=true;let i=this.ƀjn-this.ƀbi.y;this.ƀbi.y=this.ƀbi.y+i*Ds*t;}};var fi=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},gt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcr=new Map;}constructor(t,e,i,r=exports.ScrollDirection.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===exports.ScrollDirection.Horizontal?this.ƀbz(e,i,s):this.ƀcg(e,i,s),this.ƀgc=X.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgc);}ƀcg(t,e,i){e>0&&this.ƀbw(new helpersLib.Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x,t.y-e*2),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀbz(t,e,i){e>0&&this.ƀbw(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(0,t.y),{round:false}).setRotation(helpersLib.Radian.get270).displayParent(i).attach(i),T.createRectangle(new helpersLib.Vector(t.x-e*2,t.y),helpersLib.ColorHelper.white).toSprite().setPosition(new helpersLib.Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbw(t){let i={id:this.ƀbx(t.y),scale:1,size:t,anchor:{x:0,y:0},boundingShapes:void 0};return new X(i,{textureSize:t,ignoreAnchor:true})}ƀbx(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcr.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new fi;helpersLib.ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=V__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcr.set(e,i);}else throw new Error("Canvas context is null")}return i}};var _s=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbj}get contentSize(){return this.ƀip.contentSize}constructor(t,e={}){super();let i={padding:_s,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new gt(r,t,i.padding).attach(this);let s=new u().displayParent(r).attach(this);this.ƀip=new Ge(s,t.y,i.padding,i.smallContentAlign),this.ƀbj=new helpersLib.Vector(t.x,this.ƀip.scrollHeight),new ie(t).displayParent(r).attach(this).onWheel.subscribe(a=>this.ƀip.onWheel(a)).attach(this),y.afterSceneUpdateAction.subscribe(a=>this.ƀip.update(a.delta)).attach(this),this.addChildTo=s;}scrollToTop(t){this.ƀip.scrollToTop(),t?.instant&&this.ƀip.jumpToTarget();}scrollToBottom(t){this.ƀip.scrollToBottom(),t?.instant&&this.ƀip.jumpToTarget();}};var Fs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ls=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class gi{static{h(this,"KeyboardService");}constructor(){this.ƀfp=new actionsLib.Action,this.keyPressed=this.ƀfp.notifier,this.ƀfq=new actionsLib.Action,this.keyReleased=this.ƀfq.notifier,this.ƀfw=new Set,this.ƀfv=new Set,window.addEventListener("keydown",t=>{this.ƀfw.add(t.key),this.ƀfv.add(t.key),!t.repeat&&this.ƀfp.trigger(t.key);}),window.addEventListener("keyup",t=>{this.ƀfw.delete(t.key),this.ƀfq.trigger(t.key);}),window.addEventListener("blur",()=>{this.ƀfw.clear();}),y.afterSceneUpdateAction.subscribe(()=>{this.ƀfv.clear();}).attachToRoot();}isKeyDown(t){return this.ƀfw.has(t)}isKeyJustPressed(t){return this.ƀfv.has(t)}};exports.KeyboardService=Fs([d(),Ls("design:paramtypes",[])],exports.KeyboardService);var Vs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ns=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class yi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀde}get lastFocusedPosition(){return this.ƀfs}constructor(t){this.ƀgi=t,this.ƀgu=new actionsLib.Action,this.onTargetFocus=this.ƀgu.notifier,this.ƀjx=0,this.ƀjz=false,this.ƀde=false,this.ƀfs=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀkb(e.delta)).attachToRoot();}ƀkb(t){if(this.ƀgj){let e=this.ƀed(this.ƀgi.getStagePosition(),this.ƀgj);this.ƀhe===void 0?this.ƀhe=e:this.ƀau(e,t);}this.ƀgj=this.ƀgi.getStagePosition();}ƀau(t,e){this.ƀhe-t>10?(this.ƀjx=Math.max(250,this.ƀjx),this.ƀjz=true):this.ƀjx>1e3&&(this.ƀjz=true);let i=this.ƀjx>=300&&this.ƀjz;this.ƀfn(i,t,e);}ƀfn(t,e,i){(t||e>this.ƀhe)&&(this.ƀhe=e),t?(this.ƀjz=false,this.ƀjx=0,this.ƀde=true,this.ƀfs=this.ƀgi.getStagePosition(),this.ƀgu.trigger(this.ƀfs)):(this.ƀjx+=i,this.ƀde=false);}ƀed(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=Vs([d(),Ns("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var x;(function(o){o[o.Hidden=1]="Hidden",o[o.Visible=2]="Visible",o[o.Appearing=3]="Appearing",o[o.Disappearing=4]="Disappearing",o[o.DisappearToChange=5]="DisappearToChange";})(x||(x={}));var _e=class extends actionsLib.Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgt=new actionsLib.Action,this.ƀgv=new actionsLib.Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀj.value=0,this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀo.completeAnimation(),this.ƀn=t!==void 0?x.Visible:x.Hidden,this.ƀhv=void 0;let i=t!==void 0?1:0,r=this.ƀji!==t;r&&(this.ƀji=t,this.ƀgt.trigger(this.ƀji)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀgv.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):(this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji)));break;case x.Disappearing:t===this.ƀji?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀhv=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0):t===this.ƀji?(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀhv&&(this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀgv.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀhv!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀji=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀhv===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀji=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};var Zi=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbv=t;let i={duration:200,animation:S.easeInOut,...e};this.alpha=0,this.ƀjj=new _e(i).onStateChange(r=>{this.ƀbi?.destroy(),this.ƀbi=void 0,r!==void 0&&(this.ƀbi=new u().displayParent(this).attach(this),this.ƀbv({state:r,container:this.ƀbi}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjj.setState(t,e),this}};var I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var Fe=class extends actionsLib.Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,nextState:this.ƀgl,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgt=new actionsLib.Action,this.ƀgv=new actionsLib.Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀji===void 0)this.ƀji=t,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀji=t,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀji&&(this.ƀn=I.Transitioning,this.ƀgl=t,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case I.Transitioning:t!==this.ƀgl&&(t===this.ƀji?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;case I.Reverting:t!==this.ƀji&&(t===this.ƀgl?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀji=this.ƀgl,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀji=this.ƀgl,this.ƀgl=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀji===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var C;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(C||(C={}));var Le=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=C.Idle,this.ƀgt=new actionsLib.Action,this.ƀgv=new actionsLib.Action,this.ƀha={duration:500,animation:S.easeInOutCubic,...t},this.ƀjj=new Fe({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((e,i)=>this.ƀep(e,i)).onValueChange(e=>this.ƀeq(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀff===void 0?(this.ƀff=t,this.ƀgt.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀjj.setState(t,e)):this.ƀff!==t?this.ƀgk!==t?this.ƀn===C.Idle?(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀgk=t,this.ƀgt.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀgk}),this.ƀjj.setState(t,e)):this.ƀjj.setState(t,e):this.ƀn===C.Reverting&&this.ƀgk===t&&(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀjj.setState(t,e)):(this.ƀn===C.TransitionForward||this.ƀn===C.TransitionBackward)&&(this.ƀn=C.Reverting,this.ƀjj.setState(t,e));}ƀep(t,e){switch(this.ƀff!==void 0&&this.ƀff!==t&&this.ƀff!==e&&this.ƀgt.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgk!==t&&this.ƀgk!==e&&this.ƀgt.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀgk}),e!==void 0&&e!==this.ƀff&&e!==this.ƀgk&&this.ƀgt.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀn){case C.Idle:break;case C.TransitionForward:case C.TransitionBackward:e===void 0?(this.ƀn=C.Idle,this.ƀff=this.ƀgk,this.ƀgk=void 0):this.ƀff!==t&&this.ƀen(t,e);break;case C.Reverting:e===void 0?(this.ƀn=C.Idle,this.ƀgk=void 0):this.ƀff!==e&&this.ƀen(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀeq(t){let e=1;(this.ƀn===C.TransitionBackward||this.ƀn===C.Reverting&&this.ƀff!==void 0&&this.ƀgk!==void 0&&this.ƀff>this.ƀgk)&&(e=-1),(this.ƀn===C.Idle||t!==0)&&this.ƀgv.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgv.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgk});}ƀen(t,e){this.ƀff=t,this.ƀgk=e,this.ƀgv.trigger({value:0,index:this.ƀff}),this.ƀn=this.ƀff<this.ƀgk?C.TransitionForward:C.TransitionBackward;}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e.value,e.index)).attach(this),this}};exports.ScrollDirection=void 0;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(exports.ScrollDirection||(exports.ScrollDirection={}));var wi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbv=t,this.ƀcm="x",this.ƀbk=new Map,this.ƀha={duration:300,animation:S.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀha.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀha.size.x+this.ƀha.margin*2,this.ƀha.size.y):new helpersLib.Vector(this.ƀha.size.x,this.ƀha.size.y+this.ƀha.margin*2),r=new u().setPosition(this.ƀha.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀha.margin,0):new helpersLib.Vector(0,-this.ƀha.margin),{round:false}).displayParent(this).attach(this);this.ƀca(i,this.ƀha.margin,this.ƀha.direction,r),this.ƀcm=this.ƀha.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀjj=new Le({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbk.set(n,a),this.ƀbv({index:n,container:a});}else {let a=this.ƀbk.get(n);a&&(a.destroy(),this.ƀbk.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbk.get(n);if(a){let l={x:0,y:0};l[this.ƀcm]=i[this.ƀcm]*s+this.ƀha.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjj.setIndex(t,e),this}ƀca(t,e,i,r){new gt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},er=class extends wi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var wt=class{static{h(this,"VectorSet");}constructor(){this.ƀkg=new Map;}add(t){let e=this.ƀkg.get(t.x);e||(e=new Set,this.ƀkg.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀkg.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀkg.get(t.x);return e?e.delete(t.y):false}};var xi=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var B=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new helpersLib.Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new helpersLib.Vector(.5,.5)).multiplyNumber(e)}};var re=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new helpersLib.Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=B.areaToGridArea(e,i);if(this.ƀat(t,s))return helpersLib.Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=helpersLib.Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=helpersLib.Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new helpersLib.Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new wt,s=new helpersLib.Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new helpersLib.Rectangle(n,n.add(i));if(this.ƀat(t,a))return helpersLib.Vector.fromTo(e,n);t.getNeighborPositions(n,helpersLib.GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀat(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new helpersLib.Vector(r,i)))return false;return true}};var ir=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return helpersLib.Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},to=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀem=t,this.ƀjg=e,this.ƀgy=new helpersLib.BinaryHeap("min"),this.ƀax=[],this.ƀgm=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new ir(this.ƀjg,0,Number.MAX_SAFE_INTEGER);this.ƀgy.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀgy.size>0}getNeighbors(t,e){return this.ƀem.getNeighborPositions(t.position,e).filter(i=>this.ƀem.get(i)).map(i=>this.ƀgm.get(i)||this.ƀcb(i))}popLowestPathCostNode(){let t=this.ƀgy.pop();return this.ƀgy.delete(t),t.closed=true,this.ƀax.push(t),t}changeNodeCost(t,e,i,r){this.ƀgy.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀgy.add(t.pathLength,t);}getBestClosedNode(){return this.ƀax.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcb(t){let e=new ir(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgm.set(t,e),this.ƀgy.add(e.pathLength,e),e}},se=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new to(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var oe=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjo=t,this.ƀx=e,this.ƀet=this.ƀdv(this.ƀx.size),this.ƀko=new helpersLib.Grid({size:this.ƀx.size,defaultValue:this.ƀet}),this.ƀcn=new helpersLib.Grid({size:this.ƀx.size,defaultValue:void 0});let i=new wt,r=new helpersLib.Queue;for(this.ƀdk(this.ƀx.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀko.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀko.getOrFail(n);this.ƀea(n,this.ƀx).forEach(l=>{if(!i.has(l.position)){let c=this.ƀko.getOrFail(l.position),p=a+l.distance;this.ƀx.getOrFail(l.position)&&p<c&&(this.ƀko.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjo)){if(t=this.ƀko.movePositionInsideGrid(t),this.ƀcn.has(t))return this.ƀcn.get(t);{let e=this.ƀea(t,this.ƀx),i;return this.ƀko.getOrFail(t)>=this.ƀet?e.some(s=>this.ƀx.get(s.position))&&(e.some(n=>!this.ƀx.get(n.position))?i=this.ƀdp(e):i=this.ƀdl(t,e)):i=this.ƀdl(t,e),this.ƀcn.set(t,i),i}}}ƀdp(t){let e=t.filter(i=>this.ƀx.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdl(t,e){let i=e.filter(r=>this.ƀko.getOrFail(r.position)<this.ƀet).reduce((r,s)=>{let n=this.ƀko.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀet}).bestDirections;return this.ƀef(i,t)}ƀef(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀfk(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfk(t,e){let i=t.add(this.ƀkh(e));return this.ƀx.isPointWithinBounds(i)&&this.ƀx.getOrFail(i)}ƀea(t,e){return this.ƀko.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdk(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new helpersLib.Vector(r,i));return e}ƀkh(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀdv(t){return (t.x+t.y)*20}};var oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},no=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends ${static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new actionsLib.Variable(false),this.lastP2Time=new actionsLib.Variable(0),this.onPhysicsStep=new actionsLib.Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=oo([dt(),no("design:paramtypes",[helpersLib.Vector,Boolean,W__default.default.World,Map,Map,Map,Map])],v);var co=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},K=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};K=co([d()],K);var po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},uo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ve=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhh=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhh.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};Ve=po([d(),uo("design:paramtypes",[K])],Ve);var fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},nt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhh=t,this.ƀy=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀy.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Bt){return e.aabbNeedsUpdate=true,e.updateAABB(),re.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀy.get(t,e,i);return r||(r=this.ƀby(t,e,i),this.ƀy.set(t,e,i,r)),r}ƀby(t,e,i){let r=new helpersLib.Grid({size:new helpersLib.Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀhh.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdu(s,e);r.setArea(a,false);}}),r}ƀdu(t,e){let i=f.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=fo([d(),mo("design:paramtypes",[K,Ve])],nt);var wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},xo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Bt=50,Gt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhg=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Bt);let n=v.getInstanceByIDOrFail(t),a,l;helpersLib.Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhg.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let E=f.aabbToBoundingBox(l.aabb),vt=B.areaToGridArea(E,s.gridCellSize);m.setArea(vt,true);}let g=se.findPath(m,c,p,s.neighborType);return g.path=g.path.map(E=>B.gridPositionToPosition(E,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Bt){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(g.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=B.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let g=this.ƀhg.getAvilabilityGrid(n,s,r);p=new oe(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};Gt=wo([d(),xo("design:paramtypes",[nt])],Gt);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=new U;exports.PhysicsGateway=class bi{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return j.trigger("createPhysicsWorld",t)}getMapSize(t){return j.trigger("getMapSize",t)}setPaused(t,e){return j.trigger("setPaused",t,e)}hitTest(t,e){return j.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return j.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return j.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return j.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return j.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return j.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Bt){return j.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};exports.PhysicsGateway=Po([d()],exports.PhysicsGateway);var So=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Co=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Q=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀz=t,this.ƀhd=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀz.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhd.findPathDirection(t,c.position,i,r),m;p===void 0?m=T.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=T.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new A(m,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,helpersLib.ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new A(a,"alpha",{duration:n,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,helpersLib.ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let m=p.hits.length>0?helpersLib.ColorHelper.red:helpersLib.ColorHelper.white;T.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new A(l,"alpha",{duration:a,animation:S.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new helpersLib.Radian(t.angle),n=i?.color??helpersLib.ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcq(c,n).displayParent(a).attachToRoot();}),new A(a,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcq(t,e){switch(t.type){case W__default.default.Shape.PARTICLE:throw new Error("Not implemented");case W__default.default.Shape.LINE:throw new Error("Not implemented");case W__default.default.Shape.PLANE:throw new Error("Not implemented");case W__default.default.Shape.CIRCLE:throw new Error("Not implemented");case W__default.default.Shape.CAPSULE:throw new Error("Not implemented");case W__default.default.Shape.BOX:throw new Error("Not implemented");case W__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case W__default.default.Shape.CONVEX:return this.ƀcp(t,e);default:throw new Error("Not implemented")}}ƀcp(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Q=So([d(),Co("design:paramtypes",[nt,Gt])],Q);var Ro=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Io=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ne=class{static{h(this,"HitTestService");}constructor(t){this.ƀjq=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdi(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new W__default.default.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?helpersLib.ColorHelper.red:helpersLib.ColorHelper.green;this.ƀjq.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdi(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Ro([d(),Io("design:paramtypes",[Q])],Ne);var Oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀib(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀay=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀib(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀeo(r.p2Body),r.entity.ƀis(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀeo(t){let e=f.arrayToVector(t.velocity);e.length>10.8&&(e=e.normalize(10.8),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-10.01),10.01);}ƀib(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdn(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdn(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeb(i);return {collisionDetailsA:this.ƀdm(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdm(s,i.bodyB.mass,a,c,e.area)}}ƀdm(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeb(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=Oo([d()],je);var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Do=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends Wt{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Mo([dt(),Do("design:paramtypes",[Number,Object])],He);var Bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},H=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbs(t,new helpersLib.Vector(e.x/2,-H/2),new helpersLib.Vector(e.x+H*2,H),i),this.ƀbs(t,new helpersLib.Vector(e.x/2,e.y+H/2),new helpersLib.Vector(e.x+H*2,H),i),this.ƀbs(t,new helpersLib.Vector(-H/2,e.y/2),new helpersLib.Vector(H,e.y+H*2),i),this.ƀbs(t,new helpersLib.Vector(e.x+H/2,e.y/2),new helpersLib.Vector(H,e.y+H*2),i);}ƀbs(t,e,i,r){return new He(t,{shapeDefinition:{materialName:st,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Bo([d()],We);var _o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ar=new W__default.default.Material,Fo={id:st,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},_t=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new W__default.default.Material),n.set(a.id,a);}),s.has(st))throw new Error(`Material with name ${st} cannot be defined, pick another name for the material.`);return s.set(st,ar),n.set(st,Fo),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdz(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdy(e,i.materialDefinitions)}ƀdz(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀdy(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀdr(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀdz(n.materialA,s),l=this.ƀdz(n.materialB,s);t.addContactMaterial(new W__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀdr(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀdz(s.id,r);t.addContactMaterial(new W__default.default.ContactMaterial(n,ar,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};_t=_o([d()],_t);var Lo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ft=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀge=t,this.ƀaj=e,this.ƀz=i,this.ƀaz=r,this.ƀhh=s;}createPhysicsWorld(t){let e=new W__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀge.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhh.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&y.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀaz.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjk(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjk(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀz.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjk(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀaz.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ft=Lo([d(),Vo("design:paramtypes",[_t,We,nt,je,K])],Ft);var jo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vt=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new W__default.default.RaycastResult,s=new W__default.default.Ray({mode:W__default.default.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbn(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new W__default.default.Ray({mode:W__default.default.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbn(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbn(n,e));},"callback")});return t.p2World.raycast(new W__default.default.RaycastResult,s),Array.from(r.values())}ƀbn(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Vt=jo([d()],Vt);var Ho=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},lt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};lt=Ho([d()],lt);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Nt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbo(r,t.length))}ƀbo(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:helpersLib.Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Nt=Wo([d()],Nt);var $o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Yo=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcd(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀhw.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀjq.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...E}=m;return E})}ƀcd(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(helpersLib.Radian.get90).vector,p=c.normalize(i.x);a.push(new helpersLib.Line(t,t.add(p))),a.push(new helpersLib.Line(t,t.add(p.multiplyNumber(-1))));let m=l.normalize(i.y);a.push(new helpersLib.Line(t,t.add(m))),a.push(new helpersLib.Line(t,t.add(m.multiplyNumber(-1))));let g=Math.round(i.y/Yo),E=i.y/(g*2+1)*2,vt=l.normalize(E),ne=i.x,lr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(g).forEach(pt=>{let bt=E*(pt+1),Ci=vt.multiplyNumber(pt+1),ae=c.normalize(this.ƀej(ne,lr,bt)),he=t.add(Ci);a.push(new helpersLib.Line(he,he.add(ae))),a.push(new helpersLib.Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ci.multiplyNumber(-1));a.push(new helpersLib.Line(le,le.add(ae))),a.push(new helpersLib.Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(pt=>{if(s){let bt=this.ƀhx.castClosest(n,pt,r);return {line:pt,hits:bt?[bt]:[]}}else {let bt=this.ƀhx.castAllFirstContacts(n,pt,r);return {line:pt,hits:bt}}})}ƀej(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀfd.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=$o([d(),zo("design:paramtypes",[Vt,Q,Nt,lt])],$e);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ze=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeg(i),c=this.ƀcd(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀhw.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀjq.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcd(t,e,i,r,s,n){let a=new helpersLib.Radian(helpersLib.PI_360/r),l=new helpersLib.Vector(0,-e),c=a.vector;return helpersLib.ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new helpersLib.Line(t,p)}).map(p=>{if(s){let m=this.ƀhx.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀhx.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfd.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=helpersLib.Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀfd.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeg(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ze=Xo([d(),Ko("design:paramtypes",[Vt,Q,Nt,lt])],ze);var en=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},jt=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};jt=en([d()],jt);var rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀho=t,this.ƀhd=e,this.ƀjq=i,this.ƀda=r,this.ƀcu=s,this.ƀeu=n,this.ƀhn=a,this.ƀfd=l;}createPhysicsWorld(t){return this.ƀho.createPhysicsWorld(t)}getMapSize(t){return this.ƀhn.getMapSize(t)}setPaused(t,e){this.ƀho.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀeu.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhd.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhd.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfd.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀda.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcu.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n){this.ƀjq.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=rn([q({controllerLink:j}),sn("design:paramtypes",[Ft,Gt,Q,ze,$e,Ne,jt,lt])],Pi);var on=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ke=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case exports.PhysicsShapeType.Point:return this.ƀbu(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbu(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcc(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀce(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbu(t,e,i,r,s,n){let a=new W__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcc(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new W__default.default.Convex({vertices:g.map(E=>[E.x,E.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,E)=>g+E.area,0),m=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(g=>m.addShape(g)),m.setDensity(r.density),m}ƀce(t,e,i,r,s,n){let a=new W__default.default.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new W__default.default.Body({type:n==="dynamic"?W__default.default.Body.DYNAMIC:W__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ke=on([d()],ke);var nn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},an=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀho=t,this.ƀhm=e,this.ƀix=i,this.ƀhn=r,this.ƀhh=s;}createBody(t,e,i,r,s){return this.ƀix.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀhm.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀhm.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhh.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhh.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀho.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀho.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhn.subscribeToPhysicsStep(t,e)}};Si=nn([q({controllerLink:J}),an("design:paramtypes",[Ft,_t,ke,jt,K])],Si);exports.AnimationFlicker=Ai;exports.AnimationInterpolationFunctions=Y;exports.Animations=S;exports.Animator=A;exports.BORDER_MATERIAL_NAME=st;exports.BardLegendsHardReset=G;exports.Camera=Xt;exports.ClosestAvailableSpaceHelper=re;exports.Container=u;exports.ControllerDecorator=q;exports.ControllerLink=U;exports.DEFAULT_SHADER_RESOLUTION=O;exports.DeltaTime=xi;exports.DisplayObjectArray=ci;exports.Entity=$;exports.EntityDecorator=dt;exports.FadeInContent=Zi;exports.FadeInStateAnimation=_e;exports.Game=w;exports.Graphics=T;exports.ImmovablePhysicsEntity=Wt;exports.Menu=Dt;exports.MenuEntity=di;exports.MouseWheelListenerUI=ie;exports.MovableEntity=Xe;exports.MovablePhysicsEntity=Ke;exports.PathFinder=se;exports.PhysicsEntity=b;exports.Placeholder=ai;exports.PositionConversionHelper=kt;exports.ROTATIONAL_SPEED_LIMIT=Qe;exports.RichText=hi;exports.SPEED_LIMIT=Ze;exports.Scene=Pt;exports.SceneDecorator=wr;exports.ScrollAreaUI=mi;exports.ScrollMaskUI=gt;exports.Service=P;exports.ServiceDecorator=d;exports.SingletonEntity=ut;exports.SlideInContent=er;exports.SlideInContentByIndex=wi;exports.SlideStateAnimation=Le;exports.Sprite=X;exports.StateAnimation=Fe;exports.Text=te;exports.UpdatableContainer=li;exports.UpdateCycle=y;exports.VectorFieldPathFinder=oe;exports.VectorSet=wt;exports.View=Ht;exports.ViewDecorator=Ye;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Action,ActionLib,SingleEvent,IDAttachable,Variable,Attachable,ActionSubscription,Reducer,SingleAction}from'actions-lib';import'reflect-metadata';import {Rectangle,Vector,Radian,Random,MapToWeakRefs,Comparator,NumberHelper,ArrayHelper,ColorHelper,PI_360,Queue,GridNeighborType,BinaryHeap,Grid,Line}from'helpers-lib';import W from'p2';import*as V from'pixi.js';import {RichTextSeparator}from'script-engine-lib';var cr=Object.defineProperty;var h=(o,t)=>cr(o,"name",{value:t,configurable:true});var G=class{static{h(this,"BardLegendsHardReset");}static{this.ƀes=new Action;}static{this.onHardReset=this.ƀes.notifier;}static hardReset(){ActionLib.hardReset(),this.ƀes.trigger();}};function d(){return function(o){let t=P.ƀec(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var P=class{static{h(this,"Service");}static{this.ƀir=new Map;}static get(t){let e=this.ƀir.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀid([],t.$meta.paramtypes);e=new t(...i),this.ƀir.set(t,e);}return e}static ƀec(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e}static ƀid(t,e){let i=[...t];if(e.length>t.length){let s=e.slice(t.length).map(n=>{if(n&&n.$meta?.type==="service")return this.get(n)});i.push(...s);}return i}};G.onHardReset.subscribe(()=>{P.ƀir=new Map;}).attachToRoot();var U=class{static{h(this,"ControllerLink");}constructor(){this.ƀbm=[],this.ƀic=[];}trigger(t,...e){let i=this.ƀbm.find(r=>!!r[t]);if(i)return i[t](...e);throw new Error(`ServiceLink: no defined function with the name: "${t}", found in the linked controllers!`)}registerController(t){Reflect.ownKeys(t.constructor.prototype).filter(e=>e!=="constructor").map(e=>e.toString()).forEach(e=>{if(this.ƀic.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀic.push(e);}),this.ƀbm.push(t);}};function q(o){return function(t){let e=P.ƀec(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=P.ƀid([],e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);o.controllerLink.registerController(r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var y=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀij=new Action;}static{this.sceneUpdateAction=this.ƀij.notifier;}static{this.ƀf=new Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀjv=0;}static{this.ƀkd=void 0;}static wait(t){let e=this.ƀjv+t;return SingleEvent.create(i=>{let r=o.beforeSceneUpdateAction.subscribe(s=>{s.time>=e&&i();}).attachToRoot();return ()=>r.destroy()})}static registerUpdateModifier(t){if(!this.ƀkd)this.ƀkd=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkd=void 0;}static triggerUpdateTick(t){this.ƀkd&&(t=this.ƀkd(this.ƀjv,t)),this.ƀjv+=t,this.ƀfr=t,t>0&&(o.ƀad.trigger({time:this.ƀjv,delta:t}),o.ƀij.trigger({time:this.ƀjv,delta:t}),o.ƀf.trigger({time:this.ƀjv,delta:t}));}static get lastDelta(){return this.ƀfr}static{this.ƀfr=0;}};G.onHardReset.subscribe(()=>{y.ƀad.clear(),y.ƀij.clear(),y.ƀf.clear(),y.ƀkd=void 0,y.ƀjv=0;}).attachToRoot();var _=class o{static{h(this,"EntityStoreHelper");}static{this.ƀaw=new Map;}static registerEntityClass(t){this.ƀaw.set(t.id,new Map);}static registerEntity(t){this.ƀaw.get(t.classID).set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀaw.get(i)?.delete(e);}static getEntity(t,e){return this.ƀaw.get(t.id)?.get(e)}static getSingleton(t){let e=o.getEntities(t);if(e.length>1)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has multiple instances! Name: "${this.name}"`);return e[0]}static getSingletonOrFail(t){let e=this.getSingleton(t);if(!e)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has no instance! Name: "${this.name}"`);return e}static getEntities(t){let e=this.ƀaw.get(t.id);return Array.from(e.values())}};G.onHardReset.subscribe(()=>{_.ƀaw.clear();}).attachToRoot();var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀkm=new Map;}static registerView(t,e){o.ƀkm.has(e)||o.ƀkm.set(e,[]);let i=o.ƀkm.get(e);i&&i.push(t),_.getEntities(e).forEach(s=>{this.ƀch(s,t);});}static ƀch(t,e){try{let i=P.ƀid([this],e.$meta.paramtypes);o.entityID=t.id;let r=new e(t,...i.slice(1));t.destroyed?r.destroy():t.ƀkl.ƀkn.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcw=t,this.ƀkn=[];}createViews(){if(!this.ƀcw.destroyed){let t=o.ƀkm.get(this.ƀcw.constructor);t&&t.forEach(e=>{o.ƀch(this.ƀcw,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkn.length;i++){let r=this.ƀkn[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkn.forEach(t=>{t.destroy();});}};G.onHardReset.subscribe(()=>{rt.ƀkm=new Map;}).attachToRoot();function dt(){return function(o){o.$meta={type:"entity"},_.registerEntityClass(o);}}h(dt,"EntityDecorator");var $=class extends IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return _.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=_.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return _.getEntities(this)}constructor(){super(),this.ƀkl=new rt(this),_.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀkl.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀkl.destroyViews(),_.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀkl.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀkl.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀkl.createViews(),this}update(t,e){}};var ut=class extends ${static{h(this,"SingletonEntity");}static getInstance(){return _.getSingleton(this)}static getInstanceOrFail(){return _.getSingletonOrFail(this)}constructor(){if(super(),this.constructor.getEntities().length>1)throw this.attachToRoot(),new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! "${this}"`)}};function wr(){return function(o){return o.$meta={paramtypes:P.ƀec(o),type:"scene"},o}}h(wr,"SceneDecorator");var Pt=class o extends IDAttachable{static{h(this,"Scene");}static{this.ƀii=false;}static{this.ƀb=new Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveScene(){return o.ƀb.value}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static isActive(){return o.ƀb.value instanceof this}static getInstance(){return o.ƀb.value instanceof this?o.ƀb.value:void 0}static getInstanceOrFail(){if(!o.ƀb.value)throw new Error("Scene: getInstance is called when there is no active scene!");if(!(o.ƀb.value instanceof this))throw new Error(`Scene: getInstance is called while "${this.name}" was not the active scene. Current scene is: "${o.ƀb.value}"!`);return o.ƀb.value}static open(...t){if(o.ƀii)throw new Error("Scene: you cannot open a scene while a scene is transitioning!");if(o.ƀb.value)throw new Error("Scene: you cannot open a scene while there is already another active scene!");let e=t[0];o.ƀii=true;let i=P.ƀid([],this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀii=false,r)).chainToRoot()}constructor(){super(),this.ƀgn=new Action,this.onClose=this.ƀgn.notifier,y.sceneUpdateAction.subscribe(t=>this.update(t.time,t.delta)).attach(this);}close(...t){if(o.ƀb.value!==this)throw new Error("Internal Error: Scene instance is accessed while it is not the active scene!");if(o.ƀii)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀii=true;let e=t[0];return this.prepareToClose().map(()=>(super.destroy(),o.ƀb.set(void 0),o.ƀii=false,this.ƀgn.trigger(e),e)).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};G.onHardReset.subscribe(()=>{Pt.ƀb.set(void 0);}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:P.ƀec(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var Ht=class extends IDAttachable{static{h(this,"View");}static getInstance(t){return this.$meta.entity.validateID(t)?this.$meta.viewInstances.get(t):void 0}static getInstanceOrFail(t){if(!this.$meta.entity.validateID(t))throw new Error(`View: getInstance is called with entity id: "${t}", that is not belonging to the class: "${this.$meta.entity}"`);let i=this.$meta.viewInstances.get(t);if(!i)throw new Error(`View: getInstanceOrFail is called with entity id: "${t}", that is not found!`);return i}constructor(){super(),this.attachToRoot(),this.ƀcx=rt.entityID,this.ƀei().set(this.ƀcx,this);}destroy(){this.destroyed||(super.destroy(),this.ƀei().delete(this.ƀcx));}update(t,e){}ƀei(){return this.constructor.$meta.viewInstances}};var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new W.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Sr=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},J=new U,St=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return J.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return J.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return J.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return J.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return J.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return J.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return J.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return J.trigger("subscribeToPhysicsStep",t,e)}};St=Sr([d()],St);var b=class o extends ${static{h(this,"PhysicsEntity");}static{this.ƀhb=new Map;}static{this.ƀhi=new Map;}static getFromP2BodyID(t){return o.ƀhb.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhb.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhi.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhi.values())}get area(){return this.ƀu}get mass(){return this.ƀgd}get collisions(){return this.ƀay}constructor(t,e,i){super(),this.ƀgo=new Action,this.onCollision=this.ƀgo.notifier,this.type="dynamic",this.ƀu=0,this.ƀgd=0,this.ƀay=[],this.physicsWorldID=t,this.ƀhk=P.get(St);let r=this.ƀhk.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhk.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀhj=this.ƀhk.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhl=this.ƀhk.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhk.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgd=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhk.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhb.set(this.p2Body.id,this),o.ƀhi.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhk.removeBody(this.physicsWorldID,this.p2Body),o.ƀhb.delete(this.p2Body.id),o.ƀhi.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀhj,this.ƀhl,t.ƀhj,t.ƀhl)}ƀis(t){this.ƀay=t,t.length>0&&this.ƀgo.trigger(t);}};var Wt=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:Vector.zero,rotationalSpeed:0}}};var Xe=class extends ${static{h(this,"MovableEntity");}constructor(){super(),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),y.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀjk(t,e);}).attach(this);}ƀjk(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ke=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),this.ƀez=false,this.ƀfa=false,this.ƀfc=false,this.ƀfb=false,this.ƀhf(),this.ƀfx(),P.get(St).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjk(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀjk(t,e){this.ƀez=true,this.ƀfa=true,this.ƀfc=true,this.ƀfb=true,this.ƀhf();}ƀhf(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀfx(){this.position.subscribe(t=>{this.ƀez?this.ƀez=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfa?this.ƀfa=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfb?this.ƀfb=false:this.p2Body.angularVelocity=t;}).attach(this);}};var Ze=10.8,Qe=10.01,tt;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(tt||(tt={}));var st="border";var Y=class{static{h(this,"AnimationInterpolationFunctions");}static boomerangTime(t){return 1-Math.abs(t-.5)*2}static lineer(t){return t}static easeIn(t){return Math.pow(t,2)}static easeOut(t){return 1-Math.pow(1-t,2)}static easeInOut(t){return t<.5?2*t*t:(t-=1,1-2*t*t)}static easeInOutCubic(t){let e=2*t-2;return t<.5?4*Math.pow(t,3):(t-1)*Math.pow(e,2)+1}},Rr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return Y.lineer(t)}},Ir=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return Y.easeIn(t)}},Ar=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return Y.easeOut(t)}},Or=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return Y.easeInOut(t)}},Mr=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return Y.easeInOutCubic(t)}},Ai=class{static{h(this,"AnimationFlicker");}start(){this.ƀjw=new Array(10).fill(0),Random.integerBetween(0,9),this.ƀjw[Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(Random.integerBetween(0,9),this.ƀjw[Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(Random.integerBetween(0,9),this.ƀjw[Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀjw[e]}},S=class{static{h(this,"Animations");}static{this.lineer=new Rr;}static{this.easeIn=new Ir;}static{this.easeOut=new Ar;}static{this.easeInOut=new Or;}static{this.easeInOutCubic=new Mr;}};var F;(function(o){o[o.ThrowError=1]="ThrowError",o[o.IgnoreNewAnimation=2]="IgnoreNewAnimation",o[o.CompletePrevious=3]="CompletePrevious";})(F||(F={}));var R;(function(o){o[o.ReturnToOriginal=1]="ReturnToOriginal",o[o.StayInCurrentState=2]="StayInCurrentState",o[o.JumpToEnd=3]="JumpToEnd",o[o.Loop=4]="Loop";})(R||(R={}));var A=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdj(t){let e=o.ƀk.get(t);return e||(e=new MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀgx!==void 0}get target(){return this.ƀjn}get value(){return this.ƀkf||(this.ƀkf=new Variable(this.ƀjn)),this.ƀkf.notifier}constructor(t,e,i){this.ƀfl=false,this.ƀiz=false,this.ƀjn=t,this.ƀha={duration:200,animation:S.lineer,reAnimateHandling:F.ThrowError,completionHandling:R.StayInCurrentState,...i},this.ƀl=Comparator.isArray(e)?e:[e],this.ƀfy(t,this.ƀl);}animate(t,e){let i={...this.ƀha,...e};if(this.ƀgx)switch(i.reAnimateHandling){case F.ThrowError:throw new Error("Animator: new animation triggered while another is not complete yet.");case F.IgnoreNewAnimation:return SingleEvent.instant();case F.CompletePrevious:this.ƀit(i.completionHandling,this.ƀgx.ƀhu,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return SingleEvent.create(s=>{this.ƀfl&&(this.ƀiz=true);let n=this.ƀl.reduce((c,p)=>(c[p]={ƀjh:this.ƀjn[p],ƀjp:t[p]},c),{}),a={ƀcs:i.duration,ƀct:0,ƀhu:n,ƀbf:i.completionHandling,ƀm:i.animation,ƀbe:s};if(a.ƀbf!==R.Loop&&this.ƀfj(a)){this.ƀgx=void 0,s();return}else a.ƀm.start();let l=this.ƀgx;return this.ƀgx=a,this.ƀcv(),l?.ƀbe(),()=>{this.ƀgx===a&&(this.ƀjn instanceof Attachable&&this.ƀjn.destroyed||this.ƀit(a.ƀbf,a.ƀhu,true),this.ƀgx=void 0,this.ƀkc?.destroy(),this.ƀkc=void 0);}})}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r]&&(e=true,this.ƀjn[r]=t[r]);}e&&this.ƀkf?.set(this.ƀjn),this.ƀgx?.ƀbe();}completeAnimation(t){if(this.ƀgx){t=t??this.ƀgx.ƀbf,this.ƀit(t,this.ƀgx.ƀhu,true);let e=this.ƀgx.ƀbe;this.ƀgx=void 0,e();}}ƀcv(){this.ƀkc||(this.ƀkc=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfl=true;try{let e=this.ƀgx;if(!e)return;e.ƀct+=t.delta;let i=e.ƀct>=e.ƀcs;if(i)if(e.ƀbf===R.Loop)e.ƀct%=e.ƀcs,e.ƀm.start(),i=!1;else {this.ƀit(e.ƀbf,e.ƀhu,!1),this.ƀgx=void 0,e.ƀbe(),this.ƀgx||(this.ƀkc?.destroy(),this.ƀkc=void 0);return}if(!i){let r=e.ƀm.multiplierFunction(e.ƀct/e.ƀcs),s=!1;for(let n=0;n<this.ƀl.length;n++){let a=this.ƀl[n],l=e.ƀhu[a],p=(l.ƀjp-l.ƀjh)*r+l.ƀjh;p!==this.ƀjn[a]&&(s=!0,this.ƀjn[a]=p);}s&&this.ƀkf?.set(this.ƀjn);}}finally{this.ƀfl=false,this.ƀiz&&(this.ƀiz=false,this.ƀkc?.destroy(),this.ƀkc=void 0,this.ƀcv());}}).attachToRoot());}ƀfj(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjn[i]!==t.ƀhu[i].ƀjp)return false}return true}ƀit(t,e,i){switch(t){case R.ReturnToOriginal:this.ƀif(e);break;case R.StayInCurrentState:i||this.ƀfo(e);break;case R.JumpToEnd:this.ƀfo(e);break;case R.Loop:this.ƀif(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀif(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjh&&(e=true,this.ƀjn[r]=t[r].ƀjh);}e&&this.ƀkf?.set(this.ƀjn);}ƀfo(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjp&&(e=true,this.ƀjn[r]=t[r].ƀjp);}e&&this.ƀkf?.set(this.ƀjn);}ƀfy(t,e){let i=o.ƀdj(t);for(let r of e){if(i.has(r))throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(t,void 0,2)}", Property: "${r}"`);i.set(r,this);}}};var $t;(function(o){o.Click="click",o.MouseOver="mouseover",o.MouseOut="mouseout",o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerUpOutside="pointerupoutside",o.PointerMove="pointermove",o.PointerCancel="pointercancel",o.PointerOver="pointerover",o.PointerOut="pointerout",o.PointerEnter="pointerenter",o.PointerLeave="pointerleave",o.Added="added",o.Removed="removed",o.Update="update",o.Change="change";})($t||($t={}));var qe;(function(o){o.Default="default",o.Pointer="pointer";})(qe||(qe={}));var ue=class extends IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgh=false,this.ƀdc=false,this.ƀig=1,this.ƀw=1,this.pixiContainer=new V.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new Vector(this.pixiContainer.width,this.pixiContainer.height)}setSize(t){return this.pixiContainer.width=t.x,this.pixiContainer.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.pixiContainer.getLocalBounds(),r=new Vector(this.pixiContainer.scale.x,this.pixiContainer.scale.y),s=new Vector(i.x,i.y).multiply(r),n=new Vector(i.width,i.height).multiply(r),a=s.add(n.multiply(e.holdFrom));t=t.subtract(a);}return e?.round!==false&&(t=t.round({rollHalfsDown:true})),this.position=t,this}get position(){return new Vector(this.pixiContainer.x,this.pixiContainer.y)}set position(t){this.pixiContainer.position=t;}get x(){return this.pixiContainer.x}set x(t){this.pixiContainer.x=t;}get y(){return this.pixiContainer.y}set y(t){this.pixiContainer.y=t;}on(t,e){let i=h(r=>e(),"handle");return this.pixiContainer.on(t,i),new ActionSubscription(()=>{this.pixiContainer.off(t,i);})}setRotation(t){return this.rotation=t,this}get rotation(){return new Radian(this.pixiContainer.rotation)}set rotation(t){this.pixiContainer.rotation=t.value;}get rotationValue(){return this.rotation.value}set rotationValue(t){this.rotation=new Radian(t);}setZIndex(t){return this.zIndex=t,this}get zIndex(){return this.pixiContainer.zIndex}set zIndex(t){this.pixiContainer.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new Radian(this.pixiContainer.skew.x)}set skewX(t){this.pixiContainer.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new Radian(this.pixiContainer.skew.y)}set skewY(t){this.pixiContainer.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.pixiContainer.sortableChildren}set sortableChildren(t){this.pixiContainer.sortableChildren=t;}setAlpha(t){return this.pixiContainer.alpha=t,this}get alpha(){return this.pixiContainer.alpha}set alpha(t){this.pixiContainer.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.pixiContainer.interactive}set interactive(t){t?this.pixiContainer.eventMode="dynamic":this.pixiContainer.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.pixiContainer.cursor}set cursor(t){this.pixiContainer.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.pixiContainer.addChild(t.pixiContainer),this.pixiContainer.mask=t.getMask(),this.ƀgb=t):(this.ƀgb&&this.pixiContainer.removeChild(this.ƀgb.pixiContainer),this.pixiContainer.mask=null),this}hitTest(t){if(this.pixiContainer.parent)if(this.pixiContainer.hitArea){let e=this.pixiContainer.toLocal(t);return this.pixiContainer.hitArea.contains(e.x,e.y)}else return this.pixiContainer.getBounds().contains(t.x,t.y);else return false}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgh}set mirror(t){this.ƀgh=t,this.ƀke();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdc}set flip(t){this.ƀdc=t,this.ƀke();}setScale(t){return this.scale=t,this}get scale(){return this.ƀig}set scale(t){this.ƀig=t,this.ƀke();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀke();}ƀke(){this.pixiContainer.scale.set(this.ƀig,this.ƀig),this.ƀw<1?this.pixiContainer.scale.x*=this.ƀw:this.ƀw>1&&(this.pixiContainer.scale.y/=this.ƀw),this.ƀgh&&(this.pixiContainer.scale.x*=-1),this.ƀdc&&(this.pixiContainer.scale.y*=-1);}};var O=2,Tt;(function(o){o[o.Normal=0]="Normal",o[o.Add=1]="Add",o[o.Screen=3]="Screen",o[o.Luminosity=16]="Luminosity",o[o.ColorDodge=7]="ColorDodge";})(Tt||(Tt={}));var fe=class{static{h(this,"GaussianValuesHelper");}static ƀdh(t,e){let i=e*e,r=1/(PI_360*i),s=-(t*t)/(2*i);return r*Math.exp(s)}static getValuesForLinearSamplingPascal(t){let e=t*2,i=Math.pow(2,e),r=.005*i,s=NumberHelper.pascalTriangleRow(e).slice(t).filter(l=>{if(l<r)i-=l*2;else return true}),n=1/i,a=s.map(l=>l*n);return this.ƀbr(a)}static getValuesForLinearSamplingGauss(t){if(t===0)return [{offset:0,multiplier:1}];if(t===1)return [{offset:0,multiplier:.5},{offset:1,multiplier:.25}];{let e=ArrayHelper.createIntegerArray(Math.ceil(t*.75)).map(r=>this.ƀdh(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbr(e)}}static ƀbr(t){let e=[{offset:0,multiplier:t[0]}];for(let i=1;i<t.length-1;i+=2){let r=t[i]+t[i+1],s=i+t[i+1]/r;e.push({offset:s,multiplier:r});}if(t.length%2===0){let i=t[t.length-1],r=t.length-1;e.push({offset:r,multiplier:i});}return e}};var Di=class ti extends V.Filter{static{h(this,"BlurFilterPass");}static ƀeh(){return `
|
|
1
|
+
import {Action,ActionLib,SingleEvent,IDAttachable,Variable,Attachable,Sequence,Reducer,SingleAction}from'actions-lib';import'reflect-metadata';import {Rectangle,Vector,Radian,Random,MapToWeakRefs,Comparator,NumberHelper,ArrayHelper,ColorHelper,PI_360,Queue,GridNeighborType,BinaryHeap,Grid,Line}from'helpers-lib';import W from'p2';import*as V from'pixi.js';import {RichTextSeparator}from'script-engine-lib';var cr=Object.defineProperty;var h=(o,t)=>cr(o,"name",{value:t,configurable:true});var G=class{static{h(this,"BardLegendsHardReset");}static{this.ƀes=new Action;}static{this.onHardReset=this.ƀes.notifier;}static hardReset(){ActionLib.hardReset(),this.ƀes.trigger();}};function d(){return function(o){let t=P.ƀec(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var P=class{static{h(this,"Service");}static{this.ƀir=new Map;}static get(t){let e=this.ƀir.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀid([],t.$meta.paramtypes);e=new t(...i),this.ƀir.set(t,e);}return e}static ƀec(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e}static ƀid(t,e){let i=[...t];if(e.length>t.length){let s=e.slice(t.length).map(n=>{if(n&&n.$meta?.type==="service")return this.get(n)});i.push(...s);}return i}};G.onHardReset.subscribe(()=>{P.ƀir=new Map;}).attachToRoot();var U=class{static{h(this,"ControllerLink");}constructor(){this.ƀbm=[],this.ƀic=[];}trigger(t,...e){let i=this.ƀbm.find(r=>!!r[t]);if(i)return i[t](...e);throw new Error(`ServiceLink: no defined function with the name: "${t}", found in the linked controllers!`)}registerController(t){Reflect.ownKeys(t.constructor.prototype).filter(e=>e!=="constructor").map(e=>e.toString()).forEach(e=>{if(this.ƀic.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀic.push(e);}),this.ƀbm.push(t);}};function q(o){return function(t){let e=P.ƀec(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=P.ƀid([],e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);o.controllerLink.registerController(r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var y=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀij=new Action;}static{this.sceneUpdateAction=this.ƀij.notifier;}static{this.ƀf=new Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀjv=0;}static{this.ƀkd=void 0;}static wait(t){let e=this.ƀjv+t;return SingleEvent.create(i=>{let r=o.beforeSceneUpdateAction.subscribe(s=>{s.time>=e&&i();}).attachToRoot();return ()=>r.destroy()})}static registerUpdateModifier(t){if(!this.ƀkd)this.ƀkd=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkd=void 0;}static triggerUpdateTick(t){this.ƀkd&&(t=this.ƀkd(this.ƀjv,t)),this.ƀjv+=t,this.ƀfr=t,t>0&&(o.ƀad.trigger({time:this.ƀjv,delta:t}),o.ƀij.trigger({time:this.ƀjv,delta:t}),o.ƀf.trigger({time:this.ƀjv,delta:t}));}static get lastDelta(){return this.ƀfr}static{this.ƀfr=0;}};G.onHardReset.subscribe(()=>{y.ƀad.clear(),y.ƀij.clear(),y.ƀf.clear(),y.ƀkd=void 0,y.ƀjv=0;}).attachToRoot();var _=class o{static{h(this,"EntityStoreHelper");}static{this.ƀaw=new Map;}static registerEntityClass(t){this.ƀaw.set(t.id,new Map);}static registerEntity(t){this.ƀaw.get(t.classID).set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀaw.get(i)?.delete(e);}static getEntity(t,e){return this.ƀaw.get(t.id)?.get(e)}static getSingleton(t){let e=o.getEntities(t);if(e.length>1)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has multiple instances! Name: "${this.name}"`);return e[0]}static getSingletonOrFail(t){let e=this.getSingleton(t);if(!e)throw new Error(`EntityStoreHelper: selectSingleton is called with an entity that has no instance! Name: "${this.name}"`);return e}static getEntities(t){let e=this.ƀaw.get(t.id);return Array.from(e.values())}};G.onHardReset.subscribe(()=>{_.ƀaw.clear();}).attachToRoot();var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀkm=new Map;}static registerView(t,e){o.ƀkm.has(e)||o.ƀkm.set(e,[]);let i=o.ƀkm.get(e);i&&i.push(t),_.getEntities(e).forEach(s=>{this.ƀch(s,t);});}static ƀch(t,e){try{let i=P.ƀid([this],e.$meta.paramtypes);o.entityID=t.id;let r=new e(t,...i.slice(1));t.destroyed?r.destroy():t.ƀkl.ƀkn.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcw=t,this.ƀkn=[];}createViews(){if(!this.ƀcw.destroyed){let t=o.ƀkm.get(this.ƀcw.constructor);t&&t.forEach(e=>{o.ƀch(this.ƀcw,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkn.length;i++){let r=this.ƀkn[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkn.forEach(t=>{t.destroy();});}};G.onHardReset.subscribe(()=>{rt.ƀkm=new Map;}).attachToRoot();function dt(){return function(o){o.$meta={type:"entity"},_.registerEntityClass(o);}}h(dt,"EntityDecorator");var $=class extends IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return _.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=_.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return _.getEntities(this)}constructor(){super(),this.ƀkl=new rt(this),_.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀkl.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀkl.destroyViews(),_.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀkl.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀkl.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀkl.createViews(),this}update(t,e){}};var ut=class extends ${static{h(this,"SingletonEntity");}static getInstance(){return _.getSingleton(this)}static getInstanceOrFail(){return _.getSingletonOrFail(this)}constructor(){if(super(),this.constructor.getEntities().length>1)throw this.attachToRoot(),new Error(`SingletonEntity: entity is decorated as singleton but multiple instances are created! "${this}"`)}};function wr(){return function(o){return o.$meta={paramtypes:P.ƀec(o),type:"scene"},o}}h(wr,"SceneDecorator");var Pt=class o extends IDAttachable{static{h(this,"Scene");}static{this.ƀii=false;}static{this.ƀb=new Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveScene(){return o.ƀb.value}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static isActive(){return o.ƀb.value instanceof this}static getInstance(){return o.ƀb.value instanceof this?o.ƀb.value:void 0}static getInstanceOrFail(){if(!o.ƀb.value)throw new Error("Scene: getInstance is called when there is no active scene!");if(!(o.ƀb.value instanceof this))throw new Error(`Scene: getInstance is called while "${this.name}" was not the active scene. Current scene is: "${o.ƀb.value}"!`);return o.ƀb.value}static open(...t){if(o.ƀii)throw new Error("Scene: you cannot open a scene while a scene is transitioning!");if(o.ƀb.value)throw new Error("Scene: you cannot open a scene while there is already another active scene!");let e=t[0];o.ƀii=true;let i=P.ƀid([],this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀii=false,r)).chainToRoot()}constructor(){super(),this.ƀgn=new Action,this.onClose=this.ƀgn.notifier,y.sceneUpdateAction.subscribe(t=>this.update(t.time,t.delta)).attach(this);}close(...t){if(o.ƀb.value!==this)throw new Error("Internal Error: Scene instance is accessed while it is not the active scene!");if(o.ƀii)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀii=true;let e=t[0];return this.prepareToClose().map(()=>(super.destroy(),o.ƀb.set(void 0),o.ƀii=false,this.ƀgn.trigger(e),e)).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};G.onHardReset.subscribe(()=>{Pt.ƀb.set(void 0);}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:P.ƀec(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var Ht=class extends IDAttachable{static{h(this,"View");}static getInstance(t){return this.$meta.entity.validateID(t)?this.$meta.viewInstances.get(t):void 0}static getInstanceOrFail(t){if(!this.$meta.entity.validateID(t))throw new Error(`View: getInstance is called with entity id: "${t}", that is not belonging to the class: "${this.$meta.entity}"`);let i=this.$meta.viewInstances.get(t);if(!i)throw new Error(`View: getInstanceOrFail is called with entity id: "${t}", that is not found!`);return i}constructor(){super(),this.attachToRoot(),this.ƀcx=rt.entityID,this.ƀei().set(this.ƀcx,this);}destroy(){this.destroyed||(super.destroy(),this.ƀei().delete(this.ƀcx));}update(t,e){}ƀei(){return this.constructor.$meta.viewInstances}};var f=class o{static{h(this,"P2JSHelper");}static aabbToBoundingBox(t){return Rectangle.fromRect({topLeft:{x:t.lowerBound[0],y:t.lowerBound[1]},bottomRight:{x:t.upperBound[0],y:t.upperBound[1]}})}static arrayToVector(t){return new Vector(t[0],t[1])}static vectorToArray(t){return [t.x,t.y]}static arePhysicsGroupsCollidable(t,e,i,r){return (t&r)!==0&&(i&e)!==0}static canCollideWith(t,e){return t.shapes.some(i=>e.shapes.some(r=>o.arePhysicsGroupsCollidable(i.collisionGroup,i.collisionMask,r.collisionGroup,r.collisionMask)))}static cloneP2Body(t){let e=new W.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var Sr=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},J=new U,St=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return J.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return J.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return J.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return J.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return J.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return J.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return J.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return J.trigger("subscribeToPhysicsStep",t,e)}};St=Sr([d()],St);var b=class o extends ${static{h(this,"PhysicsEntity");}static{this.ƀhb=new Map;}static{this.ƀhi=new Map;}static getFromP2BodyID(t){return o.ƀhb.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhb.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhi.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhi.values())}get area(){return this.ƀu}get mass(){return this.ƀgd}get collisions(){return this.ƀay}constructor(t,e,i){super(),this.ƀgo=new Action,this.onCollision=this.ƀgo.notifier,this.type="dynamic",this.ƀu=0,this.ƀgd=0,this.ƀay=[],this.physicsWorldID=t,this.ƀhk=P.get(St);let r=this.ƀhk.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhk.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀhj=this.ƀhk.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhl=this.ƀhk.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhk.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgd=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhk.addBody(this.physicsWorldID,this.p2Body,e.addInEmptySpace,e.shapeDefinition.group,e.includeOnPathfinding))throw new Error("PhysicsEntity was not able to be added to the world!");o.ƀhb.set(this.p2Body.id,this),o.ƀhi.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhk.removeBody(this.physicsWorldID,this.p2Body),o.ƀhb.delete(this.p2Body.id),o.ƀhi.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀhj,this.ƀhl,t.ƀhj,t.ƀhl)}ƀis(t){this.ƀay=t,t.length>0&&this.ƀgo.trigger(t);}};var Wt=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=f.arrayToVector(this.p2Body.position),this.rotation=new Radian(this.p2Body.angle);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position,rotation:this.rotation,velocity:Vector.zero,rotationalSpeed:0}}};var Xe=class extends ${static{h(this,"MovableEntity");}constructor(){super(),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),y.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀjk(t,e);}).attach(this);}ƀjk(t,e){this.position.value=this.position.value.add(this.velocity.value.multiplyNumber(e)),this.rotation.value=new Radian(this.rotation.value.value+this.rotationalSpeed.value*e);}};var Ke=class extends b{static{h(this,"MovablePhysicsEntity");}constructor(t,e){super(t,e,"dynamic"),this.position=new Variable(Vector.zero),this.rotation=new Variable(Radian.get0),this.velocity=new Variable(Vector.zero),this.rotationalSpeed=new Variable(0),this.ƀez=false,this.ƀfa=false,this.ƀfc=false,this.ƀfb=false,this.ƀhf(),this.ƀfx(),P.get(St).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjk(i,r)).attach(this);}convertToDTO(){return {entityID:this.id,classID:this.classID,position:this.position.value,rotation:this.rotation.value,velocity:this.velocity.value,rotationalSpeed:this.rotationalSpeed.value}}ƀjk(t,e){this.ƀez=true,this.ƀfa=true,this.ƀfc=true,this.ƀfb=true,this.ƀhf();}ƀhf(){this.position.value=f.arrayToVector(this.p2Body.position),this.rotation.value=new Radian(this.p2Body.angle),this.velocity.value=f.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀfx(){this.position.subscribe(t=>{this.ƀez?this.ƀez=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfa?this.ƀfa=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfb?this.ƀfb=false:this.p2Body.angularVelocity=t;}).attach(this);}};var Ze=10.8,Qe=10.01,tt;(function(o){o[o.Point=1]="Point",o[o.Circle=2]="Circle",o[o.Polygon=3]="Polygon",o[o.Rectangle=4]="Rectangle";})(tt||(tt={}));var st="border";var Y=class{static{h(this,"AnimationInterpolationFunctions");}static boomerangTime(t){return 1-Math.abs(t-.5)*2}static lineer(t){return t}static easeIn(t){return Math.pow(t,2)}static easeOut(t){return 1-Math.pow(1-t,2)}static easeInOut(t){return t<.5?2*t*t:(t-=1,1-2*t*t)}static easeInOutCubic(t){let e=2*t-2;return t<.5?4*Math.pow(t,3):(t-1)*Math.pow(e,2)+1}},Rr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return Y.lineer(t)}},Ir=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return Y.easeIn(t)}},Ar=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return Y.easeOut(t)}},Or=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return Y.easeInOut(t)}},Mr=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return Y.easeInOutCubic(t)}},Ai=class{static{h(this,"AnimationFlicker");}start(){this.ƀjw=new Array(10).fill(0),Random.integerBetween(0,9),this.ƀjw[Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(Random.integerBetween(0,9),this.ƀjw[Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(Random.integerBetween(0,9),this.ƀjw[Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀjw[e]}},S=class{static{h(this,"Animations");}static{this.lineer=new Rr;}static{this.easeIn=new Ir;}static{this.easeOut=new Ar;}static{this.easeInOut=new Or;}static{this.easeInOutCubic=new Mr;}};var F;(function(o){o[o.ThrowError=1]="ThrowError",o[o.IgnoreNewAnimation=2]="IgnoreNewAnimation",o[o.CompletePrevious=3]="CompletePrevious";})(F||(F={}));var R;(function(o){o[o.ReturnToOriginal=1]="ReturnToOriginal",o[o.StayInCurrentState=2]="StayInCurrentState",o[o.JumpToEnd=3]="JumpToEnd",o[o.Loop=4]="Loop";})(R||(R={}));var A=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdj(t){let e=o.ƀk.get(t);return e||(e=new MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀgx!==void 0}get target(){return this.ƀjn}get value(){return this.ƀkf||(this.ƀkf=new Variable(this.ƀjn)),this.ƀkf.notifier}constructor(t,e,i){this.ƀfl=false,this.ƀiz=false,this.ƀjn=t,this.ƀha={duration:200,animation:S.lineer,reAnimateHandling:F.ThrowError,completionHandling:R.StayInCurrentState,...i},this.ƀl=Comparator.isArray(e)?e:[e],this.ƀfy(t,this.ƀl);}animate(t,e){let i={...this.ƀha,...e};if(this.ƀgx)switch(i.reAnimateHandling){case F.ThrowError:throw new Error("Animator: new animation triggered while another is not complete yet.");case F.IgnoreNewAnimation:return SingleEvent.instant();case F.CompletePrevious:this.ƀit(i.completionHandling,this.ƀgx.ƀhu,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return SingleEvent.create(s=>{this.ƀfl&&(this.ƀiz=true);let n=this.ƀl.reduce((c,p)=>(c[p]={ƀjh:this.ƀjn[p],ƀjp:t[p]},c),{}),a={ƀcs:i.duration,ƀct:0,ƀhu:n,ƀbf:i.completionHandling,ƀm:i.animation,ƀbe:s};if(a.ƀbf!==R.Loop&&this.ƀfj(a)){this.ƀgx=void 0,s();return}else a.ƀm.start();let l=this.ƀgx;return this.ƀgx=a,this.ƀcv(),l?.ƀbe(),()=>{this.ƀgx===a&&(this.ƀjn instanceof Attachable&&this.ƀjn.destroyed||this.ƀit(a.ƀbf,a.ƀhu,true),this.ƀgx=void 0,this.ƀkc?.destroy(),this.ƀkc=void 0);}})}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r]&&(e=true,this.ƀjn[r]=t[r]);}e&&this.ƀkf?.set(this.ƀjn),this.ƀgx?.ƀbe();}completeAnimation(t){if(this.ƀgx){t=t??this.ƀgx.ƀbf,this.ƀit(t,this.ƀgx.ƀhu,true);let e=this.ƀgx.ƀbe;this.ƀgx=void 0,e();}}ƀcv(){this.ƀkc||(this.ƀkc=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfl=true;try{let e=this.ƀgx;if(!e)return;e.ƀct+=t.delta;let i=e.ƀct>=e.ƀcs;if(i)if(e.ƀbf===R.Loop)e.ƀct%=e.ƀcs,e.ƀm.start(),i=!1;else {this.ƀit(e.ƀbf,e.ƀhu,!1),this.ƀgx=void 0,e.ƀbe(),this.ƀgx||(this.ƀkc?.destroy(),this.ƀkc=void 0);return}if(!i){let r=e.ƀm.multiplierFunction(e.ƀct/e.ƀcs),s=!1;for(let n=0;n<this.ƀl.length;n++){let a=this.ƀl[n],l=e.ƀhu[a],p=(l.ƀjp-l.ƀjh)*r+l.ƀjh;p!==this.ƀjn[a]&&(s=!0,this.ƀjn[a]=p);}s&&this.ƀkf?.set(this.ƀjn);}}finally{this.ƀfl=false,this.ƀiz&&(this.ƀiz=false,this.ƀkc?.destroy(),this.ƀkc=void 0,this.ƀcv());}}).attachToRoot());}ƀfj(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjn[i]!==t.ƀhu[i].ƀjp)return false}return true}ƀit(t,e,i){switch(t){case R.ReturnToOriginal:this.ƀif(e);break;case R.StayInCurrentState:i||this.ƀfo(e);break;case R.JumpToEnd:this.ƀfo(e);break;case R.Loop:this.ƀif(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀif(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjh&&(e=true,this.ƀjn[r]=t[r].ƀjh);}e&&this.ƀkf?.set(this.ƀjn);}ƀfo(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjn[r]!==t[r].ƀjp&&(e=true,this.ƀjn[r]=t[r].ƀjp);}e&&this.ƀkf?.set(this.ƀjn);}ƀfy(t,e){let i=o.ƀdj(t);for(let r of e){if(i.has(r))throw new Error(`Animator: target property is already animated! Target: "${JSON.stringify(t,void 0,2)}", Property: "${r}"`);i.set(r,this);}}};var $t;(function(o){o.Click="click",o.MouseOver="mouseover",o.MouseOut="mouseout",o.PointerDown="pointerdown",o.PointerUp="pointerup",o.PointerUpOutside="pointerupoutside",o.PointerMove="pointermove",o.PointerCancel="pointercancel",o.PointerOver="pointerover",o.PointerOut="pointerout",o.PointerEnter="pointerenter",o.PointerLeave="pointerleave",o.Added="added",o.Removed="removed",o.Update="update",o.Change="change";})($t||($t={}));var qe;(function(o){o.Default="default",o.Pointer="pointer";})(qe||(qe={}));var ue=class extends IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgh=false,this.ƀdc=false,this.ƀig=1,this.ƀw=1,this.pixiContainer=new V.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new Vector(this.pixiContainer.width,this.pixiContainer.height)}setSize(t){return this.pixiContainer.width=t.x,this.pixiContainer.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.pixiContainer.getLocalBounds(),r=new Vector(this.pixiContainer.scale.x,this.pixiContainer.scale.y),s=new Vector(i.x,i.y).multiply(r),n=new Vector(i.width,i.height).multiply(r),a=s.add(n.multiply(e.holdFrom));t=t.subtract(a);}return e?.round!==false&&(t=t.round({rollHalfsDown:true})),this.position=t,this}get position(){return new Vector(this.pixiContainer.x,this.pixiContainer.y)}set position(t){this.pixiContainer.position=t;}get x(){return this.pixiContainer.x}set x(t){this.pixiContainer.x=t;}get y(){return this.pixiContainer.y}set y(t){this.pixiContainer.y=t;}on(t){return Sequence.create(e=>{let i=h(r=>e(),"handle");return this.pixiContainer.on(t,i),()=>this.pixiContainer.off(t,i)})}setRotation(t){return this.rotation=t,this}get rotation(){return new Radian(this.pixiContainer.rotation)}set rotation(t){this.pixiContainer.rotation=t.value;}get rotationValue(){return this.rotation.value}set rotationValue(t){this.rotation=new Radian(t);}setZIndex(t){return this.zIndex=t,this}get zIndex(){return this.pixiContainer.zIndex}set zIndex(t){this.pixiContainer.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new Radian(this.pixiContainer.skew.x)}set skewX(t){this.pixiContainer.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new Radian(this.pixiContainer.skew.y)}set skewY(t){this.pixiContainer.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.pixiContainer.sortableChildren}set sortableChildren(t){this.pixiContainer.sortableChildren=t;}setAlpha(t){return this.pixiContainer.alpha=t,this}get alpha(){return this.pixiContainer.alpha}set alpha(t){this.pixiContainer.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.pixiContainer.interactive}set interactive(t){t?this.pixiContainer.eventMode="dynamic":this.pixiContainer.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.pixiContainer.cursor}set cursor(t){this.pixiContainer.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.pixiContainer.addChild(t.pixiContainer),this.pixiContainer.mask=t.getMask(),this.ƀgb=t):(this.ƀgb&&this.pixiContainer.removeChild(this.ƀgb.pixiContainer),this.pixiContainer.mask=null),this}hitTest(t){if(this.pixiContainer.parent)if(this.pixiContainer.hitArea){let e=this.pixiContainer.toLocal(t);return this.pixiContainer.hitArea.contains(e.x,e.y)}else return this.pixiContainer.getBounds().contains(t.x,t.y);else return false}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgh}set mirror(t){this.ƀgh=t,this.ƀke();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdc}set flip(t){this.ƀdc=t,this.ƀke();}setScale(t){return this.scale=t,this}get scale(){return this.ƀig}set scale(t){this.ƀig=t,this.ƀke();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀke();}ƀke(){this.pixiContainer.scale.set(this.ƀig,this.ƀig),this.ƀw<1?this.pixiContainer.scale.x*=this.ƀw:this.ƀw>1&&(this.pixiContainer.scale.y/=this.ƀw),this.ƀgh&&(this.pixiContainer.scale.x*=-1),this.ƀdc&&(this.pixiContainer.scale.y*=-1);}};var O=2,Tt;(function(o){o[o.Normal=0]="Normal",o[o.Add=1]="Add",o[o.Screen=3]="Screen",o[o.Luminosity=16]="Luminosity",o[o.ColorDodge=7]="ColorDodge";})(Tt||(Tt={}));var fe=class{static{h(this,"GaussianValuesHelper");}static ƀdh(t,e){let i=e*e,r=1/(PI_360*i),s=-(t*t)/(2*i);return r*Math.exp(s)}static getValuesForLinearSamplingPascal(t){let e=t*2,i=Math.pow(2,e),r=.005*i,s=NumberHelper.pascalTriangleRow(e).slice(t).filter(l=>{if(l<r)i-=l*2;else return true}),n=1/i,a=s.map(l=>l*n);return this.ƀbr(a)}static getValuesForLinearSamplingGauss(t){if(t===0)return [{offset:0,multiplier:1}];if(t===1)return [{offset:0,multiplier:.5},{offset:1,multiplier:.25}];{let e=ArrayHelper.createIntegerArray(Math.ceil(t*.75)).map(r=>this.ƀdh(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbr(e)}}static ƀbr(t){let e=[{offset:0,multiplier:t[0]}];for(let i=1;i<t.length-1;i+=2){let r=t[i]+t[i+1],s=i+t[i+1]/r;e.push({offset:s,multiplier:r});}if(t.length%2===0){let i=t[t.length-1],r=t.length-1;e.push({offset:r,multiplier:i});}return e}};var Di=class ti extends V.Filter{static{h(this,"BlurFilterPass");}static ƀeh(){return `
|
|
2
2
|
attribute vec2 aVertexPosition;
|
|
3
3
|
attribute vec2 aTextureCoord;
|
|
4
4
|
|
|
@@ -64,4 +64,4 @@ import {Action,ActionLib,SingleEvent,IDAttachable,Variable,Attachable,ActionSubs
|
|
|
64
64
|
highestAlpha = centerColor.a;`,e+=`
|
|
65
65
|
|
|
66
66
|
gl_FragColor = vec4(color, 1.0) * highestAlpha;
|
|
67
|
-
}`,e}constructor(t,e){if(super(o.ƀeh(),o.ƀdq(t*O)),this.ƀcy=t,this.resolution=O,this.ƀcy=t*O,this.ƀcy<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcy>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");Comparator.isInteger(this.ƀcy)||(this.ƀcy=Math.floor(this.ƀcy));let i=ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcy*this.ƀcy,this.padding=this.ƀcy;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*O),1/(e.height*O)]),t.applyFilter(this,e,i,r);}};var Te=class extends V.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=O;let e={blurRadius:1,expand:0,color:ColorHelper.white,blendMode:Tt.Screen,...t};this.ƀcz=new Ce(e.expand,e.color);let i=Comparator.isNumber(e.blurRadius)?new Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Et(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=V.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀcz.apply(t,e,s,V.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀek=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbd(e),s=Comparator.isNumber(r.blurRadius)?new Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀds(t.texture,s,r.expand,r.color,i),a=new V.Sprite(n);return this.ƀiu(a,Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀds(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀek.has(n))return o.ƀek.get(n);{let a=this.ƀdt(t,e,i,r);return o.ƀek.set(n,a),a}}else return this.ƀdt(t,e,i,r)}static ƀdt(t,e,i,r){let s=new V.Sprite(t);this.ƀdb(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀiu(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdb(t,e){if(t.isSprite){let s=new V.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbd(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:ColorHelper.white,blendMode:Tt.Add};return t&&(e={...e,...t}),e}};G.onHardReset.subscribe(()=>{Zt.ƀek.clear();}).attachToRoot();var X=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=w.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.pixiContainer,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:V.SCALE_MODES.LINEAR,multisample:V.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:Vector.zero,boundingShapes:void 0,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀju=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjd=t,this.pixiSprite=new V.Sprite(M.getAsset(t.id)),this.pixiContainer.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgc?.destroy(),this.ƀak?.destroy(),this.ƀjd.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjd.id),this.ƀhq&&M.destroyAsset(this.ƀhq.texture.id)),this.ƀhq&&!this.ƀhq.destroyed&&this.ƀhq.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀju}set textureScale(t){this.ƀju=t,this.pixiSprite.scale.set(t);}get size(){return new Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀjd.boundingShapes&&!this.pixiContainer.hitArea&&(this.pixiContainer.hitArea=new we(this.ƀjd.boundingShapes,this.size,Vector.fromVec2(this.ƀjd.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===V.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=V.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=V.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new V.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀhq)return this.ƀhq.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhq)this.ƀhq.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=Vector.fromVec2(this.ƀjd.anchor).to(t);return new Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhq&&(this.ƀhq.destroy(),this.ƀhq=void 0),t&&(this.ƀhq=Zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjd.destroyAssetOnDestroy),this.ƀhq.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhq.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.pixiContainer.addChild(this.ƀhq)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbt().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgc){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgc=this.ƀbt(),this.ƀgc.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgc.pixiSprite.renderable=false,this.ƀgc.displayParent(this);}return this.ƀgc}ƀbt(){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀjd.boundingShapes,ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.pixiContainer);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}};var Ee=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,m=Math.floor(c/p),g=c-p*m;m>=1&&g<i.dashLength&&(g+=p,m--);let E=s.normalize(g/2),vt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(E)}),l=l.add(E),m>0){let ne=s.normalize(i.dashLength);ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(vt),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(vt),a.push({from:l,to:l.add(E)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcr=new Map;}static createArrow(t,e){let i=new V.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new V.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:ColorHelper.white,...i},s=new V.Graphics;return s.lineStyle(r.width,r.color),Ee.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new V.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new V.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=ColorHelper.white){let i=new V.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new V.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new V.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new V.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new V.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new V.Graphics,s=new Radian(PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.pixiContainer.addChild(t),this.pixiGraphics=t,this.ƀam=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀam,cache:false,...t},i=this.ƀee(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},boundingShapes:void 0,destroyAssetOnDestroy:!e.cache},s=new X(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀee(t,e){if(e){let i=o.ƀcr.get(t);return i||(i=this.ƀcf(),o.ƀcr.set(t,i)),i}else return this.ƀcf()}ƀcf(){let t=w.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {assetID:t.id,bounds:new Vector(e.x,e.y)}}};var ai=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀhr=new V.Graphics,this.ƀhr.beginFill(0,1e-9),this.ƀhr.drawRect(0,0,t.x,t.y),this.ƀhr.endFill(),this.pixiContainer.addChild(this.ƀhr);}destroy(){this.destroyed||(super.destroy(),this.ƀhr.destroy());}};var Ot=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:Radian.get60,distance:10,color:ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return {fontFamily:e.fontFamily,fill:ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r}}};var Ie=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=RichTextSeparator.process(t,i),s=this.ƀfe(r,e),n=this.ƀs(s);return this.ƀjb(n)}static ƀfe(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Ot.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdo(a.tags,e,i),p=s(l,c),m=V.TextMetrics.measureText(" ",new V.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdo(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbb(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbb(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀjb(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀjc(s.text).map(a=>{let l=new V.TextStyle(s.pixiStyle),c=V.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀjc(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Ae=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀkr(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀkr(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀkr(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀci.length===0}get remainingWidth(){return this.ƀkq-this.ƀck}constructor(t,e){if(this.ƀkq=t,this.ƀfu=[],this.ƀci=[],this.ƀck=0,this.ƀft=new Vector(0,0),this.ƀcj=0,this.ƀew=e?.horizontalAlignment??"left",this.ƀki=e?.verticalAlignment??"bottom",e?.rectangleCutOption){if(e.rectangleCutOption.position.x<0||e.rectangleCutOption.position.x>=this.ƀkq||e.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcl={direction:e.rectangleCutOption.direction,rectangle:this.ƀbp(e.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcj,t.y),i=this.ƀdw(this.ƀft.y,this.ƀft.y+e);return this.ƀck+t.x<=i}insertWord(t){let e=Math.max(this.ƀcj,t.style.height);if(this.ƀci.length===0){let i=this.ƀdx(this.ƀft.y,this.ƀft.y+e);this.ƀft=new Vector(i,this.ƀft.y),this.ƀck=this.ƀft.x;}this.ƀci.push({chunk:t,position:new Vector(this.ƀck,this.ƀft.y)}),this.ƀcj=e,this.ƀck+=t.style.width;}newLine(){let t=this.ƀft.y+this.ƀcj,e=this.ƀdx(t,t);this.ƀdd(),this.ƀft=new Vector(e,t),this.ƀck=this.ƀft.x,this.ƀcj=0;}print(){return this.ƀdd(),this.ƀfu}ƀdd(){this.ƀci.length>0&&(this.ƀfu.push(this.ƀg(this.ƀci)),this.ƀci=[]);}ƀg(t){return t=this.ƀkk(t),t=this.ƀey(t),t}ƀey(t){if(this.ƀew==="left")return t;let e=this.ƀft.y+this.ƀcj,i=this.ƀdx(this.ƀft.y,e),s=this.ƀdw(this.ƀft.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀew==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new Vector(l.position.x+a,l.position.y)},l))}ƀkk(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀki){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}return r={chunk:r.chunk,position:new Vector(r.position.x,r.position.y+s)},r})}ƀdx(t,e){return this.ƀcl&&(this.ƀcl.direction==="topLeft"||this.ƀcl.direction==="bottomLeft")&&(this.ƀcl.rectangle.isPointInside(new Vector(0,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new Vector(0,e),{includeEdges:false}))?this.ƀcl.rectangle.bottomRight.x:0}ƀdw(t,e){return this.ƀcl&&(this.ƀcl.direction==="topRight"||this.ƀcl.direction==="bottomRight")&&(this.ƀcl.rectangle.isPointInside(new Vector(this.ƀkq,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new Vector(this.ƀkq,e),{includeEdges:false}))?this.ƀcl.rectangle.topLeft.x:this.ƀkq}ƀbp(t){let e,i;switch(t.direction){case "topRight":e=new Vector(t.position.x,-1/0),i=new Vector(1/0,t.position.y);break;case "topLeft":e=new Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new Vector(1/0,1/0);break;case "bottomLeft":e=new Vector(-1/0,t.position.y),i=new Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new Rectangle(e,i)}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgg(t),t=this.ƀka(t),this.ƀav(t)}static ƀgg(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀka(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀav(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ie.process(t,e),r=new Oe(e.default.wordWrapWidth??1/0,{rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=Ae.wrapText(i,r);return Me.process(s)}};var Cs=1,$i=1/Cs,te=class extends u{static{h(this,"Text");}get ƀjs(){if(!this.ƀjt){let t=new V.TextStyle(this.ƀht);this.ƀjt=V.TextMetrics.measureText(this.ƀjr,t);}return this.ƀjt}get ascent(){return this.ƀjs.fontProperties.ascent}constructor(t,e){super(),this.ƀht=Ot.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhs.destroyed&&this.ƀhs.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new Vector(this.ƀhs.anchor.x,this.ƀhs.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhs.anchor.set(t.x,t.y);}setPosition(t,e){if(e?.holdFrom){let i=this.ƀht.dropShadowDistance??0,r=new Vector(e.holdFrom.x*i,e.holdFrom.y*i);t=t.add(r);}return super.setPosition(t,e),this}setText(t){return this.ƀjr!==t&&(this.ƀjr=t,this.ƀia()),this}setColor(t){let e=ColorHelper.rgbToHex(t);return this.ƀht.fill!==e&&(this.ƀht.fill=e,this.ƀia()),this}ƀia(){this.ƀhs?.destroy(),this.ƀjm?.destroy(),this.ƀjm=void 0,this.ƀjt=void 0;let t=new V.TextStyle(this.ƀht);this.ƀhs=new V.Text(this.ƀjr,t),this.ƀi&&this.ƀhs.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhs.scale.set($i,$i),this.pixiContainer.addChild(this.ƀhs),this.ƀht.lineThrough&&(this.ƀjm=this.ƀe(this.ƀhs,this.ƀht.fill),this.pixiContainer.addChild(this.ƀjm));}ƀe(t,e){let i=V.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new V.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=V.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,g=0;t.style.align==="center"?g=0+(t.width-p.width)*.5:t.style.align==="right"&&(g=0+t.width-p.width),g=Math.floor(g),n.moveTo(Math.floor(g),m),n.lineTo(Math.floor(g+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var hi=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new te(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var li=class extends u{static{h(this,"UpdatableContainer");}},ci=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbv=t,this.ƀco=new Map,this.ƀha={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀco.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀha.trackBy(r,s),a;this.ƀco.has(n)?(a=this.ƀco.get(n),e.delete(n),a.update(r)):(a=this.ƀbv(r).displayParent(this).attach(this),this.ƀco.set(n,a)),this.ƀha.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀha.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀha.positioning.spacing);}),e.forEach(r=>{this.ƀco.get(r).destroy(),this.ƀco.delete(r);});}};var Dt=class o extends u{static{h(this,"Menu");}static{this.ƀjy=false;}static closeAll(){return o.ƀgz?o.ƀgz.close():SingleEvent.instant()}constructor(t,e){super(),this.ƀgs=new SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new SingleAction,this.onClose=this.ƀgn.notifier;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,darkeningAlpha:.3,...e};this.setZIndex(100).setAlpha(0),this.ƀo=new A(this,"alpha",{animation:S.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:F.CompletePrevious,completionHandling:R.StayInCurrentState}),this.ƀaa=T.createRectangle(new Vector(1,1),ColorHelper.black).toSprite({cache:true}).setAlpha(i.darkeningAlpha).setInteractive(true).displayParent(this).attach(this),this.ƀgf=X.createByName(t).setPosition(new Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(r=>{this.ƀaa.aspectRatio=r.x/r.y,this.ƀaa.scale=Math.max(r.x,r.y),this.ƀaa.setPosition(Vector.zero,{holdFrom:Vector.half}),this.setPosition(r.multiplyNumber(.5));}).attach(this),o.ƀgz=this,this.onDestroy().tap(()=>{o.ƀgz=void 0;}).attachToRoot(),i.closeOnBackgroundClick&&this.ƀaa.on($t.Click,()=>{o.ƀjy||this.ƀq(false);}).attach(this),this.ƀq(true);}getBoundingMask(){return this.ƀgf.getBoundingMask()}close(){return this.ƀq(false)}ƀq(t){if(o.ƀjy)throw new Error("WindowUI: cannot iterate while in transition");return o.ƀjy=true,this.ƀo.animate({alpha:t?1:0}).chain(this).tap(()=>{o.ƀjy=false,t?this.ƀgs.resolve():(this.ƀgn.resolve(),this.destroy());}).chainToRoot()}};var di=class extends ut{static{h(this,"MenuEntity");}constructor(t,e){super(),this.ƀgq=new SingleAction,this.onCreate=this.ƀgq.notifier,this.ƀgs=new SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new SingleAction,this.onClose=this.ƀgn.notifier,Dt.closeAll().tap(()=>{if(!Pt.getActiveScene())throw new Error("WindowEntity: constructor is called when there is no active scene!");w.pause.effect(true).attach(this),this.ƀgf=new Dt(t,e).displayParent(w.camera.layers.foregroundScreen).attach(this),this.ƀgq.resolve(this.ƀgf),this.ƀgf.onOpen.subscribe(()=>this.ƀgs.resolve()).attach(this),this.ƀgf.onClose.subscribe(()=>{this.destroy(),this.ƀgn.resolve();}).attach(this);}).attach(this);}getMenuEvents(){return {onOpen:this.onOpen.toSingleEvent().destroyIfNotAttached(),onClose:this.onClose.toSingleEvent().destroyIfNotAttached()}}close(){if(this.ƀgf){let t=this.onClose.toSingleEvent().destroyIfNotAttached();return this.ƀgf.close(),t}else return this.onCreate.asyncMapQueue(()=>this.close()).singleChain(this)}};var Rs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Is=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},mt=class{static{h(this,"MouseService");}get initialMouseMoveHappened(){return this.ƀfg.value}getStagePosition(){return this.ƀje.value}getScreenPosition(){return this.ƀik.value}getMainButtonState(){return this.ƀfz.value}getSecondaryButtonState(){return this.ƀiq.value}constructor(){this.ƀfg=new Variable(false),this.onInitialMouseMove=this.ƀfg.notifier,this.ƀje=new Variable(Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀje.notifier,this.ƀik=new Variable(Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀik.notifier,this.ƀfz=new Variable(false),this.mainButtonState=this.ƀfz.notifier,this.ƀiq=new Variable(false),this.secondaryButtonState=this.ƀiq.notifier,this.ƀjf(),window.addEventListener("mousedown",t=>{t.button===0?this.ƀfz.value=true:t.button===2&&(this.ƀiq.value=true);}),window.addEventListener("mouseup",t=>{t.button===0?this.ƀfz.value=false:t.button===2&&(this.ƀiq.value=false);}),window.addEventListener("blur",()=>{this.ƀfz.value=false,this.ƀiq.value=false;});}ƀjf(){let t=Vector.zero;window.addEventListener("mousemove",e=>{t=new Vector(e.clientX,e.clientY),this.ƀfg.value=true;}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀik.value=t;}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀik.value);e.isEqual(this.ƀje.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:this.ƀik.value.x,clientY:this.ƀik.value.y,pointerType:"mouse"})):this.ƀje.value=e;}).attachToRoot();}};mt=Rs([d(),Is("design:paramtypes",[])],mt);var ie=class extends u{static{h(this,"MouseWheelListenerUI");}constructor(t){super(),this.ƀgw=new Action,this.onWheel=this.ƀgw.notifier,this.ƀer=(e=>{let i=P.get(mt).getScreenPosition(),r=this.ƀkp.getBounds();i.x>=r.x&&i.x<=r.x+r.width&&i.y>=r.y&&i.y<=r.y+r.height&&this.ƀgw.trigger(e.deltaY);}).bind(this),this.ƀkp=new V.Graphics,this.ƀkp.beginFill(0,1e-9),this.ƀkp.drawRect(0,0,t.x,t.y),this.ƀkp.endFill(),this.pixiContainer.addChild(this.ƀkp),window.addEventListener("wheel",this.ƀer);}destroy(){this.destroyed||(super.destroy(),this.ƀkp.destroy(),window.removeEventListener("wheel",this.ƀer));}};var Ms=.65,Ds=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀio}get contentSize(){return this.ƀbi.size.ceil()}constructor(t,e,i,r){this.ƀbi=t,this.ƀv=e,this.ƀhc=i,this.ƀja=r,this.ƀfh=false,this.ƀio=e-i*2,this.ƀbi.y=i,this.ƀjn=i;}onWheel(t){this.setTarget(this.ƀjn-t*Ms);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjn=NumberHelper.clamp(t,this.ƀv-this.ƀhc-this.contentSize.y,this.ƀhc);}jumpToTarget(){this.ƀbi.y=this.ƀjn;}update(t){let e=this.contentSize;if(e.y<=this.ƀio){switch(this.ƀja){case "start":this.ƀjn=this.ƀhc;break;case "center":this.ƀjn=(this.ƀv-e.y)*.5;break;case "end":this.ƀjn=this.ƀv-e.y-this.ƀhc;break;default:{this.ƀja;throw new Error(`Unexpected case! "${this.ƀja}"`)}}this.ƀfh||(this.ƀbi.y=this.ƀjn);}this.ƀfh=true;let i=this.ƀjn-this.ƀbi.y;this.ƀbi.y=this.ƀbi.y+i*Ds*t;}};var fi=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},gt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcr=new Map;}constructor(t,e,i,r=et.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===et.Horizontal?this.ƀbz(e,i,s):this.ƀcg(e,i,s),this.ƀgc=X.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgc);}ƀcg(t,e,i){e>0&&this.ƀbw(new Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new Vector(t.x,t.y-e*2),ColorHelper.white).toSprite().setPosition(new Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new Vector(t.x,e)).setPosition(new Vector(t.x,t.y),{round:false}).setRotation(Radian.get180).displayParent(i).attach(i);}ƀbz(t,e,i){e>0&&this.ƀbw(new Vector(t.y,e)).setPosition(new Vector(0,t.y),{round:false}).setRotation(Radian.get270).displayParent(i).attach(i),T.createRectangle(new Vector(t.x-e*2,t.y),ColorHelper.white).toSprite().setPosition(new Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new Vector(t.y,e)).setPosition(new Vector(t.x,0),{round:false}).setRotation(Radian.get90).displayParent(i).attach(i);}ƀbw(t){let i={id:this.ƀbx(t.y),scale:1,size:t,anchor:{x:0,y:0},boundingShapes:void 0};return new X(i,{textureSize:t,ignoreAnchor:true})}ƀbx(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcr.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new fi;ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=V.Texture.from(r);i=M.insertAsset(a),o.ƀcr.set(e,i);}else throw new Error("Canvas context is null")}return i}};var _s=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbj}get contentSize(){return this.ƀip.contentSize}constructor(t,e={}){super();let i={padding:_s,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new gt(r,t,i.padding).attach(this);let s=new u().displayParent(r).attach(this);this.ƀip=new Ge(s,t.y,i.padding,i.smallContentAlign),this.ƀbj=new Vector(t.x,this.ƀip.scrollHeight),new ie(t).displayParent(r).attach(this).onWheel.subscribe(a=>this.ƀip.onWheel(a)).attach(this),y.afterSceneUpdateAction.subscribe(a=>this.ƀip.update(a.delta)).attach(this),this.addChildTo=s;}scrollToTop(t){this.ƀip.scrollToTop(),t?.instant&&this.ƀip.jumpToTarget();}scrollToBottom(t){this.ƀip.scrollToBottom(),t?.instant&&this.ƀip.jumpToTarget();}};var Fs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ls=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},gi=class{static{h(this,"KeyboardService");}constructor(){this.ƀfp=new Action,this.keyPressed=this.ƀfp.notifier,this.ƀfq=new Action,this.keyReleased=this.ƀfq.notifier,this.ƀfw=new Set,this.ƀfv=new Set,window.addEventListener("keydown",t=>{this.ƀfw.add(t.key),this.ƀfv.add(t.key),!t.repeat&&this.ƀfp.trigger(t.key);}),window.addEventListener("keyup",t=>{this.ƀfw.delete(t.key),this.ƀfq.trigger(t.key);}),window.addEventListener("blur",()=>{this.ƀfw.clear();}),y.afterSceneUpdateAction.subscribe(()=>{this.ƀfv.clear();}).attachToRoot();}isKeyDown(t){return this.ƀfw.has(t)}isKeyJustPressed(t){return this.ƀfv.has(t)}};gi=Fs([d(),Ls("design:paramtypes",[])],gi);var Vs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ns=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},yi=class{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀde}get lastFocusedPosition(){return this.ƀfs}constructor(t){this.ƀgi=t,this.ƀgu=new Action,this.onTargetFocus=this.ƀgu.notifier,this.ƀjx=0,this.ƀjz=false,this.ƀde=false,this.ƀfs=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀkb(e.delta)).attachToRoot();}ƀkb(t){if(this.ƀgj){let e=this.ƀed(this.ƀgi.getStagePosition(),this.ƀgj);this.ƀhe===void 0?this.ƀhe=e:this.ƀau(e,t);}this.ƀgj=this.ƀgi.getStagePosition();}ƀau(t,e){this.ƀhe-t>10?(this.ƀjx=Math.max(250,this.ƀjx),this.ƀjz=true):this.ƀjx>1e3&&(this.ƀjz=true);let i=this.ƀjx>=300&&this.ƀjz;this.ƀfn(i,t,e);}ƀfn(t,e,i){(t||e>this.ƀhe)&&(this.ƀhe=e),t?(this.ƀjz=false,this.ƀjx=0,this.ƀde=true,this.ƀfs=this.ƀgi.getStagePosition(),this.ƀgu.trigger(this.ƀfs)):(this.ƀjx+=i,this.ƀde=false);}ƀed(t,e){let i=Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};yi=Vs([d(),Ns("design:paramtypes",[mt])],yi);var x;(function(o){o[o.Hidden=1]="Hidden",o[o.Visible=2]="Visible",o[o.Appearing=3]="Appearing",o[o.Disappearing=4]="Disappearing",o[o.DisappearToChange=5]="DisappearToChange";})(x||(x={}));var _e=class extends Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgt=new Action,this.ƀgv=new Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀj.value=0,this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:F.CompletePrevious,completionHandling:R.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀo.completeAnimation(),this.ƀn=t!==void 0?x.Visible:x.Hidden,this.ƀhv=void 0;let i=t!==void 0?1:0,r=this.ƀji!==t;r&&(this.ƀji=t,this.ƀgt.trigger(this.ƀji)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀgv.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):(this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji)));break;case x.Disappearing:t===this.ƀji?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀhv=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0):t===this.ƀji?(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀhv&&(this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀgv.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀhv!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀji=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀhv===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀji=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};var Zi=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbv=t;let i={duration:200,animation:S.easeInOut,...e};this.alpha=0,this.ƀjj=new _e(i).onStateChange(r=>{this.ƀbi?.destroy(),this.ƀbi=void 0,r!==void 0&&(this.ƀbi=new u().displayParent(this).attach(this),this.ƀbv({state:r,container:this.ƀbi}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjj.setState(t,e),this}};var I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var Fe=class extends Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,nextState:this.ƀgl,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgt=new Action,this.ƀgv=new Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:F.CompletePrevious,completionHandling:R.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀji===void 0)this.ƀji=t,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀji=t,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀji&&(this.ƀn=I.Transitioning,this.ƀgl=t,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case I.Transitioning:t!==this.ƀgl&&(t===this.ƀji?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;case I.Reverting:t!==this.ƀji&&(t===this.ƀgl?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀji=this.ƀgl,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀji=this.ƀgl,this.ƀgl=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀji===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};var it;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(it||(it={}));var C;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(C||(C={}));var Le=class extends Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=C.Idle,this.ƀgt=new Action,this.ƀgv=new Action,this.ƀha={duration:500,animation:S.easeInOutCubic,...t},this.ƀjj=new Fe({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((e,i)=>this.ƀep(e,i)).onValueChange(e=>this.ƀeq(e)).attach(this);}setIndex(t,e){if(!Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀff===void 0?(this.ƀff=t,this.ƀgt.trigger({state:it.Appear,index:t}),this.ƀjj.setState(t,e)):this.ƀff!==t?this.ƀgk!==t?this.ƀn===C.Idle?(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀgk=t,this.ƀgt.trigger({state:it.Appear,index:this.ƀgk}),this.ƀjj.setState(t,e)):this.ƀjj.setState(t,e):this.ƀn===C.Reverting&&this.ƀgk===t&&(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀjj.setState(t,e)):(this.ƀn===C.TransitionForward||this.ƀn===C.TransitionBackward)&&(this.ƀn=C.Reverting,this.ƀjj.setState(t,e));}ƀep(t,e){switch(this.ƀff!==void 0&&this.ƀff!==t&&this.ƀff!==e&&this.ƀgt.trigger({state:it.Disappear,index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgk!==t&&this.ƀgk!==e&&this.ƀgt.trigger({state:it.Disappear,index:this.ƀgk}),e!==void 0&&e!==this.ƀff&&e!==this.ƀgk&&this.ƀgt.trigger({state:it.Appear,index:e}),this.ƀn){case C.Idle:break;case C.TransitionForward:case C.TransitionBackward:e===void 0?(this.ƀn=C.Idle,this.ƀff=this.ƀgk,this.ƀgk=void 0):this.ƀff!==t&&this.ƀen(t,e);break;case C.Reverting:e===void 0?(this.ƀn=C.Idle,this.ƀgk=void 0):this.ƀff!==e&&this.ƀen(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀeq(t){let e=1;(this.ƀn===C.TransitionBackward||this.ƀn===C.Reverting&&this.ƀff!==void 0&&this.ƀgk!==void 0&&this.ƀff>this.ƀgk)&&(e=-1),(this.ƀn===C.Idle||t!==0)&&this.ƀgv.trigger({value:NumberHelper.ensurePositiveZero(-e*t),index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgv.trigger({value:NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgk});}ƀen(t,e){this.ƀff=t,this.ƀgk=e,this.ƀgv.trigger({value:0,index:this.ƀff}),this.ƀn=this.ƀff<this.ƀgk?C.TransitionForward:C.TransitionBackward;}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e.value,e.index)).attach(this),this}};var et;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(et||(et={}));var wi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbv=t,this.ƀcm="x",this.ƀbk=new Map,this.ƀha={duration:300,animation:S.easeInOutCubic,size:new Vector(500,500),margin:20,direction:et.Horizontal,...e};let i=this.ƀha.direction===et.Horizontal?new Vector(this.ƀha.size.x+this.ƀha.margin*2,this.ƀha.size.y):new Vector(this.ƀha.size.x,this.ƀha.size.y+this.ƀha.margin*2),r=new u().setPosition(this.ƀha.direction===et.Horizontal?new Vector(-this.ƀha.margin,0):new Vector(0,-this.ƀha.margin),{round:false}).displayParent(this).attach(this);this.ƀca(i,this.ƀha.margin,this.ƀha.direction,r),this.ƀcm=this.ƀha.direction===et.Horizontal?"x":"y",this.ƀjj=new Le({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((s,n)=>{if(s===it.Appear){let a=new u().displayParent(this).attach(this);this.ƀbk.set(n,a),this.ƀbv({index:n,container:a});}else {let a=this.ƀbk.get(n);a&&(a.destroy(),this.ƀbk.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbk.get(n);if(a){let l={x:0,y:0};l[this.ƀcm]=i[this.ƀcm]*s+this.ƀha.margin,a.setPosition(Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjj.setIndex(t,e),this}ƀca(t,e,i,r){new gt(r,new Vector(t.x,t.y),e,i).attach(this);}},er=class extends wi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var wt=class{static{h(this,"VectorSet");}constructor(){this.ƀkg=new Map;}add(t){let e=this.ƀkg.get(t.x);e||(e=new Set,this.ƀkg.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀkg.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀkg.get(t.x);return e?e.delete(t.y):false}};var xi=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var B=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new Vector(.5,.5)).multiplyNumber(e)}};var re=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=B.areaToGridArea(e,i);if(this.ƀat(t,s))return Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new wt,s=new Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new Rectangle(n,n.add(i));if(this.ƀat(t,a))return Vector.fromTo(e,n);t.getNeighborPositions(n,GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀat(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new Vector(r,i)))return false;return true}};var ir=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},to=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀem=t,this.ƀjg=e,this.ƀgy=new BinaryHeap("min"),this.ƀax=[],this.ƀgm=new Grid({size:t.size,defaultValue:void 0});let i=new ir(this.ƀjg,0,Number.MAX_SAFE_INTEGER);this.ƀgy.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀgy.size>0}getNeighbors(t,e){return this.ƀem.getNeighborPositions(t.position,e).filter(i=>this.ƀem.get(i)).map(i=>this.ƀgm.get(i)||this.ƀcb(i))}popLowestPathCostNode(){let t=this.ƀgy.pop();return this.ƀgy.delete(t),t.closed=true,this.ƀax.push(t),t}changeNodeCost(t,e,i,r){this.ƀgy.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀgy.add(t.pathLength,t);}getBestClosedNode(){return this.ƀax.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcb(t){let e=new ir(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgm.set(t,e),this.ƀgy.add(e.pathLength,e),e}},se=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new to(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var oe=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjo=t,this.ƀx=e,this.ƀet=this.ƀdv(this.ƀx.size),this.ƀko=new Grid({size:this.ƀx.size,defaultValue:this.ƀet}),this.ƀcn=new Grid({size:this.ƀx.size,defaultValue:void 0});let i=new wt,r=new Queue;for(this.ƀdk(this.ƀx.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀko.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀko.getOrFail(n);this.ƀea(n,this.ƀx).forEach(l=>{if(!i.has(l.position)){let c=this.ƀko.getOrFail(l.position),p=a+l.distance;this.ƀx.getOrFail(l.position)&&p<c&&(this.ƀko.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjo)){if(t=this.ƀko.movePositionInsideGrid(t),this.ƀcn.has(t))return this.ƀcn.get(t);{let e=this.ƀea(t,this.ƀx),i;return this.ƀko.getOrFail(t)>=this.ƀet?e.some(s=>this.ƀx.get(s.position))&&(e.some(n=>!this.ƀx.get(n.position))?i=this.ƀdp(e):i=this.ƀdl(t,e)):i=this.ƀdl(t,e),this.ƀcn.set(t,i),i}}}ƀdp(t){let e=t.filter(i=>this.ƀx.get(i.position)).map(i=>i.direction.radian);return Radian.getAverage(...e)}ƀdl(t,e){let i=e.filter(r=>this.ƀko.getOrFail(r.position)<this.ƀet).reduce((r,s)=>{let n=this.ƀko.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀet}).bestDirections;return this.ƀef(i,t)}ƀef(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),Vector.zero);if(i.isZero()||!this.ƀfk(e,i))return Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfk(t,e){let i=t.add(this.ƀkh(e));return this.ƀx.isPointWithinBounds(i)&&this.ƀx.getOrFail(i)}ƀea(t,e){return this.ƀko.getNeighborDirections(t,GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdk(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new Vector(r,i));return e}ƀkh(t){let e=t.normalize().round();return new Vector(e.x,e.y)}ƀdv(t){return (t.x+t.y)*20}};var oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},no=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends ${static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new Variable(false),this.lastP2Time=new Variable(0),this.onPhysicsStep=new Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=oo([dt(),no("design:paramtypes",[Vector,Boolean,W.World,Map,Map,Map,Map])],v);var co=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},K=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};K=co([d()],K);var po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},uo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ve=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhh=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhh.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};Ve=po([d(),uo("design:paramtypes",[K])],Ve);var fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},nt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhh=t,this.ƀy=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀy.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Bt){return e.aabbNeedsUpdate=true,e.updateAABB(),re.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀy.get(t,e,i);return r||(r=this.ƀby(t,e,i),this.ƀy.set(t,e,i,r)),r}ƀby(t,e,i){let r=new Grid({size:new Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀhh.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdu(s,e);r.setArea(a,false);}}),r}ƀdu(t,e){let i=f.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=fo([d(),mo("design:paramtypes",[K,Ve])],nt);var wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},xo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Bt=50,Gt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhg=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Bt);let n=v.getInstanceByIDOrFail(t),a,l;Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhg.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let E=f.aabbToBoundingBox(l.aabb),vt=B.areaToGridArea(E,s.gridCellSize);m.setArea(vt,true);}let g=se.findPath(m,c,p,s.neighborType);return g.path=g.path.map(E=>B.gridPositionToPosition(E,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Bt){let n=v.getInstanceByIDOrFail(t),a;if(Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(g.p2Body.aabb);}else a=new Rectangle(i,i);let l=B.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let g=this.ƀhg.getAvilabilityGrid(n,s,r);p=new oe(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};Gt=wo([d(),xo("design:paramtypes",[nt])],Gt);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=new U,bi=class{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return j.trigger("createPhysicsWorld",t)}getMapSize(t){return j.trigger("getMapSize",t)}setPaused(t,e){return j.trigger("setPaused",t,e)}hitTest(t,e){return j.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return j.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return j.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return j.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return j.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return j.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Bt){return j.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};bi=Po([d()],bi);var So=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Co=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Q=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀz=t,this.ƀhd=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀz.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhd.findPathDirection(t,c.position,i,r),m;p===void 0?m=T.createRectangleBorders(new Vector(8,8),2,ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=T.createArrow(25,c.availability?ColorHelper.green:ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new A(m,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new A(a,"alpha",{duration:n,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let m=p.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new A(l,"alpha",{duration:a,animation:S.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new Radian(t.angle),n=i?.color??ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcq(c,n).displayParent(a).attachToRoot();}),new A(a,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcq(t,e){switch(t.type){case W.Shape.PARTICLE:throw new Error("Not implemented");case W.Shape.LINE:throw new Error("Not implemented");case W.Shape.PLANE:throw new Error("Not implemented");case W.Shape.CIRCLE:throw new Error("Not implemented");case W.Shape.CAPSULE:throw new Error("Not implemented");case W.Shape.BOX:throw new Error("Not implemented");case W.Shape.HEIGHTFIELD:throw new Error("Not implemented");case W.Shape.CONVEX:return this.ƀcp(t,e);default:throw new Error("Not implemented")}}ƀcp(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Q=So([d(),Co("design:paramtypes",[nt,Gt])],Q);var Ro=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Io=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ne=class{static{h(this,"HitTestService");}constructor(t){this.ƀjq=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdi(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new W.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?ColorHelper.red:ColorHelper.green;this.ƀjq.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdi(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Ro([d(),Io("design:paramtypes",[Q])],Ne);var Oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀib(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀay=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀib(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀeo(r.p2Body),r.entity.ƀis(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀeo(t){let e=f.arrayToVector(t.velocity);e.length>10.8&&(e=e.normalize(10.8),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-10.01),10.01);}ƀib(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdn(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdn(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeb(i);return {collisionDetailsA:this.ƀdm(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdm(s,i.bodyB.mass,a,c,e.area)}}ƀdm(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeb(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=Oo([d()],je);var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Do=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends Wt{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Mo([dt(),Do("design:paramtypes",[Number,Object])],He);var Bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},H=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbs(t,new Vector(e.x/2,-H/2),new Vector(e.x+H*2,H),i),this.ƀbs(t,new Vector(e.x/2,e.y+H/2),new Vector(e.x+H*2,H),i),this.ƀbs(t,new Vector(-H/2,e.y/2),new Vector(H,e.y+H*2),i),this.ƀbs(t,new Vector(e.x+H/2,e.y/2),new Vector(H,e.y+H*2),i);}ƀbs(t,e,i,r){return new He(t,{shapeDefinition:{materialName:st,group:r,shapeType:tt.Rectangle,shapeData:i},position:e,rotation:Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Bo([d()],We);var _o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ar=new W.Material,Fo={id:st,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},_t=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new W.Material),n.set(a.id,a);}),s.has(st))throw new Error(`Material with name ${st} cannot be defined, pick another name for the material.`);return s.set(st,ar),n.set(st,Fo),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdz(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdy(e,i.materialDefinitions)}ƀdz(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀdy(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀdr(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀdz(n.materialA,s),l=this.ƀdz(n.materialB,s);t.addContactMaterial(new W.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀdr(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀdz(s.id,r);t.addContactMaterial(new W.ContactMaterial(n,ar,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};_t=_o([d()],_t);var Lo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ft=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀge=t,this.ƀaj=e,this.ƀz=i,this.ƀaz=r,this.ƀhh=s;}createPhysicsWorld(t){let e=new W.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀge.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhh.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&y.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀaz.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjk(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjk(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀz.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjk(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀaz.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ft=Lo([d(),Vo("design:paramtypes",[_t,We,nt,je,K])],Ft);var jo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vt=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new W.RaycastResult,s=new W.Ray({mode:W.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbn(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new W.Ray({mode:W.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbn(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbn(n,e));},"callback")});return t.p2World.raycast(new W.RaycastResult,s),Array.from(r.values())}ƀbn(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Vt=jo([d()],Vt);var Ho=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},lt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};lt=Ho([d()],lt);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Nt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbo(r,t.length))}ƀbo(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Nt=Wo([d()],Nt);var $o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Yo=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcd(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀhw.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀjq.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...E}=m;return E})}ƀcd(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(Radian.get90).vector,p=c.normalize(i.x);a.push(new Line(t,t.add(p))),a.push(new Line(t,t.add(p.multiplyNumber(-1))));let m=l.normalize(i.y);a.push(new Line(t,t.add(m))),a.push(new Line(t,t.add(m.multiplyNumber(-1))));let g=Math.round(i.y/Yo),E=i.y/(g*2+1)*2,vt=l.normalize(E),ne=i.x,lr=Math.pow(i.y,2);return ArrayHelper.createIntegerArray(g).forEach(pt=>{let bt=E*(pt+1),Ci=vt.multiplyNumber(pt+1),ae=c.normalize(this.ƀej(ne,lr,bt)),he=t.add(Ci);a.push(new Line(he,he.add(ae))),a.push(new Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ci.multiplyNumber(-1));a.push(new Line(le,le.add(ae))),a.push(new Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(pt=>{if(s){let bt=this.ƀhx.castClosest(n,pt,r);return {line:pt,hits:bt?[bt]:[]}}else {let bt=this.ƀhx.castAllFirstContacts(n,pt,r);return {line:pt,hits:bt}}})}ƀej(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀfd.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=$o([d(),zo("design:paramtypes",[Vt,Q,Nt,lt])],$e);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ze=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeg(i),c=this.ƀcd(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀhw.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀjq.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcd(t,e,i,r,s,n){let a=new Radian(PI_360/r),l=new Vector(0,-e),c=a.vector;return ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new Line(t,p)}).map(p=>{if(s){let m=this.ƀhx.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀhx.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfd.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀfd.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeg(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ze=Xo([d(),Ko("design:paramtypes",[Vt,Q,Nt,lt])],ze);var en=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},jt=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};jt=en([d()],jt);var rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀho=t,this.ƀhd=e,this.ƀjq=i,this.ƀda=r,this.ƀcu=s,this.ƀeu=n,this.ƀhn=a,this.ƀfd=l;}createPhysicsWorld(t){return this.ƀho.createPhysicsWorld(t)}getMapSize(t){return this.ƀhn.getMapSize(t)}setPaused(t,e){this.ƀho.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀeu.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhd.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhd.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfd.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀda.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcu.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n){this.ƀjq.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=rn([q({controllerLink:j}),sn("design:paramtypes",[Ft,Gt,Q,ze,$e,Ne,jt,lt])],Pi);var on=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ke=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case tt.Point:return this.ƀbu(n,void 0,i,r,e.shapeDefinition.group,s);case tt.Circle:return this.ƀbu(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case tt.Polygon:return this.ƀcc(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case tt.Rectangle:return this.ƀce(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbu(t,e,i,r,s,n){let a=new W.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new W.Body({type:n==="dynamic"?W.Body.DYNAMIC:W.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcc(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new W.Convex({vertices:g.map(E=>[E.x,E.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,E)=>g+E.area,0),m=new W.Body({type:n==="dynamic"?W.Body.DYNAMIC:W.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(g=>m.addShape(g)),m.setDensity(r.density),m}ƀce(t,e,i,r,s,n){let a=new W.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new W.Body({type:n==="dynamic"?W.Body.DYNAMIC:W.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ke=on([d()],ke);var nn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},an=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀho=t,this.ƀhm=e,this.ƀix=i,this.ƀhn=r,this.ƀhh=s;}createBody(t,e,i,r,s){return this.ƀix.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀhm.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀhm.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhh.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhh.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀho.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀho.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhn.subscribeToPhysicsStep(t,e)}};Si=nn([q({controllerLink:J}),an("design:paramtypes",[Ft,_t,ke,jt,K])],Si);export{Ai as AnimationFlicker,Y as AnimationInterpolationFunctions,S as Animations,R as AnimationsCompletionHandlingType,A as Animator,st as BORDER_MATERIAL_NAME,G as BardLegendsHardReset,Tt as BlendMode,Xt as Camera,Rt as CameraGateway,re as ClosestAvailableSpaceHelper,u as Container,$t as ContainerEventType,q as ControllerDecorator,U as ControllerLink,qe as Cursor,O as DEFAULT_SHADER_RESOLUTION,xi as DeltaTime,ci as DisplayObjectArray,$ as Entity,dt as EntityDecorator,Zi as FadeInContent,_e as FadeInStateAnimation,ot as FocusingAnimation,w as Game,T as Graphics,Wt as ImmovablePhysicsEntity,gi as KeyboardService,Dt as Menu,di as MenuEntity,mt as MouseService,yi as MouseTargetFocusService,ie as MouseWheelListenerUI,Xe as MovableEntity,Ke as MovablePhysicsEntity,se as PathFinder,b as PhysicsEntity,bi as PhysicsGateway,tt as PhysicsShapeType,ai as Placeholder,kt as PositionConversionHelper,Qe as ROTATIONAL_SPEED_LIMIT,F as ReAnimateHandlingType,hi as RichText,Ze as SPEED_LIMIT,Pt as Scene,wr as SceneDecorator,mi as ScrollAreaUI,et as ScrollDirection,gt as ScrollMaskUI,P as Service,d as ServiceDecorator,ut as SingletonEntity,er as SlideInContent,wi as SlideInContentByIndex,Le as SlideStateAnimation,it as SlideStateAnimationState,X as Sprite,Fe as StateAnimation,te as Text,li as UpdatableContainer,y as UpdateCycle,oe as VectorFieldPathFinder,wt as VectorSet,Ht as View,Ye as ViewDecorator};
|
|
67
|
+
}`,e}constructor(t,e){if(super(o.ƀeh(),o.ƀdq(t*O)),this.ƀcy=t,this.resolution=O,this.ƀcy=t*O,this.ƀcy<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcy>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");Comparator.isInteger(this.ƀcy)||(this.ƀcy=Math.floor(this.ƀcy));let i=ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcy*this.ƀcy,this.padding=this.ƀcy;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*O),1/(e.height*O)]),t.applyFilter(this,e,i,r);}};var Te=class extends V.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=O;let e={blurRadius:1,expand:0,color:ColorHelper.white,blendMode:Tt.Screen,...t};this.ƀcz=new Ce(e.expand,e.color);let i=Comparator.isNumber(e.blurRadius)?new Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Et(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=V.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀcz.apply(t,e,s,V.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var Zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀek=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbd(e),s=Comparator.isNumber(r.blurRadius)?new Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀds(t.texture,s,r.expand,r.color,i),a=new V.Sprite(n);return this.ƀiu(a,Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀds(t,e,i,r,s){if(!t.id)throw new Error("GlowSpriteGenerator: baseTexture should have an id");if(s){let n=`${t.id}-${i}-${e.x}-${e.y}-${r.r}-${r.g}-${r.b}`;if(o.ƀek.has(n))return o.ƀek.get(n);{let a=this.ƀdt(t,e,i,r);return o.ƀek.set(n,a),a}}else return this.ƀdt(t,e,i,r)}static ƀdt(t,e,i,r){let s=new V.Sprite(t);this.ƀdb(s,Math.max(e.x,e.y)+i),s.filters=[new Te({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀiu(t,e,i){let r=(i+(t.width-i*2)*e.x)/t.width,s=(i+(t.height-i*2)*e.y)/t.height;t.anchor.set(r,s);}static ƀdb(t,e){if(t.isSprite){let s=new V.Graphics;t.addChild(s);}let i=t.width,r=t.height;t.calculateBounds=function(){this._bounds.clear(),this._bounds.addFrame(this.transform,-e,-e,i+e,r+e);};}static ƀbd(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:ColorHelper.white,blendMode:Tt.Add};return t&&(e={...e,...t}),e}};G.onHardReset.subscribe(()=>{Zt.ƀek.clear();}).attachToRoot();var X=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=w.setupOptions.spriteDefinitions[t];if(!e)throw new Error(`Sprite: Could not find sprite definition with name ${t}.`);return new o(e)}static createSnapshotSprite(t){let e=t.pixiContainer,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:V.SCALE_MODES.LINEAR,multisample:V.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:Vector.zero,boundingShapes:void 0,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀju=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjd=t,this.pixiSprite=new V.Sprite(M.getAsset(t.id)),this.pixiContainer.addChild(this.pixiSprite),this.setTextureScale(t.scale),e.textureSize&&(this.pixiSprite.width=e.textureSize.x,this.pixiSprite.height=e.textureSize.y),e.texturePosition&&this.pixiSprite.position.set(e.texturePosition.x,e.texturePosition.y),e.ignoreAnchor||this.pixiSprite.anchor.set(t.anchor.x,t.anchor.y);}destroy(){this.destroyed||(super.destroy(),this.ƀgc?.destroy(),this.ƀak?.destroy(),this.ƀjd.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjd.id),this.ƀhq&&M.destroyAsset(this.ƀhq.texture.id)),this.ƀhq&&!this.ƀhq.destroyed&&this.ƀhq.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀju}set textureScale(t){this.ƀju=t,this.pixiSprite.scale.set(t);}get size(){return new Vector(this.pixiSprite.width,this.pixiSprite.height)}getMask(){return this.pixiSprite}set interactive(t){super.interactive=t,t&&this.ƀjd.boundingShapes&&!this.pixiContainer.hitArea&&(this.pixiContainer.hitArea=new we(this.ƀjd.boundingShapes,this.size,Vector.fromVec2(this.ƀjd.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===V.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=V.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=V.MIPMAP_MODES.OFF;}setBlendMode(t){return this.blendMode=t,this}get blendMode(){return this.pixiSprite.blendMode}set blendMode(t){this.pixiSprite.blendMode=t;}setTint(t){return this.tint=t,this}get tint(){return new V.Color(this.pixiSprite.tint).toRgb()}set tint(t){this.pixiSprite.tint=t;}setShapeAlpha(t){return this.pixiSprite.alpha=t,this}get shapeAlpha(){return this.pixiSprite.alpha}set shapeAlpha(t){this.pixiSprite.alpha=t;}setGlowAlpha(t){return this.glowAlpha=t,this}get glowAlpha(){if(this.ƀhq)return this.ƀhq.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhq)this.ƀhq.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=Vector.fromVec2(this.ƀjd.anchor).to(t);return new Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhq&&(this.ƀhq.destroy(),this.ƀhq=void 0),t&&(this.ƀhq=Zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjd.destroyAssetOnDestroy),this.ƀhq.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhq.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.pixiContainer.addChild(this.ƀhq)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbt().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgc){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgc=this.ƀbt(),this.ƀgc.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgc.pixiSprite.renderable=false,this.ƀgc.displayParent(this);}return this.ƀgc}ƀbt(){if(!this.ƀjd.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return T.createPolygon(this.ƀjd.boundingShapes,ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.pixiContainer);if(!t.toBlob)throw new Error("Sprite: canvas.toBlob is undefined!");return t.toBlob(e=>{if(!e)throw new Error("Sprite: blob is undefined!");let i=document.createElement("a");document.body.append(i),i.download="sprite.png",i.href=URL.createObjectURL(e),i.click(),i.remove();},"image/png"),this}};var Ee=class{static{h(this,"DashedLineHelper");}static getLines(t,e,i){let r=Vector.fromTo(t,e),s=r.normalize(),n=r.length-i.lineStartGap-i.lineEndGap,a=[];if(n<=0)return a;let l=t.add(s.normalize(i.lineStartGap));if(n<=i.dashGap+i.dashLength*.5)return a.push({from:l,to:l.add(s.normalize(n))}),a;let c=n-i.dashGap,p=i.dashLength+i.dashGap,m=Math.floor(c/p),g=c-p*m;m>=1&&g<i.dashLength&&(g+=p,m--);let E=s.normalize(g/2),vt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(E)}),l=l.add(E),m>0){let ne=s.normalize(i.dashLength);ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(vt),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(vt),a.push({from:l,to:l.add(E)}),a}};var T=class o extends u{static{h(this,"Graphics");}static{this.ƀcr=new Map;}static createArrow(t,e){let i=new V.Graphics,r=[[{x:0,y:-t/2},{x:t*3/8,y:-t/8},{x:t/4,y:0},{x:0,y:-t/4},{x:-t/4,y:0},{x:-t*3/8,y:-t/8}],[{x:0,y:-t/4},{x:t/8-t/30,y:-t/8-t/30},{x:t/8-t/30,y:t*7/16},{x:-t/8+t/30,y:t*7/16},{x:-t/8+t/30,y:-t/8-t/30}]];return i.beginFill(e),r.forEach(s=>{i.drawPolygon(s.map(n=>new V.Point(n.x,n.y)));}),i.endFill(),new o(i,JSON.stringify({type:"arrow",size:t,color:e}))}static createDashedLine(t,e,i){let r={width:2,dashLength:10,dashGap:4,lineStartGap:0,lineEndGap:0,color:ColorHelper.white,...i},s=new V.Graphics;return s.lineStyle(r.width,r.color),Ee.getLines(t,e,r).forEach(a=>{s.moveTo(a.from.x,a.from.y).lineTo(a.to.x,a.to.y);}),new o(s,JSON.stringify({type:"dashedLine",from:t,to:e,options:r}))}static createVector(t,e,i){let r=new V.Graphics;return r.lineStyle(2,i),r.moveTo(t.x,t.y),r.lineTo(e.x,e.y),r.lineStyle(1,i),r.beginFill(ColorHelper.white),r.drawCircle(t.x,t.y,3),r.endFill(),new o(r,JSON.stringify({type:"line",start:t,end:e,color:i}))}static createRectangleBorders(t,e,i){let r=new V.Graphics;return r.beginFill(i),r.drawRect(0,0,t.x,e),r.drawRect(0,e,e,t.y-e*2),r.drawRect(t.x-e,e,e,t.y-e*2),r.drawRect(0,t.y-e,t.x,e),r.endFill(),new o(r,JSON.stringify({type:"rectangle-borders",size:t,borderSize:e,color:i}))}static createRectangle(t,e=ColorHelper.white){let i=new V.Graphics;return i.beginFill(e),i.drawRect(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"rectangle",size:t,color:e}))}static createCircle(t,e){let i=new V.Graphics;return i.beginFill(e),i.drawCircle(0,0,t),i.endFill(),new o(i,JSON.stringify({type:"circle",radius:t,color:e}))}static createElipse(t,e){let i=new V.Graphics;return i.beginFill(e),i.drawEllipse(0,0,t.x,t.y),i.endFill(),new o(i,JSON.stringify({type:"elipse",size:t,color:e}))}static createPolygon(t,e){let i=new V.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new V.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new V.Graphics,s=new Radian(PI_360/t);r.beginFill(i),r.moveTo(e,0);for(let n=1;n<=t;n++){let l=s.multiply(n).vector.normalize(e),c=e+l.x,p=e+l.y;r.lineTo(c,p);}return r.endFill(),new o(r,JSON.stringify({type:"regular-polygon",sides:t,radius:e,color:i}))}constructor(t,e){super(),this.pixiContainer.addChild(t),this.pixiGraphics=t,this.ƀam=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀam,cache:false,...t},i=this.ƀee(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},boundingShapes:void 0,destroyAssetOnDestroy:!e.cache},s=new X(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀee(t,e){if(e){let i=o.ƀcr.get(t);return i||(i=this.ƀcf(),o.ƀcr.set(t,i)),i}else return this.ƀcf()}ƀcf(){let t=w.instance.renderer.generateTexture(this.pixiGraphics);t.id=M.insertAsset(t);let e=this.pixiGraphics.getBounds();return {assetID:t.id,bounds:new Vector(e.x,e.y)}}};var ai=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀhr=new V.Graphics,this.ƀhr.beginFill(0,1e-9),this.ƀhr.drawRect(0,0,t.x,t.y),this.ƀhr.endFill(),this.pixiContainer.addChild(this.ƀhr);}destroy(){this.destroyed||(super.destroy(),this.ƀhr.destroy());}};var Ot=class{static{h(this,"TextStyleConverter");}static getPixiTextStyle(t){let e={color:ColorHelper.white,align:"center",fontFamily:"Arial",fontStyle:"normal",fontSize:18,lineHeight:void 0,wordWrapWidth:void 0,lineThrough:false,...t},i=t?.dropShadow===true?{}:t?.dropShadow,r={};if(i){let s={blur:4,angle:Radian.get60,distance:10,color:ColorHelper.black,alpha:.5,...i};r={dropShadow:true,dropShadowBlur:s.blur,dropShadowAngle:s.angle.value,dropShadowDistance:s.distance,dropShadowColor:ColorHelper.rgbToHex(s.color),dropShadowAlpha:s.alpha};}return {fontFamily:e.fontFamily,fill:ColorHelper.rgbToHex(e.color),align:e.align,fontSize:e.fontSize,fontStyle:e.fontStyle,lineHeight:e.lineHeight,wordWrapWidth:e.wordWrapWidth,wordWrap:e.wordWrapWidth!==void 0,lineThrough:e.lineThrough,...r}}};var Ie=class{static{h(this,"RichTextDataInConverter");}static process(t,e){let i=new Set(e.styles?Object.keys(e.styles):[]),r=RichTextSeparator.process(t,i),s=this.ƀfe(r,e),n=this.ƀs(s);return this.ƀjb(n)}static ƀfe(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Ot.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdo(a.tags,e,i),p=s(l,c),m=V.TextMetrics.measureText(" ",new V.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdo(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbb(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbb(t,e){let i={...e.default};for(let l of t)e.styles&&e.styles[l]&&(i={...i,...e.styles[l]});let{wordWrapWidth:r,align:s,dropShadow:n,...a}=i;return a}static ƀs(t){let e=[],i=[];return t.forEach((r,s)=>{r.text.split(/\r?\n/).forEach((a,l)=>{l>0&&(e.push(i),i=[]),i.push({text:a,cacheKey:r.cacheKey,style:r.style,pixiStyle:r.pixiStyle,spaceWidth:r.spaceWidth});});}),e.push(i),e}static ƀjb(t){let e=[];return t.forEach(i=>{if(i.length===0)throw new Error("Internal Error: Line is unexpectedly empty");let r=i.flatMap(s=>this.ƀjc(s.text).map(a=>{let l=new V.TextStyle(s.pixiStyle),c=V.TextMetrics.measureText(a,l,false);return {text:a,whitespace:a.trim()==="",style:{cacheKey:s.cacheKey,style:s.style,pixiStyle:l,height:c.height,ascent:c.fontProperties.ascent,descent:c.fontProperties.descent,width:c.width,spaceWidth:s.spaceWidth}}}));e.push(r);}),e}static ƀjc(t){if(t==="")return [""];let e=[],i="",r=t[0]===" ";for(let s=0;s<t.length;s++){let n=t[s],a=n===" ";a===r?i+=n:(e.push(i),i=n,r=a);}return i&&e.push(i),e}};var Ae=class{static{h(this,"ConsistentSpaceTextWrapper");}static wrapText(t,e){return t.forEach(i=>{i.forEach((r,s)=>{if(e.isSpaceAvailable(new Vector(r.style.width,r.style.height)))if(r.whitespace&&s===i.length-2){let n=i[i.length-1];e.isSpaceAvailable(new Vector(n.style.width+r.style.width,n.style.height))?e.insertWord(r):this.ƀkr(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀkr(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀkr(t,e){let i=Math.max(0,Math.floor(e.remainingWidth/t.style.spaceWidth)),r=Math.max(0,Math.min(i,t.text.length-1));if(r>0){let n={text:" ".repeat(r),whitespace:true,style:{...t.style,width:r*t.style.spaceWidth}};e.insertWord(n);}e.newLine();let s=t.text.length-r-1;if(s>0){let n={text:" ".repeat(s),whitespace:true,style:{...t.style,width:s*t.style.spaceWidth}};e.insertWord(n);}}};var Oe=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀci.length===0}get remainingWidth(){return this.ƀkq-this.ƀck}constructor(t,e){if(this.ƀkq=t,this.ƀfu=[],this.ƀci=[],this.ƀck=0,this.ƀft=new Vector(0,0),this.ƀcj=0,this.ƀew=e?.horizontalAlignment??"left",this.ƀki=e?.verticalAlignment??"bottom",e?.rectangleCutOption){if(e.rectangleCutOption.position.x<0||e.rectangleCutOption.position.x>=this.ƀkq||e.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcl={direction:e.rectangleCutOption.direction,rectangle:this.ƀbp(e.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcj,t.y),i=this.ƀdw(this.ƀft.y,this.ƀft.y+e);return this.ƀck+t.x<=i}insertWord(t){let e=Math.max(this.ƀcj,t.style.height);if(this.ƀci.length===0){let i=this.ƀdx(this.ƀft.y,this.ƀft.y+e);this.ƀft=new Vector(i,this.ƀft.y),this.ƀck=this.ƀft.x;}this.ƀci.push({chunk:t,position:new Vector(this.ƀck,this.ƀft.y)}),this.ƀcj=e,this.ƀck+=t.style.width;}newLine(){let t=this.ƀft.y+this.ƀcj,e=this.ƀdx(t,t);this.ƀdd(),this.ƀft=new Vector(e,t),this.ƀck=this.ƀft.x,this.ƀcj=0;}print(){return this.ƀdd(),this.ƀfu}ƀdd(){this.ƀci.length>0&&(this.ƀfu.push(this.ƀg(this.ƀci)),this.ƀci=[]);}ƀg(t){return t=this.ƀkk(t),t=this.ƀey(t),t}ƀey(t){if(this.ƀew==="left")return t;let e=this.ƀft.y+this.ƀcj,i=this.ƀdx(this.ƀft.y,e),s=this.ƀdw(this.ƀft.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀew==="center"?a=(s-n)/2:a=s-n,t.map(l=>(l={chunk:l.chunk,position:new Vector(l.position.x+a,l.position.y)},l))}ƀkk(t){let e=Math.max(...t.map(r=>r.chunk.style.ascent)),i=Math.max(...t.map(r=>r.chunk.style.descent));return t.map(r=>{let s;switch(this.ƀki){case "top":s=i-r.chunk.style.descent;break;case "center":s=(i-r.chunk.style.descent+e-r.chunk.style.ascent)*.5;break;case "bottom":s=e-r.chunk.style.ascent;break;default:{this.ƀki;throw new Error(`Unexpected case! "${this.ƀki}"`)}}return r={chunk:r.chunk,position:new Vector(r.position.x,r.position.y+s)},r})}ƀdx(t,e){return this.ƀcl&&(this.ƀcl.direction==="topLeft"||this.ƀcl.direction==="bottomLeft")&&(this.ƀcl.rectangle.isPointInside(new Vector(0,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new Vector(0,e),{includeEdges:false}))?this.ƀcl.rectangle.bottomRight.x:0}ƀdw(t,e){return this.ƀcl&&(this.ƀcl.direction==="topRight"||this.ƀcl.direction==="bottomRight")&&(this.ƀcl.rectangle.isPointInside(new Vector(this.ƀkq,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new Vector(this.ƀkq,e),{includeEdges:false}))?this.ƀcl.rectangle.topLeft.x:this.ƀkq}ƀbp(t){let e,i;switch(t.direction){case "topRight":e=new Vector(t.position.x,-1/0),i=new Vector(1/0,t.position.y);break;case "topLeft":e=new Vector(-1/0,-1/0),i=t.position;break;case "bottomRight":e=t.position,i=new Vector(1/0,1/0);break;case "bottomLeft":e=new Vector(-1/0,t.position.y),i=new Vector(t.position.x,1/0);break;default:{t.direction;throw new Error(`Unexpected case! "${t.direction}"`)}}return new Rectangle(e,i)}};var Me=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgg(t),t=this.ƀka(t),this.ƀav(t)}static ƀgg(t){return t.map(e=>{let i=[],r,s=true;return e.forEach(n=>{if(!r||r.chunk.style.cacheKey!==n.chunk.style.cacheKey)r&&i.push(r),r=n,s=n.chunk.whitespace;else {let a=r.chunk.text+n.chunk.text;s=n.chunk.whitespace&&s,r={chunk:{text:a,whitespace:s,style:{...r.chunk.style,width:r.chunk.style.width+n.chunk.style.width}},position:r.position};}}),r&&i.push(r),i})}static ƀka(t){return t.map(e=>{if(e.length===0)return [];let i=e.pop();if(!i.chunk.whitespace||i.chunk.text===""){let r=i.chunk.text.length,s=i.chunk.text.trimEnd();r!==s.length?e.push({chunk:{text:s,whitespace:false,style:{...i.chunk.style,width:i.chunk.style.width-(r-s.length)*i.chunk.style.spaceWidth}},position:i.position}):e.push(i);}return e})}static ƀav(t){return t.flatMap(e=>e.map(i=>({text:i.chunk.text,style:i.chunk.style.style,position:i.position}))).filter(e=>e.text.trim()!=="")}};var qt=class{static{h(this,"RichTextToPlaneText");}static process(t,e){if(e.default.wordWrapWidth===void 0){if(e.default.align==="right"||e.default.align==="center")throw new Error("wordWrapWidth is required for right or center alignment");if(e.rectangleCut&&(e.rectangleCut.direction==="topRight"||e.rectangleCut.direction==="bottomRight"))throw new Error("wordWrapWidth is required for topRight or bottomRight rectangle cut")}let i=Ie.process(t,e),r=new Oe(e.default.wordWrapWidth??1/0,{rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=Ae.wrapText(i,r);return Me.process(s)}};var Cs=1,$i=1/Cs,te=class extends u{static{h(this,"Text");}get ƀjs(){if(!this.ƀjt){let t=new V.TextStyle(this.ƀht);this.ƀjt=V.TextMetrics.measureText(this.ƀjr,t);}return this.ƀjt}get ascent(){return this.ƀjs.fontProperties.ascent}constructor(t,e){super(),this.ƀht=Ot.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhs.destroyed&&this.ƀhs.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new Vector(this.ƀhs.anchor.x,this.ƀhs.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhs.anchor.set(t.x,t.y);}setPosition(t,e){if(e?.holdFrom){let i=this.ƀht.dropShadowDistance??0,r=new Vector(e.holdFrom.x*i,e.holdFrom.y*i);t=t.add(r);}return super.setPosition(t,e),this}setText(t){return this.ƀjr!==t&&(this.ƀjr=t,this.ƀia()),this}setColor(t){let e=ColorHelper.rgbToHex(t);return this.ƀht.fill!==e&&(this.ƀht.fill=e,this.ƀia()),this}ƀia(){this.ƀhs?.destroy(),this.ƀjm?.destroy(),this.ƀjm=void 0,this.ƀjt=void 0;let t=new V.TextStyle(this.ƀht);this.ƀhs=new V.Text(this.ƀjr,t),this.ƀi&&this.ƀhs.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhs.scale.set($i,$i),this.pixiContainer.addChild(this.ƀhs),this.ƀht.lineThrough&&(this.ƀjm=this.ƀe(this.ƀhs,this.ƀht.fill),this.pixiContainer.addChild(this.ƀjm));}ƀe(t,e){let i=V.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new V.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=V.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,g=0;t.style.align==="center"?g=0+(t.width-p.width)*.5:t.style.align==="right"&&(g=0+t.width-p.width),g=Math.floor(g),n.moveTo(Math.floor(g),m),n.lineTo(Math.floor(g+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var hi=class extends u{static{h(this,"RichText");}constructor(t,e){super(),qt.process(t,e).forEach(r=>new te(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var li=class extends u{static{h(this,"UpdatableContainer");}},ci=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbv=t,this.ƀco=new Map,this.ƀha={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀco.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀha.trackBy(r,s),a;this.ƀco.has(n)?(a=this.ƀco.get(n),e.delete(n),a.update(r)):(a=this.ƀbv(r).displayParent(this).attach(this),this.ƀco.set(n,a)),this.ƀha.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀha.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀha.positioning.spacing);}),e.forEach(r=>{this.ƀco.get(r).destroy(),this.ƀco.delete(r);});}};var Dt=class o extends u{static{h(this,"Menu");}static{this.ƀjy=false;}static closeAll(){return o.ƀgz?o.ƀgz.close():SingleEvent.instant()}constructor(t,e){super(),this.ƀgs=new SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new SingleAction,this.onClose=this.ƀgn.notifier;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,darkeningAlpha:.3,...e};this.setZIndex(100).setAlpha(0),this.ƀo=new A(this,"alpha",{animation:S.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:F.CompletePrevious,completionHandling:R.StayInCurrentState}),this.ƀaa=T.createRectangle(new Vector(1,1),ColorHelper.black).toSprite({cache:true}).setAlpha(i.darkeningAlpha).setInteractive(true).displayParent(this).attach(this),this.ƀgf=X.createByName(t).setPosition(new Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(r=>{this.ƀaa.aspectRatio=r.x/r.y,this.ƀaa.scale=Math.max(r.x,r.y),this.ƀaa.setPosition(Vector.zero,{holdFrom:Vector.half}),this.setPosition(r.multiplyNumber(.5));}).attach(this),o.ƀgz=this,this.onDestroy().tap(()=>{o.ƀgz=void 0;}).attachToRoot(),i.closeOnBackgroundClick&&this.ƀaa.on($t.Click).filter(()=>!o.ƀjy).tap(()=>this.ƀq(false)).take(1).attach(this),this.ƀq(true);}getBoundingMask(){return this.ƀgf.getBoundingMask()}close(){return this.ƀq(false)}ƀq(t){if(o.ƀjy)throw new Error("WindowUI: cannot iterate while in transition");return o.ƀjy=true,this.ƀo.animate({alpha:t?1:0}).chain(this).tap(()=>{o.ƀjy=false,t?this.ƀgs.resolve():(this.ƀgn.resolve(),this.destroy());}).chainToRoot()}};var di=class extends ut{static{h(this,"MenuEntity");}constructor(t,e){super(),this.ƀgq=new SingleAction,this.onCreate=this.ƀgq.notifier,this.ƀgs=new SingleAction,this.onOpen=this.ƀgs.notifier,this.ƀgn=new SingleAction,this.onClose=this.ƀgn.notifier,Dt.closeAll().tap(()=>{if(!Pt.getActiveScene())throw new Error("WindowEntity: constructor is called when there is no active scene!");w.pause.effect(true).attach(this),this.ƀgf=new Dt(t,e).displayParent(w.camera.layers.foregroundScreen).attach(this),this.ƀgq.resolve(this.ƀgf),this.ƀgf.onOpen.subscribe(()=>this.ƀgs.resolve()).attach(this),this.ƀgf.onClose.subscribe(()=>{this.destroy(),this.ƀgn.resolve();}).attach(this);}).attach(this);}getMenuEvents(){return {onOpen:this.onOpen.toSingleEvent().destroyIfNotAttached(),onClose:this.onClose.toSingleEvent().destroyIfNotAttached()}}close(){if(this.ƀgf){let t=this.onClose.toSingleEvent().destroyIfNotAttached();return this.ƀgf.close(),t}else return this.onCreate.asyncMapQueue(()=>this.close()).singleChain(this)}};var Rs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Is=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},mt=class{static{h(this,"MouseService");}get initialMouseMoveHappened(){return this.ƀfg.value}getStagePosition(){return this.ƀje.value}getScreenPosition(){return this.ƀik.value}getMainButtonState(){return this.ƀfz.value}getSecondaryButtonState(){return this.ƀiq.value}constructor(){this.ƀfg=new Variable(false),this.onInitialMouseMove=this.ƀfg.notifier,this.ƀje=new Variable(Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀje.notifier,this.ƀik=new Variable(Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀik.notifier,this.ƀfz=new Variable(false),this.mainButtonState=this.ƀfz.notifier,this.ƀiq=new Variable(false),this.secondaryButtonState=this.ƀiq.notifier,this.ƀjf(),window.addEventListener("mousedown",t=>{t.button===0?this.ƀfz.value=true:t.button===2&&(this.ƀiq.value=true);}),window.addEventListener("mouseup",t=>{t.button===0?this.ƀfz.value=false:t.button===2&&(this.ƀiq.value=false);}),window.addEventListener("blur",()=>{this.ƀfz.value=false,this.ƀiq.value=false;});}ƀjf(){let t=Vector.zero;window.addEventListener("mousemove",e=>{t=new Vector(e.clientX,e.clientY),this.ƀfg.value=true;}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀik.value=t;}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀik.value);e.isEqual(this.ƀje.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:this.ƀik.value.x,clientY:this.ƀik.value.y,pointerType:"mouse"})):this.ƀje.value=e;}).attachToRoot();}};mt=Rs([d(),Is("design:paramtypes",[])],mt);var ie=class extends u{static{h(this,"MouseWheelListenerUI");}constructor(t){super(),this.ƀgw=new Action,this.onWheel=this.ƀgw.notifier,this.ƀer=(e=>{let i=P.get(mt).getScreenPosition(),r=this.ƀkp.getBounds();i.x>=r.x&&i.x<=r.x+r.width&&i.y>=r.y&&i.y<=r.y+r.height&&this.ƀgw.trigger(e.deltaY);}).bind(this),this.ƀkp=new V.Graphics,this.ƀkp.beginFill(0,1e-9),this.ƀkp.drawRect(0,0,t.x,t.y),this.ƀkp.endFill(),this.pixiContainer.addChild(this.ƀkp),window.addEventListener("wheel",this.ƀer);}destroy(){this.destroyed||(super.destroy(),this.ƀkp.destroy(),window.removeEventListener("wheel",this.ƀer));}};var Ms=.65,Ds=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀio}get contentSize(){return this.ƀbi.size.ceil()}constructor(t,e,i,r){this.ƀbi=t,this.ƀv=e,this.ƀhc=i,this.ƀja=r,this.ƀfh=false,this.ƀio=e-i*2,this.ƀbi.y=i,this.ƀjn=i;}onWheel(t){this.setTarget(this.ƀjn-t*Ms);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjn=NumberHelper.clamp(t,this.ƀv-this.ƀhc-this.contentSize.y,this.ƀhc);}jumpToTarget(){this.ƀbi.y=this.ƀjn;}update(t){let e=this.contentSize;if(e.y<=this.ƀio){switch(this.ƀja){case "start":this.ƀjn=this.ƀhc;break;case "center":this.ƀjn=(this.ƀv-e.y)*.5;break;case "end":this.ƀjn=this.ƀv-e.y-this.ƀhc;break;default:{this.ƀja;throw new Error(`Unexpected case! "${this.ƀja}"`)}}this.ƀfh||(this.ƀbi.y=this.ƀjn);}this.ƀfh=true;let i=this.ƀjn-this.ƀbi.y;this.ƀbi.y=this.ƀbi.y+i*Ds*t;}};var fi=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},gt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcr=new Map;}constructor(t,e,i,r=et.Vertical){if(super(),i<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(e.y<i*2)throw new Error(`The height of the scroll mask cannot be lower than '${i*2}'`);let s=new u;r===et.Horizontal?this.ƀbz(e,i,s):this.ƀcg(e,i,s),this.ƀgc=X.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgc);}ƀcg(t,e,i){e>0&&this.ƀbw(new Vector(t.x,e)).displayParent(i).attach(i),T.createRectangle(new Vector(t.x,t.y-e*2),ColorHelper.white).toSprite().setPosition(new Vector(0,e),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new Vector(t.x,e)).setPosition(new Vector(t.x,t.y),{round:false}).setRotation(Radian.get180).displayParent(i).attach(i);}ƀbz(t,e,i){e>0&&this.ƀbw(new Vector(t.y,e)).setPosition(new Vector(0,t.y),{round:false}).setRotation(Radian.get270).displayParent(i).attach(i),T.createRectangle(new Vector(t.x-e*2,t.y),ColorHelper.white).toSprite().setPosition(new Vector(e,0),{round:false}).displayParent(i).attach(i),e>0&&this.ƀbw(new Vector(t.y,e)).setPosition(new Vector(t.x,0),{round:false}).setRotation(Radian.get90).displayParent(i).attach(i);}ƀbw(t){let i={id:this.ƀbx(t.y),scale:1,size:t,anchor:{x:0,y:0},boundingShapes:void 0};return new X(i,{textureSize:t,ignoreAnchor:true})}ƀbx(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcr.get(e);if(!i){let r=document.createElement("canvas");r.width=1,r.height=t;let s=r.getContext("2d");if(s){let n=new fi;ArrayHelper.createIntegerArray(t).forEach(l=>{let c=`rgba(255, 255, 255, ${n.multiplierFunction(l/t)})`;s.fillStyle=c,s.fillRect(0,l,1,1);});let a=V.Texture.from(r);i=M.insertAsset(a),o.ƀcr.set(e,i);}else throw new Error("Canvas context is null")}return i}};var _s=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbj}get contentSize(){return this.ƀip.contentSize}constructor(t,e={}){super();let i={padding:_s,smallContentAlign:"start",...e};if(i.padding<0)throw new Error("The padding of the scroll mask cannot be lower than '0'");if(i.padding>t.y*.5)throw new Error("The padding of the scroll mask cannot be higher than half of the size of the area");let r=new u().displayParent(this).attach(this);new gt(r,t,i.padding).attach(this);let s=new u().displayParent(r).attach(this);this.ƀip=new Ge(s,t.y,i.padding,i.smallContentAlign),this.ƀbj=new Vector(t.x,this.ƀip.scrollHeight),new ie(t).displayParent(r).attach(this).onWheel.subscribe(a=>this.ƀip.onWheel(a)).attach(this),y.afterSceneUpdateAction.subscribe(a=>this.ƀip.update(a.delta)).attach(this),this.addChildTo=s;}scrollToTop(t){this.ƀip.scrollToTop(),t?.instant&&this.ƀip.jumpToTarget();}scrollToBottom(t){this.ƀip.scrollToBottom(),t?.instant&&this.ƀip.jumpToTarget();}};var Fs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ls=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},gi=class{static{h(this,"KeyboardService");}constructor(){this.ƀfp=new Action,this.keyPressed=this.ƀfp.notifier,this.ƀfq=new Action,this.keyReleased=this.ƀfq.notifier,this.ƀfw=new Set,this.ƀfv=new Set,window.addEventListener("keydown",t=>{this.ƀfw.add(t.key),this.ƀfv.add(t.key),!t.repeat&&this.ƀfp.trigger(t.key);}),window.addEventListener("keyup",t=>{this.ƀfw.delete(t.key),this.ƀfq.trigger(t.key);}),window.addEventListener("blur",()=>{this.ƀfw.clear();}),y.afterSceneUpdateAction.subscribe(()=>{this.ƀfv.clear();}).attachToRoot();}isKeyDown(t){return this.ƀfw.has(t)}isKeyJustPressed(t){return this.ƀfv.has(t)}};gi=Fs([d(),Ls("design:paramtypes",[])],gi);var Vs=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ns=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},yi=class{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀde}get lastFocusedPosition(){return this.ƀfs}constructor(t){this.ƀgi=t,this.ƀgu=new Action,this.onTargetFocus=this.ƀgu.notifier,this.ƀjx=0,this.ƀjz=false,this.ƀde=false,this.ƀfs=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀkb(e.delta)).attachToRoot();}ƀkb(t){if(this.ƀgj){let e=this.ƀed(this.ƀgi.getStagePosition(),this.ƀgj);this.ƀhe===void 0?this.ƀhe=e:this.ƀau(e,t);}this.ƀgj=this.ƀgi.getStagePosition();}ƀau(t,e){this.ƀhe-t>10?(this.ƀjx=Math.max(250,this.ƀjx),this.ƀjz=true):this.ƀjx>1e3&&(this.ƀjz=true);let i=this.ƀjx>=300&&this.ƀjz;this.ƀfn(i,t,e);}ƀfn(t,e,i){(t||e>this.ƀhe)&&(this.ƀhe=e),t?(this.ƀjz=false,this.ƀjx=0,this.ƀde=true,this.ƀfs=this.ƀgi.getStagePosition(),this.ƀgu.trigger(this.ƀfs)):(this.ƀjx+=i,this.ƀde=false);}ƀed(t,e){let i=Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};yi=Vs([d(),Ns("design:paramtypes",[mt])],yi);var x;(function(o){o[o.Hidden=1]="Hidden",o[o.Visible=2]="Visible",o[o.Appearing=3]="Appearing",o[o.Disappearing=4]="Disappearing",o[o.DisappearToChange=5]="DisappearToChange";})(x||(x={}));var _e=class extends Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgt=new Action,this.ƀgv=new Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀj.value=0,this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:F.CompletePrevious,completionHandling:R.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀo.completeAnimation(),this.ƀn=t!==void 0?x.Visible:x.Hidden,this.ƀhv=void 0;let i=t!==void 0?1:0,r=this.ƀji!==t;r&&(this.ƀji=t,this.ƀgt.trigger(this.ƀji)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀgv.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgp()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀji&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀhv=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):(this.ƀhv=void 0,this.ƀji=t,this.ƀgt.trigger(this.ƀji)));break;case x.Disappearing:t===this.ƀji?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀhv=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀhv=void 0):t===this.ƀji?(this.ƀn=x.Appearing,this.ƀhv=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):t!==this.ƀhv&&(this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀgv.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀhv!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀji=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀhv===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀji=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger(this.ƀji),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};var Zi=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbv=t;let i={duration:200,animation:S.easeInOut,...e};this.alpha=0,this.ƀjj=new _e(i).onStateChange(r=>{this.ƀbi?.destroy(),this.ƀbi=void 0,r!==void 0&&(this.ƀbi=new u().displayParent(this).attach(this),this.ƀbv({state:r,container:this.ƀbi}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjj.setState(t,e),this}};var I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var Fe=class extends Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀji,nextState:this.ƀgl,queuedState:this.ƀhv,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgt=new Action,this.ƀgv=new Action,this.ƀha={duration:500,animation:S.lineer,...t},this.ƀo=new A(this.ƀj,"value",{duration:this.ƀha.duration,animation:this.ƀha.animation,reAnimateHandling:F.CompletePrevious,completionHandling:R.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀgv.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀji===void 0)this.ƀji=t,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀji=t,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀji&&(this.ƀn=I.Transitioning,this.ƀgl=t,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀgv.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this));break;case I.Transitioning:t!==this.ƀgl&&(t===this.ƀji?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;case I.Reverting:t!==this.ƀji&&(t===this.ƀgl?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀha.duration}).tap(()=>this.ƀgp()).attach(this)):this.ƀhv=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgp(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀji=this.ƀgl,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀji=this.ƀgl,this.ƀgl=void 0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀji===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀhv!==void 0?(this.ƀn=I.Transitioning,this.ƀgl=this.ƀhv,this.ƀhv=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl}),this.ƀo.animate({value:1}).tap(()=>this.ƀgp()).attach(this)):(this.ƀn=I.Idle,this.ƀgl=void 0,this.ƀj.value=0,this.ƀgt.trigger({state:this.ƀji,nextState:this.ƀgl})),this.ƀgv.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e)).attach(this),this}};var it;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(it||(it={}));var C;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(C||(C={}));var Le=class extends Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=C.Idle,this.ƀgt=new Action,this.ƀgv=new Action,this.ƀha={duration:500,animation:S.easeInOutCubic,...t},this.ƀjj=new Fe({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((e,i)=>this.ƀep(e,i)).onValueChange(e=>this.ƀeq(e)).attach(this);}setIndex(t,e){if(!Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀff===void 0?(this.ƀff=t,this.ƀgt.trigger({state:it.Appear,index:t}),this.ƀjj.setState(t,e)):this.ƀff!==t?this.ƀgk!==t?this.ƀn===C.Idle?(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀgk=t,this.ƀgt.trigger({state:it.Appear,index:this.ƀgk}),this.ƀjj.setState(t,e)):this.ƀjj.setState(t,e):this.ƀn===C.Reverting&&this.ƀgk===t&&(this.ƀn=t>this.ƀff?C.TransitionForward:C.TransitionBackward,this.ƀjj.setState(t,e)):(this.ƀn===C.TransitionForward||this.ƀn===C.TransitionBackward)&&(this.ƀn=C.Reverting,this.ƀjj.setState(t,e));}ƀep(t,e){switch(this.ƀff!==void 0&&this.ƀff!==t&&this.ƀff!==e&&this.ƀgt.trigger({state:it.Disappear,index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgk!==t&&this.ƀgk!==e&&this.ƀgt.trigger({state:it.Disappear,index:this.ƀgk}),e!==void 0&&e!==this.ƀff&&e!==this.ƀgk&&this.ƀgt.trigger({state:it.Appear,index:e}),this.ƀn){case C.Idle:break;case C.TransitionForward:case C.TransitionBackward:e===void 0?(this.ƀn=C.Idle,this.ƀff=this.ƀgk,this.ƀgk=void 0):this.ƀff!==t&&this.ƀen(t,e);break;case C.Reverting:e===void 0?(this.ƀn=C.Idle,this.ƀgk=void 0):this.ƀff!==e&&this.ƀen(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀeq(t){let e=1;(this.ƀn===C.TransitionBackward||this.ƀn===C.Reverting&&this.ƀff!==void 0&&this.ƀgk!==void 0&&this.ƀff>this.ƀgk)&&(e=-1),(this.ƀn===C.Idle||t!==0)&&this.ƀgv.trigger({value:NumberHelper.ensurePositiveZero(-e*t),index:this.ƀff}),this.ƀgk!==void 0&&this.ƀgv.trigger({value:NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgk});}ƀen(t,e){this.ƀff=t,this.ƀgk=e,this.ƀgv.trigger({value:0,index:this.ƀff}),this.ƀn=this.ƀff<this.ƀgk?C.TransitionForward:C.TransitionBackward;}onStateChange(t){return this.ƀgt.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀgv.subscribe(e=>t(e.value,e.index)).attach(this),this}};var et;(function(o){o[o.Horizontal=1]="Horizontal",o[o.Vertical=2]="Vertical";})(et||(et={}));var wi=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbv=t,this.ƀcm="x",this.ƀbk=new Map,this.ƀha={duration:300,animation:S.easeInOutCubic,size:new Vector(500,500),margin:20,direction:et.Horizontal,...e};let i=this.ƀha.direction===et.Horizontal?new Vector(this.ƀha.size.x+this.ƀha.margin*2,this.ƀha.size.y):new Vector(this.ƀha.size.x,this.ƀha.size.y+this.ƀha.margin*2),r=new u().setPosition(this.ƀha.direction===et.Horizontal?new Vector(-this.ƀha.margin,0):new Vector(0,-this.ƀha.margin),{round:false}).displayParent(this).attach(this);this.ƀca(i,this.ƀha.margin,this.ƀha.direction,r),this.ƀcm=this.ƀha.direction===et.Horizontal?"x":"y",this.ƀjj=new Le({duration:this.ƀha.duration,animation:this.ƀha.animation}).onStateChange((s,n)=>{if(s===it.Appear){let a=new u().displayParent(this).attach(this);this.ƀbk.set(n,a),this.ƀbv({index:n,container:a});}else {let a=this.ƀbk.get(n);a&&(a.destroy(),this.ƀbk.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbk.get(n);if(a){let l={x:0,y:0};l[this.ƀcm]=i[this.ƀcm]*s+this.ƀha.margin,a.setPosition(Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjj.setIndex(t,e),this}ƀca(t,e,i,r){new gt(r,new Vector(t.x,t.y),e,i).attach(this);}},er=class extends wi{static{h(this,"SlideInContent");}constructor(t,e,i){super(r=>{let s=this.indexToItem.get(r.index);if(s)e({index:r.index,item:s,container:r.container});else throw new Error(`SlideInContent: The item with index '${r.index}' is not part of the items list`)},i),this.itemToIndex=new Map,this.indexToItem=new Map,t.forEach((r,s)=>{this.itemToIndex.set(r,s),this.indexToItem.set(s,r);});}setItem(t,e){let i=this.itemToIndex.get(t);if(i!==void 0)this.setIndex(i,e);else throw new Error(`SlideInContent: The item '${t}' is not part of the items list`);return this}};var wt=class{static{h(this,"VectorSet");}constructor(){this.ƀkg=new Map;}add(t){let e=this.ƀkg.get(t.x);e||(e=new Set,this.ƀkg.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀkg.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀkg.get(t.x);return e?e.delete(t.y):false}};var xi=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var B=class{static{h(this,"PositionToGridPositionConverter");}static areaToGridArea(t,e){return new Rectangle(this.positionToGridPosition(t.topLeft,e),this.positionToGridPosition(t.bottomRight,e))}static positionToGridPosition(t,e){return t.divideNumber(e).floor()}static gridPositionToPosition(t,e){return t.add(new Vector(.5,.5)).multiplyNumber(e)}};var re=class{static{h(this,"ClosestAvailableSpaceHelper");}static findByConvertingGridSpace(t,e,i){let r=new Vector(Math.ceil(e.size.x/i)-1,Math.ceil(e.size.y/i)-1),s=B.areaToGridArea(e,i);if(this.ƀat(t,s))return Vector.zero;let n=t.movePositionInsideGrid(s.topLeft),a=Vector.fromTo(s.topLeft,n),l=this.find(t,n,r);if(l){let c=l.add(a),p=Vector.fromTo(s.topLeft.multiplyNumber(i),e.topLeft);return new Vector(c.x*i+((r.x+1)*i-e.size.x)/2-p.x,c.y*i+((r.y+1)*i-e.size.y)/2-p.y)}}static find(t,e,i){let r=new wt,s=new Queue(e);for(;s.notEmpty;){let n=s.pop();r.add(n);let a=new Rectangle(n,n.add(i));if(this.ƀat(t,a))return Vector.fromTo(e,n);t.getNeighborPositions(n,GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀat(t,e){if(!t.isAreaWithinBounds(e))return false;for(let i=e.topLeft.y;i<=e.bottomRight.y;i++)for(let r=e.topLeft.x;r<=e.bottomRight.x;r++)if(!t.get(new Vector(r,i)))return false;return true}};var ir=class{static{h(this,"PathfinderNode");}constructor(t,e,i,r=void 0){this.position=t,this.distanceFromStart=e,this.distanceToEnd=i,this.parent=r,this.closed=false;}get pathLength(){return this.distanceFromStart+this.distanceToEnd}isEqual(t){return Vector.isEqual(this.position,t)}createSolutionPath(t){let e=[this.position],i=this.parent;for(;i!==void 0;)e.push(i.position),i=i.parent;return e.reverse(),{directPathAvailable:t,path:e}}getDistance(t){return this.position.getDistance(t)}},to=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀem=t,this.ƀjg=e,this.ƀgy=new BinaryHeap("min"),this.ƀax=[],this.ƀgm=new Grid({size:t.size,defaultValue:void 0});let i=new ir(this.ƀjg,0,Number.MAX_SAFE_INTEGER);this.ƀgy.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀgy.size>0}getNeighbors(t,e){return this.ƀem.getNeighborPositions(t.position,e).filter(i=>this.ƀem.get(i)).map(i=>this.ƀgm.get(i)||this.ƀcb(i))}popLowestPathCostNode(){let t=this.ƀgy.pop();return this.ƀgy.delete(t),t.closed=true,this.ƀax.push(t),t}changeNodeCost(t,e,i,r){this.ƀgy.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀgy.add(t.pathLength,t);}getBestClosedNode(){return this.ƀax.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcb(t){let e=new ir(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgm.set(t,e),this.ƀgy.add(e.pathLength,e),e}},se=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new to(t,e);for(;s.hasOpenNodes;){let n=s.popLowestPathCostNode();if(n.isEqual(i))return n.createSolutionPath(true);let a=s.getNeighbors(n,r);for(let l of a)if(!l.closed){let c=n.distanceFromStart+n.getDistance(l.position);c<l.distanceFromStart&&s.changeNodeCost(l,c,i,n);}}return s.getBestClosedNode().createSolutionPath(false)}};var oe=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjo=t,this.ƀx=e,this.ƀet=this.ƀdv(this.ƀx.size),this.ƀko=new Grid({size:this.ƀx.size,defaultValue:this.ƀet}),this.ƀcn=new Grid({size:this.ƀx.size,defaultValue:void 0});let i=new wt,r=new Queue;for(this.ƀdk(this.ƀx.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀko.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀko.getOrFail(n);this.ƀea(n,this.ƀx).forEach(l=>{if(!i.has(l.position)){let c=this.ƀko.getOrFail(l.position),p=a+l.distance;this.ƀx.getOrFail(l.position)&&p<c&&(this.ƀko.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjo)){if(t=this.ƀko.movePositionInsideGrid(t),this.ƀcn.has(t))return this.ƀcn.get(t);{let e=this.ƀea(t,this.ƀx),i;return this.ƀko.getOrFail(t)>=this.ƀet?e.some(s=>this.ƀx.get(s.position))&&(e.some(n=>!this.ƀx.get(n.position))?i=this.ƀdp(e):i=this.ƀdl(t,e)):i=this.ƀdl(t,e),this.ƀcn.set(t,i),i}}}ƀdp(t){let e=t.filter(i=>this.ƀx.get(i.position)).map(i=>i.direction.radian);return Radian.getAverage(...e)}ƀdl(t,e){let i=e.filter(r=>this.ƀko.getOrFail(r.position)<this.ƀet).reduce((r,s)=>{let n=this.ƀko.getOrFail(s.position)+s.distance;return n<r.bestWeight?(r.bestDirections=[s.direction],r.bestWeight=n):n===r.bestWeight&&r.bestDirections.push(s.direction),r},{bestDirections:[],bestWeight:this.ƀet}).bestDirections;return this.ƀef(i,t)}ƀef(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),Vector.zero);if(i.isZero()||!this.ƀfk(e,i))return Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfk(t,e){let i=t.add(this.ƀkh(e));return this.ƀx.isPointWithinBounds(i)&&this.ƀx.getOrFail(i)}ƀea(t,e){return this.ƀko.getNeighborDirections(t,GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdk(t){let e=[];for(let i=t.topLeft.y;i<=t.bottomRight.y;i++)for(let r=t.topLeft.x;r<=t.bottomRight.x;r++)e.push(new Vector(r,i));return e}ƀkh(t){let e=t.normalize().round();return new Vector(e.x,e.y)}ƀdv(t){return (t.x+t.y)*20}};var oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},no=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends ${static{h(this,"PhysicsWorldEntity");}constructor(t,e,i,r,s,n,a){super(),this.materialDefinitions=new Map,this.physicsBodyGroupToP2Group=new Map,this.physicsBodyGroupToP2Mask=new Map,this.availabilityGridCache=new Map,this.vectorFieldCache=new Map,this.bodiesInContactWith=new Map,this.collisionReports=new Map,this.paused=new Variable(false),this.lastP2Time=new Variable(0),this.onPhysicsStep=new Action,this.mapSize=t,this.mapSizeCenter=this.mapSize.multiplyNumber(.5),this.modifyUpdateCycle=e,this.p2World=i,this.materials=r,this.materialDefinitions=s,this.physicsBodyGroupToP2Group=n,this.physicsBodyGroupToP2Mask=a;}};v=oo([dt(),no("design:paramtypes",[Vector,Boolean,W.World,Map,Map,Map,Map])],v);var co=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},K=class{static{h(this,"PhysicsBodyGroupService");}createBodyGroupsAndMasks(t,e){let i=new Map,r=new Map;return t.map((s,n)=>{if(n>31)return console.error("Cannot have more than 32 physics body groups"),{};i.set(s,1<<n),r.set(s,0);}),e.map(([s,n])=>{if(!i.has(s))throw new Error(`Physics body group "${s}" not found`);if(!i.has(n))throw new Error(`Physics body group "${n}" not found`);let a=r.get(s),l=r.get(n),c=i.get(s),p=i.get(n);r.set(s,a|p),r.set(n,l|c);}),{physicsBodyGroupToP2Group:i,physicsBodyGroupToP2Mask:r}}getGroupConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return v.getInstanceByIDOrFail(t).physicsBodyGroupToP2Mask.get(e)}canCollide(t,e,i){let r=t.physicsBodyGroupToP2Group.get(e),s=t.physicsBodyGroupToP2Mask.get(e),n=t.physicsBodyGroupToP2Group.get(i),a=t.physicsBodyGroupToP2Mask.get(i);return (s&n)!==0&&(a&r)!==0}};K=co([d()],K);var po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},uo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ve=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhh=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhh.canCollide(t,a,e)&&i.push({grid:n,cellSize:s});});}),i}get(t,e,i){return t.availabilityGridCache.get(e)?.get(i)}set(t,e,i,r){let s=t.availabilityGridCache.get(e);s||(s=new Map,t.availabilityGridCache.set(e,s)),s.set(i,r);}clear(t){t.availabilityGridCache.clear();}};Ve=po([d(),uo("design:paramtypes",[K])],Ve);var fo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},mo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},nt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhh=t,this.ƀy=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀy.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Bt){return e.aabbNeedsUpdate=true,e.updateAABB(),re.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀy.get(t,e,i);return r||(r=this.ƀby(t,e,i),this.ƀy.set(t,e,i,r)),r}ƀby(t,e,i){let r=new Grid({size:new Vector(Math.floor(t.mapSize.x/e),Math.floor(t.mapSize.y/e)),defaultValue:true});return t.p2World.bodies.forEach(s=>{let n=b.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀhh.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdu(s,e);r.setArea(a,false);}}),r}ƀdu(t,e){let i=f.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=fo([d(),mo("design:paramtypes",[K,Ve])],nt);var wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},xo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Bt=50,Gt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhg=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Bt);let n=v.getInstanceByIDOrFail(t),a,l;Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhg.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let E=f.aabbToBoundingBox(l.aabb),vt=B.areaToGridArea(E,s.gridCellSize);m.setArea(vt,true);}let g=se.findPath(m,c,p,s.neighborType);return g.path=g.path.map(E=>B.gridPositionToPosition(E,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Bt){let n=v.getInstanceByIDOrFail(t),a;if(Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(g.p2Body.aabb);}else a=new Rectangle(i,i);let l=B.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let g=this.ƀhg.getAvilabilityGrid(n,s,r);p=new oe(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};Gt=wo([d(),xo("design:paramtypes",[nt])],Gt);var Po=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},j=new U,bi=class{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return j.trigger("createPhysicsWorld",t)}getMapSize(t){return j.trigger("getMapSize",t)}setPaused(t,e){return j.trigger("setPaused",t,e)}hitTest(t,e){return j.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return j.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return j.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return j.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return j.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return j.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Bt){return j.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};bi=Po([d()],bi);var So=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Co=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Q=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀz=t,this.ƀhd=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀz.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhd.findPathDirection(t,c.position,i,r),m;p===void 0?m=T.createRectangleBorders(new Vector(8,8),2,ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=T.createArrow(25,c.availability?ColorHelper.green:ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new A(m,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new u().displayParent(e).setAlpha(.5).attach(t);T.createCircle(s,ColorHelper.blue).toSprite().displayParent(a).setPosition(r,{round:false}).setAlpha(.5).attach(t),i.forEach(c=>{let p=c.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new A(a,"alpha",{duration:n,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new u().displayParent(e).setAlpha(.5).attach(t);T.createElipse(n,ColorHelper.blue).toSprite().displayParent(l).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attach(t),i.forEach(p=>{let m=p.hits.length>0?ColorHelper.red:ColorHelper.white;T.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new A(l,"alpha",{duration:a,animation:S.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??f.arrayToVector(t.position),s=i?.overrideRotation??new Radian(t.angle),n=i?.color??ColorHelper.blue,a=new u().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcq(c,n).displayParent(a).attachToRoot();}),new A(a,"alpha",{duration:1e3,animation:S.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcq(t,e){switch(t.type){case W.Shape.PARTICLE:throw new Error("Not implemented");case W.Shape.LINE:throw new Error("Not implemented");case W.Shape.PLANE:throw new Error("Not implemented");case W.Shape.CIRCLE:throw new Error("Not implemented");case W.Shape.CAPSULE:throw new Error("Not implemented");case W.Shape.BOX:throw new Error("Not implemented");case W.Shape.HEIGHTFIELD:throw new Error("Not implemented");case W.Shape.CONVEX:return this.ƀcp(t,e);default:throw new Error("Not implemented")}}ƀcp(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return T.createPolygon(i,e).toSprite()}};Q=So([d(),Co("design:paramtypes",[nt,Gt])],Q);var Ro=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Io=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ne=class{static{h(this,"HitTestService");}constructor(t){this.ƀjq=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdi(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>f.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new W.World;l.addBody(s),n.forEach(c=>l.addBody(c)),l.step(1,1,1),a=l.narrowphase.contactEquations.some(c=>c.bodyA===s||c.bodyB===s),l.clear();}if(e?.testLayerID){let l=a?ColorHelper.red:ColorHelper.green;this.ƀjq.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀt(t,e){e?.overridePosition&&(t.position=f.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdi(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Ro([d(),Io("design:paramtypes",[Q])],Ne);var Oo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀib(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀay=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀib(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀeo(r.p2Body),r.entity.ƀis(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀeo(t){let e=f.arrayToVector(t.velocity);e.length>10.8&&(e=e.normalize(10.8),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-10.01),10.01);}ƀib(t,e){let i=b.getFromP2BodyID(e.bodyA.id),r=b.getFromP2BodyID(e.bodyB.id);if(i&&r){t.bodiesInContactWith.set(e.bodyA.id,{p2Body:e.bodyA,entity:i}),t.bodiesInContactWith.set(e.bodyB.id,{p2Body:e.bodyB,entity:r});let s=t.collisionReports.get(e.bodyA.id)||[],n=t.collisionReports.get(e.bodyB.id)||[],{collisionDetailsA:a,collisionDetailsB:l}=this.ƀdn(i,r,e);s.push({self:a,target:l}),n.push({self:l,target:a}),t.collisionReports.set(e.bodyA.id,s),t.collisionReports.set(e.bodyB.id,n);}else console.warn("ContactEquationOrganiser: Entity not found for contact equation",e);}ƀdn(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=f.arrayToVector(i.contactPointA),a=f.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀeb(i);return {collisionDetailsA:this.ƀdm(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdm(s,i.bodyB.mass,a,c,e.area)}}ƀdm(t,e,i,r,s){let n,a=i.add(t.position);return {body:t,getPositionReletiveToObject:h(()=>(n||(n=i.rotate(t.rotation.multiply(-1).vector)),n),"getPositionReletiveToObject"),getPositionOnWorld:h(()=>(a||(a=i.add(t.position)),a),"getPositionOnWorld"),position:i,mass:e,area:s,normal:r}}ƀeb(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=Oo([d()],je);var Mo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Do=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends Wt{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Mo([dt(),Do("design:paramtypes",[Number,Object])],He);var Bo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},H=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbs(t,new Vector(e.x/2,-H/2),new Vector(e.x+H*2,H),i),this.ƀbs(t,new Vector(e.x/2,e.y+H/2),new Vector(e.x+H*2,H),i),this.ƀbs(t,new Vector(-H/2,e.y/2),new Vector(H,e.y+H*2),i),this.ƀbs(t,new Vector(e.x+H/2,e.y/2),new Vector(H,e.y+H*2),i);}ƀbs(t,e,i,r){return new He(t,{shapeDefinition:{materialName:st,group:r,shapeType:tt.Rectangle,shapeData:i},position:e,rotation:Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Bo([d()],We);var _o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ar=new W.Material,Fo={id:st,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},_t=class{static{h(this,"MaterialsService");}createMaterials(t,e,i,r){let s=new Map,n=new Map;if(i.forEach(a=>{s.set(a.id,new W.Material),n.set(a.id,a);}),s.has(st))throw new Error(`Material with name ${st} cannot be defined, pick another name for the material.`);return s.set(st,ar),n.set(st,Fo),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdz(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀdy(e,i.materialDefinitions)}ƀdz(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀdy(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material definition with name ${t}.`);return i}ƀc(t,e,i,r,s){this.ƀdr(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀdz(n.materialA,s),l=this.ƀdz(n.materialB,s);t.addContactMaterial(new W.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀdr(t,e){let i=new Map;e.forEach(s=>{let n=i.get(s.materialA);n||(n=new Map,i.set(s.materialA,n)),n.set(s.materialB,s);});let r=[];return t.forEach((s,n)=>{for(let a=n;a<t.length;a++){let l=t[a],c=i.get(s)?.get(l);c?r.push(c):r.push({materialA:s,materialB:l,friction:0,bounciness:0,relaxation:4,stiffness:1e6});}}),r}ƀd(t,e,i,r){i.forEach(s=>{let n=this.ƀdz(s.id,r);t.addContactMaterial(new W.ContactMaterial(n,ar,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};_t=_o([d()],_t);var Lo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Ft=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀge=t,this.ƀaj=e,this.ƀz=i,this.ƀaz=r,this.ƀhh=s;}createPhysicsWorld(t){let e=new W.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀge.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhh.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new v(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&y.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀaz.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjk(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjk(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀz.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀz.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjk(t,e,i){if(!t.paused.value){t.availabilityGridCache.clear(),t.vectorFieldCache.clear(),t.p2World.step(i,i,i),t.modifyUpdateCycle&&(i=t.p2World.time-t.lastP2Time.value);let r=e+i;this.ƀaz.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){v.getInstanceByIDOrFail(e).paused.set(t);}};Ft=Lo([d(),Vo("design:paramtypes",[_t,We,nt,je,K])],Ft);var jo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Vt=class{static{h(this,"RayCastingService");}castClosest(t,e,i){let r=new W.RaycastResult,s=new W.Ray({mode:W.Ray.CLOSEST,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbn(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new W.Ray({mode:W.Ray.ALL,from:f.vectorToArray(e.from),to:f.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i),callback:h(n=>{let a=r.get(n.body);!r.has(n.body)||n.fraction<a.fraction?r.set(n.body,this.ƀbn(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbn(n,e));},"callback")});return t.p2World.raycast(new W.RaycastResult,s),Array.from(r.values())}ƀbn(t,e){let i=t.fraction,r=f.arrayToVector(t.normal),s,n,a;return {body:t.body,hitPosition:h(()=>(s===void 0&&(s=e.from.lerp(e.to,i)),s),"hitPosition"),hitDistance:h(()=>(n===void 0&&(n=e.length*i),n),"hitDistance"),isExternal:h(()=>(a===void 0&&(a=e.fromTo.dotProduct(r)<0),a),"isExternal"),normal:r,fraction:i,line:e}}};Vt=jo([d()],Vt);var Ho=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},lt=class{static{h(this,"ImpactService");}applyImpulse(t,e,i,r){let s=i.normalize(r),n=[e.x-t.position[0],e.y-t.position[1]];t.applyImpulse(f.vectorToArray(s),n);}};lt=Ho([d()],lt);var Wo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Nt=class{static{h(this,"RayCastHitConverterService");}toExplosionHits(t,e=true){let i=new Map;return t.forEach(r=>{r.hits.forEach(s=>{let n=i.get(s.body);if(n){let a=s.fraction<n.closestRaycastHit.fraction?s:n.closestRaycastHit;n.rayCastHits.push(s),i.set(s.body,{hitCount:n.hitCount+1,closestRaycastHit:a,rayCastHits:n.rayCastHits,isExternal:e?n.isExternal:n.isExternal&&s.isExternal(),explosionCenter:s.line.from});}else {let a=s.isExternal();i.set(s.body,{hitCount:1,closestRaycastHit:s,rayCastHits:[s],isExternal:a,explosionCenter:s.line.from});}});}),[...i.values()].map(r=>this.ƀbo(r,t.length))}ƀbo(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:true,normal:t.closestRaycastHit.normal,fraction:t.closestRaycastHit.fraction,ratioOfHits:i,raycastResults:r,getHitPosition:t.closestRaycastHit.hitPosition,getHitDistance:t.closestRaycastHit.hitDistance};{let s=f.arrayToVector(t.closestRaycastHit.body.position);return {body:b.getFromP2BodyIDOrFail(t.closestRaycastHit.body.id).convertToDTO(),p2Body:t.closestRaycastHit.body,isExternal:false,normal:Vector.fromTo(s,t.explosionCenter).normalize(),fraction:0,ratioOfHits:i,raycastResults:r,getHitPosition:h(()=>t.explosionCenter,"getHitPosition"),getHitDistance:h(()=>0,"getHitDistance")}}}};Nt=Wo([d()],Nt);var $o=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},zo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Yo=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcd(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀhw.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀjq.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...E}=m;return E})}ƀcd(t,e,i,r,s,n){let a=[],l=e.vector,c=e.add(Radian.get90).vector,p=c.normalize(i.x);a.push(new Line(t,t.add(p))),a.push(new Line(t,t.add(p.multiplyNumber(-1))));let m=l.normalize(i.y);a.push(new Line(t,t.add(m))),a.push(new Line(t,t.add(m.multiplyNumber(-1))));let g=Math.round(i.y/Yo),E=i.y/(g*2+1)*2,vt=l.normalize(E),ne=i.x,lr=Math.pow(i.y,2);return ArrayHelper.createIntegerArray(g).forEach(pt=>{let bt=E*(pt+1),Ci=vt.multiplyNumber(pt+1),ae=c.normalize(this.ƀej(ne,lr,bt)),he=t.add(Ci);a.push(new Line(he,he.add(ae))),a.push(new Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ci.multiplyNumber(-1));a.push(new Line(le,le.add(ae))),a.push(new Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(pt=>{if(s){let bt=this.ƀhx.castClosest(n,pt,r);return {line:pt,hits:bt?[bt]:[]}}else {let bt=this.ƀhx.castAllFirstContacts(n,pt,r);return {line:pt,hits:bt}}})}ƀej(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀr(t,e){t.forEach(i=>{i.raycastResults.forEach(r=>{let s,n;r.isExternal()?(s=r.line.fromTo,n=e*2):(s=r.line.fromTo.multiplyNumber(-1),n=e*(1-r.fraction)*8),this.ƀfd.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=$o([d(),zo("design:paramtypes",[Vt,Q,Nt,lt])],$e);var Xo=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},Ko=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},ze=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀhx=t,this.ƀjq=e,this.ƀhw=i,this.ƀfd=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀeg(i),c=this.ƀcd(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀhw.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀjq.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcd(t,e,i,r,s,n){let a=new Radian(PI_360/r),l=new Vector(0,-e),c=a.vector;return ArrayHelper.createEmptyArray(r).map(()=>{let p=t.add(l);return l=l.rotate(c),new Line(t,p)}).map(p=>{if(s){let m=this.ƀhx.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀhx.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀr(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfd.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=Vector.fromTo(t,f.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀfd.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeg(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ze=Xo([d(),Ko("design:paramtypes",[Vt,Q,Nt,lt])],ze);var en=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},jt=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=v.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return v.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};jt=en([d()],jt);var rn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},sn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀho=t,this.ƀhd=e,this.ƀjq=i,this.ƀda=r,this.ƀcu=s,this.ƀeu=n,this.ƀhn=a,this.ƀfd=l;}createPhysicsWorld(t){return this.ƀho.createPhysicsWorld(t)}getMapSize(t){return this.ƀhn.getMapSize(t)}setPaused(t,e){this.ƀho.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀeu.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhd.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhd.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfd.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀda.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcu.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n){this.ƀjq.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=rn([q({controllerLink:j}),sn("design:paramtypes",[Ft,Gt,Q,ze,$e,Ne,jt,lt])],Pi);var on=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},ke=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(!n.physicsBodyGroupToP2Group.has(e.shapeDefinition.group))throw new Error(`Physics body group "${e.shapeDefinition.group}" not found`);switch(e.shapeDefinition.shapeType){case tt.Point:return this.ƀbu(n,void 0,i,r,e.shapeDefinition.group,s);case tt.Circle:return this.ƀbu(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case tt.Polygon:return this.ƀcc(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case tt.Rectangle:return this.ƀce(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbu(t,e,i,r,s,n){let a=new W.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new W.Body({type:n==="dynamic"?W.Body.DYNAMIC:W.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcc(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new W.Convex({vertices:g.map(E=>[E.x,E.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,E)=>g+E.area,0),m=new W.Body({type:n==="dynamic"?W.Body.DYNAMIC:W.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(g=>m.addShape(g)),m.setDensity(r.density),m}ƀce(t,e,i,r,s,n){let a=new W.Box({width:e.x,height:e.y,collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s)});a.material=i;let l=e.x*e.y,c=new W.Body({type:n==="dynamic"?W.Body.DYNAMIC:W.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ke=on([d()],ke);var nn=function(o,t,e,i){var r=arguments.length,s=r<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,e):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,t,e,i);else for(var a=o.length-1;a>=0;a--)(n=o[a])&&(s=(r<3?n(s):r>3?n(t,e,s):n(t,e))||s);return r>3&&s&&Object.defineProperty(t,e,s),s},an=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Si=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀho=t,this.ƀhm=e,this.ƀix=i,this.ƀhn=r,this.ƀhh=s;}createBody(t,e,i,r,s){return this.ƀix.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀhm.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀhm.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhh.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhh.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀho.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀho.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhn.subscribeToPhysicsStep(t,e)}};Si=nn([q({controllerLink:J}),an("design:paramtypes",[Ft,_t,ke,jt,K])],Si);export{Ai as AnimationFlicker,Y as AnimationInterpolationFunctions,S as Animations,R as AnimationsCompletionHandlingType,A as Animator,st as BORDER_MATERIAL_NAME,G as BardLegendsHardReset,Tt as BlendMode,Xt as Camera,Rt as CameraGateway,re as ClosestAvailableSpaceHelper,u as Container,$t as ContainerEventType,q as ControllerDecorator,U as ControllerLink,qe as Cursor,O as DEFAULT_SHADER_RESOLUTION,xi as DeltaTime,ci as DisplayObjectArray,$ as Entity,dt as EntityDecorator,Zi as FadeInContent,_e as FadeInStateAnimation,ot as FocusingAnimation,w as Game,T as Graphics,Wt as ImmovablePhysicsEntity,gi as KeyboardService,Dt as Menu,di as MenuEntity,mt as MouseService,yi as MouseTargetFocusService,ie as MouseWheelListenerUI,Xe as MovableEntity,Ke as MovablePhysicsEntity,se as PathFinder,b as PhysicsEntity,bi as PhysicsGateway,tt as PhysicsShapeType,ai as Placeholder,kt as PositionConversionHelper,Qe as ROTATIONAL_SPEED_LIMIT,F as ReAnimateHandlingType,hi as RichText,Ze as SPEED_LIMIT,Pt as Scene,wr as SceneDecorator,mi as ScrollAreaUI,et as ScrollDirection,gt as ScrollMaskUI,P as Service,d as ServiceDecorator,ut as SingletonEntity,er as SlideInContent,wi as SlideInContentByIndex,Le as SlideStateAnimation,it as SlideStateAnimationState,X as Sprite,Fe as StateAnimation,te as Text,li as UpdatableContainer,y as UpdateCycle,oe as VectorFieldPathFinder,wt as VectorSet,Ht as View,Ye as ViewDecorator};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bard-legends-framework",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Bard Legends Framework",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"reflect-metadata": "0.2.2"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"actions-lib": "^3.0.
|
|
51
|
-
"helpers-lib": "^2.0.
|
|
50
|
+
"actions-lib": "^3.0.1",
|
|
51
|
+
"helpers-lib": "^2.0.5",
|
|
52
52
|
"script-engine-lib": "^1.0.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|