UNPKG

@createjs/easeljs

Version:

The Easel JavaScript library provides a full, hierarchical display list, a core interaction model, and helper classes to make working with the HTML5 Canvas element much easier. Part of the CreateJS suite of libraries.

12 lines 103 kB
/** * @license EaselJS * Visit https://createjs.com for documentation, updates and examples. * * Copyright (c) 2017 gskinner.com, inc. * * Distributed under the terms of the MIT license. * http://www.opensource.org/licenses/mit-license.html * * This notice shall be included in all copies or substantial portions of the Software. */ !function(t,i){"use strict";var h=function(){function i(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1),this.type=t,this.target=null,this.currentTarget=null,this.eventPhase=0,this.bubbles=e,this.cancelable=i,this.timeStamp=(new Date).getTime(),this.defaultPrevented=!1,this.propagationStopped=!1,this.immediatePropagationStopped=!1,this.removed=!1}var t=i.prototype;return t.preventDefault=function(){return this.defaultPrevented=this.cancelable,this},t.stopPropagation=function(){return this.propagationStopped=!0,this},t.stopImmediatePropagation=function(){return this.immediatePropagationStopped=this.propagationStopped=!0,this},t.remove=function(){return this.removed=!0,this},t.clone=function(){var t=new i(this.type,this.bubbles,this.cancelable);for(var e in this)this.hasOwnProperty(e)&&(t[e]=this[e]);return t},t.set=function(t){for(var e in t)this[e]=t[e];return this},t.toString=function(){return"["+this.constructor.name+" (type="+this.type+")]"},i}(),e=function(){function i(){this._listeners=null,this._captureListeners=null}i.initialize=function(t){var e=i.prototype;t.addEventListener=e.addEventListener,t.on=e.on,t.removeEventListener=t.off=e.removeEventListener,t.removeAllEventListeners=e.removeAllEventListeners,t.hasEventListener=e.hasEventListener,t.dispatchEvent=e.dispatchEvent,t._dispatchEvent=e._dispatchEvent,t.willTrigger=e.willTrigger};var t=i.prototype;return t.addEventListener=function(t,e,i){var n;void 0===i&&(i=!1);var r=(n=i?this._captureListeners=this._captureListeners||{}:this._listeners=this._listeners||{})[t];return r&&(this.removeEventListener(t,e,i),r=n[t]),r?r.push(e):n[t]=[e],e},t.on=function(t,e,i,n,r,s){return void 0===i&&(i=null),void 0===n&&(n=!1),void 0===r&&(r={}),void 0===s&&(s=!1),e.handleEvent&&(i=i||e,e=e.handleEvent),i=i||this,this.addEventListener(t,function(t){e.call(i,t,r),n&&t.remove()},s)},t.removeEventListener=function(t,e,i){void 0===i&&(i=!1);var n=i?this._captureListeners:this._listeners;if(n){var r=n[t];if(r)for(var s=r.length,a=0;a<s;a++)if(r[a]===e){1===s?delete n[t]:r.splice(a,1);break}}},t.off=function(t,e,i){void 0===i&&(i=!1),this.removeEventListener(t,e,i)},t.removeAllEventListeners=function(t){void 0===t&&(t=null),t?(this._listeners&&delete this._listeners[t],this._captureListeners&&delete this._captureListeners[t]):this._listeners=this._captureListeners=null},t.dispatchEvent=function(t,e,i){if(void 0===e&&(e=!1),void 0===i&&(i=!1),"string"==typeof t){var n=this._listeners;if(!(e||n&&n[t]))return!0;t=new h(t,e,i)}else t.target&&t.clone&&(t=t.clone());try{t.target=this}catch(t){}if(t.bubbles&&this.parent){for(var r=this,s=[r];r.parent;)s.push(r=r.parent);var a,o=s.length;for(a=o-1;0<=a&&!t.propagationStopped;a--)s[a]._dispatchEvent(t,1+(0==a));for(a=1;a<o&&!t.propagationStopped;a++)s[a]._dispatchEvent(t,3)}else this._dispatchEvent(t,2);return!t.defaultPrevented},t.hasEventListener=function(t){var e=this._listeners,i=this._captureListeners;return!!(e&&e[t]||i&&i[t])},t.willTrigger=function(t){for(var e=this;e;){if(e.hasEventListener(t))return!0;e=e.parent}return!1},t.toString=function(){return"["+(this.constructor.name+this.name?" "+this.name:"")+"]"},t._dispatchEvent=function(t,e){var i=1===e?this._captureListeners:this._listeners;if(t&&i){var n,r=i[t.type];if(!r||0===(n=r.length))return;try{t.currentTarget=this}catch(t){}try{t.eventPhase=e}catch(t){}t.removed=!1,r=r.slice();for(var s=0;s<n&&!t.immediatePropagationStopped;s++){var a=r[s];a.handleEvent?a.handleEvent(t):a(t),t.removed&&(this.off(t.type,a,1===e),t.removed=!1)}}},i}();function n(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function o(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function l(t,e){t.prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}var s=function(n){function i(t){var e;return(e=n.call(this)||this).name=t,e.timingMode=i.TIMEOUT,e.maxDelta=0,e.paused=!1,e._inited=!1,e._startTime=0,e._pausedTime=0,e._ticks=0,e._pausedTicks=0,e._interval=50,e._lastTime=0,e._times=null,e._tickTimes=null,e._timerId=null,e._raf=!0,e}l(i,n),o(i,null,[{key:"RAF_SYNCHED",get:function(){return"synched"}},{key:"RAF",get:function(){return"raf"}},{key:"TIMEOUT",get:function(){return"timeout"}}]);var t=i.prototype;return t.init=function(){this._inited||(this._inited=!0,this._times=[],this._tickTimes=[],this._startTime=this._getTime(),this._times.push(this._lastTime=0),this._setupTick())},t.reset=function(){if(this._raf){var t=window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.oCancelAnimationFrame||window.msCancelAnimationFrame;t&&t(this._timerId)}else clearTimeout(this._timerId);this.removeAllEventListeners("tick"),this._timerId=this._times=this._tickTimes=null,this._startTime=this._lastTime=this._ticks=0,this._inited=!1},t.addEventListener=function(t,e,i){return!this._inited&&this.init(),n.prototype.addEventListener.call(this,t,e,i)},t.getMeasuredTickTime=function(t){void 0===t&&(t=null);var e=this._tickTimes;return!e||e.length<1?-1:(t=Math.min(e.length,t||0|this.framerate),e.reduce(function(t,e){return t+e},0)/t)},t.getMeasuredFPS=function(t){void 0===t&&(t=null);var e=this._times;return!e||e.length<2?-1:(t=Math.min(e.length-1,t||0|this.framerate),1e3/((e[0]-e[t])/t))},t.getTime=function(t){return void 0===t&&(t=!1),this._startTime?this._getTime()-(t?this._pausedTime:0):-1},t.getEventTime=function(t){return void 0===t&&(t=!1),this._startTime?(this._lastTime||this._startTime)-(t?this._pausedTime:0):-1},t.getTicks=function(t){return void 0===t&&(t=!1),this._ticks-(t?this._pausedTicks:0)},t._handleSynch=function(){this._timerId=null,this._setupTick(),this._getTime()-this._lastTime>=.97*(this._interval-1)&&this._tick()},t._handleRAF=function(){this._timerId=null,this._setupTick(),this._tick()},t._handleTimeout=function(){this._timerId=null,this._setupTick(),this._tick()},t._setupTick=function(){if(null==this._timerId){var t=this.timingMode||this._raf&&i.RAF;if(t===i.RAF_SYNCHED||t===i.RAF){var e=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame;if(e)return this._timerId=e(t===i.RAF?this._handleRAF.bind(this):this._handleSynch.bind(this)),void(this._raf=!0)}this._raf=!1,this._timerId=setTimeout(this._handleTimeout.bind(this),this._interval)}},t._tick=function(){var t=this.paused,e=this._getTime(),i=e-this._lastTime;if(this._lastTime=e,this._ticks++,t&&(this._pausedTicks++,this._pausedTime+=i),this.hasEventListener("tick")){var n=new h("tick"),r=this.maxDelta;n.delta=r&&r<i?r:i,n.paused=t,n.time=e,n.runTime=e-this._pausedTime,this.dispatchEvent(n)}for(this._tickTimes.unshift(this._getTime()-e);100<this._tickTimes.length;)this._tickTimes.pop();for(this._times.unshift(e);100<this._times.length;)this._times.pop()},t._getTime=function(){var t=window.performance&&window.performance.now;return(t&&t.call(performance)||(new Date).getTime())-this._startTime},i.on=function(t,e,i,n,r,s){return a.on(t,e,i,n,r,s)},i.removeEventListener=function(t,e,i){a.removeEventListener(t,e,i)},i.off=function(t,e,i){a.off(t,e,i)},i.removeAllEventListeners=function(t){a.removeAllEventListeners(t)},i.dispatchEvent=function(t,e,i){return a.dispatchEvent(t,e,i)},i.hasEventListener=function(t){return a.hasEventListener(t)},i.willTrigger=function(t){return a.willTrigger(t)},i.toString=function(){return a.toString()},i.init=function(){a.init()},i.reset=function(){a.reset()},i.addEventListener=function(t,e,i){a.addEventListener(t,e,i)},i.getMeasuredTickTime=function(t){return a.getMeasuredTickTime(t)},i.getMeasuredFPS=function(t){return a.getMeasuredFPS(t)},i.getTime=function(t){return a.getTime(t)},i.getEventTime=function(t){return a.getEventTime(t)},i.getTicks=function(t){return a.getTicks(t)},o(i,[{key:"interval",get:function(){return this._interval},set:function(t){this._interval=t,this._inited&&this._setupTick()}},{key:"framerate",get:function(){return 1e3/this._interval},set:function(t){this.interval=1e3/t}}],[{key:"interval",get:function(){return a.interval},set:function(t){a.interval=t}},{key:"framerate",get:function(){return a.framerate},set:function(t){a.framerate=t}},{key:"name",get:function(){return a.name},set:function(t){a.name=t}},{key:"timingMode",get:function(){return a.timingMode},set:function(t){a.timingMode=t}},{key:"maxDelta",get:function(){return a.maxDelta},set:function(t){a.maxDelta=t}},{key:"paused",get:function(){return a.paused},set:function(t){a.paused=t}}]),i}(e),a=new s("createjs.global"),u=function(){throw new Error("\n\t\t\tStageGL is not currently supported on the EaselJS 2.0 branch.\n\t\t\tEnd of Q1 2018 is targetted for StageGL support.\n\t\t\tFollow @CreateJS on Twitter for updates.\n\t\t")},c=function(){function t(t,e,i,n){void 0===t&&(t="black"),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.color=t,this.offsetX=e,this.offsetY=i,this.blur=n}var e=t.prototype;return e.toString=function(){return"["+this.constructor.name+"]"},e.clone=function(){return new t(this.color,this.offsetX,this.offsetY,this.blur)},t}();c.identity=new c("transparent");var d=0;function f(){return d++}var p=function(){function t(t,e){this.setValues(t,e)}var e=t.prototype;return e.setValues=function(t,e){return void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e,this},e.copy=function(t){return this.x=t.x,this.y=t.y,this},e.clone=function(){return new t(this.x,this.y)},e.toString=function(){return"["+this.constructor.name+" (x="+this.x+" y="+this.y+")]"},t}(),_=function(){function d(t,e,i,n,r,s){this.setValues(t,e,i,n,r,s)}var t=d.prototype;return t.setValues=function(t,e,i,n,r,s){return void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s,this},t.append=function(t,e,i,n,r,s){var a=this.a,o=this.b,h=this.c,u=this.d;return 1==t&&0==e&&0==i&&1==n||(this.a=a*t+h*e,this.b=o*t+u*e,this.c=a*i+h*n,this.d=o*i+u*n),this.tx=a*r+h*s+this.tx,this.ty=o*r+u*s+this.ty,this},t.prepend=function(t,e,i,n,r,s){var a=this.a,o=this.c,h=this.tx;return this.a=t*a+i*this.b,this.b=e*a+n*this.b,this.c=t*o+i*this.d,this.d=e*o+n*this.d,this.tx=t*h+i*this.ty+r,this.ty=e*h+n*this.ty+s,this},t.appendMatrix=function(t){return this.append(t.a,t.b,t.c,t.d,t.tx,t.ty)},t.prependMatrix=function(t){return this.prepend(t.a,t.b,t.c,t.d,t.tx,t.ty)},t.appendTransform=function(t,e,i,n,r,s,a,o,h){var u,l,c;return c=r%360?(u=r*d.DEG_TO_RAD,l=Math.cos(u),Math.sin(u)):(l=1,0),s||a?(s*=d.DEG_TO_RAD,a*=d.DEG_TO_RAD,this.append(Math.cos(a),Math.sin(a),-Math.sin(s),Math.cos(s),t,e),this.append(l*i,c*i,-c*n,l*n,0,0)):this.append(l*i,c*i,-c*n,l*n,t,e),(o||h)&&(this.tx-=o*this.a+h*this.c,this.ty-=o*this.b+h*this.d),this},t.prependTransform=function(t,e,i,n,r,s,a,o,h){var u,l,c;return c=r%360?(u=r*d.DEG_TO_RAD,l=Math.cos(u),Math.sin(u)):(l=1,0),(o||h)&&(this.tx-=o,this.ty-=h),s||a?(s*=d.DEG_TO_RAD,a*=d.DEG_TO_RAD,this.prepend(l*i,c*i,-c*n,l*n,0,0),this.prepend(Math.cos(a),Math.sin(a),-Math.sin(s),Math.cos(s),t,e)):this.prepend(l*i,c*i,-c*n,l*n,t,e),this},t.rotate=function(t){t*=d.DEG_TO_RAD;var e=Math.cos(t),i=Math.sin(t),n=this.a,r=this.b;return this.a=n*e+this.c*i,this.b=r*e+this.d*i,this.c=-n*i+this.c*e,this.d=-r*i+this.d*e,this},t.skew=function(t,e){return t*=d.DEG_TO_RAD,e*=d.DEG_TO_RAD,this.append(Math.cos(e),Math.sin(e),-Math.sin(t),Math.cos(t),0,0),this},t.scale=function(t,e){return this.a*=t,this.b*=t,this.c*=e,this.d*=e,this},t.translate=function(t,e){return this.tx+=this.a*t+this.c*e,this.ty+=this.b*t+this.d*e,this},t.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},t.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,r=this.tx,s=t*n-e*i;return this.a=n/s,this.b=-e/s,this.c=-i/s,this.d=t/s,this.tx=(i*this.ty-n*r)/s,this.ty=-(t*this.ty-e*r)/s,this},t.isIdentity=function(){return 0===this.tx&&0===this.ty&&1===this.a&&0===this.b&&0===this.c&&1===this.d},t.equals=function(t){return this.tx===t.tx&&this.ty===t.ty&&this.a===t.a&&this.b===t.b&&this.c===t.c&&this.d===t.d},t.transformPoint=function(t,e,i){return void 0===i&&(i=new p),i.x=t*this.a+e*this.c+this.tx,i.y=t*this.b+e*this.d+this.ty,i},t.decompose=function(t){void 0===t&&(t={}),t.x=this.tx,t.y=this.ty,t.scaleX=Math.sqrt(this.a*this.a+this.b*this.b),t.scaleY=Math.sqrt(this.c*this.c+this.d*this.d);var e=Math.atan2(-this.c,this.d),i=Math.atan2(this.b,this.a);return Math.abs(1-e/i)<1e-5?(t.rotation=i/d.DEG_TO_RAD,this.a<0&&0<=this.d&&(t.rotation+=t.rotation<=0?180:-180),t.skewX=t.skewY=0):(t.skewX=e/d.DEG_TO_RAD,t.skewY=i/d.DEG_TO_RAD),t},t.copy=function(t){return this.setValues(t.a,t.b,t.c,t.d,t.tx,t.ty)},t.clone=function(){return new d(this.a,this.b,this.c,this.d,this.tx,this.ty)},t.toString=function(){return"["+this.constructor.name+" (a="+this.a+" b="+this.b+" c="+this.c+" d="+this.d+" tx="+this.tx+" ty="+this.ty+")]"},d}();_.DEG_TO_RAD=Math.PI/180,_.identity=new _;var v=function(){function t(t,e,i,n,r){this.setValues(t,e,i,n,r)}var e=t.prototype;return e.setValues=function(t,e,i,n,r){return void 0===t&&(t=!0),void 0===e&&(e=1),this.visible=t,this.alpha=e,this.shadow=i,this.compositeOperation=n,this.matrix=r||this.matrix&&this.matrix.identity()||new _,this},e.append=function(t,e,i,n,r){return this.alpha*=e,this.shadow=i||this.shadow,this.compositeOperation=n||this.compositeOperation,this.visible=this.visible&&t,r&&this.matrix.appendMatrix(r),this},e.prepend=function(t,e,i,n,r){return this.alpha*=e,this.shadow=this.shadow||i,this.compositeOperation=this.compositeOperation||n,this.visible=this.visible&&t,r&&this.matrix.prependMatrix(r),this},e.identity=function(){return this.visible=!0,this.alpha=1,this.shadow=this.compositeOperation=null,this.matrix.identity(),this},e.clone=function(){return new t(this.alpha,this.shadow,this.compositeOperation,this.visible,this.matrix.clone())},t}(),x=function(){function s(t,e,i,n){this.setValues(t,e,i,n)}var t=s.prototype;return t.setValues=function(t,e,i,n){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n,this},t.extend=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),t+i>this.x+this.width&&(this.width=t+i-this.x),e+n>this.y+this.height&&(this.height=e+n-this.y),t<this.x&&(this.width+=this.x-t,this.x=t),e<this.y&&(this.height+=this.y-e,this.y=e),this},t.pad=function(t,e,i,n){return this.x-=e,this.y-=t,this.width+=e+n,this.height+=t+i,this},t.copy=function(t){return this.setValues(t.x,t.y,t.width,t.height)},t.contains=function(t,e,i,n){return void 0===i&&(i=0),void 0===n&&(n=0),t>=this.x&&t+i<=this.x+this.width&&e>=this.y&&e+n<=this.y+this.height},t.union=function(t){return this.clone().extend(t.x,t.y,t.width,t.height)},t.intersection=function(t){var e=t.x,i=t.y,n=e+t.width,r=i+t.height;return this.x>e&&(e=this.x),this.y>i&&(i=this.y),this.x+this.width<n&&(n=this.x+this.width),this.y+this.height<r&&(r=this.y+this.height),n<=e||r<=i?null:new s(e,i,n-e,r-i)},t.intersects=function(t){return t.x<=this.x+this.width&&this.x<=t.x+t.width&&t.y<=this.y+this.height&&this.y<=t.y+t.height},t.isEmpty=function(){return this.width<=0||this.height<=0},t.clone=function(){return new s(this.x,this.y,this.width,this.height)},t.toString=function(){return"["+this.constructor.name+" (x="+this.x+" y="+this.y+" width="+this.width+" height="+this.height+")]"},s}(),g=function(){function t(){this.usesContext=!1,this._multiPass=null,this.VTX_SHADER_BODY=null,this.FRAG_SHADER_BODY=null}var e=t.prototype;return e.getBounds=function(t){},e.shaderParamSetup=function(t,e,i){},e.applyFilter=function(t,e,i,n,r,s,a,o){s=s||t,null==a&&(a=e),null==o&&(o=i);try{var h=t.getImageData(e,i,n,r);if(this._applyFilter(h))return s.putImageData(h,a,o),!0}catch(t){}return!1},e.toString=function(){return"["+this.constructor.name+"]"},e.clone=function(){return new t},e._applyFilter=function(t){},t}(),m=function(e){function n(){var t;return(t=e.call(this)||this).width=void 0,t.height=void 0,t.x=void 0,t.y=void 0,t.scale=1,t.offX=0,t.offY=0,t.cacheID=0,t._filterOffX=0,t._filterOffY=0,t._cacheDataURLID=0,t._cacheDataURL=null,t._drawWidth=0,t._drawHeight=0,t._boundRect=new x,t}l(n,e),n.getFilterBounds=function(t,e){void 0===e&&(e=new x);var i=t.filters,n=i&&i.length;if(!!n<=0)return e;for(var r=0;r<n;r++){var s=i[r];if(s&&s.getBounds){var a=s.getBounds();a&&(0==r?e.setValues(a.x,a.y,a.width,a.height):e.extend(a.x,a.y,a.width,a.height))}}return e};var t=n.prototype;return t.define=function(t,e,i,n,r,s,a){if(void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1),void 0===s&&(s=1),!t)throw"No symbol to cache";this._options=a,this._useWebGL=void 0!==a,this.target=t,this.width=1<=n?n:1,this.height=1<=r?r:1,this.x=e,this.y=i,this.scale=s,this.update()},t.update=function(t){if(!this.target)throw"define() must be called before update()";var e=n.getFilterBounds(this.target),i=this.target.cacheCanvas;this._drawWidth=Math.ceil(this.width*this.scale)+e.width,this._drawHeight=Math.ceil(this.height*this.scale)+e.height,i&&this._drawWidth==i.width&&this._drawHeight==i.height||this._updateSurface(),this._filterOffX=e.x,this._filterOffY=e.y,this.offX=this.x*this.scale+this._filterOffX,this.offY=this.y*this.scale+this._filterOffY,this._drawToCache(t),this.cacheID=this.cacheID?this.cacheID+1:1},t.release=function(){var t=this.target.stage;this._useWebGL&&this._webGLCache?(this._webGLCache.isCacheControlled||(this.__lastRT&&(this.__lastRT=void 0),this.__rtA&&this._webGLCache._killTextureObject(this.__rtA),this.__rtB&&this._webGLCache._killTextureObject(this.__rtB),this.target&&this.target.cacheCanvas&&this._webGLCache._killTextureObject(this.target.cacheCanvas)),this._webGLCache=!1):t instanceof u&&t.releaseTexture(this.target.cacheCanvas),this.target=this.target.cacheCanvas=null,this.cacheID=this._cacheDataURLID=this._cacheDataURL=void 0,this.width=this.height=this.x=this.y=this.offX=this.offY=0,this.scale=1},t.getCacheDataURL=function(){var t=this.target&&this.target.cacheCanvas;return t?(this.cacheID!=this._cacheDataURLID&&(this._cacheDataURLID=this.cacheID,this._cacheDataURL=t.toDataURL?t.toDataURL():null),this._cacheDataURL):null},t.draw=function(t){return!!this.target&&(t.drawImage(this.target.cacheCanvas,this.x+this._filterOffX/this.scale,this.y+this._filterOffY/this.scale,this._drawWidth/this.scale,this._drawHeight/this.scale),!0)},t.getBounds=function(){var t=this.scale;return this._boundRect.setValue(this._filterOffX/t,this._filterOffY/t,this.width/t,this.height/t)},t._updateSurface=function(){var t;if(!this._useWebGL)return(t=this.target.cacheCanvas)||(t=this.target.cacheCanvas=window.createjs&&createjs.createCanvas?createjs.createCanvas():document.createElement("canvas")),t.width=this._drawWidth,void(t.height=this._drawHeight);if(!this._webGLCache)if("stage"===this._options.useGL){if(null==this.target.stage||!this.target.stage.isWebGL)throw"Cannot use 'stage' for cache because the object's parent stage is "+(null!=this.target.stage?"non WebGL.":"not set, please addChild to the correct stage.");this.target.cacheCanvas=!0,this._webGLCache=this.target.stage}else{if("new"!==this._options.useGL)throw"Invalid option provided to useGL, expected ['stage', 'new', StageGL, undefined], got "+this._options.useGL;this.target.cacheCanvas=document.createElement("canvas"),this._webGLCache=new u(this.target.cacheCanvas,{antialias:!0,transparent:!0,autoPurge:-1}),this._webGLCache.isCacheControlled=!0}var e=this._webGLCache;t=this.target.cacheCanvas,e.isCacheControlled&&(t.width=this._drawWidth,t.height=this._drawHeight,e.updateViewport(this._drawWidth,this._drawHeight)),this.target.filters?(e.getTargetRenderTexture(this.target,this._drawWidth,this._drawHeight),e.getTargetRenderTexture(this.target,this._drawWidth,this._drawHeight)):e.isCacheControlled||e.getTargetRenderTexture(this.target,this._drawWidth,this._drawHeight)},t._drawToCache=function(t){var e=this.target,i=e.cacheCanvas,n=this._webGLCache;if(!this._useWebGL||!n){var r=i.getContext("2d");return t||r.clearRect(0,0,this._drawWidth+1,this._drawHeight+1),r.save(),r.globalCompositeOperation=t,r.setTransform(this.scale,0,0,this.scale,-this._filterOffX,-this._filterOffY),r.translate(-this.x,-this.y),e.draw(r,!0),r.restore(),e.filters&&e.filters.length&&this._applyFilters(e),void(i._invalid=!0)}this._webGLCache.cacheDraw(e,e.filters,this),(i=this.target.cacheCanvas).width=this._drawWidth,i.height=this._drawHeight,i._invalid=!0},t._applyFilters=function(){for(var t=this.target.cacheCanvas,e=this.target.filters,i=this._drawWidth,n=this._drawHeight,r=t.getContext("2d").getImageData(0,0,i,n),s=e.length,a=0;a<s;a++)e[a]._applyFilter(r);t.getContext("2d").putImageData(r,0,0)},n}(g),w=function(e){function a(){var t;return(t=e.call(this)||this).alpha=1,t.cacheCanvas=null,t.bitmapCache=null,t.id=f(),t.mouseEnabled=!0,t.tickEnabled=!0,t.name=null,t.parent=null,t.regX=0,t.regY=0,t.rotation=0,t.scaleX=1,t.scaleY=1,t.skewX=0,t.skewY=0,t.shadow=null,t.visible=!0,t.x=0,t.y=0,t.transformMatrix=null,t.compositeOperation=null,t.snapToPixel=!0,t.filters=null,t.mask=null,t.hitArea=null,t.cursor=null,t._props=new v,t._rectangle=new x,t._bounds=null,t._webGLRenderStyle=a._StageGL_NONE,t}l(a,e);var t=a.prototype;return t.isVisible=function(){return!!(this.visible&&0<this.alpha&&0!=this.scaleX&&0!=this.scaleY)},t.draw=function(t,e){return void 0===e&&(e=!1),this.drawCache(t,e)},t.drawCache=function(t,e){void 0===e&&(e=!1);var i=this.bitmapCache;return!(!i||e)&&i.draw(t)},t.updateContext=function(t){var e=this,i=e.mask,n=e._props.matrix;i&&i.graphics&&!i.graphics.isEmpty()&&(i.getMatrix(n),t.transform(n.a,n.b,n.c,n.d,n.tx,n.ty),i.graphics.drawAsPath(t),t.clip(),n.invert(),t.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),this.getMatrix(n);var r=n.tx,s=n.ty;a._snapToPixelEnabled&&e.snapToPixel&&(r=r+(r<0?-.5:.5)|0,s=s+(s<0?-.5:.5)|0),t.transform(n.a,n.b,n.c,n.d,r,s),t.globalAlpha*=e.alpha,e.compositeOperation&&(t.globalCompositeOperation=e.compositeOperation),e.shadow&&this._applyShadow(t,e.shadow)},t.cache=function(t,e,i,n,r,s){void 0===r&&(r=1),this.bitmapCache||(this.bitmapCache=new m),this.bitmapCache.define(this,t,e,i,n,r,s)},t.updateCache=function(t){if(!this.bitmapCache)throw"No cache found. cache() must be called before updateCache()";this.bitmapCache.update(t)},t.uncache=function(){this.bitmapCache&&(this.bitmapCache.release(),this.bitmapCache=void 0)},t.getCacheDataURL=function(){return this.bitmapCache?this.bitmapCache.getDataURL():null},t.localToGlobal=function(t,e,i){return void 0===i&&(i=new p),this.getConcatenatedMatrix(this._props.matrix).transformPoint(t,e,i)},t.globalToLocal=function(t,e,i){return void 0===i&&(i=new p),this.getConcatenatedMatrix(this._props.matrix).invert().transformPoint(t,e,i)},t.localToLocal=function(t,e,i,n){return n=this.localToGlobal(t,e,n),i.globalToLocal(n.x,n.y,n)},t.setTransform=function(t,e,i,n,r,s,a,o,h){return void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=0),this.x=t,this.y=e,this.scaleX=i,this.scaleY=n,this.rotation=r,this.skewX=s,this.skewY=a,this.regX=o,this.regY=h,this},t.getMatrix=function(t){var e=this,i=t&&t.identity()||new _;return e.transformMatrix?i.copy(e.transformMatrix):i.appendTransform(e.x,e.y,e.scaleX,e.scaleY,e.rotation,e.skewX,e.skewY,e.regX,e.regY)},t.getConcatenatedMatrix=function(t){for(var e=this,i=this.getMatrix(t);e=e.parent;)i.prependMatrix(e.getMatrix(e._props.matrix));return i},t.getConcatenatedDisplayProps=function(t){t=t?t.identity():new v;for(var e=this,i=e.getMatrix(t.matrix);t.prepend(e.visible,e.alpha,e.shadow,e.compositeOperation),e!=this&&i.prependMatrix(e.getMatrix(e._props.matrix)),e=e.parent;);return t},t.hitTest=function(t,e){var i=a._hitTestContext;i.setTransform(1,0,0,1,-t,-e),this.draw(i);var n=this._testHit(i);return i.setTransform(1,0,0,1,0,0),i.clearRect(0,0,2,2),n},t.set=function(t){for(var e in t)this[e]=t[e];return this},t.getBounds=function(){if(this._bounds)return this._rectangle.copy(this._bounds);var t=this.cacheCanvas;if(t){var e=this._cacheScale;return this._rectangle.setValues(this._cacheOffsetX,this._cacheOffsetY,t.width/e,t.height/e)}return null},t.getTransformedBounds=function(){return this._getBounds()},t.setBounds=function(t,e,i,n){null==t&&(this._bounds=null),this._bounds=(this._bounds||new x).setValues(t,e,i,n)},t.clone=function(){return this._cloneProps(new a)},t.toString=function(){return"["+this.constructor.name+(this.name?" (name="+this.name+")":"")+"]"},t._cloneProps=function(t){return t.alpha=this.alpha,t.mouseEnabled=this.mouseEnabled,t.tickEnabled=this.tickEnabled,t.name=this.name,t.regX=this.regX,t.regY=this.regY,t.rotation=this.rotation,t.scaleX=this.scaleX,t.scaleY=this.scaleY,t.shadow=this.shadow,t.skewX=this.skewX,t.skewY=this.skewY,t.visible=this.visible,t.x=this.x,t.y=this.y,t.compositeOperation=this.compositeOperation,t.snapToPixel=this.snapToPixel,t.filters=null==this.filters?null:this.filters.slice(0),t.mask=this.mask,t.hitArea=this.hitArea,t.cursor=this.cursor,t._bounds=this._bounds,t},t._applyShadow=function(t,e){void 0===e&&(e=c.identity),e=e,t.shadowColor=e.color,t.shadowOffsetX=e.offsetX,t.shadowOffsetY=e.offsetY,t.shadowBlur=e.blur},t._tick=function(t){var e=this._listeners;e&&e.tick&&(t.target=null,t.propagationStopped=t.immediatePropagationStopped=!1,this.dispatchEvent(t))},t._testHit=function(t){try{return 1<t.getImageData(0,0,1,1).data[3]}catch(t){if(!a.suppressCrossDomainErrors)throw"An error has occurred. This is most likely due to security restrictions on reading canvas pixel data with local or cross-domain images.";return!1}},t._getBounds=function(t,e){return this._transformBounds(this.getBounds(),t,e)},t._transformBounds=function(t,e,i){if(!t)return t;var n=t.x,r=t.y,s=t.width,a=t.height,o=this._props.matrix;o=i?o.identity():this.getMatrix(o),(n||r)&&o.appendTransform(0,0,1,1,0,0,0,-n,-r),e&&o.prependMatrix(e);var h=s*o.a,u=s*o.b,l=a*o.c,c=a*o.d,d=o.tx,f=o.ty,p=d,_=d,v=f,g=f;return(n=h+d)<p?p=n:_<n&&(_=n),(n=h+l+d)<p?p=n:_<n&&(_=n),(n=l+d)<p?p=n:_<n&&(_=n),(r=u+f)<v?v=r:g<r&&(g=r),(r=u+c+f)<v?v=r:g<r&&(g=r),(r=c+f)<v?v=r:g<r&&(g=r),t.setValues(p,v,_-p,g-v)},t._hasMouseEventListener=function(){for(var t=a._MOUSE_EVENTS,e=0,i=t.length;e<i;e++)if(this.hasEventListener(t[e]))return!0;return!!this.cursor},o(a,[{key:"stage",get:function(){for(var t=this;t.parent;)t=t.parent;return/^\[Stage(GL)?(\s\(name=\w+\))?\]$/.test(t.toString())?t:null}},{key:"scale",set:function(t){this.scaleX=this.scaleY=t},get:function(){return this.scaleX}}]),a}(e),y=window.createjs&&createjs.createCanvas?createjs.createCanvas():document.createElement("canvas");y.getContext&&(w._hitTestCanvas=y,w._hitTestContext=y.getContext("2d"),y.width=y.height=1),w._MOUSE_EVENTS=["click","dblclick","mousedown","mouseout","mouseover","pressmove","pressup","rollout","rollover"],w.suppressCrossDomainErrors=!1,w.snapToPixelEnabled=!1,w._StageGL_NONE=0,w._StageGL_SPRITE=1,w._StageGL_BITMAP=2;var b=function(h){function p(){var t;return(t=h.call(this)||this).children=[],t.mouseChildren=!0,t.tickChildren=!0,t}l(p,h);var t=p.prototype;return t.isVisible=function(){var t=this.cacheCanvas||this.children.length;return!!(this.visible&&0<this.alpha&&0!=this.scaleX&&0!=this.scaleY&&t)},t.draw=function(t,e){if(void 0===e&&(e=!1),h.prototype.draw.call(this,t,e))return!0;for(var i=this.children.slice(),n=0,r=i.length;n<r;n++){var s=i[n];s.isVisible()&&(t.save(),s.updateContext(t),s.draw(t),t.restore())}return!0},t.addChild=function(){var t=arguments.length;if(0===t)return null;var e=arguments.length<=0?void 0:arguments[0];if(1<t){for(var i=0;i<t;i++)e=this.addChild(i<0||arguments.length<=i?void 0:arguments[i]);return e}var n=e.parent,r=n===this;return n&&n._removeChildAt(n.children.indexOf(e),r),(e.parent=this).children.push(e),r||e.dispatchEvent("added"),e},t.addChildAt=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=e.length;if(0===n)return null;var r=e.pop();if(r<0||r>this.children.length)return e[n-2];if(2<n){for(var s=0;s<n-1;s++)this.addChildAt(e[s],r++);return e[n-2]}var a=e[0],o=a.parent,h=o===this;return o&&o._removeChildAt(o.children.indexOf(a),h),(a.parent=this).children.splice(r++,0,a),h||a.dispatchEvent("added"),a},t.removeChild=function(){var t=arguments.length;if(0===t)return!0;if(1<t){for(var e=!0,i=0;i<t;i++)e=e&&this.removeChild(i<0||arguments.length<=i?void 0:arguments[i]);return e}return this._removeChildAt(this.children.indexOf(arguments.length<=0?void 0:arguments[0]))},t.removeChildAt=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var n=e.length;if(0===n)return!0;if(1<n){e.sort(function(t,e){return e-t});for(var r=!0,s=0;s<n;s++)r=r&&this._removeChildAt(e[s]);return r}return this._removeChildAt(e[0])},t.removeAllChildren=function(){for(var t=this.children;t.length;)this._removeChildAt(0)},t.getChildAt=function(t){return this.children[t]},t.getChildByName=function(t){for(var e=this.children,i=e.length,n=0;n<i;n++)if(e[n].name===t)return e[n];return null},t.sortChildren=function(t){this.children.sort(t)},t.getChildIndex=function(t){return this.children.indexOf(t)},t.swapChildrenAt=function(t,e){var i=this.children,n=i[t],r=i[e];n&&r&&(i[t]=r,i[e]=n)},t.swapChildren=function(t,e){for(var i,n,r=this.children,s=r.length,a=0;a<s&&(r[a]===t&&(i=a),r[a]===e&&(n=a),null==i||null==n);a++);a!==s&&(r[i]=e,r[n]=t)},t.setChildIndex=function(t,e){var i=this.children,n=i.length;if(!(t.parent!=this||e<0||n<=e)){for(var r=0;r<n&&i[r]!==t;r++);r!==n&&r!==e&&(i.splice(r,1),i.splice(e,0,t))}},t.contains=function(t){for(;t;){if(t===this)return!0;t=t.parent}return!1},t.hitTest=function(t,e){return null!=this.getObjectUnderPoint(t,e)},t.getObjectsUnderPoint=function(t,e,i){void 0===i&&(i=0);var n=[],r=this.localToGlobal(t,e);return this._getObjectsUnderPoint(r.x,r.y,n,0<i,1===i),n},t.getObjectUnderPoint=function(t,e,i){void 0===i&&(i=0);var n=this.localToGlobal(t,e);return this._getObjectsUnderPoint(n.x,n.y,null,0<i,1===i)},t.getBounds=function(){return this._getBounds(null,!0)},t.getTransformedBounds=function(){return this._getBounds()},t.clone=function(t){void 0===t&&(t=!1);var e=this._cloneProps(new p);return t&&this._cloneChildren(e),e},t._tick=function(t){if(this.tickChildren)for(var e=this.children.length-1;0<=e;e--){var i=this.children[e];i.tickEnabled&&i._tick&&i._tick(t)}h.prototype._tick.call(this,t)},t._cloneChildren=function(t){t.children.length&&t.removeAllChildren();for(var e=t.children,i=this.children.length,n=0;n<i;n++){var r=this.children[n].clone(!0);r.parent=t,e.push(r)}},t._removeChildAt=function(t,e){if(void 0===e&&(e=!1),t<0||t>this.children.length-1)return!1;var i=this.children[t];return i&&(i.parent=null),this.children.splice(t,1),e||i.dispatchEvent("removed"),!0},t._getObjectsUnderPoint=function(t,e,i,n,r,s){if(void 0===s&&(s=0),!s&&!this._testMask(this,t,e))return null;var a,o=w._hitTestContext;r=r||n&&this._hasMouseEventListener();for(var h=this.children,u=h.length-1;0<=u;u--){var l=h[u],c=l.hitArea;if(l.visible&&(c||l.isVisible())&&(!n||l.mouseEnabled)&&(c||this._testMask(l,t,e)))if(!c&&l instanceof p){var d=l._getObjectsUnderPoint(t,e,i,n,r,s+1);if(!i&&d)return n&&!this.mouseChildren?this:d}else{if(n&&!r&&!l._hasMouseEventListener())continue;var f=l.getConcatenatedDisplayProps(l._props);if(a=f.matrix,c&&(a.appendMatrix(c.getMatrix(c._props.matrix)),f.alpha=c.alpha),o.globalAlpha=f.alpha,o.setTransform(a.a,a.b,a.c,a.d,a.tx-t,a.ty-e),(c||l).draw(o),!this._testHit(o))continue;if(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,2,2),!i)return n&&!this.mouseChildren?this:l;i.push(l)}}return null},t._testMask=function(t,e,i){var n=t.mask;if(!n||!n.graphics||n.graphics.isEmpty())return!0;var r=this._props.matrix,s=t.parent;r=s?s.getConcatenatedMatrix(r):r.identity(),r=n.getMatrix(n._props.matrix).prependMatrix(r);var a=w._hitTestContext;return a.setTransform(r.a,r.b,r.c,r.d,r.tx-e,r.ty-i),n.graphics.drawAsPath(a),a.fillStyle="#000",a.fill(),!!this._testHit(a)&&(a.setTransform(1,0,0,1,0,0),a.clearRect(0,0,2,2),!0)},t._getBounds=function(t,e){var i=h.prototype.getBounds.call(this);if(i)return this._transformBounds(i,t,e);var n=this._props.matrix;n=e?n.identity():this.getMatrix(n),t&&n.prependMatrix(t);for(var r=this.children.length,s=null,a=0;a<r;a++){var o=this.children[a];o.visible&&(i=o._getBounds(n))&&(s?s.extend(i.x,i.y,i.width,i.height):s=i.clone())}return s},o(p,[{key:"numChildren",get:function(){return this.children.length}}]),p}(w),T=function(d){function t(t,e,i,n,r,s,a,o,h,u,l){var c;return(c=d.call(this,t,e,i)||this).stageX=n,c.stageY=r,c.rawX=null==h?n:h,c.rawY=null==u?r:u,c.nativeEvent=s,c.pointerID=a,c.primary=!!o,c.relatedTarget=l,c}l(t,d);var e=t.prototype;return e.clone=function(){return new t(this.type,this.bubbles,this.cancelable,this.stageX,this.stageY,this.nativeEvent,this.pointerID,this.primary,this.rawX,this.rawY)},e.toString=function(){return"["+this.constructor.name+" (type="+this.type+" stageX="+this.stageX+" stageY="+this.stageY+")]"},o(t,[{key:"localX",get:function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).x}},{key:"localY",get:function(){return this.currentTarget.globalToLocal(this.rawX,this.rawY).y}},{key:"isTouch",get:function(){return-1!==this.pointerID}}]),t}(h),E=function(i){function t(t){var e;return(e=i.call(this)||this).autoClear=!0,e.canvas="string"==typeof t?document.getElementById(t):t,e.mouseX=0,e.mouseY=0,e.drawRect=null,e.snapToPixelEnabled=!1,e.mouseInBounds=!1,e.tickOnUpdate=!0,e.mouseMoveOutside=!1,e.preventSelection=!0,e._pointerData={},e._pointerCount=0,e._primaryPointerID=null,e._mouseOverIntervalID=null,e._nextStage=null,e._prevStage=null,e.enableDOMEvents(!0),e}l(t,i);var e=t.prototype;return e.update=function(t){if(this.canvas&&(this.tickOnUpdate&&this.tick(t),!1!==this.dispatchEvent("drawstart",!1,!0))){w._snapToPixelEnabled=this.snapToPixelEnabled;var e=this.drawRect,i=this.canvas.getContext("2d");i.setTransform(1,0,0,1,0,0),this.autoClear&&(e?i.clearRect(e.x,e.y,e.width,e.height):i.clearRect(0,0,this.canvas.width+1,this.canvas.height+1)),i.save(),this.drawRect&&(i.beginPath(),i.rect(e.x,e.y,e.width,e.height),i.clip()),this.updateContext(i),this.draw(i,!1),i.restore(),this.dispatchEvent("drawend")}},e.tick=function(t){if(this.tickEnabled&&!1!==this.dispatchEvent("tickstart",!1,!0)){var e=new h("tick");if(t)for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);this._tick(e),this.dispatchEvent("tickend")}},e.handleEvent=function(t){"tick"===t.type&&this.update(t)},e.clear=function(){if(this.canvas){var t=this.canvas.getContext("2d");t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,this.canvas.width+1,this.canvas.height+1)}},e.toDataURL=function(t,e){void 0===e&&(e="image/png");var i,n=this.canvas.getContext("2d"),r=this.canvas.width,s=this.canvas.height;if(t){i=n.getImageData(0,0,r,s);var a=n.globalCompositeOperation;n.globalCompositeOperation="destination-over",n.fillStyle=t,n.fillRect(0,0,r,s)}var o=this.canvas.toDataURL(e);return t&&(n.putImageData(i,0,0),n.globalCompositeOperation=a),o},e.enableMouseOver=function(t){var e=this;void 0===t&&(t=20),this._mouseOverIntervalID&&(clearInterval(this._mouseOverIntervalID),this._mouseOverIntervalID=null,0===t&&this._testMouseOver(!0)),t<=0||(this._mouseOverIntervalID=setInterval(function(){return e._testMouseOver()},1e3/Math.min(50,t)))},e.enableDOMEvents=function(t){var e=this;void 0===t&&(t=!0);var i=this._eventListeners;if(!t&&i){for(var n in i){var r=i[n];r.t.removeEventListener(n,r.f,!1)}this._eventListeners=null}else if(t&&!i&&this.canvas){var s=window.addEventListener?window:document;for(var a in i=this._eventListeners={mouseup:{t:s,f:function(t){return e._handleMouseUp(t)}},mousemove:{t:s,f:function(t){return e._handleMouseMove(t)}},dblclick:{t:this.canvas,f:function(t){return e._handleDoubleClick(t)}},mousedown:{t:this.canvas,f:function(t){return e._handleMouseDown(t)}}}){var o=i[a];o.t.addEventListener&&o.t.addEventListener(a,o.f,!1)}}},e.clone=function(){throw"Stage cannot be cloned."},e._getElementRect=function(e){var i;try{i=e.getBoundingClientRect()}catch(t){i={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight}}var t=(window.pageXOffset||document.scrollLeft||0)-(document.clientLeft||document.body.clientLeft||0),n=(window.pageYOffset||document.scrollTop||0)-(document.clientTop||document.body.clientTop||0),r=window.getComputedStyle?getComputedStyle(e,null):e.currentStyle,s=parseInt(r.paddingLeft)+parseInt(r.borderLeftWidth),a=parseInt(r.paddingTop)+parseInt(r.borderTopWidth),o=parseInt(r.paddingRight)+parseInt(r.borderRightWidth),h=parseInt(r.paddingBottom)+parseInt(r.borderBottomWidth);return{left:i.left+t+s,right:i.right+t-o,top:i.top+n+a,bottom:i.bottom+n-h}},e._getPointerData=function(t){var e=this._pointerData[t];return e||(e=this._pointerData[t]={x:0,y:0}),e},e._handleMouseMove=function(t){void 0===t&&(t=window.event),this._handlePointerMove(-1,t,t.pageX,t.pageY)},e._handlePointerMove=function(t,e,i,n,r){if((!this._prevStage||void 0!==r)&&this.canvas){var s=this._nextStage,a=this._getPointerData(t),o=a.inBounds;this._updatePointerPosition(t,e,i,n),(o||a.inBounds||this.mouseMoveOutside)&&(-1===t&&a.inBounds===!o&&this._dispatchMouseEvent(this,o?"mouseleave":"mouseenter",!1,t,a,e),this._dispatchMouseEvent(this,"stagemousemove",!1,t,a,e),this._dispatchMouseEvent(a.target,"pressmove",!0,t,a,e)),s&&s._handlePointerMove(t,e,i,n,null)}},e._updatePointerPosition=function(t,e,i,n){var r=this._getElementRect(this.canvas);i-=r.left,n-=r.top;var s=this.canvas.width,a=this.canvas.height;i/=(r.right-r.left)/s,n/=(r.bottom-r.top)/a;var o=this._getPointerData(t);(o.inBounds=0<=i&&0<=n&&i<=s-1&&n<=a-1)?(o.x=i,o.y=n):this.mouseMoveOutside&&(o.x=i<0?0:s-1<i?s-1:i,o.y=n<0?0:a-1<n?a-1:n),o.posEvtObj=e,o.rawX=i,o.rawY=n,t!==this._primaryPointerID&&-1!==t||(this.mouseX=o.x,this.mouseY=o.y,this.mouseInBounds=o.inBounds)},e._handleMouseUp=function(t){this._handlePointerUp(-1,t,!1)},e._handlePointerUp=function(t,e,i,n){var r=this._nextStage,s=this._getPointerData(t);if(!this._prevStage||void 0!==n){var a=null,o=s.target;n||!o&&!r||(a=this._getObjectsUnderPoint(s.x,s.y,null,!0)),s.down&&(this._dispatchMouseEvent(this,"stagemouseup",!1,t,s,e,a),s.down=!1),a===o&&this._dispatchMouseEvent(o,"click",!0,t,s,e),this._dispatchMouseEvent(o,"pressup",!0,t,s,e),i?(t==this._primaryPointerID&&(this._primaryPointerID=null),delete this._pointerData[t]):s.target=null,r&&r._handlePointerUp(t,e,i,n||a&&this)}},e._handleMouseDown=function(t){this._handlePointerDown(-1,t,t.pageX,t.pageY)},e._handlePointerDown=function(t,e,i,n,r){this.preventSelection&&e.preventDefault(),null!=this._primaryPointerID&&-1!==t||(this._primaryPointerID=t),null!=n&&this._updatePointerPosition(t,e,i,n);var s=null,a=this._nextStage,o=this._getPointerData(t);r||(s=o.target=this._getObjectsUnderPoint(o.x,o.y,null,!0)),o.inBounds&&(this._dispatchMouseEvent(this,"stagemousedown",!1,t,o,e,s),o.down=!0),this._dispatchMouseEvent(s,"mousedown",!0,t,o,e),a&&a._handlePointerDown(t,e,i,n,r||s&&this)},e._testMouseOver=function(t,e,i){if(!this._prevStage||void 0!==e){var n=this._nextStage;if(this._mouseOverIntervalID){var r=this._getPointerData(-1);if(r&&(t||this.mouseX!==this._mouseOverX||this.mouseY!==this._mouseOverY||!this.mouseInBounds)){var s=r.posEvtObj,a=i||s&&s.target===this.canvas,o=null,h=-1,u="";!e&&(t||this.mouseInBounds&&a)&&(o=this._getObjectsUnderPoint(this.mouseX,this.mouseY,null,!0),this._mouseOverX=this.mouseX,this._mouseOverY=this.mouseY);for(var l=this._mouseOverTarget||[],c=l[l.length-1],d=this._mouseOverTarget=[],f=o;f;)d.unshift(f),u||(u=f.cursor),f=f.parent;this.canvas.style.cursor=u,!e&&i&&(i.canvas.style.cursor=u);for(var p=0,_=d.length;p<_&&d[p]==l[p];p++)h=p;c!=o&&this._dispatchMouseEvent(c,"mouseout",!0,-1,r,s,o);for(var v=l.length-1;h<v;v--)this._dispatchMouseEvent(l[v],"rollout",!1,-1,r,s,o);for(var g=d.length-1;h<g;g--)this._dispatchMouseEvent(d[g],"rollover",!1,-1,r,s,c);c!=o&&this._dispatchMouseEvent(o,"mouseover",!0,-1,r,s,c),n&&n._testMouseOver(t,e||o&&this,i||a&&this)}}else n&&n._testMouseOver(t,e,i)}},e._handleDoubleClick=function(t,e){var i=null,n=this._nextStage,r=this._getPointerData(-1);e||(i=this._getObjectsUnderPoint(r.x,r.y,null,!0),this._dispatchMouseEvent(i,"dblclick",!0,-1,r,t)),n&&n._handleDoubleClick(t,e||i&&this)},e._dispatchMouseEvent=function(t,e,i,n,r,s,a){if(t&&(i||t.hasEventListener(e))){var o=new T(e,i,!1,r.x,r.y,s,n,n===this._primaryPointerID||-1===n,r.rawX,r.rawY,a);t.dispatchEvent(o)}},o(t,[{key:"nextStage",get:function(){return this._nextStage},set:function(t){this._nextStage&&(this._nextStage._prevStage=null),t&&(t._prevStage=this),this._nextStage=t}}]),t}(b);function S(t,e){var i;if(void 0===t&&(t=1),void 0===e&&(e=1),void 0!==window.createjs&&void 0!==window.createjs.createCanvas&&(i=window.createjs.createCanvas()),void 0!==window.document&&void 0!==window.document.createElement&&(i=document.createElement("canvas")),void 0!==i)return i.width=t,i.height=e,i;throw"Canvas not supported in this environment."}var C=function(){function t(t){this.readyState=t.readyState,this._video=t,this._canvas=null,this._lastTime=-1,this.readyState<2&&t.addEventListener("canplaythrough",this._videoReady.bind(this))}var e=t.prototype;return e.getImage=function(){if(!(this.readyState<2)){var t=this._canvas,e=this._video;if(t||((t=this._canvas=S()).width=e.videoWidth,t.height=e.videoHeight),2<=e.readyState&&e.currentTime!==this._lastTime){var i=t.getContext("2d");i.clearRect(0,0,t.width,t.height),i.drawImage(e,0,0,t.width,t.height),this._lastTime=e.currentTime}return t}},e._videoReady=function(){this.readyState=2},t}(),M=function(d){function n(t){var e;return e=d.call(this)||this,"string"==typeof t?(e.image=document.createElement("img"),e.image.src=t):e.image=t,e.sourceRect=null,e._webGLRenderStyle=w._StageGL_BITMAP,e}l(n,d);var t=n.prototype;return t.isVisible=function(){var t=this.image,e=this.cacheCanvas||t&&(t.naturalWidth||t.getContext||2<=t.readyState);return!!(this.visible&&0<this.alpha&&0!=this.scaleX&&0!=this.scaleY&&e)},t.draw=function(t,e){if(void 0===e&&(e=!1),d.prototype.draw.call(this,t,e))return!0;var i=this.image,n=this.sourceRect;if(i instanceof C&&(i=i.getImage()),null==i)return!0;if(n){var r=n.x,s=n.y,a=r+n.width,o=s+n.height,h=0,u=0,l=i.width,c=i.height;r<0&&(h-=r,r=0),l<a&&(a=l),s<0&&(u-=s,s=0),c<o&&(o=c),t.drawImage(i,r,s,a-r,o-s,h,u,a-r,o-s)}else t.drawImage(i,0,0);return!0},t.getBounds=function(){var t=d.prototype.getBounds.call(this);if(t)return t;var e=this.image,i=this.sourceRect||e;return e&&(e.naturalWidth||e.getContext||2<=e.readyState)?this._rectangle.setValues(0,0,i.width,i.height):null},t.clone=function(t){var e=this.image;null!=e&&null!=t&&(e=e.cloneNode());var i=new n(e);return this.sourceRect&&(i.sourceRect=this.sourceRect.clone()),this._cloneProps(i),i},n}(w),k=function(r){function t(t,e){var i;return(i=r.call(this)||this).currentFrame=0,i.currentAnimation=null,i.paused=!0,i.spriteSheet=t,i.currentAnimationFrame=0,i.framerate=0,i._animation=null,i._currentFrame=null,i._skipAdvance=!1,i._webGLRenderStyle=w._StageGL_SPRITE,null!=e&&i.gotoAndPlay(e),i}l(t,r);var e=t.prototype;return e.isVisible=function(){var t=this.cacheCanvas||this.spriteSheet.complete;return!!(this.visible&&0<this.alpha&&0!=this.scaleX&&0!=this.scaleY&&t)},e.draw=function(t,e){if(r.prototype.draw.call(this,t,e))return!0;this._normalizeFrame();var i=this.spriteSheet.getFrame(0|this._currentFrame);if(!i)return!1;var n=i.rect;return n.width&&n.height&&t.drawImage(i.image,n.x,n.y,n.width,n.height,-i.regX,-i.regY,n.width,n.height),!0},e.play=function(){this.paused=!1},e.stop=function(){this.paused=!0},e.gotoAndPlay=function(t){this.paused=!1,this._skipAdvance=!0,this._goto(t)},e.gotoAndStop=function(t){this.paused=!0,this._goto(t)},e.advance=function(t){var e=this.framerate||this.spriteSheet.framerate,i=e&&null!=t?t/(1e3/e):1;this._normalizeFrame(i)},e.getBounds=function(){return r.prototype.getBounds.call(this)||this.spriteSheet.getFrameBounds(this.currentFrame,this._rectangle)},e.clone=function(){return this._cloneProps(new t(this.spriteSheet))},e._cloneProps=function(t){return r.prototype._cloneProps.call(this,t),t.currentFrame=this.currentFrame,t.currentAnimation=this.currentAnimation,t.paused=this.paused,t.currentAnimationFrame=this.currentAnimationFrame,t.framerate=this.framerate,t._animation=this._animation,t._currentFrame=this._currentFrame,t._skipAdvance=this._skipAdvance,t},e._tick=function(t){this.paused||(this._skipAdvance||this.advance(t&&t.delta),this._skipAdvance=!1),r.prototype._tick.call(this,t)},e._normalizeFrame=function(t){void 0===t&&(t=0);var e=this._animation,i=this.paused,n=this._currentFrame;if(e){var r=e.speed||1,s=this.currentAnimationFrame,a=e.frames.length;if(a<=s+t*r){var o=e.next;if(this._dispatchAnimationEnd(e,n,i,o,a-1))return;if(o)return this._goto(o,t-(a-s)/r);this.paused=!0,s=e.frames.length-1}else s+=t*r;this.currentAnimationFrame=s,this._currentFrame=e.frames[0|s]}else{n=this._currentFrame+=t;var h=this.spriteSheet.getNumFrames();if(h<=n&&0<h&&!this._dispatchAnimationEnd(e,n,i,h-1)&&(this._currentFrame-=h)>=h)return this._normalizeFrame()}n=0|this._currentFrame,this.currentFrame!=n&&(this.currentFrame=n,this.dispatchEvent("change"))},e._dispatchAnimationEnd=function(t,e,i,n,r){var s=t?t.name:null;if(this.hasEventListener("animationend")){var a=new h("animationend");a.name=s,a.next=n,this.dispatchEvent(a)}var o=this._animation!=t||this._currentFrame!=e;return o||i||!this.paused||(this.currentAnimationFrame=r,o=!0),o},e._goto=function(t,e){if(void 0===e&&(e=0),this.currentAnimationFrame=0,isNaN(t)){var i=this.spriteSheet.getAnimation(t);i&&(this._animation=i,this.currentAnimation=t,this._normalizeFrame(e))}else this.currentAnimation=this._animation=null,this._currentFrame=t,this._normalizeFrame()},t}(w),D=function(n){function m(t,e){var i;return void 0===t&&(t=""),void 0===e&&(e=null),(i=n.call(this)||this).text=t,i.spriteSheet=e,i.lineHeight=0,i.letterSpacing=0,i.spaceWidth=0,i._oldProps={text:0,spriteSheet:0,lineHeight:0,letterSpacing:0,spaceWidth:0},i._oldStage=null,i._drawAction=null,i}l(m,n);var t=m.prototype;return t.draw=function(t,e){this.drawCache(t,e)||(this._updateState(),n.prototype.draw.call(this,t,e))},t.getBounds=function(){return this._updateText(),n.prototype.getBounds.call(this)},t.isVisible=function(){var t=this.cacheCanvas||this.spriteSheet&&this.spriteSheet.complete&&this.text;return!!(this.visible&&0<this.alpha&&0!==this.scaleX&&0!==this.scaleY&&t)},t.clone=function(){return this._cloneProps(new m(this.text,this.spriteSheet))},t.addChild=function(){},t.addChildAt=function(){},t.removeChild=function(){},t.removeChildAt=function(){},t.removeAllChildren=function(){},t._updateState=function(){this._updateText()},t._cloneProps=function(t){return n.prototype._cloneProps.call(this,t),t.lineHeight=this.lineHeight,t.letterSpacing=this.letterSpacing,t.spaceWidth=this.spaceWidth,t},t._getFrameIndex=function(t,e){var i,n=e.getAnimation(t);return n||(t!=(i=t.toUpperCase())||t!=(i=t.toLowerCase())||(i=null),i&&(n=e.getAnimation(i))),n&&n.frames[0]},t._getFrame=function(t,e){var i=this._getFrameIndex(t,e);return null==i?i:e.getFrame(i)},t._getLineHeight=function(t){var e=this._getFrame("1",t)||this._getFrame("T",t)||this._getFrame("L",t)||t.getFrame(0);return e?e.rect.height:1},t._getSpaceWidth=function(t){var e=this._getFrame("1",t)||this._getFrame("l",t)||this._getFrame("e",t)||this._getFrame("a",t)||t.getFrame(0);return e?e.rect.width:1},t._tick=function(t){var e=this.stage;e&&e.on("drawstart",this._updateText,this,!0),n.prototype._tick.call(this,t)},t._updateText=function(){var t,e=0,i=0,n=this._oldProps,r=!1,s=this.spaceWidth,a=this.lineHeight,o=this.spriteSheet,h=m._spritePool,u=this.children,l=0,c=u.length;for(var d in n)n[d]!=this[d]&&(n[d]=this[d],r=!0);if(r){var f=!!this._getFrame(" ",o);f||s||(s=this._getSpaceWidth(o)),a||(a=this._getLineHeight(o));for(var p=0,_=this.text.length;p<_;p++){var v=this.text.charAt(p);if(" "!==v||f)if("\n"!==v&&"\r"!==v){var g=this._getFrameIndex(v,o);null!=g&&(l<c?t=u[l]:(u.push(t=h.length?h.pop():new k),t.parent=this,c++),t.spriteSheet=o,t.gotoAndStop(g),t.x=e,t.y=i,l++,e+=t.getBounds().width+this.letterSpacing)}else"\r"===v&&"\n"===this.text.charAt(p+1)&&p++,e=0,i+=a;else e+=s}for(;l<c;)h.push(t=u.pop()),t.parent=null,c--;h.length>m.maxPoolSize&&(h.length=m.maxPoolSize)}},m}(b);D.maxPoolSize=100,D._spritePool=[];var L=function(n){function t(t){var e;e=n.call(this)||this,"string"==typeof t&&(t=document.getElementById(t)),e.mouseEnabled=!1;var i=t.style;return i.position="absolute",i.transformOrigin=i.WebkitTransformOrigin=i.msTransformOrigin=i.MozTransformOrigin=i.OTransformOrigin="0% 0%",e.htmlElement=t,e._oldProps=null,e._oldStage=null,e._drawAction=null,e}l(t,n);var e=t.prototype;return e.isVisible=function(){return null!=this.htmlElement},e.draw=function(t,e){return!0},e.cache=function(){},e.uncache=function(){},e.updateCache=function(){},e.hitTest=function(){},e.localToGlobal=function(){},e.globalToLocal=function(){},e.localToLocal=function(){},e.clone=function(){throw"DOMElement cannot be cloned."},e._tick=function(t){var e=this.stage;null!=e&&e!==this._oldStage&&(this._drawAction&&e.off("drawend",this._drawAction),this._drawAction=e.on("drawend",this._handleDrawEnd,this),this._oldStage=e),n.prototype._tick