bard-legends-framework 1.5.3 → 1.7.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.js CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var actionsLib=require('actions-lib');require('reflect-metadata');var helpersLib=require('helpers-lib'),L=require('pixi.js'),scriptEngineLib=require('script-engine-lib'),U=require('p2');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 L__namespace=/*#__PURE__*/_interopNamespace(L);var U__default=/*#__PURE__*/_interopDefault(U);var lr=Object.defineProperty;var h=(o,t)=>lr(o,"name",{value:t,configurable:true});var F=class{static{h(this,"BardLegendsHardReset");}static{this.ƀev=new actionsLib.Action;}static{this.onHardReset=this.ƀev.notifier;}static hardReset(){actionsLib.ActionLib.hardReset(),this.ƀev.trigger();}};function d(){return function(o){let t=T.ƀee(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var T=class{static{h(this,"Service");}static{this.ƀiy=new Map;}static get(t){let e=this.ƀiy.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀil(t.$meta.paramtypes);e=new t(...i),this.ƀiy.set(t,e);}return e}static ƀee(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e.some(i=>i.name==="Object")&&console.error(`Some injected parameters are failed to resolve. Check if it is imported as value, if not remove the "type" keyword. Class: "${t.name}"`),e}static ƀil(t){return t.map(i=>{if(i&&i.$meta?.type==="service")return this.get(i);throw new Error(`Injected parameter has to be decorated with @ServiceDecorator(), class: "${i.name}"`)})}};F.onHardReset.subscribe(()=>{T.ƀiy=new Map;}).attachToRoot();var $=class{static{h(this,"ControllerLink");}constructor(){this.ƀbl=[],this.ƀij=[];}trigger(t,...e){let i=this.ƀbl.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.ƀij.includes(e))throw new Error(`ServiceLink: the function is already registered, function name: "${e}"`);this.ƀij.push(e);}),this.ƀbl.push(t);}};function q(o){return function(t){let e=T.ƀee(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=T.ƀil(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.ƀab=new actionsLib.Action;}static{this.beforeSceneUpdateAction=this.ƀab.notifier;}static{this.ƀiq=new actionsLib.Action;}static{this.sceneUpdateAction=this.ƀiq.notifier;}static{this.ƀf=new actionsLib.Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀkd=0;}static{this.ƀkl=void 0;}static wait(t){let e=this.ƀkd+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.ƀkl)this.ƀkl=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀkl=void 0;}static triggerUpdateTick(t){this.ƀkl&&(t=this.ƀkl(this.ƀkd,t)),this.ƀkd+=t,this.ƀfw=t,t>0&&(o.ƀab.trigger({time:this.ƀkd,delta:t}),o.ƀiq.trigger({time:this.ƀkd,delta:t}),o.ƀf.trigger({time:this.ƀkd,delta:t}));}static get lastDelta(){return this.ƀfw}static{this.ƀfw=0;}};F.onHardReset.subscribe(()=>{y.ƀab.clear(),y.ƀiq.clear(),y.ƀf.clear(),y.ƀkl=void 0,y.ƀkd=0;}).attachToRoot();var A=class o{static{h(this,"EntityStoreHelper");}static{this.ƀau=new Map;}static registerEntityClass(t){this.ƀau.set(t.id,new Map);}static registerEntity(t){let e=this.ƀau.get(t.classID);if(!e)throw new Error(`EntityStoreHelper: No entity class is found. Be sure that entity is decorated with EntityDecorator! Name: "${t.constructor.name}"`);e.set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀau.get(i)?.delete(e);}static getEntity(t,e){return this.ƀau.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.ƀau.get(t.id);return Array.from(e.values())}};F.onHardReset.subscribe(()=>{A.ƀau.clear();}).attachToRoot();function Ye(o){return function(t){t.$meta={paramtypes:T.ƀee(t),viewInstances:new Map,entity:o.entity,type:"view"},rt.registerView(t,o.entity);}}h(Ye,"ViewDecorator");var dt=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.ƀcy=rt.entityID,this.ƀel().set(this.ƀcy,this);}destroy(){this.destroyed||(super.destroy(),this.ƀel().delete(this.ƀcy));}update(t,e){}ƀel(){return this.constructor.$meta.viewInstances}};var rt=class o{static{h(this,"EntityViewsHelper");}static{this.ƀku=new Map;}static registerView(t,e){o.ƀku.has(e)||o.ƀku.set(e,[]);let i=o.ƀku.get(e);i&&i.push(t),A.getEntities(e).forEach(s=>{this.ƀcg(s,t);});}static ƀcg(t,e){try{let i=T.ƀil(e.$meta.paramtypes.slice(1));o.entityID=t.id;let r=new e(t,...i);t.destroyed?r.destroy():t.ƀkt.ƀkv.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀcx=t,this.ƀkv=[];}createViews(){if(!this.ƀcx.destroyed){let t=o.ƀku.get(this.ƀcx.constructor);t&&t.forEach(e=>{o.ƀcg(this.ƀcx,e);});}}updateViews(t,e){for(let i=0;i<this.ƀkv.length;i++){let r=this.ƀkv[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀkv.forEach(t=>{t.destroy();});}};F.onHardReset.subscribe(()=>{rt.ƀku=new Map;}).attachToRoot();function ft(){return function(o){o.$meta={type:"entity"},A.registerEntityClass(o);}}h(ft,"EntityDecorator");var k=class extends actionsLib.IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return A.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=A.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return A.getEntities(this)}constructor(){super(),this.ƀkt=new rt(this),A.registerEntity(this),y.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀkt.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀkt.destroyViews(),A.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀkt.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀkt.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀkt.createViews(),this}update(t,e){}};var ut=class o extends k{static{h(this,"SingletonEntity");}static{this.ƀch=new WeakMap;}static ƀdq(t){let e=o.ƀch.get(t);return e||(e=new actionsLib.SingleAction,o.ƀch.set(t,e)),e}static ƀki(t){o.ƀch.delete(t);}static getInstanceAsync(){let t=A.getSingleton(this);return t&&!t.destroyed?actionsLib.SingleEvent.instant(t):o.ƀdq(this).toSingleEvent()}static continuesSubscription(){let t=h((e,i)=>{this.getInstanceAsync().tap(s=>{e({type:"open",value:s}),s.onDestroy().tap(()=>{e({type:"close",value:s}),t(e,i);}).attach(i);}).attach(i);},"subscribe");return actionsLib.Sequence.create((e,i)=>t(e,i.attachable))}static getInstance(){return A.getSingleton(this)}static getInstanceOrFail(){return A.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}"`);this.onDestroy().tap(()=>o.ƀki(this.constructor)).attachToRoot(),o.ƀdq(this.constructor).resolve(this);}};function br(){return function(o){return o.$meta={paramtypes:T.ƀee(o),type:"scene"},o}}h(br,"SceneDecorator");var le=class o extends actionsLib.IDAttachable{static{h(this,"Scene");}static{this.ƀfp=new actionsLib.Variable(false);}static{this.isTransitioning=this.ƀfp.notifier;}static{this.ƀb=new actionsLib.Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static cancelActiveScene(){return o.ƀb.value?o.ƀb.value.animateAndClose():actionsLib.SingleEvent.instant()}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.ƀfp.value)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.ƀfp.value=true;let i=T.ƀil(this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀfp.value=false,r)).chainToRoot()}constructor(){super(),this.ƀgt=new actionsLib.SingleAction,this.onClose=this.ƀgt.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.ƀfp.value)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀfp.value=true;let e=t[0];return this.animateAndClose().map(()=>(this.ƀgt.resolve(e),e)).chainToRoot()}animateAndClose(){return this.prepareToClose().tap(()=>{super.destroy(),o.ƀb.set(void 0),o.ƀfp.value=false;}).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};F.onHardReset.subscribe(()=>{le.ƀb.set(void 0);}).attachToRoot();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",o.Wheel="wheel";})(exports.ContainerEventType||(exports.ContainerEventType={}));exports.Cursor=void 0;(function(o){o.Default="default",o.Pointer="pointer";})(exports.Cursor||(exports.Cursor={}));var pe=class extends actionsLib.IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgn=false,this.ƀdd=false,this.ƀio=1,this.ƀv=1,this.ƀhv=new L__namespace.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new helpersLib.Vector(this.ƀhv.width,this.ƀhv.height)}setSize(t){return this.ƀhv.width=t.x,this.ƀhv.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.ƀhv.getLocalBounds(),r=new helpersLib.Vector(this.ƀhv.scale.x,this.ƀhv.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.ƀhv.x,this.ƀhv.y)}set position(t){this.ƀhv.position=t;}get x(){return this.ƀhv.x}set x(t){this.ƀhv.x=t;}get y(){return this.ƀhv.y}set y(t){this.ƀhv.y=t;}on(t){return actionsLib.Sequence.create(e=>{let i=h(r=>{if(t===exports.ContainerEventType.Wheel){let n=r.deltaY;e({deltaY:n});}else e(void 0);},"handle");return this.ƀhv.on(t,i),()=>this.ƀhv.off(t,i)}).notIdle()}setRotation(t){return this.rotation=t,this}get rotation(){return new helpersLib.Radian(this.ƀhv.rotation)}set rotation(t){this.ƀhv.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.ƀhv.zIndex}set zIndex(t){this.ƀhv.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new helpersLib.Radian(this.ƀhv.skew.x)}set skewX(t){this.ƀhv.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new helpersLib.Radian(this.ƀhv.skew.y)}set skewY(t){this.ƀhv.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.ƀhv.sortableChildren}set sortableChildren(t){this.ƀhv.sortableChildren=t;}setAlpha(t){return this.ƀhv.alpha=t,this}get alpha(){return this.ƀhv.alpha}set alpha(t){this.ƀhv.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.ƀhv.interactive}set interactive(t){t?this.ƀhv.eventMode="dynamic":this.ƀhv.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.ƀhv.cursor}set cursor(t){this.ƀhv.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.ƀhv.addChild(t.ƀhv),this.ƀhv.mask=t.getMask(),this.ƀgg=t):(this.ƀgg&&this.ƀhv.removeChild(this.ƀgg.ƀhv),this.ƀhv.mask=null),this}hitTest(t){if(this.ƀhv.parent)if(this.ƀhv.hitArea){let e=this.ƀhv.toLocal(t);return this.ƀhv.hitArea.contains(e.x,e.y)}else return this.ƀhv.getBounds().contains(t.x,t.y);else return false}get boundingBox(){let t=this.ƀhv.getLocalBounds();return new helpersLib.Rectangle(new helpersLib.Vector(t.x,t.y),new helpersLib.Vector(t.x+t.width,t.y+t.height))}ignoreBounds(t=true){return t?(this.ƀhf||(this.ƀhf=this.ƀhv.calculateBounds),this.ƀhv.calculateBounds=()=>this.ƀhv._bounds.clear()):this.ƀhf&&(this.ƀhv.calculateBounds=this.ƀhf),this}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgn}set mirror(t){this.ƀgn=t,this.ƀkm();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdd}set flip(t){this.ƀdd=t,this.ƀkm();}setScale(t){return this.scale=t,this}get scale(){return this.ƀio}set scale(t){this.ƀio=t,this.ƀkm();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀv}set aspectRatio(t){this.ƀv=t,this.ƀkm();}ƀkm(){this.ƀhv.scale.set(this.ƀio,this.ƀio),this.ƀv<1?this.ƀhv.scale.x*=this.ƀv:this.ƀv>1&&(this.ƀhv.scale.y/=this.ƀv),this.ƀgn&&(this.ƀhv.scale.x*=-1),this.ƀdd&&(this.ƀhv.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 de=class{static{h(this,"GaussianValuesHelper");}static ƀdi(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.ƀbq(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.ƀdi(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbq(e)}}static ƀbq(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 Ci=class Ke extends L__namespace.Filter{static{h(this,"BlurFilterPass");}static ƀek(){return `
1
+ 'use strict';var actionsLib=require('actions-lib');require('reflect-metadata');var helpersLib=require('helpers-lib'),j=require('pixi.js'),scriptEngineLib=require('script-engine-lib'),$=require('p2');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 j__namespace=/*#__PURE__*/_interopNamespace(j);var $__default=/*#__PURE__*/_interopDefault($);var ur=Object.defineProperty;var h=(o,t)=>ur(o,"name",{value:t,configurable:true});function Q(){return class{static{h(this,"GatewayBase");}}}h(Q,"Gateway");function Ei(o,t){let e=o.prototype,i=Object.getPrototypeOf(t);for(let r of Reflect.ownKeys(i)){if(typeof r!="string"||r==="constructor")continue;let s=t[r];if(typeof s=="function"){if(Object.prototype.hasOwnProperty.call(e,r))throw new Error(`Gateway "${o.name}": method "${r}" is already registered by another controller.`);e[r]=s.bind(t);}}}h(Ei,"bindControllerToGateway");var I=class{static{h(this,"BardLegendsHardReset");}static{this.ƀfa=new actionsLib.Action;}static{this.onHardReset=this.ƀfa.notifier;}static hardReset(){actionsLib.ActionLib.hardReset(),this.ƀfa.trigger();}};function d(){return function(o){let t=E.ƀej(o);o.$meta={paramtypes:t,type:"service"};}}h(d,"ServiceDecorator");var E=class{static{h(this,"Service");}static{this.ƀjk=new Map;}static get(t){let e=this.ƀjk.get(t);if(!e){if(!t.$meta)throw new Error(`Service: service class is not decorated by @ServiceDecorator(), class: "${t.name}"`);let i=this.ƀiy(t.$meta.paramtypes);e=new t(...i),this.ƀjk.set(t,e);}return e}static ƀej(t){let e=Reflect.getMetadata("design:paramtypes",t)||[];return e.some(i=>!i)&&console.error(`Circular dependency: ${t.name}`),e.some(i=>i.name==="Object")&&console.error(`Some injected parameters are failed to resolve. Check if it is imported as value, if not remove the "type" keyword. Class: "${t.name}"`),e}static ƀiy(t){return t.map(i=>{if(i&&i.$meta?.type==="service")return this.get(i);throw new Error(`Injected parameter has to be decorated with @ServiceDecorator(), class: "${i.name}"`)})}};I.onHardReset.subscribe(()=>{E.ƀjk=new Map;}).attachToRoot();function q(o){return function(t){let e=E.ƀej(t);if(e.some(i=>!i))console.error(`Circular dependency: ${t.name}`);else {let i=E.ƀiy(e);i.some(s=>s===void 0)&&console.error(i,e,t.name);let r=new t(...i);Ei(o,r);}t.$meta={type:"controller"};}}h(q,"ControllerDecorator");var g=class o{static{h(this,"UpdateCycle");}static{this.ƀad=new actionsLib.Action;}static{this.beforeSceneUpdateAction=this.ƀad.notifier;}static{this.ƀjd=new actionsLib.Action;}static{this.sceneUpdateAction=this.ƀjd.notifier;}static{this.ƀf=new actionsLib.Action;}static{this.afterSceneUpdateAction=this.ƀf.notifier;}static{this.ƀkv=0;}static{this.ƀld=void 0;}static wait(t){let e=this.ƀkv+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.ƀld)this.ƀld=t;else throw new Error("UpdateCycle: There can only one update modifier!")}static cleanUpdateModifier(){this.ƀld=void 0;}static triggerUpdateTick(t){this.ƀld&&(t=this.ƀld(this.ƀkv,t)),this.ƀkv+=t,this.ƀgb=t,t>0&&(o.ƀad.trigger({time:this.ƀkv,delta:t}),o.ƀjd.trigger({time:this.ƀkv,delta:t}),o.ƀf.trigger({time:this.ƀkv,delta:t}));}static get lastDelta(){return this.ƀgb}static{this.ƀgb=0;}};I.onHardReset.subscribe(()=>{g.ƀad.clear(),g.ƀjd.clear(),g.ƀf.clear(),g.ƀld=void 0,g.ƀkv=0;}).attachToRoot();var B=class o{static{h(this,"EntityStoreHelper");}static{this.ƀax=new Map;}static registerEntityClass(t){this.ƀax.set(t.id,new Map);}static registerEntity(t){let e=this.ƀax.get(t.classID);if(!e)throw new Error(`EntityStoreHelper: No entity class is found. Be sure that entity is decorated with EntityDecorator! Name: "${t.constructor.name}"`);e.set(t.id,t);}static unregisterEntity(t,e){let i=t.id;this.ƀax.get(i)?.delete(e);}static getEntity(t,e){return this.ƀax.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.ƀax.get(t.id);return Array.from(e.values())}};I.onHardReset.subscribe(()=>{B.ƀax.clear();}).attachToRoot();function Je(o){return function(t){t.$meta={paramtypes:E.ƀej(t),viewInstances:new Map,entity:o.entity,type:"view"},st.registerView(t,o.entity);}}h(Je,"ViewDecorator");var mt=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.ƀdb=st.entityID,this.ƀeq().set(this.ƀdb,this);}destroy(){this.destroyed||(super.destroy(),this.ƀeq().delete(this.ƀdb));}update(t,e){}ƀeq(){return this.constructor.$meta.viewInstances}};var st=class o{static{h(this,"EntityViewsHelper");}static{this.ƀlm=new Map;}static registerView(t,e){o.ƀlm.has(e)||o.ƀlm.set(e,[]);let i=o.ƀlm.get(e);i&&i.push(t),B.getEntities(e).forEach(s=>{this.ƀcj(s,t);});}static ƀcj(t,e){try{let i=E.ƀiy(e.$meta.paramtypes.slice(1));o.entityID=t.id;let r=new e(t,...i);t.destroyed?r.destroy():t.ƀll.ƀln.push(r);}catch(i){console.error(i);}}constructor(t){this.ƀda=t,this.ƀln=[];}createViews(){if(!this.ƀda.destroyed){let t=o.ƀlm.get(this.ƀda.constructor);t&&t.forEach(e=>{o.ƀcj(this.ƀda,e);});}}updateViews(t,e){for(let i=0;i<this.ƀln.length;i++){let r=this.ƀln[i];r.destroyed||r.update(t,e);}}destroyViews(){this.ƀln.forEach(t=>{t.destroy();});}};I.onHardReset.subscribe(()=>{st.ƀlm=new Map;}).attachToRoot();function gt(){return function(o){o.$meta={type:"entity"},B.registerEntityClass(o);}}h(gt,"EntityDecorator");var z=class extends actionsLib.IDAttachable{static{h(this,"Entity");}static getInstanceByID(t){if(t)return B.getEntity(this,t)}static getInstanceByIDOrFail(t){let e=B.getEntity(this,t);if(!e)throw new Error(`Entity: entity is not found! Name: "${this.name}", id: "${t}"`);return e}static getEntities(){return B.getEntities(this)}constructor(){super(),this.ƀll=new st(this),B.registerEntity(this),g.sceneUpdateAction.subscribe(t=>{this.destroyed||(this.update(t.time,t.delta),this.ƀll.updateViews(t.time,t.delta));}).attach(this);}destroy(){this.destroyed||(this.ƀll.destroyViews(),B.unregisterEntity(this.constructor,this.id),super.destroy());}attach(t){return super.attach(t),this.ƀll.createViews(),this}attachByID(t){return super.attachByID(t),this.ƀll.createViews(),this}attachToRoot(){return super.attachToRoot(),this.ƀll.createViews(),this}update(t,e){}};var yt=class o extends z{static{h(this,"SingletonEntity");}static{this.ƀck=new WeakMap;}static ƀdv(t){let e=o.ƀck.get(t);return e||(e=new actionsLib.SingleAction,o.ƀck.set(t,e)),e}static ƀla(t){o.ƀck.delete(t);}static getInstanceAsync(){let t=B.getSingleton(this);return t&&!t.destroyed?actionsLib.SingleEvent.instant(t):o.ƀdv(this).toSingleEvent()}static continuesSubscription(){let t=h((e,i)=>{this.getInstanceAsync().tap(s=>{e({type:"open",value:s}),s.onDestroy().tap(()=>{e({type:"close",value:s}),t(e,i);}).attach(i);}).attach(i);},"subscribe");return actionsLib.Sequence.create((e,i)=>t(e,i.attachable))}static getInstance(){return B.getSingleton(this)}static getInstanceOrFail(){return B.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}"`);this.onDestroy().tap(()=>o.ƀla(this.constructor)).attachToRoot(),o.ƀdv(this.constructor).resolve(this);}};function Er(){return function(o){return o.$meta={paramtypes:E.ƀej(o),type:"scene"},o}}h(Er,"SceneDecorator");var ce=class o extends actionsLib.IDAttachable{static{h(this,"Scene");}static{this.ƀfu=new actionsLib.Variable(false);}static{this.isTransitioning=this.ƀfu.notifier;}static{this.ƀb=new actionsLib.Variable(void 0);}static{this.activeScene=this.ƀb.notifier;}static getActiveSceneOrFail(){if(!o.ƀb.value)throw new Error("Scene: getActiveSceneOrFail is called when there is no active scene!");return o.ƀb.value}static cancelActiveScene(){return o.ƀb.value?o.ƀb.value.ƀj():actionsLib.SingleEvent.instant()}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.ƀfu.value)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.ƀfu.value=true;let i=E.ƀiy(this.$meta.paramtypes),r=new this(...i).attachToRoot();return o.ƀb.set(r),r.init(e).map(()=>(o.ƀfu.value=false,r)).chainToRoot()}constructor(){super(),this.ƀhg=new actionsLib.SingleAction,this.onClose=this.ƀhg.notifier,g.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.ƀfu.value)throw new Error("Scene: you cannot close a scene while a scene is transitioning!");o.ƀfu.value=true;let e=t[0];return this.ƀj().map(()=>(this.ƀhg.resolve(e),e)).chainToRoot()}ƀj(){return this.prepareToClose().tap(()=>{super.destroy(),o.ƀb.set(void 0),o.ƀfu.value=false;}).chainToRoot()}destroy(){throw new Error('To close a scene use the "close()" function')}};I.onHardReset.subscribe(()=>{ce.ƀb.set(void 0);}).attachToRoot();var H=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 easeInCubic(t){return Math.pow(t,3)}static easeOutCubic(t){return 1-Math.pow(1-t,3)}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}static blink(t){return t>.5?1:0}},Rr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return H.lineer(t)}},Cr=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return H.easeIn(t)}},Ar=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return H.easeOut(t)}},Ir=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return H.easeInOut(t)}},Or=class{static{h(this,"AnimationEaseInCubic");}start(){}multiplierFunction(t){return H.easeInCubic(t)}},Dr=class{static{h(this,"AnimationEaseOutCubic");}start(){}multiplierFunction(t){return H.easeOutCubic(t)}},Mr=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return H.easeInOutCubic(t)}},Br=class{static{h(this,"AnimationBlink");}start(){}multiplierFunction(t){return H.blink(t)}},Ci=class{static{h(this,"AnimationFlicker");}start(){this.ƀkw=new Array(10).fill(0),helpersLib.Random.integerBetween(0,9),this.ƀkw[helpersLib.Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(helpersLib.Random.integerBetween(0,9),this.ƀkw[helpersLib.Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(helpersLib.Random.integerBetween(0,9),this.ƀkw[helpersLib.Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀkw[e]}},w=class{static{h(this,"Animations");}static{this.lineer=new Rr;}static{this.easeIn=new Cr;}static{this.easeOut=new Ar;}static{this.easeInOut=new Ir;}static{this.easeInCubic=new Or;}static{this.easeOutCubic=new Dr;}static{this.easeInOutCubic=new Mr;}static{this.blink=new Br;}};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 C=class o{static{h(this,"Animator");}static{this.ƀl=new WeakMap;}static ƀdo(t){let e=o.ƀl.get(t);return e||(e=new helpersLib.MapToWeakRefs,o.ƀl.set(t,e)),e}get animating(){return this.ƀhp!==void 0}get target(){return this.ƀkn}get value(){return this.ƀlf||(this.ƀlf=new actionsLib.Variable(this.ƀkn)),this.ƀlf.notifier}constructor(t,e,i){this.ƀfv=false,this.ƀjv=false,this.ƀkn=t,this.ƀhr={duration:200,animation:w.lineer,reAnimateHandling:exports.ReAnimateHandlingType.ThrowError,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState,...i},this.ƀm=helpersLib.Comparator.isArray(e)?e:[e],this.ƀgi(t,this.ƀm);}animate(t,e){let i={...this.ƀhr,...e},r=this.ƀhp;if(this.ƀhp)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().notIdle();case exports.ReAnimateHandlingType.CompletePrevious:this.ƀjm(i.completionHandling,this.ƀhp.ƀio,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return actionsLib.SingleEvent.create(n=>{this.ƀfv&&(this.ƀjv=true);let a=this.ƀm.reduce((c,p)=>(c[p]={ƀkh:this.ƀkn[p],ƀkp:t[p]},c),{}),l={ƀcv:i.duration,ƀcw:0,ƀio:a,ƀbi:i.completionHandling,ƀn:i.animation,ƀbh:n};if(l.ƀbi!==exports.AnimationsCompletionHandlingType.Loop&&this.ƀfr(l)){this.ƀhp=void 0,n(),r?.ƀbh(),this.ƀhp||(this.ƀlc?.destroy(),this.ƀlc=void 0);return}else l.ƀn.start();return this.ƀhp=l,this.ƀcz(),r?.ƀbh(),()=>{this.ƀhp===l&&(this.ƀkn instanceof actionsLib.Attachable&&this.ƀkn.destroyed||this.ƀjm(l.ƀbi,l.ƀio,true),this.ƀhp=void 0,this.ƀlc?.destroy(),this.ƀlc=void 0);}}).notIdle()}set(t){let e=false;for(let i=0;i<this.ƀm.length;i++){let r=this.ƀm[i];this.ƀkn[r]!==t[r]&&(e=true,this.ƀkn[r]=t[r]);}e&&this.ƀlf?.set(this.ƀkn),this.ƀhp?.ƀbh();}completeAnimation(t){if(this.ƀhp){t=t??this.ƀhp.ƀbi,this.ƀjm(t,this.ƀhp.ƀio,true);let e=this.ƀhp.ƀbh;this.ƀhp=void 0,e();}}ƀcz(){this.ƀlc||(this.ƀlc=g.beforeSceneUpdateAction.subscribe(t=>{this.ƀfv=true;try{let e=this.ƀhp;if(!e)return;e.ƀcw+=t.delta;let i=e.ƀcw>=e.ƀcv;if(i)if(e.ƀbi===exports.AnimationsCompletionHandlingType.Loop)e.ƀcw%=e.ƀcv,e.ƀn.start(),i=!1;else {this.ƀjm(e.ƀbi,e.ƀio,!1),this.ƀhp=void 0,e.ƀbh(),this.ƀhp||(this.ƀlc?.destroy(),this.ƀlc=void 0);return}if(!i){let r=e.ƀn.multiplierFunction(e.ƀcw/e.ƀcv),s=!1;for(let n=0;n<this.ƀm.length;n++){let a=this.ƀm[n],l=e.ƀio[a],p=(l.ƀkp-l.ƀkh)*r+l.ƀkh;p!==this.ƀkn[a]&&(s=!0,this.ƀkn[a]=p);}s&&this.ƀlf?.set(this.ƀkn);}}finally{this.ƀfv=false,this.ƀjv&&(this.ƀjv=false,this.ƀlc?.destroy(),this.ƀlc=void 0,this.ƀcz());}}).attachToRoot());}ƀfr(t){for(let e=0;e<this.ƀm.length;e++){let i=this.ƀm[e];if(this.ƀkn[i]!==t.ƀio[i].ƀkp)return false}return true}ƀjm(t,e,i){switch(t){case exports.AnimationsCompletionHandlingType.ReturnToOriginal:this.ƀja(e);break;case exports.AnimationsCompletionHandlingType.StayInCurrentState:i||this.ƀfy(e);break;case exports.AnimationsCompletionHandlingType.JumpToEnd:this.ƀfy(e);break;case exports.AnimationsCompletionHandlingType.Loop:this.ƀja(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀja(t){let e=false;for(let i=0;i<this.ƀm.length;i++){let r=this.ƀm[i];this.ƀkn[r]!==t[r].ƀkh&&(e=true,this.ƀkn[r]=t[r].ƀkh);}e&&this.ƀlf?.set(this.ƀkn);}ƀfy(t){let e=false;for(let i=0;i<this.ƀm.length;i++){let r=this.ƀm[i];this.ƀkn[r]!==t[r].ƀkp&&(e=true,this.ƀkn[r]=t[r].ƀkp);}e&&this.ƀlf?.set(this.ƀkn);}ƀgi(t,e){let i=o.ƀdo(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",o.Wheel="wheel";})(exports.ContainerEventType||(exports.ContainerEventType={}));exports.Cursor=void 0;(function(o){o.Default="default",o.Pointer="pointer";})(exports.Cursor||(exports.Cursor={}));var de=class extends actionsLib.IDAttachable{static{h(this,"ContainerAttributes");}constructor(){super(),this.ƀgv=false,this.ƀdg=false,this.ƀjb=1,this.ƀw=1,this.ƀii=new j__namespace.Container;}get size(){return this.getSize()}set size(t){this.setSize(t);}getSize(){return new helpersLib.Vector(this.ƀii.width,this.ƀii.height)}setSize(t){return this.ƀii.width=t.x,this.ƀii.height=t.y,this}setPosition(t,e){if(e?.holdFrom){let i=this.ƀii.getLocalBounds(),r=new helpersLib.Vector(this.ƀii.scale.x,this.ƀii.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.ƀii.x,this.ƀii.y)}set position(t){this.ƀii.position=t;}get x(){return this.ƀii.x}set x(t){this.ƀii.x=t;}get y(){return this.ƀii.y}set y(t){this.ƀii.y=t;}on(t){return actionsLib.Sequence.create(e=>{let i=h(r=>{if(t===exports.ContainerEventType.Wheel){let n=r.deltaY;e({deltaY:n});}else e(void 0);},"handle");return this.ƀii.on(t,i),()=>this.ƀii.off(t,i)}).notIdle()}setRotation(t){return this.rotation=t,this}get rotation(){return new helpersLib.Radian(this.ƀii.rotation)}set rotation(t){this.ƀii.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.ƀii.zIndex}set zIndex(t){this.ƀii.zIndex=t;}setSkewX(t){return this.skewX=t,this}get skewX(){return new helpersLib.Radian(this.ƀii.skew.x)}set skewX(t){this.ƀii.skew.x=t.value;}setSkewY(t){return this.skewY=t,this}get skewY(){return new helpersLib.Radian(this.ƀii.skew.y)}set skewY(t){this.ƀii.skew.y=t.value;}setSortableChildren(t){return this.sortableChildren=t,this}get sortableChildren(){return this.ƀii.sortableChildren}set sortableChildren(t){this.ƀii.sortableChildren=t;}setAlpha(t){return this.ƀii.alpha=t,this}get alpha(){return this.ƀii.alpha}set alpha(t){this.ƀii.alpha=t;}setInteractive(t){return this.interactive=t,this}get interactive(){return this.ƀii.interactive}set interactive(t){t?this.ƀii.eventMode="dynamic":this.ƀii.eventMode="none";}setCursor(t){return this.cursor=t,this}get cursor(){return this.ƀii.cursor}set cursor(t){this.ƀii.cursor=t;}getMask(){throw new Error("ContainerAttributes: mask is not available!")}setMask(t){return t?(this.ƀii.addChild(t.ƀii),this.ƀii.mask=t.getMask(),this.ƀgl=t):(this.ƀgl&&this.ƀii.removeChild(this.ƀgl.ƀii),this.ƀii.mask=null),this}hitTest(t){if(this.ƀii.parent)if(this.ƀii.hitArea){let e=this.ƀii.toLocal(t);return this.ƀii.hitArea.contains(e.x,e.y)}else return this.ƀii.getBounds().contains(t.x,t.y);else return false}get boundingBox(){let t=this.ƀii.getLocalBounds();return new helpersLib.Rectangle(new helpersLib.Vector(t.x,t.y),new helpersLib.Vector(t.x+t.width,t.y+t.height))}ignoreBounds(t=true){return t?(this.ƀhs||(this.ƀhs=this.ƀii.calculateBounds),this.ƀii.calculateBounds=()=>this.ƀii._bounds.clear()):this.ƀhs&&(this.ƀii.calculateBounds=this.ƀhs),this}setMirror(t=false){return this.mirror=t,this}get mirror(){return this.ƀgv}set mirror(t){this.ƀgv=t,this.ƀle();}setFlip(t=false){return this.flip=t,this}get flip(){return this.ƀdg}set flip(t){this.ƀdg=t,this.ƀle();}setScale(t){return this.scale=t,this}get scale(){return this.ƀjb}set scale(t){this.ƀjb=t,this.ƀle();}setAspectRatio(t){return this.aspectRatio=t,this}get aspectRatio(){return this.ƀw}set aspectRatio(t){this.ƀw=t,this.ƀle();}ƀle(){this.ƀii.scale.set(this.ƀjb,this.ƀjb),this.ƀw<1?this.ƀii.scale.x*=this.ƀw:this.ƀw>1&&(this.ƀii.scale.y/=this.ƀw),this.ƀgv&&(this.ƀii.scale.x*=-1),this.ƀdg&&(this.ƀii.scale.y*=-1);}};var G=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 ue=class{static{h(this,"GaussianValuesHelper");}static ƀdm(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.ƀbt(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.ƀdm(r,t*.4)),i=e.reduce((r,s)=>r+s,0);return i=i*2-e[0],e=e.map(r=>r/i),this.ƀbt(e)}}static ƀbt(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 Oi=class Xe extends j__namespace.Filter{static{h(this,"BlurFilterPass");}static ƀep(){return `
2
2
  attribute vec2 aVertexPosition;
3
3
  attribute vec2 aTextureCoord;
4
4
 
@@ -10,7 +10,7 @@
10
10
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
11
11
  vTextureCoord = aTextureCoord;
12
12
  }
13
- `}static ƀds(t,e){let i=`
13
+ `}static ƀdx(t,e){let i=`
14
14
  uniform sampler2D uSampler;
15
15
 
16
16
  varying vec2 vTextureCoord;
@@ -29,7 +29,7 @@
29
29
  iterate(${s}, ${helpersLib.NumberHelper.toFloatString(t[r].multiplier)}, gl_FragColor);
30
30
  iterate(${s} * -1.0, ${helpersLib.NumberHelper.toFloatString(t[r].multiplier)}, gl_FragColor);`;}return i+=`
31
31
  }
32
- `,i}constructor(t,e){super(Ke.ƀek(),Ke.ƀds(de.getValuesForLinearSamplingGauss(t),e)),this.ƀey=e,this.resolution=O;}apply(t,e,i,r){this.uniforms.pixelSize=this.ƀey?1/(e.width*O):1/(e.height*O),t.applyFilter(this,e,i,r);}},Et=class extends L__namespace.Filter{static{h(this,"BlurFilter");}constructor(t=new helpersLib.Vector(2,2)){if(super(),this.ƀjt=t,this.resolution=O,this.ƀjt=t.multiplyNumber(O).floor(),this.ƀjt.x<0||this.ƀjt.y<0)throw new Error("BlurFilterLinearSampling: Strength * Resolution must be greater than 0");if(this.ƀjt.x>100||this.ƀjt.y>100)throw new Error("BlurFilterLinearSampling: Strength * Resolution cannot be higher than 100");this.ƀfa=new Ci(this.ƀjt.x,true),this.ƀkr=new Ci(this.ƀjt.y,false),this.padding=Math.max(this.ƀjt.x,this.ƀjt.y);}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀkr.apply(t,e,s,L__namespace.CLEAR_MODES.CLEAR),this.ƀfa.apply(t,s,i,r),t.returnFilterTexture(s);}get blendMode(){return this.ƀfa.blendMode}set blendMode(t){this.ƀfa.blendMode=t,this.ƀkr.blendMode=t;}};var ue=class{static{h(this,"Filters");}get red(){return this.ƀie}set red(t){this.ƀie=t,this.ƀif();}get green(){return this.ƀeo}set green(t){this.ƀeo=t,this.ƀif();}get blue(){return this.ƀae}set blue(t){this.ƀae=t,this.ƀif();}get brightness(){return this.ƀaj}set brightness(t){this.ƀaj=t,this.ƀif();}get contrast(){return this.ƀbk}set contrast(t){this.ƀbk=t,this.ƀif();}get blur(){return this.ƀaf}set blur(t){let e=helpersLib.Comparator.isNumber(t)?new helpersLib.Vector(t,t):t;(this.ƀaf&&e&&!this.ƀaf.isEqual(e)||this.ƀaf&&!e||!this.ƀaf&&e)&&(this.ƀaf=e,this.ƀag&&(this.ƀag.destroy(),this.ƀag=void 0),e&&(this.ƀag=new Et(e),this.ƀgx()));}constructor(t){this.ƀbg=t,this.ƀie=1,this.ƀeo=1,this.ƀae=1,this.ƀaj=1,this.ƀbk=1,this.ƀgx();}removeColorFilter(){this.ƀaz?.destroy(),this.ƀaz=void 0,this.ƀgx();}ƀif(){this.ƀie===1&&this.ƀeo===1&&this.ƀae===1&&this.ƀaj===1&&this.ƀbk===1?this.ƀaz&&(this.ƀaz.destroy(),this.ƀaz=void 0,this.ƀgx()):(this.ƀaz||(this.ƀaz=new L__namespace.ColorMatrixFilter,this.ƀaz.resolution=O,this.ƀgx()),this.ƀaz.matrix=[this.ƀie*this.ƀbk,0,0,0,this.ƀaj-1,0,this.ƀeo*this.ƀbk,0,0,this.ƀaj-1,0,0,this.ƀae*this.ƀbk,0,this.ƀaj-1,0,0,0,1,0]);}ƀgx(){let t=[];this.ƀag&&t.push(this.ƀag),this.ƀaz&&t.push(this.ƀaz),this.ƀbg.filters=t;}};var f=class o extends pe{static{h(this,"Container");}static{this.allContainers=new Map;}constructor(){super(),this.addChildTo=this,this.defaultChildOptions={addUnder:false,cropOverflowingParts:false},o.allContainers.set(this.id,this),this.filters=new ue(this.ƀhv);}destroy(){this.destroyed||(super.destroy(),o.allContainers.delete(this.id),!this.ƀhv.destroyed&&this.ƀhv.destroy());}getBoundingMask(){if(this.addChildTo!==this)return this.addChildTo.getBoundingMask();throw new Error(`Container: bounding mask cannot be used without bounding shapes. Display Object: "${this.id}"!`)}displayParent(t,e){let i;if(helpersLib.Comparator.isNumber(t)){if(i=o.allContainers.get(t),!i)throw new Error(`Container: parent not found! id: ${t}`)}else i=t;let r={addUnder:i.defaultChildOptions.addUnder,cropOverflowingParts:i.defaultChildOptions.cropOverflowingParts,...e};if(r.addUnder?i.addChildTo.ƀhv.addChildAt(this.ƀhv,0):i.addChildTo.ƀhv.addChild(this.ƀhv),r.cropOverflowingParts)if(i)this.ƀhv.mask=i.getBoundingMask().pixiSprite;else throw new Error("Container: cropOverflowingParts can only be used with Container parent!");return this}};var M=class{static{h(this,"GameAssets");}static{this.ƀim=new Map;}static{this.ƀp=0;}static getAsset(t){let e=this.ƀim.get(t);if(e)return e;throw new Error(`Game Assets: Resource not found! Key: "${t}"`)}static insertAsset(t,e){return e||(e=`a-${this.ƀp++}`),this.ƀim.set(e,t),e}static destroyAsset(t){let e=this.ƀim.get(t);e&&(e.destroy(true),this.ƀim.delete(t));}static async loadGameAssets(t){let e=new Map,i=[];t.forEach(s=>{if(!helpersLib.Comparator.isString(s.url))throw new Error(`GameAssets: source url should be a string: ${s.url}`);let n=e.get(s.url);n?n.push(s.id):(e.set(s.url,[s.id]),i.push({url:s.url,callback:h(a=>{if(a instanceof L__namespace.Texture&&(a.id=s.id),n=e.get(s.url),n)n.forEach(l=>{this.ƀim.set(l,a);});else throw new Error(`GameAssets: unexpected error, nameGroup is not found! "./"! ${s}`)},"callback")}));});let r=performance.now();return Promise.all(i.map(s=>L__namespace.Assets.load(s.url))).then(s=>{let n=performance.now();console.info("Asset load completed in: ",Math.round(n-r)/1e3," seconds"),s.forEach((a,l)=>{i[l].callback(a);});}).catch(s=>{throw new Error(`GameAssets: during asset loading, an error occured: ${s}`)})}};var Ut=class{static{h(this,"PositionConversionHelper");}static includeScaleInScreenPosition(t,e,i){if(e!==1){let r=helpersLib.Vector.fromTo(i,t).multiplyNumber(1/e);return i.add(r)}else return t}static normalizePolygonByAnchor(t,e,i){let r=new helpersLib.Vector(e.x*i.x,e.y*i.y);return t.map(s=>s.map(n=>r.to(helpersLib.Vector.fromVec2(n))))}},ge=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀjg=t.map(r=>new L__namespace.Polygon(r.map(s=>new L__namespace.Point(s.x,s.y))));}contains(t,e){return this.ƀjg.some(i=>i.contains(t,e))}};var Ai;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})(Ai||(Ai={}));exports.FocusingAnimation=void 0;(function(o){o[o.Instant=1]="Instant",o[o.EaseInOut=2]="EaseInOut",o[o.EaseOut=3]="EaseOut";})(exports.FocusingAnimation||(exports.FocusingAnimation={}));var Br=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},gt=new $;exports.CameraGateway=class Rt{static{h(this,"CameraGateway");}createCamera(){return gt.trigger("createCamera")}update(t,e){return gt.trigger("update",t,e)}setPosition(t){return gt.trigger("setPosition",t)}setTransition(t){return gt.trigger("setTransition",t)}getCameraPosition(){return gt.trigger("getCameraPosition")}};exports.CameraGateway=Br([d()],exports.CameraGateway);var Gr=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},we=new $,$t=class{static{h(this,"CameraViewGateway");}getLayers(){return we.trigger("getLayers")}appear(t,e){return we.trigger("appear",t,e)}};$t=Gr([d()],$t);var z=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}static blink(t){return t>.5?1:0}},Fr=class{static{h(this,"AnimationLineer");}start(){}multiplierFunction(t){return z.lineer(t)}},_r=class{static{h(this,"AnimationEaseIn");}start(){}multiplierFunction(t){return z.easeIn(t)}},Vr=class{static{h(this,"AnimationEaseOut");}start(){}multiplierFunction(t){return z.easeOut(t)}},Lr=class{static{h(this,"AnimationEaseInOut");}start(){}multiplierFunction(t){return z.easeInOut(t)}},Nr=class{static{h(this,"AnimationEaseInOutCubic");}start(){}multiplierFunction(t){return z.easeInOutCubic(t)}},jr=class{static{h(this,"AnimationBlink");}start(){}multiplierFunction(t){return z.blink(t)}},Oi=class{static{h(this,"AnimationFlicker");}start(){this.ƀke=new Array(10).fill(0),helpersLib.Random.integerBetween(0,9),this.ƀke[helpersLib.Random.integerBetween(0,9)]=Math.random(),Math.random()<.3&&(helpersLib.Random.integerBetween(0,9),this.ƀke[helpersLib.Random.integerBetween(0,9)]=Math.random()),Math.random()<.2&&(helpersLib.Random.integerBetween(0,9),this.ƀke[helpersLib.Random.integerBetween(0,9)]=Math.random());}multiplierFunction(t){let e=Math.floor(t*10);return this.ƀke[e]}},P=class{static{h(this,"Animations");}static{this.lineer=new Fr;}static{this.easeIn=new _r;}static{this.easeOut=new Vr;}static{this.easeInOut=new Lr;}static{this.easeInOutCubic=new Nr;}static{this.blink=new jr;}};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 D=class o{static{h(this,"Animator");}static{this.ƀk=new WeakMap;}static ƀdk(t){let e=o.ƀk.get(t);return e||(e=new helpersLib.MapToWeakRefs,o.ƀk.set(t,e)),e}get animating(){return this.ƀhc!==void 0}get target(){return this.ƀjv}get value(){return this.ƀkn||(this.ƀkn=new actionsLib.Variable(this.ƀjv)),this.ƀkn.notifier}constructor(t,e,i){this.ƀfq=false,this.ƀjh=false,this.ƀjv=t,this.ƀhe={duration:200,animation:P.lineer,reAnimateHandling:exports.ReAnimateHandlingType.ThrowError,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState,...i},this.ƀl=helpersLib.Comparator.isArray(e)?e:[e],this.ƀgd(t,this.ƀl);}animate(t,e){let i={...this.ƀhe,...e},r=this.ƀhc;if(this.ƀhc)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().notIdle();case exports.ReAnimateHandlingType.CompletePrevious:this.ƀja(i.completionHandling,this.ƀhc.ƀia,true);break;default:{throw new Error(`Animator: unknown re-animate handling type: "${i.reAnimateHandling}"`)}}return actionsLib.SingleEvent.create(n=>{this.ƀfq&&(this.ƀjh=true);let a=this.ƀl.reduce((c,p)=>(c[p]={ƀjp:this.ƀjv[p],ƀjx:t[p]},c),{}),l={ƀcs:i.duration,ƀct:0,ƀia:a,ƀbe:i.completionHandling,ƀm:i.animation,ƀbd:n};if(l.ƀbe!==exports.AnimationsCompletionHandlingType.Loop&&this.ƀfm(l)){this.ƀhc=void 0,n(),r?.ƀbd(),this.ƀhc||(this.ƀkk?.destroy(),this.ƀkk=void 0);return}else l.ƀm.start();return this.ƀhc=l,this.ƀcw(),r?.ƀbd(),()=>{this.ƀhc===l&&(this.ƀjv instanceof actionsLib.Attachable&&this.ƀjv.destroyed||this.ƀja(l.ƀbe,l.ƀia,true),this.ƀhc=void 0,this.ƀkk?.destroy(),this.ƀkk=void 0);}}).notIdle()}set(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjv[r]!==t[r]&&(e=true,this.ƀjv[r]=t[r]);}e&&this.ƀkn?.set(this.ƀjv),this.ƀhc?.ƀbd();}completeAnimation(t){if(this.ƀhc){t=t??this.ƀhc.ƀbe,this.ƀja(t,this.ƀhc.ƀia,true);let e=this.ƀhc.ƀbd;this.ƀhc=void 0,e();}}ƀcw(){this.ƀkk||(this.ƀkk=y.beforeSceneUpdateAction.subscribe(t=>{this.ƀfq=true;try{let e=this.ƀhc;if(!e)return;e.ƀct+=t.delta;let i=e.ƀct>=e.ƀcs;if(i)if(e.ƀbe===exports.AnimationsCompletionHandlingType.Loop)e.ƀct%=e.ƀcs,e.ƀm.start(),i=!1;else {this.ƀja(e.ƀbe,e.ƀia,!1),this.ƀhc=void 0,e.ƀbd(),this.ƀhc||(this.ƀkk?.destroy(),this.ƀkk=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.ƀia[a],p=(l.ƀjx-l.ƀjp)*r+l.ƀjp;p!==this.ƀjv[a]&&(s=!0,this.ƀjv[a]=p);}s&&this.ƀkn?.set(this.ƀjv);}}finally{this.ƀfq=false,this.ƀjh&&(this.ƀjh=false,this.ƀkk?.destroy(),this.ƀkk=void 0,this.ƀcw());}}).attachToRoot());}ƀfm(t){for(let e=0;e<this.ƀl.length;e++){let i=this.ƀl[e];if(this.ƀjv[i]!==t.ƀia[i].ƀjx)return false}return true}ƀja(t,e,i){switch(t){case exports.AnimationsCompletionHandlingType.ReturnToOriginal:this.ƀin(e);break;case exports.AnimationsCompletionHandlingType.StayInCurrentState:i||this.ƀft(e);break;case exports.AnimationsCompletionHandlingType.JumpToEnd:this.ƀft(e);break;case exports.AnimationsCompletionHandlingType.Loop:this.ƀin(e);break;default:{throw new Error(`Animator: unknown completion handling type: "${t}"`)}}}ƀin(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjv[r]!==t[r].ƀjp&&(e=true,this.ƀjv[r]=t[r].ƀjp);}e&&this.ƀkn?.set(this.ƀjv);}ƀft(t){let e=false;for(let i=0;i<this.ƀl.length;i++){let r=this.ƀl[i];this.ƀjv[r]!==t[r].ƀjx&&(e=true,this.ƀjv[r]=t[r].ƀjx);}e&&this.ƀkn?.set(this.ƀjv);}ƀgd(t,e){let i=o.ƀdk(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 I;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(I||(I={}));var xe=class extends actionsLib.Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀjq,nextState:this.ƀgr,queuedState:this.ƀib,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=I.Idle,this.ƀgz=new actionsLib.Action,this.ƀhb=new actionsLib.Action,this.ƀhe={duration:500,animation:P.lineer,...t},this.ƀo=new D(this.ƀj,"value",{duration:this.ƀhe.duration,animation:this.ƀhe.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀhb.trigger(this.ƀj.value);}).attach(this);}setState(t,e){if(this.ƀjq===void 0)this.ƀjq=t,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr}),this.ƀhb.trigger(this.ƀj.value);else if(e?.instant)this.ƀo.completeAnimation(),this.ƀn=I.Idle,this.ƀjq=t,this.ƀgr=void 0,this.ƀj.value=0,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr}),this.ƀhb.trigger(this.ƀj.value);else switch(this.ƀn){case I.Idle:t!==this.ƀjq&&(this.ƀn=I.Transitioning,this.ƀgr=t,this.ƀj.value=0,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr}),this.ƀhb.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgv()).attach(this));break;case I.Transitioning:t!==this.ƀgr&&(t===this.ƀjq?(this.ƀn=I.Reverting,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhe.duration}).tap(()=>this.ƀgv()).attach(this)):this.ƀib=t);break;case I.Reverting:t!==this.ƀjq&&(t===this.ƀgr?(this.ƀn=I.Transitioning,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhe.duration}).tap(()=>this.ƀgv()).attach(this)):this.ƀib=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgv(){switch(this.ƀn){case I.Transitioning:this.ƀj.value===1&&(this.ƀj.value=0,this.ƀib!==void 0?(this.ƀn=I.Transitioning,this.ƀjq=this.ƀgr,this.ƀgr=this.ƀib,this.ƀib=void 0,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr}),this.ƀo.animate({value:1}).tap(()=>this.ƀgv()).attach(this)):(this.ƀn=I.Idle,this.ƀjq=this.ƀgr,this.ƀgr=void 0,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr})),this.ƀhb.trigger(this.ƀj.value));break;case I.Reverting:if(this.ƀjq===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀj.value===0&&(this.ƀib!==void 0?(this.ƀn=I.Transitioning,this.ƀgr=this.ƀib,this.ƀib=void 0,this.ƀj.value=0,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr}),this.ƀo.animate({value:1}).tap(()=>this.ƀgv()).attach(this)):(this.ƀn=I.Idle,this.ƀgr=void 0,this.ƀj.value=0,this.ƀgz.trigger({state:this.ƀjq,nextState:this.ƀgr})),this.ƀhb.trigger(this.ƀj.value));break;case I.Idle:break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgz.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀhb.subscribe(e=>t(e)).attach(this),this}};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 ve=class extends actionsLib.Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀj.value,state:this.ƀjq,queuedState:this.ƀib,animationState:this.ƀn}}constructor(t){super(),this.ƀj={value:0},this.ƀn=x.Hidden,this.ƀgz=new actionsLib.Action,this.ƀhb=new actionsLib.Action,this.ƀhe={duration:500,animation:P.lineer,...t},this.ƀj.value=0,this.ƀo=new D(this.ƀj,"value",{duration:this.ƀhe.duration,animation:this.ƀhe.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀo.value.subscribe(()=>{this.ƀj.value!==1&&this.ƀj.value!==0&&this.ƀhb.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.ƀib=void 0;let i=t!==void 0?1:0,r=this.ƀjq!==t;r&&(this.ƀjq=t,this.ƀgz.trigger(this.ƀjq)),(r||this.ƀj.value!==i)&&(this.ƀj.value=i,this.ƀhb.trigger(this.ƀj.value));}else switch(this.ƀn){case x.Hidden:t!==void 0&&(this.ƀn=x.Appearing,this.ƀib=void 0,this.ƀjq=t,this.ƀgz.trigger(this.ƀjq),this.ƀo.animate({value:1}).tap(()=>this.ƀgv()).attach(this));break;case x.Visible:t===void 0?(this.ƀn=x.Disappearing,this.ƀib=void 0,this.ƀo.animate({value:0}).tap(()=>this.ƀgv()).attach(this)):t!==this.ƀjq&&(this.ƀn=x.DisappearToChange,this.ƀib=t,this.ƀo.animate({value:0}).tap(()=>this.ƀgv()).attach(this));break;case x.Appearing:t===void 0?(this.ƀn=x.Disappearing,this.ƀib=void 0,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhe.duration}).tap(()=>this.ƀgv()).attach(this)):t!==this.ƀjq&&(this.ƀj.value>0?(this.ƀn=x.DisappearToChange,this.ƀib=t,this.ƀo.animate({value:0},{duration:this.ƀj.value*this.ƀhe.duration}).tap(()=>this.ƀgv()).attach(this)):(this.ƀib=void 0,this.ƀjq=t,this.ƀgz.trigger(this.ƀjq)));break;case x.Disappearing:t===this.ƀjq?(this.ƀn=x.Appearing,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhe.duration}).tap(()=>this.ƀgv()).attach(this)):t!==void 0&&(this.ƀn=x.DisappearToChange,this.ƀib=t);break;case x.DisappearToChange:t===void 0?(this.ƀn=x.Disappearing,this.ƀib=void 0):t===this.ƀjq?(this.ƀn=x.Appearing,this.ƀib=void 0,this.ƀo.animate({value:1},{duration:(1-this.ƀj.value)*this.ƀhe.duration}).tap(()=>this.ƀgv()).attach(this)):t!==this.ƀib&&(this.ƀib=t);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀgv(){switch(this.ƀn){case x.Appearing:this.ƀj.value===1&&(this.ƀn=x.Visible,this.ƀhb.trigger(this.ƀj.value));break;case x.Disappearing:if(this.ƀib!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀj.value===0&&(this.ƀn=x.Hidden,this.ƀjq=void 0,this.ƀgz.trigger(this.ƀjq),this.ƀhb.trigger(this.ƀj.value));break;case x.DisappearToChange:if(this.ƀib===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀj.value===0&&(this.ƀn=x.Appearing,this.ƀjq=this.ƀib,this.ƀib=void 0,this.ƀgz.trigger(this.ƀjq),this.ƀhb.trigger(this.ƀj.value),this.ƀo.animate({value:1}).tap(()=>this.ƀgv()).attach(this));break;case x.Hidden:case x.Visible:return;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}onStateChange(t){return this.ƀgz.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀhb.subscribe(e=>t(e)).attach(this),this}};var Gi=class extends f{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbu=t;let i={duration:200,animation:P.easeInOut,...e};this.alpha=0,this.ƀjr=new ve(i).onStateChange(r=>{this.ƀbh?.destroy(),this.ƀbh=void 0,r!==void 0&&(this.ƀbh=new f().displayParent(this).attach(this),this.ƀbu({state:r,container:this.ƀbh}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀjr.setState(t,e),this}};var Pe=class o extends L__namespace.Filter{static{h(this,"ExpandWithColorFilter");}static ƀek(){return `
32
+ `,i}constructor(t,e){super(Xe.ƀep(),Xe.ƀdx(ue.getValuesForLinearSamplingGauss(t),e)),this.ƀfd=e,this.resolution=G;}apply(t,e,i,r){this.uniforms.pixelSize=this.ƀfd?1/(e.width*G):1/(e.height*G),t.applyFilter(this,e,i,r);}},Ot=class extends j__namespace.Filter{static{h(this,"BlurFilter");}constructor(t=new helpersLib.Vector(2,2)){if(super(),this.ƀkl=t,this.resolution=G,this.ƀkl=t.multiplyNumber(G).floor(),this.ƀkl.x<0||this.ƀkl.y<0)throw new Error("BlurFilterLinearSampling: Strength * Resolution must be greater than 0");if(this.ƀkl.x>100||this.ƀkl.y>100)throw new Error("BlurFilterLinearSampling: Strength * Resolution cannot be higher than 100");this.ƀff=new Oi(this.ƀkl.x,true),this.ƀlj=new Oi(this.ƀkl.y,false),this.padding=Math.max(this.ƀkl.x,this.ƀkl.y);}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀlj.apply(t,e,s,j__namespace.CLEAR_MODES.CLEAR),this.ƀff.apply(t,s,i,r),t.returnFilterTexture(s);}get blendMode(){return this.ƀff.blendMode}set blendMode(t){this.ƀff.blendMode=t,this.ƀlj.blendMode=t;}};var me=class{static{h(this,"Filters");}get red(){return this.ƀis}set red(t){this.ƀis=t,this.ƀit();}get green(){return this.ƀet}set green(t){this.ƀet=t,this.ƀit();}get blue(){return this.ƀag}set blue(t){this.ƀag=t,this.ƀit();}get brightness(){return this.ƀal}set brightness(t){this.ƀal=t,this.ƀit();}get contrast(){return this.ƀbo}set contrast(t){this.ƀbo=t,this.ƀit();}get blur(){return this.ƀah}set blur(t){let e=helpersLib.Comparator.isNumber(t)?new helpersLib.Vector(t,t):t;(this.ƀah&&e&&!this.ƀah.isEqual(e)||this.ƀah&&!e||!this.ƀah&&e)&&(this.ƀah=e,this.ƀai&&(this.ƀai.destroy(),this.ƀai=void 0),e&&(this.ƀai=new Ot(e),this.ƀhk()));}constructor(t){this.ƀbk=t,this.ƀis=1,this.ƀet=1,this.ƀag=1,this.ƀal=1,this.ƀbo=1,this.ƀhk();}removeColorFilter(){this.ƀbd?.destroy(),this.ƀbd=void 0,this.ƀhk();}ƀit(){this.ƀis===1&&this.ƀet===1&&this.ƀag===1&&this.ƀal===1&&this.ƀbo===1?this.ƀbd&&(this.ƀbd.destroy(),this.ƀbd=void 0,this.ƀhk()):(this.ƀbd||(this.ƀbd=new j__namespace.ColorMatrixFilter,this.ƀbd.resolution=G,this.ƀhk()),this.ƀbd.matrix=[this.ƀis*this.ƀbo,0,0,0,this.ƀal-1,0,this.ƀet*this.ƀbo,0,0,this.ƀal-1,0,0,this.ƀag*this.ƀbo,0,this.ƀal-1,0,0,0,1,0]);}ƀhk(){let t=[];this.ƀai&&t.push(this.ƀai),this.ƀbd&&t.push(this.ƀbd),this.ƀbk.filters=t;}};var u=class o extends de{static{h(this,"Container");}static{this.allContainers=new Map;}constructor(){super(),this.addChildTo=this,this.defaultChildOptions={addUnder:false,cropOverflowingParts:false},o.allContainers.set(this.id,this),this.filters=new me(this.ƀii);}destroy(){this.destroyed||(super.destroy(),o.allContainers.delete(this.id),!this.ƀii.destroyed&&this.ƀii.destroy());}getBoundingMask(){if(this.addChildTo!==this)return this.addChildTo.getBoundingMask();throw new Error(`Container: bounding mask cannot be used without bounding shapes. Display Object: "${this.id}"!`)}displayParent(t,e){let i;if(helpersLib.Comparator.isNumber(t)){if(i=o.allContainers.get(t),!i)throw new Error(`Container: parent not found! id: ${t}`)}else i=t;let r={addUnder:i.defaultChildOptions.addUnder,cropOverflowingParts:i.defaultChildOptions.cropOverflowingParts,...e};if(r.addUnder?i.addChildTo.ƀii.addChildAt(this.ƀii,0):i.addChildTo.ƀii.addChild(this.ƀii),r.cropOverflowingParts)if(i)this.ƀii.mask=i.getBoundingMask().pixiSprite;else throw new Error("Container: cropOverflowingParts can only be used with Container parent!");return this}};var M;(function(o){o[o.Idle=1]="Idle",o[o.Transitioning=2]="Transitioning",o[o.Reverting=3]="Reverting";})(M||(M={}));var ge=class extends actionsLib.Attachable{static{h(this,"StateAnimation");}get currentState(){return {value:this.ƀk.value,state:this.ƀki,nextState:this.ƀhe,queuedState:this.ƀip,animationState:this.ƀo}}constructor(t){super(),this.ƀk={value:0},this.ƀo=M.Idle,this.ƀhm=new actionsLib.Action,this.ƀho=new actionsLib.Action,this.ƀhr={duration:500,animation:w.lineer,...t},this.ƀp=new C(this.ƀk,"value",{duration:this.ƀhr.duration,animation:this.ƀhr.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀp.value.subscribe(()=>{this.ƀk.value!==1&&this.ƀk.value!==0&&this.ƀho.trigger(this.ƀk.value);}).attach(this);}setState(t,e){if(this.ƀki===void 0)this.ƀki=t,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe}),this.ƀho.trigger(this.ƀk.value);else if(e?.instant)this.ƀp.completeAnimation(),this.ƀo=M.Idle,this.ƀki=t,this.ƀhe=void 0,this.ƀk.value=0,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe}),this.ƀho.trigger(this.ƀk.value);else switch(this.ƀo){case M.Idle:t!==this.ƀki&&(this.ƀo=M.Transitioning,this.ƀhe=t,this.ƀk.value=0,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe}),this.ƀho.trigger(this.ƀk.value),this.ƀp.animate({value:1}).tap(()=>this.ƀhi()).attach(this));break;case M.Transitioning:t!==this.ƀhe&&(t===this.ƀki?(this.ƀo=M.Reverting,this.ƀp.animate({value:0},{duration:this.ƀk.value*this.ƀhr.duration}).tap(()=>this.ƀhi()).attach(this)):this.ƀip=t);break;case M.Reverting:t!==this.ƀki&&(t===this.ƀhe?(this.ƀo=M.Transitioning,this.ƀp.animate({value:1},{duration:(1-this.ƀk.value)*this.ƀhr.duration}).tap(()=>this.ƀhi()).attach(this)):this.ƀip=t);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀhi(){switch(this.ƀo){case M.Transitioning:this.ƀk.value===1&&(this.ƀk.value=0,this.ƀip!==void 0?(this.ƀo=M.Transitioning,this.ƀki=this.ƀhe,this.ƀhe=this.ƀip,this.ƀip=void 0,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe}),this.ƀp.animate({value:1}).tap(()=>this.ƀhi()).attach(this)):(this.ƀo=M.Idle,this.ƀki=this.ƀhe,this.ƀhe=void 0,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe})),this.ƀho.trigger(this.ƀk.value));break;case M.Reverting:if(this.ƀki===void 0)throw new Error("StateAnimation: state must be defined when reverting!");this.ƀk.value===0&&(this.ƀip!==void 0?(this.ƀo=M.Transitioning,this.ƀhe=this.ƀip,this.ƀip=void 0,this.ƀk.value=0,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe}),this.ƀp.animate({value:1}).tap(()=>this.ƀhi()).attach(this)):(this.ƀo=M.Idle,this.ƀhe=void 0,this.ƀk.value=0,this.ƀhm.trigger({state:this.ƀki,nextState:this.ƀhe})),this.ƀho.trigger(this.ƀk.value));break;case M.Idle:break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}onStateChange(t){return this.ƀhm.subscribe(e=>t(e.state,e.nextState)).attach(this),this}onValueChange(t){return this.ƀho.subscribe(e=>t(e)).attach(this),this}};var v;(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";})(v||(v={}));var ye=class extends actionsLib.Attachable{static{h(this,"FadeInStateAnimation");}get currentState(){return {value:this.ƀk.value,state:this.ƀki,queuedState:this.ƀip,animationState:this.ƀo}}constructor(t){super(),this.ƀk={value:0},this.ƀo=v.Hidden,this.ƀhm=new actionsLib.Action,this.ƀho=new actionsLib.Action,this.ƀhr={duration:500,animation:w.lineer,...t},this.ƀk.value=0,this.ƀp=new C(this.ƀk,"value",{duration:this.ƀhr.duration,animation:this.ƀhr.animation,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀp.value.subscribe(()=>{this.ƀk.value!==1&&this.ƀk.value!==0&&this.ƀho.trigger(this.ƀk.value);}).attach(this);}setState(t,e){if(e?.instant){this.ƀp.completeAnimation(),this.ƀo=t!==void 0?v.Visible:v.Hidden,this.ƀip=void 0;let i=t!==void 0?1:0,r=this.ƀki!==t;r&&(this.ƀki=t,this.ƀhm.trigger(this.ƀki)),(r||this.ƀk.value!==i)&&(this.ƀk.value=i,this.ƀho.trigger(this.ƀk.value));}else switch(this.ƀo){case v.Hidden:t!==void 0&&(this.ƀo=v.Appearing,this.ƀip=void 0,this.ƀki=t,this.ƀhm.trigger(this.ƀki),this.ƀp.animate({value:1}).tap(()=>this.ƀhi()).attach(this));break;case v.Visible:t===void 0?(this.ƀo=v.Disappearing,this.ƀip=void 0,this.ƀp.animate({value:0}).tap(()=>this.ƀhi()).attach(this)):t!==this.ƀki&&(this.ƀo=v.DisappearToChange,this.ƀip=t,this.ƀp.animate({value:0}).tap(()=>this.ƀhi()).attach(this));break;case v.Appearing:t===void 0?(this.ƀo=v.Disappearing,this.ƀip=void 0,this.ƀp.animate({value:0},{duration:this.ƀk.value*this.ƀhr.duration}).tap(()=>this.ƀhi()).attach(this)):t!==this.ƀki&&(this.ƀk.value>0?(this.ƀo=v.DisappearToChange,this.ƀip=t,this.ƀp.animate({value:0},{duration:this.ƀk.value*this.ƀhr.duration}).tap(()=>this.ƀhi()).attach(this)):(this.ƀip=void 0,this.ƀki=t,this.ƀhm.trigger(this.ƀki)));break;case v.Disappearing:t===this.ƀki?(this.ƀo=v.Appearing,this.ƀp.animate({value:1},{duration:(1-this.ƀk.value)*this.ƀhr.duration}).tap(()=>this.ƀhi()).attach(this)):t!==void 0&&(this.ƀo=v.DisappearToChange,this.ƀip=t);break;case v.DisappearToChange:t===void 0?(this.ƀo=v.Disappearing,this.ƀip=void 0):t===this.ƀki?(this.ƀo=v.Appearing,this.ƀip=void 0,this.ƀp.animate({value:1},{duration:(1-this.ƀk.value)*this.ƀhr.duration}).tap(()=>this.ƀhi()).attach(this)):t!==this.ƀip&&(this.ƀip=t);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀhi(){switch(this.ƀo){case v.Appearing:this.ƀk.value===1&&(this.ƀo=v.Visible,this.ƀho.trigger(this.ƀk.value));break;case v.Disappearing:if(this.ƀip!==void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearing should not have a queued value");this.ƀk.value===0&&(this.ƀo=v.Hidden,this.ƀki=void 0,this.ƀhm.trigger(this.ƀki),this.ƀho.trigger(this.ƀk.value));break;case v.DisappearToChange:if(this.ƀip===void 0)throw new Error("FadeInStateAnimation: Unexpected state, disappearToChange should always have a queued value");this.ƀk.value===0&&(this.ƀo=v.Appearing,this.ƀki=this.ƀip,this.ƀip=void 0,this.ƀhm.trigger(this.ƀki),this.ƀho.trigger(this.ƀk.value),this.ƀp.animate({value:1}).tap(()=>this.ƀhi()).attach(this));break;case v.Hidden:case v.Visible:return;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}onStateChange(t){return this.ƀhm.subscribe(e=>t(e)).attach(this),this}onValueChange(t){return this.ƀho.subscribe(e=>t(e)).attach(this),this}};var Gi=class extends u{static{h(this,"FadeInContent");}constructor(t,e){super(),this.ƀbx=t;let i={duration:200,animation:w.easeInOut,...e};this.alpha=0,this.ƀkj=new ye(i).onStateChange(r=>{this.ƀbl?.destroy(),this.ƀbl=void 0,r!==void 0&&(this.ƀbl=new u().displayParent(this).attach(this),this.ƀbx({state:r,container:this.ƀbl}));}).onValueChange(r=>{this.alpha=r;}).attach(this);}setState(t,e){return this.ƀkj.setState(t,e),this}};var F=class{static{h(this,"GameAssets");}static{this.ƀiz=new Map;}static{this.ƀq=0;}static getAsset(t){let e=this.ƀiz.get(t);if(e)return e;throw new Error(`Game Assets: Resource not found! Key: "${t}"`)}static insertAsset(t,e){let i=e||`a-${this.ƀq++}`;return this.ƀiz.set(i,t),i}static destroyAsset(t){let e=this.ƀiz.get(t);e&&(e.destroy(true),this.ƀiz.delete(t));}static async loadGameAssets(t){let e=new Map,i=[];t.forEach(s=>{if(!helpersLib.Comparator.isString(s.url))throw new Error(`GameAssets: source url should be a string: ${s.url}`);let n=e.get(s.url),a=s.id;n?n.push(a):(e.set(s.url,[a]),i.push({url:s.url,callback:h(l=>{if(l instanceof j__namespace.Texture&&(l.id=a),n=e.get(s.url),n)n.forEach(c=>{this.ƀiz.set(c,l);});else throw new Error(`GameAssets: unexpected error, nameGroup is not found! "./"! ${s}`)},"callback")}));});let r=performance.now();return Promise.all(i.map(s=>j__namespace.Assets.load(s.url))).then(s=>{let n=performance.now();console.info("Asset load completed in: ",Math.round(n-r)/1e3," seconds"),s.forEach((a,l)=>{i[l].callback(a);});}).catch(s=>{throw new Error(`GameAssets: during asset loading, an error occured: ${s}`)})}};var ve=class o extends j__namespace.Filter{static{h(this,"ExpandWithColorFilter");}static ƀep(){return `
33
33
  attribute vec2 aVertexPosition;
34
34
  attribute vec2 aTextureCoord;
35
35
 
@@ -41,7 +41,7 @@
41
41
  gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
42
42
  vTextureCoord = aTextureCoord;
43
43
  }
44
- `}static ƀds(t){let e=`
44
+ `}static ƀdx(t){let e=`
45
45
  uniform sampler2D uSampler;
46
46
  uniform vec2 pixelSize;
47
47
  uniform float expandSquared;
@@ -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.ƀek(),o.ƀds(t*O)),this.ƀcz=t,this.resolution=O,this.ƀcz=t*O,this.ƀcz<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀcz>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀcz)||(this.ƀcz=Math.floor(this.ƀcz));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀcz*this.ƀcz,this.padding=this.ƀcz;}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 Se=class extends L__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.ƀda=new Pe(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀag=new Et(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀag.blendMode=L__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀda.apply(t,e,s,L__namespace.CLEAR_MODES.CLEAR),this.ƀag.apply(t,s,i,r),t.returnFilterTexture(s);}};var zt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀen=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbc(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀdu(t.texture,s,r.expand,r.color,i),a=new L__namespace.Sprite(n);return this.ƀjb(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀdu(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.ƀen.has(n))return o.ƀen.get(n);{let a=this.ƀdv(t,e,i,r);return o.ƀen.set(n,a),a}}else return this.ƀdv(t,e,i,r)}static ƀdv(t,e,i,r){let s=new L__namespace.Sprite(t);this.ƀdc(s,Math.max(e.x,e.y)+i),s.filters=[new Se({blurRadius:e,expand:i,color:r})];let n=w.instance.renderer.generateTexture(s);return n.id=M.insertAsset(n),s.destroy(),n}static ƀjb(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 ƀdc(t,e){if(t.isSprite){let s=new L__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 ƀbc(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};F.onHardReset.subscribe(()=>{zt.ƀen.clear();}).attachToRoot();var Y=class o extends f{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.ƀhv,i=e.parent;i&&i.removeChild(e);let r=w.instance.renderer.generateTexture(e,{resolution:2,scaleMode:L__namespace.SCALE_MODES.LINEAR,multisample:L__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:M.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀkc=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀjl=t,this.pixiSprite=new L__namespace.Sprite(M.getAsset(t.id)),this.ƀhv.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.ƀgh?.destroy(),this.ƀai?.destroy(),this.ƀjl.destroyAssetOnDestroy&&(M.destroyAsset(this.ƀjl.id),this.ƀhw&&M.destroyAsset(this.ƀhw.texture.id)),this.ƀhw&&!this.ƀhw.destroyed&&this.ƀhw.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀkc}set textureScale(t){this.ƀkc=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.ƀjl.boundingShapes&&!this.ƀhv.hitArea&&(this.ƀhv.hitArea=new ge(this.ƀjl.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀjl.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===L__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=L__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=L__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 L__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.ƀhw)return this.ƀhw.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀhw)this.ƀhw.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀjl.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀhw&&(this.ƀhw.destroy(),this.ƀhw=void 0),t&&(this.ƀhw=zt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀjl.destroyAssetOnDestroy),this.ƀhw.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀhw.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.ƀhv.addChild(this.ƀhw)),this}showBoundingShape(t){return t?this.ƀai||(this.ƀai=this.ƀbs().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀai&&(this.ƀai.destroy(),this.ƀai=void 0),this}getBoundingMask(){if(!this.ƀgh){if(!this.ƀjl.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgh=this.ƀbs(),this.ƀgh.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgh.pixiSprite.renderable=false,this.ƀgh.displayParent(this);}return this.ƀgh}ƀbs(){if(!this.ƀjl.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return E.createPolygon(this.ƀjl.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=w.instance.renderer.extract.canvas(this.ƀhv);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 qe=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},yt=class o extends f{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 f;r===exports.ScrollDirection.Horizontal?this.ƀby(e,i,s):this.ƀcf(e,i,s),this.ƀgh=Y.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgh);}ƀcf(t,e,i){e>0&&this.ƀbv(new helpersLib.Vector(t.x,e)).displayParent(i).attach(i),E.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.ƀbv(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀby(t,e,i){e>0&&this.ƀbv(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(0,t.y),{round:false}).setRotation(helpersLib.Radian.get270).displayParent(i).attach(i),E.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.ƀbv(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀbv(t){let i={id:this.ƀbw(t.y),scale:1,size:t,anchor:{x:0,y:0}};return new Y(i,{textureSize:t,ignoreAnchor:true})}ƀbw(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 qe;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=L__namespace.Texture.from(r);i=M.insertAsset(a),o.ƀcr.set(e,i);}else throw new Error("Canvas context is null")}return i}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var S;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(S||(S={}));var Te=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀn=S.Idle,this.ƀgz=new actionsLib.Action,this.ƀhb=new actionsLib.Action,this.ƀhe={duration:500,animation:P.easeInOutCubic,...t},this.ƀjr=new xe({duration:this.ƀhe.duration,animation:this.ƀhe.animation}).onStateChange((e,i)=>this.ƀet(e,i)).onValueChange(e=>this.ƀeu(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfi===void 0?(this.ƀfi=t,this.ƀgz.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀjr.setState(t,e)):this.ƀfi!==t?this.ƀgq!==t?this.ƀn===S.Idle?(this.ƀn=t>this.ƀfi?S.TransitionForward:S.TransitionBackward,this.ƀgq=t,this.ƀgz.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀgq}),this.ƀjr.setState(t,e)):this.ƀjr.setState(t,e):this.ƀn===S.Reverting&&this.ƀgq===t&&(this.ƀn=t>this.ƀfi?S.TransitionForward:S.TransitionBackward,this.ƀjr.setState(t,e)):(this.ƀn===S.TransitionForward||this.ƀn===S.TransitionBackward)&&(this.ƀn=S.Reverting,this.ƀjr.setState(t,e));}ƀet(t,e){switch(this.ƀfi!==void 0&&this.ƀfi!==t&&this.ƀfi!==e&&this.ƀgz.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀfi}),this.ƀgq!==void 0&&this.ƀgq!==t&&this.ƀgq!==e&&this.ƀgz.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀgq}),e!==void 0&&e!==this.ƀfi&&e!==this.ƀgq&&this.ƀgz.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀn){case S.Idle:break;case S.TransitionForward:case S.TransitionBackward:e===void 0?(this.ƀn=S.Idle,this.ƀfi=this.ƀgq,this.ƀgq=void 0):this.ƀfi!==t&&this.ƀeq(t,e);break;case S.Reverting:e===void 0?(this.ƀn=S.Idle,this.ƀgq=void 0):this.ƀfi!==e&&this.ƀeq(t,e);break;default:{this.ƀn;throw new Error(`Unexpected case! "${this.ƀn}"`)}}}ƀeu(t){let e=1;(this.ƀn===S.TransitionBackward||this.ƀn===S.Reverting&&this.ƀfi!==void 0&&this.ƀgq!==void 0&&this.ƀfi>this.ƀgq)&&(e=-1),(this.ƀn===S.Idle||t!==0)&&this.ƀhb.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfi}),this.ƀgq!==void 0&&this.ƀhb.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀgq});}ƀeq(t,e){this.ƀfi=t,this.ƀgq=e,this.ƀhb.trigger({value:0,index:this.ƀfi}),this.ƀn=this.ƀfi<this.ƀgq?S.TransitionForward:S.TransitionBackward;}onStateChange(t){return this.ƀgz.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀhb.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 ti=class extends f{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbu=t,this.ƀcm="x",this.ƀbj=new Map,this.ƀhe={duration:300,animation:P.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀhe.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀhe.size.x+this.ƀhe.margin*2,this.ƀhe.size.y):new helpersLib.Vector(this.ƀhe.size.x,this.ƀhe.size.y+this.ƀhe.margin*2),r=new f().setPosition(this.ƀhe.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀhe.margin,0):new helpersLib.Vector(0,-this.ƀhe.margin),{round:false}).displayParent(this).attach(this);this.ƀbz(i,this.ƀhe.margin,this.ƀhe.direction,r),this.ƀcm=this.ƀhe.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀjr=new Te({duration:this.ƀhe.duration,animation:this.ƀhe.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new f().displayParent(this).attach(this);this.ƀbj.set(n,a),this.ƀbu({index:n,container:a});}else {let a=this.ƀbj.get(n);a&&(a.destroy(),this.ƀbj.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbj.get(n);if(a){let l={x:0,y:0};l[this.ƀcm]=i[this.ƀcm]*s+this.ƀhe.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀjr.setIndex(t,e),this}ƀbz(t,e,i,r){new yt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},Hi=class extends ti{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 xt=class{static{h(this,"VectorSet");}constructor(){this.ƀko=new Map;}add(t){let e=this.ƀko.get(t.x);e||(e=new Set,this.ƀko.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀko.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀko.get(t.x);return e?e.delete(t.y):false}};var ei=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 Yt=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.ƀar(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 xt,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.ƀar(t,a))return helpersLib.Vector.fromTo(e,n);t.getNeighborPositions(n,helpersLib.GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀar(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 Wi=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)}},ds=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀep=t,this.ƀjo=e,this.ƀhd=new helpersLib.BinaryHeap("min"),this.ƀav=[],this.ƀgs=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new Wi(this.ƀjo,0,Number.MAX_SAFE_INTEGER);this.ƀhd.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀhd.size>0}getNeighbors(t,e){return this.ƀep.getNeighborPositions(t.position,e).filter(i=>this.ƀep.get(i)).map(i=>this.ƀgs.get(i)||this.ƀca(i))}popLowestPathCostNode(){let t=this.ƀhd.pop();return this.ƀhd.delete(t),t.closed=true,this.ƀav.push(t),t}changeNodeCost(t,e,i,r){this.ƀhd.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀhd.add(t.pathLength,t);}getBestClosedNode(){return this.ƀav.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀca(t){let e=new Wi(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀgs.set(t,e),this.ƀhd.add(e.pathLength,e),e}},Xt=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new ds(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 Kt=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀjw=t,this.ƀw=e,this.ƀew=this.ƀdx(this.ƀw.size),this.ƀkw=new helpersLib.Grid({size:this.ƀw.size,defaultValue:this.ƀew}),this.ƀcn=new helpersLib.Grid({size:this.ƀw.size,defaultValue:void 0});let i=new xt,r=new helpersLib.Queue;for(this.ƀdl(this.ƀw.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀkw.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀkw.getOrFail(n);this.ƀec(n,this.ƀw).forEach(l=>{if(!i.has(l.position)){let c=this.ƀkw.getOrFail(l.position),p=a+l.distance;this.ƀw.getOrFail(l.position)&&p<c&&(this.ƀkw.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀjw)){if(t=this.ƀkw.movePositionInsideGrid(t),this.ƀcn.has(t))return this.ƀcn.get(t);{let e=this.ƀec(t,this.ƀw),i;return this.ƀkw.getOrFail(t)>=this.ƀew?e.some(s=>this.ƀw.get(s.position))&&(e.some(n=>!this.ƀw.get(n.position))?i=this.ƀdr(e):i=this.ƀdm(t,e)):i=this.ƀdm(t,e),this.ƀcn.set(t,i),i}}}ƀdr(t){let e=t.filter(i=>this.ƀw.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdm(t,e){let i=e.filter(r=>this.ƀkw.getOrFail(r.position)<this.ƀew).reduce((r,s)=>{let n=this.ƀkw.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.ƀew}).bestDirections;return this.ƀei(i,t)}ƀei(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀfo(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀfo(t,e){let i=t.add(this.ƀkp(e));return this.ƀw.isPointWithinBounds(i)&&this.ƀw.getOrFail(i)}ƀec(t,e){return this.ƀkw.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdl(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}ƀkp(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀdx(t){return (t.x+t.y)*20}};var ys=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},V=class extends ut{static{h(this,"CameraEntity");}constructor(){super(...arguments),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.offset=new actionsLib.Variable(helpersLib.Vector.zero),this.targetPosition=new actionsLib.Variable(void 0),this.focusingNewTargetInfo=new actionsLib.Variable(void 0);}};V=ys([ft()],V);var ws=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},xs=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},At=class extends dt{static{h(this,"CameraView");}constructor(t){super(),this.ƀcx=t,this.ƀip=new f().setAlpha(0).displayParent(w.instance.stage).attach(this),this.ƀac=E.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(w.instance.stage).attach(this),this.ƀaa=new f().displayParent(this.ƀip).attach(this),this.ƀao=new f().displayParent(this.ƀip).attach(this),this.ƀdh=new f().setSortableChildren(true).displayParent(this.ƀip).attach(this),this.ƀan=new f().setSortableChildren(true).displayParent(this.ƀao).attach(this),this.ƀdg=new f().setSortableChildren(true).setZIndex(20).displayParent(this.ƀan).attach(this),this.ƀgf=new f().setSortableChildren(true).setZIndex(10).displayParent(this.ƀan).attach(this),this.ƀz=new f().setZIndex(0).displayParent(this.ƀan).attach(this),this.ƀh=new D(this.ƀip,"alpha",{duration:500,animation:P.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀad=new D(this.ƀac,"alpha",{duration:500,animation:P.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),w.instance.screenSize.subscribe(e=>{this.ƀac.aspectRatio=e.x/e.y,this.ƀac.scale=Math.max(e.x,e.y),this.ƀac.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.zero});}).attach(this),w.instance.setScreenPositionToStagePositionFunction(e=>new helpersLib.Vector(e.x-this.ƀan.position.x-this.ƀao.position.x,e.y-this.ƀan.position.y-this.ƀao.position.y)),this.ƀcx.position.subscribe(e=>{this.ƀan.position=this.ƀbp(e);}).attach(this),this.ƀcx.offset.subscribe(e=>{this.ƀao.position=e;}).attach(this),this.appear(true,"alpha");}destroy(){this.destroyed||(super.destroy(),w.instance.resetScreenPositionToStagePositionFunction());}getLayers(){return {backgroundScreen:this.ƀaa.id,background:this.ƀz.id,main:this.ƀgf.id,foreground:this.ƀdg.id,foregroundScreen:this.ƀdh.id}}appear(t,e){switch(e){case "alpha":return this.ƀad.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),this.ƀh.animate({alpha:t?1:0}).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀad.set({alpha:t?1:0}),this.ƀad.animate({alpha:t?0:1}).chain(this);case "instant":return this.ƀh.set({alpha:t?1:0}),this.ƀad.set({alpha:t?0:1}),actionsLib.SingleEvent.instant();default:{throw new Error('Switch ended with value "never".')}}}ƀbp(t){return helpersLib.Vector.fromTo(t,w.instance.screenSizeCenter.value)}};At=ws([Ye({entity:V}),xs("design:paramtypes",[V])],At);var Ps=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},Ss=1500,Re=class{static{h(this,"CameraService");}createCamera(){return new V().attachToRoot()}getCameraPosition(){let t=V.getInstanceOrFail();return helpersLib.Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=V.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=V.getInstanceOrFail();e.focusingNewTargetInfo.value={time:w.time,duration:t?.duration??Ss,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??exports.FocusingAnimation.Instant};}update(t,e){let i=V.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀfr(i,r,t):i.position.value=r);}ƀfr(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===exports.FocusingAnimation.Instant)this.ƀbb(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbb(t,e);else {let n;r.focusingAnimation===exports.FocusingAnimation.EaseInOut?n=z.easeInOut(s):r.focusingAnimation===exports.FocusingAnimation.EaseOut?n=z.easeOut(s):n=1;let a=r.position.lerp(e,n);r.roundPosition&&(Math.abs(a.x-r.position.x)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(Math.round(a.x),a.y)),Math.abs(a.y-r.position.y)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(a.x,Math.round(a.y)))),t.position.value=a;}}}ƀbb(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};Re=Ps([d()],Re);var Ts=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},Es=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},si=class{static{h(this,"CameraController");}constructor(t){this.ƀap=t;}createCamera(){return this.ƀap.createCamera().id}update(t,e){this.ƀap.update(t,e);}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}getCameraPosition(){return this.ƀap.getCameraPosition()}};si=Ts([q({controllerLink:gt}),Es("design:paramtypes",[Re])],si);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},oi=class{static{h(this,"CameraViewController");}getLayers(){let t=V.getInstanceOrFail().id;return At.getInstanceOrFail(t).getLayers()}appear(t,e){let i=V.getInstanceOrFail().id;return At.getInstanceOrFail(i).appear(t,e)}};oi=Rs([q({controllerLink:we})],oi);var Qt=class{static{h(this,"Camera");}get position(){return this.ƀam.getCameraPosition()}constructor(){this.ƀam=T.get(exports.CameraGateway),this.ƀaq=T.get($t),this.ƀam.createCamera(),this.layers=this.ƀaq.getLayers();}setPosition(t){this.ƀam.setPosition(t);}setTransition(t){this.ƀam.setTransition(t);}appear(t,e="alpha"){return this.ƀaq.appear(t,e)}};var w=class o{static{h(this,"Game");}static get instance(){return this.ƀfl}static{this.pause=actionsLib.Reducer.createOr();}static get camera(){return this.ƀal}static get time(){return y.ƀkd}static get setupOptions(){return this.ƀje}constructor(t){if(this.ƀit=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSize=this.ƀit.notifier,this.ƀiu=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSizeCenter=this.ƀiu.notifier,this.devMode=false,this.resetScreenPositionToStagePositionFunction(),o.ƀfl)throw new Error("There can be only one Game instance!");{this.ƀbf={screenResolution:void 0,maxScreenResolution:void 0,devMode:false,backgroundColor:helpersLib.ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbf.devMode||false;let e=helpersLib.JsonHelper.removeUndefinedProperties({backgroundColor:this.ƀbf.backgroundColor,autoStart:false,antialias:this.ƀbf.antialias,resolution:this.ƀbf.resolution,width:this.ƀbf.screenResolution?.width,height:this.ƀbf.screenResolution?.height});this.ƀhu=new L__namespace.Application(e);}}async setup(t){o.ƀje=t;let e=document.body.appendChild(this.ƀhu.view);this.ƀjd(e),await Promise.all([M.loadGameAssets(t.assetDefinitions)]),o.ƀfl=this,this.stage=new f().attachToRoot(),this.stage.ƀhv=this.ƀhu.stage,this.renderer=this.ƀhu.renderer,this.stage.sortableChildren=true,globalThis.ƀa=this.ƀhu,this.ƀer(),o.ƀal=new Qt,this.ƀhu.start(),this.ƀhu.ticker.add(()=>{y.triggerUpdateTick(this.ƀhu.ticker.deltaMS);});}setResolution(t){if(this.ƀhu.renderer.resolution!==t){this.ƀhu.renderer.resolution=t;let e=this.ƀeg();this.ƀhu.renderer.resize(e.x,e.y);}}screenPositonToStagePosition(t){let e=Ut.includeScaleInScreenPosition(t,o.instance.stage.scale,o.instance.screenSizeCenter.value);return this.ƀis(e)}setScreenPositionToStagePositionFunction(t){this.ƀis=t;}resetScreenPositionToStagePositionFunction(){this.ƀis=t=>t;}destroyAsset(t){M.destroyAsset(t);}ƀer(){this.ƀcv(),this.ƀjc(),window.addEventListener("resize",t=>{this.ƀcv(),this.ƀjc();});}ƀcv(){let t=this.ƀeg();(t.x!==this.ƀhu.screen.width||t.y!==this.ƀhu.screen.height)&&this.ƀhu.renderer.resize(t.x,t.y);}ƀjc(){let t=new helpersLib.Vector(this.ƀhu.screen.width,this.ƀhu.screen.height);this.ƀit.value=t,this.ƀiu.value=t.multiplyNumber(.5).round();}ƀeg(){let t=this.ƀbf.screenResolution?.width??window.innerWidth,e=this.ƀbf.screenResolution?.height??window.innerHeight;return this.ƀbf.maxScreenResolution&&(t=Math.min(t,this.ƀbf.maxScreenResolution.width),e=Math.min(e,this.ƀbf.maxScreenResolution.height)),new helpersLib.Vector(t,e)}ƀjd(t){this.ƀbf.maxScreenResolution&&(t.style.maxWidth=`${this.ƀbf.maxScreenResolution?.width}px`,t.style.maxHeight=`${this.ƀbf.maxScreenResolution?.height}px`),t.style.width="100%",t.style.height="100%";}};var Ie=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 R=s.normalize(g/2),bt=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(R)}),l=l.add(R),m>0){let oe=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(bt),a.push({from:l,to:l.add(oe)}),l=l.add(oe);});}return l=l.add(bt),a.push({from:l,to:l.add(R)}),a}};var E=class o extends f{static{h(this,"Graphics");}static{this.ƀcr=new Map;}static createArrow(t,e){let i=new L__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 L__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 L__namespace.Graphics;return s.lineStyle(r.width,r.color),Ie.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 L__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 L__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 L__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 L__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 L__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 L__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new L__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new L__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.ƀhv.addChild(t),this.pixiGraphics=t,this.ƀak=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀak,cache:false,...t},i=this.ƀeh(e.cacheName,e.cache),r={id:i.assetID,scale:1,size:i.bounds,anchor:{x:0,y:0},destroyAssetOnDestroy:!e.cache},s=new Y(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀeh(t,e){if(e){let i=o.ƀcr.get(t);return i||(i=this.ƀce(),o.ƀcr.set(t,i)),i}else return this.ƀce()}ƀce(){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 f{static{h(this,"Placeholder");}constructor(t){super(),this.ƀhx=new L__namespace.Graphics,this.ƀhx.beginFill(0,1e-9),this.ƀhx.drawRect(0,0,t.x,t.y),this.ƀhx.endFill(),this.ƀhv.addChild(this.ƀhx);}destroy(){this.destroyed||(super.destroy(),this.ƀhx.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 helpersLib.JsonHelper.removeUndefinedProperties({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 Oe=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.ƀfh(r,e),n=this.ƀr(s);return this.ƀjj(n)}static ƀfh(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.ƀdp(a.tags,e,i),p=s(l,c),m=L__namespace.TextMetrics.measureText(" ",new L__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdp(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀba(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀba(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 ƀr(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 ƀjj(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.ƀjk(s.text).map(a=>{let l=new L__namespace.TextStyle(s.pixiStyle),c=L__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 ƀjk(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 Me=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀci.length===0}get remainingWidth(){return this.ƀkx-this.ƀck}constructor(t,e){this.ƀkx=t,this.ƀfz=[],this.ƀci=[],this.ƀck=0,this.ƀfy=new helpersLib.Vector(0,0),this.ƀcj=0;let i={rectangleCutOption:void 0,horizontalAlignment:"left",verticalAlignment:"bottom",...e};if(this.ƀez=i.horizontalAlignment,this.ƀkq=i.verticalAlignment,i.rectangleCutOption){if(i.rectangleCutOption.position.x<0||i.rectangleCutOption.position.x>=this.ƀkx||i.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀcl={direction:i.rectangleCutOption.direction,rectangle:this.ƀbo(i.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcj,t.y),i=this.ƀdy(this.ƀfy.y,this.ƀfy.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.ƀdz(this.ƀfy.y,this.ƀfy.y+e);this.ƀfy=new helpersLib.Vector(i,this.ƀfy.y),this.ƀck=this.ƀfy.x;}this.ƀci.push({chunk:t,position:new helpersLib.Vector(this.ƀck,this.ƀfy.y)}),this.ƀcj=e,this.ƀck+=t.style.width;}newLine(){let t=this.ƀfy.y+this.ƀcj,e=this.ƀdz(t,t);this.ƀde(),this.ƀfy=new helpersLib.Vector(e,t),this.ƀck=this.ƀfy.x,this.ƀcj=0;}print(){return this.ƀde(),this.ƀfz}ƀde(){this.ƀci.length>0&&(this.ƀfz.push(this.ƀg(this.ƀci)),this.ƀci=[]);}ƀg(t){return t=this.ƀks(t),t=this.ƀfb(t),t}ƀfb(t){if(this.ƀez==="left")return t;let e=this.ƀfy.y+this.ƀcj,i=this.ƀdz(this.ƀfy.y,e),s=this.ƀdy(this.ƀfy.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀez==="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))}ƀks(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.ƀkq){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.ƀkq;throw new Error(`Unexpected case! "${this.ƀkq}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀdz(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}ƀdy(t,e){return this.ƀcl&&(this.ƀcl.direction==="topRight"||this.ƀcl.direction==="bottomRight")&&(this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(this.ƀkx,t),{includeEdges:false})||this.ƀcl.rectangle.isPointInside(new helpersLib.Vector(this.ƀkx,e),{includeEdges:false}))?this.ƀcl.rectangle.topLeft.x:this.ƀkx}ƀbo(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 De=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.ƀky(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀky(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀky(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 Be=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgm(t),t=this.ƀkh(t),this.ƀat(t)}static ƀgm(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 ƀkh(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 ƀat(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=Oe.process(t,e),r=helpersLib.JsonHelper.removeUndefinedProperties({rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=new Me(e.default.wordWrapWidth??1/0,r),n=De.wrapText(i,s);return Be.process(n)}};var Ws=1,Xi=1/Ws,te=class extends f{static{h(this,"Text");}get ƀka(){if(!this.ƀkb){let t=new L__namespace.TextStyle(this.ƀhz);this.ƀkb=L__namespace.TextMetrics.measureText(this.ƀjz,t);}return this.ƀkb}get ascent(){return this.ƀka.fontProperties.ascent}constructor(t,e){super(),this.ƀhz=Ot.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀhy.destroyed&&this.ƀhy.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀhy.anchor.x,this.ƀhy.anchor.y)}set anchor(t){this.ƀi=t,this.ƀhy.anchor.set(t.x,t.y);}setText(t){return this.ƀjz!==t&&(this.ƀjz=t,this.ƀig()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀhz.fill!==e&&(this.ƀhz.fill=e,this.ƀig()),this}ƀig(){this.ƀhy?.destroy(),this.ƀju?.destroy(),this.ƀju=void 0,this.ƀkb=void 0;let t=new L__namespace.TextStyle(this.ƀhz);this.ƀhy=new L__namespace.Text(this.ƀjz,t),this.ƀik(),this.ƀi&&this.ƀhy.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀhy.scale.set(Xi,Xi),this.ƀhv.addChild(this.ƀhy),this.ƀhz.lineThrough&&(this.ƀju=this.ƀe(this.ƀhy,this.ƀhz.fill),this.ƀhv.addChild(this.ƀju));}ƀik(){let t=L__namespace.TextMetrics.measureText(this.ƀjz,new L__namespace.TextStyle({...this.ƀhz,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀhy.calculateBounds=function(){this.updateText(true),this._bounds.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this._bounds.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=L__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new L__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=L__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 f{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 f{static{h(this,"UpdatableContainer");}},ci=class extends f{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbu=t,this.ƀco=new Map,this.ƀhe={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.ƀhe.trackBy(r,s),a;this.ƀco.has(n)?(a=this.ƀco.get(n),e.delete(n),a.update(r)):(a=this.ƀbu(r).displayParent(this).attach(this),this.ƀco.set(n,a)),this.ƀhe.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhe.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhe.positioning.spacing);}),e.forEach(r=>{this.ƀco.get(r).destroy(),this.ƀco.delete(r);});}};var ee=class o extends f{static{h(this,"MenuUI");}static{this.ƀfn=actionsLib.Reducer.createExistenceChecker();}static{this.isAnyMenuTransitioning=this.ƀfn.notifier;}constructor(t,e){super(),this.ƀgw=new actionsLib.SingleAction,this.onCreate=this.ƀgw.notifier,this.ƀgy=new actionsLib.SingleAction,this.onOpen=this.ƀgy.notifier,this.ƀgt=new actionsLib.SingleAction,this.onClose=this.ƀgt.notifier,this.ƀaw=false;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,backgroundDarkeningRatio:.3,...e};this.setAlpha(0),this.ƀo=new D(this,"alpha",{animation:P.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState});let r=E.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.backgroundDarkeningRatio).setInteractive(true).displayParent(this).attach(this);this.ƀgk=Y.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),w.instance.screenSize.subscribe(n=>{r.aspectRatio=n.x/n.y,r.scale=Math.max(n.x,n.y),r.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(n.multiplyNumber(.5));}).attach(this),this.ƀgw.resolve();let s=o.ƀfn.effect().attach(this);this.ƀo.animate({alpha:1}).chain(this).tap(()=>{this.ƀgy.resolve(),s.destroy(),i.closeOnBackgroundClick&&r.on(exports.ContainerEventType.Click).take(1).tap(()=>this.close()).attach(this);}).attachToRoot();}getBoundingMask(){return this.ƀgk.getBoundingMask()}close(){if(!this.ƀaw){this.ƀaw=true;let t=o.ƀfn.effect().attach(this);this.ƀo.animate({alpha:0}).chain(this).map(()=>{this.ƀgt.resolve(),t.destroy(),this.destroy();}).chainToRoot();}return this.onClose.toSingleEvent()}};var di=class extends ut{static{h(this,"MenuEntity");}static subscribeIsOpen(){return actionsLib.ActionLib.merge(this.continuesSubscription().map(t=>t.type==="open"),actionsLib.SingleEvent.instant(this.getInstance()!==void 0))}constructor(t){super(),this.ƀhe=t,queueMicrotask(()=>{if(!this.ƀgl)throw new Error("MenuEntity: MenuEntity has to have a MenuView.")});}ƀii(t){this.ƀgl=t,this.ƀgl.onClose.subscribe(()=>this.destroy()).attach(this);}onCreate(){return this.ƀgl.onCreate.toSingleEvent()}onOpen(){return this.ƀgl.onOpen.toSingleEvent()}onClose(){return this.ƀgl.onClose.toSingleEvent()}close(){return this.ƀgl.close()}};var fi=class extends dt{static{h(this,"MenuView");}constructor(t,e,i){super();let r=helpersLib.JsonHelper.removeUndefinedProperties({appearAnimationDuration:i.appearAnimationDuration,backgroundDarkeningRatio:i.backgroundDarkeningRatio,closeOnBackgroundClick:t.ƀhe.closeOnBackgroundClick}),s=new ee(e,r).displayParent(w.camera.layers.foregroundScreen).attach(this);t.ƀii(s);let n=new actionsLib.SingleAction;s.onCreate.subscribe(()=>n.resolve(s)).attach(this),this.onCreate=n.notifier,this.onOpen=s.onOpen.notifier,this.onClose=s.onClose.notifier;}};var Ks=.65,Zs=.01,Fe=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀiv}get contentSize(){return this.ƀbh.size.ceil()}constructor(t,e,i,r){this.ƀbh=t,this.ƀu=e,this.ƀhh=i,this.ƀji=r,this.ƀfk=false,this.ƀiv=e-i*2,this.ƀbh.y=i,this.ƀjv=i;}onWheel(t){this.setTarget(this.ƀjv-t*Ks);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀjv=helpersLib.NumberHelper.clamp(t,this.ƀu-this.ƀhh-this.contentSize.y,this.ƀhh);}jumpToTarget(){this.ƀbh.y=this.ƀjv;}update(t){let e=this.contentSize;if(e.y<=this.ƀiv){switch(this.ƀji){case "start":this.ƀjv=this.ƀhh;break;case "center":this.ƀjv=(this.ƀu-e.y)*.5;break;case "end":this.ƀjv=this.ƀu-e.y-this.ƀhh;break;default:{this.ƀji;throw new Error(`Unexpected case! "${this.ƀji}"`)}}this.ƀfk||(this.ƀbh.y=this.ƀjv);}this.ƀfk=true;let i=this.ƀjv-this.ƀbh.y;this.ƀbh.y=this.ƀbh.y+i*Zs*t;}};var qs=15,ui=class extends f{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbi}get contentSize(){return this.ƀiw.contentSize}constructor(t,e={}){super();let i={padding:qs,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 f().displayParent(this).attach(this);new yt(r,t,i.padding).attach(this);let s=new L__namespace.Graphics;s.beginFill(0,1e-9),s.drawRect(0,0,t.x,t.y),s.endFill(),r.ƀhv.addChild(s);let n=new f().displayParent(r).attach(this);this.ƀiw=new Fe(n,t.y,i.padding,i.smallContentAlign),this.ƀbi=new helpersLib.Vector(t.x,this.ƀiw.scrollHeight),s.eventMode="dynamic",s.addEventListener("wheel",a=>{this.ƀiw.onWheel(a.deltaY);}),n.setInteractive(true),n.ƀhv.addEventListener("wheel",a=>{this.ƀiw.onWheel(a.deltaY);}),y.afterSceneUpdateAction.subscribe(a=>this.ƀiw.update(a.delta)).attach(this),this.addChildTo=n;}scrollToTop(t){this.ƀiw.scrollToTop(),t?.instant&&this.ƀiw.jumpToTarget();}scrollToBottom(t){this.ƀiw.scrollToBottom(),t?.instant&&this.ƀiw.jumpToTarget();}};var to=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},eo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.KeyboardService=class mi{static{h(this,"KeyboardService");}constructor(){this.ƀfu=new actionsLib.Action,this.keyPressed=this.ƀfu.notifier,this.ƀfv=new actionsLib.Action,this.keyReleased=this.ƀfv.notifier,this.ƀgb=new Set,this.ƀga=new Set,window.addEventListener("keydown",t=>{this.ƀgb.add(t.code),this.ƀga.add(t.code),!t.repeat&&this.ƀfu.trigger({key:t.key,code:t.code});}),window.addEventListener("keyup",t=>{this.ƀgb.delete(t.code),this.ƀfv.trigger({key:t.key,code:t.code});}),window.addEventListener("blur",()=>{this.ƀgb.clear();}),y.afterSceneUpdateAction.subscribe(()=>this.ƀga.clear()).attachToRoot();}isKeyDown(t,e){return (e?.onlyPressedThisFrame?this.ƀga:this.ƀgb).has(t)}};exports.KeyboardService=to([d(),eo("design:paramtypes",[])],exports.KeyboardService);var io=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},ro=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class re{static{h(this,"MouseService");}constructor(){this.ƀfj=new actionsLib.Variable(false),this.initialMouseMovementHappened=this.ƀfj.notifier,this.ƀjm=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀjm.notifier,this.ƀir=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀir.notifier,this.ƀge=new actionsLib.Variable(false),this.mainButtonState=this.ƀge.notifier,this.ƀix=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀix.notifier,this.ƀjn(),window.addEventListener("pointerdown",t=>{t.button===0?this.ƀge.value=true:t.button===2&&(this.ƀix.value=true);},{capture:true}),window.addEventListener("pointerup",t=>{t.button===0?this.ƀge.value=false:t.button===2&&(this.ƀix.value=false);},{capture:true}),window.addEventListener("blur",()=>{this.ƀge.value=false,this.ƀix.value=false;},{capture:true});}ƀjn(){let t=helpersLib.Vector.zero;window.addEventListener("pointermove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfj.value=true;},{capture:true}),y.beforeSceneUpdateAction.subscribe(()=>{this.ƀir.value=this.clientPositionToScreenPosition(t);}).attachToRoot(),y.afterSceneUpdateAction.subscribe(()=>{let e=w.instance.screenPositonToStagePosition(this.ƀir.value);e.isEqual(this.ƀjm.value)?w.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:t.x,clientY:t.y,pointerType:"mouse"})):this.ƀjm.value=e;}).attachToRoot();}clientPositionToScreenPosition(t){let i=w.instance.renderer.view.getBoundingClientRect(),r=i.width,s=i.height;if(r<=0||s<=0)return helpersLib.Vector.zero;let n=w.instance.renderer,a=(t.x-i.left)/r*n.screen.width,l=(t.y-i.top)/s*n.screen.height;return a=helpersLib.NumberHelper.clamp(a,0,n.screen.width),l=helpersLib.NumberHelper.clamp(l,0,n.screen.height),new helpersLib.Vector(a,l)}};exports.MouseService=io([d(),ro("design:paramtypes",[])],exports.MouseService);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},oo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseTargetFocusService=class gi{static{h(this,"MouseTargetFocusService");}get focusedInLastFrame(){return this.ƀdf}get lastFocusedPosition(){return this.ƀfx}constructor(t){this.ƀgo=t,this.ƀha=new actionsLib.Action,this.onTargetFocus=this.ƀha.notifier,this.ƀkf=0,this.ƀkg=false,this.ƀdf=false,this.ƀfx=void 0,y.beforeSceneUpdateAction.subscribe(e=>this.ƀkj(e.delta)).attachToRoot();}ƀkj(t){if(this.ƀgp){let e=this.ƀef(this.ƀgo.stagePosition.value,this.ƀgp);this.ƀhj===void 0?this.ƀhj=e:this.ƀas(e,t);}this.ƀgp=this.ƀgo.stagePosition.value;}ƀas(t,e){this.ƀhj-t>10?(this.ƀkf=Math.max(250,this.ƀkf),this.ƀkg=true):this.ƀkf>1e3&&(this.ƀkg=true);let i=this.ƀkf>=300&&this.ƀkg;this.ƀfs(i,t,e);}ƀfs(t,e,i){(t||e>this.ƀhj)&&(this.ƀhj=e),t?(this.ƀkg=false,this.ƀkf=0,this.ƀdf=true,this.ƀfx=this.ƀgo.stagePosition.value,this.ƀha.trigger(this.ƀfx)):(this.ƀkf+=i,this.ƀdf=false);}ƀef(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=so([d(),oo("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var yi=10.8,wi=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 u=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 U__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};var ot="border";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},X=new $,Bt=class{static{h(this,"PhysicsInternalGateway");}createBody(t,e,i,r,s){return X.trigger("createBody",t,e,i,r,s)}getMaterial(t,e){return X.trigger("getMaterial",t,e)}getMaterialDefinition(t,e){return X.trigger("getMaterialDefinition",t,e)}getGroupConstant(t,e){return X.trigger("getGroupConstant",t,e)}getMaskConstant(t,e){return X.trigger("getMaskConstant",t,e)}addBody(t,e,i,r,s){return X.trigger("addBody",t,e,i,r,s)}removeBody(t,e){return X.trigger("removeBody",t,e)}subscribeToPhysicsStep(t,e){return X.trigger("subscribeToPhysicsStep",t,e)}};Bt=po([d()],Bt);var b=class o extends k{static{h(this,"PhysicsEntity");}static{this.ƀhg=new Map;}static{this.ƀhn=new Map;}static getFromP2BodyID(t){return o.ƀhg.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀhg.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀhn.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀhn.values())}get area(){return this.ƀt}get mass(){return this.ƀgi}get collisions(){return this.ƀax}constructor(t,e,i){super(),this.ƀgu=new actionsLib.Action,this.onCollision=this.ƀgu.notifier,this.type="dynamic",this.ƀt=0,this.ƀgi=0,this.ƀax=[],this.physicsWorldID=t,this.ƀhp=T.get(Bt);let r=this.ƀhp.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀhp.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀho=this.ƀhp.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀhq=this.ƀhp.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀhp.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀt=this.p2Body.getArea(),this.ƀgi=this.p2Body.mass,this.p2Body.position=u.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀhp.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.ƀhg.set(this.p2Body.id,this),o.ƀhn.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀhp.removeBody(this.physicsWorldID,this.p2Body),o.ƀhg.delete(this.p2Body.id),o.ƀhn.delete(this.id));}canCollideWith(t){return u.arePhysicsGroupsCollidable(this.ƀho,this.ƀhq,t.ƀho,t.ƀhq)}ƀiz(t){this.ƀax=t,t.length>0&&this.ƀgu.trigger(t);}};var se=class extends b{static{h(this,"ImmovablePhysicsEntity");}constructor(t,e){super(t,e,"static"),this.position=u.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 xi=class extends k{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.ƀjs(t,e);}).attach(this);}ƀjs(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 vi=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.ƀfc=false,this.ƀfd=false,this.ƀff=false,this.ƀfe=false,this.ƀhk(),this.ƀgc(),T.get(Bt).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀjs(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}}ƀjs(t,e){this.ƀfc=true,this.ƀfd=true,this.ƀff=true,this.ƀfe=true,this.ƀhk();}ƀhk(){this.position.value=u.arrayToVector(this.p2Body.position),this.rotation.value=new helpersLib.Radian(this.p2Body.angle),this.velocity.value=u.arrayToVector(this.p2Body.velocity),this.rotationalSpeed.value=this.p2Body.angularVelocity;}ƀgc(){this.position.subscribe(t=>{this.ƀfc?this.ƀfc=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfd?this.ƀfd=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀff?this.ƀff=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfe?this.ƀfe=false:this.p2Body.angularVelocity=t;}).attach(this);}};var go=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},yo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},v=class extends k{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=go([ft(),yo("design:paramtypes",[helpersLib.Vector,Boolean,U__default.default.World,Map,Map,Map,Map])],v);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},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=bo([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},So=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Le=class{static{h(this,"AvailabilityGridCacheService");}constructor(t){this.ƀhm=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhm.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();}};Le=Po([d(),So("design:paramtypes",[K])],Le);var To=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},Eo=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.ƀhm=t,this.ƀx=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=u.aabbToBoundingBox(e.aabb);this.ƀx.getCollidableGrids(t,i).forEach(s=>{let n=B.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=Gt){return e.aabbNeedsUpdate=true,e.updateAABB(),Yt.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),u.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀx.get(t,e,i);return r||(r=this.ƀbx(t,e,i),this.ƀx.set(t,e,i,r)),r}ƀbx(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.ƀhm.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀdw(s,e);r.setArea(a,false);}}),r}ƀdw(t,e){let i=u.aabbToBoundingBox(t.aabb);return B.areaToGridArea(i,e)}};nt=To([d(),Eo("design:paramtypes",[K,Le])],nt);var Io=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},Ao=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Gt=50,Ft=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhl=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=Gt);let n=v.getInstanceByIDOrFail(t),a,l;helpersLib.Comparator.isNumber(i)?(l=b.getPhysicsInstanceOrFail(i).p2Body,a=u.arrayToVector(l.position)):a=i;let c=B.positionToGridPosition(e,s.gridCellSize),p=B.positionToGridPosition(a,s.gridCellSize),m=this.ƀhl.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let R=u.aabbToBoundingBox(l.aabb),bt=B.areaToGridArea(R,s.gridCellSize);m.setArea(bt,true);}let g=Xt.findPath(m,c,p,s.neighborType);return g.path=g.path.map(R=>B.gridPositionToPosition(R,s.gridCellSize)),g}findPathDirection(t,e,i,r,s=Gt){let n=v.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let g=b.getPhysicsInstanceOrFail(i);a=u.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.ƀhl.getAvilabilityGrid(n,s,r);p=new Kt(l,g),n.vectorFieldCache.set(c,p);}let m=B.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};Ft=Io([d(),Ao("design:paramtypes",[nt])],Ft);var Do=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=new $;exports.PhysicsGateway=class bi{static{h(this,"PhysicsGateway");}createPhysicsWorld(t){return H.trigger("createPhysicsWorld",t)}getMapSize(t){return H.trigger("getMapSize",t)}setPaused(t,e){return H.trigger("setPaused",t,e)}hitTest(t,e){return H.trigger("hitTest",t,e)}findPath(t,e,i,r,s){return H.trigger("findPath",t,e,i,r,s)}findPathDirection(t,e,i,r){return H.trigger("findPathDirection",t,e,i,r)}applyImpulse(t,e,i,r){return H.trigger("applyImpulse",t,e,i,r)}createExplosion(t,e,i,r,s,n){return H.trigger("createExplosion",t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return H.trigger("createElipticExplosion",t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=Gt){return H.trigger("printPathfindingTestGrid",t,e,i,r,s,n)}};exports.PhysicsGateway=Do([d()],exports.PhysicsGateway);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},Go=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.ƀy=t,this.ƀhi=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t);this.ƀy.getAvilabilityGrid(a,n,r).map((c,p)=>({position:B.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhi.findPathDirection(t,c.position,i,r),m;p===void 0?m=E.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=E.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new D(m,"alpha",{duration:1e3,animation:P.easeIn}).animate({alpha:0}).tap(()=>m.destroy()).attach(m);}});}createExplosionDebugVisual(t,e,i,r,s,n=300){let a=new f().displayParent(e).setAlpha(.5).attach(t);E.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;E.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new D(a,"alpha",{duration:n,animation:P.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}createElipticExplosionDebugVisual(t,e,i,r,s,n,a=300){let l=new f().displayParent(e).setAlpha(.5).attach(t);E.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;E.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new D(l,"alpha",{duration:a,animation:P.easeIn}).animate({alpha:0}).tap(()=>l.destroy()).attach(l);}createPhysicsEntityShapeVisual(t,e,i){let r=i?.overridePosition??u.arrayToVector(t.position),s=i?.overrideRotation??new helpersLib.Radian(t.angle),n=i?.color??helpersLib.ColorHelper.blue,a=new f().displayParent(e).setPosition(r,{round:false}).setRotation(s).setAlpha(.5).attachToRoot();t.shapes.forEach(c=>{this.ƀcq(c,n).displayParent(a).attachToRoot();}),new D(a,"alpha",{duration:1e3,animation:P.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀcq(t,e){switch(t.type){case U__default.default.Shape.PARTICLE:throw new Error("Not implemented");case U__default.default.Shape.LINE:throw new Error("Not implemented");case U__default.default.Shape.PLANE:throw new Error("Not implemented");case U__default.default.Shape.CIRCLE:throw new Error("Not implemented");case U__default.default.Shape.CAPSULE:throw new Error("Not implemented");case U__default.default.Shape.BOX:throw new Error("Not implemented");case U__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case U__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 E.createPolygon(i,e).toSprite()}};Q=Bo([d(),Go("design:paramtypes",[nt,Ft])],Q);var Vo=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},Lo=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.ƀjy=t;}hitTest(t,e){let i=t.world,r=b.getFromP2BodyIDOrFail(t.id),s=u.cloneP2Body(t);this.ƀs(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdj(s)).map(l=>b.getFromP2BodyIDOrFail(l.id)).filter(l=>l.includeInPathfinding).filter(l=>r.canCollideWith(l)).map(l=>u.cloneP2Body(l.p2Body)),a=false;if(n.length!==0){let l=new U__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.ƀjy.createPhysicsEntityShapeVisual(t,e.testLayerID,{overridePosition:e.overridePosition,overrideRotation:e.overrideRotation,color:l});}return a}ƀs(t,e){e?.overridePosition&&(t.position=u.vectorToArray(e.overridePosition)),e?.overrideRotation&&(t.angle=e.overrideRotation.value);}ƀdj(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Ne=Vo([d(),Lo("design:paramtypes",[Q])],Ne);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},je=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀih(t,i);});});}step(t,e,i){b.getPhysicsEntities().forEach(r=>{r.ƀax=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀih(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀes(r.p2Body),r.entity.ƀiz(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀes(t){let e=u.arrayToVector(t.velocity);e.length>yi&&(e=e.normalize(yi),t.velocity=u.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-wi),wi);}ƀih(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.ƀdo(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);}ƀdo(t,e,i){let r=t.convertToDTO(),s=e.convertToDTO(),n=u.arrayToVector(i.contactPointA),a=u.arrayToVector(i.contactPointB),{normalA:l,normalB:c}=this.ƀed(i);return {collisionDetailsA:this.ƀdn(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀdn(s,i.bodyB.mass,a,c,e.area)}}ƀdn(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}}ƀed(t){let e=u.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};je=jo([d()],je);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},Wo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends se{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=Ho([ft(),Wo("design:paramtypes",[Number,Object])],He);var Uo=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},W=1e4,We=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbr(t,new helpersLib.Vector(e.x/2,-W/2),new helpersLib.Vector(e.x+W*2,W),i),this.ƀbr(t,new helpersLib.Vector(e.x/2,e.y+W/2),new helpersLib.Vector(e.x+W*2,W),i),this.ƀbr(t,new helpersLib.Vector(-W/2,e.y/2),new helpersLib.Vector(W,e.y+W*2),i),this.ƀbr(t,new helpersLib.Vector(e.x+W/2,e.y/2),new helpersLib.Vector(W,e.y+W*2),i);}ƀbr(t,e,i,r){return new He(t,{shapeDefinition:{materialName:ot,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};We=Uo([d()],We);var ko=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},nr=new U__default.default.Material,zo={id:ot,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 U__default.default.Material),n.set(a.id,a);}),s.has(ot))throw new Error(`Material with name ${ot} cannot be defined, pick another name for the material.`);return s.set(ot,nr),n.set(ot,zo),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀeb(e,i.materials)}getMaterialDefinition(t,e){let i=v.getInstanceByIDOrFail(t);return this.ƀea(e,i.materialDefinitions)}ƀeb(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀea(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.ƀdt(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀeb(n.materialA,s),l=this.ƀeb(n.materialB,s);t.addContactMaterial(new U__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀdt(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.ƀeb(s.id,r);t.addContactMaterial(new U__default.default.ContactMaterial(n,nr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};_t=ko([d()],_t);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},Yo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Vt=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgj=t,this.ƀah=e,this.ƀy=i,this.ƀay=r,this.ƀhm=s;}createPhysicsWorld(t){let e=new U__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgj.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhm.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.ƀah.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀay.registerPhysicsWorld(a),t.modifyUpdateCycle?y.registerUpdateModifier((l,c)=>this.ƀjs(a,l,c)):y.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀjs(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=v.getInstanceByIDOrFail(t);if(i){let a=this.ƀy.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀy.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀy.onBodyAdded(n,e,r),true}removeBody(t,e){v.getInstanceByID(t)?.p2World.removeBody(e);}ƀjs(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.ƀay.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);}};Vt=Jo([d(),Yo("design:paramtypes",[_t,We,nt,je,K])],Vt);var Ko=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,"RayCastingService");}castClosest(t,e,i){let r=new U__default.default.RaycastResult,s=new U__default.default.Ray({mode:U__default.default.Ray.CLOSEST,from:u.vectorToArray(e.from),to:u.vectorToArray(e.to),collisionGroup:t.physicsBodyGroupToP2Group.get(i),collisionMask:t.physicsBodyGroupToP2Mask.get(i)});if(t.p2World.raycast(r,s),r.hasHit())return this.ƀbm(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new U__default.default.Ray({mode:U__default.default.Ray.ALL,from:u.vectorToArray(e.from),to:u.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.ƀbm(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbm(n,e));},"callback")});return t.p2World.raycast(new U__default.default.RaycastResult,s),Array.from(r.values())}ƀbm(t,e){let i=t.fraction,r=u.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}}};Nt=Ko([d()],Nt);var Zo=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(u.vectorToArray(s),n);}};lt=Zo([d()],lt);var Qo=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,"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.ƀbn(r,t.length))}ƀbn(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=u.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")}}}};jt=Qo([d()],jt);var tn=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},en=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},on=15,$e=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀid=t,this.ƀjy=e,this.ƀic=i,this.ƀfg=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=v.getInstanceByIDOrFail(t),c=this.ƀcc(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀic.toExplosionHits(c,false);return this.ƀq(p,n),a?.testLayerID&&this.ƀjy.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:g,...R}=m;return R})}ƀcc(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/on),R=i.y/(g*2+1)*2,bt=l.normalize(R),oe=i.x,hr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(g).forEach(pt=>{let Pt=R*(pt+1),Ti=bt.multiplyNumber(pt+1),ne=c.normalize(this.ƀem(oe,hr,Pt)),ae=t.add(Ti);a.push(new helpersLib.Line(ae,ae.add(ne))),a.push(new helpersLib.Line(ae,ae.add(ne.multiplyNumber(-1))));let he=t.add(Ti.multiplyNumber(-1));a.push(new helpersLib.Line(he,he.add(ne))),a.push(new helpersLib.Line(he,he.add(ne.multiplyNumber(-1))));}),a.map(pt=>{if(s){let Pt=this.ƀid.castClosest(n,pt,r);return {line:pt,hits:Pt?[Pt]:[]}}else {let Pt=this.ƀid.castAllFirstContacts(n,pt,r);return {line:pt,hits:Pt}}})}ƀem(t,e,i){return Math.sqrt(1-Math.pow(i,2)/e)*t}ƀq(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.ƀfg.applyImpulse(r.body,r.hitPosition(),s,n);});});}};$e=tn([d(),en("design:paramtypes",[Nt,Q,jt,lt])],$e);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)},ke=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀid=t,this.ƀjy=e,this.ƀic=i,this.ƀfg=r;}createExplosion(t,e,i,r,s,n){let a=v.getInstanceByIDOrFail(t),l=this.ƀej(i),c=this.ƀcc(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀic.toExplosionHits(c);return this.ƀq(e,i,s,l,p),n?.testLayerID&&this.ƀjy.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcc(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.ƀid.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀid.castAllFirstContacts(n,p,i);return {line:p,hits:m}}})}ƀq(t,e,i,r,s){s.forEach(n=>{if(n.isExternal)n.raycastResults.forEach(a=>{let l=i*(1-a.fraction);this.ƀfg.applyImpulse(a.body,a.hitPosition(),a.line.fromTo,l);});else {let a=helpersLib.Vector.fromTo(t,u.arrayToVector(n.p2Body.position)),l=a.length/e,c=i*r*l/2;this.ƀfg.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀej(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};ke=nn([d(),an("design:paramtypes",[Nt,Q,jt,lt])],ke);var dn=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},Ht=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)}};Ht=dn([d()],Ht);var fn=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},un=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.ƀht=t,this.ƀhi=e,this.ƀjy=i,this.ƀdb=r,this.ƀcu=s,this.ƀex=n,this.ƀhs=a,this.ƀfg=l;}createPhysicsWorld(t){return this.ƀht.createPhysicsWorld(t)}getMapSize(t){return this.ƀhs.getMapSize(t)}setPaused(t,e){this.ƀht.setPaused(t,e);}hitTest(t,e){let i=b.getPhysicsInstanceOrFail(t);return this.ƀex.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhi.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhi.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=b.getPhysicsInstanceOrFail(t);this.ƀfg.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀdb.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.ƀjy.printPathfindingTestGrid(t,e,i,r,s,n);}};Pi=fn([q({controllerLink:H}),un("design:paramtypes",[Vt,Ft,Q,ke,$e,Ne,Ht,lt])],Pi);var mn=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},ze=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.ƀbt(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbt(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀcb(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀcd(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbt(t,e,i,r,s,n){let a=new U__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀcb(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(g=>new U__default.default.Convex({vertices:g.map(R=>[R.x,R.y]),collisionGroup:a,collisionMask:l})).map(g=>(g.material=i,g)),p=c.reduce((g,R)=>g+R.area,0),m=new U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(g=>m.addShape(g)),m.setDensity(r.density),m}ƀcd(t,e,i,r,s,n){let a=new U__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 U__default.default.Body({type:n==="dynamic"?U__default.default.Body.DYNAMIC:U__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ze=mn([d()],ze);var gn=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},yn=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.ƀht=t,this.ƀhr=e,this.ƀjf=i,this.ƀhs=r,this.ƀhm=s;}createBody(t,e,i,r,s){return this.ƀjf.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀhr.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀhr.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhm.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhm.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀht.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀht.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀhs.subscribeToPhysicsStep(t,e)}};Si=gn([q({controllerLink:X}),yn("design:paramtypes",[Vt,_t,ze,Ht,K])],Si);exports.AnimationFlicker=Oi;exports.AnimationInterpolationFunctions=z;exports.Animations=P;exports.Animator=D;exports.BORDER_MATERIAL_NAME=ot;exports.BardLegendsHardReset=F;exports.Camera=Qt;exports.ClosestAvailableSpaceHelper=Yt;exports.Container=f;exports.ControllerDecorator=q;exports.ControllerLink=$;exports.DEFAULT_SHADER_RESOLUTION=O;exports.DeltaTime=ei;exports.DisplayObjectArray=ci;exports.Entity=k;exports.EntityDecorator=ft;exports.FadeInContent=Gi;exports.FadeInStateAnimation=ve;exports.Game=w;exports.Graphics=E;exports.ImmovablePhysicsEntity=se;exports.MenuEntity=di;exports.MenuUI=ee;exports.MenuView=fi;exports.MovableEntity=xi;exports.MovablePhysicsEntity=vi;exports.PathFinder=Xt;exports.PhysicsEntity=b;exports.Placeholder=ai;exports.PositionConversionHelper=Ut;exports.ROTATIONAL_SPEED_LIMIT=wi;exports.RichText=hi;exports.SPEED_LIMIT=yi;exports.Scene=le;exports.SceneDecorator=br;exports.ScrollAreaUI=ui;exports.ScrollMaskUI=yt;exports.Service=T;exports.ServiceDecorator=d;exports.SingletonEntity=ut;exports.SlideInContent=Hi;exports.SlideInContentByIndex=ti;exports.SlideStateAnimation=Te;exports.Sprite=Y;exports.StateAnimation=xe;exports.Text=te;exports.UpdatableContainer=li;exports.UpdateCycle=y;exports.VectorFieldPathFinder=Kt;exports.VectorSet=xt;exports.View=dt;exports.ViewDecorator=Ye;
67
+ }`,e}constructor(t,e){if(super(o.ƀep(),o.ƀdx(t*G)),this.ƀdc=t,this.resolution=G,this.ƀdc=t*G,this.ƀdc<0)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be smaller than 0");if(this.ƀdc>10)throw new Error("ExpandWithColorFilter: Expand * resolution cannot be higher than 10");helpersLib.Comparator.isInteger(this.ƀdc)||(this.ƀdc=Math.floor(this.ƀdc));let i=helpersLib.ColorHelper.normalize(e);this.uniforms.color=new Float32Array([i.red,i.green,i.blue]),this.uniforms.expandSquared=this.ƀdc*this.ƀdc,this.padding=this.ƀdc;}apply(t,e,i,r){this.uniforms.pixelSize=new Float32Array([1/(e.width*G),1/(e.height*G)]),t.applyFilter(this,e,i,r);}};var be=class extends j__namespace.Filter{static{h(this,"GlowFilter");}constructor(t){super(),this.resolution=G;let e={blurRadius:1,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Screen,...t};this.ƀdd=new ve(e.expand,e.color);let i=helpersLib.Comparator.isNumber(e.blurRadius)?new helpersLib.Vector(e.blurRadius,e.blurRadius):e.blurRadius;this.ƀai=new Ot(i),this.padding=Math.max(i.x,i.y)+e.expand,this.ƀai.blendMode=j__namespace.BLEND_MODES.SCREEN;}apply(t,e,i,r){let s=t.getFilterTexture();this.ƀdd.apply(t,e,s,j__namespace.CLEAR_MODES.CLEAR),this.ƀai.apply(t,s,i,r),t.returnFilterTexture(s);}};var kt=class o{static{h(this,"GlowSpriteGenerator");}static{this.ƀes=new Map;}static createGlowSpriteFromSprite(t,e,i){let r=this.ƀbg(e),s=helpersLib.Comparator.isNumber(r.blurRadius)?new helpersLib.Vector(r.blurRadius,r.blurRadius):r.blurRadius,n=this.ƀdz(t.texture,s,r.expand,r.color,i),a=new j__namespace.Sprite(n);return this.ƀjn(a,helpersLib.Vector.fromVec2(t.anchor),Math.max(s.x,s.y)+r.expand),a.alpha=r.glowAlpha,a.blendMode=r.blendMode,a}static ƀdz(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.ƀes.has(n))return o.ƀes.get(n);{let a=this.ƀea(t,e,i,r);return o.ƀes.set(n,a),a}}else return this.ƀea(t,e,i,r)}static ƀea(t,e,i,r){let s=new j__namespace.Sprite(t);this.ƀdf(s,Math.max(e.x,e.y)+i),s.filters=[new be({blurRadius:e,expand:i,color:r})];let n=x.instance.renderer.generateTexture(s);return n.id=F.insertAsset(n),s.destroy(),n}static ƀjn(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 ƀdf(t,e){if(t.isSprite){let s=new j__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 ƀbg(t){let e={glowAlpha:1,blurRadius:5,expand:0,color:helpersLib.ColorHelper.white,blendMode:exports.BlendMode.Add};return t&&(e={...e,...t}),e}};I.onHardReset.subscribe(()=>{kt.ƀes.clear();}).attachToRoot();var J=class o extends u{static{h(this,"Sprite");}static createByName(t){let e=x.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.ƀii,i=e.parent;i&&i.removeChild(e);let r=x.instance.renderer.generateTexture(e,{resolution:2,scaleMode:j__namespace.SCALE_MODES.LINEAR,multisample:j__namespace.MSAA_QUALITY.HIGH});i&&i.addChild(e);let n={id:F.insertAsset(r),scale:t.scale,size:t.size,anchor:helpersLib.Vector.zero,destroyAssetOnDestroy:true};return new o(n,{ignoreAnchor:true})}constructor(t,e={}){if(super(),this.ƀku=1,!t)throw new Error("Sprite: spriteDefinition cannot be nullish!");this.ƀkb=t,this.pixiSprite=new j__namespace.Sprite(F.getAsset(t.id)),this.ƀii.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.ƀgm?.destroy(),this.ƀak?.destroy(),this.ƀkb.destroyAssetOnDestroy&&(F.destroyAsset(this.ƀkb.id),this.ƀij&&F.destroyAsset(this.ƀij.texture.id)),this.ƀij&&!this.ƀij.destroyed&&this.ƀij.destroy());}setTextureScale(t){return this.textureScale=t,this}get textureScale(){return this.ƀku}set textureScale(t){this.ƀku=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.ƀkb.boundingShapes&&!this.ƀii.hitArea&&(this.ƀii.hitArea=new os(this.ƀkb.boundingShapes,this.size,helpersLib.Vector.fromVec2(this.ƀkb.anchor)));}setMipmap(t){return this.mipmap=t,this}get mipmap(){return this.pixiSprite.texture.baseTexture.mipmap===j__namespace.MIPMAP_MODES.ON}set mipmap(t){t?this.pixiSprite.texture.baseTexture.mipmap=j__namespace.MIPMAP_MODES.ON:this.pixiSprite.texture.baseTexture.mipmap=j__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 j__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.ƀij)return this.ƀij.alpha;throw new Error("Sprite: getGlowFilterAlpha cannot be called before glow filter is added.")}set glowAlpha(t){if(this.ƀij)this.ƀij.alpha=t;else throw new Error("Sprite: setGlowFilterAlpha cannot be called before glow filter is added.")}getAlignmentVector(t){let e=helpersLib.Vector.fromVec2(this.ƀkb.anchor).to(t);return new helpersLib.Vector(this.size.x*e.x,this.size.y*e.y)}setGlowEffect(t){return this.ƀij&&(this.ƀij.destroy(),this.ƀij=void 0),t&&(this.ƀij=kt.createGlowSpriteFromSprite(this.pixiSprite,t,!this.ƀkb.destroyAssetOnDestroy),this.ƀij.position.set(this.pixiSprite.x,this.pixiSprite.y),this.ƀij.scale.set(this.pixiSprite.scale.x,this.pixiSprite.scale.y),this.ƀii.addChild(this.ƀij)),this}showBoundingShape(t){return t?this.ƀak||(this.ƀak=this.ƀbv().setAlpha(.3).setTint({r:0,g:0,b:200}).displayParent(this)):this.ƀak&&(this.ƀak.destroy(),this.ƀak=void 0),this}getBoundingMask(){if(!this.ƀgm){if(!this.ƀkb.boundingShapes)throw new Error("Sprite: cropOverflowingParts cannot be used without polygonDefinition!");this.ƀgm=this.ƀbv(),this.ƀgm.pixiSprite._maskRefCount=Number.POSITIVE_INFINITY,this.ƀgm.pixiSprite.renderable=false,this.ƀgm.displayParent(this);}return this.ƀgm}ƀbv(){if(!this.ƀkb.boundingShapes)throw new Error("Sprite: bounding shape cannot be created without polygonDefinition!");return A.createPolygon(this.ƀkb.boundingShapes,helpersLib.ColorHelper.white).toSprite().attach(this)}download(){let t=x.instance.renderer.extract.canvas(this.ƀii);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}},os=class{static{h(this,"CompositeHitArea");}constructor(t,e,i){this.ƀju=t.map(r=>new j__namespace.Polygon(r.map(s=>new j__namespace.Point(s.x,s.y))));}contains(t,e){return this.ƀju.some(i=>i.contains(t,e))}};var Se=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),y=c-p*m;m>=1&&y<i.dashLength&&(y+=p,m--);let D=s.normalize(y/2),Et=s.normalize(i.dashGap);if(a.push({from:l,to:l.add(D)}),l=l.add(D),m>0){let ne=s.normalize(i.dashLength);helpersLib.ArrayHelper.createEmptyArray(m).forEach(()=>{l=l.add(Et),a.push({from:l,to:l.add(ne)}),l=l.add(ne);});}return l=l.add(Et),a.push({from:l,to:l.add(D)}),a}};var A=class o extends u{static{h(this,"Graphics");}static{this.ƀcu=new Map;}static createArrow(t,e){let i=new j__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 j__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 j__namespace.Graphics;return s.lineStyle(r.width,r.color),Se.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 j__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 j__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 j__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 j__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 j__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 j__namespace.Graphics,r=JSON.stringify({type:"polygon",polygon:t,color:e});return i.beginFill(e),t.forEach(s=>{i.drawPolygon(s.map(n=>new j__namespace.Point(n.x,n.y)));}),i.endFill(),new o(i,r)}static createRegularPolygon(t,e,i){let r=new j__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.ƀii.addChild(t),this.pixiGraphics=t,this.ƀan=e;}destroy(){this.destroyed||(super.destroy(),!this.pixiGraphics.destroyed&&this.pixiGraphics.destroy());}toSprite(t){let e={cacheName:this.ƀan,cache:false,...t},i=this.ƀem(e.cacheName,e.cache),r={id:i.textureID,scale:1,size:i.bounds,anchor:{x:0,y:0},destroyAssetOnDestroy:!e.cache},s=new J(r,{texturePosition:i.bounds,ignoreAnchor:true});return this.attachToRoot(),this.destroy(),s}ƀem(t,e){if(e){let i=o.ƀcu.get(t);return i||(i=this.ƀch(),o.ƀcu.set(t,i)),i}else return this.ƀch()}ƀch(){let t=x.instance.renderer.generateTexture(this.pixiGraphics);t.id=F.insertAsset(t);let e=this.pixiGraphics.getBounds();return {textureID:t.id,bounds:new helpersLib.Vector(e.x,e.y)}}};var Qe=class{static{h(this,"AnimationEaseInOutFlatter");}start(){}multiplierFunction(t){return 3*(1-t)*Math.pow(t,2)+Math.pow(t,3)}},xt=class o extends u{static{h(this,"ScrollMaskUI");}static{this.ƀcu=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.ƀcb(e,i,s):this.ƀci(e,i,s),this.ƀgm=J.createSnapshotSprite(s).attach(this),s.destroy(),t.setMask(this.ƀgm);}ƀci(t,e,i){e>0&&this.ƀby(new helpersLib.Vector(t.x,e)).displayParent(i).attach(i),A.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.ƀby(new helpersLib.Vector(t.x,e)).setPosition(new helpersLib.Vector(t.x,t.y),{round:false}).setRotation(helpersLib.Radian.get180).displayParent(i).attach(i);}ƀcb(t,e,i){e>0&&this.ƀby(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(0,t.y),{round:false}).setRotation(helpersLib.Radian.get270).displayParent(i).attach(i),A.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.ƀby(new helpersLib.Vector(t.y,e)).setPosition(new helpersLib.Vector(t.x,0),{round:false}).setRotation(helpersLib.Radian.get90).displayParent(i).attach(i);}ƀby(t){let i={id:this.ƀbz(t.y),scale:1,size:t,anchor:{x:0,y:0}};return new J(i,{textureSize:t,ignoreAnchor:true})}ƀbz(t){let e=JSON.stringify({type:"gradient",length:t}),i=o.ƀcu.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 Qe;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=j__namespace.Texture.from(r);i=F.insertAsset(a),o.ƀcu.set(e,i);}else throw new Error("Canvas context is null")}return i}};exports.SlideStateAnimationState=void 0;(function(o){o[o.Appear=1]="Appear",o[o.Disappear=2]="Disappear";})(exports.SlideStateAnimationState||(exports.SlideStateAnimationState={}));var P;(function(o){o[o.Idle=1]="Idle",o[o.TransitionForward=2]="TransitionForward",o[o.TransitionBackward=3]="TransitionBackward",o[o.Reverting=4]="Reverting";})(P||(P={}));var Pe=class extends actionsLib.Attachable{static{h(this,"SlideStateAnimation");}constructor(t){super(),this.ƀo=P.Idle,this.ƀhm=new actionsLib.Action,this.ƀho=new actionsLib.Action,this.ƀhr={duration:500,animation:w.easeInOutCubic,...t},this.ƀkj=new ge({duration:this.ƀhr.duration,animation:this.ƀhr.animation}).onStateChange((e,i)=>this.ƀey(e,i)).onValueChange(e=>this.ƀez(e)).attach(this);}setIndex(t,e){if(!helpersLib.Comparator.isInteger(t))throw new Error("SlideStateAnimation: index must be an integer!");this.ƀfn===void 0?(this.ƀfn=t,this.ƀhm.trigger({state:exports.SlideStateAnimationState.Appear,index:t}),this.ƀkj.setState(t,e)):this.ƀfn!==t?this.ƀhd!==t?this.ƀo===P.Idle?(this.ƀo=t>this.ƀfn?P.TransitionForward:P.TransitionBackward,this.ƀhd=t,this.ƀhm.trigger({state:exports.SlideStateAnimationState.Appear,index:this.ƀhd}),this.ƀkj.setState(t,e)):this.ƀkj.setState(t,e):this.ƀo===P.Reverting&&this.ƀhd===t&&(this.ƀo=t>this.ƀfn?P.TransitionForward:P.TransitionBackward,this.ƀkj.setState(t,e)):(this.ƀo===P.TransitionForward||this.ƀo===P.TransitionBackward)&&(this.ƀo=P.Reverting,this.ƀkj.setState(t,e));}ƀey(t,e){switch(this.ƀfn!==void 0&&this.ƀfn!==t&&this.ƀfn!==e&&this.ƀhm.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀfn}),this.ƀhd!==void 0&&this.ƀhd!==t&&this.ƀhd!==e&&this.ƀhm.trigger({state:exports.SlideStateAnimationState.Disappear,index:this.ƀhd}),e!==void 0&&e!==this.ƀfn&&e!==this.ƀhd&&this.ƀhm.trigger({state:exports.SlideStateAnimationState.Appear,index:e}),this.ƀo){case P.Idle:break;case P.TransitionForward:case P.TransitionBackward:e===void 0?(this.ƀo=P.Idle,this.ƀfn=this.ƀhd,this.ƀhd=void 0):this.ƀfn!==t&&this.ƀev(t,e);break;case P.Reverting:e===void 0?(this.ƀo=P.Idle,this.ƀhd=void 0):this.ƀfn!==e&&this.ƀev(t,e);break;default:{this.ƀo;throw new Error(`Unexpected case! "${this.ƀo}"`)}}}ƀez(t){let e=1;(this.ƀo===P.TransitionBackward||this.ƀo===P.Reverting&&this.ƀfn!==void 0&&this.ƀhd!==void 0&&this.ƀfn>this.ƀhd)&&(e=-1),(this.ƀo===P.Idle||t!==0)&&this.ƀho.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(-e*t),index:this.ƀfn}),this.ƀhd!==void 0&&this.ƀho.trigger({value:helpersLib.NumberHelper.ensurePositiveZero(e*(1-t)),index:this.ƀhd});}ƀev(t,e){this.ƀfn=t,this.ƀhd=e,this.ƀho.trigger({value:0,index:this.ƀfn}),this.ƀo=this.ƀfn<this.ƀhd?P.TransitionForward:P.TransitionBackward;}onStateChange(t){return this.ƀhm.subscribe(e=>t(e.state,e.index)).attach(this),this}onValueChange(t){return this.ƀho.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 qe=class extends u{static{h(this,"SlideInContentByIndex");}constructor(t,e){super(),this.ƀbx=t,this.ƀcp="x",this.ƀbn=new Map,this.ƀhr={duration:300,animation:w.easeInOutCubic,size:new helpersLib.Vector(500,500),margin:20,direction:exports.ScrollDirection.Horizontal,...e};let i=this.ƀhr.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(this.ƀhr.size.x+this.ƀhr.margin*2,this.ƀhr.size.y):new helpersLib.Vector(this.ƀhr.size.x,this.ƀhr.size.y+this.ƀhr.margin*2),r=new u().setPosition(this.ƀhr.direction===exports.ScrollDirection.Horizontal?new helpersLib.Vector(-this.ƀhr.margin,0):new helpersLib.Vector(0,-this.ƀhr.margin),{round:false}).displayParent(this).attach(this);this.ƀcc(i,this.ƀhr.margin,this.ƀhr.direction,r),this.ƀcp=this.ƀhr.direction===exports.ScrollDirection.Horizontal?"x":"y",this.ƀkj=new Pe({duration:this.ƀhr.duration,animation:this.ƀhr.animation}).onStateChange((s,n)=>{if(s===exports.SlideStateAnimationState.Appear){let a=new u().displayParent(this).attach(this);this.ƀbn.set(n,a),this.ƀbx({index:n,container:a});}else {let a=this.ƀbn.get(n);a&&(a.destroy(),this.ƀbn.delete(n));}}).onValueChange((s,n)=>{let a=this.ƀbn.get(n);if(a){let l={x:0,y:0};l[this.ƀcp]=i[this.ƀcp]*s+this.ƀhr.margin,a.setPosition(helpersLib.Vector.fromVec2(l),{round:false});}}).attach(this),this.addChildTo=r;}setIndex(t,e){return this.ƀkj.setIndex(t,e),this}ƀcc(t,e,i,r){new xt(r,new helpersLib.Vector(t.x,t.y),e,i).attach(this);}},ji=class extends qe{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 bt=class{static{h(this,"VectorSet");}constructor(){this.ƀlg=new Map;}add(t){let e=this.ƀlg.get(t.x);e||(e=new Set,this.ƀlg.set(t.x,e)),e.add(t.y);}has(t){let e=this.ƀlg.get(t.x);return e?e.has(t.y):false}delete(t){let e=this.ƀlg.get(t.x);return e?e.delete(t.y):false}};var ti=class{static{h(this,"DeltaTime");}static adjustMultiplier(t,e){return Math.pow(t,e)}};var V=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 Yt=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=V.areaToGridArea(e,i);if(this.ƀau(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 bt,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.ƀau(t,a))return helpersLib.Vector.fromTo(e,n);t.getNeighborPositions(n,helpersLib.GridNeighborType.Ortogonal).forEach(l=>{r.has(l)||s.add(l);});}}static ƀau(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 Ui=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)}},Ss=class{static{h(this,"PathfinderGrid");}constructor(t,e){this.ƀeu=t,this.ƀkf=e,this.ƀhq=new helpersLib.BinaryHeap("min"),this.ƀaz=[],this.ƀhf=new helpersLib.Grid({size:t.size,defaultValue:void 0});let i=new Ui(this.ƀkf,0,Number.MAX_SAFE_INTEGER);this.ƀhq.add(i.pathLength,i);}get hasOpenNodes(){return this.ƀhq.size>0}getNeighbors(t,e){return this.ƀeu.getNeighborPositions(t.position,e).filter(i=>this.ƀeu.get(i)).map(i=>this.ƀhf.get(i)||this.ƀcd(i))}popLowestPathCostNode(){let t=this.ƀhq.pop();return this.ƀhq.delete(t),t.closed=true,this.ƀaz.push(t),t}changeNodeCost(t,e,i,r){this.ƀhq.delete(t),t.distanceFromStart=e,t.distanceToEnd=t.getDistance(i),t.parent=r,this.ƀhq.add(t.pathLength,t);}getBestClosedNode(){return this.ƀaz.reduce((t,e)=>t.distanceToEnd<e.distanceToEnd?t:e)}ƀcd(t){let e=new Ui(t,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER);return this.ƀhf.set(t,e),this.ƀhq.add(e.pathLength,e),e}},Xt=class{static{h(this,"PathFinder");}static findPath(t,e,i,r){let s=new Ss(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 Kt=class{static{h(this,"VectorFieldPathFinder");}constructor(t,e){this.ƀko=t,this.ƀy=e,this.ƀfb=this.ƀec(this.ƀy.size),this.ƀlo=new helpersLib.Grid({size:this.ƀy.size,defaultValue:this.ƀfb}),this.ƀcq=new helpersLib.Grid({size:this.ƀy.size,defaultValue:void 0});let i=new bt,r=new helpersLib.Queue;for(this.ƀdp(this.ƀy.cropAreaOutsideOfTheGrid(t)).forEach(n=>{this.ƀlo.set(n,0),r.add(n);});r.notEmpty;){let n=r.pop();if(!i.has(n)){i.add(n);let a=this.ƀlo.getOrFail(n);this.ƀeh(n,this.ƀy).forEach(l=>{if(!i.has(l.position)){let c=this.ƀlo.getOrFail(l.position),p=a+l.distance;this.ƀy.getOrFail(l.position)&&p<c&&(this.ƀlo.set(l.position,p),r.add(l.position));}});}}}getDirectionToTarget(t){if(!t.isInsideRectangle(this.ƀko)){if(t=this.ƀlo.movePositionInsideGrid(t),this.ƀcq.has(t))return this.ƀcq.get(t);{let e=this.ƀeh(t,this.ƀy),i;return this.ƀlo.getOrFail(t)>=this.ƀfb?e.some(s=>this.ƀy.get(s.position))&&(e.some(n=>!this.ƀy.get(n.position))?i=this.ƀdw(e):i=this.ƀdr(t,e)):i=this.ƀdr(t,e),this.ƀcq.set(t,i),i}}}ƀdw(t){let e=t.filter(i=>this.ƀy.get(i.position)).map(i=>i.direction.radian);return helpersLib.Radian.getAverage(...e)}ƀdr(t,e){let i=e.filter(r=>this.ƀlo.getOrFail(r.position)<this.ƀfb).reduce((r,s)=>{let n=this.ƀlo.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.ƀfb}).bestDirections;return this.ƀen(i,t)}ƀen(t,e){if(t.length>0){let i=t.reduce((r,s)=>r.add(s),helpersLib.Vector.zero);if(i.isZero()||!this.ƀft(e,i))return helpersLib.Random.pickRandomElement(t).radian;if(t.length>=1)return i.radian}}ƀft(t,e){let i=t.add(this.ƀlh(e));return this.ƀy.isPointWithinBounds(i)&&this.ƀy.getOrFail(i)}ƀeh(t,e){return this.ƀlo.getNeighborDirections(t,helpersLib.GridNeighborType.All).map(i=>({position:t.add(i),direction:i,distance:i.x!==0&&i.y!==0?14:10}))}ƀdp(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}ƀlh(t){let e=t.normalize().round();return new helpersLib.Vector(e.x,e.y)}ƀec(t){return (t.x+t.y)*20}};var T=class o{static{h(this,"AudioAssets");}static{this.ƀam=new Map;}static{this.context=new AudioContext;}static async load(t){await Promise.all(t.map(e=>fetch(e.url).then(i=>i.arrayBuffer()).then(i=>this.context.decodeAudioData(i)).then(i=>this.ƀam.set(e.id,i))));}static createSource(t){let e=o.ƀdq(t),i=o.context.createBufferSource();return i.buffer=e,i}static ƀdq(t){let e=this.ƀam.get(t);if(!e)throw new Error(`Audio: Sound with id ${t} was not loaded.`);return e}};I.onHardReset.subscribe(()=>{T.context=new AudioContext,T.ƀam.clear();}).attachToRoot();var Y=class o{static{h(this,"Audio");}static ƀjq(){return this.ƀfq=new o,this.ƀfq}constructor(){this.ƀgp=T.context.createGain(),this.ƀgo=T.context.createGain(),this.ƀhc=T.context.createGain(),this.ƀjx=T.context.createGain(),this.ƀgp.connect(T.context.destination),this.ƀgo.connect(this.ƀgp),this.ƀhc.connect(this.ƀgo),this.ƀjx.connect(this.ƀgo),this.ƀgq=new C(this.ƀgp.gain,"value",{duration:500*2,animation:w.lineer,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState});}setVolumes(t){this.ƀgo.gain.value=t.master,this.ƀhc.gain.value=t.music,this.ƀjx.gain.value=t.sound;}appear(t,e="ease"){let i=t?1:0;switch(e){case "ease":return this.ƀgq.animate({value:i}).chainToRoot();case "instant":return this.ƀgq.set({value:i}),actionsLib.SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}};I.onHardReset.subscribe(()=>{Y.ƀjq();}).attachToRoot();var As=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};exports.CameraGateway=class ot extends Q(){static{h(this,"CameraGateway");}};exports.CameraGateway=As([d()],exports.CameraGateway);var Is=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},Pt=class extends Q(){static{h(this,"CameraViewGateway");}};Pt=Is([d()],Pt);var $i;(function(o){o.BackgroundScreen="backgroundScreen",o.Background="background",o.Main="main",o.Foreground="foreground",o.ForegroundScreen="foregroundScreen";})($i||($i={}));exports.FocusingAnimation=void 0;(function(o){o[o.Instant=1]="Instant",o[o.EaseInOut=2]="EaseInOut",o[o.EaseOut=3]="EaseOut";})(exports.FocusingAnimation||(exports.FocusingAnimation={}));var ii=class extends u{static{h(this,"Placeholder");}constructor(t){super(),this.ƀik=new j__namespace.Graphics,this.ƀik.beginFill(0,1e-9),this.ƀik.drawRect(0,0,t.x,t.y),this.ƀik.endFill(),this.ƀii.addChild(this.ƀik);}destroy(){this.destroyed||(super.destroy(),this.ƀik.destroy());}};var Mt=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 helpersLib.JsonHelper.removeUndefinedProperties({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 Ee=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.ƀfm(r,e),n=this.ƀs(s);return this.ƀjz(n)}static ƀfm(t,e){let i=new Map,r=new Map,s=h((a,l)=>{if(r.has(l))return r.get(l);let c=Mt.getPixiTextStyle(a);return r.set(l,c),c},"GetPixiStyle");return t.map(a=>{let{style:l,cacheKey:c}=this.ƀdu(a.tags,e,i),p=s(l,c),m=j__namespace.TextMetrics.measureText(" ",new j__namespace.TextStyle(p),false);return {text:a.text,cacheKey:c,style:l,pixiStyle:p,spaceWidth:m.width}})}static ƀdu(t,e,i){let r=t.join("+");if(i.has(r))return {style:i.get(r),cacheKey:r};let s=this.ƀbe(t,e);return i.set(r,s),{style:s,cacheKey:r}}static ƀbe(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 ƀjz(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.ƀka(s.text).map(a=>{let l=new j__namespace.TextStyle(s.pixiStyle),c=j__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 ƀka(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 Re=class{static{h(this,"RichTextTypewriter");}get lineIsEmpty(){return this.ƀcl.length===0}get remainingWidth(){return this.ƀlp-this.ƀcn}constructor(t,e){this.ƀlp=t,this.ƀge=[],this.ƀcl=[],this.ƀcn=0,this.ƀgd=new helpersLib.Vector(0,0),this.ƀcm=0;let i={rectangleCutOption:void 0,horizontalAlignment:"left",verticalAlignment:"bottom",...e};if(this.ƀfe=i.horizontalAlignment,this.ƀli=i.verticalAlignment,i.rectangleCutOption){if(i.rectangleCutOption.position.x<0||i.rectangleCutOption.position.x>=this.ƀlp||i.rectangleCutOption.position.y<0)throw new Error("Rectangle cut position is out of bounds");this.ƀco={direction:i.rectangleCutOption.direction,rectangle:this.ƀbr(i.rectangleCutOption)};}}isSpaceAvailable(t){let e=Math.max(this.ƀcm,t.y),i=this.ƀed(this.ƀgd.y,this.ƀgd.y+e);return this.ƀcn+t.x<=i}insertWord(t){let e=Math.max(this.ƀcm,t.style.height);if(this.ƀcl.length===0){let i=this.ƀee(this.ƀgd.y,this.ƀgd.y+e);this.ƀgd=new helpersLib.Vector(i,this.ƀgd.y),this.ƀcn=this.ƀgd.x;}this.ƀcl.push({chunk:t,position:new helpersLib.Vector(this.ƀcn,this.ƀgd.y)}),this.ƀcm=e,this.ƀcn+=t.style.width;}newLine(){let t=this.ƀgd.y+this.ƀcm,e=this.ƀee(t,t);this.ƀdh(),this.ƀgd=new helpersLib.Vector(e,t),this.ƀcn=this.ƀgd.x,this.ƀcm=0;}print(){return this.ƀdh(),this.ƀge}ƀdh(){this.ƀcl.length>0&&(this.ƀge.push(this.ƀg(this.ƀcl)),this.ƀcl=[]);}ƀg(t){return t=this.ƀlk(t),t=this.ƀfg(t),t}ƀfg(t){if(this.ƀfe==="left")return t;let e=this.ƀgd.y+this.ƀcm,i=this.ƀee(this.ƀgd.y,e),s=this.ƀed(this.ƀgd.y,e)-i,n=Math.min(s,t.reduce((l,c)=>l+c.chunk.style.width,0)),a;return this.ƀfe==="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))}ƀlk(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.ƀli){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.ƀli;throw new Error(`Unexpected case! "${this.ƀli}"`)}}return r={chunk:r.chunk,position:new helpersLib.Vector(r.position.x,r.position.y+s)},r})}ƀee(t,e){return this.ƀco&&(this.ƀco.direction==="topLeft"||this.ƀco.direction==="bottomLeft")&&(this.ƀco.rectangle.isPointInside(new helpersLib.Vector(0,t),{includeEdges:false})||this.ƀco.rectangle.isPointInside(new helpersLib.Vector(0,e),{includeEdges:false}))?this.ƀco.rectangle.bottomRight.x:0}ƀed(t,e){return this.ƀco&&(this.ƀco.direction==="topRight"||this.ƀco.direction==="bottomRight")&&(this.ƀco.rectangle.isPointInside(new helpersLib.Vector(this.ƀlp,t),{includeEdges:false})||this.ƀco.rectangle.isPointInside(new helpersLib.Vector(this.ƀlp,e),{includeEdges:false}))?this.ƀco.rectangle.topLeft.x:this.ƀlp}ƀbr(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 Ce=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.ƀlq(r,e);}else e.insertWord(r);else e.lineIsEmpty?e.insertWord(r):r.whitespace?this.ƀlq(r,e):(e.newLine(),e.insertWord(r));}),e.newLine();}),e.print()}static ƀlq(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 Ae=class{static{h(this,"RichTextDataOutConverter");}static process(t){return t=this.ƀgu(t),t=this.ƀkz(t),this.ƀaw(t)}static ƀgu(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 ƀkz(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 ƀaw(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 Zt=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=Ee.process(t,e),r=helpersLib.JsonHelper.removeUndefinedProperties({rectangleCutOption:e.rectangleCut,verticalAlignment:e.verticalAlignment,horizontalAlignment:e.default.align}),s=new Re(e.default.wordWrapWidth??1/0,r),n=Ce.wrapText(i,s);return Ae.process(n)}};var Vs=1,Ji=1/Vs,Qt=class extends u{static{h(this,"Text");}get ƀks(){if(!this.ƀkt){let t=new j__namespace.TextStyle(this.ƀim);this.ƀkt=j__namespace.TextMetrics.measureText(this.ƀkr,t);}return this.ƀkt}get ascent(){return this.ƀks.fontProperties.ascent}constructor(t,e){super(),this.ƀim=Mt.getPixiTextStyle(e),this.setText(t);}destroy(){this.destroyed||(super.destroy(),!this.ƀil.destroyed&&this.ƀil.destroy());}setAnchor(t){return this.anchor=t,this}get anchor(){return new helpersLib.Vector(this.ƀil.anchor.x,this.ƀil.anchor.y)}set anchor(t){this.ƀi=t,this.ƀil.anchor.set(t.x,t.y);}setText(t){return this.ƀkr!==t&&(this.ƀkr=t,this.ƀiu()),this}setColor(t){let e=helpersLib.ColorHelper.rgbToHex(t);return this.ƀim.fill!==e&&(this.ƀim.fill=e,this.ƀiu()),this}ƀiu(){this.ƀil?.destroy(),this.ƀkm?.destroy(),this.ƀkm=void 0,this.ƀkt=void 0;let t=new j__namespace.TextStyle(this.ƀim);this.ƀil=new j__namespace.Text(this.ƀkr,t),this.ƀix(),this.ƀi&&this.ƀil.anchor.set(this.ƀi.x,this.ƀi.y),this.ƀil.scale.set(Ji,Ji),this.ƀii.addChild(this.ƀil),this.ƀim.lineThrough&&(this.ƀkm=this.ƀe(this.ƀil,this.ƀim.fill),this.ƀii.addChild(this.ƀkm));}ƀix(){let t=j__namespace.TextMetrics.measureText(this.ƀkr,new j__namespace.TextStyle({...this.ƀim,dropShadow:false,dropShadowAlpha:0,dropShadowBlur:0,dropShadowDistance:0}));this.ƀil.calculateBounds=function(){this.updateText(true),this._bounds.clear();let e=-this.anchor.x*t.width,i=-this.anchor.y*t.height;this._bounds.addFrame(this.transform,e,i,e+t.width,i+t.height);};}ƀe(t,e){let i=j__namespace.TextMetrics.measureText(t.text,t.style),r=Math.max(1,Math.round(i.lineHeight*.07)),s=r%2*.5,n=new j__namespace.Graphics;n.lineStyle(r,e);let a=0;return i.lines.forEach((l,c)=>{let p=j__namespace.TextMetrics.measureText(l,t.style),m=Math.round(a+(p.fontProperties.ascent-p.fontProperties.descent)*.6+p.fontProperties.descent)+s,y=0;t.style.align==="center"?y=0+(t.width-p.width)*.5:t.style.align==="right"&&(y=0+t.width-p.width),y=Math.floor(y),n.moveTo(Math.floor(y),m),n.lineTo(Math.floor(y+p.width),m),a+=p.lineHeight;}),n.endFill(),n}};var ri=class extends u{static{h(this,"RichText");}constructor(t,e){super(),Zt.process(t,e).forEach(r=>new Qt(r.text,r.style).setPosition(r.position).displayParent(this).attach(this));}};var Ls=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},N=class extends yt{static{h(this,"CameraEntity");}constructor(){super(...arguments),this.position=new actionsLib.Variable(helpersLib.Vector.zero),this.offset=new actionsLib.Variable(helpersLib.Vector.zero),this.targetPosition=new actionsLib.Variable(void 0),this.focusingNewTargetInfo=new actionsLib.Variable(void 0);}};N=Ls([gt()],N);var Oe=class{static{h(this,"PositionConversionHelper");}static includeScaleInScreenPosition(t,e,i){if(e!==1){let r=helpersLib.Vector.fromTo(i,t).multiplyNumber(1/e);return i.add(r)}else return t}};var Hs=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},js=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Tt=class extends mt{static{h(this,"CameraView");}constructor(t){super(),this.ƀda=t,this.ƀkc=(()=>{let e=new u().attach(this);return e.ƀii=x.instance.ƀih.stage,e})(),this.ƀjc=new u().setAlpha(0).displayParent(this.ƀkc).attach(this),this.ƀae=A.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(0).displayParent(this.ƀkc).attach(this),this.ƀac=new u().displayParent(this.ƀjc).attach(this),this.ƀar=new u().displayParent(this.ƀjc).attach(this),this.ƀdk=new u().setSortableChildren(true).displayParent(this.ƀjc).attach(this),this.ƀaq=new u().setSortableChildren(true).displayParent(this.ƀar).attach(this),this.ƀdj=new u().setSortableChildren(true).setZIndex(20).displayParent(this.ƀaq).attach(this),this.ƀgk=new u().setSortableChildren(true).setZIndex(10).displayParent(this.ƀaq).attach(this),this.ƀab=new u().setZIndex(0).displayParent(this.ƀaq).attach(this),this.ƀh=new C(this.ƀjc,"alpha",{duration:500,animation:w.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),this.ƀaf=new C(this.ƀae,"alpha",{duration:500,animation:w.easeInOutCubic,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState}),x.instance.screenSize.subscribe(e=>{this.ƀae.aspectRatio=e.x/e.y,this.ƀae.scale=Math.max(e.x,e.y),this.ƀae.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.zero});}).attach(this),this.ƀda.position.subscribe(e=>{this.ƀaq.position=this.ƀbs(e);}).attach(this),this.ƀda.offset.subscribe(e=>{this.ƀar.position=e;}).attach(this),this.appear(true,"alpha");}screenPositonToStagePosition(t){let e=Oe.includeScaleInScreenPosition(t,this.ƀkc.scale,x.instance.screenSizeCenter.value);return new helpersLib.Vector(e.x-this.ƀaq.position.x-this.ƀar.position.x,e.y-this.ƀaq.position.y-this.ƀar.position.y)}getLayers(){return {backgroundScreen:this.ƀac.id,background:this.ƀab.id,main:this.ƀgk.id,foreground:this.ƀdj.id,foregroundScreen:this.ƀdk.id}}appear(t,e){switch(e){case "alpha":return this.ƀaf.set({alpha:0}),this.ƀh.set({alpha:t?0:1}),this.ƀh.animate({alpha:t?1:0}).chain(this);case "pureBlack":return this.ƀh.set({alpha:1}),this.ƀaf.set({alpha:t?1:0}),this.ƀaf.animate({alpha:t?0:1}).chain(this);case "instant":return this.ƀh.set({alpha:t?1:0}),this.ƀaf.set({alpha:t?0:1}),actionsLib.SingleEvent.instant();default:{throw new Error(`Unexpected case! "${e}"`)}}}ƀbs(t){return helpersLib.Vector.fromTo(t,x.instance.screenSizeCenter.value)}};Tt=Hs([Je({entity:N}),js("design:paramtypes",[N])],Tt);var $s=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},zs=1500,De=class{static{h(this,"CameraService");}createCamera(){return new N().attachToRoot()}getCameraPosition(){let t=N.getInstanceOrFail();return helpersLib.Vector.fromTo(t.offset.value,t.position.value)}setPosition(t){let e=N.getInstanceOrFail();e.targetPosition.value=t;}setTransition(t){let e=N.getInstanceOrFail();e.focusingNewTargetInfo.value={time:x.time,duration:t?.duration??zs,position:e.position.value,roundPosition:t?.roundPosition??false,roundPositionThreshold:t?.roundPositionThreshold??0,focusingAnimation:t?.animation??exports.FocusingAnimation.Instant};}update(t,e){let i=N.getInstanceOrFail(),r=i.targetPosition.value;r&&(i.focusingNewTargetInfo.value?this.ƀfw(i,r,t):i.position.value=r);}ƀfw(t,e,i){let r=t.focusingNewTargetInfo.value;if(r.focusingAnimation===exports.FocusingAnimation.Instant)this.ƀbf(t,e);else {let s=(i-r.time)/r.duration;if(s>=1)this.ƀbf(t,e);else {let n;r.focusingAnimation===exports.FocusingAnimation.EaseInOut?n=H.easeInOut(s):r.focusingAnimation===exports.FocusingAnimation.EaseOut?n=H.easeOut(s):n=1;let a=r.position.lerp(e,n);r.roundPosition&&(Math.abs(a.x-r.position.x)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(Math.round(a.x),a.y)),Math.abs(a.y-r.position.y)>=r.roundPositionThreshold&&(a=new helpersLib.Vector(a.x,Math.round(a.y)))),t.position.value=a;}}}ƀbf(t,e){t.position.value=e,t.focusingNewTargetInfo.value=void 0;}};De=$s([d()],De);var ks=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},Js=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},oi=class{static{h(this,"CameraController");}constructor(t){this.ƀas=t;}createCamera(){return this.ƀas.createCamera().id}update(t,e){this.ƀas.update(t,e);}setPosition(t){this.ƀas.setPosition(t);}setTransition(t){this.ƀas.setTransition(t);}getCameraPosition(){return this.ƀas.getCameraPosition()}};oi=ks([q(exports.CameraGateway),Js("design:paramtypes",[De])],oi);var Ys=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},ni=class{static{h(this,"CameraViewController");}getLayers(){let t=N.getInstanceOrFail().id;return Tt.getInstanceOrFail(t).getLayers()}appear(t,e){let i=N.getInstanceOrFail().id;return Tt.getInstanceOrFail(i).appear(t,e)}screenPositonToStagePosition(t){let e=N.getInstanceOrFail().id;return Tt.getInstanceOrFail(e).screenPositonToStagePosition(t)}};ni=Ys([q(Pt)],ni);var te=class{static{h(this,"Camera");}get position(){return this.ƀap.getCameraPosition()}constructor(){this.ƀap=E.get(exports.CameraGateway),this.ƀat=E.get(Pt),this.ƀap.createCamera(),this.layers=this.ƀat.getLayers();}setPosition(t){this.ƀap.setPosition(t);}setTransition(t){this.ƀap.setTransition(t);}appear(t,e="alpha"){return this.ƀat.appear(t,e)}screenPositonToStagePosition(t){return this.ƀat.screenPositonToStagePosition(t)}};var x=class o{static{h(this,"Game");}static get instance(){return this.ƀfq}static{this.pause=actionsLib.Reducer.createOr();}static{this.freeze=actionsLib.Reducer.createOr();}static get camera(){return this.ƀao}static get audio(){return this.ƀx}static appear(t,e){let i=e?.audio??"ease",r=e?.camera??"alpha";return actionsLib.ActionLib.all([this.audio.appear(t,i),actionsLib.SingleEvent.instant().asyncTap(()=>i!=="instant"&&g.wait(500)).asyncTap(()=>this.camera.appear(t,r))]).mapToVoid().chainToRoot()}static get time(){return g.ƀkv}static get setupOptions(){return this.ƀjs}constructor(t){if(this.ƀjf=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSize=this.ƀjf.notifier,this.ƀjg=new actionsLib.Variable(helpersLib.Vector.zero),this.screenSizeCenter=this.ƀjg.notifier,this.devMode=false,o.ƀfq)throw new Error("There can be only one Game instance!");this.ƀbj={screenResolution:void 0,maxScreenResolution:void 0,devMode:false,backgroundColor:helpersLib.ColorHelper.black,antialias:false,resolution:1,...t},this.devMode=this.ƀbj.devMode||false;let e=helpersLib.JsonHelper.removeUndefinedProperties({backgroundColor:this.ƀbj.backgroundColor,autoStart:false,antialias:this.ƀbj.antialias,resolution:this.ƀbj.resolution,width:this.ƀbj.screenResolution?.width,height:this.ƀbj.screenResolution?.height});this.ƀih=new j__namespace.Application(e);let i=o.pause.effect(false).attachToRoot();o.freeze.subscribe(r=>{i.update(r),r?T.context.suspend():T.context.resume();}).attachToRoot();}async setup(t){o.ƀjs=t;let e=document.body.appendChild(this.ƀih.view);this.ƀjp(e),await Promise.all([F.loadGameAssets(t.spriteAssetDefinitions),F.loadGameAssets(t.fontAssetDefinitions),T.load(t.soundAssetDefinitions)]),o.ƀfq=this,this.renderer=this.ƀih.renderer,globalThis.ƀa=this.ƀih,this.ƀew(),o.ƀao=new te,o.ƀx=Y.ƀjq(),this.ƀih.start(),this.ƀih.ticker.add(()=>{o.freeze.value||g.triggerUpdateTick(this.ƀih.ticker.deltaMS);});}setResolution(t){if(this.ƀih.renderer.resolution!==t){this.ƀih.renderer.resolution=t;let e=this.ƀel();this.ƀih.renderer.resize(e.x,e.y);}}ƀew(){this.ƀcy(),this.ƀjo(),window.addEventListener("resize",t=>{this.ƀcy(),this.ƀjo();});}ƀcy(){let t=this.ƀel();(t.x!==this.ƀih.screen.width||t.y!==this.ƀih.screen.height)&&this.ƀih.renderer.resize(t.x,t.y);}ƀjo(){let t=new helpersLib.Vector(this.ƀih.screen.width,this.ƀih.screen.height);this.ƀjf.value=t,this.ƀjg.value=t.multiplyNumber(.5).round();}ƀel(){let t=this.ƀbj.screenResolution?.width??window.innerWidth,e=this.ƀbj.screenResolution?.height??window.innerHeight;return this.ƀbj.maxScreenResolution&&(t=Math.min(t,this.ƀbj.maxScreenResolution.width),e=Math.min(e,this.ƀbj.maxScreenResolution.height)),new helpersLib.Vector(t,e)}ƀjp(t){this.ƀbj.maxScreenResolution&&(t.style.maxWidth=`${this.ƀbj.maxScreenResolution?.width}px`,t.style.maxHeight=`${this.ƀbj.maxScreenResolution?.height}px`),t.style.width="100%",t.style.height="100%";}};var Gt=class extends actionsLib.IDAttachable{static{h(this,"AudioContainer");}constructor(t){super(),this.ƀkv=new actionsLib.Variable(0),this.time=this.ƀkv.notifier,this.ƀdl=T.context.createGain(),this.ƀdl.connect(t),this.ƀkg=T.context.currentTime,g.beforeSceneUpdateAction.subscribe(()=>{this.ƀkv.value=T.context.currentTime-this.ƀkg;}).attach(this);}get volume(){return this.ƀdl.gain.value}set volume(t){this.setVolume(t);}setVolume(t){return this.ƀdl.gain.value=t,this}notifyOnTime(t){return this.time.value>t?actionsLib.SingleEvent.createDestroyed():actionsLib.SingleEvent.create(e=>{let i=this.time.subscribe(r=>{r>=t&&e();}).attach(this);return ()=>i.destroy()})}destroy(){this.destroyed||(super.destroy(),this.ƀjy.onended=null,this.ƀjy.stop(),this.ƀjy.disconnect(),this.ƀdl?.disconnect());}ƀin(t){this.ƀjy=T.createSource(t.soundID),this.ƀjy.connect(this.ƀdl),t.onComplete&&(this.ƀjy.onended=t.onComplete),t.loop?(this.ƀjy.loop=true,this.ƀjy.loopStart=t.start,this.ƀjy.loopEnd=t.end??this.ƀjy.buffer.duration,this.ƀjy.start(0,t.start)):this.ƀjy.start(0,t.start,t.end-t.start);}};var io=800,qi=-128,hi=class o extends Gt{static{h(this,"Music");}static createByName(t,e){let i=x.setupOptions.musicDefinitions[t];if(!i)throw new Error(`Music: Could not find music definition with name ${t}.`);return new o(i,e)}constructor(t,e){super(Y.ƀfq.ƀhc),this.ƀjr();let i=x.setupOptions.soundDefinitions[t.soundID],r=helpersLib.NumberHelper.clamp(e?.offset??0,0,t.loop?t.loop.to:i.duration);if(this.ƀkg=T.context.currentTime-r,this.ƀkv.value=r,t.loop){let s=t.loop.from,n=t.loop.to;this.ƀin({soundID:i.id,start:r,end:r<t.loop.from?s:n,loop:false,onComplete:h(()=>{this.ƀjy.disconnect(),this.ƀin({soundID:i.id,start:s,end:n,loop:true});},"onComplete")});}else this.ƀin({soundID:i.id,start:r,end:i.duration,loop:false,onComplete:h(()=>this.destroy(),"onComplete")});if(e?.muffle!==void 0){let s=helpersLib.NumberHelper.clamp(e.muffle,0,1);this.ƀhb.set({value:1-s}),this.ƀgz.set({value:s*qi});}}ƀjr(){this.ƀgy=T.context.createBiquadFilter(),this.ƀgy.type="highshelf",this.ƀgy.frequency.value=io,this.ƀgy.gain.value=0,this.ƀha=T.context.createGain(),this.ƀdl.disconnect(),this.ƀdl.connect(this.ƀha),this.ƀha.connect(this.ƀgy),this.ƀgy.connect(Y.ƀfq.ƀhc);let t={duration:500,animation:w.lineer,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState};this.ƀhb=new C(this.ƀha.gain,"value",t),this.ƀgz=new C(this.ƀgy.gain,"value",t);}muffle(t,e=500){t=helpersLib.NumberHelper.clamp(t,0,1);let i=this.ƀha.gain.value>t;return actionsLib.ActionLib.all([this.ƀhb.animate({value:1-t},{duration:e,animation:i?w.easeOut:w.easeIn}),this.ƀgz.animate({value:t*qi},{duration:e,animation:i?w.easeIn:w.lineer})]).mapToVoid().chainToRoot()}destroy(){this.destroyed||(this.ƀha.disconnect(),this.ƀgy.disconnect()),super.destroy();}};var li=class o extends Gt{static{h(this,"Sound");}static createByName(t){let e=x.setupOptions.soundDefinitions[t];if(!e)throw new Error(`Sound: Could not find sound definition with name ${t}.`);return new o(e)}constructor(t){super(Y.ƀfq.ƀjx),this.ƀin({soundID:t.id,start:0,end:t.duration,loop:false,onComplete:h(()=>this.destroy(),"onComplete")});}};var ci=class extends u{static{h(this,"UpdatableContainer");}},pi=class extends u{static{h(this,"DisplayObjectArray");}constructor(t,e){super(),this.ƀbx=t,this.ƀcr=new Map,this.ƀhr={trackBy:h((i,r)=>r,"trackBy"),positioning:{direction:"vertical",spacing:0},...e};}set(t){let e=new Set(this.ƀcr.keys()),i=0;t.forEach((r,s)=>{let n=this.ƀhr.trackBy(r,s),a;this.ƀcr.has(n)?(a=this.ƀcr.get(n),e.delete(n),a.update(r)):(a=this.ƀbx(r).displayParent(this).attach(this),this.ƀcr.set(n,a)),this.ƀhr.positioning.direction==="horizontal"?(a.x=i,i+=a.size.x+this.ƀhr.positioning.spacing):(a.y=i,i+=a.size.y+this.ƀhr.positioning.spacing);}),e.forEach(r=>{this.ƀcr.get(r).destroy(),this.ƀcr.delete(r);});}};var ee=class o extends u{static{h(this,"MenuUI");}static{this.ƀfs=actionsLib.Reducer.createExistenceChecker();}static{this.isAnyMenuTransitioning=this.ƀfs.notifier;}constructor(t,e){super(),this.ƀhj=new actionsLib.SingleAction,this.onCreate=this.ƀhj.notifier,this.ƀhl=new actionsLib.SingleAction,this.onOpen=this.ƀhl.notifier,this.ƀhg=new actionsLib.SingleAction,this.onClose=this.ƀhg.notifier,this.ƀba=false;let i={closeOnBackgroundClick:true,appearAnimationDuration:150,backgroundDarkeningRatio:.3,...e};this.setAlpha(0),this.ƀp=new C(this,"alpha",{animation:w.easeInOutCubic,duration:i.appearAnimationDuration,reAnimateHandling:exports.ReAnimateHandlingType.CompletePrevious,completionHandling:exports.AnimationsCompletionHandlingType.StayInCurrentState});let r=A.createRectangle(new helpersLib.Vector(1,1),helpersLib.ColorHelper.black).toSprite({cache:true}).setAlpha(i.backgroundDarkeningRatio).setInteractive(true).displayParent(this).attach(this);this.ƀgs=J.createByName(t).setPosition(new helpersLib.Vector(0,0)).setInteractive(true).displayParent(this).attach(this),x.instance.screenSize.subscribe(n=>{r.aspectRatio=n.x/n.y,r.scale=Math.max(n.x,n.y),r.setPosition(helpersLib.Vector.zero,{holdFrom:helpersLib.Vector.half}),this.setPosition(n.multiplyNumber(.5));}).attach(this),this.ƀhj.resolve();let s=o.ƀfs.effect().attach(this);this.ƀp.animate({alpha:1}).chain(this).tap(()=>{this.ƀhl.resolve(),s.destroy(),i.closeOnBackgroundClick&&r.on(exports.ContainerEventType.Click).take(1).tap(()=>this.close()).attach(this);}).attachToRoot();}getBoundingMask(){return this.ƀgs.getBoundingMask()}close(){if(!this.ƀba){this.ƀba=true;let t=o.ƀfs.effect().attach(this);this.ƀp.animate({alpha:0}).chain(this).map(()=>{this.ƀhg.resolve(),t.destroy(),this.destroy();}).chainToRoot();}return this.onClose.toSingleEvent()}};var ui=class extends yt{static{h(this,"MenuEntity");}static subscribeIsOpen(){return actionsLib.ActionLib.merge(this.continuesSubscription().map(t=>t.type==="open"),actionsLib.SingleEvent.instant(this.getInstance()!==void 0))}constructor(t){super(),this.ƀhr=t,queueMicrotask(()=>{if(!this.ƀgt)throw new Error("MenuEntity: MenuEntity has to have a MenuView.")});}ƀiw(t){this.ƀgt=t,this.ƀgt.onClose.subscribe(()=>this.destroy()).attach(this);}onCreate(){return this.ƀgt.onCreate.toSingleEvent()}onOpen(){return this.ƀgt.onOpen.toSingleEvent()}onClose(){return this.ƀgt.onClose.toSingleEvent()}close(){return this.ƀgt.close()}};var fi=class extends mt{static{h(this,"MenuView");}constructor(t,e,i){super();let r=helpersLib.JsonHelper.removeUndefinedProperties({appearAnimationDuration:i.appearAnimationDuration,backgroundDarkeningRatio:i.backgroundDarkeningRatio,closeOnBackgroundClick:t.ƀhr.closeOnBackgroundClick}),s=new ee(e,r).displayParent(x.camera.layers.foregroundScreen).attach(this);t.ƀiw(s);let n=new actionsLib.SingleAction;s.onCreate.subscribe(()=>n.resolve(s)).attach(this),this.onCreate=n.notifier,this.onOpen=s.onOpen.notifier,this.onClose=s.onClose.notifier;}};var co=.65,po=.01,Ge=class{static{h(this,"SmoothScroller");}get scrollHeight(){return this.ƀjh}get contentSize(){return this.ƀbl.size.ceil()}constructor(t,e,i,r){this.ƀbl=t,this.ƀv=e,this.ƀhu=i,this.ƀjw=r,this.ƀfp=false,this.ƀjh=e-i*2,this.ƀbl.y=i,this.ƀkn=i;}onWheel(t){this.setTarget(this.ƀkn-t*co);}scrollToTop(){this.setTarget(1/0);}scrollToBottom(){this.setTarget(-1/0);}setTarget(t){this.ƀkn=helpersLib.NumberHelper.clamp(t,this.ƀv-this.ƀhu-this.contentSize.y,this.ƀhu);}jumpToTarget(){this.ƀbl.y=this.ƀkn;}update(t){let e=this.contentSize;if(e.y<=this.ƀjh){switch(this.ƀjw){case "start":this.ƀkn=this.ƀhu;break;case "center":this.ƀkn=(this.ƀv-e.y)*.5;break;case "end":this.ƀkn=this.ƀv-e.y-this.ƀhu;break;default:{this.ƀjw;throw new Error(`Unexpected case! "${this.ƀjw}"`)}}this.ƀfp||(this.ƀbl.y=this.ƀkn);}this.ƀfp=true;let i=this.ƀkn-this.ƀbl.y;this.ƀbl.y=this.ƀbl.y+i*po*t;}};var fo=15,mi=class extends u{static{h(this,"ScrollAreaUI");}get contentAreaSize(){return this.ƀbm}get contentSize(){return this.ƀji.contentSize}constructor(t,e={}){super();let i={padding:fo,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 xt(r,t,i.padding).attach(this);let s=new j__namespace.Graphics;s.beginFill(0,1e-9),s.drawRect(0,0,t.x,t.y),s.endFill(),r.ƀii.addChild(s);let n=new u().displayParent(r).attach(this);this.ƀji=new Ge(n,t.y,i.padding,i.smallContentAlign),this.ƀbm=new helpersLib.Vector(t.x,this.ƀji.scrollHeight),s.eventMode="dynamic",s.addEventListener("wheel",a=>{this.ƀji.onWheel(a.deltaY);}),n.setInteractive(true),n.ƀii.addEventListener("wheel",a=>{this.ƀji.onWheel(a.deltaY);}),g.afterSceneUpdateAction.subscribe(a=>this.ƀji.update(a.delta)).attach(this),this.addChildTo=n;}scrollToTop(t){this.ƀji.scrollToTop(),t?.instant&&this.ƀji.jumpToTarget();}scrollToBottom(t){this.ƀji.scrollToBottom(),t?.instant&&this.ƀji.jumpToTarget();}};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},go=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.ƀfz=new actionsLib.Action,this.keyPressed=this.ƀfz.notifier,this.ƀga=new actionsLib.Action,this.keyReleased=this.ƀga.notifier,this.ƀgg=new Set,this.ƀgf=new Set,window.addEventListener("keydown",t=>{this.ƀgg.add(t.code),this.ƀgf.add(t.code),!t.repeat&&this.ƀfz.trigger({key:t.key,code:t.code});}),window.addEventListener("keyup",t=>{this.ƀgg.delete(t.code),this.ƀga.trigger({key:t.key,code:t.code});}),window.addEventListener("blur",()=>{this.ƀgg.clear();}),g.afterSceneUpdateAction.subscribe(()=>this.ƀgf.clear()).attachToRoot();}isKeyDown(t,e){return (e?.onlyPressedThisFrame?this.ƀgf:this.ƀgg).has(t)}};exports.KeyboardService=mo([d(),go("design:paramtypes",[])],exports.KeyboardService);var yo=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},wo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)};exports.MouseService=class re{static{h(this,"MouseService");}constructor(){this.ƀfo=new actionsLib.Variable(false),this.initialMouseMovementHappened=this.ƀfo.notifier,this.ƀkd=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.stagePosition=this.ƀkd.notifier,this.ƀje=new actionsLib.Variable(helpersLib.Vector.zero,{notifyOnChange:true}),this.screenPosition=this.ƀje.notifier,this.ƀgj=new actionsLib.Variable(false),this.mainButtonState=this.ƀgj.notifier,this.ƀjj=new actionsLib.Variable(false),this.secondaryButtonState=this.ƀjj.notifier,this.ƀke(),window.addEventListener("pointerdown",t=>{t.button===0?this.ƀgj.value=true:t.button===2&&(this.ƀjj.value=true);},{capture:true}),window.addEventListener("pointerup",t=>{t.button===0?this.ƀgj.value=false:t.button===2&&(this.ƀjj.value=false);},{capture:true}),window.addEventListener("blur",()=>{this.ƀgj.value=false,this.ƀjj.value=false;},{capture:true});}ƀke(){let t=helpersLib.Vector.zero;window.addEventListener("pointermove",e=>{t=new helpersLib.Vector(e.clientX,e.clientY),this.ƀfo.value=true;},{capture:true}),g.beforeSceneUpdateAction.subscribe(()=>{this.ƀje.value=this.ƀay(t);}).attachToRoot(),g.afterSceneUpdateAction.subscribe(()=>{let e=x.camera.screenPositonToStagePosition(this.ƀje.value);e.isEqual(this.ƀkd.value)?x.instance.renderer.events.onPointerMove(new PointerEvent("pointermove",{clientX:t.x,clientY:t.y,pointerType:"mouse"})):this.ƀkd.value=e;}).attachToRoot();}ƀay(t){let i=x.instance.renderer.view.getBoundingClientRect(),r=i.width,s=i.height;if(r<=0||s<=0)return helpersLib.Vector.zero;let n=x.instance.renderer,a=(t.x-i.left)/r*n.screen.width,l=(t.y-i.top)/s*n.screen.height;return a=helpersLib.NumberHelper.clamp(a,0,n.screen.width),l=helpersLib.NumberHelper.clamp(l,0,n.screen.height),new helpersLib.Vector(a,l)}};exports.MouseService=yo([d(),wo("design:paramtypes",[])],exports.MouseService);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},vo=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.ƀdi}get lastFocusedPosition(){return this.ƀgc}constructor(t){this.ƀgw=t,this.ƀhn=new actionsLib.Action,this.onTargetFocus=this.ƀhn.notifier,this.ƀkx=0,this.ƀky=false,this.ƀdi=false,this.ƀgc=void 0,g.beforeSceneUpdateAction.subscribe(e=>this.ƀlb(e.delta)).attachToRoot();}ƀlb(t){if(this.ƀgx){let e=this.ƀek(this.ƀgw.stagePosition.value,this.ƀgx);this.ƀhw===void 0?this.ƀhw=e:this.ƀav(e,t);}this.ƀgx=this.ƀgw.stagePosition.value;}ƀav(t,e){this.ƀhw-t>10?(this.ƀkx=Math.max(250,this.ƀkx),this.ƀky=true):this.ƀkx>1e3&&(this.ƀky=true);let i=this.ƀkx>=300&&this.ƀky;this.ƀfx(i,t,e);}ƀfx(t,e,i){(t||e>this.ƀhw)&&(this.ƀhw=e),t?(this.ƀky=false,this.ƀkx=0,this.ƀdi=true,this.ƀgc=this.ƀgw.stagePosition.value,this.ƀhn.trigger(this.ƀgc)):(this.ƀkx+=i,this.ƀdi=false);}ƀek(t,e){let i=helpersLib.Vector.fromTo(t,e);return Math.abs(i.x)+Math.abs(i.y)}};exports.MouseTargetFocusService=xo([d(),vo("design:paramtypes",[exports.MouseService])],exports.MouseTargetFocusService);var wi=10.8,xi=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 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 $__default.default.Body({position:t.position,angle:t.angle,type:t.type});return e.shapes=t.shapes,e}};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},at=class extends Q(){static{h(this,"PhysicsInternalGateway");}};at=Ro([d()],at);var S=class o extends z{static{h(this,"PhysicsEntity");}static{this.ƀht=new Map;}static{this.ƀia=new Map;}static getFromP2BodyID(t){return o.ƀht.get(t)}static getFromP2BodyIDOrFail(t){let e=o.ƀht.get(t);if(!e)throw new Error(`PhysicsEntity with p2BodyID ${t} not found`);return e}static getPhysicsInstanceOrFail(t){let e=o.ƀia.get(t);if(!e)throw new Error(`PhysicsEntity with id ${t} not found`);return e}static getPhysicsEntities(){return Array.from(o.ƀia.values())}get area(){return this.ƀu}get mass(){return this.ƀgn}get collisions(){return this.ƀbb}constructor(t,e,i){super(),this.ƀhh=new actionsLib.Action,this.onCollision=this.ƀhh.notifier,this.type="dynamic",this.ƀu=0,this.ƀgn=0,this.ƀbb=[],this.physicsWorldID=t,this.ƀic=E.get(at);let r=this.ƀic.getMaterial(this.physicsWorldID,e.shapeDefinition.materialName),s=this.ƀic.getMaterialDefinition(this.physicsWorldID,e.shapeDefinition.materialName);if(this.type=i,this.physicsBodyGroup=e.shapeDefinition.group,this.includeInPathfinding=e.includeOnPathfinding,this.ƀib=this.ƀic.getGroupConstant(this.physicsWorldID,this.physicsBodyGroup),this.ƀid=this.ƀic.getMaskConstant(this.physicsWorldID,this.physicsBodyGroup),this.p2Body=this.ƀic.createBody(this.physicsWorldID,e,r,s,this.type),this.ƀu=this.p2Body.getArea(),this.ƀgn=this.p2Body.mass,this.p2Body.position=f.vectorToArray(e.position),this.p2Body.angle=e.rotation.value,!this.ƀic.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.ƀht.set(this.p2Body.id,this),o.ƀia.set(this.id,this);}destroy(){this.destroyed||(super.destroy(),this.ƀic.removeBody(this.physicsWorldID,this.p2Body),o.ƀht.delete(this.p2Body.id),o.ƀia.delete(this.id));}canCollideWith(t){return f.arePhysicsGroupsCollidable(this.ƀib,this.ƀid,t.ƀib,t.ƀid)}ƀjl(t){this.ƀbb=t,t.length>0&&this.ƀhh.trigger(t);}};var se=class extends S{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 vi=class extends z{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),g.beforeSceneUpdateAction.subscribe(({time:t,delta:e})=>{this.ƀkk(t,e);}).attach(this);}ƀkk(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 bi=class extends S{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.ƀfh=false,this.ƀfi=false,this.ƀfk=false,this.ƀfj=false,this.ƀhx(),this.ƀgh(),E.get(at).subscribeToPhysicsStep(t,({time:i,delta:r})=>this.ƀkk(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}}ƀkk(t,e){this.ƀfh=true,this.ƀfi=true,this.ƀfk=true,this.ƀfj=true,this.ƀhx();}ƀhx(){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;}ƀgh(){this.position.subscribe(t=>{this.ƀfh?this.ƀfh=false:this.p2Body.position=[t.x,t.y];}).attach(this),this.rotation.subscribe(t=>{this.ƀfi?this.ƀfi=false:this.p2Body.angle=t.value;}).attach(this),this.velocity.subscribe(t=>{this.ƀfk?this.ƀfk=false:this.p2Body.velocity=[t.x,t.y];}).attach(this),this.rotationalSpeed.subscribe(t=>{this.ƀfj?this.ƀfj=false:this.p2Body.angularVelocity=t;}).attach(this);}};var ht="border";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};exports.PhysicsGateway=class oe extends Q(){static{h(this,"PhysicsGateway");}};exports.PhysicsGateway=Oo([d()],exports.PhysicsGateway);var Do=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)},b=class extends z{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;}};b=Do([gt(),Mo("design:paramtypes",[helpersLib.Vector,Boolean,$__default.default.World,Map,Map,Map,Map])],b);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},X=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 b.getInstanceByIDOrFail(t).physicsBodyGroupToP2Group.get(e)}getMaskConstant(t,e){return b.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}};X=_o([d()],X);var Vo=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},Lo=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.ƀhz=t;}getCollidableGrids(t,e){let i=[];return t.availabilityGridCache.forEach((r,s)=>{r.forEach((n,a)=>{this.ƀhz.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=Vo([d(),Lo("design:paramtypes",[X])],Ve);var No=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},Ho=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},lt=class{static{h(this,"AvailabilityGridService");}constructor(t,e){this.ƀhz=t,this.ƀz=e;}onBodyAdded(t,e,i){e.aabbNeedsUpdate=true,e.updateAABB();let r=f.aabbToBoundingBox(e.aabb);this.ƀz.getCollidableGrids(t,i).forEach(s=>{let n=V.areaToGridArea(r,s.cellSize);s.grid.setArea(n,false);});}findClosestAvailableSpace(t,e,i,r=50){return e.aabbNeedsUpdate=true,e.updateAABB(),Yt.findByConvertingGridSpace(this.getAvilabilityGrid(t,r,i),f.aabbToBoundingBox(e.aabb),r)}getAvilabilityGrid(t,e,i){let r=this.ƀz.get(t,e,i);return r||(r=this.ƀca(t,e,i),this.ƀz.set(t,e,i,r)),r}ƀca(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=S.getFromP2BodyIDOrFail(s.id);if(n.includeInPathfinding&&this.ƀhz.canCollide(t,n.physicsBodyGroup,i)){let a=this.ƀeb(s,e);r.setArea(a,false);}}),r}ƀeb(t,e){let i=f.aabbToBoundingBox(t.aabb);return V.areaToGridArea(i,e)}};lt=No([d(),Ho("design:paramtypes",[X,Ve])],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},$o=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Vt=class{static{h(this,"PathFinderService");}constructor(t){this.ƀhy=t;}findPathAStar(t,e,i,r,s){s||(s={}),s.neighborType===void 0&&(s.neighborType=helpersLib.GridNeighborType.Ortogonal),s.gridCellSize===void 0&&(s.gridCellSize=50);let n=b.getInstanceByIDOrFail(t),a,l;helpersLib.Comparator.isNumber(i)?(l=S.getPhysicsInstanceOrFail(i).p2Body,a=f.arrayToVector(l.position)):a=i;let c=V.positionToGridPosition(e,s.gridCellSize),p=V.positionToGridPosition(a,s.gridCellSize),m=this.ƀhy.getAvilabilityGrid(n,s.gridCellSize,r);if(l){let D=f.aabbToBoundingBox(l.aabb),Et=V.areaToGridArea(D,s.gridCellSize);m.setArea(Et,true);}let y=Xt.findPath(m,c,p,s.neighborType);return y.path=y.path.map(D=>V.gridPositionToPosition(D,s.gridCellSize)),y}findPathDirection(t,e,i,r,s=50){let n=b.getInstanceByIDOrFail(t),a;if(helpersLib.Comparator.isNumber(i)){let y=S.getPhysicsInstanceOrFail(i);a=f.aabbToBoundingBox(y.p2Body.aabb);}else a=new helpersLib.Rectangle(i,i);let l=V.areaToGridArea(a,s),c=JSON.stringify({targetGridArea:l,collidableWithGroup:r}),p=n.vectorFieldCache.get(c);if(!p){let y=this.ƀhy.getAvilabilityGrid(n,s,r);p=new Kt(l,y),n.vectorFieldCache.set(c,p);}let m=V.positionToGridPosition(e,s);return p.getDirectionToTarget(m)}};Vt=Wo([d(),$o("design:paramtypes",[lt])],Vt);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},Yo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Z=class{static{h(this,"TestVisualsService");}constructor(t,e){this.ƀaa=t,this.ƀhv=e;}printPathfindingTestGrid(t,e,i,r,s,n){let a=b.getInstanceByIDOrFail(t);this.ƀaa.getAvilabilityGrid(a,n,r).map((c,p)=>({position:V.gridPositionToPosition(p,n),availability:c})).forEach(c=>{if(c.position.isInsideRectangle(s)){let p=this.ƀhv.findPathDirection(t,c.position,i,r),m;p===void 0?m=A.createRectangleBorders(new helpersLib.Vector(8,8),2,helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).attach(a):m=A.createArrow(25,c.availability?helpersLib.ColorHelper.green:helpersLib.ColorHelper.red).toSprite().displayParent(e).setPosition(c.position,{round:false}).setRotation(p).attach(a),new C(m,"alpha",{duration:1e3,animation:w.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);A.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;A.createVector(r,c.line.to,p).toSprite().displayParent(a).attach(t);}),new C(a,"alpha",{duration:n,animation:w.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);A.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;A.createVector(p.line.from,p.line.to,m).toSprite().displayParent(l).attach(t);}),new C(l,"alpha",{duration:a,animation:w.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.ƀct(c,n).displayParent(a).attachToRoot();}),new C(a,"alpha",{duration:1e3,animation:w.easeIn}).animate({alpha:0}).tap(()=>a.destroy()).attach(a);}ƀct(t,e){switch(t.type){case $__default.default.Shape.PARTICLE:throw new Error("Not implemented");case $__default.default.Shape.LINE:throw new Error("Not implemented");case $__default.default.Shape.PLANE:throw new Error("Not implemented");case $__default.default.Shape.CIRCLE:throw new Error("Not implemented");case $__default.default.Shape.CAPSULE:throw new Error("Not implemented");case $__default.default.Shape.BOX:throw new Error("Not implemented");case $__default.default.Shape.HEIGHTFIELD:throw new Error("Not implemented");case $__default.default.Shape.CONVEX:return this.ƀcs(t,e);default:throw new Error("Not implemented")}}ƀcs(t,e){let i=[t.vertices.map(r=>({x:r[0],y:r[1]}))];return A.createPolygon(i,e).toSprite()}};Z=Jo([d(),Yo("design:paramtypes",[lt,Vt])],Z);var Zo=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},Qo=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Le=class{static{h(this,"HitTestService");}constructor(t){this.ƀkq=t;}hitTest(t,e){let i=t.world,r=S.getFromP2BodyIDOrFail(t.id),s=f.cloneP2Body(t);this.ƀt(s,e);let n=i.broadphase.aabbQuery(i,this.ƀdn(s)).map(l=>S.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 $__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.ƀkq.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);}ƀdn(t){return t.aabbNeedsUpdate=true,t.updateAABB(),t.aabb}};Le=Zo([d(),Qo("design:paramtypes",[Z])],Le);var tn=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},Ne=class{static{h(this,"CollisionsService");}registerPhysicsWorld(t){t.p2World.on("beginContact",e=>{e.contactEquations.forEach(i=>{this.ƀiv(t,i);});});}step(t,e,i){S.getPhysicsEntities().forEach(r=>{r.ƀbb=[];}),t.p2World.narrowphase.contactEquations.forEach(r=>{this.ƀiv(t,r);}),t.bodiesInContactWith.forEach((r,s)=>{this.ƀex(r.p2Body),r.entity.ƀjl(t.collisionReports.get(s)||[]);}),t.bodiesInContactWith.clear(),t.collisionReports.clear();}ƀex(t){let e=f.arrayToVector(t.velocity);e.length>wi&&(e=e.normalize(wi),t.velocity=f.vectorToArray(e)),t.angularVelocity=Math.min(Math.max(t.angularVelocity,-xi),xi);}ƀiv(t,e){let i=S.getFromP2BodyID(e.bodyA.id),r=S.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.ƀdt(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);}ƀdt(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.ƀei(i);return {collisionDetailsA:this.ƀds(r,i.bodyA.mass,n,l,t.area),collisionDetailsB:this.ƀds(s,i.bodyB.mass,a,c,e.area)}}ƀds(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}}ƀei(t){let e=f.arrayToVector(t.normalA),i=e.multiplyNumber(-1);return {normalA:e,normalB:i}}};Ne=tn([d()],Ne);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},rn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},He=class extends se{static{h(this,"BorderEntity");}constructor(t,e){super(t,e);}};He=en([gt(),rn("design:paramtypes",[Number,Object])],He);var sn=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},W=1e4,je=class{static{h(this,"BorderService");}createBorders(t,e,i){this.ƀbu(t,new helpersLib.Vector(e.x/2,-W/2),new helpersLib.Vector(e.x+W*2,W),i),this.ƀbu(t,new helpersLib.Vector(e.x/2,e.y+W/2),new helpersLib.Vector(e.x+W*2,W),i),this.ƀbu(t,new helpersLib.Vector(-W/2,e.y/2),new helpersLib.Vector(W,e.y+W*2),i),this.ƀbu(t,new helpersLib.Vector(e.x+W/2,e.y/2),new helpersLib.Vector(W,e.y+W*2),i);}ƀbu(t,e,i,r){return new He(t,{shapeDefinition:{materialName:ht,group:r,shapeType:exports.PhysicsShapeType.Rectangle,shapeData:i},position:e,rotation:helpersLib.Radian.get0,addInEmptySpace:false,includeOnPathfinding:true}).attachByID(t)}};je=sn([d()],je);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},cr=new $__default.default.Material,an={id:ht,density:Number.MAX_SAFE_INTEGER,velocityDrag:1,rotationalDrag:1},Lt=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 $__default.default.Material),n.set(a.id,a);}),s.has(ht))throw new Error(`Material with name ${ht} cannot be defined, pick another name for the material.`);return s.set(ht,cr),n.set(ht,an),this.ƀc(t,e,i,r,s),{materials:s,materialDefinitions:n}}getMaterial(t,e){let i=b.getInstanceByIDOrFail(t);return this.ƀeg(e,i.materials)}getMaterialDefinition(t,e){let i=b.getInstanceByIDOrFail(t);return this.ƀef(e,i.materialDefinitions)}ƀeg(t,e){let i=e.get(t);if(!i)throw new Error(`Could not find material with name ${t}.`);return i}ƀef(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.ƀdy(i.map(n=>n.id),r).forEach(n=>{let a=this.ƀeg(n.materialA,s),l=this.ƀeg(n.materialB,s);t.addContactMaterial(new $__default.default.ContactMaterial(a,l,{friction:n.friction,restitution:n.bounciness,stiffness:n.stiffness,relaxation:n.relaxation}));}),this.ƀd(t,e,i,s);}ƀdy(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.ƀeg(s.id,r);t.addContactMaterial(new $__default.default.ContactMaterial(n,cr,{friction:e.friction,restitution:e.bounciness,stiffness:e.stiffness,relaxation:e.relaxation}));});}};Lt=nn([d()],Lt);var hn=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},ln=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Nt=class{static{h(this,"PhysicsWorldService");}constructor(t,e,i,r,s){this.ƀgr=t,this.ƀaj=e,this.ƀaa=i,this.ƀbc=r,this.ƀhz=s;}createPhysicsWorld(t){let e=new $__default.default.World({gravity:[0,0]}),{materials:i,materialDefinitions:r}=this.ƀgr.createMaterials(e,t.borderProperties,t.materialDefinitions,t.materialContactDefinitions),{physicsBodyGroupToP2Group:s,physicsBodyGroupToP2Mask:n}=this.ƀhz.createBodyGroupsAndMasks(t.physicsBodyGroups,t.interactingBodyGroups),a=new b(t.mapSize,t.modifyUpdateCycle,e,i,r,s,n).attachByID(t.attachTo);return a.onDestroy().tap(()=>{e.clear(),t.modifyUpdateCycle&&g.cleanUpdateModifier();}).attachToRoot(),this.ƀaj.createBorders(a.id,t.mapSize,t.borderProperties.borderBodyGroup),this.ƀbc.registerPhysicsWorld(a),t.modifyUpdateCycle?g.registerUpdateModifier((l,c)=>this.ƀkk(a,l,c)):g.beforeSceneUpdateAction.subscribe(({time:l,delta:c})=>{this.ƀkk(a,l,c);}).attach(a),a.id}addBody(t,e,i,r,s){let n=b.getInstanceByIDOrFail(t);if(i){let a=this.ƀaa.findClosestAvailableSpace(n,e,r);return a?(e.position[0]+=a.x,e.position[1]+=a.y,n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true):false}else return n.p2World.addBody(e),s&&this.ƀaa.onBodyAdded(n,e,r),true}removeBody(t,e){b.getInstanceByID(t)?.p2World.removeBody(e);}ƀkk(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.ƀbc.step(t,r,i),t.onPhysicsStep.trigger({time:r,delta:i}),t.lastP2Time.value=t.p2World.time;}return i}setPaused(t,e){b.getInstanceByIDOrFail(e).paused.set(t);}};Nt=hn([d(),ln("design:paramtypes",[Lt,je,lt,Ne,X])],Nt);var pn=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,"RayCastingService");}castClosest(t,e,i){let r=new $__default.default.RaycastResult,s=new $__default.default.Ray({mode:$__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.ƀbp(r,e)}castAllFirstContacts(t,e,i){let r=new Map,s=new $__default.default.Ray({mode:$__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.ƀbp(n,e)):n.fraction===a.fraction&&a.isExternal()&&r.set(n.body,this.ƀbp(n,e));},"callback")});return t.p2World.raycast(new $__default.default.RaycastResult,s),Array.from(r.values())}ƀbp(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}}};jt=pn([d()],jt);var dn=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},dt=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);}};dt=dn([d()],dt);var un=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},Ut=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.ƀbq(r,t.length))}ƀbq(t,e){let i=t.hitCount/e,r=t.rayCastHits;if(t.isExternal)return {body:S.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:S.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")}}}};Ut=un([d()],Ut);var mn=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},gn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},xn=15,We=class{static{h(this,"ElipticExplosionService");}constructor(t,e,i,r){this.ƀir=t,this.ƀkq=e,this.ƀiq=i,this.ƀfl=r;}createElipticExplosion(t,e,i,r,s,n,a){let l=b.getInstanceByIDOrFail(t),c=this.ƀcf(e,i,r,s,a?.hitOnlyClosest===true,l),p=this.ƀiq.toExplosionHits(c,false);return this.ƀr(p,n),a?.testLayerID&&this.ƀkq.createElipticExplosionDebugVisual(l,a.testLayerID,c,e,i,r,a.debugRayDuration),p.map(m=>{let{p2Body:y,...D}=m;return D})}ƀcf(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 y=Math.round(i.y/xn),D=i.y/(y*2+1)*2,Et=l.normalize(D),ne=i.x,dr=Math.pow(i.y,2);return helpersLib.ArrayHelper.createIntegerArray(y).forEach(ft=>{let Rt=D*(ft+1),Ti=Et.multiplyNumber(ft+1),ae=c.normalize(this.ƀer(ne,dr,Rt)),he=t.add(Ti);a.push(new helpersLib.Line(he,he.add(ae))),a.push(new helpersLib.Line(he,he.add(ae.multiplyNumber(-1))));let le=t.add(Ti.multiplyNumber(-1));a.push(new helpersLib.Line(le,le.add(ae))),a.push(new helpersLib.Line(le,le.add(ae.multiplyNumber(-1))));}),a.map(ft=>{if(s){let Rt=this.ƀir.castClosest(n,ft,r);return {line:ft,hits:Rt?[Rt]:[]}}else {let Rt=this.ƀir.castAllFirstContacts(n,ft,r);return {line:ft,hits:Rt}}})}ƀer(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.ƀfl.applyImpulse(r.body,r.hitPosition(),s,n);});});}};We=mn([d(),gn("design:paramtypes",[jt,Z,Ut,dt])],We);var vn=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},bn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},$e=class{static{h(this,"ExplosionService");}constructor(t,e,i,r){this.ƀir=t,this.ƀkq=e,this.ƀiq=i,this.ƀfl=r;}createExplosion(t,e,i,r,s,n){let a=b.getInstanceByIDOrFail(t),l=this.ƀeo(i),c=this.ƀcf(e,i,r,l,n?.hitOnlyClosest===true,a),p=this.ƀiq.toExplosionHits(c);return this.ƀr(e,i,s,l,p),n?.testLayerID&&this.ƀkq.createExplosionDebugVisual(a,n.testLayerID,c,e,i,n.debugRayDuration),p}ƀcf(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.ƀir.castClosest(n,p,i);return {line:p,hits:m?[m]:[]}}else {let m=this.ƀir.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.ƀfl.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.ƀfl.applyImpulse(n.p2Body,n.getHitPosition(),a,c);}});}ƀeo(t){return t>100?Math.floor(t*.3):Math.floor(t*.26+4)}};$e=vn([d(),bn("design:paramtypes",[jt,Z,Ut,dt])],$e);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},Wt=class{static{h(this,"PhysicsQueryService");}getMapSize(t){let e=b.getInstanceByIDOrFail(t);return {dimentions:e.mapSize,center:e.mapSizeCenter}}subscribeToPhysicsStep(t,e){return b.getInstanceByIDOrFail(t).onPhysicsStep.subscribe(e)}};Wt=Rn([d()],Wt);var Cn=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,"PhysicsController");}constructor(t,e,i,r,s,n,a,l){this.ƀig=t,this.ƀhv=e,this.ƀkq=i,this.ƀde=r,this.ƀcx=s,this.ƀfc=n,this.ƀif=a,this.ƀfl=l;}createPhysicsWorld(t){return this.ƀig.createPhysicsWorld(t)}getMapSize(t){return this.ƀif.getMapSize(t)}setPaused(t,e){this.ƀig.setPaused(t,e);}hitTest(t,e){let i=S.getPhysicsInstanceOrFail(t);return this.ƀfc.hitTest(i.p2Body,e)}findPath(t,e,i,r,s){return this.ƀhv.findPathAStar(t,e,i,r,{neighborType:s})}findPathDirection(t,e,i,r){return this.ƀhv.findPathDirection(t,e,i,r)}applyImpulse(t,e,i,r){let s=S.getPhysicsInstanceOrFail(t);this.ƀfl.applyImpulse(s.p2Body,e,i,r);}createExplosion(t,e,i,r,s,n){return this.ƀde.createExplosion(t,e,i,r,s,n)}createElipticExplosion(t,e,i,r,s,n,a){return this.ƀcx.createElipticExplosion(t,e,i,r,s,n,a)}printPathfindingTestGrid(t,e,i,r,s,n=50){this.ƀkq.printPathfindingTestGrid(t,e,i,r,s,n);}};Si=Cn([q(exports.PhysicsGateway),An("design:paramtypes",[Nt,Vt,Z,$e,We,Le,Wt,dt])],Si);var In=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},ze=class{static{h(this,"ShapeCreationService");}createBody(t,e,i,r,s){let n=b.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.ƀbw(n,void 0,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Circle:return this.ƀbw(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Polygon:return this.ƀce(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);case exports.PhysicsShapeType.Rectangle:return this.ƀcg(n,e.shapeDefinition.shapeData,i,r,e.shapeDefinition.group,s);default:{e.shapeDefinition.shapeType;throw new Error(`Unexpected case! "${e.shapeDefinition.shapeType}"`)}}}ƀbw(t,e,i,r,s,n){let a=new $__default.default.Circle({collisionGroup:t.physicsBodyGroupToP2Group.get(s),collisionMask:t.physicsBodyGroupToP2Mask.get(s),radius:e});a.material=i;let l=new $__default.default.Body({type:n==="dynamic"?$__default.default.Body.DYNAMIC:$__default.default.Body.STATIC,mass:r.density,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return l.addShape(a),l}ƀce(t,e,i,r,s,n){let a=t.physicsBodyGroupToP2Group.get(s),l=t.physicsBodyGroupToP2Mask.get(s),c=e.map(y=>new $__default.default.Convex({vertices:y.map(D=>[D.x,D.y]),collisionGroup:a,collisionMask:l})).map(y=>(y.material=i,y)),p=c.reduce((y,D)=>y+D.area,0),m=new $__default.default.Body({type:n==="dynamic"?$__default.default.Body.DYNAMIC:$__default.default.Body.STATIC,mass:p,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.forEach(y=>m.addShape(y)),m.setDensity(r.density),m}ƀcg(t,e,i,r,s,n){let a=new $__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 $__default.default.Body({type:n==="dynamic"?$__default.default.Body.DYNAMIC:$__default.default.Body.STATIC,mass:l,damping:r.velocityDrag,angularDamping:r.rotationalDrag});return c.addShape(a),c.setDensity(r.density),c}};ze=In([d()],ze);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},Dn=function(o,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(o,t)},Pi=class{static{h(this,"PhysicsInternalController");}constructor(t,e,i,r,s){this.ƀig=t,this.ƀie=e,this.ƀjt=i,this.ƀif=r,this.ƀhz=s;}createBody(t,e,i,r,s){return this.ƀjt.createBody(t,e,i,r,s)}getMaterial(t,e){return this.ƀie.getMaterial(t,e)}getMaterialDefinition(t,e){return this.ƀie.getMaterialDefinition(t,e)}getGroupConstant(t,e){return this.ƀhz.getGroupConstant(t,e)}getMaskConstant(t,e){return this.ƀhz.getMaskConstant(t,e)}addBody(t,e,i,r,s){return this.ƀig.addBody(t,e,i,r,s)}removeBody(t,e){this.ƀig.removeBody(t,e);}subscribeToPhysicsStep(t,e){return this.ƀif.subscribeToPhysicsStep(t,e)}};Pi=On([q(at),Dn("design:paramtypes",[Nt,Lt,ze,Wt,X])],Pi);exports.AnimationFlicker=Ci;exports.AnimationInterpolationFunctions=H;exports.Animations=w;exports.Animator=C;exports.BORDER_MATERIAL_NAME=ht;exports.BardLegendsHardReset=I;exports.Camera=te;exports.ClosestAvailableSpaceHelper=Yt;exports.Container=u;exports.ControllerDecorator=q;exports.DEFAULT_SHADER_RESOLUTION=G;exports.DeltaTime=ti;exports.DisplayObjectArray=pi;exports.Entity=z;exports.EntityDecorator=gt;exports.FadeInContent=Gi;exports.FadeInStateAnimation=ye;exports.Game=x;exports.Gateway=Q;exports.Graphics=A;exports.ImmovablePhysicsEntity=se;exports.MenuEntity=ui;exports.MenuUI=ee;exports.MenuView=fi;exports.MovableEntity=vi;exports.MovablePhysicsEntity=bi;exports.Music=hi;exports.PathFinder=Xt;exports.PhysicsEntity=S;exports.Placeholder=ii;exports.ROTATIONAL_SPEED_LIMIT=xi;exports.RichText=ri;exports.SPEED_LIMIT=wi;exports.Scene=ce;exports.SceneDecorator=Er;exports.ScrollAreaUI=mi;exports.ScrollMaskUI=xt;exports.Service=E;exports.ServiceDecorator=d;exports.SingletonEntity=yt;exports.SlideInContent=ji;exports.SlideInContentByIndex=qe;exports.SlideStateAnimation=Pe;exports.Sound=li;exports.Sprite=J;exports.StateAnimation=ge;exports.Text=Qt;exports.UpdatableContainer=ci;exports.UpdateCycle=g;exports.VectorFieldPathFinder=Kt;exports.VectorSet=bt;exports.View=mt;exports.ViewDecorator=Je;