Files
monkeygg2.github.io/games/vex-3/vex-3.min.js
T
2023-08-25 13:31:04 +05:30

1 line
1.5 MiB
Plaintext

!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory(global.h5branding=global.h5branding||{})}(this,function(exports){"use strict";var commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function createCommonjsModule(fn,module){return fn(module={exports:{}},module.exports),module.exports}var BrandingDomain,list;createCommonjsModule(function(module,exports){module.exports=function(){function isFunction(x){return"function"==typeof x}var isArray=Array.isArray?Array.isArray:function(x){return"[object Array]"===Object.prototype.toString.call(x)},len=0,vertxNext=void 0,customSchedulerFn=void 0,asap=function(callback,arg){queue[len]=callback,queue[len+1]=arg,2===(len+=2)&&(customSchedulerFn?customSchedulerFn(flush):scheduleFlush())},browserWindow="undefined"!=typeof window?window:void 0,browserGlobal=browserWindow||{},BrowserMutationObserver=browserGlobal.MutationObserver||browserGlobal.WebKitMutationObserver,isNode="undefined"==typeof self&&"undefined"!=typeof process&&"[object process]"==={}.toString.call(process),isWorker="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel;function useSetTimeout(){var globalSetTimeout=setTimeout;return function(){return globalSetTimeout(flush,1)}}var queue=new Array(1e3);function flush(){for(var i=0;i<len;i+=2){var callback=queue[i],arg=queue[i+1];callback(arg),queue[i]=void 0,queue[i+1]=void 0}len=0}var channel,iterations,observer,node,scheduleFlush=void 0;function then(onFulfillment,onRejection){var parent=this,child=new this.constructor(noop);void 0===child[PROMISE_ID]&&makePromise(child);var _state=parent._state;if(_state){var callback=arguments[_state-1];asap(function(){return invokeCallback(_state,child,callback,parent._result)})}else subscribe(parent,child,onFulfillment,onRejection);return child}function resolve$1(object){if(object&&"object"==typeof object&&object.constructor===this)return object;var promise=new this(noop);return resolve(promise,object),promise}scheduleFlush=isNode?function(){return process.nextTick(flush)}:BrowserMutationObserver?(iterations=0,observer=new BrowserMutationObserver(flush),node=document.createTextNode(""),observer.observe(node,{characterData:!0}),function(){node.data=iterations=++iterations%2}):isWorker?((channel=new MessageChannel).port1.onmessage=flush,function(){return channel.port2.postMessage(0)}):void 0===browserWindow?function(){try{var vertx=Function("return this")().require("vertx");return void 0===(vertxNext=vertx.runOnLoop||vertx.runOnContext)?useSetTimeout():function(){vertxNext(flush)}}catch(e){return useSetTimeout()}}():useSetTimeout();var PROMISE_ID=Math.random().toString(36).substring(2);function noop(){}var PENDING=void 0,FULFILLED=1,REJECTED=2;function tryThen(then$$1,value,fulfillmentHandler,rejectionHandler){try{then$$1.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function handleMaybeThenable(promise,maybeThenable,then$$1){maybeThenable.constructor===promise.constructor&&then$$1===then&&maybeThenable.constructor.resolve===resolve$1?function(promise,thenable){thenable._state===FULFILLED?fulfill(promise,thenable._result):thenable._state===REJECTED?reject(promise,thenable._result):subscribe(thenable,void 0,function(value){return resolve(promise,value)},function(reason){return reject(promise,reason)})}(promise,maybeThenable):void 0===then$$1?fulfill(promise,maybeThenable):isFunction(then$$1)?function(promise,thenable,then$$1){asap(function(promise){var sealed=!1,error=tryThen(then$$1,thenable,function(value){sealed||(sealed=!0,thenable!==value?resolve(promise,value):fulfill(promise,value))},function(reason){sealed||(sealed=!0,reject(promise,reason))},promise._label);!sealed&&error&&(sealed=!0,reject(promise,error))},promise)}(promise,maybeThenable,then$$1):fulfill(promise,maybeThenable)}function resolve(promise,value){if(promise===value)reject(promise,new TypeError("You cannot resolve a promise with itself"));else if(type=typeof(x=value),null===x||"object"!==type&&"function"!==type)fulfill(promise,value);else{var then$$1=void 0;try{then$$1=value.then}catch(error){return void reject(promise,error)}handleMaybeThenable(promise,value,then$$1)}var x,type}function publishRejection(promise){promise._onerror&&promise._onerror(promise._result),publish(promise)}function fulfill(promise,value){promise._state===PENDING&&(promise._result=value,promise._state=FULFILLED,0!==promise._subscribers.length&&asap(publish,promise))}function reject(promise,reason){promise._state===PENDING&&(promise._state=REJECTED,promise._result=reason,asap(publishRejection,promise))}function subscribe(parent,child,onFulfillment,onRejection){var _subscribers=parent._subscribers,length=_subscribers.length;parent._onerror=null,_subscribers[length]=child,_subscribers[length+FULFILLED]=onFulfillment,_subscribers[length+REJECTED]=onRejection,0===length&&parent._state&&asap(publish,parent)}function publish(promise){var subscribers=promise._subscribers,settled=promise._state;if(0!==subscribers.length){for(var child=void 0,callback=void 0,detail=promise._result,i=0;i<subscribers.length;i+=3)child=subscribers[i],callback=subscribers[i+settled],child?invokeCallback(settled,child,callback,detail):callback(detail);promise._subscribers.length=0}}function invokeCallback(settled,promise,callback,detail){var hasCallback=isFunction(callback),value=void 0,error=void 0,succeeded=!0;if(hasCallback){try{value=callback(detail)}catch(e){succeeded=!1,error=e}if(promise===value)return void reject(promise,new TypeError("A promises callback cannot return that same promise."))}else value=detail;promise._state!==PENDING||(hasCallback&&succeeded?resolve(promise,value):!1===succeeded?reject(promise,error):settled===FULFILLED?fulfill(promise,value):settled===REJECTED&&reject(promise,value))}var id=0;function makePromise(promise){promise[PROMISE_ID]=id++,promise._state=void 0,promise._result=void 0,promise._subscribers=[]}var Enumerator=function(){function Enumerator(Constructor,input){this._instanceConstructor=Constructor,this.promise=new Constructor(noop),this.promise[PROMISE_ID]||makePromise(this.promise),isArray(input)?(this.length=input.length,this._remaining=input.length,this._result=new Array(this.length),0===this.length?fulfill(this.promise,this._result):(this.length=this.length||0,this._enumerate(input),0===this._remaining&&fulfill(this.promise,this._result))):reject(this.promise,new Error("Array Methods must be provided an Array"))}return Enumerator.prototype._enumerate=function(input){for(var i=0;this._state===PENDING&&i<input.length;i++)this._eachEntry(input[i],i)},Enumerator.prototype._eachEntry=function(entry,i){var c=this._instanceConstructor,resolve$$1=c.resolve;if(resolve$$1===resolve$1){var _then=void 0,error=void 0,didError=!1;try{_then=entry.then}catch(e){didError=!0,error=e}if(_then===then&&entry._state!==PENDING)this._settledAt(entry._state,i,entry._result);else if("function"!=typeof _then)this._remaining--,this._result[i]=entry;else if(c===Promise$1){var promise=new c(noop);didError?reject(promise,error):handleMaybeThenable(promise,entry,_then),this._willSettleAt(promise,i)}else this._willSettleAt(new c(function(resolve$$1){return resolve$$1(entry)}),i)}else this._willSettleAt(resolve$$1(entry),i)},Enumerator.prototype._settledAt=function(state,i,value){var promise=this.promise;promise._state===PENDING&&(this._remaining--,state===REJECTED?reject(promise,value):this._result[i]=value),0===this._remaining&&fulfill(promise,this._result)},Enumerator.prototype._willSettleAt=function(promise,i){var enumerator=this;subscribe(promise,void 0,function(value){return enumerator._settledAt(FULFILLED,i,value)},function(reason){return enumerator._settledAt(REJECTED,i,reason)})},Enumerator}(),Promise$1=function(){function Promise(resolver){this[PROMISE_ID]=id++,this._result=this._state=void 0,this._subscribers=[],noop!==resolver&&("function"!=typeof resolver&&function(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}(),this instanceof Promise?function(promise,resolver){try{resolver(function(value){resolve(promise,value)},function(reason){reject(promise,reason)})}catch(e){reject(promise,e)}}(this,resolver):function(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}())}return Promise.prototype.catch=function(onRejection){return this.then(null,onRejection)},Promise.prototype.finally=function(callback){var constructor=this.constructor;return isFunction(callback)?this.then(function(value){return constructor.resolve(callback()).then(function(){return value})},function(reason){return constructor.resolve(callback()).then(function(){throw reason})}):this.then(callback,callback)},Promise}();return Promise$1.prototype.then=then,Promise$1.all=function(entries){return new Enumerator(this,entries).promise},Promise$1.race=function(entries){var Constructor=this;return isArray(entries)?new Constructor(function(resolve,reject){for(var length=entries.length,i=0;i<length;i++)Constructor.resolve(entries[i]).then(resolve,reject)}):new Constructor(function(_,reject){return reject(new TypeError("You must pass an array to race."))})},Promise$1.resolve=resolve$1,Promise$1.reject=function(reason){var promise=new this(noop);return reject(promise,reason),promise},Promise$1._setScheduler=function(scheduleFn){customSchedulerFn=scheduleFn},Promise$1._setAsap=function(asapFn){asap=asapFn},Promise$1._asap=asap,Promise$1.polyfill=function(){var local=void 0;if(void 0!==commonjsGlobal)local=commonjsGlobal;else if("undefined"!=typeof self)local=self;else try{local=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var P=local.Promise;if(P){var promiseToString=null;try{promiseToString=Object.prototype.toString.call(P.resolve())}catch(e){}if("[object Promise]"===promiseToString&&!P.cast)return}local.Promise=Promise$1},Promise$1.Promise=Promise$1}()}).polyfill();(BrandingDomain=exports.BrandingDomain||(exports.BrandingDomain={}))[BrandingDomain.Neutral=0]="Neutral",BrandingDomain[BrandingDomain.Yepi=1]="Yepi",BrandingDomain[BrandingDomain.Spele=2]="Spele",BrandingDomain[BrandingDomain.Funnygames=3]="Funnygames",BrandingDomain[BrandingDomain.Kizi=4]="Kizi",BrandingDomain[BrandingDomain.PlayCell=5]="PlayCell",BrandingDomain[BrandingDomain.GameCell=6]="GameCell",BrandingDomain[BrandingDomain.Bild=7]="Bild",BrandingDomain[BrandingDomain.AGame=8]="AGame",BrandingDomain[BrandingDomain.Admeen=9]="Admeen",BrandingDomain[BrandingDomain.PlayTime=10]="PlayTime",BrandingDomain[BrandingDomain.Zigiz=11]="Zigiz";var UtmTargets,Sld=function(){function Sld(){}return Sld.has=function(domain){var tldOffset=domain.lastIndexOf(".");if(tldOffset<=0||tldOffset>=domain.length-1)return!1;var sldOffset=domain.lastIndexOf(".",tldOffset-1);if(sldOffset<=0||tldOffset-1<=sldOffset)return!1;var sldList=list[domain.slice(tldOffset+1)];return!!sldList&&0<=sldList.indexOf(" "+domain.slice(sldOffset+1,tldOffset)+" ")},Sld.is=function(domain){var tldOffset=domain.lastIndexOf(".");if(tldOffset<=0||tldOffset>=domain.length-1)return!1;if(0<=domain.lastIndexOf(".",tldOffset-1))return!1;var sldList=list[domain.slice(tldOffset+1)];return!!sldList&&0<=sldList.indexOf(" "+domain.slice(0,tldOffset)+" ")},Sld.get=function(domain){var tldOffset=domain.lastIndexOf(".");if(tldOffset<=0||tldOffset>=domain.length-1)return null;var sldOffset=domain.lastIndexOf(".",tldOffset-1);if(sldOffset<=0||tldOffset-1<=sldOffset)return null;var sldList=list[domain.slice(tldOffset+1)];return sldList?sldList.indexOf(" "+domain.slice(sldOffset+1,tldOffset)+" ")<0?null:domain.slice(sldOffset+1):null},Sld}(),Domain=function(){function Domain(){}return Domain.setList=function(newList){list=newList||{}},Domain.getDomain=function(host){if(!list)return null;var t=host.match(/\./g);if(t&&t.length<2)return host;var tld=this.getTld(host);if(!tld)return null;var end=host.length-tld.length-1;return end=host.lastIndexOf(".",end-1)+1,host.substring(end)||""},Domain.getTld=function(host){if(!list)return"";var pos=host.lastIndexOf("."),tld=host.substring(pos+1);return list[tld.toLowerCase()]&&Sld.get(host)||tld},Domain.KEY="Domains",Domain}(),Loader=function(){function Loader(){this.cache={}}return Object.defineProperty(Loader,"instance",{get:function(){return void 0===Loader.classInstance&&(Loader.classInstance=new Loader),Loader.classInstance},enumerable:!1,configurable:!0}),Loader.prototype.load=function(key,url,contentType){var _this=this;return this.contains(key)?Promise.reject("Already in cache."):(this.cache[key]={url:url,data:null},this.requestXhr(url,contentType).then(function(data){return _this.loadComplete(key,data)}).catch(function(e){return _this.remove(key),Promise.reject(e)}))},Loader.prototype.loadComplete=function(key,data){if(!this.contains(key))return Promise.reject("Item was removed from cache before loading was complete.");try{var json=JSON.parse(data);return this.cache[key].data=json,Promise.resolve(json)}catch(error){return Promise.reject("There was an error parsing JSON file.")}},Loader.prototype.remove=function(key){this.contains(key)&&delete this.cache[key]},Loader.prototype.get=function(key){return this.contains(key)?this.cache[key].data:null},Loader.prototype.contains=function(key){return this.cache.hasOwnProperty(key)},Loader.prototype.isLoading=function(key){return this.contains(key)&&null===this.cache[key].data},Loader.prototype.isLoaded=function(key){return this.contains(key)&&null!==this.cache[key].data},Loader.prototype.loadScript=function(url,deferred,callback){return void 0===deferred&&(deferred=!0),new Promise(function(resolve,reject){var tag=document.createElement("script");tag.src=url,tag.async=!1,tag.onload=function(){"function"==typeof callback&&callback(),resolve()},document.head.appendChild(tag)})},Loader.prototype.requestXhr=function(url,contentType){var xhr;return void 0===contentType&&(contentType="application/json"),window.XMLHttpRequest?(xhr=new XMLHttpRequest,new Promise(function(resolve,reject){xhr.onreadystatechange=function(){4===xhr.readyState&&(200===xhr.status?(resolve(xhr.responseText),xhr.onreadystatechange=null):0<xhr.status&&(reject("There was a problem with the request: status "+xhr.status),xhr.onreadystatechange=null))};try{xhr.open("GET",url,!0),xhr.setRequestHeader("Content-Type",contentType),xhr.send()}catch(e){reject("Error: Unable to send request, CORS not allowed.")}})):Promise.reject("Unable to send request, XMLHttpRequest not supported.")},Loader}();function addScript(src,buster,callback){var s=document.createElement("script");s.setAttribute("src",src+"?v="+buster),"function"==typeof callback&&(s.onload=callback),document.body.appendChild(s)}(UtmTargets=exports.UtmTargets||(exports.UtmTargets={}))[UtmTargets.splashscreen=0]="splashscreen",UtmTargets[UtmTargets.logo=1]="logo",UtmTargets[UtmTargets.facebook=2]="facebook",UtmTargets[UtmTargets.twitter=3]="twitter",UtmTargets[UtmTargets.playstore=4]="playstore",UtmTargets[UtmTargets.appstore=5]="appstore",UtmTargets[UtmTargets.more_games=6]="more_games",UtmTargets[UtmTargets.download_game=7]="download_game",UtmTargets[UtmTargets.walkthrough=8]="walkthrough",UtmTargets[UtmTargets.disclaimer=9]="disclaimer",UtmTargets[UtmTargets.highscores=10]="highscores";var h,s,PortalScripts=function(){function PortalScripts(){}return PortalScripts.loadPortalScript=function(siteLockList){siteLockList&&siteLockList.hasOwnProperty("minijuegos")&&-1!==siteLockList.minijuegos.indexOf(Utils.getSourceSite())&&(void 0!==window.mpConfig?window.mpConfig.partner="orange-games":window.mpConfig={partner:"orange-games"},addScript("https://ext.minijuegosgratis.com/external-host/main.js",Date.now()/1e3)),siteLockList&&siteLockList.hasOwnProperty("kongregate")&&-1!==siteLockList.kongregate.indexOf(Utils.getSourceSite())&&addScript("https://cdn1.kongregate.com/javascripts/kongregate_api.js",Date.now()/1e3,function(){"undefined"!=typeof kongregateAPI&&kongregateAPI.loadAPI(function(){window.kongregate=kongregateAPI.getAPI()})}),siteLockList&&siteLockList.hasOwnProperty("newgrounds")&&-1!==siteLockList.newgrounds.indexOf(Utils.getSourceSite())&&addScript("https://cdn.fbrq.io/@azerion/splash/assets/scripts/newgroundsio.min.js",Date.now()/1e3)},PortalScripts}(),Branding$$1=function(){function Branding$$1(){}return Branding$$1.preload=function(version){var promise=Promise.all([Loader.instance.load(Domain.KEY,Utils.ASSET_LOCATION+"json/domains.json?v="+version,"text/plain"),Loader.instance.load(Branding$$1.SITELOCK_PORTALS,Utils.ASSET_LOCATION+"json/sitelock.json?v="+version,"text/plain")]);return Promise.all([Loader.instance.load(Branding$$1.INTERNAL_PORTALS_KEY,Utils.ASSET_LOCATION+"json/internal.json?v="+version,"text/plain"),Loader.instance.load(Branding$$1.CONTRACTED_PORTALS_KEY,Utils.ASSET_LOCATION+"json/contracted.json?v="+version,"text/plain"),Loader.instance.load(Branding$$1.SPECIAL_PORTALS_KEY,Utils.ASSET_LOCATION+"json/special.json?v="+version,"text/plain")]),promise.then(function(data){var domains=data[0],sitelock=data[1];Domain.setList(domains),PortalScripts.loadPortalScript(sitelock),Branding$$1.setSiteLock(sitelock)}).catch(function(){})},Branding$$1.setSiteLock=function(data){Branding$$1.siteLocks=data},Object.defineProperty(Branding$$1,"brandingLogoUrl",{get:function(){var imageName;switch(Utils.isOnDevice()||Branding$$1.isAirfi()?Utils.ASSET_LOCATION="assets/":"fbrq.io"===Utils.getSourceSite(!0)&&(Utils.ASSET_LOCATION="https://"+window.location.host+"/@azerion/splash/assets/"),Utils.getBrandingDomain()){case exports.BrandingDomain.Spele:imageName="spele";break;case exports.BrandingDomain.PlayCell:imageName="playcell";break;case exports.BrandingDomain.GameCell:imageName="gamecell";break;case exports.BrandingDomain.Yepi:imageName="yepi";break;case exports.BrandingDomain.Admeen:imageName="admeen";break;case exports.BrandingDomain.Bild:imageName="bild";break;case exports.BrandingDomain.Kizi:imageName="kizi";break;case exports.BrandingDomain.Funnygames:imageName="funnygames";break;case exports.BrandingDomain.PlayTime:imageName="playtime";break;default:case exports.BrandingDomain.AGame:imageName="agame";break;case exports.BrandingDomain.Zigiz:imageName="zigiz"}return Utils.ASSET_LOCATION+"images/branding_logo_"+imageName+"_small.png"},enumerable:!1,configurable:!0}),Object.defineProperty(Branding$$1,"brandingBackgroundColor",{get:function(){var bgColor;switch(Utils.getBrandingDomain()){case exports.BrandingDomain.Spele:bgColor="#4a72ad";break;case exports.BrandingDomain.PlayCell:bgColor="#52a1e1";break;case exports.BrandingDomain.GameCell:bgColor="#c600b2";break;case exports.BrandingDomain.Yepi:bgColor="#0573a7";break;case exports.BrandingDomain.AGame:bgColor="#0C486C";break;case exports.BrandingDomain.Admeen:bgColor="#4267B2";break;case exports.BrandingDomain.Bild:bgColor="#de0000";break;default:case exports.BrandingDomain.Kizi:bgColor="#012f50";break;case exports.BrandingDomain.Funnygames:bgColor="#33b0ff";break;case exports.BrandingDomain.PlayTime:case exports.BrandingDomain.Zigiz:bgColor="#023a63"}return bgColor},enumerable:!1,configurable:!0}),Branding$$1.openCampaignLink=function(gameTitle,type){if(!Utils.isOnDevice()&&!Branding$$1.isSpecial()&&Branding$$1.outGoingLinksAllowed()){var url,win,host=Utils.getSourceSite(),protocol=Utils.isOnDevice()?"https://":"//";switch(Utils.getBrandingDomain()){case exports.BrandingDomain.Spele:url=protocol+"www.spele.nl";break;case exports.BrandingDomain.Yepi:url=protocol+"www.yepi.com";break;case exports.BrandingDomain.Admeen:return url="https://media.admeen.com/branding/link.php",void((win=window.open(url,"_blank"))&&win.focus&&win.focus());case exports.BrandingDomain.PlayCell:url=protocol+"www.playcell.com";break;case exports.BrandingDomain.GameCell:url=protocol+"www.gamecell.com";break;case exports.BrandingDomain.Kizi:url=protocol+"www.kizi.com";break;case exports.BrandingDomain.Bild:return void((win=window.open(protocol+"www.bildspielt.de","_blank"))&&win.focus&&win.focus());case exports.BrandingDomain.Funnygames:url=protocol+"www.funnygames.nu";break;case exports.BrandingDomain.PlayTime:url=protocol+"playtime.nl";break;default:case exports.BrandingDomain.AGame:url=protocol+"www.agame.com";break;case exports.BrandingDomain.Zigiz:url=protocol+"m.zigiz.com"}var utmContent="string"==typeof type?type:exports.UtmTargets[type];(win=window.open(url+"/?utm_source="+host+"&utm_medium=html5&utm_term="+gameTitle+"&utm_content="+utmContent+"&utm_campaign=Gamedistribution","_blank"))&&win.focus&&win.focus()}},Branding$$1.isInternal=function(){return Branding$$1.hostMatchesList(Loader.instance.get(Branding$$1.INTERNAL_PORTALS_KEY))},Branding$$1.isContracted=function(){return Branding$$1.hostMatchesList(Loader.instance.get(Branding$$1.CONTRACTED_PORTALS_KEY))},Branding$$1.isSpecial=function(){return Branding$$1.hostMatchesList(Loader.instance.get(Branding$$1.SPECIAL_PORTALS_KEY))},Branding$$1.isAdmeen=function(){if(!Branding$$1.siteLocks||!Branding$$1.siteLocks.hasOwnProperty("admeen"))return!1;var admeen=Branding$$1.siteLocks.admeen;return Branding$$1.hostMatchesList(admeen)},Branding$$1.isKongregate=function(){if(!Branding$$1.siteLocks||!Branding$$1.siteLocks.hasOwnProperty("kongregate"))return!1;var kongregate=Branding$$1.siteLocks.kongregate;return Branding$$1.hostMatchesList(kongregate)},Branding$$1.isNewgrounds=function(){if(!Branding$$1.siteLocks||!Branding$$1.siteLocks.hasOwnProperty("newgrounds"))return!1;var newgrounds=Branding$$1.siteLocks.newgrounds;return Branding$$1.hostMatchesList(newgrounds)},Branding$$1.isBild=function(){return"bild.fbrq.io"===window.location.host||-1!==window.location.host.indexOf("contentfleet.com")},Branding$$1.isPlaytime=function(){return-1!==window.location.host.indexOf("playtime.nl")},Branding$$1.isBip=function(){return-1!==window.location.search.indexOf("bipgaming")||"bip.fbrq.io"===window.location.host},Branding$$1.isPlaycellApp=function(){return-1!==window.location.search.indexOf("playcellApp")},Branding$$1.isAGame=function(){return-1!==window.location.search.indexOf("agame")},Branding$$1.isAirfi=function(){return!!window.hasOwnProperty("airfi")&&window.airfi},Branding$$1.outGoingLinksAllowed=function(){return!(Branding$$1.isAirfi()||Branding$$1.isSpecial()||Branding$$1.isContracted())&&(!window.hasOwnProperty("fbrqLA")||window.fbrqLA)},Branding$$1.hostMatchesList=function(portals){portals=portals||[];for(var host=Utils.getSourceSite(),id=0;id<portals.length;id++)if(host===portals[id])return!0;return!1},Branding$$1.LOGO_KEY="branding_logo",Branding$$1.INTERNAL_PORTALS_KEY="branding_portals",Branding$$1.CONTRACTED_PORTALS_KEY="branding_contracted",Branding$$1.SPECIAL_PORTALS_KEY="branding_special",Branding$$1.SITELOCK_PORTALS="sitelock_portals",Branding$$1.DOMAIN_OVERWRITE=null,Branding$$1.analyticsEnabled=!0,Branding$$1}(),Utils=function(){function Utils(){}return Utils.getSourceSite=function(forceLocal){void 0===forceLocal&&(forceLocal=!1);var host=document.referrer||window.location.host;if(forceLocal&&(host=window.location.host),-1!==host.indexOf("embed.gamedistribution.com")&&-1!==window.location.search.indexOf("gd_sdk_referrer_url")&&(host=Utils.getUrlParameter("gd_sdk_referrer_url")||host),host=decodeURIComponent(host),Branding$$1.isBild())return"bildspielt.de";if(Branding$$1.isBip())return"bipgaming.com";host=(host=-1<host.indexOf("://")?host.split("/")[2]:host.split("/")[0]).split(":")[0];var newHost=Domain.getDomain(host);return null!==newHost?newHost:(3===host.split(".").length&&(host=host.substr(host.indexOf(".")+1)),host)},Utils.getBrandingDomain=function(){if(window.hasOwnProperty("fbrqBD")&&window.fbrqBD in exports.BrandingDomain)return window.fbrqBD;if(Branding$$1.DOMAIN_OVERWRITE)return Branding$$1.DOMAIN_OVERWRITE;var source=Utils.getSourceSite();if(Branding$$1.isAdmeen())return exports.BrandingDomain.Admeen;if(Branding$$1.isPlaycellApp()||Branding$$1.isBip())return exports.BrandingDomain.PlayCell;switch(source){case"spele.nl":return exports.BrandingDomain.Spele;case"yepi.com":return exports.BrandingDomain.Yepi;case"oyunskor.com":case"barbioyunu.com.tr":case"bebekoyunu.com.tr":case"oyunkolu.com":case"oyungemisi.com":case"oyunlar1.com":case"oyunkuzusu.com":case"kraloyun.com":case"rekoroyun.com":case"oyundedem.com":case"oyunoyna.com":case"pastaoyunu.com.tr":case"playcell.com":return exports.BrandingDomain.PlayCell;case"gamecell.com":return exports.BrandingDomain.GameCell;case"playxl.com":return exports.BrandingDomain.Admeen;case"kizi.com":return exports.BrandingDomain.Kizi;case"bildspielt.de":return exports.BrandingDomain.Bild;case"funnygames.nl":return exports.BrandingDomain.Funnygames;case"playtime.nl":return exports.BrandingDomain.PlayTime;default:case"agame.com":return exports.BrandingDomain.AGame;case"gmbl.nl":case"zigiz.com":return exports.BrandingDomain.Zigiz;case"coolmathgames.com":return exports.BrandingDomain.Neutral}},Utils.getReferrer=function(host){return-1!==host.indexOf("?ref=")?host.substr(host.indexOf("?ref=")+5):host},Utils.inIframe=function(){try{return window.self!==window.top}catch(e){return!0}},Utils.inGDGameZone=function(){return-1!==document.referrer.indexOf("html5.gamedistribution.com")},Utils.getDomain=function(uri){var parser=document.createElement("a");return parser.href=uri,parser.origin},Utils.isOnDevice=function(){return void 0!==window.cordova&&!/(gamedistribution\.com)/.test(window.location.hostname)},Utils.isTc=function(){return/(teamcity\.azerdev\.com)/.test(window.location.host)},Utils.getRandomRange=function(min,max){return Math.random()*(max-min)+min|0},Utils.getUrlParameter=function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var results=new RegExp("[\\?&]"+name+"=([^&#]*)").exec(location.search);return null===results?"":decodeURIComponent(results[1].replace(/\+/g," "))},Utils.intTimeToString=function(time){var hours=Math.floor(time/3600),minutes=Math.floor(time%3600/60),seconds=time%60;return(hours<10?"0"+hours:hours.toString())+":"+(minutes<10?"0"+minutes:minutes.toString())+":"+(seconds<10?"0"+seconds:seconds.toString())},Utils.LANGUAGE="en",Utils.ASSET_LOCATION=window.hasOwnProperty("fbrqSA")&&!0===window.fbrqSA?"assets/":"./fbrq/",Utils}(),GoogleAnalytics=function(){function GoogleAnalytics(){this.fbrqId="UA-60359297-50"}return GoogleAnalytics.addScript=function(){return Branding$$1.analyticsEnabled?new Promise(function(resolve,reject){var s=document.createElement("script"),src="js/null.js?https://www.googletagmanager.com/gtag/js?id="+GoogleAnalytics.GAMeasurementId;s.setAttribute("src",src),s.async=!0,s.onload=function(){resolve({loaded:!0})},document.head.appendChild(s)}):Promise.resolve()},GoogleAnalytics.preload=function(){return Branding$$1.analyticsEnabled&&GoogleAnalytics.addScript().then(function(result,error){return new Promise(function(resolve,reject){result.loaded&&(window.hasOwnProperty("dataLayer")&&(window.dataLayer=window.dataLayer||[]),gtag=function(){window.hasOwnProperty("dataLayer")&&window.dataLayer.push(arguments)}),resolve()})}),Promise.resolve()},GoogleAnalytics.prototype.setup=function(analyticsId,appName,appVersion,trackerWrapper,sampleRate){if(void 0===appName&&(appName="none"),void 0===appVersion&&(appVersion="none"),void 0===trackerWrapper&&(trackerWrapper="auto"),void 0===sampleRate&&(sampleRate=100),"function"!=typeof gtag)return null;if(!Branding$$1.analyticsEnabled){var disableID="ga-disable-"+analyticsId;return window.hasOwnProperty(disableID)&&(window.disableID=!Branding$$1.analyticsEnabled),null}var referrer="none";Branding$$1.isAGame()&&(referrer=Utils.getReferrer(decodeURIComponent(document.referrer))),gtag("js",new Date),gtag("set","user_properties",{app_name:appName,app_version:appVersion,referrer:referrer}),gtag("config",analyticsId,{sample_rate:sampleRate});var settings={name:"fbrq",sample_rate:1,referrer:referrer,app_name:"All"};if("auto"!==trackerWrapper)for(var key in trackerWrapper)trackerWrapper.hasOwnProperty(key)&&(settings[key]=trackerWrapper[key]);return gtag("config",this.fbrqId,settings),gtag},GoogleAnalytics.prototype.sendScreenView=function(screenName){Branding$$1.analyticsEnabled&&("undefined"==typeof gtag&&"function"!=typeof gtag||(gtag("event","screen_view",{screen_name:screenName}),gtag("event","screen_view",{send_to:this.fbrqId,screen_name:screenName})))},GoogleAnalytics.prototype.sendGenericEvent=function(category,action,label){Branding$$1.analyticsEnabled&&("undefined"==typeof gtag&&"function"!=typeof gtag||(gtag("event",action,{event_category:category,event_label:label}),gtag("event",action,{send_to:this.fbrqId,event_category:category,event_label:label})))},GoogleAnalytics.GAMeasurementId="none",GoogleAnalytics}(),CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;return a&&c.mixIn(a),c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)}),(c.init.prototype=c).$super=this,c},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[],this.sigBytes=null!=c?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;if(a=a.sigBytes,this.clamp(),b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-e%4*8&255)<<24-(b+e)%4*8;else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);return this.sigBytes+=a,this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<32-c%4*8,a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);return a.words=this.words.slice(0),a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*h.random()|0);return new r.init(c,a)}}),l=f.enc={},k=l.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-b%4*8&255;d.push((e>>>4).toString(16)),d.push((15&e).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,2),16)<<24-b%8*4;return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-b%4*8&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(255&a.charCodeAt(b))<<24-b%4*8;return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data")}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init,this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e);if(a=(f=a?h.ceil(f):h.max((0|f)-this._minBufferSize,0))*e,b=h.min(4*a,b),a){for(var g=0;g<a;g+=e)this._doProcessBlock(d,g);g=d.splice(0,a),c.sigBytes-=b}return new r.init(g,b)},clone:function(){var a=m.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});g.Hasher=u.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset()},reset:function(){u.reset.call(this),this._doReset()},update:function(a){return this._append(a),this._process(),this},finalize:function(a){return a&&this._append(a),this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return new a.init(d).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return new t.HMAC.init(a,d).finalize(c)}}});var t=f.algo={};return f}(Math);!function(h){for(var s=CryptoJS,g=(f=s.lib).WordArray,q=f.Hasher,f=s.algo,m=[],r=[],l=function(a){return 4294967296*(a-(0|a))|0},k=2,n=0;n<64;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(n<8&&(m[n]=l(h.pow(k,.5))),r[n]=l(h.pow(k,1/3)),n++),k++}var a=[];f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;p<64;p++){if(p<16)a[p]=0|c[d+p];else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p],l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g),q=n,n=m,m=h,h=j+k|0,j=g,g=f,f=e,e=k+l|0}b[0]=b[0]+e|0,b[1]=b[1]+f|0,b[2]=b[2]+g|0,b[3]=b[3]+j|0,b[4]=b[4]+h|0,b[5]=b[5]+m|0,b[6]=b[6]+n|0,b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;return d[e>>>5]|=128<<24-e%32,d[14+(e+64>>>9<<4)]=h.floor(b/4294967296),d[15+(e+64>>>9<<4)]=b,a.sigBytes=4*d.length,this._process(),this._hash},clone:function(){var a=q.clone.call(this);return a._hash=this._hash.clone(),a}});s.SHA256=q._createHelper(f),s.HmacSHA256=q._createHmacHelper(f)}(Math),s=(h=CryptoJS).enc.Utf8,h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init,"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g)),g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j<h;j++)k[j]^=1549556828,n[j]^=909522486;r.sigBytes=l.sigBytes=m,this.reset()},reset:function(){var f=this._hasher;f.reset(),f.update(this._iKey)},update:function(f){return this._hasher.update(f),this},finalize:function(f){var g=this._hasher;return f=g.finalize(f),g.reset(),g.finalize(this._oKey.clone().concat(f))}}),function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp(),b=[];for(var a=0;a<f;a+=3)for(var d=(e[a>>>2]>>>24-a%4*8&255)<<16|(e[a+1>>>2]>>>24-(a+1)%4*8&255)<<8|e[a+2>>>2]>>>24-(a+2)%4*8&255,g=0;g<4&&a+.75*g<f;g++)b.push(c.charAt(d>>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var e=b.length,f=this._map;(c=f.charAt(64))&&(-1!=(c=b.indexOf(c))&&(e=c));for(var c=[],a=0,d=0;d<e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<d%4*2,h=f.indexOf(b.charAt(d))>>>6-d%4*2;c[a>>>2]|=(g|h)<<24-a%4*8,a++}return j.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),function(gameanalytics){!function(EGAErrorSeverity){EGAErrorSeverity[EGAErrorSeverity.Undefined=0]="Undefined",EGAErrorSeverity[EGAErrorSeverity.Debug=1]="Debug",EGAErrorSeverity[EGAErrorSeverity.Info=2]="Info",EGAErrorSeverity[EGAErrorSeverity.Warning=3]="Warning",EGAErrorSeverity[EGAErrorSeverity.Error=4]="Error",EGAErrorSeverity[EGAErrorSeverity.Critical=5]="Critical"}(gameanalytics.EGAErrorSeverity||(gameanalytics.EGAErrorSeverity={})),function(EGAGender){EGAGender[EGAGender.Undefined=0]="Undefined",EGAGender[EGAGender.Male=1]="Male",EGAGender[EGAGender.Female=2]="Female"}(gameanalytics.EGAGender||(gameanalytics.EGAGender={})),function(EGAProgressionStatus){EGAProgressionStatus[EGAProgressionStatus.Undefined=0]="Undefined",EGAProgressionStatus[EGAProgressionStatus.Start=1]="Start",EGAProgressionStatus[EGAProgressionStatus.Complete=2]="Complete",EGAProgressionStatus[EGAProgressionStatus.Fail=3]="Fail"}(gameanalytics.EGAProgressionStatus||(gameanalytics.EGAProgressionStatus={})),function(EGAResourceFlowType){EGAResourceFlowType[EGAResourceFlowType.Undefined=0]="Undefined",EGAResourceFlowType[EGAResourceFlowType.Source=1]="Source",EGAResourceFlowType[EGAResourceFlowType.Sink=2]="Sink"}(gameanalytics.EGAResourceFlowType||(gameanalytics.EGAResourceFlowType={})),function(http){!function(EGASdkErrorType){EGASdkErrorType[EGASdkErrorType.Undefined=0]="Undefined",EGASdkErrorType[EGASdkErrorType.Rejected=1]="Rejected"}(http.EGASdkErrorType||(http.EGASdkErrorType={})),function(EGAHTTPApiResponse){EGAHTTPApiResponse[EGAHTTPApiResponse.NoResponse=0]="NoResponse",EGAHTTPApiResponse[EGAHTTPApiResponse.BadResponse=1]="BadResponse",EGAHTTPApiResponse[EGAHTTPApiResponse.RequestTimeout=2]="RequestTimeout",EGAHTTPApiResponse[EGAHTTPApiResponse.JsonEncodeFailed=3]="JsonEncodeFailed",EGAHTTPApiResponse[EGAHTTPApiResponse.JsonDecodeFailed=4]="JsonDecodeFailed",EGAHTTPApiResponse[EGAHTTPApiResponse.InternalServerError=5]="InternalServerError",EGAHTTPApiResponse[EGAHTTPApiResponse.BadRequest=6]="BadRequest",EGAHTTPApiResponse[EGAHTTPApiResponse.Unauthorized=7]="Unauthorized",EGAHTTPApiResponse[EGAHTTPApiResponse.UnknownResponseCode=8]="UnknownResponseCode",EGAHTTPApiResponse[EGAHTTPApiResponse.Ok=9]="Ok"}(http.EGAHTTPApiResponse||(http.EGAHTTPApiResponse={}))}(gameanalytics.http||(gameanalytics.http={}))}(gameanalytics||(gameanalytics={}));var gameanalytics;gameanalytics.EGAErrorSeverity,gameanalytics.EGAGender,gameanalytics.EGAProgressionStatus,gameanalytics.EGAResourceFlowType;!function(gameanalytics){!function(logging){var EGALoggerMessageType;!function(EGALoggerMessageType){EGALoggerMessageType[EGALoggerMessageType.Error=0]="Error",EGALoggerMessageType[EGALoggerMessageType.Warning=1]="Warning",EGALoggerMessageType[EGALoggerMessageType.Info=2]="Info",EGALoggerMessageType[EGALoggerMessageType.Debug=3]="Debug"}(EGALoggerMessageType||(EGALoggerMessageType={}));var GALogger=function(){function GALogger(){GALogger.debugEnabled=!1}return GALogger.setInfoLog=function(value){GALogger.instance.infoLogEnabled=value},GALogger.setVerboseLog=function(value){GALogger.instance.infoLogVerboseEnabled=value},GALogger.i=function(format){if(GALogger.instance.infoLogEnabled){var message="Info/"+GALogger.Tag+": "+format;GALogger.instance.sendNotificationMessage(message,EGALoggerMessageType.Info)}},GALogger.w=function(format){var message="Warning/"+GALogger.Tag+": "+format;GALogger.instance.sendNotificationMessage(message,EGALoggerMessageType.Warning)},GALogger.e=function(format){var message="Error/"+GALogger.Tag+": "+format;GALogger.instance.sendNotificationMessage(message,EGALoggerMessageType.Error)},GALogger.ii=function(format){if(GALogger.instance.infoLogVerboseEnabled){var message="Verbose/"+GALogger.Tag+": "+format;GALogger.instance.sendNotificationMessage(message,EGALoggerMessageType.Info)}},GALogger.d=function(format){if(GALogger.debugEnabled){var message="Debug/"+GALogger.Tag+": "+format;GALogger.instance.sendNotificationMessage(message,EGALoggerMessageType.Debug)}},GALogger.prototype.sendNotificationMessage=function(message,type){switch(type){case EGALoggerMessageType.Error:case EGALoggerMessageType.Warning:break;case EGALoggerMessageType.Debug:console.debug;break;case EGALoggerMessageType.Info:}},GALogger.instance=new GALogger,GALogger.Tag="GameAnalytics",GALogger}();logging.GALogger=GALogger}(gameanalytics.logging||(gameanalytics.logging={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(utilities){var GALogger=gameanalytics.logging.GALogger,GAUtilities=function(){function GAUtilities(){}return GAUtilities.getHmac=function(key,data){var encryptedMessage=CryptoJS.HmacSHA256(data,key);return CryptoJS.enc.Base64.stringify(encryptedMessage)},GAUtilities.stringMatch=function(s,pattern){return!(!s||!pattern)&&pattern.test(s)},GAUtilities.joinStringArray=function(v,delimiter){for(var result="",i=0,il=v.length;i<il;i++)0<i&&(result+=delimiter),result+=v[i];return result},GAUtilities.stringArrayContainsString=function(array,search){if(0===array.length)return!1;for(var s in array)if(array[s]===search)return!0;return!1},GAUtilities.encode64=function(input){input=encodeURI(input);for(var chr1,chr2,enc1,enc2,enc3,output="",chr3=0,enc4=0,i=0;enc1=(chr1=input.charCodeAt(i++))>>2,enc2=(3&chr1)<<4|(chr2=input.charCodeAt(i++))>>4,enc3=(15&chr2)<<2|(chr3=input.charCodeAt(i++))>>6,enc4=63&chr3,isNaN(chr2)?enc3=enc4=64:isNaN(chr3)&&(enc4=64),output=output+GAUtilities.keyStr.charAt(enc1)+GAUtilities.keyStr.charAt(enc2)+GAUtilities.keyStr.charAt(enc3)+GAUtilities.keyStr.charAt(enc4),chr1=chr2=chr3=0,enc1=enc2=enc3=enc4=0,i<input.length;);return output},GAUtilities.decode64=function(input){var chr1,chr2,enc2,enc3,output="",chr3=0,enc4=0,i=0;for(/[^A-Za-z0-9\+\/\=]/g.exec(input)&&GALogger.w("There were invalid base64 characters in the input text. Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='. Expect errors in decoding."),input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");chr1=GAUtilities.keyStr.indexOf(input.charAt(i++))<<2|(enc2=GAUtilities.keyStr.indexOf(input.charAt(i++)))>>4,chr2=(15&enc2)<<4|(enc3=GAUtilities.keyStr.indexOf(input.charAt(i++)))>>2,chr3=(3&enc3)<<6|(enc4=GAUtilities.keyStr.indexOf(input.charAt(i++))),output+=String.fromCharCode(chr1),64!=enc3&&(output+=String.fromCharCode(chr2)),64!=enc4&&(output+=String.fromCharCode(chr3)),chr1=chr2=chr3=0,enc2=enc3=enc4=0,i<input.length;);return decodeURI(output)},GAUtilities.timeIntervalSince1970=function(){var date=new Date;return Math.round(date.getTime()/1e3)},GAUtilities.createGuid=function(){return(GAUtilities.s4()+GAUtilities.s4()+"-"+GAUtilities.s4()+"-4"+GAUtilities.s4().substr(0,3)+"-"+GAUtilities.s4()+"-"+GAUtilities.s4()+GAUtilities.s4()+GAUtilities.s4()).toLowerCase()},GAUtilities.s4=function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},GAUtilities.keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",GAUtilities}();utilities.GAUtilities=GAUtilities}(gameanalytics.utilities||(gameanalytics.utilities={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(validators){var GALogger=gameanalytics.logging.GALogger,EGASdkErrorType=gameanalytics.http.EGASdkErrorType,GAUtilities=gameanalytics.utilities.GAUtilities,GAValidator=function(){function GAValidator(){}return GAValidator.validateBusinessEvent=function(currency,amount,cartType,itemType,itemId){return GAValidator.validateCurrency(currency)?amount<0?(GALogger.w("Validation fail - business event - amount. Cannot be less than 0. Failed amount: "+amount),!1):GAValidator.validateShortString(cartType,!0)?GAValidator.validateEventPartLength(itemType,!1)?GAValidator.validateEventPartCharacters(itemType)?GAValidator.validateEventPartLength(itemId,!1)?!!GAValidator.validateEventPartCharacters(itemId)||(GALogger.w("Validation fail - business event - itemId: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+itemId),!1):(GALogger.w("Validation fail - business event - itemId. Cannot be (null), empty or above 64 characters. String: "+itemId),!1):(GALogger.w("Validation fail - business event - itemType: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+itemType),!1):(GALogger.w("Validation fail - business event - itemType: Cannot be (null), empty or above 64 characters. String: "+itemType),!1):(GALogger.w("Validation fail - business event - cartType. Cannot be above 32 length. String: "+cartType),!1):(GALogger.w("Validation fail - business event - currency: Cannot be (null) and need to be A-Z, 3 characters and in the standard at openexchangerates.org. Failed currency: "+currency),!1)},GAValidator.validateResourceEvent=function(flowType,currency,amount,itemType,itemId,availableCurrencies,availableItemTypes){return flowType==gameanalytics.EGAResourceFlowType.Undefined?(GALogger.w("Validation fail - resource event - flowType: Invalid flow type."),!1):currency?GAUtilities.stringArrayContainsString(availableCurrencies,currency)?0<amount?itemType?GAValidator.validateEventPartLength(itemType,!1)?GAValidator.validateEventPartCharacters(itemType)?GAUtilities.stringArrayContainsString(availableItemTypes,itemType)?GAValidator.validateEventPartLength(itemId,!1)?!!GAValidator.validateEventPartCharacters(itemId)||(GALogger.w("Validation fail - resource event - itemId: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+itemId),!1):(GALogger.w("Validation fail - resource event - itemId: Cannot be (null), empty or above 64 characters. String: "+itemId),!1):(GALogger.w("Validation fail - resource event - itemType: Not found in list of pre-defined available resource itemTypes. String: "+itemType),!1):(GALogger.w("Validation fail - resource event - itemType: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+itemType),!1):(GALogger.w("Validation fail - resource event - itemType: Cannot be (null), empty or above 64 characters. String: "+itemType),!1):(GALogger.w("Validation fail - resource event - itemType: Cannot be (null)"),!1):(GALogger.w("Validation fail - resource event - amount: Float amount cannot be 0 or negative. Value: "+amount),!1):(GALogger.w("Validation fail - resource event - currency: Not found in list of pre-defined available resource currencies. String: "+currency),!1):(GALogger.w("Validation fail - resource event - currency: Cannot be (null)"),!1)},GAValidator.validateProgressionEvent=function(progressionStatus,progression01,progression02,progression03){if(progressionStatus==gameanalytics.EGAProgressionStatus.Undefined)return GALogger.w("Validation fail - progression event: Invalid progression status."),!1;if(progression03&&!progression02&&progression01)return GALogger.w("Validation fail - progression event: 03 found but 01+02 are invalid. Progression must be set as either 01, 01+02 or 01+02+03."),!1;if(progression02&&!progression01)return GALogger.w("Validation fail - progression event: 02 found but not 01. Progression must be set as either 01, 01+02 or 01+02+03"),!1;if(!progression01)return GALogger.w("Validation fail - progression event: progression01 not valid. Progressions must be set as either 01, 01+02 or 01+02+03"),!1;if(!GAValidator.validateEventPartLength(progression01,!1))return GALogger.w("Validation fail - progression event - progression01: Cannot be (null), empty or above 64 characters. String: "+progression01),!1;if(!GAValidator.validateEventPartCharacters(progression01))return GALogger.w("Validation fail - progression event - progression01: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+progression01),!1;if(progression02){if(!GAValidator.validateEventPartLength(progression02,!0))return GALogger.w("Validation fail - progression event - progression02: Cannot be empty or above 64 characters. String: "+progression02),!1;if(!GAValidator.validateEventPartCharacters(progression02))return GALogger.w("Validation fail - progression event - progression02: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+progression02),!1}if(progression03){if(!GAValidator.validateEventPartLength(progression03,!0))return GALogger.w("Validation fail - progression event - progression03: Cannot be empty or above 64 characters. String: "+progression03),!1;if(!GAValidator.validateEventPartCharacters(progression03))return GALogger.w("Validation fail - progression event - progression03: Cannot contain other characters than A-z, 0-9, -_., ()!?. String: "+progression03),!1}return!0},GAValidator.validateDesignEvent=function(eventId,value){return GAValidator.validateEventIdLength(eventId)?!!GAValidator.validateEventIdCharacters(eventId)||(GALogger.w("Validation fail - design event - eventId: Non valid characters. Only allowed A-z, 0-9, -_., ()!?. String: "+eventId),!1):(GALogger.w("Validation fail - design event - eventId: Cannot be (null) or empty. Only 5 event parts allowed seperated by :. Each part need to be 32 characters or less. String: "+eventId),!1)},GAValidator.validateErrorEvent=function(severity,message){return severity==gameanalytics.EGAErrorSeverity.Undefined?(GALogger.w("Validation fail - error event - severity: Severity was unsupported value."),!1):!!GAValidator.validateLongString(message,!0)||(GALogger.w("Validation fail - error event - message: Message cannot be above 8192 characters."),!1)},GAValidator.validateSdkErrorEvent=function(gameKey,gameSecret,type){return!!GAValidator.validateKeys(gameKey,gameSecret)&&(type!==EGASdkErrorType.Undefined||(GALogger.w("Validation fail - sdk error event - type: Type was unsupported value."),!1))},GAValidator.validateKeys=function(gameKey,gameSecret){return!(!GAUtilities.stringMatch(gameKey,/^[A-z0-9]{32}$/)||!GAUtilities.stringMatch(gameSecret,/^[A-z0-9]{40}$/))},GAValidator.validateCurrency=function(currency){return!!currency&&!!GAUtilities.stringMatch(currency,/^[A-Z]{3}$/)},GAValidator.validateEventPartLength=function(eventPart,allowNull){return!(!allowNull||eventPart)||!!eventPart&&!(64<eventPart.length)},GAValidator.validateEventPartCharacters=function(eventPart){return!!GAUtilities.stringMatch(eventPart,/^[A-Za-z0-9\s\-_\.\(\)\!\?]{1,64}$/)},GAValidator.validateEventIdLength=function(eventId){return!!eventId&&!!GAUtilities.stringMatch(eventId,/^[^:]{1,64}(?::[^:]{1,64}){0,4}$/)},GAValidator.validateEventIdCharacters=function(eventId){return!!eventId&&!!GAUtilities.stringMatch(eventId,/^[A-Za-z0-9\s\-_\.\(\)\!\?]{1,64}(:[A-Za-z0-9\s\-_\.\(\)\!\?]{1,64}){0,4}$/)},GAValidator.validateAndCleanInitRequestResponse=function(initResponse){if(null==initResponse)return GALogger.w("validateInitRequestResponse failed - no response dictionary."),null;var validatedDict={};try{validatedDict.enabled=initResponse.enabled}catch(e){return GALogger.w("validateInitRequestResponse failed - invalid type in 'enabled' field."),null}try{var serverTsNumber=initResponse.server_ts;if(!(0<serverTsNumber))return GALogger.w("validateInitRequestResponse failed - invalid value in 'server_ts' field."),null;validatedDict.server_ts=serverTsNumber}catch(e){return GALogger.w("validateInitRequestResponse failed - invalid type in 'server_ts' field. type="+typeof initResponse.server_ts+", value="+initResponse.server_ts+", "+e),null}try{var configurations=initResponse.configurations;validatedDict.configurations=configurations}catch(e){return GALogger.w("validateInitRequestResponse failed - invalid type in 'configurations' field. type="+typeof initResponse.configurations+", value="+initResponse.configurations+", "+e),null}return validatedDict},GAValidator.validateBuild=function(build){return!!GAValidator.validateShortString(build,!1)},GAValidator.validateSdkWrapperVersion=function(wrapperVersion){return!!GAUtilities.stringMatch(wrapperVersion,/^(unity|unreal|gamemaker|cocos2d|construct|defold) [0-9]{0,5}(\.[0-9]{0,5}){0,2}$/)},GAValidator.validateEngineVersion=function(engineVersion){return!(!engineVersion||!GAUtilities.stringMatch(engineVersion,/^(unity|unreal|gamemaker|cocos2d|construct|defold) [0-9]{0,5}(\.[0-9]{0,5}){0,2}$/))},GAValidator.validateUserId=function(uId){return!!GAValidator.validateString(uId,!1)||(GALogger.w("Validation fail - user id: id cannot be (null), empty or above 64 characters."),!1)},GAValidator.validateShortString=function(shortString,canBeEmpty){return!(!canBeEmpty||shortString)||!(!shortString||32<shortString.length)},GAValidator.validateString=function(s,canBeEmpty){return!(!canBeEmpty||s)||!(!s||64<s.length)},GAValidator.validateLongString=function(longString,canBeEmpty){return!(!canBeEmpty||longString)||!(!longString||8192<longString.length)},GAValidator.validateConnectionType=function(connectionType){return GAUtilities.stringMatch(connectionType,/^(wwan|wifi|lan|offline)$/)},GAValidator.validateCustomDimensions=function(customDimensions){return GAValidator.validateArrayOfStrings(20,32,!1,"custom dimensions",customDimensions)},GAValidator.validateResourceCurrencies=function(resourceCurrencies){if(!GAValidator.validateArrayOfStrings(20,64,!1,"resource currencies",resourceCurrencies))return!1;for(var i=0;i<resourceCurrencies.length;++i)if(!GAUtilities.stringMatch(resourceCurrencies[i],/^[A-Za-z]+$/))return GALogger.w("resource currencies validation failed: a resource currency can only be A-Z, a-z. String was: "+resourceCurrencies[i]),!1;return!0},GAValidator.validateResourceItemTypes=function(resourceItemTypes){if(!GAValidator.validateArrayOfStrings(20,32,!1,"resource item types",resourceItemTypes))return!1;for(var i=0;i<resourceItemTypes.length;++i)if(!GAValidator.validateEventPartCharacters(resourceItemTypes[i]))return GALogger.w("resource item types validation failed: a resource item type cannot contain other characters than A-z, 0-9, -_., ()!?. String was: "+resourceItemTypes[i]),!1;return!0},GAValidator.validateDimension01=function(dimension01,availableDimensions){return!dimension01||!!GAUtilities.stringArrayContainsString(availableDimensions,dimension01)},GAValidator.validateDimension02=function(dimension02,availableDimensions){return!dimension02||!!GAUtilities.stringArrayContainsString(availableDimensions,dimension02)},GAValidator.validateDimension03=function(dimension03,availableDimensions){return!dimension03||!!GAUtilities.stringArrayContainsString(availableDimensions,dimension03)},GAValidator.validateArrayOfStrings=function(maxCount,maxStringLength,allowNoValues,logTag,arrayOfStrings){var arrayTag=logTag;if(arrayTag||(arrayTag="Array"),!arrayOfStrings)return GALogger.w(arrayTag+" validation failed: array cannot be null. "),!1;if(0==allowNoValues&&0==arrayOfStrings.length)return GALogger.w(arrayTag+" validation failed: array cannot be empty. "),!1;if(0<maxCount&&arrayOfStrings.length>maxCount)return GALogger.w(arrayTag+" validation failed: array cannot exceed "+maxCount+" values. It has "+arrayOfStrings.length+" values."),!1;for(var i=0;i<arrayOfStrings.length;++i){var stringLength=arrayOfStrings[i]?arrayOfStrings[i].length:0;if(0===stringLength)return GALogger.w(arrayTag+" validation failed: contained an empty string. Array="+JSON.stringify(arrayOfStrings)),!1;if(0<maxStringLength&&maxStringLength<stringLength)return GALogger.w(arrayTag+" validation failed: a string exceeded max allowed length (which is: "+maxStringLength+"). String was: "+arrayOfStrings[i]),!1}return!0},GAValidator.validateFacebookId=function(facebookId){return!!GAValidator.validateString(facebookId,!1)||(GALogger.w("Validation fail - facebook id: id cannot be (null), empty or above 64 characters."),!1)},GAValidator.validateGender=function(gender){if(isNaN(Number(gameanalytics.EGAGender[gender]))){if(gender==gameanalytics.EGAGender.Undefined||gender!=gameanalytics.EGAGender.Male&&gender!=gameanalytics.EGAGender.Female)return GALogger.w("Validation fail - gender: Has to be 'male' or 'female'. Was: "+gender),!1}else if(gender==gameanalytics.EGAGender[gameanalytics.EGAGender.Undefined]||gender!=gameanalytics.EGAGender[gameanalytics.EGAGender.Male]&&gender!=gameanalytics.EGAGender[gameanalytics.EGAGender.Female])return GALogger.w("Validation fail - gender: Has to be 'male' or 'female'. Was: "+gender),!1;return!0},GAValidator.validateBirthyear=function(birthYear){return!(birthYear<0||9999<birthYear)||(GALogger.w("Validation fail - birthYear: Cannot be (null) or invalid range."),!1)},GAValidator.validateClientTs=function(clientTs){return!(clientTs<-4294967294||4294967294<clientTs)},GAValidator}();validators.GAValidator=GAValidator}(gameanalytics.validators||(gameanalytics.validators={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(device){var NameValueVersion=function(name,value,version){this.name=name,this.value=value,this.version=version};device.NameValueVersion=NameValueVersion;var NameVersion=function(name,version){this.name=name,this.version=version};device.NameVersion=NameVersion;var GADevice=function(){function GADevice(){}return GADevice.touch=function(){},GADevice.getRelevantSdkVersion=function(){return GADevice.sdkGameEngineVersion?GADevice.sdkGameEngineVersion:GADevice.sdkWrapperVersion},GADevice.getConnectionType=function(){return GADevice.connectionType},GADevice.updateConnectionType=function(){GADevice.connectionType=navigator.onLine?"ios"===GADevice.buildPlatform||"android"===GADevice.buildPlatform?"wwan":"lan":"offline"},GADevice.getOSVersionString=function(){return GADevice.buildPlatform+" "+GADevice.osVersionPair.version},GADevice.runtimePlatformToString=function(){return GADevice.osVersionPair.name},GADevice.getBrowserVersionString=function(){var tem,ua=navigator.userAgent,M=ua.match(/(opera|chrome|safari|firefox|ubrowser|msie|trident|fbav(?=\/))\/?\s*(\d+)/i)||[];if(0==M.length&&"ios"===GADevice.buildPlatform)return"webkit_"+GADevice.osVersion;if(/trident/i.test(M[1]))return"IE "+((tem=/\brv[ :]+(\d+)/g.exec(ua)||[])[1]||"");if("Chrome"===M[1]&&null!=(tem=ua.match(/\b(OPR|Edge|UBrowser)\/(\d+)/)))return tem.slice(1).join(" ").replace("OPR","Opera").replace("UBrowser","UC").toLowerCase();if(M[1]&&"fbav"===M[1].toLowerCase()&&(M[1]="facebook",M[2]))return"facebook "+M[2];var MString=M[2]?[M[1],M[2]]:[navigator.appName,navigator.appVersion,"-?"];return null!=(tem=ua.match(/version\/(\d+)/i))&&MString.splice(1,1,tem[1]),MString.join(" ").toLowerCase()},GADevice.getDeviceModel=function(){return"unknown"},GADevice.getDeviceManufacturer=function(){return"unknown"},GADevice.matchItem=function(agent,data){var regexv,matches,mathcesResult,version,result=new NameVersion("unknown","0.0.0"),i=0,j=0;for(i=0;i<data.length;i+=1)if(new RegExp(data[i].value,"i").test(agent)){if(regexv=new RegExp(data[i].version+"[- /:;]([\\d._]+)","i"),version="",(matches=agent.match(regexv))&&matches[1]&&(mathcesResult=matches[1]),mathcesResult){var matchesArray=mathcesResult.split(/[._]+/);for(j=0;j<Math.min(matchesArray.length,3);j+=1)version+=matchesArray[j]+(j<Math.min(matchesArray.length,3)-1?".":"")}else version="0.0.0";return result.name=data[i].name,result.version=version,result}return result},GADevice.sdkWrapperVersion="javascript 3.1.2",GADevice.osVersionPair=GADevice.matchItem([navigator.platform,navigator.userAgent,navigator.appVersion,navigator.vendor].join(" "),[new NameValueVersion("windows_phone","Windows Phone","OS"),new NameValueVersion("windows","Win","NT"),new NameValueVersion("ios","iPhone","OS"),new NameValueVersion("ios","iPad","OS"),new NameValueVersion("ios","iPod","OS"),new NameValueVersion("android","Android","Android"),new NameValueVersion("blackBerry","BlackBerry","/"),new NameValueVersion("mac_osx","Mac","OS X"),new NameValueVersion("tizen","Tizen","Tizen"),new NameValueVersion("linux","Linux","rv")]),GADevice.buildPlatform=GADevice.runtimePlatformToString(),GADevice.deviceModel=GADevice.getDeviceModel(),GADevice.deviceManufacturer=GADevice.getDeviceManufacturer(),GADevice.osVersion=GADevice.getOSVersionString(),GADevice.browserVersion=GADevice.getBrowserVersionString(),GADevice.maxSafeInteger=Math.pow(2,53)-1,GADevice}();device.GADevice=GADevice}(gameanalytics.device||(gameanalytics.device={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(threading){var TimedBlock=function(){function TimedBlock(deadline){this.deadline=deadline,this.ignore=!1,this.async=!1,this.running=!1,this.id=++TimedBlock.idCounter}return TimedBlock.idCounter=0,TimedBlock}();threading.TimedBlock=TimedBlock}(gameanalytics.threading||(gameanalytics.threading={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(threading){var PriorityQueue=function(){function PriorityQueue(priorityComparer){this.comparer=priorityComparer,this._subQueues={},this._sortedKeys=[]}return PriorityQueue.prototype.enqueue=function(priority,item){-1===this._sortedKeys.indexOf(priority)&&this.addQueueOfPriority(priority),this._subQueues[priority].push(item)},PriorityQueue.prototype.addQueueOfPriority=function(priority){var _this=this;this._sortedKeys.push(priority),this._sortedKeys.sort(function(x,y){return _this.comparer.compare(x,y)}),this._subQueues[priority]=[]},PriorityQueue.prototype.peek=function(){if(this.hasItems())return this._subQueues[this._sortedKeys[0]][0];throw new Error("The queue is empty")},PriorityQueue.prototype.hasItems=function(){return 0<this._sortedKeys.length},PriorityQueue.prototype.dequeue=function(){if(this.hasItems())return this.dequeueFromHighPriorityQueue();throw new Error("The queue is empty")},PriorityQueue.prototype.dequeueFromHighPriorityQueue=function(){var firstKey=this._sortedKeys[0],nextItem=this._subQueues[firstKey].shift();return 0===this._subQueues[firstKey].length&&(this._sortedKeys.shift(),delete this._subQueues[firstKey]),nextItem},PriorityQueue}();threading.PriorityQueue=PriorityQueue}(gameanalytics.threading||(gameanalytics.threading={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(store_1){var EGAStoreArgsOperator,EGAStore,GALogger=gameanalytics.logging.GALogger;!function(EGAStoreArgsOperator){EGAStoreArgsOperator[EGAStoreArgsOperator.Equal=0]="Equal",EGAStoreArgsOperator[EGAStoreArgsOperator.LessOrEqual=1]="LessOrEqual",EGAStoreArgsOperator[EGAStoreArgsOperator.NotEqual=2]="NotEqual"}(EGAStoreArgsOperator=store_1.EGAStoreArgsOperator||(store_1.EGAStoreArgsOperator={})),function(EGAStore){EGAStore[EGAStore.Events=0]="Events",EGAStore[EGAStore.Sessions=1]="Sessions",EGAStore[EGAStore.Progression=2]="Progression"}(EGAStore=store_1.EGAStore||(store_1.EGAStore={}));var GAStore=function(){function GAStore(){this.eventsStore=[],this.sessionsStore=[],this.progressionStore=[],this.storeItems={};try{GAStore.storageAvailable="object"==typeof localStorage&&(localStorage.setItem("testingLocalStorage","yes"),localStorage.removeItem("testingLocalStorage"),!0)}catch(e){}}return GAStore.isStorageAvailable=function(){return GAStore.storageAvailable},GAStore.isStoreTooLargeForEvents=function(){return GAStore.instance.eventsStore.length+GAStore.instance.sessionsStore.length>GAStore.MaxNumberOfEntries},GAStore.select=function(store,args,sort,maxCount){void 0===args&&(args=[]),void 0===sort&&(sort=!1),void 0===maxCount&&(maxCount=0);var currentStore=GAStore.getStore(store);if(!currentStore)return null;for(var result=[],i=0;i<currentStore.length;++i){for(var entry=currentStore[i],add=!0,j=0;j<args.length;++j){var argsEntry=args[j];if(entry[argsEntry[0]])switch(argsEntry[1]){case EGAStoreArgsOperator.Equal:add=entry[argsEntry[0]]==argsEntry[2];break;case EGAStoreArgsOperator.LessOrEqual:add=entry[argsEntry[0]]<=argsEntry[2];break;case EGAStoreArgsOperator.NotEqual:add=entry[argsEntry[0]]!=argsEntry[2];break;default:add=!1}else add=!1;if(!add)break}add&&result.push(entry)}return sort&&result.sort(function(a,b){return a.client_ts-b.client_ts}),0<maxCount&&result.length>maxCount&&(result=result.slice(0,maxCount+1)),result},GAStore.update=function(store,setArgs,whereArgs){void 0===whereArgs&&(whereArgs=[]);var currentStore=GAStore.getStore(store);if(!currentStore)return!1;for(var i=0;i<currentStore.length;++i){for(var entry=currentStore[i],update=!0,j=0;j<whereArgs.length;++j){var argsEntry=whereArgs[j];if(entry[argsEntry[0]])switch(argsEntry[1]){case EGAStoreArgsOperator.Equal:update=entry[argsEntry[0]]==argsEntry[2];break;case EGAStoreArgsOperator.LessOrEqual:update=entry[argsEntry[0]]<=argsEntry[2];break;case EGAStoreArgsOperator.NotEqual:update=entry[argsEntry[0]]!=argsEntry[2];break;default:update=!1}else update=!1;if(!update)break}if(update)for(j=0;j<setArgs.length;++j){var setArgsEntry=setArgs[j];entry[setArgsEntry[0]]=setArgsEntry[1]}}return!0},GAStore.delete=function(store,args){var currentStore=GAStore.getStore(store);if(currentStore)for(var i=0;i<currentStore.length;++i){for(var entry=currentStore[i],del=!0,j=0;j<args.length;++j){var argsEntry=args[j];if(entry[argsEntry[0]])switch(argsEntry[1]){case EGAStoreArgsOperator.Equal:del=entry[argsEntry[0]]==argsEntry[2];break;case EGAStoreArgsOperator.LessOrEqual:del=entry[argsEntry[0]]<=argsEntry[2];break;case EGAStoreArgsOperator.NotEqual:del=entry[argsEntry[0]]!=argsEntry[2];break;default:del=!1}else del=!1;if(!del)break}del&&(currentStore.splice(i,1),--i)}},GAStore.insert=function(store,newEntry,replace,replaceKey){void 0===replace&&(replace=!1),void 0===replaceKey&&(replaceKey=null);var currentStore=GAStore.getStore(store);if(currentStore)if(replace){if(!replaceKey)return;for(var replaced=!1,i=0;i<currentStore.length;++i){var entry=currentStore[i];if(entry[replaceKey]==newEntry[replaceKey]){for(var s in newEntry)entry[s]=newEntry[s];replaced=!0;break}}replaced||currentStore.push(newEntry)}else currentStore.push(newEntry)},GAStore.save=function(){GAStore.isStorageAvailable()?(localStorage.setItem(GAStore.KeyPrefix+GAStore.EventsStoreKey,JSON.stringify(GAStore.instance.eventsStore)),localStorage.setItem(GAStore.KeyPrefix+GAStore.SessionsStoreKey,JSON.stringify(GAStore.instance.sessionsStore)),localStorage.setItem(GAStore.KeyPrefix+GAStore.ProgressionStoreKey,JSON.stringify(GAStore.instance.progressionStore)),localStorage.setItem(GAStore.KeyPrefix+GAStore.ItemsStoreKey,JSON.stringify(GAStore.instance.storeItems))):GALogger.w("Storage is not available, cannot save.")},GAStore.load=function(){if(GAStore.isStorageAvailable()){try{GAStore.instance.eventsStore=JSON.parse(localStorage.getItem(GAStore.KeyPrefix+GAStore.EventsStoreKey)),GAStore.instance.eventsStore||(GAStore.instance.eventsStore=[])}catch(e){GALogger.w("Load failed for 'events' store. Using empty store."),GAStore.instance.eventsStore=[]}try{GAStore.instance.sessionsStore=JSON.parse(localStorage.getItem(GAStore.KeyPrefix+GAStore.SessionsStoreKey)),GAStore.instance.sessionsStore||(GAStore.instance.sessionsStore=[])}catch(e){GALogger.w("Load failed for 'sessions' store. Using empty store."),GAStore.instance.sessionsStore=[]}try{GAStore.instance.progressionStore=JSON.parse(localStorage.getItem(GAStore.KeyPrefix+GAStore.ProgressionStoreKey)),GAStore.instance.progressionStore||(GAStore.instance.progressionStore=[])}catch(e){GALogger.w("Load failed for 'progression' store. Using empty store."),GAStore.instance.progressionStore=[]}try{GAStore.instance.storeItems=JSON.parse(localStorage.getItem(GAStore.KeyPrefix+GAStore.ItemsStoreKey)),GAStore.instance.storeItems||(GAStore.instance.storeItems={})}catch(e){GALogger.w("Load failed for 'items' store. Using empty store."),GAStore.instance.progressionStore=[]}}else GALogger.w("Storage is not available, cannot load.")},GAStore.setItem=function(key,value){var keyWithPrefix=GAStore.KeyPrefix+key;value?GAStore.instance.storeItems[keyWithPrefix]=value:keyWithPrefix in GAStore.instance.storeItems&&delete GAStore.instance.storeItems[keyWithPrefix]},GAStore.getItem=function(key){var keyWithPrefix=GAStore.KeyPrefix+key;return keyWithPrefix in GAStore.instance.storeItems?GAStore.instance.storeItems[keyWithPrefix]:null},GAStore.getStore=function(store){switch(store){case EGAStore.Events:return GAStore.instance.eventsStore;case EGAStore.Sessions:return GAStore.instance.sessionsStore;case EGAStore.Progression:return GAStore.instance.progressionStore;default:return GALogger.w("GAStore.getStore(): Cannot find store: "+store),null}},GAStore.instance=new GAStore,GAStore.MaxNumberOfEntries=2e3,GAStore.KeyPrefix="GA::",GAStore.EventsStoreKey="ga_event",GAStore.SessionsStoreKey="ga_session",GAStore.ProgressionStoreKey="ga_progression",GAStore.ItemsStoreKey="ga_items",GAStore}();store_1.GAStore=GAStore}(gameanalytics.store||(gameanalytics.store={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(state){var GAValidator=gameanalytics.validators.GAValidator,GAUtilities=gameanalytics.utilities.GAUtilities,GALogger=gameanalytics.logging.GALogger,GAStore=gameanalytics.store.GAStore,GADevice=gameanalytics.device.GADevice,EGAStore=gameanalytics.store.EGAStore,EGAStoreArgsOperator=gameanalytics.store.EGAStoreArgsOperator,GAState=function(){function GAState(){this.availableCustomDimensions01=[],this.availableCustomDimensions02=[],this.availableCustomDimensions03=[],this.availableResourceCurrencies=[],this.availableResourceItemTypes=[],this.configurations={},this.commandCenterListeners=[],this.sdkConfigDefault={},this.sdkConfig={},this.progressionTries={},this._isEventSubmissionEnabled=!0}return GAState.setUserId=function(userId){GAState.instance.userId=userId,GAState.cacheIdentifier()},GAState.getIdentifier=function(){return GAState.instance.identifier},GAState.isInitialized=function(){return GAState.instance.initialized},GAState.setInitialized=function(value){GAState.instance.initialized=value},GAState.getSessionStart=function(){return GAState.instance.sessionStart},GAState.getSessionNum=function(){return GAState.instance.sessionNum},GAState.getTransactionNum=function(){return GAState.instance.transactionNum},GAState.getSessionId=function(){return GAState.instance.sessionId},GAState.getCurrentCustomDimension01=function(){return GAState.instance.currentCustomDimension01},GAState.getCurrentCustomDimension02=function(){return GAState.instance.currentCustomDimension02},GAState.getCurrentCustomDimension03=function(){return GAState.instance.currentCustomDimension03},GAState.getGameKey=function(){return GAState.instance.gameKey},GAState.getGameSecret=function(){return GAState.instance.gameSecret},GAState.getAvailableCustomDimensions01=function(){return GAState.instance.availableCustomDimensions01},GAState.setAvailableCustomDimensions01=function(value){GAValidator.validateCustomDimensions(value)&&(GAState.instance.availableCustomDimensions01=value,GAState.validateAndFixCurrentDimensions(),GALogger.i("Set available custom01 dimension values: ("+GAUtilities.joinStringArray(value,", ")+")"))},GAState.getAvailableCustomDimensions02=function(){return GAState.instance.availableCustomDimensions02},GAState.setAvailableCustomDimensions02=function(value){GAValidator.validateCustomDimensions(value)&&(GAState.instance.availableCustomDimensions02=value,GAState.validateAndFixCurrentDimensions(),GALogger.i("Set available custom02 dimension values: ("+GAUtilities.joinStringArray(value,", ")+")"))},GAState.getAvailableCustomDimensions03=function(){return GAState.instance.availableCustomDimensions03},GAState.setAvailableCustomDimensions03=function(value){GAValidator.validateCustomDimensions(value)&&(GAState.instance.availableCustomDimensions03=value,GAState.validateAndFixCurrentDimensions(),GALogger.i("Set available custom03 dimension values: ("+GAUtilities.joinStringArray(value,", ")+")"))},GAState.getAvailableResourceCurrencies=function(){return GAState.instance.availableResourceCurrencies},GAState.setAvailableResourceCurrencies=function(value){GAValidator.validateResourceCurrencies(value)&&(GAState.instance.availableResourceCurrencies=value,GALogger.i("Set available resource currencies: ("+GAUtilities.joinStringArray(value,", ")+")"))},GAState.getAvailableResourceItemTypes=function(){return GAState.instance.availableResourceItemTypes},GAState.setAvailableResourceItemTypes=function(value){GAValidator.validateResourceItemTypes(value)&&(GAState.instance.availableResourceItemTypes=value,GALogger.i("Set available resource item types: ("+GAUtilities.joinStringArray(value,", ")+")"))},GAState.getBuild=function(){return GAState.instance.build},GAState.setBuild=function(value){GAState.instance.build=value,GALogger.i("Set build version: "+value)},GAState.getUseManualSessionHandling=function(){return GAState.instance.useManualSessionHandling},GAState.isEventSubmissionEnabled=function(){return GAState.instance._isEventSubmissionEnabled},GAState.prototype.setDefaultId=function(value){this.defaultUserId=value||"",GAState.cacheIdentifier()},GAState.getDefaultId=function(){return GAState.instance.defaultUserId},GAState.getSdkConfig=function(){var count=0;for(var json in GAState.instance.sdkConfig)0===count&&(first=json),++count;if(first&&0<count)return GAState.instance.sdkConfig;var first;count=0;for(var json in GAState.instance.sdkConfigCached)0===count&&(first=json),++count;return first&&0<count?GAState.instance.sdkConfigCached:GAState.instance.sdkConfigDefault},GAState.isEnabled=function(){var currentSdkConfig=GAState.getSdkConfig();return(!currentSdkConfig.enabled||"false"!=currentSdkConfig.enabled)&&!!GAState.instance.initAuthorized},GAState.setCustomDimension01=function(dimension){GAState.instance.currentCustomDimension01=dimension,GAStore.setItem(GAState.Dimension01Key,dimension),GALogger.i("Set custom01 dimension value: "+dimension)},GAState.setCustomDimension02=function(dimension){GAState.instance.currentCustomDimension02=dimension,GAStore.setItem(GAState.Dimension02Key,dimension),GALogger.i("Set custom02 dimension value: "+dimension)},GAState.setCustomDimension03=function(dimension){GAState.instance.currentCustomDimension03=dimension,GAStore.setItem(GAState.Dimension03Key,dimension),GALogger.i("Set custom03 dimension value: "+dimension)},GAState.setFacebookId=function(facebookId){GAState.instance.facebookId=facebookId,GAStore.setItem(GAState.FacebookIdKey,facebookId),GALogger.i("Set facebook id: "+facebookId)},GAState.setGender=function(gender){GAState.instance.gender=isNaN(Number(gameanalytics.EGAGender[gender]))?gameanalytics.EGAGender[gender].toString().toLowerCase():gameanalytics.EGAGender[gameanalytics.EGAGender[gender]].toString().toLowerCase(),GAStore.setItem(GAState.GenderKey,GAState.instance.gender),GALogger.i("Set gender: "+GAState.instance.gender)},GAState.setBirthYear=function(birthYear){GAState.instance.birthYear=birthYear,GAStore.setItem(GAState.BirthYearKey,birthYear.toString()),GALogger.i("Set birth year: "+birthYear)},GAState.incrementSessionNum=function(){var sessionNumInt=GAState.getSessionNum()+1;GAState.instance.sessionNum=sessionNumInt},GAState.incrementTransactionNum=function(){var transactionNumInt=GAState.getTransactionNum()+1;GAState.instance.transactionNum=transactionNumInt},GAState.incrementProgressionTries=function(progression){var tries=GAState.getProgressionTries(progression)+1;GAState.instance.progressionTries[progression]=tries;var values={};values.progression=progression,values.tries=tries,GAStore.insert(EGAStore.Progression,values,!0,"progression")},GAState.getProgressionTries=function(progression){return progression in GAState.instance.progressionTries?GAState.instance.progressionTries[progression]:0},GAState.clearProgressionTries=function(progression){progression in GAState.instance.progressionTries&&delete GAState.instance.progressionTries[progression];var parms=[];parms.push(["progression",EGAStoreArgsOperator.Equal,progression]),GAStore.delete(EGAStore.Progression,parms)},GAState.setKeys=function(gameKey,gameSecret){GAState.instance.gameKey=gameKey,GAState.instance.gameSecret=gameSecret},GAState.setManualSessionHandling=function(flag){GAState.instance.useManualSessionHandling=flag,GALogger.i("Use manual session handling: "+flag)},GAState.setEnabledEventSubmission=function(flag){GAState.instance._isEventSubmissionEnabled=flag},GAState.getEventAnnotations=function(){var annotations={v:2};annotations.user_id=GAState.instance.identifier,annotations.client_ts=GAState.getClientTsAdjusted(),annotations.sdk_version=GADevice.getRelevantSdkVersion(),annotations.os_version=GADevice.osVersion,annotations.manufacturer=GADevice.deviceManufacturer,annotations.device=GADevice.deviceModel,annotations.browser_version=GADevice.browserVersion,annotations.platform=GADevice.buildPlatform,annotations.session_id=GAState.instance.sessionId,annotations[GAState.SessionNumKey]=GAState.instance.sessionNum;var connection_type=GADevice.getConnectionType();return GAValidator.validateConnectionType(connection_type)&&(annotations.connection_type=connection_type),GADevice.gameEngineVersion&&(annotations.engine_version=GADevice.gameEngineVersion),GAState.instance.build&&(annotations.build=GAState.instance.build),GAState.instance.facebookId&&(annotations[GAState.FacebookIdKey]=GAState.instance.facebookId),GAState.instance.gender&&(annotations[GAState.GenderKey]=GAState.instance.gender),0!=GAState.instance.birthYear&&(annotations[GAState.BirthYearKey]=GAState.instance.birthYear),annotations},GAState.getSdkErrorEventAnnotations=function(){var annotations={v:2};annotations.category=GAState.CategorySdkError,annotations.sdk_version=GADevice.getRelevantSdkVersion(),annotations.os_version=GADevice.osVersion,annotations.manufacturer=GADevice.deviceManufacturer,annotations.device=GADevice.deviceModel,annotations.platform=GADevice.buildPlatform;var connection_type=GADevice.getConnectionType();return GAValidator.validateConnectionType(connection_type)&&(annotations.connection_type=connection_type),GADevice.gameEngineVersion&&(annotations.engine_version=GADevice.gameEngineVersion),annotations},GAState.getInitAnnotations=function(){var initAnnotations={};return initAnnotations.user_id=GAState.getIdentifier(),initAnnotations.sdk_version=GADevice.getRelevantSdkVersion(),initAnnotations.os_version=GADevice.osVersion,initAnnotations.platform=GADevice.buildPlatform,initAnnotations},GAState.getClientTsAdjusted=function(){var clientTs=GAUtilities.timeIntervalSince1970(),clientTsAdjustedInteger=clientTs+GAState.instance.clientServerTimeOffset;return GAValidator.validateClientTs(clientTsAdjustedInteger)?clientTsAdjustedInteger:clientTs},GAState.sessionIsStarted=function(){return 0!=GAState.instance.sessionStart},GAState.cacheIdentifier=function(){GAState.instance.userId?GAState.instance.identifier=GAState.instance.userId:GAState.instance.defaultUserId&&(GAState.instance.identifier=GAState.instance.defaultUserId)},GAState.ensurePersistedStates=function(){GAStore.isStorageAvailable()&&GAStore.load();var instance=GAState.instance;instance.setDefaultId(null!=GAStore.getItem(GAState.DefaultUserIdKey)?GAStore.getItem(GAState.DefaultUserIdKey):GAUtilities.createGuid()),instance.sessionNum=null!=GAStore.getItem(GAState.SessionNumKey)?Number(GAStore.getItem(GAState.SessionNumKey)):0,instance.transactionNum=null!=GAStore.getItem(GAState.TransactionNumKey)?Number(GAStore.getItem(GAState.TransactionNumKey)):0,instance.facebookId?GAStore.setItem(GAState.FacebookIdKey,instance.facebookId):(instance.facebookId=null!=GAStore.getItem(GAState.FacebookIdKey)?GAStore.getItem(GAState.FacebookIdKey):"",instance.facebookId),instance.gender?GAStore.setItem(GAState.GenderKey,instance.gender):(instance.gender=null!=GAStore.getItem(GAState.GenderKey)?GAStore.getItem(GAState.GenderKey):"",instance.gender),instance.birthYear&&0!=instance.birthYear?GAStore.setItem(GAState.BirthYearKey,instance.birthYear.toString()):(instance.birthYear=null!=GAStore.getItem(GAState.BirthYearKey)?Number(GAStore.getItem(GAState.BirthYearKey)):0,instance.birthYear),instance.currentCustomDimension01?GAStore.setItem(GAState.Dimension01Key,instance.currentCustomDimension01):(instance.currentCustomDimension01=null!=GAStore.getItem(GAState.Dimension01Key)?GAStore.getItem(GAState.Dimension01Key):"",instance.currentCustomDimension01),instance.currentCustomDimension02?GAStore.setItem(GAState.Dimension02Key,instance.currentCustomDimension02):(instance.currentCustomDimension02=null!=GAStore.getItem(GAState.Dimension02Key)?GAStore.getItem(GAState.Dimension02Key):"",instance.currentCustomDimension02),instance.currentCustomDimension03?GAStore.setItem(GAState.Dimension03Key,instance.currentCustomDimension03):(instance.currentCustomDimension03=null!=GAStore.getItem(GAState.Dimension03Key)?GAStore.getItem(GAState.Dimension03Key):"",instance.currentCustomDimension03);var sdkConfigCachedString=null!=GAStore.getItem(GAState.SdkConfigCachedKey)?GAStore.getItem(GAState.SdkConfigCachedKey):"";if(sdkConfigCachedString){var sdkConfigCached=JSON.parse(GAUtilities.decode64(sdkConfigCachedString));sdkConfigCached&&(instance.sdkConfigCached=sdkConfigCached)}var results_ga_progression=GAStore.select(EGAStore.Progression);if(results_ga_progression)for(var i=0;i<results_ga_progression.length;++i){var result=results_ga_progression[i];result&&(instance.progressionTries[result.progression]=result.tries)}},GAState.calculateServerTimeOffset=function(serverTs){return serverTs-GAUtilities.timeIntervalSince1970()},GAState.validateAndCleanCustomFields=function(fields){var result={};if(fields){var count=0;for(var key in fields){var value=fields[key];if(key&&value)if(count<GAState.MAX_CUSTOM_FIELDS_COUNT){var regex=new RegExp("^[a-zA-Z0-9_]{1,"+GAState.MAX_CUSTOM_FIELDS_KEY_LENGTH+"}$");if(GAUtilities.stringMatch(key,regex)){var type=typeof value;if("string"===type||value instanceof String){var valueAsString=value;valueAsString.length<=GAState.MAX_CUSTOM_FIELDS_VALUE_STRING_LENGTH&&0<valueAsString.length?(result[key]=valueAsString,++count):GALogger.w("validateAndCleanCustomFields: entry with key="+key+", value="+value+" has been omitted because its value is an empty string or exceeds the max number of characters ("+GAState.MAX_CUSTOM_FIELDS_VALUE_STRING_LENGTH+")")}else if("number"===type||value instanceof Number){var valueAsNumber=value;result[key]=valueAsNumber,++count}else GALogger.w("validateAndCleanCustomFields: entry with key="+key+", value="+value+" has been omitted because its value is not a string or number")}else GALogger.w("validateAndCleanCustomFields: entry with key="+key+", value="+value+" has been omitted because its key contains illegal character, is empty or exceeds the max number of characters ("+GAState.MAX_CUSTOM_FIELDS_KEY_LENGTH+")")}else GALogger.w("validateAndCleanCustomFields: entry with key="+key+", value="+value+" has been omitted because it exceeds the max number of custom fields ("+GAState.MAX_CUSTOM_FIELDS_COUNT+")");else GALogger.w("validateAndCleanCustomFields: entry with key="+key+", value="+value+" has been omitted because its key or value is null")}}return result},GAState.validateAndFixCurrentDimensions=function(){GAValidator.validateDimension01(GAState.getCurrentCustomDimension01(),GAState.getAvailableCustomDimensions01())||GAState.setCustomDimension01(""),GAValidator.validateDimension02(GAState.getCurrentCustomDimension02(),GAState.getAvailableCustomDimensions02())||GAState.setCustomDimension02(""),GAValidator.validateDimension03(GAState.getCurrentCustomDimension03(),GAState.getAvailableCustomDimensions03())||GAState.setCustomDimension03("")},GAState.getConfigurationStringValue=function(key,defaultValue){return GAState.instance.configurations[key]?GAState.instance.configurations[key].toString():defaultValue},GAState.isCommandCenterReady=function(){return GAState.instance.commandCenterIsReady},GAState.addCommandCenterListener=function(listener){GAState.instance.commandCenterListeners.indexOf(listener)<0&&GAState.instance.commandCenterListeners.push(listener)},GAState.removeCommandCenterListener=function(listener){var index=GAState.instance.commandCenterListeners.indexOf(listener);-1<index&&GAState.instance.commandCenterListeners.splice(index,1)},GAState.getConfigurationsContentAsString=function(){return JSON.stringify(GAState.instance.configurations)},GAState.populateConfigurations=function(sdkConfig){var configurations=sdkConfig.configurations;if(configurations)for(var i=0;i<configurations.length;++i){var configuration=configurations[i];if(configuration){var key=configuration.key,value=configuration.value,start_ts=configuration.start?configuration.start:Number.MIN_VALUE,end_ts=configuration.end?configuration.end:Number.MAX_VALUE,client_ts_adjusted=GAState.getClientTsAdjusted();key&&value&&start_ts<client_ts_adjusted&&client_ts_adjusted<end_ts&&(GAState.instance.configurations[key]=value)}}GAState.instance.commandCenterIsReady=!0;var listeners=GAState.instance.commandCenterListeners;for(i=0;i<listeners.length;++i)listeners[i]&&listeners[i].onCommandCenterUpdated()},GAState.CategorySdkError="sdk_error",GAState.MAX_CUSTOM_FIELDS_COUNT=50,GAState.MAX_CUSTOM_FIELDS_KEY_LENGTH=64,GAState.MAX_CUSTOM_FIELDS_VALUE_STRING_LENGTH=256,GAState.instance=new GAState,GAState.DefaultUserIdKey="default_user_id",GAState.SessionNumKey="session_num",GAState.TransactionNumKey="transaction_num",GAState.FacebookIdKey="facebook_id",GAState.GenderKey="gender",GAState.BirthYearKey="birth_year",GAState.Dimension01Key="dimension01",GAState.Dimension02Key="dimension02",GAState.Dimension03Key="dimension03",GAState.SdkConfigCachedKey="sdk_config_cached",GAState}();state.GAState=GAState}(gameanalytics.state||(gameanalytics.state={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(tasks){var GAUtilities=gameanalytics.utilities.GAUtilities,GALogger=gameanalytics.logging.GALogger,SdkErrorTask=function(){function SdkErrorTask(){}return SdkErrorTask.execute=function(url,type,payloadData,secretKey){if(SdkErrorTask.countMap[type]||(SdkErrorTask.countMap[type]=0),!(SdkErrorTask.countMap[type]>=SdkErrorTask.MaxCount)){var hashHmac=GAUtilities.getHmac(secretKey,payloadData),request=new XMLHttpRequest;request.onreadystatechange=function(){if(4===request.readyState){if(!request.responseText)return;if(200!=request.status)return void GALogger.w("sdk error failed. response code not 200. status code: "+request.status+", description: "+request.statusText+", body: "+request.responseText);SdkErrorTask.countMap[type]=SdkErrorTask.countMap[type]+1}},request.open("POST",url,!0),request.setRequestHeader("Content-Type","application/json"),request.setRequestHeader("Authorization",hashHmac);try{request.send(payloadData)}catch(e){}}},SdkErrorTask.MaxCount=10,SdkErrorTask.countMap={},SdkErrorTask}();tasks.SdkErrorTask=SdkErrorTask}(gameanalytics.tasks||(gameanalytics.tasks={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(http){var GAState=gameanalytics.state.GAState,GALogger=gameanalytics.logging.GALogger,GAUtilities=gameanalytics.utilities.GAUtilities,GAValidator=gameanalytics.validators.GAValidator,SdkErrorTask=gameanalytics.tasks.SdkErrorTask,GAHTTPApi=function(){function GAHTTPApi(){this.protocol="https",this.hostName="api.gameanalytics.com",this.version="v2",this.baseUrl="json/null.json?"+this.protocol+"://"+this.hostName+"/"+this.version,this.initializeUrlPath="init",this.eventsUrlPath="events",this.useGzip=!1}return GAHTTPApi.prototype.requestInit=function(callback){var gameKey=GAState.getGameKey(),url=(this.baseUrl,this.initializeUrlPath);url="json/null.json?https://rubick.gameanalytics.com/v2/command_center?game_key="+gameKey+"&interval_seconds=1000000";var initAnnotations=GAState.getInitAnnotations(),JSONstring=JSON.stringify(initAnnotations);if(JSONstring){var payloadData=this.createPayloadData(JSONstring,this.useGzip),extraArgs=[];extraArgs.push(JSONstring),GAHTTPApi.sendRequest(url,payloadData,extraArgs,this.useGzip,GAHTTPApi.initRequestCallback,callback)}else callback(http.EGAHTTPApiResponse.JsonEncodeFailed,null)},GAHTTPApi.prototype.sendEventsInArray=function(eventArray,requestId,callback){if(0!=eventArray.length){var gameKey=GAState.getGameKey(),url=this.baseUrl+"/"+gameKey+"/"+this.eventsUrlPath,JSONstring=JSON.stringify(eventArray);if(JSONstring){var payloadData=this.createPayloadData(JSONstring,this.useGzip),extraArgs=[];extraArgs.push(JSONstring),extraArgs.push(requestId),extraArgs.push(eventArray.length.toString()),GAHTTPApi.sendRequest(url,payloadData,extraArgs,this.useGzip,GAHTTPApi.sendEventInArrayRequestCallback,callback)}else callback(http.EGAHTTPApiResponse.JsonEncodeFailed,null,requestId,eventArray.length)}},GAHTTPApi.prototype.sendSdkErrorEvent=function(type){if(GAState.isEventSubmissionEnabled()){var gameKey=GAState.getGameKey(),secretKey=GAState.getGameSecret();if(GAValidator.validateSdkErrorEvent(gameKey,secretKey,type)){var payloadJSONString,url=this.baseUrl+"/"+gameKey+"/"+this.eventsUrlPath,json=GAState.getSdkErrorEventAnnotations(),typeString=GAHTTPApi.sdkErrorTypeToString(type);json.type=typeString;var eventArray=[];eventArray.push(json),(payloadJSONString=JSON.stringify(eventArray))?SdkErrorTask.execute(url,type,payloadJSONString,secretKey):GALogger.w("sendSdkErrorEvent: JSON encoding failed.")}}},GAHTTPApi.sendEventInArrayRequestCallback=function(request,url,callback,extra){void 0===extra&&(extra=null);extra[0],extra[1];var body,responseCode,requestId=extra[2],eventCount=parseInt(extra[3]);body=request.responseText,responseCode=request.status;var requestResponseEnum=GAHTTPApi.instance.processRequestResponse(responseCode,request.statusText,body,"Events");if(requestResponseEnum==http.EGAHTTPApiResponse.Ok||requestResponseEnum==http.EGAHTTPApiResponse.BadRequest){var requestJsonDict=body?JSON.parse(body):{};null!=requestJsonDict?(http.EGAHTTPApiResponse.BadRequest,callback(requestResponseEnum,requestJsonDict,requestId,eventCount)):callback(http.EGAHTTPApiResponse.JsonDecodeFailed,null,requestId,eventCount)}else callback(requestResponseEnum,null,requestId,eventCount)},GAHTTPApi.sendRequest=function(url,payloadData,extraArgs,gzip,callback,callback2){var request=new XMLHttpRequest,key=GAState.getGameSecret(),authorization=GAUtilities.getHmac(key,payloadData),args=[];for(var s in args.push(authorization),extraArgs)args.push(extraArgs[s]);if(request.onreadystatechange=function(){4===request.readyState&&callback(request,url,callback2,args)},request.open("POST",url,!0),request.setRequestHeader("Content-Type","text/plain"),request.setRequestHeader("Authorization",authorization),gzip)throw new Error("gzip not supported");try{request.send(payloadData)}catch(e){}},GAHTTPApi.initRequestCallback=function(request,url,callback,extra){void 0===extra&&(extra=null);var body,responseCode;extra[0],extra[1];body=request.responseText,responseCode=request.status;var requestJsonDict=body?JSON.parse(body):{},requestResponseEnum=GAHTTPApi.instance.processRequestResponse(responseCode,request.statusText,body,"Init");if(requestResponseEnum==http.EGAHTTPApiResponse.Ok||requestResponseEnum==http.EGAHTTPApiResponse.BadRequest)if(null!=requestJsonDict)if(requestResponseEnum!==http.EGAHTTPApiResponse.BadRequest){var validatedInitValues=GAValidator.validateAndCleanInitRequestResponse(requestJsonDict);validatedInitValues?callback(http.EGAHTTPApiResponse.Ok,validatedInitValues,"",0):callback(http.EGAHTTPApiResponse.BadResponse,null,"",0)}else callback(requestResponseEnum,null,"",0);else callback(http.EGAHTTPApiResponse.JsonDecodeFailed,null,"",0);else callback(requestResponseEnum,null,"",0)},GAHTTPApi.prototype.createPayloadData=function(payload,gzip){if(gzip)throw new Error("gzip not supported");return payload},GAHTTPApi.prototype.processRequestResponse=function(responseCode,responseMessage,body,requestId){return body?200===responseCode?http.EGAHTTPApiResponse.Ok:0===responseCode||401===responseCode?http.EGAHTTPApiResponse.Unauthorized:400===responseCode?http.EGAHTTPApiResponse.BadRequest:500===responseCode?http.EGAHTTPApiResponse.InternalServerError:http.EGAHTTPApiResponse.UnknownResponseCode:http.EGAHTTPApiResponse.NoResponse},GAHTTPApi.sdkErrorTypeToString=function(value){switch(value){case http.EGASdkErrorType.Rejected:return"rejected";default:return""}},GAHTTPApi.instance=new GAHTTPApi,GAHTTPApi}();http.GAHTTPApi=GAHTTPApi}(gameanalytics.http||(gameanalytics.http={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){var events_1,GAStore,EGAStore,EGAStoreArgsOperator,GAState,GALogger,GAUtilities,EGAHTTPApiResponse,GAHTTPApi,GAValidator,EGASdkErrorType,GAEvents;events_1=gameanalytics.events||(gameanalytics.events={}),GAStore=gameanalytics.store.GAStore,EGAStore=gameanalytics.store.EGAStore,EGAStoreArgsOperator=gameanalytics.store.EGAStoreArgsOperator,GAState=gameanalytics.state.GAState,GALogger=gameanalytics.logging.GALogger,GAUtilities=gameanalytics.utilities.GAUtilities,EGAHTTPApiResponse=gameanalytics.http.EGAHTTPApiResponse,GAHTTPApi=gameanalytics.http.GAHTTPApi,GAValidator=gameanalytics.validators.GAValidator,EGASdkErrorType=gameanalytics.http.EGASdkErrorType,GAEvents=function(){function GAEvents(){}return GAEvents.addSessionStartEvent=function(){if(GAState.isEventSubmissionEnabled()){var eventDict={};eventDict.category=GAEvents.CategorySessionStart,GAState.incrementSessionNum(),GAStore.setItem(GAState.SessionNumKey,GAState.getSessionNum().toString()),GAEvents.addDimensionsToEvent(eventDict),GAEvents.addEventToStore(eventDict),GALogger.i("Add SESSION START event"),GAEvents.processEvents(GAEvents.CategorySessionStart,!1)}},GAEvents.addSessionEndEvent=function(){if(GAState.isEventSubmissionEnabled()){var session_start_ts=GAState.getSessionStart(),sessionLength=GAState.getClientTsAdjusted()-session_start_ts;sessionLength<0&&(GALogger.w("Session length was calculated to be less then 0. Should not be possible. Resetting to 0."),sessionLength=0);var eventDict={};eventDict.category=GAEvents.CategorySessionEnd,eventDict.length=sessionLength,GAEvents.addDimensionsToEvent(eventDict),GAEvents.addEventToStore(eventDict),GALogger.i("Add SESSION END event."),GAEvents.processEvents("",!1)}},GAEvents.addBusinessEvent=function(currency,amount,itemType,itemId,cartType,fields){if(void 0===cartType&&(cartType=null),GAState.isEventSubmissionEnabled())if(GAValidator.validateBusinessEvent(currency,amount,cartType,itemType,itemId)){var eventDict={};GAState.incrementTransactionNum(),GAStore.setItem(GAState.TransactionNumKey,GAState.getTransactionNum().toString()),eventDict.event_id=itemType+":"+itemId,eventDict.category=GAEvents.CategoryBusiness,eventDict.currency=currency,eventDict.amount=amount,eventDict[GAState.TransactionNumKey]=GAState.getTransactionNum(),cartType&&(eventDict.cart_type=cartType),GAEvents.addDimensionsToEvent(eventDict),GAEvents.addFieldsToEvent(eventDict,GAState.validateAndCleanCustomFields(fields)),GALogger.i("Add BUSINESS event: {currency:"+currency+", amount:"+amount+", itemType:"+itemType+", itemId:"+itemId+", cartType:"+cartType+"}"),GAEvents.addEventToStore(eventDict)}else GAHTTPApi.instance.sendSdkErrorEvent(EGASdkErrorType.Rejected)},GAEvents.addResourceEvent=function(flowType,currency,amount,itemType,itemId,fields){if(GAState.isEventSubmissionEnabled())if(GAValidator.validateResourceEvent(flowType,currency,amount,itemType,itemId,GAState.getAvailableResourceCurrencies(),GAState.getAvailableResourceItemTypes())){flowType===gameanalytics.EGAResourceFlowType.Sink&&(amount*=-1);var eventDict={},flowTypeString=GAEvents.resourceFlowTypeToString(flowType);eventDict.event_id=flowTypeString+":"+currency+":"+itemType+":"+itemId,eventDict.category=GAEvents.CategoryResource,eventDict.amount=amount,GAEvents.addDimensionsToEvent(eventDict),GAEvents.addFieldsToEvent(eventDict,GAState.validateAndCleanCustomFields(fields)),GALogger.i("Add RESOURCE event: {currency:"+currency+", amount:"+amount+", itemType:"+itemType+", itemId:"+itemId+"}"),GAEvents.addEventToStore(eventDict)}else GAHTTPApi.instance.sendSdkErrorEvent(EGASdkErrorType.Rejected)},GAEvents.addProgressionEvent=function(progressionStatus,progression01,progression02,progression03,score,sendScore,fields){if(GAState.isEventSubmissionEnabled()){var progressionStatusString=GAEvents.progressionStatusToString(progressionStatus);if(GAValidator.validateProgressionEvent(progressionStatus,progression01,progression02,progression03)){var progressionIdentifier,eventDict={};progressionIdentifier=progression02?progression03?progression01+":"+progression02+":"+progression03:progression01+":"+progression02:progression01,eventDict.category=GAEvents.CategoryProgression,eventDict.event_id=progressionStatusString+":"+progressionIdentifier;var attempt_num=0;sendScore&&progressionStatus!=gameanalytics.EGAProgressionStatus.Start&&(eventDict.score=score),progressionStatus===gameanalytics.EGAProgressionStatus.Fail&&GAState.incrementProgressionTries(progressionIdentifier),progressionStatus===gameanalytics.EGAProgressionStatus.Complete&&(GAState.incrementProgressionTries(progressionIdentifier),attempt_num=GAState.getProgressionTries(progressionIdentifier),eventDict.attempt_num=attempt_num,GAState.clearProgressionTries(progressionIdentifier)),GAEvents.addDimensionsToEvent(eventDict),GAEvents.addFieldsToEvent(eventDict,GAState.validateAndCleanCustomFields(fields)),GALogger.i("Add PROGRESSION event: {status:"+progressionStatusString+", progression01:"+progression01+", progression02:"+progression02+", progression03:"+progression03+", score:"+score+", attempt:"+attempt_num+"}"),GAEvents.addEventToStore(eventDict)}else GAHTTPApi.instance.sendSdkErrorEvent(EGASdkErrorType.Rejected)}},GAEvents.addDesignEvent=function(eventId,value,sendValue,fields){if(GAState.isEventSubmissionEnabled())if(GAValidator.validateDesignEvent(eventId,value)){var eventData={};eventData.category=GAEvents.CategoryDesign,eventData.event_id=eventId,sendValue&&(eventData.value=value),GAEvents.addDimensionsToEvent(eventData),GAEvents.addFieldsToEvent(eventData,GAState.validateAndCleanCustomFields(fields)),GALogger.i("Add DESIGN event: {eventId:"+eventId+", value:"+value+"}"),GAEvents.addEventToStore(eventData)}else GAHTTPApi.instance.sendSdkErrorEvent(EGASdkErrorType.Rejected)},GAEvents.addErrorEvent=function(severity,message,fields){if(GAState.isEventSubmissionEnabled()){var severityString=GAEvents.errorSeverityToString(severity);if(GAValidator.validateErrorEvent(severity,message)){var eventData={};eventData.category=GAEvents.CategoryError,eventData.severity=severityString,eventData.message=message,GAEvents.addDimensionsToEvent(eventData),GAEvents.addFieldsToEvent(eventData,GAState.validateAndCleanCustomFields(fields)),GALogger.i("Add ERROR event: {severity:"+severityString+", message:"+message+"}"),GAEvents.addEventToStore(eventData)}else GAHTTPApi.instance.sendSdkErrorEvent(EGASdkErrorType.Rejected)}},GAEvents.processEvents=function(category,performCleanUp){if(GAState.isEventSubmissionEnabled())try{var requestIdentifier=GAUtilities.createGuid();performCleanUp&&(GAEvents.cleanupEvents(),GAEvents.fixMissingSessionEndEvents());var selectArgs=[];selectArgs.push(["status",EGAStoreArgsOperator.Equal,"new"]);var updateWhereArgs=[];updateWhereArgs.push(["status",EGAStoreArgsOperator.Equal,"new"]),category&&(selectArgs.push(["category",EGAStoreArgsOperator.Equal,category]),updateWhereArgs.push(["category",EGAStoreArgsOperator.Equal,category]));var updateSetArgs=[];updateSetArgs.push(["status",requestIdentifier]);var events=GAStore.select(EGAStore.Events,selectArgs);if(!events||0==events.length)return GALogger.i("Event queue: No events to send"),void GAEvents.updateSessionStore();if(events.length>GAEvents.MaxEventCount){if(!(events=GAStore.select(EGAStore.Events,selectArgs,!0,GAEvents.MaxEventCount)))return;var lastTimestamp=events[events.length-1].client_ts;if(selectArgs.push(["client_ts",EGAStoreArgsOperator.LessOrEqual,lastTimestamp]),!(events=GAStore.select(EGAStore.Events,selectArgs)))return;updateWhereArgs.push(["client_ts",EGAStoreArgsOperator.LessOrEqual,lastTimestamp])}if(GALogger.i("Event queue: Sending "+events.length+" events."),!GAStore.update(EGAStore.Events,updateSetArgs,updateWhereArgs))return;for(var payloadArray=[],i=0;i<events.length;++i){var ev=events[i],eventDict=JSON.parse(GAUtilities.decode64(ev.event));0!=eventDict.length&&payloadArray.push(eventDict)}GAHTTPApi.instance.sendEventsInArray(payloadArray,requestIdentifier,GAEvents.processEventsCallback)}catch(e){GALogger.e("Error during ProcessEvents(): "+e.stack)}},GAEvents.processEventsCallback=function(responseEnum,dataDict,requestId,eventCount){var requestIdWhereArgs=[];if(requestIdWhereArgs.push(["status",EGAStoreArgsOperator.Equal,requestId]),responseEnum===EGAHTTPApiResponse.Ok)GAStore.delete(EGAStore.Events,requestIdWhereArgs),GALogger.i("Event queue: "+eventCount+" events sent.");else if(responseEnum===EGAHTTPApiResponse.NoResponse){var setArgs=[];setArgs.push(["status","new"]),GALogger.w("Event queue: Failed to send events to collector - Retrying next time"),GAStore.update(EGAStore.Events,setArgs,requestIdWhereArgs)}else{if(dataDict){var json,count=0;for(var j in dataDict)0==count&&(json=dataDict[j]),++count;responseEnum===EGAHTTPApiResponse.BadRequest&&json.constructor===Array?GALogger.w("Event queue: "+eventCount+" events sent. "+count+" events failed GA server validation."):GALogger.w("Event queue: Failed to send events.")}else GALogger.w("Event queue: Failed to send events.");GAStore.delete(EGAStore.Events,requestIdWhereArgs)}},GAEvents.cleanupEvents=function(){GAStore.update(EGAStore.Events,[["status","new"]])},GAEvents.fixMissingSessionEndEvents=function(){if(GAState.isEventSubmissionEnabled()){var args=[];args.push(["session_id",EGAStoreArgsOperator.NotEqual,GAState.getSessionId()]);var sessions=GAStore.select(EGAStore.Sessions,args);if(sessions&&0!=sessions.length){GALogger.i(sessions.length+" session(s) located with missing session_end event.");for(var i=0;i<sessions.length;++i){var sessionEndEvent=JSON.parse(GAUtilities.decode64(sessions[i].event)),length=sessionEndEvent.client_ts-sessions[i].timestamp;length=Math.max(0,length),sessionEndEvent.category=GAEvents.CategorySessionEnd,sessionEndEvent.length=length,GAEvents.addEventToStore(sessionEndEvent)}}}},GAEvents.addEventToStore=function(eventData){if(GAState.isEventSubmissionEnabled())if(GAState.isInitialized())try{if(GAStore.isStoreTooLargeForEvents()&&!GAUtilities.stringMatch(eventData.category,/^(user|session_end|business)$/))return void GALogger.w("Database too large. Event has been blocked.");var ev=GAState.getEventAnnotations(),jsonDefaults=GAUtilities.encode64(JSON.stringify(ev));for(var e in eventData)ev[e]=eventData[e];var json=JSON.stringify(ev);GALogger.ii("Event added to queue: "+json);var values={status:"new"};values.category=ev.category,values.session_id=ev.session_id,values.client_ts=ev.client_ts,values.event=GAUtilities.encode64(JSON.stringify(ev)),GAStore.insert(EGAStore.Events,values),eventData.category==GAEvents.CategorySessionEnd?GAStore.delete(EGAStore.Sessions,[["session_id",EGAStoreArgsOperator.Equal,ev.session_id]]):((values={}).session_id=ev.session_id,values.timestamp=GAState.getSessionStart(),values.event=jsonDefaults,GAStore.insert(EGAStore.Sessions,values,!0,"session_id")),GAStore.isStorageAvailable()&&GAStore.save()}catch(e){GALogger.e("addEventToStore: error"),GALogger.e(e.stack)}else GALogger.w("Could not add event: SDK is not initialized")},GAEvents.updateSessionStore=function(){if(GAState.sessionIsStarted()){var values={};values.session_id=GAState.instance.sessionId,values.timestamp=GAState.getSessionStart(),values.event=GAUtilities.encode64(JSON.stringify(GAState.getEventAnnotations())),GAStore.insert(EGAStore.Sessions,values,!0,"session_id"),GAStore.isStorageAvailable()&&GAStore.save()}},GAEvents.addDimensionsToEvent=function(eventData){eventData&&(GAState.getCurrentCustomDimension01()&&(eventData.custom_01=GAState.getCurrentCustomDimension01()),GAState.getCurrentCustomDimension02()&&(eventData.custom_02=GAState.getCurrentCustomDimension02()),GAState.getCurrentCustomDimension03()&&(eventData.custom_03=GAState.getCurrentCustomDimension03()))},GAEvents.addFieldsToEvent=function(eventData,fields){eventData&&fields&&0<Object.keys(fields).length&&(eventData.custom_fields=fields)},GAEvents.resourceFlowTypeToString=function(value){return value==gameanalytics.EGAResourceFlowType.Source||value==gameanalytics.EGAResourceFlowType[gameanalytics.EGAResourceFlowType.Source]?"Source":value==gameanalytics.EGAResourceFlowType.Sink||value==gameanalytics.EGAResourceFlowType[gameanalytics.EGAResourceFlowType.Sink]?"Sink":""},GAEvents.progressionStatusToString=function(value){return value==gameanalytics.EGAProgressionStatus.Start||value==gameanalytics.EGAProgressionStatus[gameanalytics.EGAProgressionStatus.Start]?"Start":value==gameanalytics.EGAProgressionStatus.Complete||value==gameanalytics.EGAProgressionStatus[gameanalytics.EGAProgressionStatus.Complete]?"Complete":value==gameanalytics.EGAProgressionStatus.Fail||value==gameanalytics.EGAProgressionStatus[gameanalytics.EGAProgressionStatus.Fail]?"Fail":""},GAEvents.errorSeverityToString=function(value){return value==gameanalytics.EGAErrorSeverity.Debug||value==gameanalytics.EGAErrorSeverity[gameanalytics.EGAErrorSeverity.Debug]?"debug":value==gameanalytics.EGAErrorSeverity.Info||value==gameanalytics.EGAErrorSeverity[gameanalytics.EGAErrorSeverity.Info]?"info":value==gameanalytics.EGAErrorSeverity.Warning||value==gameanalytics.EGAErrorSeverity[gameanalytics.EGAErrorSeverity.Warning]?"warning":value==gameanalytics.EGAErrorSeverity.Error||value==gameanalytics.EGAErrorSeverity[gameanalytics.EGAErrorSeverity.Error]?"error":value==gameanalytics.EGAErrorSeverity.Critical||value==gameanalytics.EGAErrorSeverity[gameanalytics.EGAErrorSeverity.Critical]?"critical":""},GAEvents.instance=new GAEvents,GAEvents.CategorySessionStart="user",GAEvents.CategorySessionEnd="session_end",GAEvents.CategoryDesign="design",GAEvents.CategoryBusiness="business",GAEvents.CategoryProgression="progression",GAEvents.CategoryResource="resource",GAEvents.CategoryError="error",GAEvents.MaxEventCount=500,GAEvents}(),events_1.GAEvents=GAEvents}(gameanalytics||(gameanalytics={})),function(gameanalytics){!function(threading){var GALogger=gameanalytics.logging.GALogger,GAState=gameanalytics.state.GAState,GAEvents=gameanalytics.events.GAEvents,GAThreading=function(){function GAThreading(){this.blocks=new threading.PriorityQueue({compare:function(x,y){return x-y}}),this.id2TimedBlockMap={},GAThreading.startThread()}return GAThreading.createTimedBlock=function(delayInSeconds){void 0===delayInSeconds&&(delayInSeconds=0);var time=new Date;return time.setSeconds(time.getSeconds()+delayInSeconds),new threading.TimedBlock(time)},GAThreading.performTaskOnGAThread=function(taskBlock,delayInSeconds){void 0===delayInSeconds&&(delayInSeconds=0);var time=new Date;time.setSeconds(time.getSeconds()+delayInSeconds);var timedBlock=new threading.TimedBlock(time);timedBlock.block=taskBlock,GAThreading.instance.id2TimedBlockMap[timedBlock.id]=timedBlock,GAThreading.instance.addTimedBlock(timedBlock)},GAThreading.performTimedBlockOnGAThread=function(timedBlock){GAThreading.instance.id2TimedBlockMap[timedBlock.id]=timedBlock,GAThreading.instance.addTimedBlock(timedBlock)},GAThreading.scheduleTimer=function(interval,callback){var time=new Date;time.setSeconds(time.getSeconds()+interval);var timedBlock=new threading.TimedBlock(time);return timedBlock.block=callback,GAThreading.instance.id2TimedBlockMap[timedBlock.id]=timedBlock,GAThreading.instance.addTimedBlock(timedBlock),timedBlock.id},GAThreading.getTimedBlockById=function(blockIdentifier){return blockIdentifier in GAThreading.instance.id2TimedBlockMap?GAThreading.instance.id2TimedBlockMap[blockIdentifier]:null},GAThreading.ensureEventQueueIsRunning=function(){GAThreading.instance.keepRunning=!0,GAThreading.instance.isRunning||(GAThreading.instance.isRunning=!0,GAThreading.scheduleTimer(GAThreading.ProcessEventsIntervalInSeconds,GAThreading.processEventQueue))},GAThreading.endSessionAndStopQueue=function(){GAState.isInitialized()&&(GALogger.i("Ending session."),GAThreading.stopEventQueue(),GAState.isEnabled()&&GAState.sessionIsStarted()&&(GAEvents.addSessionEndEvent(),GAState.instance.sessionStart=0))},GAThreading.stopEventQueue=function(){GAThreading.instance.keepRunning=!1},GAThreading.ignoreTimer=function(blockIdentifier){blockIdentifier in GAThreading.instance.id2TimedBlockMap&&(GAThreading.instance.id2TimedBlockMap[blockIdentifier].ignore=!0)},GAThreading.setEventProcessInterval=function(interval){0<interval&&(GAThreading.ProcessEventsIntervalInSeconds=interval)},GAThreading.prototype.addTimedBlock=function(timedBlock){this.blocks.enqueue(timedBlock.deadline.getTime(),timedBlock)},GAThreading.run=function(){clearTimeout(GAThreading.runTimeoutId);try{for(var timedBlock;timedBlock=GAThreading.getNextBlock();)if(!timedBlock.ignore)if(timedBlock.async){if(!timedBlock.running){timedBlock.running=!0,timedBlock.block();break}}else timedBlock.block();return void(GAThreading.runTimeoutId=setTimeout(GAThreading.run,GAThreading.ThreadWaitTimeInMs))}catch(e){GALogger.e("Error on GA thread"),GALogger.e(e.stack)}},GAThreading.startThread=function(){GAThreading.runTimeoutId=setTimeout(GAThreading.run,0)},GAThreading.getNextBlock=function(){var now=new Date;return GAThreading.instance.blocks.hasItems()&&GAThreading.instance.blocks.peek().deadline.getTime()<=now.getTime()?GAThreading.instance.blocks.peek().async&&GAThreading.instance.blocks.peek().running?GAThreading.instance.blocks.peek():GAThreading.instance.blocks.dequeue():null},GAThreading.processEventQueue=function(){GAEvents.processEvents("",!0),GAThreading.instance.keepRunning?GAThreading.scheduleTimer(GAThreading.ProcessEventsIntervalInSeconds,GAThreading.processEventQueue):GAThreading.instance.isRunning=!1},GAThreading.instance=new GAThreading,GAThreading.ThreadWaitTimeInMs=1e3,GAThreading.ProcessEventsIntervalInSeconds=8,GAThreading}();threading.GAThreading=GAThreading}(gameanalytics.threading||(gameanalytics.threading={}))}(gameanalytics||(gameanalytics={})),function(gameanalytics){var GAThreading=gameanalytics.threading.GAThreading,GALogger=gameanalytics.logging.GALogger,GAStore=gameanalytics.store.GAStore,GAState=gameanalytics.state.GAState,GAHTTPApi=gameanalytics.http.GAHTTPApi,GADevice=gameanalytics.device.GADevice,GAValidator=gameanalytics.validators.GAValidator,EGAHTTPApiResponse=gameanalytics.http.EGAHTTPApiResponse,GAUtilities=gameanalytics.utilities.GAUtilities,GAEvents=gameanalytics.events.GAEvents,GameAnalytics=function(){function GameAnalytics(){}return GameAnalytics.init=function(){if(GADevice.touch(),GameAnalytics.methodMap.configureAvailableCustomDimensions01=GameAnalytics.configureAvailableCustomDimensions01,GameAnalytics.methodMap.configureAvailableCustomDimensions02=GameAnalytics.configureAvailableCustomDimensions02,GameAnalytics.methodMap.configureAvailableCustomDimensions03=GameAnalytics.configureAvailableCustomDimensions03,GameAnalytics.methodMap.configureAvailableResourceCurrencies=GameAnalytics.configureAvailableResourceCurrencies,GameAnalytics.methodMap.configureAvailableResourceItemTypes=GameAnalytics.configureAvailableResourceItemTypes,GameAnalytics.methodMap.configureBuild=GameAnalytics.configureBuild,GameAnalytics.methodMap.configureSdkGameEngineVersion=GameAnalytics.configureSdkGameEngineVersion,GameAnalytics.methodMap.configureGameEngineVersion=GameAnalytics.configureGameEngineVersion,GameAnalytics.methodMap.configureUserId=GameAnalytics.configureUserId,GameAnalytics.methodMap.initialize=GameAnalytics.initialize,GameAnalytics.methodMap.addBusinessEvent=GameAnalytics.addBusinessEvent,GameAnalytics.methodMap.addResourceEvent=GameAnalytics.addResourceEvent,GameAnalytics.methodMap.addProgressionEvent=GameAnalytics.addProgressionEvent,GameAnalytics.methodMap.addDesignEvent=GameAnalytics.addDesignEvent,GameAnalytics.methodMap.addErrorEvent=GameAnalytics.addErrorEvent,GameAnalytics.methodMap.addErrorEvent=GameAnalytics.addErrorEvent,GameAnalytics.methodMap.setEnabledInfoLog=GameAnalytics.setEnabledInfoLog,GameAnalytics.methodMap.setEnabledVerboseLog=GameAnalytics.setEnabledVerboseLog,GameAnalytics.methodMap.setEnabledManualSessionHandling=GameAnalytics.setEnabledManualSessionHandling,GameAnalytics.methodMap.setEnabledEventSubmission=GameAnalytics.setEnabledEventSubmission,GameAnalytics.methodMap.setCustomDimension01=GameAnalytics.setCustomDimension01,GameAnalytics.methodMap.setCustomDimension02=GameAnalytics.setCustomDimension02,GameAnalytics.methodMap.setCustomDimension03=GameAnalytics.setCustomDimension03,GameAnalytics.methodMap.setFacebookId=GameAnalytics.setFacebookId,GameAnalytics.methodMap.setGender=GameAnalytics.setGender,GameAnalytics.methodMap.setBirthYear=GameAnalytics.setBirthYear,GameAnalytics.methodMap.setEventProcessInterval=GameAnalytics.setEventProcessInterval,GameAnalytics.methodMap.startSession=GameAnalytics.startSession,GameAnalytics.methodMap.endSession=GameAnalytics.endSession,GameAnalytics.methodMap.onStop=GameAnalytics.onStop,GameAnalytics.methodMap.onResume=GameAnalytics.onResume,GameAnalytics.methodMap.addCommandCenterListener=GameAnalytics.addCommandCenterListener,GameAnalytics.methodMap.removeCommandCenterListener=GameAnalytics.removeCommandCenterListener,GameAnalytics.methodMap.getCommandCenterValueAsString=GameAnalytics.getCommandCenterValueAsString,GameAnalytics.methodMap.isCommandCenterReady=GameAnalytics.isCommandCenterReady,GameAnalytics.methodMap.getConfigurationsContentAsString=GameAnalytics.getConfigurationsContentAsString,"undefined"!=typeof window&&void 0!==window.GameAnalytics&&void 0!==window.GameAnalytics.q){var q=window.GameAnalytics.q;for(var i in q)GameAnalytics.gaCommand.apply(null,q[i])}},GameAnalytics.gaCommand=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];0<args.length&&args[0]in gameanalytics.GameAnalytics.methodMap&&(1<args.length?gameanalytics.GameAnalytics.methodMap[args[0]].apply(null,Array.prototype.slice.call(args,1)):gameanalytics.GameAnalytics.methodMap[args[0]]())},GameAnalytics.configureAvailableCustomDimensions01=function(customDimensions){void 0===customDimensions&&(customDimensions=[]),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("Available custom dimensions must be set before SDK is initialized"):GAState.setAvailableCustomDimensions01(customDimensions)})},GameAnalytics.configureAvailableCustomDimensions02=function(customDimensions){void 0===customDimensions&&(customDimensions=[]),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("Available custom dimensions must be set before SDK is initialized"):GAState.setAvailableCustomDimensions02(customDimensions)})},GameAnalytics.configureAvailableCustomDimensions03=function(customDimensions){void 0===customDimensions&&(customDimensions=[]),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("Available custom dimensions must be set before SDK is initialized"):GAState.setAvailableCustomDimensions03(customDimensions)})},GameAnalytics.configureAvailableResourceCurrencies=function(resourceCurrencies){void 0===resourceCurrencies&&(resourceCurrencies=[]),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("Available resource currencies must be set before SDK is initialized"):GAState.setAvailableResourceCurrencies(resourceCurrencies)})},GameAnalytics.configureAvailableResourceItemTypes=function(resourceItemTypes){void 0===resourceItemTypes&&(resourceItemTypes=[]),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("Available resource item types must be set before SDK is initialized"):GAState.setAvailableResourceItemTypes(resourceItemTypes)})},GameAnalytics.configureBuild=function(build){void 0===build&&(build=""),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("Build version must be set before SDK is initialized."):GAValidator.validateBuild(build)?GAState.setBuild(build):GALogger.i("Validation fail - configure build: Cannot be null, empty or above 32 length. String: "+build)})},GameAnalytics.configureSdkGameEngineVersion=function(sdkGameEngineVersion){void 0===sdkGameEngineVersion&&(sdkGameEngineVersion=""),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)||(GAValidator.validateSdkWrapperVersion(sdkGameEngineVersion)?GADevice.sdkGameEngineVersion=sdkGameEngineVersion:GALogger.i("Validation fail - configure sdk version: Sdk version not supported. String: "+sdkGameEngineVersion))})},GameAnalytics.configureGameEngineVersion=function(gameEngineVersion){void 0===gameEngineVersion&&(gameEngineVersion=""),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)||(GAValidator.validateEngineVersion(gameEngineVersion)?GADevice.gameEngineVersion=gameEngineVersion:GALogger.i("Validation fail - configure game engine version: Game engine version not supported. String: "+gameEngineVersion))})},GameAnalytics.configureUserId=function(uId){void 0===uId&&(uId=""),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("A custom user id must be set before SDK is initialized."):GAValidator.validateUserId(uId)?GAState.setUserId(uId):GALogger.i("Validation fail - configure user_id: Cannot be null, empty or above 64 length. Will use default user_id method. Used string: "+uId)})},GameAnalytics.initialize=function(gameKey,gameSecret){void 0===gameKey&&(gameKey=""),void 0===gameSecret&&(gameSecret=""),GADevice.updateConnectionType();var timedBlock=GAThreading.createTimedBlock();timedBlock.async=!0,GameAnalytics.initTimedBlockId=timedBlock.id,timedBlock.block=function(){GameAnalytics.isSdkReady(!0,!1)?GALogger.w("SDK already initialized. Can only be called once."):GAValidator.validateKeys(gameKey,gameSecret)?(GAState.setKeys(gameKey,gameSecret),GameAnalytics.internalInitialize()):GALogger.w("SDK failed initialize. Game key or secret key is invalid. Can only contain characters A-z 0-9, gameKey is 32 length, gameSecret is 40 length. Failed keys - gameKey: "+gameKey+", secretKey: "+gameSecret)},GAThreading.performTimedBlockOnGAThread(timedBlock)},GameAnalytics.addBusinessEvent=function(currency,amount,itemType,itemId,cartType){void 0===currency&&(currency=""),void 0===amount&&(amount=0),void 0===itemType&&(itemType=""),void 0===itemId&&(itemId=""),void 0===cartType&&(cartType=""),GADevice.updateConnectionType(),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!0,"Could not add business event")&&GAEvents.addBusinessEvent(currency,amount,itemType,itemId,cartType,{})})},GameAnalytics.addResourceEvent=function(flowType,currency,amount,itemType,itemId){void 0===flowType&&(flowType=gameanalytics.EGAResourceFlowType.Undefined),void 0===currency&&(currency=""),void 0===amount&&(amount=0),void 0===itemType&&(itemType=""),void 0===itemId&&(itemId=""),GADevice.updateConnectionType(),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!0,"Could not add resource event")&&GAEvents.addResourceEvent(flowType,currency,amount,itemType,itemId,{})})},GameAnalytics.addProgressionEvent=function(progressionStatus,progression01,progression02,progression03,score){void 0===progressionStatus&&(progressionStatus=gameanalytics.EGAProgressionStatus.Undefined),void 0===progression01&&(progression01=""),void 0===progression02&&(progression02=""),void 0===progression03&&(progression03=""),GADevice.updateConnectionType(),GAThreading.performTaskOnGAThread(function(){if(GameAnalytics.isSdkReady(!0,!0,"Could not add progression event")){var sendScore="number"==typeof score;GAEvents.addProgressionEvent(progressionStatus,progression01,progression02,progression03,sendScore?score:0,sendScore,{})}})},GameAnalytics.addDesignEvent=function(eventId,value){GADevice.updateConnectionType(),GAThreading.performTaskOnGAThread(function(){if(GameAnalytics.isSdkReady(!0,!0,"Could not add design event")){var sendValue="number"==typeof value;GAEvents.addDesignEvent(eventId,sendValue?value:0,sendValue,{})}})},GameAnalytics.addErrorEvent=function(severity,message){void 0===severity&&(severity=gameanalytics.EGAErrorSeverity.Undefined),void 0===message&&(message=""),GADevice.updateConnectionType(),GAThreading.performTaskOnGAThread(function(){GameAnalytics.isSdkReady(!0,!0,"Could not add error event")&&GAEvents.addErrorEvent(severity,message,{})})},GameAnalytics.setEnabledInfoLog=function(flag){void 0===flag&&(flag=!1),GAThreading.performTaskOnGAThread(function(){flag?(GALogger.setInfoLog(flag),GALogger.i("Info logging enabled")):(GALogger.i("Info logging disabled"),GALogger.setInfoLog(flag))})},GameAnalytics.setEnabledVerboseLog=function(flag){void 0===flag&&(flag=!1),GAThreading.performTaskOnGAThread(function(){flag?(GALogger.setVerboseLog(flag),GALogger.i("Verbose logging enabled")):(GALogger.i("Verbose logging disabled"),GALogger.setVerboseLog(flag))})},GameAnalytics.setEnabledManualSessionHandling=function(flag){void 0===flag&&(flag=!1),GAThreading.performTaskOnGAThread(function(){GAState.setManualSessionHandling(flag)})},GameAnalytics.setEnabledEventSubmission=function(flag){void 0===flag&&(flag=!1),GAThreading.performTaskOnGAThread(function(){flag?(GAState.setEnabledEventSubmission(flag),GALogger.i("Event submission enabled")):(GALogger.i("Event submission disabled"),GAState.setEnabledEventSubmission(flag))})},GameAnalytics.setCustomDimension01=function(dimension){void 0===dimension&&(dimension=""),GAThreading.performTaskOnGAThread(function(){GAValidator.validateDimension01(dimension,GAState.getAvailableCustomDimensions01())?GAState.setCustomDimension01(dimension):GALogger.w("Could not set custom01 dimension value to '"+dimension+"'. Value not found in available custom01 dimension values")})},GameAnalytics.setCustomDimension02=function(dimension){void 0===dimension&&(dimension=""),GAThreading.performTaskOnGAThread(function(){GAValidator.validateDimension02(dimension,GAState.getAvailableCustomDimensions02())?GAState.setCustomDimension02(dimension):GALogger.w("Could not set custom02 dimension value to '"+dimension+"'. Value not found in available custom02 dimension values")})},GameAnalytics.setCustomDimension03=function(dimension){void 0===dimension&&(dimension=""),GAThreading.performTaskOnGAThread(function(){GAValidator.validateDimension03(dimension,GAState.getAvailableCustomDimensions03())?GAState.setCustomDimension03(dimension):GALogger.w("Could not set custom03 dimension value to '"+dimension+"'. Value not found in available custom03 dimension values")})},GameAnalytics.setFacebookId=function(facebookId){void 0===facebookId&&(facebookId=""),GAThreading.performTaskOnGAThread(function(){GAValidator.validateFacebookId(facebookId)&&GAState.setFacebookId(facebookId)})},GameAnalytics.setGender=function(gender){void 0===gender&&(gender=gameanalytics.EGAGender.Undefined),GAThreading.performTaskOnGAThread(function(){GAValidator.validateGender(gender)&&GAState.setGender(gender)})},GameAnalytics.setBirthYear=function(birthYear){void 0===birthYear&&(birthYear=0),GAThreading.performTaskOnGAThread(function(){GAValidator.validateBirthyear(birthYear)&&GAState.setBirthYear(birthYear)})},GameAnalytics.setEventProcessInterval=function(intervalInSeconds){GAThreading.performTaskOnGAThread(function(){GAThreading.setEventProcessInterval(intervalInSeconds)})},GameAnalytics.startSession=function(){if(GAState.isInitialized()){var timedBlock=GAThreading.createTimedBlock();timedBlock.async=!0,GameAnalytics.initTimedBlockId=timedBlock.id,timedBlock.block=function(){GAState.isEnabled()&&GAState.sessionIsStarted()&&GAThreading.endSessionAndStopQueue(),GameAnalytics.resumeSessionAndStartQueue()},GAThreading.performTimedBlockOnGAThread(timedBlock)}},GameAnalytics.endSession=function(){GameAnalytics.onStop()},GameAnalytics.onStop=function(){GAThreading.performTaskOnGAThread(function(){try{GAThreading.endSessionAndStopQueue()}catch(Exception){}})},GameAnalytics.onResume=function(){var timedBlock=GAThreading.createTimedBlock();timedBlock.async=!0,GameAnalytics.initTimedBlockId=timedBlock.id,timedBlock.block=function(){GameAnalytics.resumeSessionAndStartQueue()},GAThreading.performTimedBlockOnGAThread(timedBlock)},GameAnalytics.getCommandCenterValueAsString=function(key,defaultValue){return void 0===defaultValue&&(defaultValue=null),GAState.getConfigurationStringValue(key,defaultValue)},GameAnalytics.isCommandCenterReady=function(){return GAState.isCommandCenterReady()},GameAnalytics.addCommandCenterListener=function(listener){GAState.addCommandCenterListener(listener)},GameAnalytics.removeCommandCenterListener=function(listener){GAState.removeCommandCenterListener(listener)},GameAnalytics.getConfigurationsContentAsString=function(){return GAState.getConfigurationsContentAsString()},GameAnalytics.internalInitialize=function(){GAState.ensurePersistedStates(),GAStore.setItem(GAState.DefaultUserIdKey,GAState.getDefaultId()),GAState.setInitialized(!0),GameAnalytics.newSession(),GAState.isEnabled()&&GAThreading.ensureEventQueueIsRunning()},GameAnalytics.newSession=function(){GALogger.i("Starting a new session."),GAState.validateAndFixCurrentDimensions(),GAHTTPApi.instance.requestInit(GameAnalytics.startNewSessionCallback)},GameAnalytics.startNewSessionCallback=function(initResponse,initResponseDict){if(initResponse===EGAHTTPApiResponse.Ok&&initResponseDict){var timeOffsetSeconds=0;if(initResponseDict.server_ts){var serverTs=initResponseDict.server_ts;timeOffsetSeconds=GAState.calculateServerTimeOffset(serverTs)}initResponseDict.time_offset=timeOffsetSeconds,GAStore.setItem(GAState.SdkConfigCachedKey,GAUtilities.encode64(JSON.stringify(initResponseDict))),GAState.instance.sdkConfigCached=initResponseDict,GAState.instance.sdkConfig=initResponseDict,GAState.instance.initAuthorized=!0}else initResponse==EGAHTTPApiResponse.Unauthorized?(GALogger.w("Initialize SDK failed - Unauthorized"),GAState.instance.initAuthorized=!1):(initResponse===EGAHTTPApiResponse.NoResponse||initResponse===EGAHTTPApiResponse.RequestTimeout?GALogger.i("Init call (session start) failed - no response. Could be offline or timeout."):initResponse===EGAHTTPApiResponse.BadResponse||initResponse===EGAHTTPApiResponse.JsonEncodeFailed||initResponse===EGAHTTPApiResponse.JsonDecodeFailed?GALogger.i("Init call (session start) failed - bad response. Could be bad response from proxy or GA servers."):initResponse!==EGAHTTPApiResponse.BadRequest&&initResponse!==EGAHTTPApiResponse.UnknownResponseCode||GALogger.i("Init call (session start) failed - bad request or unknown response."),null==GAState.instance.sdkConfig?null!=GAState.instance.sdkConfigCached?(GALogger.i("Init call (session start) failed - using cached init values."),GAState.instance.sdkConfig=GAState.instance.sdkConfigCached):(GALogger.i("Init call (session start) failed - using default init values."),GAState.instance.sdkConfig=GAState.instance.sdkConfigDefault):GALogger.i("Init call (session start) failed - using cached init values."),GAState.instance.initAuthorized=!0);if(GAState.instance.clientServerTimeOffset=GAState.getSdkConfig().time_offset?GAState.getSdkConfig().time_offset:0,GAState.populateConfigurations(GAState.getSdkConfig()),!GAState.isEnabled())return GALogger.w("Could not start session: SDK is disabled."),void GAThreading.stopEventQueue();GAThreading.ensureEventQueueIsRunning();var newSessionId=GAUtilities.createGuid();GAState.instance.sessionId=newSessionId,GAState.instance.sessionStart=GAState.getClientTsAdjusted(),GAEvents.addSessionStartEvent();var timedBlock=GAThreading.getTimedBlockById(GameAnalytics.initTimedBlockId);null!=timedBlock&&(timedBlock.running=!1),GameAnalytics.initTimedBlockId=-1},GameAnalytics.resumeSessionAndStartQueue=function(){GAState.isInitialized()&&(GALogger.i("Resuming session."),GAState.sessionIsStarted()||GameAnalytics.newSession())},GameAnalytics.isSdkReady=function(needsInitialized,warn,message){return void 0===warn&&(warn=!0),void 0===message&&(message=""),message&&(message+=": "),needsInitialized&&!GAState.isInitialized()?(warn&&GALogger.w(message+"SDK is not initialized"),!1):needsInitialized&&!GAState.isEnabled()?(warn&&GALogger.w(message+"SDK is disabled"),!1):!(needsInitialized&&!GAState.sessionIsStarted())||(warn&&GALogger.w(message+"Session has not started yet"),!1)},GameAnalytics.initTimedBlockId=-1,GameAnalytics.methodMap={},GameAnalytics}();gameanalytics.GameAnalytics=GameAnalytics}(gameanalytics||(gameanalytics={})),gameanalytics.GameAnalytics.init();gameanalytics.GameAnalytics.gaCommand;var GameAnalytics_node=gameanalytics,GameAnalytics$1=function(){function GameAnalytics(){}return GameAnalytics.prototype.setup=function(key,secret,version){Branding$$1.analyticsEnabled&&(GameAnalytics_node.GameAnalytics.initialize(key,secret),GameAnalytics_node.GameAnalytics.configureBuild(version),GameAnalytics_node.GameAnalytics.startSession(),window.addEventListener("beforeunload",function(){GameAnalytics_node.GameAnalytics.endSession()}))},GameAnalytics.prototype.addProgressionEvent=function(progressionStatus,progression01,progression02,progression03,score){Branding$$1.analyticsEnabled&&GameAnalytics_node.GameAnalytics.addProgressionEvent(progressionStatus,progression01,progression02,progression03,score)},GameAnalytics.prototype.addDesignEvent=function(eventId,value){Branding$$1.analyticsEnabled&&GameAnalytics_node.GameAnalytics.addDesignEvent(eventId,value)},GameAnalytics}();function __awaiter(thisArg,_arguments,P,generator){return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value))}catch(e){reject(e)}}function rejected(value){try{step(generator.throw(value))}catch(e){reject(e)}}function step(result){result.done?resolve(result.value):new P(function(resolve){resolve(result.value)}).then(fulfilled,rejected)}step((generator=generator.apply(thisArg,_arguments||[])).next())})}function __generator(thisArg,body){var f,y,t,g,_={label:0,sent:function(){if(1&t[0])throw t[1];return t[1]},trys:[],ops:[]};return g={next:verb(0),throw:verb(1),return:verb(2)},"function"==typeof Symbol&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return function(op){if(f)throw new TypeError("Generator is already executing.");for(;_;)try{if(f=1,y&&(t=2&op[0]?y.return:op[0]?y.throw||((t=y.return)&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;switch(y=0,t&&(op=[2&op[0],t.value]),op[0]){case 0:case 1:t=op;break;case 4:return _.label++,{value:op[1],done:!1};case 5:_.label++,y=op[1],op=[0];continue;case 7:op=_.ops.pop(),_.trys.pop();continue;default:if(!(t=0<(t=_.trys).length&&t[t.length-1])&&(6===op[0]||2===op[0])){_=0;continue}if(3===op[0]&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(6===op[0]&&_.label<t[1]){_.label=t[1],t=op;break}if(t&&_.label<t[2]){_.label=t[2],_.ops.push(op);break}t[2]&&_.ops.pop(),_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e],y=0}finally{f=t=0}if(5&op[0])throw op[1];return{value:op[0]?op[1]:void 0,done:!0}}([n,v])}}}var progressbar=createCommonjsModule(function(module,exports){module.exports=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=commonjsRequire;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i=commonjsRequire,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){(function(){var mockTweenable,root=this||Function("return this")(),Tweenable=function(){var formula,DEFAULT_SCHEDULE_FUNCTION,timeoutHandler_endTime,timeoutHandler_currentTime,timeoutHandler_isEnded,timeoutHandler_offset,_now=Date.now?Date.now:function(){return+new Date},now="undefined"!=typeof SHIFTY_DEBUG_NOW?SHIFTY_DEBUG_NOW:_now;function noop(){}function each(obj,fn){var key;for(key in obj)Object.hasOwnProperty.call(obj,key)&&fn(key)}function shallowCopy(targetObj,srcObj){return each(srcObj,function(prop){targetObj[prop]=srcObj[prop]}),targetObj}function defaults(target,src){each(src,function(prop){void 0===target[prop]&&(target[prop]=src[prop])})}function tweenProps(forPosition,currentState,originalState,targetState,duration,timestamp,easing){var prop,easingObjectProp,easingFn,normalizedPosition=forPosition<timestamp?0:(forPosition-timestamp)/duration;for(prop in currentState)currentState.hasOwnProperty(prop)&&(easingObjectProp=easing[prop],easingFn="function"==typeof easingObjectProp?easingObjectProp:formula[easingObjectProp],currentState[prop]=tweenProp(originalState[prop],targetState[prop],easingFn,normalizedPosition));return currentState}function tweenProp(start,end,easingFunc,position){return start+(end-start)*easingFunc(position)}function applyFilter(tweenable,filterName){var filters=Tweenable.prototype.filter,args=tweenable._filterArgs;each(filters,function(name){void 0!==filters[name][filterName]&&filters[name][filterName].apply(tweenable,args)})}function timeoutHandler(tweenable,timestamp,delay,duration,currentState,originalState,targetState,easing,step,schedule,opt_currentTimeOverride){timeoutHandler_endTime=timestamp+delay+duration,timeoutHandler_currentTime=Math.min(opt_currentTimeOverride||now(),timeoutHandler_endTime),timeoutHandler_isEnded=timeoutHandler_endTime<=timeoutHandler_currentTime,timeoutHandler_offset=duration-(timeoutHandler_endTime-timeoutHandler_currentTime),tweenable.isPlaying()&&(timeoutHandler_isEnded?(step(targetState,tweenable._attachment,timeoutHandler_offset),tweenable.stop(!0)):(tweenable._scheduleId=schedule(tweenable._timeoutHandler,1e3/60),applyFilter(tweenable,"beforeTween"),timeoutHandler_currentTime<timestamp+delay?tweenProps(1,currentState,originalState,targetState,1,1,easing):tweenProps(timeoutHandler_currentTime,currentState,originalState,targetState,duration,timestamp+delay,easing),applyFilter(tweenable,"afterTween"),step(currentState,tweenable._attachment,timeoutHandler_offset)))}function composeEasingObject(fromTweenParams,easing){var composedEasing={},typeofEasing=typeof easing;return each(fromTweenParams,"string"===typeofEasing||"function"===typeofEasing?function(prop){composedEasing[prop]=easing}:function(prop){composedEasing[prop]||(composedEasing[prop]=easing[prop]||"linear")}),composedEasing}function Tweenable(opt_initialState,opt_config){this._currentState=opt_initialState||{},this._configured=!1,this._scheduleFunction=DEFAULT_SCHEDULE_FUNCTION,void 0!==opt_config&&this.setConfig(opt_config)}return DEFAULT_SCHEDULE_FUNCTION="undefined"!=typeof window&&(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||window.mozCancelRequestAnimationFrame&&window.mozRequestAnimationFrame)||setTimeout,Tweenable.prototype.tween=function(opt_config){return this._isTweening?this:(void 0===opt_config&&this._configured||this.setConfig(opt_config),this._timestamp=now(),this._start(this.get(),this._attachment),this.resume())},Tweenable.prototype.setConfig=function(config){config=config||{},this._configured=!0,this._attachment=config.attachment,this._pausedAtTime=null,this._scheduleId=null,this._delay=config.delay||0,this._start=config.start||noop,this._step=config.step||noop,this._finish=config.finish||noop,this._duration=config.duration||500,this._currentState=shallowCopy({},config.from||this.get()),this._originalState=this.get(),this._targetState=shallowCopy({},config.to||this.get());var self=this;this._timeoutHandler=function(){timeoutHandler(self,self._timestamp,self._delay,self._duration,self._currentState,self._originalState,self._targetState,self._easing,self._step,self._scheduleFunction)};var currentState=this._currentState,targetState=this._targetState;return defaults(targetState,currentState),this._easing=composeEasingObject(currentState,config.easing||"linear"),this._filterArgs=[currentState,this._originalState,targetState,this._easing],applyFilter(this,"tweenCreated"),this},Tweenable.prototype.get=function(){return shallowCopy({},this._currentState)},Tweenable.prototype.set=function(state){this._currentState=state},Tweenable.prototype.pause=function(){return this._pausedAtTime=now(),this._isPaused=!0,this},Tweenable.prototype.resume=function(){return this._isPaused&&(this._timestamp+=now()-this._pausedAtTime),this._isPaused=!1,this._isTweening=!0,this._timeoutHandler(),this},Tweenable.prototype.seek=function(millisecond){millisecond=Math.max(millisecond,0);var currentTime=now();return this._timestamp+millisecond===0||(this._timestamp=currentTime-millisecond,this.isPlaying()||(this._isTweening=!0,this._isPaused=!1,timeoutHandler(this,this._timestamp,this._delay,this._duration,this._currentState,this._originalState,this._targetState,this._easing,this._step,this._scheduleFunction,currentTime),this.pause())),this},Tweenable.prototype.stop=function(gotoEnd){return this._isTweening=!1,this._isPaused=!1,this._timeoutHandler=noop,(root.cancelAnimationFrame||root.webkitCancelAnimationFrame||root.oCancelAnimationFrame||root.msCancelAnimationFrame||root.mozCancelRequestAnimationFrame||root.clearTimeout)(this._scheduleId),gotoEnd&&(applyFilter(this,"beforeTween"),tweenProps(1,this._currentState,this._originalState,this._targetState,1,0,this._easing),applyFilter(this,"afterTween"),applyFilter(this,"afterTweenEnd"),this._finish.call(this,this._currentState,this._attachment)),this},Tweenable.prototype.isPlaying=function(){return this._isTweening&&!this._isPaused},Tweenable.prototype.setScheduleFunction=function(scheduleFunction){this._scheduleFunction=scheduleFunction},Tweenable.prototype.dispose=function(){var prop;for(prop in this)this.hasOwnProperty(prop)&&delete this[prop]},Tweenable.prototype.filter={},formula=Tweenable.prototype.formula={linear:function(pos){return pos}},shallowCopy(Tweenable,{now:now,each:each,tweenProps:tweenProps,tweenProp:tweenProp,applyFilter:applyFilter,shallowCopy:shallowCopy,defaults:defaults,composeEasingObject:composeEasingObject}),"function"==typeof SHIFTY_DEBUG_NOW&&(root.timeoutHandler=timeoutHandler),"object"==typeof exports?module.exports=Tweenable:void 0===root.Tweenable&&(root.Tweenable=Tweenable),Tweenable}();Tweenable.shallowCopy(Tweenable.prototype.formula,{easeInQuad:function(pos){return Math.pow(pos,2)},easeOutQuad:function(pos){return-(Math.pow(pos-1,2)-1)},easeInOutQuad:function(pos){return(pos/=.5)<1?.5*Math.pow(pos,2):-.5*((pos-=2)*pos-2)},easeInCubic:function(pos){return Math.pow(pos,3)},easeOutCubic:function(pos){return Math.pow(pos-1,3)+1},easeInOutCubic:function(pos){return(pos/=.5)<1?.5*Math.pow(pos,3):.5*(Math.pow(pos-2,3)+2)},easeInQuart:function(pos){return Math.pow(pos,4)},easeOutQuart:function(pos){return-(Math.pow(pos-1,4)-1)},easeInOutQuart:function(pos){return(pos/=.5)<1?.5*Math.pow(pos,4):-.5*((pos-=2)*Math.pow(pos,3)-2)},easeInQuint:function(pos){return Math.pow(pos,5)},easeOutQuint:function(pos){return Math.pow(pos-1,5)+1},easeInOutQuint:function(pos){return(pos/=.5)<1?.5*Math.pow(pos,5):.5*(Math.pow(pos-2,5)+2)},easeInSine:function(pos){return 1-Math.cos(pos*(Math.PI/2))},easeOutSine:function(pos){return Math.sin(pos*(Math.PI/2))},easeInOutSine:function(pos){return-.5*(Math.cos(Math.PI*pos)-1)},easeInExpo:function(pos){return 0===pos?0:Math.pow(2,10*(pos-1))},easeOutExpo:function(pos){return 1===pos?1:1-Math.pow(2,-10*pos)},easeInOutExpo:function(pos){return 0===pos?0:1===pos?1:(pos/=.5)<1?.5*Math.pow(2,10*(pos-1)):.5*(2-Math.pow(2,-10*--pos))},easeInCirc:function(pos){return-(Math.sqrt(1-pos*pos)-1)},easeOutCirc:function(pos){return Math.sqrt(1-Math.pow(pos-1,2))},easeInOutCirc:function(pos){return(pos/=.5)<1?-.5*(Math.sqrt(1-pos*pos)-1):.5*(Math.sqrt(1-(pos-=2)*pos)+1)},easeOutBounce:function(pos){return pos<1/2.75?7.5625*pos*pos:pos<2/2.75?7.5625*(pos-=1.5/2.75)*pos+.75:pos<2.5/2.75?7.5625*(pos-=2.25/2.75)*pos+.9375:7.5625*(pos-=2.625/2.75)*pos+.984375},easeInBack:function(pos){var s=1.70158;return pos*pos*((s+1)*pos-s)},easeOutBack:function(pos){var s=1.70158;return(pos-=1)*pos*((s+1)*pos+s)+1},easeInOutBack:function(pos){var s=1.70158;return(pos/=.5)<1?pos*pos*((1+(s*=1.525))*pos-s)*.5:.5*((pos-=2)*pos*((1+(s*=1.525))*pos+s)+2)},elastic:function(pos){return-1*Math.pow(4,-8*pos)*Math.sin((6*pos-1)*(2*Math.PI)/2)+1},swingFromTo:function(pos){var s=1.70158;return(pos/=.5)<1?pos*pos*((1+(s*=1.525))*pos-s)*.5:.5*((pos-=2)*pos*((1+(s*=1.525))*pos+s)+2)},swingFrom:function(pos){var s=1.70158;return pos*pos*((s+1)*pos-s)},swingTo:function(pos){var s=1.70158;return(pos-=1)*pos*((s+1)*pos+s)+1},bounce:function(pos){return pos<1/2.75?7.5625*pos*pos:pos<2/2.75?7.5625*(pos-=1.5/2.75)*pos+.75:pos<2.5/2.75?7.5625*(pos-=2.25/2.75)*pos+.9375:7.5625*(pos-=2.625/2.75)*pos+.984375},bouncePast:function(pos){return pos<1/2.75?7.5625*pos*pos:pos<2/2.75?2-(7.5625*(pos-=1.5/2.75)*pos+.75):pos<2.5/2.75?2-(7.5625*(pos-=2.25/2.75)*pos+.9375):2-(7.5625*(pos-=2.625/2.75)*pos+.984375)},easeFromTo:function(pos){return(pos/=.5)<1?.5*Math.pow(pos,4):-.5*((pos-=2)*Math.pow(pos,3)-2)},easeFrom:function(pos){return Math.pow(pos,4)},easeTo:function(pos){return Math.pow(pos,.25)}}),function(){function cubicBezierAtTime(t,p1x,p1y,p2x,p2y,duration){var ax=0,bx=0,cx=0,ay=0,by=0,cy=0;function sampleCurveX(t){return((ax*t+bx)*t+cx)*t}function fabs(n){return 0<=n?n:0-n}function solveCurveX(x,epsilon){var t0,t1,t2,x2,d2,i,t;for(t2=x,i=0;i<8;i++){if(fabs(x2=sampleCurveX(t2)-x)<epsilon)return t2;if(fabs(d2=(3*ax*(t=t2)+2*bx)*t+cx)<1e-6)break;t2-=x2/d2}if(t1=1,(t2=x)<(t0=0))return t0;if(t1<t2)return t1;for(;t0<t1;){if(fabs((x2=sampleCurveX(t2))-x)<epsilon)return t2;x2<x?t0=t2:t1=t2,t2=.5*(t1-t0)+t0}return t2}return ax=1-(cx=3*p1x)-(bx=3*(p2x-p1x)-cx),ay=1-(cy=3*p1y)-(by=3*(p2y-p1y)-cy),function(x,epsilon){return t=solveCurveX(x,epsilon),((ay*t+by)*t+cy)*t;var t}(t,function(duration){return 1/(200*duration)}(duration))}Tweenable.setBezierFunction=function(name,x1,y1,x2,y2){var cubicBezierTransition=function(x1,y1,x2,y2){return function(pos){return cubicBezierAtTime(pos,x1,y1,x2,y2,1)}}(x1,y1,x2,y2);return cubicBezierTransition.displayName=name,cubicBezierTransition.x1=x1,cubicBezierTransition.y1=y1,cubicBezierTransition.x2=x2,cubicBezierTransition.y2=y2,Tweenable.prototype.formula[name]=cubicBezierTransition},Tweenable.unsetBezierFunction=function(name){delete Tweenable.prototype.formula[name]}}(),(mockTweenable=new Tweenable)._filterArgs=[],Tweenable.interpolate=function(from,targetState,position,easing,opt_delay){var current=Tweenable.shallowCopy({},from),delay=opt_delay||0,easingObject=Tweenable.composeEasingObject(from,easing||"linear");mockTweenable.set({});var filterArgs=mockTweenable._filterArgs;filterArgs.length=0,filterArgs[0]=current,filterArgs[1]=from,filterArgs[2]=targetState,filterArgs[3]=easingObject,Tweenable.applyFilter(mockTweenable,"tweenCreated"),Tweenable.applyFilter(mockTweenable,"beforeTween");var interpolatedValues=function(from,current,targetState,position,easing,delay){return Tweenable.tweenProps(position,current,from,targetState,1,delay,easing)}(from,current,targetState,position,easingObject,delay);return Tweenable.applyFilter(mockTweenable,"afterTween"),interpolatedValues},function(Tweenable){var R_NUMBER_COMPONENT=/(\d|\-|\.)/,R_FORMAT_CHUNKS=/([^\-0-9\.]+)/g,R_UNFORMATTED_VALUES=/[0-9.\-]+/g,R_RGB=new RegExp("rgb\\("+R_UNFORMATTED_VALUES.source+/,\s*/.source+R_UNFORMATTED_VALUES.source+/,\s*/.source+R_UNFORMATTED_VALUES.source+"\\)","g"),R_RGB_PREFIX=/^.*\(/,R_HEX=/#([0-9]|[a-f]){3,6}/gi,VALUE_PLACEHOLDER="VAL";function sanitizeObjectForHexProps(stateObject){Tweenable.each(stateObject,function(prop){var currentProp=stateObject[prop];"string"==typeof currentProp&&currentProp.match(R_HEX)&&(stateObject[prop]=filterStringChunks(R_HEX,currentProp,convertHexToRGB))})}function convertHexToRGB(hexString){var hex,rgbArr=(3===(hex=(hex=hexString).replace(/#/,"")).length&&(hex=(hex=hex.split(""))[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2]),hexToRGBArray_returnArray[0]=hexToDec(hex.substr(0,2)),hexToRGBArray_returnArray[1]=hexToDec(hex.substr(2,2)),hexToRGBArray_returnArray[2]=hexToDec(hex.substr(4,2)),hexToRGBArray_returnArray);return"rgb("+rgbArr[0]+","+rgbArr[1]+","+rgbArr[2]+")"}var hexToRGBArray_returnArray=[];function hexToDec(hex){return parseInt(hex,16)}function filterStringChunks(pattern,unfilteredString,filter){var pattenMatches=unfilteredString.match(pattern),filteredString=unfilteredString.replace(pattern,VALUE_PLACEHOLDER);if(pattenMatches)for(var currentChunk,pattenMatchesLength=pattenMatches.length,i=0;i<pattenMatchesLength;i++)currentChunk=pattenMatches.shift(),filteredString=filteredString.replace(VALUE_PLACEHOLDER,filter(currentChunk));return filteredString}function sanitizeRGBChunk(rgbChunk){for(var numbers=rgbChunk.match(R_UNFORMATTED_VALUES),numbersLength=numbers.length,sanitizedString=rgbChunk.match(R_RGB_PREFIX)[0],i=0;i<numbersLength;i++)sanitizedString+=parseInt(numbers[i],10)+",";return sanitizedString=sanitizedString.slice(0,-1)+")"}function getFormatManifests(stateObject){var manifestAccumulator={};return Tweenable.each(stateObject,function(prop){var formattedString,chunks,currentProp=stateObject[prop];if("string"==typeof currentProp){var rawValues=getValuesFrom(currentProp);manifestAccumulator[prop]={formatString:(formattedString=currentProp,chunks=formattedString.match(R_FORMAT_CHUNKS),chunks?(1===chunks.length||formattedString.charAt(0).match(R_NUMBER_COMPONENT))&&chunks.unshift(""):chunks=["",""],chunks.join(VALUE_PLACEHOLDER)),chunkNames:function(rawValues,prefix){var i,accumulator=[],rawValuesLength=rawValues.length;for(i=0;i<rawValuesLength;i++)accumulator.push("_"+prefix+"_"+i);return accumulator}(rawValues,prop)}}}),manifestAccumulator}function expandFormattedProperties(stateObject,formatManifests){Tweenable.each(formatManifests,function(prop){for(var currentProp=stateObject[prop],rawValues=getValuesFrom(currentProp),rawValuesLength=rawValues.length,i=0;i<rawValuesLength;i++)stateObject[formatManifests[prop].chunkNames[i]]=+rawValues[i];delete stateObject[prop]})}function collapseFormattedProperties(stateObject,formatManifests){Tweenable.each(formatManifests,function(prop){var currentProp=stateObject[prop],formatChunks=function(stateObject,chunkNames){for(var currentChunkName,extractedValues={},chunkNamesLength=chunkNames.length,i=0;i<chunkNamesLength;i++)currentChunkName=chunkNames[i],extractedValues[currentChunkName]=stateObject[currentChunkName],delete stateObject[currentChunkName];return extractedValues}(stateObject,formatManifests[prop].chunkNames),valuesList=function(stateObject,chunkNames){getValuesList_accumulator.length=0;for(var chunkNamesLength=chunkNames.length,i=0;i<chunkNamesLength;i++)getValuesList_accumulator.push(stateObject[chunkNames[i]]);return getValuesList_accumulator}(formatChunks,formatManifests[prop].chunkNames);currentProp=function(formatString,rawValues){for(var formattedValueString=formatString,rawValuesLength=rawValues.length,i=0;i<rawValuesLength;i++)formattedValueString=formattedValueString.replace(VALUE_PLACEHOLDER,+rawValues[i].toFixed(4));return formattedValueString}(formatManifests[prop].formatString,valuesList),stateObject[prop]=filterStringChunks(R_RGB,currentProp,sanitizeRGBChunk)})}var getValuesList_accumulator=[];function getValuesFrom(formattedString){return formattedString.match(R_UNFORMATTED_VALUES)}Tweenable.prototype.filter.token={tweenCreated:function(currentState,fromState,toState,easingObject){sanitizeObjectForHexProps(currentState),sanitizeObjectForHexProps(fromState),sanitizeObjectForHexProps(toState),this._tokenData=getFormatManifests(currentState)},beforeTween:function(currentState,fromState,toState,easingObject){!function(easingObject,tokenData){Tweenable.each(tokenData,function(prop){var i,currentProp=tokenData[prop],chunkNames=currentProp.chunkNames,chunkLength=chunkNames.length,easing=easingObject[prop];if("string"==typeof easing){var easingChunks=easing.split(" "),lastEasingChunk=easingChunks[easingChunks.length-1];for(i=0;i<chunkLength;i++)easingObject[chunkNames[i]]=easingChunks[i]||lastEasingChunk}else for(i=0;i<chunkLength;i++)easingObject[chunkNames[i]]=easing;delete easingObject[prop]})}(easingObject,this._tokenData),expandFormattedProperties(currentState,this._tokenData),expandFormattedProperties(fromState,this._tokenData),expandFormattedProperties(toState,this._tokenData)},afterTween:function(currentState,fromState,toState,easingObject){collapseFormattedProperties(currentState,this._tokenData),collapseFormattedProperties(fromState,this._tokenData),collapseFormattedProperties(toState,this._tokenData),function(easingObject,tokenData){Tweenable.each(tokenData,function(prop){var currentProp=tokenData[prop],chunkNames=currentProp.chunkNames,chunkLength=chunkNames.length,firstEasing=easingObject[chunkNames[0]],typeofEasings=typeof firstEasing;if("string"===typeofEasings){for(var composedEasingString="",i=0;i<chunkLength;i++)composedEasingString+=" "+easingObject[chunkNames[i]],delete easingObject[chunkNames[i]];easingObject[prop]=composedEasingString.substr(1)}else easingObject[prop]=firstEasing})}(easingObject,this._tokenData)}}}(Tweenable)}).call(null)},{}],2:[function(require,module,exports){var Shape=require("./shape"),utils=require("./utils"),Circle=function(container,options){this._pathTemplate="M 50,50 m 0,-{radius} a {radius},{radius} 0 1 1 0,{2radius} a {radius},{radius} 0 1 1 0,-{2radius}",this.containerAspectRatio=1,Shape.apply(this,arguments)};((Circle.prototype=new Shape).constructor=Circle).prototype._pathString=function(opts){var widthOfWider=opts.strokeWidth;opts.trailWidth&&opts.trailWidth>opts.strokeWidth&&(widthOfWider=opts.trailWidth);var r=50-widthOfWider/2;return utils.render(this._pathTemplate,{radius:r,"2radius":2*r})},Circle.prototype._trailString=function(opts){return this._pathString(opts)},module.exports=Circle},{"./shape":7,"./utils":9}],3:[function(require,module,exports){var Shape=require("./shape"),utils=require("./utils"),Line=function(container,options){this._pathTemplate="M 0,{center} L 100,{center}",Shape.apply(this,arguments)};((Line.prototype=new Shape).constructor=Line).prototype._initializeSvg=function(svg,opts){svg.setAttribute("viewBox","0 0 100 "+opts.strokeWidth),svg.setAttribute("preserveAspectRatio","none")},Line.prototype._pathString=function(opts){return utils.render(this._pathTemplate,{center:opts.strokeWidth/2})},Line.prototype._trailString=function(opts){return this._pathString(opts)},module.exports=Line},{"./shape":7,"./utils":9}],4:[function(require,module,exports){module.exports={Line:require("./line"),Circle:require("./circle"),SemiCircle:require("./semicircle"),Square:require("./square"),Path:require("./path"),Shape:require("./shape"),utils:require("./utils")}},{"./circle":2,"./line":3,"./path":5,"./semicircle":6,"./shape":7,"./square":8,"./utils":9}],5:[function(require,module,exports){var Tweenable=require("shifty"),utils=require("./utils"),EASING_ALIASES={easeIn:"easeInCubic",easeOut:"easeOutCubic",easeInOut:"easeInOutCubic"},Path=function Path(path,opts){if(!(this instanceof Path))throw new Error("Constructor was called without new keyword");var element;opts=utils.extend({duration:800,easing:"linear",from:{},to:{},step:function(){}},opts),element=utils.isString(path)?document.querySelector(path):path,this.path=element,this._opts=opts,this._tweenable=null;var length=this.path.getTotalLength();this.path.style.strokeDasharray=length+" "+length,this.set(0)};Path.prototype.value=function(){var offset=this._getComputedDashOffset(),length=this.path.getTotalLength(),progress=1-offset/length;return parseFloat(progress.toFixed(6),10)},Path.prototype.set=function(progress){this.stop(),this.path.style.strokeDashoffset=this._progressToOffset(progress);var step=this._opts.step;if(utils.isFunction(step)){var easing=this._easing(this._opts.easing),values=this._calculateTo(progress,easing),reference=this._opts.shape||this;step(values,reference,this._opts.attachment)}},Path.prototype.stop=function(){this._stopTween(),this.path.style.strokeDashoffset=this._getComputedDashOffset()},Path.prototype.animate=function(progress,opts,cb){opts=opts||{},utils.isFunction(opts)&&(cb=opts,opts={});var passedOpts=utils.extend({},opts),defaultOpts=utils.extend({},this._opts);opts=utils.extend(defaultOpts,opts);var shiftyEasing=this._easing(opts.easing),values=this._resolveFromAndTo(progress,shiftyEasing,passedOpts);this.stop(),this.path.getBoundingClientRect();var offset=this._getComputedDashOffset(),newOffset=this._progressToOffset(progress),self=this;this._tweenable=new Tweenable,this._tweenable.tween({from:utils.extend({offset:offset},values.from),to:utils.extend({offset:newOffset},values.to),duration:opts.duration,easing:shiftyEasing,step:function(state){self.path.style.strokeDashoffset=state.offset;var reference=opts.shape||self;opts.step(state,reference,opts.attachment)},finish:function(state){utils.isFunction(cb)&&cb()}})},Path.prototype._getComputedDashOffset=function(){var computedStyle=window.getComputedStyle(this.path,null);return parseFloat(computedStyle.getPropertyValue("stroke-dashoffset"),10)},Path.prototype._progressToOffset=function(progress){var length=this.path.getTotalLength();return length-progress*length},Path.prototype._resolveFromAndTo=function(progress,easing,opts){return opts.from&&opts.to?{from:opts.from,to:opts.to}:{from:this._calculateFrom(easing),to:this._calculateTo(progress,easing)}},Path.prototype._calculateFrom=function(easing){return Tweenable.interpolate(this._opts.from,this._opts.to,this.value(),easing)},Path.prototype._calculateTo=function(progress,easing){return Tweenable.interpolate(this._opts.from,this._opts.to,progress,easing)},Path.prototype._stopTween=function(){null!==this._tweenable&&(this._tweenable.stop(),this._tweenable=null)},Path.prototype._easing=function(easing){return EASING_ALIASES.hasOwnProperty(easing)?EASING_ALIASES[easing]:easing},module.exports=Path},{"./utils":9,shifty:1}],6:[function(require,module,exports){var Shape=require("./shape"),Circle=require("./circle"),utils=require("./utils"),SemiCircle=function(container,options){this._pathTemplate="M 50,50 m -{radius},0 a {radius},{radius} 0 1 1 {2radius},0",this.containerAspectRatio=2,Shape.apply(this,arguments)};((SemiCircle.prototype=new Shape).constructor=SemiCircle).prototype._initializeSvg=function(svg,opts){svg.setAttribute("viewBox","0 0 100 50")},SemiCircle.prototype._initializeTextContainer=function(opts,container,textContainer){opts.text.style&&(textContainer.style.top="auto",textContainer.style.bottom="0",opts.text.alignToBottom?utils.setStyle(textContainer,"transform","translate(-50%, 0)"):utils.setStyle(textContainer,"transform","translate(-50%, 50%)"))},SemiCircle.prototype._pathString=Circle.prototype._pathString,SemiCircle.prototype._trailString=Circle.prototype._trailString,module.exports=SemiCircle},{"./circle":2,"./shape":7,"./utils":9}],7:[function(require,module,exports){var Path=require("./path"),utils=require("./utils"),Shape=function Shape(container,opts){if(!(this instanceof Shape))throw new Error("Constructor was called without new keyword");if(0!==arguments.length){this._opts=utils.extend({color:"#555",strokeWidth:1,trailColor:null,trailWidth:null,fill:null,text:{style:{color:null,position:"absolute",left:"50%",top:"50%",padding:0,margin:0,transform:{prefix:!0,value:"translate(-50%, -50%)"}},autoStyleContainer:!0,alignToBottom:!0,value:null,className:"progressbar-text"},svgStyle:{display:"block",width:"100%"},warnings:!1},opts,!0),utils.isObject(opts)&&void 0!==opts.svgStyle&&(this._opts.svgStyle=opts.svgStyle),utils.isObject(opts)&&utils.isObject(opts.text)&&void 0!==opts.text.style&&(this._opts.text.style=opts.text.style);var element,svgView=this._createSvgView(this._opts);if(!(element=utils.isString(container)?document.querySelector(container):container))throw new Error("Container does not exist: "+container);this._container=element,this._container.appendChild(svgView.svg),this._opts.warnings&&this._warnContainerAspectRatio(this._container),this._opts.svgStyle&&utils.setStyles(svgView.svg,this._opts.svgStyle),this.svg=svgView.svg,this.path=svgView.path,this.trail=svgView.trail,this.text=null;var newOpts=utils.extend({attachment:void 0,shape:this},this._opts);this._progressPath=new Path(svgView.path,newOpts),utils.isObject(this._opts.text)&&null!==this._opts.text.value&&this.setText(this._opts.text.value)}};Shape.prototype.animate=function(progress,opts,cb){if(null===this._progressPath)throw new Error("Object is destroyed");this._progressPath.animate(progress,opts,cb)},Shape.prototype.stop=function(){if(null===this._progressPath)throw new Error("Object is destroyed");void 0!==this._progressPath&&this._progressPath.stop()},Shape.prototype.destroy=function(){if(null===this._progressPath)throw new Error("Object is destroyed");this.stop(),this.svg.parentNode.removeChild(this.svg),this.svg=null,this.path=null,this.trail=null,(this._progressPath=null)!==this.text&&(this.text.parentNode.removeChild(this.text),this.text=null)},Shape.prototype.set=function(progress){if(null===this._progressPath)throw new Error("Object is destroyed");this._progressPath.set(progress)},Shape.prototype.value=function(){if(null===this._progressPath)throw new Error("Object is destroyed");return void 0===this._progressPath?0:this._progressPath.value()},Shape.prototype.setText=function(newText){if(null===this._progressPath)throw new Error("Object is destroyed");null===this.text&&(this.text=this._createTextContainer(this._opts,this._container),this._container.appendChild(this.text)),utils.isObject(newText)?(utils.removeChildren(this.text),this.text.appendChild(newText)):this.text.innerHTML=newText},Shape.prototype._createSvgView=function(opts){var svg=document.createElementNS("http://www.w3.org/2000/svg","svg");this._initializeSvg(svg,opts);var trailPath=null;(opts.trailColor||opts.trailWidth)&&(trailPath=this._createTrail(opts),svg.appendChild(trailPath));var path=this._createPath(opts);return svg.appendChild(path),{svg:svg,path:path,trail:trailPath}},Shape.prototype._initializeSvg=function(svg,opts){svg.setAttribute("viewBox","0 0 100 100")},Shape.prototype._createPath=function(opts){var pathString=this._pathString(opts);return this._createPathElement(pathString,opts)},Shape.prototype._createTrail=function(opts){var pathString=this._trailString(opts),newOpts=utils.extend({},opts);return newOpts.trailColor||(newOpts.trailColor="#eee"),newOpts.trailWidth||(newOpts.trailWidth=newOpts.strokeWidth),newOpts.color=newOpts.trailColor,newOpts.strokeWidth=newOpts.trailWidth,newOpts.fill=null,this._createPathElement(pathString,newOpts)},Shape.prototype._createPathElement=function(pathString,opts){var path=document.createElementNS("http://www.w3.org/2000/svg","path");return path.setAttribute("d",pathString),path.setAttribute("stroke",opts.color),path.setAttribute("stroke-width",opts.strokeWidth),opts.fill?path.setAttribute("fill",opts.fill):path.setAttribute("fill-opacity","0"),path},Shape.prototype._createTextContainer=function(opts,container){var textContainer=document.createElement("div");textContainer.className=opts.text.className;var textStyle=opts.text.style;return textStyle&&(opts.text.autoStyleContainer&&(container.style.position="relative"),utils.setStyles(textContainer,textStyle),textStyle.color||(textContainer.style.color=opts.color)),this._initializeTextContainer(opts,container,textContainer),textContainer},Shape.prototype._initializeTextContainer=function(opts,container,element){},Shape.prototype._pathString=function(opts){throw new Error("Override this function for each progress bar")},Shape.prototype._trailString=function(opts){throw new Error("Override this function for each progress bar")},Shape.prototype._warnContainerAspectRatio=function(container){if(this.containerAspectRatio){var computedStyle=window.getComputedStyle(container,null),width=parseFloat(computedStyle.getPropertyValue("width"),10),height=parseFloat(computedStyle.getPropertyValue("height"),10);utils.floatEquals(this.containerAspectRatio,width/height)}},module.exports=Shape},{"./path":5,"./utils":9}],8:[function(require,module,exports){var Shape=require("./shape"),utils=require("./utils"),Square=function(container,options){this._pathTemplate="M 0,{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{strokeWidth}",this._trailTemplate="M {startMargin},{halfOfStrokeWidth} L {width},{halfOfStrokeWidth} L {width},{width} L {halfOfStrokeWidth},{width} L {halfOfStrokeWidth},{halfOfStrokeWidth}",Shape.apply(this,arguments)};((Square.prototype=new Shape).constructor=Square).prototype._pathString=function(opts){var w=100-opts.strokeWidth/2;return utils.render(this._pathTemplate,{width:w,strokeWidth:opts.strokeWidth,halfOfStrokeWidth:opts.strokeWidth/2})},Square.prototype._trailString=function(opts){var w=100-opts.strokeWidth/2;return utils.render(this._trailTemplate,{width:w,strokeWidth:opts.strokeWidth,halfOfStrokeWidth:opts.strokeWidth/2,startMargin:opts.strokeWidth/2-opts.trailWidth/2})},module.exports=Square},{"./shape":7,"./utils":9}],9:[function(require,module,exports){var PREFIXES="Webkit Moz O ms".split(" ");function setStyle(element,style,value){for(var elStyle=element.style,i=0;i<PREFIXES.length;++i){var prefix=PREFIXES[i];elStyle[prefix+capitalize(style)]=value}elStyle[style]=value}function capitalize(text){return text.charAt(0).toUpperCase()+text.slice(1)}function isObject(obj){if(function(obj){return"[object Array]"===Object.prototype.toString.call(obj)}(obj))return!1;var type=typeof obj;return"object"===type&&!!obj}function forEachObject(object,callback){for(var key in object)if(object.hasOwnProperty(key)){var val=object[key];callback(val,key)}}module.exports={extend:function extend(destination,source,recursive){for(var attrName in destination=destination||{},recursive=recursive||!1,source=source||{})if(source.hasOwnProperty(attrName)){var destVal=destination[attrName],sourceVal=source[attrName];recursive&&isObject(destVal)&&isObject(sourceVal)?destination[attrName]=extend(destVal,sourceVal,recursive):destination[attrName]=sourceVal}return destination},render:function(template,vars){var rendered=template;for(var key in vars)if(vars.hasOwnProperty(key)){var val=vars[key],regExpString="\\{"+key+"\\}",regExp=new RegExp(regExpString,"g");rendered=rendered.replace(regExp,val)}return rendered},setStyle:setStyle,setStyles:function(element,styles){forEachObject(styles,function(styleValue,styleName){null!=styleValue&&(isObject(styleValue)&&!0===styleValue.prefix?setStyle(element,styleName,styleValue.value):element.style[styleName]=styleValue)})},capitalize:capitalize,isString:function(obj){return"string"==typeof obj||obj instanceof String},isFunction:function(obj){return"function"==typeof obj},isObject:isObject,forEachObject:forEachObject,floatEquals:function(a,b){return Math.abs(a-b)<.001},removeChildren:function(el){for(;el.firstChild;)el.removeChild(el.firstChild)}}},{}]},{},[4])(4)});var SplashLoader=function(){function SplashLoader(options){this.circleLoader=null,this.loaded=!1,this.showPlayButton="undefined"==typeof playBtn||playBtn,this.progress=0,this.options={gameId:"12346",gameTitle:"Place Holder",gameName:"place-holder",libs:[],version:"dev",barColor:"white",gaMeasurementId:"none"},this.options.gameId=options.gameId,this.options.gameTitle=options.gameTitle,this.options.version=options.version,this.options.barColor=options.barColor?options.barColor:this.options.barColor,this.options.libs=options.libs,this.options.gaMeasurementId=options.gaMeasurementId}return SplashLoader.getInstance=function(options){if(!SplashLoader.instance){if(!options)throw new Error("Can not create new SplashLoader instance without options!");SplashLoader.instance=new SplashLoader(options)}return SplashLoader.instance},SplashLoader.prototype.create=function(){return __awaiter(this,void 0,void 0,function(){var css,html,head,style,container,body,versionDiv;return __generator(this,function(_a){switch(_a.label){case 0:return css="\n #h5branding-center {\n position: absolute;\n top: 45%;\n left: 50%;\n transform: translate(-50%, -20%);\n text-align: center;\n width: 100%;\n }\n #h5branding-wrapper {\n position: relative;\n z-index: 665;\n width: 150px;\n height: 150px;\n display:inline-block;\n margin: 35px 40px 96px 40px;\n }\n\n #h5branding-version {\n position: absolute;\n right: 5px;\n font-family: Helvetica, Arial, sans-serif;\n color: #ffffff;\n font-size: 0.5em;\n top: 5px;\n }\n\n #h5branding-wrapper > #h5branding-bar, #h5branding-wrapper > img {\n box-shadow: inset 10px 10px 20px 5px rgba(0, 0, 0, 0.5);\n border-radius: 50%;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n }\n\n #h5branding-ad {\n position: relative;\n z-index: 667;\n border-radius: 5px;\n border: 3px solid white;\n background: rgba(256, 256, 256, 0.2);\n width: 336px;\n height: 280px;\n display: none;\n margin: 0px 10px 0px 10px;\n }\n\n #h5branding-wrapper > img {\n /* Needs appropriate vendor prefixes */\n box-sizing: border-box;\n\n /* This needs to be equal to strokeWidth */\n padding: 4%;\n }\n\n #h5branding-wrapper > img {\n border-radius: 50%;\n box-shadow: inset 0 5px 5px rgba(0, 0, 0, 0.5), 5px 5px 7px rgba(0, 0, 0, 0.3);\n }\n\n #h5branding-container {\n box-sizing: border-box;\n position: absolute;\n z-index: 664;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: #000;\n overflow: hidden;\n }\n\n #h5branding-background {\n position: absolute;\n top: -25%;\n left: -25%;\n width: 150%;\n height: 150%;\n background-blend-mode: multiply;\n background-size: cover;\n filter: blur(40px) brightness(1.5);\n }\n\n @media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {\n /* IE10+ CSS styles go here */\n #h5branding-background {\n background-image: none !important;\n }\n }\n\n #h5branding-logo {\n position: absolute;\n margin: 0 auto;\n left: 0;\n right: 0;\n text-align: center;\n top: 10%;\n }\n\n #h5branding-logo > img {\n height: 150px;\n }\n\n #h5branding-title {\n position: absolute;\n width: 100%;\n background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.5) 50%, transparent);\n color: #fff;\n text-shadow: 0 0 1px rgba(0, 0, 0, 0.7);\n bottom:10%;\n padding: 15px 0;\n text-align: center;\n font-size: 18px;\n font-family: Helvetica, Arial, sans-serif;\n font-weight: bold;\n line-height: 100%;\n }\n\n #h5branding-button {\n /* border: 0; */\n padding: 10px 22px;\n border-radius: 5px;\n border: 3px solid white;\n background: linear-gradient(0deg, #dddddd, #ffffff);\n color: #222;\n text-transform: uppercase;\n text-shadow: 0 0 1px #fff;\n font-family: Helvetica, Arial, sans-serif;\n font-weight: bold;\n font-size: 18px;\n cursor: pointer;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);\n display: none;\n width: 150px;\n position: absolute;\n top: 170px;\n margin: 0 auto;\n left: 0;\n right: 0;\n }\n\n @media (orientation: portrait) and (max-width: 1080px) {\n #h5branding-logo > img {\n height: initial;\n width:100%;\n }\n }\n\n @media (orientation: landscape) and (max-height: 640px) {\n #h5branding-title {\n display: none;\n }\n\n #h5branding-logo > img {\n height: 100px;\n }\n }\n\n @media (orientation: landscape) and (max-height: 460px) {\n #h5branding-title {\n display: none;\n }\n\n #h5branding-wrapper {\n width: 110px;\n height: 110px;\n margin: 0;\n }\n\n #h5branding-logo {\n top: 0;\n transform: scale(0.7, 0.7);\n }\n\n #h5branding-button {\n top: initial;\n width: 110px;\n font-size: 14px;\n position: absolute;\n top: 140px;\n left: 0;\n right: 0;\n }\n\n #h5branding-ad {\n display: none !important;\n }\n }\n\n @media (orientation: portrait) and (max-width: 250px) {\n #h5branding-logo {\n top: 2%;\n }\n }\n\n @media (orientation: landscape) and (max-width: 330px) {\n #h5branding-button {\n top: 120px;\n }\n\n #h5branding-logo > img {\n height: 70px;\n }\n }\n\n @media (max-width: 600px) and (max-height: 850px) {\n #h5branding-ad {\n display: none !important;\n }\n }\n\n @media (max-width: 600px) and (max-height: 1100px) {\n #h5branding-center {\n top: 40%;\n }\n\n #h5branding-title {\n bottom: 5%\n }\n }\n\n @media (max-width: 600px) and (max-height: 900px) {\n #h5branding-title {\n display: none\n }\n }\n\n @media (orientation: landscape) and (min-width: 800px) {\n #h5branding-wrapper {\n margin-left: 120px;\n margin-right: 120px;\n }\n }\n\n ",gameLogo=this.getGameLogoUrl(this.options.gameId),gameTitle=this.options.gameTitle,html='\n <div id="h5branding-background"></div>\n <div id="h5branding-version"></div>\n <div id="h5branding-logo"></div>\n <div id="h5branding-center">\n <div id="h5branding-ad"></div>\n <div id="h5branding-wrapper">\n <img src="'+gameLogo+'" />\n <div id="h5branding-bar"></div>\n <button id="h5branding-button" onclick="h5branding.SplashLoader.getInstance().onPlayButtonClick();">Play</button>\n </div>\n </div>\n <div id="h5branding-title">'+gameTitle+"</div>\n ",head=document.head||document.getElementsByTagName("head")[0],(style=document.createElement("style")).type="text/css",style.styleSheet?style.styleSheet.cssText=css:style.appendChild(document.createTextNode(css)),head.appendChild(style),(container=document.createElement("div")).innerHTML=html,container.id="h5branding-container",(body=document.body||document.getElementsByTagName("body")[0]).insertBefore(container,body.firstChild),this.circleLoader=new progressbar.Circle("#h5branding-bar",{strokeWidth:3,color:this.options.barColor}),this.options.gaMeasurementId&&(GoogleAnalytics.GAMeasurementId=this.options.gaMeasurementId),(versionDiv=document.getElementById("h5branding-version"))&&(versionDiv.innerHTML=this.options.version),[4,Promise.all([this.loadBranding(),this.loadLibs(),GoogleAnalytics.preload()])];case 1:return _a.sent(),this.loaded=!0,[2]}var gameLogo,gameTitle})})},SplashLoader.prototype.loadBranding=function(){return __awaiter(this,void 0,void 0,function(){var background,logoContainer,logo;return __generator(this,function(_a){switch(_a.label){case 0:return[4,Branding$$1.preload(Date.now().toString())];case 1:return _a.sent(),(background=document.getElementById("h5branding-background"))&&(background.style.backgroundImage="url("+this.getGameLogoUrl(this.options.gameId)+")",background.style.backgroundColor=Branding$$1.brandingBackgroundColor),(logoContainer=document.getElementById("h5branding-logo"))&&Utils.getBrandingDomain()!==exports.BrandingDomain.Neutral&&((logo=document.createElement("img")).src=Branding$$1.brandingLogoUrl.replace("_small",""),logoContainer.appendChild(logo)),[2]}})})},SplashLoader.prototype.loadLibs=function(){var _this=this,scripts=this.options.libs.map(function(url,index){return Loader.instance.loadScript(url,!0,function(){_this.setScriptloadProgress(scripts.length,index+1)})});return Promise.all(scripts)},Object.defineProperty(SplashLoader.prototype,"bannerAllowed",{get:function(){var width=document.body.clientWidth,height=document.body.clientHeight;return this.progress<100&&!(height<width&&height<=460)&&!(width<600&&height<850)},enumerable:!1,configurable:!0}),SplashLoader.prototype.showBanner=function(){if(!this.bannerAllowed)return null;var banner=document.getElementById("h5branding-ad");return banner?(banner.style.display="inline-flex",banner):null},SplashLoader.prototype.setScriptloadProgress=function(maxScripts,increment){var progress=.3*increment/maxScripts;this.circleLoader.animate(progress,null,function(){})},SplashLoader.prototype.setLoadProgress=function(progress){var _this=this;if(this.loaded)if(progress=30+.7*progress,100===(this.progress=progress)){var button_1=document.querySelector("#h5branding-button");this.circleLoader.animate(1,null,function(){!Utils.inGDGameZone()&&button_1&&!0===_this.showPlayButton?button_1.style.display="block":(Utils.inGDGameZone()||!1===_this.showPlayButton)&&_this.onPlayButtonClick()})}else this.circleLoader.animate(progress/100,null,function(){})},SplashLoader.prototype.setButtonCallback=function(cb){this.buttonCallback=cb},SplashLoader.prototype.onPlayButtonClick=function(){this.buttonCallback&&this.buttonCallback()},SplashLoader.prototype.destroy=function(){var element=document.querySelector("#h5branding-container");null!==element&&null!==element.parentNode&&element.parentNode.removeChild(element)},SplashLoader.prototype.getGameLogoUrl=function(gameId){var imagePath=gameId+"-512x512.jpeg";return window.hasOwnProperty("fbrqSA")&&!0===window.fbrqSA?"assets/"+imagePath:"./gamedistribution/"+imagePath},SplashLoader}(),EGAProgressionStatus$1=GameAnalytics_node.EGAProgressionStatus,google=new GoogleAnalytics,gameanalytics$1=new GameAnalytics$1;exports.EGAProgressionStatus=EGAProgressionStatus$1,exports.google=google,exports.gameanalytics=gameanalytics$1,exports.Utils=Utils,exports.Domain=Domain,exports.Branding=Branding$$1,exports.SplashLoader=SplashLoader,Object.defineProperty(exports,"__esModule",{value:!0})}),function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory(global.h5ads=global.h5ads||{})}(this,function(exports){"use strict";var extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};var module,CocoonProvider,eventemitter3=(function(module){var has=Object.prototype.hasOwnProperty,prefix="~";function Events(){}function EE(fn,context,once){this.fn=fn,this.context=context,this.once=once||!1}function addListener(emitter,event,fn,context,once){if("function"!=typeof fn)throw new TypeError("The listener must be a function");var listener=new EE(fn,context||emitter,once),evt=prefix?prefix+event:event;return emitter._events[evt]?emitter._events[evt].fn?emitter._events[evt]=[emitter._events[evt],listener]:emitter._events[evt].push(listener):(emitter._events[evt]=listener,emitter._eventsCount++),emitter}function clearEvent(emitter,evt){0==--emitter._eventsCount?emitter._events=new Events:delete emitter._events[evt]}function EventEmitter(){this._events=new Events,this._eventsCount=0}Object.create&&(Events.prototype=Object.create(null),(new Events).__proto__||(prefix=!1)),EventEmitter.prototype.eventNames=function(){var events,name,names=[];if(0===this._eventsCount)return names;for(name in events=this._events)has.call(events,name)&&names.push(prefix?name.slice(1):name);return Object.getOwnPropertySymbols?names.concat(Object.getOwnPropertySymbols(events)):names},EventEmitter.prototype.listeners=function(event){var evt=prefix?prefix+event:event,handlers=this._events[evt];if(!handlers)return[];if(handlers.fn)return[handlers.fn];for(var i=0,l=handlers.length,ee=new Array(l);i<l;i++)ee[i]=handlers[i].fn;return ee},EventEmitter.prototype.listenerCount=function(event){var evt=prefix?prefix+event:event,listeners=this._events[evt];return listeners?listeners.fn?1:listeners.length:0},EventEmitter.prototype.emit=function(event,a1,a2,a3,a4,a5){var evt=prefix?prefix+event:event;if(!this._events[evt])return!1;var args,i,listeners=this._events[evt],len=arguments.length;if(listeners.fn){switch(listeners.once&&this.removeListener(event,listeners.fn,void 0,!0),len){case 1:return listeners.fn.call(listeners.context),!0;case 2:return listeners.fn.call(listeners.context,a1),!0;case 3:return listeners.fn.call(listeners.context,a1,a2),!0;case 4:return listeners.fn.call(listeners.context,a1,a2,a3),!0;case 5:return listeners.fn.call(listeners.context,a1,a2,a3,a4),!0;case 6:return listeners.fn.call(listeners.context,a1,a2,a3,a4,a5),!0}for(i=1,args=new Array(len-1);i<len;i++)args[i-1]=arguments[i];listeners.fn.apply(listeners.context,args)}else{var j,length=listeners.length;for(i=0;i<length;i++)switch(listeners[i].once&&this.removeListener(event,listeners[i].fn,void 0,!0),len){case 1:listeners[i].fn.call(listeners[i].context);break;case 2:listeners[i].fn.call(listeners[i].context,a1);break;case 3:listeners[i].fn.call(listeners[i].context,a1,a2);break;case 4:listeners[i].fn.call(listeners[i].context,a1,a2,a3);break;default:if(!args)for(j=1,args=new Array(len-1);j<len;j++)args[j-1]=arguments[j];listeners[i].fn.apply(listeners[i].context,args)}}return!0},EventEmitter.prototype.on=function(event,fn,context){return addListener(this,event,fn,context,!1)},EventEmitter.prototype.once=function(event,fn,context){return addListener(this,event,fn,context,!0)},EventEmitter.prototype.removeListener=function(event,fn,context,once){var evt=prefix?prefix+event:event;if(!this._events[evt])return this;if(!fn)return clearEvent(this,evt),this;var listeners=this._events[evt];if(listeners.fn)listeners.fn!==fn||once&&!listeners.once||context&&listeners.context!==context||clearEvent(this,evt);else{for(var i=0,events=[],length=listeners.length;i<length;i++)(listeners[i].fn!==fn||once&&!listeners[i].once||context&&listeners[i].context!==context)&&events.push(listeners[i]);events.length?this._events[evt]=1===events.length?events[0]:events:clearEvent(this,evt)}return this},EventEmitter.prototype.removeAllListeners=function(event){var evt;return event?(evt=prefix?prefix+event:event,this._events[evt]&&clearEvent(this,evt)):(this._events=new Events,this._eventsCount=0),this},EventEmitter.prototype.off=EventEmitter.prototype.removeListener,EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prefixed=prefix,EventEmitter.EventEmitter=EventEmitter,module.exports=EventEmitter}(module={exports:{}},module.exports),module.exports);!function(CocoonProvider){CocoonProvider[CocoonProvider.AdMob=0]="AdMob",CocoonProvider[CocoonProvider.MoPub=1]="MoPub",CocoonProvider[CocoonProvider.Chartboost=2]="Chartboost",CocoonProvider[CocoonProvider.Heyzap=3]="Heyzap"}(CocoonProvider||(CocoonProvider={}));var GameDistributionAdType,GameDistributionBannerSize,GameDistributionAlignment,CocoonAds$$1=function(){function CocoonAds$$1(provider,config){if(this.adsEnabled=!1,this.bannerShowable=!1,this.interstitialShowable=!1,this.insentiveShowable=!1,Cocoon&&Cocoon.Ad){switch(this.adsEnabled=!0,provider){default:case CocoonProvider.AdMob:this.cocoonProvider=Cocoon.Ad.AdMob;break;case CocoonProvider.Chartboost:this.cocoonProvider=Cocoon.Ad.Chartboost;break;case CocoonProvider.Heyzap:this.cocoonProvider=Cocoon.Ad.Heyzap;break;case CocoonProvider.MoPub:this.cocoonProvider=Cocoon.Ad.MoPub}this.cocoonProvider.configure(config)}}return CocoonAds$$1.prototype.setManager=function(manager){this.adManager=manager,this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)},CocoonAds$$1.prototype.showAd=function(adType){if(this.adsEnabled){if(adType===exports.AdType.banner){if(!this.bannerShowable||null===this.banner)return;this.adManager.emit(exports.AdEvents.BANNER_SHOWN,this.banner.width,this.banner.height),this.adManager.bannerActive=!0,this.banner.show()}if(adType===exports.AdType.interstitial){if(!this.interstitialShowable||null===this.interstitial)return void this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,exports.AdType.interstitial);this.interstitial.show()}if(adType===exports.AdType.rewarded){if(!this.insentiveShowable||null===this.insentive)return void this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,exports.AdType.rewarded);this.insentive.show()}}else adType!==exports.AdType.banner&&this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)},CocoonAds$$1.prototype.adAvailable=function(adType){return!0},CocoonAds$$1.prototype.preloadAd=function(adType,adId,bannerPosition){var _this=this;this.adsEnabled&&(this.destroyAd(adType),adType===exports.AdType.banner&&(this.banner=this.cocoonProvider.createBanner(adId),bannerPosition&&this.banner.setLayout(bannerPosition),this.banner.on("load",function(){_this.bannerShowable=!0}),this.banner.on("fail",function(){_this.bannerShowable=!1,_this.banner=null}),this.banner.on("click",function(){_this.adManager.emit(exports.AdEvents.AD_CLICKED,exports.AdType.banner)}),this.banner.on("show",function(){}),this.banner.on("dismiss",function(){}),this.banner.load()),adType===exports.AdType.interstitial&&(this.interstitial=this.cocoonProvider.createInterstitial(adId),this.interstitial.on("load",function(){_this.interstitialShowable=!0}),this.interstitial.on("fail",function(){_this.interstitialShowable=!1,_this.interstitial=null}),this.interstitial.on("click",function(){_this.adManager.emit(exports.AdEvents.AD_CLICKED,exports.AdType.interstitial)}),this.interstitial.on("show",function(){_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED,exports.AdType.interstitial)}),this.interstitial.on("dismiss",function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,exports.AdType.interstitial),_this.interstitialShowable=!1,_this.interstitial=null}),this.interstitial.load()),adType===exports.AdType.rewarded&&(this.insentive=this.cocoonProvider.createRewardedVideo(adId),this.insentive.on("load",function(){_this.insentiveShowable=!0}),this.insentive.on("fail",function(){_this.insentiveShowable=!1,_this.insentive=null}),this.insentive.on("click",function(){_this.adManager.emit(exports.AdEvents.AD_CLICKED,exports.AdType.rewarded)}),this.insentive.on("show",function(){_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED,exports.AdType.rewarded)}),this.insentive.on("dismiss",function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,exports.AdType.rewarded),_this.insentiveShowable=!1,_this.insentive=null}),this.insentive.on("reward",function(){_this.adManager.emit(exports.AdEvents.AD_REWARDED,exports.AdType.rewarded),_this.insentiveShowable=!1,_this.insentive=null}),this.insentive.load()))},CocoonAds$$1.prototype.destroyAd=function(adType){if(this.adsEnabled){if(adType===exports.AdType.banner&&null!==this.banner){try{this.cocoonProvider.releaseBanner(this.banner)}catch(e){}this.banner=null,this.bannerShowable=!1}adType===exports.AdType.interstitial&&null!==this.interstitial&&(this.cocoonProvider.releaseInterstitial(this.interstitial),this.interstitial=null,this.interstitialShowable=!1)}},CocoonAds$$1.prototype.hideAd=function(adType){this.adsEnabled&&(adType===exports.AdType.interstitial&&null!==this.interstitial&&this.interstitial.hide(),adType===exports.AdType.banner&&null!==this.banner&&(this.adManager.bannerActive&&(this.adManager.bannerActive=!1,this.adManager.emit(exports.AdEvents.BANNER_HIDDEN,this.banner.width,this.banner.height)),this.banner.hide()),adType===exports.AdType.rewarded&&null!==this.insentive&&this.insentive.hide())},CocoonAds$$1}(),CordovaGamedistribution$$1=function(){function CordovaGamedistribution$$1(gameId,userId,debug){void 0===debug&&(debug=!1),this.adsEnabled=!1,void 0===cordova.plugins||void 0!==cordova.plugins&&void 0===cordova.plugins.gdApi||(debug&&cordova.plugins.gdApi.enableTestAds(),this.setAdListeners(),cordova.plugins.gdApi.init([gameId,userId],function(data){},function(error){}))}return CordovaGamedistribution$$1.prototype.setAdListeners=function(){var _this=this;cordova.plugins.gdApi.setAdListener(function(data){switch(data.event){case"BANNER_STARTED":_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED);break;case"API_IS_READY":_this.adsEnabled=!0;break;case"API_ALREADY_INITIALIZED":break;case"BANNER_CLOSED":case"API_NOT_READY":case"BANNER_FAILED":_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)}},function(error){_this.adsEnabled=!1})},CordovaGamedistribution$$1.prototype.setManager=function(manager){this.adManager=manager,this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)},CordovaGamedistribution$$1.prototype.showAd=function(adType){var _this=this;this.adsEnabled?cordova.plugins.gdApi.showBanner(function(data){},function(data){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)}):this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)},CordovaGamedistribution$$1.prototype.adAvailable=function(adType){return!0},CordovaGamedistribution$$1.prototype.preloadAd=function(adType){},CordovaGamedistribution$$1.prototype.destroyAd=function(adType){},CordovaGamedistribution$$1.prototype.hideAd=function(adType){},CordovaGamedistribution$$1}(),CordovaGamedock$$1=function(){function CordovaGamedock$$1(){var _this=this;if(this.adsEnabled=!1,this.rewardedLoaded=!1,"undefined"!=typeof gamedockSDK){gamedockSDK.on("PrivacyPolicyStatus",function(data){_this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)}),gamedockSDK.initialise(!1,{shouldBlock:!0,requiredAge:12},!0,"PRODUCTION",[]),gamedockSDK.on("AdAvailable",function(data){switch(data.type){case"interstitial":_this.interstitalAvailable();break;case"rewardVideo":_this.rewardedChanged(!0);break;case"banner":throw new Error("Not yet implemented.")}}),gamedockSDK.on("AdNotAvailable",function(data){switch(data.type){case"interstitial":case"rewardVideo":_this.resumeGameplay();break;case"banner":throw new Error("Not yet implemented.")}}),gamedockSDK.on("AdFinished",function(data){switch(data.type){case"interstitial":_this.resumeGameplay();break;case"rewardVideo":_this.rewardVideoFinished(data.reason);break;case"banner":throw new Error("Not yet implemented.")}})}}return CordovaGamedock$$1.prototype.setManager=function(manager){this.adManager=manager},CordovaGamedock$$1.prototype.showAd=function(adType){if(void 0===adType&&(adType=exports.AdType.interstitial),"undefined"!=typeof gamedockSDK)switch(adType){case exports.AdType.interstitial:this.adManager.emit(exports.AdEvents.CONTENT_PAUSED),gamedockSDK.requestInterstitial();break;case exports.AdType.rewarded:if(!this.adAvailable(exports.AdType.rewarded)){this.resumeGameplay();break}this.adManager.emit(exports.AdEvents.CONTENT_PAUSED),this.rewardedChanged(!1),gamedockSDK.playRewardVideo();break;default:this.resumeGameplay()}},CordovaGamedock$$1.prototype.interstitalAvailable=function(){"undefined"!=typeof gamedockSDK&&gamedockSDK.playInterstitial()},CordovaGamedock$$1.prototype.rewardVideoFinished=function(reason){switch(reason){case"dismiss":this.resumeGameplay();break;case"close":this.adManager.emit(exports.AdEvents.AD_REWARDED)}},CordovaGamedock$$1.prototype.resumeGameplay=function(){this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)},CordovaGamedock$$1.prototype.preloadAd=function(adType){if(void 0===adType&&(adType=exports.AdType.interstitial),"undefined"!=typeof gamedockSDK)switch(adType){case exports.AdType.rewarded:if(this.rewardedLoaded)return;gamedockSDK.requestRewardVideo()}},CordovaGamedock$$1.prototype.destroyAd=function(){},CordovaGamedock$$1.prototype.hideAd=function(){},CordovaGamedock$$1.prototype.adAvailable=function(adType){switch(adType){case exports.AdType.rewarded:return this.rewardedLoaded}return!1},CordovaGamedock$$1.prototype.rewardedChanged=function(available){this.rewardedLoaded=available},CordovaGamedock$$1}(),CordovaHeyzap$$1=function(){function CordovaHeyzap$$1(publisherId){var _this=this;this.adsEnabled=!1,this.adsEnabled=!0,HeyzapAds.start(publisherId).then(function(){},function(e){_this.adsEnabled=!1})}return CordovaHeyzap$$1.prototype.setManager=function(manager){this.adManager=manager,this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)},CordovaHeyzap$$1.prototype.showAd=function(adType,bannerAdPositions){var _this=this;switch(this.adsEnabled||this.adManager.emit(exports.AdEvents.CONTENT_RESUMED),adType){case exports.AdType.interstitial:HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.HIDE,function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,HeyzapAds.InterstitialAd.Events.HIDE)}),HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.SHOW_FAILED,function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,HeyzapAds.InterstitialAd.Events.SHOW_FAILED)}),HeyzapAds.InterstitialAd.addEventListener(HeyzapAds.InterstitialAd.Events.CLICKED,function(){_this.adManager.emit(exports.AdEvents.AD_CLICKED,HeyzapAds.InterstitialAd.Events.CLICKED)}),HeyzapAds.InterstitialAd.show().then(function(){_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED)},function(e){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)});break;case exports.AdType.interstitial:HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.HIDE,function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,HeyzapAds.VideoAd.Events.HIDE)}),HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.SHOW_FAILED,function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,HeyzapAds.VideoAd.Events.SHOW_FAILED)}),HeyzapAds.VideoAd.addEventListener(HeyzapAds.VideoAd.Events.CLICKED,function(){_this.adManager.emit(exports.AdEvents.AD_CLICKED,HeyzapAds.VideoAd.Events.CLICKED)}),HeyzapAds.VideoAd.show().then(function(){_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED)},function(e){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)});break;case exports.AdType.rewarded:HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.HIDE,function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,HeyzapAds.IncentivizedAd.Events.HIDE)}),HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.SHOW_FAILED,function(){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED,HeyzapAds.IncentivizedAd.Events.SHOW_FAILED)}),HeyzapAds.IncentivizedAd.addEventListener(HeyzapAds.IncentivizedAd.Events.CLICKED,function(){_this.adManager.emit(exports.AdEvents.AD_CLICKED,HeyzapAds.IncentivizedAd.Events.CLICKED)}),HeyzapAds.IncentivizedAd.show().then(function(){_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED)},function(e){_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)});break;case exports.AdType.banner:if(void 0===bannerAdPositions)return;HeyzapAds.BannerAd.show(bannerAdPositions).then(function(){},function(e){})}},CordovaHeyzap$$1.prototype.adAvailable=function(adType){return!0},CordovaHeyzap$$1.prototype.preloadAd=function(adType){this.adsEnabled&&adType===exports.AdType.rewarded&&HeyzapAds.IncentivizedAd.fetch().then(function(){},function(e){})},CordovaHeyzap$$1.prototype.destroyAd=function(adType){this.adsEnabled&&adType===exports.AdType.banner&&HeyzapAds.BannerAd.destroy().then(function(){},function(e){})},CordovaHeyzap$$1.prototype.hideAd=function(adType){this.adsEnabled&&adType===exports.AdType.banner&&HeyzapAds.BannerAd.hide().then(function(){},function(e){})},CordovaHeyzap$$1}(),CordovaIronSource$$1=function(){function CordovaIronSource$$1(appKey){var _this=this;if(this.adsEnabled=!1,this.interstitialLoaded=!1,this.rewardedLoaded=!1,"undefined"!=typeof IronSourceAds){IronSourceAds.init({appKey:appKey});var resume=function(){return _this.resumeGameplay()};window.addEventListener("interstitialClosed",resume),window.addEventListener("interstitialShowFailed",resume),window.addEventListener("interstitialLoaded",function(){return _this.interstitialChanged(!0)}),window.addEventListener("rewardedVideoClosed",resume),window.addEventListener("rewardedVideoFailed",resume),IronSourceAds.hasRewardedVideo({onSuccess:this.rewardedChanged.bind(this)}),window.addEventListener("rewardedVideoAvailabilityChanged",function(event){return _this.rewardedChanged(event.available)})}}return CordovaIronSource$$1.prototype.setManager=function(manager){this.adManager=manager,this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)},CordovaIronSource$$1.prototype.showAd=function(adType){switch(void 0===adType&&(adType=exports.AdType.interstitial),adType){case exports.AdType.interstitial:if(!this.interstitialLoaded){this.resumeGameplay();break}this.interstitialChanged(!1),this.adManager.emit(exports.AdEvents.CONTENT_PAUSED),IronSourceAds.showInterstitial();break;case exports.AdType.rewarded:if(!this.rewardedLoaded){this.resumeGameplay();break}this.adManager.emit(exports.AdEvents.CONTENT_PAUSED),IronSourceAds.showRewardedVideo();break;default:this.resumeGameplay()}},CordovaIronSource$$1.prototype.resumeGameplay=function(){this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)},CordovaIronSource$$1.prototype.preloadAd=function(adType){void 0===adType&&(adType=exports.AdType.interstitial),adType===exports.AdType.interstitial&&IronSourceAds.loadInterstitial()},CordovaIronSource$$1.prototype.destroyAd=function(){},CordovaIronSource$$1.prototype.hideAd=function(){},CordovaIronSource$$1.prototype.adAvailable=function(adType){switch(adType){case exports.AdType.interstitial:return this.interstitialLoaded;case exports.AdType.rewarded:return this.rewardedLoaded}return!1},CordovaIronSource$$1.prototype.interstitialChanged=function(available){this.interstitialLoaded=available},CordovaIronSource$$1.prototype.rewardedChanged=function(available){this.rewardedLoaded=available},CordovaIronSource$$1}();!function(GameDistributionAdType){GameDistributionAdType.interstitial="interstitial",GameDistributionAdType.rewarded="rewarded",GameDistributionAdType.display="display"}(GameDistributionAdType||(GameDistributionAdType={})),(GameDistributionBannerSize=exports.GameDistributionBannerSize||(exports.GameDistributionBannerSize={}))[GameDistributionBannerSize.LargeRectangle=0]="LargeRectangle",GameDistributionBannerSize[GameDistributionBannerSize.MediumRectangle=1]="MediumRectangle",GameDistributionBannerSize[GameDistributionBannerSize.Billboard=2]="Billboard",GameDistributionBannerSize[GameDistributionBannerSize.Leaderboard=3]="Leaderboard",GameDistributionBannerSize[GameDistributionBannerSize.Skyscraper=4]="Skyscraper",GameDistributionBannerSize[GameDistributionBannerSize.WideSkyscraper=5]="WideSkyscraper",(GameDistributionAlignment=exports.GameDistributionAlignment||(exports.GameDistributionAlignment={}))[GameDistributionAlignment.TopLeft=0]="TopLeft",GameDistributionAlignment[GameDistributionAlignment.TopCenter=1]="TopCenter",GameDistributionAlignment[GameDistributionAlignment.TopRight=2]="TopRight",GameDistributionAlignment[GameDistributionAlignment.CenterLeft=3]="CenterLeft",GameDistributionAlignment[GameDistributionAlignment.Center=4]="Center",GameDistributionAlignment[GameDistributionAlignment.CenterRight=5]="CenterRight",GameDistributionAlignment[GameDistributionAlignment.BottomLeft=6]="BottomLeft",GameDistributionAlignment[GameDistributionAlignment.BottomCenter=7]="BottomCenter",GameDistributionAlignment[GameDistributionAlignment.BottomRight=8]="BottomRight";var GoogleAdEvent,GameDistributionBanner$$1=function(){function GameDistributionBanner$$1(){this.scaleFactor=1,this.offsetX=0,this.offsetY=0,this.element=document.createElement("div"),this.element.style.position="absolute",this.element.style.top="0px",this.element.style.left="0px",this.element.id="banner-"+Date.now()+(1e7*Math.random()|0),document.body.appendChild(this.element)}return GameDistributionBanner$$1.prototype.loadBanner=function(){return"undefined"==typeof gdsdk?Promise.reject("GD Sdk not available, probably due to adblocker"):gdsdk.showAd(GameDistributionAdType.display,{containerId:this.element.id})},GameDistributionBanner$$1.prototype.destroy=function(){document.body.removeChild(this.element),this.resizeListener&&window.removeEventListener("resize",this.resizeListener),delete this.element,delete this.parent,delete this.alignment},GameDistributionBanner$$1.prototype.alignIn=function(element,position){var _this=this;this.parent||(this.parent=element,this.alignment=position,this.resizeListener=function(){return _this.resize()},window.addEventListener("resize",this.resizeListener),this.resize())},GameDistributionBanner$$1.prototype.setOffset=function(x,y){void 0===x&&(x=0),void 0===y&&(y=0),this.offsetX=x,this.offsetY=y,this.resize()},GameDistributionBanner$$1.prototype.resize=function(){if(this.parent){var parentBoundingRect=this.parent.getBoundingClientRect();switch(this.alignment){case exports.GameDistributionAlignment.TopLeft:this.position(parentBoundingRect.left,parentBoundingRect.top);break;case exports.GameDistributionAlignment.TopCenter:this.position(parentBoundingRect.left+parentBoundingRect.width/2-this.width*this.scaleFactor/2,parentBoundingRect.top);break;case exports.GameDistributionAlignment.TopRight:this.position(parentBoundingRect.left+parentBoundingRect.width-this.width*this.scaleFactor,parentBoundingRect.top);break;case exports.GameDistributionAlignment.CenterLeft:this.position(parentBoundingRect.left,parentBoundingRect.top+parentBoundingRect.height/2-this.height*this.scaleFactor/2);break;case exports.GameDistributionAlignment.Center:this.position(parentBoundingRect.left+parentBoundingRect.width/2-this.width*this.scaleFactor/2,parentBoundingRect.top+parentBoundingRect.height/2-this.height*this.scaleFactor/2);break;case exports.GameDistributionAlignment.CenterRight:this.position(parentBoundingRect.left+parentBoundingRect.width-this.width*this.scaleFactor,parentBoundingRect.top+parentBoundingRect.height/2-this.height*this.scaleFactor/2);break;case exports.GameDistributionAlignment.BottomLeft:this.position(parentBoundingRect.left,parentBoundingRect.top+parentBoundingRect.height-this.height*this.scaleFactor);break;case exports.GameDistributionAlignment.BottomCenter:this.position(parentBoundingRect.left+parentBoundingRect.width/2-this.width*this.scaleFactor/2,parentBoundingRect.top+parentBoundingRect.height-this.height*this.scaleFactor);break;case exports.GameDistributionAlignment.BottomRight:this.position(parentBoundingRect.left+parentBoundingRect.width-this.width*this.scaleFactor,parentBoundingRect.top+parentBoundingRect.height-this.height*this.scaleFactor)}}},GameDistributionBanner$$1.prototype.setSize=function(size){var width,height;switch(size){default:case exports.GameDistributionBannerSize.LargeRectangle:width=336,height=280;break;case exports.GameDistributionBannerSize.MediumRectangle:width=300,height=250;break;case exports.GameDistributionBannerSize.Billboard:width=970,height=250;break;case exports.GameDistributionBannerSize.Leaderboard:width=728,height=90;break;case exports.GameDistributionBannerSize.Skyscraper:width=120,height=600;break;case exports.GameDistributionBannerSize.WideSkyscraper:width=160,height=600}this.width=width,this.height=height,this.element.style.width=width+"px",this.element.style.height=height+"px"},GameDistributionBanner$$1.prototype.position=function(x,y){this.element.style.left=x+this.offsetX+"px",this.element.style.top=y+this.offsetY+"px"},GameDistributionBanner$$1.prototype.scale=function(factor){this.element.style.transformOrigin="left top",this.scaleFactor=factor,this.element.style.transform="scale("+factor+")"},GameDistributionBanner$$1}(),GameDistribution$$1=function(){function GameDistribution$$1(gameId){var d,s,id,js,fjs,_this=this;this.adsEnabled=!1,this.hasRewarded=!1,this.adShowing=!1,this.areAdsEnabled(),window.GD_OPTIONS={gameId:gameId,advertisementSettings:{autoplay:!1},onEvent:function(event){switch(event.name){case"SDK_GAME_PAUSE":_this.adManager.emit(exports.AdEvents.CONTENT_PAUSED);break;case"SDK_READY":_this.sdkLoaded()}}},d=document,s="script",id="gamedistribution-jssdk",fjs=d.getElementsByTagName(s)[0],d.getElementById(id)||((js=d.createElement(s)).id=id,js.src="./gamedistribution/js/main.min.js",fjs.parentNode&&fjs.parentNode.insertBefore(js,fjs))}return GameDistribution$$1.prototype.setManager=function(manager){this.adManager=manager,this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)},GameDistribution$$1.prototype.sdkLoaded=function(){var _this=this;this.areAdsEnabled().then(function(enabled){enabled&&(_this.adsEnabled=!0)})},GameDistribution$$1.prototype.showAd=function(adType){var _this=this;if(this.adsEnabled){if("undefined"==typeof gdsdk||gdsdk&&void 0===gdsdk.showAd)return this.adsEnabled=!1,void this.adManager.emit(exports.AdEvents.CONTENT_RESUMED);gdsdk.showAd(adType===exports.AdType.rewarded?GameDistributionAdType.rewarded:GameDistributionAdType.interstitial).then(function(){adType===exports.AdType.rewarded&&(_this.adManager.emit(exports.AdEvents.AD_REWARDED),_this.hasRewarded=!1),_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)}).catch(function(){adType===exports.AdType.rewarded&&_this.hasRewarded&&(_this.hasRewarded=!1),_this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)})}else this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)},GameDistribution$$1.prototype.createBanner=function(size){if(this.adsEnabled){var banner=new GameDistributionBanner$$1;return banner.setSize(size),banner}},GameDistribution$$1.prototype.loadBanner=function(size){if(this.adsEnabled){var banner=new GameDistributionBanner$$1;return banner.setSize(size),banner.loadBanner(),banner}},GameDistribution$$1.prototype.preloadAd=function(adType){var _this=this;!this.hasRewarded&&this.adsEnabled&&adType===exports.AdType.rewarded&&gdsdk.preloadAd(GameDistributionAdType.rewarded).then(function(){_this.hasRewarded=!0,_this.adManager.emit(exports.AdEvents.AD_LOADED,adType)})},GameDistribution$$1.prototype.adAvailable=function(adType){return adType!==exports.AdType.rewarded||this.hasRewarded},GameDistribution$$1.prototype.destroyAd=function(){},GameDistribution$$1.prototype.hideAd=function(){},GameDistribution$$1.prototype.areAdsEnabled=function(){var test=document.createElement("script");test.id="debug-test-ad",test.src="js/null.js?https://storage.googleapis.com/cdn.fbrq.io/anyad.js",document.body.appendChild(test);return new Promise(function(resolve){window.setTimeout(function(){resolve(function(){var enabled=!0;if(document.getElementById("az-test-ad")||(enabled=!1),document.getElementById("debug-test-ad")){var d=document.getElementById("debug-test-ad");try{d.parentNode.removeChild(d)}catch(e){}}if(document.getElementById("az-test-ad")){var t=document.getElementById("az-test-ad");try{t.parentNode.removeChild(t)}catch(e){}}return enabled}())},100)})},GameDistribution$$1}();!function(GoogleAdEvent){GoogleAdEvent[GoogleAdEvent.start=0]="start",GoogleAdEvent[GoogleAdEvent.firstQuartile=1]="firstQuartile",GoogleAdEvent[GoogleAdEvent.midPoint=2]="midPoint",GoogleAdEvent[GoogleAdEvent.thirdQuartile=3]="thirdQuartile",GoogleAdEvent[GoogleAdEvent.complete=4]="complete"}(GoogleAdEvent||(GoogleAdEvent={}));var AdEvents,AdType,Ima3$$1=function(){function Ima3$$1(canvas,adTagUrl){this.googleEnabled=!1,this.adsEnabled=!0,this.adTagUrl="",this.adRequested=!1,this.areAdsEnabled(),"undefined"!=typeof google&&(this.googleEnabled=!0,this.gameContent="string"==typeof canvas.parentElement?document.getElementById(canvas.parentElement):canvas.parentElement,this.gameContent.style.position="absolute",this.gameContent.style.width="100%",this.adContent=this.gameContent.parentNode.appendChild(document.createElement("div")),this.adContent.id="phaser-ad-container",this.adContent.style.position="absolute",this.adContent.style.zIndex="9999",this.adContent.style.display="none",this.adContent.style.top="0",this.adContent.style.left="0",this.adContent.style.width="100%",this.adContent.style.height="100%",this.adContent.style.overflow="hidden",this.adTagUrl=adTagUrl,this.adDisplay=new google.ima.AdDisplayContainer(this.adContent),google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),google.ima.settings.setLocale("nl"),this.adLoader=new google.ima.AdsLoader(this.adDisplay),this.adLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdManagerLoader,!1,this),this.adLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this))}return Ima3$$1.prototype.setManager=function(manager){this.adManager=manager,this.adManager.emit(exports.AdEvents.AD_PROVIDER_LOADED)},Ima3$$1.prototype.showAd=function(adType,customParams){if(!this.adRequested)if(this.adsEnabled||this.adManager.emit(exports.AdEvents.AD_DISABLED,!0),this.googleEnabled){this.adDisplay.initialize();var adsRequest=new google.ima.AdsRequest;adsRequest.adTagUrl=this.adTagUrl+this.parseCustomParams(customParams);var width=window.innerWidth,height=window.innerHeight;document.body.clientHeight<window.innerHeight&&(height=document.body.clientHeight,width=document.body.clientWidth),adsRequest.linearAdSlotWidth=width,adsRequest.linearAdSlotHeight=height,adsRequest.nonLinearAdSlotWidth=width,adsRequest.nonLinearAdSlotHeight=height,adsRequest.forceNonLinearFullSlot=!0;try{this.adRequested=!0,this.adLoader.requestAds(adsRequest)}catch(e){this.onContentResumeRequested()}}else this.onContentResumeRequested()},Ima3$$1.prototype.adAvailable=function(adType){return!0},Ima3$$1.prototype.preloadAd=function(){},Ima3$$1.prototype.destroyAd=function(){},Ima3$$1.prototype.hideAd=function(){},Ima3$$1.prototype.onAdManagerLoader=function(adsManagerLoadedEvent){var _this=this,adsRenderingSettings=new google.ima.AdsRenderingSettings;adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete=!0;var adsManager=adsManagerLoadedEvent.getAdsManager(this.gameContent,adsRenderingSettings);(this.adsManager=adsManager).addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested,!1,this),adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested,!1,this),adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError,!1,this),[google.ima.AdEvent.Type.ALL_ADS_COMPLETED,google.ima.AdEvent.Type.CLICK,google.ima.AdEvent.Type.COMPLETE,google.ima.AdEvent.Type.FIRST_QUARTILE,google.ima.AdEvent.Type.LOADED,google.ima.AdEvent.Type.MIDPOINT,google.ima.AdEvent.Type.PAUSED,google.ima.AdEvent.Type.STARTED,google.ima.AdEvent.Type.THIRD_QUARTILE].forEach(function(event){adsManager.addEventListener(event,_this.onAdEvent,!1,_this)});try{this.adContent.style.display="block";var width=window.innerWidth,height=window.innerHeight;this.adsManager.init(width,height,google.ima.ViewMode.NORMAL),this.adsManager.start(),this.resizeListener=function(){null!==_this.adsManager&&_this.adsManager.resize(window.innerWidth,window.innerHeight,google.ima.ViewMode.NORMAL)},window.addEventListener("resize",this.resizeListener)}catch(adError){this.onAdError(adError)}},Ima3$$1.prototype.onAdEvent=function(adEvent){switch(adEvent.type){case google.ima.AdEvent.Type.CLICK:this.adManager.emit(exports.AdEvents.AD_CLICKED);break;case google.ima.AdEvent.Type.LOADED:this.adRequested=!1;var ad=adEvent.getAd();ad.isLinear()||this.onContentResumeRequested();break;case google.ima.AdEvent.Type.STARTED:this.adManager.emit(exports.AdEvents.AD_PROGRESSION,GoogleAdEvent.start);break;case google.ima.AdEvent.Type.FIRST_QUARTILE:this.adManager.emit(exports.AdEvents.AD_PROGRESSION,GoogleAdEvent.firstQuartile);break;case google.ima.AdEvent.Type.MIDPOINT:this.adManager.emit(exports.AdEvents.AD_PROGRESSION,GoogleAdEvent.midPoint);break;case google.ima.AdEvent.Type.THIRD_QUARTILE:this.adManager.emit(exports.AdEvents.AD_PROGRESSION,GoogleAdEvent.thirdQuartile);break;case google.ima.AdEvent.Type.COMPLETE:this.adManager.emit(exports.AdEvents.AD_PROGRESSION,GoogleAdEvent.complete);break;case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:this.onContentResumeRequested()}},Ima3$$1.prototype.onAdError=function(error){null!==this.adsManager&&(this.adsManager.destroy(),null!==this.resizeListener&&window.removeEventListener("resize",this.resizeListener)),this.adRequested&&(this.adRequested=!1),this.onContentResumeRequested()},Ima3$$1.prototype.onContentPauseRequested=function(){this.adManager.emit(exports.AdEvents.CONTENT_PAUSED)},Ima3$$1.prototype.onContentResumeRequested=function(){"undefined"!=typeof google&&(this.adContent.style.display="none"),this.adManager.emit(exports.AdEvents.CONTENT_RESUMED)},Ima3$$1.prototype.parseCustomParams=function(customParams){if(void 0===customParams)return"";var customDataString="";for(var key in customParams){if(customParams.hasOwnProperty(key))0<customDataString.length&&(customDataString+="&"),customDataString+=key+"="+(Array.isArray(customParams[key])?customParams[key].join(","):customParams[key])}return"&cust_params="+encodeURIComponent(customDataString)},Ima3$$1.prototype.areAdsEnabled=function(){var _this=this,test=document.createElement("div");test.innerHTML="&nbsp;",test.className="adsbox",test.style.position="absolute",test.style.fontSize="10px",document.body.appendChild(test);window.setTimeout(function(){var enabled;_this.adsEnabled=(enabled=!0,0===test.offsetHeight&&(enabled=!1),test.parentNode&&test.parentNode.removeChild(test),enabled)},100)},Ima3$$1}();(AdEvents=exports.AdEvents||(exports.AdEvents={})).CONTENT_PAUSED="onContentPaused",AdEvents.CONTENT_RESUMED="onContentResumed",AdEvents.AD_PROGRESSION="onAdProgression",AdEvents.AD_DISABLED="onAdsDisabled",AdEvents.AD_CLICKED="onAdClicked",AdEvents.AD_REWARDED="onAdRewardGranted",AdEvents.BANNER_SHOWN="onBannerShown",AdEvents.BANNER_HIDDEN="onBannerHidden",AdEvents.AD_LOADED="onAdLoaded",AdEvents.AD_PROVIDER_LOADED="onAdProviderLoaded",(AdType=exports.AdType||(exports.AdType={}))[AdType.interstitial=0]="interstitial",AdType[AdType.rewarded=1]="rewarded",AdType[AdType.banner=2]="banner";var H5AdWrapper=function(_super){function H5AdWrapper(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.bannerActive=!1,_this.provider=null,_this}return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}(H5AdWrapper,_super),H5AdWrapper.prototype.setAdProvider=function(provider){this.provider=provider,this.provider.setManager(this)},H5AdWrapper.prototype.showAd=function(adType){for(var args=[],_i=1;_i<arguments.length;_i++)args[_i-1]=arguments[_i];if(null===this.provider)throw new Error("Can not request an ad without an provider, please attach an ad provider!");args.unshift(adType),this.provider.showAd.apply(this.provider,args)},H5AdWrapper.prototype.createBanner=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return this.provider.loadBanner.apply(this.provider,args)},H5AdWrapper.prototype.loadBanner=function(){for(var args=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];return"function"==typeof this.provider.loadBanner?this.provider.loadBanner.apply(this.provider,args):null},H5AdWrapper.prototype.preloadAd=function(adType){for(var args=[],_i=1;_i<arguments.length;_i++)args[_i-1]=arguments[_i];if(null===this.provider)throw new Error("Can not preload an ad without an provider, please attach an ad provider!");args.unshift(adType),this.provider.preloadAd.apply(this.provider,args)},H5AdWrapper.prototype.destroyAd=function(adType){for(var args=[],_i=1;_i<arguments.length;_i++)args[_i-1]=arguments[_i];if(null===this.provider)throw new Error("Can not destroy an ad without an provider, please attach an ad provider!");args.unshift(adType),this.provider.destroyAd.apply(this.provider,args)},H5AdWrapper.prototype.hideAd=function(adType){for(var args=[],_i=1;_i<arguments.length;_i++)args[_i-1]=arguments[_i];if(null===this.provider)throw new Error("Can not hide an ad without an provider, please attach an ad provider!");args.unshift(adType),this.provider.hideAd.apply(this.provider,args)},H5AdWrapper.prototype.adsEnabled=function(){if(null===this.provider)throw new Error("Can not hide an ad without an provider, please attach an ad provider!");return this.provider.adsEnabled},H5AdWrapper.prototype.adAvailable=function(adType){for(var args=[],_i=1;_i<arguments.length;_i++)args[_i-1]=arguments[_i];if(null===this.provider)throw new Error("Can not hide an ad without an provider, please attach an ad provider!");return args.unshift(adType),this.provider.adAvailable.apply(this.provider,args)},H5AdWrapper}(eventemitter3),adWrapper=new H5AdWrapper;exports.H5AdWrapper=H5AdWrapper,exports.adWrapper=adWrapper,exports.CocoonAds=CocoonAds$$1,exports.CordovaGamedistribution=CordovaGamedistribution$$1,exports.CordovaGamedock=CordovaGamedock$$1,exports.CordovaHeyzap=CordovaHeyzap$$1,exports.CordovaIronSource=CordovaIronSource$$1,exports.GameDistribution=GameDistribution$$1,exports.GameDistributionBanner=GameDistributionBanner$$1,exports.Ima3=Ima3$$1,Object.defineProperty(exports,"__esModule",{value:!0})}),function(a){var b;"object"==typeof exports?module.exports=a():("undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.p2=a())}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){return e(b[g][1][a]||a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){function d(){}var e=a("./Scalar");(b.exports=d).lineInt=function(a,b,c){c=c||0;var d,f,g,h,i,j,k,l=[0,0];return d=a[1][1]-a[0][1],f=a[0][0]-a[1][0],g=d*a[0][0]+f*a[0][1],h=b[1][1]-b[0][1],i=b[0][0]-b[1][0],j=h*b[0][0]+i*b[0][1],k=d*i-h*f,e.eq(k,0,c)||(l[0]=(i*g-f*j)/k,l[1]=(d*j-h*g)/k),l},d.segmentsIntersect=function(a,b,c,d){var e=b[0]-a[0],f=b[1]-a[1],g=d[0]-c[0],h=d[1]-c[1];if(g*f-h*e==0)return!1;var i=(e*(c[1]-a[1])+f*(a[0]-c[0]))/(g*f-h*e),j=(g*(a[1]-c[1])+h*(c[0]-a[0]))/(h*e-g*f);return 0<=i&&i<=1&&0<=j&&j<=1}},{"./Scalar":4}],2:[function(a,b,c){function d(){}(b.exports=d).area=function(a,b,c){return(b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1])},d.left=function(a,b,c){return 0<d.area(a,b,c)},d.leftOn=function(a,b,c){return 0<=d.area(a,b,c)},d.right=function(a,b,c){return d.area(a,b,c)<0},d.rightOn=function(a,b,c){return d.area(a,b,c)<=0};var e=[],f=[];d.collinear=function(a,b,c,g){if(g){var h=e,i=f;h[0]=b[0]-a[0],h[1]=b[1]-a[1],i[0]=c[0]-b[0],i[1]=c[1]-b[1];var j=h[0]*i[0]+h[1]*i[1],k=Math.sqrt(h[0]*h[0]+h[1]*h[1]),l=Math.sqrt(i[0]*i[0]+i[1]*i[1]);return Math.acos(j/(k*l))<g}return 0==d.area(a,b,c)},d.sqdist=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d}},{}],3:[function(a,b,c){function d(){this.vertices=[]}function e(a,b,c,d,e){e=e||0;var f=b[1]-a[1],g=a[0]-b[0],i=f*a[0]+g*a[1],j=d[1]-c[1],k=c[0]-d[0],l=j*c[0]+k*c[1],m=f*k-j*g;return h.eq(m,0,e)?[0,0]:[(k*i-g*l)/m,(f*l-j*i)/m]}var f=a("./Line"),g=a("./Point"),h=a("./Scalar");(b.exports=d).prototype.at=function(a){var b=this.vertices,c=b.length;return b[a<0?a%c+c:a%c]},d.prototype.first=function(){return this.vertices[0]},d.prototype.last=function(){return this.vertices[this.vertices.length-1]},d.prototype.clear=function(){this.vertices.length=0},d.prototype.append=function(a,b,c){if(void 0===b)throw new Error("From is not given!");if(void 0===c)throw new Error("To is not given!");if(c-1<b)throw new Error("lol1");if(c>a.vertices.length)throw new Error("lol2");if(b<0)throw new Error("lol3");for(var d=b;d<c;d++)this.vertices.push(a.vertices[d])},d.prototype.makeCCW=function(){for(var a=0,b=this.vertices,c=1;c<this.vertices.length;++c)(b[c][1]<b[a][1]||b[c][1]==b[a][1]&&b[c][0]>b[a][0])&&(a=c);g.left(this.at(a-1),this.at(a),this.at(a+1))||this.reverse()},d.prototype.reverse=function(){for(var a=[],b=0,c=this.vertices.length;b!==c;b++)a.push(this.vertices.pop());this.vertices=a},d.prototype.isReflex=function(a){return g.right(this.at(a-1),this.at(a),this.at(a+1))};var i=[],j=[];d.prototype.canSee=function(a,b){var c,d,e=i,h=j;if(g.leftOn(this.at(a+1),this.at(a),this.at(b))&&g.rightOn(this.at(a-1),this.at(a),this.at(b)))return!1;d=g.sqdist(this.at(a),this.at(b));for(var k=0;k!==this.vertices.length;++k)if((k+1)%this.vertices.length!==a&&k!==a&&g.leftOn(this.at(a),this.at(b),this.at(k+1))&&g.rightOn(this.at(a),this.at(b),this.at(k))&&(e[0]=this.at(a),e[1]=this.at(b),h[0]=this.at(k),h[1]=this.at(k+1),c=f.lineInt(e,h),g.sqdist(this.at(a),c)<d))return!1;return!0},d.prototype.copy=function(a,b,c){var e=c||new d;if(e.clear(),a<b)for(var f=a;f<=b;f++)e.vertices.push(this.vertices[f]);else{for(f=0;f<=b;f++)e.vertices.push(this.vertices[f]);for(f=a;f<this.vertices.length;f++)e.vertices.push(this.vertices[f])}return e},d.prototype.getCutEdges=function(){for(var a=[],b=[],c=[],e=new d,f=Number.MAX_VALUE,g=0;g<this.vertices.length;++g)if(this.isReflex(g))for(var h=0;h<this.vertices.length;++h)if(this.canSee(g,h)){b=this.copy(g,h,e).getCutEdges(),c=this.copy(h,g,e).getCutEdges();for(var i=0;i<c.length;i++)b.push(c[i]);b.length<f&&(f=(a=b).length,a.push([this.at(g),this.at(h)]))}return a},d.prototype.decomp=function(){var a=this.getCutEdges();return 0<a.length?this.slice(a):[this]},d.prototype.slice=function(a){if(0==a.length)return[this];if(a instanceof Array&&a.length&&a[0]instanceof Array&&2==a[0].length&&a[0][0]instanceof Array){for(var b=[this],c=0;c<a.length;c++)for(var d=a[c],e=0;e<b.length;e++){var g=b[e].slice(d);if(g){b.splice(e,1),b.push(g[0],g[1]);break}}return b}d=a,c=this.vertices.indexOf(d[0]),e=this.vertices.indexOf(d[1]);return-1!=c&&-1!=e&&[this.copy(c,e),this.copy(e,c)]},d.prototype.isSimple=function(){for(var a=this.vertices,b=0;b<a.length-1;b++)for(var c=0;c<b-1;c++)if(f.segmentsIntersect(a[b],a[b+1],a[c],a[c+1]))return!1;for(b=1;b<a.length-2;b++)if(f.segmentsIntersect(a[0],a[a.length-1],a[b],a[b+1]))return!1;return!0},d.prototype.quickDecomp=function(a,b,c,f,h,i){h=h||100,i=i||0,f=f||25,a=void 0!==a?a:[],b=b||[],c=c||[];var j=[0,0],k=[0,0],l=[0,0],m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=new d,u=new d,v=this,w=this.vertices;if(w.length<3)return a;if(++i>h)return a;for(var x=0;x<this.vertices.length;++x)if(v.isReflex(x)){b.push(v.vertices[x]),m=n=Number.MAX_VALUE;for(var y=0;y<this.vertices.length;++y)g.left(v.at(x-1),v.at(x),v.at(y))&&g.rightOn(v.at(x-1),v.at(x),v.at(y-1))&&(l=e(v.at(x-1),v.at(x),v.at(y),v.at(y-1)),g.right(v.at(x+1),v.at(x),l)&&(o=g.sqdist(v.vertices[x],l))<n&&(n=o,k=l,r=y)),g.left(v.at(x+1),v.at(x),v.at(y+1))&&g.rightOn(v.at(x+1),v.at(x),v.at(y))&&(l=e(v.at(x+1),v.at(x),v.at(y),v.at(y+1)),g.left(v.at(x-1),v.at(x),l)&&(o=g.sqdist(v.vertices[x],l))<m&&(m=o,j=l,q=y));if(r==(q+1)%this.vertices.length)l[0]=(k[0]+j[0])/2,l[1]=(k[1]+j[1])/2,c.push(l),x<q?(t.append(v,x,q+1),t.vertices.push(l),u.vertices.push(l),0!=r&&u.append(v,r,v.vertices.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,v.vertices.length),t.append(v,0,q+1),t.vertices.push(l),u.vertices.push(l),u.append(v,r,x+1));else{if(q<r&&(q+=this.vertices.length),p=Number.MAX_VALUE,q<r)return a;for(y=r;y<=q;++y)g.leftOn(v.at(x-1),v.at(x),v.at(y))&&g.rightOn(v.at(x+1),v.at(x),v.at(y))&&(o=g.sqdist(v.at(x),v.at(y)))<p&&(p=o,s=y%this.vertices.length);x<s?(t.append(v,x,s+1),0!=s&&u.append(v,s,w.length),u.append(v,0,x+1)):(0!=x&&t.append(v,x,w.length),t.append(v,0,s+1),u.append(v,s,x+1))}return t.vertices.length<u.vertices.length?(t.quickDecomp(a,b,c,f,h,i),u.quickDecomp(a,b,c,f,h,i)):(u.quickDecomp(a,b,c,f,h,i),t.quickDecomp(a,b,c,f,h,i)),a}return a.push(this),a},d.prototype.removeCollinearPoints=function(a){for(var b=0,c=this.vertices.length-1;3<this.vertices.length&&0<=c;--c)g.collinear(this.at(c-1),this.at(c),this.at(c+1),a)&&(this.vertices.splice(c%this.vertices.length,1),c--,b++);return b}},{"./Line":1,"./Point":2,"./Scalar":4}],4:[function(a,b,c){function d(){}(b.exports=d).eq=function(a,b,c){return c=c||0,Math.abs(a-b)<c}},{}],5:[function(a,b,c){b.exports={Polygon:a("./Polygon"),Point:a("./Point")}},{"./Point":2,"./Polygon":3}],6:[function(a,b,c){b.exports={name:"p2",version:"0.7.0",description:"A JavaScript 2D physics engine.",author:"Stefan Hedman <schteppe@gmail.com> (http://steffe.se)",keywords:["p2.js","p2","physics","engine","2d"],main:"./src/p2.js",engines:{node:"*"},repository:{type:"git",url:"https://github.com/schteppe/p2.js.git"},bugs:{url:"https://github.com/schteppe/p2.js/issues"},licenses:[{type:"MIT"}],devDependencies:{grunt:"^0.4.5","grunt-contrib-jshint":"^0.11.2","grunt-contrib-nodeunit":"^0.4.1","grunt-contrib-uglify":"~0.4.0","grunt-contrib-watch":"~0.5.0","grunt-browserify":"~2.0.1","grunt-contrib-concat":"^0.4.0"},dependencies:{"poly-decomp":"0.1.0"}}},{}],7:[function(a,b,c){function d(a){this.lowerBound=e.create(),a&&a.lowerBound&&e.copy(this.lowerBound,a.lowerBound),this.upperBound=e.create(),a&&a.upperBound&&e.copy(this.upperBound,a.upperBound)}var e=a("../math/vec2");a("../utils/Utils"),b.exports=d;var f=e.create();d.prototype.setFromPoints=function(a,b,c,d){var g=this.lowerBound,h=this.upperBound;"number"!=typeof c&&(c=0),0!==c?e.rotate(g,a[0],c):e.copy(g,a[0]),e.copy(h,g);for(var i=Math.cos(c),j=Math.sin(c),k=1;k<a.length;k++){var l=a[k];if(0!==c){var m=l[0],n=l[1];f[0]=i*m-j*n,f[1]=j*m+i*n,l=f}for(var o=0;o<2;o++)l[o]>h[o]&&(h[o]=l[o]),l[o]<g[o]&&(g[o]=l[o])}b&&(e.add(this.lowerBound,this.lowerBound,b),e.add(this.upperBound,this.upperBound,b)),d&&(this.lowerBound[0]-=d,this.lowerBound[1]-=d,this.upperBound[0]+=d,this.upperBound[1]+=d)},d.prototype.copy=function(a){e.copy(this.lowerBound,a.lowerBound),e.copy(this.upperBound,a.upperBound)},d.prototype.extend=function(a){for(var b=2;b--;){var c=a.lowerBound[b];this.lowerBound[b]>c&&(this.lowerBound[b]=c);var d=a.upperBound[b];this.upperBound[b]<d&&(this.upperBound[b]=d)}},d.prototype.overlaps=function(a){var b=this.lowerBound,c=this.upperBound,d=a.lowerBound,e=a.upperBound;return(d[0]<=c[0]&&c[0]<=e[0]||b[0]<=e[0]&&e[0]<=c[0])&&(d[1]<=c[1]&&c[1]<=e[1]||b[1]<=e[1]&&e[1]<=c[1])},d.prototype.containsPoint=function(a){var b=this.lowerBound,c=this.upperBound;return b[0]<=a[0]&&a[0]<=c[0]&&b[1]<=a[1]&&a[1]<=c[1]},d.prototype.overlapsRay=function(a){var b=1/a.direction[0],c=1/a.direction[1],d=(this.lowerBound[0]-a.from[0])*b,e=(this.upperBound[0]-a.from[0])*b,f=(this.lowerBound[1]-a.from[1])*c,g=(this.upperBound[1]-a.from[1])*c,h=Math.max(Math.max(Math.min(d,e),Math.min(f,g))),i=Math.min(Math.min(Math.max(d,e),Math.max(f,g)));return i<0?-1:i<h?-1:h}},{"../math/vec2":30,"../utils/Utils":57}],8:[function(a,b,c){function d(a){this.type=a,this.result=[],this.world=null,this.boundingVolumeType=d.AABB}var e=a("../math/vec2"),f=a("../objects/Body");(b.exports=d).AABB=1,d.BOUNDING_CIRCLE=2,d.prototype.setWorld=function(a){this.world=a},d.prototype.getCollisionPairs=function(a){};var g=e.create();d.boundingRadiusCheck=function(a,b){e.sub(g,a.position,b.position);var c=e.squaredLength(g),d=a.boundingRadius+b.boundingRadius;return c<=d*d},d.aabbCheck=function(a,b){return a.getAABB().overlaps(b.getAABB())},d.prototype.boundingVolumeCheck=function(a,b){var c;switch(this.boundingVolumeType){case d.BOUNDING_CIRCLE:c=d.boundingRadiusCheck(a,b);break;case d.AABB:c=d.aabbCheck(a,b);break;default:throw new Error("Bounding volume type not recognized: "+this.boundingVolumeType)}return c},d.canCollide=function(a,b){var c=f.KINEMATIC,d=f.STATIC;return!(a.type===d&&b.type===d||a.type===c&&b.type===d||a.type===d&&b.type===c||a.type===c&&b.type===c||a.sleepState===f.SLEEPING&&b.sleepState===f.SLEEPING||a.sleepState===f.SLEEPING&&b.type===d||b.sleepState===f.SLEEPING&&a.type===d)},d.NAIVE=1,d.SAP=2},{"../math/vec2":30,"../objects/Body":31}],9:[function(a,b,c){function d(){e.call(this,e.NAIVE)}var e=(a("../shapes/Circle"),a("../shapes/Plane"),a("../shapes/Shape"),a("../shapes/Particle"),a("../collision/Broadphase"));a("../math/vec2"),(((b.exports=d).prototype=new e).constructor=d).prototype.getCollisionPairs=function(a){for(var b=a.bodies,c=this.result,d=c.length=0,f=b.length;d!==f;d++)for(var g=b[d],h=0;h<d;h++){var i=b[h];e.canCollide(g,i)&&this.boundingVolumeCheck(g,i)&&c.push(g,i)}return c},d.prototype.aabbQuery=function(a,b,c){c=c||[];for(var d=a.bodies,e=0;e<d.length;e++){var f=d[e];f.aabbNeedsUpdate&&f.updateAABB(),f.aabb.overlaps(b)&&c.push(f)}return c}},{"../collision/Broadphase":8,"../math/vec2":30,"../shapes/Circle":39,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45}],10:[function(a,b,c){function d(){this.contactEquations=[],this.frictionEquations=[],this.enableFriction=!0,this.enabledEquations=!0,this.slipForce=10,this.frictionCoefficient=.3,this.surfaceVelocity=0,this.contactEquationPool=new k({size:32}),this.frictionEquationPool=new l({size:64}),this.restitution=0,this.stiffness=n.DEFAULT_STIFFNESS,this.relaxation=n.DEFAULT_RELAXATION,this.frictionStiffness=n.DEFAULT_STIFFNESS,this.frictionRelaxation=n.DEFAULT_RELAXATION,this.enableFrictionReduction=!0,this.collidingBodiesLastStep=new m,this.contactSkinSize=.01}function e(a,b){g.set(a.vertices[0],.5*-b.length,-b.radius),g.set(a.vertices[1],.5*b.length,-b.radius),g.set(a.vertices[2],.5*b.length,b.radius),g.set(a.vertices[3],.5*-b.length,b.radius)}function f(a,b,c,d){for(var e=T,f=U,j=V,k=W,l=a,m=b.vertices,n=null,o=0;o!==m.length+1;o++){var p=m[o%m.length],q=m[(o+1)%m.length];g.rotate(e,p,d),g.rotate(f,q,d),i(e,e,c),i(f,f,c),h(j,e,l),h(k,f,l);var r=g.crossLength(j,k);if(null===n&&(n=r),r*n<=0)return!1;n=r}return!0}var g=a("../math/vec2"),h=g.sub,i=g.add,j=g.dot,k=(a("../utils/Utils"),a("../utils/ContactEquationPool")),l=a("../utils/FrictionEquationPool"),m=a("../utils/TupleDictionary"),n=a("../equations/Equation"),o=(a("../equations/ContactEquation"),a("../equations/FrictionEquation"),a("../shapes/Circle")),p=a("../shapes/Convex"),q=a("../shapes/Shape"),r=(a("../objects/Body"),a("../shapes/Box"));b.exports=d;var s=g.fromValues(0,1),t=g.fromValues(0,0),u=g.fromValues(0,0),v=g.fromValues(0,0),w=g.fromValues(0,0),x=g.fromValues(0,0),y=g.fromValues(0,0),z=g.fromValues(0,0),A=g.fromValues(0,0),B=g.fromValues(0,0),C=g.fromValues(0,0),D=g.fromValues(0,0),E=g.fromValues(0,0),F=g.fromValues(0,0),G=g.fromValues(0,0),H=g.fromValues(0,0),I=g.fromValues(0,0),J=g.fromValues(0,0),K=g.fromValues(0,0),L=[],M=g.create(),N=g.create();d.prototype.bodiesOverlap=function(a,b){for(var c=M,d=N,e=0,f=a.shapes.length;e!==f;e++){var g=a.shapes[e];a.toWorldFrame(c,g.position);for(var h=0,i=b.shapes.length;h!==i;h++){var j=b.shapes[h];if(b.toWorldFrame(d,j.position),this[g.type|j.type](a,g,c,g.angle+a.angle,b,j,d,j.angle+b.angle,!0))return!0}}return!1},d.prototype.collidedLastStep=function(a,b){var c=0|a.id,d=0|b.id;return!!this.collidingBodiesLastStep.get(c,d)},d.prototype.reset=function(){this.collidingBodiesLastStep.reset();for(var a=this.contactEquations,b=a.length;b--;){var c=a[b],d=c.bodyA.id,e=c.bodyB.id;this.collidingBodiesLastStep.set(d,e,!0)}for(var f=this.contactEquations,g=this.frictionEquations,h=0;h<f.length;h++)this.contactEquationPool.release(f[h]);for(h=0;h<g.length;h++)this.frictionEquationPool.release(g[h]);this.contactEquations.length=this.frictionEquations.length=0},d.prototype.createContactEquation=function(a,b,c,d){var e=this.contactEquationPool.get();return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.restitution=this.restitution,e.firstImpact=!this.collidedLastStep(a,b),e.stiffness=this.stiffness,e.relaxation=this.relaxation,e.needsUpdate=!0,e.enabled=this.enabledEquations,e.offset=this.contactSkinSize,e},d.prototype.createFrictionEquation=function(a,b,c,d){var e=this.frictionEquationPool.get();return e.bodyA=a,e.bodyB=b,e.shapeA=c,e.shapeB=d,e.setSlipForce(this.slipForce),e.frictionCoefficient=this.frictionCoefficient,e.relativeVelocity=this.surfaceVelocity,e.enabled=this.enabledEquations,e.needsUpdate=!0,e.stiffness=this.frictionStiffness,e.relaxation=this.frictionRelaxation,e.contactEquations.length=0,e},d.prototype.createFrictionFromContact=function(a){var b=this.createFrictionEquation(a.bodyA,a.bodyB,a.shapeA,a.shapeB);return g.copy(b.contactPointA,a.contactPointA),g.copy(b.contactPointB,a.contactPointB),g.rotate90cw(b.t,a.normalA),b.contactEquations.push(a),b},d.prototype.createFrictionFromAverage=function(a){var b=this.contactEquations[this.contactEquations.length-1],c=this.createFrictionEquation(b.bodyA,b.bodyB,b.shapeA,b.shapeB),d=b.bodyA;b.bodyB,g.set(c.contactPointA,0,0),g.set(c.contactPointB,0,0),g.set(c.t,0,0);for(var e=0;e!==a;e++)(b=this.contactEquations[this.contactEquations.length-1-e]).bodyA===d?(g.add(c.t,c.t,b.normalA),g.add(c.contactPointA,c.contactPointA,b.contactPointA),g.add(c.contactPointB,c.contactPointB,b.contactPointB)):(g.sub(c.t,c.t,b.normalA),g.add(c.contactPointA,c.contactPointA,b.contactPointB),g.add(c.contactPointB,c.contactPointB,b.contactPointA)),c.contactEquations.push(b);var f=1/a;return g.scale(c.contactPointA,c.contactPointA,f),g.scale(c.contactPointB,c.contactPointB,f),g.normalize(c.t,c.t),g.rotate90cw(c.t,c.t),c},d.prototype[q.LINE|q.CONVEX]=d.prototype.convexLine=function(a,b,c,d,e,f,g,h,i){return!i&&0},d.prototype[q.LINE|q.BOX]=d.prototype.lineBox=function(a,b,c,d,e,f,g,h,i){return!i&&0};var O=new r({width:1,height:1}),P=g.create();d.prototype[q.CAPSULE|q.CONVEX]=d.prototype[q.CAPSULE|q.BOX]=d.prototype.convexCapsule=function(a,b,c,d,f,h,i,j,k){var l=P;g.set(l,h.length/2,0),g.rotate(l,l,j),g.add(l,l,i);var m=this.circleConvex(f,h,l,j,a,b,c,d,k,h.radius);g.set(l,-h.length/2,0),g.rotate(l,l,j),g.add(l,l,i);var n=this.circleConvex(f,h,l,j,a,b,c,d,k,h.radius);if(k&&(m||n))return!0;var o=O;return e(o,h),this.convexConvex(a,b,c,d,f,o,i,j,k)+m+n},d.prototype[q.CAPSULE|q.LINE]=d.prototype.lineCapsule=function(a,b,c,d,e,f,g,h,i){return!i&&0};var Q=g.create(),R=g.create(),S=new r({width:1,height:1});d.prototype[q.CAPSULE|q.CAPSULE]=d.prototype.capsuleCapsule=function(a,b,c,d,f,h,i,j,k){for(var m=Q,n=R,o=0,p=0;p<2;p++){g.set(m,(0===p?-1:1)*b.length/2,0),g.rotate(m,m,d),g.add(m,m,c);for(var q=0;q<2;q++){g.set(n,(0===q?-1:1)*h.length/2,0),g.rotate(n,n,j),g.add(n,n,i),this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var r=this.circleCircle(a,b,m,d,f,h,n,j,k,b.radius,h.radius);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&r)return!0;o+=r}}this.enableFrictionReduction&&(l=this.enableFriction,this.enableFriction=!1);var s=S;e(s,b);var t=this.convexCapsule(a,s,c,d,f,h,i,j,k);if(this.enableFrictionReduction&&(this.enableFriction=l),k&&t)return!0;if(o+=t,this.enableFrictionReduction){var l=this.enableFriction;this.enableFriction=!1}e(s,h);var u=this.convexCapsule(f,s,i,j,a,b,c,d,k);return this.enableFrictionReduction&&(this.enableFriction=l),!(!k||!u)||(o+=u,this.enableFrictionReduction&&o&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(o)),o)},d.prototype[q.LINE|q.LINE]=d.prototype.lineLine=function(a,b,c,d,e,f,g,h,i){return!i&&0},d.prototype[q.PLANE|q.LINE]=d.prototype.planeLine=function(a,b,c,d,e,f,k,l,m){var n=t,o=u,p=v,q=w,r=x,C=y,D=z,E=A,F=B,G=L,H=0;g.set(n,-f.length/2,0),g.set(o,f.length/2,0),g.rotate(p,n,l),g.rotate(q,o,l),i(p,p,k),i(q,q,k),g.copy(n,p),g.copy(o,q),h(r,o,n),g.normalize(C,r),g.rotate90cw(F,C),g.rotate(E,s,d),G[0]=n,G[1]=o;for(var I=0;I<G.length;I++){var J=G[I];h(D,J,c);var K=j(D,E);if(K<0){if(m)return!0;var M=this.createContactEquation(a,e,b,f);H++,g.copy(M.normalA,E),g.normalize(M.normalA,M.normalA),g.scale(D,E,K),h(M.contactPointA,J,D),h(M.contactPointA,M.contactPointA,a.position),h(M.contactPointB,J,k),i(M.contactPointB,M.contactPointB,k),h(M.contactPointB,M.contactPointB,e.position),this.contactEquations.push(M),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(M))}}return!m&&(this.enableFrictionReduction||H&&this.enableFriction&&this.frictionEquations.push(this.createFrictionFromAverage(H)),H)},d.prototype[q.PARTICLE|q.CAPSULE]=d.prototype.particleCapsule=function(a,b,c,d,e,f,g,h,i){return this.circleLine(a,b,c,d,e,f,g,h,i,f.radius,0)},d.prototype[q.CIRCLE|q.LINE]=d.prototype.circleLine=function(a,b,c,d,e,f,k,l,m,n,o){n=n||0,o=void 0!==o?o:b.radius;var p=t,q=u,r=v,s=w,H=x,I=y,J=z,K=A,M=B,N=C,O=D,P=E,Q=F,R=G,S=L;g.set(K,-f.length/2,0),g.set(M,f.length/2,0),g.rotate(N,K,l),g.rotate(O,M,l),i(N,N,k),i(O,O,k),g.copy(K,N),g.copy(M,O),h(I,M,K),g.normalize(J,I),g.rotate90cw(H,J),h(P,c,K);var T=j(P,H);h(s,K,k),h(Q,c,k);var U=o+n;if(Math.abs(T)<U){g.scale(p,H,T),h(r,c,p),g.scale(q,H,j(H,Q)),g.normalize(q,q),g.scale(q,q,n),i(r,r,q);var V=j(J,r),W=j(J,K),X=j(J,M);if(W<V&&V<X){if(m)return!0;var Y=this.createContactEquation(a,e,b,f);return g.scale(Y.normalA,p,-1),g.normalize(Y.normalA,Y.normalA),g.scale(Y.contactPointA,Y.normalA,o),i(Y.contactPointA,Y.contactPointA,c),h(Y.contactPointA,Y.contactPointA,a.position),h(Y.contactPointB,r,k),i(Y.contactPointB,Y.contactPointB,k),h(Y.contactPointB,Y.contactPointB,e.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}}S[0]=K,S[1]=M;for(var Z=0;Z<S.length;Z++){var $=S[Z];if(h(P,$,c),g.squaredLength(P)<Math.pow(U,2)){if(m)return!0;Y=this.createContactEquation(a,e,b,f);return g.copy(Y.normalA,P),g.normalize(Y.normalA,Y.normalA),g.scale(Y.contactPointA,Y.normalA,o),i(Y.contactPointA,Y.contactPointA,c),h(Y.contactPointA,Y.contactPointA,a.position),h(Y.contactPointB,$,k),g.scale(R,Y.normalA,-n),i(Y.contactPointB,Y.contactPointB,R),i(Y.contactPointB,Y.contactPointB,k),h(Y.contactPointB,Y.contactPointB,e.position),this.contactEquations.push(Y),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(Y)),1}}return 0},d.prototype[q.CIRCLE|q.CAPSULE]=d.prototype.circleCapsule=function(a,b,c,d,e,f,g,h,i){return this.circleLine(a,b,c,d,e,f,g,h,i,f.radius)},d.prototype[q.CIRCLE|q.CONVEX]=d.prototype[q.CIRCLE|q.BOX]=d.prototype.circleConvex=function(a,b,c,d,e,j,k,l,m,n){n="number"==typeof n?n:b.radius;for(var o=t,p=u,q=v,r=w,s=x,y=C,z=D,A=F,B=G,E=H,J=I,K=!1,L=Number.MAX_VALUE,M=j.vertices,N=0;N!==M.length+1;N++){var O=M[N%M.length],P=M[(N+1)%M.length];if(g.rotate(o,O,l),g.rotate(p,P,l),i(o,o,k),i(p,p,k),h(q,p,o),g.normalize(r,q),g.rotate90cw(s,r),g.scale(B,s,-b.radius),i(B,B,c),f(B,j,k,l)){g.sub(E,o,B);var Q=Math.abs(g.dot(E,s));Q<L&&(g.copy(J,B),L=Q,g.scale(A,s,Q),g.add(A,A,B),K=!0)}}if(K){if(m)return!0;var R=this.createContactEquation(a,e,b,j);return g.sub(R.normalA,J,c),g.normalize(R.normalA,R.normalA),g.scale(R.contactPointA,R.normalA,n),i(R.contactPointA,R.contactPointA,c),h(R.contactPointA,R.contactPointA,a.position),h(R.contactPointB,A,k),i(R.contactPointB,R.contactPointB,k),h(R.contactPointB,R.contactPointB,e.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}if(0<n)for(N=0;N<M.length;N++){var S=M[N];if(g.rotate(z,S,l),i(z,z,k),h(y,z,c),g.squaredLength(y)<Math.pow(n,2)){if(m)return!0;R=this.createContactEquation(a,e,b,j);return g.copy(R.normalA,y),g.normalize(R.normalA,R.normalA),g.scale(R.contactPointA,R.normalA,n),i(R.contactPointA,R.contactPointA,c),h(R.contactPointA,R.contactPointA,a.position),h(R.contactPointB,z,k),i(R.contactPointB,R.contactPointB,k),h(R.contactPointB,R.contactPointB,e.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}}return 0};var T=g.create(),U=g.create(),V=g.create(),W=g.create();d.prototype[q.PARTICLE|q.CONVEX]=d.prototype[q.PARTICLE|q.BOX]=d.prototype.particleConvex=function(a,b,c,d,e,k,l,m,n){var o=t,p=u,q=v,r=w,s=x,A=y,B=z,D=C,E=F,G=J,H=K,I=Number.MAX_VALUE,L=!1,M=k.vertices;if(!f(c,k,l,m))return 0;if(n)return!0;for(var N=0;N!==M.length+1;N++){var O=M[N%M.length],P=M[(N+1)%M.length];g.rotate(o,O,m),g.rotate(p,P,m),i(o,o,l),i(p,p,l),h(q,p,o),g.normalize(r,q),g.rotate90cw(s,r),h(D,c,o),j(D,s),h(A,o,l),h(B,c,l),g.sub(G,o,c);var Q=Math.abs(g.dot(G,s));Q<I&&(I=Q,g.scale(E,s,Q),g.add(E,E,c),g.copy(H,s),L=!0)}if(L){var R=this.createContactEquation(a,e,b,k);return g.scale(R.normalA,H,-1),g.normalize(R.normalA,R.normalA),g.set(R.contactPointA,0,0),i(R.contactPointA,R.contactPointA,c),h(R.contactPointA,R.contactPointA,a.position),h(R.contactPointB,E,l),i(R.contactPointB,R.contactPointB,l),h(R.contactPointB,R.contactPointB,e.position),this.contactEquations.push(R),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(R)),1}return 0},d.prototype[q.CIRCLE]=d.prototype.circleCircle=function(a,b,c,d,e,f,j,k,l,m,n){var o=t;m=m||b.radius,n=n||f.radius;h(o,c,j);var p=m+n;if(g.squaredLength(o)>Math.pow(p,2))return 0;if(l)return!0;var q=this.createContactEquation(a,e,b,f);return h(q.normalA,j,c),g.normalize(q.normalA,q.normalA),g.scale(q.contactPointA,q.normalA,m),g.scale(q.contactPointB,q.normalA,-n),i(q.contactPointA,q.contactPointA,c),h(q.contactPointA,q.contactPointA,a.position),i(q.contactPointB,q.contactPointB,j),h(q.contactPointB,q.contactPointB,e.position),this.contactEquations.push(q),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(q)),1},d.prototype[q.PLANE|q.CONVEX]=d.prototype[q.PLANE|q.BOX]=d.prototype.planeConvex=function(a,b,c,d,e,f,k,l,m){var n=t,o=u,p=v,q=0;g.rotate(o,s,d);for(var r=0;r!==f.vertices.length;r++){var w=f.vertices[r];if(g.rotate(n,w,l),i(n,n,k),h(p,n,c),j(p,o)<=0){if(m)return!0;q++;var x=this.createContactEquation(a,e,b,f);h(p,n,c),g.copy(x.normalA,o);var y=j(p,x.normalA);g.scale(p,x.normalA,y),h(x.contactPointB,n,e.position),h(x.contactPointA,n,p),h(x.contactPointA,x.contactPointA,a.position),this.contactEquations.push(x),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(x))}}return this.enableFrictionReduction&&this.enableFriction&&q&&this.frictionEquations.push(this.createFrictionFromAverage(q)),q},d.prototype[q.PARTICLE|q.PLANE]=d.prototype.particlePlane=function(a,b,c,d,e,f,i,k,l){var m=t,n=u;k=k||0,h(m,c,i),g.rotate(n,s,k);var o=j(m,n);if(0<o)return 0;if(l)return!0;var p=this.createContactEquation(e,a,f,b);return g.copy(p.normalA,n),g.scale(m,p.normalA,o),h(p.contactPointA,c,m),h(p.contactPointA,p.contactPointA,e.position),h(p.contactPointB,c,a.position),this.contactEquations.push(p),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(p)),1},d.prototype[q.CIRCLE|q.PARTICLE]=d.prototype.circleParticle=function(a,b,c,d,e,f,j,k,l){var m=t;if(h(m,j,c),g.squaredLength(m)>Math.pow(b.radius,2))return 0;if(l)return!0;var n=this.createContactEquation(a,e,b,f);return g.copy(n.normalA,m),g.normalize(n.normalA,n.normalA),g.scale(n.contactPointA,n.normalA,b.radius),i(n.contactPointA,n.contactPointA,c),h(n.contactPointA,n.contactPointA,a.position),h(n.contactPointB,j,e.position),this.contactEquations.push(n),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(n)),1};var X=new o({radius:1}),Y=g.create(),Z=g.create();g.create(),d.prototype[q.PLANE|q.CAPSULE]=d.prototype.planeCapsule=function(a,b,c,d,e,f,h,j,k){var o,l=Y,m=Z,n=X;g.set(l,-f.length/2,0),g.rotate(l,l,j),i(l,l,h),g.set(m,f.length/2,0),g.rotate(m,m,j),i(m,m,h),n.radius=f.radius,this.enableFrictionReduction&&(o=this.enableFriction,this.enableFriction=!1);var p=this.circlePlane(e,n,l,0,a,b,c,d,k),q=this.circlePlane(e,n,m,0,a,b,c,d,k);if(this.enableFrictionReduction&&(this.enableFriction=o),k)return p||q;var r=p+q;return this.enableFrictionReduction&&r&&this.frictionEquations.push(this.createFrictionFromAverage(r)),r},d.prototype[q.CIRCLE|q.PLANE]=d.prototype.circlePlane=function(a,b,c,d,e,f,k,l,m){var n=a,o=b,p=c,q=e,r=k,w=l;w=w||0;var x=t,y=u,z=v;h(x,p,r),g.rotate(y,s,w);var A=j(y,x);if(A>o.radius)return 0;if(m)return!0;var B=this.createContactEquation(q,n,f,b);return g.copy(B.normalA,y),g.scale(B.contactPointB,B.normalA,-o.radius),i(B.contactPointB,B.contactPointB,p),h(B.contactPointB,B.contactPointB,n.position),g.scale(z,B.normalA,A),h(B.contactPointA,x,z),i(B.contactPointA,B.contactPointA,r),h(B.contactPointA,B.contactPointA,q.position),this.contactEquations.push(B),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(B)),1},d.prototype[q.CONVEX]=d.prototype[q.CONVEX|q.BOX]=d.prototype[q.BOX]=d.prototype.convexConvex=function(a,b,c,e,f,k,l,m,n,o){var p=t,q=u,r=v,s=w,y=x,C=z,D=A,E=B,F=0;o="number"==typeof o?o:0;if(!d.findSeparatingAxis(b,c,e,k,l,m,p))return 0;h(D,l,c),0<j(p,D)&&g.scale(p,p,-1);var G=d.getClosestEdge(b,e,p,!0),H=d.getClosestEdge(k,m,p);if(-1===G||-1===H)return 0;for(var I=0;I<2;I++){var T,J=G,K=H,L=b,M=k,N=c,O=l,P=e,Q=m,R=a,S=f;if(0===I)T=J,J=K,K=T,T=L,L=M,M=T,T=N,N=O,O=T,T=P,P=Q,Q=T,T=R,R=S,S=T;for(var U=K;U<K+2;U++){var V=M.vertices[(U+M.vertices.length)%M.vertices.length];g.rotate(q,V,Q),i(q,q,O);for(var W=0,X=J-1;X<J+2;X++){var Y=L.vertices[(X+L.vertices.length)%L.vertices.length],Z=L.vertices[(X+1+L.vertices.length)%L.vertices.length];g.rotate(r,Y,P),g.rotate(s,Z,P),i(r,r,N),i(s,s,N),h(y,s,r),g.rotate90cw(E,y),g.normalize(E,E),h(D,q,r);var $=j(E,D);(X===J&&$<=o||X!==J&&$<=0)&&W++}if(3<=W){if(n)return!0;var _=this.createContactEquation(R,S,L,M);F++;Y=L.vertices[J%L.vertices.length],Z=L.vertices[(J+1)%L.vertices.length];g.rotate(r,Y,P),g.rotate(s,Z,P),i(r,r,N),i(s,s,N),h(y,s,r),g.rotate90cw(_.normalA,y),g.normalize(_.normalA,_.normalA),h(D,q,r);$=j(_.normalA,D);g.scale(C,_.normalA,$),h(_.contactPointA,q,N),h(_.contactPointA,_.contactPointA,C),i(_.contactPointA,_.contactPointA,N),h(_.contactPointA,_.contactPointA,R.position),h(_.contactPointB,q,O),i(_.contactPointB,_.contactPointB,O),h(_.contactPointB,_.contactPointB,S.position),this.contactEquations.push(_),this.enableFrictionReduction||this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(_))}}}return this.enableFrictionReduction&&this.enableFriction&&F&&this.frictionEquations.push(this.createFrictionFromAverage(F)),F};var $=g.fromValues(0,0);d.projectConvexOntoAxis=function(a,b,c,d,e){var f,h,i=null,k=null,l=$;g.rotate(l,d,-c);for(var m=0;m<a.vertices.length;m++)f=a.vertices[m],h=j(f,l),(null===i||i<h)&&(i=h),(null===k||h<k)&&(k=h);if(i<k){var n=k;k=i,i=n}var o=j(b,d);g.set(e,k+o,i+o)};var _=g.fromValues(0,0),aa=g.fromValues(0,0),ba=g.fromValues(0,0),ca=g.fromValues(0,0),da=g.fromValues(0,0),ea=g.fromValues(0,0);d.findSeparatingAxis=function(a,b,c,e,f,i,j){var k=null,l=!1,m=!1,n=_,o=aa,p=ba,q=ca,s=da,t=ea;if(a instanceof r&&e instanceof r)for(var u=0;2!==u;u++){var v=a,w=c;1===u&&(v=e,w=i);for(var x=0;2!==x;x++){0===x?g.set(q,0,1):1===x&&g.set(q,1,0),0!==w&&g.rotate(q,q,w),d.projectConvexOntoAxis(a,b,c,q,s),d.projectConvexOntoAxis(e,f,i,q,t);var y=s,z=t;s[0]>t[0]&&(z=s,y=t),l=(A=z[0]-y[1])<=0,(null===k||k<A)&&(g.copy(j,q),k=A,m=l)}}else for(u=0;2!==u;u++){v=a,w=c;1===u&&(v=e,w=i);for(x=0;x!==v.vertices.length;x++){g.rotate(o,v.vertices[x],w),g.rotate(p,v.vertices[(x+1)%v.vertices.length],w),h(n,p,o),g.rotate90cw(q,n),g.normalize(q,q),d.projectConvexOntoAxis(a,b,c,q,s),d.projectConvexOntoAxis(e,f,i,q,t);var A;y=s,z=t;s[0]>t[0]&&(z=s,y=t),l=(A=z[0]-y[1])<=0,(null===k||k<A)&&(g.copy(j,q),k=A,m=l)}}return m};var fa=g.fromValues(0,0),ga=g.fromValues(0,0),ha=g.fromValues(0,0);d.getClosestEdge=function(a,b,c,d){var e=fa,f=ga,i=ha;g.rotate(e,c,-b),d&&g.scale(e,e,-1);for(var k=-1,l=a.vertices.length,m=-1,n=0;n!==l;n++){h(f,a.vertices[(n+1)%l],a.vertices[n%l]),g.rotate90cw(i,f),g.normalize(i,i);var o=j(i,e);(-1===k||m<o)&&(k=n%l,m=o)}return k};var ia=g.create(),ja=g.create(),ka=g.create(),la=g.create(),ma=g.create(),na=g.create(),oa=g.create();d.prototype[q.CIRCLE|q.HEIGHTFIELD]=d.prototype.circleHeightfield=function(a,b,c,d,e,f,j,k,l,m){var n=f.heights,o=(m=m||b.radius,f.elementWidth),p=ja,q=ia,r=ma,s=oa,t=na,u=ka,v=la,w=Math.floor((c[0]-m-j[0])/o),x=Math.ceil((c[0]+m-j[0])/o);w<0&&(w=0),x>=n.length&&(x=n.length-1);for(var y=n[w],z=n[x],A=w;A<x;A++)n[A]<z&&(z=n[A]),n[A]>y&&(y=n[A]);if(c[1]-m>y)return!l&&0;var B=!1;for(A=w;A<x;A++){g.set(u,A*o,n[A]),g.set(v,(A+1)*o,n[A+1]),g.add(u,u,j),g.add(v,v,j),g.sub(t,v,u),g.rotate(t,t,Math.PI/2),g.normalize(t,t),g.scale(q,t,-m),g.add(q,q,c),g.sub(p,q,u);var C=g.dot(p,t);if(q[0]>=u[0]&&q[0]<v[0]&&C<=0){if(l)return!0;B=!0,g.scale(p,t,-C),g.add(r,q,p),g.copy(s,t);var D=this.createContactEquation(e,a,f,b);g.copy(D.normalA,s),g.scale(D.contactPointB,D.normalA,-m),i(D.contactPointB,D.contactPointB,c),h(D.contactPointB,D.contactPointB,a.position),g.copy(D.contactPointA,r),g.sub(D.contactPointA,D.contactPointA,e.position),this.contactEquations.push(D),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(D))}}if(B=!1,0<m)for(A=w;A<=x;A++)if(g.set(u,A*o,n[A]),g.add(u,u,j),g.sub(p,c,u),g.squaredLength(p)<Math.pow(m,2)){if(l)return!0;B=!0;D=this.createContactEquation(e,a,f,b);g.copy(D.normalA,p),g.normalize(D.normalA,D.normalA),g.scale(D.contactPointB,D.normalA,-m),i(D.contactPointB,D.contactPointB,c),h(D.contactPointB,D.contactPointB,a.position),h(D.contactPointA,u,j),i(D.contactPointA,D.contactPointA,j),h(D.contactPointA,D.contactPointA,e.position),this.contactEquations.push(D),this.enableFriction&&this.frictionEquations.push(this.createFrictionFromContact(D))}return B?1:0};var pa=g.create(),qa=g.create(),ra=g.create(),sa=new p({vertices:[g.create(),g.create(),g.create(),g.create()]});d.prototype[q.BOX|q.HEIGHTFIELD]=d.prototype[q.CONVEX|q.HEIGHTFIELD]=d.prototype.convexHeightfield=function(a,b,c,d,e,f,h,i,j){var k=f.heights,l=f.elementWidth,m=pa,n=qa,o=ra,p=sa,q=Math.floor((a.aabb.lowerBound[0]-h[0])/l),r=Math.ceil((a.aabb.upperBound[0]-h[0])/l);q<0&&(q=0),r>=k.length&&(r=k.length-1);for(var s=k[q],t=k[r],u=q;u<r;u++)k[u]<t&&(t=k[u]),k[u]>s&&(s=k[u]);if(a.aabb.lowerBound[1]>s)return!j&&0;var v=0;for(u=q;u<r;u++){g.set(m,u*l,k[u]),g.set(n,(u+1)*l,k[u+1]),g.add(m,m,h),g.add(n,n,h);g.set(o,.5*(n[0]+m[0]),.5*(n[1]+m[1]-100)),g.sub(p.vertices[0],n,o),g.sub(p.vertices[1],m,o),g.copy(p.vertices[2],p.vertices[1]),g.copy(p.vertices[3],p.vertices[0]),p.vertices[2][1]-=100,p.vertices[3][1]-=100,v+=this.convexConvex(a,b,c,d,e,p,o,0,j)}return v}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../shapes/Box":37,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Shape":45,"../utils/ContactEquationPool":48,"../utils/FrictionEquationPool":49,"../utils/TupleDictionary":56,"../utils/Utils":57}],11:[function(a,b,c){function d(a){a=a||{},this.from=a.from?f.fromValues(a.from[0],a.from[1]):f.create(),this.to=a.to?f.fromValues(a.to[0],a.to[1]):f.create(),this.checkCollisionResponse=void 0===a.checkCollisionResponse||a.checkCollisionResponse,this.skipBackfaces=!!a.skipBackfaces,this.collisionMask=void 0!==a.collisionMask?a.collisionMask:-1,this.collisionGroup=void 0!==a.collisionGroup?a.collisionGroup:-1,this.mode=void 0!==a.mode?a.mode:d.ANY,this.callback=a.callback||function(a){},this.direction=f.create(),this.length=1,this.update()}function e(a,b,c){f.sub(h,c,a);var d=f.dot(h,b);return f.scale(i,b,d),f.add(i,i,a),f.squaredDistance(c,i)}b.exports=d;var f=a("../math/vec2");a("../collision/RaycastResult"),a("../shapes/Shape"),a("../collision/AABB"),(d.prototype.constructor=d).CLOSEST=1,d.ANY=2,d.ALL=4,d.prototype.update=function(){var a=this.direction;f.sub(a,this.to,this.from),this.length=f.length(a),f.normalize(a,a)},d.prototype.intersectBodies=function(a,b){for(var c=0,d=b.length;!a.shouldStop(this)&&c<d;c++){var e=b[c],f=e.getAABB();(0<=f.overlapsRay(this)||f.containsPoint(this.from))&&this.intersectBody(a,e)}};var g=f.create();d.prototype.intersectBody=function(a,b){var c=this.checkCollisionResponse;if(!c||b.collisionResponse)for(var d=g,e=0,h=b.shapes.length;e<h;e++){var i=b.shapes[e];if((!c||i.collisionResponse)&&0!=(this.collisionGroup&i.collisionMask)&&0!=(i.collisionGroup&this.collisionMask)){f.rotate(d,i.position,b.angle),f.add(d,d,b.position);var j=i.angle+b.angle;if(this.intersectShape(a,i,j,d,b),a.shouldStop(this))break}}},d.prototype.intersectShape=function(a,b,c,d,f){e(this.from,this.direction,d)>b.boundingRadius*b.boundingRadius||(this._currentBody=f,(this._currentShape=b).raycast(a,this,d,c),this._currentBody=this._currentShape=null)},d.prototype.getAABB=function(a){var b=this.to,c=this.from;f.set(a.lowerBound,Math.min(b[0],c[0]),Math.min(b[1],c[1])),f.set(a.upperBound,Math.max(b[0],c[0]),Math.max(b[1],c[1]))},f.create(),d.prototype.reportIntersection=function(a,b,c,e){var g=(this.from,this.to,this._currentShape),h=this._currentBody;if(!(this.skipBackfaces&&0<f.dot(c,this.direction)))switch(this.mode){case d.ALL:a.set(c,g,h,b,e),this.callback(a);break;case d.CLOSEST:(b<a.fraction||!a.hasHit())&&a.set(c,g,h,b,e);break;case d.ANY:a.set(c,g,h,b,e)}};var h=f.create(),i=f.create()},{"../collision/AABB":7,"../collision/RaycastResult":12,"../math/vec2":30,"../shapes/Shape":45}],12:[function(a,b,c){function d(){this.normal=e.create(),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1}var e=a("../math/vec2"),f=a("../collision/Ray");(b.exports=d).prototype.reset=function(){e.set(this.normal,0,0),this.shape=null,this.body=null,this.faceIndex=-1,this.fraction=-1,this.isStopped=!1},d.prototype.getHitDistance=function(a){return e.distance(a.from,a.to)*this.fraction},d.prototype.hasHit=function(){return-1!==this.fraction},d.prototype.getHitPoint=function(a,b){e.lerp(a,b.from,b.to,this.fraction)},d.prototype.stop=function(){this.isStopped=!0},d.prototype.shouldStop=function(a){return this.isStopped||-1!==this.fraction&&a.mode===f.ANY},d.prototype.set=function(a,b,c,d,f){e.copy(this.normal,a),this.shape=b,this.body=c,this.fraction=d,this.faceIndex=f}},{"../collision/Ray":11,"../math/vec2":30}],13:[function(a,b,c){function d(){f.call(this,f.SAP),this.axisList=[],this.axisIndex=0;var a=this;this._addBodyHandler=function(b){a.axisList.push(b.body)},this._removeBodyHandler=function(b){var c=a.axisList.indexOf(b.body);-1!==c&&a.axisList.splice(c,1)}}var e=a("../utils/Utils"),f=a("../collision/Broadphase");(((b.exports=d).prototype=new f).constructor=d).prototype.setWorld=function(a){this.axisList.length=0,e.appendArray(this.axisList,a.bodies),a.off("addBody",this._addBodyHandler).off("removeBody",this._removeBodyHandler),a.on("addBody",this._addBodyHandler).on("removeBody",this._removeBodyHandler),this.world=a},d.sortAxisList=function(a,b){b|=0;for(var c=1,d=a.length;c<d;c++){for(var e=a[c],f=c-1;0<=f&&!(a[f].aabb.lowerBound[b]<=e.aabb.lowerBound[b]);f--)a[f+1]=a[f];a[f+1]=e}return a},d.prototype.sortList=function(){var a=this.axisList,b=this.axisIndex;d.sortAxisList(a,b)},d.prototype.getCollisionPairs=function(a){var b=this.axisList,c=this.result,d=this.axisIndex;c.length=0;for(var e=b.length;e--;){var g=b[e];g.aabbNeedsUpdate&&g.updateAABB()}this.sortList();for(var h=0,i=0|b.length;h!==i;h++)for(var j=b[h],k=h+1;k<i;k++){var l=b[k];if(!(l.aabb.lowerBound[d]<=j.aabb.upperBound[d]))break;f.canCollide(j,l)&&this.boundingVolumeCheck(j,l)&&c.push(j,l)}return c},d.prototype.aabbQuery=function(a,b,c){c=c||[],this.sortList();var d=this.axisIndex,e="x";1===d&&(e="y"),2===d&&(e="z");for(var f=this.axisList,g=(b.lowerBound[e],b.upperBound[e],0);g<f.length;g++){var h=f[g];h.aabbNeedsUpdate&&h.updateAABB(),h.aabb.overlaps(b)&&c.push(h)}return c}},{"../collision/Broadphase":8,"../utils/Utils":57}],14:[function(a,b,c){function d(a,b,c,d){this.type=c,d=e.defaults(d,{collideConnected:!0,wakeUpBodies:!0}),this.equations=[],this.bodyA=a,this.bodyB=b,this.collideConnected=d.collideConnected,d.wakeUpBodies&&(a&&a.wakeUp(),b&&b.wakeUp())}b.exports=d;var e=a("../utils/Utils");d.prototype.update=function(){throw new Error("method update() not implmemented in this Constraint subclass!")},d.DISTANCE=1,d.GEAR=2,d.LOCK=3,d.PRISMATIC=4,d.REVOLUTE=5,d.prototype.setStiffness=function(a){for(var b=this.equations,c=0;c!==b.length;c++){var d=b[c];d.stiffness=a,d.needsUpdate=!0}},d.prototype.setRelaxation=function(a){for(var b=this.equations,c=0;c!==b.length;c++){var d=b[c];d.relaxation=a,d.needsUpdate=!0}}},{"../utils/Utils":57}],15:[function(a,b,c){function d(a,b,c){c=h.defaults(c,{localAnchorA:[0,0],localAnchorB:[0,0]}),e.call(this,a,b,e.DISTANCE,c),this.localAnchorA=g.fromValues(c.localAnchorA[0],c.localAnchorA[1]),this.localAnchorB=g.fromValues(c.localAnchorB[0],c.localAnchorB[1]);var m,d=this.localAnchorA,i=this.localAnchorB;if(this.distance=0,"number"==typeof c.distance)this.distance=c.distance;else{var j=g.create(),k=g.create(),l=g.create();g.rotate(j,d,a.angle),g.rotate(k,i,b.angle),g.add(l,b.position,k),g.sub(l,l,j),g.sub(l,l,a.position),this.distance=g.length(l)}m=void 0===c.maxForce?Number.MAX_VALUE:c.maxForce;var n=new f(a,b,-m,m);this.equations=[n],this.maxForce=m;l=g.create();var o=g.create(),p=g.create(),q=this;n.computeGq=function(){var a=this.bodyA,b=this.bodyB,c=a.position,e=b.position;return g.rotate(o,d,a.angle),g.rotate(p,i,b.angle),g.add(l,e,p),g.sub(l,l,o),g.sub(l,l,c),g.length(l)-q.distance},this.setMaxForce(m),this.upperLimitEnabled=!1,this.upperLimit=1,this.lowerLimitEnabled=!1,this.lowerLimit=0,this.position=0}var e=a("./Constraint"),f=a("../equations/Equation"),g=a("../math/vec2"),h=a("../utils/Utils");((b.exports=d).prototype=new e).constructor=d;var i=g.create(),j=g.create(),k=g.create();d.prototype.update=function(){var a=this.equations[0],b=this.bodyA,c=this.bodyB,d=(this.distance,b.position),e=c.position,f=this.equations[0],h=a.G;g.rotate(j,this.localAnchorA,b.angle),g.rotate(k,this.localAnchorB,c.angle),g.add(i,e,k),g.sub(i,i,j),g.sub(i,i,d),this.position=g.length(i);var l=!1;if(this.upperLimitEnabled&&this.position>this.upperLimit&&(f.maxForce=0,f.minForce=-this.maxForce,this.distance=this.upperLimit,l=!0),this.lowerLimitEnabled&&this.position<this.lowerLimit&&(f.maxForce=this.maxForce,f.minForce=0,this.distance=this.lowerLimit,l=!0),!this.lowerLimitEnabled&&!this.upperLimitEnabled||l){f.enabled=!0,g.normalize(i,i);var m=g.crossLength(j,i),n=g.crossLength(k,i);h[0]=-i[0],h[1]=-i[1],h[2]=-m,h[3]=i[0],h[4]=i[1],h[5]=n}else f.enabled=!1},d.prototype.setMaxForce=function(a){var b=this.equations[0];b.minForce=-a,b.maxForce=a},d.prototype.getMaxForce=function(){return this.equations[0].maxForce}},{"../equations/Equation":22,"../math/vec2":30,"../utils/Utils":57,"./Constraint":14}],16:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.GEAR,c),this.ratio=void 0!==c.ratio?c.ratio:1,this.angle=void 0!==c.angle?c.angle:b.angle-this.ratio*a.angle,c.angle=this.angle,c.ratio=this.ratio,this.equations=[new f(a,b,c)],void 0!==c.maxTorque&&this.setMaxTorque(c.maxTorque)}var e=a("./Constraint"),f=(a("../equations/Equation"),a("../equations/AngleLockEquation"));a("../math/vec2"),(((b.exports=d).prototype=new e).constructor=d).prototype.update=function(){var a=this.equations[0];a.ratio!==this.ratio&&a.setRatio(this.ratio),a.angle=this.angle},d.prototype.setMaxTorque=function(a){this.equations[0].setMaxTorque(a)},d.prototype.getMaxTorque=function(a){return this.equations[0].maxForce}},{"../equations/AngleLockEquation":20,"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],17:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.LOCK,c);var d=void 0===c.maxForce?Number.MAX_VALUE:c.maxForce,h=(c.localAngleB,new g(a,b,-d,d)),i=new g(a,b,-d,d),j=new g(a,b,-d,d),k=f.create(),l=f.create(),m=this;h.computeGq=function(){return f.rotate(k,m.localOffsetB,a.angle),f.sub(l,b.position,a.position),f.sub(l,l,k),l[0]},i.computeGq=function(){return f.rotate(k,m.localOffsetB,a.angle),f.sub(l,b.position,a.position),f.sub(l,l,k),l[1]};var n=f.create(),o=f.create();j.computeGq=function(){return f.rotate(n,m.localOffsetB,b.angle-m.localAngleB),f.scale(n,n,-1),f.sub(l,a.position,b.position),f.add(l,l,n),f.rotate(o,n,-Math.PI/2),f.normalize(o,o),f.dot(l,o)},this.localOffsetB=f.create(),c.localOffsetB?f.copy(this.localOffsetB,c.localOffsetB):(f.sub(this.localOffsetB,b.position,a.position),f.rotate(this.localOffsetB,this.localOffsetB,-a.angle)),this.localAngleB=0,"number"==typeof c.localAngleB?this.localAngleB=c.localAngleB:this.localAngleB=b.angle-a.angle,this.equations.push(h,i,j),this.setMaxForce(d)}var e=a("./Constraint"),f=a("../math/vec2"),g=a("../equations/Equation");(((b.exports=d).prototype=new e).constructor=d).prototype.setMaxForce=function(a){for(var b=this.equations,c=0;c<this.equations.length;c++)b[c].maxForce=a,b[c].minForce=-a},d.prototype.getMaxForce=function(){return this.equations[0].maxForce};var h=f.create(),i=f.create(),j=f.create(),k=f.fromValues(1,0),l=f.fromValues(0,1);d.prototype.update=function(){var a=this.equations[0],b=this.equations[1],c=this.equations[2],d=this.bodyA,e=this.bodyB;f.rotate(h,this.localOffsetB,d.angle),f.rotate(i,this.localOffsetB,e.angle-this.localAngleB),f.scale(i,i,-1),f.rotate(j,i,Math.PI/2),f.normalize(j,j),a.G[0]=-1,a.G[1]=0,a.G[2]=-f.crossLength(h,k),a.G[3]=1,b.G[0]=0,b.G[1]=-1,b.G[2]=-f.crossLength(h,l),b.G[4]=1,c.G[0]=-j[0],c.G[1]=-j[1],c.G[3]=j[0],c.G[4]=j[1],c.G[5]=f.crossLength(i,j)}},{"../equations/Equation":22,"../math/vec2":30,"./Constraint":14}],18:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.PRISMATIC,c);var d=h.fromValues(0,0),j=h.fromValues(1,0),k=h.fromValues(0,0);c.localAnchorA&&h.copy(d,c.localAnchorA),c.localAxisA&&h.copy(j,c.localAxisA),c.localAnchorB&&h.copy(k,c.localAnchorB),this.localAnchorA=d,this.localAnchorB=k,this.localAxisA=j;var l=this.maxForce=void 0!==c.maxForce?c.maxForce:Number.MAX_VALUE,m=new g(a,b,-l,l),n=new h.create,o=new h.create,p=new h.create,q=new h.create;if(m.computeGq=function(){return h.dot(p,q)},m.updateJacobian=function(){var c=this.G,e=a.position,f=b.position;h.rotate(n,d,a.angle),h.rotate(o,k,b.angle),h.add(p,f,o),h.sub(p,p,e),h.sub(p,p,n),h.rotate(q,j,a.angle+Math.PI/2),c[0]=-q[0],c[1]=-q[1],c[2]=-h.crossLength(n,q)+h.crossLength(q,p),c[3]=q[0],c[4]=q[1],c[5]=h.crossLength(o,q)},this.equations.push(m),!c.disableRotationalLock){var r=new i(a,b,-l,l);this.equations.push(r)}this.position=0,this.velocity=0,this.lowerLimitEnabled=void 0!==c.lowerLimit,this.upperLimitEnabled=void 0!==c.upperLimit,this.lowerLimit=void 0!==c.lowerLimit?c.lowerLimit:0,this.upperLimit=void 0!==c.upperLimit?c.upperLimit:1,this.upperLimitEquation=new f(a,b),this.lowerLimitEquation=new f(a,b),this.upperLimitEquation.minForce=this.lowerLimitEquation.minForce=0,this.upperLimitEquation.maxForce=this.lowerLimitEquation.maxForce=l,this.motorEquation=new g(a,b),this.motorEnabled=!1,this.motorSpeed=0;var s=this,t=this.motorEquation;t.computeGW,t.computeGq=function(){return 0},t.computeGW=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.velocity,e=c.velocity,f=b.angularVelocity,g=c.angularVelocity;return this.gmult(a,d,f,e,g)+s.motorSpeed}}var e=a("./Constraint"),f=a("../equations/ContactEquation"),g=a("../equations/Equation"),h=a("../math/vec2"),i=a("../equations/RotationalLockEquation");((b.exports=d).prototype=new e).constructor=d;var j=h.create(),k=h.create(),l=h.create(),m=h.create(),n=h.create(),o=h.create();d.prototype.update=function(){var a=this.equations,b=a[0],c=this.upperLimit,d=this.lowerLimit,e=this.upperLimitEquation,f=this.lowerLimitEquation,g=this.bodyA,i=this.bodyB,p=this.localAxisA,q=this.localAnchorA,r=this.localAnchorB;b.updateJacobian(),h.rotate(j,p,g.angle),h.rotate(m,q,g.angle),h.add(k,m,g.position),h.rotate(n,r,i.angle),h.add(l,n,i.position);var u,s=this.position=h.dot(l,j)-h.dot(k,j);if(this.motorEnabled){var t=this.motorEquation.G;t[0]=j[0],t[1]=j[1],t[2]=h.crossLength(j,n),t[3]=-j[0],t[4]=-j[1],t[5]=-h.crossLength(j,m)}this.upperLimitEnabled&&c<s?(h.scale(e.normalA,j,-1),h.sub(e.contactPointA,k,g.position),h.sub(e.contactPointB,l,i.position),h.scale(o,j,c),h.add(e.contactPointA,e.contactPointA,o),-1===a.indexOf(e)&&a.push(e)):-1!==(u=a.indexOf(e))&&a.splice(u,1);this.lowerLimitEnabled&&s<d?(h.scale(f.normalA,j,1),h.sub(f.contactPointA,k,g.position),h.sub(f.contactPointB,l,i.position),h.scale(o,j,d),h.sub(f.contactPointB,f.contactPointB,o),-1===a.indexOf(f)&&a.push(f)):-1!==(u=a.indexOf(f))&&a.splice(u,1)},d.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},d.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},d.prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)}},{"../equations/ContactEquation":21,"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../math/vec2":30,"./Constraint":14}],19:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,e.REVOLUTE,c);var d=this.maxForce=void 0!==c.maxForce?c.maxForce:Number.MAX_VALUE;this.pivotA=i.create(),this.pivotB=i.create(),c.worldPivot?(i.sub(this.pivotA,c.worldPivot,a.position),i.sub(this.pivotB,c.worldPivot,b.position),i.rotate(this.pivotA,this.pivotA,-a.angle),i.rotate(this.pivotB,this.pivotB,-b.angle)):(i.copy(this.pivotA,c.localPivotA),i.copy(this.pivotB,c.localPivotB));var o=this.equations=[new f(a,b,-d,d),new f(a,b,-d,d)],p=o[0],q=o[1],r=this;p.computeGq=function(){return i.rotate(j,r.pivotA,a.angle),i.rotate(k,r.pivotB,b.angle),i.add(n,b.position,k),i.sub(n,n,a.position),i.sub(n,n,j),i.dot(n,l)},q.computeGq=function(){return i.rotate(j,r.pivotA,a.angle),i.rotate(k,r.pivotB,b.angle),i.add(n,b.position,k),i.sub(n,n,a.position),i.sub(n,n,j),i.dot(n,m)},q.minForce=p.minForce=-d,q.maxForce=p.maxForce=d,this.motorEquation=new g(a,b),this.motorEnabled=!1,this.angle=0,this.lowerLimitEnabled=!1,this.upperLimitEnabled=!1,this.lowerLimit=0,this.upperLimit=0,this.upperLimitEquation=new h(a,b),this.lowerLimitEquation=new h(a,b),this.upperLimitEquation.minForce=0,this.lowerLimitEquation.maxForce=0}var e=a("./Constraint"),f=a("../equations/Equation"),g=a("../equations/RotationalVelocityEquation"),h=a("../equations/RotationalLockEquation"),i=a("../math/vec2");b.exports=d;var j=i.create(),k=i.create(),l=i.fromValues(1,0),m=i.fromValues(0,1),n=i.create();((d.prototype=new e).constructor=d).prototype.setLimits=function(a,b){"number"==typeof a?(this.lowerLimit=a,this.lowerLimitEnabled=!0):(this.lowerLimit=a,this.lowerLimitEnabled=!1),"number"==typeof b?(this.upperLimit=b,this.upperLimitEnabled=!0):(this.upperLimit=b,this.upperLimitEnabled=!1)},d.prototype.update=function(){var r,a=this.bodyA,b=this.bodyB,c=this.pivotA,d=this.pivotB,e=this.equations,f=(e[0],e[1],e[0]),g=e[1],h=this.upperLimit,n=this.lowerLimit,o=this.upperLimitEquation,p=this.lowerLimitEquation,q=this.angle=b.angle-a.angle;this.upperLimitEnabled&&h<q?(o.angle=h,-1===e.indexOf(o)&&e.push(o)):-1!==(r=e.indexOf(o))&&e.splice(r,1);this.lowerLimitEnabled&&q<n?(p.angle=n,-1===e.indexOf(p)&&e.push(p)):-1!==(r=e.indexOf(p))&&e.splice(r,1);i.rotate(j,c,a.angle),i.rotate(k,d,b.angle),f.G[0]=-1,f.G[1]=0,f.G[2]=-i.crossLength(j,l),f.G[3]=1,f.G[4]=0,f.G[5]=i.crossLength(k,l),g.G[0]=0,g.G[1]=-1,g.G[2]=-i.crossLength(j,m),g.G[3]=0,g.G[4]=1,g.G[5]=i.crossLength(k,m)},d.prototype.enableMotor=function(){this.motorEnabled||(this.equations.push(this.motorEquation),this.motorEnabled=!0)},d.prototype.disableMotor=function(){if(this.motorEnabled){var a=this.equations.indexOf(this.motorEquation);this.equations.splice(a,1),this.motorEnabled=!1}},d.prototype.motorIsEnabled=function(){return!!this.motorEnabled},d.prototype.setMotorSpeed=function(a){if(this.motorEnabled){var b=this.equations.indexOf(this.motorEquation);this.equations[b].relativeVelocity=a}},d.prototype.getMotorSpeed=function(){return!!this.motorEnabled&&this.motorEquation.relativeVelocity}},{"../equations/Equation":22,"../equations/RotationalLockEquation":24,"../equations/RotationalVelocityEquation":25,"../math/vec2":30,"./Constraint":14}],20:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0,this.ratio="number"==typeof c.ratio?c.ratio:1,this.setRatio(this.ratio)}var e=a("./Equation");a("../math/vec2"),(((b.exports=d).prototype=new e).constructor=d).prototype.computeGq=function(){return this.ratio*this.bodyA.angle-this.bodyB.angle+this.angle},d.prototype.setRatio=function(a){var b=this.G;b[2]=a,b[5]=-1,this.ratio=a},d.prototype.setMaxTorque=function(a){this.maxForce=a,this.minForce=-a}},{"../math/vec2":30,"./Equation":22}],21:[function(a,b,c){function d(a,b){e.call(this,a,b,0,Number.MAX_VALUE),this.contactPointA=f.create(),this.penetrationVec=f.create(),this.contactPointB=f.create(),this.normalA=f.create(),this.restitution=0,this.firstImpact=!1,this.shapeA=null,this.shapeB=null}var e=a("./Equation"),f=a("../math/vec2");(((b.exports=d).prototype=new e).constructor=d).prototype.computeB=function(a,b,c){var p,q,d=this.bodyA,e=this.bodyB,g=this.contactPointA,h=this.contactPointB,i=d.position,j=e.position,k=this.penetrationVec,l=this.normalA,m=this.G,n=f.crossLength(g,l),o=f.crossLength(h,l);return m[0]=-l[0],m[1]=-l[1],m[2]=-n,m[3]=l[0],m[4]=l[1],m[5]=o,f.add(k,j,h),f.sub(k,k,i),f.sub(k,k,g),p=this.firstImpact&&0!==this.restitution?(q=0,1/b*(1+this.restitution)*this.computeGW()):(q=f.dot(l,k)+this.offset,this.computeGW()),-q*a-p*b-c*this.computeGiMf()}},{"../math/vec2":30,"./Equation":22}],22:[function(a,b,c){function d(a,b,c,e){this.minForce=void 0===c?-Number.MAX_VALUE:c,this.maxForce=void 0===e?Number.MAX_VALUE:e,this.bodyA=a,this.bodyB=b,this.stiffness=d.DEFAULT_STIFFNESS,this.relaxation=d.DEFAULT_RELAXATION,this.G=new f.ARRAY_TYPE(6);for(var g=0;g<6;g++)this.G[g]=0;this.offset=0,this.a=0,this.b=0,this.epsilon=0,this.timeStep=1/60,this.needsUpdate=!0,this.multiplier=0,this.relativeVelocity=0,this.enabled=!0}b.exports=d;var e=a("../math/vec2"),f=a("../utils/Utils");a("../objects/Body"),(d.prototype.constructor=d).DEFAULT_STIFFNESS=1e6,d.DEFAULT_RELAXATION=4,d.prototype.update=function(){var a=this.stiffness,b=this.relaxation,c=this.timeStep;this.a=4/(c*(1+4*b)),this.b=4*b/(1+4*b),this.epsilon=4/(c*c*a*(1+4*b)),this.needsUpdate=!1},d.prototype.gmult=function(a,b,c,d,e){return a[0]*b[0]+a[1]*b[1]+a[2]*c+a[3]*d[0]+a[4]*d[1]+a[5]*e},d.prototype.computeB=function(a,b,c){var d=this.computeGW();return-this.computeGq()*a-d*b-this.computeGiMf()*c};var g=e.create(),h=e.create();d.prototype.computeGq=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=(b.position,c.position,b.angle),e=c.angle;return this.gmult(a,g,d,h,e)+this.offset},d.prototype.computeGW=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.velocity,e=c.velocity,f=b.angularVelocity,g=c.angularVelocity;return this.gmult(a,d,f,e,g)+this.relativeVelocity},d.prototype.computeGWlambda=function(){var a=this.G,b=this.bodyA,c=this.bodyB,d=b.vlambda,e=c.vlambda,f=b.wlambda,g=c.wlambda;return this.gmult(a,d,f,e,g)};var i=e.create(),j=e.create();d.prototype.computeGiMf=function(){var a=this.bodyA,b=this.bodyB,c=a.force,d=a.angularForce,f=b.force,g=b.angularForce,h=a.invMassSolve,k=b.invMassSolve,l=a.invInertiaSolve,m=b.invInertiaSolve,n=this.G;return e.scale(i,c,h),e.multiply(i,a.massMultiplier,i),e.scale(j,f,k),e.multiply(j,b.massMultiplier,j),this.gmult(n,i,d*l,j,g*m)},d.prototype.computeGiMGt=function(){var a=this.bodyA,b=this.bodyB,c=a.invMassSolve,d=b.invMassSolve,e=a.invInertiaSolve,f=b.invInertiaSolve,g=this.G;return g[0]*g[0]*c*a.massMultiplier[0]+g[1]*g[1]*c*a.massMultiplier[1]+g[2]*g[2]*e+g[3]*g[3]*d*b.massMultiplier[0]+g[4]*g[4]*d*b.massMultiplier[1]+g[5]*g[5]*f};var k=e.create(),l=e.create(),m=e.create();e.create(),e.create(),e.create(),d.prototype.addToWlambda=function(a){var b=this.bodyA,c=this.bodyB,d=k,f=l,g=m,h=b.invMassSolve,i=c.invMassSolve,j=b.invInertiaSolve,n=c.invInertiaSolve,o=this.G;f[0]=o[0],f[1]=o[1],g[0]=o[3],g[1]=o[4],e.scale(d,f,h*a),e.multiply(d,d,b.massMultiplier),e.add(b.vlambda,b.vlambda,d),b.wlambda+=j*o[2]*a,e.scale(d,g,i*a),e.multiply(d,d,c.massMultiplier),e.add(c.vlambda,c.vlambda,d),c.wlambda+=n*o[5]*a},d.prototype.computeInvC=function(a){return 1/(this.computeGiMGt()+a)}},{"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],23:[function(a,b,c){function d(a,b,c){f.call(this,a,b,-c,c),this.contactPointA=e.create(),this.contactPointB=e.create(),this.t=e.create(),this.contactEquations=[],this.shapeA=null,this.shapeB=null,this.frictionCoefficient=.3}var e=a("../math/vec2"),f=a("./Equation");a("../utils/Utils"),(((b.exports=d).prototype=new f).constructor=d).prototype.setSlipForce=function(a){this.maxForce=a,this.minForce=-a},d.prototype.getSlipForce=function(){return this.maxForce},d.prototype.computeB=function(a,b,c){var d=(this.bodyA,this.bodyB,this.contactPointA),f=this.contactPointB,g=this.t,h=this.G;return h[0]=-g[0],h[1]=-g[1],h[2]=-e.crossLength(d,g),h[3]=g[0],h[4]=g[1],h[5]=e.crossLength(f,g),-this.computeGW()*b-c*this.computeGiMf()}},{"../math/vec2":30,"../utils/Utils":57,"./Equation":22}],24:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.angle=c.angle||0;var d=this.G;d[2]=1,d[5]=-1}var e=a("./Equation"),f=a("../math/vec2");((b.exports=d).prototype=new e).constructor=d;var g=f.create(),h=f.create(),i=f.fromValues(1,0),j=f.fromValues(0,1);d.prototype.computeGq=function(){return f.rotate(g,i,this.bodyA.angle+this.angle),f.rotate(h,j,this.bodyB.angle),f.dot(g,h)}},{"../math/vec2":30,"./Equation":22}],25:[function(a,b,c){function d(a,b){e.call(this,a,b,-Number.MAX_VALUE,Number.MAX_VALUE),this.relativeVelocity=1,this.ratio=1}var e=a("./Equation");a("../math/vec2"),(((b.exports=d).prototype=new e).constructor=d).prototype.computeB=function(a,b,c){var d=this.G;d[2]=-1,d[5]=this.ratio;var e=this.computeGiMf();return-this.computeGW()*b-c*e}},{"../math/vec2":30,"./Equation":22}],26:[function(a,b,c){var d=function(){};(b.exports=d).prototype={constructor:d,on:function(a,b,c){b.context=c||this,void 0===this._listeners&&(this._listeners={});var d=this._listeners;return void 0===d[a]&&(d[a]=[]),-1===d[a].indexOf(b)&&d[a].push(b),this},has:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;if(b){if(void 0!==c[a]&&-1!==c[a].indexOf(b))return!0}else if(void 0!==c[a])return!0;return!1},off:function(a,b){if(void 0===this._listeners)return this;var c=this._listeners,d=c[a].indexOf(b);return-1!==d&&c[a].splice(d,1),this},emit:function(a){if(void 0===this._listeners)return this;var c=this._listeners[a.type];if(void 0!==c){a.target=this;for(var d=0,e=c.length;d<e;d++){var f=c[d];f.call(f.context,a)}}return this}}},{}],27:[function(a,b,c){function d(a,b,c){if(c=c||{},!(a instanceof e&&b instanceof e))throw new Error("First two arguments must be Material instances.");this.id=d.idCounter++,this.materialA=a,this.materialB=b,this.friction=void 0!==c.friction?Number(c.friction):.3,this.restitution=void 0!==c.restitution?Number(c.restitution):0,this.stiffness=void 0!==c.stiffness?Number(c.stiffness):f.DEFAULT_STIFFNESS,this.relaxation=void 0!==c.relaxation?Number(c.relaxation):f.DEFAULT_RELAXATION,this.frictionStiffness=void 0!==c.frictionStiffness?Number(c.frictionStiffness):f.DEFAULT_STIFFNESS,this.frictionRelaxation=void 0!==c.frictionRelaxation?Number(c.frictionRelaxation):f.DEFAULT_RELAXATION,this.surfaceVelocity=void 0!==c.surfaceVelocity?Number(c.surfaceVelocity):0,this.contactSkinSize=.005}var e=a("./Material"),f=a("../equations/Equation");(b.exports=d).idCounter=0},{"../equations/Equation":22,"./Material":28}],28:[function(a,b,c){function d(a){this.id=a||d.idCounter++}(b.exports=d).idCounter=0},{}],29:[function(a,b,c){var d={GetArea:function(a){if(a.length<6)return 0;for(var b=a.length-2,c=0,d=0;d<b;d+=2)c+=(a[d+2]-a[d])*(a[d+1]+a[d+3]);return.5*-(c+=(a[0]-a[b])*(a[b+1]+a[1]))},Triangulate:function(a){var b=a.length>>1;if(b<3)return[];for(var c=[],e=[],f=0;f<b;f++)e.push(f);f=0;for(var g=b;3<g;){var h=e[(f+0)%g],i=e[(f+1)%g],j=e[(f+2)%g],k=a[2*h],l=a[2*h+1],m=a[2*i],n=a[2*i+1],o=a[2*j],p=a[2*j+1],q=!1;if(d._convex(k,l,m,n,o,p)){q=!0;for(var r=0;r<g;r++){var s=e[r];if(s!=h&&s!=i&&s!=j&&d._PointInTriangle(a[2*s],a[2*s+1],k,l,m,n,o,p)){q=!1;break}}}if(q)c.push(h,i,j),e.splice((f+1)%g,1),g--,f=0;else if(f++>3*g)break}return c.push(e[0],e[1],e[2]),c},_PointInTriangle:function(a,b,c,d,e,f,g,h){var i=g-c,j=h-d,k=e-c,l=f-d,m=a-c,n=b-d,o=i*i+j*j,p=i*k+j*l,q=i*m+j*n,r=k*k+l*l,s=k*m+l*n,t=1/(o*r-p*p),u=(r*q-p*s)*t,v=(o*s-p*q)*t;return 0<=u&&0<=v&&u+v<1},_convex:function(a,b,c,d,e,f){return 0<=(b-d)*(e-c)+(c-a)*(f-d)}};b.exports=d},{}],30:[function(a,b,c){var d=b.exports={},e=a("../utils/Utils");d.crossLength=function(a,b){return a[0]*b[1]-a[1]*b[0]},d.crossVZ=function(a,b,c){return d.rotate(a,b,-Math.PI/2),d.scale(a,a,c),a},d.crossZV=function(a,b,c){return d.rotate(a,c,Math.PI/2),d.scale(a,a,b),a},d.rotate=function(a,b,c){if(0!==c){var d=Math.cos(c),e=Math.sin(c),f=b[0],g=b[1];a[0]=d*f-e*g,a[1]=e*f+d*g}else a[0]=b[0],a[1]=b[1]},d.rotate90cw=function(a,b){var c=b[0],d=b[1];a[0]=d,a[1]=-c},d.toLocalFrame=function(a,b,c,e){d.copy(a,b),d.sub(a,a,c),d.rotate(a,a,-e)},d.toGlobalFrame=function(a,b,c,e){d.copy(a,b),d.rotate(a,a,e),d.add(a,a,c)},d.vectorToLocalFrame=function(a,b,c){d.rotate(a,b,-c)},d.vectorToGlobalFrame=function(a,b,c){d.rotate(a,b,c)},d.centroid=function(a,b,c,e){return d.add(a,b,c),d.add(a,a,e),d.scale(a,a,1/3),a},d.create=function(){var a=new e.ARRAY_TYPE(2);return a[0]=0,a[1]=0,a},d.clone=function(a){var b=new e.ARRAY_TYPE(2);return b[0]=a[0],b[1]=a[1],b},d.fromValues=function(a,b){var c=new e.ARRAY_TYPE(2);return c[0]=a,c[1]=b,c},d.copy=function(a,b){return a[0]=b[0],a[1]=b[1],a},d.set=function(a,b,c){return a[0]=b,a[1]=c,a},d.add=function(a,b,c){return a[0]=b[0]+c[0],a[1]=b[1]+c[1],a},d.subtract=function(a,b,c){return a[0]=b[0]-c[0],a[1]=b[1]-c[1],a},d.sub=d.subtract,d.multiply=function(a,b,c){return a[0]=b[0]*c[0],a[1]=b[1]*c[1],a},d.mul=d.multiply,d.divide=function(a,b,c){return a[0]=b[0]/c[0],a[1]=b[1]/c[1],a},d.div=d.divide,d.scale=function(a,b,c){return a[0]=b[0]*c,a[1]=b[1]*c,a},d.distance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return Math.sqrt(c*c+d*d)},d.dist=d.distance,d.squaredDistance=function(a,b){var c=b[0]-a[0],d=b[1]-a[1];return c*c+d*d},d.sqrDist=d.squaredDistance,d.length=function(a){var b=a[0],c=a[1];return Math.sqrt(b*b+c*c)},d.len=d.length,d.squaredLength=function(a){var b=a[0],c=a[1];return b*b+c*c},d.sqrLen=d.squaredLength,d.negate=function(a,b){return a[0]=-b[0],a[1]=-b[1],a},d.normalize=function(a,b){var c=b[0],d=b[1],e=c*c+d*d;return 0<e&&(e=1/Math.sqrt(e),a[0]=b[0]*e,a[1]=b[1]*e),a},d.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]},d.str=function(a){return"vec2("+a[0]+", "+a[1]+")"},d.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},d.reflect=function(a,b,c){var d=b[0]*c[0]+b[1]*c[1];a[0]=b[0]-2*c[0]*d,a[1]=b[1]-2*c[1]*d},d.getLineSegmentsIntersection=function(a,b,c,e,f){var g=d.getLineSegmentsIntersectionFraction(b,c,e,f);return!(g<0||(a[0]=b[0]+g*(c[0]-b[0]),a[1]=b[1]+g*(c[1]-b[1]),0))},d.getLineSegmentsIntersectionFraction=function(a,b,c,d){var e,f,g=b[0]-a[0],h=b[1]-a[1],i=d[0]-c[0],j=d[1]-c[1];return e=(-h*(a[0]-c[0])+g*(a[1]-c[1]))/(-i*h+g*j),f=(i*(a[1]-c[1])-j*(a[0]-c[0]))/(-i*h+g*j),0<=e&&e<=1&&0<=f&&f<=1?f:-1}},{"../utils/Utils":57}],31:[function(a,b,c){function d(a){a=a||{},k.call(this),this.id=a.id||++d._idCounter,this.world=null,this.shapes=[],this.mass=a.mass||0,this.invMass=0,this.inertia=0,this.invInertia=0,this.invMassSolve=0,this.invInertiaSolve=0,this.fixedRotation=!!a.fixedRotation,this.fixedX=!!a.fixedX,this.fixedY=!!a.fixedY,this.massMultiplier=e.create(),this.position=e.fromValues(0,0),a.position&&e.copy(this.position,a.position),this.interpolatedPosition=e.fromValues(0,0),this.interpolatedAngle=0,this.previousPosition=e.fromValues(0,0),this.previousAngle=0,this.velocity=e.fromValues(0,0),a.velocity&&e.copy(this.velocity,a.velocity),this.vlambda=e.fromValues(0,0),this.wlambda=0,this.angle=a.angle||0,this.angularVelocity=a.angularVelocity||0,this.force=e.create(),a.force&&e.copy(this.force,a.force),this.angularForce=a.angularForce||0,this.damping="number"==typeof a.damping?a.damping:.1,this.angularDamping="number"==typeof a.angularDamping?a.angularDamping:.1,this.type=d.STATIC,void 0!==a.type?this.type=a.type:a.mass?this.type=d.DYNAMIC:this.type=d.STATIC,this.boundingRadius=0,this.aabb=new j,this.aabbNeedsUpdate=!0,this.allowSleep=void 0===a.allowSleep||a.allowSleep,this.wantsToSleep=!1,this.sleepState=d.AWAKE,this.sleepSpeedLimit=void 0!==a.sleepSpeedLimit?a.sleepSpeedLimit:.2,this.sleepTimeLimit=void 0!==a.sleepTimeLimit?a.sleepTimeLimit:1,this.gravityScale=void 0!==a.gravityScale?a.gravityScale:1,this.collisionResponse=void 0===a.collisionResponse||a.collisionResponse,this.idleTime=0,this.timeLastSleepy=0,this.ccdSpeedThreshold=void 0!==a.ccdSpeedThreshold?a.ccdSpeedThreshold:-1,this.ccdIterations=void 0!==a.ccdIterations?a.ccdIterations:10,this.concavePath=null,this._wakeUpAfterNarrowphase=!1,this.updateMassProperties()}var e=a("../math/vec2"),f=a("poly-decomp"),g=a("../shapes/Convex"),h=a("../collision/RaycastResult"),i=a("../collision/Ray"),j=a("../collision/AABB"),k=a("../events/EventEmitter");(((b.exports=d).prototype=new k).constructor=d)._idCounter=0,d.prototype.updateSolveMassProperties=function(){this.sleepState===d.SLEEPING||this.type===d.KINEMATIC?(this.invMassSolve=0,this.invInertiaSolve=0):(this.invMassSolve=this.invMass,this.invInertiaSolve=this.invInertia)},d.prototype.setDensity=function(a){var b=this.getArea();this.mass=b*a,this.updateMassProperties()},d.prototype.getArea=function(){for(var a=0,b=0;b<this.shapes.length;b++)a+=this.shapes[b].area;return a},d.prototype.getAABB=function(){return this.aabbNeedsUpdate&&this.updateAABB(),this.aabb};var l=new j,m=e.create();d.prototype.updateAABB=function(){for(var a=this.shapes,b=a.length,c=m,d=this.angle,f=0;f!==b;f++){var g=a[f],h=g.angle+d;e.rotate(c,g.position,d),e.add(c,c,this.position),g.computeAABB(l,c,h),0===f?this.aabb.copy(l):this.aabb.extend(l)}this.aabbNeedsUpdate=!1},d.prototype.updateBoundingRadius=function(){for(var a=this.shapes,b=a.length,c=0,d=0;d!==b;d++){var f=a[d],g=e.length(f.position),h=f.boundingRadius;c<g+h&&(c=g+h)}this.boundingRadius=c},d.prototype.addShape=function(a,b,c){if(a.body)throw new Error("A shape can only be added to one body.");a.body=this,b?e.copy(a.position,b):e.set(a.position,0,0),a.angle=c||0,this.shapes.push(a),this.updateMassProperties(),this.updateBoundingRadius(),this.aabbNeedsUpdate=!0},d.prototype.removeShape=function(a){var b=this.shapes.indexOf(a);return-1!==b&&(this.shapes.splice(b,1),this.aabbNeedsUpdate=!0,!(a.body=null))},d.prototype.updateMassProperties=function(){if(this.type===d.STATIC||this.type===d.KINEMATIC)this.mass=Number.MAX_VALUE,this.invMass=0,this.inertia=Number.MAX_VALUE,this.invInertia=0;else{var a=this.shapes,b=a.length,c=this.mass/b,f=0;if(this.fixedRotation)this.inertia=Number.MAX_VALUE,this.invInertia=0;else{for(var g=0;g<b;g++){var h=a[g],i=e.squaredLength(h.position);f+=h.computeMomentOfInertia(c)+c*i}this.inertia=f,this.invInertia=0<f?1/f:0}this.invMass=1/this.mass,e.set(this.massMultiplier,this.fixedX?0:1,this.fixedY?0:1)}},e.create(),d.prototype.applyForce=function(a,b){if(e.add(this.force,this.force,a),b){var c=e.crossLength(b,a);this.angularForce+=c}};var n=e.create(),o=e.create(),p=e.create();d.prototype.applyForceLocal=function(a,b){b=b||p;var c=n,d=o;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyForce(c,d)};var q=e.create();d.prototype.applyImpulse=function(a,b){if(this.type===d.DYNAMIC){var c=q;if(e.scale(c,a,this.invMass),e.multiply(c,this.massMultiplier,c),e.add(this.velocity,c,this.velocity),b){var f=e.crossLength(b,a);f*=this.invInertia,this.angularVelocity+=f}}};var r=e.create(),s=e.create(),t=e.create();d.prototype.applyImpulseLocal=function(a,b){b=b||t;var c=r,d=s;this.vectorToWorldFrame(c,a),this.vectorToWorldFrame(d,b),this.applyImpulse(c,d)},d.prototype.toLocalFrame=function(a,b){e.toLocalFrame(a,b,this.position,this.angle)},d.prototype.toWorldFrame=function(a,b){e.toGlobalFrame(a,b,this.position,this.angle)},d.prototype.vectorToLocalFrame=function(a,b){e.vectorToLocalFrame(a,b,this.angle)},d.prototype.vectorToWorldFrame=function(a,b){e.vectorToGlobalFrame(a,b,this.angle)},d.prototype.fromPolygon=function(a,b){b=b||{};for(var c=this.shapes.length;0<=c;--c)this.removeShape(this.shapes[c]);var i,d=new f.Polygon;if(d.vertices=a,d.makeCCW(),"number"==typeof b.removeCollinearPoints&&d.removeCollinearPoints(b.removeCollinearPoints),void 0===b.skipSimpleCheck&&!d.isSimple())return!1;this.concavePath=d.vertices.slice(0);for(c=0;c<this.concavePath.length;c++){var h=[0,0];e.copy(h,this.concavePath[c]),this.concavePath[c]=h}i=b.optimalDecomp?d.decomp():d.quickDecomp();var j=e.create();for(c=0;c!==i.length;c++){for(var k=new g({vertices:i[c].vertices}),l=0;l!==k.vertices.length;l++){h=k.vertices[l];e.sub(h,h,k.centerOfMass)}e.scale(j,k.centerOfMass,1),k.updateTriangles(),k.updateCenterOfMass(),k.updateBoundingRadius(),this.addShape(k,j)}return this.adjustCenterOfMass(),this.aabbNeedsUpdate=!0};var u=(e.fromValues(0,0),e.fromValues(0,0)),v=e.fromValues(0,0),w=e.fromValues(0,0);d.prototype.adjustCenterOfMass=function(){var a=u,b=v,c=w,d=0;e.set(b,0,0);for(var f=0;f!==this.shapes.length;f++){var g=this.shapes[f];e.scale(a,g.position,g.area),e.add(b,b,a),d+=g.area}e.scale(c,b,1/d);for(f=0;f!==this.shapes.length;f++){g=this.shapes[f];e.sub(g.position,g.position,c)}e.add(this.position,this.position,c);for(f=0;this.concavePath&&f<this.concavePath.length;f++)e.sub(this.concavePath[f],this.concavePath[f],c);this.updateMassProperties(),this.updateBoundingRadius()},d.prototype.setZeroForce=function(){e.set(this.force,0,0),this.angularForce=0},d.prototype.resetConstraintVelocity=function(){var b=this.vlambda;e.set(b,0,0),this.wlambda=0},d.prototype.addConstraintVelocity=function(){var a=this,b=a.velocity;e.add(b,b,a.vlambda),a.angularVelocity+=a.wlambda},d.prototype.applyDamping=function(a){if(this.type===d.DYNAMIC){var b=this.velocity;e.scale(b,b,Math.pow(1-this.damping,a)),this.angularVelocity*=Math.pow(1-this.angularDamping,a)}},d.prototype.wakeUp=function(){var a=this.sleepState;this.sleepState=d.AWAKE,this.idleTime=0,a!==d.AWAKE&&this.emit(d.wakeUpEvent)},d.prototype.sleep=function(){this.sleepState=d.SLEEPING,this.angularVelocity=0,this.angularForce=0,e.set(this.velocity,0,0),e.set(this.force,0,0),this.emit(d.sleepEvent)},d.prototype.sleepTick=function(a,b,c){this.allowSleep&&this.type!==d.SLEEPING&&(this.wantsToSleep=!1,this.sleepState,e.squaredLength(this.velocity)+Math.pow(this.angularVelocity,2)>=Math.pow(this.sleepSpeedLimit,2)?(this.idleTime=0,this.sleepState=d.AWAKE):(this.idleTime+=c,this.sleepState=d.SLEEPY),this.idleTime>this.sleepTimeLimit&&(b?this.wantsToSleep=!0:this.sleep()))},d.prototype.overlaps=function(a){return this.world.overlapKeeper.bodiesAreOverlapping(this,a)};var x=e.create(),y=e.create();d.prototype.integrate=function(a){var b=this.invMass,c=this.force,d=this.position,f=this.velocity;e.copy(this.previousPosition,this.position),this.previousAngle=this.angle,this.fixedRotation||(this.angularVelocity+=this.angularForce*this.invInertia*a),e.scale(x,c,a*b),e.multiply(x,this.massMultiplier,x),e.add(f,x,f),this.integrateToTimeOfImpact(a)||(e.scale(y,f,a),e.add(d,d,y),this.fixedRotation||(this.angle+=this.angularVelocity*a)),this.aabbNeedsUpdate=!0};var z=new h,A=new i({mode:i.ALL}),B=e.create(),C=e.create(),D=e.create(),E=e.create();d.prototype.integrateToTimeOfImpact=function(a){if(this.ccdSpeedThreshold<0||e.squaredLength(this.velocity)<Math.pow(this.ccdSpeedThreshold,2))return!1;e.normalize(B,this.velocity),e.scale(C,this.velocity,a),e.add(C,C,this.position),e.sub(D,C,this.position);var b,c=this.angularVelocity*a,d=e.length(D),f=1,g=this;if(z.reset(),A.callback=function(a){a.body!==g&&(b=a.body,a.getHitPoint(C,A),e.sub(D,C,g.position),f=e.length(D)/d,a.stop())},e.copy(A.from,this.position),e.copy(A.to,C),A.update(),this.world.raycast(z,A),!b)return!1;var h=this.angle;e.copy(E,this.position);for(var i=0,j=0,k=0,l=f;j<=l&&i<this.ccdIterations;)i++,k=(l-j)/2,e.scale(y,D,f),e.add(this.position,E,y),this.angle=h+c*f,this.updateAABB(),this.aabb.overlaps(b.aabb)&&this.world.narrowphase.bodiesOverlap(this,b)?j=k:l=k;return f=k,e.copy(this.position,E),this.angle=h,e.scale(y,D,f),e.add(this.position,this.position,y),this.fixedRotation||(this.angle+=c*f),!0},d.prototype.getVelocityAtPoint=function(a,b){return e.crossVZ(a,b,this.angularVelocity),e.subtract(a,this.velocity,a),a},d.sleepyEvent={type:"sleepy"},d.sleepEvent={type:"sleep"},d.wakeUpEvent={type:"wakeup"},d.DYNAMIC=1,d.STATIC=2,d.KINEMATIC=4,d.AWAKE=0,d.SLEEPY=1,d.SLEEPING=2},{"../collision/AABB":7,"../collision/Ray":11,"../collision/RaycastResult":12,"../events/EventEmitter":26,"../math/vec2":30,"../shapes/Convex":40,"poly-decomp":5}],32:[function(a,b,c){function d(a,b,c){c=c||{},f.call(this,a,b,c),this.localAnchorA=e.fromValues(0,0),this.localAnchorB=e.fromValues(0,0),c.localAnchorA&&e.copy(this.localAnchorA,c.localAnchorA),c.localAnchorB&&e.copy(this.localAnchorB,c.localAnchorB),c.worldAnchorA&&this.setWorldAnchorA(c.worldAnchorA),c.worldAnchorB&&this.setWorldAnchorB(c.worldAnchorB);var d=e.create(),g=e.create();this.getWorldAnchorA(d),this.getWorldAnchorB(g);var h=e.distance(d,g);this.restLength="number"==typeof c.restLength?c.restLength:h}var e=a("../math/vec2"),f=a("./Spring");a("../utils/Utils"),(((b.exports=d).prototype=new f).constructor=d).prototype.setWorldAnchorA=function(a){this.bodyA.toLocalFrame(this.localAnchorA,a)},d.prototype.setWorldAnchorB=function(a){this.bodyB.toLocalFrame(this.localAnchorB,a)},d.prototype.getWorldAnchorA=function(a){this.bodyA.toWorldFrame(a,this.localAnchorA)},d.prototype.getWorldAnchorB=function(a){this.bodyB.toWorldFrame(a,this.localAnchorB)};var g=e.create(),h=e.create(),i=e.create(),j=e.create(),k=e.create(),l=e.create(),m=e.create(),n=e.create(),o=e.create();d.prototype.applyForce=function(){var a=this.stiffness,b=this.damping,c=this.restLength,d=this.bodyA,f=this.bodyB,p=g,q=h,r=i,s=j,t=o,u=k,v=l,w=m,x=n;this.getWorldAnchorA(u),this.getWorldAnchorB(v),e.sub(w,u,d.position),e.sub(x,v,f.position),e.sub(p,v,u);var y=e.len(p);e.normalize(q,p),e.sub(r,f.velocity,d.velocity),e.crossZV(t,f.angularVelocity,x),e.add(r,r,t),e.crossZV(t,d.angularVelocity,w),e.sub(r,r,t),e.scale(s,q,-a*(y-c)-b*e.dot(r,q)),e.sub(d.force,d.force,s),e.add(f.force,f.force,s);var z=e.crossLength(w,s),A=e.crossLength(x,s);d.angularForce-=z,f.angularForce+=A}},{"../math/vec2":30,"../utils/Utils":57,"./Spring":34}],33:[function(a,b,c){function d(a,b,c){c=c||{},e.call(this,a,b,c),this.restAngle="number"==typeof c.restAngle?c.restAngle:b.angle-a.angle}var e=(a("../math/vec2"),a("./Spring"));(((b.exports=d).prototype=new e).constructor=d).prototype.applyForce=function(){var a=this.stiffness,b=this.damping,c=this.restAngle,d=this.bodyA,e=this.bodyB,h=-a*(e.angle-d.angle-c)-b*(e.angularVelocity-d.angularVelocity)*0;d.angularForce-=h,e.angularForce+=h}},{"../math/vec2":30,"./Spring":34}],34:[function(a,b,c){function d(a,b,c){c=e.defaults(c,{stiffness:100,damping:1}),this.stiffness=c.stiffness,this.damping=c.damping,this.bodyA=a,this.bodyB=b}var e=(a("../math/vec2"),a("../utils/Utils"));(b.exports=d).prototype.applyForce=function(){}},{"../math/vec2":30,"../utils/Utils":57}],35:[function(a,b,c){function d(a,b){b=b||{},this.chassisBody=a,this.wheels=[],this.groundBody=new i({mass:0}),this.world=null;var c=this;this.preStepCallback=function(){c.update()}}function e(a,b){b=b||{},this.vehicle=a,this.forwardEquation=new h(a.chassisBody,a.groundBody),this.sideEquation=new h(a.chassisBody,a.groundBody),this.steerValue=0,this.engineForce=0,this.setSideFriction(void 0!==b.sideFriction?b.sideFriction:5),this.localForwardVector=f.fromValues(0,1),b.localForwardVector&&f.copy(this.localForwardVector,b.localForwardVector),this.localPosition=f.fromValues(0,0),b.localPosition&&f.copy(this.localPosition,b.localPosition),g.apply(this,a.chassisBody,a.groundBody),this.equations.push(this.forwardEquation,this.sideEquation),this.setBrakeForce(0)}var f=a("../math/vec2"),g=(a("../utils/Utils"),a("../constraints/Constraint")),h=a("../equations/FrictionEquation"),i=a("../objects/Body");(b.exports=d).prototype.addToWorld=function(a){(this.world=a).addBody(this.groundBody),a.on("preStep",this.preStepCallback);for(var b=0;b<this.wheels.length;b++){var c=this.wheels[b];a.addConstraint(c)}},d.prototype.removeFromWorld=function(){var a=this.world;a.removeBody(this.groundBody),a.off("preStep",this.preStepCallback);for(var b=0;b<this.wheels.length;b++){var c=this.wheels[b];a.removeConstraint(c)}this.world=null},d.prototype.addWheel=function(a){var b=new e(this,a);return this.wheels.push(b),b},d.prototype.update=function(){for(var a=0;a<this.wheels.length;a++)this.wheels[a].update()},(e.prototype=new g).setBrakeForce=function(a){this.forwardEquation.setSlipForce(a)},e.prototype.setSideFriction=function(a){this.sideEquation.setSlipForce(a)};var j=f.create(),k=f.create();e.prototype.getSpeed=function(){return this.vehicle.chassisBody.vectorToWorldFrame(k,this.localForwardVector),this.vehicle.chassisBody.getVelocityAtPoint(j,k),f.dot(j,k)};var l=f.create();e.prototype.update=function(){this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.t,this.localForwardVector),f.rotate(this.sideEquation.t,this.localForwardVector,Math.PI/2),this.vehicle.chassisBody.vectorToWorldFrame(this.sideEquation.t,this.sideEquation.t),f.rotate(this.forwardEquation.t,this.forwardEquation.t,this.steerValue),f.rotate(this.sideEquation.t,this.sideEquation.t,this.steerValue),this.vehicle.chassisBody.toWorldFrame(this.forwardEquation.contactPointB,this.localPosition),f.copy(this.sideEquation.contactPointB,this.forwardEquation.contactPointB),this.vehicle.chassisBody.vectorToWorldFrame(this.forwardEquation.contactPointA,this.localPosition),f.copy(this.sideEquation.contactPointA,this.forwardEquation.contactPointA),f.normalize(l,this.forwardEquation.t),f.scale(l,l,this.engineForce),this.vehicle.chassisBody.applyForce(l,this.forwardEquation.contactPointA)}},{"../constraints/Constraint":14,"../equations/FrictionEquation":23,"../math/vec2":30,"../objects/Body":31,"../utils/Utils":57}],36:[function(a,b,c){var d=b.exports={AABB:a("./collision/AABB"),AngleLockEquation:a("./equations/AngleLockEquation"),Body:a("./objects/Body"),Broadphase:a("./collision/Broadphase"),Capsule:a("./shapes/Capsule"),Circle:a("./shapes/Circle"),Constraint:a("./constraints/Constraint"),ContactEquation:a("./equations/ContactEquation"),ContactEquationPool:a("./utils/ContactEquationPool"),ContactMaterial:a("./material/ContactMaterial"),Convex:a("./shapes/Convex"),DistanceConstraint:a("./constraints/DistanceConstraint"),Equation:a("./equations/Equation"),EventEmitter:a("./events/EventEmitter"),FrictionEquation:a("./equations/FrictionEquation"),FrictionEquationPool:a("./utils/FrictionEquationPool"),GearConstraint:a("./constraints/GearConstraint"),GSSolver:a("./solver/GSSolver"),Heightfield:a("./shapes/Heightfield"),Line:a("./shapes/Line"),LockConstraint:a("./constraints/LockConstraint"),Material:a("./material/Material"),Narrowphase:a("./collision/Narrowphase"),NaiveBroadphase:a("./collision/NaiveBroadphase"),Particle:a("./shapes/Particle"),Plane:a("./shapes/Plane"),Pool:a("./utils/Pool"),RevoluteConstraint:a("./constraints/RevoluteConstraint"),PrismaticConstraint:a("./constraints/PrismaticConstraint"),Ray:a("./collision/Ray"),RaycastResult:a("./collision/RaycastResult"),Box:a("./shapes/Box"),RotationalVelocityEquation:a("./equations/RotationalVelocityEquation"),SAPBroadphase:a("./collision/SAPBroadphase"),Shape:a("./shapes/Shape"),Solver:a("./solver/Solver"),Spring:a("./objects/Spring"),TopDownVehicle:a("./objects/TopDownVehicle"),LinearSpring:a("./objects/LinearSpring"),RotationalSpring:a("./objects/RotationalSpring"),Utils:a("./utils/Utils"),World:a("./world/World"),vec2:a("./math/vec2"),version:a("../package.json").version};Object.defineProperty(d,"Rectangle",{get:function(){return this.Box}})},{"../package.json":6,"./collision/AABB":7,"./collision/Broadphase":8,"./collision/NaiveBroadphase":9,"./collision/Narrowphase":10,"./collision/Ray":11,"./collision/RaycastResult":12,"./collision/SAPBroadphase":13,"./constraints/Constraint":14,"./constraints/DistanceConstraint":15,"./constraints/GearConstraint":16,"./constraints/LockConstraint":17,"./constraints/PrismaticConstraint":18,"./constraints/RevoluteConstraint":19,"./equations/AngleLockEquation":20,"./equations/ContactEquation":21,"./equations/Equation":22,"./equations/FrictionEquation":23,"./equations/RotationalVelocityEquation":25,"./events/EventEmitter":26,"./material/ContactMaterial":27,"./material/Material":28,"./math/vec2":30,"./objects/Body":31,"./objects/LinearSpring":32,"./objects/RotationalSpring":33,"./objects/Spring":34,"./objects/TopDownVehicle":35,"./shapes/Box":37,"./shapes/Capsule":38,"./shapes/Circle":39,"./shapes/Convex":40,"./shapes/Heightfield":41,"./shapes/Line":42,"./shapes/Particle":43,"./shapes/Plane":44,"./shapes/Shape":45,"./solver/GSSolver":46,"./solver/Solver":47,"./utils/ContactEquationPool":48,"./utils/FrictionEquationPool":49,"./utils/Pool":55,"./utils/Utils":57,"./world/World":61}],37:[function(a,b,c){function d(a){"number"==typeof a&&"number"==typeof arguments[1]&&(a={width:a,height:arguments[1]}),a=a||{};var b=this.width=a.width||1,c=this.height=a.height||1,d=[e.fromValues(-b/2,-c/2),e.fromValues(b/2,-c/2),e.fromValues(b/2,c/2),e.fromValues(-b/2,c/2)],h=[e.fromValues(1,0),e.fromValues(0,1)];a.vertices=d,a.axes=h,a.type=f.BOX,g.call(this,a)}var e=a("../math/vec2"),f=a("./Shape"),g=a("./Convex");(((b.exports=d).prototype=new g).constructor=d).prototype.computeMomentOfInertia=function(a){var b=this.width,c=this.height;return a*(c*c+b*b)/12},d.prototype.updateBoundingRadius=function(){var a=this.width,b=this.height;this.boundingRadius=Math.sqrt(a*a+b*b)/2},e.create(),e.create(),e.create(),e.create(),d.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)},d.prototype.updateArea=function(){this.area=this.width*this.height}},{"../math/vec2":30,"./Convex":40,"./Shape":45}],38:[function(a,b,c){function d(a){"number"==typeof a&&"number"==typeof arguments[1]&&(a={length:a,radius:arguments[1]}),a=a||{},this.length=a.length||1,this.radius=a.radius||1,a.type=e.CAPSULE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");(((b.exports=d).prototype=new e).constructor=d).prototype.computeMomentOfInertia=function(a){var b=this.radius,c=this.length+b,d=2*b;return a*(d*d+c*c)/12},d.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius+this.length/2},d.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius+2*this.radius*this.length};var g=f.create();d.prototype.computeAABB=function(a,b,c){var d=this.radius;f.set(g,this.length/2,0),0!==c&&f.rotate(g,g,c),f.set(a.upperBound,Math.max(g[0]+d,-g[0]+d),Math.max(g[1]+d,-g[1]+d)),f.set(a.lowerBound,Math.min(g[0]-d,-g[0]-d),Math.min(g[1]-d,-g[1]-d)),f.add(a.lowerBound,a.lowerBound,b),f.add(a.upperBound,a.upperBound,b)};var h=f.create(),i=f.create(),j=f.create(),k=f.create(),l=f.fromValues(0,1);d.prototype.raycast=function(a,b,c,d){for(var e=b.from,g=b.to,m=(b.direction,h),n=i,o=j,p=k,q=this.length/2,r=0;r<2;r++){var s=this.radius*(2*r-1);if(f.set(o,-q,s),f.set(p,q,s),f.toGlobalFrame(o,o,c,d),f.toGlobalFrame(p,p,c,d),0<=(t=f.getLineSegmentsIntersectionFraction(e,g,o,p))&&(f.rotate(n,l,d),f.scale(n,n,2*r-1),b.reportIntersection(a,t,n,-1),a.shouldStop(b)))return}var u=Math.pow(this.radius,2)+Math.pow(q,2);for(r=0;r<2;r++){f.set(o,q*(2*r-1),0),f.toGlobalFrame(o,o,c,d);var t,v=Math.pow(g[0]-e[0],2)+Math.pow(g[1]-e[1],2),w=2*((g[0]-e[0])*(e[0]-o[0])+(g[1]-e[1])*(e[1]-o[1])),x=Math.pow(e[0]-o[0],2)+Math.pow(e[1]-o[1],2)-Math.pow(this.radius,2);if(!((t=Math.pow(w,2)-4*v*x)<0))if(0===t){if(f.lerp(m,e,g,t),f.squaredDistance(m,c)>u&&(f.sub(n,m,o),f.normalize(n,n),b.reportIntersection(a,t,n,-1),a.shouldStop(b)))return}else{var y=Math.sqrt(t),z=1/(2*v),A=(-w-y)*z,B=(-w+y)*z;if(0<=A&&A<=1&&(f.lerp(m,e,g,A),f.squaredDistance(m,c)>u&&(f.sub(n,m,o),f.normalize(n,n),b.reportIntersection(a,A,n,-1),a.shouldStop(b))))return;if(0<=B&&B<=1&&(f.lerp(m,e,g,B),f.squaredDistance(m,c)>u&&(f.sub(n,m,o),f.normalize(n,n),b.reportIntersection(a,B,n,-1),a.shouldStop(b))))return}}}},{"../math/vec2":30,"./Shape":45}],39:[function(a,b,c){function d(a){"number"==typeof a&&(a={radius:a}),a=a||{},this.radius=a.radius||1,a.type=e.CIRCLE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");(((b.exports=d).prototype=new e).constructor=d).prototype.computeMomentOfInertia=function(a){var b=this.radius;return a*b*b/2},d.prototype.updateBoundingRadius=function(){this.boundingRadius=this.radius},d.prototype.updateArea=function(){this.area=Math.PI*this.radius*this.radius},d.prototype.computeAABB=function(a,b,c){var d=this.radius;f.set(a.upperBound,d,d),f.set(a.lowerBound,-d,-d),b&&(f.add(a.lowerBound,a.lowerBound,b),f.add(a.upperBound,a.upperBound,b))};var g=f.create(),h=f.create();d.prototype.raycast=function(a,b,c,d){var e=b.from,i=b.to,j=this.radius,k=Math.pow(i[0]-e[0],2)+Math.pow(i[1]-e[1],2),l=2*((i[0]-e[0])*(e[0]-c[0])+(i[1]-e[1])*(e[1]-c[1])),m=Math.pow(e[0]-c[0],2)+Math.pow(e[1]-c[1],2)-Math.pow(j,2),n=Math.pow(l,2)-4*k*m,o=g,p=h;if(!(n<0))if(0===n)f.lerp(o,e,i,n),f.sub(p,o,c),f.normalize(p,p),b.reportIntersection(a,n,p,-1);else{var q=Math.sqrt(n),r=1/(2*k),s=(-l-q)*r,t=(-l+q)*r;if(0<=s&&s<=1&&(f.lerp(o,e,i,s),f.sub(p,o,c),f.normalize(p,p),b.reportIntersection(a,s,p,-1),a.shouldStop(b)))return;0<=t&&t<=1&&(f.lerp(o,e,i,t),f.sub(p,o,c),f.normalize(p,p),b.reportIntersection(a,t,p,-1))}}},{"../math/vec2":30,"./Shape":45}],40:[function(a,b,c){function d(a){Array.isArray(a)&&(a={vertices:a,axes:arguments[1]}),a=a||{},this.vertices=[];for(var b=void 0!==a.vertices?a.vertices:[],c=0;c<b.length;c++){var d=f.create();f.copy(d,b[c]),this.vertices.push(d)}if(this.axes=[],a.axes)for(c=0;c<a.axes.length;c++){var g=f.create();f.copy(g,a.axes[c]),this.axes.push(g)}else for(c=0;c<this.vertices.length;c++){var h=this.vertices[c],i=this.vertices[(c+1)%this.vertices.length],j=f.create();f.sub(j,i,h),f.rotate90cw(j,j),f.normalize(j,j),this.axes.push(j)}if(this.centerOfMass=f.fromValues(0,0),this.triangles=[],this.vertices.length&&(this.updateTriangles(),this.updateCenterOfMass()),this.boundingRadius=0,a.type=e.CONVEX,e.call(this,a),this.updateBoundingRadius(),this.updateArea(),this.area<0)throw new Error("Convex vertices must be given in conter-clockwise winding.")}var e=a("./Shape"),f=a("../math/vec2"),g=a("../math/polyk");a("poly-decomp"),((b.exports=d).prototype=new e).constructor=d;var h=f.create(),i=f.create();d.prototype.projectOntoLocalAxis=function(a,b){for(var c,d,e=null,g=null,i=(a=h,0);i<this.vertices.length;i++)c=this.vertices[i],d=f.dot(c,a),(null===e||e<d)&&(e=d),(null===g||d<g)&&(g=d);if(e<g){var j=g;g=e,e=j}f.set(b,g,e)},d.prototype.projectOntoWorldAxis=function(a,b,c,d){var e=i;this.projectOntoLocalAxis(a,d),0!==c?f.rotate(e,a,c):e=a;var g=f.dot(b,e);f.set(d,d[0]+g,d[1]+g)},d.prototype.updateTriangles=function(){for(var a=[],b=this.triangles.length=0;b<this.vertices.length;b++){var c=this.vertices[b];a.push(c[0],c[1])}var d=g.Triangulate(a);for(b=0;b<d.length;b+=3){var e=d[b],f=d[b+1],h=d[b+2];this.triangles.push([e,f,h])}};var j=f.create(),k=f.create(),l=f.create(),m=f.create(),n=f.create();f.create(),f.create(),f.create(),f.create(),d.prototype.updateCenterOfMass=function(){var a=this.triangles,b=this.vertices,c=this.centerOfMass,e=j,g=l,h=m,i=n,o=k;f.set(c,0,0);for(var p=0,q=0;q!==a.length;q++){var r=a[q];g=b[r[0]],h=b[r[1]],i=b[r[2]];f.centroid(e,g,h,i);var s=d.triangleArea(g,h,i);p+=s,f.scale(o,e,s),f.add(c,c,o)}f.scale(c,c,1/p)},d.prototype.computeMomentOfInertia=function(a){for(var b=0,c=0,d=this.vertices.length,e=d-1,g=0;g<d;e=g,g++){var h=this.vertices[e],i=this.vertices[g],j=Math.abs(f.crossLength(h,i));b+=j*(f.dot(i,i)+f.dot(i,h)+f.dot(h,h)),c+=j}return a/6*(b/c)},d.prototype.updateBoundingRadius=function(){for(var a=this.vertices,b=0,c=0;c!==a.length;c++){var d=f.squaredLength(a[c]);b<d&&(b=d)}this.boundingRadius=Math.sqrt(b)},d.triangleArea=function(a,b,c){return.5*((b[0]-a[0])*(c[1]-a[1])-(c[0]-a[0])*(b[1]-a[1]))},d.prototype.updateArea=function(){this.updateTriangles(),this.area=0;for(var a=this.triangles,b=this.vertices,c=0;c!==a.length;c++){var e=a[c],f=b[e[0]],g=b[e[1]],h=b[e[2]],i=d.triangleArea(f,g,h);this.area+=i}},d.prototype.computeAABB=function(a,b,c){a.setFromPoints(this.vertices,b,c,0)};var o=f.create(),p=f.create(),q=f.create();d.prototype.raycast=function(a,b,c,d){var e=o,g=p,h=q,i=this.vertices;f.toLocalFrame(e,b.from,c,d),f.toLocalFrame(g,b.to,c,d);for(var j=i.length,k=0;k<j&&!a.shouldStop(b);k++){var l=i[k],m=i[(k+1)%j],n=f.getLineSegmentsIntersectionFraction(e,g,l,m);0<=n&&(f.sub(h,m,l),f.rotate(h,h,-Math.PI/2+d),f.normalize(h,h),b.reportIntersection(a,n,h,k))}}},{"../math/polyk":29,"../math/vec2":30,"./Shape":45,"poly-decomp":5}],41:[function(a,b,c){function d(a){if(Array.isArray(a)&&(a={heights:a},"object"==typeof arguments[1]))for(var b in arguments[1])a[b]=arguments[1][b];a=a||{},this.heights=a.heights?a.heights.slice(0):[],this.maxValue=a.maxValue||null,this.minValue=a.minValue||null,this.elementWidth=a.elementWidth||.1,void 0!==a.maxValue&&void 0!==a.minValue||this.updateMaxMinValues(),a.type=e.HEIGHTFIELD,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");a("../utils/Utils"),(((b.exports=d).prototype=new e).constructor=d).prototype.updateMaxMinValues=function(){for(var a=this.heights,b=a[0],c=a[0],d=0;d!==a.length;d++){var e=a[d];b<e&&(b=e),e<c&&(c=e)}this.maxValue=b,this.minValue=c},d.prototype.computeMomentOfInertia=function(a){return Number.MAX_VALUE},d.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},d.prototype.updateArea=function(){for(var a=this.heights,b=0,c=0;c<a.length-1;c++)b+=(a[c]+a[c+1])/2*this.elementWidth;this.area=b};var g=[f.create(),f.create(),f.create(),f.create()];d.prototype.computeAABB=function(a,b,c){f.set(g[0],0,this.maxValue),f.set(g[1],this.elementWidth*this.heights.length,this.maxValue),f.set(g[2],this.elementWidth*this.heights.length,this.minValue),f.set(g[3],0,this.minValue),a.setFromPoints(g,b,c)},d.prototype.getLineSegment=function(a,b,c){var d=this.heights,e=this.elementWidth;f.set(a,c*e,d[c]),f.set(b,(c+1)*e,d[c+1])},d.prototype.getSegmentIndex=function(a){return Math.floor(a[0]/this.elementWidth)},d.prototype.getClampedSegmentIndex=function(a){var b=this.getSegmentIndex(a);return Math.min(this.heights.length,Math.max(b,0))};var h=(f.create(),f.create()),i=f.create(),j=f.create(),k=f.create(),l=f.create();f.fromValues(0,1),d.prototype.raycast=function(a,b,c,d){var e=b.from,g=b.to,m=(b.direction,h),n=i,o=j,p=k,q=l;f.toLocalFrame(p,e,c,d),f.toLocalFrame(q,g,c,d);var r=this.getClampedSegmentIndex(p),s=this.getClampedSegmentIndex(q);if(s<r){var t=r;r=s,s=t}for(var u=0;u<this.heights.length-1;u++){this.getLineSegment(n,o,u);var v=f.getLineSegmentsIntersectionFraction(p,q,n,o);if(0<=v&&(f.sub(m,o,n),f.rotate(m,m,d+Math.PI/2),f.normalize(m,m),b.reportIntersection(a,v,m,-1),a.shouldStop(b)))return}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],42:[function(a,b,c){function d(a){"number"==typeof a&&(a={length:a}),a=a||{},this.length=a.length||1,a.type=e.LINE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");(((b.exports=d).prototype=new e).constructor=d).prototype.computeMomentOfInertia=function(a){return a*Math.pow(this.length,2)/12},d.prototype.updateBoundingRadius=function(){this.boundingRadius=this.length/2};var g=[f.create(),f.create()];d.prototype.computeAABB=function(a,b,c){var d=this.length/2;f.set(g[0],-d,0),f.set(g[1],d,0),a.setFromPoints(g,b,c,0)};var h=(f.create(),f.create()),i=f.create(),j=f.create(),k=f.fromValues(0,1);d.prototype.raycast=function(a,b,c,d){var e=b.from,g=b.to,l=i,m=j,n=this.length/2;f.set(l,-n,0),f.set(m,n,0),f.toGlobalFrame(l,l,c,d),f.toGlobalFrame(m,m,c,d);var o=f.getLineSegmentsIntersectionFraction(l,m,e,g);if(0<=o){var p=h;f.rotate(p,k,d),b.reportIntersection(a,o,p,-1)}}},{"../math/vec2":30,"./Shape":45}],43:[function(a,b,c){function d(a){(a=a||{}).type=e.PARTICLE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");(((b.exports=d).prototype=new e).constructor=d).prototype.computeMomentOfInertia=function(a){return 0},d.prototype.updateBoundingRadius=function(){this.boundingRadius=0},d.prototype.computeAABB=function(a,b,c){f.copy(a.lowerBound,b),f.copy(a.upperBound,b)}},{"../math/vec2":30,"./Shape":45}],44:[function(a,b,c){function d(a){(a=a||{}).type=e.PLANE,e.call(this,a)}var e=a("./Shape"),f=a("../math/vec2");a("../utils/Utils"),(((b.exports=d).prototype=new e).constructor=d).prototype.computeMomentOfInertia=function(a){return 0},d.prototype.updateBoundingRadius=function(){this.boundingRadius=Number.MAX_VALUE},d.prototype.computeAABB=function(a,b,c){var d=c%(2*Math.PI),e=f.set,g=Number.MAX_VALUE,h=a.lowerBound,i=a.upperBound;0===d?(e(h,-g,-g),e(i,g,0)):d===Math.PI/2?(e(h,0,-g),e(i,g,g)):d===Math.PI?(e(h,-g,0),e(i,g,g)):d===3*Math.PI/2?(e(h,-g,-g),e(i,0,g)):(e(h,-g,-g),e(i,g,g)),f.add(h,h,b),f.add(i,i,b)},d.prototype.updateArea=function(){this.area=Number.MAX_VALUE};var g=f.create(),h=(f.create(),f.create(),f.create()),i=f.create();d.prototype.raycast=function(a,b,c,d){var e=b.from,j=b.to,k=b.direction,l=g,m=h,n=i;f.set(m,0,1),f.rotate(m,m,d),f.sub(n,e,c);var o=f.dot(n,m);if(f.sub(n,j,c),!(0<o*f.dot(n,m)||f.squaredDistance(e,j)<o*o)){var p=f.dot(m,k);f.sub(l,e,c);var q=-f.dot(m,l)/p/b.length;b.reportIntersection(a,q,m,-1)}}},{"../math/vec2":30,"../utils/Utils":57,"./Shape":45}],45:[function(a,b,c){function d(a){a=a||{},this.body=null,this.position=e.fromValues(0,0),a.position&&e.copy(this.position,a.position),this.angle=a.angle||0,this.type=a.type||0,this.id=d.idCounter++,this.boundingRadius=0,this.collisionGroup=void 0!==a.collisionGroup?a.collisionGroup:1,this.collisionResponse=void 0===a.collisionResponse||a.collisionResponse,this.collisionMask=void 0!==a.collisionMask?a.collisionMask:1,this.material=a.material||null,this.area=0,this.sensor=void 0!==a.sensor&&a.sensor,this.type&&this.updateBoundingRadius(),this.updateArea()}b.exports=d;var e=a("../math/vec2");d.idCounter=0,d.CIRCLE=1,d.PARTICLE=2,d.PLANE=4,d.CONVEX=8,d.LINE=16,d.BOX=32,Object.defineProperty(d,"RECTANGLE",{get:function(){return d.BOX}}),d.CAPSULE=64,d.HEIGHTFIELD=128,d.prototype.computeMomentOfInertia=function(a){},d.prototype.updateBoundingRadius=function(){},d.prototype.updateArea=function(){},d.prototype.computeAABB=function(a,b,c){},d.prototype.raycast=function(a,b,c,d){}},{"../math/vec2":30}],46:[function(a,b,c){function d(a){g.call(this,a,g.GS),a=a||{},this.iterations=a.iterations||10,this.tolerance=a.tolerance||1e-7,this.arrayStep=30,this.lambda=new h.ARRAY_TYPE(this.arrayStep),this.Bs=new h.ARRAY_TYPE(this.arrayStep),this.invCs=new h.ARRAY_TYPE(this.arrayStep),this.useZeroRHS=!1,this.frictionIterations=0,this.usedIterations=0}var f=a("../math/vec2"),g=a("./Solver"),h=a("../utils/Utils"),i=a("../equations/FrictionEquation");(((b.exports=d).prototype=new g).constructor=d).prototype.solve=function(a,b){this.sortEquations();var w,x,c=0,g=this.iterations,j=this.frictionIterations,k=this.equations,l=k.length,m=Math.pow(this.tolerance*l,2),n=b.bodies,o=b.bodies.length,p=(f.add,f.set,this.useZeroRHS),q=this.lambda;if(this.usedIterations=0,l)for(var r=0;r!==o;r++){n[r].updateSolveMassProperties()}q.length<l&&(q=this.lambda=new h.ARRAY_TYPE(l+this.arrayStep),this.Bs=new h.ARRAY_TYPE(l+this.arrayStep),this.invCs=new h.ARRAY_TYPE(l+this.arrayStep)),function(a){for(var b=a.length;b--;)a[b]=0}(q);for(var t=this.invCs,u=this.Bs,r=(q=this.lambda,0);r!==k.length;r++){var v;((v=k[r]).timeStep!==a||v.needsUpdate)&&(v.timeStep=a,v.update()),u[r]=v.computeB(v.a,v.b,a),t[r]=v.computeInvC(v.epsilon)}if(0!==l){for(r=0;r!==o;r++){n[r].resetConstraintVelocity()}if(j){for(c=0;c!==j;c++){for(x=w=0;x!==l;x++){v=k[x];var y=d.iterateEquation(x,v,v.epsilon,u,t,q,p,a,c);w+=Math.abs(y)}if(this.usedIterations++,w*w<=m)break}for(d.updateMultipliers(k,q,1/a),x=0;x!==l;x++){var z=k[x];if(z instanceof i){for(var A=0,B=0;B!==z.contactEquations.length;B++)A+=z.contactEquations[B].multiplier;A*=z.frictionCoefficient/z.contactEquations.length,z.maxForce=A,z.minForce=-A}}}for(c=0;c!==g;c++){for(x=w=0;x!==l;x++){v=k[x];y=d.iterateEquation(x,v,v.epsilon,u,t,q,p,a,c);w+=Math.abs(y)}if(this.usedIterations++,w*w<=m)break}for(r=0;r!==o;r++)n[r].addConstraintVelocity();d.updateMultipliers(k,q,1/a)}},d.updateMultipliers=function(a,b,c){for(var d=a.length;d--;)a[d].multiplier=b[d]*c},d.iterateEquation=function(a,b,c,d,e,f,g,h,i){var j=d[a],k=e[a],l=f[a],m=b.computeGWlambda(),n=b.maxForce,o=b.minForce;g&&(j=0);var p=k*(j-m-c*l),q=l+p;return q<o*h?p=o*h-l:n*h<q&&(p=n*h-l),f[a]+=p,b.addToWlambda(p),p}},{"../equations/FrictionEquation":23,"../math/vec2":30,"../utils/Utils":57,"./Solver":47}],47:[function(a,b,c){function d(a,b){a=a||{},e.call(this),this.type=b,this.equations=[],this.equationSortFunction=a.equationSortFunction||!1}var e=(a("../utils/Utils"),a("../events/EventEmitter"));(((b.exports=d).prototype=new e).constructor=d).prototype.solve=function(a,b){throw new Error("Solver.solve should be implemented by subclasses!")};var f={bodies:[]};d.prototype.solveIsland=function(a,b){this.removeAllEquations(),b.equations.length&&(this.addEquations(b.equations),f.bodies.length=0,b.getBodies(f.bodies),f.bodies.length&&this.solve(a,f))},d.prototype.sortEquations=function(){this.equationSortFunction&&this.equations.sort(this.equationSortFunction)},d.prototype.addEquation=function(a){a.enabled&&this.equations.push(a)},d.prototype.addEquations=function(a){for(var b=0,c=a.length;b!==c;b++){var d=a[b];d.enabled&&this.equations.push(d)}},d.prototype.removeEquation=function(a){var b=this.equations.indexOf(a);-1!==b&&this.equations.splice(b,1)},d.prototype.removeAllEquations=function(){this.equations.length=0},d.GS=1,d.ISLAND=2},{"../events/EventEmitter":26,"../utils/Utils":57}],48:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../equations/ContactEquation"),f=a("./Pool");(((b.exports=d).prototype=new f).constructor=d).prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.bodyA=a.bodyB=null,this}},{"../equations/ContactEquation":21,"./Pool":55}],49:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../equations/FrictionEquation"),f=a("./Pool");(((b.exports=d).prototype=new f).constructor=d).prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.bodyA=a.bodyB=null,this}},{"../equations/FrictionEquation":23,"./Pool":55}],50:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../world/IslandNode"),f=a("./Pool");(((b.exports=d).prototype=new f).constructor=d).prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.reset(),this}},{"../world/IslandNode":60,"./Pool":55}],51:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("../world/Island"),f=a("./Pool");(((b.exports=d).prototype=new f).constructor=d).prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.reset(),this}},{"../world/Island":58,"./Pool":55}],52:[function(a,b,c){function d(){this.overlappingShapesLastState=new e,this.overlappingShapesCurrentState=new e,this.recordPool=new f({size:16}),this.tmpDict=new e,this.tmpArray1=[]}var e=a("./TupleDictionary"),f=(a("./OverlapKeeperRecord"),a("./OverlapKeeperRecordPool"));a("./Utils"),(b.exports=d).prototype.tick=function(){for(var a=this.overlappingShapesLastState,b=this.overlappingShapesCurrentState,c=a.keys.length;c--;){var d=a.keys[c],e=a.getByKey(d);b.getByKey(d),e&&this.recordPool.release(e)}a.reset(),a.copy(b),b.reset()},d.prototype.setOverlapping=function(a,b,c,d){var e=(this.overlappingShapesLastState,this.overlappingShapesCurrentState);if(!e.get(b.id,d.id)){var f=this.recordPool.get();f.set(a,b,c,d),e.set(b.id,d.id,f)}},d.prototype.getNewOverlaps=function(a){return this.getDiff(this.overlappingShapesLastState,this.overlappingShapesCurrentState,a)},d.prototype.getEndOverlaps=function(a){return this.getDiff(this.overlappingShapesCurrentState,this.overlappingShapesLastState,a)},d.prototype.bodiesAreOverlapping=function(a,b){for(var c=this.overlappingShapesCurrentState,d=c.keys.length;d--;){var e=c.keys[d],f=c.data[e];if(f.bodyA===a&&f.bodyB===b||f.bodyA===b&&f.bodyB===a)return!0}return!1},d.prototype.getDiff=function(a,b,c){var d=a,e=b;(c=c||[]).length=0;for(var f=e.keys.length;f--;){var g=e.keys[f],h=e.data[g];if(!h)throw new Error("Key "+g+" had no data!");d.data[g]||c.push(h)}return c},d.prototype.isNewOverlap=function(a,b){var c=0|a.id,d=0|b.id,e=this.overlappingShapesLastState,f=this.overlappingShapesCurrentState;return!e.get(c,d)&&!!f.get(c,d)},d.prototype.getNewBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getNewOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},d.prototype.getEndBodyOverlaps=function(a){this.tmpArray1.length=0;var b=this.getEndOverlaps(this.tmpArray1);return this.getBodyDiff(b,a)},d.prototype.getBodyDiff=function(a,b){b=b||[];for(var c=this.tmpDict,d=a.length;d--;){var e=a[d];c.set(0|e.bodyA.id,0|e.bodyB.id,e)}for(d=c.keys.length;d--;){(e=c.getByKey(c.keys[d]))&&b.push(e.bodyA,e.bodyB)}return c.reset(),b}},{"./OverlapKeeperRecord":53,"./OverlapKeeperRecordPool":54,"./TupleDictionary":56,"./Utils":57}],53:[function(a,b,c){function d(a,b,c,d){this.shapeA=b,this.shapeB=d,this.bodyA=a,this.bodyB=c}(b.exports=d).prototype.set=function(a,b,c,e){d.call(this,a,b,c,e)}},{}],54:[function(a,b,c){function d(){f.apply(this,arguments)}var e=a("./OverlapKeeperRecord"),f=a("./Pool");(((b.exports=d).prototype=new f).constructor=d).prototype.create=function(){return new e},d.prototype.destroy=function(a){return a.bodyA=a.bodyB=a.shapeA=a.shapeB=null,this}},{"./OverlapKeeperRecord":53,"./Pool":55}],55:[function(a,b,c){function d(a){a=a||{},this.objects=[],void 0!==a.size&&this.resize(a.size)}(b.exports=d).prototype.resize=function(a){for(var b=this.objects;b.length>a;)b.pop();for(;b.length<a;)b.push(this.create());return this},d.prototype.get=function(){var a=this.objects;return a.length?a.pop():this.create()},d.prototype.release=function(a){return this.destroy(a),this.objects.push(a),this}},{}],56:[function(a,b,c){function d(){this.data={},this.keys=[]}var e=a("./Utils");(b.exports=d).prototype.getKey=function(a,b){return(0|(a|=0))==(0|(b|=0))?-1:0|((0|b)<(0|a)?a<<16|65535&b:b<<16|65535&a)},d.prototype.getByKey=function(a){return a|=0,this.data[a]},d.prototype.get=function(a,b){return this.data[this.getKey(a,b)]},d.prototype.set=function(a,b,c){if(!c)throw new Error("No data!");var d=this.getKey(a,b);return this.data[d]||this.keys.push(d),this.data[d]=c,d},d.prototype.reset=function(){for(var a=this.data,b=this.keys,c=b.length;c--;)delete a[b[c]];b.length=0},d.prototype.copy=function(a){this.reset(),e.appendArray(this.keys,a.keys);for(var b=a.keys.length;b--;){var c=a.keys[b];this.data[c]=a.data[c]}}},{"./Utils":57}],57:[function(a,b,c){function d(){}(b.exports=d).appendArray=function(a,b){if(b.length<15e4)a.push.apply(a,b);else for(var c=0,d=b.length;c!==d;++c)a.push(b[c])},d.splice=function(a,b,c){c=c||1;for(var d=b,e=a.length-c;d<e;d++)a[d]=a[d+c];a.length=e},d.ARRAY_TYPE="undefined"!=typeof P2_ARRAY_TYPE?P2_ARRAY_TYPE:"undefined"!=typeof Float32Array?Float32Array:Array,d.extend=function(a,b){for(var c in b)a[c]=b[c]},d.defaults=function(a,b){for(var c in a=a||{},b)c in a||(a[c]=b[c]);return a}},{}],58:[function(a,b,c){function d(){this.equations=[],this.bodies=[]}var e=a("../objects/Body");(b.exports=d).prototype.reset=function(){this.equations.length=this.bodies.length=0};var f=[];d.prototype.getBodies=function(a){for(var b=a||[],c=this.equations,d=f.length=0;d!==c.length;d++){var e=c[d];-1===f.indexOf(e.bodyA.id)&&(b.push(e.bodyA),f.push(e.bodyA.id)),-1===f.indexOf(e.bodyB.id)&&(b.push(e.bodyB),f.push(e.bodyB.id))}return b},d.prototype.wantsToSleep=function(){for(var a=0;a<this.bodies.length;a++){var b=this.bodies[a];if(b.type===e.DYNAMIC&&!b.wantsToSleep)return!1}return!0},d.prototype.sleep=function(){for(var a=0;a<this.bodies.length;a++)this.bodies[a].sleep();return!0}},{"../objects/Body":31}],59:[function(a,b,c){function d(a){this.nodePool=new e({size:16}),this.islandPool=new f({size:8}),this.equations=[],this.islands=[],this.nodes=[],this.queue=[]}var e=(a("../math/vec2"),a("./Island"),a("./IslandNode"),a("./../utils/IslandNodePool")),f=a("./../utils/IslandPool"),g=a("../objects/Body");(b.exports=d).getUnvisitedNode=function(a){for(var b=a.length,c=0;c!==b;c++){var d=a[c];if(!d.visited&&d.body.type===g.DYNAMIC)return d}return!1},d.prototype.visit=function(a,b,c){b.push(a.body);for(var d=a.equations.length,e=0;e!==d;e++){var f=a.equations[e];-1===c.indexOf(f)&&c.push(f)}},d.prototype.bfs=function(a,b,c){var e=this.queue;for(e.length=0,e.push(a),a.visited=!0,this.visit(a,b,c);e.length;)for(var f,h=e.pop();f=d.getUnvisitedNode(h.neighbors);)f.visited=!0,this.visit(f,b,c),f.body.type===g.DYNAMIC&&e.push(f)},d.prototype.split=function(a){for(var b=a.bodies,c=this.nodes,e=this.equations;c.length;)this.nodePool.release(c.pop());for(var f=0;f!==b.length;f++){var g=this.nodePool.get();g.body=b[f],c.push(g)}for(var h=0;h!==e.length;h++){var i=e[h],j=(f=b.indexOf(i.bodyA),b.indexOf(i.bodyB)),k=c[f],l=c[j];k.neighbors.push(l),l.neighbors.push(k),k.equations.push(i),l.equations.push(i)}var m=this.islands;for(f=0;f<m.length;f++)this.islandPool.release(m[f]);m.length=0;for(var n;n=d.getUnvisitedNode(c);){var o=this.islandPool.get();this.bfs(n,o.bodies,o.equations),m.push(o)}return m}},{"../math/vec2":30,"../objects/Body":31,"./../utils/IslandNodePool":50,"./../utils/IslandPool":51,"./Island":58,"./IslandNode":60}],60:[function(a,b,c){function d(a){this.body=a,this.neighbors=[],this.equations=[],this.visited=!1}(b.exports=d).prototype.reset=function(){this.equations.length=0,this.neighbors.length=0,this.visited=!1,this.body=null}},{}],61:[function(a,b,c){function d(a){l.apply(this),a=a||{},this.springs=[],this.bodies=[],this.disabledBodyCollisionPairs=[],this.solver=a.solver||new e,this.narrowphase=new r(this),this.islandManager=new u,this.gravity=f.fromValues(0,-9.78),a.gravity&&f.copy(this.gravity,a.gravity),this.frictionGravity=f.length(this.gravity)||10,this.useWorldGravityAsFrictionGravity=!0,this.useFrictionGravityOnZeroGravity=!0,this.broadphase=a.broadphase||new q,this.broadphase.setWorld(this),this.constraints=[],this.defaultMaterial=new n,this.defaultContactMaterial=new o(this.defaultMaterial,this.defaultMaterial),this.lastTimeStep=1/60,this.applySpringForces=!0,this.applyDamping=!0,this.applyGravity=!0,this.solveConstraints=!0,this.contactMaterials=[],this.time=0,this.accumulator=0,this.stepping=!1,this.bodiesToBeRemoved=[],this.islandSplit=void 0===a.islandSplit||!!a.islandSplit,this.emitImpactEvent=!0,this._constraintIdCounter=0,this._bodyIdCounter=0,this.postStepEvent={type:"postStep"},this.addBodyEvent={type:"addBody",body:null},this.removeBodyEvent={type:"removeBody",body:null},this.addSpringEvent={type:"addSpring",spring:null},this.impactEvent={type:"impact",bodyA:null,bodyB:null,shapeA:null,shapeB:null,contactEquation:null},this.postBroadphaseEvent={type:"postBroadphase",pairs:null},this.sleepMode=d.NO_SLEEPING,this.beginContactEvent={type:"beginContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null,contactEquations:[]},this.endContactEvent={type:"endContact",shapeA:null,shapeB:null,bodyA:null,bodyB:null},this.preSolveEvent={type:"preSolve",contactEquations:null,frictionEquations:null},this.overlappingShapesLastState={keys:[]},this.overlappingShapesCurrentState={keys:[]},this.overlapKeeper=new t}var e=a("../solver/GSSolver"),f=(a("../solver/Solver"),a("../collision/Ray"),a("../math/vec2")),g=a("../shapes/Circle"),h=a("../shapes/Convex"),i=(a("../shapes/Line"),a("../shapes/Plane")),j=a("../shapes/Capsule"),k=a("../shapes/Particle"),l=a("../events/EventEmitter"),m=a("../objects/Body"),n=(a("../shapes/Shape"),a("../objects/LinearSpring"),a("../material/Material")),o=a("../material/ContactMaterial"),p=(a("../constraints/DistanceConstraint"),a("../constraints/Constraint"),a("../constraints/LockConstraint"),a("../constraints/RevoluteConstraint"),a("../constraints/PrismaticConstraint"),a("../constraints/GearConstraint"),a("../../package.json"),a("../collision/Broadphase"),a("../collision/AABB")),q=a("../collision/SAPBroadphase"),r=a("../collision/Narrowphase"),s=a("../utils/Utils"),t=a("../utils/OverlapKeeper"),u=a("./IslandManager");a("../objects/RotationalSpring"),(((b.exports=d).prototype=new Object(l.prototype)).constructor=d).NO_SLEEPING=1,d.BODY_SLEEPING=2,d.ISLAND_SLEEPING=4,d.prototype.addConstraint=function(a){this.constraints.push(a)},d.prototype.addContactMaterial=function(a){this.contactMaterials.push(a)},d.prototype.removeContactMaterial=function(a){var b=this.contactMaterials.indexOf(a);-1!==b&&s.splice(this.contactMaterials,b,1)},d.prototype.getContactMaterial=function(a,b){for(var c=this.contactMaterials,d=0,e=c.length;d!==e;d++){var f=c[d];if(f.materialA.id===a.id&&f.materialB.id===b.id||f.materialA.id===b.id&&f.materialB.id===a.id)return f}return!1},d.prototype.removeConstraint=function(a){var b=this.constraints.indexOf(a);-1!==b&&s.splice(this.constraints,b,1)};var v=(f.create(),f.create(),f.create(),f.create(),f.create(),f.create(),f.create()),w=f.fromValues(0,0),x=f.fromValues(0,0);f.fromValues(0,0),f.fromValues(0,0),d.prototype.step=function(a,b,c){if(c=c||10,0===(b=b||0))this.internalStep(a),this.time+=a;else{this.accumulator+=b;for(var d=0;this.accumulator>=a&&d<c;)this.internalStep(a),this.time+=a,this.accumulator-=a,d++;for(var e=this.accumulator%a/a,g=0;g!==this.bodies.length;g++){var h=this.bodies[g];f.lerp(h.interpolatedPosition,h.previousPosition,h.position,e),h.interpolatedAngle=h.previousAngle+e*(h.angle-h.previousAngle)}}};var y=[];d.prototype.internalStep=function(a){this.stepping=!0;var b=this.springs.length,c=this.springs,e=this.bodies,g=this.gravity,h=this.solver,i=this.bodies.length,j=this.broadphase,k=this.narrowphase,l=this.constraints,n=v,o=(f.scale,f.add),p=(f.rotate,this.islandManager);if(this.overlapKeeper.tick(),this.lastTimeStep=a,this.useWorldGravityAsFrictionGravity){var q=f.length(this.gravity);0===q&&this.useFrictionGravityOnZeroGravity||(this.frictionGravity=q)}if(this.applyGravity)for(var r=0;r!==i;r++){var u=(t=e[r]).force;t.type===m.DYNAMIC&&t.sleepState!==m.SLEEPING&&(f.scale(n,g,t.mass*t.gravityScale),o(u,u,n))}if(this.applySpringForces)for(r=0;r!==b;r++){c[r].applyForce()}if(this.applyDamping)for(r=0;r!==i;r++){var t;(t=e[r]).type===m.DYNAMIC&&t.applyDamping(a)}var x=j.getCollisionPairs(this),z=this.disabledBodyCollisionPairs;for(r=z.length-2;0<=r;r-=2)for(var A=x.length-2;0<=A;A-=2)(z[r]===x[A]&&z[r+1]===x[A+1]||z[r+1]===x[A]&&z[r]===x[A+1])&&x.splice(A,2);var B=l.length;for(r=0;r!==B;r++){var C=l[r];if(!C.collideConnected)for(A=x.length-2;0<=A;A-=2)(C.bodyA===x[A]&&C.bodyB===x[A+1]||C.bodyB===x[A]&&C.bodyA===x[A+1])&&x.splice(A,2)}this.postBroadphaseEvent.pairs=x,this.emit(this.postBroadphaseEvent),this.postBroadphaseEvent.pairs=null,k.reset(this);r=0;for(var D=x.length;r!==D;r+=2)for(var E=x[r],F=x[r+1],G=0,H=E.shapes.length;G!==H;G++)for(var I=E.shapes[G],J=I.position,K=I.angle,L=0,M=F.shapes.length;L!==M;L++){var N=F.shapes[L],O=N.position,P=N.angle,Q=this.defaultContactMaterial;if(I.material&&N.material){var R=this.getContactMaterial(I.material,N.material);R&&(Q=R)}this.runNarrowphase(k,E,I,J,K,F,N,O,P,Q,this.frictionGravity)}for(r=0;r!==i;r++){(S=e[r])._wakeUpAfterNarrowphase&&(S.wakeUp(),S._wakeUpAfterNarrowphase=!1)}if(this.has("endContact")){this.overlapKeeper.getEndOverlaps(y);var T=this.endContactEvent;for(L=y.length;L--;){var U=y[L];T.shapeA=U.shapeA,T.shapeB=U.shapeB,T.bodyA=U.bodyA,T.bodyB=U.bodyB,this.emit(T)}y.length=0}var V=this.preSolveEvent;V.contactEquations=k.contactEquations,V.frictionEquations=k.frictionEquations,this.emit(V),V.contactEquations=V.frictionEquations=null;B=l.length;for(r=0;r!==B;r++)l[r].update();if(k.contactEquations.length||k.frictionEquations.length||B)if(this.islandSplit){for(p.equations.length=0,s.appendArray(p.equations,k.contactEquations),s.appendArray(p.equations,k.frictionEquations),r=0;r!==B;r++)s.appendArray(p.equations,l[r].equations);p.split(this);for(r=0;r!==p.islands.length;r++){(W=p.islands[r]).equations.length&&h.solveIsland(a,W)}}else{for(h.addEquations(k.contactEquations),h.addEquations(k.frictionEquations),r=0;r!==B;r++)h.addEquations(l[r].equations);this.solveConstraints&&h.solve(a,this),h.removeAllEquations()}for(r=0;r!==i;r++){var S;(S=e[r]).integrate(a)}for(r=0;r!==i;r++)e[r].setZeroForce();if(this.emitImpactEvent&&this.has("impact")){var X=this.impactEvent;for(r=0;r!==k.contactEquations.length;r++){var Y=k.contactEquations[r];Y.firstImpact&&(X.bodyA=Y.bodyA,X.bodyB=Y.bodyB,X.shapeA=Y.shapeA,X.shapeB=Y.shapeB,X.contactEquation=Y,this.emit(X))}}if(this.sleepMode===d.BODY_SLEEPING)for(r=0;r!==i;r++)e[r].sleepTick(this.time,!1,a);else if(this.sleepMode===d.ISLAND_SLEEPING&&this.islandSplit){for(r=0;r!==i;r++)e[r].sleepTick(this.time,!0,a);for(r=0;r<this.islandManager.islands.length;r++){var W;(W=this.islandManager.islands[r]).wantsToSleep()&&W.sleep()}}this.stepping=!1;var Z=this.bodiesToBeRemoved;for(r=0;r!==Z.length;r++)this.removeBody(Z[r]);Z.length=0,this.emit(this.postStepEvent)},d.prototype.runNarrowphase=function(a,b,c,d,e,g,h,i,j,k,l){if(0!=(c.collisionGroup&h.collisionMask)&&0!=(h.collisionGroup&c.collisionMask)){f.rotate(w,d,b.angle),f.rotate(x,i,g.angle),f.add(w,w,b.position),f.add(x,x,g.position);var p,n=e+b.angle,o=j+g.angle;a.enableFriction=0<k.friction,a.frictionCoefficient=k.friction,p=b.type===m.STATIC||b.type===m.KINEMATIC?g.mass:g.type===m.STATIC||g.type===m.KINEMATIC?b.mass:b.mass*g.mass/(b.mass+g.mass),a.slipForce=k.friction*l*p,a.restitution=k.restitution,a.surfaceVelocity=k.surfaceVelocity,a.frictionStiffness=k.frictionStiffness,a.frictionRelaxation=k.frictionRelaxation,a.stiffness=k.stiffness,a.relaxation=k.relaxation,a.contactSkinSize=k.contactSkinSize,a.enabledEquations=b.collisionResponse&&g.collisionResponse&&c.collisionResponse&&h.collisionResponse;var q=a[c.type|h.type],r=0;if(q){var s=c.sensor||h.sensor,t=a.frictionEquations.length;r=c.type<h.type?q.call(a,b,c,w,n,g,h,x,o,s):q.call(a,g,h,x,o,b,c,w,n,s);var u=a.frictionEquations.length-t;if(r){if(b.allowSleep&&b.type===m.DYNAMIC&&b.sleepState===m.SLEEPING&&g.sleepState===m.AWAKE&&g.type!==m.STATIC&&f.squaredLength(g.velocity)+Math.pow(g.angularVelocity,2)>=2*Math.pow(g.sleepSpeedLimit,2)&&(b._wakeUpAfterNarrowphase=!0),g.allowSleep&&g.type===m.DYNAMIC&&g.sleepState===m.SLEEPING&&b.sleepState===m.AWAKE&&b.type!==m.STATIC&&f.squaredLength(b.velocity)+Math.pow(b.angularVelocity,2)>=2*Math.pow(b.sleepSpeedLimit,2)&&(g._wakeUpAfterNarrowphase=!0),this.overlapKeeper.setOverlapping(b,c,g,h),this.has("beginContact")&&this.overlapKeeper.isNewOverlap(c,h)){var v=this.beginContactEvent;if(v.shapeA=c,v.shapeB=h,v.bodyA=b,v.bodyB=g,v.contactEquations.length=0,"number"==typeof r)for(var y=a.contactEquations.length-r;y<a.contactEquations.length;y++)v.contactEquations.push(a.contactEquations[y]);this.emit(v)}if("number"==typeof r&&1<u)for(y=a.frictionEquations.length-u;y<a.frictionEquations.length;y++){var z=a.frictionEquations[y];z.setSlipForce(z.getSlipForce()/u)}}}}},d.prototype.addSpring=function(a){this.springs.push(a);var b=this.addSpringEvent;b.spring=a,this.emit(b),b.spring=null},d.prototype.removeSpring=function(a){var b=this.springs.indexOf(a);-1!==b&&s.splice(this.springs,b,1)},d.prototype.addBody=function(a){if(-1===this.bodies.indexOf(a)){this.bodies.push(a);var b=(a.world=this).addBodyEvent;b.body=a,this.emit(b),b.body=null}},d.prototype.removeBody=function(a){if(this.stepping)this.bodiesToBeRemoved.push(a);else{a.world=null;var b=this.bodies.indexOf(a);-1!==b&&(s.splice(this.bodies,b,1),(this.removeBodyEvent.body=a).resetConstraintVelocity(),this.emit(this.removeBodyEvent),this.removeBodyEvent.body=null)}},d.prototype.getBodyById=function(a){for(var b=this.bodies,c=0;c<b.length;c++){var d=b[c];if(d.id===a)return d}return!1},d.prototype.disableBodyCollision=function(a,b){this.disabledBodyCollisionPairs.push(a,b)},d.prototype.enableBodyCollision=function(a,b){for(var c=this.disabledBodyCollisionPairs,d=0;d<c.length;d+=2)if(c[d]===a&&c[d+1]===b||c[d+1]===a&&c[d]===b)return void c.splice(d,2)},d.prototype.clear=function(){this.time=0,this.solver&&this.solver.equations.length&&this.solver.removeAllEquations();for(var a=this.constraints,b=a.length-1;0<=b;b--)this.removeConstraint(a[b]);var c=this.bodies;for(b=c.length-1;0<=b;b--)this.removeBody(c[b]);var e=this.springs;for(b=e.length-1;0<=b;b--)this.removeSpring(e[b]);var f=this.contactMaterials;for(b=f.length-1;0<=b;b--)this.removeContactMaterial(f[b]);d.apply(this)};var z=f.create(),A=(f.fromValues(0,0),f.fromValues(0,0));d.prototype.hitTest=function(a,b,c){c=c||0;var d=new m({position:a}),e=new k,l=a,o=z,p=A;d.addShape(e);for(var q=this.narrowphase,r=[],s=0,t=b.length;s!==t;s++)for(var u=b[s],v=0,w=u.shapes.length;v!==w;v++){var x=u.shapes[v];f.rotate(o,x.position,u.angle),f.add(o,o,u.position);var y=x.angle+u.angle;(x instanceof g&&q.circleParticle(u,x,o,y,d,e,l,0,!0)||x instanceof h&&q.particleConvex(d,e,l,0,u,x,o,y,!0)||x instanceof i&&q.particlePlane(d,e,l,0,u,x,o,y,!0)||x instanceof j&&q.particleCapsule(d,e,l,0,u,x,o,y,!0)||x instanceof k&&f.squaredLength(f.sub(p,o,a))<c*c)&&r.push(u)}return r},d.prototype.setGlobalStiffness=function(a){for(var b=this.constraints,c=0;c!==b.length;c++)for(var d=b[c],e=0;e!==d.equations.length;e++){var f=d.equations[e];f.stiffness=a,f.needsUpdate=!0}var g=this.contactMaterials;for(c=0;c!==g.length;c++){(d=g[c]).stiffness=d.frictionStiffness=a}(d=this.defaultContactMaterial).stiffness=d.frictionStiffness=a},d.prototype.setGlobalRelaxation=function(a){for(var b=0;b!==this.constraints.length;b++)for(var c=this.constraints[b],d=0;d!==c.equations.length;d++){var e=c.equations[d];e.relaxation=a,e.needsUpdate=!0}for(b=0;b!==this.contactMaterials.length;b++){(c=this.contactMaterials[b]).relaxation=c.frictionRelaxation=a}(c=this.defaultContactMaterial).relaxation=c.frictionRelaxation=a};var B=new p,C=[];d.prototype.raycast=function(a,b){return b.getAABB(B),this.broadphase.aabbQuery(this,B,C),b.intersectBodies(a,C),C.length=0,a.hasHit()}},{"../../package.json":6,"../collision/AABB":7,"../collision/Broadphase":8,"../collision/Narrowphase":10,"../collision/Ray":11,"../collision/SAPBroadphase":13,"../constraints/Constraint":14,"../constraints/DistanceConstraint":15,"../constraints/GearConstraint":16,"../constraints/LockConstraint":17,"../constraints/PrismaticConstraint":18,"../constraints/RevoluteConstraint":19,"../events/EventEmitter":26,"../material/ContactMaterial":27,"../material/Material":28,"../math/vec2":30,"../objects/Body":31,"../objects/LinearSpring":32,"../objects/RotationalSpring":33,"../shapes/Capsule":38,"../shapes/Circle":39,"../shapes/Convex":40,"../shapes/Line":42,"../shapes/Particle":43,"../shapes/Plane":44,"../shapes/Shape":45,"../solver/GSSolver":46,"../solver/Solver":47,"../utils/OverlapKeeper":52,"../utils/Utils":57,"./IslandManager":59}]},{},[36])(36)}),function(){var a=this,b=b||{};return b.game=null,b.WEBGL_RENDERER=0,b.CANVAS_RENDERER=1,b.VERSION="v2.2.9",b._UID=0,"undefined"!=typeof Float32Array?(b.Float32Array=Float32Array,b.Uint16Array=Uint16Array,b.Uint32Array=Uint32Array,b.ArrayBuffer=ArrayBuffer):(b.Float32Array=Array,b.Uint16Array=Array),b.PI_2=2*Math.PI,b.RAD_TO_DEG=180/Math.PI,b.DEG_TO_RAD=Math.PI/180,b.RETINA_PREFIX="@2x",b.DisplayObject=function(){this.position=new b.Point(0,0),this.scale=new b.Point(1,1),this.pivot=new b.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.renderable=!1,this.parent=null,this.worldAlpha=1,this.worldTransform=new b.Matrix,this.worldPosition=new b.Point(0,0),this.worldScale=new b.Point(1,1),this.worldRotation=0,this.filterArea=null,this._sr=0,this._cr=1,this._bounds=new b.Rectangle(0,0,0,0),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},b.DisplayObject.prototype.constructor=b.DisplayObject,b.DisplayObject.prototype={destroy:function(){if(this.children){for(var a=this.children.length;a--;)this.children[a].destroy();this.children=[]}this.hitArea=null,this.parent=null,this.worldTransform=null,this.filterArea=null,this.renderable=!1,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite()},updateTransform:function(a){if(!a&&!this.parent&&!this.game)return this;var c=this.parent;a?c=a:this.parent||(c=this.game.world);var d,e,f,g,h,i,j=c.worldTransform,k=this.worldTransform;return this.rotation%b.PI_2?(this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation)),d=this._cr*this.scale.x,e=this._sr*this.scale.x,f=-this._sr*this.scale.y,g=this._cr*this.scale.y,h=this.position.x,i=this.position.y,(this.pivot.x||this.pivot.y)&&(h-=this.pivot.x*d+this.pivot.y*f,i-=this.pivot.x*e+this.pivot.y*g),k.a=d*j.a+e*j.c,k.b=d*j.b+e*j.d,k.c=f*j.a+g*j.c,k.d=f*j.b+g*j.d):(d=this.scale.x,g=this.scale.y,h=this.position.x-this.pivot.x*d,i=this.position.y-this.pivot.y*g,k.a=d*j.a,k.b=d*j.b,k.c=g*j.c,k.d=g*j.d),k.tx=h*j.a+i*j.c+j.tx,k.ty=h*j.b+i*j.d+j.ty,this.worldAlpha=this.alpha*c.worldAlpha,this.worldPosition.set(k.tx,k.ty),this.worldScale.set(this.scale.x*Math.sqrt(k.a*k.a+k.c*k.c),this.scale.y*Math.sqrt(k.b*k.b+k.d*k.d)),this.worldRotation=Math.atan2(-k.c,k.d),this._currentBounds=null,this.transformCallback&&this.transformCallback.call(this.transformCallbackContext,k,j),this},preUpdate:function(){},generateTexture:function(a,c,d){var e=this.getLocalBounds(),f=new b.RenderTexture(0|e.width,0|e.height,d,c,a);return b.DisplayObject._tempMatrix.tx=-e.x,b.DisplayObject._tempMatrix.ty=-e.y,f.render(this,b.DisplayObject._tempMatrix),f},updateCache:function(){return this._generateCachedSprite(),this},toGlobal:function(a){return this.updateTransform(),this.worldTransform.apply(a)},toLocal:function(a,b){return b&&(a=b.toGlobal(a)),this.updateTransform(),this.worldTransform.applyInverse(a)},_renderCachedSprite:function(a){this._cachedSprite.worldAlpha=this.worldAlpha,a.gl?b.Sprite.prototype._renderWebGL.call(this._cachedSprite,a):b.Sprite.prototype._renderCanvas.call(this._cachedSprite,a)},_generateCachedSprite:function(){this._cacheAsBitmap=!1;var a=this.getLocalBounds();if(a.width=Math.max(1,Math.ceil(a.width)),a.height=Math.max(1,Math.ceil(a.height)),this.updateTransform(),this._cachedSprite)this._cachedSprite.texture.resize(a.width,a.height);else{var c=new b.RenderTexture(a.width,a.height);this._cachedSprite=new b.Sprite(c),this._cachedSprite.worldTransform=this.worldTransform}var d=this._filters;this._filters=null,this._cachedSprite.filters=d,b.DisplayObject._tempMatrix.tx=-a.x,b.DisplayObject._tempMatrix.ty=-a.y,this._cachedSprite.texture.render(this,b.DisplayObject._tempMatrix,!0),this._cachedSprite.anchor.x=-a.x/a.width,this._cachedSprite.anchor.y=-a.y/a.height,this._filters=d,this._cacheAsBitmap=!0},_destroyCachedSprite:function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)}},b.DisplayObject.prototype.displayObjectUpdateTransform=b.DisplayObject.prototype.updateTransform,Object.defineProperties(b.DisplayObject.prototype,{x:{get:function(){return this.position.x},set:function(a){this.position.x=a}},y:{get:function(){return this.position.y},set:function(a){this.position.y=a}},worldVisible:{get:function(){if(this.visible){var a=this.parent;if(!a)return this.visible;do{if(!a.visible)return!1;a=a.parent}while(a);return!0}return!1}},mask:{get:function(){return this._mask},set:function(a){this._mask&&(this._mask.isMask=!1),(this._mask=a)&&(this._mask.isMask=!0)}},filters:{get:function(){return this._filters},set:function(a){if(Array.isArray(a)){for(var c=[],d=0;d<a.length;d++)for(var e=a[d].passes,f=0;f<e.length;f++)c.push(e[f]);this._filterBlock={target:this,filterPasses:c}}this._filters=a,this.blendMode&&this.blendMode===b.blendModes.MULTIPLY&&(this.blendMode=b.blendModes.NORMAL)}},cacheAsBitmap:{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap!==a&&(a?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=a)}}}),b.DisplayObjectContainer=function(){b.DisplayObject.call(this),this.children=[],this.ignoreChildInput=!1},b.DisplayObjectContainer.prototype=Object.create(b.DisplayObject.prototype),b.DisplayObjectContainer.prototype.constructor=b.DisplayObjectContainer,b.DisplayObjectContainer.prototype.addChild=function(a){return this.addChildAt(a,this.children.length)},b.DisplayObjectContainer.prototype.addChildAt=function(a,b){if(0<=b&&b<=this.children.length)return a.parent&&a.parent.removeChild(a),(a.parent=this).children.splice(b,0,a),a;throw new Error(a+"addChildAt: The index "+b+" supplied is out of bounds "+this.children.length)},b.DisplayObjectContainer.prototype.swapChildren=function(a,b){if(a!==b){var c=this.getChildIndex(a),d=this.getChildIndex(b);if(c<0||d<0)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[c]=b,this.children[d]=a}},b.DisplayObjectContainer.prototype.getChildIndex=function(a){var b=this.children.indexOf(a);if(-1===b)throw new Error("The supplied DisplayObject must be a child of the caller");return b},b.DisplayObjectContainer.prototype.setChildIndex=function(a,b){if(b<0||b>=this.children.length)throw new Error("The supplied index is out of bounds");var c=this.getChildIndex(a);this.children.splice(c,1),this.children.splice(b,0,a)},b.DisplayObjectContainer.prototype.getChildAt=function(a){if(a<0||a>=this.children.length)throw new Error("getChildAt: Supplied index "+a+" does not exist in the child list, or the supplied DisplayObject must be a child of the caller");return this.children[a]},b.DisplayObjectContainer.prototype.removeChild=function(a){var b=this.children.indexOf(a);if(-1!==b)return this.removeChildAt(b)},b.DisplayObjectContainer.prototype.removeChildAt=function(a){var b=this.getChildAt(a);return b&&(b.parent=void 0,this.children.splice(a,1)),b},b.DisplayObjectContainer.prototype.removeChildren=function(a,b){void 0===a&&(a=0),void 0===b&&(b=this.children.length);var c=b-a;if(0<c&&c<=b){for(var d=this.children.splice(a,c),e=0;e<d.length;e++)d[e].parent=void 0;return d}if(0===c&&0===this.children.length)return[];throw new Error("removeChildren: Range Error, numeric values are outside the acceptable range")},b.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(this.displayObjectUpdateTransform(),!this._cacheAsBitmap))for(var a=0;a<this.children.length;a++)this.children[a].updateTransform()},b.DisplayObjectContainer.prototype.displayObjectContainerUpdateTransform=b.DisplayObjectContainer.prototype.updateTransform,b.DisplayObjectContainer.prototype.getBounds=function(a){var e,c=a&&a instanceof b.DisplayObject,d=!0;if(c?d=a instanceof b.DisplayObjectContainer&&a.contains(this):a=this,c){var f=a.worldTransform;for(a.worldTransform=b.identityMatrix,e=0;e<a.children.length;e++)a.children[e].updateTransform()}var g,h,i,j=1/0,k=1/0,l=-1/0,m=-1/0,n=!1;for(e=0;e<this.children.length;e++)this.children[e].visible&&(n=!0,j=j<(g=this.children[e].getBounds()).x?j:g.x,k=k<g.y?k:g.y,l=(h=g.width+g.x)<l?l:h,m=(i=g.height+g.y)<m?m:i);var o=this._bounds;if(!n){var p=(o=new b.Rectangle).x,q=o.width+o.x,r=o.y,s=o.height+o.y,t=this.worldTransform,u=t.a,v=t.b,w=t.c,x=t.d,y=t.tx,z=t.ty,A=u*q+w*s+y,B=x*s+v*q+z,C=u*p+w*s+y,D=x*s+v*p+z,E=u*p+w*r+y,F=x*r+v*p+z,G=u*q+w*r+y,H=x*r+v*q+z;j=G<(j=E<(j=C<(j=l=A)?C:j)?E:j)?G:j,k=H<(k=F<(k=D<(k=m=B)?D:k)?F:k)?H:k,l=(l=(l=l<C?C:l)<E?E:l)<G?G:l,m=(m=(m=m<D?D:m)<F?F:m)<H?H:m}if(o.x=j,o.y=k,o.width=l-j,o.height=m-k,c)for(a.worldTransform=f,e=0;e<a.children.length;e++)a.children[e].updateTransform();if(!d){var I=a.getBounds();o.x-=I.x,o.y-=I.y}return o},b.DisplayObjectContainer.prototype.getLocalBounds=function(){return this.getBounds(this)},b.DisplayObjectContainer.prototype.contains=function(a){return!!a&&(a===this||this.contains(a.parent))},b.DisplayObjectContainer.prototype._renderWebGL=function(a){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);var b;if(this._mask||this._filters){for(this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),a.spriteBatch.start()}else for(b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a)}},b.DisplayObjectContainer.prototype._renderCanvas=function(a){if(!1!==this.visible&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(a);this._mask&&a.maskManager.pushMask(this._mask,a);for(var b=0;b<this.children.length;b++)this.children[b]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},Object.defineProperty(b.DisplayObjectContainer.prototype,"width",{get:function(){return this.getLocalBounds().width*this.scale.x},set:function(a){var b=this.getLocalBounds().width;this.scale.x=0!==b?a/b:1,this._width=a}}),Object.defineProperty(b.DisplayObjectContainer.prototype,"height",{get:function(){return this.getLocalBounds().height*this.scale.y},set:function(a){var b=this.getLocalBounds().height;this.scale.y=0!==b?a/b:1,this._height=a}}),b.Sprite=function(a){b.DisplayObjectContainer.call(this),this.anchor=new b.Point,this.texture=a||b.Texture.emptyTexture,this._width=0,this._height=0,this.tint=16777215,this.cachedTint=-1,this.tintedTexture=null,this.blendMode=b.blendModes.NORMAL,this.shader=null,this.exists=!0,this.texture.baseTexture.hasLoaded&&this.onTextureUpdate(),this.renderable=!0},b.Sprite.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Sprite.prototype.constructor=b.Sprite,Object.defineProperty(b.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(b.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),b.Sprite.prototype.setTexture=function(a,b){void 0!==b&&this.texture.baseTexture.destroy(),this.texture.baseTexture.skipRender=!1,this.texture=a,this.texture.valid=!0,this.cachedTint=-1},b.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},b.Sprite.prototype.getBounds=function(a){var b=this.texture.frame.width,c=this.texture.frame.height,d=b*(1-this.anchor.x),e=b*-this.anchor.x,f=c*(1-this.anchor.y),g=c*-this.anchor.y,h=a||this.worldTransform,i=h.a,j=h.b,k=h.c,l=h.d,m=h.tx,n=h.ty,o=-1/0,p=-1/0,q=1/0,r=1/0;if(0===j&&0===k){if(i<0){i*=-1;var s=d;d=-e,e=-s}if(l<0){l*=-1;s=f;f=-g,g=-s}q=i*e+m,o=i*d+m,r=l*g+n,p=l*f+n}else{var t=i*e+k*g+m,u=l*g+j*e+n,v=i*d+k*g+m,w=l*g+j*d+n,x=i*d+k*f+m,y=l*f+j*d+n,z=i*e+k*f+m,A=l*f+j*e+n;q=z<(q=x<(q=v<(q=t<q?t:q)?v:q)?x:q)?z:q,r=A<(r=y<(r=w<(r=u<r?u:r)?w:r)?y:r)?A:r,o=(o=(o=(o=o<t?t:o)<v?v:o)<x?x:o)<z?z:o,p=(p=(p=(p=p<u?u:p)<w?w:p)<y?y:p)<A?A:p}var B=this._bounds;return B.x=q,B.width=o-q,B.y=r,B.height=p-r,this._currentBounds=B},b.Sprite.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=b.identityMatrix;for(var c=0;c<this.children.length;c++)this.children[c].updateTransform();var d=this.getBounds();for(this.worldTransform=a,c=0;c<this.children.length;c++)this.children[c].updateTransform();return d},b.Sprite.prototype._renderWebGL=function(a,b){if(this.visible&&!(this.alpha<=0)&&this.renderable){var c=this.worldTransform;if(b&&(c=b),this._mask||this._filters){var d=a.spriteBatch;this._filters&&(d.flush(),a.filterManager.pushFilter(this._filterBlock)),this._mask&&(d.stop(),a.maskManager.pushMask(this.mask,a),d.start()),d.render(this);for(var e=0;e<this.children.length;e++)this.children[e]._renderWebGL(a);d.stop(),this._mask&&a.maskManager.popMask(this._mask,a),this._filters&&a.filterManager.popFilter(),d.start()}else{a.spriteBatch.render(this);for(e=0;e<this.children.length;e++)this.children[e]._renderWebGL(a,c)}}},b.Sprite.prototype._renderCanvas=function(a,c){if(!(!this.visible||0===this.alpha||!this.renderable||this.texture.crop.width<=0||this.texture.crop.height<=0)){var d=this.worldTransform;if(c&&(d=c),this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,a.context.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a),this.texture.valid){var e=this.texture.baseTexture.resolution/a.resolution;a.context.globalAlpha=this.worldAlpha,a.smoothProperty&&a.scaleMode!==this.texture.baseTexture.scaleMode&&(a.scaleMode=this.texture.baseTexture.scaleMode,a.context[a.smoothProperty]=a.scaleMode===b.scaleModes.LINEAR);var f=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,g=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height,h=d.tx*a.resolution+a.shakeX,i=d.ty*a.resolution+a.shakeY;a.roundPixels?(a.context.setTransform(d.a,d.b,d.c,d.d,0|h,0|i),f|=0,g|=0):a.context.setTransform(d.a,d.b,d.c,d.d,h,i);var j=this.texture.crop.width,k=this.texture.crop.height;if(f/=e,g/=e,16777215!==this.tint)(this.texture.requiresReTint||this.cachedTint!==this.tint)&&(this.tintedTexture=b.CanvasTinter.getTintedTexture(this,this.tint),this.cachedTint=this.tint,this.texture.requiresReTint=!1),a.context.drawImage(this.tintedTexture,0,0,j,k,f,g,j/e,k/e);else{var l=this.texture.crop.x,m=this.texture.crop.y;a.context.drawImage(this.texture.baseTexture.source,l,m,j,k,f,g,j/e,k/e)}}for(var n=0;n<this.children.length;n++)this.children[n]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},b.SpriteBatch=function(a){b.DisplayObjectContainer.call(this),this.textureThing=a,this.ready=!1},b.SpriteBatch.prototype=Object.create(b.DisplayObjectContainer.prototype),b.SpriteBatch.prototype.constructor=b.SpriteBatch,b.SpriteBatch.prototype.initWebGL=function(a){this.fastSpriteBatch=new b.WebGLFastSpriteBatch(a),this.ready=!0},b.SpriteBatch.prototype.updateTransform=function(){this.displayObjectUpdateTransform()},b.SpriteBatch.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||!this.children.length||(this.ready||this.initWebGL(a.gl),this.fastSpriteBatch.gl!==a.gl&&this.fastSpriteBatch.setContext(a.gl),a.spriteBatch.stop(),a.shaderManager.setShader(a.shaderManager.fastShader),this.fastSpriteBatch.begin(this,a),this.fastSpriteBatch.render(this),a.spriteBatch.start())},b.SpriteBatch.prototype._renderCanvas=function(a){if(this.visible&&!(this.alpha<=0)&&this.children.length){var b=a.context;b.globalAlpha=this.worldAlpha,this.displayObjectUpdateTransform();for(var c=this.worldTransform,d=!0,e=0;e<this.children.length;e++){var f=this.children[e];if(f.visible){var g=f.texture,h=g.frame;if(b.globalAlpha=this.worldAlpha*f.alpha,f.rotation%(2*Math.PI)==0)d&&(b.setTransform(c.a,c.b,c.c,c.d,c.tx,c.ty),d=!1),b.drawImage(g.baseTexture.source,h.x,h.y,h.width,h.height,f.anchor.x*(-h.width*f.scale.x)+f.position.x+.5+a.shakeX|0,f.anchor.y*(-h.height*f.scale.y)+f.position.y+.5+a.shakeY|0,h.width*f.scale.x,h.height*f.scale.y);else{d||(d=!0),f.displayObjectUpdateTransform();var i=f.worldTransform,j=i.tx*a.resolution+a.shakeX,k=i.ty*a.resolution+a.shakeY;a.roundPixels?b.setTransform(i.a,i.b,i.c,i.d,0|j,0|k):b.setTransform(i.a,i.b,i.c,i.d,j,k),b.drawImage(g.baseTexture.source,h.x,h.y,h.width,h.height,f.anchor.x*-h.width+.5|0,f.anchor.y*-h.height+.5|0,h.width,h.height)}}}}},b.hex2rgb=function(a){return[(a>>16&255)/255,(a>>8&255)/255,(255&a)/255]},b.rgb2hex=function(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]},b.canUseNewCanvasBlendModes=function(){if(void 0===document)return!1;var a="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAABAQMAAADD8p2OAAAAA1BMVEX/",c="AAAACklEQVQI12NgAAAAAgAB4iG8MwAAAABJRU5ErkJggg==",d=new Image;d.src=a+"AP804Oa6"+c;var e=new Image;e.src=a+"/wCKxvRF"+c;var g=b.CanvasPool.create(this,6,1).getContext("2d");if(g.globalCompositeOperation="multiply",g.drawImage(d,0,0),g.drawImage(e,2,0),!g.getImageData(2,0,1,1))return!1;var h=g.getImageData(2,0,1,1).data;return b.CanvasPool.remove(this),255===h[0]&&0===h[1]&&0===h[2]},b.getNextPowerOfTwo=function(a){if(0<a&&0==(a&a-1))return a;for(var b=1;b<a;)b<<=1;return b},b.isPowerOfTwo=function(a,b){return 0<a&&0==(a&a-1)&&0<b&&0==(b&b-1)},b.CanvasPool={create:function(a,c,d){var e,f=b.CanvasPool.getFirst();if(-1===f){var g={parent:a,canvas:document.createElement("canvas")};b.CanvasPool.pool.push(g),e=g.canvas}else b.CanvasPool.pool[f].parent=a,e=b.CanvasPool.pool[f].canvas;return void 0!==c&&(e.width=c,e.height=d),e},getFirst:function(){for(var a=b.CanvasPool.pool,c=0;c<a.length;c++)if(!a[c].parent)return c;return-1},remove:function(a){for(var c=b.CanvasPool.pool,d=0;d<c.length;d++)c[d].parent===a&&(c[d].parent=null,c[d].canvas.width=1,c[d].canvas.height=1)},removeByCanvas:function(a){for(var c=b.CanvasPool.pool,d=0;d<c.length;d++)c[d].canvas===a&&(c[d].parent=null,c[d].canvas.width=1,c[d].canvas.height=1)},getTotal:function(){for(var a=b.CanvasPool.pool,c=0,d=0;d<a.length;d++)a[d].parent&&c++;return c},getFree:function(){for(var a=b.CanvasPool.pool,c=0,d=0;d<a.length;d++)a[d].parent||c++;return c}},b.CanvasPool.pool=[],b.initDefaultShaders=function(){},b.CompileVertexShader=function(a,c){return b._CompileShader(a,c,a.VERTEX_SHADER)},b.CompileFragmentShader=function(a,c){return b._CompileShader(a,c,a.FRAGMENT_SHADER)},b._CompileShader=function(a,b,c){var d=b;Array.isArray(b)&&(d=b.join("\n"));var e=a.createShader(c);return a.shaderSource(e,d),a.compileShader(e),a.getShaderParameter(e,a.COMPILE_STATUS)?e:(window.console.log(a.getShaderInfoLog(e)),null)},b.compileProgram=function(a,c,d){var e=b.CompileFragmentShader(a,d),f=b.CompileVertexShader(a,c),g=a.createProgram();return a.attachShader(g,f),a.attachShader(g,e),a.linkProgram(g),a.getProgramParameter(g,a.LINK_STATUS)||(window.console.log(a.getProgramInfoLog(g)),window.console.log("Could not initialise shaders")),g},b.PixiShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.firstRun=!0,this.dirty=!0,this.attributes=[],this.init()},b.PixiShader.prototype.constructor=b.PixiShader,b.PixiShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc||b.PixiShader.defaultVertexSrc,this.fragmentSrc);for(var d in a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.dimensions=a.getUniformLocation(c,"dimensions"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(c,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute],this.uniforms)this.uniforms[d].uniformLocation=a.getUniformLocation(c,d);this.initUniforms(),this.program=c},b.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var a,b=this.gl;for(var c in this.uniforms){var d=(a=this.uniforms[c]).type;"sampler2D"===d?(a._init=!1,null!==a.value&&this.initSampler2D(a)):"mat2"===d||"mat3"===d||"mat4"===d?(a.glMatrix=!0,a.glValueLength=1,"mat2"===d?a.glFunc=b.uniformMatrix2fv:"mat3"===d?a.glFunc=b.uniformMatrix3fv:"mat4"===d&&(a.glFunc=b.uniformMatrix4fv)):(a.glFunc=b["uniform"+d],a.glValueLength="2f"===d||"2i"===d?2:"3f"===d||"3i"===d?3:"4f"===d||"4i"===d?4:1)}},b.PixiShader.prototype.initSampler2D=function(a){if(a.value&&a.value.baseTexture&&a.value.baseTexture.hasLoaded){var b=this.gl;if(b.activeTexture(b["TEXTURE"+this.textureCount]),b.bindTexture(b.TEXTURE_2D,a.value.baseTexture._glTextures[b.id]),a.textureData){var c=a.textureData,d=c.magFilter?c.magFilter:b.LINEAR,e=c.minFilter?c.minFilter:b.LINEAR,f=c.wrapS?c.wrapS:b.CLAMP_TO_EDGE,g=c.wrapT?c.wrapT:b.CLAMP_TO_EDGE,h=c.luminance?b.LUMINANCE:b.RGBA;if(c.repeat&&(f=b.REPEAT,g=b.REPEAT),b.pixelStorei(b.UNPACK_FLIP_Y_WEBGL,!!c.flipY),c.width){var i=c.width?c.width:512,j=c.height?c.height:2,k=c.border?c.border:0;b.texImage2D(b.TEXTURE_2D,0,h,i,j,k,h,b.UNSIGNED_BYTE,null)}else b.texImage2D(b.TEXTURE_2D,0,h,b.RGBA,b.UNSIGNED_BYTE,a.value.baseTexture.source);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,d),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,f),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,g)}b.uniform1i(a.uniformLocation,this.textureCount),a._init=!0,this.textureCount++}},b.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var a,c=this.gl;for(var d in this.uniforms)1===(a=this.uniforms[d]).glValueLength?!0===a.glMatrix?a.glFunc.call(c,a.uniformLocation,a.transpose,a.value):a.glFunc.call(c,a.uniformLocation,a.value):2===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y):3===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y,a.value.z):4===a.glValueLength?a.glFunc.call(c,a.uniformLocation,a.value.x,a.value.y,a.value.z,a.value.w):"sampler2D"===a.type&&(a._init?(c.activeTexture(c["TEXTURE"+this.textureCount]),a.value.baseTexture._dirty[c.id]?b.instances[c.id].updateTexture(a.value.baseTexture):c.bindTexture(c.TEXTURE_2D,a.value.baseTexture._glTextures[c.id]),c.uniform1i(a.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(a))},b.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec4 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = vec4(aColor.rgb * aColor.a, aColor.a);","}"],b.PixiFastShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {"," vec2 v;"," vec2 sv = aVertexPosition * aScale;"," v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);"," v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);"," v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;"," gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);"," vTextureCoord = aTextureCoord;"," vColor = aColor;","}"],this.textureCount=0,this.init()},b.PixiFastShader.prototype.constructor=b.PixiFastShader,b.PixiFastShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.dimensions=a.getUniformLocation(c,"dimensions"),this.uMatrix=a.getUniformLocation(c,"uMatrix"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aPositionCoord=a.getAttribLocation(c,"aPositionCoord"),this.aScale=a.getAttribLocation(c,"aScale"),this.aRotation=a.getAttribLocation(c,"aRotation"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.colorAttribute=a.getAttribLocation(c,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=c},b.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.StripShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * alpha;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);"," vTextureCoord = aTextureCoord;","}"],this.init()},b.StripShader.prototype.constructor=b.StripShader,b.StripShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.uSampler=a.getUniformLocation(c,"uSampler"),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.colorAttribute=a.getAttribLocation(c,"aColor"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.aTextureCoord=a.getAttribLocation(c,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.StripShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},b.PrimitiveShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform float flipY;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},b.PrimitiveShader.prototype.constructor=b.PrimitiveShader,b.PrimitiveShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.tintColor=a.getUniformLocation(c,"tint"),this.flipY=a.getUniformLocation(c,"flipY"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.colorAttribute=a.getAttribLocation(c,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},b.ComplexPrimitiveShader=function(a){this._UID=b._UID++,this.gl=a,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {"," gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","uniform float flipY;","varying vec4 vColor;","void main(void) {"," vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);"," v -= offsetVector.xyx;"," gl_Position = vec4( v.x / projectionVector.x -1.0, (v.y / projectionVector.y * -flipY) + flipY , 0.0, 1.0);"," vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},b.ComplexPrimitiveShader.prototype.constructor=b.ComplexPrimitiveShader,b.ComplexPrimitiveShader.prototype.init=function(){var a=this.gl,c=b.compileProgram(a,this.vertexSrc,this.fragmentSrc);a.useProgram(c),this.projectionVector=a.getUniformLocation(c,"projectionVector"),this.offsetVector=a.getUniformLocation(c,"offsetVector"),this.tintColor=a.getUniformLocation(c,"tint"),this.color=a.getUniformLocation(c,"color"),this.flipY=a.getUniformLocation(c,"flipY"),this.aVertexPosition=a.getAttribLocation(c,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=a.getUniformLocation(c,"translationMatrix"),this.alpha=a.getUniformLocation(c,"alpha"),this.program=c},b.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},b.glContexts=[],b.instances=[],b.WebGLRenderer=function(a){this.game=a,b.defaultRenderer||(b.defaultRenderer=this),this.type=b.WEBGL_RENDERER,this.resolution=a.resolution,this.transparent=a.transparent,this.autoResize=!1,this.preserveDrawingBuffer=a.preserveDrawingBuffer,this.clearBeforeRender=a.clearBeforeRender,this.width=a.width,this.height=a.height,this.view=a.canvas,this._contextOptions={alpha:this.transparent,antialias:a.antialias,premultipliedAlpha:this.transparent&&"notMultiplied"!==this.transparent,stencil:!0,preserveDrawingBuffer:this.preserveDrawingBuffer},this.projection=new b.Point,this.offset=new b.Point,this.shaderManager=new b.WebGLShaderManager,this.spriteBatch=new b.WebGLSpriteBatch,this.maskManager=new b.WebGLMaskManager,this.filterManager=new b.WebGLFilterManager,this.stencilManager=new b.WebGLStencilManager,this.blendModeManager=new b.WebGLBlendModeManager,this.renderSession={},this.renderSession.game=this.game,this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,(this.renderSession.renderer=this).renderSession.resolution=this.resolution,this.initContext(),this.mapBlendModes()},b.WebGLRenderer.prototype.constructor=b.WebGLRenderer,b.WebGLRenderer.prototype.initContext=function(){var a=this.view.getContext("webgl",this._contextOptions)||this.view.getContext("experimental-webgl",this._contextOptions);if(!(this.gl=a))throw new Error("This browser does not support webGL. Try using the canvas renderer");this.glContextId=a.id=b.WebGLRenderer.glContextId++,b.glContexts[this.glContextId]=a,b.instances[this.glContextId]=this,a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),this.shaderManager.setContext(a),this.spriteBatch.setContext(a),this.maskManager.setContext(a),this.filterManager.setContext(a),this.blendModeManager.setContext(a),this.stencilManager.setContext(a),this.renderSession.gl=this.gl,this.resize(this.width,this.height)},b.WebGLRenderer.prototype.render=function(a){if(!this.contextLost){var b=this.gl;b.viewport(0,0,this.width,this.height),b.bindFramebuffer(b.FRAMEBUFFER,null),this.game.clearBeforeRender&&(b.clearColor(a._bgColor.r,a._bgColor.g,a._bgColor.b,a._bgColor.a),b.clear(b.COLOR_BUFFER_BIT)),this.offset.x=this.game.camera._shake.x,this.offset.y=this.game.camera._shake.y,this.renderDisplayObject(a,this.projection)}},b.WebGLRenderer.prototype.renderDisplayObject=function(a,c,d,e){this.renderSession.blendModeManager.setBlendMode(b.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.flipY=d?-1:1,this.renderSession.projection=c,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,d),a._renderWebGL(this.renderSession,e),this.spriteBatch.end()},b.WebGLRenderer.prototype.resize=function(a,b){this.width=a*this.resolution,this.height=b*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2/this.resolution,this.projection.y=-this.height/2/this.resolution},b.WebGLRenderer.prototype.updateTexture=function(a){if(!a.hasLoaded)return!1;var c=this.gl;return a._glTextures[c.id]||(a._glTextures[c.id]=c.createTexture()),c.bindTexture(c.TEXTURE_2D,a._glTextures[c.id]),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultipliedAlpha),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,a.source),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a.mipmap&&b.isPowerOfTwo(a.width,a.height)?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR_MIPMAP_LINEAR:c.NEAREST_MIPMAP_NEAREST),c.generateMipmap(c.TEXTURE_2D)):c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,a.scaleMode===b.scaleModes.LINEAR?c.LINEAR:c.NEAREST),a._powerOf2?(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.REPEAT),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.REPEAT)):(c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE)),!(a._dirty[c.id]=!1)},b.WebGLRenderer.prototype.destroy=function(){b.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null,b.CanvasPool.remove(this),b.instances[this.glContextId]=null,b.WebGLRenderer.glContextId--},b.WebGLRenderer.prototype.mapBlendModes=function(){var a=this.gl;if(!b.blendModesWebGL){var c=[],d=b.blendModes;c[d.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],c[d.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],c[d.SCREEN]=[a.SRC_ALPHA,a.ONE],c[d.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],c[d.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],b.blendModesWebGL=c}},b.WebGLRenderer.glContextId=0,b.WebGLBlendModeManager=function(){this.currentBlendMode=99999},b.WebGLBlendModeManager.prototype.constructor=b.WebGLBlendModeManager,b.WebGLBlendModeManager.prototype.setContext=function(a){this.gl=a},b.WebGLBlendModeManager.prototype.setBlendMode=function(a){if(this.currentBlendMode===a)return!1;this.currentBlendMode=a;var c=b.blendModesWebGL[this.currentBlendMode];return c&&this.gl.blendFunc(c[0],c[1]),!0},b.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},b.WebGLMaskManager=function(){},b.WebGLMaskManager.prototype.constructor=b.WebGLMaskManager,b.WebGLMaskManager.prototype.setContext=function(a){this.gl=a},b.WebGLMaskManager.prototype.pushMask=function(a,c){var d=c.gl;a.dirty&&b.WebGLGraphics.updateGraphics(a,d),void 0!==a._webGL[d.id]&&void 0!==a._webGL[d.id].data&&0!==a._webGL[d.id].data.length&&c.stencilManager.pushStencil(a,a._webGL[d.id].data[0],c)},b.WebGLMaskManager.prototype.popMask=function(a,b){var c=this.gl;void 0!==a._webGL[c.id]&&void 0!==a._webGL[c.id].data&&0!==a._webGL[c.id].data.length&&b.stencilManager.popStencil(a,a._webGL[c.id].data[0],b)},b.WebGLMaskManager.prototype.destroy=function(){this.gl=null},b.WebGLStencilManager=function(){this.stencilStack=[],this.reverse=!0,this.count=0},b.WebGLStencilManager.prototype.setContext=function(a){this.gl=a},b.WebGLStencilManager.prototype.pushStencil=function(a,b,c){var d=this.gl;this.bindGraphics(a,b,c),0===this.stencilStack.length&&(d.enable(d.STENCIL_TEST),d.clear(d.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(b);var e=this.count;d.colorMask(!1,!1,!1,!1),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),1===b.mode?(d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0),this.reverse?(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),this.reverse?d.stencilFunc(d.EQUAL,255-(e+1),255):d.stencilFunc(d.EQUAL,e+1,255),this.reverse=!this.reverse):(this.reverse?(d.stencilFunc(d.EQUAL,e,255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,255-e,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0),this.reverse?d.stencilFunc(d.EQUAL,e+1,255):d.stencilFunc(d.EQUAL,255-(e+1),255)),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP),this.count++},b.WebGLStencilManager.prototype.bindGraphics=function(a,c,d){this._currentGraphics=a;var e,f=this.gl,g=d.projection,h=d.offset;1===c.mode?(e=d.shaderManager.complexPrimitiveShader,d.shaderManager.setShader(e),f.uniform1f(e.flipY,d.flipY),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,b.hex2rgb(a.tint)),f.uniform3fv(e.color,c.color),f.uniform1f(e.alpha,a.worldAlpha*c.alpha),f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,8,0)):(e=d.shaderManager.primitiveShader,d.shaderManager.setShader(e),f.uniformMatrix3fv(e.translationMatrix,!1,a.worldTransform.toArray(!0)),f.uniform1f(e.flipY,d.flipY),f.uniform2f(e.projectionVector,g.x,-g.y),f.uniform2f(e.offsetVector,-h.x,-h.y),f.uniform3fv(e.tintColor,b.hex2rgb(a.tint)),f.uniform1f(e.alpha,a.worldAlpha),f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(e.aVertexPosition,2,f.FLOAT,!1,24,0),f.vertexAttribPointer(e.colorAttribute,4,f.FLOAT,!1,24,8)),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,c.indexBuffer)},b.WebGLStencilManager.prototype.popStencil=function(a,b,c){var d=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)d.disable(d.STENCIL_TEST);else{var e=this.count;this.bindGraphics(a,b,c),d.colorMask(!1,!1,!1,!1),1===b.mode?(this.reverse=!this.reverse,this.reverse?(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)):(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(b.indices.length-4)),d.stencilFunc(d.ALWAYS,0,255),d.stencilOp(d.KEEP,d.KEEP,d.INVERT),d.drawElements(d.TRIANGLE_FAN,b.indices.length-4,d.UNSIGNED_SHORT,0)):(this.reverse?(d.stencilFunc(d.EQUAL,e+1,255),d.stencilOp(d.KEEP,d.KEEP,d.DECR)):(d.stencilFunc(d.EQUAL,255-(e+1),255),d.stencilOp(d.KEEP,d.KEEP,d.INCR)),d.drawElements(d.TRIANGLE_STRIP,b.indices.length,d.UNSIGNED_SHORT,0)),this.reverse?d.stencilFunc(d.EQUAL,e,255):d.stencilFunc(d.EQUAL,255-e,255),d.colorMask(!0,!0,!0,!0),d.stencilOp(d.KEEP,d.KEEP,d.KEEP)}},b.WebGLStencilManager.prototype.destroy=function(){this.stencilStack=null,this.gl=null},b.WebGLShaderManager=function(){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[];for(var a=0;a<this.maxAttibs;a++)this.attribState[a]=!1;this.stack=[]},b.WebGLShaderManager.prototype.constructor=b.WebGLShaderManager,b.WebGLShaderManager.prototype.setContext=function(a){this.gl=a,this.primitiveShader=new b.PrimitiveShader(a),this.complexPrimitiveShader=new b.ComplexPrimitiveShader(a),this.defaultShader=new b.PixiShader(a),this.fastShader=new b.PixiFastShader(a),this.stripShader=new b.StripShader(a),this.setShader(this.defaultShader)},b.WebGLShaderManager.prototype.setAttribs=function(a){var b;for(b=0;b<this.tempAttribState.length;b++)this.tempAttribState[b]=!1;for(b=0;b<a.length;b++){var c=a[b];this.tempAttribState[c]=!0}var d=this.gl;for(b=0;b<this.attribState.length;b++)this.attribState[b]!==this.tempAttribState[b]&&(this.attribState[b]=this.tempAttribState[b],this.tempAttribState[b]?d.enableVertexAttribArray(b):d.disableVertexAttribArray(b))},b.WebGLShaderManager.prototype.setShader=function(a){return this._currentId!==a._UID&&(this._currentId=a._UID,this.currentShader=a,this.gl.useProgram(a.program),this.setAttribs(a.attributes),!0)},b.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.complexPrimitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null},b.WebGLSpriteBatch=function(){this.vertSize=5,this.size=2e3;var a=4*this.size*4*this.vertSize,c=6*this.size;this.vertices=new b.ArrayBuffer(a),this.positions=new b.Float32Array(this.vertices),this.colors=new b.Uint32Array(this.vertices),this.indices=new b.Uint16Array(c);for(var d=this.lastIndexCount=0,e=0;d<c;d+=6,e+=4)this.indices[d+0]=e+0,this.indices[d+1]=e+1,this.indices[d+2]=e+2,this.indices[d+3]=e+0,this.indices[d+4]=e+2,this.indices[d+5]=e+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.dirty=!0,this.textures=[],this.blendModes=[],this.shaders=[],this.sprites=[],this.defaultShader=new b.AbstractFilter(["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {"," gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"])},b.WebGLSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW),this.currentBlendMode=99999;var c=new b.PixiShader(a);c.fragmentSrc=this.defaultShader.fragmentSrc,c.uniforms={},c.init(),this.defaultShader.shaders[a.id]=c},b.WebGLSpriteBatch.prototype.begin=function(a){this.renderSession=a,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},b.WebGLSpriteBatch.prototype.end=function(){this.flush()},b.WebGLSpriteBatch.prototype.render=function(a,b){var c=a.texture,d=a.worldTransform;b&&(d=b),this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture);var e=c._uvs;if(e){var f,g,h,i,j=a.anchor.x,k=a.anchor.y;if(c.trim){var l=c.trim;f=(g=l.x-j*l.width)+c.crop.width,h=(i=l.y-k*l.height)+c.crop.height}else f=c.frame.width*(1-j),g=c.frame.width*-j,h=c.frame.height*(1-k),i=c.frame.height*-k;var m=4*this.currentBatchSize*this.vertSize,n=c.baseTexture.resolution,o=d.a/n,p=d.b/n,q=d.c/n,r=d.d/n,s=d.tx,t=d.ty,u=this.colors,v=this.positions;this.renderSession.roundPixels?(v[m]=o*g+q*i+s|0,v[m+1]=r*i+p*g+t|0,v[m+5]=o*f+q*i+s|0,v[m+6]=r*i+p*f+t|0,v[m+10]=o*f+q*h+s|0,v[m+11]=r*h+p*f+t|0,v[m+15]=o*g+q*h+s|0,v[m+16]=r*h+p*g+t|0):(v[m]=o*g+q*i+s,v[m+1]=r*i+p*g+t,v[m+5]=o*f+q*i+s,v[m+6]=r*i+p*f+t,v[m+10]=o*f+q*h+s,v[m+11]=r*h+p*f+t,v[m+15]=o*g+q*h+s,v[m+16]=r*h+p*g+t),v[m+2]=e.x0,v[m+3]=e.y0,v[m+7]=e.x1,v[m+8]=e.y1,v[m+12]=e.x2,v[m+13]=e.y2,v[m+17]=e.x3,v[m+18]=e.y3;var w=a.tint;u[m+4]=u[m+9]=u[m+14]=u[m+19]=(w>>16)+(65280&w)+((255&w)<<16)+(255*a.worldAlpha<<24),this.sprites[this.currentBatchSize++]=a}},b.WebGLSpriteBatch.prototype.renderTilingSprite=function(a){var c=a.tilingTexture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=c.baseTexture),a._uvs||(a._uvs=new b.TextureUvs);var d=a._uvs,e=c.baseTexture.width,f=c.baseTexture.height;a.tilePosition.x%=e*a.tileScaleOffset.x,a.tilePosition.y%=f*a.tileScaleOffset.y;var g=a.tilePosition.x/(e*a.tileScaleOffset.x),h=a.tilePosition.y/(f*a.tileScaleOffset.y),i=a.width/e/(a.tileScale.x*a.tileScaleOffset.x),j=a.height/f/(a.tileScale.y*a.tileScaleOffset.y);d.x0=0-g,d.y0=0-h,d.x1=1*i-g,d.y1=0-h,d.x2=1*i-g,d.y2=1*j-h,d.x3=0-g,d.y3=1*j-h;var k=a.tint,l=(k>>16)+(65280&k)+((255&k)<<16)+(255*a.worldAlpha<<24),m=this.positions,n=this.colors,o=a.width,p=a.height,q=a.anchor.x,r=a.anchor.y,s=o*(1-q),t=o*-q,u=p*(1-r),v=p*-r,w=4*this.currentBatchSize*this.vertSize,x=c.baseTexture.resolution,y=a.worldTransform,z=y.a/x,A=y.b/x,B=y.c/x,C=y.d/x,D=y.tx,E=y.ty;m[w++]=z*t+B*v+D,m[w++]=C*v+A*t+E,m[w++]=d.x0,m[w++]=d.y0,n[w++]=l,m[w++]=z*s+B*v+D,m[w++]=C*v+A*s+E,m[w++]=d.x1,m[w++]=d.y1,n[w++]=l,m[w++]=z*s+B*u+D,m[w++]=C*u+A*s+E,m[w++]=d.x2,m[w++]=d.y2,n[w++]=l,m[w++]=z*t+B*u+D,m[w++]=C*u+A*t+E,m[w++]=d.x3,m[w++]=d.y3,n[w++]=l,this.sprites[this.currentBatchSize++]=a},b.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a,c=this.gl;if(this.dirty){this.dirty=!1,c.activeTexture(c.TEXTURE0),c.bindBuffer(c.ARRAY_BUFFER,this.vertexBuffer),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a=this.defaultShader.shaders[c.id];var d=4*this.vertSize;c.vertexAttribPointer(a.aVertexPosition,2,c.FLOAT,!1,d,0),c.vertexAttribPointer(a.aTextureCoord,2,c.FLOAT,!1,d,8),c.vertexAttribPointer(a.colorAttribute,4,c.UNSIGNED_BYTE,!0,d,16)}if(this.currentBatchSize>.5*this.size)c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices);else{var e=this.positions.subarray(0,4*this.currentBatchSize*this.vertSize);c.bufferSubData(c.ARRAY_BUFFER,0,e)}for(var f,g,h,i,j=0,k=0,l=null,m=this.renderSession.blendModeManager.currentBlendMode,n=null,o=!1,p=!1,q=0,r=this.currentBatchSize;q<r;q++){f=(i=this.sprites[q]).tilingTexture?i.tilingTexture.baseTexture:i.texture.baseTexture,o=m!==(g=i.blendMode),p=n!==(h=i.shader||this.defaultShader);var s=f.skipRender;if(s&&0<i.children.length&&(s=!1),(l!==f&&!s||o||p)&&(this.renderBatch(l,j,k),k=q,j=0,l=f,o&&(m=g,this.renderSession.blendModeManager.setBlendMode(m)),p)){(a=(n=h).shaders[c.id])||((a=new b.PixiShader(c)).fragmentSrc=n.fragmentSrc,a.uniforms=n.uniforms,a.init(),n.shaders[c.id]=a),this.renderSession.shaderManager.setShader(a),a.dirty&&a.syncUniforms();var t=this.renderSession.projection;c.uniform2f(a.projectionVector,t.x,t.y);var u=this.renderSession.offset;c.uniform2f(a.offsetVector,u.x,u.y)}j++}this.renderBatch(l,j,k),this.currentBatchSize=0}},b.WebGLSpriteBatch.prototype.renderBatch=function(a,b,c){if(0!==b){var d=this.gl;if(a._dirty[d.id]){if(!this.renderSession.renderer.updateTexture(a))return}else d.bindTexture(d.TEXTURE_2D,a._glTextures[d.id]);d.drawElements(d.TRIANGLES,6*b,d.UNSIGNED_SHORT,6*c*2),this.renderSession.drawCount++}},b.WebGLSpriteBatch.prototype.stop=function(){this.flush(),this.dirty=!0},b.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},b.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},b.WebGLFastSpriteBatch=function(a){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var c=4*this.size*this.vertSize,d=6*this.maxSize;this.vertices=new b.Float32Array(c),this.indices=new b.Uint16Array(d),this.vertexBuffer=null,this.indexBuffer=null;for(var e=this.lastIndexCount=0,f=0;e<d;e+=6,f+=4)this.indices[e+0]=f+0,this.indices[e+1]=f+1,this.indices[e+2]=f+2,this.indices[e+3]=f+0,this.indices[e+4]=f+2,this.indices[e+5]=f+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(a)},b.WebGLFastSpriteBatch.prototype.constructor=b.WebGLFastSpriteBatch,b.WebGLFastSpriteBatch.prototype.setContext=function(a){this.gl=a,this.vertexBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.indices,a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertices,a.DYNAMIC_DRAW)},b.WebGLFastSpriteBatch.prototype.begin=function(a,b){this.renderSession=b,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=a.worldTransform.toArray(!0),this.start()},b.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},b.WebGLFastSpriteBatch.prototype.render=function(a){var b=a.children,c=b[0];if(c.texture._uvs){this.currentBaseTexture=c.texture.baseTexture,c.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(c.blendMode));for(var d=0,e=b.length;d<e;d++)this.renderSprite(b[d]);this.flush()}},b.WebGLFastSpriteBatch.prototype.renderSprite=function(a){if(a.visible&&(a.texture.baseTexture===this.currentBaseTexture||a.texture.baseTexture.skipRender||(this.flush(),this.currentBaseTexture=a.texture.baseTexture,a.texture._uvs))){var b,c,d,e,f,g,h=this.vertices;if(b=a.texture._uvs,a.texture.frame.width,a.texture.frame.height,a.texture.trim){var i=a.texture.trim;c=(d=i.x-a.anchor.x*i.width)+a.texture.crop.width,e=(f=i.y-a.anchor.y*i.height)+a.texture.crop.height}else c=a.texture.frame.width*(1-a.anchor.x),d=a.texture.frame.width*-a.anchor.x,e=a.texture.frame.height*(1-a.anchor.y),f=a.texture.frame.height*-a.anchor.y;g=4*this.currentBatchSize*this.vertSize,h[g++]=d,h[g++]=f,h[g++]=a.position.x,h[g++]=a.position.y,h[g++]=a.scale.x,h[g++]=a.scale.y,h[g++]=a.rotation,h[g++]=b.x0,h[g++]=b.y1,h[g++]=a.alpha,h[g++]=c,h[g++]=f,h[g++]=a.position.x,h[g++]=a.position.y,h[g++]=a.scale.x,h[g++]=a.scale.y,h[g++]=a.rotation,h[g++]=b.x1,h[g++]=b.y1,h[g++]=a.alpha,h[g++]=c,h[g++]=e,h[g++]=a.position.x,h[g++]=a.position.y,h[g++]=a.scale.x,h[g++]=a.scale.y,h[g++]=a.rotation,h[g++]=b.x2,h[g++]=b.y2,h[g++]=a.alpha,h[g++]=d,h[g++]=e,h[g++]=a.position.x,h[g++]=a.position.y,h[g++]=a.scale.x,h[g++]=a.scale.y,h[g++]=a.rotation,h[g++]=b.x3,h[g++]=b.y3,h[g++]=a.alpha,this.currentBatchSize++,this.currentBatchSize>=this.size&&this.flush()}},b.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var a=this.gl;if(this.currentBaseTexture._glTextures[a.id]||this.renderSession.renderer.updateTexture(this.currentBaseTexture,a),a.bindTexture(a.TEXTURE_2D,this.currentBaseTexture._glTextures[a.id]),this.currentBatchSize>.5*this.size)a.bufferSubData(a.ARRAY_BUFFER,0,this.vertices);else{var b=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);a.bufferSubData(a.ARRAY_BUFFER,0,b)}a.drawElements(a.TRIANGLES,6*this.currentBatchSize,a.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},b.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},b.WebGLFastSpriteBatch.prototype.start=function(){var a=this.gl;a.activeTexture(a.TEXTURE0),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var b=this.renderSession.projection;a.uniform2f(this.shader.projectionVector,b.x,b.y),a.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var c=4*this.vertSize;a.vertexAttribPointer(this.shader.aVertexPosition,2,a.FLOAT,!1,c,0),a.vertexAttribPointer(this.shader.aPositionCoord,2,a.FLOAT,!1,c,8),a.vertexAttribPointer(this.shader.aScale,2,a.FLOAT,!1,c,16),a.vertexAttribPointer(this.shader.aRotation,1,a.FLOAT,!1,c,24),a.vertexAttribPointer(this.shader.aTextureCoord,2,a.FLOAT,!1,c,28),a.vertexAttribPointer(this.shader.colorAttribute,1,a.FLOAT,!1,c,36)},b.WebGLFilterManager=function(){this.filterStack=[],this.offsetX=0,this.offsetY=0},b.WebGLFilterManager.prototype.constructor=b.WebGLFilterManager,b.WebGLFilterManager.prototype.setContext=function(a){this.gl=a,this.texturePool=[],this.initShaderBuffers()},b.WebGLFilterManager.prototype.begin=function(a,b){this.renderSession=a,this.defaultShader=a.shaderManager.defaultShader;var c=this.renderSession.projection;this.width=2*c.x,this.height=2*-c.y,this.buffer=b},b.WebGLFilterManager.prototype.pushFilter=function(a){var c=this.gl,d=this.renderSession.projection,e=this.renderSession.offset;a._filterArea=a.target.filterArea||a.target.getBounds(),a._previous_stencil_mgr=this.renderSession.stencilManager,this.renderSession.stencilManager=new b.WebGLStencilManager,this.renderSession.stencilManager.setContext(c),c.disable(c.STENCIL_TEST),this.filterStack.push(a);var f=a.filterPasses[0];this.offsetX+=a._filterArea.x,this.offsetY+=a._filterArea.y;var g=this.texturePool.pop();g?g.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution):g=new b.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),c.bindTexture(c.TEXTURE_2D,g.texture);var h=a._filterArea,i=f.padding;h.x-=i,h.y-=i,h.width+=2*i,h.height+=2*i,h.x<0&&(h.x=0),h.width>this.width&&(h.width=this.width),h.y<0&&(h.y=0),h.height>this.height&&(h.height=this.height),c.bindFramebuffer(c.FRAMEBUFFER,g.frameBuffer),c.viewport(0,0,h.width*this.renderSession.resolution,h.height*this.renderSession.resolution),d.x=h.width/2,d.y=-h.height/2,e.x=-h.x,e.y=-h.y,c.colorMask(!0,!0,!0,!0),c.clearColor(0,0,0,0),c.clear(c.COLOR_BUFFER_BIT),a._glFilterTexture=g},b.WebGLFilterManager.prototype.popFilter=function(){var a=this.gl,c=this.filterStack.pop(),d=c._filterArea,e=c._glFilterTexture,f=this.renderSession.projection,g=this.renderSession.offset;if(1<c.filterPasses.length){a.viewport(0,0,d.width*this.renderSession.resolution,d.height*this.renderSession.resolution),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=d.height,this.vertexArray[2]=d.width,this.vertexArray[3]=d.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=d.width,this.vertexArray[7]=0,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=d.width/this.width,this.uvArray[5]=d.height/this.height,this.uvArray[6]=d.width/this.width,this.uvArray[7]=d.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray);var h=e,i=this.texturePool.pop();i||(i=new b.FilterTexture(this.gl,this.width*this.renderSession.resolution,this.height*this.renderSession.resolution)),i.resize(this.width*this.renderSession.resolution,this.height*this.renderSession.resolution),a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.clear(a.COLOR_BUFFER_BIT),a.disable(a.BLEND);for(var j=0;j<c.filterPasses.length-1;j++){var k=c.filterPasses[j];a.bindFramebuffer(a.FRAMEBUFFER,i.frameBuffer),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,h.texture),this.applyFilterPass(k,d,d.width,d.height);var l=h;h=i,i=l}a.enable(a.BLEND),e=h,this.texturePool.push(i)}var m=c.filterPasses[c.filterPasses.length-1];this.offsetX-=d.x,this.offsetY-=d.y;var n=this.width,o=this.height,p=0,q=0,r=this.buffer;if(0===this.filterStack.length)a.colorMask(!0,!0,!0,!0);else{var s=this.filterStack[this.filterStack.length-1];n=(d=s._filterArea).width,o=d.height,p=d.x,q=d.y,r=s._glFilterTexture.frameBuffer}f.x=n/2,f.y=-o/2,g.x=p,g.y=q;var t=(d=c._filterArea).x-p,u=d.y-q;a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=t,this.vertexArray[1]=u+d.height,this.vertexArray[2]=t+d.width,this.vertexArray[3]=u+d.height,this.vertexArray[4]=t,this.vertexArray[5]=u,this.vertexArray[6]=t+d.width,this.vertexArray[7]=u,a.bufferSubData(a.ARRAY_BUFFER,0,this.vertexArray),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=d.width/this.width,this.uvArray[5]=d.height/this.height,this.uvArray[6]=d.width/this.width,this.uvArray[7]=d.height/this.height,a.bufferSubData(a.ARRAY_BUFFER,0,this.uvArray),a.viewport(0,0,n*this.renderSession.resolution,o*this.renderSession.resolution),a.bindFramebuffer(a.FRAMEBUFFER,r),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,e.texture),this.renderSession.stencilManager&&this.renderSession.stencilManager.destroy(),this.renderSession.stencilManager=c._previous_stencil_mgr,c._previous_stencil_mgr=null,0<this.renderSession.stencilManager.count?a.enable(a.STENCIL_TEST):a.disable(a.STENCIL_TEST),this.applyFilterPass(m,d,n,o),this.texturePool.push(e),c._glFilterTexture=null},b.WebGLFilterManager.prototype.applyFilterPass=function(a,c,d,e){var f=this.gl,g=a.shaders[f.id];g||((g=new b.PixiShader(f)).fragmentSrc=a.fragmentSrc,g.uniforms=a.uniforms,g.init(),a.shaders[f.id]=g),this.renderSession.shaderManager.setShader(g),f.uniform2f(g.projectionVector,d/2,-e/2),f.uniform2f(g.offsetVector,0,0),a.uniforms.dimensions&&(a.uniforms.dimensions.value[0]=this.width,a.uniforms.dimensions.value[1]=this.height,a.uniforms.dimensions.value[2]=this.vertexArray[0],a.uniforms.dimensions.value[3]=this.vertexArray[5]),g.syncUniforms(),f.bindBuffer(f.ARRAY_BUFFER,this.vertexBuffer),f.vertexAttribPointer(g.aVertexPosition,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.uvBuffer),f.vertexAttribPointer(g.aTextureCoord,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,this.colorBuffer),f.vertexAttribPointer(g.colorAttribute,2,f.FLOAT,!1,0,0),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,this.indexBuffer),f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0),this.renderSession.drawCount++},b.WebGLFilterManager.prototype.initShaderBuffers=function(){var a=this.gl;this.vertexBuffer=a.createBuffer(),this.uvBuffer=a.createBuffer(),this.colorBuffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.vertexArray=new b.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.vertexBuffer),a.bufferData(a.ARRAY_BUFFER,this.vertexArray,a.STATIC_DRAW),this.uvArray=new b.Float32Array([0,0,1,0,0,1,1,1]),a.bindBuffer(a.ARRAY_BUFFER,this.uvBuffer),a.bufferData(a.ARRAY_BUFFER,this.uvArray,a.STATIC_DRAW),this.colorArray=new b.Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),a.bindBuffer(a.ARRAY_BUFFER,this.colorBuffer),a.bufferData(a.ARRAY_BUFFER,this.colorArray,a.STATIC_DRAW),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),a.STATIC_DRAW)},b.WebGLFilterManager.prototype.destroy=function(){var a=this.gl;this.filterStack=null,this.offsetX=0;for(var b=this.offsetY=0;b<this.texturePool.length;b++)this.texturePool[b].destroy();this.texturePool=null,a.deleteBuffer(this.vertexBuffer),a.deleteBuffer(this.uvBuffer),a.deleteBuffer(this.colorBuffer),a.deleteBuffer(this.indexBuffer)},b.FilterTexture=function(a,c,d,e){this.gl=a,this.frameBuffer=a.createFramebuffer(),this.texture=a.createTexture(),e=e||b.scaleModes.DEFAULT,a.bindTexture(a.TEXTURE_2D,this.texture),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,e===b.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,e===b.scaleModes.LINEAR?a.LINEAR:a.NEAREST),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.bindFramebuffer(a.FRAMEBUFFER,this.frameBuffer),a.bindFramebuffer(a.FRAMEBUFFER,this.frameBuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,this.texture,0),this.renderBuffer=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,this.renderBuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,this.renderBuffer),this.resize(c,d)},b.FilterTexture.prototype.constructor=b.FilterTexture,b.FilterTexture.prototype.clear=function(){var a=this.gl;a.clearColor(0,0,0,0),a.clear(a.COLOR_BUFFER_BIT)},b.FilterTexture.prototype.resize=function(a,b){if(this.width!==a||this.height!==b){this.width=a,this.height=b;var c=this.gl;c.bindTexture(c.TEXTURE_2D,this.texture),c.texImage2D(c.TEXTURE_2D,0,c.RGBA,a,b,0,c.RGBA,c.UNSIGNED_BYTE,null),c.bindRenderbuffer(c.RENDERBUFFER,this.renderBuffer),c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,a,b)}},b.FilterTexture.prototype.destroy=function(){var a=this.gl;a.deleteFramebuffer(this.frameBuffer),a.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},b.CanvasBuffer=function(a,c){this.width=a,this.height=c,this.canvas=b.CanvasPool.create(this,this.width,this.height),this.context=this.canvas.getContext("2d"),this.canvas.width=a,this.canvas.height=c},b.CanvasBuffer.prototype.constructor=b.CanvasBuffer,b.CanvasBuffer.prototype.clear=function(){this.context.setTransform(1,0,0,1,0,0),this.context.clearRect(0,0,this.width,this.height)},b.CanvasBuffer.prototype.resize=function(a,b){this.width=this.canvas.width=a,this.height=this.canvas.height=b},b.CanvasBuffer.prototype.destroy=function(){b.CanvasPool.remove(this)},b.CanvasMaskManager=function(){},b.CanvasMaskManager.prototype.constructor=b.CanvasMaskManager,b.CanvasMaskManager.prototype.pushMask=function(a,c){var d=c.context;d.save();var e=a.alpha,f=a.worldTransform,g=c.resolution;d.setTransform(f.a*g,f.b*g,f.c*g,f.d*g,f.tx*g,f.ty*g),b.CanvasGraphics.renderGraphicsMask(a,d),d.clip(),a.worldAlpha=e},b.CanvasMaskManager.prototype.popMask=function(a){a.context.restore()},b.CanvasTinter=function(){},b.CanvasTinter.getTintedTexture=function(a,c){var d=a.tintedTexture||b.CanvasPool.create(this);return b.CanvasTinter.tintMethod(a.texture,c,d),d},b.CanvasTinter.tintWithMultiply=function(a,b,c){var d=c.getContext("2d"),e=a.crop;c.width===e.width&&c.height===e.height||(c.width=e.width,c.height=e.height),d.clearRect(0,0,e.width,e.height),d.fillStyle="#"+("00000"+(0|b).toString(16)).substr(-6),d.fillRect(0,0,e.width,e.height),d.globalCompositeOperation="multiply",d.drawImage(a.baseTexture.source,e.x,e.y,e.width,e.height,0,0,e.width,e.height),d.globalCompositeOperation="destination-atop",d.drawImage(a.baseTexture.source,e.x,e.y,e.width,e.height,0,0,e.width,e.height)},b.CanvasTinter.tintWithPerPixel=function(a,c,d){var e=d.getContext("2d"),f=a.crop;d.width=f.width,d.height=f.height,e.globalCompositeOperation="copy",e.drawImage(a.baseTexture.source,f.x,f.y,f.width,f.height,0,0,f.width,f.height);for(var g=b.hex2rgb(c),h=g[0],i=g[1],j=g[2],k=e.getImageData(0,0,f.width,f.height),l=k.data,m=0;m<l.length;m+=4)if(l[m+0]*=h,l[m+1]*=i,l[m+2]*=j,!b.CanvasTinter.canHandleAlpha){var n=l[m+3];l[m+0]/=255/n,l[m+1]/=255/n,l[m+2]/=255/n}e.putImageData(k,0,0)},b.CanvasTinter.checkInverseAlpha=function(){var a=new b.CanvasBuffer(2,1);a.context.fillStyle="rgba(10, 20, 30, 0.5)",a.context.fillRect(0,0,1,1);var c=a.context.getImageData(0,0,1,1);if(null===c)return!1;a.context.putImageData(c,1,0);var d=a.context.getImageData(1,0,1,1);return d.data[0]===c.data[0]&&d.data[1]===c.data[1]&&d.data[2]===c.data[2]&&d.data[3]===c.data[3]},b.CanvasTinter.canHandleAlpha=b.CanvasTinter.checkInverseAlpha(),b.CanvasTinter.canUseMultiply=b.canUseNewCanvasBlendModes(),b.CanvasTinter.tintMethod=b.CanvasTinter.canUseMultiply?b.CanvasTinter.tintWithMultiply:b.CanvasTinter.tintWithPerPixel,b.CanvasRenderer=function(a){this.game=a,b.defaultRenderer||(b.defaultRenderer=this),this.type=b.CANVAS_RENDERER,this.resolution=a.resolution,this.clearBeforeRender=a.clearBeforeRender,this.transparent=a.transparent,this.autoResize=!1,this.width=a.width*this.resolution,this.height=a.height*this.resolution,this.view=a.canvas,this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.count=0,this.maskManager=new b.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:Phaser.Canvas.getSmoothingPrefix(this.context),roundPixels:!1},this.mapBlendModes(),this.resize(this.width,this.height)},b.CanvasRenderer.prototype.constructor=b.CanvasRenderer,b.CanvasRenderer.prototype.render=function(a){this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,this.renderSession.currentBlendMode=0,this.renderSession.shakeX=this.game.camera._shake.x,this.renderSession.shakeY=this.game.camera._shake.y,this.context.globalCompositeOperation="source-over",navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),this.clearBeforeRender&&(this.transparent?this.context.clearRect(0,0,this.width,this.height):a._bgColor&&(this.context.fillStyle=a._bgColor.rgba,this.context.fillRect(0,0,this.width,this.height))),this.renderDisplayObject(a)},b.CanvasRenderer.prototype.destroy=function(a){void 0===a&&(a=!0),a&&this.view.parent&&this.view.parent.removeChild(this.view),this.view=null,this.context=null,this.maskManager=null,this.renderSession=null},b.CanvasRenderer.prototype.resize=function(a,c){this.width=a*this.resolution,this.height=c*this.resolution,this.view.width=this.width,this.view.height=this.height,this.autoResize&&(this.view.style.width=this.width/this.resolution+"px",this.view.style.height=this.height/this.resolution+"px"),this.renderSession.smoothProperty&&(this.context[this.renderSession.smoothProperty]=this.renderSession.scaleMode===b.scaleModes.LINEAR)},b.CanvasRenderer.prototype.renderDisplayObject=function(a,b,c){this.renderSession.context=b||this.context,this.renderSession.resolution=this.resolution,a._renderCanvas(this.renderSession,c)},b.CanvasRenderer.prototype.mapBlendModes=function(){if(!b.blendModesCanvas){var a=[],c=b.blendModes,d=b.canUseNewCanvasBlendModes();a[c.NORMAL]="source-over",a[c.ADD]="lighter",a[c.MULTIPLY]=d?"multiply":"source-over",a[c.SCREEN]=d?"screen":"source-over",a[c.OVERLAY]=d?"overlay":"source-over",a[c.DARKEN]=d?"darken":"source-over",a[c.LIGHTEN]=d?"lighten":"source-over",a[c.COLOR_DODGE]=d?"color-dodge":"source-over",a[c.COLOR_BURN]=d?"color-burn":"source-over",a[c.HARD_LIGHT]=d?"hard-light":"source-over",a[c.SOFT_LIGHT]=d?"soft-light":"source-over",a[c.DIFFERENCE]=d?"difference":"source-over",a[c.EXCLUSION]=d?"exclusion":"source-over",a[c.HUE]=d?"hue":"source-over",a[c.SATURATION]=d?"saturation":"source-over",a[c.COLOR]=d?"color":"source-over",a[c.LUMINOSITY]=d?"luminosity":"source-over",b.blendModesCanvas=a}},b.BaseTexture=function(a,c){this.resolution=1,this.width=100,this.height=100,this.scaleMode=c||b.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=a,this.premultipliedAlpha=!0,this._glTextures=[],this.mipmap=!1,this._dirty=[!0,!0,!0,!0],a&&((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height&&(this.hasLoaded=!0,this.width=this.source.naturalWidth||this.source.width,this.height=this.source.naturalHeight||this.source.height,this.dirty()),this.skipRender=!1,this._powerOf2=!1)},b.BaseTexture.prototype.constructor=b.BaseTexture,b.BaseTexture.prototype.forceLoaded=function(a,b){this.hasLoaded=!0,this.width=a,this.height=b,this.dirty()},b.BaseTexture.prototype.destroy=function(){this.source&&b.CanvasPool.removeByCanvas(this.source),this.source=null,this.unloadFromGPU()},b.BaseTexture.prototype.updateSourceImage=function(a){},b.BaseTexture.prototype.dirty=function(){for(var a=0;a<this._glTextures.length;a++)this._dirty[a]=!0},b.BaseTexture.prototype.unloadFromGPU=function(){this.dirty();for(var a=this._glTextures.length-1;0<=a;a--){var c=this._glTextures[a],d=b.glContexts[a];d&&c&&d.deleteTexture(c)}this._glTextures.length=0,this.dirty()},b.BaseTexture.fromCanvas=function(a,c){return 0===a.width&&(a.width=1),0===a.height&&(a.height=1),new b.BaseTexture(a,c)},b.TextureSilentFail=!1,b.Texture=function(a,c,d,e){this.noFrame=!1,c||(this.noFrame=!0,c=new b.Rectangle(0,0,1,1)),a instanceof b.Texture&&(a=a.baseTexture),this.baseTexture=a,this.frame=c,this.trim=e,this.valid=!1,this.isTiling=!1,this.requiresUpdate=!1,this.requiresReTint=!1,this._uvs=null,this.width=0,this.height=0,this.crop=d||new b.Rectangle(0,0,1,1),a.hasLoaded&&(this.noFrame&&(c=new b.Rectangle(0,0,a.width,a.height)),this.setFrame(c))},b.Texture.prototype.constructor=b.Texture,b.Texture.prototype.onBaseTextureLoaded=function(){var a=this.baseTexture;this.noFrame&&(this.frame=new b.Rectangle(0,0,a.width,a.height)),this.setFrame(this.frame)},b.Texture.prototype.destroy=function(a){a&&this.baseTexture.destroy(),this.valid=!1},b.Texture.prototype.setFrame=function(a){if(this.noFrame=!1,this.frame=a,this.width=a.width,this.height=a.height,this.crop.x=a.x,this.crop.y=a.y,this.crop.width=a.width,this.crop.height=a.height,this.trim||!(a.x+a.width>this.baseTexture.width||a.y+a.height>this.baseTexture.height))this.valid=a&&a.width&&a.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&this._updateUvs();else{if(!b.TextureSilentFail)throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=!1}},b.Texture.prototype._updateUvs=function(){this._uvs||(this._uvs=new b.TextureUvs);var a=this.crop,c=this.baseTexture.width,d=this.baseTexture.height;this._uvs.x0=a.x/c,this._uvs.y0=a.y/d,this._uvs.x1=(a.x+a.width)/c,this._uvs.y1=a.y/d,this._uvs.x2=(a.x+a.width)/c,this._uvs.y2=(a.y+a.height)/d,this._uvs.x3=a.x/c,this._uvs.y3=(a.y+a.height)/d},b.Texture.fromCanvas=function(a,c){var d=b.BaseTexture.fromCanvas(a,c);return new b.Texture(d)},b.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},b.RenderTexture=function(a,c,d,e,f){if(this.width=a||100,this.height=c||100,this.resolution=f||1,this.frame=new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.crop=new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution),this.baseTexture=new b.BaseTexture,this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution,this.baseTexture._glTextures=[],this.baseTexture.resolution=this.resolution,this.baseTexture.scaleMode=e||b.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,b.Texture.call(this,this.baseTexture,new b.Rectangle(0,0,this.width*this.resolution,this.height*this.resolution)),this.renderer=d||b.defaultRenderer,this.renderer.type===b.WEBGL_RENDERER){var g=this.renderer.gl;this.baseTexture._dirty[g.id]=!1,this.textureBuffer=new b.FilterTexture(g,this.width,this.height,this.baseTexture.scaleMode),this.baseTexture._glTextures[g.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new b.Point(.5*this.width,.5*-this.height)}else this.render=this.renderCanvas,this.textureBuffer=new b.CanvasBuffer(this.width*this.resolution,this.height*this.resolution),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,this.tempMatrix=new Phaser.Matrix,this._updateUvs()},b.RenderTexture.prototype=Object.create(b.Texture.prototype),b.RenderTexture.prototype.constructor=b.RenderTexture,b.RenderTexture.prototype.resize=function(a,c,d){a===this.width&&c===this.height||(this.valid=0<a&&0<c,this.width=a,this.height=c,this.frame.width=this.crop.width=a*this.resolution,this.frame.height=this.crop.height=c*this.resolution,d&&(this.baseTexture.width=this.width*this.resolution,this.baseTexture.height=this.height*this.resolution),this.renderer.type===b.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.valid&&this.textureBuffer.resize(this.width,this.height))},b.RenderTexture.prototype.clear=function(){this.valid&&(this.renderer.type===b.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear())},b.RenderTexture.prototype.renderWebGL=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),d.translate(0,2*this.projection.y),b&&d.append(b),d.scale(1,-1);for(var e=0;e<a.children.length;e++)a.children[e].updateTransform();var f=this.renderer.gl;f.viewport(0,0,this.width*this.resolution,this.height*this.resolution),f.bindFramebuffer(f.FRAMEBUFFER,this.textureBuffer.frameBuffer),c&&this.textureBuffer.clear(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(a,this.projection,this.textureBuffer.frameBuffer,b),this.renderer.spriteBatch.dirty=!0}},b.RenderTexture.prototype.renderCanvas=function(a,b,c){if(this.valid&&0!==a.alpha){var d=a.worldTransform;d.identity(),b&&d.append(b);for(var e=0;e<a.children.length;e++)a.children[e].updateTransform();c&&this.textureBuffer.clear();var f=this.renderer.resolution;this.renderer.resolution=this.resolution,this.renderer.renderDisplayObject(a,this.textureBuffer.context,b),this.renderer.resolution=f}},b.RenderTexture.prototype.getImage=function(){var a=new Image;return a.src=this.getBase64(),a},b.RenderTexture.prototype.getBase64=function(){return this.getCanvas().toDataURL()},b.RenderTexture.prototype.getCanvas=function(){if(this.renderer.type!==b.WEBGL_RENDERER)return this.textureBuffer.canvas;var a=this.renderer.gl,c=this.textureBuffer.width,d=this.textureBuffer.height,e=new Uint8Array(4*c*d);a.bindFramebuffer(a.FRAMEBUFFER,this.textureBuffer.frameBuffer),a.readPixels(0,0,c,d,a.RGBA,a.UNSIGNED_BYTE,e),a.bindFramebuffer(a.FRAMEBUFFER,null);var f=new b.CanvasBuffer(c,d),g=f.context.getImageData(0,0,c,d);return g.data.set(e),f.context.putImageData(g,0,0),f.canvas},b.AbstractFilter=function(a,b){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=b||{},this.fragmentSrc=a||[]},b.AbstractFilter.prototype.constructor=b.AbstractFilter,b.AbstractFilter.prototype.syncUniforms=function(){for(var a=0,b=this.shaders.length;a<b;a++)this.shaders[a].dirty=!0},b.Strip=function(a){b.DisplayObjectContainer.call(this),this.texture=a,this.uvs=new b.Float32Array([0,1,1,1,1,0,0,1]),this.vertices=new b.Float32Array([0,0,100,0,100,100,0,100]),this.colors=new b.Float32Array([1,1,1,1]),this.indices=new b.Uint16Array([0,1,2,3]),this.dirty=!0,this.blendMode=b.blendModes.NORMAL,this.canvasPadding=0,this.drawMode=b.Strip.DrawModes.TRIANGLE_STRIP},b.Strip.prototype=Object.create(b.DisplayObjectContainer.prototype),b.Strip.prototype.constructor=b.Strip,b.Strip.prototype._renderWebGL=function(a){!this.visible||this.alpha<=0||(a.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(a),a.shaderManager.setShader(a.shaderManager.stripShader),this._renderStrip(a),a.spriteBatch.start())},b.Strip.prototype._initWebGL=function(a){var b=a.gl;this._vertexBuffer=b.createBuffer(),this._indexBuffer=b.createBuffer(),this._uvBuffer=b.createBuffer(),this._colorBuffer=b.createBuffer(),b.bindBuffer(b.ARRAY_BUFFER,this._vertexBuffer),b.bufferData(b.ARRAY_BUFFER,this.vertices,b.DYNAMIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._uvBuffer),b.bufferData(b.ARRAY_BUFFER,this.uvs,b.STATIC_DRAW),b.bindBuffer(b.ARRAY_BUFFER,this._colorBuffer),b.bufferData(b.ARRAY_BUFFER,this.colors,b.STATIC_DRAW),b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,this._indexBuffer),b.bufferData(b.ELEMENT_ARRAY_BUFFER,this.indices,b.STATIC_DRAW)},b.Strip.prototype._renderStrip=function(a){var c=a.gl,d=a.projection,e=a.offset,f=a.shaderManager.stripShader,g=this.drawMode===b.Strip.DrawModes.TRIANGLE_STRIP?c.TRIANGLE_STRIP:c.TRIANGLES;a.blendModeManager.setBlendMode(this.blendMode),c.uniformMatrix3fv(f.translationMatrix,!1,this.worldTransform.toArray(!0)),c.uniform2f(f.projectionVector,d.x,-d.y),c.uniform2f(f.offsetVector,-e.x,-e.y),c.uniform1f(f.alpha,this.worldAlpha),this.dirty?(this.dirty=!1,c.bindBuffer(c.ARRAY_BUFFER,this._vertexBuffer),c.bufferData(c.ARRAY_BUFFER,this.vertices,c.STATIC_DRAW),c.vertexAttribPointer(f.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this._uvBuffer),c.bufferData(c.ARRAY_BUFFER,this.uvs,c.STATIC_DRAW),c.vertexAttribPointer(f.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),this.texture.baseTexture._dirty[c.id]?a.renderer.updateTexture(this.texture.baseTexture):c.bindTexture(c.TEXTURE_2D,this.texture.baseTexture._glTextures[c.id]),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indexBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,this.indices,c.STATIC_DRAW)):(c.bindBuffer(c.ARRAY_BUFFER,this._vertexBuffer),c.bufferSubData(c.ARRAY_BUFFER,0,this.vertices),c.vertexAttribPointer(f.aVertexPosition,2,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,this._uvBuffer),c.vertexAttribPointer(f.aTextureCoord,2,c.FLOAT,!1,0,0),c.activeTexture(c.TEXTURE0),this.texture.baseTexture._dirty[c.id]?a.renderer.updateTexture(this.texture.baseTexture):c.bindTexture(c.TEXTURE_2D,this.texture.baseTexture._glTextures[c.id]),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),c.drawElements(g,this.indices.length,c.UNSIGNED_SHORT,0)},b.Strip.prototype._renderCanvas=function(a){var c=a.context,d=this.worldTransform,e=d.tx*a.resolution+a.shakeX,f=d.ty*a.resolution+a.shakeY;a.roundPixels?c.setTransform(d.a,d.b,d.c,d.d,0|e,0|f):c.setTransform(d.a,d.b,d.c,d.d,e,f),this.drawMode===b.Strip.DrawModes.TRIANGLE_STRIP?this._renderCanvasTriangleStrip(c):this._renderCanvasTriangles(c)},b.Strip.prototype._renderCanvasTriangleStrip=function(a){var b=this.vertices,c=this.uvs,d=b.length/2;this.count++;for(var e=0;e<d-2;e++){var f=2*e;this._renderCanvasDrawTriangle(a,b,c,f,f+2,f+4)}},b.Strip.prototype._renderCanvasTriangles=function(a){var b=this.vertices,c=this.uvs,d=this.indices,e=d.length;this.count++;for(var f=0;f<e;f+=3){var g=2*d[f],h=2*d[f+1],i=2*d[f+2];this._renderCanvasDrawTriangle(a,b,c,g,h,i)}},b.Strip.prototype._renderCanvasDrawTriangle=function(a,b,c,d,e,f){var g=this.texture.baseTexture.source,h=this.texture.width,i=this.texture.height,j=b[d],k=b[e],l=b[f],m=b[d+1],n=b[e+1],o=b[f+1],p=c[d]*h,q=c[e]*h,r=c[f]*h,s=c[d+1]*i,t=c[e+1]*i,u=c[f+1]*i;if(0<this.canvasPadding){var v=this.canvasPadding/this.worldTransform.a,w=this.canvasPadding/this.worldTransform.d,x=(j+k+l)/3,y=(m+n+o)/3,z=j-x,A=m-y,B=Math.sqrt(z*z+A*A);j=x+z/B*(B+v),m=y+A/B*(B+w),A=n-y,k=x+(z=k-x)/(B=Math.sqrt(z*z+A*A))*(B+v),n=y+A/B*(B+w),A=o-y,l=x+(z=l-x)/(B=Math.sqrt(z*z+A*A))*(B+v),o=y+A/B*(B+w)}a.save(),a.beginPath(),a.moveTo(j,m),a.lineTo(k,n),a.lineTo(l,o),a.closePath(),a.clip();var C=p*t+s*r+q*u-t*r-s*q-p*u,D=j*t+s*l+k*u-t*l-s*k-j*u,E=p*k+j*r+q*l-k*r-j*q-p*l,F=p*t*l+s*k*r+j*q*u-j*t*r-s*q*l-p*k*u,G=m*t+s*o+n*u-t*o-s*n-m*u,H=p*n+m*r+q*o-n*r-m*q-p*o,I=p*t*o+s*n*r+m*q*u-m*t*r-s*q*o-p*n*u;a.transform(D/C,G/C,E/C,H/C,F/C,I/C),a.drawImage(g,0,0),a.restore()},b.Strip.prototype.renderStripFlat=function(a){var b=this.context,c=a.vertices,d=c.length/2;this.count++,b.beginPath();for(var e=1;e<d-2;e++){var f=2*e,g=c[f],h=c[f+2],i=c[f+4],j=c[f+1],k=c[f+3],l=c[f+5];b.moveTo(g,j),b.lineTo(h,k),b.lineTo(i,l)}b.fillStyle="#FF0000",b.fill(),b.closePath()},b.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},b.Strip.prototype.getBounds=function(a){for(var c=a||this.worldTransform,d=c.a,e=c.b,f=c.c,g=c.d,h=c.tx,i=c.ty,j=-1/0,k=-1/0,l=1/0,m=1/0,n=this.vertices,o=0,p=n.length;o<p;o+=2){var q=n[o],r=n[o+1],s=d*q+f*r+h,t=g*r+e*q+i;l=s<l?s:l,m=t<m?t:m,j=j<s?s:j,k=k<t?t:k}if(l===-1/0||k===1/0)return b.EmptyRectangle;var u=this._bounds;return u.x=l,u.width=j-l,u.y=m,u.height=k-m,this._currentBounds=u},b.Strip.DrawModes={TRIANGLE_STRIP:0,TRIANGLES:1},b.Rope=function(a,c){b.Strip.call(this,a),this.points=c,this.vertices=new b.Float32Array(4*c.length),this.uvs=new b.Float32Array(4*c.length),this.colors=new b.Float32Array(2*c.length),this.indices=new b.Uint16Array(2*c.length),this.refresh()},b.Rope.prototype=Object.create(b.Strip.prototype),b.Rope.prototype.constructor=b.Rope,b.Rope.prototype.refresh=function(){var a=this.points;if(!(a.length<1)){var b=this.uvs,c=(a[0],this.indices),d=this.colors;this.count-=.2,b[0]=0,b[1]=0,b[2]=0,b[3]=1,d[0]=1,d[1]=1,c[0]=0,c[1]=1;for(var f,g,h=a.length,i=1;i<h;i++)a[i],g=i/(h-1),b[f=4*i]=g,b[f+1]=0,b[f+2]=g,b[f+3]=1,d[f=2*i]=1,d[f+1]=1,c[f=2*i]=f,c[f+1]=f+1}},b.Rope.prototype.updateTransform=function(){var a=this.points;if(!(a.length<1)){var c,d=a[0],e={x:0,y:0};this.count-=.2;for(var f,g,i,j,k=this.vertices,l=a.length,m=0;m<l;m++)f=a[m],g=4*m,c=m<a.length-1?a[m+1]:f,e.y=-(c.x-d.x),e.x=c.y-d.y,1<10*(1-m/(l-1))&&1,i=Math.sqrt(e.x*e.x+e.y*e.y),j=this.texture.height/2,e.x/=i,e.y/=i,e.x*=j,e.y*=j,k[g]=f.x+e.x,k[g+1]=f.y+e.y,k[g+2]=f.x-e.x,k[g+3]=f.y-e.y,d=f;b.DisplayObjectContainer.prototype.updateTransform.call(this)}},b.Rope.prototype.setTexture=function(a){this.texture=a},b.TilingSprite=function(a,c,d){b.Sprite.call(this,a),this._width=c||128,this._height=d||128,this.tileScale=new b.Point(1,1),this.tileScaleOffset=new b.Point(1,1),this.tilePosition=new b.Point,this.renderable=!0,this.tint=16777215,this.textureDebug=!1,this.blendMode=b.blendModes.NORMAL,this.canvasBuffer=null,this.tilingTexture=null,this.tilePattern=null,this.refreshTexture=!0,this.frameWidth=0,this.frameHeight=0},b.TilingSprite.prototype=Object.create(b.Sprite.prototype),b.TilingSprite.prototype.constructor=b.TilingSprite,b.TilingSprite.prototype.setTexture=function(a){this.texture!==a&&(this.texture=a,this.refreshTexture=!0,this.cachedTint=16777215)},b.TilingSprite.prototype._renderWebGL=function(a){if(this.visible&&this.renderable&&0!==this.alpha){if(this._mask&&(a.spriteBatch.stop(),a.maskManager.pushMask(this.mask,a),a.spriteBatch.start()),this._filters&&(a.spriteBatch.flush(),a.filterManager.pushFilter(this._filterBlock)),this.refreshTexture){if(this.generateTilingTexture(!0,a),!this.tilingTexture)return;this.tilingTexture.needsUpdate&&(a.renderer.updateTexture(this.tilingTexture.baseTexture),this.tilingTexture.needsUpdate=!1)}a.spriteBatch.renderTilingSprite(this);for(var b=0;b<this.children.length;b++)this.children[b]._renderWebGL(a);a.spriteBatch.stop(),this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(this._mask,a),a.spriteBatch.start()}},b.TilingSprite.prototype._renderCanvas=function(a){if(this.visible&&this.renderable&&0!==this.alpha){var c=a.context;this._mask&&a.maskManager.pushMask(this._mask,a),c.globalAlpha=this.worldAlpha;var d=this.worldTransform,e=a.resolution,f=d.tx*e+a.shakeX,g=d.ty*e+a.shakeY;if(c.setTransform(d.a*e,d.b*e,d.c*e,d.d*e,f,g),this.refreshTexture){if(this.generateTilingTexture(!1,a),!this.tilingTexture)return;this.tilePattern=c.createPattern(this.tilingTexture.baseTexture.source,"repeat")}var h=a.currentBlendMode;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,c.globalCompositeOperation=b.blendModesCanvas[a.currentBlendMode]);var i=this.tilePosition,j=this.tileScale;i.x%=this.tilingTexture.baseTexture.width,i.y%=this.tilingTexture.baseTexture.height,c.scale(j.x,j.y),c.translate(i.x+this.anchor.x*-this._width,i.y+this.anchor.y*-this._height),c.fillStyle=this.tilePattern;f=-i.x,g=-i.y;var k=this._width/j.x,l=this._height/j.y;a.roundPixels&&(f|=0,g|=0,k|=0,l|=0),c.fillRect(f,g,k,l),c.scale(1/j.x,1/j.y),c.translate(-i.x+this.anchor.x*this._width,-i.y+this.anchor.y*this._height),this._mask&&a.maskManager.popMask(a);for(var m=0;m<this.children.length;m++)this.children[m]._renderCanvas(a);h!==this.blendMode&&(a.currentBlendMode=h,c.globalCompositeOperation=b.blendModesCanvas[h])}},b.TilingSprite.prototype.onTextureUpdate=function(){},b.TilingSprite.prototype.generateTilingTexture=function(a,c){if(this.texture.baseTexture.hasLoaded){var d=this.texture,e=d.frame,f=this._frame.sourceSizeW||this._frame.width,g=this._frame.sourceSizeH||this._frame.height,h=0,i=0;this._frame.trimmed&&(h=this._frame.spriteSourceSizeX,i=this._frame.spriteSourceSizeY),a&&(f=b.getNextPowerOfTwo(f),g=b.getNextPowerOfTwo(g)),this.canvasBuffer?(this.canvasBuffer.resize(f,g),this.tilingTexture.baseTexture.width=f,this.tilingTexture.baseTexture.height=g):(this.canvasBuffer=new b.CanvasBuffer(f,g),this.tilingTexture=b.Texture.fromCanvas(this.canvasBuffer.canvas),this.tilingTexture.isTiling=!0),this.tilingTexture.needsUpdate=!0,this.textureDebug&&(this.canvasBuffer.context.strokeStyle="#00ff00",this.canvasBuffer.context.strokeRect(0,0,f,g));var j=d.crop.width,k=d.crop.height;j===f&&k===g||(j=f,k=g),this.canvasBuffer.context.drawImage(d.baseTexture.source,d.crop.x,d.crop.y,d.crop.width,d.crop.height,h,i,j,k),this.tileScaleOffset.x=e.width/f,this.tileScaleOffset.y=e.height/g,this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}},b.TilingSprite.prototype.getBounds=function(){var a=this._width,b=this._height,c=a*(1-this.anchor.x),d=a*-this.anchor.x,e=b*(1-this.anchor.y),f=b*-this.anchor.y,g=this.worldTransform,h=g.a,i=g.b,j=g.c,k=g.d,l=g.tx,m=g.ty,n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=-1/0,w=-1/0,x=1/0,y=1/0;x=t<(x=r<(x=p<(x=n<x?n:x)?p:x)?r:x)?t:x,y=u<(y=s<(y=q<(y=o<y?o:y)?q:y)?s:y)?u:y,v=(v=(v=(v=v<n?n:v)<p?p:v)<r?r:v)<t?t:v,w=(w=(w=(w=w<o?o:w)<q?q:w)<s?s:w)<u?u:w;var z=this._bounds;return z.x=x,z.width=v-x,z.y=y,z.height=w-y,this._currentBounds=z},b.TilingSprite.prototype.destroy=function(){b.Sprite.prototype.destroy.call(this),this.canvasBuffer&&(this.canvasBuffer.destroy(),this.canvasBuffer=null),this.tileScale=null,this.tileScaleOffset=null,this.tilePosition=null,this.tilingTexture&&(this.tilingTexture.destroy(!0),this.tilingTexture=null)},Object.defineProperty(b.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(a){this._width=a}}),Object.defineProperty(b.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(a){this._height=a}}),"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),exports.PIXI=b):"undefined"!=typeof define&&define.amd?define("PIXI",a.PIXI=b):a.PIXI=b,b}.call(this),function(){function a(a,b){this._scaleFactor=a,this._deltaMode=b,this.originalEvent=null}var b=this,c=c||{VERSION:"2.6.15",GAMES:[],AUTO:0,CANVAS:1,WEBGL:2,HEADLESS:3,NONE:0,LEFT:1,RIGHT:2,UP:3,DOWN:4,SPRITE:0,BUTTON:1,IMAGE:2,GRAPHICS:3,TEXT:4,TILESPRITE:5,BITMAPTEXT:6,GROUP:7,RENDERTEXTURE:8,TILEMAP:9,TILEMAPLAYER:10,EMITTER:11,POLYGON:12,BITMAPDATA:13,CANVAS_FILTER:14,WEBGL_FILTER:15,ELLIPSE:16,SPRITEBATCH:17,RETROFONT:18,POINTER:19,ROPE:20,CIRCLE:21,RECTANGLE:22,LINE:23,MATRIX:24,POINT:25,ROUNDEDRECTANGLE:26,CREATURE:27,VIDEO:28,PENDING_ATLAS:-1,HORIZONTAL:0,VERTICAL:1,LANDSCAPE:0,PORTRAIT:1,ANGLE_UP:270,ANGLE_DOWN:90,ANGLE_LEFT:180,ANGLE_RIGHT:0,ANGLE_NORTH_EAST:315,ANGLE_NORTH_WEST:225,ANGLE_SOUTH_EAST:45,ANGLE_SOUTH_WEST:135,TOP_LEFT:0,TOP_CENTER:1,TOP_RIGHT:2,LEFT_TOP:3,LEFT_CENTER:4,LEFT_BOTTOM:5,CENTER:6,RIGHT_TOP:7,RIGHT_CENTER:8,RIGHT_BOTTOM:9,BOTTOM_LEFT:10,BOTTOM_CENTER:11,BOTTOM_RIGHT:12,blendModes:{NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},scaleModes:{DEFAULT:0,LINEAR:0,NEAREST:1},PIXI:PIXI||{}};if(Math.trunc||(Math.trunc=function(a){return a<0?Math.ceil(a):Math.floor(a)}),Function.prototype.bind||(Function.prototype.bind=function(){var a=Array.prototype.slice;return function(b){function c(){var f=e.concat(a.call(arguments));d.apply(this instanceof c?this:b,f)}var d=this,e=a.call(arguments,1);if("function"!=typeof d)throw new TypeError;return c.prototype=function a(b){if(b&&(a.prototype=b),!(this instanceof a))return new a}(d.prototype),c}}()),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),Array.prototype.forEach||(Array.prototype.forEach=function(a){"use strict";if(null==this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=2<=arguments.length?arguments[1]:void 0,e=0;e<c;e++)e in b&&a.call(d,b[e],e,b)}),"function"!=typeof window.Uint32Array&&"object"!=typeof window.Uint32Array){var d=function(a){var b=new Array;window[a]=function(a){if("number"==typeof a){Array.call(this,a),this.length=a;for(var b=0;b<this.length;b++)this[b]=0}else{Array.call(this,a.length),this.length=a.length;for(b=0;b<this.length;b++)this[b]=a[b]}},window[a].prototype=b,window[a].constructor=window[a]};d("Uint32Array"),d("Int16Array")}for(var e in window.console||(window.console={},window.console.log=window.console.assert=function(){},window.console.warn=window.console.assert=function(){}),/firefox/i.test(navigator.userAgent)&&(window.oldGetComputedStyle=window.getComputedStyle,window.getComputedStyle=function(a,b){var c=window.oldGetComputedStyle(a,b);return null===c?{getPropertyValue:function(){}}:c}),c.Utils={reverseString:function(a){return a.split("").reverse().join("")},getProperty:function(a,b){for(var c=b.split("."),d=c.pop(),e=c.length,f=1,g=c[0];f<e&&(a=a[g]);)g=c[f],f++;return a?a[d]:null},setProperty:function(a,b,c){for(var d=b.split("."),e=d.pop(),f=d.length,g=1,h=d[0];g<f&&(a=a[h]);)h=d[g],g++;return a&&(a[e]=c),a},chanceRoll:function(a){return void 0===a&&(a=50),0<a&&100*Math.random()<=a},randomChoice:function(a,b){return Math.random()<.5?a:b},parseDimension:function(a,b){var c=0;return"string"==typeof a?"%"===a.substr(-1)?(c=parseInt(a,10)/100,0===b?window.innerWidth*c:window.innerHeight*c):parseInt(a,10):a},pad:function(a,b,c,d){if(void 0===b)b=0;if(void 0===c)c=" ";if(void 0===d)d=3;var e=0;if(b+1>=(a=a.toString()).length)switch(d){case 1:a=new Array(b+1-a.length).join(c)+a;break;case 3:var f=Math.ceil((e=b-a.length)/2);a=new Array(e-f+1).join(c)+a+new Array(f+1).join(c);break;default:a+=new Array(b+1-a.length).join(c)}return a},isPlainObject:function(a){if("object"!=typeof a||a.nodeType||a===a.window)return!1;try{if(a.constructor&&!{}.hasOwnProperty.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(a){return!1}return!0},extend:function(){var a,b,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;for("boolean"==typeof h&&(k=h,h=arguments[1]||{},i=2),j===i&&(h=this,--i);i<j;i++)if(null!=(a=arguments[i]))for(b in a)d=h[b],h!==(e=a[b])&&(k&&e&&(c.Utils.isPlainObject(e)||(f=Array.isArray(e)))?(g=f?(f=!1,d&&Array.isArray(d)?d:[]):d&&c.Utils.isPlainObject(d)?d:{},h[b]=c.Utils.extend(k,g,e)):void 0!==e&&(h[b]=e));return h},mixinPrototype:function(a,b,c){void 0===c&&(c=!1);for(var d=Object.keys(b),e=0;e<d.length;e++){var f=d[e],g=b[f];!c&&f in a||(!g||"function"!=typeof g.get&&"function"!=typeof g.set?a[f]=g:"function"==typeof g.clone?a[f]=g.clone():Object.defineProperty(a,f,g))}},mixin:function(a,b){if(!a||"object"!=typeof a)return b;for(var d in a){var e=a[d];if(!e.childNodes&&!e.cloneNode){var f=typeof a[d];a[d]&&"object"===f?typeof b[d]===f?b[d]=c.Utils.mixin(a[d],b[d]):b[d]=c.Utils.mixin(a[d],new e.constructor):b[d]=a[d]}}return b}},c.Circle=function(a,b,d){a=a||0,b=b||0,d=d||0,this.x=a,this.y=b,this._diameter=d,(this._radius=0)<d&&(this._radius=.5*d),this.type=c.CIRCLE},c.Circle.prototype={circumference:function(){return Math.PI*this._radius*2},random:function(a){void 0===a&&(a=new c.Point);var b=2*Math.PI*Math.random(),d=Math.random()+Math.random(),e=1<d?2-d:d,f=e*Math.cos(b),g=e*Math.sin(b);return a.x=this.x+f*this.radius,a.y=this.y+g*this.radius,a},getBounds:function(){return new c.Rectangle(this.x-this.radius,this.y-this.radius,this.diameter,this.diameter)},setTo:function(a,b,c){return this.x=a,this.y=b,this._diameter=c,this._radius=.5*c,this},copyFrom:function(a){return this.setTo(a.x,a.y,a.diameter)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.diameter=this._diameter,a},distance:function(a,b){var d=c.Math.distance(this.x,this.y,a.x,a.y);return b?Math.round(d):d},clone:function(a){return null==a?a=new c.Circle(this.x,this.y,this.diameter):a.setTo(this.x,this.y,this.diameter),a},contains:function(a,b){return c.Circle.contains(this,a,b)},circumferencePoint:function(a,b,d){return c.Circle.circumferencePoint(this,a,b,d)},offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},toString:function(){return"[{Phaser.Circle (x="+this.x+" y="+this.y+" diameter="+this.diameter+" radius="+this.radius+")}]"}},c.Circle.prototype.constructor=c.Circle,Object.defineProperty(c.Circle.prototype,"diameter",{get:function(){return this._diameter},set:function(a){0<a&&(this._diameter=a,this._radius=.5*a)}}),Object.defineProperty(c.Circle.prototype,"radius",{get:function(){return this._radius},set:function(a){0<a&&(this._radius=a,this._diameter=2*a)}}),Object.defineProperty(c.Circle.prototype,"left",{get:function(){return this.x-this._radius},set:function(a){a>this.x?(this._radius=0,this._diameter=0):this.radius=this.x-a}}),Object.defineProperty(c.Circle.prototype,"right",{get:function(){return this.x+this._radius},set:function(a){a<this.x?(this._radius=0,this._diameter=0):this.radius=a-this.x}}),Object.defineProperty(c.Circle.prototype,"top",{get:function(){return this.y-this._radius},set:function(a){a>this.y?(this._radius=0,this._diameter=0):this.radius=this.y-a}}),Object.defineProperty(c.Circle.prototype,"bottom",{get:function(){return this.y+this._radius},set:function(a){a<this.y?(this._radius=0,this._diameter=0):this.radius=a-this.y}}),Object.defineProperty(c.Circle.prototype,"area",{get:function(){return 0<this._radius?Math.PI*this._radius*this._radius:0}}),Object.defineProperty(c.Circle.prototype,"empty",{get:function(){return 0===this._diameter},set:function(a){!0===a&&this.setTo(0,0,0)}}),c.Circle.contains=function(a,b,c){return 0<a.radius&&b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom&&(a.x-b)*(a.x-b)+(a.y-c)*(a.y-c)<=a.radius*a.radius},c.Circle.equals=function(a,b){return a.x===b.x&&a.y===b.y&&a.diameter===b.diameter},c.Circle.intersects=function(a,b){return c.Math.distance(a.x,a.y,b.x,b.y)<=a.radius+b.radius},c.Circle.circumferencePoint=function(a,b,d,e){return void 0===d&&(d=!1),void 0===e&&(e=new c.Point),!0===d&&(b=c.Math.degToRad(b)),e.x=a.x+a.radius*Math.cos(b),e.y=a.y+a.radius*Math.sin(b),e},c.Circle.intersectsRectangle=function(a,b){var c=Math.abs(a.x-b.x-b.halfWidth);if(c>b.halfWidth+a.radius)return!1;var d=Math.abs(a.y-b.y-b.halfHeight);if(d>b.halfHeight+a.radius)return!1;if(c<=b.halfWidth||d<=b.halfHeight)return!0;var e=c-b.halfWidth,f=d-b.halfHeight;return e*e+f*f<=a.radius*a.radius},PIXI.Circle=c.Circle,c.Ellipse=function(a,b,d,e){a=a||0,b=b||0,d=d||0,e=e||0,this.x=a,this.y=b,this.width=d,this.height=e,this.type=c.ELLIPSE},c.Ellipse.prototype={setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},getBounds:function(){return new c.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},clone:function(a){return null==a?a=new c.Ellipse(this.x,this.y,this.width,this.height):a.setTo(this.x,this.y,this.width,this.height),a},contains:function(a,b){return c.Ellipse.contains(this,a,b)},random:function(a){void 0===a&&(a=new c.Point);var b=Math.random()*Math.PI*2,d=Math.random();return a.x=Math.sqrt(d)*Math.cos(b),a.y=Math.sqrt(d)*Math.sin(b),a.x=this.x+a.x*this.width/2,a.y=this.y+a.y*this.height/2,a},toString:function(){return"[{Phaser.Ellipse (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")}]"}},c.Ellipse.prototype.constructor=c.Ellipse,Object.defineProperty(c.Ellipse.prototype,"left",{get:function(){return this.x},set:function(a){this.x=a}}),Object.defineProperty(c.Ellipse.prototype,"right",{get:function(){return this.x+this.width},set:function(a){a<this.x?this.width=0:this.width=a-this.x}}),Object.defineProperty(c.Ellipse.prototype,"top",{get:function(){return this.y},set:function(a){this.y=a}}),Object.defineProperty(c.Ellipse.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a<this.y?this.height=0:this.height=a-this.y}}),Object.defineProperty(c.Ellipse.prototype,"empty",{get:function(){return 0===this.width||0===this.height},set:function(a){!0===a&&this.setTo(0,0,0,0)}}),c.Ellipse.contains=function(a,b,c){if(a.width<=0||a.height<=0)return!1;var d=(b-a.x)/a.width-.5,e=(c-a.y)/a.height-.5;return(d*=d)+(e*=e)<.25},PIXI.Ellipse=c.Ellipse,c.Line=function(a,b,d,e){a=a||0,b=b||0,d=d||0,e=e||0,this.start=new c.Point(a,b),this.end=new c.Point(d,e),this.type=c.LINE},c.Line.prototype={setTo:function(a,b,c,d){return this.start.setTo(a,b),this.end.setTo(c,d),this},fromSprite:function(a,b,c){return void 0===c&&(c=!1),c?this.setTo(a.center.x,a.center.y,b.center.x,b.center.y):this.setTo(a.x,a.y,b.x,b.y)},fromAngle:function(a,b,c,d){return this.start.setTo(a,b),this.end.setTo(a+Math.cos(c)*d,b+Math.sin(c)*d),this},rotate:function(a,b){var c=(this.start.x+this.end.x)/2,d=(this.start.y+this.end.y)/2;return this.start.rotate(c,d,a,b),this.end.rotate(c,d,a,b),this},rotateAround:function(a,b,c,d){return this.start.rotate(a,b,c,d),this.end.rotate(a,b,c,d),this},intersects:function(a,b,d){return c.Line.intersectsPoints(this.start,this.end,a.start,a.end,b,d)},reflect:function(a){return c.Line.reflect(this,a)},midPoint:function(a){return void 0===a&&(a=new c.Point),a.x=(this.start.x+this.end.x)/2,a.y=(this.start.y+this.end.y)/2,a},centerOn:function(a,b){var e=a-(this.start.x+this.end.x)/2,f=b-(this.start.y+this.end.y)/2;this.start.add(e,f),this.end.add(e,f)},pointOnLine:function(a,b){return(a-this.start.x)*(this.end.y-this.start.y)==(this.end.x-this.start.x)*(b-this.start.y)},pointOnSegment:function(a,b){var c=Math.min(this.start.x,this.end.x),d=Math.max(this.start.x,this.end.x),e=Math.min(this.start.y,this.end.y),f=Math.max(this.start.y,this.end.y);return this.pointOnLine(a,b)&&c<=a&&a<=d&&e<=b&&b<=f},random:function(a){void 0===a&&(a=new c.Point);var b=Math.random();return a.x=this.start.x+b*(this.end.x-this.start.x),a.y=this.start.y+b*(this.end.y-this.start.y),a},coordinatesOnLine:function(a,b){void 0===a&&(a=1),void 0===b&&(b=[]);var c=Math.round(this.start.x),d=Math.round(this.start.y),e=Math.round(this.end.x),f=Math.round(this.end.y),g=Math.abs(e-c),h=Math.abs(f-d),i=c<e?1:-1,j=d<f?1:-1,k=g-h;b.push([c,d]);for(var l=1;c!==e||d!==f;){var m=k<<1;-h<m&&(k-=h,c+=i),m<g&&(k+=g,d+=j),l%a==0&&b.push([c,d]),l++}return b},clone:function(a){return null==a?a=new c.Line(this.start.x,this.start.y,this.end.x,this.end.y):a.setTo(this.start.x,this.start.y,this.end.x,this.end.y),a}},Object.defineProperty(c.Line.prototype,"length",{get:function(){return Math.sqrt((this.end.x-this.start.x)*(this.end.x-this.start.x)+(this.end.y-this.start.y)*(this.end.y-this.start.y))}}),Object.defineProperty(c.Line.prototype,"angle",{get:function(){return Math.atan2(this.end.y-this.start.y,this.end.x-this.start.x)}}),Object.defineProperty(c.Line.prototype,"slope",{get:function(){return(this.end.y-this.start.y)/(this.end.x-this.start.x)}}),Object.defineProperty(c.Line.prototype,"perpSlope",{get:function(){return-(this.end.x-this.start.x)/(this.end.y-this.start.y)}}),Object.defineProperty(c.Line.prototype,"x",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(c.Line.prototype,"y",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(c.Line.prototype,"left",{get:function(){return Math.min(this.start.x,this.end.x)}}),Object.defineProperty(c.Line.prototype,"right",{get:function(){return Math.max(this.start.x,this.end.x)}}),Object.defineProperty(c.Line.prototype,"top",{get:function(){return Math.min(this.start.y,this.end.y)}}),Object.defineProperty(c.Line.prototype,"bottom",{get:function(){return Math.max(this.start.y,this.end.y)}}),Object.defineProperty(c.Line.prototype,"width",{get:function(){return Math.abs(this.start.x-this.end.x)}}),Object.defineProperty(c.Line.prototype,"height",{get:function(){return Math.abs(this.start.y-this.end.y)}}),Object.defineProperty(c.Line.prototype,"normalX",{get:function(){return Math.cos(this.angle-1.5707963267948966)}}),Object.defineProperty(c.Line.prototype,"normalY",{get:function(){return Math.sin(this.angle-1.5707963267948966)}}),Object.defineProperty(c.Line.prototype,"normalAngle",{get:function(){return c.Math.wrap(this.angle-1.5707963267948966,-Math.PI,Math.PI)}}),c.Line.intersectsPoints=function(a,b,d,e,f,g){void 0===f&&(f=!0),void 0===g&&(g=new c.Point);var h=b.y-a.y,i=e.y-d.y,j=a.x-b.x,k=d.x-e.x,l=b.x*a.y-a.x*b.y,m=e.x*d.y-d.x*e.y,n=h*k-i*j;if(0===n)return null;if(g.x=(j*m-k*l)/n,g.y=(i*l-h*m)/n,f){var o=(e.y-d.y)*(b.x-a.x)-(e.x-d.x)*(b.y-a.y),p=((e.x-d.x)*(a.y-d.y)-(e.y-d.y)*(a.x-d.x))/o,q=((b.x-a.x)*(a.y-d.y)-(b.y-a.y)*(a.x-d.x))/o;return 0<=p&&p<=1&&0<=q&&q<=1?g:null}return g},c.Line.intersects=function(a,b,d,e){return c.Line.intersectsPoints(a.start,a.end,b.start,b.end,d,e)},c.Line.intersectsRectangle=function(a,b){if(!c.Rectangle.intersects(a,b))return!1;var d=a.start.x,e=a.start.y,f=a.end.x,g=a.end.y,h=b.x,i=b.y,j=b.right,k=b.bottom,l=0;if(h<=d&&d<=j&&i<=e&&e<=k||h<=f&&f<=j&&i<=g&&g<=k)return!0;if(d<h&&h<=f){if((l=e+(g-e)*(h-d)/(f-d))>i&&l<=k)return!0}else if(j<d&&f<=j&&(l=e+(g-e)*(j-d)/(f-d))>=i&&l<=k)return!0;if(e<i&&i<=g){if((l=d+(f-d)*(i-e)/(g-e))>=h&&l<=j)return!0}else if(k<e&&g<=k&&(l=d+(f-d)*(k-e)/(g-e))>=h&&l<=j)return!0;return!1},c.Line.reflect=function(a,b){return 2*b.normalAngle-3.141592653589793-a.angle},c.Matrix=function(a,b,d,e,f,g){null!=a||(a=1),null!=b||(b=0),null!=d||(d=0),null!=e||(e=1),null!=f||(f=0),null!=g||(g=0),this.a=a,this.b=b,this.c=d,this.d=e,this.tx=f,this.ty=g,this.type=c.MATRIX},c.Matrix.prototype={fromArray:function(a){return this.setTo(a[0],a[1],a[3],a[4],a[2],a[5])},setTo:function(a,b,c,d,e,f){return this.a=a,this.b=b,this.c=c,this.d=d,this.tx=e,this.ty=f,this},clone:function(a){return null==a?a=new c.Matrix(this.a,this.b,this.c,this.d,this.tx,this.ty):(a.a=this.a,a.b=this.b,a.c=this.c,a.d=this.d,a.tx=this.tx,a.ty=this.ty),a},copyTo:function(a){return a.copyFrom(this),a},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},toArray:function(a,b){return void 0===b&&(b=new PIXI.Float32Array(9)),a?(b[0]=this.a,b[1]=this.b,b[2]=0,b[3]=this.c,b[4]=this.d,b[5]=0,b[6]=this.tx,b[7]=this.ty):(b[0]=this.a,b[1]=this.c,b[2]=this.tx,b[3]=this.b,b[4]=this.d,b[5]=this.ty,b[6]=0,b[7]=0),b[8]=1,b},apply:function(a,b){return void 0===b&&(b=new c.Point),b.x=this.a*a.x+this.c*a.y+this.tx,b.y=this.b*a.x+this.d*a.y+this.ty,b},applyInverse:function(a,b){void 0===b&&(b=new c.Point);var d=1/(this.a*this.d+this.c*-this.b),e=a.x,f=a.y;return b.x=this.d*d*e+-this.c*d*f+(this.ty*this.c-this.tx*this.d)*d,b.y=this.a*d*f+-this.b*d*e+(-this.ty*this.a+this.tx*this.b)*d,b},translate:function(a,b){return this.tx+=a,this.ty+=b,this},scale:function(a,b){return this.a*=a,this.d*=b,this.c*=a,this.b*=b,this.tx*=a,this.ty*=b,this},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},append: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},identity:function(){return this.setTo(1,0,0,1,0,0)}},c.identityMatrix=new c.Matrix,PIXI.Matrix=c.Matrix,PIXI.identityMatrix=c.identityMatrix,c.Point=function(a,b){a=a||0,b=b||0,this.x=a,this.y=b,this.type=c.POINT},c.Point.prototype={copyFrom:function(a){return this.setTo(a.x,a.y)},invert:function(){return this.setTo(this.y,this.x)},setTo:function(a,b){return this.x=a||0,this.y=b||(0!==b?this.x:0),this},set:function(a,b){return this.x=a||0,this.y=b||(0!==b?this.x:0),this},add:function(a,b){return this.x+=a,this.y+=b,this},subtract:function(a,b){return this.x-=a,this.y-=b,this},multiply:function(a,b){return this.x*=a,this.y*=b,this},divide:function(a,b){return this.x/=a,this.y/=b,this},clampX:function(a,b){return this.x=c.Math.clamp(this.x,a,b),this},clampY:function(a,b){return this.y=c.Math.clamp(this.y,a,b),this},clamp:function(a,b){return this.x=c.Math.clamp(this.x,a,b),this.y=c.Math.clamp(this.y,a,b),this},clone:function(a){return null==a?a=new c.Point(this.x,this.y):a.setTo(this.x,this.y),a},copyTo:function(a){return a.x=this.x,a.y=this.y,a},distance:function(a,b){return c.Point.distance(this,a,b)},equals:function(a){return a.x===this.x&&a.y===this.y},angle:function(a,b){return void 0===b&&(b=!1),b?c.Math.radToDeg(Math.atan2(a.y-this.y,a.x-this.x)):Math.atan2(a.y-this.y,a.x-this.x)},rotate:function(a,b,d,e,f){return c.Point.rotate(this,a,b,d,e,f)},getMagnitude:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},getMagnitudeSq:function(){return this.x*this.x+this.y*this.y},setMagnitude:function(a){return this.normalize().multiply(a,a)},normalize:function(){if(!this.isZero()){var a=this.getMagnitude();this.x/=a,this.y/=a}return this},isZero:function(){return 0===this.x&&0===this.y},dot:function(a){return this.x*a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},perp:function(){return this.setTo(-this.y,this.x)},rperp:function(){return this.setTo(this.y,-this.x)},normalRightHand:function(){return this.setTo(-1*this.y,this.x)},floor:function(){return this.setTo(Math.floor(this.x),Math.floor(this.y))},ceil:function(){return this.setTo(Math.ceil(this.x),Math.ceil(this.y))},toString:function(){return"[{Point (x="+this.x+" y="+this.y+")}]"}},c.Point.prototype.constructor=c.Point,c.Point.add=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x+b.x,d.y=a.y+b.y,d},c.Point.subtract=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x-b.x,d.y=a.y-b.y,d},c.Point.multiply=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x*b.x,d.y=a.y*b.y,d},c.Point.divide=function(a,b,d){return void 0===d&&(d=new c.Point),d.x=a.x/b.x,d.y=a.y/b.y,d},c.Point.equals=function(a,b){return a.x===b.x&&a.y===b.y},c.Point.angle=function(a,b){return Math.atan2(a.y-b.y,a.x-b.x)},c.Point.negative=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(-a.x,-a.y)},c.Point.multiplyAdd=function(a,b,d,e){return void 0===e&&(e=new c.Point),e.setTo(a.x+b.x*d,a.y+b.y*d)},c.Point.interpolate=function(a,b,d,e){return void 0===e&&(e=new c.Point),e.setTo(a.x+(b.x-a.x)*d,a.y+(b.y-a.y)*d)},c.Point.perp=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(-a.y,a.x)},c.Point.rperp=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(a.y,-a.x)},c.Point.distance=function(a,b,d){var e=c.Math.distance(a.x,a.y,b.x,b.y);return d?Math.round(e):e},c.Point.project=function(a,b,d){void 0===d&&(d=new c.Point);var e=a.dot(b)/b.getMagnitudeSq();return 0!==e&&d.setTo(e*b.x,e*b.y),d},c.Point.projectUnit=function(a,b,d){void 0===d&&(d=new c.Point);var e=a.dot(b);return 0!==e&&d.setTo(e*b.x,e*b.y),d},c.Point.normalRightHand=function(a,b){return void 0===b&&(b=new c.Point),b.setTo(-1*a.y,a.x)},c.Point.normalize=function(a,b){void 0===b&&(b=new c.Point);var d=a.getMagnitude();return 0!==d&&b.setTo(a.x/d,a.y/d),b},c.Point.rotate=function(a,b,d,e,f,g){if(f&&(e=c.Math.degToRad(e)),void 0===g){a.subtract(b,d);var h=Math.sin(e),i=Math.cos(e),j=i*a.x-h*a.y,k=h*a.x+i*a.y;a.x=j+b,a.y=k+d}else{var l=e+Math.atan2(a.y-d,a.x-b);a.x=b+g*Math.cos(l),a.y=d+g*Math.sin(l)}return a},c.Point.centroid=function(a,b){if(void 0===b&&(b=new c.Point),"[object Array]"!==Object.prototype.toString.call(a))throw new Error("Phaser.Point. Parameter 'points' must be an array");var d=a.length;if(d<1)throw new Error("Phaser.Point. Parameter 'points' array must not be empty");if(1===d)return b.copyFrom(a[0]),b;for(var e=0;e<d;e++)c.Point.add(b,a[e],b);return b.divide(d,d),b},c.Point.parse=function(a,b,d){b=b||"x",d=d||"y";var e=new c.Point;return a[b]&&(e.x=parseInt(a[b],10)),a[d]&&(e.y=parseInt(a[d],10)),e},PIXI.Point=c.Point,c.Polygon=function(){this.area=0,this._points=[],0<arguments.length&&this.setTo.apply(this,arguments),this.closed=!0,this.flattened=!1,this.type=c.POLYGON},c.Polygon.prototype={toNumberArray:function(a){void 0===a&&(a=[]);for(var b=0;b<this._points.length;b++)"number"==typeof this._points[b]?(a.push(this._points[b]),a.push(this._points[b+1]),b++):(a.push(this._points[b].x),a.push(this._points[b].y));return a},flatten:function(){return this._points=this.toNumberArray(),this.flattened=!0,this},clone:function(a){var b=this._points.slice();return null==a?a=new c.Polygon(b):a.setTo(b),a},contains:function(a,b){var c=!1;if(this.flattened)for(var d=-2,e=this._points.length-2;(d+=2)<this._points.length;e=d){var f=this._points[d],g=this._points[d+1],h=this._points[e],i=this._points[e+1];(g<=b&&b<i||i<=b&&b<g)&&a<(h-f)*(b-g)/(i-g)+f&&(c=!c)}else for(d=-1,e=this._points.length-1;++d<this._points.length;e=d){f=this._points[d].x,g=this._points[d].y,h=this._points[e].x,i=this._points[e].y;(g<=b&&b<i||i<=b&&b<g)&&a<(h-f)*(b-g)/(i-g)+f&&(c=!c)}return c},setTo:function(a){if(this.area=0,this._points=[],0<arguments.length){Array.isArray(a)||(a=Array.prototype.slice.call(arguments));for(var b=Number.MAX_VALUE,c=0,d=a.length;c<d;c++){if("number"==typeof a[c]){var e=new PIXI.Point(a[c],a[c+1]);c++}else if(Array.isArray(a[c]))e=new PIXI.Point(a[c][0],a[c][1]);else e=new PIXI.Point(a[c].x,a[c].y);this._points.push(e),e.y<b&&(b=e.y)}this.calculateArea(b)}return this},calculateArea:function(a){for(var b,c,d,e,f=0,g=this._points.length;f<g;f++)b=this._points[f],c=f===g-1?this._points[0]:this._points[f+1],d=(b.y-a+(c.y-a))/2,e=b.x-c.x,this.area+=d*e;return this.area}},c.Polygon.prototype.constructor=c.Polygon,Object.defineProperty(c.Polygon.prototype,"points",{get:function(){return this._points},set:function(a){null!=a?this.setTo(a):this.setTo()}}),PIXI.Polygon=c.Polygon,c.Rectangle=function(a,b,d,e){a=a||0,b=b||0,d=d||0,e=e||0,this.x=a,this.y=b,this.width=d,this.height=e,this.type=c.RECTANGLE},c.Rectangle.prototype={offset:function(a,b){return this.x+=a,this.y+=b,this},offsetPoint:function(a){return this.offset(a.x,a.y)},setTo:function(a,b,c,d){return this.x=a,this.y=b,this.width=c,this.height=d,this},scale:function(a,b){return void 0===b&&(b=a),this.width*=a,this.height*=b,this},centerOn:function(a,b){return this.centerX=a,this.centerY=b,this},floor:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y)},floorAll:function(){this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.width=Math.floor(this.width),this.height=Math.floor(this.height)},ceil:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y)},ceilAll:function(){this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.width=Math.ceil(this.width),this.height=Math.ceil(this.height)},copyFrom:function(a){return this.setTo(a.x,a.y,a.width,a.height)},copyTo:function(a){return a.x=this.x,a.y=this.y,a.width=this.width,a.height=this.height,a},inflate:function(a,b){return c.Rectangle.inflate(this,a,b)},size:function(a){return c.Rectangle.size(this,a)},resize:function(a,b){return this.width=a,this.height=b,this},clone:function(a){return c.Rectangle.clone(this,a)},contains:function(a,b){return c.Rectangle.contains(this,a,b)},containsRect:function(a){return c.Rectangle.containsRect(a,this)},equals:function(a){return c.Rectangle.equals(this,a)},intersection:function(a,b){return c.Rectangle.intersection(this,a,b)},intersects:function(a){return c.Rectangle.intersects(this,a)},intersectsRaw:function(a,b,d,e,f){return c.Rectangle.intersectsRaw(this,a,b,d,e,f)},union:function(a,b){return c.Rectangle.union(this,a,b)},random:function(a){return void 0===a&&(a=new c.Point),a.x=this.randomX,a.y=this.randomY,a},getPoint:function(a,b){switch(void 0===b&&(b=new c.Point),a){default:case c.TOP_LEFT:return b.set(this.x,this.y);case c.TOP_CENTER:return b.set(this.centerX,this.y);case c.TOP_RIGHT:return b.set(this.right,this.y);case c.LEFT_CENTER:return b.set(this.x,this.centerY);case c.CENTER:return b.set(this.centerX,this.centerY);case c.RIGHT_CENTER:return b.set(this.right,this.centerY);case c.BOTTOM_LEFT:return b.set(this.x,this.bottom);case c.BOTTOM_CENTER:return b.set(this.centerX,this.bottom);case c.BOTTOM_RIGHT:return b.set(this.right,this.bottom)}},toString:function(){return"[{Rectangle (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+" empty="+this.empty+")}]"}},Object.defineProperty(c.Rectangle.prototype,"halfWidth",{get:function(){return Math.round(this.width/2)}}),Object.defineProperty(c.Rectangle.prototype,"halfHeight",{get:function(){return Math.round(this.height/2)}}),Object.defineProperty(c.Rectangle.prototype,"bottom",{get:function(){return this.y+this.height},set:function(a){a<=this.y?this.height=0:this.height=a-this.y}}),Object.defineProperty(c.Rectangle.prototype,"bottomLeft",{get:function(){return new c.Point(this.x,this.bottom)},set:function(a){this.x=a.x,this.bottom=a.y}}),Object.defineProperty(c.Rectangle.prototype,"bottomRight",{get:function(){return new c.Point(this.right,this.bottom)},set:function(a){this.right=a.x,this.bottom=a.y}}),Object.defineProperty(c.Rectangle.prototype,"left",{get:function(){return this.x},set:function(a){a>=this.right?this.width=0:this.width=this.right-a,this.x=a}}),Object.defineProperty(c.Rectangle.prototype,"right",{get:function(){return this.x+this.width},set:function(a){a<=this.x?this.width=0:this.width=a-this.x}}),Object.defineProperty(c.Rectangle.prototype,"volume",{get:function(){return this.width*this.height}}),Object.defineProperty(c.Rectangle.prototype,"perimeter",{get:function(){return 2*this.width+2*this.height}}),Object.defineProperty(c.Rectangle.prototype,"centerX",{get:function(){return this.x+this.halfWidth},set:function(a){this.x=a-this.halfWidth}}),Object.defineProperty(c.Rectangle.prototype,"centerY",{get:function(){return this.y+this.halfHeight},set:function(a){this.y=a-this.halfHeight}}),Object.defineProperty(c.Rectangle.prototype,"randomX",{get:function(){return this.x+Math.random()*this.width}}),Object.defineProperty(c.Rectangle.prototype,"randomY",{get:function(){return this.y+Math.random()*this.height}}),Object.defineProperty(c.Rectangle.prototype,"top",{get:function(){return this.y},set:function(a){a>=this.bottom?(this.height=0,this.y=a):this.height=this.bottom-a}}),Object.defineProperty(c.Rectangle.prototype,"topLeft",{get:function(){return new c.Point(this.x,this.y)},set:function(a){this.x=a.x,this.y=a.y}}),Object.defineProperty(c.Rectangle.prototype,"topRight",{get:function(){return new c.Point(this.x+this.width,this.y)},set:function(a){this.right=a.x,this.y=a.y}}),Object.defineProperty(c.Rectangle.prototype,"empty",{get:function(){return!this.width||!this.height},set:function(a){!0===a&&this.setTo(0,0,0,0)}}),c.Rectangle.prototype.constructor=c.Rectangle,c.Rectangle.inflate=function(a,b,c){return a.x-=b,a.width+=2*b,a.y-=c,a.height+=2*c,a},c.Rectangle.inflatePoint=function(a,b){return c.Rectangle.inflate(a,b.x,b.y)},c.Rectangle.size=function(a,b){return null==b?b=new c.Point(a.width,a.height):b.setTo(a.width,a.height),b},c.Rectangle.clone=function(a,b){return null==b?b=new c.Rectangle(a.x,a.y,a.width,a.height):b.setTo(a.x,a.y,a.width,a.height),b},c.Rectangle.contains=function(a,b,c){return!(a.width<=0||a.height<=0)&&b>=a.x&&b<a.right&&c>=a.y&&c<a.bottom},c.Rectangle.containsRaw=function(a,b,c,d,e,f){return a<=e&&e<a+c&&b<=f&&f<b+d},c.Rectangle.containsPoint=function(a,b){return c.Rectangle.contains(a,b.x,b.y)},c.Rectangle.containsRect=function(a,b){return!(a.volume>b.volume)&&a.x>=b.x&&a.y>=b.y&&a.right<b.right&&a.bottom<b.bottom},c.Rectangle.equals=function(a,b){return a.x===b.x&&a.y===b.y&&a.width===b.width&&a.height===b.height},c.Rectangle.sameDimensions=function(a,b){return a.width===b.width&&a.height===b.height},c.Rectangle.intersection=function(a,b,d){return void 0===d&&(d=new c.Rectangle),c.Rectangle.intersects(a,b)&&(d.x=Math.max(a.x,b.x),d.y=Math.max(a.y,b.y),d.width=Math.min(a.right,b.right)-d.x,d.height=Math.min(a.bottom,b.bottom)-d.y),d},c.Rectangle.intersects=function(a,b){return!(a.width<=0||a.height<=0||b.width<=0||b.height<=0||a.right<b.x||a.bottom<b.y||a.x>b.right||a.y>b.bottom)},c.Rectangle.intersectsRaw=function(a,b,c,d,e,f){return void 0===f&&(f=0),!(b>a.right+f||c<a.left-f||d>a.bottom+f||e<a.top-f)},c.Rectangle.union=function(a,b,d){return void 0===d&&(d=new c.Rectangle),d.setTo(Math.min(a.x,b.x),Math.min(a.y,b.y),Math.max(a.right,b.right)-Math.min(a.left,b.left),Math.max(a.bottom,b.bottom)-Math.min(a.top,b.top))},c.Rectangle.aabb=function(a,b){void 0===b&&(b=new c.Rectangle);var d=Number.NEGATIVE_INFINITY,e=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,g=Number.POSITIVE_INFINITY;return a.forEach(function(a){a.x>d&&(d=a.x),a.x<e&&(e=a.x),a.y>f&&(f=a.y),a.y<g&&(g=a.y)}),b.setTo(e,g,d-e,f-g),b},PIXI.Rectangle=c.Rectangle,PIXI.EmptyRectangle=new c.Rectangle(0,0,0,0),c.RoundedRectangle=function(a,b,d,e,f){void 0===a&&(a=0),void 0===b&&(b=0),void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=20),this.x=a,this.y=b,this.width=d,this.height=e,this.radius=f||20,this.type=c.ROUNDEDRECTANGLE},c.RoundedRectangle.prototype={clone:function(){return new c.RoundedRectangle(this.x,this.y,this.width,this.height,this.radius)},contains:function(a,b){if(this.width<=0||this.height<=0)return!1;var c=this.x;if(c<=a&&a<=c+this.width){var d=this.y;if(d<=b&&b<=d+this.height)return!0}return!1}},c.RoundedRectangle.prototype.constructor=c.RoundedRectangle,PIXI.RoundedRectangle=c.RoundedRectangle,c.Camera=function(a,b,d,e,f,g){this.game=a,this.world=a.world,this.id=0,this.view=new c.Rectangle(d,e,f,g),this.bounds=new c.Rectangle(d,e,f,g),this.deadzone=null,this.visible=!0,this.roundPx=!0,this.atLimit={x:!1,y:!1},this.target=null,this.displayObject=null,this.scale=null,this.totalInView=0,this.lerp=new c.Point(1,1),this.onShakeComplete=new c.Signal,this.onFlashComplete=new c.Signal,this.onFadeComplete=new c.Signal,this.fx=null,this._targetPosition=new c.Point,this._edge=0,this._position=new c.Point,this._shake={intensity:0,duration:0,horizontal:!1,vertical:!1,shakeBounds:!0,x:0,y:0},this._fxDuration=0,this._fxType=0},c.Camera.FOLLOW_LOCKON=0,c.Camera.FOLLOW_PLATFORMER=1,c.Camera.FOLLOW_TOPDOWN=2,c.Camera.FOLLOW_TOPDOWN_TIGHT=3,c.Camera.SHAKE_BOTH=4,c.Camera.SHAKE_HORIZONTAL=5,c.Camera.SHAKE_VERTICAL=6,c.Camera.ENABLE_FX=!0,c.Camera.prototype={boot:function(){this.displayObject=this.game.world,this.scale=this.game.world.scale,this.game.camera=this,c.Graphics&&c.Camera.ENABLE_FX&&(this.fx=new c.Graphics(this.game),this.game.stage.addChild(this.fx))},preUpdate:function(){this.totalInView=0},follow:function(a,b,d,e){var f;switch(void 0===b&&(b=c.Camera.FOLLOW_LOCKON),void 0===d&&(d=1),void 0===e&&(e=1),this.target=a,this.lerp.set(d,e),b){case c.Camera.FOLLOW_PLATFORMER:var g=this.width/8,h=this.height/3;this.deadzone=new c.Rectangle((this.width-g)/2,(this.height-h)/2-.25*h,g,h);break;case c.Camera.FOLLOW_TOPDOWN:f=Math.max(this.width,this.height)/4,this.deadzone=new c.Rectangle((this.width-f)/2,(this.height-f)/2,f,f);break;case c.Camera.FOLLOW_TOPDOWN_TIGHT:f=Math.max(this.width,this.height)/8,this.deadzone=new c.Rectangle((this.width-f)/2,(this.height-f)/2,f,f);break;case c.Camera.FOLLOW_LOCKON:default:this.deadzone=null}},unfollow:function(){this.target=null},focusOn:function(a){this.setPosition(Math.round(a.x-this.view.halfWidth),Math.round(a.y-this.view.halfHeight))},focusOnXY:function(a,b){this.setPosition(Math.round(a-this.view.halfWidth),Math.round(b-this.view.halfHeight))},shake:function(a,b,d,e,f){return void 0===a&&(a=.05),void 0===b&&(b=500),void 0===d&&(d=!0),void 0===e&&(e=c.Camera.SHAKE_BOTH),void 0===f&&(f=!0),!(!d&&0<this._shake.duration||(this._shake.intensity=a,this._shake.duration=b,this._shake.shakeBounds=f,this._shake.x=0,this._shake.y=0,this._shake.horizontal=e===c.Camera.SHAKE_BOTH||e===c.Camera.SHAKE_HORIZONTAL,this._shake.vertical=e===c.Camera.SHAKE_BOTH||e===c.Camera.SHAKE_VERTICAL,0))},flash:function(a,b,c){return void 0===a&&(a=16777215),void 0===b&&(b=500),void 0===c&&(c=!1),!(!this.fx||!c&&0<this._fxDuration||(this.fx.clear(),this.fx.beginFill(a),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=1,this._fxDuration=b,this._fxType=0))},fade:function(a,b,c){return void 0===a&&(a=0),void 0===b&&(b=500),void 0===c&&(c=!1),!(!this.fx||!c&&0<this._fxDuration||(this.fx.clear(),this.fx.beginFill(a),this.fx.drawRect(0,0,this.width,this.height),this.fx.endFill(),this.fx.alpha=0,this._fxDuration=b,this._fxType=1,0))},update:function(){0<this._fxDuration&&this.updateFX(),0<this._shake.duration&&this.updateShake(),this.bounds&&this.checkBounds(),this.roundPx&&(this.view.floor(),this._shake.x=Math.floor(this._shake.x),this._shake.y=Math.floor(this._shake.y)),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},updateFX:function(){0===this._fxType?(this.fx.alpha-=this.game.time.elapsedMS/this._fxDuration,this.fx.alpha<=0&&(this._fxDuration=0,this.fx.alpha=0,this.onFlashComplete.dispatch())):(this.fx.alpha+=this.game.time.elapsedMS/this._fxDuration,1<=this.fx.alpha&&(this._fxDuration=0,this.fx.alpha=1,this.onFadeComplete.dispatch()))},updateShake:function(){this._shake.duration-=this.game.time.elapsedMS,this._shake.duration<=0?(this.onShakeComplete.dispatch(),this._shake.x=0,this._shake.y=0):(this._shake.horizontal&&(this._shake.x=this.game.rnd.frac()*this._shake.intensity*this.view.width*2-this._shake.intensity*this.view.width),this._shake.vertical&&(this._shake.y=this.game.rnd.frac()*this._shake.intensity*this.view.height*2-this._shake.intensity*this.view.height))},updateTarget:function(){this._targetPosition.x=this.view.x+this.target.worldPosition.x,this._targetPosition.y=this.view.y+this.target.worldPosition.y,this.deadzone?(this._edge=this._targetPosition.x-this.view.x,this._edge<this.deadzone.left?this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.left,this.lerp.x):this._edge>this.deadzone.right&&(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.deadzone.right,this.lerp.x)),this._edge=this._targetPosition.y-this.view.y,this._edge<this.deadzone.top?this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.top,this.lerp.y):this._edge>this.deadzone.bottom&&(this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.deadzone.bottom,this.lerp.y))):(this.view.x=this.game.math.linear(this.view.x,this._targetPosition.x-this.view.halfWidth,this.lerp.x),this.view.y=this.game.math.linear(this.view.y,this._targetPosition.y-this.view.halfHeight,this.lerp.y)),this.bounds&&this.checkBounds(),this.roundPx&&this.view.floor(),this.displayObject.position.x=-this.view.x,this.displayObject.position.y=-this.view.y},setBoundsToWorld:function(){this.bounds&&this.bounds.copyFrom(this.game.world.bounds)},checkBounds:function(){this.atLimit.x=!1,this.atLimit.y=!1;var a=this.view.x+this._shake.x,b=this.view.right+this._shake.x,c=this.view.y+this._shake.y,d=this.view.bottom+this._shake.y;a<=this.bounds.x*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.x*this.scale.x,this._shake.shakeBounds||(this._shake.x=0)),b>=this.bounds.right*this.scale.x&&(this.atLimit.x=!0,this.view.x=this.bounds.right*this.scale.x-this.width,this._shake.shakeBounds||(this._shake.x=0)),c<=this.bounds.top*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.top*this.scale.y,this._shake.shakeBounds||(this._shake.y=0)),d>=this.bounds.bottom*this.scale.y&&(this.atLimit.y=!0,this.view.y=this.bounds.bottom*this.scale.y-this.height,this._shake.shakeBounds||(this._shake.y=0))},setPosition:function(a,b){this.view.x=a,this.view.y=b,this.bounds&&this.checkBounds()},setSize:function(a,b){this.view.width=a,this.view.height=b},reset:function(){this.target=null,this.view.x=0,this.view.y=0,this._shake.duration=0,this.resetFX()},resetFX:function(){this.fx&&(this.fx.clear(),this.fx.alpha=0,this._fxDuration=0)}},c.Camera.prototype.constructor=c.Camera,Object.defineProperty(c.Camera.prototype,"x",{get:function(){return this.view.x},set:function(a){this.view.x=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(c.Camera.prototype,"y",{get:function(){return this.view.y},set:function(a){this.view.y=a,this.bounds&&this.checkBounds()}}),Object.defineProperty(c.Camera.prototype,"position",{get:function(){return this._position.set(this.view.x,this.view.y),this._position},set:function(a){void 0!==a.x&&(this.view.x=a.x),void 0!==a.y&&(this.view.y=a.y),this.bounds&&this.checkBounds()}}),Object.defineProperty(c.Camera.prototype,"width",{get:function(){return this.view.width},set:function(a){this.view.width=a}}),Object.defineProperty(c.Camera.prototype,"height",{get:function(){return this.view.height},set:function(a){this.view.height=a}}),Object.defineProperty(c.Camera.prototype,"shakeIntensity",{get:function(){return this._shake.intensity},set:function(a){this._shake.intensity=a}}),c.State=function(){this.game=null,this.key="",this.add=null,this.make=null,this.camera=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.sound=null,this.scale=null,this.stage=null,this.state=null,this.time=null,this.tweens=null,this.world=null,this.particles=null,this.physics=null,this.rnd=null},c.State.prototype={init:function(){},preload:function(){},loadUpdate:function(){},loadRender:function(){},create:function(){},update:function(){},preRender:function(){},render:function(){},resize:function(){},paused:function(){},resumed:function(){},pauseUpdate:function(){},shutdown:function(){}},c.State.prototype.constructor=c.State,c.StateManager=function(a,b){this.game=a,this.states={},(this._pendingState=null)!=b&&(this._pendingState=b),this._clearWorld=!1,this._clearCache=!1,this._created=!1,this._args=[],this.current="",this.onStateChange=new c.Signal,this.onInitCallback=null,this.onPreloadCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPreRenderCallback=null,this.onLoadUpdateCallback=null,this.onLoadRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.onShutDownCallback=null},c.StateManager.prototype={boot:function(){this.game.onPause.add(this.pause,this),this.game.onResume.add(this.resume,this),null!==this._pendingState&&"string"!=typeof this._pendingState&&this.add("default",this._pendingState,!0)},add:function(a,b,d){var e;return void 0===d&&(d=!1),b instanceof c.State?e=b:"object"==typeof b?(e=b).game=this.game:"function"==typeof b&&(e=new b(this.game)),this.states[a]=e,d&&(this.game.isBooted?this.start(a):this._pendingState=a),e},remove:function(a){this.current===a&&(this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onPreRenderCallback=null,this.onRenderCallback=null,this.onResizeCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null),delete this.states[a]},start:function(a,b,c){void 0===b&&(b=!0),void 0===c&&(c=!1),this.checkState(a)&&(this._pendingState=a,this._clearWorld=b,this._clearCache=c,3<arguments.length&&(this._args=Array.prototype.splice.call(arguments,3)))},restart:function(a,b){void 0===a&&(a=!0),void 0===b&&(b=!1),this._pendingState=this.current,this._clearWorld=a,this._clearCache=b,2<arguments.length&&(this._args=Array.prototype.slice.call(arguments,2))},dummy:function(){},preUpdate:function(){if(this._pendingState&&this.game.isBooted){var a=this.current;if(this.clearCurrentState(),this.setCurrentState(this._pendingState),this.onStateChange.dispatch(this.current,a),this.current!==this._pendingState)return;this._pendingState=null,this.onPreloadCallback?(this.game.load.reset(!0),this.onPreloadCallback.call(this.callbackContext,this.game),0===this.game.load.totalQueuedFiles()&&0===this.game.load.totalQueuedPacks()?this.loadComplete():this.game.load.start()):this.loadComplete()}},clearCurrentState:function(){this.current&&(this.onShutDownCallback&&this.onShutDownCallback.call(this.callbackContext,this.game),this.game.tweens.removeAll(),this.game.camera.reset(),this.game.input.reset(!0),this.game.physics.clear(),this.game.time.removeAll(),this.game.scale.reset(this._clearWorld),this.game.debug&&this.game.debug.reset(),this._clearWorld&&(this.game.world.shutdown(),this._clearCache&&this.game.cache.destroy()))},checkState:function(a){return this.states[a]&&!!(this.states[a].preload||this.states[a].create||this.states[a].update||this.states[a].render)||!1},link:function(a){this.states[a].game=this.game,this.states[a].add=this.game.add,this.states[a].make=this.game.make,this.states[a].camera=this.game.camera,this.states[a].cache=this.game.cache,this.states[a].input=this.game.input,this.states[a].load=this.game.load,this.states[a].math=this.game.math,this.states[a].sound=this.game.sound,this.states[a].scale=this.game.scale,(this.states[a].state=this).states[a].stage=this.game.stage,this.states[a].time=this.game.time,this.states[a].tweens=this.game.tweens,this.states[a].world=this.game.world,this.states[a].particles=this.game.particles,this.states[a].rnd=this.game.rnd,this.states[a].physics=this.game.physics,this.states[a].key=a},unlink:function(a){this.states[a]&&(this.states[a].game=null,this.states[a].add=null,this.states[a].make=null,this.states[a].camera=null,this.states[a].cache=null,this.states[a].input=null,this.states[a].load=null,this.states[a].math=null,this.states[a].sound=null,this.states[a].scale=null,this.states[a].state=null,this.states[a].stage=null,this.states[a].time=null,this.states[a].tweens=null,this.states[a].world=null,this.states[a].particles=null,this.states[a].rnd=null,this.states[a].physics=null)},setCurrentState:function(a){this.callbackContext=this.states[a],this.link(a),this.onInitCallback=this.states[a].init||this.dummy,this.onPreloadCallback=this.states[a].preload||null,this.onLoadRenderCallback=this.states[a].loadRender||null,this.onLoadUpdateCallback=this.states[a].loadUpdate||null,this.onCreateCallback=this.states[a].create||null,this.onUpdateCallback=this.states[a].update||null,this.onPreRenderCallback=this.states[a].preRender||null,this.onRenderCallback=this.states[a].render||null,this.onResizeCallback=this.states[a].resize||null,this.onPausedCallback=this.states[a].paused||null,this.onResumedCallback=this.states[a].resumed||null,this.onPauseUpdateCallback=this.states[a].pauseUpdate||null,this.onShutDownCallback=this.states[a].shutdown||this.dummy,""!==this.current&&this.game.physics.reset(),this.current=a,this._created=!1,this.onInitCallback.apply(this.callbackContext,this._args),a===this._pendingState&&(this._args=[]),this.game._kickstart=!0},getCurrentState:function(){return this.states[this.current]},loadComplete:function(){!1===this._created&&this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game),!1===this._created&&this.onCreateCallback?(this._created=!0,this.onCreateCallback.call(this.callbackContext,this.game)):this._created=!0},pause:function(){this._created&&this.onPausedCallback&&this.onPausedCallback.call(this.callbackContext,this.game)},resume:function(){this._created&&this.onResumedCallback&&this.onResumedCallback.call(this.callbackContext,this.game)},update:function(){this._created?this.onUpdateCallback&&this.onUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},pauseUpdate:function(){this._created?this.onPauseUpdateCallback&&this.onPauseUpdateCallback.call(this.callbackContext,this.game):this.onLoadUpdateCallback&&this.onLoadUpdateCallback.call(this.callbackContext,this.game)},preRender:function(a){this._created&&this.onPreRenderCallback&&this.onPreRenderCallback.call(this.callbackContext,this.game,a)},resize:function(a,b){this.onResizeCallback&&this.onResizeCallback.call(this.callbackContext,a,b)},render:function(){this._created?this.onRenderCallback&&(this.game.renderType===c.CANVAS?(this.game.context.save(),this.game.context.setTransform(1,0,0,1,0,0),this.onRenderCallback.call(this.callbackContext,this.game),this.game.context.restore()):this.onRenderCallback.call(this.callbackContext,this.game)):this.onLoadRenderCallback&&this.onLoadRenderCallback.call(this.callbackContext,this.game)},destroy:function(){this._clearWorld=!0,this._clearCache=!0,this.clearCurrentState(),this.callbackContext=null,this.onInitCallback=null,this.onShutDownCallback=null,this.onPreloadCallback=null,this.onLoadRenderCallback=null,this.onLoadUpdateCallback=null,this.onCreateCallback=null,this.onUpdateCallback=null,this.onRenderCallback=null,this.onPausedCallback=null,this.onResumedCallback=null,this.onPauseUpdateCallback=null,this.game=null,this.states={},this._pendingState=null,this.current=""}},c.StateManager.prototype.constructor=c.StateManager,Object.defineProperty(c.StateManager.prototype,"created",{get:function(){return this._created}}),c.Signal=function(){},c.Signal.prototype={_bindings:null,_prevParams:null,memorize:!1,_shouldPropagate:!0,active:!0,_boundDispatch:!1,validateListener:function(a,b){if("function"!=typeof a)throw new Error("Phaser.Signal: listener is a required param of {fn}() and should be a Function.".replace("{fn}",b))},_registerListener:function(a,b,d,e,f){var g,h=this._indexOfListener(a,d);if(-1!==h){if((g=this._bindings[h]).isOnce()!==b)throw new Error("You cannot add"+(b?"":"Once")+"() then add"+(b?"Once":"")+"() the same listener without removing the relationship first.")}else g=new c.SignalBinding(this,a,b,d,e,f),this._addBinding(g);return this.memorize&&this._prevParams&&g.execute(this._prevParams),g},_addBinding:function(a){this._bindings||(this._bindings=[]);for(var b=this._bindings.length;b--,this._bindings[b]&&a._priority<=this._bindings[b]._priority;);this._bindings.splice(b+1,0,a)},_indexOfListener:function(a,b){if(!this._bindings)return-1;void 0===b&&(b=null);for(var c,d=this._bindings.length;d--;)if((c=this._bindings[d])._listener===a&&c.context===b)return d;return-1},has:function(a,b){return-1!==this._indexOfListener(a,b)},add:function(a,b,c){this.validateListener(a,"add");var d=[];if(3<arguments.length)for(var e=3;e<arguments.length;e++)d.push(arguments[e]);return this._registerListener(a,!1,b,c,d)},addOnce:function(a,b,c){this.validateListener(a,"addOnce");var d=[];if(3<arguments.length)for(var e=3;e<arguments.length;e++)d.push(arguments[e]);return this._registerListener(a,!0,b,c,d)},remove:function(a,b){this.validateListener(a,"remove");var c=this._indexOfListener(a,b);return-1!==c&&(this._bindings[c]._destroy(),this._bindings.splice(c,1)),a},removeAll:function(a){if(void 0===a&&(a=null),this._bindings){for(var b=this._bindings.length;b--;)a?this._bindings[b].context===a&&(this._bindings[b]._destroy(),this._bindings.splice(b,1)):this._bindings[b]._destroy();a||(this._bindings.length=0)}},getNumListeners:function(){return this._bindings?this._bindings.length:0},halt:function(){this._shouldPropagate=!1},dispatch:function(){if(this.active&&this._bindings){var a,b=Array.prototype.slice.call(arguments),c=this._bindings.length;if(this.memorize&&(this._prevParams=b),c)for(a=this._bindings.slice(),this._shouldPropagate=!0;a[--c]&&this._shouldPropagate&&!1!==a[c].execute(b););}},forget:function(){this._prevParams&&(this._prevParams=null)},dispose:function(){this.removeAll(),this._bindings=null,this._prevParams&&(this._prevParams=null)},toString:function(){return"[Phaser.Signal active:"+this.active+" numListeners:"+this.getNumListeners()+"]"}},Object.defineProperty(c.Signal.prototype,"boundDispatch",{get:function(){var a=this;return this._boundDispatch||(this._boundDispatch=function(){return a.dispatch.apply(a,arguments)})}}),c.Signal.prototype.constructor=c.Signal,c.SignalBinding=function(a,b,c,d,e,f){this._listener=b,c&&(this._isOnce=!0),null!=d&&(this.context=d),this._signal=a,e&&(this._priority=e),f&&f.length&&(this._args=f)},c.SignalBinding.prototype={context:null,_isOnce:!1,_priority:0,_args:null,callCount:0,active:!0,params:null,execute:function(a){var b,c;return this.active&&this._listener&&(c=this.params?this.params.concat(a):a,this._args&&(c=c.concat(this._args)),b=this._listener.apply(this.context,c),this.callCount++,this._isOnce&&this.detach()),b},detach:function(){return this.isBound()?this._signal.remove(this._listener,this.context):null},isBound:function(){return!!this._signal&&!!this._listener},isOnce:function(){return this._isOnce},getListener:function(){return this._listener},getSignal:function(){return this._signal},_destroy:function(){delete this._signal,delete this._listener,delete this.context},toString:function(){return"[Phaser.SignalBinding isOnce:"+this._isOnce+", isBound:"+this.isBound()+", active:"+this.active+"]"}},c.SignalBinding.prototype.constructor=c.SignalBinding,c.Filter=function(a,b,d){this.game=a,this.type=c.WEBGL_FILTER,this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.prevPoint=new c.Point;var e=new Date;if(this.uniforms={resolution:{type:"2f",value:{x:256,y:256}},time:{type:"1f",value:0},mouse:{type:"2f",value:{x:0,y:0}},date:{type:"4fv",value:[e.getFullYear(),e.getMonth(),e.getDate(),60*e.getHours()*60+60*e.getMinutes()+e.getSeconds()]},sampleRate:{type:"1f",value:44100},iChannel0:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel1:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel2:{type:"sampler2D",value:null,textureData:{repeat:!0}},iChannel3:{type:"sampler2D",value:null,textureData:{repeat:!0}}},b)for(var f in b)this.uniforms[f]=b[f];this.fragmentSrc=d||""},c.Filter.prototype={init:function(){},setResolution:function(a,b){this.uniforms.resolution.value.x=a,this.uniforms.resolution.value.y=b},update:function(a){if(void 0!==a){var b=a.x/this.game.width,c=1-a.y/this.game.height;b===this.prevPoint.x&&c===this.prevPoint.y||(this.uniforms.mouse.value.x=b.toFixed(2),this.uniforms.mouse.value.y=c.toFixed(2),this.prevPoint.set(b,c))}this.uniforms.time.value=this.game.time.totalElapsedSeconds()},addToWorld:function(a,b,c,d,e,f){void 0===e&&(e=0),void 0===f&&(f=0),null!=c?this.width=c:c=this.width,null!=d?this.height=d:d=this.height;var g=this.game.add.image(a,b,"__default");return g.width=c,g.height=d,g.anchor.set(e,f),g.filters=[this],g},destroy:function(){this.game=null}},c.Filter.prototype.constructor=c.Filter,Object.defineProperty(c.Filter.prototype,"width",{get:function(){return this.uniforms.resolution.value.x},set:function(a){this.uniforms.resolution.value.x=a}}),Object.defineProperty(c.Filter.prototype,"height",{get:function(){return this.uniforms.resolution.value.y},set:function(a){this.uniforms.resolution.value.y=a}}),c.Plugin=function(a,b){void 0===b&&(b=null),this.game=a,this.parent=b,this.active=!1,this.visible=!1,this.hasPreUpdate=!1,this.hasUpdate=!1,this.hasPostUpdate=!1,this.hasRender=!1,this.hasPostRender=!1},c.Plugin.prototype={preUpdate:function(){},update:function(){},render:function(){},postRender:function(){},destroy:function(){this.game=null,this.parent=null,this.active=!1,this.visible=!1}},c.Plugin.prototype.constructor=c.Plugin,c.PluginManager=function(a){this.game=a,this.plugins=[],this._len=0,this._i=0},c.PluginManager.prototype={add:function(a){var b=Array.prototype.slice.call(arguments,1),c=!1;return"function"==typeof a?a=new a(this.game,this):(a.game=this.game,a.parent=this),"function"==typeof a.preUpdate&&(c=a.hasPreUpdate=!0),"function"==typeof a.update&&(c=a.hasUpdate=!0),"function"==typeof a.postUpdate&&(c=a.hasPostUpdate=!0),"function"==typeof a.render&&(c=a.hasRender=!0),"function"==typeof a.postRender&&(c=a.hasPostRender=!0),c?((a.hasPreUpdate||a.hasUpdate||a.hasPostUpdate)&&(a.active=!0),(a.hasRender||a.hasPostRender)&&(a.visible=!0),this._len=this.plugins.push(a),"function"==typeof a.init&&a.init.apply(a,b),a):null},remove:function(a,b){for(void 0===b&&(b=!0),this._i=this._len;this._i--;)if(this.plugins[this._i]===a)return b&&a.destroy(),this.plugins.splice(this._i,1),void this._len--},removeAll:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].destroy();this.plugins.length=0,this._len=0},preUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPreUpdate&&this.plugins[this._i].preUpdate()},update:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasUpdate&&this.plugins[this._i].update()},postUpdate:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].active&&this.plugins[this._i].hasPostUpdate&&this.plugins[this._i].postUpdate()},render:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasRender&&this.plugins[this._i].render()},postRender:function(){for(this._i=this._len;this._i--;)this.plugins[this._i].visible&&this.plugins[this._i].hasPostRender&&this.plugins[this._i].postRender()},destroy:function(){this.removeAll(),this.game=null}},c.PluginManager.prototype.constructor=c.PluginManager,c.Stage=function(a){this.game=a,PIXI.DisplayObjectContainer.call(this),this.name="_stage_root",this.disableVisibilityChange=!1,this.exists=!0,this.worldTransform=new PIXI.Matrix,(this.stage=this).currentRenderOrderID=0,this._hiddenVar="hidden",this._onChange=null,this._bgColor={r:0,g:0,b:0,a:0,color:0,rgba:"#000000"},this.game.transparent||(this._bgColor.a=1),a.config&&this.parseConfig(a.config)},c.Stage.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),c.Stage.prototype.constructor=c.Stage,c.Stage.prototype.parseConfig=function(a){a.disableVisibilityChange&&(this.disableVisibilityChange=a.disableVisibilityChange),a.backgroundColor&&this.setBackgroundColor(a.backgroundColor)},c.Stage.prototype.boot=function(){c.DOM.getOffset(this.game.canvas,this.offset),c.Canvas.setUserSelect(this.game.canvas,"none"),c.Canvas.setTouchAction(this.game.canvas,"none"),this.checkVisibility()},c.Stage.prototype.preUpdate=function(){for(var a=this.currentRenderOrderID=0;a<this.children.length;){var b=this.children[a];b.preUpdate(),this===b.parent&&a++}},c.Stage.prototype.update=function(){for(var a=this.children.length;a--;)this.children[a].update()},c.Stage.prototype.postUpdate=function(){this.game.camera.update(),this.game.camera.target&&(this.game.camera.target.postUpdate(),this.updateTransform(),this.game.camera.updateTarget());for(var a=0;a<this.children.length;a++)this.children[a].postUpdate();this.updateTransform()},c.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var a=0;a<this.children.length;a++)this.children[a].updateTransform()},c.Stage.prototype.checkVisibility=function(){void 0!==document.hidden?this._hiddenVar="visibilitychange":void 0!==document.webkitHidden?this._hiddenVar="webkitvisibilitychange":void 0!==document.mozHidden?this._hiddenVar="mozvisibilitychange":void 0!==document.msHidden?this._hiddenVar="msvisibilitychange":this._hiddenVar=null;var a=this;this._onChange=function(b){return a.visibilityChange(b)},this._onClick=function(b){document.hasFocus()||a.visibilityChange(b)},this._hiddenVar&&document.addEventListener(this._hiddenVar,this._onChange,!1),window.onblur=this._onChange,window.onfocus=this._onChange,window.onpagehide=this._onChange,window.onpageshow=this._onChange,window.addEventListener("click",this._onClick),this.game.device.cocoonJSApp&&(CocoonJS.App.onSuspended.addEventListener(function(){c.Stage.prototype.visibilityChange.call(a,{type:"pause"})}),CocoonJS.App.onActivated.addEventListener(function(){c.Stage.prototype.visibilityChange.call(a,{type:"resume"})}))},c.Stage.prototype.visibilityChange=function(a){switch(a.type){case"blur":case"pagehide":return void this.game.focusLoss(a);case"click":case"focus":case"pageshow":return void this.game.focusGain(a)}this.disableVisibilityChange||(document.hidden||document.mozHidden||document.msHidden||document.webkitHidden||"pause"===a.type?this.game.gamePaused(a):this.game.gameResumed(a))},c.Stage.prototype.setBackgroundColor=function(a){this.game.transparent||(c.Color.valueToColor(a,this._bgColor),c.Color.updateColor(this._bgColor),this._bgColor.r/=255,this._bgColor.g/=255,this._bgColor.b/=255,this._bgColor.a=1)},c.Stage.prototype.destroy=function(){this._hiddenVar&&document.removeEventListener(this._hiddenVar,this._onChange,!1),window.onpagehide=null,window.onpageshow=null,window.onblur=null,window.onfocus=null,window.removeEventListener("click",this._onClick)},Object.defineProperty(c.Stage.prototype,"backgroundColor",{get:function(){return this._bgColor.color},set:function(a){this.setBackgroundColor(a)}}),Object.defineProperty(c.Stage.prototype,"smoothed",{get:function(){return PIXI.scaleModes.DEFAULT===PIXI.scaleModes.LINEAR},set:function(a){PIXI.scaleModes.DEFAULT=a?PIXI.scaleModes.LINEAR:PIXI.scaleModes.NEAREST}}),c.Group=function(a,b,d,e,f,g){void 0===e&&(e=!1),void 0===f&&(f=!1),void 0===g&&(g=c.Physics.ARCADE),this.game=a,void 0===b&&(b=a.world),this.name=d||"group",this.z=0,PIXI.DisplayObjectContainer.call(this),e?(this.game.stage.addChild(this),this.z=this.game.stage.children.length):b&&(b.addChild(this),this.z=b.children.length),this.type=c.GROUP,this.physicsType=c.GROUP,this.alive=!0,this.exists=!0,this.ignoreDestroy=!1,this.pendingDestroy=!1,this.classType=c.Sprite,this.cursor=null,this.inputEnableChildren=!1,this.onChildInputDown=new c.Signal,this.onChildInputUp=new c.Signal,this.onChildInputOver=new c.Signal,this.onChildInputOut=new c.Signal,this.enableBody=f,this.enableBodyDebug=!1,this.physicsBodyType=g,this.physicsSortDirection=null,this.onDestroy=new c.Signal,this.cursorIndex=0,this.fixedToCamera=!1,this.cameraOffset=new c.Point,this.hash=[],this._sortProperty="z"},c.Group.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),c.Group.prototype.constructor=c.Group,c.Group.RETURN_NONE=0,c.Group.RETURN_TOTAL=1,c.Group.RETURN_CHILD=2,c.Group.RETURN_ALL=3,c.Group.SORT_ASCENDING=-1,c.Group.SORT_DESCENDING=1,c.Group.prototype.add=function(a,b,c){return void 0===b&&(b=!1),a.parent===this||(a.body&&a.parent&&a.parent.hash&&a.parent.removeFromHash(a),void 0===c?(a.z=this.children.length,this.addChild(a)):(this.addChildAt(a,c),this.updateZ()),this.enableBody&&a.hasOwnProperty("body")&&null===a.body?this.game.physics.enable(a,this.physicsBodyType):a.body&&this.addToHash(a),!this.inputEnableChildren||a.input&&!a.inputEnabled||(a.inputEnabled=!0),!b&&a.events&&a.events.onAddedToGroup$dispatch(a,this),null===this.cursor&&(this.cursor=a)),a},c.Group.prototype.addAt=function(a,b,c){this.add(a,c,b)},c.Group.prototype.addToHash=function(a){return a.parent===this&&-1===this.hash.indexOf(a)&&(this.hash.push(a),!0)},c.Group.prototype.removeFromHash=function(a){if(a){var b=this.hash.indexOf(a);if(-1!==b)return this.hash.splice(b,1),!0}return!1},c.Group.prototype.addMultiple=function(a,b){if(a instanceof c.Group)a.moveAll(this,b);else if(Array.isArray(a))for(var d=0;d<a.length;d++)this.add(a[d],b);return a},c.Group.prototype.getAt=function(a){return a<0||a>=this.children.length?-1:this.getChildAt(a)},c.Group.prototype.create=function(a,b,c,d,e,f){void 0===e&&(e=!0);var g=new this.classType(this.game,a,b,c,d);return g.exists=e,g.visible=e,g.alive=e,this.add(g,!1,f)},c.Group.prototype.createMultiple=function(a,b,c,d){void 0===c&&(c=0),void 0===d&&(d=!1),Array.isArray(b)||(b=[b]),Array.isArray(c)||(c=[c]);var e=this,f=[];return b.forEach(function(b){c.forEach(function(c){for(var g=0;g<a;g++)f.push(e.create(0,0,b,c,d))})}),f},c.Group.prototype.updateZ=function(){for(var a=this.children.length;a--;)this.children[a].z=a},c.Group.prototype.align=function(a,b,d,e,f,g){if(void 0===f&&(f=c.TOP_LEFT),void 0===g&&(g=0),0===this.children.length||g>this.children.length||-1===a&&-1===b)return!1;for(var h=new c.Rectangle(0,0,d,e),i=a*d,j=b*e,k=g;k<this.children.length;k++){var l=this.children[k];if(l.alignIn)if(l.alignIn(h,f),-1===a)h.y+=e,h.y===j&&(h.x+=d,h.y=0);else if(-1===b)h.x+=d,h.x===i&&(h.x=0,h.y+=e);else if(h.x+=d,h.x===i&&(h.x=0,h.y+=e,h.y===j))return!0}return!0},c.Group.prototype.resetCursor=function(a){if(void 0===a&&(a=0),a>this.children.length-1&&(a=0),this.cursor)return this.cursorIndex=a,this.cursor=this.children[this.cursorIndex],this.cursor},c.Group.prototype.next=function(){if(this.cursor)return this.cursorIndex>=this.children.length-1?this.cursorIndex=0:this.cursorIndex++,this.cursor=this.children[this.cursorIndex],this.cursor},c.Group.prototype.previous=function(){if(this.cursor)return 0===this.cursorIndex?this.cursorIndex=this.children.length-1:this.cursorIndex--,this.cursor=this.children[this.cursorIndex],this.cursor},c.Group.prototype.swap=function(a,b){this.swapChildren(a,b),this.updateZ()},c.Group.prototype.bringToTop=function(a){return a.parent===this&&this.getIndex(a)<this.children.length&&(this.remove(a,!1,!0),this.add(a,!0)),a},c.Group.prototype.sendToBack=function(a){return a.parent===this&&0<this.getIndex(a)&&(this.remove(a,!1,!0),this.addAt(a,0,!0)),a},c.Group.prototype.moveUp=function(a){if(a.parent===this&&this.getIndex(a)<this.children.length-1){var b=this.getIndex(a),c=this.getAt(b+1);c&&this.swap(a,c)}return a},c.Group.prototype.moveDown=function(a){if(a.parent===this&&0<this.getIndex(a)){var b=this.getIndex(a),c=this.getAt(b-1);c&&this.swap(a,c)}return a},c.Group.prototype.xy=function(a,b,c){if(a<0||a>this.children.length)return-1;this.getChildAt(a).x=b,this.getChildAt(a).y=c},c.Group.prototype.reverse=function(){this.children.reverse(),this.updateZ()},c.Group.prototype.getIndex=function(a){return this.children.indexOf(a)},c.Group.prototype.getByName=function(a){for(var b=0;b<this.children.length;b++)if(this.children[b].name===a)return this.children[b];return null},c.Group.prototype.replace=function(a,b){var d=this.getIndex(a);if(-1!==d)return b.parent&&(b.parent instanceof c.Group?b.parent.remove(b):b.parent.removeChild(b)),this.remove(a),this.addAt(b,d),a},c.Group.prototype.hasProperty=function(a,b){var c=b.length;return 1===c&&b[0]in a||2===c&&b[0]in a&&b[1]in a[b[0]]||3===c&&b[0]in a&&b[1]in a[b[0]]&&b[2]in a[b[0]][b[1]]||4===c&&b[0]in a&&b[1]in a[b[0]]&&b[2]in a[b[0]][b[1]]&&b[3]in a[b[0]][b[1]][b[2]]},c.Group.prototype.setProperty=function(a,b,c,d,e){if(void 0===e&&(e=!1),d=d||0,!this.hasProperty(a,b)&&(!e||0<d))return!1;var f=b.length;return 1===f?0===d?a[b[0]]=c:1===d?a[b[0]]+=c:2===d?a[b[0]]-=c:3===d?a[b[0]]*=c:4===d&&(a[b[0]]/=c):2===f?0===d?a[b[0]][b[1]]=c:1===d?a[b[0]][b[1]]+=c:2===d?a[b[0]][b[1]]-=c:3===d?a[b[0]][b[1]]*=c:4===d&&(a[b[0]][b[1]]/=c):3===f?0===d?a[b[0]][b[1]][b[2]]=c:1===d?a[b[0]][b[1]][b[2]]+=c:2===d?a[b[0]][b[1]][b[2]]-=c:3===d?a[b[0]][b[1]][b[2]]*=c:4===d&&(a[b[0]][b[1]][b[2]]/=c):4===f&&(0===d?a[b[0]][b[1]][b[2]][b[3]]=c:1===d?a[b[0]][b[1]][b[2]][b[3]]+=c:2===d?a[b[0]][b[1]][b[2]][b[3]]-=c:3===d?a[b[0]][b[1]][b[2]][b[3]]*=c:4===d&&(a[b[0]][b[1]][b[2]][b[3]]/=c)),!0},c.Group.prototype.checkProperty=function(a,b,d,e){return void 0===e&&(e=!1),!(!c.Utils.getProperty(a,b)&&e)&&c.Utils.getProperty(a,b)===d},c.Group.prototype.set=function(a,b,c,d,e,f,g){if(void 0===g&&(g=!1),b=b.split("."),void 0===d&&(d=!1),void 0===e&&(e=!1),(!1===d||d&&a.alive)&&(!1===e||e&&a.visible))return this.setProperty(a,b,c,f,g)},c.Group.prototype.setAll=function(a,b,c,d,e,f){void 0===c&&(c=!1),void 0===d&&(d=!1),void 0===f&&(f=!1),a=a.split("."),e=e||0;for(var g=0;g<this.children.length;g++)(!c||c&&this.children[g].alive)&&(!d||d&&this.children[g].visible)&&this.setProperty(this.children[g],a,b,e,f)},c.Group.prototype.setAllChildren=function(a,b,d,e,f,g){void 0===d&&(d=!1),void 0===e&&(e=!1),void 0===g&&(g=!1),f=f||0;for(var h=0;h<this.children.length;h++)(!d||d&&this.children[h].alive)&&(!e||e&&this.children[h].visible)&&(this.children[h]instanceof c.Group?this.children[h].setAllChildren(a,b,d,e,f,g):this.setProperty(this.children[h],a.split("."),b,f,g))},c.Group.prototype.checkAll=function(a,b,c,d,e){void 0===c&&(c=!1),void 0===d&&(d=!1),void 0===e&&(e=!1);for(var f=0;f<this.children.length;f++)if((!c||c&&this.children[f].alive)&&(!d||d&&this.children[f].visible)&&!this.checkProperty(this.children[f],a,b,e))return!1;return!0},c.Group.prototype.addAll=function(a,b,c,d){this.setAll(a,b,c,d,1)},c.Group.prototype.subAll=function(a,b,c,d){this.setAll(a,b,c,d,2)},c.Group.prototype.multiplyAll=function(a,b,c,d){this.setAll(a,b,c,d,3)},c.Group.prototype.divideAll=function(a,b,c,d){this.setAll(a,b,c,d,4)},c.Group.prototype.callAllExists=function(a,b){var c;if(2<arguments.length){c=[];for(var d=2;d<arguments.length;d++)c.push(arguments[d])}for(d=0;d<this.children.length;d++)this.children[d].exists===b&&this.children[d][a]&&this.children[d][a].apply(this.children[d],c)},c.Group.prototype.callbackFromArray=function(a,b,c){if(1===c){if(a[b[0]])return a[b[0]]}else if(2===c){if(a[b[0]][b[1]])return a[b[0]][b[1]]}else if(3===c){if(a[b[0]][b[1]][b[2]])return a[b[0]][b[1]][b[2]]}else if(4===c){if(a[b[0]][b[1]][b[2]][b[3]])return a[b[0]][b[1]][b[2]][b[3]]}else if(a[b])return a[b];return!1},c.Group.prototype.callAll=function(a,b){if(void 0!==a){var e,c=(a=a.split(".")).length;if(null==b||""===b)b=null;else if("string"==typeof b)var d=(b=b.split(".")).length;if(2<arguments.length){e=[];for(var f=2;f<arguments.length;f++)e.push(arguments[f])}var g=null,h=null;for(f=0;f<this.children.length;f++)g=this.callbackFromArray(this.children[f],a,c),b&&g?(h=this.callbackFromArray(this.children[f],b,d),g&&g.apply(h,e)):g&&g.apply(this.children[f],e)}},c.Group.prototype.preUpdate=function(){if(this.pendingDestroy)return this.destroy(),!1;if(!this.exists||!this.parent.exists)return!(this.renderOrderID=-1);for(var a=0;a<this.children.length;a++)this.children[a].preUpdate();return!0},c.Group.prototype.update=function(){for(var a=this.children.length;a--;)this.children[a].update()},c.Group.prototype.postUpdate=function(){this.fixedToCamera&&(this.x=this.game.camera.view.x+this.cameraOffset.x,this.y=this.game.camera.view.y+this.cameraOffset.y);for(var a=0;a<this.children.length;a++)this.children[a].postUpdate()},c.Group.prototype.filter=function(a,b){for(var d=-1,e=this.children.length,f=[];++d<e;){var g=this.children[d];(!b||b&&g.exists)&&a(g,d,this.children)&&f.push(g)}return new c.ArraySet(f)},c.Group.prototype.forEach=function(a,b,c){if(void 0===c&&(c=!1),arguments.length<=3)for(var d=0;d<this.children.length;d++)(!c||c&&this.children[d].exists)&&a.call(b,this.children[d]);else{var e=[null];for(d=3;d<arguments.length;d++)e.push(arguments[d]);for(d=0;d<this.children.length;d++)(!c||c&&this.children[d].exists)&&(e[0]=this.children[d],a.apply(b,e))}},c.Group.prototype.forEachExists=function(a,b){var d;if(2<arguments.length){d=[null];for(var e=2;e<arguments.length;e++)d.push(arguments[e])}this.iterate("exists",!0,c.Group.RETURN_TOTAL,a,b,d)},c.Group.prototype.forEachAlive=function(a,b){var d;if(2<arguments.length){d=[null];for(var e=2;e<arguments.length;e++)d.push(arguments[e])}this.iterate("alive",!0,c.Group.RETURN_TOTAL,a,b,d)},c.Group.prototype.forEachDead=function(a,b){var d;if(2<arguments.length){d=[null];for(var e=2;e<arguments.length;e++)d.push(arguments[e])}this.iterate("alive",!1,c.Group.RETURN_TOTAL,a,b,d)},c.Group.prototype.sort=function(a,b){this.children.length<2||(void 0===a&&(a="z"),void 0===b&&(b=c.Group.SORT_ASCENDING),this._sortProperty=a,b===c.Group.SORT_ASCENDING?this.children.sort(this.ascendingSortHandler.bind(this)):this.children.sort(this.descendingSortHandler.bind(this)),this.updateZ())},c.Group.prototype.customSort=function(a,b){this.children.length<2||(this.children.sort(a.bind(b)),this.updateZ())},c.Group.prototype.ascendingSortHandler=function(a,b){return a[this._sortProperty]<b[this._sortProperty]?-1:a[this._sortProperty]>b[this._sortProperty]?1:a.z<b.z?-1:1},c.Group.prototype.descendingSortHandler=function(a,b){return a[this._sortProperty]<b[this._sortProperty]?1:a[this._sortProperty]>b[this._sortProperty]?-1:0},c.Group.prototype.iterate=function(a,b,d,e,f,g){if(0===this.children.length){if(d===c.Group.RETURN_TOTAL)return 0;if(d===c.Group.RETURN_ALL)return[]}var h=0;if(d===c.Group.RETURN_ALL)var i=[];for(var j=0;j<this.children.length;j++)if(this.children[j][a]===b){if(h++,e&&(g?(g[0]=this.children[j],e.apply(f,g)):e.call(f,this.children[j])),d===c.Group.RETURN_CHILD)return this.children[j];d===c.Group.RETURN_ALL&&i.push(this.children[j])}return d===c.Group.RETURN_TOTAL?h:d===c.Group.RETURN_ALL?i:null},c.Group.prototype.getFirstExists=function(a,b,d,e,f,g){void 0===b&&(b=!1),"boolean"!=typeof a&&(a=!0);var h=this.iterate("exists",a,c.Group.RETURN_CHILD);return null===h&&b?this.create(d,e,f,g):this.resetChild(h,d,e,f,g)},c.Group.prototype.getFirstAlive=function(a,b,d,e,f){void 0===a&&(a=!1);var g=this.iterate("alive",!0,c.Group.RETURN_CHILD);return null===g&&a?this.create(b,d,e,f):this.resetChild(g,b,d,e,f)},c.Group.prototype.getFirstDead=function(a,b,d,e,f){void 0===a&&(a=!1);var g=this.iterate("alive",!1,c.Group.RETURN_CHILD);return null===g&&a?this.create(b,d,e,f):this.resetChild(g,b,d,e,f)},c.Group.prototype.resetChild=function(a,b,c,d,e){return null===a?null:(void 0===b&&(b=null),void 0===c&&(c=null),null!==b&&null!==c&&a.reset(b,c),void 0!==d&&a.loadTexture(d,e),a)},c.Group.prototype.getTop=function(){if(0<this.children.length)return this.children[this.children.length-1]},c.Group.prototype.getBottom=function(){if(0<this.children.length)return this.children[0]},c.Group.prototype.getClosestTo=function(a,b,d){for(var e=Number.MAX_VALUE,f=0,g=null,h=0;h<this.children.length;h++){var i=this.children[h];i.exists&&(f=Math.abs(c.Point.distance(a,i)))<e&&(!b||b.call(d,i,f))&&(e=f,g=i)}return g},c.Group.prototype.getFurthestFrom=function(a,b,d){for(var e=0,f=0,g=null,h=0;h<this.children.length;h++){var i=this.children[h];i.exists&&(f=Math.abs(c.Point.distance(a,i)))>e&&(!b||b.call(d,i,f))&&(e=f,g=i)}return g},c.Group.prototype.countLiving=function(){return this.iterate("alive",!0,c.Group.RETURN_TOTAL)},c.Group.prototype.countDead=function(){return this.iterate("alive",!1,c.Group.RETURN_TOTAL)},c.Group.prototype.getRandom=function(a,b){return void 0===a&&(a=0),void 0===b&&(b=this.children.length),0===b?null:c.ArrayUtils.getRandomItem(this.children,a,b)},c.Group.prototype.getRandomExists=function(a,b){var c=this.getAll("exists",!0,a,b);return this.game.rnd.pick(c)},c.Group.prototype.getAll=function(a,b,c,d){void 0===c&&(c=0),void 0===d&&(d=this.children.length);for(var e=[],f=c;f<d;f++){var g=this.children[f];a&&g[a]===b&&e.push(g)}return e},c.Group.prototype.remove=function(a,b,c){if(void 0===b&&(b=!1),void 0===c&&(c=!1),0===this.children.length||-1===this.children.indexOf(a))return!1;c||!a.events||a.destroyPhase||a.events.onRemovedFromGroup$dispatch(a,this);var d=this.removeChild(a);return this.removeFromHash(a),this.updateZ(),this.cursor===a&&this.next(),b&&d&&d.destroy(!0),!0},c.Group.prototype.moveAll=function(a,b){if(void 0===b&&(b=!1),0<this.children.length&&a instanceof c.Group){for(;a.add(this.children[0],b),0<this.children.length;);this.hash=[],this.cursor=null}return a},c.Group.prototype.removeAll=function(a,b,c){if(void 0===a&&(a=!1),void 0===b&&(b=!1),void 0===c&&(c=!1),0!==this.children.length){do{!b&&this.children[0].events&&this.children[0].events.onRemovedFromGroup$dispatch(this.children[0],this);var d=this.removeChild(this.children[0]);this.removeFromHash(d),a&&d&&d.destroy(!0,c)}while(0<this.children.length);this.hash=[],this.cursor=null}},c.Group.prototype.removeBetween=function(a,b,c,d){if(void 0===b&&(b=this.children.length-1),void 0===c&&(c=!1),void 0===d&&(d=!1),0!==this.children.length){if(b<a||a<0||b>this.children.length)return!1;for(var e=b;a<=e;){!d&&this.children[e].events&&this.children[e].events.onRemovedFromGroup$dispatch(this.children[e],this);var f=this.removeChild(this.children[e]);this.removeFromHash(f),c&&f&&f.destroy(!0),this.cursor===this.children[e]&&(this.cursor=null),e--}this.updateZ()}},c.Group.prototype.destroy=function(a,b){null===this.game||this.ignoreDestroy||(void 0===a&&(a=!0),void 0===b&&(b=!1),this.onDestroy.dispatch(this,a,b),this.removeAll(a),this.cursor=null,this.filters=null,this.pendingDestroy=!1,b||(this.parent&&this.parent.removeChild(this),this.game=null,this.exists=!1))},Object.defineProperty(c.Group.prototype,"total",{get:function(){return this.iterate("exists",!0,c.Group.RETURN_TOTAL)}}),Object.defineProperty(c.Group.prototype,"length",{get:function(){return this.children.length}}),Object.defineProperty(c.Group.prototype,"angle",{get:function(){return c.Math.radToDeg(this.rotation)},set:function(a){this.rotation=c.Math.degToRad(a)}}),Object.defineProperty(c.Group.prototype,"centerX",{get:function(){return this.getBounds(this.parent).centerX},set:function(a){var b=this.getBounds(this.parent),c=this.x-b.x;this.x=a+c-b.halfWidth}}),Object.defineProperty(c.Group.prototype,"centerY",{get:function(){return this.getBounds(this.parent).centerY},set:function(a){var b=this.getBounds(this.parent),c=this.y-b.y;this.y=a+c-b.halfHeight}}),Object.defineProperty(c.Group.prototype,"left",{get:function(){return this.getBounds(this.parent).left},set:function(a){var b=this.getBounds(this.parent),c=this.x-b.x;this.x=a+c}}),Object.defineProperty(c.Group.prototype,"right",{get:function(){return this.getBounds(this.parent).right},set:function(a){var b=this.getBounds(this.parent),c=this.x-b.x;this.x=a+c-b.width}}),Object.defineProperty(c.Group.prototype,"top",{get:function(){return this.getBounds(this.parent).top},set:function(a){var b=this.getBounds(this.parent),c=this.y-b.y;this.y=a+c}}),Object.defineProperty(c.Group.prototype,"bottom",{get:function(){return this.getBounds(this.parent).bottom},set:function(a){var b=this.getBounds(this.parent),c=this.y-b.y;this.y=a+c-b.height}}),c.World=function(a){c.Group.call(this,a,null,"__world",!1),this.bounds=new c.Rectangle(0,0,a.width,a.height),this.camera=null,this._definedSize=!1,this._width=a.width,this._height=a.height,this.game.state.onStateChange.add(this.stateChange,this)},c.World.prototype=Object.create(c.Group.prototype),c.World.prototype.constructor=c.World,c.World.prototype.boot=function(){this.camera=new c.Camera(this.game,0,0,0,this.game.width,this.game.height),this.game.stage.addChild(this),this.camera.boot()},c.World.prototype.stateChange=function(){this.x=0,this.y=0,this.camera.reset()},c.World.prototype.setBounds=function(a,b,c,d){this._definedSize=!0,this._width=c,this._height=d,this.bounds.setTo(a,b,c,d),this.x=a,this.y=b,this.camera.bounds&&this.camera.bounds.setTo(a,b,Math.max(c,this.game.width),Math.max(d,this.game.height)),this.game.physics.setBoundsToWorld()},c.World.prototype.resize=function(a,b){this._definedSize&&(a<this._width&&(a=this._width),b<this._height&&(b=this._height)),this.bounds.width=a,this.bounds.height=b,this.game.camera.setBoundsToWorld(),this.game.physics.setBoundsToWorld()},c.World.prototype.shutdown=function(){this.destroy(!0,!0)},c.World.prototype.wrap=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=!1),void 0===d&&(d=!0),void 0===e&&(e=!0),c?(a.getBounds(),d&&(a.x+a._currentBounds.width<this.bounds.x?a.x=this.bounds.right:a.x>this.bounds.right&&(a.x=this.bounds.left)),e&&(a.y+a._currentBounds.height<this.bounds.top?a.y=this.bounds.bottom:a.y>this.bounds.bottom&&(a.y=this.bounds.top))):(d&&a.x+b<this.bounds.x?a.x=this.bounds.right+b:d&&a.x-b>this.bounds.right&&(a.x=this.bounds.left-b),e&&a.y+b<this.bounds.top?a.y=this.bounds.bottom+b:e&&a.y-b>this.bounds.bottom&&(a.y=this.bounds.top-b))},Object.defineProperty(c.World.prototype,"width",{get:function(){return this.bounds.width},set:function(a){a<this.game.width&&(a=this.game.width),this.bounds.width=a,this._width=a,this._definedSize=!0}}),Object.defineProperty(c.World.prototype,"height",{get:function(){return this.bounds.height},set:function(a){a<this.game.height&&(a=this.game.height),this.bounds.height=a,this._height=a,this._definedSize=!0}}),Object.defineProperty(c.World.prototype,"centerX",{get:function(){return this.bounds.halfWidth+this.bounds.x}}),Object.defineProperty(c.World.prototype,"centerY",{get:function(){return this.bounds.halfHeight+this.bounds.y}}),Object.defineProperty(c.World.prototype,"randomX",{get:function(){return this.bounds.x<0?this.game.rnd.between(this.bounds.x,this.bounds.width-Math.abs(this.bounds.x)):this.game.rnd.between(this.bounds.x,this.bounds.width)}}),Object.defineProperty(c.World.prototype,"randomY",{get:function(){return this.bounds.y<0?this.game.rnd.between(this.bounds.y,this.bounds.height-Math.abs(this.bounds.y)):this.game.rnd.between(this.bounds.y,this.bounds.height)}}),c.Game=function(a,b,d,e,f,g,h,i){return this.id=c.GAMES.push(this)-1,this.config=null,this.physicsConfig=i,this.parent="",this.width=800,this.height=600,this.resolution=1,this._width=800,this._height=600,this.transparent=!1,this.antialias=!0,this.preserveDrawingBuffer=!1,this.clearBeforeRender=!0,this.renderer=null,this.renderType=c.AUTO,this.state=null,this.isBooted=!1,this.isRunning=!1,this.raf=null,this.add=null,this.make=null,this.cache=null,this.input=null,this.load=null,this.math=null,this.net=null,this.scale=null,this.sound=null,this.stage=null,this.time=null,this.tweens=null,this.world=null,this.physics=null,this.plugins=null,this.rnd=null,this.device=c.Device,this.camera=null,this.canvas=null,this.context=null,this.debug=null,this.particles=null,this.create=null,this.lockRender=!1,this.stepping=!1,this.pendingStep=!1,this.stepCount=0,this.onPause=null,this.onResume=null,this.onBlur=null,this.onFocus=null,this._paused=!1,this._codePaused=!1,this.currentUpdateID=0,this.updatesThisFrame=1,this._deltaTime=0,this._lastCount=0,this._spiraling=0,this._kickstart=!0,this.fpsProblemNotifier=new c.Signal,this.forceSingleUpdate=!0,this._nextFpsNotification=0,1===arguments.length&&"object"==typeof a?this.parseConfig(a):(this.config={enableDebug:!0},void 0!==a&&(this._width=a),void 0!==b&&(this._height=b),void 0!==d&&(this.renderType=d),void 0!==e&&(this.parent=e),void 0!==g&&(this.transparent=g),void 0!==h&&(this.antialias=h),this.rnd=new c.RandomDataGenerator([(Date.now()*Math.random()).toString()]),this.state=new c.StateManager(this,f)),this.device.whenReady(this.boot,this),this},c.Game.prototype={parseConfig:function(a){void 0===(this.config=a).enableDebug&&(this.config.enableDebug=!0),a.width&&(this._width=a.width),a.height&&(this._height=a.height),a.renderer&&(this.renderType=a.renderer),a.parent&&(this.parent=a.parent),void 0!==a.transparent&&(this.transparent=a.transparent),void 0!==a.antialias&&(this.antialias=a.antialias),a.resolution&&(this.resolution=a.resolution),void 0!==a.preserveDrawingBuffer&&(this.preserveDrawingBuffer=a.preserveDrawingBuffer),a.physicsConfig&&(this.physicsConfig=a.physicsConfig);var b=[(Date.now()*Math.random()).toString()];a.seed&&(b=a.seed),this.rnd=new c.RandomDataGenerator(b);var d=null;a.state&&(d=a.state),this.state=new c.StateManager(this,d)},boot:function(){this.isBooted||(this.onPause=new c.Signal,this.onResume=new c.Signal,this.onBlur=new c.Signal,this.onFocus=new c.Signal,this.isBooted=!0,(PIXI.game=this).math=c.Math,this.scale=new c.ScaleManager(this,this._width,this._height),this.stage=new c.Stage(this),this.setUpRenderer(),this.world=new c.World(this),this.add=new c.GameObjectFactory(this),this.make=new c.GameObjectCreator(this),this.cache=new c.Cache(this),this.load=new c.Loader(this),this.time=new c.Time(this),this.tweens=new c.TweenManager(this),this.input=new c.Input(this),this.sound=new c.SoundManager(this),this.physics=new c.Physics(this,this.physicsConfig),this.particles=new c.Particles(this),this.create=new c.Create(this),this.plugins=new c.PluginManager(this),this.net=new c.Net(this),this.time.boot(),this.stage.boot(),this.world.boot(),this.scale.boot(),this.input.boot(),this.sound.boot(),this.state.boot(),this.config.enableDebug?(this.debug=new c.Utils.Debug(this),this.debug.boot()):this.debug={preUpdate:function(){},update:function(){},reset:function(){}},this.showDebugHeader(),this.isRunning=!0,this.config&&this.config.forceSetTimeOut?this.raf=new c.RequestAnimationFrame(this,this.config.forceSetTimeOut):this.raf=new c.RequestAnimationFrame(this,!1),this._kickstart=!0,window.focus&&(!window.PhaserGlobal||window.PhaserGlobal&&!window.PhaserGlobal.stopFocus)&&window.focus(),this.raf.start())},showDebugHeader:function(){if(!window.PhaserGlobal||!window.PhaserGlobal.hideBanner){var a=c.VERSION,b="Canvas",d="HTML Audio",e=1;if(this.renderType===c.WEBGL?(b="WebGL",e++):this.renderType===c.HEADLESS&&(b="Headless"),this.device.webAudio&&(d="WebAudio",e++),this.device.chrome)for(var f=["%c %c %c @azerion/phaser v"+a+" | Pixi.js | "+b+" | "+d+" %c %c %c https://github.com/azerion / https://www.azerion.com %c♥%c♥%c♥","background: #7ab3eb","background: #378ce1","color: #ffffff; background: #207cd8;","background: #378ce1","background: #7ab3eb","background: #ffffff"],g=0;g<3;g++)g<e?f.push("color: #ff2424; background: #fff"):f.push("color: #959595; background: #fff");else window.console}},setUpRenderer:function(){if(this.config.canvas?this.canvas=this.config.canvas:this.canvas=c.Canvas.create(this,this.width,this.height,this.config.canvasID,!0),this.config.canvasStyle?this.canvas.style=this.config.canvasStyle:this.canvas.style["-webkit-full-screen"]="width: 100%; height: 100%",this.renderType===c.HEADLESS||this.renderType===c.CANVAS||this.renderType===c.AUTO&&!this.device.webGL){if(!this.device.canvas)throw new Error("Phaser.Game - Cannot create Canvas or WebGL context, aborting.");this.renderType=c.CANVAS,this.renderer=new PIXI.CanvasRenderer(this),this.context=this.renderer.context}else this.renderType=c.WEBGL,this.renderer=new PIXI.WebGLRenderer(this),this.context=null,this.canvas.addEventListener("webglcontextlost",this.contextLost.bind(this),!1),this.canvas.addEventListener("webglcontextrestored",this.contextRestored.bind(this),!1);this.device.cocoonJS&&(this.canvas.screencanvas=this.renderType===c.CANVAS),this.renderType!==c.HEADLESS&&(this.stage.smoothed=this.antialias,c.Canvas.addToDOM(this.canvas,this.parent,!1),c.Canvas.setTouchAction(this.canvas))},contextLost:function(a){a.preventDefault(),this.renderer.contextLost=!0},contextRestored:function(){this.renderer.initContext(),this.cache.clearGLTextures(),this.renderer.contextLost=!1},update:function(a){if(this.time.update(a),this._kickstart)return this.updateLogic(this.time.desiredFpsMult),this.updateRender(this.time.slowMotion*this.time.desiredFps),void(this._kickstart=!1);if(1<this._spiraling&&!this.forceSingleUpdate)this.time.time>this._nextFpsNotification&&(this._nextFpsNotification=this.time.time+1e4,this.fpsProblemNotifier.dispatch()),this._deltaTime=0,this._spiraling=0,this.updateRender(this.time.slowMotion*this.time.desiredFps);else{var b=1e3*this.time.slowMotion/this.time.desiredFps;this._deltaTime+=Math.max(Math.min(3*b,this.time.elapsed),0);var c=0;for(this.updatesThisFrame=Math.floor(this._deltaTime/b),this.forceSingleUpdate&&(this.updatesThisFrame=Math.min(1,this.updatesThisFrame));this._deltaTime>=b&&(this._deltaTime-=b,this.currentUpdateID=c,this.updateLogic(this.time.desiredFpsMult),c++,!this.forceSingleUpdate||1!==c);)this.time.refresh();c>this._lastCount?this._spiraling++:c<this._lastCount&&(this._spiraling=0),this._lastCount=c,this.updateRender(this._deltaTime/b)}},updateLogic:function(a){this._paused||this.pendingStep?(this.scale.pauseUpdate(),this.state.pauseUpdate(),this.debug.preUpdate()):(this.stepping&&(this.pendingStep=!0),this.scale.preUpdate(),this.debug.preUpdate(),this.camera.preUpdate(),this.physics.preUpdate(),this.state.preUpdate(a),this.plugins.preUpdate(a),this.stage.preUpdate(),this.state.update(),this.stage.update(),this.tweens.update(),this.sound.update(),this.input.update(),this.physics.update(),this.particles.update(),this.plugins.update(),this.stage.postUpdate(),this.plugins.postUpdate()),this.stage.updateTransform()},updateRender:function(a){this.lockRender||(this.state.preRender(a),this.renderType!==c.HEADLESS&&(this.renderer.render(this.stage),this.plugins.render(a),this.state.render(a)),this.plugins.postRender(a))},enableStep:function(){this.stepping=!0,this.pendingStep=!1,this.stepCount=0},disableStep:function(){this.stepping=!1,this.pendingStep=!1},step:function(){this.pendingStep=!1,this.stepCount++},destroy:function(){this.raf.stop(),this.state.destroy(),this.sound.destroy(),this.scale.destroy(),this.stage.destroy(),this.input.destroy(),this.physics.destroy(),this.plugins.destroy(),this.state=null,this.sound=null,this.scale=null,this.stage=null,this.input=null,this.physics=null,this.plugins=null,this.cache=null,this.load=null,this.time=null,this.world=null,this.isBooted=!1,this.renderer.destroy(!1),c.Canvas.removeFromDOM(this.canvas),PIXI.defaultRenderer=null,c.GAMES[this.id]=null},gamePaused:function(a){this._paused||(this._paused=!0,this.time.gamePaused(),this.sound.muteOnPause&&this.sound.setMute(),this.onPause.dispatch(a),this.device.cordova&&this.device.iOS&&(this.lockRender=!0))},gameResumed:function(a){this._paused&&!this._codePaused&&(this._paused=!1,this.time.gameResumed(),this.input.reset(),this.sound.muteOnPause&&this.sound.unsetMute(),this.onResume.dispatch(a),this.device.cordova&&this.device.iOS&&(this.lockRender=!1))},focusLoss:function(a){this.onBlur.dispatch(a),this.stage.disableVisibilityChange||this.gamePaused(a)},focusGain:function(a){this.onFocus.dispatch(a),this.stage.disableVisibilityChange||this.gameResumed(a)}},c.Game.prototype.constructor=c.Game,Object.defineProperty(c.Game.prototype,"paused",{get:function(){return this._paused},set:function(a){!0===a?(!1===this._paused&&(this._paused=!0,this.sound.setMute(),this.time.gamePaused(),this.onPause.dispatch(this)),this._codePaused=!0):(this._paused&&(this._paused=!1,this.input.reset(),this.sound.unsetMute(),this.time.gameResumed(),this.onResume.dispatch(this)),this._codePaused=!1)}}),c.Input=function(a){this.game=a,this.hitCanvas=null,this.hitContext=null,this.moveCallbacks=[],this.customCandidateHandler=null,this.customCandidateHandlerContext=null,this.pollRate=0,this.enabled=!0,this.multiInputOverride=c.Input.MOUSE_TOUCH_COMBINE,this.position=null,this.speed=null,this.circle=null,this.scale=null,this.maxPointers=-1,this.tapRate=200,this.doubleTapRate=300,this.holdRate=2e3,this.justPressedRate=200,this.justReleasedRate=200,this.recordPointerHistory=!1,this.recordRate=100,this.recordLimit=100,this.pointer1=null,this.pointer2=null,this.pointer3=null,this.pointer4=null,this.pointer5=null,this.pointer6=null,this.pointer7=null,this.pointer8=null,this.pointer9=null,this.pointer10=null,this.pointers=[],this.activePointer=null,this.mousePointer=null,this.mouse=null,this.keyboard=null,this.touch=null,this.mspointer=null,this.gamepad=null,this.resetLocked=!1,this.onDown=null,this.onUp=null,this.onTap=null,this.onHold=null,this.minPriorityID=0,this.interactiveItems=new c.ArraySet,this._localPoint=new c.Point,this._pollCounter=0,this._oldPosition=null,this._x=0,this._y=0},c.Input.MOUSE_OVERRIDES_TOUCH=0,c.Input.TOUCH_OVERRIDES_MOUSE=1,c.Input.MOUSE_TOUCH_COMBINE=2,c.Input.MAX_POINTERS=10,c.Input.prototype={boot:function(){this.mousePointer=new c.Pointer(this.game,0,c.PointerMode.CURSOR),this.addPointer(),this.addPointer(),this.mouse=new c.Mouse(this.game),this.touch=new c.Touch(this.game),this.mspointer=new c.MSPointer(this.game),c.Keyboard&&(this.keyboard=new c.Keyboard(this.game)),c.Gamepad&&(this.gamepad=new c.Gamepad(this.game)),this.onDown=new c.Signal,this.onUp=new c.Signal,this.onTap=new c.Signal,this.onHold=new c.Signal,this.scale=new c.Point(1,1),this.speed=new c.Point,this.position=new c.Point,this._oldPosition=new c.Point,this.circle=new c.Circle(0,0,45),this.activePointer=this.mousePointer,this.hitCanvas=PIXI.CanvasPool.create(this,1,1),this.hitContext=this.hitCanvas.getContext("2d"),this.game.device.mspointer?this.mspointer.start():this.game.device.touch&&this.touch.start(),this.mspointer.active||this.mouse.start(),this.mousePointer.active=!0,this.keyboard&&this.keyboard.start();var a=this;this._onClickTrampoline=function(b){a.onClickTrampoline(b)},this.game.canvas.addEventListener("click",this._onClickTrampoline,!1)},destroy:function(){this.mouse.stop(),this.touch.stop(),this.mspointer.stop(),this.keyboard&&this.keyboard.stop(),this.gamepad&&this.gamepad.stop(),this.moveCallbacks=[],PIXI.CanvasPool.remove(this),this.game.canvas.removeEventListener("click",this._onClickTrampoline)},setInteractiveCandidateHandler:function(a,b){this.customCandidateHandler=a,this.customCandidateHandlerContext=b},addMoveCallback:function(a,b){this.moveCallbacks.push({callback:a,context:b})},deleteMoveCallback:function(a,b){for(var c=this.moveCallbacks.length;c--;)if(this.moveCallbacks[c].callback===a&&this.moveCallbacks[c].context===b)return void this.moveCallbacks.splice(c,1)},addPointer:function(){if(this.pointers.length>=c.Input.MAX_POINTERS)return null;var a=this.pointers.length+1,b=new c.Pointer(this.game,a,c.PointerMode.TOUCH);return this.pointers.push(b),this["pointer"+a]=b},update:function(){if(this.keyboard&&this.keyboard.update(),0<this.pollRate&&this._pollCounter<this.pollRate)this._pollCounter++;else{this.speed.x=this.position.x-this._oldPosition.x,this.speed.y=this.position.y-this._oldPosition.y,this._oldPosition.copyFrom(this.position),this.mousePointer.update(),this.gamepad&&this.gamepad.active&&this.gamepad.update();for(var a=0;a<this.pointers.length;a++)this.pointers[a].update();this._pollCounter=0}},reset:function(a){if(this.game.isBooted&&!this.resetLocked){void 0===a&&(a=!1),this.mousePointer.reset(),this.keyboard&&this.keyboard.reset(a),this.gamepad&&this.gamepad.reset();for(var b=0;b<this.pointers.length;b++)this.pointers[b].reset();"none"!==this.game.canvas.style.cursor&&(this.game.canvas.style.cursor="inherit"),a&&(this.onDown.dispose(),this.onUp.dispose(),this.onTap.dispose(),this.onHold.dispose(),this.onDown=new c.Signal,this.onUp=new c.Signal,this.onTap=new c.Signal,this.onHold=new c.Signal,this.moveCallbacks=[]),this._pollCounter=0}},resetSpeed:function(a,b){this._oldPosition.setTo(a,b),this.speed.setTo(0,0)},startPointer:function(a){if(0<=this.maxPointers&&this.countActivePointers(this.maxPointers)>=this.maxPointers)return null;if(!this.pointer1.active)return this.pointer1.start(a);if(!this.pointer2.active)return this.pointer2.start(a);for(var b=2;b<this.pointers.length;b++){var c=this.pointers[b];if(!c.active)return c.start(a)}return null},updatePointer:function(a){if(this.pointer1.active&&this.pointer1.identifier===a.identifier)return this.pointer1.move(a);if(this.pointer2.active&&this.pointer2.identifier===a.identifier)return this.pointer2.move(a);for(var b=2;b<this.pointers.length;b++){var c=this.pointers[b];if(c.active&&c.identifier===a.identifier)return c.move(a)}return null},stopPointer:function(a){if(this.pointer1.active&&this.pointer1.identifier===a.identifier)return this.pointer1.stop(a);if(this.pointer2.active&&this.pointer2.identifier===a.identifier)return this.pointer2.stop(a);for(var b=2;b<this.pointers.length;b++){var c=this.pointers[b];if(c.active&&c.identifier===a.identifier)return c.stop(a)}return null},countActivePointers:function(a){void 0===a&&(a=this.pointers.length);for(var b=a,c=0;c<this.pointers.length&&0<b;c++)this.pointers[c].active&&b--;return a-b},getPointer:function(a){void 0===a&&(a=!1);for(var b=0;b<this.pointers.length;b++){var c=this.pointers[b];if(c.active===a)return c}return null},getPointerFromIdentifier:function(a){for(var b=0;b<this.pointers.length;b++){var c=this.pointers[b];if(c.identifier===a)return c}return null},getPointerFromId:function(a){for(var b=0;b<this.pointers.length;b++){var c=this.pointers[b];if(c.pointerId===a)return c}return null},getLocalPosition:function(a,b,d){void 0===d&&(d=new c.Point);var e=a.worldTransform,f=1/(e.a*e.d+e.c*-e.b);return d.setTo(e.d*f*b.x+-e.c*f*b.y+(e.ty*e.c-e.tx*e.d)*f,e.a*f*b.y+-e.b*f*b.x+(-e.ty*e.a+e.tx*e.b)*f)},hitTest:function(a,b,d){if(!a.worldVisible)return!1;if(this.getLocalPosition(a,b,this._localPoint),d.copyFrom(this._localPoint),a.hitArea&&a.hitArea.contains)return a.hitArea.contains(this._localPoint.x,this._localPoint.y);if(a instanceof c.TileSprite){var e=a.width,f=a.height,g=-e*a.anchor.x;if(this._localPoint.x>=g&&this._localPoint.x<g+e){var h=-f*a.anchor.y;if(this._localPoint.y>=h&&this._localPoint.y<h+f)return!0}}else if(a instanceof PIXI.Sprite){e=a.texture.frame.width,f=a.texture.frame.height,g=-e*a.anchor.x;if(this._localPoint.x>=g&&this._localPoint.x<g+e){h=-f*a.anchor.y;if(this._localPoint.y>=h&&this._localPoint.y<h+f)return!0}}else if(c.Graphics&&a instanceof c.Graphics)for(var i=0;i<a.graphicsData.length;i++){var j=a.graphicsData[i];if(j.fill&&j.shape&&j.shape.contains(this._localPoint.x,this._localPoint.y))return!0}for(i=0;i<a.children.length;i++)if(this.hitTest(a.children[i],b,d))return!0;return!1},onClickTrampoline:function(){this.activePointer.processClickTrampolines()}},c.Input.prototype.constructor=c.Input,Object.defineProperty(c.Input.prototype,"x",{get:function(){return this._x},set:function(a){this._x=Math.floor(a)}}),Object.defineProperty(c.Input.prototype,"y",{get:function(){return this._y},set:function(a){this._y=Math.floor(a)}}),Object.defineProperty(c.Input.prototype,"pollLocked",{get:function(){return 0<this.pollRate&&this._pollCounter<this.pollRate}}),Object.defineProperty(c.Input.prototype,"totalInactivePointers",{get:function(){return this.pointers.length-this.countActivePointers()}}),Object.defineProperty(c.Input.prototype,"totalActivePointers",{get:function(){return this.countActivePointers()}}),Object.defineProperty(c.Input.prototype,"worldX",{get:function(){return this.game.camera.view.x+this.x}}),Object.defineProperty(c.Input.prototype,"worldY",{get:function(){return this.game.camera.view.y+this.y}}),c.Mouse=function(a){this.game=a,this.input=a.input,this.callbackContext=this.game,this.mouseDownCallback=null,this.mouseUpCallback=null,this.mouseOutCallback=null,this.mouseOverCallback=null,this.mouseWheelCallback=null,this.capture=!1,this.button=-1,this.wheelDelta=0,this.enabled=!0,this.locked=!1,this.stopOnGameOut=!1,this.pointerLock=new c.Signal,this.event=null,this._onMouseDown=null,this._onMouseMove=null,this._onMouseUp=null,this._onMouseOut=null,this._onMouseOver=null,this._onMouseWheel=null,this._wheelEvent=null},c.Mouse.NO_BUTTON=-1,c.Mouse.LEFT_BUTTON=0,c.Mouse.MIDDLE_BUTTON=1,c.Mouse.RIGHT_BUTTON=2,c.Mouse.BACK_BUTTON=3,c.Mouse.FORWARD_BUTTON=4,c.Mouse.WHEEL_UP=1,c.Mouse.WHEEL_DOWN=-1,c.Mouse.prototype={start:function(){if((!this.game.device.android||!1!==this.game.device.chrome)&&null===this._onMouseDown){var b=this;this._onMouseDown=function(a){return b.onMouseDown(a)},this._onMouseMove=function(a){return b.onMouseMove(a)},this._onMouseUp=function(a){return b.onMouseUp(a)},this._onMouseUpGlobal=function(a){return b.onMouseUpGlobal(a)},this._onMouseOutGlobal=function(a){return b.onMouseOutGlobal(a)},this._onMouseOut=function(a){return b.onMouseOut(a)},this._onMouseOver=function(a){return b.onMouseOver(a)},this._onMouseWheel=function(a){return b.onMouseWheel(a)};var c=this.game.canvas;c.addEventListener("mousedown",this._onMouseDown,!0),c.addEventListener("mousemove",this._onMouseMove,!0),c.addEventListener("mouseup",this._onMouseUp,!0),this.game.device.cocoonJS||(window.addEventListener("mouseup",this._onMouseUpGlobal,!0),window.addEventListener("mouseout",this._onMouseOutGlobal,!0),c.addEventListener("mouseover",this._onMouseOver,!0),c.addEventListener("mouseout",this._onMouseOut,!0));var d=this.game.device.wheelEvent;d&&(c.addEventListener(d,this._onMouseWheel,!0),"mousewheel"===d?this._wheelEvent=new a(-.025,1):"DOMMouseScroll"===d&&(this._wheelEvent=new a(1,1)))}},onMouseDown:function(a){this.event=a,this.capture&&a.preventDefault(),this.mouseDownCallback&&this.mouseDownCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=0,this.input.mousePointer.start(a))},onMouseMove:function(a){this.event=a,this.capture&&a.preventDefault(),this.mouseMoveCallback&&this.mouseMoveCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=0,this.input.mousePointer.move(a))},onMouseUp:function(a){this.event=a,this.capture&&a.preventDefault(),this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=0,this.input.mousePointer.stop(a))},onMouseUpGlobal:function(a){this.input.mousePointer.withinGame||(this.mouseUpCallback&&this.mouseUpCallback.call(this.callbackContext,a),a.identifier=0,this.input.mousePointer.stop(a))},onMouseOutGlobal:function(a){this.event=a,this.capture&&a.preventDefault(),this.input.mousePointer.withinGame=!1,this.input.enabled&&this.enabled&&(this.input.mousePointer.stop(a),this.input.mousePointer.leftButton.stop(a),this.input.mousePointer.rightButton.stop(a))},onMouseOut:function(a){this.event=a,this.capture&&a.preventDefault(),this.input.mousePointer.withinGame=!1,this.mouseOutCallback&&this.mouseOutCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&this.stopOnGameOut&&(a.identifier=0,this.input.mousePointer.stop(a))},onMouseOver:function(a){this.event=a,this.capture&&a.preventDefault(),this.input.mousePointer.withinGame=!0,this.mouseOverCallback&&this.mouseOverCallback.call(this.callbackContext,a)},onMouseWheel:function(a){this._wheelEvent&&(a=this._wheelEvent.bindEvent(a)),this.event=a,this.capture&&a.preventDefault(),this.wheelDelta=c.Math.clamp(-a.deltaY,-1,1),this.mouseWheelCallback&&this.mouseWheelCallback.call(this.callbackContext,a)},requestPointerLock:function(){if(this.game.device.pointerLock){var a=this.game.canvas;a.requestPointerLock=a.requestPointerLock||a.mozRequestPointerLock||a.webkitRequestPointerLock,a.requestPointerLock();var b=this;this._pointerLockChange=function(a){return b.pointerLockChange(a)},document.addEventListener("pointerlockchange",this._pointerLockChange,!0),document.addEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.addEventListener("webkitpointerlockchange",this._pointerLockChange,!0)}},pointerLockChange:function(a){var b=this.game.canvas;document.pointerLockElement===b||document.mozPointerLockElement===b||document.webkitPointerLockElement===b?(this.locked=!0,this.pointerLock.dispatch(!0,a)):(this.locked=!1,this.pointerLock.dispatch(!1,a))},releasePointerLock:function(){document.exitPointerLock=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock,document.exitPointerLock(),document.removeEventListener("pointerlockchange",this._pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this._pointerLockChange,!0)},stop:function(){var a=this.game.canvas;a.removeEventListener("mousedown",this._onMouseDown,!0),a.removeEventListener("mousemove",this._onMouseMove,!0),a.removeEventListener("mouseup",this._onMouseUp,!0),a.removeEventListener("mouseover",this._onMouseOver,!0),a.removeEventListener("mouseout",this._onMouseOut,!0);var b=this.game.device.wheelEvent;b&&a.removeEventListener(b,this._onMouseWheel,!0),window.removeEventListener("mouseup",this._onMouseUpGlobal,!0),window.removeEventListener("mouseout",this._onMouseOutGlobal,!0),document.removeEventListener("pointerlockchange",this._pointerLockChange,!0),document.removeEventListener("mozpointerlockchange",this._pointerLockChange,!0),document.removeEventListener("webkitpointerlockchange",this._pointerLockChange,!0)}},c.Mouse.prototype.constructor=c.Mouse,((a.prototype={}).constructor=a).prototype.bindEvent=function(b){if(!a._stubsGenerated&&b){var c=function(a){return function(){var b=this.originalEvent[a];return"function"!=typeof b?b:b.bind(this.originalEvent)}};for(var d in b)d in a.prototype||Object.defineProperty(a.prototype,d,{get:c(d)});a._stubsGenerated=!0}return this.originalEvent=b,this},Object.defineProperties(a.prototype,{type:{value:"wheel"},deltaMode:{get:function(){return this._deltaMode}},deltaY:{get:function(){return this._scaleFactor*(this.originalEvent.wheelDelta||this.originalEvent.detail)||0}},deltaX:{get:function(){return this._scaleFactor*this.originalEvent.wheelDeltaX||0}},deltaZ:{value:0}}),c.MSPointer=function(a){this.game=a,this.input=a.input,this.callbackContext=this.game,this.pointerDownCallback=null,this.pointerMoveCallback=null,this.pointerUpCallback=null,this.capture=!1,this.event=null,this.active=!1,this.enabled=!0,this._onMSPointerDown=null,this._onMSPointerMove=null,this._onMSPointerUp=null,this._onMSPointerUpGlobal=null,this._onMSPointerOut=null,this._onMSPointerOver=null},c.MSPointer.prototype={start:function(){if(!this.game.device.mspointer)return!1;if(null!==this._onMSPointerDown)return!1;var a=this;this._onMSPointerDown=function(b){return a.onPointerDown(b)},this._onMSPointerMove=function(b){return a.onPointerMove(b)},this._onMSPointerUp=function(b){return a.onPointerUp(b)},this._onMSPointerUpGlobal=function(b){return a.onPointerUpGlobal(b)},this._onMSPointerOut=function(b){return a.onPointerOut(b)},this._onMSPointerOver=function(b){return a.onPointerOver(b)};var b=this.game.canvas;return b.addEventListener("MSPointerDown",this._onMSPointerDown,!1),b.addEventListener("MSPointerMove",this._onMSPointerMove,!1),b.addEventListener("MSPointerUp",this._onMSPointerUp,!1),b.addEventListener("pointerdown",this._onMSPointerDown,!1),b.addEventListener("pointermove",this._onMSPointerMove,!1),b.addEventListener("pointerup",this._onMSPointerUp,!1),b.style["-ms-content-zooming"]="none",b.style["-ms-touch-action"]="none",this.game.device.cocoonJS||(window.addEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),b.addEventListener("MSPointerOver",this._onMSPointerOver,!0),b.addEventListener("MSPointerOut",this._onMSPointerOut,!0),window.addEventListener("pointerup",this._onMSPointerUpGlobal,!0),b.addEventListener("pointerover",this._onMSPointerOver,!0),b.addEventListener("pointerout",this._onMSPointerOut,!0)),this.active=!0},onPointerDown:function(a){this.event=a,this.capture&&a.preventDefault(),this.pointerDownCallback&&this.pointerDownCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=a.pointerId,"mouse"===a.pointerType||4===a.pointerType?this.input.mousePointer.start(a):this.input.startPointer(a))},onPointerMove:function(a){this.event=a,this.capture&&a.preventDefault(),this.pointerMoveCallback&&this.pointerMoveCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=a.pointerId,"mouse"===a.pointerType||4===a.pointerType?this.input.mousePointer.move(a):this.input.updatePointer(a))},onPointerUp:function(a){this.event=a,this.capture&&a.preventDefault(),this.pointerUpCallback&&this.pointerUpCallback.call(this.callbackContext,a),this.input.enabled&&this.enabled&&(a.identifier=a.pointerId,"mouse"===a.pointerType||4===a.pointerType?this.input.mousePointer.stop(a):this.input.stopPointer(a))},onPointerUpGlobal:function(a){if("mouse"!==a.pointerType&&4!==a.pointerType||this.input.mousePointer.withinGame){var b=this.input.getPointerFromIdentifier(a.identifier);b&&b.withinGame&&this.onPointerUp(a)}else this.onPointerUp(a)},onPointerOut:function(a){if(this.event=a,this.capture&&a.preventDefault(),"mouse"===a.pointerType||4===a.pointerType)this.input.mousePointer.withinGame=!1;else{var b=this.input.getPointerFromIdentifier(a.identifier);b&&(b.withinGame=!1)}this.input.mouse.mouseOutCallback&&this.input.mouse.mouseOutCallback.call(this.input.mouse.callbackContext,a),this.input.enabled&&this.enabled&&this.input.mouse.stopOnGameOut&&(a.identifier=0,b?b.stop(a):this.input.mousePointer.stop(a))},onPointerOver:function(a){if(this.event=a,this.capture&&a.preventDefault(),"mouse"===a.pointerType||4===a.pointerType)this.input.mousePointer.withinGame=!0;else{var b=this.input.getPointerFromIdentifier(a.identifier);b&&(b.withinGame=!0)}this.input.mouse.mouseOverCallback&&this.input.mouse.mouseOverCallback.call(this.input.mouse.callbackContext,a)},stop:function(){var a=this.game.canvas;a.removeEventListener("MSPointerDown",this._onMSPointerDown,!1),a.removeEventListener("MSPointerMove",this._onMSPointerMove,!1),a.removeEventListener("MSPointerUp",this._onMSPointerUp,!1),a.removeEventListener("pointerdown",this._onMSPointerDown,!1),a.removeEventListener("pointermove",this._onMSPointerMove,!1),a.removeEventListener("pointerup",this._onMSPointerUp,!1),window.removeEventListener("MSPointerUp",this._onMSPointerUpGlobal,!0),a.removeEventListener("MSPointerOver",this._onMSPointerOver,!0),a.removeEventListener("MSPointerOut",this._onMSPointerOut,!0),window.removeEventListener("pointerup",this._onMSPointerUpGlobal,!0),a.removeEventListener("pointerover",this._onMSPointerOver,!0),a.removeEventListener("pointerout",this._onMSPointerOut,!0),this.active=!1}},c.MSPointer.prototype.constructor=c.MSPointer,c.DeviceButton=function(a,b){this.parent=a,this.game=a.game,this.event=null,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1,this.value=0,this.buttonCode=b,this.onDown=new c.Signal,this.onUp=new c.Signal,this.onFloat=new c.Signal},c.DeviceButton.prototype={start:function(a,b){this.isDown||(this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.repeats=0,this.event=a,this.value=b,a&&(this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.ctrlKey=a.ctrlKey),this.onDown.dispatch(this,b))},stop:function(a,b){this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.event=a,this.value=b,a&&(this.altKey=a.altKey,this.shiftKey=a.shiftKey,this.ctrlKey=a.ctrlKey),this.onUp.dispatch(this,b))},padFloat:function(a){this.value=a,this.onFloat.dispatch(this,a)},justPressed:function(a){return a=a||250,this.isDown&&this.timeDown+a>this.game.time.time},justReleased:function(a){return a=a||250,this.isUp&&this.timeUp+a>this.game.time.time},reset:function(){this.isDown=!1,this.isUp=!0,this.timeDown=this.game.time.time,this.repeats=0,this.altKey=!1,this.shiftKey=!1,this.ctrlKey=!1},destroy:function(){this.onDown.dispose(),this.onUp.dispose(),this.onFloat.dispose(),this.parent=null,this.game=null}},c.DeviceButton.prototype.constructor=c.DeviceButton,Object.defineProperty(c.DeviceButton.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),c.Pointer=function(a,b,d){this.game=a,this.id=b,this.type=c.POINTER,this.exists=!0,this.identifier=0,this.pointerId=null,this.pointerMode=d||c.PointerMode.CURSOR|c.PointerMode.CONTACT,this.target=null,this.button=null,this.leftButton=new c.DeviceButton(this,c.Pointer.LEFT_BUTTON),this.middleButton=new c.DeviceButton(this,c.Pointer.MIDDLE_BUTTON),this.rightButton=new c.DeviceButton(this,c.Pointer.RIGHT_BUTTON),this.backButton=new c.DeviceButton(this,c.Pointer.BACK_BUTTON),this.forwardButton=new c.DeviceButton(this,c.Pointer.FORWARD_BUTTON),this.eraserButton=new c.DeviceButton(this,c.Pointer.ERASER_BUTTON),this._holdSent=!1,this._history=[],this._nextDrop=0,this._stateReset=!1,this.withinGame=!1,this.clientX=-1,this.clientY=-1,this.pageX=-1,this.pageY=-1,this.screenX=-1,this.screenY=-1,this.rawMovementX=0,this.rawMovementY=0,this.movementX=0,this.movementY=0,this.x=-1,this.y=-1,this.isMouse=0===b,this.isDown=!1,this.isUp=!0,this.timeDown=0,this.timeUp=0,this.previousTapTime=0,this.totalTouches=0,this.msSinceLastClick=Number.MAX_VALUE,this.targetObject=null,this.interactiveCandidates=[],this.active=!1,this.dirty=!1,this.position=new c.Point,this.positionDown=new c.Point,this.positionUp=new c.Point,this.circle=new c.Circle(0,0,44),this._clickTrampolines=null,this._trampolineTargetObject=null},c.Pointer.NO_BUTTON=0,c.Pointer.LEFT_BUTTON=1,c.Pointer.RIGHT_BUTTON=2,c.Pointer.MIDDLE_BUTTON=4,c.Pointer.BACK_BUTTON=8,c.Pointer.FORWARD_BUTTON=16,c.Pointer.ERASER_BUTTON=32,c.Pointer.prototype={resetButtons:function(){this.isDown=!1,this.isUp=!0,this.isMouse&&(this.leftButton.reset(),this.middleButton.reset(),this.rightButton.reset(),this.backButton.reset(),this.forwardButton.reset(),this.eraserButton.reset())},processButtonsDown:function(a,b){c.Pointer.LEFT_BUTTON&a&&this.leftButton.start(b),c.Pointer.RIGHT_BUTTON&a&&this.rightButton.start(b),c.Pointer.MIDDLE_BUTTON&a&&this.middleButton.start(b),c.Pointer.BACK_BUTTON&a&&this.backButton.start(b),c.Pointer.FORWARD_BUTTON&a&&this.forwardButton.start(b),c.Pointer.ERASER_BUTTON&a&&this.eraserButton.start(b)},processButtonsUp:function(a,b){a===c.Mouse.LEFT_BUTTON&&this.leftButton.stop(b),a===c.Mouse.RIGHT_BUTTON&&this.rightButton.stop(b),a===c.Mouse.MIDDLE_BUTTON&&this.middleButton.stop(b),a===c.Mouse.BACK_BUTTON&&this.backButton.stop(b),a===c.Mouse.FORWARD_BUTTON&&this.forwardButton.stop(b),5===a&&this.eraserButton.stop(b)},updateButtons:function(a){this.button=a.button;var b="down"===a.type.toLowerCase().substr(-4);void 0!==a.buttons?b?this.processButtonsDown(a.buttons,a):this.processButtonsUp(a.button,a):b?this.leftButton.start(a):(this.leftButton.stop(a),this.rightButton.stop(a)),1===a.buttons&&a.ctrlKey&&this.leftButton.isDown&&(this.leftButton.stop(a),this.rightButton.start(a)),this.isUp=!0,this.isDown=!1,(this.leftButton.isDown||this.rightButton.isDown||this.middleButton.isDown||this.backButton.isDown||this.forwardButton.isDown||this.eraserButton.isDown)&&(this.isUp=!1,this.isDown=!0)},start:function(a){var b=this.game.input;return a.pointerId&&(this.pointerId=a.pointerId),this.identifier=a.identifier,this.target=a.target,this.isMouse?this.updateButtons(a):(this.isDown=!0,this.isUp=!1),this.active=!0,this.withinGame=!0,this.dirty=!1,this._history=[],this._clickTrampolines=null,this._trampolineTargetObject=null,this.msSinceLastClick=this.game.time.time-this.timeDown,this.timeDown=this.game.time.time,this._holdSent=!1,this.move(a,!0),this.positionDown.setTo(this.x,this.y),(b.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||b.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||b.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===b.totalActivePointers)&&(b.x=this.x,b.y=this.y,b.position.setTo(this.x,this.y),b.onDown.dispatch(this,a),b.resetSpeed(this.x,this.y)),this._stateReset=!1,this.totalTouches++,null!==this.targetObject&&this.targetObject._touchedHandler(this),this},update:function(){var a=this.game.input;this.active&&(this.dirty&&(0<a.interactiveItems.total&&this.processInteractiveObjects(!1),this.dirty=!1),!1===this._holdSent&&this.duration>=a.holdRate&&((a.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||a.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||a.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===a.totalActivePointers)&&a.onHold.dispatch(this),this._holdSent=!0),a.recordPointerHistory&&this.game.time.time>=this._nextDrop&&(this._nextDrop=this.game.time.time+a.recordRate,this._history.push({x:this.position.x,y:this.position.y}),this._history.length>a.recordLimit&&this._history.shift()))},move:function(a,b){var d=this.game.input;if(!d.pollLocked){void 0===b&&(b=!1),void 0!==a.button&&(this.button=a.button),b&&this.isMouse&&this.updateButtons(a),this.clientX=a.clientX,this.clientY=a.clientY,this.pageX=a.pageX,this.pageY=a.pageY,this.screenX=a.screenX,this.screenY=a.screenY,this.isMouse&&d.mouse.locked&&!b&&(this.rawMovementX=a.movementX||a.mozMovementX||a.webkitMovementX||0,this.rawMovementY=a.movementY||a.mozMovementY||a.webkitMovementY||0,this.movementX+=this.rawMovementX,this.movementY+=this.rawMovementY),this.x=(this.pageX-this.game.scale.offset.x)*d.scale.x,this.y=(this.pageY-this.game.scale.offset.y)*d.scale.y,this.position.setTo(this.x,this.y),this.circle.x=this.x,this.circle.y=this.y,(d.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||d.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||d.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===d.totalActivePointers)&&(d.activePointer=this,d.x=this.x,d.y=this.y,d.position.setTo(d.x,d.y),d.circle.x=d.x,d.circle.y=d.y),this.withinGame=this.game.scale.bounds.contains(this.pageX,this.pageY);for(var e=d.moveCallbacks.length;e--;)d.moveCallbacks[e].callback.call(d.moveCallbacks[e].context,this,this.x,this.y,b);return null!==this.targetObject&&!0===this.targetObject.isDragged?!1===this.targetObject.update(this)&&(this.targetObject=null):0<d.interactiveItems.total&&this.processInteractiveObjects(b),this}},processInteractiveObjects:function(a){var b=0,c=-1,d=null,e=this.game.input.interactiveItems.first;for(this.interactiveCandidates=[];e;)e.checked=!1,e.validForInput(c,b,!1)&&(e.checked=!0,(a&&e.checkPointerDown(this,!0)||!a&&e.checkPointerOver(this,!0))&&(b=e.sprite.renderOrderID,c=e.priorityID,d=e,this.interactiveCandidates.push(e))),e=this.game.input.interactiveItems.next;for(e=this.game.input.interactiveItems.first;e;)!e.checked&&e.validForInput(c,b,!0)&&(a&&e.checkPointerDown(this,!1)||!a&&e.checkPointerOver(this,!1))&&(b=e.sprite.renderOrderID,c=e.priorityID,d=e,this.interactiveCandidates.push(e)),e=this.game.input.interactiveItems.next;return this.game.input.customCandidateHandler&&(d=this.game.input.customCandidateHandler.call(this.game.input.customCandidateHandlerContext,this,this.interactiveCandidates,d)),this.swapTarget(d,!1),null!==this.targetObject},swapTarget:function(a,b){void 0===b&&(b=!1),null===a?this.targetObject&&(this.targetObject._pointerOutHandler(this,b),this.targetObject=null):null===this.targetObject?(this.targetObject=a)._pointerOverHandler(this,b):this.targetObject===a?!1===a.update(this)&&(this.targetObject=null):(this.targetObject._pointerOutHandler(this,b),this.targetObject=a,this.targetObject._pointerOverHandler(this,b))},leave:function(a){this.withinGame=!1,this.move(a,!1)},stop:function(a){var b=this.game.input;return this._stateReset&&this.withinGame?void a.preventDefault():(this.timeUp=this.game.time.time,(b.multiInputOverride===c.Input.MOUSE_OVERRIDES_TOUCH||b.multiInputOverride===c.Input.MOUSE_TOUCH_COMBINE||b.multiInputOverride===c.Input.TOUCH_OVERRIDES_MOUSE&&0===b.totalActivePointers)&&(b.onUp.dispatch(this,a),0<=this.duration&&this.duration<=b.tapRate&&(this.timeUp-this.previousTapTime<b.doubleTapRate?b.onTap.dispatch(this,!0):b.onTap.dispatch(this,!1),this.previousTapTime=this.timeUp)),this.isMouse?this.updateButtons(a):(this.isDown=!1,this.isUp=!0),0<this.id&&(this.active=!1),this.withinGame=this.game.scale.bounds.contains(a.pageX,a.pageY),this.pointerId=null,this.identifier=null,this.positionUp.setTo(this.x,this.y),!1===this.isMouse&&b.currentPointers--,b.interactiveItems.callAll("_releasedHandler",this),this._clickTrampolines&&(this._trampolineTargetObject=this.targetObject),this.targetObject=null,this)},justPressed:function(a){return a=a||this.game.input.justPressedRate,!0===this.isDown&&this.timeDown+a>this.game.time.time},justReleased:function(a){return a=a||this.game.input.justReleasedRate,this.isUp&&this.timeUp+a>this.game.time.time},addClickTrampoline:function(a,b,c,d){if(this.isDown){for(var e=this._clickTrampolines=this._clickTrampolines||[],f=0;f<e.length;f++)if(e[f].name===a){e.splice(f,1);break}e.push({name:a,targetObject:this.targetObject,callback:b,callbackContext:c,callbackArgs:d})}},processClickTrampolines:function(){var a=this._clickTrampolines;if(a){for(var b=0;b<a.length;b++){var c=a[b];c.targetObject===this._trampolineTargetObject&&c.callback.apply(c.callbackContext,c.callbackArgs)}this._clickTrampolines=null,this._trampolineTargetObject=null}},reset:function(){!1===this.isMouse&&(this.active=!1),this.pointerId=null,this.identifier=null,this.dirty=!1,this.totalTouches=0,this._holdSent=!1,this._history.length=0,this._stateReset=!0,this.resetButtons(),this.targetObject&&this.targetObject._releasedHandler(this),this.targetObject=null},resetMovement:function(){this.movementX=0,this.movementY=0}},c.Pointer.prototype.constructor=c.Pointer,Object.defineProperty(c.Pointer.prototype,"duration",{get:function(){return this.isUp?-1:this.game.time.time-this.timeDown}}),Object.defineProperty(c.Pointer.prototype,"worldX",{get:function(){return this.game.world.camera.x+this.x}}),Object.defineProperty(c.Pointer.prototype,"worldY",{get:function(){return this.game.world.camera.y+this.y}}),c.PointerMode={CURSOR:1,CONTACT:2},c.Touch=function(a){this.game=a,this.enabled=!0,this.touchLockCallbacks=[],this.callbackContext=this.game,this.touchStartCallback=null,this.touchMoveCallback=null,this.touchEndCallback=null,this.touchEnterCallback=null,this.touchLeaveCallback=null,this.touchCancelCallback=null,this.preventDefault=!0,this.event=null,this._onTouchStart=null,this._onTouchMove=null,this._onTouchEnd=null,this._onTouchEnter=null,this._onTouchLeave=null,this._onTouchCancel=null,this._onTouchMove=null},c.Touch.prototype={start:function(){if(null===this._onTouchStart){var a=this;this.game.device.touch&&(this._onTouchStart=function(b){return a.onTouchStart(b)},this._onTouchMove=function(b){return a.onTouchMove(b)},this._onTouchEnd=function(b){return a.onTouchEnd(b)},this._onTouchEnter=function(b){return a.onTouchEnter(b)},this._onTouchLeave=function(b){return a.onTouchLeave(b)},this._onTouchCancel=function(b){return a.onTouchCancel(b)},this.game.canvas.addEventListener("touchstart",this._onTouchStart,!1),this.game.canvas.addEventListener("touchmove",this._onTouchMove,!1),this.game.canvas.addEventListener("touchend",this._onTouchEnd,!1),this.game.canvas.addEventListener("touchcancel",this._onTouchCancel,!1),this.game.device.cocoonJS||(this.game.canvas.addEventListener("touchenter",this._onTouchEnter,!1),this.game.canvas.addEventListener("touchleave",this._onTouchLeave,!1)))}},consumeDocumentTouches:function(){this._documentTouchMove=function(a){a.preventDefault()},document.addEventListener("touchmove",this._documentTouchMove,!1)},addTouchLockCallback:function(a,b,c){void 0===c&&(c=!1),this.touchLockCallbacks.push({callback:a,context:b,onEnd:c})},removeTouchLockCallback:function(a,b){for(var c=this.touchLockCallbacks.length;c--;)if(this.touchLockCallbacks[c].callback===a&&this.touchLockCallbacks[c].context===b)return this.touchLockCallbacks.splice(c,1),!0;return!1},onTouchStart:function(a){for(var b=this.touchLockCallbacks.length;b--;){var c=this.touchLockCallbacks[b];!c.onEnd&&c.callback.call(c.context,this,a)&&this.touchLockCallbacks.splice(b,1)}if(this.event=a,this.game.input.enabled&&this.enabled){this.touchStartCallback&&this.touchStartCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault();for(b=0;b<a.changedTouches.length;b++)this.game.input.startPointer(a.changedTouches[b])}},onTouchCancel:function(a){if(this.event=a,this.touchCancelCallback&&this.touchCancelCallback.call(this.callbackContext,a),this.game.input.enabled&&this.enabled){this.preventDefault&&a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this.game.input.stopPointer(a.changedTouches[b])}},onTouchEnter:function(a){this.event=a,this.touchEnterCallback&&this.touchEnterCallback.call(this.callbackContext,a),this.game.input.enabled&&this.enabled&&this.preventDefault&&a.preventDefault()},onTouchLeave:function(a){this.event=a,this.touchLeaveCallback&&this.touchLeaveCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault()},onTouchMove:function(a){this.event=a,this.touchMoveCallback&&this.touchMoveCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault();for(var b=0;b<a.changedTouches.length;b++)this.game.input.updatePointer(a.changedTouches[b])},onTouchEnd:function(a){for(var b=this.touchLockCallbacks.length;b--;){var c=this.touchLockCallbacks[b];c.onEnd&&c.callback.call(c.context,this,a)&&this.touchLockCallbacks.splice(b,1)}this.event=a,this.touchEndCallback&&this.touchEndCallback.call(this.callbackContext,a),this.preventDefault&&a.preventDefault();for(b=0;b<a.changedTouches.length;b++)this.game.input.stopPointer(a.changedTouches[b])},stop:function(){this.game.device.touch&&(this.game.canvas.removeEventListener("touchstart",this._onTouchStart),this.game.canvas.removeEventListener("touchmove",this._onTouchMove),this.game.canvas.removeEventListener("touchend",this._onTouchEnd),this.game.canvas.removeEventListener("touchenter",this._onTouchEnter),this.game.canvas.removeEventListener("touchleave",this._onTouchLeave),this.game.canvas.removeEventListener("touchcancel",this._onTouchCancel))}},c.Touch.prototype.constructor=c.Touch,c.InputHandler=function(a){this.sprite=a,this.game=a.game,this.enabled=!1,this.checked=!1,this.priorityID=0,this.useHandCursor=!1,this._setHandCursor=!1,this.isDragged=!1,this.allowHorizontalDrag=!0,this.allowVerticalDrag=!0,this.bringToTop=!1,this.snapOffset=null,this.snapOnDrag=!1,this.snapOnRelease=!1,this.snapX=0,this.snapY=0,this.snapOffsetX=0,this.snapOffsetY=0,this.pixelPerfectOver=!1,this.pixelPerfectClick=!1,this.pixelPerfectAlpha=255,this.draggable=!1,this.boundsRect=null,this.boundsSprite=null,this.scaleLayer=!1,this.dragOffset=new c.Point,this.dragFromCenter=!1,this.dragStopBlocksInputUp=!1,this.dragStartPoint=new c.Point,this.dragDistanceThreshold=0,this.dragTimeThreshold=0,this.downPoint=new c.Point,this.snapPoint=new c.Point,this._dragPoint=new c.Point,this._dragPhase=!1,this._pendingDrag=!1,this._dragTimePass=!1,this._dragDistancePass=!1,this._wasEnabled=!1,this._tempPoint=new c.Point,this._pointerData=[],this._pointerData.push({id:0,x:0,y:0,camX:0,camY:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1})},c.InputHandler.prototype={start:function(a,b){if(a=a||0,void 0===b&&(b=!1),!1===this.enabled){this.game.input.interactiveItems.add(this),this.useHandCursor=b,this.priorityID=a;for(var d=0;d<10;d++)this._pointerData[d]={id:d,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1};this.snapOffset=new c.Point,this.enabled=!0,this._wasEnabled=!0}return this.sprite.events.onAddedToGroup.add(this.addedToGroup,this),this.sprite.events.onRemovedFromGroup.add(this.removedFromGroup,this),this.sprite},addedToGroup:function(){this._dragPhase||this._wasEnabled&&!this.enabled&&this.start()},removedFromGroup:function(){this._dragPhase||(this.enabled?(this._wasEnabled=!0,this.stop()):this._wasEnabled=!1)},reset:function(){this.enabled=!1;for(var a=0;a<10;a++)this._pointerData[a]={id:a,x:0,y:0,isDown:!1,isUp:!1,isOver:!1,isOut:!1,timeOver:0,timeOut:0,timeDown:0,timeUp:0,downDuration:0,isDragged:!1}},stop:function(){!1!==this.enabled&&(this.enabled=!1,this.game.input.interactiveItems.remove(this))},destroy:function(){this.sprite&&(this._setHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),this.enabled=!1,this.game.input.interactiveItems.remove(this),this._pointerData.length=0,this.boundsRect=null,this.boundsSprite=null,this.sprite=null)},validForInput:function(a,b,c){return void 0===c&&(c=!0),!(!this.enabled||0===this.sprite.scale.x||0===this.sprite.scale.y||this.priorityID<this.game.input.minPriorityID||this.sprite.parent&&this.sprite.parent.ignoreChildInput||!c&&(this.pixelPerfectClick||this.pixelPerfectOver)||!(this.priorityID>a||this.priorityID===a&&this.sprite.renderOrderID>b))},isPixelPerfect:function(){return this.pixelPerfectClick||this.pixelPerfectOver},pointerX:function(a){return a=a||0,this._pointerData[a].x},pointerY:function(a){return a=a||0,this._pointerData[a].y},pointerDown:function(a){return a=a||0,this._pointerData[a].isDown},pointerUp:function(a){return a=a||0,this._pointerData[a].isUp},pointerTimeDown:function(a){return a=a||0,this._pointerData[a].timeDown},pointerTimeUp:function(a){return a=a||0,this._pointerData[a].timeUp},pointerOver:function(a){if(!this.enabled)return!1;if(void 0!==a)return this._pointerData[a].isOver;for(var b=0;b<10;b++)if(this._pointerData[b].isOver)return!0;return!1},pointerOut:function(a){if(!this.enabled)return!1;if(void 0!==a)return this._pointerData[a].isOut;for(var b=0;b<10;b++)if(this._pointerData[b].isOut)return!0},pointerTimeOver:function(a){return a=a||0,this._pointerData[a].timeOver},pointerTimeOut:function(a){return a=a||0,this._pointerData[a].timeOut},pointerDragged:function(a){return a=a||0,this._pointerData[a].isDragged},checkPointerDown:function(a,b){return!!(a.isDown&&this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,a,this._tempPoint)&&(void 0===b&&(b=!1),!(!b&&this.pixelPerfectClick)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))},checkPointerOver:function(a,b){return!!(this.enabled&&this.sprite&&this.sprite.parent&&this.sprite.visible&&this.sprite.parent.visible&&0!==this.sprite.worldScale.x&&0!==this.sprite.worldScale.y)&&!!this.game.input.hitTest(this.sprite,a,this._tempPoint)&&(void 0===b&&(b=!1),!(!b&&this.pixelPerfectOver)||this.checkPixel(this._tempPoint.x,this._tempPoint.y))},checkPixel:function(a,b,c){if(this.sprite.texture.baseTexture.source){if(null===a&&null===b){this.game.input.getLocalPosition(this.sprite,c,this._tempPoint);a=this._tempPoint.x,b=this._tempPoint.y}if(0!==this.sprite.anchor.x&&(a-=-this.sprite.texture.frame.width*this.sprite.anchor.x),0!==this.sprite.anchor.y&&(b-=-this.sprite.texture.frame.height*this.sprite.anchor.y),a+=this.sprite.texture.frame.x,b+=this.sprite.texture.frame.y,this.sprite.texture.trim&&(a-=this.sprite.texture.trim.x,b-=this.sprite.texture.trim.y,a<this.sprite.texture.crop.x||a>this.sprite.texture.crop.right||b<this.sprite.texture.crop.y||b>this.sprite.texture.crop.bottom))return this._dx=a,this._dy=b,!1;if(this._dx=a,this._dy=b,this.game.input.hitContext.clearRect(0,0,1,1),this.game.input.hitContext.drawImage(this.sprite.texture.baseTexture.source,a,b,1,1,0,0,1,1),this.game.input.hitContext.getImageData(0,0,1,1).data[3]>=this.pixelPerfectAlpha)return!0}return!1},update:function(a){if(null!==this.sprite&&void 0!==this.sprite.parent)return this.enabled&&this.sprite.visible&&this.sprite.parent.visible?this._pendingDrag?(this._dragDistancePass||(this._dragDistancePass=c.Math.distance(a.x,a.y,this.downPoint.x,this.downPoint.y)>=this.dragDistanceThreshold),this._dragDistancePass&&this._dragTimePass&&this.startDrag(a),!0):this.draggable&&this._draggedPointerID===a.id?this.updateDrag(a,!1):this._pointerData[a.id].isOver?this.checkPointerOver(a)?(this._pointerData[a.id].x=a.x-this.sprite.x,this._pointerData[a.id].y=a.y-this.sprite.y,!0):(this._pointerOutHandler(a),!1):void 0:(this._pointerOutHandler(a),!1)},_pointerOverHandler:function(a,b){if(null!==this.sprite){var d=this._pointerData[a.id];if(!1===d.isOver||a.dirty){var e=!1===d.isOver;d.isOver=!0,d.isOut=!1,d.timeOver=this.game.time.time,d.x=a.x-this.sprite.x,d.y=a.y-this.sprite.y,this.useHandCursor&&!1===d.isDragged&&(this.game.canvas.style.cursor="pointer",this._setHandCursor=!0),!b&&e&&this.sprite&&this.sprite.events&&this.sprite.events.onInputOver$dispatch(this.sprite,a),this.sprite.parent&&this.sprite.parent.type===c.GROUP&&this.sprite.parent.onChildInputOver.dispatch(this.sprite,a)}}},_pointerOutHandler:function(a,b){if(null!==this.sprite){var d=this._pointerData[a.id];d.isOver=!1,d.isOut=!0,d.timeOut=this.game.time.time,this.useHandCursor&&!1===d.isDragged&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),!b&&this.sprite&&this.sprite.events&&(this.sprite.events.onInputOut$dispatch(this.sprite,a),this.sprite&&this.sprite.parent&&this.sprite.parent.type===c.GROUP&&this.sprite.parent.onChildInputOut.dispatch(this.sprite,a))}},_touchedHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];if(!b.isDown&&b.isOver){if(this.pixelPerfectClick&&!this.checkPixel(null,null,a))return;if(b.isDown=!0,b.isUp=!1,b.timeDown=this.game.time.time,this.downPoint.set(a.x,a.y),a.dirty=!0,this.sprite&&this.sprite.events&&(this.sprite.events.onInputDown$dispatch(this.sprite,a),this.sprite&&this.sprite.parent&&this.sprite.parent.type===c.GROUP&&this.sprite.parent.onChildInputDown.dispatch(this.sprite,a),null===this.sprite))return;this.draggable&&!1===this.isDragged&&(0===this.dragTimeThreshold&&0===this.dragDistanceThreshold?this.startDrag(a):(this._pendingDrag=!0,this._dragDistancePass=0===this.dragDistanceThreshold,0<this.dragTimeThreshold?(this._dragTimePass=!1,this.game.time.events.add(this.dragTimeThreshold,this.dragTimeElapsed,this,a)):this._dragTimePass=!0)),this.bringToTop&&this.sprite.bringToTop()}}},dragTimeElapsed:function(a){this._dragTimePass=!0,this._pendingDrag&&this.sprite&&this._dragDistancePass&&this.startDrag(a)},_releasedHandler:function(a){if(null!==this.sprite){var b=this._pointerData[a.id];if(b.isDown&&a.isUp){b.isDown=!1,b.isUp=!0,b.timeUp=this.game.time.time,b.downDuration=b.timeUp-b.timeDown;var d=this.checkPointerOver(a);this.sprite&&this.sprite.events&&(this.dragStopBlocksInputUp&&(!this.dragStopBlocksInputUp||this.draggable&&this.isDragged&&this._draggedPointerID===a.id)||this.sprite.events.onInputUp$dispatch(this.sprite,a,d),this.sprite&&this.sprite.parent&&this.sprite.parent.type===c.GROUP&&this.sprite.parent.onChildInputUp.dispatch(this.sprite,a,d),d&&(d=this.checkPointerOver(a))),!(b.isOver=d)&&this.useHandCursor&&(this.game.canvas.style.cursor="default",this._setHandCursor=!1),a.dirty=!0,this._pendingDrag=!1,this.draggable&&this.isDragged&&this._draggedPointerID===a.id&&this.stopDrag(a)}}},updateDrag:function(a,b){if(void 0===b&&(b=!1),a.isUp)return this.stopDrag(a),!1;var c=this.globalToLocalX(a.x)+this._dragPoint.x+this.dragOffset.x,d=this.globalToLocalY(a.y)+this._dragPoint.y+this.dragOffset.y;if(this.sprite.fixedToCamera)this.allowHorizontalDrag&&(this.sprite.cameraOffset.x=c),this.allowVerticalDrag&&(this.sprite.cameraOffset.y=d),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.cameraOffset.x,this.sprite.cameraOffset.y));else{var e=this.game.camera.x-this._pointerData[a.id].camX,f=this.game.camera.y-this._pointerData[a.id].camY;this.allowHorizontalDrag&&(this.sprite.x=c+e),this.allowVerticalDrag&&(this.sprite.y=d+f),this.boundsRect&&this.checkBoundsRect(),this.boundsSprite&&this.checkBoundsSprite(),this.snapOnDrag&&(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY,this.snapPoint.set(this.sprite.x,this.sprite.y))}return this.sprite.events.onDragUpdate.dispatch(this.sprite,a,c,d,this.snapPoint,b),!0},justOver:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOver&&this.overDuration(a)<b},justOut:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isOut&&this.game.time.time-this._pointerData[a].timeOut<b},justPressed:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isDown&&this.downDuration(a)<b},justReleased:function(a,b){return a=a||0,b=b||500,this._pointerData[a].isUp&&this.game.time.time-this._pointerData[a].timeUp<b},overDuration:function(a){return a=a||0,this._pointerData[a].isOver?this.game.time.time-this._pointerData[a].timeOver:-1},downDuration:function(a){return a=a||0,this._pointerData[a].isDown?this.game.time.time-this._pointerData[a].timeDown:-1},enableDrag:function(a,b,d,e,f,g){void 0===a&&(a=!1),void 0===b&&(b=!1),void 0===d&&(d=!1),void 0===e&&(e=255),void 0===f&&(f=null),void 0===g&&(g=null),this._dragPoint=new c.Point,this.draggable=!0,this.bringToTop=b,this.dragOffset=new c.Point,this.dragFromCenter=a,this.pixelPerfectClick=d,this.pixelPerfectAlpha=e,f&&(this.boundsRect=f),g&&(this.boundsSprite=g)},disableDrag:function(){if(this._pointerData)for(var a=0;a<10;a++)this._pointerData[a].isDragged=!1;this.draggable=!1,this.isDragged=!1,this._draggedPointerID=-1,this._pendingDrag=!1},startDrag:function(a){var b=this.sprite.x,c=this.sprite.y;if(this.isDragged=!0,this._draggedPointerID=a.id,this._pointerData[a.id].camX=this.game.camera.x,this._pointerData[a.id].camY=this.game.camera.y,this._pointerData[a.id].isDragged=!0,this.sprite.fixedToCamera){if(this.dragFromCenter){var d=this.sprite.getBounds();this.sprite.cameraOffset.x=this.globalToLocalX(a.x)+(this.sprite.cameraOffset.x-d.centerX),this.sprite.cameraOffset.y=this.globalToLocalY(a.y)+(this.sprite.cameraOffset.y-d.centerY)}this._dragPoint.setTo(this.sprite.cameraOffset.x-a.x,this.sprite.cameraOffset.y-a.y)}else{if(this.dragFromCenter){d=this.sprite.getBounds();this.sprite.x=this.globalToLocalX(a.x)+(this.sprite.x-d.centerX),this.sprite.y=this.globalToLocalY(a.y)+(this.sprite.y-d.centerY)}this._dragPoint.setTo(this.sprite.x-this.globalToLocalX(a.x),this.sprite.y-this.globalToLocalY(a.y))}this.updateDrag(a,!0),this.bringToTop&&(this._dragPhase=!0,this.sprite.bringToTop()),this.dragStartPoint.set(b,c),this.sprite.events.onDragStart$dispatch(this.sprite,a,b,c),this._pendingDrag=!1},globalToLocalX:function(a){return this.scaleLayer&&(a-=this.game.scale.grid.boundsFluid.x,a*=this.game.scale.grid.scaleFluidInversed.x),a},globalToLocalY:function(a){return this.scaleLayer&&(a-=this.game.scale.grid.boundsFluid.y,a*=this.game.scale.grid.scaleFluidInversed.y),a},stopDrag:function(a){this.isDragged=!1,this._draggedPointerID=-1,this._pointerData[a.id].isDragged=!1,this._dragPhase=!1,this._pendingDrag=!1,this.snapOnRelease&&(this.sprite.fixedToCamera?(this.sprite.cameraOffset.x=Math.round((this.sprite.cameraOffset.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.cameraOffset.y=Math.round((this.sprite.cameraOffset.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY):(this.sprite.x=Math.round((this.sprite.x-this.snapOffsetX%this.snapX)/this.snapX)*this.snapX+this.snapOffsetX%this.snapX,this.sprite.y=Math.round((this.sprite.y-this.snapOffsetY%this.snapY)/this.snapY)*this.snapY+this.snapOffsetY%this.snapY)),this.sprite.events.onDragStop$dispatch(this.sprite,a),!1===this.checkPointerOver(a)&&this._pointerOutHandler(a)},setDragLock:function(a,b){void 0===a&&(a=!0),void 0===b&&(b=!0),this.allowHorizontalDrag=a,this.allowVerticalDrag=b},enableSnap:function(a,b,c,d,e,f){void 0===c&&(c=!0),void 0===d&&(d=!1),void 0===e&&(e=0),void 0===f&&(f=0),this.snapX=a,this.snapY=b,this.snapOffsetX=e,this.snapOffsetY=f,this.snapOnDrag=c,this.snapOnRelease=d},disableSnap:function(){this.snapOnDrag=!1,this.snapOnRelease=!1},checkBoundsRect:function(){this.sprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsRect.left?this.sprite.cameraOffset.x=this.boundsRect.left:this.sprite.cameraOffset.x+this.sprite.width>this.boundsRect.right&&(this.sprite.cameraOffset.x=this.boundsRect.right-this.sprite.width),this.sprite.cameraOffset.y<this.boundsRect.top?this.sprite.cameraOffset.y=this.boundsRect.top:this.sprite.cameraOffset.y+this.sprite.height>this.boundsRect.bottom&&(this.sprite.cameraOffset.y=this.boundsRect.bottom-this.sprite.height)):(this.sprite.left<this.boundsRect.left?this.sprite.x=this.boundsRect.x+this.sprite.offsetX:this.sprite.right>this.boundsRect.right&&(this.sprite.x=this.boundsRect.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsRect.top?this.sprite.y=this.boundsRect.top+this.sprite.offsetY:this.sprite.bottom>this.boundsRect.bottom&&(this.sprite.y=this.boundsRect.bottom-(this.sprite.height-this.sprite.offsetY)))},checkBoundsSprite:function(){this.sprite.fixedToCamera&&this.boundsSprite.fixedToCamera?(this.sprite.cameraOffset.x<this.boundsSprite.cameraOffset.x?this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x:this.sprite.cameraOffset.x+this.sprite.width>this.boundsSprite.cameraOffset.x+this.boundsSprite.width&&(this.sprite.cameraOffset.x=this.boundsSprite.cameraOffset.x+this.boundsSprite.width-this.sprite.width),this.sprite.cameraOffset.y<this.boundsSprite.cameraOffset.y?this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y:this.sprite.cameraOffset.y+this.sprite.height>this.boundsSprite.cameraOffset.y+this.boundsSprite.height&&(this.sprite.cameraOffset.y=this.boundsSprite.cameraOffset.y+this.boundsSprite.height-this.sprite.height)):(this.sprite.left<this.boundsSprite.left?this.sprite.x=this.boundsSprite.left+this.sprite.offsetX:this.sprite.right>this.boundsSprite.right&&(this.sprite.x=this.boundsSprite.right-(this.sprite.width-this.sprite.offsetX)),this.sprite.top<this.boundsSprite.top?this.sprite.y=this.boundsSprite.top+this.sprite.offsetY:this.sprite.bottom>this.boundsSprite.bottom&&(this.sprite.y=this.boundsSprite.bottom-(this.sprite.height-this.sprite.offsetY)))}},c.InputHandler.prototype.constructor=c.InputHandler,c.Gamepad=function(a){this.game=a,this._gamepadIndexMap={},this._rawPads=[],this._active=!1,this.enabled=!0,this._gamepadSupportAvailable=!!navigator.webkitGetGamepads||!!navigator.webkitGamepads||-1!==navigator.userAgent.indexOf("Firefox/")||!!navigator.getGamepads,this._prevRawGamepadTypes=[],this._prevTimestamps=[],(this.callbackContext=this).onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this._ongamepadconnected=null,this._gamepaddisconnected=null,this._gamepads=[new c.SinglePad(a,this),new c.SinglePad(a,this),new c.SinglePad(a,this),new c.SinglePad(a,this)]},c.Gamepad.prototype={addCallbacks:function(a,b){void 0!==b&&(this.onConnectCallback="function"==typeof b.onConnect?b.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof b.onDisconnect?b.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof b.onDown?b.onDown:this.onDownCallback,this.onUpCallback="function"==typeof b.onUp?b.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof b.onAxis?b.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof b.onFloat?b.onFloat:this.onFloatCallback,this.callbackContext=a)},start:function(){if(!this._active){this._active=!0;var a=this;this._onGamepadConnected=function(b){return a.onGamepadConnected(b)},this._onGamepadDisconnected=function(b){return a.onGamepadDisconnected(b)},window.addEventListener("gamepadconnected",this._onGamepadConnected,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnected,!1)}},onGamepadConnected:function(a){var b=a.gamepad;this._rawPads.push(b),this._gamepads[b.index].connect(b)},onGamepadDisconnected:function(a){var b=a.gamepad;for(var c in this._rawPads)this._rawPads[c].index===b.index&&this._rawPads.splice(c,1);this._gamepads[b.index].disconnect()},update:function(){this._pollGamepads(),this.pad1.pollStatus(),this.pad2.pollStatus(),this.pad3.pollStatus(),this.pad4.pollStatus()},_pollGamepads:function(){if(this._active){if(navigator.getGamepads)var a=navigator.getGamepads();else if(navigator.webkitGetGamepads)a=navigator.webkitGetGamepads();else if(navigator.webkitGamepads)a=navigator.webkitGamepads();if(a){for(var b=!(this._rawPads=[]),c=0;c<a.length&&(typeof a[c]!==this._prevRawGamepadTypes[c]&&(b=!0,this._prevRawGamepadTypes[c]=typeof a[c]),a[c]&&this._rawPads.push(a[c]),3!==c);c++);for(var d=0;d<this._gamepads.length;d++)this._gamepads[d]._rawPad=this._rawPads[d];if(b){for(var e,f={rawIndices:{},padIndices:{}},g=0;g<this._gamepads.length;g++)if((e=this._gamepads[g]).connected)for(var h=0;h<this._rawPads.length;h++)this._rawPads[h].index===e.index&&(f.rawIndices[e.index]=!0,f.padIndices[g]=!0);for(var i=0;i<this._gamepads.length;i++)if(e=this._gamepads[i],!f.padIndices[i]){this._rawPads.length<1&&e.disconnect();for(var j=0;j<this._rawPads.length&&!f.padIndices[i];j++){var k=this._rawPads[j];if(k){if(f.rawIndices[k.index]){e.disconnect();continue}e.connect(k),f.rawIndices[k.index]=!0,f.padIndices[i]=!0}else e.disconnect()}}}}}},setDeadZones:function(a){for(var b=0;b<this._gamepads.length;b++)this._gamepads[b].deadZone=a},stop:function(){this._active=!1,window.removeEventListener("gamepadconnected",this._onGamepadConnected),window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnected)},reset:function(){this.update();for(var a=0;a<this._gamepads.length;a++)this._gamepads[a].reset()},justPressed:function(a,b){for(var c=0;c<this._gamepads.length;c++)if(!0===this._gamepads[c].justPressed(a,b))return!0;return!1},justReleased:function(a,b){for(var c=0;c<this._gamepads.length;c++)if(!0===this._gamepads[c].justReleased(a,b))return!0;return!1},isDown:function(a){for(var b=0;b<this._gamepads.length;b++)if(!0===this._gamepads[b].isDown(a))return!0;return!1},destroy:function(){this.stop();for(var a=0;a<this._gamepads.length;a++)this._gamepads[a].destroy()}},c.Gamepad.prototype.constructor=c.Gamepad,Object.defineProperty(c.Gamepad.prototype,"active",{get:function(){return this._active}}),Object.defineProperty(c.Gamepad.prototype,"supported",{get:function(){return this._gamepadSupportAvailable}}),Object.defineProperty(c.Gamepad.prototype,"padsConnected",{get:function(){return this._rawPads.length}}),Object.defineProperty(c.Gamepad.prototype,"pad1",{get:function(){return this._gamepads[0]}}),Object.defineProperty(c.Gamepad.prototype,"pad2",{get:function(){return this._gamepads[1]}}),Object.defineProperty(c.Gamepad.prototype,"pad3",{get:function(){return this._gamepads[2]}}),Object.defineProperty(c.Gamepad.prototype,"pad4",{get:function(){return this._gamepads[3]}}),c.Gamepad.BUTTON_0=0,c.Gamepad.BUTTON_1=1,c.Gamepad.BUTTON_2=2,c.Gamepad.BUTTON_3=3,c.Gamepad.BUTTON_4=4,c.Gamepad.BUTTON_5=5,c.Gamepad.BUTTON_6=6,c.Gamepad.BUTTON_7=7,c.Gamepad.BUTTON_8=8,c.Gamepad.BUTTON_9=9,c.Gamepad.BUTTON_10=10,c.Gamepad.BUTTON_11=11,c.Gamepad.BUTTON_12=12,c.Gamepad.BUTTON_13=13,c.Gamepad.BUTTON_14=14,c.Gamepad.BUTTON_15=15,c.Gamepad.AXIS_0=0,c.Gamepad.AXIS_1=1,c.Gamepad.AXIS_2=2,c.Gamepad.AXIS_3=3,c.Gamepad.AXIS_4=4,c.Gamepad.AXIS_5=5,c.Gamepad.AXIS_6=6,c.Gamepad.AXIS_7=7,c.Gamepad.AXIS_8=8,c.Gamepad.AXIS_9=9,c.Gamepad.XBOX360_A=0,c.Gamepad.XBOX360_B=1,c.Gamepad.XBOX360_X=2,c.Gamepad.XBOX360_Y=3,c.Gamepad.XBOX360_LEFT_BUMPER=4,c.Gamepad.XBOX360_RIGHT_BUMPER=5,c.Gamepad.XBOX360_LEFT_TRIGGER=6,c.Gamepad.XBOX360_RIGHT_TRIGGER=7,c.Gamepad.XBOX360_BACK=8,c.Gamepad.XBOX360_START=9,c.Gamepad.XBOX360_STICK_LEFT_BUTTON=10,c.Gamepad.XBOX360_STICK_RIGHT_BUTTON=11,c.Gamepad.XBOX360_DPAD_LEFT=14,c.Gamepad.XBOX360_DPAD_RIGHT=15,c.Gamepad.XBOX360_DPAD_UP=12,c.Gamepad.XBOX360_DPAD_DOWN=13,c.Gamepad.XBOX360_STICK_LEFT_X=0,c.Gamepad.XBOX360_STICK_LEFT_Y=1,c.Gamepad.XBOX360_STICK_RIGHT_X=2,c.Gamepad.XBOX360_STICK_RIGHT_Y=3,c.Gamepad.PS3XC_X=0,c.Gamepad.PS3XC_CIRCLE=1,c.Gamepad.PS3XC_SQUARE=2,c.Gamepad.PS3XC_TRIANGLE=3,c.Gamepad.PS3XC_L1=4,c.Gamepad.PS3XC_R1=5,c.Gamepad.PS3XC_L2=6,c.Gamepad.PS3XC_R2=7,c.Gamepad.PS3XC_SELECT=8,c.Gamepad.PS3XC_START=9,c.Gamepad.PS3XC_STICK_LEFT_BUTTON=10,c.Gamepad.PS3XC_STICK_RIGHT_BUTTON=11,c.Gamepad.PS3XC_DPAD_UP=12,c.Gamepad.PS3XC_DPAD_DOWN=13,c.Gamepad.PS3XC_DPAD_LEFT=14,c.Gamepad.PS3XC_DPAD_RIGHT=15,c.Gamepad.PS3XC_STICK_LEFT_X=0,c.Gamepad.PS3XC_STICK_LEFT_Y=1,c.Gamepad.PS3XC_STICK_RIGHT_X=2,c.Gamepad.PS3XC_STICK_RIGHT_Y=3,c.SinglePad=function(a,b){this.game=a,this.index=null,this.connected=!1,(this.callbackContext=this).onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null,this.deadZone=.26,this._padParent=b,this._rawPad=null,this._prevTimestamp=null,this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0},c.SinglePad.prototype={addCallbacks:function(a,b){void 0!==b&&(this.onConnectCallback="function"==typeof b.onConnect?b.onConnect:this.onConnectCallback,this.onDisconnectCallback="function"==typeof b.onDisconnect?b.onDisconnect:this.onDisconnectCallback,this.onDownCallback="function"==typeof b.onDown?b.onDown:this.onDownCallback,this.onUpCallback="function"==typeof b.onUp?b.onUp:this.onUpCallback,this.onAxisCallback="function"==typeof b.onAxis?b.onAxis:this.onAxisCallback,this.onFloatCallback="function"==typeof b.onFloat?b.onFloat:this.onFloatCallback,this.callbackContext=a)},getButton:function(a){return this._buttons[a]?this._buttons[a]:null},pollStatus:function(){if(this.connected&&this.game.input.enabled&&this.game.input.gamepad.enabled&&(!this._rawPad.timestamp||this._rawPad.timestamp!==this._prevTimestamp)){for(var a=0;a<this._buttonsLen;a++){var b=isNaN(this._rawPad.buttons[a])?this._rawPad.buttons[a].value:this._rawPad.buttons[a];b!==this._buttons[a].value&&(1===b?this.processButtonDown(a,b):0===b?this.processButtonUp(a,b):this.processButtonFloat(a,b))}for(var c=0;c<this._axesLen;c++){var d=this._rawPad.axes[c];0<d&&d>this.deadZone||d<0&&d<-this.deadZone?this.processAxisChange(c,d):this.processAxisChange(c,0)}this._prevTimestamp=this._rawPad.timestamp}},connect:function(a){var b=!this.connected;this.connected=!0,this.index=a.index,this._rawPad=a,this._buttons=[],this._buttonsLen=a.buttons.length,this._axes=[],this._axesLen=a.axes.length;for(var d=0;d<this._axesLen;d++)this._axes[d]=a.axes[d];for(var e in a.buttons)e=parseInt(e,10),this._buttons[e]=new c.DeviceButton(this,e);b&&this._padParent.onConnectCallback&&this._padParent.onConnectCallback.call(this._padParent.callbackContext,this.index),b&&this.onConnectCallback&&this.onConnectCallback.call(this.callbackContext)},disconnect:function(){var a=this.connected,b=this.index;this.connected=!1,this.index=null,this._rawPad=void 0;for(var c=0;c<this._buttonsLen;c++)this._buttons[c].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,a&&this._padParent.onDisconnectCallback&&this._padParent.onDisconnectCallback.call(this._padParent.callbackContext,b),a&&this.onDisconnectCallback&&this.onDisconnectCallback.call(this.callbackContext)},destroy:function(){this._rawPad=void 0;for(var a=0;a<this._buttonsLen;a++)this._buttons[a].destroy();this._buttons=[],this._buttonsLen=0,this._axes=[],this._axesLen=0,this.onConnectCallback=null,this.onDisconnectCallback=null,this.onDownCallback=null,this.onUpCallback=null,this.onAxisCallback=null,this.onFloatCallback=null},processAxisChange:function(a,b){this._axes[a]!==b&&(this._axes[a]=b,this._padParent.onAxisCallback&&this._padParent.onAxisCallback.call(this._padParent.callbackContext,this,a,b),this.onAxisCallback&&this.onAxisCallback.call(this.callbackContext,this,a,b))},processButtonDown:function(a,b){this._buttons[a]&&this._buttons[a].start(null,b),this._padParent.onDownCallback&&this._padParent.onDownCallback.call(this._padParent.callbackContext,a,b,this.index),this.onDownCallback&&this.onDownCallback.call(this.callbackContext,a,b)},processButtonUp:function(a,b){this._padParent.onUpCallback&&this._padParent.onUpCallback.call(this._padParent.callbackContext,a,b,this.index),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,a,b),this._buttons[a]&&this._buttons[a].stop(null,b)},processButtonFloat:function(a,b){this._padParent.onFloatCallback&&this._padParent.onFloatCallback.call(this._padParent.callbackContext,a,b,this.index),this.onFloatCallback&&this.onFloatCallback.call(this.callbackContext,a,b),this._buttons[a]&&this._buttons[a].padFloat(b)},axis:function(a){return!!this._axes[a]&&this._axes[a]},isDown:function(a){return!!this._buttons[a]&&this._buttons[a].isDown},isUp:function(a){return!!this._buttons[a]&&this._buttons[a].isUp},justReleased:function(a,b){if(this._buttons[a])return this._buttons[a].justReleased(b)},justPressed:function(a,b){if(this._buttons[a])return this._buttons[a].justPressed(b)},buttonValue:function(a){return this._buttons[a]?this._buttons[a].value:null},reset:function(){for(var a=0;a<this._axes.length;a++)this._axes[a]=0}},c.SinglePad.prototype.constructor=c.SinglePad,c.Key=function(a,b){this.game=a,this._enabled=!0,this.event=null,this.isDown=!1,this.isUp=!0,this.altKey=!1,this.ctrlKey=!1,this.shiftKey=!1,this.timeDown=0,this.duration=0,this.timeUp=-2500,this.repeats=0,this.keyCode=b,this.onDown=new c.Signal,this.onHoldCallback=null,this.onHoldContext=null,this.onUp=new c.Signal,this._justDown=!1,this._justUp=!1},c.Key.prototype={update:function(){this._enabled&&this.isDown&&(this.duration=this.game.time.time-this.timeDown,this.repeats++,this.onHoldCallback&&this.onHoldCallback.call(this.onHoldContext,this))},processKeyDown:function(a){this._enabled&&(this.event=a,this.isDown||(this.altKey=a.altKey,this.ctrlKey=a.ctrlKey,this.shiftKey=a.shiftKey,this.isDown=!0,this.isUp=!1,this.timeDown=this.game.time.time,this.duration=0,this.repeats=0,this._justDown=!0,this.onDown.dispatch(this)))},processKeyUp:function(a){this._enabled&&(this.event=a,this.isUp||(this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=this.game.time.time-this.timeDown,this._justUp=!0,this.onUp.dispatch(this)))},reset:function(a){void 0===a&&(a=!0),this.isDown=!1,this.isUp=!0,this.timeUp=this.game.time.time,this.duration=0,this._enabled=!0,this._justDown=!1,this._justUp=!1,a&&(this.onDown.removeAll(),this.onUp.removeAll(),this.onHoldCallback=null,this.onHoldContext=null)},downDuration:function(a){return void 0===a&&(a=50),this.isDown&&this.duration<a},upDuration:function(a){return void 0===a&&(a=50),!this.isDown&&this.game.time.time-this.timeUp<a}},Object.defineProperty(c.Key.prototype,"justDown",{get:function(){var a=this._justDown;return this._justDown=!1,a}}),Object.defineProperty(c.Key.prototype,"justUp",{get:function(){var a=this._justUp;return this._justUp=!1,a}}),Object.defineProperty(c.Key.prototype,"enabled",{get:function(){return this._enabled},set:function(a){(a=!!a)!==this._enabled&&(a||this.reset(!1),this._enabled=a)}}),c.Key.prototype.constructor=c.Key,c.Keyboard=function(a){this.game=a,this.enabled=!0,this.event=null,this.pressEvent=null,(this.callbackContext=this).onDownCallback=null,this.onPressCallback=null,this.onUpCallback=null,this._keys=[],this._capture=[],this._onKeyDown=null,this._onKeyPress=null,this._onKeyUp=null,this._i=0,this._k=0},c.Keyboard.prototype={addCallbacks:function(a,b,c,d){this.callbackContext=a,null!=b&&(this.onDownCallback=b),null!=c&&(this.onUpCallback=c),null!=d&&(this.onPressCallback=d)},addKey:function(a){return this._keys[a]||(this._keys[a]=new c.Key(this.game,a),this.addKeyCapture(a)),this._keys[a]},addKeys:function(a){var b={};for(var c in a)b[c]=this.addKey(a[c]);return b},removeKey:function(a){this._keys[a]&&(this._keys[a]=null,this.removeKeyCapture(a))},createCursorKeys:function(){return this.addKeys({up:c.KeyCode.UP,down:c.KeyCode.DOWN,left:c.KeyCode.LEFT,right:c.KeyCode.RIGHT})},start:function(){if(!this.game.device.cocoonJS&&null===this._onKeyDown){var a=this;this._onKeyDown=function(b){return a.processKeyDown(b)},this._onKeyUp=function(b){return a.processKeyUp(b)},this._onKeyPress=function(b){return a.processKeyPress(b)},window.addEventListener("keydown",this._onKeyDown,!1),window.addEventListener("keyup",this._onKeyUp,!1),window.addEventListener("keypress",this._onKeyPress,!1)}},stop:function(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),window.removeEventListener("keypress",this._onKeyPress),this._onKeyDown=null,this._onKeyUp=null,this._onKeyPress=null},destroy:function(){this.stop(),this.clearCaptures(),this._keys.length=0,this._i=0},addKeyCapture:function(a){if("object"==typeof a)for(var b in a)this._capture[a[b]]=!0;else this._capture[a]=!0},removeKeyCapture:function(a){delete this._capture[a]},clearCaptures:function(){this._capture={}},update:function(){for(this._i=this._keys.length;this._i--;)this._keys[this._i]&&this._keys[this._i].update()},processKeyDown:function(a){if(this.event=a,this.game.input.enabled&&this.enabled){var b=a.keyCode;this._capture[b]&&a.preventDefault(),this._keys[b]||(this._keys[b]=new c.Key(this.game,b)),this._keys[b].processKeyDown(a),this._k=b,this.onDownCallback&&this.onDownCallback.call(this.callbackContext,a)}},processKeyPress:function(a){this.pressEvent=a,this.game.input.enabled&&this.enabled&&this.onPressCallback&&this.onPressCallback.call(this.callbackContext,String.fromCharCode(a.charCode),a)},processKeyUp:function(a){if(this.event=a,this.game.input.enabled&&this.enabled){var b=a.keyCode;this._capture[b]&&a.preventDefault(),this._keys[b]||(this._keys[b]=new c.Key(this.game,b)),this._keys[b].processKeyUp(a),this.onUpCallback&&this.onUpCallback.call(this.callbackContext,a)}},reset:function(a){void 0===a&&(a=!0),this.event=null;for(var b=this._keys.length;b--;)this._keys[b]&&this._keys[b].reset(a)},downDuration:function(a,b){return this._keys[a]?this._keys[a].downDuration(b):null},upDuration:function(a,b){return this._keys[a]?this._keys[a].upDuration(b):null},isDown:function(a){return this._keys[a]?this._keys[a].isDown:null}},Object.defineProperty(c.Keyboard.prototype,"lastChar",{get:function(){return 32===this.event.charCode?"":String.fromCharCode(this.pressEvent.charCode)}}),Object.defineProperty(c.Keyboard.prototype,"lastKey",{get:function(){return this._keys[this._k]}}),c.Keyboard.prototype.constructor=c.Keyboard,c.KeyCode={A:"A".charCodeAt(0),B:"B".charCodeAt(0),C:"C".charCodeAt(0),D:"D".charCodeAt(0),E:"E".charCodeAt(0),F:"F".charCodeAt(0),G:"G".charCodeAt(0),H:"H".charCodeAt(0),I:"I".charCodeAt(0),J:"J".charCodeAt(0),K:"K".charCodeAt(0),L:"L".charCodeAt(0),M:"M".charCodeAt(0),N:"N".charCodeAt(0),O:"O".charCodeAt(0),P:"P".charCodeAt(0),Q:"Q".charCodeAt(0),R:"R".charCodeAt(0),S:"S".charCodeAt(0),T:"T".charCodeAt(0),U:"U".charCodeAt(0),V:"V".charCodeAt(0),W:"W".charCodeAt(0),X:"X".charCodeAt(0),Y:"Y".charCodeAt(0),Z:"Z".charCodeAt(0),ZERO:"0".charCodeAt(0),ONE:"1".charCodeAt(0),TWO:"2".charCodeAt(0),THREE:"3".charCodeAt(0),FOUR:"4".charCodeAt(0),FIVE:"5".charCodeAt(0),SIX:"6".charCodeAt(0),SEVEN:"7".charCodeAt(0),EIGHT:"8".charCodeAt(0),NINE:"9".charCodeAt(0),NUMPAD_0:96,NUMPAD_1:97,NUMPAD_2:98,NUMPAD_3:99,NUMPAD_4:100,NUMPAD_5:101,NUMPAD_6:102,NUMPAD_7:103,NUMPAD_8:104,NUMPAD_9:105,NUMPAD_MULTIPLY:106,NUMPAD_ADD:107,NUMPAD_ENTER:108,NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,F13:124,F14:125,F15:126,COLON:186,EQUALS:187,COMMA:188,UNDERSCORE:189,PERIOD:190,QUESTION_MARK:191,TILDE:192,OPEN_BRACKET:219,BACKWARD_SLASH:220,CLOSED_BRACKET:221,QUOTES:222,BACKSPACE:8,TAB:9,CLEAR:12,ENTER:13,SHIFT:16,CONTROL:17,ALT:18,CAPS_LOCK:20,ESC:27,SPACEBAR:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PLUS:43,MINUS:44,INSERT:45,DELETE:46,HELP:47,NUM_LOCK:144},c.KeyCode)c.KeyCode.hasOwnProperty(e)&&!e.match(/[a-z]/)&&(c.Keyboard[e]=c.KeyCode[e]);for(var f in c.Component=function(){},c.Component.Angle=function(){},c.Component.Angle.prototype={angle:{get:function(){return c.Math.wrapAngle(c.Math.radToDeg(this.rotation))},set:function(a){this.rotation=c.Math.degToRad(c.Math.wrapAngle(a))}}},c.Component.Animation=function(){},c.Component.Animation.prototype={play:function(a,b,c,d){if(this.animations)return this.animations.play(a,b,c,d)}},c.Component.AutoCull=function(){},c.Component.AutoCull.prototype={autoCull:!1,inCamera:{get:function(){return this.autoCull||this.checkWorldBounds||(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y),this.game.world.camera.view.intersects(this._bounds)}}},c.Component.Bounds=function(){},c.Component.Bounds.prototype={offsetX:{get:function(){return this.anchor.x*this.width}},offsetY:{get:function(){return this.anchor.y*this.height}},centerX:{get:function(){return this.x-this.offsetX+.5*this.width},set:function(a){this.x=a+this.offsetX-.5*this.width}},centerY:{get:function(){return this.y-this.offsetY+.5*this.height},set:function(a){this.y=a+this.offsetY-.5*this.height}},left:{get:function(){return this.x-this.offsetX},set:function(a){this.x=a+this.offsetX}},right:{get:function(){return this.x+this.width-this.offsetX},set:function(a){this.x=a-this.width+this.offsetX}},top:{get:function(){return this.y-this.offsetY},set:function(a){this.y=a+this.offsetY}},bottom:{get:function(){return this.y+this.height-this.offsetY},set:function(a){this.y=a-this.height+this.offsetY}},alignIn:function(a,b,d,e){switch(void 0===d&&(d=0),void 0===e&&(e=0),b){default:case c.TOP_LEFT:this.left=a.left-d,this.top=a.top-e;break;case c.TOP_CENTER:this.centerX=a.centerX+d,this.top=a.top-e;break;case c.TOP_RIGHT:this.right=a.right+d,this.top=a.top-e;break;case c.LEFT_CENTER:this.left=a.left-d,this.centerY=a.centerY+e;break;case c.CENTER:this.centerX=a.centerX+d,this.centerY=a.centerY+e;break;case c.RIGHT_CENTER:this.right=a.right+d,this.centerY=a.centerY+e;break;case c.BOTTOM_LEFT:this.left=a.left-d,this.bottom=a.bottom+e;break;case c.BOTTOM_CENTER:this.centerX=a.centerX+d,this.bottom=a.bottom+e;break;case c.BOTTOM_RIGHT:this.right=a.right+d,this.bottom=a.bottom+e}return this},alignTo:function(a,b,d,e){switch(void 0===d&&(d=0),void 0===e&&(e=0),b){default:case c.TOP_LEFT:this.left=a.left-d,this.bottom=a.top-e;break;case c.TOP_CENTER:this.centerX=a.centerX+d,this.bottom=a.top-e;break;case c.TOP_RIGHT:this.right=a.right+d,this.bottom=a.top-e;break;case c.LEFT_TOP:this.right=a.left-d,this.top=a.top-e;break;case c.LEFT_CENTER:this.right=a.left-d,this.centerY=a.centerY+e;break;case c.LEFT_BOTTOM:this.right=a.left-d,this.bottom=a.bottom+e;break;case c.RIGHT_TOP:this.left=a.right+d,this.top=a.top-e;break;case c.RIGHT_CENTER:this.left=a.right+d,this.centerY=a.centerY+e;break;case c.RIGHT_BOTTOM:this.left=a.right+d,this.bottom=a.bottom+e;break;case c.BOTTOM_LEFT:this.left=a.left-d,this.top=a.bottom+e;break;case c.BOTTOM_CENTER:this.centerX=a.centerX+d,this.top=a.bottom+e;break;case c.BOTTOM_RIGHT:this.right=a.right+d,this.top=a.bottom+e}return this}},c.Group.prototype.alignIn=c.Component.Bounds.prototype.alignIn,c.Group.prototype.alignTo=c.Component.Bounds.prototype.alignTo,c.Component.BringToTop=function(){},c.Component.BringToTop.prototype.bringToTop=function(){return this.parent&&this.parent.bringToTop(this),this},c.Component.BringToTop.prototype.sendToBack=function(){return this.parent&&this.parent.sendToBack(this),this},c.Component.BringToTop.prototype.moveUp=function(){return this.parent&&this.parent.moveUp(this),this},c.Component.BringToTop.prototype.moveDown=function(){return this.parent&&this.parent.moveDown(this),this},c.Component.Core=function(){},c.Component.Core.install=function(a){c.Utils.mixinPrototype(this,c.Component.Core.prototype),this.components={};for(var b=0;b<a.length;b++){var d=a[b],e=!1;"Destroy"===d&&(e=!0),c.Utils.mixinPrototype(this,c.Component[d].prototype,e),this.components[d]=!0}},c.Component.Core.init=function(a,b,d,e,f){this.game=a,this.key=e,this.data={},this.position.set(b,d),this.world=new c.Point(b,d),this.previousPosition=new c.Point(b,d),this.events=new c.Events(this),this._bounds=new c.Rectangle,this.components.PhysicsBody&&(this.body=this.body),this.components.Animation&&(this.animations=new c.AnimationManager(this)),this.components.LoadTexture&&null!==e&&this.loadTexture(e,f),this.components.FixedToCamera&&(this.cameraOffset=new c.Point(b,d))},c.Component.Core.preUpdate=function(){if(!this.pendingDestroy){if(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!this.exists||!this.parent.exists)return!(this.renderOrderID=-1);this.world.setTo(this.game.camera.x+this.worldTransform.tx,this.game.camera.y+this.worldTransform.ty),this.visible&&(this.renderOrderID=this.game.stage.currentRenderOrderID++),this.animations&&this.animations.update(),this.body&&this.body.preUpdate();for(var a=0;a<this.children.length;a++)this.children[a].preUpdate();return!0}this.destroy()},c.Component.Core.prototype={game:null,name:"",data:{},components:{},z:0,events:void 0,animations:void 0,key:"",world:null,debug:!1,previousPosition:null,previousRotation:0,renderOrderID:0,fresh:!0,pendingDestroy:!1,_bounds:null,_exists:!0,exists:{get:function(){return this._exists},set:function(a){a?(this._exists=!0,this.body&&this.body.type===c.Physics.P2JS&&this.body.addToWorld(),this.visible=!0):(this._exists=!1,this.body&&this.body.type===c.Physics.P2JS&&this.body.removeFromWorld(),this.visible=!1)}},update:function(){},postUpdate:function(){this.customRender&&this.key.render(),this.components.PhysicsBody&&c.Component.PhysicsBody.postUpdate.call(this),this.components.FixedToCamera&&c.Component.FixedToCamera.postUpdate.call(this);for(var a=0;a<this.children.length;a++)this.children[a].postUpdate()}},c.Component.Crop=function(){},c.Component.Crop.prototype={cropRect:null,_crop:null,crop:function(a,b){void 0===b&&(b=!1),a?(b&&null!==this.cropRect?this.cropRect.setTo(a.x,a.y,a.width,a.height):b&&null===this.cropRect?this.cropRect=new c.Rectangle(a.x,a.y,a.width,a.height):this.cropRect=a,this.updateCrop()):(this._crop=null,this.cropRect=null,this.resetFrame())},updateCrop:function(){if(this.cropRect){var a=this.texture.crop.x,b=this.texture.crop.y,d=this.texture.crop.width,e=this.texture.crop.height;this._crop=c.Rectangle.clone(this.cropRect,this._crop),this._crop.x+=this._frame.x,this._crop.y+=this._frame.y;var f=Math.max(this._frame.x,this._crop.x),g=Math.max(this._frame.y,this._crop.y),h=Math.min(this._frame.right,this._crop.right)-f,i=Math.min(this._frame.bottom,this._crop.bottom)-g;this.texture.crop.x=f,this.texture.crop.y=g,this.texture.crop.width=h,this.texture.crop.height=i,this.texture.frame.width=Math.min(h,this.cropRect.width),this.texture.frame.height=Math.min(i,this.cropRect.height),this.texture.width=this.texture.frame.width,this.texture.height=this.texture.frame.height,this.texture._updateUvs(),16777215===this.tint||a===f&&b===g&&d===h&&e===i||(this.texture.requiresReTint=!0)}}},c.Component.Delta=function(){},c.Component.Delta.prototype={deltaX:{get:function(){return this.world.x-this.previousPosition.x}},deltaY:{get:function(){return this.world.y-this.previousPosition.y}},deltaZ:{get:function(){return this.rotation-this.previousRotation}}},c.Component.Destroy=function(){},c.Component.Destroy.prototype={destroyPhase:!1,destroy:function(a,b){if(null!==this.game&&!this.destroyPhase){void 0===a&&(a=!0),void 0===b&&(b=!1),this.destroyPhase=!0,this.events&&this.events.onDestroy$dispatch(this),this.parent&&(this.parent instanceof c.Group?this.parent.remove(this):this.parent.removeChild(this)),this.input&&this.input.destroy(),this.animations&&this.animations.destroy(),this.body&&this.body.destroy(),this.events&&this.events.destroy(),this.game.tweens.removeFrom(this);var d=this.children.length;if(a)for(;d--;)this.children[d].destroy(a);else for(;d--;)this.removeChild(this.children[d]);this._crop&&(this._crop=null,this.cropRect=null),this._frame&&(this._frame=null),c.Video&&this.key instanceof c.Video&&this.key.onChangeSource.remove(this.resizeFrame,this),c.BitmapText&&this._glyphs&&(this._glyphs=[]),this.alive=!1,this.exists=!1,this.visible=!1,this.filters=null,this.mask=null,this.game=null,this.data={},this.renderable=!1,this.transformCallback&&(this.transformCallback=null,this.transformCallbackContext=null),this.hitArea=null,this.parent=null,this.stage=null,this.worldTransform=null,this.filterArea=null,this._bounds=null,this._currentBounds=null,this._mask=null,this._destroyCachedSprite(),b&&this.texture.destroy(!0),this.destroyPhase=!1,this.pendingDestroy=!1}}},c.Events=function(a){this.parent=a},c.Events.prototype={destroy:function(){this._parent=null,this._onDestroy&&this._onDestroy.dispose(),this._onAddedToGroup&&this._onAddedToGroup.dispose(),this._onRemovedFromGroup&&this._onRemovedFromGroup.dispose(),this._onRemovedFromWorld&&this._onRemovedFromWorld.dispose(),this._onKilled&&this._onKilled.dispose(),this._onRevived&&this._onRevived.dispose(),this._onEnterBounds&&this._onEnterBounds.dispose(),this._onOutOfBounds&&this._onOutOfBounds.dispose(),this._onInputOver&&this._onInputOver.dispose(),this._onInputOut&&this._onInputOut.dispose(),this._onInputDown&&this._onInputDown.dispose(),this._onInputUp&&this._onInputUp.dispose(),this._onDragStart&&this._onDragStart.dispose(),this._onDragUpdate&&this._onDragUpdate.dispose(),this._onDragStop&&this._onDragStop.dispose(),this._onAnimationStart&&this._onAnimationStart.dispose(),this._onAnimationComplete&&this._onAnimationComplete.dispose(),this._onAnimationLoop&&this._onAnimationLoop.dispose()},onAddedToGroup:null,onRemovedFromGroup:null,onRemovedFromWorld:null,onDestroy:null,onKilled:null,onRevived:null,onOutOfBounds:null,onEnterBounds:null,onInputOver:null,onInputOut:null,onInputDown:null,onInputUp:null,onDragStart:null,onDragUpdate:null,onDragStop:null,onAnimationStart:null,onAnimationComplete:null,onAnimationLoop:null},c.Events.prototype.constructor=c.Events,c.Events.prototype)c.Events.prototype.hasOwnProperty(f)&&0===f.indexOf("on")&&null===c.Events.prototype[f]&&function(a,b){"use strict";Object.defineProperty(c.Events.prototype,a,{get:function(){return this[b]||(this[b]=new c.Signal)}}),c.Events.prototype[a+"$dispatch"]=function(){return this[b]?this[b].dispatch.apply(this[b],arguments):null}}(f,"_"+f);c.Component.FixedToCamera=function(){},c.Component.FixedToCamera.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y)},c.Component.FixedToCamera.prototype={_fixedToCamera:!1,fixedToCamera:{get:function(){return this._fixedToCamera},set:function(a){a?(this._fixedToCamera=!0,this.cameraOffset.set(this.x,this.y)):this._fixedToCamera=!1}},cameraOffset:new c.Point},c.Component.Health=function(){},c.Component.Health.prototype={health:1,maxHealth:100,damage:function(a){return this.alive&&(this.health-=a,this.health<=0&&this.kill()),this},setHealth:function(a){return this.health=a,this.health>this.maxHealth&&(this.health=this.maxHealth),this},heal:function(a){return this.alive&&(this.health+=a,this.health>this.maxHealth&&(this.health=this.maxHealth)),this}},c.Component.InCamera=function(){},c.Component.InCamera.prototype={inCamera:{get:function(){return this.game.world.camera.view.intersects(this._bounds)}}},c.Component.InputEnabled=function(){},c.Component.InputEnabled.prototype={input:null,inputEnabled:{get:function(){return this.input&&this.input.enabled},set:function(a){a?null===this.input?(this.input=new c.InputHandler(this),this.input.start()):this.input&&!this.input.enabled&&this.input.start():this.input&&this.input.enabled&&this.input.stop()}}},c.Component.InWorld=function(){},c.Component.InWorld.preUpdate=function(){if(this.autoCull||this.checkWorldBounds){if(this._bounds.copyFrom(this.getBounds()),this._bounds.x+=this.game.camera.view.x,this._bounds.y+=this.game.camera.view.y,this.autoCull)if(this.game.world.camera.view.intersects(this._bounds))this.renderable=!0,this.game.world.camera.totalInView++;else if(this.renderable=!1,this.outOfCameraBoundsKill)return this.kill(),!1;if(this.checkWorldBounds)if(this._outOfBoundsFired&&this.game.world.bounds.intersects(this._bounds))this._outOfBoundsFired=!1,this.events.onEnterBounds$dispatch(this);else if(!this._outOfBoundsFired&&!this.game.world.bounds.intersects(this._bounds)&&(this._outOfBoundsFired=!0,this.events.onOutOfBounds$dispatch(this),this.outOfBoundsKill))return this.kill(),!1}return!0},c.Component.InWorld.prototype={checkWorldBounds:!1,outOfBoundsKill:!1,outOfCameraBoundsKill:!1,_outOfBoundsFired:!1,inWorld:{get:function(){return this.game.world.bounds.intersects(this.getBounds())}}},c.Component.LifeSpan=function(){},c.Component.LifeSpan.preUpdate=function(){return!(0<this.lifespan&&(this.lifespan-=this.game.time.physicsElapsedMS,this.lifespan<=0)&&(this.kill(),1))},c.Component.LifeSpan.prototype={alive:!0,lifespan:0,revive:function(a){return void 0===a&&(a=100),this.alive=!0,this.exists=!0,this.visible=!0,"function"==typeof this.setHealth&&this.setHealth(a),this.events&&this.events.onRevived$dispatch(this),this},kill:function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.events&&this.events.onKilled$dispatch(this),this}},c.Component.LoadTexture=function(){},c.Component.LoadTexture.prototype={customRender:!1,_frame:null,loadTexture:function(a,b,d){b=a===c.PENDING_ATLAS?(a=b,0):b||0,(d||void 0===d)&&this.animations&&this.animations.stop(),this.key=a,this.customRender=!1;var e=this.game.cache,f=!0,g=!this.texture.baseTexture.scaleMode;if(c.RenderTexture&&a instanceof c.RenderTexture)this.key=a.key,this.setTexture(a);else if(c.BitmapData&&a instanceof c.BitmapData)this.customRender=!0,this.setTexture(a.texture),f=e.hasFrameData(a.key,c.Cache.BITMAPDATA)?!this.animations.loadFrameData(e.getFrameData(a.key,c.Cache.BITMAPDATA),b):!this.animations.loadFrameData(a.frameData,0);else if(c.Video&&a instanceof c.Video){this.customRender=!0;var h=a.texture.valid;this.setTexture(a.texture),this.setFrame(a.texture.frame.clone()),a.onChangeSource.add(this.resizeFrame,this),this.texture.valid=h}else if(c.Tilemap&&a instanceof c.TilemapLayer)this.setTexture(PIXI.Texture.fromCanvas(a.canvas));else if(a instanceof PIXI.Texture)this.setTexture(a);else{var i=e.getImage(a,!0);this.key=i.key,this.setTexture(new PIXI.Texture(i.base)),this.texture.baseTexture.skipRender="__default"===a,f=!this.animations.loadFrameData(i.frameData,b)}f&&(this._frame=c.Rectangle.clone(this.texture.frame)),g||(this.texture.baseTexture.scaleMode=1)},setFrame:function(a){this._frame=a,this.texture.frame.x=a.x,this.texture.frame.y=a.y,this.texture.frame.width=a.width,this.texture.frame.height=a.height,this.texture.crop.x=a.x,this.texture.crop.y=a.y,this.texture.crop.width=a.width,this.texture.crop.height=a.height,a.trimmed?(this.texture.trim?(this.texture.trim.x=a.spriteSourceSizeX,this.texture.trim.y=a.spriteSourceSizeY,this.texture.trim.width=a.sourceSizeW,this.texture.trim.height=a.sourceSizeH):this.texture.trim={x:a.spriteSourceSizeX,y:a.spriteSourceSizeY,width:a.sourceSizeW,height:a.sourceSizeH},this.texture.width=a.sourceSizeW,this.texture.height=a.sourceSizeH,this.texture.frame.width=a.sourceSizeW,this.texture.frame.height=a.sourceSizeH):!a.trimmed&&this.texture.trim&&(this.texture.trim=null),this.cropRect&&this.updateCrop(),this.texture.requiresReTint=!0,this.texture._updateUvs(),this.tilingTexture&&(this.refreshTexture=!0)},resizeFrame:function(a,b,c){this.texture.frame.resize(b,c),this.texture.setFrame(this.texture.frame)},resetFrame:function(){this._frame&&this.setFrame(this._frame)},frame:{get:function(){return this.animations.frame},set:function(a){this.animations.frame=a}},frameName:{get:function(){return this.animations.frameName},set:function(a){this.animations.frameName=a}}},c.Component.Overlap=function(){},c.Component.Overlap.prototype={overlap:function(a){return c.Rectangle.intersects(this.getBounds(),a.getBounds())}},c.Component.PhysicsBody=function(){},c.Component.PhysicsBody.preUpdate=function(){return this.fresh&&this.exists?(this.world.setTo(this.parent.position.x+this.position.x,this.parent.position.y+this.position.y),this.worldTransform.tx=this.world.x,this.worldTransform.ty=this.world.y,this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,this.body&&this.body.preUpdate(),this.fresh=!1):(this.previousPosition.set(this.world.x,this.world.y),this.previousRotation=this.rotation,!(!this._exists||!this.parent.exists)||!(this.renderOrderID=-1))},c.Component.PhysicsBody.postUpdate=function(){this.exists&&this.body&&this.body.postUpdate()},c.Component.PhysicsBody.prototype={body:null,x:{get:function(){return this.position.x},set:function(a){this.position.x=a,this.body&&!this.body.dirty&&(this.body._reset=!0)}},y:{get:function(){return this.position.y},set:function(a){this.position.y=a,this.body&&!this.body.dirty&&(this.body._reset=!0)}}},c.Component.Reset=function(){},c.Component.Reset.prototype.reset=function(a,b,c){return void 0===c&&(c=1),this.world.set(a,b),this.position.set(a,b),this.fresh=!0,this.exists=!0,this.visible=!0,this.renderable=!0,this.components.InWorld&&(this._outOfBoundsFired=!1),this.components.LifeSpan&&(this.alive=!0,this.health=c),this.components.PhysicsBody&&this.body&&this.body.reset(a,b,!1,!1),this},c.Component.ScaleMinMax=function(){},c.Component.ScaleMinMax.prototype={transformCallback:null,transformCallbackContext:this,scaleMin:null,scaleMax:null,checkTransform:function(a){this.scaleMin&&(a.a<this.scaleMin.x&&(a.a=this.scaleMin.x),a.d<this.scaleMin.y&&(a.d=this.scaleMin.y)),this.scaleMax&&(a.a>this.scaleMax.x&&(a.a=this.scaleMax.x),a.d>this.scaleMax.y&&(a.d=this.scaleMax.y))},setScaleMinMax:function(a,b,d,e){void 0===b?b=d=e=a:void 0===d&&(d=e=b,b=a),null===a?this.scaleMin=null:this.scaleMin?this.scaleMin.set(a,b):this.scaleMin=new c.Point(a,b),null===d?this.scaleMax=null:this.scaleMax?this.scaleMax.set(d,e):this.scaleMax=new c.Point(d,e),null===this.scaleMin?this.transformCallback=null:(this.transformCallback=this.checkTransform,this.transformCallbackContext=this)}},c.Component.Smoothed=function(){},c.Component.Smoothed.prototype={smoothed:{get:function(){return!this.texture.baseTexture.scaleMode},set:function(a){a?this.texture&&(this.texture.baseTexture.scaleMode=0):this.texture&&(this.texture.baseTexture.scaleMode=1)}}},c.GameObjectFactory=function(a){this.game=a,this.world=this.game.world},c.GameObjectFactory.prototype={existing:function(a){return this.world.add(a)},weapon:function(a,b,d,e){var f=this.game.plugins.add(c.Weapon);return f.createBullets(a,b,d,e),f},image:function(a,b,d,e,f){return void 0===f&&(f=this.world),f.add(new c.Image(this.game,a,b,d,e))},sprite:function(a,b,c,d,e){return void 0===e&&(e=this.world),e.create(a,b,c,d)},creature:function(a,b,d,e,f){void 0===f&&(f=this.world);var g=new c.Creature(this.game,a,b,d,e);return f.add(g),g},tween:function(a){return this.game.tweens.create(a)},group:function(a,b,d,e,f){return new c.Group(this.game,a,b,d,e,f)},physicsGroup:function(a,b,d,e){return new c.Group(this.game,b,d,e,!0,a)},spriteBatch:function(a,b,d){return void 0===a&&(a=null),void 0===b&&(b="group"),void 0===d&&(d=!1),new c.SpriteBatch(this.game,a,b,d)},audio:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},sound:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},audioSprite:function(a){return this.game.sound.addSprite(a)},tileSprite:function(a,b,d,e,f,g,h){return void 0===h&&(h=this.world),h.add(new c.TileSprite(this.game,a,b,d,e,f,g))},rope:function(a,b,d,e,f,g){return void 0===g&&(g=this.world),g.add(new c.Rope(this.game,a,b,d,e,f))},text:function(a,b,d,e,f){return void 0===f&&(f=this.world),f.add(new c.Text(this.game,a,b,d,e))},button:function(a,b,d,e,f,g,h,i,j,k){return void 0===k&&(k=this.world),k.add(new c.Button(this.game,a,b,d,e,f,g,h,i,j))},graphics:function(a,b,d){return void 0===d&&(d=this.world),d.add(new c.Graphics(this.game,a,b))},emitter:function(a,b,d){return this.game.particles.add(new c.Particles.Arcade.Emitter(this.game,a,b,d))},retroFont:function(a,b,d,e,f,g,h,i,j){return new c.RetroFont(this.game,a,b,d,e,f,g,h,i,j)},bitmapText:function(a,b,d,e,f,g){return void 0===g&&(g=this.world),g.add(new c.BitmapText(this.game,a,b,d,e,f))},tilemap:function(a,b,d,e,f){return new c.Tilemap(this.game,a,b,d,e,f)},renderTexture:function(a,b,d,e){void 0!==d&&""!==d||(d=this.game.rnd.uuid()),void 0===e&&(e=!1);var f=new c.RenderTexture(this.game,a,b,d);return e&&this.game.cache.addRenderTexture(d,f),f},video:function(a,b){return new c.Video(this.game,a,b)},bitmapData:function(a,b,d,e){void 0===e&&(e=!1),void 0!==d&&""!==d||(d=this.game.rnd.uuid());var f=new c.BitmapData(this.game,d,a,b);return e&&this.game.cache.addBitmapData(d,f),f},filter:function(a){var b=Array.prototype.slice.call(arguments,1);return(a=new c.Filter[a](this.game)).init.apply(a,b),a},plugin:function(a){return this.game.plugins.add(a)}},c.GameObjectFactory.prototype.constructor=c.GameObjectFactory,c.GameObjectCreator=function(a){this.game=a,this.world=this.game.world},c.GameObjectCreator.prototype={image:function(a,b,d,e){return new c.Image(this.game,a,b,d,e)},sprite:function(a,b,d,e){return new c.Sprite(this.game,a,b,d,e)},tween:function(a){return new c.Tween(a,this.game,this.game.tweens)},group:function(a,b,d,e,f){return new c.Group(this.game,a,b,d,e,f)},spriteBatch:function(a,b,d){return void 0===b&&(b="group"),void 0===d&&(d=!1),new c.SpriteBatch(this.game,a,b,d)},audio:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},audioSprite:function(a){return this.game.sound.addSprite(a)},sound:function(a,b,c,d){return this.game.sound.add(a,b,c,d)},tileSprite:function(a,b,d,e,f,g){return new c.TileSprite(this.game,a,b,d,e,f,g)},rope:function(a,b,d,e,f){return new c.Rope(this.game,a,b,d,e,f)},text:function(a,b,d,e){return new c.Text(this.game,a,b,d,e)},button:function(a,b,d,e,f,g,h,i,j){return new c.Button(this.game,a,b,d,e,f,g,h,i,j)},graphics:function(a,b){return new c.Graphics(this.game,a,b)},emitter:function(a,b,d){return new c.Particles.Arcade.Emitter(this.game,a,b,d)},retroFont:function(a,b,d,e,f,g,h,i,j){return new c.RetroFont(this.game,a,b,d,e,f,g,h,i,j)},bitmapText:function(a,b,d,e,f,g){return new c.BitmapText(this.game,a,b,d,e,f,g)},tilemap:function(a,b,d,e,f){return new c.Tilemap(this.game,a,b,d,e,f)},renderTexture:function(a,b,d,e){void 0!==d&&""!==d||(d=this.game.rnd.uuid()),void 0===e&&(e=!1);var f=new c.RenderTexture(this.game,a,b,d);return e&&this.game.cache.addRenderTexture(d,f),f},bitmapData:function(a,b,d,e){void 0===e&&(e=!1),void 0!==d&&""!==d||(d=this.game.rnd.uuid());var f=new c.BitmapData(this.game,d,a,b);return e&&this.game.cache.addBitmapData(d,f),f},filter:function(a){var b=Array.prototype.slice.call(arguments,1);return(a=new c.Filter[a](this.game)).init.apply(a,b),a}},c.GameObjectCreator.prototype.constructor=c.GameObjectCreator,c.Sprite=function(a,b,d,e,f){b=b||0,d=d||0,e=e||null,f=f||null,this.type=c.SPRITE,this.physicsType=c.SPRITE,PIXI.Sprite.call(this,c.Cache.DEFAULT),c.Component.Core.init.call(this,a,b,d,e,f)},c.Sprite.prototype=Object.create(PIXI.Sprite.prototype),c.Sprite.prototype.constructor=c.Sprite,c.Component.Core.install.call(c.Sprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),c.Sprite.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.Sprite.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.Sprite.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Sprite.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Sprite.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},c.Image=function(a,b,d,e,f){b=b||0,d=d||0,e=e||null,f=f||null,this.type=c.IMAGE,PIXI.Sprite.call(this,c.Cache.DEFAULT),c.Component.Core.init.call(this,a,b,d,e,f)},c.Image.prototype=Object.create(PIXI.Sprite.prototype),c.Image.prototype.constructor=c.Image,c.Component.Core.install.call(c.Image.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Destroy","FixedToCamera","InputEnabled","LifeSpan","LoadTexture","Overlap","Reset","ScaleMinMax","Smoothed"]),c.Image.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Image.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Image.prototype.preUpdate=function(){return!!this.preUpdateInWorld()&&this.preUpdateCore()},c.Button=function(a,b,d,e,f,g,h,i,j,k){b=b||0,d=d||0,e=e||null,f=f||null,g=g||this,c.Image.call(this,a,b,d,e,i),this.type=c.BUTTON,this.physicsType=c.SPRITE,this._onOverFrame=null,this._onOutFrame=null,this._onDownFrame=null,this._onUpFrame=null,this.onOverSound=null,this.onOutSound=null,this.onDownSound=null,this.onUpSound=null,this.onOverSoundMarker="",this.onOutSoundMarker="",this.onDownSoundMarker="",this.onUpSoundMarker="",this.onInputOver=new c.Signal,this.onInputOut=new c.Signal,this.onInputDown=new c.Signal,this.onInputUp=new c.Signal,this.onOverMouseOnly=!0,this.justReleasedPreventsOver=c.PointerMode.TOUCH,this.freezeFrames=!1,this.forceOut=!1,this.inputEnabled=!0,this.input.start(0,!0),this.input.useHandCursor=!0,this.setFrames(h,i,j,k),null!==f&&this.onInputUp.add(f,g),this.events.onInputOver.add(this.onInputOverHandler,this),this.events.onInputOut.add(this.onInputOutHandler,this),this.events.onInputDown.add(this.onInputDownHandler,this),this.events.onInputUp.add(this.onInputUpHandler,this),this.events.onRemovedFromWorld.add(this.removedFromWorld,this)},c.Button.prototype=Object.create(c.Image.prototype),c.Button.prototype.constructor=c.Button;var g="Over",h="Out",i="Down",j="Up";c.Button.prototype.clearFrames=function(){this.setFrames(null,null,null,null)},c.Button.prototype.removedFromWorld=function(){this.inputEnabled=!1},c.Button.prototype.setStateFrame=function(a,b,c){var d="_on"+a+"Frame";null!==b?(this[d]=b,c&&this.changeStateFrame(a)):this[d]=null},c.Button.prototype.changeStateFrame=function(a){if(this.freezeFrames)return!1;var c=this["_on"+a+"Frame"];return"string"==typeof c?(this.frameName=c,!0):"number"==typeof c&&(this.frame=c,!0)},c.Button.prototype.setFrames=function(a,b,c,d){this.setStateFrame(g,a,this.input.pointerOver()),this.setStateFrame(h,b,!this.input.pointerOver()),this.setStateFrame(i,c,this.input.pointerDown()),this.setStateFrame(j,d,this.input.pointerUp())},c.Button.prototype.setStateSound=function(a,b,d){var e="on"+a+"Sound",f="on"+a+"SoundMarker";b instanceof c.Sound||b instanceof c.AudioSprite?(this[e]=b,this[f]="string"==typeof d?d:""):(this[e]=null,this[f]="")},c.Button.prototype.playStateSound=function(a){var c=this["on"+a+"Sound"];if(c){var e=this["on"+a+"SoundMarker"];return c.play(e),!0}return!1},c.Button.prototype.setSounds=function(a,b,c,d,e,f,k,l){this.setStateSound(g,a,b),this.setStateSound(h,e,f),this.setStateSound(i,c,d),this.setStateSound(j,k,l)},c.Button.prototype.setOverSound=function(a,b){this.setStateSound(g,a,b)},c.Button.prototype.setOutSound=function(a,b){this.setStateSound(h,a,b)},c.Button.prototype.setDownSound=function(a,b){this.setStateSound(i,a,b)},c.Button.prototype.setUpSound=function(a,b){this.setStateSound(j,a,b)},c.Button.prototype.onInputOverHandler=function(a,b){b.justReleased()&&(this.justReleasedPreventsOver&b.pointerMode)===b.pointerMode||(this.changeStateFrame(g),this.onOverMouseOnly&&!b.isMouse||(this.playStateSound(g),this.onInputOver&&this.onInputOver.dispatch(this,b)))},c.Button.prototype.onInputOutHandler=function(a,b){this.changeStateFrame(h),this.playStateSound(h),this.onInputOut&&this.onInputOut.dispatch(this,b)},c.Button.prototype.onInputDownHandler=function(a,b){this.changeStateFrame(i),this.playStateSound(i),this.onInputDown&&this.onInputDown.dispatch(this,b)},c.Button.prototype.onInputUpHandler=function(a,b,c){if(this.playStateSound(j),this.onInputUp&&this.onInputUp.dispatch(this,b,c),!this.freezeFrames)if(!0===this.forceOut||(this.forceOut&b.pointerMode)===b.pointerMode)this.changeStateFrame(h);else{this.changeStateFrame(j)||(c?this.changeStateFrame(g):this.changeStateFrame(h))}},c.SpriteBatch=function(a,b,d,e){null!=b||(b=a.world),PIXI.SpriteBatch.call(this),c.Group.call(this,a,b,d,e),this.type=c.SPRITEBATCH},c.SpriteBatch.prototype=c.Utils.extend(!0,c.SpriteBatch.prototype,PIXI.SpriteBatch.prototype,c.Group.prototype),c.SpriteBatch.prototype.constructor=c.SpriteBatch,c.BitmapData=function(a,b,d,e,f){void 0!==d&&0!==d||(d=256),void 0!==e&&0!==e||(e=256),void 0===f&&(f=!1),this.game=a,this.key=b,this.width=d,this.height=e,this.canvas=c.Canvas.create(this,d,e,null,f),this.context=this.canvas.getContext("2d",{alpha:!0}),this.ctx=this.context,this.smoothProperty=a.renderType===c.CANVAS?a.renderer.renderSession.smoothProperty:c.Canvas.getSmoothingPrefix(this.context),this.imageData=this.context.getImageData(0,0,d,e),this.data=null,this.imageData&&(this.data=this.imageData.data),this.pixels=null,this.data&&(this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data),this.baseTexture=new PIXI.BaseTexture(this.canvas),this.texture=new PIXI.Texture(this.baseTexture),this.frameData=new c.FrameData,this.textureFrame=this.frameData.addFrame(new c.Frame(0,0,0,d,e,"bitmapData")),this.texture.frame=this.textureFrame,this.type=c.BITMAPDATA,this.disableTextureUpload=!1,this.dirty=!1,this.cls=this.clear,this._image=null,this._pos=new c.Point,this._size=new c.Point,this._scale=new c.Point,this._rotate=0,this._alpha={prev:1,current:1},this._anchor=new c.Point,this._tempR=0,this._tempG=0,this._tempB=0,this._circle=new c.Circle,this._swapCanvas=void 0},c.BitmapData.prototype={move:function(a,b,c){return 0!==a&&this.moveH(a,c),0!==b&&this.moveV(b,c),this},moveH:function(a,b){void 0===b&&(b=!0),void 0===this._swapCanvas&&(this._swapCanvas=PIXI.CanvasPool.create(this,this.width,this.height));var d=this._swapCanvas.getContext("2d"),e=this.height,f=this.canvas;if(d.clearRect(0,0,this.width,this.height),a<0){a=Math.abs(a);var g=this.width-a;b&&d.drawImage(f,0,0,a,e,g,0,a,e),d.drawImage(f,a,0,g,e,0,0,g,e)}else{g=this.width-a;b&&d.drawImage(f,g,0,a,e,0,0,a,e),d.drawImage(f,0,0,g,e,a,0,g,e)}return this.clear(),this.copy(this._swapCanvas)},moveV:function(a,b){void 0===b&&(b=!0),void 0===this._swapCanvas&&(this._swapCanvas=PIXI.CanvasPool.create(this,this.width,this.height));var d=this._swapCanvas.getContext("2d"),e=this.width,f=this.canvas;if(d.clearRect(0,0,this.width,this.height),a<0){a=Math.abs(a);var g=this.height-a;b&&d.drawImage(f,0,0,e,a,0,g,e,a),d.drawImage(f,0,a,e,g,0,0,e,g)}else{g=this.height-a;b&&d.drawImage(f,0,g,e,a,0,0,e,a),d.drawImage(f,0,0,e,g,0,a,e,g)}return this.clear(),this.copy(this._swapCanvas)},add:function(a){if(Array.isArray(a))for(var b=0;b<a.length;b++)a[b].loadTexture&&a[b].loadTexture(this);else a.loadTexture(this);return this},load:function(a){if("string"==typeof a&&(a=this.game.cache.getImage(a)),a)return this.resize(a.width,a.height),this.cls(),this.draw(a),this.update(),this},clear:function(a,b,c,d){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=this.width),void 0===d&&(d=this.height),this.context.clearRect(a,b,c,d),this.dirty=!0,this},fill:function(a,b,c,d){return void 0===d&&(d=1),this.context.fillStyle="rgba("+a+","+b+","+c+","+d+")",this.context.fillRect(0,0,this.width,this.height),this.dirty=!0,this},generateTexture:function(a){var b=new Image;b.src=this.canvas.toDataURL("image/png");var c=this.game.cache.addImage(a,"",b);return new PIXI.Texture(c.base)},resize:function(a,b){return a===this.width&&b===this.height||(this.width=a,this.height=b,this.canvas.width=a,this.canvas.height=b,void 0!==this._swapCanvas&&(this._swapCanvas.width=a,this._swapCanvas.height=b),this.baseTexture.width=a,this.baseTexture.height=b,this.textureFrame.width=a,this.textureFrame.height=b,this.texture.width=a,this.texture.height=b,this.texture.crop.width=a,this.texture.crop.height=b,this.update(),this.dirty=!0),this},update:function(a,b,c,d){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=Math.max(1,this.width)),void 0===d&&(d=Math.max(1,this.height)),this.imageData=this.context.getImageData(a,b,c,d),this.data=this.imageData.data,this.imageData.data.buffer?(this.buffer=this.imageData.data.buffer,this.pixels=new Uint32Array(this.buffer)):window.ArrayBuffer?(this.buffer=new ArrayBuffer(this.imageData.data.length),this.pixels=new Uint32Array(this.buffer)):this.pixels=this.imageData.data,this},processPixelRGB:function(a,b,d,e,f,g){void 0===d&&(d=0),void 0===e&&(e=0),void 0===f&&(f=this.width),void 0===g&&(g=this.height);for(var h=d+f,i=e+g,j=c.Color.createColor(),k={r:0,g:0,b:0,a:0},l=!1,m=e;m<i;m++)for(var n=d;n<h;n++)c.Color.unpackPixel(this.getPixel32(n,m),j),!1!==(k=a.call(b,j,n,m))&&null!=k&&(this.setPixel32(n,m,k.r,k.g,k.b,k.a,!1),l=!0);return l&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},processPixel: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=c+e,h=d+f,i=0,j=0,k=!1,l=d;l<h;l++)for(var m=c;m<g;m++)i=this.getPixel32(m,l),(j=a.call(b,i,m,l))!==i&&(this.pixels[l*this.width+m]=j,k=!0);return k&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0),this},replaceRGB:function(a,b,d,e,f,g,h,i,j){var k=0,l=0,m=this.width,n=this.height,o=c.Color.packPixel(a,b,d,e);void 0!==j&&j instanceof c.Rectangle&&(k=j.x,l=j.y,m=j.width,n=j.height);for(var p=0;p<n;p++)for(var q=0;q<m;q++)this.getPixel32(k+q,l+p)===o&&this.setPixel32(k+q,l+p,f,g,h,i,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this},setHSL:function(a,b,d,e){var f=a||0===a,g=b||0===b,h=d||0===d;if(f||g||h){void 0===e&&(e=new c.Rectangle(0,0,this.width,this.height));for(var i=c.Color.createColor(),j=e.y;j<e.bottom;j++)for(var k=e.x;k<e.right;k++)c.Color.unpackPixel(this.getPixel32(k,j),i,!0),f&&(i.h=a),g&&(i.s=b),h&&(i.l=d),c.Color.HSLtoRGB(i.h,i.s,i.l,i),this.setPixel32(k,j,i.r,i.g,i.b,i.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},shiftHSL:function(a,b,d,e){if(null!=a||(a=!1),null!=b||(b=!1),null!=d||(d=!1),a||b||d){void 0===e&&(e=new c.Rectangle(0,0,this.width,this.height));for(var f=c.Color.createColor(),g=e.y;g<e.bottom;g++)for(var h=e.x;h<e.right;h++)c.Color.unpackPixel(this.getPixel32(h,g),f,!0),a&&(f.h=this.game.math.wrap(f.h+a,0,1)),b&&(f.s=this.game.math.clamp(f.s+b,0,1)),d&&(f.l=this.game.math.clamp(f.l+d,0,1)),c.Color.HSLtoRGB(f.h,f.s,f.l,f),this.setPixel32(h,g,f.r,f.g,f.b,f.a,!1);return this.context.putImageData(this.imageData,0,0),this.dirty=!0,this}},setPixel32:function(a,b,d,e,f,g,h){return void 0===h&&(h=!0),0<=a&&a<=this.width&&0<=b&&b<=this.height&&(c.Device.LITTLE_ENDIAN?this.pixels[b*this.width+a]=g<<24|f<<16|e<<8|d:this.pixels[b*this.width+a]=d<<24|e<<16|f<<8|g,h&&(this.context.putImageData(this.imageData,0,0),this.dirty=!0)),this},setPixel:function(a,b,c,d,e,f){return this.setPixel32(a,b,c,d,e,255,f)},getPixel:function(a,b,d){d||(d=c.Color.createColor());var e=~~(a+b*this.width);return e*=4,d.r=this.data[e],d.g=this.data[++e],d.b=this.data[++e],d.a=this.data[++e],d},getPixel32:function(a,b){if(0<=a&&a<=this.width&&0<=b&&b<=this.height)return this.pixels[b*this.width+a]},getPixelRGB:function(a,b,d,e,f){return c.Color.unpackPixel(this.getPixel32(a,b),d,e,f)},getPixels:function(a){return this.context.getImageData(a.x,a.y,a.width,a.height)},getFirstPixel:function(a){void 0===a&&(a=0);var b=c.Color.createColor(),d=0,e=0,f=1,g=!1;for(1===a?(f=-1,e=this.height):3===a&&(f=-1,d=this.width);c.Color.unpackPixel(this.getPixel32(d,e),b),0===a||1===a?++d===this.width&&(d=0,((e+=f)>=this.height||e<=0)&&(g=!0)):2!==a&&3!==a||++e===this.height&&(e=0,((d+=f)>=this.width||d<=0)&&(g=!0)),0===b.a&&!g;);return b.x=d,b.y=e,b},getBounds:function(a){return void 0===a&&(a=new c.Rectangle),a.x=this.getFirstPixel(2).x,a.x===this.width?a.setTo(0,0,0,0):(a.y=this.getFirstPixel(0).y,a.width=this.getFirstPixel(3).x-a.x+1,a.height=this.getFirstPixel(1).y-a.y+1,a)},addToWorld:function(a,b,c,d,e,f){e=e||1,f=f||1;var g=this.game.add.image(a,b,this);return g.anchor.set(c,d),g.scale.set(e,f),g},copy:function(a,b,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r){if(null!=a||(a=this),(a instanceof c.RenderTexture||a instanceof PIXI.RenderTexture)&&(a=a.getCanvas()),(this._image=a)instanceof c.Sprite||a instanceof c.Image||a instanceof c.Text||a instanceof PIXI.Sprite)this._pos.set(a.texture.crop.x,a.texture.crop.y),this._size.set(a.texture.crop.width,a.texture.crop.height),this._scale.set(a.scale.x,a.scale.y),this._anchor.set(a.anchor.x,a.anchor.y),this._rotate=a.rotation,this._alpha.current=a.alpha,a.texture instanceof c.RenderTexture||a.texture instanceof PIXI.RenderTexture?this._image=a.texture.getCanvas():this._image=a.texture.baseTexture.source,null!=g||(g=a.x),null!=h||(h=a.y),a.texture.trim&&(g+=a.texture.trim.x-a.anchor.x*a.texture.trim.width,h+=a.texture.trim.y-a.anchor.y*a.texture.trim.height),16777215!==a.tint&&(a.cachedTint!==a.tint&&(a.cachedTint=a.tint,a.tintedTexture=PIXI.CanvasTinter.getTintedTexture(a,a.tint)),this._image=a.tintedTexture,this._pos.set(0));else{if(this._pos.set(0),this._scale.set(1),this._anchor.set(0),this._rotate=0,this._alpha.current=1,a instanceof c.BitmapData)this._image=a.canvas;else if("string"==typeof a){if(null===(a=this.game.cache.getImage(a)))return;this._image=a}this._size.set(this._image.width,this._image.height)}if(null!=b||(b=0),null!=d||(d=0),e&&(this._size.x=e),f&&(this._size.y=f),null!=g||(g=b),null!=h||(h=d),null!=i||(i=this._size.x),null!=j||(j=this._size.y),"number"==typeof k&&(this._rotate=k),"number"==typeof l&&(this._anchor.x=l),"number"==typeof m&&(this._anchor.y=m),"number"==typeof n&&(this._scale.x=n),"number"==typeof o&&(this._scale.y=o),"number"==typeof p&&(this._alpha.current=p),void 0===q&&(q=null),void 0===r&&(r=!1),!(this._alpha.current<=0||0===this._scale.x||0===this._scale.y||0===this._size.x||0===this._size.y)){var s=this.context;return this._alpha.prev=s.globalAlpha,s.save(),s.globalAlpha=this._alpha.current,q&&(this.op=q),r&&(g|=0,h|=0),s.translate(g,h),s.scale(this._scale.x,this._scale.y),s.rotate(this._rotate),s.drawImage(this._image,this._pos.x+b,this._pos.y+d,this._size.x,this._size.y,-i*this._anchor.x,-j*this._anchor.y,i,j),s.restore(),s.globalAlpha=this._alpha.prev,this.dirty=!0,this}},copyTransform:function(a,b,d){if(void 0===b&&(b=null),void 0===d&&(d=!1),!a.hasOwnProperty("worldTransform")||!a.worldVisible||0===a.worldAlpha)return this;var e=a.worldTransform;if(this._pos.set(a.texture.crop.x,a.texture.crop.y),this._size.set(a.texture.crop.width,a.texture.crop.height),0===e.a||0===e.d||0===this._size.x||0===this._size.y)return this;a.texture instanceof c.RenderTexture||a.texture instanceof PIXI.RenderTexture?this._image=a.texture.getCanvas():this._image=a.texture.baseTexture.source;var f=e.tx,g=e.ty;a.texture.trim&&(f+=a.texture.trim.x-a.anchor.x*a.texture.trim.width,g+=a.texture.trim.y-a.anchor.y*a.texture.trim.height),16777215!==a.tint&&(a.cachedTint!==a.tint&&(a.cachedTint=a.tint,a.tintedTexture=PIXI.CanvasTinter.getTintedTexture(a,a.tint)),this._image=a.tintedTexture,this._pos.set(0)),d&&(f|=0,g|=0);var h=this.context;return this._alpha.prev=h.globalAlpha,h.save(),h.globalAlpha=this._alpha.current,b&&(this.op=b),h[this.smoothProperty]=a.texture.baseTexture.scaleMode===PIXI.scaleModes.LINEAR,h.setTransform(e.a,e.b,e.c,e.d,f,g),h.drawImage(this._image,this._pos.x,this._pos.y,this._size.x,this._size.y,-this._size.x*a.anchor.x,-this._size.y*a.anchor.y,this._size.x,this._size.y),h.restore(),h.globalAlpha=this._alpha.prev,this.dirty=!0,this},copyRect:function(a,b,c,d,e,f,g){return this.copy(a,b.x,b.y,b.width,b.height,c,d,b.width,b.height,0,0,0,1,1,e,f,g)},draw:function(a,b,c,d,e,f,g){return this.copy(a,null,null,null,null,b,c,d,e,null,null,null,null,null,null,f,g)},drawGroup:function(a,b,c){return 0<a.total&&a.forEachExists(this.drawGroupProxy,this,b,c),this},drawGroupProxy:function(a,b,d){if(a.hasOwnProperty("texture")&&this.copyTransform(a,b,d),a.type===c.GROUP&&a.exists)this.drawGroup(a,b,d);else if(a.hasOwnProperty("children")&&0<a.children.length)for(var e=0;e<a.children.length;e++)a.children[e].exists&&this.copyTransform(a.children[e],b,d)},drawFull:function(a,b,d){if(!1===a.worldVisible||0===a.worldAlpha||a.hasOwnProperty("exists")&&!1===a.exists)return this;if(a.type!==c.GROUP&&a.type!==c.EMITTER&&a.type!==c.BITMAPTEXT)if(a.type===c.GRAPHICS){var e=a.getBounds();this.ctx.save(),this.ctx.translate(e.x,e.y),PIXI.CanvasGraphics.renderGraphics(a,this.ctx),this.ctx.restore()}else this.copy(a,null,null,null,null,a.worldPosition.x,a.worldPosition.y,null,null,a.worldRotation,null,null,a.worldScale.x,a.worldScale.y,a.worldAlpha,b,d);if(a.children)for(var f=0;f<a.children.length;f++)this.drawFull(a.children[f],b,d);return this},shadow:function(a,b,c,d){var e=this.context;return null==a?e.shadowColor="rgba(0,0,0,0)":(e.shadowColor=a,e.shadowBlur=b||5,e.shadowOffsetX=c||10,e.shadowOffsetY=d||10),this},alphaMask:function(a,b,c,d){return null==d?this.draw(b).blendSourceAtop():this.draw(b,d.x,d.y,d.width,d.height).blendSourceAtop(),null==c?this.draw(a).blendReset():this.draw(a,c.x,c.y,c.width,c.height).blendReset(),this},extract:function(a,b,c,d,e,f,g,h,i){return void 0===e&&(e=255),void 0===f&&(f=!1),void 0===g&&(g=b),void 0===h&&(h=c),void 0===i&&(i=d),f&&a.resize(this.width,this.height),this.processPixelRGB(function(f,j,k){return f.r===b&&f.g===c&&f.b===d&&a.setPixel32(j,k,g,h,i,e,!1),!1},this),a.context.putImageData(a.imageData,0,0),a.dirty=!0,a},rect:function(a,b,c,d,e){return void 0!==e&&(this.context.fillStyle=e),this.context.fillRect(a,b,c,d),this},text:function(a,b,c,d,e,f){void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d="14px Courier"),void 0===e&&(e="rgb(255,255,255)"),void 0===f&&(f=!0);var g=this.context,h=g.font;return g.font=d,f&&(g.fillStyle="rgb(0,0,0)",g.fillText(a,b+1,c+1)),g.fillStyle=e,g.fillText(a,b,c),g.font=h,this},circle:function(a,b,c,d){var e=this.context;return void 0!==d&&(e.fillStyle=d),e.beginPath(),e.arc(a,b,c,0,2*Math.PI,!1),e.closePath(),e.fill(),this},line:function(a,b,c,d,e,f){void 0===e&&(e="#fff"),void 0===f&&(f=1);var g=this.context;return g.beginPath(),g.moveTo(a,b),g.lineTo(c,d),g.lineWidth=f,g.strokeStyle=e,g.stroke(),g.closePath(),this},textureLine:function(a,b,d){if(void 0===d&&(d="repeat-x"),"string"!=typeof b||(b=this.game.cache.getImage(b))){var e=a.length;"no-repeat"===d&&e>b.width&&(e=b.width);var f=this.context;return f.fillStyle=f.createPattern(b,d),this._circle=new c.Circle(a.start.x,a.start.y,b.height),this._circle.circumferencePoint(a.angle-1.5707963267948966,!1,this._pos),f.save(),f.translate(this._pos.x,this._pos.y),f.rotate(a.angle),f.fillRect(0,0,e,b.height),f.restore(),this.dirty=!0,this}},render:function(){return!this.disableTextureUpload&&this.dirty&&(this.baseTexture.dirty(),this.dirty=!1),this},destroy:function(){this.frameData.destroy(),this.texture.destroy(!0),PIXI.CanvasPool.remove(this)},blendReset:function(){return this.op="source-over",this},blendSourceOver:function(){return this.op="source-over",this},blendSourceIn:function(){return this.op="source-in",this},blendSourceOut:function(){return this.op="source-out",this},blendSourceAtop:function(){return this.op="source-atop",this},blendDestinationOver:function(){return this.op="destination-over",this},blendDestinationIn:function(){return this.op="destination-in",this},blendDestinationOut:function(){return this.op="destination-out",this},blendDestinationAtop:function(){return this.op="destination-atop",this},blendXor:function(){return this.op="xor",this},blendAdd:function(){return this.op="lighter",this},blendMultiply:function(){return this.op="multiply",this},blendScreen:function(){return this.op="screen",this},blendOverlay:function(){return this.op="overlay",this},blendDarken:function(){return this.op="darken",this},blendLighten:function(){return this.op="lighten",this},blendColorDodge:function(){return this.op="color-dodge",this},blendColorBurn:function(){return this.op="color-burn",this},blendHardLight:function(){return this.op="hard-light",this},blendSoftLight:function(){return this.op="soft-light",this},blendDifference:function(){return this.op="difference",this},blendExclusion:function(){return this.op="exclusion",this},blendHue:function(){return this.op="hue",this},blendSaturation:function(){return this.op="saturation",this},blendColor:function(){return this.op="color",this},blendLuminosity:function(){return this.op="luminosity",this}},Object.defineProperty(c.BitmapData.prototype,"smoothed",{get:function(){c.Canvas.getSmoothingEnabled(this.context)},set:function(a){c.Canvas.setSmoothingEnabled(this.context,a)}}),Object.defineProperty(c.BitmapData.prototype,"op",{get:function(){return this.context.globalCompositeOperation},set:function(a){this.context.globalCompositeOperation=a}}),c.BitmapData.getTransform=function(a,b,c,d,e,f){return"number"!=typeof a&&(a=0),"number"!=typeof b&&(b=0),"number"!=typeof c&&(c=1),"number"!=typeof d&&(d=1),"number"!=typeof e&&(e=0),"number"!=typeof f&&(f=0),{sx:c,sy:d,scaleX:c,scaleY:d,skewX:e,skewY:f,translateX:a,translateY:b,tx:a,ty:b}},c.BitmapData.prototype.constructor=c.BitmapData,PIXI.Graphics=function(){PIXI.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor=0,this.graphicsData=[],this.tint=16777215,this.blendMode=PIXI.blendModes.NORMAL,this.currentPath=null,this._webGL=[],this.isMask=!1,this.boundsPadding=0,this._localBounds=new PIXI.Rectangle(0,0,1,1),this.dirty=!0,this._boundsDirty=!1,this.webGLDirty=!1,this.cachedSpriteDirty=!1},PIXI.Graphics.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),PIXI.Graphics.prototype.constructor=PIXI.Graphics,PIXI.Graphics.prototype.lineStyle=function(a,b,c){return this.lineWidth=a||0,this.lineColor=b||0,this.lineAlpha=void 0===c?1:c,this.currentPath&&(this.currentPath.shape.points.length?this.drawShape(new PIXI.Polygon(this.currentPath.shape.points.slice(-2))):(this.currentPath.lineWidth=this.lineWidth,this.currentPath.lineColor=this.lineColor,this.currentPath.lineAlpha=this.lineAlpha)),this},PIXI.Graphics.prototype.moveTo=function(a,b){return this.drawShape(new PIXI.Polygon([a,b])),this},PIXI.Graphics.prototype.lineTo=function(a,b){return this.currentPath||this.moveTo(0,0),this.currentPath.shape.points.push(a,b),this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.quadraticCurveTo=function(a,b,c,d){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);var e,f,h=this.currentPath.shape.points;0===h.length&&this.moveTo(0,0);for(var i=h[h.length-2],j=h[h.length-1],k=0,l=1;l<=20;++l)e=i+(a-i)*(k=l/20),f=j+(b-j)*k,h.push(e+(a+(c-a)*k-e)*k,f+(b+(d-b)*k-f)*k);return this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.bezierCurveTo=function(a,b,c,d,e,f){this.currentPath?0===this.currentPath.shape.points.length&&(this.currentPath.shape.points=[0,0]):this.moveTo(0,0);for(var g,h,i,j,k,m=this.currentPath.shape.points,n=m[m.length-2],o=m[m.length-1],p=0,q=1;q<=20;++q)i=(h=(g=1-(p=q/20))*g)*g,k=(j=p*p)*p,m.push(i*n+3*h*p*a+3*g*j*c+k*e,i*o+3*h*p*b+3*g*j*d+k*f);return this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.arcTo=function(a,b,c,d,e){this.currentPath?0===this.currentPath.shape.points.length&&this.currentPath.shape.points.push(a,b):this.moveTo(a,b);var f=this.currentPath.shape.points,g=f[f.length-2],i=f[f.length-1]-b,j=g-a,k=d-b,l=c-a,m=Math.abs(i*l-j*k);if(m<1e-8||0===e)f[f.length-2]===a&&f[f.length-1]===b||f.push(a,b);else{var n=i*i+j*j,o=k*k+l*l,p=i*k+j*l,q=e*Math.sqrt(n)/m,r=e*Math.sqrt(o)/m,s=q*p/n,t=r*p/o,u=q*l+r*j,v=q*k+r*i,w=j*(r+s),x=i*(r+s),y=l*(q+t),z=k*(q+t),A=Math.atan2(x-v,w-u),B=Math.atan2(z-v,y-u);this.arc(u+a,v+b,e,A,B,l*i<j*k)}return this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.arc=function(a,b,c,d,e,f,g){if(d===e)return this;void 0===f&&(f=!1),void 0===g&&(g=40),!f&&e<=d?e+=2*Math.PI:f&&d<=e&&(d+=2*Math.PI);var h=f?-1*(d-e):e-d,i=Math.ceil(Math.abs(h)/(2*Math.PI))*g;if(0===h)return this;var j=a+Math.cos(d)*c,k=b+Math.sin(d)*c;f&&this.filling?this.moveTo(a,b):this.moveTo(j,k);for(var l=this.currentPath.shape.points,m=h/(2*i),n=2*m,o=Math.cos(m),p=Math.sin(m),q=i-1,r=q%1/q,s=0;s<=q;s++){var u=m+d+n*(s+r*s),v=Math.cos(u),w=-Math.sin(u);l.push((o*v+p*w)*c+a,(o*-w+p*v)*c+b)}return this.dirty=!0,this._boundsDirty=!0,this},PIXI.Graphics.prototype.beginFill=function(a,b){return this.filling=!0,this.fillColor=a||0,this.fillAlpha=void 0===b?1:b,this.currentPath&&this.currentPath.shape.points.length<=2&&(this.currentPath.fill=this.filling,this.currentPath.fillColor=this.fillColor,this.currentPath.fillAlpha=this.fillAlpha),this},PIXI.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},PIXI.Graphics.prototype.drawRect=function(a,b,c,d){return this.drawShape(new PIXI.Rectangle(a,b,c,d)),this},PIXI.Graphics.prototype.drawRoundedRect=function(a,b,c,d,e){return this.drawShape(new PIXI.RoundedRectangle(a,b,c,d,e)),this},PIXI.Graphics.prototype.drawCircle=function(a,b,c){return this.drawShape(new PIXI.Circle(a,b,c)),this},PIXI.Graphics.prototype.drawEllipse=function(a,b,c,d){return this.drawShape(new PIXI.Ellipse(a,b,c,d)),this},PIXI.Graphics.prototype.drawPolygon=function(a){(a instanceof c.Polygon||a instanceof PIXI.Polygon)&&(a=a.points);var b=a;if(!Array.isArray(b)){b=new Array(arguments.length);for(var d=0;d<b.length;++d)b[d]=arguments[d]}return this.drawShape(new c.Polygon(b)),this},PIXI.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this._boundsDirty=!0,this.clearDirty=!0,this.graphicsData=[],this.updateLocalBounds(),this},PIXI.Graphics.prototype.generateTexture=function(a,b,c){void 0===a&&(a=1),void 0===b&&(b=PIXI.scaleModes.DEFAULT),void 0===c&&(c=0);var d=this.getBounds();d.width+=c,d.height+=c;var e=new PIXI.CanvasBuffer(d.width*a,d.height*a),f=PIXI.Texture.fromCanvas(e.canvas,b);return f.baseTexture.resolution=a,e.context.scale(a,a),e.context.translate(-d.x,-d.y),PIXI.CanvasGraphics.renderGraphics(this,e.context),f},PIXI.Graphics.prototype._renderWebGL=function(a){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.worldAlpha=this.worldAlpha,void PIXI.Sprite.prototype._renderWebGL.call(this._cachedSprite,a);if(a.spriteBatch.stop(),a.blendModeManager.setBlendMode(this.blendMode),this._mask&&a.maskManager.pushMask(this._mask,a),this._filters&&a.filterManager.pushFilter(this._filterBlock),this.blendMode!==a.spriteBatch.currentBlendMode){a.spriteBatch.currentBlendMode=this.blendMode;var b=PIXI.blendModesWebGL[a.spriteBatch.currentBlendMode];a.spriteBatch.gl.blendFunc(b[0],b[1])}if(this.webGLDirty&&(this.dirty=!0,this.webGLDirty=!1),PIXI.WebGLGraphics.renderGraphics(this,a),this.children.length){a.spriteBatch.start();for(var c=0;c<this.children.length;c++)this.children[c]._renderWebGL(a);a.spriteBatch.stop()}this._filters&&a.filterManager.popFilter(),this._mask&&a.maskManager.popMask(this.mask,a),a.drawCount++,a.spriteBatch.start()}},PIXI.Graphics.prototype._renderCanvas=function(a){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._prevTint!==this.tint&&(this.dirty=!0,this._prevTint=this.tint),this._cacheAsBitmap)return(this.dirty||this.cachedSpriteDirty)&&(this._generateCachedSprite(),this.updateCachedSpriteTexture(),this.cachedSpriteDirty=!1,this.dirty=!1),this._cachedSprite.alpha=this.alpha,void PIXI.Sprite.prototype._renderCanvas.call(this._cachedSprite,a);var b=a.context,c=this.worldTransform;this.blendMode!==a.currentBlendMode&&(a.currentBlendMode=this.blendMode,b.globalCompositeOperation=PIXI.blendModesCanvas[a.currentBlendMode]),this._mask&&a.maskManager.pushMask(this._mask,a);var d=a.resolution,e=c.tx*a.resolution+a.shakeX,f=c.ty*a.resolution+a.shakeY;b.setTransform(c.a*d,c.b*d,c.c*d,c.d*d,e,f),PIXI.CanvasGraphics.renderGraphics(this,b);for(var g=0;g<this.children.length;g++)this.children[g]._renderCanvas(a);this._mask&&a.maskManager.popMask(a)}},PIXI.Graphics.prototype.getBounds=function(a){if(!this._currentBounds){if(!this.renderable)return PIXI.EmptyRectangle;this.dirty&&(this.updateLocalBounds(),this.webGLDirty=!0,this.cachedSpriteDirty=!0,this.dirty=!1);var b=this._localBounds,c=b.x,d=b.width+b.x,e=b.y,f=b.height+b.y,g=a||this.worldTransform,h=g.a,i=g.b,j=g.c,k=g.d,l=g.tx,m=g.ty,n=h*d+j*f+l,o=k*f+i*d+m,p=h*c+j*f+l,q=k*f+i*c+m,r=h*c+j*e+l,s=k*e+i*c+m,t=h*d+j*e+l,u=k*e+i*d+m,v=n,w=o,x=n,y=o;x=t<(x=r<(x=p<x?p:x)?r:x)?t:x,y=u<(y=s<(y=q<y?q:y)?s:y)?u:y,v=(v=(v=v<p?p:v)<r?r:v)<t?t:v,w=(w=(w=w<q?q:w)<s?s:w)<u?u:w,this._bounds.x=x,this._bounds.width=v-x,this._bounds.y=y,this._bounds.height=w-y,this._currentBounds=this._bounds}return this._currentBounds},PIXI.Graphics.prototype.getLocalBounds=function(){var a=this.worldTransform;this.worldTransform=PIXI.identityMatrix;for(var b=0;b<this.children.length;b++)this.children[b].updateTransform();var c=this.getBounds();for(this.worldTransform=a,b=0;b<this.children.length;b++)this.children[b].updateTransform();return c},PIXI.Graphics.prototype.containsPoint=function(a){this.worldTransform.applyInverse(a,tempPoint);for(var b=this.graphicsData,c=0;c<b.length;c++){var d=b[c];if(d.fill&&d.shape&&d.shape.contains(tempPoint.x,tempPoint.y))return!0}return!1},PIXI.Graphics.prototype.updateLocalBounds=function(){var a=1/0,b=-1/0,d=1/0,e=-1/0;if(this.graphicsData.length)for(var f,g,h,i,j,k,l=0;l<this.graphicsData.length;l++){var m=this.graphicsData[l],n=m.type,o=m.lineWidth;if(f=m.shape,n===PIXI.Graphics.RECT||n===PIXI.Graphics.RREC)h=f.x-o/2,i=f.y-o/2,a=h<a?h:a,b=b<h+(j=f.width+o)?h+j:b,d=i<d?i:d,e=e<i+(k=f.height+o)?i+k:e;else if(n===PIXI.Graphics.CIRC)h=f.x,i=f.y,a=h-(j=f.radius+o/2)<a?h-j:a,b=b<h+j?h+j:b,d=i-(k=f.radius+o/2)<d?i-k:d,e=e<i+k?i+k:e;else if(n===PIXI.Graphics.ELIP)h=f.x,i=f.y,a=h-(j=f.width+o/2)<a?h-j:a,b=b<h+j?h+j:b,d=i-(k=f.height+o/2)<d?i-k:d,e=e<i+k?i+k:e;else{g=f.points;for(var p=0;p<g.length;p++)g[p]instanceof c.Point?(h=g[p].x,i=g[p].y):(h=g[p],i=g[p+1],p<g.length-1&&p++),a=h-o<a?h-o:a,b=b<h+o?h+o:b,d=i-o<d?i-o:d,e=e<i+o?i+o:e}}else e=d=b=a=0;var q=this.boundsPadding;this._localBounds.x=a-q,this._localBounds.width=b-a+2*q,this._localBounds.y=d-q,this._localBounds.height=e-d+2*q},PIXI.Graphics.prototype._generateCachedSprite=function(){var a=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(a.width,a.height);else{var b=new PIXI.CanvasBuffer(a.width,a.height),c=PIXI.Texture.fromCanvas(b.canvas);this._cachedSprite=new PIXI.Sprite(c),this._cachedSprite.buffer=b,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-a.x/a.width,this._cachedSprite.anchor.y=-a.y/a.height,this._cachedSprite.buffer.context.translate(-a.x,-a.y),this.worldAlpha=1,PIXI.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},PIXI.Graphics.prototype.updateCachedSpriteTexture=function(){var a=this._cachedSprite,b=a.texture,c=a.buffer.canvas;b.baseTexture.width=c.width,b.baseTexture.height=c.height,b.crop.width=b.frame.width=c.width,b.crop.height=b.frame.height=c.height,a._width=c.width,a._height=c.height,b.baseTexture.dirty()},PIXI.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},PIXI.Graphics.prototype.drawShape=function(a){this.currentPath&&this.currentPath.shape.points.length<=2&&this.graphicsData.pop(),this.currentPath=null,a instanceof c.Polygon&&(a=a.clone()).flatten();var b=new PIXI.GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.filling,a);return this.graphicsData.push(b),b.type===PIXI.Graphics.POLY&&(b.shape.closed=this.filling,this.currentPath=b),this.dirty=!0,this._boundsDirty=!0,b},Object.defineProperty(PIXI.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(a){this._cacheAsBitmap=a,this._cacheAsBitmap?this._generateCachedSprite():this.destroyCachedSprite(),this.dirty=!0,this.webGLDirty=!0}}),PIXI.GraphicsData=function(a,b,c,d,e,f,g){this.lineWidth=a,this.lineColor=b,this.lineAlpha=c,this._lineTint=b,this.fillColor=d,this.fillAlpha=e,this._fillTint=d,this.fill=f,this.shape=g,this.type=g.type},PIXI.GraphicsData.prototype.constructor=PIXI.GraphicsData,PIXI.GraphicsData.prototype.clone=function(){return new GraphicsData(this.lineWidth,this.lineColor,this.lineAlpha,this.fillColor,this.fillAlpha,this.fill,this.shape)},PIXI.EarCut={},PIXI.EarCut.Triangulate=function(a,b,c){c=c||2;var h,i,j,k,l,m,n,d=b&&b.length,e=d?b[0]*c:a.length,f=PIXI.EarCut.linkedList(a,0,e,c,!0),g=[];if(!f)return g;if(d&&(f=PIXI.EarCut.eliminateHoles(a,b,f,c)),a.length>80*c){h=j=a[0],i=k=a[1];for(var o=c;o<e;o+=c)(l=a[o])<h&&(h=l),(m=a[o+1])<i&&(i=m),j<l&&(j=l),k<m&&(k=m);n=Math.max(j-h,k-i)}return PIXI.EarCut.earcutLinked(f,g,c,h,i,n),g},PIXI.EarCut.linkedList=function(a,b,c,d,e){var f,g,h,i=0;for(f=b,g=c-d;f<c;f+=d)i+=(a[g]-a[f])*(a[f+1]+a[g+1]),g=f;if(e===0<i)for(f=b;f<c;f+=d)h=PIXI.EarCut.insertNode(f,a[f],a[f+1],h);else for(f=c-d;b<=f;f-=d)h=PIXI.EarCut.insertNode(f,a[f],a[f+1],h);return h},PIXI.EarCut.filterPoints=function(a,b){if(!a)return a;b||(b=a);var c,d=a;do{if(c=!1,d.steiner||!PIXI.EarCut.equals(d,d.next)&&0!==PIXI.EarCut.area(d.prev,d,d.next))d=d.next;else{if(PIXI.EarCut.removeNode(d),(d=b=d.prev)===d.next)return null;c=!0}}while(c||d!==b);return b},PIXI.EarCut.earcutLinked=function(a,b,c,d,e,f,g){if(a){!g&&f&&PIXI.EarCut.indexCurve(a,d,e,f);for(var h,i,j=a;a.prev!==a.next;)if(h=a.prev,i=a.next,f?PIXI.EarCut.isEarHashed(a,d,e,f):PIXI.EarCut.isEar(a))b.push(h.i/c),b.push(a.i/c),b.push(i.i/c),PIXI.EarCut.removeNode(a),a=i.next,j=i.next;else if((a=i)===j){g?1===g?(a=PIXI.EarCut.cureLocalIntersections(a,b,c),PIXI.EarCut.earcutLinked(a,b,c,d,e,f,2)):2===g&&PIXI.EarCut.splitEarcut(a,b,c,d,e,f):PIXI.EarCut.earcutLinked(PIXI.EarCut.filterPoints(a),b,c,d,e,f,1);break}}},PIXI.EarCut.isEar=function(a){var b=a.prev,c=a,d=a.next;if(0<=PIXI.EarCut.area(b,c,d))return!1;for(var e=a.next.next;e!==a.prev;){if(PIXI.EarCut.pointInTriangle(b.x,b.y,c.x,c.y,d.x,d.y,e.x,e.y)&&0<=PIXI.EarCut.area(e.prev,e,e.next))return!1;e=e.next}return!0},PIXI.EarCut.isEarHashed=function(a,b,c,d){var e=a.prev,f=a,g=a.next;if(0<=PIXI.EarCut.area(e,f,g))return!1;for(var h=e.x<f.x?e.x<g.x?e.x:g.x:f.x<g.x?f.x:g.x,i=e.y<f.y?e.y<g.y?e.y:g.y:f.y<g.y?f.y:g.y,j=e.x>f.x?e.x>g.x?e.x:g.x:f.x>g.x?f.x:g.x,k=e.y>f.y?e.y>g.y?e.y:g.y:f.y>g.y?f.y:g.y,l=PIXI.EarCut.zOrder(h,i,b,c,d),m=PIXI.EarCut.zOrder(j,k,b,c,d),n=a.nextZ;n&&n.z<=m;){if(n!==a.prev&&n!==a.next&&PIXI.EarCut.pointInTriangle(e.x,e.y,f.x,f.y,g.x,g.y,n.x,n.y)&&0<=PIXI.EarCut.area(n.prev,n,n.next))return!1;n=n.nextZ}for(n=a.prevZ;n&&n.z>=l;){if(n!==a.prev&&n!==a.next&&PIXI.EarCut.pointInTriangle(e.x,e.y,f.x,f.y,g.x,g.y,n.x,n.y)&&0<=PIXI.EarCut.area(n.prev,n,n.next))return!1;n=n.prevZ}return!0},PIXI.EarCut.cureLocalIntersections=function(a,b,c){var d=a;do{var e=d.prev,f=d.next.next;PIXI.EarCut.intersects(e,d,d.next,f)&&PIXI.EarCut.locallyInside(e,f)&&PIXI.EarCut.locallyInside(f,e)&&(b.push(e.i/c),b.push(d.i/c),b.push(f.i/c),PIXI.EarCut.removeNode(d),PIXI.EarCut.removeNode(d.next),d=a=f),d=d.next}while(d!==a);return d},PIXI.EarCut.splitEarcut=function(a,b,c,d,e,f){var g=a;do{for(var h=g.next.next;h!==g.prev;){if(g.i!==h.i&&PIXI.EarCut.isValidDiagonal(g,h)){var i=PIXI.EarCut.splitPolygon(g,h);return g=PIXI.EarCut.filterPoints(g,g.next),i=PIXI.EarCut.filterPoints(i,i.next),PIXI.EarCut.earcutLinked(g,b,c,d,e,f),void PIXI.EarCut.earcutLinked(i,b,c,d,e,f)}h=h.next}g=g.next}while(g!==a)},PIXI.EarCut.eliminateHoles=function(a,b,c,d){var e,f,g,h,i,j=[];for(e=0,f=b.length;e<f;e++)g=b[e]*d,h=e<f-1?b[e+1]*d:a.length,(i=PIXI.EarCut.linkedList(a,g,h,d,!1))===i.next&&(i.steiner=!0),j.push(PIXI.EarCut.getLeftmost(i));for(j.sort(compareX),e=0;e<j.length;e++)PIXI.EarCut.eliminateHole(j[e],c),c=PIXI.EarCut.filterPoints(c,c.next);return c},PIXI.EarCut.compareX=function(a,b){return a.x-b.x},PIXI.EarCut.eliminateHole=function(a,b){if(b=PIXI.EarCut.findHoleBridge(a,b)){var c=PIXI.EarCut.splitPolygon(b,a);PIXI.EarCut.filterPoints(c,c.next)}},PIXI.EarCut.findHoleBridge=function(a,b){var c,d=b,e=a.x,f=a.y,g=-1/0;do{if(f<=d.y&&f>=d.next.y){var h=d.x+(f-d.y)*(d.next.x-d.x)/(d.next.y-d.y);h<=e&&g<h&&(g=h,c=d.x<d.next.x?d:d.next)}d=d.next}while(d!==b);if(!c)return null;if(a.x===c.x)return c.prev;var i,j=c,k=1/0;for(d=c.next;d!==j;)e>=d.x&&d.x>=c.x&&PIXI.EarCut.pointInTriangle(f<c.y?e:g,f,c.x,c.y,f<c.y?g:e,f,d.x,d.y)&&((i=Math.abs(f-d.y)/(e-d.x))<k||i===k&&d.x>c.x)&&PIXI.EarCut.locallyInside(d,a)&&(c=d,k=i),d=d.next;return c},PIXI.EarCut.indexCurve=function(a,b,c,d){for(var e=a;null===e.z&&(e.z=PIXI.EarCut.zOrder(e.x,e.y,b,c,d)),e.prevZ=e.prev,e.nextZ=e.next,(e=e.next)!==a;);e.prevZ.nextZ=null,e.prevZ=null,PIXI.EarCut.sortLinked(e)},PIXI.EarCut.sortLinked=function(a){var b,c,d,e,f,g,h,i,j=1;do{for(c=a,f=a=null,g=0;c;){for(g++,d=c,b=h=0;b<j&&(h++,d=d.nextZ);b++);for(i=j;0<h||0<i&&d;)0===h?(d=(e=d).nextZ,i--):0!==i&&d?c.z<=d.z?(c=(e=c).nextZ,h--):(d=(e=d).nextZ,i--):(c=(e=c).nextZ,h--),f?f.nextZ=e:a=e,e.prevZ=f,f=e;c=d}f.nextZ=null,j*=2}while(1<g);return a},PIXI.EarCut.zOrder=function(a,b,c,d,e){return(a=1431655765&((a=858993459&((a=252645135&((a=16711935&((a=32767*(a-c)/e)|a<<8))|a<<4))|a<<2))|a<<1))|(b=1431655765&((b=858993459&((b=252645135&((b=16711935&((b=32767*(b-d)/e)|b<<8))|b<<4))|b<<2))|b<<1))<<1},PIXI.EarCut.getLeftmost=function(a){for(var b=a,c=a;b.x<c.x&&(c=b),(b=b.next)!==a;);return c},PIXI.EarCut.pointInTriangle=function(a,b,c,d,e,f,g,h){return 0<=(e-g)*(b-h)-(a-g)*(f-h)&&0<=(a-g)*(d-h)-(c-g)*(b-h)&&0<=(c-g)*(f-h)-(e-g)*(d-h)},PIXI.EarCut.isValidDiagonal=function(a,b){return PIXI.EarCut.equals(a,b)||a.next.i!==b.i&&a.prev.i!==b.i&&!PIXI.EarCut.intersectsPolygon(a,b)&&PIXI.EarCut.locallyInside(a,b)&&PIXI.EarCut.locallyInside(b,a)&&PIXI.EarCut.middleInside(a,b)},PIXI.EarCut.area=function(a,b,c){return(b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y)},PIXI.EarCut.equals=function(a,b){return a.x===b.x&&a.y===b.y},PIXI.EarCut.intersects=function(a,b,c,d){return 0<PIXI.EarCut.area(a,b,c)!=0<PIXI.EarCut.area(a,b,d)&&0<PIXI.EarCut.area(c,d,a)!=0<PIXI.EarCut.area(c,d,b)},PIXI.EarCut.intersectsPolygon=function(a,b){var c=a;do{if(c.i!==a.i&&c.next.i!==a.i&&c.i!==b.i&&c.next.i!==b.i&&PIXI.EarCut.intersects(c,c.next,a,b))return!0;c=c.next}while(c!==a);return!1},PIXI.EarCut.locallyInside=function(a,b){return PIXI.EarCut.area(a.prev,a,a.next)<0?0<=PIXI.EarCut.area(a,b,a.next)&&0<=PIXI.EarCut.area(a,a.prev,b):PIXI.EarCut.area(a,b,a.prev)<0||PIXI.EarCut.area(a,a.next,b)<0},PIXI.EarCut.middleInside=function(a,b){for(var c=a,d=!1,e=(a.x+b.x)/2,f=(a.y+b.y)/2;c.y>f!=c.next.y>f&&e<(c.next.x-c.x)*(f-c.y)/(c.next.y-c.y)+c.x&&(d=!d),(c=c.next)!==a;);return d},PIXI.EarCut.splitPolygon=function(a,b){var c=new PIXI.EarCut.Node(a.i,a.x,a.y),d=new PIXI.EarCut.Node(b.i,b.x,b.y),e=a.next,f=b.prev;return(a.next=b).prev=a,(c.next=e).prev=c,(d.next=c).prev=d,(f.next=d).prev=f,d},PIXI.EarCut.insertNode=function(a,b,c,d){var e=new PIXI.EarCut.Node(a,b,c);return d?(e.next=d.next,(e.prev=d).next.prev=e,d.next=e):(e.prev=e).next=e,e},PIXI.EarCut.removeNode=function(a){a.next.prev=a.prev,a.prev.next=a.next,a.prevZ&&(a.prevZ.nextZ=a.nextZ),a.nextZ&&(a.nextZ.prevZ=a.prevZ)},PIXI.EarCut.Node=function(a,b,c){this.i=a,this.x=b,this.y=c,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1},PIXI.WebGLGraphics=function(){},PIXI.WebGLGraphics.stencilBufferLimit=6,PIXI.WebGLGraphics.renderGraphics=function(a,b){var c,d=b.gl,e=b.projection,f=b.offset,g=b.shaderManager.primitiveShader;a.dirty&&PIXI.WebGLGraphics.updateGraphics(a,d);for(var h=a._webGL[d.id],i=0;i<h.data.length;i++)1===h.data[i].mode?(c=h.data[i],b.stencilManager.pushStencil(a,c,b),d.drawElements(d.TRIANGLE_FAN,4,d.UNSIGNED_SHORT,2*(c.indices.length-4)),b.stencilManager.popStencil(a,c,b)):(c=h.data[i],b.shaderManager.setShader(g),g=b.shaderManager.primitiveShader,d.uniformMatrix3fv(g.translationMatrix,!1,a.worldTransform.toArray(!0)),d.uniform1f(g.flipY,1),d.uniform2f(g.projectionVector,e.x,-e.y),d.uniform2f(g.offsetVector,-f.x,-f.y),d.uniform3fv(g.tintColor,PIXI.hex2rgb(a.tint)),d.uniform1f(g.alpha,a.worldAlpha),d.bindBuffer(d.ARRAY_BUFFER,c.buffer),d.vertexAttribPointer(g.aVertexPosition,2,d.FLOAT,!1,24,0),d.vertexAttribPointer(g.colorAttribute,4,d.FLOAT,!1,24,8),d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,c.indexBuffer),d.drawElements(d.TRIANGLE_STRIP,c.indices.length,d.UNSIGNED_SHORT,0))},PIXI.WebGLGraphics.updateGraphics=function(a,b){var d,f,c=a._webGL[b.id];if(c||(c=a._webGL[b.id]={lastIndex:0,data:[],gl:b}),a.dirty=!1,a.clearDirty){for(a.clearDirty=!1,d=0;d<c.data.length;d++){var e=c.data[d];e.reset(),PIXI.WebGLGraphics.graphicsDataPool.push(e)}c.data=[],c.lastIndex=0}for(d=c.lastIndex;d<a.graphicsData.length;d++){var g=a.graphicsData[d];if(g.type===PIXI.Graphics.POLY){if(g.points=g.shape.points.slice(),g.shape.closed&&(g.points[0]===g.points[g.points.length-2]&&g.points[1]===g.points[g.points.length-1]||g.points.push(g.points[0],g.points[1])),g.fill&&g.points.length>=PIXI.WebGLGraphics.stencilBufferLimit)if(g.points.length<2*PIXI.WebGLGraphics.stencilBufferLimit){f=PIXI.WebGLGraphics.switchMode(c,0),PIXI.WebGLGraphics.buildPoly(g,f)||(f=PIXI.WebGLGraphics.switchMode(c,1),PIXI.WebGLGraphics.buildComplexPoly(g,f))}else f=PIXI.WebGLGraphics.switchMode(c,1),PIXI.WebGLGraphics.buildComplexPoly(g,f);0<g.lineWidth&&(f=PIXI.WebGLGraphics.switchMode(c,0),PIXI.WebGLGraphics.buildLine(g,f))}else f=PIXI.WebGLGraphics.switchMode(c,0),g.type===PIXI.Graphics.RECT?PIXI.WebGLGraphics.buildRectangle(g,f):g.type===PIXI.Graphics.CIRC||g.type===PIXI.Graphics.ELIP?PIXI.WebGLGraphics.buildCircle(g,f):g.type===PIXI.Graphics.RREC&&PIXI.WebGLGraphics.buildRoundedRectangle(g,f);c.lastIndex++}for(d=0;d<c.data.length;d++)(f=c.data[d]).dirty&&f.upload()},PIXI.WebGLGraphics.switchMode=function(a,b){var c;return a.data.length?(c=a.data[a.data.length-1]).mode===b&&1!==b||((c=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(a.gl)).mode=b,a.data.push(c)):((c=PIXI.WebGLGraphics.graphicsDataPool.pop()||new PIXI.WebGLGraphicsData(a.gl)).mode=b,a.data.push(c)),c.dirty=!0,c},PIXI.WebGLGraphics.buildRectangle=function(a,b){var c=a.shape,d=c.x,e=c.y,f=c.width,g=c.height;if(a.fill){var h=PIXI.hex2rgb(a.fillColor),i=a.fillAlpha,j=h[0]*i,k=h[1]*i,l=h[2]*i,m=b.points,n=b.indices,o=m.length/6;m.push(d,e),m.push(j,k,l,i),m.push(d+f,e),m.push(j,k,l,i),m.push(d,e+g),m.push(j,k,l,i),m.push(d+f,e+g),m.push(j,k,l,i),n.push(o,o,o+1,o+2,o+3,o+3)}if(a.lineWidth){var p=a.points;a.points=[d,e,d+f,e,d+f,e+g,d,e+g,d,e],PIXI.WebGLGraphics.buildLine(a,b),a.points=p}},PIXI.WebGLGraphics.buildRoundedRectangle=function(a,b){var c=a.shape,d=c.x,e=c.y,f=c.width,g=c.height,h=c.radius,i=[];if(i.push(d,e+h),i=(i=(i=(i=i.concat(PIXI.WebGLGraphics.quadraticBezierCurve(d,e+g-h,d,e+g,d+h,e+g))).concat(PIXI.WebGLGraphics.quadraticBezierCurve(d+f-h,e+g,d+f,e+g,d+f,e+g-h))).concat(PIXI.WebGLGraphics.quadraticBezierCurve(d+f,e+h,d+f,e,d+f-h,e))).concat(PIXI.WebGLGraphics.quadraticBezierCurve(d+h,e,d,e,d,e+h)),a.fill){var j=PIXI.hex2rgb(a.fillColor),k=a.fillAlpha,l=j[0]*k,m=j[1]*k,n=j[2]*k,o=b.points,p=b.indices,q=o.length/6,r=PIXI.EarCut.Triangulate(i,null,2),s=0;for(s=0;s<r.length;s+=3)p.push(r[s]+q),p.push(r[s]+q),p.push(r[s+1]+q),p.push(r[s+2]+q),p.push(r[s+2]+q);for(s=0;s<i.length;s++)o.push(i[s],i[++s],l,m,n,k)}if(a.lineWidth){var t=a.points;a.points=i,PIXI.WebGLGraphics.buildLine(a,b),a.points=t}},PIXI.WebGLGraphics.quadraticBezierCurve=function(a,b,c,d,e,f){function g(a,b,c){return a+(b-a)*c}for(var h,i,j,k,l,m,o=[],p=0,q=0;q<=20;q++)h=g(a,c,p=q/20),i=g(b,d,p),j=g(c,e,p),k=g(d,f,p),l=g(h,j,p),m=g(i,k,p),o.push(l,m);return o},PIXI.WebGLGraphics.buildCircle=function(a,b){var c,d,e=a.shape,f=e.x,g=e.y;d=a.type===PIXI.Graphics.CIRC?(c=e.radius,e.radius):(c=e.width,e.height);var i=2*Math.PI/40,j=0;if(a.fill){var k=PIXI.hex2rgb(a.fillColor),l=a.fillAlpha,m=k[0]*l,n=k[1]*l,o=k[2]*l,p=b.points,q=b.indices,r=p.length/6;for(q.push(r),j=0;j<41;j++)p.push(f,g,m,n,o,l),p.push(f+Math.sin(i*j)*c,g+Math.cos(i*j)*d,m,n,o,l),q.push(r++,r++);q.push(r-1)}if(a.lineWidth){var s=a.points;for(a.points=[],j=0;j<41;j++)a.points.push(f+Math.sin(i*j)*c,g+Math.cos(i*j)*d);PIXI.WebGLGraphics.buildLine(a,b),a.points=s}},PIXI.WebGLGraphics.buildLine=function(a,b){var c=0,d=a.points;if(0!==d.length){if(a.lineWidth%2)for(c=0;c<d.length;c++)d[c]+=.5;var e=new PIXI.Point(d[0],d[1]),f=new PIXI.Point(d[d.length-2],d[d.length-1]);if(e.x===f.x&&e.y===f.y){(d=d.slice()).pop(),d.pop();var g=(f=new PIXI.Point(d[d.length-2],d[d.length-1])).x+.5*(e.x-f.x),h=f.y+.5*(e.y-f.y);d.unshift(g,h),d.push(g,h)}var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,E,F=b.points,G=b.indices,H=d.length/2,I=d.length,J=F.length/6,K=a.lineWidth/2,L=PIXI.hex2rgb(a.lineColor),M=a.lineAlpha,N=L[0]*M,O=L[1]*M,P=L[2]*M;for(k=d[0],l=d[1],m=d[2],q=-(l-(n=d[3])),r=k-m,q/=E=Math.sqrt(q*q+r*r),r/=E,q*=K,r*=K,F.push(k-q,l-r,N,O,P,M),F.push(k+q,l+r,N,O,P,M),c=1;c<H-1;c++)k=d[2*(c-1)],l=d[2*(c-1)+1],m=d[2*c],n=d[2*c+1],o=d[2*(c+1)],p=d[2*(c+1)+1],q=-(l-n),r=k-m,q/=E=Math.sqrt(q*q+r*r),r/=E,q*=K,r*=K,s=-(n-p),t=m-o,s/=E=Math.sqrt(s*s+t*t),t/=E,y=(-q+k)*(-r+n)-(-q+m)*(-r+l),B=(-(s*=K)+o)*(-(t*=K)+n)-(-s+m)*(-t+p),C=(w=-r+l-(-r+n))*(A=-s+m-(-s+o))-(z=-t+p-(-t+n))*(x=-q+m-(-q+k)),Math.abs(C)<.1?(C+=10.1,F.push(m-q,n-r,N,O,P,M),F.push(m+q,n+r,N,O,P,M)):19600<((i=(x*B-A*y)/C)-m)*(i-m)+((j=(z*y-w*B)/C)-n)+(j-n)?(u=q-s,v=r-t,u/=E=Math.sqrt(u*u+v*v),v/=E,u*=K,v*=K,F.push(m-u,n-v),F.push(N,O,P,M),F.push(m+u,n+v),F.push(N,O,P,M),F.push(m-u,n-v),F.push(N,O,P,M),I++):(F.push(i,j),F.push(N,O,P,M),F.push(m-(i-m),n-(j-n)),F.push(N,O,P,M));for(k=d[2*(H-2)],l=d[2*(H-2)+1],m=d[2*(H-1)],q=-(l-(n=d[2*(H-1)+1])),r=k-m,q/=E=Math.sqrt(q*q+r*r),r/=E,q*=K,r*=K,F.push(m-q,n-r),F.push(N,O,P,M),F.push(m+q,n+r),F.push(N,O,P,M),G.push(J),c=0;c<I;c++)G.push(J++);G.push(J-1)}},PIXI.WebGLGraphics.buildComplexPoly=function(a,b){var c=a.points.slice();if(!(c.length<6)){var d=b.indices;b.points=c,b.alpha=a.fillAlpha,b.color=PIXI.hex2rgb(a.fillColor);for(var e,f,g=1/0,h=-1/0,i=1/0,j=-1/0,k=0;k<c.length;k+=2)g=(e=c[k])<g?e:g,h=h<e?e:h,i=(f=c[k+1])<i?f:i,j=j<f?f:j;c.push(g,i,h,i,h,j,g,j);var l=c.length/2;for(k=0;k<l;k++)d.push(k)}},PIXI.WebGLGraphics.buildPoly=function(a,b){var c=a.points;if(!(c.length<6)){var d=b.points,e=b.indices,f=c.length/2,g=PIXI.hex2rgb(a.fillColor),h=a.fillAlpha,i=g[0]*h,j=g[1]*h,k=g[2]*h,l=PIXI.EarCut.Triangulate(c,null,2);if(!l)return!1;var m=d.length/6,n=0;for(n=0;n<l.length;n+=3)e.push(l[n]+m),e.push(l[n]+m),e.push(l[n+1]+m),e.push(l[n+2]+m),e.push(l[n+2]+m);for(n=0;n<f;n++)d.push(c[2*n],c[2*n+1],i,j,k,h);return!0}},PIXI.WebGLGraphics.graphicsDataPool=[],PIXI.WebGLGraphicsData=function(a){this.gl=a,this.color=[0,0,0],this.points=[],this.indices=[],this.buffer=a.createBuffer(),this.indexBuffer=a.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},PIXI.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[]},PIXI.WebGLGraphicsData.prototype.upload=function(){var a=this.gl;this.glPoints=new PIXI.Float32Array(this.points),a.bindBuffer(a.ARRAY_BUFFER,this.buffer),a.bufferData(a.ARRAY_BUFFER,this.glPoints,a.STATIC_DRAW),this.glIndicies=new PIXI.Uint16Array(this.indices),a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,this.indexBuffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,this.glIndicies,a.STATIC_DRAW),this.dirty=!1},PIXI.CanvasGraphics=function(){},PIXI.CanvasGraphics.renderGraphics=function(a,b){var c=a.worldAlpha;a.dirty&&(this.updateGraphicsTint(a),a.dirty=!1);for(var d=0;d<a.graphicsData.length;d++){var e=a.graphicsData[d],f=e.shape,g=e._fillTint,h=e._lineTint;if(b.lineWidth=e.lineWidth,e.type===PIXI.Graphics.POLY){b.beginPath();var i=f.points;b.moveTo(i[0],i[1]);for(var j=1;j<i.length/2;j++)b.lineTo(i[2*j],i[2*j+1]);f.closed&&b.lineTo(i[0],i[1]),i[0]===i[i.length-2]&&i[1]===i[i.length-1]&&b.closePath(),e.fill&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke())}else if(e.type===PIXI.Graphics.RECT)(e.fillColor||0===e.fillColor)&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fillRect(f.x,f.y,f.width,f.height)),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.strokeRect(f.x,f.y,f.width,f.height));else if(e.type===PIXI.Graphics.CIRC)b.beginPath(),b.arc(f.x,f.y,f.radius,0,2*Math.PI),b.closePath(),e.fill&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke());else if(e.type===PIXI.Graphics.ELIP){var k=2*f.width,l=2*f.height,m=f.x-k/2,n=f.y-l/2;b.beginPath();var o=.5522848,p=k/2*o,q=l/2*o,r=m+k,s=n+l,t=m+k/2,u=n+l/2;b.moveTo(m,u),b.bezierCurveTo(m,u-q,t-p,n,t,n),b.bezierCurveTo(t+p,n,r,u-q,r,u),b.bezierCurveTo(r,u+q,t+p,s,t,s),b.bezierCurveTo(t-p,s,m,u+q,m,u),b.closePath(),e.fill&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke())}else if(e.type===PIXI.Graphics.RREC){var v=f.x,w=f.y,x=f.width,y=f.height,z=f.radius,A=Math.min(x,y)/2|0;z=A<z?A:z,b.beginPath(),b.moveTo(v,w+z),b.lineTo(v,w+y-z),b.quadraticCurveTo(v,w+y,v+z,w+y),b.lineTo(v+x-z,w+y),b.quadraticCurveTo(v+x,w+y,v+x,w+y-z),b.lineTo(v+x,w+z),b.quadraticCurveTo(v+x,w,v+x-z,w),b.lineTo(v+z,w),b.quadraticCurveTo(v,w,v,w+z),b.closePath(),(e.fillColor||0===e.fillColor)&&(b.globalAlpha=e.fillAlpha*c,b.fillStyle="#"+("00000"+(0|g).toString(16)).substr(-6),b.fill()),e.lineWidth&&(b.globalAlpha=e.lineAlpha*c,b.strokeStyle="#"+("00000"+(0|h).toString(16)).substr(-6),b.stroke())}}},PIXI.CanvasGraphics.renderGraphicsMask=function(a,b){var c=a.graphicsData.length;if(0!==c){b.beginPath();for(var d=0;d<c;d++){var e=a.graphicsData[d],f=e.shape;if(e.type===PIXI.Graphics.POLY){var g=f.points;b.moveTo(g[0],g[1]);for(var h=1;h<g.length/2;h++)b.lineTo(g[2*h],g[2*h+1]);g[0]===g[g.length-2]&&g[1]===g[g.length-1]&&b.closePath()}else if(e.type===PIXI.Graphics.RECT)b.rect(f.x,f.y,f.width,f.height),b.closePath();else if(e.type===PIXI.Graphics.CIRC)b.arc(f.x,f.y,f.radius,0,2*Math.PI),b.closePath();else if(e.type===PIXI.Graphics.ELIP){var i=2*f.width,j=2*f.height,k=f.x-i/2,l=f.y-j/2,m=.5522848,n=i/2*m,o=j/2*m,p=k+i,q=l+j,r=k+i/2,s=l+j/2;b.moveTo(k,s),b.bezierCurveTo(k,s-o,r-n,l,r,l),b.bezierCurveTo(r+n,l,p,s-o,p,s),b.bezierCurveTo(p,s+o,r+n,q,r,q),b.bezierCurveTo(r-n,q,k,s+o,k,s),b.closePath()}else if(e.type===PIXI.Graphics.RREC){var t=f.x,u=f.y,v=f.width,w=f.height,x=f.radius,y=Math.min(v,w)/2|0;x=y<x?y:x,b.moveTo(t,u+x),b.lineTo(t,u+w-x),b.quadraticCurveTo(t,u+w,t+x,u+w),b.lineTo(t+v-x,u+w),b.quadraticCurveTo(t+v,u+w,t+v,u+w-x),b.lineTo(t+v,u+x),b.quadraticCurveTo(t+v,u,t+v-x,u),b.lineTo(t+x,u),b.quadraticCurveTo(t,u,t,u+x),b.closePath()}}}},PIXI.CanvasGraphics.updateGraphicsTint=function(a){if(16777215!==a.tint)for(var b=(a.tint>>16&255)/255,c=(a.tint>>8&255)/255,d=(255&a.tint)/255,e=0;e<a.graphicsData.length;e++){var f=a.graphicsData[e],g=0|f.fillColor,h=0|f.lineColor;f._fillTint=((g>>16&255)/255*b*255<<16)+((g>>8&255)/255*c*255<<8)+(255&g)/255*d*255,f._lineTint=((h>>16&255)/255*b*255<<16)+((h>>8&255)/255*c*255<<8)+(255&h)/255*d*255}},c.Graphics=function(a,b,d){void 0===b&&(b=0),void 0===d&&(d=0),this.type=c.GRAPHICS,this.physicsType=c.SPRITE,this.anchor=new c.Point,PIXI.Graphics.call(this),c.Component.Core.init.call(this,a,b,d,"",null)},c.Graphics.prototype=Object.create(PIXI.Graphics.prototype),c.Graphics.prototype.constructor=c.Graphics,c.Component.Core.install.call(c.Graphics.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),c.Graphics.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.Graphics.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.Graphics.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Graphics.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Graphics.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},c.Graphics.prototype.postUpdate=function(){c.Component.PhysicsBody.postUpdate.call(this),c.Component.FixedToCamera.postUpdate.call(this),this._boundsDirty&&(this.updateLocalBounds(),this._boundsDirty=!1);for(var a=0;a<this.children.length;a++)this.children[a].postUpdate()},c.Graphics.prototype.destroy=function(a){this.clear(),c.Component.Destroy.prototype.destroy.call(this,a)},c.Graphics.prototype.drawTriangle=function(a,b){void 0===b&&(b=!1);var d=new c.Polygon(a);if(b){var e=new c.Point(this.game.camera.x-a[0].x,this.game.camera.y-a[0].y),f=new c.Point(a[1].x-a[0].x,a[1].y-a[0].y),h=new c.Point(a[1].x-a[2].x,a[1].y-a[2].y).cross(f);0<e.dot(h)&&this.drawPolygon(d)}else this.drawPolygon(d)},c.Graphics.prototype.drawTriangles=function(a,b,d){void 0===d&&(d=!1);var e,f=new c.Point,g=new c.Point,h=new c.Point,i=[];if(b)if(a[0]instanceof c.Point)for(e=0;e<b.length/3;e++)i.push(a[b[3*e]]),i.push(a[b[3*e+1]]),i.push(a[b[3*e+2]]),3===i.length&&(this.drawTriangle(i,d),i=[]);else for(e=0;e<b.length;e++)f.x=a[2*b[e]],f.y=a[2*b[e]+1],i.push(f.copyTo({})),3===i.length&&(this.drawTriangle(i,d),i=[]);else if(a[0]instanceof c.Point)for(e=0;e<a.length/3;e++)this.drawTriangle([a[3*e],a[3*e+1],a[3*e+2]],d);else for(e=0;e<a.length/6;e++)f.x=a[6*e+0],f.y=a[6*e+1],g.x=a[6*e+2],g.y=a[6*e+3],h.x=a[6*e+4],h.y=a[6*e+5],this.drawTriangle([f,g,h],d)},c.RenderTexture=function(a,b,d,e,f,g){void 0===e&&(e=""),void 0===f&&(f=c.scaleModes.DEFAULT),void 0===g&&(g=1),this.game=a,this.key=e,this.type=c.RENDERTEXTURE,this._tempMatrix=new PIXI.Matrix,PIXI.RenderTexture.call(this,b,d,this.game.renderer,f,g),this.render=c.RenderTexture.prototype.render},c.RenderTexture.prototype=Object.create(PIXI.RenderTexture.prototype),c.RenderTexture.prototype.constructor=c.RenderTexture,c.RenderTexture.prototype.renderXY=function(a,b,c,d){a.updateTransform(),this._tempMatrix.copyFrom(a.worldTransform),this._tempMatrix.tx=b,this._tempMatrix.ty=c,this.renderer.type===PIXI.WEBGL_RENDERER?this.renderWebGL(a,this._tempMatrix,d):this.renderCanvas(a,this._tempMatrix,d)},c.RenderTexture.prototype.renderRawXY=function(a,b,c,d){this._tempMatrix.identity().translate(b,c),this.renderer.type===PIXI.WEBGL_RENDERER?this.renderWebGL(a,this._tempMatrix,d):this.renderCanvas(a,this._tempMatrix,d)},c.RenderTexture.prototype.render=function(a,b,c){null==b?this._tempMatrix.copyFrom(a.worldTransform):this._tempMatrix.copyFrom(b),this.renderer.type===PIXI.WEBGL_RENDERER?this.renderWebGL(a,this._tempMatrix,c):this.renderCanvas(a,this._tempMatrix,c)},c.Text=function(a,b,d,e,f){b=b||0,d=d||0,e=null==e?"":e.toString(),f=c.Utils.extend({},f),this.type=c.TEXT,this.physicsType=c.SPRITE,this.padding=new c.Point,this.textBounds=null,this.canvas=PIXI.CanvasPool.create(this),this.context=this.canvas.getContext("2d"),this.colors=[],this.strokeColors=[],this.fontStyles=[],this.fontWeights=[],this.autoRound=!1,this.useAdvancedWrap=!1,this._res=a.renderer.resolution,this._text=e,this._fontComponents=null,this._lineSpacing=0,this._charCount=0,this._width=0,this._height=0,c.Sprite.call(this,a,b,d,PIXI.Texture.fromCanvas(this.canvas)),this.setStyle(f),""!==e&&this.updateText()},c.Text.prototype=Object.create(c.Sprite.prototype),c.Text.prototype.constructor=c.Text,c.Text.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},c.Text.prototype.update=function(){},c.Text.prototype.destroy=function(a){this.texture.destroy(!0),c.Component.Destroy.prototype.destroy.call(this,a)},c.Text.prototype.setShadow=function(a,b,c,d,e,f){return void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c="rgba(0, 0, 0, 1)"),void 0===d&&(d=0),void 0===e&&(e=!0),void 0===f&&(f=!0),this.style.shadowOffsetX=a,this.style.shadowOffsetY=b,this.style.shadowColor=c,this.style.shadowBlur=d,this.style.shadowStroke=e,this.style.shadowFill=f,this.dirty=!0,this},c.Text.prototype.setStyle=function(a,b){void 0===b&&(b=!1),(a=a||{}).font=a.font||"bold 20pt Arial",a.backgroundColor=a.backgroundColor||null,a.fill=a.fill||"black",a.align=a.align||"left",a.boundsAlignH=a.boundsAlignH||"left",a.boundsAlignV=a.boundsAlignV||"top",a.stroke=a.stroke||"black",a.strokeThickness=a.strokeThickness||0,a.wordWrap=a.wordWrap||!1,a.wordWrapWidth=a.wordWrapWidth||100,a.maxLines=a.maxLines||0,a.shadowOffsetX=a.shadowOffsetX||0,a.shadowOffsetY=a.shadowOffsetY||0,a.shadowColor=a.shadowColor||"rgba(0,0,0,0)",a.shadowBlur=a.shadowBlur||0,a.tabs=a.tabs||0;var c=this.fontToComponents(a.font);return a.fontStyle&&(c.fontStyle=a.fontStyle),a.fontVariant&&(c.fontVariant=a.fontVariant),a.fontWeight&&(c.fontWeight=a.fontWeight),a.fontSize&&("number"==typeof a.fontSize&&(a.fontSize=a.fontSize+"px"),c.fontSize=a.fontSize),this._fontComponents=c,a.font=this.componentsToFont(this._fontComponents),this.style=a,this.dirty=!0,b&&this.updateText(),this},c.Text.prototype.updateText=function(){this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font;var a=this.text;this.style.wordWrap&&(a=this.runWordWrap(this.text));var b=a.split(/(?:\r\n|\r|\n)/),c=this.style.tabs,d=[],e=0,f=this.determineFontProperties(this.style.font),g=b.length;0<this.style.maxLines&&this.style.maxLines<b.length&&(g=this.style.maxLines);for(var h=this._charCount=0;h<g;h++){if(0===c){var i=this.style.strokeThickness+this.padding.x;0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?i+=this.measureLine(b[h]):i+=this.context.measureText(b[h]).width,this.style.wordWrap&&(i-=this.context.measureText(" ").width)}else{var j=b[h].split(/(?:\t)/);i=this.padding.x+this.style.strokeThickness;if(Array.isArray(c))for(var k=0,l=0;l<j.length;l++){var m;m=0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?this.measureLine(j[l]):Math.ceil(this.context.measureText(j[l]).width),0<l&&(k+=c[l-1]),i=k+m}else for(l=0;l<j.length;l++){0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?i+=this.measureLine(j[l]):i+=Math.ceil(this.context.measureText(j[l]).width),i+=this.game.math.snapToCeil(i,c)-i}}d[h]=Math.ceil(i),e=Math.max(e,d[h])}this.canvas.width=e*this._res;var r,s,o=f.fontSize+this.style.strokeThickness+this.padding.y,p=o*g,q=this._lineSpacing;for(q<0&&Math.abs(q)>o&&(q=-o),0!==q&&(p+=0<q?q*b.length:q*(b.length-1)),this.canvas.height=p*this._res,this.context.scale(this._res,this._res),navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.style.backgroundColor&&(this.context.fillStyle=this.style.backgroundColor,this.context.fillRect(0,0,this.canvas.width,this.canvas.height)),this.context.fillStyle=this.style.fill,this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.textBaseline="alphabetic",this.context.lineWidth=this.style.strokeThickness,this.context.lineCap="round",this.context.lineJoin="round",h=this._charCount=0;h<g;h++)r=this.style.strokeThickness/2,s=this.style.strokeThickness/2+h*o+f.ascent,0<h&&(s+=q*h),"right"===this.style.align?r+=e-d[h]:"center"===this.style.align&&(r+=(e-d[h])/2),this.autoRound&&(r=Math.round(r),s=Math.round(s)),0<this.colors.length||0<this.strokeColors.length||0<this.fontWeights.length||0<this.fontStyles.length?this.updateLine(b[h],r,s):(this.style.stroke&&this.style.strokeThickness&&(this.updateShadow(this.style.shadowStroke),0===c?this.context.strokeText(b[h],r,s):this.renderTabLine(b[h],r,s,!1)),this.style.fill&&(this.updateShadow(this.style.shadowFill),0===c?this.context.fillText(b[h],r,s):this.renderTabLine(b[h],r,s,!0)));this.updateTexture(),this.dirty=!1},c.Text.prototype.renderTabLine=function(a,b,c,d){var e=a.split(/(?:\t)/),f=this.style.tabs,g=0;if(Array.isArray(f))for(var h=0,i=0;i<e.length;i++)0<i&&(h+=f[i-1]),g=b+h,d?this.context.fillText(e[i],g,c):this.context.strokeText(e[i],g,c);else for(i=0;i<e.length;i++){var j=Math.ceil(this.context.measureText(e[i]).width);g=this.game.math.snapToCeil(b,f),d?this.context.fillText(e[i],g,c):this.context.strokeText(e[i],g,c),b=g+j}},c.Text.prototype.updateShadow=function(a){a?(this.context.shadowOffsetX=this.style.shadowOffsetX,this.context.shadowOffsetY=this.style.shadowOffsetY,this.context.shadowColor=this.style.shadowColor,this.context.shadowBlur=this.style.shadowBlur):(this.context.shadowOffsetX=0,this.context.shadowOffsetY=0,this.context.shadowColor=0,this.context.shadowBlur=0)},c.Text.prototype.measureLine=function(a){for(var b=0,c=0;c<a.length;c++){var d=a[c];if(0<this.fontWeights.length||0<this.fontStyles.length){var e=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(e.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(e.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(e)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill)),b+=this.context.measureText(d).width,this._charCount++}return Math.ceil(b)},c.Text.prototype.updateLine=function(a,b,c){for(var d=0;d<a.length;d++){var e=a[d];if(0<this.fontWeights.length||0<this.fontStyles.length){var f=this.fontToComponents(this.context.font);this.fontStyles[this._charCount]&&(f.fontStyle=this.fontStyles[this._charCount]),this.fontWeights[this._charCount]&&(f.fontWeight=this.fontWeights[this._charCount]),this.context.font=this.componentsToFont(f)}this.style.stroke&&this.style.strokeThickness&&(this.strokeColors[this._charCount]&&(this.context.strokeStyle=this.strokeColors[this._charCount]),this.updateShadow(this.style.shadowStroke),this.context.strokeText(e,b,c)),this.style.fill&&(this.colors[this._charCount]&&(this.context.fillStyle=this.colors[this._charCount]),this.updateShadow(this.style.shadowFill),this.context.fillText(e,b,c)),b+=this.context.measureText(e).width,this._charCount++}},c.Text.prototype.clearColors=function(){return this.colors=[],this.strokeColors=[],this.dirty=!0,this},c.Text.prototype.clearFontValues=function(){return this.fontStyles=[],this.fontWeights=[],this.dirty=!0,this},c.Text.prototype.addColor=function(a,b){return this.colors[b]=a,this.dirty=!0,this},c.Text.prototype.addStrokeColor=function(a,b){return this.strokeColors[b]=a,this.dirty=!0,this},c.Text.prototype.addFontStyle=function(a,b){return this.fontStyles[b]=a,this.dirty=!0,this},c.Text.prototype.addFontWeight=function(a,b){return this.fontWeights[b]=a,this.dirty=!0,this},c.Text.prototype.precalculateWordWrap=function(a){return this.texture.baseTexture.resolution=this._res,this.context.font=this.style.font,this.runWordWrap(a).split(/(?:\r\n|\r|\n)/)},c.Text.prototype.runWordWrap=function(a){return this.useAdvancedWrap?this.advancedWordWrap(a):this.basicWordWrap(a)},c.Text.prototype.advancedWordWrap=function(a){for(var b=this.context,c=this.style.wordWrapWidth,d="",e=a.replace(/ +/gi," ").split(/\r?\n/gi),f=e.length,g=0;g<f;g++){var h=e[g],i="";if(h=h.replace(/^ *|\s*$/gi,""),b.measureText(h).width<c)d+=h+"\n";else{for(var j=c,k=h.split(" "),l=0;l<k.length;l++){var m=k[l],n=m+" ",o=b.measureText(n).width;if(j<o){if(0===l){for(var p=n;p.length&&(p=p.slice(0,-1),!((o=b.measureText(p).width)<=j)););if(!p.length)throw new Error("This text's wordWrapWidth setting is less than a single character!");var q=m.substr(p.length);k[l]=q,i+=p}var r=k[l].length?l:l+1,s=k.slice(r).join(" ").replace(/[ \n]*$/gi,"");e[g+1]=s+" "+(e[g+1]||""),f=e.length;break}i+=n,j-=o}d+=i.replace(/[ \n]*$/gi,"")+"\n"}}return d.replace(/[\s|\n]*$/gi,"")},c.Text.prototype.basicWordWrap=function(a){for(var b="",c=a.split("\n"),d=0;d<c.length;d++){for(var e=this.style.wordWrapWidth,f=c[d].split(" "),g=0;g<f.length;g++){var h=this.context.measureText(f[g]).width,i=h+this.context.measureText(" ").width;e<i?(0<g&&(b+="\n"),b+=f[g]+" ",e=this.style.wordWrapWidth-h):(e-=i,b+=f[g]+" ")}d<c.length-1&&(b+="\n")}return b},c.Text.prototype.updateFont=function(a){var b=this.componentsToFont(a);this.style.font!==b&&(this.style.font=b,this.dirty=!0,this.parent&&this.updateTransform())},c.Text.prototype.fontToComponents=function(a){var b=a.match(/^\s*(?:\b(normal|italic|oblique|inherit)?\b)\s*(?:\b(normal|small-caps|inherit)?\b)\s*(?:\b(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900|inherit)?\b)\s*(?:\b(xx-small|x-small|small|medium|large|x-large|xx-large|larger|smaller|0|\d*(?:[.]\d*)?(?:%|[a-z]{2,5}))?\b)\s*(.*)\s*$/);if(b){var c=b[5].trim();return/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(c)||/['",]/.exec(c)||(c="'"+c+"'"),{font:a,fontStyle:b[1]||"normal",fontVariant:b[2]||"normal",fontWeight:b[3]||"normal",fontSize:b[4]||"medium",fontFamily:c}}return{font:a}},c.Text.prototype.componentsToFont=function(a){var b,c=[];return(b=a.fontStyle)&&"normal"!==b&&c.push(b),(b=a.fontVariant)&&"normal"!==b&&c.push(b),(b=a.fontWeight)&&"normal"!==b&&c.push(b),(b=a.fontSize)&&"medium"!==b&&c.push(b),(b=a.fontFamily)&&c.push(b),c.length||c.push(a.font),c.join(" ")},c.Text.prototype.setText=function(a,b){return void 0===b&&(b=!1),this.text=a.toString()||"",b?this.updateText():this.dirty=!0,this},c.Text.prototype.parseList=function(a){if(!Array.isArray(a))return this;for(var b="",c=0;c<a.length;c++)Array.isArray(a[c])?(b+=a[c].join("\t"),c<a.length-1&&(b+="\n")):(b+=a[c],c<a.length-1&&(b+="\t"));return this.text=b,this.dirty=!0,this},c.Text.prototype.setTextBounds=function(a,b,d,e){return void 0===a?this.textBounds=null:(this.textBounds?this.textBounds.setTo(a,b,d,e):this.textBounds=new c.Rectangle(a,b,d,e),this.style.wordWrapWidth>d&&(this.style.wordWrapWidth=d)),this.updateTexture(),this},c.Text.prototype.updateTexture=function(){var a=this.texture.baseTexture,b=this.texture.crop,c=this.texture.frame,d=this.canvas.width,e=this.canvas.height;if(a.width=d,a.height=e,b.width=d,b.height=e,c.width=d,c.height=e,this.texture.width=d,this.texture.height=e,this._width=d,this._height=e,this.textBounds){var f=this.textBounds.x,g=this.textBounds.y;"right"===this.style.boundsAlignH?f+=this.textBounds.width-this.canvas.width/this.resolution:"center"===this.style.boundsAlignH&&(f+=this.textBounds.halfWidth-this.canvas.width/this.resolution/2),"bottom"===this.style.boundsAlignV?g+=this.textBounds.height-this.canvas.height/this.resolution:"middle"===this.style.boundsAlignV&&(g+=this.textBounds.halfHeight-this.canvas.height/this.resolution/2),this.pivot.x=-f,this.pivot.y=-g}this.renderable=0!==d&&0!==e,this.texture.requiresReTint=!0,this.texture.baseTexture.dirty()},c.Text.prototype._renderWebGL=function(a){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderWebGL.call(this,a)},c.Text.prototype._renderCanvas=function(a){this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype._renderCanvas.call(this,a)},c.Text.prototype.determineFontProperties=function(a){var b=c.Text.fontPropertiesCache[a];if(!b){b={};var d=c.Text.fontPropertiesCanvas,e=c.Text.fontPropertiesContext;e.font=a;var f=Math.ceil(e.measureText("|MÉq").width),g=Math.ceil(e.measureText("|MÉq").width),h=2*g;if(g=1.4*g|0,d.width=f,d.height=h,e.fillStyle="#f00",e.fillRect(0,0,f,h),e.font=a,e.textBaseline="alphabetic",e.fillStyle="#000",e.fillText("|MÉq",0,g),!e.getImageData(0,0,f,h))return b.ascent=g,b.descent=g+6,b.fontSize=b.ascent+b.descent,c.Text.fontPropertiesCache[a]=b;var i,j,k=e.getImageData(0,0,f,h).data,l=k.length,m=4*f,n=0,o=!1;for(i=0;i<g;i++){for(j=0;j<m;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n+=m}for(b.ascent=g-i,n=l-m,o=!1,i=h;g<i;i--){for(j=0;j<m;j+=4)if(255!==k[n+j]){o=!0;break}if(o)break;n-=m}b.descent=i-g,b.descent+=6,b.fontSize=b.ascent+b.descent,c.Text.fontPropertiesCache[a]=b}return b},c.Text.prototype.getBounds=function(a){return this.dirty&&(this.updateText(),this.dirty=!1),PIXI.Sprite.prototype.getBounds.call(this,a)},Object.defineProperty(c.Text.prototype,"text",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a.toString()||"",this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(c.Text.prototype,"cssFont",{get:function(){return this.componentsToFont(this._fontComponents)},set:function(a){a=a||"bold 20pt Arial",this._fontComponents=this.fontToComponents(a),this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"font",{get:function(){return this._fontComponents.fontFamily},set:function(a){a=(a=a||"Arial").trim(),/^(?:inherit|serif|sans-serif|cursive|fantasy|monospace)$/.exec(a)||/['",]/.exec(a)||(a="'"+a+"'"),this._fontComponents.fontFamily=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontSize",{get:function(){var a=this._fontComponents.fontSize;return a&&/(?:^0$|px$)/.exec(a)?parseInt(a,10):a},set:function(a){"number"==typeof(a=a||"0")&&(a+="px"),this._fontComponents.fontSize=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontWeight",{get:function(){return this._fontComponents.fontWeight||"normal"},set:function(a){a=a||"normal",this._fontComponents.fontWeight=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontStyle",{get:function(){return this._fontComponents.fontStyle||"normal"},set:function(a){a=a||"normal",this._fontComponents.fontStyle=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fontVariant",{get:function(){return this._fontComponents.fontVariant||"normal"},set:function(a){a=a||"normal",this._fontComponents.fontVariant=a,this.updateFont(this._fontComponents)}}),Object.defineProperty(c.Text.prototype,"fill",{get:function(){return this.style.fill},set:function(a){a!==this.style.fill&&(this.style.fill=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"align",{get:function(){return this.style.align},set:function(a){a!==this.style.align&&(this.style.align=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"resolution",{get:function(){return this._res},set:function(a){a!==this._res&&(this._res=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"tabs",{get:function(){return this.style.tabs},set:function(a){a!==this.style.tabs&&(this.style.tabs=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"boundsAlignH",{get:function(){return this.style.boundsAlignH},set:function(a){a!==this.style.boundsAlignH&&(this.style.boundsAlignH=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"boundsAlignV",{get:function(){return this.style.boundsAlignV},set:function(a){a!==this.style.boundsAlignV&&(this.style.boundsAlignV=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"stroke",{get:function(){return this.style.stroke},set:function(a){a!==this.style.stroke&&(this.style.stroke=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"strokeThickness",{get:function(){return this.style.strokeThickness},set:function(a){a!==this.style.strokeThickness&&(this.style.strokeThickness=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"wordWrap",{get:function(){return this.style.wordWrap},set:function(a){a!==this.style.wordWrap&&(this.style.wordWrap=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"wordWrapWidth",{get:function(){return this.style.wordWrapWidth},set:function(a){a!==this.style.wordWrapWidth&&(this.style.wordWrapWidth=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"lineSpacing",{get:function(){return this._lineSpacing},set:function(a){a!==this._lineSpacing&&(this._lineSpacing=parseFloat(a),this.dirty=!0,this.parent&&this.updateTransform())}}),Object.defineProperty(c.Text.prototype,"shadowOffsetX",{get:function(){return this.style.shadowOffsetX},set:function(a){a!==this.style.shadowOffsetX&&(this.style.shadowOffsetX=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowOffsetY",{get:function(){return this.style.shadowOffsetY},set:function(a){a!==this.style.shadowOffsetY&&(this.style.shadowOffsetY=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowColor",{get:function(){return this.style.shadowColor},set:function(a){a!==this.style.shadowColor&&(this.style.shadowColor=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowBlur",{get:function(){return this.style.shadowBlur},set:function(a){a!==this.style.shadowBlur&&(this.style.shadowBlur=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowStroke",{get:function(){return this.style.shadowStroke},set:function(a){a!==this.style.shadowStroke&&(this.style.shadowStroke=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"shadowFill",{get:function(){return this.style.shadowFill},set:function(a){a!==this.style.shadowFill&&(this.style.shadowFill=a,this.dirty=!0)}}),Object.defineProperty(c.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width},set:function(a){this.scale.x=a/this.texture.frame.width,this._width=a}}),Object.defineProperty(c.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height},set:function(a){this.scale.y=a/this.texture.frame.height,this._height=a}}),c.Text.fontPropertiesCache={},c.Text.fontPropertiesCanvas=document.createElement("canvas"),c.Text.fontPropertiesContext=c.Text.fontPropertiesCanvas.getContext("2d"),c.BitmapText=function(a,b,d,e,f,g,h){b=b||0,d=d||0,e=e||"",f=f||"",g=g||32,h=h||"left",PIXI.DisplayObjectContainer.call(this),this.type=c.BITMAPTEXT,this.physicsType=c.SPRITE,this.textWidth=0,this.textHeight=0,this.anchor=new c.Point,this._prevAnchor=new c.Point,this._glyphs=[],this._maxWidth=0,this._text=f.toString()||"",this._data=a.cache.getBitmapFont(e),this._font=e,this._fontSize=g,this._align=h,this._tint=16777215,this.updateText(),this.dirty=!1,c.Component.Core.init.call(this,a,b,d,"",null)},c.BitmapText.prototype=Object.create(PIXI.DisplayObjectContainer.prototype),c.BitmapText.prototype.constructor=c.BitmapText,c.Component.Core.install.call(c.BitmapText.prototype,["Angle","AutoCull","Bounds","Destroy","FixedToCamera","InputEnabled","InWorld","LifeSpan","PhysicsBody","Reset"]),c.BitmapText.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.BitmapText.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.BitmapText.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.BitmapText.prototype.preUpdateCore=c.Component.Core.preUpdate,c.BitmapText.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},c.BitmapText.prototype.postUpdate=function(){c.Component.PhysicsBody.postUpdate.call(this),c.Component.FixedToCamera.postUpdate.call(this),this.body&&this.body.type===c.Physics.ARCADE&&(this.textWidth===this.body.sourceWidth&&this.textHeight===this.body.sourceHeight||this.body.setSize(this.textWidth,this.textHeight))},c.BitmapText.prototype.setText=function(a){this.text=a},c.BitmapText.prototype.scanLine=function(a,b,c){for(var d=0,e=0,f=-1,g=0,h=null,i=0<this._maxWidth?this._maxWidth:null,j=[],k=0;k<c.length;k++){var l=k===c.length-1;if(/(?:\r\n|\r|\n)/.test(c.charAt(k)))return{width:e,text:c.substr(0,k),end:l,chars:j};var o,m=c.charCodeAt(k),n=a.chars[m];void 0===n&&(m=32,n=a.chars[m]);var p=h&&n.kerning[h]?n.kerning[h]:0;if(/(\s)/.test(c.charAt(k))&&(f=k,g=e),o=(p+n.texture.width+n.xOffset)*b,i&&i<=e+o&&-1<f)return{width:g||e,text:c.substr(0,k-(k-f)),end:l,chars:j};e+=(n.xAdvance+p)*b,j.push(d+(n.xOffset+p)*b),d+=(n.xAdvance+p)*b,h=m}return{width:e,text:c,end:l,chars:j}},c.BitmapText.prototype.cleanText=function(a,b){void 0===b&&(b="");var c=this._data.font;if(!c)return"";for(var e=a.replace(/\r\n|\n\r|\n|\r/g,"\n").split("\n"),f=0;f<e.length;f++){for(var g="",h=e[f],i=0;i<h.length;i++)g=c.chars[h.charCodeAt(i)]?g.concat(h[i]):g.concat(b);e[f]=g}return e.join("\n")},c.BitmapText.prototype.updateText=function(){var a=this._data.font;if(a){var b=this.text,c=this._fontSize/a.size,d=[],e=0;this.textWidth=0;do{(f=this.scanLine(a,c,b)).y=e,d.push(f),f.width>this.textWidth&&(this.textWidth=f.width),e+=a.lineHeight*c,b=b.substr(f.text.length+1)}while(!1===f.end);this.textHeight=e;for(var g=0,h=0,i=this.textWidth*this.anchor.x,j=this.textHeight*this.anchor.y,k=0;k<d.length;k++){var f=d[k];"right"===this._align?h=this.textWidth-f.width:"center"===this._align&&(h=(this.textWidth-f.width)/2);for(var l=0;l<f.text.length;l++){var m=f.text.charCodeAt(l),n=a.chars[m];void 0===n&&(m=32,n=a.chars[m]);var o=this._glyphs[g];o?o.texture=n.texture:((o=new PIXI.Sprite(n.texture)).name=f.text[l],this._glyphs.push(o)),o.position.x=f.chars[l]+h-i,o.position.y=f.y+n.yOffset*c-j,o.scale.set(c),o.tint=this.tint,o.texture.requiresReTint=!0,o.parent||this.addChild(o),g++}}for(k=g;k<this._glyphs.length;k++)this.removeChild(this._glyphs[k])}},c.BitmapText.prototype.purgeGlyphs=function(){for(var a=this._glyphs.length,b=[],c=0;c<this._glyphs.length;c++)this._glyphs[c].parent!==this?this._glyphs[c].destroy():b.push(this._glyphs[c]);return this._glyphs=[],this._glyphs=b,this.updateText(),a-b.length},c.BitmapText.prototype.updateTransform=function(){!this.dirty&&this.anchor.equals(this._prevAnchor)||(this.updateText(),this.dirty=!1,this._prevAnchor.copyFrom(this.anchor)),PIXI.DisplayObjectContainer.prototype.updateTransform.call(this)},Object.defineProperty(c.BitmapText.prototype,"align",{get:function(){return this._align},set:function(a){a===this._align||"left"!==a&&"center"!==a&&"right"!==a||(this._align=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"tint",{get:function(){return this._tint},set:function(a){a!==this._tint&&(this._tint=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"font",{get:function(){return this._font},set:function(a){a!==this._font&&(this._font=a.trim(),this._data=this.game.cache.getBitmapFont(this._font),this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"fontSize",{get:function(){return this._fontSize},set:function(a){(a=parseInt(a,10))!==this._fontSize&&0<a&&(this._fontSize=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"text",{get:function(){return this._text},set:function(a){a!==this._text&&(this._text=a.toString()||"",this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"maxWidth",{get:function(){return this._maxWidth},set:function(a){a!==this._maxWidth&&(this._maxWidth=a,this.updateText())}}),Object.defineProperty(c.BitmapText.prototype,"smoothed",{get:function(){return!this._data.base.scaleMode},set:function(a){this._data.base.scaleMode=a?0:1}}),c.RetroFont=function(a,b,d,e,f,g,h,i,j,k){if(!a.cache.checkImageKey(b))return!1;null!=g||(g=a.cache.getImage(b).width/d),this.characterWidth=d,this.characterHeight=e,this.characterSpacingX=h||0,this.characterSpacingY=i||0,this.characterPerRow=g,this.offsetX=j||0,this.offsetY=k||0,this.align="left",this.multiLine=!1,this.autoUpperCase=!0,this.customSpacingX=0,this.customSpacingY=0,this.fixedWidth=0,this.fontSet=a.cache.getImage(b),this._text="",this.grabData=[],this.frameData=new c.FrameData;for(var l=this.offsetX,m=this.offsetY,n=0,o=0;o<f.length;o++){var p=this.frameData.addFrame(new c.Frame(o,l,m,this.characterWidth,this.characterHeight));this.grabData[f.charCodeAt(o)]=p.index,++n===this.characterPerRow?(n=0,l=this.offsetX,m+=this.characterHeight+this.characterSpacingY):l+=this.characterWidth+this.characterSpacingX}a.cache.updateFrameData(b,this.frameData),this.stamp=new c.Image(a,0,0,b,0),c.RenderTexture.call(this,a,100,100,"",c.scaleModes.NEAREST),this.type=c.RETROFONT},c.RetroFont.prototype=Object.create(c.RenderTexture.prototype),c.RetroFont.prototype.constructor=c.RetroFont,c.RetroFont.ALIGN_LEFT="left",c.RetroFont.ALIGN_RIGHT="right",c.RetroFont.ALIGN_CENTER="center",c.RetroFont.TEXT_SET1=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~",c.RetroFont.TEXT_SET2=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ",c.RetroFont.TEXT_SET3="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ",c.RetroFont.TEXT_SET4="ABCDEFGHIJKLMNOPQRSTUVWXYZ 0123456789",c.RetroFont.TEXT_SET5="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,/() '!?-*:0123456789",c.RetroFont.TEXT_SET6="ABCDEFGHIJKLMNOPQRSTUVWXYZ!?:;0123456789\"(),-.' ",c.RetroFont.TEXT_SET7="AGMSY+:4BHNTZ!;5CIOU.?06DJPV,(17EKQW\")28FLRX-'39",c.RetroFont.TEXT_SET8="0123456789 .ABCDEFGHIJKLMNOPQRSTUVWXYZ",c.RetroFont.TEXT_SET9="ABCDEFGHIJKLMNOPQRSTUVWXYZ()-0123456789.:,'\"?!",c.RetroFont.TEXT_SET10="ABCDEFGHIJKLMNOPQRSTUVWXYZ",c.RetroFont.TEXT_SET11="ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789",c.RetroFont.prototype.setFixedWidth=function(a,b){void 0===b&&(b="left"),this.fixedWidth=a,this.align=b},c.RetroFont.prototype.setText=function(a,b,c,d,e,f){this.multiLine=b||!1,this.customSpacingX=c||0,this.customSpacingY=d||0,this.align=e||"left",this.autoUpperCase=!f,0<a.length&&(this.text=a)},c.RetroFont.prototype.buildRetroFontText=function(){var a=0,b=0;if(this.clear(),this.multiLine){var d=this._text.split("\n");0<this.fixedWidth?this.resize(this.fixedWidth,d.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0):this.resize(this.getLongestLine()*(this.characterWidth+this.customSpacingX),d.length*(this.characterHeight+this.customSpacingY)-this.customSpacingY,!0);for(var e=0;e<d.length;e++)a=0,this.align===c.RetroFont.ALIGN_RIGHT?a=this.width-d[e].length*(this.characterWidth+this.customSpacingX):this.align===c.RetroFont.ALIGN_CENTER&&(a=this.width/2-d[e].length*(this.characterWidth+this.customSpacingX)/2,a+=this.customSpacingX/2),a<0&&(a=0),this.pasteLine(d[e],a,b,this.customSpacingX),b+=this.characterHeight+this.customSpacingY}else 0<this.fixedWidth?this.resize(this.fixedWidth,this.characterHeight,!0):this.resize(this._text.length*(this.characterWidth+this.customSpacingX),this.characterHeight,!0),a=0,this.align===c.RetroFont.ALIGN_RIGHT?a=this.width-this._text.length*(this.characterWidth+this.customSpacingX):this.align===c.RetroFont.ALIGN_CENTER&&(a=this.width/2-this._text.length*(this.characterWidth+this.customSpacingX)/2,a+=this.customSpacingX/2),a<0&&(a=0),this.pasteLine(this._text,a,0,this.customSpacingX);this.requiresReTint=!0},c.RetroFont.prototype.pasteLine=function(a,b,c,d){for(var e=0;e<a.length;e++)if(" "===a.charAt(e))b+=this.characterWidth+d;else if(0<=this.grabData[a.charCodeAt(e)]&&(this.stamp.frame=this.grabData[a.charCodeAt(e)],this.renderXY(this.stamp,b,c,!1),(b+=this.characterWidth+d)>this.width))break},c.RetroFont.prototype.getLongestLine=function(){var a=0;if(0<this._text.length)for(var b=this._text.split("\n"),c=0;c<b.length;c++)b[c].length>a&&(a=b[c].length);return a},c.RetroFont.prototype.removeUnsupportedCharacters=function(a){for(var b="",c=0;c<this._text.length;c++){var d=this._text[c],e=d.charCodeAt(0);(0<=this.grabData[e]||!a&&"\n"===d)&&(b=b.concat(d))}return b},c.RetroFont.prototype.updateOffset=function(a,b){if(this.offsetX!==a||this.offsetY!==b){for(var c=a-this.offsetX,d=b-this.offsetY,e=this.game.cache.getFrameData(this.stamp.key).getFrames(),f=e.length;f--;)e[f].x+=c,e[f].y+=d;this.buildRetroFontText()}},Object.defineProperty(c.RetroFont.prototype,"text",{get:function(){return this._text},set:function(a){var b;(b=this.autoUpperCase?a.toUpperCase():a)!==this._text&&(this._text=b,this.removeUnsupportedCharacters(this.multiLine),this.buildRetroFontText())}}),Object.defineProperty(c.RetroFont.prototype,"smoothed",{get:function(){return this.stamp.smoothed},set:function(a){this.stamp.smoothed=a,this.buildRetroFontText()}}),c.Rope=function(a,b,d,e,f,g){this.points=[],this.points=g,this._hasUpdateAnimation=!1,this._updateAnimationCallback=null,b=b||0,d=d||0,e=e||null,f=f||null,this.type=c.ROPE,PIXI.Rope.call(this,c.Cache.DEFAULT,this.points),c.Component.Core.init.call(this,a,b,d,e,f)},c.Rope.prototype=Object.create(PIXI.Rope.prototype),c.Rope.prototype.constructor=c.Rope,c.Component.Core.install.call(c.Rope.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Crop","Delta","Destroy","FixedToCamera","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","ScaleMinMax","Smoothed"]),c.Rope.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.Rope.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.Rope.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.Rope.prototype.preUpdateCore=c.Component.Core.preUpdate,c.Rope.prototype.preUpdate=function(){return!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},c.Rope.prototype.update=function(){this._hasUpdateAnimation&&this.updateAnimation.call(this)},c.Rope.prototype.reset=function(a,b){return c.Component.Reset.prototype.reset.call(this,a,b),this},Object.defineProperty(c.Rope.prototype,"updateAnimation",{get:function(){return this._updateAnimation},set:function(a){a&&"function"==typeof a?(this._hasUpdateAnimation=!0,this._updateAnimation=a):(this._hasUpdateAnimation=!1,this._updateAnimation=null)}}),Object.defineProperty(c.Rope.prototype,"segments",{get:function(){for(var a,b,d,e,f,g,h,i,j=[],k=0;k<this.points.length;k++)a=4*k,b=this.vertices[a]*this.scale.x,d=this.vertices[a+1]*this.scale.y,e=this.vertices[a+4]*this.scale.x,f=this.vertices[a+3]*this.scale.y,g=c.Math.difference(b,e),h=c.Math.difference(d,f),b+=this.world.x,d+=this.world.y,i=new c.Rectangle(b,d,g,h),j.push(i);return j}}),c.TileSprite=function(a,b,d,e,f,g,h){b=b||0,d=d||0,e=e||256,f=f||256,g=g||null,h=h||null,this.type=c.TILESPRITE,this.physicsType=c.SPRITE,this._scroll=new c.Point;var i=a.cache.getImage("__default",!0);PIXI.TilingSprite.call(this,new PIXI.Texture(i.base),e,f),c.Component.Core.init.call(this,a,b,d,g,h)},c.TileSprite.prototype=Object.create(PIXI.TilingSprite.prototype),c.TileSprite.prototype.constructor=c.TileSprite,c.Component.Core.install.call(c.TileSprite.prototype,["Angle","Animation","AutoCull","Bounds","BringToTop","Destroy","FixedToCamera","Health","InCamera","InputEnabled","InWorld","LifeSpan","LoadTexture","Overlap","PhysicsBody","Reset","Smoothed"]),c.TileSprite.prototype.preUpdatePhysics=c.Component.PhysicsBody.preUpdate,c.TileSprite.prototype.preUpdateLifeSpan=c.Component.LifeSpan.preUpdate,c.TileSprite.prototype.preUpdateInWorld=c.Component.InWorld.preUpdate,c.TileSprite.prototype.preUpdateCore=c.Component.Core.preUpdate,c.TileSprite.prototype.preUpdate=function(){return 0!==this._scroll.x&&(this.tilePosition.x+=this._scroll.x*this.game.time.physicsElapsed),0!==this._scroll.y&&(this.tilePosition.y+=this._scroll.y*this.game.time.physicsElapsed),!!(this.preUpdatePhysics()&&this.preUpdateLifeSpan()&&this.preUpdateInWorld())&&this.preUpdateCore()},c.TileSprite.prototype.autoScroll=function(a,b){this._scroll.set(a,b)},c.TileSprite.prototype.stopScroll=function(){this._scroll.set(0,0)},c.TileSprite.prototype.destroy=function(a){c.Component.Destroy.prototype.destroy.call(this,a),PIXI.TilingSprite.prototype.destroy.call(this)},c.TileSprite.prototype.reset=function(a,b){return c.Component.Reset.prototype.reset.call(this,a,b),this.tilePosition.x=0,this.tilePosition.y=0,this},c.Device=function(){this.deviceReadyAt=0,this.initialized=!1,this.desktop=!1,this.iOS=!1,this.iOSVersion=0,this.cocoonJS=!1,this.cocoonJSApp=!1,this.wechatMinigame=!1,this.cordova=!1,this.node=!1,this.nodeWebkit=!1,this.electron=!1,this.ejecta=!1,this.crosswalk=!1,this.android=!1,this.chromeOS=!1,this.linux=!1,this.macOS=!1,this.windows=!1,this.windowsPhone=!1,this.canvas=!1,this.canvasBitBltShift=null,this.webGL=!1,this.file=!1,this.fileSystem=!1,this.localStorage=!1,this.worker=!1,this.css3D=!1,this.pointerLock=!1,this.typedArray=!1,this.vibration=!1,this.getUserMedia=!0,this.quirksMode=!1,this.touch=!1,this.mspointer=!1,this.wheelEvent=null,this.arora=!1,this.chrome=!1,this.chromeVersion=0,this.epiphany=!1,this.firefox=!1,this.firefoxVersion=0,this.ie=!1,this.ieVersion=0,this.trident=!1,this.tridentVersion=0,this.edge=!1,this.mobileSafari=!1,this.midori=!1,this.opera=!1,this.safari=!1,this.safariVersion=0,this.webApp=!1,this.silk=!1,this.audioData=!1,this.webAudio=!1,this.ogg=!1,this.opus=!1,this.mp3=!1,this.wav=!1,this.m4a=!1,this.webm=!1,this.dolby=!1,this.oggVideo=!1,this.h264Video=!1,this.mp4Video=!1,this.webmVideo=!1,this.vp9Video=!1,this.hlsVideo=!1,this.iPhone=!1,this.iPhone4=!1,this.iPad=!1,this.pixelRatio=0,this.littleEndian=!1,this.LITTLE_ENDIAN=!1,this.support32bit=!1,this.fullscreen=!1,this.requestFullscreen="",this.cancelFullscreen="",this.fullscreenKeyboard=!1},c.Device=new c.Device,c.Device.onInitialized=new c.Signal,c.Device.whenReady=function(a,b,c){var d=this._readyCheck;if(this.deviceReadyAt||!d)a.call(b,this);else if(d._monitor||c)d._queue=d._queue||[],d._queue.push([a,b]);else{d._monitor=d.bind(this),d._queue=d._queue||[],d._queue.push([a,b]);var e=void 0!==window.cordova,f=navigator.isCocoonJS;"complete"===document.readyState||"interactive"===document.readyState?window.setTimeout(d._monitor,0):e&&!f?document.addEventListener("deviceready",d._monitor,!1):(document.addEventListener("DOMContentLoaded",d._monitor,!1),window.addEventListener("load",d._monitor,!1))}},c.Device._readyCheck=function(){var a=this._readyCheck;if(document.body){if(!this.deviceReadyAt){this.deviceReadyAt=Date.now(),document.removeEventListener("deviceready",a._monitor),document.removeEventListener("DOMContentLoaded",a._monitor),window.removeEventListener("load",a._monitor),this._initialize(),this.initialized=!0,this.onInitialized.dispatch(this);for(var b;b=a._queue.shift();){var c=b[0],d=b[1];c.call(d,this)}this._readyCheck=null,this._initialize=null,this.onInitialized=null}}else window.setTimeout(a._monitor,20)},c.Device._initialize=function(){var m=this;(function(){var a=navigator.userAgent;/Playstation Vita/.test(a)?m.vita=!0:/Kindle/.test(a)||/\bKF[A-Z][A-Z]+/.test(a)||/Silk.*Mobile Safari/.test(a)?m.kindle=!0:/Android/.test(a)?m.android=!0:/CrOS/.test(a)?m.chromeOS=!0:/iP[ao]d|iPhone/i.test(a)?(m.iOS=!0,navigator.appVersion.match(/OS (\d+)/),m.iOSVersion=parseInt(RegExp.$1,10)):/Linux/.test(a)?m.linux=!0:/Mac OS/.test(a)?m.macOS=!0:/Windows/.test(a)&&(m.windows=!0),(/Windows Phone/i.test(a)||/IEMobile/i.test(a))&&(m.android=!1,m.iOS=!1,m.macOS=!1,m.windows=!0,m.windowsPhone=!0);var b=/Silk/.test(a);(m.windows||m.macOS||m.linux&&!b||m.chromeOS)&&(m.desktop=!0),(m.windowsPhone||/Windows NT/i.test(a)&&/Touch/i.test(a))&&(m.desktop=!1)})(),function(){var a=navigator.userAgent;if(/Arora/.test(a)?m.arora=!0:/Edge\/\d+/.test(a)?m.edge=!0:/Chrome\/(\d+)/.test(a)&&!m.windowsPhone?(m.chrome=!0,m.chromeVersion=parseInt(RegExp.$1,10)):/Epiphany/.test(a)?m.epiphany=!0:/Firefox\D+(\d+)/.test(a)?(m.firefox=!0,m.firefoxVersion=parseInt(RegExp.$1,10)):/AppleWebKit/.test(a)&&m.iOS?m.mobileSafari=!0:/MSIE (\d+\.\d+);/.test(a)?(m.ie=!0,m.ieVersion=parseInt(RegExp.$1,10)):/Midori/.test(a)?m.midori=!0:/Opera/.test(a)?m.opera=!0:/Safari\/(\d+)/.test(a)&&!m.windowsPhone?(m.safari=!0,/Version\/(\d+)\./.test(a)&&(m.safariVersion=parseInt(RegExp.$1,10))):/Trident\/(\d+\.\d+)(.*)rv:(\d+\.\d+)/.test(a)&&(m.ie=!0,m.trident=!0,m.tridentVersion=parseInt(RegExp.$1,10),m.ieVersion=parseInt(RegExp.$3,10)),/Silk/.test(a)&&(m.silk=!0),navigator.standalone&&(m.webApp=!0),void 0!==window.cordova&&(m.cordova=!0),"undefined"!=typeof process&&"undefined"!=typeof require&&(m.node=!0),m.node&&"object"==typeof process.versions&&(m.nodeWebkit=!!process.versions["node-webkit"],m.electron=!!process.versions.electron),navigator.isCocoonJS&&(m.cocoonJS=!0),void 0!==window.wx&&(m.wechatMinigame=!0),m.cocoonJS)try{m.cocoonJSApp="undefined"!=typeof CocoonJS}catch(a){m.cocoonJSApp=!1}void 0!==window.ejecta&&(m.ejecta=!0),/Crosswalk/.test(a)&&(m.crosswalk=!0)}(),function(){m.audioData=!!window.Audio,m.webAudio=!(!window.AudioContext&&!window.webkitAudioContext);var a=document.createElement("audio");try{if(a.canPlayType&&(a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(m.ogg=!0),(a.canPlayType('audio/ogg; codecs="opus"').replace(/^no$/,"")||a.canPlayType("audio/opus;").replace(/^no$/,""))&&(m.opus=!0),a.canPlayType("audio/mpeg;").replace(/^no$/,"")&&(m.mp3=!0),a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,"")&&(m.wav=!0),(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;").replace(/^no$/,""))&&(m.m4a=!0),a.canPlayType('audio/webm; codecs="vorbis"').replace(/^no$/,"")&&(m.webm=!0),""!==a.canPlayType('audio/mp4;codecs="ec-3"')))if(m.edge)m.dolby=!0;else if(m.safari&&9<=m.safariVersion&&/Mac OS X (\d+)_(\d+)/.test(navigator.userAgent)){var b=parseInt(RegExp.$1,10),c=parseInt(RegExp.$2,10);(10===b&&11<=c||10<b)&&(m.dolby=!0)}}catch(a){}}(),function(){var a=document.createElement("video");try{a.canPlayType&&(a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,"")&&(m.oggVideo=!0),a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,"")&&(m.h264Video=!0,m.mp4Video=!0),a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")&&(m.webmVideo=!0),a.canPlayType('video/webm; codecs="vp9"').replace(/^no$/,"")&&(m.vp9Video=!0),a.canPlayType('application/x-mpegURL; codecs="avc1.42E01E"').replace(/^no$/,"")&&(m.hlsVideo=!0))}catch(a){}}(),function(){var a,b=document.createElement("p"),c={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};for(var d in document.body.insertBefore(b,null),c)void 0!==b.style[d]&&(b.style[d]="translate3d(1px,1px,1px)",a=window.getComputedStyle(b).getPropertyValue(c[d]));document.body.removeChild(b),m.css3D=void 0!==a&&0<a.length&&"none"!==a}(),function(){var a;m.pixelRatio=window.devicePixelRatio||1,m.iPhone=-1!==navigator.userAgent.toLowerCase().indexOf("iphone"),m.iPhone4=2===m.pixelRatio&&m.iPhone,m.iPad=!!(!(a=-1!==navigator.userAgent.toLowerCase().indexOf("ipad"))&&navigator.userAgent.match(/Mac/)&&navigator.maxTouchPoints&&2<navigator.maxTouchPoints)||a,"undefined"!=typeof Int8Array?m.typedArray=!0:m.typedArray=!1,"undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint32Array&&(m.littleEndian=function(){var a=new ArrayBuffer(4),b=new Uint8Array(a),c=new Uint32Array(a);return b[0]=161,b[1]=178,b[2]=195,b[3]=212,3569595041===c[0]||2712847316!==c[0]&&null}(),m.LITTLE_ENDIAN=m.littleEndian),m.support32bit="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof Int32Array&&null!==m.littleEndian&&function(){if(void 0===Uint8ClampedArray)return!1;var b=PIXI.CanvasPool.create(this,1,1).getContext("2d");if(!b)return!1;var c=b.createImageData(1,1);return PIXI.CanvasPool.remove(this),c.data instanceof Uint8ClampedArray}(),navigator.vibrate=navigator.vibrate||navigator.webkitVibrate||navigator.mozVibrate||navigator.msVibrate,navigator.vibrate&&(m.vibration=!0)}(),function(){m.canvas=!!window.CanvasRenderingContext2D||m.cocoonJS;try{m.localStorage=!!localStorage.getItem}catch(a){m.localStorage=!1}m.file=!!(window.File&&window.FileReader&&window.FileList&&window.Blob),m.fileSystem=!!window.requestFileSystem;var a={stencil:!0};m.webGL=function(){try{var b=document.createElement("canvas");return b.screencanvas=!1,!!window.WebGLRenderingContext&&(b.getContext("webgl",a)||b.getContext("experimental-webgl",a))}catch(a){return!1}}(),m.webGL=!!m.webGL,m.worker=!!window.Worker,m.pointerLock="pointerLockElement"in document||"mozPointerLockElement"in document||"webkitPointerLockElement"in document,m.quirksMode="CSS1Compat"!==document.compatMode,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia||navigator.oGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,m.getUserMedia=m.getUserMedia&&!!navigator.getUserMedia&&!!window.URL,m.firefox&&m.firefoxVersion<21&&(m.getUserMedia=!1),!m.iOS&&(m.ie||m.firefox||m.chrome)&&(m.canvasBitBltShift=!0),(m.safari||m.mobileSafari)&&(m.canvasBitBltShift=!1)}(),function(){for(var a=["requestFullscreen","requestFullScreen","webkitRequestFullscreen","webkitRequestFullScreen","msRequestFullscreen","msRequestFullScreen","mozRequestFullScreen","mozRequestFullscreen"],b=document.createElement("div"),c=0;c<a.length;c++)if(b[a[c]]){m.fullscreen=!0,m.requestFullscreen=a[c];break}var d=["cancelFullScreen","exitFullscreen","webkitCancelFullScreen","webkitExitFullscreen","msCancelFullScreen","msExitFullscreen","mozCancelFullScreen","mozExitFullscreen"];if(m.fullscreen)for(c=0;c<d.length;c++)if(document[d[c]]){m.cancelFullscreen=d[c];break}window.Element&&Element.ALLOW_KEYBOARD_INPUT&&(m.fullscreenKeyboard=!0)}(),("ontouchstart"in document.documentElement||window.navigator.maxTouchPoints&&1<=window.navigator.maxTouchPoints)&&(m.touch=!0),(window.PointerEvent||window.MSPointerEvent||window.navigator.msPointerEnabled||window.navigator.pointerEnabled)&&(m.mspointer=!0),m.cocoonJS||("onwheel"in window||m.ie&&"WheelEvent"in window?m.wheelEvent="wheel":"onmousewheel"in window?m.wheelEvent="mousewheel":m.firefox&&"MouseScrollEvent"in window&&(m.wheelEvent="DOMMouseScroll"))},c.Device.canPlayAudio=function(a){return!!("mp3"===a&&this.mp3||"ogg"===a&&(this.ogg||this.opus)||"m4a"===a&&this.m4a||"opus"===a&&this.opus||"wav"===a&&this.wav||"webm"===a&&this.webm||"mp4"===a&&this.dolby)},c.Device.canPlayVideo=function(a){return!!("webm"===a&&(this.webmVideo||this.vp9Video)||"mp4"===a&&(this.mp4Video||this.h264Video)||("ogg"===a||"ogv"===a)&&this.oggVideo||"mpeg"===a&&this.hlsVideo)},c.Device.isConsoleOpen=function(){return!(!window.console||!window.console.firebug)||!(!window.console||(console.clear,!console.profiles))&&0<console.profiles.length},c.Device.isAndroidStockBrowser=function(){var a=window.navigator.userAgent.match(/Android.*AppleWebKit\/([\d.]+)/);return a&&a[1]<537},c.Canvas={create:function(a,b,c,d,e){b=b||256,c=c||256;var f=e?document.createElement("canvas"):PIXI.CanvasPool.create(a,b,c);return"string"==typeof d&&""!==d&&(f.id=d),f.width=b,f.height=c,f.style.display="block",f},setBackgroundColor:function(a,b){return b=b||"rgb(0,0,0)",a.style.backgroundColor=b,a},setTouchAction:function(a,b){return b=b||"none",a.style.msTouchAction=b,a.style["ms-touch-action"]=b,a.style["touch-action"]=b,a},setUserSelect:function(a,b){return b=b||"none",a.style["-webkit-touch-callout"]=b,a.style["-webkit-user-select"]=b,a.style["-khtml-user-select"]=b,a.style["-moz-user-select"]=b,a.style["-ms-user-select"]=b,a.style["user-select"]=b,a.style["-webkit-tap-highlight-color"]="rgba(0, 0, 0, 0)",a},addToDOM:function(a,b,c){var d;return void 0===c&&(c=!0),b&&("string"==typeof b?d=document.getElementById(b):"object"==typeof b&&1===b.nodeType&&(d=b)),d||(d=document.body),c&&d.style&&(d.style.overflow="hidden"),d.appendChild(a),a},removeFromDOM:function(a){a.parentNode&&a.parentNode.removeChild(a)},setTransform:function(a,b,c,d,e,f,g){return a.setTransform(d,f,g,e,b,c),a},setSmoothingEnabled:function(a,b){var d=c.Canvas.getSmoothingPrefix(a);return d&&(a[d]=b),a},getSmoothingPrefix:function(a){var b=["i","webkitI","msI","mozI","oI"];for(var c in b){var d=b[c]+"mageSmoothingEnabled";if(d in a)return d}return null},getSmoothingEnabled:function(a){var b=c.Canvas.getSmoothingPrefix(a);if(b)return a[b]},setImageRenderingCrisp:function(a){for(var b=["optimizeSpeed","crisp-edges","-moz-crisp-edges","-webkit-optimize-contrast","optimize-contrast","pixelated"],c=0;c<b.length;c++)a.style["image-rendering"]=b[c];return a.style.msInterpolationMode="nearest-neighbor",a},setImageRenderingBicubic:function(a){return a.style["image-rendering"]="auto",a.style.msInterpolationMode="bicubic",a}},c.RequestAnimationFrame=function(a,b){void 0===b&&(b=!1),this.game=a,this.isRunning=!1,this.forceSetTimeOut=b;for(var c=["ms","moz","webkit","o"],d=0;d<c.length&&!window.requestAnimationFrame;d++)window.requestAnimationFrame=window[c[d]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[c[d]+"CancelAnimationFrame"];this._isSetTimeOut=!1,this._onLoop=null,this._timeOutID=null},c.RequestAnimationFrame.prototype={start:function(){this.isRunning=!0;var a=this;!window.requestAnimationFrame||this.forceSetTimeOut?(this._isSetTimeOut=!0,this._onLoop=function(){return a.updateSetTimeout()},this._timeOutID=window.setTimeout(this._onLoop,0)):(this._isSetTimeOut=!1,this._onLoop=function(b){return a.updateRAF(b)},this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateRAF:function(a){this.isRunning&&(this.game.update(Math.floor(a)),this._timeOutID=window.requestAnimationFrame(this._onLoop))},updateSetTimeout:function(){this.isRunning&&(this.game.update(Date.now()),this._timeOutID=window.setTimeout(this._onLoop,this.game.time.timeToCall))},stop:function(){this._isSetTimeOut?clearTimeout(this._timeOutID):window.cancelAnimationFrame(this._timeOutID),this.isRunning=!1},isSetTimeOut:function(){return this._isSetTimeOut},isRAF:function(){return!1===this._isSetTimeOut}},c.RequestAnimationFrame.prototype.constructor=c.RequestAnimationFrame,c.Math={PI2:2*Math.PI,between:function(a,b){return Math.floor(Math.random()*(b-a+1)+a)},fuzzyEqual:function(a,b,c){return void 0===c&&(c=1e-4),Math.abs(a-b)<c},fuzzyLessThan:function(a,b,c){return void 0===c&&(c=1e-4),a<b+c},fuzzyGreaterThan:function(a,b,c){return void 0===c&&(c=1e-4),b-c<a},fuzzyCeil:function(a,b){return void 0===b&&(b=1e-4),Math.ceil(a-b)},fuzzyFloor:function(a,b){return void 0===b&&(b=1e-4),Math.floor(a+b)},average:function(){for(var a=0,b=arguments.length,c=0;c<b;c++)a+=+arguments[c];return a/b},shear:function(a){return a%1},snapTo:function(a,b,c){return void 0===c&&(c=0),0===b?a:(a-=c,c+(a=b*Math.round(a/b)))},snapToFloor:function(a,b,c){return void 0===c&&(c=0),0===b?a:(a-=c,c+(a=b*Math.floor(a/b)))},snapToCeil:function(a,b,c){return void 0===c&&(c=0),0===b?a:(a-=c,c+(a=b*Math.ceil(a/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},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},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},rotateToAngle:function(a,b,d){return void 0===d&&(d=.05),a===b||(Math.abs(b-a)<=d||Math.abs(b-a)>=c.Math.PI2-d?a=b:(Math.abs(b-a)>Math.PI&&(b<a?b+=c.Math.PI2:b-=c.Math.PI2),a<b?a+=d:b<a&&(a-=d))),a},getShortestAngle:function(a,b){var c=b-a;return 0===c?0:c-360*Math.floor((c- -180)/360)},angleBetween:function(a,b,c,d){return Math.atan2(d-b,c-a)},angleBetweenY:function(a,b,c,d){return Math.atan2(c-a,d-b)},angleBetweenPoints:function(a,b){return Math.atan2(b.y-a.y,b.x-a.x)},angleBetweenPointsY:function(a,b){return Math.atan2(b.x-a.x,b.y-a.y)},reverseAngle:function(a){return this.normalizeAngle(a+Math.PI,!0)},normalizeAngle:function(a){return 0<=(a%=2*Math.PI)?a:a+2*Math.PI},maxAdd:function(a,b,c){return Math.min(a+b,c)},minSub:function(a,b,c){return Math.max(a-b,c)},wrap:function(a,b,c){var d=c-b;if(d<=0)return 0;var e=(a-b)%d;return e<0&&(e+=d),e+b},wrapValue:function(a,b,c){return((a=Math.abs(a))+(b=Math.abs(b)))%(c=Math.abs(c))},isOdd:function(a){return!!(1&a)},isEven:function(a){return!(1&a)},min:function(){if(1===arguments.length&&"object"==typeof arguments[0])var a=arguments[0];else a=arguments;for(var b=1,c=0,d=a.length;b<d;b++)a[b]<a[c]&&(c=b);return a[c]},max:function(){if(1===arguments.length&&"object"==typeof arguments[0])var a=arguments[0];else a=arguments;for(var b=1,c=0,d=a.length;b<d;b++)a[b]>a[c]&&(c=b);return a[c]},minProperty:function(a){if(2===arguments.length&&"object"==typeof arguments[1])var b=arguments[1];else b=arguments.slice(1);for(var c=1,d=0,e=b.length;c<e;c++)b[c][a]<b[d][a]&&(d=c);return b[d][a]},maxProperty:function(a){if(2===arguments.length&&"object"==typeof arguments[1])var b=arguments[1];else b=arguments.slice(1);for(var c=1,d=0,e=b.length;c<e;c++)b[c][a]>b[d][a]&&(d=c);return b[d][a]},wrapAngle:function(a,b){return b?this.wrap(a,-Math.PI,Math.PI):this.wrap(a,-180,180)},linearInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return b<0?this.linear(a[0],a[1],d):1<b?this.linear(a[c],a[c-1],c-d):this.linear(a[e],a[c<e+1?c:e+1],d-e)},bezierInterpolation:function(a,b){for(var c=0,d=a.length-1,e=0;e<=d;e++)c+=Math.pow(1-b,d-e)*Math.pow(b,e)*a[e]*this.bernstein(d,e);return c},catmullRomInterpolation:function(a,b){var c=a.length-1,d=c*b,e=Math.floor(d);return a[0]===a[c]?(b<0&&(e=Math.floor(d=c*(1+b))),this.catmullRom(a[(e-1+c)%c],a[e],a[(e+1)%c],a[(e+2)%c],d-e)):b<0?a[0]-(this.catmullRom(a[0],a[0],a[1],a[1],-d)-a[0]):1<b?a[c]-(this.catmullRom(a[c],a[c],a[c-1],a[c-1],d-c)-a[c]):this.catmullRom(a[e?e-1:0],a[e],a[c<e+1?c:e+1],a[c<e+2?c:e+2],d-e)},linear:function(a,b,c){return(b-a)*c+a},bernstein:function(a,b){return this.factorial(a)/this.factorial(b)/this.factorial(a-b)},factorial:function(a){if(0===a)return 1;for(var b=a;--a;)b*=a;return b},catmullRom:function(a,b,c,d,e){var f=.5*(c-a),g=.5*(d-b),h=e*e;return(2*b-2*c+f+g)*(e*h)+(-3*b+3*c-2*f-g)*h+f*e+b},difference:function(a,b){return Math.abs(a-b)},roundAwayFromZero:function(a){return 0<a?Math.ceil(a):Math.floor(a)},sinCosGenerator:function(a,b,c,d){void 0===b&&(b=1),void 0===c&&(c=1),void 0===d&&(d=1);for(var e=b,f=c,g=d*Math.PI/a,h=[],i=[],j=0;j<a;j++)e+=(f-=e*g)*g,h[j]=f,i[j]=e;return{sin:i,cos:h,length:a}},distance:function(a,b,c,d){var e=a-c,f=b-d;return Math.sqrt(e*e+f*f)},distanceSq:function(a,b,c,d){var e=a-c,f=b-d;return e*e+f*f},distancePow:function(a,b,c,d,e){return void 0===e&&(e=2),Math.sqrt(Math.pow(c-a,e)+Math.pow(d-b,e))},clamp:function(a,b,c){return a<b?b:c<a?c:a},clampBottom:function(a,b){return a<b?b:a},within:function(a,b,c){return Math.abs(a-b)<=c},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,b,c){return(a=Math.max(0,Math.min(1,(a-b)/(c-b))))*a*(3-2*a)},smootherstep:function(a,b,c){return(a=Math.max(0,Math.min(1,(a-b)/(c-b))))*a*a*(a*(6*a-15)+10)},sign:function(a){return a<0?-1:0<a?1:0},percent:function(a,b,c){return void 0===c&&(c=0),b<a||b<c?1:a<c||a<c?0:(a-c)/b}};var k=Math.PI/180,l=180/Math.PI;return c.Math.degToRad=function(a){return a*k},c.Math.radToDeg=function(a){return a*l},c.RandomDataGenerator=function(a){void 0===a&&(a=[]),this.c=1,this.s0=0,this.s1=0,this.s2=0,"string"==typeof a?this.state(a):this.sow(a)},c.RandomDataGenerator.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},sow:function(a){if(this.s0=this.hash(" "),this.s1=this.hash(this.s0),this.s2=this.hash(this.s1),this.c=1,a)for(var b=0;b<a.length&&null!=a[b];b++){var c=a[b];this.s0-=this.hash(c),this.s0+=~~(this.s0<0),this.s1-=this.hash(c),this.s1+=~~(this.s1<0),this.s2-=this.hash(c),this.s2+=~~(this.s2<0)}},hash:function(a){var b,c,d;for(d=4022871197,a=a.toString(),c=0;c<a.length;c++)b=.02519603282416938*(d+=a.charCodeAt(c)),b-=d=b>>>0,d=(b*=d)>>>0,d+=4294967296*(b-=d);return 2.3283064365386963e-10*(d>>>0)},integer:function(){return 4294967296*this.rnd.apply(this)},frac:function(){return this.rnd.apply(this)+11102230246251565e-32*(2097152*this.rnd.apply(this)|0)},real:function(){return this.integer()+this.frac()},integerInRange:function(a,b){return Math.floor(this.realInRange(0,b-a+1)+a)},between:function(a,b){return this.integerInRange(a,b)},realInRange:function(a,b){return this.frac()*(b-a)+a},normal:function(){return 1-2*this.frac()},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},pick:function(a){return a[this.integerInRange(0,a.length-1)]},sign:function(){return this.pick([-1,1])},weightedPick:function(a){return a[~~(Math.pow(this.frac(),2)*(a.length-1)+.5)]},timestamp:function(a,b){return this.realInRange(a||9466848e5,b||1577862e6)},angle:function(){return this.integerInRange(-180,180)},state:function(a){return"string"==typeof a&&a.match(/^!rnd/)&&(a=a.split(","),this.c=parseFloat(a[1]),this.s0=parseFloat(a[2]),this.s1=parseFloat(a[3]),this.s2=parseFloat(a[4])),["!rnd",this.c,this.s0,this.s1,this.s2].join(",")}},c.RandomDataGenerator.prototype.constructor=c.RandomDataGenerator,c.QuadTree=function(a,b,c,d,e,f,g){this.maxObjects=10,this.maxLevels=4,this.level=0,this.bounds={},this.objects=[],this.nodes=[],this._empty=[],this.reset(a,b,c,d,e,f,g)},c.QuadTree.prototype={reset:function(a,b,c,d,e,f,g){this.maxObjects=e||10,this.maxLevels=f||4,this.level=g||0,this.bounds={x:Math.round(a),y:Math.round(b),width:c,height:d,subWidth:Math.floor(c/2),subHeight:Math.floor(d/2),right:Math.round(a)+Math.floor(c/2),bottom:Math.round(b)+Math.floor(d/2)},this.objects.length=0,this.nodes.length=0},populate:function(a){a.forEach(this.populateHandler,this,!0)},populateHandler:function(a){a.body&&a.exists&&this.insert(a.body)},split:function(){this.nodes[0]=new c.QuadTree(this.bounds.right,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[1]=new c.QuadTree(this.bounds.x,this.bounds.y,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[2]=new c.QuadTree(this.bounds.x,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1),this.nodes[3]=new c.QuadTree(this.bounds.right,this.bounds.bottom,this.bounds.subWidth,this.bounds.subHeight,this.maxObjects,this.maxLevels,this.level+1)},insert:function(a){var b,c=0;if(null==this.nodes[0]||-1===(b=this.getIndex(a))){if(this.objects.push(a),this.objects.length>this.maxObjects&&this.level<this.maxLevels)for(null==this.nodes[0]&&this.split();c<this.objects.length;)-1!==(b=this.getIndex(this.objects[c]))?this.nodes[b].insert(this.objects.splice(c,1)[0]):c++}else this.nodes[b].insert(a)},getIndex:function(a){var b=-1;return a.x<this.bounds.right&&a.right<this.bounds.right?a.y<this.bounds.bottom&&a.bottom<this.bounds.bottom?b=1:a.y>this.bounds.bottom&&(b=2):a.x>this.bounds.right&&(a.y<this.bounds.bottom&&a.bottom<this.bounds.bottom?b=0:a.y>this.bounds.bottom&&(b=3)),b},retrieve:function(a){if(a instanceof c.Rectangle)var b=this.objects,d=this.getIndex(a);else{if(!a.body)return this._empty;b=this.objects,d=this.getIndex(a.body)}return this.nodes[0]&&(b=-1!==d?b.concat(this.nodes[d].retrieve(a)):(b=(b=(b=b.concat(this.nodes[0].retrieve(a))).concat(this.nodes[1].retrieve(a))).concat(this.nodes[2].retrieve(a))).concat(this.nodes[3].retrieve(a))),b},clear:function(){this.objects.length=0;for(var a=this.nodes.length;a--;)this.nodes[a].clear(),this.nodes.splice(a,1);this.nodes.length=0}},c.QuadTree.prototype.constructor=c.QuadTree,c.Net=function(a){this.game=a},c.Net.prototype={getHostName:function(){return window.location&&window.location.hostname?window.location.hostname:null},checkDomainName:function(a){return-1!==window.location.hostname.indexOf(a)},updateQueryString:function(a,b,c,d){void 0===c&&(c=!1),void 0!==d&&""!==d||(d=window.location.href);var e="",f=new RegExp("([?|&])"+a+"=.*?(&|#|$)(.*)","gi");if(f.test(d))e=null!=b?d.replace(f,"$1"+a+"="+b+"$2$3"):d.replace(f,"$1$3").replace(/(&|\?)$/,"");else if(null!=b){var g=-1!==d.indexOf("?")?"&":"?",h=d.split("#");d=h[0]+g+a+"="+b,h[1]&&(d+="#"+h[1]),e=d}else e=d;if(!c)return e;window.location.href=e},getQueryString:function(a){void 0===a&&(a="");var b={},c=location.search.substring(1).split("&");for(var d in c){var e=c[d].split("=");if(1<e.length){if(a&&a===this.decodeURI(e[0]))return this.decodeURI(e[1]);b[this.decodeURI(e[0])]=this.decodeURI(e[1])}}return b},decodeURI:function(a){return decodeURIComponent(a.replace(/\+/g," "))}},c.Net.prototype.constructor=c.Net,c.TweenManager=function(a){this.game=a,this.frameBased=!1,this._tweens=[],this._add=[],this.easeMap={Power0:c.Easing.Power0,Power1:c.Easing.Power1,Power2:c.Easing.Power2,Power3:c.Easing.Power3,Power4:c.Easing.Power4,Linear:c.Easing.Linear.None,Quad:c.Easing.Quadratic.Out,Cubic:c.Easing.Cubic.Out,Quart:c.Easing.Quartic.Out,Quint:c.Easing.Quintic.Out,Sine:c.Easing.Sinusoidal.Out,Expo:c.Easing.Exponential.Out,Circ:c.Easing.Circular.Out,Elastic:c.Easing.Elastic.Out,Back:c.Easing.Back.Out,Bounce:c.Easing.Bounce.Out,"Quad.easeIn":c.Easing.Quadratic.In,"Cubic.easeIn":c.Easing.Cubic.In,"Quart.easeIn":c.Easing.Quartic.In,"Quint.easeIn":c.Easing.Quintic.In,"Sine.easeIn":c.Easing.Sinusoidal.In,"Expo.easeIn":c.Easing.Exponential.In,"Circ.easeIn":c.Easing.Circular.In,"Elastic.easeIn":c.Easing.Elastic.In,"Back.easeIn":c.Easing.Back.In,"Bounce.easeIn":c.Easing.Bounce.In,"Quad.easeOut":c.Easing.Quadratic.Out,"Cubic.easeOut":c.Easing.Cubic.Out,"Quart.easeOut":c.Easing.Quartic.Out,"Quint.easeOut":c.Easing.Quintic.Out,"Sine.easeOut":c.Easing.Sinusoidal.Out,"Expo.easeOut":c.Easing.Exponential.Out,"Circ.easeOut":c.Easing.Circular.Out,"Elastic.easeOut":c.Easing.Elastic.Out,"Back.easeOut":c.Easing.Back.Out,"Bounce.easeOut":c.Easing.Bounce.Out,"Quad.easeInOut":c.Easing.Quadratic.InOut,"Cubic.easeInOut":c.Easing.Cubic.InOut,"Quart.easeInOut":c.Easing.Quartic.InOut,"Quint.easeInOut":c.Easing.Quintic.InOut,"Sine.easeInOut":c.Easing.Sinusoidal.InOut,"Expo.easeInOut":c.Easing.Exponential.InOut,"Circ.easeInOut":c.Easing.Circular.InOut,"Elastic.easeInOut":c.Easing.Elastic.InOut,"Back.easeInOut":c.Easing.Back.InOut,"Bounce.easeInOut":c.Easing.Bounce.InOut},this.game.onPause.add(this._pauseAll,this),this.game.onResume.add(this._resumeAll,this)},c.TweenManager.prototype={getAll:function(){return this._tweens},removeAll:function(){for(var a=0;a<this._tweens.length;a++)this._tweens[a].pendingDelete=!0;this._add=[]},removeFrom:function(a,b){if(void 0===b&&(b=!0),Array.isArray(a))for(d=0,e=a.length;d<e;d++)this.removeFrom(a[d]);else if(a.type===c.GROUP&&b)for(var d=0,e=a.children.length;d<e;d++)this.removeFrom(a.children[d]);else{for(d=0,e=this._tweens.length;d<e;d++)a===this._tweens[d].target&&this.remove(this._tweens[d]);for(d=0,e=this._add.length;d<e;d++)a===this._add[d].target&&this.remove(this._add[d])}},add:function(a){(a._manager=this)._add.push(a)},create:function(a){return new c.Tween(a,this.game,this)},remove:function(a){var b=this._tweens.indexOf(a);-1!==b?this._tweens[b].pendingDelete=!0:-1!==(b=this._add.indexOf(a))&&(this._add[b].pendingDelete=!0)},update:function(){var a=this._add.length,b=this._tweens.length;if(0===b&&0===a)return!1;for(var c=0;c<b;)this._tweens[c].update(this.game.time.time)?c++:(this._tweens.splice(c,1),b--);return 0<a&&(this._tweens=this._tweens.concat(this._add),this._add.length=0),!0},isTweening:function(a){return this._tweens.some(function(b){return b.target===a})},_pauseAll:function(){for(var a=this._tweens.length-1;0<=a;a--)this._tweens[a]._pause()},_resumeAll:function(){for(var a=this._tweens.length-1;0<=a;a--)this._tweens[a]._resume()},pauseAll:function(){for(var a=this._tweens.length-1;0<=a;a--)this._tweens[a].pause()},resumeAll:function(){for(var a=this._tweens.length-1;0<=a;a--)this._tweens[a].resume(!0)}},c.TweenManager.prototype.constructor=c.TweenManager,c.Tween=function(a,b,d){this.game=b,this.target=a,this.manager=d,this.timeline=[],this.reverse=!1,this.timeScale=1,this.repeatCounter=0,this.pendingDelete=!1,this.onStart=new c.Signal,this.onLoop=new c.Signal,this.onRepeat=new c.Signal,this.onChildComplete=new c.Signal,this.onComplete=new c.Signal,this.isRunning=!1,this.current=0,this.properties={},this.chainedTween=null,this.isPaused=!1,this.frameBased=d.frameBased,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,this._pausedTime=0,this._codePaused=!1,this._hasStarted=!1},c.Tween.prototype={to:function(a,b,d,e,f,g,h){return(void 0===b||b<=0)&&(b=1e3),null!=d||(d=c.Easing.Default),void 0===e&&(e=!1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=!1),"string"==typeof d&&this.manager.easeMap[d]&&(d=this.manager.easeMap[d]),this.isRunning||(this.timeline.push(new c.TweenData(this).to(a,b,d,f,g,h)),e&&this.start()),this},from:function(a,b,d,e,f,g,h){return void 0===b&&(b=1e3),null!=d||(d=c.Easing.Default),void 0===e&&(e=!1),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=!1),"string"==typeof d&&this.manager.easeMap[d]&&(d=this.manager.easeMap[d]),this.isRunning||(this.timeline.push(new c.TweenData(this).from(a,b,d,f,g,h)),e&&this.start()),this},start:function(a){if(void 0===a&&(a=0),null===this.game||null===this.target||0===this.timeline.length||this.isRunning)return this;for(var b=0;b<this.timeline.length;b++)for(var c in this.timeline[b].vEnd)this.properties[c]=this.target[c]||0,Array.isArray(this.properties[c])||(this.properties[c]*=1);for(b=0;b<this.timeline.length;b++)this.timeline[b].loadValues();return this.manager.add(this),this.isRunning=!0,(a<0||a>this.timeline.length-1)&&(a=0),this.current=a,this.timeline[this.current].start(),this},stop:function(a){return void 0===a&&(a=!1),this.isRunning=!1,this._onUpdateCallback=null,this._onUpdateCallbackContext=null,a&&(this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start()),this.manager.remove(this),this},updateTweenData:function(a,b,c){if(0===this.timeline.length)return this;if(void 0===c&&(c=0),-1===c)for(var d=0;d<this.timeline.length;d++)this.timeline[d][a]=b;else this.timeline[c][a]=b;return this},delay:function(a,b){return this.updateTweenData("delay",a,b)},repeat:function(a,b,c){return void 0===b&&(b=0),this.updateTweenData("repeatCounter",a,c),this.updateTweenData("repeatDelay",b,c)},repeatDelay:function(a,b){return this.updateTweenData("repeatDelay",a,b)},yoyo:function(a,b,c){return void 0===b&&(b=0),this.updateTweenData("yoyo",a,c),this.updateTweenData("yoyoDelay",b,c)},yoyoDelay:function(a,b){return this.updateTweenData("yoyoDelay",a,b)},easing:function(a,b){return"string"==typeof a&&this.manager.easeMap[a]&&(a=this.manager.easeMap[a]),this.updateTweenData("easingFunction",a,b)},interpolation:function(a,b,d){return void 0===b&&(b=c.Math),this.updateTweenData("interpolationFunction",a,d),this.updateTweenData("interpolationContext",b,d)},repeatAll:function(a){return void 0===a&&(a=0),this.repeatCounter=a,this},chain:function(){for(var a=arguments.length;a--;)0<a?arguments[a-1].chainedTween=arguments[a]:this.chainedTween=arguments[a];return this},loop:function(a){return void 0===a&&(a=!0),this.repeatCounter=a?-1:0,this},onUpdateCallback:function(a,b){return this._onUpdateCallback=a,this._onUpdateCallbackContext=b,this},pause:function(){this.isPaused=!0,this._codePaused=!0,this._pausedTime=this.game.time.time},_pause:function(){this._codePaused||(this.isPaused=!0,this._pausedTime=this.game.time.time)},resume:function(){if(this.isPaused){this.isPaused=!1,this._codePaused=!1;for(var a=0;a<this.timeline.length;a++)this.timeline[a].isRunning||(this.timeline[a].startTime+=this.game.time.time-this._pausedTime)}},_resume:function(){this._codePaused||this.resume()},update:function(a){if(this.pendingDelete||!this.target)return!1;if(this.isPaused)return!0;var b=this.timeline[this.current].update(a);if(b===c.TweenData.PENDING)return!0;if(b===c.TweenData.RUNNING)return this._hasStarted||(this.onStart.dispatch(this.target,this),this._hasStarted=!0),null!==this._onUpdateCallback&&this._onUpdateCallback.call(this._onUpdateCallbackContext,this,this.timeline[this.current].value,this.timeline[this.current]),this.isRunning;if(b===c.TweenData.LOOPED)return-1===this.timeline[this.current].repeatCounter?this.onLoop.dispatch(this.target,this):this.onRepeat.dispatch(this.target,this),!0;if(b===c.TweenData.COMPLETE){var d=!1;return this.reverse?--this.current<0&&(this.current=this.timeline.length-1,d=!0):++this.current===this.timeline.length&&(d=!(this.current=0)),d?-1===this.repeatCounter?(this.timeline[this.current].start(),this.onLoop.dispatch(this.target,this),!0):0<this.repeatCounter?(this.repeatCounter--,this.timeline[this.current].start(),this.onRepeat.dispatch(this.target,this),!0):(this.isRunning=!1,this.onComplete.dispatch(this.target,this),this._hasStarted=!1,this.chainedTween&&this.chainedTween.start(),!1):(this.onChildComplete.dispatch(this.target,this),this.timeline[this.current].start(),!0)}},generateData:function(a,b){if(null===this.game||null===this.target)return null;void 0===a&&(a=60),void 0===b&&(b=[]);for(var c=0;c<this.timeline.length;c++)for(var d in this.timeline[c].vEnd)this.properties[d]=this.target[d]||0,Array.isArray(this.properties[d])||(this.properties[d]*=1);for(c=0;c<this.timeline.length;c++)this.timeline[c].loadValues();for(c=0;c<this.timeline.length;c++)b=b.concat(this.timeline[c].generateData(a));return b}},Object.defineProperty(c.Tween.prototype,"totalDuration",{get:function(){for(var a=0,b=0;b<this.timeline.length;b++)a+=this.timeline[b].duration;return a}}),c.Tween.prototype.constructor=c.Tween,c.TweenData=function(a){this.parent=a,this.game=a.game,this.vStart={},this.vStartCache={},this.vEnd={},this.vEndCache={},this.duration=1e3,this.percent=0,this.value=0,this.repeatCounter=0,this.repeatDelay=0,this.repeatTotal=0,this.interpolate=!1,this.yoyo=!1,this.yoyoDelay=0,this.inReverse=!1,this.delay=0,this.dt=0,this.startTime=null,this.easingFunction=c.Easing.Default,this.interpolationFunction=c.Math.linearInterpolation,this.interpolationContext=c.Math,this.isRunning=!1,this.isFrom=!1},c.TweenData.PENDING=0,c.TweenData.RUNNING=1,c.TweenData.LOOPED=2,c.TweenData.COMPLETE=3,c.TweenData.prototype={to:function(a,b,c,d,e,f){return this.vEnd=a,this.duration=b,this.easingFunction=c,this.delay=d,this.repeatTotal=e,this.yoyo=f,this.isFrom=!1,this},from:function(a,b,c,d,e,f){return this.vEnd=a,this.duration=b,this.easingFunction=c,this.delay=d,this.repeatTotal=e,this.yoyo=f,this.isFrom=!0,this},start:function(){if(this.startTime=this.game.time.time+this.delay,this.parent.reverse?this.dt=this.duration:this.dt=0,0<this.delay?this.isRunning=!1:this.isRunning=!0,this.isFrom)for(var a in this.vStartCache)this.vStart[a]=this.vEndCache[a],this.vEnd[a]=this.vStartCache[a],this.parent.target[a]=this.vStart[a];return this.value=0,this.yoyoCounter=0,this.repeatCounter=this.repeatTotal,this},loadValues:function(){for(var a in this.parent.properties){if(this.vStart[a]=this.parent.properties[a],Array.isArray(this.vEnd[a])){if(0===this.vEnd[a].length)continue;0===this.percent&&(this.vEnd[a]=[this.vStart[a]].concat(this.vEnd[a]))}void 0!==this.vEnd[a]?("string"==typeof this.vEnd[a]&&(this.vEnd[a]=this.vStart[a]+parseFloat(this.vEnd[a],10)),this.parent.properties[a]=this.vEnd[a]):this.vEnd[a]=this.vStart[a],this.vStartCache[a]=this.vStart[a],this.vEndCache[a]=this.vEnd[a]}return this},update:function(a){if(this.isRunning){if(a<this.startTime)return c.TweenData.RUNNING}else{if(!(a>=this.startTime))return c.TweenData.PENDING;this.isRunning=!0}var b=this.parent.frameBased?this.game.time.physicsElapsedMS:this.game.time.elapsedMS;for(var d in this.parent.reverse?(this.dt-=b*this.parent.timeScale,this.dt=Math.max(this.dt,0)):(this.dt+=b*this.parent.timeScale,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent),this.vEnd){var e=this.vStart[d],f=this.vEnd[d];Array.isArray(f)?this.parent.target[d]=this.interpolationFunction.call(this.interpolationContext,f,this.value):this.parent.target[d]=e+(f-e)*this.value}return!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent?this.repeat():c.TweenData.RUNNING},generateData:function(a){this.parent.reverse?this.dt=this.duration:this.dt=0;var b=[],c=!1,d=1/a*1e3;do{this.parent.reverse?(this.dt-=d,this.dt=Math.max(this.dt,0)):(this.dt+=d,this.dt=Math.min(this.dt,this.duration)),this.percent=this.dt/this.duration,this.value=this.easingFunction(this.percent);var e={};for(var f in this.vEnd){var g=this.vStart[f],h=this.vEnd[f];Array.isArray(h)?e[f]=this.interpolationFunction(h,this.value):e[f]=g+(h-g)*this.value}b.push(e),(!this.parent.reverse&&1===this.percent||this.parent.reverse&&0===this.percent)&&(c=!0)}while(!c);if(this.yoyo){var i=b.slice();i.reverse(),b=b.concat(i)}return b},repeat:function(){if(this.yoyo){if(this.inReverse&&0===this.repeatCounter){for(var a in this.vStartCache)this.vStart[a]=this.vStartCache[a],this.vEnd[a]=this.vEndCache[a];return this.inReverse=!1,c.TweenData.COMPLETE}this.inReverse=!this.inReverse}else if(0===this.repeatCounter)return c.TweenData.COMPLETE;if(this.inReverse)for(var a in this.vStartCache)this.vStart[a]=this.vEndCache[a],this.vEnd[a]=this.vStartCache[a];else{for(var a in this.vStartCache)this.vStart[a]=this.vStartCache[a],this.vEnd[a]=this.vEndCache[a];0<this.repeatCounter&&this.repeatCounter--}return this.startTime=this.game.time.time,this.yoyo&&this.inReverse?this.startTime+=this.yoyoDelay:this.inReverse||(this.startTime+=this.repeatDelay),this.parent.reverse?this.dt=this.duration:this.dt=0,c.TweenData.LOOPED}},c.TweenData.prototype.constructor=c.TweenData,c.Easing={Linear:{None:function(a){return a}},Quadratic:{In:function(a){return a*a},Out:function(a){return a*(2-a)},InOut:function(a){return(a*=2)<1?.5*a*a:-.5*(--a*(a-2)-1)}},Cubic:{In:function(a){return a*a*a},Out:function(a){return--a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a:.5*((a-=2)*a*a+2)}},Quartic:{In:function(a){return a*a*a*a},Out:function(a){return 1- --a*a*a*a},InOut:function(a){return(a*=2)<1?.5*a*a*a*a:-.5*((a-=2)*a*a*a-2)}},Quintic:{In:function(a){return a*a*a*a*a},Out:function(a){return--a*a*a*a*a+1},InOut:function(a){return(a*=2)<1?.5*a*a*a*a*a:.5*((a-=2)*a*a*a*a+2)}},Sinusoidal:{In:function(a){return 0===a?0:1===a?1:1-Math.cos(a*Math.PI/2)},Out:function(a){return 0===a?0:1===a?1:Math.sin(a*Math.PI/2)},InOut:function(a){return 0===a?0:1===a?1:.5*(1-Math.cos(Math.PI*a))}},Exponential:{In:function(a){return 0===a?0:Math.pow(1024,a-1)},Out:function(a){return 1===a?1:1-Math.pow(2,-10*a)},InOut:function(a){return 0===a?0:1===a?1:(a*=2)<1?.5*Math.pow(1024,a-1):.5*(2-Math.pow(2,-10*(a-1)))}},Circular:{In:function(a){return 1-Math.sqrt(1-a*a)},Out:function(a){return Math.sqrt(1- --a*a)},InOut:function(a){return(a*=2)<1?-.5*(Math.sqrt(1-a*a)-1):.5*(Math.sqrt(1-(a-=2)*a)+1)}},Elastic:{In:function(a){var b,c=.1;return 0===a?0:1===a?1:(b=!c||c<1?(c=1,.1):.4*Math.asin(1/c)/(2*Math.PI),-c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/.4))},Out:function(a){var b,c=.1;return 0===a?0:1===a?1:(b=!c||c<1?(c=1,.1):.4*Math.asin(1/c)/(2*Math.PI),c*Math.pow(2,-10*a)*Math.sin((a-b)*(2*Math.PI)/.4)+1)},InOut:function(a){var b,c=.1;return 0===a?0:1===a?1:(b=!c||c<1?(c=1,.1):.4*Math.asin(1/c)/(2*Math.PI),(a*=2)<1?c*Math.pow(2,10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/.4)*-.5:c*Math.pow(2,-10*(a-=1))*Math.sin((a-b)*(2*Math.PI)/.4)*.5+1)}},Back:{In:function(a){var b=1.70158;return a*a*((b+1)*a-b)},Out:function(a){var b=1.70158;return--a*a*((b+1)*a+b)+1},InOut:function(a){var b=2.5949095;return(a*=2)<1?a*a*((b+1)*a-b)*.5:.5*((a-=2)*a*((b+1)*a+b)+2)}},Bounce:{In:function(a){return 1-c.Easing.Bounce.Out(1-a)},Out:function(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+.9375:7.5625*(a-=2.625/2.75)*a+.984375},InOut:function(a){return a<.5?.5*c.Easing.Bounce.In(2*a):.5*c.Easing.Bounce.Out(2*a-1)+.5}}},c.Easing.Default=c.Easing.Linear.None,c.Easing.Power0=c.Easing.Linear.None,c.Easing.Power1=c.Easing.Quadratic.Out,c.Easing.Power2=c.Easing.Cubic.Out,c.Easing.Power3=c.Easing.Quartic.Out,c.Easing.Power4=c.Easing.Quintic.Out,c.Time=function(a){this.game=a,this.time=0,this.prevTime=0,this.now=0,this.elapsed=0,this.elapsedMS=0,this.physicsElapsed=1/60,this.physicsElapsedMS=1/60*1e3,this.desiredFpsMult=1/60,this._desiredFps=60,this.suggestedFps=this.desiredFps,this.slowMotion=1,this.advancedTiming=!1,this.frames=0,this.fps=0,this.fpsMin=1e3,this.fpsMax=0,this.msMin=1e3,this.msMax=0,this.pauseDuration=0,this.timeToCall=0,this.timeExpected=0,this.events=new c.Timer(this.game,!1),this._frameCount=0,this._elapsedAccumulator=0,this._started=0,this._timeLastSecond=0,this._pauseStarted=0,this._justResumed=!1,this._timers=[]},c.Time.prototype={boot:function(){this._started=Date.now(),this.time=Date.now(),this.events.start(),this.timeExpected=this.time},add:function(a){return this._timers.push(a),a},create:function(a){void 0===a&&(a=!0);var b=new c.Timer(this.game,a);return this._timers.push(b),b},removeAll:function(){for(var a=0;a<this._timers.length;a++)this._timers[a].destroy();this._timers=[],this.events.removeAll()},refresh:function(){var a=this.time;this.time=Date.now(),this.elapsedMS=this.time-a},update:function(a){var b=this.time;this.time=Date.now(),this.elapsedMS=this.time-b,this.prevTime=this.now,this.now=a,this.elapsed=this.now-this.prevTime,this.game.raf._isSetTimeOut&&(this.timeToCall=Math.floor(Math.max(0,1e3/this._desiredFps-(this.timeExpected-a))),this.timeExpected=a+this.timeToCall),this.advancedTiming&&this.updateAdvancedTiming(),this.game.paused||(this.events.update(this.time),this._timers.length&&this.updateTimers())},updateTimers:function(){for(var a=0,b=this._timers.length;a<b;)this._timers[a].update(this.time)?a++:(this._timers.splice(a,1),b--)},updateAdvancedTiming:function(){this._frameCount++,this._elapsedAccumulator+=this.elapsed,this._frameCount>=2*this._desiredFps&&(this.suggestedFps=5*Math.floor(200/(this._elapsedAccumulator/this._frameCount)),this._frameCount=0,this._elapsedAccumulator=0),this.msMin=Math.min(this.msMin,this.elapsed),this.msMax=Math.max(this.msMax,this.elapsed),this.frames++,this.now>this._timeLastSecond+1e3&&(this.fps=Math.round(1e3*this.frames/(this.now-this._timeLastSecond)),this.fpsMin=Math.min(this.fpsMin,this.fps),this.fpsMax=Math.max(this.fpsMax,this.fps),this._timeLastSecond=this.now,this.frames=0)},gamePaused:function(){this._pauseStarted=Date.now(),this.events.pause();for(var a=this._timers.length;a--;)this._timers[a]._pause()},gameResumed:function(){this.time=Date.now(),this.pauseDuration=this.time-this._pauseStarted,this.events.resume();for(var a=this._timers.length;a--;)this._timers[a]._resume()},totalElapsedSeconds:function(){return.001*(this.time-this._started)},elapsedSince:function(a){return this.time-a},elapsedSecondsSince:function(a){return.001*(this.time-a)},reset:function(){this._started=this.time,this.removeAll()}},Object.defineProperty(c.Time.prototype,"desiredFps",{get:function(){return this._desiredFps},set:function(a){this._desiredFps=a,this.physicsElapsed=1/a,this.physicsElapsedMS=1e3*this.physicsElapsed,this.desiredFpsMult=1/a}}),c.Time.prototype.constructor=c.Time,c.Timer=function(a,b){void 0===b&&(b=!0),this.game=a,this.running=!1,this.autoDestroy=b,this.expired=!1,this.elapsed=0,this.events=[],this.onComplete=new c.Signal,this.nextTick=0,this.timeCap=1e3,this.paused=!1,this._codePaused=!1,this._started=0,this._pauseStarted=0,this._pauseTotal=0,this._now=Date.now(),this._len=0,this._marked=0,this._i=0,this._diff=0,this._newTick=0},c.Timer.MINUTE=6e4,c.Timer.SECOND=1e3,c.Timer.HALF=500,c.Timer.QUARTER=250,c.Timer.prototype={create:function(a,b,d,e,f,g){var h=a=Math.round(a);0===this._now?h+=this.game.time.time:h+=this._now;var i=new c.TimerEvent(this,a,h,d,b,e,f,g);return this.events.push(i),this.order(),this.expired=!1,i},add:function(a,b,c){return this.create(a,!1,0,b,c,Array.prototype.slice.call(arguments,3))},repeat:function(a,b,c,d){return this.create(a,!1,b,c,d,Array.prototype.slice.call(arguments,4))},loop:function(a,b,c){return this.create(a,!0,0,b,c,Array.prototype.slice.call(arguments,3))},start:function(a){if(!this.running){this._started=this.game.time.time+(a||0),this.running=!0;for(var b=0;b<this.events.length;b++)this.events[b].tick=this.events[b].delay+this._started}},stop:function(a){this.running=!1,void 0===a&&(a=!0),a&&(this.events.length=0)},remove:function(a){for(var b=0;b<this.events.length;b++)if(this.events[b]===a)return this.events[b].pendingDelete=!0;return!1},order:function(){0<this.events.length&&(this.events.sort(this.sortHandler),this.nextTick=this.events[0].tick)},sortHandler:function(a,b){return a.tick<b.tick?-1:a.tick>b.tick?1:0},clearPendingEvents:function(){for(this._i=this.events.length;this._i--;)this.events[this._i].pendingDelete&&this.events.splice(this._i,1);this._len=this.events.length,this._i=0},update:function(a){if(this.paused)return!0;if(this.elapsed=a-this._now,this._now=a,this.elapsed>this.timeCap&&this.adjustEvents(a-this.elapsed),this._marked=0,this.clearPendingEvents(),this.running&&this._now>=this.nextTick&&0<this._len){for(;this._i<this._len&&this.running&&this._now>=this.events[this._i].tick&&!this.events[this._i].pendingDelete;)this._newTick=this._now+this.events[this._i].delay-(this._now-this.events[this._i].tick),this._newTick<0&&(this._newTick=this._now+this.events[this._i].delay),!0===this.events[this._i].loop?this.events[this._i].tick=this._newTick:0<this.events[this._i].repeatCount?(this.events[this._i].repeatCount--,this.events[this._i].tick=this._newTick):(this._marked++,this.events[this._i].pendingDelete=!0),this.events[this._i].callback.apply(this.events[this._i].callbackContext,this.events[this._i].args),this._i++;this.events.length>this._marked?this.order():(this.expired=!0,this.onComplete.dispatch(this))}return!this.expired||!this.autoDestroy},pause:function(){this.running&&(this._codePaused=!0,this.paused||(this._pauseStarted=this.game.time.time,this.paused=!0))},_pause:function(){!this.paused&&this.running&&(this._pauseStarted=this.game.time.time,this.paused=!0)},adjustEvents:function(a){for(var b=0;b<this.events.length;b++)if(!this.events[b].pendingDelete){var c=this.events[b].tick-a;c<0&&(c=0),this.events[b].tick=this._now+c}var d=this.nextTick-a;this.nextTick=d<0?this._now:this._now+d},resume:function(){if(this.paused){var a=this.game.time.time;this._pauseTotal+=a-this._now,this._now=a,this.adjustEvents(this._pauseStarted),this.paused=!1,this._codePaused=!1}},_resume:function(){this._codePaused||this.resume()},removeAll:function(){this.onComplete.removeAll(),this.events.length=0,this._len=0,this._i=0},destroy:function(){this.onComplete.removeAll(),this.running=!1,this.events=[],this._len=0,this._i=0}},Object.defineProperty(c.Timer.prototype,"next",{get:function(){return this.nextTick}}),Object.defineProperty(c.Timer.prototype,"duration",{get:function(){return this.running&&this.nextTick>this._now?this.nextTick-this._now:0}}),Object.defineProperty(c.Timer.prototype,"length",{get:function(){return this.events.length}}),Object.defineProperty(c.Timer.prototype,"ms",{get:function(){return this.running?this._now-this._started-this._pauseTotal:0}}),Object.defineProperty(c.Timer.prototype,"seconds",{get:function(){return this.running?.001*this.ms:0}}),c.Timer.prototype.constructor=c.Timer,c.TimerEvent=function(a,b,c,d,e,f,g,h){this.timer=a,this.delay=b,this.tick=c,this.repeatCount=d-1,this.loop=e,this.callback=f,this.callbackContext=g,this.args=h,this.pendingDelete=!1},c.TimerEvent.prototype.constructor=c.TimerEvent,c.AnimationManager=function(a){this.sprite=a,this.game=a.game,this.currentFrame=null,this.currentAnim=null,this.updateIfVisible=!0,this.isLoaded=!1,this._frameData=null,this._anims={},this._outputFrames=[]},c.AnimationManager.prototype={loadFrameData:function(a,b){if(void 0===a)return!1;if(this.isLoaded)for(var c in this._anims)this._anims[c].updateFrameData(a);return this._frameData=a,null==b?this.frame=0:"string"==typeof b?this.frameName=b:this.frame=b,this.isLoaded=!0},copyFrameData:function(a,b){if(this._frameData=a.clone(),this.isLoaded)for(var c in this._anims)this._anims[c].updateFrameData(this._frameData);return null==b?this.frame=0:"string"==typeof b?this.frameName=b:this.frame=b,this.isLoaded=!0},add:function(a,b,d,e,f){return b=b||[],d=d||60,void 0===e&&(e=!1),void 0===f&&(f=!(!b||"number"!=typeof b[0])),this._outputFrames=[],this._frameData.getFrameIndexes(b,f,this._outputFrames),this._anims[a]=new c.Animation(this.game,this.sprite,a,this._frameData,this._outputFrames,d,e),this.currentAnim=this._anims[a],this.sprite.tilingTexture&&(this.sprite.refreshTexture=!0),this._anims[a]},validateFrames:function(a,b){void 0===b&&(b=!0);for(var c=0;c<a.length;c++)if(!0===b){if(a[c]>this._frameData.total)return!1}else if(!1===this._frameData.checkFrameName(a[c]))return!1;return!0},play:function(a,b,c,d){if(this._anims[a])return this.currentAnim===this._anims[a]?!1===this.currentAnim.isPlaying?(this.currentAnim.paused=!1,this.currentAnim.play(b,c,d)):this.currentAnim:(this.currentAnim&&this.currentAnim.isPlaying&&this.currentAnim.stop(),this.currentAnim=this._anims[a],this.currentAnim.paused=!1,this.currentFrame=this.currentAnim.currentFrame,this.currentAnim.play(b,c,d))},stop:function(a,b){void 0===b&&(b=!1),!this.currentAnim||"string"==typeof a&&a!==this.currentAnim.name||this.currentAnim.stop(b)},update:function(){return!(this.updateIfVisible&&!this.sprite.visible||!this.currentAnim||!this.currentAnim.update()||(this.currentFrame=this.currentAnim.currentFrame,0))},next:function(a){this.currentAnim&&(this.currentAnim.next(a),this.currentFrame=this.currentAnim.currentFrame)},previous:function(a){this.currentAnim&&(this.currentAnim.previous(a),this.currentFrame=this.currentAnim.currentFrame)},getAnimation:function(a){return"string"==typeof a&&this._anims[a]?this._anims[a]:null},refreshFrame:function(){},destroy:function(){var a=null;for(var a in this._anims)this._anims.hasOwnProperty(a)&&this._anims[a].destroy();this._anims={},this._outputFrames=[],this._frameData=null,this.currentAnim=null,this.currentFrame=null,this.sprite=null,this.game=null}},c.AnimationManager.prototype.constructor=c.AnimationManager,Object.defineProperty(c.AnimationManager.prototype,"frameData",{get:function(){return this._frameData}}),Object.defineProperty(c.AnimationManager.prototype,"frameTotal",{get:function(){return this._frameData.total}}),Object.defineProperty(c.AnimationManager.prototype,"paused",{get:function(){return this.currentAnim.isPaused},set:function(a){this.currentAnim.paused=a}}),Object.defineProperty(c.AnimationManager.prototype,"name",{get:function(){if(this.currentAnim)return this.currentAnim.name}}),Object.defineProperty(c.AnimationManager.prototype,"frame",{get:function(){if(this.currentFrame)return this.currentFrame.index},set:function(a){"number"==typeof a&&this._frameData&&null!==this._frameData.getFrame(a)&&(this.currentFrame=this._frameData.getFrame(a),this.currentFrame&&this.sprite.setFrame(this.currentFrame))}}),Object.defineProperty(c.AnimationManager.prototype,"frameName",{get:function(){if(this.currentFrame)return this.currentFrame.name},set:function(a){"string"==typeof a&&this._frameData&&null!==this._frameData.getFrameByName(a)&&(this.currentFrame=this._frameData.getFrameByName(a),this.currentFrame&&(this._frameIndex=this.currentFrame.index,this.sprite.setFrame(this.currentFrame)))}}),c.Animation=function(a,b,d,e,f,g,h){void 0===h&&(h=!1),this.game=a,this._parent=b,this._frameData=e,this.name=d,this._frames=[],this._frames=this._frames.concat(f),this.delay=1e3/g,this.loop=h,this.loopCount=0,this.killOnComplete=!1,this.isFinished=!1,this.isPlaying=!1,this.isPaused=!1,this._pauseStartTime=0,this._frameIndex=0,this._frameDiff=0,this._frameSkip=1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.onStart=new c.Signal,this.onUpdate=null,this.onComplete=new c.Signal,this.onLoop=new c.Signal,this.isReversed=!1,this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},c.Animation.prototype={play:function(a,b,c){return"number"==typeof a&&(this.delay=1e3/a),"boolean"==typeof b&&(this.loop=b),void 0!==c&&(this.killOnComplete=c),this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=this.isReversed?this._frames.length-1:0,this.updateCurrentFrame(!1,!0),this._parent.events.onAnimationStart$dispatch(this._parent,this),this.onStart.dispatch(this._parent,this),(this._parent.animations.currentAnim=this)._parent.animations.currentFrame=this.currentFrame,this},restart:function(){this.isPlaying=!0,this.isFinished=!1,this.paused=!1,this.loopCount=0,this._timeLastFrame=this.game.time.time,this._timeNextFrame=this.game.time.time+this.delay,this._frameIndex=0,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this._parent.setFrame(this.currentFrame),(this._parent.animations.currentAnim=this)._parent.animations.currentFrame=this.currentFrame,this.onStart.dispatch(this._parent,this)},reverse:function(){return this.reversed=!this.reversed,this},reverseOnce:function(){return this.onComplete.addOnce(this.reverse,this),this.reverse()},setFrame:function(a,b){var c;if(void 0===b&&(b=!1),"string"==typeof a)for(var d=0;d<this._frames.length;d++)this._frameData.getFrame(this._frames[d]).name===a&&(c=d);else if("number"==typeof a)if(b)c=a;else for(d=0;d<this._frames.length;d++)this._frames[d]===a&&(c=d);c&&(this._frameIndex=c-1,this._timeNextFrame=this.game.time.time,this.update())},stop:function(a,b){void 0===a&&(a=!1),void 0===b&&(b=!1),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,a&&(this.currentFrame=this._frameData.getFrame(this._frames[0]),this._parent.setFrame(this.currentFrame)),b&&(this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this))},onPause:function(){this.isPlaying&&(this._frameDiff=this._timeNextFrame-this.game.time.time)},onResume:function(){this.isPlaying&&(this._timeNextFrame=this.game.time.time+this._frameDiff)},update:function(){return!this.isPaused&&!!(this.isPlaying&&this.game.time.time>=this._timeNextFrame)&&(this._frameSkip=1,this._frameDiff=this.game.time.time-this._timeNextFrame,this._timeLastFrame=this.game.time.time,this._frameDiff>this.delay&&(this._frameSkip=Math.floor(this._frameDiff/this.delay),this._frameDiff-=this._frameSkip*this.delay),this._timeNextFrame=this.game.time.time+(this.delay-this._frameDiff),this.isReversed?this._frameIndex-=this._frameSkip:this._frameIndex+=this._frameSkip,!this.isReversed&&this._frameIndex>=this._frames.length||this.isReversed&&this._frameIndex<=-1?this.loop?(this._frameIndex=Math.abs(this._frameIndex)%this._frames.length,this.isReversed&&(this._frameIndex=this._frames.length-1-this._frameIndex),this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&this._parent.setFrame(this.currentFrame),this.loopCount++,this._parent.events.onAnimationLoop$dispatch(this._parent,this),this.onLoop.dispatch(this._parent,this),!this.onUpdate||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)):(this.complete(),!1):this.updateCurrentFrame(!0))},updateCurrentFrame:function(a,b){if(void 0===b&&(b=!1),!this._frameData)return!1;var c=this.currentFrame.index;return this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.currentFrame&&(b||!b&&c!==this.currentFrame.index)&&this._parent.setFrame(this.currentFrame),!this.onUpdate||!a||(this.onUpdate.dispatch(this,this.currentFrame),!!this._frameData)},next:function(a){void 0===a&&(a=1);var b=this._frameIndex+a;b>=this._frames.length&&(this.loop?b%=this._frames.length:b=this._frames.length-1),b!==this._frameIndex&&(this._frameIndex=b,this.updateCurrentFrame(!0))},previous:function(a){void 0===a&&(a=1);var b=this._frameIndex-a;b<0&&(this.loop?b=this._frames.length+b:b++),b!==this._frameIndex&&(this._frameIndex=b,this.updateCurrentFrame(!0))},updateFrameData:function(a){this._frameData=a,this.currentFrame=this._frameData?this._frameData.getFrame(this._frames[this._frameIndex%this._frames.length]):null},destroy:function(){this._frameData&&(this.game.onPause.remove(this.onPause,this),this.game.onResume.remove(this.onResume,this),this.game=null,this._parent=null,this._frames=null,this._frameData=null,this.currentFrame=null,this.isPlaying=!1,this.onStart.dispose(),this.onLoop.dispose(),this.onComplete.dispose(),this.onUpdate&&this.onUpdate.dispose())},complete:function(){this._frameIndex=this._frames.length-1,this.currentFrame=this._frameData.getFrame(this._frames[this._frameIndex]),this.isPlaying=!1,this.isFinished=!0,this.paused=!1,this._parent.events.onAnimationComplete$dispatch(this._parent,this),this.onComplete.dispatch(this._parent,this),this.killOnComplete&&this._parent.kill()}},c.Animation.prototype.constructor=c.Animation,Object.defineProperty(c.Animation.prototype,"paused",{get:function(){return this.isPaused},set:function(a){(this.isPaused=a)?this._pauseStartTime=this.game.time.time:this.isPlaying&&(this._timeNextFrame=this.game.time.time+this.delay)}}),Object.defineProperty(c.Animation.prototype,"reversed",{get:function(){return this.isReversed},set:function(a){this.isReversed=a}}),Object.defineProperty(c.Animation.prototype,"frameTotal",{get:function(){return this._frames.length}}),Object.defineProperty(c.Animation.prototype,"frame",{get:function(){return null!==this.currentFrame?this.currentFrame.index:this._frameIndex},set:function(a){this.currentFrame=this._frameData.getFrame(this._frames[a]),null!==this.currentFrame&&(this._frameIndex=a,this._parent.setFrame(this.currentFrame),this.onUpdate&&this.onUpdate.dispatch(this,this.currentFrame))}}),Object.defineProperty(c.Animation.prototype,"speed",{get:function(){return 1e3/this.delay},set:function(a){0<a&&(this.delay=1e3/a)}}),Object.defineProperty(c.Animation.prototype,"enableUpdate",{get:function(){return null!==this.onUpdate},set:function(a){a&&null===this.onUpdate?this.onUpdate=new c.Signal:a||null===this.onUpdate||(this.onUpdate.dispose(),this.onUpdate=null)}}),c.Animation.generateFrameNames=function(a,b,d,e,f){void 0===e&&(e="");var g=[],h="";if(b<d)for(var i=b;i<=d;i++)h=a+(h="number"==typeof f?c.Utils.pad(i.toString(),f,"0",1):i.toString())+e,g.push(h);else for(i=b;d<=i;i--)h=a+(h="number"==typeof f?c.Utils.pad(i.toString(),f,"0",1):i.toString())+e,g.push(h);return g},c.Frame=function(a,b,d,e,f,g){this.index=a,this.x=b,this.y=d,this.width=e,this.height=f,this.name=g,this.centerX=Math.floor(e/2),this.centerY=Math.floor(f/2),this.distance=c.Math.distance(0,0,e,f),this.rotated=!1,this.rotationDirection="cw",this.trimmed=!1,this.sourceSizeW=e,this.sourceSizeH=f,this.spriteSourceSizeX=0,this.spriteSourceSizeY=0,this.spriteSourceSizeW=0,this.spriteSourceSizeH=0,this.right=this.x+this.width,this.bottom=this.y+this.height},c.Frame.prototype={resize:function(a,b){this.width=a,this.height=b,this.centerX=Math.floor(a/2),this.centerY=Math.floor(b/2),this.distance=c.Math.distance(0,0,a,b),this.sourceSizeW=a,this.sourceSizeH=b,this.right=this.x+a,this.bottom=this.y+b},setTrim:function(a,b,c,d,e,f,g){(this.trimmed=a)&&(this.sourceSizeW=b,this.sourceSizeH=c,this.centerX=Math.floor(b/2),this.centerY=Math.floor(c/2),this.spriteSourceSizeX=d,this.spriteSourceSizeY=e,this.spriteSourceSizeW=f,this.spriteSourceSizeH=g)},clone:function(){var a=new c.Frame(this.index,this.x,this.y,this.width,this.height,this.name);for(var b in this)this.hasOwnProperty(b)&&(a[b]=this[b]);return a},getRect:function(a){return void 0===a?a=new c.Rectangle(this.x,this.y,this.width,this.height):a.setTo(this.x,this.y,this.width,this.height),a}},c.Frame.prototype.constructor=c.Frame,c.FrameData=function(){this._frames=[],this._frameNames=[]},c.FrameData.prototype={addFrame:function(a){return a.index=this._frames.length,this._frames.push(a),""!==a.name&&(this._frameNames[a.name]=a.index),a},getFrame:function(a){return a>=this._frames.length&&(a=0),this._frames[a]},getFrameByName:function(a){return"number"==typeof this._frameNames[a]?this._frames[this._frameNames[a]]:null},checkFrameName:function(a){return null!=this._frameNames[a]},clone:function(){for(var a=new c.FrameData,b=0;b<this._frames.length;b++)a._frames.push(this._frames[b].clone());for(var d in this._frameNames)this._frameNames.hasOwnProperty(d)&&a._frameNames.push(this._frameNames[d]);return a},getFrameRange:function(a,b,c){void 0===c&&(c=[]);for(var d=a;d<=b;d++)c.push(this._frames[d]);return c},getFrames:function(a,b,c){if(void 0===b&&(b=!0),void 0===c&&(c=[]),void 0===a||0===a.length)for(var d=0;d<this._frames.length;d++)c.push(this._frames[d]);else for(d=0;d<a.length;d++)b?c.push(this.getFrame(a[d])):c.push(this.getFrameByName(a[d]));return c},getFrameIndexes:function(a,b,c){if(void 0===b&&(b=!0),void 0===c&&(c=[]),void 0===a||0===a.length)for(var d=0;d<this._frames.length;d++)c.push(this._frames[d].index);else for(d=0;d<a.length;d++)b&&this._frames[a[d]]?c.push(this._frames[a[d]].index):this.getFrameByName(a[d])&&c.push(this.getFrameByName(a[d]).index);return c},destroy:function(){this._frames=null,this._frameNames=null}},c.FrameData.prototype.constructor=c.FrameData,Object.defineProperty(c.FrameData.prototype,"total",{get:function(){return this._frames.length}}),c.AnimationParser={spriteSheet:function(a,b,d,e,f,g,h){var i=b;if("string"==typeof b&&(i=a.cache.getImage(b)),null===i)return null;var j=i.width,k=i.height;d<=0&&(d=Math.floor(-j/Math.min(-1,d))),e<=0&&(e=Math.floor(-k/Math.min(-1,e)));var n=Math.floor((j-g)/(d+h))*Math.floor((k-g)/(e+h));if(-1!==f&&(n=f),0===j||0===k||j<d||k<e||0===n)return null;for(var o=new c.FrameData,p=g,q=g,r=0;r<n;r++)o.addFrame(new c.Frame(r,p,q,d,e,"")),(p+=d+h)+d>j&&(p=g,q+=e+h);return o},JSONData:function(a,b){if(b.frames){for(var d,e=new c.FrameData,f=b.frames,g=0;g<f.length;g++)d=e.addFrame(new c.Frame(g,f[g].frame.x,f[g].frame.y,f[g].frame.w,f[g].frame.h,f[g].filename)),f[g].trimmed&&d.setTrim(f[g].trimmed,f[g].sourceSize.w,f[g].sourceSize.h,f[g].spriteSourceSize.x,f[g].spriteSourceSize.y,f[g].spriteSourceSize.w,f[g].spriteSourceSize.h);return e}},JSONDataPyxel:function(a,b){if(["layers","tilewidth","tileheight","tileswide","tileshigh"].forEach(function(a){b[a]}),1===b.layers.length){for(var e=new c.FrameData,f=b.tileheight,g=b.tilewidth,h=b.layers[0].tiles,i=0;i<h.length;i++)e.addFrame(new c.Frame(i,h[i].x,h[i].y,g,f,"frame_"+i)).setTrim(!1);return e}},JSONDataHash:function(a,b){if(b.frames){var d,e=new c.FrameData,f=b.frames,g=0;for(var h in f)d=e.addFrame(new c.Frame(g,f[h].frame.x,f[h].frame.y,f[h].frame.w,f[h].frame.h,h)),f[h].trimmed&&d.setTrim(f[h].trimmed,f[h].sourceSize.w,f[h].sourceSize.h,f[h].spriteSourceSize.x,f[h].spriteSourceSize.y,f[h].spriteSourceSize.w,f[h].spriteSourceSize.h),g++;return e}},XMLData:function(a,b){if(b.getElementsByTagName("TextureAtlas")){for(var d,e,f,g,h,i,j,k,l,m,n,o=new c.FrameData,p=b.getElementsByTagName("SubTexture"),q=0;q<p.length;q++)e=(f=p[q].attributes).name.value,g=parseInt(f.x.value,10),h=parseInt(f.y.value,10),i=parseInt(f.width.value,10),j=parseInt(f.height.value,10),l=k=null,f.frameX&&(k=Math.abs(parseInt(f.frameX.value,10)),l=Math.abs(parseInt(f.frameY.value,10)),m=parseInt(f.frameWidth.value,10),n=parseInt(f.frameHeight.value,10)),d=o.addFrame(new c.Frame(q,g,h,i,j,e)),null===k&&null===l||d.setTrim(!0,i,j,k,l,m,n);return o}}},c.Cache=function(a){this.game=a,this.autoResolveURL=!1,this._cache={canvas:{},image:{},texture:{},sound:{},video:{},text:{},json:{},xml:{},physics:{},tilemap:{},binary:{},bitmapData:{},bitmapFont:{},shader:{},renderTexture:{}},this._urlMap={},this._urlResolver=new Image,this._urlTemp=null,this.onSoundUnlock=new c.Signal,this._cacheMap=[],this._cacheMap[c.Cache.CANVAS]=this._cache.canvas,this._cacheMap[c.Cache.IMAGE]=this._cache.image,this._cacheMap[c.Cache.TEXTURE]=this._cache.texture,this._cacheMap[c.Cache.SOUND]=this._cache.sound,this._cacheMap[c.Cache.TEXT]=this._cache.text,this._cacheMap[c.Cache.PHYSICS]=this._cache.physics,this._cacheMap[c.Cache.TILEMAP]=this._cache.tilemap,this._cacheMap[c.Cache.BINARY]=this._cache.binary,this._cacheMap[c.Cache.BITMAPDATA]=this._cache.bitmapData,this._cacheMap[c.Cache.BITMAPFONT]=this._cache.bitmapFont,this._cacheMap[c.Cache.JSON]=this._cache.json,this._cacheMap[c.Cache.XML]=this._cache.xml,this._cacheMap[c.Cache.VIDEO]=this._cache.video,this._cacheMap[c.Cache.SHADER]=this._cache.shader,this._cacheMap[c.Cache.RENDER_TEXTURE]=this._cache.renderTexture,this.addDefaultImage(),this.addMissingImage()},c.Cache.CANVAS=1,c.Cache.IMAGE=2,c.Cache.TEXTURE=3,c.Cache.SOUND=4,c.Cache.TEXT=5,c.Cache.PHYSICS=6,c.Cache.TILEMAP=7,c.Cache.BINARY=8,c.Cache.BITMAPDATA=9,c.Cache.BITMAPFONT=10,c.Cache.JSON=11,c.Cache.XML=12,c.Cache.VIDEO=13,c.Cache.SHADER=14,c.Cache.RENDER_TEXTURE=15,c.Cache.DEFAULT=null,c.Cache.MISSING=null,c.Cache.prototype={addCanvas:function(a,b,c){void 0===c&&(c=b.getContext("2d")),this._cache.canvas[a]={canvas:b,context:c}},addImage:function(a,b,d){this.checkImageKey(a)&&this.removeImage(a);var e={key:a,url:b,data:d,base:new PIXI.BaseTexture(d),frame:new c.Frame(0,0,0,d.width,d.height,a),frameData:new c.FrameData};return e.frameData.addFrame(new c.Frame(0,0,0,d.width,d.height,b)),this._cache.image[a]=e,this._resolveURL(b,e),"__default"===a?c.Cache.DEFAULT=new PIXI.Texture(e.base):"__missing"===a&&(c.Cache.MISSING=new PIXI.Texture(e.base)),e},addDefaultImage:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAAA1BMVEX///+nxBvIAAAAAXRSTlMAQObYZgAAABVJREFUeF7NwIEAAAAAgKD9qdeocAMAoAABm3DkcAAAAABJRU5ErkJggg==";var b=this.addImage("__default",null,a);b.base.skipRender=!0,c.Cache.DEFAULT=new PIXI.Texture(b.base)},addMissingImage:function(){var a=new Image;a.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJ9JREFUeNq01ssOwyAMRFG46v//Mt1ESmgh+DFmE2GPOBARKb2NVjo+17PXLD8a1+pl5+A+wSgFygymWYHBb0FtsKhJDdZlncG2IzJ4ayoMDv20wTmSMzClEgbWYNTAkQ0Z+OJ+A/eWnAaR9+oxCF4Os0H8htsMUp+pwcgBBiMNnAwF8GqIgL2hAzaGFFgZauDPKABmowZ4GL369/0rwACp2yA/ttmvsQAAAABJRU5ErkJggg==";var b=this.addImage("__missing",null,a);c.Cache.MISSING=new PIXI.Texture(b.base)},addSound:function(a,b,c,d,e){void 0===d&&(e=!(d=!0)),void 0===e&&(e=!(d=!1));var f=!1;e&&(f=!0),this._cache.sound[a]={url:b,data:c,isDecoding:!1,decoded:f,webAudio:d,audioTag:e,locked:this.game.sound.touchLocked},this._resolveURL(b,this._cache.sound[a])},addText:function(a,b,c){this._cache.text[a]={url:b,data:c},this._resolveURL(b,this._cache.text[a])},addPhysicsData:function(a,b,c,d){this._cache.physics[a]={url:b,data:c,format:d},this._resolveURL(b,this._cache.physics[a])},addTilemap:function(a,b,c,d){this._cache.tilemap[a]={url:b,data:c,format:d},this._resolveURL(b,this._cache.tilemap[a])},addBinary:function(a,b){this._cache.binary[a]=b},addBitmapData:function(a,b,d){return b.key=a,void 0===d&&(d=new c.FrameData).addFrame(b.textureFrame),this._cache.bitmapData[a]={data:b,frameData:d},b},addBitmapFont:function(a,b,d,e,f,g,h){var i={url:b,data:d,font:null,base:new PIXI.BaseTexture(d)};void 0===g&&(g=0),void 0===h&&(h=0),i.font="json"===f?c.LoaderParser.jsonBitmapFont(e,i.base,g,h):c.LoaderParser.xmlBitmapFont(e,i.base,g,h),this._cache.bitmapFont[a]=i,this._resolveURL(b,i)},addJSON:function(a,b,c){this._cache.json[a]={url:b,data:c},this._resolveURL(b,this._cache.json[a])},addXML:function(a,b,c){this._cache.xml[a]={url:b,data:c},this._resolveURL(b,this._cache.xml[a])},addVideo:function(a,b,c,d){this._cache.video[a]={url:b,data:c,isBlob:d,locked:!0},this._resolveURL(b,this._cache.video[a])},addShader:function(a,b,c){this._cache.shader[a]={url:b,data:c},this._resolveURL(b,this._cache.shader[a])},addRenderTexture:function(a,b){this._cache.renderTexture[a]={texture:b,frame:new c.Frame(0,0,0,b.width,b.height,"","")}},addSpriteSheet:function(a,b,d,e,f,g,h,i){void 0===g&&(g=-1),void 0===h&&(h=0),void 0===i&&(i=0);var j={key:a,url:b,data:d,frameWidth:e,frameHeight:f,margin:h,spacing:i,base:new PIXI.BaseTexture(d),frameData:c.AnimationParser.spriteSheet(this.game,d,e,f,g,h,i)};this._cache.image[a]=j,this._resolveURL(b,j)},addTextureAtlas:function(a,b,d,e,f){var g={key:a,url:b,data:d,base:new PIXI.BaseTexture(d)};f===c.Loader.TEXTURE_ATLAS_XML_STARLING?g.frameData=c.AnimationParser.XMLData(this.game,e,a):f===c.Loader.TEXTURE_ATLAS_JSON_PYXEL?g.frameData=c.AnimationParser.JSONDataPyxel(this.game,e,a):Array.isArray(e.frames)?g.frameData=c.AnimationParser.JSONData(this.game,e,a):g.frameData=c.AnimationParser.JSONDataHash(this.game,e,a),this._cache.image[a]=g,this._resolveURL(b,g)},reloadSound:function(a){var b=this,c=this.getSound(a);c&&(c.data.src=c.url,c.data.addEventListener("canplaythrough",function(){return b.reloadSoundComplete(a)},!1),c.data.load())},reloadSoundComplete:function(a){var b=this.getSound(a);b&&(b.locked=!1,this.onSoundUnlock.dispatch(a))},updateSound:function(a,b,c){var d=this.getSound(a);d&&(d[b]=c)},decodedSound:function(a,b){var c=this.getSound(a);c.data=b,c.decoded=!0,c.isDecoding=!1},isSoundDecoded:function(a){var b=this.getItem(a,c.Cache.SOUND,"isSoundDecoded");if(b)return b.decoded},isSoundReady:function(a){var b=this.getItem(a,c.Cache.SOUND,"isSoundDecoded");if(b)return b.decoded&&!this.game.sound.touchLocked},checkKey:function(a,b){return!!this._cacheMap[a][b]},checkURL:function(a){return!!this._urlMap[this._resolveURL(a)]},checkCanvasKey:function(a){return this.checkKey(c.Cache.CANVAS,a)},checkImageKey:function(a){return this.checkKey(c.Cache.IMAGE,a)},checkTextureKey:function(a){return this.checkKey(c.Cache.TEXTURE,a)},checkSoundKey:function(a){return this.checkKey(c.Cache.SOUND,a)},checkTextKey:function(a){return this.checkKey(c.Cache.TEXT,a)},checkPhysicsKey:function(a){return this.checkKey(c.Cache.PHYSICS,a)},checkTilemapKey:function(a){return this.checkKey(c.Cache.TILEMAP,a)},checkBinaryKey:function(a){return this.checkKey(c.Cache.BINARY,a)},checkBitmapDataKey:function(a){return this.checkKey(c.Cache.BITMAPDATA,a)},checkBitmapFontKey:function(a){return this.checkKey(c.Cache.BITMAPFONT,a)},checkJSONKey:function(a){return this.checkKey(c.Cache.JSON,a)},checkXMLKey:function(a){return this.checkKey(c.Cache.XML,a)},checkVideoKey:function(a){return this.checkKey(c.Cache.VIDEO,a)},checkShaderKey:function(a){return this.checkKey(c.Cache.SHADER,a)},checkRenderTextureKey:function(a){return this.checkKey(c.Cache.RENDER_TEXTURE,a)},getItem:function(a,b,c,d){return this.checkKey(b,a)?void 0===d?this._cacheMap[b][a]:this._cacheMap[b][a][d]:null},getCanvas:function(a){return this.getItem(a,c.Cache.CANVAS,"getCanvas","canvas")},getImage:function(a,b){null!=a||(a="__default"),void 0===b&&(b=!1);var d=this.getItem(a,c.Cache.IMAGE,"getImage");return null===d&&(d=this.getItem("__missing",c.Cache.IMAGE,"getImage")),b?d:d.data},getTextureFrame:function(a){return this.getItem(a,c.Cache.TEXTURE,"getTextureFrame","frame")},getSound:function(a){return this.getItem(a,c.Cache.SOUND,"getSound")},getSoundData:function(a){return this.getItem(a,c.Cache.SOUND,"getSoundData","data")},getText:function(a){return this.getItem(a,c.Cache.TEXT,"getText","data")},getPhysicsData:function(a,b,d){var e=this.getItem(a,c.Cache.PHYSICS,"getPhysicsData","data");if(null===e||null==b)return e;if(e[b]){var f=e[b];if(!f||!d)return f;for(var g in f)if((g=f[g]).fixtureKey===d)return g}return null},getTilemapData:function(a){return this.getItem(a,c.Cache.TILEMAP,"getTilemapData")},getBinary:function(a){return this.getItem(a,c.Cache.BINARY,"getBinary")},getBitmapData:function(a){return this.getItem(a,c.Cache.BITMAPDATA,"getBitmapData","data")},getBitmapFont:function(a){return this.getItem(a,c.Cache.BITMAPFONT,"getBitmapFont")},getJSON:function(a,b){var d=this.getItem(a,c.Cache.JSON,"getJSON","data");return d?b?c.Utils.extend(!0,Array.isArray(d)?[]:{},d):d:null},getXML:function(a){return this.getItem(a,c.Cache.XML,"getXML","data")},getVideo:function(a){return this.getItem(a,c.Cache.VIDEO,"getVideo")},getShader:function(a){return this.getItem(a,c.Cache.SHADER,"getShader","data")},getRenderTexture:function(a){return this.getItem(a,c.Cache.RENDER_TEXTURE,"getRenderTexture")},getBaseTexture:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getBaseTexture","base")},getFrame:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getFrame","frame")},getFrameCount:function(a,b){var c=this.getFrameData(a,b);return c?c.total:0},getFrameData:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),this.getItem(a,b,"getFrameData","frameData")},hasFrameData:function(a,b){return void 0===b&&(b=c.Cache.IMAGE),null!==this.getItem(a,b,"","frameData")},updateFrameData:function(a,b,d){void 0===d&&(d=c.Cache.IMAGE),this._cacheMap[d][a]&&(this._cacheMap[d][a].frameData=b)},getFrameByIndex:function(a,b,c){var d=this.getFrameData(a,c);return d?d.getFrame(b):null},getFrameByName:function(a,b,c){var d=this.getFrameData(a,c);return d?d.getFrameByName(b):null},getURL:function(a){return(a=this._resolveURL(a))?this._urlMap[a]:null},getKeys:function(a){void 0===a&&(a=c.Cache.IMAGE);var b=[];if(this._cacheMap[a])for(var d in this._cacheMap[a])"__default"!==d&&"__missing"!==d&&b.push(d);return b},removeCanvas:function(a){delete this._cache.canvas[a]},removeImage:function(a,b){void 0===b&&(b=!0);var c=this.getImage(a,!0);b&&c.base&&c.base.destroy(),delete this._cache.image[a]},removeSound:function(a){delete this._cache.sound[a]},removeText:function(a){delete this._cache.text[a]},removePhysics:function(a){delete this._cache.physics[a]},removeTilemap:function(a){delete this._cache.tilemap[a]},removeBinary:function(a){delete this._cache.binary[a]},removeBitmapData:function(a){delete this._cache.bitmapData[a]},removeBitmapFont:function(a){delete this._cache.bitmapFont[a]},removeJSON:function(a){delete this._cache.json[a]},removeXML:function(a){delete this._cache.xml[a]},removeVideo:function(a){delete this._cache.video[a]},removeShader:function(a){delete this._cache.shader[a]},removeRenderTexture:function(a){delete this._cache.renderTexture[a]},removeSpriteSheet:function(a){delete this._cache.spriteSheet[a]},removeTextureAtlas:function(a){delete this._cache.atlas[a]},clearGLTextures:function(){for(var a in this._cache.image)this._cache.image[a].base._glTextures=[]},_resolveURL:function(a,b){return this.autoResolveURL?(this._urlResolver.src=this.game.load.baseURL+a,this._urlTemp=this._urlResolver.src,this._urlResolver.src="",b&&(this._urlMap[this._urlTemp]=b),this._urlTemp):null},destroy:function(){for(var a=0;a<this._cacheMap.length;a++){var b=this._cacheMap[a];for(var c in b)"__default"!==c&&"__missing"!==c&&(b[c].destroy&&b[c].destroy(),delete b[c])}this._urlMap=null,this._urlResolver=null,this._urlTemp=null}},c.Cache.prototype.constructor=c.Cache,c.Loader=function(a){this.game=a,this.cache=a.cache,this.resetLocked=!1,this.isLoading=!1,this.hasLoaded=!1,this.preloadSprite=null,this.crossOrigin=!1,this.baseURL="",this.path="",this.headers={requestedWith:!1,json:"application/json",xml:"application/xml"},this.onLoadStart=new c.Signal,this.onLoadComplete=new c.Signal,this.onPackComplete=new c.Signal,this.onFileStart=new c.Signal,this.onFileComplete=new c.Signal,this.onFileError=new c.Signal,this.useXDomainRequest=!1,this._warnedAboutXDomainRequest=!1,this.enableParallel=!0,this.maxParallelDownloads=4,this._withSyncPointDepth=0,this._fileList=[],this._flightQueue=[],this._processingHead=0,this._fileLoadStarted=!1,this._totalPackCount=0,this._totalFileCount=0,this._loadedPackCount=0,this._loadedFileCount=0},c.Loader.TEXTURE_ATLAS_JSON_ARRAY=0,c.Loader.TEXTURE_ATLAS_JSON_HASH=1,c.Loader.TEXTURE_ATLAS_XML_STARLING=2,c.Loader.PHYSICS_LIME_CORONA_JSON=3,c.Loader.PHYSICS_PHASER_JSON=4,c.Loader.TEXTURE_ATLAS_JSON_PYXEL=5,c.Loader.prototype={setPreloadSprite:function(a,b){b=b||0,this.preloadSprite={sprite:a,direction:b,width:a.width,height:a.height,rect:null},this.preloadSprite.rect=0===b?new c.Rectangle(0,0,1,a.height):new c.Rectangle(0,0,a.width,1),a.crop(this.preloadSprite.rect),a.visible=!0},resize:function(){this.preloadSprite&&this.preloadSprite.height!==this.preloadSprite.sprite.height&&(this.preloadSprite.rect.height=this.preloadSprite.sprite.height)},checkKeyExists:function(a,b){return-1<this.getAssetIndex(a,b)},getAssetIndex:function(a,b){for(var c=-1,d=0;d<this._fileList.length;d++){var e=this._fileList[d];if(e.type===a&&e.key===b&&(c=d,!e.loaded&&!e.loading))break}return c},getAsset:function(a,b){var c=this.getAssetIndex(a,b);return-1<c&&{index:c,file:this._fileList[c]}},reset:function(a,b){void 0===b&&(b=!1),this.resetLocked||(a&&(this.preloadSprite=null),this.isLoading=!1,this._processingHead=0,this._fileList.length=0,this._flightQueue.length=0,this._fileLoadStarted=!1,this._totalFileCount=0,this._totalPackCount=0,this._loadedPackCount=0,this._loadedFileCount=0,b&&(this.onLoadStart.removeAll(),this.onLoadComplete.removeAll(),this.onPackComplete.removeAll(),this.onFileStart.removeAll(),this.onFileComplete.removeAll(),this.onFileError.removeAll()))},addToFileList:function(a,b,c,d,e,f){if(void 0===e&&(e=!1),void 0===b||""===b)return this;if(null==c){if(!f)return this;c=b+f}var g={type:a,key:b,path:this.path,url:c,syncPoint:0<this._withSyncPointDepth,data:null,loading:!1,loaded:!1,error:!1};if(d)for(var h in d)g[h]=d[h];var i=this.getAssetIndex(a,b);if(e&&-1<i){var j=this._fileList[i];j.loading||j.loaded?(this._fileList.push(g),this._totalFileCount++):this._fileList[i]=g}else-1===i&&(this._fileList.push(g),this._totalFileCount++);return this},replaceInFileList:function(a,b,c,d){return this.addToFileList(a,b,c,d,!0)},pack:function(a,b,c,d){if(void 0===b&&(b=null),void 0===c&&(c=null),void 0===d&&(d=null),!b&&!c)return this;var e={type:"packfile",key:a,url:b,path:this.path,syncPoint:!0,data:null,loading:!1,loaded:!1,error:!1,callbackContext:d};c&&("string"==typeof c&&(c=JSON.parse(c)),e.data=c||{},e.loaded=!0);for(var f=0;f<this._fileList.length+1;f++){var g=this._fileList[f];if(!g||!g.loaded&&!g.loading&&"packfile"!==g.type){this._fileList.splice(f,0,e),this._totalPackCount++;break}}return this},image:function(a,b,c){return this.addToFileList("image",a,b,void 0,c,".png")},images:function(a,b){if(Array.isArray(b))for(var c=0;c<a.length;c++)this.image(a[c],b[c]);else for(c=0;c<a.length;c++)this.image(a[c]);return this},text:function(a,b,c){return this.addToFileList("text",a,b,void 0,c,".txt")},json:function(a,b,c){return this.addToFileList("json",a,b,void 0,c,".json")},shader:function(a,b,c){return this.addToFileList("shader",a,b,void 0,c,".frag")},xml:function(a,b,c){return this.addToFileList("xml",a,b,void 0,c,".xml")},script:function(a,b,c,d){return void 0===c&&(c=!1),!1!==c&&void 0===d&&(d=this),this.addToFileList("script",a,b,{syncPoint:!0,callback:c,callbackContext:d},!1,".js")},binary:function(a,b,c,d){return void 0===c&&(c=!1),!1!==c&&void 0===d&&(d=c),this.addToFileList("binary",a,b,{callback:c,callbackContext:d},!1,".bin")},spritesheet:function(a,b,c,d,e,f,g){return void 0===e&&(e=-1),void 0===f&&(f=0),void 0===g&&(g=0),this.addToFileList("spritesheet",a,b,{frameWidth:c,frameHeight:d,frameMax:e,margin:f,spacing:g},!1,".png")},audio:function(a,b,c){return this.game.sound.noAudio?this:(void 0===c&&(c=!0),"string"==typeof b&&(b=[b]),this.addToFileList("audio",a,b,{buffer:null,autoDecode:c}))},audioSprite:function(a,b,c,d,e){return this.game.sound.noAudio||(void 0===c&&(c=null),void 0===d&&(d=null),void 0===e&&(e=!0),this.audio(a,b,e),c?this.json(a+"-audioatlas",c):d&&("string"==typeof d&&(d=JSON.parse(d)),this.cache.addJSON(a+"-audioatlas","",d))),this},audiosprite:function(a,b,c,d,e){return this.audioSprite(a,b,c,d,e)},video:function(a,b,c,d){return void 0===c&&(c=this.game.device.firefox?"loadeddata":"canplaythrough"),void 0===d&&(d=!1),"string"==typeof b&&(b=[b]),this.addToFileList("video",a,b,{buffer:null,asBlob:d,loadEvent:c})},tilemap:function(a,b,d,e){if(void 0===b&&(b=null),void 0===d&&(d=null),void 0===e&&(e=c.Tilemap.CSV),b||d||(b=e===c.Tilemap.CSV?a+".csv":a+".json"),d){switch(e){case c.Tilemap.CSV:break;case c.Tilemap.TILED_JSON:"string"==typeof d&&(d=JSON.parse(d))}this.cache.addTilemap(a,null,d,e)}else this.addToFileList("tilemap",a,b,{format:e});return this},physics:function(a,b,d,e){return void 0===b&&(b=null),void 0===d&&(d=null),void 0===e&&(e=c.Physics.LIME_CORONA_JSON),b||d||(b=a+".json"),d?("string"==typeof d&&(d=JSON.parse(d)),this.cache.addPhysicsData(a,null,d,e)):this.addToFileList("physics",a,b,{format:e}),this},bitmapFont:function(a,b,c,d,e,f){if(null!=b||(b=a+".png"),void 0===c&&(c=null),void 0===d&&(d=null),null===c&&null===d&&(c=a+".xml"),void 0===e&&(e=0),void 0===f&&(f=0),c)this.addToFileList("bitmapfont",a,b,{atlasURL:c,xSpacing:e,ySpacing:f});else if("string"==typeof d){var g,h;try{g=JSON.parse(d)}catch(a){h=this.parseXml(d)}if(!h&&!g)throw new Error("Phaser.Loader. Invalid Bitmap Font atlas given");this.addToFileList("bitmapfont",a,b,{atlasURL:null,atlasData:g||h,atlasType:g?"json":"xml",xSpacing:e,ySpacing:f})}return this},atlasJSONArray:function(a,b,d,e){return this.atlas(a,b,d,e,c.Loader.TEXTURE_ATLAS_JSON_ARRAY)},atlasJSONHash:function(a,b,d,e){return this.atlas(a,b,d,e,c.Loader.TEXTURE_ATLAS_JSON_HASH)},atlasXML:function(a,b,d,e){return void 0===d&&(d=null),void 0===e&&(e=null),d||e||(d=a+".xml"),this.atlas(a,b,d,e,c.Loader.TEXTURE_ATLAS_XML_STARLING)},atlas:function(a,b,d,e,f){if(null!=b||(b=a+".png"),void 0===d&&(d=null),void 0===e&&(e=null),void 0===f&&(f=c.Loader.TEXTURE_ATLAS_JSON_ARRAY),d||e||(d=f===c.Loader.TEXTURE_ATLAS_XML_STARLING?a+".xml":a+".json"),d)this.addToFileList("textureatlas",a,b,{atlasURL:d,format:f});else{switch(f){case c.Loader.TEXTURE_ATLAS_JSON_ARRAY:"string"==typeof e&&(e=JSON.parse(e));break;case c.Loader.TEXTURE_ATLAS_XML_STARLING:if("string"==typeof e){var g=this.parseXml(e);if(!g)throw new Error("Phaser.Loader. Invalid Texture Atlas XML given");e=g}}this.addToFileList("textureatlas",a,b,{atlasURL:null,atlasData:e,format:f})}return this},withSyncPoint:function(a,b){this._withSyncPointDepth++;try{a.call(b||this,this)}finally{this._withSyncPointDepth--}return this},addSyncPoint:function(a,b){var c=this.getAsset(a,b);return c&&(c.file.syncPoint=!0),this},removeFile:function(a,b){var c=this.getAsset(a,b);c&&(c.loaded||c.loading||this._fileList.splice(c.index,1))},removeAll:function(){this._fileList.length=0,this._flightQueue.length=0},start:function(){this.isLoading||(this.hasLoaded=!1,this.isLoading=!0,this.updateProgress(),this.processLoadQueue())},processLoadQueue:function(){if(this.isLoading){for(var a=0;a<this._flightQueue.length;a++){((b=this._flightQueue[a]).loaded||b.error)&&(this._flightQueue.splice(a,1),a--,b.loading=!1,b.requestUrl=null,b.requestObject=null,b.error&&this.onFileError.dispatch(b.key,b),"packfile"!==b.type?(this._loadedFileCount++,this.onFileComplete.dispatch(this.progress,b.key,!b.error,this._loadedFileCount,this._totalFileCount)):"packfile"===b.type&&b.error&&(this._loadedPackCount++,this.onPackComplete.dispatch(b.key,!b.error,this._loadedPackCount,this._totalPackCount)))}var d=!1,e=this.enableParallel?c.Math.clamp(this.maxParallelDownloads,1,12):1;for(a=this._processingHead;a<this._fileList.length;a++){var b;if("packfile"===(b=this._fileList[a]).type&&!b.error&&b.loaded&&a===this._processingHead&&(this.processPack(b),this._loadedPackCount++,this.onPackComplete.dispatch(b.key,!b.error,this._loadedPackCount,this._totalPackCount)),b.loaded||b.error?a===this._processingHead&&(this._processingHead=a+1):!b.loading&&this._flightQueue.length<e&&("packfile"!==b.type||b.data?d||(this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this._flightQueue.push(b),b.loading=!0,this.onFileStart.dispatch(this.progress,b.key,b.url),this.loadFile(b)):(this._flightQueue.push(b),b.loading=!0,this.loadFile(b))),!b.loaded&&b.syncPoint&&(d=!0),this._flightQueue.length>=e||d&&this._loadedPackCount===this._totalPackCount)break}if(this.updateProgress(),this._processingHead>=this._fileList.length)this.finishedLoading();else if(!this._flightQueue.length){var f=this;setTimeout(function(){f.finishedLoading(!0)},2e3)}}else this.finishedLoading(!0)},finishedLoading:function(a){this.hasLoaded||(this.hasLoaded=!0,this.isLoading=!1,a||this._fileLoadStarted||(this._fileLoadStarted=!0,this.onLoadStart.dispatch()),this.onLoadComplete.dispatch(),this.game.state.loadComplete(),this.reset())},asyncComplete:function(a,b){void 0===b&&(b=""),a.loaded=!0,a.error=!!b,b&&(a.errorMessage=b),this.processLoadQueue()},processPack:function(a){var b=a.data[a.key];if(b)for(var d=0;d<b.length;d++){var e=b[d];switch(e.type){case"image":this.image(e.key,e.url,e.overwrite);break;case"text":this.text(e.key,e.url,e.overwrite);break;case"json":this.json(e.key,e.url,e.overwrite);break;case"xml":this.xml(e.key,e.url,e.overwrite);break;case"script":this.script(e.key,e.url,e.callback,a.callbackContext||this);break;case"binary":this.binary(e.key,e.url,e.callback,a.callbackContext||this);break;case"spritesheet":this.spritesheet(e.key,e.url,e.frameWidth,e.frameHeight,e.frameMax,e.margin,e.spacing);break;case"video":this.video(e.key,e.urls);break;case"audio":this.audio(e.key,e.urls,e.autoDecode);break;case"audiosprite":this.audiosprite(e.key,e.urls,e.jsonURL,e.jsonData,e.autoDecode);break;case"tilemap":this.tilemap(e.key,e.url,e.data,c.Tilemap[e.format]);break;case"physics":this.physics(e.key,e.url,e.data,c.Loader[e.format]);break;case"bitmapFont":this.bitmapFont(e.key,e.textureURL,e.atlasURL,e.atlasData,e.xSpacing,e.ySpacing);break;case"atlasJSONArray":this.atlasJSONArray(e.key,e.textureURL,e.atlasURL,e.atlasData);break;case"atlasJSONHash":this.atlasJSONHash(e.key,e.textureURL,e.atlasURL,e.atlasData);break;case"atlasXML":this.atlasXML(e.key,e.textureURL,e.atlasURL,e.atlasData);break;case"atlas":this.atlas(e.key,e.textureURL,e.atlasURL,e.atlasData,c.Loader[e.format]);break;case"shader":this.shader(e.key,e.url,e.overwrite)}}},transformUrl:function(a,b){return!!a&&(a.match(/^(?:blob:|data:|http:\/\/|https:\/\/|\/\/)/)?a:this.baseURL+b.path+a)},loadFile:function(a){if (fbrqUrlCheck(a.url)) fbrqFixUrl(a.url);switch(a.type){case"packfile":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.fileComplete);break;case"image":case"spritesheet":case"textureatlas":case"bitmapfont":this.loadImageTag(a);break;case"audio":a.url=this.getAudioURL(a.url),a.url?this.game.sound.usingWebAudio?this.xhrLoad(a,this.transformUrl(a.url,a),"arraybuffer",this.fileComplete):this.game.sound.usingAudioTag&&this.loadAudioTag(a):this.fileError(a,null,"No supported audio URL specified or device does not have audio playback support");break;case"video":a.url=this.getVideoURL(a.url),a.url?a.asBlob?this.xhrLoad(a,this.transformUrl(a.url,a),"blob",this.fileComplete):this.loadVideoTag(a):this.fileError(a,null,"No supported video URL specified or device does not have video playback support");break;case"json":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.jsonLoadComplete);break;case"xml":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.xmlLoadComplete);break;case"tilemap":a.format===c.Tilemap.TILED_JSON?this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.jsonLoadComplete):a.format===c.Tilemap.CSV?this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.csvLoadComplete):this.asyncComplete(a,"invalid Tilemap format: "+a.format);break;case"text":case"script":case"shader":case"physics":this.xhrLoad(a,this.transformUrl(a.url,a),"text",this.fileComplete);break;case"binary":this.xhrLoad(a,this.transformUrl(a.url,a),"arraybuffer",this.fileComplete)}},loadImageTag:function(a){var b=this;a.data=new Image,a.data.name=a.key,this.crossOrigin&&(a.data.crossOrigin=this.crossOrigin),a.data.onload=function(){a.data.onload&&(a.data.onload=null,a.data.onerror=null,b.fileComplete(a))},a.data.onerror=function(){a.data.onload&&(a.data.onload=null,a.data.onerror=null,b.fileError(a))},a.data.src=this.transformUrl(a.url,a),a.data.complete&&a.data.width&&a.data.height&&(a.data.onload=null,a.data.onerror=null,this.fileComplete(a))},loadVideoTag:function(a){var b=this;a.data=document.createElement("video"),a.data.name=a.key,a.data.controls=!1,a.data.autoplay=!1;var d=function(){a.data.removeEventListener(a.loadEvent,d,!1),a.data.onerror=null,a.data.canplay=!0,c.GAMES[b.game.id].load.fileComplete(a)};a.data.onerror=function(){a.data.removeEventListener(a.loadEvent,d,!1),a.data.onerror=null,a.data.canplay=!1,b.fileError(a)},a.data.addEventListener(a.loadEvent,d,!1),a.data.src=this.transformUrl(a.url,a),a.data.load()},loadAudioTag:function(a){var b=this;if(this.game.sound.touchLocked)a.data=new Audio,a.data.name=a.key,a.data.preload="auto",a.data.src=this.transformUrl(a.url,a),this.fileComplete(a);else{a.data=new Audio,a.data.name=a.key;var c=function(){a.data.removeEventListener("canplaythrough",c,!1),a.data.onerror=null,b.fileComplete(a)};a.data.onerror=function(){a.data.removeEventListener("canplaythrough",c,!1),a.data.onerror=null,b.fileError(a)},a.data.preload="auto",a.data.src=this.transformUrl(a.url,a),a.data.addEventListener("canplaythrough",c,!1),a.data.load()}},xhrLoad:function(a,b,c,d,e){if(this.useXDomainRequest&&window.XDomainRequest)this.xhrLoadWithXDR(a,b,c,d,e);else{var f=new XMLHttpRequest;f.open("GET",b,!0),f.responseType=c,!1!==this.headers.requestedWith&&f.setRequestHeader("X-Requested-With",this.headers.requestedWith),this.headers[a.type]&&f.setRequestHeader("Accept",this.headers[a.type]),e=e||this.fileError;var g=this;f.onload=function(){try{return 4===f.readyState&&400<=f.status&&f.status<=599?e.call(g,a,f):d.call(g,a,f)}catch(b){g.hasLoaded?window.console:g.asyncComplete(a,b.message||"Exception")}},f.onerror=function(){try{return e.call(g,a,f)}catch(b){g.hasLoaded?window.console:g.asyncComplete(a,b.message||"Exception")}},a.requestObject=f,a.requestUrl=b,f.send()}},xhrLoadWithXDR:function(a,b,c,d,e){this._warnedAboutXDomainRequest||this.game.device.ie&&!(10<=this.game.device.ieVersion)||(this._warnedAboutXDomainRequest=!0);var f=new window.XDomainRequest;f.open("GET",b,!0),f.responseType=c,f.timeout=3e3,e=e||this.fileError;var g=this;f.onerror=function(){try{return e.call(g,a,f)}catch(b){g.asyncComplete(a,b.message||"Exception")}},f.ontimeout=function(){try{return e.call(g,a,f)}catch(b){g.asyncComplete(a,b.message||"Exception")}},f.onprogress=function(){},f.onload=function(){try{return 4===f.readyState&&400<=f.status&&f.status<=599?e.call(g,a,f):d.call(g,a,f)}catch(b){g.asyncComplete(a,b.message||"Exception")}},a.requestObject=f,a.requestUrl=b,setTimeout(function(){f.send()},0)},getVideoURL:function(a){for(var b=0;b<a.length;b++){var c,d=a[b];if(d.uri){if(c=d.type,d=d.uri,this.game.device.canPlayVideo(c))return d}else{if(0===d.indexOf("blob:")||0===d.indexOf("data:"))return d;if(0<=d.indexOf("?")&&(d=d.substr(0,d.indexOf("?"))),c=d.substr((Math.max(0,d.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayVideo(c))return a[b]}}return null},getAudioURL:function(a){if(this.game.sound.noAudio)return null;for(var b=0;b<a.length;b++){var c,d=a[b];if(d.uri){if(c=d.type,d=d.uri,this.game.device.canPlayAudio(c))return d}else{if(0===d.indexOf("blob:")||0===d.indexOf("data:"))return d;if(0<=d.indexOf("?")&&(d=d.substr(0,d.indexOf("?"))),c=d.substr((Math.max(0,d.lastIndexOf("."))||1/0)+1).toLowerCase(),this.game.device.canPlayAudio(c))return a[b]}}return null},fileError:function(a,b,c){var e="error loading asset from URL "+(a.requestUrl||this.transformUrl(a.url,a));!c&&b&&(c=b.status),c&&(e=e+" ("+c+")"),this.asyncComplete(a,e)},fileComplete:function(a,b){var d=!0;switch(a.type){case"packfile":var e=JSON.parse(b.responseText);a.data=e||{};break;case"image":this.cache.addImage(a.key,a.url,a.data);break;case"spritesheet":this.cache.addSpriteSheet(a.key,a.url,a.data,a.frameWidth,a.frameHeight,a.frameMax,a.margin,a.spacing);break;case"textureatlas":if(null==a.atlasURL)this.cache.addTextureAtlas(a.key,a.url,a.data,a.atlasData,a.format);else if(d=!1,a.format===c.Loader.TEXTURE_ATLAS_JSON_ARRAY||a.format===c.Loader.TEXTURE_ATLAS_JSON_HASH||a.format===c.Loader.TEXTURE_ATLAS_JSON_PYXEL)this.xhrLoad(a,this.transformUrl(a.atlasURL,a),"text",this.jsonLoadComplete);else{if(a.format!==c.Loader.TEXTURE_ATLAS_XML_STARLING)throw new Error("Phaser.Loader. Invalid Texture Atlas format: "+a.format);this.xhrLoad(a,this.transformUrl(a.atlasURL,a),"text",this.xmlLoadComplete)}break;case"bitmapfont":a.atlasURL?(d=!1,this.xhrLoad(a,this.transformUrl(a.atlasURL,a),"text",function(a,b){var c;try{c=JSON.parse(b.responseText)}catch(a){}c?(a.atlasType="json",this.jsonLoadComplete(a,b)):(a.atlasType="xml",this.xmlLoadComplete(a,b))})):this.cache.addBitmapFont(a.key,a.url,a.data,a.atlasData,a.atlasType,a.xSpacing,a.ySpacing);break;case"video":if(a.asBlob)try{a.data=b.response}catch(b){throw new Error("Phaser.Loader. Unable to parse video file as Blob: "+a.key)}this.cache.addVideo(a.key,a.url,a.data,a.asBlob);break;case"audio":this.game.sound.usingWebAudio?(a.data=b.response,this.cache.addSound(a.key,a.url,a.data,!0,!1),a.autoDecode&&this.game.sound.decode(a.key)):this.cache.addSound(a.key,a.url,a.data,!1,!0);break;case"text":a.data=b.responseText,this.cache.addText(a.key,a.url,a.data);break;case"shader":a.data=b.responseText,this.cache.addShader(a.key,a.url,a.data);break;case"physics":e=JSON.parse(b.responseText);this.cache.addPhysicsData(a.key,a.url,e,a.format);break;case"script":a.data=document.createElement("script"),a.data.language="javascript",a.data.type="text/javascript",a.data.defer=!1,a.data.text=b.responseText,document.head.appendChild(a.data),a.callback&&(a.data=a.callback.call(a.callbackContext,a.key,b.responseText));break;case"binary":a.callback?a.data=a.callback.call(a.callbackContext,a.key,b.response):a.data=b.response,this.cache.addBinary(a.key,a.data)}d&&this.asyncComplete(a)},jsonLoadComplete:function(a,b){var c=JSON.parse(b.responseText);"tilemap"===a.type?this.cache.addTilemap(a.key,a.url,c,a.format):"bitmapfont"===a.type?this.cache.addBitmapFont(a.key,a.url,a.data,c,a.atlasType,a.xSpacing,a.ySpacing):"json"===a.type?this.cache.addJSON(a.key,a.url,c):this.cache.addTextureAtlas(a.key,a.url,a.data,c,a.format),this.asyncComplete(a)},csvLoadComplete:function(a,b){var c=b.responseText;this.cache.addTilemap(a.key,a.url,c,a.format),this.asyncComplete(a)},xmlLoadComplete:function(a,b){var c=b.responseText,d=this.parseXml(c);if(d)"bitmapfont"===a.type?this.cache.addBitmapFont(a.key,a.url,a.data,d,a.atlasType,a.xSpacing,a.ySpacing):"textureatlas"===a.type?this.cache.addTextureAtlas(a.key,a.url,a.data,d,a.format):"xml"===a.type&&this.cache.addXML(a.key,a.url,d),this.asyncComplete(a);else{b.responseType||b.contentType;this.asyncComplete(a,"invalid XML")}},parseXml:function(a){var b;try{if(window.DOMParser)b=(new DOMParser).parseFromString(a,"text/xml");else(b=new ActiveXObject("Microsoft.XMLDOM")).async="false",b.loadXML(a)}catch(a){b=null}return b&&b.documentElement&&!b.getElementsByTagName("parsererror").length?b:null},updateProgress:function(){this.preloadSprite&&(0===this.preloadSprite.direction?this.preloadSprite.rect.width=Math.floor(this.preloadSprite.width/100*this.progress):this.preloadSprite.rect.height=Math.floor(this.preloadSprite.height/100*this.progress),this.preloadSprite.sprite?this.preloadSprite.sprite.updateCrop():this.preloadSprite=null)},totalLoadedFiles:function(){return this._loadedFileCount},totalQueuedFiles:function(){return this._totalFileCount-this._loadedFileCount},totalLoadedPacks:function(){return this._totalPackCount},totalQueuedPacks:function(){return this._totalPackCount-this._loadedPackCount}},Object.defineProperty(c.Loader.prototype,"progressFloat",{get:function(){var a=this._loadedFileCount/this._totalFileCount*100;return c.Math.clamp(a||0,0,100)}}),Object.defineProperty(c.Loader.prototype,"progress",{get:function(){return Math.round(this.progressFloat)}}),c.Loader.prototype.constructor=c.Loader,c.LoaderParser={bitmapFont:function(a,b,c,d){return this.xmlBitmapFont(a,b,c,d)},xmlBitmapFont:function(a,b,c,d){var e={},f=a.getElementsByTagName("info")[0],g=a.getElementsByTagName("common")[0];e.font=f.getAttribute("face"),e.size=parseInt(f.getAttribute("size"),10),e.lineHeight=parseInt(g.getAttribute("lineHeight"),10)+d,e.chars={};for(var h=a.getElementsByTagName("char"),i=0;i<h.length;i++){var j=parseInt(h[i].getAttribute("id"),10);e.chars[j]={x:parseInt(h[i].getAttribute("x"),10),y:parseInt(h[i].getAttribute("y"),10),width:parseInt(h[i].getAttribute("width"),10),height:parseInt(h[i].getAttribute("height"),10),xOffset:parseInt(h[i].getAttribute("xoffset"),10),yOffset:parseInt(h[i].getAttribute("yoffset"),10),xAdvance:parseInt(h[i].getAttribute("xadvance"),10)+c,kerning:{}}}var k=a.getElementsByTagName("kerning");for(i=0;i<k.length;i++){var l=parseInt(k[i].getAttribute("first"),10),m=parseInt(k[i].getAttribute("second"),10),n=parseInt(k[i].getAttribute("amount"),10);e.chars[m].kerning[l]=n}return this.finalizeBitmapFont(b,e)},jsonBitmapFont:function(a,b,c,d){var e={font:a.font.info._face,size:parseInt(a.font.info._size,10),lineHeight:parseInt(a.font.common._lineHeight,10)+d,chars:{}};return a.font.chars.char.forEach(function(a){var b=parseInt(a._id,10);e.chars[b]={x:parseInt(a._x,10),y:parseInt(a._y,10),width:parseInt(a._width,10),height:parseInt(a._height,10),xOffset:parseInt(a._xoffset,10),yOffset:parseInt(a._yoffset,10),xAdvance:parseInt(a._xadvance,10)+c,kerning:{}}}),a.font.kernings&&a.font.kernings.kerning&&a.font.kernings.kerning.forEach(function(a){e.chars[a._second].kerning[a._first]=parseInt(a._amount,10)}),this.finalizeBitmapFont(b,e)},finalizeBitmapFont:function(a,b){return Object.keys(b.chars).forEach(function(d){var e=b.chars[d];e.texture=new PIXI.Texture(a,new c.Rectangle(e.x,e.y,e.width,e.height))}),b}},c.AudioSprite=function(a,b){for(var c in this.game=a,this.key=b,this.config=this.game.cache.getJSON(b+"-audioatlas"),this.autoplayKey=null,this.autoplay=!1,this.sounds={},this.config.spritemap){var d=this.config.spritemap[c],e=this.game.add.sound(this.key);e.addMarker(c,d.start,d.end-d.start,null,d.loop),this.sounds[c]=e}this.config.autoplay&&(this.autoplayKey=this.config.autoplay,this.play(this.autoplayKey),this.autoplay=this.sounds[this.autoplayKey])},c.AudioSprite.prototype={play:function(a,b){return void 0===b&&(b=1),this.sounds[a].play(a,null,b)},stop:function(a){if(a)this.sounds[a].stop();else for(var b in this.sounds)this.sounds[b].stop()},get:function(a){return this.sounds[a]}},c.AudioSprite.prototype.constructor=c.AudioSprite,c.Sound=function(a,b,d,e,f){void 0===d&&(d=1),void 0===e&&(e=!1),void 0===f&&(f=a.sound.connectToMaster),this.game=a,this.name=b,this.key=b,this.loop=e,this.markers={},this.context=null,this.autoplay=!1,this.totalDuration=0,this.startTime=0,this.currentTime=0,this.duration=0,this.durationMS=0,this.position=0,this.stopTime=0,this.paused=!1,this.pausedPosition=0,this.pausedTime=0,this.isPlaying=!1,this.currentMarker="",this.fadeTween=null,this.pendingPlayback=!1,this.override=!1,this.allowMultiple=!1,this.usingWebAudio=this.game.sound.usingWebAudio,this.usingAudioTag=this.game.sound.usingAudioTag,this.externalNode=null,this.masterGainNode=null,this.gainNode=null,this._sound=null,this.usingWebAudio?(this.context=this.game.sound.context,this.masterGainNode=this.game.sound.masterGain,void 0===this.context.createGain?this.gainNode=this.context.createGainNode():this.gainNode=this.context.createGain(),this.gainNode.gain.value=d*this.game.sound.volume,f&&this.gainNode.connect(this.masterGainNode)):this.usingAudioTag&&(this.game.cache.getSound(b)&&this.game.cache.isSoundReady(b)?(this._sound=this.game.cache.getSoundData(b),this.totalDuration=0,this._sound.duration&&(this.totalDuration=this._sound.duration)):this.game.cache.onSoundUnlock.add(this.soundHasUnlocked,this)),this.onDecoded=new c.Signal,this.onPlay=new c.Signal,this.onPause=new c.Signal,this.onResume=new c.Signal,this.onLoop=new c.Signal,this.onStop=new c.Signal,this.onMute=new c.Signal,this.onMarkerComplete=new c.Signal,this.onFadeComplete=new c.Signal,this._volume=d,this._buffer=null,this._muted=!1,this._tempMarker=0,this._tempPosition=0,this._tempVolume=0,this._tempPause=0,this._muteVolume=0,this._tempLoop=0,this._paused=!1,this._onDecodedEventDispatched=!1},c.Sound.prototype={soundHasUnlocked:function(a){a===this.key&&(this._sound=this.game.cache.getSoundData(this.key),this.totalDuration=this._sound.duration)},addMarker:function(a,b,c,d,e){null!=c||(c=1),null!=d||(d=1),void 0===e&&(e=!1),this.markers[a]={name:a,start:b,stop:b+c,volume:d,duration:c,durationMS:1e3*c,loop:e}},removeMarker:function(a){delete this.markers[a]},onEndedHandler:function(){this._sound.onended=null,this.isPlaying=!1,this.currentTime=this.durationMS,this.stop()},update:function(){this.game.cache.checkSoundKey(this.key)?(this.isDecoded&&!this._onDecodedEventDispatched&&(this.onDecoded.dispatch(this),this._onDecodedEventDispatched=!0),this.pendingPlayback&&this.game.cache.isSoundReady(this.key)&&(this.pendingPlayback=!1,this.play(this._tempMarker,this._tempPosition,this._tempVolume,this._tempLoop)),this.isPlaying&&(this.currentTime=this.game.time.time-this.startTime,this.currentTime>=this.durationMS&&(this.usingWebAudio?this.loop?(this.onLoop.dispatch(this),this.isPlaying=!1,""===this.currentMarker?(this.currentTime=0,this.startTime=this.game.time.time,this.isPlaying=!0):(this.onMarkerComplete.dispatch(this.currentMarker,this),this.play(this.currentMarker,0,this.volume,!0,!0))):""!==this.currentMarker&&this.stop():this.loop?(this.onLoop.dispatch(this),""===this.currentMarker&&(this.currentTime=0,this.startTime=this.game.time.time),this.isPlaying=!1,this.play(this.currentMarker,0,this.volume,!0,!0)):this.stop()))):this.destroy()},loopFull:function(a){return this.play(null,0,a,!0)},play:function(a,b,c,d,e){if(void 0!==a&&!1!==a&&null!==a||(a=""),void 0===e&&(e=!0),this.isPlaying&&!this.allowMultiple&&!e&&!this.override)return this;if(this._sound&&this.isPlaying&&!this.allowMultiple&&(this.override||e)){if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(a){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);this.isPlaying=!1}var f=Object.keys(this.markers);if(""===a&&1===f.length&&(a=f[0]),""===a&&0<f.length)return this;if(""!==a){if(!this.markers[a])return this;this.currentMarker=a,this.position=this.markers[a].start,this.volume=this.markers[a].volume,this.loop=this.markers[a].loop,this.duration=this.markers[a].duration,this.durationMS=this.markers[a].durationMS,void 0!==c&&(this.volume=c),void 0!==d&&(this.loop=d),this._tempMarker=a,this._tempPosition=this.position,this._tempVolume=this.volume,this._tempLoop=this.loop}else b=b||0,void 0===c&&(c=this._volume),void 0===d&&(d=this.loop),this.position=Math.max(0,b),this.volume=c,this.loop=d,this.duration=0,this.durationMS=0,this._tempMarker=a,this._tempPosition=b,this._tempVolume=c,this._tempLoop=d;return this.usingWebAudio?this.game.cache.isSoundDecoded(this.key)?(this._sound=this.context.createBufferSource(),this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this._buffer=this.game.cache.getSoundData(this.key),this._sound.buffer=this._buffer,this.loop&&""===a&&(this._sound.loop=!0),this.loop||""!==a||(this._sound.onended=this.onEndedHandler.bind(this)),this.totalDuration=this._sound.buffer.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=Math.ceil(1e3*this.totalDuration)),void 0===this._sound.start?this._sound.noteGrainOn(0,this.position,this.duration):this.loop&&""===a?this._sound.start(0,0):this._sound.start(0,this.position,this.duration),this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):(this.pendingPlayback=!0,this.game.cache.getSound(this.key)&&!1===this.game.cache.getSound(this.key).isDecoding&&this.game.sound.decode(this.key,this)):this.game.cache.getSound(this.key)&&this.game.cache.getSound(this.key).locked?(this.game.cache.reloadSound(this.key),this.pendingPlayback=!0):this._sound&&(this.game.device.wechatMinigame||this.game.device.cocoonJS||4===this._sound.readyState)?(this.loop&&(this._sound.loop=!0),!this.loop&&""===a&&this.game.device.wechatMinigame&&this._sound.addEventListener("ended",this.onEndedHandler.bind(this)),this._sound.play(),this.totalDuration=this._sound.duration,0===this.duration&&(this.duration=this.totalDuration,this.durationMS=1e3*this.totalDuration),this._sound.currentTime=this.position,this._sound.muted=this._muted,this._muted||this.game.sound.mute?this._sound.volume=0:this._sound.volume=this._volume,this.isPlaying=!0,this.startTime=this.game.time.time,this.currentTime=0,this.stopTime=this.startTime+this.durationMS,this.onPlay.dispatch(this)):this.pendingPlayback=!0,this},restart:function(a,b,c,d){a=a||"",b=b||0,c=c||1,void 0===d&&(d=!1),this.play(a,b,c,d,!0)},pause:function(){this.isPlaying&&this._sound&&(this.paused=!0,this.pausedPosition=this.currentTime,this.pausedTime=this.game.time.time,this._tempPause=this._sound.currentTime,this.onPause.dispatch(this),this.stop())},resume:function(){if(this.paused&&this._sound){if(this.usingWebAudio){var a=Math.max(0,this.position+this.pausedPosition/1e3);this._sound=this.context.createBufferSource(),this._sound.buffer=this._buffer,this.externalNode?this._sound.connect(this.externalNode):this._sound.connect(this.gainNode),this.loop&&(this._sound.loop=!0),this.loop||""!==this.currentMarker||(this._sound.onended=this.onEndedHandler.bind(this));var b=this.duration-this.pausedPosition/1e3;void 0===this._sound.start?this._sound.noteGrainOn(0,a,b):this.loop&&this.game.device.chrome?42===this.game.device.chromeVersion?this._sound.start(0):this._sound.start(0,a):this._sound.start(0,a,b)}else this._sound.currentTime=this._tempPause,this._sound.play();this.isPlaying=!0,this.paused=!1,this.startTime+=this.game.time.time-this.pausedTime,this.onResume.dispatch(this)}},stop:function(){if(this.isPlaying&&this._sound)if(this.usingWebAudio){if(void 0===this._sound.stop)this._sound.noteOff(0);else try{this._sound.stop(0)}catch(a){}this.externalNode?this._sound.disconnect(this.externalNode):this.gainNode&&this._sound.disconnect(this.gainNode)}else this.usingAudioTag&&(this._sound.pause(),this._sound.currentTime=0);if(this.pendingPlayback=!1,this.isPlaying=!1,!this.paused){var a=this.currentMarker;""!==this.currentMarker&&this.onMarkerComplete.dispatch(this.currentMarker,this),this.currentMarker="",null!==this.fadeTween&&this.fadeTween.stop(),this.onStop.dispatch(this,a)}},fadeIn:function(a,b,c){void 0===b&&(b=!1),void 0===c&&(c=this.currentMarker),this.paused||(this.play(c,0,0,b),this.fadeTo(a,1))},fadeOut:function(a){this.fadeTo(a,0)},fadeTo:function(a,b){if(this.isPlaying&&!this.paused&&b!==this.volume){if(void 0===a&&(a=1e3),void 0===b)return;this.fadeTween=this.game.add.tween(this).to({volume:b},a,c.Easing.Linear.None,!0),this.fadeTween.onComplete.add(this.fadeComplete,this)}},fadeComplete:function(){this.onFadeComplete.dispatch(this,this.volume),0===this.volume&&this.stop()},updateGlobalVolume:function(a){this.usingAudioTag&&this._sound&&(this._sound.volume=a*this._volume)},destroy:function(a){void 0===a&&(a=!0),this.stop(),a?this.game.sound.remove(this):(this.markers={},this.context=null,this._buffer=null,this.externalNode=null,this.onDecoded.dispose(),this.onPlay.dispose(),this.onPause.dispose(),this.onResume.dispose(),this.onLoop.dispose(),this.onStop.dispose(),this.onMute.dispose(),this.onMarkerComplete.dispose())}},c.Sound.prototype.constructor=c.Sound,Object.defineProperty(c.Sound.prototype,"isDecoding",{get:function(){return this.game.cache.getSound(this.key).isDecoding}}),Object.defineProperty(c.Sound.prototype,"isDecoded",{get:function(){return this.game.cache.isSoundDecoded(this.key)}}),Object.defineProperty(c.Sound.prototype,"mute",{get:function(){return this._muted||this.game.sound.mute},set:function(a){(a=a||!1)!==this._muted&&(a?(this._muted=!0,this._muteVolume=this._tempVolume,this.game.device.wechatMinigame?this._sound.pause():this.usingWebAudio?this.gainNode.gain.value=0:this.usingAudioTag&&this._sound&&(this._sound.volume=0)):(this._muted=!1,this.game.device.wechatMinigame&&this.isPlaying?this._sound.play():this.usingWebAudio?this.gainNode.gain.value=this._muteVolume:this.usingAudioTag&&this._sound&&(this._sound.volume=this._muteVolume)),this.onMute.dispatch(this))}}),Object.defineProperty(c.Sound.prototype,"volume",{get:function(){return this._volume},set:function(a){this.game.device.firefox&&this.usingAudioTag&&(a=this.game.math.clamp(a,0,1)),this._muted?this._muteVolume=a:(this._tempVolume=a,this._volume=a,this.usingWebAudio?this.gainNode.gain.value=a:this.usingAudioTag&&this._sound&&(this._sound.volume=a))}}),c.SoundManager=function(a){this.game=a,this.onSoundDecode=new c.Signal,this.onVolumeChange=new c.Signal,this.onMute=new c.Signal,this.onUnMute=new c.Signal,this.context=null,this.usingWebAudio=!1,this.usingAudioTag=!1,this.noAudio=!1,this.connectToMaster=!0,this.touchLocked=!1,this.channels=32,this.muteOnPause=!0,this._codeMuted=!1,this._muted=!1,this._unlockSource=null,this._volume=1,this._sounds=[],this._watchList=new c.ArraySet,this._watching=!1,this._watchCallback=null,this._watchContext=null},c.SoundManager.prototype={boot:function(){if(this.game.device.iOS&&!1===this.game.device.webAudio&&(this.channels=1),window.PhaserGlobal){if(!0===window.PhaserGlobal.disableAudio)return this.noAudio=!0,void(this.touchLocked=!1);if(!0===window.PhaserGlobal.disableWebAudio)return this.usingAudioTag=!0,void(this.touchLocked=!1)}if(window.PhaserGlobal&&window.PhaserGlobal.audioContext)this.context=window.PhaserGlobal.audioContext;else if(window.AudioContext)try{this.context=new window.AudioContext}catch(a){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}else if(window.webkitAudioContext)try{this.context=new window.webkitAudioContext}catch(a){this.context=null,this.usingWebAudio=!1,this.touchLocked=!1}if(null===this.context){if(void 0===window.Audio)return void(this.noAudio=!0);this.usingAudioTag=!0}else this.usingWebAudio=!0,void 0===this.context.createGain?this.masterGain=this.context.createGainNode():this.masterGain=this.context.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this.context.destination);this.noAudio||!this.game.device.cocoonJS&&(this.game.device.chrome||this.game.device.iOS||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock)&&this.setTouchLock()},setTouchLock:function(){this.noAudio||window.PhaserGlobal&&!0===window.PhaserGlobal.disableAudio||(8<this.game.device.iOSVersion||55<=this.game.device.chromeVersion?this.game.input.touch.addTouchLockCallback(this.unlock,this,!0):this.game.input.touch.addTouchLockCallback(this.unlock,this),this.touchLocked=!0)},unlock:function(){if(this.noAudio||!this.touchLocked||null!==this._unlockSource)return!0;if(this.usingAudioTag)this.touchLocked=!1,this._unlockSource=null;else if(this.usingWebAudio){var a=this.context.createBuffer(1,1,22050);this._unlockSource=this.context.createBufferSource(),this._unlockSource.buffer=a,this._unlockSource.connect(this.context.destination),void 0===this._unlockSource.start?this._unlockSource.noteOn(0):this._unlockSource.start(0),"suspended"===this._unlockSource.context.state&&this._unlockSource.context.resume()}return!0},stopAll:function(){if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].stop()},pauseAll:function(){if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].pause()},resumeAll:function(){if(!this.noAudio)for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].resume()},decode:function(a,b){b=b||null;var c=this.game.cache.getSoundData(a);if(c&&!1===this.game.cache.isSoundDecoded(a)){this.game.cache.updateSound(a,"isDecoding",!0);var d=this;try{this.context.decodeAudioData(c,function(c){c&&(d.game.cache.decodedSound(a,c),d.onSoundDecode.dispatch(a,b))})}catch(a){}}},setDecodedCallback:function(a,b,d){"string"==typeof a&&(a=[a]),this._watchList.reset();for(var e=0;e<a.length;e++)a[e]instanceof c.Sound?this.game.cache.isSoundDecoded(a[e].key)||this._watchList.add(a[e].key):this.game.cache.isSoundDecoded(a[e])||this._watchList.add(a[e]);0===this._watchList.total?(this._watching=!1,b.call(d)):(this._watching=!0,this._watchCallback=b,this._watchContext=d)},update:function(){if(!this.noAudio){!this.touchLocked||null===this._unlockSource||this._unlockSource.playbackState!==this._unlockSource.PLAYING_STATE&&this._unlockSource.playbackState!==this._unlockSource.FINISHED_STATE||(this.touchLocked=!1,this._unlockSource=null);for(var a=0;a<this._sounds.length;a++)this._sounds[a].update();if(this._watching){for(var b=this._watchList.first;b;)this.game.cache.isSoundDecoded(b)&&this._watchList.remove(b),b=this._watchList.next;0===this._watchList.total&&(this._watching=!1,this._watchCallback.call(this._watchContext))}}},add:function(a,b,d,e){void 0===b&&(b=1),void 0===d&&(d=!1),void 0===e&&(e=this.connectToMaster);var f=new c.Sound(this.game,a,b,d,e);return this._sounds.push(f),f},addSprite:function(a){return new c.AudioSprite(this.game,a)},remove:function(a){for(var b=this._sounds.length;b--;)if(this._sounds[b]===a)return this._sounds[b].destroy(!1),this._sounds.splice(b,1),!0;return!1},removeByKey:function(a){for(var b=this._sounds.length,c=0;b--;)this._sounds[b].key===a&&(this._sounds[b].destroy(!1),this._sounds.splice(b,1),c++);return c},play:function(a,b,c){if(!this.noAudio){var d=this.add(a,b,c);return d.play(),d}},setMute:function(){if(!this._muted){this._muted=!0,this.usingWebAudio&&(this._muteVolume=this.masterGain.gain.value,this.masterGain.gain.value=0);for(var a=0;a<this._sounds.length;a++)this._sounds[a].usingAudioTag&&(this._sounds[a].mute=!0);this.onMute.dispatch()}},unsetMute:function(){if(this._muted&&!this._codeMuted){this._muted=!1,this.usingWebAudio&&(this.masterGain.gain.value=this._muteVolume);for(var a=0;a<this._sounds.length;a++)this._sounds[a].usingAudioTag&&(this._sounds[a].mute=!1);this.onUnMute.dispatch()}},destroy:function(){this.stopAll();for(var a=0;a<this._sounds.length;a++)this._sounds[a]&&this._sounds[a].destroy();this._sounds=[],this.onSoundDecode.dispose(),this.context&&(window.PhaserGlobal?window.PhaserGlobal.audioContext=this.context:this.context.close&&this.context.close())}},c.SoundManager.prototype.constructor=c.SoundManager,Object.defineProperty(c.SoundManager.prototype,"mute",{get:function(){return this._muted},set:function(a){if(a=a||!1){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(c.SoundManager.prototype,"volume",{get:function(){return this._volume},set:function(a){if(a<0?a=0:1<a&&(a=1),this._volume!==a){if(this._volume=a,this.usingWebAudio)this.masterGain.gain.value=a;else for(var b=0;b<this._sounds.length;b++)this._sounds[b].usingAudioTag&&this._sounds[b].updateGlobalVolume(a);this.onVolumeChange.dispatch(a)}}}),c.ScaleManager=function(a,b,d){this.game=a,this.dom=c.DOM,this.grid=null,this.width=0,this.height=0,this.minWidth=null,this.maxWidth=null,this.minHeight=null,this.maxHeight=null,this.offset=new c.Point,this.forceLandscape=!1,this.forcePortrait=!1,this.incorrectOrientation=!1,this._pageAlignHorizontally=!1,this._pageAlignVertically=!1,this.onOrientationChange=new c.Signal,this.enterIncorrectOrientation=new c.Signal,this.leaveIncorrectOrientation=new c.Signal,this.hasPhaserSetFullScreen=!1,this.fullScreenTarget=null,this._createdFullScreenTarget=null,this.onFullScreenInit=new c.Signal,this.onFullScreenChange=new c.Signal,this.onFullScreenError=new c.Signal,this.screenOrientation=this.dom.getScreenOrientation(),this.scaleFactor=new c.Point(1,1),this.scaleFactorInversed=new c.Point(1,1),this.margin={left:0,top:0,right:0,bottom:0,x:0,y:0},this.bounds=new c.Rectangle,this.aspectRatio=0,this.sourceAspectRatio=0,this.event=null,this.windowConstraints={right:"layout",bottom:""},this.compatibility={supportsFullScreen:!1,orientationFallback:null,noMargins:!1,scrollTo:null,forceMinimumDocumentHeight:!1,canExpandParent:!0,clickTrampoline:""},this._scaleMode=c.ScaleManager.NO_SCALE,this._fullScreenScaleMode=c.ScaleManager.NO_SCALE,this.parentIsWindow=!1,this.parentNode=null,this.parentScaleFactor=new c.Point(1,1),this.trackParentInterval=2e3,this.onSizeChange=new c.Signal,this.onResize=null,this.onResizeContext=null,this._pendingScaleMode=null,this._fullScreenRestore=null,this._gameSize=new c.Rectangle,this._userScaleFactor=new c.Point(1,1),this._userScaleTrim=new c.Point(0,0),this._lastUpdate=0,this._updateThrottle=0,this._updateThrottleReset=100,this._parentBounds=new c.Rectangle,this._tempBounds=new c.Rectangle,this._lastReportedCanvasSize=new c.Rectangle,this._lastReportedGameSize=new c.Rectangle,this._booted=!1,a.config&&this.parseConfig(a.config),this.setupScale(b,d)},c.ScaleManager.EXACT_FIT=0,c.ScaleManager.NO_SCALE=1,c.ScaleManager.SHOW_ALL=2,c.ScaleManager.RESIZE=3,c.ScaleManager.USER_SCALE=4,c.ScaleManager.prototype={boot:function(){var a=this.compatibility;a.supportsFullScreen=this.game.device.fullscreen&&!this.game.device.cocoonJS,this.game.device.iPad||this.game.device.webApp||this.game.device.desktop||(this.game.device.android&&!this.game.device.chrome?a.scrollTo=new c.Point(0,1):a.scrollTo=new c.Point(0,0)),this.game.device.desktop?(a.orientationFallback="screen",a.clickTrampoline="when-not-mouse"):(a.orientationFallback="",a.clickTrampoline="");var b=this;this._orientationChange=function(a){return b.orientationChange(a)},this._windowResize=function(a){return b.windowResize(a)},window.addEventListener("orientationchange",this._orientationChange,!1),window.addEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(this._fullScreenChange=function(a){return b.fullScreenChange(a)},this._fullScreenError=function(a){return b.fullScreenError(a)},document.addEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.addEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.addEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.addEventListener("fullscreenchange",this._fullScreenChange,!1),document.addEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.addEventListener("mozfullscreenerror",this._fullScreenError,!1),document.addEventListener("MSFullscreenError",this._fullScreenError,!1),document.addEventListener("fullscreenerror",this._fullScreenError,!1)),this.game.onResume.add(this._gameResumed,this),this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.setGameSize(this.game.width,this.game.height),this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),c.FlexGrid&&(this.grid=new c.FlexGrid(this,this.width,this.height)),this._booted=!0,null!==this._pendingScaleMode&&(this.scaleMode=this._pendingScaleMode,this._pendingScaleMode=null)},parseConfig:function(a){void 0!==a.scaleMode&&(this._booted?this.scaleMode=a.scaleMode:this._pendingScaleMode=a.scaleMode),void 0!==a.fullScreenScaleMode&&(this.fullScreenScaleMode=a.fullScreenScaleMode),a.fullScreenTarget&&(this.fullScreenTarget=a.fullScreenTarget)},setupScale:function(a,b){var d,e=new c.Rectangle;""!==this.game.parent&&("string"==typeof this.game.parent?d=document.getElementById(this.game.parent):this.game.parent&&1===this.game.parent.nodeType&&(d=this.game.parent)),d?(this.parentNode=d,this.parentIsWindow=!1,this.getParentBounds(this._parentBounds),e.width=this._parentBounds.width,e.height=this._parentBounds.height,this.offset.set(this._parentBounds.x,this._parentBounds.y)):(this.parentNode=null,this.parentIsWindow=!0,e.width=this.dom.visualBounds.width,e.height=this.dom.visualBounds.height,this.offset.set(0,0));var f=0,g=0;f="number"==typeof a?a:(this.parentScaleFactor.x=parseInt(a,10)/100,e.width*this.parentScaleFactor.x),g="number"==typeof b?b:(this.parentScaleFactor.y=parseInt(b,10)/100,e.height*this.parentScaleFactor.y),f=Math.floor(f),g=Math.floor(g),this._gameSize.setTo(0,0,f,g),this.updateDimensions(f,g,!1)},_gameResumed:function(){this.queueUpdate(!0)},setGameSize:function(a,b){this._gameSize.setTo(0,0,a,b),this.currentScaleMode!==c.ScaleManager.RESIZE&&this.updateDimensions(a,b,!0),this.queueUpdate(!0)},setUserScale:function(a,b,c,d){this._userScaleFactor.setTo(a,b),this._userScaleTrim.setTo(0|c,0|d),this.queueUpdate(!0)},setResizeCallback:function(a,b){this.onResize=a,this.onResizeContext=b},signalSizeChange:function(){if(!c.Rectangle.sameDimensions(this,this._lastReportedCanvasSize)||!c.Rectangle.sameDimensions(this.game,this._lastReportedGameSize)){var a=this.width,b=this.height;this._lastReportedCanvasSize.setTo(0,0,a,b),this._lastReportedGameSize.setTo(0,0,this.game.width,this.game.height),this.grid&&this.grid.onResize(a,b),this.onSizeChange.dispatch(this,a,b),this.currentScaleMode===c.ScaleManager.RESIZE&&(this.game.state.resize(a,b),this.game.load.resize(a,b))}},setMinMax:function(a,b,c,d){this.minWidth=a,this.minHeight=b,void 0!==c&&(this.maxWidth=c),void 0!==d&&(this.maxHeight=d)},preUpdate:function(){if(!(this.game.time.time<this._lastUpdate+this._updateThrottle)){var a=this._updateThrottle;this._updateThrottleReset=400<=a?0:100,this.dom.getOffset(this.game.canvas,this.offset);var b=this._parentBounds.width,d=this._parentBounds.height,e=this.getParentBounds(this._parentBounds),f=e.width!==b||e.height!==d,g=this.updateOrientationState();(f||g)&&(this.onResize&&this.onResize.call(this.onResizeContext,this,e),this.updateLayout(),this.signalSizeChange());var h=2*this._updateThrottle;this._updateThrottle<a&&(h=Math.min(a,this._updateThrottleReset)),this._updateThrottle=c.Math.clamp(h,25,this.trackParentInterval),this._lastUpdate=this.game.time.time}},pauseUpdate:function(){this.preUpdate(),this._updateThrottle=this.trackParentInterval},updateDimensions:function(a,b,c){this.width=a*this.parentScaleFactor.x,this.height=b*this.parentScaleFactor.y,this.game.width=this.width,this.game.height=this.height,this.sourceAspectRatio=this.width/this.height,this.updateScalingAndBounds(),c&&(this.game.renderer.resize(this.width,this.height),this.game.camera.setSize(this.width,this.height),this.game.world.resize(this.width,this.height))},updateScalingAndBounds:function(){this.scaleFactor.x=this.game.width/this.width,this.scaleFactor.y=this.game.height/this.height,this.scaleFactorInversed.x=this.width/this.game.width,this.scaleFactorInversed.y=this.height/this.game.height,this.aspectRatio=this.width/this.height,this.game.canvas&&this.dom.getOffset(this.game.canvas,this.offset),this.bounds.setTo(this.offset.x,this.offset.y,this.width,this.height),this.game.input&&this.game.input.scale&&this.game.input.scale.setTo(this.scaleFactor.x,this.scaleFactor.y)},forceOrientation:function(a,b){void 0===b&&(b=!1),this.forceLandscape=a,this.forcePortrait=b,this.queueUpdate(!0)},classifyOrientation:function(a){return"portrait-primary"===a||"portrait-secondary"===a?"portrait":"landscape-primary"===a||"landscape-secondary"===a?"landscape":null},updateOrientationState:function(){var a=this.screenOrientation,b=this.incorrectOrientation;this.screenOrientation=this.dom.getScreenOrientation(this.compatibility.orientationFallback),this.incorrectOrientation=this.forceLandscape&&!this.isLandscape||this.forcePortrait&&!this.isPortrait;var c=a!==this.screenOrientation,d=b!==this.incorrectOrientation;return d&&(this.incorrectOrientation?this.enterIncorrectOrientation.dispatch():this.leaveIncorrectOrientation.dispatch()),(c||d)&&this.onOrientationChange.dispatch(this,a,b),c||d},orientationChange:function(a){this.event=a,this.queueUpdate(!0)},windowResize:function(a){this.event=a,this.queueUpdate(!0)},scrollTop:function(){var a=this.compatibility.scrollTo;a&&window.scrollTo(a.x,a.y)},refresh:function(){this.scrollTop(),this.queueUpdate(!0)},updateLayout:function(){var a=this.currentScaleMode;if(a!==c.ScaleManager.RESIZE){if(this.scrollTop(),this.compatibility.forceMinimumDocumentHeight&&(document.documentElement.style.minHeight=window.innerHeight+"px"),this.incorrectOrientation?this.setMaximum():a===c.ScaleManager.EXACT_FIT?this.setExactFit():a===c.ScaleManager.SHOW_ALL?(this.setShowAll(!0),this.resetCanvas(),this.setShowAll()):a===c.ScaleManager.NO_SCALE?(this.width=this.game.width,this.height=this.game.height):a===c.ScaleManager.USER_SCALE&&(this.width=this.game.width*this._userScaleFactor.x-this._userScaleTrim.x,this.height=this.game.height*this._userScaleFactor.y-this._userScaleTrim.y),!this.compatibility.canExpandParent&&(a===c.ScaleManager.SHOW_ALL||a===c.ScaleManager.USER_SCALE)){var b=this.getParentBounds(this._tempBounds);this.width=Math.min(this.width,b.width),this.height=Math.min(this.height,b.height)}this.width=0|this.width,this.height=0|this.height,this.reflowCanvas()}else this.reflowGame()},getParentBounds:function(a){var b=a||new c.Rectangle,d=this.boundingParent,e=this.dom.visualBounds,f=this.dom.layoutBounds;if(d){var g=d.getBoundingClientRect(),h=d.offsetParent?d.offsetParent.getBoundingClientRect():d.getBoundingClientRect();b.setTo(g.left-h.left,g.top-h.top,g.width,g.height);var i=this.windowConstraints;if(i.right){var j="layout"===i.right?f:e;b.right=Math.min(b.right,j.width)}if(i.bottom){j="layout"===i.bottom?f:e;b.bottom=Math.min(b.bottom,j.height)}}else b.setTo(0,0,e.width,e.height);return b.setTo(Math.round(b.x),Math.round(b.y),Math.round(b.width),Math.round(b.height)),b},alignCanvas:function(a,b){var c=this.getParentBounds(this._tempBounds),d=this.game.canvas,e=this.margin;if(a){e.left=e.right=0;var f=d.getBoundingClientRect();if(this.width<c.width&&!this.incorrectOrientation){var g=f.left-c.x,h=c.width/2-this.width/2,i=(h=Math.max(h,0))-g;e.left=Math.round(i)}d.style.marginLeft=e.left+"px",0!==e.left&&(e.right=-(c.width-f.width-e.left),d.style.marginRight=e.right+"px")}if(b){e.top=e.bottom=0;f=d.getBoundingClientRect();if(this.height<c.height&&!this.incorrectOrientation){g=f.top-c.y,h=c.height/2-this.height/2,i=(h=Math.max(h,0))-g;e.top=Math.round(i)}d.style.marginTop=e.top+"px",0!==e.top&&(e.bottom=-(c.height-f.height-e.top),d.style.marginBottom=e.bottom+"px")}e.x=e.left,e.y=e.top},reflowGame:function(){this.resetCanvas("","");var a=this.getParentBounds(this._tempBounds);this.updateDimensions(a.width,a.height,!0)},reflowCanvas:function(){this.incorrectOrientation||(this.width=c.Math.clamp(this.width,this.minWidth||0,this.maxWidth||this.width),this.height=c.Math.clamp(this.height,this.minHeight||0,this.maxHeight||this.height)),this.resetCanvas(),this.compatibility.noMargins||(this.isFullScreen&&this._createdFullScreenTarget?this.alignCanvas(!0,!0):this.alignCanvas(this.pageAlignHorizontally,this.pageAlignVertically)),this.updateScalingAndBounds()},resetCanvas:function(a,b){void 0===a&&(a=this.width+"px"),void 0===b&&(b=this.height+"px");var c=this.game.canvas;this.compatibility.noMargins||(c.style.marginLeft="",c.style.marginTop="",c.style.marginRight="",c.style.marginBottom=""),c.style.width=a,c.style.height=b},queueUpdate:function(a){a&&(this._parentBounds.width=0,this._parentBounds.height=0),this._updateThrottle=this._updateThrottleReset},reset:function(a){a&&this.grid&&this.grid.reset()},setMaximum:function(){this.width=this.dom.visualBounds.width,this.height=this.dom.visualBounds.height},setShowAll:function(a){var b,c=this.getParentBounds(this._tempBounds),d=c.width,e=c.height;b=a?Math.max(e/this.game.height,d/this.game.width):Math.min(e/this.game.height,d/this.game.width),this.width=Math.round(this.game.width*b),this.height=Math.round(this.game.height*b)},setExactFit:function(){var a=this.getParentBounds(this._tempBounds);this.width=a.width,this.height=a.height,this.isFullScreen||(this.maxWidth&&(this.width=Math.min(this.width,this.maxWidth)),this.maxHeight&&(this.height=Math.min(this.height,this.maxHeight)))},createFullScreenTarget:function(){var a=document.createElement("div");return a.style.margin="0",a.style.padding="0",a.style.background="#000",a},startFullScreen:function(a,b){if(this.isFullScreen)return!1;if(this.compatibility.supportsFullScreen){if("when-not-mouse"===this.compatibility.clickTrampoline){var e=this.game.input;if(e.activePointer&&e.activePointer!==e.mousePointer&&(b||!1!==b))return void e.activePointer.addClickTrampoline("startFullScreen",this.startFullScreen,this,[a,!1])}void 0!==a&&this.game.renderType===c.CANVAS&&(this.game.stage.smoothed=a);var f=this.fullScreenTarget;f||(this.cleanupCreatedTarget(),this._createdFullScreenTarget=this.createFullScreenTarget(),f=this._createdFullScreenTarget);var g={targetElement:f};if(this.hasPhaserSetFullScreen=!0,this.onFullScreenInit.dispatch(this,g),this._createdFullScreenTarget){var h=this.game.canvas;h.parentNode.insertBefore(f,h),f.appendChild(h)}return this.game.device.fullscreenKeyboard?f[this.game.device.requestFullscreen](Element.ALLOW_KEYBOARD_INPUT):f[this.game.device.requestFullscreen](),!0}var d=this;setTimeout(function(){d.fullScreenError()},10)},stopFullScreen:function(){return!(!this.isFullScreen||!this.compatibility.supportsFullScreen||(this.hasPhaserSetFullScreen=!1,document[this.game.device.cancelFullscreen](),0))},cleanupCreatedTarget:function(){var a=this._createdFullScreenTarget;if(a&&a.parentNode){var b=a.parentNode;b.insertBefore(this.game.canvas,a),b.removeChild(a)}this._createdFullScreenTarget=null},prepScreenMode:function(a){var b=!!this._createdFullScreenTarget,d=this._createdFullScreenTarget||this.fullScreenTarget;a?(b||this.fullScreenScaleMode===c.ScaleManager.EXACT_FIT)&&d!==this.game.canvas&&(this._fullScreenRestore={targetWidth:d.style.width,targetHeight:d.style.height},d.style.width="100%",d.style.height="100%"):(this._fullScreenRestore&&(d.style.width=this._fullScreenRestore.targetWidth,d.style.height=this._fullScreenRestore.targetHeight,this._fullScreenRestore=null),this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.resetCanvas())},fullScreenChange:function(a){this.event=a,this.isFullScreen?this.prepScreenMode(!0):(this.prepScreenMode(!1),this.cleanupCreatedTarget()),this.updateLayout(),this.queueUpdate(!0),this.onFullScreenChange.dispatch(this,this.width,this.height)},fullScreenError:function(a){this.event=a,this.cleanupCreatedTarget(),this.onFullScreenError.dispatch(this)},scaleSprite:function(a,b,c,d){if(void 0===b&&(b=this.width),void 0===c&&(c=this.height),void 0===d&&(d=!1),!a||!a.scale)return a;if(a.scale.x=1,a.scale.y=1,a.width<=0||a.height<=0||b<=0||c<=0)return a;var e=b,f=a.height*b/a.width,g=a.width*c/a.height,h=c,i=b<g;return(i=i?d:!d)?(a.width=Math.floor(e),a.height=Math.floor(f)):(a.width=Math.floor(g),a.height=Math.floor(h)),a},destroy:function(){this.game.onResume.remove(this._gameResumed,this),window.removeEventListener("orientationchange",this._orientationChange,!1),window.removeEventListener("resize",this._windowResize,!1),this.compatibility.supportsFullScreen&&(document.removeEventListener("webkitfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("mozfullscreenchange",this._fullScreenChange,!1),document.removeEventListener("MSFullscreenChange",this._fullScreenChange,!1),document.removeEventListener("fullscreenchange",this._fullScreenChange,!1),document.removeEventListener("webkitfullscreenerror",this._fullScreenError,!1),document.removeEventListener("mozfullscreenerror",this._fullScreenError,!1),document.removeEventListener("MSFullscreenError",this._fullScreenError,!1),document.removeEventListener("fullscreenerror",this._fullScreenError,!1))}},c.ScaleManager.prototype.constructor=c.ScaleManager,Object.defineProperty(c.ScaleManager.prototype,"boundingParent",{get:function(){return this.parentIsWindow||this.isFullScreen&&this.hasPhaserSetFullScreen&&!this._createdFullScreenTarget?null:this.game.canvas&&this.game.canvas.parentNode||null}}),Object.defineProperty(c.ScaleManager.prototype,"scaleMode",{get:function(){return this._scaleMode},set:function(a){return a!==this._scaleMode&&(this.isFullScreen||(this.updateDimensions(this._gameSize.width,this._gameSize.height,!0),this.queueUpdate(!0)),this._scaleMode=a),this._scaleMode}}),Object.defineProperty(c.ScaleManager.prototype,"fullScreenScaleMode",{get:function(){return this._fullScreenScaleMode},set:function(a){return a!==this._fullScreenScaleMode&&(this.isFullScreen?(this.prepScreenMode(!1),this._fullScreenScaleMode=a,this.prepScreenMode(!0),this.queueUpdate(!0)):this._fullScreenScaleMode=a),this._fullScreenScaleMode}}),Object.defineProperty(c.ScaleManager.prototype,"currentScaleMode",{get:function(){return this.isFullScreen?this._fullScreenScaleMode:this._scaleMode}}),Object.defineProperty(c.ScaleManager.prototype,"pageAlignHorizontally",{get:function(){return this._pageAlignHorizontally},set:function(a){a!==this._pageAlignHorizontally&&(this._pageAlignHorizontally=a,this.queueUpdate(!0))}}),Object.defineProperty(c.ScaleManager.prototype,"pageAlignVertically",{get:function(){return this._pageAlignVertically},set:function(a){a!==this._pageAlignVertically&&(this._pageAlignVertically=a,this.queueUpdate(!0))}}),Object.defineProperty(c.ScaleManager.prototype,"isFullScreen",{get:function(){return!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement)}}),Object.defineProperty(c.ScaleManager.prototype,"isPortrait",{get:function(){return"portrait"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(c.ScaleManager.prototype,"isLandscape",{get:function(){return"landscape"===this.classifyOrientation(this.screenOrientation)}}),Object.defineProperty(c.ScaleManager.prototype,"isGamePortrait",{get:function(){return this.height>this.width}}),Object.defineProperty(c.ScaleManager.prototype,"isGameLandscape",{get:function(){return this.width>this.height}}),c.Utils.Debug=function(a){this.game=a,this.sprite=null,this.bmd=null,this.canvas=null,this.context=null,this.font="14px Courier",this.columnWidth=100,this.lineHeight=16,this.renderShadow=!0,this.currentX=0,this.currentY=0,this.currentAlpha=1,this.dirty=!1},c.Utils.Debug.prototype={boot:function(){this.game.renderType===c.CANVAS?this.context=this.game.context:(this.bmd=new c.BitmapData(this.game,"__DEBUG",this.game.width,this.game.height,!0),this.sprite=this.game.make.image(0,0,this.bmd),this.game.stage.addChild(this.sprite),this.game.scale.onSizeChange.add(this.resize,this),this.canvas=PIXI.CanvasPool.create(this,this.game.width,this.game.height),this.context=this.canvas.getContext("2d"))},resize:function(a,b,c){this.bmd.resize(b,c),this.canvas.width=b,this.canvas.height=c},preUpdate:function(){this.dirty&&this.sprite&&(this.bmd.clear(),this.bmd.draw(this.canvas,0,0),this.context.clearRect(0,0,this.game.width,this.game.height),this.dirty=!1)},reset:function(){this.context&&this.context.clearRect(0,0,this.game.width,this.game.height),this.sprite&&this.bmd.clear()},start:function(a,b,c,d){"number"!=typeof a&&(a=0),"number"!=typeof b&&(b=0),c=c||"rgb(255,255,255)",void 0===d&&(d=0),this.currentX=a,this.currentY=b,this.currentColor=c,this.columnWidth=d,this.dirty=!0,this.context.save(),this.context.setTransform(1,0,0,1,0,0),this.context.strokeStyle=c,this.context.fillStyle=c,this.context.font=this.font,this.context.globalAlpha=this.currentAlpha},stop:function(){this.context.restore()},line:function(){for(var a=this.currentX,b=0;b<arguments.length;b++)this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(arguments[b],a+1,this.currentY+1),this.context.fillStyle=this.currentColor),this.context.fillText(arguments[b],a,this.currentY),a+=this.columnWidth;this.currentY+=this.lineHeight},soundInfo:function(a,b,c,d){this.start(b,c,d),this.line("Sound: "+a.key+" Locked: "+a.game.sound.touchLocked),this.line("Is Ready?: "+this.game.cache.isSoundReady(a.key)+" Pending Playback: "+a.pendingPlayback),this.line("Decoded: "+a.isDecoded+" Decoding: "+a.isDecoding),this.line("Total Duration: "+a.totalDuration+" Playing: "+a.isPlaying),this.line("Time: "+a.currentTime),this.line("Volume: "+a.volume+" Muted: "+a.mute),this.line("WebAudio: "+a.usingWebAudio+" Audio: "+a.usingAudioTag),""!==a.currentMarker&&(this.line("Marker: "+a.currentMarker+" Duration: "+a.duration+" (ms: "+a.durationMS+")"),this.line("Start: "+a.markers[a.currentMarker].start+" Stop: "+a.markers[a.currentMarker].stop),this.line("Position: "+a.position)),this.stop()},cameraInfo:function(a,b,c,d){this.start(b,c,d),this.line("Camera ("+a.width+" x "+a.height+")"),this.line("X: "+a.x+" Y: "+a.y),a.bounds&&this.line("Bounds x: "+a.bounds.x+" Y: "+a.bounds.y+" w: "+a.bounds.width+" h: "+a.bounds.height),this.line("View x: "+a.view.x+" Y: "+a.view.y+" w: "+a.view.width+" h: "+a.view.height),this.line("Total in view: "+a.totalInView),this.stop()},timer:function(a,b,c,d){this.start(b,c,d),this.line("Timer (running: "+a.running+" expired: "+a.expired+")"),this.line("Next Tick: "+a.next+" Duration: "+a.duration),this.line("Paused: "+a.paused+" Length: "+a.length),this.stop()},pointer:function(a,b,c,d,e){null!=a&&(void 0===b&&(b=!1),c=c||"rgba(0,255,0,0.5)",d=d||"rgba(255,0,0,0.5)",!0===b&&!0===a.isUp||(this.start(a.x,a.y-100,e),this.context.beginPath(),this.context.arc(a.x,a.y,a.circle.radius,0,2*Math.PI),a.active?this.context.fillStyle=c:this.context.fillStyle=d,this.context.fill(),this.context.closePath(),this.context.beginPath(),this.context.moveTo(a.positionDown.x,a.positionDown.y),this.context.lineTo(a.position.x,a.position.y),this.context.lineWidth=2,this.context.stroke(),this.context.closePath(),this.line("ID: "+a.id+" Active: "+a.active),this.line("World X: "+a.worldX+" World Y: "+a.worldY),this.line("Screen X: "+a.x+" Screen Y: "+a.y+" In: "+a.withinGame),this.line("Duration: "+a.duration+" ms"),this.line("is Down: "+a.isDown+" is Up: "+a.isUp),this.stop()))},spriteInputInfo:function(a,b,c,d){this.start(b,c,d),this.line("Sprite Input: ("+a.width+" x "+a.height+")"),this.line("x: "+a.input.pointerX().toFixed(1)+" y: "+a.input.pointerY().toFixed(1)),this.line("over: "+a.input.pointerOver()+" duration: "+a.input.overDuration().toFixed(0)),this.line("down: "+a.input.pointerDown()+" duration: "+a.input.downDuration().toFixed(0)),this.line("just over: "+a.input.justOver()+" just out: "+a.input.justOut()),this.stop()},key:function(a,b,c,d){this.start(b,c,d,150),this.line("Key:",a.keyCode,"isDown:",a.isDown),this.line("justDown:",a.justDown,"justUp:",a.justUp),this.line("Time Down:",a.timeDown.toFixed(0),"duration:",a.duration.toFixed(0)),this.stop()},inputInfo:function(a,b,c){this.start(a,b,c),this.line("Input"),this.line("X: "+this.game.input.x+" Y: "+this.game.input.y),this.line("World X: "+this.game.input.worldX+" World Y: "+this.game.input.worldY),this.line("Scale X: "+this.game.input.scale.x.toFixed(1)+" Scale Y: "+this.game.input.scale.x.toFixed(1)),this.line("Screen X: "+this.game.input.activePointer.screenX+" Screen Y: "+this.game.input.activePointer.screenY),this.stop()},spriteBounds:function(a,b,c){var d=a.getBounds();d.x+=this.game.camera.x,d.y+=this.game.camera.y,this.rectangle(d,b,c)},ropeSegments:function(a,b,c){var d=this;a.segments.forEach(function(a){d.rectangle(a,b,c)},this)},spriteInfo:function(a,b,c,d){this.start(b,c,d),this.line("Sprite: ("+a.width+" x "+a.height+") anchor: "+a.anchor.x+" x "+a.anchor.y),this.line("x: "+a.x.toFixed(1)+" y: "+a.y.toFixed(1)),this.line("angle: "+a.angle.toFixed(1)+" rotation: "+a.rotation.toFixed(1)),this.line("visible: "+a.visible+" in camera: "+a.inCamera),this.line("bounds x: "+a._bounds.x.toFixed(1)+" y: "+a._bounds.y.toFixed(1)+" w: "+a._bounds.width.toFixed(1)+" h: "+a._bounds.height.toFixed(1)),this.stop()},spriteCoords:function(a,b,c,d){this.start(b,c,d,100),a.name&&this.line(a.name),this.line("x:",a.x.toFixed(2),"y:",a.y.toFixed(2)),this.line("pos x:",a.position.x.toFixed(2),"pos y:",a.position.y.toFixed(2)),this.line("world x:",a.world.x.toFixed(2),"world y:",a.world.y.toFixed(2)),this.stop()},lineInfo:function(a,b,c,d){this.start(b,c,d,80),this.line("start.x:",a.start.x.toFixed(2),"start.y:",a.start.y.toFixed(2)),this.line("end.x:",a.end.x.toFixed(2),"end.y:",a.end.y.toFixed(2)),this.line("length:",a.length.toFixed(2),"angle:",a.angle),this.stop()},pixel:function(a,b,c,d){d=d||2,this.start(),this.context.fillStyle=c,this.context.fillRect(a,b,d,d),this.stop()},geom:function(a,b,d,e){void 0===d&&(d=!0),void 0===e&&(e=0),b=b||"rgba(0,255,0,0.4)",this.start(),this.context.fillStyle=b,this.context.strokeStyle=b,a instanceof c.Rectangle||1===e?d?this.context.fillRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height):this.context.strokeRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height):a instanceof c.Circle||2===e?(this.context.beginPath(),this.context.arc(a.x-this.game.camera.x,a.y-this.game.camera.y,a.radius,0,2*Math.PI,!1),this.context.closePath(),d?this.context.fill():this.context.stroke()):a instanceof c.Point||3===e?this.context.fillRect(a.x-this.game.camera.x,a.y-this.game.camera.y,4,4):(a instanceof c.Line||4===e)&&(this.context.lineWidth=1,this.context.beginPath(),this.context.moveTo(a.start.x+.5-this.game.camera.x,a.start.y+.5-this.game.camera.y),this.context.lineTo(a.end.x+.5-this.game.camera.x,a.end.y+.5-this.game.camera.y),this.context.closePath(),this.context.stroke()),this.stop()},rectangle:function(a,b,c){void 0===c&&(c=!0),b=b||"rgba(0, 255, 0, 0.4)",this.start(),c?(this.context.fillStyle=b,this.context.fillRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height)):(this.context.strokeStyle=b,this.context.strokeRect(a.x-this.game.camera.x,a.y-this.game.camera.y,a.width,a.height)),this.stop()},text:function(a,b,c,d,e){d=d||"rgb(255,255,255)",e=e||"16px Courier",this.start(),this.context.font=e,this.renderShadow&&(this.context.fillStyle="rgb(0,0,0)",this.context.fillText(a,b+1,c+1)),this.context.fillStyle=d,this.context.fillText(a,b,c),this.stop()},quadTree:function(a,b){b=b||"rgba(255,0,0,0.3)",this.start();var c=a.bounds;if(0===a.nodes.length){this.context.strokeStyle=b,this.context.strokeRect(c.x,c.y,c.width,c.height),this.text("size: "+a.objects.length,c.x+4,c.y+16,"rgb(0,200,0)","12px Courier"),this.context.strokeStyle="rgb(0,255,0)";for(var d=0;d<a.objects.length;d++)this.context.strokeRect(a.objects[d].x,a.objects[d].y,a.objects[d].width,a.objects[d].height)}else for(d=0;d<a.nodes.length;d++)this.quadTree(a.nodes[d]);this.stop()},body:function(a,b,d){a.body&&(this.start(),a.body.type===c.Physics.ARCADE?c.Physics.Arcade.Body.render(this.context,a.body,b,d):a.body.type===c.Physics.NINJA?c.Physics.Ninja.Body.render(this.context,a.body,b,d):a.body.type===c.Physics.BOX2D&&c.Physics.Box2D.renderBody(this.context,a.body,b),this.stop())},bodyInfo:function(a,b,d,e){a.body&&(this.start(b,d,e,210),a.body.type===c.Physics.ARCADE?c.Physics.Arcade.Body.renderBodyInfo(this,a.body):a.body.type===c.Physics.BOX2D&&this.game.physics.box2d.renderBodyInfo(this,a.body),this.stop())},box2dWorld:function(){this.start(),this.context.translate(-this.game.camera.view.x,-this.game.camera.view.y,0),this.game.physics.box2d.renderDebugDraw(this.context),this.stop()},box2dBody:function(a,b){this.start(),c.Physics.Box2D.renderBody(this.context,a,b),this.stop()},displayList:function(a){if(void 0===a&&(a=this.game.world),a.hasOwnProperty("renderOrderID"),a.children&&0<a.children.length)for(var b=0;b<a.children.length;b++)this.game.debug.displayList(a.children[b])},destroy:function(){PIXI.CanvasPool.remove(this)}},c.Utils.Debug.prototype.constructor=c.Utils.Debug,c.DOM={getOffset:function(a,b){b=b||new c.Point;var d=a.getBoundingClientRect(),e=c.DOM.scrollY,f=c.DOM.scrollX,g=document.documentElement.clientTop,h=document.documentElement.clientLeft;return b.x=d.left+f-h,b.y=d.top+e-g,b},getBounds:function(a,b){return void 0===b&&(b=0),!(!(a=a&&!a.nodeType?a[0]:a)||1!==a.nodeType)&&this.calibrate(a.getBoundingClientRect(),b)},calibrate:function(a,b){b=+b||0;var c={width:0,height:0,left:0,right:0,top:0,bottom:0};return c.width=(c.right=a.right+b)-(c.left=a.left-b),c.height=(c.bottom=a.bottom+b)-(c.top=a.top-b),c},getAspectRatio:function(a){var b=(a=null==a?this.visualBounds:1===a.nodeType?this.getBounds(a):a).width,c=a.height;return"function"==typeof b&&(b=b.call(a)),"function"==typeof c&&(c=c.call(a)),b/c},inLayoutViewport:function(a,b){var c=this.getBounds(a,b);return!!c&&0<=c.bottom&&0<=c.right&&c.top<=this.layoutBounds.width&&c.left<=this.layoutBounds.height},getScreenOrientation:function(a){var b=window.screen,c=b.orientation||b.mozOrientation||b.msOrientation;if(c&&"string"==typeof c.type)return c.type;if("string"==typeof c)return c;var d="portrait-primary",e="landscape-primary";if("screen"===a)return b.height>b.width?d:e;if("viewport"===a)return this.visualBounds.height>this.visualBounds.width?d:e;if("window.orientation"===a&&"number"==typeof window.orientation)return 0===window.orientation||180===window.orientation?d:e;if(window.matchMedia){if(window.matchMedia("(orientation: portrait)").matches)return d;if(window.matchMedia("(orientation: landscape)").matches)return e}return this.visualBounds.height>this.visualBounds.width?d:e},visualBounds:new c.Rectangle,layoutBounds:new c.Rectangle,documentBounds:new c.Rectangle},c.Device.whenReady(function(a){var b=window&&"pageXOffset"in window?function(){return window.pageXOffset}:function(){return document.documentElement.scrollLeft},d=window&&"pageYOffset"in window?function(){return window.pageYOffset}:function(){return document.documentElement.scrollTop};if(Object.defineProperty(c.DOM,"scrollX",{get:b}),Object.defineProperty(c.DOM,"scrollY",{get:d}),Object.defineProperty(c.DOM.visualBounds,"x",{get:b}),Object.defineProperty(c.DOM.visualBounds,"y",{get:d}),Object.defineProperty(c.DOM.layoutBounds,"x",{value:0}),Object.defineProperty(c.DOM.layoutBounds,"y",{value:0}),a.desktop&&document.documentElement.clientWidth<=window.innerWidth&&document.documentElement.clientHeight<=window.innerHeight){var e=function(){return Math.max(window.innerWidth,document.documentElement.clientWidth)},f=function(){return Math.max(window.innerHeight,document.documentElement.clientHeight)};Object.defineProperty(c.DOM.visualBounds,"width",{get:e}),Object.defineProperty(c.DOM.visualBounds,"height",{get:f}),Object.defineProperty(c.DOM.layoutBounds,"width",{get:e}),Object.defineProperty(c.DOM.layoutBounds,"height",{get:f})}else Object.defineProperty(c.DOM.visualBounds,"width",{get:function(){return window.innerWidth}}),Object.defineProperty(c.DOM.visualBounds,"height",{get:function(){return window.innerHeight}}),Object.defineProperty(c.DOM.layoutBounds,"width",{get:function(){var a=document.documentElement.clientWidth,b=window.innerWidth;return a<b?b:a}}),Object.defineProperty(c.DOM.layoutBounds,"height",{get:function(){var a=document.documentElement.clientHeight,b=window.innerHeight;return a<b?b:a}});Object.defineProperty(c.DOM.documentBounds,"x",{value:0}),Object.defineProperty(c.DOM.documentBounds,"y",{value:0}),Object.defineProperty(c.DOM.documentBounds,"width",{get:function(){var a=document.documentElement;return Math.max(a.clientWidth,a.offsetWidth,a.scrollWidth)}}),Object.defineProperty(c.DOM.documentBounds,"height",{get:function(){var a=document.documentElement;return Math.max(a.clientHeight,a.offsetHeight,a.scrollHeight)}})},null,!0),c.ArraySet=function(a){this.position=0,this.list=a||[]},c.ArraySet.prototype={add:function(a){return this.exists(a)||this.list.push(a),a},getIndex:function(a){return this.list.indexOf(a)},getByKey:function(a,b){for(var c=this.list.length;c--;)if(this.list[c][a]===b)return this.list[c];return null},exists:function(a){return-1<this.list.indexOf(a)},reset:function(){this.list.length=0},remove:function(a){var b=this.list.indexOf(a);if(-1<b)return this.list.splice(b,1),a},setAll:function(a,b){for(var c=this.list.length;c--;)this.list[c]&&(this.list[c][a]=b)},callAll:function(a){for(var b=Array.prototype.slice.call(arguments,1),c=this.list.length;c--;)this.list[c]&&this.list[c][a]&&this.list[c][a].apply(this.list[c],b)},removeAll:function(a){void 0===a&&(a=!1);for(var b=this.list.length;b--;)if(this.list[b]){var c=this.remove(this.list[b]);a&&c.destroy()}this.position=0,this.list=[]}},Object.defineProperty(c.ArraySet.prototype,"total",{get:function(){return this.list.length}}),Object.defineProperty(c.ArraySet.prototype,"first",{get:function(){return(this.position=0)<this.list.length?this.list[0]:null}}),Object.defineProperty(c.ArraySet.prototype,"next",{get:function(){return this.position<this.list.length?(this.position++,this.list[this.position]):null}}),c.ArraySet.prototype.constructor=c.ArraySet,c.ArrayUtils={getRandomItem:function(a,b,c){if(null===a)return null;void 0===b&&(b=0),void 0===c&&(c=a.length);var d=b+Math.floor(Math.random()*c);return void 0===a[d]?null:a[d]},removeRandomItem:function(a,b,c){if(null==a)return null;void 0===b&&(b=0),void 0===c&&(c=a.length);var d=b+Math.floor(Math.random()*c);if(d<a.length){var e=a.splice(d,1);return void 0===e[0]?null:e[0]}return null},shuffle:function(a){for(var b=a.length-1;0<b;b--){var c=Math.floor(Math.random()*(b+1)),d=a[b];a[b]=a[c],a[c]=d}return a},transposeMatrix:function(a){for(var b=a.length,c=a[0].length,d=new Array(c),e=0;e<c;e++){d[e]=new Array(b);for(var f=b-1;-1<f;f--)d[e][f]=a[f][e]}return d},rotateMatrix:function(a,b){if("string"!=typeof b&&(b=(b%360+360)%360),90===b||-270===b||"rotateLeft"===b)a=(a=c.ArrayUtils.transposeMatrix(a)).reverse();else if(-90===b||270===b||"rotateRight"===b)a=a.reverse(),a=c.ArrayUtils.transposeMatrix(a);else if(180===Math.abs(b)||"rotate180"===b){for(var d=0;d<a.length;d++)a[d].reverse();a=a.reverse()}return a},findClosest:function(a,b){if(!b.length)return NaN;if(1===b.length||a<b[0])return b[0];for(var c=1;b[c]<a;)c++;var d=b[c-1],e=c<b.length?b[c]:Number.POSITIVE_INFINITY;return e-a<=a-d?e:d},rotateRight:function(a){var b=a.pop();return a.unshift(b),b},rotateLeft:function(a){var b=a.shift();return a.push(b),b},rotate:function(a){var b=a.shift();return a.push(b),b},numberArray:function(a,b){for(var c=[],d=a;d<=b;d++)c.push(d);return c},numberArrayStep:function(a,b,d){null!=a||(a=0),null!=b||(b=a,a=0),void 0===d&&(d=1);for(var e=[],f=Math.max(c.Math.roundAwayFromZero((b-a)/(d||1)),0),g=0;g<f;g++)e.push(a),a+=d;return e}},c.LinkedList=function(){this.next=null,this.prev=null,this.first=null,this.last=null,this.total=0},c.LinkedList.prototype={add:function(a){return 0===this.total&&null===this.first&&null===this.last?(this.first=a,this.last=a,(this.next=a).prev=this):((this.last.next=a).prev=this.last,this.last=a),this.total++,a},reset:function(){this.first=null,this.last=null,this.next=null,this.prev=null,this.total=0},remove:function(a){if(1===this.total)return this.reset(),void(a.next=a.prev=null);a===this.first?this.first=this.first.next:a===this.last&&(this.last=this.last.prev),a.prev&&(a.prev.next=a.next),a.next&&(a.next.prev=a.prev),a.next=a.prev=null,null===this.first&&(this.last=null),this.total--},callAll:function(a){if(this.first&&this.last)for(var b=this.first;b&&b[a]&&b[a].call(b),(b=b.next)!==this.last.next;);}},c.LinkedList.prototype.constructor=c.LinkedList,c.Create=function(a){this.game=a,this.bmd=null,this.canvas=null,this.ctx=null,this.palettes=[{0:"#000",1:"#9D9D9D",2:"#FFF",3:"#BE2633",4:"#E06F8B",5:"#493C2B",6:"#A46422",7:"#EB8931",8:"#F7E26B",9:"#2F484E",A:"#44891A",B:"#A3CE27",C:"#1B2632",D:"#005784",E:"#31A2F2",F:"#B2DCEF"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#f5f4eb"},{0:"#000",1:"#2234d1",2:"#0c7e45",3:"#44aacc",4:"#8a3622",5:"#5c2e78",6:"#aa5c3d",7:"#b5b5b5",8:"#5e606e",9:"#4c81fb",A:"#6cd947",B:"#7be2f9",C:"#eb8a60",D:"#e23d69",E:"#ffd93f",F:"#fff"},{0:"#000",1:"#fff",2:"#8b4131",3:"#7bbdc5",4:"#8b41ac",5:"#6aac41",6:"#3931a4",7:"#d5de73",8:"#945a20",9:"#5a4100",A:"#bd736a",B:"#525252",C:"#838383",D:"#acee8b",E:"#7b73de",F:"#acacac"},{0:"#000",1:"#191028",2:"#46af45",3:"#a1d685",4:"#453e78",5:"#7664fe",6:"#833129",7:"#9ec2e8",8:"#dc534b",9:"#e18d79",A:"#d6b97b",B:"#e9d8a1",C:"#216c4b",D:"#d365c8",E:"#afaab9",F:"#fff"}]},c.Create.PALETTE_ARNE=0,c.Create.PALETTE_JMP=1,c.Create.PALETTE_CGA=2,c.Create.PALETTE_C64=3,c.Create.PALETTE_JAPANESE_MACHINE=4,c.Create.prototype={texture:function(a,b,c,d,e){void 0===c&&(c=8),void 0===d&&(d=c),void 0===e&&(e=0);var f=b[0].length*c,g=b.length*d;null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(f,g),this.bmd.clear();for(var h=0;h<b.length;h++)for(var i=b[h],j=0;j<i.length;j++){var k=i[j];"."!==k&&" "!==k&&(this.ctx.fillStyle=this.palettes[e][k],this.ctx.fillRect(j*c,h*d,c,d))}return this.bmd.generateTexture(a)},grid:function(a,b,c,d,e,f){null===this.bmd&&(this.bmd=this.game.make.bitmapData(),this.canvas=this.bmd.canvas,this.ctx=this.bmd.context),this.bmd.resize(b,c),this.ctx.fillStyle=f;for(var g=0;g<c;g+=e)this.ctx.fillRect(0,g,b,1);for(var h=0;h<b;h+=d)this.ctx.fillRect(h,0,1,c);return this.bmd.generateTexture(a)}},c.Create.prototype.constructor=c.Create,c.FlexGrid=function(a,b,d){this.game=a.game,this.manager=a,this.width=b,this.height=d,this.boundsCustom=new c.Rectangle(0,0,b,d),this.boundsFluid=new c.Rectangle(0,0,b,d),this.boundsFull=new c.Rectangle(0,0,b,d),this.boundsNone=new c.Rectangle(0,0,b,d),this.positionCustom=new c.Point(0,0),this.positionFluid=new c.Point(0,0),this.positionFull=new c.Point(0,0),this.positionNone=new c.Point(0,0),this.scaleCustom=new c.Point(1,1),this.scaleFluid=new c.Point(1,1),this.scaleFluidInversed=new c.Point(1,1),this.scaleFull=new c.Point(1,1),this.scaleNone=new c.Point(1,1),this.customWidth=0,this.customHeight=0,this.customOffsetX=0,this.customOffsetY=0,this.ratioH=b/d,this.ratioV=d/b,this.multiplier=0,this.layers=[]},c.FlexGrid.prototype={setSize:function(a,b){this.width=a,this.height=b,this.ratioH=a/b,this.ratioV=b/a,this.scaleNone=new c.Point(1,1),this.boundsNone.width=this.width,this.boundsNone.height=this.height,this.refresh()},createCustomLayer:function(a,b,d,e){void 0===e&&(e=!0),this.customWidth=a,this.customHeight=b,this.boundsCustom.width=a,this.boundsCustom.height=b;var f=new c.FlexLayer(this,this.positionCustom,this.boundsCustom,this.scaleCustom);return e&&this.game.world.add(f),this.layers.push(f),void 0!==d&&null!==typeof d&&f.addMultiple(d),f},createFluidLayer:function(a,b){void 0===b&&(b=!0);var d=new c.FlexLayer(this,this.positionFluid,this.boundsFluid,this.scaleFluid);return b&&this.game.world.add(d),this.layers.push(d),void 0!==a&&null!==typeof a&&d.addMultiple(a),d},createFullLayer:function(a){var b=new c.FlexLayer(this,this.positionFull,this.boundsFull,this.scaleFluid);return this.game.world.add(b),this.layers.push(b),void 0!==a&&b.addMultiple(a),b},createFixedLayer:function(a){var b=new c.FlexLayer(this,this.positionNone,this.boundsNone,this.scaleNone);return this.game.world.add(b),this.layers.push(b),void 0!==a&&b.addMultiple(a),b},reset:function(){for(var a=this.layers.length;a--;)this.layers[a].persist||(this.layers[a].position=null,this.layers[a].scale=null,this.layers.slice(a,1))},onResize:function(a,b){this.ratioH=a/b,this.ratioV=b/a,this.refresh(a,b)},refresh:function(){this.multiplier=Math.min(this.manager.height/this.height,this.manager.width/this.width),this.boundsFluid.width=Math.round(this.width*this.multiplier),this.boundsFluid.height=Math.round(this.height*this.multiplier),this.scaleFluid.set(this.boundsFluid.width/this.width,this.boundsFluid.height/this.height),this.scaleFluidInversed.set(this.width/this.boundsFluid.width,this.height/this.boundsFluid.height),this.scaleFull.set(this.boundsFull.width/this.width,this.boundsFull.height/this.height),this.boundsFull.width=Math.round(this.manager.width*this.scaleFluidInversed.x),this.boundsFull.height=Math.round(this.manager.height*this.scaleFluidInversed.y),this.boundsFluid.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.boundsNone.centerOn(this.manager.bounds.centerX,this.manager.bounds.centerY),this.positionFluid.set(this.boundsFluid.x,this.boundsFluid.y),this.positionNone.set(this.boundsNone.x,this.boundsNone.y)},fitSprite:function(a){this.manager.scaleSprite(a),a.x=this.manager.bounds.centerX,a.y=this.manager.bounds.centerY},debug:function(){this.game.debug.text(this.boundsFluid.width+" x "+this.boundsFluid.height,this.boundsFluid.x+4,this.boundsFluid.y+16),this.game.debug.geom(this.boundsFluid,"rgba(255,0,0,0.9",!1)}},c.FlexGrid.prototype.constructor=c.FlexGrid,c.FlexLayer=function(a,b,d,e){c.Group.call(this,a.game,null,"__flexLayer"+a.game.rnd.uuid(),!1),this.manager=a.manager,this.grid=a,this.persist=!1,this.position=b,this.bounds=d,this.scale=e,this.topLeft=d.topLeft,this.topMiddle=new c.Point(d.halfWidth,0),this.topRight=d.topRight,this.bottomLeft=d.bottomLeft,this.bottomMiddle=new c.Point(d.halfWidth,d.bottom),this.bottomRight=d.bottomRight},c.FlexLayer.prototype=Object.create(c.Group.prototype),c.FlexLayer.prototype.constructor=c.FlexLayer,c.FlexLayer.prototype.resize=function(){},c.FlexLayer.prototype.debug=function(){this.game.debug.text(this.bounds.width+" x "+this.bounds.height,this.bounds.x+4,this.bounds.y+16),this.game.debug.geom(this.bounds,"rgba(0,0,255,0.9",!1),this.game.debug.geom(this.topLeft,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topMiddle,"rgba(255,255,255,0.9"),this.game.debug.geom(this.topRight,"rgba(255,255,255,0.9")},c.Color={packPixel:function(a,b,d,e){return c.Device.LITTLE_ENDIAN?(e<<24|d<<16|b<<8|a)>>>0:(a<<24|b<<16|d<<8|e)>>>0},unpackPixel:function(a,b,d,e){return null!=b||(b=c.Color.createColor()),null!=d||(d=!1),null!=e||(e=!1),c.Device.LITTLE_ENDIAN?(b.a=(4278190080&a)>>>24,b.b=(16711680&a)>>>16,b.g=(65280&a)>>>8,b.r=255&a):(b.r=(4278190080&a)>>>24,b.g=(16711680&a)>>>16,b.b=(65280&a)>>>8,b.a=255&a),b.color=a,b.rgba="rgba("+b.r+","+b.g+","+b.b+","+b.a/255+")",d&&c.Color.RGBtoHSL(b.r,b.g,b.b,b),e&&c.Color.RGBtoHSV(b.r,b.g,b.b,b),b},fromRGBA:function(a,b){return b||(b=c.Color.createColor()),b.r=(4278190080&a)>>>24,b.g=(16711680&a)>>>16,b.b=(65280&a)>>>8,b.a=255&a,b.rgba="rgba("+b.r+","+b.g+","+b.b+","+b.a+")",b},toRGBA:function(a,b,c,d){return a<<24|b<<16|c<<8|d},toABGR:function(a,b,c,d){return(d<<24|c<<16|b<<8|a)>>>0},RGBtoHSL:function(a,b,d,e){e||(e=c.Color.createColor(a,b,d,1)),a/=255,b/=255,d/=255;var f=Math.min(a,b,d),g=Math.max(a,b,d);if(e.h=0,e.s=0,e.l=(g+f)/2,g!==f){var h=g-f;e.s=.5<e.l?h/(2-g-f):h/(g+f),g===a?e.h=(b-d)/h+(b<d?6:0):g===b?e.h=(d-a)/h+2:g===d&&(e.h=(a-b)/h+4),e.h/=6}return e},HSLtoRGB:function(a,b,d,e){if(e?(e.r=d,e.g=d,e.b=d):e=c.Color.createColor(d,d,d),0!==b){var f=d<.5?d*(1+b):d+b-d*b,g=2*d-f;e.r=c.Color.hueToColor(g,f,a+1/3),e.g=c.Color.hueToColor(g,f,a),e.b=c.Color.hueToColor(g,f,a-1/3)}return e.r=Math.floor(255*e.r|0),e.g=Math.floor(255*e.g|0),e.b=Math.floor(255*e.b|0),c.Color.updateColor(e),e},RGBtoHSV:function(a,b,d,e){e||(e=c.Color.createColor(a,b,d,255)),a/=255,b/=255,d/=255;var f=Math.min(a,b,d),g=Math.max(a,b,d),h=g-f;return e.h=0,e.s=0===g?0:h/g,(e.v=g)!==f&&(g===a?e.h=(b-d)/h+(b<d?6:0):g===b?e.h=(d-a)/h+2:g===d&&(e.h=(a-b)/h+4),e.h/=6),e},HSVtoRGB:function(a,b,d,e){void 0===e&&(e=c.Color.createColor(0,0,0,1,a,b,0,d));var f,g,h,i=Math.floor(6*a),j=6*a-i,k=d*(1-b),l=d*(1-j*b),m=d*(1-(1-j)*b);switch(i%6){case 0:f=d,g=m,h=k;break;case 1:f=l,g=d,h=k;break;case 2:f=k,g=d,h=m;break;case 3:f=k,g=l,h=d;break;case 4:f=m,g=k,h=d;break;case 5:f=d,g=k,h=l}return e.r=Math.floor(255*f),e.g=Math.floor(255*g),e.b=Math.floor(255*h),c.Color.updateColor(e),e},hueToColor:function(a,b,c){return c<0&&(c+=1),1<c&&(c-=1),c<1/6?a+6*(b-a)*c:c<.5?b:c<2/3?a+(b-a)*(2/3-c)*6:a},createColor:function(a,b,d,e,f,g,h,i){var j={r:a||0,g:b||0,b:d||0,a:e||1,h:f||0,s:g||0,l:h||0,v:i||0,color:0,color32:0,rgba:""};return c.Color.updateColor(j)},updateColor:function(a){return a.rgba="rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+a.a.toString()+")",a.color=c.Color.getColor(a.r,a.g,a.b),a.color32=c.Color.getColor32(255*a.a,a.r,a.g,a.b),a},getColor32:function(a,b,c,d){return a<<24|b<<16|c<<8|d},getColor:function(a,b,c){return a<<16|b<<8|c},RGBtoString:function(a,b,d,e,f){return void 0===e&&(e=255),void 0===f&&(f="#"),"#"===f?"#"+((1<<24)+(a<<16)+(b<<8)+d).toString(16).slice(1):"0x"+c.Color.componentToHex(e)+c.Color.componentToHex(a)+c.Color.componentToHex(b)+c.Color.componentToHex(d)},hexToRGB:function(a){var b=c.Color.hexToColor(a);if(b)return c.Color.getColor32(b.a,b.r,b.g,b.b)},hexToColor:function(a,b){a=a.replace(/^(?:#|0x)?([a-f\d])([a-f\d])([a-f\d])$/i,function(a,b,c,d){return b+b+c+c+d+d});var d=/^(?:#|0x)?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a);if(d){var e=parseInt(d[1],16),f=parseInt(d[2],16),g=parseInt(d[3],16);b?(b.r=e,b.g=f,b.b=g):b=c.Color.createColor(e,f,g)}return b},webToColor:function(a,b){b||(b=c.Color.createColor());var d=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?))?\s*\)$/.exec(a);return d&&(b.r=parseInt(d[1],10),b.g=parseInt(d[2],10),b.b=parseInt(d[3],10),b.a=void 0!==d[4]?parseFloat(d[4]):1,c.Color.updateColor(b)),b},valueToColor:function(a,b){if(b||(b=c.Color.createColor()),"string"==typeof a)return 0===a.indexOf("rgb")?c.Color.webToColor(a,b):(b.a=1,c.Color.hexToColor(a,b));if("number"!=typeof a)return b;var d=c.Color.getRGB(a);return b.r=d.r,b.g=d.g,b.b=d.b,b.a=d.a/255,b},componentToHex:function(a){var b=a.toString(16);return 1===b.length?"0"+b:b},HSVColorWheel:function(a,b){void 0===a&&(a=1),void 0===b&&(b=1);for(var d=[],e=0;e<=359;e++)d.push(c.Color.HSVtoRGB(e/359,a,b));return d},HSLColorWheel:function(a,b){void 0===a&&(a=.5),void 0===b&&(b=.5);for(var d=[],e=0;e<=359;e++)d.push(c.Color.HSLtoRGB(e/359,a,b));return d},interpolateColor:function(a,b,d,e,f){void 0===f&&(f=255);var g=c.Color.getRGB(a),h=c.Color.getRGB(b),i=(h.red-g.red)*e/d+g.red,j=(h.green-g.green)*e/d+g.green,k=(h.blue-g.blue)*e/d+g.blue;return c.Color.getColor32(f,i,j,k)},interpolateColorWithRGB:function(a,b,d,e,f,g){var h=c.Color.getRGB(a),i=(b-h.red)*g/f+h.red,j=(d-h.green)*g/f+h.green,k=(e-h.blue)*g/f+h.blue;return c.Color.getColor(i,j,k)},interpolateRGB:function(a,b,d,e,f,g,h,i){var j=(e-a)*i/h+a,k=(f-b)*i/h+b,l=(g-d)*i/h+d;return c.Color.getColor(j,k,l)},getRandomColor:function(a,b,d){if(void 0===a&&(a=0),void 0===b&&(b=255),void 0===d&&(d=255),255<b||b<a)return c.Color.getColor(255,255,255);var e=a+Math.round(Math.random()*(b-a)),f=a+Math.round(Math.random()*(b-a)),g=a+Math.round(Math.random()*(b-a));return c.Color.getColor32(d,e,f,g)},getRGB:function(a){return 16777215<a?{alpha:a>>>24,red:a>>16&255,green:a>>8&255,blue:255&a,a:a>>>24,r:a>>16&255,g:a>>8&255,b:255&a}:{alpha:255,red:a>>16&255,green:a>>8&255,blue:255&a,a:255,r:a>>16&255,g:a>>8&255,b:255&a}},getWebRGB:function(a){if("object"==typeof a)return"rgba("+a.r.toString()+","+a.g.toString()+","+a.b.toString()+","+(a.a/255).toString()+")";var b=c.Color.getRGB(a);return"rgba("+b.r.toString()+","+b.g.toString()+","+b.b.toString()+","+(b.a/255).toString()+")"},getAlpha:function(a){return a>>>24},getAlphaFloat:function(a){return(a>>>24)/255},getRed:function(a){return a>>16&255},getGreen:function(a){return a>>8&255},getBlue:function(a){return 255&a},blendNormal:function(a){return a},blendLighten:function(a,b){return a<b?b:a},blendDarken:function(a,b){return a<b?a:b},blendMultiply:function(a,b){return a*b/255},blendAverage:function(a,b){return(a+b)/2},blendAdd:function(a,b){return Math.min(255,a+b)},blendSubtract:function(a,b){return Math.max(0,a+b-255)},blendDifference:function(a,b){return Math.abs(a-b)},blendNegation:function(a,b){return 255-Math.abs(255-a-b)},blendScreen:function(a,b){return 255-((255-a)*(255-b)>>8)},blendExclusion:function(a,b){return a+b-2*a*b/255},blendOverlay:function(a,b){return b<128?2*a*b/255:255-2*(255-a)*(255-b)/255},blendSoftLight:function(a,b){return b<128?2*(64+(a>>1))*(b/255):255-2*(255-(64+(a>>1)))*(255-b)/255},blendHardLight:function(a,b){return c.Color.blendOverlay(b,a)},blendColorDodge:function(a,b){return 255===b?b:Math.min(255,(a<<8)/(255-b))},blendColorBurn:function(a,b){return 0===b?b:Math.max(0,255-(255-a<<8)/b)},blendLinearDodge:function(a,b){return c.Color.blendAdd(a,b)},blendLinearBurn:function(a,b){return c.Color.blendSubtract(a,b)},blendLinearLight:function(a,b){return b<128?c.Color.blendLinearBurn(a,2*b):c.Color.blendLinearDodge(a,2*(b-128))},blendVividLight:function(a,b){return b<128?c.Color.blendColorBurn(a,2*b):c.Color.blendColorDodge(a,2*(b-128))},blendPinLight:function(a,b){return b<128?c.Color.blendDarken(a,2*b):c.Color.blendLighten(a,2*(b-128))},blendHardMix:function(a,b){return c.Color.blendVividLight(a,b)<128?0:255},blendReflect:function(a,b){return 255===b?b:Math.min(255,a*a/(255-b))},blendGlow:function(a,b){return c.Color.blendReflect(b,a)},blendPhoenix:function(a,b){return Math.min(a,b)-Math.max(a,b)+255}},c.Physics=function(a,b){b=b||{},this.game=a,this.config=b,this.arcade=null,this.p2=null,this.ninja=null,this.box2d=null,this.chipmunk=null,this.matter=null,this.parseConfig()},c.Physics.ARCADE=0,c.Physics.P2JS=1,c.Physics.NINJA=2,c.Physics.BOX2D=3,c.Physics.CHIPMUNK=4,c.Physics.MATTERJS=5,c.Physics.prototype={parseConfig:function(){this.config.hasOwnProperty("arcade")&&!0!==this.config.arcade||!c.Physics.hasOwnProperty("Arcade")||(this.arcade=new c.Physics.Arcade(this.game)),this.config.hasOwnProperty("ninja")&&!0===this.config.ninja&&c.Physics.hasOwnProperty("Ninja")&&(this.ninja=new c.Physics.Ninja(this.game)),this.config.hasOwnProperty("p2")&&!0===this.config.p2&&c.Physics.hasOwnProperty("P2")&&(this.p2=new c.Physics.P2(this.game,this.config)),this.config.hasOwnProperty("box2d")&&!0===this.config.box2d&&c.Physics.hasOwnProperty("BOX2D")&&(this.box2d=new c.Physics.BOX2D(this.game,this.config)),this.config.hasOwnProperty("matter")&&!0===this.config.matter&&c.Physics.hasOwnProperty("Matter")&&(this.matter=new c.Physics.Matter(this.game,this.config))},startSystem:function(a){a===c.Physics.ARCADE?this.arcade=new c.Physics.Arcade(this.game):a===c.Physics.P2JS?null===this.p2?this.p2=new c.Physics.P2(this.game,this.config):this.p2.reset():a===c.Physics.NINJA?this.ninja=new c.Physics.Ninja(this.game):a===c.Physics.BOX2D?null===this.box2d?this.box2d=new c.Physics.Box2D(this.game,this.config):this.box2d.reset():a===c.Physics.MATTERJS&&(null===this.matter?this.matter=new c.Physics.Matter(this.game,this.config):this.matter.reset())},enable:function(a,b,d){void 0===b&&(b=c.Physics.ARCADE),void 0===d&&(d=!1),b===c.Physics.ARCADE?this.arcade.enable(a):b===c.Physics.P2JS&&this.p2?this.p2.enable(a,d):b===c.Physics.NINJA&&this.ninja?this.ninja.enableAABB(a):b===c.Physics.BOX2D&&this.box2d?this.box2d.enable(a):b===c.Physics.MATTERJS&&this.matter&&this.matter.enable(a)},preUpdate:function(){this.p2&&this.p2.preUpdate(),this.box2d&&this.box2d.preUpdate(),this.matter&&this.matter.preUpdate()},update:function(){this.p2&&this.p2.update(),this.box2d&&this.box2d.update(),this.matter&&this.matter.update()},setBoundsToWorld:function(){this.arcade&&this.arcade.setBoundsToWorld(),this.ninja&&this.ninja.setBoundsToWorld(),this.p2&&this.p2.setBoundsToWorld(),this.box2d&&this.box2d.setBoundsToWorld(),this.matter&&this.matter.setBoundsToWorld()},clear:function(){this.p2&&this.p2.clear(),this.box2d&&this.box2d.clear(),this.matter&&this.matter.clear()},reset:function(){this.p2&&this.p2.reset(),this.box2d&&this.box2d.reset(),this.matter&&this.matter.reset()},destroy:function(){this.p2&&this.p2.destroy(),this.box2d&&this.box2d.destroy(),this.matter&&this.matter.destroy(),this.arcade=null,this.ninja=null,this.p2=null,this.box2d=null,this.matter=null}},c.Physics.prototype.constructor=c.Physics,c.Physics.Arcade=function(a){this.game=a,this.gravity=new c.Point,this.bounds=new c.Rectangle(0,0,a.world.width,a.world.height),this.checkCollision={up:!0,down:!0,left:!0,right:!0},this.maxObjects=10,this.maxLevels=4,this.OVERLAP_BIAS=4,this.forceX=!1,this.sortDirection=c.Physics.Arcade.LEFT_RIGHT,this.skipQuadTree=!0,this.isPaused=!1,this.quadTree=new c.QuadTree(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this._total=0,this.setBoundsToWorld()},c.Physics.Arcade.prototype.constructor=c.Physics.Arcade,c.Physics.Arcade.SORT_NONE=0,c.Physics.Arcade.LEFT_RIGHT=1,c.Physics.Arcade.RIGHT_LEFT=2,c.Physics.Arcade.TOP_BOTTOM=3,c.Physics.Arcade.BOTTOM_TOP=4,c.Physics.Arcade.prototype={setBounds:function(a,b,c,d){this.bounds.setTo(a,b,c,d)},setBoundsToWorld:function(){this.bounds.copyFrom(this.game.world.bounds)},enable:function(a,b){void 0===b&&(b=!0);var d=1;if(Array.isArray(a))for(d=a.length;d--;)a[d]instanceof c.Group?this.enable(a[d].children,b):(this.enableBody(a[d]),b&&a[d].hasOwnProperty("children")&&0<a[d].children.length&&this.enable(a[d],!0));else a instanceof c.Group?this.enable(a.children,b):(this.enableBody(a),b&&a.hasOwnProperty("children")&&0<a.children.length&&this.enable(a.children,!0))},enableBody:function(a){a.hasOwnProperty("body")&&null===a.body&&(a.body=new c.Physics.Arcade.Body(a),a.parent&&a.parent instanceof c.Group&&a.parent.addToHash(a))},updateMotion:function(a){var b=this.computeVelocity(0,a,a.angularVelocity,a.angularAcceleration,a.angularDrag,a.maxAngular)-a.angularVelocity;a.angularVelocity+=b,a.rotation+=a.angularVelocity*this.game.time.physicsElapsed,a.velocity.x=this.computeVelocity(1,a,a.velocity.x,a.acceleration.x,a.drag.x,a.maxVelocity.x),a.velocity.y=this.computeVelocity(2,a,a.velocity.y,a.acceleration.y,a.drag.y,a.maxVelocity.y)},computeVelocity:function(a,b,c,d,e,f){return void 0===f&&(f=1e4),1===a&&b.allowGravity?c+=(this.gravity.x+b.gravity.x)*this.game.time.physicsElapsed:2===a&&b.allowGravity&&(c+=(this.gravity.y+b.gravity.y)*this.game.time.physicsElapsed),d?c+=d*this.game.time.physicsElapsed:e&&(0<c-(e*=this.game.time.physicsElapsed)?c-=e:c+e<0?c+=e:c=0),f<c?c=f:c<-f&&(c=-f),c},overlap:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._total=0,!Array.isArray(a)&&Array.isArray(b))for(var f=0;f<b.length;f++)this.collideHandler(a,b[f],c,d,e,!0);else if(Array.isArray(a)&&!Array.isArray(b))for(f=0;f<a.length;f++)this.collideHandler(a[f],b,c,d,e,!0);else if(Array.isArray(a)&&Array.isArray(b))for(f=0;f<a.length;f++)for(var g=0;g<b.length;g++)this.collideHandler(a[f],b[g],c,d,e,!0);else this.collideHandler(a,b,c,d,e,!0);return 0<this._total},collide:function(a,b,c,d,e){if(c=c||null,d=d||null,e=e||c,this._total=0,!Array.isArray(a)&&Array.isArray(b))for(var f=0;f<b.length;f++)this.collideHandler(a,b[f],c,d,e,!1);else if(Array.isArray(a)&&!Array.isArray(b))for(f=0;f<a.length;f++)this.collideHandler(a[f],b,c,d,e,!1);else if(Array.isArray(a)&&Array.isArray(b))for(f=0;f<a.length;f++)for(var g=0;g<b.length;g++)this.collideHandler(a[f],b[g],c,d,e,!1);else this.collideHandler(a,b,c,d,e,!1);return 0<this._total},sortLeftRight:function(a,b){return a.body&&b.body?a.body.x-b.body.x:0},sortRightLeft:function(a,b){return a.body&&b.body?b.body.x-a.body.x:0},sortTopBottom:function(a,b){return a.body&&b.body?a.body.y-b.body.y:0},sortBottomTop:function(a,b){return a.body&&b.body?b.body.y-a.body.y:0},sort:function(a,b){null!==a.physicsSortDirection?b=a.physicsSortDirection:void 0===b&&(b=this.sortDirection),b===c.Physics.Arcade.LEFT_RIGHT?a.hash.sort(this.sortLeftRight):b===c.Physics.Arcade.RIGHT_LEFT?a.hash.sort(this.sortRightLeft):b===c.Physics.Arcade.TOP_BOTTOM?a.hash.sort(this.sortTopBottom):b===c.Physics.Arcade.BOTTOM_TOP&&a.hash.sort(this.sortBottomTop)},collideHandler:function(a,b,d,e,f,g){if(void 0===b&&a.physicsType===c.GROUP)return this.sort(a),void this.collideGroupVsSelf(a,d,e,f,g);a&&b&&a.exists&&b.exists&&(this.sortDirection!==c.Physics.Arcade.SORT_NONE&&(a.physicsType===c.GROUP&&this.sort(a),b.physicsType===c.GROUP&&this.sort(b)),a.physicsType===c.SPRITE?b.physicsType===c.SPRITE?this.collideSpriteVsSprite(a,b,d,e,f,g):b.physicsType===c.GROUP?this.collideSpriteVsGroup(a,b,d,e,f,g):b.physicsType===c.TILEMAPLAYER&&this.collideSpriteVsTilemapLayer(a,b,d,e,f,g):a.physicsType===c.GROUP?b.physicsType===c.SPRITE?this.collideSpriteVsGroup(b,a,d,e,f,g):b.physicsType===c.GROUP?this.collideGroupVsGroup(a,b,d,e,f,g):b.physicsType===c.TILEMAPLAYER&&this.collideGroupVsTilemapLayer(a,b,d,e,f,g):a.physicsType===c.TILEMAPLAYER&&(b.physicsType===c.SPRITE?this.collideSpriteVsTilemapLayer(b,a,d,e,f,g):b.physicsType===c.GROUP&&this.collideGroupVsTilemapLayer(b,a,d,e,f,g)))},collideSpriteVsSprite:function(a,b,c,d,e,f){return!(!a.body||!b.body||(this.separate(a.body,b.body,d,e,f)&&(c&&c.call(e,a,b),this._total++),0))},collideSpriteVsGroup:function(a,b,d,e,f,g){if(0!==b.length&&a.body)if(this.skipQuadTree||a.body.skipQuadTree)for(var h={},i=0;i<b.hash.length;i++){var j=b.hash[i];if(j&&j.exists&&j.body){if(h=j.body.getBounds(h),this.sortDirection===c.Physics.Arcade.LEFT_RIGHT){if(a.body.right<h.x)break;if(h.right<a.body.x)continue}else if(this.sortDirection===c.Physics.Arcade.RIGHT_LEFT){if(a.body.x>h.right)break;if(h.x>a.body.right)continue}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM){if(a.body.bottom<h.y)break;if(h.bottom<a.body.y)continue}else if(this.sortDirection===c.Physics.Arcade.BOTTOM_TOP){if(a.body.y>h.bottom)break;if(h.y>a.body.bottom)continue}this.collideSpriteVsSprite(a,j,d,e,f,g)}}else{this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(b);var k=this.quadTree.retrieve(a);for(i=0;i<k.length;i++)this.separate(a.body,k[i],e,f,g)&&(d&&d.call(f,a,k[i].sprite),this._total++)}},collideGroupVsSelf:function(a,b,d,e,f){if(0!==a.length)for(var g=0;g<a.hash.length;g++){var h={},i=a.hash[g];if(i&&i.exists&&i.body){h=i.body.getBounds(h);for(var j=g+1;j<a.hash.length;j++){var k={},l=a.hash[j];if(l&&l.exists&&l.body){if(k=l.body.getBounds(k),this.sortDirection===c.Physics.Arcade.LEFT_RIGHT){if(h.right<k.x)break;if(k.right<h.x)continue}else if(this.sortDirection===c.Physics.Arcade.RIGHT_LEFT){if(h.x>k.right)continue;if(k.x>h.right)break}else if(this.sortDirection===c.Physics.Arcade.TOP_BOTTOM){if(h.bottom<k.y)continue;if(k.bottom<h.y)break}else if(this.sortDirection===c.Physics.Arcade.BOTTOM_TOP){if(h.y>k.bottom)continue;if(k.y>i.body.bottom)break}this.collideSpriteVsSprite(i,l,b,d,e,f)}}}}},collideGroupVsGroup:function(a,b,d,e,f,g){if(0!==a.length&&0!==b.length)for(var h=0;h<a.children.length;h++)a.children[h].exists&&(a.children[h].physicsType===c.GROUP?this.collideGroupVsGroup(a.children[h],b,d,e,f,g):this.collideSpriteVsGroup(a.children[h],b,d,e,f,g))},separate:function(a,b,c,d,e){if(!a.enable||!b.enable||a.checkCollision.none||b.checkCollision.none||!this.intersects(a,b))return!1;if(c&&!1===c.call(d,a.sprite,b.sprite))return!1;if(a.isCircle&&b.isCircle)return this.separateCircle(a,b,e);if(a.isCircle!==b.isCircle){var f=a.isCircle?b:a,g=a.isCircle?a:b,h_x=f.x,h_y=f.y,h_right=f.right,h_bottom=f.bottom,i_x=g.x+g.radius,i_y=g.y+g.radius;if((i_y<h_y||h_bottom<i_y)&&(i_x<h_x||h_right<i_x))return this.separateCircle(a,b,e)}var j=!1,k=!1;this.forceX||Math.abs(this.gravity.y+a.gravity.y)<Math.abs(this.gravity.x+a.gravity.x)?(j=this.separateX(a,b,e),this.intersects(a,b)&&(k=this.separateY(a,b,e))):(k=this.separateY(a,b,e),this.intersects(a,b)&&(j=this.separateX(a,b,e)));var l=j||k;return l&&(e?(a.onOverlap&&a.onOverlap.dispatch(a.sprite,b.sprite),b.onOverlap&&b.onOverlap.dispatch(b.sprite,a.sprite)):(a.onCollide&&a.onCollide.dispatch(a.sprite,b.sprite),b.onCollide&&b.onCollide.dispatch(b.sprite,a.sprite))),l},intersects:function(a,b){return a!==b&&(a.isCircle?b.isCircle?c.Math.distance(a.center.x,a.center.y,b.center.x,b.center.y)<=a.radius+b.radius:this.circleBodyIntersects(a,b):b.isCircle?this.circleBodyIntersects(b,a):!(a.right<=b.position.x||a.bottom<=b.position.y||a.position.x>=b.right||a.position.y>=b.bottom))},circleBodyIntersects:function(a,b){var d=c.Math.clamp(a.center.x,b.left,b.right),e=c.Math.clamp(a.center.y,b.top,b.bottom);return(a.center.x-d)*(a.center.x-d)+(a.center.y-e)*(a.center.y-e)<=a.radius*a.radius},separateCircle:function(a,b,d){this.getOverlapX(a,b),this.getOverlapY(a,b);var e=b.center.x-a.center.x,f=b.center.y-a.center.y,g=Math.atan2(f,e),h=0;if(a.isCircle!==b.isCircle){var i={x:b.isCircle?a.position.x:b.position.x,y:b.isCircle?a.position.y:b.position.y,right:b.isCircle?a.right:b.right,bottom:b.isCircle?a.bottom:b.bottom},j={x:a.isCircle?a.position.x+a.radius:b.position.x+b.radius,y:a.isCircle?a.position.y+a.radius:b.position.y+b.radius,radius:a.isCircle?a.radius:b.radius};j.y<i.y?j.x<i.x?h=c.Math.distance(j.x,j.y,i.x,i.y)-j.radius:i.right<j.x&&(h=c.Math.distance(j.x,j.y,i.right,i.y)-j.radius):i.bottom<j.y&&(j.x<i.x?h=c.Math.distance(j.x,j.y,i.x,i.bottom)-j.radius:i.right<j.x&&(h=c.Math.distance(j.x,j.y,i.right,i.bottom)-j.radius)),h*=-1}else h=a.radius+b.radius-c.Math.distance(a.center.x,a.center.y,b.center.x,b.center.y);if(d||0===h||a.immovable&&b.immovable||a.customSeparateX||b.customSeparateX)return 0!==h&&(a.onOverlap&&a.onOverlap.dispatch(a.sprite,b.sprite),b.onOverlap&&b.onOverlap.dispatch(b.sprite,a.sprite)),0!==h;var k_x=a.velocity.x*Math.cos(g)+a.velocity.y*Math.sin(g),k_y=a.velocity.x*Math.sin(g)-a.velocity.y*Math.cos(g),l_x=b.velocity.x*Math.cos(g)+b.velocity.y*Math.sin(g),l_y=b.velocity.x*Math.sin(g)-b.velocity.y*Math.cos(g),m=((a.mass-b.mass)*k_x+2*b.mass*l_x)/(a.mass+b.mass),n=(2*a.mass*k_x+(b.mass-a.mass)*l_x)/(a.mass+b.mass);return a.immovable||(a.velocity.x=(m*Math.cos(g)-k_y*Math.sin(g))*a.bounce.x,a.velocity.y=(k_y*Math.cos(g)+m*Math.sin(g))*a.bounce.y),b.immovable||(b.velocity.x=(n*Math.cos(g)-l_y*Math.sin(g))*b.bounce.x,b.velocity.y=(l_y*Math.cos(g)+n*Math.sin(g))*b.bounce.y),Math.abs(g)<Math.PI/2?0<a.velocity.x&&!a.immovable&&b.velocity.x>a.velocity.x?a.velocity.x*=-1:b.velocity.x<0&&!b.immovable&&a.velocity.x<b.velocity.x?b.velocity.x*=-1:0<a.velocity.y&&!a.immovable&&b.velocity.y>a.velocity.y?a.velocity.y*=-1:b.velocity.y<0&&!b.immovable&&a.velocity.y<b.velocity.y&&(b.velocity.y*=-1):Math.abs(g)>Math.PI/2&&(a.velocity.x<0&&!a.immovable&&b.velocity.x<a.velocity.x?a.velocity.x*=-1:0<b.velocity.x&&!b.immovable&&a.velocity.x>b.velocity.x?b.velocity.x*=-1:a.velocity.y<0&&!a.immovable&&b.velocity.y<a.velocity.y?a.velocity.y*=-1:0<b.velocity.y&&!b.immovable&&a.velocity.x>b.velocity.y&&(b.velocity.y*=-1)),a.immovable||(a.x+=a.velocity.x*this.game.time.physicsElapsed-h*Math.cos(g),a.y+=a.velocity.y*this.game.time.physicsElapsed-h*Math.sin(g)),b.immovable||(b.x+=b.velocity.x*this.game.time.physicsElapsed+h*Math.cos(g),b.y+=b.velocity.y*this.game.time.physicsElapsed+h*Math.sin(g)),a.onCollide&&a.onCollide.dispatch(a.sprite,b.sprite),b.onCollide&&b.onCollide.dispatch(b.sprite,a.sprite),!0},getOverlapX:function(a,b,c){var d=0,e=a.deltaAbsX()+b.deltaAbsX()+this.OVERLAP_BIAS;return 0===a.deltaX()&&0===b.deltaX()?(a.embedded=!0,b.embedded=!0):a.deltaX()>b.deltaX()?e<(d=a.right-b.x)&&!c||!1===a.checkCollision.right||!1===b.checkCollision.left?d=0:(a.touching.none=!1,a.touching.right=!0,b.touching.none=!1,b.touching.left=!0):a.deltaX()<b.deltaX()&&(e<-(d=a.x-b.width-b.x)&&!c||!1===a.checkCollision.left||!1===b.checkCollision.right?d=0:(a.touching.none=!1,a.touching.left=!0,b.touching.none=!1,b.touching.right=!0)),a.overlapX=d,b.overlapX=d},getOverlapY:function(a,b,c){var d=0,e=a.deltaAbsY()+b.deltaAbsY()+this.OVERLAP_BIAS;return 0===a.deltaY()&&0===b.deltaY()?(a.embedded=!0,b.embedded=!0):a.deltaY()>b.deltaY()?e<(d=a.bottom-b.y)&&!c||!1===a.checkCollision.down||!1===b.checkCollision.up?d=0:(a.touching.none=!1,a.touching.down=!0,b.touching.none=!1,b.touching.up=!0):a.deltaY()<b.deltaY()&&(e<-(d=a.y-b.bottom)&&!c||!1===a.checkCollision.up||!1===b.checkCollision.down?d=0:(a.touching.none=!1,a.touching.up=!0,b.touching.none=!1,b.touching.down=!0)),a.overlapY=d,b.overlapY=d},separateX:function(a,b,c){var d=this.getOverlapX(a,b,c);if(c||0===d||a.immovable&&b.immovable||a.customSeparateX||b.customSeparateX)return 0!==d||a.embedded&&b.embedded;var e=a.velocity.x,f=b.velocity.x;if(a.immovable||b.immovable)a.immovable?(b.x+=d,b.velocity.x=e-f*b.bounce.x,a.moves&&(b.y+=(a.y-a.prev.y)*a.friction.y)):(a.x-=d,a.velocity.x=f-e*a.bounce.x,b.moves&&(a.y+=(b.y-b.prev.y)*b.friction.y));else{d*=.5,a.x-=d,b.x+=d;var g=Math.sqrt(f*f*b.mass/a.mass)*(0<f?1:-1),h=Math.sqrt(e*e*a.mass/b.mass)*(0<e?1:-1),i=.5*(g+h);g-=i,h-=i,a.velocity.x=i+g*a.bounce.x,b.velocity.x=i+h*b.bounce.x}return!0},separateY:function(a,b,c){var d=this.getOverlapY(a,b,c);if(c||0===d||a.immovable&&b.immovable||a.customSeparateY||b.customSeparateY)return 0!==d||a.embedded&&b.embedded;var e=a.velocity.y,f=b.velocity.y;if(a.immovable||b.immovable)a.immovable?(b.y+=d,b.velocity.y=e-f*b.bounce.y,a.moves&&(b.x+=(a.x-a.prev.x)*a.friction.x)):(a.y-=d,a.velocity.y=f-e*a.bounce.y,b.moves&&(a.x+=(b.x-b.prev.x)*b.friction.x));else{d*=.5,a.y-=d,b.y+=d;var g=Math.sqrt(f*f*b.mass/a.mass)*(0<f?1:-1),h=Math.sqrt(e*e*a.mass/b.mass)*(0<e?1:-1),i=.5*(g+h);g-=i,h-=i,a.velocity.y=i+g*a.bounce.y,b.velocity.y=i+h*b.bounce.y}return!0},getObjectsUnderPointer:function(a,b,c,d){if(0!==b.length&&a.exists)return this.getObjectsAtLocation(a.x,a.y,b,c,d,a)},getObjectsAtLocation:function(a,b,d,e,f,g){this.quadTree.clear(),this.quadTree.reset(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,this.maxObjects,this.maxLevels),this.quadTree.populate(d);for(var h=new c.Rectangle(a,b,1,1),i=[],j=this.quadTree.retrieve(h),k=0;k<j.length;k++)j[k].hitTest(a,b)&&(e&&e.call(f,g,j[k].sprite),i.push(j[k].sprite));return i},moveToObject:function(a,b,c,d){void 0===c&&(c=60),void 0===d&&(d=0);var e=Math.atan2(b.y-a.y,b.x-a.x);return 0<d&&(c=this.distanceBetween(a,b)/(d/1e3)),a.body.velocity.x=Math.cos(e)*c,a.body.velocity.y=Math.sin(e)*c,e},moveToPointer:function(a,b,c,d){void 0===b&&(b=60),c=c||this.game.input.activePointer,void 0===d&&(d=0);var e=this.angleToPointer(a,c);return 0<d&&(b=this.distanceToPointer(a,c)/(d/1e3)),a.body.velocity.x=Math.cos(e)*b,a.body.velocity.y=Math.sin(e)*b,e},moveToXY:function(a,b,c,d,e){void 0===d&&(d=60),void 0===e&&(e=0);var f=Math.atan2(c-a.y,b-a.x);return 0<e&&(d=this.distanceToXY(a,b,c)/(e/1e3)),a.body.velocity.x=Math.cos(f)*d,a.body.velocity.y=Math.sin(f)*d,f},velocityFromAngle:function(a,b,d){return void 0===b&&(b=60),(d=d||new c.Point).setTo(Math.cos(this.game.math.degToRad(a))*b,Math.sin(this.game.math.degToRad(a))*b)},velocityFromRotation:function(a,b,d){return void 0===b&&(b=60),(d=d||new c.Point).setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerationFromRotation:function(a,b,d){return void 0===b&&(b=60),(d=d||new c.Point).setTo(Math.cos(a)*b,Math.sin(a)*b)},accelerateToObject:function(a,b,c,d,e){void 0===c&&(c=60),void 0===d&&(d=1e3),void 0===e&&(e=1e3);var f=this.angleBetween(a,b);return a.body.acceleration.setTo(Math.cos(f)*c,Math.sin(f)*c),a.body.maxVelocity.setTo(d,e),f},accelerateToPointer:function(a,b,c,d,e){void 0===c&&(c=60),void 0===b&&(b=this.game.input.activePointer),void 0===d&&(d=1e3),void 0===e&&(e=1e3);var f=this.angleToPointer(a,b);return a.body.acceleration.setTo(Math.cos(f)*c,Math.sin(f)*c),a.body.maxVelocity.setTo(d,e),f},accelerateToXY:function(a,b,c,d,e,f){void 0===d&&(d=60),void 0===e&&(e=1e3),void 0===f&&(f=1e3);var g=this.angleToXY(a,b,c);return a.body.acceleration.setTo(Math.cos(g)*d,Math.sin(g)*d),a.body.maxVelocity.setTo(e,f),g},distanceBetween:function(a,b,c){void 0===c&&(c=!1);var d=c?a.world.x-b.world.x:a.x-b.x,e=c?a.world.y-b.world.y:a.y-b.y;return Math.sqrt(d*d+e*e)},distanceToXY:function(a,b,c,d){void 0===d&&(d=!1);var e=d?a.world.x-b:a.x-b,f=d?a.world.y-c:a.y-c;return Math.sqrt(e*e+f*f)},distanceToPointer:function(a,b,c){void 0===b&&(b=this.game.input.activePointer),void 0===c&&(c=!1);var d=c?a.world.x-b.worldX:a.x-b.worldX,e=c?a.world.y-b.worldY:a.y-b.worldY;return Math.sqrt(d*d+e*e)},angleBetween:function(a,b,c){return void 0===c&&(c=!1),c?Math.atan2(b.world.y-a.world.y,b.world.x-a.world.x):Math.atan2(b.y-a.y,b.x-a.x)},angleBetweenCenters:function(a,b){var c=b.centerX-a.centerX,d=b.centerY-a.centerY;return Math.atan2(d,c)},angleToXY:function(a,b,c,d){return void 0===d&&(d=!1),d?Math.atan2(c-a.world.y,b-a.world.x):Math.atan2(c-a.y,b-a.x)},angleToPointer:function(a,b,c){return void 0===b&&(b=this.game.input.activePointer),void 0===c&&(c=!1),c?Math.atan2(b.worldY-a.world.y,b.worldX-a.world.x):Math.atan2(b.worldY-a.y,b.worldX-a.x)},worldAngleToPointer:function(a,b){return this.angleToPointer(a,b,!0)}},c.Physics.Arcade.Body=function(a){this.sprite=a,this.game=a.game,this.type=c.Physics.ARCADE,this.enable=!0,this.isCircle=!1,this.radius=0,this.offset=new c.Point,this.position=new c.Point(a.x,a.y),this.prev=new c.Point(this.position.x,this.position.y),this.allowRotation=!0,this.rotation=a.angle,this.preRotation=a.angle,this.width=a.width,this.height=a.height,this.sourceWidth=a.width,this.sourceHeight=a.height,a.texture&&(this.sourceWidth=a.texture.frame.width,this.sourceHeight=a.texture.frame.height),this.halfWidth=Math.abs(a.width/2),this.halfHeight=Math.abs(a.height/2),this.center=new c.Point(a.x+this.halfWidth,a.y+this.halfHeight),this.velocity=new c.Point,this.newVelocity=new c.Point,this.deltaMax=new c.Point,this.acceleration=new c.Point,this.drag=new c.Point,this.allowGravity=!0,this.gravity=new c.Point,this.bounce=new c.Point,this.worldBounce=null,this.onWorldBounds=null,this.onCollide=null,this.onOverlap=null,this.maxVelocity=new c.Point(1e4,1e4),this.friction=new c.Point(1,0),this.angularVelocity=0,this.angularAcceleration=0,this.angularDrag=0,this.maxAngular=1e3,this.mass=1,this.angle=0,this.speed=0,this.facing=c.NONE,this.immovable=!1,this.moves=!0,this.customSeparateX=!1,this.customSeparateY=!1,this.overlapX=0,this.overlapY=0,this.overlapR=0,this.embedded=!1,this.collideWorldBounds=!1,this.checkCollision={none:!1,any:!0,up:!0,down:!0,left:!0,right:!0},this.touching={none:!0,up:!1,down:!1,left:!1,right:!1},this.wasTouching={none:!0,up:!1,down:!1,left:!1,right:!1},this.blocked={up:!1,down:!1,left:!1,right:!1},this.tilePadding=new c.Point,this.dirty=!1,this.skipQuadTree=!1,this.syncBounds=!1,this.isMoving=!1,this.stopVelocityOnCollide=!0,this.moveTimer=0,this.moveDistance=0,this.moveDuration=0,this.moveTarget=null,this.moveEnd=null,this.onMoveComplete=new c.Signal,this.movementCallback=null,this.movementCallbackContext=null,this._reset=!0,this._sx=a.scale.x,this._sy=a.scale.y,this._dx=0,this._dy=0},c.Physics.Arcade.Body.prototype={updateBounds:function(){if(this.syncBounds){var a=this.sprite.getBounds();a.ceilAll(),a.width===this.width&&a.height===this.height||(this.width=a.width,this.height=a.height,this._reset=!0)}else{var b=Math.abs(this.sprite.scale.x),c=Math.abs(this.sprite.scale.y);b===this._sx&&c===this._sy||(this.width=this.sourceWidth*b,this.height=this.sourceHeight*c,this._sx=b,this._sy=c,this._reset=!0)}this._reset&&(this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight))},preUpdate:function(){this.enable&&!this.game.physics.arcade.isPaused&&(this.dirty=!0,this.wasTouching.none=this.touching.none,this.wasTouching.up=this.touching.up,this.wasTouching.down=this.touching.down,this.wasTouching.left=this.touching.left,this.wasTouching.right=this.touching.right,this.touching.none=!0,this.touching.up=!1,this.touching.down=!1,this.touching.left=!1,this.touching.right=!1,this.blocked.up=!1,this.blocked.down=!1,this.blocked.left=!1,this.blocked.right=!1,this.embedded=!1,this.updateBounds(),this.position.x=this.sprite.world.x-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=this.sprite.world.y-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.rotation=this.sprite.angle,this.preRotation=this.rotation,(this._reset||this.sprite.fresh)&&(this.prev.x=this.position.x,this.prev.y=this.position.y),this.moves&&(this.game.physics.arcade.updateMotion(this),this.newVelocity.set(this.velocity.x*this.game.time.physicsElapsed,this.velocity.y*this.game.time.physicsElapsed),this.position.x+=this.newVelocity.x,this.position.y+=this.newVelocity.y,this.position.x===this.prev.x&&this.position.y===this.prev.y||(this.angle=Math.atan2(this.velocity.y,this.velocity.x)),this.speed=Math.sqrt(this.velocity.x*this.velocity.x+this.velocity.y*this.velocity.y),this.collideWorldBounds&&this.checkWorldBounds()&&this.onWorldBounds&&this.onWorldBounds.dispatch(this.sprite,this.blocked.up,this.blocked.down,this.blocked.left,this.blocked.right)),this._dx=this.deltaX(),this._dy=this.deltaY(),this._reset=!1)},updateMovement:function(){var a=0,b=0!==this.overlapX||0!==this.overlapY;if(a=0<this.moveDuration?(this.moveTimer+=this.game.time.elapsedMS,this.moveTimer/this.moveDuration):(this.moveTarget.end.set(this.position.x,this.position.y),this.moveTarget.length/this.moveDistance),this.movementCallback)var c=this.movementCallback.call(this.movementCallbackContext,this,this.velocity,a);return!(b||1<=a||void 0!==c&&!0!==c)||(this.stopMovement(1<=a||this.stopVelocityOnCollide&&b),!1)},stopMovement:function(a){this.isMoving&&(this.isMoving=!1,a&&this.velocity.set(0),this.onMoveComplete.dispatch(this.sprite,0!==this.overlapX||0!==this.overlapY))},postUpdate:function(){this.enable&&this.dirty&&(this.isMoving&&this.updateMovement(),this.dirty=!1,this.deltaX()<0?this.facing=c.LEFT:0<this.deltaX()&&(this.facing=c.RIGHT),this.deltaY()<0?this.facing=c.UP:0<this.deltaY()&&(this.facing=c.DOWN),this.moves&&(this._dx=this.deltaX(),this._dy=this.deltaY(),0!==this.deltaMax.x&&0!==this._dx&&(this._dx<0&&this._dx<-this.deltaMax.x?this._dx=-this.deltaMax.x:0<this._dx&&this._dx>this.deltaMax.x&&(this._dx=this.deltaMax.x)),0!==this.deltaMax.y&&0!==this._dy&&(this._dy<0&&this._dy<-this.deltaMax.y?this._dy=-this.deltaMax.y:0<this._dy&&this._dy>this.deltaMax.y&&(this._dy=this.deltaMax.y)),this.sprite.position.x+=this._dx,this.sprite.position.y+=this._dy,this._reset=!0),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.allowRotation&&(this.sprite.angle+=this.deltaZ()),this.prev.x=this.position.x,this.prev.y=this.position.y)},checkWorldBounds:function(){var a=this.position,b=this.game.physics.arcade.bounds,c=this.game.physics.arcade.checkCollision,d=this.worldBounce?-this.worldBounce.x:-this.bounce.x,e=this.worldBounce?-this.worldBounce.y:-this.bounce.y;if(this.isCircle){var f_x=this.center.x-this.radius,f_y=this.center.y-this.radius,f_right=this.center.x+this.radius,f_bottom=this.center.y+this.radius;f_x<b.x&&c.left?(a.x=b.x-this.halfWidth+this.radius,this.velocity.x*=d,this.blocked.left=!0):f_right>b.right&&c.right&&(a.x=b.right-this.halfWidth-this.radius,this.velocity.x*=d,this.blocked.right=!0),f_y<b.y&&c.up?(a.y=b.y-this.halfHeight+this.radius,this.velocity.y*=e,this.blocked.up=!0):f_bottom>b.bottom&&c.down&&(a.y=b.bottom-this.halfHeight-this.radius,this.velocity.y*=e,this.blocked.down=!0)}else a.x<b.x&&c.left?(a.x=b.x,this.velocity.x*=d,this.blocked.left=!0):this.right>b.right&&c.right&&(a.x=b.right-this.width,this.velocity.x*=d,this.blocked.right=!0),a.y<b.y&&c.up?(a.y=b.y,this.velocity.y*=e,this.blocked.up=!0):this.bottom>b.bottom&&c.down&&(a.y=b.bottom-this.height,this.velocity.y*=e,this.blocked.down=!0);return this.blocked.up||this.blocked.down||this.blocked.left||this.blocked.right},moveFrom:function(a,b,c){return void 0===b&&(b=this.speed),0!==b&&(void 0===c?(d=this.angle,c=this.game.math.radToDeg(d)):d=this.game.math.degToRad(c),this.moveTimer=0,this.moveDuration=a,0===c||180===c?this.velocity.set(Math.cos(d)*b,0):90===c||270===c?this.velocity.set(0,Math.sin(d)*b):this.velocity.set(Math.cos(d)*b,Math.sin(d)*b),this.isMoving=!0);var d},moveTo:function(a,b,d){var f,e=b/(a/1e3);return 0!==e&&(void 0===d?(f=this.angle,d=this.game.math.radToDeg(f)):f=this.game.math.degToRad(d),b=Math.abs(b),this.moveDuration=0,this.moveDistance=b,null===this.moveTarget&&(this.moveTarget=new c.Line,this.moveEnd=new c.Point),this.moveTarget.fromAngle(this.x,this.y,f,b),this.moveEnd.set(this.moveTarget.end.x,this.moveTarget.end.y),this.moveTarget.setTo(this.x,this.y,this.x,this.y),0===d||180===d?this.velocity.set(Math.cos(f)*e,0):90===d||270===d?this.velocity.set(0,Math.sin(f)*e):this.velocity.set(Math.cos(f)*e,Math.sin(f)*e),this.isMoving=!0)},setSize:function(a,b,c,d){void 0===c&&(c=this.offset.x),void 0===d&&(d=this.offset.y),this.sourceWidth=a,this.sourceHeight=b,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(c,d),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight),this.isCircle=!1,this.radius=0},setCircle:function(a,b,c){void 0===b&&(b=this.offset.x),void 0===c&&(c=this.offset.y),0<a?(this.isCircle=!0,this.radius=a,this.sourceWidth=2*a,this.sourceHeight=2*a,this.width=this.sourceWidth*this._sx,this.height=this.sourceHeight*this._sy,this.halfWidth=Math.floor(this.width/2),this.halfHeight=Math.floor(this.height/2),this.offset.setTo(b,c),this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)):this.isCircle=!1},reset:function(a,b){this.velocity.set(0),this.acceleration.set(0),this.speed=0,this.angularVelocity=0,this.angularAcceleration=0,this.position.x=a-this.sprite.anchor.x*this.sprite.width+this.sprite.scale.x*this.offset.x,this.position.x-=this.sprite.scale.x<0?this.width:0,this.position.y=b-this.sprite.anchor.y*this.sprite.height+this.sprite.scale.y*this.offset.y,this.position.y-=this.sprite.scale.y<0?this.height:0,this.prev.x=this.position.x,this.prev.y=this.position.y,this.rotation=this.sprite.angle,this.preRotation=this.rotation,this._sx=this.sprite.scale.x,this._sy=this.sprite.scale.y,this.center.setTo(this.position.x+this.halfWidth,this.position.y+this.halfHeight)},getBounds:function(a){return this.isCircle?(a.x=this.center.x-this.radius,a.y=this.center.y-this.radius,a.right=this.center.x+this.radius,a.bottom=this.center.y+this.radius):(a.x=this.x,a.y=this.y,a.right=this.right,a.bottom=this.bottom),a},hitTest:function(a,b){return this.isCircle?c.Circle.contains(this,a,b):c.Rectangle.contains(this,a,b)},onFloor:function(){return this.blocked.down},onCeiling:function(){return this.blocked.up},onWall:function(){return this.blocked.left||this.blocked.right},deltaAbsX:function(){return 0<this.deltaX()?this.deltaX():-this.deltaX()},deltaAbsY:function(){return 0<this.deltaY()?this.deltaY():-this.deltaY()},deltaX:function(){return this.position.x-this.prev.x},deltaY:function(){return this.position.y-this.prev.y},deltaZ:function(){return this.rotation-this.preRotation},destroy:function(){this.sprite.parent&&this.sprite.parent instanceof c.Group&&this.sprite.parent.removeFromHash(this.sprite),this.sprite.body=null,this.sprite=null}},Object.defineProperty(c.Physics.Arcade.Body.prototype,"left",{get:function(){return this.position.x}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"right",{get:function(){return this.position.x+this.width}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"top",{get:function(){return this.position.y}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"bottom",{get:function(){return this.position.y+this.height}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"x",{get:function(){return this.position.x},set:function(a){this.position.x=a}}),Object.defineProperty(c.Physics.Arcade.Body.prototype,"y",{get:function(){return this.position.y},set:function(a){this.position.y=a}}),c.Physics.Arcade.Body.render=function(a,b,c,d){void 0===d&&(d=!0),c=c||"rgba(0,255,0,0.4)",a.fillStyle=c,a.strokeStyle=c,b.isCircle?(a.beginPath(),a.arc(b.center.x-b.game.camera.x,b.center.y-b.game.camera.y,b.radius,0,2*Math.PI),d?a.fill():a.stroke()):d?a.fillRect(b.position.x-b.game.camera.x,b.position.y-b.game.camera.y,b.width,b.height):a.strokeRect(b.position.x-b.game.camera.x,b.position.y-b.game.camera.y,b.width,b.height)},c.Physics.Arcade.Body.renderBodyInfo=function(a,b){a.line("x: "+b.x.toFixed(2),"y: "+b.y.toFixed(2),"width: "+b.width,"height: "+b.height),a.line("velocity x: "+b.velocity.x.toFixed(2),"y: "+b.velocity.y.toFixed(2),"deltaX: "+b._dx.toFixed(2),"deltaY: "+b._dy.toFixed(2)),a.line("acceleration x: "+b.acceleration.x.toFixed(2),"y: "+b.acceleration.y.toFixed(2),"speed: "+b.speed.toFixed(2),"angle: "+b.angle.toFixed(2)),a.line("gravity x: "+b.gravity.x,"y: "+b.gravity.y,"bounce x: "+b.bounce.x.toFixed(2),"y: "+b.bounce.y.toFixed(2)),a.line("touching left: "+b.touching.left,"right: "+b.touching.right,"up: "+b.touching.up,"down: "+b.touching.down),a.line("blocked left: "+b.blocked.left,"right: "+b.blocked.right,"up: "+b.blocked.up,"down: "+b.blocked.down)},c.Physics.Arcade.Body.prototype.constructor=c.Physics.Arcade.Body,c.Physics.Arcade.TilemapCollision=function(){},c.Physics.Arcade.TilemapCollision.prototype={TILE_BIAS:16,collideSpriteVsTilemapLayer:function(a,b,c,d,e,f){if(a.body){var g=b.getTiles(a.body.position.x-a.body.tilePadding.x,a.body.position.y-a.body.tilePadding.y,a.body.width+a.body.tilePadding.x,a.body.height+a.body.tilePadding.y,!1,!1);if(0!==g.length)for(var h=0;h<g.length;h++)d?d.call(e,a,g[h])&&this.separateTile(h,a.body,g[h],b,f)&&(this._total++,c&&c.call(e,a,g[h])):this.separateTile(h,a.body,g[h],b,f)&&(this._total++,c&&c.call(e,a,g[h]))}},collideGroupVsTilemapLayer:function(a,b,c,d,e,f){if(0!==a.length)for(var g=0;g<a.children.length;g++)a.children[g].exists&&this.collideSpriteVsTilemapLayer(a.children[g],b,c,d,e,f)},separateTile:function(a,b,c,d,e){if(!b.enable)return!1;var f=d.fixedToCamera?0:d.position.x,g=d.fixedToCamera?0:d.position.y;if(!c.intersects(b.position.x-f,b.position.y-g,b.right-f,b.bottom-g))return!1;if(e)return!0;if(c.collisionCallback&&!c.collisionCallback.call(c.collisionCallbackContext,b.sprite,c))return!1;if(void 0!==c.layer.callbacks&&c.layer.callbacks[c.index]&&!c.layer.callbacks[c.index].callback.call(c.layer.callbacks[c.index].callbackContext,b.sprite,c))return!1;if(!(c.faceLeft||c.faceRight||c.faceTop||c.faceBottom))return!1;var h=0,i=0,j=0,k=1;if(b.deltaAbsX()>b.deltaAbsY()?j=-1:b.deltaAbsX()<b.deltaAbsY()&&(k=-1),0!==b.deltaX()&&0!==b.deltaY()&&(c.faceLeft||c.faceRight)&&(c.faceTop||c.faceBottom)&&(j=Math.min(Math.abs(b.position.x-f-c.right),Math.abs(b.right-f-c.left)),k=Math.min(Math.abs(b.position.y-g-c.bottom),Math.abs(b.bottom-g-c.top))),j<k){if((c.faceLeft||c.faceRight)&&0!==(h=this.tileCheckX(b,c,d))&&!c.intersects(b.position.x-f,b.position.y-g,b.right-f,b.bottom-g))return!0;(c.faceTop||c.faceBottom)&&(i=this.tileCheckY(b,c,d))}else{if((c.faceTop||c.faceBottom)&&0!==(i=this.tileCheckY(b,c,d))&&!c.intersects(b.position.x-f,b.position.y-g,b.right-f,b.bottom-g))return!0;(c.faceLeft||c.faceRight)&&(h=this.tileCheckX(b,c,d))}return 0!==h||0!==i},tileCheckX:function(a,b,c){var d=0,e=c.fixedToCamera?0:c.position.x;return a.deltaX()<0&&!a.blocked.left&&b.collideRight&&a.checkCollision.left?b.faceRight&&a.x-e<b.right&&(d=a.x-e-b.right)<-this.TILE_BIAS&&(d=0):0<a.deltaX()&&!a.blocked.right&&b.collideLeft&&a.checkCollision.right&&b.faceLeft&&a.right-e>b.left&&(d=a.right-e-b.left)>this.TILE_BIAS&&(d=0),0!==d&&(a.customSeparateX?a.overlapX=d:this.processTileSeparationX(a,d)),d},tileCheckY:function(a,b,c){var d=0,e=c.fixedToCamera?0:c.position.y;return a.deltaY()<0&&!a.blocked.up&&b.collideDown&&a.checkCollision.up?b.faceBottom&&a.y-e<b.bottom&&(d=a.y-e-b.bottom)<-this.TILE_BIAS&&(d=0):0<a.deltaY()&&!a.blocked.down&&b.collideUp&&a.checkCollision.down&&b.faceTop&&a.bottom-e>b.top&&(d=a.bottom-e-b.top)>this.TILE_BIAS&&(d=0),0!==d&&(a.customSeparateY?a.overlapY=d:this.processTileSeparationY(a,d)),d},processTileSeparationX:function(a,b){b<0?a.blocked.left=!0:0<b&&(a.blocked.right=!0),a.position.x-=b,0===a.bounce.x?a.velocity.x=0:a.velocity.x=-a.velocity.x*a.bounce.x},processTileSeparationY:function(a,b){b<0?a.blocked.up=!0:0<b&&(a.blocked.down=!0),a.position.y-=b,0===a.bounce.y?a.velocity.y=0:a.velocity.y=-a.velocity.y*a.bounce.y}},c.Utils.mixinPrototype(c.Physics.Arcade.prototype,c.Physics.Arcade.TilemapCollision.prototype),p2.Body.prototype.parent=null,p2.Spring.prototype.parent=null,c.Physics.P2=function(a,b){this.game=a,void 0===b?b={gravity:[0,0],broadphase:new p2.SAPBroadphase}:(b.hasOwnProperty("gravity")||(b.gravity=[0,0]),b.hasOwnProperty("broadphase")||(b.broadphase=new p2.SAPBroadphase)),this.config=b,this.world=new p2.World(this.config),this.frameRate=1/60,this.useElapsedTime=!1,this.paused=!1,this.materials=[],this.gravity=new c.Physics.P2.InversePointProxy(this,this.world.gravity),this.walls={left:null,right:null,top:null,bottom:null},this.onBodyAdded=new c.Signal,this.onBodyRemoved=new c.Signal,this.onSpringAdded=new c.Signal,this.onSpringRemoved=new c.Signal,this.onConstraintAdded=new c.Signal,this.onConstraintRemoved=new c.Signal,this.onContactMaterialAdded=new c.Signal,this.onContactMaterialRemoved=new c.Signal,this.postBroadphaseCallback=null,this.callbackContext=null,this.onBeginContact=new c.Signal,this.onEndContact=new c.Signal,b.hasOwnProperty("mpx")&&b.hasOwnProperty("pxm")&&b.hasOwnProperty("mpxi")&&b.hasOwnProperty("pxmi")&&(this.mpx=b.mpx,this.mpxi=b.mpxi,this.pxm=b.pxm,this.pxmi=b.pxmi),this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.collisionGroups=[],this.nothingCollisionGroup=new c.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new c.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new c.Physics.P2.CollisionGroup(2147483648),this.boundsCollidesWith=[],this._toRemove=[],this._collisionGroupID=2,this._boundsLeft=!0,this._boundsRight=!0,this._boundsTop=!0,this._boundsBottom=!0,this._boundsOwnGroup=!1,this.setBoundsToWorld(!0,!0,!0,!0,!1)},c.Physics.P2.prototype={removeBodyNextStep:function(a){this._toRemove.push(a)},preUpdate:function(){for(var a=this._toRemove.length;a--;)this.removeBody(this._toRemove[a]);this._toRemove.length=0},enable:function(a,b,d){void 0===b&&(b=!1),void 0===d&&(d=!0);var e=1;if(Array.isArray(a))for(e=a.length;e--;)a[e]instanceof c.Group?this.enable(a[e].children,b,d):(this.enableBody(a[e],b),d&&a[e].hasOwnProperty("children")&&0<a[e].children.length&&this.enable(a[e],b,!0));else a instanceof c.Group?this.enable(a.children,b,d):(this.enableBody(a,b),d&&a.hasOwnProperty("children")&&0<a.children.length&&this.enable(a.children,b,!0))},enableBody:function(a,b){a.hasOwnProperty("body")&&null===a.body&&(a.body=new c.Physics.P2.Body(this.game,a,a.x,a.y,1),a.body.debug=b,void 0!==a.anchor&&a.anchor.set(.5))},setImpactEvents:function(a){a?this.world.on("impact",this.impactHandler,this):this.world.off("impact",this.impactHandler,this)},setPostBroadphaseCallback:function(a,b){this.postBroadphaseCallback=a,this.callbackContext=b,null!==a?this.world.on("postBroadphase",this.postBroadphaseHandler,this):this.world.off("postBroadphase",this.postBroadphaseHandler,this)},postBroadphaseHandler:function(a){if(this.postBroadphaseCallback&&0!==a.pairs.length)for(var b=a.pairs.length-2;0<=b;b-=2)a.pairs[b].parent&&a.pairs[b+1].parent&&!this.postBroadphaseCallback.call(this.callbackContext,a.pairs[b].parent,a.pairs[b+1].parent)&&a.pairs.splice(b,2)},impactHandler:function(a){if(a.bodyA.parent&&a.bodyB.parent){var b=a.bodyA.parent,c=a.bodyB.parent;b._bodyCallbacks[a.bodyB.id]&&b._bodyCallbacks[a.bodyB.id].call(b._bodyCallbackContext[a.bodyB.id],b,c,a.shapeA,a.shapeB),c._bodyCallbacks[a.bodyA.id]&&c._bodyCallbacks[a.bodyA.id].call(c._bodyCallbackContext[a.bodyA.id],c,b,a.shapeB,a.shapeA),b._groupCallbacks[a.shapeB.collisionGroup]&&b._groupCallbacks[a.shapeB.collisionGroup].call(b._groupCallbackContext[a.shapeB.collisionGroup],b,c,a.shapeA,a.shapeB),c._groupCallbacks[a.shapeA.collisionGroup]&&c._groupCallbacks[a.shapeA.collisionGroup].call(c._groupCallbackContext[a.shapeA.collisionGroup],c,b,a.shapeB,a.shapeA)}},beginContactHandler:function(a){a.bodyA&&a.bodyB&&(this.onBeginContact.dispatch(a.bodyA,a.bodyB,a.shapeA,a.shapeB,a.contactEquations),a.bodyA.parent&&a.bodyA.parent.onBeginContact.dispatch(a.bodyB.parent,a.bodyB,a.shapeA,a.shapeB,a.contactEquations),a.bodyB.parent&&a.bodyB.parent.onBeginContact.dispatch(a.bodyA.parent,a.bodyA,a.shapeB,a.shapeA,a.contactEquations))},endContactHandler:function(a){a.bodyA&&a.bodyB&&(this.onEndContact.dispatch(a.bodyA,a.bodyB,a.shapeA,a.shapeB),a.bodyA.parent&&a.bodyA.parent.onEndContact.dispatch(a.bodyB.parent,a.bodyB,a.shapeA,a.shapeB),a.bodyB.parent&&a.bodyB.parent.onEndContact.dispatch(a.bodyA.parent,a.bodyA,a.shapeB,a.shapeA))},setBoundsToWorld:function(a,b,c,d,e){this.setBounds(this.game.world.bounds.x,this.game.world.bounds.y,this.game.world.bounds.width,this.game.world.bounds.height,a,b,c,d,e)},setWorldMaterial:function(a,b,c,d,e){void 0===b&&(b=!0),void 0===c&&(c=!0),void 0===d&&(d=!0),void 0===e&&(e=!0),b&&this.walls.left&&(this.walls.left.shapes[0].material=a),c&&this.walls.right&&(this.walls.right.shapes[0].material=a),d&&this.walls.top&&(this.walls.top.shapes[0].material=a),e&&this.walls.bottom&&(this.walls.bottom.shapes[0].material=a)},updateBoundsCollisionGroup:function(a){void 0===a&&(a=!0);var b=a?this.boundsCollisionGroup.mask:this.everythingCollisionGroup.mask;this.walls.left&&(this.walls.left.shapes[0].collisionGroup=b),this.walls.right&&(this.walls.right.shapes[0].collisionGroup=b),this.walls.top&&(this.walls.top.shapes[0].collisionGroup=b),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionGroup=b),this._boundsOwnGroup=a},setBounds:function(a,b,c,d,e,f,g,h,i){void 0===e&&(e=this._boundsLeft),void 0===f&&(f=this._boundsRight),void 0===g&&(g=this._boundsTop),void 0===h&&(h=this._boundsBottom),void 0===i&&(i=this._boundsOwnGroup),this.setupWall(e,"left",a,b,1.5707963267948966,i),this.setupWall(f,"right",a+c,b,-1.5707963267948966,i),this.setupWall(g,"top",a,b,-3.141592653589793,i),this.setupWall(h,"bottom",a,b+d,0,i),this._boundsLeft=e,this._boundsRight=f,this._boundsTop=g,this._boundsBottom=h,this._boundsOwnGroup=i},setupWall:function(a,b,c,d,e,f){a?(this.walls[b]?this.walls[b].position=[this.pxmi(c),this.pxmi(d)]:(this.walls[b]=new p2.Body({mass:0,position:[this.pxmi(c),this.pxmi(d)],angle:e}),this.walls[b].addShape(new p2.Plane),this.world.addBody(this.walls[b])),f&&(this.walls[b].shapes[0].collisionGroup=this.boundsCollisionGroup.mask)):this.walls[b]&&(this.world.removeBody(this.walls[b]),this.walls[b]=null)},pause:function(){this.paused=!0},resume:function(){this.paused=!1},update:function(){this.paused||(this.useElapsedTime?this.world.step(this.game.time.physicsElapsed):this.world.step(this.frameRate))},reset:function(){this.world.on("beginContact",this.beginContactHandler,this),this.world.on("endContact",this.endContactHandler,this),this.nothingCollisionGroup=new c.Physics.P2.CollisionGroup(1),this.boundsCollisionGroup=new c.Physics.P2.CollisionGroup(2),this.everythingCollisionGroup=new c.Physics.P2.CollisionGroup(2147483648),this._collisionGroupID=2,this.setBoundsToWorld(!0,!0,!0,!0,!1)},clear:function(){this.world.time=0,this.world.fixedStepTime=0,this.world.solver&&this.world.solver.equations.length&&this.world.solver.removeAllEquations();for(var a=this.world.constraints,b=a.length-1;0<=b;b--)this.world.removeConstraint(a[b]);var c=this.world.bodies;for(b=c.length-1;0<=b;b--)this.world.removeBody(c[b]);var d=this.world.springs;for(b=d.length-1;0<=b;b--)this.world.removeSpring(d[b]);var e=this.world.contactMaterials;for(b=e.length-1;0<=b;b--)this.world.removeContactMaterial(e[b]);this.world.off("beginContact",this.beginContactHandler,this),this.world.off("endContact",this.endContactHandler,this),this.postBroadphaseCallback=null,this.callbackContext=null,this.impactCallback=null,this.collisionGroups=[],this._toRemove=[],this.boundsCollidesWith=[],this.walls={left:null,right:null,top:null,bottom:null}},destroy:function(){this.clear(),this.game=null},addBody:function(a){return!a.data.world&&(this.world.addBody(a.data),this.onBodyAdded.dispatch(a),!0)},removeBody:function(a){return a.data.world===this.world&&(this.world.removeBody(a.data),this.onBodyRemoved.dispatch(a)),a},addSpring:function(a){return a instanceof c.Physics.P2.Spring||a instanceof c.Physics.P2.RotationalSpring?this.world.addSpring(a.data):this.world.addSpring(a),this.onSpringAdded.dispatch(a),a},removeSpring:function(a){return a instanceof c.Physics.P2.Spring||a instanceof c.Physics.P2.RotationalSpring?this.world.removeSpring(a.data):this.world.removeSpring(a),this.onSpringRemoved.dispatch(a),a},createDistanceConstraint:function(a,b,d,e,f,g){if(a=this.getBody(a),b=this.getBody(b),a&&b)return this.addConstraint(new c.Physics.P2.DistanceConstraint(this,a,b,d,e,f,g))},createGearConstraint:function(a,b,d,e){if(a=this.getBody(a),b=this.getBody(b),a&&b)return this.addConstraint(new c.Physics.P2.GearConstraint(this,a,b,d,e))},createRevoluteConstraint:function(a,b,d,e,f,g){if(a=this.getBody(a),d=this.getBody(d),a&&d)return this.addConstraint(new c.Physics.P2.RevoluteConstraint(this,a,b,d,e,f,g))},createLockConstraint:function(a,b,d,e,f){if(a=this.getBody(a),b=this.getBody(b),a&&b)return this.addConstraint(new c.Physics.P2.LockConstraint(this,a,b,d,e,f))},createPrismaticConstraint:function(a,b,d,e,f,g,h){if(a=this.getBody(a),b=this.getBody(b),a&&b)return this.addConstraint(new c.Physics.P2.PrismaticConstraint(this,a,b,d,e,f,g,h))},addConstraint:function(a){return this.world.addConstraint(a),this.onConstraintAdded.dispatch(a),a},removeConstraint:function(a){return this.world.removeConstraint(a),this.onConstraintRemoved.dispatch(a),a},addContactMaterial:function(a){return this.world.addContactMaterial(a),this.onContactMaterialAdded.dispatch(a),a},removeContactMaterial:function(a){return this.world.removeContactMaterial(a),this.onContactMaterialRemoved.dispatch(a),a},getContactMaterial:function(a,b){return this.world.getContactMaterial(a,b)},setMaterial:function(a,b){for(var c=b.length;c--;)b[c].setMaterial(a)},createMaterial:function(a,b){a=a||"";var d=new c.Physics.P2.Material(a);return this.materials.push(d),void 0!==b&&b.setMaterial(d),d},createContactMaterial:function(a,b,d){void 0===a&&(a=this.createMaterial()),void 0===b&&(b=this.createMaterial());var e=new c.Physics.P2.ContactMaterial(a,b,d);return this.addContactMaterial(e)},getBodies:function(){for(var a=[],b=this.world.bodies.length;b--;)a.push(this.world.bodies[b].parent);return a},getBody:function(a){return a instanceof p2.Body?a:a instanceof c.Physics.P2.Body?a.data:a.body&&a.body.type===c.Physics.P2JS?a.body.data:null},getSprings:function(){for(var a=[],b=this.world.springs.length;b--;)a.push(this.world.springs[b].parent);return a},getConstraints:function(){for(var a=[],b=this.world.constraints.length;b--;)a.push(this.world.constraints[b]);return a},hitTest:function(a,b,d,e){void 0===b&&(b=this.world.bodies),void 0===d&&(d=5),void 0===e&&(e=!1);for(var f=[this.pxmi(a.x),this.pxmi(a.y)],g=[],h=b.length;h--;)b[h]instanceof c.Physics.P2.Body&&(!e||b[h].data.type!==p2.Body.STATIC)?g.push(b[h].data):b[h]instanceof p2.Body&&b[h].parent&&(!e||b[h].type!==p2.Body.STATIC)?g.push(b[h]):b[h]instanceof c.Sprite&&b[h].hasOwnProperty("body")&&(!e||b[h].body.data.type!==p2.Body.STATIC)&&g.push(b[h].body.data);return this.world.hitTest(f,g,d)},toJSON:function(){return this.world.toJSON()},createCollisionGroup:function(a){var b=Math.pow(2,this._collisionGroupID);this.walls.left&&(this.walls.left.shapes[0].collisionMask=this.walls.left.shapes[0].collisionMask|b),this.walls.right&&(this.walls.right.shapes[0].collisionMask=this.walls.right.shapes[0].collisionMask|b),this.walls.top&&(this.walls.top.shapes[0].collisionMask=this.walls.top.shapes[0].collisionMask|b),this.walls.bottom&&(this.walls.bottom.shapes[0].collisionMask=this.walls.bottom.shapes[0].collisionMask|b),this._collisionGroupID++;var d=new c.Physics.P2.CollisionGroup(b);return this.collisionGroups.push(d),a&&this.setCollisionGroup(a,d),d},setCollisionGroup:function(a,b){if(a instanceof c.Group)for(var d=0;d<a.total;d++)a.children[d].body&&a.children[d].body.type===c.Physics.P2JS&&a.children[d].body.setCollisionGroup(b);else a.body.setCollisionGroup(b)},createSpring:function(a,b,d,e,f,g,h,i,j){if(a=this.getBody(a),b=this.getBody(b),a&&b)return this.addSpring(new c.Physics.P2.Spring(this,a,b,d,e,f,g,h,i,j))},createRotationalSpring:function(a,b,d,e,f){if(a=this.getBody(a),b=this.getBody(b),a&&b)return this.addSpring(new c.Physics.P2.RotationalSpring(this,a,b,d,e,f))},createBody:function(a,b,d,e,f,g){void 0===e&&(e=!1);var h=new c.Physics.P2.Body(this.game,null,a,b,d);return!(g&&!h.addPolygon(f,g))&&(e&&this.world.addBody(h.data),h)},createParticle:function(a,b,d,e,f,g){void 0===e&&(e=!1);var h=new c.Physics.P2.Body(this.game,null,a,b,d);return!(g&&!h.addPolygon(f,g))&&(e&&this.world.addBody(h.data),h)},convertCollisionObjects:function(a,b,c){void 0===c&&(c=!0);for(var d=[],e=0,f=a.collision[b].length;e<f;e++){var g=a.collision[b][e],h=this.createBody(g.x,g.y,0,c,{},g.polyline);h&&d.push(h)}return d},clearTilemapLayerBodies:function(a,b){b=a.getLayer(b);for(var c=a.layers[b].bodies.length;c--;)a.layers[b].bodies[c].destroy();a.layers[b].bodies.length=0},convertTilemap:function(a,b,c,d){b=a.getLayer(b),void 0===c&&(c=!0),void 0===d&&(d=!0),this.clearTilemapLayerBodies(a,b);for(var e=0,f=0,g=0,h=0,i=a.layers[b].height;h<i;h++)for(var j=e=0,k=a.layers[b].width;j<k;j++){var l=a.layers[b].data[h][j];if(l&&-1<l.index&&l.collides)if(d){var m=a.getTileRight(b,j,h);if(0===e&&(f=l.x*l.width,g=l.y*l.height,e=l.width),m&&m.collides)e+=l.width;else(n=this.createBody(f,g,0,!1)).addRectangle(e,l.height,e/2,l.height/2,0),c&&this.addBody(n),a.layers[b].bodies.push(n),e=0}else{var n;(n=this.createBody(l.x*l.width,l.y*l.height,0,!1)).addRectangle(l.width,l.height,l.width/2,l.height/2,0),c&&this.addBody(n),a.layers[b].bodies.push(n)}}return a.layers[b].bodies},mpx:function(a){return 20*a},pxm:function(a){return.05*a},mpxi:function(a){return-20*a},pxmi:function(a){return-.05*a}},Object.defineProperty(c.Physics.P2.prototype,"friction",{get:function(){return this.world.defaultContactMaterial.friction},set:function(a){this.world.defaultContactMaterial.friction=a}}),Object.defineProperty(c.Physics.P2.prototype,"restitution",{get:function(){return this.world.defaultContactMaterial.restitution},set:function(a){this.world.defaultContactMaterial.restitution=a}}),Object.defineProperty(c.Physics.P2.prototype,"contactMaterial",{get:function(){return this.world.defaultContactMaterial},set:function(a){this.world.defaultContactMaterial=a}}),Object.defineProperty(c.Physics.P2.prototype,"applySpringForces",{get:function(){return this.world.applySpringForces},set:function(a){this.world.applySpringForces=a}}),Object.defineProperty(c.Physics.P2.prototype,"applyDamping",{get:function(){return this.world.applyDamping},set:function(a){this.world.applyDamping=a}}),Object.defineProperty(c.Physics.P2.prototype,"applyGravity",{get:function(){return this.world.applyGravity},set:function(a){this.world.applyGravity=a}}),Object.defineProperty(c.Physics.P2.prototype,"solveConstraints",{get:function(){return this.world.solveConstraints},set:function(a){this.world.solveConstraints=a}}),Object.defineProperty(c.Physics.P2.prototype,"time",{get:function(){return this.world.time}}),Object.defineProperty(c.Physics.P2.prototype,"emitImpactEvent",{get:function(){return this.world.emitImpactEvent},set:function(a){this.world.emitImpactEvent=a}}),Object.defineProperty(c.Physics.P2.prototype,"sleepMode",{get:function(){return this.world.sleepMode},set:function(a){this.world.sleepMode=a}}),Object.defineProperty(c.Physics.P2.prototype,"total",{get:function(){return this.world.bodies.length}}),c.Physics.P2.FixtureList=function(a){Array.isArray(a)||(a=[a]),this.rawList=a,this.init(),this.parse(this.rawList)},c.Physics.P2.FixtureList.prototype={init:function(){this.namedFixtures={},this.groupedFixtures=[],this.allFixtures=[]},setCategory:function(a,b){this.getFixtures(b).forEach(function(b){b.collisionGroup=a})},setMask:function(a,b){this.getFixtures(b).forEach(function(b){b.collisionMask=a})},setSensor:function(a,b){this.getFixtures(b).forEach(function(b){b.sensor=a})},setMaterial:function(a,b){this.getFixtures(b).forEach(function(b){b.material=a})},getFixtures:function(a){var b=[];if(a){a instanceof Array||(a=[a]);var c=this;return a.forEach(function(a){c.namedFixtures[a]&&b.push(c.namedFixtures[a])}),this.flatten(b)}return this.allFixtures},getFixtureByKey:function(a){return this.namedFixtures[a]},getGroup:function(a){return this.groupedFixtures[a]},parse:function(){var a,b,c,d;for(a in d=[],c=this.rawList)b=c[a],isNaN(a-0)?this.namedFixtures[a]=this.flatten(b):(this.groupedFixtures[a]=this.groupedFixtures[a]||[],this.groupedFixtures[a]=this.groupedFixtures[a].concat(b)),d.push(this.allFixtures=this.flatten(this.groupedFixtures))},flatten:function(a){var b,c;return b=[],c=arguments.callee,a.forEach(function(a){return Array.prototype.push.apply(b,Array.isArray(a)?c(a):[a])}),b}},c.Physics.P2.PointProxy=function(a,b){this.world=a,this.destination=b},c.Physics.P2.PointProxy.prototype.constructor=c.Physics.P2.PointProxy,Object.defineProperty(c.Physics.P2.PointProxy.prototype,"x",{get:function(){return this.world.mpx(this.destination[0])},set:function(a){this.destination[0]=this.world.pxm(a)}}),Object.defineProperty(c.Physics.P2.PointProxy.prototype,"y",{get:function(){return this.world.mpx(this.destination[1])},set:function(a){this.destination[1]=this.world.pxm(a)}}),Object.defineProperty(c.Physics.P2.PointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(a){this.destination[0]=a}}),Object.defineProperty(c.Physics.P2.PointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(a){this.destination[1]=a}}),c.Physics.P2.InversePointProxy=function(a,b){this.world=a,this.destination=b},c.Physics.P2.InversePointProxy.prototype.constructor=c.Physics.P2.InversePointProxy,Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"x",{get:function(){return this.world.mpxi(this.destination[0])},set:function(a){this.destination[0]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"y",{get:function(){return this.world.mpxi(this.destination[1])},set:function(a){this.destination[1]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"mx",{get:function(){return this.destination[0]},set:function(a){this.destination[0]=-a}}),Object.defineProperty(c.Physics.P2.InversePointProxy.prototype,"my",{get:function(){return this.destination[1]},set:function(a){this.destination[1]=-a}}),c.Physics.P2.Body=function(a,b,d,e,f){b=b||null,d=d||0,e=e||0,void 0===f&&(f=1),this.game=a,this.world=a.physics.p2,this.sprite=b,this.type=c.Physics.P2JS,this.offset=new c.Point,this.data=new p2.Body({position:[this.world.pxmi(d),this.world.pxmi(e)],mass:f}),(this.data.parent=this).velocity=new c.Physics.P2.InversePointProxy(this.world,this.data.velocity),this.force=new c.Physics.P2.InversePointProxy(this.world,this.data.force),this.gravity=new c.Point,this.onBeginContact=new c.Signal,this.onEndContact=new c.Signal,this.collidesWith=[],this.removeNextStep=!1,this.debugBody=null,this.dirty=!1,this._collideWorldBounds=!0,this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this._reset=!1,b&&(this.setRectangleFromSprite(b),b.exists&&this.game.physics.p2.addBody(this))},c.Physics.P2.Body.prototype={createBodyCallback:function(a,b,c){var d=-1;a.id?d=a.id:a.body&&(d=a.body.id),-1<d&&(null===b?(delete this._bodyCallbacks[d],delete this._bodyCallbackContext[d]):(this._bodyCallbacks[d]=b,this._bodyCallbackContext[d]=c))},createGroupCallback:function(a,b,c){null===b?(delete this._groupCallbacks[a.mask],delete this._groupCallbackContext[a.mask]):(this._groupCallbacks[a.mask]=b,this._groupCallbackContext[a.mask]=c)},getCollisionMask:function(){var a=0;this._collideWorldBounds&&(a=this.game.physics.p2.boundsCollisionGroup.mask);for(var b=0;b<this.collidesWith.length;b++)a|=this.collidesWith[b].mask;return a},updateCollisionMask:function(a){var b=this.getCollisionMask();if(void 0===a)for(var c=this.data.shapes.length-1;0<=c;c--)this.data.shapes[c].collisionMask=b;else a.collisionMask=b},setCollisionGroup:function(a,b){var c=this.getCollisionMask();if(void 0===b)for(var d=this.data.shapes.length-1;0<=d;d--)this.data.shapes[d].collisionGroup=a.mask,this.data.shapes[d].collisionMask=c;else b.collisionGroup=a.mask,b.collisionMask=c},clearCollision:function(a,b,c){if(void 0===a&&(a=!0),void 0===b&&(b=!0),void 0===c)for(var d=this.data.shapes.length-1;0<=d;d--)a&&(this.data.shapes[d].collisionGroup=null),b&&(this.data.shapes[d].collisionMask=null);else a&&(c.collisionGroup=null),b&&(c.collisionMask=null);a&&(this.collidesWith.length=0)},removeCollisionGroup:function(a,b,c){var d;if(void 0===b&&(b=!0),Array.isArray(a))for(var e=0;e<a.length;e++)-1<(d=this.collidesWith.indexOf(a[e]))&&(this.collidesWith.splice(d,1),b&&(delete this._groupCallbacks[a.mask],delete this._groupCallbackContext[a.mask]));else-1<(d=this.collidesWith.indexOf(a))&&(this.collidesWith.splice(d,1),b&&(delete this._groupCallbacks[a.mask],delete this._groupCallbackContext[a.mask]));var f=this.getCollisionMask();if(void 0===c)for(e=this.data.shapes.length-1;0<=e;e--)this.data.shapes[e].collisionMask=f;else c.collisionMask=f},collides:function(a,b,c,d){if(Array.isArray(a))for(var e=0;e<a.length;e++)-1===this.collidesWith.indexOf(a[e])&&(this.collidesWith.push(a[e]),b&&this.createGroupCallback(a[e],b,c));else-1===this.collidesWith.indexOf(a)&&(this.collidesWith.push(a),b&&this.createGroupCallback(a,b,c));var f=this.getCollisionMask();if(void 0===d)for(e=this.data.shapes.length-1;0<=e;e--)this.data.shapes[e].collisionMask=f;else d.collisionMask=f},adjustCenterOfMass:function(){this.data.adjustCenterOfMass(),this.shapeChanged()},getVelocityAtPoint:function(a,b){return this.data.getVelocityAtPoint(a,b)},applyDamping:function(a){this.data.applyDamping(a)},applyImpulse:function(a,b,c){this.data.applyImpulse(a,[this.world.pxmi(b),this.world.pxmi(c)])},applyImpulseLocal:function(a,b,c){this.data.applyImpulseLocal(a,[this.world.pxmi(b),this.world.pxmi(c)])},applyForce:function(a,b,c){this.data.applyForce(a,[this.world.pxmi(b),this.world.pxmi(c)])},setZeroForce:function(){this.data.setZeroForce()},setZeroRotation:function(){this.data.angularVelocity=0},setZeroVelocity:function(){this.data.velocity[0]=0,this.data.velocity[1]=0},setZeroDamping:function(){this.data.damping=0,this.data.angularDamping=0},toLocalFrame:function(a,b){return this.data.toLocalFrame(a,b)},toWorldFrame:function(a,b){return this.data.toWorldFrame(a,b)},rotateLeft:function(a){this.data.angularVelocity=this.world.pxm(-a)},rotateRight:function(a){this.data.angularVelocity=this.world.pxm(a)},moveForward:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.velocity[0]=b*Math.cos(c),this.data.velocity[1]=b*Math.sin(c)},moveBackward:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.velocity[0]=-b*Math.cos(c),this.data.velocity[1]=-b*Math.sin(c)},thrust:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.force[0]+=b*Math.cos(c),this.data.force[1]+=b*Math.sin(c)},thrustLeft:function(a){var b=this.world.pxmi(-a),c=this.data.angle;this.data.force[0]+=b*Math.cos(c),this.data.force[1]+=b*Math.sin(c)},thrustRight:function(a){var b=this.world.pxmi(-a),c=this.data.angle;this.data.force[0]-=b*Math.cos(c),this.data.force[1]-=b*Math.sin(c)},reverse:function(a){var b=this.world.pxmi(-a),c=this.data.angle+Math.PI/2;this.data.force[0]-=b*Math.cos(c),this.data.force[1]-=b*Math.sin(c)},moveLeft:function(a){this.data.velocity[0]=this.world.pxmi(-a)},moveRight:function(a){this.data.velocity[0]=this.world.pxmi(a)},moveUp:function(a){this.data.velocity[1]=this.world.pxmi(-a)},moveDown:function(a){this.data.velocity[1]=this.world.pxmi(a)},preUpdate:function(){this.dirty=!0,this.removeNextStep&&(this.removeFromWorld(),this.removeNextStep=!1)},postUpdate:function(){this.sprite.x=this.world.mpxi(this.data.position[0])+this.offset.x,this.sprite.y=this.world.mpxi(this.data.position[1])+this.offset.y,this.fixedRotation||(this.sprite.rotation=this.data.angle),this.debugBody&&this.debugBody.updateSpriteTransform(),this.dirty=!1},reset:function(a,b,c,d){void 0===c&&(c=!1),void 0===d&&(d=!1),this.setZeroForce(),this.setZeroVelocity(),this.setZeroRotation(),c&&this.setZeroDamping(),d&&(this.mass=1),this.x=a,this.y=b},addToWorld:function(){if(this.game.physics.p2._toRemove)for(var a=0;a<this.game.physics.p2._toRemove.length;a++)this.game.physics.p2._toRemove[a]===this&&this.game.physics.p2._toRemove.splice(a,1);this.data.world!==this.game.physics.p2.world&&this.game.physics.p2.addBody(this)},removeFromWorld:function(){this.data.world===this.game.physics.p2.world&&this.game.physics.p2.removeBodyNextStep(this)},destroy:function(){this.removeFromWorld(),this.clearShapes(),this._bodyCallbacks={},this._bodyCallbackContext={},this._groupCallbacks={},this._groupCallbackContext={},this.debugBody&&this.debugBody.destroy(!0,!0),this.debugBody=null,this.sprite&&(this.sprite.body=null,this.sprite=null)},clearShapes:function(){for(var a=this.data.shapes.length;a--;)this.data.removeShape(this.data.shapes[a]);this.shapeChanged()},addShape:function(a,b,c,d){return void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=0),this.data.addShape(a,[this.world.pxmi(b),this.world.pxmi(c)],d),this.shapeChanged(),a},addCircle:function(a,b,c,d){var e=new p2.Circle({radius:this.world.pxm(a)});return this.addShape(e,b,c,d)},addRectangle:function(a,b,c,d,e){var f=new p2.Box({width:this.world.pxm(a),height:this.world.pxm(b)});return this.addShape(f,c,d,e)},addPlane:function(a,b,c){var d=new p2.Plane;return this.addShape(d,a,b,c)},addParticle:function(a,b,c){var d=new p2.Particle;return this.addShape(d,a,b,c)},addLine:function(a,b,c,d){var e=new p2.Line({length:this.world.pxm(a)});return this.addShape(e,b,c,d)},addCapsule:function(a,b,c,d,e){var f=new p2.Capsule({length:this.world.pxm(a),radius:this.world.pxm(b)});return this.addShape(f,c,d,e)},addPolygon:function(a,b){a=a||{},Array.isArray(b)||(b=Array.prototype.slice.call(arguments,1));var c=[];if(1===b.length&&Array.isArray(b[0]))c=b[0].slice(0);else if(Array.isArray(b[0]))c=b.slice();else if("number"==typeof b[0])for(var d=0,e=b.length;d<e;d+=2)c.push([b[d],b[d+1]]);var f=c.length-1;c[f][0]===c[0][0]&&c[f][1]===c[0][1]&&c.pop();for(var g=0;g<c.length;g++)c[g][0]=this.world.pxmi(c[g][0]),c[g][1]=this.world.pxmi(c[g][1]);var h=this.data.fromPolygon(c,a);return this.shapeChanged(),h},removeShape:function(a){var b=this.data.removeShape(a);return this.shapeChanged(),b},setCircle:function(a,b,c,d){return this.clearShapes(),this.addCircle(a,b,c,d)},setRectangle:function(a,b,c,d,e){return void 0===a&&(a=16),void 0===b&&(b=16),this.clearShapes(),this.addRectangle(a,b,c,d,e)},setRectangleFromSprite:function(a){return void 0===a&&(a=this.sprite),this.clearShapes(),this.addRectangle(a.width,a.height,0,0,a.rotation)},setMaterial:function(a,b){if(void 0===b)for(var c=this.data.shapes.length-1;0<=c;c--)this.data.shapes[c].material=a;else b.material=a},shapeChanged:function(){this.debugBody&&this.debugBody.draw()},addPhaserPolygon:function(a,b){for(var c=this.game.cache.getPhysicsData(a,b),d=[],e=0;e<c.length;e++){var f=c[e],g=this.addFixture(f);d[f.filter.group]=d[f.filter.group]||[],d[f.filter.group]=d[f.filter.group].concat(g),f.fixtureKey&&(d[f.fixtureKey]=g)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),d},addFixture:function(a){var b=[];if(a.circle){(c=new p2.Circle({radius:this.world.pxm(a.circle.radius)})).collisionGroup=a.filter.categoryBits,c.collisionMask=a.filter.maskBits,c.sensor=a.isSensor;var d=p2.vec2.create();d[0]=this.world.pxmi(a.circle.position[0]-this.sprite.width/2),d[1]=this.world.pxmi(a.circle.position[1]-this.sprite.height/2),this.data.addShape(c,d),b.push(c)}else for(var e=a.polygons,f=p2.vec2.create(),g=0;g<e.length;g++){for(var h=e[g],i=[],j=0;j<h.length;j+=2)i.push([this.world.pxmi(h[j]),this.world.pxmi(h[j+1])]);for(var c=new p2.Convex({vertices:i}),k=0;k!==c.vertices.length;k++){var l=c.vertices[k];p2.vec2.sub(l,l,c.centerOfMass)}p2.vec2.scale(f,c.centerOfMass,1),f[0]-=this.world.pxmi(this.sprite.width/2),f[1]-=this.world.pxmi(this.sprite.height/2),c.updateTriangles(),c.updateCenterOfMass(),c.updateBoundingRadius(),c.collisionGroup=a.filter.categoryBits,c.collisionMask=a.filter.maskBits,c.sensor=a.isSensor,this.data.addShape(c,f),b.push(c)}return b},loadPolygon:function(a,b){if(null===a)var c=b;else c=this.game.cache.getPhysicsData(a,b);for(var d=p2.vec2.create(),e=0;e<c.length;e++){for(var f=[],g=0;g<c[e].shape.length;g+=2)f.push([this.world.pxmi(c[e].shape[g]),this.world.pxmi(c[e].shape[g+1])]);for(var h=new p2.Convex({vertices:f}),i=0;i!==h.vertices.length;i++){var j=h.vertices[i];p2.vec2.sub(j,j,h.centerOfMass)}p2.vec2.scale(d,h.centerOfMass,1),d[0]-=this.world.pxmi(this.sprite.width/2),d[1]-=this.world.pxmi(this.sprite.height/2),h.updateTriangles(),h.updateCenterOfMass(),h.updateBoundingRadius(),this.data.addShape(h,d)}return this.data.aabbNeedsUpdate=!0,this.shapeChanged(),!0}},c.Physics.P2.Body.prototype.constructor=c.Physics.P2.Body,c.Physics.P2.Body.DYNAMIC=1,c.Physics.P2.Body.STATIC=2,c.Physics.P2.Body.KINEMATIC=4,Object.defineProperty(c.Physics.P2.Body.prototype,"static",{get:function(){return this.data.type===c.Physics.P2.Body.STATIC},set:function(a){a&&this.data.type!==c.Physics.P2.Body.STATIC?(this.data.type=c.Physics.P2.Body.STATIC,this.mass=0):a||this.data.type!==c.Physics.P2.Body.STATIC||(this.data.type=c.Physics.P2.Body.DYNAMIC,this.mass=1)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"dynamic",{get:function(){return this.data.type===c.Physics.P2.Body.DYNAMIC},set:function(a){a&&this.data.type!==c.Physics.P2.Body.DYNAMIC?(this.data.type=c.Physics.P2.Body.DYNAMIC,this.mass=1):a||this.data.type!==c.Physics.P2.Body.DYNAMIC||(this.data.type=c.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"kinematic",{get:function(){return this.data.type===c.Physics.P2.Body.KINEMATIC},set:function(a){a&&this.data.type!==c.Physics.P2.Body.KINEMATIC?(this.data.type=c.Physics.P2.Body.KINEMATIC,this.mass=4):a||this.data.type!==c.Physics.P2.Body.KINEMATIC||(this.data.type=c.Physics.P2.Body.STATIC,this.mass=0)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"allowSleep",{get:function(){return this.data.allowSleep},set:function(a){a!==this.data.allowSleep&&(this.data.allowSleep=a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angle",{get:function(){return c.Math.wrapAngle(c.Math.radToDeg(this.data.angle))},set:function(a){this.data.angle=c.Math.degToRad(c.Math.wrapAngle(a))}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angularDamping",{get:function(){return this.data.angularDamping},set:function(a){this.data.angularDamping=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angularForce",{get:function(){return this.data.angularForce},set:function(a){this.data.angularForce=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"angularVelocity",{get:function(){return this.data.angularVelocity},set:function(a){this.data.angularVelocity=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"damping",{get:function(){return this.data.damping},set:function(a){this.data.damping=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"fixedRotation",{get:function(){return this.data.fixedRotation},set:function(a){a!==this.data.fixedRotation&&(this.data.fixedRotation=a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"inertia",{get:function(){return this.data.inertia},set:function(a){this.data.inertia=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"mass",{get:function(){return this.data.mass},set:function(a){a!==this.data.mass&&(this.data.mass=a,this.data.updateMassProperties())}}),Object.defineProperty(c.Physics.P2.Body.prototype,"motionState",{get:function(){return this.data.type},set:function(a){a!==this.data.type&&(this.data.type=a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"rotation",{get:function(){return this.data.angle},set:function(a){this.data.angle=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"sleepSpeedLimit",{get:function(){return this.data.sleepSpeedLimit},set:function(a){this.data.sleepSpeedLimit=a}}),Object.defineProperty(c.Physics.P2.Body.prototype,"x",{get:function(){return this.world.mpxi(this.data.position[0])},set:function(a){this.data.position[0]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"y",{get:function(){return this.world.mpxi(this.data.position[1])},set:function(a){this.data.position[1]=this.world.pxmi(a)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"id",{get:function(){return this.data.id}}),Object.defineProperty(c.Physics.P2.Body.prototype,"debug",{get:function(){return null!==this.debugBody},set:function(a){a&&!this.debugBody?this.debugBody=new c.Physics.P2.BodyDebug(this.game,this.data):!a&&this.debugBody&&(this.debugBody.destroy(),this.debugBody=null)}}),Object.defineProperty(c.Physics.P2.Body.prototype,"collideWorldBounds",{get:function(){return this._collideWorldBounds},set:function(a){a&&!this._collideWorldBounds?(this._collideWorldBounds=!0,this.updateCollisionMask()):!a&&this._collideWorldBounds&&(this._collideWorldBounds=!1,this.updateCollisionMask())}}),c.Physics.P2.BodyDebug=function(a,b,d){c.Group.call(this,a);var e={pixelsPerLengthUnit:a.physics.p2.mpx(1),debugPolygons:!1,lineWidth:1,alpha:.5};this.settings=c.Utils.extend(e,d),this.ppu=this.settings.pixelsPerLengthUnit,this.ppu=-1*this.ppu,this.body=b,this.canvas=new c.Graphics(a),this.canvas.alpha=this.settings.alpha,this.add(this.canvas),this.draw(),this.updateSpriteTransform()},c.Physics.P2.BodyDebug.prototype=Object.create(c.Group.prototype),c.Physics.P2.BodyDebug.prototype.constructor=c.Physics.P2.BodyDebug,c.Utils.extend(c.Physics.P2.BodyDebug.prototype,{updateSpriteTransform:function(){this.position.x=this.body.position[0]*this.ppu,this.position.y=this.body.position[1]*this.ppu,this.rotation=this.body.angle},draw:function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o;if(h=this.body,(j=this.canvas).clear(),c=parseInt(this.randomPastelHex(),16),f=16711680,g=this.lineWidth,h instanceof p2.Body&&h.shapes.length){var p=h.shapes.length;for(d=0;d!==p;){if(i=(b=h.shapes[d]).position||0,a=b.angle||0,b instanceof p2.Circle)this.drawCircle(j,i[0]*this.ppu,i[1]*this.ppu,a,b.radius*this.ppu,c,g);else if(b instanceof p2.Capsule)this.drawCapsule(j,i[0]*this.ppu,i[1]*this.ppu,a,b.length*this.ppu,b.radius*this.ppu,f,c,g);else if(b instanceof p2.Plane)this.drawPlane(j,i[0]*this.ppu,-i[1]*this.ppu,c,f,5*g,10*g,10*g,100*this.ppu,a);else if(b instanceof p2.Line)this.drawLine(j,b.length*this.ppu,f,g);else if(b instanceof p2.Box)this.drawRectangle(j,i[0]*this.ppu,i[1]*this.ppu,a,b.width*this.ppu,b.height*this.ppu,f,c,g);else if(b instanceof p2.Convex){for(l=[],m=p2.vec2.create(),e=n=0,o=b.vertices.length;0<=o?n<o:o<n;e=0<=o?++n:--n)k=b.vertices[e],p2.vec2.rotate(m,k,a),l.push([(m[0]+i[0])*this.ppu,-(m[1]+i[1])*this.ppu]);this.drawConvex(j,l,b.triangles,f,c,g,this.settings.debugPolygons,[i[0]*this.ppu,-i[1]*this.ppu])}d++}}},drawRectangle:function(a,b,c,d,e,f,g,h,i){void 0===i&&(i=1),void 0===g&&(g=0),a.lineStyle(i,g,1),a.beginFill(h),a.drawRect(b-e/2,c-f/2,e,f)},drawCircle:function(a,b,c,d,e,f,g){void 0===g&&(g=1),void 0===f&&(f=16777215),a.lineStyle(g,0,1),a.beginFill(f,1),a.drawCircle(b,c,2*-e),a.endFill(),a.moveTo(b,c),a.lineTo(b+e*Math.cos(-d),c+e*Math.sin(-d))},drawLine:function(a,b,c,d){void 0===d&&(d=1),void 0===c&&(c=0),a.lineStyle(5*d,c,1),a.moveTo(-b/2,0),a.lineTo(b/2,0)},drawConvex:function(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q,r,s;if(void 0===f&&(f=1),void 0===d&&(d=0),g){for(i=[16711680,65280,255],j=0;j!==b.length+1;)l=b[j%b.length],m=b[(j+1)%b.length],o=l[0],r=l[1],p=m[0],s=m[1],a.lineStyle(f,i[j%i.length],1),a.moveTo(o,-r),a.lineTo(p,-s),a.drawCircle(o,-r,2*f),j++;return a.lineStyle(f,0,1),a.drawCircle(h[0],h[1],2*f)}for(a.lineStyle(f,d,1),a.beginFill(e),j=0;j!==b.length;)n=(k=b[j])[0],q=k[1],0===j?a.moveTo(n,-q):a.lineTo(n,-q),j++;if(a.endFill(),2<b.length)return a.moveTo(b[b.length-1][0],-b[b.length-1][1]),a.lineTo(b[0][0],-b[0][1])},drawPath:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q;for(void 0===e&&(e=1),void 0===c&&(c=0),a.lineStyle(e,c,1),"number"==typeof d&&a.beginFill(d),h=g=null,f=0;f<b.length;)p=(o=b[f])[0],q=o[1],p===g&&q===h||(0===f?a.moveTo(p,q):(i=g,j=h,k=p,l=q,m=b[(f+1)%b.length][0],0!=(k-i)*(b[(f+1)%b.length][1]-j)-(m-i)*(l-j)&&a.lineTo(p,q)),g=p,h=q),f++;"number"==typeof d&&a.endFill(),2<b.length&&"number"==typeof d&&(a.moveTo(b[b.length-1][0],b[b.length-1][1]),a.lineTo(b[0][0],b[0][1]))},drawPlane:function(a,b,c,d,e,f,g,h,i,j){var k,l;void 0===f&&(f=1),void 0===d&&(d=16777215),a.lineStyle(f,e,11),a.beginFill(d),a.moveTo(b,-c),k=b+Math.cos(j)*this.game.width,l=c+Math.sin(j)*this.game.height,a.lineTo(k,-l),a.moveTo(b,-c),k=b+Math.cos(j)*-this.game.width,l=c+Math.sin(j)*-this.game.height,a.lineTo(k,-l)},drawCapsule:function(a,b,c,d,e,f,g,h,i){void 0===i&&(i=1),void 0===g&&(g=0),a.lineStyle(i,g,1);var j=Math.cos(d),k=Math.sin(d);a.beginFill(h,1),a.drawCircle(-e/2*j+b,-e/2*k+c,2*-f),a.drawCircle(e/2*j+b,e/2*k+c,2*-f),a.endFill(),a.lineStyle(i,g,0),a.beginFill(h,1),a.moveTo(-e/2*j+f*k+b,-e/2*k+f*j+c),a.lineTo(e/2*j+f*k+b,e/2*k+f*j+c),a.lineTo(e/2*j-f*k+b,e/2*k-f*j+c),a.lineTo(-e/2*j-f*k+b,-e/2*k-f*j+c),a.endFill(),a.lineStyle(i,g,1),a.moveTo(-e/2*j+f*k+b,-e/2*k+f*j+c),a.lineTo(e/2*j+f*k+b,e/2*k+f*j+c),a.moveTo(-e/2*j-f*k+b,-e/2*k-f*j+c),a.lineTo(e/2*j-f*k+b,e/2*k-f*j+c)},randomPastelHex:function(){var a,b,c,d;return c=[255,255,255],d=Math.floor(256*Math.random()),b=Math.floor(256*Math.random()),a=Math.floor(256*Math.random()),d=Math.floor((d+3*c[0])/4),b=Math.floor((b+3*c[1])/4),a=Math.floor((a+3*c[2])/4),this.rgbToHex(d,b,a)},rgbToHex:function(a,b,c){return this.componentToHex(a)+this.componentToHex(b)+this.componentToHex(c)},componentToHex:function(a){var b;return 2===(b=a.toString(16)).length?b:b+"0"}}),c.Physics.P2.Spring=function(a,b,c,d,e,f,g,h,i,j){this.game=a.game,void 0===d&&(d=1),void 0===e&&(e=100),void 0===f&&(f=1);var k={restLength:d=(this.world=a).pxm(d),stiffness:e,damping:f};null!=g&&(k.worldAnchorA=[a.pxm(g[0]),a.pxm(g[1])]),null!=h&&(k.worldAnchorB=[a.pxm(h[0]),a.pxm(h[1])]),null!=i&&(k.localAnchorA=[a.pxm(i[0]),a.pxm(i[1])]),null!=j&&(k.localAnchorB=[a.pxm(j[0]),a.pxm(j[1])]),this.data=new p2.LinearSpring(b,c,k),this.data.parent=this},c.Physics.P2.Spring.prototype.constructor=c.Physics.P2.Spring,c.Physics.P2.RotationalSpring=function(a,b,c,d,e,f){this.game=a.game,this.world=a,void 0===d&&(d=null),void 0===e&&(e=100),void 0===f&&(f=1),d&&(d=a.pxm(d));var g={restAngle:d,stiffness:e,damping:f};this.data=new p2.RotationalSpring(b,c,g),this.data.parent=this},c.Physics.P2.Spring.prototype.constructor=c.Physics.P2.Spring,c.Physics.P2.Material=function(a){this.name=a,p2.Material.call(this)},c.Physics.P2.Material.prototype=Object.create(p2.Material.prototype),c.Physics.P2.Material.prototype.constructor=c.Physics.P2.Material,c.Physics.P2.ContactMaterial=function(a,b,c){p2.ContactMaterial.call(this,a,b,c)},c.Physics.P2.ContactMaterial.prototype=Object.create(p2.ContactMaterial.prototype),c.Physics.P2.ContactMaterial.prototype.constructor=c.Physics.P2.ContactMaterial,c.Physics.P2.CollisionGroup=function(a){this.mask=a},c.Physics.P2.DistanceConstraint=function(a,b,c,d,e,f,g){void 0===d&&(d=100),void 0===e&&(e=[0,0]),void 0===f&&(f=[0,0]),void 0===g&&(g=Number.MAX_VALUE),this.game=a.game;var h={distance:d=(this.world=a).pxm(d),localAnchorA:e=[a.pxmi(e[0]),a.pxmi(e[1])],localAnchorB:f=[a.pxmi(f[0]),a.pxmi(f[1])],maxForce:g};p2.DistanceConstraint.call(this,b,c,h)},c.Physics.P2.DistanceConstraint.prototype=Object.create(p2.DistanceConstraint.prototype),c.Physics.P2.DistanceConstraint.prototype.constructor=c.Physics.P2.DistanceConstraint,c.Physics.P2.GearConstraint=function(a,b,c,d,e){void 0===d&&(d=0),void 0===e&&(e=1),this.game=a.game,this.world=a;var f={angle:d,ratio:e};p2.GearConstraint.call(this,b,c,f)},c.Physics.P2.GearConstraint.prototype=Object.create(p2.GearConstraint.prototype),c.Physics.P2.GearConstraint.prototype.constructor=c.Physics.P2.GearConstraint,c.Physics.P2.LockConstraint=function(a,b,c,d,e,f){void 0===d&&(d=[0,0]),void 0===e&&(e=0),void 0===f&&(f=Number.MAX_VALUE),this.game=a.game;var g={localOffsetB:d=[(this.world=a).pxm(d[0]),a.pxm(d[1])],localAngleB:e,maxForce:f};p2.LockConstraint.call(this,b,c,g)},c.Physics.P2.LockConstraint.prototype=Object.create(p2.LockConstraint.prototype),c.Physics.P2.LockConstraint.prototype.constructor=c.Physics.P2.LockConstraint,c.Physics.P2.PrismaticConstraint=function(a,b,c,d,e,f,g,h){void 0===d&&(d=!0),void 0===e&&(e=[0,0]),void 0===f&&(f=[0,0]),void 0===g&&(g=[0,0]),void 0===h&&(h=Number.MAX_VALUE),this.game=a.game;var i={localAnchorA:e=[(this.world=a).pxmi(e[0]),a.pxmi(e[1])],localAnchorB:f=[a.pxmi(f[0]),a.pxmi(f[1])],localAxisA:g,maxForce:h,disableRotationalLock:!d};p2.PrismaticConstraint.call(this,b,c,i)},c.Physics.P2.PrismaticConstraint.prototype=Object.create(p2.PrismaticConstraint.prototype),c.Physics.P2.PrismaticConstraint.prototype.constructor=c.Physics.P2.PrismaticConstraint,c.Physics.P2.RevoluteConstraint=function(a,b,c,d,e,f,g){void 0===f&&(f=Number.MAX_VALUE),void 0===g&&(g=null),this.game=a.game,c=[(this.world=a).pxmi(c[0]),a.pxmi(c[1])],e=[a.pxmi(e[0]),a.pxmi(e[1])],g&&(g=[a.pxmi(g[0]),a.pxmi(g[1])]);var h={worldPivot:g,localPivotA:c,localPivotB:e,maxForce:f};p2.RevoluteConstraint.call(this,b,d,h)},c.Physics.P2.RevoluteConstraint.prototype=Object.create(p2.RevoluteConstraint.prototype),c.Physics.P2.RevoluteConstraint.prototype.constructor=c.Physics.P2.RevoluteConstraint,c.ImageCollection=function(a,b,c,d,e,f,g){(void 0===c||c<=0)&&(c=32),(void 0===d||d<=0)&&(d=32),void 0===e&&(e=0),void 0===f&&(f=0),this.name=a,this.firstgid=0|b,this.imageWidth=0|c,this.imageHeight=0|d,this.imageMargin=0|e,this.imageSpacing=0|f,this.properties=g||{},this.images=[],this.total=0},c.ImageCollection.prototype={containsImageIndex:function(a){return a>=this.firstgid&&a<this.firstgid+this.total},addImage:function(a,b){this.images.push({gid:a,image:b}),this.total++}},c.ImageCollection.prototype.constructor=c.ImageCollection,c.Tile=function(a,b,c,d,e,f){this.layer=a,this.index=b,this.x=c,this.y=d,this.rotation=0,this.flipped=!1,this.worldX=c*e,this.worldY=d*f,this.width=e,this.height=f,this.centerX=Math.abs(e/2),this.centerY=Math.abs(f/2),this.alpha=1,this.properties={},this.scanned=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1,this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.collisionCallback=null,this.collisionCallbackContext=this},c.Tile.prototype={containsPoint:function(a,b){return!(a<this.worldX||b<this.worldY||a>this.right||b>this.bottom)},intersects:function(a,b,c,d){return!(c<=this.worldX||d<=this.worldY||a>=this.worldX+this.width||b>=this.worldY+this.height)},setCollisionCallback:function(a,b){this.collisionCallback=a,this.collisionCallbackContext=b},destroy:function(){this.collisionCallback=null,this.collisionCallbackContext=null,this.properties=null},setCollision:function(a,b,c,d){this.collideLeft=a,this.collideRight=b,this.collideUp=c,this.collideDown=d,this.faceLeft=a,this.faceRight=b,this.faceTop=c,this.faceBottom=d},resetCollision:function(){this.collideLeft=!1,this.collideRight=!1,this.collideUp=!1,this.collideDown=!1,this.faceTop=!1,this.faceBottom=!1,this.faceLeft=!1,this.faceRight=!1},isInteresting:function(a,b){return a&&b?this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.faceTop||this.faceBottom||this.faceLeft||this.faceRight||this.collisionCallback:a?this.collideLeft||this.collideRight||this.collideUp||this.collideDown:!!b&&(this.faceTop||this.faceBottom||this.faceLeft||this.faceRight)},copy:function(a){this.index=a.index,this.alpha=a.alpha,this.properties=a.properties,this.collideUp=a.collideUp,this.collideDown=a.collideDown,this.collideLeft=a.collideLeft,this.collideRight=a.collideRight,this.collisionCallback=a.collisionCallback,this.collisionCallbackContext=a.collisionCallbackContext}},c.Tile.prototype.constructor=c.Tile,Object.defineProperty(c.Tile.prototype,"collides",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown}}),Object.defineProperty(c.Tile.prototype,"canCollide",{get:function(){return this.collideLeft||this.collideRight||this.collideUp||this.collideDown||this.collisionCallback}}),Object.defineProperty(c.Tile.prototype,"left",{get:function(){return this.worldX}}),Object.defineProperty(c.Tile.prototype,"right",{get:function(){return this.worldX+this.width}}),Object.defineProperty(c.Tile.prototype,"top",{get:function(){return this.worldY}}),Object.defineProperty(c.Tile.prototype,"bottom",{get:function(){return this.worldY+this.height}}),c.Tilemap=function(a,b,d,e,f,g){this.game=a,this.key=b;var h=c.TilemapParser.parse(this.game,b,d,e,f,g);null!==h&&(this.width=h.width,this.height=h.height,this.tileWidth=h.tileWidth,this.tileHeight=h.tileHeight,this.orientation=h.orientation,this.format=h.format,this.version=h.version,this.properties=h.properties,this.widthInPixels=h.widthInPixels,this.heightInPixels=h.heightInPixels,this.layers=h.layers,this.tilesets=h.tilesets,this.imagecollections=h.imagecollections,this.tiles=h.tiles,this.objects=h.objects,this.collideIndexes=[],this.collision=h.collision,this.images=h.images,this.enableDebug=!1,this.currentLayer=0,this.debugMap=[],this._results=[],this._tempA=0,this._tempB=0)},c.Tilemap.CSV=0,c.Tilemap.TILED_JSON=1,c.Tilemap.NORTH=0,c.Tilemap.EAST=1,c.Tilemap.SOUTH=2,c.Tilemap.WEST=3,c.Tilemap.prototype={create:function(a,b,c,d,e,f){return void 0===f&&(f=this.game.world),this.width=b,this.height=c,this.setTileSize(d,e),this.layers.length=0,this.createBlankLayer(a,b,c,d,e,f)},setTileSize:function(a,b){this.tileWidth=a,this.tileHeight=b,this.widthInPixels=this.width*a,this.heightInPixels=this.height*b},addTilesetImage:function(a,b,d,e,f,g,h){if(void 0===a)return null;void 0===d&&(d=this.tileWidth),void 0===e&&(e=this.tileHeight),void 0===f&&(f=0),void 0===g&&(g=0),void 0===h&&(h=0),0===d&&(d=32),0===e&&(e=32);var i=null;if(null!=b||(b=a),b instanceof c.BitmapData)i=b.canvas;else{if(!this.game.cache.checkImageKey(b))return null;i=this.game.cache.getImage(b)}var j=this.getTilesetIndex(a);if(null===j&&this.format===c.Tilemap.TILED_JSON)return null;if(this.tilesets[j])return this.tilesets[j].setImage(i),this.tilesets[j];var k=new c.Tileset(a,h,d,e,f,g,{});k.setImage(i),this.tilesets.push(k);for(var l=this.tilesets.length-1,m=f,n=f,o=0,p=0,q=0,r=h;r<h+k.total&&(this.tiles[r]=[m,n,l],m+=d+g,++o!==k.total)&&(++p!==k.columns||(m=f,n+=e+g,p=0,++q!==k.rows));r++);return k},createFromObjects:function(a,b,d,e,f,g,h,i,j){if(void 0===f&&(f=!0),void 0===g&&(g=!1),void 0===h&&(h=this.game.world),void 0===i&&(i=c.Sprite),void 0===j&&(j=!0),this.objects[a])for(var k=0;k<this.objects[a].length;k++){var l=!1,m=this.objects[a][k];if(void 0!==m.gid&&"number"==typeof b&&m.gid===b?l=!0:void 0!==m.id&&"number"==typeof b&&m.id===b?l=!0:void 0!==m.name&&"string"==typeof b&&m.name===b&&(l=!0),l){var n=new i(this.game,parseFloat(m.x,10),parseFloat(m.y,10),d,e);for(var o in n.name=m.name,n.visible=m.visible,n.autoCull=g,n.exists=f,m.width&&(n.width=m.width),m.height&&(n.height=m.height),m.rotation&&(n.angle=m.rotation),j&&(n.y-=n.height),h.add(n),m.properties)h.set(n,o,m.properties[o],!1,!1,0,!0)}}},createFromTiles:function(a,b,d,e,f,g){"number"==typeof a&&(a=[a]),null==b?b=[]:"number"==typeof b&&(b=[b]),e=this.getLayer(e),void 0===f&&(f=this.game.world),void 0===g&&(g={}),void 0===g.customClass&&(g.customClass=c.Sprite),void 0===g.adjustY&&(g.adjustY=!0);var h=this.layers[e].width,i=this.layers[e].height;if(this.copy(0,0,h,i,e),this._results.length<2)return 0;for(var j,k=0,l=1,m=this._results.length;l<m;l++)if(-1!==a.indexOf(this._results[l].index)){for(var n in j=new g.customClass(this.game,this._results[l].worldX,this._results[l].worldY,d),g)j[n]=g[n];f.add(j),k++}if(1===b.length)for(l=0;l<a.length;l++)this.replace(a[l],b[0],0,0,h,i,e);else if(1<b.length)for(l=0;l<a.length;l++)this.replace(a[l],b[l],0,0,h,i,e);return k},createLayer:function(a,b,d,e){void 0===b&&(b=this.game.width),void 0===d&&(d=this.game.height),void 0===e&&(e=this.game.world);var f=a;if("string"==typeof a&&(f=this.getLayerIndex(a)),!(null===f||f>this.layers.length)){void 0===b||b<=0?b=Math.min(this.game.width,this.layers[f].widthInPixels):b>this.game.width&&(b=this.game.width),void 0===d||d<=0?d=Math.min(this.game.height,this.layers[f].heightInPixels):d>this.game.height&&(d=this.game.height),this.enableDebug;var g=e.add(new c.TilemapLayer(this.game,this,f,b,d));return this.enableDebug,g}},createBlankLayer:function(a,b,d,e,f,g){if(void 0===g&&(g=this.game.world),null===this.getLayerIndex(a)){for(var h,i={name:a,x:0,y:0,width:b,height:d,widthInPixels:b*e,heightInPixels:d*f,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:null},j=[],k=0;k<d;k++){h=[];for(var l=0;l<b;l++)h.push(new c.Tile(i,-1,l,k,e,f));j.push(h)}i.data=j,this.layers.push(i),this.currentLayer=this.layers.length-1;var m=i.widthInPixels,n=i.heightInPixels;return m>this.game.width&&(m=this.game.width),n>this.game.height&&(n=this.game.height),(j=new c.TilemapLayer(this.game,this,this.layers.length-1,m,n)).name=a,g.add(j)}},getIndex:function(a,b){for(var c=0;c<a.length;c++)if(a[c].name===b)return c;return null},getLayerIndex:function(a){return this.getIndex(this.layers,a)},getTilesetIndex:function(a){return this.getIndex(this.tilesets,a)},getImageIndex:function(a){return this.getIndex(this.images,a)},setTileIndexCallback:function(a,b,c,d){if(d=this.getLayer(d),"number"==typeof a)this.layers[d].callbacks[a]={callback:b,callbackContext:c};else for(var e=0,f=a.length;e<f;e++)this.layers[d].callbacks[a[e]]={callback:b,callbackContext:c}},setTileLocationCallback:function(a,b,c,d,e,f,g){if(g=this.getLayer(g),this.copy(a,b,c,d,g),!(this._results.length<2))for(var h=1;h<this._results.length;h++)this._results[h].setCollisionCallback(e,f)},setCollision:function(a,b,c,d){if(void 0===b&&(b=!0),void 0===d&&(d=!0),c=this.getLayer(c),"number"==typeof a)return this.setCollisionByIndex(a,b,c,!0);if(Array.isArray(a)){for(var e=0;e<a.length;e++)this.setCollisionByIndex(a[e],b,c,!1);d&&this.calculateFaces(c)}},setCollisionBetween:function(a,b,c,d,e){if(void 0===c&&(c=!0),void 0===e&&(e=!0),d=this.getLayer(d),!(b<a)){for(var f=a;f<=b;f++)this.setCollisionByIndex(f,c,d,!1);e&&this.calculateFaces(d)}},setCollisionByExclusion:function(a,b,c,d){void 0===b&&(b=!0),void 0===d&&(d=!0),c=this.getLayer(c);for(var e=0,f=this.tiles.length;e<f;e++)-1===a.indexOf(e)&&this.setCollisionByIndex(e,b,c,!1);d&&this.calculateFaces(c)},setCollisionByIndex:function(a,b,c,d){if(void 0===b&&(b=!0),void 0===c&&(c=this.currentLayer),void 0===d&&(d=!0),b)this.collideIndexes.push(a);else{var e=this.collideIndexes.indexOf(a);-1<e&&this.collideIndexes.splice(e,1)}for(var f=0;f<this.layers[c].height;f++)for(var g=0;g<this.layers[c].width;g++){var h=this.layers[c].data[f][g];h&&h.index===a&&(b?h.setCollision(!0,!0,!0,!0):h.resetCollision(),h.faceTop=b,h.faceBottom=b,h.faceLeft=b,h.faceRight=b)}return d&&this.calculateFaces(c),c},getLayer:function(a){return void 0===a?a=this.currentLayer:"string"==typeof a?a=this.getLayerIndex(a):a instanceof c.TilemapLayer&&(a=a.index),a},setPreventRecalculate:function(a){if(!0===a&&!0!==this.preventingRecalculate&&(this.preventingRecalculate=!0,this.needToRecalculate={}),!1===a&&!0===this.preventingRecalculate){for(var b in this.preventingRecalculate=!1,this.needToRecalculate)this.calculateFaces(b);this.needToRecalculate=!1}},calculateFaces:function(a){if(this.preventingRecalculate)this.needToRecalculate[a]=!0;else for(var b=null,c=null,d=null,e=null,f=0,g=this.layers[a].height;f<g;f++)for(var h=0,i=this.layers[a].width;h<i;h++){var j=this.layers[a].data[f][h];j&&(b=this.getTileAbove(a,h,f),c=this.getTileBelow(a,h,f),d=this.getTileLeft(a,h,f),e=this.getTileRight(a,h,f),j.collides&&(j.faceTop=!0,j.faceBottom=!0,j.faceLeft=!0,j.faceRight=!0),b&&b.collides&&(j.faceTop=!1),c&&c.collides&&(j.faceBottom=!1),d&&d.collides&&(j.faceLeft=!1),e&&e.collides&&(j.faceRight=!1))}},getTileAbove:function(a,b,c){return 0<c?this.layers[a].data[c-1][b]:null},getTileBelow:function(a,b,c){return c<this.layers[a].height-1?this.layers[a].data[c+1][b]:null},getTileLeft:function(a,b,c){return 0<b?this.layers[a].data[c][b-1]:null},getTileRight:function(a,b,c){return b<this.layers[a].width-1?this.layers[a].data[c][b+1]:null},setLayer:function(a){a=this.getLayer(a),this.layers[a]&&(this.currentLayer=a)},hasTile:function(a,b,c){return c=this.getLayer(c),void 0!==this.layers[c].data[b]&&void 0!==this.layers[c].data[b][a]&&-1<this.layers[c].data[b][a].index},removeTile:function(a,b,d){if(d=this.getLayer(d),0<=a&&a<this.layers[d].width&&0<=b&&b<this.layers[d].height&&this.hasTile(a,b,d)){var e=this.layers[d].data[b][a];return this.layers[d].data[b][a]=new c.Tile(this.layers[d],-1,a,b,this.tileWidth,this.tileHeight),this.layers[d].dirty=!0,this.calculateFaces(d),e}},removeTileWorldXY:function(a,b,c,d,e){return e=this.getLayer(e),a=this.game.math.snapToFloor(a,c)/c,b=this.game.math.snapToFloor(b,d)/d,this.removeTile(a,b,e)},putTile:function(a,b,d,e){return null===a?this.removeTile(b,d,e):(e=this.getLayer(e),0<=b&&b<this.layers[e].width&&0<=d&&d<this.layers[e].height?(a instanceof c.Tile?(f=a.index,this.hasTile(b,d,e)?this.layers[e].data[d][b].copy(a):this.layers[e].data[d][b]=new c.Tile(e,f,b,d,a.width,a.height)):(f=a,this.hasTile(b,d,e)?this.layers[e].data[d][b].index=f:this.layers[e].data[d][b]=new c.Tile(this.layers[e],f,b,d,this.tileWidth,this.tileHeight)),-1<this.collideIndexes.indexOf(f)?this.layers[e].data[d][b].setCollision(!0,!0,!0,!0):this.layers[e].data[d][b].resetCollision(),this.layers[e].dirty=!0,this.calculateFaces(e),this.layers[e].data[d][b]):null);var f},putTileWorldXY:function(a,b,c,d,e,f){return f=this.getLayer(f),b=this.game.math.snapToFloor(b,d)/d,c=this.game.math.snapToFloor(c,e)/e,this.putTile(a,b,c,f)},searchTileIndex:function(a,b,c,d){void 0===b&&(b=0),void 0===c&&(c=!1),d=this.getLayer(d);var e=0;if(c){for(var f=this.layers[d].height-1;0<=f;f--)for(var g=this.layers[d].width-1;0<=g;g--)if(this.layers[d].data[f][g].index===a){if(e===b)return this.layers[d].data[f][g];e++}}else for(f=0;f<this.layers[d].height;f++)for(g=0;g<this.layers[d].width;g++)if(this.layers[d].data[f][g].index===a){if(e===b)return this.layers[d].data[f][g];e++}return null},getTile:function(a,b,c,d){return void 0===d&&(d=!1),c=this.getLayer(c),0<=a&&a<this.layers[c].width&&0<=b&&b<this.layers[c].height?-1===this.layers[c].data[b][a].index?d?this.layers[c].data[b][a]:null:this.layers[c].data[b][a]:null},getTileWorldXY:function(a,b,c,d,e,f){return void 0===c&&(c=this.tileWidth),void 0===d&&(d=this.tileHeight),e=this.getLayer(e),a=this.game.math.snapToFloor(a,c)/c,b=this.game.math.snapToFloor(b,d)/d,this.getTile(a,b,e,f)},copy:function(a,b,c,d,e){if(e=this.getLayer(e),this.layers[e]){void 0===a&&(a=0),void 0===b&&(b=0),void 0===c&&(c=this.layers[e].width),void 0===d&&(d=this.layers[e].height),a<0&&(a=0),b<0&&(b=0),c>this.layers[e].width&&(c=this.layers[e].width),d>this.layers[e].height&&(d=this.layers[e].height),this._results.length=0,this._results.push({x:a,y:b,width:c,height:d,layer:e});for(var f=b;f<b+d;f++)for(var g=a;g<a+c;g++)this._results.push(this.layers[e].data[f][g]);return this._results}this._results.length=0},paste:function(a,b,c,d){if(void 0===a&&(a=0),void 0===b&&(b=0),d=this.getLayer(d),c&&!(c.length<2)){for(var e=a-c[1].x,f=b-c[1].y,g=1;g<c.length;g++)this.layers[d].data[f+c[g].y][e+c[g].x].copy(c[g]);this.layers[d].dirty=!0,this.calculateFaces(d)}},swap:function(a,b,c,d,e,f,g){g=this.getLayer(g),this.copy(c,d,e,f,g),this._results.length<2||(this._tempA=a,this._tempB=b,this._results.forEach(this.swapHandler,this),this.paste(c,d,this._results,g))},swapHandler:function(a){a.index===this._tempA?a.index=this._tempB:a.index===this._tempB&&(a.index=this._tempA)},forEach:function(a,b,c,d,e,f,g){g=this.getLayer(g),this.copy(c,d,e,f,g),this._results.length<2||(this._results.forEach(a,b),this.paste(c,d,this._results,g))},replace:function(a,b,c,d,e,f,g){if(g=this.getLayer(g),this.copy(c,d,e,f,g),!(this._results.length<2)){for(var h=1;h<this._results.length;h++)this._results[h].index===a&&(this._results[h].index=b);this.paste(c,d,this._results,g)}},random:function(a,b,c,d,e){if(e=this.getLayer(e),this.copy(a,b,c,d,e),!(this._results.length<2)){for(var f=[],g=1;g<this._results.length;g++)if(this._results[g].index){var h=this._results[g].index;-1===f.indexOf(h)&&f.push(h)}for(var i=1;i<this._results.length;i++)this._results[i].index=this.game.rnd.pick(f);this.paste(a,b,this._results,e)}},shuffle:function(a,b,d,e,f){if(f=this.getLayer(f),this.copy(a,b,d,e,f),!(this._results.length<2)){for(var g=[],h=1;h<this._results.length;h++)this._results[h].index&&g.push(this._results[h].index);c.ArrayUtils.shuffle(g);for(var i=1;i<this._results.length;i++)this._results[i].index=g[i-1];this.paste(a,b,this._results,f)}},fill:function(a,b,c,d,e,f){if(f=this.getLayer(f),this.copy(b,c,d,e,f),!(this._results.length<2)){for(var g=1;g<this._results.length;g++)this._results[g].index=a;this.paste(b,c,this._results,f)}},removeAllLayers:function(){this.layers.length=0,this.currentLayer=0},dump:function(){for(var a="",b=[""],c=0;c<this.layers[this.currentLayer].height;c++){for(var d=0;d<this.layers[this.currentLayer].width;d++)a+="%c ",1<this.layers[this.currentLayer].data[c][d]?this.debugMap[this.layers[this.currentLayer].data[c][d]]?b.push("background: "+this.debugMap[this.layers[this.currentLayer].data[c][d]]):b.push("background: #ffffff"):b.push("background: rgb(0, 0, 0)");a+="\n"}b[0]=a},destroy:function(){this.removeAllLayers(),this.data=[],this.game=null}},c.Tilemap.prototype.constructor=c.Tilemap,Object.defineProperty(c.Tilemap.prototype,"layer",{get:function(){return this.layers[this.currentLayer]},set:function(a){a!==this.currentLayer&&this.setLayer(a)}}),c.TilemapLayer=function(a,b,d,e,f){e|=0,f|=0,c.Sprite.call(this,a,0,0),this.map=b,this.index=d,this.layer=b.layers[d],this.canvas=PIXI.CanvasPool.create(this,e,f),this.context=this.canvas.getContext("2d"),this.setTexture(new PIXI.Texture(new PIXI.BaseTexture(this.canvas))),this.type=c.TILEMAPLAYER,this.physicsType=c.TILEMAPLAYER,this.renderSettings={enableScrollDelta:!1,overdrawRatio:.2,copyCanvas:null},this.debug=!1,this.exists=!0,this.debugSettings={missingImageFill:"rgb(255,255,255)",debuggedTileOverfill:"rgba(0,255,0,0.4)",forceFullRedraw:!0,debugAlpha:.5,facingEdgeStroke:"rgba(0,255,0,1)",collidingTileOverfill:"rgba(0,255,0,0.2)"},this.scrollFactorX=1,this.scrollFactorY=1,this.dirty=!0,this.rayStepRate=4,this._wrap=!1,this._mc={scrollX:0,scrollY:0,renderWidth:0,renderHeight:0,tileWidth:b.tileWidth,tileHeight:b.tileHeight,cw:b.tileWidth,ch:b.tileHeight,tilesets:[]},this._scrollX=0,this._scrollY=0,this._results=[],a.device.canvasBitBltShift||(this.renderSettings.copyCanvas=c.TilemapLayer.ensureSharedCopyCanvas()),this.fixedToCamera=!0},c.TilemapLayer.prototype=Object.create(c.Sprite.prototype),c.TilemapLayer.prototype.constructor=c.TilemapLayer,c.TilemapLayer.prototype.preUpdateCore=c.Component.Core.preUpdate,c.TilemapLayer.sharedCopyCanvas=null,c.TilemapLayer.ensureSharedCopyCanvas=function(){return this.sharedCopyCanvas||(this.sharedCopyCanvas=PIXI.CanvasPool.create(this,2,2)),this.sharedCopyCanvas},c.TilemapLayer.prototype.preUpdate=function(){return this.preUpdateCore()},c.TilemapLayer.prototype.postUpdate=function(){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=this.game.camera.view.x*this.scrollFactorX/this.scale.x,this._scrollY=this.game.camera.view.y*this.scrollFactorY/this.scale.y},c.TilemapLayer.prototype._renderCanvas=function(a){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=this.game.camera.view.x*this.scrollFactorX/this.scale.x,this._scrollY=this.game.camera.view.y*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderCanvas.call(this,a)},c.TilemapLayer.prototype._renderWebGL=function(a){this.fixedToCamera&&(this.position.x=(this.game.camera.view.x+this.cameraOffset.x)/this.game.camera.scale.x,this.position.y=(this.game.camera.view.y+this.cameraOffset.y)/this.game.camera.scale.y),this._scrollX=this.game.camera.view.x*this.scrollFactorX/this.scale.x,this._scrollY=this.game.camera.view.y*this.scrollFactorY/this.scale.y,this.render(),PIXI.Sprite.prototype._renderWebGL.call(this,a)},c.TilemapLayer.prototype.destroy=function(){PIXI.CanvasPool.remove(this),c.Component.Destroy.prototype.destroy.call(this)},c.TilemapLayer.prototype.resize=function(a,b){this.canvas.width=a,this.canvas.height=b,this.texture.frame.resize(a,b),this.texture.width=a,this.texture.height=b,this.texture.crop.width=a,this.texture.crop.height=b,this.texture.baseTexture.width=a,this.texture.baseTexture.height=b,this.texture.baseTexture.dirty(),this.texture.requiresUpdate=!0,this.texture._updateUvs(),this.dirty=!0},c.TilemapLayer.prototype.resizeWorld=function(){this.game.world.setBounds(0,0,this.layer.widthInPixels*this.scale.x,this.layer.heightInPixels*this.scale.y)},c.TilemapLayer.prototype._fixX=function(a){return 1===this.scrollFactorX||0===this.scrollFactorX&&0===this.position.x?a:0===this.scrollFactorX&&0!==this.position.x?a-this.position.x:this._scrollX+(a-this._scrollX/this.scrollFactorX)},c.TilemapLayer.prototype._unfixX=function(a){return 1===this.scrollFactorX?a:this._scrollX/this.scrollFactorX+(a-this._scrollX)},c.TilemapLayer.prototype._fixY=function(a){return 1===this.scrollFactorY||0===this.scrollFactorY&&0===this.position.y?a:0===this.scrollFactorY&&0!==this.position.y?a-this.position.y:this._scrollY+(a-this._scrollY/this.scrollFactorY)},c.TilemapLayer.prototype._unfixY=function(a){return 1===this.scrollFactorY?a:this._scrollY/this.scrollFactorY+(a-this._scrollY)},c.TilemapLayer.prototype.getTileX=function(a){return Math.floor(this._fixX(a)/this._mc.tileWidth)},c.TilemapLayer.prototype.getTileY=function(a){return Math.floor(this._fixY(a)/this._mc.tileHeight)},c.TilemapLayer.prototype.getTileXY=function(a,b,c){return c.x=this.getTileX(a),c.y=this.getTileY(b),c},c.TilemapLayer.prototype.getRayCastTiles=function(a,b,c,d){b||(b=this.rayStepRate),void 0===c&&(c=!1),void 0===d&&(d=!1);var e=this.getTiles(a.x,a.y,a.width,a.height,c,d);if(0===e.length)return[];for(var f=a.coordinatesOnLine(b),g=[],h=0;h<e.length;h++)for(var i=0;i<f.length;i++){var j=e[h],k=f[i];if(j.containsPoint(k[0],k[1])){g.push(j);break}}return g},c.TilemapLayer.prototype.getTiles=function(a,b,c,d,e,f){void 0===e&&(e=!1),void 0===f&&(f=!1);var g=!(e||f);a=this._fixX(a),b=this._fixY(b);for(var h=Math.floor(a/(this._mc.cw*this.scale.x)),i=Math.floor(b/(this._mc.ch*this.scale.y)),j=Math.ceil((a+c)/(this._mc.cw*this.scale.x))-h,k=Math.ceil((b+d)/(this._mc.ch*this.scale.y))-i;this._results.length;)this._results.pop();for(var l=i;l<i+k;l++)for(var m=h;m<h+j;m++){var n=this.layer.data[l];n&&n[m]&&(g||n[m].isInteresting(e,f))&&this._results.push(n[m])}return this._results.slice()},c.TilemapLayer.prototype.resolveTileset=function(a){var b=this._mc.tilesets;if(a<2e3)for(;b.length<a;)b.push(void 0);var c=this.map.tiles[a]&&this.map.tiles[a][2];if(null!==c){var d=this.map.tilesets[c];if(d&&d.containsTileIndex(a))return b[a]=d}return b[a]=null},c.TilemapLayer.prototype.resetTilesetCache=function(){for(var a=this._mc.tilesets;a.length;)a.pop()},c.TilemapLayer.prototype.setScale=function(a,b){a=a||1,b=b||a;for(var c=0;c<this.layer.data.length;c++)for(var d=this.layer.data[c],e=0;e<d.length;e++){var f=d[e];f.width=this.map.tileWidth*a,f.height=this.map.tileHeight*b,f.worldX=f.x*f.width,f.worldY=f.y*f.height}this.scale.setTo(a,b)},c.TilemapLayer.prototype.shiftCanvas=function(a,b,c){var d=a.canvas,e=d.width-Math.abs(b),f=d.height-Math.abs(c),g=0,h=0,i=b,j=c;b<0&&(g=-b,i=0),c<0&&(h=-c,j=0);var k=this.renderSettings.copyCanvas;if(k){(k.width<e||k.height<f)&&(k.width=e,k.height=f);var l=k.getContext("2d");l.clearRect(0,0,e,f),l.drawImage(d,g,h,e,f,0,0,e,f),a.clearRect(i,j,e,f),a.drawImage(k,0,0,e,f,i,j,e,f)}else a.save(),a.globalCompositeOperation="copy",a.drawImage(d,g,h,e,f,i,j,e,f),a.restore()},c.TilemapLayer.prototype.renderRegion=function(a,b,c,d,e,f){var g=this.context,h=this.layer.width,i=this.layer.height,j=this._mc.tileWidth,k=this._mc.tileHeight,l=this._mc.tilesets,m=NaN;this._wrap||(c<=e&&(c=Math.max(0,c),e=Math.min(h-1,e)),d<=f&&(d=Math.max(0,d),f=Math.min(i-1,f)));var n,o,p,q,r,s,t=c*j-a,v=(c+(1<<20)*h)%h;for(q=(d+(1<<20)*i)%i,s=f-d,o=d*k-b;0<=s;q++,s--,o+=k){i<=q&&(q-=i);var x=this.layer.data[q];for(p=v,r=e-c,n=t;0<=r;p++,r--,n+=j){h<=p&&(p-=h);var y=x[p];if(y&&!(y.index<0)){var z=y.index,A=l[z];void 0===A&&(A=this.resolveTileset(z)),y.alpha===m||this.debug||(g.globalAlpha=y.alpha,m=y.alpha),A?y.rotation||y.flipped?(g.save(),g.translate(n+y.centerX,o+y.centerY),g.rotate(y.rotation),y.flipped&&g.scale(-1,1),A.draw(g,-y.centerX,-y.centerY,z),g.restore()):A.draw(g,n,o,z):this.debugSettings.missingImageFill&&(g.fillStyle=this.debugSettings.missingImageFill,g.fillRect(n,o,j,k)),y.debug&&this.debugSettings.debuggedTileOverfill&&(g.fillStyle=this.debugSettings.debuggedTileOverfill,g.fillRect(n,o,j,k))}}}},c.TilemapLayer.prototype.renderDeltaScroll=function(a,b){var c=this._mc.scrollX,d=this._mc.scrollY,e=this.canvas.width,f=this.canvas.height,g=this._mc.tileWidth,h=this._mc.tileHeight,i=0,j=-g,k=0,l=-h;if(a<0?(i=e+a,j=e-1):0<a&&(j=a),b<0?(k=f+b,l=f-1):0<b&&(l=b),this.shiftCanvas(this.context,a,b),i=Math.floor((i+c)/g),j=Math.floor((j+c)/g),k=Math.floor((k+d)/h),l=Math.floor((l+d)/h),i<=j){this.context.clearRect(i*g-c,0,(j-i+1)*g,f);var m=Math.floor((0+d)/h),n=Math.floor((f-1+d)/h);this.renderRegion(c,d,i,m,j,n)}if(k<=l){this.context.clearRect(0,k*h-d,e,(l-k+1)*h);var o=Math.floor((0+c)/g),p=Math.floor((e-1+c)/g);this.renderRegion(c,d,o,k,p,l)}},c.TilemapLayer.prototype.renderFull=function(){var a=this._mc.scrollX,b=this._mc.scrollY,c=this.canvas.width,d=this.canvas.height,e=this._mc.tileWidth,f=this._mc.tileHeight,g=Math.floor(a/e),h=Math.floor((c-1+a)/e),i=Math.floor(b/f),j=Math.floor((d-1+b)/f);this.context.clearRect(0,0,c,d),this.renderRegion(a,b,g,i,h,j)},c.TilemapLayer.prototype.render=function(){var a=!1;if(this.visible){(this.dirty||this.layer.dirty)&&(a=!(this.layer.dirty=!1));var b=this.canvas.width,c=this.canvas.height,d=0|this._scrollX,e=0|this._scrollY,f=this._mc,g=f.scrollX-d,h=f.scrollY-e;if(a||0!==g||0!==h||f.renderWidth!==b||f.renderHeight!==c)return this.context.save(),f.scrollX=d,f.scrollY=e,f.renderWidth===b&&f.renderHeight===c||(f.renderWidth=b,f.renderHeight=c),this.debug&&(this.context.globalAlpha=this.debugSettings.debugAlpha,this.debugSettings.forceFullRedraw&&(a=!0)),!a&&this.renderSettings.enableScrollDelta&&Math.abs(g)+Math.abs(h)<Math.min(b,c)?this.renderDeltaScroll(g,h):this.renderFull(),this.debug&&(this.context.globalAlpha=1,this.renderDebug()),this.texture.baseTexture.dirty(),this.dirty=!1,this.context.restore(),!0}},c.TilemapLayer.prototype.renderDebug=function(){var a,b,c,d,e,f,g=this._mc.scrollX,h=this._mc.scrollY,i=this.context,j=this.canvas.width,k=this.canvas.height,l=this.layer.width,m=this.layer.height,n=this._mc.tileWidth,o=this._mc.tileHeight,p=Math.floor(g/n),q=Math.floor((j-1+g)/n),r=Math.floor(h/o),s=Math.floor((k-1+h)/o),t=p*n-g,u=r*o-h,v=(p+(1<<20)*l)%l,w=(r+(1<<20)*m)%m;for(i.strokeStyle=this.debugSettings.facingEdgeStroke,d=w,f=s-r,b=u;0<=f;d++,f--,b+=o){m<=d&&(d-=m);var x=this.layer.data[d];for(c=v,e=q-p,a=t;0<=e;c++,e--,a+=n){l<=c&&(c-=l);var y=x[c];!y||y.index<0||!y.collides||(this.debugSettings.collidingTileOverfill&&(i.fillStyle=this.debugSettings.collidingTileOverfill,i.fillRect(a,b,this._mc.cw,this._mc.ch)),this.debugSettings.facingEdgeStroke&&(i.beginPath(),y.faceTop&&(i.moveTo(a,b),i.lineTo(a+this._mc.cw,b)),y.faceBottom&&(i.moveTo(a,b+this._mc.ch),i.lineTo(a+this._mc.cw,b+this._mc.ch)),y.faceLeft&&(i.moveTo(a,b),i.lineTo(a,b+this._mc.ch)),y.faceRight&&(i.moveTo(a+this._mc.cw,b),i.lineTo(a+this._mc.cw,b+this._mc.ch)),i.closePath(),i.stroke()))}}},Object.defineProperty(c.TilemapLayer.prototype,"wrap",{get:function(){return this._wrap},set:function(a){this._wrap=a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollX",{get:function(){return this._scrollX},set:function(a){this._scrollX=a}}),Object.defineProperty(c.TilemapLayer.prototype,"scrollY",{get:function(){return this._scrollY},set:function(a){this._scrollY=a}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionWidth",{get:function(){return this._mc.cw},set:function(a){this._mc.cw=0|a,this.dirty=!0}}),Object.defineProperty(c.TilemapLayer.prototype,"collisionHeight",{get:function(){return this._mc.ch},set:function(a){this._mc.ch=0|a,this.dirty=!0}}),c.TilemapParser={INSERT_NULL:!1,parse:function(a,b,d,e,f,g){if(void 0===d&&(d=32),void 0===e&&(e=32),void 0===f&&(f=10),void 0===g&&(g=10),void 0===b)return this.getEmptyData();if(null===b)return this.getEmptyData(d,e,f,g);var h=a.cache.getTilemapData(b);if(h){if(h.format===c.Tilemap.CSV)return this.parseCSV(b,h.data,d,e);if(!h.format||h.format===c.Tilemap.TILED_JSON)return this.parseTiledJSON(h.data)}},parseCSV:function(a,b,d,e){for(var f=this.getEmptyData(),g=[],h=(b=b.trim()).split("\n"),i=h.length,j=0,k=0;k<h.length;k++){g[k]=[];for(var l=h[k].split(","),m=0;m<l.length;m++)g[k][m]=new c.Tile(f.layers[0],parseInt(l[m],10),m,k,d,e);0===j&&(j=l.length)}return f.format=c.Tilemap.CSV,f.name=a,f.width=j,f.height=i,f.tileWidth=d,f.tileHeight=e,f.widthInPixels=j*d,f.heightInPixels=i*e,f.layers[0].width=j,f.layers[0].height=i,f.layers[0].widthInPixels=f.widthInPixels,f.layers[0].heightInPixels=f.heightInPixels,f.layers[0].data=g,f},getEmptyData:function(a,b,c,d){return{width:null!=c?c:0,height:null!=d?d:0,tileWidth:null!=a?a:0,tileHeight:null!=b?b:0,orientation:"orthogonal",version:"1",properties:{},widthInPixels:0,heightInPixels:0,layers:[{name:"layer",x:0,y:0,width:0,height:0,widthInPixels:0,heightInPixels:0,alpha:1,visible:!0,properties:{},indexes:[],callbacks:[],bodies:[],data:[]}],images:[],objects:{},collision:{},tilesets:[],tiles:[]}},parseTiledJSON:function(a){function b(a,b){var c={};for(var d in b){var e=b[d];void 0!==a[e]&&(c[e]=a[e])}return c}if("orthogonal"!==a.orientation)return null;for(var d={width:a.width,height:a.height,tileWidth:a.tilewidth,tileHeight:a.tileheight,orientation:a.orientation,format:c.Tilemap.TILED_JSON,version:a.version,properties:a.properties,widthInPixels:a.width*a.tilewidth,heightInPixels:a.height*a.tileheight},e=[],f=0;f<a.layers.length;f++)if("tilelayer"===a.layers[f].type){var g=a.layers[f];if(!g.compression&&g.encoding&&"base64"===g.encoding){for(var h=window.atob(g.data),i=h.length,j=new Array(i),k=0;k<i;k+=4)j[k/4]=(h.charCodeAt(k)|h.charCodeAt(k+1)<<8|h.charCodeAt(k+2)<<16|h.charCodeAt(k+3)<<24)>>>0;g.data=j,delete g.encoding}else if(g.compression)continue;var l={name:g.name,x:g.x,y:g.y,width:g.width,height:g.height,widthInPixels:g.width*a.tilewidth,heightInPixels:g.height*a.tileheight,alpha:g.opacity,visible:g.visible,properties:{},indexes:[],callbacks:[],bodies:[]};g.properties&&(l.properties=g.properties);var m,n,o,q=0,r=[],s=[],t=0;for(i=g.data.length;t<i;t++){if(n=!1,o=m=0,536870912<(p=g.data[t]))switch(2147483648<p&&(p-=2147483648,o+=4),1073741824<p&&(p-=1073741824,o+=2),536870912<p&&(p-=536870912,o+=1),o){case 5:m=Math.PI/2;break;case 6:m=Math.PI;break;case 3:m=3*Math.PI/2;break;case 4:n=!(m=0);break;case 7:m=Math.PI/2,n=!0;break;case 2:m=Math.PI,n=!0;break;case 1:m=3*Math.PI/2,n=!0}if(0<p)(u=new c.Tile(l,p,q,s.length,a.tilewidth,a.tileheight)).rotation=m,u.flipped=n,0!==o&&(u.flippedVal=o),r.push(u);else c.TilemapParser.INSERT_NULL?r.push(null):r.push(new c.Tile(l,-1,q,s.length,a.tilewidth,a.tileheight));++q===g.width&&(s.push(r),q=0,r=[])}l.data=s,e.push(l)}d.layers=e;var v=[];for(f=0;f<a.layers.length;f++)if("imagelayer"===a.layers[f].type){var w=a.layers[f],x={name:w.name,image:w.image,x:w.x,y:w.y,alpha:w.opacity,visible:w.visible,properties:{}};w.properties&&(x.properties=w.properties),v.push(x)}d.images=v;var y=[],z=[],A=null;for(f=0;f<a.tilesets.length;f++){if((B=a.tilesets[f]).image){var C=new c.Tileset(B.name,B.firstgid,B.tilewidth,B.tileheight,B.margin,B.spacing,B.properties);B.tileproperties&&(C.tileProperties=B.tileproperties),C.updateTileData(B.imagewidth,B.imageheight),y.push(C)}else{var D=new c.ImageCollection(B.name,B.firstgid,B.tilewidth,B.tileheight,B.margin,B.spacing,B.properties);for(var E in B.tiles){x=B.tiles[E].image;var p=B.firstgid+parseInt(E,10);D.addImage(p,x)}z.push(D)}A&&(A.lastgid=B.firstgid-1),A=B}d.tilesets=y,d.imagecollections=z;var F={},G={};for(f=0;f<a.layers.length;f++)if("objectgroup"===a.layers[f].type){var H=a.layers[f];F[H.name]=[],G[H.name]=[];var I=0;for(i=H.objects.length;I<i;I++)if(H.objects[I].gid){var J={gid:H.objects[I].gid,name:H.objects[I].name,type:H.objects[I].hasOwnProperty("type")?H.objects[I].type:"",x:H.objects[I].x,y:H.objects[I].y,visible:H.objects[I].visible,properties:H.objects[I].properties};H.objects[I].rotation&&(J.rotation=H.objects[I].rotation),F[H.name].push(J)}else if(H.objects[I].polyline){J={name:H.objects[I].name,type:H.objects[I].type,x:H.objects[I].x,y:H.objects[I].y,width:H.objects[I].width,height:H.objects[I].height,visible:H.objects[I].visible,properties:H.objects[I].properties};H.objects[I].rotation&&(J.rotation=H.objects[I].rotation),J.polyline=[];for(var K=0;K<H.objects[I].polyline.length;K++)J.polyline.push([H.objects[I].polyline[K].x,H.objects[I].polyline[K].y]);G[H.name].push(J),F[H.name].push(J)}else if(H.objects[I].polygon){(J=b(H.objects[I],["name","type","x","y","visible","rotation","properties"])).polygon=[];for(K=0;K<H.objects[I].polygon.length;K++)J.polygon.push([H.objects[I].polygon[K].x,H.objects[I].polygon[K].y]);F[H.name].push(J)}else if(H.objects[I].ellipse){J=b(H.objects[I],["name","type","ellipse","x","y","width","height","visible","rotation","properties"]);F[H.name].push(J)}else{(J=b(H.objects[I],["name","type","x","y","width","height","visible","rotation","properties"])).rectangle=!0,F[H.name].push(J)}}d.objects=F,d.collision=G,d.tiles=[];for(f=0;f<d.tilesets.length;f++){q=(B=d.tilesets[f]).tileMargin;var L=B.tileMargin,M=0,N=0,O=0;for(t=B.firstgid;t<B.firstgid+B.total&&(d.tiles[t]=[q,L,f],q+=B.tileWidth+B.tileSpacing,++M!==B.total)&&(++N!==B.columns||(q=B.tileMargin,L+=B.tileHeight+B.tileSpacing,N=0,++O!==B.rows));t++);}var u,P,B;for(f=0;f<d.layers.length;f++){l=d.layers[f],B=null;for(k=0;k<l.data.length;k++){r=l.data[k];for(var Q=0;Q<r.length;Q++)null===(u=r[Q])||u.index<0||(P=d.tiles[u.index][2],(B=d.tilesets[P]).tileProperties&&B.tileProperties[u.index-B.firstgid]&&(u.properties=c.Utils.mixin(B.tileProperties[u.index-B.firstgid],u.properties)))}}return d}},c.Tileset=function(a,b,c,d,e,f,g){(void 0===c||c<=0)&&(c=32),(void 0===d||d<=0)&&(d=32),void 0===e&&(e=0),void 0===f&&(f=0),this.name=a,this.firstgid=0|b,this.tileWidth=0|c,this.tileHeight=0|d,this.tileMargin=0|e,this.tileSpacing=0|f,this.properties=g||{},this.image=null,this.rows=0,this.columns=0,this.total=0,this.drawCoords=[]},c.Tileset.prototype={draw:function(a,b,c,d){var e=d-this.firstgid<<1;0<=e&&e+1<this.drawCoords.length&&a.drawImage(this.image,this.drawCoords[e],this.drawCoords[e+1],this.tileWidth,this.tileHeight,b,c,this.tileWidth,this.tileHeight)},containsTileIndex:function(a){return a>=this.firstgid&&a<this.firstgid+this.total},setImage:function(a){this.image=a,this.updateTileData(a.width,a.height)},setSpacing:function(a,b){this.tileMargin=0|a,this.tileSpacing=0|b,this.image&&this.updateTileData(this.image.width,this.image.height)},updateTileData:function(a,b){var c=(b-2*this.tileMargin+this.tileSpacing)/(this.tileHeight+this.tileSpacing),d=(a-2*this.tileMargin+this.tileSpacing)/(this.tileWidth+this.tileSpacing);c=Math.floor(c),d=Math.floor(d),this.rows&&this.rows!==c||this.columns&&this.columns,this.rows=c,this.columns=d,this.total=c*d,this.drawCoords.length=0;for(var e=this.tileMargin,f=this.tileMargin,g=0;g<this.rows;g++){for(var h=0;h<this.columns;h++)this.drawCoords.push(e),this.drawCoords.push(f),e+=this.tileWidth+this.tileSpacing;e=this.tileMargin,f+=this.tileHeight+this.tileSpacing}}},c.Tileset.prototype.constructor=c.Tileset,c.Particle=function(a,b,d,e,f){c.Sprite.call(this,a,b,d,e,f),this.autoScale=!1,this.scaleData=null,this._s=0,this.autoAlpha=!1,this.alphaData=null,this._a=0},c.Particle.prototype=Object.create(c.Sprite.prototype),c.Particle.prototype.constructor=c.Particle,c.Particle.prototype.update=function(){this.autoScale&&(this._s--,this._s?this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y):this.autoScale=!1),this.autoAlpha&&(this._a--,this._a?this.alpha=this.alphaData[this._a].v:this.autoAlpha=!1)},c.Particle.prototype.onEmit=function(){},c.Particle.prototype.setAlphaData=function(a){this.alphaData=a,this._a=a.length-1,this.alpha=this.alphaData[this._a].v,this.autoAlpha=!0},c.Particle.prototype.setScaleData=function(a){this.scaleData=a,this._s=a.length-1,this.scale.set(this.scaleData[this._s].x,this.scaleData[this._s].y),this.autoScale=!0},c.Particle.prototype.reset=function(a,b,d){return c.Component.Reset.prototype.reset.call(this,a,b,d),this.alpha=1,this.scale.set(1),this.autoScale=!1,this.autoAlpha=!1,this},c.Particles=function(a){this.game=a,this.emitters={},this.ID=0},c.Particles.prototype={add:function(a){return this.emitters[a.name]=a},remove:function(a){delete this.emitters[a.name]},update:function(){for(var a in this.emitters)this.emitters[a].exists&&this.emitters[a].update()}},c.Particles.prototype.constructor=c.Particles,c.Particles.Arcade={},c.Particles.Arcade.Emitter=function(a,b,d,e){this.maxParticles=e||50,c.Group.call(this,a),this.name="emitter"+this.game.particles.ID++,this.type=c.EMITTER,this.physicsType=c.GROUP,this.area=new c.Rectangle(b,d,1,1),this.minParticleSpeed=new c.Point(-100,-100),this.maxParticleSpeed=new c.Point(100,100),this.minParticleScale=1,this.maxParticleScale=1,this.scaleData=null,this.minRotation=-360,this.maxRotation=360,this.minParticleAlpha=1,this.maxParticleAlpha=1,this.alphaData=null,this.gravity=100,this.particleClass=c.Particle,this.particleDrag=new c.Point,this.angularDrag=0,this.frequency=100,this.lifespan=2e3,this.bounce=new c.Point,this.on=!1,this.particleAnchor=new c.Point(.5,.5),this.blendMode=c.blendModes.NORMAL,this.emitX=b,this.emitY=d,this.autoScale=!1,this.autoAlpha=!1,this.particleBringToTop=!1,this.particleSendToBack=!1,this._minParticleScale=new c.Point(1,1),this._maxParticleScale=new c.Point(1,1),this._quantity=0,this._timer=0,this._counter=0,this._flowQuantity=0,this._flowTotal=0,this._explode=!0,this._frames=null},c.Particles.Arcade.Emitter.prototype=Object.create(c.Group.prototype),c.Particles.Arcade.Emitter.prototype.constructor=c.Particles.Arcade.Emitter,c.Particles.Arcade.Emitter.prototype.update=function(){if(this.on&&this.game.time.time>=this._timer)if(this._timer=this.game.time.time+this.frequency*this.game.time.slowMotion,0!==this._flowTotal)if(0<this._flowQuantity){for(var a=0;a<this._flowQuantity;a++)if(this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal)){this.on=!1;break}}else this.emitParticle()&&(this._counter++,-1!==this._flowTotal&&this._counter>=this._flowTotal&&(this.on=!1));else this.emitParticle()&&(this._counter++,0<this._quantity&&this._counter>=this._quantity&&(this.on=!1));for(a=this.children.length;a--;)this.children[a].exists&&this.children[a].update()},c.Particles.Arcade.Emitter.prototype.makeParticles=function(a,b,c,d,e){void 0===b&&(b=0),void 0===c&&(c=this.maxParticles),void 0===d&&(d=!1),void 0===e&&(e=!1);var f,g=0,h=a,i=b;for(this._frames=b,c>this.maxParticles&&(this.maxParticles=c);g<c;)Array.isArray(a)&&(h=this.game.rnd.pick(a)),Array.isArray(b)&&(i=this.game.rnd.pick(b)),f=new this.particleClass(this.game,0,0,h,i),this.game.physics.arcade.enable(f,!1),d?(f.body.checkCollision.any=!0,f.body.checkCollision.none=!1):f.body.checkCollision.none=!0,f.body.collideWorldBounds=e,f.body.skipQuadTree=!0,f.exists=!1,f.visible=!1,f.anchor.copyFrom(this.particleAnchor),this.add(f),g++;return this},c.Particles.Arcade.Emitter.prototype.kill=function(){return this.on=!1,this.alive=!1,this.exists=!1,this},c.Particles.Arcade.Emitter.prototype.revive=function(){return this.alive=!0,this.exists=!0,this},c.Particles.Arcade.Emitter.prototype.explode=function(a,b){return this._flowTotal=0,this.start(!0,a,0,b,!1),this},c.Particles.Arcade.Emitter.prototype.flow=function(a,b,c,d,e){return void 0!==c&&0!==c||(c=1),void 0===d&&(d=-1),void 0===e&&(e=!0),c>this.maxParticles&&(c=this.maxParticles),this._counter=0,this._flowQuantity=c,this._flowTotal=d,e?(this.start(!0,a,b,c),this._counter+=c,this.on=!0,this._timer=this.game.time.time+b*this.game.time.slowMotion):this.start(!1,a,b,c),this},c.Particles.Arcade.Emitter.prototype.start=function(a,b,c,d,e){if(void 0===a&&(a=!0),void 0===b&&(b=0),null!=c||(c=250),void 0===d&&(d=0),void 0===e&&(e=!1),d>this.maxParticles&&(d=this.maxParticles),this.revive(),this.visible=!0,this.lifespan=b,this.frequency=c,a||e)for(var f=0;f<d;f++)this.emitParticle();else this.on=!0,this._quantity=d,this._counter=0,this._timer=this.game.time.time+c*this.game.time.slowMotion;return this},c.Particles.Arcade.Emitter.prototype.emitParticle=function(a,b,c,d){void 0===a&&(a=null),void 0===b&&(b=null);var e=this.getFirstExists(!1);if(null===e)return!1;var f=this.game.rnd;void 0!==c&&void 0!==d?e.loadTexture(c,d):void 0!==c&&e.loadTexture(c);var g=this.emitX,h=this.emitY;null!==a?g=a:1<this.width&&(g=f.between(this.left,this.right)),null!==b?h=b:1<this.height&&(h=f.between(this.top,this.bottom)),e.reset(g,h),e.angle=0,e.lifespan=this.lifespan,this.particleBringToTop?this.bringToTop(e):this.particleSendToBack&&this.sendToBack(e),this.autoScale?e.setScaleData(this.scaleData):1!==this.minParticleScale||1!==this.maxParticleScale?e.scale.set(f.realInRange(this.minParticleScale,this.maxParticleScale)):this._minParticleScale.x===this._maxParticleScale.x&&this._minParticleScale.y===this._maxParticleScale.y||e.scale.set(f.realInRange(this._minParticleScale.x,this._maxParticleScale.x),f.realInRange(this._minParticleScale.y,this._maxParticleScale.y)),void 0===d&&(Array.isArray(this._frames)?e.frame=this.game.rnd.pick(this._frames):e.frame=this._frames),this.autoAlpha?e.setAlphaData(this.alphaData):e.alpha=f.realInRange(this.minParticleAlpha,this.maxParticleAlpha),e.blendMode=this.blendMode;var i=e.body;return i.updateBounds(),i.bounce.copyFrom(this.bounce),i.drag.copyFrom(this.particleDrag),i.velocity.x=f.between(this.minParticleSpeed.x,this.maxParticleSpeed.x),i.velocity.y=f.between(this.minParticleSpeed.y,this.maxParticleSpeed.y),i.angularVelocity=f.between(this.minRotation,this.maxRotation),i.gravity.y=this.gravity,i.angularDrag=this.angularDrag,e.onEmit(),!0},c.Particles.Arcade.Emitter.prototype.destroy=function(){this.game.particles.remove(this),c.Group.prototype.destroy.call(this,!0,!1)},c.Particles.Arcade.Emitter.prototype.setSize=function(a,b){return this.area.width=a,this.area.height=b,this},c.Particles.Arcade.Emitter.prototype.setXSpeed=function(a,b){return a=a||0,b=b||0,this.minParticleSpeed.x=a,this.maxParticleSpeed.x=b,this},c.Particles.Arcade.Emitter.prototype.setYSpeed=function(a,b){return a=a||0,b=b||0,this.minParticleSpeed.y=a,this.maxParticleSpeed.y=b,this},c.Particles.Arcade.Emitter.prototype.setRotation=function(a,b){return a=a||0,b=b||0,this.minRotation=a,this.maxRotation=b,this},c.Particles.Arcade.Emitter.prototype.setAlpha=function(a,b,d,e,f){if(void 0===a&&(a=1),void 0===b&&(b=1),void 0===d&&(d=0),void 0===e&&(e=c.Easing.Linear.None),void 0===f&&(f=!1),this.minParticleAlpha=a,this.maxParticleAlpha=b,this.autoAlpha=!1,0<d&&a!==b){var g={v:a},h=this.game.make.tween(g).to({v:b},d,e);h.yoyo(f),this.alphaData=h.generateData(60),this.alphaData.reverse(),this.autoAlpha=!0}return this},c.Particles.Arcade.Emitter.prototype.setScale=function(a,b,d,e,f,g,h){if(void 0===a&&(a=1),void 0===b&&(b=1),void 0===d&&(d=1),void 0===e&&(e=1),void 0===f&&(f=0),void 0===g&&(g=c.Easing.Linear.None),void 0===h&&(h=!1),this.minParticleScale=1,this.maxParticleScale=1,this._minParticleScale.set(a,d),this._maxParticleScale.set(b,e),this.autoScale=!1,0<f&&(a!==b||d!==e)){var i={x:a,y:d},j=this.game.make.tween(i).to({x:b,y:e},f,g);j.yoyo(h),this.scaleData=j.generateData(60),this.scaleData.reverse(),this.autoScale=!0}return this},c.Particles.Arcade.Emitter.prototype.at=function(a){return a.center?(this.emitX=a.center.x,this.emitY=a.center.y):(this.emitX=a.world.x+a.anchor.x*a.width,this.emitY=a.world.y+a.anchor.y*a.height),this},Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"width",{get:function(){return this.area.width},set:function(a){this.area.width=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"height",{get:function(){return this.area.height},set:function(a){this.area.height=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"x",{get:function(){return this.emitX},set:function(a){this.emitX=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"y",{get:function(){return this.emitY},set:function(a){this.emitY=a}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"left",{get:function(){return Math.floor(this.x-this.area.width/2)}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"right",{get:function(){return Math.floor(this.x+this.area.width/2)}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"top",{get:function(){return Math.floor(this.y-this.area.height/2)}}),Object.defineProperty(c.Particles.Arcade.Emitter.prototype,"bottom",{get:function(){return Math.floor(this.y+this.area.height/2)}}),c.Weapon=function(a,b){c.Plugin.call(this,a,b),this.bullets=null,this.autoExpandBulletsGroup=!1,this.autofire=!1,this.shots=0,this.fireLimit=0,this.fireRate=100,this.fireRateVariance=0,this.fireFrom=new c.Rectangle(0,0,1,1),this.fireAngle=c.ANGLE_UP,this.bulletInheritSpriteSpeed=!1,this.bulletAnimation="",this.bulletFrameRandom=!1,this.bulletFrameCycle=!1,this.bulletWorldWrap=!1,this.bulletWorldWrapPadding=0,this.bulletAngleOffset=0,this.bulletAngleVariance=0,this.bulletSpeed=200,this.bulletSpeedVariance=0,this.bulletLifespan=0,this.bulletKillDistance=0,this.bulletGravity=new c.Point(0,0),this.bulletRotateToVelocity=!1,this.bulletKey="",this.bulletFrame="",this._bulletClass=c.Bullet,this._bulletCollideWorldBounds=!1,this._bulletKillType=c.Weapon.KILL_WORLD_BOUNDS,this._data={customBody:!1,width:0,height:0,offsetX:0,offsetY:0},this.bounds=new c.Rectangle,this.bulletBounds=a.world.bounds,this.bulletFrames=[],this.bulletFrameIndex=0,this.anims={},this.onFire=new c.Signal,this.onKill=new c.Signal,this.onFireLimit=new c.Signal,this.trackedSprite=null,this.trackedPointer=null,this.trackRotation=!1,this.trackOffset=new c.Point,this._nextFire=0,this._rotatedPoint=new c.Point},c.Weapon.prototype=Object.create(c.Plugin.prototype),c.Weapon.prototype.constructor=c.Weapon,c.Weapon.KILL_NEVER=0,c.Weapon.KILL_LIFESPAN=1,c.Weapon.KILL_DISTANCE=2,c.Weapon.KILL_WEAPON_BOUNDS=3,c.Weapon.KILL_CAMERA_BOUNDS=4,c.Weapon.KILL_WORLD_BOUNDS=5,c.Weapon.KILL_STATIC_BOUNDS=6,c.Weapon.prototype.createBullets=function(a,b,d,e){return void 0===a&&(a=1),void 0===e&&(e=this.game.world),this.bullets||(this.bullets=this.game.add.physicsGroup(c.Physics.ARCADE,e),this.bullets.classType=this._bulletClass),0!==a&&(-1===a&&(this.autoExpandBulletsGroup=!0,a=1),this.bullets.createMultiple(a,b,d),this.bullets.setAll("data.bulletManager",this),this.bulletKey=b,this.bulletFrame=d),this},c.Weapon.prototype.forEach=function(a,b){return this.bullets.forEachExists(a,b,arguments),this},c.Weapon.prototype.pauseAll=function(){return this.bullets.setAll("body.enable",!1),this},c.Weapon.prototype.resumeAll=function(){return this.bullets.setAll("body.enable",!0),this},c.Weapon.prototype.killAll=function(){return this.bullets.callAllExists("kill",!0),this.bullets.setAll("body.enable",!0),this},c.Weapon.prototype.resetShots=function(a){return void(this.shots=0)!==a&&(this.fireLimit=a),this},c.Weapon.prototype.destroy=function(){this.parent.remove(this,!1),this.bullets.destroy(),this.game=null,this.parent=null,this.active=!1,this.visible=!1},c.Weapon.prototype.update=function(){this._bulletKillType===c.Weapon.KILL_WEAPON_BOUNDS&&(this.trackedSprite?(this.trackedSprite.updateTransform(),this.bounds.centerOn(this.trackedSprite.worldPosition.x,this.trackedSprite.worldPosition.y)):this.trackedPointer&&this.bounds.centerOn(this.trackedPointer.worldX,this.trackedPointer.worldY)),this.autofire&&this.fire()},c.Weapon.prototype.trackSprite=function(a,b,c,d){return void 0===b&&(b=0),void 0===c&&(c=0),void 0===d&&(d=!1),this.trackedPointer=null,this.trackedSprite=a,this.trackRotation=d,this.trackOffset.set(b,c),this},c.Weapon.prototype.trackPointer=function(a,b,c){return void 0===a&&(a=this.game.input.activePointer),void 0===b&&(b=0),void 0===c&&(c=0),this.trackedPointer=a,this.trackedSprite=null,this.trackRotation=!1,this.trackOffset.set(b,c),this},c.Weapon.prototype.fire=function(a,b,d){if(this.game.time.now<this._nextFire||0<this.fireLimit&&this.shots===this.fireLimit)return!1;var e=this.bulletSpeed;0!==this.bulletSpeedVariance&&(e+=c.Math.between(-this.bulletSpeedVariance,this.bulletSpeedVariance)),a?1<this.fireFrom.width?this.fireFrom.centerOn(a.x,a.y):(this.fireFrom.x=a.x,this.fireFrom.y=a.y):this.trackedSprite?(this.trackRotation?(this._rotatedPoint.set(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y),this._rotatedPoint.rotate(this.trackedSprite.world.x,this.trackedSprite.world.y,this.trackedSprite.rotation),1<this.fireFrom.width?this.fireFrom.centerOn(this._rotatedPoint.x,this._rotatedPoint.y):(this.fireFrom.x=this._rotatedPoint.x,this.fireFrom.y=this._rotatedPoint.y)):1<this.fireFrom.width?this.fireFrom.centerOn(this.trackedSprite.world.x+this.trackOffset.x,this.trackedSprite.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedSprite.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedSprite.world.y+this.trackOffset.y),this.bulletInheritSpriteSpeed&&(e+=this.trackedSprite.body.speed)):this.trackedPointer&&(1<this.fireFrom.width?this.fireFrom.centerOn(this.trackedPointer.world.x+this.trackOffset.x,this.trackedPointer.world.y+this.trackOffset.y):(this.fireFrom.x=this.trackedPointer.world.x+this.trackOffset.x,this.fireFrom.y=this.trackedPointer.world.y+this.trackOffset.y));var f=1<this.fireFrom.width?this.fireFrom.randomX:this.fireFrom.x,g=1<this.fireFrom.height?this.fireFrom.randomY:this.fireFrom.y,h=this.trackRotation?this.trackedSprite.angle:this.fireAngle;void 0!==b&&void 0!==d&&(h=this.game.math.radToDeg(Math.atan2(d-g,b-f))),0!==this.bulletAngleVariance&&(h+=c.Math.between(-this.bulletAngleVariance,this.bulletAngleVariance));var i=0,j=0;0===h||180===h?i=Math.cos(this.game.math.degToRad(h))*e:j=(90===h||270===h||(i=Math.cos(this.game.math.degToRad(h))*e),Math.sin(this.game.math.degToRad(h))*e);var k=null;if(this.autoExpandBulletsGroup?(k=this.bullets.getFirstExists(!1,!0,f,g,this.bulletKey,this.bulletFrame)).data.bulletManager=this:k=this.bullets.getFirstExists(!1),k){if(k.reset(f,g),k.data.fromX=f,k.data.fromY=g,k.data.killType=this.bulletKillType,k.data.killDistance=this.bulletKillDistance,k.data.rotateToVelocity=this.bulletRotateToVelocity,this.bulletKillType===c.Weapon.KILL_LIFESPAN&&(k.lifespan=this.bulletLifespan),k.angle=h+this.bulletAngleOffset,""!==this.bulletAnimation){if(null===k.animations.getAnimation(this.bulletAnimation)){var l=this.anims[this.bulletAnimation];k.animations.add(l.name,l.frames,l.frameRate,l.loop,l.useNumericIndex)}k.animations.play(this.bulletAnimation)}else this.bulletFrameCycle?(k.frame=this.bulletFrames[this.bulletFrameIndex],++this.bulletFrameIndex>=this.bulletFrames.length&&(this.bulletFrameIndex=0)):this.bulletFrameRandom&&(k.frame=this.bulletFrames[Math.floor(Math.random()*this.bulletFrames.length)]);if(k.data.bodyDirty&&(this._data.customBody&&k.body.setSize(this._data.width,this._data.height,this._data.offsetX,this._data.offsetY),k.body.collideWorldBounds=this.bulletCollideWorldBounds,k.data.bodyDirty=!1),k.body.velocity.set(i,j),k.body.gravity.set(this.bulletGravity.x,this.bulletGravity.y),0!==this.bulletSpeedVariance){var m=this.fireRate;(m+=c.Math.between(-this.fireRateVariance,this.fireRateVariance))<0&&(m=0),this._nextFire=this.game.time.now+m}else this._nextFire=this.game.time.now+this.fireRate;this.shots++,this.onFire.dispatch(k,this,e),0<this.fireLimit&&this.shots===this.fireLimit&&this.onFireLimit.dispatch(this,this.fireLimit)}return k},c.Weapon.prototype.fireAtPointer=function(a){return void 0===a&&(a=this.game.input.activePointer),this.fire(null,a.worldX,a.worldY)},c.Weapon.prototype.fireAtSprite=function(a){return this.fire(null,a.world.x,a.world.y)},c.Weapon.prototype.fireAtXY=function(a,b){return this.fire(null,a,b)},c.Weapon.prototype.setBulletBodyOffset=function(a,b,c,d){return void 0===c&&(c=0),void 0===d&&(d=0),this._data.customBody=!0,this._data.width=a,this._data.height=b,this._data.offsetX=c,this._data.offsetY=d,this.bullets.callAll("body.setSize","body",a,b,c,d),this.bullets.setAll("data.bodyDirty",!1),this},c.Weapon.prototype.setBulletFrames=function(a,b,d,e){return void 0===d&&(d=!0),void 0===e&&(e=!1),this.bulletFrames=c.ArrayUtils.numberArray(a,b),this.bulletFrameIndex=0,this.bulletFrameCycle=d,this.bulletFrameRandom=e,this},c.Weapon.prototype.addBulletAnimation=function(a,b,c,d,e){return this.anims[a]={name:a,frames:b,frameRate:c,loop:d,useNumericIndex:e},this.bullets.callAll("animations.add","animations",a,b,c,d,e),this.bulletAnimation=a,this},c.Weapon.prototype.debug=function(a,b,c){void 0===a&&(a=16),void 0===b&&(b=32),void 0===c&&(c=!1),this.game.debug.text("Weapon Plugin",a,b),this.game.debug.text("Bullets Alive: "+this.bullets.total+" - Total: "+this.bullets.length,a,b+24),c&&this.bullets.forEachExists(this.game.debug.body,this.game.debug,"rgba(255, 0, 255, 0.8)")},Object.defineProperty(c.Weapon.prototype,"bulletClass",{get:function(){return this._bulletClass},set:function(a){this._bulletClass=a,this.bullets.classType=this._bulletClass}}),Object.defineProperty(c.Weapon.prototype,"bulletKillType",{get:function(){return this._bulletKillType},set:function(a){switch(a){case c.Weapon.KILL_STATIC_BOUNDS:case c.Weapon.KILL_WEAPON_BOUNDS:this.bulletBounds=this.bounds;break;case c.Weapon.KILL_CAMERA_BOUNDS:this.bulletBounds=this.game.camera.view;break;case c.Weapon.KILL_WORLD_BOUNDS:this.bulletBounds=this.game.world.bounds}this._bulletKillType=a}}),Object.defineProperty(c.Weapon.prototype,"bulletCollideWorldBounds",{get:function(){return this._bulletCollideWorldBounds},set:function(a){this._bulletCollideWorldBounds=a,this.bullets.setAll("body.collideWorldBounds",a),this.bullets.setAll("data.bodyDirty",!1)}}),Object.defineProperty(c.Weapon.prototype,"x",{get:function(){return this.fireFrom.x},set:function(a){this.fireFrom.x=a}}),Object.defineProperty(c.Weapon.prototype,"y",{get:function(){return this.fireFrom.y},set:function(a){this.fireFrom.y=a}}),c.Bullet=function(a,b,d,e,f){c.Sprite.call(this,a,b,d,e,f),this.anchor.set(.5),this.data={bulletManager:null,fromX:0,fromY:0,bodyDirty:!0,rotateToVelocity:!1,killType:0,killDistance:0}},c.Bullet.prototype=Object.create(c.Sprite.prototype),c.Bullet.prototype.constructor=c.Bullet,c.Bullet.prototype.kill=function(){return this.alive=!1,this.exists=!1,this.visible=!1,this.data.bulletManager.onKill.dispatch(this),this},c.Bullet.prototype.update=function(){this.exists&&(this.data.killType>c.Weapon.KILL_LIFESPAN&&(this.data.killType===c.Weapon.KILL_DISTANCE?this.game.physics.arcade.distanceToXY(this,this.data.fromX,this.data.fromY,!0)>this.data.killDistance&&this.kill():this.data.bulletManager.bulletBounds.intersects(this)||this.kill()),this.data.rotateToVelocity&&(this.rotation=Math.atan2(this.body.velocity.y,this.body.velocity.x)),this.data.bulletManager.bulletWorldWrap&&this.game.world.wrap(this,this.data.bulletManager.bulletWorldWrapPadding))},c.Video=function(a,b,d){if(void 0===b&&(b=null),void 0===d&&(d=null),this.game=a,this.key=b,this.width=0,this.height=0,this.type=c.VIDEO,this.disableTextureUpload=!1,this.touchLocked=!1,this.onPlay=new c.Signal,this.onChangeSource=new c.Signal,this.onComplete=new c.Signal,this.onAccess=new c.Signal,this.onError=new c.Signal,this.onTimeout=new c.Signal,this.timeout=15e3,this._timeOutID=null,this.video=null,this.videoStream=null,this.isStreaming=!1,this.retryLimit=20,this.retry=0,this.retryInterval=500,this._retryID=null,this._codeMuted=!1,this._muted=!1,this._codePaused=!1,this._paused=!1,this._pending=!1,this._autoplay=!1,this._endCallback=null,this._playCallback=null,b&&this.game.cache.checkVideoKey(b)){var e=this.game.cache.getVideo(b);e.isBlob?this.createVideoFromBlob(e.data):this.video=e.data,this.width=this.video.videoWidth,this.height=this.video.videoHeight}else d&&this.createVideoFromURL(d,!1);this.video&&!d?this.baseTexture=new PIXI.BaseTexture(this.video):this.baseTexture=new PIXI.BaseTexture(c.Cache.DEFAULT.baseTexture.source),this.baseTexture.forceLoaded(this.width,this.height),this.texture=new PIXI.Texture(this.baseTexture),this.textureFrame=new c.Frame(0,0,0,this.width,this.height,"video"),this.texture.setFrame(this.textureFrame),this.texture.valid=!1,null!==b&&this.video&&(this.texture.valid=this.video.canplay),this.snapshot=null,c.BitmapData&&(this.snapshot=new c.BitmapData(this.game,"",this.width,this.height)),!this.game.device.cocoonJS&&(this.game.device.iOS||this.game.device.chrome)||window.PhaserGlobal&&window.PhaserGlobal.fakeiOSTouchLock?this.setTouchLock():e&&(e.locked=!1)},c.Video.prototype={connectToMediaStream:function(a,b){return a&&b&&(this.video=a,this.videoStream=b,this.isStreaming=!0,this.baseTexture.source=this.video,this.updateTexture(null,this.video.videoWidth,this.video.videoHeight),this.onAccess.dispatch(this)),this},startMediaStream:function(a,b,c){if(void 0===a&&(a=!1),void 0===b&&(b=null),void 0===c&&(c=null),!this.game.device.getUserMedia)return this.onError.dispatch(this,"No getUserMedia"),!1;null!==this.videoStream&&(this.videoStream.active?this.videoStream.active=!1:this.videoStream.stop()),this.removeVideoElement(),this.video=document.createElement("video"),this.video.setAttribute("autoplay","autoplay"),null!==b&&(this.video.width=b),null!==c&&(this.video.height=c),this._timeOutID=window.setTimeout(this.getUserMediaTimeout.bind(this),this.timeout);try{navigator.getUserMedia({audio:a,video:!0},this.getUserMediaSuccess.bind(this),this.getUserMediaError.bind(this))}catch(a){this.getUserMediaError(a)}return this},getUserMediaTimeout:function(){clearTimeout(this._timeOutID),this.onTimeout.dispatch(this)},getUserMediaError:function(a){clearTimeout(this._timeOutID),this.onError.dispatch(this,a)},getUserMediaSuccess:function(a){clearTimeout(this._timeOutID),this.videoStream=a,void 0!==this.video.mozSrcObject?this.video.mozSrcObject=a:this.video.src=window.URL&&window.URL.createObjectURL(a)||a;var b=this;this.video.onloadeddata=function(){var c=10;!function a(){if(0<c)if(0<b.video.videoWidth){var d=b.video.videoWidth,e=b.video.videoHeight;isNaN(b.video.videoHeight)&&(e=d/(4/3)),b.video.play(),b.isStreaming=!0,b.baseTexture.source=b.video,b.updateTexture(null,d,e),b.onAccess.dispatch(b)}else window.setTimeout(a,500);c--}()}},createVideoFromBlob:function(a){var b=this;return this.video=document.createElement("video"),this.video.controls=!1,this.video.setAttribute("autoplay","autoplay"),this.video.addEventListener("loadeddata",function(a){b.updateTexture(a)},!0),this.video.src=window.URL.createObjectURL(a),this.video.canplay=!0,this},createVideoFromURL:function(a,b){return void 0===b&&(b=!1),this.texture&&(this.texture.valid=!1),this.video=document.createElement("video"),this.video.controls=!1,b&&this.video.setAttribute("autoplay","autoplay"),this.video.src=a,this.video.canplay=!0,this.video.load(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.key=a,this},updateTexture:function(a,b,c){var d=!1;null!=b||(b=this.video.videoWidth,d=!0),null!=c||(c=this.video.videoHeight),this.width=b,this.height=c,this.baseTexture.source!==this.video&&(this.baseTexture.source=this.video),this.baseTexture.forceLoaded(b,c),this.texture.frame.resize(b,c),this.texture.width=b,this.texture.height=c,this.texture.valid=!0,this.snapshot&&this.snapshot.resize(b,c),d&&null!==this.key&&(this.onChangeSource.dispatch(this,b,c),this._autoplay&&(this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate)))},complete:function(){this.onComplete.dispatch(this)},play:function(a,b){return void 0===a&&(a=!1),void 0===b&&(b=1),this.game.sound.onMute&&(this.game.sound.onMute.add(this.setMute,this),this.game.sound.onUnMute.add(this.unsetMute,this),this.game.sound.mute&&this.setMute()),this.game.onPause.add(this.setPause,this),this.game.onResume.add(this.setResume,this),this._endCallback=this.complete.bind(this),this.video.addEventListener("ended",this._endCallback,!0),this.video.addEventListener("webkitendfullscreen",this._endCallback,!0),this.video.loop=a?"loop":"",this.video.playbackRate=b,this.touchLocked?this._pending=!0:(this._pending=!1,null!==this.key&&(4!==this.video.readyState?(this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)):(this._playCallback=this.playHandler.bind(this),this.video.addEventListener("playing",this._playCallback,!0))),this.video.play(),this.onPlay.dispatch(this,a,b)),this},playHandler:function(){this.video.removeEventListener("playing",this._playCallback,!0),this.updateTexture()},stop:function(){return this.game.sound.onMute&&(this.game.sound.onMute.remove(this.setMute,this),this.game.sound.onUnMute.remove(this.unsetMute,this)),this.game.onPause.remove(this.setPause,this),this.game.onResume.remove(this.setResume,this),this.isStreaming?(this.video.mozSrcObject?(this.video.mozSrcObject.stop(),this.video.src=null):(this.video.src="",this.videoStream.active?this.videoStream.active=!1:this.videoStream.getTracks?this.videoStream.getTracks().forEach(function(a){a.stop()}):this.videoStream.stop()),this.videoStream=null,this.isStreaming=!1):(this.video.removeEventListener("ended",this._endCallback,!0),this.video.removeEventListener("webkitendfullscreen",this._endCallback,!0),this.video.removeEventListener("playing",this._playCallback,!0),this.touchLocked?this._pending=!1:this.video.pause()),this},add:function(a){if(Array.isArray(a))for(var b=0;b<a.length;b++)a[b].loadTexture&&a[b].loadTexture(this);else a.loadTexture(this);return this},addToWorld:function(a,b,c,d,e,f){e=e||1,f=f||1;var g=this.game.add.image(a,b,this);return g.anchor.set(c,d),g.scale.set(e,f),g},render:function(){!this.disableTextureUpload&&this.playing&&this.baseTexture.dirty()},setMute:function(){this._muted||(this._muted=!0,this.video.muted=!0)},unsetMute:function(){this._muted&&!this._codeMuted&&(this._muted=!1,this.video.muted=!1)},setPause:function(){this._paused||this.touchLocked||(this._paused=!0,this.video.pause())},setResume:function(){!this._paused||this._codePaused||this.touchLocked||(this._paused=!1,this.video.ended||this.video.play())},changeSource:function(a,b){return void 0===b&&(b=!0),this.texture.valid=!1,this.video.pause(),this.retry=this.retryLimit,this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval),this.video.src=a,this.video.load(),(this._autoplay=b)||(this.paused=!0),this},checkVideoProgress:function(){4===this.video.readyState?this.updateTexture():(this.retry--,0<this.retry&&(this._retryID=window.setTimeout(this.checkVideoProgress.bind(this),this.retryInterval)))},setTouchLock:function(){this.game.input.touch.addTouchLockCallback(this.unlock,this),this.touchLocked=!0},unlock:function(){if(this.touchLocked=!1,this.video.play(),this.onPlay.dispatch(this,this.loop,this.playbackRate),this.key){var a=this.game.cache.getVideo(this.key);a&&!a.isBlob&&(a.locked=!1)}return!0},grab:function(a,b,c){return void 0===a&&(a=!1),void 0===b&&(b=1),void 0===c&&(c=null),null===this.snapshot?void 0:(a&&this.snapshot.cls(),this.snapshot.copy(this.video,0,0,this.width,this.height,0,0,this.width,this.height,0,0,0,1,1,b,c),this.snapshot)},removeVideoElement:function(){if(this.video){for(this.video.parentNode&&this.video.parentNode.removeChild(this.video);this.video.hasChildNodes();)this.video.removeChild(this.video.firstChild);this.video.removeAttribute("autoplay"),this.video.removeAttribute("src"),this.video=null}},destroy:function(){this.stop(),this.removeVideoElement(),this.touchLocked&&this.game.input.touch.removeTouchLockCallback(this.unlock,this),this._retryID&&window.clearTimeout(this._retryID)}},Object.defineProperty(c.Video.prototype,"currentTime",{get:function(){return this.video?this.video.currentTime:0},set:function(a){this.video.currentTime=a}}),Object.defineProperty(c.Video.prototype,"duration",{get:function(){return this.video?this.video.duration:0}}),Object.defineProperty(c.Video.prototype,"progress",{get:function(){return this.video?this.video.currentTime/this.video.duration:0}}),Object.defineProperty(c.Video.prototype,"mute",{get:function(){return this._muted},set:function(a){if(a=a||null){if(this._muted)return;this._codeMuted=!0,this.setMute()}else{if(!this._muted)return;this._codeMuted=!1,this.unsetMute()}}}),Object.defineProperty(c.Video.prototype,"paused",{get:function(){return this._paused},set:function(a){if(a=a||null,!this.touchLocked)if(a){if(this._paused)return;this._codePaused=!0,this.setPause()}else{if(!this._paused)return;this._codePaused=!1,this.setResume()}}}),Object.defineProperty(c.Video.prototype,"volume",{get:function(){return this.video?this.video.volume:1},set:function(a){a<0?a=0:1<a&&(a=1),this.video&&(this.video.volume=a)}}),Object.defineProperty(c.Video.prototype,"playbackRate",{get:function(){return this.video?this.video.playbackRate:1},set:function(a){this.video&&(this.video.playbackRate=a)}}),Object.defineProperty(c.Video.prototype,"loop",{get:function(){return!!this.video&&this.video.loop},set:function(a){a&&this.video?this.video.loop="loop":this.video&&(this.video.loop="")}}),Object.defineProperty(c.Video.prototype,"playing",{get:function(){return!(this.video.paused&&this.video.ended)}}),c.Video.prototype.constructor=c.Video,void 0===PIXI.blendModes&&(PIXI.blendModes=c.blendModes),void 0===PIXI.scaleModes&&(PIXI.scaleModes=c.scaleModes),void 0===PIXI.Texture.emptyTexture&&(PIXI.Texture.emptyTexture=new PIXI.Texture(new PIXI.BaseTexture)),void 0===PIXI.DisplayObject._tempMatrix&&(PIXI.DisplayObject._tempMatrix=new PIXI.Matrix),void 0===PIXI.RenderTexture.tempMatrix&&(PIXI.RenderTexture.tempMatrix=new PIXI.Matrix),PIXI.Graphics&&void 0===PIXI.Graphics.POLY&&(PIXI.Graphics.POLY=c.POLYGON,PIXI.Graphics.RECT=c.RECTANGLE,PIXI.Graphics.CIRC=c.CIRCLE,PIXI.Graphics.ELIP=c.ELLIPSE,PIXI.Graphics.RREC=c.ROUNDEDRECTANGLE),PIXI.TextureSilentFail=!0,"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=c),exports.Phaser=c):"undefined"!=typeof define&&define.amd?define("Phaser",b.Phaser=c):b.Phaser=c,c}.call(this),function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.i18next=b()}(this,function(){"use strict";function a(a){return null==a?"":""+a}function c(a,b,c){function d(a){return a&&-1<a.indexOf("###")?a.replace(/###/g,"."):a}function e(){return!a||"string"==typeof a}for(var f="string"!=typeof b?[].concat(b):b.split(".");1<f.length;){if(e())return{};var g=d(f.shift());!a[g]&&c&&(a[g]=new c),a=a[g]}return e()?{}:{obj:a,k:d(f.shift())}}function d(a,b,d){var e=c(a,b,Object);e.obj[e.k]=d}function e(a,b,d,e){var f=c(a,b,Object),g=f.obj,h=f.k;g[h]=g[h]||[],e&&(g[h]=g[h].concat(d)),e||g[h].push(d)}function f(a,b){var d=c(a,b),e=d.obj,f=d.k;if(e)return e[f]}function h(a){return a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}function i(a){return"string"==typeof a?a.replace(/[&<>"'\/]/g,function(a){return F[a]}):a}function j(a){return a.interpolation={unescapeSuffix:"HTML"},a.interpolation.prefix=a.interpolationPrefix||"__",a.interpolation.suffix=a.interpolationSuffix||"__",a.interpolation.escapeValue=a.escapeInterpolation||!1,a.interpolation.nestingPrefix=a.reusePrefix||"$t(",a.interpolation.nestingSuffix=a.reuseSuffix||")",a}function m(a){return(a.interpolationPrefix||a.interpolationSuffix||void 0!==a.escapeInterpolation)&&(a=j(a)),a.nsSeparator=a.nsseparator,a.keySeparator=a.keyseparator,a.returnObjects=a.returnObjectTrees,a}function o(a){return a.charAt(0).toUpperCase()+a.slice(1)}function s(a){return"string"==typeof a.ns&&(a.ns=[a.ns]),"string"==typeof a.fallbackLng&&(a.fallbackLng=[a.fallbackLng]),"string"==typeof a.fallbackNS&&(a.fallbackNS=[a.fallbackNS]),a.whitelist&&a.whitelist.indexOf("cimode")<0&&a.whitelist.push("cimode"),a}function t(){}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},v=function(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")},w=Object.assign||function(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)Object.prototype.hasOwnProperty.call(c,d)&&(a[d]=c[d])}return a},x=function(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}),b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)},y=function(a,b){if(!a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!b||"object"!=typeof b&&"function"!=typeof b?a:b},z=function(b,c){if(Array.isArray(b))return b;if(Symbol.iterator in Object(b))return function(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&h.return&&h.return()}finally{if(e)throw f}}return c}(b,c);throw new TypeError("Invalid attempt to destructure non-iterable instance")},B={type:"logger",log:function(a){this.output("log",a)},warn:function(a){this.output("warn",a)},error:function(a){this.output("error",a)},output:function(a,b){var c;console&&console[a]&&(c=console)[a].apply(c,function(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}return Array.from(a)}(b))}},D=new(function(){function a(b){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};v(this,a),this.init(b,c)}return a.prototype.init=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};this.prefix=b.prefix||"i18next:",this.logger=a||B,this.options=b,this.debug=b.debug},a.prototype.setDebug=function(a){this.debug=a},a.prototype.log=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return this.forward(b,"log","",!0)},a.prototype.warn=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return this.forward(b,"warn","",!0)},a.prototype.error=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return this.forward(b,"error","")},a.prototype.deprecate=function(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];return this.forward(b,"warn","WARNING DEPRECATED: ",!0)},a.prototype.forward=function(a,b,c,d){return d&&!this.debug?null:("string"==typeof a[0]&&(a[0]=""+c+this.prefix+" "+a[0]),this.logger[b](a))},a.prototype.create=function(b){return new a(this.logger,w({prefix:this.prefix+":"+b+":"},this.options))},a}()),E=function(){function a(){v(this,a),this.observers={}}return a.prototype.on=function(a,b){var c=this;a.split(" ").forEach(function(a){c.observers[a]=c.observers[a]||[],c.observers[a].push(b)})},a.prototype.off=function(a,b){var c=this;this.observers[a]&&this.observers[a].forEach(function(){if(b){var d=c.observers[a].indexOf(b);-1<d&&c.observers[a].splice(d,1)}else delete c.observers[a]})},a.prototype.emit=function(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];this.observers[a]&&[].concat(this.observers[a]).forEach(function(a){a.apply(void 0,c)});this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(b){var d;b.apply(b,(d=[a]).concat.apply(d,c))})},a}(),F={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"},G=function(a){function b(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};v(this,b);var e=y(this,a.call(this));return e.data=c,e.options=d,e}return x(b,a),b.prototype.addNamespaces=function(a){this.options.ns.indexOf(a)<0&&this.options.ns.push(a)},b.prototype.removeNamespaces=function(a){var b=this.options.ns.indexOf(a);-1<b&&this.options.ns.splice(b,1)},b.prototype.getResource=function(a,b,c){var e=(3<arguments.length&&void 0!==arguments[3]?arguments[3]:{}).keySeparator||this.options.keySeparator;void 0===e&&(e=".");var g=[a,b];return c&&"string"!=typeof c&&(g=g.concat(c)),c&&"string"==typeof c&&(g=g.concat(e?c.split(e):c)),-1<a.indexOf(".")&&(g=a.split(".")),f(this.data,g)},b.prototype.addResource=function(a,b,c,e){var f=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{silent:!1},g=this.options.keySeparator;void 0===g&&(g=".");var h=[a,b];c&&(h=h.concat(g?c.split(g):c)),-1<a.indexOf(".")&&(e=b,b=(h=a.split("."))[1]),this.addNamespaces(b),d(this.data,h,e),f.silent||this.emit("added",a,b,c,e)},b.prototype.addResources=function(a,b,c){for(var d in c)"string"==typeof c[d]&&this.addResource(a,b,d,c[d],{silent:!0});this.emit("added",a,b,c)},b.prototype.addResourceBundle=function(a,b,c,e,h){var i=[a,b];-1<a.indexOf(".")&&(e=c,c=b,b=(i=a.split("."))[1]),this.addNamespaces(b);var j=f(this.data,i)||{};e?function g(a,b,c){for(var d in b)d in a?"string"==typeof a[d]||a[d]instanceof String||"string"==typeof b[d]||b[d]instanceof String?c&&(a[d]=b[d]):g(a[d],b[d],c):a[d]=b[d];return a}(j,c,h):j=w({},j,c),d(this.data,i,j),this.emit("added",a,b,c)},b.prototype.removeResourceBundle=function(a,b){this.hasResourceBundle(a,b)&&delete this.data[a][b],this.removeNamespaces(b),this.emit("removed",a,b)},b.prototype.hasResourceBundle=function(a,b){return void 0!==this.getResource(a,b)},b.prototype.getResourceBundle=function(a,b){return b||(b=this.options.defaultNS),"v1"===this.options.compatibilityAPI?w({},this.getResource(a,b)):this.getResource(a,b)},b.prototype.toJSON=function(){return this.data},b}(E),H={processors:{},addPostProcessor:function(a){this.processors[a.name]=a},handle:function(a,b,c,d,e){var f=this;return a.forEach(function(a){f.processors[a]&&(b=f.processors[a].process(b,c,d,e))}),b}},I=function(a){function c(d){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};v(this,c);var f=y(this,a.call(this));return function(a,b,c){a.forEach(function(a){b[a]&&(c[a]=b[a])})}(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector"],d,f),f.options=e,f.logger=D.create("translator"),f}return x(c,a),c.prototype.changeLanguage=function(a){a&&(this.language=a)},c.prototype.exists=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};return"v1"===this.options.compatibilityAPI&&(b=m(b)),void 0!==this.resolve(a,b)},c.prototype.extractFromKey=function(a,b){var c=b.nsSeparator||this.options.nsSeparator;void 0===c&&(c=":");var d=b.keySeparator||this.options.keySeparator||".",e=b.ns||this.options.defaultNS;if(c&&-1<a.indexOf(c)){var f=a.split(c);(c!==d||c===d&&-1<this.options.ns.indexOf(f[0]))&&(e=f.shift()),a=f.join(d)}return"string"==typeof e&&(e=[e]),{key:a,namespaces:e}},c.prototype.translate=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};if("object"!==(void 0===b?"undefined":u(b))?b=this.options.overloadTranslationOptionHandler(arguments):"v1"===this.options.compatibilityAPI&&(b=m(b)),null==a||""===a)return"";"number"==typeof a&&(a=String(a)),"string"==typeof a&&(a=[a]);var c=b.keySeparator||this.options.keySeparator||".",d=this.extractFromKey(a[a.length-1],b),e=d.key,f=d.namespaces,g=f[f.length-1],h=b.lng||this.language,i=b.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h&&"cimode"===h.toLowerCase())return i?g+(b.nsSeparator||this.options.nsSeparator)+e:e;var k=this.resolve(a,b),l=Object.prototype.toString.apply(k),o=void 0!==b.joinArrays?b.joinArrays:this.options.joinArrays;if(k&&"string"!=typeof k&&["[object Number]","[object Function]","[object RegExp]"].indexOf(l)<0&&(!o||"[object Array]"!==l)){if(!b.returnObjects&&!this.options.returnObjects)return this.logger.warn("accessing an object - but returnObjects options is not enabled!"),this.options.returnedObjectHandler?this.options.returnedObjectHandler(e,k,b):"key '"+e+" ("+this.language+")' returned an object instead of string.";if(b.keySeparator||this.options.keySeparator){var p="[object Array]"===l?[]:{};for(var q in k)Object.prototype.hasOwnProperty.call(k,q)&&(p[q]=this.translate(""+e+c+q,w({},b,{joinArrays:!1,ns:f})));k=p}}else if(o&&"[object Array]"===l)(k=k.join(o))&&(k=this.extendTranslation(k,e,b));else{var r=!1,s=!1;if(this.isValidLookup(k)||void 0===b.defaultValue||(r=!0,k=b.defaultValue),this.isValidLookup(k)||(s=!0,k=e),s||r){this.logger.log("missingKey",h,g,e,k);var t=[],v=this.languageUtils.getFallbackCodes(this.options.fallbackLng,b.lng||this.language);if("fallback"===this.options.saveMissingTo&&v&&v[0])for(var x=0;x<v.length;x++)t.push(v[x]);else"all"===this.options.saveMissingTo?t=this.languageUtils.toResolveHierarchy(b.lng||this.language):t.push(b.lng||this.language);this.options.saveMissing&&(this.options.missingKeyHandler?this.options.missingKeyHandler(t,g,e,k):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(t,g,e,k)),this.emit("missingKey",t,g,e,k)}k=this.extendTranslation(k,e,b),s&&k===e&&this.options.appendNamespaceToMissingKey&&(k=g+":"+e),s&&this.options.parseMissingKeyHandler&&(k=this.options.parseMissingKeyHandler(k))}return k},c.prototype.extendTranslation=function(a,b,c){var d=this;c.interpolation&&this.interpolator.init(w({},c,{interpolation:w({},this.options.interpolation,c.interpolation)}));var e=c.replace&&"string"!=typeof c.replace?c.replace:c;this.options.interpolation.defaultVariables&&(e=w({},this.options.interpolation.defaultVariables,e)),a=this.interpolator.interpolate(a,e,c.lng||this.language),!1!==c.nest&&(a=this.interpolator.nest(a,function(){return d.translate.apply(d,arguments)},c)),c.interpolation&&this.interpolator.reset();var f=c.postProcess||this.options.postProcess,g="string"==typeof f?[f]:f;return void 0!==a&&g&&g.length&&!1!==c.applyPostProcessor&&(a=H.handle(g,a,b,c,this)),a},c.prototype.resolve=function(a){var b=this,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},d=void 0;return"string"==typeof a&&(a=[a]),a.forEach(function(a){if(!b.isValidLookup(d)){var e=b.extractFromKey(a,c),f=e.key,g=e.namespaces;b.options.fallbackNS&&(g=g.concat(b.options.fallbackNS));var h=void 0!==c.count&&"string"!=typeof c.count,i=void 0!==c.context&&"string"==typeof c.context&&""!==c.context,j=c.lngs?c.lngs:b.languageUtils.toResolveHierarchy(c.lng||b.language);g.forEach(function(a){b.isValidLookup(d)||j.forEach(function(e){if(!b.isValidLookup(d)){var g=f,j=[g],k=void 0;h&&(k=b.pluralResolver.getSuffix(e,c.count)),h&&i&&j.push(g+k),i&&j.push(g+=""+b.options.contextSeparator+c.context),h&&j.push(g+=k);for(var l=void 0;l=j.pop();)b.isValidLookup(d)||(d=b.getResource(e,a,l,c))}})})}}),d},c.prototype.isValidLookup=function(a){return!(void 0===a||!this.options.returnNull&&null===a||!this.options.returnEmptyString&&""===a)},c.prototype.getResource=function(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};return this.resourceStore.getResource(a,b,c,d)},c}(E),J=function(){function a(b){v(this,a),this.options=b,this.whitelist=this.options.whitelist||!1,this.logger=D.create("languageUtils")}return a.prototype.getScriptPartFromCode=function(a){if(!a||a.indexOf("-")<0)return null;var b=a.split("-");return 2===b.length?null:(b.pop(),this.formatLanguageCode(b.join("-")))},a.prototype.getLanguagePartFromCode=function(a){if(!a||a.indexOf("-")<0)return a;var b=a.split("-");return this.formatLanguageCode(b[0])},a.prototype.formatLanguageCode=function(a){if("string"==typeof a&&-1<a.indexOf("-")){var b=["hans","hant","latn","cyrl","cans","mong","arab"],c=a.split("-");return this.options.lowerCaseLng?c=c.map(function(a){return a.toLowerCase()}):2===c.length?(c[0]=c[0].toLowerCase(),c[1]=c[1].toUpperCase(),-1<b.indexOf(c[1].toLowerCase())&&(c[1]=o(c[1].toLowerCase()))):3===c.length&&(c[0]=c[0].toLowerCase(),2===c[1].length&&(c[1]=c[1].toUpperCase()),"sgn"!==c[0]&&2===c[2].length&&(c[2]=c[2].toUpperCase()),-1<b.indexOf(c[1].toLowerCase())&&(c[1]=o(c[1].toLowerCase())),-1<b.indexOf(c[2].toLowerCase())&&(c[2]=o(c[2].toLowerCase()))),c.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?a.toLowerCase():a},a.prototype.isWhitelisted=function(a){return("languageOnly"===this.options.load||this.options.nonExplicitWhitelist)&&(a=this.getLanguagePartFromCode(a)),!this.whitelist||!this.whitelist.length||-1<this.whitelist.indexOf(a)},a.prototype.getFallbackCodes=function(a,b){if(!a)return[];if("string"==typeof a&&(a=[a]),"[object Array]"===Object.prototype.toString.apply(a))return a;if(!b)return a.default||[];var c=a[b];return c||(c=a[this.getScriptPartFromCode(b)]),c||(c=a[this.formatLanguageCode(b)]),c||(c=a.default),c||[]},a.prototype.toResolveHierarchy=function(a,b){var c=this,d=this.getFallbackCodes(b||this.options.fallbackLng||[],a),e=[],f=function(a){a&&(c.isWhitelisted(a)?e.push(a):c.logger.warn("rejecting non-whitelisted language code: "+a))};return"string"==typeof a&&-1<a.indexOf("-")?("languageOnly"!==this.options.load&&f(this.formatLanguageCode(a)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&f(this.getScriptPartFromCode(a)),"currentOnly"!==this.options.load&&f(this.getLanguagePartFromCode(a))):"string"==typeof a&&f(this.formatLanguageCode(a)),d.forEach(function(a){e.indexOf(a)<0&&f(c.formatLanguageCode(a))}),e},a}(),K=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","tg","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","es_ar","et","eu","fi","fo","fur","fy","gl","gu","ha","he","hi","hu","hy","ia","it","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt","pt_br","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","id","ja","jbo","ka","kk","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21}],L={1:function(a){return Number(1<a)},2:function(a){return Number(1!=a)},3:function(a){return 0},4:function(a){return Number(a%10==1&&a%100!=11?0:2<=a%10&&a%10<=4&&(a%100<10||20<=a%100)?1:2)},5:function(a){return Number(0===a?0:1==a?1:2==a?2:3<=a%100&&a%100<=10?3:11<=a%100?4:5)},6:function(a){return Number(1==a?0:2<=a&&a<=4?1:2)},7:function(a){return Number(1==a?0:2<=a%10&&a%10<=4&&(a%100<10||20<=a%100)?1:2)},8:function(a){return Number(1==a?0:2==a?1:8!=a&&11!=a?2:3)},9:function(a){return Number(2<=a)},10:function(a){return Number(1==a?0:2==a?1:a<7?2:a<11?3:4)},11:function(a){return Number(1==a||11==a?0:2==a||12==a?1:2<a&&a<20?2:3)},12:function(a){return Number(a%10!=1||a%100==11)},13:function(a){return Number(0!==a)},14:function(a){return Number(1==a?0:2==a?1:3==a?2:3)},15:function(a){return Number(a%10==1&&a%100!=11?0:2<=a%10&&(a%100<10||20<=a%100)?1:2)},16:function(a){return Number(a%10==1&&a%100!=11?0:0!==a?1:2)},17:function(a){return Number(1==a||a%10==1?0:1)},18:function(a){return Number(0==a?0:1==a?1:2)},19:function(a){return Number(1==a?0:0===a||1<a%100&&a%100<11?1:10<a%100&&a%100<20?2:3)},20:function(a){return Number(1==a?0:0===a||0<a%100&&a%100<20?1:2)},21:function(a){return Number(a%100==1?1:a%100==2?2:a%100==3||a%100==4?3:0)}},M=function(){function a(b){var c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};v(this,a),this.languageUtils=b,this.options=c,this.logger=D.create("pluralResolver"),this.rules=function(){var a={};return K.forEach(function(b){b.lngs.forEach(function(c){a[c]={numbers:b.nr,plurals:L[b.fc]}})}),a}()}return a.prototype.addRule=function(a,b){this.rules[a]=b},a.prototype.getRule=function(a){return this.rules[this.languageUtils.getLanguagePartFromCode(a)]},a.prototype.needsPlural=function(a){var b=this.getRule(a);return b&&1<b.numbers.length},a.prototype.getSuffix=function(a,b){var c=this,d=this.getRule(a);if(d){if(1===d.numbers.length)return"";var e=d.noAbs?d.plurals(b):d.plurals(Math.abs(b)),f=d.numbers[e];this.options.simplifyPluralSuffix&&2===d.numbers.length&&1===d.numbers[0]&&(2===f?f="plural":1===f&&(f=""));var g=function(){return c.options.prepend&&f.toString()?c.options.prepend+f.toString():f.toString()};return"v1"===this.options.compatibilityJSON?1===f?"":"number"==typeof f?"_plural_"+f.toString():g():"v2"===this.options.compatibilityJSON||2===d.numbers.length&&1===d.numbers[0]?g():2===d.numbers.length&&1===d.numbers[0]?g():this.options.prepend&&e.toString()?this.options.prepend+e.toString():e.toString()}return this.logger.warn("no plural rule found for: "+a),""},a}(),N=function(){function b(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};v(this,b),this.logger=D.create("interpolator"),this.init(a,!0)}return b.prototype.init=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};arguments[1]&&(this.options=a,this.format=a.interpolation&&a.interpolation.format||function(a){return a},this.escape=a.interpolation&&a.interpolation.escape||i),a.interpolation||(a.interpolation={escapeValue:!0});var c=a.interpolation;this.escapeValue=void 0===c.escapeValue||c.escapeValue,this.prefix=c.prefix?h(c.prefix):c.prefixEscaped||"{{",this.suffix=c.suffix?h(c.suffix):c.suffixEscaped||"}}",this.formatSeparator=c.formatSeparator?c.formatSeparator:c.formatSeparator||",",this.unescapePrefix=c.unescapeSuffix?"":c.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":c.unescapeSuffix||"",this.nestingPrefix=c.nestingPrefix?h(c.nestingPrefix):c.nestingPrefixEscaped||h("$t("),this.nestingSuffix=c.nestingSuffix?h(c.nestingSuffix):c.nestingSuffixEscaped||h(")"),this.resetRegExp()},b.prototype.reset=function(){this.options&&this.init(this.options)},b.prototype.resetRegExp=function(){var a=this.prefix+"(.+?)"+this.suffix;this.regexp=new RegExp(a,"g");var b=""+this.prefix+this.unescapePrefix+"(.+?)"+this.unescapeSuffix+this.suffix;this.regexpUnescape=new RegExp(b,"g");var c=this.nestingPrefix+"(.+?)"+this.nestingSuffix;this.nestingRegexp=new RegExp(c,"g")},b.prototype.interpolate=function(b,c,d){function e(a){return a.replace(/\$/g,"$$$$")}var g=this,h=void 0,i=void 0,j=function(a){if(a.indexOf(g.formatSeparator)<0)return f(c,a);var b=a.split(g.formatSeparator),e=b.shift().trim(),h=b.join(g.formatSeparator).trim();return g.format(f(c,e),h,d)};for(this.resetRegExp();h=this.regexpUnescape.exec(b);)i=j(h[1].trim()),b=b.replace(h[0],i),this.regexpUnescape.lastIndex=0;for(;h=this.regexp.exec(b);)"string"!=typeof(i=j(h[1].trim()))&&(i=a(i)),i||(this.logger.warn("missed to pass in variable "+h[1]+" for interpolating "+b),i=""),i=e(this.escapeValue?this.escape(i):i),b=b.replace(h[0],i),this.regexp.lastIndex=0;return b},b.prototype.nest=function(b,c){function d(a){if(a.indexOf(",")<0)return a;var b=a.split(",");a=b.shift();var c=b.join(",");c=(c=this.interpolate(c,h)).replace(/'/g,'"');try{h=JSON.parse(c)}catch(d){this.logger.error("failed parsing options string in nesting for key "+a,d)}return a}var e=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{},f=void 0,g=void 0,h=w({},e);for(h.applyPostProcessor=!1;f=this.nestingRegexp.exec(b);){if((g=c(d.call(this,f[1].trim()),h))&&f[0]===b&&"string"!=typeof g)return g;"string"!=typeof g&&(g=a(g)),g||(this.logger.warn("missed to resolve "+f[1]+" for nesting "+b),g=""),b=b.replace(f[0],g),this.regexp.lastIndex=0}return b},b}(),O=function(a){function b(c,d,e){var f=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};v(this,b);var g=y(this,a.call(this));return g.backend=c,g.store=d,g.services=e,g.options=f,g.logger=D.create("backendConnector"),g.state={},g.queue=[],g.backend&&g.backend.init&&g.backend.init(e,f.backend,f),g}return x(b,a),b.prototype.queueLoad=function(a,b,c){var d=this,e=[],f=[],g=[],h=[];return a.forEach(function(a){var c=!0;b.forEach(function(b){var g=a+"|"+b;d.store.hasResourceBundle(a,b)?d.state[g]=2:d.state[g]<0||(1===d.state[g]?f.indexOf(g)<0&&f.push(g):(d.state[g]=1,c=!1,f.indexOf(g)<0&&f.push(g),e.indexOf(g)<0&&e.push(g),h.indexOf(b)<0&&h.push(b)))}),c||g.push(a)}),(e.length||f.length)&&this.queue.push({pending:f,loaded:{},errors:[],callback:c}),{toLoad:e,pending:f,toLoadLanguages:g,toLoadNamespaces:h}},b.prototype.loaded=function(a,b,c){var d=this,f=a.split("|"),g=z(f,2),h=g[0],i=g[1];b&&this.emit("failedLoading",h,i,b),c&&this.store.addResourceBundle(h,i,c),this.state[a]=b?-1:2,this.queue.forEach(function(c){e(c.loaded,[h],i),function(a,b){for(var c=a.indexOf(b);-1!==c;)a.splice(c,1),c=a.indexOf(b)}(c.pending,a),b&&c.errors.push(b),0!==c.pending.length||c.done||(d.emit("loaded",c.loaded),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.queue=this.queue.filter(function(a){return!a.done})},b.prototype.read=function(a,b,c){var d=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,e=this,f=4<arguments.length&&void 0!==arguments[4]?arguments[4]:250,g=arguments[5];return a.length?this.backend[c](a,b,function(h,i){return h&&i&&d<5?void setTimeout(function(){e.read.call(e,a,b,c,d+1,2*f,g)},f):void g(h,i)}):g(null,{})},b.prototype.load=function(a,b,c){var d=this;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),c&&c();var e=w({},this.backend.options,this.options.backend);"string"==typeof a&&(a=this.services.languageUtils.toResolveHierarchy(a)),"string"==typeof b&&(b=[b]);var g=this.queueLoad(a,b,c);return g.toLoad.length?void(e.allowMultiLoading&&this.backend.readMulti?this.read(g.toLoadLanguages,g.toLoadNamespaces,"readMulti",null,null,function(a,b){a&&d.logger.warn("loading namespaces "+g.toLoadNamespaces.join(", ")+" for languages "+g.toLoadLanguages.join(", ")+" via multiloading failed",a),!a&&b&&d.logger.log("successfully loaded namespaces "+g.toLoadNamespaces.join(", ")+" for languages "+g.toLoadLanguages.join(", ")+" via multiloading",b),g.toLoad.forEach(function(c){var e=c.split("|"),g=z(e,2),h=g[0],i=g[1],j=f(b,[h,i]);if(j)d.loaded(c,a,j);else{var k="loading namespace "+i+" for language "+h+" via multiloading failed";d.loaded(c,k),d.logger.error(k)}})}):g.toLoad.forEach(function(a){d.loadOne(a)})):(g.pending.length||c(),null)},b.prototype.reload=function(a,b){var c=this;this.backend||this.logger.warn("No backend was added via i18next.use. Will not load resources.");var d=w({},this.backend.options,this.options.backend);"string"==typeof a&&(a=this.services.languageUtils.toResolveHierarchy(a)),"string"==typeof b&&(b=[b]),d.allowMultiLoading&&this.backend.readMulti?this.read(a,b,"readMulti",null,null,function(d,e){d&&c.logger.warn("reloading namespaces "+b.join(", ")+" for languages "+a.join(", ")+" via multiloading failed",d),!d&&e&&c.logger.log("successfully reloaded namespaces "+b.join(", ")+" for languages "+a.join(", ")+" via multiloading",e),a.forEach(function(a){b.forEach(function(b){var g=f(e,[a,b]);if(g)c.loaded(a+"|"+b,d,g);else{var h="reloading namespace "+b+" for language "+a+" via multiloading failed";c.loaded(a+"|"+b,h),c.logger.error(h)}})})}):a.forEach(function(a){b.forEach(function(b){c.loadOne(a+"|"+b,"re")})})},b.prototype.loadOne=function(a){var b=this,c=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",d=a.split("|"),e=z(d,2),f=e[0],g=e[1];this.read(f,g,"read",null,null,function(d,e){d&&b.logger.warn(c+"loading namespace "+g+" for language "+f+" failed",d),!d&&e&&b.logger.log(c+"loaded namespace "+g+" for language "+f,e),b.loaded(a,d,e)})},b.prototype.saveMissing=function(a,b,c,d){this.backend&&this.backend.create&&this.backend.create(a,b,c,d),a&&a[0]&&this.store.addResource(a[0],b,c,d)},b}(E),P=function(a){function b(c,d,e){var f=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};v(this,b);var g=y(this,a.call(this));return g.cache=c,g.store=d,g.services=e,g.options=f,g.logger=D.create("cacheConnector"),g.cache&&g.cache.init&&g.cache.init(e,f.cache,f),g}return x(b,a),b.prototype.load=function(a,b,c){var d=this;if(!this.cache)return c&&c();var e=w({},this.cache.options,this.options.cache),f="string"==typeof a?this.services.languageUtils.toResolveHierarchy(a):a;e.enabled?this.cache.load(f,function(a,b){if(a&&d.logger.error("loading languages "+f.join(", ")+" from cache failed",a),b)for(var e in b)if(Object.prototype.hasOwnProperty.call(b,e))for(var g in b[e])if(Object.prototype.hasOwnProperty.call(b[e],g)&&"i18nStamp"!==g){var h=b[e][g];h&&d.store.addResourceBundle(e,g,h)}c&&c()}):c&&c()},b.prototype.save=function(){this.cache&&this.options.cache&&this.options.cache.enabled&&this.cache.save(this.store.data)},b}(E);return new(function(a){function b(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},d=arguments[1];v(this,b);var e=y(this,a.call(this));if(e.options=s(c),e.services={},e.logger=D,e.modules={external:[]},d&&!e.isInitialized&&!c.isClone){var f;if(!e.options.initImmediate)return f=e.init(c,d),y(e,f);setTimeout(function(){e.init(c,d)},0)}return e}return x(b,a),b.prototype.init=function(a,b){function c(a){return a?"function"==typeof a?new a:a:null}var d=this;if("function"==typeof a&&(b=a,a={}),a||(a={}),"v1"===a.compatibilityAPI?this.options=w({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",saveMissing:!1,saveMissingTo:"fallback",missingKeyHandler:!1,postProcess:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:function(){},parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(a){return{defaultValue:a[1]}},interpolation:{escapeValue:!0,format:function(a,b,c){return a},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",defaultVariables:void 0}},s(function(a){return a.resStore&&(a.resources=a.resStore),a.ns&&a.ns.defaultNs?(a.defaultNS=a.ns.defaultNs,a.ns=a.ns.namespaces):a.defaultNS=a.ns||"translation",a.fallbackToDefaultNS&&a.defaultNS&&(a.fallbackNS=a.defaultNS),a.saveMissing=a.sendMissing,a.saveMissingTo=a.sendMissingTo||"current",a.returnNull=!a.fallbackOnNull,a.returnEmptyString=!a.fallbackOnEmpty,a.returnObjects=a.returnObjectTrees,a.joinArrays="\n",a.returnedObjectHandler=a.objectTreeKeyHandler,a.parseMissingKeyHandler=a.parseMissingKey,a.appendNamespaceToMissingKey=!0,a.nsSeparator=a.nsseparator||":",a.keySeparator=a.keyseparator||".","sprintf"===a.shortcutFunction&&(a.overloadTranslationOptionHandler=function(a){for(var b=[],c=1;c<a.length;c++)b.push(a[c]);return{postProcess:"sprintf",sprintf:b}}),a.whitelist=a.lngWhitelist,a.preload=a.preload,"current"===a.load&&(a.load="currentOnly"),"unspecific"===a.load&&(a.load="languageOnly"),a.backend=a.backend||{},a.backend.loadPath=a.resGetPath||"locales/__lng__/__ns__.json",a.backend.addPath=a.resPostPath||"locales/add/__lng__/__ns__",a.backend.allowMultiLoading=a.dynamicLoad,a.cache=a.cache||{},a.cache.prefix="res_",a.cache.expirationTime=6048e5,a.cache.enabled=a.useLocalStorage,(a=j(a)).defaultVariables&&(a.interpolation.defaultVariables=a.defaultVariables),a}(a)),{}):"v1"===a.compatibilityJSON?this.options=w({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",saveMissing:!1,saveMissingTo:"fallback",missingKeyHandler:!1,postProcess:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:function(){},parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(a){return{defaultValue:a[1]}},interpolation:{escapeValue:!0,format:function(a,b,c){return a},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",defaultVariables:void 0}},s(function(a){return(a=j(a)).joinArrays="\n",a}(a)),{}):this.options=w({},{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,whitelist:!1,nonExplicitWhitelist:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",saveMissing:!1,saveMissingTo:"fallback",missingKeyHandler:!1,postProcess:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:function(){},parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(a){return{defaultValue:a[1]}},interpolation:{escapeValue:!0,format:function(a,b,c){return a},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",defaultVariables:void 0}},this.options,s(a)),this.format=this.options.interpolation.format,b||(b=t),!this.options.isClone){this.modules.logger?D.init(c(this.modules.logger),this.options):D.init(null,this.options);var e=new J(this.options);this.store=new G(this.options.resources,this.options);var f=this.services;f.logger=D,f.resourceStore=this.store,f.resourceStore.on("added removed",function(a,b){f.cacheConnector.save()}),f.languageUtils=e,f.pluralResolver=new M(e,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f.interpolator=new N(this.options),f.backendConnector=new O(c(this.modules.backend),f.resourceStore,f,this.options),f.backendConnector.on("*",function(a){for(var b=arguments.length,c=Array(1<b?b-1:0),e=1;e<b;e++)c[e-1]=arguments[e];d.emit.apply(d,[a].concat(c))}),f.backendConnector.on("loaded",function(a){f.cacheConnector.save()}),f.cacheConnector=new P(c(this.modules.cache),f.resourceStore,f,this.options),f.cacheConnector.on("*",function(a){for(var b=arguments.length,c=Array(1<b?b-1:0),e=1;e<b;e++)c[e-1]=arguments[e];d.emit.apply(d,[a].concat(c))}),this.modules.languageDetector&&(f.languageDetector=c(this.modules.languageDetector),f.languageDetector.init(f,this.options.detection,this.options)),this.translator=new I(this.services,this.options),this.translator.on("*",function(a){for(var b=arguments.length,c=Array(1<b?b-1:0),e=1;e<b;e++)c[e-1]=arguments[e];d.emit.apply(d,[a].concat(c))}),this.modules.external.forEach(function(a){a.init&&a.init(d)})}["getResource","addResource","addResources","addResourceBundle","removeResourceBundle","hasResourceBundle","getResourceBundle"].forEach(function(a){d[a]=function(){var b;return(b=d.store)[a].apply(b,arguments)}}),"v1"===this.options.compatibilityAPI&&function(a){a.lng=function(){return D.deprecate("i18next.lng() can be replaced by i18next.language for detected language or i18next.languages for languages ordered by translation lookup."),a.services.languageUtils.toResolveHierarchy(a.language)[0]},a.preload=function(b,c){D.deprecate("i18next.preload() can be replaced with i18next.loadLanguages()"),a.loadLanguages(b,c)},a.setLng=function(b,c,d){return D.deprecate("i18next.setLng() can be replaced with i18next.changeLanguage() or i18next.getFixedT() to get a translation function with fixed language or namespace."),"function"==typeof c&&(d=c,c={}),c||(c={}),!0===c.fixLng&&d?d(null,a.getFixedT(b)):a.changeLanguage(b,d)},a.addPostProcessor=function(b,c){D.deprecate("i18next.addPostProcessor() can be replaced by i18next.use({ type: 'postProcessor', name: 'name', process: fc })"),a.use({type:"postProcessor",name:b,process:c})}}(this);var h=function(){d.changeLanguage(d.options.lng,function(a,c){d.isInitialized=!0,d.logger.log("initialized",d.options),d.emit("initialized",d.options),b(a,c)})};return this.options.resources||!this.options.initImmediate?h():setTimeout(h,0),this},b.prototype.loadResources=function(){var a=this,b=0<arguments.length&&void 0!==arguments[0]?arguments[0]:t;if(this.options.resources)b(null);else{if(this.language&&"cimode"===this.language.toLowerCase())return b();var c=[],d=function(b){b&&a.services.languageUtils.toResolveHierarchy(b).forEach(function(a){c.indexOf(a)<0&&c.push(a)})};if(this.language)d(this.language);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(a){return d(a)});this.options.preload&&this.options.preload.forEach(function(a){return d(a)}),this.services.cacheConnector.load(c,this.options.ns,function(){a.services.backendConnector.load(c,a.options.ns,b)})}},b.prototype.reloadResources=function(a,b){a||(a=this.languages),b||(b=this.options.ns),this.services.backendConnector.reload(a,b)},b.prototype.use=function(a){return"backend"===a.type&&(this.modules.backend=a),"cache"===a.type&&(this.modules.cache=a),("logger"===a.type||a.log&&a.warn&&a.error)&&(this.modules.logger=a),"languageDetector"===a.type&&(this.modules.languageDetector=a),"postProcessor"===a.type&&H.addPostProcessor(a),"3rdParty"===a.type&&this.modules.external.push(a),this},b.prototype.changeLanguage=function(a,b){var c=this,d=function(a,d){d&&(c.emit("languageChanged",d),c.logger.log("languageChanged",d)),b&&b(a,function(){return c.t.apply(c,arguments)})},e=function(a){a&&(c.language=a,c.languages=c.services.languageUtils.toResolveHierarchy(a),c.translator.changeLanguage(a),c.services.languageDetector&&c.services.languageDetector.cacheUserLanguage(a)),c.loadResources(function(b){d(b,a)})};a||!this.services.languageDetector||this.services.languageDetector.async?!a&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect(e):e(a):e(this.services.languageDetector.detect())},b.prototype.getFixedT=function(a,b){var c=this,d=function e(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},d=w({},b);return d.lng=d.lng||e.lng,d.lngs=d.lngs||e.lngs,d.ns=d.ns||e.ns,c.t(a,d)};return"string"==typeof a?d.lng=a:d.lngs=a,d.ns=b,d},b.prototype.t=function(){var a;return this.translator&&(a=this.translator).translate.apply(a,arguments)},b.prototype.exists=function(){var a;return this.translator&&(a=this.translator).exists.apply(a,arguments)},b.prototype.setDefaultNamespace=function(a){this.options.defaultNS=a},b.prototype.loadNamespaces=function(a,b){var c=this;return this.options.ns?("string"==typeof a&&(a=[a]),a.forEach(function(a){c.options.ns.indexOf(a)<0&&c.options.ns.push(a)}),void this.loadResources(b)):b&&b()},b.prototype.loadLanguages=function(a,b){"string"==typeof a&&(a=[a]);var c=this.options.preload||[],d=a.filter(function(a){return c.indexOf(a)<0});return d.length?(this.options.preload=c.concat(d),void this.loadResources(b)):b()},b.prototype.dir=function(a){if(a||(a=this.languages&&0<this.languages.length?this.languages[0]:this.language),!a)return"rtl";return 0<=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam"].indexOf(this.services.languageUtils.getLanguagePartFromCode(a))?"rtl":"ltr"},b.prototype.createInstance=function(){return new b(0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},arguments[1])},b.prototype.cloneInstance=function(){var a=this,c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},d=1<arguments.length&&void 0!==arguments[1]?arguments[1]:t,e=w({},this.options,c,{isClone:!0}),f=new b(e,d);return["store","services","language"].forEach(function(b){f[b]=a[b]}),f.translator=new I(f.services,f.options),f.translator.on("*",function(a){for(var b=arguments.length,c=Array(1<b?b-1:0),d=1;d<b;d++)c[d-1]=arguments[d];f.emit.apply(f,[a].concat(c))}),f.init(e,d),f},b}(E))});var PhaserI18n,__extends=this&&this.__extends||function(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)};function x(){function c(a,e){this.x=a||0,this.y=e||0}function B(a,e){this.pos=a||new c,this.r=e||0}function n(a,e){this.pos=a||new c,this.angle=0,this.offset=new c,this.u(e||[])}function q(a,e,b){this.pos=a||new c,this.w=e||0,this.h=b||0}function w(){this.b=this.a=null,this.overlapN=new c,this.overlapV=new c,this.clear()}function C(a,e,b){for(var h=Number.MAX_VALUE,c=-Number.MAX_VALUE,k=a.length,g=0;g<k;g++){var d=a[g].f(e);d<h&&(h=d),c<d&&(c=d)}b[0]=h,b[1]=c}function y(a,e,b,h,c,k){var g=r.pop(),d=r.pop();return e=(a=m.pop().c(e).sub(a)).f(c),C(b,c,g),C(h,c,d),d[0]+=e,d[1]+=e,g[0]>d[1]||d[0]>g[1]?(m.push(a),r.push(g),r.push(d),!0):(k&&(g[0]<d[0]?(k.aInB=!1,g[1]<d[1]?(b=g[1]-d[0],k.bInA=!1):b=(b=g[1]-d[0])<(h=d[1]-g[0])?b:-h):(k.bInA=!1,g[1]>d[1]?(b=g[0]-d[1],k.aInB=!1):b=(b=g[1]-d[0])<(h=d[1]-g[0])?b:-h),(h=Math.abs(b))<k.overlap&&(k.overlap=h,k.overlapN.c(c),b<0&&k.overlapN.reverse())),m.push(a),r.push(g),r.push(d),!1)}function z(a,e){var b=a.g(),c=e.f(a);return c<0?-1:b<c?1:0}function D(a,e,b){for(var c=m.pop().c(e.pos).sub(a.pos),l=e.r,k=l*l,g=a.calcPoints,d=g.length,u=m.pop(),f=m.pop(),n=0;n<d;n++){var v=n===d-1?0:n+1,r=0===n?d-1:n-1,q=0,t=null;u.c(a.edges[n]),f.c(c).sub(g[n]),b&&f.g()>k&&(b.aInB=!1);var p=z(u,f);if(-1===p){if(u.c(a.edges[r]),1===(p=z(u,v=m.pop().c(c).sub(g[r])))){if(l<(p=f.j()))return m.push(c),m.push(u),m.push(f),m.push(v),!1;b&&(b.bInA=!1,t=f.normalize(),q=l-p)}m.push(v)}else if(1===p){if(u.c(a.edges[v]),f.c(c).sub(g[v]),-1===(p=z(u,f))){if(l<(p=f.j()))return m.push(c),m.push(u),m.push(f),!1;b&&(b.bInA=!1,t=f.normalize(),q=l-p)}}else{if(v=u.m().normalize(),p=f.f(v),r=Math.abs(p),0<p&&l<r)return m.push(c),m.push(v),m.push(f),!1;b&&(t=v,q=l-p,0<=p||q<2*l)&&(b.bInA=!1)}t&&b&&Math.abs(q)<Math.abs(b.overlap)&&(b.overlap=q,b.overlapN.c(t))}return b&&(b.a=a,b.b=e,b.overlapV.c(b.overlapN).scale(b.overlap)),m.push(c),m.push(u),m.push(f),!0}function E(a,e,b){for(var c=a.calcPoints,l=c.length,k=e.calcPoints,g=k.length,d=0;d<l;d++)if(y(a.pos,e.pos,c,k,a.normals[d],b))return!1;for(d=0;d<g;d++)if(y(a.pos,e.pos,c,k,e.normals[d],b))return!1;return b&&(b.a=a,b.b=e,b.overlapV.c(b.overlapN).scale(b.overlap)),!0}var f={};f.Vector=c,(f.V=c).prototype.copy=c.prototype.c=function(a){return this.x=a.x,this.y=a.y,this},c.prototype.clone=c.prototype.clone=function(){return new c(this.x,this.y)},c.prototype.perp=c.prototype.m=function(){var a=this.x;return this.x=this.y,this.y=-a,this},c.prototype.rotate=c.prototype.rotate=function(a){var e=this.x,b=this.y;return this.x=e*Math.cos(a)-b*Math.sin(a),this.y=e*Math.sin(a)+b*Math.cos(a),this},c.prototype.reverse=c.prototype.reverse=function(){return this.x=-this.x,this.y=-this.y,this},c.prototype.normalize=c.prototype.normalize=function(){var a=this.j();return 0<a&&(this.x/=a,this.y/=a),this},c.prototype.add=c.prototype.add=function(a){return this.x+=a.x,this.y+=a.y,this},c.prototype.sub=c.prototype.sub=function(a){return this.x-=a.x,this.y-=a.y,this},c.prototype.scale=c.prototype.scale=function(a,e){return this.x*=a,this.y*=e||a,this},c.prototype.project=c.prototype.o=function(a){var e=this.f(a)/a.g();return this.x=e*a.x,this.y=e*a.y,this},c.prototype.projectN=c.prototype.s=function(a){var e=this.f(a);return this.x=e*a.x,this.y=e*a.y,this},c.prototype.reflect=function(a){var e=this.x,b=this.y;return this.o(a).scale(2),this.x-=e,this.y-=b,this},c.prototype.reflectN=function(a){var e=this.x,b=this.y;return this.s(a).scale(2),this.x-=e,this.y-=b,this},c.prototype.dot=c.prototype.f=function(a){return this.x*a.x+this.y*a.y},c.prototype.len2=c.prototype.g=function(){return this.f(this)},c.prototype.len=c.prototype.j=function(){return Math.sqrt(this.g())},(f.Circle=B).prototype.getAABB=function(){var a=this.r;return new q(this.pos.clone().sub(new c(a,a)),2*a,2*a).l()},(f.Polygon=n).prototype.setPoints=n.prototype.u=function(a){if(!this.points||this.points.length!==a.length){var e,b=this.calcPoints=[],h=this.edges=[],l=this.normals=[];for(e=0;e<a.length;e++)b.push(new c),h.push(new c),l.push(new c)}return this.points=a,this.i(),this},n.prototype.setAngle=function(a){return this.angle=a,this.i(),this},n.prototype.setOffset=function(a){return this.offset=a,this.i(),this},n.prototype.rotate=n.prototype.rotate=function(a){for(var e=this.points,b=e.length,c=0;c<b;c++)e[c].rotate(a);return this.i(),this},n.prototype.translate=n.prototype.translate=function(a,c){for(var b=this.points,h=b.length,l=0;l<h;l++)b[l].x+=a,b[l].y+=c;return this.i(),this},n.prototype.i=function(){var d,a=this.calcPoints,c=this.edges,b=this.normals,h=this.points,l=this.offset,k=this.angle,g=h.length;for(d=0;d<g;d++){var f=a[d].c(h[d]);f.x+=l.x,f.y+=l.y,0!==k&&f.rotate(k)}for(d=0;d<g;d++)h=a[d],h=c[d].c(d<g-1?a[d+1]:a[0]).sub(h),b[d].c(h).m().normalize()},n.prototype.getAABB=function(){for(var a=this.calcPoints,e=a.length,b=a[0].x,h=a[0].y,f=a[0].x,k=a[0].y,g=1;g<e;g++){var d=a[g];d.x<b?b=d.x:d.x>f&&(f=d.x),d.y<h?h=d.y:d.y>k&&(k=d.y)}return new q(this.pos.clone().add(new c(b,h)),f-b,k-h).l()},(f.Box=q).prototype.toPolygon=q.prototype.l=function(){var a=this.pos,e=this.w,b=this.h;return new n(new c(a.x,a.y),[new c,new c(e,0),new c(e,b),new c(0,b)])},(f.Response=w).prototype.clear=w.prototype.clear=function(){return this.bInA=this.aInB=!0,this.overlap=Number.MAX_VALUE,this};for(var m=[],t=0;t<10;t++)m.push(new c);var r=[];for(t=0;t<5;t++)r.push([]);var A=new w,F=new q(new c,1e-6,1e-6).l();return f.isSeparatingAxis=y,f.pointInCircle=function(a,c){var b=m.pop().c(a).sub(c.pos),h=c.r*c.r,f=b.g();return m.push(b),f<=h},f.pointInPolygon=function(a,c){F.pos.c(a),A.clear();var b=E(F,c,A);return b&&(b=A.aInB),b},f.testCircleCircle=function(a,c,b){var f=m.pop().c(c.pos).sub(a.pos),l=a.r+c.r,k=f.g();return l*l<k?(m.push(f),!1):(b&&(k=Math.sqrt(k),b.a=a,b.b=c,b.overlap=l-k,b.overlapN.c(f.normalize()),b.overlapV.c(f).scale(b.overlap),b.aInB=a.r<=c.r&&k<=c.r-a.r,b.bInA=c.r<=a.r&&k<=a.r-c.r),m.push(f),!0)},f.testPolygonCircle=D,f.testCirclePolygon=function(a,c,b){if((a=D(c,a,b))&&b){c=b.a;var f=b.aInB;b.overlapN.reverse(),b.overlapV.reverse(),b.a=b.b,b.b=c,b.aInB=b.bInA,b.bInA=f}return a},f.testPolygonPolygon=E,f}!function(a){!function(a){var b=function(){function a(a){this.type="backend",this.loadPath="/locales/{{lng}}/{{ns}}.json",this.game=a}return a.prototype.init=function(a,b){this.services=a,b&&b.loadPath&&this.setLoadPath(b.loadPath)},a.prototype.setLoadPath=function(a){this.loadPath=a},a.prototype.read=function(a,b,c){var d=this,e=this.services.interpolator.interpolate(this.loadPath,{lng:a,ns:b}),f=b+"_"+a,g=function(a,b){b===f&&(c(null,d.game.cache.getJSON(f)),d.game.load.onFileComplete.remove(g))};this.game.load.onFileComplete.add(g),this.game.load.json(f,e)},a.prototype.readMulti=function(a,b,c){},a.prototype.create=function(a,b,c,d){},a}();a.Backend=b}(a.I18next||(a.I18next={}))}(PhaserI18n||(PhaserI18n={})),function(a){var b=function(b){function c(a,c){var d=b.call(this,a,c)||this;return d._language="en",d.wasLoaderLocked=!1,d.started=!1,Object.defineProperty(a,"i18n",{value:d}),d.addLocaleLoader(),d.addLocaleFactory(),d.addLocaleCreator(),d}return __extends(c,b),c.prototype.init=function(b){for(var c=this,d=[],e=1;e<arguments.length;e++)d[e-1]=arguments[e];this.wasLoaderLocked=this.game.load.resetLocked,this.game.load.resetLocked=!0,i18next.on("languageChanged",function(){c.recursiveUpdateText(c.game.stage)}),this.backend=new a.I18next.Backend(this.game),i18next.use(this.backend);for(var f=0;f<d.length;f++)i18next.use(d[f]);i18next.init(b,function(){c.recursiveUpdateText(c.game.stage)})},c.prototype.setLanguage=function(a){void 0===a&&(a="en"),i18next.changeLanguage(a)},c.prototype.recursiveUpdateText=function(a){var b=this;(a instanceof Phaser.Text||a instanceof Phaser.BitmapText)&&(a.dirty=!0),a.children&&0<a.children.length&&a.children.forEach(function(a){b.recursiveUpdateText(a)})},c.prototype.addLocaleLoader=function(){var a=this;Phaser.Loader.prototype.locale=function(b,c,d){var e=this;Array.isArray(c)?d=c:void 0!==c&&a.backend.setLoadPath(c),i18next.loadLanguages(b,function(){a.started||(a.started=!0,e.game.load.resetLocked=a.wasLoaderLocked)}),d&&i18next.loadNamespaces(d)}},c.prototype.addLocaleFactory=function(){Phaser.GameObjectFactory.prototype.translatedText=function(b,c,d,e,f,g){return void 0===g&&(g=this.world),g.add(new a.TranslatedText(this.game,b,c,d,e,f))},Phaser.GameObjectFactory.prototype.translatedBitmapText=function(b,c,d,e,f,g,h,i){return void 0===i&&(i=this.world),i.add(new a.TranslatedBitmapText(this.game,b,c,d,e,f,g,h))}},c.prototype.addLocaleCreator=function(){Phaser.GameObjectCreator.prototype.translatedText=function(b,c,d,e,f){return new a.TranslatedText(this.game,b,c,d,e,f)},Phaser.GameObjectCreator.prototype.translatedBitmapText=function(b,c,d,e,f,g,h){return new a.TranslatedBitmapText(this.game,b,c,d,e,f,g,h)}},c}(Phaser.Plugin);a.Plugin=b}(PhaserI18n||(PhaserI18n={})),function(a){var b=function(a){function b(b,c,d,e,f,g,h,i){var j=a.call(this,b,c,d,e,"",g,h)||this;return j._nonTranslated="",j._interpolations={},j._interpolations=i||{},j.text=f,j}return __extends(b,a),b.prototype.setTranslationParamameter=function(a,b){this._interpolations[a]=b,this.dirty=!0},b.prototype.clearTranslationParamameter=function(a){a in this._interpolations&&delete this._interpolations[a]},Object.defineProperty(b.prototype,"_text",{get:function(){return i18next.t(this._nonTranslated,this._interpolations)||""},set:function(a){a!==this._nonTranslated&&(this._nonTranslated=a.toString()||"")},enumerable:!0,configurable:!0}),b}(Phaser.BitmapText);a.TranslatedBitmapText=b}(PhaserI18n||(PhaserI18n={})),function(a){var b=function(a){function b(b,c,d,e,f,g){var h=a.call(this,b,c,d,"",f)||this;return h._nonTranslated="",h._interpolations={},h._interpolations=g||{},h.text=e,h}return __extends(b,a),b.prototype.setTranslationParamameter=function(a,b){this._interpolations[a]=b,this.dirty=!0},b.prototype.clearTranslationParamameter=function(a){a in this._interpolations&&delete this._interpolations[a]},Object.defineProperty(b.prototype,"_text",{get:function(){return i18next.t(this._nonTranslated,this._interpolations)||""},set:function(a){a!==this._nonTranslated&&(this._nonTranslated=a.toString()||"")},enumerable:!0,configurable:!0}),b}(Phaser.Text);a.TranslatedText=b}(PhaserI18n||(PhaserI18n={})),function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o():"function"==typeof define&&define.amd?define(o):(e=e||self).i18nextBrowserLanguageDetector=o()}(this,function(){"use strict";function e(e,o){for(var t=0;t<o.length;t++){var n=o[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var o=[],t=o.forEach,n=o.slice;function i(e){return t.call(n.call(arguments,1),function(o){if(o)for(var t in o)void 0===e[t]&&(e[t]=o[t])}),e}var a=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,s=function(e,o,t,n){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};t&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+60*t*1e3)),n&&(i.domain=n),document.cookie=function(e,o,t){var n=t||{};n.path=n.path||"/";var i=e+"="+encodeURIComponent(o);if(0<n.maxAge){var r=n.maxAge-0;if(isNaN(r))throw new Error("maxAge should be a Number");i+="; Max-Age="+Math.floor(r)}if(n.domain){if(!a.test(n.domain))throw new TypeError("option domain is invalid");i+="; Domain="+n.domain}if(n.path){if(!a.test(n.path))throw new TypeError("option path is invalid");i+="; Path="+n.path}if(n.expires){if("function"!=typeof n.expires.toUTCString)throw new TypeError("option expires is invalid");i+="; Expires="+n.expires.toUTCString()}if(n.httpOnly&&(i+="; HttpOnly"),n.secure&&(i+="; Secure"),n.sameSite)switch("string"==typeof n.sameSite?n.sameSite.toLowerCase():n.sameSite){case!0:i+="; SameSite=Strict";break;case"lax":i+="; SameSite=Lax";break;case"strict":i+="; SameSite=Strict";break;case"none":i+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}return i}(e,encodeURIComponent(o),i)},l={name:"cookie",lookup:function(e){var o;if(e.lookupCookie&&"undefined"!=typeof document){var t=function(e){for(var o=e+"=",t=document.cookie.split(";"),n=0;n<t.length;n++){for(var i=t[n];" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(o))return i.substring(o.length,i.length)}return null}(e.lookupCookie);t&&(o=t)}return o},cacheUserLanguage:function(e,o){o.lookupCookie&&"undefined"!=typeof document&&s(o.lookupCookie,e,o.cookieMinutes,o.cookieDomain,o.cookieOptions)}},c={name:"querystring",lookup:function(e){var o;if("undefined"!=typeof window)for(var t=window.location.search.substring(1).split("&"),n=0;n<t.length;n++){var i=t[n].indexOf("=");0<i&&t[n].substring(0,i)===e.lookupQuerystring&&(o=t[n].substring(i+1))}return o}},p=null,d=function(){if(null!==p)return p;try{p="undefined"!==window&&null!==window.localStorage,window.localStorage.setItem("i18next.translate.boo","foo"),window.localStorage.removeItem("i18next.translate.boo")}catch(e){p=!1}return p},f={name:"localStorage",lookup:function(e){var o;if(e.lookupLocalStorage&&d()){var t=window.localStorage.getItem(e.lookupLocalStorage);t&&(o=t)}return o},cacheUserLanguage:function(e,o){o.lookupLocalStorage&&d()&&window.localStorage.setItem(o.lookupLocalStorage,e)}},g=null,h=function(){if(null!==g)return g;try{g="undefined"!==window&&null!==window.sessionStorage,window.sessionStorage.setItem("i18next.translate.boo","foo"),window.sessionStorage.removeItem("i18next.translate.boo")}catch(e){g=!1}return g},m={name:"sessionStorage",lookup:function(e){var o;if(e.lookupSessionStorage&&h()){var t=window.sessionStorage.getItem(e.lookupSessionStorage);t&&(o=t)}return o},cacheUserLanguage:function(e,o){o.lookupSessionStorage&&h()&&window.sessionStorage.setItem(o.lookupSessionStorage,e)}},v={name:"navigator",lookup:function(e){var o=[];if("undefined"!=typeof navigator){if(navigator.languages)for(var t=0;t<navigator.languages.length;t++)o.push(navigator.languages[t]);navigator.userLanguage&&o.push(navigator.userLanguage),navigator.language&&o.push(navigator.language)}return 0<o.length?o:void 0}},k={name:"htmlTag",lookup:function(e){var o,t=e.htmlTag||("undefined"!=typeof document?document.documentElement:null);return t&&"function"==typeof t.getAttribute&&(o=t.getAttribute("lang")),o}},w={name:"path",lookup:function(e){var o;if("undefined"!=typeof window){var t=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(t instanceof Array)if("number"==typeof e.lookupFromPathIndex){if("string"!=typeof t[e.lookupFromPathIndex])return;o=t[e.lookupFromPathIndex].replace("/","")}else o=t[0].replace("/","")}return o}},S={name:"subdomain",lookup:function(e){var o;if("undefined"!=typeof window){var t=window.location.href.match(/(?:http[s]*\:\/\/)*(.*?)\.(?=[^\/]*\..{2,5})/gi);t instanceof Array&&(o="number"==typeof e.lookupFromSubdomainIndex?t[e.lookupFromSubdomainIndex].replace("http://","").replace("https://","").replace(".",""):t[0].replace("http://","").replace("https://","").replace(".",""))}return o}},y=function(){function o(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{};!function(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o),this.type="languageDetector",this.detectors={},this.init(e,t)}var n;return n=[{key:"init",value:function(e){var o=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},t=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.services=e,this.options=i(o,this.options||{},{order:["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"],lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"]}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=t,this.addDetector(l),this.addDetector(c),this.addDetector(f),this.addDetector(m),this.addDetector(v),this.addDetector(k),this.addDetector(w),this.addDetector(S)}},{key:"addDetector",value:function(e){this.detectors[e.name]=e}},{key:"detect",value:function(e){var o=this;e||(e=this.options.order);var t=[];return e.forEach(function(e){if(o.detectors[e]){var n=o.detectors[e].lookup(o.options);n&&"string"==typeof n&&(n=[n]),n&&(t=t.concat(n))}}),this.services.languageUtils.getBestMatchFromCodes?t:0<t.length?t[0]:null}},{key:"cacheUserLanguage",value:function(e,o){var t=this;o||(o=this.options.caches),o&&(this.options.excludeCacheFor&&-1<this.options.excludeCacheFor.indexOf(e)||o.forEach(function(o){t.detectors[o]&&t.detectors[o].cacheUserLanguage(e,t.options)}))}}],e(o.prototype,n),o}();return y.type="languageDetector",y}),function(global){var NativePromise=global.Promise,nativePromiseSupported=NativePromise&&"resolve"in NativePromise&&"reject"in NativePromise&&"all"in NativePromise&&"race"in NativePromise&&function(){var resolve;return new NativePromise(function(r){resolve=r}),"function"==typeof resolve}();"undefined"!=typeof exports&&exports?(exports.Promise=nativePromiseSupported?NativePromise:Promise,exports.Polyfill=Promise):"function"==typeof define&&define.amd?define(function(){return nativePromiseSupported?NativePromise:Promise}):nativePromiseSupported||(global.Promise=Promise);var PENDING="pending",SEALED="sealed",FULFILLED="fulfilled",REJECTED="rejected",NOOP=function(){};function isArray(value){return"[object Array]"===Object.prototype.toString.call(value)}var asyncTimer,asyncSetTimer="undefined"!=typeof setImmediate?setImmediate:setTimeout,asyncQueue=[];function asyncFlush(){for(var i=0;i<asyncQueue.length;i++)asyncQueue[i][0](asyncQueue[i][1]);asyncTimer=!(asyncQueue=[])}function asyncCall(callback,arg){asyncQueue.push([callback,arg]),asyncTimer||(asyncTimer=!0,asyncSetTimer(asyncFlush,0))}function invokeCallback(subscriber){var owner=subscriber.owner,settled=owner.state_,value=owner.data_,callback=subscriber[settled],promise=subscriber.then;if("function"==typeof callback){settled=FULFILLED;try{value=callback(value)}catch(e){reject(promise,e)}}handleThenable(promise,value)||(settled===FULFILLED&&resolve(promise,value),settled===REJECTED&&reject(promise,value))}function handleThenable(promise,value){var resolved;try{if(promise===value)throw new TypeError("A promises callback cannot return that same promise.");if(value&&("function"==typeof value||"object"==typeof value)){var then=value.then;if("function"==typeof then)return then.call(value,function(val){resolved||(resolved=!0,value!==val?resolve(promise,val):fulfill(promise,val))},function(reason){resolved||(resolved=!0,reject(promise,reason))}),!0}}catch(e){return resolved||reject(promise,e),!0}return!1}function resolve(promise,value){promise!==value&&handleThenable(promise,value)||fulfill(promise,value)}function fulfill(promise,value){promise.state_===PENDING&&(promise.state_=SEALED,promise.data_=value,asyncCall(publishFulfillment,promise))}function reject(promise,reason){promise.state_===PENDING&&(promise.state_=SEALED,promise.data_=reason,asyncCall(publishRejection,promise))}function publish(promise){var callbacks=promise.then_;promise.then_=void 0;for(var i=0;i<callbacks.length;i++)invokeCallback(callbacks[i])}function publishFulfillment(promise){promise.state_=FULFILLED,publish(promise)}function publishRejection(promise){promise.state_=REJECTED,publish(promise)}function Promise(resolver){if("function"!=typeof resolver)throw new TypeError("Promise constructor takes a function argument");if(this instanceof Promise==!1)throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");this.then_=[],function(resolver,promise){function rejectPromise(reason){reject(promise,reason)}try{resolver(function(value){resolve(promise,value)},rejectPromise)}catch(e){rejectPromise(e)}}(resolver,this)}Promise.prototype={constructor:Promise,state_:PENDING,then_:null,data_:void 0,then:function(onFulfillment,onRejection){var subscriber={owner:this,then:new this.constructor(NOOP),fulfilled:onFulfillment,rejected:onRejection};return this.state_===FULFILLED||this.state_===REJECTED?asyncCall(invokeCallback,subscriber):this.then_.push(subscriber),subscriber.then},catch:function(onRejection){return this.then(null,onRejection)}},Promise.all=function(promises){if(!isArray(promises))throw new TypeError("You must pass an array to Promise.all().");return new this(function(resolve,reject){var results=[],remaining=0;function resolver(index){return remaining++,function(value){results[index]=value,--remaining||resolve(results)}}for(var promise,i=0;i<promises.length;i++)(promise=promises[i])&&"function"==typeof promise.then?promise.then(resolver(i),reject):results[i]=promise;remaining||resolve(results)})},Promise.race=function(promises){if(!isArray(promises))throw new TypeError("You must pass an array to Promise.race().");return new this(function(resolve,reject){for(var promise,i=0;i<promises.length;i++)(promise=promises[i])&&"function"==typeof promise.then?promise.then(resolve,reject):resolve(promise)})},Promise.resolve=function(value){return value&&"object"==typeof value&&value.constructor===this?value:new this(function(resolve){resolve(value)})},Promise.reject=function(reason){return new this(function(resolve,reject){reject(reason)})}}("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this),"function"==typeof define&&define.amd?define(x):"object"==typeof exports?module.exports=x():this.SAT=x();__extends=this&&this.__extends||function(){var extendStatics=function(d,b){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])})(d,b)};return function(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}}();var PlayerState,HitAreas,Entity=function(){function Entity(main){this.main=main}return Entity.prototype.levelStart=function(){},Entity.prototype.destroy=function(){this.main=null},Entity.prototype.reset=function(){},Entity.prototype.resetLevel=function(){this.xPos=this.startX,this.yPos=this.startY},Entity}(),HitBoxInfo=function(xOff,yOff,width,height){this.xOff=xOff,this.yOff=yOff,this.width=width,this.height=height};!function(PlayerState){PlayerState[PlayerState.Idle=0]="Idle",PlayerState[PlayerState.Running=1]="Running",PlayerState[PlayerState.Jumping=2]="Jumping",PlayerState[PlayerState.Falling=3]="Falling",PlayerState[PlayerState.Sliding=4]="Sliding",PlayerState[PlayerState.Crouching=5]="Crouching",PlayerState[PlayerState.Scaling=6]="Scaling",PlayerState[PlayerState.Hanging=7]="Hanging",PlayerState[PlayerState.Zipping=8]="Zipping",PlayerState[PlayerState.Swinging=9]="Swinging",PlayerState[PlayerState.Pushing=10]="Pushing",PlayerState[PlayerState.Kicking=11]="Kicking",PlayerState[PlayerState.Spawning=12]="Spawning",PlayerState[PlayerState.Swimming=13]="Swimming",PlayerState[PlayerState.JumpDown=14]="JumpDown",PlayerState[PlayerState.JumpFrontFlip=15]="JumpFrontFlip",PlayerState[PlayerState.JumpBackFlip=16]="JumpBackFlip"}(PlayerState||(PlayerState={})),function(HitAreas){HitAreas[HitAreas.Head=0]="Head",HitAreas[HitAreas.Body=1]="Body",HitAreas[HitAreas.Hands=2]="Hands",HitAreas[HitAreas.Feet=3]="Feet"}(HitAreas||(HitAreas={}));var Vex3,Player=function(_super){function Player(main,game,layer){var _this=_super.call(this,main)||this;_this.maxVelocity=6,_this.acc=1,_this.fallingMax=20,_this.startWidth=18,_this.maxScaleTime=45,_this.maxHangCoolDown=10,_this.maxBreathe=600,_this.scoreUpdated=!1,_this.god=!1,_this.game=game,_this.container=game.add.group(),layer.add(_this.container),_this.stateSprites={};var sprite=_this.container.create(0,0,"playerStand");sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Idle]=sprite,(sprite=_this.container.create(0,0,"playerRun")).animations.add("run"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Running]=sprite,(sprite=_this.container.create(0,0,"playerJump")).animations.add("jump"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Jumping]=sprite,(sprite=_this.container.create(0,0,"playerJumpDown")).animations.add("jump"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.JumpDown]=sprite,(sprite=_this.container.create(0,0,"playerJumpFrontFlip")).animations.add("jump"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.JumpFrontFlip]=sprite,(sprite=_this.container.create(0,0,"playerJumpBackFlip")).animations.add("jump"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.JumpBackFlip]=sprite,(sprite=_this.container.create(0,0,"playerSlide")).animations.add("slide"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Sliding]=sprite,(sprite=_this.container.create(0,0,"playerCrouch")).animations.add("crouch"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Crouching]=sprite,(sprite=_this.container.create(0,0,"playerScale")).animations.add("scale"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Scaling]=sprite,(sprite=_this.container.create(0,0,"playerHang")).animations.add("hang"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Hanging]=sprite,(sprite=_this.container.create(0,0,"playerPulley")).animations.add("zip"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Zipping]=sprite,(sprite=_this.container.create(0,0,"playerSwing")).animations.add("swing"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Swinging]=sprite,(sprite=_this.container.create(0,0,"playerPush")).animations.add("push"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Pushing]=sprite,(sprite=_this.container.create(0,0,"playerKick")).animations.add("kick"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Kicking]=sprite,(sprite=_this.container.create(0,0,"playerFall")).animations.add("fall"),sprite.anchor.set(.5,.8),sprite.visible=!1,_this.stateSprites[PlayerState.Falling]=sprite,(sprite=_this.container.create(0,0,"playerSwimTop")).animations.add("swim"),sprite.anchor.set(.45,17/23),sprite.y=-10,sprite.visible=!1,_this.stateSprites[PlayerState.Swimming]=sprite,_this.legSprite=_this.container.create(0,0,"playerSwimBottom"),_this.legSprite.animations.add("swim"),_this.legSprite.animations.play("swim",null,!0),_this.legSprite.anchor.set(9/16,.15),_this.legSprite.y=-10,_this.legSprite.visible=!1,(sprite=_this.container.create(0,0,"playerSpawn")).animations.add("spawn"),sprite.anchor.set(.5,1),sprite.visible=!1,_this.stateSprites[PlayerState.Spawning]=sprite,_this.stateInfos={};var infoSet={};infoSet[HitAreas.Head]=new HitBoxInfo(-3.75,-32.75,7.55,9.5),infoSet[HitAreas.Body]=new HitBoxInfo(-5.75,-23.5,11.5,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(1.4,-19.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9.75),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Idle]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-33,7.55,18.1),infoSet[HitAreas.Body]=new HitBoxInfo(-12.55,-30,24.1,26.95),infoSet[HitAreas.Hands]=new HitBoxInfo(1.4,-19.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9.75),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Running]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-32.45,7.55,16.9),infoSet[HitAreas.Body]=new HitBoxInfo(-5.05,-23,12,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(1.05,-34.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-5.75,-6.25,8,9),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Jumping]=infoSet,_this.stateInfos[PlayerState.JumpDown]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-16.25,-10.35,7.55,7.2),infoSet[HitAreas.Body]=new HitBoxInfo(-13,-11.5,18.25,9.75),infoSet[HitAreas.Hands]=new HitBoxInfo(.45,-11.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,10.5),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Sliding]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-19,7.55,9.5),infoSet[HitAreas.Body]=new HitBoxInfo(-4.75,-11.25,11.5,9.75),infoSet[HitAreas.Hands]=new HitBoxInfo(.45,-14.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9.75),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Crouching]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-33.25,7.55,9.5),infoSet[HitAreas.Body]=new HitBoxInfo(-6.1,-23.85,15,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(3.95,-36.65,7.55,14.45),infoSet[HitAreas.Feet]=new HitBoxInfo(-5.6,-6.6,7,6.25),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Scaling]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-32.75,7.55,9.5),infoSet[HitAreas.Body]=new HitBoxInfo(-6.25,-23.5,11.5,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(.35,-40.15,9.75,15.65),infoSet[HitAreas.Feet]=new HitBoxInfo(-9.2,-6.25,13,5.25),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Hanging]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-32.45,7.55,9.5),infoSet[HitAreas.Body]=new HitBoxInfo(-4.8,-23,11.5,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(-1.2,-35.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Zipping]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-32.45,7.55,16.9),infoSet[HitAreas.Body]=new HitBoxInfo(-4.8,-23,11.5,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(-1.2,-35.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Swinging]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-3.85,-32.45,7.55,16.9),infoSet[HitAreas.Body]=new HitBoxInfo(-4.8,-23,11.5,17.3),infoSet[HitAreas.Hands]=new HitBoxInfo(-1.8,-25.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Pushing]=infoSet,(infoSet={})[HitAreas.Head]=new HitBoxInfo(-2.5,-27.05,7.55,9.5),infoSet[HitAreas.Body]=new HitBoxInfo(-5,-21.4,11.5,13.25),infoSet[HitAreas.Hands]=new HitBoxInfo(-1.4,-19.5,7.55,9.5),infoSet[HitAreas.Feet]=new HitBoxInfo(-6.5,-6.25,13,9),_this.makeTotalBounds(infoSet),_this.stateInfos[PlayerState.Swimming]=infoSet,_this.stateInfos[PlayerState.Falling]=_this.stateInfos[PlayerState.Jumping],_this.stateInfos[PlayerState.Spawning]=_this.stateInfos[PlayerState.Idle],_this.stateInfos[PlayerState.Kicking]=_this.stateInfos[PlayerState.Idle],_this.head=new SAT.Box(new SAT.Vector(0,0),13,9.75),_this.headInfo=new HitBoxInfo(-3.75,-32.75,7.55,9.5),_this.body=new SAT.Box(new SAT.Vector(0,0),13,9.75),_this.bodyInfo=new HitBoxInfo(-5.75,-23.5,11.5,17.3),_this.hands=new SAT.Box(new SAT.Vector(0,0),13,9.75),_this.handsInfo=new HitBoxInfo(-.75,-19.5,7.55,9.5),_this.feetInfo=new HitBoxInfo(-20.2,-6.25,30.05,10.75),_this.feet=new SAT.Box(new SAT.Vector(0,0),13,9.75),_this.pressDown=new PressDown(_this.container),_this.breatheGroup=game.add.group(_this.container),_this.breatheBlocks=[];for(var i=0;i<10;i++){var bb=_this.breatheGroup.create(10*(i-5),-65,"breatheBlock");_this.breatheBlocks.push(bb)}return _this.aniCont=!1,_this.keys=main.keys,_this.alive=!1,_this.deaths=0,_this.lookingAround=!1,game.input.addMoveCallback(function(){_this.main.keys.isScreenButtonDown()||_this.state!==PlayerState.Idle&&_this.state!==PlayerState.Swimming&&_this.state!==PlayerState.Hanging||(_this.lookingAround=!0)},_this),_this}return __extends(Player,_super),Player.prototype.makeTotalBounds=function(infoSet){infoSet.leftEdgeOff=Math.min(infoSet[HitAreas.Hands].xOff,Math.min(infoSet[HitAreas.Feet].xOff,Math.min(infoSet[HitAreas.Head].xOff,infoSet[HitAreas.Body].xOff))),infoSet.topEdgeOff=Math.min(infoSet[HitAreas.Hands].yOff,Math.min(infoSet[HitAreas.Feet].yOff,Math.min(infoSet[HitAreas.Head].yOff,infoSet[HitAreas.Body].yOff))),infoSet.rightEdgeOff=Math.max(infoSet[HitAreas.Hands].xOff+infoSet[HitAreas.Hands].width,Math.max(infoSet[HitAreas.Feet].xOff+infoSet[HitAreas.Feet].width,Math.max(infoSet[HitAreas.Head].xOff+infoSet[HitAreas.Head].width,infoSet[HitAreas.Body].xOff+infoSet[HitAreas.Body].width))),infoSet.bottomEdgeOff=Math.max(infoSet[HitAreas.Hands].yOff+infoSet[HitAreas.Hands].height,Math.max(infoSet[HitAreas.Feet].yOff+infoSet[HitAreas.Feet].height,Math.max(infoSet[HitAreas.Head].yOff+infoSet[HitAreas.Head].height,infoSet[HitAreas.Body].yOff+infoSet[HitAreas.Body].height)))},Player.prototype.spawn=function(x,y){this.xVelocity=0,this.yVelocity=0,this.forcedXVelocity=0,this.xPos=x,this.yPos=y,this.rotation=0,this.rotationDest=0,this.checkpoint=new Phaser.Point(x,y),this.resetpoint=new Phaser.Point(x,y),this.container.scale.set(1,1),this.container.visible=!0,this.spriteYOff=0,this.falling=!1,this.crouching=!1,this.scaling=!1,this.kicking=!1,this.hanging=!1,this.pushing=!1,this.swimming=!1,this.bouncing=!1,this.currentHang=null,this.hangTime=10,this.scaleHistory=4e3,this.scaleTime=0,this.currentZipline=null,this.lastZipline=null,this.lastPool=null,this.currentPole=null,this.poleTimer=0,this.currentCannon=null,this.onIce=!1,this.onSpeedBlock=!1,this.porting=!1,this.breathe=this.maxBreathe,this.poolCoolDown=0,this.swimmingLegs=[],this.keysObtained=0,this.heldKeys=[],this.alive=!0,this.setSpawn(),this.faceRight(),this.updatePositions(),this.resetHitBoxes(),this.scoreUpdated=!1},Player.prototype.resetHitBoxes=function(){var headXOff,handsXOff,bodyXOff,feetXOff;feetXOff="right"===this.facing?(headXOff=this.headInfo.xOff,handsXOff=this.handsInfo.xOff,bodyXOff=this.bodyInfo.xOff,this.feetInfo.xOff):(headXOff=-this.headInfo.xOff-this.headInfo.width,handsXOff=-this.handsInfo.xOff-this.handsInfo.width,bodyXOff=-this.bodyInfo.xOff-this.bodyInfo.width,-this.feetInfo.xOff-this.feetInfo.width);var rad=this.rotation*Math.PI/180;this.head.pos.x=this.xPos,this.head.pos.y=this.yPos,this.head.w=this.headInfo.width,this.head.h=this.headInfo.height,this.headPolygon=this.head.toPolygon(),this.headPolygon.setOffset(new SAT.Vector(headXOff,this.headInfo.yOff)),this.headPolygon.setAngle(rad),this.hands.pos.x=this.xPos,this.hands.pos.y=this.yPos,this.hands.w=this.handsInfo.width,this.hands.h=this.handsInfo.height,this.handsPolygon=this.hands.toPolygon(),this.handsPolygon.setOffset(new SAT.Vector(handsXOff,this.handsInfo.yOff)),this.handsPolygon.setAngle(rad),this.body.pos.x=this.xPos,this.body.pos.y=this.yPos,this.body.w=this.bodyInfo.width,this.body.h=this.bodyInfo.height,this.bodyPolygon=this.body.toPolygon(),this.bodyPolygon.setOffset(new SAT.Vector(bodyXOff,this.bodyInfo.yOff)),this.bodyPolygon.setAngle(rad),this.feet.pos.x=this.xPos,this.feet.pos.y=this.yPos,this.feet.w=this.feetInfo.width,this.feet.h=this.feetInfo.height,this.feetPolygon=this.feet.toPolygon(),this.feetPolygon.setOffset(new SAT.Vector(feetXOff,this.feetInfo.yOff)),this.feetPolygon.setAngle(rad),this.width=this.stateInfos[this.state].rightEdgeOff-this.stateInfos[this.state].leftEdgeOff,this.height=this.stateInfos[this.state].bottomEdgeOff-this.stateInfos[this.state].topEdgeOff;var totalBox=new SAT.Box(new SAT.Vector(this.xPos,this.yPos),this.width,this.height);this.totalPolygon=totalBox.toPolygon(),this.totalPolygon.setOffset(new SAT.Vector(this.stateInfos[this.state].leftEdgeOff,this.stateInfos[this.state].topEdgeOff))},Player.prototype.updateHitBoxesPos=function(){this.head.pos.y=this.yPos,this.feet.pos.y=this.yPos,this.hands.pos.y=this.yPos,this.body.pos.y=this.yPos,this.headPolygon.pos.x=this.xPos,this.headPolygon.pos.y=this.yPos,this.bodyPolygon.pos.x=this.xPos,this.bodyPolygon.pos.y=this.yPos,this.handsPolygon.pos.x=this.xPos,this.handsPolygon.pos.y=this.yPos,this.feetPolygon.pos.x=this.xPos,this.feetPolygon.pos.y=this.yPos,this.totalPolygon.pos.x=this.xPos,this.totalPolygon.pos.y=this.yPos;var rad=this.rotation*Math.PI/180;this.headPolygon.setAngle(rad),this.bodyPolygon.setAngle(rad),this.handsPolygon.setAngle(rad),this.feetPolygon.setAngle(rad),this.totalPolygon.setAngle(rad)},Player.prototype.redrawHitBoxes=function(){this.hitGraphics.clear(),this.hitGraphics.beginFill(16711680,.5),this.hitGraphics.moveTo(this.xPos+this.bodyPolygon.calcPoints[0].x,this.yPos+this.bodyPolygon.calcPoints[0].y);for(var i=1;i<4;i++)this.hitGraphics.lineTo(this.xPos+this.bodyPolygon.calcPoints[i].x,this.yPos+this.bodyPolygon.calcPoints[i].y);this.hitGraphics.lineTo(this.xPos+this.bodyPolygon.calcPoints[0].x,this.yPos+this.bodyPolygon.calcPoints[0].y),this.hitGraphics.endFill(),this.hitGraphics.beginFill(65280,.5),this.hitGraphics.moveTo(this.xPos+this.headPolygon.calcPoints[0].x,this.yPos+this.headPolygon.calcPoints[0].y);for(i=1;i<4;i++)this.hitGraphics.lineTo(this.xPos+this.headPolygon.calcPoints[i].x,this.yPos+this.headPolygon.calcPoints[i].y);this.hitGraphics.lineTo(this.xPos+this.headPolygon.calcPoints[0].x,this.yPos+this.headPolygon.calcPoints[0].y),this.hitGraphics.endFill(),this.hitGraphics.beginFill(255,.5),this.hitGraphics.moveTo(this.xPos+this.handsPolygon.calcPoints[0].x,this.yPos+this.handsPolygon.calcPoints[0].y);for(i=1;i<4;i++)this.hitGraphics.lineTo(this.xPos+this.handsPolygon.calcPoints[i].x,this.yPos+this.handsPolygon.calcPoints[i].y);this.hitGraphics.lineTo(this.xPos+this.handsPolygon.calcPoints[0].x,this.yPos+this.handsPolygon.calcPoints[0].y),this.hitGraphics.endFill(),this.hitGraphics.beginFill(16776960,.5),this.hitGraphics.moveTo(this.xPos+this.feetPolygon.calcPoints[0].x,this.yPos+this.feetPolygon.calcPoints[0].y);for(i=1;i<4;i++)this.hitGraphics.lineTo(this.xPos+this.feetPolygon.calcPoints[i].x,this.yPos+this.feetPolygon.calcPoints[i].y);this.hitGraphics.lineTo(this.xPos+this.feetPolygon.calcPoints[0].x,this.yPos+this.feetPolygon.calcPoints[0].y),this.hitGraphics.endFill(),this.hitGraphics.beginFill(65535,.2),this.hitGraphics.moveTo(this.xPos+this.totalPolygon.calcPoints[0].x,this.yPos+this.totalPolygon.calcPoints[0].y);for(i=1;i<4;i++)this.hitGraphics.lineTo(this.xPos+this.totalPolygon.calcPoints[i].x,this.yPos+this.totalPolygon.calcPoints[i].y);this.hitGraphics.lineTo(this.xPos+this.totalPolygon.calcPoints[0].x,this.yPos+this.totalPolygon.calcPoints[0].y),this.hitGraphics.endFill()},Player.prototype.setIdle=function(){this.state=PlayerState.Idle,this.sprite&&(this.sprite.visible=!1),this.prevFrame=0,this.sprite=this.stateSprites[PlayerState.Idle],this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setRun=function(){this.state=PlayerState.Running,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Running],this.sprite.animations.play("run",60*this.main.gameSpeed,!0),this.sprite.animations.frame=0,this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setJump=function(changeSprite,spriteState){void 0===changeSprite&&(changeSprite=!0),void 0===spriteState&&(spriteState=null),(this.state!==PlayerState.Jumping||spriteState)&&(this.state=PlayerState.Jumping,changeSprite&&(this.sprite&&(this.sprite.visible=!1),spriteState?(this.sprite=this.stateSprites[spriteState],this.jumpState=spriteState):(this.sprite=this.stateSprites[PlayerState.Jumping],this.jumpState=PlayerState.Jumping),this.sprite.animations.currentAnim.stop(!0),this.sprite.animations.play("jump",60*this.main.gameSpeed,!1),this.sprite.animations.frame=0,this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1),this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.height=this.stateInfos[this.state].height,this.resetHitBoxes())},Player.prototype.setSlide=function(){this.state!==PlayerState.Sliding&&(this.state=PlayerState.Sliding,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Sliding],this.sprite.animations.stop("slide",!0),this.sprite.animations.play("slide",null,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes())},Player.prototype.setCrouch=function(){this.state=PlayerState.Crouching,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Crouching],this.sprite.animations.stop("crouch",!0),this.sprite.animations.paused=!1,this.sprite.animations.play("crouch",null,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setScale=function(){this.state!==PlayerState.Scaling&&(this.state=PlayerState.Scaling,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Scaling],this.sprite.animations.currentAnim.stop(!0),this.sprite.animations.play("scale",null,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes())},Player.prototype.setHang=function(){this.state=PlayerState.Hanging,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Hanging],this.sprite.animations.frame=0,this.sprite.animations.refreshFrame(),this.sprite.animations.play("scale",60*this.main.gameSpeed,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setZip=function(){this.state=PlayerState.Zipping,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Zipping],this.sprite.frame=0,this.sprite.animations.stop("zip",!0),this.sprite.animations.refreshFrame(),this.sprite.animations.paused=!1,this.sprite.animations.play("zip",null,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setSwing=function(){this.state=PlayerState.Swinging,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Swinging],this.sprite.animations.stop("swing",!0),this.sprite.animations.paused=!1,this.sprite.animations.play("swing",null,!0),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setPush=function(){this.state=PlayerState.Pushing,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Pushing],this.sprite.animations.frame=0,this.sprite.animations.refreshFrame(),this.sprite.animations.play("push",60*this.main.gameSpeed,!0),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setKick=function(){this.state=PlayerState.Kicking,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Kicking],this.sprite.animations.frame=0,this.sprite.animations.refreshFrame(),this.sprite.animations.play("kick",60*this.main.gameSpeed,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setFall=function(){this.state=PlayerState.Falling,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Falling],this.sprite.animations.frame=0,this.sprite.animations.refreshFrame(),this.sprite.animations.play("fall",60*this.main.gameSpeed,!1),this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setSwim=function(){this.state=PlayerState.Swimming,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Swimming],this.sprite.animations.frame=0,this.sprite.animations.refreshFrame(),this.sprite.rotation=0,this.legSprite.rotation=0,this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!0,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.setSpawn=function(){this.state=PlayerState.Spawning,this.sprite&&(this.sprite.visible=!1),this.sprite=this.stateSprites[PlayerState.Spawning],this.sprite.animations.stop("spawn",!0),this.sprite.animations.refreshFrame(),this.sprite.animations.play("spawn",90,!1),this.stateTime=20,this.prevFrame=0,this.sprite.visible=!0,this.legSprite.visible=!1,this.headInfo=this.stateInfos[this.state][HitAreas.Head],this.bodyInfo=this.stateInfos[this.state][HitAreas.Body],this.handsInfo=this.stateInfos[this.state][HitAreas.Hands],this.feetInfo=this.stateInfos[this.state][HitAreas.Feet],this.resetHitBoxes()},Player.prototype.faceLeft=function(){"left"!==this.facing&&(this.facing="left",0<this.container.scale.x&&(this.container.scale.x*=-1),this.resetHitBoxes())},Player.prototype.faceRight=function(){"right"!==this.facing&&(this.facing="right",this.container.scale.x<0&&(this.container.scale.x*=-1),this.resetHitBoxes())},Player.prototype.enterActBlock=function(){this.actBlock&&this.crouching&&(this.actBlock.hellEnabled?this.main.changeLevel(this.actBlock.levelNum,-1,!0):this.main.changeLevel(this.actBlock.levelNum,-1),this.actBlock=null)},Player.prototype.jump=function(power,changeSprite,spriteState){void 0===changeSprite&&(changeSprite=!0),void 0===spriteState&&(spriteState=null),this.yVelocity=power,this.falling=!0,this.scaling=!1,this.swimming=!1,this.actBlock=null,this.hanging&&(this.hanging=!1,this.hangTime=0,this.currentHang=null),this.currentPole&&(3<=this.sprite.frame&&this.sprite.frame<=12?(this.poleTimer=0,this.currentPole=null,this.setJump(!0,PlayerState.JumpBackFlip),"right"===this.facing?(this.xVelocity=5,this.xPos+=10):(this.xVelocity=-5,this.xPos-=10),6<=this.sprite.frame&&this.sprite.frame<=9&&("right"===this.facing?this.xVelocity=9:this.xVelocity=-9),this.main.sounds.playSound("poleSwing"),this.yVelocity-=.2,this.updatePositions()):(this.poleTimer=0,this.currentPole=null,this.yVelocity=0)),this.currentZipline=null,this.setJump(changeSprite,spriteState),this.acc=1,this.updateHitBoxesPos()},Player.prototype.land=function(block){if(this.yVelocity=0,this.forcedXVelocity*=.8,this.yPos=block.yPos-.5*block.height+block.yVelocity,this.onIce=!1,this.onSpeedBlock=!1,"ice"===block.blockType?this.onIce=!0:"speed"===block.blockType&&(this.onSpeedBlock=!0),this.rotationDest=0,this.state!==PlayerState.Jumping&&this.state!==PlayerState.Scaling&&this.state!==PlayerState.Hanging||(this.main.sounds.playSound("land"),this.keys.left.isDown()||this.keys.right.isDown()?this.setRun():this.setIdle()),this.falling=!1,this.scaling=!1,this.hanging=!1,this.scaleHistory=4e3,this.currentHang=null,this.lastPool=null,this.actBlock=null,block.landed=new Phaser.Point(this.xPos-block.xPos,this.yPos-block.xPos),"push"===block.blockType&&this.crouching&&!this.kicking){if("not trapped"===block.checkTrapped())return;this.kicking=!0,this.kickBlock=block,this.xVelocity=this.forcedXVelocity=0,this.setKick(),this.sprite.animations.paused=!0,this.stateTime=10,block.stuckRight?(this.faceLeft(),this.tarKickX=block.rightEdge-.5*this.width):(this.tarKickX=block.leftEdge+.5*this.width,this.faceRight())}else if("act"===block.blockType){var actBlock=block;this.actBlock=actBlock,this.game.device.desktop&&this.enterActBlock(),this.pressDown.showPressDown=!0}},Player.prototype.scale=function(bound,left){void 0===left&&(left=!0),this.scaling?(this.lastPool=null,1<this.yVelocity&&(this.yVelocity*=.8),this.scaleTime+=this.main.gameSpeed,this.scaleTime>this.maxScaleTime&&(this.scaling=!1,this.falling=!0,this.setJump(),this.lastScaled=!1),this.xVelocity=this.forcedXVelocity=0):(left&&this.scaleHistory!=bound.rightEdge||!left&&this.scaleHistory!==bound.leftEdge)&&(this.scaleTime=0,this.scaling=!0,this.falling=!1,this.diving=!1,this.rotation=0,this.rotationDest=0,5<this.yVelocity?this.main.sounds.playSound("wallSlide"):this.main.sounds.playSound("connectSlide"),this.yVelocity<0&&(this.yVelocity=0),this.scaleHistory=left?bound.rightEdge:bound.leftEdge,this.setScale(),this.lastScaled=!0,this.xVelocity=this.forcedXVelocity=0)},Player.prototype.hang=function(block,left){void 0===left&&(left=!0),this.state!==PlayerState.Hanging&&this.setHang(),this.yVelocity=0,this.yPos=block.topEdge-this.handsInfo.yOff-4,this.xPos=left?block.leftEdge-this.handsInfo.xOff-this.handsInfo.width+4:block.rightEdge-this.handsInfo.xOff+this.handsInfo.width-4,this.hanging||(this.main.sounds.playSound("connectHang"),this.rotation=0,this.rotationDest=0),this.hanging=!0,this.falling=!1,this.currentHang=block,this.lastPool=null,this.scaleHistory=4e3,this.lastZipline=!1},Player.prototype.unhang=function(){this.hanging=!1,this.falling=!0,this.hangTime=0,this.currentHang=null},Player.prototype.checkForBlock=function(offsetX,offSetY){for(var i=0;i<this.main.blocks.length;i++){var block=this.main.blocks[i];if(block.alive&&SAT.pointInPolygon(new SAT.Vector(offsetX,offSetY),block.totalBoundPolygon))return!0}return!1},Player.prototype.checkBlocks=function(){if(!this.bouncing){var touchingAny=!1,hittingTop=!1,hittingBottom=!1,hittingLeft=!1,hittingRight=!1,isPushBlock=!1;this.pressDown.showPressDown=!1;for(var i=0;i<this.main.blocks.length;i++){var block=this.main.blocks[i];if(block.alive)if(block.rightEdge<this.xPos-40||block.leftEdge>this.xPos+40||block.topEdge>this.yPos+80||block.bottomEdge<this.yPos-80)block.landed=null;else{if(0,this.yVelocity>this.fallingMax&&SAT.testPolygonPolygon(this.totalPolygon,block.topBoundPolygon)){if("bounce"===block.blockType&&SAT.testPolygonPolygon(this.totalPolygon,block.topBoundPolygon)){this.land(block);continue}return void this.kill(1)}if(0<this.keysObtained&&"lock"===block.blockType){var lockBlock=block;if(!lockBlock.unlocked&&SAT.testPolygonPolygon(this.totalPolygon,block.totalBoundPolygon)){lockBlock.unlock(),this.heldKeys.pop().useKey(),this.keysObtained--;continue}}if((0<=this.yVelocity||block.yVelocity<0)&&-2<=this.yVelocity-block.yVelocity&&SAT.testPolygonPolygon(this.feetPolygon,block.topBoundPolygon)){if(this.falling&&this.keys.down.isDown()&&"glass"===block.blockType){block.smash();continue}this.xPos>block.xPos-.5*block.width&&this.xPos<block.xPos+.5*block.width&&this.land(block),touchingAny=isPushBlock=hittingTop=!0}else{if(block.landed=null,SAT.testPolygonPolygon(this.headPolygon,block.bottomBoundPolygon)){if(this.xPos<block.leftEdge)continue;if(this.xPos>block.rightEdge)continue;if(this.hanging||this.yVelocity-block.yVelocity<=.5){this.scaling||this.hanging?(this.setJump(),this.scaling=!1,this.scaleTime=0,this.hanging=!1,this.hangTime=0,this.currentHang=null,this.yVelocity=2,this.falling=!0,this.scaleHistory=4e3,this.lastZipline=!1):this.yVelocity*=-.5,"ice"===block.blockType?this.yPos=block.yPos+.5*block.height+block.yVelocity+this.height+2:this.yPos=block.yPos+.5*block.height+2*block.yVelocity+this.height+1,this.updateHitBoxesPos(),hittingBottom=!0,"push"===block.blockType&&(isPushBlock=!0);continue}}if(!this.currentHang&&this.poolCoolDown<=0&&!this.swimming){if(block.hangable&&this.falling&&this.hangTime>=this.maxHangCoolDown&&(0<=this.yVelocity||block.yVelocity<0)){if(SAT.testPolygonPolygon(this.handsPolygon,block.lhBoundPolygon)&&!this.checkForBlock(block.leftEdge+3,block.topEdge-5)&&!this.checkForBlock(block.leftEdge-3,block.topEdge-5)){this.hang(block),hittingRight=touchingAny=!0;continue}if(SAT.testPolygonPolygon(this.handsPolygon,block.rhBoundPolygon)&&!this.checkForBlock(block.rightEdge+3,block.topEdge-5)&&!this.checkForBlock(block.rightEdge+-3,block.topEdge-5)){this.hang(block,!1),hittingLeft=touchingAny=!0;continue}}}else{if("right"===this.facing&&this.currentHang===block){this.hang(this.currentHang),hittingRight=!0;continue}if("left"===this.facing&&this.currentHang===block){this.hang(this.currentHang,!1),hittingLeft=!0;continue}touchingAny=!0}if(this.xPos>block.rightEdge||this.xPos<block.leftEdge)if("right"===this.facing){if(block.scalable&&(this.falling||this.scaling)&&-3<=this.yVelocity&&SAT.testPolygonPolygon(this.handsPolygon,block.leftBoundPolygon)){this.scale(block,!1),this.xPos=block.xPos-.5*block.width+this.handsInfo.xOff-this.handsInfo.width+1,hittingRight=touchingAny=!0;continue}}else if(block.scalable&&(this.falling||this.scaling)&&-3<=this.yVelocity&&SAT.testPolygonPolygon(this.handsPolygon,block.rightBoundPolygon)){this.scale(block,!0),this.xPos=block.xPos+.5*block.width+this.handsInfo.xOff-1,hittingLeft=touchingAny=!0;continue}if(!this.scaling&&(0<=this.xVelocity+this.forcedXVelocity||this.currentHang)&&SAT.testPolygonPolygon(this.bodyPolygon,block.leftBoundPolygon)){if(this.hanging&&"right"===this.facing&&this.unhang(),"push"!==block.blockType||this.falling||this.crouching||"right"!==this.facing){this.xVelocity=this.forcedXVelocity=0,this.xPos=block.xPos-block.width/2-this.bodyInfo.xOff-this.bodyInfo.width+2,hittingRight=!0;continue}block.xVelocity<this.xVelocity&&(block.xVelocity=this.xVelocity);var pushBlock=block;this.xPos=block.leftEdge-this.width/2+this.xVelocity,pushBlock.pushingRight=!0,pushBlock.pushed=!0,this.state!==PlayerState.Pushing&&this.setPush()}else if((!this.scaling&&this.xVelocity+this.forcedXVelocity<=0||this.currentHang)&&SAT.testPolygonPolygon(this.bodyPolygon,block.rightBoundPolygon)){if(this.hanging&&"left"===this.facing&&this.unhang(),"push"!==block.blockType||this.crouching||this.falling||"left"!==this.facing){this.xVelocity=this.forcedXVelocity=0,this.falling?this.xPos=block.rightEdge+4:this.xPos=block.xPos+block.width/2-this.bodyInfo.xOff-2,this.updatePositions(),hittingLeft=!0;continue}block.xVelocity>this.xVelocity&&(block.xVelocity=this.xVelocity);pushBlock=block;this.xPos=block.rightEdge+this.width/2+this.xVelocity,pushBlock.pushingLeft=!0,pushBlock.pushed=!0,this.state!==PlayerState.Pushing&&this.setPush()}else;}}}if(hittingLeft&&hittingRight||hittingTop&&hittingBottom)return isPushBlock&&this.main.achievements.gotAchievement("headsup"),void this.kill(3);touchingAny||hittingTop&&this.state!==PlayerState.Pushing||this.currentSlope||this.currentHang||(this.falling=!0,!this.diving&&this.yVelocity<=this.fallingMax&&(this.rotationDest=0),this.state===PlayerState.Running||this.state===PlayerState.Idle||this.state===PlayerState.Pushing?this.setJump():this.crouching?(this.setJump(),this.crouching=!1):(this.scaling||this.hanging)&&(this.setJump(),this.scaling=!1,this.scaleTime=0,this.hanging=!1,this.hangTime=0))}},Player.prototype.checkSlopeCollisions=function(){this.currentSlope=null;for(var _i=0,_a=this.main.slopes;_i<_a.length;_i++){var slope=_a[_i];if(slope.alive){if("left"!==this.facing||slope.right){if("right"===this.facing&&slope.right&&(this.falling||this.scaling)&&this.yPos-.5*this.height<slope.bottomEdge&&0<this.yVelocity&&SAT.testPolygonPolygon(this.handsPolygon,slope.wallPoly)){this.currentSlope=slope,this.xPos=slope.leftEdge-.5*this.width-1;continue}}else if((this.falling||this.scaling)&&this.yPos-.5*this.height<slope.bottomEdge&&0<this.yVelocity&&SAT.testPolygonPolygon(this.handsPolygon,slope.wallPoly)){this.currentSlope=slope,this.xPos=slope.rightEdge+.5*this.width+1;continue}if(!this.hanging&&!this.scaling)if(!slope.right&&this.xVelocity<0){if(SAT.testPolygonPolygon(this.bodyPolygon,slope.wallPoly)){this.xPos=slope.rightEdge+.5*this.width+7,this.xVelocity=this.forcedXVelocity=0;continue}}else if(slope.right&&0<this.xVelocity&&SAT.testPolygonPolygon(this.bodyPolygon,slope.wallPoly)){this.xPos=slope.leftEdge-.5*this.width-7,this.xVelocity=this.forcedXVelocity=0;continue}if(this.xPos>slope.leftEdge&&this.xPos<slope.rightEdge&&SAT.testPolygonPolygon(this.headPolygon,slope.bottomPoly)&&this.yPos>=slope.bottomEdge+.5*this.height&&this.yVelocity<0&&(this.yPos=slope.bottomEdge+this.height,this.yVelocity*=-.5,this.yPos+=this.yVelocity,this.updatePositions(),this.scaleHistory=4e3,this.currentZipline=null),this.xPos>slope.leftEdge&&this.xPos<slope.rightEdge&&this.yPos>slope.topEdge&&this.yPos<slope.bottomEdge)if(slope.right){dist=1-(this.xPos-slope.leftEdge)/slope.width;if(this.yPos>=slope.bottomEdge-slope.height*dist){slopeGradient=slope.height/slope.width;if(this.yVelocity>-5-slopeGradient){if(20<=this.yVelocity)return void this.kill(3);this.state!==PlayerState.Crouching&&(1<Math.abs(this.xVelocity)?this.state!==PlayerState.Running&&this.setRun():this.setIdle()),this.yVelocity=0,this.rotationDest=45*slopeGradient,this.yPos=slope.bottomEdge-slope.height*dist+2,this.yPos<slope.height&&(this.yPos=slope.height),this.currentSlope=slope,this.scaleHistory=4e3,this.currentZipline=!1,this.falling=!1,this.scaling=!1,this.hanging=!1}}}else{var dist=(this.xPos-slope.leftEdge)/slope.width;if(this.yPos>=slope.bottomEdge-slope.height*dist){var slopeGradient=slope.height/slope.width;if(this.yVelocity>-5-slopeGradient){if(20<=this.yVelocity)return void this.kill(3);1<this.yVelocity&&(this.xVelocity=-this.yVelocity),this.state!==PlayerState.Crouching&&(1<Math.abs(this.xVelocity)?this.state!==PlayerState.Running&&this.setRun():this.setIdle()),this.yVelocity=0,this.rotationDest=-45*slopeGradient,this.yPos=slope.bottomEdge-slope.height*dist+2,this.currentSlope=slope,this.scaleHistory=4e3,this.currentZipline=!1,this.falling=!1,this.scaling=!1,this.hanging=!1}}}}}},Player.prototype.checkCheckpoint=function(){for(var i=0;i<this.main.checkpoints.length;i++){var checkpoint=this.main.checkpoints[i];if(SAT.testPolygonPolygon(this.bodyPolygon,checkpoint.boxPolygon)&&0===checkpoint.state)return checkpoint.trigger(),void this.checkpoint.set(checkpoint.xPos,checkpoint.yPos)}},Player.prototype.checkKeyObj=function(){for(var _i=0,_a=this.main.keyObjs;_i<_a.length;_i++){var key=_a[_i];key.alive&&(key.following||SAT.testPolygonPolygon(this.bodyPolygon,key.hitBoxPolygon)&&(this.heldKeys.push(key),this.keysObtained++,4===this.keysObtained&&this.main.achievements.gotAchievement("caretaker"),key.follow()))}},Player.prototype.checkKeyboard=function(){this.bouncing||(this.currentZipline||this.crouching||this.scaling||this.hanging||(this.keys.left.isDown()?(this.xVelocity>-this.maxVelocity?(this.xVelocity-=this.acc,0<this.xVelocity&&(this.xVelocity*=.5)):this.onIce?this.xVelocity+=.025*this.acc*this.main.gameSpeed:this.xVelocity+=.2*this.acc,"right"===this.facing&&(this.state===PlayerState.Pushing&&this.setRun(),this.faceLeft()),this.state===PlayerState.Idle&&this.setRun()):this.keys.right.isDown()?(this.xVelocity<this.maxVelocity&&(this.xVelocity+=this.acc,this.xVelocity<0?this.xVelocity*=.5:this.onIce?this.xVelocity-=.025*this.acc*this.main.gameSpeed:this.xVelocity-=.2*this.acc),"left"===this.facing&&(this.state===PlayerState.Pushing&&this.setRun(),this.faceRight()),this.state===PlayerState.Idle&&this.setRun()):(this.state!==PlayerState.Running&&this.state!==PlayerState.Pushing||this.setIdle(),this.falling?this.xVelocity*=.75:this.onIce?this.xVelocity*=.9:0<this.xVelocity?(this.xVelocity-=2*this.acc,this.xVelocity<1&&(this.xVelocity=this.forcedXVelocity=0)):this.xVelocity<0&&(this.xVelocity+=2*this.acc,-1<this.xVelocity&&(this.xVelocity=this.forcedXVelocity=0)))),this.forcedXVelocity*=.98,!this.keys.up.pressed()||this.crouching||this.falling?this.keys.up.pressed()&&this.falling&&!this.crouching&&this.jumpState===PlayerState.Jumping&&this.setJump(!0,PlayerState.JumpFrontFlip):this.jump(-8))},Player.prototype.checkCrouch=function(){if(!this.bouncing){if(!this.keys.down.pressed()||!this.falling||this.lastPool||this.diving||this.currentPole||this.state!==PlayerState.Falling&&(this.setJump(!0,PlayerState.JumpDown),this.yVelocity<0&&(this.yVelocity*=.5*this.main.gameSpeed),this.yPos+=.75*this.yVelocity),!this.keys.down.isDown()&&this.falling&&this.state===PlayerState.Jumping&&this.jumpState===PlayerState.JumpDown&&this.setJump(!0,PlayerState.Jumping),!(this.swimming||this.falling||this.scaling||this.hanging||this.kicking))if(this.keys.down.isDown()){if(this.currentZipline)return this.falling=!0,this.setJump(),this.lastZipline=this.currentZipline,void(this.currentZipline=null);if(this.currentPole)return this.setJump(),this.currentPole=null,void(this.poleTimer=0);this.crouching?this.xVelocity<1&&-1<this.xVelocity?(this.state===PlayerState.Sliding&&(this.sprite.animations.frame<8?(this.sprite.animations.frame=8,this.sprite.animations.paused=!1):this.sprite.animations.currentAnim.isFinished&&this.setCrouch()),this.crouching=!0,this.xVelocity=this.forcedXVelocity=0):!this.onSpeedBlock||this.keys.left.isDown()||this.keys.right.isDown()?this.onIce?this.xVelocity*=.99:this.xVelocity*=.97:((8<this.sprite.animations.currentAnim.frame||this.sprite.animations.currentAnim!==this.sprite.animations.getAnimation("crouch"))&&this.setCrouch(),this.crouching=!0,this.xVelocity=this.forcedXVelocity=0):this.xVelocity<2&&-2<this.xVelocity?(this.setCrouch(),this.crouching=!0,this.xVelocity=this.forcedXVelocity=0):(this.currentSlope?this.keys.down.isDown()?(this.setCrouch(),this.crouching=!0,this.xVelocity=this.forcedXVelocity=0):this.crouching=!0:this.state!=PlayerState.Sliding&&(this.main.sounds.playSound("slide"),this.setSlide()),this.crouching=!0)}else if((this.state===PlayerState.Sliding||this.state===PlayerState.Crouching)&&(7===this.sprite.animations.frame&&(this.sprite.animations.frame=8,this.sprite.animations.paused=!1),this.sprite.animations.currentAnim.isFinished)){this.setIdle(),this.crouching=!1,this.updateHitBoxesPos();for(var _i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];SAT.testPolygonPolygon(this.bodyPolygon,block.rightBoundPolygon)?this.xPos=block.rightEdge+7:SAT.testPolygonPolygon(this.bodyPolygon,block.leftBoundPolygon)&&(this.xPos=block.leftEdge-7)}}(this.scaling||this.hanging)&&this.keys.down.isDown()&&(this.scaling=!1,this.unhang(),this.setJump())}},Player.prototype.checkZipline=function(){this.currentZipline=null;for(var i=0;i<this.main.ziplines.length;i++){var zipline=this.main.ziplines[i];if(zipline!==this.lastZipline&&(!(this.xPos-40>zipline.rightEdge||this.xPos+40<zipline.leftEdge||this.yPos-80>zipline.bottomEdge||this.yPos+80<zipline.topEdge)&&SAT.testPolygonPolygon(this.handsPolygon,zipline.hitPolygon)))if("left"==zipline.direction){var linePoint=(zipline.startPos.x-this.xPos)*zipline.scope+zipline.startPos.y+25;this.currentZipline||(this.yVelocity=0),this.xVelocity,this.yVelocity+=1,this.xVelocity-=1.5*zipline.scope,this.xVelocity<0&&"right"===this.facing&&this.faceLeft(),this.state!=PlayerState.Zipping&&(this.setZip(),this.main.sounds.playSound("ziplineFull")),this.yPos=linePoint+5,this.currentZipline=zipline,this.scaleHistory=4e3,this.lastZipline=null,this.falling=!1}else{linePoint=(this.xPos-zipline.startPos.x)*zipline.scope+zipline.startPos.y+this.height;this.currentZipline||(this.yVelocity=0),this.xVelocity<8&&(this.yVelocity+=1,this.xVelocity+=1.3*zipline.scope),0<this.xVelocity&&"left"===this.facing&&this.faceRight(),this.state!=PlayerState.Zipping&&(this.setZip(),this.main.sounds.playSound("ziplineFull")),this.yPos=linePoint-4,this.currentZipline=zipline,this.scaleHistory=4e3,this.lastZipline=null,this.falling=!1}}},Player.prototype.checkPoleCollisions=function(){if(10<=this.poleTimer++)for(var i=0;i<this.main.poles.length;i++){var pole=this.main.poles[i];SAT.testPolygonPolygon(this.handsPolygon,pole.hitBoxPolygon)?this.currentPole||(this.xVelocity=this.forcedXVelocity=0,this.yVelocity=0,this.currentPole=pole,this.falling=!1,this.rotation=0,this.xPos=this.currentPole.xPos-2,this.yPos=this.currentPole.yPos+30):SAT.testPolygonPolygon(this.bodyPolygon,pole.hitBoxPolygon)&&(0<this.xVelocity?(this.xVelocity=this.forcedXVelocity=0,this.xPos=pole.xPos-5):this.xVelocity<0&&(this.xVelocity=this.forcedXVelocity=0,this.xPos=pole.xPos+5))}},Player.prototype.performSwing=function(){this.xPos=this.currentPole.xPos,this.yPos=this.currentPole.yPos+30,this.xVelocity=this.forcedXVelocity=0,this.yVelocity=0,this.rotationDest=0,this.falling=!1,this.state!==PlayerState.Swinging&&this.setSwing(),this.currentPole.redSection.alpha-=.15*(this.currentPole.redSection.alpha-1),"right"===this.facing?this.currentPole.redSection.rotation=30*Math.PI/180:this.currentPole.redSection.rotation=150*Math.PI/180,this.scaleHistory=4e3,this.lastZipline=null},Player.prototype.checkDeath=function(){this.updateHitBoxesPos();for(var i=0;i<this.main.obstacles.length;i++){var obstacle=this.main.obstacles[i];if(obstacle.alive)switch(obstacle.obstacleType){case"spike":var spike=obstacle;(SAT.testPolygonPolygon(this.bodyPolygon,spike.deathBoxPolygon)||SAT.testPolygonPolygon(this.headPolygon,spike.deathBoxPolygon))&&this.kill();break;case"buzzsaw":var buzzsaw=obstacle;(SAT.testCirclePolygon(buzzsaw.deathCircle,this.bodyPolygon)||SAT.testCirclePolygon(buzzsaw.deathCircle,this.headPolygon))&&this.kill(buzzsaw.killValue);break;case"shurikan":var shurikan=obstacle;(SAT.testPolygonPolygon(this.bodyPolygon,shurikan.hitBoxPoly)||SAT.testPolygonPolygon(this.headPolygon,shurikan.hitBoxPoly))&&this.kill(9);break;case"quadrant":for(var _i=0,_a=obstacle.deathHitBoxPolygons;_i<_a.length;_i++){var hit=_a[_i];(SAT.testPolygonPolygon(this.bodyPolygon,hit)||SAT.testPolygonPolygon(this.headPolygon,hit))&&this.kill(10)}break;case"laser":var laser=obstacle;(SAT.testPolygonPolygon(this.bodyPolygon,laser.deathHitBoxPolygon)||SAT.testPolygonPolygon(this.headPolygon,laser.deathHitBoxPolygon))&&this.kill(14);break;case"reaper":for(var _b=0,_c=obstacle.deathHitBoxes;_b<_c.length;_b++){var death=_c[_b];(SAT.testPolygonPolygon(this.bodyPolygon,death)||SAT.testPolygonPolygon(this.headPolygon,death))&&this.kill(8)}break;case"spark":var spark=obstacle;(SAT.testPolygonPolygon(this.totalPolygon,spark.deathBoxPolygon)||SAT.testPolygonPolygon(this.headPolygon,spark.deathBoxPolygon))&&this.kill(11,!0)}}},Player.prototype.performKick=function(){this.kickBlock.stuckRight?(this.kickBlock.xVelocity=-15,this.xPos-=10):(this.kickBlock.xVelocity=15,this.xPos+=10),this.kickBlock.stuckLeft=this.kickBlock.stuckRight=!1,this.kickBlock.xPos+=this.kickBlock.xVelocity,this.kicking=!1,this.kickBlock=null,this.tarKickX=0,this.crouching=!1,this.main.sounds.playSound("kickBlock"),this.jump(-5,!1)},Player.prototype.updateGravity=function(){this.yVelocity+=this.main.gravity*this.main.gameSpeed,this.yVelocity>this.fallingMax?(this.state!=PlayerState.Falling&&(this.setFall(),this.diving=!1),this.rotationDest+=-this.container.scale.x*this.yVelocity*.25*this.main.gameSpeed,(this.rotation<-150||150<this.rotation)&&(this.kill(5),this.main.sounds.fall.play())):this.falling&&this.yVelocity,this.state!==PlayerState.Zipping||this.currentZipline||(this.setJump(),this.falling=!0)},Player.prototype.checkPoolCollisions=function(){for(var touchingAny=!1,i=0;i<this.main.pools.length;i++){var pool=this.main.pools[i];if(SAT.testPolygonPolygon(this.bodyPolygon,pool.totalPolygon)){if(touchingAny=!0,pool.prevElec)return void this.kill(12,!0);if(this.state!==PlayerState.Swimming&&0<=this.yVelocity){this.main.sounds.playSound("splash1");for(var i_1=0;i_1<5;i_1++)this.main.createColorParticle(this.xPos+10*Math.random()-5,this.yPos-this.height/2,10*Math.random()-5,-10*Math.random(),56814,4,!0,!0);this.currentPool=pool,this.swimming=!0,this.scaling=!1,this.hanging=!1,this.falling=!1,this.crouching=!1,this.diving=!1,this.faceRight(),this.setSwim(),this.main.playerUnderLayer.addChild(this.container),this.rotation=0,this.scaleHistory=4e3,this.lastZipline=null,this.rotationDest=0}}if(this.yVelocity<0&&SAT.testPolygonPolygon(this.feetPolygon,pool.topPolygon)){this.main.sounds.playSound("splash1"),this.lastPool=pool,this.state===PlayerState.Swimming&&(this.jump(-6),this.poolCoolDown=15,this.main.playerLayer.addChild(this.container));for(var i_2=this.rotation=0;i_2<5;i_2++)this.main.createColorParticle(this.xPos+10*Math.random()-5,this.yPos-this.height/2,10*Math.random()-5,-10*Math.random(),56814,4,!0,!0);this.breathe<90&&this.main.achievements.gotAchievement("gasping")}}touchingAny||(this.swimming=!1,this.state===PlayerState.Swimming&&(this.setJump(),this.falling=!0),this.currentPool=null,0<this.poolCoolDown&&this.poolCoolDown--)},Player.prototype.getSwim=function(){if(this.state==PlayerState.Swimming){if(this.keys.up.isDown()||this.keys.down.isDown()||(this.xVelocity*=.85,this.yVelocity*=.85,this.xVelocity<1&&-1<this.xVelocity&&(this.xVelocity=this.forcedXVelocity=0),this.yVelocity<1&&-1<this.yVelocity&&(this.yVelocity=0)),this.currentCannon||(this.keys.left.isDown()?this.sprite.rotation-=7*Math.PI/180:this.keys.right.isDown()&&(this.sprite.rotation+=7*Math.PI/180),this.swimmingLegs.push(this.sprite.rotation),4<this.swimmingLegs.length&&(this.legSprite.rotation=this.swimmingLegs.shift())),!this.currentCannon&&this.keys.up.isDown()){this.keys.up.pressed()&&(this.sprite.animations.currentAnim.stop(!0),this.sprite.animations.play("swim",null,!1));var rad=this.sprite.rotation-Math.PI/2,xInc=Math.cos(rad),yInc=Math.sin(rad),speed=3;this.xVelocity+=xInc,this.yVelocity+=yInc,0<xInc&&this.xVelocity>xInc*speed?this.xVelocity=xInc*speed:xInc<0&&this.xVelocity<xInc*speed&&(this.xVelocity=xInc*speed),0<yInc&&this.yVelocity>yInc*speed?this.yVelocity=yInc*speed:yInc<0&&this.yVelocity<yInc*speed&&(this.yVelocity=yInc*speed),Math.random()<.3&&this.main.createColorParticle(this.xPos+10*Math.random()-5,this.yPos-.5*this.height+10*Math.random()-5,-this.xVelocity/2+Math.random(),-this.yVelocity/2+Math.random(),56814,4,!0,!0)}else 4===this.sprite.frame&&(this.sprite.animations.paused=!1);if(!this.currentCannon&&this.keys.down.isDown()){rad=this.sprite.rotation-Math.PI/2,xInc=-Math.cos(rad),yInc=-Math.sin(rad),speed=2;this.xVelocity+=xInc,this.yVelocity+=yInc,0<xInc&&this.xVelocity>xInc*speed?this.xVelocity=xInc*speed:xInc<0&&this.xVelocity<xInc*speed&&(this.xVelocity=xInc*speed),0<yInc&&this.yVelocity>yInc*speed?this.yVelocity=yInc*speed:yInc<0&&this.yVelocity<yInc*speed&&(this.yVelocity=yInc*speed)}this.xPos+=this.xVelocity,this.yPos+=this.yVelocity}},Player.prototype.checkSwimBlockCollisions=function(){for(var i=0;i<this.main.blocks.length;i++){var block=this.main.blocks[i];if(block.alive&&!(block.rightEdge<this.xPos-40||block.leftEdge>this.xPos+40||block.topEdge>this.yPos+80||block.bottomEdge<this.yPos-80)){if(0<this.keysObtained&&"lock"===block.blockType){var lockBlock=block;if(!lockBlock.unlocked&&SAT.testPolygonPolygon(this.totalPolygon,block.totalBoundPolygon)){lockBlock.unlock(),this.heldKeys.pop().useKey(),this.keysObtained--;continue}}SAT.testPolygonPolygon(this.totalPolygon,block.topBoundPolygon)?(this.yPos=block.topEdge-3,this.yVelocity*=-0,!0):SAT.testPolygonPolygon(this.totalPolygon,block.bottomBoundPolygon)?(this.yVelocity*=-.5,this.yPos=block.bottomEdge+this.height-2):SAT.testPolygonPolygon(this.totalPolygon,block.leftBoundPolygon)?(this.xVelocity*=-.5,this.xPos=block.leftEdge-7):SAT.testPolygonPolygon(this.totalPolygon,block.rightBoundPolygon)&&(this.xVelocity*=-.5,this.xPos=block.rightEdge+7)}}},Player.prototype.cannonLogic=function(){this.swimming?(this.sprite.rotation=this.currentCannon.rad+90,360<this.sprite.rotation&&(this.sprite.rotation-=360)):(this.rotation=180*this.currentCannon.rad/Math.PI+90,this.rotationDest=this.rotation,360<this.rotation&&(this.rotation-=360),360<this.rotationDest&&(this.rotationDest-=360)),this.falling=!1,this.yVelocity=this.xVelocity=this.forcedXVelocity=0;this.xPos=this.currentCannon.xPos+50*Math.cos(this.currentCannon.rad),this.yPos=this.currentCannon.yPos+50*Math.sin(this.currentCannon.rad),this.swimming||this.setIdle(),this.keys.up.pressed()&&(this.currentCannon.firing=!0)},Player.prototype.checkCannonCollisions=function(){for(var _i=0,_a=this.main.cannons;_i<_a.length;_i++){var cannon=_a[_i];if(!cannon.alive)return;if(Math.pow(cannon.xPos-this.xPos,2)+Math.pow(cannon.yPos-this.yPos,2)<7225){this.currentCannon||(this.container.parent.removeChild(this.container),this.main.playerUnderLayer.addChild(this.container)),this.main.sounds.playSound("cannonEnter"),this.currentCannon=cannon;break}}},Player.prototype.respawn=function(){this.main.resetDeath(),this.xVelocity=this.forcedXVelocity=0,this.yVelocity=0,this.spriteYOff=0,this.xPos=this.checkpoint.x,this.yPos=this.checkpoint.y,this.container.scale.set(1,1),this.rotation=0,this.rotationDest=0,this.falling=!0,this.hanging=!1,this.scaling=!1,this.crouching=!1,this.bouncing=!1,this.swimming=!1,this.kicking=!1,this.diving=!1,this.currentHang=null,this.lastPool=null,this.currentPole=null,this.poleTimer=0,this.currentCannon=null,this.scaleHistory=4e3,this.lastZipline=null,this.breathe=this.maxBreathe,this.container.visible=!0,this.faceRight(),this.setSpawn(),this.alive=!1;for(var _i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];"bounce"===block.blockType&&(block.landed=null)}},Player.prototype.kill=function(reason,electricity){if(void 0===reason&&(reason=0),void 0===electricity&&(electricity=!1),!this.god){this.currentZipline=null;electricity?this.main.sounds.playSound("electricity"):Math.random()<.5?this.main.sounds.playSound("death1"):this.main.sounds.playSound("death2"),this.main.playerDeath();for(var i=0;i<5;i++)this.main.createColorParticle(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),16711680);this.main.createPlayerGib(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),"playerHead"),this.main.createPlayerGib(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),"playerBody",2*Math.random()*Math.PI,8*Math.random()-4),this.main.createPlayerGib(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),"playerArm",2*Math.random()*Math.PI,8*Math.random()-4),this.main.createPlayerGib(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),"playerArm",2*Math.random()*Math.PI,8*Math.random()-4),this.main.createPlayerGib(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),"playerLeg",2*Math.random()*Math.PI,8*Math.random()-4),this.main.createPlayerGib(this.xPos+10*Math.random()-5,this.yPos-this.height*Math.random(),10*Math.random()-5,-10*Math.random(),"playerLeg",2*Math.random()*Math.PI,8*Math.random()-4),this.container.visible=!1,this.keysObtained=0,this.heldKeys=[],this.respawn(),this.main.deathText.show(this.xPos,this.yPos,getDeathText(reason))}},Player.prototype.checkStar=function(){for(var i=0;i<this.main.stars.length;i++){var star=this.main.stars[i];if(!star.alive)return;if(SAT.testPolygonPolygon(this.totalPolygon,star.hitBoxPolygon)){star.getStar();for(var i_3=0;i_3<15;i_3++)this.main.createColorParticle(star.xPos,star.yPos,10*Math.random()-5,-10*Math.random(),16763904)}}},Player.prototype.animationTick=function(){switch(this.state){case PlayerState.Running:5<=this.sprite.animations.frame&&this.prevFrame<5&&this.main.sounds.playSound("footstep"),11<=this.sprite.animations.frame&&this.prevFrame<11&&this.main.sounds.playSound("footstep"),17<=this.sprite.animations.frame&&this.prevFrame<17&&this.main.sounds.playSound("footstep");break;case PlayerState.Sliding:7<=this.sprite.animations.frame&&this.prevFrame<7&&(this.sprite.animations.paused=!0,this.sprite.animations.frame=7);break;case PlayerState.Crouching:7<=this.sprite.frame&&this.prevFrame<7&&(this.sprite.animations.paused=!0,this.sprite.animations.frame=7);break;case PlayerState.Spawning:this.stateTime<=0?(this.setIdle(),this.alive=!0,this.main.firstSpawn&&(this.main.firstSpawn=!1,this.main.followingWire||(this.main.timerLive=!0))):this.stateTime--;break;case PlayerState.Kicking:if(this.stateTime<=0)this.performKick(),this.sprite.animations.paused=!1;else{var dist=this.tarKickX-this.xPos;this.xPos+=dist/5,Math.abs(dist)<.5&&(this.xPos=this.tarKickX),this.stateTime--}break;case PlayerState.Swinging:32<=this.sprite.frame&&this.sprite.animations.currentAnim.setFrame(2),4<=this.sprite.frame&&this.prevFrame<4&&this.main.sounds.playSound("poleWoosh");break;case PlayerState.Swimming:4<=this.sprite.frame&&this.prevFrame<4&&(this.sprite.animations.paused=!0,this.sprite.animations.frame=4)}this.prevFrame=this.sprite.frame},Player.prototype.cameraLogic=function(){if(this.alive||!this.alive){var halfWidth=this.game.width/2,halfHeight=this.game.height/2;if(this.lookingAround)if(this.state!==PlayerState.Idle&&this.state!==PlayerState.Swimming&&this.state!==PlayerState.Hanging&&(this.lookingAround=!1),this.main.keys.isScreenButtonDown())this.lookingAround=!1;else{var maxXOff=this.game.device.desktop?this.game.width/4:this.game.width/2,maxYOff=this.game.device.desktop?this.game.height/4:this.game.height/2;tarX=(this.game.input.activePointer.position.x-halfWidth)/halfWidth*maxXOff+this.xPos,tarY=(this.game.input.activePointer.position.y-halfHeight)/halfHeight*maxYOff+this.yPos,distX=tarX-this.game.camera.x-halfWidth,distY=tarY-this.game.camera.y-halfHeight;(dist=Math.sqrt(Math.pow(this.game.camera.y-tarY,2)+Math.pow(this.game.camera.x-tarX,2)))<.5?(this.game.camera.x=tarX,this.game.camera.y=tarY):(this.game.camera.x+=distX/15,this.game.camera.y+=distY/15)}else{var shake=0;10<this.yVelocity&&(shake=Math.random()*this.yVelocity*2);var tarX=this.xPos-halfWidth+shake,tarY=this.yPos-halfHeight+shake,dist=Math.sqrt(Math.pow(this.game.camera.y-tarY,2)+Math.pow(this.game.camera.x-tarX,2)),distX=tarX-this.game.camera.x,distY=tarY-this.game.camera.y;dist<.5?(this.game.camera.x=tarX,this.game.camera.y=tarY):(this.game.camera.x+=distX/4,this.game.camera.y+=distY/4)}}},Player.prototype.getRotation=function(){var rotationSpeed=5+Math.abs(this.xVelocity);this.rotationDest=this.rotationDest%360,this.rotation=this.rotation%360,Math.abs(this.rotationDest-this.rotation)<=rotationSpeed&&(this.rotation=this.rotationDest),180<Math.abs(this.rotationDest-this.rotation)&&(this.rotationDest<this.rotation?this.rotationDest+=360:this.rotationDest-=360),this.rotationDest>this.rotation?this.rotation+=rotationSpeed+(this.rotationDest-this.rotation)/3:this.rotationDest<this.rotation&&(this.rotation-=rotationSpeed-(this.rotationDest-this.rotation)/3)},Player.prototype.incVelocities=function(){this.currentCannon||(this.xPos+=(this.xVelocity+this.forcedXVelocity)*this.main.gameSpeed,this.yPos+=this.yVelocity*this.main.gameSpeed,this.currentSlope&&(this.currentSlope.right?this.yPos+=this.xVelocity*this.main.gameSpeed+1:this.yPos-=this.xVelocity*this.main.gameSpeed+1))},Player.prototype.loseKey=function(key){var ii=this.heldKeys.indexOf(key);this.heldKeys.splice(ii,1),this.keysObtained--},Player.prototype.update=function(){var prevX=this.xPos,prevY=this.yPos,prevRot=this.rotation;if(this.animationTick(),this.alive){if(this.porting){var distX=this.main.finishPortal.xPos-this.xPos,distY=this.main.finishPortal.yPos-this.yPos;this.xPos+=distX/10,this.yPos+=distY/10,this.container.rotation+=8-this.container.scale.x,this.container.scale.x*=.95,this.container.scale.y*=.95,Math.abs(this.container.scale.x)<.3&&this.main.finishLevel(),this.updatePositions()}else if(this.main.finishPortal&&SAT.testPolygonPolygon(this.totalPolygon,this.main.finishPortal.hitBoxPolygon))this.porting=!0,this.main.timerLive=!1,this.setFall(),this.scoreUpdated||(Constants.actFinishTime=Date.now()-Constants.actStartTime,this.scoreUpdated=!0);else if(this.state===PlayerState.Spawning);else{this.swimming||this.kicking||this.currentCannon||this.main.followingWire||this.checkKeyboard(),this.checkCrouch(),this.swimming||this.currentCannon||this.updateGravity(),this.incVelocities(),this.hangTime<this.maxHangCoolDown&&this.hangTime++,this.checkPoolCollisions(),this.swimming?(this.getSwim(),this.checkSwimBlockCollisions(),this.breathe-=this.main.gameSpeed,this.breathe<=0&&this.kill(4)):(this.currentCannon||(this.checkBlocks(),this.checkSlopeCollisions(),this.currentPole?this.performSwing():this.checkPoleCollisions()),(this.falling||this.currentZipline)&&0<this.yVelocity&&this.checkZipline(),this.breathe<this.maxBreathe?this.breathe+=4*this.main.gameSpeed:this.breathe=this.maxBreathe),this.currentCannon?this.cannonLogic():this.checkCannonCollisions(),this.checkKeyObj(),this.checkCheckpoint(),this.checkDeath(),this.checkStar();for(var _i=0,_a=this.main.lightSwitches;_i<_a.length;_i++){var lightSwitch=_a[_i];SAT.testPolygonPolygon(this.totalPolygon,lightSwitch.hitBoxPolygon)&&this.main.goDark()}this.swimming?this.rotation=0:this.getRotation(),this.xPos===prevX&&this.yPos===prevY&&this.rotation===prevRot||this.updatePositions(),this.swimming||(this.sprite.position.y=this.spriteYOff),!this.currentZipline&&this.main.sounds.ziplineFull.isPlaying&&this.main.sounds.ziplineFull.stop()}for(var _b=0,_c=this.main.breatheBlasters;_b<_c.length;_b++){var bb=_c[_b];SAT.testPolygonPolygon(this.totalPolygon,bb.hitPoly)&&(this.breathe+=5,this.breathe>this.maxBreathe&&(this.breathe=this.maxBreathe))}this.breatheBar(),this.game.device.desktop&&this.pressDown.blink()}this.main.followingWire||this.cameraLogic()},Player.prototype.breatheBar=function(){if(this.swimming){this.breatheGroup.visible=!0,this.breatheGroup.rotation=-this.container.rotation,this.breatheGroup.scale.x<1&&(this.breatheGroup.scale.x+=-.1,1<this.breatheGroup.scale.x&&(this.breatheGroup.scale.x=1),this.breatheGroup.scale.y=this.breatheGroup.scale.x,this.breatheGroup.alpha=this.breatheGroup.scale.x);for(var showNum=Math.floor(this.breathe/60),i=0;i<10;i++){var bb=this.breatheBlocks[i];showNum<i?0<bb.alpha&&(bb.alpha-=.1,bb.y-=.5,bb.alpha<0&&(bb.alpha=0,bb.y=-85)):bb.alpha<1&&(bb.alpha+=.1,bb.y=-65,1<bb.alpha&&(bb.alpha=1,bb.y=-65))}}else this.breatheGroup.visible=!1},Player.prototype.pause=function(){this.sprite&&this.sprite.animations&&this.sprite.animations.currentAnim&&(this.sprite.animations.paused=!0)},Player.prototype.resume=function(){this.sprite&&this.sprite.animations.currentAnim&&(this.sprite.animations.paused=!1)},Player.prototype.hide=function(){this.container.visible=!1,this.alive=!1},Player.prototype.updatePositions=function(){this.container.x=this.xPos,this.container.y=this.yPos,this.container.rotation=this.rotation*Math.PI/180,this.updateHitBoxesPos()},Player}(Entity),Particle=function(_super){function Particle(main,game,layer,size,collide,liquid,fadeAfter){var _this=_super.call(this,main)||this;return _this.fadeAfter=150,_this.size=size,_this.hitBox=new SAT.Box(new SAT.Vector(0,0),size,size),_this.collide=collide,_this.alive=!1,_this.fadeAfter=fadeAfter,_this.liquid=liquid,_this}return __extends(Particle,_super),Particle.prototype.spawnBase=function(x,y,xVelocity,yVelocity){this.xPos=x,this.yPos=y,this.xVelocity=xVelocity,this.yVelocity=yVelocity,this.hitBox.pos.x=x-.5*this.size,this.hitBox.pos.y=y-.5*this.size,this.hitBoxPolygon=this.hitBox.toPolygon(),this.fadeTime=0,this.alive=!0,this.water=!1,this.onIce=!1},Particle.prototype.destroy=function(){this.hitBoxPolygon=null,this.hitBox=null,this.main.particleNum--,this.alive=!1},Particle.prototype.multAlpha=function(alpha){},Particle.prototype.update=function(){this.alive&&(this.getWater(),this.water?(this.xPos+=.1*this.xVelocity*this.main.gameSpeed,this.yPos+=.5*this.yVelocity*this.main.gameSpeed,this.liquid&&(this.yPos+=.5*this.yVelocity*this.main.gameSpeed,-1<this.yVelocity&&(this.yVelocity-=.05*this.main.gameSpeed))):(this.xPos+=this.xVelocity*this.main.gameSpeed,this.yPos+=this.yVelocity*this.main.gameSpeed),this.collide&&this.yVelocity<12&&(this.water?this.liquid||(this.yVelocity+=.25*this.main.gravity*this.main.gameSpeed):this.yVelocity+=this.main.gravity*this.main.gameSpeed),1<=this.main.gameSpeed&&(this.water||this.onIce?this.xVelocity*=.99:this.xVelocity*=.95),Math.abs(this.xVelocity)<.1&&(this.xVelocity=0),this.collide&&this.runCollisions())},Particle.prototype.runCollisions=function(){for(var i=0;i<this.main.blocks.length;i++){var block=this.main.blocks[i];if(block.alive)if(SAT.testPolygonPolygon(this.hitBoxPolygon,block.topBoundPolygon)){if(4<=this.yVelocity?this.yVelocity*=-.25:1<=this.yVelocity&&(this.yVelocity=0),this.yPos=block.topEdge-.5*this.size,this.xPos+=block.xVelocity,"speed"===block.blockType){var speedBlock=block;this.xVelocity+=speedBlock.speedInc}"ice"===block.blockType&&(this.onIce=!0)}else if(SAT.testPolygonPolygon(this.hitBoxPolygon,block.bottomBoundPolygon)&&this.yVelocity<0)this.yVelocity*=-.5,this.yPos=block.bottomEdge,0<this.xVelocity?this.xVelocity-=.1:this.xVelocity<0&&(this.xVelocity+=.1),this.yPos+=this.yVelocity;else if(SAT.testPolygonPolygon(this.hitBoxPolygon,block.leftBoundPolygon))this.xVelocity*=-.5,this.xPos=block.leftEdge-.5*this.size,this.xPos+=this.xVelocity;else if(SAT.testPolygonPolygon(this.hitBoxPolygon,block.rightBoundPolygon))this.xVelocity*=-.5,this.xPos=block.rightEdge+.5*this.size,this.xPos+=this.xVelocity;else{for(var _i=0,_a=this.main.pools;_i<_a.length;_i++){var pool=_a[_i];if(SAT.testPolygonPolygon(this.hitBoxPolygon,pool.totalPolygon)){if(this.liquid&&!this.water)return void this.destroy();this.water||(this.yVelocity=0),this.water=!0}}if(this.liquid&&!this.water)return void this.destroy()}}},Particle.prototype.getWater=function(){this.water=!1;for(var _i=0,_a=this.main.pools;_i<_a.length;_i++){var pool=_a[_i];if(SAT.testPolygonPolygon(this.hitBoxPolygon,pool.totalPolygon)){this.water=!0;break}}},Particle}(Entity),PlayerGib=function(_super){function PlayerGib(main,game,layer,spriteKey,size,collide){var _this=_super.call(this,main,game,layer,size,collide,!1,150)||this;return _this.sprite=layer.create(0,0,spriteKey),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this}return __extends(PlayerGib,_super),PlayerGib.prototype.spawn=function(x,y,xVelocity,yVelocity,rotation,rotSpeed){_super.prototype.spawnBase.call(this,x,y,xVelocity,yVelocity),this.rotation=rotation,this.rotSpeed=rotSpeed,this.sprite.position.set(x,y),this.sprite.rotation=rotation},PlayerGib.prototype.update=function(){if(this.alive){if(this.fadeTime>=this.fadeAfter){if(this.sprite.alpha-=.1*this.main.gameSpeed,this.sprite.alpha<=0)return void this.destroy()}else this.fadeTime++;var prevX=this.xPos,prevY=this.yPos;_super.prototype.update.call(this),this.alive&&(this.rotation+=this.rotSpeed,0<this.rotSpeed?this.rotSpeed-=.5:this.rotSpeed<0&&(this.rotSpeed+=.5),Math.abs(this.rotSpeed)<.6&&(this.rotSpeed=0),prevX==this.xPos&&prevY==this.yPos||(this.sprite.position.set(this.xPos,this.yPos),this.sprite.rotation=this.rotation,this.hitBox.pos.x=this.xPos-.5*this.size,this.hitBox.pos.y=this.yPos-.5*this.size,this.hitBoxPolygon=this.hitBox.toPolygon()))}},PlayerGib.prototype.destroy=function(){this.alive&&(this.sprite&&(this.sprite.destroy(),this.sprite=null),_super.prototype.destroy.call(this))},PlayerGib}(Particle);!function(Vex3){var Game=function(_super){function Game(){var _this=_super.call(this,{enableDebug:!1,width:960,height:840,renderer:Phaser.AUTO,parent:"content",transparent:!0,antialias:!0,preserveDrawingBuffer:!1,physicsConfig:null,seed:"",state:null,forceSetTimeOut:!1})||this;return _this.clearBeforeRender=!0,Phaser.Device.whenReady(function(){document.getElementById("content").addEventListener("touchstart",function(e){_this.gameResumed(e)})}),h5branding.Branding.analyticsEnabled=!0,h5branding.SplashLoader.getInstance({gameId:"762c932b4db74c6da0c1d101b2da8be6",gameName:Constants.GAME_TITLE,gameTitle:Constants.GAME_SPLASH_TITLE,libs:[],version:version}).create().then(function(){Fabrique.RayGun.getInstance(),_this.state.add("preGame",{create:_this.stateCreator.bind(_this),preload:_this.statePreloader.bind(_this)},!0),languageDetector=new i18nextBrowserLanguageDetector(null),h5branding.Utils.LANGUAGE="none"}),_this}return __extends(Game,_super),Game.prototype.statePreloader=function(){var _this=this;libs.forEach(function(library){_this.load.script(library,library)})},Game.prototype.stateCreator=function(){this.plugins.add(PhaserSpine.SpinePlugin),this.plugins.add(PhaserCachebuster.CacheBuster),this.plugins.add(PhaserSuperStorage.StoragePlugin),this.plugins.add(PhaserI18n.Plugin,{fallbackLng:"en",load:"languageOnly",backend:{loadPath:"assets/locales/{{lng}}.json"}},languageDetector),this.storage.forcePromises=!0,h5branding.Utils.isOnDevice()&&void 0!==window.NativeStorage&&this.storage.setAdapter(new PhaserSuperStorage.StorageAdapters.CordovaStorage),this.state.add("Boot",VexBoot),this.state.add("Game",VexGameState),this.state.start("Boot"),this.state.remove("preGame")},Game}(Phaser.Game);Vex3.Game=Game}(Vex3||(Vex3={}));var ActState,Block=function(_super){function Block(main,game,layer){var _this=_super.call(this,main)||this;return _this.scalable=!0,_this.hangable=!0,_this.main=main,_this.game=game,_this.layer=layer,_this.passable=!1,_this}return __extends(Block,_super),Block.prototype.update=function(){this.landed&&this.specificLand()},Block.prototype.specificLand=function(){},Block.prototype.levelStart=function(){},Block.prototype.destroy=function(){this.topBound=null,this.topBoundPolygon=null,this.bottomBound=null,this.bottomBoundPolygon=null,this.leftBound=null,this.leftBoundPolygon=null,this.rightBound=null,this.rightBoundPolygon=null,this.lhBound=null,this.lhBoundPolygon=null,this.rhBound=null,this.rhBoundPolygon=null,this.totalBound=null,this.totalBoundPolygon=null,this.game=null,this.layer=null,_super.prototype.destroy.call(this)},Block.prototype.resetLevel=function(){this.landed=null},Block.prototype.reset=function(){this.landed=null},Block}(Entity);!function(ActState){ActState[ActState.Locked=0]="Locked",ActState[ActState.NotPlayed=1]="NotPlayed",ActState[ActState.Played=2]="Played",ActState[ActState.Challenge=3]="Challenge"}(ActState||(ActState={}));var ActBlock=function(_super){function ActBlock(main,game,layer,levelNum,level){var _this=_super.call(this,main,game,layer)||this;_this.hellEnabled=!1,_this.level=level,_this.levelNum=levelNum,_this.container=game.add.group(layer,"container"+levelNum),_this.sprite=_this.container.create(0,0,"actBlock"+levelNum),_this.sprite.visible=!1,_this.sprite.autoCull=!0;var title=_this.main.levels.levels[levelNum].name;if(_this.titleText=game.add.bitmapText(0,0,"grob24",title,28),_this.titleText.anchor.set(.5,.5),_this.titleText.visible=!1,-1!=level.topTime){var check=game.add.sprite(55,0,"actCheck");check.anchor.set(.5,.5),_this.titleText.addChild(check),"10"==level.id&&(check.x=65)}return _this.container.addChild(_this.titleText),_this.enterStage=_this.container.create(0,0,"enterLevelText"),_this.enterStage.anchor.set(.5,0),_this.enterStage.visible=!1,_this.downArrow=_this.container.create(0,0,"actDownArrow"),_this.downArrow.visible=!1,_this.timeText=game.add.bitmapText(0,0,"grob24","00:00",20),_this.timeText.position.set(-30,0),_this.timeText.visible=!1,_this.container.add(_this.timeText),_this.fastestTimeText=_this.container.create(0,0,"fastestTimeText"),_this.fastestTimeText.anchor.set(.5,.5),_this.fastestTimeText.visible=!1,_this.fastestTimeText.autoCull=!0,_this.rankText=_this.container.create(0,0,level.getRankSpriteKey()),_this.rankText.anchor.set(.5,.5),_this.rankText.scale.set(.5,.5),_this.rankText.visible=!1,_this.rankText.autoCull=!0,_this.completedText=_this.container.create(0,0,"completedText"),_this.completedText.anchor.set(.5,.5),_this.completedText.visible=!1,_this.completedText.autoCull=!0,_this.completeIcon=_this.container.create(0,0,"completedIcon"),_this.completeIcon.anchor.set(.5,.5),_this.completeIcon.visible=!1,_this.completeIcon.autoCull=!0,_this.starIcon=_this.container.create(0,0,"starIcon"),_this.starIcon.anchor.set(.5,.5),_this.starIcon.visible=!1,_this.starIcon.autoCull=!0,_this.challengeIcon=_this.container.create(0,0,"challengeIcon"),_this.challengeIcon.anchor.set(.5,.5),_this.challengeIcon.visible=!1,_this.challengeIcon.autoCull=!0,_this.hellBtn=new Phaser.Sprite(_this.game,0,0,"hellNormal"),_this.container.addChild(_this.hellBtn),_this.hellBtn.scale.set(.5,.5),_this.hellBtn.anchor.set(.5,.5),_this.hellCheckBox=new Phaser.Sprite(_this.game,0,0,"tickboxWhite"),_this.hellCheckBox.anchor.set(.5,.5),_this.hellCheckBox.frame=1,_this.container.addChild(_this.hellCheckBox),_this.hellCheckBox.inputEnabled=!0,_this.hellCheckBox.events.onInputUp.add(function(){_this.toggleTickBox()}),_this.alive=!1,_this.blockType="act",_this.hangable=!0,_this.scalable=!0,_this.setHellBtnPos(),_this.toggleHellBtnInput(!1,.5),_this}return __extends(ActBlock,_super),ActBlock.prototype.toggleTickBox=function(){this.hellCheckBox.frame=1==this.hellCheckBox.frame?0:1,this.hellEnabled?this.hellEnabled=!1:this.hellEnabled=!0},ActBlock.prototype.getHellText=function(){return this.hellEnabled?"clickHellTxt":"hellText"},ActBlock.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=140,this.height=140,this.container.position.set(x,y),10==this.levelNum?(this.width=160,this.height=160):(this.width=140,this.height=140),this.sprite.anchor.set(.5,.5),this.sprite.visible=!0,this.titleText.position.set(0,-25),this.titleText.visible=!0,this.enterStage.position.set(0,-25.5),this.enterStage.visible=!0,this.downArrow.position.set(-7,14),-1!=this.level.topTime?(Constants.actFinishTime=-1,this.state=ActState.Played,this.completedText.visible=!1,this.completedText.position.y=40,this.timeText.setText(timeDecoratorActBlock(this.level.topTime)),this.timeText.position.set(-62,40),this.timeText.visible=!0,this.rankText.position.set(35,53),this.rankText.visible=!0,this.fastestTimeText.position.set(0,35),this.fastestTimeText.visible=!0,this.starIcon.visible=!0,this.starIcon.position.set(0,0),"10"!=this.level.id?(this.challengeIcon.visible=!0,this.challengeIcon.position.set(45,0),this.level.challengeCompleted&&(this.challengeIcon.frame=1)):this.starIcon.position.set(45,0),this.level.gotStar&&(this.starIcon.frame=1),this.titleText.position.y=-50,this.completeIcon.visible=!0,this.completeIcon.position.set(-45,0),this.level.gotGold()&&(this.completeIcon.frame=1,"10"!=this.level.id&&(this.state=ActState.Challenge,this.downArrow.visible=!1))):(this.state=ActState.NotPlayed,this.downArrow.visible=!0),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*this.width,this.rightEdge=x+.5*this.width,this.topEdge=y-.5*this.height,this.bottomEdge=y+.5*this.height,this.alive=!0,this.prevLand=!1;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),this.width,this.height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),this.width,ActBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,ActBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,ActBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,this.height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,this.height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),this.width,ActBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-BasicBlock.TOP_BOUND_HEIGHT)),this.setHellBtnPos()},ActBlock.prototype.toggleHellBtnInput=function(enable,alphaValue){this.hellBtn.alpha=alphaValue,this.hellCheckBox.inputEnabled=enable,this.hellCheckBox.alpha=alphaValue},ActBlock.prototype.toggleHellBtnVisibility=function(enable){this.hellBtn.visible=enable,this.hellCheckBox.visible=enable},ActBlock.prototype.setHellBtnPos=function(){this.hellBtn.x=this.enterStage.x+this.enterStage.width/2-12,this.hellBtn.y=this.enterStage.y+this.enterStage.height+15,this.hellCheckBox.x=this.hellBtn.x-this.hellBtn.width+10,this.hellCheckBox.y=this.hellBtn.y+this.hellBtn.height+2},ActBlock.prototype.playerOffBlock=function(){if(0<this.enterStage.alpha&&(this.enterStage.alpha-=.1),this.completedText.alpha=this.enterStage.alpha,this.enterStage.alpha<=0){switch(this.state){case ActState.NotPlayed:var distY=0-this.titleText.position.y;this.titleText.position.y=this.titleText.position.y+distY/10,this.downArrow.alpha=this.enterStage.alpha;break;case ActState.Played:this.timeText.alpha<1&&(this.timeText.alpha+=.1),this.rankText.alpha=this.fastestTimeText.alpha=this.completeIcon.alpha=this.starIcon.alpha=this.challengeIcon.alpha=this.timeText.alpha,this.downArrow.alpha=this.enterStage.alpha;break;case ActState.Challenge:this.timeText.alpha<1&&(this.timeText.alpha+=.1),this.rankText.alpha=this.fastestTimeText.alpha=this.completeIcon.alpha=this.starIcon.alpha=this.challengeIcon.alpha=this.timeText.alpha,this.main.enableHellButton=!1}this.toggleHellBtnVisibility(!1)}},ActBlock.prototype.playerOnBlock=function(){switch(this.toggleHellBtnVisibility(!0),this.setHellBtnPos(),this.state){case ActState.NotPlayed:var distY=-40-this.titleText.position.y;Math.abs(distY)<1?this.titleText.position.y=-40:this.titleText.position.y=this.titleText.position.y+distY/8,0===distY&&(this.enterStage.alpha<1&&(this.enterStage.alpha+=.1),this.downArrow.alpha=this.enterStage.alpha);break;case ActState.Played:0<this.timeText.alpha&&(this.timeText.alpha-=.1),this.rankText.alpha=this.fastestTimeText.alpha=this.completeIcon.alpha=this.starIcon.alpha=this.challengeIcon.alpha=this.timeText.alpha,this.timeText.alpha<=0&&(this.enterStage.alpha<1&&(this.enterStage.alpha+=.1),this.completedText.alpha=this.enterStage.alpha);break;case ActState.Challenge:0<this.timeText.alpha&&(this.timeText.alpha-=.1),this.rankText.alpha=this.fastestTimeText.alpha=this.completeIcon.alpha=this.starIcon.alpha=this.challengeIcon.alpha=this.timeText.alpha,this.timeText.alpha<=0&&this.enterStage.alpha<1&&(this.enterStage.alpha+=.1),this.main.enableHellButton||(this.toggleHellBtnInput(!0,1),this.main.enableHellButton=!0)}},ActBlock.prototype.update=function(){this.landed?(this.playerOnBlock(),this.prevLand||this.main.rankTime.show(this.level)):(this.playerOffBlock(),this.prevLand&&this.main.rankTime.hide()),this.prevLand=!!this.landed},ActBlock.prototype.destroy=function(){this.titleText.destroy(),this.titleText=null,this.enterStage.destroy(),this.enterStage=null,this.downArrow.destroy(),this.downArrow=null,this.fastestTimeText.destroy(),this.fastestTimeText=null,this.timeText.destroy(),this.timeText=null,this.completedText.destroy(),this.completedText=null,this.completeIcon.destroy(),this.completeIcon=null,this.starIcon.destroy(),this.starIcon=null,this.challengeIcon.destroy(),this.challengeIcon=null,this.sprite.destroy(!1),this.sprite=null,this.container.destroy(),this.container=null},ActBlock.TOP_BOUND_HEIGHT=12,ActBlock}(Block),BasicBlock=function(_super){function BasicBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"basicBlockColors"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this}return __extends(BasicBlock,_super),BasicBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/this.sprite.width,height/this.sprite.height),this.sprite.anchor.set(.5,.5),this.sprite.frame=parseInt(this.main.currentLevelID),this.sprite.visible=!0,this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.xVelocity=0,this.yVelocity=0,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-BasicBlock.TOP_BOUND_HEIGHT))},BasicBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},BasicBlock.prototype.update=function(){this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},BasicBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},BasicBlock.prototype.reset=function(){},BasicBlock.TOP_BOUND_HEIGHT=12,BasicBlock}(Block),BlockedWall=function(_super){function BlockedWall(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"blockedWall"),_this.sprite.animations.add("blockedwall"),_this.sprite.animations.play("blockedwall",null,!0),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this.hangable=!1,_this.scalable=!1,_this}return __extends(BlockedWall,_super),BlockedWall.prototype.spawn=function(x,y,width,height,rotation,level){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.angle=rotation,this.sprite.anchor.set(.5,.5),this.sprite.frame=parseInt(this.main.currentLevelID),this.sprite.visible=!0,this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.xVelocity=0,this.yVelocity=0,level.colorFilter&&this.main.options.blend?this.sprite.filters=[level.colorFilter]:this.sprite.filters=null,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT)),-1!==level.topTime&&(this.alive=!1,this.sprite.visible=!1)},BlockedWall.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},BlockedWall.prototype.update=function(){this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},BlockedWall.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},BlockedWall.prototype.reset=function(){},BlockedWall.TOP_BOUND_HEIGHT=12,BlockedWall}(Block),BounceBlock=function(_super){function BounceBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.bounceStr=4,_this.container=_this.game.add.group(layer),_this.sprite=_this.container.create(0,0,"bounceBlock"),_this.sprite.autoCull=!0,_this.arrowAnimation=_this.container.create(0,0,"arrowAnimation"),_this.arrowAnimation.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.arrowAnimation.anchor.set(.5,.5),_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this.blockType="bounce",_this}return __extends(BounceBlock,_super),BounceBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.startY=y,this.spriteYOff=0,this.width=width,this.height=height,this.container.position.set(x,y),this.container.scale.set(width/100,height/100),this.arrowMask=this.game.add.graphics(0,0,this.container),this.main.options.blend?(this.arrowMask.beginFill(0),this.arrowMask.drawRect(-50,-50,100,100),this.arrowMask.endFill(),this.arrowAnimation.mask=this.arrowMask,this.arrowAnimation.animations.add("arrow"),this.arrowAnimation.play("arrow",60*this.main.gameSpeed,!0)):this.arrowAnimation.loadTexture("arrowStatic"),this.startScaleX=width/100,this.startScaleY=height/100,this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.bouncing=!1,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height,leftEdge=x-halfWidth,topEdge=y-halfHeight;this.totalBound=new SAT.Box(new SAT.Vector(leftEdge,topEdge),width,height),this.topBound=new SAT.Box(new SAT.Vector(leftEdge,topEdge),width,BasicBlock.TOP_BOUND_HEIGHT),this.lhBound=new SAT.Box(new SAT.Vector(leftEdge,topEdge),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.rhBound=new SAT.Box(new SAT.Vector(x,topEdge),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.leftBound=new SAT.Box(new SAT.Vector(leftEdge,topEdge),halfWidth,height),this.rightBound=new SAT.Box(new SAT.Vector(x,topEdge),halfWidth,height),this.bottomBound=new SAT.Box(new SAT.Vector(leftEdge,y+halfHeight-BasicBlock.TOP_BOUND_HEIGHT),width,BasicBlock.TOP_BOUND_HEIGHT),this.totalBoundPolygon=this.totalBound.toPolygon(),this.topBoundPolygon=this.topBound.toPolygon(),this.lhBoundPolygon=this.lhBound.toPolygon(),this.rhBoundPolygon=this.rhBound.toPolygon(),this.leftBoundPolygon=this.leftBound.toPolygon(),this.rightBoundPolygon=this.rightBound.toPolygon(),this.bottomBoundPolygon=this.bottomBound.toPolygon()},BounceBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height;var halfWidth=.5*this.width,halfHeight=.5*this.height,leftEdge=this.xPos-halfWidth,topEdge=this.yPos-halfHeight;this.totalBound.pos.x=leftEdge,this.totalBound.pos.y=topEdge,this.topBound.pos.x=leftEdge,this.topBound.pos.y=topEdge,this.lhBound.pos.x=leftEdge,this.lhBound.pos.y=topEdge,this.rhBound.pos.x=this.xPos,this.rhBound.pos.y=topEdge,this.leftBound.pos.x=leftEdge,this.leftBound.pos.y=topEdge,this.rightBound.pos.x=this.xPos,this.rightBound.pos.y=topEdge,this.bottomBound.pos.x=leftEdge,this.bottomBound.pos.y=this.yPos+this.height-BasicBlock.TOP_BOUND_HEIGHT,this.topBoundPolygon=this.topBound.toPolygon(),this.lhBoundPolygon=this.lhBound.toPolygon(),this.rhBoundPolygon=this.rhBound.toPolygon(),this.leftBoundPolygon=this.leftBound.toPolygon(),this.rightBoundPolygon=this.rightBound.toPolygon(),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.container.y=this.yPos},BounceBlock.prototype.update=function(){this.landed?this.specificLand():1==this.container.scale.x&&1==this.container.scale.y||(this.container.scale.y-=(this.container.scale.y-this.startScaleY)*(.15*this.main.gameSpeed),this.container.scale.x-=(this.container.scale.x-this.startScaleX)*(.15*this.main.gameSpeed),this.spriteYOff=(this.startScaleY-this.container.scale.y)*this.height*.5),this.container.position.y=this.yPos+2*this.spriteYOff},BounceBlock.prototype.specificLand=function(){this.container.scale.x+=.01*this.bounceStr*this.main.gameSpeed,this.container.scale.y-=.01*this.bounceStr*this.main.gameSpeed,this.spriteYOff=(this.startScaleY-this.container.scale.y)*this.height*.5,this.bouncing?(this.main.player.xPos=this.lockX,this.main.player.spriteYOff=2*this.spriteYOff+5,this.main.player.updatePositions()):(this.lockX=this.main.player.xPos,this.main.player.setCrouch(),this.main.player.bouncing=!0,this.bouncing=!0),this.container.scale.y<.25&&(this.main.player.yPos-=.5*this.height,this.main.player.xPos=this.lockX,this.main.player.jump(-35*this.height*.01),this.main.player.bouncing=!1,this.main.player.spriteYOff=0,this.bouncing=!1,this.main.sounds.playSound("bounce1"))},BounceBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.arrowAnimation.destroy(),this.arrowAnimation=null,this.arrowMask&&(this.arrowMask.destroy(),this.arrowMask=null),this.container.destroy(),this.container=null,_super.prototype.destroy.call(this)},BounceBlock}(Block),ExplosiveBlock=function(_super){function ExplosiveBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"explosiveBlock"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.alive=!1,_this.explodingOverlay=game.add.graphics(0,0,_this.layer),_this.sprite.addChild(_this.explodingOverlay),_this.hangable=!0,_this.scalable=!0,_this}return __extends(ExplosiveBlock,_super),ExplosiveBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.sprite.visible=!0,this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.explodingOverlay.beginFill(16777215,1),this.explodingOverlay.drawRect(0,0,width,height),this.explodingOverlay.visible=!0,this.explodingOverlay.position.set(-this.width/2,-this.height/2),this.explodingOverlay.alpha=0,this.xVelocity=0,this.yVelocity=0,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT))},ExplosiveBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},ExplosiveBlock.prototype.update=function(){this.exploding&&(this.sprite.scale.x-=.1*(this.sprite.scale.x-1.5),this.sprite.scale.y=this.sprite.scale.x,this.explodingOverlay.alpha+=.05,1<=this.explodingOverlay.alpha&&(this.main.exploding||this.main.explode())),this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},ExplosiveBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.explodingOverlay.destroy(),this.explodingOverlay=null,_super.prototype.destroy.call(this)},ExplosiveBlock.prototype.resetLevel=function(){this.explodingOverlay.visible=!1,this.exploding=!1,this.explodingOverlay.scale.set(1,1),this.explodingOverlay.alpha=1,this.sprite.scale.set(1,1)},ExplosiveBlock.prototype.reset=function(){},ExplosiveBlock.TOP_BOUND_HEIGHT=12,ExplosiveBlock}(Block),FallingBlock=function(_super){function FallingBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.container=_this.game.add.group(layer),_this.sprite=_this.container.create(0,0,"fallingBlock"),_this.sprite.autoCull=!0,_this.arrowAnimation=_this.container.create(0,0,"arrowAnimation"),_this.arrowAnimation.autoCull=!0,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this.container.visible=!1,_this}return __extends(FallingBlock,_super),FallingBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.startY=y,this.width=width,this.height=height,this.container.position.set(x,y),this.container.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.arrowAnimation.anchor.set(.5,.5),this.arrowAnimation.scale.set(1,-1),this.main.options.blend?(this.arrowMask=this.game.add.graphics(0,0,this.container),this.arrowMask.beginFill(0),this.arrowMask.drawRect(-50,-50,100,100),this.arrowMask.endFill(),this.arrowAnimation.mask=this.arrowMask,this.arrowAnimation.animations.add("arrow"),this.arrowAnimation.play("arrow",60*this.main.gameSpeed,!0)):this.arrowAnimation.loadTexture("arrowStatic"),this.container.visible=!0,this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.falling=!1,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-BasicBlock.TOP_BOUND_HEIGHT))},FallingBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos,this.container.position.y=this.yPos},FallingBlock.prototype.update=function(){if(!this.alive){if(SAT.testPolygonPolygon(this.totalBoundPolygon,this.main.player.bodyPolygon))return;this.alive=!0}this.prevY=this.yPos,this.falling?(this.yVelocity+=this.main.gravity*this.main.gameSpeed,this.container.alpha-=.01*this.main.gameSpeed,20<=this.yVelocity&&(this.main.sounds.playSound("blockDestroy"),this.alive=!1,this.container.alpha=0,this.yPos=this.startY,this.yVelocity=0,this.falling=!1)):this.landed?(this.falling=!0,this.yVelocity=-2,this.main.sounds.playSound("fallingBlock")):this.container.alpha<1&&(this.container.alpha+=.02),this.yPos+=this.yVelocity*this.main.gameSpeed,this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},FallingBlock.prototype.reset=function(){this.yPos=this.startY,this.yVelocity=0,this.falling=!1,this.alive=!0,this.container.alpha=1,this.updatePosition()},FallingBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.arrowAnimation.destroy(),this.arrowAnimation=null,this.arrowMask&&(this.arrowMask.destroy(),this.arrowMask=null),this.container.destroy(),this.container=null,_super.prototype.destroy.call(this)},FallingBlock}(Block),GlassBlock=function(_super){function GlassBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"glassBlock"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.alive=!1,_this.blockType="glass",_this.hangable=!0,_this.scalable=!0,_this}return __extends(GlassBlock,_super),GlassBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.sprite.visible=!0,this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,IceBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,IceBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,IceBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,IceBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-IceBlock.TOP_BOUND_HEIGHT))},GlassBlock.prototype.smash=function(){this.sprite.visible=!1,this.main.sounds.playSound("glassSmash");for(var i=0;i<.25*this.width;i++){var xx=this.xPos-this.width/2+Math.random()*this.width,yy=this.yPos-.5*this.height+Math.random()*this.height;this.main.createColorParticle(xx,yy,5*Math.random()-2.5,this.main.player.yVelocity*Math.random(),12185594,8),this.alive=!1,10<this.main.player.yVelocity&&(this.main.player.yVelocity=10)}},GlassBlock.prototype.resetLevel=function(){this.reset()},GlassBlock.prototype.reset=function(){"3"!=this.main.currentLevelID&&(this.alive=!0,this.sprite.visible=!0)},GlassBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null},GlassBlock.TOP_BOUND_HEIGHT=12,GlassBlock}(Block),levelData={levelhub:[{type:"spawnPoint",x:579.45,y:1932.75},{type:"spike10x",x:3005.65,y:1273.95,rotation:90},{type:"spike",x:2843.25,y:1332.8,rotation:180},{type:"spike",x:2854.3,y:1332.8,rotation:180},{type:"spike",x:2865.3,y:1332.8,rotation:180},{type:"checkpoint",x:3110.7,y:1324.3},{type:"spike10x",x:3185.6,y:1354,rotation:0},{type:"basicBlock",x:3104.35,y:1411.9,width:681.9,height:100},{type:"buzzsawOnStick",x:2921.4,y:1198.8,rotation:-90},{type:"spike30x",x:2912.7,y:1003.85,rotation:0},{type:"basicBlock",x:2904.55,y:1056.2,width:358.4,height:89},{type:"basicBlock",x:2737.55,y:1026.4,width:81.8,height:308.3},{type:"basicBlock",x:2737.55,y:1792.3,width:81.8,height:1091.6},{type:"spike30x",x:3156.65,y:1095.35,rotation:90},{type:"spike10x",x:3282.8,y:878.9,rotation:180},{type:"spike10x",x:3099.35,y:827.75,rotation:180},{type:"spike10x",x:3098.3,y:941.6,rotation:0},{type:"spike10x",x:3279.75,y:987.75,rotation:0},{type:"blockedWall",x:2009.55,y:649.25,width:443.65,height:63.65,rotation:90,actnum:9},{type:"bouncingBuzzsaw",x:1551.65,y:735.35,width:54.7},{type:"bouncingBuzzsaw",x:1414.6,y:751.35,width:54.7},{type:"blockedWall",x:1815,y:502.75,width:63.65,height:443.65,rotation:0,actnum:8},{type:"basicBlock",x:1812.55,y:735,width:100,height:281},{type:"blockedWall",x:970.7,y:525.45,width:63.65,height:443.65,rotation:0,actnum:7},{type:"buzzsaw",x:721.95,y:556.95,width:101,height:102.2},{type:"checkpoint",x:760.5,y:834},{type:"buzzsawHorizontal",x:894.95,y:1001.4},{type:"blockedWall",x:872,y:916.25,width:443.65,height:63.65,rotation:-90,actnum:6},{type:"basicBlock",x:515.05,y:922,width:500,height:100},{type:"lockBlock",x:976,y:1171,width:100.05,height:100},{type:"blockedWall",x:1127.6,y:1078.55,width:63.65,height:443.65,rotation:0,actnum:5},{type:"basicBlock",x:1651.25,y:922,width:1252.6,height:100},{type:"spike",x:1902.4,y:1170,rotation:90},{type:"spike",x:1902.35,y:1158.9,rotation:90},{type:"spike",x:1902.35,y:1148,rotation:90},{type:"spike",x:1902.35,y:1136.9,rotation:90},{type:"spike",x:1902.35,y:1191.05,rotation:90},{type:"spike",x:1902.35,y:1180.05,rotation:90},{type:"spike",x:2165.5,y:1233.9,rotation:-90},{type:"spike",x:2165.5,y:1244.95,rotation:-90},{type:"spike",x:2165.5,y:1255.95,rotation:-90},{type:"spike",x:2165.5,y:1267,rotation:-90},{type:"spike",x:2165.5,y:1212.85,rotation:-90},{type:"spike",x:2165.5,y:1223.9,rotation:-90},{type:"spike30x",x:1457.25,y:1707.05,rotation:0},{type:"buzzsaw",x:2270.55,y:1172.5,width:101,height:102.2},{type:"fallingSpike",x:2230.9,y:1280.55,rotation:180},{type:"fallingSpike",x:2241.95,y:1280.55,rotation:180},{type:"fallingSpike",x:2252.95,y:1280.55,rotation:180},{type:"fallingSpike",x:2264,y:1280.55,rotation:180},{type:"shurikanSpawner",x:2120.3,y:1400,rotation:89.99563598632812},{type:"pushBlock",x:2018.15,y:1487.25,width:70,height:69.9},{type:"checkpoint",x:1925,y:1516.35},{type:"ziplinePole",x:1591.3,y:1097.55},{type:"ziplinePole",x:1186.7,y:1186.9},{type:"bounceBlock",x:2168.85,y:2305.4,width:50,height:50},{type:"basicBlock",x:1754.85,y:2282.45,width:100,height:100},{type:"horizontalBlock",x:2208.25,y:1964.85,width:45.9,height:45.9},{type:"buzzsaw",x:1607.75,y:2069.95,width:93,height:94.15},{type:"buzzsaw",x:1811.65,y:1960.3,width:93,height:94.15},{type:"blockedWall",x:1849.65,y:1390.25,width:63.65,height:443.65,rotation:0,actnum:4},{type:"blockedWall",x:2018.75,y:1783,width:63.65,height:443.65,rotation:0,actnum:3},{type:"basicBlock",x:2057.35,y:1604.4,width:499,height:100},{type:"checkpoint",x:1968.2,y:1776.95},{type:"spike10x",x:1301.6,y:1764.95,rotation:-90},{type:"spike10x",x:1262.9,y:1763.55,rotation:90},{type:"basicBlock",x:1456.15,y:1764.95,width:295,height:100.05},{type:"fallingBlock",x:634,y:2216.25,width:50,height:50},{type:"fallingBlock",x:1036,y:2216.25,width:50,height:50},{type:"buzzsaw",x:634.2,y:2331.35,width:101,height:102.2},{type:"buzzsaw",x:710,y:2331.35,width:101,height:102.2},{type:"buzzsaw",x:788.6,y:2331.35,width:101,height:102.2},{type:"buzzsaw",x:864.4,y:2331.35,width:101,height:102.2},{type:"buzzsaw",x:949,y:2331.35,width:101,height:102.2},{type:"buzzsaw",x:1024.8,y:2331.35,width:101,height:102.2},{type:"ziplinePole",x:1650.8,y:1620.3},{type:"ziplinePole",x:1246.2,y:1557.45},{type:"checkpoint",x:1045.2,y:1555.35},{type:"basicBlock",x:235,y:1170.45,width:470,height:2340.9},{type:"blockedWall",x:1204.05,y:1479.8,width:63.65,height:443.65,rotation:0,actnum:2},{type:"blockedWall",x:988.95,y:1469.15,width:63.65,height:443.65,rotation:0,actnum:1},{type:"bounceBlock",x:1130.5,y:2166.25,width:75,height:75},{type:"basicBlock",x:705.05,y:1642.3,width:190,height:100},{type:"basicBlock",x:585,y:2001.35,width:232,height:100.05},{type:"basicBlock",x:2488.75,y:1605.35,width:437.8,height:1466.2},{type:"buzzsaw",x:520.55,y:418.5,width:101,height:102.2},{type:"basicBlock",x:1370,y:209.05,width:2432,height:420.6},{type:"basicBlock",x:875,y:1951.25,width:150,height:200.1},{type:"basicBlock",x:1e3,y:1822.4,width:102,height:458},{type:"basicBlock",x:849,y:1692.35,width:100,height:200},{type:"basicBlock",x:750,y:2026.4,width:100,height:50},{type:"spike10x",x:749.6,y:1993.5,rotation:0},{type:"basicBlock",x:1205,y:1893,width:100,height:602},{type:"basicBlock",x:1158,y:2261.45,width:195,height:140},{type:"fallingBlock",x:835,y:2216.25,width:50,height:50},{type:"basicBlock",x:1397.55,y:2579.05,width:2761.8,height:497.3},{type:"checkpoint",x:1070.5,y:2153.25},{type:"basicBlock",x:1652.7,y:1734.95,width:100,height:160},{type:"actBlock",actNum:"1",x:540,y:1623.35},{type:"actBlock",actNum:"2",x:539.95,y:2262.35},{type:"rightSlope",x:1781.7,y:1734.95,width:160,height:160,rotation:0},{type:"actBlock",actNum:"3",x:1326,y:2010},{type:"basicBlock",x:1811.7,y:1864.25,width:100,height:100},{type:"basicBlock",x:1444.05,y:2088.5,width:100,height:299},{type:"basicBlock",x:1739,y:2188,width:508,height:100},{type:"basicBlock",x:1999,y:2026,width:100,height:424},{type:"actBlock",actNum:"4",x:1875.25,y:2400},{type:"swimmingPool",x:1721.7,y:2048.45,width:455.5,height:179.1},{type:"basicBlock",x:1981.75,y:1380.4,width:373.7,height:100},{type:"basicBlock",x:1843.85,y:1280.9,width:100,height:299},{type:"basicBlock",x:2097.8,y:1964.25,width:100,height:100},{type:"basicBlock",x:2235.6,y:2167.75,width:71.95,height:100},{type:"classicLaser",x:2230.3,y:2058.3},{type:"checkpoint",x:1988.85,y:2292},{type:"actBlock",actNum:"5",x:1726,y:1203},{type:"basicBlock",x:1604.9,y:1181.4,width:100,height:100},{type:"basicBlock",x:2223.4,y:1222.4,width:100,height:100},{type:"checkpoint",x:1956.2,y:1292.4},{type:"pole",x:1975.9,y:1190.3},{type:"pole",x:2170.2,y:1057.6},{type:"pole",x:1974.9,y:1057.6},{type:"actBlock",actNum:"6",x:541,y:1153},{type:"basicBlock",x:659,y:1151,width:100,height:141},{type:"basicBlock",x:976,y:908.75,width:100,height:427.7},{type:"key",x:1062.15,y:1108.4},{type:"basicBlock",x:814,y:1019.5,width:100,height:295},{type:"actBlock",actNum:"7",x:540,y:614.8},{type:"checkpoint",x:901.1,y:1183.05},{type:"basicBlock",x:862.4,y:1270.35,width:785.2,height:100.05},{type:"circularCannon",x:702.15,y:762.9},{type:"basicBlock",x:538,y:778.2,width:140,height:190.8},{type:"basicBlock",x:790,y:513.75,width:140,height:190.8},{type:"leftSlope",x:1074.95,y:644.9,width:100,height:100,rotation:0},{type:"basicBlock",x:1074.95,y:783.5,width:100,height:178.05},{type:"iceBlock",x:1374.95,y:644.9,width:500,height:100.05},{type:"actBlock",actNum:"8",x:1195,y:903.05},{type:"reaper",x:1374.8,y:594.95,width:352.1,rotation:0},{type:"basicBlock",x:2110.35,y:644.9,width:330,height:100},{type:"windBlaster",x:1706,y:872,rotation:-90},{type:"checkpoint",x:1021.75,y:657.5},{type:"actBlock",actNum:"9",x:2202,y:625.5},{type:"basicBlock",x:2524.15,y:346.25,width:508.6,height:697.9},{type:"checkpoint",x:1772.65,y:556.5},{type:"checkpoint",x:2621.3,y:834.25},{type:"ziplinePole",x:2748.75,y:836.95},{type:"ziplinePole",x:3474.95,y:984.65},{type:"spike30x",x:3422.65,y:956.35,rotation:-90},{type:"basicBlock",x:3684.85,y:959.2,width:508.6,height:1466.2},{type:"basicBlock",x:3282.8,y:731.35,width:100,height:281},{type:"basicBlock",x:3098.75,y:679.35,width:100,height:281},{type:"basicBlock",x:3280.55,y:1140.4,width:100,height:289},{type:"basicBlock",x:3098.75,y:1096.55,width:100,height:295.1},{type:"glassBlock",x:3380.55,y:1151.95,width:100,height:100},{type:"classicLaser",x:2884.65,y:743.5},{type:"classicLaser",x:2961.65,y:919.15},{type:"actBlock",actNum:"10",x:2917.75,y:1244.3},{type:"quadrantRight",x:2725.95,y:1216.3,rotation:0,width:179.5},{type:"shurikanDispenser",x:2041.85,y:508.95}],level1:[{type:"basicBlock",x:9.9,y:50,width:300.7,height:100.05},{type:"leftSlope",x:97,y:147.85,width:100,height:100,rotation:-90},{type:"leftSlope",x:-427.1,y:149.85,width:100,height:102,rotation:180},{type:"basicBlock",x:295.1,y:-90.95,width:116,height:100},{type:"spike30x",x:-417.1,y:-8.05,rotation:0},{type:"spike30x",x:5,y:-8.05,rotation:0},{type:"spike10x",x:-263.1,y:49.85,rotation:90},{type:"spike10x",x:-149.1,y:50,rotation:-90},{type:"basicBlock",x:-423.5,y:49.85,width:304.7,height:100.05},{type:"spike10x",x:137.1,y:-92.35,rotation:-90},{type:"basicBlock",x:820,y:670,width:220,height:100.05},{type:"textFade",textNum:"15",x:-588.025,y:352.75,rotation:179.99913024902344},{type:"textFade",textNum:"15",x:493.775,y:246.7,rotation:0},{type:"textFade",textNum:"16",x:643.375,y:591.65,rotation:179.99913024902344},{type:"textFade",textNum:"17",x:62.25,y:500.225,rotation:-90.00175476074219},{type:"textFade",textNum:"17",x:-906.95,y:261.825,rotation:-90.00175476074219},{type:"textFade",textNum:"15",x:842.75,y:207.42499999999998,rotation:90},{type:"textFade",textNum:"15",x:-625.075,y:-276.55,rotation:-.0008697509765625},{type:"spike",x:-782.55,y:-150.35,rotation:180},{type:"spike",x:-771.55,y:-150.35,rotation:180},{type:"spike",x:-760.55,y:-150.35,rotation:180},{type:"spike",x:-749.55,y:-150.35,rotation:180},{type:"horizontalBlock",x:-765.55,y:-182.85,width:50,height:50},{type:"spike",x:-877.6,y:-150.35,rotation:180},{type:"spike",x:-866.6,y:-150.35,rotation:180},{type:"spike",x:-855.6,y:-150.35,rotation:180},{type:"spike",x:-844.6,y:-150.35,rotation:180},{type:"horizontalBlock",x:-860.6,y:-182.85,width:50,height:50},{type:"spike",x:-689.55,y:-150.35,rotation:180},{type:"spike",x:-678.55,y:-150.35,rotation:180},{type:"spike",x:-667.55,y:-150.35,rotation:180},{type:"spike",x:-656.55,y:-150.35,rotation:180},{type:"horizontalBlock",x:-672.55,y:-182.85,width:50,height:50},{type:"checkpoint",x:-812.7,y:61.85},{type:"spike",x:-910.95,y:181.45,rotation:180},{type:"spike",x:-899.95,y:181.45,rotation:180},{type:"spike",x:-888.95,y:181.45,rotation:180},{type:"spike",x:-877.95,y:181.45,rotation:180},{type:"horizontalBlock",x:-893.95,y:148.95,width:50,height:50},{type:"bounceBlock",x:-903.95,y:355,width:50,height:50},{type:"buzzsawVerticalUp",x:-729.8,y:426.8},{type:"checkpoint",x:-494.8,y:342.55},{type:"buzzsaw",x:478.45,y:319.4},{type:"buzzsaw",x:587.45,y:319.4},{type:"spike10x",x:689.3,y:203.85,rotation:-90},{type:"basicBlock",x:722.2,y:149.55,width:50,height:207.1},{type:"basicBlock",x:620,y:0,width:780,height:100.05},{type:"basicBlock",x:360,y:320,width:230,height:100.05},{type:"textFade",textNum:"10",x:357.525,y:318.475,rotation:0},{type:"textFade",textNum:"8",x:360.5,y:178.89999999999998,rotation:0},{type:"spawnPoint",x:349.85,y:260.45},{type:"basicBlock",x:195,y:188.7,width:100,height:659.3},{type:"basicBlock",x:700,y:320,width:220,height:100.05},{type:"textFade",textNum:"11",x:699.9,y:319.1,rotation:0},{type:"basicBlock",x:760,y:445.05,width:100,height:150},{type:"basicBlock",x:960,y:484.75,width:100,height:871.5},{type:"verticalDownBlock",x:885,y:345.05,width:50,height:50},{type:"verticalUpBlock",x:835,y:495,width:50,height:50},{type:"textFade",textNum:"12",x:831.875,y:670.925,rotation:0},{type:"checkpoint",x:777.85,y:582.2},{type:"fallingBlock",x:685,y:645,width:50,height:50},{type:"fallingBlock",x:635,y:645,width:50,height:50},{type:"basicBlock",x:150,y:670,width:220,height:100.05},{type:"checkpoint",x:192.05,y:582.2},{type:"textFade",textNum:"14",x:148.7,y:675.425,rotation:0},{type:"bounceBlock",x:65,y:595.2,width:50,height:50},{type:"basicBlock",x:-10,y:612,width:100,height:584},{type:"ziplinePole",x:-12.95,y:285.05},{type:"ziplinePole",x:-428.9,y:345.55},{type:"basicBlock",x:-464.95,y:641.1,width:100,height:522.1},{type:"basicBlock",x:-737.55,y:150,width:186,height:100.05},{type:"basicBlock",x:-572,y:430,width:116.05,height:100.05},{type:"basicBlock",x:-1e3,y:-155.45,width:100,height:523.2},{type:"bounceBlock",x:-755.55,y:75,width:50,height:50},{type:"basicBlock",x:-538.7,y:-179.55,width:217.6,height:100.05},{type:"ziplinePole",x:193.05,y:-176.05},{type:"ziplinePole",x:-442.95,y:-264.55},{type:"finishPortal",x:289,y:-170.85},{type:"basicBlock",x:391.45,y:-274.9,width:100,height:467.1},{type:"basicBlock",x:-354.25,y:-458.45,width:1391.6,height:100.05},{type:"buzzsawVerticalUp",x:-254.15,y:-260.9},{type:"basicBlock",x:-1e3,y:497.9,width:100,height:785.2},{type:"textFade",textNum:"18",x:-516.5250000000001,y:280.5,rotation:0},{type:"basicBlock",x:-892,y:430,width:116.05,height:100.05},{type:"basicBlock",x:-562,y:34,width:171,height:332.1},{type:"star",x:-206.05,y:50.05},{type:"textFade",textNum:"41",x:-826.85,y:-3.575000000000003,rotation:0},{type:"fallingBlock",x:585,y:645.2,width:50,height:50},{type:"fallingBlock",x:535,y:645.2,width:50,height:50},{type:"fallingBlock",x:485,y:645.2,width:50,height:50},{type:"fallingBlock",x:435,y:645.2,width:50,height:50},{type:"fallingBlock",x:385,y:645,width:50,height:50},{type:"fallingBlock",x:335,y:645,width:50,height:50},{type:"fallingBlock",x:285,y:645,width:50,height:50}],level2:[{type:"shurikanSpawner",x:1231.5,y:-471.35,rotation:90.0052490234375},{type:"shurikanSpawner",x:1085.85,y:-250,rotation:-89.9947509765625},{type:"shurikanSpawner",x:990.45,y:-471.35,rotation:90.0052490234375},{type:"basicBlock",x:1085.3,y:-200,width:460.2,height:100},{type:"checkpoint",x:1355.1,y:-111},{type:"verticalUpBlock",x:1137.3,y:25,width:356.1,height:100},{type:"verticalDownBlock",x:1137.3,y:225.05,width:358,height:100},{type:"basicBlock",x:739.35,y:175,width:48.2,height:100},{type:"ziplinePole",x:1043.95,y:530.05},{type:"shurikanSpawner",x:794,y:820,rotation:-89.9947509765625},{type:"shurikanSpawner",x:795.9,y:254.95,rotation:180},{type:"basicBlock",x:809.25,y:24.7,width:100,height:1323},{type:"checkpoint",x:562.35,y:-66},{type:"spike10x",x:265.1,y:14,rotation:0},{type:"spike10x",x:361.6,y:14,rotation:0},{type:"spike10x",x:457.6,y:14,rotation:0},{type:"textFade",textNum:"17",x:-87.52499999999999,y:222.55,rotation:-15.002182006835938},{type:"checkpoint",x:-107.8,y:291.75},{type:"textFade",textNum:"20",x:326.15,y:487.17499999999995,rotation:0},{type:"spike10x",x:83.6,y:461.15,rotation:180},{type:"spike10x",x:83.6,y:588.4,rotation:0},{type:"basicBlock",x:449,y:320,width:230,height:100.05},{type:"spawnPoint",x:348.85,y:260.45},{type:"basicBlock",x:611,y:470,width:94,height:800},{type:"basicBlock",x:84.05,y:261.7,width:100,height:383.1},{type:"basicBlock",x:195.55,y:647.05,width:737.5,height:100.05},{type:"basicBlock",x:-121,y:464.75,width:100,height:272.1},{type:"swimmingPool",x:246,y:472,width:636,height:250},{type:"textFade",textNum:"17",x:269.9,y:275.025,rotation:90},{type:"basicBlock",x:254.95,y:46.8,width:442.1,height:50},{type:"basicBlock",x:10,y:252.7,width:50,height:50},{type:"basicBlock",x:-221,y:308.05,width:100,height:778},{type:"basicBlock",x:89.5,y:-3,width:254,height:50},{type:"spike",x:-104,y:28.8,rotation:180},{type:"spike",x:-115.5,y:28.8,rotation:180},{type:"spike",x:-115,y:-37.4,rotation:0},{type:"spike",x:-103.5,y:-37.4,rotation:0},{type:"verticalDownBlock",x:-109,y:-4,width:25,height:50},{type:"checkpoint",x:45.5,y:-66},{type:"basicBlock",x:-121.55,y:147.65,width:100,height:50},{type:"basicBlock",x:591.6,y:22,width:235.1,height:99.5},{type:"pushBlock",x:165,y:-120,width:50,height:49.9},{type:"basicBlock",x:295.3,y:-235.55,width:929.6,height:100.05},{type:"star",x:-223.95,y:-209.95},{type:"pushBlock",x:734.25,y:-2.05,width:50,height:49.9},{type:"basicBlock",x:682.2,y:300,width:50,height:50},{type:"textFade",textNum:"17",x:347.975,y:-62.55,rotation:-.00262451171875},{type:"basicBlock",x:735.25,y:428,width:50,height:100},{type:"basicBlock",x:807.45,y:820,width:300,height:100.05},{type:"basicBlock",x:1007.45,y:716.85,width:100,height:305.95},{type:"checkpoint",x:978.1,y:525.9},{type:"swimmingPool",x:807.95,y:677.5,width:299.9,height:185},{type:"textFade",textNum:"21",x:124.25,y:16.700000000000003,rotation:0},{type:"textFade",textNum:"22",x:603.325,y:48.900000000000006,rotation:0},{type:"ziplinePole",x:1396.9,y:576.55},{type:"basicBlock",x:1395.9,y:761,width:100,height:305.05},{type:"shurikanSpawner",x:1210.5,y:682.5,rotation:-89.9947509765625},{type:"basicBlock",x:1545.9,y:658.5,width:200,height:100},{type:"bounceBlock",x:1538.9,y:576.5,width:65,height:65},{type:"checkpoint",x:1380.1,y:87},{type:"basicBlock",x:1365.35,y:175,width:100,height:100},{type:"basicBlock",x:909,y:175,width:100,height:100},{type:"basicBlock",x:883.1,y:75,width:48.2,height:100},{type:"basicBlock",x:1365.35,y:-25,width:100,height:100},{type:"basicBlock",x:1465.35,y:-112,width:100,height:274.1},{type:"pushBlock",x:1273.3,y:-338.6,width:50,height:49.9},{type:"basicBlock",x:883.25,y:-336.55,width:50,height:175.05},{type:"finishPortal",x:883.25,y:-453.55},{type:"basicBlock",x:-146,y:45.15,width:50,height:50}],level3:[{type:"checkpoint",x:616.25,y:420.1},{type:"bounceBlock",x:1587.4,y:286.1,width:46,height:55},{type:"buzzsaw",x:-30,y:213.1},{type:"ziplinePole",x:26.95,y:-86.85},{type:"checkpoint",x:-34.1,y:-89.8},{type:"basicBlock",x:-7.9,y:252.7,width:100,height:611},{type:"spike30x",x:-749.75,y:368.35,rotation:180},{type:"spike30x",x:-697.7,y:549.3,rotation:0},{type:"spike30x",x:-456.65,y:368.35,rotation:180},{type:"spike30x",x:-406.6,y:549.3,rotation:0},{type:"buzzsaw",x:-188.05,y:10.95},{type:"bounceBlock",x:987.15,y:5.1,width:45,height:45},{type:"checkpoint",x:-107.35,y:420.1},{type:"spike30x",x:216.7,y:-61.15,rotation:0},{type:"shurikanSpawner",x:1436.75,y:216.65,rotation:-90},{type:"spike10x",x:1249.1,y:77.1,rotation:90},{type:"buzzsaw",x:201.25,y:205.45},{type:"spike10x",x:933,y:79.1,rotation:-90},{type:"spike30x",x:1090.45,y:134,rotation:180},{type:"basicBlock",x:1091.05,y:77.1,width:300,height:100.05},{type:"checkpoint",x:1357.55,y:120.95},{type:"checkpoint",x:815.7,y:120.95},{type:"basicBlock",x:516.05,y:208.1,width:40,height:40},{type:"checkpoint",x:322.75,y:120.95},{type:"textFade",textNum:"17",x:175.275,y:133.25,rotation:0},{type:"bounceBlock",x:97.05,y:433.1,width:50,height:50},{type:"basicBlock",x:717,y:707.1,width:100,height:100.05},{type:"textFade",textNum:"17",x:716,y:537.075,rotation:-90},{type:"spawnPoint",x:721,y:643.1},{type:"basicBlock",x:617.05,y:607.1,width:100,height:300},{type:"basicBlock",x:817,y:457.1,width:100,height:600},{type:"buzzsawOnStick",x:721.9,y:705.8,rotation:-90},{type:"pole",x:413.1,y:393.1},{type:"basicBlock",x:192.1,y:607.6,width:100,height:299},{type:"textFade",textNum:"23",x:412.15,y:325.975,rotation:0},{type:"textFade",textNum:"24",x:412.175,y:499.97499999999997,rotation:0},{type:"basicBlock",x:-60,y:508.1,width:404.1,height:100.05},{type:"pole",x:90.3,y:100.95},{type:"basicBlock",x:317.05,y:208.1,width:100,height:100.05},{type:"textFade",textNum:"25",x:-7.149999999999999,y:179.075,rotation:0},{type:"fallingBlock",x:417.05,y:208.1,width:100,height:100},{type:"basicBlock",x:617.05,y:208.1,width:100,height:100},{type:"buzzsawOnStick",x:516.4,y:203.7,rotation:-90},{type:"iceBlock",x:1087.05,y:233.1,width:440,height:150.05},{type:"basicBlock",x:1357.05,y:408.1,width:100,height:500},{type:"textFade",textNum:"26",x:951.5250000000001,y:188.64999999999998,rotation:0},{type:"basicBlock",x:1531.05,y:213.1,width:78,height:200},{type:"ziplinePole",x:853.2,y:-232},{type:"basicBlock",x:891.05,y:-147.95,width:100,height:100.05},{type:"textFade",textNum:"17",x:1152.3249999999998,y:4.35,rotation:180},{type:"basicBlock",x:-7.9,y:-350.1,width:100,height:400},{type:"glassBlock",x:-107.9,y:10.95,width:100,height:100.05},{type:"basicBlock",x:-208,y:-172.5,width:100,height:1065.3},{type:"textFade",textNum:"27",x:-208.75,y:-57.9,rotation:0},{type:"glassBlock",x:-107.9,y:210.95,width:100,height:100.05},{type:"glassBlock",x:-107.9,y:408.95,width:100,height:100.05},{type:"textFade",textNum:"17",x:-109.6,y:-151.425,rotation:90},{type:"basicBlock",x:202.2,y:-2.8,width:321,height:100.05},{type:"basicBlock",x:-600.2,y:309.95,width:685.1,height:100.05},{type:"basicBlock",x:-550.3,y:607,width:785.3,height:100.05},{type:"basicBlock",x:-892.9,y:563.35,width:100,height:607.1},{type:"finishPortal",x:-810.2,y:470.15},{type:"pole",x:-340.1,y:463.1},{type:"pole",x:-551.15,y:463.1},{type:"pole",x:-740.2,y:463.1},{type:"shurikanSpawner",x:-727.4,y:382.85,rotation:45},{type:"fallingBlock",x:67.1,y:-525.1,width:50,height:50},{type:"fallingBlock",x:219.1,y:-549.1,width:50,height:50},{type:"fallingBlock",x:378.75,y:-567.1,width:50,height:50},{type:"fallingBlock",x:530.75,y:-591.1,width:50,height:50},{type:"buzzsawOnStick",x:142.9,y:-543.1,rotation:-90},{type:"buzzsawOnStick",x:304.75,y:-549.05,rotation:90},{type:"buzzsawOnStick",x:452.25,y:-581.2,rotation:-90},{type:"buzzsawOnStick",x:614.1,y:-587.15,rotation:90},{type:"star",x:616.15,y:-678.15},{type:"basicBlock",x:1657.05,y:102.1,width:100,height:422},{type:"basicBlock",x:1073.7,y:-393.9,width:100,height:592},{type:"basicBlock",x:1572.6,y:-147.95,width:269.1,height:100.05},{type:"pushBlock",x:1581.35,y:87.9,width:50,height:49.9},{type:"pole",x:1448.35,y:-57.85}],level4:[{type:"fallingSpike",x:-350.65,y:-571.35,rotation:180},{type:"fallingSpike",x:-329.15,y:-571.35,rotation:180},{type:"fallingSpike",x:-393.75,y:-571.35,rotation:180},{type:"fallingSpike",x:-372.25,y:-571.35,rotation:180},{type:"fallingSpike",x:-436.75,y:-571.35,rotation:180},{type:"fallingSpike",x:-415.25,y:-571.35,rotation:180},{type:"fallingSpike",x:-479.85,y:-571.35,rotation:180},{type:"fallingSpike",x:-458.35,y:-571.35,rotation:180},{type:"fallingSpike",x:-522.9,y:-571.35,rotation:180},{type:"fallingSpike",x:-501.4,y:-571.35,rotation:180},{type:"fallingSpike",x:-566,y:-571.35,rotation:180},{type:"fallingSpike",x:-544.5,y:-571.35,rotation:180},{type:"fallingSpike",x:-609,y:-571.35,rotation:180},{type:"fallingSpike",x:-587.5,y:-571.35,rotation:180},{type:"fallingSpike",x:-652.1,y:-571.35,rotation:180},{type:"fallingSpike",x:-630.6,y:-571.35,rotation:180},{type:"spike10x",x:-615.05,y:-465.7,rotation:0},{type:"basicBlock",x:-770.2,y:-567.4,width:100,height:225.2},{type:"spike30x",x:200.45,y:-167.85,rotation:0},{type:"spike10x",x:8.05,y:-168.1,rotation:0},{type:"spike10x",x:-87.45,y:-168.1,rotation:0},{type:"shurikanSpawner",x:648.7,y:-236.5,rotation:0},{type:"textFade",textNum:"5",x:37.05,y:342.975,rotation:-90},{type:"textFade",textNum:"4",x:617.5,y:-5.225000000000001,rotation:0},{type:"spike10x",x:952.2,y:-167.1,rotation:0},{type:"windBlaster",x:1249.1,y:70.95,rotation:-90},{type:"buzzsaw",x:1044.4,y:340.25},{type:"buzzsawHorizontal",x:1043.95,y:470.6},{type:"glassBlock",x:943.95,y:143.65,width:100,height:100},{type:"basicBlock",x:1043.95,y:90.85,width:100,height:500},{type:"basicBlock",x:666.85,y:44.75,width:50,height:100},{type:"buzzsawHorizontal",x:423.95,y:0},{type:"spike10x",x:187.1,y:318.25,rotation:-90.00175476074219},{type:"spike10x",x:183.05,y:485.85,rotation:89.99824523925781},{type:"shurikanSpawner",x:555.4,y:311.8,rotation:90},{type:"speedBlock",x:545,y:320,width:300,height:100.05},{type:"basicBlock",x:345,y:320,width:100,height:100.05},{type:"spawnPoint",x:348.85,y:260.45},{type:"basicBlock",x:345,y:615.35,width:100,height:291.2},{type:"basicBlock",x:956.05,y:520,width:522.1,height:100.05},{type:"speedBlockLeft",x:545,y:520,width:300,height:100.05},{type:"checkpoint",x:347.3,y:432},{type:"basicBlock",x:844,y:418,width:100,height:696},{type:"basicBlock",x:245,y:219.85,width:100,height:300},{type:"textFade",textNum:"5",x:469.42499999999995,y:236.05,rotation:0},{type:"basicBlock",x:87.3,y:486.85,width:176.7,height:100.05},{type:"basicBlock",x:545.05,y:119.85,width:500.1,height:100.05},{type:"basicBlock",x:-50,y:300.9,width:100,height:921.7},{type:"classicLaser",x:154.05,y:240.6},{type:"checkpoint",x:252.35,y:32},{type:"verticalUpBlock",x:90,y:194.05,width:50,height:100},{type:"basicBlock",x:90,y:343.1,width:50,height:100},{type:"textFade",textNum:"28",x:332.4,y:323.725,rotation:0},{type:"basicBlock",x:250,y:-109.75,width:500.1,height:100.05},{type:"buzzsawVerticalUp",x:571.9,y:-76},{type:"basicBlock",x:940.9,y:-109,width:402.1,height:100.05},{type:"star",x:450.95,y:-204.95},{type:"basicBlock",x:350.05,y:-258.55,width:100,height:200},{type:"basicBlock",x:473.05,y:-309,width:346,height:100.05},{type:"basicBlock",x:691.85,y:-209,width:100,height:300},{type:"checkpoint",x:839.4,y:32},{type:"basicBlock",x:1249.1,y:423.1,width:100,height:706.3},{type:"checkpoint",x:1081.8,y:-196.95},{type:"windBlaster",x:789.85,y:-157.95,rotation:-90},{type:"windBlaster",x:954.25,y:-341,rotation:90},{type:"basicBlock",x:948.85,y:-391,width:198,height:100.05},{type:"checkpoint",x:401.35,y:-397.05},{type:"textFade",textNum:"5",x:777.125,y:-393.65,rotation:180},{type:"iceBlock",x:99.55,y:-309,width:401,height:100.05},{type:"basicBlock",x:-150,y:202,width:100,height:1122},{type:"buzzsawOnStick",x:210.65,y:-299.35,rotation:90},{type:"checkpoint",x:-255.85,y:-496.2},{type:"basicBlock",x:-459.9,y:-408.2,width:720.6,height:100.05},{type:"basicBlock",x:-459.25,y:-630,width:720.6,height:100.05},{type:"finishPortal",x:-690.05,y:-487.2},{type:"buzzsawOnStick",x:-21.199999999999996,y:-309,rotation:-90},{type:"textFade",textNum:"5",x:248.175,y:425.8,rotation:-165.00189208984375},{type:"swimmingPool",x:1046.95,y:331.8,width:306,height:276.3}],level5:[{type:"laserPoint",x:543.75,y:565},{type:"laserPoint",x:1269.1,y:565},{type:"laserPoint",x:122,y:146.55},{type:"laserPoint",x:231,y:146.55},{type:"textFade",textNum:"15",x:65.025,y:753.4,rotation:.0008697509765625},{type:"bounceBlock",x:1439.4,y:808.7,width:50,height:50},{type:"glassBlock",x:390,y:157.5,width:126,height:100},{type:"spike30x",x:-180.55,y:465.85,rotation:-90},{type:"classicLaser",x:150,y:54.4},{type:"textFade",textNum:"15",x:386,y:219.525,rotation:90.00175476074219},{type:"spike10x",x:135.4,y:462.45,rotation:90},{type:"checkpoint",x:-95.8,y:54.65},{type:"glassBlock",x:389,y:-105.3,width:122,height:100},{type:"quadrantLeft",x:730.1,y:-192.5,rotation:0},{type:"quadrantLeft",x:1006.85,y:-192.5,rotation:0},{type:"textFade",textNum:"15",x:1367.1,y:-10.025000000000006,rotation:-104.99729919433594},{type:"bounceBlock",x:1396,y:115,width:50,height:50},{type:"checkpoint",x:1314.2,y:102.65},{type:"basicBlock",x:714.1,y:390.1,width:100,height:199.9},{type:"spawnPoint",x:713.45,y:264.15},{type:"finishPortal",x:1514.6,y:552.25},{type:"basicBlock",x:914.1,y:365,width:100,height:250.1},{type:"basicBlock",x:1114.1,y:340.05,width:100,height:300},{type:"basicBlock",x:1314.1,y:387.3,width:100,height:495.3},{type:"bouncingBuzzsaw",x:914.1,y:0},{type:"bouncingBuzzsaw",x:1114.1,y:0},{type:"basicBlock",x:1414.1,y:190,width:100,height:100},{type:"quadrantLeft",x:1373,y:-83,rotation:0},{type:"basicBlock",x:1232.85,y:-142.5,width:100.1,height:100},{type:"textFade",textNum:"15",x:804.125,y:230,rotation:-14.99810791015625},{type:"checkpoint",x:1234.6,y:-230.5},{type:"iceBlock",x:905.3,y:-142.5,width:556.9,height:100.05},{type:"basicBlock",x:573.8,y:-142.5,width:106.1,height:100},{type:"checkpoint",x:578.55,y:-230.5},{type:"basicBlock",x:1514,y:87.2,width:100,height:806.1},{type:"basicBlock",x:497.75,y:210.55,width:100,height:806.1},{type:"basicBlock",x:277,y:252.95,width:100,height:291},{type:"basicBlock",x:226.7,y:562,width:200,height:100},{type:"pushBlock",x:470.15,y:-279.05,width:50,height:49.9},{type:"basicBlock",x:26.95,y:454,width:200.1,height:316.05},{type:"basicBlock",x:77,y:-49.65,width:100,height:488.1},{type:"basicBlock",x:177.55,y:-225.05,width:301,height:462.9},{type:"pole",x:384.1,y:439.65},{type:"rightSlope",x:-22.9,y:247.55,width:100,height:100,rotation:0},{type:"ziplinePole",x:-156.3,y:58},{type:"ziplinePole",x:-599.15,y:119.2},{type:"spike30x",x:-538.25,y:195.6,rotation:90},{type:"ziplinePole",x:-154.05,y:379.25},{type:"classicLaser",x:-206.3,y:202.7},{type:"ziplinePole",x:-599.15,y:292.7},{type:"ziplinePole",x:-154.05,y:414.3},{type:"ziplinePole",x:-599.15,y:524.95},{type:"classicLaser",x:-512.65,y:417.9},{type:"ziplinePole",x:-599.15,y:575.95},{type:"ziplinePole",x:-135.05,y:746.15},{type:"checkpoint",x:-63.55,y:743.2},{type:"basicBlock",x:-123.1,y:352,width:100,height:520},{type:"spike10x",x:-538.25,y:595.35,rotation:90},{type:"basicBlock",x:-596.15,y:349.85,width:100,height:600.2},{type:"buzzsaw",x:386.1,y:560.4,width:121.2,height:122.65},{type:"buzzsaw",x:-271.2,y:377.8,width:66.25,height:67.05},{type:"buzzsaw",x:-390.25,y:550.8,width:66.25,height:67.05},{type:"quadrantRight",x:158.25,y:749.65,rotation:0},{type:"pole",x:158.05,y:749.2},{type:"quadrantRight",x:350.3,y:749.65,rotation:45},{type:"pole",x:350.1,y:749.2},{type:"quadrantRight",x:534.3,y:749.65,rotation:0},{type:"pole",x:534.1,y:749.2},{type:"basicBlock",x:725,y:831,width:100,height:100},{type:"checkpoint",x:730.65,y:743.25},{type:"basicBlock",x:-96.45,y:831,width:153,height:100},{type:"hazardStrips",x:538.75,y:513.9},{type:"hazardStrips",x:1264.1,y:535.25},{type:"hazardStrips",x:117,y:93.65},{type:"hazardStrips",x:227,y:107.45},{type:"basicBlock",x:1216.55,y:856,width:503.3,height:50},{type:"basicBlock",x:1167.3,y:808.7,width:236.1,height:50},{type:"basicBlock",x:1374.35,y:808.7,width:80.1,height:50},{type:"basicBlock",x:1514,y:731.1,width:100,height:298.9},{type:"buzzsawHorizontalFast",x:1310.3,y:732.7},{type:"buzzsawHorizontalFast",x:1004.25,y:732.7},{type:"fallingBlock",x:387.95,y:346,width:100,height:100},{type:"star",x:-271.05,y:435.1}],level6:[{type:"spike10x",x:672.1,y:-499.25,rotation:-90.00175476074219},{type:"checkpoint",x:311.95,y:-388.05},{type:"quadrantRight",x:385.05,y:-737.25,rotation:0,width:179.5},{type:"spike10x",x:28.6,y:308.75,rotation:180},{type:"spike10x",x:-270.4,y:207.9,rotation:180},{type:"textFade",textNum:"5",x:752.425,y:-131,rotation:.0008697509765625},{type:"bounceBlock",x:232,y:-74.5,width:50,height:50},{type:"lockBlock",x:230,y:750,width:100.05,height:100},{type:"checkpoint",x:26.85,y:-338},{type:"quadrantRight",x:-44,y:-76.5,rotation:0,width:211.5},{type:"checkpoint",x:402.8,y:163.25},{type:"quadrantLeft",x:680.2,y:401.1,rotation:0,width:201.5},{type:"key",x:675.1,y:403.2},{type:"basicBlock",x:380,y:300,width:200,height:200},{type:"spawnPoint",x:329.35,y:173.9},{type:"finishPortal",x:424.05,y:470.2},{type:"lockBlock",x:230,y:250,width:100.05,height:100},{type:"lockBlock",x:230,y:349.95,width:100.05,height:100},{type:"lockBlock",x:230,y:449.95,width:100.05,height:100},{type:"lockBlock",x:330,y:450,width:100.05,height:100},{type:"basicBlock",x:530,y:398.5,width:100,height:397.1},{type:"basicBlock",x:130,y:550,width:100,height:700},{type:"basicBlock",x:630,y:200,width:100,height:200},{type:"basicBlock",x:30,y:200,width:100,height:200},{type:"textFade",textNum:"31",x:336.07500000000005,y:92.625,rotation:0},{type:"textFade",textNum:"32",x:333.9,y:253.325,rotation:0},{type:"basicBlock",x:630,y:-50,width:100,height:100},{type:"basicBlock",x:30,y:-150,width:100,height:300.1},{type:"basicBlock",x:330,y:0,width:300,height:100},{type:"basicBlock",x:830,y:300,width:100,height:600},{type:"checkpoint",x:630.3,y:62},{type:"checkpoint",x:26.85,y:62},{type:"swimmingPool",x:680,y:400,width:200,height:200},{type:"basicBlock",x:-170,y:-125,width:100,height:350},{type:"basicBlock",x:-169,y:150,width:300,height:100},{type:"basicBlock",x:330,y:700,width:100,height:400},{type:"star",x:230,y:750.05},{type:"basicBlock",x:580,y:550,width:400,height:100},{type:"basicBlock",x:-95,y:25,width:50,height:50},{type:"basicBlock",x:-45,y:-75,width:50,height:50},{type:"key",x:-106.1,y:-174.55},{type:"basicBlock",x:-70,y:-250,width:100,height:100},{type:"basicBlock",x:330,y:-200,width:100,height:300.1},{type:"textFade",textNum:"5",x:128.05,y:61.975,rotation:-90},{type:"textFade",textNum:"5",x:532.15,y:56.575,rotation:-90},{type:"checkpoint",x:640.5,y:-138},{type:"speedBlock",x:929.95,y:-49.95,width:499.9,height:100},{type:"basicBlock",x:1230,y:-50,width:100,height:100},{type:"buzzsawOnStick",x:1004.1,y:-55,rotation:-90},{type:"speedBlockLeft",x:929.95,y:-280,width:499.9,height:100},{type:"buzzsawOnStick",x:814.8,y:-274.45,rotation:90},{type:"key",x:725.05,y:-369.55},{type:"bounceBlock",x:1230.3,y:-124.95,width:50,height:50},{type:"glassBlock",x:231,y:550,width:100,height:100},{type:"lockBlock",x:230,y:650,width:100.05,height:100},{type:"basicBlock",x:230,y:850,width:100,height:100},{type:"ziplinePole",x:-182.05,y:-335.1},{type:"ziplinePole",x:-749.2,y:-185.1},{type:"key",x:-504.2,y:-311.95},{type:"basicBlock",x:-750,y:-50,width:100,height:200},{type:"ziplinePole",x:-656.15,y:-84.55},{type:"ziplinePole",x:-259.05,y:64.95},{type:"basicBlock",x:-650,y:0,width:100,height:100},{type:"classicLaser",x:-249.1,y:-152.75},{type:"buzzsaw",x:-504.1,y:-157.75,width:101,height:102.2},{type:"basicBlock",x:-850,y:-175,width:100,height:450},{type:"textFade",textNum:"5",x:732.05,y:203.125,rotation:90.00175476074219},{type:"textFade",textNum:"5",x:172.775,y:-317.3,rotation:-179.99913024902344},{type:"windBlaster",x:330,y:-350.05,rotation:-90},{type:"fallingBlock",x:381,y:-548,width:50,height:50},{type:"fallingBlock",x:291,y:-640,width:50,height:50},{type:"fallingBlock",x:385,y:-734,width:50,height:50},{type:"fallingBlock",x:291,y:-821,width:50,height:50},{type:"key",x:345.5,y:-916.4},{type:"bounceBlock",x:-270,y:650,width:70,height:70},{type:"key",x:31.95,y:569.3},{type:"bounceBlock",x:-116.95,y:650,width:70,height:70},{type:"bounceBlock",x:30,y:650,width:70,height:70},{type:"buzzsaw",x:-439.7,y:-13.65,width:101,height:102.2},{type:"spike10x",x:730.6,y:-557.55,rotation:0},{type:"spike10x",x:828,y:-557.55,rotation:0},{type:"basicBlock",x:780,y:-499.65,width:200,height:100}],level7:[{type:"basicBlock",x:-173,y:183.6,width:150,height:115},{type:"buzzsawOnStick",x:101.19999999999999,y:-297.4,rotation:90},{type:"buzzsawOnStick",x:102.8,y:-306.6,rotation:-90},{type:"quadrantRight",x:798.2,y:896.2,rotation:0,width:179.5},{type:"quadrantRight",x:584.15,y:896.2,rotation:0,width:179.5},{type:"basicBlock",x:251,y:367,width:100,height:1733},{type:"basicBlock",x:754.2,y:995.75,width:906.1,height:100},{type:"checkpoint",x:364.5,y:894.2},{type:"breatheBlaster",x:356.85,y:926.1,rotation:-90},{type:"textFade",textNum:"5",x:714.8,y:508.67499999999995,rotation:90.00175476074219},{type:"circularCannon",x:392.15,y:382.25},{type:"spike",x:860,y:-581.35,rotation:180},{type:"spike",x:871,y:-581.35,rotation:180},{type:"spike",x:883,y:-581.35,rotation:180},{type:"spike",x:894,y:-581.35,rotation:180},{type:"spike10x",x:643.9,y:-581.65,rotation:180},{type:"basicBlock",x:643.9,y:-703.5,width:100,height:230},{type:"spike30x",x:546.6,y:-507.7,rotation:0},{type:"spike10x",x:793.1,y:-654.1,rotation:-90},{type:"spike10x",x:792.1,y:-500.2,rotation:-90},{type:"fallingSpike",x:-418.05,y:-49.25,rotation:180},{type:"fallingSpike",x:-439.55,y:-49.25,rotation:180},{type:"fallingSpike",x:-396.55,y:-49.25,rotation:180},{type:"textFade",textNum:"5",x:141.02499999999998,y:-436.525,rotation:-59.99946594238281},{type:"bounceBlock",x:171.05,y:216.05,width:60,height:60},{type:"bounceBlock",x:31,y:216.05,width:60,height:60},{type:"spike10x",x:-272.15,y:376.65,rotation:90},{type:"windBlaster",x:-281.05,y:477.05,rotation:0},{type:"windBlaster",x:-135.1,y:380.1,rotation:180},{type:"spike10x",x:-144,y:480.5,rotation:-90},{type:"textFade",textNum:"5",x:94.8,y:441.17499999999995,rotation:-89.99824523925781},{type:"fallingSpike",x:-319.3,y:12.45,rotation:180},{type:"fallingSpike",x:-361.3,y:12.45,rotation:180},{type:"fallingSpike",x:-340.8,y:12.45,rotation:180},{type:"fallingSpike",x:-297.8,y:12.45,rotation:180},{type:"basicBlock",x:-355.15,y:109.95,width:150,height:115},{type:"star",x:-28.45,y:1185.8},{type:"classicLaser",x:-31.05,y:969.55},{type:"buzzsawHorizontal",x:78.05,y:615.2,width:184.8},{type:"basicBlock",x:-65.4,y:665.65,width:438.1,height:100},{type:"spike",x:-438.15,y:58,rotation:-90},{type:"spike",x:-438.15,y:68.5,rotation:-90},{type:"spike",x:-438.15,y:78.5,rotation:-90},{type:"basicBlock",x:-330.15,y:-32.3,width:100,height:73.5},{type:"textFade",textNum:"5",x:-770.2,y:627.125,rotation:90.00175476074219},{type:"buzzsaw",x:-802.6,y:759.25,width:76.55,height:77.5},{type:"buzzsaw",x:-736.6,y:911.3,width:76.55,height:77.5},{type:"buzzsaw",x:-632,y:1222.3,width:77.5,height:76.55},{type:"buzzsaw",x:-479.95,y:1124.3,width:77.5,height:76.55},{type:"textFade",textNum:"5",x:-770.2,y:188.075,rotation:90.00175476074219},{type:"buzzsaw",x:-736.6,y:442.2,width:76.55,height:77.5},{type:"buzzsaw",x:-639.35,y:708.65,width:184.8,height:187.05},{type:"buzzsaw",x:-639.35,y:509.6,width:184.8,height:187.05},{type:"basicBlock",x:-638.2,y:127,width:200,height:768.3},{type:"basicBlock",x:-380.15,y:706.65,width:200,height:1087.9},{type:"basicBlock",x:-1e3,y:55,width:200,height:300},{type:"basicBlock",x:1400,y:56,width:200,height:300},{type:"finishPortal",x:1236.25,y:133.95},{type:"basicBlock",x:-950,y:875,width:300,height:1425.1},{type:"basicBlock",x:200,y:1403,width:2000.2,height:370},{type:"basicBlock",x:1350.1,y:875.45,width:300,height:1425.1},{type:"basicBlock",x:1200,y:-157.15,width:600,height:200},{type:"basicBlock",x:-638.2,y:927.9,width:200,height:437.8},{type:"checkpoint",x:230.85,y:-536.8},{type:"circularCannon",x:102,y:-302},{type:"checkpoint",x:-469.95,y:125.65},{type:"checkpointSwimming",x:105.2,y:182.2},{type:"basicBlock",x:-279.35,y:-157.15,width:520,height:200},{type:"basicBlock",x:-67,y:-104,width:138,height:1268.4},{type:"basicBlock",x:351,y:-449,width:100,height:100},{type:"pushBlock",x:348.9,y:-561.95,width:50,height:50},{type:"speedBlock",x:601,y:-449,width:400,height:100},{type:"basicBlock",x:850,y:-473.8,width:100,height:150},{type:"basicBlock",x:332.85,y:-782.7,width:938.4,height:100},{type:"checkpoint",x:959.1,y:-295.15},{type:"basicBlock",x:850,y:-711.2,width:100,height:243.05},{type:"classicLaser",x:746.15,y:-698.9},{type:"basicBlock",x:1069.25,y:-542.8,width:100,height:573.1},{type:"basicBlock",x:350.4,y:-207.15,width:100,height:100},{type:"basicBlock",x:500,y:27.85,width:100,height:570.7},{type:"hazardStrips",x:540,y:-257.25},{type:"hazardStrips",x:899.1,y:-257.25},{type:"classicLaser",x:726.4,y:-136.3},{type:"laserPoint",x:545,y:-207.25},{type:"laserPoint",x:904.1,y:-207.25},{type:"checkpointSwimming",x:383.25,y:182.2},{type:"textFade",textNum:"5",x:969.25,y:-475.575,rotation:90.00175476074219},{type:"textFade",textNum:"5",x:426.1,y:-146.525,rotation:90.00175476074219},{type:"pole",x:823.2,y:-339.5},{type:"pole",x:642.15,y:-339.5},{type:"spawnPoint",x:-849.85,y:122.6},{type:"basicBlock",x:475.9,y:539.5,width:350,height:100},{type:"reaper",x:647.4,y:389.05,width:161.3,rotation:-90},{type:"basicBlock",x:819.2,y:460,width:100,height:750},{type:"basicBlock",x:594.2,y:785,width:350,height:100},{type:"reaper",x:383.95,y:662.35,width:126.35,rotation:-90},{type:"textFade",textNum:"34",x:357.25,y:995.2750000000001,rotation:0},{type:"checkpoint",x:1042.45,y:894.2},{type:"breatheBlaster",x:1034.8,y:926.1,rotation:-90},{type:"textFade",textNum:"5",x:1028.55,y:777.625,rotation:-89.99824523925781},{type:"reaper",x:1034.15,y:439.3,width:276.85,rotation:-90},{type:"reaper",x:1034.15,y:439.3,width:130.45,rotation:180},{type:"checkpoint",x:-187.5,y:88.1},{type:"swimmingPool",x:200,y:721,width:2e3,height:994}],level8:[{type:"textFade",textNum:"5",x:38,y:999.4250000000001,rotation:90},{type:"shurikanSpawner",x:1783.55,y:512.7,rotation:180},{type:"basicBlock",x:1294,y:383,width:112,height:100},{type:"basicBlock",x:738,y:233.5,width:100,height:201},{type:"buzzsaw",x:929.2,y:338.05,width:85,height:86},{type:"buzzsaw",x:929.2,y:227.05,width:85,height:86},{type:"textFade",textNum:"5",x:1589.65,y:558.275,rotation:-90},{type:"textFade",textNum:"5",x:1693.55,y:938.775,rotation:-90},{type:"checkpoint",x:481.85,y:1099.65},{type:"laserPoint",x:532.7,y:970},{type:"laserPoint",x:952,y:970},{type:"textFade",textNum:"5",x:190.025,y:1101.1,rotation:0},{type:"basicBlock",x:263,y:691.55,width:100,height:100.9},{type:"basicBlock",x:1189.95,y:884.6,width:120.1,height:249.2},{type:"finishPortal",x:835.4,y:303.25},{type:"basicBlock",x:625.15,y:383,width:692.8,height:100},{type:"spawnPoint",x:335.75,y:518.5},{type:"basicBlock",x:114,y:385,width:330,height:550},{type:"basicBlock",x:444,y:610,width:330,height:100},{type:"sparkBlock",x:785,y:610,width:100,height:100},{type:"basicBlock",x:1e3,y:688.6,width:100,height:257.4},{type:"checkpoint",x:1046.65,y:871.2},{type:"textFade",textNum:"35",x:488.22499999999997,y:615.1,rotation:0},{type:"textFade",textNum:"5",x:658.025,y:524.8,rotation:0},{type:"basicBlock",x:1190,y:496.45,width:120,height:326.8},{type:"hazardStrips",x:599,y:560.15},{type:"hazardStrips",x:950,y:560.15},{type:"laserPoint",x:603.85,y:610.4},{type:"laserPoint",x:955,y:610},{type:"textFade",textNum:"5",x:1102.1,y:558.275,rotation:90},{type:"sparkBlock",x:1190,y:710,width:120,height:120},{type:"checkpoint",x:415.2,y:899.45},{type:"key",x:1348.9,y:783.25},{type:"ziplinePole",x:963.5,y:875.4},{type:"ziplinePole",x:485.8,y:902.4},{type:"basicBlock",x:1223.25,y:959.2,width:553.4,height:100},{type:"basicBlock",x:320.25,y:987.45,width:435.2,height:100},{type:"reaper",x:719.5,y:864.25,width:150.6,rotation:-90},{type:"basicBlock",x:263,y:937.45,width:100,height:200},{type:"solarBlock",x:263,y:1087.45,width:100,height:111.55},{type:"lightSwitch",x:354.7,y:899.8},{type:"checkpoint",x:147.2,y:899.45},{type:"lightSwitch",x:73.05,y:1039.9},{type:"sparkBlock",x:36.7,y:1167.4,width:134,height:134},{type:"sparkBlock",x:263,y:1187.45,width:100,height:100},{type:"sparkBlock",x:396,y:1173.55,width:74,height:74},{type:"basicBlock",x:483,y:1287,width:100,height:300},{type:"solarBlock",x:263,y:792,width:100,height:111.55},{type:"basicBlock",x:263,y:1387.45,width:100,height:300},{type:"hazardStrips",x:527.85,y:937.75},{type:"hazardStrips",x:946.5,y:909.5},{type:"basicBlock",x:1400,y:546.3,width:100,height:100},{type:"basicBlock",x:1500,y:734.3,width:100,height:549.8},{type:"swimmingPool",x:1350.5,y:784.85,width:201,height:250},{type:"checkpoint",x:1501.6,y:421.4},{type:"speedBlock",x:1040.65,y:1187.15,width:1015.3,height:100},{type:"quadrantLeft",x:709.15,y:1188.25,rotation:0},{type:"quadrantLeft",x:930.2,y:1188.25,rotation:45},{type:"quadrantLeft",x:1137.25,y:1188.25,rotation:0},{type:"quadrantLeft",x:1358.3,y:1188.25,rotation:45},{type:"checkpoint",x:1598.6,y:1098.65},{type:"basicBlock",x:1749.5,y:1187,width:205,height:100.9},{type:"lockBlock",x:163,y:1387.15,width:100.05,height:100},{type:"basicBlock",x:163,y:1487.15,width:100,height:100},{type:"star",x:163.05,y:1388},{type:"key",x:1700.3,y:1030.4},{type:"lightSwitch",x:1640,y:1105},{type:"bounceBlock",x:1699.95,y:1106.55,width:60,height:60},{type:"shurikanSpawner",x:1560.9,y:902.8,rotation:0},{type:"shurikanSpawner",x:1783.55,y:855.8,rotation:180},{type:"lockBlock",x:1700,y:746.75,width:100.05,height:100},{type:"basicBlock",x:1600,y:747.2,width:100,height:100.9},{type:"basicBlock",x:1800,y:436.75,width:100,height:720.2},{type:"basicBlock",x:1598,y:1286.65,width:100,height:300},{type:"bounceBlock",x:1597.4,y:671.75,width:50,height:50},{type:"textFade",textNum:"36",x:402.775,y:985.625,rotation:0},{type:"textFade",textNum:"37",x:1451,y:538.5,rotation:0},{type:"textFade",textNum:"5",x:619.925,y:1100.95,rotation:0},{type:"lockBlock",x:1300,y:283,width:100.05,height:100},{type:"textFade",textNum:"5",x:1394.3,y:363.625,rotation:-90},{type:"basicBlock",x:1900,y:968.65,width:100,height:537.9},{type:"basicBlock",x:1240,y:183,width:219.8,height:100},{type:"basicBlock",x:-101,y:946,width:100,height:1672},{type:"checkpoint",x:1189.85,y:295},{type:"circularCannon",x:1051.05,y:286},{type:"basicBlock",x:879.4,y:183,width:184.8,height:100}],level9:[{type:"buzzsawVerticalUp",x:1225.1,y:425.9},{type:"buzzsaw",x:1322.1,y:459.9,width:101,height:102.2},{type:"buzzsawVerticalUp",x:776.15,y:325.9},{type:"buzzsawHorizontal",x:1053.9,y:573.95},{type:"buzzsaw",x:-265.4,y:-199.95,width:51,height:51.6},{type:"buzzsaw",x:-26.35,y:-225.95,width:51,height:51.6},{type:"buzzsaw",x:29.7,y:-225.95,width:51,height:51.6},{type:"buzzsaw",x:-119.4,y:-195.95,width:51,height:51.6},{type:"spike30x",x:-133.85,y:-47.9,rotation:0},{type:"spike30x",x:415.8,y:-47.9,rotation:0},{type:"spike30x",x:124.75,y:-47.9,rotation:0},{type:"timedKey",x:1054.8,y:115.85},{type:"timedKey",x:1054.8,y:571.05},{type:"fallingBlock",x:830.95,y:155.55,width:50,height:50},{type:"fallingBlock",x:1054.15,y:185,width:50,height:50},{type:"fallingBlock",x:1232.9,y:155.55,width:50,height:50},{type:"bouncingBuzzsaw",x:592.15,y:308.35,width:51},{type:"fallingSpike",x:574.3,y:564.9,rotation:90},{type:"fallingSpike",x:574.3,y:542.9,rotation:90},{type:"fallingSpike",x:574.3,y:521.4,rotation:90},{type:"fallingSpike",x:574.3,y:499.4,rotation:90},{type:"fallingSpike",x:659,y:609.4,rotation:-90},{type:"fallingSpike",x:659,y:631.4,rotation:-90},{type:"fallingSpike",x:659,y:652.9,rotation:-90},{type:"fallingSpike",x:659,y:674.9,rotation:-90},{type:"shurikanDispenser",x:187.9,y:300},{type:"shurikanDispenser",x:187.9,y:540},{type:"shurikanDispenser",x:428,y:542.95},{type:"shurikanDispenser",x:428,y:816.95},{type:"basicBlock",x:368,y:401.65,width:200,height:100},{type:"basicBlock",x:246.9,y:646.6,width:200,height:100},{type:"basicBlock",x:91.4,y:10,width:750,height:100},{type:"fallingSpike",x:181.35,y:126.55,rotation:180},{type:"fallingSpike",x:203.35,y:126.55,rotation:180},{type:"fallingSpike",x:-64.45,y:152.1,rotation:0},{type:"fallingSpike",x:-86.45,y:152.1,rotation:0},{type:"fallingSpike",x:-107.95,y:152.1,rotation:0},{type:"fallingSpike",x:-129.95,y:152.1,rotation:0},{type:"fallingSpike",x:79.55,y:152.1,rotation:0},{type:"fallingSpike",x:57.55,y:152.1,rotation:0},{type:"basicBlock",x:-8.1,y:210,width:750,height:100},{type:"basicBlock",x:-118.1,y:610,width:330,height:100},{type:"shurikanDispenser",x:-158.3,y:403.55},{type:"shurikanDispenser",x:-1.05,y:506.05},{type:"basicBlock",x:-333.1,y:510,width:100,height:300},{type:"basicBlock",x:-233.1,y:410,width:100,height:100},{type:"basicBlock",x:96.9,y:560.8,width:100,height:800},{type:"basicBlock",x:-80.1,y:462,width:50,height:50},{type:"checkpoint",x:-243.25,y:322},{type:"basicBlock",x:-208.1,y:489.05,width:50,height:58},{type:"pole",x:-517.1,y:304.55},{type:"pole",x:-649.1,y:249.55},{type:"pole",x:-489.3,y:200.55},{type:"shurikanDispenser",x:-597.4,y:172.75},{type:"checkpoint",x:-322.6,y:122},{type:"textFade",textNum:"5",x:-167.075,y:537.3,rotation:.004364013671875},{type:"textFade",textNum:"5",x:-421.1,y:298.17499999999995,rotation:-89.99563598632812},{type:"basicBlock",x:-750.05,y:291.35,width:100,height:934.6},{type:"fallingSpike",x:-223.65,y:67.9,rotation:180},{type:"fallingSpike",x:-201.65,y:67.9,rotation:180},{type:"fallingSpike",x:-180.15,y:67.9,rotation:180},{type:"fallingSpike",x:-158.15,y:67.9,rotation:180},{type:"fallingSpike",x:-36.15,y:67.9,rotation:180},{type:"fallingSpike",x:-14.15,y:67.9,rotation:180},{type:"fallingSpike",x:7.35,y:67.9,rotation:180},{type:"fallingSpike",x:29.35,y:67.9,rotation:180},{type:"basicBlock",x:196.9,y:40,width:100,height:159.95},{type:"checkpoint",x:316.35,y:122.15},{type:"textFade",textNum:"5",x:416.1,y:249.575,rotation:90.00436401367188},{type:"solarBlock",x:416.9,y:210,width:100,height:100},{type:"basicBlock",x:516.4,y:360.05,width:100,height:800},{type:"solarBlock",x:616.4,y:210,width:100,height:100},{type:"basicBlock",x:406.9,y:911,width:520,height:100},{type:"basicBlock",x:716.4,y:561,width:100,height:800},{type:"checkpoint",x:741.5,y:123},{type:"lightSwitch",x:415.15,y:120.55},{type:"swimmingPool",x:406.9,y:560.55,width:520,height:600.9},{type:"basicBlock",x:1046,y:676.45,width:560.1,height:100},{type:"basicBlock",x:1424,y:-108.1,width:200,height:330.1},{type:"basicBlock",x:1574,y:231.95,width:300,height:150},{type:"lockBlock",x:1474,y:106.95,width:100.05,height:100},{type:"basicBlock",x:1374,y:441.6,width:100.1,height:570},{type:"bounceBlock",x:1664.65,y:126.95,width:60,height:60},{type:"textFade",textNum:"5",x:1601.95,y:-1.9749999999999943,rotation:-104.99484252929688},{type:"ziplinePole",x:1341,y:-308.1},{type:"ziplinePole",x:517.1,y:-255},{type:"checkpoint",x:420.15,y:-258},{type:"textFade",textNum:"5",x:645.075,y:132.6,rotation:.004364013671875},{type:"shurikanDispenser",x:1125.55,y:-315.25},{type:"shurikanDispenser",x:712.95,y:-287.8},{type:"basicBlock",x:516.4,y:-124.8,width:100,height:190.25},{type:"basicBlock",x:414.65,y:-169.9,width:105.1,height:100},{type:"checkpoint",x:1463.85,y:-310.8},{type:"invisBlock",x:196.9,y:-169.9,width:100,height:100},{type:"textFade",textNum:"39",x:464.725,y:-165.175,rotation:0},{type:"textFade",textNum:"40",x:682.875,y:61.625,rotation:0},{type:"invisBlockUp",x:-.35,y:-225.95,width:52,height:52},{type:"invisBlockDown",x:-145.4,y:-195.95,width:52,height:52},{type:"invisBlockUp",x:-265.4,y:-225.95,width:52,height:52},{type:"invisBlockDown",x:-391.45,y:-285.95,width:52,height:52},{type:"invisBlockUp",x:-513.45,y:-193.95,width:52,height:52},{type:"finishPortal",x:-751.2,y:-205.55},{type:"star",x:1053.25,y:765.25},{type:"invisBlock",x:1499,y:751.6,width:50,height:50},{type:"invisBlock",x:1449.05,y:864.95,width:50,height:50},{type:"lockBlock",x:1374,y:106.95,width:100.05,height:100},{type:"invisBlock",x:1351.05,y:804.5,width:50,height:50},{type:"invisBlock",x:1255.6,y:864.95,width:50,height:50},{type:"invisBlock",x:1149.6,y:804.5,width:50,height:50},{type:"invisBlock",x:1054.15,y:864.95,width:50,height:50},{type:"invisBlock",x:1556.05,y:604.1,width:50,height:50},{type:"basicBlock",x:923.9,y:404,width:100,height:300},{type:"basicBlock",x:1176.6,y:404.55,width:100,height:300},{type:"swimmingPool",x:1045,y:410,width:558,height:432.9},{type:"spawnPoint",x:-258.25,y:505.15},{type:"textFade",textNum:"5",x:1679.375,y:357.55,rotation:-179.9947509765625},{type:"textFade",textNum:"5",x:1499.55,y:647.975,rotation:97.76797485351562},{type:"textFade",textNum:"5",x:1335.3249999999998,y:759.95,rotation:180}],level10:[{type:"basicBlock",x:143.1,y:146.7,width:56,height:61},{type:"basicBlock",x:604,y:-164.95,width:224.1,height:100},{type:"speedBlock",x:266.95,y:-664.75,width:50,height:50},{type:"spike10x",x:283.6,y:-590.15,rotation:-90},{type:"buzzsawHorizontal",x:239,y:-493.95},{type:"speedBlock",x:268.95,y:-518.5,width:50,height:50},{type:"spike10x",x:184.05,y:-344.75,rotation:90},{type:"speedBlockLeft",x:200.15,y:-417.2,width:50,height:50},{type:"spike10x",x:184.05,y:-489.75,rotation:90},{type:"speedBlockLeft",x:266.95,y:-173.15,width:50,height:50},{type:"bounceBlock",x:266.95,y:61.8,width:50,height:35},{type:"textFade",textNum:"5",x:-1026.25,y:148.02499999999998,rotation:-74.99945068359375},{type:"spike10x",x:-323.25,y:-489.15,rotation:90},{type:"spike10x",x:67.85,y:-301.8,rotation:-90},{type:"reaper",x:-933.45,y:-363.45,width:459,rotation:0},{type:"reaper",x:-933.5,y:-362.55,width:135.25,rotation:-45.001312255859375},{type:"reaper",x:-933.8,y:-362.05,width:316.45,rotation:-89.99824523925781},{type:"bouncingBuzzsaw",x:-1122.5,y:530.65,width:57},{type:"bouncingBuzzsaw",x:-1218.35,y:530.6,width:56.95},{type:"basicBlock",x:-1307,y:-14,width:100,height:698},{type:"timedKey",x:-792.3,y:774.25},{type:"bouncingBuzzsaw",x:-886.7,y:598.3,width:57},{type:"bouncingBuzzsaw",x:-708.1,y:597.05,width:57},{type:"bouncingBuzzsaw",x:-743.55,y:530.65,width:57},{type:"bouncingBuzzsaw",x:-839.4,y:530.6,width:56.95},{type:"checkpoint",x:-419.9,y:593.55},{type:"spike30x",x:159.2,y:337.25,rotation:-90},{type:"spike10x",x:-38.15,y:322.35,rotation:0},{type:"fallingSpike",x:-104.2,y:197.05,rotation:-90},{type:"fallingSpike",x:-104.2,y:172.55,rotation:-90},{type:"fallingSpike",x:-104.2,y:185.05,rotation:-90},{type:"basicBlock",x:-71,y:141.4,width:51,height:122.65},{type:"ziplinePole",x:-445,y:195.7},{type:"spike30x",x:-813.3,y:259.85,rotation:0},{type:"spike10x",x:-619.1,y:259.85,rotation:0},{type:"wire",x:410.9,y:30.05,rotation:-90},{type:"wire",x:360.9,y:30.05,rotation:-90},{type:"wire",x:310.9,y:30.05,rotation:-90},{type:"wire",x:260.9,y:30.05,rotation:-90},{type:"wire",x:210.9,y:30.05,rotation:-90},{type:"wire",x:160.9,y:30.05,rotation:-90},{type:"wire",x:110.9,y:30.05,rotation:-90},{type:"wire",x:60.9,y:30.05,rotation:-90},{type:"wire",x:10.9,y:30.05,rotation:-90},{type:"wire",x:-39.1,y:30.05,rotation:-90},{type:"wire",x:-89.1,y:30.05,rotation:-90},{type:"wire",x:-139.1,y:30.05,rotation:-90},{type:"wire",x:-160.1,y:59.05,rotation:180},{type:"wire",x:-160.1,y:109.05,rotation:180},{type:"wire",x:-189.1,y:130.05,rotation:-90},{type:"wire",x:-239.1,y:130.05,rotation:-90},{type:"wire",x:-289.1,y:130.05,rotation:-90},{type:"wire",x:-339.1,y:130.05,rotation:-90},{type:"wire",x:-389.1,y:130.05,rotation:-90},{type:"wire",x:-439.1,y:130.05,rotation:-90},{type:"wire",x:-489.1,y:130.05,rotation:-90},{type:"wire",x:-539.1,y:130.05,rotation:-90},{type:"wire",x:-589.1,y:130.05,rotation:-90},{type:"wire",x:-639.1,y:130.05,rotation:-90},{type:"wire",x:-689.1,y:130.05,rotation:-90},{type:"wire",x:-739.1,y:130.05,rotation:-90},{type:"wire",x:-789.1,y:130.05,rotation:-90},{type:"wire",x:-839.1,y:130.05,rotation:-90},{type:"wire",x:-889.1,y:130.05,rotation:-90},{type:"wire",x:-939.1,y:130.05,rotation:-90},{type:"wire",x:-989.1,y:130.05,rotation:-90},{type:"wire",x:-1039.1,y:130.05,rotation:-90},{type:"wire",x:-1089.1,y:130.05,rotation:-90},{type:"wire",x:-1110.1,y:159.05,rotation:180},{type:"basicBlock",x:381.05,y:127.3,width:330,height:100},{type:"finishPortal",x:484.9,y:-51.75},{type:"explosiveBlock",x:485.05,y:27.3,width:100,height:100},{type:"basicBlock",x:-1222,y:284,width:329.9,height:100},{type:"enlargingBuzzsaw",x:-782.2,y:130.3,width:124.7},{type:"basicBlock",x:-531.15,y:279.75,width:200,height:100},{type:"invisBlock",x:-895.3,y:229.65,width:50,height:50},{type:"invisBlockUp",x:-946.35,y:109.65,width:50,height:50},{type:"basicBlock",x:-895.3,y:-9.25,width:50,height:50},{type:"basicBlock",x:-683.7,y:-9.25,width:50,height:50},{type:"checkpoint",x:-513.9,y:191.75},{type:"basicBlock",x:-908,y:-313,width:700,height:100},{type:"basicBlock",x:-1008.95,y:531,width:100,height:593.2},{type:"basicBlock",x:-794.9,y:317.75,width:335.9,height:100},{type:"basicBlock",x:-381.15,y:-242,width:100,height:597.1},{type:"ziplinePole",x:-17.85,y:294.7},{type:"basicBlock",x:-16.55,y:379.75,width:60,height:100},{type:"fallingSpike",x:-82.05,y:286.55,rotation:0},{type:"fallingSpike",x:-57.55,y:286.55,rotation:0},{type:"fallingSpike",x:-70.05,y:286.55,rotation:0},{type:"basicBlock",x:-69.3,y:393.1,width:51,height:197.8},{type:"ziplinePole",x:65.75,y:532.25},{type:"basicBlock",x:113.05,y:617.3,width:110,height:100},{type:"basicBlock",x:193.05,y:391.75,width:50,height:551.1},{type:"basicBlock",x:10.7,y:127.3,width:214.8,height:100},{type:"textFade",textNum:"5",x:93.5,y:269.275,rotation:90.00175476074219},{type:"ziplinePole",x:-351.95,y:596.5},{type:"basicBlock",x:-440.1,y:680.55,width:200,height:100},{type:"basicBlock",x:-581.15,y:338.35,width:100,height:217},{type:"buzzsawOnStick",x:-226.2,y:552.5,rotation:-90},{type:"buzzsawOnStick",x:-90.95000000000002,y:540.3,rotation:90},{type:"laserPoint",x:-436.1,y:315.1},{type:"laserPoint",x:-90.5,y:315.1},{type:"hazardStrips",x:-94.8,y:294.45},{type:"hazardStrips",x:-441.15,y:229.75},{type:"basicBlock",x:-581.15,y:784.4,width:100,height:486.9},{type:"lightSwitch",x:-499.1,y:581.15},{type:"basicBlock",x:-958.75,y:978.2,width:656.2,height:100},{type:"solarBlock",x:-1009.15,y:878.2,width:100,height:100},{type:"basicBlock",x:-1337.15,y:810,width:100,height:436.8},{type:"checkpoint",x:-1439.1,y:554.65},{type:"lockBlock",x:-1337.15,y:542,width:100.05,height:100},{type:"basicBlock",x:-1337,y:412.8,width:100,height:158.5},{type:"basicBlock",x:-1475.65,y:641.5,width:178.9,height:100},{type:"bounceBlock",x:-1540.1,y:566.8,width:50,height:50},{type:"circularCannon",x:-1535.25,y:236.3},{type:"shurikanDispenser",x:-1425.15,y:142.65},{type:"shurikanDispenser",x:-1644.2,y:142.65},{type:"shurikanDispenser",x:-1425.15,y:329.7},{type:"shurikanDispenser",x:-1644.2,y:329.7},{type:"circularCannon",x:-1535.25,y:-76.75},{type:"shurikanDispenser",x:-1425.15,y:-170.4},{type:"shurikanDispenser",x:-1644.2,y:-170.4},{type:"shurikanDispenser",x:-1425.15,y:16.65},{type:"shurikanDispenser",x:-1644.2,y:16.65},{type:"checkpoint",x:-1307.25,y:-401.35},{type:"basicBlock",x:-1756.4,y:346.75,width:100,height:1224.1},{type:"textFade",textNum:"5",x:-1540.35,y:448.07500000000005,rotation:-89.99824523925781},{type:"pushBlock",x:-1203.3,y:-427.15,width:50,height:49.9},{type:"checkpoint",x:-380.65,y:-578.55},{type:"shurikanSpawner",x:-263.15,y:-279.5,rotation:-90},{type:"shurikanSpawner",x:29.2,y:-514.7,rotation:90},{type:"shurikanSpawner",x:-153.05,y:-514.7,rotation:90},{type:"iceBlock",x:-181.15,y:-490.55,width:300,height:100.05},{type:"iceBlock",x:-73.85,y:-303.2,width:300,height:100.05},{type:"iceBlock",x:-181.15,y:-98.15,width:300,height:100.05},{type:"shurikanSpawner",x:-301.1,y:-269.7,rotation:0},{type:"shurikanSpawner",x:-80.9,y:-159.6,rotation:180},{type:"shurikanSpawner",x:-318.6,y:-427.4,rotation:0},{type:"spawnPoint",x:-1231.25,y:209.9},{type:"swimmingPool",x:-959.2,y:767.2,width:656,height:322.1},{type:"basicBlock",x:341.95,y:59.8,width:100,height:38},{type:"speedBlock",x:201.15,y:-70.2,width:50,height:50},{type:"checkpoint",x:169.25,y:78.3},{type:"spike10x",x:284.05,y:-97,rotation:-90},{type:"basicBlock",x:341.95,y:-362.55,width:100,height:761.1},{type:"spike10x",x:184.05,y:-246.75,rotation:90},{type:"pole",x:226,y:-342.45},{type:"checkpoint",x:343.15,y:-781.1},{type:"basicBlock",x:763.05,y:-85.8,width:100,height:528.8},{type:"textFade",textNum:"4",x:-544.8,y:-458.625,rotation:0},{type:"textFade",textNum:"5",x:254.55,y:-28.025,rotation:-90},{type:"basicBlock",x:415.95,y:-718.1,width:50,height:50},{type:"basicBlock",x:466.95,y:-565.25,width:50,height:147},{type:"basicBlock",x:416.95,y:-418.35,width:50,height:50},{type:"lockBlock",x:441.95,y:-164.95,width:100.05,height:100},{type:"timedKey",x:683.85,y:-248.85},{type:"fallingBlock",x:466.95,y:-418.35,width:50,height:50},{type:"fallingBlock",x:516.95,y:-418.35,width:50,height:50},{type:"fallingBlock",x:566.95,y:-418.35,width:50,height:50},{type:"fallingBlock",x:616.95,y:-418.35,width:50,height:50},{type:"basicBlock",x:516.95,y:-277.45,width:50,height:124.95},{type:"classicLaser",x:423.95,y:-352.7},{type:"textFade",textNum:"42",x:-1166.65,y:287.3,rotation:0},{type:"basicBlock",x:688.65,y:-324.65,width:50,height:50},{type:"basicBlock",x:126,y:-448.8,width:100,height:807},{type:"lockBlock",x:763.05,y:-400.4,width:100.05,height:100},{type:"basicBlock",x:763.65,y:-714.5,width:100,height:528.8},{type:"basicBlock",x:924.1,y:-300.65,width:224.1,height:100},{type:"timedKey",x:993.65,y:-398.65},{type:"star",x:942.25,y:-400.05},{type:"basicBlock",x:925.7,y:-500.4,width:224.1,height:100},{type:"classicLaser",x:1061.7,y:-404.65}],level1c:[{type:"spike10x",x:45.9,y:477.6,rotation:90},{type:"spike10x",x:145.05,y:524.4,rotation:180},{type:"spike10x",x:41.05,y:416.25,rotation:180},{type:"textFade",textNum:"16",x:643.375,y:591.65,rotation:179.99913024902344},{type:"reaper",x:507.7,y:552.35,width:207.1,rotation:0},{type:"leftSlope",x:97,y:147.85,width:100,height:100,rotation:-90},{type:"leftSlope",x:-427.1,y:149.85,width:100,height:102,rotation:180},{type:"basicBlock",x:295.1,y:-90.95,width:116,height:100},{type:"spike30x",x:-417.1,y:-8.05,rotation:0},{type:"spike30x",x:5,y:-8.05,rotation:0},{type:"spike10x",x:-263.1,y:49.85,rotation:90},{type:"spike10x",x:-149.1,y:50,rotation:-90},{type:"basicBlock",x:-423.5,y:49.85,width:304.7,height:100.05},{type:"basicBlock",x:9.9,y:50,width:300.7,height:100.05},{type:"spike10x",x:137.1,y:-92.35,rotation:-90},{type:"basicBlock",x:820,y:670,width:220,height:100.05},{type:"textFade",textNum:"15",x:-588.025,y:352.75,rotation:179.99913024902344},{type:"textFade",textNum:"15",x:493.775,y:246.7,rotation:0},{type:"textFade",textNum:"17",x:62.25,y:500.225,rotation:-90.00175476074219},{type:"textFade",textNum:"17",x:-906.95,y:261.825,rotation:-90.00175476074219},{type:"textFade",textNum:"15",x:842.75,y:207.42499999999998,rotation:90},{type:"textFade",textNum:"15",x:-625.075,y:-276.55,rotation:-.0008697509765625},{type:"checkpoint",x:-812.7,y:61.85},{type:"bounceBlock",x:-903.95,y:355,width:50,height:50},{type:"buzzsawVerticalUp",x:-787.9,y:426.8},{type:"checkpoint",x:-494.8,y:342.55},{type:"buzzsaw",x:478.45,y:319.4,width:101,height:102.2},{type:"buzzsaw",x:587.45,y:319.4,width:101,height:102.2},{type:"spike10x",x:689.3,y:201.85,rotation:-90},{type:"basicBlock",x:722.2,y:148.5,width:50,height:205.1},{type:"basicBlock",x:620,y:0,width:780,height:100.05},{type:"basicBlock",x:360,y:320,width:230,height:100.05},{type:"textFade",textNum:"10",x:357.525,y:318.475,rotation:0},{type:"textFade",textNum:"8",x:360.5,y:178.89999999999998,rotation:0},{type:"spawnPoint",x:349.85,y:260.45},{type:"basicBlock",x:195,y:188.7,width:100,height:659.3},{type:"basicBlock",x:700,y:320,width:220,height:100.05},{type:"textFade",textNum:"11",x:699.9,y:319.1,rotation:0},{type:"basicBlock",x:760,y:445.05,width:100,height:150},{type:"basicBlock",x:960,y:484.75,width:100,height:871.5},{type:"verticalDownBlock",x:885,y:345.05,width:50,height:50},{type:"verticalUpBlock",x:835,y:495,width:50,height:50},{type:"textFade",textNum:"12",x:831.875,y:670.925,rotation:0},{type:"checkpoint",x:777.85,y:582.2},{type:"fallingBlock",x:685,y:645,width:50,height:50},{type:"fallingBlock",x:635,y:645,width:50,height:50},{type:"basicBlock",x:150,y:670,width:220,height:100.05},{type:"checkpoint",x:192.05,y:582.2},{type:"textFade",textNum:"14",x:148.7,y:675.425,rotation:0},{type:"bounceBlock",x:65,y:595.2,width:50,height:50},{type:"basicBlock",x:-10,y:612,width:100,height:584},{type:"ziplinePole",x:-12.95,y:285.05},{type:"ziplinePole",x:-428.9,y:345.55},{type:"basicBlock",x:-464.95,y:641.1,width:100,height:522.1},{type:"basicBlock",x:-737.55,y:150,width:186,height:100.05},{type:"basicBlock",x:-572,y:430,width:116.05,height:100.05},{type:"basicBlock",x:-1e3,y:-155.45,width:100,height:523.2},{type:"bounceBlock",x:-755.55,y:75,width:50,height:50},{type:"basicBlock",x:-538.7,y:-179.55,width:217.6,height:100.05},{type:"ziplinePole",x:193.05,y:-176.05},{type:"ziplinePole",x:-442.95,y:-264.55},{type:"finishPortal",x:289,y:-170.85},{type:"basicBlock",x:391.45,y:-274.9,width:100,height:467.1},{type:"basicBlock",x:-354.25,y:-458.45,width:1391.6,height:100.05},{type:"buzzsawVerticalUp",x:-309.3,y:-266.1},{type:"basicBlock",x:-1e3,y:497.9,width:100,height:785.2},{type:"textFade",textNum:"18",x:-516.5250000000001,y:280.5,rotation:0},{type:"basicBlock",x:-892,y:430,width:116.05,height:100.05},{type:"basicBlock",x:-562,y:34,width:171,height:332.1},{type:"star",x:-206.05,y:50.05},{type:"textFade",textNum:"41",x:-826.85,y:-3.575000000000003,rotation:0},{type:"bouncingBuzzsaw",x:886.5,y:497.5,width:39.6},{type:"circularCannon",x:505.9,y:552.8},{type:"basicBlock",x:65,y:384.95,width:50,height:50},{type:"basicBlock",x:120,y:493.35,width:50,height:50},{type:"buzzsawVerticalDown",x:-676.75,y:426.8},{type:"classicLaser",x:-885.35,y:147.5},{type:"classicLaser",x:-897.35,y:-212.7},{type:"classicLaser",x:-801.25,y:-212.7},{type:"classicLaser",x:-707.1,y:-212.7},{type:"buzzsawVerticalDown",x:-121.05,y:-243.05},{type:"buzzsawVerticalUp",x:56.25,y:-218}],level2c:[{type:"shurikanSpawner",x:918.55,y:-293.8,rotation:.0052490234375},{type:"shurikanDispenser",x:1135.6,y:141.2},{type:"spike30x",x:1464,y:232.9,rotation:180},{type:"spike10x",x:1658.2,y:232.9,rotation:180},{type:"buzzsaw",x:716.25,y:428,width:71.25,height:72.1},{type:"buzzsaw",x:707.2,y:300,width:49.5,height:50.1},{type:"buzzsaw",x:715.25,y:175,width:71.25,height:72.1},{type:"quadrantRight",x:537.8,y:489.7,rotation:0},{type:"spike10x",x:-170.1,y:77.7,rotation:180},{type:"spike10x",x:-171.55,y:114.6,rotation:0},{type:"windBlaster",x:82.2,y:597.3,rotation:-90},{type:"shurikanSpawner",x:1231.5,y:-471.35,rotation:90.0052490234375},{type:"shurikanSpawner",x:1085.85,y:-250,rotation:-89.9947509765625},{type:"shurikanSpawner",x:990.45,y:-471.35,rotation:90.0052490234375},{type:"basicBlock",x:1085.3,y:-200,width:460.2,height:100},{type:"verticalUpBlock",x:1137.3,y:-.05,width:356.1,height:150.1},{type:"verticalDownBlock",x:1137.3,y:225.05,width:358,height:100},{type:"basicBlock",x:739.35,y:175,width:48.2,height:100},{type:"ziplinePole",x:1043.95,y:530.05},{type:"shurikanSpawner",x:795.9,y:254.95,rotation:180},{type:"basicBlock",x:809.25,y:-128.65,width:100,height:1015.2},{type:"checkpoint",x:562.35,y:-66},{type:"spike10x",x:265.1,y:14,rotation:0},{type:"spike10x",x:361.6,y:14,rotation:0},{type:"spike10x",x:457.6,y:14,rotation:0},{type:"textFade",textNum:"17",x:-87.52499999999999,y:222.55,rotation:-15.002182006835938},{type:"checkpoint",x:-107.8,y:291.75},{type:"textFade",textNum:"20",x:326.15,y:487.17499999999995,rotation:0},{type:"spike10x",x:83.6,y:461.15,rotation:180},{type:"spike10x",x:83.6,y:588.4,rotation:0},{type:"basicBlock",x:449,y:320,width:230,height:100.05},{type:"spawnPoint",x:385.9,y:245},{type:"basicBlock",x:611,y:470,width:94,height:800},{type:"basicBlock",x:84.05,y:261.7,width:100,height:383.1},{type:"basicBlock",x:195.55,y:647.05,width:737.5,height:100.05},{type:"basicBlock",x:-118.5,y:464.75,width:107,height:272.1},{type:"textFade",textNum:"17",x:269.9,y:275.025,rotation:90},{type:"basicBlock",x:254.95,y:46.8,width:442.1,height:50},{type:"basicBlock",x:10,y:252.7,width:50,height:50},{type:"basicBlock",x:-221,y:308.05,width:100,height:778},{type:"basicBlock",x:89.5,y:-3,width:254,height:50},{type:"spike",x:-104,y:28.8,rotation:180},{type:"spike",x:-115.5,y:28.8,rotation:180},{type:"spike",x:-115,y:-37.4,rotation:0},{type:"spike",x:-103.5,y:-37.4,rotation:0},{type:"verticalDownBlock",x:-109,y:-4,width:25,height:50},{type:"checkpoint",x:45.5,y:-66},{type:"basicBlock",x:-121.55,y:147.65,width:100,height:50},{type:"basicBlock",x:591.6,y:22,width:235.1,height:99.5},{type:"pushBlock",x:165,y:-120,width:50,height:49.9},{type:"basicBlock",x:295.3,y:-235.55,width:929.6,height:100.05},{type:"star",x:-223.95,y:-209.95},{type:"pushBlock",x:734.25,y:-2.05,width:50,height:49.9},{type:"basicBlock",x:682.2,y:300,width:50,height:50},{type:"textFade",textNum:"17",x:347.975,y:-62.55,rotation:-.00262451171875},{type:"basicBlock",x:735.25,y:428,width:50,height:100},{type:"sparkBlock",x:809.1,y:482.1,width:100,height:208.2},{type:"basicBlock",x:1007.45,y:716.85,width:100,height:305.95},{type:"checkpoint",x:978.1,y:525.9},{type:"textFade",textNum:"21",x:124.25,y:16.700000000000003,rotation:0},{type:"textFade",textNum:"22",x:603.325,y:48.900000000000006,rotation:0},{type:"ziplinePole",x:1396.9,y:576.55},{type:"basicBlock",x:1395.9,y:761,width:100,height:305.05},{type:"shurikanSpawner",x:1183.45,y:682.5,rotation:-89.9947509765625},{type:"basicBlock",x:1544.9,y:658.5,width:200,height:100},{type:"bounceBlock",x:1538.9,y:582.5,width:52,height:52},{type:"checkpoint",x:1380.1,y:87},{type:"basicBlock",x:1516.45,y:175,width:400.1,height:100},{type:"basicBlock",x:909,y:175,width:100,height:100},{type:"basicBlock",x:883.1,y:75,width:48.2,height:100},{type:"basicBlock",x:1365.35,y:-25,width:100,height:100},{type:"basicBlock",x:1465.35,y:-112,width:100,height:274.1},{type:"pushBlock",x:1273.3,y:-338.6,width:50,height:49.9},{type:"basicBlock",x:883.25,y:-336.55,width:50,height:175.05},{type:"finishPortal",x:883.25,y:-453.55},{type:"basicBlock",x:811,y:819,width:306.9,height:100.05},{type:"spike",x:-55.5,y:179.85,rotation:180},{type:"spike",x:-67,y:179.85,rotation:180},{type:"spike",x:-66.5,y:113.65,rotation:0},{type:"spike",x:-55,y:113.65,rotation:0},{type:"verticalUpBlock",x:-60.5,y:147.05,width:25,height:50},{type:"lockBlock",x:-15,y:378.7,width:100.05,height:100},{type:"timedKey",x:538.85,y:489.55},{type:"swimmingPool",x:249.25,y:472.3,width:630.5,height:250},{type:"basicBlock",x:809.1,y:635.2,width:100,height:100},{type:"swimmingPool",x:807.95,y:677.5,width:299.9,height:185},{type:"bouncingBuzzsaw",x:374.85,y:-145.6,width:69.35},{type:"shurikanSpawner",x:1125.15,y:460.2,rotation:90.0052490234375},{type:"shurikanSpawner",x:1312.4,y:460.2,rotation:90.0052490234375},{type:"basicBlock",x:1774.65,y:346,width:100,height:100},{type:"checkpoint",x:1445.15,y:570.5},{type:"basicBlock",x:1653.7,y:610.05,width:146.2,height:196.9},{type:"spike10x",x:1572.7,y:560.2,rotation:-90},{type:"basicBlock",x:1874.65,y:296,width:100,height:200},{type:"checkpoint",x:1352.15,y:-113},{type:"basicBlock",x:-146,y:45.15,width:50,height:50}],level3c:[{type:"shurikanSpawner",x:1604.95,y:59.4,rotation:180},{type:"textFade",textNum:"17",x:175.275,y:133.25,rotation:0},{type:"buzzsawHorizontal",x:-108,y:11.05},{type:"glassBlock",x:-107.9,y:10.95,width:100,height:100.05},{type:"glassBlock",x:-107.9,y:210.95,width:100,height:100.05},{type:"basicBlock",x:715.55,y:409.4,width:40,height:40},{type:"checkpoint",x:616.25,y:420.1},{type:"bounceBlock",x:1587.4,y:286.1,width:46,height:55},{type:"ziplinePole",x:26.95,y:-86.85},{type:"checkpoint",x:-34.1,y:-89.8},{type:"basicBlock",x:-7.9,y:252.7,width:100,height:611},{type:"spike30x",x:-749.75,y:368.35,rotation:180},{type:"spike30x",x:-697.7,y:549.3,rotation:0},{type:"spike30x",x:-456.65,y:368.35,rotation:180},{type:"spike30x",x:-406.6,y:549.3,rotation:0},{type:"bounceBlock",x:987.15,y:5.1,width:45,height:45},{type:"checkpoint",x:-107.35,y:420.1},{type:"spike30x",x:216.7,y:-61.15,rotation:0},{type:"shurikanSpawner",x:1436.75,y:216.65,rotation:-90},{type:"spike10x",x:1249.1,y:77.1,rotation:90},{type:"spike10x",x:933,y:79.1,rotation:-90},{type:"spike30x",x:1090.45,y:134,rotation:180},{type:"basicBlock",x:1091.05,y:77.1,width:300,height:100.05},{type:"checkpoint",x:1328.55,y:120.95},{type:"basicBlock",x:516.05,y:208.1,width:40,height:40},{type:"checkpoint",x:322.75,y:120.95},{type:"bounceBlock",x:97.05,y:433.1,width:50,height:50},{type:"fallingBlock",x:717,y:707.1,width:100,height:100.05},{type:"textFade",textNum:"17",x:716,y:537.075,rotation:-90},{type:"spawnPoint",x:721,y:643.1},{type:"basicBlock",x:617.05,y:607.1,width:100,height:300},{type:"basicBlock",x:817,y:457.1,width:100,height:600},{type:"buzzsawOnStick",x:717.9,y:705.8,rotation:-90},{type:"pole",x:413.1,y:393.1},{type:"basicBlock",x:192.1,y:607.6,width:100,height:299},{type:"textFade",textNum:"23",x:412.15,y:325.975,rotation:0},{type:"textFade",textNum:"24",x:412.175,y:499.97499999999997,rotation:0},{type:"basicBlock",x:-60,y:508.1,width:404.1,height:100.05},{type:"pole",x:90.3,y:100.95},{type:"basicBlock",x:317.05,y:208.1,width:100,height:100.05},{type:"textFade",textNum:"25",x:-7.149999999999999,y:179.075,rotation:0},{type:"fallingBlock",x:417.05,y:208.1,width:100,height:100},{type:"fallingBlock",x:617.05,y:208.1,width:100,height:100},{type:"buzzsawOnStick",x:516.4,y:203.7,rotation:-90},{type:"iceBlock",x:1087.05,y:233.1,width:440,height:150.05},{type:"basicBlock",x:1357.05,y:408.1,width:100,height:500},{type:"textFade",textNum:"26",x:951.5250000000001,y:188.64999999999998,rotation:0},{type:"basicBlock",x:1531.05,y:213.1,width:78,height:200},{type:"ziplinePole",x:853.2,y:-232},{type:"basicBlock",x:891.05,y:-147.95,width:100,height:100.05},{type:"textFade",textNum:"17",x:1152.3249999999998,y:4.35,rotation:180},{type:"basicBlock",x:-7.9,y:-350.1,width:100,height:400},{type:"basicBlock",x:-208,y:-172.5,width:100,height:1065.3},{type:"textFade",textNum:"27",x:-208.75,y:-57.9,rotation:0},{type:"glassBlock",x:-107.9,y:408.95,width:100,height:100.05},{type:"textFade",textNum:"17",x:-109.6,y:-151.425,rotation:90},{type:"basicBlock",x:202.2,y:-2.8,width:321,height:100.05},{type:"basicBlock",x:-600.2,y:309.95,width:685.1,height:100.05},{type:"basicBlock",x:-550.3,y:607,width:785.3,height:100.05},{type:"basicBlock",x:-892.9,y:563.35,width:100,height:607.1},{type:"finishPortal",x:-810.2,y:470.15},{type:"pole",x:-340.1,y:463.1},{type:"pole",x:-551.15,y:463.1},{type:"pole",x:-740.2,y:463.1},{type:"shurikanSpawner",x:-727.4,y:382.85,rotation:45},{type:"fallingBlock",x:67.1,y:-525.1,width:50,height:50},{type:"fallingBlock",x:219.1,y:-549.1,width:50,height:50},{type:"fallingBlock",x:378.75,y:-567.1,width:50,height:50},{type:"fallingBlock",x:530.75,y:-591.1,width:50,height:50},{type:"buzzsawOnStick",x:142.9,y:-543.1,rotation:-90},{type:"buzzsawOnStick",x:304.75,y:-549.05,rotation:90},{type:"buzzsawOnStick",x:452.25,y:-581.2,rotation:-90},{type:"buzzsawOnStick",x:614.1,y:-587.15,rotation:90},{type:"star",x:616.15,y:-678.15},{type:"basicBlock",x:1657.05,y:102.1,width:100,height:422},{type:"basicBlock",x:1073.7,y:-393.9,width:100,height:592},{type:"basicBlock",x:1572.6,y:-147.95,width:269.1,height:100.05},{type:"pushBlock",x:1581.35,y:87.9,width:50,height:49.9},{type:"pole",x:1448.35,y:-57.85},{type:"buzzsawOnStick",x:715.7,y:414,rotation:90},{type:"shurikanSpawner",x:-397.6,y:540.5,rotation:-135},{type:"classicLaser",x:414.55,y:566.15},{type:"timedKey",x:1384.8,y:133.1},{type:"lockBlock",x:1191.05,y:-22.9,width:100.05,height:100},{type:"basicBlock",x:1135.75,y:-147.95,width:26.3,height:100.05},{type:"basicBlock",x:1191.05,y:-135.4,width:100,height:125}],level4c:[{type:"fallingSpike",x:-587.55,y:-466.45,rotation:0},{type:"fallingSpike",x:-609.05,y:-466.45,rotation:0},{type:"fallingSpike",x:-501.45,y:-466.45,rotation:0},{type:"fallingSpike",x:-522.95,y:-466.45,rotation:0},{type:"fallingSpike",x:-415.3,y:-466.45,rotation:0},{type:"fallingSpike",x:-436.8,y:-466.45,rotation:0},{type:"fallingSpike",x:-329.2,y:-466.45,rotation:0},{type:"fallingSpike",x:-350.7,y:-466.45,rotation:0},{type:"fallingSpike",x:842.7,y:-369.6,rotation:-90},{type:"fallingSpike",x:842.7,y:-348.1,rotation:-90},{type:"fallingSpike",x:842.7,y:-412.7,rotation:-90},{type:"fallingSpike",x:842.7,y:-391.2,rotation:-90},{type:"fallingSpike",x:842.7,y:-434.2,rotation:-90},{type:"fallingSpike",x:932.15,y:-167.85,rotation:0},{type:"fallingSpike",x:910.65,y:-167.85,rotation:0},{type:"fallingSpike",x:975.25,y:-167.85,rotation:0},{type:"fallingSpike",x:953.75,y:-167.85,rotation:0},{type:"fallingSpike",x:996.75,y:-167.85,rotation:0},{type:"quadrantLeft",x:944.25,y:342.6,rotation:0},{type:"verticalUpBlock",x:943.25,y:339.6,width:32,height:100},{type:"quadrantLeft",x:1146.3,y:342.6,rotation:0},{type:"verticalDownBlock",x:1145.3,y:339.6,width:32,height:100},{type:"quadrantLeft",x:91,y:197.05,rotation:0},{type:"spike10x",x:703.05,y:320,rotation:89.99824523925781},{type:"spike10x",x:746.5,y:461.85,rotation:-.0008697509765625},{type:"spike10x",x:786.1,y:321.4,rotation:-90.00175476074219},{type:"fallingSpike",x:-393.75,y:-571.35,rotation:180},{type:"fallingSpike",x:-372.25,y:-571.35,rotation:180},{type:"fallingSpike",x:-479.85,y:-571.35,rotation:180},{type:"fallingSpike",x:-458.35,y:-571.35,rotation:180},{type:"fallingSpike",x:-566,y:-571.35,rotation:180},{type:"fallingSpike",x:-544.5,y:-571.35,rotation:180},{type:"fallingSpike",x:-652.1,y:-571.35,rotation:180},{type:"fallingSpike",x:-630.6,y:-571.35,rotation:180},{type:"basicBlock",x:-770.2,y:-567.4,width:100,height:225.2},{type:"spike30x",x:200.45,y:-167.85,rotation:0},{type:"spike10x",x:8.05,y:-168.1,rotation:0},{type:"spike10x",x:-87.45,y:-168.1,rotation:0},{type:"textFade",textNum:"5",x:37.05,y:342.975,rotation:-90},{type:"textFade",textNum:"4",x:617.5,y:-5.225000000000001,rotation:0},{type:"windBlaster",x:1249.1,y:70.95,rotation:-90},{type:"buzzsaw",x:1044.4,y:340.25,width:101,height:102.2},{type:"glassBlock",x:943.95,y:143.65,width:100,height:100},{type:"basicBlock",x:1043.95,y:90.85,width:100,height:500},{type:"basicBlock",x:666.85,y:44.75,width:50,height:100},{type:"spike10x",x:187.1,y:318.25,rotation:-90.00175476074219},{type:"spike10x",x:183.05,y:485.85,rotation:89.99824523925781},{type:"shurikanSpawner",x:555.4,y:311.8,rotation:90},{type:"speedBlock",x:545,y:320,width:300,height:100.05},{type:"basicBlock",x:345,y:320,width:100,height:100.05},{type:"spawnPoint",x:331.9,y:240.55},{type:"basicBlock",x:345,y:615.35,width:100,height:291.2},{type:"basicBlock",x:956.05,y:520,width:522.1,height:100.05},{type:"speedBlockLeft",x:545,y:520,width:300,height:100.05},{type:"checkpoint",x:347.3,y:432},{type:"basicBlock",x:844,y:418,width:100,height:696},{type:"basicBlock",x:245,y:219.85,width:100,height:300},{type:"textFade",textNum:"5",x:469.42499999999995,y:236.05,rotation:0},{type:"basicBlock",x:87.3,y:486.85,width:176.7,height:100.05},{type:"basicBlock",x:545.05,y:119.85,width:500.1,height:100.05},{type:"basicBlock",x:-50,y:300.9,width:100,height:921.7},{type:"classicLaser",x:154.05,y:240.6},{type:"checkpoint",x:252.35,y:32},{type:"verticalUpBlock",x:90,y:194.05,width:50,height:100},{type:"basicBlock",x:90,y:343.1,width:50,height:100},{type:"textFade",textNum:"28",x:332.4,y:323.725,rotation:0},{type:"basicBlock",x:250,y:-109.75,width:500.1,height:100.05},{type:"bouncingBuzzsaw",x:571.75,y:-75.8,width:69},{type:"basicBlock",x:940.9,y:-109,width:402.1,height:100.05},{type:"star",x:450.95,y:-204.95},{type:"basicBlock",x:350.05,y:-258.55,width:100,height:200},{type:"basicBlock",x:473.05,y:-309,width:346,height:100.05},{type:"basicBlock",x:691.85,y:-209,width:100,height:300},{type:"checkpoint",x:839.4,y:32},{type:"basicBlock",x:1249.1,y:423.1,width:100,height:706.3},{type:"checkpoint",x:1081.8,y:-196.95},{type:"windBlaster",x:789.85,y:-157.95,rotation:-90},{type:"windBlaster",x:954.25,y:-341,rotation:90},{type:"basicBlock",x:948.85,y:-391,width:198,height:100.05},{type:"checkpoint",x:401.35,y:-397.05},{type:"textFade",textNum:"5",x:777.125,y:-393.65,rotation:180},{type:"basicBlock",x:-150,y:202,width:100,height:1122},{type:"buzzsawOnStick",x:210.65,y:-299.35,rotation:90},{type:"checkpoint",x:-255.85,y:-496.2},{type:"basicBlock",x:-459.9,y:-408.2,width:720.6,height:100.05},{type:"basicBlock",x:-459.25,y:-630,width:720.6,height:100.05},{type:"finishPortal",x:-690.05,y:-487.2},{type:"buzzsawOnStick",x:-21.199999999999996,y:-309,rotation:-90},{type:"textFade",textNum:"5",x:248.175,y:425.8,rotation:-165.00189208984375},{type:"swimmingPool",x:1046.95,y:331.8,width:306,height:276.3},{type:"iceBlock",x:511.95,y:-396.8,width:75,height:75.05},{type:"basicBlock",x:511.95,y:-500.3,width:75,height:132},{type:"spike30x",x:46.4,y:-367.2,rotation:0},{type:"iceBlock",x:99.55,y:-309,width:401,height:100.05},{type:"pushBlock",x:326.1,y:-418.15,width:50,height:49.9}],level5c:[{type:"laserPoint",x:543.75,y:565},{type:"laserPoint",x:1269.1,y:565},{type:"laserPoint",x:122,y:146.55},{type:"laserPoint",x:231,y:146.55},{type:"buzzsawOnStick",x:349.95,y:800.1,rotation:90},{type:"buzzsawOnStick",x:534.3,y:791.4,rotation:-90},{type:"buzzsawOnStick",x:157.9,y:792.1,rotation:-90},{type:"quadrantLeft",x:730.1,y:-192.5,rotation:0},{type:"quadrantLeft",x:1006.85,y:-192.5,rotation:0},{type:"bounceBlock",x:1439.4,y:808.7,width:50,height:50},{type:"glassBlock",x:390,y:157.5,width:126,height:100},{type:"spike30x",x:-180.55,y:465.85,rotation:-90},{type:"classicLaser",x:275.15,y:54.4},{type:"textFade",textNum:"15",x:386,y:219.525,rotation:90.00175476074219},{type:"spike10x",x:135.4,y:462.45,rotation:90},{type:"checkpoint",x:-95.8,y:54.65},{type:"glassBlock",x:389,y:-105.3,width:122,height:100},{type:"quadrantRight",x:730.1,y:-192.5,rotation:0},{type:"quadrantRight",x:1006.85,y:-192.5,rotation:0},{type:"textFade",textNum:"15",x:1367.1,y:-10.025000000000006,rotation:-104.99729919433594},{type:"bounceBlock",x:1396,y:115,width:50,height:50},{type:"checkpoint",x:1314.2,y:102.65},{type:"spawnPoint",x:715.8,y:258},{type:"finishPortal",x:1514.6,y:552.25},{type:"basicBlock",x:1314.1,y:387.3,width:100,height:495.3},{type:"bouncingBuzzsaw",x:914.1,y:0,width:101},{type:"bouncingBuzzsaw",x:1114.1,y:0,width:101},{type:"basicBlock",x:1414.1,y:190,width:100,height:100},{type:"quadrantLeft",x:1373,y:-83,rotation:0},{type:"basicBlock",x:1232.85,y:-142.5,width:100.1,height:100},{type:"textFade",textNum:"15",x:804.125,y:230,rotation:-14.99810791015625},{type:"checkpoint",x:1234.6,y:-230.5},{type:"iceBlock",x:905.3,y:-142.5,width:556.9,height:100.05},{type:"basicBlock",x:573.8,y:-142.5,width:106.1,height:100},{type:"checkpoint",x:578.55,y:-230.5},{type:"basicBlock",x:1514,y:-35.35,width:100,height:1051.2},{type:"basicBlock",x:497.75,y:210.55,width:100,height:806.1},{type:"basicBlock",x:277,y:252.95,width:100,height:291},{type:"basicBlock",x:226.7,y:562,width:200,height:100},{type:"pushBlock",x:470.15,y:-279.05,width:50,height:49.9},{type:"basicBlock",x:26.95,y:454,width:200.1,height:316.05},{type:"basicBlock",x:77,y:-49.65,width:100,height:488.1},{type:"basicBlock",x:177.55,y:-225.05,width:301,height:462.9},{type:"pole",x:384.1,y:439.65},{type:"rightSlope",x:-22.9,y:247.55,width:100,height:100,rotation:0},{type:"ziplinePole",x:-156.3,y:58},{type:"ziplinePole",x:-599.15,y:119.2},{type:"spike30x",x:-538.25,y:195.6,rotation:90},{type:"ziplinePole",x:-154.05,y:379.25},{type:"classicLaser",x:-206.3,y:202.7},{type:"ziplinePole",x:-599.15,y:292.7},{type:"ziplinePole",x:-154.05,y:414.3},{type:"ziplinePole",x:-599.15,y:524.95},{type:"classicLaser",x:-512.65,y:417.9},{type:"ziplinePole",x:-599.15,y:575.95},{type:"ziplinePole",x:-135.05,y:746.15},{type:"checkpoint",x:-63.55,y:743.2},{type:"basicBlock",x:-123.1,y:352,width:100,height:520},{type:"spike10x",x:-538.25,y:595.35,rotation:90},{type:"basicBlock",x:-596.15,y:349.85,width:100,height:600.2},{type:"buzzsaw",x:386.1,y:560.4,width:121.2,height:122.65},{type:"buzzsawHorizontal",x:-320.25,y:377.8},{type:"pole",x:158.05,y:796.25},{type:"pole",x:350.1,y:796.25},{type:"pole",x:534.1,y:796.25},{type:"basicBlock",x:725,y:831,width:100,height:100},{type:"checkpoint",x:730.65,y:743.25},{type:"basicBlock",x:-96.45,y:831,width:153,height:100},{type:"hazardStrips",x:538.75,y:513.9},{type:"hazardStrips",x:1264.1,y:535.25},{type:"hazardStrips",x:117,y:93.65},{type:"hazardStrips",x:227,y:107.45},{type:"basicBlock",x:1216.55,y:856,width:503.3,height:50},{type:"basicBlock",x:1167.3,y:808.7,width:236.1,height:50},{type:"basicBlock",x:1374.35,y:808.7,width:80.1,height:50},{type:"basicBlock",x:1514,y:731.1,width:100,height:298.9},{type:"fallingBlock",x:387.95,y:346,width:100,height:100},{type:"star",x:-271.05,y:435.1},{type:"bouncingBuzzsaw",x:1210.35,y:666.8,width:65.5},{type:"quadrantLeft",x:1373,y:-83,rotation:45},{type:"fallingBlock",x:714.1,y:340.1,width:100,height:100},{type:"fallingBlock",x:914.1,y:289.95,width:100,height:100},{type:"fallingBlock",x:1114.1,y:240.15,width:100,height:100},{type:"basicBlock",x:901.55,y:-331.8,width:761.6,height:100},{type:"classicLaser",x:-223.4,y:548.25},{type:"classicLaser",x:-505.75,y:202.7}],level6c:[{type:"quadrantRight",x:290.8,y:-852.25,rotation:0,width:179.5},{type:"quadrantLeft",x:-44,y:-76.5,rotation:44.99913024902344,width:211.5},{type:"checkpoint",x:311.95,y:-388.05},{type:"quadrantRight",x:385.05,y:-737.25,rotation:0,width:179.5},{type:"spike10x",x:28.6,y:308.75,rotation:180},{type:"spike30x",x:-171.4,y:207.9,rotation:180},{type:"textFade",textNum:"5",x:752.425,y:-131,rotation:.0008697509765625},{type:"bounceBlock",x:232,y:-74.5,width:50,height:50},{type:"checkpoint",x:26.85,y:-338},{type:"quadrantRight",x:-44,y:-76.5,rotation:0,width:211.5},{type:"checkpoint",x:402.8,y:163.25},{type:"quadrantLeft",x:680.2,y:401.1,rotation:0,width:201.5},{type:"key",x:675.1,y:403.2},{type:"basicBlock",x:380,y:350,width:200,height:300},{type:"spawnPoint",x:329.35,y:173.9},{type:"finishPortal",x:225.45,y:770.5},{type:"lockBlock",x:230,y:250,width:100.05,height:100},{type:"lockBlock",x:230,y:350,width:100.05,height:100},{type:"lockBlock",x:230,y:450,width:100.05,height:100},{type:"lockBlock",x:230,y:550,width:100.05,height:100},{type:"basicBlock",x:530,y:398.5,width:100,height:397.1},{type:"basicBlock",x:130,y:550,width:100,height:700},{type:"basicBlock",x:630,y:150,width:100,height:100},{type:"basicBlock",x:30,y:200,width:100,height:200},{type:"textFade",textNum:"31",x:336.07500000000005,y:92.625,rotation:0},{type:"textFade",textNum:"32",x:333.9,y:253.325,rotation:0},{type:"basicBlock",x:630,y:-50,width:100,height:100},{type:"basicBlock",x:30,y:-150,width:100,height:300.1},{type:"basicBlock",x:330,y:0,width:300,height:100},{type:"basicBlock",x:830,y:300,width:100,height:600},{type:"checkpoint",x:630.3,y:62},{type:"checkpoint",x:26.85,y:62},{type:"swimmingPool",x:680,y:400,width:200,height:200},{type:"basicBlock",x:-170,y:-125,width:100,height:350},{type:"basicBlock",x:-169,y:150,width:300,height:100},{type:"basicBlock",x:330,y:700,width:100,height:400},{type:"basicBlock",x:580,y:550,width:400,height:100},{type:"basicBlock",x:-95,y:25,width:50,height:50},{type:"basicBlock",x:-45,y:-75,width:50,height:50},{type:"key",x:-106.1,y:-174.55},{type:"basicBlock",x:-70,y:-250,width:100,height:100},{type:"basicBlock",x:330,y:-200,width:100,height:300.1},{type:"textFade",textNum:"5",x:128.05,y:61.975,rotation:-90},{type:"textFade",textNum:"5",x:532.15,y:56.575,rotation:-90},{type:"checkpoint",x:640.5,y:-138},{type:"basicBlock",x:1230,y:-50,width:100,height:100},{type:"buzzsawOnStick",x:1004.1,y:-55,rotation:-90},{type:"buzzsawOnStick",x:814.8,y:-274.45,rotation:90},{type:"key",x:816,y:-369.55},{type:"bounceBlock",x:1230.3,y:-124.95,width:50,height:50},{type:"lockBlock",x:230,y:650,width:100.05,height:100},{type:"basicBlock",x:230,y:850,width:100,height:100},{type:"ziplinePole",x:-182.05,y:-335.1},{type:"ziplinePole",x:-749.2,y:-185.1},{type:"key",x:-504.2,y:-311.95},{type:"basicBlock",x:-750,y:-50,width:100,height:200},{type:"ziplinePole",x:-656.15,y:-84.55},{type:"ziplinePole",x:-259.05,y:64.95},{type:"basicBlock",x:-650,y:0,width:100,height:100},{type:"classicLaser",x:-249.1,y:-152.75},{type:"enlargingBuzzsaw",x:-437.1,y:-140.75,width:101},{type:"basicBlock",x:-850,y:-175,width:100,height:450},{type:"textFade",textNum:"5",x:732.05,y:203.125,rotation:90.00175476074219},{type:"textFade",textNum:"5",x:172.775,y:-317.3,rotation:-179.99913024902344},{type:"windBlaster",x:330,y:-350.05,rotation:-90},{type:"fallingBlock",x:381,y:-548,width:50,height:50},{type:"fallingBlock",x:291,y:-640,width:50,height:50},{type:"fallingBlock",x:385,y:-734,width:50,height:50},{type:"fallingBlock",x:291,y:-852,width:50,height:50},{type:"key",x:345.5,y:-947.4},{type:"bounceBlock",x:-270,y:650,width:70,height:70},{type:"key",x:31.95,y:569.3},{type:"bounceBlock",x:30,y:650,width:70,height:70},{type:"sparkBlock",x:630,y:250,width:100,height:100},{type:"speedBlock",x:780,y:-50,width:200,height:100},{type:"shurikanDispenser",x:-117.05,y:454.95},{type:"classicLaser",x:-634.05,y:-152.75},{type:"spike10x",x:755.9,y:-499.7,rotation:-90.00175476074219},{type:"spike10x",x:814.4,y:-558,rotation:0},{type:"spike10x",x:911.8,y:-558,rotation:0},{type:"basicBlock",x:863.8,y:-500.1,width:200,height:100},{type:"speedBlockLeft",x:1080,y:-283.05,width:200,height:100}],level7c:[{type:"quadrantLeft",x:692.15,y:896.2,rotation:45},{type:"reaper",x:677.55,y:654.45,width:161.3,rotation:-90},{type:"horizontalBlockFast",x:645.3,y:-494.6,width:100,height:100},{type:"buzzsawOnStick",x:97.4,y:-302.8,rotation:-180},{type:"buzzsawOnStick",x:106.6,y:-301.2,rotation:0},{type:"fallingSpike",x:-529.8,y:23.45,rotation:90},{type:"buzzsawVerticalUp",x:-801,y:1124.3},{type:"buzzsawVerticalUp",x:-537.55,y:911.3},{type:"buzzsawVerticalUp",x:-537.55,y:442.2},{type:"basicBlock",x:-173,y:183.6,width:150,height:115},{type:"buzzsawOnStick",x:101.19999999999999,y:-297.4,rotation:90},{type:"buzzsawOnStick",x:102.8,y:-306.6,rotation:-90},{type:"quadrantLeft",x:798.2,y:896.2,rotation:89.99824523925781},{type:"quadrantLeft",x:584.15,y:896.2,rotation:0},{type:"basicBlock",x:251,y:367,width:100,height:1733},{type:"basicBlock",x:754.2,y:995.75,width:906.1,height:100},{type:"checkpoint",x:364.5,y:894.2},{type:"breatheBlaster",x:356.85,y:926.1,rotation:-90},{type:"textFade",textNum:"5",x:714.8,y:508.67499999999995,rotation:90.00175476074219},{type:"circularCannon",x:392.15,y:382.25},{type:"spike",x:860,y:-581.35,rotation:180},{type:"spike",x:871,y:-581.35,rotation:180},{type:"spike",x:883,y:-581.35,rotation:180},{type:"spike",x:894,y:-581.35,rotation:180},{type:"spike10x",x:643.9,y:-581.65,rotation:180},{type:"basicBlock",x:643.9,y:-703.5,width:100,height:230},{type:"spike30x",x:546.6,y:-507.7,rotation:0},{type:"spike10x",x:793.1,y:-654.1,rotation:-90},{type:"fallingSpike",x:-418.05,y:-49.25,rotation:180},{type:"fallingSpike",x:-439.55,y:-49.25,rotation:180},{type:"fallingSpike",x:-396.55,y:-49.25,rotation:180},{type:"textFade",textNum:"5",x:141.02499999999998,y:-436.525,rotation:-59.99946594238281},{type:"bounceBlock",x:171.05,y:216.05,width:60,height:60},{type:"bounceBlock",x:31,y:216.05,width:60,height:60},{type:"spike10x",x:-272.15,y:376.65,rotation:90},{type:"windBlaster",x:-135.1,y:380.1,rotation:180},{type:"spike10x",x:-144,y:480.5,rotation:-90},{type:"textFade",textNum:"5",x:94.8,y:441.17499999999995,rotation:-89.99824523925781},{type:"fallingSpike",x:-319.3,y:12.45,rotation:180},{type:"fallingSpike",x:-361.3,y:12.45,rotation:180},{type:"fallingSpike",x:-340.8,y:12.45,rotation:180},{type:"fallingSpike",x:-297.8,y:12.45,rotation:180},{type:"basicBlock",x:-355.15,y:109.95,width:150,height:115},{type:"buzzsawHorizontal",x:78.05,y:615.6},{type:"basicBlock",x:-41.1,y:665.65,width:486.9,height:100},{type:"fallingSpike",x:-438.15,y:58,rotation:-90},{type:"fallingSpike",x:-438.15,y:78.5,rotation:-90},{type:"basicBlock",x:-330.15,y:-32.3,width:100,height:73.5},{type:"textFade",textNum:"5",x:-770.2,y:627.125,rotation:90.00175476074219},{type:"buzzsawVerticalUp",x:-736.6,y:911.3},{type:"buzzsawVerticalUp",x:-479.95,y:1124.3},{type:"textFade",textNum:"5",x:-770.2,y:188.075,rotation:90.00175476074219},{type:"buzzsawVerticalUp",x:-736.6,y:442.2},{type:"basicBlock",x:-638.2,y:127,width:200,height:768.3},{type:"basicBlock",x:-380.15,y:706.65,width:200,height:1087.9},{type:"basicBlock",x:-1e3,y:55,width:200,height:300},{type:"basicBlock",x:1400,y:56,width:200,height:300},{type:"finishPortal",x:1236.25,y:133.95},{type:"basicBlock",x:-950,y:875,width:300,height:1425.1},{type:"basicBlock",x:200,y:1403,width:2000.2,height:370},{type:"basicBlock",x:1350.1,y:875.45,width:300,height:1425.1},{type:"basicBlock",x:1200,y:-157.15,width:600,height:200},{type:"basicBlock",x:-638.2,y:828.3,width:200,height:637.4},{type:"checkpoint",x:230.85,y:-536.8},{type:"circularCannon",x:102,y:-302},{type:"checkpoint",x:-469.95,y:125.65},{type:"checkpointSwimming",x:105.2,y:182.2},{type:"basicBlock",x:-279.35,y:-157.15,width:520,height:200},{type:"basicBlock",x:-67,y:-104,width:138,height:1268.4},{type:"basicBlock",x:351,y:-449,width:100,height:100},{type:"speedBlock",x:601,y:-449,width:400,height:100},{type:"basicBlock",x:850,y:-473.8,width:100,height:150},{type:"basicBlock",x:332.85,y:-782.7,width:938.4,height:100},{type:"checkpoint",x:959.1,y:-295.15},{type:"basicBlock",x:850,y:-711.2,width:100,height:243.05},{type:"classicLaser",x:746.15,y:-698.9},{type:"basicBlock",x:1069.25,y:-542.8,width:100,height:573.1},{type:"basicBlock",x:350.4,y:-207.15,width:100,height:100},{type:"basicBlock",x:500,y:27.85,width:100,height:570.7},{type:"hazardStrips",x:540,y:-257.25},{type:"hazardStrips",x:899.1,y:-257.25},{type:"classicLaser",x:726.4,y:-136.3},{type:"laserPoint",x:545,y:-207.25},{type:"laserPoint",x:904.1,y:-207.25},{type:"checkpointSwimming",x:383.25,y:182.2},{type:"textFade",textNum:"5",x:969.25,y:-475.575,rotation:90.00175476074219},{type:"textFade",textNum:"5",x:426.1,y:-146.525,rotation:90.00175476074219},{type:"pole",x:823.2,y:-339.5},{type:"pole",x:642.15,y:-339.5},{type:"spawnPoint",x:-856.95,y:127.35},{type:"basicBlock",x:475.9,y:539.5,width:350,height:100},{type:"reaper",x:647.4,y:389.05,width:161.3,rotation:-90},{type:"basicBlock",x:819.2,y:465.65,width:100,height:760.9},{type:"basicBlock",x:584.75,y:785,width:368.8,height:100},{type:"reaper",x:383.95,y:662.35,width:126.35,rotation:-90},{type:"textFade",textNum:"34",x:357.25,y:995.2750000000001,rotation:0},{type:"textFade",textNum:"5",x:1028.55,y:777.625,rotation:-89.99824523925781},{type:"checkpoint",x:-187.5,y:88.1},{type:"bouncingBuzzsaw",x:-239.6,y:379.4,width:47},{type:"bouncingBuzzsaw",x:100.55,y:285.55,width:47},{type:"enlargingBuzzsaw",x:735.15,y:-324.1,width:73},{type:"solarBlock",x:350.4,y:785,width:100,height:100},{type:"lightSwitch",x:381.1,y:290.1},{type:"lightSwitch",x:434.95,y:902.7},{type:"solarBlock",x:818.4,y:896.2,width:100,height:100},{type:"swimmingPool",x:200,y:721.4,width:2e3,height:994}],level8c:[{type:"bounceBlock",x:1692.95,y:1120,width:60,height:60},{type:"speedBlock",x:825.25,y:1188.75,width:325,height:100},{type:"speedBlock",x:1249.7,y:1188,width:325,height:100},{type:"textFade",textNum:"5",x:38,y:999.4250000000001,rotation:90},{type:"shurikanSpawner",x:1783.55,y:512.7,rotation:180},{type:"basicBlock",x:1294,y:383.05,width:112,height:100},{type:"basicBlock",x:738,y:233.5,width:100,height:201},{type:"buzzsaw",x:929.2,y:338.05,width:85,height:86},{type:"buzzsaw",x:929.2,y:227.05,width:85,height:86},{type:"textFade",textNum:"5",x:1589.65,y:558.275,rotation:-90},{type:"textFade",textNum:"5",x:1693.55,y:938.775,rotation:-90},{type:"checkpoint",x:481.85,y:1099.65},{type:"laserPoint",x:532.7,y:970},{type:"laserPoint",x:952,y:970},{type:"textFade",textNum:"5",x:190.025,y:1101.1,rotation:0},{type:"basicBlock",x:263,y:691.55,width:100,height:100.9},{type:"basicBlock",x:1189.95,y:884.6,width:120.1,height:249.2},{type:"finishPortal",x:835.4,y:303.25},{type:"basicBlock",x:625.15,y:383,width:692.8,height:100},{type:"spawnPoint",x:315.95,y:538.55},{type:"basicBlock",x:114,y:385,width:330,height:550},{type:"basicBlock",x:444,y:610,width:330,height:100},{type:"sparkBlock",x:785,y:610,width:100,height:100},{type:"basicBlock",x:1e3,y:688.6,width:100,height:257.4},{type:"checkpoint",x:1046.65,y:871.2},{type:"textFade",textNum:"35",x:488.22499999999997,y:615.1,rotation:0},{type:"textFade",textNum:"5",x:658.025,y:524.8,rotation:0},{type:"basicBlock",x:1190,y:496.45,width:120,height:326.8},{type:"hazardStrips",x:599,y:560.15},{type:"hazardStrips",x:950,y:560.15},{type:"laserPoint",x:603.85,y:610.4},{type:"laserPoint",x:955,y:610},{type:"textFade",textNum:"5",x:1102.1,y:558.275,rotation:90},{type:"sparkBlock",x:1190,y:710,width:120,height:120},{type:"checkpoint",x:415.2,y:899.45},{type:"timedKey",x:1348.9,y:783.25},{type:"ziplinePole",x:963.5,y:875.4},{type:"ziplinePole",x:485.8,y:902.4},{type:"basicBlock",x:1223.25,y:959.2,width:553.4,height:100},{type:"basicBlock",x:320.25,y:987.45,width:435.2,height:100},{type:"reaper",x:815.5,y:857.25,width:133.05,rotation:-90},{type:"basicBlock",x:263,y:937.45,width:100,height:200},{type:"solarBlock",x:263,y:1087.45,width:100,height:100},{type:"lightSwitch",x:354.7,y:899.8},{type:"checkpoint",x:147.2,y:899.45},{type:"lightSwitch",x:73.05,y:1039.9},{type:"sparkBlock",x:36.7,y:1167.4,width:134,height:134},{type:"sparkBlock",x:263,y:1187.45,width:100,height:100},{type:"sparkBlock",x:396,y:1173.55,width:74,height:74},{type:"basicBlock",x:483,y:1287,width:100,height:300},{type:"solarBlock",x:263,y:792,width:100,height:100},{type:"basicBlock",x:263,y:1387.45,width:100,height:300},{type:"hazardStrips",x:527.85,y:937.75},{type:"hazardStrips",x:946.5,y:909.5},{type:"basicBlock",x:1400,y:546.3,width:100,height:100},{type:"basicBlock",x:1500,y:734.3,width:100,height:549.8},{type:"swimmingPool",x:1350.5,y:784.85,width:201,height:250},{type:"checkpoint",x:1501.6,y:421.4},{type:"quadrantLeft",x:709.15,y:1188.25,rotation:0},{type:"quadrantLeft",x:930.2,y:1188.25,rotation:45},{type:"quadrantLeft",x:1137.25,y:1188.25,rotation:0},{type:"quadrantLeft",x:1358.3,y:1188.25,rotation:45},{type:"checkpoint",x:1598.6,y:1098.65},{type:"basicBlock",x:1690.95,y:1187,width:88,height:100.9},{type:"basicBlock",x:79.95,y:1487.15,width:266.1,height:100},{type:"timedKey",x:1820.35,y:1030.4},{type:"lightSwitch",x:1640,y:1105},{type:"bounceBlock",x:1820,y:1207.6,width:60,height:60},{type:"shurikanSpawner",x:1560.9,y:902.8,rotation:0},{type:"shurikanSpawner",x:1838.55,y:855.8,rotation:180},{type:"lockBlock",x:1700,y:746.75,width:100.05,height:100},{type:"basicBlock",x:1600,y:747.2,width:100,height:100.9},{type:"basicBlock",x:1800,y:436.75,width:100,height:720.2},{type:"basicBlock",x:1598,y:1286.65,width:100,height:300},{type:"bounceBlock",x:1597.4,y:671.75,width:50,height:50},{type:"textFade",textNum:"36",x:402.775,y:985.625,rotation:0},{type:"textFade",textNum:"37",x:1451,y:538.5,rotation:0},{type:"textFade",textNum:"5",x:619.925,y:1100.95,rotation:0},{type:"lockBlock",x:1300,y:283,width:100.05,height:100},{type:"textFade",textNum:"5",x:1394.3,y:363.625,rotation:-90},{type:"basicBlock",x:1900,y:968.65,width:100,height:537.9},{type:"basicBlock",x:1240.2,y:183,width:219.8,height:100},{type:"basicBlock",x:-101,y:946,width:100,height:1672},{type:"checkpoint",x:1189.85,y:295},{type:"circularCannon",x:1051.05,y:286},{type:"basicBlock",x:879.4,y:183,width:184.8,height:100},{type:"reaper",x:625.85,y:869.35,width:133.05,rotation:-90},{type:"bounceBlock",x:190.5,y:1414.15,width:45,height:45},{type:"basicBlock",x:127.65,y:1134.4,width:50,height:200},{type:"shurikanDispenser",x:41.95,y:1337.3},{type:"shurikanSpawner",x:1838.55,y:992.8,rotation:180}],level9c:[{type:"buzzsaw",x:-540.5,y:-193.95,width:51,height:51.6},{type:"buzzsaw",x:-484.45,y:-193.95,width:51,height:51.6},{type:"buzzsaw",x:-292.45,y:-225.95,width:51,height:51.6},{type:"buzzsaw",x:-236.4,y:-225.95,width:51,height:51.6},{type:"enlargingBuzzsaw",x:-391.45,y:-285.95,width:32.95},{type:"windBlaster",x:-194.9,y:160,rotation:-90},{type:"windBlaster",x:-94.9,y:59,rotation:90},{type:"windBlaster",x:-6.6,y:160,rotation:-90},{type:"windBlaster",x:93.4,y:59,rotation:90},{type:"buzzsawVerticalUp",x:1225.1,y:425.9},{type:"buzzsaw",x:1322.1,y:459.9,width:101,height:102.2},{type:"buzzsawVerticalUp",x:776.15,y:325.9},{type:"enlargingBuzzsaw",x:1053.9,y:573.95,width:101},{type:"buzzsaw",x:-26.35,y:-225.95,width:51,height:51.6},{type:"buzzsaw",x:29.7,y:-225.95,width:51,height:51.6},{type:"enlargingBuzzsaw",x:-145.4,y:-195.95,width:32.95},{type:"spike30x",x:-133.85,y:-47.9,rotation:0},{type:"spike30x",x:415.8,y:-47.9,rotation:0},{type:"spike30x",x:124.75,y:-47.9,rotation:0},{type:"timedKey",x:924.75,y:590},{type:"timedKey",x:1174.85,y:590},{type:"bouncingBuzzsaw",x:592.15,y:308.35,width:51},{type:"fallingSpike",x:574.3,y:564.9,rotation:90},{type:"fallingSpike",x:574.3,y:542.9,rotation:90},{type:"fallingSpike",x:574.3,y:521.4,rotation:90},{type:"fallingSpike",x:574.3,y:499.4,rotation:90},{type:"fallingSpike",x:659,y:609.4,rotation:-90},{type:"fallingSpike",x:659,y:631.4,rotation:-90},{type:"fallingSpike",x:659,y:652.9,rotation:-90},{type:"fallingSpike",x:659,y:674.9,rotation:-90},{type:"shurikanDispenser",x:187.9,y:300},{type:"shurikanDispenser",x:187.9,y:540},{type:"shurikanDispenser",x:428,y:542.95},{type:"shurikanDispenser",x:428,y:816.95},{type:"basicBlock",x:366.4,y:401.65,width:200,height:100},{type:"basicBlock",x:246.9,y:646.6,width:200,height:100},{type:"basicBlock",x:91.4,y:10,width:750,height:100},{type:"fallingSpike",x:181.35,y:126.55,rotation:180},{type:"fallingSpike",x:203.35,y:126.55,rotation:180},{type:"fallingSpike",x:-64.45,y:152.1,rotation:0},{type:"fallingSpike",x:-86.45,y:152.1,rotation:0},{type:"fallingSpike",x:-107.95,y:152.1,rotation:0},{type:"fallingSpike",x:-129.95,y:152.1,rotation:0},{type:"fallingSpike",x:79.55,y:152.1,rotation:0},{type:"fallingSpike",x:57.55,y:152.1,rotation:0},{type:"basicBlock",x:-8.1,y:210,width:750,height:100},{type:"basicBlock",x:-118.1,y:610,width:330,height:100},{type:"shurikanDispenser",x:-158.3,y:403.55},{type:"shurikanDispenser",x:-1.05,y:506.05},{type:"basicBlock",x:-333.1,y:510,width:100,height:300},{type:"basicBlock",x:-233.1,y:410,width:100,height:100},{type:"basicBlock",x:96.9,y:560.8,width:100,height:800},{type:"fallingBlock",x:-80.1,y:462,width:50,height:50},{type:"checkpoint",x:-243.25,y:322},{type:"basicBlock",x:-208.1,y:489.05,width:50,height:58},{type:"pole",x:-534.1,y:289.75},{type:"pole",x:-597.85,y:90.75},{type:"shurikanDispenser",x:-597.4,y:172.75},{type:"checkpoint",x:-322.6,y:122},{type:"textFade",textNum:"5",x:-167.075,y:537.3,rotation:.004364013671875},{type:"textFade",textNum:"5",x:-421.1,y:298.17499999999995,rotation:-89.99563598632812},{type:"basicBlock",x:-750.05,y:291.35,width:100,height:934.6},{type:"fallingSpike",x:-223.65,y:67.9,rotation:180},{type:"fallingSpike",x:-201.65,y:67.9,rotation:180},{type:"fallingSpike",x:-180.15,y:67.9,rotation:180},{type:"fallingSpike",x:-158.15,y:67.9,rotation:180},{type:"fallingSpike",x:-36.15,y:67.9,rotation:180},{type:"fallingSpike",x:-14.15,y:67.9,rotation:180},{type:"fallingSpike",x:7.35,y:67.9,rotation:180},{type:"fallingSpike",x:29.35,y:67.9,rotation:180},{type:"basicBlock",x:196.9,y:40,width:100,height:159.95},{type:"checkpoint",x:316.35,y:122.15},{type:"textFade",textNum:"5",x:416.1,y:249.575,rotation:90.00436401367188},{type:"solarBlock",x:416.9,y:210,width:100,height:100},{type:"basicBlock",x:516.4,y:360.05,width:100,height:800},{type:"solarBlock",x:616.4,y:210,width:100,height:100},{type:"basicBlock",x:406.9,y:911,width:520,height:100},{type:"basicBlock",x:716.4,y:561,width:100,height:800},{type:"checkpoint",x:741.5,y:123},{type:"lightSwitch",x:415.15,y:120.55},{type:"swimmingPool",x:406.9,y:560.55,width:520,height:600.9},{type:"basicBlock",x:1046,y:676.45,width:560.1,height:100},{type:"basicBlock",x:1424,y:-108.1,width:200,height:330.1},{type:"basicBlock",x:1574,y:231.95,width:300,height:150},{type:"lockBlock",x:1474,y:106.95,width:100.05,height:100},{type:"basicBlock",x:1374,y:441.6,width:100.1,height:570},{type:"bounceBlock",x:1664.65,y:126.95,width:60,height:60},{type:"textFade",textNum:"5",x:1601.95,y:-1.9749999999999943,rotation:-104.99484252929688},{type:"ziplinePole",x:1341,y:-308.1},{type:"ziplinePole",x:938.25,y:-286},{type:"checkpoint",x:420.15,y:-258},{type:"textFade",textNum:"5",x:645.075,y:132.6,rotation:.004364013671875},{type:"shurikanDispenser",x:1125.55,y:-315.25},{type:"shurikanDispenser",x:712.95,y:-287.8},{type:"basicBlock",x:516.4,y:-124.8,width:100,height:190.25},{type:"basicBlock",x:414.65,y:-169.9,width:105.1,height:100},{type:"checkpoint",x:1463.85,y:-310.8},{type:"invisBlock",x:196.9,y:-169.9,width:100,height:100},{type:"textFade",textNum:"39",x:464.725,y:-165.175,rotation:0},{type:"textFade",textNum:"40",x:682.875,y:61.625,rotation:0},{type:"invisBlockUp",x:-.35,y:-225.95,width:52,height:52},{type:"invisBlockDown",x:-145.4,y:-195.95,width:52,height:52},{type:"invisBlockUp",x:-265.4,y:-225.95,width:52,height:52},{type:"invisBlockDown",x:-391.45,y:-285.95,width:52,height:52},{type:"invisBlockUp",x:-513.45,y:-193.95,width:52,height:52},{type:"finishPortal",x:-751.2,y:-205.55},{type:"star",x:1053.25,y:765.25},{type:"invisBlock",x:1499,y:751.6,width:50,height:50},{type:"invisBlock",x:1449.05,y:864.95,width:50,height:50},{type:"lockBlock",x:1374,y:106.95,width:100.05,height:100},{type:"invisBlock",x:1351.05,y:804.5,width:50,height:50},{type:"invisBlock",x:1255.6,y:864.95,width:50,height:50},{type:"invisBlock",x:1149.6,y:804.5,width:50,height:50},{type:"invisBlock",x:1054.15,y:864.95,width:50,height:50},{type:"invisBlock",x:1556.05,y:604.1,width:50,height:50},{type:"basicBlock",x:923.9,y:404,width:100,height:300},{type:"basicBlock",x:1176.6,y:404.55,width:100,height:300},{type:"spawnPoint",x:-258.55,y:505.35},{type:"basicBlock",x:-675.05,y:229,width:50,height:50},{type:"swimmingPool",x:1045,y:410,width:558,height:432.9},{type:"ziplinePole",x:921.9,y:-284.1},{type:"ziplinePole",x:519.15,y:-255},{type:"sparkBlock",x:930.05,y:-230.95,width:44,height:44}]},allunlocked=!1,Level=function(){function Level(levels,id,data,name,topTime,goldTime,silverTime,bronzeTime,hue){this.levels=levels,this.id=id,this.data=data,this.name=name,this.topTime=topTime,this.goldTime=1e3*goldTime,this.silverTime=1e3*silverTime,this.bronzeTime=1e3*bronzeTime,this.gotStar=!1,this.found=!1,this.challengeCompleted=!1,(this.hue=hue)&&(this.colorFilter=new PIXI.ColorMatrixFilter,this.colorFilter.hue(hue)),allunlocked&&-1===this.topTime&&(this.topTime=5),-1<this.topTime&&(this.topTime<this.goldTime?this.bestRank=0:this.topTime<this.silverTime?this.bestRank=2:this.topTime<this.bronzeTime?this.bestRank=3:this.bestRank=4),"hub"!==this.id&&this.loadLevel()}return Level.prototype.setBestTime=function(time,deaths){var tr=6;-1<time&&(tr=time<this.goldTime?0===deaths?0:1:time<this.silverTime?2:time<this.bronzeTime?3:4),-1!==this.topTime&&tr>this.bestRank||(this.topTime=time,this.topTime>time&&(this.topTime=time),this.bestRank=tr,this.saveLevel())},Level.prototype.gotGold=function(){return-1!==this.topTime&&this.topTime<=this.goldTime},Level.prototype.getRankSpriteKey=function(){return this.gotGold()&&this.gotStar&&this.challengeCompleted?"clearText":Level.RANK_SPRITE_KEYS[this.bestRank]},Level.prototype.loadLevel=function(){var id=parseInt(this.id),level=SaveGame.getInstance().getLevel(id-1);this.topTime=level.tt,this.bestRank=level.br,this.gotStar=level.gs,this.challengeCompleted=level.cc},Level.prototype.saveLevel=function(){var save={tt:this.topTime,br:this.bestRank,gs:this.gotStar,cc:this.challengeCompleted,fn:this.found};SaveGame.getInstance().saveLevels(parseInt(this.id),save)},Level.prototype.clearSavedData=function(){SaveGame.getInstance().resetLevels()},Level.RANK_SPRITE_KEYS={0:"perfectText",1:"goldText",2:"silverText",3:"bronzeText",4:"clearText"},Level}(),Levels=function(){function Levels(doneCallback){this.levels={},this.totalLoad=0,this.loadedNum=0,this.doneCallback=doneCallback,this.latestCompleted=Constants.latestCompleted,this.loadLevel("hub","levelhub","Level Hub",-1,-1,-1),this.loadLevel("1","level1","Act 1",25,45,60,130,"level1c"),this.loadLevel("2","level2","Act 2",50,70,90,180,"level2c"),this.loadLevel("3","level3","Act 3",50,70,90,180,"level3c"),this.loadLevel("4","level4","Act 4",60,80,100,-150,"level4c"),this.loadLevel("5","level5","Act 5",60,80,100,-90,"level5c"),this.loadLevel("6","level6","Act 6",90,110,130,-40,"level6c"),this.loadLevel("7","level7","Act 7",90,110,130,1,"level7c"),this.loadLevel("8","level8","Act 8",80,100,120,30,"level8c"),this.loadLevel("9","level9","Act 9",120,150,180,70,"level9c"),this.loadLevel("10","level10","Vexation",180,210,240,100),(allunlocked||this.latestCompleted>Levels.LAST_LEVEL)&&(this.latestCompleted=Levels.LAST_LEVEL),doneCallback()}return Levels.prototype.getGoldNumber=function(){var nn=0;for(var key in this.levels){var level=this.levels[key];"hub"!=key&&(level.gotGold()&&nn++)}return nn},Levels.prototype.getPerfectNumber=function(){var nn=0;for(var key in this.levels){var level=this.levels[key];"hub"!=key&&(0==level.bestRank&&nn++)}return nn},Levels.prototype.checkOlympian=function(){for(var key in this.levels){var level=this.levels[key];if("hub"!=key&&!level.gotGold())return!1}return!0},Levels.prototype.checkPerfection=function(){for(var key in this.levels){var level=this.levels[key];if("hub"!=key&&0!==level.bestRank)return!1}return!0},Levels.prototype.checkAstronomer=function(){for(var key in this.levels){var level=this.levels[key];if("hub"!=key&&!level.gotStar)return!1}return!0},Levels.prototype.checkWinner=function(){for(var key in this.levels){var level=this.levels[key];if("hub"!=key&&"10"!=key&&!level.challengeCompleted)return!1}return!0},Levels.prototype.clearAllLevelData=function(){for(var key in this.levels){this.levels[key].clearSavedData()}this.latestCompleted=0},Levels.prototype.loadLevel=function(id,filename,levelName,goldTime,silverTime,bronzeTime,hue,challengeName){void 0===hue&&(hue=0),this.levels[id]=new Level(this,id,levelData[filename],levelName,-1,goldTime,silverTime,bronzeTime,hue),this.levels[id].challengeData=levelData[challengeName]},Levels.LAST_LEVEL=10,Levels}(),Sounds=function(){function Sounds(main,game){this.main=main,this.muted=!1,this.connectHang=game.add.audio("connectHang"),this.fall=game.add.audio("fall",.2),this.downgrade=game.add.audio("downgrade",.7),this.poleSwing=game.add.audio("poleSwing",.7),this.splash1=game.add.audio("splash1",.7),this.ziplineFull=game.add.audio("ziplineFull",.7),this.cannonEnter=game.add.audio("cannonEnter",.7),this.wallSlide=game.add.audio("wallSlide",.7),this.connectSlide=game.add.audio("connect",.7),this.land=game.add.audio("land",.5),this.slide=game.add.audio("slide",.7),this.death1=game.add.audio("death1",.7),this.death2=game.add.audio("death2",.7),this.electricity=game.add.audio("electricity",.5),this.poleWoosh=game.add.audio("poleWoosh",.7),this.bounce1=game.add.audio("bounce1",.7),this.cannonFire=game.add.audio("cannonFire",.7),this.glassSmash=game.add.audio("glassSmash",.7),this.fallingBlock=game.add.audio("fallingBlock",.7),this.blockDestroy=game.add.audio("blockDestroy",.7),this.buttonClick=game.add.audio("buttonClick",.7),this.achievementUnlocked=game.add.audio("achievementUnlocked",.7),this.footstep=game.add.audio("footstep",.7),this.laserFire=game.add.audio("laserFire",.7),this.ding=game.add.audio("ding",.7),this.kickBlock=game.add.audio("kickBlock",.7),this.starPickup=game.add.audio("starPickup",.7),this.menuSong=game.add.audio("menuSong",.7,!0),this.songs=[],this.vexSong1=game.add.audio("vexSong1",.7,!0),this.songs.push(this.vexSong1),this.vexSong2=game.add.audio("vexSong2",.7,!0),this.songs.push(this.vexSong2),this.vexSong3=game.add.audio("vexSong3",.7,!0),this.songs.push(this.vexSong3),this.vexSong4=game.add.audio("vexSong4",.7,!0),this.songs.push(this.vexSong4)}return Sounds.prototype.playSound=function(soundKey){this.muted||this[soundKey].play(null,null,.6*this.main.options.effectVolume)},Sounds.prototype.playRandomMusic=function(){for(var _i=0,_a=this.songs;_i<_a.length;_i++){_a[_i].stop()}this.menuSong.stop();var nn=Math.floor(Math.random()*this.songs.length),song=this.songs[nn];song.play(null,null,.6*this.main.options.musicVolume,!0),this.currentMusic=song},Sounds.prototype.playMenuSong=function(){for(var _i=0,_a=this.songs;_i<_a.length;_i++){_a[_i].stop()}this.menuSong.play(null,null,.6*this.main.options.musicVolume,!0),this.currentMusic=this.menuSong},Sounds.prototype.stopAllSounds=function(){},Sounds}(),LeftSlope=function(_super){function LeftSlope(main,game,layer,right){void 0===right&&(right=!1);var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.right=right,_this.sprite=layer.create(0,0,"leftSlopeColors"),_this.sprite.autoCull=!0,_this.alive=!1,_this}return __extends(LeftSlope,_super),LeftSlope.prototype.spawn=function(x,y,width,height,rotation){this.xPos=x,this.yPos=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.right&&(this.sprite.scale.x=-this.sprite.scale.x),this.sprite.anchor.set(.5,.5),this.sprite.rotation=rotation*Math.PI/180;var nn=parseInt(this.main.currentLevelID);nn<8&&(this.sprite.frame=nn),this.alive=!0,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.wallPoly=new SAT.Box(new SAT.Vector(x,y),10,height-20).toPolygon(),this.bottomPoly=new SAT.Box(new SAT.Vector(x,y),width,10).toPolygon(),this.right?this.wallPoly.setOffset(new SAT.Vector(-width/2,-height/2+20)):this.wallPoly.setOffset(new SAT.Vector(width/2,-height/2+20)),this.bottomPoly.setOffset(new SAT.Vector(width/2,height/2))},LeftSlope.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},LeftSlope}(Entity),VerticalUpBlock=function(_super){function VerticalUpBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.maxMoveDist=100,_this.sprite=layer.create(0,0,"verticalUpBlock"),_this.sprite.autoCull=!0,_this.sprite.autoCull=!0,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this}return __extends(VerticalUpBlock,_super),VerticalUpBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.startY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=-2,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.alive=!0,this.attachmentOffsets=[],this.attachments=[];var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-BasicBlock.TOP_BOUND_HEIGHT))},VerticalUpBlock.prototype.levelStart=function(){for(var testPoly=new SAT.Box(new SAT.Vector(this.leftEdge,this.topEdge-10),this.width,this.height+20).toPolygon(),i=0;i<this.main.obstacles.length;i++){var obs=this.main.obstacles[i];if("spike"===obs.obstacleType){var spike=obs;SAT.testPolygonPolygon(testPoly,spike.deathBoxPolygon)&&(this.attachments.push(spike),this.attachmentOffsets.push(new Phaser.Point(spike.xPos-this.xPos,spike.yPos-this.yPos)))}else if("quadrant"===obs.obstacleType){var quad=obs;SAT.testPolygonPolygon(testPoly,quad.attachHitBoxPolygon)&&(this.attachments.push(obs),this.attachmentOffsets.push(new Phaser.Point(obs.xPos-this.xPos,obs.yPos-this.yPos)))}}},VerticalUpBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos,this.sprite.y=this.yPos;for(var i=0;i<this.attachments.length;i++){var spike=this.attachments[i],offset=this.attachmentOffsets[i];spike.xPos=this.xPos+offset.x,spike.yPos=this.yPos+offset.y,spike.updatePosition()}},VerticalUpBlock.prototype.update=function(){this.prevY=this.yPos,this.yVelocity<0?this.yPos<this.startY-this.maxMoveDist&&(this.yVelocity=-this.yVelocity,this.landed&&(this.main.player.yPos+=2*this.yVelocity),this.main.player.updatePositions()):this.yPos>this.startY+this.maxMoveDist&&(this.yVelocity=-this.yVelocity,this.landed&&(this.main.player.yPos+=2*this.yVelocity),this.main.player.updatePositions()),this.yPos+=this.yVelocity,this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},VerticalUpBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.attachments=null,this.attachmentOffsets=null,_super.prototype.destroy.call(this)},VerticalUpBlock}(Block),VerticalDownBlock=function(_super){function VerticalDownBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.maxMoveDist=100,_this.sprite=layer.create(0,0,"verticalDownBlock"),_this.sprite.autoCull=!0,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this}return __extends(VerticalDownBlock,_super),VerticalDownBlock.prototype.levelStart=function(){for(var testPoly=new SAT.Box(new SAT.Vector(this.leftEdge,this.topEdge-10),this.width,this.height+20).toPolygon(),i=0;i<this.main.obstacles.length;i++){var obs=this.main.obstacles[i];if("spike"===obs.obstacleType){var spike=obs;SAT.testPolygonPolygon(testPoly,spike.deathBoxPolygon)&&(this.attachments.push(spike),this.attachmentOffsets.push(new Phaser.Point(spike.xPos-this.xPos,spike.yPos-this.yPos)))}else if("quadrant"===obs.obstacleType){var quad=obs;SAT.testPolygonPolygon(testPoly,quad.attachHitBoxPolygon)&&(this.attachments.push(obs),this.attachmentOffsets.push(new Phaser.Point(obs.xPos-this.xPos,obs.yPos-this.yPos)))}}},VerticalDownBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.startY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=2,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.alive=!0,this.attachmentOffsets=[],this.attachments=[];var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-BasicBlock.TOP_BOUND_HEIGHT))},VerticalDownBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos,this.sprite.y=this.yPos;for(var i=0;i<this.attachments.length;i++){var spike=this.attachments[i],offset=this.attachmentOffsets[i];spike.xPos=this.xPos+offset.x,spike.yPos=this.yPos+offset.y,spike.updatePosition()}},VerticalDownBlock.prototype.update=function(){this.prevY=this.yPos,0<this.yVelocity?this.yPos>this.startY+this.maxMoveDist&&(this.yVelocity=-this.yVelocity):this.yPos<this.startY-this.maxMoveDist&&(this.yVelocity=-this.yVelocity),this.yPos+=this.yVelocity,this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},VerticalDownBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.attachments=null,this.attachmentOffsets=null,_super.prototype.destroy.call(this)},VerticalDownBlock}(Block),PushBlock=function(_super){function PushBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"pushBlock"),_this.sprite.autoCull=!0,_this.alive=!1,_this.blockType="push",_this.hangable=!0,_this.scalable=!0,_this}return __extends(PushBlock,_super),PushBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.pushingRight=!1,this.pushingLeft=!1,this.pushed=!1,this.inWater=!1,this.onIce=!1,this.stuckLeft=!1,this.stuckRight=!1,this.land=!1,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT))},PushBlock.prototype.checkBlockCollisions=function(){this.land=!1,this.onIce=!1;for(var i=0;i<this.main.blocks.length;i++){var block=this.main.blocks[i];if(block.alive)if(SAT.testPolygonPolygon(block.topBoundPolygon,this.bottomBoundPolygon)){if(this.yVelocity,"ice"===block.blockType&&(this.onIce=!0),this.yVelocity=block.yVelocity,this.inWater?(this.yVelocity*=-1,this.yPos=block.topEdge-.5*this.height):0<this.yVelocity?this.yPos=block.topEdge-.5*this.height+this.yVelocity:this.yPos=block.topEdge-.5*this.height+1,this.land=!0,this.updatePositions(),"speed"===block.blockType){var speedBlock=block;this.xVelocity+=.4*speedBlock.speedInc}else if("falling"===block.blockType){var fallBlock=block;fallBlock.falling||(fallBlock.falling=!0,fallBlock.yVelocity=-2)}}else(this.yVelocity<0||0<block.yVelocity)&&SAT.testPolygonPolygon(this.topBoundPolygon,block.bottomBoundPolygon)?(this.yVelocity<0&&(this.yVelocity*=.5),this.yPos=block.bottomEdge+.5*this.height):this.xVelocity-block.xVelocity<0&&SAT.testPolygonPolygon(this.leftBoundPolygon,block.rightBoundPolygon)?(this.xVelocity=0,this.xPos=block.rightEdge+.5*this.width):0<this.xVelocity-block.xVelocity&&SAT.testPolygonPolygon(this.rightBoundPolygon,block.leftBoundPolygon)&&(this.xVelocity=0,this.xPos=block.leftEdge-.5*this.width)}},PushBlock.prototype.checkWaterCollisions=function(){var wasInWater=this.inWater;this.inWater=!1;for(var i=0;i<this.main.pools.length;i++){var pool=this.main.pools[i];SAT.testPolygonPolygon(this.totalBoundPolygon,pool.totalPolygon)&&(this.main.underPoolLayer.addChild(this.sprite),this.yPos>pool.yPos-.5*pool.height&&(!wasInWater&&this.yVelocity,this.yVelocity-=this.main.gameSpeed,this.yVelocity<-3&&(this.yVelocity=-3),this.inWater=!0))}},PushBlock.prototype.checkTrapped=function(){for(var leftPoint=new SAT.Vector(this.leftEdge-5,this.topEdge+10),rightPoint=new SAT.Vector(this.rightEdge+5,this.topEdge+10),i=0;i<this.main.blocks.length;i++){var block=this.main.blocks[i];if(block.alive){if(SAT.pointInPolygon(leftPoint,block.totalBoundPolygon))return this.stuckLeft=!0,"left";if(SAT.pointInPolygon(rightPoint,block.totalBoundPolygon))return this.stuckRight=!0,"right"}}return"not trapped"},PushBlock.prototype.update=function(){this.land||(this.yVelocity+=this.main.gravity*this.main.gameSpeed),this.xPos+=this.xVelocity,this.yPos+=this.yVelocity,this.landed&&(this.main.player.xPos+=this.xVelocity,this.main.player.updatePositions()),this.onIce?this.xVelocity-=.01*this.xVelocity:this.xVelocity-=.25*this.xVelocity,this.checkBlockCollisions(),this.checkWaterCollisions(),this.updatePositions()},PushBlock.prototype.updatePositions=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},PushBlock.prototype.reset=function(){this.main.levelLayer.addChild(this.sprite),this.xPos=this.startX,this.yPos=this.startY,this.pushed=!1,this.pushingLeft=!1,this.pushingRight=!1,this.updatePositions()},PushBlock.prototype.resetLevel=function(){this.reset()},PushBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},PushBlock.TOP_BOUND_HEIGHT=12,PushBlock}(Block),IceBlock=function(_super){function IceBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"iceBlock"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.alive=!1,_this.blockType="ice",_this.hangable=!0,_this.scalable=!0,_this}return __extends(IceBlock,_super),IceBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.startX=x,this.startY=y,this.width=width,this.height=height,this.startHeight=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.startXScale=width/100,this.startYScale=height/100,this.sprite.anchor.set(.5,.5),this.sprite.visible=!0,this.main.options.blend&&(this.maskGraphic=this.game.add.graphics(0,0,this.layer),this.maskGraphic.beginFill(0),this.maskGraphic.drawRect(.5*-width,.5*-height,width,height),this.maskGraphic.endFill(),this.maskGraphic.position.set(x,y),this.sprite.mask=this.maskGraphic),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.depletionRate=.001,this.meltScale=1,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,IceBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,IceBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,IceBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,IceBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-IceBlock.TOP_BOUND_HEIGHT)),this.hitGraphics=this.game.add.graphics(0,0),this.hitGraphics.visible=!1,this.layer.add(this.hitGraphics),this.hitGraphics.clear(),this.hitGraphics.beginFill(16711680,.5),this.hitGraphics.moveTo(this.xPos+this.rhBoundPolygon.calcPoints[0].x,this.yPos+this.rhBoundPolygon.calcPoints[0].y);for(var i=1;i<4;i++)this.hitGraphics.lineTo(this.xPos+this.rhBoundPolygon.calcPoints[i].x,this.yPos+this.rhBoundPolygon.calcPoints[i].y);this.hitGraphics.lineTo(this.xPos+this.rhBoundPolygon.calcPoints[0].x,this.yPos+this.rhBoundPolygon.calcPoints[0].y),this.hitGraphics.endFill()},IceBlock.prototype.update=function(){if(this.alive){if(this.melted,this.rightEdge<this.game.camera.x||this.leftEdge>this.game.camera.x+640||this.bottomEdge<this.game.camera.y||this.topEdge>this.game.camera.y+560)return;this.meltScale-=this.depletionRate,this.maskGraphic?(this.maskGraphic.scale.y=this.meltScale,this.maskGraphic.y-=this.depletionRate*this.startHeight/2):(this.sprite.scale.y=this.height/100*this.meltScale,this.sprite.position.y=this.yPos-this.height/2*(1-this.meltScale));var halfWidth=.5*this.width,halfHeight=.5*this.height,height=(this.width,this.height),x=this.xPos,y=this.yPos;this.totalBound=new SAT.Box(new SAT.Vector(this.xPos,this.yPos),this.width,this.height*this.meltScale),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height*this.meltScale),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height*this.meltScale),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,this.meltScale*halfHeight-IceBlock.TOP_BOUND_HEIGHT)),this.meltScale<=0&&(this.melted=!0,this.alive=!1,this.sprite.visible=!1)}},IceBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.maskGraphic&&(this.maskGraphic.destroy(),this.maskGraphic=null),this.hitGraphics.destroy(),delete this.hitGraphics,_super.prototype.destroy.call(this)},IceBlock.prototype.resetLevel=function(){this.reset()},IceBlock.prototype.reset=function(){this.meltScale=1,this.maskGraphic&&(this.maskGraphic.scale.y=1,this.maskGraphic.y=this.startY),this.sprite.scale.set(this.startXScale,this.startYScale),this.sprite.visible=!0,this.alive=!0,this.melted=!1},IceBlock.TOP_BOUND_HEIGHT=12,IceBlock}(Block),SpeedBlock=function(_super){function SpeedBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.container=game.add.group(layer),_this.sprite=_this.container.create(0,0,"speedBlock"),_this.sprite.anchor.set(.5,.5),_this.sprite.autoCull=!0,_this.arrowAnimation=_this.container.create(0,0,"arrowAnimation"),_this.arrowAnimation.animations.add("arrow"),_this.arrowAnimation.anchor.set(.5,.5),_this.arrowAnimation.autoCull=!0,_this.alive=!1,_this.blockType="speed",_this.hangable=!0,_this.scalable=!0,_this}return __extends(SpeedBlock,_super),SpeedBlock.prototype.spawn=function(x,y,width,height,speedInc){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.speedInc=speedInc,this.container.position.set(x,y),this.container.scale.set(width/100,height/100),this.main.options.blend?(this.arrowMask=this.game.add.graphics(0,0,this.container),this.arrowMask.beginFill(0),this.arrowMask.drawRect(-50,-50,100,100),this.arrowMask.endFill(),this.arrowAnimation.mask=this.arrowMask,this.arrowAnimation.play("arrow",null,!0)):this.arrowAnimation.loadTexture("arrowStatic"),0<this.speedInc?this.arrowAnimation.rotation=Math.PI/2:this.arrowAnimation.rotation=-Math.PI/2,this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.xVelocity=0,this.yVelocity=0,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT))},SpeedBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.container.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},SpeedBlock.prototype.update=function(){this.landed&&this.land(),this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},SpeedBlock.prototype.land=function(){(0<this.speedInc&&this.main.player.xVelocity<5*this.speedInc||this.speedInc<0&&this.main.player.xVelocity>5*this.speedInc)&&(this.main.player.xVelocity+=this.speedInc,this.main.player.xVelocity===this.speedInc&&(this.main.player.xVelocity+=.75*this.speedInc))},SpeedBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.arrowMask&&(this.arrowMask.destroy(),this.arrowMask=null),this.container.destroy(),this.container=null,_super.prototype.destroy.call(this)},SpeedBlock.TOP_BOUND_HEIGHT=12,SpeedBlock}(Block),LB=function(_super){function LB(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"lockBlock"),_this.sprite.autoCull=!0,_this.alive=!1,_this.blockType="lock",_this.hangable=!0,_this.scalable=!0,_this}return __extends(LB,_super),LB.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT))},LB.prototype.unlock=function(){this.unlocked=!0,this.passable=!0,this.alive=!1,this.sprite.visible=!1},LB.prototype.update=function(){},LB.prototype.updatePositions=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},LB.prototype.reset=function(){},LB.prototype.resetLevel=function(){this.alive=!0,this.unlocked=!1,this.passable=!1,this.sprite.visible=!0},LB.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},LB.TOP_BOUND_HEIGHT=12,LB}(Block),SparkBlock=function(_super){function SparkBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"sparkBlock"),_this.sprite.autoCull=!0,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this.spark=new Spark(main,game,layer,_this),_this.main.obstacles.push(_this.spark),_this}return __extends(SparkBlock,_super),SparkBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.xVelocity=0,this.yVelocity=0,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT)),this.spark.spawn()},SparkBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},SparkBlock.prototype.update=function(){this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},SparkBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},SparkBlock.prototype.resetLevel=function(){},SparkBlock.prototype.reset=function(){},SparkBlock.TOP_BOUND_HEIGHT=12,SparkBlock}(Block),SolarBlock=function(_super){function SolarBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"solarBlock"),_this.sprite.autoCull=!0,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this}return __extends(SolarBlock,_super),SolarBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.xVelocity=0,this.yVelocity=0,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT))},SolarBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},SolarBlock.prototype.update=function(){this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition()},SolarBlock.prototype.goDark=function(){this.alive=!1,this.sprite.visible=!1},SolarBlock.prototype.goLight=function(){this.alive=!0,this.sprite.visible=!0},SolarBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},SolarBlock.prototype.reset=function(){},SolarBlock.TOP_BOUND_HEIGHT=12,SolarBlock}(Block),InvisBlock=function(_super){function InvisBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.init(),_this.hangable=!0,_this.scalable=!0,_this}return __extends(InvisBlock,_super),InvisBlock.prototype.init=function(){this.sprite=this.layer.create(0,0,"invisBlock"),this.sprite.autoCull=!0,this.alive=!1},InvisBlock.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.prevX=x,this.prevY=y,this.startX=x,this.startY=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=0,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.xVelocity=0,this.yVelocity=0,this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,PushBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,PushBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-PushBlock.TOP_BOUND_HEIGHT))},InvisBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos},InvisBlock.prototype.update=function(){if(this.alive){var player=this.main.player,dist=Math.sqrt(Math.pow(player.xPos-this.xPos,2)+Math.pow(player.yPos-this.yPos,2));this.sprite.alpha-=.25*(this.sprite.alpha-(dist-InvisBlock.RANGE)/InvisBlock.RANGE),this.xPos==this.prevX&&this.yPos==this.prevY||this.updatePosition(),this.prevX=this.xPos,this.prevY=this.yPos}},InvisBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},InvisBlock.prototype.reset=function(){},InvisBlock.TOP_BOUND_HEIGHT=12,InvisBlock.RANGE=200,InvisBlock}(Block),InvisBlockUp=function(_super){function InvisBlockUp(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.maxMoveDist=100,_this}return __extends(InvisBlockUp,_super),InvisBlockUp.prototype.init=function(){this.sprite=this.layer.create(0,0,"invisBlockUp"),this.sprite.autoCull=!0,this.alive=!1},InvisBlockUp.prototype.levelStart=function(){this.attachments=[],this.attachmentOffsets=[];for(var testPoly=new SAT.Box(new SAT.Vector(this.leftEdge,this.topEdge-10),this.width,this.height+20).toPolygon(),i=0;i<this.main.obstacles.length;i++){var obs=this.main.obstacles[i];if("spike"===obs.obstacleType){var spike=obs;SAT.testPolygonPolygon(testPoly,spike.deathBoxPolygon)&&(this.attachments.push(spike),this.attachmentOffsets.push(new Phaser.Point(spike.xPos-this.xPos,spike.yPos-this.yPos)))}else if("buzzsaw"===obs.obstacleType){var buzzsaw=obs;SAT.testCirclePolygon(buzzsaw.deathCircle,testPoly)&&(this.attachments.push(buzzsaw),this.attachmentOffsets.push(new Phaser.Point(buzzsaw.xPos-this.xPos,buzzsaw.yPos-this.yPos)))}}},InvisBlockUp.prototype.spawn=function(x,y,width,height){_super.prototype.spawn.call(this,x,y,width,height),this.yVelocity=-2},InvisBlockUp.prototype.update=function(){this.yVelocity<0?this.yPos<this.startY-this.maxMoveDist&&(this.yVelocity=-this.yVelocity,this.landed&&(this.main.player.yPos+=2*this.yVelocity),this.main.player.updatePositions()):this.yPos>this.startY+this.maxMoveDist&&(this.yVelocity=-this.yVelocity,this.landed&&(this.main.player.yPos+=2*this.yVelocity),this.main.player.updatePositions()),this.yPos+=this.yVelocity;for(var i=0;i<this.attachments.length;i++){var spike=this.attachments[i],offset=this.attachmentOffsets[i];spike.xPos=this.xPos+offset.x,spike.yPos=this.yPos+offset.y,spike.updatePosition()}_super.prototype.update.call(this)},InvisBlockUp}(InvisBlock),InvisBlockDown=function(_super){function InvisBlockDown(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.maxMoveDist=100,_this}return __extends(InvisBlockDown,_super),InvisBlockDown.prototype.init=function(){this.sprite=this.layer.create(0,0,"invisBlockDown"),this.sprite.autoCull=!0,this.alive=!1},InvisBlockDown.prototype.levelStart=function(){this.attachments=[],this.attachmentOffsets=[];for(var testPoly=new SAT.Box(new SAT.Vector(this.leftEdge,this.topEdge-10),this.width,this.height+20).toPolygon(),i=0;i<this.main.obstacles.length;i++){var obs=this.main.obstacles[i];if("spike"===obs.obstacleType){var spike=obs;SAT.testPolygonPolygon(testPoly,spike.deathBoxPolygon)&&(this.attachments.push(spike),this.attachmentOffsets.push(new Phaser.Point(spike.xPos-this.xPos,spike.yPos-this.yPos)))}else if("buzzsaw"===obs.obstacleType){var buzzsaw=obs;SAT.testCirclePolygon(buzzsaw.deathCircle,testPoly)&&(this.attachments.push(buzzsaw),this.attachmentOffsets.push(new Phaser.Point(buzzsaw.xPos-this.xPos,buzzsaw.yPos-this.yPos)))}}},InvisBlockDown.prototype.spawn=function(x,y,width,height){_super.prototype.spawn.call(this,x,y,width,height),this.yVelocity=2},InvisBlockDown.prototype.update=function(){this.yVelocity<0?this.yPos<this.startY-this.maxMoveDist&&(this.yVelocity=-this.yVelocity,this.landed&&(this.main.player.yPos+=2*this.yVelocity),this.main.player.updatePositions()):this.yPos>this.startY+this.maxMoveDist&&(this.yVelocity=-this.yVelocity,this.landed&&(this.main.player.yPos+=2*this.yVelocity),this.main.player.updatePositions()),this.yPos+=this.yVelocity;for(var i=0;i<this.attachments.length;i++){var spike=this.attachments[i],offset=this.attachmentOffsets[i];spike.xPos=this.xPos+offset.x,spike.yPos=this.yPos+offset.y,spike.updatePosition()}_super.prototype.update.call(this)},InvisBlockDown}(InvisBlock),SwimmingPool=function(_super){function SwimmingPool(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"swimmingPool"),_this.sprite.anchor.set(.5,.5),_this.sprite.alpha=.6,_this.topMask=game.add.graphics(0,0,_this.layer),_this}return __extends(SwimmingPool,_super),SwimmingPool.prototype.spawn=function(x,y,width,height){this.xPos=x,this.yPos=y,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/250,height/250),this.electric=!1,this.prevElec=!1,this.totalPolygon=new SAT.Box(new SAT.Vector(x-width/2,y-height/2),width,height).toPolygon(),this.topPolygon=new SAT.Box(new SAT.Vector(x-width/2,y-height/2),width,12).toPolygon(),this.topMask.beginFill(16776960,.5),this.topMask.drawRect(0,0,width,height),this.topMask.endFill(),this.topMask.position.set(x-this.width/2,y-this.height/2)},SwimmingPool.prototype.update=function(){this.electric?(this.topMask.visible=!0,this.prevElec=!0):(this.topMask.visible=!1,this.prevElec=!1),this.electric=!1},SwimmingPool.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.topMask.destroy(),this.topMask=null,this.game=null,this.layer=null,this.totalPolygon=null,this.topPolygon=null,_super.prototype.destroy.call(this)},SwimmingPool}(Entity),Zipline=function(_super){function Zipline(main,game,layer,pos1,pos2){var _this=_super.call(this,main)||this;return pos1.y<pos2.y?(_this.startPos=pos1,_this.endPos=pos2,_this.topEdge=pos1.y,_this.bottomEdge=pos2.y):(_this.startPos=pos2,_this.endPos=pos1,_this.topEdge=pos2.y,_this.bottomEdge=pos1.y),_this.startPos.x<_this.endPos.x?(_this.direction="right",_this.leftEdge=_this.startPos.x,_this.rightEdge=_this.endPos.x):(_this.direction="left",_this.leftEdge=_this.endPos.x,_this.rightEdge=_this.startPos.x),_this.width=Math.abs(_this.endPos.x-_this.startPos.x),_this.height=Math.abs(_this.endPos.y-_this.startPos.y),_this.scope=_this.height/_this.width,_this.wire=game.add.graphics(0,0,layer),_this.wire.lineStyle(2,16737792),_this.wire.moveTo(_this.startPos.x,_this.startPos.y),_this.wire.lineTo(_this.endPos.x,_this.endPos.y),_this.hitPolygon=new SAT.Polygon(new SAT.Vector(_this.startPos.x,_this.startPos.y),[new SAT.Vector(0,5),new SAT.Vector(_this.endPos.x-_this.startPos.x,_this.endPos.y-_this.startPos.y+5),new SAT.Vector(_this.endPos.x-_this.startPos.x,_this.endPos.y-_this.startPos.y-5),new SAT.Vector(0,-5)]),_this}return __extends(Zipline,_super),Zipline.prototype.destroy=function(){this.wire.destroy(),this.wire=null,this.hitPolygon=null,this.startPos=null,this.endPos=null,_super.prototype.destroy.call(this)},Zipline}(Entity),Vector=SAT.Vector,ZiplinePole=function(_super){function ZiplinePole(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"ziplinePole"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(3/9.8,29.2/64.25),_this}return __extends(ZiplinePole,_super),ZiplinePole.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y)},ZiplinePole.prototype.attach=function(other){return((this.attachedZiplinePole=other).attachedZiplinePole=this).zipline=new Zipline(this.main,this.game,this.layer,new Phaser.Point(this.xPos,this.yPos-25),new Phaser.Point(other.xPos,other.yPos-25)),other.zipline=this.zipline,this.zipline},ZiplinePole.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.game=null,this.layer=null,this.attachedZiplinePole=null,this.zipline=null,_super.prototype.destroy.call(this)},ZiplinePole}(Entity),Checkpoint=function(_super){function Checkpoint(main,game,layer,floating){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.container=game.add.group(_this.layer),(_this.floating=floating)?(_this.sprite=_this.container.create(0,0,"checkpointSwimming"),_this.sprite.anchor.set(.5,.5)):(_this.sprite=_this.container.create(0,0,"checkpoint"),_this.sprite.anchor.set(8/21.15,17/55)),_this.sprite.autoCull=!0,_this}return __extends(Checkpoint,_super),Checkpoint.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.startY=y,this.container.position.set(x,y),this.boxPolygon=new SAT.Box(new SAT.Vector(x-60,y-40),120,80).toPolygon(),this.state=0,this.floatRad=0},Checkpoint.prototype.trigger=function(){this.sprite.frame=1,this.state=1;for(var i=0;i<10;i++)this.main.createColorParticle(this.xPos,this.yPos,10*Math.random()-5,-6-4*Math.random(),65280);this.main.checkpointText.spawn(this.xPos,this.yPos-30),this.main.dark&&this.main.goLight(),this.main.sounds.playSound("ding"),this.main.checkpointTriggered(this)},Checkpoint.prototype.gray=function(){this.sprite.frame=2,this.state=2},Checkpoint.prototype.resetLevel=function(){this.sprite.frame=0,this.state=0},Checkpoint.prototype.update=function(){this.floating&&(this.floatRad+=.1,this.floatRad%=8*Math.PI,this.sprite.position.y=25+10*Math.sin(this.floatRad/4),this.sprite.rotation=Math.cos(this.floatRad/4)*Math.PI/8)},Checkpoint.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.boxPolygon=null,this.container.destroy(),this.container=null,_super.prototype.destroy.call(this)},Checkpoint}(Entity),CheckPointText=function(_super){function CheckPointText(main,game,layer){var _this=_super.call(this,main)||this;return _this.alive=!1,_this.sprite=layer.create(0,0,"checkpointText"),_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this}return __extends(CheckPointText,_super),CheckPointText.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.alive=!0,this.displayTime=60,this.moveDist=0},CheckPointText.prototype.update=function(){this.alive&&0<this.displayTime&&(-30<this.moveDist&&(this.moveDist-=2),this.sprite.position.y=this.yPos+this.moveDist,this.displayTime--,this.displayTime<=0&&(this.sprite.visible=!1,this.alive=!1))},CheckPointText}(Entity),Pole=function(_super){function Pole(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"pole"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.redSection=layer.create(0,0,"poleRedSection"),_this.redSection.anchor.set(0,.5),_this.redSection.autoCull=!0,_this.redSection.visible=!1,_this.sprite.anchor.set(.5,.5),_this.hitBoxPolygon=new SAT.Box(new SAT.Vector(0,0),10,10).toPolygon(),_this.hitBoxPolygon.setOffset(new SAT.Vector(-5,-5)),_this}return __extends(Pole,_super),Pole.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.redSection.position.set(x,y),this.redSection.alpha=0,this.redSection.visible=!0,this.hitBoxPolygon.pos.x=x,this.hitBoxPolygon.pos.y=y},Pole.prototype.update=function(){this.main.player.currentPole!=this&&(this.redSection.alpha-=.5*this.redSection.alpha)},Pole.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.redSection.destroy(),this.redSection=null,this.hitBoxPolygon=null,this.game=null,this.layer=null,_super.prototype.destroy.call(this)},Pole}(Entity),Star=function(_super){function Star(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"star"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.hitBoxPolygon=new SAT.Box(new SAT.Vector(0,0),40,40).toPolygon(),_this.hitBoxPolygon.setOffset(new SAT.Vector(-20,-20)),_this.alive=!1,_this}return __extends(Star,_super),Star.prototype.spawn=function(x,y){this.main.currentLevel.gotStar||(this.xPos=x,this.yPos=y,this.sprite.visible=!0,this.sprite.position.set(x,y),this.hitBoxPolygon.pos.x=x,this.hitBoxPolygon.pos.y=y,this.alive=!0)},Star.prototype.getStar=function(){this.main.currentLevel.gotStar=!0,this.main.achievements.gotAchievement("star"+this.main.currentLevelID),this.main.levels.checkAstronomer()&&this.main.achievements.gotAchievement("astronomer"),this.main.sounds.playSound("starPickup"),this.main.currentLevel.saveLevel(),this.die()},Star.prototype.die=function(){this.alive=!1,this.sprite.visible=!1},Star.prototype.reset=function(){},Star.prototype.resetLevel=function(){},Star.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.hitBoxPolygon=null,this.game,this.layer,_super.prototype.destroy.call(this)},Star}(Entity),WindBlaster=function(_super){function WindBlaster(main,game,layer){var _this=_super.call(this,main)||this;_this.game=game,_this.layer=layer,_this.container=game.add.group(layer),_this.windGraphics=[];var ww=game.make.graphics(0,0);ww.lineStyle(1,2236962),ww.moveTo(0,0),ww.lineTo(27,0);var tex=ww.generateTexture();ww.destroy();for(var i=0;i<6;i++){var spr=_this.game.add.sprite(0,0,tex,null,_this.container);spr.visible=!1,_this.windGraphics.push(spr)}return _this.sprite=_this.container.create(0,0,"windBlaster"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(0,.5),_this.fanSprite=game.add.sprite(0,0,"windFan"),_this.fanSprite.anchor.set(0,.5),_this.fanSprite.animations.add("fan"),_this.fanSprite.play("fan",null,!0),_this.sprite.addChild(_this.fanSprite),_this.fanMask=new SAT.Box(new SAT.Vector(0,0),180,50).toPolygon(),_this.fanMask.setOffset(new SAT.Vector(0,-25)),_this.alive=!1,_this}return __extends(WindBlaster,_super),WindBlaster.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.container.position.set(x,y),this.container.angle=rotation,this.rotation=rotation,this.fanMask.pos.x=x,this.fanMask.pos.y=y,this.fanMask.setAngle(rotation*Math.PI/180),this.alive=!0;for(var _i=this.inc=0,_a=this.windGraphics;_i<_a.length;_i++){var ww=_a[_i];ww.position.set(130*Math.random(),46*Math.random()-23),ww.visible=!0}},WindBlaster.prototype.update=function(){var player=this.main.player;if(player&&player.alive)if(SAT.testPolygonPolygon(this.fanMask,this.main.player.totalPolygon)){var rad=this.rotation*Math.PI/180,yPush=.15*Math.sin(rad);yPush<-.12&&(this.inc=Math.max(2,this.inc)),this.main.player.yVelocity+=.25*Math.sin(rad)*this.inc,this.main.player.xVelocity+=.25*Math.cos(rad)*this.inc,yPush<-.12&&this.main.player.yPos>this.yPos-5&&(this.main.player.yPos=this.yPos-5,this.main.player.yVelocity=-4,this.main.player.updateHitBoxesPos(),this.main.player.falling=!0),this.inc<2.5?this.inc+=.25:this.inc=2.5}else this.inc-=.25,this.inc<0&&(this.inc=0);for(var _i=0,_a=this.windGraphics;_i<_a.length;_i++){var ww=_a[_i];ww.position.x+=6,ww.alpha-=.05,130<ww.position.x&&(ww.position.x=0,ww.position.y=46*Math.random()-23,ww.alpha=1)}},WindBlaster.prototype.die=function(){this.alive=!1,this.container.visible=!1},WindBlaster.prototype.destroy=function(){this.container.destroy(),this.container=null,this.fanSprite.destroy(),this.fanSprite=null;for(var _i=0,_a=this.windGraphics;_i<_a.length;_i++){_a[_i].destroy(!0,!0)}_super.prototype.destroy.call(this)},WindBlaster}(Entity),FinishPortal=function(_super){function FinishPortal(main,game,layer){var _this=_super.call(this,main)||this;return _this.particleSpawnRate=3,_this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"finishPortal"),_this.sprite.autoCull=!0,_this.sprite.animations.add("animate"),_this.sprite.animations.play("animate",30,!0),_this.sprite.anchor.set(.5,.5),_this.main.options.blend&&(FinishPortal.BlurFilterX||((FinishPortal.BlurFilterX=game.add.filter("BlurX")).blur=20),FinishPortal.BlurFilterY||((FinishPortal.BlurFilterY=game.add.filter("BlurY")).blur=20),_this.sprite.filters=[FinishPortal.BlurFilterX,FinishPortal.BlurFilterY]),_this.hitBoxPolygon=new SAT.Box(new SAT.Vector(0,0),60,60).toPolygon(),_this.hitBoxPolygon.setOffset(new SAT.Vector(-30,-30)),_this}return __extends(FinishPortal,_super),FinishPortal.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.hitBoxPolygon.pos.x=x,this.hitBoxPolygon.pos.y=y,this.particleTimer=0},FinishPortal.prototype.update=function(){this.particleTimer++,this.particleTimer>this.particleSpawnRate&&(this.main.createColorParticle(this.xPos-80+160*Math.random(),this.yPos-80+160*Math.random(),0,0,4649252,4,!1),this.particleTimer=0);for(var _i=0,_a=this.main.particles;_i<_a.length;_i++){var particle=_a[_i];if(!particle.alive)return;var distSq=Math.pow(particle.xPos-this.xPos,2)+Math.pow(particle.yPos-this.yPos,2);distSq<62500&&(distSq<2500&&(particle.fadeTime=150,particle.multAlpha(.5)),particle.yPos<this.yPos?particle.yVelocity+=.75:particle.yPos>this.yPos&&(particle.yVelocity-=.75),particle.xPos<this.xPos?particle.xVelocity+=.75:particle.xPos>this.xPos&&(particle.xVelocity-=.75))}},FinishPortal.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.hitBoxPolygon=null,_super.prototype.destroy.call(this)},FinishPortal}(Entity),HazardStrips=function(_super){function HazardStrips(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"hazardStrips"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.alive=!1,_this}return __extends(HazardStrips,_super),HazardStrips.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.alive=!0},HazardStrips.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},HazardStrips}(Entity),Key=function(_super){function Key(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.init(),_this.hitBoxPolygon=new SAT.Box(new SAT.Vector(0,0),20,40).toPolygon(),_this.hitBoxPolygon.setOffset(new SAT.Vector(-10,-20)),_this.alive=!1,_this.lineColor=16763904,_this}return __extends(Key,_super),Key.prototype.init=function(){this.sprite=this.layer.create(0,0,"key"),this.sprite.autoCull=!0,this.sprite.anchor.set(.5,.5),this.lineGraphic=this.game.add.graphics(0,0,this.layer)},Key.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.xVelocity=0,this.yVelocity=0,this.sprite.position.set(x,y),this.hitBoxPolygon.pos.x=x,this.hitBoxPolygon.pos.y=y,this.alive=!0,this.used=!1,this.keyNum=0,this.saveUse=!1,this.following=!1,this.rad=0},Key.prototype.useKey=function(){this.used=!0,this.lineGraphic.clear(),this.sprite.visible=!1,this.alive=!1},Key.prototype.followPlayer=function(){var tarX,tarY,offset=10*(this.keyNum-1);this.rad=-4*this.player.xVelocity*Math.PI/180,this.yVelocity<0&&(this.yVelocity+=.5),this.yPos+=this.yVelocity,tarY=this.player.swimming?(tarX=this.player.xPos,this.player.yPos-offset):(tarX="right"===this.player.facing?this.player.xPos-30:this.player.xPos+30,this.player.yPos-6-offset);var xDist=tarX-this.xPos,yDist=tarY-this.yPos;this.xPos+=xDist/5,this.yPos+=yDist/5,Math.abs(xDist)<1&&(this.xPos=tarX),Math.abs(yDist)<1&&(this.yPos=tarY),this.hitBoxPolygon.pos.x=this.xPos,this.hitBoxPolygon.pos.y=this.yPos},Key.prototype.runCollisions=function(){for(var _i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];if(block.alive){if(SAT.testPolygonPolygon(block.topBoundPolygon,this.hitBoxPolygon)){this.player.xVelocity<5?this.yVelocity=this.player.xVelocity*this.player.xVelocity*-.2:this.yVelocity=-5,this.yPos=block.topEdge-20,this.hitBoxPolygon.pos.y=this.yPos;continue}if(SAT.testPolygonPolygon(block.rightBoundPolygon,this.hitBoxPolygon)){this.xPos=block.rightEdge+11;continue}if(SAT.testPolygonPolygon(block.leftBoundPolygon,this.hitBoxPolygon)){this.xPos=block.leftEdge-11;continue}SAT.testPolygonPolygon(block.bottomBoundPolygon,this.hitBoxPolygon)&&(this.yVelocity*=-1,this.yPos=block.bottomEdge+21)}}},Key.prototype.drawLineToPlayer=function(){this.lineGraphic.clear(),this.lineGraphic.lineStyle(2,this.lineColor),this.lineGraphic.moveTo(this.xPos,this.yPos),this.player.currentPole?this.lineGraphic.lineTo(this.player.xPos,this.player.yPos-31):this.player.crouching?this.lineGraphic.lineTo(this.player.xPos,this.player.yPos-6):this.lineGraphic.lineTo(this.player.xPos,this.player.yPos-16)},Key.prototype.follow=function(){this.following=!0},Key.prototype.update=function(){this.alive&&(this.player=this.main.player,this.used?.1<this.sprite.scale.x?(this.sprite.scale.x-=.1,this.sprite.scale.y=this.sprite.scale.x,this.rad-=5*Math.PI/180,this.sprite.rotation=this.rad):(this.alive=!1,this.sprite.visible=!1):this.following&&(this.followPlayer(),this.runCollisions(),this.drawLineToPlayer(),this.updatePositions()))},Key.prototype.die=function(){this.alive=!1,this.sprite.visible=!1},Key.prototype.reset=function(){this.used||(this.xPos=this.startX,this.yPos=this.startY,this.updatePositions(),this.following&&(this.following=!1,this.lineGraphic.clear()))},Key.prototype.resetLevel=function(){this.xPos=this.startX,this.yPos=this.startY,this.updatePositions(),this.sprite.scale.set(1,1),this.used=!1,this.alive=!0,this.sprite.visible=!0,this.following=!1},Key.prototype.updatePositions=function(){this.sprite.position.set(this.xPos,this.yPos),this.hitBoxPolygon.pos.x=this.xPos,this.hitBoxPolygon.pos.y=this.yPos},Key.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.hitBoxPolygon=null,this.lineGraphic.destroy(),this.lineGraphic=null,this.game=null,this.layer=null,this.player=null,_super.prototype.destroy.call(this)},Key}(Entity),TimedKey=function(_super){function TimedKey(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.lineColor=16711680,_this}return __extends(TimedKey,_super),TimedKey.prototype.spawn=function(x,y){_super.prototype.spawn.call(this,x,y),this.timer=0},TimedKey.prototype.init=function(){this.sprite=this.layer.create(0,0,"timedKey"),this.sprite.autoCull=!0,this.sprite.anchor.set(.5,.5),this.lineGraphic=this.game.add.graphics(0,0,this.layer)},TimedKey.prototype.follow=function(){this.following=!0,this.timer=0},TimedKey.prototype.update=function(){this.following&&!this.used&&(this.timer>=TimedKey.TIMER_MAX?(this.main.player.loseKey(this),this.reset()):this.timer++),_super.prototype.update.call(this)},TimedKey.TIMER_MAX=180,TimedKey}(Key),CircularCannon=function(_super){function CircularCannon(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.container=game.add.group(layer),_this.baseSprite=_this.container.create(0,0,"cannonBase"),_this.baseSprite.autoCull=!0,_this.baseSprite.anchor.set(.5,.5),_this.tubeSprite=_this.container.create(0,0,"cannonTube"),_this.tubeSprite.autoCull=!0,_this.tubeSprite.anchor.set(3/37,.5),_this.alive=!1,_this}return __extends(CircularCannon,_super),CircularCannon.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.container.position.set(x,y),this.alive=!0,this.rad=0,this.cannonSpeed=4*Math.PI/180,this.firing=!1,this.power=15},CircularCannon.prototype.fire=function(){var player=this.main.player;player.currentCannon=null;var xFire=Math.cos(this.rad)*this.power,yFire=Math.sin(this.rad)*this.power;player.swimming?player.xVelocity=xFire:player.forcedXVelocity=xFire,player.yVelocity=yFire,player.xPos=this.xPos+80*Math.cos(this.rad),player.yPos=this.yPos+80*Math.sin(this.rad),player.rotationDest=0,this.main.sounds.playSound("cannonFire");for(var i=0;i<10;i++)this.main.createColorParticle(player.xPos,player.yPos,xFire*(Math.random()+.25),yFire*(Math.random()+.25),16759552,4);player.swimming||(player.falling=!0,player.setJump()),player.container.parent.removeChild(player.container),this.main.playerUnderLayer.addChild(player.container),player.updateHitBoxesPos(),this.firing=!1},CircularCannon.prototype.update=function(){var player=this.main.player;this.firing?(this.tubeSprite.scale.x-=.15*(this.tubeSprite.scale.x-.75),this.tubeSprite.scale.y-=.15*(this.tubeSprite.scale.y-1.35),this.tubeSprite.scale.x<.9&&this.fire()):(this.tubeSprite.scale.x-=.3*(this.tubeSprite.scale.x-1),this.tubeSprite.scale.y-=.3*(this.tubeSprite.scale.y-1),player.currentCannon!==this?this.rad=Math.atan2(player.yPos-this.yPos,player.xPos-this.xPos):(this.rad+=this.cannonSpeed,this.rad%=360),this.tubeSprite.rotation=this.rad)},CircularCannon.prototype.die=function(){this.alive=!1,this.container.visible=!1},CircularCannon.prototype.destroy=function(){this.baseSprite.destroy(),this.baseSprite=null,this.tubeSprite.destroy(),this.tubeSprite=null,this.container.destroy(),this.container=null,_super.prototype.destroy.call(this)},CircularCannon}(Entity),BreatheBlaster=function(_super){function BreatheBlaster(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"breatheBlaster"),_this.sprite.anchor.set(1,.5),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.sprite.scale.set(1,.5),_this.alive=!1,_this.hitPoly=new SAT.Box(new SAT.Vector(0,0),100,50).toPolygon(),_this}return __extends(BreatheBlaster,_super),BreatheBlaster.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.angle=rotation,this.sprite.visible=!0,this.alive=!0,this.rad=rotation*Math.PI/180,this.hitPoly.pos.x=x,this.hitPoly.pos.y=y,this.hitPoly.setAngle(rotation*Math.PI/180)},BreatheBlaster.prototype.update=function(){if(Math.random()<.25){var ss=4*Math.random(),rr=this.rad-2+4*Math.random();this.main.createColorParticle(this.xPos,this.yPos,Math.cos(rr)*ss,Math.sin(rr)*ss,3394815,4,!0,!0,100)}},BreatheBlaster.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this),this.game=null,this.layer=null},BreatheBlaster}(Entity),LightSwitch=function(_super){function LightSwitch(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"lightSwitch"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.hitBoxPolygon=new SAT.Box(new SAT.Vector(0,0),20,20).toPolygon(),_this.hitBoxPolygon.setOffset(new SAT.Vector(-10,-10)),_this}return __extends(LightSwitch,_super),LightSwitch.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.hitBoxPolygon.pos.x=x,this.hitBoxPolygon.pos.y=y},LightSwitch.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},LightSwitch}(Entity),Wire=function(_super){function Wire(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.sprite=layer.create(0,0,"wire"),_this.sprite.autoCull=!0,_this.sprite.visible=!1,_this.sprite.anchor.set(1,.5),_this.alive=!1,_this}return __extends(Wire,_super),Wire.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.rad=(rotation+90)*Math.PI/180,this.sprite.position.set(x+25*Math.cos(this.rad),y+25*Math.sin(this.rad)),this.sprite.rotation=this.rad,this.sprite.visible=!0,this.alive=!0},Wire.prototype.resetLevel=function(){this.sprite.scale.x=1},Wire.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.game=null,this.layer=null,_super.prototype.destroy.call(this)},Wire}(Entity),WireTrail=function(){function WireTrail(main,wires){this.sparkSpeed=.15,this.main=main,this.wires=wires,this.spark=new Spark(main,main.game,main.obstacleLayer,null),this.currentInd=wires.length,this.spark.spawn(0,0),this.nextWire(),this.main.obstacles.push(this.spark),this.burning=!1}return WireTrail.prototype.nextWire=function(){if(0===this.currentInd)return this.main.explosiveBlock.exploding=!0,void(this.burning=!1);this.currentInd--,this.currentWire=this.wires[this.currentInd],this.spark.xPos=this.currentWire.xPos-25*Math.cos(this.currentWire.rad),this.spark.yPos=this.currentWire.yPos-25*Math.sin(this.currentWire.rad),this.sparkXSpeed=Math.cos(this.currentWire.rad)*this.sparkSpeed,this.sparkYSpeed=Math.sin(this.currentWire.rad)*this.sparkSpeed},WireTrail.prototype.update=function(){this.burning&&(this.spark.xPos+=this.sparkXSpeed,this.spark.yPos+=this.sparkYSpeed,this.currentWire.sprite.scale.x-=this.sparkSpeed/50,this.currentWire.sprite.scale.x<=0&&(this.currentWire.sprite.scale.x=0,this.nextWire()))},WireTrail.prototype.startFollow=function(){this.followInd=0,this.followWire=this.wires[this.followInd],this.followDist=0,this.followX=this.followWire.xPos+25*Math.cos(this.followWire.rad)-this.main.game.width/2,this.followY=this.followWire.yPos+25*Math.sin(this.followWire.rad)-this.main.game.height/2,this.followXSpeed=-8*Math.cos(this.followWire.rad),this.followYSpeed=-8*Math.sin(this.followWire.rad)},WireTrail.prototype.followTick=function(){if(this.followX+=this.followXSpeed,this.followY+=this.followYSpeed,this.followDist+=8,50<=this.followDist){if(this.followInd++,this.followInd>=this.wires.length-4)return!0;this.followWire=this.wires[this.followInd],this.followDist=0,this.followX=this.followWire.xPos+25*Math.cos(this.followWire.rad)-this.main.game.width/2,this.followY=this.followWire.yPos+25*Math.sin(this.followWire.rad)-this.main.game.height/2,this.followXSpeed=-8*Math.cos(this.followWire.rad),this.followYSpeed=-8*Math.sin(this.followWire.rad)}return this.main.game.camera.x=this.followX,this.main.game.camera.y=this.followY,!1},WireTrail.prototype.destroy=function(){this.burning=!1,this.main=null,this.wires=null,this.spark=null},WireTrail.prototype.resetLevel=function(){for(var _i=0,_a=this.wires;_i<_a.length;_i++){_a[_i].sprite.scale.set(1,1)}this.currentInd=this.wires.length,this.nextWire()},WireTrail}(),Obstacle=function(_super){function Obstacle(main,game,layer){var _this=_super.call(this,main)||this;return _this.game=game,_this.layer=layer,_this.alive=!1,_this}return __extends(Obstacle,_super),Obstacle.prototype.levelStart=function(){},Obstacle.prototype.update=function(){},Obstacle.prototype.destroy=function(){this.main=null,this.game=null,this.layer=null,_super.prototype.destroy.call(this)},Obstacle.prototype.updatePosition=function(){},Obstacle}(Entity),Buzzsaw=function(_super){function Buzzsaw(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"buzzsaw"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.deathCircle=new SAT.Circle(new SAT.Vector(0,0),44),_this.obstacleType="buzzsaw",_this.killValue=2,_this}return __extends(Buzzsaw,_super),Buzzsaw.prototype.levelStart=function(){for(var _i=0,_a=this.main.pools;_i<_a.length;_i++){var pool=_a[_i];SAT.testCirclePolygon(this.deathCircle,pool.totalPolygon)&&this.main.underPoolLayer.addChild(this.sprite)}},Buzzsaw.prototype.spawn=function(x,y,scale){void 0===scale&&(scale=1),this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.deathCircle.pos.x=x,this.deathCircle.pos.y=y,this.alive=!0,1!=scale&&(this.sprite.scale.set(scale,scale),this.deathCircle.r=44*scale)},Buzzsaw.prototype.update=function(){this.sprite.rotation+=4*Math.PI/180},Buzzsaw.prototype.updatePosition=function(){this.sprite.position.set(this.xPos,this.yPos),this.deathCircle.pos.x=this.xPos,this.deathCircle.pos.y=this.yPos},Buzzsaw.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.deathCircle=null,_super.prototype.destroy.call(this)},Buzzsaw}(Obstacle),BuzzsawVerticalUp=function(_super){function BuzzsawVerticalUp(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.maxMoveDist=100,_this.obstacleType="buzzsaw",_this.alive=!1,_this}return __extends(BuzzsawVerticalUp,_super),BuzzsawVerticalUp.prototype.spawn=function(x,y,startSpeed){void 0===startSpeed&&(startSpeed=-2),this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.yVelocity=startSpeed,this.startY=y,this.deathCircle.pos.x=x,this.deathCircle.pos.y=y,this.alive=!0},BuzzsawVerticalUp.prototype.update=function(){_super.prototype.update.call(this);var prevY=this.yPos;this.yVelocity<0?this.yPos<this.startY-this.maxMoveDist&&(this.yVelocity=-this.yVelocity):this.yPos>this.startY+this.maxMoveDist&&(this.yVelocity=-this.yVelocity),this.yPos+=this.yVelocity,this.yPos!=prevY&&this.updatePosition()},BuzzsawVerticalUp.prototype.updatePosition=function(){this.sprite.position.set(this.xPos,this.yPos),this.deathCircle.pos.y=this.yPos},BuzzsawVerticalUp.prototype.reset=function(){this.yVelocity=-2,this.updatePosition()},BuzzsawVerticalUp.prototype.resetLevel=function(){this.reset()},BuzzsawVerticalUp}(Buzzsaw),BuzzsawHorizontal=function(_super){function BuzzsawHorizontal(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.maxMoveDist=100,_this.obstacleType="buzzsaw",_this.alive=!1,_this}return __extends(BuzzsawHorizontal,_super),BuzzsawHorizontal.prototype.spawn=function(x,y,speed,scale){void 0===scale&&(scale=1),this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.xVelocity=-speed,this.startSpeed=speed,this.startX=x,this.startY=y,this.deathCircle.pos.x=x,this.deathCircle.pos.y=y,this.alive=!0,1!=scale&&(this.sprite.scale.set(scale,scale),this.deathCircle.r=45*scale)},BuzzsawHorizontal.prototype.update=function(){_super.prototype.update.call(this);var prevX=this.xPos;0<this.xVelocity?this.xPos>this.startX+this.maxMoveDist&&(this.xVelocity=-this.xVelocity):this.xPos<this.startX-this.maxMoveDist&&(this.xVelocity=-this.xVelocity),this.xPos+=this.xVelocity,this.xPos!=prevX&&(this.sprite.position.x=this.xPos,this.deathCircle.pos.x=this.xPos)},BuzzsawHorizontal.prototype.reset=function(){this.xVelocity=-this.startSpeed,this.xPos=this.startX,this.yPos=this.startY,this.updatePosition()},BuzzsawHorizontal.prototype.resetLevel=function(){this.reset()},BuzzsawHorizontal}(Buzzsaw),BouncingBuzzsaw=function(_super){function BouncingBuzzsaw(main,game,layer){return _super.call(this,main,game,layer)||this}return __extends(BouncingBuzzsaw,_super),BouncingBuzzsaw.prototype.spawn=function(x,y,scale){void 0===scale&&(scale=1),_super.prototype.spawn.call(this,x,y,scale),this.yVelocity=0},BouncingBuzzsaw.prototype.update=function(){this.alive&&(this.yVelocity+=this.main.gravity*this.main.gameSpeed,this.yPos+=this.yVelocity,this.updatePosition(),this.checkBlockCollisions()),_super.prototype.update.call(this)},BouncingBuzzsaw.prototype.checkBlockCollisions=function(){for(var _i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];block.alive&&(SAT.testPolygonCircle(block.topBoundPolygon,this.deathCircle)&&(this.yVelocity*=-1,this.yPos+=this.yVelocity))}},BouncingBuzzsaw.prototype.reset=function(){this.yPos=this.startY,this.yVelocity=0,this.updatePosition()},BouncingBuzzsaw.prototype.resetLevel=function(){this.reset(),_super.prototype.resetLevel.call(this)},BouncingBuzzsaw}(Buzzsaw),EnlargingBuzzsaw=function(_super){function EnlargingBuzzsaw(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.obstacleType="buzzsaw",_this.alive=!1,_this}return __extends(EnlargingBuzzsaw,_super),EnlargingBuzzsaw.prototype.spawn=function(x,y,scale){void 0===scale&&(scale=1),this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.visible=!0,this.enlarging=!0,this.deathCircle.pos.x=x,this.deathCircle.pos.y=y,this.scaleXStart=scale,this.scaleYStart=scale,this.scale=scale,this.alive=!0},EnlargingBuzzsaw.prototype.update=function(){this.enlarging?(this.scale+=.02*this.scaleXStart*this.main.gameSpeed,this.scale>2.5*this.scaleXStart&&(this.scale=2.5*this.scaleXStart,this.enlarging=!1)):(this.scale-=.02*this.scaleXStart*this.main.gameSpeed,this.scale<.5*this.scaleXStart&&(this.scale=.5*this.scaleXStart,this.enlarging=!0)),_super.prototype.update.call(this),this.updatePosition()},EnlargingBuzzsaw.prototype.updatePosition=function(){this.sprite.scale.set(this.scale,this.scale),this.sprite.position.set(this.xPos,this.yPos),this.deathCircle.pos.y=this.yPos,this.deathCircle.r=42*this.scale},EnlargingBuzzsaw.prototype.resetLevel=function(){},EnlargingBuzzsaw}(Buzzsaw),BuzzsawOnStick=function(_super){function BuzzsawOnStick(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"buzzsawOnStick"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.1,.5),_this.sprite.visible=!1,_this.obstacleType="misc",_this.buzzsaw=new Buzzsaw(_this.main,_this.game,_this.layer),_this.main.obstacles.push(_this.buzzsaw),_this}return __extends(BuzzsawOnStick,_super),BuzzsawOnStick.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.rotation=rotation,this.startRotation=rotation,this.sprite.position.set(x,y),this.sprite.rotation=rotation,this.sprite.visible=!0,this.alive=!0;var rad=this.rotation*Math.PI/180;this.buzzsaw.spawn(this.xPos+130*Math.cos(rad),this.yPos+130*Math.sin(rad),.5)},BuzzsawOnStick.prototype.update=function(){this.rotation+=8,this.updatePosition()},BuzzsawOnStick.prototype.updatePosition=function(){var rad=this.rotation*Math.PI/180;this.sprite.rotation=rad,this.buzzsaw.xPos=this.xPos+130*Math.cos(rad),this.buzzsaw.yPos=this.yPos+130*Math.sin(rad),this.buzzsaw.updatePosition()},BuzzsawOnStick.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.buzzsaw=null},BuzzsawOnStick.prototype.resetLevel=function(){this.rotation=this.startRotation,this.updatePosition()},BuzzsawOnStick}(Obstacle),FallingSpike=function(_super){function FallingSpike(main,game,layer,dispenser){void 0===dispenser&&(dispenser=!1);var _this=_super.call(this,main,game,layer)||this;_this.game=game,_this.layer=layer,_this.obstacleType="spike",_this.sprite=_this.layer.create(0,0,"fallingSpike"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.alive=!1,_this.dispenser=dispenser,_this.graphics=_this.game.add.graphics(0,0,_this.layer),_this.graphics.visible=!0,_this.width=7.5,_this.height=14.75,_this.deathBoxPolygon=new SAT.Box(new SAT.Vector(0,0),_this.width,_this.height).toPolygon();var halfWidth=.5*_this.width,halfHeight=.5*_this.height;return _this.deathBoxPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),_this}return __extends(FallingSpike,_super),FallingSpike.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.rotation=rotation,this.rad=rotation*Math.PI/180,this.xVelocity=0,this.yVelocity=0,this.sprite.position.set(x,y),this.sprite.angle=rotation,this.dispenser||(this.sprite.visible=!0),this.alive=!0,this.deathBoxPolygon.pos.x=x,this.deathBoxPolygon.pos.y=y,this.falling=!1,this.fallDist=0,this.speed=0},FallingSpike.prototype.levelStart=function(){this.range=350;for(var rad=this.rotation*Math.PI/180,maxOff=0,ss=10;ss<=this.range;){for(var tt=new SAT.Polygon(new SAT.Vector(this.xPos,this.yPos),[new SAT.Vector(0,0),new SAT.Vector(Math.cos(rad)*ss,Math.sin(rad)*ss)]),_i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i],resp=new SAT.Response;SAT.testPolygonPolygon(tt,block.totalBoundPolygon,resp)&&Math.abs(resp.overlap)>maxOff&&(maxOff=Math.abs(resp.overlap))}if(0<maxOff){ss-=maxOff;break}if(ss===this.range)break;(ss+=20)>this.range&&(ss=this.range)}this.hitDist=ss,this.searchHitBox=new SAT.Box(new SAT.Vector(this.xPos,this.yPos),this.hitDist,16).toPolygon(),this.searchHitBox.offset=new SAT.Vector(0,-8),this.searchHitBox.setAngle(rad)},FallingSpike.prototype.update=function(){if(this.alive)if(this.falling)this.xVelocity+=Math.cos(this.rad)*this.main.gravity,this.yVelocity+=Math.sin(this.rad)*this.main.gravity,this.speed+=this.main.gravity,this.xPos+=this.xVelocity,this.yPos+=this.yVelocity,this.fallDist+=this.speed,this.updatePositions(),this.fallDist>this.hitDist&&this.reset();else{if(this.xPos!=this.startX||this.yPos!=this.startY){var xDist=this.startX-this.xPos,yDist=this.startY-this.yPos;Math.abs(xDist)<1?this.xPos=this.startX:this.xPos+=xDist/5,Math.abs(yDist)<1?this.yPos=this.startY:this.yPos+=(this.startY-this.yPos)/5,this.updatePositions()}var player=this.main.player;SAT.testPolygonPolygon(this.searchHitBox,player.totalPolygon)&&(this.falling=!0)}},FallingSpike.prototype.updatePositions=function(){this.sprite.position.set(this.xPos,this.yPos),this.deathBoxPolygon.pos.x=this.xPos,this.deathBoxPolygon.pos.y=this.yPos},FallingSpike.prototype.reset=function(){this.dispenser?this.die():(this.falling=!1,this.xPos=this.startX-15*Math.cos(this.rad),this.yPos=this.startY-15*Math.sin(this.rad),this.xVelocity=0,this.yVelocity=0,this.sprite.position.set(this.xPos,this.yPos),this.deathBoxPolygon.pos.x=this.xPos,this.deathBoxPolygon.pos.y=this.yPos,this.fallDist=0,this.speed=0)},FallingSpike.prototype.dispenserFire=function(){this.falling=!0,this.alive=!0,this.xPos=this.startX+15*Math.cos(this.rad),this.yPos=this.startY+15*Math.sin(this.rad),this.xVelocity=0,this.yVelocity=0,this.sprite.position.set(this.xPos,this.yPos),this.sprite.visible=!0,this.deathBoxPolygon.pos.x=this.xPos,this.deathBoxPolygon.pos.y=this.yPos,this.fallDist=0,this.speed=0},FallingSpike.prototype.die=function(){this.sprite.visible=!1,this.alive=!1},FallingSpike.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.searchHitBox=null,this.deathBoxPolygon=null,this.graphics.destroy(),this.graphics=null,_super.prototype.destroy.call(this)},FallingSpike.prototype.resetLevel=function(){this.reset()},FallingSpike}(Obstacle),ShurikanHorizontal=function(_super){function ShurikanHorizontal(main,game,layer,spawner){var _this=_super.call(this,main,game,layer)||this;return _this.spawner=spawner,_this.sprite=layer.create(0,0,"shurikanHorizontal"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.obstacleType="shurikan",_this.alive=!1,_this.hitBoxPoly=new SAT.Box(new Vector(0,0),20,20).toPolygon(),_this.hitBoxPoly.setOffset(new SAT.Vector(-10,-10)),_this}return __extends(ShurikanHorizontal,_super),ShurikanHorizontal.prototype.spawn=function(x,y,xVelocity,yVelocity,frame){void 0===frame&&(frame=0),this.xPos=x,this.yPos=y,this.xVelocity=xVelocity,this.yVelocity=yVelocity,this.speed=Math.sqrt(xVelocity*xVelocity+yVelocity*yVelocity),this.dist=0,this.sprite.position.set(x,y),this.sprite.scale.set(1,1),this.sprite.frame=frame,this.sprite.visible=!0,this.alive=!0,this.rotation=0},ShurikanHorizontal.prototype.update=function(){this.alive&&(this.rotation+=15*this.main.gameSpeed,200<this.dist?(this.sprite.scale.x-=.1*this.main.gameSpeed,this.sprite.scale.y=this.sprite.scale.x,this.sprite.scale.x<=.1&&(this.alive=!1,this.sprite.visible=!1,this.spawner.shurikanPool.push(this),this.spawner.spawned--)):(this.xPos+=this.xVelocity,this.yPos+=this.yVelocity,this.dist+=this.speed),this.sprite.position.set(this.xPos,this.yPos),this.hitBoxPoly.pos.x=this.xPos,this.hitBoxPoly.pos.y=this.yPos,this.sprite.rotation=this.rotation*Math.PI/180)},ShurikanHorizontal.prototype.resetLevel=function(){this.alive=!1,this.sprite.visible=!1,this.spawner.shurikanPool.push(this)},ShurikanHorizontal.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.spawner=null,this.hitBoxPoly=null,_super.prototype.destroy.call(this)},ShurikanHorizontal}(Obstacle),ShurikanSpawner=function(_super){function ShurikanSpawner(main,game,layer){var _this=_super.call(this,main,game,layer)||this;_this.sprite=layer.create(0,0,"shurikanSpawner"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.obstacleType="spawner",_this.alive=!1,_this.shurikanPool=[];for(var i=0;i<3;i++){var shurikan=new ShurikanHorizontal(_this.main,_this.game,_this.layer,_this);_this.shurikanPool.push(shurikan),_this.main.obstacles.push(shurikan)}return _this}return __extends(ShurikanSpawner,_super),ShurikanSpawner.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.rotation=rotation,this.sprite.position.set(x,y),this.sprite.rotation=rotation*Math.PI/180,this.cooldown=0,this.spawned=0,this.alive=!0},ShurikanSpawner.prototype.update=function(){if(this.alive&&this.spawned<3&&(this.cooldown+=this.main.gameSpeed,this.cooldown>ShurikanSpawner.fireTimer)){this.cooldown=0;var shurikan=this.shurikanPool.pop();if(!shurikan)return;var xVel=1.3*Math.cos(this.rotation*Math.PI/180),yVel=1.3*Math.sin(this.rotation*Math.PI/180),frame=0;90==this.rotation||-90==this.rotation?frame=1:0!=this.rotation&&-180!=this.rotation&&180!=this.rotation&&(frame=2),shurikan.spawn(this.xPos,this.yPos,xVel,yVel,frame),this.spawned++,3===this.spawned&&(this.cooldown=-60)}},ShurikanSpawner.prototype.resetLevel=function(){this.spawned=0,this.cooldown=0},ShurikanSpawner.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.shurikanPool=null,_super.prototype.destroy.call(this)},ShurikanSpawner.fireTimer=30,ShurikanSpawner}(Obstacle),Bullet=function(_super){function Bullet(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.game=game,_this.layer=layer,_this.obstacleType="bullet",_this.sprite=_this.layer.create(0,0,"bullet"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.deathBoxPolygon=new SAT.Box(new SAT.Vector(0,0),8,8).toPolygon(),_this.deathBoxPolygon.setOffset(new SAT.Vector(-4,-4)),_this.graphics=_this.game.add.graphics(0,0,_this.layer),_this.graphics.visible=!0,_this.alive=!1,_this}return __extends(Bullet,_super),Bullet.prototype.spawn=function(x,y,xVelocity,yVelocity,rad){this.xPos=x,this.yPos=y,this.xVelocity=xVelocity,this.yVelocity=yVelocity,this.rad=rad,this.sprite.position.set(x,y),this.sprite.rotation=rad,this.deathBoxPolygon.pos.x=x,this.deathBoxPolygon.pos.y=y,this.deathBoxPolygon.setAngle(rad),this.alive=!0,this.sprite.visible=!0},Bullet.prototype.update=function(){if(this.alive){this.xPos+=this.xVelocity*this.main.gameSpeed,this.yPos+=this.yVelocity*this.main.gameSpeed,this.updatePositions();for(var _i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];if(SAT.testPolygonPolygon(block.totalBoundPolygon,this.deathBoxPolygon)){for(var i=0;i<10;i++)this.main.createColorParticle(this.xPos,this.yPos,16*Math.random()-8,16*Math.random()-8,16711680);this.die()}}SAT.testPolygonPolygon(this.deathBoxPolygon,this.main.player.totalPolygon)&&(this.main.player.kill(14),this.die())}},Bullet.prototype.updatePositions=function(){this.sprite.position.set(this.xPos,this.yPos),this.deathBoxPolygon.pos.x=this.xPos,this.deathBoxPolygon.pos.y=this.yPos},Bullet.prototype.die=function(){this.alive=!1,this.sprite.visible=!1},Bullet.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.deathBoxPolygon=null,this.graphics.destroy(),this.graphics=null},Bullet.prototype.resetLevel=function(){this.die()},Bullet}(Obstacle),ClassicLaser=function(_super){function ClassicLaser(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"classicLaser"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.bullet=new Bullet(main,game,main.obstacleLayer),_this.main.obstacles.push(_this.bullet),_this.alive=!1,_this}return __extends(ClassicLaser,_super),ClassicLaser.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.rad=Math.PI/2,this.sprite.position.set(x,y),this.sprite.rotation=this.rad,this.spinDest=Math.PI/2,this.shootTimer=0},ClassicLaser.prototype.levelStart=function(){this.storeNearbyPlatforms()},ClassicLaser.prototype.storeNearbyPlatforms=function(){this.platforms=[];for(var searchRad=new SAT.Circle(new SAT.Vector(this.xPos,this.yPos),250),_i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];SAT.testCirclePolygon(searchRad,block.totalBoundPolygon)&&this.platforms.push(block)}},ClassicLaser.prototype.update=function(){var player=this.main.player;if(player&&player.alive){var inSight=!0;if(Math.pow(this.xPos-player.xPos,2)+Math.pow(this.yPos-player.yPos,2)<=ClassicLaser.RANGE_SQ){for(var testLine=new SAT.Polygon(new Vector(0,0),[new SAT.Vector(this.xPos,this.yPos),new SAT.Vector(player.xPos,player.yPos)]),testLine2=new SAT.Polygon(new Vector(0,0),[new SAT.Vector(this.xPos,this.yPos),new SAT.Vector(player.xPos,player.yPos-player.height)]),_i=0,_a=this.platforms;_i<_a.length;_i++){var block=_a[_i];if(SAT.testPolygonPolygon(testLine,block.totalBoundPolygon)&&SAT.testPolygonPolygon(testLine2,block.totalBoundPolygon)){inSight=!1;break}}inSight&&(this.spinDest=Math.atan2(player.yPos-this.yPos,player.xPos-this.xPos),this.shootTimer++,this.shootTimer>=ClassicLaser.FIRE_RATE&&(this.shootTimer=0,this.bullet.spawn(this.xPos,this.yPos,25*Math.cos(this.rad),25*Math.sin(this.rad),this.rad),this.main.sounds.playSound("laserFire")))}else this.spinDest=Math.PI/2;var distRotation=this.rad-this.spinDest;Math.abs(distRotation)<.5*Math.PI/180?this.rad=this.spinDest:distRotation>200*Math.PI/180?this.rad=this.spinDest:this.rad-=.25*distRotation,this.sprite.rotation=this.rad}},ClassicLaser.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,_super.prototype.destroy.call(this)},ClassicLaser.prototype.reset=function(){this.shootTimer=0},ClassicLaser.prototype.resetLevel=function(){this.reset(),this.rad=Math.PI/2,this.spinDest=Math.PI/2},ClassicLaser.FIRE_RATE=40,ClassicLaser.RANGE_SQ=62500,ClassicLaser}(Obstacle),Quadrant=function(_super){function Quadrant(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"quadrant"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.obstacleType="quadrant",_this.deathHitBoxPolygons=[],_this}return __extends(Quadrant,_super),Quadrant.prototype.spawn=function(x,y,rotation,rotSpeed,scale){var hit;void 0===scale&&(scale=1),this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.rad=rotation*Math.PI/180,this.startRad=this.rad,this.rotSpeed=rotSpeed,this.sprite.position.set(x,y),this.sprite.visible=!0,this.sprite.scale.set(scale,scale),this.alive=!0,this.attachHitBoxPolygon=new SAT.Box(new SAT.Vector(x,y),10,10).toPolygon(),this.attachHitBoxPolygon.setOffset(new SAT.Vector(-5,-5)),(hit=new SAT.Box(new SAT.Vector(0,0),10*scale,10*scale).toPolygon()).setOffset(new SAT.Vector(75*scale,0)),this.deathHitBoxPolygons.push(hit),(hit=new SAT.Box(new SAT.Vector(0,0),10*scale,10*scale).toPolygon()).setOffset(new SAT.Vector(0,75*scale)),this.deathHitBoxPolygons.push(hit),(hit=new SAT.Box(new SAT.Vector(0,0),10*scale,10*scale).toPolygon()).setOffset(new SAT.Vector(-75*scale,0)),this.deathHitBoxPolygons.push(hit),(hit=new SAT.Box(new SAT.Vector(0,0),10*scale,10*scale).toPolygon()).setOffset(new SAT.Vector(0,-75*scale)),this.deathHitBoxPolygons.push(hit)},Quadrant.prototype.update=function(){this.rad+=this.rotSpeed,this.updatePosition()},Quadrant.prototype.updatePosition=function(){this.sprite.position.set(this.xPos,this.yPos),this.sprite.rotation=this.rad;for(var _i=0,_a=this.deathHitBoxPolygons;_i<_a.length;_i++){var hitbox=_a[_i];hitbox.pos.x=this.xPos,hitbox.pos.y=this.yPos,hitbox.setAngle(this.rad)}},Quadrant.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.deathHitBoxPolygons=null,_super.prototype.destroy.call(this)},Quadrant.prototype.resetLevel=function(){this.rad=this.startRad,this.updatePosition()},Quadrant}(Obstacle),LaserPoint=function(_super){function LaserPoint(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.laserGraphic=game.add.graphics(0,0,layer),_this.obstacleType="laser",_this}return __extends(LaserPoint,_super),LaserPoint.prototype.spawn=function(startX,startY,endX,endY){this.xPos=startX,this.yPos=startY,this.xLength=endX-startX,this.yLength=endY-startY,this.alive=!0,this.deathHitBoxPolygon=new SAT.Polygon(new SAT.Vector(this.xPos,this.yPos),[new SAT.Vector(0,0),new SAT.Vector(endX-startX,endY-startY)]),this.laserGraphic.position.set(this.xPos,this.yPos),this.laserGraphic.lineStyle(2,16724787),this.laserGraphic.moveTo(0,0),this.laserGraphic.lineTo(endX-startX,endY-startY)},LaserPoint.prototype.update=function(){if(Math.random()<.05){var dist=Math.random(),xx=this.xPos+this.xLength*dist,yy=this.yPos+this.yLength*dist;this.main.createColorParticle(xx,yy,10*Math.random()-5,-5*Math.random(),16711680,4,!1,!1,10,!0)}},LaserPoint.prototype.destroy=function(){this.game=null,this.layer=null,this.laserGraphic.destroy(),this.laserGraphic=null,_super.prototype.destroy.call(this)},LaserPoint}(Obstacle),Reaper=function(_super){function Reaper(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.sprite=layer.create(0,0,"reaper"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.obstacleType="reaper",_this.killValue=2,_this.deathHitBoxes=[],_this}return __extends(Reaper,_super),Reaper.prototype.spawn=function(x,y,rotation,scale){void 0===scale&&(scale=1),this.xPos=x,this.yPos=y,this.startX=x,this.startY=y,this.rad=rotation*Math.PI/180,this.startRad=this.rad,this.sprite.position.set(x,y),this.sprite.scale.set(scale/2,scale/2),this.sprite.visible=!0,this.alive=!0;var hit=new SAT.Box(new SAT.Vector(x,y),13.4*scale,8.6*scale).toPolygon();hit.setOffset(new SAT.Vector(-13.4*scale,-75*scale)),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),6.35*scale,6.3*scale).toPolygon()).setOffset(new SAT.Vector(-42*scale,-65*scale)),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),2.9*scale,2.9*scale).toPolygon()).setOffset(new SAT.Vector(-59*scale,-46*scale)),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),1.5*scale,1.5*scale).toPolygon()).setOffset(new SAT.Vector(-66*scale,-26*scale)),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),13.4*scale,8.6*scale).toPolygon()).setOffset(new SAT.Vector(-13.4*scale,-75*scale)),hit.setAngle(Math.PI),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),6.35*scale,6.3*scale).toPolygon()).setOffset(new SAT.Vector(-42*scale,-65*scale)),hit.setAngle(Math.PI),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),2.9*scale,2.9*scale).toPolygon()).setOffset(new SAT.Vector(-59*scale,-46*scale)),hit.setAngle(Math.PI),this.deathHitBoxes.push(hit),(hit=new SAT.Box(new SAT.Vector(x,y),1.5*scale,1.5*scale).toPolygon()).setOffset(new SAT.Vector(-66*scale,-26*scale)),hit.setAngle(Math.PI),this.deathHitBoxes.push(hit)},Reaper.prototype.update=function(){this.rad+=-5*Math.PI/180,this.updatePositions()},Reaper.prototype.updatePositions=function(){this.sprite.position.set(this.xPos,this.yPos),this.sprite.rotation=this.rad;for(var i=0;i<this.deathHitBoxes.length;i++){var hitbox=this.deathHitBoxes[i];i<4?hitbox.setAngle(this.rad):hitbox.setAngle(this.rad+Math.PI)}},Reaper.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.deathHitBoxes=null,_super.prototype.destroy.call(this)},Reaper.prototype.resetLevel=function(){this.rad=this.startRad},Reaper}(Obstacle),Spark=function(_super){function Spark(main,game,layer,sparkBlock){var _this=_super.call(this,main,game,layer)||this;return _this.sparkBlock=sparkBlock,_this.obstacleType="spark",_this.sprite=_this.layer.create(0,0,"spark"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.visible=!1,_this.deathBoxPolygon=new SAT.Box(new SAT.Vector(0,0),16,16).toPolygon(),_this.deathBoxPolygon.setOffset(new SAT.Vector(-8,-8)),_this}return __extends(Spark,_super),Spark.prototype.spawn=function(x,y){this.sparkBlock&&(x=this.sparkBlock.leftEdge,y=this.sparkBlock.topEdge,this.direction="right"),this.xPos=x,this.yPos=y,this.alive=!0,this.sprite.visible=!0,this.updatePositions()},Spark.prototype.update=function(){if(this.sparkBlock)switch(this.direction){case"right":this.xPos+=5*this.main.gameSpeed,this.xPos>this.sparkBlock.rightEdge&&(this.xPos=this.sparkBlock.rightEdge,this.direction="down");break;case"down":this.yPos+=5*this.main.gameSpeed,this.yPos>this.sparkBlock.bottomEdge&&(this.yPos=this.sparkBlock.bottomEdge,this.direction="left");break;case"left":this.xPos-=5*this.main.gameSpeed,this.xPos<this.sparkBlock.leftEdge&&(this.xPos=this.sparkBlock.leftEdge,this.direction="up");break;case"up":this.yPos-=5*this.main.gameSpeed,this.yPos<this.sparkBlock.topEdge&&(this.yPos=this.sparkBlock.topEdge,this.direction="right")}Math.random()<.2&&this.main.createColorParticle(this.xPos,this.yPos,10*Math.random()-5,5*Math.random(),16763904,4,!1,!1,10,!0),this.updatePositions();for(var _i=0,_a=this.main.pools;_i<_a.length;_i++){var pool=_a[_i];SAT.testPolygonPolygon(this.deathBoxPolygon,pool.totalPolygon)&&(pool.electric=!0)}},Spark.prototype.updatePositions=function(){this.sprite.position.set(this.xPos,this.yPos),this.deathBoxPolygon.pos.x=this.xPos,this.deathBoxPolygon.pos.y=this.yPos},Spark.prototype.resetLevel=function(){if(this.sparkBlock){var x=this.sparkBlock.leftEdge,y=this.sparkBlock.topEdge;this.direction="right",this.xPos=x,this.yPos=y}this.updatePositions()},Spark.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.deathBoxPolygon=null},Spark}(Obstacle),ShurikanDispenser=function(_super){function ShurikanDispenser(main,game,layer){var _this=_super.call(this,main,game,layer)||this;_this.sprite=layer.create(0,0,"shurikanDispenser"),_this.sprite.autoCull=!0,_this.sprite.anchor.set(.5,.5),_this.sprite.animations.add("spawn"),_this.sprite.visible=!1,_this.obstacleType="shurikan",_this.alive=!1,_this.hitBoxPoly=new SAT.Box(new Vector(0,0),20,20).toPolygon(),_this.hitBoxPoly.setOffset(new SAT.Vector(-10,-10)),_this.spikes=[];for(var i=0;i<4;i++){var spike=new FallingSpike(main,game,_this.layer,!0);_this.spikes[i]=spike,_this.main.obstacles.push(spike)}return _this}return __extends(ShurikanDispenser,_super),ShurikanDispenser.prototype.spawn=function(x,y){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.scale.set(1,1),this.sprite.visible=!0,this.alive=!0,this.charge=ShurikanDispenser.CHARGE_TIME;for(var i=0;i<4;i++){this.spikes[i].spawn(x,y,90*i)}},ShurikanDispenser.prototype.levelStart=function(){this.storeNearbyPlatforms()},ShurikanDispenser.prototype.storeNearbyPlatforms=function(){this.platforms=[];for(var searchRad=new SAT.Circle(new SAT.Vector(this.xPos,this.yPos),250),_i=0,_a=this.main.blocks;_i<_a.length;_i++){var block=_a[_i];SAT.testCirclePolygon(searchRad,block.totalBoundPolygon)&&this.platforms.push(block)}},ShurikanDispenser.prototype.fireSpikes=function(){for(var i=0;i<4;i++){this.spikes[i].dispenserFire()}this.sprite.animations.stop("spawn",!0),this.sprite.animations.play("spawn",null,!1)},ShurikanDispenser.prototype.update=function(){var player=this.main.player,inSight=!0;if(player&&player.alive){var testLine=new SAT.Polygon(new Vector(0,0),[new SAT.Vector(this.xPos,this.yPos),new SAT.Vector(player.xPos,player.yPos-15)]);if(Math.pow(this.xPos-player.xPos-15,2)+Math.pow(this.yPos-player.yPos,2)<=62500){for(var _i=0,_a=this.platforms;_i<_a.length;_i++){var block=_a[_i];if(SAT.testPolygonPolygon(testLine,block.totalBoundPolygon)){inSight=!1;break}}inSight&&this.charge>=ShurikanDispenser.CHARGE_TIME&&(this.fireSpikes(),this.charge=0,this.rad=0)}}this.charge<ShurikanDispenser.CHARGE_TIME&&(this.charge+=this.main.gameSpeed,this.rad+=Math.PI/ShurikanDispenser.CHARGE_TIME),this.sprite.rotation=this.rad},ShurikanDispenser.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null},ShurikanDispenser.prototype.resetLevel=function(){this.charge=0},ShurikanDispenser.CHARGE_TIME=35,ShurikanDispenser}(Obstacle),TextFade=function(){function TextFade(main,game,layer,spriteKey){this.appearDistSq=22500,this.disappearDistSq=28900,this.reappearTime=30,this.main=main,this.game=game,this.sprite=layer.create(0,0,spriteKey),this.sprite.autoCull=!0,this.sprite.anchor.set(.5,.5)}return TextFade.prototype.spawn=function(x,y,rotation){"textFade29"==this.sprite.key?y-=8:"textFade13"===this.sprite.key&&(this.game.device.desktop||this.sprite.loadTexture("textFade13Mobile")),this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.sprite.rotation=rotation*Math.PI/180,this.sprite.scale.x=.5,this.sprite.scale.y=.5,this.sprite.alpha=0,this.reappear=0},TextFade.prototype.update=function(){var distSq=Math.pow(this.main.player.xPos-this.xPos,2)+Math.pow(this.main.player.yPos-this.yPos,2);distSq<this.appearDistSq?(this.sprite.alpha-=.25*(this.sprite.alpha-1),this.sprite.scale.x-=.25*(this.sprite.scale.x-1),this.sprite.scale.y=this.sprite.scale.x,this.reappear=0):distSq>this.disappearDistSq&&(this.reappear>=this.reappearTime?(this.sprite.alpha-=.25*this.sprite.alpha,this.sprite.scale.x-=.25*this.sprite.scale.x,this.sprite.scale.y=this.sprite.scale.x):this.reappear++)},TextFade.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.main=null},TextFade}(),DeathText=function(){function DeathText(game,layer){this.text=game.add.bitmapText(0,0,"grobred32","",18),this.text.visible=!1,this.text.anchor.set(.5,.5),layer.add(this.text),this.alive=!1}return DeathText.prototype.show=function(x,y,text){this.xPos=x,this.yPos=y,this.text.position.set(x,y),this.text.setText(text),this.text.visible=!0,this.text.scale.set(.75,.75),this.tarY=y+30,this.alive=!0},DeathText.prototype.update=function(){this.alive&&(this.text.scale.x<1.3?(this.text.scale.x-=.05*(this.text.scale.x-1.3),this.text.scale.y=this.text.scale.x,1.3-this.text.scale.x<.01&&this.text.scale.set(1.3,1.3)):(this.text.alpha-=.15*this.text.alpha,this.text.alpha&&(this.alive=!1,this.text.visible=!1)),this.yPos--,this.text.position.y=this.yPos)},DeathText}(),ColorParticle=function(_super){function ColorParticle(main,game,layer,color,size,collide,isLiquid,fadeTime,scaleOut){var _this=_super.call(this,main,game,layer,size,collide,isLiquid,fadeTime)||this;return _this.scaleOut=scaleOut,_this.size=size,_this.graphics=game.add.graphics(0,0,layer),_this.graphics.beginFill(color),_this.graphics.drawRect(-size/2,-size/2,size,size),_this.graphics.endFill(),_this.fadeAfter=fadeTime,_this}return __extends(ColorParticle,_super),ColorParticle.prototype.spawn=function(x,y,xVelocity,yVelocity){_super.prototype.spawnBase.call(this,x,y,xVelocity,yVelocity),this.graphics.position.set(x,y),this.fadeTime=0},ColorParticle.prototype.destroy=function(){this.alive&&(this.graphics.destroy(),this.graphics=null,this.alive=!1,_super.prototype.destroy.call(this))},ColorParticle.prototype.multAlpha=function(mult){this.graphics.alpha*=mult},ColorParticle.prototype.update=function(){if(this.alive){if(this.fadeTime>=this.fadeAfter){if(this.graphics.alpha-=.1*this.main.gameSpeed,this.scaleOut&&(this.graphics.scale.x*=.8,this.graphics.scale.y=this.graphics.scale.x),this.graphics.alpha<=0)return void this.destroy()}else this.fadeTime++;var prevX=this.xPos,prevY=this.yPos;_super.prototype.update.call(this),this.alive&&(prevX==this.xPos&&prevY==this.yPos||(this.graphics.position.set(this.xPos,this.yPos),this.hitBoxPolygon.pos.x=this.xPos-.5*this.size,this.hitBoxPolygon.pos.y=this.yPos-.5*this.size))}},ColorParticle}(Particle),hubArrows=[];hubArrows[0]=[{type:"textFade",textNum:"13",x:585.375,y:1997.175,rotation:0},{type:"textFade",textNum:"1",x:584.8,y:1869.4,rotation:0},{type:"textFade",textNum:"4",x:733.6500000000001,y:1897.125,rotation:0},{type:"textFade",textNum:"5",x:924.55,y:1753.525,rotation:-90},{type:"textFade",textNum:"5",x:779.625,y:1549.2,rotation:164.99945068359375},{type:"textFade",textNum:"6",x:740.075,y:1639.475,rotation:0},{type:"textFade",textNum:"7",x:907.7750000000001,y:1887.825,rotation:0},{type:"textFade",textNum:"5",x:1326.525,y:1574.6,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1904.1,y:1796.625,rotation:90.00175476074219},{type:"textFade",textNum:"29",x:2048.15,y:1972,rotation:0},{type:"textFade",textNum:"5",x:1743.725,y:1532.975,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:2155.075,y:1304.55,rotation:180},{type:"textFade",textNum:"5",x:1391.1750000000002,y:1161.85,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.9,y:1132.9250000000002,rotation:-89.9947509765625},{type:"textFade",textNum:"30",x:1043.8,y:1270.025,rotation:0},{type:"textFade",textNum:"33",x:670.325,y:918.85,rotation:0},{type:"textFade",textNum:"4",x:2219.2,y:1120.6750000000002,rotation:0},{type:"textFade",textNum:"5",x:642.1,y:582.775,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:862.875,y:647.825,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1701.65,y:616.725,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1904.1,y:735.325,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2381.525,y:804.2,rotation:0},{type:"textFade",textNum:"5",x:2180.675,y:827,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3375.95,y:1018.4250000000001,rotation:89.99824523925781}],hubArrows[1]=[{type:"textFade",textNum:"43",x:584.25,y:1871.175,rotation:0},{type:"textFade",textNum:"5",x:924.1,y:1754.5749999999998,rotation:-90},{type:"textFade",textNum:"5",x:1117.1,y:1513.6750000000002,rotation:90},{type:"textFade",textNum:"44",x:739.3499999999999,y:1641.275,rotation:0},{type:"textFade",textNum:"19",x:1102.625,y:1646.975,rotation:0},{type:"textFade",textNum:"5",x:1903.65,y:1797.6750000000002,rotation:90.00175476074219},{type:"textFade",textNum:"29",x:2047.7,y:1973.05,rotation:0},{type:"textFade",textNum:"5",x:1743.275,y:1534.025,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:2154.625,y:1305.6,rotation:180},{type:"textFade",textNum:"5",x:1390.725,y:1162.9,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.45,y:1133.975,rotation:-89.9947509765625},{type:"textFade",textNum:"30",x:1043.35,y:1271.0749999999998,rotation:0},{type:"textFade",textNum:"33",x:669.875,y:919.9,rotation:0},{type:"textFade",textNum:"4",x:2218.75,y:1121.725,rotation:0},{type:"textFade",textNum:"5",x:641.65,y:583.825,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:862.425,y:648.875,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1701.2,y:617.775,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1903.65,y:736.375,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2381.075,y:805.25,rotation:0},{type:"textFade",textNum:"5",x:2180.225,y:828.05,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3375.5,y:1019.475,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:717.475,y:1895.875,rotation:-44.99955749511719},{type:"textFade",textNum:"5",x:704.775,y:1525.7,rotation:0}],hubArrows[2]=[{type:"textFade",textNum:"43",x:584.25,y:1871.475,rotation:0},{type:"textFade",textNum:"5",x:1104.1,y:2015.525,rotation:-90},{type:"textFade",textNum:"5",x:1326.075,y:1575.95,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1903.65,y:1797.975,rotation:90.00175476074219},{type:"textFade",textNum:"29",x:2047.7,y:1973.35,rotation:0},{type:"textFade",textNum:"5",x:2154.625,y:1305.9,rotation:180},{type:"textFade",textNum:"5",x:1390.725,y:1163.2,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.45,y:1134.275,rotation:-89.9947509765625},{type:"textFade",textNum:"30",x:1043.35,y:1271.375,rotation:0},{type:"textFade",textNum:"33",x:669.875,y:920.2,rotation:0},{type:"textFade",textNum:"4",x:2218.75,y:1122.025,rotation:0},{type:"textFade",textNum:"5",x:641.65,y:584.125,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:862.425,y:649.175,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1701.2,y:618.075,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1903.65,y:736.675,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2381.075,y:805.55,rotation:0},{type:"textFade",textNum:"5",x:2180.225,y:828.35,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3375.5,y:1019.775,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:730.775,y:1885.1750000000002,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:923.75,y:1767.1750000000002,rotation:-90},{type:"textFade",textNum:"5",x:738.175,y:1563,rotation:0},{type:"textFade",textNum:"5",x:1553.875,y:1908.2,rotation:180}],hubArrows[3]=[{type:"textFade",textNum:"43",x:584.1500000000001,y:1870.475,rotation:0},{type:"textFade",textNum:"5",x:1104,y:2014.525,rotation:-90},{type:"textFade",textNum:"5",x:1325.975,y:1574.95,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1903.575,y:1857.9250000000002,rotation:-60.0001220703125},{type:"textFade",textNum:"29",x:2047.6000000000001,y:1972.35,rotation:0},{type:"textFade",textNum:"5",x:2154.525,y:1304.9,rotation:180},{type:"textFade",textNum:"5",x:1390.625,y:1162.2,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.35,y:1133.275,rotation:-89.9947509765625},{type:"textFade",textNum:"30",x:1043.25,y:1270.375,rotation:0},{type:"textFade",textNum:"33",x:669.775,y:919.2,rotation:0},{type:"textFade",textNum:"4",x:2218.6499999999996,y:1121.025,rotation:0},{type:"textFade",textNum:"5",x:641.55,y:583.125,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:862.325,y:648.175,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1701.1,y:617.075,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1903.55,y:735.675,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2380.975,y:804.55,rotation:0},{type:"textFade",textNum:"5",x:2180.125,y:827.35,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3375.4,y:1018.775,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:730.675,y:1884.1750000000002,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:923.65,y:1766.1750000000002,rotation:-90},{type:"textFade",textNum:"5",x:738.075,y:1562,rotation:0},{type:"textFade",textNum:"5",x:1553.8249999999998,y:1907.2,rotation:0},{type:"textFade",textNum:"5",x:2201.5,y:1841.9250000000002,rotation:90.00175476074219}],hubArrows[4]=[{type:"textFade",textNum:"43",x:584.25,y:1872.425,rotation:0},{type:"textFade",textNum:"5",x:1104.1,y:2016.475,rotation:-90},{type:"textFade",textNum:"5",x:1326.075,y:1576.9,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1859.625,y:1767.8249999999998,rotation:-134.99737548828125},{type:"textFade",textNum:"5",x:1743.275,y:1535.275,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:2154.625,y:1306.85,rotation:180},{type:"textFade",textNum:"5",x:735.45,y:1135.225,rotation:-89.9947509765625},{type:"textFade",textNum:"30",x:1043.35,y:1272.3249999999998,rotation:0},{type:"textFade",textNum:"33",x:669.875,y:921.15,rotation:0},{type:"textFade",textNum:"4",x:2218.75,y:1122.975,rotation:0},{type:"textFade",textNum:"5",x:641.65,y:585.075,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:862.425,y:650.125,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1701.2,y:619.025,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1903.65,y:737.625,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2381.075,y:806.5,rotation:0},{type:"textFade",textNum:"5",x:2180.225,y:829.3,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3375.5,y:1020.725,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:730.775,y:1886.125,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:923.75,y:1768.125,rotation:-90},{type:"textFade",textNum:"5",x:738.175,y:1563.95,rotation:0},{type:"textFade",textNum:"5",x:1553.9250000000002,y:1909.15,rotation:0},{type:"textFade",textNum:"5",x:2201.6,y:1859.8249999999998,rotation:-89.99824523925781},{type:"textFade",textNum:"5",x:2072.125,y:2307.25,rotation:.0008697509765625}],hubArrows[5]=[{type:"textFade",textNum:"43",x:584.2,y:1873.525,rotation:0},{type:"textFade",textNum:"5",x:1104.05,y:2017.575,rotation:-90},{type:"textFade",textNum:"5",x:1326.025,y:1578,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1854.5749999999998,y:1763.275,rotation:-134.9982452392578},{type:"textFade",textNum:"5",x:1743.225,y:1536.375,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:2154.575,y:1307.95,rotation:180},{type:"textFade",textNum:"5",x:1390.6750000000002,y:1165.25,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.4,y:1136.3249999999998,rotation:-89.9947509765625},{type:"textFade",textNum:"30",x:1043.3,y:1273.4250000000002,rotation:0},{type:"textFade",textNum:"4",x:2218.7,y:1124.0749999999998,rotation:0},{type:"textFade",textNum:"5",x:641.6,y:586.175,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:862.375,y:651.2249999999999,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1701.15,y:620.125,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1903.6,y:738.725,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2381.025,y:807.6,rotation:0},{type:"textFade",textNum:"5",x:2180.175,y:830.4,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3375.45,y:1021.825,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:730.725,y:1887.225,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:923.7,y:1769.225,rotation:-90},{type:"textFade",textNum:"5",x:738.125,y:1565.05,rotation:0},{type:"textFade",textNum:"5",x:1553.875,y:1910.25,rotation:0},{type:"textFade",textNum:"5",x:2201.55,y:1844.9250000000002,rotation:-89.99824523925781},{type:"textFade",textNum:"5",x:2064.075,y:2307.3,rotation:0}],hubArrows[6]=[{type:"textFade",textNum:"5",x:2155.575,y:1308.9,rotation:180},{type:"textFade",textNum:"5",x:1391.6750000000002,y:1166.2,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:736.4,y:1137.3249999999998,rotation:90.0052490234375},{type:"textFade",textNum:"30",x:1044.3,y:1274.375,rotation:0},{type:"textFade",textNum:"33",x:670.825,y:923.2,rotation:0},{type:"textFade",textNum:"4",x:2219.7,y:1125.025,rotation:0},{type:"textFade",textNum:"5",x:642.6,y:587.125,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:1702.15,y:621.075,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:1904.6,y:739.675,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2382.025,y:808.55,rotation:0},{type:"textFade",textNum:"5",x:2181.175,y:831.35,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3376.45,y:1022.775,rotation:89.99824523925781},{type:"textFade",textNum:"43",x:585.2,y:1874.475,rotation:0},{type:"textFade",textNum:"5",x:1105.05,y:2018.525,rotation:-90},{type:"textFade",textNum:"5",x:1327.025,y:1578.95,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1855.5749999999998,y:1764.225,rotation:-134.9982452392578},{type:"textFade",textNum:"5",x:1744.225,y:1537.325,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:731.725,y:1888.1750000000002,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:924.7,y:1770.1750000000002,rotation:-90},{type:"textFade",textNum:"5",x:739.125,y:1566,rotation:0},{type:"textFade",textNum:"5",x:1554.875,y:1911.2,rotation:0},{type:"textFade",textNum:"5",x:2202.55,y:1845.875,rotation:-89.99824523925781},{type:"textFade",textNum:"5",x:2065.075,y:2308.25,rotation:0},{type:"textFade",textNum:"5",x:895.75,y:1079.975,rotation:-89.9947509765625}],hubArrows[7]=[{type:"textFade",textNum:"33",x:670.975,y:918.15,rotation:0},{type:"textFade",textNum:"5",x:642.75,y:582.125,rotation:90.0052490234375},{type:"textFade",textNum:"5",x:863.525,y:647.125,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1702.3,y:616.025,rotation:90.00436401367188},{type:"textFade",textNum:"38",x:2382.175,y:803.5,rotation:0},{type:"textFade",textNum:"5",x:2181.325,y:826.3,rotation:-.0008697509765625},{type:"textFade",textNum:"5",x:3376.6,y:1017.725,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:2155.725,y:1303.85,rotation:180},{type:"textFade",textNum:"5",x:1391.8249999999998,y:1161.15,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:736.55,y:1132.275,rotation:90.0052490234375},{type:"textFade",textNum:"30",x:1044.45,y:1269.3249999999998,rotation:0},{type:"textFade",textNum:"4",x:2219.8500000000004,y:1119.975,rotation:0},{type:"textFade",textNum:"43",x:585.3499999999999,y:1869.425,rotation:0},{type:"textFade",textNum:"5",x:1105.2,y:2013.475,rotation:-90},{type:"textFade",textNum:"5",x:1327.175,y:1573.9,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1855.725,y:1759.1750000000002,rotation:-134.9982452392578},{type:"textFade",textNum:"5",x:1744.375,y:1532.275,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:731.875,y:1883.125,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:924.85,y:1765.125,rotation:-90},{type:"textFade",textNum:"5",x:739.275,y:1560.95,rotation:0},{type:"textFade",textNum:"5",x:1555.025,y:1906.15,rotation:0},{type:"textFade",textNum:"5",x:2202.7,y:1840.8249999999998,rotation:-89.99824523925781},{type:"textFade",textNum:"5",x:2065.225,y:2303.2,rotation:0},{type:"textFade",textNum:"5",x:895.9,y:1074.9250000000002,rotation:-89.9947509765625}],hubArrows[8]=[{type:"textFade",textNum:"33",x:669.675,y:919,rotation:0},{type:"textFade",textNum:"5",x:641.45,y:582.975,rotation:90.0052490234375},{type:"textFade",textNum:"5",x:862.225,y:647.9749999999999,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1370.525,y:839,rotation:.004364013671875},{type:"textFade",textNum:"5",x:3375.3,y:1018.575,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:2154.425,y:1304.7,rotation:180},{type:"textFade",textNum:"5",x:1390.525,y:1162,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.25,y:1133.125,rotation:90.0052490234375},{type:"textFade",textNum:"30",x:1043.15,y:1270.1750000000002,rotation:0},{type:"textFade",textNum:"4",x:2218.55,y:1120.8249999999998,rotation:0},{type:"textFade",textNum:"43",x:584.05,y:1870.275,rotation:0},{type:"textFade",textNum:"5",x:1103.9,y:2014.325,rotation:-90},{type:"textFade",textNum:"5",x:1325.875,y:1574.75,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1854.4250000000002,y:1760.025,rotation:-134.9982452392578},{type:"textFade",textNum:"5",x:1743.0749999999998,y:1533.125,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:730.575,y:1883.975,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:923.55,y:1765.975,rotation:-90},{type:"textFade",textNum:"5",x:737.975,y:1561.8,rotation:0},{type:"textFade",textNum:"5",x:1553.725,y:1907,rotation:0},{type:"textFade",textNum:"5",x:2201.4,y:1841.6750000000002,rotation:-89.99824523925781},{type:"textFade",textNum:"5",x:2063.925,y:2304.05,rotation:0},{type:"textFade",textNum:"5",x:894.6,y:1075.775,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:1698.075,y:664.025,rotation:-59.99620056152344}],hubArrows[9]=[{type:"textFade",textNum:"33",x:669.675,y:919,rotation:0},{type:"textFade",textNum:"5",x:641.45,y:582.975,rotation:90.0052490234375},{type:"textFade",textNum:"5",x:862.225,y:647.9749999999999,rotation:-29.995941162109375},{type:"textFade",textNum:"5",x:1370.525,y:839,rotation:.004364013671875},{type:"textFade",textNum:"5",x:3375.3,y:1018.575,rotation:89.99824523925781},{type:"textFade",textNum:"5",x:2154.425,y:1304.7,rotation:180},{type:"textFade",textNum:"5",x:1390.525,y:1162,rotation:166.93624877929688},{type:"textFade",textNum:"5",x:735.25,y:1133.125,rotation:90.0052490234375},{type:"textFade",textNum:"30",x:1043.15,y:1270.1750000000002,rotation:0},{type:"textFade",textNum:"4",x:2218.55,y:1120.8249999999998,rotation:0},{type:"textFade",textNum:"43",x:584.05,y:1870.275,rotation:0},{type:"textFade",textNum:"5",x:1103.9,y:2014.325,rotation:-90},{type:"textFade",textNum:"5",x:1325.875,y:1574.75,rotation:14.998931884765625},{type:"textFade",textNum:"5",x:1854.4250000000002,y:1760.025,rotation:-134.9982452392578},{type:"textFade",textNum:"5",x:1743.0749999999998,y:1533.125,rotation:-29.999221801757812},{type:"textFade",textNum:"5",x:730.575,y:1883.975,rotation:-45.00044250488281},{type:"textFade",textNum:"5",x:923.55,y:1765.975,rotation:-90},{type:"textFade",textNum:"5",x:737.975,y:1561.8,rotation:0},{type:"textFade",textNum:"5",x:1553.725,y:1907,rotation:0},{type:"textFade",textNum:"5",x:2201.4,y:1841.6750000000002,rotation:-89.99824523925781},{type:"textFade",textNum:"5",x:2063.925,y:2304.05,rotation:0},{type:"textFade",textNum:"5",x:894.6,y:1075.775,rotation:-89.9947509765625},{type:"textFade",textNum:"5",x:1698.075,y:664.025,rotation:-59.99620056152344},{type:"textFade",textNum:"5",x:1902.1,y:700.075,rotation:90.00436401367188},{type:"textFade",textNum:"5",x:2034.325,y:838.2,rotation:.004364013671875},{type:"textFade",textNum:"38",x:2254.475,y:802.75,rotation:0}],hubArrows[10]=hubArrows[9];var Options=function(){function Options(game){this.autoReset=!1,this.particleLimit=30,this.controllerSelect=!1,this.blend=!0,this.waves=!0,this.parallax=!0,this.musicVolume=1,this.effectVolume=.5,this.muted=!1,this.game=game;var data=SaveGame.getInstance(this.game).getAllValues();this.loadOptions(data.options)}return Options.prototype.loadOptions=function(data){this.musicVolume=data.mv,this.effectVolume=data.efxv,this.autoReset=data.ar,this.particleLimit=data.pl,this.controllerSelect=data.nc,this.blend=data.bl,this.waves=data.wv,this.parallax=data.plx,this.muted=data.mt},Options.prototype.saveOptions=function(){var save={mv:this.musicVolume,efxv:this.effectVolume,ar:this.autoReset,pl:this.particleLimit,nc:this.controllerSelect,bl:this.blend,wv:this.waves,plx:this.parallax,mt:this.muted};SaveGame.getInstance().saveOptions(save)},Options.prototype.clearSavedData=function(){SaveGame.getInstance().resetOptions();var defaultOpt=SaveGame.getInstance().getOptions();this.loadOptions(JSON.parse(defaultOpt))},Options}(),Achievement=function(spriteKey,type,name,description){this.spriteKey=spriteKey,this.type=type,this.name=name,this.description=description,this.completed=!1},Achievements=function(){function Achievements(main,game){this.game=game,this.main=main,this.achievements={},this.standardActs=[],this.hardcore=[],this.awesome=[],this.completion=[],this.standardGot=0,this.hardcoreGot=0,this.awesomeGot=0,this.completionGot=0,this.totalGot=0,this.allMax=0,this.addAchievement("act1","act1Achievement",0,"Act 1","Complete Act 1 to any ranking"),this.addAchievement("act2","act2Achievement",0,"Act 2","Complete Act 2 to any ranking"),this.addAchievement("act3","act3Achievement",0,"Act 3","Complete Act 3 to any ranking"),this.addAchievement("act4","act4Achievement",0,"Act 4","Complete Act 4 to any ranking"),this.addAchievement("act5","act5Achievement",0,"Act 5","Complete Act 5 to any ranking"),this.addAchievement("act6","act6Achievement",0,"Act 6","Complete Act 6 to any ranking"),this.addAchievement("act7","act7Achievement",0,"Act 7","Complete Act 7 to any ranking"),this.addAchievement("act8","act8Achievement",0,"Act 8","Complete Act 8 to any ranking"),this.addAchievement("act9","act9Achievement",0,"Act 9","Complete Act 9 to any ranking"),this.addAchievement("act10","act10Achievement",0,"Vexation","Complete the Vexation to any ranking"),this.addAchievement("star1","star1Achievement",1,"Mine !","Grab the hidden star on Act 1"),this.addAchievement("star2","star2Achievement",1,"Thanks Box !","Grab the hidden star on Act 2"),this.addAchievement("star3","star3Achievement",1,"It's the Climb !","Grab the hidden star on Act 3"),this.addAchievement("star4","star4Achievement",1,"Between a Saw","Grab the hidden star on Act 4"),this.addAchievement("star5","star5Achievement",1,"Leap of Faith","Grab the hidden star on Act 5"),this.addAchievement("star6","star6Achievement",1,"Keychain","Grab the hidden star on Act 6"),this.addAchievement("star7","star7Achievement",1,"Take the Plunge","Grab the hidden star on Act 7"),this.addAchievement("star8","star8Achievement",1,"Lights Out !","Grab the hidden star on Act 8"),this.addAchievement("star9","star9Achievement",1,"Outside the Box","Grab the hidden star on Act 9"),this.addAchievement("star10","star10Achievement",1,"Inside the Box","Grab the hidden star on the Vexation"),this.addAchievement("challenge1","challenge1Achievement",1,"One Step At A Time","Complete Challenge Mode for Act 1"),this.addAchievement("challenge2","challenge2Achievement",1,"Double Down","Complete Challenge Mode for Act 2"),this.addAchievement("challenge3","challenge3Achievement",1,"Third's the Charm","Complete Challenge Mode for Act 3"),this.addAchievement("challenge4","challenge4Achievement",1,"Fantastic Four","Complete Challenge Mode for Act 4"),this.addAchievement("challenge5","challenge5Achievement",1,"High Five","Complete Challenge Mode for Act 5"),this.addAchievement("challenge6","challenge6Achievement",1,"Demon","Complete Challenge Mode for Act 6"),this.addAchievement("challenge7","challenge7Achievement",1,"You're Lucky","Complete Challenge Mode for Act 7"),this.addAchievement("challenge8","challenge8Achievement",1,"Eight Times the Champ","Complete Challenge Mode for Act 8"),this.addAchievement("challenge9","challenge9Achievement",1,"Nine Lives","Complete Challenge Mode for Act 9"),this.addAchievement("perfect","awesome1Achievement",2,"Perfect !","Complete any Act with Perfect ranking"),this.addAchievement("caretaker","awesome2Achievement",2,"Caretaker","Hold 4 keys at one time"),this.addAchievement("gasping","awesome3Achievement",2,"Gasping","Surface from swimming with one bubble left"),this.addAchievement("timeflies","awesome4Achievement",2,"Time Flies V2.0","Play the game for over one hour"),this.addAchievement("headsup","awesome5Achievement",2,"Heads Up","Get crushed by a pushable block"),this.addAchievement("deathtycoon","awesome6Achievement",2,"Death Tycoon","Get over 100 total deaths"),this.addAchievement("olympian","complete1Achievement",3,"Olympian","Achieve Gold or better on every Act"),this.addAchievement("perfectionist","complete2Achievement",3,"Perfectionist","Achieve Perfect or better on every Act"),this.addAchievement("astronomer","complete3Achievement",3,"Astronomer","Collect every star in the game"),this.addAchievement("winner","complete4Achievement",3,"Winner","Complete every Act in Challenge Mode"),this.tryLoadAchievements()}return Achievements.prototype.addAchievement=function(id,spriteKey,type,name,description){var aa=new Achievement(spriteKey,type,name,description);switch(this.achievements[id]=aa,type){case 0:this.standardActs.push(aa);break;case 1:this.hardcore.push(aa);break;case 2:this.awesome.push(aa);break;case 3:this.completion.push(aa)}this.allMax++},Achievements.prototype.gotAchievement=function(key){var achievement=this.achievements[key];if(achievement&&!achievement.completed){switch(achievement.completed=!0,this.main.achievementUnlocked.show(achievement),h5branding.Utils.isOnDevice()&&SocialServicesHandler.submitAchievement(this.game,key),this.saveAchievements(),achievement.icon&&(achievement.icon.sprite.filters=null),achievement.type){case 0:this.standardGot++;break;case 1:this.hardcoreGot++;break;case 2:this.awesomeGot++;break;case 3:this.completionGot++}this.totalGot++,this.main.timerGui.updateProgress(this.getTotalProgress()),this.main.achievementsWindow.updateProgress()}},Achievements.prototype.saveAchievements=function(){var save={};for(var key in this.achievements){var achievement=this.achievements[key];save[key]=achievement.completed}SaveGame.getInstance().saveAchievements(save)},Achievements.prototype.clearSavedData=function(){for(var key in this.achievements){var achievement=this.achievements[key];achievement.completed=!1,achievement.icon.sprite.filters=[AchievementsWindow.GRAY_FILTER]}SaveGame.getInstance().resetAchievements(),this.totalGot=0,this.standardGot=0,this.awesomeGot=0,this.hardcoreGot=0,this.completionGot=0},Achievements.prototype.tryLoadAchievements=function(){var saved=SaveGame.getInstance().getAchievements();if(saved)try{var json=saved;for(var key in json){var ss=json[key],achievement=this.achievements[key];if(void 0===ss||!achievement)return;if(achievement.completed=ss)switch(this.totalGot++,achievement.type){case 0:this.standardGot++;break;case 1:this.hardcoreGot++;break;case 2:this.awesomeGot++;break;case 3:this.completionGot++}}}catch(e){return}},Achievements.prototype.getStandardActsProgress=function(){return this.standardGot/this.standardActs.length},Achievements.prototype.getHardcoreProgress=function(){return this.hardcoreGot/this.hardcore.length},Achievements.prototype.getAwesomeProgress=function(){return this.awesomeGot/this.awesome.length},Achievements.prototype.getCompletionProgress=function(){return this.main.levels?(this.hardcoreGot+this.main.levels.getGoldNumber()+this.main.levels.getPerfectNumber())/(this.hardcore.length+20):0},Achievements.prototype.getTotalProgress=function(){return this.totalGot/this.allMax},Achievements}();function timeDecorator(time){var ms=Math.floor(time/100%10),msStr=ms.toString();ms<10&&(msStr="0"+ms);var seconds=Math.floor(time/1e3%60),secondStr=seconds.toString();seconds<10&&(secondStr="0"+secondStr);var minutes=Math.floor(time/1e3/60%60),minuteStr=minutes.toString();return minutes<10&&(minuteStr="0"+minuteStr),minuteStr+":"+secondStr+":"+msStr}function timeDecoratorHub(time){Math.floor(time/100);var seconds=Math.floor(time/1e3%60),secondStr=seconds.toString();seconds<10&&(secondStr="0"+secondStr);var minutes=Math.floor(time/1e3/60%60),minuteStr=minutes.toString();minutes<10&&(minuteStr="0"+minuteStr);var hours=Math.floor(time/1e3/60/60|0),hourStr=hours.toString();return hours<10&&(hourStr="0"+hourStr),hourStr+":"+minuteStr+":"+secondStr}function timeDecoratorActBlock(time){var seconds=Math.floor(time/1e3%60),secondStr=seconds.toString();seconds<10&&(secondStr="0"+secondStr);var minutes=Math.floor(time/1e3/60%60),minuteStr=minutes.toString();return minutes<10&&(minuteStr="0"+minuteStr),minuteStr+":"+secondStr}function getDeathText(reason){var rr,text="";switch(reason){case 1:text=Math.random()<.5?"Splattered!":"Hard landing!";break;case 2:text=(rr=Math.random())<.33?"Shredded!":rr<.66?"Buzzkill!":"Sawed to bits!";break;case 3:text=(rr=Math.random())<.33?"Crushed!":rr<.66?"Squashed!":"Too compressed!";break;case 4:text=(rr=Math.random())<.33?"Lungs collapsed!":rr<.66?"Drowned!":"Sleeping with no fishes...!";break;case 5:text=(rr=Math.random())<.33?"Fell out the world!":rr<.66?"Straight to hell.!":"Fell too far!";break;case 6:text="No entry!";break;case 7:text=(rr=Math.random())<.33?"Squished.":rr<.66?"Squashed.":"Crushed.";break;case 8:text=(rr=Math.random())<.25?"Reaped.":rr<.5?"Scythed.":rr<.75?"Grim death.":"Decapitated.";break;case 9:text=(rr=Math.random())<.33?"tried shurikenjutsu!":rr<.66?"Bad ninja!":"Sliced and diced!";break;case 10:text=Math.random()<.5?"Death four-ways!":"Sliced and diced!";break;case 11:text=(rr=Math.random())<.33?"Electrocuted!":rr<.66?"Sparked out!":"Shocking.";break;case 12:text=(rr=Math.random())<.33?"Crushed!":rr<.66?"Squashed!":"Too compressed!";break;case 13:text=(rr=Math.random())<.33?"Swiped.":rr<.66?"Rushed off your feet.":"Ripped to bits";break;case 14:text=(rr=Math.random())<.33?"Obliterated!":rr<.66?"Splasered!":"Fried vexman!";break;case 15:text=Math.random()<.5?"Surprised spiked!":"Penetrated!";break;default:text=Math.random()<.5?"Spiked!":"Popped!"}return text}var GameStates,TimerGui=function(){function TimerGui(main,game,layer){this.main=main,this.game=game,this.layer=layer,this.timerContainer=game.add.group(layer),this.timerBG=this.timerContainer.create(-15,-10,"timerBG"),this.timerLabelText=game.add.bitmapText(20,5,"grob24","Time Played:",12),this.timerContainer.addChild(this.timerLabelText),this.timerText=game.add.bitmapText(15,18,"grob24","00:00:00",24),this.timerContainer.addChild(this.timerText),this.rankLabelText=game.add.bitmapText(5,60,"grob24","Progress:",12),this.timerContainer.addChild(this.rankLabelText),this.rankText=game.add.sprite(-5,70,"perfectText"),this.rankText.scale.set(.6,.6),this.rankText.visible=!1,this.timerContainer.addChild(this.rankText),this.progressText=game.add.bitmapText(35,70,"grob24","0%",20),this.timerContainer.addChild(this.progressText),this.levelNameContainer=game.add.group(layer),this.levelNameContainer.position.x=game.width,this.levelNameBG=this.levelNameContainer.create(-140,-10,"levelNameBG"),this.deathText=game.add.bitmapText(-20,35,"grobred32","0 total deaths",12),this.deathText.anchor.set(1,0),this.levelNameContainer.addChild(this.deathText),this.levelName=game.add.bitmapText(-10,5,"grob24","Level Hub",24),this.levelName.anchor.set(1,0),this.levelNameContainer.addChild(this.levelName),this.inGame=!1}return TimerGui.prototype.enterLevel=function(level){this.rankLabelText.setText("Current Rank"),this.rankType=0,this.rankText.loadTexture("perfectText"),this.rankText.visible=!0,this.timerText.setText("00:00:00"),this.levelName.setText(level.name),this.deathText.setText("0 deaths"),this.progressText.visible=!1,this.inGame=!0,this.currentLevel=level,this.main.options.blend?(this.timerBG.filters=[this.main.currentLevel.colorFilter],this.levelNameBG.filters=[this.main.currentLevel.colorFilter]):(this.timerBG.filters=null,this.levelNameBG.filters=null)},TimerGui.prototype.exitLevel=function(){this.levelName.setText("Level Hub"),this.rankLabelText.setText("Progress:"),this.rankText.visible=!1,this.inGame=!1,this.timerBG.filters=null,this.levelNameBG.filters=null,this.progressText.visible=!0},TimerGui.prototype.resetLevel=function(){this.rankType=0,this.rankText.loadTexture("perfectText")},TimerGui.prototype.hide=function(){this.timerContainer.visible=!1,this.levelNameContainer.visible=!1},TimerGui.prototype.show=function(){this.timerContainer.visible=!0,this.levelNameContainer.visible=!0},TimerGui.prototype.updateLevelTime=function(time){if(this.inGame){this.timerText.setText(timeDecorator(Date.now()-Constants.actStartTime));var seconds=Date.now()-Constants.actStartTime;switch(this.rankType){case 0:case 1:seconds>this.currentLevel.goldTime&&(this.main.sounds.playSound("downgrade"),this.rankType=2,this.rankText.loadTexture("silverText"));break;case 2:seconds>this.currentLevel.silverTime&&(this.main.sounds.playSound("downgrade"),this.rankType=3,this.rankText.loadTexture("bronzeText"));break;case 3:seconds>this.currentLevel.bronzeTime&&(this.main.sounds.playSound("downgrade"),this.rankType=4,this.rankText.loadTexture("noneText"))}}else this.timerText.setText(timeDecoratorHub(Date.now()-Constants.levelMapStartTime))},TimerGui.prototype.updateDeaths=function(deaths){this.inGame?(this.deathText.setText(deaths+" deaths"),0<deaths&&(this.main.sounds.playSound("downgrade"),0===this.rankType&&(this.rankType=1,this.rankText.loadTexture("goldText")))):this.deathText.setText(deaths+" total deaths")},TimerGui.prototype.updateProgress=function(value){this.progressText.setText(Math.floor(100*value)+"%")},TimerGui.prototype.resizeStage=function(width,height){this.levelNameContainer.position.x=width},TimerGui}(),ControllerStick=function(){function ControllerStick(game,x,y,sprite,oneStick){this.game=game,this.sprite=game.add.sprite(x,y,sprite),this.sprite.alpha=.5,this.sprite.anchor.set(.5,.5),this.sprite.scale.set(1.35,1.35),this.sprite.fixedToCamera=!0,this.sprite.inputEnabled=!0,this.sprite.events.onInputDown.add(this.onDown,this),this.sprite.events.onInputUp.add(this.onUp,this),this.pressedDown=new Phaser.Signal,this.isDown=!1,this.upDd=!1,this.downDd=!1,this.leftDd=!1,this.oneStick=oneStick}return ControllerStick.prototype.onDown=function(_,p){this.pointer=p,this.isDown=!0},ControllerStick.prototype.onUp=function(){this.isDown&&this.pressedDown.dispatch(),this.isDown=!1,this.upDd=!1,this.downDd=!1,this.leftDd=!1,this.rightDd=!1},ControllerStick.prototype.hide=function(){this.sprite.visible=!1},ControllerStick.prototype.show=function(){this.sprite.visible=!0},ControllerStick.prototype.upIsDown=function(){return this.upDd},ControllerStick.prototype.downIsDown=function(){return this.downDd},ControllerStick.prototype.leftIsDown=function(){return this.leftDd},ControllerStick.prototype.rightIsDown=function(){return this.rightDd},ControllerStick.prototype.update=function(){if(this.isDown)if(this.oneStick){var center=this.sprite.x-this.game.camera.x;this.pointer.position.x<center?(this.leftDd=!0,this.rightDd=!1):(this.rightDd=!0,this.leftDd=!1)}else{var grad,screenX_1=this.sprite.position.x-this.game.camera.x,screenY_1=this.sprite.position.y-this.game.camera.y;if(Math.pow(this.pointer.position.x-screenX_1,2)+Math.pow(this.pointer.position.y-screenY_1,2)<400)return this.upDd=!1,this.downDd=!1,this.leftDd=!1,void(this.rightDd=!1);if(this.pointer.position.x<screenX_1)this.rightDd=!1,1<(grad=(this.pointer.y-screenY_1)/(this.pointer.position.x-screenX_1))?(this.upDd=!0,this.leftDd=!1,this.downDd=!1):grad<-1?(this.upDd=!1,this.leftDd=!1,this.downDd=!0):(this.upDd=!1,this.leftDd=!0,this.downDd=!1);else this.leftDd=!1,1<(grad=(this.pointer.y-screenY_1)/(this.pointer.position.x-screenX_1))?(this.upDd=!1,this.rightDd=!1,this.downDd=!0):(grad<-1?(this.upDd=!0,this.rightDd=!1):(this.upDd=!1,this.rightDd=!0),this.downDd=!1)}},ControllerStick}(),GameKey=function(){function GameKey(keys){this.keys=keys,this.buttonDown=!1,this.calls=[]}return GameKey.prototype.isDown=function(){for(var _i=0,_a=this.calls;_i<_a.length;_i++){if((0,_a[_i])())return!0}for(var _b=0,_c=this.keys;_b<_c.length;_b++){if(_c[_b].isDown)return!0}return!1},GameKey.prototype.pressed=function(){return this.isDown()&&!this.prev},GameKey.prototype.update=function(){this.isDown()?this.prev=!0:this.prev=!1},GameKey}(),BREAK_X_1=560,BREAK_X_2=360,VexGameState=function(){function VexGameState(game){}return VexGameState.prototype.init=function(){document.body.style.backgroundColor="#ffffff"},VexGameState.prototype.create=function(){var _this=this,upKey=this.game.input.keyboard.addKey(Phaser.Keyboard.UP),wKey=this.game.input.keyboard.addKey(Phaser.Keyboard.W),downKey=this.game.input.keyboard.addKey(Phaser.Keyboard.DOWN),sKey=this.game.input.keyboard.addKey(Phaser.Keyboard.S),leftKey=this.game.input.keyboard.addKey(Phaser.Keyboard.LEFT),aKey=this.game.input.keyboard.addKey(Phaser.Keyboard.A),rightKey=this.game.input.keyboard.addKey(Phaser.Keyboard.RIGHT),dKey=this.game.input.keyboard.addKey(Phaser.Keyboard.D),spaceKey=this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR),rKey=this.game.input.keyboard.addKey(Phaser.Keyboard.R),upGameKey=new GameKey([upKey,wKey]),downGameKey=new GameKey([downKey,sKey]),leftGameKey=new GameKey([leftKey,aKey]),rightGameKey=new GameKey([rightKey,dKey]),spaceGameKey=new GameKey([spaceKey]),resetGameKey=new GameKey([rKey]);this.circleMovement=new ControllerStick(this.game,150,400,"circleLrButton",!0),leftGameKey.calls.push(this.circleMovement.leftIsDown.bind(this.circleMovement)),rightGameKey.calls.push(this.circleMovement.rightIsDown.bind(this.circleMovement)),this.buttonJump=new ControllerButton(this.game,400,500,"jumpButton",!1),upGameKey.calls.push(this.buttonJump.buttonPressed.bind(this.buttonJump)),this.buttonCrouch=new ControllerButton(this.game,400,400,"crouchButton",!1),downGameKey.calls.push(this.buttonCrouch.buttonPressed.bind(this.buttonCrouch));var c3=this.circleMovement,jumpBtn=this.buttonJump,crouchBtn=this.buttonCrouch;this.circle1=new ControllerStick(this.game,150,400,"circleButton",!1),this.circle2=new ControllerStick(this.game,this.game.width-150,400,"circleButton",!1);var c1=this.circle1,c2=this.circle2;upGameKey.calls.push(this.circle1.upIsDown.bind(this.circle1)),upGameKey.calls.push(this.circle2.upIsDown.bind(this.circle2)),downGameKey.calls.push(this.circle1.downIsDown.bind(this.circle1)),downGameKey.calls.push(this.circle2.downIsDown.bind(this.circle2)),leftGameKey.calls.push(this.circle1.leftIsDown.bind(this.circle1)),leftGameKey.calls.push(this.circle2.leftIsDown.bind(this.circle2)),rightGameKey.calls.push(this.circle1.rightIsDown.bind(this.circle1)),rightGameKey.calls.push(this.circle2.rightIsDown.bind(this.circle2));var game=this.game;this.keys={up:upGameKey,down:downGameKey,left:leftGameKey,right:rightGameKey,reset:resetGameKey,space:spaceGameKey,show:function(){game.device.desktop||(Constants.oldControls?(c1.show(),c2.show()):(c3.show(),jumpBtn.show(),crouchBtn.show()))},hide:function(){c3.hide(),jumpBtn.hide(),crouchBtn.hide(),c1.hide(),c2.hide()},isScreenButtonDown:function(){return!!c3.isDown||(!!jumpBtn.isDown||(!!crouchBtn.isDown||(!!c1.isDown||!!c2.isDown)))},setAlpha:function(alpha){c3.sprite.alpha=alpha,jumpBtn.sprite.alpha=alpha,crouchBtn.sprite.alpha=alpha,c1.sprite.alpha=alpha,c2.sprite.alpha=alpha}},this.keys.hide(),this.game.stage.backgroundColor="#FFFFFF",this.game.world.setBounds(-3e3,-3e3,9e3,6e3),this.main=new Main(this.game,this.keys),this.main,this.game.scale.onSizeChange.add(function(scale,width,height){_this.game.device.desktop||(width*=1.35,height*=1.35),_this.resizeStage(scale,width,height)}),this.resizeStage(null,this.game.width,this.game.height);var hudLayer=this.game.add.group();hudLayer.add(this.circleMovement.sprite),hudLayer.add(this.buttonJump.sprite),hudLayer.add(this.buttonCrouch.sprite),hudLayer.add(this.circle1.sprite),hudLayer.add(this.circle2.sprite);var mobileDownLink=function(){_this.main.mobilePressedDown()};this.circle1.pressedDown.add(mobileDownLink),this.circle2.pressedDown.add(mobileDownLink),this.circleMovement.pressedDown.add(mobileDownLink),this.buttonJump.pressedDown.add(mobileDownLink),this.buttonCrouch.pressedDown.add(mobileDownLink)},VexGameState.prototype.resizeStage=function(scale,width,height){this.main.resizeStage(width,height),this.circleMovement.sprite.cameraOffset.x=130,this.circleMovement.sprite.scale.set(1.25),this.buttonJump.sprite.cameraOffset.x=width-130,this.buttonCrouch.sprite.cameraOffset.x=width-270,this.buttonJump.sprite.scale.set(.75),this.buttonCrouch.sprite.scale.set(.75),this.circle1.sprite.cameraOffset.x=130,this.circle2.sprite.cameraOffset.x=width-130,this.circle1.sprite.scale.set(1.25),this.circle2.sprite.scale.set(1.25),width<BREAK_X_2?(this.circle1.sprite.cameraOffset.y=height-240,this.circle2.sprite.cameraOffset.y=height-240,this.circle1.sprite.scale.set(.8,.8),this.circle2.sprite.scale.set(.8,.8),this.circle1.sprite.cameraOffset.x=70,this.circle2.sprite.cameraOffset.x=width-70):width<BREAK_X_1?(this.circleMovement.sprite.scale.set(1.15),this.circleMovement.sprite.cameraOffset.y=height-240,this.buttonJump.sprite.scale.set(.6),this.buttonCrouch.sprite.scale.set(.6),this.buttonJump.sprite.cameraOffset.x=width-70,this.buttonCrouch.sprite.cameraOffset.x=width-170,this.buttonJump.sprite.cameraOffset.y=height-280,this.buttonCrouch.sprite.cameraOffset.y=height-190,this.circle1.sprite.scale.set(1.15),this.circle2.sprite.scale.set(1.15),this.circle1.sprite.cameraOffset.y=height-240,this.circle2.sprite.cameraOffset.y=height-240):(this.circleMovement.sprite.cameraOffset.x=160,this.circleMovement.sprite.cameraOffset.y=height-180,this.buttonJump.sprite.cameraOffset.y=height-220,this.buttonCrouch.sprite.cameraOffset.y=height-150,this.circle1.sprite.cameraOffset.x=160,this.circle2.sprite.cameraOffset.x=width-160,this.circle1.sprite.cameraOffset.y=height-180,this.circle2.sprite.cameraOffset.y=height-180)},VexGameState.prototype.update=function(){for(var kk in this.main.update(),this.keys)"function"!=typeof this.keys[kk]&&this.keys[kk].update();Constants.oldControls?(this.circle1.update(),this.circle2.update()):this.circleMovement.update()},VexGameState.prototype.quitGame=function(){},VexGameState}(),RankTime=function(){function RankTime(main,game,layer){this.main=main,this.game=game,this.layer=layer,this.container=game.add.group(layer),this.container.position.set(game.width-375,game.height),this.bg=this.container.create(0,0,"rankTimeBG"),this.staticText=game.add.sprite(38,-17,"rankTimeStaticText"),this.container.addChild(this.staticText),this.levelNameText=game.add.bitmapText(15,48,"grob24","Level Hub",24),this.container.addChild(this.levelNameText),this.timeText=game.add.bitmapText(80,18,"grob24","00:00",12),this.container.addChild(this.timeText),this.goldTimeText=game.add.bitmapText(132,60,"grob24","00:00",12),this.container.addChild(this.goldTimeText),this.silverTimeText=game.add.bitmapText(217,60,"grob24","00:00",12),this.container.addChild(this.silverTimeText),this.bronzeTimeText=game.add.bitmapText(302,60,"grob24","00:00",12),this.container.addChild(this.bronzeTimeText),this.goldIcon=game.add.sprite(185,29,"completedIcon"),this.goldIcon.scale.set(.6,.6),this.goldIcon.anchor.set(.5,.5),this.container.addChild(this.goldIcon),this.starIcon=game.add.sprite(250,29,"starIcon"),this.starIcon.scale.set(.6,.6),this.starIcon.anchor.set(.5,.5),this.container.addChild(this.starIcon),this.challengeIcon=game.add.sprite(320,29,"challengeIcon"),this.challengeIcon.scale.set(.6,.6),this.challengeIcon.anchor.set(.5,.5),this.container.addChild(this.challengeIcon),this.container.visible=!1}return RankTime.prototype.show=function(level){this.showingLevel=level,this.levelNameText.setText(level.name),-1<level.topTime?this.timeText.setText(timeDecoratorActBlock(level.topTime)):this.timeText.setText(timeDecoratorActBlock(0)),this.goldTimeText.setText(timeDecoratorActBlock(level.goldTime)),this.silverTimeText.setText(timeDecoratorActBlock(level.silverTime)),this.bronzeTimeText.setText(timeDecoratorActBlock(level.bronzeTime)),level.gotGold()?(this.goldIcon.frame=1,level.challengeData&&(this.main.allowSpace=!0),this.main.keys.show()):this.goldIcon.frame=0,level.challengeCompleted?this.challengeIcon.frame=1:this.challengeIcon.frame=0,level.gotStar?this.starIcon.frame=1:this.starIcon.frame=0,this.main.options.blend?this.bg.filters=[level.colorFilter]:this.bg.filters=null,this.container.visible=!0},RankTime.prototype.hide=function(){this.main.allowSpace=!1,this.main.keys.show(),this.showingLevel=null},RankTime.prototype.invis=function(){this.container.visible=!1},RankTime.prototype.vis=function(){this.container.visible=!0},RankTime.prototype.leaveHub=function(){this.container.y=this.game.height,this.main.buttonSet.bottomButtons.position.y=this.game.height-50,this.container.visible=!1},RankTime.prototype.update=function(){if(this.showingLevel){var tarY=this.game.height-80;if(this.container.y>this.game.height-tarY){var dist=this.container.y-tarY;Math.abs(dist)<2?this.container.y=tarY:this.container.y-=dist/4,this.game.width<BREAK_X_1?this.main.buttonSet.bottomButtons.y=this.container.y-50:this.main.buttonSet.brandLogo&&(this.main.buttonSet.brandLogo.y=this.container.y+10-this.game.height)}}else{dist=this.container.y-this.game.height;Math.abs(dist)<2?(this.container.y=this.game.height,this.container.visible=!0):this.container.y-=dist/4,this.game.width<BREAK_X_1?this.main.buttonSet.bottomButtons.y=this.container.y-50:this.main.buttonSet.brandLogo&&(this.main.buttonSet.brandLogo.y=this.container.y+10-this.game.height)}},RankTime.prototype.resizeStage=function(width,height){this.container.x=width-375},RankTime}(),BottomButton=function(game,x,y,logoKey,labelText,layer,clickCall){var _this=this;this.game=game,this.container=game.add.group(layer),this.container.position.set(x,y),this.bg=this.container.create(0,0,"stageButtonBG"),this.bg.inputEnabled=!0,this.logo=this.container.create(25,25,logoKey),this.logo.anchor.set(.5,.5),this.light=game.add.graphics(0,0),this.light.visible=!1,this.light.beginFill(16777215,.2),this.light.drawRect(0,0,50,50),this.light.endFill(),this.container.addChild(this.light),this.label=this.container.create(25,-20,"stageLabelBG"),this.label.anchor.set(.5,.5),this.container.addChild(this.label),this.labelText=game.add.bitmapText(0,0,"grob24",labelText,14),this.labelText.anchor.set(.5,.5),this.label.addChild(this.labelText),this.label.visible=!1,game.device.desktop&&(this.bg.events.onInputOver.add(function(){_this.light.visible=!0,_this.label.visible=!0},this),this.bg.events.onInputOut.add(function(){_this.light.visible=!1,_this.label.visible=!1},this)),this.bg.events.onInputUp.add(clickCall,this)},ButtonSet=function(){function ButtonSet(main,game,layer){var _this=this;this.main=main,this.game=game,this.layer=layer,this.bottomButtons=game.add.group(layer,"bottomButtons"),this.bottomButtons.visible=!1,this.bottomButtons.position.set(0,game.height-50),this.logoGroup=game.add.group(layer,"logoGroup"),this.logoGroup.position.set(0,game.height-50),this.firstButton=new BottomButton(game,0,0,"quitLogo","Main Menu",this.bottomButtons,function(){_this.triggerFirst()}),this.firstButton.label.x+=15,this.secondButton=new BottomButton(game,51,0,"trophyLogo",this.getlabelText(),this.bottomButtons,function(){_this.triggerSecond()}),this.thirdButton=new BottomButton(game,102,0,"optionsLogo","Options",this.bottomButtons,function(){_this.triggerThird()}),this.fourthButton=new BottomButton(game,153,0,"actSelectLogo","Act Select",this.bottomButtons,function(){_this.triggerFourth()}),this.muteButton=new ExplandButton(game,game.width-20,30,"muteButton",this.layer,function(){},function(){},function(){Constants.muted?(Constants.muted=!1,_this.main.correctSoundValues(),_this.muteButton.sprite.frame=0):(Constants.muted=!0,_this.main.correctSoundValues(),_this.muteButton.sprite.frame=1)}),this.pauseButton=new ExplandButton(game,570,30,"pauseButton",this.layer,function(){},function(){},function(){main.pauseWindow.show(),Fabrique.PauseHandler.getInstance().sendPauseEvent(PauseType.BUTTON)}),this.pauseButton.hide()}return ButtonSet.prototype.muteTheButton=function(mute){},ButtonSet.prototype.getlabelText=function(){return h5branding.Utils.isOnDevice()?"Achievements":"Trophies"},ButtonSet.prototype.update=function(){this.pauseButton.update(),this.muteButton.update()},ButtonSet.prototype.changeLevel=function(){"hub"===this.main.currentLevelID?(this.firstButton.logo.loadTexture("quitLogo"),this.firstButton.labelText.setText("Main Menu"),this.secondButton.logo.loadTexture("trophyLogo"),this.secondButton.labelText.setText(this.getlabelText()),this.thirdButton.logo.loadTexture("optionsLogo"),this.thirdButton.labelText.setText("Options"),this.fourthButton.logo.loadTexture("actSelectLogo"),this.fourthButton.labelText.setText("Act Select"),this.bottomButtons.filters=null,this.muteButton.sprite.filters=null,this.pauseButton.sprite.filters=null,this.brandLogo&&(this.brandLogo.visible=!0)):(this.firstButton.logo.loadTexture("resetLogo"),this.firstButton.labelText.setText("Reset Act"),this.secondButton.logo.loadTexture("quitLogo"),this.secondButton.labelText.setText("Quit Act"),this.thirdButton.logo.loadTexture("trophyLogo"),this.thirdButton.labelText.setText(this.getlabelText()),this.fourthButton.logo.loadTexture("optionsLogo"),this.fourthButton.labelText.setText("Options"),Constants.blend&&(this.bottomButtons.filters=[this.main.currentLevel.colorFilter],this.muteButton.sprite.filters=[this.main.currentLevel.colorFilter],this.pauseButton.sprite.filters=[this.main.currentLevel.colorFilter],(h5branding.Utils.getBrandingDomain()===h5branding.BrandingDomain.Bild||h5branding.Branding.isContracted())&&this.brandLogo&&(this.brandLogo.visible=!1))),h5branding.Utils.isOnDevice()?(this.muteButton.sprite.position.set(this.game.width-160,20),this.pauseButton.sprite.position.set(this.game.width-200,20)):(this.muteButton.sprite.position.set(this.game.width-30,80),this.pauseButton.sprite.position.set(this.game.width-70,80)),this.pauseButton.show(),this.bottomButtons.visible=!0},ButtonSet.prototype.enterMainMenu=function(){this.muteButton.sprite.position.set(this.game.width-20,30),this.pauseButton.hide(),this.bottomButtons.visible=!1},ButtonSet.prototype.triggerFirst=function(){this.main.state!==GameStates.Window&&("hub"===this.main.currentLevelID?this.main.exitLevel():(Constants.actStartTime=Date.now(),this.main.resetLevel()))},ButtonSet.prototype.showAchievements=function(){h5branding.Utils.isOnDevice()?SocialServicesHandler.showAchievements(this.game):this.main.achievementsWindow.show()},ButtonSet.prototype.triggerSecond=function(){this.main.state!==GameStates.Window&&("hub"===this.main.currentLevelID?this.showAchievements():this.main.exitLevel())},ButtonSet.prototype.triggerThird=function(){this.main.state!==GameStates.Window&&("hub"===this.main.currentLevelID?this.main.optionsWindow.show():this.showAchievements())},ButtonSet.prototype.triggerFourth=function(){this.main.state!==GameStates.Window&&("hub"===this.main.currentLevelID?this.main.actSelectWindow.show():this.main.optionsWindow.show())},ButtonSet.prototype.resizeStage=function(width,height){this.bottomButtons.position.y=height-50,this.logoGroup.position.y=height-50,this.main.state===GameStates.MainMenu?this.muteButton.sprite.position.set(width-20,30):h5branding.Utils.isOnDevice()?(this.muteButton.sprite.position.set(this.game.width-160,20),this.pauseButton.sprite.position.set(this.game.width-200,20)):(this.muteButton.sprite.position.set(this.game.width-30,80),this.pauseButton.sprite.position.set(this.game.width-70,80)),this.brandLogo&&this.brandLogo.position.set(width-10,height-10)},ButtonSet}(),SimpleTransition=function(){function SimpleTransition(main,game,layer){this.main=main,this.game=game,this.scaleX=game.width/640,this.scaleY=game.height/560,this.topHalf=layer.create(0,0,"simpleTransition"),this.topHalf.scale.set(this.scaleX,this.scaleY),this.bottomHalf=layer.create(0,0,"simpleTransition"),this.bottomHalf.anchor.set(1,1),this.bottomHalf.scale.set(-this.scaleX,-this.scaleY),this.topHalf.fixedToCamera=!0,this.bottomHalf.fixedToCamera=!0,this.topHalf.visible=!1,this.bottomHalf.visible=!1,this.state=0}return SimpleTransition.prototype.beginTransition=function(callback,filter,isHub){this.state=1,this.isHub=isHub,this.topHalf.cameraOffset.set(0,0),this.topHalf.anchor.set(0,0),this.bottomHalf.cameraOffset.set(0,0),this.bottomHalf.anchor.set(1,1),this.topHalf.rotation=-90,this.bottomHalf.rotation=90,this.callback=callback,filter&&this.main.options.blend?(this.topHalf.filters=[filter],this.bottomHalf.filters=[filter]):(this.topHalf.filters=null,this.bottomHalf.filters=null),this.topHalf.visible=!0,this.bottomHalf.visible=!0},SimpleTransition.prototype.update=function(){if(1===this.state){var dist=this.topHalf.angle-0;this.topHalf.angle-=dist/10,Math.abs(dist)<.5&&(this.topHalf.rotation=0,this.bottomHalf.rotation=0,this.topHalf.cameraOffset.set(this.game.width,this.game.height),this.bottomHalf.cameraOffset.set(this.game.width,this.game.height),this.topHalf.anchor.set(1,1),this.bottomHalf.anchor.set(0,0),this.isHub||!this.game.device.desktop&&h5branding.Utils.isOnDevice(),this.state=2,this.callback()),this.bottomHalf.rotation=-this.topHalf.rotation}else if(2===this.state){dist=this.topHalf.angle-60;this.topHalf.angle-=dist/10,Math.abs(dist)<.5&&(this.topHalf.rotation=90,this.bottomHalf.rotation=-this.topHalf.rotation,this.state=0,this.topHalf.visible=!1,this.bottomHalf.visible=!1),this.bottomHalf.rotation=-this.topHalf.rotation}},SimpleTransition.prototype.resizeStage=function(width,height){this.scaleX=width/640,this.scaleY=height/560,this.topHalf.scale.set(this.scaleX,this.scaleY),this.bottomHalf.anchor.set(1,1),this.bottomHalf.scale.set(-this.scaleX,-this.scaleY)},SimpleTransition}(),VexWindow=function(){function VexWindow(main,game,layer){this.main=main,this.game=game,this.layer=layer,this.container=game.add.group(layer)}return VexWindow.prototype.init=function(){var _this=this;this.closeButton=this.game.add.sprite(100,-100,"closeButton"),this.closeButton.inputEnabled=!0,this.closeButton.anchor.set(.5,.5),this.closeButton.events.onInputUp.add(function(){if(_this.main.sounds.playSound("buttonClick"),"hub"===_this.main.currentLevelID||"mainmenu"===_this.main.currentLevelID){var adType=_this.main.pauseWindow.container.visible?"resume":"window_close";Fabrique.AdHandler.getInstance().showAd(adType,function(){var returnAdType="hub"===_this.main.currentLevelID?"level_select":"menu";h5branding.google.sendScreenView(returnAdType),_this.hide()})}else h5branding.google.sendScreenView("gameplay"),_this.hide()},this),this.container.position.set(this.game.width/2,-400),this.frame.anchor.set(.5,.5),this.container.addChild(this.frame),this.container.addChild(this.closeButton),this.container.visible=!1,this.showing=!1},VexWindow.prototype.show=function(){this.main.state!==GameStates.Playing&&this.main.state!==GameStates.MainMenu||(this.container.position.y=-800,this.container.visible=!0,this.showing=!0,this.main.openWindow())},VexWindow.prototype.hide=function(){this.showing=!1,this.main.closeWindow()},VexWindow.prototype.update=function(){if(this.showing){var tarY=this.game.height/2;-2<(dist=this.container.position.y-tarY)?this.container.position.y=tarY:this.container.position.y-=dist/4}else{tarY=this.game.height+800;var dist=this.container.y-tarY;this.container.position.y>this.game.height+500?(this.container.position.y=900,this.container.visible=!1):this.container.position.y-=dist/4}},VexWindow.prototype.resizeStage=function(width,height){this.container.x=width/2},VexWindow}(),ActSelectButton=function(){},ActSelectWindow=function(_super){function ActSelectWindow(main,game,layer){var _this=_super.call(this,main,game,layer)||this;_this.frame=layer.create(0,0,"actSelectSmall"),_this.frame.scale.x=(game.width-80)/330,_this.frame.scale.y=(game.height-120)/330,_this.game.device.desktop&&90<=.15*_this.game.canvas.height&&100<=.12*_this.game.canvas.width&&(_this.frame.scale.x=(game.width-150)/330,_this.frame.scale.y=(game.height-250)/330),_this.buttons=[];var rowNum=Math.floor((game.width-120)/90);_this.init();for(var _loop_1=function(i){var level=main.levels.levels[i+1],asb=new ActSelectButton,ll=game.add.sprite(120-this_1.frame.width/2+i%rowNum*90,-this_1.frame.height/2+140+100*Math.floor(i/rowNum),"act"+(i+1)+"-button");this_1.container.addChild(ll),ll.inputEnabled=!0,ll.anchor.set(.5,0),ll.scale.set(.8,.8),ll.events.onInputUp.add(function(){_this.main.portToActBlock(i+1),_this.hide()},this_1),asb.sprite=ll;var text=game.add.sprite(-4,32,level.getRankSpriteKey());text.anchor.set(.5,0),text.scale.set(.35,.35),asb.rank=text,ll.addChild(text);var trophy=game.add.sprite(-18,60,"completedIcon");trophy.anchor.set(.5,.5),trophy.scale.set(.5,.5),asb.trophy=trophy,level.gotGold()&&(trophy.frame=1),ll.addChild(trophy);var star=game.add.sprite(-2,60,"starIcon");star.anchor.set(.5,.5),star.scale.set(.5,.5),asb.star=star,ll.addChild(star),level.gotStar&&(star.frame=1);var challenge=game.add.sprite(12,60,"challengeIcon");challenge.anchor.set(.5,.5),challenge.scale.set(.5,.5),asb.saw=challenge,level.challengeCompleted&&(challenge.frame=1),ll.addChild(challenge),"10"===level.id&&(challenge.visible=!1,star.x=12),this_1.buttons.push(asb),-1===level.topTime&&(ll.visible=!1)},this_1=this,i=0;i<10;i++)_loop_1(i);return _this.resizeStage(game.width,game.height),_this}return __extends(ActSelectWindow,_super),ActSelectWindow.prototype.resetWindow=function(){for(var i=0;i<10;i++){var level=this.main.levels.levels[i+1],ll=this.buttons[i];-1!==level.topTime&&(ll.sprite.visible=!0,ll.rank.loadTexture(level.getRankSpriteKey()),level.challengeCompleted&&(ll.saw.frame=1),level.gotStar&&(ll.star.frame=1),level.gotGold()&&(ll.trophy.frame=1))}},ActSelectWindow.prototype.show=function(){_super.prototype.show.call(this)},ActSelectWindow.prototype.hide=function(){_super.prototype.hide.call(this)},ActSelectWindow.prototype.resizeStage=function(width,height){if(this.container.position.x=width/2,this.frame.scale.x=(width-60)/330,this.frame.scale.y=(height-100)/330,this.game.device.desktop&&90<=.15*this.game.canvas.height&&100<=.12*this.game.canvas.width&&(this.frame.scale.x=(width-150)/330,this.frame.scale.y=(height-250)/330),width+height<1100)for(var rowNum=Math.floor((this.frame.width-30)/70),i=0;i<10;i++){(button=this.buttons[i]).sprite.scale.set(.8,.8),button.sprite.position.x=100-this.frame.width/2+i%rowNum*70,button.sprite.position.y=-this.frame.height/2+60+70*Math.floor(i/rowNum)}else for(rowNum=Math.floor((this.frame.width-30)/100),i=0;i<10;i++){var button;(button=this.buttons[i]).sprite.scale.set(1,1),button.sprite.position.x=100-this.frame.width/2+i%rowNum*100,button.sprite.position.y=-this.frame.height/2+30+100*Math.floor(i/rowNum)}this.closeButton.position.set(150*this.frame.scale.x,-160*this.frame.scale.y)},ActSelectWindow}(VexWindow),AchievementUnlocked=function(){function AchievementUnlocked(main,game,layer){this.main=main,this.game=game,this.layer=layer,this.container=game.add.group(layer),this.container.position.set(650,80),this.frame=this.container.create(0,0,"achievementUnlocked"),this.screenX=game.width,this.container.visible=!1,this.icon=game.add.sprite(56,50,"act1Achievement"),this.icon.anchor.set(.5,.5),this.container.addChild(this.icon),this.nameText=game.add.bitmapText(86,40,"grob24","",12),this.container.addChild(this.nameText),this.showing=!1}return AchievementUnlocked.prototype.show=function(achievement){this.container.position.x=this.game.width,this.container.visible=!0,this.showing=!0,this.showTime=120,this.icon.loadTexture(achievement.spriteKey),this.nameText.setText(achievement.name),this.nameText.maxWidth=.3*this.container.width,this.main.sounds.playSound("achievementUnlocked")},AchievementUnlocked.prototype.hide=function(){this.showing=!1},AchievementUnlocked.prototype.update=function(){if(this.showing){if(this.showTime--,this.showTime<=0)return void this.hide();(dist=this.container.position.x-this.game.width+150)<5?this.container.position.x=this.game.width-150:this.container.position.x-=dist/4}else{var dist=this.container.position.x-this.game.width;this.container.position.x>this.game.width?(this.container.position.x=this.game.width,this.container.visible=!1):this.container.position.x-=dist/4}},AchievementUnlocked.prototype.resetWindow=function(){},AchievementUnlocked}(),ExplandButton=function(){function ExplandButton(game,x,y,spriteKey,parent,overCall,outCall,upCall){var _this=this;this.game=game,this.sprite=game.add.sprite(x,y,spriteKey),this.sprite.anchor.set(.5,.5),this.sprite.inputEnabled=!0,parent.addChild(this.sprite),this.sprite.events.onInputOver.add(function(){overCall(),_this.over=!0}),this.sprite.events.onInputOut.add(function(){outCall(),_this.over=!1}),this.sprite.events.onInputUp.add(function(){upCall()}),this.scale=1,this.scaleOff=1,this.over=!1}return ExplandButton.prototype.update=function(){if(this.sprite.visible&&(this.sprite.scale.set(this.scale*this.scaleOff,this.scale*this.scaleOff),this.game.device.desktop)){var dist;if(this.over){if(this.scale<1.1)-.01<(dist=this.scale-1.1)?this.scale=1.1:this.scale-=dist/6,this.sprite.scale.set(this.scale*this.scaleOff,this.scale*this.scaleOff)}else if(1<this.scale)(dist=this.scale-1)<.01?this.scale=1:this.scale-=dist/6,this.sprite.scale.set(this.scale*this.scaleOff,this.scale*this.scaleOff);this.sprite.scale.set(this.scale*this.scaleOff,this.scale*this.scaleOff)}},ExplandButton.prototype.hide=function(){this.sprite.visible=!1},ExplandButton.prototype.show=function(){this.sprite.visible=!0},ExplandButton}(),AchievementsWindow=function(_super){function AchievementsWindow(main,game,layer){var _this=_super.call(this,main,game,layer)||this;_this.offscreenX=700,_this.frame=layer.create(0,0,"actSelectSmall"),_this.frame.scale.x=(game.width-80)/330,_this.frame.scale.y=(game.height-120)/330,_this.init(),_this.closeButton.position.set(520,-50),_this.buttons=[],AchievementsWindow.GRAY_FILTER||(AchievementsWindow.GRAY_FILTER=game.add.filter("Gray"));var pp=Math.floor(100*main.achievements.getTotalProgress())+"% Total";_this.totalProgressText=game.add.bitmapText(280,10,"grob24",pp,24),_this.container.addChild(_this.totalProgressText),_this.buttonScreen=game.add.group(),_this.container.addChild(_this.buttonScreen),_this.standardActsButton=new ExplandButton(game,160,120,"standardActsButton",_this.buttonScreen,function(){_this.bottomText.setText("Standard Acts - Completing the standard acts, 1 to the Vexation")},function(){_this.bottomText.setText("")},function(){_this.main.sounds.playSound("buttonClick"),_this.showScreen(_this.standardActsScreen,"standard")}),_this.standardActsProgressBar=game.add.sprite(-48,75,"achievementProgressBar"),_this.standardActsButton.sprite.addChild(_this.standardActsProgressBar),_this.standardActsProgressBar.scale.x=Math.max(.01,main.achievements.getStandardActsProgress()),_this.standardActsProgressBar.anchor.set(0,.5),pp=Math.floor(100*main.achievements.getStandardActsProgress())+"%",_this.standardActsProgressText=game.add.bitmapText(0,75,"grob24",pp,14),_this.standardActsProgressText.anchor.set(.5,.5),_this.standardActsButton.sprite.addChild(_this.standardActsProgressText),_this.buttons.push(_this.standardActsButton),_this.challengeActsButton=new ExplandButton(game,400,135,"challengeActsButton",_this.buttonScreen,function(){_this.bottomText.setText("Hardcore - Completing the challenge acts and finding hidden stars")},function(){_this.bottomText.setText("")},function(){_this.main.sounds.playSound("buttonClick"),_this.showScreen(_this.hardcoreScreen,"hardcore")}),_this.hardcoreProgressBar=game.add.sprite(-48,65,"achievementProgressBar"),_this.challengeActsButton.sprite.addChild(_this.hardcoreProgressBar),_this.hardcoreProgressBar.scale.x=Math.max(.01,main.achievements.getHardcoreProgress()),_this.hardcoreProgressBar.anchor.set(0,.5),pp=Math.floor(100*main.achievements.getHardcoreProgress())+"%",_this.hardcoreProgressText=game.add.bitmapText(0,65,"grob24",pp,14),_this.hardcoreProgressText.anchor.set(.5,.5),_this.challengeActsButton.sprite.addChild(_this.hardcoreProgressText),_this.buttons.push(_this.challengeActsButton),_this.awesomeStuffButton=new ExplandButton(game,160,290,"awesomeStuffButton",_this.buttonScreen,function(){_this.bottomText.setText("Awesome Stuff - Performing hard and tricky feats")},function(){_this.bottomText.setText("")},function(){_this.main.sounds.playSound("buttonClick"),_this.showScreen(_this.awesomeScreen,"awesome")}),_this.buttons.push(_this.awesomeStuffButton),_this.awesomeProgressBar=game.add.sprite(-48,65,"achievementProgressBar"),_this.awesomeStuffButton.sprite.addChild(_this.awesomeProgressBar),_this.awesomeProgressBar.scale.x=Math.max(.01,main.achievements.getAwesomeProgress()),_this.awesomeProgressBar.anchor.set(0,.5),pp=Math.floor(100*main.achievements.getAwesomeProgress())+"%",_this.awesomeProgressText=game.add.bitmapText(0,65,"grob24",pp,14),_this.awesomeProgressText.anchor.set(.5,.5),_this.awesomeStuffButton.sprite.addChild(_this.awesomeProgressText),_this.completionButton=new ExplandButton(game,400,290,"completionButton",_this.buttonScreen,function(){_this.bottomText.setText("Completion - A round-up of the other categories")},function(){_this.bottomText.setText("")},function(){_this.main.sounds.playSound("buttonClick"),_this.showScreen(_this.completionScreen,"completed")}),_this.completionProgressBar=game.add.sprite(-48,55,"achievementProgressBar"),_this.completionButton.sprite.addChild(_this.completionProgressBar),_this.completionProgressBar.scale.x=Math.max(.01,main.achievements.getCompletionProgress()),_this.completionProgressBar.anchor.set(0,.5),pp=Math.floor(100*main.achievements.getCompletionProgress())+"%",_this.completionProgressText=game.add.bitmapText(0,55,"grob24",pp,14),_this.completionProgressText.anchor.set(.5,.5),_this.completionButton.sprite.addChild(_this.completionProgressText),_this.buttons.push(_this.completionButton),_this.standardActsScreen=game.add.group(),_this.standardButtons=[],_this.container.addChild(_this.standardActsScreen);for(var _loop_2=function(i){var achievement=this_2.main.achievements.standardActs[i],icon=new ExplandButton(game,80+i%8*60,120+60*Math.floor(i/8),achievement.spriteKey,this_2.standardActsScreen,function(){_this.bottomText.setText(achievement.name+" - "+achievement.description)},function(){_this.bottomText.setText("")},function(){});achievement.completed||(icon.sprite.filters=[AchievementsWindow.GRAY_FILTER]),achievement.icon=icon,this_2.standardButtons.push(icon),this_2.buttons.push(icon)},this_2=this,i=0;i<_this.main.achievements.standardActs.length;i++)_loop_2(i);_this.backButton=game.add.sprite(60,300,"backButton"),_this.backButton.visible=!1,_this.backButton.inputEnabled=!0,_this.backButton.events.onInputUp.add(function(){_this.showMainScreen()}),_this.container.addChild(_this.backButton),_this.standardActsScreen.visible=!1,_this.hardcoreScreen=game.add.group(),_this.container.addChild(_this.hardcoreScreen),_this.hardcoreButtons=[];var _loop_3=function(i){var achievement=this_3.main.achievements.hardcore[i],icon=new ExplandButton(game,80+i%8*60,120+60*Math.floor(i/8),achievement.spriteKey,this_3.hardcoreScreen,function(){_this.bottomText.setText(achievement.name+" - "+achievement.description)},function(){_this.bottomText.setText("")},function(){});icon.sprite.scale.set(.7,.7),achievement.completed||(icon.sprite.filters=[AchievementsWindow.GRAY_FILTER]),achievement.icon=icon,this_3.buttons.push(icon),this_3.hardcoreButtons.push(icon)},this_3=this;for(i=0;i<_this.main.achievements.hardcore.length;i++)_loop_3(i);_this.hardcoreScreen.visible=!1,_this.awesomeScreen=game.add.group(),_this.container.addChild(_this.awesomeScreen),_this.awesomeButtons=[];var _loop_4=function(i){var achievement=this_4.main.achievements.awesome[i],icon=new ExplandButton(game,80+i%8*60,120+60*Math.floor(i/8),achievement.spriteKey,this_4.awesomeScreen,function(){_this.bottomText.setText(achievement.name+" - "+achievement.description)},function(){_this.bottomText.setText("")},function(){});achievement.completed||(icon.sprite.filters=[AchievementsWindow.GRAY_FILTER]),achievement.icon=icon,this_4.buttons.push(icon),this_4.awesomeButtons.push(icon)},this_4=this;for(i=0;i<_this.main.achievements.awesome.length;i++)_loop_4(i);_this.awesomeScreen.visible=!1,_this.completionScreen=game.add.group(),_this.container.addChild(_this.completionScreen),_this.completionButtons=[];var _loop_5=function(i){var achievement=this_5.main.achievements.completion[i],icon=new ExplandButton(game,80+i%8*60,120+60*Math.floor(i/8),achievement.spriteKey,this_5.completionScreen,function(){_this.bottomText.setText(achievement.name+" - "+achievement.description)},function(){_this.bottomText.setText("")},function(){});achievement.completed||(icon.sprite.filters=[AchievementsWindow.GRAY_FILTER]),achievement.icon=icon,this_5.buttons.push(icon),this_5.completionButtons.push(icon)},this_5=this;for(i=0;i<_this.main.achievements.completion.length;i++)_loop_5(i);return _this.completionScreen.visible=!1,_this.bottomText=game.add.bitmapText(-100,170,"grob24","",14),_this.container.addChild(_this.bottomText),_this.showingScreen=!1,_this.currentScreen=_this.buttonScreen,_this.resizeStage(game.width,game.height),_this}return __extends(AchievementsWindow,_super),AchievementsWindow.prototype.updateProgress=function(){var pp=Math.floor(100*this.main.achievements.getTotalProgress())+"% Total Completion";this.totalProgressText.setText(pp),pp=Math.floor(100*this.main.achievements.getCompletionProgress())+"%",this.completionProgressText.setText(pp),this.completionProgressBar.scale.x=Math.max(.01,this.main.achievements.getCompletionProgress()),pp=Math.floor(100*this.main.achievements.getAwesomeProgress())+"%",this.awesomeProgressText.setText(pp),this.awesomeProgressBar.scale.x=Math.max(.01,this.main.achievements.getAwesomeProgress()),pp=Math.floor(100*this.main.achievements.getHardcoreProgress())+"%",this.hardcoreProgressText.setText(pp),this.hardcoreProgressBar.scale.x=Math.max(.01,this.main.achievements.getHardcoreProgress()),pp=Math.floor(100*this.main.achievements.getStandardActsProgress())+"%",this.standardActsProgressText.setText(pp),this.standardActsProgressBar.scale.x=Math.max(.01,this.main.achievements.getStandardActsProgress())},AchievementsWindow.prototype.showScreen=function(screen,screenName){null!=screenName&&h5branding.google.sendScreenView("achievements_"+screenName),this.currentScreen.visible=!1,screen.visible=!0,this.currentScreen=screen,this.backButton.visible=!0,this.totalProgressText.visible=!1},AchievementsWindow.prototype.showMainScreen=function(){this.showScreen(this.buttonScreen,"menu"),this.backButton.visible=!1,this.totalProgressText.visible=!0},AchievementsWindow.prototype.show=function(){_super.prototype.show.call(this)},AchievementsWindow.prototype.update=function(){_super.prototype.update.call(this);for(var _i=0,_a=this.buttons;_i<_a.length;_i++){_a[_i].update()}},AchievementsWindow.prototype.hide=function(){_super.prototype.hide.call(this)},AchievementsWindow.prototype.resizeStage=function(width,height){if(this.container.position.x=width/2,this.frame.scale.x=(width-60)/330,this.frame.scale.y=(height-60)/330,width+height<1100?(this.standardActsButton.scaleOff=.7,this.challengeActsButton.scaleOff=.7,this.awesomeStuffButton.scaleOff=.7,this.completionButton.scaleOff=.7,this.standardActsButton.sprite.scale.set(this.standardActsButton.scale*this.standardActsButton.scaleOff),this.challengeActsButton.sprite.scale.set(this.challengeActsButton.scale*this.challengeActsButton.scaleOff),this.awesomeStuffButton.sprite.scale.set(this.awesomeStuffButton.scale*this.awesomeStuffButton.scaleOff),this.completionButton.sprite.scale.set(this.completionButton.scale*this.completionButton.scaleOff),width<height?(this.standardActsButton.sprite.position.set(0,-180),this.challengeActsButton.sprite.position.set(0,-60),this.awesomeStuffButton.sprite.position.set(0,70),this.completionButton.sprite.position.set(0,180),this.bottomText.visible=!1,this.backButton.position.set(60*this.frame.scale.x,105*this.frame.scale.y)):(this.standardActsButton.sprite.position.set(-100,-55),this.challengeActsButton.sprite.position.set(100,-55),this.awesomeStuffButton.sprite.position.set(-100,55),this.completionButton.sprite.position.set(100,55),this.bottomText.visible=!0,this.backButton.position.set(80*this.frame.scale.x,105*this.frame.scale.y))):width<height?(this.standardActsButton.sprite.position.set(0,-180),this.challengeActsButton.sprite.position.set(0,-60),this.awesomeStuffButton.sprite.position.set(0,70),this.completionButton.sprite.position.set(0,180),this.bottomText.visible=!1,this.backButton.position.set(60*this.frame.scale.x,105*this.frame.scale.y)):(this.standardActsButton.sprite.position.set(-width/4+40,-height/4+40),this.challengeActsButton.sprite.position.set(width/4-40,-height/4+40),this.awesomeStuffButton.sprite.position.set(-width/4+40,height/4-40),this.completionButton.sprite.position.set(width/4-40,height/4-40),this.bottomText.visible=!0,this.backButton.position.set(80*this.frame.scale.x,105*this.frame.scale.y)),width+height<1100){for(var rowNum=Math.floor((width-120)/70),i=0;i<this.standardButtons.length;i++){(button=this.standardButtons[i]).sprite.position.x=100-width/2+i%rowNum*70,button.sprite.position.y=-height/2+80+70*Math.floor(i/rowNum),button.scaleOff=.8}var hRowNum=Math.floor((width-120)/60);for(i=0;i<this.hardcoreButtons.length;i++){(button=this.hardcoreButtons[i]).sprite.position.x=100-width/2+i%hRowNum*60,button.sprite.position.y=-height/2+80+60*Math.floor(i/hRowNum),button.scaleOff=.8}for(i=0;i<this.awesomeButtons.length;i++){(button=this.awesomeButtons[i]).sprite.position.x=100-width/2+i%rowNum*70,button.sprite.position.y=-height/2+80+70*Math.floor(i/rowNum),button.scaleOff=.8}for(i=0;i<this.completionButtons.length;i++){(button=this.completionButtons[i]).sprite.position.x=100-width/2+i%rowNum*70,button.sprite.position.y=-height/2+80+70*Math.floor(i/rowNum),button.scaleOff=.8}}else{for(rowNum=Math.floor((width-120)/100),i=0;i<this.standardButtons.length;i++){(button=this.standardButtons[i]).sprite.position.x=100-width/2+i%rowNum*100,button.sprite.position.y=-height/2+80+100*Math.floor(i/rowNum),button.scaleOff=1}for(hRowNum=Math.floor((width-120)/80),i=0;i<this.hardcoreButtons.length;i++){(button=this.hardcoreButtons[i]).sprite.position.x=100-width/2+i%hRowNum*80,button.sprite.position.y=-height/2+80+80*Math.floor(i/hRowNum),button.scaleOff=1}for(i=0;i<this.awesomeButtons.length;i++){(button=this.awesomeButtons[i]).sprite.position.x=100-width/2+i%rowNum*100,button.sprite.position.y=-height/2+80+100*Math.floor(i/rowNum),button.scaleOff=1}for(i=0;i<this.completionButtons.length;i++){var button;(button=this.completionButtons[i]).sprite.position.x=100-width/2+i%rowNum*70,button.sprite.position.y=-height/2+80+100*Math.floor(i/rowNum),button.scaleOff=1}}this.closeButton.position.set(150*this.frame.scale.x,-160*this.frame.scale.y),this.bottomText.position.set(-140*this.frame.scale.x,145*this.frame.scale.y),this.totalProgressText.position.set(-145*this.frame.scale.x,-160*this.frame.scale.y)},AchievementsWindow}(VexWindow),OptionSlider=function(){function OptionSlider(game,layer,x,y,value,labelText,stopCall){this.game=game,this.container=game.add.group(),this.container.position.set(x,y),layer.addChild(this.container),this.slider=game.add.sprite(-75,0,"slider"),this.slider.anchor.set(0,.5),this.slideDrag=game.add.sprite(150*value,0,"slideDrag"),this.slideDrag.anchor.set(.5,.5),this.slider.addChild(this.slideDrag),this.container.addChild(this.slider),this.slider.inputEnabled=!0,this.slider.events.onInputDown.add(this.setDrag,this),this.stopCall=stopCall,this.labelText=game.add.bitmapText(0,-40,"grob24",labelText,16),this.labelText.anchor.set(.5,0),this.container.addChild(this.labelText),this.xPos=x}return OptionSlider.prototype.setPos=function(x,y){this.xPos=x,this.container.position.set(x,y)},OptionSlider.prototype.setDrag=function(_,pointer){this.sliding=!0},OptionSlider.prototype.setValue=function(value){this.slideDrag.position.x=150*value,this.stopCall(value)},OptionSlider.prototype.stopDrag=function(){if(this.sliding){this.sliding=!1;var vv=Math.max(Math.min(150,this.game.input.activePointer.position.x-this.xPos+75-this.game.width/2),0);this.stopCall(vv/150)}},OptionSlider.prototype.update=function(){this.sliding&&(this.slideDrag.position.x=this.game.input.activePointer.position.x-this.xPos+75-this.game.width/2,this.slideDrag.position.x=Math.max(Math.min(150,this.slideDrag.position.x),0))},OptionSlider}(),OptionTick=function(){function OptionTick(game,layer,x,y,enabled,text,onCall,offCall){this.container=game.add.group(),layer.addChild(this.container),this.sprite=game.add.sprite(0,0,"tickButton"),this.sprite.anchor.set(.5,.5),this.container.addChild(this.sprite),this.sprite.inputEnabled=!0,this.sprite.events.onInputUp.add(this.toggle,this),this.labelText=game.add.bitmapText(10,0,"grob24",text,16),this.labelText.anchor.set(1,.5),this.labelText.align="center",this.container.addChild(this.labelText),this.enabled=enabled,this.enabled||(this.sprite.frame=1),this.onCall=onCall,this.offCall=offCall}return OptionTick.prototype.toggle=function(){this.enabled?(this.enabled=!1,this.sprite.frame=1,this.offCall()):(this.enabled=!0,this.sprite.frame=0,this.onCall())},OptionTick.prototype.setValue=function(enabled){this.enabled=enabled,this.sprite.frame=enabled?0:1},OptionTick}(),OptionsWindow=function(_super){function OptionsWindow(main,game,layer){var _this=_super.call(this,main,game,layer)||this;_this.frame=layer.create(0,0,"actSelectSmall"),_this.frame.scale.x=(game.width-80)/330,_this.frame.scale.y=(game.height-120)/330;Math.floor((game.width-120)/90);return _this.items=[],_this.init(),_this.closeButton.position.set(150,-15),_this.titleText=game.add.bitmapText(0,0,"grob24","Options",24),_this.container.addChild(_this.titleText),_this.sliders=[],_this.bgmVolumeSlider=new OptionSlider(game,_this.container,20,150,Constants.musicVolume,"Music Volume - "+Math.round(100*Constants.musicVolume),function(value){Constants.musicVolume=value,Constants.musicVolume=value,!1===Constants.muted&&(main.buttonSet.muteButton.sprite.frame=0,main.options.musicVolume=Constants.musicVolume,main.options.effectVolume=Constants.effectVolume,main.sounds.currentMusic&&(main.sounds.currentMusic.volume=Constants.musicVolume)),SaveGame.getInstance().saveOptions(),_this.bgmVolumeSlider.labelText.setText("Music Volume - "+Math.round(100*Constants.musicVolume))}),_this.sliders.push(_this.bgmVolumeSlider),_this.effectVolumeSlider=new OptionSlider(game,_this.container,20,210,Constants.effectVolume,"Effect Volume - "+Math.round(100*Constants.effectVolume),function(value){Constants.effectVolume=value,Constants.effectVolume=value,!1===Constants.muted&&(main.buttonSet.muteButton.sprite.frame=0,main.options.musicVolume=Constants.musicVolume,main.options.effectVolume=Constants.effectVolume,main.sounds.currentMusic&&(main.sounds.currentMusic.volume=Constants.musicVolume)),SaveGame.getInstance().saveOptions(),_this.effectVolumeSlider.labelText.setText("Effect Volume - "+Math.round(100*Constants.effectVolume))}),_this.sliders.push(_this.effectVolumeSlider),_this.particleLimitSlider=new OptionSlider(game,_this.container,410,155,Constants.particleLimit/100,"Particle Limit - "+Math.round(main.options.particleLimit),function(value){Constants.particleLimit=100*value,SaveGame.getInstance().saveOptions(),_this.particleLimitSlider.labelText.setText("Particle Limit - "+Math.round(Constants.particleLimit))}),_this.sliders.push(_this.particleLimitSlider),game.input.onUp.add(function(){for(var _i=0,_a=_this.sliders;_i<_a.length;_i++){_a[_i].stopDrag()}}),_this.game.device.desktop||(_this.controllerSelect=new OptionTick(game,_this.container,240,410,Constants.blend,"Old Controls",function(){Constants.oldControls=!0,SaveGame.getInstance().saveOptions()},function(){Constants.oldControls=!1,SaveGame.getInstance().saveOptions()})),_this.autoResetTick=new OptionTick(game,_this.container,120,420,Constants.autoReset,"Auto Reset When\nBest Time Passed",function(){Constants.autoReset=!0,SaveGame.getInstance().saveOptions()},function(){Constants.autoReset=!1,SaveGame.getInstance().saveOptions()}),_this.blendTick=new OptionTick(game,_this.container,450,240,Constants.blend,"Blend Mode",function(){Constants.blend=!0,SaveGame.getInstance().saveOptions()},function(){Constants.blend=!1,SaveGame.getInstance().saveOptions()}),_this.parallaxTick=new OptionTick(game,_this.container,490,320,Constants.parallax,"Background Parallax",function(){Constants.parallax=!0,SaveGame.getInstance().saveOptions()},function(){Constants.parallax=!1,SaveGame.getInstance().saveOptions()}),_this.noClear=game.add.sprite(445,470,"optionsNoClear"),_this.noClear.anchor.set(.5,.5),_this.container.addChild(_this.noClear),_this.noClear.visible=!1,_this.clearAllButton=new ExplandButton(game,0,0,"clearAllButton",_this.container,function(){},function(){},function(){_this.main.clearAllSavedData(),_this.hide()}),_this.clearAllButton.hide(),_this.resizeStage(game.width,game.height),_this}return __extends(OptionsWindow,_super),OptionsWindow.prototype.updateValues=function(){this.bgmVolumeSlider.setValue(Constants.musicVolume),this.effectVolumeSlider.setValue(Constants.effectVolume),Constants.particleLimit=Constants.particleLimit/100,this.particleLimitSlider.setValue(Constants.particleLimit),this.autoResetTick.setValue(Constants.autoReset),this.parallaxTick.setValue(Constants.parallax),this.controllerSelect&&this.controllerSelect.setValue(Constants.oldControls),this.blendTick.setValue(Constants.blend)},OptionsWindow.prototype.show=function(){h5branding.google.sendScreenView("options"),"mainmenu"===this.main.currentLevelID?this.clearAllButton.show():this.noClear.visible=!0,_super.prototype.show.call(this)},OptionsWindow.prototype.hide=function(){this.clearAllButton.hide(),this.noClear.visible=!1,_super.prototype.hide.call(this)},OptionsWindow.prototype.update=function(){_super.prototype.update.call(this);for(var _i=0,_a=this.sliders;_i<_a.length;_i++){_a[_i].update()}this.clearAllButton.update()},OptionsWindow.prototype.resizeStage=function(width,height){this.container.position.x=width/2,this.frame.scale.x=(width-60)/330,this.frame.scale.y=(height-60)/330,this.game.device.desktop&&90<=.15*this.game.canvas.height&&100<=.12*this.game.canvas.width&&(this.frame.scale.x=(width-250)/330,this.frame.scale.y=(height-250)/330),width<height?(this.bgmVolumeSlider.setPos(0,-150),this.effectVolumeSlider.setPos(0,-90),this.particleLimitSlider.setPos(0,-30),this.controllerSelect&&this.controllerSelect.container.position.set(40,40),this.blendTick.container.position.set(40,80),this.autoResetTick.container.position.set(40,120),this.parallaxTick.container.position.set(40,160),this.clearAllButton.sprite.position.set(0,240),this.noClear.position.set(0,230)):height<350?(this.bgmVolumeSlider.setPos(-100,-20),this.effectVolumeSlider.setPos(100,-60),this.particleLimitSlider.setPos(-100,35),this.controllerSelect&&this.controllerSelect.container.position.set(-100,40),this.blendTick.container.position.set(-100,70),this.autoResetTick.container.position.set(140,-10),this.parallaxTick.container.position.set(140,20),this.clearAllButton.sprite.position.set(110,70),this.noClear.position.set(110,130)):(this.bgmVolumeSlider.setPos(-width/4+40,10),this.effectVolumeSlider.setPos(-width/4+40,-60),this.particleLimitSlider.setPos(-width/4+40,80),this.controllerSelect&&this.controllerSelect.container.position.set(width/4,-60),this.blendTick.container.position.set(width/4,-20),this.autoResetTick.container.position.set(width/4,20),this.parallaxTick.container.position.set(width/4,60),this.clearAllButton.sprite.position.set(width/4,120),this.noClear.position.set(width/4,120)),this.titleText.position.set(-140*this.frame.scale.x,-150*this.frame.scale.y),this.closeButton.position.set(150*this.frame.scale.x,-160*this.frame.scale.y)},OptionsWindow}(VexWindow),PauseWindow=function(_super){function PauseWindow(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.frame=game.add.sprite(0,0,"pauseWindow"),_this.game=game,_this.showY=170,_this.init(),h5branding.Branding.isAirfi()||(_this.brandLogo=_this.game.make.button(0,-_this.game.height/2+20,"branding_logo"),_this.container.addChild(_this.brandLogo),_this.brandLogo.inputEnabled=h5branding.Branding.outGoingLinksAllowed(),_this.brandLogo.input.useHandCursor=!0,_this.brandLogo.anchor.set(.5,.5),_this.brandLogo.scale.set(.8,.8),_this.brandLogo.position.set(150*_this.frame.scale.x-150,-160*_this.frame.scale.y+200),_this.brandLogo.events.onInputUp.add(function(){h5branding.Branding.openCampaignLink("vex-3",h5branding.UtmTargets.logo)})),_this.closeButton.position.set(120,-80),_this}return __extends(PauseWindow,_super),PauseWindow.prototype.show=function(){_super.prototype.show.call(this),Constants.pausedMapTime=Date.now(),null!==Constants.actStartTime&&(Constants.pausedActTime=Date.now())},PauseWindow.prototype.hide=function(){_super.prototype.hide.call(this);var elapsedTime=Date.now()-Constants.pausedMapTime;if(Constants.levelMapStartTime+=elapsedTime,null!==Constants.actStartTime){var elapsedActTime=Date.now()-Constants.pausedActTime;Constants.actStartTime+=elapsedActTime}},PauseWindow}(VexWindow),MainMenu=function(){function MainMenu(main,game,layer){var _this=this;h5branding.google.sendScreenView("menu"),this.game=game,this.buttonLayer=game.add.group(layer),h5branding.Branding.isAirfi(),this.optionsButton=new ExplandButton(game,550,320,"menuOptions",this.buttonLayer,function(){},function(){},function(){main.state===GameStates.MainMenu&&main.optionsWindow.show()}),this.achievementsButton=new ExplandButton(game,270,460,this.getTrophyBtnImageName(),this.buttonLayer,function(){},function(){},function(){_this.showAchievements(main)}),h5branding.Branding.outGoingLinksAllowed()&&(this.moreGamesButton=new ExplandButton(game,420,460,this.getMoreGamesBtnImageName(),this.buttonLayer,function(){},function(){},function(){_this.showMoreGames()}),this.moreGamesButton.sprite.visible=!1),h5branding.Utils.isOnDevice()&&SocialServicesHandler.login(this.game),this.playButton=new ExplandButton(game,120,320,"menuPlayGame",this.buttonLayer,function(){},function(){},function(){main.state===GameStates.MainMenu&&main.changeLevel("hub",-1)}),this.playButton.scaleOff=.8,this.vex4Button=new ExplandButton(game,680,540,"vex4Logo",this.buttonLayer,function(){},function(){},function(){_this.vex4Link()}),this.windowOpen=!1,this.buttonLayer.y=game.height+400,this.vexLogo=layer.create(320,-200,"vexLogo"),this.vexLogo.anchor.set(.5,.5),this.logoAni=0,this.buttonTarY=0,h5branding.Branding.outGoingLinksAllowed()?(this.brandLogo=this.game.make.button(0,-this.game.height/2+20,"branding_logo"),layer.add(this.brandLogo),this.brandLogo.inputEnabled=h5branding.Branding.outGoingLinksAllowed(),this.brandLogo.input.useHandCursor=!0,this.brandLogo.events.onInputUp.add(function(){h5branding.Branding.openCampaignLink("vex-3",h5branding.UtmTargets.logo)}),this.brandLogo.scale.set(.6,.6)):(this.vex4Button.sprite.visible=!1,this.vex4Button.sprite.inputEnabled=!1),this.resizeStage(game.width,game.height),this.logoScale=1,this.vexLogo.scale.set(this.logoScale*this.extraScale),this.vexLogoTarY=60}return MainMenu.prototype.getTrophyBtnImageName=function(){return h5branding.Utils.isOnDevice()?"menuAchievements":"menuTrophy"},MainMenu.prototype.getMoreGamesBtnImageName=function(){return h5branding.Utils.isOnDevice()?"menuLeaderBoard":"menuMoreGames"},MainMenu.prototype.showMoreGames=function(){h5branding.Utils.isOnDevice()&&SocialServicesHandler.showLeaderboards(this.game)},MainMenu.prototype.showAchievements=function(main){h5branding.google.sendScreenView("achievements_menu"),h5branding.Utils.isOnDevice()?SocialServicesHandler.showAchievements(this.game):main.state===GameStates.MainMenu&&main.achievementsWindow.show()},MainMenu.prototype.vex4Link=function(){window.open("https://kizi.com/games/vex-4?utm_source="+window.location.host+"&utm_medium=html5&utm_term=vex-4&utm_content=vex3&utm_campaign=Gamedistribution","_blank")},MainMenu.prototype.enterMenu=function(){this.logoAni=0,this.vexLogo.position.y=-200,this.buttonLayer.y=600,this.logoScale=1},MainMenu.prototype.update=function(){if(this.playButton.update(),this.optionsButton.update(),this.achievementsButton.update(),this.vex4Button.update(),this.moreGamesButton&&this.moreGamesButton.update(),0===this.logoAni)this.vexLogo.y<260&&(-5<(dist=this.vexLogo.y-260)?(this.vexLogo.y=260,this.logoAni=1):this.vexLogo.y-=dist/8);else if(1===this.logoAni){if(this.vexLogo.y!=this.vexLogoTarY){var dist=this.vexLogo.y-this.vexLogoTarY;Math.abs(dist)<2?this.vexLogo.y=this.vexLogoTarY:(this.vexLogo.y-=dist/8,this.logoScale-=.012,this.vexLogo.scale.x=this.logoScale*this.extraScale,this.vexLogo.scale.y=this.vexLogo.scale.x)}else this.buttonLayer.y===this.buttonTarY&&(this.logoAni=2);if(this.buttonLayer.y>this.buttonTarY)(dist=this.buttonLayer.y-this.buttonTarY)<2?this.buttonLayer.y=this.buttonTarY:this.buttonLayer.y-=dist/8}else{if(this.windowOpen){if(this.buttonLayer.y!=this.game.height+400){dist=this.buttonLayer.y-this.game.height+400;Math.abs(dist)<2?this.buttonLayer.y=this.game.height+400:this.buttonLayer.y-=dist/4}}else if(this.buttonLayer.y!=this.buttonTarY){dist=this.buttonLayer.y-this.buttonTarY;Math.abs(dist)<2?this.buttonLayer.y=this.buttonTarY:this.buttonLayer.y-=dist/4}if(this.vexLogo.y!=this.vexLogoTarY){dist=this.vexLogo.y-this.vexLogoTarY;Math.abs(dist)<2?this.vexLogo.y=this.vexLogoTarY:this.vexLogo.y-=dist/8}}},MainMenu.prototype.resizeStage=function(width,height){if(this.buttonLayer.position.x=width/2,this.vexLogoTarY=60,width<height)if(500<width&&800<height){if(1e3<height){this.buttonLayer.scale.set(1.7,1.7),this.buttonTarY=-height,this.vex4Button.scale=.8;var hh=600<height?height-30:height;this.playButton.sprite.position.set(0,hh-280),this.achievementsButton.sprite.position.set(-85,hh-150),this.vex4Button.sprite.position.set(80,hh+30),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(-85,hh-40),this.optionsButton.sprite.position.set(75,hh-125)}else{this.buttonLayer.scale.set(1.7,1.7),this.buttonTarY=320-height;hh=600<height?height-30:height;this.playButton.sprite.position.set(0,hh-380),this.achievementsButton.sprite.position.set(-85,hh-270),this.vex4Button.sprite.position.set(80,hh-90),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(-85,hh-160),this.optionsButton.sprite.position.set(75,hh-245)}this.extraScale=2}else if(350<width&&600<height){this.buttonLayer.scale.set(1,1),this.extraScale=1.5,this.buttonTarY=0;hh=600<height?height-30:height;this.playButton.sprite.position.set(0,hh-380),this.achievementsButton.sprite.position.set(-85,hh-270),this.vex4Button.sprite.position.set(80,hh-90),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(-85,hh-160),this.optionsButton.sprite.position.set(75,hh-245)}else{this.buttonLayer.scale.set(.8,.8),this.vexLogo.scale.set(1,1),this.extraScale=.8,this.buttonTarY=70,this.vexLogoTarY=30;hh=600<height?height-30:height;this.playButton.sprite.position.set(0,hh-380),this.achievementsButton.sprite.position.set(-85,hh-270),this.vex4Button.sprite.position.set(80,hh-90),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(-85,hh-160),this.optionsButton.sprite.position.set(75,hh-245)}else if(height<width&&width<900)if(this.vexLogoTarY=60,900<width&&550<height){this.buttonLayer.scale.set(1.4,1.4),this.extraScale=2,this.vexLogoTarY=90,this.vex4Button.scale=1,this.buttonTarY=height/2-500;hh=Math.min(height,460);this.playButton.sprite.position.set(-150,hh-240),this.achievementsButton.sprite.position.set(-80,hh-115),this.vex4Button.sprite.position.set(175,hh),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(80,hh-110),this.optionsButton.sprite.position.set(150,hh-240)}else if(600<width&&350<height){this.buttonLayer.scale.set(1.05,1.05),this.extraScale=1.2,this.buttonTarY=-40,this.vex4Button.scale=.8;hh=Math.min(height,460);this.playButton.sprite.position.set(-150,hh-240),this.achievementsButton.sprite.position.set(-80,hh-115),this.vex4Button.sprite.position.set(240,hh-100),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(80,hh-110),this.optionsButton.sprite.position.set(150,hh-240)}else{this.buttonLayer.scale.set(.8,.8),this.vexLogo.scale.set(1,1),this.extraScale=.8,this.buttonTarY=0,this.vex4Button.scale=.7;hh=Math.min(height,460);this.playButton.sprite.position.set(-150,hh-200),this.achievementsButton.sprite.position.set(-80,hh-75),this.vex4Button.sprite.position.set(210,hh-45),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(80,hh-70),this.optionsButton.sprite.position.set(150,hh-200)}else if(this.vexLogoTarY=60,900<width&&550<height){this.buttonLayer.scale.set(1.4,1.4),this.extraScale=2,this.vexLogoTarY=90,this.vex4Button.scale=1,this.buttonTarY=height/2-500;hh=Math.min(height,460);this.playButton.sprite.position.set(-150,hh-155),this.achievementsButton.sprite.position.set(-80,hh-30),this.vex4Button.sprite.position.set(240,hh),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(80,hh-25),this.optionsButton.sprite.position.set(150,hh-155)}else if(600<width&&350<height){this.buttonLayer.scale.set(1.2,1.2),this.extraScale=1.5,this.buttonTarY=-40,this.vex4Button.scale=1;hh=Math.min(height,460);this.playButton.sprite.position.set(-150,hh-250),this.achievementsButton.sprite.position.set(-80,hh-125),this.vex4Button.sprite.position.set(240,hh-95),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(80,hh-120),this.optionsButton.sprite.position.set(150,hh-250)}else{this.buttonLayer.scale.set(1,1),this.vexLogo.scale.set(1,1),this.extraScale=.8,this.buttonTarY=0,this.vex4Button.scale=1;hh=Math.min(height,460);this.playButton.sprite.position.set(-150,hh-155),this.achievementsButton.sprite.position.set(-80,hh-30),this.vex4Button.sprite.position.set(240,hh),this.moreGamesButton&&this.moreGamesButton.sprite.position.set(80,hh-25),this.optionsButton.sprite.position.set(150,hh-155)}this.brandLogo&&this.brandLogo.position.set(10,height-70),this.vexLogo.scale.x=this.logoScale*this.extraScale,this.vexLogo.scale.y=this.vexLogo.scale.x,this.vexLogo.position.x=width/2},MainMenu}();!function(GameStates){GameStates[GameStates.Loading=0]="Loading",GameStates[GameStates.Playing=1]="Playing",GameStates[GameStates.Window=2]="Window",GameStates[GameStates.MainMenu=3]="MainMenu"}(GameStates||(GameStates={}));var PauseType,Fabrique,Main=function(){function Main(game,keys){var _this=this;this.gameSpeed=1,this.gravity=.5,this.tint=16720418,this.skipMenu=!1,this.enableHellButton=!1,this.finished=!1,this.time=0,this.timeCheck=Date.now(),this.game=game,this.keys=keys,this.allowSpace=!1,this.yKey=game.input.keyboard.addKey(Phaser.Keyboard.Y),this.hKey=game.input.keyboard.addKey(Phaser.Keyboard.H),game.time.desiredFps=30,this.sounds=new Sounds(this,game),this.background=game.add.group(),this.background.create(-200,-400,"parallaxBackground"),this.background.alpha=.5,this.background.fixedToCamera=!1,this.underPoolLayer=game.add.group(),this.playerUnderLayer=game.add.group(),this.poolLayer=game.add.group(),this.obstacleLayer=game.add.group(),this.levelLayer=game.add.group(),this.topObstacleLayer=game.add.group(),this.particleLayer=game.add.group(),this.topPoolLayer=game.add.group(),this.textLayer=game.add.group(),this.playerLayer=game.add.group(),this.overlayLayer=game.add.group(),this.guiLayer=game.add.group(),this.guiLayer.fixedToCamera=!0,this.mainMenuLayer=game.add.group(),this.windowLayer=game.add.group(),this.windowLayer.fixedToCamera=!0,this.transitionLayer=game.add.group(),this.mainMenu=new MainMenu(this,game,this.mainMenuLayer),this.game.cache&&(this.timerGui=new TimerGui(this,game,this.guiLayer),this.rankTime=new RankTime(this,game,this.guiLayer)),this.darkOverlay=this.overlayLayer.create(0,0,"darkOverlay"),this.darkOverlay.anchor.set(.5,.5),this.darkOverlay.animations.add("dark"),this.darkOverlay.visible=!1,this.darkGraphics=this.game.add.graphics(0,0,this.overlayLayer),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(-game.width,-game.height-259,2*game.width,game.height),this.darkGraphics.endFill(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(259,-259-game.height,game.width,2*game.height),this.darkGraphics.endFill(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(-game.width-259,259,2*game.width,game.height),this.darkGraphics.endFill(),this.darkGraphics.endFill(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(-game.width-259,-259-game.height,game.width,2*game.height),this.darkGraphics.endFill(),this.darkGraphics.visible=!1,this.windowOverlay=this.game.add.graphics(0,0,this.overlayLayer),this.windowOverlay.beginFill(0,.35),this.windowOverlay.drawRect(-10,-10,game.width+20,game.height+20),this.windowOverlay.endFill(),this.windowOverlay.fixedToCamera=!0,this.windowOverlay.visible=!1,this.flashOverlay=game.add.graphics(0,0,this.overlayLayer),this.flashOverlay.fixedToCamera=!0,this.flashOverlay.beginFill(16777215),this.flashOverlay.drawRect(-10,10,game.width+10,game.height+10),this.flashOverlay.endFill(),this.flashOverlay.visible=!1,this.exploding=!1,this.deathText=new DeathText(game,this.overlayLayer),this.state=GameStates.Loading,this.player=new Player(this,game,this.playerLayer),this.checkpointText=new CheckPointText(this,game,this.particleLayer),this.destroying=!1,this.options=new Options(game),this.achievements=new Achievements(this,this.game),this.achievementsWindow=new AchievementsWindow(this,game,this.windowLayer),this.achievementUnlocked=new AchievementUnlocked(this,game,this.windowLayer),this.tipsWindow=new TipsWindow(this.game,this.windowLayer),this.optionsWindow=new OptionsWindow(this,game,this.windowLayer),this.pauseWindow=new PauseWindow(this,game,this.windowLayer),this.buttonSet=new ButtonSet(this,game,this.guiLayer),this.currentLevelID="mainmenu",this.firstSpawn=!1,this.transition=new SimpleTransition(this,game,this.transitionLayer),this.levels=new Levels(function(){}),this.achievementsWindow.updateProgress(),Fabrique.PauseHandler.getInstance().onPauseCallback.add(function(){_this.pauseWindow.show()}),this.actSelectWindow=new ActSelectWindow(this,game,this.windowLayer),Constants.muted&&(this.buttonSet.muteButton.sprite.frame=1),this.optionsWindow.updateValues(),this.keys.hide(),this.timerGui.hide(),this.state=GameStates.MainMenu,this.sounds.playMenuSong(),this.skipMenu&&this.changeLevel("hub",-1),this.correctSoundValues()}return Main.prototype.mobilePressedDown=function(){h5branding.Utils.isOnDevice()||(this.keys.show(),this.player.resume()),this.correctSoundValues(),this.player.enterActBlock()},Main.prototype.gotoMainMenu=function(){var _this=this;this.transition.beginTransition(function(){_this.prevLevel=_this.currentLevelID,_this.destroying=!0,_this.state=GameStates.Loading,_this.currentLevel=_this.levels.levels[_this.currentLevelID],_this.destroyLevel(),_this.timerLive=!1,_this.buttonSet.enterMainMenu(),_this.state=GameStates.MainMenu,_this.mainMenuLayer.visible=!0,_this.keys.hide(),_this.timerGui.hide(),_this.rankTime.invis(),_this.currentLevelID="mainmenu",_this.game.camera.x=0,_this.game.camera.y=0,_this.background.position.set(0,0),_this.mainMenu.enterMenu()},null,!1),this.state=GameStates.Loading},Main.prototype.changeLevel=function(targetLevelID,completedTime,challenge){var _this=this;void 0===challenge&&(challenge=!1),Constants.levelMapStartTime||(Constants.levelMapStartTime=Date.now()),SaveGame.getInstance(this.game).saveStats(),this.state===GameStates.MainMenu?this.prevLevel="mainmenu":this.prevLevel=this.currentLevelID,this.transition.beginTransition(function(){if("mainmenu"!==_this.prevLevel?_this.prevLevel=_this.currentLevelID:(_this.mainMenuLayer.visible=!1,_this.timerGui.show(),_this.rankTime.vis()),_this.sounds.playRandomMusic(),_this.destroying=!0,_this.currentLevelID=""+targetLevelID,_this.currentLevel=_this.levels.levels[_this.currentLevelID],_this.flashOverlay.visible=!1,"hub"===_this.currentLevelID){if(-1!==completedTime){if(_this.currentChallenge){h5branding.Utils.isOnDevice()&&SocialServicesHandler.submitScore(_this.game,Constants.actFinishTime,"challenge",_this.prevLevel),_this.achievements.gotAchievement("challenge"+_this.prevLevel);var pl=_this.levels.levels[_this.prevLevel];pl.challengeCompleted=!0,_this.levels.checkWinner()&&_this.achievements.gotAchievement("winner"),pl.saveLevel()}else _this.achievements.gotAchievement("act"+_this.prevLevel),_this.elapsedTime=Date.now()-Constants.actStartTime,h5branding.Utils.isOnDevice()&&SocialServicesHandler.submitScore(_this.game,Constants.actFinishTime,"act",_this.prevLevel);_this.levels.levels[_this.prevLevel].setBestTime(Constants.actFinishTime,_this.currentDeaths),0===_this.levels.levels[_this.prevLevel].bestRank&&(_this.achievements.gotAchievement("perfect"),_this.levels.checkPerfection()&&_this.achievements.gotAchievement("perfectionist")),_this.levels.levels[_this.prevLevel].bestRank<=1&&_this.levels.checkOlympian()&&_this.achievements.gotAchievement("olympian");var nn=parseInt(_this.prevLevel);nn>_this.levels.latestCompleted&&(_this.levels.latestCompleted=nn>Levels.LAST_LEVEL?Levels.LAST_LEVEL:nn,Constants.latestCompleted=_this.levels.latestCompleted)}_this.actSelectWindow.resetWindow()}"mainmenu"!==_this.prevLevel&&_this.destroyLevel(),challenge?_this.createLevel(_this.currentLevel.challengeData,_this.game):_this.createLevel(_this.currentLevel.data,_this.game),_this.firstSpawn=!0,_this.timerLive=!1,_this.currentTime=null,_this.currentDeaths=0,_this.buttonSet.changeLevel(),"hub"!==_this.currentLevelID?(h5branding.google.sendScreenView("gameplay"),_this.allowSpace=!1,_this.rankTime.leaveHub(),_this.timerGui.enterLevel(_this.currentLevel),_this.correctSoundValues(),h5branding.gameanalytics.addDesignEvent("Start:Level:"+_this.currentLevelID),Constants.actStartTime=Date.now(),Constants.blend?(_this.background.filters=[_this.currentLevel.colorFilter],_this.optionsWindow.frame.filters=[_this.currentLevel.colorFilter],_this.achievementsWindow.frame.filters=[_this.currentLevel.colorFilter],_this.pauseWindow.frame.filters=[_this.currentLevel.colorFilter],_this.achievementUnlocked.frame.filters=[_this.currentLevel.colorFilter]):(_this.background.filters=null,_this.optionsWindow.frame.filters=null,_this.achievementsWindow.frame.filters=null,_this.pauseWindow.frame.filters=null,_this.achievementUnlocked.frame.filters=null)):(h5branding.google.sendScreenView("level_select"),_this.timerGui.exitLevel(),_this.background.filters=null,_this.optionsWindow.frame.filters=null,_this.achievementsWindow.frame.filters=null,_this.pauseWindow.frame.filters=null,_this.achievementUnlocked.frame.filters=null,_this.timerGui.updateDeaths(Constants.totalDeaths),_this.timerGui.updateProgress(_this.achievements.getTotalProgress())),"10"==_this.currentLevelID?(_this.followingWire=!0,_this.wireTrail.startFollow()):_this.followingWire=!1,_this.currentChallenge=challenge,_this.state=GameStates.Playing,_this.keys.show(),0==_this.levels.latestCompleted?_this.keys.setAlpha(.5):1==_this.levels.latestCompleted?_this.keys.setAlpha(.2):_this.keys.setAlpha(.15)},this.levels.levels[targetLevelID].colorFilter,"hub"===this.currentLevelID||"mainmenu"===this.currentLevelID),this.state=GameStates.Loading},Main.prototype.finishLevel=function(){var _this=this;this.finished||(this.finished=!0,this.enableHellButton=!1,(Constants.actFinishTime<this.levels.levels.hub.topTime||-1===this.levels.levels.hub.topTime)&&(this.levels.levels.hub.topTime=Constants.actFinishTime),h5branding.gameanalytics.addDesignEvent("Complete:Level:"+this.currentLevelID,this.currentDeaths),Constants.actStartTime=null,Fabrique.AdHandler.getInstance().showAd("endLevel",function(){_this.resumeOnFinish()}))},Main.prototype.resumeOnFinish=function(){var time=this.currentTime;this.game.paused=!1,this.changeLevel("hub",time),this.keys.show(),this.player.resume(),this.finished=!1,this.correctSoundValues()},Main.prototype.destroyLevel=function(){for(var _i=0,_a=this.blocks;_i<_a.length;_i++){_a[_i].destroy()}this.blocks=null;for(var _b=0,_c=this.obstacles;_b<_c.length;_b++){_c[_b].destroy()}for(var _d=0,_e=this.ziplines;_d<_e.length;_d++){_e[_d].destroy()}this.ziplines=null;for(var _f=0,_g=this.checkpoints;_f<_g.length;_f++){_g[_f].destroy()}this.checkpoints=null;for(var _h=0,_j=this.textFades;_h<_j.length;_h++){_j[_h].destroy()}this.textFades=null;for(var _k=0,_l=this.pools;_k<_l.length;_k++){_l[_k].destroy()}this.pools=null;for(var _m=0,_o=this.poles;_m<_o.length;_m++){_o[_m].destroy()}this.poles=null;for(var _p=0,_q=this.stars;_p<_q.length;_p++){_q[_p].destroy()}this.stars=null;for(var _r=0,_s=this.fans;_r<_s.length;_r++){_s[_r].destroy()}this.fans=null;for(var _t=0,_u=this.keyObjs;_t<_u.length;_t++){_u[_t].destroy()}this.keyObjs=null;for(var _v=0,_w=this.cannons;_v<_w.length;_v++){_w[_v].destroy()}this.cannons=null;for(var _x=0,_y=this.slopes;_x<_y.length;_x++){_y[_x].destroy()}this.slopes=null;for(var _z=0,_0=this.breatheBlasters;_z<_0.length;_z++){_0[_z].destroy()}this.breatheBlasters=null;for(var _1=0,_2=this.wires;_1<_2.length;_1++){_2[_1].destroy()}this.wires=null;for(var _3=0,_4=this.lightSwitches;_3<_4.length;_3++){_4[_3].destroy()}this.lightSwitches=null;for(var _5=0,_6=this.misc;_5<_6.length;_5++){_6[_5].destroy()}this.misc=null;for(var _7=0,_8=this.particles;_7<_8.length;_7++){_8[_7].destroy()}this.wireTrail&&this.wireTrail.destroy(),this.finishPortal=null,this.player.hide()},Main.prototype.createLevel=function(leveljson,game){var spawnX=0,spawnY=0;this.dark=!1,this.darkOverlay.visible=!1,this.darkGraphics.visible=!1,this.blocks=[],this.solarBlocks=[],this.slopes=[],this.obstacles=[],this.ziplines=[],this.checkpoints=[],this.poles=[],this.particles=[],this.textFades=[],this.pools=[],this.stars=[],this.fans=[],this.keyObjs=[],this.wires=[],this.misc=[],this.cannons=[],this.lightSwitches=[],this.breatheBlasters=[],this.actBlocks={},this.explosiveBlock=null,this.wireTrail=null,this.particleNum=0;var freeZip=null,freeLaserPoint=null;if(leveljson)for(var i=0;i<leveljson.length;i++){switch((struct=leveljson[i]).type){case"spawnPoint":spawnX=struct.x,spawnY=struct.y;break;case"basicBlock":(block=new BasicBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"verticalUpBlock":(block=new VerticalUpBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"verticalDownBlock":(block=new VerticalDownBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"horizontalBlock":(block=new HorizontalBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"horizontalBlockFast":(block=new HorizontalBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height,-5),this.blocks.push(block);break;case"fallingBlock":(block=new FallingBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"bounceBlock":(block=new BounceBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"pushBlock":(block=new PushBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"iceBlock":(block=new IceBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"glassBlock":(block=new GlassBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"speedBlock":(block=new SpeedBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height,2.5),this.blocks.push(block);break;case"speedBlockLeft":(block=new SpeedBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height,-2.5),this.blocks.push(block);break;case"lockBlock":(block=new LB(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"sparkBlock":(block=new SparkBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"solarBlock":(block=new SolarBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block),this.solarBlocks.push(block);break;case"invisBlock":(block=new InvisBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"invisBlockUp":(block=new InvisBlockUp(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"invisBlockDown":(block=new InvisBlockDown(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block);break;case"explosiveBlock":(block=new ExplosiveBlock(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.blocks.push(block),this.explosiveBlock=block;break;case"blockedWall":(block=new BlockedWall(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height,struct.rotation,this.levels.levels[struct.actnum]),this.blocks.push(block);break;case"actBlock":(block=new ActBlock(this,game,this.levelLayer,struct.actNum,this.levels.levels[struct.actNum])).spawn(struct.x,struct.y),this.blocks.push(block),this.actBlocks[struct.actNum]=block;break;case"swimmingPool":var block=void 0;(block="7"==this.currentLevelID?new SwimmingPool(this,game,this.topPoolLayer):new SwimmingPool(this,game,this.poolLayer)).spawn(struct.x,struct.y,struct.width,struct.height),this.pools.push(block);break;case"leftSlope":(block=new LeftSlope(this,game,this.levelLayer)).spawn(struct.x,struct.y,struct.width,struct.height,struct.rotation),this.slopes.push(block);break;case"rightSlope":(block=new LeftSlope(this,game,this.levelLayer,!0)).spawn(struct.x,struct.y,struct.width,struct.height,struct.rotation),this.slopes.push(block);break;case"ziplinePole":var ziplinePole=new ZiplinePole(this,game,this.obstacleLayer);ziplinePole.spawn(struct.x,struct.y),freeZip=freeZip?(this.ziplines.push(freeZip.attach(ziplinePole)),null):ziplinePole,this.misc.push(ziplinePole);break;case"pole":var pole=new Pole(this,game,this.topObstacleLayer);pole.spawn(struct.x,struct.y),this.poles.push(pole);break;case"checkpoint":(checkpoint=new Checkpoint(this,game,this.obstacleLayer,!1)).spawn(struct.x,struct.y),this.checkpoints.push(checkpoint);break;case"checkpointSwimming":var checkpoint;(checkpoint=new Checkpoint(this,game,this.obstacleLayer,!0)).spawn(struct.x,struct.y),this.checkpoints.push(checkpoint);break;case"star":var star=new Star(this,game,this.topObstacleLayer);star.spawn(struct.x,struct.y),this.stars.push(star);break;case"windBlaster":var windBlaster=new WindBlaster(this,game,this.obstacleLayer);windBlaster.spawn(struct.x,struct.y,struct.rotation),this.fans.push(windBlaster);break;case"finishPortal":var finishPortal=new FinishPortal(this,game,this.obstacleLayer);finishPortal.spawn(struct.x,struct.y),this.misc.push(finishPortal),this.finishPortal=finishPortal;break;case"key":(key=new Key(this,game,this.obstacleLayer)).spawn(struct.x,struct.y),this.keyObjs.push(key);break;case"timedKey":(key=new TimedKey(this,game,this.obstacleLayer)).spawn(struct.x,struct.y),this.keyObjs.push(key);break;case"circularCannon":var cannon=new CircularCannon(this,game,this.topObstacleLayer);cannon.spawn(struct.x,struct.y),this.cannons.push(cannon);break;case"lightSwitch":var light=new LightSwitch(this,game,this.topObstacleLayer);light.spawn(struct.x,struct.y),this.lightSwitches.push(light);break;case"wire":var wire=new Wire(this,game,this.obstacleLayer);wire.spawn(struct.x,struct.y,struct.rotation),this.wires.push(wire);break;case"buzzsaw":var buzzsaw=new Buzzsaw(this,game,this.obstacleLayer);struct.width?buzzsaw.spawn(struct.x,struct.y,Math.round(struct.width)/101):buzzsaw.spawn(struct.x,struct.y),this.obstacles.push(buzzsaw);break;case"buzzsawVerticalUp":(buzzsaw=new BuzzsawVerticalUp(this,game,this.obstacleLayer)).spawn(struct.x,struct.y),this.obstacles.push(buzzsaw);break;case"buzzsawVerticalDown":(buzzsaw=new BuzzsawVerticalUp(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,2),this.obstacles.push(buzzsaw);break;case"buzzsawHorizontal":buzzsaw=new BuzzsawHorizontal(this,game,this.obstacleLayer);struct.width?buzzsaw.spawn(struct.x,struct.y,2,Math.round(struct.width)/101):buzzsaw.spawn(struct.x,struct.y,2),this.obstacles.push(buzzsaw);break;case"buzzsawHorizontalFast":(buzzsaw=new BuzzsawHorizontal(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,5),this.obstacles.push(buzzsaw);break;case"bouncingBuzzsaw":buzzsaw=new BouncingBuzzsaw(this,game,this.obstacleLayer);struct.width?buzzsaw.spawn(struct.x,struct.y,Math.round(struct.width)/101):buzzsaw.spawn(struct.x,struct.y),this.obstacles.push(buzzsaw);break;case"enlargingBuzzsaw":buzzsaw=new EnlargingBuzzsaw(this,game,this.obstacleLayer);struct.width?buzzsaw.spawn(struct.x,struct.y,Math.round(struct.width)/101):buzzsaw.spawn(struct.x,struct.y),this.obstacles.push(buzzsaw);break;case"buzzsawOnStick":buzzsaw=void 0;(buzzsaw="hub"===this.currentLevelID?new BuzzsawOnStick(this,game,this.obstacleLayer):new BuzzsawOnStick(this,game,this.topObstacleLayer)).spawn(struct.x,struct.y,struct.rotation),this.obstacles.push(buzzsaw);break;case"spike":(spike=new Spike(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,struct.rotation),this.obstacles.push(spike);break;case"spike10x":(spike=new Spike10x(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,struct.rotation),this.obstacles.push(spike);break;case"spike30x":(spike=new Spike30x(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,struct.rotation),this.obstacles.push(spike);break;case"fallingSpike":(spike=new FallingSpike(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,struct.rotation-90),this.obstacles.push(spike);break;case"shurikanSpawner":var spike;(spike=new ShurikanSpawner(this,game,this.obstacleLayer)).spawn(struct.x,struct.y,struct.rotation),this.obstacles.push(spike);break;case"classicLaser":var laser=new ClassicLaser(this,game,this.topObstacleLayer);laser.spawn(struct.x,struct.y),this.obstacles.push(laser);break;case"quadrantRight":var quad=new Quadrant(this,game,this.obstacleLayer);struct.width?quad.spawn(struct.x,struct.y,struct.rotation,2*Math.PI/180,struct.width/180):quad.spawn(struct.x,struct.y,struct.rotation,2*Math.PI/180),this.obstacles.push(quad);break;case"quadrantLeft":quad=new Quadrant(this,game,this.obstacleLayer);struct.width?quad.spawn(struct.x,struct.y,struct.rotation,-2*Math.PI/180,struct.width/180):quad.spawn(struct.x,struct.y,struct.rotation,-2*Math.PI/180),this.obstacles.push(quad);break;case"laserPoint":if(freeLaserPoint){var laserPoint=new LaserPoint(this,game,this.obstacleLayer);laserPoint.spawn(freeLaserPoint.x,freeLaserPoint.y,struct.x,struct.y),this.obstacles.push(laserPoint),freeLaserPoint=null}else freeLaserPoint=new Phaser.Point(struct.x,struct.y);break;case"reaper":var reaper=new Reaper(this,game,this.obstacleLayer);struct.width?reaper.spawn(struct.x,struct.y,struct.rotation,Math.round(struct.width)/133):reaper.spawn(struct.x,struct.y,struct.rotation),this.obstacles.push(reaper);break;case"shurikanDispenser":var dispenser=new ShurikanDispenser(this,game,this.obstacleLayer);dispenser.spawn(struct.x,struct.y),this.obstacles.push(dispenser);break;case"hazardStrips":var hazard=new HazardStrips(this,game,this.topObstacleLayer);hazard.spawn(struct.x,struct.y),this.misc.push(hazard);break;case"breatheBlaster":var blaster=new BreatheBlaster(this,game,this.obstacleLayer);blaster.spawn(struct.x,struct.y,struct.rotation),this.breatheBlasters.push(blaster);break;case"textFade":(textFade=new TextFade(this,game,this.textLayer,"textFade"+struct.textNum)).spawn(struct.x,struct.y,struct.rotation),this.textFades.push(textFade)}}for(var key in this.blocks){(block=this.blocks[key]).levelStart&&block.levelStart()}for(var _i=0,_a=this.obstacles;_i<_a.length;_i++){var obs=_a[_i];obs.levelStart&&obs.levelStart()}if("10"===this.currentLevelID&&(this.wireTrail=new WireTrail(this,this.wires)),"hub"==this.currentLevelID){for(var _b=0,arrows_1=hubArrows[this.levels.latestCompleted];_b<arrows_1.length;_b++){var struct,textFade;if("textFade"===(struct=arrows_1[_b]).type)(textFade=new TextFade(this,game,this.textLayer,"textFade"+struct.textNum)).spawn(struct.x,struct.y,struct.rotation),this.textFades.push(textFade)}this.prevLevel&&"mainmenu"!=this.prevLevel&&this.actBlocks?this.player.spawn(this.actBlocks[this.prevLevel].xPos,this.actBlocks[this.prevLevel].topEdge):0<this.levels.latestCompleted&&this.actBlocks?this.player.spawn(this.actBlocks[this.levels.latestCompleted].xPos,this.actBlocks[this.levels.latestCompleted].topEdge):this.player.spawn(spawnX,spawnY)}else this.player.spawn(spawnX,spawnY);this.spawnX=spawnX,this.spawnY=spawnY,this.state=GameStates.Playing},Main.prototype.correctSoundValues=function(){!1===Constants.muted?(this.optionsWindow.bgmVolumeSlider.setValue(Constants.musicVolume),this.optionsWindow.effectVolumeSlider.setValue(Constants.effectVolume)):(this.buttonSet.muteButton.sprite.frame=1,this.options.musicVolume=0,this.options.effectVolume=0,this.sounds.currentMusic&&(this.sounds.currentMusic.volume=0)),SaveGame.getInstance().saveOptions()},Main.prototype.createColorParticle=function(x,y,xVelocity,yVelocity,color,size,collide,isLiquid,fadeTime,scaleOut){if(void 0===color&&(color=0),void 0===size&&(size=4),void 0===collide&&(collide=!0),void 0===isLiquid&&(isLiquid=!1),void 0===fadeTime&&(fadeTime=140),void 0===scaleOut&&(scaleOut=!1),0!==Constants.particleLimit){var particle=new ColorParticle(this,this.game,this.particleLayer,color,size,collide,isLiquid,fadeTime,scaleOut);if(particle.spawn(x,y,xVelocity,yVelocity),this.particleNum++,this.particles.push(particle),this.particleNum>=Constants.particleLimit)for(var _i=0,_a=this.particles;_i<_a.length;_i++){var particle_1=_a[_i];if(particle_1.alive){particle_1.destroy();break}}}},Main.prototype.createPlayerGib=function(x,y,xVelocity,yVelocity,spriteKey,rotation,rotSpeed,size,collide,isLiquid,fadeTime){void 0===rotation&&(rotation=0),void 0===rotSpeed&&(rotSpeed=0),void 0===size&&(size=4),void 0===collide&&(collide=!0),void 0===isLiquid&&(isLiquid=!1),void 0===fadeTime&&(fadeTime=0);var particle=new PlayerGib(this,this.game,this.particleLayer,spriteKey,size,collide);if(particle.spawn(x,y,xVelocity,yVelocity,rotation,rotSpeed),this.particleNum++,this.particles.push(particle),this.particleNum>=Constants.particleLimit)for(var _i=0,_a=this.particles;_i<_a.length;_i++){var particle_2=_a[_i];if(particle_2.alive){particle_2.destroy();break}}},Main.prototype.goDark=function(){var _this=this;if(!this.dark){this.dark=!0,this.darkOverlay.visible=!0,setTimeout(function(){return _this.darkOverlay.animations.play("dark",30,!1,!1)},100),this.darkGraphics.visible=!0,this.flashOverlay.visible=!1;for(var _i=0,_a=this.solarBlocks;_i<_a.length;_i++){_a[_i].goDark()}}},Main.prototype.goLight=function(){this.dark&&(this.flashOverlay.visible=!0,this.flashOverlay.alpha=1),this.dark=!1,this.darkOverlay.visible=!1,this.darkOverlay.animations.stop("dark",!0),this.darkGraphics.visible=!1;for(var _i=0,_a=this.solarBlocks;_i<_a.length;_i++){_a[_i].goLight()}},Main.prototype.explode=function(){this.exploding=!0,this.flashOverlay.visible=!0,this.flashOverlay.alpha=0},Main.prototype.checkpointTriggered=function(curCheck){for(var _i=0,_a=this.checkpoints;_i<_a.length;_i++){var checkpoint=_a[_i];checkpoint!==curCheck&&(1===checkpoint.state&&("hub"==this.currentLevelID||"6"==this.currentLevelID?checkpoint.resetLevel():checkpoint.gray()))}},Main.prototype.portToActBlock=function(num){this.player.currentPole=null,this.player.xPos=this.actBlocks[num].xPos,this.player.yPos=this.actBlocks[num].topEdge,this.player.yVelocity=0,this.player.xVelocity=0,this.player.forcedXVelocity=0,this.player.setIdle(),this.player.updateHitBoxesPos(),this.player.updatePositions(),this.game.camera.x=this.player.xPos-320,this.game.camera.y=this.player.yPos-280},Main.prototype.playerDeath=function(){this.currentDeaths++,Constants.totalDeaths++,"hub"!==this.currentLevelID&&h5branding.gameanalytics.addDesignEvent("Fail:Level:"+this.currentLevelID,this.currentDeaths),this.currentDeaths%11!=10||this.game.device.desktop||this.tipsWindow.animateWindow(),100<Constants.totalDeaths&&this.achievements.gotAchievement("deathtycoon"),"hub"===this.currentLevelID?this.timerGui.updateDeaths(Constants.totalDeaths):this.timerGui.updateDeaths(this.currentDeaths),SaveGame.getInstance(this.game).saveStats()},Main.prototype.exitLevel=function(){var _this=this;Fabrique.AdHandler.getInstance().showAd("exitLevel",function(){"hub"===_this.currentLevelID?_this.gotoMainMenu():(_this.changeLevel("hub",-1),_this.enableHellButton=!1)})},Main.prototype.openWindow=function(){this.state=GameStates.Window,"mainmenu"===this.currentLevelID?this.mainMenu.windowOpen=!0:this.windowOverlay.visible=!0,this.keys.hide(),this.player.pause()},Main.prototype.closeWindow=function(){"mainmenu"===this.currentLevelID?(this.mainMenu.windowOpen=!1,this.state=GameStates.MainMenu):(this.state=GameStates.Playing,this.keys.show(),this.player.resume()),this.windowOverlay.visible=!1,this.sounds.currentMusic.resume()},Main.prototype.update=function(){var t=Date.now();switch(t-this.timeCheck<34&&(this.time+=t-this.timeCheck,this.timeCheck=Date.now()),this.transition.update(),this.state){case GameStates.Playing:for(var _i=0,_a=this.cannons;_i<_a.length;_i++){_a[_i].update()}if(this.player.update(),this.state!==GameStates.Playing)return;for(var key in this.blocks){this.blocks[key].update()}for(var key in this.wireTrail&&(this.followingWire&&this.wireTrail.followTick()&&(this.followingWire=!1,this.wireTrail.burning=!0,this.timerLive=!0),this.wireTrail.update()),this.obstacles){this.obstacles[key].update()}for(var _b=0,_c=this.pools;_b<_c.length;_b++){_c[_b].update()}for(var i=0;i<this.particles.length;i++){var particle=this.particles[i];particle.alive?particle.update():(this.particles.splice(i,1),i--)}for(var key in this.poles){this.poles[key].update()}for(var key in this.checkpoints){this.checkpoints[key].update()}for(var key in this.textFades){this.textFades[key].update()}for(var _d=0,_e=this.fans;_d<_e.length;_d++){_e[_d].update()}for(var _f=0,_g=this.keyObjs;_f<_g.length;_f++){(key=_g[_f]).update()}for(var _h=0,_j=this.breatheBlasters;_h<_j.length;_h++){_j[_h].update()}this.finishPortal&&this.finishPortal.update(),this.deathText&&this.deathText.update(),this.checkpointText&&this.checkpointText.update(),this.exploding?(this.flashOverlay.alpha+=.05,1<=this.flashOverlay.alpha&&(this.exploding=!1,this.changeLevel("hub",-1))):this.dark?(this.darkGraphics.position.set(this.player.xPos,this.player.yPos),this.darkOverlay.position.set(this.player.xPos,this.player.yPos)):this.flashOverlay.visible&&(this.flashOverlay.alpha-=.03,this.flashOverlay.alpha<=0&&(this.flashOverlay.visible=!1)),Constants.timePlayed++,Constants.isAnHour(Constants.levelMapStartTime)&&this.achievements.gotAchievement("timeflies"),"hub"==this.currentLevelID?(this.rankTime.update(),this.timerGui.updateLevelTime(Constants.levelMapStartTime)):(this.timerLive&&(this.currentTime=Constants.actStartTime,this.timerGui.updateLevelTime(Constants.actStartTime)),this.keys.reset.pressed()&&(this.resetLevel(),Constants.actStartTime=Date.now()),Constants.autoReset&&-1!==this.currentLevel.topTime&&this.currentTime>this.currentLevel.topTime&&this.resetLevel()),Constants.parallax?(this.background.x=this.game.camera.x+this.game.camera.x/10%140,this.background.y=this.game.camera.y+this.game.camera.y/10%140):(this.background.x=this.game.camera.x,this.background.y=this.game.camera.y);break;case GameStates.Window:"mainmenu"==this.currentLevelID&&this.mainMenu.update();break;case GameStates.MainMenu:this.mainMenu.update(),Constants.parallax&&(this.background.x+=1,this.background.y+=1,this.background.x=this.background.x%140,this.background.y=this.background.y%140)}this.actSelectWindow&&this.actSelectWindow.update(),this.achievementsWindow&&this.achievementsWindow.update(),this.achievementUnlocked&&this.achievementUnlocked.update(),this.optionsWindow&&this.optionsWindow.update(),this.pauseWindow&&this.pauseWindow.update()},Main.prototype.resetDeath=function(){this.resumeOnReset()},Main.prototype.pauseOnLevelEnd=function(){this.game.paused=!0,this.keys.hide(),this.player.pause()},Main.prototype.resumeOnReset=function(){var time=Date.now();this.currentTime=time,this.game.paused=!1;for(var _i=0,_a=this.blocks;_i<_a.length;_i++){_a[_i].reset()}for(var _b=0,_c=this.obstacles;_b<_c.length;_b++){_c[_b].reset()}for(var _d=0,_e=this.keyObjs;_d<_e.length;_d++){_e[_d].reset()}this.goLight(),this.keys.show(),this.player.resume()},Main.prototype.resetLevel=function(){this.dark&&this.goLight();for(var _i=0,_a=this.obstacles;_i<_a.length;_i++){_a[_i].resetLevel()}for(var _b=0,_c=this.checkpoints;_b<_c.length;_b++){_c[_b].resetLevel()}for(var _d=0,_e=this.wires;_d<_e.length;_d++){_e[_d].resetLevel()}this.wireTrail&&this.wireTrail.resetLevel();for(var _f=0,_g=this.blocks;_f<_g.length;_f++){_g[_f].resetLevel()}for(var _h=0,_j=this.keyObjs;_h<_j.length;_h++){_j[_h].resetLevel()}this.player.spawn(this.spawnX,this.spawnY),this.timerGui.resetLevel(),this.currentTime=null,this.currentDeaths=0,this.timerGui.updateDeaths(this.currentDeaths)},Main.prototype.resizeStage=function(width,height){this.timerGui.resizeStage(width,height),this.buttonSet.resizeStage(width,height),this.rankTime.resizeStage(width,height),this.transition.resizeStage(width,height),this.tipsWindow.resize(),this.pauseWindow.resizeStage(width,height),this.actSelectWindow&&this.actSelectWindow.resizeStage(width,height),this.optionsWindow.resizeStage(width,height),this.achievementsWindow.resizeStage(width,height),this.mainMenu.resizeStage(width,height),this.darkGraphics.clear(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(-width,-height-259,2*width,height),this.darkGraphics.endFill(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(259,-259-height,width,3*height),this.darkGraphics.endFill(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(-width-259,259,2*width,height),this.darkGraphics.endFill(),this.darkGraphics.endFill(),this.darkGraphics.beginFill(0),this.darkGraphics.drawRect(-width-259,-259-height,width,3*height),this.darkGraphics.endFill(),this.windowOverlay.clear(),this.windowOverlay.beginFill(0,.35),this.windowOverlay.drawRect(-10,-10,width+20,height+20),this.windowOverlay.endFill(),this.flashOverlay.clear(),this.flashOverlay.beginFill(16777215),this.flashOverlay.drawRect(-10,10,this.game.width+10,this.game.height+10),this.flashOverlay.endFill()},Main.prototype.clearAllSavedData=function(){this.levels.clearAllLevelData(),SaveGame.getInstance().clearAll(),this.optionsWindow.updateValues(),this.achievements.clearSavedData(),this.achievementsWindow.updateProgress(),this.keys.show(),this.buttonSet.muteButton.sprite.frame=0,this.sounds.playMenuSong(),this.levels=new Levels(function(){}),this.achievementUnlocked=new AchievementUnlocked(this,this.game,this.windowLayer),this.achievementsWindow=new AchievementsWindow(this,this.game,this.windowLayer),this.actSelectWindow=new ActSelectWindow(this,this.game,this.windowLayer),this.rankTime=new RankTime(this,this.game,this.guiLayer),this.correctSoundValues()},Main}(),Spike=function(_super){function Spike(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.obstacleType="spike",_this.init(),_this}return __extends(Spike,_super),Spike.prototype.init=function(){this.sprite=this.layer.create(0,0,"spike"),this.sprite.autoCull=!0,this.sprite.anchor.set(.5,.5),this.graphics=this.game.add.graphics(0,0,this.layer),this.graphics.visible=!1,this.width=7.5,this.height=14.75,this.spikeNum=1},Spike.prototype.levelStart=function(){for(var _i=0,_a=this.main.pools;_i<_a.length;_i++){var pool=_a[_i];SAT.testPolygonPolygon(this.deathBoxPolygon,pool.totalPolygon)&&this.main.underPoolLayer.addChild(this.sprite)}},Spike.prototype.spawn=function(x,y,rotation){this.xPos=x,this.yPos=y,this.sprite.position.set(x,y),this.alive=!0,this.sprite.visible=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height,rad=rotation*Math.PI/180;this.rad=rad,this.sprite.rotation=rad;var topLeftOff=new Phaser.Point(-halfWidth*Math.cos(this.rad)- -halfHeight*Math.sin(this.rad),-halfWidth*Math.sin(this.rad)+-halfHeight*Math.cos(this.rad)),topRightOff=new Phaser.Point(halfWidth*Math.cos(this.rad)- -halfHeight*Math.sin(this.rad),halfWidth*Math.sin(this.rad)+-halfHeight*Math.cos(this.rad)),bottomLeftOff=new Phaser.Point(-halfWidth*Math.cos(this.rad)-halfHeight*Math.sin(this.rad),-halfWidth*Math.sin(this.rad)+halfHeight*Math.cos(this.rad)),bottomRightOff=new Phaser.Point(halfWidth*Math.cos(this.rad)-halfHeight*Math.sin(this.rad),halfWidth*Math.sin(this.rad)+halfHeight*Math.cos(this.rad));this.deathBoxPolygon=new SAT.Polygon(new SAT.Vector(x,y),[new SAT.Vector(topLeftOff.x,topLeftOff.y),new SAT.Vector(topRightOff.x,topRightOff.y),new SAT.Vector(bottomRightOff.x,bottomRightOff.y),new SAT.Vector(bottomLeftOff.x,bottomLeftOff.y)]),this.graphics.beginFill(16711680,.5),this.graphics.moveTo(this.deathBoxPolygon.points[0].x,this.deathBoxPolygon.points[0].y),this.graphics.lineTo(this.deathBoxPolygon.points[1].x,this.deathBoxPolygon.points[1].y),this.graphics.lineTo(this.deathBoxPolygon.points[2].x,this.deathBoxPolygon.points[2].y),this.graphics.lineTo(this.deathBoxPolygon.points[3].x,this.deathBoxPolygon.points[3].y),this.graphics.endFill(),this.graphics.position.set(x,y)},Spike.prototype.update=function(){},Spike.prototype.updatePosition=function(){this.sprite.position.set(this.xPos,this.yPos);var halfWidth=.5*this.width,halfHeight=.5*this.height,topLeftOff=new Phaser.Point(-halfWidth*Math.cos(this.rad)- -halfHeight*Math.sin(this.rad),-halfWidth*Math.sin(this.rad)+-halfHeight*Math.cos(this.rad)),topRightOff=new Phaser.Point(halfWidth*Math.cos(this.rad)- -halfHeight*Math.sin(this.rad),halfWidth*Math.sin(this.rad)+-halfHeight*Math.cos(this.rad)),bottomLeftOff=new Phaser.Point(-halfWidth*Math.cos(this.rad)-halfHeight*Math.sin(this.rad),-halfWidth*Math.sin(this.rad)+halfHeight*Math.cos(this.rad)),bottomRightOff=new Phaser.Point(halfWidth*Math.cos(this.rad)-halfHeight*Math.sin(this.rad),halfWidth*Math.sin(this.rad)+halfHeight*Math.cos(this.rad));this.deathBoxPolygon=new SAT.Polygon(new SAT.Vector(this.xPos,this.yPos),[new SAT.Vector(topLeftOff.x,topLeftOff.y),new SAT.Vector(topRightOff.x,topRightOff.y),new SAT.Vector(bottomRightOff.x,bottomRightOff.y),new SAT.Vector(bottomLeftOff.x,bottomLeftOff.y)]),this.graphics.clear(),this.graphics.beginFill(16711680,.5),this.graphics.moveTo(this.deathBoxPolygon.points[0].x,this.deathBoxPolygon.points[0].y),this.graphics.lineTo(this.deathBoxPolygon.points[1].x,this.deathBoxPolygon.points[1].y),this.graphics.lineTo(this.deathBoxPolygon.points[2].x,this.deathBoxPolygon.points[2].y),this.graphics.lineTo(this.deathBoxPolygon.points[3].x,this.deathBoxPolygon.points[3].y),this.graphics.endFill(),this.graphics.position.set(this.xPos,this.yPos)},Spike.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.deathBoxPolygon=null,this.graphics.destroy(),this.graphics=null},Spike}(Obstacle),HorizontalBlock=function(_super){function HorizontalBlock(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.maxMoveDist=100,_this.sprite=layer.create(0,0,"horizontalBlock"),_this.sprite.autoCull=!0,_this.alive=!1,_this.hangable=!0,_this.scalable=!0,_this}return __extends(HorizontalBlock,_super),HorizontalBlock.prototype.spawn=function(x,y,width,height,speed){void 0===speed&&(speed=-2),this.xPos=x,this.yPos=y,this.startX=x,this.width=width,this.height=height,this.sprite.position.set(x,y),this.sprite.scale.set(width/100,height/100),this.sprite.anchor.set(.5,.5),this.xVelocity=speed,this.startXVelocity=speed,this.yVelocity=0,this.leftEdge=x-.5*width,this.rightEdge=x+.5*width,this.topEdge=y-.5*height,this.bottomEdge=y+.5*height,this.attachmentOffsets=[],this.attachments=[],this.landed=null,this.alive=!0;var halfWidth=.5*this.width,halfHeight=.5*this.height;this.totalBound=new SAT.Box(new SAT.Vector(x,y),width,height),this.totalBoundPolygon=this.totalBound.toPolygon(),this.totalBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.topBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.topBoundPolygon=this.topBound.toPolygon(),this.topBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.lhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.lhBoundPolygon=this.lhBound.toPolygon(),this.lhBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rhBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,BasicBlock.TOP_BOUND_HEIGHT),this.rhBoundPolygon=this.rhBound.toPolygon(),this.rhBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.leftBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.leftBoundPolygon=this.leftBound.toPolygon(),this.leftBoundPolygon.setOffset(new SAT.Vector(-halfWidth,-halfHeight)),this.rightBound=new SAT.Box(new SAT.Vector(x,y),halfWidth,height),this.rightBoundPolygon=this.rightBound.toPolygon(),this.rightBoundPolygon.setOffset(new SAT.Vector(0,-halfHeight)),this.bottomBound=new SAT.Box(new SAT.Vector(x,y),width,BasicBlock.TOP_BOUND_HEIGHT),this.bottomBoundPolygon=this.bottomBound.toPolygon(),this.bottomBoundPolygon.setOffset(new SAT.Vector(-halfWidth,halfHeight-BasicBlock.TOP_BOUND_HEIGHT))},HorizontalBlock.prototype.levelStart=function(){for(var testPoly=new SAT.Box(new SAT.Vector(this.leftEdge,this.topEdge),this.width,this.height+10).toPolygon(),i=0;i<this.main.obstacles.length;i++){var obs=this.main.obstacles[i];if("spike"===obs.obstacleType){var spike=obs;if(1!=spike.spikeNum)continue;SAT.testPolygonPolygon(testPoly,spike.deathBoxPolygon)&&(this.attachments.push(spike),this.attachmentOffsets.push(new Phaser.Point(spike.xPos-this.xPos,spike.yPos-this.yPos)))}}},HorizontalBlock.prototype.updatePosition=function(){this.leftEdge=this.xPos-.5*this.width,this.rightEdge=this.xPos+.5*this.width,this.topEdge=this.yPos-.5*this.height,this.bottomEdge=this.yPos+.5*this.height,this.sprite.position.set(this.xPos,this.yPos),this.totalBoundPolygon.pos.x=this.xPos,this.totalBoundPolygon.pos.y=this.yPos,this.topBoundPolygon.pos.x=this.xPos,this.topBoundPolygon.pos.y=this.yPos,this.lhBoundPolygon.pos.x=this.xPos,this.lhBoundPolygon.pos.y=this.yPos,this.rhBoundPolygon.pos.x=this.xPos,this.rhBoundPolygon.pos.y=this.yPos,this.leftBoundPolygon.pos.x=this.xPos,this.leftBoundPolygon.pos.y=this.yPos,this.rightBoundPolygon.pos.x=this.xPos,this.rightBoundPolygon.pos.y=this.yPos,this.bottomBoundPolygon.pos.x=this.xPos,this.bottomBoundPolygon.pos.y=this.yPos,this.sprite.x=this.xPos;for(var i=0;i<this.attachments.length;i++){var spike=this.attachments[i],offset=this.attachmentOffsets[i];spike.xPos=this.xPos+offset.x,spike.yPos=this.yPos+offset.y,spike.updatePosition()}},HorizontalBlock.prototype.update=function(){var prevX=this.xPos;if(0<this.xVelocity?this.xPos>this.startX+this.maxMoveDist&&(this.xVelocity=-this.xVelocity):this.xPos<this.startX-this.maxMoveDist&&(this.xVelocity=-this.xVelocity),this.xPos+=this.xVelocity,this.xPos!=prevX&&this.updatePosition(),this.landed){var xExtra=this.main.player.xPos-prevX-this.landed.x;this.landed.x+=xExtra,this.main.player.xPos=this.xPos+this.landed.x,this.main.player.updatePositions()}},HorizontalBlock.prototype.reset=function(){this.xPos=this.startX,this.xVelocity=this.startXVelocity},HorizontalBlock.prototype.resetLevel=function(){this.reset()},HorizontalBlock.prototype.destroy=function(){this.sprite.destroy(),this.sprite=null,this.attachments=null,this.attachmentOffsets=null},HorizontalBlock}(Block),ControllerButton=function(){function ControllerButton(game,x,y,sprite,isMove){this.game=game,this.sprite=game.add.sprite(x,y,sprite),this.sprite.alpha=.5,this.sprite.anchor.set(.5,.5),this.sprite.scale.set(1.35,1.35),this.sprite.fixedToCamera=!0,this.sprite.inputEnabled=!0,isMove&&(this.sprite.events.onInputOver.add(this.onDown,this),this.sprite.events.onInputOut.add(this.onUp,this)),this.sprite.events.onInputDown.add(this.onDown,this),this.sprite.events.onInputUp.add(this.onUp,this),this.pressedDown=new Phaser.Signal,this.isDown=!1,this.isPressed=!1}return ControllerButton.prototype.onDown=function(_,p){this.pointer=p,this.isDown=!0},ControllerButton.prototype.onUp=function(){this.isDown&&this.pressedDown.dispatch(),this.isDown=!1,this.isPressed=!1},ControllerButton.prototype.hide=function(){this.sprite.visible=!1},ControllerButton.prototype.show=function(){this.sprite.visible=!0},ControllerButton.prototype.buttonPressed=function(){return this.isDown},ControllerButton}(),Constants=function(){function Constants(){}return Constants.getInterstialAd=function(type,isIOS){var adType;switch(type){case"start":adType=isIOS?Constants.iOS_AD_ID_StartInterstitial:Constants.Google_AD_ID_StartInterstitial;break;case"level":adType=isIOS?Constants.iOS_AD_ID_LevelInterstitial:Constants.Google_AD_ID_LevelInterstitial;break;case"pause":adType=isIOS?Constants.iOS_AD_ID_PauseBanner:Constants.Google_AD_ID_PauseBanner}return adType},Constants.calcCurrentTime=function(time){var timeNow=new Date(Date.now()),previousTime=new Date(time);return previousTime.setTime(previousTime.getTime()),timeNow-previousTime},Constants.isAnHour=function(time){return 1==Math.floor(time/1e3/60/60)},Constants.overrideSplash=function(game){return h5branding.Utils.getBrandingDomain()!=h5branding.BrandingDomain.Bild||!!h5branding.Branding.isContracted()},Constants.GOOGLE_ID="UA-85519155-1",Constants.GOOGLE_APP_NAME="Vex 3",Constants.GAME_KEY="20cbc90eaf20dbd14fc4265232077ef3",Constants.SECRET_KEY="6843de2fc526e0131ff1424076aae62a79630806",Constants.GAME_TITLE="vex-3",Constants.GAME_SPLASH_TITLE="Vex 3",Constants.AdID=201,Constants.iOS_AD_ID="ca-app-pub-1394495769473752~2756650820",Constants.iOS_AD_ID_StartInterstitial="ca-app-pub-1394495769473752/7186850421",Constants.iOS_AD_ID_PauseBanner="ca-app-pub-1394495769473752/8663583623",Constants.iOS_AD_ID_LevelInterstitial="ca-app-pub-1394495769473752/4233384021",Constants.Google_AD_ID="ca-app-pub-1394495769473752~1140316825",Constants.Google_AD_ID_StartInterstitial="ca-app-pub-1394495769473752/7047249623",Constants.Google_AD_ID_PauseBanner="ca-app-pub-1394495769473752/8523982820",Constants.Google_AD_ID_LevelInterstitial="ca-app-pub-1394495769473752/5570516420",Constants.tutorialURL="http://kizi.com/videos/u/vex-3",Constants.totalDeaths=0,Constants.timePlayed=0,Constants.autoReset=!1,Constants.particleLimit=30,Constants.oldControls=!1,Constants.blend=!0,Constants.waves=!0,Constants.parallax=!0,Constants.musicVolume=1,Constants.effectVolume=.5,Constants.muted=!1,Constants.gotStar=!1,Constants.challengeCompleted=!1,Constants.latestCompleted=0,Constants.currentLevel=1,Constants.actFinishTime=-1,Constants.pausedActTime=null,Constants.pausedMapTime=null,Constants.isPaused=!1,Constants.achievements={act1:!1,act2:!1,act3:!1,act4:!1,act5:!1,act6:!1,act7:!1,act8:!1,act9:!1,star1:!1,star2:!1,star3:!1,star4:!1,star5:!1,star6:!1,star7:!1,star8:!1,star9:!1,star10:!1,challenge1:!1,challenge2:!1,challenge3:!1,challenge4:!1,challenge5:!1,challenge6:!1,challenge7:!1,challenge8:!1,challenge9:!1,perfect:!1,caretaker:!1,gasping:!1,timeflies:!1,headsup:!1,deathtycoon:!1,olympian:!1,perfectionist:!1,astronomer:!1,winner:!1,vexation:!1},Constants}(),SocialServicesData=function(){function SocialServicesData(){}return SocialServicesData.convertTime=function(game,time){return game.device.android?time:100*Math.floor(time/1e3)},SocialServicesData.getActName=function(name,level){var actName;switch(name){case"act":actName="10"===level?"vexation":name+level;break;case"challenge":actName="hardcore"+level}return actName},SocialServicesData.getSocialServiceID=function(game,socialServicesObj,key){var obj=socialServicesObj[key];return game.device.android?obj.android:game.device.iOS?obj.ios:void 0},SocialServicesData.ACT_1="CggI4vyI-WkQAhAU",SocialServicesData.ACT_2="CggI4vyI-WkQAhAV",SocialServicesData.ACT_3="CggI4vyI-WkQAhAW",SocialServicesData.ACT_4="CggI4vyI-WkQAhAX",SocialServicesData.ACT_5="CggI4vyI-WkQAhAY",SocialServicesData.ACT_6="CggI4vyI-WkQAhAZ",SocialServicesData.ACT_7="CggI4vyI-WkQAhAa",SocialServicesData.ACT_8="CggI4vyI-WkQAhAb",SocialServicesData.ACT_9="CggI4vyI-WkQAhAc",SocialServicesData.VEXATION="CggI4vyI-WkQAhAd",SocialServicesData.MINE_="CggI4vyI-WkQAhAe",SocialServicesData.THANKS_BOX_="CggI4vyI-WkQAhAf",SocialServicesData.ITS_THE_CLIMB_="CggI4vyI-WkQAhAg",SocialServicesData.BETWEEN_A_SAW="CggI4vyI-WkQAhAh",SocialServicesData.LEAP_OF_FAITH="CggI4vyI-WkQAhAi",SocialServicesData.KEYCHAIN="CggI4vyI-WkQAhAj",SocialServicesData.TAKE_THE_PLUNGE="CggI4vyI-WkQAhAk",SocialServicesData.LIGHTS_OUT_="CggI4vyI-WkQAhAl",SocialServicesData.OUTSIDE_THE_BOX="CggI4vyI-WkQAhAm",SocialServicesData.INSIDE_THE_BOX="CggI4vyI-WkQAhAn",SocialServicesData.ONE_STEP_AT_A_TIME="CggI4vyI-WkQAhAo",SocialServicesData.DOUBLE_DOWN="CggI4vyI-WkQAhAp",SocialServicesData.THIRDS_THE_CHARM="CggI4vyI-WkQAhAq",SocialServicesData.FANTASTIC_FOUR="CggI4vyI-WkQAhAr",SocialServicesData.HIGH_FIVE="CggI4vyI-WkQAhAs",SocialServicesData.DEMON="CggI4vyI-WkQAhAt",SocialServicesData.YOURE_LUCKY="CggI4vyI-WkQAhAu",SocialServicesData.EIGHT_TIMES_THE_CHAMP="CggI4vyI-WkQAhAv",SocialServicesData.NINE_LIVES="CggI4vyI-WkQAhAw",SocialServicesData.PERFECT_="CggI4vyI-WkQAhAx",SocialServicesData.CARETAKER="CggI4vyI-WkQAhAy",SocialServicesData.GASPING="CggI4vyI-WkQAhAz",SocialServicesData.TIME_FLIES_V20="CggI4vyI-WkQAhA0",SocialServicesData.HEADS_UP="CggI4vyI-WkQAhA1",SocialServicesData.DEATH_TYCOON="CggI4vyI-WkQAhA2",SocialServicesData.OLYMPIAN="CggI4vyI-WkQAhA3",SocialServicesData.PERFECTIONIST="CggI4vyI-WkQAhA4",SocialServicesData.ASTRONOMER="CggI4vyI-WkQAhA5",SocialServicesData.WINNER="CggI4vyI-WkQAhA6",SocialServicesData.LEAD_ACT_1="CggI4vyI-WkQAhAB",SocialServicesData.LEAD_ACT_2="CggI4vyI-WkQAhAD",SocialServicesData.LEAD_ACT_3="CggI4vyI-WkQAhAF",SocialServicesData.LEAD_ACT_4="CggI4vyI-WkQAhAH",SocialServicesData.LEAD_ACT_5="CggI4vyI-WkQAhAJ",SocialServicesData.LEAD_ACT_6="CggI4vyI-WkQAhAL",SocialServicesData.LEAD_ACT_7="CggI4vyI-WkQAhAN",SocialServicesData.LEAD_ACT_8="CggI4vyI-WkQAhAP",SocialServicesData.LEAD_ACT_9="CggI4vyI-WkQAhAR",SocialServicesData.LEAD_ACT_1__HARDCORE="CggI4vyI-WkQAhAC",SocialServicesData.LEAD_ACT_2__HARDCORE="CggI4vyI-WkQAhAE",SocialServicesData.LEAD_ACT_3__HARDCORE="CggI4vyI-WkQAhAG",SocialServicesData.LEAD_ACT_4__HARDCORE="CggI4vyI-WkQAhAI",SocialServicesData.LEAD_ACT_5__HARDCORE="CggI4vyI-WkQAhAK",SocialServicesData.LEAD_ACT_6__HARDCORE="CggI4vyI-WkQAhAM",SocialServicesData.LEAD_ACT_7__HARDCORE="CggI4vyI-WkQAhAO",SocialServicesData.LEAD_ACT_8__HARDCORE="CggI4vyI-WkQAhAQ",SocialServicesData.LEAD_ACT_9__HARDCORE="CggI4vyI-WkQAhAS",SocialServicesData.LEAD_VEXATION="CggI4vyI-WkQAhAT",SocialServicesData.AchToSocialID={act1:{android:SocialServicesData.ACT_1,ios:"act1"},act2:{android:SocialServicesData.ACT_2,ios:"act2"},act3:{android:SocialServicesData.ACT_3,ios:"act3"},act4:{android:SocialServicesData.ACT_4,ios:"act4"},act5:{android:SocialServicesData.ACT_5,ios:"act5"},act6:{android:SocialServicesData.ACT_6,ios:"act6"},act7:{android:SocialServicesData.ACT_7,ios:"act7"},act8:{android:SocialServicesData.ACT_8,ios:"act8"},act9:{android:SocialServicesData.ACT_9,ios:"act9"},act10:{android:SocialServicesData.VEXATION,ios:"vexation"},star1:{android:SocialServicesData.MINE_,ios:"mine"},star2:{android:SocialServicesData.THANKS_BOX_,ios:"thanks_box"},star3:{android:SocialServicesData.ITS_THE_CLIMB_,ios:"its_the_climb"},star4:{android:SocialServicesData.BETWEEN_A_SAW,ios:"between_a_saw"},star5:{android:SocialServicesData.LEAP_OF_FAITH,ios:"leap_of_faith"},star6:{android:SocialServicesData.KEYCHAIN,ios:"keychain"},star7:{android:SocialServicesData.TAKE_THE_PLUNGE,ios:"take_the_plunge"},star8:{android:SocialServicesData.LIGHTS_OUT_,ios:"lights_out"},star9:{android:SocialServicesData.OUTSIDE_THE_BOX,ios:"outside_the_box"},star10:{android:SocialServicesData.INSIDE_THE_BOX,ios:"inside_the_box"},challenge1:{android:SocialServicesData.ONE_STEP_AT_A_TIME,ios:"one_step_at_a_time"},challenge2:{android:SocialServicesData.DOUBLE_DOWN,ios:"double_down"},challenge3:{android:SocialServicesData.THIRDS_THE_CHARM,ios:"thirds_the_charm"},challenge4:{android:SocialServicesData.FANTASTIC_FOUR,ios:"fantastic_four"},challenge5:{android:SocialServicesData.HIGH_FIVE,ios:"high_five"},challenge6:{android:SocialServicesData.DEMON,ios:"demon"},challenge7:{android:SocialServicesData.YOURE_LUCKY,ios:"youre_lucky"},challenge8:{android:SocialServicesData.EIGHT_TIMES_THE_CHAMP,ios:"eight_times_the_champ"},challenge9:{android:SocialServicesData.NINE_LIVES,ios:"nine_lives"},perfect:{android:SocialServicesData.PERFECT_,ios:"perfect"},caretaker:{android:SocialServicesData.CARETAKER,ios:"caretaker"},gasping:{android:SocialServicesData.GASPING,ios:"gasping"},timeflies:{android:SocialServicesData.TIME_FLIES_V20,ios:"time_flies"},headsup:{android:SocialServicesData.HEADS_UP,ios:"heads_up"},deathtycoon:{android:SocialServicesData.DEATH_TYCOON,ios:"death_tycoon"},olympian:{android:SocialServicesData.OLYMPIAN,ios:"olympian"},perfectionist:{android:SocialServicesData.PERFECT_,ios:"perfectionist"},astronomer:{android:SocialServicesData.ASTRONOMER,ios:"astronomer"},winner:{android:SocialServicesData.WINNER,ios:"winner"}},SocialServicesData.LeaderBoardToSocialID={act1:{android:SocialServicesData.LEAD_ACT_1,ios:"act1"},act2:{android:SocialServicesData.LEAD_ACT_2,ios:"act2"},act3:{android:SocialServicesData.LEAD_ACT_3,ios:"act3"},act4:{android:SocialServicesData.LEAD_ACT_4,ios:"act4"},act5:{android:SocialServicesData.LEAD_ACT_5,ios:"act5"},act6:{android:SocialServicesData.LEAD_ACT_6,ios:"act6"},act7:{android:SocialServicesData.LEAD_ACT_7,ios:"act7"},act8:{android:SocialServicesData.LEAD_ACT_8,ios:"act8"},act9:{android:SocialServicesData.LEAD_ACT_9,ios:"act9"},hardcore1:{android:SocialServicesData.LEAD_ACT_1__HARDCORE,ios:"act1_hardcore"},hardcore2:{android:SocialServicesData.LEAD_ACT_2__HARDCORE,ios:"act2_hardcore"},hardcore3:{android:SocialServicesData.LEAD_ACT_3__HARDCORE,ios:"act3_hardcore"},hardcore4:{android:SocialServicesData.LEAD_ACT_4__HARDCORE,ios:"act4_hardcore"},hardcore5:{android:SocialServicesData.LEAD_ACT_5__HARDCORE,ios:"act5_hardcore"},hardcore6:{android:SocialServicesData.LEAD_ACT_6__HARDCORE,ios:"act6_hardcore"},hardcore7:{android:SocialServicesData.LEAD_ACT_7__HARDCORE,ios:"act7_hardcore"},hardcore8:{android:SocialServicesData.LEAD_ACT_8__HARDCORE,ios:"act8_hardcore"},hardcore9:{android:SocialServicesData.LEAD_ACT_9__HARDCORE,ios:"act9_hardcore"},vexation:{android:SocialServicesData.LEAD_VEXATION,ios:"vexation"}},SocialServicesData}();!function(Fabrique){var LoaderHelper=function(){function LoaderHelper(){}return LoaderHelper.show=function(){var loader=document.getElementById("loader");loader&&(loader.style.display="block")},LoaderHelper.hide=function(){var loader=document.getElementById("loader");loader&&(loader.style.display="none")},LoaderHelper}();Fabrique.LoaderHelper=LoaderHelper}(Fabrique||(Fabrique={})),function(Fabrique){var RayGun=function(){function RayGun(){var a,b,c,e,f,g,h,_this=this;this.apiKey="YT53I8S7SvjkNYVgA0GReA",this.recurringError=[],a=window,b=document,c="script",e="rg4js",a.RaygunObject=e,a[e]=a[e]||function(){(a[e].o=a[e].o||[]).push(arguments)},f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src="raygun/raygun.min.js",g.parentNode.insertBefore(f,g),h=a.onerror,a.onerror=function(b,c,d,f,g){h&&h(b,c,d,f,g),g||(g=new Error(b)),a[e].q=a[e].q||[],a[e].q.push({e:g})},rg4js("apiKey",this.apiKey),rg4js("enableCrashReporting",!0),rg4js("setVersion",version),rg4js("options",{ignore3rdPartyErrors:!0}),rg4js("onBeforeSend",function(data){return _this.filterError(data)}),rg4js("enablePulse",!1)}return RayGun.getInstance=function(){return null===RayGun.instance&&(RayGun.instance=new RayGun),RayGun.instance},RayGun.prototype.filterError=function(payload){if(void 0!==payload&&payload.Details&&payload.Details.Error&&payload.Details.Error.Message){if(-1!==this.recurringError.indexOf(payload.Details.Error.Message))return!1;this.recurringError.push(payload.Details.Error.Message)}return payload},RayGun.instance=null,RayGun}();Fabrique.RayGun=RayGun}(Fabrique||(Fabrique={})),function(Fabrique){var State=function(_super){function State(){var _this=null!==_super&&_super.apply(this,arguments)||this;return _this.name=State.Name,_this}return __extends(State,_super),State.prototype.create=function(){h5branding.google.sendScreenView(this.name)},State.Name="default",State}(Phaser.State);Fabrique.State=State}(Fabrique||(Fabrique={})),function(Fabrique){var ContentStatus;!function(ContentStatus){ContentStatus.PAUSED="Paused",ContentStatus.RESUMED="Resumed"}(ContentStatus||(ContentStatus={}));var AdHandler=function(){function AdHandler(){this.contentStatus=ContentStatus.RESUMED}return AdHandler.getInstance=function(){return AdHandler.instance||(AdHandler.instance=new AdHandler),AdHandler.instance},AdHandler.prototype.initAdProvider=function(){var adProvider=new h5ads.GameDistribution("762c932b4db74c6da0c1d101b2da8be6");h5ads.adWrapper.setAdProvider(adProvider),window.hasOwnProperty("fbrqSA")&&!0===window.fbrqSA&&(h5branding.Utils.ASSET_LOCATION="assets/")},AdHandler.prototype.showAd=function(type,resumeCallback,pauseCallback){var _this=this;Fabrique.LoaderHelper.show(),h5ads.adWrapper.once(h5ads.AdEvents.CONTENT_PAUSED,function(){Fabrique.LoaderHelper.hide(),h5branding.google.sendScreenView("advertisement_"+type),pauseCallback&&pauseCallback.call(_this),_this.contentStatus=ContentStatus.PAUSED,Fabrique.PauseHandler.getInstance().pause()}),h5ads.adWrapper.once(h5ads.AdEvents.CONTENT_RESUMED,function(){Fabrique.LoaderHelper.hide(),resumeCallback&&resumeCallback.call(_this),h5ads.adWrapper.removeAllListeners(h5ads.AdEvents.CONTENT_PAUSED),h5ads.adWrapper.removeAllListeners(h5ads.AdEvents.CONTENT_RESUMED),_this.contentStatus=ContentStatus.RESUMED,Fabrique.PauseHandler.getInstance().resume()}),h5ads.adWrapper.showAd(h5ads.AdType.interstitial)},AdHandler.prototype.isAdPlaying=function(){return this.contentStatus===ContentStatus.PAUSED},AdHandler}();Fabrique.AdHandler=AdHandler}(Fabrique||(Fabrique={})),function(Fabrique){var AnalyticsHandler=function(){function AnalyticsHandler(game){this.game=game}return AnalyticsHandler.prototype.initAnalytics=function(){h5branding.gameanalytics.setup(Constants.GAME_KEY,Constants.SECRET_KEY,version),h5branding.Utils.isOnDevice()?h5branding.google.setup(Constants.GOOGLE_ID,Constants.GOOGLE_APP_NAME,version,{storage:"none"}):h5branding.google.setup(Constants.GOOGLE_ID,Constants.GOOGLE_APP_NAME,version)},AnalyticsHandler.getInstance=function(game){return null===AnalyticsHandler.instance&&(AnalyticsHandler.instance=new AnalyticsHandler(game)),AnalyticsHandler.instance},AnalyticsHandler.instance=null,AnalyticsHandler}();Fabrique.AnalyticsHandler=AnalyticsHandler}(Fabrique||(Fabrique={})),function(PauseType){PauseType.BUTTON="button",PauseType.BLUR="blur"}(PauseType||(PauseType={})),function(Fabrique){var PauseHandler=function(){function PauseHandler(game){this.game=game,this.focused=!0}return PauseHandler.getInstance=function(game){return PauseHandler.instance||(PauseHandler.instance=new PauseHandler(game)),PauseHandler.instance},PauseHandler.prototype.init=function(){var _this=this;this.game.stage.disableVisibilityChange=!0,this.onPauseCallback=new Phaser.Signal,h5branding.Utils.isOnDevice()&&(document.addEventListener("pause",function(){return _this.onPause()}),document.addEventListener("resume",function(){return _this.onResume()})),this.game.onBlur.add(this.onBlur,this),this.game.onFocus.add(this.onFocus,this),this.game.onPause.add(this.onPause,this),this.game.onResume.add(this.onResume,this)},PauseHandler.prototype.onBlur=function(){Fabrique.AdHandler.getInstance().isAdPlaying()||this.sendPauseEvent(PauseType.BLUR),this.focused=!1,this.game.onPause.dispatch()},PauseHandler.prototype.onFocus=function(){this.focused=!0,Fabrique.AdHandler.getInstance().isAdPlaying()||this.game.onResume.dispatch()},PauseHandler.prototype.onPause=function(){this.game.sound.setMute(),this.onPauseCallback&&!Fabrique.AdHandler.getInstance().isAdPlaying()&&this.onPauseCallback.dispatch()},PauseHandler.prototype.onResume=function(){this.game.sound.unsetMute()},PauseHandler.prototype.pause=function(){this.game.onPause.dispatch()},PauseHandler.prototype.resume=function(){this.hasFocus&&this.game.onResume.dispatch()},Object.defineProperty(PauseHandler.prototype,"hasFocus",{get:function(){return this.focused},enumerable:!1,configurable:!0}),PauseHandler.prototype.sendPauseEvent=function(type){h5branding.google.sendScreenView(type+"_game_pause")},PauseHandler}();Fabrique.PauseHandler=PauseHandler}(Fabrique||(Fabrique={}));var SaveGame=function(){function SaveGame(game){this.levels=[],this.achievements=Constants.achievements,this.game=game}return SaveGame.getInstance=function(game){return SaveGame.instance||(SaveGame.instance=new SaveGame(game)),SaveGame.instance},SaveGame.prototype.init=function(){var _this=this;this.game.storage.setNamespace("v3"),this.game.storage.getItem("sg").then(function(storedItem){null==storedItem?(_this.clearAll(),_this.save()):_this.restore()})},SaveGame.prototype.getAllValues=function(){return{options:this.getOptions(),stats:this.getStats(),latestCompleted:Constants.latestCompleted,levels:this.getAllLevels(),achievements:this.getAchievements()}},SaveGame.prototype.setAllValues=function(data){this.setOptions(data.options),this.setStats(data.stats),this.setLastLevel(data.latestCompleted),this.setAllLevels(data.levels),this.setAchievements(data.achievements)},SaveGame.prototype.getOptions=function(){return{mv:Constants.musicVolume,efxv:Constants.effectVolume,ar:Constants.autoReset,pl:Constants.particleLimit,nc:Constants.oldControls,bl:Constants.blend,wv:Constants.waves,plx:Constants.parallax,mt:Constants.muted}},SaveGame.prototype.setOptions=function(data){Constants.musicVolume=data.mv,Constants.effectVolume=data.efxv,Constants.autoReset=data.ar,Constants.particleLimit=data.pl,Constants.oldControls=data.nc,Constants.blend=data.bl,Constants.waves=data.wv,Constants.parallax=data.plx,Constants.muted=data.mt},SaveGame.prototype.getStats=function(){return{td:Constants.totalDeaths,tp:Constants.timePlayed}},SaveGame.prototype.setStats=function(data){Constants.totalDeaths=data.td,Constants.timePlayed=data.tp},SaveGame.prototype.setLastLevel=function(id){Constants.latestCompleted=id>Levels.LAST_LEVEL?Levels.LAST_LEVEL:id},SaveGame.prototype.getAllLevels=function(){return this.levels},SaveGame.prototype.setLevel=function(id,saveData){var index=id-1,level=this.levels[index];(level=saveData).id=id,this.levels[index]=level},SaveGame.prototype.setAllLevels=function(data){this.levels=[],this.levels=data},SaveGame.prototype.getLevel=function(id){return this.levels[id]},SaveGame.prototype.getAchievements=function(){return this.achievements},SaveGame.prototype.setAchievements=function(data){this.achievements=data},SaveGame.prototype.clearOptions=function(){Constants.musicVolume=1,Constants.effectVolume=.5,Constants.autoReset=!1,Constants.particleLimit=30,Constants.oldControls=!1,Constants.blend=!0,Constants.waves=!0,Constants.parallax=!0,Constants.muted=!1,this.game.device.desktop||(Constants.particleLimit=0,Constants.blend=!1,Constants.waves=!1,Constants.parallax=!1)},SaveGame.prototype.clearStats=function(){Constants.totalDeaths=0,Constants.timePlayed=0},SaveGame.prototype.clearLevel=function(){return{tt:-1,br:4,gs:!1,cc:!1,fn:!1}},SaveGame.prototype.clearAllLevels=function(){this.levels=[];for(var i=0;i<=10;i++){var level=this.clearLevel();level.id=i+1,this.levels.push(level)}},SaveGame.prototype.clearAchievements=function(){this.achievements=Constants.achievements},SaveGame.prototype.saveOptions=function(data){this.save()},SaveGame.prototype.resetOptions=function(){this.clearOptions(),this.save()},SaveGame.prototype.saveStats=function(data){this.save()},SaveGame.prototype.resetStats=function(){this.clearStats(),this.save()},SaveGame.prototype.saveLevels=function(id,data){this.setLevel(id,data),this.setLastLevel(id),this.save()},SaveGame.prototype.resetLevels=function(){this.clearAllLevels(),this.setLastLevel(0),this.save()},SaveGame.prototype.saveAchievements=function(data){this.setAchievements(data),this.save()},SaveGame.prototype.resetAchievements=function(){this.clearAchievements(),this.save()},SaveGame.prototype.clearAll=function(){this.clearOptions(),this.clearStats(),this.clearAllLevels(),this.save()},SaveGame.prototype.save=function(){var data=JSON.stringify(this.getAllValues()),hash=this.hash([data.options,data.stats,data.latestCompleted,data.levels,data.achievements].join("-"));this.game.storage.setItem("sg",data),this.game.storage.setItem("h",hash)},SaveGame.prototype.restore=function(){var _this=this;this.game.storage.getItem("sg").then(function(data){_this.setAllValues(JSON.parse(data))})},SaveGame.prototype.load=function(){return this.game.storage.getItem("sg")},SaveGame.prototype.hash=function(data){var i,len,hash=0;if(0===data.length)return hash.toString();for(i=0,len=data.length;i<len;i++)hash=(hash<<5)-hash+data.charCodeAt(i),hash|=0;return hash.toString()},SaveGame.prototype.checkStoredHash=function(){var _this=this,data=this.getAllValues();this.game.storage.getItem("h").then(function(storedHash){_this.hash([data.options,data.stats,data.latestCompleted,data.levels,data.achievements].join("-"))})},SaveGame}(),SocialServicesHandler=function(){function SocialServicesHandler(){}return SocialServicesHandler.init=function(game){socialService=this.getSocialInterface(game)},SocialServicesHandler.getSocialInterface=function(game){return game.device.android?(Cocoon.Social.GooglePlayGames.init({}),Cocoon.Social.GooglePlayGames.getSocialInterface()):game.device.iOS?(Cocoon.Social.GameCenter.init({}),Cocoon.Social.GameCenter.getSocialInterface()):void 0},SocialServicesHandler.login=function(game){socialService.login(function(loggedIn,error){})},SocialServicesHandler.submitAchievement=function(game,achievementKey){var achievementID=SocialServicesData.getSocialServiceID(game,SocialServicesData.AchToSocialID,achievementKey);socialService.submitAchievement(achievementID,function(error){})},SocialServicesHandler.submitScore=function(game,time,lName,lNumber){var score=SocialServicesData.convertTime(game,time),levelName=SocialServicesData.getActName(lName,lNumber),boardID=SocialServicesData.getSocialServiceID(game,SocialServicesData.LeaderBoardToSocialID,levelName);socialService.submitScore(score,function(error){},{leaderboardID:boardID})},SocialServicesHandler.showAchievements=function(game){socialService.showAchievements(function(error){})},SocialServicesHandler.showLeaderboards=function(game){socialService.showLeaderboard(function(error){})},SocialServicesHandler}(),PressDown=function(){function PressDown(group){this.parentGroup=group,this.blinkingImg=this.parentGroup.create(0,-50,"pressDown"),this.blinkingImg.anchor.set(.5,.5),this.blinkingImg.visible=!1,this.pressDownTimer=60,this.showPressDown=!1}return PressDown.prototype.blink=function(){this.showPressDown?(this.pressDownTimer<=0?(this.blinkingImg.visible=!this.blinkingImg.visible,this.pressDownTimer=15):this.pressDownTimer--,this.parentGroup.scale.x<0?this.blinkingImg.scale.x=-1:this.blinkingImg.scale.x=1):(this.blinkingImg.visible=!1,this.pressDownTimer=60)},PressDown}(),Spike10x=function(_super){function Spike10x(main,game,layer){return _super.call(this,main,game,layer)||this}return __extends(Spike10x,_super),Spike10x.prototype.init=function(){this.sprite=this.layer.create(0,0,"spike10x"),this.sprite.autoCull=!0,this.sprite.anchor.set(.5,.5),this.sprite.visible=!1,this.graphics=this.game.add.graphics(0,0,this.layer),this.graphics.visible=!1,this.width=97.2,this.height=17.6},Spike10x}(Spike),Spike30x=function(_super){function Spike30x(main,game,layer){return _super.call(this,main,game,layer)||this}return __extends(Spike30x,_super),Spike30x.prototype.init=function(){this.sprite=this.layer.create(0,0,"spike30x"),this.sprite.autoCull=!0,this.sprite.anchor.set(.5,.5),this.sprite.visible=!1,this.graphics=this.game.add.graphics(0,0,this.layer),this.graphics.visible=!1,this.width=291.2,this.height=14.75,this.spikeNum=30},Spike30x}(Spike),VexBoot=function(){function VexBoot(game){}return VexBoot.prototype.init=function(){var _this=this;this.input.maxPointers=2,Fabrique.AnalyticsHandler.getInstance(this.game).initAnalytics(),Fabrique.AdHandler.getInstance().initAdProvider(),Fabrique.PauseHandler.getInstance(this.game).init(),"none"!==h5branding.Utils.LANGUAGE?this.game.i18n.setLanguage(h5branding.Utils.LANGUAGE):this.game.i18n.setLanguage(languageDetector.detect(["navigator"])),SaveGame.getInstance(this.game).init(),h5branding.Utils.isOnDevice()&&SocialServicesHandler.init(this.game),this.game.canvas.oncontextmenu=function(e){e.preventDefault()},h5branding.google.sendScreenView("splash"),this.game.load.cacheBuster="undefined"==typeof version?null:version,this.game.device.desktop?(this.scale.scaleMode=Phaser.ScaleManager.RESIZE,this.scale.supportsFullScreen=!0,this.scale.setMinMax(640,300,2e3,1120),this.scale.pageAlignHorizontally=!0,this.scale.pageAlignVertically=!0):(this.scale.scaleMode=Phaser.ScaleManager.USER_SCALE,this.game.scale.fullScreenScaleMode=Phaser.ScaleManager.USER_SCALE,this.game.scale.pageAlignHorizontally=!0,this.game.scale.pageAlignVertically=!0,this.game.scale.windowConstraints.right="layout",this.game.scale.windowConstraints.bottom="visual",window.addEventListener("resize",function(e){return _this.resizeCallback(_this.game.scale)}),this.resizeCallback(this.game.scale))},VexBoot.prototype.resizeCallback=function(manager){var userRatio=1.35;1<this.game.device.pixelRatio&&(userRatio=1.35),manager.width===window.innerWidth*userRatio&&manager.height===window.innerHeight*userRatio||(manager.setGameSize(window.innerWidth*userRatio,window.innerHeight*userRatio),manager.setUserScale(1/userRatio,1/userRatio))},VexBoot.prototype.preload=function(){var _this=this;Fabrique.LoaderHelper.hide(),this.game.load.onFileComplete.add(function(progress){h5branding.SplashLoader.getInstance().setLoadProgress(progress)}),this.game.load.onLoadComplete.add(function(){h5branding.SplashLoader.getInstance().setLoadProgress(100)}),h5branding.SplashLoader.getInstance().setButtonCallback(function(){h5branding.SplashLoader.getInstance().destroy(),h5branding.Utils.inGDGameZone()?(Fabrique.LoaderHelper.hide(),_this.game.state.start("Game")):Fabrique.AdHandler.getInstance().showAd("splash",function(){_this.game.state.start("Game")})}),this.game.device.iOS?(this.game.load.audio("connectHang",["assets/sounds/connect-hang.m4a"],!1),this.game.load.audio("fall",["assets/sounds/fall.m4a"],!1),this.game.load.audio("downgrade",["assets/sounds/downgrade.m4a"],!1),this.game.load.audio("poleSwing",["assets/sounds/pole-swing.m4a"],!1),this.game.load.audio("splash1",["assets/sounds/splash1.m4a"],!1),this.game.load.audio("ziplineFull",["assets/sounds/zipline-full.m4a"],!1),this.game.load.audio("cannonEnter",["assets/sounds/cannon-enter.m4a"],!1),this.game.load.audio("wallSlide",["assets/sounds/wall-slide.m4a"],!1),this.game.load.audio("connect",["assets/sounds/connect.m4a"],!1),this.game.load.audio("land",["assets/sounds/land.m4a"],!1),this.game.load.audio("slide",["assets/sounds/slide.m4a"],!1),this.game.load.audio("death1",["assets/sounds/slide.m4a"],!1),this.game.load.audio("death2",["assets/sounds/death2.m4a"],!1),this.game.load.audio("electricity",["assets/sounds/electricity.m4a"],!1),this.game.load.audio("poleWoosh",["assets/sounds/pole-woosh.m4a"],!1),this.game.load.audio("bounce1",["assets/sounds/bounce1.m4a"],!1),this.game.load.audio("cannonFire",["assets/sounds/cannon-fire.m4a"],!1),this.game.load.audio("glassSmash",["assets/sounds/glass-smash.m4a"],!1),this.game.load.audio("fallingBlock",["assets/sounds/falling-block.m4a"],!1),this.game.load.audio("blockDestroy",["assets/sounds/block-destroy.m4a"],!1),this.game.load.audio("menuSong",["assets/sounds/menu-song.m4a"],!1),this.game.load.audio("vexSong1",["assets/sounds/vex-song-1.m4a"],!1),this.game.load.audio("vexSong2",["assets/sounds/vex-song-2.m4a"],!1),this.game.load.audio("vexSong3",["assets/sounds/vex-song-3.m4a"],!1),this.game.load.audio("vexSong4",["assets/sounds/vex-song-4.m4a"],!1),this.game.load.audio("buttonClick",["assets/sounds/button-click.m4a"],!1),this.game.load.audio("achievementUnlocked",["assets/sounds/achievement-unlocked.m4a"],!1),this.game.load.audio("footstep",["assets/sounds/footstep.m4a"],!1),this.game.load.audio("laserFire",["assets/sounds/laser-fire.m4a"],!1),this.game.load.audio("ding",["assets/sounds/ding.m4a"],!1),this.game.load.audio("kickBlock",["assets/sounds/kick-block.m4a"],!1),this.game.load.audio("starPickup",["assets/sounds/star-pickup.m4a"],!1)):(this.game.load.audio("connectHang",["assets/sounds/connect-hang.ogg"],["assets/sounds/connect-hang.mp3"],!1),this.game.load.audio("fall",["assets/sounds/fall.ogg"],["assets/sounds/fall.wav"],!1),this.game.load.audio("downgrade",["assets/sounds/downgrade.ogg"],["assets/sounds/downgrade.mp3"],!1),this.game.load.audio("poleSwing",["assets/sounds/pole-swing.ogg"],["assets/sounds/pole-swing.mp3"],!1),this.game.load.audio("splash1",["assets/sounds/splash1.ogg"],["assets/sounds/splash1.mp3"],!1),this.game.load.audio("ziplineFull",["assets/sounds/zipline-full.ogg"],["assets/sounds/zipline-full.mp3"],!1),this.game.load.audio("cannonEnter",["assets/sounds/cannon-enter.ogg"],["assets/sounds/cannon-enter.mp3"],!1),this.game.load.audio("wallSlide",["assets/sounds/wall-slide.ogg"],["assets/sounds/wall-slide.mp3"],!1),this.game.load.audio("connect",["assets/sounds/connect.ogg"],["assets/sounds/connect.mp3"],!1),this.game.load.audio("land",["assets/sounds/land.ogg"],["assets/sounds/land.mp3"],!1),this.game.load.audio("slide",["assets/sounds/slide.ogg"],["assets/sounds/slide.mp3"],!1),this.game.load.audio("death1",["assets/sounds/slide.ogg"],["assets/sounds/slide.mp3"],!1),this.game.load.audio("death2",["assets/sounds/death2.ogg"],["assets/sounds/death2.mp3"],!1),this.game.load.audio("electricity",["assets/sounds/electricity.ogg"],["assets/sounds/electricity.mp3"],!1),this.game.load.audio("poleWoosh",["assets/sounds/pole-woosh.ogg"],["assets/sounds/pole-woosh.mp3"],!1),this.game.load.audio("bounce1",["assets/sounds/bounce1.ogg"],["assets/sounds/bounce1.mp3"],!1),this.game.load.audio("cannonFire",["assets/sounds/cannon-fire.ogg"],["assets/sounds/cannon-fire.mp3"],!1),this.game.load.audio("glassSmash",["assets/sounds/glass-smash.ogg"],["assets/sounds/glass-smash.mp3"],!1),this.game.load.audio("fallingBlock",["assets/sounds/falling-block.ogg"],["assets/sounds/falling-block.mp3"],!1),this.game.load.audio("blockDestroy",["assets/sounds/block-destroy.ogg"],["assets/sounds/block-destroy.mp3"],!1),this.game.load.audio("menuSong",["assets/sounds/menu-song.ogg"],["assets/sounds/menu-song.mp3"],!1),this.game.load.audio("vexSong1",["assets/sounds/vex-song-1.ogg"],["assets/sounds/vex-song-1.mp3"],!1),this.game.load.audio("vexSong2",["assets/sounds/vex-song-2.ogg"],["assets/sounds/vex-song-2.mp3"],!1),this.game.load.audio("vexSong3",["assets/sounds/vex-song-3.ogg"],["assets/sounds/vex-song-3.mp3"],!1),this.game.load.audio("vexSong4",["assets/sounds/vex-song-4.ogg"],["assets/sounds/vex-song-4.mp3"],!1),this.game.load.audio("buttonClick",["assets/sounds/button-click.ogg"],["assets/sounds/button-click.mp3"],!1),this.game.load.audio("achievementUnlocked",["assets/sounds/achievement-unlocked.ogg"],["assets/sounds/achievement-unlocked.mp3"],!1),this.game.load.audio("footstep",["assets/sounds/footstep.ogg"],["assets/sounds/footstep.mp3"],!1),this.game.load.audio("laserFire",["assets/sounds/laser-fire.ogg"],["assets/sounds/laser-fire.mp3"],!1),this.game.load.audio("ding",["assets/sounds/ding.ogg"],["assets/sounds/ding.mp3"],!1),this.game.load.audio("kickBlock",["assets/sounds/kick-block.ogg"],["assets/sounds/kick-block.mp3"],!1),this.game.load.audio("starPickup",["assets/sounds/star-pickup.ogg"],["assets/sounds/star-pickup.mp3"],!1)),this.game.load.script("colorMatrixFilter","assets/filters/ColorMatrixFilter.js"),this.game.load.script("blurX","assets/filters/BlurX.js"),this.game.load.script("blurY","assets/filters/BlurY.js"),this.game.load.script("gray","assets/filters/Gray.js"),this.game.load.bitmapFont("grob24","assets/images/fonts/grob24.png","assets/images/fonts/grob24.fnt"),this.game.load.bitmapFont("grobred32","assets/images/fonts/grobred32.png","assets/images/fonts/grobred32.fnt"),this.game.load.image("menuPlayGame","assets/images/buttons/mainmenu/menu-play-game.png"),this.game.load.image("menuOptions","assets/images/buttons/mainmenu/menu-options.png"),this.game.load.image("menuTrophy","assets/images/buttons/mainmenu/menu-trophy.png"),this.game.load.image("vex4Logo","assets/images/buttons/mainmenu/vex4.png"),h5branding.Branding.isAirfi()||this.game.load.image("menuMoreGames","assets/images/buttons/mainmenu/menu-more-games.png"),this.game.load.image("menuLeaderBoard","assets/images/buttons/mainmenu/menu-leaderboard.png"),this.game.load.image("menuAchievements","assets/images/buttons/mainmenu/menu-achievement.png"),this.game.load.image("circleButton","assets/images/circle-button.png"),this.game.load.image("circleLrButton","assets/images/L_R-circle-button.png"),this.game.load.image("jumpButton","assets/images/jump-button.png"),this.game.load.image("crouchButton","assets/images/crouch-button.png"),this.game.load.image("spaceButton","assets/images/space-button.png"),this.game.load.image("normalBtn","assets/images/press-down-normal.png"),this.game.load.image("hardcoreBtn","assets/images/press-down-hard.png"),this.game.load.image("hellNormal","assets/images/text/hell_white_normal.png"),this.game.load.spritesheet("tickboxWhite","assets/images/buttons/tick_white_box.png",132,25,2,0,1),this.game.load.image("hellXL","assets/images/hell_xl.png"),this.game.load.image("clickHellTxt","assets/images/text/act-block/click_hell_text.png"),this.game.load.image("gameTopBG","assets/images/gui/game-top-bg.png"),this.game.load.image("rankTimeBG","assets/images/gui/rank-time-bg.png"),this.game.load.image("timerBG","assets/images/gui/timer-bg.png"),this.game.load.image("levelNameBG","assets/images/gui/level-name-bg.png"),this.game.load.image("rankTimeStaticText","assets/images/gui/rank-time-static-text.png"),this.game.load.image("bronzeText","assets/images/text/ranks/bronze-text.png"),this.game.load.image("silverText","assets/images/text/ranks/silver-text.png"),this.game.load.image("goldText","assets/images/text/ranks/gold-text.png"),this.game.load.image("perfectText","assets/images/text/ranks/perfect-text.png"),this.game.load.image("clearText","assets/images/text/ranks/clear-text.png"),this.game.load.image("noneText","assets/images/text/ranks/none-text.png"),this.game.load.image("stageButtonBG","assets/images/buttons/stage-button-bg.png"),this.game.load.image("stageLabelBG","assets/images/buttons/bottom-label-bg.png"),this.game.load.image("quitLogo","assets/images/buttons/quit-logo.png"),this.game.load.image("trophyLogo","assets/images/buttons/trophy-logo.png"),this.game.load.image("optionsLogo","assets/images/buttons/options-logo.png"),this.game.load.image("resetLogo","assets/images/buttons/reset-logo.png"),this.game.load.image("actSelectLogo","assets/images/buttons/act-select-logo.png"),this.game.load.spritesheet("muteButton","assets/images/buttons/mute-button.png",30,29,2,0,1),this.game.load.image("pauseButton","assets/images/buttons/pause-button.png"),this.game.load.image("actSelectWindow","assets/images/windows/act-select-window.png"),this.game.load.image("actSelectWindowLong","assets/images/windows/pause-window-small.png"),this.game.load.image("actSelectSmall","assets/images/windows/act-select-small.png"),this.game.load.image("closeButton","assets/images/buttons/close-button.png"),this.game.load.image("act1-button","assets/images/buttons/act1-button.png"),this.game.load.image("act2-button","assets/images/buttons/act2-button.png"),this.game.load.image("act3-button","assets/images/buttons/act3-button.png"),this.game.load.image("act4-button","assets/images/buttons/act4-button.png"),this.game.load.image("act5-button","assets/images/buttons/act5-button.png"),this.game.load.image("act6-button","assets/images/buttons/act6-button.png"),this.game.load.image("act7-button","assets/images/buttons/act7-button.png"),this.game.load.image("act8-button","assets/images/buttons/act8-button.png"),this.game.load.image("act9-button","assets/images/buttons/act9-button.png"),this.game.load.image("act10-button","assets/images/buttons/act10-button.png"),this.game.load.image("achievementsWindow","assets/images/windows/achievements-window.png"),this.game.load.image("standardActsButton","assets/images/buttons/standard-acts-button.png"),this.game.load.image("challengeActsButton","assets/images/buttons/challenge-acts-button.png"),this.game.load.image("awesomeStuffButton","assets/images/buttons/awesome-stuff-button.png"),this.game.load.image("completionButton","assets/images/buttons/completion-button.png"),this.game.load.image("achievementProgressBar","assets/images/buttons/achievements/achievement-progress-bar.png"),this.game.load.image("optionsWindow","assets/images/windows/options-window.png"),this.game.load.image("slider","assets/images/buttons/slider.png"),this.game.load.image("slideDrag","assets/images/buttons/slide-drag.png"),this.game.load.spritesheet("tickButton","assets/images/buttons/tick-button.png",132,25,2,0,1),this.game.load.spritesheet("qualityButton","assets/images/buttons/quality-button.png",55,20,3,0,1),this.game.load.spritesheet("qualityButton","assets/images/buttons/quality-button.png",55,20,3,0,1),this.game.load.image("optionsNoClear","assets/images/buttons/options-noclear.png"),this.game.load.image("clearAllButton","assets/images/buttons/clear-all-button.png"),this.game.load.image("pauseWindow","assets/images/windows/pause-window-small.png"),this.game.load.image("parallaxBackground","assets/images/parallaxBackground.png"),this.game.load.image("simpleTransition","assets/images/gui/simple-transition.png"),this.game.load.image("basicBlock","assets/images/blocks/block-basic.png"),this.game.load.spritesheet("basicBlockColors","assets/images/blocks/basic-block-colors.png",99,99,12,0,2),this.game.load.image("leftSlope","assets/images/blocks/left-slope.png"),this.game.load.spritesheet("leftSlopeColors","assets/images/blocks/slope-colors.png",99,99,8,0,2),this.game.load.image("verticalUpBlock","assets/images/blocks/vertical-up-block.png"),this.game.load.image("verticalDownBlock","assets/images/blocks/vertical-down-block.png"),this.game.load.image("horizontalBlock","assets/images/blocks/horizontal-block.png"),this.game.load.image("fallingBlock","assets/images/blocks/falling-block.png"),this.game.load.image("bounceBlock","assets/images/blocks/bounce-block.png"),this.game.load.image("pushBlock","assets/images/blocks/push-block.png"),this.game.load.image("iceBlock","assets/images/blocks/ice-block.png"),this.game.load.image("glassBlock","assets/images/blocks/glass-block.png"),this.game.load.image("speedBlock","assets/images/blocks/speed-block.png"),this.game.load.image("lockBlock","assets/images/blocks/lock-block.png"),this.game.load.image("sparkBlock","assets/images/blocks/spark-block.png"),this.game.load.image("solarBlock","assets/images/blocks/solar-block.png"),this.game.load.image("invisBlock","assets/images/blocks/invis-block.png"),this.game.load.image("invisBlockUp","assets/images/blocks/invis-block-up.png"),this.game.load.image("invisBlockDown","assets/images/blocks/invis-block-down.png"),this.game.load.image("explosiveBlock","assets/images/blocks/explosive-block.png"),this.game.load.spritesheet("blockedWall","assets/images/blocks/blocked-wall.png",65,444,120,0,1),this.game.load.image("actBlock1","assets/images/blocks/act-block-1.png"),this.game.load.image("actBlock2","assets/images/blocks/act-block-2.png"),this.game.load.image("actBlock3","assets/images/blocks/act-block-3.png"),this.game.load.image("actBlock4","assets/images/blocks/act-block-4.png"),this.game.load.image("actBlock5","assets/images/blocks/act-block-5.png"),this.game.load.image("actBlock6","assets/images/blocks/act-block-6.png"),this.game.load.image("actBlock7","assets/images/blocks/act-block-7.png"),this.game.load.image("actBlock8","assets/images/blocks/act-block-8.png"),this.game.load.image("actBlock9","assets/images/blocks/act-block-9.png"),this.game.load.image("actBlock10","assets/images/blocks/act-block-10.png"),this.game.load.image("swimmingPool","assets/images/blocks/swimming-pool.png"),this.game.load.image("leftSlope","assets/images/blocks/left-slope.png"),this.game.load.spritesheet("slope-colors","assets/images/blocks/slope-colors.png",100,100,8),this.game.load.spritesheet("arrowAnimation","assets/images/blocks/arrow-animation.png",100,292,30),this.game.load.image("arrowStatic","assets/images/blocks/arrow-static.png"),this.game.load.spritesheet("checkpoint","assets/images/items/checkpoint.png",24,55,3),this.game.load.spritesheet("checkpointSwimming","assets/images/items/checkpoint-swimming.png",51,62,3,1),this.game.load.image("checkpointText","assets/images/items/checkpoint-text.png"),this.game.load.spritesheet("finishPortal","assets/images/items/finish-portal.png",52,60,60),this.game.load.image("ziplinePole","assets/images/items/zipline-pole.png"),this.game.load.image("pole","assets/images/items/pole.png"),this.game.load.image("poleRedSection","assets/images/items/pole-red-section.png"),this.game.load.image("star","assets/images/items/star.png"),this.game.load.image("hazardStrips","assets/images/items/hazard-strips.png"),this.game.load.image("breatheBlaster","assets/images/items/breathe-blaster.png"),this.game.load.image("windBlaster","assets/images/items/wind-blaster.png"),this.game.load.spritesheet("windFan","assets/images/items/wind-fan.png",13,53,6),this.game.load.image("key","assets/images/items/key.png"),this.game.load.image("timedKey","assets/images/items/timed-key.png"),this.game.load.image("cannonBase","assets/images/items/cannon-base.png"),this.game.load.image("cannonTube","assets/images/items/cannon-tube.png"),this.game.load.image("lightSwitch","assets/images/items/light-switch.png"),this.game.load.image("wire","assets/images/items/wire.png"),this.game.load.image("buzzsaw","assets/images/obstacles/buzzsaw.png"),this.game.load.image("buzzsawOnStick","assets/images/obstacles/buzzsaw-on-stick.png"),this.game.load.image("spike","assets/images/obstacles/spike.png"),this.game.load.image("spike10x","assets/images/obstacles/spike10x.png"),this.game.load.image("spike30x","assets/images/obstacles/spike30x.png"),this.game.load.image("fallingSpike","assets/images/obstacles/falling-spike.png"),this.game.load.image("shurikanSpawner","assets/images/obstacles/shurikan-spawner.png"),this.game.load.spritesheet("shurikanHorizontal","assets/images/obstacles/shurikan-horizontal.png",22,22,3),this.game.load.spritesheet("shurikanHorizontal","assets/images/obstacles/shurikan-horizontal.png",22,22,3),this.game.load.spritesheet("shurikanDispenser","assets/images/obstacles/shurikan-dispenser.png",46,46,25),this.game.load.image("classicLaser","assets/images/obstacles/classic-laser.png"),this.game.load.image("bullet","assets/images/obstacles/laser-bullet.png"),this.game.load.image("quadrant","assets/images/obstacles/quadrant.png"),this.game.load.image("reaper","assets/images/obstacles/reaper.png"),this.game.load.image("spark","assets/images/obstacles/spark.png"),this.game.load.image("pressDown","assets/images/press-down.png"),this.game.load.image("actCheck","assets/images/act-check.png"),this.game.load.image("playerStand","assets/images/player/player-stand.png"),this.game.load.spritesheet("playerSlide","assets/images/player/player-slide.png",37,36,16),this.game.load.spritesheet("playerCrouch","assets/images/player/player-crouch.png",28,33,15,1),this.game.load.spritesheet("playerRun","assets/images/player/player-run.png",30,32,20),this.game.load.spritesheet("playerJump","assets/images/player/player-jump.png",22,39,7),this.game.load.spritesheet("playerJumpDown","assets/images/player/player-jump-down.png",25,40,17),this.game.load.spritesheet("playerJumpFrontFlip","assets/images/player/player-jump-front-flip.png",35,43,19),this.game.load.spritesheet("playerJumpBackFlip","assets/images/player/player-jump-back-flip.png",36,41,22),this.game.load.spritesheet("playerFall","assets/images/player/player-fall.png",23,37,23),this.game.load.spritesheet("playerScale","assets/images/player/player-scale.png",20,39,4),this.game.load.spritesheet("playerHang","assets/images/player/player-hang.png",19,38,20),this.game.load.spritesheet("playerPulley","assets/images/player/player-pulley.png",43,39,35),this.game.load.spritesheet("playerSwing","assets/images/player/player-swing.png",61,72,35),this.game.load.spritesheet("playerPush","assets/images/player/player-push.png",28,33,31),this.game.load.spritesheet("playerKick","assets/images/player/player-kick.png",36,41,28),this.game.load.spritesheet("playerSwimTop","assets/images/player/player-swim-top.png",20,23,8),this.game.load.spritesheet("playerSwimBottom","assets/images/player/player-swim-bottom.png",16,20,28),this.game.load.spritesheet("playerSpawn","assets/images/player/player-spawn.png",16,40,60),this.game.load.image("playerHead","assets/images/player/parts/player-head.png"),this.game.load.image("playerBody","assets/images/player/parts/player-body.png"),this.game.load.image("playerArm","assets/images/player/parts/player-arm.png"),this.game.load.image("playerLeg","assets/images/player/parts/player-leg.png"),this.game.load.image("breatheBlock","assets/images/breathe-block.png"),this.game.load.image("enterLevelText","assets/images/text/act-block/enter-level-text.png"),this.game.load.image("actDownArrow","assets/images/text/act-block/act-down-arrow.png"),this.game.load.image("completedText","assets/images/text/act-block/completed-text.png"),this.game.load.image("hellText","assets/images/text/act-block/hell-text.png"),this.game.load.image("fastestTimeText","assets/images/text/act-block/fastest-time-text.png"),this.game.load.spritesheet("completedIcon","assets/images/text/act-block/completed-icon.png",50,44,2),this.game.load.spritesheet("challengeIcon","assets/images/text/act-block/challenge-icon.png",68,67,2),this.game.load.spritesheet("starIcon","assets/images/text/act-block/star-icon.png",48,46,2),this.game.load.image("vexLogo","assets/images/vex-logo.png"),this.game.load.image("textFade1","assets/images/text/text-fade-1.png"),this.game.load.image("textFade2","assets/images/text/text-fade-2.png"),this.game.load.image("textFade4","assets/images/text/text-fade-4.png"),this.game.load.image("textFade5","assets/images/text/text-fade-5.png"),this.game.load.image("textFade6","assets/images/text/text-fade-6.png"),this.game.load.image("textFade7","assets/images/text/text-fade-7.png"),this.game.load.image("textFade8","assets/images/text/text-fade-8.png"),this.game.load.image("textFade10","assets/images/text/text-fade-10.png"),this.game.load.image("textFade11","assets/images/text/text-fade-11.png"),this.game.load.image("textFade12","assets/images/text/text-fade-12.png"),this.game.load.image("textFade13","assets/images/text/text-fade-13.png"),this.game.load.image("textFade13Mobile","assets/images/text/text-fade-13-mobile.png"),this.game.load.image("textFade14","assets/images/text/text-fade-14.png"),this.game.load.image("textFade15","assets/images/text/text-fade-15.png"),this.game.load.image("textFade16","assets/images/text/text-fade-16.png"),this.game.load.image("textFade17","assets/images/text/text-fade-17.png"),this.game.load.image("textFade18","assets/images/text/text-fade-18.png"),this.game.load.image("textFade19","assets/images/text/text-fade-19.png"),this.game.load.image("textFade20","assets/images/text/text-fade-20.png"),this.game.load.image("textFade21","assets/images/text/text-fade-21.png"),this.game.load.image("textFade22","assets/images/text/text-fade-22.png"),this.game.load.image("textFade23","assets/images/text/text-fade-23.png"),this.game.load.image("textFade24","assets/images/text/text-fade-24.png"),this.game.load.image("textFade25","assets/images/text/text-fade-25.png"),this.game.load.image("textFade26","assets/images/text/text-fade-26.png"),this.game.load.image("textFade27","assets/images/text/text-fade-27.png"),this.game.load.image("textFade28","assets/images/text/text-fade-28.png"),this.game.load.image("textFade29","assets/images/text/text-fade-29.png"),this.game.load.image("textFade30","assets/images/text/text-fade-30.png"),this.game.load.image("textFade31","assets/images/text/text-fade-31.png"),this.game.load.image("textFade32","assets/images/text/text-fade-32.png"),this.game.load.image("textFade33","assets/images/text/text-fade-33.png"),this.game.load.image("textFade34","assets/images/text/text-fade-34.png"),this.game.load.image("textFade35","assets/images/text/text-fade-35.png"),this.game.load.image("textFade36","assets/images/text/text-fade-36.png"),this.game.load.image("textFade37","assets/images/text/text-fade-37.png"),this.game.load.image("textFade38","assets/images/text/text-fade-38.png"),this.game.load.image("textFade39","assets/images/text/text-fade-39.png"),this.game.load.image("textFade40","assets/images/text/text-fade-40.png"),this.game.load.image("textFade41","assets/images/text/text-fade-41.png"),this.game.load.image("textFade42","assets/images/text/text-fade-42.png"),this.game.load.image("textFade43","assets/images/text/text-fade-43.png"),this.game.load.image("textFade44","assets/images/text/text-fade-44.png"),this.game.load.spritesheet("darkOverlay","assets/images/dark-overlay.png",520,520,30),this.game.load.image("achievementUnlocked","assets/images/windows/achievement-unlocked.png"),this.game.load.image("stuckWindow","assets/images/windows/stuck-window.png"),this.game.load.image("backButton","assets/images/buttons/back-button.png");for(var i=1;i<=10;i++)this.game.load.image("act"+i+"Achievement","assets/images/buttons/achievements/act"+i+"-achievement.png");for(i=1;i<=10;i++)this.game.load.image("star"+i+"Achievement","assets/images/buttons/achievements/star"+i+"-achievement.png");for(i=1;i<=9;i++)this.game.load.image("challenge"+i+"Achievement","assets/images/buttons/achievements/challenge"+i+"-achievement.png");for(i=1;i<=7;i++)this.game.load.image("awesome"+i+"Achievement","assets/images/buttons/achievements/awesome"+i+"-achievement.png");for(i=1;i<=4;i++)this.game.load.image("complete"+i+"Achievement","assets/images/buttons/achievements/complete"+i+"-achievement.png");this.game.load.crossOrigin="anonymous",h5branding.Utils.getBrandingDomain()!==h5branding.BrandingDomain.Neutral&&this.game.load.image("branding_logo",h5branding.Branding.brandingLogoUrl)},VexBoot}(),OrientationWindow=function(_super){function OrientationWindow(main,game,layer){var _this=_super.call(this,main,game,layer)||this;return _this.frame=layer.create(0,0,"orientationWindow"),_this.showY=170,_this.init(),_this.closeButton.position.set(450,-30),_this}return __extends(OrientationWindow,_super),OrientationWindow}(VexWindow),StuckPopup=function(){function StuckPopup(main,game,layer){this.main=main,this.game=game,this.layer=layer,this.container=game.add.group(layer),this.container.position.set(game.width/2,-60),this.frame=this.container.create(0,0,"stuckWindow"),this.frame.anchor.set(.5,.5),this.screenX=game.width,this.container.visible=!1,this.showing=!1,this.frame.inputEnabled=!0,this.frame.events.onInputUp.add(function(){window.open(Constants.tutorialURL,"_blank")})}return StuckPopup.prototype.show=function(level){this.level=level,this.container.position.x=this.game.width/2,this.container.position.y=-60,this.container.visible=!0,this.showing=!0},StuckPopup.prototype.hide=function(){this.showing=!1},StuckPopup.prototype.update=function(){if(this.showing){-5<(dist=this.container.position.y-35)?this.container.position.y=35:this.container.position.y-=dist/4}else{var dist=this.container.position.y+60;this.container.position.y<-55?(this.container.position.y=-60,this.container.visible=!1):this.container.position.y-=dist/4}},StuckPopup.prototype.resizeWindow=function(width,height){this.container.position.x=width/2},StuckPopup}(),TipsWindow=function(){function TipsWindow(game,layer){this.canDisplay=!0,this.game=game,this.windowGroup=this.game.add.group(layer),this.makeTip()}return TipsWindow.prototype.makeTip=function(){this.background=this.game.add.sprite(.5*this.game.width,.1*this.game.height,"actSelectSmall"),this.tipText=this.game.add.bitmapText(.5*this.game.width,.1*this.game.height,"grob24","Tip: Don't like the controls? You can switch them in the option menu!",20),this.background.width=1.02*this.game.width,this.background.height=.065*this.game.height,this.background.anchor.set(.5),this.tipText.anchor.set(.5),this.windowGroup.add(this.background),this.windowGroup.add(this.tipText),this.windowGroup.alpha=0,this.resize()},TipsWindow.prototype.animateWindow=function(){this.canDisplay&&(this.canDisplay=!1,this.game.add.tween(this.windowGroup).to({alpha:1},600,Phaser.Easing.Linear.None,!0),this.game.add.tween(this.windowGroup).to({y:100},1e3,Phaser.Easing.Exponential.Out,!0).onComplete.add(this.resetWindow,this))},TipsWindow.prototype.resetWindow=function(){var _this=this;this.game.add.tween(this.windowGroup).to({alpha:0},300,Phaser.Easing.Linear.None,!0,7500).onComplete.add(function(){_this.windowGroup.y-=100,_this.windowGroup.alpha=0,_this.canDisplay=!0},this)},TipsWindow.prototype.resize=function(){this.game.width>this.game.height?(this.background.width=1.02*this.game.width,this.background.height=.065*this.game.height,this.background.x=.5*this.game.width,this.background.y=.1*this.game.height,this.tipText.x=.5*this.game.width,this.tipText.y=.1*this.game.height,this.tipText.fontSize=20):(this.background.width=1.02*this.game.width,this.background.height=.045*this.game.height,this.background.x=.5*this.game.width,this.background.y=.1*this.game.height,this.tipText.x=.5*this.game.width,this.tipText.y=.1*this.game.height,this.tipText.fontSize=15)},TipsWindow}();