text: !function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,runClearTimeout(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}var cachedSetTimeout,cachedClearTimeout,process=module.exports={};!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],2:[function(require,module,exports){function Game(options){if(!(this instanceof Game))return new Game(options);options=options||{},Emitter.call(this),this.paused=!1,this.renderer=options.renderer||{},this.fps=options.config["game.fps"]||60,this.step=1/this.fps;for(let k of["config","events","sounds"])if(options.hasOwnProperty(k))for(let item in options[k])this[k][item]=options[k][item],"sounds"===k&&console.log({item:this[k][item]});this.audioContext=new(window.AudioContext||window.webkitAudioContext)}const Emitter=require("eventemitter2").EventEmitter2,now=require("performance-now"),inherits=require("inherits"),raf=require("raf");module.exports=Game,inherits(Game,Emitter),Game.prototype.config={"game.debug":!1,"game.fps":60,"game.height":document.documentElement.clientHeight||600,"game.width":document.documentElement.clientWidth||600},Game.prototype.events={},Game.prototype.sounds={},Game.prototype.start=function(state){this.paused=!1,this.last=now(),this.time=0,this.accumulator=0,this.emit("start",state),raf(this.frame.bind(this))},Game.prototype.frame=function(time){if(!this.paused){const newTime=now();let dt=(newTime-this.last)/1e3;for(dt>.2&&(dt=this.step),this.accumulator+=dt,this.last=newTime;this.accumulator>=this.step;)this.time+=this.step,this.accumulator-=this.step,this.update(this.step,this.time);this.draw(this.renderer,this.accumulator/this.step),raf(this.frame.bind(this))}},Game.prototype.update=function(interval,time){this.emit("update",interval,time)},Game.prototype.draw=function(renderer,frameState){this.emit("draw",renderer,frameState)},Game.prototype.end=function(state){this.emit("end",state)},Game.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))},Game.prototype.resume=function(){this.paused&&(this.start(),this.emit("resume"))},Game.prototype.resize=function(){this.emit("resize")},Game.prototype.toggle=function(){this.paused?this.resume():this.pause()}},{eventemitter2:3,inherits:4,"performance-now":5,raf:6}],3:[function(require,module,exports){!function(undefined){function init(){this._events={},this._conf&&configure.call(this,this._conf)}function configure(conf){conf?(this._conf=conf,conf.delimiter&&(this.delimiter=conf.delimiter),this._events.maxListeners=conf.maxListeners!==undefined?conf.maxListeners:defaultMaxListeners,conf.wildcard&&(this.wildcard=conf.wildcard),conf.newListener&&(this.newListener=conf.newListener),conf.verboseMemoryLeak&&(this.verboseMemoryLeak=conf.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._events.maxListeners=defaultMaxListeners}function logPossibleMemoryLeak(count,eventName){var errorMsg="(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.";this.verboseMemoryLeak?(errorMsg+=" Event name: %s.",console.error(errorMsg,count,eventName)):console.error(errorMsg,count),console.trace&&console.trace()}function EventEmitter(conf){this._events={},this.newListener=!1,this.verboseMemoryLeak=!1,configure.call(this,conf)}function searchListenerTree(handlers,type,tree,i){if(!tree)return[];var leaf,len,branch,xTree,xxTree,isolatedBranch,endReached,listeners=[],typeLength=type.length,currentType=type[i],nextType=type[i+1];if(i===typeLength&&tree._listeners){if("function"==typeof tree._listeners)return handlers&&handlers.push(tree._listeners),[tree];for(leaf=0,len=tree._listeners.length;leaf<len;leaf++)handlers&&handlers.push(tree._listeners[leaf]);return[tree]}if("*"===currentType||"**"===currentType||tree[currentType]){if("*"===currentType){for(branch in tree)"_listeners"!==branch&&tree.hasOwnProperty(branch)&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],i+1)));return listeners}if("**"===currentType){endReached=i+1===typeLength||i+2===typeLength&&"*"===nextType,endReached&&tree._listeners&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree,typeLength)));for(branch in tree)"_listeners"!==branch&&tree.hasOwnProperty(branch)&&("*"===branch||"**"===branch?(tree[branch]._listeners&&!endReached&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],typeLength))),listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],i))):listeners=branch===nextType?listeners.concat(searchListenerTree(handlers,type,tree[branch],i+2)):listeners.concat(searchListenerTree(handlers,type,tree[branch],i)));return listeners}listeners=listeners.concat(searchListenerTree(handlers,type,tree[currentType],i+1))}if(xTree=tree["*"],xTree&&searchListenerTree(handlers,type,xTree,i+1),xxTree=tree["**"])if(i<typeLength){xxTree._listeners&&searchListenerTree(handlers,type,xxTree,typeLength);for(branch in xxTree)"_listeners"!==branch&&xxTree.hasOwnProperty(branch)&&(branch===nextType?searchListenerTree(handlers,type,xxTree[branch],i+2):branch===currentType?searchListenerTree(handlers,type,xxTree[branch],i+1):(isolatedBranch={},isolatedBranch[branch]=xxTree[branch],searchListenerTree(handlers,type,{"**":isolatedBranch},i+1)))}else xxTree._listeners?searchListenerTree(handlers,type,xxTree,typeLength):xxTree["*"]&&xxTree["*"]._listeners&&searchListenerTree(handlers,type,xxTree["*"],typeLength);return listeners}function growListenerTree(type,listener){type="string"==typeof type?type.split(this.delimiter):type.slice();for(var i=0,len=type.length;i+1<len;i++)if("**"===type[i]&&"**"===type[i+1])return;for(var tree=this.listenerTree,name=type.shift();name!==undefined;){if(tree[name]||(tree[name]={}),tree=tree[name],0===type.length)return tree._listeners?("function"==typeof tree._listeners&&(tree._listeners=[tree._listeners]),tree._listeners.push(listener),!tree._listeners.warned&&this._events.maxListeners>0&&tree._listeners.length>this._events.maxListeners&&(tree._listeners.warned=!0,logPossibleMemoryLeak.call(this,tree._listeners.length,name))):tree._listeners=listener,!0;name=type.shift()}return!0}var isArray=Array.isArray?Array.isArray:function(obj){return"[object Array]"===Object.prototype.toString.call(obj)},defaultMaxListeners=10;EventEmitter.EventEmitter2=EventEmitter,EventEmitter.prototype.delimiter=".",EventEmitter.prototype.setMaxListeners=function(n){n!==undefined&&(this._events||init.call(this),this._events.maxListeners=n,this._conf||(this._conf={}),this._conf.maxListeners=n)},EventEmitter.prototype.event="",EventEmitter.prototype.once=function(event,fn){return this.many(event,1,fn),this},EventEmitter.prototype.many=function(event,ttl,fn){function listener(){0==--ttl&&self.off(event,listener),fn.apply(this,arguments)}var self=this;if("function"!=typeof fn)throw new Error("many only accepts instances of Function");return listener._origin=fn,this.on(event,listener),self},EventEmitter.prototype.emit=function(){this._events||init.call(this);var type=arguments[0];if("newListener"===type&&!this.newListener&&!this._events.newListener)return!1;var args,l,i,j,handler,al=arguments.length;if(this._all&&this._all.length){if(handler=this._all.slice(),al>3)for(args=new Array(al),j=0;j<al;j++)args[j]=arguments[j];for(i=0,l=handler.length;i<l;i++)switch(this.event=type,al){case 1:handler[i].call(this,type);break;case 2:handler[i].call(this,type,arguments[1]);break;case 3:handler[i].call(this,type,arguments[1],arguments[2]);break;default:handler[i].apply(this,args)}}if(this.wildcard){handler=[];var ns="string"==typeof type?type.split(this.delimiter):type.slice();searchListenerTree.call(this,handler,ns,this.listenerTree,0)}else{if("function"==typeof(handler=this._events[type])){switch(this.event=type,al){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];handler.apply(this,args)}return!0}handler&&(handler=handler.slice())}if(handler&&handler.length){if(al>3)for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];for(i=0,l=handler.length;i<l;i++)switch(this.event=type,al){case 1:handler[i].call(this);break;case 2:handler[i].call(this,arguments[1]);break;case 3:handler[i].call(this,arguments[1],arguments[2]);break;default:handler[i].apply(this,args)}return!0}if(!this._all&&"error"===type)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},EventEmitter.prototype.emitAsync=function(){this._events||init.call(this);var type=arguments[0];if("newListener"===type&&!this.newListener&&!this._events.newListener)return Promise.resolve([!1]);var args,l,i,j,handler,promises=[],al=arguments.length;if(this._all){if(al>3)for(args=new Array(al),j=1;j<al;j++)args[j]=arguments[j];for(i=0,l=this._all.length;i<l;i++)switch(this.event=type,al){case 1:promises.push(this._all[i].call(this,type));break;case 2:promises.push(this._all[i].call(this,type,arguments[1]));break;case 3:promises.push(this._all[i].call(this,type,arguments[1],arguments[2]));break;default:promises.push(this._all[i].apply(this,args))}}if(this.wildcard){handler=[];var ns="string"==typeof type?type.split(this.delimiter):type.slice();searchListenerTree.call(this,handler,ns,this.listenerTree,0)}else handler=this._events[type];if("function"==typeof handler)switch(this.event=type,al){case 1:promises.push(handler.call(this));break;case 2:promises.push(handler.call(this,arguments[1]));break;case 3:promises.push(handler.call(this,arguments[1],arguments[2]));break;default:for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];promises.push(handler.apply(this,args))}else if(handler&&handler.length){if(al>3)for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];for(i=0,l=handler.length;i<l;i++)switch(this.event=type,al){case 1:promises.push(handler[i].call(this));break;case 2:promises.push(handler[i].call(this,arguments[1]));break;case 3:promises.push(handler[i].call(this,arguments[1],arguments[2]));break;default:promises.push(handler[i].apply(this,args))}}else if(!this._all&&"error"===type)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(promises)},EventEmitter.prototype.on=function(type,listener){if("function"==typeof type)return this.onAny(type),this;if("function"!=typeof listener)throw new Error("on only accepts instances of Function");return this._events||init.call(this),this.emit("newListener",type,listener),this.wildcard?(growListenerTree.call(this,type,listener),this):(this._events[type]?("function"==typeof this._events[type]&&(this._events[type]=[this._events[type]]),this._events[type].push(listener),!this._events[type].warned&&this._events.maxListeners>0&&this._events[type].length>this._events.maxListeners&&(this._events[type].warned=!0,logPossibleMemoryLeak.call(this,this._events[type].length,type))):this._events[type]=listener,this)},EventEmitter.prototype.onAny=function(fn){if("function"!=typeof fn)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),this._all.push(fn),this},EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prototype.off=function(type,listener){function recursivelyGarbageCollect(root){if(root!==undefined){var keys=Object.keys(root);for(var i in keys){var key=keys[i],obj=root[key];obj instanceof Function||"object"!=typeof obj||null===obj||(Object.keys(obj).length>0&&recursivelyGarbageCollect(root[key]),0===Object.keys(obj).length&&delete root[key])}}}if("function"!=typeof listener)throw new Error("removeListener only takes instances of Function");var handlers,leafs=[];if(this.wildcard){var ns="string"==typeof type?type.split(this.delimiter):type.slice();leafs=searchListenerTree.call(this,null,ns,this.listenerTree,0)}else{if(!this._events[type])return this;handlers=this._events[type],leafs.push({_listeners:handlers})}for(var iLeaf=0;iLeaf<leafs.length;iLeaf++){var leaf=leafs[iLeaf];if(handlers=leaf._listeners,isArray(handlers)){for(var position=-1,i=0,length=handlers.length;i<length;i++)if(handlers[i]===listener||handlers[i].listener&&handlers[i].listener===listener||handlers[i]._origin&&handlers[i]._origin===listener){position=i;break}if(position<0)continue;return this.wildcard?leaf._listeners.splice(position,1):this._events[type].splice(position,1),0===handlers.length&&(this.wildcard?delete leaf._listeners:delete this._events[type]),this.emit("removeListener",type,listener),this}(handlers===listener||handlers.listener&&handlers.listener===listener||handlers._origin&&handlers._origin===listener)&&(this.wildcard?delete leaf._listeners:delete this._events[type],this.emit("removeListener",type,listener))}return recursivelyGarbageCollect(this.listenerTree),this},EventEmitter.prototype.offAny=function(fn){var fns,i=0,l=0;if(fn&&this._all&&this._all.length>0){for(fns=this._all,i=0,l=fns.length;i<l;i++)if(fn===fns[i])return fns.splice(i,1),this.emit("removeListenerAny",fn),this}else{for(fns=this._all,i=0,l=fns.length;i<l;i++)this.emit("removeListenerAny",fns[i]);this._all=[]}return this},EventEmitter.prototype.removeListener=EventEmitter.prototype.off,EventEmitter.prototype.removeAllListeners=function(type){if(0===arguments.length)return!this._events||init.call(this),this;if(this.wildcard)for(var ns="string"==typeof type?type.split(this.delimiter):type.slice(),leafs=searchListenerTree.call(this,null,ns,this.listenerTree,0),iLeaf=0;iLeaf<leafs.length;iLeaf++){var leaf=leafs[iLeaf];leaf._listeners=null}else this._events&&(this._events[type]=null);return this},EventEmitter.prototype.listeners=function(type){if(this.wildcard){var handlers=[],ns="string"==typeof type?type.split(this.delimiter):type.slice();return searchListenerTree.call(this,handlers,ns,this.listenerTree,0),handlers}return this._events||init.call(this),this._events[type]||(this._events[type]=[]),isArray(this._events[type])||(this._events[type]=[this._events[type]]),this._events[type]},EventEmitter.prototype.listenerCount=function(type){return this.listeners(type).length},EventEmitter.prototype.listenersAny=function(){return this._all?this._all:[]},"function"==typeof define&&define.amd?define(function(){return EventEmitter}):"object"==typeof exports?module.exports=EventEmitter:window.EventEmitter2=EventEmitter}()},{}],4:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],5:[function(require,module,exports){(function(process){(function(){var getNanoSeconds,hrtime,loadTime;"undefined"!=typeof performance&&null!==performance&&performance.now?module.exports=function(){return performance.now()}:void 0!==process&&null!==process&&process.hrtime?(module.exports=function(){return(getNanoSeconds()-loadTime)/1e6},hrtime=process.hrtime,getNanoSeconds=function(){var hr;return hr=hrtime(),1e9*hr[0]+hr[1]},loadTime=getNanoSeconds()):Date.now?(module.exports=function(){return Date.now()-loadTime},loadTime=Date.now()):(module.exports=function(){return(new Date).getTime()-loadTime},loadTime=(new Date).getTime())}).call(this)}).call(this,require("_process"))},{_process:1}],6:[function(require,module,exports){(function(global){for(var now=require("performance-now"),root="undefined"==typeof window?global:window,vendors=["moz","webkit"],suffix="AnimationFrame",raf=root["request"+suffix],caf=root["cancel"+suffix]||root["cancelRequest"+suffix],i=0;!raf&&i<vendors.length;i++)raf=root[vendors[i]+"Request"+suffix],caf=root[vendors[i]+"Cancel"+suffix]||root[vendors[i]+"CancelRequest"+suffix];if(!raf||!caf){var last=0,id=0,queue=[];raf=function(callback){if(0===queue.length){var _now=now(),next=Math.max(0,1e3/60-(_now-last));last=next+_now,setTimeout(function(){var cp=queue.slice(0);queue.length=0;for(var i=0;i<cp.length;i++)if(!cp[i].cancelled)try{cp[i].callback(last)}catch(e){setTimeout(function(){throw e},0)}},Math.round(next))}return queue.push({handle:++id,callback:callback,cancelled:!1}),id},caf=function(handle){for(var i=0;i<queue.length;i++)queue[i].handle===handle&&(queue[i].cancelled=!0)}}module.exports=function(fn){return raf.call(root,fn)},module.exports.cancel=function(){caf.apply(root,arguments)},module.exports.polyfill=function(object){object||(object=root),object.requestAnimationFrame=raf,object.cancelAnimationFrame=caf}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"performance-now":7}],7:[function(require,module,exports){(function(process){(function(){var getNanoSeconds,hrtime,loadTime,moduleLoadTime,nodeLoadTime,upTime;"undefined"!=typeof performance&&null!==performance&&performance.now?module.exports=function(){return performance.now()}:void 0!==process&&null!==process&&process.hrtime?(module.exports=function(){return(getNanoSeconds()-nodeLoadTime)/1e6},hrtime=process.hrtime,getNanoSeconds=function(){var hr;return hr=hrtime(),1e9*hr[0]+hr[1]},moduleLoadTime=getNanoSeconds(),upTime=1e9*process.uptime(),nodeLoadTime=moduleLoadTime-upTime):Date.now?(module.exports=function(){return Date.now()-loadTime},loadTime=Date.now()):(module.exports=function(){return(new Date).getTime()-loadTime},loadTime=(new Date).getTime())}).call(this)}).call(this,require("_process"))},{_process:1}]},{},[2]),function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){return o(e[i][1][r]||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r}()({1:[function(require,module,exports){function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(fun){if(cachedSetTimeout===setTimeout)return setTimeout(fun,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(fun,0);try{return cachedSetTimeout(fun,0)}catch(e){try{return cachedSetTimeout.call(null,fun,0)}catch(e){return cachedSetTimeout.call(this,fun,0)}}}function runClearTimeout(marker){if(cachedClearTimeout===clearTimeout)return clearTimeout(marker);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(marker);try{return cachedClearTimeout(marker)}catch(e){try{return cachedClearTimeout.call(null,marker)}catch(e){return cachedClearTimeout.call(this,marker)}}}function cleanUpNextTick(){draining&&currentQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var timeout=runTimeout(cleanUpNextTick);draining=!0;for(var len=queue.length;len;){for(currentQueue=queue,queue=[];++queueIndex<len;)currentQueue&&currentQueue[queueIndex].run();queueIndex=-1,len=queue.length}currentQueue=null,draining=!1,runClearTimeout(timeout)}}function Item(fun,array){this.fun=fun,this.array=array}function noop(){}var cachedSetTimeout,cachedClearTimeout,process=module.exports={};!function(){try{cachedSetTimeout="function"==typeof setTimeout?setTimeout:defaultSetTimout}catch(e){cachedSetTimeout=defaultSetTimout}try{cachedClearTimeout="function"==typeof clearTimeout?clearTimeout:defaultClearTimeout}catch(e){cachedClearTimeout=defaultClearTimeout}}();var currentQueue,queue=[],draining=!1,queueIndex=-1;process.nextTick=function(fun){var args=new Array(arguments.length-1);if(arguments.length>1)for(var i=1;i<arguments.length;i++)args[i-1]=arguments[i];queue.push(new Item(fun,args)),1!==queue.length||draining||runTimeout(drainQueue)},Item.prototype.run=function(){this.fun.apply(null,this.array)},process.title="browser",process.browser=!0,process.env={},process.argv=[],process.version="",process.versions={},process.on=noop,process.addListener=noop,process.once=noop,process.off=noop,process.removeListener=noop,process.removeAllListeners=noop,process.emit=noop,process.prependListener=noop,process.prependOnceListener=noop,process.listeners=function(name){return[]},process.binding=function(name){throw new Error("process.binding is not supported")},process.cwd=function(){return"/"},process.chdir=function(dir){throw new Error("process.chdir is not supported")},process.umask=function(){return 0}},{}],2:[function(require,module,exports){function explodeAsteroid(asteroid){let n=Math.floor(Math.random()*game.config["entity.asteroids.explosion.numbers.max"])+game.config["entity.asteroids.explosion.numbers.min"],sizePerAst=asteroid.size-game.config["entity.asteroids.size.explosion.interval"],angle=-asteroid.angle,options={};options["position.x"]=asteroid.position.x,options["position.y"]=asteroid.position.y,options.size=sizePerAst;for(let _n=0;_n<n;_n++)angle+=360/n*_n,options.angle=angle,addAsteroids(1,options);removeAsteroidById(asteroid.id),explodeWithShard(asteroid),game.sounds["asteroid.explosion"].play()}function explodePlayer(){player&&explodeWithShard(player),player=void 0}function explodeWithShard(entity){return!1}function clearConsole(){console.API,void 0!==console._commandLineAPI?console.API=console._commandLineAPI:void 0!==console._inspectorCommandLineAPI?console.API=console._inspectorCommandLineAPI:void 0!==console.clear&&(console.API=console),console.API.clear()}function initializePlayer(){player={position:{x:game.config["entity.player.position.x"]===-1?canvas.width/2:game.config["entity.player.position.x"],y:game.config["entity.player.position.y"]===-1?canvas.height/2:game.config["entity.player.position.y"]},size:{x:game.config["entity.player.size.x"],y:game.config["entity.player.size.y"]},velocity:{x:game.config["entity.player.velocity.x"],y:game.config["entity.player.velocity.y"]},speed:game.config["entity.player.speed"],friction:game.config["entity.player.friction"],color:game.config["entity.player.color"],angle:game.config["entity.player.angle"],rotation:game.config["entity.player.rotation"]},player.points=[],player.points[0]={x:player.position.x-player.size.x/4,y:player.position.y+player.size.y/4},player.points[1]={x:player.position.x,y:player.position.y-player.size.y/4},player.points[2]={x:player.position.x+player.size.x/4,y:player.position.y+player.size.y/4}}function sound(src){this.sound=document.createElement("audio"),this.sound.src=src,this.sound.setAttribute("preload","auto"),this.sound.setAttribute("controls","none"),this.sound.style.display="none",document.body.appendChild(this.sound),this.play=function(){this.sound.play()},this.stop=function(){this.sound.pause()}}function removeAsteroidById(id){let _i=(ast=>{for(let _a=0,len=asteroids.length;_a<len;_a++)if(ast===asteroids[_a].id)return _a})(id),_len=asteroids.length,_ara=asteroids.slice(0,_i);_ara[_ara.length]=_i!==asteroids.length-1?asteroids.slice(_i+1,_len):[],asteroids=_ara.flat()}const Game=require("./index"),Keyboard=require("crtrdg-keyboard"),tic=require("tic")(),greinerHormann=require("greiner-hormann"),classifyPoints=require("robust-point-in-polygon"),canvas=document.createElement("canvas");document.body.appendChild(canvas);const sqr=x=>x*x,dist2=(v,w)=>sqr(v.x-w.x)+sqr(v.y-w.y),game=new Game({renderer:canvas.getContext("2d"),config:{"entity.asteroid.bounce.friction.x":.995,"entity.asteroid.bounce.friction.y":.995,"entity.asteroids.color":"white","entity.asteroids.explosion.numbers.max":3,"entity.asteroids.explosion.numbers.min":2,"entity.asteroid.explode.angle.marge.min":-5,"entity.asteroid.explode.angle.marge.max":5,"entity.asteroids.friction":1,"entity.asteroids.points.marge.x.min":-17,"entity.asteroids.points.marge.x.max":17,"entity.asteroids.points.marge.y.min":-17,"entity.asteroids.points.marge.y.max":17,"entity.asteroids.points.number.min":5,"entity.asteroids.points.number.max":12,"entity.asteroids.rotation.min":.01,"entity.asteroids.rotation.max":3,"entity.asteroids.size.explosion.interval":15,"entity.asteroids.size.min":16,"entity.asteroids.size.max":52,"entity.asteroid.marge.x":36,"entity.asteroid.marge.y":36,"entity.asteroids.velocity.max":1.2,"entity.asteroids.velocity.min":.3,"entity.asteroids.weight":3,"entity.bullet.size":4,"entity.bullet.speed":13,"entity.bullet.timelife.max":2,"entity.player.angle":0,"entity.player.color":"white","entity.player.friction":.997,"entity.player.position.x":-1,"entity.player.position.y":-1,"entity.player.speed":.2,"entity.player.size.x":24,"entity.player.size.y":24,"entity.player.rotation":3.334,"entity.player.velocity.x":0,"entity.player.velocity.y":0,"entity.player.weight":3,"entity.shards.color":"white","entity.shards.friction":.3,"entity.shards.numbers.min":10,"entity.shards.numbers.max":20,"entity.shards.rotation.min":30,"entity.shards.rotation.max":100,"entity.shards.size.max":12,"entity.shards.size.min":3,"entity.shards.timelife.max":10,"entity.shards.timelife.min":5,"entity.shards.velocity.max":.1,"entity.shards.velocity.min":.001,"game.background":"black","game.debug":!1,"game.fps":120,"game.outterMargin.x":50,"game.outterMargin.y":50,"game.width":-1,"game.height":-1},events:{Z:"player.move.forward",Q:"player.rotate.left",D:"player.rotate.right","<enter>":"player.shoot"},sounds:{"asteroid.explosion":new sound("asteroid.explosion.wav"),"asteroid.impact":new sound("asteroid.impact.wav"),"player.fire":new sound("player.fire.wav")}});game.start(),game.width=canvas.width=game.config["game.width"]===-1?window.innerWidth:game.config["game.width"],game.height=canvas.height=game.config["game.height"]===-1?window.innerHeight:game.config["game.height"],game.on("pause",()=>{console.log("paused")}),game.on("resume",()=>{console.log("resumed")});const keyboard=new Keyboard(game),keysDown=keyboard.keysDown;let player,asteroids=[],bullets=[],shards=[],pressed=[],intersections=[],_tempShard=0;keyboard.on("keydown",key=>{if(!(pressed.indexOf(key)>-1))switch(pressed[pressed.length]=key,key){case"P":game.toggle();break;case"M":initializePlayer();break;case"U":addAsteroids(8);break;case"Y":if(!player)return;explodePlayer();break;case"I":explodeAsteroid(asteroids[0]);break;case"<enter>":if(!player)return;game.sounds["player.fire"].play();let vel=rotate(0,0,0,-game.config["entity.bullet.speed"],-player.angle);const bullet={angle:player.angle,position:{x:player.points[1].x,y:player.points[1].y},size:{x:game.config["entity.bullet.size"],y:game.config["entity.bullet.size"]},velocity:{x:vel[0],y:vel[1]},friction:.999,timelife:0,color:"#fff"};bullets[bullets.length]=bullet;break;case"F10":clearConsole()}}),keyboard.on("keyup",key=>{pressed.splice(pressed.indexOf(key),1)}),game.on("start",()=>{console.log("started",this),window.addEventListener("resize",()=>game.resize())}),game.on("update",(interval,time)=>{tic.tick(interval),player&&updateEntity(interval).player(player);for(let bullet of bullets)updateEntity(interval).bullet(bullet);for(let asteroid of asteroids)updateEntity(interval).asteroid(asteroid);let event;for(let key in keysDown)if(event=game.events[key])switch(event){case"player.move.forward":if(!player)return;let rotated=rotate(0,0,0,-player.speed,-player.angle);player.velocity.x+=rotated[0],player.velocity.y+=rotated[1];break;case"player.rotate.left":if(!player)return;player.angle=(player.angle-player.rotation)%360;for(let p of player.points){let rotated=rotate(player.position.x,player.position.y,p.x,p.y,player.rotation);p.x=rotated[0],p.y=rotated[1]}break;case"player.rotate.right":if(!player)return;player.angle=(player.angle+player.rotation)%360;for(let p of player.points){let rotated=rotate(player.position.x,player.position.y,p.x,p.y,-player.rotation);p.x=rotated[0],p.y=rotated[1]}}}),game.on("draw",(context,delta)=>{function entity(_entity){if(_entity.hasOwnProperty("points")&&_entity.points.length>1){context.beginPath(),context.moveTo(_entity.points[0].x,_entity.points[0].y);for(let point of _entity.points)context.lineTo(point.x,point.y);context.closePath(),context.strokeStyle=_entity.color,context.stroke(),game.config["game.debug"]===!0&&(context.fillStyle="red",context.fillRect(_entity.position.x,_entity.position.y,3,3))}else context.fillStyle=_entity.color,context.fillRect(_entity.position.x,_entity.position.y,_entity.size.x,_entity.size.y)}context.save(),context.clearRect(0,0,canvas.width,canvas.height),function(){context.fillStyle=game.config["game.background"],context.fillRect(0,0,canvas.width,canvas.height)}(),player&&entity(player);for(let bullet of bullets)entity(bullet);for(let asteroid of asteroids)entity(asteroid)
  ;for(let shard of shards)entity(shard);for(;intersections.length>0;)entity(intersections[0]),intersections.pop();context.restore()}),game.on("resize",()=>{game.width=canvas.width=game.config["game.width"]===-1?window.innerWidth:game.config["game.width"],game.height=canvas.height=game.config["game.height"]===-1?window.innerHeight:game.config["game.height"]}),tic.interval(()=>{_tempShard=_tempShard?0:1;for(let sound in game.sounds)game.sounds[sound].stop();for(let bullet of bullets)(bullet.timelife=bullet.timelife+game.step)>game.config["entity.bullet.timelife.max"]&&bullets.shift();for(let shard of shards)(shard.timelife=shard.timelife+game.step)>game.config["entity.shards.timelife.max"]&&shards.shift()},game.step);const rotate=(cx,cy,x,y,angle)=>{const radians=Math.PI/180*angle,cos=Math.cos(radians),sin=Math.sin(radians);return[cos*(x-cx)+sin*(y-cy)+cx,cos*(y-cy)-sin*(x-cx)+cy]},addAsteroids=(num,options={})=>{let to=asteroids.length+num;for(let p=asteroids.length;p<to;p++){let numberOfPoints=-1;for(;numberOfPoints%2!=0;)numberOfPoints=options["points.number"]||Math.floor(Math.random()*(options["points.number.max"]||game.config["entity.asteroids.points.number.max"]))+(options["points.number.min"]||game.config["entity.asteroids.points.number.min"]);const asteroid={id:Math.floor(999999*Math.random())-999999,position:{x:options["position.x"]||Math.floor(Math.random()*(game.width-game.config["entity.asteroid.marge.x"]))+game.config["entity.asteroid.marge.x"],y:options["position.y"]||Math.floor(Math.random()*(game.height-game.config["entity.asteroid.marge.y"]))+game.config["entity.asteroid.marge.y"]},size:options.size||Math.floor(Math.random()*(options["size.max"]||game.config["entity.asteroids.size.max"])+(options["size.min"]||game.config["entity.asteroids.size.min"])),velocity:{x:Math.floor(Math.random()*(options["velocity.max"]||game.config["entity.asteroids.velocity.max"]))+(options["velocity.min"]||game.config["entity.asteroids.velocity.min"]),y:Math.floor(Math.random()*(options["velocity.max"]||game.config["entity.asteroids.velocity.max"]))+(options["velocity.min"]||game.config["entity.asteroids.velocity.min"])},friction:options.friction||game.config["entity.asteroids.friction"],color:options.color||game.config["entity.asteroids.color"],angle:options.angle||Math.floor(359*Math.random())-359,rotation:Math.floor(Math.random()*(options["rotation.max"]||game.config["entity.asteroids.rotation.max"]))-(options["rotation.min"]||game.config["entity.asteroids.rotation.min"])};asteroid.points=[];let angle=0;for(let p=0;p<numberOfPoints;p++){let vector=rotate(0,0,0,-asteroid.size,angle);angle+=360/numberOfPoints%360;let _foo,_x,_y,ratio,posX=0,posY=0,cond=!0;for(;cond;)ratio=asteroid.size/game.config["entity.asteroids.size.max"],posX=vector[0]+(Math.floor(Math.random()*(options["points.marge.x.max"]||game.config["entity.asteroids.points.marge.x.max"]))+(options["points.marge.x.min"]||game.config["entity.asteroids.points.marge.x.min"]))*ratio,posY=vector[1]+(Math.floor(Math.random()*(options["points.marge.y.max"]||game.config["entity.asteroids.points.marge.y.max"]))+(options["points.marge.y.min"]||game.config["entity.asteroids.points.marge.y.min"]))*ratio,_x=asteroid.position.x+posX,_y=asteroid.position.y+posY,_foo=dist2(asteroid.position,{x:_x,y:_y}),cond=_foo<game.config["entity.asteroid.size.min"]||_foo>game.config["entity.asteroid.size.max"];asteroid.points[p]={x:_x,y:_y}}asteroids[p]=asteroid}},bounceAsteroids=(asteroidA,asteroidB,options)=>{const angleA=asteroidA.angle,angleB=asteroidB.angle,stepA=-asteroidA.angle+angleB/2,stepB=-asteroidB.angle+angleA/2;asteroidA.angle=(asteroidA.angle-stepA)%360,asteroidB.angle=(asteroidB.angle-stepB)%360;const vectorA=rotate(0,0,asteroidA.velocity.x,asteroidA.velocity.y,stepA),vectorB=rotate(0,0,asteroidB.velocity.x,asteroidB.velocity.y,stepB);asteroidA.velocity.x=vectorA[0],asteroidA.velocity.y=vectorA[1],asteroidB.velocity.x=vectorB[0],asteroidB.velocity.y=vectorB[1];let _pointsA=asteroidA.points,_pointsB=asteroidB.points;for(let p=0,len=_pointsA.length;p<len;p++)_pointsA[p].x+=asteroidA.velocity.x,_pointsA[p].y+=asteroidA.velocity.y;for(let p=0,len=_pointsB.length;p<len;p++)_pointsB[p].x+=asteroidB.velocity.x,_pointsB[p].y+=asteroidB.velocity.y;let intersection=greinerHormann.intersection(_pointsA,_pointsB);asteroidA.position.x+=vectorA[0],asteroidA.position.y+=vectorA[1],asteroidB.position.x+=vectorB[0],asteroidB.position.y+=vectorB[1],null===intersection&&game.sounds["asteroid.impact"].play()},collisionBulletAsteroid=(bullet=>{for(let asteroid of asteroids){const bar=asteroid.points.map(v=>[v.x,v.y]),foo=classifyPoints(bar,[bullet.position.x,bullet.position.y]);if(foo===-1){explodeAsteroid(asteroid);const _bullets=[];for(let _bullet of bullets)bullet!==_bullet&&(_bullets[_bullets.length]=_bullet);bullets=_bullets;break}}},(bullet,asteroid)=>{if(classifyPoints(asteroid.points.map(v=>[v.x,v.y]),[bullet.position.x,bullet.position.y])===-1){explodeAsteroid(asteroid);const _bullets=[];for(let _bullet of bullets)bullet!==_bullet&&(_bullets[_bullets.length]=_bullet);bullets=_bullets}}),updateEntity=interval=>{return{asteroid:entity=>{(entity.size<game.config["entity.asteroids.size.min"]||entity.size>game.config["entity.asteroids.size.max"])&&removeAsteroidById(entity.id);const posX=_tempShard*game.width*((entity.position.x-entity.size+game.config["entity.asteroids.points.marge.x.min"]<0)-(entity.position.x+entity.size+game.config["entity.asteroids.points.marge.x.max"]>game.width)),posY=_tempShard*game.height*((entity.position.y-entity.size+game.config["entity.asteroids.points.marge.y.min"]<0)-(entity.position.y+entity.size+game.config["entity.asteroids.points.marge.y.max"]>game.height));if(player&&player.hasOwnProperty("points")&&player.points.length>2&&null!==greinerHormann.intersection(entity.points,player.points)&&explodePlayer(),asteroids.length>1)for(let _asteroid of asteroids){if(_asteroid.id===entity.id)break;for(;null!==greinerHormann.intersection(entity.points,_asteroid.points);)bounceAsteroids(entity,_asteroid)}entity.velocity.x*=entity.friction,entity.velocity.y*=entity.friction,entity.position.x+=entity.velocity.x+posX,entity.position.y+=entity.velocity.y+posY;for(let point of entity.points)point.x+=entity.velocity.x+posX,point.y+=entity.velocity.y+posY;for(let bullet of bullets)collisionBulletAsteroid(bullet,entity)},bullet:entity=>{entity.velocity.x*=entity.friction,entity.velocity.y*=entity.friction,entity.position.x+=entity.velocity.x,entity.position.y+=entity.velocity.y},player:entity=>{const posX=game.width*(entity.position.x<0)-game.width*(entity.position.x>game.width),posY=game.height*(entity.position.y<0)-game.height*(entity.position.y>game.height);entity.velocity.x*=entity.friction,entity.velocity.y*=entity.friction,entity.position.x+=entity.velocity.x,entity.position.y+=entity.velocity.y;for(let point of entity.points)point.x+=entity.velocity.x+posX,point.y+=entity.velocity.y+posY;entity.position.x+=posX,entity.position.y+=posY},shard:entity=>{if(entity.velocity.x*=entity.friction.x,entity.velocity.y*=entity.friction.y,entity.position.x+=entity.velocity.x,entity.position.y+=entity.velocity.y,void 0!==entity.points&&entity.points.length>1)for(let point of entity.points)point.x+=entity.velocity.x,point.y+=entity.velocity.y}}};document.addEventListener("DOMContentLoaded",mainEvent=>{initializePlayer(),addAsteroids(12)})},{"./index":3,"crtrdg-keyboard":4,"greiner-hormann":7,"robust-point-in-polygon":13,tic:17}],3:[function(require,module,exports){function Game(options){if(!(this instanceof Game))return new Game(options);options=options||{},Emitter.call(this),this.paused=!1,this.renderer=options.renderer||{},this.fps=options.config["game.fps"]||60,this.step=1/this.fps;for(let k of["config","events","sounds"])if(options.hasOwnProperty(k))for(let item in options[k])this[k][item]=options[k][item],"sounds"===k&&console.log({item:this[k][item]});this.audioContext=new(window.AudioContext||window.webkitAudioContext)}const Emitter=require("eventemitter2").EventEmitter2,now=require("performance-now"),inherits=require("inherits"),raf=require("raf");module.exports=Game,inherits(Game,Emitter),Game.prototype.config={"game.debug":!1,"game.fps":60,"game.height":document.documentElement.clientHeight||600,"game.width":document.documentElement.clientWidth||600},Game.prototype.events={},Game.prototype.sounds={},Game.prototype.start=function(state){this.paused=!1,this.last=now(),this.time=0,this.accumulator=0,this.emit("start",state),raf(this.frame.bind(this))},Game.prototype.frame=function(time){if(!this.paused){const newTime=now();let dt=(newTime-this.last)/1e3;for(dt>.2&&(dt=this.step),this.accumulator+=dt,this.last=newTime;this.accumulator>=this.step;)this.time+=this.step,this.accumulator-=this.step,this.update(this.step,this.time);this.draw(this.renderer,this.accumulator/this.step),raf(this.frame.bind(this))}},Game.prototype.update=function(interval,time){this.emit("update",interval,time)},Game.prototype.draw=function(renderer,frameState){this.emit("draw",renderer,frameState)},Game.prototype.end=function(state){this.emit("end",state)},Game.prototype.pause=function(){this.paused||(this.paused=!0,this.emit("pause"))},Game.prototype.resume=function(){this.paused&&(this.start(),this.emit("resume"))},Game.prototype.resize=function(){this.emit("resize")},Game.prototype.toggle=function(){this.paused?this.resume():this.pause()}},{eventemitter2:6,inherits:8,"performance-now":9,raf:10}],4:[function(require,module,exports){function Keyboard(){if(!(this instanceof Keyboard))return new Keyboard;this.keysDown={},this.initializeListeners()}var EventEmitter=require("eventemitter2").EventEmitter2,inherits=require("inherits"),vkey=require("vkey");module.exports=Keyboard,inherits(Keyboard,EventEmitter),Keyboard.prototype.initializeListeners=function(){var self=this;document.addEventListener("keydown",function(e){self.emit("keydown",vkey[e.keyCode]),self.keysDown[vkey[e.keyCode]]=!0,40!==e.keyCode&&38!==e.keyCode&&37!==e.keyCode&&39!==e.keyCode&&32!==e.keyCode||e.preventDefault()},!1),document.addEventListener("keyup",function(e){self.emit("keyup",vkey[e.keyCode]),delete self.keysDown[vkey[e.keyCode]]},!1)}},{eventemitter2:5,inherits:8,vkey:20}],5:[function(require,module,exports){!function(undefined){function init(){this._events={},this._conf&&configure.call(this,this._conf)}function configure(conf){conf&&(this._conf=conf,conf.delimiter&&(this.delimiter=conf.delimiter),conf.maxListeners&&(this._events.maxListeners=conf.maxListeners),conf.wildcard&&(this.wildcard=conf.wildcard),conf.newListener&&(this.newListener=conf.newListener),this.wildcard&&(this.listenerTree={}))}function EventEmitter(conf){this._events={},this.newListener=!1,configure.call(this,conf)}function searchListenerTree(handlers,type,tree,i){if(!tree)return[];var leaf,len,branch,xTree,xxTree,isolatedBranch,endReached,listeners=[],typeLength=type.length,currentType=type[i],nextType=type[i+1];if(i===typeLength&&tree._listeners){if("function"==typeof tree._listeners)return handlers&&handlers.push(tree._listeners),[tree];for(leaf=0,len=tree._listeners.length;leaf<len;leaf++)handlers&&handlers.push(tree._listeners[leaf]);return[tree]}if("*"===currentType||"**"===currentType||tree[currentType]){if("*"===currentType){for(branch in tree)"_listeners"!==branch&&tree.hasOwnProperty(branch)&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],i+1)));return listeners}if("**"===currentType){endReached=i+1===typeLength||i+2===typeLength&&"*"===nextType,endReached&&tree._listeners&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree,typeLength)));for(branch in tree)"_listeners"!==branch&&tree.hasOwnProperty(branch)&&("*"===branch||"**"===branch?(tree[branch]._listeners&&!endReached&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],typeLength))),listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],i))):listeners=branch===nextType?listeners.concat(searchListenerTree(handlers,type,tree[branch],i+2)):listeners.concat(searchListenerTree(handlers,type,tree[branch],i)));return listeners}listeners=listeners.concat(searchListenerTree(handlers,type,tree[currentType],i+1))}if(xTree=tree["*"],xTree&&searchListenerTree(handlers,type,xTree,i+1),xxTree=tree["**"])if(i<typeLength){xxTree._listeners&&searchListenerTree(handlers,type,xxTree,typeLength);for(branch in xxTree)"_listeners"!==branch&&xxTree.hasOwnProperty(branch)&&(branch===nextType?searchListenerTree(handlers,type,xxTree[branch],i+2):branch===currentType?searchListenerTree(handlers,type,xxTree[branch],i+1):(isolatedBranch={},isolatedBranch[branch]=xxTree[branch],searchListenerTree(handlers,type,{"**":isolatedBranch},i+1)))}else xxTree._listeners?searchListenerTree(handlers,type,xxTree,typeLength):xxTree["*"]&&xxTree["*"]._listeners&&searchListenerTree(handlers,type,xxTree["*"],typeLength);return listeners}function growListenerTree(type,listener){type="string"==typeof type?type.split(this.delimiter):type.slice();for(var i=0,len=type.length;i+1<len;i++)if("**"===type[i]&&"**"===type[i+1])return;for(var tree=this.listenerTree,name=type.shift();name;){if(tree[name]||(tree[name]={}),tree=tree[name],0===type.length){if(tree._listeners){if("function"==typeof tree._listeners)tree._listeners=[tree._listeners,listener];else if(isArray(tree._listeners)&&(tree._listeners.push(listener),!tree._listeners.warned)){var m=defaultMaxListeners;void 0!==this._events.maxListeners&&(m=this._events.maxListeners),m>0&&tree._listeners.length>m&&(tree._listeners.warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",tree._listeners.length),console.trace())}}else tree._listeners=listener;return!0}name=type.shift()}return!0}var isArray=Array.isArray?Array.isArray:function(obj){return"[object Array]"===Object.prototype.toString.call(obj)},defaultMaxListeners=10;EventEmitter.prototype.delimiter=".",EventEmitter.prototype.setMaxListeners=function(n){this._events||init.call(this),this._events.maxListeners=n,this._conf||(this._conf={}),this._conf.maxListeners=n},EventEmitter.prototype.event="",EventEmitter.prototype.once=function(event,fn){return this.many(event,1,fn),this},EventEmitter.prototype.many=function(event,ttl,fn){function listener(){0==--ttl&&self.off(event,listener),fn.apply(this,arguments)}var self=this;if("function"!=typeof fn)throw new Error("many only accepts instances of Function");return listener._origin=fn,this.on(event,listener),self},EventEmitter.prototype.emit=function(){this._events||init.call(this);var type=arguments[0];if("newListener"===type&&!this.newListener&&!this._events.newListener)return!1;if(this._all){for(var l=arguments.length,args=new Array(l-1),i=1;i<l;i++)args[i-1]=arguments[i];for(i=0,l=this._all.length;i<l;i++)this.event=type,this._all[i].apply(this,args)}if("error"===type&&!(this._all||this._events.error||this.wildcard&&this.listenerTree.error))throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");var handler;if(this.wildcard){handler=[];var ns="string"==typeof type?type.split(this.delimiter):type.slice();searchListenerTree.call(this,handler,ns,this.listenerTree,0)}else handler=this._events[type];if("function"==typeof handler){if(this.event=type,1===arguments.length)handler.call(this);else if(arguments.length>1)switch(arguments.length){case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:for(var l=arguments.length,args=new Array(l-1),i=1;i<l;i++)args[i-1]=arguments[i];handler.apply(this,args)}return!0}if(handler){for(var l=arguments.length,args=new Array(l-1),i=1;i<l;i++)args[i-1]=arguments[i];for(var listeners=handler.slice(),i=0,l=listeners.length;i<l;i++)this.event=type,listeners[i].apply(this,args);return listeners.length>0||!!this._all}return!!this._all},EventEmitter.prototype.on=function(type,listener){if("function"==typeof type)return this.onAny(type),this;if("function"!=typeof listener)throw new Error("on only accepts instances of Function");if(this._events||init.call(this),this.emit("newListener",type,listener),this.wildcard)return growListenerTree.call(this,type,listener),this;if(this._events[type]){if("function"==typeof this._events[type])this._events[type]=[this._events[type],listener];else if(isArray(this._events[type])&&(this._events[type].push(listener),!this._events[type].warned)){var m=defaultMaxListeners;void 0!==this._events.maxListeners&&(m=this._events.maxListeners),m>0&&this._events[type].length>m&&(this._events[type].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[type].length),console.trace())}}else this._events[type]=listener;return this},EventEmitter.prototype.onAny=function(fn){if("function"!=typeof fn)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),this._all.push(fn),this},EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prototype.off=function(type,listener){if("function"!=typeof listener)throw new Error("removeListener only takes instances of Function");var handlers,leafs=[];if(this.wildcard){var ns="string"==typeof type?type.split(this.delimiter):type.slice();leafs=searchListenerTree.call(this,null,ns,this.listenerTree,0)}else{if(!this._events[type])return this;handlers=this._events[type],leafs.push({_listeners:handlers})}for(var iLeaf=0;iLeaf<leafs.length;iLeaf++){var leaf=leafs[iLeaf];if(handlers=leaf._listeners,isArray(handlers)){for(var position=-1,i=0,length=handlers.length;i<length;i++)if(handlers[i]===listener||handlers[i].listener&&handlers[i].listener===listener||handlers[i]._origin&&handlers[i]._origin===listener){position=i;break}if(position<0)continue;return this.wildcard?leaf._listeners.splice(position,1):this._events[type].splice(position,1),0===handlers.length&&(this.wildcard?delete leaf._listeners:delete this._events[type]),this}(handlers===listener||handlers.listener&&handlers.listener===listener||handlers._origin&&handlers._origin===listener)&&(this.wildcard?delete leaf._listeners:delete this._events[type])}return this},EventEmitter.prototype.offAny=function(fn){var fns,i=0,l=0;if(fn&&this._all&&this._all.length>0){for(fns=this._all,i=0,l=fns.length;i<l;i++)if(fn===fns[i])return fns.splice(i,1),this}else this._all=[];return this},EventEmitter.prototype.removeListener=EventEmitter.prototype.off,EventEmitter.prototype.removeAllListeners=function(type){if(0===arguments.length)return!this._events||init.call(this),this;if(this.wildcard)for(var ns="string"==typeof type?type.split(this.delimiter):type.slice(),leafs=searchListenerTree.call(this,null,ns,this.listenerTree,0),iLeaf=0;iLeaf<leafs.length;iLeaf++){var leaf=leafs[iLeaf];leaf._listeners=null}else{if(!this._events[type])return this;this._events[type]=null}return this},EventEmitter.prototype.listeners=function(type){if(this.wildcard){var handlers=[],ns="string"==typeof type?type.split(this.delimiter):type.slice();return searchListenerTree.call(this,handlers,ns,this.listenerTree,0),handlers}return this._events||init.call(this),this._events[type]||(this._events[type]=[]),isArray(this._events[type])||(this._events[type]=[this._events[type]]),this._events[type]},EventEmitter.prototype.listenersAny=function(){return this._all?this._all:[]},"function"==typeof define&&define.amd?define(function(){return EventEmitter}):"object"==typeof exports?exports.EventEmitter2=EventEmitter:window.EventEmitter2=EventEmitter}()},{}],6:[function(require,module,exports){!function(undefined){function init(){this._events={},this._conf&&configure.call(this,this._conf)}function configure(conf){conf?(this._conf=conf,conf.delimiter&&(this.delimiter=conf.delimiter),this._events.maxListeners=conf.maxListeners!==undefined?conf.maxListeners:defaultMaxListeners,conf.wildcard&&(this.wildcard=conf.wildcard),conf.newListener&&(this.newListener=conf.newListener),conf.verboseMemoryLeak&&(this.verboseMemoryLeak=conf.verboseMemoryLeak),this.wildcard&&(this.listenerTree={})):this._events.maxListeners=defaultMaxListeners}function logPossibleMemoryLeak(count,eventName){var errorMsg="(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.";this.verboseMemoryLeak?(errorMsg+=" Event name: %s.",console.error(errorMsg,count,eventName)):console.error(errorMsg,count),console.trace&&console.trace()}function EventEmitter(conf){this._events={},this.newListener=!1,this.verboseMemoryLeak=!1,configure.call(this,conf)}function searchListenerTree(handlers,type,tree,i){if(!tree)return[];var leaf,len,branch,xTree,xxTree,isolatedBranch,endReached,listeners=[],typeLength=type.length,currentType=type[i],nextType=type[i+1];if(i===typeLength&&tree._listeners){if("function"==typeof tree._listeners)return handlers&&handlers.push(tree._listeners),[tree];for(leaf=0,len=tree._listeners.length;leaf<len;leaf++)handlers&&handlers.push(tree._listeners[leaf]);return[tree]}if("*"===currentType||"**"===currentType||tree[currentType]){if("*"===currentType){for(branch in tree)"_listeners"!==branch&&tree.hasOwnProperty(branch)&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],i+1)));return listeners}if("**"===currentType){endReached=i+1===typeLength||i+2===typeLength&&"*"===nextType,endReached&&tree._listeners&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree,typeLength)));for(branch in tree)"_listeners"!==branch&&tree.hasOwnProperty(branch)&&("*"===branch||"**"===branch?(tree[branch]._listeners&&!endReached&&(listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],typeLength))),listeners=listeners.concat(searchListenerTree(handlers,type,tree[branch],i))):listeners=branch===nextType?listeners.concat(searchListenerTree(handlers,type,tree[branch],i+2)):listeners.concat(searchListenerTree(handlers,type,tree[branch],i)));return listeners}listeners=listeners.concat(searchListenerTree(handlers,type,tree[currentType],i+1))}if(xTree=tree["*"],xTree&&searchListenerTree(handlers,type,xTree,i+1),xxTree=tree["**"])if(i<typeLength){xxTree._listeners&&searchListenerTree(handlers,type,xxTree,typeLength);for(branch in xxTree)"_listeners"!==branch&&xxTree.hasOwnProperty(branch)&&(branch===nextType?searchListenerTree(handlers,type,xxTree[branch],i+2):branch===currentType?searchListenerTree(handlers,type,xxTree[branch],i+1):(isolatedBranch={},isolatedBranch[branch]=xxTree[branch],searchListenerTree(handlers,type,{"**":isolatedBranch},i+1)))}else xxTree._listeners?searchListenerTree(handlers,type,xxTree,typeLength):xxTree["*"]&&xxTree["*"]._listeners&&searchListenerTree(handlers,type,xxTree["*"],typeLength);return listeners}function growListenerTree(type,listener){type="string"==typeof type?type.split(this.delimiter):type.slice();for(var i=0,len=type.length;i+1<len;i++)if("**"===type[i]&&"**"===type[i+1])return;for(var tree=this.listenerTree,name=type.shift();name!==undefined;){if(tree[name]||(tree[name]={}),tree=tree[name],0===type.length)return tree._listeners?("function"==typeof tree._listeners&&(tree._listeners=[tree._listeners]),tree._listeners.push(listener),!tree._listeners.warned&&this._events.maxListeners>0&&tree._listeners.length>this._events.maxListeners&&(tree._listeners.warned=!0,logPossibleMemoryLeak.call(this,tree._listeners.length,name))):tree._listeners=listener,!0;name=type.shift()}return!0}var isArray=Array.isArray?Array.isArray:function(obj){return"[object Array]"===Object.prototype.toString.call(obj)},defaultMaxListeners=10;EventEmitter.EventEmitter2=EventEmitter,EventEmitter.prototype.delimiter=".",EventEmitter.prototype.setMaxListeners=function(n){n!==undefined&&(this._events||init.call(this),this._events.maxListeners=n,this._conf||(this._conf={}),this._conf.maxListeners=n)},EventEmitter.prototype.event="",EventEmitter.prototype.once=function(event,fn){return this.many(event,1,fn),this},EventEmitter.prototype.many=function(event,ttl,fn){function listener(){0==--ttl&&self.off(event,listener),fn.apply(this,arguments)}var self=this;if("function"!=typeof fn)throw new Error("many only accepts instances of Function");return listener._origin=fn,this.on(event,listener),self},EventEmitter.prototype.emit=function(){this._events||init.call(this);var type=arguments[0];if("newListener"===type&&!this.newListener&&!this._events.newListener)return!1;var args,l,i,j,handler,al=arguments.length;if(this._all&&this._all.length){if(handler=this._all.slice(),al>3)for(args=new Array(al),j=0;j<al;j++)args[j]=arguments[j];for(i=0,l=handler.length;i<l;i++)switch(this.event=type,al){case 1:handler[i].call(this,type);break;case 2:handler[i].call(this,type,arguments[1]);break;case 3:handler[i].call(this,type,arguments[1],arguments[2]);break;default:handler[i].apply(this,args)}}if(this.wildcard){handler=[];var ns="string"==typeof type?type.split(this.delimiter):type.slice();searchListenerTree.call(this,handler,ns,this.listenerTree,0)}else{if("function"==typeof(handler=this._events[type])){switch(this.event=type,al){case 1:handler.call(this);break;case 2:handler.call(this,arguments[1]);break;case 3:handler.call(this,arguments[1],arguments[2]);break;default:for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];handler.apply(this,args)}return!0}handler&&(handler=handler.slice())}if(handler&&handler.length){if(al>3)for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];for(i=0,l=handler.length;i<l;i++)switch(this.event=type,al){case 1:handler[i].call(this);break;case 2:handler[i].call(this,arguments[1]);break;case 3:handler[i].call(this,arguments[1],arguments[2]);break;default:handler[i].apply(this,args)}return!0}if(!this._all&&"error"===type)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},EventEmitter.prototype.emitAsync=function(){this._events||init.call(this);var type=arguments[0];if("newListener"===type&&!this.newListener&&!this._events.newListener)return Promise.resolve([!1]);var args,l,i,j,handler,promises=[],al=arguments.length;if(this._all){if(al>3)for(args=new Array(al),j=1;j<al;j++)args[j]=arguments[j];for(i=0,l=this._all.length;i<l;i++)switch(this.event=type,al){case 1:promises.push(this._all[i].call(this,type));break;case 2:promises.push(this._all[i].call(this,type,arguments[1]));break;case 3:promises.push(this._all[i].call(this,type,arguments[1],arguments[2]));break;default:promises.push(this._all[i].apply(this,args))}}if(this.wildcard){handler=[];var ns="string"==typeof type?type.split(this.delimiter):type.slice();searchListenerTree.call(this,handler,ns,this.listenerTree,0)}else handler=this._events[type];if("function"==typeof handler)switch(this.event=type,al){case 1:promises.push(handler.call(this));break;case 2:promises.push(handler.call(this,arguments[1]));break;case 3:promises.push(handler.call(this,arguments[1],arguments[2]));break;default:for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];promises.push(handler.apply(this,args))}else if(handler&&handler.length){if(al>3)for(args=new Array(al-1),j=1;j<al;j++)args[j-1]=arguments[j];for(i=0,l=handler.length;i<l;i++)switch(this.event=type,al){case 1:promises.push(handler[i].call(this));break;case 2:promises.push(handler[i].call(this,arguments[1]));break;case 3:promises.push(handler[i].call(this,arguments[1],arguments[2]));break;default:promises.push(handler[i].apply(this,args))}}else if(!this._all&&"error"===type)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(promises)},EventEmitter.prototype.on=function(type,listener){if("function"==typeof type)return this.onAny(type),this;if("function"!=typeof listener)throw new Error("on only accepts instances of Function");return this._events||init.call(this),this.emit("newListener",type,listener),this.wildcard?(growListenerTree.call(this,type,listener),this):(this._events[type]?("function"==typeof this._events[type]&&(this._events[type]=[this._events[type]]),this._events[type].push(listener),!this._events[type].warned&&this._events.maxListeners>0&&this._events[type].length>this._events.maxListeners&&(this._events[type].warned=!0,logPossibleMemoryLeak.call(this,this._events[type].length,type))):this._events[type]=listener,this)},EventEmitter.prototype.onAny=function(fn){if("function"!=typeof fn)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),this._all.push(fn),this},EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prototype.off=function(type,listener){function recursivelyGarbageCollect(root){if(root!==undefined){var keys=Object.keys(root);for(var i in keys){var key=keys[i],obj=root[key];obj instanceof Function||"object"!=typeof obj||null===obj||(Object.keys(obj).length>0&&recursivelyGarbageCollect(root[key]),0===Object.keys(obj).length&&delete root[key])}}}if("function"!=typeof listener)throw new Error("removeListener only takes instances of Function");var handlers,leafs=[];if(this.wildcard){var ns="string"==typeof type?type.split(this.delimiter):type.slice();leafs=searchListenerTree.call(this,null,ns,this.listenerTree,0)}else{if(!this._events[type])return this;handlers=this._events[type],leafs.push({_listeners:handlers})}for(var iLeaf=0;iLeaf<leafs.length;iLeaf++){var leaf=leafs[iLeaf];if(handlers=leaf._listeners,isArray(handlers)){for(var position=-1,i=0,length=handlers.length;i<length;i++)if(handlers[i]===listener||handlers[i].listener&&handlers[i].listener===listener||handlers[i]._origin&&handlers[i]._origin===listener){position=i;break}if(position<0)continue;return this.wildcard?leaf._listeners.splice(position,1):this._events[type].splice(position,1),0===handlers.length&&(this.wildcard?delete leaf._listeners:delete this._events[type]),this.emit("removeListener",type,listener),this}(handlers===listener||handlers.listener&&handlers.listener===listener||handlers._origin&&handlers._origin===listener)&&(this.wildcard?delete leaf._listeners:delete this._events[type],this.emit("removeListener",type,listener))}return recursivelyGarbageCollect(this.listenerTree),this},EventEmitter.prototype.offAny=function(fn){var fns,i=0,l=0;if(fn&&this._all&&this._all.length>0){for(fns=this._all,i=0,l=fns.length;i<l;i++)if(fn===fns[i])return fns.splice(i,1),this.emit("removeListenerAny",fn),this}else{for(fns=this._all,i=0,l=fns.length;i<l;i++)this.emit("removeListenerAny",fns[i]);this._all=[]}return this},EventEmitter.prototype.removeListener=EventEmitter.prototype.off,EventEmitter.prototype.removeAllListeners=function(type){if(0===arguments.length)return!this._events||init.call(this),this;if(this.wildcard)for(var ns="string"==typeof type?type.split(this.delimiter):type.slice(),leafs=searchListenerTree.call(this,null,ns,this.listenerTree,0),iLeaf=0;iLeaf<leafs.length;iLeaf++){var leaf=leafs[iLeaf];leaf._listeners=null}else this._events&&(this._events[type]=null);return this},EventEmitter.prototype.listeners=function(type){if(this.wildcard){var handlers=[],ns="string"==typeof type?type.split(this.delimiter):type.slice();return searchListenerTree.call(this,handlers,ns,this.listenerTree,0),handlers}return this._events||init.call(this),this._events[type]||(this._events[type]=[]),isArray(this._events[type])||(this._events[type]=[this._events[type]]),this._events[type]},EventEmitter.prototype.listenerCount=function(type){return this.listeners(type).length},EventEmitter.prototype.listenersAny=function(){return this._all?this._all:[]},"function"==typeof define&&define.amd?define(function(){return EventEmitter}):"object"==typeof exports?module.exports=EventEmitter:window.EventEmitter2=EventEmitter}()},{}],7:[function(require,module,exports){!function(global,factory){
  "object"==typeof exports&&void 0!==module?factory(exports):"function"==typeof define&&define.amd?define(["exports"],factory):factory(global.greinerHormann={})}(this,function(exports){"use strict";function boolean(polygonA,polygonB,eA,eB){var source=new Polygon(polygonA),clip=new Polygon(polygonB);return source.clip(clip,eA,eB)}function union(polygonA,polygonB){return boolean(polygonA,polygonB,!1,!1)}function intersection(polygonA,polygonB){return boolean(polygonA,polygonB,!0,!0)}function diff(polygonA,polygonB){return boolean(polygonA,polygonB,!1,!0)}var Vertex=function(x,y){1===arguments.length&&(Array.isArray(x)?(y=x[1],x=x[0]):(y=x.y,x=x.x)),this.x=x,this.y=y,this.next=null,this.prev=null,this._corresponding=null,this._distance=0,this._isEntry=!0,this._isIntersection=!1,this._visited=!1};Vertex.createIntersection=function(x,y,distance){var vertex=new Vertex(x,y);return vertex._distance=distance,vertex._isIntersection=!0,vertex._isEntry=!1,vertex},Vertex.prototype.visit=function(){this._visited=!0,null===this._corresponding||this._corresponding._visited||this._corresponding.visit()},Vertex.prototype.equals=function(v){return this.x===v.x&&this.y===v.y},Vertex.prototype.isInside=function(poly){var oddNodes=!1,vertex=poly.first,next=vertex.next,x=this.x,y=this.y;do(vertex.y<y&&next.y>=y||next.y<y&&vertex.y>=y)&&(vertex.x<=x||next.x<=x)&&(oddNodes^=vertex.x+(y-vertex.y)/(next.y-vertex.y)*(next.x-vertex.x)<x),vertex=vertex.next,next=vertex.next||poly.first;while(!vertex.equals(poly.first))return oddNodes};var Intersection=function(s1,s2,c1,c2){this.x=0,this.y=0,this.toSource=0,this.toClip=0;var d=(c2.y-c1.y)*(s2.x-s1.x)-(c2.x-c1.x)*(s2.y-s1.y);0!==d&&(this.toSource=((c2.x-c1.x)*(s1.y-c1.y)-(c2.y-c1.y)*(s1.x-c1.x))/d,this.toClip=((s2.x-s1.x)*(s1.y-c1.y)-(s2.y-s1.y)*(s1.x-c1.x))/d,this.valid()&&(this.x=s1.x+this.toSource*(s2.x-s1.x),this.y=s1.y+this.toSource*(s2.y-s1.y)))};Intersection.prototype.valid=function(){return 0<this.toSource&&this.toSource<1&&0<this.toClip&&this.toClip<1};var Polygon=function(p,arrayVertices){var this$1=this;this.first=null,this.vertices=0,this._lastUnprocessed=null,this._arrayVertices=void 0===arrayVertices?Array.isArray(p[0]):arrayVertices;for(var i=0,len=p.length;i<len;i++)this$1.addVertex(new Vertex(p[i]))};Polygon.prototype.addVertex=function(vertex){if(null===this.first)this.first=vertex,this.first.next=vertex,this.first.prev=vertex;else{var next=this.first,prev=next.prev;next.prev=vertex,vertex.next=next,vertex.prev=prev,prev.next=vertex}this.vertices++},Polygon.prototype.insertVertex=function(vertex,start,end){for(var prev,curr=start;!curr.equals(end)&&curr._distance<vertex._distance;)curr=curr.next;vertex.next=curr,prev=curr.prev,vertex.prev=prev,prev.next=vertex,curr.prev=vertex,this.vertices++},Polygon.prototype.getNext=function(v){for(var c=v;c._isIntersection;)c=c.next;return c},Polygon.prototype.getFirstIntersect=function(){var v=this._firstIntersect||this.first;do{if(v._isIntersection&&!v._visited)break;v=v.next}while(!v.equals(this.first))return this._firstIntersect=v,v},Polygon.prototype.hasUnprocessed=function(){var this$1=this,v=this._lastUnprocessed||this.first;do{if(v._isIntersection&&!v._visited)return this$1._lastUnprocessed=v,!0;v=v.next}while(!v.equals(this.first))return this._lastUnprocessed=null,!1},Polygon.prototype.getPoints=function(){var points=[],v=this.first;if(this._arrayVertices)do points.push([v.x,v.y]),v=v.next;while(v!==this.first)else do points.push({x:v.x,y:v.y}),v=v.next;while(v!==this.first)return points},Polygon.prototype.clip=function(clip$1,sourceForwards,clipForwards){var sourceInClip,clipInSource,this$1=this,sourceVertex=this.first,clipVertex=clip$1.first,isUnion=!sourceForwards&&!clipForwards,isIntersection=sourceForwards&&clipForwards;do{if(!sourceVertex._isIntersection)do{if(!clipVertex._isIntersection){var i=new Intersection(sourceVertex,this$1.getNext(sourceVertex.next),clipVertex,clip$1.getNext(clipVertex.next));if(i.valid()){var sourceIntersection=Vertex.createIntersection(i.x,i.y,i.toSource),clipIntersection=Vertex.createIntersection(i.x,i.y,i.toClip);sourceIntersection._corresponding=clipIntersection,clipIntersection._corresponding=sourceIntersection,this$1.insertVertex(sourceIntersection,sourceVertex,this$1.getNext(sourceVertex.next)),clip$1.insertVertex(clipIntersection,clipVertex,clip$1.getNext(clipVertex.next))}}clipVertex=clipVertex.next}while(!clipVertex.equals(clip$1.first))sourceVertex=sourceVertex.next}while(!sourceVertex.equals(this.first))sourceVertex=this.first,clipVertex=clip$1.first,sourceInClip=sourceVertex.isInside(clip$1),clipInSource=clipVertex.isInside(this),sourceForwards^=sourceInClip,clipForwards^=clipInSource;do sourceVertex._isIntersection&&(sourceVertex._isEntry=sourceForwards,sourceForwards=!sourceForwards),sourceVertex=sourceVertex.next;while(!sourceVertex.equals(this.first))do clipVertex._isIntersection&&(clipVertex._isEntry=clipForwards,clipForwards=!clipForwards),clipVertex=clipVertex.next;while(!clipVertex.equals(clip$1.first))for(var list=[];this.hasUnprocessed();){var current=this$1.getFirstIntersect(),clipped=new Polygon([],this$1._arrayVertices);clipped.addVertex(new Vertex(current.x,current.y));do{if(current.visit(),current._isEntry)do current=current.next,clipped.addVertex(new Vertex(current.x,current.y));while(!current._isIntersection)else do current=current.prev,clipped.addVertex(new Vertex(current.x,current.y));while(!current._isIntersection)current=current._corresponding}while(!current._visited)list.push(clipped.getPoints())}return 0===list.length&&(isUnion?sourceInClip?list.push(clip$1.getPoints()):clipInSource?list.push(this.getPoints()):list.push(this.getPoints(),clip$1.getPoints()):isIntersection?sourceInClip?list.push(this.getPoints()):clipInSource&&list.push(clip$1.getPoints()):sourceInClip?list.push(clip$1.getPoints(),this.getPoints()):clipInSource?list.push(this.getPoints(),clip$1.getPoints()):list.push(this.getPoints()),0===list.length&&(list=null)),list};var clip=boolean;exports.union=union,exports.intersection=intersection,exports.diff=diff,exports.clip=clip,Object.defineProperty(exports,"__esModule",{value:!0})})},{}],8:[function(require,module,exports){"function"==typeof Object.create?module.exports=function(ctor,superCtor){ctor.super_=superCtor,ctor.prototype=Object.create(superCtor.prototype,{constructor:{value:ctor,enumerable:!1,writable:!0,configurable:!0}})}:module.exports=function(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype,ctor.prototype=new TempCtor,ctor.prototype.constructor=ctor}},{}],9:[function(require,module,exports){(function(process){(function(){var getNanoSeconds,hrtime,loadTime;"undefined"!=typeof performance&&null!==performance&&performance.now?module.exports=function(){return performance.now()}:void 0!==process&&null!==process&&process.hrtime?(module.exports=function(){return(getNanoSeconds()-loadTime)/1e6},hrtime=process.hrtime,getNanoSeconds=function(){var hr;return hr=hrtime(),1e9*hr[0]+hr[1]},loadTime=getNanoSeconds()):Date.now?(module.exports=function(){return Date.now()-loadTime},loadTime=Date.now()):(module.exports=function(){return(new Date).getTime()-loadTime},loadTime=(new Date).getTime())}).call(this)}).call(this,require("_process"))},{_process:1}],10:[function(require,module,exports){(function(global){for(var now=require("performance-now"),root="undefined"==typeof window?global:window,vendors=["moz","webkit"],suffix="AnimationFrame",raf=root["request"+suffix],caf=root["cancel"+suffix]||root["cancelRequest"+suffix],i=0;!raf&&i<vendors.length;i++)raf=root[vendors[i]+"Request"+suffix],caf=root[vendors[i]+"Cancel"+suffix]||root[vendors[i]+"CancelRequest"+suffix];if(!raf||!caf){var last=0,id=0,queue=[];raf=function(callback){if(0===queue.length){var _now=now(),next=Math.max(0,1e3/60-(_now-last));last=next+_now,setTimeout(function(){var cp=queue.slice(0);queue.length=0;for(var i=0;i<cp.length;i++)if(!cp[i].cancelled)try{cp[i].callback(last)}catch(e){setTimeout(function(){throw e},0)}},Math.round(next))}return queue.push({handle:++id,callback:callback,cancelled:!1}),id},caf=function(handle){for(var i=0;i<queue.length;i++)queue[i].handle===handle&&(queue[i].cancelled=!0)}}module.exports=function(fn){return raf.call(root,fn)},module.exports.cancel=function(){caf.apply(root,arguments)},module.exports.polyfill=function(object){object||(object=root),object.requestAnimationFrame=raf,object.cancelAnimationFrame=caf}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"performance-now":11}],11:[function(require,module,exports){(function(process){(function(){var getNanoSeconds,hrtime,loadTime,moduleLoadTime,nodeLoadTime,upTime;"undefined"!=typeof performance&&null!==performance&&performance.now?module.exports=function(){return performance.now()}:void 0!==process&&null!==process&&process.hrtime?(module.exports=function(){return(getNanoSeconds()-nodeLoadTime)/1e6},hrtime=process.hrtime,getNanoSeconds=function(){var hr;return hr=hrtime(),1e9*hr[0]+hr[1]},moduleLoadTime=getNanoSeconds(),upTime=1e9*process.uptime(),nodeLoadTime=moduleLoadTime-upTime):Date.now?(module.exports=function(){return Date.now()-loadTime},loadTime=Date.now()):(module.exports=function(){return(new Date).getTime()-loadTime},loadTime=(new Date).getTime())}).call(this)}).call(this,require("_process"))},{_process:1}],12:[function(require,module,exports){"use strict";function cofactor(m,c){for(var result=new Array(m.length-1),i=1;i<m.length;++i)for(var r=result[i-1]=new Array(m.length-1),j=0,k=0;j<m.length;++j)j!==c&&(r[k++]=m[i][j]);return result}function matrix(n){for(var result=new Array(n),i=0;i<n;++i){result[i]=new Array(n);for(var j=0;j<n;++j)result[i][j]=["m",j,"[",n-i-1,"]"].join("")}return result}function sign(n){return 1&n?"-":""}function generateSum(expr){if(1===expr.length)return expr[0];if(2===expr.length)return["sum(",expr[0],",",expr[1],")"].join("");var m=expr.length>>1;return["sum(",generateSum(expr.slice(0,m)),",",generateSum(expr.slice(m)),")"].join("")}function determinant(m){if(2===m.length)return[["sum(prod(",m[0][0],",",m[1][1],"),prod(-",m[0][1],",",m[1][0],"))"].join("")];for(var expr=[],i=0;i<m.length;++i)expr.push(["scale(",generateSum(determinant(cofactor(m,i))),",",sign(i),m[0][i],")"].join(""));return expr}function orientation(n){for(var pos=[],neg=[],m=matrix(n),args=[],i=0;i<n;++i)0==(1&i)?pos.push.apply(pos,determinant(cofactor(m,i))):neg.push.apply(neg,determinant(cofactor(m,i))),args.push("m"+i);var posExpr=generateSum(pos),negExpr=generateSum(neg),funcName="orientation"+n+"Exact",code=["function ",funcName,"(",args.join(),"){var p=",posExpr,",n=",negExpr,",d=sub(p,n);return d[d.length-1];};return ",funcName].join("");return new Function("sum","prod","scale","sub",code)(robustSum,twoProduct,robustScale,robustSubtract)}function slowOrient(args){var proc=CACHED[args.length];return proc||(proc=CACHED[args.length]=orientation(args.length)),proc.apply(void 0,args)}var twoProduct=require("two-product"),robustSum=require("robust-sum"),robustScale=require("robust-scale"),robustSubtract=require("robust-subtract"),NUM_EXPAND=5,orientation3Exact=orientation(3),orientation4Exact=orientation(4),CACHED=[function(){return 0},function(){return 0},function(a,b){return b[0]-a[0]},function(a,b,c){var s,l=(a[1]-c[1])*(b[0]-c[0]),r=(a[0]-c[0])*(b[1]-c[1]),det=l-r;if(l>0){if(r<=0)return det;s=l+r}else{if(!(l<0))return det;if(r>=0)return det;s=-(l+r)}var tol=3.3306690738754716e-16*s;return det>=tol||det<=-tol?det:orientation3Exact(a,b,c)},function(a,b,c,d){var adx=a[0]-d[0],bdx=b[0]-d[0],cdx=c[0]-d[0],ady=a[1]-d[1],bdy=b[1]-d[1],cdy=c[1]-d[1],adz=a[2]-d[2],bdz=b[2]-d[2],cdz=c[2]-d[2],bdxcdy=bdx*cdy,cdxbdy=cdx*bdy,cdxady=cdx*ady,adxcdy=adx*cdy,adxbdy=adx*bdy,bdxady=bdx*ady,det=adz*(bdxcdy-cdxbdy)+bdz*(cdxady-adxcdy)+cdz*(adxbdy-bdxady),permanent=(Math.abs(bdxcdy)+Math.abs(cdxbdy))*Math.abs(adz)+(Math.abs(cdxady)+Math.abs(adxcdy))*Math.abs(bdz)+(Math.abs(adxbdy)+Math.abs(bdxady))*Math.abs(cdz),tol=7.771561172376103e-16*permanent;return det>tol||-det>tol?det:orientation4Exact(a,b,c,d)}];!function(){for(;CACHED.length<=NUM_EXPAND;)CACHED.push(orientation(CACHED.length));for(var args=[],procArgs=["slow"],i=0;i<=NUM_EXPAND;++i)args.push("a"+i),procArgs.push("o"+i);for(var code=["function getOrientation(",args.join(),"){switch(arguments.length){case 0:case 1:return 0;"],i=2;i<=NUM_EXPAND;++i)code.push("case ",i,":return o",i,"(",args.slice(0,i).join(),");");code.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation"),procArgs.push(code.join(""));var proc=Function.apply(void 0,procArgs);module.exports=proc.apply(void 0,[slowOrient].concat(CACHED));for(var i=0;i<=NUM_EXPAND;++i)module.exports[i]=CACHED[i]}()},{"robust-scale":14,"robust-subtract":15,"robust-sum":16,"two-product":18}],13:[function(require,module,exports){function robustPointInPolygon(vs,point){for(var x=point[0],y=point[1],n=vs.length,inside=1,lim=n,i=0,j=n-1;i<lim;j=i++){var a=vs[i],b=vs[j],yi=a[1],yj=b[1];if(yj<yi){if(yj<y&&y<yi){var s=orient(a,b,point);if(0===s)return 0;inside^=0<s|0}else if(y===yi){var c=vs[(i+1)%n],yk=c[1];if(yi<yk){var s=orient(a,b,point);if(0===s)return 0;inside^=0<s|0}}}else if(yi<yj){if(yi<y&&y<yj){var s=orient(a,b,point);if(0===s)return 0;inside^=s<0|0}else if(y===yi){var c=vs[(i+1)%n],yk=c[1];if(yk<yi){var s=orient(a,b,point);if(0===s)return 0;inside^=s<0|0}}}else if(y===yi){var x0=Math.min(a[0],b[0]),x1=Math.max(a[0],b[0]);if(0===i){for(;j>0;){var k=(j+n-1)%n,p=vs[k];if(p[1]!==y)break;var px=p[0];x0=Math.min(x0,px),x1=Math.max(x1,px),j=k}if(0===j)return x0<=x&&x<=x1?0:1;lim=j+1}for(var y0=vs[(j+n-1)%n][1];i+1<lim;){var p=vs[i+1];if(p[1]!==y)break;var px=p[0];x0=Math.min(x0,px),x1=Math.max(x1,px),i+=1}if(x0<=x&&x<=x1)return 0;var y1=vs[(i+1)%n][1];x<x0&&y0<y!=y1<y&&(inside^=1)}}return 2*inside-1}module.exports=robustPointInPolygon;var orient=require("robust-orientation")},{"robust-orientation":12}],14:[function(require,module,exports){"use strict";function scaleLinearExpansion(e,scale){var n=e.length;if(1===n){var ts=twoProduct(e[0],scale);return ts[0]?ts:[ts[1]]}var g=new Array(2*n),q=[.1,.1],t=[.1,.1],count=0;twoProduct(e[0],scale,q),q[0]&&(g[count++]=q[0]);for(var i=1;i<n;++i){twoProduct(e[i],scale,t);twoSum(q[1],t[0],q),q[0]&&(g[count++]=q[0]);var a=t[1],b=q[1],x=a+b,bv=x-a,y=b-bv;q[1]=x,y&&(g[count++]=y)}return q[1]&&(g[count++]=q[1]),0===count&&(g[count++]=0),g.length=count,g}var twoProduct=require("two-product"),twoSum=require("two-sum");module.exports=scaleLinearExpansion},{"two-product":18,"two-sum":19}],15:[function(require,module,exports){"use strict";function scalarScalar(a,b){var x=a+b,bv=x-a,av=x-bv,br=b-bv,ar=a-av,y=ar+br;return y?[y,x]:[x]}function robustSubtract(e,f){var ne=0|e.length,nf=0|f.length;if(1===ne&&1===nf)return scalarScalar(e[0],-f[0]);var a,b,n=ne+nf,g=new Array(n),count=0,eptr=0,fptr=0,abs=Math.abs,ei=e[eptr],ea=abs(ei),fi=-f[fptr],fa=abs(fi);ea<fa?(b=ei,(eptr+=1)<ne&&(ei=e[eptr],ea=abs(ei))):(b=fi,(fptr+=1)<nf&&(fi=-f[fptr],fa=abs(fi))),eptr<ne&&ea<fa||fptr>=nf?(a=ei,(eptr+=1)<ne&&(ei=e[eptr],ea=abs(ei))):(a=fi,(fptr+=1)<nf&&(fi=-f[fptr],fa=abs(fi)));for(var _x,_bv,_av,_br,_ar,x=a+b,bv=x-a,y=b-bv,q0=y,q1=x;eptr<ne&&fptr<nf;)ea<fa?(a=ei,(eptr+=1)<ne&&(ei=e[eptr],ea=abs(ei))):(a=fi,(fptr+=1)<nf&&(fi=-f[fptr],fa=abs(fi))),b=q0,x=a+b,bv=x-a,y=b-bv,y&&(g[count++]=y),_x=q1+x,_bv=_x-q1,_av=_x-_bv,_br=x-_bv,_ar=q1-_av,q0=_ar+_br,q1=_x;for(;eptr<ne;)a=ei,b=q0,x=a+b,bv=x-a,y=b-bv,y&&(g[count++]=y),_x=q1+x,_bv=_x-q1,_av=_x-_bv,_br=x-_bv,_ar=q1-_av,q0=_ar+_br,q1=_x,(eptr+=1)<ne&&(ei=e[eptr]);for(;fptr<nf;)a=fi,b=q0,x=a+b,bv=x-a,y=b-bv,y&&(g[count++]=y),_x=q1+x,_bv=_x-q1,_av=_x-_bv,_br=x-_bv,_ar=q1-_av,q0=_ar+_br,q1=_x,(fptr+=1)<nf&&(fi=-f[fptr]);return q0&&(g[count++]=q0),q1&&(g[count++]=q1),count||(g[count++]=0),g.length=count,g}module.exports=robustSubtract},{}],16:[function(require,module,exports){"use strict";function scalarScalar(a,b){var x=a+b,bv=x-a,av=x-bv,br=b-bv,ar=a-av,y=ar+br;return y?[y,x]:[x]}function linearExpansionSum(e,f){var ne=0|e.length,nf=0|f.length;if(1===ne&&1===nf)return scalarScalar(e[0],f[0]);var a,b,n=ne+nf,g=new Array(n),count=0,eptr=0,fptr=0,abs=Math.abs,ei=e[eptr],ea=abs(ei),fi=f[fptr],fa=abs(fi);ea<fa?(b=ei,(eptr+=1)<ne&&(ei=e[eptr],ea=abs(ei))):(b=fi,(fptr+=1)<nf&&(fi=f[fptr],fa=abs(fi))),eptr<ne&&ea<fa||fptr>=nf?(a=ei,(eptr+=1)<ne&&(ei=e[eptr],ea=abs(ei))):(a=fi,(fptr+=1)<nf&&(fi=f[fptr],fa=abs(fi)));for(var _x,_bv,_av,_br,_ar,x=a+b,bv=x-a,y=b-bv,q0=y,q1=x;eptr<ne&&fptr<nf;)ea<fa?(a=ei,(eptr+=1)<ne&&(ei=e[eptr],ea=abs(ei))):(a=fi,(fptr+=1)<nf&&(fi=f[fptr],fa=abs(fi))),b=q0,x=a+b,bv=x-a,y=b-bv,y&&(g[count++]=y),_x=q1+x,_bv=_x-q1,_av=_x-_bv,_br=x-_bv,_ar=q1-_av,q0=_ar+_br,q1=_x;for(;eptr<ne;)a=ei,b=q0,x=a+b,bv=x-a,y=b-bv,y&&(g[count++]=y),_x=q1+x,_bv=_x-q1,_av=_x-_bv,_br=x-_bv,_ar=q1-_av,q0=_ar+_br,q1=_x,(eptr+=1)<ne&&(ei=e[eptr]);for(;fptr<nf;)a=fi,b=q0,x=a+b,bv=x-a,y=b-bv,y&&(g[count++]=y),_x=q1+x,_bv=_x-q1,_av=_x-_bv,_br=x-_bv,_ar=q1-_av,q0=_ar+_br,q1=_x,(fptr+=1)<nf&&(fi=f[fptr]);return q0&&(g[count++]=q0),q1&&(g[count++]=q1),count||(g[count++]=0),g.length=count,g}module.exports=linearExpansionSum},{}],17:[function(require,module,exports){function Tic(){this._things=[],this._dt=-1}var now=function(){var p=window.performance||Object.create(null);return function(){return(p.now||p.webkitNow||p.mozNow||p.msNow||p.oNow||function(){return(new Date).getTime()}).call(p)}}();module.exports=function(){return new Tic},Tic.prototype._stack=function(thing){var self=this;self._things.push(thing);var i=self._things.length-1;return function(){delete self._things[i]}},Tic.prototype.interval=Tic.prototype.setInterval=function(fn,at){return this._stack({fn:fn,at:at,args:Array.prototype.slice.call(arguments,2),elapsed:0,once:!1})},Tic.prototype.timeout=Tic.prototype.setTimeout=function(fn,at){return this._stack({fn:fn,at:at,args:Array.prototype.slice.call(arguments,2),elapsed:0,once:!0})},Tic.prototype.tick=function(dt){var self=this;if(arguments.length<1){var t=now();this._dt<0&&(this._dt=t),dt=t-this._dt,this._dt=t}self._things.forEach(function(thing,i){thing.elapsed+=dt,thing.elapsed>thing.at&&(thing.elapsed-=thing.at,thing.fn.apply(thing.fn,thing.args||[]),thing.once&&delete self._things[i])})}},{}],18:[function(require,module,exports){"use strict";function twoProduct(a,b,result){var x=a*b,c=SPLITTER*a,abig=c-a,ahi=c-abig,alo=a-ahi,d=SPLITTER*b,bbig=d-b,bhi=d-bbig,blo=b-bhi,err1=x-ahi*bhi,err2=err1-alo*bhi,err3=err2-ahi*blo,y=alo*blo-err3;return result?(result[0]=y,result[1]=x,result):[y,x]}module.exports=twoProduct;var SPLITTER=+(Math.pow(2,27)+1)},{}],19:[function(require,module,exports){"use strict";function fastTwoSum(a,b,result){var x=a+b,bv=x-a,av=x-bv,br=b-bv,ar=a-av;return result?(result[0]=ar+br,result[1]=x,result):[ar+br,x]}module.exports=fastTwoSum},{}],20:[function(require,module,exports){var i,ua="undefined"!=typeof window?window.navigator.userAgent:"",isOSX=/OS X/.test(ua),isOpera=/Opera/.test(ua),maybeFirefox=!/like Gecko/.test(ua)&&!isOpera,output=module.exports={0:isOSX?"<menu>":"<UNK>",1:"<mouse 1>",2:"<mouse 2>",3:"<break>",4:"<mouse 3>",5:"<mouse 4>",6:"<mouse 5>",8:"<backspace>",9:"<tab>",12:"<clear>",13:"<enter>",16:"<shift>",17:"<control>",18:"<alt>",19:"<pause>",20:"<caps-lock>",21:"<ime-hangul>",23:"<ime-junja>",24:"<ime-final>",25:"<ime-kanji>",27:"<escape>",28:"<ime-convert>",29:"<ime-nonconvert>",30:"<ime-accept>",31:"<ime-mode-change>",27:"<escape>",32:"<space>",33:"<page-up>",34:"<page-down>",35:"<end>",36:"<home>",37:"<left>",38:"<up>",39:"<right>",40:"<down>",41:"<select>",42:"<print>",43:"<execute>",44:"<snapshot>",45:"<insert>",46:"<delete>",47:"<help>",91:"<meta>",92:"<meta>",93:isOSX?"<meta>":"<menu>",95:"<sleep>",106:"<num-*>",107:"<num-+>",108:"<num-enter>",109:"<num-->",110:"<num-.>",111:"<num-/>",144:"<num-lock>",145:"<scroll-lock>",160:"<shift-left>",161:"<shift-right>",162:"<control-left>",163:"<control-right>",164:"<alt-left>",165:"<alt-right>",166:"<browser-back>",167:"<browser-forward>",168:"<browser-refresh>",169:"<browser-stop>",170:"<browser-search>",171:"<browser-favorites>",172:"<browser-home>",173:isOSX&&maybeFirefox?"-":"<volume-mute>",174:"<volume-down>",175:"<volume-up>",176:"<next-track>",177:"<prev-track>",178:"<stop>",179:"<play-pause>",180:"<launch-mail>",181:"<launch-media-select>",182:"<launch-app 1>",183:"<launch-app 2>",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",223:"<meta>",224:"<meta>",226:"<alt-gr>",229:"<ime-process>",231:isOpera?"`":"<unicode>",246:"<attention>",247:"<crsel>",248:"<exsel>",249:"<erase-eof>",250:"<play>",251:"<zoom>",252:"<no-name>",253:"<pa-1>",254:"<clear>"};for(i=58;i<65;++i)output[i]=String.fromCharCode(i);for(i=48;i<58;++i)output[i]=i-48+"";for(i=65;i<91;++i)output[i]=String.fromCharCode(i);for(i=96;i<106;++i)output[i]="<num-"+(i-96)+">";for(i=112;i<136;++i)output[i]="F"+(i-111)},{}]},{},[2]);