From b7710ab22513087c4c9da0dd800c4127f1128726 Mon Sep 17 00:00:00 2001 From: "Zachary W. Freiberg" Date: Tue, 17 Feb 2015 11:16:19 +1300 Subject: [PATCH] Added rotateToVelocity to Arcade Physics component. Issue #179 --- build/kiwi.d.ts | 7 +++++++ build/kiwi.js | 11 +++++++++++ build/kiwi.min.js | 16 ++++++++-------- src/components/ArcadePhysics.ts | 16 ++++++++++++++++ templateGame/lib/kiwi.js | 11 +++++++++++ 5 files changed, 53 insertions(+), 8 deletions(-) diff --git a/build/kiwi.d.ts b/build/kiwi.d.ts index 1efedcd6..50eb3f80 100644 --- a/build/kiwi.d.ts +++ b/build/kiwi.d.ts @@ -6137,6 +6137,13 @@ declare module Kiwi.Components { */ parent: Kiwi.Entity; /** + * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component. + * @method rotateToVelocity + * @return { Number } + * @public + */ + rotateToVelocity(): number; + /** * A static method for seperating two normal GameObjects on both the X and Y Axis's. * Both objects need to have both an ArcadePhysics Component and a Box component in order for the separate process to succeed. * This method is not recommended to be directly used but instead use a 'collide/overlaps' method instead. diff --git a/build/kiwi.js b/build/kiwi.js index 6faaeb88..d6e0e1e3 100644 --- a/build/kiwi.js +++ b/build/kiwi.js @@ -8658,6 +8658,17 @@ var Kiwi; this._callbackFunction = callbackFunction; this._callbackContext = callbackContext; }; + /** + * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component. + * @method rotateToVelocity + * @return { Number } + * @public + */ + ArcadePhysics.prototype.rotateToVelocity = function () { + var result = Math.atan2(this.velocity.y, this.velocity.x); + this.transform.rotation = result; + return result; + }; /* *--------------- * Seperation Code diff --git a/build/kiwi.min.js b/build/kiwi.min.js index bc0963b7..5a2352e7 100644 --- a/build/kiwi.min.js +++ b/build/kiwi.min.js @@ -1,11 +1,11 @@ var Kiwi;!function(a){var b=function(){function b(b,c,d,e){var f=this;if(void 0===b&&(b=""),void 0===c&&(c="KiwiGame"),void 0===d&&(d=null),void 0===e&&(e={}),this._startup=null,this.audio=null,this.fileStore=null,this.input=null,this.cameras=null,this.pluginManager=null,this.loader=null,this.raf=null,this.stage=null,this.states=null,this.time=null,this.tweens=null,this.rnd=null,this._frameRate=60,this._interval=1e3/60,this._delta=0,this._frame=0,a.Log.setDefaultsFromParams(e.log),a.Log.log("Kiwi.Game: "+c+" is booting using Kiwi.js "+a.VERSION,"#version"),null===a.DEVICE&&(a.DEVICE=new a.System.Device),"undefined"!==e.debug&&"number"==typeof e.debug)switch(e.debug){case a.DEBUG_ON:this._debugOption=e.debug,a.Log.log(" Kiwi.Game: Debugging turned ON.","#debugging");break;case a.DEBUG_OFF:this._debugOption=e.debug,a.Log.log(" Kiwi.Game: Debugging turned OFF.","#debugging");break;default:this._debugOption=a.DEBUG_ON,a.Log.error(" Kiwi.Game: Debug option passed, but is not a valid option. Turned ON by default.","#debugging")}else this._debugOption=a.DEBUG_ON,a.Log.log(" Kiwi.Game: Debug option not specified. Turned ON by default.","#debugging");if("undefined"!==e.bootCallback&&(this.bootCallbackOption=e.bootCallback),"undefined"!==e.deviceTarget&&"number"==typeof e.deviceTarget)switch(e.deviceTarget){case a.TARGET_BROWSER:this._deviceTargetOption=e.deviceTarget,a.Log.log(" Kiwi.Game: Targeting BROWSERS.","#target");break;case a.TARGET_COCOON:this._deviceTargetOption=e.deviceTarget,a.Log.log(" Kiwi.Game: Targeting COCOONJS.","#target");break;default:this._deviceTargetOption=a.TARGET_BROWSER,a.Log.error(" Kiwi.Game: Target device specified, but is not a valid option. Defaulting to BROWSER.","#target")}else this._deviceTargetOption=a.TARGET_BROWSER,a.Log.log(" Kiwi.Game: Targeted device not specified. Defaulting to BROWSER.","#target");var g=a.RENDERER_WEBGL,h=a.RENDERER_CANVAS;if("undefined"!==e.renderer&&"number"==typeof e.renderer)switch(e.renderer){case a.RENDERER_CANVAS:this._renderOption=e.renderer,a.Log.log(" Kiwi.Game: Rendering using CANVAS.","#renderer","#canvas");break;case a.RENDERER_WEBGL:a.DEVICE.webGL?(this._renderOption=e.renderer,a.Log.log(" Kiwi.Game: Rendering using WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: WEBGL renderer requested but device does not support WEBGL. Rendering using CANVAS.","#renderer","#canvas"));break;case a.RENDERER_AUTO:a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer auto-detected WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer auto-detected CANVAS.","#renderer","#canvas"));break;default:a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer specified, but is not a valid option. Defaulting to WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer specified, but is not a valid option. WEBGL renderer sought by default but device does not support WEBGL. Defaulting to CANVAS.","#renderer","#canvas"))}else a.DEVICE.webGL?(this._renderOption=g,a.Log.log(" Kiwi.Game: Renderer not specified. Defaulting to WEBGL.","#renderer","#webgl")):(this._renderOption=h,a.Log.log(" Kiwi.Game: Renderer not specified. WEBGL renderer sought by default but device does not support WEBGL. Defaulting to CANVAS.","#renderer","#canvas"));this.id=a.GameManager.register(this),this._startup=new a.System.Bootstrap,this.audio=new a.Sound.AudioManager(this),this.fileStore=new a.Files.FileStore(this),this.input=new a.Input.InputManager(this);var i=a.Stage.DEFAULT_WIDTH,j=a.Stage.DEFAULT_HEIGHT;if("undefined"!==e.width&&"number"==typeof e.width&&(i=e.width),"undefined"!==e.height&&"number"==typeof e.height&&(j=e.height),a.Log.log(" Kiwi.Game: Stage Dimensions: "+i+"x"+j,"#dimensions"),a.Utils.Common.isUndefined(e.scaleType))a.Log.log(" Kiwi.Game: Stage scaling not specified, defaulting to NONE.","#scaling"),e.scaleType=0;else switch(e.scaleType){case a.Stage.SCALE_FIT:a.Log.log(" Kiwi.Game: Stage scaling set to FIT.","#scaling");break;case a.Stage.SCALE_STRETCH:a.Log.log(" Kiwi.Game: Stage scaling set to STRETCH.","#scaling");break;case a.Stage.SCALE_NONE:a.Log.log(" Kiwi.Game: Stage scaling set to NONE.","#scaling");break;default:a.Log.log(" Kiwi.Game: Stage specified, but is not a valid option. Set to NONE.","#scaling"),e.scaleType=0}this.stage=new a.Stage(this,c,i,j,e.scaleType),this.renderer=null,this.cameras=new a.CameraManager(this),this._deviceTargetOption!==a.TARGET_COCOON&&(this.huds=new a.HUD.HUDManager(this)),this.loader=new a.Files.Loader(this),this.states=new a.StateManager(this),this.rnd=new a.Utils.RandomDataGenerator([Date.now.toString()]),this.time=new a.Time.ClockManager(this),this.tweens=new a.Animations.Tweens.TweenManager(this),null!==d?this.states.addState(d,!0):a.Log.log(" Kiwi.Game: Default State not passed.","#state"),this.pluginManager=new a.PluginManager(this,e.plugins),this.deviceTargetOption===a.TARGET_BROWSER?this._startup.boot(b,function(){return f._start()}):(""!==b&&a.Log.log(" Kiwi.Game: Not Targetting a BROWSER. DOM Parent parameter ignored.","#dom"),this._start())}return Object.defineProperty(b.prototype,"renderOption",{get:function(){return this._renderOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"deviceTargetOption",{get:function(){return this._deviceTargetOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"debugOption",{get:function(){return this._debugOption},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"debug",{get:function(){return this._debugOption===a.DEBUG_ON},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Game"},Object.defineProperty(b.prototype,"frame",{get:function(){return this._frame},set:function(b){this._frame=a.Utils.GameMath.truncate(b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"idealFrame",{get:function(){return this.time.elapsed()/(1e3/this._frameRate)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameRate",{get:function(){return this._frameRate},set:function(a){a>0&&(this._frameRate=a,this._interval=1e3/this._frameRate,this.time.setMasterInterval(this._interval))},enumerable:!0,configurable:!0}),b.prototype._start=function(){var b=this;this.stage.boot(this._startup),this.stage.renderer||a.Log.error(" Kiwi.Game: Could not create rendering context","#renderer"),this._renderOption===a.RENDERER_WEBGL&&this.stage.ctx&&(this._renderOption=a.RENDERER_CANVAS),this.renderer=this.stage.renderer,this.renderer.boot(),this.cameras.boot(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.boot(),this.time.boot(),this.input.boot(),this.audio.boot(),this.fileStore.boot(),this.loader.boot(),this.states.boot(),this.pluginManager.boot(),this._lastTime=Date.now(),this.raf=new a.Utils.RequestAnimationFrame(function(){return b._loop()}),this.raf.start(),this.bootCallbackOption&&(a.Log.log(" Kiwi.Game: invoked boot callback","#boot"),this.bootCallbackOption(this))},b.prototype._loop=function(){this._delta=this.raf.currentTime-this._lastTime,this._delta>this._interval&&(this.time.update(),this.audio.update(),this.input.update(),this.tweens.update(),this.cameras.update(),this._deviceTargetOption!==a.TARGET_COCOON&&this.huds.update(),this.states.update(),this.pluginManager.update(),this._frame++,null!==this.states.current&&(this.cameras.render(),this.states.postRender()),this._lastTime=this.raf.currentTime-this._delta%this._interval)},b}();a.Game=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function b(b,c,d,e,f){this._scaleType=a.Stage.SCALE_NONE,this.offset=new a.Geom.Point,this._color=new a.Utils.Color,this.container=null,this._game=b,this.name=c,this.domReady=!1,this._alpha=1,this._x=0,this._y=0,this._width=d,this._height=e,this.color="ffffff",b.deviceTargetOption===a.TARGET_COCOON&&(this.color="000000"),this._scale=new a.Geom.Point(1,1),this._scaleType=f,this.onResize=new a.Signal,this.onWindowResize=new a.Signal,this._renderer=null}return b.prototype.objType=function(){return"Stage"},Object.defineProperty(b.prototype,"scaleType",{get:function(){return this._scaleType},set:function(a){this._scaleType=a,this._scaleContainer()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"alpha",{get:function(){return this._alpha},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.container.style.opacity=String(a.Utils.GameMath.clamp(b,1,0))),this._alpha=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._x},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.left=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.left=String(b+"px")),this._x=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._y},set:function(b){this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.style.top=String(b+"px"):this._game.deviceTargetOption===a.TARGET_COCOON&&(this.canvas.style.top=String(b+"px")),this._y=b},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return this._width},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scale",{get:function(){return this._scale},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleX",{get:function(){return this._scale.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"scaleY",{get:function(){return this._scale.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"color",{get:function(){return this._color.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._color.set.apply(this._color,b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b}},set:function(a){this._color.set(a.r,a.g,a.b)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"rgbaColor",{get:function(){return{r:255*this._color.r,g:255*this._color.g,b:255*this._color.b,a:255*this._color.a}},set:function(a){this._color.set(a.r,a.g,a.b,a.a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"normalizedColor",{get:function(){return{r:this._color.r,g:this._color.g,b:this._color.b,a:this._color.a}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"renderer",{get:function(){return this._renderer},enumerable:!0,configurable:!0}),b.prototype.boot=function(b){var c=this,d=this;this.domReady=!0,this.container=b.container,this._game.deviceTargetOption===a.TARGET_BROWSER&&(this.offset=this.getOffsetPoint(this.container),this._x=this.offset.x,this._y=this.offset.y,window.addEventListener("resize",function(a){return c._windowResized(a)},!0)),this._createCompositeCanvas(),this._game.deviceTargetOption===a.TARGET_COCOON?(this._scaleContainer(),window.addEventListener("orientationchange",function(a){return d._orientationChanged(a)},!0)):this._calculateContainerScale()},b.prototype.getOffsetPoint=function(b,c){void 0===c&&(c=new a.Geom.Point);var d=b.getBoundingClientRect(),e=b.clientTop||document.body.clientTop||0,f=b.clientLeft||document.body.clientLeft||0,g=window.pageYOffset||b.scrollTop||document.body.scrollTop,h=window.pageXOffset||b.scrollLeft||document.body.scrollLeft;return c.setTo(d.left+h-f,d.top+g-e)},b.prototype._windowResized=function(){this._calculateContainerScale(),this.onWindowResize.dispatch()},b.prototype._orientationChanged=function(){this.onResize.dispatch(window.innerWidth,window.innerHeight)},b.prototype._calculateContainerScale=function(){this._scaleContainer(),this._scaleContainer(),this.offset=this.getOffsetPoint(this.container),this._scale.x=this._width/this.container.clientWidth,this._scale.y=this._height/this.container.clientHeight},b.prototype._createCompositeCanvas=function(){this._game.deviceTargetOption==a.TARGET_COCOON?this.canvas=document.createElement(navigator.isCocoonJS?"screencanvas":"canvas"):(this.canvas=document.createElement("canvas"),this.canvas.style.width="100%",this.canvas.style.height="100%"),this.canvas.id=this._game.id+"compositeCanvas",this.canvas.style.position="absolute",this.canvas.width=this.width,this.canvas.height=this.height,this._game.renderOption===a.RENDERER_CANVAS?(this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null):this._game.renderOption===a.RENDERER_WEBGL&&(this.gl=this.canvas.getContext("webgl"),this.gl||(this.gl=this.canvas.getContext("experimental-webgl"),this.gl?a.Log.warn("Kiwi.Stage: 'webgl' context is not available. Using 'experimental-webgl'","#renderer"):(a.Log.warn("Kiwi.Stage: WebGL rendering is not available despite the device apparently supporting it. Reverting to CANVAS.","#renderer"),this.ctx=this.canvas.getContext("2d"),this.ctx.fillStyle="#fff",this.gl=null)),this.gl&&(this.gl.clearColor(1,1,1,1),this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT),this.ctx=null)),this.ctx?this._renderer=new a.Renderers.CanvasRenderer(this._game):this.gl&&(this._renderer=new a.Renderers.GLRenderManager(this._game)),this._game.deviceTargetOption===a.TARGET_BROWSER?this.container.appendChild(this.canvas):document.body.appendChild(this.canvas)},b.prototype.resize=function(b,c){this.canvas.height=c,this.canvas.width=b,this._height=c,this._width=b,this._game.deviceTargetOption===a.TARGET_BROWSER&&this._calculateContainerScale(),this.onResize.dispatch(this._width,this._height)},b.prototype.setRGBColor=function(a,b,c){return this.rgbColor={r:a,g:b,b:c},this.rgbColor},b.prototype.createDebugCanvas=function(){0!=a.Utils.Common.isUndefined(this.debugCanvas)&&(this._game.deviceTargetOption===a.TARGET_COCOON&&a.Log.log("Debug canvas not supported in cocoon, creating canvas and context anyway","#debug-canvas"),this.debugCanvas=document.createElement("canvas"),this.debugCanvas.id=this._game.id+"debugCanvas",this.debugCanvas.style.position="absolute",this.debugCanvas.width=this.width,this.debugCanvas.height=this.height,this.debugCanvas.style.width="100%",this.debugCanvas.style.height="100%",this.dctx=this.debugCanvas.getContext("2d"),this.clearDebugCanvas(),this._game.deviceTargetOption===a.TARGET_BROWSER&&this.container.appendChild(this.debugCanvas))},b.prototype.clearDebugCanvas=function(a){this.dctx.fillStyle=a||"rgba(255,0,0,.2)",this.dctx.clearRect(0,0,this.width,this.height),this.dctx.fillRect(0,0,this.width,this.height)},b.prototype.toggleDebugCanvas=function(){this.debugCanvas.style.display="none"===this.debugCanvas.style.display?"block":"none"},b.prototype._scaleContainer=function(){if(this._game.deviceTargetOption==a.TARGET_BROWSER){var b=this.container.clientWidth;this.container.style.width=String(this._width+"px"),this.container.style.height=String(this._height+"px"),this._scaleType==a.Stage.SCALE_NONE&&(this.container.style.maxWidth="",this.container.style.minWidth=""),(this._scaleType==a.Stage.SCALE_STRETCH||this._scaleType==a.Stage.SCALE_FIT)&&(this.container.style.minWidth="100%",this.container.style.maxWidth="100%"),this._scaleType==a.Stage.SCALE_STRETCH?(this.container.style.minHeight="100%",this.container.style.maxHeight="100%"):(this.container.style.minHeight="",this.container.style.maxHeight=""),this._scaleType==a.Stage.SCALE_FIT&&(this.container.style.height=String(b/this._width*this._height)+"px")}if(this._game.deviceTargetOption==a.TARGET_COCOON)switch(this._scaleType){case a.Stage.SCALE_FIT:this.canvas.style.cssText="idtkscale:ScaleAspectFit";break;case a.Stage.SCALE_STRETCH:this.canvas.style.cssText="idtkscale:ScaleToFill";break;case a.Stage.SCALE_NONE:this.canvas.style.cssText=""}},b.DEFAULT_WIDTH=800,b.DEFAULT_HEIGHT=600,b.SCALE_NONE=0,b.SCALE_FIT=1,b.SCALE_STRETCH=2,b}();a.Stage=b}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b=function(){function a(a,b){this._components={},this._type=a,this._owner=b}return a.prototype.objType=function(){return"ComponentManager"},a.prototype.hasComponent=function(a){return this._components[a]?!0:!1},a.prototype.hasActiveComponent=function(a){return this._components[a]&&this._components[a].active===!0?!0:!1},a.prototype.getComponent=function(a){return this._components[a]?this._components[a]:null},a.prototype.add=function(a){return this._components[a.name]=a,a},a.prototype.addBatch=function(){for(var a=[],b=0;bf.majorVersion?a.Log.warn(" Kiwi.PluginManager: This major version of Kiwi is greater than that required by '"+d+"'. It is unknown whether this plugin will work with this version of Kiwi","#plugin"):a.Utils.Version.greaterOrEqual(a.VERSION,a.Plugins[d].minimumKiwiVersion)?a.Log.log(" Kiwi.PluginManager: Kiwi version meets minimum version requirements for '"+d+"'.","#plugin"):a.Log.warn(" Kiwi.PluginManager: Kiwi version ("+a.VERSION+") does not meet minimum version requirements for the plugin ("+a.Plugins[d].minimumKiwiVersion+").","#plugin")}else a.Log.warn(" Kiwi.PluginManager: '"+d+"' is missing the minimumKiwiVersion property. It is unknown whether '"+d+"' will work with this version of Kiwi","#plugin");else a.Log.log(" Kiwi.PluginManager: Plugin '"+d+"' appears to be invalid. No property with that name exists on the Kiwi.Plugins object or the Plugin is not registered. Check that the js file containing the plugin has been included. This plugin will be ignored","#plugin");else a.Log.log(" Kiwi.PluginManager: The supplied plugin name at index "+c+"is not a string and will be ignored","#plugin")}this._plugins=b;for(var c=0;c=a&&(a=0),a>1&&(a=1),this._alpha=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){this._visible=a},enumerable:!0,configurable:!0}),b.prototype.scaleToWidth=function(a){this.scale=a/this.width},b.prototype.scaleToHeight=function(a){this.scale=a/this.height},b.prototype.centerAnchorPoint=function(){this.anchorPointX=.5*this.width,this.anchorPointY=.5*this.height },Object.defineProperty(b.prototype,"cellIndex",{get:function(){return this._cellIndex},set:function(b){if(null!==this.atlas){var c=this.atlas.cells[b];void 0!==c?(this._cellIndex=b,this.width=c.w,this.height=c.h):a.Log.error("Could not the set the cellIndex of a Entity, to cell that does not exist on its TextureAtlas.","#entity","#cellIndex")}},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"exists",{get:function(){return this._exists},set:function(a){this._exists=a},enumerable:!0,configurable:!0}),b.prototype.addTag=function(){for(var a=[],b=0;b-1&&(this.members.splice(c,1),a.parent=null,b&&a.destroy())}return a},b.prototype.removeChildAt=function(a){if(this.members[a]){var b=this.members[a];return this.removeChild(b)}return null},b.prototype.removeChildren=function(a,b,c){void 0===a&&(a=0),void 0===b&&(b=2147483647),void 0===c&&(c=!1),b-=a;for(var d=this.members.splice(a,b),e=0;e=0;c--){if(this.members[c].hasTag(b))return this.members[c];if(this.members[c].childType()==a.GROUP){var d=this.members[c].getLastChildByTag(b);if(d)return d}}return null},b.prototype.setChildIndex=function(a,b){return a.parent!==this||this.getChildIndex(a)===b?!1:(this.removeChild(a),this.addChildAt(a,b),!0)},b.prototype.swapChildren=function(a,b){if(a.parent!==this||b.parent!==this)return!1;var c=this.getChildIndex(a),d=this.getChildIndex(b);return-1!==c&&-1!==d&&c!==d?(this.members[c]=b,this.members[d]=a,!0):!1},b.prototype.swapChildrenAt=function(a,b){var c=this.getChildAt(a),d=this.getChildAt(b);return null!==c&&null!==d?c==d||c.parent!==this||d.parent!==this?!1:(this.members[a]=d,this.members[b]=c,!0):!1},b.prototype.replaceChild=function(a,b){if(a===b)return!1;var c=this.getChildIndex(a);return c>-1?(b.parent&&b.parent.removeChild(b),this.removeChildAt(c),this.addChildAt(b,c),b.parent=null,!0):!1},b.prototype.forEach=function(a,b){for(var c=[],d=2;d0&&this.members.forEach(function(d){return b.apply(a,[d].concat(c))})},b.prototype.forEachAlive=function(a,b){for(var c=[],d=2;d0&&this.members.forEach(function(d){d.exists&&b.apply(a,[d].concat(c))})},b.prototype.setAll=function(a,b,c){if(null===a)for(var d=0;d0)for(var a=0;a-1&&this._trackingList.splice(b,1)},c.prototype.destroyUnused=function(){for(var a=0,b=0;b0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.Sprite=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f){return void 0===e&&(e=0),void 0===f&&(f=0),b.call(this,c,e,f),this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),a.Utils.Common.isString(d)&&(d=this.state.textures[d]),"undefined"==typeof d?(a.Log.error("A Texture Atlas was not passed when instantiating a new Static Image.","#static-image","#texture"),this.visible=!1,void(this.active=!1)):(this.atlas=d,this.cellIndex=this.atlas.cellIndex,this.width=d.cells[this.cellIndex].w,this.height=d.cells[this.cellIndex].h,this.transform.rotPointX=this.width/2,this.transform.rotPointY=this.height/2,void(this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))))}return __extends(c,b),c.prototype.objType=function(){return"StaticImage"},c.prototype.render=function(a){if(b.prototype.render.call(this,a),this.alpha>0){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty);var f=this.atlas.cells[this.cellIndex];c.drawImage(this.atlas.image,f.x,f.y,f.w,f.h,-d.rotPointX,-d.rotPointY,f.w,f.h),c.restore()}},c.prototype.renderGL=function(a,b,c){void 0===c&&(c=null),this.glRenderer.addToBatch(a,this,b)},c}(a.Entity);b.StaticImage=c}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h,i,j){void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g="#000000"),void 0===h&&(h=32),void 0===i&&(i="normal"),void 0===j&&(j="sans-serif"),b.call(this,c,e,f),this._tempDirty=!0,this.game.renderOption===a.RENDERER_WEBGL&&(this.glRenderer=this.game.renderer.requestSharedRenderer("TextureAtlasRenderer")),this._text=d,this._fontWeight=i,this._fontSize=h,this._fontColor=new a.Utils.Color(g),this._fontFamily=j,this._textAlign="left",this._baseline="top",this._tempDirty=!0,this._canvas=document.createElement("canvas"),this._canvas.width=2,this._canvas.height=2,this._ctx=this._canvas.getContext("2d"),this.atlas=new a.Textures.SingleImage(this.game.rnd.uuid(),this._canvas),this.state.textureLibrary.add(this.atlas),this.atlas.dirty=!0,this._alignWidth=0,this.box=this.components.add(new a.Components.Box(this,e,f,this.width,this.height))}return __extends(c,b),c.prototype.objType=function(){return"Textfield"},Object.defineProperty(c.prototype,"text",{get:function(){return this._text},set:function(a){this._text=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"color",{get:function(){return"#"+this._fontColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._fontColor.set.apply(this._fontColor,b),this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontWeight",{get:function(){return this._fontWeight},set:function(a){this._fontWeight=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontSize",{get:function(){return this._fontSize},set:function(a){this._fontSize=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fontFamily",{get:function(){return this._fontFamily},set:function(a){this._fontFamily=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"textAlign",{get:function(){return this._textAlign},set:function(a){this._textAlign=a,this._tempDirty=!0},enumerable:!0,configurable:!0}),c.prototype._renderText=function(){this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily;var b=this._ctx.measureText(this._text),c=b.width,d=1.3*this._fontSize;if(this._alignWidth=c,-1==a.Utils.Common.base2Sizes.indexOf(c)){for(var e=0;c>a.Utils.Common.base2Sizes[e];)e++;c=a.Utils.Common.base2Sizes[e]}if(-1==a.Utils.Common.base2Sizes.indexOf(d)){for(var e=0;d>a.Utils.Common.base2Sizes[e];)e++;d=a.Utils.Common.base2Sizes[e]}this._canvas.width=c,this._canvas.height=d,this._ctx.clearRect(0,0,c,d),this._ctx.font=this._fontWeight+" "+this._fontSize+"px "+this._fontFamily,this._ctx.fillStyle=this.color.slice(0,7),this._ctx.textBaseline=this._baseline,this._ctx.fillText(this._text,0,0),this.width=this._alignWidth,this.height=this._canvas.height,this.atlas.cells[0]={x:0,y:0,w:this._canvas.width,h:this._canvas.height,hitboxes:[{x:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_LEFT?0:this._textAlign===a.GameObjects.TextField.TEXT_ALIGN_CENTER?.5*-this._alignWidth:-this._alignWidth,y:0,w:this.width,h:this.height}]},this._tempDirty=!1,this.atlas.dirty=!0},c.prototype.render=function(){if(this.alpha>0&&this.visible){var b=this.game.stage.ctx;b.save();var c=this.transform;this.alpha>0&&this.alpha<=1&&(b.globalAlpha=this.alpha),this._tempDirty&&this._renderText();var d=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:d=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:d=.5*this._alignWidth;break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:d=this._alignWidth}var e=c.getConcatenatedMatrix();b.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),b.drawImage(this._canvas,0,0,this._canvas.width,this._canvas.height,-c.rotPointX-d,-c.rotPointY,this._canvas.width,this._canvas.height),b.restore()}},c.prototype.renderGL=function(b,c,d){void 0===d&&(d=null),this._tempDirty&&this._renderText();var e=[],f=this.transform,g=f.getConcatenatedMatrix(),h=0;switch(this._textAlign){case a.GameObjects.TextField.TEXT_ALIGN_LEFT:h=0;break;case a.GameObjects.TextField.TEXT_ALIGN_CENTER:h=-(.5*this._alignWidth);break;case a.GameObjects.TextField.TEXT_ALIGN_RIGHT:h=-this._alignWidth}var i=new a.Geom.Point(h-f.rotPointX,0-f.rotPointY),j=new a.Geom.Point(this._canvas.width+h-f.rotPointX,0-f.rotPointY),k=new a.Geom.Point(this._canvas.width+h-f.rotPointX,this._canvas.height-f.rotPointY),l=new a.Geom.Point(h-f.rotPointX,this._canvas.height-f.rotPointY);i=g.transformPoint(i),j=g.transformPoint(j),k=g.transformPoint(k),l=g.transformPoint(l),e.push(i.x,i.y,0,0,this.alpha,j.x,j.y,this._canvas.width,0,this.alpha,k.x,k.y,this._canvas.width,this._canvas.height,this.alpha,l.x,l.y,0,this._canvas.height,this.alpha),this.glRenderer.concatBatch(e)},c.TEXT_ALIGN_CENTER="center",c.TEXT_ALIGN_RIGHT="right",c.TEXT_ALIGN_LEFT="left",c}(a.Entity);b.TextField=c,b.Textfield=a.GameObjects.TextField}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=-1),this.allowCollisions=a.Components.ArcadePhysics.NONE,this.properties={},this.tilemap=b,this.index=c,this.cellIndex=d,this.offset=new a.Geom.Point(0,0)}return b.prototype.objType=function(){return"TileType"},b}();b.TileType=c}(c=b.Tilemap||(b.Tilemap={}))}(b=a.GameObjects||(a.GameObjects={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function c(b,c,d,e){void 0===e&&(e=0),this.tileWidth=0,this.tileHeight=0,this.width=0,this.height=0,this.properties={},this.tileTypes=[],this.createTileType(-1),this.layers=[],this.state=b,this.game=b.game,void 0!==c&&void 0!==d?this.createFromFileStore(c,d,e):(void 0!==c||void 0!==d)&&a.Log.warn("You must pass BOTH the TileMapDataKey and TextureAtlas inorder to create a TileMap from the File Store.","#tilemap")}return Object.defineProperty(c.prototype,"widthInPixels",{get:function(){return this.width*this.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"heightInPixels",{get:function(){return this.height*this.tileHeight},enumerable:!0,configurable:!0}),c.prototype.createFromFileStore=function(c,d,e){void 0===e&&(e=0);var f=null;switch(a.Utils.Common.isString(d)&&(d=this.state.textures[d]),typeof c){case"string":if(0==this.game.fileStore.exists(c))return a.Log.error("The JSON file you have told to use for a TileMap does not exist.","#tilemap","#json"),!1;f=JSON.parse(this.game.fileStore.getFile(c).data);break;case"object":f=c.isData&&c.dataType===a.Files.File.JSON?a.Utils.Common.isString(c.parse)?JSON.parse(c.data):c.data:c;break;default:a.Log.error("The type of TileMapData passed could not be idenified. Please either pass a name of JSON file to use OR an object to be used.","#tilemap")}this.orientation=void 0==f.orientation?b.ORTHOGONAL:f.orientation,this.tileWidth=void 0==f.tilewidth?32:f.tilewidth,this.tileHeight=void 0==f.tileheight?32:f.tileheight,this.width=f.width,this.height=f.height;for(var g in f.properties)this.properties[g]=f.properties[g];"undefined"!==f.tilesets&&-1!==e&&this._generateTypesFromTileset(f.tilesets,d,e);for(var h=0;hl;l+=h)for(var m=f;i>m;m+=g){var n=void 0==b.cells[c]?-1:c,o=this.createTileType(n);o.offset.x=k.x,o.offset.y=k.y,c++}for(var p in e.tileproperties){var o=this.tileTypes[parseInt(e.firstgid)+parseInt(p)];o.properties=e.tileproperties[p]}}},c.prototype.setTo=function(a,b,c,d){this.tileWidth=a,this.tileHeight=b,this.width=c,this.height=d},c.prototype.createTileType=function(a){void 0===a&&(a=-1);var c=new b.TileType(this,this.tileTypes.length,a);return this.tileTypes.push(c),c},c.prototype.createTileTypes=function(a){for(var b=[],c=0;c=d;d++)c.push(this.createTileType(d));return c},c.prototype.setCell=function(a,b){this.tileTypes[a].cellIndex=b},c.prototype.setCellsByRange=function(a,b,c){for(var d=a;a+c>d;d++)this.tileTypes[d].cellIndex=b,b++},c.prototype.createNewLayer=function(b,c,d,e,f,g,h,i,j){if(void 0===d&&(d=[]),void 0===e&&(e=this.width),void 0===f&&(f=this.height),void 0===g&&(g=0),void 0===h&&(h=0),void 0===i&&(i=this.tileWidth),void 0===j&&(j=this.tileHeight),d.lengthc||c>=this._data.length?-1:c},d.prototype.getTileFromXY=function(a,b){var c=this.getIndexFromXY(a,b);return-1!==c?this.tilemap.tileTypes[this._data[c]]:null},d.prototype.getIndexFromCoords=function(b,c){if(b>this.transform.worldX+this.widthInPixels||c>this.transform.worldY+this.heightInPixels||bg;g++)for(var f=b;b+d>f;f++){var h=this.getIndexFromXY(f,g);-1!==h&&(this._data[h]=this.game.rnd.pick(a))}},d.prototype.fill=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=this.width),void 0===e&&(e=this.height);for(var f=c;c+e>f;f++)for(var g=b;b+d>g;g++){var h=this.getIndexFromXY(g,f);-1!==h&&(this._data[h]=a)}},d.prototype.replaceTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&this._data[i]==a&&(this._data[i]=b)}},d.prototype.swapTiles=function(a,b,c,d,e,f){void 0===c&&(c=0),void 0===d&&(d=0),void 0===e&&(e=this.width),void 0===f&&(f=this.height);for(var g=d;d+f>g;g++)for(var h=c;c+e>h;h++){var i=this.getIndexFromXY(h,g);-1!==i&&(this._data[i]==a?this._data[i]=b:this._data[i]==b&&(this._data[i]=a))}},d.prototype.getOverlappingTiles=function(b,c){if(void 0===c&&(c=a.Components.ArcadePhysics.ANY),0==b.components.hasComponent("Box"))return[];var d=b.components.getComponent("Box").worldHitbox;if(d.left>this.transform.worldX+this.widthInPixels||d.rightthis.transform.worldY+this.heightInPixels)return[];for(var e=this.transform.worldX,f=this.transform.worldY,g=d.x-e,h=d.y-f,i=a.Utils.GameMath.snapToFloor(g,this.tileWidth)/this.tileWidth,j=a.Utils.GameMath.snapToFloor(h,this.tileHeight)/this.tileHeight,k=a.Utils.GameMath.snapToCeil(d.width,this.tileWidth)/this.tileWidth,l=a.Utils.GameMath.snapToCeil(d.height,this.tileHeight)/this.tileHeight,m=this.getCollidableTiles(i,j,k+1,l+1,c),n=0;nd.right||o.x+this.tileWidth+ed.bottom||o.y+this.tileHeight+fthis.width||c>this.height)){0>b&&(b=0),0>c&&(c=0),b+d>this.width&&(d=this.width-b),c+e>this.height&&(e=this.height-c);for(var h=c;c+e>h;h++)for(var i=b;b+d>i;i++){var j=this.getIndexFromXY(i,h);if(-1!==j){var k=this.tileData[j];(this.tilemap.tileTypes[k].allowCollisions&f)!==a.Components.ArcadePhysics.NONE&&g.push({index:j,type:k,x:i*this.tileWidth,y:h*this.tileHeight})}}return g}},d.prototype.update=function(){c.prototype.update.call(this)},d.prototype._calculateBoundaries=function(c,d){if(this.orientation==b.ORTHOGONAL){this._corner1.setTo(0,0),this._corner2.setTo(this.game.stage.width,0),this._corner3.setTo(this.game.stage.width,this.game.stage.height),this._corner4.setTo(0,this.game.stage.height),this._corner1=c.transformPoint(this._corner1),this._corner2=c.transformPoint(this._corner2),this._corner3=c.transformPoint(this._corner3),this._corner4=c.transformPoint(this._corner4);var e=d.clone();return e.invert(),this._corner1=e.transformPoint(this._corner1),this._corner2=e.transformPoint(this._corner2),this._corner3=e.transformPoint(this._corner3),this._corner4=e.transformPoint(this._corner4),this._startX=Math.min(this._corner1.x,this._corner2.x,this._corner3.x,this._corner4.x),this._startY=Math.min(this._corner1.y,this._corner2.y,this._corner3.y,this._corner4.y),this._maxX=Math.max(this._corner1.x,this._corner2.x,this._corner3.x,this._corner4.x),this._maxY=Math.max(this._corner1.y,this._corner2.y,this._corner3.y,this._corner4.y),this._startX/=this.tileWidth,this._startY/=this.tileHeight,this._maxX/=this.tileWidth,this._maxY/=this.tileHeight,this._startX=Math.floor(this._startX),this._startY=Math.floor(this._startY),this._maxX=Math.ceil(this._maxX),this._maxY=Math.ceil(this._maxY),this._startX=a.Utils.GameMath.clamp(this._startX,this.width),this._startY=a.Utils.GameMath.clamp(this._startY,this.height),this._maxX=a.Utils.GameMath.clamp(this._maxX,this.width),void(this._maxY=a.Utils.GameMath.clamp(this._maxY,this.height))}this.orientation==b.ISOMETRIC&&(this._startX=0,this._startY=0,this._maxX=this.width,this._maxY=this.height)},d.prototype.chartToScreen=function(a,b,c){return{x:a.x*b-a.y*b,y:a.x*c/2+a.y*c/2}},d.prototype.screenToChart=function(a,b,c){var d=Math.floor(a.x/b),e=Math.floor((a.y-d*(c/2))/c);return{x:d+e,y:e}},d.prototype.render=function(a){if(!(this.visible===!1||this.alpha<.1||this.exists===!1)){var c=this.game.stage.ctx;c.save(),this.alpha>0&&this.alpha<=1&&(c.globalAlpha=this.alpha);var d=this.transform,e=d.getConcatenatedMatrix();c.transform(e.a,e.b,e.c,e.d,e.tx,e.ty),this._calculateBoundaries(a,e);for(var f=this._startY;f1)&&(this._nowEntered=b),this.isDown===!1&&b.frameDuration<2&&(this._nowDown=b),this._dragEnabled&&0==this.isDragging&&1==this.isDown&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top,this._nowDragging=b)):this.isDown===!0?this._nowLeft=b:this.withinBounds===!0&&this._withinBounds.id==b.id&&(this._nowLeft=b))},c.prototype._updateMouse=function(){this._evaluateMousePointer(this.game.input.mouse.cursor),null!==this._nowLeft&&this._onLeft.dispatch(this.owner,this._nowLeft),null!==this._nowEntered&&this._onEntered.dispatch(this.owner,this._nowEntered),null!==this._nowDown&&this.isDown===!1&&(this._onDown.dispatch(this.owner,this._nowDown),this._isDown=this._nowDown,this._isUp=!1),1==this._dragEnabled&&this.isDragging===!1&&null!==this._nowDragging&&(this._onDragStarted.dispatch(this.owner,this._nowDragging),this._isDragging=this._nowDragging),this.isDown===!0&&null!==this._nowUp&&this._isDown.id===this._nowUp.id&&(this._onUp.dispatch(this.owner,this._nowUp),this.isDragging===!0&&this._isDragging.id==this._nowUp.id&&(this._isDragging=null,this._onDragStopped.dispatch(this.owner,this._nowUp)),this._isDown=null,this._isUp=!0)},c.prototype._evaluateMousePointer=function(b){this._tempPoint=this.game.cameras.defaultCamera.transformPoint(b.point),a.Geom.Intersect.pointToRectangle(this._tempPoint,this._box.worldHitbox).result?(this._dragEnabled&&this.isDragging===!1&&(this._distance.x=this._tempPoint.x-this._box.worldHitbox.left,this._distance.y=this._tempPoint.y-this._box.worldHitbox.top),this.withinBounds===!1&&(this._nowEntered=b,this._withinBounds=b,this._outsideBounds=!1,this._justEntered=!0)):this.withinBounds===!0&&this.isDragging===!1&&(this._nowLeft=b,this._withinBounds=null,this._outsideBounds=!0),b.isDown===!0?(this._justEntered&&(this._isDown=b,this._isUp=!1,this._tempDragDisabled=!0),this.withinBounds===!0&&this.isDown===!1&&null===this._nowDown&&(this._nowDown=b),this._dragEnabled===!0&&0==this.isDragging&&this._tempDragDisabled===!1&&1==this.isDown&&(this._nowDragging=b)):(this._tempDragDisabled===!0&&(this._tempDragDisabled=!1),this.isDown===!0&&(this._nowUp=b)),this._justEntered&&(this._justEntered=!1)},c.prototype.destroy=function(){b.prototype.destroy.call(this),this.enabled=!1,delete this._box,delete this._isDown,delete this._isUp,delete this._isDragging,delete this._dragEnabled,this._onDown&&this._onDown.dispose(),delete this._onDown,this._onDragStarted&&this._onDragStarted.dispose(),delete this._onDragStarted,this._onUp&&this._onUp.dispose(),delete this._onUp,this._onLeft&&this._onLeft.dispose(),delete this._onLeft,this._onEntered&&this._onEntered.dispose(),delete this._onEntered,this._onDragStopped&&this._onDragStopped.dispose(),delete this._onDragStopped,delete this._dragDistance},c}(a.Component);b.Input=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(a){function b(b){a.call(this,b,"Sound"),this._audio=[]}return __extends(b,a),b.prototype.objType=function(){return"Sound"},b.prototype.addSound=function(a,b,c,d){if(void 0===c&&(c=1),void 0===d&&(d=!1),1!=this._validate(a)){var e=this.game.audio.add(b,c,d);return this._audio[a]=e,e}},b.prototype.removeSound=function(a){0!=this._validate(a)&&(this._audio[a].stop(),this._audio[a].destroy(),delete this._audio[a])},b.prototype.getSound=function(a){return 0!=this._validate(a)?this._audio[a]:void 0},b.prototype._validate=function(a){return void 0===this._audio[a]?!1:!0},b.prototype.play=function(a){0!=this._validate(a)&&this._audio[a].play()},b.prototype.stop=function(a){0!=this._validate(a)&&this._audio[a].stop()},b.prototype.pause=function(a){0!=this._validate(a)&&this._audio[a].pause()},b.prototype.resume=function(a){0!=this._validate(a)&&this._audio[a].resume()},b.prototype.destroy=function(){a.prototype.destroy.call(this);for(var b in this._audio)this._audio[b].stop(),this._audio[b].destroy(),delete this._audio[b];delete this._audio},b}(a.Component);b.Sound=c}(b=a.Components||(a.Components={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(d,e){b.call(this,d,"ArcadePhysics"),this._callbackFunction=null,this._callbackContext=null,this.parent=d,this.box=e,this.transform=this.parent.transform,this.last=new a.Geom.Point(this.transform.worldX,this.transform.worldY),this.mass=1,this.elasticity=0,this.immovable=!1,this.moves=!0,this.touching=c.NONE,this.wasTouching=c.NONE,this.allowCollisions=c.ANY,this.velocity=new a.Geom.Point,this.acceleration=new a.Geom.Point,this.drag=new a.Geom.Point,this.maxVelocity=new a.Geom.Point(1e4,1e4),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e4 -}return __extends(c,b),c.prototype.isTouching=function(a){return(this.touching&a)==a},c.prototype.solid=function(a){return void 0!==a&&(this.allowCollisions=a?c.ANY:c.NONE),(this.allowCollisions&c.ANY)>c.NONE},c.prototype.setCallback=function(a,b){this._callbackFunction=a,this._callbackContext=b},c.separate=function(a,b){var c=this.separateX(a,b),d=this.separateY(a,b);return c||d},c.separateX=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldX-e.last.x,i=f.transform.worldX-f.last.x;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x-(h>0?h:0),e.last.y+e.box.hitboxOffset.y,l.width+(h>0?h:-h),l.height),o=new a.Geom.Rectangle(m.x-(i>0?i:0),f.last.y+f.box.hitboxOffset.y,m.width+(i>0?i:-i),m.height);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.x+l.width-m.x,!(g>p)&&e.allowCollisions&c.RIGHT&&f.allowCollisions&c.LEFT?(e.touching|=c.RIGHT,f.touching|=c.LEFT):g=0):(g=l.x-m.width-m.x,!(-g>p)&&e.allowCollisions&c.LEFT&&f.allowCollisions&c.RIGHT?(e.touching|=c.LEFT,f.touching|=c.RIGHT):g=0)}if(0!=g){var q=e.velocity.x,r=f.velocity.x;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.x=f.transform.x+g,f.velocity.x=q-r*f.elasticity):(e.transform.x=e.transform.x-g,e.velocity.x=r-q*e.elasticity);else{g*=.5,e.transform.x=e.transform.x-g,f.transform.x=f.transform.x+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.x=u+s*e.elasticity,f.velocity.x=u+t*f.elasticity}return!0}return!1},c.separateY=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldY-e.last.y,i=f.transform.worldY-f.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x,l.y-(h>0?h:0),l.width,l.height+j),o=new a.Geom.Rectangle(m.x,m.y-(i>0?i:0),m.width,m.height+k);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.y+l.height-m.y,!(g>p)&&e.allowCollisions&c.DOWN&&f.allowCollisions&c.UP?(e.touching|=c.DOWN,f.touching|=c.UP):g=0):(g=l.y-m.height-m.y,!(-g>p)&&e.allowCollisions&c.UP&&f.allowCollisions&c.DOWN?(e.touching|=c.UP,f.touching|=c.DOWN):g=0),0!=g){var q=e.velocity.y,r=f.velocity.y;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.y=f.transform.y+g,f.velocity.y=q-r*f.elasticity,b.active&&e.moves&&i>h&&(f.transform.x=f.transform.worldX+b.transform.worldX-e.last.x)):(e.transform.y=e.transform.y-g,e.velocity.y=r-q*e.elasticity,d.active&&f.moves&&h>i&&(e.transform.x=e.transform.worldX+d.transform.worldX-f.last.x));else{g*=.5,e.transform.y=e.transform.y-g,f.transform.y=f.transform.y+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.y=u+s*e.elasticity,f.velocity.y=u+t*f.elasticity}return!0}}return!1},c.separateTiles=function(a,b,c){if(0==a.components.hasComponent("ArcadePhysics"))return!1;if(a.components.getComponent("ArcadePhysics").immovable)return!1;for(var d=!1,e=!1,f=0;f0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=g.transform.worldX+e.x,r=new a.Geom.Rectangle(n.x-(h>0?h:0),f.last.y+f.box.hitboxOffset.y,n.width+(h>0?h:-h),n.height),s=new a.Geom.Rectangle(q-(i>0?i:0),g.last.y+e.y,d.tileWidth+(i>0?i:-i),d.tileHeight);if(r.x+r.width>s.x&&r.xs.y&&r.yi?(l=n.x+n.width-q,!(l>m)&&f.allowCollisions&c.RIGHT&&o[p[e.index]].allowCollisions&c.LEFT?f.touching|=c.RIGHT:l=0):(l=n.x-d.tileWidth-q,!(-l>m)&&f.allowCollisions&c.LEFT&&o[p[e.index]].allowCollisions&c.RIGHT?f.touching|=c.LEFT:l=0),0!=l)){var t=f.velocity.x,u=g.velocity.x;return f.transform.x=f.transform.x-l,f.velocity.x=u-t*f.elasticity,!0}return!1},c.separateTilesY=function(b,d,e){var f=b.components.getComponent("ArcadePhysics"),g=d.components.getComponent("ArcadePhysics"),h=f.transform.worldY-f.last.y,i=g.transform.worldY-g.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=d.transform.worldY+e.y,r=new a.Geom.Rectangle(n.x,n.y-(h>0?h:0),n.width,n.height+j),s=new a.Geom.Rectangle(g.transform.worldX+e.x,q-(i>0?i:0),d.tileWidth,d.tileHeight+k);if(r.x+r.width>s.x&&r.xs.y&&r.yi?(l=n.y+n.height-q,!(l>m)&&f.allowCollisions&c.DOWN&&o[p[e.index]].allowCollisions&c.UP?f.touching|=c.DOWN:l=0):(l=n.y-d.tileHeight-q,!(-l>m)&&f.allowCollisions&c.UP&&o[p[e.index]].allowCollisions&c.DOWN?f.touching|=c.UP:l=0),0!=l)){var t=f.velocity.y,u=g.velocity.y;return f.transform.y=f.transform.y-l,f.velocity.y=u-t*f.elasticity,!0}return!1},c.prototype.overlapsTiles=function(b,d,e){if(void 0===d&&(d=!1),void 0===e&&(e=a.Components.ArcadePhysics.ANY),this.parent.childType()!==a.TILE_LAYER)return!1;var f=this.parent.getOverlappingTiles(b,e);return f.length>0?(d&&c.separateTiles(b,this.parent,f),!0):!1},c.prototype.overlaps=function(a,b){if(void 0===b&&(b=!1),0!=a.components.hasComponent("Box")){var d=a.components.getComponent("Box"),e=d.worldHitbox.x+d.worldHitbox.width>this.box.worldHitbox.x&&d.worldHitbox.xthis.box.worldHitbox.y&&d.worldHitbox.y0?a-=d:0>a+d?a+=d:a=0),0!=a&&1e4!=e&&(a>e?a=e:-e>a&&(a=-e)),a},c.prototype.updateMotion=function(){var a,b;b=(c.computeVelocity(this.angularVelocity,this.angularAcceleration,this.angularDrag,this.maxAngular)-this.angularVelocity)/2,this.angularVelocity+=b,this.transform.rotation+=this.angularVelocity*c.updateInterval,this.angularVelocity+=b,b=(c.computeVelocity(this.velocity.x,this.acceleration.x,this.drag.x,this.maxVelocity.x)-this.velocity.x)/2,this.velocity.x+=b,a=this.velocity.x*c.updateInterval,this.velocity.x+=b,this.transform.x=this.transform.x+a,b=(c.computeVelocity(this.velocity.y,this.acceleration.y,this.drag.y,this.maxVelocity.y)-this.velocity.y)/2,this.velocity.y+=b,a=this.velocity.y*c.updateInterval,this.velocity.y+=b,this.transform.y=this.transform.y+a},c.prototype.update=function(){this.last.x=this.transform.worldX,this.last.y=this.transform.worldY,this.moves&&this.updateMotion(),this.wasTouching=this.touching,this.touching=c.NONE},c.prototype.destroy=function(){b.prototype.destroy.call(this),delete this.transform,delete this.owner,delete this._callbackContext,delete this._callbackFunction},c.prototype.objType=function(){return"ArcadePhysics"},c.collide=function(a,b,d){return void 0===d&&(d=!0),c.overlaps(a,b,d)},c.collideGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsObjectGroup(a,b,d)},c.collideGroupGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsGroupGroup(a,b,d)},c.overlaps=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlaps(b,c)},c.overlapsObjectGroup=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlapsGroup(b,c)},c.overlapsGroupGroup=function(b,d,e){void 0===e&&(e=!0);for(var f=!1,g=b.members,h=0;h=this._loadingList.length&&(this._queueLoading=!1,this.clearQueue(),this.onQueueComplete.dispatch()))},b.prototype._startLoadingQueue=function(){return this._loadingQueue.length<=0?(a.Log.log("Kiwi.Files.Loader: No queued files to load.","#loading"),!1):this._loadingQueue[0].loading?!1:(this._loadingQueue[0].onComplete.addOnce(this._queueFileComplete,this,1),this._loadingQueue[0].load(),!0)},b.prototype._queueFileComplete=function(b){var c=this._loadingQueue.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingQueue.","#loading","#error"):(this._loadingQueue.splice(c,1),void this._startLoadingQueue())},b.prototype._startLoadingParallel=function(a){a.loading||(a.onComplete.add(this._parallelFileComplete,this,1),a.load())},b.prototype._startLoadingAllParallel=function(){for(var a=0;a=this._loadingList.length)return this._queueLoading=!1,void this.onSizeCallback.call(this.onSizeContext,this._bytesTotal);var a=this._loadingList[this._currentFileIndex];if(a.detailsReceived)this._detailsReceived();else{var b=a.loadDetails(this._detailsReceived,this);b||this._detailsReceived()}},b.prototype._detailsReceived=function(){var a=this._loadingList[this._currentFileIndex];a.detailsReceived&&(this._bytesTotal+=a.size),this._currentFileIndex++,this._calculateNextFileSize()},b.prototype.addImage=function(b,c,d,e,f,g,h){void 0===h&&(h=!0);var i={type:a.Files.File.IMAGE,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var j=b;i.key=j.key,i.url=j.url,i.metadata={width:j.width,height:j.height,offsetX:j.offsetX,offsetY:j.offsetY},j.xhrLoading&&(i.xhrLoading=j.xhrLoading),j.state&&(i.state=j.state),j.tags&&(i.tags=j.tags)}else!h&&this.game.states.current&&(i.state=this.game.states.current),i.key=b,i.url=c,i.metadata={width:d,height:e,offsetX:f,offsetY:g};var k=new a.Files.TextureFile(this.game,i);return this.addFileToQueue(k),k},b.prototype.addSpriteSheet=function(b,c,d,e,f,g,h,i,j,k,l,m){void 0===m&&(m=!0);var n={type:a.Files.File.SPRITE_SHEET,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var o=b;n.key=o.key,n.url=o.url,n.metadata={frameWidth:o.frameWidth,frameHeight:o.frameHeight,numCells:o.numCells,rows:o.rows,cols:o.cols,sheetOffsetX:o.sheetOffsetX,sheetOffsetY:o.sheetOffsetY,cellOffsetX:o.cellOffsetX,cellOffsetY:o.cellOffsetY},o.xhrLoading&&(n.xhrLoading=o.xhrLoading),o.state&&(n.state=o.state),o.tags&&(n.tags=o.tags)}else!m&&this.game.states.current&&(n.state=this.game.states.current),n.key=b,n.url=c,n.metadata={frameWidth:d,frameHeight:e,numCells:f,rows:g,cols:h,sheetOffsetX:i,sheetOffsetY:j,cellOffsetX:k,cellOffsetY:l};var p=new a.Files.TextureFile(this.game,n);return this.addFileToQueue(p),p},b.prototype.addTextureAtlas=function(b,c,d,e,f){void 0===f&&(f=!0);var g={type:a.Files.File.TEXTURE_ATLAS,key:b,url:c,fileStore:this.game.fileStore,metadata:{jsonID:d}},h={type:a.Files.File.JSON,key:d,url:e,fileStore:this.game.fileStore,metadata:{imageID:b}};if(!f&&this.game.states.current&&(g.state=this.game.states.current,h.state=this.game.states.current),a.Utils.Common.isObject(b)){var i=b;g.key=i.textureAtlasKey,g.url=i.textureAtlasURL,h.key=i.jsonKey,h.url=i.jsonURL,g.metadata.jsonID=h.key,h.metadata.imageID=g.key,i.state&&(g.state=i.state,h.state=i.state),i.xhrLoading&&(g.xhrLoading=i.xhrLoading),i.tags&&(h.tags=i.tags,g.tags=i.tags)}var j=new a.Files.TextureFile(this.game,g),k=new a.Files.DataFile(this.game,h);return this.addFileToQueue(j),this.addFileToQueue(k),j},b.prototype.addAudio=function(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!0);var f={type:a.Files.File.AUDIO,key:null,url:null,state:null,fileStore:this.game.fileStore};a.Utils.Common.isObject(b)?(f=b,f.fileStore=this.game.fileStore):(f.key=b,f.url=c,!d&&this.game.states.current&&(f.state=this.game.states.current));var g,h,i=0;for(g=a.Utils.Common.isString(f.url)?[f.url]:f.url;i-1?(this.name=a.substr(a.lastIndexOf("/")+1),this.path=a.substr(0,a.lastIndexOf("/")+1)):(this.path="",this.name=a),this.extension=a.substr(a.lastIndexOf(".")+1).toLowerCase()},b.prototype.objType=function(){return"File"},Object.defineProperty(b.prototype,"loadInParallel",{get:function(){return this._loadInParallel},enumerable:!0,configurable:!0}),b.prototype.load=function(b,c,d,e,f){return this.loading?void a.Log.error("Kiwi.Files.File: File loading is in progress. Cannot be told to load again.","#loading"):(a.Log.log("Kiwi.Files.File: Starting to load '"+this.name+"'","#file","#loading"),b&&this.onComplete.add(b),c&&this.onProgress.add(c),d&&(this.fileStore=d),"undefined"!=typeof e&&(this.maxLoadAttempts=e),"undefined"!=typeof f&&(this.timeOutDelay=f),this._start(),void this._load())},b.prototype._load=function(){this.attemptCounter++,this.xhrLoader("GET","text")},b.prototype.loadProgress=function(){this.onProgress.dispatch(this)},b.prototype.loadSuccess=function(){this.complete||(this.success=!0,this.hasError=!1,this._stop(),this.fileStore&&this.fileStore.addFile(this.key,this),this.onComplete.dispatch(this))},b.prototype.loadError=function(b){this.attemptCounter>=this.maxLoadAttempts?(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'. Trying Again","#loading"),this.hasError=!0,this.success=!1,this.error=b,this._stop(),this.onComplete.dispatch(this)):(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'","#loading"),this._load())},b.prototype.xhrLoader=function(a,b,c){var d=this;void 0===a&&(a="GET"),void 0===b&&(b="text"),void 0===c&&(c=this.timeOutDelay),this._xhr=new XMLHttpRequest,this._xhr.open("GET",this.URL,!0),null!==c&&(this._xhr.timeout=c),this._xhr.responseType=b,this._xhr.onload=function(a){return d.xhrOnLoad(a)},this._xhr.onerror=function(a){return d.loadError(a)},this._xhr.onprogress=function(a){return d.xhrOnProgress(a)},this._xhr.onreadystatechange=function(){return function(){this.readyState=this._xhr.readyState}},this._xhr.onloadstart=function(){return function(a){this.timeStarted=a.timeStamp,this.lastProgress=a.timeStamp}},this._xhr.ontimeout=function(){return function(){this.hasTimedOut=!0}},this._xhr.send()},b.prototype.xhrOnProgress=function(a){this.bytesLoaded=parseInt(a.loaded),this.bytesTotal=parseInt(a.total),this.percentLoaded=Math.round(this.bytesLoaded/this.bytesTotal*100),this.onProgress.dispatch(this)},b.prototype.xhrOnLoad=function(a){this.status=this._xhr.status,this.statusText=this._xhr.statusText,this._xhr.response?(this._getXhrHeaderInfo(),this.buffer=this._xhr.response,this.processXhr(this._xhr.response)):this.loadError(a)},b.prototype.processXhr=function(a){this.data=a,this.loadSuccess()},b.prototype._start=function(){this.attemptCounter=0,this.loading=!0,this.timeStarted=Date.now(),this.percentLoaded=0},b.prototype._stop=function(){this.loading=!1,this.complete=!0,this.percentLoaded=100,this.timeFinished=Date.now(),this.duration=this.timeFinished-this.timeStarted},b.prototype.loadDetails=function(b,c){return void 0===b&&(b=null),void 0===c&&(c=null),this.loading?(a.Log.error("Kiwi.Files.File: Cannot get the file details whilst the file is already loading"),!1):(b&&(this.headCompleteCallback=b),c&&(this.headCompleteContext=c),this.xhrHeadRequest(),!0)},b.prototype._getXhrHeaderInfo=function(){this._xhr&&(this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.type=this._xhr.getResponseHeader("Content-Type"),this.size=parseInt(this._xhr.getResponseHeader("Content-Length")),this.lastModified=this._xhr.getResponseHeader("Last-Modified"),this.ETag=this._xhr.getResponseHeader("ETag"),this.detailsReceived=!0)},b.prototype.xhrHeadRequest=function(){var a=this;this._xhr=new XMLHttpRequest,this._xhr.open("HEAD",this.fileURL,!0),null!==this.timeOutDelay&&(this._xhr.timeout=this.timeOutDelay),this._xhr.onload=function(b){return a.xhrHeadOnLoad(b)},this._xhr.onerror=function(b){return a.xhrHeadOnError(b)},this._xhr.send()},b.prototype.xhrHeadOnError=function(){this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!1)},b.prototype.xhrHeadOnLoad=function(){200===this._xhr.status?(this._getXhrHeaderInfo(),this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!0)):this.xhrHeadOnError(null)},b.prototype.addTag=function(a){-1==this._tags.indexOf(a)&&this._tags.push(a)},b.prototype.removeTag=function(a){var b=this._tags.indexOf(a);-1!=b&&this._tags.splice(b,1)},b.prototype.hasTag=function(a){return-1==this._tags.indexOf(a)?!1:!0},Object.defineProperty(b.prototype,"isTexture",{get:function(){return a.Files.TextureFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isAudio",{get:function(){return a.Files.AudioFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isData",{get:function(){return a.Files.DataFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this.fileStore&&this.fileStore.removeFile(this.key),this.onComplete.dispose(),this.onProgress.dispose(),delete this.fileStore,delete this._xhr,delete this.data,delete this.buffer,delete this.game,delete this.error,delete this.headCompleteCallback,delete this.headCompleteContext,delete this.onComplete,delete this.onProgress,delete this.ownerState},Object.defineProperty(b.prototype,"fileName",{get:function(){return this.name},set:function(a){this.name=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"filePath",{get:function(){return this.path},set:function(a){this.path=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileExtension",{get:function(){return this.extension},set:function(a){this.extension=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileURL",{get:function(){return this.URL},set:function(a){this.URL=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileType",{get:function(){return this.type},set:function(a){this.type=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileSize",{get:function(){return this.size},set:function(a){this.size=a},enumerable:!0,configurable:!0}),b.prototype.getFileDetails=function(a,b,c){void 0===a&&(a=null),void 0===c&&(c=null),c&&(this.timeOutDelay=c),this.loadDetails(a,null)},b.TIMEOUT_DELAY=4e3,b.MAX_LOAD_ATTEMPTS=2,b.IMAGE=0,b.SPRITE_SHEET=1,b.TEXTURE_ATLAS=2,b.AUDIO=3,b.JSON=4,b.XML=5,b.BINARY_DATA=6,b.TEXT_DATA=7,b.UNKNOWN=8,b}();b.File=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._size=0,this._game=a,this._files={}}return a.prototype.objType=function(){return"FileStore"},a.prototype.boot=function(){},a.prototype.getFile=function(a){return this._files[a]},a.prototype.getFilesByTag=function(a){var b={};for(var c in this._files)this._files[c].hasTag(a)&&(b[c]=this._files[c]);return b},a.prototype.removeFilesByTag=function(a){var b=0;for(var c in this._files)this._files[c].hasTag(a)&&(this.removeFile(c),b++);return b},Object.defineProperty(a.prototype,"keys",{get:function(){var a=new Array;for(var b in this._files)a.push(b);return a},enumerable:!0,configurable:!0}),a.prototype.size=function(){return this._size},a.prototype.addFile=function(a,b){return this._files[a]?!1:(this._files[a]=b,this._size++,!0)},a.prototype.exists=function(a){return this._files[a]?!0:!1},a.prototype.removeStateFiles=function(a){for(var b in this._files)this._files[b].ownerState===a&&this.removeFile(b)},a.prototype.removeFile=function(a,b){void 0===b&&(b=!1);var c=this._files[a];return c?(this._files[a]=null,delete this._files[a],b&&this._files[a].destroy(),!0):!1},a}();a.FileStore=b}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this.isReady=!1,this.container=null,this.input=null}return b.prototype.objType=function(){return"Bootstrap"},b.prototype.boot=function(a,b,c){var d=this;void 0===b&&(b=null),void 0===c&&(c=!0),this._callback=b,this._domParent=a,this._createContainer=c,"complete"===document.readyState||"interactive"===document.readyState?this.ready():(document.addEventListener("DOMContentLoaded",function(){return d.ready()},!1),window.addEventListener("load",function(){return d.ready()},!1))},b.prototype.ready=function(){var b=this; -this.isReady!==!0&&(document.body?(this.isReady=!0,this._createContainer===!0&&(""===this._domParent?(a.Log.log(" Kiwi.Game: No DOM parent specified. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer("KiwiGame"+Date.now().toString()),document.body.appendChild(this.container)):document.querySelector(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.querySelector(this._domParent),this._setupContainer()):document.getElementById(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.getElementById(this._domParent),this._setupContainer()):(a.Log.log(" Kiwi.Game: The element '"+this._domParent+"' could not be found. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer(this._domParent),document.body.appendChild(this.container))),null!==this._callback&&this._callback()):window.setTimeout(function(){return b.ready()},13))},b.prototype._setupContainer=function(b){void 0===b&&(b=""),b&&(this.container.id=b),this.container.style.width=a.Stage.DEFAULT_WIDTH+"px",this.container.style.height=a.Stage.DEFAULT_HEIGHT+"px",this.container.style.position="relative",this.container.style.overflow="hidden"},b}();b.Bootstrap=c}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.blob=!1,this.touch=!1,this.pointerEnabled=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.ieMobile=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webaudio=!1,this.ogg=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkDevice(),this._checkFeatures(),this._checkOS()}return a.prototype.objType=function(){return"Device"},a.prototype._checkOS=function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows Phone/.test(a)?this.windowsPhone=!0:/Windows/.test(a)&&(this.windows=!0)},a.prototype._checkFeatures=function(){"undefined"!=typeof window.Blob&&(this.blob=!0),this.canvas=!!window.CanvasRenderingContext2D,this.webGL=!!window.WebGLRenderingContext;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0)&&(this.touch=!0),(window.navigator.pointerEnabled||window.navigator.msPointerEnabled)&&(this.pointerEnabled=!0)},a.prototype._checkBrowser=function(){{var a=navigator.userAgent;navigator.appName}/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1),/IEMobile/.test(a)&&(this.ieMobile=!0)):/Trident/.test(a)?(this.ie=!0,/rv:(\d+\.\d+)\)/.test(a),this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},a.prototype._checkAudio=function(){this.audioData=!!window.Audio,this.webaudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0))}catch(c){}},a.prototype._checkDevice=function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},a.prototype.getAll=function(){var a="";return a=a.concat("Device\n"),a=a.concat("iPhone : "+this.iPhone+"\n"),a=a.concat("iPhone4 : "+this.iPhone4+"\n"),a=a.concat("iPad : "+this.iPad+"\n"),a=a.concat("\n"),a=a.concat("Operating System\n"),a=a.concat("iOS: "+this.iOS+"\n"),a=a.concat("Android: "+this.android+"\n"),a=a.concat("ChromeOS: "+this.chromeOS+"\n"),a=a.concat("Linux: "+this.linux+"\n"),a=a.concat("MacOS: "+this.macOS+"\n"),a=a.concat("Windows: "+this.windows+"\n"),a=a.concat("\n"),a=a.concat("Browser\n"),a=a.concat("Arora: "+this.arora+"\n"),a=a.concat("Chrome: "+this.chrome+"\n"),a=a.concat("Epiphany: "+this.epiphany+"\n"),a=a.concat("Firefox: "+this.firefox+"\n"),a=a.concat("Internet Explorer: "+this.ie+" ("+this.ieVersion+")\n"),a=a.concat("Mobile Safari: "+this.mobileSafari+"\n"),a=a.concat("Midori: "+this.midori+"\n"),a=a.concat("Opera: "+this.opera+"\n"),a=a.concat("Safari: "+this.safari+"\n"),a=a.concat("\n"),a=a.concat("Features\n"),a=a.concat("Blob: "+this.blob+"\n"),a=a.concat("Canvas: "+this.canvas+"\n"),a=a.concat("File: "+this.file+"\n"),a=a.concat("FileSystem: "+this.fileSystem+"\n"),a=a.concat("LocalStorage: "+this.localStorage+"\n"),a=a.concat("WebGL: "+this.webGL+"\n"),a=a.concat("Worker: "+this.worker+"\n"),a=a.concat("Touch: "+this.touch+"\n"),a=a.concat("\n"),a=a.concat("Audio\n"),a=a.concat("Audio Data: "+this.canvas+"\n"),a=a.concat("Web Audio: "+this.canvas+"\n"),a=a.concat("Can play OGG: "+this.canvas+"\n"),a=a.concat("Can play MP3: "+this.canvas+"\n"),a=a.concat("Can play M4A: "+this.canvas+"\n"),a=a.concat("Can play WAV: "+this.canvas+"\n")},a}();a.Device=b}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e){this.dirty=!1,this.cellIndex=0,this.name=a,this.cells=c||new Array,this.sequences=e||new Array,this.image=d,this._type=b}return b.prototype.objType=function(){return"TextureAtlas"},Object.defineProperty(b.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),b.prototype.createGLTextureWrapper=function(b,c){this.glTextureWrapper=new a.Renderers.GLTextureWrapper(b,this),c.registerTextureWrapper(b,this.glTextureWrapper)},b.prototype.enableGL=function(a,b,c){b.updateTextureSize(a,new Float32Array([this.image.width,this.image.height])),c.useTexture(a,this.glTextureWrapper),this.dirty&&this.refreshTextureGL(a)},b.prototype.refreshTextureGL=function(a){this.glTextureWrapper&&this.glTextureWrapper.refreshTexture(a),this.dirty=!1},b.prototype.readJSON=function(b){var c=JSON.parse(b);void 0!==c.name&&(this.name=c.name);for(var d=0;d=this.numCells||(b.push({x:d,y:e,w:this.cellWidth,h:this.cellHeight,hitboxes:[{x:0,y:0,w:this.cellWidth,h:this.cellHeight}]}),c.push(f++),d+=this.cellOffsetX+this.cellWidth);d=this.sheetOffsetX,e+=this.cellOffsetY+this.cellHeight}return this.sequences=new Array,this.sequences.push(new a.Animations.Sequence("default",c)),b},c}(b.TextureAtlas);b.SpriteSheet=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h){this.width=e||d.width,this.height=f||d.height,this.offsetX=g||0,this.offsetY=h||0,b.call(this,c,a.Textures.TextureAtlas.SINGLE_IMAGE,this.generateAtlasCells(),d)}return __extends(c,b),c.prototype.objType=function(){return"SingleImage"},c.prototype.generateAtlasCells=function(){return[{x:this.offsetX,y:this.offsetY,w:this.width,h:this.height,hitboxes:[{x:0,y:0,w:this.width,h:this.height}]}]},c}(b.TextureAtlas);b.SingleImage=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Back"},a.In=function(a){var b=1.70158;return a*a*((b+1)*a-b)},a.Out=function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},a.InOut=function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)},a}();a.Back=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"Bounce"},b.In=function(b){return 1-a.Animations.Tweens.Easing.Bounce.Out(1-b)},b.Out=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},b.InOut=function(b){return.5>b?.5*a.Animations.Tweens.Easing.Bounce.In(2*b):.5*a.Animations.Tweens.Easing.Bounce.Out(2*b-1)+.5},b}();b.Bounce=c}(c=b.Easing||(b.Easing={}))}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Circular"},a.In=function(a){return 1-Math.sqrt(1-a*a)},a.Out=function(a){return Math.sqrt(1- --a*a)},a.InOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},a}();a.Circular=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Cubic"},a.In=function(a){return a*a*a},a.Out=function(a){return--a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},a}();a.Cubic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Elastic"},a.In=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)))},a.Out=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin(2*(a-b)*Math.PI/d)+1)},a.InOut=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d):c*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)*.5+1)},a}();a.Elastic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Exponential"},a.In=function(a){return 0===a?0:Math.pow(1024,a-1)},a.Out=function(a){return 1===a?1:1-Math.pow(2,-10*a)},a.InOut=function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)},a}();a.Exponential=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Linear"},a.None=function(a){return a},a}();a.Linear=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quadratic"},a.In=function(a){return a*a},a.Out=function(a){return a*(2-a)},a.InOut=function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)},a}();a.Quadratic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quartic"},a.In=function(a){return a*a*a*a},a.Out=function(a){return 1- --a*a*a*a},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},a}();a.Quartic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quintic"},a.In=function(a){return a*a*a*a*a},a.Out=function(a){return--a*a*a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},a}();a.Quintic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Sinusoidal"},a.In=function(a){return 1-Math.cos(a*Math.PI/2)},a.Out=function(a){return Math.sin(a*Math.PI/2)},a.InOut=function(a){return.5*(1-Math.cos(Math.PI*a))},a}();a.Sinusoidal=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(a,b){this._game=a,this._tweens=[],this.clock=b||this._game.time.clock}return b.prototype.objType=function(){return"TweenManager"},b.prototype.getAll=function(){return this._tweens},b.prototype.removeAll=function(){this._tweens.length=0},b.prototype.create=function(b){var c=new a.Animations.Tween(b,this._game);return this.validateClock(),c.manager=this,c},b.prototype.add=function(a){return a.setParent(this._game),a.manager=this,this.validateClock(),this._tweens.push(a),a},b.prototype.remove=function(a){var b=this._tweens.indexOf(a);return-1!==b&&this._tweens.splice(b,1),a},b.prototype.update=function(){var a=0,b=this._tweens.length;if(0===this._tweens.length)return!1;for(;b>a;)this._tweens[a].update(1e3*this.clock.elapsed())?a++:(this._tweens.splice(a,1),b--);return!0},b.prototype.validateClock=function(){this.clock||(this.clock=this._game.time.clock,this.clock||a.Log.error("Tween manager could not find valid clock!"))},b}();b.TweenManager=c}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){void 0===c&&(c=null),this._game=null,this._manager=null,this._object=null,this._valuesStart={},this._valuesEnd={},this._duration=1e3,this._delayTime=0,this._startTime=null,this._easingFunction=a.Animations.Tweens.Easing.Linear.None,this._interpolationFunction=a.Utils.GameMath.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartContext=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onUpdateContext=null,this._onCompleteCallback=null,this._onCompleteCalled=!1,this._onCompleteContext=null,this.isRunning=!1,this._object=b,null!==c&&(this._game=c,this._manager=this._game.tweens),this.isRunning=!1}return b.prototype.objType=function(){return"Tween"},Object.defineProperty(b.prototype,"manager",{get:function(){return this._manager},set:function(a){this._manager=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"object",{get:function(){return this._object},set:function(a){var b,c={};this._object=a;for(b in this._valuesEnd)a[b]&&(c[b]=this._valuesEnd[b]);this._valuesEnd=c},enumerable:!0,configurable:!0}),b.prototype.to=function(a,b,c,d){return void 0===b&&(b=1e3),void 0===c&&(c=null),void 0===d&&(d=!1),this._duration=b,this._valuesEnd=a,null!==c&&(this._easingFunction=c),d===!0?this.start():this},b.prototype.start=function(){var a;if(null!==this._game&&null!==this._object){this.isRunning=!0,this._manager.add(this),this._onStartCallbackFired=!1,this._onCompleteCalled=!1,this._startTime=1e3*this._manager.clock.elapsed()+this._delayTime;for(var a in this._valuesEnd)if(null!==this._object[a]&&a in this._object){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]="function"==typeof this._object[a]?this._object[a]():this._object[a]}return this}},b.prototype.stop=function(){return null!==this._manager&&this._manager.remove(this),this.isRunning=!1,this},b.prototype.setParent=function(a){this._game=a,this._manager=this._game.tweens},b.prototype.delay=function(a){return this._delayTime=a,this},b.prototype.easing=function(a){return this._easingFunction=a,this},b.prototype.interpolation=function(a){return this._interpolationFunction=a,this},b.prototype.chain=function(a){return this._chainedTweens.push(a),this},b.prototype.onStart=function(a,b){return this._onStartCallback=a,this._onStartContext=b,this},b.prototype.onUpdate=function(a,b){return this._onUpdateCallback=a,this._onUpdateContext=b,this},b.prototype.onComplete=function(a,b){return this._onCompleteCallback=a,this._onCompleteContext=b,this},b.prototype.update=function(a){if(a1?1:0>b?0:b;var c=this._easingFunction(b);for(var d in this._valuesStart){var e=this._valuesStart[d],f=this._valuesEnd[d];f instanceof Array?this._object[d]=this._interpolationFunction(f,c):"function"==typeof this._object[d]?this._object[d](e+(f-e)*c):this._object[d]=e+(f-e)*c}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateContext,this._object,c),1===b){this.isRunning=!1,null!==this._onCompleteCallback&&this._onCompleteCalled===!1&&(this._onCompleteCalled=!0,this._onCompleteCallback.call(this._onCompleteContext,this._object));for(var g=0;gg){var i=e*g;f.x=(d-i)/2,d=i}else{var j=d/g;f.y=(e-j)/2,e=j}break;case a.Stage.SCALE_STRETCH:break;case a.Stage.SCALE_NONE:d=this._game.stage.width,e=this._game.stage.height}b.viewport(f.x,f.y,d,e)},c.prototype.initState=function(a){this._textureManager.clearTextures(this._game.stage.gl),this._textureManager.uploadTextureLibrary(this._game.stage.gl,a.textureLibrary)},c.prototype.endState=function(){this._textureManager.clearTextures(this._game.stage.gl),a.Log.log("Ending WebGL on State","#renderer","#webgl")},c.prototype.render=function(b){var c=this._game.stage.gl,d=this._game.stage.normalizedColor;if(c.clearColor(d.r*d.a,d.g*d.a,d.b*d.a,d.a),c.clear(c.COLOR_BUFFER_BIT),0!=this._game.states.current.members.length){this.numDrawCalls=0,this._textureManager.numTextureWrites=0,this._entityCount=0;var e=b.transform.getConcatenatedMatrix(),f=b.transform,g=vec2.create(),h=vec2.create(),i=vec2.create();vec2.set(h,f.scaleX,f.scaleY),vec2.set(g,-f.rotPointX,-f.rotPointY),vec2.set(i,e.tx,e.ty),mat3.identity(this.camMatrix),mat3.translate(this.camMatrix,this.camMatrix,i),mat3.rotate(this.camMatrix,this.camMatrix,f.rotation),mat3.scale(this.camMatrix,this.camMatrix,h),mat3.translate(this.camMatrix,this.camMatrix,g),this._game.deviceTargetOption==a.TARGET_COCOON&&this._switchBlendMode(c,this._currentBlendMode),this.collateRenderSequence(),this.collateBatches(),this.renderBatches(c,b)}},c.prototype.collateRenderSequence=function(){this._sequence=[];var a=this._game.states.current;this.collateChild(a)},c.prototype.collateChild=function(b){if(b.visible)if(b.childType()===a.GROUP)for(var c=0;c=b)return!0;return!1},b.DEFAULT_MAX_TEX_MEM_MB=1024,b}();b.GLTextureManager=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this._created=!1,this._uploaded=!1,this.items=d||a.squareVertices,this.itemSize=c||2,this.numItems=this.items.length/this.itemSize,this.createBuffer(b),e&&this.uploadBuffer(b,this.items)}return Object.defineProperty(a.prototype,"created",{get:function(){return this._created},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"uploaded",{get:function(){return this._uploaded},enumerable:!0,configurable:!0}),a.prototype.clear=function(){this.items=new Array},a.prototype.createBuffer=function(a){return this.buffer=a.createBuffer(),this._created=!0,!0},a.prototype.uploadBuffer=function(a,b){this.items=b,this.numItems=this.items.length/this.itemSize;var c=new Float32Array(this.items);return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,c,a.DYNAMIC_DRAW),this._uploaded=!0,!0},a.prototype.deleteBuffer=function(a){return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.deleteBuffer(this.buffer),this.uploaded=!1,this.created=!1,!0},a.squareVertices=[0,0,100,0,100,100,0,100],a.squareUVs=[0,0,.1,0,.1,.1,0,.1],a.squareCols=[1,1,1,1],a}();a.GLArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){this.gl=a,this.dirty=!0,this._srcRGB=a.SRC_ALPHA,this._dstRGB=a.ONE_MINUS_SRC_ALPHA,this._srcAlpha=a.ONE,this._dstAlpha=a.ONE,this._modeRGB=a.FUNC_ADD,this._modeAlpha=a.FUNC_ADD,"undefined"==typeof b&&(b=null),b&&this.readConfig(b)}return a.prototype.readConfig=function(a){void 0!==a.mode?this.setMode(a.mode):(a.srcRGB=this.makeConstant(a.srcRGB),"undefined"!=typeof a.srcRGB&&(this._srcRGB=a.srcRGB),a.dstRGB=this.makeConstant(a.dstRGB),"undefined"!=typeof a.dstRGB&&(this._dstRGB=a.dstRGB),a.srcAlpha=this.makeConstant(a.srcAlpha),"undefined"!=typeof a.srcAlpha&&(this._srcAlpha=a.srcAlpha),a.dstAlpha=this.makeConstant(a.dstAlpha),"undefined"!=typeof a.dstAlpha&&(this._dstAlpha=a.dstAlpha),a.modeRGB=this.makeConstant(a.modeRGB),"undefined"!=typeof a.modeRGB&&(this._modeRGB=a.modeRGB),a.modeAlpha=this.makeConstant(a.modeAlpha),"undefined"!=typeof a.modeAlpha&&(this._modeAlpha=a.modeAlpha)),this.dirty=!0},a.prototype.makeConstant=function(a){if("number"==typeof a)return a;switch("string"==typeof a&&(a=a.toUpperCase()),a){case"ZERO":a=this.gl.ZERO;break;case"ONE":a=this.gl.ONE;break;case"SRC_COLOR":case"SRC_COLOUR":a=this.gl.SRC_COLOR;break;case"ONE_MINUS_SRC_COLOR":case"ONE_MINUS_SRC_COLOUR":a=this.gl.ONE_MINUS_SRC_COLOR;break;case"DST_COLOR":case"DST_COLOUR":a=this.gl.DST_COLOR;break;case"ONE_MINUS_DST_COLOR":case"ONE_MINUS_DST_COLOUR":a=this.gl.ONE_MINUS_DST_COLOR;break;case"SRC_ALPHA":a=this.gl.SRC_ALPHA;break;case"ONE_MINUS_SRC_ALPHA":a=this.gl.ONE_MINUS_SRC_ALPHA;break;case"DST_ALPHA":a=this.gl.DST_ALPHA;break;case"ONE_MINUS_DST_ALPHA":a=this.gl.ONE_MINUS_DST_ALPHA;break;case"SRC_ALPHA_SATURATE":a=this.gl.SRC_ALPHA_SATURATE;break;case"CONSTANT_COLOR":case"CONSTANT_COLOUR":a=this.gl.CONSTANT_COLOR;break;case"ONE_MINUS_CONSTANT_COLOR":case"ONE_MINUS_CONSTANT_COLOUR":a=this.gl.ONE_MINUS_CONSTANT_COLOR;break;case"CONSTANT_ALPHA":a=this.gl.CONSTANT_ALPHA;break;case"ONE_MINUS_CONSTANT_ALPHA":a=this.gl.ONE_MINUS_CONSTANT_ALPHA;break;case"FUNC_ADD":a=this.gl.FUNC_ADD;break;case"FUNC_SUBTRACT":a=this.gl.FUNC_SUBTRACT;break;case"FUNC_REVERSE_SUBTRACT":a=this.gl.FUNC_REVERSE_SUBTRACT;break;default:a=void 0}return a},a.prototype.setMode=function(a){switch(a=a.toUpperCase()){case"ADDITIVE":case"ADD":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"SUBTRACT":case"SUBTRACTIVE":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_ADD;break;case"ERASE":case"ERASER":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_REVERSE_SUBTRACT;break;case"BLACK":case"BLACKEN":this._srcRGB=this.gl.ZERO,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"NORMAL":default:this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD}this.dirty=!0},a.prototype.isIdentical=function(a){return this==a?!0:this._srcRGB==a._srcRGB&&this._dstRGB==a._dstRGB&&this._srcAlpha==a._srcAlpha&&this._dstAlpha==a._dstAlpha&&this._modeRGB==a._modeRGB&&this._modeAlpha==a._modeAlpha?!0:!1},a.prototype.apply=function(a){a.blendEquationSeparate(this._modeRGB,this._modeAlpha),a.blendFuncSeparate(this._srcRGB,this._dstRGB,this._srcAlpha,this._dstAlpha),this.dirty=!1},a}();a.GLBlendMode=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this.indices=d||a.square,this.itemSize=c||1,this.numItems=this.indices.length/this.itemSize,e&&(this.buffer=this.init(b))}return a.prototype.clear=function(){this.indices=new Array},a.prototype.init=function(a){var b=a.createBuffer();return a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,b),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),b},a.prototype.refresh=function(a){return this.numItems=this.indices.length/this.itemSize,a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),this.buffer},a.square=[0,1,2,0,2,3],a}();a.GLElementArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=!1),this.loaded=!1,this._isBatchRenderer=!1,this.shaderManager=c,this._isBatchRenderer=d,this.loaded=!0,this.blendMode=new a.Renderers.GLBlendMode(b,{mode:"NORMAL"})}return b.prototype.enable=function(a,b){void 0===b&&(b=null)},b.prototype.disable=function(){},b.prototype.clear=function(){},b.prototype.draw=function(){},b.prototype.updateStageResolution=function(){},b.prototype.updateTextureSize=function(){},Object.defineProperty(b.prototype,"isBatchRenderer",{get:function(){return this._isBatchRenderer},enumerable:!0,configurable:!0}),b.RENDERER_ID="Renderer",b}();b.Renderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(c){function d(a,d,e){void 0===e&&(e=null),c.call(this,a,d,!0),this._shaderPairName="TextureAtlasShader",this._maxItems=1e3;var f=5;this._vertexBuffer=new b.GLArrayBuffer(a,f);var g=6;this._indexBuffer=new b.GLElementArrayBuffer(a,1,this._generateIndices(this._maxItems*g)),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName)}return __extends(d,c),d.prototype.enable=function(a,b){void 0===b&&(b=null),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName,!0),a.uniform1i(this.shaderPair.uniforms.uSampler.location,0),a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b.stageResolution),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.disable=function(a){a.disableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.disableVertexAttribArray(this.shaderPair.attributes.aAlpha)},d.prototype.clear=function(a,b){this._vertexBuffer.clear(),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.draw=function(a){this._vertexBuffer.uploadBuffer(a,this._vertexBuffer.items),a.enableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.vertexAttribPointer(this.shaderPair.attributes.aXYUV,4,a.FLOAT,!1,20,0),a.enableVertexAttribArray(this.shaderPair.attributes.aAlpha),a.vertexAttribPointer(this.shaderPair.attributes.aAlpha,1,a.FLOAT,!1,20,16),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indexBuffer.buffer),a.drawElements(a.TRIANGLES,this._vertexBuffer.items.length/20*6,a.UNSIGNED_SHORT,0)},d.prototype._generateIndices=function(a){for(var b=new Array,c=0;a>c;c++)b.push(4*c+0,4*c+1,4*c+2,4*c+0,4*c+2,4*c+3);return b},d.prototype.updateStageResolution=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b)},d.prototype.updateTextureSize=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uTextureSize.location,b)},d.prototype.setShaderPair=function(a){"string"==typeof a&&(this._shaderPairName=a)},d.prototype.addToBatch=function(b,c){if(!(c.alpha<=0)){var d=c.transform,e=d.getConcatenatedMatrix(),f=c.atlas.cells[c.cellIndex],g=new a.Geom.Point(0-d.rotPointX,0-d.rotPointY),h=new a.Geom.Point(f.w-d.rotPointX,0-d.rotPointY),i=new a.Geom.Point(f.w-d.rotPointX,f.h-d.rotPointY),j=new a.Geom.Point(0-d.rotPointX,f.h-d.rotPointY);g=e.transformPoint(g),h=e.transformPoint(h),i=e.transformPoint(i),j=e.transformPoint(j),this._vertexBuffer.items.push(g.x,g.y,f.x,f.y,c.alpha,h.x,h.y,f.x+f.w,f.y,c.alpha,i.x,i.y,f.x+f.w,f.y+f.h,c.alpha,j.x,j.y,f.x,f.y+f.h,c.alpha)}},d.prototype.concatBatch=function(a){this._vertexBuffer.items=this._vertexBuffer.items.concat(a)},d.RENDERER_ID="TextureAtlasRenderer",d}(b.Renderer);b.TextureAtlasRenderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.loaded=!1}return a.prototype.init=function(a){this.vertShader=this.compile(a,this.vertSource.join("\n"),a.VERTEX_SHADER),this.fragShader=this.compile(a,this.fragSource.join("\n"),a.FRAGMENT_SHADER),this.shaderProgram=this.attach(a,this.vertShader,this.fragShader),this.loaded=!0},a.prototype.attach=function(a,b,c){var d=a.createProgram();return a.attachShader(d,c),a.attachShader(d,b),a.linkProgram(d),d},a.prototype.compile=function(a,b,c){var d=a.createShader(c);return a.shaderSource(d,b),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:null},a.prototype.setParam=function(a,b){this.uniforms[a].value=b,this.uniforms[a].dirty=!0},a.prototype.applyUniforms=function(a){for(var b in this.uniforms)this.applyUniform(a,b)},a.prototype.applyUniform=function(a,b){var c=this.uniforms[b];this.uniforms[b].dirty&&(a["uniform"+c.type](c.location,c.value),this.uniforms[b].dirty=!1)},a.prototype.initUniforms=function(a){for(var b in this.uniforms){var c=this.uniforms[b];c.location=a.getUniformLocation(this.shaderProgram,b),c.dirty=!0,c.value=null}},a.RENDERER_ID="ShaderPair",a}();a.ShaderPair=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.attributes={aXYUV:null,aAlpha:null},this.uniforms={uCamMatrix:{type:"mat3"},uResolution:{type:"2fv"},uTextureSize:{type:"2fv"},uSampler:{type:"1i"}},this.fragSource=["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor.a *= vAlpha;","}"],this.vertSource=["attribute vec4 aXYUV;","attribute float aAlpha;","uniform mat3 uCamMatrix;","uniform vec2 uResolution;","uniform vec2 uTextureSize;","varying vec2 vTextureCoord;","varying float vAlpha;","void main(void) {"," vec2 pos = (uCamMatrix * vec3(aXYUV.xy,1)).xy; "," gl_Position = vec4((pos / uResolution * 2.0 - 1.0) * vec2(1, -1), 0, 1);"," vTextureCoord = aXYUV.zw / uTextureSize;"," vAlpha = aAlpha;","}"]}return __extends(b,a),b.prototype.init=function(b){a.prototype.init.call(this,b),this.attributes.aXYUV=b.getAttribLocation(this.shaderProgram,"aXYUV"),this.attributes.aAlpha=b.getAttribLocation(this.shaderProgram,"aAlpha"),this.initUniforms(b)},b}(a.ShaderPair);a.TextureAtlasShader=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d){this._frameIndex=0,this._startTime=null,this._reverse=!1,this._isPlaying=!1,this._onStop=null,this._onPlay=null,this._onUpdate=null,this._onLoop=null,this._onComplete=null,this.name=a,this._sequence=b,this._speed=b.speed,this._loop=b.loop,this._parent=d,this._clock=c,this._lastFrameElapsed=this.clock.elapsed()}return b.prototype.objType=function(){return"Animation"},Object.defineProperty(b.prototype,"loop",{get:function(){return this._loop},set:function(a){this._loop=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameIndex",{get:function(){return this._frameIndex},set:function(a){this._validateFrame(a)&&(this._frameIndex=a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"currentCell",{get:function(){return this._sequence.cells[this.frameIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"speed",{get:function(){return this._speed},set:function(a){this._speed=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clock",{get:function(){return this._clock?this._clock:this._parent.entity.clock},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"reverse",{get:function(){return this._reverse},set:function(a){this._reverse=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isPlaying",{get:function(){return this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onStop",{get:function(){return null==this._onStop&&(this._onStop=new a.Signal),this._onStop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onPlay",{get:function(){return null==this._onPlay&&(this._onPlay=new a.Signal),this._onPlay},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUpdate",{get:function(){return null==this._onUpdate&&(this._onUpdate=new a.Signal),this._onUpdate},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onLoop",{get:function(){return null==this._onLoop&&(this._onLoop=new a.Signal),this._onLoop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onComplete",{get:function(){return null==this._onComplete&&(this._onComplete=new a.Signal),this._onComplete},enumerable:!0,configurable:!0}),b.prototype._start=function(a){void 0===a&&(a=null),null!==a&&(this.frameIndex=a),this._isPlaying=!0,this._startTime=this.clock.elapsed(),this._lastFrameElapsed=this.clock.elapsed(),null!==this._onPlay&&this._onPlay.dispatch()},b.prototype.play=function(){this._frameIndex>=this.length-1&&(this.frameIndex=0),this.playAt(this._frameIndex)},b.prototype.playAt=function(a){this._start(a)},b.prototype.pause=function(){this.stop()},b.prototype.resume=function(){null!==this._startTime&&(this._isPlaying=!0)},b.prototype.stop=function(){this._isPlaying&&(this._isPlaying=!1,null!==this._onStop&&this._onStop.dispatch())},b.prototype.nextFrame=function(){this._frameIndex++,this._frameIndex>=this.length&&(this.frameIndex=0)},b.prototype.prevFrame=function(){this._frameIndex--,this._frameIndex<0&&(this.frameIndex=this.length-1)},b.prototype.update=function(){var a;if(this._isPlaying&&(a=(this.clock.elapsed()-this._lastFrameElapsed)/this._speed%(this.length+1),this._reverse&&(a*=-1),a=a>0?Math.floor(a):Math.ceil(a),0!==a)){if(this._frameIndex+=a,this._lastFrameElapsed=this.clock.elapsed(),this._loop){if(this._frameIndex>=this.length)for(;this._frameIndex>=this.length;)this._frameIndex-=this.length,null!=this._onLoop&&this._onLoop.dispatch();else if(this._frameIndex<0)for(;this._frameIndex<0;)this._frameIndex+=this.length,null!=this._onLoop&&this._onLoop.dispatch()}else if(this._frameIndex<0||this._frameIndex>=this.length)return null!=this._onComplete&&this._onComplete.dispatch(),void this._parent.stop();this._parent.updateCellIndex(),null!==this._onUpdate&&this._onUpdate.dispatch()}},b.prototype._validateFrame=function(a){return a=0},Object.defineProperty(b.prototype,"length",{get:function(){return this._sequence.cells.length},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this._isPlaying=!1,delete this._clock,delete this._sequence,delete this._parent,this._onLoop&&this._onLoop.dispose(),this._onStop&&this._onStop.dispose(),this._onPlay&&this._onPlay.dispose(),this._onUpdate&&this._onUpdate.dispose(),delete this._onLoop,delete this._onStop,delete this._onPlay,delete this._onUpdate,delete this.frameIndex,delete this.loop,delete this._reverse,delete this._tick},b}();b.Animation=c}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===c&&(c=.1),void 0===d&&(d=!0),this.name=a,this.cells=b,this.speed=c,this.loop=d}return a}();a.Sequence=b}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this.preventDefault=!1,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.timeUp=0,this.repeats=0,this._manager=a,this.game=this._manager.game,this.keyCode=b,c&&this.update(c)}return a.prototype.objType=function(){return"Key"},Object.defineProperty(a.prototype,"duration",{get:function(){return this.isDown&&(this.timeDown=this.game.time.now()),this.timeDownthis.game.time.now()?!0:!1},a.prototype.justReleased=function(a){return void 0===a&&(a=this._manager.justReleasedRate),this.isUp===!0&&this.timeUp+a>this.game.time.now()?!0:!1},a.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeUp=0,this.timeDown=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},a}();a.Key=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._keys=[],this.justPressedRate=200,this.justReleasedRate=200,this.game=a}return b.prototype.objType=function(){return"Keyboard"},Object.defineProperty(b.prototype,"keys",{get:function(){return this._keys},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this.onKeyUp=new a.Signal,this.onKeyDown=new a.Signal,this.onKeyDownOnce=new a.Signal,this.start()},b.prototype.update=function(){},b.prototype.start=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.addEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.addEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype.stop=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.removeEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.removeEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype._keyPressed=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),0==this._keys[b.keyCode].repeats&&this.onKeyDownOnce.dispatch(b.keyCode,this._keys[b.keyCode]),this.onKeyDown.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype._keyReleased=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),this.onKeyUp.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype.addKey=function(b,c){void 0===c&&(c=!1);var d=new a.Input.Key(this,b);return d.preventDefault=c,this._keys[b]=d},b.prototype.justPressed=function(a,b){return void 0===b&&(b=this.justPressedRate),this._keys[a]?this._keys[a].justPressed(b):!1},b.prototype.justReleased=function(a,b){return void 0===b&&(b=this.justReleasedRate),this._keys[a]?this._keys[a].justReleased(b):!1},b.prototype.isDown=function(a){return this._keys[a]?this._keys[a].isDown:!1},b.prototype.isUp=function(a){return this._keys[a]?this._keys[a].isUp:!1},b.prototype.reset=function(){for(var a in this._keys)this._keys[a].reset()},b}();b.Keyboard=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Keycodes"},a.A="A".charCodeAt(0),a.B="B".charCodeAt(0),a.C="C".charCodeAt(0),a.D="D".charCodeAt(0),a.E="E".charCodeAt(0),a.F="F".charCodeAt(0),a.G="G".charCodeAt(0),a.H="H".charCodeAt(0),a.I="I".charCodeAt(0),a.J="J".charCodeAt(0),a.K="K".charCodeAt(0),a.L="L".charCodeAt(0),a.M="M".charCodeAt(0),a.N="N".charCodeAt(0),a.O="O".charCodeAt(0),a.P="P".charCodeAt(0),a.Q="Q".charCodeAt(0),a.R="R".charCodeAt(0),a.S="S".charCodeAt(0),a.T="T".charCodeAt(0),a.U="U".charCodeAt(0),a.V="V".charCodeAt(0),a.W="W".charCodeAt(0),a.X="X".charCodeAt(0),a.Y="Y".charCodeAt(0),a.Z="Z".charCodeAt(0),a.ZERO="0".charCodeAt(0),a.ONE="1".charCodeAt(0),a.TWO="2".charCodeAt(0),a.THREE="3".charCodeAt(0),a.FOUR="4".charCodeAt(0),a.FIVE="5".charCodeAt(0),a.SIX="6".charCodeAt(0),a.SEVEN="7".charCodeAt(0),a.EIGHT="8".charCodeAt(0),a.NINE="9".charCodeAt(0),a.NUMPAD_0=96,a.NUMPAD_1=97,a.NUMPAD_2=98,a.NUMPAD_3=99,a.NUMPAD_4=100,a.NUMPAD_5=101,a.NUMPAD_6=102,a.NUMPAD_7=103,a.NUMPAD_8=104,a.NUMPAD_9=105,a.NUMPAD_MULTIPLY=106,a.NUMPAD_ADD=107,a.NUMPAD_ENTER=108,a.NUMPAD_SUBTRACT=109,a.NUMPAD_DECIMAL=110,a.NUMPAD_DIVIDE=111,a.F1=112,a.F2=113,a.F3=114,a.F4=115,a.F5=116,a.F6=117,a.F7=118,a.F8=119,a.F9=120,a.F10=121,a.F11=122,a.F12=123,a.F13=124,a.F14=125,a.F15=126,a.COLON=186,a.EQUALS=187,a.UNDERSCORE=189,a.QUESTION_MARK=191,a.TILDE=192,a.OPEN_BRACKET=219,a.BACKWARD_SLASH=220,a.CLOSED_BRACKET=221,a.QUOTES=222,a.BACKSPACE=8,a.TAB=9,a.CLEAR=12,a.ENTER=13,a.SHIFT=16,a.CONTROL=17,a.ALT=18,a.CAPS_LOCK=20,a.ESC=27,a.SPACEBAR=32,a.PAGE_UP=33,a.PAGE_DOWN=34,a.END=35,a.HOME=36,a.LEFT=37,a.UP=38,a.RIGHT=39,a.DOWN=40,a.INSERT=45,a.DELETE=46,a.HELP=47,a.NUM_LOCK=144,a}();a.Keycodes=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.game=a}return b.prototype.objType=function(){return"InputManager"},Object.defineProperty(b.prototype,"pointers",{get:function(){return this._pointers},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._pointers=[],this.mouse=new a.Input.Mouse(this.game),this.mouse.boot(),this.keyboard=new a.Input.Keyboard(this.game),this.keyboard.boot(),this.touch=new a.Input.Touch(this.game),this.touch.boot(),this.mouse.onDown.add(this._onDownEvent,this),this.mouse.onUp.add(this._onUpEvent,this),this.touch.touchDown.add(this._onDownEvent,this),this.touch.touchUp.add(this._onUpEvent,this),this._pointers=this.touch.fingers.slice(),this._pointers.push(this.mouse.cursor),this.isDown=!1,this.position=new a.Geom.Point,this.onDown=new a.Signal,this.onUp=new a.Signal},b.prototype._onDownEvent=function(a,b,c,d,e,f){this.onDown.dispatch(a,b,c,d,e,f)},b.prototype._onUpEvent=function(a,b,c,d,e,f){this.onUp.dispatch(a,b,c,d,e,f)},Object.defineProperty(b.prototype,"onPressed",{get:function(){return this.onDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onReleased",{get:function(){return this.onUp},enumerable:!0,configurable:!0}),b.prototype.update=function(){this.mouse.update(),this.keyboard.update(),this.touch.update(),this.touch.touchEnabled?this.position.setTo(this.touch.x,this.touch.y):this.position.setTo(this.mouse.x,this.mouse.y),this.isDown=this.mouse.isDown||this.touch.isDown},b.prototype.reset=function(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()},Object.defineProperty(b.prototype,"x",{get:function(){return this.position.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.position.y},enumerable:!0,configurable:!0}),b}();b.InputManager=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this._game=a}return b.prototype.objType=function(){return"Mouse"},Object.defineProperty(b.prototype,"cursor",{get:function(){return this._cursor},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this._cursor=new a.Input.MouseCursor(this._game),this._cursor.active=!0,this._cursor.id=1,this.onDown=new a.Signal,this.onUp=new a.Signal,this.onWheel=new a.Signal,this.start()},Object.defineProperty(b.prototype,"isDown",{get:function(){return this._cursor.isDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isUp",{get:function(){return this._cursor.isUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"duration",{get:function(){return this._cursor.duration},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._cursor.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._cursor.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaX",{get:function(){return this._cursor.wheelDeltaX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaY",{get:function(){return this._cursor.wheelDeltaY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"ctrlKey",{get:function(){return this._cursor.ctrlKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"shiftKey",{get:function(){return this._cursor.shiftKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"altKey",{get:function(){return this._cursor.altKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"button",{get:function(){return this._cursor.button},enumerable:!0,configurable:!0}),b.prototype.update=function(){this._cursor.update()},b.prototype.start=function(){var b=this;this._game.deviceTargetOption===a.TARGET_BROWSER?a.DEVICE.ie&&a.DEVICE.ieVersion<9?(this._domElement.attachEvent("onmousedown",function(a){return b.onMouseDown(a)}),this._domElement.attachEvent("onmousemove",function(a){return b.onMouseMove(a)}),this._domElement.attachEvent("onmouseup",function(a){return b.onMouseUp(a)}),this._domElement.attachEvent("onmousewheel",function(a){return b.onMouseWheel(a)})):(this._domElement.addEventListener("mousedown",function(a){return b.onMouseDown(a)},!0),this._domElement.addEventListener("mousemove",function(a){return b.onMouseMove(a)},!0),this._domElement.addEventListener("mouseup",function(a){return b.onMouseUp(a)},!0),this._domElement.addEventListener("mousewheel",function(a){return b.onMouseWheel(a)},!0),this._domElement.addEventListener("DOMMouseScroll",function(a){return b.onMouseWheel(a)},!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("mousedown",function(a){return b.onMouseDown(a)},!0),this._game.stage.canvas.addEventListener("mousemove",function(a){return b.onMouseMove(a)},!0),this._game.stage.canvas.addEventListener("mouseup",function(a){return b.onMouseUp(a)},!0),this._game.stage.canvas.addEventListener("mousewheel",function(a){return b.onMouseWheel(a)},!0),this._game.stage.canvas.addEventListener("DOMMouseScroll",function(a){return b.onMouseWheel(a)},!0))},b.prototype.stop=function(){var b=this;this._game.deviceTargetOption===a.TARGET_BROWSER&&(this._domElement.removeEventListener("mousedown",function(a){return b.onMouseDown(a)},!1),this._domElement.removeEventListener("mousedown",this.onMouseDown,!1),this._domElement.removeEventListener("mousemove",this.onMouseMove,!1),this._domElement.removeEventListener("mouseup",this.onMouseUp,!1),this._domElement.removeEventListener("mousewheel",this.onMouseWheel,!1),this._domElement.removeEventListener("DOMMouseScroll",this.onMouseWheel,!1))},b.prototype.onMouseDown=function(a){this._cursor.start(a),this.onDown.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseMove=function(a){a.preventDefault(),this._cursor.move(a)},b.prototype.onMouseUp=function(a){this._cursor.stop(a),this.onUp.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor) -},b.prototype.onMouseWheel=function(a){this._cursor.wheel(a),this.onWheel.dispatch(this._cursor.wheelDeltaX,this._cursor.wheelDeltaY,this._cursor)},b.prototype.justPressed=function(a){return void 0===a&&(a=this._cursor.justPressedRate),this._cursor.justPressed(a)},b.prototype.justReleased=function(a){return void 0===a&&(a=this._cursor.justReleasedRate),this._cursor.justReleased(a)},b.prototype.reset=function(){this._cursor.reset()},b.LEFT_BUTTON=0,b.MIDDLE_BUTTON=1,b.RIGHT_BUTTON=2,b}();b.Mouse=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.isDown=!1,this.isUp=!0,this._maxPointers=10,this._game=a}return b.prototype.objType=function(){return"TouchManager"},Object.defineProperty(b.prototype,"fingers",{get:function(){return this._fingers},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onDown",{get:function(){return this.touchDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUp",{get:function(){return this.touchUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onCancel",{get:function(){return this.touchCancel},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this.finger1=new a.Input.Finger(this._game),this.finger2=new a.Input.Finger(this._game),this.finger3=new a.Input.Finger(this._game),this.finger4=new a.Input.Finger(this._game),this.finger5=new a.Input.Finger(this._game),this.finger6=new a.Input.Finger(this._game),this.finger7=new a.Input.Finger(this._game),this.finger8=new a.Input.Finger(this._game),this.finger9=new a.Input.Finger(this._game),this.finger10=new a.Input.Finger(this._game),this._fingers=[this.finger1,this.finger2,this.finger3,this.finger4,this.finger5,this.finger6,this.finger7,this.finger8,this.finger9,this.finger10],this.latestFinger=this.finger1,this.touchDown=new a.Signal,this.touchUp=new a.Signal,this.touchCancel=new a.Signal,this.start()},b.prototype.start=function(){var b=this;if(a.DEVICE.touch)if(this.touchEnabled=!0,this._game.deviceTargetOption===a.TARGET_BROWSER)if(a.DEVICE.pointerEnabled){var c="pointerup",d="pointerdown",e="pointerenter",f="pointerleave",g="pointercancel",h="pointermove";if(window.navigator.msPointerEnabled)var c="MSPointerUp",d="MSPointerDown",e="MSPointerEnter",f="MSPointerLeave",g="MSPointerCancel",h="MSPointerMove";this._domElement.addEventListener(c,function(a){return b.onPointerStart(a)},!1),this._domElement.addEventListener(d,function(a){return b.onPointerEnd(a)},!1),this._domElement.addEventListener(e,function(a){return b.onPointerEnter(a)},!1),this._domElement.addEventListener(f,function(a){return b.onPointerLeave(a)},!1),this._domElement.addEventListener(g,function(a){return b.onPointerCancel(a)},!1),this._domElement.addEventListener(h,function(a){return b.onPointerMove(a)},!1)}else this._domElement.addEventListener("touchstart",function(a){return b.onTouchStart(a)},!1),this._domElement.addEventListener("touchmove",function(a){return b.onTouchMove(a)},!1),this._domElement.addEventListener("touchend",function(a){return b.onTouchEnd(a)},!1),this._domElement.addEventListener("touchenter",function(a){return b.onTouchEnter(a)},!1),this._domElement.addEventListener("touchleave",function(a){return b.onTouchLeave(a)},!1),this._domElement.addEventListener("touchcancel",function(a){return b.onTouchCancel(a)},!1),document.addEventListener("touchmove",function(a){return b.consumeTouchMove(a)},!1);else this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("touchstart",function(a){return b.onTouchStart(a)},!1),this._game.stage.canvas.addEventListener("touchmove",function(a){return b.onTouchMove(a)},!1),this._game.stage.canvas.addEventListener("touchend",function(a){return b.onTouchEnd(a)},!1),this._game.stage.canvas.addEventListener("touchenter",function(a){return b.onTouchEnter(a)},!1),this._game.stage.canvas.addEventListener("touchleave",function(a){return b.onTouchLeave(a)},!1),this._game.stage.canvas.addEventListener("touchcancel",function(a){return b.onTouchCancel(a)},!1));else this.touchEnabled=!1},b.prototype.consumeTouchMove=function(a){a.preventDefault()},Object.defineProperty(b.prototype,"x",{get:function(){return this.latestFinger.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.latestFinger.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"maximumPointers",{get:function(){return this._maxPointers},set:function(a){0>a&&(a=1),a>this._fingers.length&&(a=this._fingers.length),this._maxPointers=a},enumerable:!0,configurable:!0}),b.prototype._registerFinger=function(a,b){for(var c=0;cthis._game.time.now()?!0:!1},b.prototype.justReleased=function(a){return void 0===a&&(a=this.justReleasedRate),this.isUp===!0&&this.timeUp+a>this._game.time.now()?!0:!1},Object.defineProperty(b.prototype,"pressed",{get:function(){return this.timeDown>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"released",{get:function(){return this.timeUp>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),b.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.duration=0,this.frameDuration=0},b.prototype.update=function(){this.isDown===!0&&(this.frameDuration++,this.duration=this._game.time.now()-this.timeDown)},b}();b.Pointer=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments),this.wheelDeltaX=0,this.wheelDeltaY=0,this.preventDown=!0,this.preventUp=!0,this.preventWheel=!0}return __extends(b,a),b.prototype.objType=function(){return"MouseCursor"},b.prototype.start=function(b){this.preventDown&&b.preventDefault(),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.button=b.button,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.preventUp&&b.preventDefault(),this.move(b),a.prototype.stop.call(this,b)},b.prototype.wheel=function(a){this.preventWheel&&a.preventDefault(),this.wheelDeltaX=a.wheelDeltaX?a.wheelDeltaX:a.deltaX,this.wheelDeltaY=a.wheelDeltaY?a.wheelDeltaY:a.deltaY},b}(a.Pointer);a.MouseCursor=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b){a.call(this,b),this.circle.diameter=44}return __extends(b,a),b.prototype.objType=function(){return"Finger"},b.prototype.start=function(b){this.active=!0,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.active=!1,a.prototype.stop.call(this,b)},b.prototype.leave=function(a){this.withinGame=!1,this.move(a)},b.prototype.reset=function(){this.active=!1,a.prototype.reset.call(this)},b}(a.Pointer);a.Finger=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c,d){this.cx=0,this.cy=0,this.halfWidth=0,this.halfHeight=0,this.cx=a||0,this.cy=b||0,this.halfWidth=c/2||0,this.halfHeight=d/2||0}return b.prototype.objType=function(){return"AABB"},Object.defineProperty(b.prototype,"height",{get:function(){return 2*this.halfHeight},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return 2*this.halfWidth},enumerable:!0,configurable:!0}),b.prototype.draw=function(a){return a.beginPath(),a.moveTo(this.cx-this.halfWidth,this.cy),a.lineTo(this.cx+this.halfWidth,this.cy),a.moveTo(this.cx,this.cy-this.halfHeight),a.lineTo(this.cx,this.cy+this.halfHeight),a.stroke(),this},b.prototype.setPosition=function(a,b){return this.cx=a,this.cy=b,this},b.prototype.setPositionPoint=function(a){return this.cx=a.x,this.cy=a.y,this},b.prototype.toRect=function(){return new a.Rectangle(this.cx-this.halfWidth,this.cy-this.halfHeight,2*this.halfWidth,2*this.halfHeight)},b.prototype.fromRect=function(a){return this.halfWidth=a.width/2,this.halfHeight=a.height/2,this.cx=a.x+this.halfWidth,this.cy=a.y+this.halfHeight,this},b}();a.AABB=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this._diameter=0,this._radius=0,this.x=0,this.y=0,this.setTo(a,b,c)}return b.prototype.objType=function(){return"Circle"},Object.defineProperty(b.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"circumference",{get:function(){return 2*Math.PI*this._radius},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){isNaN(a)||(athis.x?this.radius=a-this.x:(this._radius=0,this._diameter=0))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a&&!isNaN(a)&&(a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isEmpty",{get:function(){return this._diameter<=0?!0:!1},enumerable:!0,configurable:!0}),b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x,this.y,this._diameter)},b.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.diameter)},b.prototype.copyTo=function(a){return a.copyFrom(this)},b.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},b.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.diameter===a.diameter?!0:!1},b.prototype.intersects=function(a){return this.distanceTo(a,!1)=g)==!0||(d.y<=h&&d.y>=i)==!0)&&(d.result=!0)}return d},b.lineToRawSegment=function(b,c,d,e,f,g){void 0===g&&(g=new a.IntersectResult),g.result=!1;var h=(b.x1-b.x2)*(d-f)-(b.y1-b.y2)*(c-e);if(0!==h){g.x=((b.x1*b.y2-b.y1*b.x2)*(c-e)-(b.x1-b.x2)*(c*f-d*e))/h,g.y=((b.x1*b.y2-b.y1*b.x2)*(d-f)-(b.y1-b.y2)*(c*f-d*e))/h;var i=Math.max(c,e),j=Math.min(c,e),k=Math.max(d,f),l=Math.min(d,f);g.x<=i&&g.x>=j&&g.y<=k&&g.y>=l&&(g.result=!0)}return g},b.lineSegmentToRawSegment=function(c,d,e,f,g,h){void 0===h&&(h=new a.IntersectResult),h=b.lineToRawSegment(c,d,e,f,g,h);var i=Math.max(c.x1,c.x2),j=Math.min(c.x1,c.x2),k=Math.max(c.y1,c.y2),l=Math.min(c.y1,c.y2);return h.x<=i&&h.x>=j&&h.y<=k&&h.y>=l?h:(h.result=!1,h)},b.lineToRay=function(b,c,d){void 0===d&&(d=new a.IntersectResult),d.result=!1;var e=(b.x1-b.x2)*(c.y1-c.y2)-(b.y1-b.y2)*(c.x1-c.x2);return 0!==e&&(d.x=((b.x1*b.y2-b.y1*b.x2)*(c.x1-c.x2)-(b.x1-b.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((b.x1*b.y2-b.y1*b.x2)*(c.y1-c.y2)-(b.y1-b.y2)*(c.x1*c.y2-c.y1*c.x2))/e,d.result=!0,!(c.x1>=c.x2)&&d.x=c.y2)&&d.y=Math.min(c.x1,c.x2)&&e.x<=Math.max(c.x1,c.x2)&&e.y>=Math.min(c.y1,c.y2)&&e.y<=Math.max(c.y1,c.y2)||(e.result=!1)),e},b.lineSegmentToRay=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,b.lineToRay(c,d,e),e.result===!0&&(e.x>=Math.min(c.x1,c.x2)&&e.x<=Math.max(c.x1,c.x2)&&e.y>=Math.min(c.y1,c.y2)&&e.y<=Math.max(c.y1,c.y2)||(e.result=!1)),e},b.lineSegmentToCircle=function(c,d,e){void 0===e&&(e=new a.IntersectResult),e.result=!1;var f=c.perp(d.x,d.y);if(f.length<=d.radius){var g=Math.max(c.x1,c.x2),h=Math.min(c.x1,c.x2),i=Math.max(c.y1,c.y2),j=Math.min(c.y1,c.y2);f.x2<=g&&f.x2>=h&&f.y2<=i&&f.y2>=j?e.result=!0:(b.circleContainsPoint(d,{x:c.x1,y:c.y1}).result||b.circleContainsPoint(d,{x:c.x2,y:c.y2}).result)&&(e.result=!0)}return e},b.lineSegmentToRectangle=function(c,d,e){if(void 0===e&&(e=new a.IntersectResult),e.result=!1,d.contains(c.x1,c.y1)&&d.contains(c.x2,c.y2))e.x=(c.x1+c.x2)/2,e.y=(c.y1+c.y2)/2,e.result=!0;else{if(b.lineSegmentToRawSegment(c,d.x,d.y,d.right,d.y,e),e.result===!0)return e;if(b.lineSegmentToRawSegment(c,d.x,d.y,d.x,d.bottom,e),e.result===!0)return e;if(b.lineSegmentToRawSegment(c,d.x,d.bottom,d.right,d.bottom,e),e.result===!0)return e;b.lineSegmentToRawSegment(c,d.right,d.y,d.right,d.bottom,e)}return e},b.rayToRectangle=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,b.lineToRectangle(c,d,e),e},b.rayToLineSegment=function(b,c,d,e,f,g,h,i,j){void 0===j&&(j=new a.IntersectResult),j.result=!1;var k,l,m;return(e-c)/(d-b)!=(i-g)/(h-f)&&(m=(d-b)*(i-g)-(e-c)*(h-f),0!=m&&(k=((c-g)*(h-f)-(b-f)*(i-g))/m,l=((c-g)*(d-b)-(b-f)*(e-c))/m,k>=0&&l>=0&&1>=l&&(j.result=!0,j.x=b+k*(d-b),c+k*(e-c)))),j},b.circleToCircle=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,e.result=(c.radius+d.radius)*(c.radius+d.radius)>=b.distanceSquared(c.x,c.y,d.x,d.y),e},b.circleToRectangle=function(b,c,d){void 0===d&&(d=new a.IntersectResult),d.result=!1;var e,f,g,h,i,j,k,l;return i=c.width/2,g=Math.abs(b.x-c.x-i),k=b.radius+i,g>k?(d.result=!1,d):(j=c.height/2,h=Math.abs(b.y-c.y-j),l=b.radius+j,h>l?(d.result=!1,d):i>=g||h<=c.height/2?(d.result=!0,d):(e=g-i,f=h-j,d.result=e*e+f*f<=b.radius*b.radius,d))},b.circleContainsPoint=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,e.result=c.radius*c.radius>=b.distanceSquared(c.x,c.y,d.x,d.y),e},b.pointToRectangle=function(b,c,d){return void 0===d&&(d=new a.IntersectResult),d.result=!1,d.setTo(b.x,b.y),d.result=c.containsPoint(b),d},b.rectangleToRectangle=function(b,c,d){void 0===d&&(d=new a.IntersectResult),d.result=!1;var e=Math.max(b.x,c.x),f=Math.min(b.right,c.right),g=Math.max(b.y,c.y),h=Math.min(b.bottom,c.bottom);d.setTo(e,g,f-e,h-g,f-e,h-g);var i=d.x+.5*d.width,j=d.y+.5*d.height;return i>b.x&&ib.y&&j=c&&d>=a&&b>=e&&f>=b?!0:!1},b.prototype.intersectLineLine=function(b){return a.Geom.Intersect.lineToLine(this,b)},b.prototype.perp=function(a,c,d){void 0===d&&(d=new b);var e;if(this.y1===this.y2)return d.setTo(a,c,a,this.y1),d;if(this.x1===this.x2)return d.setTo(a,c,this.x1,c),d;var f=c-this.perpSlope*a;return e=this.intersectLineLine(0!==a?{x1:a,y1:c,x2:0,y2:f}:{x1:a,y1:c,x2:1,y2:f+this.perpSlope}),d.setTo(a,c,e.x,e.y),d},b.prototype.toString=function(){return"[{Line (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}();b.Line=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this.setTo(a,b,c,d,e,f)}return b.prototype.objType=function(){return"Matrix"},b.prototype.setTo=function(a,b,c,d,e,f){return void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),this.a=a,this.b=b,this.c=c,this.d=d,this.tx=e,this.ty=f,this},b.prototype.setFromTransform=function(a,b,c,d,e){this.identity();var f=Math.cos(e),g=Math.sin(e);return this.append(f*c,g*c,-g*d,f*d,a,b),this},b.prototype.setFromOffsetTransform=function(a,b,c,d,e,f,g){this.identity();var h=Math.cos(e),i=Math.sin(e);return this.append(h*c,i*c,-i*d,h*d,a+f,b+g),this},b.prototype.prepend=function(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0);var g=this.tx,h=this.a,i=this.c;return this.a=h*a+this.b*c,this.b=h*b+this.b*d,this.c=i*a+this.d*c,this.d=i*b+this.d*d,this.tx=g*a+this.ty*c+e,this.ty=g*b+this.ty*d+f,this},b.prototype.prependMatrix=function(a){var b=this.tx,c=this.a,d=this.c;return this.a=c*a.a+this.b*a.c,this.b=c*a.b+this.b*a.d,this.c=d*a.a+this.d*a.c,this.d=d*a.b+this.d*a.d,this.tx=b*a.a+this.ty*a.c+a.tx,this.ty=b*a.b+this.ty*a.d+a.ty,this},b.prototype.append=function(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0);var g=this.a,h=this.b,i=this.c,j=this.d;return this.a=a*g+b*i,this.b=a*h+b*j,this.c=c*g+d*i,this.d=c*h+d*j,this.tx=e*g+f*i+this.tx,this.ty=e*h+f*j+this.ty,this},b.prototype.appendMatrix=function(a){var b=this.a,c=this.b,d=this.c,e=this.d;return this.a=a.a*b+a.b*d,this.b=a.a*c+a.b*e,this.c=a.c*b+a.d*d,this.d=a.c*c+a.d*e,this.tx=a.tx*b+a.ty*d+this.tx,this.ty=a.tx*c+a.ty*e+this.ty,this},b.prototype.setPosition=function(a,b){return this.tx=a,this.ty=b,this},b.prototype.setPositionPoint=function(a){return this.tx=a.x,this.ty=a.y,this},b.prototype.getPosition=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this.tx,this.ty)},b.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},b.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a,e=this.c,f=this.tx;return this.a=d*b-this.b*c,this.b=d*c+this.b*b,this.c=e*b-this.d*c,this.d=e*c+this.d*b,this.tx=f*b-this.ty*c,this.ty=f*c+this.ty*b,this},b.prototype.translate=function(a,b){return this.tx+=a,this.ty+=b,this},b.prototype.scale=function(a,b){return this.a*=a,this.d*=b,this},b.prototype.transformPoint=function(a){var b=a.x,c=a.y;return a.x=this.a*b+this.c*c+this.tx,a.y=this.b*b+this.d*c+this.ty,a},b.prototype.invert=function(){var a=this.a,b=this.b,c=this.c,d=this.d,e=this.tx,f=a*d-b*c;return this.a=d/f,this.b=-b/f,this.c=-c/f,this.d=a/f,this.tx=(c*this.ty-d*e)/f,this.ty=-(a*this.ty-b*e)/f,this},b.prototype.copyFrom=function(a){return this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.tx=a.tx,this.ty=a.ty,this},b.prototype.copyTo=function(a){return a.a=this.a,a.b=this.b,a.c=this.c,a.d=this.d,a.tx=this.tx,a.ty=this.ty,this},b.prototype.clone=function(){return new a.Geom.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty)},Object.defineProperty(b.prototype,"toString",{get:function(){return"[{Matrix (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")}]"},enumerable:!0,configurable:!0}),b}();b.Matrix=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return a.prototype.objType=function(){return"Point"},a.prototype.polar=function(a,b){return this.x=a*Math.cos(b),this.y=a*Math.sin(b),this},a.prototype.add=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x+b.x,this.y+b.y)},a.prototype.addTo=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(this.x+a,this.y+b)},a.prototype.subtractFrom=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(this.x-a,this.y-b)},a.prototype.invert=function(){return this.setTo(this.y,this.x)},a.prototype.clamp=function(a,b){return this.clampX(a,b),this.clampY(a,b),this},a.prototype.clampX=function(a,b){return this.x=Math.max(Math.min(this.x,b),a),this},a.prototype.clampY=function(a,b){return this.x=Math.max(Math.min(this.x,b),a),this.y=Math.max(Math.min(this.y,b),a),this},a.prototype.clone=function(b){return void 0===b&&(b=new a),b.setTo(this.x,this.y) -},a.prototype.copyFrom=function(a){return this.setTo(a.x,a.y)},a.prototype.copyTo=function(a){return a.setTo(this.x,this.y)},a.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)},a.prototype.angleToXY=function(a,b){return Math.atan2(b-this.y,a-this.x)},a.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},a.prototype.distanceToXY=function(a,b,c){void 0===c&&(c=!1);var d=this.x-a,e=this.y-b;return c===!0?Math.round(Math.sqrt(d*d+e*e)):Math.sqrt(d*d+e*e)},a.distanceBetween=function(a,b,c){void 0===c&&(c=!1);var d=a.x-b.x,e=a.y-b.y;return c===!0?Math.round(Math.sqrt(d*d+e*e)):Math.sqrt(d*d+e*e)},a.polar=function(b,c){return new a(b*Math.cos(c),b*Math.sin(c))},a.prototype.distanceCompare=function(a,b){return this.distanceTo(a)>=b?!0:!1},a.prototype.equals=function(a){return this.x===a.x&&this.y===a.y?!0:!1},a.interpolate=function(b,c,d){var e=c.x-b.x,f=c.y-b.y;return new a(c.x-e*d,c.y-f*d)},a.prototype.offset=function(a,b){return this.x+=a,this.y+=b,this},a.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},a.prototype.subtract=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x-b.x,this.y-b.y)},a.prototype.getCSS=function(){return this.x+"px "+this.y+"px"},a.prototype.toString=function(){return"[{Point (x="+this.x+" y="+this.y+")}]"},a}();a.Point=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x=0,this.y=0,this.width=0,this.height=0,this.setTo(a,b,c,d)}return c.prototype.objType=function(){return"Rectangle"},Object.defineProperty(c.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a&&(this.height=a=this.x&&a<=this.right&&b>=this.y&&b<=this.bottom?!0:!1},c.prototype.containsPoint=function(a){return this.contains(a.x,a.y)},c.prototype.containsRect=function(a){return a.volume>this.volume?!1:a.x>=this.x&&a.y>=this.y&&a.right<=this.right&&a.bottom<=this.bottom?!0:!1},c.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.width,a.height)},c.prototype.copyTo=function(a){return void 0===a&&(a=new c),a.copyFrom(this)},c.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.width===a.width&&this.height===a.height?!0:!1},c.prototype.inflate=function(a,b){return isNaN(a)||isNaN(b)||(this.x-=a,this.width+=2*a,this.y-=b,this.height+=2*b),this},c.prototype.inflatePoint=function(a){return this.inflate(a.x,a.y)},c.prototype.intersection=function(a,b){return void 0===b&&(b=new c),this.intersects(a)===!0&&(b.x=Math.max(a.x,this.x),b.y=Math.max(a.y,this.y),b.width=Math.min(a.right,this.right)-b.x,b.height=Math.min(a.bottom,this.bottom)-b.y),b},c.prototype.intersects=function(a){return a.x>this.right-1?!1:a.right-1this.bottom-1?!1:!0},c.prototype.overlap=function(a){var b={top:!1,bottom:!1,left:!1,right:!1,contains:!1,contained:!1},c=this.intersection(a);return c.isEmpty?b:(this.containsRect(a)&&(b.contains=!0),a.containsRect(this)&&(b.contained=!0),this.topa.bottom&&(b.bottom=!0),this.lefta.right&&(b.right=!0),b)},c.prototype.isEmpty=function(){return this.width<1||this.height<1?!0:!1},c.prototype.offset=function(a,b){return isNaN(a)||isNaN(b)||(this.x+=a,this.y+=b),this},c.prototype.offsetPoint=function(a){return this.offset(a.x,a.y)},c.prototype.setEmpty=function(){return this.setTo(0,0,0,0)},c.prototype.setTo=function(a,b,c,d){return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)||(this.x=a,this.y=b,c>=0&&(this.width=c),d>=0&&(this.height=d)),this},c.prototype.union=function(a,b){return void 0===b&&(b=new c),b.setTo(Math.min(a.x,this.x),Math.min(a.y,this.y),Math.max(a.right,this.right),Math.max(a.bottom,this.bottom))},c.prototype.scale=function(b,c,d){var e=new a.Geom.Transform;e.scaleX=b,e.scaleY=c,e.x=d.x,e.y=d.y;var f=this.topLeft;return e.transformPoint(f),this.topLeft=f,this.width*=b,this.height*=c,this},c.prototype.toString=function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" isEmpty="+this.isEmpty()+")}]"},c}();b.Rectangle=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,c,d,e,f,g,h){void 0===a&&(a=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),this._x=0,this._y=0,this._scaleX=1,this._scaleY=1,this._rotation=0,this._rotPointX=0,this._rotPointY=0,this._parent=null,this._locked=!1,this._ignoreParent=!1,this.setTransform(a,c,d,e,f,g,h),this._matrix=new b.Matrix,this._matrix.setFromOffsetTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,this._rotPointX,this._rotPointY),this._cachedConcatenatedMatrix=this.getConcatenatedMatrix(),this._concatMatrix=new b.Matrix}return c.prototype.objType=function(){return"Transform"},Object.defineProperty(c.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleX",{get:function(){return this._scaleX},set:function(a){this._scaleX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleY",{get:function(){return this._scaleY},set:function(a){this._scaleY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotation",{get:function(){return this._rotation},set:function(a){this._rotation=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointX",{get:function(){return this._rotPointX},set:function(a){this._rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointX",{get:function(){return this.rotPointX},set:function(a){this.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"matrix",{get:function(){return this._matrix},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldX",{get:function(){return this.getConcatenatedMatrix().tx-this._rotPointX},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldY",{get:function(){return this.getConcatenatedMatrix().ty-this._rotPointY},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return this._parent},set:function(a){this.checkAncestor(a)||(this._parent=a)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"locked",{get:function(){return this._locked},set:function(a){this._locked=a,this._locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreParent",{get:function(){return this._ignoreParent},set:function(a){this._ignoreParent=a},enumerable:!0,configurable:!0}),c.prototype.setPosition=function(a,b){return this._x=a,this._y=b,this},c.prototype.setPositionFromPoint=function(a){return this._x=a.x,this._y=a.y,this},c.prototype.translatePositionFromPoint=function(a){return this._x+=a.x,this._y+=a.y,this},c.prototype.getPositionPoint=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this._x,this._y)},Object.defineProperty(c.prototype,"scale",{set:function(a){this._scaleX=a,this._scaleY=a},enumerable:!0,configurable:!0}),c.prototype.setTransform=function(a,b,c,d,e,f,g){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=1),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),this._x=a,this._y=b,this._scaleX=c,this._scaleY=d,this._rotation=e,this._rotPointX=f,this._rotPointY=g,this},c.prototype.getParentMatrix=function(){return this._parent?this._parent.getConcatenatedMatrix():null},c.prototype.getConcatenatedMatrix=function(){var a;return this._locked||(this._parent?this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX-this._parent.anchorPointX,this.anchorPointY-this._parent.anchorPointY):this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)),!this._ignoreParent&&(a=this.getParentMatrix())?(this._concatMatrix.copyFrom(this._matrix),this._concatMatrix.prependMatrix(a),this._concatMatrix):this._matrix},c.prototype.transformPoint=function(a){var b=this.getConcatenatedMatrix();return b.transformPoint(a)},c.prototype.copyFrom=function(a){return this.setTransform(a.x,a.y,a.scaleX,a.scaleY,a.rotation,a.rotPointX,a.rotPointY),this.parent=a.parent,this._matrix=a.matrix.clone(),this},c.prototype.copyTo=function(a){return a.copyFrom(this),this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.copyFrom(this),a},c.prototype.checkAncestor=function(){return!1},Object.defineProperty(c.prototype,"toString",{get:function(){return"[{Transform (x="+this._x+" y="+this._y+" scaleX="+this._scaleX+" scaleY="+this._scaleY+" rotation="+this._rotation+" regX="+this._rotPointX+" regY="+this.rotPointY+" matrix="+this._matrix+")}]"},enumerable:!0,configurable:!0}),c}();b.Transform=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return c.prototype.objType=function(){return"Vector2"},c.fromAngle=function(a){return new c(Math.cos(a),Math.sin(a))},c.randomRadius=function(a){return new c(2*Math.random()-1,2*Math.random()-1).multiplyScalar(a)},c.fromPoint=function(a){return new c(a.x,a.y)},c.prototype.add=function(a){return new c(this.x+a.x,this.y+a.y)},c.prototype.addX=function(a){return new c(this.x+a.x,this.y)},c.prototype.addY=function(a){return new c(this.x,this.y+a.y)},c.prototype.subtract=function(b){return new a.Geom.Vector2(this.x-b.x,this.y-b.y)},c.prototype.multiply=function(b){return new a.Geom.Vector2(this.x*b.x,this.y*b.y)},c.prototype.multiplyScalar=function(b){return new a.Geom.Vector2(this.x*b,this.y*b)},c.prototype.dot=function(a){return this.x*a.x+this.y*a.y},c.prototype.lenSqr=function(){return this.x*this.x+this.y*this.y},c.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},c.prototype.unit=function(){var a=1/this.len();return this.multiplyScalar(a)},c.prototype.floor=function(){return new c(Math.floor(this.x),Math.floor(this.y))},c.prototype.ceil=function(){return new c(Math.ceil(this.x),Math.ceil(this.y))},c.prototype.round=function(){return new c(Math.round(this.x),Math.round(this.y))},c.prototype.clamp=function(a,b){return new c(Math.max(Math.min(this.x,b.x),a.x),Math.max(Math.min(this.y,b.y),a.y))},c.prototype.perp=function(){return new c(-this.y,this.x)},c.prototype.neg=function(){return new c(-this.x,-this.y)},c.prototype.equal=function(a){return this.x===a.x&&this.y===a.y},c.prototype.point=function(){return new b.Point(this.x,this.y)},c.prototype.clear=function(){return this.x=0,this.y=0,this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.setTo(this.x,this.y)},c.prototype.copyFrom=function(a){return this.x=a.x,this.y=a.y,this},c.prototype.copyTo=function(a){return a.x=this.x,a.y=this.y,a},c.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},c.prototype.toString=function(){return"[{Vector2 (x="+this.x+" y="+this.y+")}]"},c}();b.Vector2=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){if(this._game=b,this.name=c,this._manager=this._game.huds,this._device=this._game.deviceTargetOption,this._manager.supported){switch(this._device){case a.TARGET_BROWSER:this.container=document.createElement("div"),this.container.id="HUD-layer-"+b.rnd.uuid(),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="absolute",this._widgets=new Array}this["class"]="kiwi-display"}}return b.prototype.objType=function(){return"HUDDisplay"},b.prototype.addWidget=function(b){return this._manager.supported&&(this._widgets.push(b),this._device==a.TARGET_BROWSER)?(this.container.appendChild(b.container),!0):!1},b.prototype.removeWidget=function(a){if(this._manager.supported&&this.removeFromContainer(a)){var b=this._widgets.indexOf(a);if(-1!==b)return this._widgets.splice(b,1),!0}return!1},b.prototype.removeAllWidgets=function(){for(var a=0;athis._icons.length)for(var a=this.counter.max-this._icons.length,b=0;a>b;b++)this._addIcon();else for(var b=this.counter.max;bthis.counter.current-1?"none":"block"},c.prototype._addIcon=function(){if(this.horizontal)var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x+(this.width+this.iconGap)*(this._icons.length-1),this.y);else var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x,(this.height+this.iconGap)*(this._icons.length-1)+this.y);this._icons.push(b),this._device==a.TARGET_BROWSER&&this.container.appendChild(b.container)},c.prototype._removeIcon=function(b){this._device==a.TARGET_BROWSER&&this.container.removeChild(b.container)},Object.defineProperty(c.prototype,"horizontal",{get:function(){return this._horizontal},set:function(a){this._horizontal=a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"vertical",{get:function(){return!this._horizontal},set:function(a){this._horizontal=!a,this._amountChanged()},enumerable:!0,configurable:!0}),c}(a.HUD.HUDWidget);b.IconBar=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){void 0===f&&(f=0),b.call(this,c,"basicScore",d,e),this.name="basicScore",this["class"]="kiwi-basicscore-widget kiwi-widget",this.counter=this.components.add(new a.HUD.HUDComponents.Counter(this,f)),this.counter.updated.add(this._updateText,this),this._updateText()}return __extends(c,b),c.prototype.objType=function(){return"BasicScoreWidget"},c.prototype._updateText=function(){this.text=String(this.counter.current)},c}(a.HUD.Widget.TextField);b.BasicScore=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,d,e,f),this.name="button",this["class"]="kiwi-button-widget kiwi-widget",this.input=this.components.add(new a.HUD.HUDComponents.WidgetInput(this,this.container))}return __extends(c,b),c.prototype.objType=function(){return"ButtonWidget"},c}(a.HUD.Widget.TextField);b.Button=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,"time",e,f),this.name="time",this["class"]="kiwi-time-widget kiwi-widget",this.time=this.components.add(new a.HUD.HUDComponents.Time(this,d))}return __extends(c,b),c.prototype.objType=function(){return"TimeWidget"},c.prototype.pause=function(){this.time.pause()},c.prototype.stop=function(){this.time.stop()},c.prototype.start=function(){this.time.start()},c.prototype.resume=function(){this.time.resume()},c.prototype.update=function(){b.prototype.update.call(this),this.time.isRunning&&(this.text=this.time.getTime())},c}(a.HUD.Widget.TextField);b.Time=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(a,c,d){b.call(this,a,"menu",c,d),this._menuItems=[],this._styles=[],this["class"]="kiwi-menu-widget kiwi-widget"}return __extends(c,b),c.prototype.objType=function(){return"MenuWidget"},c.prototype.setIconStyle=function(a,b){this._styles.push({index:a,value:b});for(var c=0;cthis._max?this._max:null!==this._min&&athis._min)&&(null!==this._min&&this._current-athis._max?this._current=this._max:this._current+=a,this.updated.dispatch(this._current,this._max,this._min)),this._current},c.prototype.currentPercent=function(){return null!==this.max?this.current/this.max*100:void 0},c}(a.Component);b.Counter=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d){b.call(this,c,"WidgetInput"),this._active=!1,this._container=d,this.onUp=new a.Signal,this.onDown=new a.Signal,this.onOver=new a.Signal,this.onOut=new a.Signal,this._addEvents()}return __extends(c,b),c.prototype.objType=function(){return"WidgetInputComponent"},c.prototype.setElement=function(a){this._removeEvents(),this._container=a,this._addEvents()},c.prototype._addEvents=function(){if(!this._active){this._binds=[],this._binds.push({event:"mouseup","function":this._up.bind(this)}),this._binds.push({event:"mousedown","function":this._down.bind(this)}),this._binds.push({event:"mouseover","function":this._over.bind(this)}),this._binds.push({event:"mouseout","function":this._out.bind(this)});for(var a=0;a=this.duration&&(this._usingWebAudio?this._loop?("default"==this._currentMarker?(this._currentTime=0,this._startTime=this._game.time.now()):this.play(this._currentMarker,!0),this.onLoop.dispatch()):this.stop():this._usingAudioTag&&(this._loop?(this.play(this._currentMarker,!0),this.onLoop.dispatch()):this.stop()))))},b.prototype.destroy=function(){this._game&&this._game.audio.remove(this,!1),this.onLoop&&this.onLoop.dispose(),this.onStop&&this.onStop.dispose(),this.onPlay&&this.onPlay.dispose(),this.onMute&&this.onMute.dispose(),this.onPause&&this.onPause.dispose(),this.onResume&&this.onResume.dispose(),delete this.onLoop,delete this.onStop,delete this.onPause,delete this.onMute,delete this.onPlay,delete this.onResume,delete this._game,delete this._sound,delete this._currentTime,delete this._startTime,delete this._stopTime,delete this._pending,delete this.masterGainNode,delete this.gainNode,delete this.totalDuration,delete this.duration,delete this._file,delete this._buffer,delete this._decoded},b}();b.Audio=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.audio={}}return b.prototype.objType=function(){return"AudioLibrary"},b.prototype.clear=function(){for(var a in this.audio)delete this.audio[a]},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.AudioLibrary: Rebuilding Audio Library.","#audio","#rebuild");for(var d=b.keys,e=0;e0&&(b=Math.min(b,this._maxFrameDuration));for(var c=0;c=this.delay;)this._currentCount++,this.processEvents(a.TimerEvent.TIMER_COUNT),this._elapsed-=this.delay,-1!==this.repeatCount&&this._currentCount>=this.repeatCount&&this.stop();for(;this._elapsed<0;)this._currentCount--,this._elapsed+=this.delay,this._currentCount<0&&(this.clear(),this.stop())},b.prototype.start=function(){return this._isStopped===!0&&(this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._currentCount=0,this._elapsed=0,this._lastElapsed=this._clock.elapsed()||0,this.processEvents(a.TimerEvent.TIMER_START)),this},b.prototype.stop=function(){return(this._isRunning===!0||this._isPaused===!0)&&(this._isRunning=!1,this._isPaused=!1,this._isStopped=!0,this.processEvents(a.TimerEvent.TIMER_STOP)),this},b.prototype.pause=function(){return this._isRunning===!0&&(this._isRunning=!1,this._isPaused=!0),this},b.prototype.resume=function(){return this._isPaused===!0&&(this._isRunning=!0,this._isPaused=!1),this},b.prototype.addTimerEvent=function(b){return b.type===a.TimerEvent.TIMER_START?this._startEvents.push(b):b.type===a.TimerEvent.TIMER_COUNT?this._countEvents.push(b):b.type===a.TimerEvent.TIMER_STOP&&this._stopEvents.push(b),b},b.prototype.createTimerEvent=function(b,c,d){return b===a.TimerEvent.TIMER_START?(this._startEvents.push(new a.TimerEvent(b,c,d)),this._startEvents[this._startEvents.length-1]):b===a.TimerEvent.TIMER_COUNT?(this._countEvents.push(new a.TimerEvent(b,c,d)),this._countEvents[this._countEvents.length-1]):b===a.TimerEvent.TIMER_STOP?(this._stopEvents.push(new a.TimerEvent(b,c,d)),this._stopEvents[this._stopEvents.length-1]):null},b.prototype.removeTimerEvent=function(b){var c=[];return b.type===a.TimerEvent.TIMER_START?c=this._startEvents.splice(this._startEvents.indexOf(b),1):b.type===a.TimerEvent.TIMER_COUNT?c=this._countEvents.splice(this._countEvents.indexOf(b),1):b.type===a.TimerEvent.TIMER_STOP&&(c=this._stopEvents.splice(this._stopEvents.indexOf(b),1)),1===c.length?!0:!1},b.prototype.clear=function(b){void 0===b&&(b=0),0===b?(this._startEvents.length=0,this._countEvents.length=0,this._stopEvents.length=0):b===a.TimerEvent.TIMER_START?this._startEvents.length=0:b===a.TimerEvent.TIMER_COUNT?this._countEvents.length=0:b===a.TimerEvent.TIMER_STOP&&(this._stopEvents.length=0)},b.prototype.toString=function(){return"[{Timer (name="+this.name+" delay="+this.delay+" repeatCount="+this.repeatCount+" running="+this._isRunning+")}]"},b}();a.Timer=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this._callback=null,this.type=0,this.type=a,this._callback=b,this._callbackContext=c}return a.prototype.objType=function(){return"TimerEvent"},a.prototype.run=function(){this._callback&&this._callback.apply(this._callbackContext)},a.TIMER_START=1,a.TIMER_COUNT=2,a.TIMER_STOP=3,a}();a.TimerEvent=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!1),this.domElement=null,this.context=null,this._visible=!0,this._offScreen=!1,this._clearMode=1,this.domElement=document.createElement("canvas"),this.domElement.width=b,this.domElement.height=c,this._width=b,this._height=c,this.context=this.domElement.getContext("2d"),this._offScreen=e,this._visible=d,d===!1&&(this.domElement.style.display="none"),this._bgColor=new a.Utils.Color(0,0,0)}return Object.defineProperty(b.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a,this._updatedSize()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a,this._updatedSize()},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Canvas"},Object.defineProperty(b.prototype,"bgColor",{get:function(){return"#"+this._bgColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._bgColor.set.apply(this._bgColor,b)},enumerable:!0,configurable:!0}),b.prototype._updatedSize=function(){this.domElement.width=this._width,this.domElement.height=this._height},b.prototype.destroy=function(){this._offScreen===!1&&(this.domElement.style.display="none")},Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){null!==a&&a!==this._visible&&(this._visible=a,this.domElement.style.display=a===!0?"block":"none")},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clearMode",{get:function(){return this._clearMode},set:function(b){null!==b&&b!==this._clearMode&&b>=a.Utils.Canvas.CLEARMODE_NONE&&b<=a.Utils.Canvas.CLEARMODE_FILLRECT_ALPHA&&(this._clearMode=b)},enumerable:!0,configurable:!0}),b.prototype.clear=function(){this._clearMode===b.CLEARMODE_NONE||(this._clearMode===b.CLEARMODE_CLEARRECT?this.context.clearRect(0,0,this.domElement.width,this.domElement.height):this._clearMode===b.CLEARMODE_FILLRECT?(this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)):this._clearMode===b.CLEARMODE_FILLRECT_ALPHA&&(this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)))},b.prototype.saveAsPNG=function(){return this.domElement.toDataURL()},b.prototype.toString=function(){return"[{Canvas (width="+this.width+" height="+this.height+" visible="+this.visible+" offScreen="+this._offScreen+" clearMode="+this.clearMode+")}]"},b.CLEARMODE_NONE=0,b.CLEARMODE_CLEARRECT=1,b.CLEARMODE_FILLRECT=2,b.CLEARMODE_FILLRECT_ALPHA=3,b -}();b.Canvas=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){for(var a=[],b=0;b1?this.r255=a:this.rNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g",{get:function(){return this._g},set:function(a){a>1?this.g255=a:this.gNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b",{get:function(){return this._b},set:function(a){a>1?this.b255=a:this.bNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a",{get:function(){return this._a},set:function(a){a>1?this.a255=a:this.aNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"r255",{get:function(){return Math.round(255*this._r)},set:function(a){isNaN(a)||(this._r=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g255",{get:function(){return Math.round(255*this._g)},set:function(a){isNaN(a)||(this._g=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b255",{get:function(){return Math.round(255*this._b)},set:function(a){isNaN(a)||(this._b=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a255",{get:function(){return Math.round(255*this._a)},set:function(a){isNaN(a)||(this._a=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"red",{get:function(){return this.r},set:function(a){this.r=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"green",{get:function(){return this.g},set:function(a){this.g=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"blue",{get:function(){return this.b},set:function(a){this.b=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"alpha",{get:function(){return this.a},set:function(a){this.a=a},enumerable:!0,configurable:!0}),a.prototype.parseString=function(a){var b;return a=a.toLowerCase(),"rgba"===a.slice(0,4)?(a=a.replace("rgba",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2],this.a=+b[3]):"rgb"===a.slice(0,3)?(a=a.replace("rgb",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2]):"hsla"===a.slice(0,4)?(a=a.replace("hsla",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2],+b[3])):"hsl"===a.slice(0,3)?(a=a.replace("hsl",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2])):this.parseHex(a),this},a.prototype.parseHex=function(a){var b,c=this.r255,d=this.g255,e=this.b255,f=this.a255;return"#"===a.charAt(0)&&(a=a.slice(1)),"0x"===a.slice(0,2)&&(a=a.slice(2)),b=parseInt(a,16),3===a.length?(c=17*(b>>8&15),d=17*(b>>4&15),e=17*(15&b)):4===a.length?(c=17*(b>>12&15),d=17*(b>>8&15),e=17*(b>>4&15),f=17*(15&b)):6===a.length?(c=b>>16&255,d=b>>8&255,e=255&b,f=255):8===a.length&&(c=b>>24&255,d=b>>16&255,e=b>>8&255,f=255&b),this.r255=c,this.g255=d,this.b255=e,this.a255=f,this},a.prototype.getHex=function(a){void 0===a&&(a=!0);var b,c="";for(b=this.r255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.g255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.b255.toString(16);b.length<2;)b="0"+b;if(c+=b,a){for(b=this.a255.toString(16);b.length<2;)b="0"+b;c+=b}return c},a.prototype.parseHsv=function(a,b,c,d){void 0===d&&(d=1);var e,f,g,h,i,j,k,l;if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d))return this;switch(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),h=Math.floor(6*a),i=6*a-h,j=c*(1-b),k=c*(1-i*b),l=c*(1-(1-i)*b),h%6){case 0:e=c,f=l,g=j;break;case 1:e=k,f=c,g=j;break;case 2:e=j,f=c,g=l;break;case 3:e=j,f=k,g=c;break;case 4:e=l,f=j,g=c;break;case 5:e=c,f=j,g=k}return this._r=e,this._g=f,this._b=g,this._a=d,this},a.prototype.getHsva=function(){var a,b,c,d,e=this._r,f=this._g,g=this._b,h=Math.max(e,f,g),i=Math.min(e,f,g);if(a=h,b=h,c=h,d=h-i,b=0===h?0:d/h,h===i)a=0;else{switch(h){case e:a=(f-g)/d+(g>f?6:0);break;case f:a=(g-e)/d+2;break;case g:a=(e-f)/d+4}a/=6}return{h:a,s:b,v:c,a:this._a}},a.prototype.parseHsl=function(a,b,c,d){void 0===d&&(d=1);var e,f,g=this._r,h=this._g,i=this._b;return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)?this:(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),0===b?(g=c,h=c,i=c):(e=.5>c?c*(1+b):c+b-c*b,f=2*c-e,g=this._hue2rgb(f,e,a+1/3),h=this._hue2rgb(f,e,a),i=this._hue2rgb(f,e,a-1/3)),this._r=g,this._g=h,this._b=i,this._a=d,this)},a.prototype.getHsla=function(){var a,b=this._r,c=this._g,d=this._b,e=Math.max(b,c,d),f=Math.min(b,c,d),g=(e+f)/2,h=(e+f)/2,i=(e+f)/2;if(e==f)g=0,h=0;else{switch(a=e-f,h=i>.5?a/(2-e-f):a/(e+f),e){case b:g=(c-d)/a+(d>c?6:0);break;case c:g=(d-b)/a+2;break;case d:g=(b-c)/a+4}g/=6}return{h:g,s:h,l:i,a:this._a}},a.prototype._hue2rgb=function(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a},a}();a.Color=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.defaultCompare=function(a,b){return b>a?-1:a===b?0:1},b.prototype.objType=function(){return"Common"},b.defaultEquals=function(a,b){return a===b},b.defaultToString=function(b){return null===b?"KIWI_NULL":a.Utils.Common.isUndefined(b)?"KIWI_UNDEFINED":a.Utils.Common.isString(b)?b:b.toString()},b.isBetween=function(a,b,c){return a>b&&c>a},b.isFunction=function(a){return"function"==typeof a},b.isNumeric=function(a){return!isNaN(a)},b.isUndefined=function(a){return"undefined"==typeof a},b.isString=function(a){return"[object String]"===Object.prototype.toString.call(a)},b.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.isObject=function(a){return"[object Object]"===Object.prototype.toString.call(a)},b.reverseCompareFunction=function(b){return a.Utils.Common.isFunction(b)?function(a,c){return-1*b(a,c)}:function(a,b){return b>a?1:a===b?0:-1}},b.compareToEquals=function(a){return function(b,c){return 0===a(b,c)}},b.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},b.convertToBase2=function(a){var b=a.width,c=a.height;if(-1==this.base2Sizes.indexOf(b)){for(var d=0;b>this.base2Sizes[d];)d++;b=this.base2Sizes[d]}if(-1==this.base2Sizes.indexOf(c)){for(var d=0;c>this.base2Sizes[d];)d++;c=this.base2Sizes[d]}if(a.width!==b||a.height!==c){var e=document.createElement("canvas");return e.width=b,e.height=c,e.getContext("2d").drawImage(a,0,0),e}return a},b.base2Sizes=[2,4,16,32,64,128,256,512,1024,2048,4096],b}();b.Common=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"GameMath"},b.computeMachineEpsilon=function(){var a=4/3,b=a-1,c=b+b+b;return Math.abs(1-c)},b.fuzzyEqual=function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)a},b.fuzzyGreaterThan=function(a,b,c){return void 0===c&&(c=1e-4),a>b-c},b.fuzzyCeil=function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},b.fuzzyFloor=function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},b.average=function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},b.shear=function(a){return a%1},b.wrap=function(a,b,c){if(void 0===c&&(c=0),a-=c,b-=c,0==b)return c;for(a%=b,a+=c;c>a;)a+=b;return a},b.arithWrap=function(a,b,c){return void 0===c&&(c=0),b-=c,0==b?c:a-b*Math.floor((a-c)/b)},b.clamp=function(a,b,c){return void 0===c&&(c=0),Math.max(c,Math.min(b,a))},b.snapTo=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},b.snapToFloor=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},b.snapToCeil=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},b.snapToInArray=function(a,b,c){if(void 0===c&&(c=!0),c&&b.sort(),a=f-a?f:e},b.roundTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},b.floorTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},b.ceilTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},b.interpolateFloat=function(a,b,c){return(b-a)*c+a},b.radiansToDegrees=function(a){return a*b.RAD_TO_DEG},b.degreesToRadians=function(a){return a*b.DEG_TO_RAD},b.angleBetween=function(a,b,c,d){return Math.atan2(d-b,c-a)},b.normalizeAngle=function(a,c){void 0===c&&(c=!0);var d=c?b.PI:180;return b.wrap(a,d,-d)},b.nearestAngleBetween=function(a,c,d){void 0===d&&(d=!0);var e=d?b.PI:180;return a=b.normalizeAngle(a,d),c=b.normalizeAngle(c,d),-e/2>a&&c>e/2&&(a+=2*e),-e/2>c&&a>e/2&&(c+=2*e),b.normalizeAngle(c-a,d)},b.normalizeAngleToAnother=function(b,c,d){return void 0===d&&(d=!0),c+a.Utils.GameMath.nearestAngleBetween(c,b,d)},b.normalizeAngleAfterAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(b-c,d),c+b},b.normalizeAngleBeforeAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(c-b,d),c-b},b.interpolateAngles=function(b,c,d,e,f){return void 0===e&&(e=!0),void 0===f&&(f=null),b=a.Utils.GameMath.normalizeAngle(b,e),c=a.Utils.GameMath.normalizeAngleToAnother(c,b,e),"function"==typeof f?f(d,b,c-b,1):a.Utils.GameMath.interpolateFloat(b,c,d)},b.logBaseOf=function(a,b){return Math.log(a)/Math.log(b)},b.GCD=function(a,b){var c;for(a=Math.abs(a),b=Math.abs(b),b>a&&(c=a,a=b,b=c);;){if(c=a%b,!c)return b;a=b,b=c}return 1},b.LCM=function(b,c){return b*c/a.Utils.GameMath.GCD(b,c)},b.factorial=function(a){if(0==a)return 1;for(var b=a;--a;)b*=a;return b},b.gammaFunction=function(b){return a.Utils.GameMath.factorial(b-1)},b.fallingFactorial=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(b-c)},b.risingFactorial=function(b,c){return a.Utils.GameMath.factorial(b+c-1)/a.Utils.GameMath.factorial(b-1)},b.binCoef=function(b,c){return a.Utils.GameMath.fallingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.risingBinCoef=function(b,c){return a.Utils.GameMath.risingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.chanceRoll=function(a){return void 0===a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},b.maxAdd=function(a,b,c){return a+=b,a>c&&(a=c),a},b.minSub=function(a,b,c){return a-=b,c>a&&(a=c),a},b.wrapValue=function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},b.randomSign=function(){return Math.random()>.5?1:-1},b.isOdd=function(a){return 1&a?!0:!1},b.isEven=function(a){return 1&a?!1:!0},b.wrapAngle=function(a){var b=a;return a>=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},b.angleLimit=function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},b.linearInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return 0>c?a.Utils.GameMath.linear(b[0],b[1],e):c>1?a.Utils.GameMath.linear(b[d],b[d-1],d-e):a.Utils.GameMath.linear(b[f],b[f+1>d?d:f+1],e-f)},b.bezierInterpolation=function(b,c){for(var d=0,e=b.length-1,f=0;e>=f;f++)d+=Math.pow(1-c,e-f)*Math.pow(c,f)*b[f]*a.Utils.GameMath.bernstein(e,f);return d},b.catmullRomInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return b[0]===b[d]?(0>c&&(f=Math.floor(e=d*(1+c))),a.Utils.GameMath.catmullRom(b[(f-1+d)%d],b[f],b[(f+1)%d],b[(f+2)%d],e-f)):0>c?b[0]-(a.Utils.GameMath.catmullRom(b[0],b[0],b[1],b[1],-e)-b[0]):c>1?b[d]-(a.Utils.GameMath.catmullRom(b[d],b[d],b[d-1],b[d-1],e-d)-b[d]):a.Utils.GameMath.catmullRom(b[f?f-1:0],b[f],b[f+1>d?d:f+1],b[f+2>d?d:f+2],e-f)},b.linear=function(a,b,c){return(b-a)*c+a},b.bernstein=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(c)/a.Utils.GameMath.factorial(b-c)},b.catmullRom=function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},b.difference=function(a,b){return Math.abs(a-b)},b.PI=3.141592653589793,b.PI_2=1.5707963267948966,b.PI_4=.7853981633974483,b.PI_8=.39269908169872414,b.PI_16=.19634954084936207,b.TWO_PI=6.283185307179586,b.THREE_PI_2=4.71238898038469,b.E=2.71828182845905,b.LN10=2.302585092994046,b.LN2=.6931471805599453,b.LOG10E=.4342944819032518,b.LOG2E=1.4426950408889634,b.SQRT1_2=.7071067811865476,b.SQRT2=1.4142135623730951,b.DEG_TO_RAD=.017453292519943295,b.RAD_TO_DEG=57.29577951308232,b.B_16=65536,b.B_31=2147483648,b.B_32=4294967296,b.B_48=281474976710656,b.B_53=9007199254740992,b.B_64=0x10000000000000000,b.ONE_THIRD=.3333333333333333,b.TWO_THIRDS=.6666666666666666,b.ONE_SIXTH=.16666666666666666,b.COS_PI_3=.8660254037844386,b.SIN_2PI_3=.03654595,b.CIRCLE_ALPHA=.5522847498307935,b.ON=!0,b.OFF=!1,b.SHORT_EPSILON=.1,b.PERC_EPSILON=.001,b.EPSILON=1e-4,b.LONG_EPSILON=1e-8,b}();b.GameMath=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){void 0===a&&(a=[]),this.c=1,this._data={lipsum:["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","nunc","sagittis","tortor","ac","mi","pretium","sed","convallis","massa","pulvinar","curabitur","non","turpis","velit","vitae","rutrum","odio","aliquam","sapien","orci","tempor","sed","elementum","sit","amet","tincidunt","sed","risus","etiam","nec","lacus","id","ante","hendrerit","malesuada","donec","porttitor","magna","eget","libero","pharetra","sollicitudin","aliquam","mattis","mattis","massa","et","porta","morbi","vitae","magna","augue","vestibulum","at","lectus","sed","tellus","facilisis","tincidunt","suspendisse","eros","magna","consequat","at","sollicitudin","ac","vestibulum","vel","dolor","in","egestas","lacus","quis","lacus","placerat","et","molestie","ipsum","scelerisque","nullam","sit","amet","tortor","dui","aenean","pulvinar","odio","nec","placerat","fringilla","neque","dolor"]},this.sow(a)}return a.prototype.objType=function(){return"RandomDataGenerator"},a.prototype.uint32=function(){return 4294967296*this.rnd.apply(this)},a.prototype.fract32=function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},a.prototype.rnd=function(){var a=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|a,this.s0=this.s1,this.s1=this.s2,this.s2=a-this.c,this.s2},a.prototype.hash=function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},a.prototype.sow=function(a){void 0===a&&(a=[]),this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1);for(var b,c=0;b=a[c++];)this.s0-=this.hash(b),this.s0+=~~(this.s0<0),this.s1-=this.hash(b),this.s1+=~~(this.s1<0),this.s2-=this.hash(b),this.s2+=~~(this.s2<0)},a.prototype.integer=function(){return this.uint32()},a.prototype.frac=function(){return this.fract32()},a.prototype.real=function(){return this.uint32()+this.fract32()},a.prototype.integerInRange=function(a,b){return Math.floor(this.realInRange(a,b))},a.prototype.realInRange=function(a,b){return a=a||0,b=b||0,this.frac()*(b-a)+a},a.prototype.normal=function(){return 1-2*this.frac()},a.prototype.uuid=function(){var a,b;for(b=a="";a++<36;b+=~a%5|3*a&4?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},a.prototype.pick=function(a){return a[this.integerInRange(0,a.length)]},a.prototype.weightedPick=function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},a.prototype.word=function(){return this.pick(this._data.lipsum)},a.prototype.words=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.pick(this._data.lipsum));return b.join(" ")},a.prototype.sentence=function(){var a;return a=this.words(this.integerInRange(2,16)).replace(/[a-z]/,function(a){return a.toUpperCase()}),a+"."},a.prototype.sentences=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.sentence());return b.join(" ")},a.prototype.timestamp=function(a,b){return void 0===a&&(a=9466848e5),void 0===b&&(b=1577862e6),this.realInRange(a,b)},a.prototype.angle=function(){return this.integerInRange(-180,180)},a}();a.RandomDataGenerator=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._isSetTimeOut=!1,this.lastTime=0,this.currentTime=0,this.isRunning=!1,this._callback=a;for(var b=["ms","moz","webkit","o"],c=0;c0?this.recordings[this.recordings.length-1].time:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"numRecordings",{get:function(){return this.recordings.length},enumerable:!0,configurable:!0}),b.prototype.record=function(a,b,c){if(void 0===b&&(b=[]),void 0===c&&(c=console.log),this.recording){var d={messages:a,time:Date.now(),tags:b,logMethod:c};this.recordings.push(d)>this.maxRecordings&&this.recordings.shift()}},b.prototype.clearRecordings=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.recordings.length),this.recordings.splice(a,b)},b.prototype._execute=function(a,b,c,d){void 0===d&&(d=!1),(this.display||d)&&a.apply(b,c)},b.prototype.getTagsFromArray=function(a){for(var b=0,c=[];bd.time&&this._show(d,c)},b.prototype.addFilter=function(){for(var a=[],b=0;be.majorVersion?"greater":d.majorVersione.minorVersion?"greater":d.minorVersione.patchVersion?"greater":d.patchVersion0&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},f.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},f.cross=function(a,b,c){var d=b[0]*c[1]-b[1]*c[0];return a[0]=a[1]=0,a[2]=d,a},f.lerp=function(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a},f.random=function(a,b){b=b||1;var c=2*d()*Math.PI;return a[0]=Math.cos(c)*b,a[1]=Math.sin(c)*b,a},f.transformMat2=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[2]*e,a[1]=c[1]*d+c[3]*e,a},f.transformMat2d=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[2]*e+c[4],a[1]=c[1]*d+c[3]*e+c[5],a},f.transformMat3=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[3]*e+c[6],a[1]=c[1]*d+c[4]*e+c[7],a},f.transformMat4=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[4]*e+c[12],a[1]=c[1]*d+c[5]*e+c[13],a -},f.forEach=function(){var a=f.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=2),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],f(a,a,g),b[h]=a[0],b[h+1]=a[1];return b}}(),f.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},"undefined"!=typeof a&&(a.vec2=f);var g={};g.create=function(){var a=new c(3);return a[0]=0,a[1]=0,a[2]=0,a},g.clone=function(a){var b=new c(3);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b},g.fromValues=function(a,b,d){var e=new c(3);return e[0]=a,e[1]=b,e[2]=d,e},g.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a},g.set=function(a,b,c,d){return a[0]=b,a[1]=c,a[2]=d,a},g.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a},g.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a},g.sub=g.subtract,g.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a},g.mul=g.multiply,g.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},g.div=g.divide,g.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a},g.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a},g.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a},g.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a},g.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return Math.sqrt(c*c+d*d+e*e)},g.dist=g.distance,g.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return c*c+d*d+e*e},g.sqrDist=g.squaredDistance,g.length=function(a){var b=a[0],c=a[1],d=a[2];return Math.sqrt(b*b+c*c+d*d)},g.len=g.length,g.squaredLength=function(a){var b=a[0],c=a[1],d=a[2];return b*b+c*c+d*d},g.sqrLen=g.squaredLength,g.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a},g.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=c*c+d*d+e*e;return f>0&&(f=1/Math.sqrt(f),a[0]=b[0]*f,a[1]=b[1]*f,a[2]=b[2]*f),a},g.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},g.cross=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a},g.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a},g.random=function(a,b){b=b||1;var c=2*d()*Math.PI,e=2*d()-1,f=Math.sqrt(1-e*e)*b;return a[0]=Math.cos(c)*f,a[1]=Math.sin(c)*f,a[2]=e*b,a},g.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12],a[1]=c[1]*d+c[5]*e+c[9]*f+c[13],a[2]=c[2]*d+c[6]*e+c[10]*f+c[14],a},g.transformMat3=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=d*c[0]+e*c[3]+f*c[6],a[1]=d*c[1]+e*c[4]+f*c[7],a[2]=d*c[2]+e*c[5]+f*c[8],a},g.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},g.forEach=function(){var a=g.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=3),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2];return b}}(),g.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"},"undefined"!=typeof a&&(a.vec3=g);var h={};h.create=function(){var a=new c(4);return a[0]=0,a[1]=0,a[2]=0,a[3]=0,a},h.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},h.fromValues=function(a,b,d,e){var f=new c(4);return f[0]=a,f[1]=b,f[2]=d,f[3]=e,f},h.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},h.set=function(a,b,c,d,e){return a[0]=b,a[1]=c,a[2]=d,a[3]=e,a},h.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a[3]=b[3]+c[3],a},h.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a[3]=b[3]-c[3],a},h.sub=h.subtract,h.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a},h.mul=h.multiply,h.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a[3]=b[3]/c[3],a},h.div=h.divide,h.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a[3]=Math.min(b[3],c[3]),a},h.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a[3]=Math.max(b[3],c[3]),a},h.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a},h.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a[3]=b[3]+c[3]*d,a},h.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return Math.sqrt(c*c+d*d+e*e+f*f)},h.dist=h.distance,h.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return c*c+d*d+e*e+f*f},h.sqrDist=h.squaredDistance,h.length=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return Math.sqrt(b*b+c*c+d*d+e*e)},h.len=h.length,h.squaredLength=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return b*b+c*c+d*d+e*e},h.sqrLen=h.squaredLength,h.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=-b[3],a},h.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f;return g>0&&(g=1/Math.sqrt(g),a[0]=b[0]*g,a[1]=b[1]*g,a[2]=b[2]*g,a[3]=b[3]*g),a},h.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},h.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2],h=b[3];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a[3]=h+d*(c[3]-h),a},h.random=function(a,b){return b=b||1,a[0]=d(),a[1]=d(),a[2]=d(),a[3]=d(),h.normalize(a,a),h.scale(a,a,b),a},h.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12]*g,a[1]=c[1]*d+c[5]*e+c[9]*f+c[13]*g,a[2]=c[2]*d+c[6]*e+c[10]*f+c[14]*g,a[3]=c[3]*d+c[7]*e+c[11]*f+c[15]*g,a},h.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},h.forEach=function(){var a=h.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=4),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],a[3]=b[h+3],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2],b[h+3]=a[3];return b}}(),h.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.vec4=h);var i={};i.create=function(){var a=new c(4);return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},i.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},i.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},i.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},i.transpose=function(a,b){if(a===b){var c=b[1];a[1]=b[2],a[2]=c}else a[0]=b[0],a[1]=b[2],a[2]=b[1],a[3]=b[3];return a},i.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*f-e*d;return g?(g=1/g,a[0]=f*g,a[1]=-d*g,a[2]=-e*g,a[3]=c*g,a):null},i.adjoint=function(a,b){var c=b[0];return a[0]=b[3],a[1]=-b[1],a[2]=-b[2],a[3]=c,a},i.determinant=function(a){return a[0]*a[3]-a[2]*a[1]},i.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*h+e*j,a[1]=d*i+e*k,a[2]=f*h+g*j,a[3]=f*i+g*k,a},i.mul=i.multiply,i.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+e*h,a[1]=d*-h+e*i,a[2]=f*i+g*h,a[3]=f*-h+g*i,a},i.scale=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1];return a[0]=d*h,a[1]=e*i,a[2]=f*h,a[3]=g*i,a},i.str=function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.mat2=i);var j={};j.create=function(){var a=new c(6);return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},j.clone=function(a){var b=new c(6);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b},j.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a},j.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},j.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=c*f-d*e;return i?(i=1/i,a[0]=f*i,a[1]=-d*i,a[2]=-e*i,a[3]=c*i,a[4]=(e*h-f*g)*i,a[5]=(d*g-c*h)*i,a):null},j.determinant=function(a){return a[0]*a[3]-a[1]*a[2]},j.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=c[0],k=c[1],l=c[2],m=c[3],n=c[4],o=c[5];return a[0]=d*j+e*l,a[1]=d*k+e*m,a[2]=f*j+g*l,a[3]=f*k+g*m,a[4]=j*h+l*i+n,a[5]=k*h+m*i+o,a},j.mul=j.multiply,j.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=Math.sin(c),k=Math.cos(c);return a[0]=d*k+e*j,a[1]=-d*j+e*k,a[2]=f*k+g*j,a[3]=-f*j+k*g,a[4]=k*h+j*i,a[5]=k*i-j*h,a},j.scale=function(a,b,c){var d=c[0],e=c[1];return a[0]=b[0]*d,a[1]=b[1]*e,a[2]=b[2]*d,a[3]=b[3]*e,a[4]=b[4]*d,a[5]=b[5]*e,a},j.translate=function(a,b,c){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4]+c[0],a[5]=b[5]+c[1],a},j.str=function(a){return"mat2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"},"undefined"!=typeof a&&(a.mat2d=j);var k={};k.create=function(){var a=new c(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},k.fromMat4=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[4],a[4]=b[5],a[5]=b[6],a[6]=b[8],a[7]=b[9],a[8]=b[10],a},k.clone=function(a){var b=new c(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},k.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},k.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},k.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[5];a[1]=b[3],a[2]=b[6],a[3]=c,a[5]=b[7],a[6]=d,a[7]=e}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8];return a},k.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=k*g-h*j,m=-k*f+h*i,n=j*f-g*i,o=c*l+d*m+e*n;return o?(o=1/o,a[0]=l*o,a[1]=(-k*d+e*j)*o,a[2]=(h*d-e*g)*o,a[3]=m*o,a[4]=(k*c-e*i)*o,a[5]=(-h*c+e*f)*o,a[6]=n*o,a[7]=(-j*c+d*i)*o,a[8]=(g*c-d*f)*o,a):null},k.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},k.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8];return b*(j*f-g*i)+c*(-j*e+g*h)+d*(i*e-f*h)},k.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},k.mul=k.multiply,k.translate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1];return a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=m*d+n*g+j,a[7]=m*e+n*h+k,a[8]=m*f+n*i+l,a},k.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=Math.sin(c),n=Math.cos(c);return a[0]=n*d+m*g,a[1]=n*e+m*h,a[2]=n*f+m*i,a[3]=n*g-m*d,a[4]=n*h-m*e,a[5]=n*i-m*f,a[6]=j,a[7]=k,a[8]=l,a},k.scale=function(a,b,c){var d=c[0],e=c[1];return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=e*b[3],a[4]=e*b[4],a[5]=e*b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},k.fromMat2d=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=0,a[3]=b[2],a[4]=b[3],a[5]=0,a[6]=b[4],a[7]=b[5],a[8]=1,a},k.fromQuat=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c+c,h=d+d,i=e+e,j=c*g,k=c*h,l=c*i,m=d*h,n=d*i,o=e*i,p=f*g,q=f*h,r=f*i;return a[0]=1-(m+o),a[3]=k+r,a[6]=l-q,a[1]=k-r,a[4]=1-(j+o),a[7]=n+p,a[2]=l+q,a[5]=n-p,a[8]=1-(j+m),a},k.normalFromMat4=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(i*A-g*D-j*z)*E,a[2]=(g*C-h*A+j*y)*E,a[3]=(e*C-d*D-f*B)*E,a[4]=(c*D-e*A+f*z)*E,a[5]=(d*A-c*C-f*y)*E,a[6]=(p*x-q*w+r*v)*E,a[7]=(q*u-o*x-r*t)*E,a[8]=(o*w-p*u+r*s)*E,a):null},k.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"},"undefined"!=typeof a&&(a.mat3=k);var l={};l.create=function(){var a=new c(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},l.clone=function(a){var b=new c(16);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b},l.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},l.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},l.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[3],f=b[6],g=b[7],h=b[11];a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=c,a[6]=b[9],a[7]=b[13],a[8]=d,a[9]=f,a[11]=b[14],a[12]=e,a[13]=g,a[14]=h}else a[0]=b[0],a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=b[1],a[5]=b[5],a[6]=b[9],a[7]=b[13],a[8]=b[2],a[9]=b[6],a[10]=b[10],a[11]=b[14],a[12]=b[3],a[13]=b[7],a[14]=b[11],a[15]=b[15];return a},l.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(e*C-d*D-f*B)*E,a[2]=(p*x-q*w+r*v)*E,a[3]=(m*w-l*x-n*v)*E,a[4]=(i*A-g*D-j*z)*E,a[5]=(c*D-e*A+f*z)*E,a[6]=(q*u-o*x-r*t)*E,a[7]=(k*x-m*u+n*t)*E,a[8]=(g*C-h*A+j*y)*E,a[9]=(d*A-c*C-f*y)*E,a[10]=(o*w-p*u+r*s)*E,a[11]=(l*u-k*w-n*s)*E,a[12]=(h*z-g*B-i*y)*E,a[13]=(c*B-d*z+e*y)*E,a[14]=(p*t-o*v-q*s)*E,a[15]=(k*v-l*t+m*s)*E,a):null},l.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15];return a[0]=h*(m*r-n*q)-l*(i*r-j*q)+p*(i*n-j*m),a[1]=-(d*(m*r-n*q)-l*(e*r-f*q)+p*(e*n-f*m)),a[2]=d*(i*r-j*q)-h*(e*r-f*q)+p*(e*j-f*i),a[3]=-(d*(i*n-j*m)-h*(e*n-f*m)+l*(e*j-f*i)),a[4]=-(g*(m*r-n*q)-k*(i*r-j*q)+o*(i*n-j*m)),a[5]=c*(m*r-n*q)-k*(e*r-f*q)+o*(e*n-f*m),a[6]=-(c*(i*r-j*q)-g*(e*r-f*q)+o*(e*j-f*i)),a[7]=c*(i*n-j*m)-g*(e*n-f*m)+k*(e*j-f*i),a[8]=g*(l*r-n*p)-k*(h*r-j*p)+o*(h*n-j*l),a[9]=-(c*(l*r-n*p)-k*(d*r-f*p)+o*(d*n-f*l)),a[10]=c*(h*r-j*p)-g*(d*r-f*p)+o*(d*j-f*h),a[11]=-(c*(h*n-j*l)-g*(d*n-f*l)+k*(d*j-f*h)),a[12]=-(g*(l*q-m*p)-k*(h*q-i*p)+o*(h*m-i*l)),a[13]=c*(l*q-m*p)-k*(d*q-e*p)+o*(d*m-e*l),a[14]=-(c*(h*q-i*p)-g*(d*q-e*p)+o*(d*i-e*h)),a[15]=c*(h*m-i*l)-g*(d*m-e*l)+k*(d*i-e*h),a},l.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8],k=a[9],l=a[10],m=a[11],n=a[12],o=a[13],p=a[14],q=a[15],r=b*g-c*f,s=b*h-d*f,t=b*i-e*f,u=c*h-d*g,v=c*i-e*g,w=d*i-e*h,x=j*o-k*n,y=j*p-l*n,z=j*q-m*n,A=k*p-l*o,B=k*q-m*o,C=l*q-m*p;return r*C-s*B+t*A+u*z-v*y+w*x},l.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3];return a[0]=t*d+u*h+v*l+w*p,a[1]=t*e+u*i+v*m+w*q,a[2]=t*f+u*j+v*n+w*r,a[3]=t*g+u*k+v*o+w*s,t=c[4],u=c[5],v=c[6],w=c[7],a[4]=t*d+u*h+v*l+w*p,a[5]=t*e+u*i+v*m+w*q,a[6]=t*f+u*j+v*n+w*r,a[7]=t*g+u*k+v*o+w*s,t=c[8],u=c[9],v=c[10],w=c[11],a[8]=t*d+u*h+v*l+w*p,a[9]=t*e+u*i+v*m+w*q,a[10]=t*f+u*j+v*n+w*r,a[11]=t*g+u*k+v*o+w*s,t=c[12],u=c[13],v=c[14],w=c[15],a[12]=t*d+u*h+v*l+w*p,a[13]=t*e+u*i+v*m+w*q,a[14]=t*f+u*j+v*n+w*r,a[15]=t*g+u*k+v*o+w*s,a},l.mul=l.multiply,l.translate=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=c[0],q=c[1],r=c[2];return b===a?(a[12]=b[0]*p+b[4]*q+b[8]*r+b[12],a[13]=b[1]*p+b[5]*q+b[9]*r+b[13],a[14]=b[2]*p+b[6]*q+b[10]*r+b[14],a[15]=b[3]*p+b[7]*q+b[11]*r+b[15]):(d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=j,a[7]=k,a[8]=l,a[9]=m,a[10]=n,a[11]=o,a[12]=d*p+h*q+l*r+b[12],a[13]=e*p+i*q+m*r+b[13],a[14]=f*p+j*q+n*r+b[14],a[15]=g*p+k*q+o*r+b[15]),a},l.scale=function(a,b,c){var d=c[0],e=c[1],f=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*e,a[5]=b[5]*e,a[6]=b[6]*e,a[7]=b[7]*e,a[8]=b[8]*f,a[9]=b[9]*f,a[10]=b[10]*f,a[11]=b[11]*f,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},l.rotate=function(a,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D=e[0],E=e[1],F=e[2],G=Math.sqrt(D*D+E*E+F*F);return Math.abs(G)h?(g.cross(a,b,e),g.length(a)<1e-6&&g.cross(a,c,e),g.normalize(a,a),m.setAxisAngle(d,a,Math.PI),d):h>.999999?(d[0]=0,d[1]=0,d[2]=0,d[3]=1,d):(g.cross(a,e,f),d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=1+h,m.normalize(d,d))}}(),m.setAxes=function(){var a=k.create();return function(b,c,d,e){return a[0]=d[0],a[3]=d[1],a[6]=d[2],a[1]=e[0],a[4]=e[1],a[7]=e[2],a[2]=c[0],a[5]=c[1],a[8]=c[2],m.normalize(b,m.fromMat3(b,a))}}(),m.clone=h.clone,m.fromValues=h.fromValues,m.copy=h.copy,m.set=h.set,m.identity=function(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a},m.setAxisAngle=function(a,b,c){c*=.5;var d=Math.sin(c);return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=Math.cos(c),a},m.add=h.add,m.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*k+g*h+e*j-f*i,a[1]=e*k+g*i+f*h-d*j,a[2]=f*k+g*j+d*i-e*h,a[3]=g*k-d*h-e*i-f*j,a},m.mul=m.multiply,m.scale=h.scale,m.rotateX=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+g*h,a[1]=e*i+f*h,a[2]=f*i-e*h,a[3]=g*i-d*h,a},m.rotateY=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i-f*h,a[1]=e*i+g*h,a[2]=f*i+d*h,a[3]=g*i-e*h,a},m.rotateZ=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+e*h,a[1]=e*i-d*h,a[2]=f*i+g*h,a[3]=g*i-f*h,a},m.calculateW=function(a,b){var c=b[0],d=b[1],e=b[2];return a[0]=c,a[1]=d,a[2]=e,a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a},m.dot=h.dot,m.lerp=h.lerp,m.slerp=function(a,b,c,d){var e,f,g,h,i,j=b[0],k=b[1],l=b[2],m=b[3],n=c[0],o=c[1],p=c[2],q=c[3];return f=j*n+k*o+l*p+m*q,0>f&&(f=-f,n=-n,o=-o,p=-p,q=-q),1-f>1e-6?(e=Math.acos(f),g=Math.sin(e),h=Math.sin((1-d)*e)/g,i=Math.sin(d*e)/g):(h=1-d,i=d),a[0]=h*j+i*n,a[1]=h*k+i*o,a[2]=h*l+i*p,a[3]=h*m+i*q,a},m.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f,h=g?1/g:0;return a[0]=-c*h,a[1]=-d*h,a[2]=-e*h,a[3]=f*h,a},m.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},m.length=h.length,m.len=m.length,m.squaredLength=h.squaredLength,m.sqrLen=m.squaredLength,m.normalize=h.normalize,m.fromMat3=function(){var a="undefined"!=typeof Int8Array?new Int8Array([1,2,0]):[1,2,0];return function(b,c){var d,e=c[0]+c[4]+c[8];if(e>0)d=Math.sqrt(e+1),b[3]=.5*d,d=.5/d,b[0]=(c[7]-c[5])*d,b[1]=(c[2]-c[6])*d,b[2]=(c[3]-c[1])*d;else{var f=0;c[4]>c[0]&&(f=1),c[8]>c[3*f+f]&&(f=2);var g=a[f],h=a[g];d=Math.sqrt(c[3*f+f]-c[3*g+g]-c[3*h+h]+1),b[f]=.5*d,d=.5/d,b[3]=(c[3*h+g]-c[3*g+h])*d,b[g]=(c[3*g+f]+c[3*f+g])*d,b[h]=(c[3*h+f]+c[3*f+h])*d}return b}}(),m.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.quat=m)}(b.exports)}(this); \ No newline at end of file +}return __extends(c,b),c.prototype.isTouching=function(a){return(this.touching&a)==a},c.prototype.solid=function(a){return void 0!==a&&(this.allowCollisions=a?c.ANY:c.NONE),(this.allowCollisions&c.ANY)>c.NONE},c.prototype.setCallback=function(a,b){this._callbackFunction=a,this._callbackContext=b},c.prototype.rotateToVelocity=function(){var a=Math.atan2(this.velocity.y,this.velocity.x);return this.transform.rotation=a,a},c.separate=function(a,b){var c=this.separateX(a,b),d=this.separateY(a,b);return c||d},c.separateX=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldX-e.last.x,i=f.transform.worldX-f.last.x;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x-(h>0?h:0),e.last.y+e.box.hitboxOffset.y,l.width+(h>0?h:-h),l.height),o=new a.Geom.Rectangle(m.x-(i>0?i:0),f.last.y+f.box.hitboxOffset.y,m.width+(i>0?i:-i),m.height);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.x+l.width-m.x,!(g>p)&&e.allowCollisions&c.RIGHT&&f.allowCollisions&c.LEFT?(e.touching|=c.RIGHT,f.touching|=c.LEFT):g=0):(g=l.x-m.width-m.x,!(-g>p)&&e.allowCollisions&c.LEFT&&f.allowCollisions&c.RIGHT?(e.touching|=c.LEFT,f.touching|=c.RIGHT):g=0)}if(0!=g){var q=e.velocity.x,r=f.velocity.x;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.x=f.transform.x+g,f.velocity.x=q-r*f.elasticity):(e.transform.x=e.transform.x-g,e.velocity.x=r-q*e.elasticity);else{g*=.5,e.transform.x=e.transform.x-g,f.transform.x=f.transform.x+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.x=u+s*e.elasticity,f.velocity.x=u+t*f.elasticity}return!0}return!1},c.separateY=function(b,d){var e=b.components.getComponent("ArcadePhysics"),f=d.components.getComponent("ArcadePhysics");if(e.immovable&&f.immovable)return!1;var g=0,h=e.transform.worldY-e.last.y,i=f.transform.worldY-f.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=e.box.worldHitbox,m=f.box.worldHitbox,n=new a.Geom.Rectangle(l.x,l.y-(h>0?h:0),l.width,l.height+j),o=new a.Geom.Rectangle(m.x,m.y-(i>0?i:0),m.width,m.height+k);if(n.x+n.width>o.x&&n.xo.y&&n.yi?(g=l.y+l.height-m.y,!(g>p)&&e.allowCollisions&c.DOWN&&f.allowCollisions&c.UP?(e.touching|=c.DOWN,f.touching|=c.UP):g=0):(g=l.y-m.height-m.y,!(-g>p)&&e.allowCollisions&c.UP&&f.allowCollisions&c.DOWN?(e.touching|=c.UP,f.touching|=c.DOWN):g=0),0!=g){var q=e.velocity.y,r=f.velocity.y;if(e.immovable||f.immovable)e.immovable?f.immovable||(f.transform.y=f.transform.y+g,f.velocity.y=q-r*f.elasticity,b.active&&e.moves&&i>h&&(f.transform.x=f.transform.worldX+b.transform.worldX-e.last.x)):(e.transform.y=e.transform.y-g,e.velocity.y=r-q*e.elasticity,d.active&&f.moves&&h>i&&(e.transform.x=e.transform.worldX+d.transform.worldX-f.last.x));else{g*=.5,e.transform.y=e.transform.y-g,f.transform.y=f.transform.y+g;var s=Math.sqrt(r*r*f.mass/e.mass)*(r>0?1:-1),t=Math.sqrt(q*q*e.mass/f.mass)*(q>0?1:-1),u=.5*(s+t);s-=u,t-=u,e.velocity.y=u+s*e.elasticity,f.velocity.y=u+t*f.elasticity}return!0}}return!1},c.separateTiles=function(a,b,c){if(0==a.components.hasComponent("ArcadePhysics"))return!1;if(a.components.getComponent("ArcadePhysics").immovable)return!1;for(var d=!1,e=!1,f=0;f0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=g.transform.worldX+e.x,r=new a.Geom.Rectangle(n.x-(h>0?h:0),f.last.y+f.box.hitboxOffset.y,n.width+(h>0?h:-h),n.height),s=new a.Geom.Rectangle(q-(i>0?i:0),g.last.y+e.y,d.tileWidth+(i>0?i:-i),d.tileHeight);if(r.x+r.width>s.x&&r.xs.y&&r.yi?(l=n.x+n.width-q,!(l>m)&&f.allowCollisions&c.RIGHT&&o[p[e.index]].allowCollisions&c.LEFT?f.touching|=c.RIGHT:l=0):(l=n.x-d.tileWidth-q,!(-l>m)&&f.allowCollisions&c.LEFT&&o[p[e.index]].allowCollisions&c.RIGHT?f.touching|=c.LEFT:l=0),0!=l)){var t=f.velocity.x,u=g.velocity.x;return f.transform.x=f.transform.x-l,f.velocity.x=u-t*f.elasticity,!0}return!1},c.separateTilesY=function(b,d,e){var f=b.components.getComponent("ArcadePhysics"),g=d.components.getComponent("ArcadePhysics"),h=f.transform.worldY-f.last.y,i=g.transform.worldY-g.last.y;if(h==i)return!1;var j=h>0?h:-h,k=i>0?i:-i,l=0,m=j+k+c.OVERLAP_BIAS,n=f.box.worldHitbox,o=d.tilemap.tileTypes,p=d.tileData,q=d.transform.worldY+e.y,r=new a.Geom.Rectangle(n.x,n.y-(h>0?h:0),n.width,n.height+j),s=new a.Geom.Rectangle(g.transform.worldX+e.x,q-(i>0?i:0),d.tileWidth,d.tileHeight+k);if(r.x+r.width>s.x&&r.xs.y&&r.yi?(l=n.y+n.height-q,!(l>m)&&f.allowCollisions&c.DOWN&&o[p[e.index]].allowCollisions&c.UP?f.touching|=c.DOWN:l=0):(l=n.y-d.tileHeight-q,!(-l>m)&&f.allowCollisions&c.UP&&o[p[e.index]].allowCollisions&c.DOWN?f.touching|=c.UP:l=0),0!=l)){var t=f.velocity.y,u=g.velocity.y;return f.transform.y=f.transform.y-l,f.velocity.y=u-t*f.elasticity,!0}return!1},c.prototype.overlapsTiles=function(b,d,e){if(void 0===d&&(d=!1),void 0===e&&(e=a.Components.ArcadePhysics.ANY),this.parent.childType()!==a.TILE_LAYER)return!1;var f=this.parent.getOverlappingTiles(b,e);return f.length>0?(d&&c.separateTiles(b,this.parent,f),!0):!1},c.prototype.overlaps=function(a,b){if(void 0===b&&(b=!1),0!=a.components.hasComponent("Box")){var d=a.components.getComponent("Box"),e=d.worldHitbox.x+d.worldHitbox.width>this.box.worldHitbox.x&&d.worldHitbox.xthis.box.worldHitbox.y&&d.worldHitbox.y0?a-=d:0>a+d?a+=d:a=0),0!=a&&1e4!=e&&(a>e?a=e:-e>a&&(a=-e)),a},c.prototype.updateMotion=function(){var a,b;b=(c.computeVelocity(this.angularVelocity,this.angularAcceleration,this.angularDrag,this.maxAngular)-this.angularVelocity)/2,this.angularVelocity+=b,this.transform.rotation+=this.angularVelocity*c.updateInterval,this.angularVelocity+=b,b=(c.computeVelocity(this.velocity.x,this.acceleration.x,this.drag.x,this.maxVelocity.x)-this.velocity.x)/2,this.velocity.x+=b,a=this.velocity.x*c.updateInterval,this.velocity.x+=b,this.transform.x=this.transform.x+a,b=(c.computeVelocity(this.velocity.y,this.acceleration.y,this.drag.y,this.maxVelocity.y)-this.velocity.y)/2,this.velocity.y+=b,a=this.velocity.y*c.updateInterval,this.velocity.y+=b,this.transform.y=this.transform.y+a},c.prototype.update=function(){this.last.x=this.transform.worldX,this.last.y=this.transform.worldY,this.moves&&this.updateMotion(),this.wasTouching=this.touching,this.touching=c.NONE},c.prototype.destroy=function(){b.prototype.destroy.call(this),delete this.transform,delete this.owner,delete this._callbackContext,delete this._callbackFunction},c.prototype.objType=function(){return"ArcadePhysics"},c.collide=function(a,b,d){return void 0===d&&(d=!0),c.overlaps(a,b,d)},c.collideGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsObjectGroup(a,b,d)},c.collideGroupGroup=function(a,b,d){return void 0===d&&(d=!0),c.overlapsGroupGroup(a,b,d)},c.overlaps=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlaps(b,c)},c.overlapsObjectGroup=function(a,b,c){void 0===c&&(c=!0);var d=a.components.getComponent("ArcadePhysics");return d.overlapsGroup(b,c)},c.overlapsGroupGroup=function(b,d,e){void 0===e&&(e=!0);for(var f=!1,g=b.members,h=0;h=this._loadingList.length&&(this._queueLoading=!1,this.clearQueue(),this.onQueueComplete.dispatch()))},b.prototype._startLoadingQueue=function(){return this._loadingQueue.length<=0?(a.Log.log("Kiwi.Files.Loader: No queued files to load.","#loading"),!1):this._loadingQueue[0].loading?!1:(this._loadingQueue[0].onComplete.addOnce(this._queueFileComplete,this,1),this._loadingQueue[0].load(),!0)},b.prototype._queueFileComplete=function(b){var c=this._loadingQueue.indexOf(b);return-1===c?void a.Log.warn("Something has gone wrong? The file which executed this method doesn't exist in the loadingQueue.","#loading","#error"):(this._loadingQueue.splice(c,1),void this._startLoadingQueue())},b.prototype._startLoadingParallel=function(a){a.loading||(a.onComplete.add(this._parallelFileComplete,this,1),a.load())},b.prototype._startLoadingAllParallel=function(){for(var a=0;a=this._loadingList.length)return this._queueLoading=!1,void this.onSizeCallback.call(this.onSizeContext,this._bytesTotal);var a=this._loadingList[this._currentFileIndex];if(a.detailsReceived)this._detailsReceived();else{var b=a.loadDetails(this._detailsReceived,this);b||this._detailsReceived()}},b.prototype._detailsReceived=function(){var a=this._loadingList[this._currentFileIndex];a.detailsReceived&&(this._bytesTotal+=a.size),this._currentFileIndex++,this._calculateNextFileSize()},b.prototype.addImage=function(b,c,d,e,f,g,h){void 0===h&&(h=!0);var i={type:a.Files.File.IMAGE,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var j=b;i.key=j.key,i.url=j.url,i.metadata={width:j.width,height:j.height,offsetX:j.offsetX,offsetY:j.offsetY},j.xhrLoading&&(i.xhrLoading=j.xhrLoading),j.state&&(i.state=j.state),j.tags&&(i.tags=j.tags)}else!h&&this.game.states.current&&(i.state=this.game.states.current),i.key=b,i.url=c,i.metadata={width:d,height:e,offsetX:f,offsetY:g};var k=new a.Files.TextureFile(this.game,i);return this.addFileToQueue(k),k},b.prototype.addSpriteSheet=function(b,c,d,e,f,g,h,i,j,k,l,m){void 0===m&&(m=!0);var n={type:a.Files.File.SPRITE_SHEET,key:null,url:null,fileStore:this.game.fileStore,metadata:{}};if(a.Utils.Common.isObject(b)){var o=b;n.key=o.key,n.url=o.url,n.metadata={frameWidth:o.frameWidth,frameHeight:o.frameHeight,numCells:o.numCells,rows:o.rows,cols:o.cols,sheetOffsetX:o.sheetOffsetX,sheetOffsetY:o.sheetOffsetY,cellOffsetX:o.cellOffsetX,cellOffsetY:o.cellOffsetY},o.xhrLoading&&(n.xhrLoading=o.xhrLoading),o.state&&(n.state=o.state),o.tags&&(n.tags=o.tags)}else!m&&this.game.states.current&&(n.state=this.game.states.current),n.key=b,n.url=c,n.metadata={frameWidth:d,frameHeight:e,numCells:f,rows:g,cols:h,sheetOffsetX:i,sheetOffsetY:j,cellOffsetX:k,cellOffsetY:l};var p=new a.Files.TextureFile(this.game,n);return this.addFileToQueue(p),p},b.prototype.addTextureAtlas=function(b,c,d,e,f){void 0===f&&(f=!0);var g={type:a.Files.File.TEXTURE_ATLAS,key:b,url:c,fileStore:this.game.fileStore,metadata:{jsonID:d}},h={type:a.Files.File.JSON,key:d,url:e,fileStore:this.game.fileStore,metadata:{imageID:b}};if(!f&&this.game.states.current&&(g.state=this.game.states.current,h.state=this.game.states.current),a.Utils.Common.isObject(b)){var i=b;g.key=i.textureAtlasKey,g.url=i.textureAtlasURL,h.key=i.jsonKey,h.url=i.jsonURL,g.metadata.jsonID=h.key,h.metadata.imageID=g.key,i.state&&(g.state=i.state,h.state=i.state),i.xhrLoading&&(g.xhrLoading=i.xhrLoading),i.tags&&(h.tags=i.tags,g.tags=i.tags)}var j=new a.Files.TextureFile(this.game,g),k=new a.Files.DataFile(this.game,h);return this.addFileToQueue(j),this.addFileToQueue(k),j},b.prototype.addAudio=function(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!0);var f={type:a.Files.File.AUDIO,key:null,url:null,state:null,fileStore:this.game.fileStore};a.Utils.Common.isObject(b)?(f=b,f.fileStore=this.game.fileStore):(f.key=b,f.url=c,!d&&this.game.states.current&&(f.state=this.game.states.current));var g,h,i=0;for(g=a.Utils.Common.isString(f.url)?[f.url]:f.url;i-1?(this.name=a.substr(a.lastIndexOf("/")+1),this.path=a.substr(0,a.lastIndexOf("/")+1)):(this.path="",this.name=a),this.extension=a.substr(a.lastIndexOf(".")+1).toLowerCase()},b.prototype.objType=function(){return"File"},Object.defineProperty(b.prototype,"loadInParallel",{get:function(){return this._loadInParallel},enumerable:!0,configurable:!0}),b.prototype.load=function(b,c,d,e,f){return this.loading?void a.Log.error("Kiwi.Files.File: File loading is in progress. Cannot be told to load again.","#loading"):(a.Log.log("Kiwi.Files.File: Starting to load '"+this.name+"'","#file","#loading"),b&&this.onComplete.add(b),c&&this.onProgress.add(c),d&&(this.fileStore=d),"undefined"!=typeof e&&(this.maxLoadAttempts=e),"undefined"!=typeof f&&(this.timeOutDelay=f),this._start(),void this._load())},b.prototype._load=function(){this.attemptCounter++,this.xhrLoader("GET","text")},b.prototype.loadProgress=function(){this.onProgress.dispatch(this)},b.prototype.loadSuccess=function(){this.complete||(this.success=!0,this.hasError=!1,this._stop(),this.fileStore&&this.fileStore.addFile(this.key,this),this.onComplete.dispatch(this))},b.prototype.loadError=function(b){this.attemptCounter>=this.maxLoadAttempts?(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'. Trying Again","#loading"),this.hasError=!0,this.success=!1,this.error=b,this._stop(),this.onComplete.dispatch(this)):(a.Log.log("Kiwi.Files.File: Failed to load file '"+this.name+"'","#loading"),this._load())},b.prototype.xhrLoader=function(a,b,c){var d=this;void 0===a&&(a="GET"),void 0===b&&(b="text"),void 0===c&&(c=this.timeOutDelay),this._xhr=new XMLHttpRequest,this._xhr.open("GET",this.URL,!0),null!==c&&(this._xhr.timeout=c),this._xhr.responseType=b,this._xhr.onload=function(a){return d.xhrOnLoad(a)},this._xhr.onerror=function(a){return d.loadError(a)},this._xhr.onprogress=function(a){return d.xhrOnProgress(a)},this._xhr.onreadystatechange=function(){return function(){this.readyState=this._xhr.readyState}},this._xhr.onloadstart=function(){return function(a){this.timeStarted=a.timeStamp,this.lastProgress=a.timeStamp}},this._xhr.ontimeout=function(){return function(){this.hasTimedOut=!0}},this._xhr.send()},b.prototype.xhrOnProgress=function(a){this.bytesLoaded=parseInt(a.loaded),this.bytesTotal=parseInt(a.total),this.percentLoaded=Math.round(this.bytesLoaded/this.bytesTotal*100),this.onProgress.dispatch(this)},b.prototype.xhrOnLoad=function(a){this.status=this._xhr.status,this.statusText=this._xhr.statusText,this._xhr.response?(this._getXhrHeaderInfo(),this.buffer=this._xhr.response,this.processXhr(this._xhr.response)):this.loadError(a)},b.prototype.processXhr=function(a){this.data=a,this.loadSuccess()},b.prototype._start=function(){this.attemptCounter=0,this.loading=!0,this.timeStarted=Date.now(),this.percentLoaded=0},b.prototype._stop=function(){this.loading=!1,this.complete=!0,this.percentLoaded=100,this.timeFinished=Date.now(),this.duration=this.timeFinished-this.timeStarted},b.prototype.loadDetails=function(b,c){return void 0===b&&(b=null),void 0===c&&(c=null),this.loading?(a.Log.error("Kiwi.Files.File: Cannot get the file details whilst the file is already loading"),!1):(b&&(this.headCompleteCallback=b),c&&(this.headCompleteContext=c),this.xhrHeadRequest(),!0)},b.prototype._getXhrHeaderInfo=function(){this._xhr&&(this.status=this._xhr.status,this.statusText=this._xhr.statusText,this.type=this._xhr.getResponseHeader("Content-Type"),this.size=parseInt(this._xhr.getResponseHeader("Content-Length")),this.lastModified=this._xhr.getResponseHeader("Last-Modified"),this.ETag=this._xhr.getResponseHeader("ETag"),this.detailsReceived=!0)},b.prototype.xhrHeadRequest=function(){var a=this;this._xhr=new XMLHttpRequest,this._xhr.open("HEAD",this.fileURL,!0),null!==this.timeOutDelay&&(this._xhr.timeout=this.timeOutDelay),this._xhr.onload=function(b){return a.xhrHeadOnLoad(b)},this._xhr.onerror=function(b){return a.xhrHeadOnError(b)},this._xhr.send()},b.prototype.xhrHeadOnError=function(){this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!1)},b.prototype.xhrHeadOnLoad=function(){200===this._xhr.status?(this._getXhrHeaderInfo(),this.headCompleteCallback&&this.headCompleteCallback.call(this.headCompleteContext,!0)):this.xhrHeadOnError(null)},b.prototype.addTag=function(a){-1==this._tags.indexOf(a)&&this._tags.push(a)},b.prototype.removeTag=function(a){var b=this._tags.indexOf(a);-1!=b&&this._tags.splice(b,1)},b.prototype.hasTag=function(a){return-1==this._tags.indexOf(a)?!1:!0},Object.defineProperty(b.prototype,"isTexture",{get:function(){return a.Files.TextureFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isAudio",{get:function(){return a.Files.AudioFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isData",{get:function(){return a.Files.DataFile.prototype.objType.call(this)===this.objType()},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this.fileStore&&this.fileStore.removeFile(this.key),this.onComplete.dispose(),this.onProgress.dispose(),delete this.fileStore,delete this._xhr,delete this.data,delete this.buffer,delete this.game,delete this.error,delete this.headCompleteCallback,delete this.headCompleteContext,delete this.onComplete,delete this.onProgress,delete this.ownerState},Object.defineProperty(b.prototype,"fileName",{get:function(){return this.name},set:function(a){this.name=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"filePath",{get:function(){return this.path},set:function(a){this.path=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileExtension",{get:function(){return this.extension},set:function(a){this.extension=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileURL",{get:function(){return this.URL},set:function(a){this.URL=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileType",{get:function(){return this.type},set:function(a){this.type=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"fileSize",{get:function(){return this.size},set:function(a){this.size=a},enumerable:!0,configurable:!0}),b.prototype.getFileDetails=function(a,b,c){void 0===a&&(a=null),void 0===c&&(c=null),c&&(this.timeOutDelay=c),this.loadDetails(a,null)},b.TIMEOUT_DELAY=4e3,b.MAX_LOAD_ATTEMPTS=2,b.IMAGE=0,b.SPRITE_SHEET=1,b.TEXTURE_ATLAS=2,b.AUDIO=3,b.JSON=4,b.XML=5,b.BINARY_DATA=6,b.TEXT_DATA=7,b.UNKNOWN=8,b}();b.File=c}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._size=0,this._game=a,this._files={}}return a.prototype.objType=function(){return"FileStore"},a.prototype.boot=function(){},a.prototype.getFile=function(a){return this._files[a]},a.prototype.getFilesByTag=function(a){var b={};for(var c in this._files)this._files[c].hasTag(a)&&(b[c]=this._files[c]);return b},a.prototype.removeFilesByTag=function(a){var b=0;for(var c in this._files)this._files[c].hasTag(a)&&(this.removeFile(c),b++);return b},Object.defineProperty(a.prototype,"keys",{get:function(){var a=new Array;for(var b in this._files)a.push(b);return a},enumerable:!0,configurable:!0}),a.prototype.size=function(){return this._size},a.prototype.addFile=function(a,b){return this._files[a]?!1:(this._files[a]=b,this._size++,!0)},a.prototype.exists=function(a){return this._files[a]?!0:!1},a.prototype.removeStateFiles=function(a){for(var b in this._files)this._files[b].ownerState===a&&this.removeFile(b)},a.prototype.removeFile=function(a,b){void 0===b&&(b=!1);var c=this._files[a];return c?(this._files[a]=null,delete this._files[a],b&&this._files[a].destroy(),!0):!1},a}();a.FileStore=b}(b=a.Files||(a.Files={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){this.isReady=!1,this.container=null,this.input=null}return b.prototype.objType=function(){return"Bootstrap"},b.prototype.boot=function(a,b,c){var d=this;void 0===b&&(b=null),void 0===c&&(c=!0),this._callback=b,this._domParent=a,this._createContainer=c,"complete"===document.readyState||"interactive"===document.readyState?this.ready():(document.addEventListener("DOMContentLoaded",function(){return d.ready() +},!1),window.addEventListener("load",function(){return d.ready()},!1))},b.prototype.ready=function(){var b=this;this.isReady!==!0&&(document.body?(this.isReady=!0,this._createContainer===!0&&(""===this._domParent?(a.Log.log(" Kiwi.Game: No DOM parent specified. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer("KiwiGame"+Date.now().toString()),document.body.appendChild(this.container)):document.querySelector(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.querySelector(this._domParent),this._setupContainer()):document.getElementById(this._domParent)?(a.Log.log(" Kiwi.Game: Game being created inside '"+this._domParent+"'.","#dom"),this.container=document.getElementById(this._domParent),this._setupContainer()):(a.Log.log(" Kiwi.Game: The element '"+this._domParent+"' could not be found. Appending the game to the body.","#dom"),this.container=document.createElement("div"),this._setupContainer(this._domParent),document.body.appendChild(this.container))),null!==this._callback&&this._callback()):window.setTimeout(function(){return b.ready()},13))},b.prototype._setupContainer=function(b){void 0===b&&(b=""),b&&(this.container.id=b),this.container.style.width=a.Stage.DEFAULT_WIDTH+"px",this.container.style.height=a.Stage.DEFAULT_HEIGHT+"px",this.container.style.position="relative",this.container.style.overflow="hidden"},b}();b.Bootstrap=c}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.iOS=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.webGL=!1,this.worker=!1,this.blob=!1,this.touch=!1,this.pointerEnabled=!1,this.arora=!1,this.chrome=!1,this.epiphany=!1,this.firefox=!1,this.ie=!1,this.ieVersion=0,this.ieMobile=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.webApp=!1,this.audioData=!1,this.webaudio=!1,this.ogg=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this._checkAudio(),this._checkBrowser(),this._checkDevice(),this._checkFeatures(),this._checkOS()}return a.prototype.objType=function(){return"Device"},a.prototype._checkOS=function(){var a=navigator.userAgent;/Android/.test(a)?this.android=!0:/CrOS/.test(a)?this.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?this.iOS=!0:/Linux/.test(a)?this.linux=!0:/Mac OS/.test(a)?this.macOS=!0:/Windows Phone/.test(a)?this.windowsPhone=!0:/Windows/.test(a)&&(this.windows=!0)},a.prototype._checkFeatures=function(){"undefined"!=typeof window.Blob&&(this.blob=!0),this.canvas=!!window.CanvasRenderingContext2D,this.webGL=!!window.WebGLRenderingContext;try{this.localStorage=!!localStorage.getItem}catch(a){this.localStorage=!1}this.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),this.fileSystem=!!window.requestFileSystem,this.worker=!!window.Worker,("ontouchstart"in document.documentElement||window.navigator.msPointerEnabled&&window.navigator.msMaxTouchPoints>0||window.navigator.pointerEnabled&&window.navigator.maxTouchPoints>0)&&(this.touch=!0),(window.navigator.pointerEnabled||window.navigator.msPointerEnabled)&&(this.pointerEnabled=!0)},a.prototype._checkBrowser=function(){{var a=navigator.userAgent;navigator.appName}/Arora/.test(a)?this.arora=!0:/Chrome/.test(a)?this.chrome=!0:/Epiphany/.test(a)?this.epiphany=!0:/Firefox/.test(a)?this.firefox=!0:/Mobile Safari/.test(a)?this.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(this.ie=!0,this.ieVersion=parseInt(RegExp.$1),/IEMobile/.test(a)&&(this.ieMobile=!0)):/Trident/.test(a)?(this.ie=!0,/rv:(\d+\.\d+)\)/.test(a),this.ieVersion=parseInt(RegExp.$1)):/Midori/.test(a)?this.midori=!0:/Opera/.test(a)?this.opera=!0:/Safari/.test(a)&&(this.safari=!0),navigator.standalone&&(this.webApp=!0)},a.prototype._checkAudio=function(){this.audioData=!!window.Audio,this.webaudio=!(!window.webkitAudioContext&&!window.AudioContext);var a=document.createElement("audio"),b=!1;try{(b=!!a.canPlayType)&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.ogg=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(this.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(this.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(this.m4a=!0))}catch(c){}},a.prototype._checkDevice=function(){this.pixelRatio=window.devicePixelRatio||1,this.iPhone=-1!=navigator.userAgent.toLowerCase().indexOf("iphone"),this.iPhone4=2==this.pixelRatio&&this.iPhone,this.iPad=-1!=navigator.userAgent.toLowerCase().indexOf("ipad")},a.prototype.getAll=function(){var a="";return a=a.concat("Device\n"),a=a.concat("iPhone : "+this.iPhone+"\n"),a=a.concat("iPhone4 : "+this.iPhone4+"\n"),a=a.concat("iPad : "+this.iPad+"\n"),a=a.concat("\n"),a=a.concat("Operating System\n"),a=a.concat("iOS: "+this.iOS+"\n"),a=a.concat("Android: "+this.android+"\n"),a=a.concat("ChromeOS: "+this.chromeOS+"\n"),a=a.concat("Linux: "+this.linux+"\n"),a=a.concat("MacOS: "+this.macOS+"\n"),a=a.concat("Windows: "+this.windows+"\n"),a=a.concat("\n"),a=a.concat("Browser\n"),a=a.concat("Arora: "+this.arora+"\n"),a=a.concat("Chrome: "+this.chrome+"\n"),a=a.concat("Epiphany: "+this.epiphany+"\n"),a=a.concat("Firefox: "+this.firefox+"\n"),a=a.concat("Internet Explorer: "+this.ie+" ("+this.ieVersion+")\n"),a=a.concat("Mobile Safari: "+this.mobileSafari+"\n"),a=a.concat("Midori: "+this.midori+"\n"),a=a.concat("Opera: "+this.opera+"\n"),a=a.concat("Safari: "+this.safari+"\n"),a=a.concat("\n"),a=a.concat("Features\n"),a=a.concat("Blob: "+this.blob+"\n"),a=a.concat("Canvas: "+this.canvas+"\n"),a=a.concat("File: "+this.file+"\n"),a=a.concat("FileSystem: "+this.fileSystem+"\n"),a=a.concat("LocalStorage: "+this.localStorage+"\n"),a=a.concat("WebGL: "+this.webGL+"\n"),a=a.concat("Worker: "+this.worker+"\n"),a=a.concat("Touch: "+this.touch+"\n"),a=a.concat("\n"),a=a.concat("Audio\n"),a=a.concat("Audio Data: "+this.canvas+"\n"),a=a.concat("Web Audio: "+this.canvas+"\n"),a=a.concat("Can play OGG: "+this.canvas+"\n"),a=a.concat("Can play MP3: "+this.canvas+"\n"),a=a.concat("Can play M4A: "+this.canvas+"\n"),a=a.concat("Can play WAV: "+this.canvas+"\n")},a}();a.Device=b}(b=a.System||(a.System={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e){this.dirty=!1,this.cellIndex=0,this.name=a,this.cells=c||new Array,this.sequences=e||new Array,this.image=d,this._type=b}return b.prototype.objType=function(){return"TextureAtlas"},Object.defineProperty(b.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),b.prototype.createGLTextureWrapper=function(b,c){this.glTextureWrapper=new a.Renderers.GLTextureWrapper(b,this),c.registerTextureWrapper(b,this.glTextureWrapper)},b.prototype.enableGL=function(a,b,c){b.updateTextureSize(a,new Float32Array([this.image.width,this.image.height])),c.useTexture(a,this.glTextureWrapper),this.dirty&&this.refreshTextureGL(a)},b.prototype.refreshTextureGL=function(a){this.glTextureWrapper&&this.glTextureWrapper.refreshTexture(a),this.dirty=!1},b.prototype.readJSON=function(b){var c=JSON.parse(b);void 0!==c.name&&(this.name=c.name);for(var d=0;d=this.numCells||(b.push({x:d,y:e,w:this.cellWidth,h:this.cellHeight,hitboxes:[{x:0,y:0,w:this.cellWidth,h:this.cellHeight}]}),c.push(f++),d+=this.cellOffsetX+this.cellWidth);d=this.sheetOffsetX,e+=this.cellOffsetY+this.cellHeight}return this.sequences=new Array,this.sequences.push(new a.Animations.Sequence("default",c)),b},c}(b.TextureAtlas);b.SpriteSheet=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(b){function c(c,d,e,f,g,h){this.width=e||d.width,this.height=f||d.height,this.offsetX=g||0,this.offsetY=h||0,b.call(this,c,a.Textures.TextureAtlas.SINGLE_IMAGE,this.generateAtlasCells(),d)}return __extends(c,b),c.prototype.objType=function(){return"SingleImage"},c.prototype.generateAtlasCells=function(){return[{x:this.offsetX,y:this.offsetY,w:this.width,h:this.height,hitboxes:[{x:0,y:0,w:this.width,h:this.height}]}]},c}(b.TextureAtlas);b.SingleImage=c}(b=a.Textures||(a.Textures={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Back"},a.In=function(a){var b=1.70158;return a*a*((b+1)*a-b)},a.Out=function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},a.InOut=function(a){var b=2.5949095;return(a*=2)<1?.5*a*a*((b+1)*a-b):.5*((a-=2)*a*((b+1)*a+b)+2)},a}();a.Back=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"Bounce"},b.In=function(b){return 1-a.Animations.Tweens.Easing.Bounce.Out(1-b)},b.Out=function(a){return 1/2.75>a?7.5625*a*a:2/2.75>a?7.5625*(a-=1.5/2.75)*a+.75:2.5/2.75>a?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},b.InOut=function(b){return.5>b?.5*a.Animations.Tweens.Easing.Bounce.In(2*b):.5*a.Animations.Tweens.Easing.Bounce.Out(2*b-1)+.5},b}();b.Bounce=c}(c=b.Easing||(b.Easing={}))}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Circular"},a.In=function(a){return 1-Math.sqrt(1-a*a)},a.Out=function(a){return Math.sqrt(1- --a*a)},a.InOut=function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)},a}();a.Circular=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Cubic"},a.In=function(a){return a*a*a},a.Out=function(a){return--a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)},a}();a.Cubic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Elastic"},a.In=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),-(c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)))},a.Out=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin(2*(a-b)*Math.PI/d)+1)},a.InOut=function(a){var b,c=.1,d=.4;return 0===a?0:1===a?1:(!c||1>c?(c=1,b=d/4):b=d*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?-.5*c*Math.pow(2,10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d):c*Math.pow(2,-10*(a-=1))*Math.sin(2*(a-b)*Math.PI/d)*.5+1)},a}();a.Elastic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Exponential"},a.In=function(a){return 0===a?0:Math.pow(1024,a-1)},a.Out=function(a){return 1===a?1:1-Math.pow(2,-10*a)},a.InOut=function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(-Math.pow(2,-10*(a-1))+2)},a}();a.Exponential=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Linear"},a.None=function(a){return a},a}();a.Linear=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quadratic"},a.In=function(a){return a*a},a.Out=function(a){return a*(2-a)},a.InOut=function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)},a}();a.Quadratic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quartic"},a.In=function(a){return a*a*a*a},a.Out=function(a){return 1- --a*a*a*a},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)},a}();a.Quartic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Quintic"},a.In=function(a){return a*a*a*a*a},a.Out=function(a){return--a*a*a*a*a+1},a.InOut=function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)},a}();a.Quintic=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Sinusoidal"},a.In=function(a){return 1-Math.cos(a*Math.PI/2)},a.Out=function(a){return Math.sin(a*Math.PI/2)},a.InOut=function(a){return.5*(1-Math.cos(Math.PI*a))},a}();a.Sinusoidal=b}(b=a.Easing||(a.Easing={}))}(b=a.Tweens||(a.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(){function b(a,b){this._game=a,this._tweens=[],this.clock=b||this._game.time.clock}return b.prototype.objType=function(){return"TweenManager"},b.prototype.getAll=function(){return this._tweens},b.prototype.removeAll=function(){this._tweens.length=0},b.prototype.create=function(b){var c=new a.Animations.Tween(b,this._game);return this.validateClock(),c.manager=this,c},b.prototype.add=function(a){return a.setParent(this._game),a.manager=this,this.validateClock(),this._tweens.push(a),a},b.prototype.remove=function(a){var b=this._tweens.indexOf(a);return-1!==b&&this._tweens.splice(b,1),a},b.prototype.update=function(){var a=0,b=this._tweens.length;if(0===this._tweens.length)return!1;for(;b>a;)this._tweens[a].update(1e3*this.clock.elapsed())?a++:(this._tweens.splice(a,1),b--);return!0},b.prototype.validateClock=function(){this.clock||(this.clock=this._game.time.clock,this.clock||a.Log.error("Tween manager could not find valid clock!"))},b}();b.TweenManager=c}(c=b.Tweens||(b.Tweens={}))}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){void 0===c&&(c=null),this._game=null,this._manager=null,this._object=null,this._valuesStart={},this._valuesEnd={},this._duration=1e3,this._delayTime=0,this._startTime=null,this._easingFunction=a.Animations.Tweens.Easing.Linear.None,this._interpolationFunction=a.Utils.GameMath.linearInterpolation,this._chainedTweens=[],this._onStartCallback=null,this._onStartContext=null,this._onStartCallbackFired=!1,this._onUpdateCallback=null,this._onUpdateContext=null,this._onCompleteCallback=null,this._onCompleteCalled=!1,this._onCompleteContext=null,this.isRunning=!1,this._object=b,null!==c&&(this._game=c,this._manager=this._game.tweens),this.isRunning=!1}return b.prototype.objType=function(){return"Tween"},Object.defineProperty(b.prototype,"manager",{get:function(){return this._manager},set:function(a){this._manager=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"object",{get:function(){return this._object},set:function(a){var b,c={};this._object=a;for(b in this._valuesEnd)a[b]&&(c[b]=this._valuesEnd[b]);this._valuesEnd=c},enumerable:!0,configurable:!0}),b.prototype.to=function(a,b,c,d){return void 0===b&&(b=1e3),void 0===c&&(c=null),void 0===d&&(d=!1),this._duration=b,this._valuesEnd=a,null!==c&&(this._easingFunction=c),d===!0?this.start():this},b.prototype.start=function(){var a;if(null!==this._game&&null!==this._object){this.isRunning=!0,this._manager.add(this),this._onStartCallbackFired=!1,this._onCompleteCalled=!1,this._startTime=1e3*this._manager.clock.elapsed()+this._delayTime;for(var a in this._valuesEnd)if(null!==this._object[a]&&a in this._object){if(this._valuesEnd[a]instanceof Array){if(0===this._valuesEnd[a].length)continue;this._valuesEnd[a]=[this._object[a]].concat(this._valuesEnd[a])}this._valuesStart[a]="function"==typeof this._object[a]?this._object[a]():this._object[a]}return this}},b.prototype.stop=function(){return null!==this._manager&&this._manager.remove(this),this.isRunning=!1,this},b.prototype.setParent=function(a){this._game=a,this._manager=this._game.tweens},b.prototype.delay=function(a){return this._delayTime=a,this},b.prototype.easing=function(a){return this._easingFunction=a,this},b.prototype.interpolation=function(a){return this._interpolationFunction=a,this},b.prototype.chain=function(a){return this._chainedTweens.push(a),this},b.prototype.onStart=function(a,b){return this._onStartCallback=a,this._onStartContext=b,this},b.prototype.onUpdate=function(a,b){return this._onUpdateCallback=a,this._onUpdateContext=b,this},b.prototype.onComplete=function(a,b){return this._onCompleteCallback=a,this._onCompleteContext=b,this},b.prototype.update=function(a){if(a1?1:0>b?0:b;var c=this._easingFunction(b);for(var d in this._valuesStart){var e=this._valuesStart[d],f=this._valuesEnd[d];f instanceof Array?this._object[d]=this._interpolationFunction(f,c):"function"==typeof this._object[d]?this._object[d](e+(f-e)*c):this._object[d]=e+(f-e)*c}if(null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateContext,this._object,c),1===b){this.isRunning=!1,null!==this._onCompleteCallback&&this._onCompleteCalled===!1&&(this._onCompleteCalled=!0,this._onCompleteCallback.call(this._onCompleteContext,this._object));for(var g=0;gg){var i=e*g;f.x=(d-i)/2,d=i}else{var j=d/g;f.y=(e-j)/2,e=j}break;case a.Stage.SCALE_STRETCH:break;case a.Stage.SCALE_NONE:d=this._game.stage.width,e=this._game.stage.height}b.viewport(f.x,f.y,d,e)},c.prototype.initState=function(a){this._textureManager.clearTextures(this._game.stage.gl),this._textureManager.uploadTextureLibrary(this._game.stage.gl,a.textureLibrary)},c.prototype.endState=function(){this._textureManager.clearTextures(this._game.stage.gl),a.Log.log("Ending WebGL on State","#renderer","#webgl")},c.prototype.render=function(b){var c=this._game.stage.gl,d=this._game.stage.normalizedColor;if(c.clearColor(d.r*d.a,d.g*d.a,d.b*d.a,d.a),c.clear(c.COLOR_BUFFER_BIT),0!=this._game.states.current.members.length){this.numDrawCalls=0,this._textureManager.numTextureWrites=0,this._entityCount=0;var e=b.transform.getConcatenatedMatrix(),f=b.transform,g=vec2.create(),h=vec2.create(),i=vec2.create();vec2.set(h,f.scaleX,f.scaleY),vec2.set(g,-f.rotPointX,-f.rotPointY),vec2.set(i,e.tx,e.ty),mat3.identity(this.camMatrix),mat3.translate(this.camMatrix,this.camMatrix,i),mat3.rotate(this.camMatrix,this.camMatrix,f.rotation),mat3.scale(this.camMatrix,this.camMatrix,h),mat3.translate(this.camMatrix,this.camMatrix,g),this._game.deviceTargetOption==a.TARGET_COCOON&&this._switchBlendMode(c,this._currentBlendMode),this.collateRenderSequence(),this.collateBatches(),this.renderBatches(c,b)}},c.prototype.collateRenderSequence=function(){this._sequence=[];var a=this._game.states.current;this.collateChild(a)},c.prototype.collateChild=function(b){if(b.visible)if(b.childType()===a.GROUP)for(var c=0;c=b)return!0;return!1},b.DEFAULT_MAX_TEX_MEM_MB=1024,b}();b.GLTextureManager=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this._created=!1,this._uploaded=!1,this.items=d||a.squareVertices,this.itemSize=c||2,this.numItems=this.items.length/this.itemSize,this.createBuffer(b),e&&this.uploadBuffer(b,this.items)}return Object.defineProperty(a.prototype,"created",{get:function(){return this._created},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"uploaded",{get:function(){return this._uploaded},enumerable:!0,configurable:!0}),a.prototype.clear=function(){this.items=new Array},a.prototype.createBuffer=function(a){return this.buffer=a.createBuffer(),this._created=!0,!0},a.prototype.uploadBuffer=function(a,b){this.items=b,this.numItems=this.items.length/this.itemSize;var c=new Float32Array(this.items);return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,c,a.DYNAMIC_DRAW),this._uploaded=!0,!0},a.prototype.deleteBuffer=function(a){return a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.deleteBuffer(this.buffer),this.uploaded=!1,this.created=!1,!0},a.squareVertices=[0,0,100,0,100,100,0,100],a.squareUVs=[0,0,.1,0,.1,.1,0,.1],a.squareCols=[1,1,1,1],a}();a.GLArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){this.gl=a,this.dirty=!0,this._srcRGB=a.SRC_ALPHA,this._dstRGB=a.ONE_MINUS_SRC_ALPHA,this._srcAlpha=a.ONE,this._dstAlpha=a.ONE,this._modeRGB=a.FUNC_ADD,this._modeAlpha=a.FUNC_ADD,"undefined"==typeof b&&(b=null),b&&this.readConfig(b)}return a.prototype.readConfig=function(a){void 0!==a.mode?this.setMode(a.mode):(a.srcRGB=this.makeConstant(a.srcRGB),"undefined"!=typeof a.srcRGB&&(this._srcRGB=a.srcRGB),a.dstRGB=this.makeConstant(a.dstRGB),"undefined"!=typeof a.dstRGB&&(this._dstRGB=a.dstRGB),a.srcAlpha=this.makeConstant(a.srcAlpha),"undefined"!=typeof a.srcAlpha&&(this._srcAlpha=a.srcAlpha),a.dstAlpha=this.makeConstant(a.dstAlpha),"undefined"!=typeof a.dstAlpha&&(this._dstAlpha=a.dstAlpha),a.modeRGB=this.makeConstant(a.modeRGB),"undefined"!=typeof a.modeRGB&&(this._modeRGB=a.modeRGB),a.modeAlpha=this.makeConstant(a.modeAlpha),"undefined"!=typeof a.modeAlpha&&(this._modeAlpha=a.modeAlpha)),this.dirty=!0},a.prototype.makeConstant=function(a){if("number"==typeof a)return a;switch("string"==typeof a&&(a=a.toUpperCase()),a){case"ZERO":a=this.gl.ZERO;break;case"ONE":a=this.gl.ONE;break;case"SRC_COLOR":case"SRC_COLOUR":a=this.gl.SRC_COLOR;break;case"ONE_MINUS_SRC_COLOR":case"ONE_MINUS_SRC_COLOUR":a=this.gl.ONE_MINUS_SRC_COLOR;break;case"DST_COLOR":case"DST_COLOUR":a=this.gl.DST_COLOR;break;case"ONE_MINUS_DST_COLOR":case"ONE_MINUS_DST_COLOUR":a=this.gl.ONE_MINUS_DST_COLOR;break;case"SRC_ALPHA":a=this.gl.SRC_ALPHA;break;case"ONE_MINUS_SRC_ALPHA":a=this.gl.ONE_MINUS_SRC_ALPHA;break;case"DST_ALPHA":a=this.gl.DST_ALPHA;break;case"ONE_MINUS_DST_ALPHA":a=this.gl.ONE_MINUS_DST_ALPHA;break;case"SRC_ALPHA_SATURATE":a=this.gl.SRC_ALPHA_SATURATE;break;case"CONSTANT_COLOR":case"CONSTANT_COLOUR":a=this.gl.CONSTANT_COLOR;break;case"ONE_MINUS_CONSTANT_COLOR":case"ONE_MINUS_CONSTANT_COLOUR":a=this.gl.ONE_MINUS_CONSTANT_COLOR;break;case"CONSTANT_ALPHA":a=this.gl.CONSTANT_ALPHA;break;case"ONE_MINUS_CONSTANT_ALPHA":a=this.gl.ONE_MINUS_CONSTANT_ALPHA;break;case"FUNC_ADD":a=this.gl.FUNC_ADD;break;case"FUNC_SUBTRACT":a=this.gl.FUNC_SUBTRACT;break;case"FUNC_REVERSE_SUBTRACT":a=this.gl.FUNC_REVERSE_SUBTRACT;break;default:a=void 0}return a},a.prototype.setMode=function(a){switch(a=a.toUpperCase()){case"ADDITIVE":case"ADD":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"SUBTRACT":case"SUBTRACTIVE":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_ADD;break;case"ERASE":case"ERASER":this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_REVERSE_SUBTRACT,this._modeAlpha=this.gl.FUNC_REVERSE_SUBTRACT;break;case"BLACK":case"BLACKEN":this._srcRGB=this.gl.ZERO,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD;break;case"NORMAL":default:this._srcRGB=this.gl.SRC_ALPHA,this._dstRGB=this.gl.ONE_MINUS_SRC_ALPHA,this._srcAlpha=this.gl.ONE,this._dstAlpha=this.gl.ONE,this._modeRGB=this.gl.FUNC_ADD,this._modeAlpha=this.gl.FUNC_ADD}this.dirty=!0},a.prototype.isIdentical=function(a){return this==a?!0:this._srcRGB==a._srcRGB&&this._dstRGB==a._dstRGB&&this._srcAlpha==a._srcAlpha&&this._dstAlpha==a._dstAlpha&&this._modeRGB==a._modeRGB&&this._modeAlpha==a._modeAlpha?!0:!1},a.prototype.apply=function(a){a.blendEquationSeparate(this._modeRGB,this._modeAlpha),a.blendFuncSeparate(this._srcRGB,this._dstRGB,this._srcAlpha,this._dstAlpha),this.dirty=!1},a}();a.GLBlendMode=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(b,c,d,e){void 0===e&&(e=!0),this.indices=d||a.square,this.itemSize=c||1,this.numItems=this.indices.length/this.itemSize,e&&(this.buffer=this.init(b))}return a.prototype.clear=function(){this.indices=new Array},a.prototype.init=function(a){var b=a.createBuffer();return a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,b),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),b},a.prototype.refresh=function(a){return this.numItems=this.indices.length/this.itemSize,a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array(this.indices),a.STATIC_DRAW),this.buffer},a.square=[0,1,2,0,2,3],a}();a.GLElementArrayBuffer=b}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d){void 0===d&&(d=!1),this.loaded=!1,this._isBatchRenderer=!1,this.shaderManager=c,this._isBatchRenderer=d,this.loaded=!0,this.blendMode=new a.Renderers.GLBlendMode(b,{mode:"NORMAL"})}return b.prototype.enable=function(a,b){void 0===b&&(b=null)},b.prototype.disable=function(){},b.prototype.clear=function(){},b.prototype.draw=function(){},b.prototype.updateStageResolution=function(){},b.prototype.updateTextureSize=function(){},Object.defineProperty(b.prototype,"isBatchRenderer",{get:function(){return this._isBatchRenderer},enumerable:!0,configurable:!0}),b.RENDERER_ID="Renderer",b}();b.Renderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(c){function d(a,d,e){void 0===e&&(e=null),c.call(this,a,d,!0),this._shaderPairName="TextureAtlasShader",this._maxItems=1e3;var f=5;this._vertexBuffer=new b.GLArrayBuffer(a,f);var g=6;this._indexBuffer=new b.GLElementArrayBuffer(a,1,this._generateIndices(this._maxItems*g)),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName)}return __extends(d,c),d.prototype.enable=function(a,b){void 0===b&&(b=null),this.shaderPair=this.shaderManager.requestShader(a,this._shaderPairName,!0),a.uniform1i(this.shaderPair.uniforms.uSampler.location,0),a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b.stageResolution),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.disable=function(a){a.disableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.disableVertexAttribArray(this.shaderPair.attributes.aAlpha)},d.prototype.clear=function(a,b){this._vertexBuffer.clear(),a.uniformMatrix3fv(this.shaderPair.uniforms.uCamMatrix.location,!1,b.camMatrix)},d.prototype.draw=function(a){this._vertexBuffer.uploadBuffer(a,this._vertexBuffer.items),a.enableVertexAttribArray(this.shaderPair.attributes.aXYUV),a.vertexAttribPointer(this.shaderPair.attributes.aXYUV,4,a.FLOAT,!1,20,0),a.enableVertexAttribArray(this.shaderPair.attributes.aAlpha),a.vertexAttribPointer(this.shaderPair.attributes.aAlpha,1,a.FLOAT,!1,20,16),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this._indexBuffer.buffer),a.drawElements(a.TRIANGLES,this._vertexBuffer.items.length/20*6,a.UNSIGNED_SHORT,0)},d.prototype._generateIndices=function(a){for(var b=new Array,c=0;a>c;c++)b.push(4*c+0,4*c+1,4*c+2,4*c+0,4*c+2,4*c+3);return b},d.prototype.updateStageResolution=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uResolution.location,b)},d.prototype.updateTextureSize=function(a,b){a.uniform2fv(this.shaderPair.uniforms.uTextureSize.location,b)},d.prototype.setShaderPair=function(a){"string"==typeof a&&(this._shaderPairName=a)},d.prototype.addToBatch=function(b,c){if(!(c.alpha<=0)){var d=c.transform,e=d.getConcatenatedMatrix(),f=c.atlas.cells[c.cellIndex],g=new a.Geom.Point(0-d.rotPointX,0-d.rotPointY),h=new a.Geom.Point(f.w-d.rotPointX,0-d.rotPointY),i=new a.Geom.Point(f.w-d.rotPointX,f.h-d.rotPointY),j=new a.Geom.Point(0-d.rotPointX,f.h-d.rotPointY);g=e.transformPoint(g),h=e.transformPoint(h),i=e.transformPoint(i),j=e.transformPoint(j),this._vertexBuffer.items.push(g.x,g.y,f.x,f.y,c.alpha,h.x,h.y,f.x+f.w,f.y,c.alpha,i.x,i.y,f.x+f.w,f.y+f.h,c.alpha,j.x,j.y,f.x,f.y+f.h,c.alpha)}},d.prototype.concatBatch=function(a){this._vertexBuffer.items=this._vertexBuffer.items.concat(a)},d.RENDERER_ID="TextureAtlasRenderer",d}(b.Renderer);b.TextureAtlasRenderer=c}(b=a.Renderers||(a.Renderers={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){this.loaded=!1}return a.prototype.init=function(a){this.vertShader=this.compile(a,this.vertSource.join("\n"),a.VERTEX_SHADER),this.fragShader=this.compile(a,this.fragSource.join("\n"),a.FRAGMENT_SHADER),this.shaderProgram=this.attach(a,this.vertShader,this.fragShader),this.loaded=!0},a.prototype.attach=function(a,b,c){var d=a.createProgram();return a.attachShader(d,c),a.attachShader(d,b),a.linkProgram(d),d},a.prototype.compile=function(a,b,c){var d=a.createShader(c);return a.shaderSource(d,b),a.compileShader(d),a.getShaderParameter(d,a.COMPILE_STATUS)?d:null},a.prototype.setParam=function(a,b){this.uniforms[a].value=b,this.uniforms[a].dirty=!0},a.prototype.applyUniforms=function(a){for(var b in this.uniforms)this.applyUniform(a,b)},a.prototype.applyUniform=function(a,b){var c=this.uniforms[b];this.uniforms[b].dirty&&(a["uniform"+c.type](c.location,c.value),this.uniforms[b].dirty=!1)},a.prototype.initUniforms=function(a){for(var b in this.uniforms){var c=this.uniforms[b];c.location=a.getUniformLocation(this.shaderProgram,b),c.dirty=!0,c.value=null}},a.RENDERER_ID="ShaderPair",a}();a.ShaderPair=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.call(this),this.attributes={aXYUV:null,aAlpha:null},this.uniforms={uCamMatrix:{type:"mat3"},uResolution:{type:"2fv"},uTextureSize:{type:"2fv"},uSampler:{type:"1i"}},this.fragSource=["precision mediump float;","varying vec2 vTextureCoord;","varying float vAlpha;","uniform sampler2D uSampler;","void main(void) {","gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","gl_FragColor.a *= vAlpha;","}"],this.vertSource=["attribute vec4 aXYUV;","attribute float aAlpha;","uniform mat3 uCamMatrix;","uniform vec2 uResolution;","uniform vec2 uTextureSize;","varying vec2 vTextureCoord;","varying float vAlpha;","void main(void) {"," vec2 pos = (uCamMatrix * vec3(aXYUV.xy,1)).xy; "," gl_Position = vec4((pos / uResolution * 2.0 - 1.0) * vec2(1, -1), 0, 1);"," vTextureCoord = aXYUV.zw / uTextureSize;"," vAlpha = aAlpha;","}"]}return __extends(b,a),b.prototype.init=function(b){a.prototype.init.call(this,b),this.attributes.aXYUV=b.getAttribLocation(this.shaderProgram,"aXYUV"),this.attributes.aAlpha=b.getAttribLocation(this.shaderProgram,"aAlpha"),this.initUniforms(b)},b}(a.ShaderPair);a.TextureAtlasShader=b}(b=a.Shaders||(a.Shaders={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d){this._frameIndex=0,this._startTime=null,this._reverse=!1,this._isPlaying=!1,this._onStop=null,this._onPlay=null,this._onUpdate=null,this._onLoop=null,this._onComplete=null,this.name=a,this._sequence=b,this._speed=b.speed,this._loop=b.loop,this._parent=d,this._clock=c,this._lastFrameElapsed=this.clock.elapsed()}return b.prototype.objType=function(){return"Animation"},Object.defineProperty(b.prototype,"loop",{get:function(){return this._loop},set:function(a){this._loop=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"frameIndex",{get:function(){return this._frameIndex},set:function(a){this._validateFrame(a)&&(this._frameIndex=a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"currentCell",{get:function(){return this._sequence.cells[this.frameIndex]},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"speed",{get:function(){return this._speed},set:function(a){this._speed=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clock",{get:function(){return this._clock?this._clock:this._parent.entity.clock},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"reverse",{get:function(){return this._reverse},set:function(a){this._reverse=a},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isPlaying",{get:function(){return this._isPlaying},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onStop",{get:function(){return null==this._onStop&&(this._onStop=new a.Signal),this._onStop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onPlay",{get:function(){return null==this._onPlay&&(this._onPlay=new a.Signal),this._onPlay},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUpdate",{get:function(){return null==this._onUpdate&&(this._onUpdate=new a.Signal),this._onUpdate},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onLoop",{get:function(){return null==this._onLoop&&(this._onLoop=new a.Signal),this._onLoop},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onComplete",{get:function(){return null==this._onComplete&&(this._onComplete=new a.Signal),this._onComplete},enumerable:!0,configurable:!0}),b.prototype._start=function(a){void 0===a&&(a=null),null!==a&&(this.frameIndex=a),this._isPlaying=!0,this._startTime=this.clock.elapsed(),this._lastFrameElapsed=this.clock.elapsed(),null!==this._onPlay&&this._onPlay.dispatch()},b.prototype.play=function(){this._frameIndex>=this.length-1&&(this.frameIndex=0),this.playAt(this._frameIndex)},b.prototype.playAt=function(a){this._start(a)},b.prototype.pause=function(){this.stop()},b.prototype.resume=function(){null!==this._startTime&&(this._isPlaying=!0)},b.prototype.stop=function(){this._isPlaying&&(this._isPlaying=!1,null!==this._onStop&&this._onStop.dispatch())},b.prototype.nextFrame=function(){this._frameIndex++,this._frameIndex>=this.length&&(this.frameIndex=0)},b.prototype.prevFrame=function(){this._frameIndex--,this._frameIndex<0&&(this.frameIndex=this.length-1)},b.prototype.update=function(){var a;if(this._isPlaying&&(a=(this.clock.elapsed()-this._lastFrameElapsed)/this._speed%(this.length+1),this._reverse&&(a*=-1),a=a>0?Math.floor(a):Math.ceil(a),0!==a)){if(this._frameIndex+=a,this._lastFrameElapsed=this.clock.elapsed(),this._loop){if(this._frameIndex>=this.length)for(;this._frameIndex>=this.length;)this._frameIndex-=this.length,null!=this._onLoop&&this._onLoop.dispatch();else if(this._frameIndex<0)for(;this._frameIndex<0;)this._frameIndex+=this.length,null!=this._onLoop&&this._onLoop.dispatch()}else if(this._frameIndex<0||this._frameIndex>=this.length)return null!=this._onComplete&&this._onComplete.dispatch(),void this._parent.stop();this._parent.updateCellIndex(),null!==this._onUpdate&&this._onUpdate.dispatch()}},b.prototype._validateFrame=function(a){return a=0},Object.defineProperty(b.prototype,"length",{get:function(){return this._sequence.cells.length},enumerable:!0,configurable:!0}),b.prototype.destroy=function(){this._isPlaying=!1,delete this._clock,delete this._sequence,delete this._parent,this._onLoop&&this._onLoop.dispose(),this._onStop&&this._onStop.dispose(),this._onPlay&&this._onPlay.dispose(),this._onUpdate&&this._onUpdate.dispose(),delete this._onLoop,delete this._onStop,delete this._onPlay,delete this._onUpdate,delete this.frameIndex,delete this.loop,delete this._reverse,delete this._tick},b}();b.Animation=c}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c,d){void 0===c&&(c=.1),void 0===d&&(d=!0),this.name=a,this.cells=b,this.speed=c,this.loop=d}return a}();a.Sequence=b}(b=a.Animations||(a.Animations={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this.preventDefault=!1,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.timeUp=0,this.repeats=0,this._manager=a,this.game=this._manager.game,this.keyCode=b,c&&this.update(c)}return a.prototype.objType=function(){return"Key"},Object.defineProperty(a.prototype,"duration",{get:function(){return this.isDown&&(this.timeDown=this.game.time.now()),this.timeDownthis.game.time.now()?!0:!1},a.prototype.justReleased=function(a){return void 0===a&&(a=this._manager.justReleasedRate),this.isUp===!0&&this.timeUp+a>this.game.time.now()?!0:!1},a.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeUp=0,this.timeDown=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},a}();a.Key=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._keys=[],this.justPressedRate=200,this.justReleasedRate=200,this.game=a}return b.prototype.objType=function(){return"Keyboard"},Object.defineProperty(b.prototype,"keys",{get:function(){return this._keys},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this.onKeyUp=new a.Signal,this.onKeyDown=new a.Signal,this.onKeyDownOnce=new a.Signal,this.start()},b.prototype.update=function(){},b.prototype.start=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.addEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.addEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype.stop=function(){var b=this;this.game.deviceTargetOption===a.TARGET_BROWSER&&(document.body.removeEventListener("keydown",function(a){return b._keyPressed(a)},!1),document.body.removeEventListener("keyup",function(a){return b._keyReleased(a)},!1))},b.prototype._keyPressed=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),0==this._keys[b.keyCode].repeats&&this.onKeyDownOnce.dispatch(b.keyCode,this._keys[b.keyCode]),this.onKeyDown.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype._keyReleased=function(b){this._keys[b.keyCode]?this._keys[b.keyCode].update(b):this._keys[b.keyCode]=new a.Input.Key(this,b.keyCode,b),this.onKeyUp.dispatch(b.keyCode,this._keys[b.keyCode])},b.prototype.addKey=function(b,c){void 0===c&&(c=!1);var d=new a.Input.Key(this,b);return d.preventDefault=c,this._keys[b]=d},b.prototype.justPressed=function(a,b){return void 0===b&&(b=this.justPressedRate),this._keys[a]?this._keys[a].justPressed(b):!1},b.prototype.justReleased=function(a,b){return void 0===b&&(b=this.justReleasedRate),this._keys[a]?this._keys[a].justReleased(b):!1},b.prototype.isDown=function(a){return this._keys[a]?this._keys[a].isDown:!1},b.prototype.isUp=function(a){return this._keys[a]?this._keys[a].isUp:!1},b.prototype.reset=function(){for(var a in this._keys)this._keys[a].reset()},b}();b.Keyboard=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){}return a.prototype.objType=function(){return"Keycodes"},a.A="A".charCodeAt(0),a.B="B".charCodeAt(0),a.C="C".charCodeAt(0),a.D="D".charCodeAt(0),a.E="E".charCodeAt(0),a.F="F".charCodeAt(0),a.G="G".charCodeAt(0),a.H="H".charCodeAt(0),a.I="I".charCodeAt(0),a.J="J".charCodeAt(0),a.K="K".charCodeAt(0),a.L="L".charCodeAt(0),a.M="M".charCodeAt(0),a.N="N".charCodeAt(0),a.O="O".charCodeAt(0),a.P="P".charCodeAt(0),a.Q="Q".charCodeAt(0),a.R="R".charCodeAt(0),a.S="S".charCodeAt(0),a.T="T".charCodeAt(0),a.U="U".charCodeAt(0),a.V="V".charCodeAt(0),a.W="W".charCodeAt(0),a.X="X".charCodeAt(0),a.Y="Y".charCodeAt(0),a.Z="Z".charCodeAt(0),a.ZERO="0".charCodeAt(0),a.ONE="1".charCodeAt(0),a.TWO="2".charCodeAt(0),a.THREE="3".charCodeAt(0),a.FOUR="4".charCodeAt(0),a.FIVE="5".charCodeAt(0),a.SIX="6".charCodeAt(0),a.SEVEN="7".charCodeAt(0),a.EIGHT="8".charCodeAt(0),a.NINE="9".charCodeAt(0),a.NUMPAD_0=96,a.NUMPAD_1=97,a.NUMPAD_2=98,a.NUMPAD_3=99,a.NUMPAD_4=100,a.NUMPAD_5=101,a.NUMPAD_6=102,a.NUMPAD_7=103,a.NUMPAD_8=104,a.NUMPAD_9=105,a.NUMPAD_MULTIPLY=106,a.NUMPAD_ADD=107,a.NUMPAD_ENTER=108,a.NUMPAD_SUBTRACT=109,a.NUMPAD_DECIMAL=110,a.NUMPAD_DIVIDE=111,a.F1=112,a.F2=113,a.F3=114,a.F4=115,a.F5=116,a.F6=117,a.F7=118,a.F8=119,a.F9=120,a.F10=121,a.F11=122,a.F12=123,a.F13=124,a.F14=125,a.F15=126,a.COLON=186,a.EQUALS=187,a.UNDERSCORE=189,a.QUESTION_MARK=191,a.TILDE=192,a.OPEN_BRACKET=219,a.BACKWARD_SLASH=220,a.CLOSED_BRACKET=221,a.QUOTES=222,a.BACKSPACE=8,a.TAB=9,a.CLEAR=12,a.ENTER=13,a.SHIFT=16,a.CONTROL=17,a.ALT=18,a.CAPS_LOCK=20,a.ESC=27,a.SPACEBAR=32,a.PAGE_UP=33,a.PAGE_DOWN=34,a.END=35,a.HOME=36,a.LEFT=37,a.UP=38,a.RIGHT=39,a.DOWN=40,a.INSERT=45,a.DELETE=46,a.HELP=47,a.NUM_LOCK=144,a}();a.Keycodes=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this.game=a}return b.prototype.objType=function(){return"InputManager"},Object.defineProperty(b.prototype,"pointers",{get:function(){return this._pointers},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._pointers=[],this.mouse=new a.Input.Mouse(this.game),this.mouse.boot(),this.keyboard=new a.Input.Keyboard(this.game),this.keyboard.boot(),this.touch=new a.Input.Touch(this.game),this.touch.boot(),this.mouse.onDown.add(this._onDownEvent,this),this.mouse.onUp.add(this._onUpEvent,this),this.touch.touchDown.add(this._onDownEvent,this),this.touch.touchUp.add(this._onUpEvent,this),this._pointers=this.touch.fingers.slice(),this._pointers.push(this.mouse.cursor),this.isDown=!1,this.position=new a.Geom.Point,this.onDown=new a.Signal,this.onUp=new a.Signal},b.prototype._onDownEvent=function(a,b,c,d,e,f){this.onDown.dispatch(a,b,c,d,e,f)},b.prototype._onUpEvent=function(a,b,c,d,e,f){this.onUp.dispatch(a,b,c,d,e,f)},Object.defineProperty(b.prototype,"onPressed",{get:function(){return this.onDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onReleased",{get:function(){return this.onUp},enumerable:!0,configurable:!0}),b.prototype.update=function(){this.mouse.update(),this.keyboard.update(),this.touch.update(),this.touch.touchEnabled?this.position.setTo(this.touch.x,this.touch.y):this.position.setTo(this.mouse.x,this.mouse.y),this.isDown=this.mouse.isDown||this.touch.isDown},b.prototype.reset=function(){this.mouse.reset(),this.keyboard.reset(),this.touch.reset()},Object.defineProperty(b.prototype,"x",{get:function(){return this.position.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.position.y},enumerable:!0,configurable:!0}),b}();b.InputManager=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this._game=a}return b.prototype.objType=function(){return"Mouse"},Object.defineProperty(b.prototype,"cursor",{get:function(){return this._cursor},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this._cursor=new a.Input.MouseCursor(this._game),this._cursor.active=!0,this._cursor.id=1,this.onDown=new a.Signal,this.onUp=new a.Signal,this.onWheel=new a.Signal,this.start()},Object.defineProperty(b.prototype,"isDown",{get:function(){return this._cursor.isDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isUp",{get:function(){return this._cursor.isUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"duration",{get:function(){return this._cursor.duration},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"x",{get:function(){return this._cursor.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this._cursor.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaX",{get:function(){return this._cursor.wheelDeltaX},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"wheelDeltaY",{get:function(){return this._cursor.wheelDeltaY},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"ctrlKey",{get:function(){return this._cursor.ctrlKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"shiftKey",{get:function(){return this._cursor.shiftKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"altKey",{get:function(){return this._cursor.altKey},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"button",{get:function(){return this._cursor.button},enumerable:!0,configurable:!0}),b.prototype.update=function(){this._cursor.update()},b.prototype.start=function(){var b=this;this._game.deviceTargetOption===a.TARGET_BROWSER?a.DEVICE.ie&&a.DEVICE.ieVersion<9?(this._domElement.attachEvent("onmousedown",function(a){return b.onMouseDown(a)}),this._domElement.attachEvent("onmousemove",function(a){return b.onMouseMove(a)}),this._domElement.attachEvent("onmouseup",function(a){return b.onMouseUp(a)}),this._domElement.attachEvent("onmousewheel",function(a){return b.onMouseWheel(a)})):(this._domElement.addEventListener("mousedown",function(a){return b.onMouseDown(a)},!0),this._domElement.addEventListener("mousemove",function(a){return b.onMouseMove(a)},!0),this._domElement.addEventListener("mouseup",function(a){return b.onMouseUp(a)},!0),this._domElement.addEventListener("mousewheel",function(a){return b.onMouseWheel(a)},!0),this._domElement.addEventListener("DOMMouseScroll",function(a){return b.onMouseWheel(a)},!0)):this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("mousedown",function(a){return b.onMouseDown(a)},!0),this._game.stage.canvas.addEventListener("mousemove",function(a){return b.onMouseMove(a)},!0),this._game.stage.canvas.addEventListener("mouseup",function(a){return b.onMouseUp(a)},!0),this._game.stage.canvas.addEventListener("mousewheel",function(a){return b.onMouseWheel(a)},!0),this._game.stage.canvas.addEventListener("DOMMouseScroll",function(a){return b.onMouseWheel(a)},!0))},b.prototype.stop=function(){var b=this;this._game.deviceTargetOption===a.TARGET_BROWSER&&(this._domElement.removeEventListener("mousedown",function(a){return b.onMouseDown(a)},!1),this._domElement.removeEventListener("mousedown",this.onMouseDown,!1),this._domElement.removeEventListener("mousemove",this.onMouseMove,!1),this._domElement.removeEventListener("mouseup",this.onMouseUp,!1),this._domElement.removeEventListener("mousewheel",this.onMouseWheel,!1),this._domElement.removeEventListener("DOMMouseScroll",this.onMouseWheel,!1))},b.prototype.onMouseDown=function(a){this._cursor.start(a),this.onDown.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseMove=function(a){a.preventDefault(),this._cursor.move(a) +},b.prototype.onMouseUp=function(a){this._cursor.stop(a),this.onUp.dispatch(this._cursor.x,this._cursor.y,this._cursor.timeDown,this._cursor.timeUp,this.duration,this._cursor)},b.prototype.onMouseWheel=function(a){this._cursor.wheel(a),this.onWheel.dispatch(this._cursor.wheelDeltaX,this._cursor.wheelDeltaY,this._cursor)},b.prototype.justPressed=function(a){return void 0===a&&(a=this._cursor.justPressedRate),this._cursor.justPressed(a)},b.prototype.justReleased=function(a){return void 0===a&&(a=this._cursor.justReleasedRate),this._cursor.justReleased(a)},b.prototype.reset=function(){this._cursor.reset()},b.LEFT_BUTTON=0,b.MIDDLE_BUTTON=1,b.RIGHT_BUTTON=2,b}();b.Mouse=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._domElement=null,this.isDown=!1,this.isUp=!0,this._maxPointers=10,this._game=a}return b.prototype.objType=function(){return"TouchManager"},Object.defineProperty(b.prototype,"fingers",{get:function(){return this._fingers},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onDown",{get:function(){return this.touchDown},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onUp",{get:function(){return this.touchUp},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"onCancel",{get:function(){return this.touchCancel},enumerable:!0,configurable:!0}),b.prototype.boot=function(){this._domElement=this._game.stage.container,this.finger1=new a.Input.Finger(this._game),this.finger2=new a.Input.Finger(this._game),this.finger3=new a.Input.Finger(this._game),this.finger4=new a.Input.Finger(this._game),this.finger5=new a.Input.Finger(this._game),this.finger6=new a.Input.Finger(this._game),this.finger7=new a.Input.Finger(this._game),this.finger8=new a.Input.Finger(this._game),this.finger9=new a.Input.Finger(this._game),this.finger10=new a.Input.Finger(this._game),this._fingers=[this.finger1,this.finger2,this.finger3,this.finger4,this.finger5,this.finger6,this.finger7,this.finger8,this.finger9,this.finger10],this.latestFinger=this.finger1,this.touchDown=new a.Signal,this.touchUp=new a.Signal,this.touchCancel=new a.Signal,this.start()},b.prototype.start=function(){var b=this;if(a.DEVICE.touch)if(this.touchEnabled=!0,this._game.deviceTargetOption===a.TARGET_BROWSER)if(a.DEVICE.pointerEnabled){var c="pointerup",d="pointerdown",e="pointerenter",f="pointerleave",g="pointercancel",h="pointermove";if(window.navigator.msPointerEnabled)var c="MSPointerUp",d="MSPointerDown",e="MSPointerEnter",f="MSPointerLeave",g="MSPointerCancel",h="MSPointerMove";this._domElement.addEventListener(c,function(a){return b.onPointerStart(a)},!1),this._domElement.addEventListener(d,function(a){return b.onPointerEnd(a)},!1),this._domElement.addEventListener(e,function(a){return b.onPointerEnter(a)},!1),this._domElement.addEventListener(f,function(a){return b.onPointerLeave(a)},!1),this._domElement.addEventListener(g,function(a){return b.onPointerCancel(a)},!1),this._domElement.addEventListener(h,function(a){return b.onPointerMove(a)},!1)}else this._domElement.addEventListener("touchstart",function(a){return b.onTouchStart(a)},!1),this._domElement.addEventListener("touchmove",function(a){return b.onTouchMove(a)},!1),this._domElement.addEventListener("touchend",function(a){return b.onTouchEnd(a)},!1),this._domElement.addEventListener("touchenter",function(a){return b.onTouchEnter(a)},!1),this._domElement.addEventListener("touchleave",function(a){return b.onTouchLeave(a)},!1),this._domElement.addEventListener("touchcancel",function(a){return b.onTouchCancel(a)},!1),document.addEventListener("touchmove",function(a){return b.consumeTouchMove(a)},!1);else this._game.deviceTargetOption===a.TARGET_COCOON&&(this._game.stage.canvas.addEventListener("touchstart",function(a){return b.onTouchStart(a)},!1),this._game.stage.canvas.addEventListener("touchmove",function(a){return b.onTouchMove(a)},!1),this._game.stage.canvas.addEventListener("touchend",function(a){return b.onTouchEnd(a)},!1),this._game.stage.canvas.addEventListener("touchenter",function(a){return b.onTouchEnter(a)},!1),this._game.stage.canvas.addEventListener("touchleave",function(a){return b.onTouchLeave(a)},!1),this._game.stage.canvas.addEventListener("touchcancel",function(a){return b.onTouchCancel(a)},!1));else this.touchEnabled=!1},b.prototype.consumeTouchMove=function(a){a.preventDefault()},Object.defineProperty(b.prototype,"x",{get:function(){return this.latestFinger.x},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"y",{get:function(){return this.latestFinger.y},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"maximumPointers",{get:function(){return this._maxPointers},set:function(a){0>a&&(a=1),a>this._fingers.length&&(a=this._fingers.length),this._maxPointers=a},enumerable:!0,configurable:!0}),b.prototype._registerFinger=function(a,b){for(var c=0;cthis._game.time.now()?!0:!1},b.prototype.justReleased=function(a){return void 0===a&&(a=this.justReleasedRate),this.isUp===!0&&this.timeUp+a>this._game.time.now()?!0:!1},Object.defineProperty(b.prototype,"pressed",{get:function(){return this.timeDown>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"released",{get:function(){return this.timeUp>=this._game.time.now()-this._game.time.delta()},enumerable:!0,configurable:!0}),b.prototype.reset=function(){this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.duration=0,this.frameDuration=0},b.prototype.update=function(){this.isDown===!0&&(this.frameDuration++,this.duration=this._game.time.now()-this.timeDown)},b}();b.Pointer=c}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(){a.apply(this,arguments),this.wheelDeltaX=0,this.wheelDeltaY=0,this.preventDown=!0,this.preventUp=!0,this.preventWheel=!0}return __extends(b,a),b.prototype.objType=function(){return"MouseCursor"},b.prototype.start=function(b){this.preventDown&&b.preventDefault(),this.ctrlKey=b.ctrlKey,this.shiftKey=b.shiftKey,this.altKey=b.altKey,this.button=b.button,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.preventUp&&b.preventDefault(),this.move(b),a.prototype.stop.call(this,b)},b.prototype.wheel=function(a){this.preventWheel&&a.preventDefault(),this.wheelDeltaX=a.wheelDeltaX?a.wheelDeltaX:a.deltaX,this.wheelDeltaY=a.wheelDeltaY?a.wheelDeltaY:a.deltaY},b}(a.Pointer);a.MouseCursor=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(a){function b(b){a.call(this,b),this.circle.diameter=44}return __extends(b,a),b.prototype.objType=function(){return"Finger"},b.prototype.start=function(b){this.active=!0,a.prototype.start.call(this,b)},b.prototype.stop=function(b){this.active=!1,a.prototype.stop.call(this,b)},b.prototype.leave=function(a){this.withinGame=!1,this.move(a)},b.prototype.reset=function(){this.active=!1,a.prototype.reset.call(this)},b}(a.Pointer);a.Finger=b}(b=a.Input||(a.Input={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c,d){this.cx=0,this.cy=0,this.halfWidth=0,this.halfHeight=0,this.cx=a||0,this.cy=b||0,this.halfWidth=c/2||0,this.halfHeight=d/2||0}return b.prototype.objType=function(){return"AABB"},Object.defineProperty(b.prototype,"height",{get:function(){return 2*this.halfHeight},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"width",{get:function(){return 2*this.halfWidth},enumerable:!0,configurable:!0}),b.prototype.draw=function(a){return a.beginPath(),a.moveTo(this.cx-this.halfWidth,this.cy),a.lineTo(this.cx+this.halfWidth,this.cy),a.moveTo(this.cx,this.cy-this.halfHeight),a.lineTo(this.cx,this.cy+this.halfHeight),a.stroke(),this},b.prototype.setPosition=function(a,b){return this.cx=a,this.cy=b,this},b.prototype.setPositionPoint=function(a){return this.cx=a.x,this.cy=a.y,this},b.prototype.toRect=function(){return new a.Rectangle(this.cx-this.halfWidth,this.cy-this.halfHeight,2*this.halfWidth,2*this.halfHeight)},b.prototype.fromRect=function(a){return this.halfWidth=a.width/2,this.halfHeight=a.height/2,this.cx=a.x+this.halfWidth,this.cy=a.y+this.halfHeight,this},b}();a.AABB=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function b(a,b,c){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),this._diameter=0,this._radius=0,this.x=0,this.y=0,this.setTo(a,b,c)}return b.prototype.objType=function(){return"Circle"},Object.defineProperty(b.prototype,"diameter",{get:function(){return this._diameter},set:function(a){a>0&&(this._diameter=a,this._radius=.5*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"radius",{get:function(){return this._radius},set:function(a){a>0&&(this._radius=a,this._diameter=2*a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"circumference",{get:function(){return 2*Math.PI*this._radius},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){isNaN(a)||(athis.x?this.radius=a-this.x:(this._radius=0,this._diameter=0))},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a&&!isNaN(a)&&(a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a)},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"area",{get:function(){return this._radius>0?Math.PI*this._radius*this._radius:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"isEmpty",{get:function(){return this._diameter<=0?!0:!1},enumerable:!0,configurable:!0}),b.prototype.clone=function(a){return void 0===a&&(a=new b),a.setTo(this.x,this.y,this._diameter)},b.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.diameter)},b.prototype.copyTo=function(a){return a.copyFrom(this)},b.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},b.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.diameter===a.diameter?!0:!1},b.prototype.intersects=function(a){return this.distanceTo(a,!1)=g)==!0||(d.y<=h&&d.y>=i)==!0)&&(d.result=!0)}return d},b.lineToRawSegment=function(b,c,d,e,f,g){void 0===g&&(g=new a.IntersectResult),g.result=!1;var h=(b.x1-b.x2)*(d-f)-(b.y1-b.y2)*(c-e);if(0!==h){g.x=((b.x1*b.y2-b.y1*b.x2)*(c-e)-(b.x1-b.x2)*(c*f-d*e))/h,g.y=((b.x1*b.y2-b.y1*b.x2)*(d-f)-(b.y1-b.y2)*(c*f-d*e))/h;var i=Math.max(c,e),j=Math.min(c,e),k=Math.max(d,f),l=Math.min(d,f);g.x<=i&&g.x>=j&&g.y<=k&&g.y>=l&&(g.result=!0)}return g},b.lineSegmentToRawSegment=function(c,d,e,f,g,h){void 0===h&&(h=new a.IntersectResult),h=b.lineToRawSegment(c,d,e,f,g,h);var i=Math.max(c.x1,c.x2),j=Math.min(c.x1,c.x2),k=Math.max(c.y1,c.y2),l=Math.min(c.y1,c.y2);return h.x<=i&&h.x>=j&&h.y<=k&&h.y>=l?h:(h.result=!1,h)},b.lineToRay=function(b,c,d){void 0===d&&(d=new a.IntersectResult),d.result=!1;var e=(b.x1-b.x2)*(c.y1-c.y2)-(b.y1-b.y2)*(c.x1-c.x2);return 0!==e&&(d.x=((b.x1*b.y2-b.y1*b.x2)*(c.x1-c.x2)-(b.x1-b.x2)*(c.x1*c.y2-c.y1*c.x2))/e,d.y=((b.x1*b.y2-b.y1*b.x2)*(c.y1-c.y2)-(b.y1-b.y2)*(c.x1*c.y2-c.y1*c.x2))/e,d.result=!0,!(c.x1>=c.x2)&&d.x=c.y2)&&d.y=Math.min(c.x1,c.x2)&&e.x<=Math.max(c.x1,c.x2)&&e.y>=Math.min(c.y1,c.y2)&&e.y<=Math.max(c.y1,c.y2)||(e.result=!1)),e},b.lineSegmentToRay=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,b.lineToRay(c,d,e),e.result===!0&&(e.x>=Math.min(c.x1,c.x2)&&e.x<=Math.max(c.x1,c.x2)&&e.y>=Math.min(c.y1,c.y2)&&e.y<=Math.max(c.y1,c.y2)||(e.result=!1)),e},b.lineSegmentToCircle=function(c,d,e){void 0===e&&(e=new a.IntersectResult),e.result=!1;var f=c.perp(d.x,d.y);if(f.length<=d.radius){var g=Math.max(c.x1,c.x2),h=Math.min(c.x1,c.x2),i=Math.max(c.y1,c.y2),j=Math.min(c.y1,c.y2);f.x2<=g&&f.x2>=h&&f.y2<=i&&f.y2>=j?e.result=!0:(b.circleContainsPoint(d,{x:c.x1,y:c.y1}).result||b.circleContainsPoint(d,{x:c.x2,y:c.y2}).result)&&(e.result=!0)}return e},b.lineSegmentToRectangle=function(c,d,e){if(void 0===e&&(e=new a.IntersectResult),e.result=!1,d.contains(c.x1,c.y1)&&d.contains(c.x2,c.y2))e.x=(c.x1+c.x2)/2,e.y=(c.y1+c.y2)/2,e.result=!0;else{if(b.lineSegmentToRawSegment(c,d.x,d.y,d.right,d.y,e),e.result===!0)return e;if(b.lineSegmentToRawSegment(c,d.x,d.y,d.x,d.bottom,e),e.result===!0)return e;if(b.lineSegmentToRawSegment(c,d.x,d.bottom,d.right,d.bottom,e),e.result===!0)return e;b.lineSegmentToRawSegment(c,d.right,d.y,d.right,d.bottom,e)}return e},b.rayToRectangle=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,b.lineToRectangle(c,d,e),e},b.rayToLineSegment=function(b,c,d,e,f,g,h,i,j){void 0===j&&(j=new a.IntersectResult),j.result=!1;var k,l,m;return(e-c)/(d-b)!=(i-g)/(h-f)&&(m=(d-b)*(i-g)-(e-c)*(h-f),0!=m&&(k=((c-g)*(h-f)-(b-f)*(i-g))/m,l=((c-g)*(d-b)-(b-f)*(e-c))/m,k>=0&&l>=0&&1>=l&&(j.result=!0,j.x=b+k*(d-b),c+k*(e-c)))),j},b.circleToCircle=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,e.result=(c.radius+d.radius)*(c.radius+d.radius)>=b.distanceSquared(c.x,c.y,d.x,d.y),e},b.circleToRectangle=function(b,c,d){void 0===d&&(d=new a.IntersectResult),d.result=!1;var e,f,g,h,i,j,k,l;return i=c.width/2,g=Math.abs(b.x-c.x-i),k=b.radius+i,g>k?(d.result=!1,d):(j=c.height/2,h=Math.abs(b.y-c.y-j),l=b.radius+j,h>l?(d.result=!1,d):i>=g||h<=c.height/2?(d.result=!0,d):(e=g-i,f=h-j,d.result=e*e+f*f<=b.radius*b.radius,d))},b.circleContainsPoint=function(c,d,e){return void 0===e&&(e=new a.IntersectResult),e.result=!1,e.result=c.radius*c.radius>=b.distanceSquared(c.x,c.y,d.x,d.y),e},b.pointToRectangle=function(b,c,d){return void 0===d&&(d=new a.IntersectResult),d.result=!1,d.setTo(b.x,b.y),d.result=c.containsPoint(b),d},b.rectangleToRectangle=function(b,c,d){void 0===d&&(d=new a.IntersectResult),d.result=!1;var e=Math.max(b.x,c.x),f=Math.min(b.right,c.right),g=Math.max(b.y,c.y),h=Math.min(b.bottom,c.bottom);d.setTo(e,g,f-e,h-g,f-e,h-g);var i=d.x+.5*d.width,j=d.y+.5*d.height;return i>b.x&&ib.y&&j=c&&d>=a&&b>=e&&f>=b?!0:!1},b.prototype.intersectLineLine=function(b){return a.Geom.Intersect.lineToLine(this,b)},b.prototype.perp=function(a,c,d){void 0===d&&(d=new b);var e;if(this.y1===this.y2)return d.setTo(a,c,a,this.y1),d;if(this.x1===this.x2)return d.setTo(a,c,this.x1,c),d;var f=c-this.perpSlope*a;return e=this.intersectLineLine(0!==a?{x1:a,y1:c,x2:0,y2:f}:{x1:a,y1:c,x2:1,y2:f+this.perpSlope}),d.setTo(a,c,e.x,e.y),d},b.prototype.toString=function(){return"[{Line (x1="+this.x1+" y1="+this.y1+" x2="+this.x2+" y2="+this.y2+")}]"},b}();b.Line=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this.setTo(a,b,c,d,e,f)}return b.prototype.objType=function(){return"Matrix"},b.prototype.setTo=function(a,b,c,d,e,f){return void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),this.a=a,this.b=b,this.c=c,this.d=d,this.tx=e,this.ty=f,this},b.prototype.setFromTransform=function(a,b,c,d,e){this.identity();var f=Math.cos(e),g=Math.sin(e);return this.append(f*c,g*c,-g*d,f*d,a,b),this},b.prototype.setFromOffsetTransform=function(a,b,c,d,e,f,g){this.identity();var h=Math.cos(e),i=Math.sin(e);return this.append(h*c,i*c,-i*d,h*d,a+f,b+g),this},b.prototype.prepend=function(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0);var g=this.tx,h=this.a,i=this.c;return this.a=h*a+this.b*c,this.b=h*b+this.b*d,this.c=i*a+this.d*c,this.d=i*b+this.d*d,this.tx=g*a+this.ty*c+e,this.ty=g*b+this.ty*d+f,this},b.prototype.prependMatrix=function(a){var b=this.tx,c=this.a,d=this.c;return this.a=c*a.a+this.b*a.c,this.b=c*a.b+this.b*a.d,this.c=d*a.a+this.d*a.c,this.d=d*a.b+this.d*a.d,this.tx=b*a.a+this.ty*a.c+a.tx,this.ty=b*a.b+this.ty*a.d+a.ty,this},b.prototype.append=function(a,b,c,d,e,f){void 0===a&&(a=1),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0);var g=this.a,h=this.b,i=this.c,j=this.d;return this.a=a*g+b*i,this.b=a*h+b*j,this.c=c*g+d*i,this.d=c*h+d*j,this.tx=e*g+f*i+this.tx,this.ty=e*h+f*j+this.ty,this},b.prototype.appendMatrix=function(a){var b=this.a,c=this.b,d=this.c,e=this.d;return this.a=a.a*b+a.b*d,this.b=a.a*c+a.b*e,this.c=a.c*b+a.d*d,this.d=a.c*c+a.d*e,this.tx=a.tx*b+a.ty*d+this.tx,this.ty=a.tx*c+a.ty*e+this.ty,this},b.prototype.setPosition=function(a,b){return this.tx=a,this.ty=b,this},b.prototype.setPositionPoint=function(a){return this.tx=a.x,this.ty=a.y,this},b.prototype.getPosition=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this.tx,this.ty)},b.prototype.identity=function(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this},b.prototype.rotate=function(a){var b=Math.cos(a),c=Math.sin(a),d=this.a,e=this.c,f=this.tx;return this.a=d*b-this.b*c,this.b=d*c+this.b*b,this.c=e*b-this.d*c,this.d=e*c+this.d*b,this.tx=f*b-this.ty*c,this.ty=f*c+this.ty*b,this},b.prototype.translate=function(a,b){return this.tx+=a,this.ty+=b,this},b.prototype.scale=function(a,b){return this.a*=a,this.d*=b,this},b.prototype.transformPoint=function(a){var b=a.x,c=a.y;return a.x=this.a*b+this.c*c+this.tx,a.y=this.b*b+this.d*c+this.ty,a},b.prototype.invert=function(){var a=this.a,b=this.b,c=this.c,d=this.d,e=this.tx,f=a*d-b*c;return this.a=d/f,this.b=-b/f,this.c=-c/f,this.d=a/f,this.tx=(c*this.ty-d*e)/f,this.ty=-(a*this.ty-b*e)/f,this},b.prototype.copyFrom=function(a){return this.a=a.a,this.b=a.b,this.c=a.c,this.d=a.d,this.tx=a.tx,this.ty=a.ty,this},b.prototype.copyTo=function(a){return a.a=this.a,a.b=this.b,a.c=this.c,a.d=this.d,a.tx=this.tx,a.ty=this.ty,this},b.prototype.clone=function(){return new a.Geom.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty)},Object.defineProperty(b.prototype,"toString",{get:function(){return"[{Matrix (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")}]"},enumerable:!0,configurable:!0}),b}();b.Matrix=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return a.prototype.objType=function(){return"Point"},a.prototype.polar=function(a,b){return this.x=a*Math.cos(b),this.y=a*Math.sin(b),this},a.prototype.add=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x+b.x,this.y+b.y)},a.prototype.addTo=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(this.x+a,this.y+b)},a.prototype.subtractFrom=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(this.x-a,this.y-b)},a.prototype.invert=function(){return this.setTo(this.y,this.x)},a.prototype.clamp=function(a,b){return this.clampX(a,b),this.clampY(a,b),this},a.prototype.clampX=function(a,b){return this.x=Math.max(Math.min(this.x,b),a),this +},a.prototype.clampY=function(a,b){return this.x=Math.max(Math.min(this.x,b),a),this.y=Math.max(Math.min(this.y,b),a),this},a.prototype.clone=function(b){return void 0===b&&(b=new a),b.setTo(this.x,this.y)},a.prototype.copyFrom=function(a){return this.setTo(a.x,a.y)},a.prototype.copyTo=function(a){return a.setTo(this.x,this.y)},a.prototype.angleTo=function(a){return Math.atan2(a.y-this.y,a.x-this.x)},a.prototype.angleToXY=function(a,b){return Math.atan2(b-this.y,a-this.x)},a.prototype.distanceTo=function(a,b){void 0===b&&(b=!1);var c=this.x-a.x,d=this.y-a.y;return b===!0?Math.round(Math.sqrt(c*c+d*d)):Math.sqrt(c*c+d*d)},a.prototype.distanceToXY=function(a,b,c){void 0===c&&(c=!1);var d=this.x-a,e=this.y-b;return c===!0?Math.round(Math.sqrt(d*d+e*e)):Math.sqrt(d*d+e*e)},a.distanceBetween=function(a,b,c){void 0===c&&(c=!1);var d=a.x-b.x,e=a.y-b.y;return c===!0?Math.round(Math.sqrt(d*d+e*e)):Math.sqrt(d*d+e*e)},a.polar=function(b,c){return new a(b*Math.cos(c),b*Math.sin(c))},a.prototype.distanceCompare=function(a,b){return this.distanceTo(a)>=b?!0:!1},a.prototype.equals=function(a){return this.x===a.x&&this.y===a.y?!0:!1},a.interpolate=function(b,c,d){var e=c.x-b.x,f=c.y-b.y;return new a(c.x-e*d,c.y-f*d)},a.prototype.offset=function(a,b){return this.x+=a,this.y+=b,this},a.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},a.prototype.subtract=function(b,c){return void 0===c&&(c=new a),c.setTo(this.x-b.x,this.y-b.y)},a.prototype.getCSS=function(){return this.x+"px "+this.y+"px"},a.prototype.toString=function(){return"[{Point (x="+this.x+" y="+this.y+")}]"},a}();a.Point=b}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b,c,d){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.x=0,this.y=0,this.width=0,this.height=0,this.setTo(a,b,c,d)}return c.prototype.objType=function(){return"Rectangle"},Object.defineProperty(c.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a&&(this.height=a=this.x&&a<=this.right&&b>=this.y&&b<=this.bottom?!0:!1},c.prototype.containsPoint=function(a){return this.contains(a.x,a.y)},c.prototype.containsRect=function(a){return a.volume>this.volume?!1:a.x>=this.x&&a.y>=this.y&&a.right<=this.right&&a.bottom<=this.bottom?!0:!1},c.prototype.copyFrom=function(a){return this.setTo(a.x,a.y,a.width,a.height)},c.prototype.copyTo=function(a){return void 0===a&&(a=new c),a.copyFrom(this)},c.prototype.equals=function(a){return this.x===a.x&&this.y===a.y&&this.width===a.width&&this.height===a.height?!0:!1},c.prototype.inflate=function(a,b){return isNaN(a)||isNaN(b)||(this.x-=a,this.width+=2*a,this.y-=b,this.height+=2*b),this},c.prototype.inflatePoint=function(a){return this.inflate(a.x,a.y)},c.prototype.intersection=function(a,b){return void 0===b&&(b=new c),this.intersects(a)===!0&&(b.x=Math.max(a.x,this.x),b.y=Math.max(a.y,this.y),b.width=Math.min(a.right,this.right)-b.x,b.height=Math.min(a.bottom,this.bottom)-b.y),b},c.prototype.intersects=function(a){return a.x>this.right-1?!1:a.right-1this.bottom-1?!1:!0},c.prototype.overlap=function(a){var b={top:!1,bottom:!1,left:!1,right:!1,contains:!1,contained:!1},c=this.intersection(a);return c.isEmpty?b:(this.containsRect(a)&&(b.contains=!0),a.containsRect(this)&&(b.contained=!0),this.topa.bottom&&(b.bottom=!0),this.lefta.right&&(b.right=!0),b)},c.prototype.isEmpty=function(){return this.width<1||this.height<1?!0:!1},c.prototype.offset=function(a,b){return isNaN(a)||isNaN(b)||(this.x+=a,this.y+=b),this},c.prototype.offsetPoint=function(a){return this.offset(a.x,a.y)},c.prototype.setEmpty=function(){return this.setTo(0,0,0,0)},c.prototype.setTo=function(a,b,c,d){return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)||(this.x=a,this.y=b,c>=0&&(this.width=c),d>=0&&(this.height=d)),this},c.prototype.union=function(a,b){return void 0===b&&(b=new c),b.setTo(Math.min(a.x,this.x),Math.min(a.y,this.y),Math.max(a.right,this.right),Math.max(a.bottom,this.bottom))},c.prototype.scale=function(b,c,d){var e=new a.Geom.Transform;e.scaleX=b,e.scaleY=c,e.x=d.x,e.y=d.y;var f=this.topLeft;return e.transformPoint(f),this.topLeft=f,this.width*=b,this.height*=c,this},c.prototype.toString=function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" isEmpty="+this.isEmpty()+")}]"},c}();b.Rectangle=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,c,d,e,f,g,h){void 0===a&&(a=0),void 0===c&&(c=0),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),this._x=0,this._y=0,this._scaleX=1,this._scaleY=1,this._rotation=0,this._rotPointX=0,this._rotPointY=0,this._parent=null,this._locked=!1,this._ignoreParent=!1,this.setTransform(a,c,d,e,f,g,h),this._matrix=new b.Matrix,this._matrix.setFromOffsetTransform(this._x,this._y,this._scaleX,this._scaleY,this._rotation,this._rotPointX,this._rotPointY),this._cachedConcatenatedMatrix=this.getConcatenatedMatrix(),this._concatMatrix=new b.Matrix}return c.prototype.objType=function(){return"Transform"},Object.defineProperty(c.prototype,"x",{get:function(){return this._x},set:function(a){this._x=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"y",{get:function(){return this._y},set:function(a){this._y=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleX",{get:function(){return this._scaleX},set:function(a){this._scaleX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"scaleY",{get:function(){return this._scaleY},set:function(a){this._scaleY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotation",{get:function(){return this._rotation},set:function(a){this._rotation=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointX",{get:function(){return this._rotPointX},set:function(a){this._rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rotPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointX",{get:function(){return this.rotPointX},set:function(a){this.rotPointX=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"anchorPointY",{get:function(){return this._rotPointY},set:function(a){this._rotPointY=a},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"matrix",{get:function(){return this._matrix},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldX",{get:function(){return this.getConcatenatedMatrix().tx-this._rotPointX},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"worldY",{get:function(){return this.getConcatenatedMatrix().ty-this._rotPointY},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"parent",{get:function(){return this._parent},set:function(a){this.checkAncestor(a)||(this._parent=a)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"locked",{get:function(){return this._locked},set:function(a){this._locked=a,this._locked&&this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"ignoreParent",{get:function(){return this._ignoreParent},set:function(a){this._ignoreParent=a},enumerable:!0,configurable:!0}),c.prototype.setPosition=function(a,b){return this._x=a,this._y=b,this},c.prototype.setPositionFromPoint=function(a){return this._x=a.x,this._y=a.y,this},c.prototype.translatePositionFromPoint=function(a){return this._x+=a.x,this._y+=a.y,this},c.prototype.getPositionPoint=function(b){return void 0===b&&(b=new a.Geom.Point),b.setTo(this._x,this._y)},Object.defineProperty(c.prototype,"scale",{set:function(a){this._scaleX=a,this._scaleY=a},enumerable:!0,configurable:!0}),c.prototype.setTransform=function(a,b,c,d,e,f,g){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=1),void 0===d&&(d=1),void 0===e&&(e=0),void 0===f&&(f=0),void 0===g&&(g=0),this._x=a,this._y=b,this._scaleX=c,this._scaleY=d,this._rotation=e,this._rotPointX=f,this._rotPointY=g,this},c.prototype.getParentMatrix=function(){return this._parent?this._parent.getConcatenatedMatrix():null},c.prototype.getConcatenatedMatrix=function(){var a;return this._locked||(this._parent?this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX-this._parent.anchorPointX,this.anchorPointY-this._parent.anchorPointY):this._matrix.setFromOffsetTransform(this.x,this.y,this.scaleX,this.scaleY,this.rotation,this.anchorPointX,this.anchorPointY)),!this._ignoreParent&&(a=this.getParentMatrix())?(this._concatMatrix.copyFrom(this._matrix),this._concatMatrix.prependMatrix(a),this._concatMatrix):this._matrix},c.prototype.transformPoint=function(a){var b=this.getConcatenatedMatrix();return b.transformPoint(a)},c.prototype.copyFrom=function(a){return this.setTransform(a.x,a.y,a.scaleX,a.scaleY,a.rotation,a.rotPointX,a.rotPointY),this.parent=a.parent,this._matrix=a.matrix.clone(),this},c.prototype.copyTo=function(a){return a.copyFrom(this),this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.copyFrom(this),a},c.prototype.checkAncestor=function(){return!1},Object.defineProperty(c.prototype,"toString",{get:function(){return"[{Transform (x="+this._x+" y="+this._y+" scaleX="+this._scaleX+" scaleY="+this._scaleY+" rotation="+this._rotation+" regX="+this._rotPointX+" regY="+this.rotPointY+" matrix="+this._matrix+")}]"},enumerable:!0,configurable:!0}),c}();b.Transform=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function c(a,b){void 0===a&&(a=0),void 0===b&&(b=0),this.setTo(a,b)}return c.prototype.objType=function(){return"Vector2"},c.fromAngle=function(a){return new c(Math.cos(a),Math.sin(a))},c.randomRadius=function(a){return new c(2*Math.random()-1,2*Math.random()-1).multiplyScalar(a)},c.fromPoint=function(a){return new c(a.x,a.y)},c.prototype.add=function(a){return new c(this.x+a.x,this.y+a.y)},c.prototype.addX=function(a){return new c(this.x+a.x,this.y)},c.prototype.addY=function(a){return new c(this.x,this.y+a.y)},c.prototype.subtract=function(b){return new a.Geom.Vector2(this.x-b.x,this.y-b.y)},c.prototype.multiply=function(b){return new a.Geom.Vector2(this.x*b.x,this.y*b.y)},c.prototype.multiplyScalar=function(b){return new a.Geom.Vector2(this.x*b,this.y*b)},c.prototype.dot=function(a){return this.x*a.x+this.y*a.y},c.prototype.lenSqr=function(){return this.x*this.x+this.y*this.y},c.prototype.len=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},c.prototype.unit=function(){var a=1/this.len();return this.multiplyScalar(a)},c.prototype.floor=function(){return new c(Math.floor(this.x),Math.floor(this.y))},c.prototype.ceil=function(){return new c(Math.ceil(this.x),Math.ceil(this.y))},c.prototype.round=function(){return new c(Math.round(this.x),Math.round(this.y))},c.prototype.clamp=function(a,b){return new c(Math.max(Math.min(this.x,b.x),a.x),Math.max(Math.min(this.y,b.y),a.y))},c.prototype.perp=function(){return new c(-this.y,this.x)},c.prototype.neg=function(){return new c(-this.x,-this.y)},c.prototype.equal=function(a){return this.x===a.x&&this.y===a.y},c.prototype.point=function(){return new b.Point(this.x,this.y)},c.prototype.clear=function(){return this.x=0,this.y=0,this},c.prototype.clone=function(a){return void 0===a&&(a=new c),a.setTo(this.x,this.y)},c.prototype.copyFrom=function(a){return this.x=a.x,this.y=a.y,this},c.prototype.copyTo=function(a){return a.x=this.x,a.y=this.y,a},c.prototype.setTo=function(a,b){return this.x=a,this.y=b,this},c.prototype.toString=function(){return"[{Vector2 (x="+this.x+" y="+this.y+")}]"},c}();b.Vector2=c}(b=a.Geom||(a.Geom={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c){if(this._game=b,this.name=c,this._manager=this._game.huds,this._device=this._game.deviceTargetOption,this._manager.supported){switch(this._device){case a.TARGET_BROWSER:this.container=document.createElement("div"),this.container.id="HUD-layer-"+b.rnd.uuid(),this.container.style.width="100%",this.container.style.height="100%",this.container.style.position="absolute",this._widgets=new Array}this["class"]="kiwi-display"}}return b.prototype.objType=function(){return"HUDDisplay"},b.prototype.addWidget=function(b){return this._manager.supported&&(this._widgets.push(b),this._device==a.TARGET_BROWSER)?(this.container.appendChild(b.container),!0):!1},b.prototype.removeWidget=function(a){if(this._manager.supported&&this.removeFromContainer(a)){var b=this._widgets.indexOf(a);if(-1!==b)return this._widgets.splice(b,1),!0}return!1},b.prototype.removeAllWidgets=function(){for(var a=0;athis._icons.length)for(var a=this.counter.max-this._icons.length,b=0;a>b;b++)this._addIcon();else for(var b=this.counter.max;bthis.counter.current-1?"none":"block"},c.prototype._addIcon=function(){if(this.horizontal)var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x+(this.width+this.iconGap)*(this._icons.length-1),this.y);else var b=new a.HUD.Widget.Icon(this.game,this.atlas,this.x,(this.height+this.iconGap)*(this._icons.length-1)+this.y);this._icons.push(b),this._device==a.TARGET_BROWSER&&this.container.appendChild(b.container)},c.prototype._removeIcon=function(b){this._device==a.TARGET_BROWSER&&this.container.removeChild(b.container)},Object.defineProperty(c.prototype,"horizontal",{get:function(){return this._horizontal},set:function(a){this._horizontal=a,this._amountChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"vertical",{get:function(){return!this._horizontal},set:function(a){this._horizontal=!a,this._amountChanged()},enumerable:!0,configurable:!0}),c}(a.HUD.HUDWidget);b.IconBar=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){void 0===f&&(f=0),b.call(this,c,"basicScore",d,e),this.name="basicScore",this["class"]="kiwi-basicscore-widget kiwi-widget",this.counter=this.components.add(new a.HUD.HUDComponents.Counter(this,f)),this.counter.updated.add(this._updateText,this),this._updateText()}return __extends(c,b),c.prototype.objType=function(){return"BasicScoreWidget"},c.prototype._updateText=function(){this.text=String(this.counter.current)},c}(a.HUD.Widget.TextField);b.BasicScore=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,d,e,f),this.name="button",this["class"]="kiwi-button-widget kiwi-widget",this.input=this.components.add(new a.HUD.HUDComponents.WidgetInput(this,this.container))}return __extends(c,b),c.prototype.objType=function(){return"ButtonWidget"},c}(a.HUD.Widget.TextField);b.Button=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d,e,f){b.call(this,c,"time",e,f),this.name="time",this["class"]="kiwi-time-widget kiwi-widget",this.time=this.components.add(new a.HUD.HUDComponents.Time(this,d))}return __extends(c,b),c.prototype.objType=function(){return"TimeWidget"},c.prototype.pause=function(){this.time.pause()},c.prototype.stop=function(){this.time.stop()},c.prototype.start=function(){this.time.start()},c.prototype.resume=function(){this.time.resume()},c.prototype.update=function(){b.prototype.update.call(this),this.time.isRunning&&(this.text=this.time.getTime())},c}(a.HUD.Widget.TextField);b.Time=c}(c=b.Widget||(b.Widget={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(a,c,d){b.call(this,a,"menu",c,d),this._menuItems=[],this._styles=[],this["class"]="kiwi-menu-widget kiwi-widget"}return __extends(c,b),c.prototype.objType=function(){return"MenuWidget"},c.prototype.setIconStyle=function(a,b){this._styles.push({index:a,value:b});for(var c=0;cthis._max?this._max:null!==this._min&&athis._min)&&(null!==this._min&&this._current-athis._max?this._current=this._max:this._current+=a,this.updated.dispatch(this._current,this._max,this._min)),this._current},c.prototype.currentPercent=function(){return null!==this.max?this.current/this.max*100:void 0},c}(a.Component);b.Counter=c}(c=b.HUDComponents||(b.HUDComponents={}))}(b=a.HUD||(a.HUD={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c;!function(b){var c=function(b){function c(c,d){b.call(this,c,"WidgetInput"),this._active=!1,this._container=d,this.onUp=new a.Signal,this.onDown=new a.Signal,this.onOver=new a.Signal,this.onOut=new a.Signal,this._addEvents()}return __extends(c,b),c.prototype.objType=function(){return"WidgetInputComponent"},c.prototype.setElement=function(a){this._removeEvents(),this._container=a,this._addEvents()},c.prototype._addEvents=function(){if(!this._active){this._binds=[],this._binds.push({event:"mouseup","function":this._up.bind(this)}),this._binds.push({event:"mousedown","function":this._down.bind(this)}),this._binds.push({event:"mouseover","function":this._over.bind(this)}),this._binds.push({event:"mouseout","function":this._out.bind(this)});for(var a=0;a=this.duration&&(this._usingWebAudio?this._loop?("default"==this._currentMarker?(this._currentTime=0,this._startTime=this._game.time.now()):this.play(this._currentMarker,!0),this.onLoop.dispatch()):this.stop():this._usingAudioTag&&(this._loop?(this.play(this._currentMarker,!0),this.onLoop.dispatch()):this.stop()))))},b.prototype.destroy=function(){this._game&&this._game.audio.remove(this,!1),this.onLoop&&this.onLoop.dispose(),this.onStop&&this.onStop.dispose(),this.onPlay&&this.onPlay.dispose(),this.onMute&&this.onMute.dispose(),this.onPause&&this.onPause.dispose(),this.onResume&&this.onResume.dispose(),delete this.onLoop,delete this.onStop,delete this.onPause,delete this.onMute,delete this.onPlay,delete this.onResume,delete this._game,delete this._sound,delete this._currentTime,delete this._startTime,delete this._stopTime,delete this._pending,delete this.masterGainNode,delete this.gainNode,delete this.totalDuration,delete this.duration,delete this._file,delete this._buffer,delete this._decoded},b}();b.Audio=c}(b=a.Sound||(a.Sound={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(a){this._game=a,this.audio={}}return b.prototype.objType=function(){return"AudioLibrary"},b.prototype.clear=function(){for(var a in this.audio)delete this.audio[a]},b.prototype.rebuild=function(b,c){this.clear(),a.Log.log("Kiwi.AudioLibrary: Rebuilding Audio Library.","#audio","#rebuild");for(var d=b.keys,e=0;e0&&(b=Math.min(b,this._maxFrameDuration));for(var c=0;c=this.delay;)this._currentCount++,this.processEvents(a.TimerEvent.TIMER_COUNT),this._elapsed-=this.delay,-1!==this.repeatCount&&this._currentCount>=this.repeatCount&&this.stop();for(;this._elapsed<0;)this._currentCount--,this._elapsed+=this.delay,this._currentCount<0&&(this.clear(),this.stop())},b.prototype.start=function(){return this._isStopped===!0&&(this._isRunning=!0,this._isPaused=!1,this._isStopped=!1,this._currentCount=0,this._elapsed=0,this._lastElapsed=this._clock.elapsed()||0,this.processEvents(a.TimerEvent.TIMER_START)),this},b.prototype.stop=function(){return(this._isRunning===!0||this._isPaused===!0)&&(this._isRunning=!1,this._isPaused=!1,this._isStopped=!0,this.processEvents(a.TimerEvent.TIMER_STOP)),this},b.prototype.pause=function(){return this._isRunning===!0&&(this._isRunning=!1,this._isPaused=!0),this},b.prototype.resume=function(){return this._isPaused===!0&&(this._isRunning=!0,this._isPaused=!1),this},b.prototype.addTimerEvent=function(b){return b.type===a.TimerEvent.TIMER_START?this._startEvents.push(b):b.type===a.TimerEvent.TIMER_COUNT?this._countEvents.push(b):b.type===a.TimerEvent.TIMER_STOP&&this._stopEvents.push(b),b},b.prototype.createTimerEvent=function(b,c,d){return b===a.TimerEvent.TIMER_START?(this._startEvents.push(new a.TimerEvent(b,c,d)),this._startEvents[this._startEvents.length-1]):b===a.TimerEvent.TIMER_COUNT?(this._countEvents.push(new a.TimerEvent(b,c,d)),this._countEvents[this._countEvents.length-1]):b===a.TimerEvent.TIMER_STOP?(this._stopEvents.push(new a.TimerEvent(b,c,d)),this._stopEvents[this._stopEvents.length-1]):null},b.prototype.removeTimerEvent=function(b){var c=[];return b.type===a.TimerEvent.TIMER_START?c=this._startEvents.splice(this._startEvents.indexOf(b),1):b.type===a.TimerEvent.TIMER_COUNT?c=this._countEvents.splice(this._countEvents.indexOf(b),1):b.type===a.TimerEvent.TIMER_STOP&&(c=this._stopEvents.splice(this._stopEvents.indexOf(b),1)),1===c.length?!0:!1},b.prototype.clear=function(b){void 0===b&&(b=0),0===b?(this._startEvents.length=0,this._countEvents.length=0,this._stopEvents.length=0):b===a.TimerEvent.TIMER_START?this._startEvents.length=0:b===a.TimerEvent.TIMER_COUNT?this._countEvents.length=0:b===a.TimerEvent.TIMER_STOP&&(this._stopEvents.length=0)},b.prototype.toString=function(){return"[{Timer (name="+this.name+" delay="+this.delay+" repeatCount="+this.repeatCount+" running="+this._isRunning+")}]"},b}();a.Timer=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a,b,c){this._callback=null,this.type=0,this.type=a,this._callback=b,this._callbackContext=c}return a.prototype.objType=function(){return"TimerEvent"},a.prototype.run=function(){this._callback&&this._callback.apply(this._callbackContext)},a.TIMER_START=1,a.TIMER_COUNT=2,a.TIMER_STOP=3,a}();a.TimerEvent=b}(b=a.Time||(a.Time={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(b,c,d,e){void 0===d&&(d=!0),void 0===e&&(e=!1),this.domElement=null,this.context=null,this._visible=!0,this._offScreen=!1,this._clearMode=1,this.domElement=document.createElement("canvas"),this.domElement.width=b,this.domElement.height=c,this._width=b,this._height=c,this.context=this.domElement.getContext("2d"),this._offScreen=e,this._visible=d,d===!1&&(this.domElement.style.display="none"),this._bgColor=new a.Utils.Color(0,0,0)}return Object.defineProperty(b.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a,this._updatedSize()},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a,this._updatedSize()},enumerable:!0,configurable:!0}),b.prototype.objType=function(){return"Canvas"},Object.defineProperty(b.prototype,"bgColor",{get:function(){return"#"+this._bgColor.getHex()},set:function(b){a.Utils.Common.isArray(b)||(b=[b]),this._bgColor.set.apply(this._bgColor,b)},enumerable:!0,configurable:!0}),b.prototype._updatedSize=function(){this.domElement.width=this._width,this.domElement.height=this._height},b.prototype.destroy=function(){this._offScreen===!1&&(this.domElement.style.display="none")},Object.defineProperty(b.prototype,"visible",{get:function(){return this._visible},set:function(a){null!==a&&a!==this._visible&&(this._visible=a,this.domElement.style.display=a===!0?"block":"none")},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"clearMode",{get:function(){return this._clearMode},set:function(b){null!==b&&b!==this._clearMode&&b>=a.Utils.Canvas.CLEARMODE_NONE&&b<=a.Utils.Canvas.CLEARMODE_FILLRECT_ALPHA&&(this._clearMode=b)},enumerable:!0,configurable:!0}),b.prototype.clear=function(){this._clearMode===b.CLEARMODE_NONE||(this._clearMode===b.CLEARMODE_CLEARRECT?this.context.clearRect(0,0,this.domElement.width,this.domElement.height):this._clearMode===b.CLEARMODE_FILLRECT?(this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)):this._clearMode===b.CLEARMODE_FILLRECT_ALPHA&&(this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.context.fillStyle=this.bgColor,this.context.fillRect(0,0,this.domElement.width,this.domElement.height)))},b.prototype.saveAsPNG=function(){return this.domElement.toDataURL()},b.prototype.toString=function(){return"[{Canvas (width="+this.width+" height="+this.height+" visible="+this.visible+" offScreen="+this._offScreen+" clearMode="+this.clearMode+")}]" +},b.CLEARMODE_NONE=0,b.CLEARMODE_CLEARRECT=1,b.CLEARMODE_FILLRECT=2,b.CLEARMODE_FILLRECT_ALPHA=3,b}();b.Canvas=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(){for(var a=[],b=0;b1?this.r255=a:this.rNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g",{get:function(){return this._g},set:function(a){a>1?this.g255=a:this.gNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b",{get:function(){return this._b},set:function(a){a>1?this.b255=a:this.bNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a",{get:function(){return this._a},set:function(a){a>1?this.a255=a:this.aNorm=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"r255",{get:function(){return Math.round(255*this._r)},set:function(a){isNaN(a)||(this._r=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"g255",{get:function(){return Math.round(255*this._g)},set:function(a){isNaN(a)||(this._g=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"b255",{get:function(){return Math.round(255*this._b)},set:function(a){isNaN(a)||(this._b=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"a255",{get:function(){return Math.round(255*this._a)},set:function(a){isNaN(a)||(this._a=a/255)},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"red",{get:function(){return this.r},set:function(a){this.r=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"green",{get:function(){return this.g},set:function(a){this.g=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"blue",{get:function(){return this.b},set:function(a){this.b=a},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"alpha",{get:function(){return this.a},set:function(a){this.a=a},enumerable:!0,configurable:!0}),a.prototype.parseString=function(a){var b;return a=a.toLowerCase(),"rgba"===a.slice(0,4)?(a=a.replace("rgba",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2],this.a=+b[3]):"rgb"===a.slice(0,3)?(a=a.replace("rgb",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.r=+b[0],this.g=+b[1],this.b=+b[2]):"hsla"===a.slice(0,4)?(a=a.replace("hsla",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2],+b[3])):"hsl"===a.slice(0,3)?(a=a.replace("hsl",""),a=a.replace("(",""),a=a.replace(")",""),b=a.split(","),this.parseHsl(+b[0],+b[1],+b[2])):this.parseHex(a),this},a.prototype.parseHex=function(a){var b,c=this.r255,d=this.g255,e=this.b255,f=this.a255;return"#"===a.charAt(0)&&(a=a.slice(1)),"0x"===a.slice(0,2)&&(a=a.slice(2)),b=parseInt(a,16),3===a.length?(c=17*(b>>8&15),d=17*(b>>4&15),e=17*(15&b)):4===a.length?(c=17*(b>>12&15),d=17*(b>>8&15),e=17*(b>>4&15),f=17*(15&b)):6===a.length?(c=b>>16&255,d=b>>8&255,e=255&b,f=255):8===a.length&&(c=b>>24&255,d=b>>16&255,e=b>>8&255,f=255&b),this.r255=c,this.g255=d,this.b255=e,this.a255=f,this},a.prototype.getHex=function(a){void 0===a&&(a=!0);var b,c="";for(b=this.r255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.g255.toString(16);b.length<2;)b="0"+b;for(c+=b,b=this.b255.toString(16);b.length<2;)b="0"+b;if(c+=b,a){for(b=this.a255.toString(16);b.length<2;)b="0"+b;c+=b}return c},a.prototype.parseHsv=function(a,b,c,d){void 0===d&&(d=1);var e,f,g,h,i,j,k,l;if(isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d))return this;switch(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),h=Math.floor(6*a),i=6*a-h,j=c*(1-b),k=c*(1-i*b),l=c*(1-(1-i)*b),h%6){case 0:e=c,f=l,g=j;break;case 1:e=k,f=c,g=j;break;case 2:e=j,f=c,g=l;break;case 3:e=j,f=k,g=c;break;case 4:e=l,f=j,g=c;break;case 5:e=c,f=j,g=k}return this._r=e,this._g=f,this._b=g,this._a=d,this},a.prototype.getHsva=function(){var a,b,c,d,e=this._r,f=this._g,g=this._b,h=Math.max(e,f,g),i=Math.min(e,f,g);if(a=h,b=h,c=h,d=h-i,b=0===h?0:d/h,h===i)a=0;else{switch(h){case e:a=(f-g)/d+(g>f?6:0);break;case f:a=(g-e)/d+2;break;case g:a=(e-f)/d+4}a/=6}return{h:a,s:b,v:c,a:this._a}},a.prototype.parseHsl=function(a,b,c,d){void 0===d&&(d=1);var e,f,g=this._r,h=this._g,i=this._b;return isNaN(a)||isNaN(b)||isNaN(c)||isNaN(d)?this:(a>1&&(a/=360),b>1&&(b/=100),c>1&&(c/=100),d>1&&(d/=255),0===b?(g=c,h=c,i=c):(e=.5>c?c*(1+b):c+b-c*b,f=2*c-e,g=this._hue2rgb(f,e,a+1/3),h=this._hue2rgb(f,e,a),i=this._hue2rgb(f,e,a-1/3)),this._r=g,this._g=h,this._b=i,this._a=d,this)},a.prototype.getHsla=function(){var a,b=this._r,c=this._g,d=this._b,e=Math.max(b,c,d),f=Math.min(b,c,d),g=(e+f)/2,h=(e+f)/2,i=(e+f)/2;if(e==f)g=0,h=0;else{switch(a=e-f,h=i>.5?a/(2-e-f):a/(e+f),e){case b:g=(c-d)/a+(d>c?6:0);break;case c:g=(d-b)/a+2;break;case d:g=(b-c)/a+4}g/=6}return{h:g,s:h,l:i,a:this._a}},a.prototype._hue2rgb=function(a,b,c){return 0>c&&(c+=1),c>1&&(c-=1),1/6>c?a+6*(b-a)*c:.5>c?b:2/3>c?a+(b-a)*(2/3-c)*6:a},a}();a.Color=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.defaultCompare=function(a,b){return b>a?-1:a===b?0:1},b.prototype.objType=function(){return"Common"},b.defaultEquals=function(a,b){return a===b},b.defaultToString=function(b){return null===b?"KIWI_NULL":a.Utils.Common.isUndefined(b)?"KIWI_UNDEFINED":a.Utils.Common.isString(b)?b:b.toString()},b.isBetween=function(a,b,c){return a>b&&c>a},b.isFunction=function(a){return"function"==typeof a},b.isNumeric=function(a){return!isNaN(a)},b.isUndefined=function(a){return"undefined"==typeof a},b.isString=function(a){return"[object String]"===Object.prototype.toString.call(a)},b.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)},b.isObject=function(a){return"[object Object]"===Object.prototype.toString.call(a)},b.reverseCompareFunction=function(b){return a.Utils.Common.isFunction(b)?function(a,c){return-1*b(a,c)}:function(a,b){return b>a?1:a===b?0:-1}},b.compareToEquals=function(a){return function(b,c){return 0===a(b,c)}},b.shuffleArray=function(a){for(var b=a.length-1;b>0;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},b.convertToBase2=function(a){var b=a.width,c=a.height;if(-1==this.base2Sizes.indexOf(b)){for(var d=0;b>this.base2Sizes[d];)d++;b=this.base2Sizes[d]}if(-1==this.base2Sizes.indexOf(c)){for(var d=0;c>this.base2Sizes[d];)d++;c=this.base2Sizes[d]}if(a.width!==b||a.height!==c){var e=document.createElement("canvas");return e.width=b,e.height=c,e.getContext("2d").drawImage(a,0,0),e}return a},b.base2Sizes=[2,4,16,32,64,128,256,512,1024,2048,4096],b}();b.Common=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(b){var c=function(){function b(){}return b.prototype.objType=function(){return"GameMath"},b.computeMachineEpsilon=function(){var a=4/3,b=a-1,c=b+b+b;return Math.abs(1-c)},b.fuzzyEqual=function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)a},b.fuzzyGreaterThan=function(a,b,c){return void 0===c&&(c=1e-4),a>b-c},b.fuzzyCeil=function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},b.fuzzyFloor=function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},b.average=function(){for(var a=[],b=0;b0?Math.floor(a):Math.ceil(a)},b.shear=function(a){return a%1},b.wrap=function(a,b,c){if(void 0===c&&(c=0),a-=c,b-=c,0==b)return c;for(a%=b,a+=c;c>a;)a+=b;return a},b.arithWrap=function(a,b,c){return void 0===c&&(c=0),b-=c,0==b?c:a-b*Math.floor((a-c)/b)},b.clamp=function(a,b,c){return void 0===c&&(c=0),Math.max(c,Math.min(b,a))},b.snapTo=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.round(a/b),c+a)},b.snapToFloor=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.floor(a/b),c+a)},b.snapToCeil=function(a,b,c){return void 0===c&&(c=0),0==b?a:(a-=c,a=b*Math.ceil(a/b),c+a)},b.snapToInArray=function(a,b,c){if(void 0===c&&(c=!0),c&&b.sort(),a=f-a?f:e},b.roundTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.round(a*d)/d},b.floorTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.floor(a*d)/d},b.ceilTo=function(a,b,c){void 0===b&&(b=0),void 0===c&&(c=10);var d=Math.pow(c,-b);return Math.ceil(a*d)/d},b.interpolateFloat=function(a,b,c){return(b-a)*c+a},b.radiansToDegrees=function(a){return a*b.RAD_TO_DEG},b.degreesToRadians=function(a){return a*b.DEG_TO_RAD},b.angleBetween=function(a,b,c,d){return Math.atan2(d-b,c-a)},b.normalizeAngle=function(a,c){void 0===c&&(c=!0);var d=c?b.PI:180;return b.wrap(a,d,-d)},b.nearestAngleBetween=function(a,c,d){void 0===d&&(d=!0);var e=d?b.PI:180;return a=b.normalizeAngle(a,d),c=b.normalizeAngle(c,d),-e/2>a&&c>e/2&&(a+=2*e),-e/2>c&&a>e/2&&(c+=2*e),b.normalizeAngle(c-a,d)},b.normalizeAngleToAnother=function(b,c,d){return void 0===d&&(d=!0),c+a.Utils.GameMath.nearestAngleBetween(c,b,d)},b.normalizeAngleAfterAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(b-c,d),c+b},b.normalizeAngleBeforeAnother=function(b,c,d){return void 0===d&&(d=!0),b=a.Utils.GameMath.normalizeAngle(c-b,d),c-b},b.interpolateAngles=function(b,c,d,e,f){return void 0===e&&(e=!0),void 0===f&&(f=null),b=a.Utils.GameMath.normalizeAngle(b,e),c=a.Utils.GameMath.normalizeAngleToAnother(c,b,e),"function"==typeof f?f(d,b,c-b,1):a.Utils.GameMath.interpolateFloat(b,c,d)},b.logBaseOf=function(a,b){return Math.log(a)/Math.log(b)},b.GCD=function(a,b){var c;for(a=Math.abs(a),b=Math.abs(b),b>a&&(c=a,a=b,b=c);;){if(c=a%b,!c)return b;a=b,b=c}return 1},b.LCM=function(b,c){return b*c/a.Utils.GameMath.GCD(b,c)},b.factorial=function(a){if(0==a)return 1;for(var b=a;--a;)b*=a;return b},b.gammaFunction=function(b){return a.Utils.GameMath.factorial(b-1)},b.fallingFactorial=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(b-c)},b.risingFactorial=function(b,c){return a.Utils.GameMath.factorial(b+c-1)/a.Utils.GameMath.factorial(b-1)},b.binCoef=function(b,c){return a.Utils.GameMath.fallingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.risingBinCoef=function(b,c){return a.Utils.GameMath.risingFactorial(b,c)/a.Utils.GameMath.factorial(c)},b.chanceRoll=function(a){return void 0===a&&(a=50),0>=a?!1:a>=100?!0:100*Math.random()>=a?!1:!0},b.maxAdd=function(a,b,c){return a+=b,a>c&&(a=c),a},b.minSub=function(a,b,c){return a-=b,c>a&&(a=c),a},b.wrapValue=function(a,b,c){var d;return a=Math.abs(a),b=Math.abs(b),c=Math.abs(c),d=(a+b)%c},b.randomSign=function(){return Math.random()>.5?1:-1},b.isOdd=function(a){return 1&a?!0:!1},b.isEven=function(a){return 1&a?!1:!0},b.wrapAngle=function(a){var b=a;return a>=-180&&180>=a?a:(b=(a+180)%360,0>b&&(b+=360),b-180)},b.angleLimit=function(a,b,c){var d=a;return a>c?d=c:b>a&&(d=b),d},b.linearInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return 0>c?a.Utils.GameMath.linear(b[0],b[1],e):c>1?a.Utils.GameMath.linear(b[d],b[d-1],d-e):a.Utils.GameMath.linear(b[f],b[f+1>d?d:f+1],e-f)},b.bezierInterpolation=function(b,c){for(var d=0,e=b.length-1,f=0;e>=f;f++)d+=Math.pow(1-c,e-f)*Math.pow(c,f)*b[f]*a.Utils.GameMath.bernstein(e,f);return d},b.catmullRomInterpolation=function(b,c){var d=b.length-1,e=d*c,f=Math.floor(e);return b[0]===b[d]?(0>c&&(f=Math.floor(e=d*(1+c))),a.Utils.GameMath.catmullRom(b[(f-1+d)%d],b[f],b[(f+1)%d],b[(f+2)%d],e-f)):0>c?b[0]-(a.Utils.GameMath.catmullRom(b[0],b[0],b[1],b[1],-e)-b[0]):c>1?b[d]-(a.Utils.GameMath.catmullRom(b[d],b[d],b[d-1],b[d-1],e-d)-b[d]):a.Utils.GameMath.catmullRom(b[f?f-1:0],b[f],b[f+1>d?d:f+1],b[f+2>d?d:f+2],e-f)},b.linear=function(a,b,c){return(b-a)*c+a},b.bernstein=function(b,c){return a.Utils.GameMath.factorial(b)/a.Utils.GameMath.factorial(c)/a.Utils.GameMath.factorial(b-c)},b.catmullRom=function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e,i=e*h;return(2*b-2*c+f+g)*i+(-3*b+3*c-2*f-g)*h+f*e+b},b.difference=function(a,b){return Math.abs(a-b)},b.PI=3.141592653589793,b.PI_2=1.5707963267948966,b.PI_4=.7853981633974483,b.PI_8=.39269908169872414,b.PI_16=.19634954084936207,b.TWO_PI=6.283185307179586,b.THREE_PI_2=4.71238898038469,b.E=2.71828182845905,b.LN10=2.302585092994046,b.LN2=.6931471805599453,b.LOG10E=.4342944819032518,b.LOG2E=1.4426950408889634,b.SQRT1_2=.7071067811865476,b.SQRT2=1.4142135623730951,b.DEG_TO_RAD=.017453292519943295,b.RAD_TO_DEG=57.29577951308232,b.B_16=65536,b.B_31=2147483648,b.B_32=4294967296,b.B_48=281474976710656,b.B_53=9007199254740992,b.B_64=0x10000000000000000,b.ONE_THIRD=.3333333333333333,b.TWO_THIRDS=.6666666666666666,b.ONE_SIXTH=.16666666666666666,b.COS_PI_3=.8660254037844386,b.SIN_2PI_3=.03654595,b.CIRCLE_ALPHA=.5522847498307935,b.ON=!0,b.OFF=!1,b.SHORT_EPSILON=.1,b.PERC_EPSILON=.001,b.EPSILON=1e-4,b.LONG_EPSILON=1e-8,b}();b.GameMath=c}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){void 0===a&&(a=[]),this.c=1,this._data={lipsum:["lorem","ipsum","dolor","sit","amet","consectetur","adipiscing","elit","nunc","sagittis","tortor","ac","mi","pretium","sed","convallis","massa","pulvinar","curabitur","non","turpis","velit","vitae","rutrum","odio","aliquam","sapien","orci","tempor","sed","elementum","sit","amet","tincidunt","sed","risus","etiam","nec","lacus","id","ante","hendrerit","malesuada","donec","porttitor","magna","eget","libero","pharetra","sollicitudin","aliquam","mattis","mattis","massa","et","porta","morbi","vitae","magna","augue","vestibulum","at","lectus","sed","tellus","facilisis","tincidunt","suspendisse","eros","magna","consequat","at","sollicitudin","ac","vestibulum","vel","dolor","in","egestas","lacus","quis","lacus","placerat","et","molestie","ipsum","scelerisque","nullam","sit","amet","tortor","dui","aenean","pulvinar","odio","nec","placerat","fringilla","neque","dolor"]},this.sow(a)}return a.prototype.objType=function(){return"RandomDataGenerator"},a.prototype.uint32=function(){return 4294967296*this.rnd.apply(this)},a.prototype.fract32=function(){return this.rnd.apply(this)+1.1102230246251565e-16*(2097152*this.rnd.apply(this)|0)},a.prototype.rnd=function(){var a=2091639*this.s0+2.3283064365386963e-10*this.c;return this.c=0|a,this.s0=this.s1,this.s1=this.s2,this.s2=a-this.c,this.s2},a.prototype.hash=function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c>>0,b-=d,b*=d,d=b>>>0,b-=d,d+=4294967296*b;return 2.3283064365386963e-10*(d>>>0)},a.prototype.sow=function(a){void 0===a&&(a=[]),this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1);for(var b,c=0;b=a[c++];)this.s0-=this.hash(b),this.s0+=~~(this.s0<0),this.s1-=this.hash(b),this.s1+=~~(this.s1<0),this.s2-=this.hash(b),this.s2+=~~(this.s2<0)},a.prototype.integer=function(){return this.uint32()},a.prototype.frac=function(){return this.fract32()},a.prototype.real=function(){return this.uint32()+this.fract32()},a.prototype.integerInRange=function(a,b){return Math.floor(this.realInRange(a,b))},a.prototype.realInRange=function(a,b){return a=a||0,b=b||0,this.frac()*(b-a)+a},a.prototype.normal=function(){return 1-2*this.frac()},a.prototype.uuid=function(){var a,b;for(b=a="";a++<36;b+=~a%5|3*a&4?(15^a?8^this.frac()*(20^a?16:4):4).toString(16):"-");return b},a.prototype.pick=function(a){return a[this.integerInRange(0,a.length)]},a.prototype.weightedPick=function(a){return a[~~(Math.pow(this.frac(),2)*a.length)]},a.prototype.word=function(){return this.pick(this._data.lipsum)},a.prototype.words=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.pick(this._data.lipsum));return b.join(" ")},a.prototype.sentence=function(){var a;return a=this.words(this.integerInRange(2,16)).replace(/[a-z]/,function(a){return a.toUpperCase()}),a+"."},a.prototype.sentences=function(a){void 0===a&&(a=3);for(var b=[],c=0;a>c;c++)b.push(this.sentence());return b.join(" ")},a.prototype.timestamp=function(a,b){return void 0===a&&(a=9466848e5),void 0===b&&(b=1577862e6),this.realInRange(a,b)},a.prototype.angle=function(){return this.integerInRange(-180,180)},a}();a.RandomDataGenerator=b}(b=a.Utils||(a.Utils={}))}(Kiwi||(Kiwi={}));var Kiwi;!function(a){var b;!function(a){var b=function(){function a(a){this._isSetTimeOut=!1,this.lastTime=0,this.currentTime=0,this.isRunning=!1,this._callback=a;for(var b=["ms","moz","webkit","o"],c=0;c0?this.recordings[this.recordings.length-1].time:0},enumerable:!0,configurable:!0}),Object.defineProperty(b.prototype,"numRecordings",{get:function(){return this.recordings.length},enumerable:!0,configurable:!0}),b.prototype.record=function(a,b,c){if(void 0===b&&(b=[]),void 0===c&&(c=console.log),this.recording){var d={messages:a,time:Date.now(),tags:b,logMethod:c};this.recordings.push(d)>this.maxRecordings&&this.recordings.shift()}},b.prototype.clearRecordings=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.recordings.length),this.recordings.splice(a,b)},b.prototype._execute=function(a,b,c,d){void 0===d&&(d=!1),(this.display||d)&&a.apply(b,c)},b.prototype.getTagsFromArray=function(a){for(var b=0,c=[];bd.time&&this._show(d,c)},b.prototype.addFilter=function(){for(var a=[],b=0;be.majorVersion?"greater":d.majorVersione.minorVersion?"greater":d.minorVersione.patchVersion?"greater":d.patchVersion0&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},f.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},f.cross=function(a,b,c){var d=b[0]*c[1]-b[1]*c[0];return a[0]=a[1]=0,a[2]=d,a},f.lerp=function(a,b,c,d){var e=b[0],f=b[1];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a},f.random=function(a,b){b=b||1;var c=2*d()*Math.PI;return a[0]=Math.cos(c)*b,a[1]=Math.sin(c)*b,a},f.transformMat2=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[2]*e,a[1]=c[1]*d+c[3]*e,a},f.transformMat2d=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[2]*e+c[4],a[1]=c[1]*d+c[3]*e+c[5],a},f.transformMat3=function(a,b,c){var d=b[0],e=b[1];return a[0]=c[0]*d+c[3]*e+c[6],a[1]=c[1]*d+c[4]*e+c[7],a},f.transformMat4=function(a,b,c){var d=b[0],e=b[1]; +return a[0]=c[0]*d+c[4]*e+c[12],a[1]=c[1]*d+c[5]*e+c[13],a},f.forEach=function(){var a=f.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=2),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],f(a,a,g),b[h]=a[0],b[h+1]=a[1];return b}}(),f.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},"undefined"!=typeof a&&(a.vec2=f);var g={};g.create=function(){var a=new c(3);return a[0]=0,a[1]=0,a[2]=0,a},g.clone=function(a){var b=new c(3);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b},g.fromValues=function(a,b,d){var e=new c(3);return e[0]=a,e[1]=b,e[2]=d,e},g.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a},g.set=function(a,b,c,d){return a[0]=b,a[1]=c,a[2]=d,a},g.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a},g.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a},g.sub=g.subtract,g.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a},g.mul=g.multiply,g.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a},g.div=g.divide,g.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a},g.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a},g.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a},g.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a},g.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return Math.sqrt(c*c+d*d+e*e)},g.dist=g.distance,g.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2];return c*c+d*d+e*e},g.sqrDist=g.squaredDistance,g.length=function(a){var b=a[0],c=a[1],d=a[2];return Math.sqrt(b*b+c*c+d*d)},g.len=g.length,g.squaredLength=function(a){var b=a[0],c=a[1],d=a[2];return b*b+c*c+d*d},g.sqrLen=g.squaredLength,g.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a},g.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=c*c+d*d+e*e;return f>0&&(f=1/Math.sqrt(f),a[0]=b[0]*f,a[1]=b[1]*f,a[2]=b[2]*f),a},g.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},g.cross=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2];return a[0]=e*i-f*h,a[1]=f*g-d*i,a[2]=d*h-e*g,a},g.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a},g.random=function(a,b){b=b||1;var c=2*d()*Math.PI,e=2*d()-1,f=Math.sqrt(1-e*e)*b;return a[0]=Math.cos(c)*f,a[1]=Math.sin(c)*f,a[2]=e*b,a},g.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12],a[1]=c[1]*d+c[5]*e+c[9]*f+c[13],a[2]=c[2]*d+c[6]*e+c[10]*f+c[14],a},g.transformMat3=function(a,b,c){var d=b[0],e=b[1],f=b[2];return a[0]=d*c[0]+e*c[3]+f*c[6],a[1]=d*c[1]+e*c[4]+f*c[7],a[2]=d*c[2]+e*c[5]+f*c[8],a},g.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},g.forEach=function(){var a=g.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=3),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2];return b}}(),g.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"},"undefined"!=typeof a&&(a.vec3=g);var h={};h.create=function(){var a=new c(4);return a[0]=0,a[1]=0,a[2]=0,a[3]=0,a},h.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},h.fromValues=function(a,b,d,e){var f=new c(4);return f[0]=a,f[1]=b,f[2]=d,f[3]=e,f},h.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},h.set=function(a,b,c,d,e){return a[0]=b,a[1]=c,a[2]=d,a[3]=e,a},h.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a[2]=b[2]+c[2],a[3]=b[3]+c[3],a},h.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a[2]=b[2]-c[2],a[3]=b[3]-c[3],a},h.sub=h.subtract,h.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a[2]=b[2]*c[2],a[3]=b[3]*c[3],a},h.mul=h.multiply,h.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a[2]=b[2]/c[2],a[3]=b[3]/c[3],a},h.div=h.divide,h.min=function(a,b,c){return a[0]=Math.min(b[0],c[0]),a[1]=Math.min(b[1],c[1]),a[2]=Math.min(b[2],c[2]),a[3]=Math.min(b[3],c[3]),a},h.max=function(a,b,c){return a[0]=Math.max(b[0],c[0]),a[1]=Math.max(b[1],c[1]),a[2]=Math.max(b[2],c[2]),a[3]=Math.max(b[3],c[3]),a},h.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a[2]=b[2]*c,a[3]=b[3]*c,a},h.scaleAndAdd=function(a,b,c,d){return a[0]=b[0]+c[0]*d,a[1]=b[1]+c[1]*d,a[2]=b[2]+c[2]*d,a[3]=b[3]+c[3]*d,a},h.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return Math.sqrt(c*c+d*d+e*e+f*f)},h.dist=h.distance,h.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1],e=b[2]-a[2],f=b[3]-a[3];return c*c+d*d+e*e+f*f},h.sqrDist=h.squaredDistance,h.length=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return Math.sqrt(b*b+c*c+d*d+e*e)},h.len=h.length,h.squaredLength=function(a){var b=a[0],c=a[1],d=a[2],e=a[3];return b*b+c*c+d*d+e*e},h.sqrLen=h.squaredLength,h.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=-b[3],a},h.normalize=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f;return g>0&&(g=1/Math.sqrt(g),a[0]=b[0]*g,a[1]=b[1]*g,a[2]=b[2]*g,a[3]=b[3]*g),a},h.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},h.lerp=function(a,b,c,d){var e=b[0],f=b[1],g=b[2],h=b[3];return a[0]=e+d*(c[0]-e),a[1]=f+d*(c[1]-f),a[2]=g+d*(c[2]-g),a[3]=h+d*(c[3]-h),a},h.random=function(a,b){return b=b||1,a[0]=d(),a[1]=d(),a[2]=d(),a[3]=d(),h.normalize(a,a),h.scale(a,a,b),a},h.transformMat4=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3];return a[0]=c[0]*d+c[4]*e+c[8]*f+c[12]*g,a[1]=c[1]*d+c[5]*e+c[9]*f+c[13]*g,a[2]=c[2]*d+c[6]*e+c[10]*f+c[14]*g,a[3]=c[3]*d+c[7]*e+c[11]*f+c[15]*g,a},h.transformQuat=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=c[0],h=c[1],i=c[2],j=c[3],k=j*d+h*f-i*e,l=j*e+i*d-g*f,m=j*f+g*e-h*d,n=-g*d-h*e-i*f;return a[0]=k*j+n*-g+l*-i-m*-h,a[1]=l*j+n*-h+m*-g-k*-i,a[2]=m*j+n*-i+k*-h-l*-g,a},h.forEach=function(){var a=h.create();return function(b,c,d,e,f,g){var h,i;for(c||(c=4),d||(d=0),i=e?Math.min(e*c+d,b.length):b.length,h=d;i>h;h+=c)a[0]=b[h],a[1]=b[h+1],a[2]=b[h+2],a[3]=b[h+3],f(a,a,g),b[h]=a[0],b[h+1]=a[1],b[h+2]=a[2],b[h+3]=a[3];return b}}(),h.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.vec4=h);var i={};i.create=function(){var a=new c(4);return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},i.clone=function(a){var b=new c(4);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b},i.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a},i.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a},i.transpose=function(a,b){if(a===b){var c=b[1];a[1]=b[2],a[2]=c}else a[0]=b[0],a[1]=b[2],a[2]=b[1],a[3]=b[3];return a},i.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*f-e*d;return g?(g=1/g,a[0]=f*g,a[1]=-d*g,a[2]=-e*g,a[3]=c*g,a):null},i.adjoint=function(a,b){var c=b[0];return a[0]=b[3],a[1]=-b[1],a[2]=-b[2],a[3]=c,a},i.determinant=function(a){return a[0]*a[3]-a[2]*a[1]},i.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*h+e*j,a[1]=d*i+e*k,a[2]=f*h+g*j,a[3]=f*i+g*k,a},i.mul=i.multiply,i.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+e*h,a[1]=d*-h+e*i,a[2]=f*i+g*h,a[3]=f*-h+g*i,a},i.scale=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1];return a[0]=d*h,a[1]=e*i,a[2]=f*h,a[3]=g*i,a},i.str=function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.mat2=i);var j={};j.create=function(){var a=new c(6);return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},j.clone=function(a){var b=new c(6);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b},j.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a},j.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=1,a[4]=0,a[5]=0,a},j.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=c*f-d*e;return i?(i=1/i,a[0]=f*i,a[1]=-d*i,a[2]=-e*i,a[3]=c*i,a[4]=(e*h-f*g)*i,a[5]=(d*g-c*h)*i,a):null},j.determinant=function(a){return a[0]*a[3]-a[1]*a[2]},j.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=c[0],k=c[1],l=c[2],m=c[3],n=c[4],o=c[5];return a[0]=d*j+e*l,a[1]=d*k+e*m,a[2]=f*j+g*l,a[3]=f*k+g*m,a[4]=j*h+l*i+n,a[5]=k*h+m*i+o,a},j.mul=j.multiply,j.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=Math.sin(c),k=Math.cos(c);return a[0]=d*k+e*j,a[1]=-d*j+e*k,a[2]=f*k+g*j,a[3]=-f*j+k*g,a[4]=k*h+j*i,a[5]=k*i-j*h,a},j.scale=function(a,b,c){var d=c[0],e=c[1];return a[0]=b[0]*d,a[1]=b[1]*e,a[2]=b[2]*d,a[3]=b[3]*e,a[4]=b[4]*d,a[5]=b[5]*e,a},j.translate=function(a,b,c){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4]+c[0],a[5]=b[5]+c[1],a},j.str=function(a){return"mat2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"},"undefined"!=typeof a&&(a.mat2d=j);var k={};k.create=function(){var a=new c(9);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},k.fromMat4=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[4],a[4]=b[5],a[5]=b[6],a[6]=b[8],a[7]=b[9],a[8]=b[10],a},k.clone=function(a){var b=new c(9);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b},k.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},k.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=1,a[5]=0,a[6]=0,a[7]=0,a[8]=1,a},k.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[5];a[1]=b[3],a[2]=b[6],a[3]=c,a[5]=b[7],a[6]=d,a[7]=e}else a[0]=b[0],a[1]=b[3],a[2]=b[6],a[3]=b[1],a[4]=b[4],a[5]=b[7],a[6]=b[2],a[7]=b[5],a[8]=b[8];return a},k.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=k*g-h*j,m=-k*f+h*i,n=j*f-g*i,o=c*l+d*m+e*n;return o?(o=1/o,a[0]=l*o,a[1]=(-k*d+e*j)*o,a[2]=(h*d-e*g)*o,a[3]=m*o,a[4]=(k*c-e*i)*o,a[5]=(-h*c+e*f)*o,a[6]=n*o,a[7]=(-j*c+d*i)*o,a[8]=(g*c-d*f)*o,a):null},k.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8];return a[0]=g*k-h*j,a[1]=e*j-d*k,a[2]=d*h-e*g,a[3]=h*i-f*k,a[4]=c*k-e*i,a[5]=e*f-c*h,a[6]=f*j-g*i,a[7]=d*i-c*j,a[8]=c*g-d*f,a},k.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8];return b*(j*f-g*i)+c*(-j*e+g*h)+d*(i*e-f*h)},k.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1],o=c[2],p=c[3],q=c[4],r=c[5],s=c[6],t=c[7],u=c[8];return a[0]=m*d+n*g+o*j,a[1]=m*e+n*h+o*k,a[2]=m*f+n*i+o*l,a[3]=p*d+q*g+r*j,a[4]=p*e+q*h+r*k,a[5]=p*f+q*i+r*l,a[6]=s*d+t*g+u*j,a[7]=s*e+t*h+u*k,a[8]=s*f+t*i+u*l,a},k.mul=k.multiply,k.translate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=c[0],n=c[1];return a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=m*d+n*g+j,a[7]=m*e+n*h+k,a[8]=m*f+n*i+l,a},k.rotate=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=Math.sin(c),n=Math.cos(c);return a[0]=n*d+m*g,a[1]=n*e+m*h,a[2]=n*f+m*i,a[3]=n*g-m*d,a[4]=n*h-m*e,a[5]=n*i-m*f,a[6]=j,a[7]=k,a[8]=l,a},k.scale=function(a,b,c){var d=c[0],e=c[1];return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=e*b[3],a[4]=e*b[4],a[5]=e*b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a},k.fromMat2d=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=0,a[3]=b[2],a[4]=b[3],a[5]=0,a[6]=b[4],a[7]=b[5],a[8]=1,a},k.fromQuat=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c+c,h=d+d,i=e+e,j=c*g,k=c*h,l=c*i,m=d*h,n=d*i,o=e*i,p=f*g,q=f*h,r=f*i;return a[0]=1-(m+o),a[3]=k+r,a[6]=l-q,a[1]=k-r,a[4]=1-(j+o),a[7]=n+p,a[2]=l+q,a[5]=n-p,a[8]=1-(j+m),a},k.normalFromMat4=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(i*A-g*D-j*z)*E,a[2]=(g*C-h*A+j*y)*E,a[3]=(e*C-d*D-f*B)*E,a[4]=(c*D-e*A+f*z)*E,a[5]=(d*A-c*C-f*y)*E,a[6]=(p*x-q*w+r*v)*E,a[7]=(q*u-o*x-r*t)*E,a[8]=(o*w-p*u+r*s)*E,a):null},k.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"},"undefined"!=typeof a&&(a.mat3=k);var l={};l.create=function(){var a=new c(16);return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},l.clone=function(a){var b=new c(16);return b[0]=a[0],b[1]=a[1],b[2]=a[2],b[3]=a[3],b[4]=a[4],b[5]=a[5],b[6]=a[6],b[7]=a[7],b[8]=a[8],b[9]=a[9],b[10]=a[10],b[11]=a[11],b[12]=a[12],b[13]=a[13],b[14]=a[14],b[15]=a[15],b},l.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a[2]=b[2],a[3]=b[3],a[4]=b[4],a[5]=b[5],a[6]=b[6],a[7]=b[7],a[8]=b[8],a[9]=b[9],a[10]=b[10],a[11]=b[11],a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},l.identity=function(a){return a[0]=1,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=1,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=1,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,a},l.transpose=function(a,b){if(a===b){var c=b[1],d=b[2],e=b[3],f=b[6],g=b[7],h=b[11];a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=c,a[6]=b[9],a[7]=b[13],a[8]=d,a[9]=f,a[11]=b[14],a[12]=e,a[13]=g,a[14]=h}else a[0]=b[0],a[1]=b[4],a[2]=b[8],a[3]=b[12],a[4]=b[1],a[5]=b[5],a[6]=b[9],a[7]=b[13],a[8]=b[2],a[9]=b[6],a[10]=b[10],a[11]=b[14],a[12]=b[3],a[13]=b[7],a[14]=b[11],a[15]=b[15];return a},l.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15],s=c*h-d*g,t=c*i-e*g,u=c*j-f*g,v=d*i-e*h,w=d*j-f*h,x=e*j-f*i,y=k*p-l*o,z=k*q-m*o,A=k*r-n*o,B=l*q-m*p,C=l*r-n*p,D=m*r-n*q,E=s*D-t*C+u*B+v*A-w*z+x*y;return E?(E=1/E,a[0]=(h*D-i*C+j*B)*E,a[1]=(e*C-d*D-f*B)*E,a[2]=(p*x-q*w+r*v)*E,a[3]=(m*w-l*x-n*v)*E,a[4]=(i*A-g*D-j*z)*E,a[5]=(c*D-e*A+f*z)*E,a[6]=(q*u-o*x-r*t)*E,a[7]=(k*x-m*u+n*t)*E,a[8]=(g*C-h*A+j*y)*E,a[9]=(d*A-c*C-f*y)*E,a[10]=(o*w-p*u+r*s)*E,a[11]=(l*u-k*w-n*s)*E,a[12]=(h*z-g*B-i*y)*E,a[13]=(c*B-d*z+e*y)*E,a[14]=(p*t-o*v-q*s)*E,a[15]=(k*v-l*t+m*s)*E,a):null},l.adjoint=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=b[4],h=b[5],i=b[6],j=b[7],k=b[8],l=b[9],m=b[10],n=b[11],o=b[12],p=b[13],q=b[14],r=b[15];return a[0]=h*(m*r-n*q)-l*(i*r-j*q)+p*(i*n-j*m),a[1]=-(d*(m*r-n*q)-l*(e*r-f*q)+p*(e*n-f*m)),a[2]=d*(i*r-j*q)-h*(e*r-f*q)+p*(e*j-f*i),a[3]=-(d*(i*n-j*m)-h*(e*n-f*m)+l*(e*j-f*i)),a[4]=-(g*(m*r-n*q)-k*(i*r-j*q)+o*(i*n-j*m)),a[5]=c*(m*r-n*q)-k*(e*r-f*q)+o*(e*n-f*m),a[6]=-(c*(i*r-j*q)-g*(e*r-f*q)+o*(e*j-f*i)),a[7]=c*(i*n-j*m)-g*(e*n-f*m)+k*(e*j-f*i),a[8]=g*(l*r-n*p)-k*(h*r-j*p)+o*(h*n-j*l),a[9]=-(c*(l*r-n*p)-k*(d*r-f*p)+o*(d*n-f*l)),a[10]=c*(h*r-j*p)-g*(d*r-f*p)+o*(d*j-f*h),a[11]=-(c*(h*n-j*l)-g*(d*n-f*l)+k*(d*j-f*h)),a[12]=-(g*(l*q-m*p)-k*(h*q-i*p)+o*(h*m-i*l)),a[13]=c*(l*q-m*p)-k*(d*q-e*p)+o*(d*m-e*l),a[14]=-(c*(h*q-i*p)-g*(d*q-e*p)+o*(d*i-e*h)),a[15]=c*(h*m-i*l)-g*(d*m-e*l)+k*(d*i-e*h),a},l.determinant=function(a){var b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],i=a[7],j=a[8],k=a[9],l=a[10],m=a[11],n=a[12],o=a[13],p=a[14],q=a[15],r=b*g-c*f,s=b*h-d*f,t=b*i-e*f,u=c*h-d*g,v=c*i-e*g,w=d*i-e*h,x=j*o-k*n,y=j*p-l*n,z=j*q-m*n,A=k*p-l*o,B=k*q-m*o,C=l*q-m*p;return r*C-s*B+t*A+u*z-v*y+w*x},l.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],p=b[12],q=b[13],r=b[14],s=b[15],t=c[0],u=c[1],v=c[2],w=c[3];return a[0]=t*d+u*h+v*l+w*p,a[1]=t*e+u*i+v*m+w*q,a[2]=t*f+u*j+v*n+w*r,a[3]=t*g+u*k+v*o+w*s,t=c[4],u=c[5],v=c[6],w=c[7],a[4]=t*d+u*h+v*l+w*p,a[5]=t*e+u*i+v*m+w*q,a[6]=t*f+u*j+v*n+w*r,a[7]=t*g+u*k+v*o+w*s,t=c[8],u=c[9],v=c[10],w=c[11],a[8]=t*d+u*h+v*l+w*p,a[9]=t*e+u*i+v*m+w*q,a[10]=t*f+u*j+v*n+w*r,a[11]=t*g+u*k+v*o+w*s,t=c[12],u=c[13],v=c[14],w=c[15],a[12]=t*d+u*h+v*l+w*p,a[13]=t*e+u*i+v*m+w*q,a[14]=t*f+u*j+v*n+w*r,a[15]=t*g+u*k+v*o+w*s,a},l.mul=l.multiply,l.translate=function(a,b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=c[0],q=c[1],r=c[2];return b===a?(a[12]=b[0]*p+b[4]*q+b[8]*r+b[12],a[13]=b[1]*p+b[5]*q+b[9]*r+b[13],a[14]=b[2]*p+b[6]*q+b[10]*r+b[14],a[15]=b[3]*p+b[7]*q+b[11]*r+b[15]):(d=b[0],e=b[1],f=b[2],g=b[3],h=b[4],i=b[5],j=b[6],k=b[7],l=b[8],m=b[9],n=b[10],o=b[11],a[0]=d,a[1]=e,a[2]=f,a[3]=g,a[4]=h,a[5]=i,a[6]=j,a[7]=k,a[8]=l,a[9]=m,a[10]=n,a[11]=o,a[12]=d*p+h*q+l*r+b[12],a[13]=e*p+i*q+m*r+b[13],a[14]=f*p+j*q+n*r+b[14],a[15]=g*p+k*q+o*r+b[15]),a},l.scale=function(a,b,c){var d=c[0],e=c[1],f=c[2];return a[0]=b[0]*d,a[1]=b[1]*d,a[2]=b[2]*d,a[3]=b[3]*d,a[4]=b[4]*e,a[5]=b[5]*e,a[6]=b[6]*e,a[7]=b[7]*e,a[8]=b[8]*f,a[9]=b[9]*f,a[10]=b[10]*f,a[11]=b[11]*f,a[12]=b[12],a[13]=b[13],a[14]=b[14],a[15]=b[15],a},l.rotate=function(a,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D=e[0],E=e[1],F=e[2],G=Math.sqrt(D*D+E*E+F*F);return Math.abs(G)h?(g.cross(a,b,e),g.length(a)<1e-6&&g.cross(a,c,e),g.normalize(a,a),m.setAxisAngle(d,a,Math.PI),d):h>.999999?(d[0]=0,d[1]=0,d[2]=0,d[3]=1,d):(g.cross(a,e,f),d[0]=a[0],d[1]=a[1],d[2]=a[2],d[3]=1+h,m.normalize(d,d))}}(),m.setAxes=function(){var a=k.create();return function(b,c,d,e){return a[0]=d[0],a[3]=d[1],a[6]=d[2],a[1]=e[0],a[4]=e[1],a[7]=e[2],a[2]=c[0],a[5]=c[1],a[8]=c[2],m.normalize(b,m.fromMat3(b,a))}}(),m.clone=h.clone,m.fromValues=h.fromValues,m.copy=h.copy,m.set=h.set,m.identity=function(a){return a[0]=0,a[1]=0,a[2]=0,a[3]=1,a},m.setAxisAngle=function(a,b,c){c*=.5;var d=Math.sin(c);return a[0]=d*b[0],a[1]=d*b[1],a[2]=d*b[2],a[3]=Math.cos(c),a},m.add=h.add,m.multiply=function(a,b,c){var d=b[0],e=b[1],f=b[2],g=b[3],h=c[0],i=c[1],j=c[2],k=c[3];return a[0]=d*k+g*h+e*j-f*i,a[1]=e*k+g*i+f*h-d*j,a[2]=f*k+g*j+d*i-e*h,a[3]=g*k-d*h-e*i-f*j,a},m.mul=m.multiply,m.scale=h.scale,m.rotateX=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+g*h,a[1]=e*i+f*h,a[2]=f*i-e*h,a[3]=g*i-d*h,a},m.rotateY=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i-f*h,a[1]=e*i+g*h,a[2]=f*i+d*h,a[3]=g*i-e*h,a},m.rotateZ=function(a,b,c){c*=.5;var d=b[0],e=b[1],f=b[2],g=b[3],h=Math.sin(c),i=Math.cos(c);return a[0]=d*i+e*h,a[1]=e*i-d*h,a[2]=f*i+g*h,a[3]=g*i-f*h,a},m.calculateW=function(a,b){var c=b[0],d=b[1],e=b[2];return a[0]=c,a[1]=d,a[2]=e,a[3]=-Math.sqrt(Math.abs(1-c*c-d*d-e*e)),a},m.dot=h.dot,m.lerp=h.lerp,m.slerp=function(a,b,c,d){var e,f,g,h,i,j=b[0],k=b[1],l=b[2],m=b[3],n=c[0],o=c[1],p=c[2],q=c[3];return f=j*n+k*o+l*p+m*q,0>f&&(f=-f,n=-n,o=-o,p=-p,q=-q),1-f>1e-6?(e=Math.acos(f),g=Math.sin(e),h=Math.sin((1-d)*e)/g,i=Math.sin(d*e)/g):(h=1-d,i=d),a[0]=h*j+i*n,a[1]=h*k+i*o,a[2]=h*l+i*p,a[3]=h*m+i*q,a},m.invert=function(a,b){var c=b[0],d=b[1],e=b[2],f=b[3],g=c*c+d*d+e*e+f*f,h=g?1/g:0;return a[0]=-c*h,a[1]=-d*h,a[2]=-e*h,a[3]=f*h,a},m.conjugate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a[2]=-b[2],a[3]=b[3],a},m.length=h.length,m.len=m.length,m.squaredLength=h.squaredLength,m.sqrLen=m.squaredLength,m.normalize=h.normalize,m.fromMat3=function(){var a="undefined"!=typeof Int8Array?new Int8Array([1,2,0]):[1,2,0];return function(b,c){var d,e=c[0]+c[4]+c[8];if(e>0)d=Math.sqrt(e+1),b[3]=.5*d,d=.5/d,b[0]=(c[7]-c[5])*d,b[1]=(c[2]-c[6])*d,b[2]=(c[3]-c[1])*d;else{var f=0;c[4]>c[0]&&(f=1),c[8]>c[3*f+f]&&(f=2);var g=a[f],h=a[g];d=Math.sqrt(c[3*f+f]-c[3*g+g]-c[3*h+h]+1),b[f]=.5*d,d=.5/d,b[3]=(c[3*h+g]-c[3*g+h])*d,b[g]=(c[3*g+f]+c[3*f+g])*d,b[h]=(c[3*h+f]+c[3*f+h])*d}return b}}(),m.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},"undefined"!=typeof a&&(a.quat=m)}(b.exports)}(this); \ No newline at end of file diff --git a/src/components/ArcadePhysics.ts b/src/components/ArcadePhysics.ts index 574fc739..151ec6c8 100644 --- a/src/components/ArcadePhysics.ts +++ b/src/components/ArcadePhysics.ts @@ -326,6 +326,22 @@ module Kiwi.Components { */ public parent: Kiwi.Entity; + /** + * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component. + * @method rotateToVelocity + * @return { Number } + * @public + */ + public rotateToVelocity (): number { + + var result: number = Math.atan2( this.velocity.y, this.velocity.x ); + + this.transform.rotation = result; + + return result; + + } + /* *--------------- diff --git a/templateGame/lib/kiwi.js b/templateGame/lib/kiwi.js index 6faaeb88..d6e0e1e3 100644 --- a/templateGame/lib/kiwi.js +++ b/templateGame/lib/kiwi.js @@ -8658,6 +8658,17 @@ var Kiwi; this._callbackFunction = callbackFunction; this._callbackContext = callbackContext; }; + /** + * Sets the parents rotation to be equal to the trajectory of the velocity of the physics component. + * @method rotateToVelocity + * @return { Number } + * @public + */ + ArcadePhysics.prototype.rotateToVelocity = function () { + var result = Math.atan2(this.velocity.y, this.velocity.x); + this.transform.rotation = result; + return result; + }; /* *--------------- * Seperation Code