text: !function t(e,i,r){function n(s,a){if(!i[s]){if(!e[s]){var h="function"==typeof require&&require;if(!a&&h)return h(s,!0);if(o)return o(s,!0);var l=new Error("Cannot find module '"+s+"'");throw l.code="MODULE_NOT_FOUND",l}var u=i[s]={exports:{}};e[s][0].call(u.exports,function(t){var i=e[s][1][t];return n(i||t)},u,u.exports,t,e,i,r)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)n(r[s]);return n}({1:[function(t,e,i){e.exports.lerp=function(t,e,i){return t*(1-i)+e*i},e.exports.smoothstep=function(t,e,i){return(i=Math.max(0,Math.min(1,(i-t)/(e-t))))*i*(3-2*i)}},{}],2:[function(t,e,i){function r(t){return!!t.get&&"function"==typeof t.get||!!t.set&&"function"==typeof t.set}function n(t,e,i){var n=i?t[e]:Object.getOwnPropertyDescriptor(t,e);return!i&&n.value&&"object"==typeof n.value&&(n=n.value),!(!n||!r(n))&&(void 0===n.enumerable&&(n.enumerable=!0),void 0===n.configurable&&(n.configurable=!0),n)}function o(t,e){var i=Object.getOwnPropertyDescriptor(t,e);return!!i&&(i.value&&"object"==typeof i.value&&(i=i.value),!1===i.configurable)}function s(t,e,i,r){for(var s in e)if(e.hasOwnProperty(s)){var a=n(e,s,i);if(!1!==a){var l=r||t;if(o(l.prototype,s)){if(h.ignoreFinals)continue;throw new Error("cannot override final property '"+s+"', set Class.ignoreFinals = true to skip")}Object.defineProperty(t.prototype,s,a)}else t.prototype[s]=e[s]}}function a(t,e){if(e){Array.isArray(e)||(e=[e]);for(var i=0;i<e.length;i++)s(t,e[i].prototype||e[i])}}function h(t){t||(t={});var e,i;if(t.initialize){if("function"!=typeof t.initialize)throw new Error("initialize must be a function");e=t.initialize,delete t.initialize}else if(t.Extends){var r=t.Extends;e=function(){r.apply(this,arguments)}}else e=function(){};t.Extends?(e.prototype=Object.create(t.Extends.prototype),e.prototype.constructor=e,i=t.Extends,delete t.Extends):e.prototype.constructor=e;var n=null;return t.Mixins&&(n=t.Mixins,delete t.Mixins),a(e,n),s(e,t,!0,i),e}h.extend=s,h.mixin=a,h.ignoreFinals=!1,e.exports=h},{}],3:[function(t,e,i){(function(t){(function(){function r(t,e,i){for(var r=(i||0)-1,n=t?t.length:0;++r<n;)if(t[r]===e)return r;return-1}function n(t,e){var i=typeof e;if(t=t.cache,"boolean"==i||null==e)return t[e]?0:-1;"number"!=i&&"string"!=i&&(i="object");var n="number"==i?e:b+e;return t=(t=t[i])&&t[n],"object"==i?t&&r(t,e)>-1?0:-1:t?0:-1}function o(t){var e=this.cache,i=typeof t;if("boolean"==i||null==t)e[t]=!0;else{"number"!=i&&"string"!=i&&(i="object");var r="number"==i?t:b+t,n=e[i]||(e[i]={});"object"==i?(n[r]||(n[r]=[])).push(t):n[r]=!0}}function s(t){return t.charCodeAt(0)}function a(t,e){for(var i=t.criteria,r=e.criteria,n=-1,o=i.length;++n<o;){var s=i[n],a=r[n];if(s!==a){if(s>a||void 0===s)return 1;if(s<a||void 0===a)return-1}}return t.index-e.index}function h(t){var e=-1,i=t.length,r=t[0],n=t[i/2|0],s=t[i-1];if(r&&"object"==typeof r&&n&&"object"==typeof n&&s&&"object"==typeof s)return!1;var a=c();a.false=a.null=a.true=a.undefined=!1;var h=c();for(h.array=t,h.cache=a,h.push=o;++e<i;)h.push(t[e]);return h}function l(t){return"\\"+Q[t]}function u(){return m.pop()||[]}function c(){return x.pop()||{array:null,cache:null,criteria:null,false:!1,index:0,null:!1,number:null,object:null,push:null,string:null,true:!1,undefined:!1,value:null}}function d(t){t.length=0,m.length<S&&m.push(t)}function f(t){var e=t.cache;e&&f(e),t.array=t.cache=t.criteria=t.object=t.number=t.string=t.value=null,x.length<S&&x.push(t)}function p(t,e,i){e||(e=0),void 0===i&&(i=t?t.length:0);for(var r=-1,n=i-e||0,o=Array(n<0?0:n);++r<n;)o[r]=t[e+r];return o}function g(t){function e(t){return t&&"object"==typeof t&&!Ji(t)&&Ii.call(t,"__wrapped__")?t:new i(t)}function i(t,e){this.__chain__=!!e,this.__wrapped__=t}function o(t){function e(){if(r){var t=p(r);Pi.apply(t,arguments)}if(this instanceof e){var o=x(i.prototype),s=i.apply(o,t||arguments);return Lt(s)?s:o}return i.apply(n,t||arguments)}var i=t[0],r=t[2],n=t[4];return Qi(e,t),e}function m(t,e,i,r,n){if(i){var o=i(t);if(void 0!==o)return o}if(!Lt(t))return t;var s=Ci.call(t);if(!z[s])return t;var a=qi[s];switch(s){case k:case U:return new a(+t);case W:case X:return new a(t);case Y:return o=a(t.source,R.exec(t)),o.lastIndex=t.lastIndex,o}var h=Ji(t);if(e){var l=!r;r||(r=u()),n||(n=u());for(var c=r.length;c--;)if(r[c]==t)return n[c];o=h?a(t.length):{}}else o=h?p(t):nr({},t);return h&&(Ii.call(t,"index")&&(o.index=t.index),Ii.call(t,"input")&&(o.input=t.input)),e?(r.push(t),n.push(o),(h?Qt:ar)(t,function(t,s){o[s]=m(t,e,i,r,n)}),l&&(d(r),d(n)),o):o}function x(t,e){return Lt(t)?ki(t):{}}function S(t,e,i){if("function"!=typeof t)return Je;if(void 0===e||!("prototype"in t))return t;var r=t.__bindData__;if(void 0===r&&(Ki.funcNames&&(r=!t.name),!(r=r||!Ki.funcDecomp))){var n=Fi.call(t);Ki.funcNames||(r=!M.test(n)),r||(r=I.test(n),Qi(t,r))}if(!1===r||!0!==r&&1&r[1])return t;switch(i){case 1:return function(i){return t.call(e,i)};case 2:return function(i,r){return t.call(e,i,r)};case 3:return function(i,r,n){return t.call(e,i,r,n)};case 4:return function(i,r,n,o){return t.call(e,i,r,n,o)}}return Pe(t,e)}function Q(t){function e(){var t=h?s:this;if(n){var f=p(n);Pi.apply(f,arguments)}if((o||u)&&(f||(f=p(arguments)),o&&Pi.apply(f,o),u&&f.length<a))return r|=16,Q([i,c?r:-4&r,f,null,s,a]);if(f||(f=arguments),l&&(i=t[d]),this instanceof e){t=x(i.prototype);var g=i.apply(t,f);return Lt(g)?g:t}return i.apply(t,f)}var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],h=1&r,l=2&r,u=4&r,c=8&r,d=i;return Qi(e,t),e}function $(t,e){var i=-1,o=ht(),s=t?t.length:0,a=s>=T&&o===r,l=[];if(a){var u=h(e);u?(o=n,e=u):a=!1}for(;++i<s;){var c=t[i];o(e,c)<0&&l.push(c)}return a&&f(e),l}function Z(t,e,i,r){for(var n=(r||0)-1,o=t?t.length:0,s=[];++n<o;){var a=t[n];if(a&&"object"==typeof a&&"number"==typeof a.length&&(Ji(a)||dt(a))){e||(a=Z(a,e,i));var h=-1,l=a.length,u=s.length;for(s.length+=l;++h<l;)s[u++]=a[h]}else i||s.push(a)}return s}function tt(t,e,i,r,n,o){if(i){var s=i(t,e);if(void 0!==s)return!!s}if(t===e)return 0!==t||1/t==1/e;var a=typeof t,h=typeof e;if(!(t!==t||t&&K[a]||e&&K[h]))return!1;if(null==t||null==e)return t===e;var l=Ci.call(t),c=Ci.call(e);if(l==G&&(l=V),c==G&&(c=V),l!=c)return!1;switch(l){case k:case U:return+t==+e;case W:return t!=+t?e!=+e:0==t?1/t==1/e:t==+e;case Y:case X:return t==Ti(e)}var f=l==N;if(!f){var p=Ii.call(t,"__wrapped__"),g=Ii.call(e,"__wrapped__");if(p||g)return tt(p?t.__wrapped__:t,g?e.__wrapped__:e,i,r,n,o);if(l!=V)return!1;var v=t.constructor,m=e.constructor;if(v!=m&&!(Mt(v)&&v instanceof v&&Mt(m)&&m instanceof m)&&"constructor"in t&&"constructor"in e)return!1}var x=!n;n||(n=u()),o||(o=u());for(var y=n.length;y--;)if(n[y]==t)return o[y]==e;var b=0;if(s=!0,n.push(t),o.push(e),f){if(y=t.length,b=e.length,(s=b==y)||r)for(;b--;){var T=y,S=e[b];if(r)for(;T--&&!(s=tt(t[T],S,i,r,n,o)););else if(!(s=tt(t[b],S,i,r,n,o)))break}}else sr(e,function(e,a,h){if(Ii.call(h,a))return b++,s=Ii.call(t,a)&&tt(t[a],e,i,r,n,o)}),s&&!r&&sr(t,function(t,e,i){if(Ii.call(i,e))return s=--b>-1});return n.pop(),o.pop(),x&&(d(n),d(o)),s}function et(t,e,i,r,n){(Ji(e)?Qt:ar)(e,function(e,o){var s,a,h=e,l=t[o];if(e&&((a=Ji(e))||hr(e))){for(var u=r.length;u--;)if(s=r[u]==e){l=n[u];break}if(!s){var c;i&&(h=i(l,e),(c=void 0!==h)&&(l=h)),c||(l=a?Ji(l)?l:[]:hr(l)?l:{}),r.push(e),n.push(l),c||et(l,e,i,r,n)}}else i&&void 0===(h=i(l,e))&&(h=e),void 0!==h&&(l=h);t[o]=l})}function rt(t,e){return t+Li(Hi()*(e-t+1))}function nt(t,e,i){var o=-1,s=ht(),a=t?t.length:0,l=[],c=!e&&a>=T&&s===r,p=i||c?u():l;if(c){var g=h(p);s=n,p=g}for(;++o<a;){var v=t[o],m=i?i(v,o,t):v;(e?!o||p[p.length-1]!==m:s(p,m)<0)&&((i||c)&&p.push(m),l.push(v))}return c?(d(p.array),f(p)):i&&d(p),l}function ot(t){return function(i,r,n){var o={};r=e.createCallback(r,n,3);var s=-1,a=i?i.length:0;if("number"==typeof a)for(;++s<a;){var h=i[s];t(o,h,r(h,s,i),i)}else ar(i,function(e,i,n){t(o,e,r(e,i,n),n)});return o}}function st(t,e,i,r,n,s){var a=1&e,h=2&e,l=4&e,u=16&e,c=32&e;if(!h&&!Mt(t))throw new Si;u&&!i.length&&(e&=-17,u=i=!1),c&&!r.length&&(e&=-33,c=r=!1);var d=t&&t.__bindData__;return d&&!0!==d?(d=p(d),d[2]&&(d[2]=p(d[2])),d[3]&&(d[3]=p(d[3])),!a||1&d[1]||(d[4]=n),!a&&1&d[1]&&(e|=8),!l||4&d[1]||(d[5]=s),u&&Pi.apply(d[2]||(d[2]=[]),i),c&&Gi.apply(d[3]||(d[3]=[]),r),d[1]|=e,st.apply(null,d)):(1==e||17===e?o:Q)([t,e,i,r,n,s])}function at(t){return tr[t]}function ht(){var t=(t=e.indexOf)===me?r:t;return t}function lt(t){return"function"==typeof t&&Ai.test(t)}function ut(t){var e,i;return!!(t&&Ci.call(t)==V&&(e=t.constructor,!Mt(e)||e instanceof e))&&(sr(t,function(t,e){i=e}),void 0===i||Ii.call(t,i))}function ct(t){return er[t]}function dt(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Ci.call(t)==G||!1}function ft(t,e,i,r){return"boolean"!=typeof e&&null!=e&&(r=i,i=e,e=!1),m(t,e,"function"==typeof i&&S(i,r,1))}function pt(t,e,i){return m(t,!0,"function"==typeof e&&S(e,i,1))}function gt(t,e){var i=x(t);return e?nr(i,e):i}function vt(t,i,r){var n;return i=e.createCallback(i,r,3),ar(t,function(t,e,r){if(i(t,e,r))return n=e,!1}),n}function mt(t,i,r){var n;return i=e.createCallback(i,r,3),yt(t,function(t,e,r){if(i(t,e,r))return n=e,!1}),n}function xt(t,e,i){var r=[];sr(t,function(t,e){r.push(e,t)});var n=r.length;for(e=S(e,i,3);n--&&!1!==e(r[n--],r[n],t););return t}function yt(t,e,i){var r=Zi(t),n=r.length;for(e=S(e,i,3);n--;){var o=r[n];if(!1===e(t[o],o,t))break}return t}function bt(t){var e=[];return sr(t,function(t,i){Mt(t)&&e.push(i)}),e.sort()}function Tt(t,e){return!!t&&Ii.call(t,e)}function St(t){for(var e=-1,i=Zi(t),r=i.length,n={};++e<r;){var o=i[e];n[t[o]]=o}return n}function _t(t){return!0===t||!1===t||t&&"object"==typeof t&&Ci.call(t)==k||!1}function wt(t){return t&&"object"==typeof t&&Ci.call(t)==U||!1}function Et(t){return t&&1===t.nodeType||!1}function Ct(t){var e=!0;if(!t)return e;var i=Ci.call(t),r=t.length;return i==N||i==X||i==G||i==V&&"number"==typeof r&&Mt(t.splice)?!r:(ar(t,function(){return e=!1}),e)}function At(t,e,i,r){return tt(t,e,"function"==typeof i&&S(i,r,2))}function Rt(t){return ji(t)&&!Wi(parseFloat(t))}function Mt(t){return"function"==typeof t}function Lt(t){return!(!t||!K[typeof t])}function Ft(t){return It(t)&&t!=+t}function Bt(t){return null===t}function It(t){return"number"==typeof t||t&&"object"==typeof t&&Ci.call(t)==W||!1}function Pt(t){return t&&"object"==typeof t&&Ci.call(t)==Y||!1}function Ot(t){return"string"==typeof t||t&&"object"==typeof t&&Ci.call(t)==X||!1}function Dt(t){return void 0===t}function Gt(t,i,r){var n={};return i=e.createCallback(i,r,3),ar(t,function(t,e,r){n[e]=i(t,e,r)}),n}function Nt(t){var e=arguments,i=2;if(!Lt(t))return t;if("number"!=typeof e[2]&&(i=e.length),i>3&&"function"==typeof e[i-2])var r=S(e[--i-1],e[i--],2);else i>2&&"function"==typeof e[i-1]&&(r=e[--i]);for(var n=p(arguments,1,i),o=-1,s=u(),a=u();++o<i;)et(t,n[o],r,s,a);return d(s),d(a),t}function kt(t,i,r){var n={};if("function"!=typeof i){var o=[];sr(t,function(t,e){o.push(e)}),o=$(o,Z(arguments,!0,!1,1));for(var s=-1,a=o.length;++s<a;){var h=o[s];n[h]=t[h]}}else i=e.createCallback(i,r,3),sr(t,function(t,e,r){i(t,e,r)||(n[e]=t)});return n}function Ut(t){for(var e=-1,i=Zi(t),r=i.length,n=fi(r);++e<r;){var o=i[e];n[e]=[o,t[o]]}return n}function jt(t,i,r){var n={};if("function"!=typeof i)for(var o=-1,s=Z(arguments,!0,!1,1),a=Lt(t)?s.length:0;++o<a;){var h=s[o];h in t&&(n[h]=t[h])}else i=e.createCallback(i,r,3),sr(t,function(t,e,r){i(t,e,r)&&(n[e]=t)});return n}function Wt(t,i,r,n){var o=Ji(t);if(null==r)if(o)r=[];else{var s=t&&t.constructor,a=s&&s.prototype;r=x(a)}return i&&(i=e.createCallback(i,n,4),(o?Qt:ar)(t,function(t,e,n){return i(r,t,e,n)})),r}function Vt(t){for(var e=-1,i=Zi(t),r=i.length,n=fi(r);++e<r;)n[e]=t[i[e]];return n}function Yt(t){for(var e=arguments,i=-1,r=Z(e,!0,!1,1),n=e[2]&&e[2][e[1]]===t?1:r.length,o=fi(n);++i<n;)o[i]=t[r[i]];return o}function Xt(t,e,i){var r=-1,n=ht(),o=t?t.length:0,s=!1;return i=(i<0?Yi(0,o+i):i)||0,Ji(t)?s=n(t,e,i)>-1:"number"==typeof o?s=(Ot(t)?t.indexOf(e,i):n(t,e,i))>-1:ar(t,function(t){if(++r>=i)return!(s=t===e)}),s}function zt(t,i,r){var n=!0;i=e.createCallback(i,r,3);var o=-1,s=t?t.length:0;if("number"==typeof s)for(;++o<s&&(n=!!i(t[o],o,t)););else ar(t,function(t,e,r){return n=!!i(t,e,r)});return n}function Ht(t,i,r){var n=[];i=e.createCallback(i,r,3);var o=-1,s=t?t.length:0;if("number"==typeof s)for(;++o<s;){var a=t[o];i(a,o,t)&&n.push(a)}else ar(t,function(t,e,r){i(t,e,r)&&n.push(t)});return n}function qt(t,i,r){i=e.createCallback(i,r,3);var n=-1,o=t?t.length:0;if("number"!=typeof o){var s;return ar(t,function(t,e,r){if(i(t,e,r))return s=t,!1}),s}for(;++n<o;){var a=t[n];if(i(a,n,t))return a}}function Kt(t,i,r){var n;return i=e.createCallback(i,r,3),Jt(t,function(t,e,r){if(i(t,e,r))return n=t,!1}),n}function Qt(t,e,i){var r=-1,n=t?t.length:0;if(e=e&&void 0===i?e:S(e,i,3),"number"==typeof n)for(;++r<n&&!1!==e(t[r],r,t););else ar(t,e);return t}function Jt(t,e,i){var r=t?t.length:0;if(e=e&&void 0===i?e:S(e,i,3),"number"==typeof r)for(;r--&&!1!==e(t[r],r,t););else{var n=Zi(t);r=n.length,ar(t,function(t,i,o){return i=n?n[--r]:--r,e(o[i],i,o)})}return t}function $t(t,e){var i=p(arguments,2),r=-1,n="function"==typeof e,o=t?t.length:0,s=fi("number"==typeof o?o:0);return Qt(t,function(t){s[++r]=(n?e:t[e]).apply(t,i)}),s}function Zt(t,i,r){var n=-1,o=t?t.length:0;if(i=e.createCallback(i,r,3),"number"==typeof o)for(var s=fi(o);++n<o;)s[n]=i(t[n],n,t);else s=[],ar(t,function(t,e,r){s[++n]=i(t,e,r)});return s}function te(t,i,r){var n=-1/0,o=n;if("function"!=typeof i&&r&&r[i]===t&&(i=null),null==i&&Ji(t))for(var a=-1,h=t.length;++a<h;){var l=t[a];l>o&&(o=l)}else i=null==i&&Ot(t)?s:e.createCallback(i,r,3),Qt(t,function(t,e,r){var s=i(t,e,r);s>n&&(n=s,o=t)});return o}function ee(t,i,r){var n=1/0,o=n;if("function"!=typeof i&&r&&r[i]===t&&(i=null),null==i&&Ji(t))for(var a=-1,h=t.length;++a<h;){var l=t[a];l<o&&(o=l)}else i=null==i&&Ot(t)?s:e.createCallback(i,r,3),Qt(t,function(t,e,r){var s=i(t,e,r);s<n&&(n=s,o=t)});return o}function ie(t,i,r,n){if(!t)return r;var o=arguments.length<3;i=e.createCallback(i,n,4);var s=-1,a=t.length;if("number"==typeof a)for(o&&(r=t[++s]);++s<a;)r=i(r,t[s],s,t);else ar(t,function(t,e,n){r=o?(o=!1,t):i(r,t,e,n)});return r}function re(t,i,r,n){var o=arguments.length<3;return i=e.createCallback(i,n,4),Jt(t,function(t,e,n){r=o?(o=!1,t):i(r,t,e,n)}),r}function ne(t,i,r){return i=e.createCallback(i,r,3),Ht(t,function(t,e,r){return!i(t,e,r)})}function oe(t,e,i){if(t&&"number"!=typeof t.length&&(t=Vt(t)),null==e||i)return t?t[rt(0,t.length-1)]:v;var r=se(t);return r.length=Xi(Yi(0,e),r.length),r}function se(t){var e=-1,i=t?t.length:0,r=fi("number"==typeof i?i:0);return Qt(t,function(t){var i=rt(0,++e);r[e]=r[i],r[i]=t}),r}function ae(t){var e=t?t.length:0;return"number"==typeof e?e:Zi(t).length}function he(t,i,r){var n;i=e.createCallback(i,r,3);var o=-1,s=t?t.length:0;if("number"==typeof s)for(;++o<s&&!(n=i(t[o],o,t)););else ar(t,function(t,e,r){return!(n=i(t,e,r))});return!!n}function le(t,i,r){var n=-1,o=Ji(i),s=t?t.length:0,h=fi("number"==typeof s?s:0);for(o||(i=e.createCallback(i,r,3)),Qt(t,function(t,e,r){var s=h[++n]=c();o?s.criteria=Zt(i,function(e){return t[e]}):(s.criteria=u())[0]=i(t,e,r),s.index=n,s.value=t}),s=h.length,h.sort(a);s--;){var l=h[s];h[s]=l.value,o||d(l.criteria),f(l)}return h}function ue(t){return t&&"number"==typeof t.length?p(t):Vt(t)}function ce(t){for(var e=-1,i=t?t.length:0,r=[];++e<i;){var n=t[e];n&&r.push(n)}return r}function de(t){return $(t,Z(arguments,!0,!0,1))}function fe(t,i,r){var n=-1,o=t?t.length:0;for(i=e.createCallback(i,r,3);++n<o;)if(i(t[n],n,t))return n;return-1}function pe(t,i,r){var n=t?t.length:0;for(i=e.createCallback(i,r,3);n--;)if(i(t[n],n,t))return n;return-1}function ge(t,i,r){var n=0,o=t?t.length:0;if("number"!=typeof i&&null!=i){var s=-1;for(i=e.createCallback(i,r,3);++s<o&&i(t[s],s,t);)n++}else if(null==(n=i)||r)return t?t[0]:v;return p(t,0,Xi(Yi(0,n),o))}function ve(t,e,i,r){return"boolean"!=typeof e&&null!=e&&(r=i,i="function"!=typeof e&&r&&r[e]===t?null:e,e=!1),null!=i&&(t=Zt(t,i,r)),Z(t,e)}function me(t,e,i){if("number"==typeof i){var n=t?t.length:0;i=i<0?Yi(0,n+i):i||0}else if(i){var o=Ce(t,e);return t[o]===e?o:-1}return r(t,e,i)}function xe(t,i,r){var n=0,o=t?t.length:0;if("number"!=typeof i&&null!=i){var s=o;for(i=e.createCallback(i,r,3);s--&&i(t[s],s,t);)n++}else n=null==i||r?1:i||n;return p(t,0,Xi(Yi(0,o-n),o))}function ye(){for(var t=[],e=-1,i=arguments.length,o=u(),s=ht(),a=s===r,l=u();++e<i;){var c=arguments[e];(Ji(c)||dt(c))&&(t.push(c),o.push(a&&c.length>=T&&h(e?t[e]:l)))}var p=t[0],g=-1,v=p?p.length:0,m=[];t:for(;++g<v;){var x=o[0];if(c=p[g],(x?n(x,c):s(l,c))<0){for(e=i,(x||l).push(c);--e;)if(x=o[e],(x?n(x,c):s(t[e],c))<0)continue t;m.push(c)}}for(;i--;)(x=o[i])&&f(x);return d(o),d(l),m}function be(t,i,r){var n=0,o=t?t.length:0;if("number"!=typeof i&&null!=i){var s=o;for(i=e.createCallback(i,r,3);s--&&i(t[s],s,t);)n++}else if(null==(n=i)||r)return t?t[o-1]:v;return p(t,Yi(0,o-n))}function Te(t,e,i){var r=t?t.length:0;for("number"==typeof i&&(r=(i<0?Yi(0,r+i):Xi(i,r-1))+1);r--;)if(t[r]===e)return r;return-1}function Se(t){for(var e=arguments,i=0,r=e.length,n=t?t.length:0;++i<r;)for(var o=-1,s=e[i];++o<n;)t[o]===s&&(Di.call(t,o--,1),n--);return t}function _e(t,e,i){t=+t||0,i="number"==typeof i?i:+i||1,null==e&&(e=t,t=0);for(var r=-1,n=Yi(0,Ri((e-t)/(i||1))),o=fi(n);++r<n;)o[r]=t,t+=i;return o}function we(t,i,r){var n=-1,o=t?t.length:0,s=[];for(i=e.createCallback(i,r,3);++n<o;){var a=t[n];i(a,n,t)&&(s.push(a),Di.call(t,n--,1),o--)}return s}function Ee(t,i,r){if("number"!=typeof i&&null!=i){var n=0,o=-1,s=t?t.length:0;for(i=e.createCallback(i,r,3);++o<s&&i(t[o],o,t);)n++}else n=null==i||r?1:Yi(0,i);return p(t,n)}function Ce(t,i,r,n){var o=0,s=t?t.length:o;for(r=r?e.createCallback(r,n,1):Je,i=r(i);o<s;){var a=o+s>>>1;r(t[a])<i?o=a+1:s=a}return o}function Ae(){return nt(Z(arguments,!0,!0))}function Re(t,i,r,n){return"boolean"!=typeof i&&null!=i&&(n=r,r="function"!=typeof i&&n&&n[i]===t?null:i,i=!1),null!=r&&(r=e.createCallback(r,n,3)),nt(t,i,r)}function Me(t){return $(t,p(arguments,1))}function Le(){for(var t=-1,e=arguments.length;++t<e;){var i=arguments[t];if(Ji(i)||dt(i))var r=r?nt($(r,i).concat($(i,r))):i}return r||[]}function Fe(){for(var t=arguments.length>1?arguments:arguments[0],e=-1,i=t?te(dr(t,"length")):0,r=fi(i<0?0:i);++e<i;)r[e]=dr(t,e);return r}function Be(t,e){var i=-1,r=t?t.length:0,n={};for(e||!r||Ji(t[0])||(e=[]);++i<r;){var o=t[i];e?n[o]=e[i]:o&&(n[o[0]]=o[1])}return n}function Ie(t,e){if(!Mt(e))throw new Si;return function(){if(--t<1)return e.apply(this,arguments)}}function Pe(t,e){return arguments.length>2?st(t,17,p(arguments,2),null,e):st(t,1,null,null,e)}function Oe(t){for(var e=arguments.length>1?Z(arguments,!0,!1,1):bt(t),i=-1,r=e.length;++i<r;){var n=e[i];t[n]=st(t[n],1,null,null,t)}return t}function De(t,e){return arguments.length>2?st(e,19,p(arguments,2),null,t):st(e,3,null,null,t)}function Ge(){for(var t=arguments,e=t.length;e--;)if(!Mt(t[e]))throw new Si;return function(){for(var e=arguments,i=t.length;i--;)e=[t[i].apply(this,e)];return e[0]}}function Ne(t,e){return e="number"==typeof e?e:+e||t.length,st(t,4,null,null,null,e)}function ke(t,e,i){var r,n,o,s,a,h,l,u=0,c=!1,d=!0;if(!Mt(t))throw new Si;if(e=Yi(0,e)||0,!0===i){var f=!0;d=!1}else Lt(i)&&(f=i.leading,c="maxWait"in i&&(Yi(e,i.maxWait)||0),d="trailing"in i?i.trailing:d);var p=function(){var i=e-(pr()-s);if(i<=0){n&&Mi(n);var c=l;n=h=l=v,c&&(u=pr(),o=t.apply(a,r),h||n||(r=a=null))}else h=Oi(p,i)},g=function(){h&&Mi(h),n=h=l=v,(d||c!==e)&&(u=pr(),o=t.apply(a,r),h||n||(r=a=null))};return function(){if(r=arguments,s=pr(),a=this,l=d&&(h||!f),!1===c)var i=f&&!h;else{n||f||(u=s);var v=c-(s-u),m=v<=0;m?(n&&(n=Mi(n)),u=s,o=t.apply(a,r)):n||(n=Oi(g,v))}return m&&h?h=Mi(h):h||e===c||(h=Oi(p,e)),i&&(m=!0,o=t.apply(a,r)),!m||h||n||(r=a=null),o}}function Ue(t){if(!Mt(t))throw new Si;var e=p(arguments,1);return Oi(function(){t.apply(v,e)},1)}function je(t,e){if(!Mt(t))throw new Si;var i=p(arguments,2);return Oi(function(){t.apply(v,i)},e)}function We(t,e){if(!Mt(t))throw new Si;var i=function(){var r=i.cache,n=e?e.apply(this,arguments):b+arguments[0];return Ii.call(r,n)?r[n]:r[n]=t.apply(this,arguments)};return i.cache={},i}function Ve(t){var e,i;if(!Mt(t))throw new Si;return function(){return e?i:(e=!0,i=t.apply(this,arguments),t=null,i)}}function Ye(t){return st(t,16,p(arguments,1))}function Xe(t){return st(t,32,null,p(arguments,1))}function ze(t,e,i){var r=!0,n=!0;if(!Mt(t))throw new Si;return!1===i?r=!1:Lt(i)&&(r="leading"in i?i.leading:r,n="trailing"in i?i.trailing:n),H.leading=r,H.maxWait=e,H.trailing=n,ke(t,e,H)}function He(t,e){return st(e,16,[t])}function qe(t){return function(){return t}}function Ke(t,e,i){var r=typeof t;if(null==t||"function"==r)return S(t,e,i);if("object"!=r)return ei(t);var n=Zi(t),o=n[0],s=t[o];return 1!=n.length||s!==s||Lt(s)?function(e){for(var i=n.length,r=!1;i--&&(r=tt(e[n[i]],t[n[i]],null,!0)););return r}:function(t){var e=t[o];return s===e&&(0!==s||1/s==1/e)}}function Qe(t){return null==t?"":Ti(t).replace(rr,at)}function Je(t){return t}function $e(t,r,n){var o=!0,s=r&&bt(r);r&&(n||s.length)||(null==n&&(n=r),a=i,r=t,t=e,s=bt(r)),!1===n?o=!1:Lt(n)&&"chain"in n&&(o=n.chain);var a=t,h=Mt(a);Qt(s,function(e){var i=t[e]=r[e];h&&(a.prototype[e]=function(){var e=this.__chain__,r=this.__wrapped__,n=[r];Pi.apply(n,arguments);var s=i.apply(t,n);if(o||e){if(r===s&&Lt(s))return this;s=new a(s),s.__chain__=e}return s})})}function Ze(){return t._=Ei,this}function ti(){}function ei(t){return function(e){return e[t]}}function ii(t,e,i){var r=null==t,n=null==e;if(null==i&&("boolean"==typeof t&&n?(i=t,t=1):n||"boolean"!=typeof e||(i=e,n=!0)),r&&n&&(e=1),t=+t||0,n?(e=t,t=0):e=+e||0,i||t%1||e%1){var o=Hi();return Xi(t+o*(e-t+parseFloat("1e-"+((o+"").length-1))),e)}return rt(t,e)}function ri(t,e){if(t){var i=t[e];return Mt(i)?t[e]():i}}function ni(t,i,r){var n=e.templateSettings;t=Ti(t||""),r=or({},r,n);var o,s=or({},r.imports,n.imports),a=Zi(s),h=Vt(s),u=0,c=r.interpolate||B,d="__p += '",f=bi((r.escape||B).source+"|"+c.source+"|"+(c===L?A:B).source+"|"+(r.evaluate||B).source+"|$","g");t.replace(f,function(e,i,r,n,s,a){return r||(r=n),d+=t.slice(u,a).replace(P,l),i&&(d+="' +\n__e("+i+") +\n'"),s&&(o=!0,d+="';\n"+s+";\n__p += '"),r&&(d+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=a+e.length,e}),d+="';\n";var p=r.variable,g=p;g||(p="obj",d="with ("+p+") {\n"+d+"\n}\n"),d=(o?d.replace(w,""):d).replace(E,"$1").replace(C,"$1;"),d="function("+p+") {\n"+(g?"":p+" || ("+p+" = {});\n")+"var __t, __p = '', __e = _.escape"+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+d+"return __p\n}";var m="\n/*\n//# sourceURL="+(r.sourceURL||"/lodash/template/source["+D+++"]")+"\n*/";try{var x=vi(a,"return "+d+m).apply(v,h)}catch(t){throw t.source=d,t}return i?x(i):(x.source=d,x)}function oi(t,e,i){t=(t=+t)>-1?t:0;var r=-1,n=fi(t);for(e=S(e,i,1);++r<t;)n[r]=e(r);return n}function si(t){return null==t?"":Ti(t).replace(ir,ct)}function ai(t){var e=++y;return Ti(null==t?"":t)+e}function hi(t){return t=new i(t),t.__chain__=!0,t}function li(t,e){return e(t),t}function ui(){return this.__chain__=!0,this}function ci(){return Ti(this.__wrapped__)}function di(){return this.__wrapped__}t=t?it.defaults(J.Object(),t,it.pick(J,O)):J;var fi=t.Array,pi=t.Boolean,gi=t.Date,vi=t.Function,mi=t.Math,xi=t.Number,yi=t.Object,bi=t.RegExp,Ti=t.String,Si=t.TypeError,_i=[],wi=yi.prototype,Ei=t._,Ci=wi.toString,Ai=bi("^"+Ti(Ci).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$"),Ri=mi.ceil,Mi=t.clearTimeout,Li=mi.floor,Fi=vi.prototype.toString,Bi=lt(Bi=yi.getPrototypeOf)&&Bi,Ii=wi.hasOwnProperty,Pi=_i.push,Oi=t.setTimeout,Di=_i.splice,Gi=_i.unshift,Ni=function(){try{var t={},e=lt(e=yi.defineProperty)&&e,i=e(t,t,t)&&e}catch(t){}return i}(),ki=lt(ki=yi.create)&&ki,Ui=lt(Ui=fi.isArray)&&Ui,ji=t.isFinite,Wi=t.isNaN,Vi=lt(Vi=yi.keys)&&Vi,Yi=mi.max,Xi=mi.min,zi=t.parseInt,Hi=mi.random,qi={};qi[N]=fi,qi[k]=pi,qi[U]=gi,qi[j]=vi,qi[V]=yi,qi[W]=xi,qi[Y]=bi,qi[X]=Ti,i.prototype=e.prototype;var Ki=e.support={};Ki.funcDecomp=!lt(t.WinRTError)&&I.test(g),Ki.funcNames="string"==typeof vi.name,e.templateSettings={escape:/<%-([\s\S]+?)%>/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:L,variable:"",imports:{_:e}},ki||(x=function(){function e(){}return function(i){if(Lt(i)){e.prototype=i;var r=new e;e.prototype=null}return r||t.Object()}}());var Qi=Ni?function(t,e){q.value=e,Ni(t,"__bindData__",q),q.value=null}:ti,Ji=Ui||function(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Ci.call(t)==N||!1},$i=function(t){var e,i=t,r=[];if(!i)return r;if(!K[typeof t])return r;for(e in i)Ii.call(i,e)&&r.push(e);return r},Zi=Vi?function(t){return Lt(t)?Vi(t):[]}:$i,tr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},er=St(tr),ir=bi("("+Zi(er).join("|")+")","g"),rr=bi("["+Zi(tr).join("")+"]","g"),nr=function(t,e,i){var r,n=t,o=n;if(!n)return o;var s=arguments,a=0,h="number"==typeof i?2:s.length;if(h>3&&"function"==typeof s[h-2])var l=S(s[--h-1],s[h--],2);else h>2&&"function"==typeof s[h-1]&&(l=s[--h]);for(;++a<h;)if((n=s[a])&&K[typeof n])for(var u=-1,c=K[typeof n]&&Zi(n),d=c?c.length:0;++u<d;)r=c[u],o[r]=l?l(o[r],n[r]):n[r];return o},or=function(t,e,i){var r,n=t,o=n;if(!n)return o;for(var s=arguments,a=0,h="number"==typeof i?2:s.length;++a<h;)if((n=s[a])&&K[typeof n])for(var l=-1,u=K[typeof n]&&Zi(n),c=u?u.length:0;++l<c;)r=u[l],void 0===o[r]&&(o[r]=n[r]);return o},sr=function(t,e,i){var r,n=t,o=n;if(!n)return o;if(!K[typeof n])return o;e=e&&void 0===i?e:S(e,i,3);for(r in n)if(!1===e(n[r],r,t))return o;return o},ar=function(t,e,i){var r,n=t,o=n;if(!n)return o;if(!K[typeof n])return o;e=e&&void 0===i?e:S(e,i,3);for(var s=-1,a=K[typeof n]&&Zi(n),h=a?a.length:0;++s<h;)if(r=a[s],!1===e(n[r],r,t))return o;return o},hr=Bi?function(t){if(!t||Ci.call(t)!=V)return!1;var e=t.valueOf,i=lt(e)&&(i=Bi(e))&&Bi(i);return i?t==i||Bi(t)==i:ut(t)}:ut,lr=ot(function(t,e,i){Ii.call(t,i)?t[i]++:t[i]=1}),ur=ot(function(t,e,i){(Ii.call(t,i)?t[i]:t[i]=[]).push(e)}),cr=ot(function(t,e,i){t[i]=e}),dr=Zt,fr=Ht,pr=lt(pr=gi.now)&&pr||function(){return(new gi).getTime()},gr=8==zi(_+"08")?zi:function(t,e){return zi(Ot(t)?t.replace(F,""):t,e||0)};return e.after=Ie,e.assign=nr,e.at=Yt,e.bind=Pe,e.bindAll=Oe,e.bindKey=De,e.chain=hi,e.compact=ce,e.compose=Ge,e.constant=qe,e.countBy=lr,e.create=gt,e.createCallback=Ke,e.curry=Ne,e.debounce=ke,e.defaults=or,e.defer=Ue,e.delay=je,e.difference=de,e.filter=Ht,e.flatten=ve,e.forEach=Qt,e.forEachRight=Jt,e.forIn=sr,e.forInRight=xt,e.forOwn=ar,e.forOwnRight=yt,e.functions=bt,e.groupBy=ur,e.indexBy=cr,e.initial=xe,e.intersection=ye,e.invert=St,e.invoke=$t,e.keys=Zi,e.map=Zt,e.mapValues=Gt,e.max=te,e.memoize=We,e.merge=Nt,e.min=ee,e.omit=kt,e.once=Ve,e.pairs=Ut,e.partial=Ye,e.partialRight=Xe,e.pick=jt,e.pluck=dr,e.property=ei,e.pull=Se,e.range=_e,e.reject=ne,e.remove=we,e.rest=Ee,e.shuffle=se,e.sortBy=le,e.tap=li,e.throttle=ze,e.times=oi,e.toArray=ue,e.transform=Wt,e.union=Ae,e.uniq=Re,e.values=Vt,e.where=fr,e.without=Me,e.wrap=He,e.xor=Le,e.zip=Fe,e.zipObject=Be,e.collect=Zt,e.drop=Ee,e.each=Qt,e.eachRight=Jt,e.extend=nr,e.methods=bt,e.object=Be,e.select=Ht,e.tail=Ee,e.unique=Re,e.unzip=Fe,$e(e),e.clone=ft,e.cloneDeep=pt,e.contains=Xt,e.escape=Qe,e.every=zt,e.find=qt,e.findIndex=fe,e.findKey=vt,e.findLast=Kt,e.findLastIndex=pe,e.findLastKey=mt,e.has=Tt,e.identity=Je,e.indexOf=me,e.isArguments=dt,e.isArray=Ji,e.isBoolean=_t,e.isDate=wt,e.isElement=Et,e.isEmpty=Ct,e.isEqual=At,e.isFinite=Rt,e.isFunction=Mt,e.isNaN=Ft,e.isNull=Bt,e.isNumber=It,e.isObject=Lt,e.isPlainObject=hr,e.isRegExp=Pt,e.isString=Ot,e.isUndefined=Dt,e.lastIndexOf=Te,e.mixin=$e,e.noConflict=Ze,e.noop=ti,e.now=pr,e.parseInt=gr,e.random=ii,e.reduce=ie,e.reduceRight=re,e.result=ri,e.runInContext=g,e.size=ae,e.some=he,e.sortedIndex=Ce,e.template=ni,e.unescape=si,e.uniqueId=ai,e.all=zt,e.any=he,e.detect=qt,e.findWhere=qt,e.foldl=ie,e.foldr=re,e.include=Xt,e.inject=ie,$e(function(){var t={};return ar(e,function(i,r){e.prototype[r]||(t[r]=i)}),t}(),!1),e.first=ge,e.last=be,e.sample=oe,e.take=ge,e.head=ge,ar(e,function(t,r){var n="sample"!==r;e.prototype[r]||(e.prototype[r]=function(e,r){var o=this.__chain__,s=t(this.__wrapped__,e,r);return o||null!=e&&(!r||n&&"function"==typeof e)?new i(s,o):s})}),e.VERSION="2.4.2",e.prototype.chain=ui,e.prototype.toString=ci,e.prototype.value=di,e.prototype.valueOf=di,Qt(["join","pop","shift"],function(t){var r=_i[t];e.prototype[t]=function(){var t=this.__chain__,e=r.apply(this.__wrapped__,arguments);return t?new i(e,t):e}}),Qt(["push","reverse","sort","unshift"],function(t){var i=_i[t];e.prototype[t]=function(){return i.apply(this.__wrapped__,arguments),this}}),Qt(["concat","slice","splice"],function(t){var r=_i[t];e.prototype[t]=function(){return new i(r.apply(this.__wrapped__,arguments),this.__chain__)}}),e}var v,m=[],x=[],y=0,b=+new Date+"",T=75,S=40,_=" \t\v\f \ufeff\n\r\u2028\u2029 ᠎             　",w=/\b__p \+= '';/g,E=/\b(__p \+=) '' \+/g,C=/(__e\(.*?\)|\b__t\)) \+\n'';/g,A=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,R=/\w*$/,M=/^\s*function[ \n\r\t]+\w/,L=/<%=([\s\S]+?)%>/g,F=RegExp("^["+_+"]*0+(?=.$)"),B=/($^)/,I=/\bthis\b/,P=/['\n\r\t\u2028\u2029\\]/g,O=["Array","Boolean","Date","Function","Math","Number","Object","RegExp","String","_","attachEvent","clearTimeout","isFinite","isNaN","parseInt","setTimeout"],D=0,G="[object Arguments]",N="[object Array]",k="[object Boolean]",U="[object Date]",j="[object Function]",W="[object Number]",V="[object Object]",Y="[object RegExp]",X="[object String]",z={};z[j]=!1,z[G]=z[N]=z[k]=z[U]=z[W]=z[V]=z[Y]=z[X]=!0;var H={leading:!1,maxWait:0,trailing:!1},q={configurable:!1,enumerable:!1,value:null,writable:!1},K={boolean:!1,function:!0,object:!0,number:!1,string:!1,undefined:!1},Q={"\\":"\\","'":"'","\n":"n","\r":"r","\t":"t","\u2028":"u2028","\u2029":"u2029"},J=K[typeof window]&&window||this,$=K[typeof i]&&i&&!i.nodeType&&i,Z=K[typeof e]&&e&&!e.nodeType&&e,tt=Z&&Z.exports===$&&$,et=K[typeof t]&&t;!et||et.global!==et&&et.window!==et||(J=et);var it=g();"function"==typeof define&&"object"==typeof define.amd&&define.amd?(J._=it,define(function(){return it})):$&&Z?tt?(Z.exports=it)._=it:$._=it:J._=it}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],4:[function(t,e,i){var r=t("pixi.js"),n=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={noiseLevelRGBA:{type:"4fv",value:[.05,.05,.05,0]}},this.fragmentSrc=["precision mediump float;\r\nvarying vec2 vTextureCoord;\r\nvarying vec4 vColor;\r\nuniform sampler2D uSampler;\r\nuniform vec4 noiseLevelRGBA;\r\n\r\n// The interval is from 0.0 to 1.0\r\nfloat rand(vec2 co) {\r\n      return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453);\r\n}\r\n\r\nvoid main(void) {\r\n      gl_FragColor = texture2D(uSampler, vTextureCoord);\r\n\r\n      float randomDelta = (rand(vTextureCoord) * 2.0) - 1.0;\r\n\r\n      gl_FragColor.r += noiseLevelRGBA.r * randomDelta;\r\n      gl_FragColor.g += noiseLevelRGBA.g * randomDelta;\r\n      gl_FragColor.b += noiseLevelRGBA.b * randomDelta;\r\n      gl_FragColor.a += noiseLevelRGBA.a * randomDelta;\r\n}"]};n.prototype=Object.create(r.AbstractFilter.prototype),n.prototype.constructor=n,Object.defineProperty(n.prototype,"noiseLevelRGBA",{get:function(){return this.uniforms.noiseLevelRGBA.value},set:function(t){this.uniforms.noiseLevelRGBA.value=t}}),e.exports=n},{"pixi.js":5}],5:[function(t,e,i){(function(){var t=this,r=r||{};r.WEBGL_RENDERER=0,r.CANVAS_RENDERER=1,r.VERSION="v1.6.1",r.blendModes={NORMAL:0,ADD:1,MULTIPLY:2,SCREEN:3,OVERLAY:4,DARKEN:5,LIGHTEN:6,COLOR_DODGE:7,COLOR_BURN:8,HARD_LIGHT:9,SOFT_LIGHT:10,DIFFERENCE:11,EXCLUSION:12,HUE:13,SATURATION:14,COLOR:15,LUMINOSITY:16},r.scaleModes={DEFAULT:0,LINEAR:0,NEAREST:1},r._UID=0,
  "undefined"!=typeof Float32Array?(r.Float32Array=Float32Array,r.Uint16Array=Uint16Array):(r.Float32Array=Array,r.Uint16Array=Array),r.INTERACTION_FREQUENCY=30,r.AUTO_PREVENT_DEFAULT=!0,r.RAD_TO_DEG=180/Math.PI,r.DEG_TO_RAD=Math.PI/180,r.dontSayHello=!1,r.sayHello=function(t){if(!r.dontSayHello){if(navigator.userAgent.toLowerCase().indexOf("chrome")>-1){var e=["%c %c %c Pixi.js "+r.VERSION+" - "+t+"  %c  %c  http://www.pixijs.com/  %c %c ♥%c♥%c♥ ","background: #ff66a5","background: #ff66a5","color: #ff66a5; background: #030307;","background: #ff66a5","background: #ffc3dc","background: #ff66a5","color: #ff2424; background: #fff","color: #ff2424; background: #fff","color: #ff2424; background: #fff"];console.log.apply(console,e)}else window.console&&console.log("Pixi.js "+r.VERSION+" - http://www.pixijs.com/");r.dontSayHello=!0}},r.Point=function(t,e){this.x=t||0,this.y=e||0},r.Point.prototype.clone=function(){return new r.Point(this.x,this.y)},r.Point.prototype.set=function(t,e){this.x=t||0,this.y=e||(0!==e?this.x:0)},r.Point.prototype.constructor=r.Point,r.Rectangle=function(t,e,i,r){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0},r.Rectangle.prototype.clone=function(){return new r.Rectangle(this.x,this.y,this.width,this.height)},r.Rectangle.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=this.x;if(t>=i&&t<=i+this.width){var r=this.y;if(e>=r&&e<=r+this.height)return!0}return!1},r.Rectangle.prototype.constructor=r.Rectangle,r.EmptyRectangle=new r.Rectangle(0,0,0,0),r.Polygon=function(t){if(t instanceof Array||(t=Array.prototype.slice.call(arguments)),"number"==typeof t[0]){for(var e=[],i=0,n=t.length;n>i;i+=2)e.push(new r.Point(t[i],t[i+1]));t=e}this.points=t},r.Polygon.prototype.clone=function(){for(var t=[],e=0;e<this.points.length;e++)t.push(this.points[e].clone());return new r.Polygon(t)},r.Polygon.prototype.contains=function(t,e){for(var i=!1,r=0,n=this.points.length-1;r<this.points.length;n=r++){var o=this.points[r].x,s=this.points[r].y,a=this.points[n].x,h=this.points[n].y;s>e!=h>e&&(a-o)*(e-s)/(h-s)+o>t&&(i=!i)}return i},r.Polygon.prototype.constructor=r.Polygon,r.Circle=function(t,e,i){this.x=t||0,this.y=e||0,this.radius=i||0},r.Circle.prototype.clone=function(){return new r.Circle(this.x,this.y,this.radius)},r.Circle.prototype.contains=function(t,e){if(this.radius<=0)return!1;var i=this.x-t,r=this.y-e,n=this.radius*this.radius;return i*=i,r*=r,n>=i+r},r.Circle.prototype.getBounds=function(){return new r.Rectangle(this.x-this.radius,this.y-this.radius,this.width,this.height)},r.Circle.prototype.constructor=r.Circle,r.Ellipse=function(t,e,i,r){this.x=t||0,this.y=e||0,this.width=i||0,this.height=r||0},r.Ellipse.prototype.clone=function(){return new r.Ellipse(this.x,this.y,this.width,this.height)},r.Ellipse.prototype.contains=function(t,e){if(this.width<=0||this.height<=0)return!1;var i=(t-this.x)/this.width,r=(e-this.y)/this.height;return i*=i,r*=r,1>=i+r},r.Ellipse.prototype.getBounds=function(){return new r.Rectangle(this.x-this.width,this.y-this.height,this.width,this.height)},r.Ellipse.prototype.constructor=r.Ellipse,r.Matrix=function(){this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0},r.Matrix.prototype.fromArray=function(t){this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]},r.Matrix.prototype.toArray=function(t){this.array||(this.array=new Float32Array(9));var e=this.array;return t?(e[0]=this.a,e[1]=this.c,e[2]=0,e[3]=this.b,e[4]=this.d,e[5]=0,e[6]=this.tx,e[7]=this.ty,e[8]=1):(e[0]=this.a,e[1]=this.b,e[2]=this.tx,e[3]=this.c,e[4]=this.d,e[5]=this.ty,e[6]=0,e[7]=0,e[8]=1),e},r.identityMatrix=new r.Matrix,r.determineMatrixArrayType=function(){return"undefined"!=typeof Float32Array?Float32Array:Array},r.Matrix2=r.determineMatrixArrayType(),r.DisplayObject=function(){this.position=new r.Point,this.scale=new r.Point(1,1),this.pivot=new r.Point(0,0),this.rotation=0,this.alpha=1,this.visible=!0,this.hitArea=null,this.buttonMode=!1,this.renderable=!1,this.parent=null,this.stage=null,this.worldAlpha=1,this._interactive=!1,this.defaultCursor="pointer",this.worldTransform=new r.Matrix,this.color=[],this.dynamic=!0,this._sr=0,this._cr=1,this.filterArea=null,this._bounds=new r.Rectangle(0,0,1,1),this._currentBounds=null,this._mask=null,this._cacheAsBitmap=!1,this._cacheIsDirty=!1},r.DisplayObject.prototype.constructor=r.DisplayObject,r.DisplayObject.prototype.setInteractive=function(t){this.interactive=t},Object.defineProperty(r.DisplayObject.prototype,"interactive",{get:function(){return this._interactive},set:function(t){this._interactive=t,this.stage&&(this.stage.dirty=!0)}}),Object.defineProperty(r.DisplayObject.prototype,"worldVisible",{get:function(){var t=this;do{if(!t.visible)return!1;t=t.parent}while(t);return!0}}),Object.defineProperty(r.DisplayObject.prototype,"mask",{get:function(){return this._mask},set:function(t){this._mask&&(this._mask.isMask=!1),this._mask=t,this._mask&&(this._mask.isMask=!0)}}),Object.defineProperty(r.DisplayObject.prototype,"filters",{get:function(){return this._filters},set:function(t){if(t){for(var e=[],i=0;i<t.length;i++)for(var r=t[i].passes,n=0;n<r.length;n++)e.push(r[n]);this._filterBlock={target:this,filterPasses:e}}this._filters=t}}),Object.defineProperty(r.DisplayObject.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap!==t&&(t?this._generateCachedSprite():this._destroyCachedSprite(),this._cacheAsBitmap=t)}}),r.DisplayObject.prototype.updateTransform=function(){this.rotation!==this.rotationCache&&(this.rotationCache=this.rotation,this._sr=Math.sin(this.rotation),this._cr=Math.cos(this.rotation));var t=this.parent.worldTransform,e=this.worldTransform,i=this.pivot.x,r=this.pivot.y,n=this._cr*this.scale.x,o=-this._sr*this.scale.y,s=this._sr*this.scale.x,a=this._cr*this.scale.y,h=this.position.x-n*i-r*o,l=this.position.y-a*r-i*s,u=t.a,c=t.b,d=t.c,f=t.d;e.a=u*n+c*s,e.b=u*o+c*a,e.tx=u*h+c*l+t.tx,e.c=d*n+f*s,e.d=d*o+f*a,e.ty=d*h+f*l+t.ty,this.worldAlpha=this.alpha*this.parent.worldAlpha},r.DisplayObject.prototype.getBounds=function(t){return t=t,r.EmptyRectangle},r.DisplayObject.prototype.getLocalBounds=function(){return this.getBounds(r.identityMatrix)},r.DisplayObject.prototype.setStageReference=function(t){this.stage=t,this._interactive&&(this.stage.dirty=!0)},r.DisplayObject.prototype.generateTexture=function(t){var e=this.getLocalBounds(),i=new r.RenderTexture(0|e.width,0|e.height,t);return i.render(this,new r.Point(-e.x,-e.y)),i},r.DisplayObject.prototype.updateCache=function(){this._generateCachedSprite()},r.DisplayObject.prototype._renderCachedSprite=function(t){this._cachedSprite.worldAlpha=this.worldAlpha,t.gl?r.Sprite.prototype._renderWebGL.call(this._cachedSprite,t):r.Sprite.prototype._renderCanvas.call(this._cachedSprite,t)},r.DisplayObject.prototype._generateCachedSprite=function(){this._cacheAsBitmap=!1;var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.texture.resize(0|t.width,0|t.height);else{var e=new r.RenderTexture(0|t.width,0|t.height);this._cachedSprite=new r.Sprite(e),this._cachedSprite.worldTransform=this.worldTransform}var i=this._filters;this._filters=null,this._cachedSprite.filters=i,this._cachedSprite.texture.render(this,new r.Point(-t.x,-t.y)),this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._filters=i,this._cacheAsBitmap=!0},r.DisplayObject.prototype._destroyCachedSprite=function(){this._cachedSprite&&(this._cachedSprite.texture.destroy(!0),this._cachedSprite=null)},r.DisplayObject.prototype._renderWebGL=function(t){t=t},r.DisplayObject.prototype._renderCanvas=function(t){t=t},Object.defineProperty(r.DisplayObject.prototype,"x",{get:function(){return this.position.x},set:function(t){this.position.x=t}}),Object.defineProperty(r.DisplayObject.prototype,"y",{get:function(){return this.position.y},set:function(t){this.position.y=t}}),r.DisplayObjectContainer=function(){r.DisplayObject.call(this),this.children=[]},r.DisplayObjectContainer.prototype=Object.create(r.DisplayObject.prototype),r.DisplayObjectContainer.prototype.constructor=r.DisplayObjectContainer,Object.defineProperty(r.DisplayObjectContainer.prototype,"width",{get:function(){return this.scale.x*this.getLocalBounds().width},set:function(t){var e=this.getLocalBounds().width;this.scale.x=0!==e?t/(e/this.scale.x):1,this._width=t}}),Object.defineProperty(r.DisplayObjectContainer.prototype,"height",{get:function(){return this.scale.y*this.getLocalBounds().height},set:function(t){var e=this.getLocalBounds().height;this.scale.y=0!==e?t/(e/this.scale.y):1,this._height=t}}),r.DisplayObjectContainer.prototype.addChild=function(t){return this.addChildAt(t,this.children.length)},r.DisplayObjectContainer.prototype.addChildAt=function(t,e){if(e>=0&&e<=this.children.length)return t.parent&&t.parent.removeChild(t),t.parent=this,this.children.splice(e,0,t),this.stage&&t.setStageReference(this.stage),t;throw new Error(t+" The index "+e+" supplied is out of bounds "+this.children.length)},r.DisplayObjectContainer.prototype.swapChildren=function(t,e){if(t!==e){var i=this.children.indexOf(t),r=this.children.indexOf(e);if(0>i||0>r)throw new Error("swapChildren: Both the supplied DisplayObjects must be a child of the caller.");this.children[i]=e,this.children[r]=t}},r.DisplayObjectContainer.prototype.getChildAt=function(t){if(t>=0&&t<this.children.length)return this.children[t];throw new Error("Supplied index does not exist in the child list, or the supplied DisplayObject must be a child of the caller")},r.DisplayObjectContainer.prototype.removeChild=function(t){return this.removeChildAt(this.children.indexOf(t))},r.DisplayObjectContainer.prototype.removeChildAt=function(t){var e=this.getChildAt(t);return this.stage&&e.removeStageReference(),e.parent=void 0,this.children.splice(t,1),e},r.DisplayObjectContainer.prototype.removeChildren=function(t,e){var i=t||0,r="number"==typeof e?e:this.children.length,n=r-i;if(n>0&&r>=n){for(var o=this.children.splice(i,n),s=0;s<o.length;s++){var a=o[s];this.stage&&a.removeStageReference(),a.parent=void 0}return o}throw new Error("Range Error, numeric values are outside the acceptable range")},r.DisplayObjectContainer.prototype.updateTransform=function(){if(this.visible&&(r.DisplayObject.prototype.updateTransform.call(this),!this._cacheAsBitmap))for(var t=0,e=this.children.length;e>t;t++)this.children[t].updateTransform()},r.DisplayObjectContainer.prototype.getBounds=function(t){if(0===this.children.length)return r.EmptyRectangle;if(t){var e=this.worldTransform;this.worldTransform=t,this.updateTransform(),this.worldTransform=e}for(var i,n,o,s=1/0,a=1/0,h=-1/0,l=-1/0,u=!1,c=0,d=this.children.length;d>c;c++){this.children[c].visible&&(u=!0,i=this.children[c].getBounds(t),s=s<i.x?s:i.x,a=a<i.y?a:i.y,n=i.width+i.x,o=i.height+i.y,h=h>n?h:n,l=l>o?l:o)}if(!u)return r.EmptyRectangle;var f=this._bounds;return f.x=s,f.y=a,f.width=h-s,f.height=l-a,f},r.DisplayObjectContainer.prototype.getLocalBounds=function(){var t=this.worldTransform;this.worldTransform=r.identityMatrix;for(var e=0,i=this.children.length;i>e;e++)this.children[e].updateTransform();var n=this.getBounds();return this.worldTransform=t,n},r.DisplayObjectContainer.prototype.setStageReference=function(t){this.stage=t,this._interactive&&(this.stage.dirty=!0);for(var e=0,i=this.children.length;i>e;e++){this.children[e].setStageReference(t)}},r.DisplayObjectContainer.prototype.removeStageReference=function(){for(var t=0,e=this.children.length;e>t;t++){this.children[t].removeStageReference()}this._interactive&&(this.stage.dirty=!0),this.stage=null},r.DisplayObjectContainer.prototype._renderWebGL=function(t){if(this.visible&&!(this.alpha<=0)){if(this._cacheAsBitmap)return void this._renderCachedSprite(t);var e,i;if(this._mask||this._filters){for(this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t);t.spriteBatch.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),t.spriteBatch.start()}else for(e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t)}},r.DisplayObjectContainer.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha){if(this._cacheAsBitmap)return void this._renderCachedSprite(t);this._mask&&t.maskManager.pushMask(this._mask,t.context);for(var e=0,i=this.children.length;i>e;e++){this.children[e]._renderCanvas(t)}this._mask&&t.maskManager.popMask(t.context)}},r.Sprite=function(t){r.DisplayObjectContainer.call(this),this.anchor=new r.Point,this.texture=t,this._width=0,this._height=0,this.tint=16777215,this.blendMode=r.blendModes.NORMAL,t.baseTexture.hasLoaded?this.onTextureUpdate():(this.onTextureUpdateBind=this.onTextureUpdate.bind(this),this.texture.addEventListener("update",this.onTextureUpdateBind)),this.renderable=!0},r.Sprite.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Sprite.prototype.constructor=r.Sprite,Object.defineProperty(r.Sprite.prototype,"width",{get:function(){return this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(r.Sprite.prototype,"height",{get:function(){return this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),r.Sprite.prototype.setTexture=function(t){this.texture=t,this.cachedTint=16777215},r.Sprite.prototype.onTextureUpdate=function(){this._width&&(this.scale.x=this._width/this.texture.frame.width),this._height&&(this.scale.y=this._height/this.texture.frame.height)},r.Sprite.prototype.getBounds=function(t){var e=this.texture.frame.width,i=this.texture.frame.height,r=e*(1-this.anchor.x),n=e*-this.anchor.x,o=i*(1-this.anchor.y),s=i*-this.anchor.y,a=t||this.worldTransform,h=a.a,l=a.c,u=a.b,c=a.d,d=a.tx,f=a.ty,p=h*n+u*s+d,g=c*s+l*n+f,v=h*r+u*s+d,m=c*s+l*r+f,x=h*r+u*o+d,y=c*o+l*r+f,b=h*n+u*o+d,T=c*o+l*n+f,S=-1/0,_=-1/0,w=1/0,E=1/0;w=w>p?p:w,w=w>v?v:w,w=w>x?x:w,w=w>b?b:w,E=E>g?g:E,E=E>m?m:E,E=E>y?y:E,E=E>T?T:E,S=p>S?p:S,S=v>S?v:S,S=x>S?x:S,S=b>S?b:S,_=g>_?g:_,_=m>_?m:_,_=y>_?y:_,_=T>_?T:_;var C=this._bounds;return C.x=w,C.width=S-w,C.y=E,C.height=_-E,this._currentBounds=C,C},r.Sprite.prototype._renderWebGL=function(t){if(this.visible&&!(this.alpha<=0)){var e,i;if(this._mask||this._filters){var r=t.spriteBatch;for(this._filters&&(r.flush(),t.filterManager.pushFilter(this._filterBlock)),this._mask&&(r.stop(),t.maskManager.pushMask(this.mask,t),r.start()),r.render(this),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t);r.stop(),this._mask&&t.maskManager.popMask(this._mask,t),this._filters&&t.filterManager.popFilter(),r.start()}else for(t.spriteBatch.render(this),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t)}},r.Sprite.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha){if(this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,t.context.globalCompositeOperation=r.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t.context),this.texture.valid){t.context.globalAlpha=this.worldAlpha,t.roundPixels?t.context.setTransform(this.worldTransform.a,this.worldTransform.c,this.worldTransform.b,this.worldTransform.d,0|this.worldTransform.tx,0|this.worldTransform.ty):t.context.setTransform(this.worldTransform.a,this.worldTransform.c,this.worldTransform.b,this.worldTransform.d,this.worldTransform.tx,this.worldTransform.ty),t.smoothProperty&&t.scaleMode!==this.texture.baseTexture.scaleMode&&(t.scaleMode=this.texture.baseTexture.scaleMode,t.context[t.smoothProperty]=t.scaleMode===r.scaleModes.LINEAR);var e=this.texture.trim?this.texture.trim.x-this.anchor.x*this.texture.trim.width:this.anchor.x*-this.texture.frame.width,i=this.texture.trim?this.texture.trim.y-this.anchor.y*this.texture.trim.height:this.anchor.y*-this.texture.frame.height;16777215!==this.tint?(this.cachedTint!==this.tint&&(this.cachedTint=this.tint,this.tintedTexture=r.CanvasTinter.getTintedTexture(this,this.tint)),t.context.drawImage(this.tintedTexture,0,0,this.texture.crop.width,this.texture.crop.height,e,i,this.texture.crop.width,this.texture.crop.height)):t.context.drawImage(this.texture.baseTexture.source,this.texture.crop.x,this.texture.crop.y,this.texture.crop.width,this.texture.crop.height,e,i,this.texture.crop.width,this.texture.crop.height)}for(var n=0,o=this.children.length;o>n;n++)this.children[n]._renderCanvas(t);this._mask&&t.maskManager.popMask(t.context)}},r.Sprite.fromFrame=function(t){var e=r.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache'+this);return new r.Sprite(e)},r.Sprite.fromImage=function(t,e,i){var n=r.Texture.fromImage(t,e,i);return new r.Sprite(n)},r.SpriteBatch=function(t){r.DisplayObjectContainer.call(this),this.textureThing=t,this.ready=!1},r.SpriteBatch.prototype=Object.create(r.DisplayObjectContainer.prototype),r.SpriteBatch.constructor=r.SpriteBatch,r.SpriteBatch.prototype.initWebGL=function(t){this.fastSpriteBatch=new r.WebGLFastSpriteBatch(t),this.ready=!0},r.SpriteBatch.prototype.updateTransform=function(){r.DisplayObject.prototype.updateTransform.call(this)},r.SpriteBatch.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||!this.children.length||(this.ready||this.initWebGL(t.gl),t.spriteBatch.stop(),t.shaderManager.setShader(t.shaderManager.fastShader),this.fastSpriteBatch.begin(this,t),this.fastSpriteBatch.render(this),t.spriteBatch.start())},r.SpriteBatch.prototype._renderCanvas=function(t){var e=t.context;e.globalAlpha=this.worldAlpha,r.DisplayObject.prototype.updateTransform.call(this);for(var i=this.worldTransform,n=!0,o=0;o<this.children.length;o++){var s=this.children[o];if(s.visible){var a=s.texture,h=a.frame;if(e.globalAlpha=this.worldAlpha*s.alpha,s.rotation%(2*Math.PI)==0)n&&(e.setTransform(i.a,i.c,i.b,i.d,i.tx,i.ty),n=!1),e.drawImage(a.baseTexture.source,h.x,h.y,h.width,h.height,s.anchor.x*-h.width*s.scale.x+s.position.x+.5|0,s.anchor.y*-h.height*s.scale.y+s.position.y+.5|0,h.width*s.scale.x,h.height*s.scale.y);else{n||(n=!0),r.DisplayObject.prototype.updateTransform.call(s);var l=s.worldTransform;t.roundPixels?e.setTransform(l.a,l.c,l.b,l.d,0|l.tx,0|l.ty):e.setTransform(l.a,l.c,l.b,l.d,l.tx,l.ty),e.drawImage(a.baseTexture.source,h.x,h.y,h.width,h.height,s.anchor.x*-h.width+.5|0,s.anchor.y*-h.height+.5|0,h.width,h.height)}}}},r.MovieClip=function(t){r.Sprite.call(this,t[0]),this.textures=t,this.animationSpeed=1,this.loop=!0,this.onComplete=null,this.currentFrame=0,this.playing=!1},r.MovieClip.prototype=Object.create(r.Sprite.prototype),r.MovieClip.prototype.constructor=r.MovieClip,Object.defineProperty(r.MovieClip.prototype,"totalFrames",{get:function(){return this.textures.length}}),r.MovieClip.prototype.stop=function(){this.playing=!1},r.MovieClip.prototype.play=function(){this.playing=!0},r.MovieClip.prototype.gotoAndStop=function(t){this.playing=!1,this.currentFrame=t;var e=this.currentFrame+.5|0;this.setTexture(this.textures[e%this.textures.length])},r.MovieClip.prototype.gotoAndPlay=function(t){this.currentFrame=t,this.playing=!0},r.MovieClip.prototype.updateTransform=function(){if(r.Sprite.prototype.updateTransform.call(this),this.playing){this.currentFrame+=this.animationSpeed;var t=this.currentFrame+.5|0;this.currentFrame=this.currentFrame%this.textures.length,this.loop||t<this.textures.length?this.setTexture(this.textures[t%this.textures.length]):t>=this.textures.length&&(this.gotoAndStop(this.textures.length-1),this.onComplete&&this.onComplete())}},r.MovieClip.fromFrames=function(t){for(var e=[],i=0;i<t.length;i++)e.push(new r.Texture.fromFrame(t[i]));return new r.MovieClip(e)},r.MovieClip.fromImages=function(t){for(var e=[],i=0;i<t.length;i++)e.push(new r.Texture.fromImage(t[i]));return new r.MovieClip(e)},r.FilterBlock=function(){this.visible=!0,this.renderable=!0},r.Text=function(t,e){this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),r.Sprite.call(this,r.Texture.fromCanvas(this.canvas)),this.setText(t),this.setStyle(e)},r.Text.prototype=Object.create(r.Sprite.prototype),r.Text.prototype.constructor=r.Text,Object.defineProperty(r.Text.prototype,"width",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.x*this.texture.frame.width},set:function(t){this.scale.x=t/this.texture.frame.width,this._width=t}}),Object.defineProperty(r.Text.prototype,"height",{get:function(){return this.dirty&&(this.updateText(),this.dirty=!1),this.scale.y*this.texture.frame.height},set:function(t){this.scale.y=t/this.texture.frame.height,this._height=t}}),r.Text.prototype.setStyle=function(t){t=t||{},t.font=t.font||"bold 20pt Arial",t.fill=t.fill||"black",t.align=t.align||"left",t.stroke=t.stroke||"black",t.strokeThickness=t.strokeThickness||0,t.wordWrap=t.wordWrap||!1,t.wordWrapWidth=t.wordWrapWidth||100,t.wordWrapWidth=t.wordWrapWidth||100,t.dropShadow=t.dropShadow||!1,t.dropShadowAngle=t.dropShadowAngle||Math.PI/6,t.dropShadowDistance=t.dropShadowDistance||4,t.dropShadowColor=t.dropShadowColor||"black",this.style=t,this.dirty=!0},r.Text.prototype.setText=function(t){this.text=t.toString()||" ",this.dirty=!0},r.Text.prototype.updateText=function(){this.context.font=this.style.font;var t=this.text;this.style.wordWrap&&(t=this.wordWrap(this.text));for(var e=t.split(/(?:\r\n|\r|\n)/),i=[],r=0,n=0;n<e.length;n++){var o=this.context.measureText(e[n]).width;i[n]=o,r=Math.max(r,o)}var s=r+this.style.strokeThickness;this.style.dropShadow&&(s+=this.style.dropShadowDistance),this.canvas.width=s+this.context.lineWidth;var a=this.determineFontHeight("font: "+this.style.font+";")+this.style.strokeThickness,h=a*e.length;this.style.dropShadow&&(h+=this.style.dropShadowDistance),this.canvas.height=h,navigator.isCocoonJS&&this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.context.font=this.style.font,this.context.strokeStyle=this.style.stroke,this.context.lineWidth=this.style.strokeThickness,this.context.textBaseline="top";var l,u;if(this.style.dropShadow){this.context.fillStyle=this.style.dropShadowColor;var c=Math.sin(this.style.dropShadowAngle)*this.style.dropShadowDistance,d=Math.cos(this.style.dropShadowAngle)*this.style.dropShadowDistance;for(n=0;n<e.length;n++)l=this.style.strokeThickness/2,u=this.style.strokeThickness/2+n*a,"right"===this.style.align?l+=r-i[n]:"center"===this.style.align&&(l+=(r-i[n])/2),this.style.fill&&this.context.fillText(e[n],l+c,u+d)}for(this.context.fillStyle=this.style.fill,n=0;n<e.length;n++)l=this.style.strokeThickness/2,u=this.style.strokeThickness/2+n*a,"right"===this.style.align?l+=r-i[n]:"center"===this.style.align&&(l+=(r-i[n])/2),this.style.stroke&&this.style.strokeThickness&&this.context.strokeText(e[n],l,u),this.style.fill&&this.context.fillText(e[n],l,u);this.updateTexture()},r.Text.prototype.updateTexture=function(){this.texture.baseTexture.width=this.canvas.width,this.texture.baseTexture.height=this.canvas.height,this.texture.crop.width=this.texture.frame.width=this.canvas.width,this.texture.crop.height=this.texture.frame.height=this.canvas.height,this._width=this.canvas.width,this._height=this.canvas.height,this.requiresUpdate=!0},r.Text.prototype._renderWebGL=function(t){this.requiresUpdate&&(this.requiresUpdate=!1,r.updateWebGLTexture(this.texture.baseTexture,t.gl)),r.Sprite.prototype._renderWebGL.call(this,t)},r.Text.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),r.Sprite.prototype.updateTransform.call(this)},r.Text.prototype.determineFontHeight=function(t){var e=r.Text.heightCache[t];if(!e){var i=document.getElementsByTagName("body")[0],n=document.createElement("div"),o=document.createTextNode("M");n.appendChild(o),n.setAttribute("style",t+";position:absolute;top:0;left:0"),i.appendChild(n),e=n.offsetHeight,r.Text.heightCache[t]=e,i.removeChild(n)}return e},r.Text.prototype.wordWrap=function(t){for(var e="",i=t.split("\n"),r=0;r<i.length;r++){for(var n=this.style.wordWrapWidth,o=i[r].split(" "),s=0;s<o.length;s++){var a=this.context.measureText(o[s]).width,h=a+this.context.measureText(" ").width;0===s||h>n?(s>0&&(e+="\n"),e+=o[s],n=this.style.wordWrapWidth-a):(n-=h,e+=" "+o[s])}r<i.length-1&&(e+="\n")}return e},r.Text.prototype.destroy=function(t){this.context=null,this.canvas=null,this.texture.destroy(void 0===t||t)},r.Text.heightCache={},r.BitmapText=function(t,e){r.DisplayObjectContainer.call(this),this._pool=[],this.setText(t),this.setStyle(e),this.updateText(),this.dirty=!1},r.BitmapText.prototype=Object.create(r.DisplayObjectContainer.prototype),r.BitmapText.prototype.constructor=r.BitmapText,r.BitmapText.prototype.setText=function(t){this.text=t||" ",this.dirty=!0},r.BitmapText.prototype.setStyle=function(t){t=t||{},t.align=t.align||"left",this.style=t;var e=t.font.split(" ");this.fontName=e[e.length-1],this.fontSize=e.length>=2?parseInt(e[e.length-2],10):r.BitmapText.fonts[this.fontName].size,this.dirty=!0,this.tint=t.tint},r.BitmapText.prototype.updateText=function(){for(var t=r.BitmapText.fonts[this.fontName],e=new r.Point,i=null,n=[],o=0,s=[],a=0,h=this.fontSize/t.size,l=0;l<this.text.length;l++){var u=this.text.charCodeAt(l);if(/(?:\r\n|\r|\n)/.test(this.text.charAt(l)))s.push(e.x),o=Math.max(o,e.x),a++,e.x=0,e.y+=t.lineHeight,i=null;else{var c=t.chars[u];c&&(i&&c[i]&&(e.x+=c.kerning[i]),n.push({texture:c.texture,line:a,charCode:u,position:new r.Point(e.x+c.xOffset,e.y+c.yOffset)}),e.x+=c.xAdvance,i=u)}}s.push(e.x),o=Math.max(o,e.x);var d=[];for(l=0;a>=l;l++){var f=0;"right"===this.style.align?f=o-s[l]:"center"===this.style.align&&(f=(o-s[l])/2),d.push(f)}var p=this.children.length,g=n.length,v=this.tint||16777215;for(l=0;g>l;l++){var m=p>l?this.children[l]:this._pool.pop();m?m.setTexture(n[l].texture):m=new r.Sprite(n[l].texture),m.position.x=(n[l].position.x+d[n[l].line])*h,m.position.y=n[l].position.y*h,m.scale.x=m.scale.y=h,m.tint=v,m.parent||this.addChild(m)}for(;this.children.length>g;){var x=this.getChildAt(this.children.length-1);this._pool.push(x),this.removeChild(x)}this.textWidth=o*h,this.textHeight=(e.y+t.lineHeight)*h},r.BitmapText.prototype.updateTransform=function(){this.dirty&&(this.updateText(),this.dirty=!1),r.DisplayObjectContainer.prototype.updateTransform.call(this)},r.BitmapText.fonts={},r.InteractionData=function(){this.global=new r.Point,this.target=null,this.originalEvent=null},r.InteractionData.prototype.getLocalPosition=function(t){var e=t.worldTransform,i=this.global,n=e.a,o=e.b,s=e.tx,a=e.c,h=e.d,l=e.ty,u=1/(n*h+o*-a);return new r.Point(h*u*i.x+-o*u*i.y+(l*o-s*h)*u,n*u*i.y+-a*u*i.x+(-l*n+s*a)*u)},r.InteractionData.prototype.constructor=r.InteractionData,r.InteractionManager=function(t){this.stage=t,this.mouse=new r.InteractionData,this.touchs={},this.tempPoint=new r.Point,this.mouseoverEnabled=!0,this.pool=[],this.interactiveItems=[],this.interactionDOMElement=null,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this.onMouseOut=this.onMouseOut.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onTouchMove=this.onTouchMove.bind(this),this.last=0,this.currentCursorStyle="inherit",this.mouseOut=!1},r.InteractionManager.prototype.constructor=r.InteractionManager,r.InteractionManager.prototype.collectInteractiveSprite=function(t,e){for(var i=t.children,r=i.length,n=r-1;n>=0;n--){var o=i[n];o._interactive?(e.interactiveChildren=!0,this.interactiveItems.push(o),o.children.length>0&&this.collectInteractiveSprite(o,o)):(o.__iParent=null,o.children.length>0&&this.collectInteractiveSprite(o,e))}},r.InteractionManager.prototype.setTarget=function(t){this.target=t,null===this.interactionDOMElement&&this.setTargetDomElement(t.view)},r.InteractionManager.prototype.setTargetDomElement=function(t){this.removeEvents(),window.navigator.msPointerEnabled&&(t.style["-ms-content-zooming"]="none",t.style["-ms-touch-action"]="none"),this.interactionDOMElement=t,t.addEventListener("mousemove",this.onMouseMove,!0),t.addEventListener("mousedown",this.onMouseDown,!0),t.addEventListener("mouseout",this.onMouseOut,!0),t.addEventListener("touchstart",this.onTouchStart,!0),t.addEventListener("touchend",this.onTouchEnd,!0),t.addEventListener("touchmove",this.onTouchMove,!0),window.addEventListener("mouseup",this.onMouseUp,!0)},r.InteractionManager.prototype.removeEvents=function(){this.interactionDOMElement&&(this.interactionDOMElement.style["-ms-content-zooming"]="",this.interactionDOMElement.style["-ms-touch-action"]="",this.interactionDOMElement.removeEventListener("mousemove",this.onMouseMove,!0),this.interactionDOMElement.removeEventListener("mousedown",this.onMouseDown,!0),this.interactionDOMElement.removeEventListener("mouseout",this.onMouseOut,!0),this.interactionDOMElement.removeEventListener("touchstart",this.onTouchStart,!0),this.interactionDOMElement.removeEventListener("touchend",this.onTouchEnd,!0),this.interactionDOMElement.removeEventListener("touchmove",this.onTouchMove,!0),this.interactionDOMElement=null,window.removeEventListener("mouseup",this.onMouseUp,!0))},r.InteractionManager.prototype.update=function(){if(this.target){var t=Date.now(),e=t-this.last;if(!(1>(e=e*r.INTERACTION_FREQUENCY/1e3))){this.last=t;var i=0;this.dirty&&this.rebuildInteractiveGraph();var n=this.interactiveItems.length,o="inherit",s=!1;for(i=0;n>i;i++){var a=this.interactiveItems[i];a.__hit=this.hitTest(a,this.mouse),this.mouse.target=a,a.__hit&&!s?(a.buttonMode&&(o=a.defaultCursor),a.interactiveChildren||(s=!0),a.__isOver||(a.mouseover&&a.mouseover(this.mouse),a.__isOver=!0)):a.__isOver&&(a.mouseout&&a.mouseout(this.mouse),a.__isOver=!1)}this.currentCursorStyle!==o&&(this.currentCursorStyle=o,this.interactionDOMElement.style.cursor=o)}}},r.InteractionManager.prototype.rebuildInteractiveGraph=function(){this.dirty=!1;for(var t=this.interactiveItems.length,e=0;t>e;e++)this.interactiveItems[e].interactiveChildren=!1;this.interactiveItems=[],this.stage.interactive&&this.interactiveItems.push(this.stage),this.collectInteractiveSprite(this.stage,this.stage)},r.InteractionManager.prototype.onMouseMove=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t||window.event;var e=this.interactionDOMElement.getBoundingClientRect();this.mouse.global.x=(t.clientX-e.left)*(this.target.width/e.width),this.mouse.global.y=(t.clientY-e.top)*(this.target.height/e.height);for(var i=this.interactiveItems.length,r=0;i>r;r++){var n=this.interactiveItems[r];n.mousemove&&n.mousemove(this.mouse)}},r.InteractionManager.prototype.onMouseDown=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t||window.event,r.AUTO_PREVENT_DEFAULT&&this.mouse.originalEvent.preventDefault();for(var e=this.interactiveItems.length,i=0;e>i;i++){var n=this.interactiveItems[i];if((n.mousedown||n.click)&&(n.__mouseIsDown=!0,n.__hit=this.hitTest(n,this.mouse),n.__hit&&(n.mousedown&&n.mousedown(this.mouse),n.__isDown=!0,!n.interactiveChildren)))break}},r.InteractionManager.prototype.onMouseOut=function(){this.dirty&&this.rebuildInteractiveGraph();var t=this.interactiveItems.length;this.interactionDOMElement.style.cursor="inherit";for(var e=0;t>e;e++){var i=this.interactiveItems[e];i.__isOver&&(this.mouse.target=i,i.mouseout&&i.mouseout(this.mouse),i.__isOver=!1)}this.mouseOut=!0,this.mouse.global.x=-1e4,this.mouse.global.y=-1e4},r.InteractionManager.prototype.onMouseUp=function(t){this.dirty&&this.rebuildInteractiveGraph(),this.mouse.originalEvent=t||window.event;for(var e=this.interactiveItems.length,i=!1,r=0;e>r;r++){var n=this.interactiveItems[r];n.__hit=this.hitTest(n,this.mouse),n.__hit&&!i?(n.mouseup&&n.mouseup(this.mouse),n.__isDown&&n.click&&n.click(this.mouse),
  n.interactiveChildren||(i=!0)):n.__isDown&&n.mouseupoutside&&n.mouseupoutside(this.mouse),n.__isDown=!1}},r.InteractionManager.prototype.hitTest=function(t,e){var i=e.global;if(!t.worldVisible)return!1;var n=t instanceof r.Sprite,o=t.worldTransform,s=o.a,a=o.b,h=o.tx,l=o.c,u=o.d,c=o.ty,d=1/(s*u+a*-l),f=u*d*i.x+-a*d*i.y+(c*a-h*u)*d,p=s*d*i.y+-l*d*i.x+(-c*s+h*l)*d;if(e.target=t,t.hitArea&&t.hitArea.contains)return!!t.hitArea.contains(f,p)&&(e.target=t,!0);if(n){var g,v=t.texture.frame.width,m=t.texture.frame.height,x=-v*t.anchor.x;if(f>x&&x+v>f&&(g=-m*t.anchor.y,p>g&&g+m>p))return e.target=t,!0}for(var y=t.children.length,b=0;y>b;b++){var T=t.children[b];if(this.hitTest(T,e))return e.target=t,!0}return!1},r.InteractionManager.prototype.onTouchMove=function(t){this.dirty&&this.rebuildInteractiveGraph();var e,i=this.interactionDOMElement.getBoundingClientRect(),r=t.changedTouches,n=0;for(n=0;n<r.length;n++){var o=r[n];e=this.touchs[o.identifier],e.originalEvent=t||window.event,e.global.x=(o.clientX-i.left)*(this.target.width/i.width),e.global.y=(o.clientY-i.top)*(this.target.height/i.height),navigator.isCocoonJS&&(e.global.x=o.clientX,e.global.y=o.clientY);for(var s=0;s<this.interactiveItems.length;s++){var a=this.interactiveItems[s];a.touchmove&&a.__touchData&&a.__touchData[o.identifier]&&a.touchmove(e)}}},r.InteractionManager.prototype.onTouchStart=function(t){this.dirty&&this.rebuildInteractiveGraph();var e=this.interactionDOMElement.getBoundingClientRect();r.AUTO_PREVENT_DEFAULT&&t.preventDefault();for(var i=t.changedTouches,n=0;n<i.length;n++){var o=i[n],s=this.pool.pop();s||(s=new r.InteractionData),s.originalEvent=t||window.event,this.touchs[o.identifier]=s,s.global.x=(o.clientX-e.left)*(this.target.width/e.width),s.global.y=(o.clientY-e.top)*(this.target.height/e.height),navigator.isCocoonJS&&(s.global.x=o.clientX,s.global.y=o.clientY);for(var a=this.interactiveItems.length,h=0;a>h;h++){var l=this.interactiveItems[h];if((l.touchstart||l.tap)&&(l.__hit=this.hitTest(l,s),l.__hit&&(l.touchstart&&l.touchstart(s),l.__isDown=!0,l.__touchData=l.__touchData||{},l.__touchData[o.identifier]=s,!l.interactiveChildren)))break}}},r.InteractionManager.prototype.onTouchEnd=function(t){this.dirty&&this.rebuildInteractiveGraph();for(var e=this.interactionDOMElement.getBoundingClientRect(),i=t.changedTouches,r=0;r<i.length;r++){var n=i[r],o=this.touchs[n.identifier],s=!1;o.global.x=(n.clientX-e.left)*(this.target.width/e.width),o.global.y=(n.clientY-e.top)*(this.target.height/e.height),navigator.isCocoonJS&&(o.global.x=n.clientX,o.global.y=n.clientY);for(var a=this.interactiveItems.length,h=0;a>h;h++){var l=this.interactiveItems[h];l.__touchData&&l.__touchData[n.identifier]&&(l.__hit=this.hitTest(l,l.__touchData[n.identifier]),o.originalEvent=t||window.event,(l.touchend||l.tap)&&(l.__hit&&!s?(l.touchend&&l.touchend(o),l.__isDown&&l.tap&&l.tap(o),l.interactiveChildren||(s=!0)):l.__isDown&&l.touchendoutside&&l.touchendoutside(o),l.__isDown=!1),l.__touchData[n.identifier]=null)}this.pool.push(o),this.touchs[n.identifier]=null}},r.Stage=function(t){r.DisplayObjectContainer.call(this),this.worldTransform=new r.Matrix,this.interactive=!0,this.interactionManager=new r.InteractionManager(this),this.dirty=!0,this.stage=this,this.stage.hitArea=new r.Rectangle(0,0,1e5,1e5),this.setBackgroundColor(t)},r.Stage.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Stage.prototype.constructor=r.Stage,r.Stage.prototype.setInteractionDelegate=function(t){this.interactionManager.setTargetDomElement(t)},r.Stage.prototype.updateTransform=function(){this.worldAlpha=1;for(var t=0,e=this.children.length;e>t;t++)this.children[t].updateTransform();this.dirty&&(this.dirty=!1,this.interactionManager.dirty=!0),this.interactive&&this.interactionManager.update()},r.Stage.prototype.setBackgroundColor=function(t){this.backgroundColor=t||0,this.backgroundColorSplit=r.hex2rgb(this.backgroundColor);var e=this.backgroundColor.toString(16);e="000000".substr(0,6-e.length)+e,this.backgroundColorString="#"+e},r.Stage.prototype.getMousePosition=function(){return this.interactionManager.mouse.global};for(var n=0,o=["ms","moz","webkit","o"],s=0;s<o.length&&!window.requestAnimationFrame;++s)window.requestAnimationFrame=window[o[s]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[o[s]+"CancelAnimationFrame"]||window[o[s]+"CancelRequestAnimationFrame"];window.requestAnimationFrame||(window.requestAnimationFrame=function(t){var e=(new Date).getTime(),i=Math.max(0,16-(e-n)),r=window.setTimeout(function(){t(e+i)},i);return n=e+i,r}),window.cancelAnimationFrame||(window.cancelAnimationFrame=function(t){clearTimeout(t)}),window.requestAnimFrame=window.requestAnimationFrame,r.hex2rgb=function(t){return[(t>>16&255)/255,(t>>8&255)/255,(255&t)/255]},r.rgb2hex=function(t){return(255*t[0]<<16)+(255*t[1]<<8)+255*t[2]},"function"!=typeof Function.prototype.bind&&(Function.prototype.bind=function(){var t=Array.prototype.slice;return function(e){function i(){var o=n.concat(t.call(arguments));r.apply(this instanceof i?this:e,o)}var r=this,n=t.call(arguments,1);if("function"!=typeof r)throw new TypeError;return i.prototype=function t(e){return e&&(t.prototype=e),this instanceof t?void 0:new t}(r.prototype),i}}()),r.AjaxRequest=function(){var t=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Microsoft.XMLHTTP"];if(!window.ActiveXObject)return!!window.XMLHttpRequest&&new window.XMLHttpRequest;for(var e=0;e<t.length;e++)try{return new window.ActiveXObject(t[e])}catch(t){}},r.canUseNewCanvasBlendModes=function(){var t=document.createElement("canvas");t.width=1,t.height=1;var e=t.getContext("2d");return e.fillStyle="#000",e.fillRect(0,0,1,1),e.globalCompositeOperation="multiply",e.fillStyle="#fff",e.fillRect(0,0,1,1),0===e.getImageData(0,0,1,1).data[0]},r.getNextPowerOfTwo=function(t){if(t>0&&0==(t&t-1))return t;for(var e=1;t>e;)e<<=1;return e},r.EventTarget=function(){var t={};this.addEventListener=this.on=function(e,i){void 0===t[e]&&(t[e]=[]),-1===t[e].indexOf(i)&&t[e].unshift(i)},this.dispatchEvent=this.emit=function(e){if(t[e.type]&&t[e.type].length)for(var i=t[e.type].length-1;i>=0;i--)t[e.type][i](e)},this.removeEventListener=this.off=function(e,i){if(void 0!==t[e]){var r=t[e].indexOf(i);-1!==r&&t[e].splice(r,1)}},this.removeAllEventListeners=function(e){var i=t[e];i&&(i.length=0)}},r.autoDetectRenderer=function(t,e,i,n,o){return t||(t=800),e||(e=600),function(){try{var t=document.createElement("canvas");return!!window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(t){return!1}}()?new r.WebGLRenderer(t,e,i,n,o):new r.CanvasRenderer(t,e,i,n)},r.autoDetectRecommendedRenderer=function(t,e,i,n,o){t||(t=800),e||(e=600);var s=function(){try{var t=document.createElement("canvas");return!!window.WebGLRenderingContext&&(t.getContext("webgl")||t.getContext("experimental-webgl"))}catch(t){return!1}}(),a=/Android/i.test(navigator.userAgent);return s&&!a?new r.WebGLRenderer(t,e,i,n,o):new r.CanvasRenderer(t,e,i,n)},r.PolyK={},r.PolyK.Triangulate=function(t){var e=!0,i=t.length>>1;if(3>i)return[];for(var n=[],o=[],s=0;i>s;s++)o.push(s);s=0;for(var a=i;a>3;){var h=o[(s+0)%a],l=o[(s+1)%a],u=o[(s+2)%a],c=t[2*h],d=t[2*h+1],f=t[2*l],p=t[2*l+1],g=t[2*u],v=t[2*u+1],m=!1;if(r.PolyK._convex(c,d,f,p,g,v,e)){m=!0;for(var x=0;a>x;x++){var y=o[x];if(y!==h&&y!==l&&y!==u&&r.PolyK._PointInTriangle(t[2*y],t[2*y+1],c,d,f,p,g,v)){m=!1;break}}}if(m)n.push(h,l,u),o.splice((s+1)%a,1),a--,s=0;else if(s++>3*a){if(!e)return window.console.log("PIXI Warning: shape too complex to fill"),[];for(n=[],o=[],s=0;i>s;s++)o.push(s);s=0,a=i,e=!1}}return n.push(o[0],o[1],o[2]),n},r.PolyK._PointInTriangle=function(t,e,i,r,n,o,s,a){var h=s-i,l=a-r,u=n-i,c=o-r,d=t-i,f=e-r,p=h*h+l*l,g=h*u+l*c,v=h*d+l*f,m=u*u+c*c,x=u*d+c*f,y=1/(p*m-g*g),b=(m*v-g*x)*y,T=(p*x-g*v)*y;return b>=0&&T>=0&&1>b+T},r.PolyK._convex=function(t,e,i,r,n,o,s){return(e-r)*(n-i)+(i-t)*(o-r)>=0===s},r.initDefaultShaders=function(){},r.CompileVertexShader=function(t,e){return r._CompileShader(t,e,t.VERTEX_SHADER)},r.CompileFragmentShader=function(t,e){return r._CompileShader(t,e,t.FRAGMENT_SHADER)},r._CompileShader=function(t,e,i){var r=e.join("\n"),n=t.createShader(i);return t.shaderSource(n,r),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:(window.console.log(t.getShaderInfoLog(n)),null)},r.compileProgram=function(t,e,i){var n=r.CompileFragmentShader(t,i),o=r.CompileVertexShader(t,e),s=t.createProgram();return t.attachShader(s,o),t.attachShader(s,n),t.linkProgram(s),t.getProgramParameter(s,t.LINK_STATUS)||window.console.log("Could not initialise shaders"),s},r.PixiShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.textureCount=0,this.attributes=[],this.init()},r.PixiShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc||r.PixiShader.defaultVertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aTextureCoord,this.colorAttribute];for(var i in this.uniforms)this.uniforms[i].uniformLocation=t.getUniformLocation(e,i);this.initUniforms(),this.program=e},r.PixiShader.prototype.initUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms){t=this.uniforms[i];var r=t.type;"sampler2D"===r?(t._init=!1,null!==t.value&&this.initSampler2D(t)):"mat2"===r||"mat3"===r||"mat4"===r?(t.glMatrix=!0,t.glValueLength=1,"mat2"===r?t.glFunc=e.uniformMatrix2fv:"mat3"===r?t.glFunc=e.uniformMatrix3fv:"mat4"===r&&(t.glFunc=e.uniformMatrix4fv)):(t.glFunc=e["uniform"+r],t.glValueLength="2f"===r||"2i"===r?2:"3f"===r||"3i"===r?3:"4f"===r||"4i"===r?4:1)}},r.PixiShader.prototype.initSampler2D=function(t){if(t.value&&t.value.baseTexture&&t.value.baseTexture.hasLoaded){var e=this.gl;if(e.activeTexture(e["TEXTURE"+this.textureCount]),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]),t.textureData){var i=t.textureData,r=i.magFilter?i.magFilter:e.LINEAR,n=i.minFilter?i.minFilter:e.LINEAR,o=i.wrapS?i.wrapS:e.CLAMP_TO_EDGE,s=i.wrapT?i.wrapT:e.CLAMP_TO_EDGE,a=i.luminance?e.LUMINANCE:e.RGBA;if(i.repeat&&(o=e.REPEAT,s=e.REPEAT),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!!i.flipY),i.width){var h=i.width?i.width:512,l=i.height?i.height:2,u=i.border?i.border:0;e.texImage2D(e.TEXTURE_2D,0,a,h,l,u,a,e.UNSIGNED_BYTE,null)}else e.texImage2D(e.TEXTURE_2D,0,a,e.RGBA,e.UNSIGNED_BYTE,t.value.baseTexture.source);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,n),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,s)}e.uniform1i(t.uniformLocation,this.textureCount),t._init=!0,this.textureCount++}},r.PixiShader.prototype.syncUniforms=function(){this.textureCount=1;var t,e=this.gl;for(var i in this.uniforms)t=this.uniforms[i],1===t.glValueLength?!0===t.glMatrix?t.glFunc.call(e,t.uniformLocation,t.transpose,t.value):t.glFunc.call(e,t.uniformLocation,t.value):2===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y):3===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z):4===t.glValueLength?t.glFunc.call(e,t.uniformLocation,t.value.x,t.value.y,t.value.z,t.value.w):"sampler2D"===t.type&&(t._init?(e.activeTexture(e["TEXTURE"+this.textureCount]),e.bindTexture(e.TEXTURE_2D,t.value.baseTexture._glTextures[e.id]||r.createWebGLTexture(t.value.baseTexture,e)),e.uniform1i(t.uniformLocation,this.textureCount),this.textureCount++):this.initSampler2D(t))},r.PixiShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},r.PixiShader.defaultVertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","attribute vec2 aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","varying vec4 vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","   gl_Position = vec4( ((aVertexPosition + offsetVector) / projectionVector) + center , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vec3 color = mod(vec3(aColor.y/65536.0, aColor.y/256.0, aColor.y), 256.0) / 256.0;","   vColor = vec4(color * aColor.x, aColor.x);","}"],r.PixiFastShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision lowp float;","varying vec2 vTextureCoord;","varying float vColor;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * vColor ;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aPositionCoord;","attribute vec2 aScale;","attribute float aRotation;","attribute vec2 aTextureCoord;","attribute float aColor;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform mat3 uMatrix;","varying vec2 vTextureCoord;","varying float vColor;","const vec2 center = vec2(-1.0, 1.0);","void main(void) {","   vec2 v;","   vec2 sv = aVertexPosition * aScale;","   v.x = (sv.x) * cos(aRotation) - (sv.y) * sin(aRotation);","   v.y = (sv.x) * sin(aRotation) + (sv.y) * cos(aRotation);","   v = ( uMatrix * vec3(v + aPositionCoord , 1.0) ).xy ;","   gl_Position = vec4( ( v / projectionVector) + center , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","   vColor = aColor;","}"],this.textureCount=0,this.init()},r.PixiFastShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.dimensions=t.getUniformLocation(e,"dimensions"),this.uMatrix=t.getUniformLocation(e,"uMatrix"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aPositionCoord=t.getAttribLocation(e,"aPositionCoord"),this.aScale=t.getAttribLocation(e,"aScale"),this.aRotation=t.getAttribLocation(e,"aRotation"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.colorAttribute=t.getAttribLocation(e,"aColor"),-1===this.colorAttribute&&(this.colorAttribute=2),this.attributes=[this.aVertexPosition,this.aPositionCoord,this.aScale,this.aRotation,this.aTextureCoord,this.colorAttribute],this.program=e},r.PixiFastShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attributes=null},r.StripShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","uniform float alpha;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y));","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec2 aTextureCoord;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","varying vec2 vTextureCoord;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","   vTextureCoord = aTextureCoord;","}"],this.init()},r.StripShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.uSampler=t.getUniformLocation(e,"uSampler"),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.aTextureCoord=t.getAttribLocation(e,"aTextureCoord"),this.attributes=[this.aVertexPosition,this.aTextureCoord],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},r.PrimitiveShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","   gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","attribute vec4 aColor;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform float alpha;","uniform vec3 tint;","varying vec4 vColor;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","   vColor = aColor * vec4(tint * alpha, alpha);","}"],this.init()},r.PrimitiveShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.colorAttribute=t.getAttribLocation(e,"aColor"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},r.PrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},r.ComplexPrimitiveShader=function(t){this._UID=r._UID++,this.gl=t,this.program=null,this.fragmentSrc=["precision mediump float;","varying vec4 vColor;","void main(void) {","   gl_FragColor = vColor;","}"],this.vertexSrc=["attribute vec2 aVertexPosition;","uniform mat3 translationMatrix;","uniform vec2 projectionVector;","uniform vec2 offsetVector;","uniform vec3 tint;","uniform float alpha;","uniform vec3 color;","varying vec4 vColor;","void main(void) {","   vec3 v = translationMatrix * vec3(aVertexPosition , 1.0);","   v -= offsetVector.xyx;","   gl_Position = vec4( v.x / projectionVector.x -1.0, v.y / -projectionVector.y + 1.0 , 0.0, 1.0);","   vColor = vec4(color * alpha * tint, alpha);","}"],this.init()},r.ComplexPrimitiveShader.prototype.init=function(){var t=this.gl,e=r.compileProgram(t,this.vertexSrc,this.fragmentSrc);t.useProgram(e),this.projectionVector=t.getUniformLocation(e,"projectionVector"),this.offsetVector=t.getUniformLocation(e,"offsetVector"),this.tintColor=t.getUniformLocation(e,"tint"),this.color=t.getUniformLocation(e,"color"),this.aVertexPosition=t.getAttribLocation(e,"aVertexPosition"),this.attributes=[this.aVertexPosition,this.colorAttribute],this.translationMatrix=t.getUniformLocation(e,"translationMatrix"),this.alpha=t.getUniformLocation(e,"alpha"),this.program=e},r.ComplexPrimitiveShader.prototype.destroy=function(){this.gl.deleteProgram(this.program),this.uniforms=null,this.gl=null,this.attribute=null},r.WebGLGraphics=function(){},r.WebGLGraphics.renderGraphics=function(t,e){var i,n=e.gl,o=e.projection,s=e.offset,a=e.shaderManager.primitiveShader;t.dirty&&r.WebGLGraphics.updateGraphics(t,n);for(var h=t._webGL[n.id],l=0;l<h.data.length;l++)1===h.data[l].mode?(i=h.data[l],e.stencilManager.pushStencil(t,i,e),n.drawElements(n.TRIANGLE_FAN,4,n.UNSIGNED_SHORT,2*(i.indices.length-4)),e.stencilManager.popStencil(t,i,e),this.last=i.mode):(i=h.data[l],e.shaderManager.setShader(a),a=e.shaderManager.primitiveShader,n.uniformMatrix3fv(a.translationMatrix,!1,t.worldTransform.toArray(!0)),n.uniform2f(a.projectionVector,o.x,-o.y),n.uniform2f(a.offsetVector,-s.x,-s.y),n.uniform3fv(a.tintColor,r.hex2rgb(t.tint)),n.uniform1f(a.alpha,t.worldAlpha),n.bindBuffer(n.ARRAY_BUFFER,i.buffer),n.vertexAttribPointer(a.aVertexPosition,2,n.FLOAT,!1,24,0),n.vertexAttribPointer(a.colorAttribute,4,n.FLOAT,!1,24,8),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i.indexBuffer),n.drawElements(n.TRIANGLE_STRIP,i.indices.length,n.UNSIGNED_SHORT,0))},r.WebGLGraphics.updateGraphics=function(t,e){var i=t._webGL[e.id];i||(i=t._webGL[e.id]={lastIndex:0,data:[],gl:e}),t.dirty=!1;var n;if(t.clearDirty){for(t.clearDirty=!1,n=0;n<i.data.length;n++){var o=i.data[n];o.reset(),r.WebGLGraphics.graphicsDataPool.push(o)}i.data=[],i.lastIndex=0}var s;for(n=i.lastIndex;n<t.graphicsData.length;n++){var a=t.graphicsData[n];a.type===r.Graphics.POLY?(a.fill&&a.points.length>6&&(a.points.length>10?(s=r.WebGLGraphics.switchMode(i,1),r.WebGLGraphics.buildComplexPoly(a,s)):(s=r.WebGLGraphics.switchMode(i,0),r.WebGLGraphics.buildPoly(a,s))),a.lineWidth>0&&(s=r.WebGLGraphics.switchMode(i,0),r.WebGLGraphics.buildLine(a,s))):(s=r.WebGLGraphics.switchMode(i,0),a.type===r.Graphics.RECT?r.WebGLGraphics.buildRectangle(a,s):a.type===r.Graphics.CIRC||a.type===r.Graphics.ELIP?r.WebGLGraphics.buildCircle(a,s):a.type===r.Graphics.RREC&&r.WebGLGraphics.buildRoundedRectangle(a,s)),i.lastIndex++}for(n=0;n<i.data.length;n++)s=i.data[n],s.dirty&&s.upload()},r.WebGLGraphics.switchMode=function(t,e){var i;return t.data.length?(i=t.data[t.data.length-1],(i.mode!==e||1===e)&&(i=r.WebGLGraphics.graphicsDataPool.pop()||new r.WebGLGraphicsData(t.gl),i.mode=e,t.data.push(i))):(i=r.WebGLGraphics.graphicsDataPool.pop()||new r.WebGLGraphicsData(t.gl),i.mode=e,t.data.push(i)),i.dirty=!0,i},r.WebGLGraphics.buildRectangle=function(t,e){var i=t.points,n=i[0],o=i[1],s=i[2],a=i[3];if(t.fill){var h=r.hex2rgb(t.fillColor),l=t.fillAlpha,u=h[0]*l,c=h[1]*l,d=h[2]*l,f=e.points,p=e.indices,g=f.length/6;f.push(n,o),f.push(u,c,d,l),f.push(n+s,o),f.push(u,c,d,l),f.push(n,o+a),f.push(u,c,d,l),f.push(n+s,o+a),f.push(u,c,d,l),p.push(g,g,g+1,g+2,g+3,g+3)}if(t.lineWidth){var v=t.points;t.points=[n,o,n+s,o,n+s,o+a,n,o+a,n,o],r.WebGLGraphics.buildLine(t,e),t.points=v}},r.WebGLGraphics.buildRoundedRectangle=function(t,e){var i=t.points,n=i[0],o=i[1],s=i[2],a=i[3],h=i[4],l=[];if(l.push(n,o+h),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n,o+a-h,n,o+a,n+h,o+a)),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n+s-h,o+a,n+s,o+a,n+s,o+a-h)),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n+s,o+h,n+s,o,n+s-h,o)),l=l.concat(r.WebGLGraphics.quadraticBezierCurve(n+h,o,n,o,n,o+h)),t.fill){var u=r.hex2rgb(t.fillColor),c=t.fillAlpha,d=u[0]*c,f=u[1]*c,p=u[2]*c,g=e.points,v=e.indices,m=g.length/6,x=r.PolyK.Triangulate(l),y=0;for(y=0;y<x.length;y+=3)v.push(x[y]+m),v.push(x[y]+m),v.push(x[y+1]+m),v.push(x[y+2]+m),v.push(x[y+2]+m);for(y=0;y<l.length;y++)g.push(l[y],l[++y],d,f,p,c)}if(t.lineWidth){var b=t.points;t.points=l,r.WebGLGraphics.buildLine(t,e),t.points=b}},r.WebGLGraphics.quadraticBezierCurve=function(t,e,i,r,n,o){function s(t,e,i){return t+(e-t)*i}for(var a,h,l,u,c,d,f=[],p=0,g=0;20>=g;g++)p=g/20,a=s(t,i,p),h=s(e,r,p),l=s(i,n,p),u=s(r,o,p),c=s(a,l,p),d=s(h,u,p),f.push(c,d);return f},r.WebGLGraphics.buildCircle=function(t,e){var i=t.points,n=i[0],o=i[1],s=i[2],a=i[3],h=2*Math.PI/40,l=0;if(t.fill){var u=r.hex2rgb(t.fillColor),c=t.fillAlpha,d=u[0]*c,f=u[1]*c,p=u[2]*c,g=e.points,v=e.indices,m=g.length/6;for(v.push(m),l=0;41>l;l++)g.push(n,o,d,f,p,c),g.push(n+Math.sin(h*l)*s,o+Math.cos(h*l)*a,d,f,p,c),v.push(m++,m++);v.push(m-1)}if(t.lineWidth){var x=t.points;for(t.points=[],l=0;41>l;l++)t.points.push(n+Math.sin(h*l)*s,o+Math.cos(h*l)*a);r.WebGLGraphics.buildLine(t,e),t.points=x}},r.WebGLGraphics.buildLine=function(t,e){var i=0,n=t.points;if(0!==n.length){if(t.lineWidth%2)for(i=0;i<n.length;i++)n[i]+=.5;var o=new r.Point(n[0],n[1]),s=new r.Point(n[n.length-2],n[n.length-1]);if(o.x===s.x&&o.y===s.y){n=n.slice(),n.pop(),n.pop(),s=new r.Point(n[n.length-2],n[n.length-1]);var a=s.x+.5*(o.x-s.x),h=s.y+.5*(o.y-s.y);n.unshift(a,h),n.push(a,h)}var l,u,c,d,f,p,g,v,m,x,y,b,T,S,_,w,E,C,A,R,M,L,F,B=e.points,I=e.indices,P=n.length/2,O=n.length,D=B.length/6,G=t.lineWidth/2,N=r.hex2rgb(t.lineColor),k=t.lineAlpha,U=N[0]*k,j=N[1]*k,W=N[2]*k;for(c=n[0],d=n[1],f=n[2],p=n[3],m=-(d-p),x=c-f,F=Math.sqrt(m*m+x*x),m/=F,x/=F,m*=G,x*=G,B.push(c-m,d-x,U,j,W,k),B.push(c+m,d+x,U,j,W,k),i=1;P-1>i;i++)c=n[2*(i-1)],d=n[2*(i-1)+1],f=n[2*i],p=n[2*i+1],g=n[2*(i+1)],v=n[2*(i+1)+1],m=-(d-p),x=c-f,F=Math.sqrt(m*m+x*x),m/=F,x/=F,m*=G,x*=G,y=-(p-v),b=f-g,F=Math.sqrt(y*y+b*b),y/=F,b/=F,y*=G,b*=G,_=-x+d-(-x+p),w=-m+f-(-m+c),E=(-m+c)*(-x+p)-(-m+f)*(-x+d),C=-b+v-(-b+p),A=-y+f-(-y+g),R=(-y+g)*(-b+p)-(-y+f)*(-b+v),M=_*A-C*w,Math.abs(M)<.1?(M+=10.1,B.push(f-m,p-x,U,j,W,k),B.push(f+m,p+x,U,j,W,k)):(l=(w*R-A*E)/M,u=(C*E-_*R)/M,L=(l-f)*(l-f)+(u-p)+(u-p),L>19600?(T=m-y,S=x-b,F=Math.sqrt(T*T+S*S),T/=F,S/=F,T*=G,S*=G,B.push(f-T,p-S),B.push(U,j,W,k),B.push(f+T,p+S),B.push(U,j,W,k),B.push(f-T,p-S),B.push(U,j,W,k),O++):(B.push(l,u),B.push(U,j,W,k),B.push(f-(l-f),p-(u-p)),B.push(U,j,W,k)));for(c=n[2*(P-2)],d=n[2*(P-2)+1],f=n[2*(P-1)],p=n[2*(P-1)+1],m=-(d-p),x=c-f,F=Math.sqrt(m*m+x*x),m/=F,x/=F,m*=G,x*=G,B.push(f-m,p-x),B.push(U,j,W,k),B.push(f+m,p+x),B.push(U,j,W,k),I.push(D),i=0;O>i;i++)I.push(D++);I.push(D-1)}},r.WebGLGraphics.buildComplexPoly=function(t,e){var i=t.points.slice();if(!(i.length<6)){var n=e.indices;e.points=i,e.alpha=t.fillAlpha,e.color=r.hex2rgb(t.fillColor);for(var o,s,a=1/0,h=-1/0,l=1/0,u=-1/0,c=0;c<i.length;c+=2)o=i[c],s=i[c+1],a=a>o?o:a,h=o>h?o:h,l=l>s?s:l,u=s>u?s:u;i.push(a,l,h,l,h,u,a,u);var d=i.length/2;for(c=0;d>c;c++)n.push(c)}},r.WebGLGraphics.buildPoly=function(t,e){var i=t.points;if(!(i.length<6)){var n=e.points,o=e.indices,s=i.length/2,a=r.hex2rgb(t.fillColor),h=t.fillAlpha,l=a[0]*h,u=a[1]*h,c=a[2]*h,d=r.PolyK.Triangulate(i),f=n.length/6,p=0;for(p=0;p<d.length;p+=3)o.push(d[p]+f),o.push(d[p]+f),o.push(d[p+1]+f),o.push(d[p+2]+f),o.push(d[p+2]+f);for(p=0;s>p;p++)n.push(i[2*p],i[2*p+1],l,u,c,h)}},r.WebGLGraphics.graphicsDataPool=[],r.WebGLGraphicsData=function(t){this.gl=t,this.color=[0,0,0],this.points=[],this.indices=[],this.lastIndex=0,this.buffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.mode=1,this.alpha=1,this.dirty=!0},r.WebGLGraphicsData.prototype.reset=function(){this.points=[],this.indices=[],this.lastIndex=0},r.WebGLGraphicsData.prototype.upload=function(){var t=this.gl;this.glPoints=new Float32Array(this.points),t.bindBuffer(t.ARRAY_BUFFER,this.buffer),t.bufferData(t.ARRAY_BUFFER,this.glPoints,t.STATIC_DRAW),this.glIndicies=new Uint16Array(this.indices),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.glIndicies,t.STATIC_DRAW),this.dirty=!1},r.glContexts=[],r.WebGLRenderer=function(t,e,i,n,o,s){r.defaultRenderer||(r.sayHello("webGL"),r.defaultRenderer=this),this.type=r.WEBGL_RENDERER,this.transparent=!!n,this.preserveDrawingBuffer=s,this.width=t||800,this.height=e||600,this.view=i||document.createElement("canvas"),this.view.width=this.width,this.view.height=this.height,this.contextLost=this.handleContextLost.bind(this),this.contextRestoredLost=this.handleContextRestored.bind(this),this.view.addEventListener("webglcontextlost",this.contextLost,!1),this.view.addEventListener("webglcontextrestored",this.contextRestoredLost,!1),this.options={alpha:this.transparent,antialias:!!o,premultipliedAlpha:!!n,stencil:!0,preserveDrawingBuffer:s};var a=null;if(["experimental-webgl","webgl"].forEach(function(t){try{a=a||this.view.getContext(t,this.options)}catch(t){}},this),!a)throw new Error("This browser does not support webGL. Try using the canvas renderer"+this);this.gl=a,this.glContextId=a.id=r.WebGLRenderer.glContextId++,r.glContexts[this.glContextId]=a,r.blendModesWebGL||(r.blendModesWebGL=[],r.blendModesWebGL[r.blendModes.NORMAL]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.ADD]=[a.SRC_ALPHA,a.DST_ALPHA],r.blendModesWebGL[r.blendModes.MULTIPLY]=[a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.SCREEN]=[a.SRC_ALPHA,a.ONE],r.blendModesWebGL[r.blendModes.OVERLAY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.DARKEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.LIGHTEN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.COLOR_DODGE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.COLOR_BURN]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.HARD_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.SOFT_LIGHT]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.DIFFERENCE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.EXCLUSION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.HUE]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.SATURATION]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.COLOR]=[a.ONE,a.ONE_MINUS_SRC_ALPHA],r.blendModesWebGL[r.blendModes.LUMINOSITY]=[a.ONE,a.ONE_MINUS_SRC_ALPHA]),this.projection=new r.Point,this.projection.x=this.width/2,this.projection.y=-this.height/2,this.offset=new r.Point(0,0),this.resize(this.width,this.height),this.contextLost=!1,this.shaderManager=new r.WebGLShaderManager(a),this.spriteBatch=new r.WebGLSpriteBatch(a),this.maskManager=new r.WebGLMaskManager(a),this.filterManager=new r.WebGLFilterManager(a,this.transparent),this.stencilManager=new r.WebGLStencilManager(a),this.blendModeManager=new r.WebGLBlendModeManager(a),this.renderSession={},this.renderSession.gl=this.gl,this.renderSession.drawCount=0,this.renderSession.shaderManager=this.shaderManager,this.renderSession.maskManager=this.maskManager,this.renderSession.filterManager=this.filterManager,this.renderSession.blendModeManager=this.blendModeManager,this.renderSession.spriteBatch=this.spriteBatch,this.renderSession.stencilManager=this.stencilManager,this.renderSession.renderer=this,a.useProgram(this.shaderManager.defaultShader.program),a.disable(a.DEPTH_TEST),a.disable(a.CULL_FACE),a.enable(a.BLEND),a.colorMask(!0,!0,!0,this.transparent)},r.WebGLRenderer.prototype.constructor=r.WebGLRenderer,r.WebGLRenderer.prototype.render=function(t){if(!this.contextLost){this.__stage!==t&&(t.interactive&&t.interactionManager.removeEvents(),this.__stage=t),r.WebGLRenderer.updateTextures(),t.updateTransform(),t._interactive&&(t._interactiveEventsAdded||(t._interactiveEventsAdded=!0,t.interactionManager.setTarget(this)));var e=this.gl;e.viewport(0,0,this.width,this.height),e.bindFramebuffer(e.FRAMEBUFFER,null),this.transparent?e.clearColor(0,0,0,0):e.clearColor(t.backgroundColorSplit[0],t.backgroundColorSplit[1],t.backgroundColorSplit[2],1),e.clear(e.COLOR_BUFFER_BIT),this.renderDisplayObject(t,this.projection),t.interactive?t._interactiveEventsAdded||(t._interactiveEventsAdded=!0,t.interactionManager.setTarget(this)):t._interactiveEventsAdded&&(t._interactiveEventsAdded=!1,t.interactionManager.setTarget(this))}},r.WebGLRenderer.prototype.renderDisplayObject=function(t,e,i){this.renderSession.blendModeManager.setBlendMode(r.blendModes.NORMAL),this.renderSession.drawCount=0,this.renderSession.currentBlendMode=9999,this.renderSession.projection=e,this.renderSession.offset=this.offset,this.spriteBatch.begin(this.renderSession),this.filterManager.begin(this.renderSession,i),t._renderWebGL(this.renderSession),this.spriteBatch.end()},r.WebGLRenderer.updateTextures=function(){var t=0;for(t=0;t<r.Texture.frameUpdates.length;t++)r.WebGLRenderer.updateTextureFrame(r.Texture.frameUpdates[t]);for(t=0;t<r.texturesToDestroy.length;t++)r.WebGLRenderer.destroyTexture(r.texturesToDestroy[t]);r.texturesToUpdate.length=0,r.texturesToDestroy.length=0,r.Texture.frameUpdates.length=0},r.WebGLRenderer.destroyTexture=function(t){for(var e=t._glTextures.length-1;e>=0;e--){var i=t._glTextures[e],n=r.glContexts[e];n&&i&&n.deleteTexture(i)}t._glTextures.length=0},r.WebGLRenderer.updateTextureFrame=function(t){t._updateWebGLuvs()},r.WebGLRenderer.prototype.resize=function(t,e){this.width=t,this.height=e,this.view.width=t,
  this.view.height=e,this.gl.viewport(0,0,this.width,this.height),this.projection.x=this.width/2,this.projection.y=-this.height/2},r.createWebGLTexture=function(t,e){return t.hasLoaded&&(t._glTextures[e.id]=e.createTexture(),e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR:e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),e.bindTexture(e.TEXTURE_2D,null),t._dirty[e.id]=!1),t._glTextures[e.id]},r.updateWebGLTexture=function(t,e){t._glTextures[e.id]&&(e.bindTexture(e.TEXTURE_2D,t._glTextures[e.id]),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultipliedAlpha),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t.source),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR:e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t.scaleMode===r.scaleModes.LINEAR?e.LINEAR:e.NEAREST),t._powerOf2?(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.REPEAT),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.REPEAT)):(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)),t._dirty[e.id]=!1)},r.WebGLRenderer.prototype.handleContextLost=function(t){t.preventDefault(),this.contextLost=!0},r.WebGLRenderer.prototype.handleContextRestored=function(){try{this.gl=this.view.getContext("experimental-webgl",this.options)}catch(t){try{this.gl=this.view.getContext("webgl",this.options)}catch(t){throw new Error(" This browser does not support webGL. Try using the canvas renderer"+this)}}var t=this.gl;t.id=r.WebGLRenderer.glContextId++,this.shaderManager.setContext(t),this.spriteBatch.setContext(t),this.primitiveBatch.setContext(t),this.maskManager.setContext(t),this.filterManager.setContext(t),this.renderSession.gl=this.gl,t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.enable(t.BLEND),t.colorMask(!0,!0,!0,this.transparent),this.gl.viewport(0,0,this.width,this.height);for(var e in r.TextureCache){r.TextureCache[e].baseTexture._glTextures=[]}this.contextLost=!1},r.WebGLRenderer.prototype.destroy=function(){this.view.removeEventListener("webglcontextlost",this.contextLost),this.view.removeEventListener("webglcontextrestored",this.contextRestoredLost),r.glContexts[this.glContextId]=null,this.projection=null,this.offset=null,this.shaderManager.destroy(),this.spriteBatch.destroy(),this.primitiveBatch.destroy(),this.maskManager.destroy(),this.filterManager.destroy(),this.shaderManager=null,this.spriteBatch=null,this.maskManager=null,this.filterManager=null,this.gl=null,this.renderSession=null},r.WebGLRenderer.glContextId=0,r.WebGLBlendModeManager=function(t){this.gl=t,this.currentBlendMode=99999},r.WebGLBlendModeManager.prototype.setBlendMode=function(t){if(this.currentBlendMode===t)return!1;this.currentBlendMode=t;var e=r.blendModesWebGL[this.currentBlendMode];return this.gl.blendFunc(e[0],e[1]),!0},r.WebGLBlendModeManager.prototype.destroy=function(){this.gl=null},r.WebGLMaskManager=function(t){this.maskStack=[],this.maskPosition=0,this.setContext(t),this.reverse=!1,this.count=0},r.WebGLMaskManager.prototype.setContext=function(t){this.gl=t},r.WebGLMaskManager.prototype.pushMask=function(t,e){var i=e.gl;t.dirty&&r.WebGLGraphics.updateGraphics(t,i),t._webGL[i.id].data.length&&e.stencilManager.pushStencil(t,t._webGL[i.id].data[0],e)},r.WebGLMaskManager.prototype.popMask=function(t,e){var i=this.gl;e.stencilManager.popStencil(t,t._webGL[i.id].data[0],e)},r.WebGLMaskManager.prototype.destroy=function(){this.maskStack=null,this.gl=null},r.WebGLStencilManager=function(t){this.stencilStack=[],this.setContext(t),this.reverse=!0,this.count=0},r.WebGLStencilManager.prototype.setContext=function(t){this.gl=t},r.WebGLStencilManager.prototype.pushStencil=function(t,e,i){var r=this.gl;this.bindGraphics(t,e,i),0===this.stencilStack.length&&(r.enable(r.STENCIL_TEST),r.clear(r.STENCIL_BUFFER_BIT),this.reverse=!0,this.count=0),this.stencilStack.push(e);var n=this.count;r.colorMask(!1,!1,!1,!1),r.stencilFunc(r.ALWAYS,0,255),r.stencilOp(r.KEEP,r.KEEP,r.INVERT),1===e.mode?(r.drawElements(r.TRIANGLE_FAN,e.indices.length-4,r.UNSIGNED_SHORT,0),this.reverse?(r.stencilFunc(r.EQUAL,255-n,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)):(r.stencilFunc(r.EQUAL,n,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(e.indices.length-4)),this.reverse?r.stencilFunc(r.EQUAL,255-(n+1),255):r.stencilFunc(r.EQUAL,n+1,255),this.reverse=!this.reverse):(this.reverse?(r.stencilFunc(r.EQUAL,n,255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)):(r.stencilFunc(r.EQUAL,255-n,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)),r.drawElements(r.TRIANGLE_STRIP,e.indices.length,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,n+1,255):r.stencilFunc(r.EQUAL,255-(n+1),255)),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP),this.count++},r.WebGLStencilManager.prototype.bindGraphics=function(t,e,i){this._currentGraphics=t;var n,o=this.gl,s=i.projection,a=i.offset;1===e.mode?(n=i.shaderManager.complexPrimativeShader,i.shaderManager.setShader(n),o.uniformMatrix3fv(n.translationMatrix,!1,t.worldTransform.toArray(!0)),o.uniform2f(n.projectionVector,s.x,-s.y),o.uniform2f(n.offsetVector,-a.x,-a.y),o.uniform3fv(n.tintColor,r.hex2rgb(t.tint)),o.uniform3fv(n.color,e.color),o.uniform1f(n.alpha,t.worldAlpha*e.alpha),o.bindBuffer(o.ARRAY_BUFFER,e.buffer),o.vertexAttribPointer(n.aVertexPosition,2,o.FLOAT,!1,8,0),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.indexBuffer)):(n=i.shaderManager.primitiveShader,i.shaderManager.setShader(n),o.uniformMatrix3fv(n.translationMatrix,!1,t.worldTransform.toArray(!0)),o.uniform2f(n.projectionVector,s.x,-s.y),o.uniform2f(n.offsetVector,-a.x,-a.y),o.uniform3fv(n.tintColor,r.hex2rgb(t.tint)),o.uniform1f(n.alpha,t.worldAlpha),o.bindBuffer(o.ARRAY_BUFFER,e.buffer),o.vertexAttribPointer(n.aVertexPosition,2,o.FLOAT,!1,24,0),o.vertexAttribPointer(n.colorAttribute,4,o.FLOAT,!1,24,8),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,e.indexBuffer))},r.WebGLStencilManager.prototype.popStencil=function(t,e,i){var r=this.gl;if(this.stencilStack.pop(),this.count--,0===this.stencilStack.length)r.disable(r.STENCIL_TEST);else{var n=this.count;this.bindGraphics(t,e,i),r.colorMask(!1,!1,!1,!1),1===e.mode?(this.reverse=!this.reverse,this.reverse?(r.stencilFunc(r.EQUAL,255-(n+1),255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)):(r.stencilFunc(r.EQUAL,n+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)),r.drawElements(r.TRIANGLE_FAN,4,r.UNSIGNED_SHORT,2*(e.indices.length-4)),r.stencilFunc(r.ALWAYS,0,255),r.stencilOp(r.KEEP,r.KEEP,r.INVERT),r.drawElements(r.TRIANGLE_FAN,e.indices.length-4,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,n,255):r.stencilFunc(r.EQUAL,255-n,255)):(this.reverse?(r.stencilFunc(r.EQUAL,n+1,255),r.stencilOp(r.KEEP,r.KEEP,r.DECR)):(r.stencilFunc(r.EQUAL,255-(n+1),255),r.stencilOp(r.KEEP,r.KEEP,r.INCR)),r.drawElements(r.TRIANGLE_STRIP,e.indices.length,r.UNSIGNED_SHORT,0),this.reverse?r.stencilFunc(r.EQUAL,n,255):r.stencilFunc(r.EQUAL,255-n,255)),r.colorMask(!0,!0,!0,!0),r.stencilOp(r.KEEP,r.KEEP,r.KEEP)}},r.WebGLStencilManager.prototype.destroy=function(){this.maskStack=null,this.gl=null},r.WebGLShaderManager=function(t){this.maxAttibs=10,this.attribState=[],this.tempAttribState=[],this.shaderMap=[];for(var e=0;e<this.maxAttibs;e++)this.attribState[e]=!1;this.setContext(t)},r.WebGLShaderManager.prototype.setContext=function(t){this.gl=t,this.primitiveShader=new r.PrimitiveShader(t),this.complexPrimativeShader=new r.ComplexPrimitiveShader(t),this.defaultShader=new r.PixiShader(t),this.fastShader=new r.PixiFastShader(t),this.stripShader=new r.StripShader(t),this.setShader(this.defaultShader)},r.WebGLShaderManager.prototype.setAttribs=function(t){var e;for(e=0;e<this.tempAttribState.length;e++)this.tempAttribState[e]=!1;for(e=0;e<t.length;e++){var i=t[e];this.tempAttribState[i]=!0}var r=this.gl;for(e=0;e<this.attribState.length;e++)this.attribState[e]!==this.tempAttribState[e]&&(this.attribState[e]=this.tempAttribState[e],this.tempAttribState[e]?r.enableVertexAttribArray(e):r.disableVertexAttribArray(e))},r.WebGLShaderManager.prototype.setShader=function(t){return this._currentId!==t._UID&&(this._currentId=t._UID,this.currentShader=t,this.gl.useProgram(t.program),this.setAttribs(t.attributes),!0)},r.WebGLShaderManager.prototype.destroy=function(){this.attribState=null,this.tempAttribState=null,this.primitiveShader.destroy(),this.defaultShader.destroy(),this.fastShader.destroy(),this.stripShader.destroy(),this.gl=null},r.WebGLSpriteBatch=function(t){this.vertSize=6,this.size=2e3;var e=4*this.size*this.vertSize,i=6*this.size;this.vertices=new Float32Array(e),this.indices=new Uint16Array(i),this.lastIndexCount=0;for(var r=0,n=0;i>r;r+=6,n+=4)this.indices[r+0]=n+0,this.indices[r+1]=n+1,this.indices[r+2]=n+2,this.indices[r+3]=n+0,this.indices[r+4]=n+2,this.indices[r+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.setContext(t),this.dirty=!0,this.textures=[],this.blendModes=[]},r.WebGLSpriteBatch.prototype.setContext=function(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW),this.currentBlendMode=99999},r.WebGLSpriteBatch.prototype.begin=function(t){this.renderSession=t,this.shader=this.renderSession.shaderManager.defaultShader,this.start()},r.WebGLSpriteBatch.prototype.end=function(){this.flush()},r.WebGLSpriteBatch.prototype.render=function(t){var e=t.texture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture);var i=e._uvs;if(i){var r,n,o,s,a=t.worldAlpha,h=t.tint,l=this.vertices,u=t.anchor.x,c=t.anchor.y;if(e.trim){var d=e.trim;n=d.x-u*d.width,r=n+e.crop.width,s=d.y-c*d.height,o=s+e.crop.height}else r=e.frame.width*(1-u),n=e.frame.width*-u,o=e.frame.height*(1-c),s=e.frame.height*-c;var f=4*this.currentBatchSize*this.vertSize,p=t.worldTransform,g=p.a,v=p.c,m=p.b,x=p.d,y=p.tx,b=p.ty;l[f++]=g*n+m*s+y,l[f++]=x*s+v*n+b,l[f++]=i.x0,l[f++]=i.y0,l[f++]=a,l[f++]=h,l[f++]=g*r+m*s+y,l[f++]=x*s+v*r+b,l[f++]=i.x1,l[f++]=i.y1,l[f++]=a,l[f++]=h,l[f++]=g*r+m*o+y,l[f++]=x*o+v*r+b,l[f++]=i.x2,l[f++]=i.y2,l[f++]=a,l[f++]=h,l[f++]=g*n+m*o+y,l[f++]=x*o+v*n+b,l[f++]=i.x3,l[f++]=i.y3,l[f++]=a,l[f++]=h,this.textures[this.currentBatchSize]=t.texture.baseTexture,this.blendModes[this.currentBatchSize]=t.blendMode,this.currentBatchSize++}},r.WebGLSpriteBatch.prototype.renderTilingSprite=function(t){var e=t.tilingTexture;this.currentBatchSize>=this.size&&(this.flush(),this.currentBaseTexture=e.baseTexture),t._uvs||(t._uvs=new r.TextureUvs);var i=t._uvs;t.tilePosition.x%=e.baseTexture.width*t.tileScaleOffset.x,t.tilePosition.y%=e.baseTexture.height*t.tileScaleOffset.y;var n=t.tilePosition.x/(e.baseTexture.width*t.tileScaleOffset.x),o=t.tilePosition.y/(e.baseTexture.height*t.tileScaleOffset.y),s=t.width/e.baseTexture.width/(t.tileScale.x*t.tileScaleOffset.x),a=t.height/e.baseTexture.height/(t.tileScale.y*t.tileScaleOffset.y);i.x0=0-n,i.y0=0-o,i.x1=1*s-n,i.y1=0-o,i.x2=1*s-n,i.y2=1*a-o,i.x3=0-n,i.y3=1*a-o;var h=t.worldAlpha,l=t.tint,u=this.vertices,c=t.width,d=t.height,f=t.anchor.x,p=t.anchor.y,g=c*(1-f),v=c*-f,m=d*(1-p),x=d*-p,y=4*this.currentBatchSize*this.vertSize,b=t.worldTransform,T=b.a,S=b.c,_=b.b,w=b.d,E=b.tx,C=b.ty;u[y++]=T*v+_*x+E,u[y++]=w*x+S*v+C,u[y++]=i.x0,u[y++]=i.y0,u[y++]=h,u[y++]=l,u[y++]=T*g+_*x+E,u[y++]=w*x+S*g+C,u[y++]=i.x1,u[y++]=i.y1,u[y++]=h,u[y++]=l,u[y++]=T*g+_*m+E,u[y++]=w*m+S*g+C,u[y++]=i.x2,u[y++]=i.y2,u[y++]=h,u[y++]=l,u[y++]=T*v+_*m+E,u[y++]=w*m+S*v+C,u[y++]=i.x3,u[y++]=i.y3,u[y++]=h,u[y++]=l,this.textures[this.currentBatchSize]=e.baseTexture,this.blendModes[this.currentBatchSize]=t.blendMode,this.currentBatchSize++},r.WebGLSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.renderSession.shaderManager.setShader(this.renderSession.shaderManager.defaultShader),this.dirty){this.dirty=!1,t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.colorAttribute,2,t.FLOAT,!1,i,16)}if(this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var r=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,r)}for(var n,o,s=0,a=0,h=null,l=this.renderSession.blendModeManager.currentBlendMode,u=0,c=this.currentBatchSize;c>u;u++)n=this.textures[u],o=this.blendModes[u],(h!==n||l!==o)&&(this.renderBatch(h,s,a),a=u,s=0,h=n,l=o,this.renderSession.blendModeManager.setBlendMode(l)),s++;this.renderBatch(h,s,a),this.currentBatchSize=0}},r.WebGLSpriteBatch.prototype.renderBatch=function(t,e,i){if(0!==e){var n=this.gl;n.bindTexture(n.TEXTURE_2D,t._glTextures[n.id]||r.createWebGLTexture(t,n)),t._dirty[n.id]&&r.updateWebGLTexture(this.currentBaseTexture,n),n.drawElements(n.TRIANGLES,6*e,n.UNSIGNED_SHORT,6*i*2),this.renderSession.drawCount++}},r.WebGLSpriteBatch.prototype.stop=function(){this.flush()},r.WebGLSpriteBatch.prototype.start=function(){this.dirty=!0},r.WebGLSpriteBatch.prototype.destroy=function(){this.vertices=null,this.indices=null,this.gl.deleteBuffer(this.vertexBuffer),this.gl.deleteBuffer(this.indexBuffer),this.currentBaseTexture=null,this.gl=null},r.WebGLFastSpriteBatch=function(t){this.vertSize=10,this.maxSize=6e3,this.size=this.maxSize;var e=4*this.size*this.vertSize,i=6*this.maxSize;this.vertices=new Float32Array(e),this.indices=new Uint16Array(i),this.vertexBuffer=null,this.indexBuffer=null,this.lastIndexCount=0;for(var r=0,n=0;i>r;r+=6,n+=4)this.indices[r+0]=n+0,this.indices[r+1]=n+1,this.indices[r+2]=n+2,this.indices[r+3]=n+0,this.indices[r+4]=n+2,this.indices[r+5]=n+3;this.drawing=!1,this.currentBatchSize=0,this.currentBaseTexture=null,this.currentBlendMode=0,this.renderSession=null,this.shader=null,this.matrix=null,this.setContext(t)},r.WebGLFastSpriteBatch.prototype.setContext=function(t){this.gl=t,this.vertexBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,this.indices,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertices,t.DYNAMIC_DRAW)},r.WebGLFastSpriteBatch.prototype.begin=function(t,e){this.renderSession=e,this.shader=this.renderSession.shaderManager.fastShader,this.matrix=t.worldTransform.toArray(!0),this.start()},r.WebGLFastSpriteBatch.prototype.end=function(){this.flush()},r.WebGLFastSpriteBatch.prototype.render=function(t){var e=t.children,i=e[0];if(i.texture._uvs){this.currentBaseTexture=i.texture.baseTexture,i.blendMode!==this.renderSession.blendModeManager.currentBlendMode&&(this.flush(),this.renderSession.blendModeManager.setBlendMode(i.blendMode));for(var r=0,n=e.length;n>r;r++)this.renderSprite(e[r]);this.flush()}},r.WebGLFastSpriteBatch.prototype.renderSprite=function(t){if(t.visible&&(t.texture.baseTexture===this.currentBaseTexture||(this.flush(),this.currentBaseTexture=t.texture.baseTexture,t.texture._uvs))){var e,i,r,n,o,s,a=this.vertices;if(e=t.texture._uvs,t.texture.frame.width,t.texture.frame.height,t.texture.trim){var h=t.texture.trim;r=h.x-t.anchor.x*h.width,i=r+t.texture.crop.width,o=h.y-t.anchor.y*h.height,n=o+t.texture.crop.height}else i=t.texture.frame.width*(1-t.anchor.x),r=t.texture.frame.width*-t.anchor.x,n=t.texture.frame.height*(1-t.anchor.y),o=t.texture.frame.height*-t.anchor.y;s=4*this.currentBatchSize*this.vertSize,a[s++]=r,a[s++]=o,a[s++]=t.position.x,a[s++]=t.position.y,a[s++]=t.scale.x,a[s++]=t.scale.y,a[s++]=t.rotation,a[s++]=e.x0,a[s++]=e.y1,a[s++]=t.alpha,a[s++]=i,a[s++]=o,a[s++]=t.position.x,a[s++]=t.position.y,a[s++]=t.scale.x,a[s++]=t.scale.y,a[s++]=t.rotation,a[s++]=e.x1,a[s++]=e.y1,a[s++]=t.alpha,a[s++]=i,a[s++]=n,a[s++]=t.position.x,a[s++]=t.position.y,a[s++]=t.scale.x,a[s++]=t.scale.y,a[s++]=t.rotation,a[s++]=e.x2,a[s++]=e.y2,a[s++]=t.alpha,a[s++]=r,a[s++]=n,a[s++]=t.position.x,a[s++]=t.position.y,a[s++]=t.scale.x,a[s++]=t.scale.y,a[s++]=t.rotation,a[s++]=e.x3,a[s++]=e.y3,a[s++]=t.alpha,++this.currentBatchSize>=this.size&&this.flush()}},r.WebGLFastSpriteBatch.prototype.flush=function(){if(0!==this.currentBatchSize){var t=this.gl;if(this.currentBaseTexture._glTextures[t.id]||r.createWebGLTexture(this.currentBaseTexture,t),t.bindTexture(t.TEXTURE_2D,this.currentBaseTexture._glTextures[t.id]),this.currentBatchSize>.5*this.size)t.bufferSubData(t.ARRAY_BUFFER,0,this.vertices);else{var e=this.vertices.subarray(0,4*this.currentBatchSize*this.vertSize);t.bufferSubData(t.ARRAY_BUFFER,0,e)}t.drawElements(t.TRIANGLES,6*this.currentBatchSize,t.UNSIGNED_SHORT,0),this.currentBatchSize=0,this.renderSession.drawCount++}},r.WebGLFastSpriteBatch.prototype.stop=function(){this.flush()},r.WebGLFastSpriteBatch.prototype.start=function(){var t=this.gl;t.activeTexture(t.TEXTURE0),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer);var e=this.renderSession.projection;t.uniform2f(this.shader.projectionVector,e.x,e.y),t.uniformMatrix3fv(this.shader.uMatrix,!1,this.matrix);var i=4*this.vertSize;t.vertexAttribPointer(this.shader.aVertexPosition,2,t.FLOAT,!1,i,0),t.vertexAttribPointer(this.shader.aPositionCoord,2,t.FLOAT,!1,i,8),t.vertexAttribPointer(this.shader.aScale,2,t.FLOAT,!1,i,16),t.vertexAttribPointer(this.shader.aRotation,1,t.FLOAT,!1,i,24),t.vertexAttribPointer(this.shader.aTextureCoord,2,t.FLOAT,!1,i,28),t.vertexAttribPointer(this.shader.colorAttribute,1,t.FLOAT,!1,i,36)},r.WebGLFilterManager=function(t,e){this.transparent=e,this.filterStack=[],this.offsetX=0,this.offsetY=0,this.setContext(t)},r.WebGLFilterManager.prototype.setContext=function(t){this.gl=t,this.texturePool=[],this.initShaderBuffers()},r.WebGLFilterManager.prototype.begin=function(t,e){this.renderSession=t,this.defaultShader=t.shaderManager.defaultShader;var i=this.renderSession.projection;this.width=2*i.x,this.height=2*-i.y,this.buffer=e},r.WebGLFilterManager.prototype.pushFilter=function(t){var e=this.gl,i=this.renderSession.projection,n=this.renderSession.offset;t._filterArea=t.target.filterArea||t.target.getBounds(),this.filterStack.push(t);var o=t.filterPasses[0];this.offsetX+=t._filterArea.x,this.offsetY+=t._filterArea.y;var s=this.texturePool.pop();s?s.resize(this.width,this.height):s=new r.FilterTexture(this.gl,this.width,this.height),e.bindTexture(e.TEXTURE_2D,s.texture);var a=t._filterArea,h=o.padding;a.x-=h,a.y-=h,a.width+=2*h,a.height+=2*h,a.x<0&&(a.x=0),a.width>this.width&&(a.width=this.width),a.y<0&&(a.y=0),a.height>this.height&&(a.height=this.height),e.bindFramebuffer(e.FRAMEBUFFER,s.frameBuffer),e.viewport(0,0,a.width,a.height),i.x=a.width/2,i.y=-a.height/2,n.x=-a.x,n.y=-a.y,this.renderSession.shaderManager.setShader(this.defaultShader),e.uniform2f(this.defaultShader.projectionVector,a.width/2,-a.height/2),e.uniform2f(this.defaultShader.offsetVector,-a.x,-a.y),e.colorMask(!0,!0,!0,!0),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),t._glFilterTexture=s},r.WebGLFilterManager.prototype.popFilter=function(){var t=this.gl,e=this.filterStack.pop(),i=e._filterArea,n=e._glFilterTexture,o=this.renderSession.projection,s=this.renderSession.offset;if(e.filterPasses.length>1){t.viewport(0,0,i.width,i.height),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=0,this.vertexArray[1]=i.height,this.vertexArray[2]=i.width,this.vertexArray[3]=i.height,this.vertexArray[4]=0,this.vertexArray[5]=0,this.vertexArray[6]=i.width,this.vertexArray[7]=0,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray);var a=n,h=this.texturePool.pop();h||(h=new r.FilterTexture(this.gl,this.width,this.height)),h.resize(this.width,this.height),t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.clear(t.COLOR_BUFFER_BIT),t.disable(t.BLEND);for(var l=0;l<e.filterPasses.length-1;l++){var u=e.filterPasses[l];t.bindFramebuffer(t.FRAMEBUFFER,h.frameBuffer),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,a.texture),this.applyFilterPass(u,i,i.width,i.height);var c=a;a=h,h=c}t.enable(t.BLEND),n=a,this.texturePool.push(h)}var d=e.filterPasses[e.filterPasses.length-1];this.offsetX-=i.x,this.offsetY-=i.y;var f=this.width,p=this.height,g=0,v=0,m=this.buffer;if(0===this.filterStack.length)t.colorMask(!0,!0,!0,!0);else{var x=this.filterStack[this.filterStack.length-1];i=x._filterArea,f=i.width,p=i.height,g=i.x,v=i.y,m=x._glFilterTexture.frameBuffer}o.x=f/2,o.y=-p/2,s.x=g,s.y=v,i=e._filterArea;var y=i.x-g,b=i.y-v;t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),this.vertexArray[0]=y,this.vertexArray[1]=b+i.height,this.vertexArray[2]=y+i.width,this.vertexArray[3]=b+i.height,this.vertexArray[4]=y,this.vertexArray[5]=b,this.vertexArray[6]=y+i.width,this.vertexArray[7]=b,t.bufferSubData(t.ARRAY_BUFFER,0,this.vertexArray),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),this.uvArray[2]=i.width/this.width,this.uvArray[5]=i.height/this.height,this.uvArray[6]=i.width/this.width,this.uvArray[7]=i.height/this.height,t.bufferSubData(t.ARRAY_BUFFER,0,this.uvArray),t.viewport(0,0,f,p),t.bindFramebuffer(t.FRAMEBUFFER,m),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,n.texture),this.applyFilterPass(d,i,f,p),this.renderSession.shaderManager.setShader(this.defaultShader),t.uniform2f(this.defaultShader.projectionVector,f/2,-p/2),t.uniform2f(this.defaultShader.offsetVector,-g,-v),this.texturePool.push(n),e._glFilterTexture=null},r.WebGLFilterManager.prototype.applyFilterPass=function(t,e,i,n){var o=this.gl,s=t.shaders[o.id];s||(s=new r.PixiShader(o),s.fragmentSrc=t.fragmentSrc,s.uniforms=t.uniforms,s.init(),t.shaders[o.id]=s),this.renderSession.shaderManager.setShader(s),o.uniform2f(s.projectionVector,i/2,-n/2),o.uniform2f(s.offsetVector,0,0),t.uniforms.dimensions&&(t.uniforms.dimensions.value[0]=this.width,t.uniforms.dimensions.value[1]=this.height,t.uniforms.dimensions.value[2]=this.vertexArray[0],t.uniforms.dimensions.value[3]=this.vertexArray[5]),s.syncUniforms(),o.bindBuffer(o.ARRAY_BUFFER,this.vertexBuffer),o.vertexAttribPointer(s.aVertexPosition,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this.uvBuffer),o.vertexAttribPointer(s.aTextureCoord,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,this.colorBuffer),o.vertexAttribPointer(s.colorAttribute,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,this.indexBuffer),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0),this.renderSession.drawCount++},r.WebGLFilterManager.prototype.initShaderBuffers=function(){var t=this.gl;this.vertexBuffer=t.createBuffer(),this.uvBuffer=t.createBuffer(),this.colorBuffer=t.createBuffer(),this.indexBuffer=t.createBuffer(),this.vertexArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.vertexBuffer),t.bufferData(t.ARRAY_BUFFER,this.vertexArray,t.STATIC_DRAW),this.uvArray=new Float32Array([0,0,1,0,0,1,1,1]),t.bindBuffer(t.ARRAY_BUFFER,this.uvBuffer),t.bufferData(t.ARRAY_BUFFER,this.uvArray,t.STATIC_DRAW),this.colorArray=new Float32Array([1,16777215,1,16777215,1,16777215,1,16777215]),t.bindBuffer(t.ARRAY_BUFFER,this.colorBuffer),t.bufferData(t.ARRAY_BUFFER,this.colorArray,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.indexBuffer),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array([0,1,2,1,3,2]),t.STATIC_DRAW)},r.WebGLFilterManager.prototype.destroy=function(){var t=this.gl;this.filterStack=null,this.offsetX=0,this.offsetY=0;for(var e=0;e<this.texturePool.length;e++)this.texturePool[e].destroy();this.texturePool=null,t.deleteBuffer(this.vertexBuffer),t.deleteBuffer(this.uvBuffer),t.deleteBuffer(this.colorBuffer),t.deleteBuffer(this.indexBuffer)},r.FilterTexture=function(t,e,i,n){this.gl=t,this.frameBuffer=t.createFramebuffer(),this.texture=t.createTexture(),n=n||r.scaleModes.DEFAULT,t.bindTexture(t.TEXTURE_2D,this.texture),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,n===r.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,n===r.scaleModes.LINEAR?t.LINEAR:t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,this.framebuffer),t.bindFramebuffer(t.FRAMEBUFFER,this.frameBuffer),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,this.texture,0),this.renderBuffer=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,this.renderBuffer),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,this.renderBuffer),this.resize(e,i)},r.FilterTexture.prototype.clear=function(){var t=this.gl;t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT)},r.FilterTexture.prototype.resize=function(t,e){if(this.width!==t||this.height!==e){this.width=t,this.height=e;var i=this.gl;i.bindTexture(i.TEXTURE_2D,this.texture),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,t,e,0,i.RGBA,i.UNSIGNED_BYTE,null),i.bindRenderbuffer(i.RENDERBUFFER,this.renderBuffer),i.renderbufferStorage(i.RENDERBUFFER,i.DEPTH_STENCIL,t,e)}},r.FilterTexture.prototype.destroy=function(){var t=this.gl;t.deleteFramebuffer(this.frameBuffer),t.deleteTexture(this.texture),this.frameBuffer=null,this.texture=null},r.CanvasMaskManager=function(){},r.CanvasMaskManager.prototype.pushMask=function(t,e){e.save();var i=t.alpha,n=t.worldTransform;e.setTransform(n.a,n.c,n.b,n.d,n.tx,n.ty),r.CanvasGraphics.renderGraphicsMask(t,e),e.clip(),t.worldAlpha=i},r.CanvasMaskManager.prototype.popMask=function(t){t.restore()},r.CanvasTinter=function(){},r.CanvasTinter.getTintedTexture=function(t,e){var i=t.texture;e=r.CanvasTinter.roundColor(e);var n="#"+("00000"+(0|e).toString(16)).substr(-6);if(i.tintCache=i.tintCache||{},i.tintCache[n])return i.tintCache[n];var o=r.CanvasTinter.canvas||document.createElement("canvas");if(r.CanvasTinter.tintMethod(i,e,o),r.CanvasTinter.convertTintToImage){var s=new Image;s.src=o.toDataURL(),i.tintCache[n]=s}else i.tintCache[n]=o,r.CanvasTinter.canvas=null;return o},r.CanvasTinter.tintWithMultiply=function(t,e,i){var r=i.getContext("2d"),n=t.frame;i.width=n.width,i.height=n.height,r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,n.width,n.height),r.globalCompositeOperation="multiply",r.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height)},r.CanvasTinter.tintWithOverlay=function(t,e,i){var r=i.getContext("2d"),n=t.frame;i.width=n.width,i.height=n.height,r.globalCompositeOperation="copy",r.fillStyle="#"+("00000"+(0|e).toString(16)).substr(-6),r.fillRect(0,0,n.width,n.height),r.globalCompositeOperation="destination-atop",r.drawImage(t.baseTexture.source,n.x,n.y,n.width,n.height,0,0,n.width,n.height)},r.CanvasTinter.tintWithPerPixel=function(t,e,i){var n=i.getContext("2d"),o=t.frame;i.width=o.width,i.height=o.height,n.globalCompositeOperation="copy",n.drawImage(t.baseTexture.source,o.x,o.y,o.width,o.height,0,0,o.width,o.height);for(var s=r.hex2rgb(e),a=s[0],h=s[1],l=s[2],u=n.getImageData(0,0,o.width,o.height),c=u.data,d=0;d<c.length;d+=4)c[d+0]*=a,c[d+1]*=h,c[d+2]*=l;n.putImageData(u,0,0)},r.CanvasTinter.roundColor=function(t){var e=r.CanvasTinter.cacheStepsPerColorChannel,i=r.hex2rgb(t);return i[0]=Math.min(255,i[0]/e*e),i[1]=Math.min(255,i[1]/e*e),i[2]=Math.min(255,i[2]/e*e),r.rgb2hex(i)},r.CanvasTinter.cacheStepsPerColorChannel=8,r.CanvasTinter.convertTintToImage=!1,r.CanvasTinter.canUseMultiply=r.canUseNewCanvasBlendModes(),r.CanvasTinter.tintMethod=r.CanvasTinter.canUseMultiply?r.CanvasTinter.tintWithMultiply:r.CanvasTinter.tintWithPerPixel,r.CanvasRenderer=function(t,e,i,n){r.defaultRenderer||(r.sayHello("Canvas"),r.defaultRenderer=this),this.type=r.CANVAS_RENDERER,this.clearBeforeRender=!0,this.transparent=!!n,r.blendModesCanvas||(r.blendModesCanvas=[],r.canUseNewCanvasBlendModes()?(r.blendModesCanvas[r.blendModes.NORMAL]="source-over",r.blendModesCanvas[r.blendModes.ADD]="lighter",r.blendModesCanvas[r.blendModes.MULTIPLY]="multiply",r.blendModesCanvas[r.blendModes.SCREEN]="screen",r.blendModesCanvas[r.blendModes.OVERLAY]="overlay",r.blendModesCanvas[r.blendModes.DARKEN]="darken",r.blendModesCanvas[r.blendModes.LIGHTEN]="lighten",r.blendModesCanvas[r.blendModes.COLOR_DODGE]="color-dodge",r.blendModesCanvas[r.blendModes.COLOR_BURN]="color-burn",r.blendModesCanvas[r.blendModes.HARD_LIGHT]="hard-light",r.blendModesCanvas[r.blendModes.SOFT_LIGHT]="soft-light",r.blendModesCanvas[r.blendModes.DIFFERENCE]="difference",r.blendModesCanvas[r.blendModes.EXCLUSION]="exclusion",r.blendModesCanvas[r.blendModes.HUE]="hue",r.blendModesCanvas[r.blendModes.SATURATION]="saturation",r.blendModesCanvas[r.blendModes.COLOR]="color",r.blendModesCanvas[r.blendModes.LUMINOSITY]="luminosity"):(r.blendModesCanvas[r.blendModes.NORMAL]="source-over",r.blendModesCanvas[r.blendModes.ADD]="lighter",r.blendModesCanvas[r.blendModes.MULTIPLY]="source-over",r.blendModesCanvas[r.blendModes.SCREEN]="source-over",r.blendModesCanvas[r.blendModes.OVERLAY]="source-over",r.blendModesCanvas[r.blendModes.DARKEN]="source-over",r.blendModesCanvas[r.blendModes.LIGHTEN]="source-over",r.blendModesCanvas[r.blendModes.COLOR_DODGE]="source-over",r.blendModesCanvas[r.blendModes.COLOR_BURN]="source-over",r.blendModesCanvas[r.blendModes.HARD_LIGHT]="source-over",r.blendModesCanvas[r.blendModes.SOFT_LIGHT]="source-over",r.blendModesCanvas[r.blendModes.DIFFERENCE]="source-over",r.blendModesCanvas[r.blendModes.EXCLUSION]="source-over",r.blendModesCanvas[r.blendModes.HUE]="source-over",r.blendModesCanvas[r.blendModes.SATURATION]="source-over",r.blendModesCanvas[r.blendModes.COLOR]="source-over",r.blendModesCanvas[r.blendModes.LUMINOSITY]="source-over")),this.width=t||800,this.height=e||600,this.view=i||document.createElement("canvas"),this.context=this.view.getContext("2d",{alpha:this.transparent}),this.refresh=!0,this.view.width=this.width,this.view.height=this.height,this.count=0,this.maskManager=new r.CanvasMaskManager,this.renderSession={context:this.context,maskManager:this.maskManager,scaleMode:null,smoothProperty:null,roundPixels:!1},"imageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="imageSmoothingEnabled":"webkitImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="webkitImageSmoothingEnabled":"mozImageSmoothingEnabled"in this.context?this.renderSession.smoothProperty="mozImageSmoothingEnabled":"oImageSmoothingEnabled"in this.context&&(this.renderSession.smoothProperty="oImageSmoothingEnabled")},r.CanvasRenderer.prototype.constructor=r.CanvasRenderer,r.CanvasRenderer.prototype.render=function(t){r.texturesToUpdate.length=0,r.texturesToDestroy.length=0,t.updateTransform(),this.context.setTransform(1,0,0,1,0,0),this.context.globalAlpha=1,navigator.isCocoonJS&&this.view.screencanvas&&(this.context.fillStyle="black",this.context.clear()),!this.transparent&&this.clearBeforeRender?(this.context.fillStyle=t.backgroundColorString,
  this.context.fillRect(0,0,this.width,this.height)):this.transparent&&this.clearBeforeRender&&this.context.clearRect(0,0,this.width,this.height),this.renderDisplayObject(t),t.interactive&&(t._interactiveEventsAdded||(t._interactiveEventsAdded=!0,t.interactionManager.setTarget(this))),r.Texture.frameUpdates.length>0&&(r.Texture.frameUpdates.length=0)},r.CanvasRenderer.prototype.resize=function(t,e){this.width=t,this.height=e,this.view.width=t,this.view.height=e},r.CanvasRenderer.prototype.renderDisplayObject=function(t,e){this.renderSession.context=e||this.context,t._renderCanvas(this.renderSession)},r.CanvasRenderer.prototype.renderStripFlat=function(t){var e=this.context,i=t.verticies,r=i.length/2;this.count++,e.beginPath();for(var n=1;r-2>n;n++){var o=2*n,s=i[o],a=i[o+2],h=i[o+4],l=i[o+1],u=i[o+3],c=i[o+5];e.moveTo(s,l),e.lineTo(a,u),e.lineTo(h,c)}e.fillStyle="#FF0000",e.fill(),e.closePath()},r.CanvasRenderer.prototype.renderStrip=function(t){var e=this.context,i=t.verticies,r=t.uvs,n=i.length/2;this.count++;for(var o=1;n-2>o;o++){var s=2*o,a=i[s],h=i[s+2],l=i[s+4],u=i[s+1],c=i[s+3],d=i[s+5],f=r[s]*t.texture.width,p=r[s+2]*t.texture.width,g=r[s+4]*t.texture.width,v=r[s+1]*t.texture.height,m=r[s+3]*t.texture.height,x=r[s+5]*t.texture.height;e.save(),e.beginPath(),e.moveTo(a,u),e.lineTo(h,c),e.lineTo(l,d),e.closePath(),e.clip();var y=f*m+v*g+p*x-m*g-v*p-f*x,b=a*m+v*l+h*x-m*l-v*h-a*x,T=f*h+a*g+p*l-h*g-a*p-f*l,S=f*m*l+v*h*g+a*p*x-a*m*g-v*p*l-f*h*x,_=u*m+v*d+c*x-m*d-v*c-u*x,w=f*c+u*g+p*d-c*g-u*p-f*d,E=f*m*d+v*c*g+u*p*x-u*m*g-v*p*d-f*c*x;e.transform(b/y,_/y,T/y,w/y,S/y,E/y),e.drawImage(t.texture.baseTexture.source,0,0),e.restore()}},r.CanvasBuffer=function(t,e){this.width=t,this.height=e,this.canvas=document.createElement("canvas"),this.context=this.canvas.getContext("2d"),this.canvas.width=t,this.canvas.height=e},r.CanvasBuffer.prototype.clear=function(){this.context.clearRect(0,0,this.width,this.height)},r.CanvasBuffer.prototype.resize=function(t,e){this.width=this.canvas.width=t,this.height=this.canvas.height=e},r.CanvasGraphics=function(){},r.CanvasGraphics.renderGraphics=function(t,e){for(var i=t.worldAlpha,n=0;n<t.graphicsData.length;n++){var o=t.graphicsData[n],s=o.points;if(e.strokeStyle="#"+("00000"+(0|o.lineColor).toString(16)).substr(-6),e.lineWidth=o.lineWidth,o.type===r.Graphics.POLY){e.beginPath(),e.moveTo(s[0],s[1]);for(var a=1;a<s.length/2;a++)e.lineTo(s[2*a],s[2*a+1]);s[0]===s[s.length-2]&&s[1]===s[s.length-1]&&e.closePath(),o.fill&&(e.globalAlpha=o.fillAlpha*i,e.fillStyle="#"+("00000"+(0|o.fillColor).toString(16)).substr(-6),e.fill()),o.lineWidth&&(e.globalAlpha=o.lineAlpha*i,e.stroke())}else if(o.type===r.Graphics.RECT)(o.fillColor||0===o.fillColor)&&(e.globalAlpha=o.fillAlpha*i,e.fillStyle="#"+("00000"+(0|o.fillColor).toString(16)).substr(-6),e.fillRect(s[0],s[1],s[2],s[3])),o.lineWidth&&(e.globalAlpha=o.lineAlpha*i,e.strokeRect(s[0],s[1],s[2],s[3]));else if(o.type===r.Graphics.CIRC)e.beginPath(),e.arc(s[0],s[1],s[2],0,2*Math.PI),e.closePath(),o.fill&&(e.globalAlpha=o.fillAlpha*i,e.fillStyle="#"+("00000"+(0|o.fillColor).toString(16)).substr(-6),e.fill()),o.lineWidth&&(e.globalAlpha=o.lineAlpha*i,e.stroke());else if(o.type===r.Graphics.ELIP){var h=o.points,l=2*h[2],u=2*h[3],c=h[0]-l/2,d=h[1]-u/2;e.beginPath();var f=.5522848,p=l/2*f,g=u/2*f,v=c+l,m=d+u,x=c+l/2,y=d+u/2;e.moveTo(c,y),e.bezierCurveTo(c,y-g,x-p,d,x,d),e.bezierCurveTo(x+p,d,v,y-g,v,y),e.bezierCurveTo(v,y+g,x+p,m,x,m),e.bezierCurveTo(x-p,m,c,y+g,c,y),e.closePath(),o.fill&&(e.globalAlpha=o.fillAlpha*i,e.fillStyle="#"+("00000"+(0|o.fillColor).toString(16)).substr(-6),e.fill()),o.lineWidth&&(e.globalAlpha=o.lineAlpha*i,e.stroke())}else if(o.type===r.Graphics.RREC){var b=s[0],T=s[1],S=s[2],_=s[3],w=s[4],E=Math.min(S,_)/2|0;w=w>E?E:w,e.beginPath(),e.moveTo(b,T+w),e.lineTo(b,T+_-w),e.quadraticCurveTo(b,T+_,b+w,T+_),e.lineTo(b+S-w,T+_),e.quadraticCurveTo(b+S,T+_,b+S,T+_-w),e.lineTo(b+S,T+w),e.quadraticCurveTo(b+S,T,b+S-w,T),e.lineTo(b+w,T),e.quadraticCurveTo(b,T,b,T+w),e.closePath(),(o.fillColor||0===o.fillColor)&&(e.globalAlpha=o.fillAlpha*i,e.fillStyle="#"+("00000"+(0|o.fillColor).toString(16)).substr(-6),e.fill()),o.lineWidth&&(e.globalAlpha=o.lineAlpha*i,e.stroke())}}},r.CanvasGraphics.renderGraphicsMask=function(t,e){var i=t.graphicsData.length;if(0!==i){i>1&&(i=1,window.console.log("Pixi.js warning: masks in canvas can only mask using the first path in the graphics object"));for(var n=0;1>n;n++){var o=t.graphicsData[n],s=o.points;if(o.type===r.Graphics.POLY){e.beginPath(),e.moveTo(s[0],s[1]);for(var a=1;a<s.length/2;a++)e.lineTo(s[2*a],s[2*a+1]);s[0]===s[s.length-2]&&s[1]===s[s.length-1]&&e.closePath()}else if(o.type===r.Graphics.RECT)e.beginPath(),e.rect(s[0],s[1],s[2],s[3]),e.closePath();else if(o.type===r.Graphics.CIRC)e.beginPath(),e.arc(s[0],s[1],s[2],0,2*Math.PI),e.closePath();else if(o.type===r.Graphics.ELIP){var h=o.points,l=2*h[2],u=2*h[3],c=h[0]-l/2,d=h[1]-u/2;e.beginPath();var f=.5522848,p=l/2*f,g=u/2*f,v=c+l,m=d+u,x=c+l/2,y=d+u/2;e.moveTo(c,y),e.bezierCurveTo(c,y-g,x-p,d,x,d),e.bezierCurveTo(x+p,d,v,y-g,v,y),e.bezierCurveTo(v,y+g,x+p,m,x,m),e.bezierCurveTo(x-p,m,c,y+g,c,y),e.closePath()}else if(o.type===r.Graphics.RREC){var b=s[0],T=s[1],S=s[2],_=s[3],w=s[4],E=Math.min(S,_)/2|0;w=w>E?E:w,e.beginPath(),e.moveTo(b,T+w),e.lineTo(b,T+_-w),e.quadraticCurveTo(b,T+_,b+w,T+_),e.lineTo(b+S-w,T+_),e.quadraticCurveTo(b+S,T+_,b+S,T+_-w),e.lineTo(b+S,T+w),e.quadraticCurveTo(b+S,T,b+S-w,T),e.lineTo(b+w,T),e.quadraticCurveTo(b,T,b,T+w),e.closePath()}}}},r.Graphics=function(){r.DisplayObjectContainer.call(this),this.renderable=!0,this.fillAlpha=1,this.lineWidth=0,this.lineColor="black",this.graphicsData=[],this.tint=16777215,this.blendMode=r.blendModes.NORMAL,this.currentPath={points:[]},this._webGL=[],this.isMask=!1,this.bounds=null,this.boundsPadding=10,this.dirty=!0},r.Graphics.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Graphics.prototype.constructor=r.Graphics,Object.defineProperty(r.Graphics.prototype,"cacheAsBitmap",{get:function(){return this._cacheAsBitmap},set:function(t){this._cacheAsBitmap=t,this._cacheAsBitmap?this._generateCachedSprite():(this.destroyCachedSprite(),this.dirty=!0)}}),r.Graphics.prototype.lineStyle=function(t,e,i){return this.currentPath.points.length||this.graphicsData.pop(),this.lineWidth=t||0,this.lineColor=e||0,this.lineAlpha=arguments.length<3?1:i,this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:r.Graphics.POLY},this.graphicsData.push(this.currentPath),this},r.Graphics.prototype.moveTo=function(t,e){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:r.Graphics.POLY},this.currentPath.points.push(t,e),this.graphicsData.push(this.currentPath),this},r.Graphics.prototype.lineTo=function(t,e){return this.currentPath.points.push(t,e),this.dirty=!0,this},r.Graphics.prototype.quadraticCurveTo=function(t,e,i,r){0===this.currentPath.points.length&&this.moveTo(0,0);var n,o,s=this.currentPath.points;0===s.length&&this.moveTo(0,0);for(var a=s[s.length-2],h=s[s.length-1],l=0,u=1;20>=u;u++)l=u/20,n=a+(t-a)*l,o=h+(e-h)*l,s.push(n+(t+(i-t)*l-n)*l,o+(e+(r-e)*l-o)*l);return this.dirty=!0,this},r.Graphics.prototype.bezierCurveTo=function(t,e,i,r,n,o){0===this.currentPath.points.length&&this.moveTo(0,0);for(var s,a,h,l,u,c=this.currentPath.points,d=c[c.length-2],f=c[c.length-1],p=0,g=1;20>g;g++)p=g/20,s=1-p,a=s*s,h=a*s,l=p*p,u=l*p,c.push(h*d+3*a*p*t+3*s*l*i+u*n,h*f+3*a*p*e+3*s*l*r+u*o);return this.dirty=!0,this},r.Graphics.prototype.arcTo=function(t,e,i,r,n){0===this.currentPath.points.length&&this.moveTo(t,e);var o=this.currentPath.points,s=o[o.length-2],a=o[o.length-1],h=a-e,l=s-t,u=r-e,c=i-t,d=Math.abs(h*c-l*u);if(1e-8>d||0===n)o.push(t,e);else{var f=h*h+l*l,p=u*u+c*c,g=h*u+l*c,v=n*Math.sqrt(f)/d,m=n*Math.sqrt(p)/d,x=v*g/f,y=m*g/p,b=v*c+m*l,T=v*u+m*h,S=l*(m+x),_=h*(m+x),w=c*(v+y),E=u*(v+y),C=Math.atan2(_-T,S-b),A=Math.atan2(E-T,w-b);this.arc(b+t,T+e,n,C,A,l*u>c*h)}return this.dirty=!0,this},r.Graphics.prototype.arc=function(t,e,i,r,n,o){var s=t+Math.cos(r)*i,a=e+Math.sin(r)*i,h=this.currentPath.points;if((0!==h.length&&h[h.length-2]!==s||h[h.length-1]!==a)&&(this.moveTo(s,a),h=this.currentPath.points),r===n)return this;!o&&r>=n?n+=2*Math.PI:o&&n>=r&&(r+=2*Math.PI);var l=o?-1*(r-n):n-r,u=Math.abs(l)/(2*Math.PI)*40;if(0===l)return this;for(var c=l/(2*u),d=2*c,f=Math.cos(c),p=Math.sin(c),g=u-1,v=g%1/g,m=0;g>=m;m++){var x=m+v*m,y=c+r+d*x,b=Math.cos(y),T=-Math.sin(y);h.push((f*b+p*T)*i+t,(f*-T+p*b)*i+e)}return this.dirty=!0,this},r.Graphics.prototype.drawPath=function(t){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath=this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[],type:r.Graphics.POLY},this.graphicsData.push(this.currentPath),this.currentPath.points=this.currentPath.points.concat(t),this.dirty=!0,this},r.Graphics.prototype.beginFill=function(t,e){return this.filling=!0,this.fillColor=t||0,this.fillAlpha=arguments.length<2?1:e,this},r.Graphics.prototype.endFill=function(){return this.filling=!1,this.fillColor=null,this.fillAlpha=1,this},r.Graphics.prototype.drawRect=function(t,e,i,n){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[t,e,i,n],type:r.Graphics.RECT},this.graphicsData.push(this.currentPath),this.dirty=!0,this},r.Graphics.prototype.drawRoundedRect=function(t,e,i,n,o){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[t,e,i,n,o],type:r.Graphics.RREC},this.graphicsData.push(this.currentPath),this.dirty=!0,this},r.Graphics.prototype.drawCircle=function(t,e,i){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[t,e,i,i],type:r.Graphics.CIRC},this.graphicsData.push(this.currentPath),this.dirty=!0,this},r.Graphics.prototype.drawEllipse=function(t,e,i,n){return this.currentPath.points.length||this.graphicsData.pop(),this.currentPath={lineWidth:this.lineWidth,lineColor:this.lineColor,lineAlpha:this.lineAlpha,fillColor:this.fillColor,fillAlpha:this.fillAlpha,fill:this.filling,points:[t,e,i,n],type:r.Graphics.ELIP},this.graphicsData.push(this.currentPath),this.dirty=!0,this},r.Graphics.prototype.clear=function(){return this.lineWidth=0,this.filling=!1,this.dirty=!0,this.clearDirty=!0,this.graphicsData=[],this.bounds=null,this},r.Graphics.prototype.generateTexture=function(){var t=this.getBounds(),e=new r.CanvasBuffer(t.width,t.height),i=r.Texture.fromCanvas(e.canvas);return e.context.translate(-t.x,-t.y),r.CanvasGraphics.renderGraphics(this,e.context),i},r.Graphics.prototype._renderWebGL=function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){if(this._cacheAsBitmap)return this.dirty&&(this._generateCachedSprite(),r.updateWebGLTexture(this._cachedSprite.texture.baseTexture,t.gl),this.dirty=!1),this._cachedSprite.alpha=this.alpha,void r.Sprite.prototype._renderWebGL.call(this._cachedSprite,t);if(t.spriteBatch.stop(),t.blendModeManager.setBlendMode(this.blendMode),this._mask&&t.maskManager.pushMask(this._mask,t),this._filters&&t.filterManager.pushFilter(this._filterBlock),this.blendMode!==t.spriteBatch.currentBlendMode){t.spriteBatch.currentBlendMode=this.blendMode;var e=r.blendModesWebGL[t.spriteBatch.currentBlendMode];t.spriteBatch.gl.blendFunc(e[0],e[1])}if(r.WebGLGraphics.renderGraphics(this,t),this.children.length){t.spriteBatch.start();for(var i=0,n=this.children.length;n>i;i++)this.children[i]._renderWebGL(t);t.spriteBatch.stop()}this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(this.mask,t),t.drawCount++,t.spriteBatch.start()}},r.Graphics.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha&&!0!==this.isMask){var e=t.context,i=this.worldTransform;this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=r.blendModesCanvas[t.currentBlendMode]),this._mask&&t.maskManager.pushMask(this._mask,t.context),e.setTransform(i.a,i.c,i.b,i.d,i.tx,i.ty),r.CanvasGraphics.renderGraphics(this,e);for(var n=0,o=this.children.length;o>n;n++)this.children[n]._renderCanvas(t);this._mask&&t.maskManager.popMask(t.context)}},r.Graphics.prototype.getBounds=function(t){this.bounds||this.updateBounds();var e=this.bounds.x,i=this.bounds.width+this.bounds.x,r=this.bounds.y,n=this.bounds.height+this.bounds.y,o=t||this.worldTransform,s=o.a,a=o.c,h=o.b,l=o.d,u=o.tx,c=o.ty,d=s*i+h*n+u,f=l*n+a*i+c,p=s*e+h*n+u,g=l*n+a*e+c,v=s*e+h*r+u,m=l*r+a*e+c,x=s*i+h*r+u,y=l*r+a*i+c,b=d,T=f,S=d,_=f;S=S>p?p:S,S=S>v?v:S,S=S>x?x:S,_=_>g?g:_,_=_>m?m:_,_=_>y?y:_,b=p>b?p:b,b=v>b?v:b,b=x>b?x:b,T=g>T?g:T,T=m>T?m:T,T=y>T?y:T;var w=this._bounds;return w.x=S,w.width=b-S,w.y=_,w.height=T-_,w},r.Graphics.prototype.updateBounds=function(){for(var t,e,i,n,o,s=1/0,a=-1/0,h=1/0,l=-1/0,u=0;u<this.graphicsData.length;u++){var c=this.graphicsData[u],d=c.type,f=c.lineWidth;if(t=c.points,d===r.Graphics.RECT)e=t[0]-f/2,i=t[1]-f/2,n=t[2]+f,o=t[3]+f,s=s>e?e:s,a=e+n>a?e+n:a,h=h>i?e:h,l=i+o>l?i+o:l;else if(d===r.Graphics.CIRC||d===r.Graphics.ELIP)e=t[0],i=t[1],n=t[2]+f/2,o=t[3]+f/2,s=s>e-n?e-n:s,a=e+n>a?e+n:a,h=h>i-o?i-o:h,l=i+o>l?i+o:l;else for(var p=0;p<t.length;p+=2)e=t[p],i=t[p+1],s=s>e-f?e-f:s,a=e+f>a?e+f:a,h=h>i-f?i-f:h,l=i+f>l?i+f:l}var g=this.boundsPadding;this.bounds=new r.Rectangle(s-g,h-g,a-s+2*g,l-h+2*g)},r.Graphics.prototype._generateCachedSprite=function(){var t=this.getLocalBounds();if(this._cachedSprite)this._cachedSprite.buffer.resize(t.width,t.height);else{var e=new r.CanvasBuffer(t.width,t.height),i=r.Texture.fromCanvas(e.canvas);this._cachedSprite=new r.Sprite(i),this._cachedSprite.buffer=e,this._cachedSprite.worldTransform=this.worldTransform}this._cachedSprite.anchor.x=-t.x/t.width,this._cachedSprite.anchor.y=-t.y/t.height,this._cachedSprite.buffer.context.translate(-t.x,-t.y),r.CanvasGraphics.renderGraphics(this,this._cachedSprite.buffer.context),this._cachedSprite.alpha=this.alpha},r.Graphics.prototype.destroyCachedSprite=function(){this._cachedSprite.texture.destroy(!0),this._cachedSprite=null},r.Graphics.POLY=0,r.Graphics.RECT=1,r.Graphics.CIRC=2,r.Graphics.ELIP=3,r.Graphics.RREC=4,r.Strip=function(t){r.DisplayObjectContainer.call(this),this.texture=t,this.uvs=new r.Float32Array([0,1,1,1,1,0,0,1]),this.verticies=new r.Float32Array([0,0,100,0,100,100,0,100]),this.colors=new r.Float32Array([1,1,1,1]),this.indices=new r.Uint16Array([0,1,2,3]),this.dirty=!0},r.Strip.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Strip.prototype.constructor=r.Strip,r.Strip.prototype._renderWebGL=function(t){!this.visible||this.alpha<=0||(t.spriteBatch.stop(),this._vertexBuffer||this._initWebGL(t),t.shaderManager.setShader(t.shaderManager.stripShader),this._renderStrip(t),t.spriteBatch.start())},r.Strip.prototype._initWebGL=function(t){var e=t.gl;this._vertexBuffer=e.createBuffer(),this._indexBuffer=e.createBuffer(),this._uvBuffer=e.createBuffer(),this._colorBuffer=e.createBuffer(),e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.verticies,e.DYNAMIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.bindBuffer(e.ARRAY_BUFFER,this._colorBuffer),e.bufferData(e.ARRAY_BUFFER,this.colors,e.STATIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)},r.Strip.prototype._renderStrip=function(t){var e=t.gl,i=t.projection,n=t.offset,o=t.shaderManager.stripShader;e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA),e.uniformMatrix3fv(o.translationMatrix,!1,this.worldTransform.toArray(!0)),e.uniform2f(o.projectionVector,i.x,-i.y),e.uniform2f(o.offsetVector,-n.x,-n.y),e.uniform1f(o.alpha,1),this.dirty?(this.dirty=!1,e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferData(e.ARRAY_BUFFER,this.verticies,e.STATIC_DRAW),e.vertexAttribPointer(o.aVertexPosition,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.bufferData(e.ARRAY_BUFFER,this.uvs,e.STATIC_DRAW),e.vertexAttribPointer(o.aTextureCoord,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.texture.baseTexture._glTextures[e.id]||r.createWebGLTexture(this.texture.baseTexture,e)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,this.indices,e.STATIC_DRAW)):(e.bindBuffer(e.ARRAY_BUFFER,this._vertexBuffer),e.bufferSubData(e.ARRAY_BUFFER,0,this.verticies),e.vertexAttribPointer(o.aVertexPosition,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this._uvBuffer),e.vertexAttribPointer(o.aTextureCoord,2,e.FLOAT,!1,0,0),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,this.texture.baseTexture._glTextures[e.id]||r.createWebGLTexture(this.texture.baseTexture,e)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,this._indexBuffer)),e.drawElements(e.TRIANGLE_STRIP,this.indices.length,e.UNSIGNED_SHORT,0)},r.Strip.prototype._renderCanvas=function(t){var e=t.context,i=this.worldTransform;t.roundPixels?e.setTransform(i.a,i.c,i.b,i.d,0|i.tx,0|i.ty):e.setTransform(i.a,i.c,i.b,i.d,i.tx,i.ty);var r=this,n=r.verticies,o=r.uvs,s=n.length/2;this.count++;for(var a=0;s-2>a;a++){var h=2*a,l=n[h],u=n[h+2],c=n[h+4],d=n[h+1],f=n[h+3],p=n[h+5],g=(l+u+c)/3,v=(d+f+p)/3,m=l-g,x=d-v,y=Math.sqrt(m*m+x*x);l=g+m/y*(y+3),d=v+x/y*(y+3),m=u-g,x=f-v,y=Math.sqrt(m*m+x*x),u=g+m/y*(y+3),f=v+x/y*(y+3),m=c-g,x=p-v,y=Math.sqrt(m*m+x*x),c=g+m/y*(y+3),p=v+x/y*(y+3);var b=o[h]*r.texture.width,T=o[h+2]*r.texture.width,S=o[h+4]*r.texture.width,_=o[h+1]*r.texture.height,w=o[h+3]*r.texture.height,E=o[h+5]*r.texture.height;e.save(),e.beginPath(),e.moveTo(l,d),e.lineTo(u,f),e.lineTo(c,p),e.closePath(),e.clip();var C=b*w+_*S+T*E-w*S-_*T-b*E,A=l*w+_*c+u*E-w*c-_*u-l*E,R=b*u+l*S+T*c-u*S-l*T-b*c,M=b*w*c+_*u*S+l*T*E-l*w*S-_*T*c-b*u*E,L=d*w+_*p+f*E-w*p-_*f-d*E,F=b*f+d*S+T*p-f*S-d*T-b*p,B=b*w*p+_*f*S+d*T*E-d*w*S-_*T*p-b*f*E;e.transform(A/C,L/C,R/C,F/C,M/C,B/C),e.drawImage(r.texture.baseTexture.source,0,0),e.restore()}},r.Strip.prototype.onTextureUpdate=function(){this.updateFrame=!0},r.Rope=function(t,e){r.Strip.call(this,t),this.points=e,this.verticies=new r.Float32Array(4*e.length),this.uvs=new r.Float32Array(4*e.length),this.colors=new r.Float32Array(2*e.length),this.indices=new r.Uint16Array(2*e.length),this.refresh()},r.Rope.prototype=Object.create(r.Strip.prototype),r.Rope.prototype.constructor=r.Rope,r.Rope.prototype.refresh=function(){var t=this.points;if(!(t.length<1)){var e=this.uvs,i=(t[0],this.indices),r=this.colors;this.count-=.2,e[0]=0,e[1]=0,e[2]=0,e[3]=1,r[0]=1,r[1]=1,i[0]=0,i[1]=1;for(var n,o,s,a=t.length,h=1;a>h;h++)n=t[h],o=4*h,s=h/(a-1),e[o]=s,e[o+1]=0,e[o+2]=s,e[o+3]=1,o=2*h,r[o]=1,r[o+1]=1,o=2*h,i[o]=o,i[o+1]=o+1,n}},r.Rope.prototype.updateTransform=function(){var t=this.points;if(!(t.length<1)){var e,i=t[0],n={x:0,y:0};this.count-=.2;for(var o,s,a,h,l,u=this.verticies,c=t.length,d=0;c>d;d++)o=t[d],s=4*d,e=d<t.length-1?t[d+1]:o,n.y=-(e.x-i.x),n.x=e.y-i.y,a=10*(1-d/(c-1)),a>1&&(a=1),h=Math.sqrt(n.x*n.x+n.y*n.y),l=this.texture.height/2,n.x/=h,n.y/=h,n.x*=l,n.y*=l,u[s]=o.x+n.x,u[s+1]=o.y+n.y,u[s+2]=o.x-n.x,u[s+3]=o.y-n.y,i=o;r.DisplayObjectContainer.prototype.updateTransform.call(this)}},r.Rope.prototype.setTexture=function(t){this.texture=t},r.TilingSprite=function(t,e,i){r.Sprite.call(this,t),this._width=e||100,this._height=i||100,this.tileScale=new r.Point(1,1),this.tileScaleOffset=new r.Point(1,1),this.tilePosition=new r.Point(0,0),this.renderable=!0,this.tint=16777215,this.blendMode=r.blendModes.NORMAL},r.TilingSprite.prototype=Object.create(r.Sprite.prototype),r.TilingSprite.prototype.constructor=r.TilingSprite,Object.defineProperty(r.TilingSprite.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t}}),Object.defineProperty(r.TilingSprite.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t}}),r.TilingSprite.prototype.setTexture=function(t){this.texture!==t&&(this.texture=t,this.refreshTexture=!0,this.cachedTint=16777215)},r.TilingSprite.prototype._renderWebGL=function(t){if(!1!==this.visible&&0!==this.alpha){var e,i;for(this._mask&&(t.spriteBatch.stop(),t.maskManager.pushMask(this.mask,t),t.spriteBatch.start()),this._filters&&(t.spriteBatch.flush(),t.filterManager.pushFilter(this._filterBlock)),!this.tilingTexture||this.refreshTexture?(this.generateTilingTexture(!0),this.tilingTexture&&this.tilingTexture.needsUpdate&&(r.updateWebGLTexture(this.tilingTexture.baseTexture,t.gl),this.tilingTexture.needsUpdate=!1)):t.spriteBatch.renderTilingSprite(this),e=0,i=this.children.length;i>e;e++)this.children[e]._renderWebGL(t);t.spriteBatch.stop(),this._filters&&t.filterManager.popFilter(),this._mask&&t.maskManager.popMask(t),t.spriteBatch.start()}},r.TilingSprite.prototype._renderCanvas=function(t){if(!1!==this.visible&&0!==this.alpha){var e=t.context;this._mask&&t.maskManager.pushMask(this._mask,e),e.globalAlpha=this.worldAlpha;var i,n,o=this.worldTransform;if(e.setTransform(o.a,o.c,o.b,o.d,o.tx,o.ty),!this.__tilePattern||this.refreshTexture){if(this.generateTilingTexture(!1),!this.tilingTexture)return;this.__tilePattern=e.createPattern(this.tilingTexture.baseTexture.source,"repeat")}this.blendMode!==t.currentBlendMode&&(t.currentBlendMode=this.blendMode,e.globalCompositeOperation=r.blendModesCanvas[t.currentBlendMode]);var s=this.tilePosition,a=this.tileScale;for(s.x%=this.tilingTexture.baseTexture.width,s.y%=this.tilingTexture.baseTexture.height,e.scale(a.x,a.y),e.translate(s.x,s.y),e.fillStyle=this.__tilePattern,e.fillRect(-s.x+this.anchor.x*-this._width,-s.y+this.anchor.y*-this._height,this._width/a.x,this._height/a.y),e.scale(1/a.x,1/a.y),e.translate(-s.x,-s.y),this._mask&&t.maskManager.popMask(t.context),i=0,n=this.children.length;n>i;i++)this.children[i]._renderCanvas(t)}},r.TilingSprite.prototype.getBounds=function(){var t=this._width,e=this._height,i=t*(1-this.anchor.x),r=t*-this.anchor.x,n=e*(1-this.anchor.y),o=e*-this.anchor.y,s=this.worldTransform,a=s.a,h=s.c,l=s.b,u=s.d,c=s.tx,d=s.ty,f=a*r+l*o+c,p=u*o+h*r+d,g=a*i+l*o+c,v=u*o+h*i+d,m=a*i+l*n+c,x=u*n+h*i+d,y=a*r+l*n+c,b=u*n+h*r+d,T=-1/0,S=-1/0,_=1/0,w=1/0;_=_>f?f:_,_=_>g?g:_,_=_>m?m:_,_=_>y?y:_,w=w>p?p:w,w=w>v?v:w,w=w>x?x:w,w=w>b?b:w,T=f>T?f:T,T=g>T?g:T,T=m>T?m:T,T=y>T?y:T,S=p>S?p:S,S=v>S?v:S,S=x>S?x:S,S=b>S?b:S;var E=this._bounds;return E.x=_,E.width=T-_,E.y=w,E.height=S-w,this._currentBounds=E,E},r.TilingSprite.prototype.onTextureUpdate=function(){},r.TilingSprite.prototype.generateTilingTexture=function(t){if(this.texture.baseTexture.hasLoaded){var e,i,n=this.texture,o=n.frame,s=o.width!==n.baseTexture.width||o.height!==n.baseTexture.height,a=!1;if(t?(e=r.getNextPowerOfTwo(o.width),i=r.getNextPowerOfTwo(o.height),(o.width!==e||o.height!==i)&&(a=!0)):s&&(e=o.width,i=o.height,a=!0),a){var h;this.tilingTexture&&this.tilingTexture.isTiling?(h=this.tilingTexture.canvasBuffer,h.resize(e,i),this.tilingTexture.baseTexture.width=e,this.tilingTexture.baseTexture.height=i,this.tilingTexture.needsUpdate=!0):(h=new r.CanvasBuffer(e,i),this.tilingTexture=r.Texture.fromCanvas(h.canvas),this.tilingTexture.canvasBuffer=h,this.tilingTexture.isTiling=!0),h.context.drawImage(n.baseTexture.source,n.crop.x,n.crop.y,n.crop.width,n.crop.height,0,0,e,i),this.tileScaleOffset.x=o.width/e,this.tileScaleOffset.y=o.height/i}else this.tilingTexture&&this.tilingTexture.isTiling&&this.tilingTexture.destroy(!0),this.tileScaleOffset.x=1,this.tileScaleOffset.y=1,this.tilingTexture=n;this.refreshTexture=!1,this.tilingTexture.baseTexture._powerOf2=!0}};var a={};a.BoneData=function(t,e){this.name=t,this.parent=e},a.BoneData.prototype={length:0,x:0,y:0,rotation:0,scaleX:1,scaleY:1},a.SlotData=function(t,e){this.name=t,this.boneData=e},a.SlotData.prototype={r:1,g:1,b:1,a:1,attachmentName:null},a.Bone=function(t,e){this.data=t,this.parent=e,this.setToSetupPose()},a.Bone.yDown=!1,a.Bone.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,m00:0,m01:0,worldX:0,m10:0,m11:0,worldY:0,worldRotation:0,worldScaleX:1,worldScaleY:1,updateWorldTransform:function(t,e){var i=this.parent;null!=i?(this.worldX=this.x*i.m00+this.y*i.m01+i.worldX,this.worldY=this.x*i.m10+this.y*i.m11+i.worldY,this.worldScaleX=i.worldScaleX*this.scaleX,this.worldScaleY=i.worldScaleY*this.scaleY,this.worldRotation=i.worldRotation+this.rotation):(this.worldX=this.x,this.worldY=this.y,this.worldScaleX=this.scaleX,this.worldScaleY=this.scaleY,this.worldRotation=this.rotation);var r=this.worldRotation*Math.PI/180,n=Math.cos(r),o=Math.sin(r);this.m00=n*this.worldScaleX,this.m10=o*this.worldScaleX,this.m01=-o*this.worldScaleY,this.m11=n*this.worldScaleY,t&&(this.m00=-this.m00,this.m01=-this.m01),e&&(this.m10=-this.m10,this.m11=-this.m11),a.Bone.yDown&&(this.m10=-this.m10,this.m11=-this.m11)},setToSetupPose:function(){var t=this.data;this.x=t.x,this.y=t.y,this.rotation=t.rotation,this.scaleX=t.scaleX,this.scaleY=t.scaleY}},a.Slot=function(t,e,i){this.data=t,this.skeleton=e,this.bone=i,this.setToSetupPose()},a.Slot.prototype={r:1,g:1,b:1,a:1,_attachmentTime:0,attachment:null,setAttachment:function(t){this.attachment=t,this._attachmentTime=this.skeleton.time},setAttachmentTime:function(t){this._attachmentTime=this.skeleton.time-t},getAttachmentTime:function(){return this.skeleton.time-this._attachmentTime},setToSetupPose:function(){var t=this.data;this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a;for(var e=this.skeleton.data.slots,i=0,r=e.length;r>i;i++)if(e[i]==t){this.setAttachment(t.attachmentName?this.skeleton.getAttachmentBySlotIndex(i,t.attachmentName):null);break}}},a.Skin=function(t){this.name=t,this.attachments={}},a.Skin.prototype={addAttachment:function(t,e,i){this.attachments[t+":"+e]=i},getAttachment:function(t,e){return this.attachments[t+":"+e]},_attachAll:function(t,e){for(var i in e.attachments){var r=i.indexOf(":"),n=parseInt(i.substring(0,r),10),o=i.substring(r+1),s=t.slots[n];if(s.attachment&&s.attachment.name==o){var a=this.getAttachment(n,o);a&&s.setAttachment(a)}}}},a.Animation=function(t,e,i){this.name=t,this.timelines=e,this.duration=i},a.Animation.prototype={apply:function(t,e,i){i&&this.duration&&(e%=this.duration);for(var r=this.timelines,n=0,o=r.length;o>n;n++)r[n].apply(t,e,1)},mix:function(t,e,i,r){i&&this.duration&&(e%=this.duration);for(var n=this.timelines,o=0,s=n.length;s>o;o++)n[o].apply(t,e,r)}},a.binarySearch=function(t,e,i){var r=0,n=Math.floor(t.length/i)-2;if(!n)return i;for(var o=n>>>1;;){if(t[(o+1)*i]<=e?r=o+1:n=o,r==n)return(r+1)*i;o=r+n>>>1}},a.linearSearch=function(t,e,i){for(var r=0,n=t.length-i;n>=r;r+=i)if(t[r]>e)return r;return-1},a.Curves=function(t){this.curves=[],this.curves.length=6*(t-1)},a.Curves.prototype={setLinear:function(t){this.curves[6*t]=0},setStepped:function(t){this.curves[6*t]=-1},setCurve:function(t,e,i,r,n){var o=.1*.1,s=.1*o,a=3*o,h=6*o,l=6*s,u=2*-e+r,c=2*-i+n,d=3*(e-r)+1,f=3*(i-n)+1,p=6*t,g=this.curves;g[p]=e*(3*.1)+u*a+d*s,g[p+1]=i*(3*.1)+c*a+f*s,g[p+2]=u*h+d*l,g[p+3]=c*h+f*l,g[p+4]=d*l,g[p+5]=f*l},getCurvePercent:function(t,e){e=0>e?0:e>1?1:e;var i=6*t,r=this.curves,n=r[i];if(!n)return e;if(-1==n)return 0;for(var o=r[i+1],s=r[i+2],a=r[i+3],h=r[i+4],l=r[i+5],u=n,c=o,d=8;;){if(u>=e){var f=u-n,p=c-o;return p+(c-p)*(e-f)/(u-f)}if(!d)break;d--,n+=s,o+=a,s+=h,a+=l,u+=n,c+=o}return c+(1-c)*(e-u)/(1-u)}},a.RotateTimeline=function(t){this.curves=new a.Curves(t),this.frames=[],this.frames.length=2*t},a.RotateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/2},setFrame:function(t,e,i){t*=2,this.frames[t]=e,this.frames[t+1]=i},apply:function(t,e,i){var r,n=this.frames;if(!(e<n[0])){var o=t.bones[this.boneIndex];if(e>=n[n.length-2]){for(r=o.data.rotation+n[n.length-1]-o.rotation;r>180;)r-=360;for(;-180>r;)r+=360;return void(o.rotation+=r*i)}var s=a.binarySearch(n,e,2),h=n[s-1],l=n[s],u=1-(e-l)/(n[s-2]-l);for(u=this.curves.getCurvePercent(s/2-1,u),r=n[s+1]-h;r>180;)r-=360;for(;-180>r;)r+=360;for(r=o.data.rotation+(h+r*u)-o.rotation;r>180;)r-=360;for(;-180>r;)r+=360;o.rotation+=r*i}}},a.TranslateTimeline=function(t){this.curves=new a.Curves(t),this.frames=[],this.frames.length=3*t},a.TranslateTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(t,e,i,r){t*=3,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r},apply:function(t,e,i){var r=this.frames;if(!(e<r[0])){var n=t.bones[this.boneIndex];if(e>=r[r.length-3])return n.x+=(n.data.x+r[r.length-2]-n.x)*i,void(n.y+=(n.data.y+r[r.length-1]-n.y)*i);var o=a.binarySearch(r,e,3),s=r[o-2],h=r[o-1],l=r[o],u=1-(e-l)/(r[o+-3]-l);u=this.curves.getCurvePercent(o/3-1,u),n.x+=(n.data.x+s+(r[o+1]-s)*u-n.x)*i,n.y+=(n.data.y+h+(r[o+2]-h)*u-n.y)*i}}},a.ScaleTimeline=function(t){this.curves=new a.Curves(t),this.frames=[],this.frames.length=3*t},a.ScaleTimeline.prototype={boneIndex:0,getFrameCount:function(){return this.frames.length/3},setFrame:function(t,e,i,r){t*=3,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r},apply:function(t,e,i){var r=this.frames;if(!(e<r[0])){var n=t.bones[this.boneIndex];if(e>=r[r.length-3])return n.scaleX+=(n.data.scaleX-1+r[r.length-2]-n.scaleX)*i,void(n.scaleY+=(n.data.scaleY-1+r[r.length-1]-n.scaleY)*i);var o=a.binarySearch(r,e,3),s=r[o-2],h=r[o-1],l=r[o],u=1-(e-l)/(r[o+-3]-l);u=this.curves.getCurvePercent(o/3-1,u),n.scaleX+=(n.data.scaleX-1+s+(r[o+1]-s)*u-n.scaleX)*i,n.scaleY+=(n.data.scaleY-1+h+(r[o+2]-h)*u-n.scaleY)*i}}},a.ColorTimeline=function(t){this.curves=new a.Curves(t),this.frames=[],this.frames.length=5*t},a.ColorTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length/5},setFrame:function(t,e,i,r,n,o){t*=5,this.frames[t]=e,this.frames[t+1]=i,this.frames[t+2]=r,this.frames[t+3]=n,this.frames[t+4]=o},apply:function(t,e,i){var r=this.frames;if(!(e<r[0])){var n=t.slots[this.slotIndex];if(e>=r[r.length-5]){var o=r.length-1;return n.r=r[o-3],n.g=r[o-2],n.b=r[o-1],void(n.a=r[o])}var s=a.binarySearch(r,e,5),h=r[s-4],l=r[s-3],u=r[s-2],c=r[s-1],d=r[s],f=1-(e-d)/(r[s-5]-d);f=this.curves.getCurvePercent(s/5-1,f);var p=h+(r[s+1]-h)*f,g=l+(r[s+2]-l)*f,v=u+(r[s+3]-u)*f,m=c+(r[s+4]-c)*f;1>i?(n.r+=(p-n.r)*i,n.g+=(g-n.g)*i,n.b+=(v-n.b)*i,n.a+=(m-n.a)*i):(n.r=p,n.g=g,n.b=v,n.a=m)}}},a.AttachmentTimeline=function(t){this.curves=new a.Curves(t),this.frames=[],this.frames.length=t,this.attachmentNames=[],this.attachmentNames.length=t},a.AttachmentTimeline.prototype={slotIndex:0,getFrameCount:function(){return this.frames.length},setFrame:function(t,e,i){this.frames[t]=e,this.attachmentNames[t]=i},apply:function(t,e){var i=this.frames;if(!(e<i[0])){var r;r=e>=i[i.length-1]?i.length-1:a.binarySearch(i,e,1)-1;var n=this.attachmentNames[r];t.slots[this.slotIndex].setAttachment(n?t.getAttachmentBySlotIndex(this.slotIndex,n):null)}}},a.SkeletonData=function(){this.bones=[],this.slots=[],this.skins=[],this.animations=[]},a.SkeletonData.prototype={defaultSkin:null,findBone:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},findBoneIndex:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].name==t)return i;return-1},findSlot:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].name==t)return slot[i];return null},findSlotIndex:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].name==t)return i
  ;return-1},findSkin:function(t){for(var e=this.skins,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},findAnimation:function(t){for(var e=this.animations,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null}},a.Skeleton=function(t){this.data=t,this.bones=[];for(var e=0,i=t.bones.length;i>e;e++){var r=t.bones[e],n=r.parent?this.bones[t.bones.indexOf(r.parent)]:null;this.bones.push(new a.Bone(r,n))}for(this.slots=[],this.drawOrder=[],e=0,i=t.slots.length;i>e;e++){var o=t.slots[e],s=this.bones[t.bones.indexOf(o.boneData)],h=new a.Slot(o,this,s);this.slots.push(h),this.drawOrder.push(h)}},a.Skeleton.prototype={x:0,y:0,skin:null,r:1,g:1,b:1,a:1,time:0,flipX:!1,flipY:!1,updateWorldTransform:function(){for(var t=this.flipX,e=this.flipY,i=this.bones,r=0,n=i.length;n>r;r++)i[r].updateWorldTransform(t,e)},setToSetupPose:function(){this.setBonesToSetupPose(),this.setSlotsToSetupPose()},setBonesToSetupPose:function(){for(var t=this.bones,e=0,i=t.length;i>e;e++)t[e].setToSetupPose()},setSlotsToSetupPose:function(){for(var t=this.slots,e=0,i=t.length;i>e;e++)t[e].setToSetupPose(e)},getRootBone:function(){return this.bones.length?this.bones[0]:null},findBone:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return e[i];return null},findBoneIndex:function(t){for(var e=this.bones,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return i;return-1},findSlot:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return e[i];return null},findSlotIndex:function(t){for(var e=this.slots,i=0,r=e.length;r>i;i++)if(e[i].data.name==t)return i;return-1},setSkinByName:function(t){var e=this.data.findSkin(t);if(!e)throw"Skin not found: "+t;this.setSkin(e)},setSkin:function(t){this.skin&&t&&t._attachAll(this,this.skin),this.skin=t},getAttachmentBySlotName:function(t,e){return this.getAttachmentBySlotIndex(this.data.findSlotIndex(t),e)},getAttachmentBySlotIndex:function(t,e){if(this.skin){var i=this.skin.getAttachment(t,e);if(i)return i}return this.data.defaultSkin?this.data.defaultSkin.getAttachment(t,e):null},setAttachment:function(t,e){for(var i=this.slots,r=0,n=i.size;n>r;r++){var o=i[r];if(o.data.name==t){var s=null;if(e&&null==(s=this.getAttachment(r,e)))throw"Attachment not found: "+e+", for slot: "+t;return void o.setAttachment(s)}}throw"Slot not found: "+t},update:function(t){time+=t}},a.AttachmentType={region:0},a.RegionAttachment=function(){this.offset=[],this.offset.length=8,this.uvs=[],this.uvs.length=8},a.RegionAttachment.prototype={x:0,y:0,rotation:0,scaleX:1,scaleY:1,width:0,height:0,rendererObject:null,regionOffsetX:0,regionOffsetY:0,regionWidth:0,regionHeight:0,regionOriginalWidth:0,regionOriginalHeight:0,setUVs:function(t,e,i,r,n){var o=this.uvs;n?(o[2]=t,o[3]=r,o[4]=t,o[5]=e,o[6]=i,o[7]=e,o[0]=i,o[1]=r):(o[0]=t,o[1]=r,o[2]=t,o[3]=e,o[4]=i,o[5]=e,o[6]=i,o[7]=r)},updateOffset:function(){var t=this.width/this.regionOriginalWidth*this.scaleX,e=this.height/this.regionOriginalHeight*this.scaleY,i=-this.width/2*this.scaleX+this.regionOffsetX*t,r=-this.height/2*this.scaleY+this.regionOffsetY*e,n=i+this.regionWidth*t,o=r+this.regionHeight*e,s=this.rotation*Math.PI/180,a=Math.cos(s),h=Math.sin(s),l=i*a+this.x,u=i*h,c=r*a+this.y,d=r*h,f=n*a+this.x,p=n*h,g=o*a+this.y,v=o*h,m=this.offset;m[0]=l-d,m[1]=c+u,m[2]=l-v,m[3]=g+u,m[4]=f-v,m[5]=g+p,m[6]=f-d,m[7]=c+p},computeVertices:function(t,e,i,r){t+=i.worldX,e+=i.worldY;var n=i.m00,o=i.m01,s=i.m10,a=i.m11,h=this.offset;r[0]=h[0]*n+h[1]*o+t,r[1]=h[0]*s+h[1]*a+e,r[2]=h[2]*n+h[3]*o+t,r[3]=h[2]*s+h[3]*a+e,r[4]=h[4]*n+h[5]*o+t,r[5]=h[4]*s+h[5]*a+e,r[6]=h[6]*n+h[7]*o+t,r[7]=h[6]*s+h[7]*a+e}},a.AnimationStateData=function(t){this.skeletonData=t,this.animationToMixTime={}},a.AnimationStateData.prototype={defaultMix:0,setMixByName:function(t,e,i){var r=this.skeletonData.findAnimation(t);if(!r)throw"Animation not found: "+t;var n=this.skeletonData.findAnimation(e);if(!n)throw"Animation not found: "+e;this.setMix(r,n,i)},setMix:function(t,e,i){this.animationToMixTime[t.name+":"+e.name]=i},getMix:function(t,e){var i=this.animationToMixTime[t.name+":"+e.name];return i||this.defaultMix}},a.AnimationState=function(t){this.data=t,this.queue=[]},a.AnimationState.prototype={animationSpeed:1,current:null,previous:null,currentTime:0,previousTime:0,currentLoop:!1,previousLoop:!1,mixTime:0,mixDuration:0,update:function(t){if(this.currentTime+=t*this.animationSpeed,this.previousTime+=t,this.mixTime+=t,this.queue.length>0){var e=this.queue[0];this.currentTime>=e.delay&&(this._setAnimation(e.animation,e.loop),this.queue.shift())}},apply:function(t){if(this.current)if(this.previous){this.previous.apply(t,this.previousTime,this.previousLoop);var e=this.mixTime/this.mixDuration;e>=1&&(e=1,this.previous=null),this.current.mix(t,this.currentTime,this.currentLoop,e)}else this.current.apply(t,this.currentTime,this.currentLoop)},clearAnimation:function(){this.previous=null,this.current=null,this.queue.length=0},_setAnimation:function(t,e){this.previous=null,t&&this.current&&(this.mixDuration=this.data.getMix(this.current,t),this.mixDuration>0&&(this.mixTime=0,this.previous=this.current,this.previousTime=this.currentTime,this.previousLoop=this.currentLoop)),this.current=t,this.currentLoop=e,this.currentTime=0},setAnimationByName:function(t,e){var i=this.data.skeletonData.findAnimation(t);if(!i)throw"Animation not found: "+t;this.setAnimation(i,e)},setAnimation:function(t,e){this.queue.length=0,this._setAnimation(t,e)},addAnimationByName:function(t,e,i){var r=this.data.skeletonData.findAnimation(t);if(!r)throw"Animation not found: "+t;this.addAnimation(r,e,i)},addAnimation:function(t,e,i){var r={};if(r.animation=t,r.loop=e,!i||0>=i){var n=this.queue.length?this.queue[this.queue.length-1].animation:this.current;i=null!=n?n.duration-this.data.getMix(n,t)+(i||0):0}r.delay=i,this.queue.push(r)},isComplete:function(){return!this.current||this.currentTime>=this.current.duration}},a.SkeletonJson=function(t){this.attachmentLoader=t},a.SkeletonJson.prototype={scale:1,readSkeletonData:function(t){for(var e,i=new a.SkeletonData,r=t.bones,n=0,o=r.length;o>n;n++){var s=r[n],h=null;if(s.parent&&!(h=i.findBone(s.parent)))throw"Parent bone not found: "+s.parent;e=new a.BoneData(s.name,h),e.length=(s.length||0)*this.scale,e.x=(s.x||0)*this.scale,e.y=(s.y||0)*this.scale,e.rotation=s.rotation||0,e.scaleX=s.scaleX||1,e.scaleY=s.scaleY||1,i.bones.push(e)}var l=t.slots;for(n=0,o=l.length;o>n;n++){var u=l[n];if(!(e=i.findBone(u.bone)))throw"Slot bone not found: "+u.bone;var c=new a.SlotData(u.name,e),d=u.color;d&&(c.r=a.SkeletonJson.toColor(d,0),c.g=a.SkeletonJson.toColor(d,1),c.b=a.SkeletonJson.toColor(d,2),c.a=a.SkeletonJson.toColor(d,3)),c.attachmentName=u.attachment,i.slots.push(c)}var f=t.skins;for(var p in f)if(f.hasOwnProperty(p)){var g=f[p],v=new a.Skin(p);for(var m in g)if(g.hasOwnProperty(m)){var x=i.findSlotIndex(m),y=g[m];for(var b in y)if(y.hasOwnProperty(b)){var T=this.readAttachment(v,b,y[b]);null!=T&&v.addAttachment(x,b,T)}}i.skins.push(v),"default"==v.name&&(i.defaultSkin=v)}var S=t.animations;for(var _ in S)S.hasOwnProperty(_)&&this.readAnimation(_,S[_],i);return i},readAttachment:function(t,e,i){e=i.name||e;var r=a.AttachmentType[i.type||"region"];if(r==a.AttachmentType.region){var n=new a.RegionAttachment;return n.x=(i.x||0)*this.scale,n.y=(i.y||0)*this.scale,n.scaleX=i.scaleX||1,n.scaleY=i.scaleY||1,n.rotation=i.rotation||0,n.width=(i.width||32)*this.scale,n.height=(i.height||32)*this.scale,n.updateOffset(),n.rendererObject={},n.rendererObject.name=e,n.rendererObject.scale={},n.rendererObject.scale.x=n.scaleX,n.rendererObject.scale.y=n.scaleY,n.rendererObject.rotation=-n.rotation*Math.PI/180,n}throw"Unknown attachment type: "+r},readAnimation:function(t,e,i){var r,n,o,s,h,l,u,c=[],d=0,f=e.bones;for(var p in f)if(f.hasOwnProperty(p)){var g=i.findBoneIndex(p);if(-1==g)throw"Bone not found: "+p;var v=f[p];for(o in v)if(v.hasOwnProperty(o))if(h=v[o],"rotate"==o){for(n=new a.RotateTimeline(h.length),n.boneIndex=g,r=0,l=0,u=h.length;u>l;l++)s=h[l],n.setFrame(r,s.time,s.angle),a.SkeletonJson.readCurve(n,r,s),r++;c.push(n),d=Math.max(d,n.frames[2*n.getFrameCount()-2])}else{if("translate"!=o&&"scale"!=o)throw"Invalid timeline type for a bone: "+o+" ("+p+")";var m=1;for("scale"==o?n=new a.ScaleTimeline(h.length):(n=new a.TranslateTimeline(h.length),m=this.scale),n.boneIndex=g,r=0,l=0,u=h.length;u>l;l++){s=h[l];var x=(s.x||0)*m,y=(s.y||0)*m;n.setFrame(r,s.time,x,y),a.SkeletonJson.readCurve(n,r,s),r++}c.push(n),d=Math.max(d,n.frames[3*n.getFrameCount()-3])}}var b=e.slots;for(var T in b)if(b.hasOwnProperty(T)){var S=b[T],_=i.findSlotIndex(T);for(o in S)if(S.hasOwnProperty(o))if(h=S[o],"color"==o){for(n=new a.ColorTimeline(h.length),n.slotIndex=_,r=0,l=0,u=h.length;u>l;l++){s=h[l];var w=s.color,E=a.SkeletonJson.toColor(w,0),C=a.SkeletonJson.toColor(w,1),A=a.SkeletonJson.toColor(w,2),R=a.SkeletonJson.toColor(w,3);n.setFrame(r,s.time,E,C,A,R),a.SkeletonJson.readCurve(n,r,s),r++}c.push(n),d=Math.max(d,n.frames[5*n.getFrameCount()-5])}else{if("attachment"!=o)throw"Invalid timeline type for a slot: "+o+" ("+T+")";for(n=new a.AttachmentTimeline(h.length),n.slotIndex=_,r=0,l=0,u=h.length;u>l;l++)s=h[l],n.setFrame(r++,s.time,s.name);c.push(n),d=Math.max(d,n.frames[n.getFrameCount()-1])}}i.animations.push(new a.Animation(t,c,d))}},a.SkeletonJson.readCurve=function(t,e,i){var r=i.curve;r&&("stepped"==r?t.curves.setStepped(e):r instanceof Array&&t.curves.setCurve(e,r[0],r[1],r[2],r[3]))},a.SkeletonJson.toColor=function(t,e){if(8!=t.length)throw"Color hexidecimal length must be 8, recieved: "+t;return parseInt(t.substr(2*e,2),16)/255},a.Atlas=function(t,e){this.textureLoader=e,this.pages=[],this.regions=[];var i=new a.AtlasReader(t),r=[];r.length=4;for(var n=null;;){var o=i.readLine();if(null==o)break;if(o=i.trim(o),o.length)if(n){var s=new a.AtlasRegion;s.name=o,s.page=n,s.rotate="true"==i.readValue(),i.readTuple(r);var h=parseInt(r[0],10),l=parseInt(r[1],10);i.readTuple(r);var u=parseInt(r[0],10),c=parseInt(r[1],10);s.u=h/n.width,s.v=l/n.height,s.rotate?(s.u2=(h+c)/n.width,s.v2=(l+u)/n.height):(s.u2=(h+u)/n.width,s.v2=(l+c)/n.height),s.x=h,s.y=l,s.width=Math.abs(u),s.height=Math.abs(c),4==i.readTuple(r)&&(s.splits=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)],4==i.readTuple(r)&&(s.pads=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10),parseInt(r[3],10)],i.readTuple(r))),s.originalWidth=parseInt(r[0],10),s.originalHeight=parseInt(r[1],10),i.readTuple(r),s.offsetX=parseInt(r[0],10),s.offsetY=parseInt(r[1],10),s.index=parseInt(i.readValue(),10),this.regions.push(s)}else{n=new a.AtlasPage,n.name=o,n.format=a.Atlas.Format[i.readValue()],i.readTuple(r),n.minFilter=a.Atlas.TextureFilter[r[0]],n.magFilter=a.Atlas.TextureFilter[r[1]];var d=i.readValue();n.uWrap=a.Atlas.TextureWrap.clampToEdge,n.vWrap=a.Atlas.TextureWrap.clampToEdge,"x"==d?n.uWrap=a.Atlas.TextureWrap.repeat:"y"==d?n.vWrap=a.Atlas.TextureWrap.repeat:"xy"==d&&(n.uWrap=n.vWrap=a.Atlas.TextureWrap.repeat),e.load(n,o),this.pages.push(n)}else n=null}},a.Atlas.prototype={findRegion:function(t){for(var e=this.regions,i=0,r=e.length;r>i;i++)if(e[i].name==t)return e[i];return null},dispose:function(){for(var t=this.pages,e=0,i=t.length;i>e;e++)this.textureLoader.unload(t[e].rendererObject)},updateUVs:function(t){for(var e=this.regions,i=0,r=e.length;r>i;i++){var n=e[i];n.page==t&&(n.u=n.x/t.width,n.v=n.y/t.height,n.rotate?(n.u2=(n.x+n.height)/t.width,n.v2=(n.y+n.width)/t.height):(n.u2=(n.x+n.width)/t.width,n.v2=(n.y+n.height)/t.height))}}},a.Atlas.Format={alpha:0,intensity:1,luminanceAlpha:2,rgb565:3,rgba4444:4,rgb888:5,rgba8888:6},a.Atlas.TextureFilter={nearest:0,linear:1,mipMap:2,mipMapNearestNearest:3,mipMapLinearNearest:4,mipMapNearestLinear:5,mipMapLinearLinear:6},a.Atlas.TextureWrap={mirroredRepeat:0,clampToEdge:1,repeat:2},a.AtlasPage=function(){},a.AtlasPage.prototype={name:null,format:null,minFilter:null,magFilter:null,uWrap:null,vWrap:null,rendererObject:null,width:0,height:0},a.AtlasRegion=function(){},a.AtlasRegion.prototype={page:null,name:null,x:0,y:0,width:0,height:0,u:0,v:0,u2:0,v2:0,offsetX:0,offsetY:0,originalWidth:0,originalHeight:0,index:0,rotate:!1,splits:null,pads:null},a.AtlasReader=function(t){this.lines=t.split(/\r\n|\r|\n/)},a.AtlasReader.prototype={index:0,trim:function(t){return t.replace(/^\s+|\s+$/g,"")},readLine:function(){return this.index>=this.lines.length?null:this.lines[this.index++]},readValue:function(){var t=this.readLine(),e=t.indexOf(":");if(-1==e)throw"Invalid line: "+t;return this.trim(t.substring(e+1))},readTuple:function(t){var e=this.readLine(),i=e.indexOf(":");if(-1==i)throw"Invalid line: "+e;for(var r=0,n=i+1;3>r;r++){var o=e.indexOf(",",n);if(-1==o){if(!r)throw"Invalid line: "+e;break}t[r]=this.trim(e.substr(n,o-n)),n=o+1}return t[r]=this.trim(e.substring(n)),r+1}},a.AtlasAttachmentLoader=function(t){this.atlas=t},a.AtlasAttachmentLoader.prototype={newAttachment:function(t,e,i){switch(e){case a.AttachmentType.region:var r=this.atlas.findRegion(i);if(!r)throw"Region not found in atlas: "+i+" ("+e+")";var n=new a.RegionAttachment(i);return n.rendererObject=r,n.setUVs(r.u,r.v,r.u2,r.v2,r.rotate),n.regionOffsetX=r.offsetX,n.regionOffsetY=r.offsetY,n.regionWidth=r.width,n.regionHeight=r.height,n.regionOriginalWidth=r.originalWidth,n.regionOriginalHeight=r.originalHeight,n}throw"Unknown attachment type: "+e}},a.Bone.yDown=!0,r.AnimCache={},r.Spine=function(t){if(r.DisplayObjectContainer.call(this),this.spineData=r.AnimCache[t],!this.spineData)throw new Error("Spine data must be preloaded using PIXI.SpineLoader or PIXI.AssetLoader: "+t);this.skeleton=new a.Skeleton(this.spineData),this.skeleton.updateWorldTransform(),this.stateData=new a.AnimationStateData(this.spineData),this.state=new a.AnimationState(this.stateData),this.slotContainers=[];for(var e=0,i=this.skeleton.drawOrder.length;i>e;e++){var n=this.skeleton.drawOrder[e],o=n.attachment,s=new r.DisplayObjectContainer;if(this.slotContainers.push(s),this.addChild(s),o instanceof a.RegionAttachment){var h=o.rendererObject.name,l=this.createSprite(n,o.rendererObject);n.currentSprite=l,n.currentSpriteName=h,s.addChild(l)}}},r.Spine.prototype=Object.create(r.DisplayObjectContainer.prototype),r.Spine.prototype.constructor=r.Spine,r.Spine.prototype.updateTransform=function(){this.lastTime=this.lastTime||Date.now();var t=.001*(Date.now()-this.lastTime);this.lastTime=Date.now(),this.state.update(t),this.state.apply(this.skeleton),this.skeleton.updateWorldTransform();for(var e=this.skeleton.drawOrder,i=0,n=e.length;n>i;i++){var o=e[i],s=o.attachment,h=this.slotContainers[i];if(s instanceof a.RegionAttachment){if(s.rendererObject&&(!o.currentSpriteName||o.currentSpriteName!=s.name)){var l=s.rendererObject.name;if(void 0!==o.currentSprite&&(o.currentSprite.visible=!1),o.sprites=o.sprites||{},void 0!==o.sprites[l])o.sprites[l].visible=!0;else{var u=this.createSprite(o,s.rendererObject);h.addChild(u)}o.currentSprite=o.sprites[l],o.currentSpriteName=l}h.visible=!0;var c=o.bone;h.position.x=c.worldX+s.x*c.m00+s.y*c.m01,h.position.y=c.worldY+s.x*c.m10+s.y*c.m11,h.scale.x=c.worldScaleX,h.scale.y=c.worldScaleY,h.rotation=-o.bone.worldRotation*Math.PI/180,h.alpha=o.a,o.currentSprite.tint=r.rgb2hex([o.r,o.g,o.b])}else h.visible=!1}r.DisplayObjectContainer.prototype.updateTransform.call(this)},r.Spine.prototype.createSprite=function(t,e){var i=r.TextureCache[e.name]?e.name:e.name+".png",n=new r.Sprite(r.Texture.fromFrame(i));return n.scale=e.scale,n.rotation=e.rotation,n.anchor.x=n.anchor.y=.5,t.sprites=t.sprites||{},t.sprites[e.name]=n,n},r.BaseTextureCache={},r.texturesToUpdate=[],r.texturesToDestroy=[],r.BaseTextureCacheIdGenerator=0,r.BaseTexture=function(t,e){if(r.EventTarget.call(this),this.width=100,this.height=100,this.scaleMode=e||r.scaleModes.DEFAULT,this.hasLoaded=!1,this.source=t,this.id=r.BaseTextureCacheIdGenerator++,this.premultipliedAlpha=!0,this._glTextures=[],this._dirty=[],t){if((this.source.complete||this.source.getContext)&&this.source.width&&this.source.height)this.hasLoaded=!0,this.width=this.source.width,this.height=this.source.height,r.texturesToUpdate.push(this);else{var i=this;this.source.onload=function(){i.hasLoaded=!0,i.width=i.source.width,i.height=i.source.height;for(var t=0;t<i._glTextures.length;t++)i._dirty[t]=!0;i.dispatchEvent({type:"loaded",content:i})},this.source.onerror=function(){i.dispatchEvent({type:"error",content:i})}}this.imageUrl=null,this._powerOf2=!1}},r.BaseTexture.prototype.constructor=r.BaseTexture,r.BaseTexture.prototype.destroy=function(){this.imageUrl?(delete r.BaseTextureCache[this.imageUrl],delete r.TextureCache[this.imageUrl],this.imageUrl=null,this.source.src=null):this.source&&this.source._pixiId&&delete r.BaseTextureCache[this.source._pixiId],this.source=null,r.texturesToDestroy.push(this)},r.BaseTexture.prototype.updateSourceImage=function(t){this.hasLoaded=!1,this.source.src=null,this.source.src=t},r.BaseTexture.fromImage=function(t,e,i){var n=r.BaseTextureCache[t];if(void 0===e&&-1===t.indexOf("data:")&&(e=!0),!n){var o=new Image;e&&(o.crossOrigin=""),o.src=t,n=new r.BaseTexture(o,i),n.imageUrl=t,r.BaseTextureCache[t]=n}return n},r.BaseTexture.fromCanvas=function(t,e){t._pixiId||(t._pixiId="canvas_"+r.TextureCacheIdGenerator++);var i=r.BaseTextureCache[t._pixiId];return i||(i=new r.BaseTexture(t,e),r.BaseTextureCache[t._pixiId]=i),i},r.TextureCache={},r.FrameCache={},r.TextureCacheIdGenerator=0,r.Texture=function(t,e){if(r.EventTarget.call(this),this.noFrame=!1,e||(this.noFrame=!0,e=new r.Rectangle(0,0,1,1)),t instanceof r.Texture&&(t=t.baseTexture),this.baseTexture=t,this.frame=e,this.trim=null,this.valid=!1,this.scope=this,this._uvs=null,this.width=0,this.height=0,this.crop=new r.Rectangle(0,0,1,1),t.hasLoaded)this.noFrame&&(e=new r.Rectangle(0,0,t.width,t.height)),this.setFrame(e);else{var i=this;t.addEventListener("loaded",function(){i.onBaseTextureLoaded()})}},r.Texture.prototype.constructor=r.Texture,r.Texture.prototype.onBaseTextureLoaded=function(){var t=this.baseTexture;t.removeEventListener("loaded",this.onLoaded),this.noFrame&&(this.frame=new r.Rectangle(0,0,t.width,t.height)),this.setFrame(this.frame),this.scope.dispatchEvent({type:"update",content:this})},r.Texture.prototype.destroy=function(t){t&&this.baseTexture.destroy(),this.valid=!1},r.Texture.prototype.setFrame=function(t){if(this.noFrame=!1,this.frame=t,this.width=t.width,this.height=t.height,this.crop.x=t.x,this.crop.y=t.y,this.crop.width=t.width,this.crop.height=t.height,!this.trim&&(t.x+t.width>this.baseTexture.width||t.y+t.height>this.baseTexture.height))throw new Error("Texture Error: frame does not fit inside the base Texture dimensions "+this);this.valid=t&&t.width&&t.height&&this.baseTexture.source&&this.baseTexture.hasLoaded,this.trim&&(this.width=this.trim.width,this.height=this.trim.height,this.frame.width=this.trim.width,this.frame.height=this.trim.height),this.valid&&r.Texture.frameUpdates.push(this)},r.Texture.prototype._updateWebGLuvs=function(){this._uvs||(this._uvs=new r.TextureUvs);var t=this.crop,e=this.baseTexture.width,i=this.baseTexture.height;this._uvs.x0=t.x/e,this._uvs.y0=t.y/i,this._uvs.x1=(t.x+t.width)/e,this._uvs.y1=t.y/i,this._uvs.x2=(t.x+t.width)/e,this._uvs.y2=(t.y+t.height)/i,this._uvs.x3=t.x/e,this._uvs.y3=(t.y+t.height)/i},r.Texture.fromImage=function(t,e,i){var n=r.TextureCache[t];return n||(n=new r.Texture(r.BaseTexture.fromImage(t,e,i)),r.TextureCache[t]=n),n},r.Texture.fromFrame=function(t){var e=r.TextureCache[t];if(!e)throw new Error('The frameId "'+t+'" does not exist in the texture cache ');return e},r.Texture.fromCanvas=function(t,e){var i=r.BaseTexture.fromCanvas(t,e);return new r.Texture(i)},r.Texture.addTextureToCache=function(t,e){r.TextureCache[e]=t},r.Texture.removeTextureFromCache=function(t){var e=r.TextureCache[t];return delete r.TextureCache[t],delete r.BaseTextureCache[t],e},r.Texture.frameUpdates=[],r.TextureUvs=function(){this.x0=0,this.y0=0,this.x1=0,this.y1=0,this.x2=0,this.y2=0,this.x3=0,this.y3=0},r.RenderTexture=function(t,e,i,n){if(r.EventTarget.call(this),this.width=t||100,this.height=e||100,this.frame=new r.Rectangle(0,0,this.width,this.height),this.crop=new r.Rectangle(0,0,this.width,this.height),this.baseTexture=new r.BaseTexture,this.baseTexture.width=this.width,this.baseTexture.height=this.height,this.baseTexture._glTextures=[],this.baseTexture.scaleMode=n||r.scaleModes.DEFAULT,this.baseTexture.hasLoaded=!0,this.renderer=i||r.defaultRenderer,this.renderer.type===r.WEBGL_RENDERER){var o=this.renderer.gl;this.textureBuffer=new r.FilterTexture(o,this.width,this.height,this.baseTexture.scaleMode),this.baseTexture._glTextures[o.id]=this.textureBuffer.texture,this.render=this.renderWebGL,this.projection=new r.Point(this.width/2,-this.height/2)}else this.render=this.renderCanvas,this.textureBuffer=new r.CanvasBuffer(this.width,this.height),this.baseTexture.source=this.textureBuffer.canvas;this.valid=!0,r.Texture.frameUpdates.push(this)},r.RenderTexture.prototype=Object.create(r.Texture.prototype),r.RenderTexture.prototype.constructor=r.RenderTexture,r.RenderTexture.prototype.resize=function(t,e,i){(t!==this.width||e!==this.height)&&(this.width=this.frame.width=this.crop.width=t,this.height=this.frame.height=this.crop.height=e,i&&(this.baseTexture.width=this.width,this.baseTexture.height=this.height),this.renderer.type===r.WEBGL_RENDERER&&(this.projection.x=this.width/2,this.projection.y=-this.height/2),this.textureBuffer.resize(this.width,this.height))},r.RenderTexture.prototype.clear=function(){this.renderer.type===r.WEBGL_RENDERER&&this.renderer.gl.bindFramebuffer(this.renderer.gl.FRAMEBUFFER,this.textureBuffer.frameBuffer),this.textureBuffer.clear()},r.RenderTexture.prototype.renderWebGL=function(t,e,i){var n=this.renderer.gl;n.colorMask(!0,!0,!0,!0),n.viewport(0,0,this.width,this.height),n.bindFramebuffer(n.FRAMEBUFFER,this.textureBuffer.frameBuffer),i&&this.textureBuffer.clear();var o=t.children,s=t.worldTransform;t.worldTransform=r.RenderTexture.tempMatrix,t.worldTransform.d=-1,t.worldTransform.ty=-2*this.projection.y,e&&(t.worldTransform.tx=e.x,t.worldTransform.ty-=e.y);for(var a=0,h=o.length;h>a;a++)o[a].updateTransform();r.WebGLRenderer.updateTextures(),this.renderer.spriteBatch.dirty=!0,this.renderer.renderDisplayObject(t,this.projection,this.textureBuffer.frameBuffer),t.worldTransform=s,this.renderer.spriteBatch.dirty=!0},r.RenderTexture.prototype.renderCanvas=function(t,e,i){var n=t.children,o=t.worldTransform;t.worldTransform=r.RenderTexture.tempMatrix,e?(t.worldTransform.tx=e.x,t.worldTransform.ty=e.y):(t.worldTransform.tx=0,t.worldTransform.ty=0);for(var s=0,a=n.length;a>s;s++)n[s].updateTransform();i&&this.textureBuffer.clear();var h=this.textureBuffer.context;this.renderer.renderDisplayObject(t,h),h.setTransform(1,0,0,1,0,0),t.worldTransform=o},r.RenderTexture.tempMatrix=new r.Matrix,r.AssetLoader=function(t,e){r.EventTarget.call(this),this.assetURLs=t,this.crossorigin=e,this.loadersByType={jpg:r.ImageLoader,jpeg:r.ImageLoader,png:r.ImageLoader,gif:r.ImageLoader,webp:r.ImageLoader,json:r.JsonLoader,atlas:r.AtlasLoader,anim:r.SpineLoader,xml:r.BitmapFontLoader,fnt:r.BitmapFontLoader}},r.AssetLoader.prototype.constructor=r.AssetLoader,r.AssetLoader.prototype._getDataType=function(t){var e="data:";if(t.slice(0,e.length).toLowerCase()===e){var i=t.slice(e.length),r=i.indexOf(",");if(-1===r)return null;var n=i.slice(0,r).split(";")[0];return n&&"text/plain"!==n.toLowerCase()?n.split("/").pop().toLowerCase():"txt"}return null},r.AssetLoader.prototype.load=function(){function t(t){e.onAssetLoaded(t.content)}var e=this;this.loadCount=this.assetURLs.length;for(var i=0;i<this.assetURLs.length;i++){var r=this.assetURLs[i],n=this._getDataType(r);n||(n=r.split("?").shift().split(".").pop().toLowerCase());var o=this.loadersByType[n];if(!o)throw new Error(n+" is an unsupported file type");var s=new o(r,this.crossorigin);s.addEventListener("loaded",t),s.load()}},r.AssetLoader.prototype.onAssetLoaded=function(t){this.loadCount--,this.dispatchEvent({type:"onProgress",content:this,loader:t}),this.onProgress&&this.onProgress(t),this.loadCount||(this.dispatchEvent({type:"onComplete",content:this}),this.onComplete&&this.onComplete())},r.JsonLoader=function(t,e){r.EventTarget.call(this),this.url=t,this.crossorigin=e,this.baseUrl=t.replace(/[^\/]*$/,""),this.loaded=!1},r.JsonLoader.prototype.constructor=r.JsonLoader,r.JsonLoader.prototype.load=function(){var t=this;window.XDomainRequest&&t.crossorigin?(this.ajaxRequest=new window.XDomainRequest,this.ajaxRequest.timeout=3e3,this.ajaxRequest.onerror=function(){t.onError()},this.ajaxRequest.ontimeout=function(){t.onError()},this.ajaxRequest.onprogress=function(){}):this.ajaxRequest=window.XMLHttpRequest?new window.XMLHttpRequest:new window.ActiveXObject("Microsoft.XMLHTTP"),this.ajaxRequest.onload=function(){t.onJSONLoaded()},this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.send()},r.JsonLoader.prototype.onJSONLoaded=function(){if(!this.ajaxRequest.responseText)return void this.onError();if(this.json=JSON.parse(this.ajaxRequest.responseText),this.json.frames){var t=this,e=this.baseUrl+this.json.meta.image,i=new r.ImageLoader(e,this.crossorigin),n=this.json.frames;this.texture=i.texture.baseTexture,i.addEventListener("loaded",function(){t.onLoaded()});for(var o in n){var s=n[o].frame;if(s&&(r.TextureCache[o]=new r.Texture(this.texture,{x:s.x,y:s.y,width:s.w,height:s.h}),r.TextureCache[o].crop=new r.Rectangle(s.x,s.y,s.w,s.h),n[o].trimmed)){var h=n[o].sourceSize,l=n[o].spriteSourceSize;r.TextureCache[o].trim=new r.Rectangle(l.x,l.y,h.w,h.h)}}i.load()}else if(this.json.bones){var u=new a.SkeletonJson,c=u.readSkeletonData(this.json);r.AnimCache[this.url]=c,this.onLoaded()}else this.onLoaded()},r.JsonLoader.prototype.onLoaded=function(){this.loaded=!0,this.dispatchEvent({type:"loaded",content:this})},r.JsonLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},r.AtlasLoader=function(t,e){r.EventTarget.call(this),this.url=t,this.baseUrl=t.replace(/[^\/]*$/,""),this.crossorigin=e,this.loaded=!1},r.AtlasLoader.constructor=r.AtlasLoader,r.AtlasLoader.prototype.load=function(){this.ajaxRequest=new r.AjaxRequest,this.ajaxRequest.onreadystatechange=this.onAtlasLoaded.bind(this),this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/json"),this.ajaxRequest.send(null)},r.AtlasLoader.prototype.onAtlasLoaded=function(){if(4===this.ajaxRequest.readyState)if(200===this.ajaxRequest.status||-1===window.location.href.indexOf("http")){this.atlas={meta:{image:[]},frames:[]};var t=this.ajaxRequest.responseText.split(/\r?\n/),e=-3,i=0,n=null,o=!1,s=0,a=0,h=this.onLoaded.bind(this);for(s=0;s<t.length;s++)if(t[s]=t[s].replace(/^\s+|\s+$/g,""),""===t[s]&&(o=s+1),t[s].length>0){if(o===s)this.atlas.meta.image.push(t[s]),i=this.atlas.meta.image.length-1,this.atlas.frames.push({}),e=-3;else if(e>0)if(e%7==1)null!=n&&(this.atlas.frames[i][n.name]=n),n={name:t[s],frame:{}};else{var l=t[s].split(" ");if(e%7==3)n.frame.x=Number(l[1].replace(",","")),n.frame.y=Number(l[2]);else if(e%7==4)n.frame.w=Number(l[1].replace(",","")),n.frame.h=Number(l[2]);else if(e%7==5){var u={x:0,y:0,w:Number(l[1].replace(",","")),h:Number(l[2])};u.w>n.frame.w||u.h>n.frame.h?(n.trimmed=!0,n.realSize=u):n.trimmed=!1}}e++}if(null!=n&&(this.atlas.frames[i][n.name]=n),this.atlas.meta.image.length>0){for(this.images=[],a=0;a<this.atlas.meta.image.length;a++){var c=this.baseUrl+this.atlas.meta.image[a],d=this.atlas.frames[a];this.images.push(new r.ImageLoader(c,this.crossorigin));for(s in d){var f=d[s].frame;f&&(r.TextureCache[s]=new r.Texture(this.images[a].texture.baseTexture,{x:f.x,y:f.y,width:f.w,height:f.h}),d[s].trimmed&&(r.TextureCache[s].realSize=d[s].realSize,r.TextureCache[s].trim.x=0,r.TextureCache[s].trim.y=0))}}for(this.currentImageId=0,a=0;a<this.images.length;a++)this.images[a].addEventListener("loaded",h);this.images[this.currentImageId].load()}else this.onLoaded()}else this.onError()},r.AtlasLoader.prototype.onLoaded=function(){this.images.length-1>this.currentImageId?(this.currentImageId++,this.images[this.currentImageId].load()):(this.loaded=!0,this.dispatchEvent({type:"loaded",content:this}))},r.AtlasLoader.prototype.onError=function(){this.dispatchEvent({type:"error",content:this})},r.SpriteSheetLoader=function(t,e){r.EventTarget.call(this),this.url=t,this.crossorigin=e,this.baseUrl=t.replace(/[^\/]*$/,""),this.texture=null,this.frames={}},r.SpriteSheetLoader.prototype.constructor=r.SpriteSheetLoader,r.SpriteSheetLoader.prototype.load=function(){var t=this,e=new r.JsonLoader(this.url,this.crossorigin);e.addEventListener("loaded",function(e){t.json=e.content.json,t.onLoaded()}),e.load()},r.SpriteSheetLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},r.ImageLoader=function(t,e){r.EventTarget.call(this),this.texture=r.Texture.fromImage(t,e),this.frames=[]},r.ImageLoader.prototype.constructor=r.ImageLoader,r.ImageLoader.prototype.load=function(){if(this.texture.baseTexture.hasLoaded)this.onLoaded();else{var t=this;this.texture.baseTexture.addEventListener("loaded",function(){t.onLoaded()})}},r.ImageLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},r.ImageLoader.prototype.loadFramedSpriteSheet=function(t,e,i){this.frames=[];for(var n=Math.floor(this.texture.width/t),o=Math.floor(this.texture.height/e),s=0,a=0;o>a;a++)for(var h=0;n>h;h++,s++){var l=new r.Texture(this.texture,{x:h*t,y:a*e,width:t,height:e});this.frames.push(l),i&&(r.TextureCache[i+"-"+s]=l)}if(this.texture.baseTexture.hasLoaded)this.onLoaded();else{var u=this;this.texture.baseTexture.addEventListener("loaded",function(){u.onLoaded()})}},r.BitmapFontLoader=function(t,e){r.EventTarget.call(this),this.url=t,this.crossorigin=e,this.baseUrl=t.replace(/[^\/]*$/,""),this.texture=null},r.BitmapFontLoader.prototype.constructor=r.BitmapFontLoader,r.BitmapFontLoader.prototype.load=function(){this.ajaxRequest=new r.AjaxRequest;var t=this;this.ajaxRequest.onreadystatechange=function(){t.onXMLLoaded()},this.ajaxRequest.open("GET",this.url,!0),this.ajaxRequest.overrideMimeType&&this.ajaxRequest.overrideMimeType("application/xml"),this.ajaxRequest.send(null)},r.BitmapFontLoader.prototype.onXMLLoaded=function(){if(4===this.ajaxRequest.readyState&&(200===this.ajaxRequest.status||-1===window.location.protocol.indexOf("http"))){var t=this.ajaxRequest.responseXML;if(!t||/MSIE 9/i.test(navigator.userAgent)||navigator.isCocoonJS)if("function"==typeof window.DOMParser){var e=new DOMParser;t=e.parseFromString(this.ajaxRequest.responseText,"text/xml")}else{var i=document.createElement("div");i.innerHTML=this.ajaxRequest.responseText,t=i}var n=this.baseUrl+t.getElementsByTagName("page")[0].getAttribute("file"),o=new r.ImageLoader(n,this.crossorigin);this.texture=o.texture.baseTexture;var s={},a=t.getElementsByTagName("info")[0],h=t.getElementsByTagName("common")[0];s.font=a.getAttribute("face"),s.size=parseInt(a.getAttribute("size"),10),s.lineHeight=parseInt(h.getAttribute("lineHeight"),10),s.chars={};for(var l=t.getElementsByTagName("char"),u=0;u<l.length;u++){var c=parseInt(l[u].getAttribute("id"),10),d=new r.Rectangle(parseInt(l[u].getAttribute("x"),10),parseInt(l[u].getAttribute("y"),10),parseInt(l[u].getAttribute("width"),10),parseInt(l[u].getAttribute("height"),10));s.chars[c]={xOffset:parseInt(l[u].getAttribute("xoffset"),10),yOffset:parseInt(l[u].getAttribute("yoffset"),10),xAdvance:parseInt(l[u].getAttribute("xadvance"),10),kerning:{},texture:r.TextureCache[c]=new r.Texture(this.texture,d)}}var f=t.getElementsByTagName("kerning");for(u=0;u<f.length;u++){var p=parseInt(f[u].getAttribute("first"),10),g=parseInt(f[u].getAttribute("second"),10),v=parseInt(f[u].getAttribute("amount"),10);s.chars[g].kerning[p]=v}r.BitmapText.fonts[s.font]=s;var m=this;o.addEventListener("loaded",function(){
  m.onLoaded()}),o.load()}},r.BitmapFontLoader.prototype.onLoaded=function(){this.dispatchEvent({type:"loaded",content:this})},r.SpineLoader=function(t,e){r.EventTarget.call(this),this.url=t,this.crossorigin=e,this.loaded=!1},r.SpineLoader.prototype.constructor=r.SpineLoader,r.SpineLoader.prototype.load=function(){var t=this,e=new r.JsonLoader(this.url,this.crossorigin);e.addEventListener("loaded",function(e){t.json=e.content.json,t.onLoaded()}),e.load()},r.SpineLoader.prototype.onLoaded=function(){this.loaded=!0,this.dispatchEvent({type:"loaded",content:this})},r.AbstractFilter=function(t,e){this.passes=[this],this.shaders=[],this.dirty=!0,this.padding=0,this.uniforms=e||{},this.fragmentSrc=t||[]},r.AlphaMaskFilter=function(t){r.AbstractFilter.call(this),this.passes=[this],t.baseTexture._powerOf2=!0,this.uniforms={mask:{type:"sampler2D",value:t},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},t.baseTexture.hasLoaded?(this.uniforms.mask.value.x=t.width,this.uniforms.mask.value.y=t.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),t.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D mask;","uniform sampler2D uSampler;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {","   vec2 mapCords = vTextureCoord.xy;","   mapCords += (dimensions.zw + offset)/ dimensions.xy ;","   mapCords.y *= -1.0;","   mapCords.y += 1.0;","   mapCords *= dimensions.xy / mapDimensions;","   vec4 original =  texture2D(uSampler, vTextureCoord);","   float maskAlpha =  texture2D(mask, mapCords).r;","   original *= maskAlpha;","   gl_FragColor =  original;","}"]},r.AlphaMaskFilter.prototype=Object.create(r.AbstractFilter.prototype),r.AlphaMaskFilter.prototype.constructor=r.AlphaMaskFilter,r.AlphaMaskFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.mask.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.mask.value.height,this.uniforms.mask.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(r.AlphaMaskFilter.prototype,"map",{get:function(){return this.uniforms.mask.value},set:function(t){this.uniforms.mask.value=t}}),r.ColorMatrixFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={matrix:{type:"mat4",value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform mat4 matrix;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord) * matrix;","}"]},r.ColorMatrixFilter.prototype=Object.create(r.AbstractFilter.prototype),r.ColorMatrixFilter.prototype.constructor=r.ColorMatrixFilter,Object.defineProperty(r.ColorMatrixFilter.prototype,"matrix",{get:function(){return this.uniforms.matrix.value},set:function(t){this.uniforms.matrix.value=t}}),r.GrayFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={gray:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float gray;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord);","   gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), gray);","}"]},r.GrayFilter.prototype=Object.create(r.AbstractFilter.prototype),r.GrayFilter.prototype.constructor=r.GrayFilter,Object.defineProperty(r.GrayFilter.prototype,"gray",{get:function(){return this.uniforms.gray.value},set:function(t){this.uniforms.gray.value=t}}),r.DisplacementFilter=function(t){r.AbstractFilter.call(this),this.passes=[this],t.baseTexture._powerOf2=!0,this.uniforms={displacementMap:{type:"sampler2D",value:t},scale:{type:"2f",value:{x:30,y:30}},offset:{type:"2f",value:{x:0,y:0}},mapDimensions:{type:"2f",value:{x:1,y:5112}},dimensions:{type:"4fv",value:[0,0,0,0]}},t.baseTexture.hasLoaded?(this.uniforms.mapDimensions.value.x=t.width,this.uniforms.mapDimensions.value.y=t.height):(this.boundLoadedFunction=this.onTextureLoaded.bind(this),t.baseTexture.on("loaded",this.boundLoadedFunction)),this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D displacementMap;","uniform sampler2D uSampler;","uniform vec2 scale;","uniform vec2 offset;","uniform vec4 dimensions;","uniform vec2 mapDimensions;","void main(void) {","   vec2 mapCords = vTextureCoord.xy;","   mapCords += (dimensions.zw + offset)/ dimensions.xy ;","   mapCords.y *= -1.0;","   mapCords.y += 1.0;","   vec2 matSample = texture2D(displacementMap, mapCords).xy;","   matSample -= 0.5;","   matSample *= scale;","   matSample /= mapDimensions;","   gl_FragColor = texture2D(uSampler, vec2(vTextureCoord.x + matSample.x, vTextureCoord.y + matSample.y));","   gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb, 1.0);","   vec2 cord = vTextureCoord;","}"]},r.DisplacementFilter.prototype=Object.create(r.AbstractFilter.prototype),r.DisplacementFilter.prototype.constructor=r.DisplacementFilter,r.DisplacementFilter.prototype.onTextureLoaded=function(){this.uniforms.mapDimensions.value.x=this.uniforms.displacementMap.value.width,this.uniforms.mapDimensions.value.y=this.uniforms.displacementMap.value.height,this.uniforms.displacementMap.value.baseTexture.off("loaded",this.boundLoadedFunction)},Object.defineProperty(r.DisplacementFilter.prototype,"map",{get:function(){return this.uniforms.displacementMap.value},set:function(t){this.uniforms.displacementMap.value=t}}),Object.defineProperty(r.DisplacementFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(t){this.uniforms.scale.value=t}}),Object.defineProperty(r.DisplacementFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(t){this.uniforms.offset.value=t}}),r.PixelateFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:0},dimensions:{type:"4fv",value:new Float32Array([1e4,100,10,10])},pixelSize:{type:"2f",value:{x:10,y:10}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 testDim;","uniform vec4 dimensions;","uniform vec2 pixelSize;","uniform sampler2D uSampler;","void main(void) {","   vec2 coord = vTextureCoord;","   vec2 size = dimensions.xy/pixelSize;","   vec2 color = floor( ( vTextureCoord * size ) ) / size + pixelSize/dimensions.xy * 0.5;","   gl_FragColor = texture2D(uSampler, color);","}"]},r.PixelateFilter.prototype=Object.create(r.AbstractFilter.prototype),r.PixelateFilter.prototype.constructor=r.PixelateFilter,Object.defineProperty(r.PixelateFilter.prototype,"size",{get:function(){return this.uniforms.pixelSize.value},set:function(t){this.dirty=!0,this.uniforms.pixelSize.value=t}}),r.BlurXFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","   vec4 sum = vec4(0.0);","   sum += texture2D(uSampler, vec2(vTextureCoord.x - 4.0*blur, vTextureCoord.y)) * 0.05;","   sum += texture2D(uSampler, vec2(vTextureCoord.x - 3.0*blur, vTextureCoord.y)) * 0.09;","   sum += texture2D(uSampler, vec2(vTextureCoord.x - 2.0*blur, vTextureCoord.y)) * 0.12;","   sum += texture2D(uSampler, vec2(vTextureCoord.x - blur, vTextureCoord.y)) * 0.15;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","   sum += texture2D(uSampler, vec2(vTextureCoord.x + blur, vTextureCoord.y)) * 0.15;","   sum += texture2D(uSampler, vec2(vTextureCoord.x + 2.0*blur, vTextureCoord.y)) * 0.12;","   sum += texture2D(uSampler, vec2(vTextureCoord.x + 3.0*blur, vTextureCoord.y)) * 0.09;","   sum += texture2D(uSampler, vec2(vTextureCoord.x + 4.0*blur, vTextureCoord.y)) * 0.05;","   gl_FragColor = sum;","}"]},r.BlurXFilter.prototype=Object.create(r.AbstractFilter.prototype),r.BlurXFilter.prototype.constructor=r.BlurXFilter,Object.defineProperty(r.BlurXFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.dirty=!0,this.uniforms.blur.value=1/7e3*t}}),r.BlurYFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","   vec4 sum = vec4(0.0);","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 4.0*blur)) * 0.05;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 3.0*blur)) * 0.09;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - 2.0*blur)) * 0.12;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y - blur)) * 0.15;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y)) * 0.16;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + blur)) * 0.15;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 2.0*blur)) * 0.12;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 3.0*blur)) * 0.09;","   sum += texture2D(uSampler, vec2(vTextureCoord.x, vTextureCoord.y + 4.0*blur)) * 0.05;","   gl_FragColor = sum;","}"]},r.BlurYFilter.prototype=Object.create(r.AbstractFilter.prototype),r.BlurYFilter.prototype.constructor=r.BlurYFilter,Object.defineProperty(r.BlurYFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.uniforms.blur.value=1/7e3*t}}),r.BlurFilter=function(){this.blurXFilter=new r.BlurXFilter,this.blurYFilter=new r.BlurYFilter,this.passes=[this.blurXFilter,this.blurYFilter]},Object.defineProperty(r.BlurFilter.prototype,"blur",{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=this.blurYFilter.blur=t}}),Object.defineProperty(r.BlurFilter.prototype,"blurX",{get:function(){return this.blurXFilter.blur},set:function(t){this.blurXFilter.blur=t}}),Object.defineProperty(r.BlurFilter.prototype,"blurY",{get:function(){return this.blurYFilter.blur},set:function(t){this.blurYFilter.blur=t}}),r.InvertFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={invert:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float invert;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord);","   gl_FragColor.rgb = mix( (vec3(1)-gl_FragColor.rgb) * gl_FragColor.a, gl_FragColor.rgb, 1.0 - invert);","}"]},r.InvertFilter.prototype=Object.create(r.AbstractFilter.prototype),r.InvertFilter.prototype.constructor=r.InvertFilter,Object.defineProperty(r.InvertFilter.prototype,"invert",{get:function(){return this.uniforms.invert.value},set:function(t){this.uniforms.invert.value=t}}),r.SepiaFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={sepia:{type:"1f",value:1}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float sepia;","uniform sampler2D uSampler;","const mat3 sepiaMatrix = mat3(0.3588, 0.7044, 0.1368, 0.2990, 0.5870, 0.1140, 0.2392, 0.4696, 0.0912);","void main(void) {","   gl_FragColor = texture2D(uSampler, vTextureCoord);","   gl_FragColor.rgb = mix( gl_FragColor.rgb, gl_FragColor.rgb * sepiaMatrix, sepia);","}"]},r.SepiaFilter.prototype=Object.create(r.AbstractFilter.prototype),r.SepiaFilter.prototype.constructor=r.SepiaFilter,Object.defineProperty(r.SepiaFilter.prototype,"sepia",{get:function(){return this.uniforms.sepia.value},set:function(t){this.uniforms.sepia.value=t}}),r.TwistFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={radius:{type:"1f",value:.5},angle:{type:"1f",value:5},offset:{type:"2f",value:{x:.5,y:.5}}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float radius;","uniform float angle;","uniform vec2 offset;","void main(void) {","   vec2 coord = vTextureCoord - offset;","   float distance = length(coord);","   if (distance < radius) {","       float ratio = (radius - distance) / radius;","       float angleMod = ratio * ratio * angle;","       float s = sin(angleMod);","       float c = cos(angleMod);","       coord = vec2(coord.x * c - coord.y * s, coord.x * s + coord.y * c);","   }","   gl_FragColor = texture2D(uSampler, coord+offset);","}"]},r.TwistFilter.prototype=Object.create(r.AbstractFilter.prototype),r.TwistFilter.prototype.constructor=r.TwistFilter,Object.defineProperty(r.TwistFilter.prototype,"offset",{get:function(){return this.uniforms.offset.value},set:function(t){this.dirty=!0,this.uniforms.offset.value=t}}),Object.defineProperty(r.TwistFilter.prototype,"radius",{get:function(){return this.uniforms.radius.value},set:function(t){this.dirty=!0,this.uniforms.radius.value=t}}),Object.defineProperty(r.TwistFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(t){this.dirty=!0,this.uniforms.angle.value=t}}),r.ColorStepFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={step:{type:"1f",value:5}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform sampler2D uSampler;","uniform float step;","void main(void) {","   vec4 color = texture2D(uSampler, vTextureCoord);","   color = floor(color * step) / step;","   gl_FragColor = color;","}"]},r.ColorStepFilter.prototype=Object.create(r.AbstractFilter.prototype),r.ColorStepFilter.prototype.constructor=r.ColorStepFilter,Object.defineProperty(r.ColorStepFilter.prototype,"step",{get:function(){return this.uniforms.step.value},set:function(t){this.uniforms.step.value=t}}),r.DotScreenFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={scale:{type:"1f",value:1},angle:{type:"1f",value:5},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec4 dimensions;","uniform sampler2D uSampler;","uniform float angle;","uniform float scale;","float pattern() {","   float s = sin(angle), c = cos(angle);","   vec2 tex = vTextureCoord * dimensions.xy;","   vec2 point = vec2(","       c * tex.x - s * tex.y,","       s * tex.x + c * tex.y","   ) * scale;","   return (sin(point.x) * sin(point.y)) * 4.0;","}","void main() {","   vec4 color = texture2D(uSampler, vTextureCoord);","   float average = (color.r + color.g + color.b) / 3.0;","   gl_FragColor = vec4(vec3(average * 10.0 - 5.0 + pattern()), color.a);","}"]},r.DotScreenFilter.prototype=Object.create(r.AbstractFilter.prototype),r.DotScreenFilter.prototype.constructor=r.DotScreenFilter,Object.defineProperty(r.DotScreenFilter.prototype,"scale",{get:function(){return this.uniforms.scale.value},set:function(t){this.dirty=!0,this.uniforms.scale.value=t}}),Object.defineProperty(r.DotScreenFilter.prototype,"angle",{get:function(){return this.uniforms.angle.value},set:function(t){this.dirty=!0,this.uniforms.angle.value=t}}),r.CrossHatchFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={blur:{type:"1f",value:1/512}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform float blur;","uniform sampler2D uSampler;","void main(void) {","    float lum = length(texture2D(uSampler, vTextureCoord.xy).rgb);","    gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);","    if (lum < 1.00) {","        if (mod(gl_FragCoord.x + gl_FragCoord.y, 10.0) == 0.0) {","            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);","        }","    }","    if (lum < 0.75) {","        if (mod(gl_FragCoord.x - gl_FragCoord.y, 10.0) == 0.0) {","            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);","        }","    }","    if (lum < 0.50) {","        if (mod(gl_FragCoord.x + gl_FragCoord.y - 5.0, 10.0) == 0.0) {","            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);","        }","    }","    if (lum < 0.3) {","        if (mod(gl_FragCoord.x - gl_FragCoord.y - 5.0, 10.0) == 0.0) {","            gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);","        }","    }","}"]},r.CrossHatchFilter.prototype=Object.create(r.AbstractFilter.prototype),r.CrossHatchFilter.prototype.constructor=r.BlurYFilter,Object.defineProperty(r.CrossHatchFilter.prototype,"blur",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.uniforms.blur.value=1/7e3*t}}),r.RGBSplitFilter=function(){r.AbstractFilter.call(this),this.passes=[this],this.uniforms={red:{type:"2f",value:{x:20,y:20}},green:{type:"2f",value:{x:-20,y:20}},blue:{type:"2f",value:{x:20,y:-20}},dimensions:{type:"4fv",value:[0,0,0,0]}},this.fragmentSrc=["precision mediump float;","varying vec2 vTextureCoord;","varying vec4 vColor;","uniform vec2 red;","uniform vec2 green;","uniform vec2 blue;","uniform vec4 dimensions;","uniform sampler2D uSampler;","void main(void) {","   gl_FragColor.r = texture2D(uSampler, vTextureCoord + red/dimensions.xy).r;","   gl_FragColor.g = texture2D(uSampler, vTextureCoord + green/dimensions.xy).g;","   gl_FragColor.b = texture2D(uSampler, vTextureCoord + blue/dimensions.xy).b;","   gl_FragColor.a = texture2D(uSampler, vTextureCoord).a;","}"]},r.RGBSplitFilter.prototype=Object.create(r.AbstractFilter.prototype),r.RGBSplitFilter.prototype.constructor=r.RGBSplitFilter,Object.defineProperty(r.RGBSplitFilter.prototype,"angle",{get:function(){return this.uniforms.blur.value/(1/7e3)},set:function(t){this.uniforms.blur.value=1/7e3*t}}),void 0!==i?(void 0!==e&&e.exports&&(i=e.exports=r),i.PIXI=r):"undefined"!=typeof define&&define.amd?define(r):t.PIXI=r}).call(this)},{}],6:[function(t,e,i){function r(t,e,i,r){var n=i-t,o=r-e;return Math.sqrt(n*n+o*o)}var n=t("vecmath/lib/Vector2"),o=t("klasse"),s=t("interpolation").lerp,a=new n,h=new n,l=new o({initialize:function(){this.steps=1,this.points=[],this.approximateCurves=!0,this.approximationFactor=.5,this._move=new n,this._start=new n,this._hasMoved=!1,this._newPath=!0},reset:function(){this.points.length=0,this._newPath=!0,this._hasMoved=!1,this._move.x=this._move.y=0,this._start.x=this._start.y=0},beginPath:function(){this.reset()},moveTo:function(t,e){this._newPath=!0,this._move.x=t,this._move.y=e,this._start.x=t,this._start.y=e,this._hasMoved=!0},__newPoint:function(t,e){this.points.push(new n(t,e)),this._newPath=!1},closePath:function(t){0!==this.points.length&&this.lineTo(this._start.x,this._start.y,t)},lineTo:function(t,e,i){if(!this._hasMoved)return void this.moveTo(t,e);i=Math.max(1,i||this.steps);for(var r=0;r<=i;r++)if(this._newPath||0!=r){var n=r/i,o=s(this._move.x,t,n),a=s(this._move.y,e,n);this.__newPoint(o,a)}this._move.x=t,this._move.y=e},bezierCurveTo:function(t,e,i,n,o,s,a){this._hasMoved||this.moveTo(t,e);var h=this._move.x,l=this._move.y;if(!a)if(this.approximateCurves){var u=r(h,l,t,e),c=r(t,e,i,n),d=r(i,n,o,s);a=~~((u+c+d)*this.approximationFactor)}else a=Math.max(1,this.steps);for(var f=0;f<a;f++){var p=f/(a-1),g=1-p,v=g*g,m=v*g,x=p*p,y=x*p,b=m*h+3*v*p*t+3*g*x*i+y*o,T=m*l+3*v*p*e+3*g*x*n+y*s;this.__newPoint(b,T)}this._move.x=o,this._move.y=s},quadraticCurveTo:function(t,e,i,r,n){this._hasMoved||this.moveTo(t,e);var o=this._move.x,s=this._move.y;if(!n)if(this.approximateCurves){var l=a.set(o,s).distance(h.set(t,e)),u=a.set(t,e).distance(h.set(i,r));n=~~((l+u)*this.approximationFactor)}else n=Math.max(1,this.steps);for(var c=0;c<n;c++){var d=c/(n-1),f=1-d,p=f*f,g=d*d,v=p*o+2*f*d*t+g*i,m=p*s+2*f*d*e+g*r;this.__newPoint(v,m)}this._move.x=i,this._move.y=r},calculateBoundingBox:function(){for(var t=this.points,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,n=-Number.MAX_VALUE,o=0;o<t.length;o++){var s=t[o];e=Math.min(e,s.x),i=Math.min(i,s.y),r=Math.max(r,s.x),n=Math.max(n,s.y)}return{x:e,y:i,width:r-e,height:n-i}},contains:function(t,e){var i=t,r=e;"object"==typeof t&&(i=t.x,r=t.y);var n,o,s=this.points,a=s.length,h=0;for(n=0,o=a-1;n<a;o=n++)s[n].y>r!=s[o].y>r&&i<(s[o].x-s[n].x)*(r-s[n].y)/(s[o].y-s[n].y)+s[n].x&&(h=!h);return h},simplify:function(t,e){var i=this.points,r=i.length,o=new n,s=t*t,a=new n(i[0]);e||(e=new l);var h=[];h.push(a);for(var u=1;u<r;u++)o=i[u],o.distanceSq(a)>s&&(h.push(new n(o)),a=o);return a.x===o.x&&a.y===o.y||h.push(new n(o)),e.points=h,e}});e.exports=l},{interpolation:1,klasse:2,"vecmath/lib/Vector2":7}],7:[function(t,e,i){function r(t,e){"object"==typeof t?(this.x=t.x||0,this.y=t.y||0):(this.x=t||0,this.y=e||0)}var n=r.prototype;n.clone=function(){return new r(this.x,this.y)},n.copy=function(t){return this.x=t.x||0,this.y=t.y||0,this},n.set=function(t,e){return"object"==typeof t?(this.x=t.x||0,this.y=t.y||0):(this.x=t||0,this.y=e||0),this},n.add=function(t){return this.x+=t.x,this.y+=t.y,this},n.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},n.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},n.scale=function(t){return this.x*=t,this.y*=t,this},n.divide=function(t){return this.x/=t.x,this.y/=t.y,this},n.negate=function(){return this.x=-this.x,this.y=-this.y,this},n.distance=function(t){var e=t.x-this.x,i=t.y-this.y;return Math.sqrt(e*e+i*i)},n.distanceSq=function(t){var e=t.x-this.x,i=t.y-this.y;return e*e+i*i},n.length=function(){var t=this.x,e=this.y;return Math.sqrt(t*t+e*e)},n.lengthSq=function(){var t=this.x,e=this.y;return t*t+e*e},n.normalize=function(){var t=this.x,e=this.y,i=t*t+e*e;return i>0&&(i=1/Math.sqrt(i),this.x=t*i,this.y=e*i),this},n.dot=function(t){return this.x*t.x+this.y*t.y},n.cross=function(t){return this.x*t.y-this.y*t.x},n.lerp=function(t,e){var i=this.x,r=this.y;return e=e||0,this.x=i+e*(t.x-i),this.y=r+e*(t.y-r),this},n.transformMat3=function(t){var e=this.x,i=this.y,r=t.val;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[7],this},n.transformMat4=function(t){var e=this.x,i=this.y,r=t.val;return this.x=r[0]*e+r[4]*i+r[12],this.y=r[1]*e+r[5]*i+r[13],this},n.reset=function(){return this.x=0,this.y=0,this},n.sub=n.subtract,n.mul=n.multiply,n.div=n.divide,n.dist=n.distance,n.distSq=n.distanceSq,n.len=n.length,n.lenSq=n.lengthSq,n.toString=function(){return"Vector2("+this.x+", "+this.y+")"},n.random=function(t){t=t||1;var e=2*Math.random()*Math.PI;return this.x=Math.cos(e)*t,this.y=Math.sin(e)*t,this},n.str=n.toString,e.exports=r},{}],8:[function(t,e,i){"use strict";i.intFromBoolean=function(t){return t?1:0},i.booleanFromInt=function(t){return null!==t&&t>0}},{}],9:[function(t,e,i){"use strict";var r=t("../janicek/core"),n=r.def,o=function(t,e,i,s,a,h){var l={a:n(t,1),b:n(e,0),c:n(i,0),d:n(s,1),tx:n(a,0),ty:n(h,0),clone:function(){return o(l.a,l.b,l.c,l.d,l.tx,l.ty)},createGradientBox:function(t,e,i,n,o){if(l.a=t/1638.4,l.d=e/1638.4,r.isUndefinedOrNull(i)||0===i)l.b=l.c=0;else{var s=Math.cos(i),a=Math.sin(i);l.b=a*l.d,l.c=-a*l.a,l.a*=s,l.d*=s}l.tx=r.isUndefinedOrNull(n)?t/2:n+t/2,l.ty=r.isUndefinedOrNull(o)?e/2:o+e/2},setRotation:function(t,e){var i=r.isUndefinedOrNull(e)?1:e;l.a=Math.cos(t)*i,l.c=Math.sin(t)*i,l.b=-l.c,l.d=l.a},invert:function(){var t=l.a*l.d-l.b*l.c;if(0===t)l.a=l.b=l.c=l.d=0,l.tx=-l.tx,l.ty=-l.ty;else{t=1/t;var e=l.d*t;l.d=l.a*t,l.a=e,l.b*=-t,l.c*=-t;var i=-l.a*l.tx-l.c*l.ty;l.ty=-l.b*l.tx-l.d*l.ty,l.tx=i}return this},transformPoint:function(t){return{x:t.x*l.a+t.y*l.c+l.tx,y:t.x*l.b+t.y*l.d+l.ty}},translate:function(t,e){l.tx+=t,l.ty+=e},rotate:function(t){var e=Math.cos(t),i=Math.sin(t),r=l.a*e-l.b*i;l.b=l.a*i+l.b*e,l.a=r;var n=l.c*e-l.d*i;l.d=l.c*i+l.d*e,l.c=n;var o=l.tx*e-l.ty*i;l.ty=l.tx*i+l.ty*e,l.tx=o},scale:function(t,e){l.a*=t,l.b*=e,l.c*=t,l.d*=e,l.tx*=t,l.ty*=e},concat:function(t){var e=l.a*t.a+l.b*t.c;l.b=l.a*t.b+l.b*t.d,l.a=e;var i=l.c*t.a+l.d*t.c;l.d=l.c*t.b+l.d*t.d,l.c=i;var r=l.tx*t.a+l.ty*t.c+t.tx;l.ty=l.tx*t.b+l.ty*t.d+t.ty,l.tx=r},mult:function(t){var e=o();return e.a=l.a*t.a+l.b*t.c,e.b=l.a*t.b+l.b*t.d,e.c=l.c*t.a+l.d*t.c,e.d=l.c*t.b+l.d*t.d,e.tx=l.tx*t.a+l.ty*t.c+t.tx,e.ty=l.tx*t.b+l.ty*t.d+t.ty,e},identity:function(){l.a=1,l.b=0,l.c=0,l.d=1,l.tx=0,l.ty=0},toMozString:function(){var t="matrix(";return t+=l.a+", ",t+=l.b+", ",t+=l.c+", ",t+=l.d+", ",t+=l.tx+"px, ",t+=l.ty+"px)"},toString:function(){var t="matrix(";return t+=l.a+", ",t+=l.b+", ",t+=l.c+", ",t+=l.d+", ",t+=l.tx+", ",t+=l.ty+")"}};return l};e.exports=o},{"../janicek/core":19}],10:[function(t,e,i){"use strict";e.exports={distanceFromOrigin:function(t){return Math.sqrt(t.x*t.x+t.y*t.y)},distance:function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},interpolate:function(t,e,i){return{x:(t.x-e.x)*i+e.x,y:(t.y-e.y)*i+e.y}},normalize:function(t,e){if(0===t.x&&0===t.y)t.x=e;else{var i=e/Math.sqrt(t.x*t.x+t.y*t.y);t.x*=i,t.y*=i}},add:function(t,e){return{x:e.x+t.x,y:e.y+t.y}},subtract:function(t,e){return{x:t.x-e.x,y:t.y-e.y}},hash:function(t){return t.x+","+t.y}}},{}],11:[function(t,e,i){"use strict";e.exports=function(t,e,i,r){return{x:t||0,y:e||0,width:i||0,height:r||0}},e.exports.core=function(t){return{left:function(){return t.x},right:function(){return t.x+t.width},top:function(){return t.y},bottom:function(){return t.y+t.height}}}},{}],12:[function(t,e,i){"use strict";var r=t("../janicek/core").def,n=function(t,e,i,n){this.w=r(n,0),this.x=r(t,0),this.y=r(e,0),this.z=r(i,0)},o=function(t,e,i,r){return new n(t,e,i,r)};n.prototype={getLength:function(){return Math.abs(o.distance(this,o()))},get length(){return this.getLength()},getLengthSquared:function(){return this.length*this.length},get lengthSquared(){return this.getLengthSquared()},add:function(t){return o(this.x+t.x,this.y+t.y,this.z+t.z)},clone:function(){return o(this.x,this.y,this.z,this.w)},crossProduct:function(t){return o(this.y*t.z-this.z*t.y,this.z*t.x-this.x*t.z,this.x*t.y-this.y*t.x,1)},decrementBy:function(t){this.x-=t.x,this.y-=t.y,this.z-=t.z},dotProduct:function(t){return this.x*t.x+this.y*t.y+this.z*t.z},equals:function(t,e){return e=r(e,!1),this.x===t.x&&this.y===t.y&&this.z===t.z&&(!e||this.w===t.w)},incrementBy:function(t){this.x+=t.x,this.y+=t.y,this.z+=t.z},nearEquals:function(t,e,i){return i=r(i,!1),Math.abs(this.x-t.x)<e&&Math.abs(this.y-t.y)<e&&Math.abs(this.z-t.z)<e&&(!i||Math.abs(this.w-t.w)<e)},negate:function(){this.x*=-1,this.y*=-1,this.z*=-1},normalize:function(){var t=this.length;return 0!==t&&(this.x/=t,this.y/=t,this.z/=t),t},project:function(){this.x/=this.w,this.y/=this.w,this.z/=this.w},scaleBy:function(t){this.x*=t,this.y*=t,this.z*=t},subtract:function(t){return o(this.x-t.x,this.y-t.y,this.z-t.z)},toString:function(){return"Vector3D("+this.x+", "+this.y+", "+this.z+")"}},o.angleBetween=function(t,e){var i=t.clone();i.normalize();var r=e.clone();return r.normalize(),Math.acos(i.dotProduct(r))},o.distance=function(t,e){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z;return Math.sqrt(i*i+r*r+n*n)},Object.defineProperties(o,{X_AXIS:{get:function(){return o(1,0,0)}}}),Object.defineProperties(o,{Y_AXIS:{get:function(){return o(0,1,0)}}}),Object.defineProperties(o,{Z_AXIS:{get:function(){return o(0,0,1)}}}),e.exports=o},{"../janicek/core":19}],13:[function(t,e,i){"use strict";e.exports=function(){return{index:null,point:null,water:null,ocean:null,coast:null,border:null,biome:null,elevation:null,moisture:null,neighbors:null,borders:null,corners:null}}},{}],14:[function(t,e,i){"use strict";e.exports=function(){return{index:null,point:null,ocean:null,water:null,coast:null,border:null,elevation:null,moisture:null,touches:null,protrudes:null,adjacent:null,river:null,downslope:null,watershed:null,watershedSize:null}}},{}],15:[function(t,e,i){"use strict";e.exports=function(){return{index:0,d0:null,d1:null,v0:null,v1:null,midpoint:null,river:0}}},{}],16:[function(t,e,i){"use strict";var r=t("./janicek/array2d"),n=t("./janicek/core"),o=t("./as3/point-core").distanceFromOrigin,s=t("./janicek/perlin-noise"),a=t("./polygonal/pm-prng"),h=t("./janicek/pseudo-random-number-generators");i.makeRadial=function(t,e){function i(t){var i=Math.atan2(t.y,t.x),r=.5*(Math.max(Math.abs(t.x),Math.abs(t.y))+o(t)),n=.5+.4*Math.sin(h+s*i+Math.cos((s+3)*i)),a=.7-.2*Math.sin(h+s*i-Math.sin((s+2)*i));return(Math.abs(i-l)<u||Math.abs(i-l+2*Math.PI)<u||Math.abs(i-l-2*Math.PI)<u)&&(n=a=.2),r<n||r>n*e&&r<a}e=n.def(e,1.07);var r=a();r.seed=t;var s=r.nextIntRange(1,6),h=r.nextDoubleRange(0,2*Math.PI),l=r.nextDoubleRange(0,2*Math.PI),u=r.nextDoubleRange(.2,.7);return i},i.makePerlin=function(t,e){e=n.def(e,.5);e=.4*e+.1;var i=r(s.makePerlinNoise(256,256,1,1,1,t,8));return function(t){return(255&i.get(n.toInt(128*(t.x+1)),n.toInt(128*(t.y+1))))/255>e+e*o(t)*o(t)}},i.makeSquare=function(){return function(t){return!0}},i.makeBlob=function(){return function(t){var e=o({x:t.x-.2,y:t.y/2+.2})<.05,i=o({x:t.x+.2,y:t.y/2+.2})<.05;return o(t)<.8-.18*Math.sin(5*Math.atan2(t.y,t.x))&&!e&&!i}},i.makeBitmap=function(t){t=r(t);var e=t.dimensions();return function(i){var r=n.toInt((i.x+1)/2*e.x),o=n.toInt((i.y+1)/2*e.y);return t.get(r,o)}},i.makeNoise=function(t){return function(e){return t=h.nextParkMiller(t),h.toBool(t)}}},{"./as3/point-core":10,"./janicek/array2d":17,"./janicek/core":19,"./janicek/perlin-noise":23,"./janicek/pseudo-random-number-generators":24,"./polygonal/pm-prng":49}],17:[function(t,e,i){"use strict";var r=t("./core"),n=t("lodash");e.exports=function(t){return t=r.def(t,[]),{value:t,get:function(e,i){return n(t[i]).isUndefined()?null:t[i][e]},set:function(e,i,n){return t[i]=r.def(t[i],[]),t[i][e]=n,t},foreachY:function(e){n(t).each(function(t){n(t).isUndefined()||e(t)})},foreachXY:function(e){var i;for(i=0;i<t.length;i++)if(!n(t[i]).isUndefined()){var r;for(r=0;r<t[i].length;r++)if(!n(t[i][r]).isUndefined()){var o=t[i][r];null!==o&&e(r,i,o)}}},any:function(e){var i;for(i=0;i<t.length;i++)if(!n(t[i]).isUndefined()){var r;for(r=0;r<t[i].length;r++)if(!n(t[i][r]).isUndefined()){var o=t[i][r];if(null!==o&&e(o))return{x:r,y:i}}}return null},dimensions:function(){var e=t.length,i=0;return this.foreachY(function(t){i=Math.max(i,t.length)}),{x:i,y:e}}}},e.exports.getIndices=function(t,e,i){return i=i||1,{x:t/i%e,y:r.toInt(t/i/e)}}},{"./core":19,lodash:3}],18:[function(t,e,i){"use strict";var r=t("./array2d"),n=t("./core"),o=t("./html-color"),s=t("./math"),a=t("./pseudo-random-number-generators");i.renderCanvasPixelArray=function(t,e){for(var i,r=t.data,o=0;o<n.toInt(r.length/4);o++){i=4*o;var s=e(i,r[i+0],r[i+1],r[i+2],r[i+3]);null!==s&&(null!==s.red&&(r[i+0]=s.red),null!==s.green&&(r[i+1]=s.green),null!==s.blue&&(r[i+2]=s.blue),null!==s.alpha&&(r[i+3]=s.alpha))}},i.addNoise=function(t,e,r,o,h,l,u,c){o=n.def(o,!1),h=n.def(h,!0),l=n.def(l,!0),u=n.def(u,!0),c=n.def(c,!1);var d=a.randomGenerator(e,a.nextParkMiller);r=s.clamp(r,1,255);var f;return i.renderCanvasPixelArray(t,function(t,e,i,n,s){f=a.toIntRange(d(),-r,r);var p={red:null,green:null,blue:null,alpha:null};return h&&(p.red=e+f),l&&(p.green=i+(o?f:a.toIntRange(d(),-r,r))),u&&(p.blue=n+(o?f:a.toIntRange(d(),-r,r))),c&&(p.alpha=s+a.toIntRange(d(),-r,r)),p}),t},i.addNoiseToCanvas=function(t,e,r,o,s,a,h,l){o=n.def(o,!1),s=n.def(s,!0),a=n.def(a,!0),h=n.def(h,!0),l=n.def(l,!1);var u=t.getImageData(0,0,t.canvas.width,t.canvas.height);u=i.addNoise(u,e,r,o,s,a,h,l),t.putImageData(u,0,0)},i.loadFileIntoImage=function(t,e){var i=new FileReader;i.onload=function(t){e.src=t.target.result},i.readAsDataURL(t)},i.getImageData=function(t){var e=document.createElement("canvas");e.width=t.width,e.height=t.height;var i=e.getContext("2d");return i.drawImage(t,0,0),i.getImageData(0,0,e.width,e.height)},i.makeImageDataUrlFromImageData=function(t){var e=document.createElement("canvas");return e.width=t.width,e.height=t.height,e.getContext("2d").putImageData(t,0,0),e.toDataURL()},
  i.makeAverageThresholdImageData=function(t,e,r,a,h){h=n.def(h,1);var l=o.colorFraction(h);return i.renderCanvasPixelArray(t,function(t,i,n,h,u){var c=s.average([i,n,h])>=e?a:r;return{red:o.getRedComponent(c),green:o.getGreenComponent(c),blue:o.getBlueComponent(c),alpha:l}}),t},i.makeAverageThresholdBitmap=function(t,e){return e=s.clamp(e,0,255),i.makeBitmap(t,function(t,i,r,n){return s.average([t,i,r])>=e})},i.makeBitmap=function(t,e){var o=r([]),s=n.toInt(t.width);return i.renderCanvasPixelArray(t,function(t,i,n,a,h){var l=r.getIndices(t,s,4);return o.set(l.x,l.y,e(i,n,a,h)),null}),o.value},i.invertBitmap=function(t){var e=r(t);return e.foreachXY(function(t,i,r){e.set(t,i,!r)}),e.value}},{"./array2d":17,"./core":19,"./html-color":21,"./math":22,"./pseudo-random-number-generators":24}],19:[function(t,e,i){"use strict";var r=t("lodash");e.exports={def:function(t,e){return r.isUndefined(t)?e:t},toInt:function(t){return 0|t},coalesce:function(){return r.find(arguments,function(t){return!r.isNull(t)&&!r.isUndefined(t)})},isUndefinedOrNull:function(t){return r.isUndefined(t)||r.isNull(t)}}},{lodash:3}],20:[function(t,e,i){"use strict";i.djb2=function(t){var e,i=5381;for(e=0;e<t.length;e++)i=(i<<5)+i+t.charCodeAt(e);return i},i.sdbm=function(t){var e,i=0;for(e=0;e<t.length;e++)i=t.charCodeAt(e)+(i<<6)+(i<<16)-i;return i},i.javaHashCode=function(t){var e=0;if(0===t.length)return e;for(var i=0;i<t.length;i++)e=(e<<5)-e+t.charCodeAt(i),e&=e;return e}},{}],21:[function(t,e,i){"use strict";var r=t("./core");i.MAX_COLOR_COMPONENT=255,i.getRedComponent=function(t){return t>>16&255},i.getGreenComponent=function(t){return t>>8&255},i.getBlueComponent=function(t){return 255&t},i.interpolateColor=function(t,e,i){var n=r.toInt((1-i)*(t>>16)+i*(e>>16)),o=r.toInt((1-i)*(t>>8&255)+i*(e>>8&255)),s=r.toInt((1-i)*(255&t)+i*(255&e));return n>255&&(n=255),o>255&&(o=255),s>255&&(s=255),n<<16|o<<8|s},i.colorFraction=function(t){return r.toInt(i.MAX_COLOR_COMPONENT*t)},i.intToHexColor=function(t){return"#"+("00000"+t.toString(16).toUpperCase()).substr(-6)},i.rgb=function(t,e,i){return"rgb("+t+","+e+","+i+")"},i.rgba=function(t,e,i,r){return"rgba("+t+","+e+","+i+","+r+")"},i.rgbF=function(t,e,i){return"rgb("+100*t+"%,"+100*e+"%,"+100*i+"%)"},i.rgbaF=function(t,e,i,r){return"rgba("+100*t+"%,"+100*e+"%,"+100*i+"%,"+r+")"},i.hsl=function(t,e,i){return"hsl("+t+","+100*e+"%,"+100*i+"%)"},i.hsla=function(t,e,i,r){return"hsla("+t+","+100*e+"%,"+100*i+"%,"+r+")"}},{"./core":19}],22:[function(t,e,i){"use strict";var r=t("lodash");i.average=function(t){return r.reduce(t,function(t,e){return t+e})/r.size(t)},i.clamp=function(t,e,i){var r=Math.min(e,i),n=Math.max(e,i);return t<r?r:t>n?n:t}},{lodash:3}],23:[function(t,e,i){"use strict";var r=t("./array2d"),n=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180,151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];i.makePerlinNoise=function(t,e,i,o,s,a,h,l){a=a||666,h=h||4,l=l||.5;var u,c,d,f=a=16807*a%2147483647,p=a=16807*a%2147483647,g=a=16807*a%2147483647,v=[],m=[],x=0;for(d=0;d<h;d++)u=Math.pow(2,d),c=Math.pow(l,d),x+=c,v.push(u),m.push(c);x=1/x;var y=r([]),b=i*(1/64)+f;o=o*(1/64)+p,s=s*(1/64)+g;var T;for(T=0;T<e;T++){i=b;var S;for(S=0;S<t;S++){var _=0;for(d=0;d<h;d++){var w=v[d],E=m[d],C=i*w,A=o*w,R=s*w,M=C-C%1,L=A-A%1,F=R-R%1,B=255&M,I=255&L,P=255&F;C-=M,A-=L,R-=F;var O=C*C*C*(C*(6*C-15)+10),D=A*A*A*(A*(6*A-15)+10),G=R*R*R*(R*(6*R-15)+10),N=n[B]+I,k=n[N]+P,U=n[N+1]+P,j=n[B+1]+I,W=n[j]+P,V=n[j+1]+P,Y=C-1,X=A-1,z=R-1,H=15&n[V+1],q=(0==(1&H)?H<8?Y:X:H<8?-Y:-X)+(0==(2&H)?H<4?X:12===H?Y:z:H<4?-X:14===H?-Y:-z);H=15&n[U+1];var K=(0==(1&H)?H<8?C:X:H<8?-C:-X)+(0==(2&H)?H<4?X:12===H?C:z:H<4?-X:14===H?-C:-z);H=15&n[W+1];var Q=(0==(1&H)?H<8?Y:A:H<8?-Y:-A)+(0==(2&H)?H<4?A:12===H?Y:z:H<4?-A:14===H?-Y:-z);H=15&n[k+1];var J=(0==(1&H)?H<8?C:A:H<8?-C:-A)+(0==(2&H)?H<4?A:12===H?C:z:H<4?-A:14===H?-C:-z);H=15&n[V];var $=(0==(1&H)?H<8?Y:X:H<8?-Y:-X)+(0==(2&H)?H<4?X:12===H?Y:R:H<4?-X:14===H?-Y:-R);H=15&n[U];var Z=(0==(1&H)?H<8?C:X:H<8?-C:-X)+(0==(2&H)?H<4?X:12===H?C:R:H<4?-X:14===H?-C:-R);H=15&n[W];var tt=(0==(1&H)?H<8?Y:A:H<8?-Y:-A)+(0==(2&H)?H<4?A:12===H?Y:R:H<4?-A:14===H?-Y:-R);H=15&n[k];var et=(0==(1&H)?H<8?C:A:H<8?-C:-A)+(0==(2&H)?H<4?A:12===H?C:R:H<4?-A:14===H?-C:-R);K+=O*(q-K),J+=O*(Q-J),Z+=O*($-Z),et+=O*(tt-et),J+=D*(K-J),et+=D*(Z-et),_+=(et+G*(J-et))*E}var it=128*(_*x+1);y.set(S,T,4278190080|it<<16|it<<8|it),i+=1/64}o+=1/64}return y.value}},{"./array2d":17}],24:[function(t,e,i){"use strict";var r=t("./hash"),n=2147483647;i.makeRandomSeed=function(){return Math.floor(Math.random()*n)},i.nextParkMiller=function(t){return 16807*t%n},i.nextParkMiller31=function(t){var e=16807*(65535&t),i=16807*(t>>>16);return e+=(32767&i)<<16,e+=i>>>15,e>2147483647&&(e-=2147483647),e},i.nextLCG=function(t){return(1103515245*t+12345)%n},i.toFloat=function(t){return t/n},i.toBool=function(t){return i.toFloat(t)>.5},i.toFloatRange=function(t,e,r){return e+(r-e)*i.toFloat(t)},i.toIntRange=function(t,e,r){return Math.round(e-.4999+(r+.4999-(e-.4999))*i.toFloat(t))},i.stringToSeed=function(t){return r.djb2(t)%n},i.randomGenerator=function(t,e){return function(){return t=e(t)}}},{"./hash":20}],25:[function(t,e,i){"use strict";var r=t("lodash"),n=t("./as3/conversion-core");e.exports=function(){return{lava:[],createLava:function(t,e){r(t.edges).each(function(t){!n.booleanFromInt(t.river)&&!t.d0.water&&!t.d1.water&&t.d0.elevation>.8&&t.d1.elevation>.8&&t.d0.moisture<.3&&t.d1.moisture<.3&&e()<i.FRACTION_LAVA_FISSURES&&(this.lava[t.index]=!0)})}}},e.exports.FRACTION_LAVA_FISSURES=.2},{"./as3/conversion-core":8,lodash:3}],26:[function(t,e,i){"use strict";var r=t("lodash"),n=t("./map"),o={};o.countLands=function(t){return r(r(t).filter(function(t){return!t.water})).size()},o.tryMutateMapPointsToGetNumberLands=function(t,e,i,s){s=r.defaults(s||{},{timeoutMilliseconds:1e4,initialNumberOfPoints:i,lakeThreshold:n.DEFAULT_LAKE_THRESHOLD});var a=s.initialNumberOfPoints,h=Date.now(),l=!1;do{t.go0PlacePoints(a,e),t.go1BuildGraph(),t.go2AssignElevations(s.lakeThreshold);var u=o.countLands(t.centers);u===i?l=!0:a+=u<i?1:-1}while(!l&&Date.now()-h<s.timeoutMilliseconds);return t},e.exports=o},{"./map":27,lodash:3}],27:[function(t,e,i){"use strict";var r=t("lodash"),n=t("./graph/center"),o=t("./as3/conversion-core"),s=t("./janicek/core"),a=t("./graph/corner"),h=t("./graph/edge"),l=t("./as3/point-core"),u=t("./point-selector"),c=t("./polygonal/pm-prng"),d=t("./as3/rectangle"),f=t("./nodename/delaunay/voronoi"),p=function(t){var e={};return e.SIZE=t,e.islandShape=null,e.mapRandom=c(),e.needsMoreRandomness,e.points=[],e.centers=[],e.corners=[],e.edges=[],e.newIsland=function(t,i){e.islandShape=t,e.mapRandom.seed=i},e.go0PlacePoints=function(t,i){e.needsMoreRandomness=u.needsMoreRandomness(i),t=s.def(t,p.DEFAULT_NUMBER_OF_POINTS),e.reset(),e.points=i(t)},e.go1BuildGraph=function(){var t=f.make(e.points,null,d(0,0,e.SIZE.width,e.SIZE.height));e.buildGraph(e.points,t),e.improveCorners(),t.dispose(),t=null,e.points=null},e.go2AssignElevations=function(t){t=s.def(t,p.DEFAULT_LAKE_THRESHOLD),e.assignCornerElevations(),e.assignOceanCoastAndLand(t),e.redistributeElevations(e.landCorners(e.corners)),r(e.corners).each(function(t){(t.ocean||t.coast)&&(t.elevation=0)}),e.assignPolygonElevations()},e.go3AssignMoisture=function(t){t=s.def(t,null),e.calculateDownslopes(),e.calculateWatersheds(),e.createRivers(t),e.assignCornerMoisture(),e.redistributeMoisture(e.landCorners(e.corners)),e.assignPolygonMoisture()},e.go4DecorateMap=function(){e.assignBiomes()},e.reset=function(){null!==e.points&&e.points.splice(0,e.points.length),null!==e.edges&&(r(e.edges).each(function(t){t.d0=t.d1=null,t.v0=t.v1=null}),e.edges.splice(0,e.edges.length)),null!==e.centers&&(r(e.centers).each(function(t){t.neighbors.splice(0,t.neighbors.length),t.corners.splice(0,t.corners.length),t.borders.splice(0,t.borders.length)}),e.centers.splice(0,e.centers.length)),null!==e.corners&&(r(e.corners).each(function(t){t.adjacent.splice(0,t.adjacent.length),t.touches.splice(0,t.touches.length),t.protrudes.splice(0,t.protrudes.length),t.downslope=null,t.watershed=null}),e.corners.splice(0,e.corners.length)),null===e.points&&(e.points=[]),null===e.edges&&(e.edges=[]),null===e.centers&&(e.centers=[]),null===e.corners&&(e.corners=[])},e.improveCorners=function(){var t,i,n=[];for(r(e.corners).each(function(e){e.border?n[e.index]=e.point:(t={x:0,y:0},r(e.touches).each(function(e){t.x+=e.point.x,t.y+=e.point.y}),t.x/=e.touches.length,t.y/=e.touches.length,n[e.index]=t)}),i=0;i<e.corners.length;i++)e.corners[i].point=n[i];r(e.edges).each(function(t){null!==t.v0&&null!==t.v1&&(t.midpoint=l.interpolate(t.v0.point,t.v1.point,.5))})},e.landCorners=function(t){var e=[];return r(t).each(function(t){t.ocean||t.coast||e.push(t)}),e},e.buildGraph=function(t,i){function o(t){var i;if(null===t)return null;var r;for(r=s.toInt(t.x)-1;r<s.toInt(t.x)+2;r++)if(!s.isUndefinedOrNull(g[r]))for(var n=0;n<g[r].length;n++){i=g[r][n];var o=t.x-i.point.x,h=t.y-i.point.y;if(o*o+h*h<1e-6)return i}return r=s.toInt(t.x),s.isUndefinedOrNull(g[r])&&(g[r]=[]),i=a(),i.index=e.corners.length,e.corners.push(i),i.point=t,i.border=0===t.x||t.x===e.SIZE.width||0===t.y||t.y===e.SIZE.height,i.touches=[],i.protrudes=[],i.adjacent=[],g[r].push(i),i}function u(t,e){null!==e&&t.indexOf(e)<0&&t.push(e)}function c(t,e){null!==e&&t.indexOf(e)<0&&t.push(e)}var d,f=i.edges(),p={};r(t).each(function(t){d=n(),d.index=e.centers.length,d.point=t,d.neighbors=[],d.borders=[],d.corners=[],e.centers.push(d),p[l.hash(t)]=d}),r(e.centers).each(function(t){i.region(t.point)});var g=[];r(f).each(function(t){var i=t.delaunayLine(),r=t.voronoiEdge(),n=h();n.index=e.edges.length,n.river=0,e.edges.push(n),n.midpoint=null!==r.p0&&null!==r.p1?l.interpolate(r.p0,r.p1,.5):null,n.infinite=!1,null===n.midpoint&&(n.infinite=!0),n.v0=o(r.p0),n.v1=o(r.p1),n.d0=p[l.hash(i.p0)],n.d1=p[l.hash(i.p1)],null!==n.d0&&n.d0.borders.push(n),null!==n.d1&&n.d1.borders.push(n),null!==n.v0&&n.v0.protrudes.push(n),null!==n.v1&&n.v1.protrudes.push(n),null!==n.d0&&null!==n.d1&&(c(n.d0.neighbors,n.d1),c(n.d1.neighbors,n.d0)),null!==n.v0&&null!==n.v1&&(u(n.v0.adjacent,n.v1),u(n.v1.adjacent,n.v0)),null!==n.d0&&(u(n.d0.corners,n.v0),u(n.d0.corners,n.v1)),null!==n.d1&&(u(n.d1.corners,n.v0),u(n.d1.corners,n.v1)),null!==n.v0&&(c(n.v0.touches,n.d0),c(n.v0.touches,n.d1)),null!==n.v1&&(c(n.v1.touches,n.d0),c(n.v1.touches,n.d1))})},e.assignCornerElevations=function(){var t=[];for(r(e.corners).each(function(t){t.water=!e.inside(t.point)}),r(e.corners).each(function(e){e.border?(e.elevation=0,t.push(e)):e.elevation=Number.POSITIVE_INFINITY});t.length>0;)for(var i=t.shift(),n=0;n<i.adjacent.length;n++){var o=i.adjacent[n],s=.01+i.elevation;i.water||o.water||(s+=1,e.needsMoreRandomness&&(s+=e.mapRandom.nextDouble())),s<o.elevation&&(o.elevation=s,t.push(o))}},e.redistributeElevations=function(t){var e,i,r;for(t.sort(function(t,e){return t.elevation>e.elevation?1:t.elevation<e.elevation?-1:t.index>e.index?1:t.index<e.index?-1:0}),e=0;e<t.length;e++)i=e/(t.length-1),r=Math.sqrt(1.1)-Math.sqrt(1.1*(1-i)),r>1&&(r=1),t[e].elevation=r},e.redistributeMoisture=function(t){var e;for(t.sort(function(t,e){return t.moisture>e.moisture?1:t.moisture<e.moisture?-1:t.index>e.index?1:t.index<e.index?-1:0}),e=0;e<t.length;e++)t[e].moisture=e/(t.length-1)},e.assignOceanCoastAndLand=function(t){var i,n,s=[];for(r(e.centers).each(function(e){n=0,r(e.corners).each(function(t){t.border&&(e.border=!0,s.push(e)),t.water&&(n+=1)}),e.water=e.ocean||n>=e.corners.length*t});s.length>0;){i=s.shift();for(var a=0;a<i.neighbors.length;a++){var h=i.neighbors[a];h.water&&!h.ocean&&(h.ocean=!0,s.push(h))}}r(e.centers).each(function(t){var e=0,i=0;r(t.neighbors).each(function(t){e+=o.intFromBoolean(t.ocean),i+=o.intFromBoolean(!t.water)}),t.coast=e>0&&i>0}),r(e.corners).each(function(t){var e=0,i=0;r(t.touches).each(function(t){e+=o.intFromBoolean(t.ocean),i+=o.intFromBoolean(!t.water)}),t.ocean=e===t.touches.length,t.coast=e>0&&i>0,t.water=i!==t.touches.length&&!t.coast})},e.assignPolygonElevations=function(){var t;r(e.centers).each(function(e){t=0,r(e.corners).each(function(e){t+=e.elevation}),e.elevation=t/e.corners.length})},e.calculateDownslopes=function(){var t;r(e.corners).each(function(e){t=e,r(e.adjacent).each(function(e){e.elevation<=t.elevation&&(t=e)}),e.downslope=t})},e.calculateWatersheds=function(){var t,i,n;r(e.corners).each(function(t){t.watershed=t,t.ocean||t.coast||(t.watershed=t.downslope)});var o,s;for(i=0;i<100;i++){for(n=!1,o=0;o<e.corners.length;o++)s=e.corners[o],s.ocean||s.coast||s.watershed.coast||(t=s.downslope.watershed,t.ocean||(s.watershed=t),n=!0);if(!n)break}for(o=0;o<e.corners.length;o++)s=e.corners[o],t=s.watershed,t.watershedSize=1+(t.watershedSize||0)},e.createRivers=function(t){t=s.coalesce(t,s.toInt((e.SIZE.width+e.SIZE.height)/4));var i,r,n;for(i=0;i<t;i++)if(r=e.corners[e.mapRandom.nextIntRange(0,e.corners.length-1)],!(r.ocean||r.elevation<.3||r.elevation>.9))for(;!r.coast&&r!==r.downslope;)n=e.lookupEdgeFromCorner(r,r.downslope),n.river=n.river+1,r.river=(r.river||0)+1,r.downslope.river=(r.downslope.river||0)+1,r=r.downslope},e.assignCornerMoisture=function(){var t,i,n=[];for(r(e.corners).each(function(t){(t.water||t.river>0)&&!t.ocean?(t.moisture=t.river>0?Math.min(3,.2*t.river):1,n.push(t)):t.moisture=0});n.length>0;){t=n.shift();for(var o=0;o<t.adjacent.length;o++){var s=t.adjacent[o];i=.9*t.moisture,i>s.moisture&&(s.moisture=i,n.push(s))}}r(e.corners).each(function(t){(t.ocean||t.coast)&&(t.moisture=1)})},e.assignPolygonMoisture=function(){var t;r(e.centers).each(function(e){t=0,r(e.corners).each(function(e){e.moisture>1&&(e.moisture=1),t+=e.moisture}),e.moisture=t/e.corners.length})},e.assignBiomes=function(){r(e.centers).each(function(t){t.biome=p.getBiome(t)})},e.lookupEdgeFromCenter=function(t,e){for(var i=0;i<t.borders.length;i++){var r=t.borders[i];if(r.d0===e||r.d1===e)return r}return null},e.lookupEdgeFromCorner=function(t,e){for(var i=0;i<t.protrudes.length;i++){var r=t.protrudes[i];if(r.v0===e||r.v1===e)return r}return null},e.inside=function(t){return e.islandShape({x:2*(t.x/e.SIZE.width-.5),y:2*(t.y/e.SIZE.height-.5)})},e.reset(),e};p.DEFAULT_LAKE_THRESHOLD=.3,p.DEFAULT_LLOYD_ITERATIONS=2,p.DEFAULT_NUMBER_OF_POINTS=1e3,p.getBiome=function(t){return t.ocean?"OCEAN":t.water?t.elevation<.1?"MARSH":t.elevation>.8?"ICE":"LAKE":t.coast?"BEACH":t.elevation>.8?t.moisture>.5?"SNOW":t.moisture>.33?"TUNDRA":t.moisture>.16?"BARE":"SCORCHED":t.elevation>.6?t.moisture>.66?"TAIGA":t.moisture>.33?"SHRUBLAND":"TEMPERATE_DESERT":t.elevation>.3?t.moisture>.83?"TEMPERATE_RAIN_FOREST":t.moisture>.5?"TEMPERATE_DECIDUOUS_FOREST":t.moisture>.16?"GRASSLAND":"TEMPERATE_DESERT":t.moisture>.66?"TROPICAL_RAIN_FOREST":t.moisture>.33?"TROPICAL_SEASONAL_FOREST":t.moisture>.16?"GRASSLAND":"SUBTROPICAL_DESERT"},e.exports=p},{"./as3/conversion-core":8,"./as3/point-core":10,"./as3/rectangle":11,"./graph/center":13,"./graph/corner":14,"./graph/edge":15,"./janicek/core":19,"./nodename/delaunay/voronoi":42,"./point-selector":48,"./polygonal/pm-prng":49,lodash:3}],28:[function(t,e,i){"use strict";e.exports={TOP:1,BOTTOM:2,LEFT:4,RIGHT:8,check:function(e,i){i=t("../../as3/rectangle").core(i);var r=0;return e.x===i.left()&&(r|=this.LEFT),e.x===i.right()&&(r|=this.RIGHT),e.y===i.top()&&(r|=this.TOP),e.y===i.bottom()&&(r|=this.BOTTOM),r}}},{"../../as3/rectangle":11}],29:[function(t,e,i){"use strict";e.exports={vertex:"vertex",site:"site"}},{}],30:[function(t,e,i){"use strict";var r=t("lodash");e.exports={delaunayLinesForEdges:function(t){var e=[];return r(t).each(function(t){e.push(t.delaunayLine())}),e},selectEdgesForSitePoint:function(t,e){return r(e).filter(function(e){return null!==e.leftSite&&e.leftSite.coord===t||null!==e.rightSite&&e.rightSite.coord===t})},selectNonIntersectingEdges:function(t,e){if(null===t)return e;var i={x:0,y:0};return r(e).filter(function(e){var r=e.makeDelaunayLineBmp(),n=!t.hitTest(i,1,r,i,1);return r.dispose(),n})},visibleLineSegments:function(e){var i=t("./lr"),n=t("../geom/line-segment"),o=[];return r(e).each(function(t){if(t.visible){var e=t.clippedEnds[i.LEFT],r=t.clippedEnds[i.RIGHT];o.push(n(e,r))}}),o}}},{"../geom/line-segment":44,"./lr":37,lodash:3}],31:[function(t,e,i){"use strict";var r=t("./halfedge"),n=t("./edge");e.exports=function(t,e,i){function o(t){var e;return t<0||t>=l?null:(e=u[t],null!==e&&e.edge===n.DELETED?(u[t]=null,null):e)}var s={},a=0,h=0,l=0,u=[],c=null;s.getLeftEnd=function(){return c},Object.defineProperties(s,{leftEnd:{get:function(){return s.getLeftEnd()}}});var d=null;return s.getRightEnd=function(){return d},Object.defineProperties(s,{rightEnd:{get:function(){return s.getRightEnd()}}}),s.dispose=function(){for(var t,e=c;e!==d;)t=e,e=e.edgeListRightNeighbor,t.dispose();c=null,d.dispose(),d=null;var i;for(i=0;i<l;i++)u[i]=null;u=null},s.insert=function(t,e){e.edgeListLeftNeighbor=t,e.edgeListRightNeighbor=t.edgeListRightNeighbor,t.edgeListRightNeighbor.edgeListLeftNeighbor=e,t.edgeListRightNeighbor=e},s.remove=function(t){t.edgeListLeftNeighbor.edgeListRightNeighbor=t.edgeListRightNeighbor,t.edgeListRightNeighbor.edgeListLeftNeighbor=t.edgeListLeftNeighbor,t.edge=n.DELETED,t.edgeListLeftNeighbor=t.edgeListRightNeighbor=null},s.edgeListLeftNeighbor=function(t){var e,i;if(e=(t.x-h)/a*l,e<0&&(e=0),e>=l&&(e=l-1),null===(i=o(e)))for(var r=1;;){if(null!==(i=this.getHash(e-r)))break;if(null!==(i=this.getHash(e+r)))break;r++}if(i===this.getLeftEnd()||i!==this.getRightEnd()&&i.isLeftOf(t)){do{i=i.edgeListRightNeighbor}while(i!==this.getRightEnd()&&i.isLeftOf(t));i=i.edgeListLeftNeighbor}else do{i=i.edgeListLeftNeighbor}while(i!==this.getLeftEnd()&&!i.isLeftOf(t));return e>0&&e<l-1&&(u[e]=i),i},h=t,a=e,l=2*i,u=[],c=r.createDummy(),d=r.createDummy(),c.edgeListLeftNeighbor=null,c.edgeListRightNeighbor=d,d.edgeListLeftNeighbor=c,d.edgeListRightNeighbor=null,u[0]=c,u[l-1]=d,s}},{"./edge":33,"./halfedge":35}],32:[function(t,e,i){"use strict";var r=t("./criterion"),n=t("./lr"),o=t("./vertex"),s=function(t,e){if(e!==r.vertex&&e!==r.site)throw"Edges: criterion must be Vertex or Site";this.edges=[],this.edgeOrientations=[],t.length>0&&(this.edges=this._reorderEdges(t,e))};s.prototype={edges:null,edgeOrientations:null,dispose:function(){this.edges=null,this.edgeOrientations=null},_reorderEdges:function(t,e){var i,s,a=t.length,h=[],l=0,u=[];i=0,s=t[i],u.push(s),this.edgeOrientations.push(n.LEFT);var c,d;if(e===r.vertex?(c=s.leftVertex,d=s.rightVertex):(c=s.leftSite,d=s.rightSite),c===o.VERTEX_AT_INFINITY||d===o.VERTEX_AT_INFINITY)return[];for(h[i]=!0,++l;l<a;)for(i=1;i<a;i++)if(!h[i]){s=t[i];var f,p;if(e===r.vertex?(f=s.leftVertex,p=s.rightVertex):(f=s.leftSite,p=s.rightSite),f===o.VERTEX_AT_INFINITY||p===o.VERTEX_AT_INFINITY)return[];f===d?(d=p,this.edgeOrientations.push(n.LEFT),u.push(s),h[i]=!0):p===c?(c=f,this.edgeOrientations.unshift(n.LEFT),u.unshift(s),h[i]=!0):f===c?(c=p,this.edgeOrientations.unshift(n.RIGHT),u.unshift(s),h[i]=!0):p===d&&(d=f,this.edgeOrientations.push(n.RIGHT),u.push(s),h[i]=!0),h[i]&&++l}return u}},e.exports=function(t,e){return new s(t,e)}},{"./criterion":29,"./lr":37,"./vertex":41}],33:[function(t,e,i){"use strict";function r(){var t;return h.length>0?(t=h.pop(),t.init()):t=new i.Edge,t}var n=t("../geom/line-segment"),o=t("./lr"),s=t("../../as3/point-core"),a=t("../../as3/rectangle"),h=[],l=0;i.Edge=function(){this._edgeIndex=l++,this.init()},i.Edge.prototype={_delaunayLineBmp:null,getDelaunayLineBmp:function(){return null===this._delaunayLineBmp&&(this._delaunayLineBmp=this.makeDelaunayLineBmp()),this._delaunayLineBmp},get delaunayLineBmp(){return this.getDelaunayLineBmp()},makeDelaunayLineBmp:function(){throw"unimplemented"},delaunayLine:function(){return n(this.leftSite.coord,this.rightSite.coord)},voronoiEdge:function(){return this.visible?n(this.clippedEnds[o.LEFT],this.clippedEnds[o.RIGHT]):n(null,null)},a:null,b:null,c:null,leftVertex:null,rightVertex:null,vertex:function(t){return t===o.LEFT?this.leftVertex:this.rightVertex},setVertex:function(t,e){t===o.LEFT?this.leftVertex=e:this.rightVertex=e},isPartOfConvexHull:function(){return null===this.leftVertex||null===this.rightVertex},sitesDistance:function(){return s.distance(this.leftSite.coord,this.rightSite.coord)},clippedEnds:null,get visible(){return null!==this.clippedEnds},leftSite:null,rightSite:null,site:function(t){return t===o.LEFT?this.leftSite:this.rightSite},_edgeIndex:0,dispose:function(){null!==this._delaunayLineBmp&&(this._delaunayLineBmp.dispose(),this._delaunayLineBmp=null),this.leftVertex=null,this.rightVertex=null,null!==this.clippedEnds&&(this.clippedEnds[o.LEFT]=null,this.clippedEnds[o.RIGHT]=null,this.clippedEnds=null),this.leftSite=null,this.rightSite=null,h.push(this)},toString:function(){return"Edge "+this._edgeIndex+"; sites "+this.leftSite+", "+this.rightSite+"; endVertices "+(null!==this.leftVertex?String(this.leftVertex.vertexIndex):"null")+", "+(null!==this.rightVertex?String(this.rightVertex.vertexIndex):"null")+"::"},clipVertices:function(t){var e,i,r,n,s,h,l=a.core(t),u=t.x,c=t.y,d=l.right(),f=l.bottom();if(1===this.a&&this.b>=0?(e=this.rightVertex,i=this.leftVertex):(e=this.leftVertex,i=this.rightVertex),1===this.a){if(s=c,null!==e&&e.y>c&&(s=e.y),s>f)return;if(r=this.c-this.b*s,h=f,null!==i&&i.y<f&&(h=i.y),h<c)return;if(n=this.c-this.b*h,r>d&&n>d||r<u&&n<u)return;r>d?(r=d,s=(this.c-r)/this.b):r<u&&(r=u,s=(this.c-r)/this.b),n>d?(n=d,h=(this.c-n)/this.b):n<u&&(n=u,h=(this.c-n)/this.b)}else{if(r=u,null!==e&&e.x>u&&(r=e.x),r>d)return;if(s=this.c-this.a*r,n=d,null!==i&&i.x<d&&(n=i.x),n<u)return;if(h=this.c-this.a*n,s>f&&h>f||s<c&&h<c)return;s>f?(s=f,r=(this.c-s)/this.a):s<c&&(s=c,r=(this.c-s)/this.a),h>f?(h=f,n=(this.c-h)/this.a):h<c&&(h=c,n=(this.c-h)/this.a)}this.clippedEnds={},e===this.leftVertex?(this.clippedEnds[o.LEFT]={x:r,y:s},this.clippedEnds[o.RIGHT]={x:n,y:h}):(this.clippedEnds[o.RIGHT]={x:r,y:s},this.clippedEnds[o.LEFT]={x:n,y:h})},init:function(){this.leftSite=null,this.rightSite=null}},i.DELETED=new i.Edge,i.createBisectingEdge=function(t,e){var i,n,o,s,a,h,l;i=e.x-t.x,n=e.y-t.y,o=i>0?i:-i,s=n>0?n:-n,l=t.x*i+t.y*n+.5*(i*i+n*n),o>s?(a=1,h=n/i,l/=i):(h=1,a=i/n,l/=n);var u=r();return u.leftSite=t,u.rightSite=e,t.addEdge(u),e.addEdge(u),u.leftVertex=null,u.rightVertex=null,u.a=a,u.b=h,u.c=l,u},i.compareSitesDistancesMax=function(t,e){var i=t.sitesDistance(),r=e.sitesDistance();return i<r?1:i>r?-1:0},i.compareSitesDistances=function(t,e){return-i.compareSitesDistancesMax(t,e)}},{"../../as3/point-core":10,"../../as3/rectangle":11,"../geom/line-segment":44,"./lr":37}],34:[function(t,e,i){"use strict";var r=t("./halfedge"),n=t("../../janicek/core");e.exports=function(t,e,i){function o(t){var e=n.toInt((t.ystar-f)/p*d);return e<0&&(e=0),e>=d&&(e=d-1),e}function s(t){return null===l[t].nextInPriorityQueue}function a(){for(;c<d-1&&s(c);)++c}var h={},l=null,u=0,c=0,d=0,f=0,p=0;return h.dispose=function(){var t;for(t=0;t<d;t++)l[t].dispose(),l[t]=null;l=null},h.insert=function(t){var e,i,r=o(t);for(r<c&&(c=r),e=l[r];null!==(i=e.nextInPriorityQueue)&&(t.ystar>i.ystar||t.ystar===i.ystar&&t.vertex.x>i.vertex.x);)e=i;t.nextInPriorityQueue=e.nextInPriorityQueue,e.nextInPriorityQueue=t,++u},h.remove=function(t){var e,i=o(t);if(null!==t.vertex){for(e=l[i];e.nextInPriorityQueue!==t;)e=e.nextInPriorityQueue;e.nextInPriorityQueue=t.nextInPriorityQueue,u--,t.vertex=null,t.nextInPriorityQueue=null,t.dispose()}},h.empty=function(){return 0===u},h.min=function(){a();var t=l[c].nextInPriorityQueue;return{x:t.vertex.x,y:t.ystar}},h.extractMin=function(){var t;return t=l[c].nextInPriorityQueue,l[c].nextInPriorityQueue=t.nextInPriorityQueue,u--,t.nextInPriorityQueue=null,t},f=t,p=e,d=4*i,function(){var t;for(u=0,c=0,l=[],t=0;t<d;t++)l[t]=r.createDummy(),l[t].nextInPriorityQueue=null}(),h}},{"../../janicek/core":19,"./halfedge":35}],35:[function(t,e,i){"use strict";var r=t("../../janicek/core").def,n=t("./lr"),o=[],s=function(t,e){t=r(t,null),e=r(e,null),this.init(t,e)};s.prototype={edgeListLeftNeighbor:null,edgeListRightNeighbor:null,nextInPriorityQueue:null,edge:null,leftRight:null,vertex:null,ystar:0,toString:function(){return"Halfedge (leftRight: "+this.leftRight+"; vertex: "+this.vertex+")"},dispose:function(){null===this.edgeListLeftNeighbor&&null===this.edgeListRightNeighbor&&null===this.nextInPriorityQueue&&(this.edge=null,this.leftRight=null,this.vertex=null,o.push(this))},reallyDispose:function(){this.edgeListLeftNeighbor=null,this.edgeListRightNeighbor=null,this.nextInPriorityQueue=null,this.edge=null,this.leftRight=null,this.vertex=null,o.push(this)},isLeftOf:function(t){var e,i,r,o,s,a,h,l,u,c,d;return e=this.edge.rightSite,(i=t.x>e.x)&&this.leftRight===n.LEFT||!(!i&&this.leftRight===n.RIGHT)&&(1===this.edge.a?(a=t.y-e.y,s=t.x-e.x,o=!1,!i&&this.edge.b<0||i&&this.edge.b>=0?(r=a>=this.edge.b*s,o=r):(r=t.x+t.y*this.edge.b>this.edge.c,this.edge.b<0&&(r=!r),r||(o=!0)),o||(h=e.x-this.edge.leftSite.x,r=this.edge.b*(s*s-a*a)<h*a*(1+2*s/h+this.edge.b*this.edge.b),this.edge.b<0&&(r=!r))):(d=this.edge.c-this.edge.a*t.x,l=t.y-d,u=t.x-e.x,c=d-e.y,r=l*l>u*u+c*c),this.leftRight===n.LEFT?r:!r)},init:function(t,e){return this.edge=t,this.leftRight=e,this.nextInPriorityQueue=null,this.vertex=null,this}},i.create=function(t,e){return o.length>0?o.pop().init(t,e):new s(t,e)},i.createDummy=function(){return i.create(null,null)}},{"../../janicek/core":19,"./lr":37}],36:[function(t,e,i){"use strict";var r=t("lodash"),n=t("../../janicek/core").def,o=t("../geom/line-segment").core,s=t("./node"),a=t("../../as3/point-core");i.find=function(t){if(t.parent===t)return t;var e=i.find(t.parent);return t.parent=e,e},i.kruskal=function(t,e){e=n(e,"minimum");var h={},l=[],u=[];switch(e){case"maximum":t.sort(o.compareLengths);break;default:t.sort(o.compareLengthsMax)}for(var c=t.length-1;c>=0;){var d=t[c];c--;var f,p=h[a.hash(d.p0)];null===p?(p=u.length>0?u.pop():s(),f=p.parent=p,p.treeSize=1,h[a.hash(d.p0)]=p):f=i.find(p);var g,v=h[a.hash(d.p1)];if(null===v?(v=u.length>0?u.pop():s(),g=v.parent=v,v.treeSize=1,h[a.hash(d.p1)]=v):g=i.find(v),f!==g){l.push(d);var m=f.treeSize,x=g.treeSize;m>=x?(g.parent=f,f.treeSize+=x):(f.parent=g,g.treeSize+=m)}}return r(h).each(function(t){u.push(t)}),l}},{"../../as3/point-core":10,"../../janicek/core":19,"../geom/line-segment":44,"./node":38,lodash:3}],37:[function(t,e,i){"use strict";e.exports={LEFT:"left",RIGHT:"right",other:function(t){return t===this.LEFT?this.RIGHT:this.LEFT}}},{}],38:[function(t,e,i){"use strict";e.exports=function(){return{parent:null,treeSize:0}},e.exports.pool=[]},{}],39:[function(t,e,i){"use strict";var r=t("lodash"),n=t("../geom/circle"),o=t("../../janicek/core").def,s=t("../../as3/rectangle"),a=t("./site");e.exports=function(){var t=[],e=0,i=!1,h={};return h.dispose=function(){null!==t&&(r(t).each(function(t){t.dispose()}),t=null)},h.push=function(e){return i=!1,t.push(e)},Object.defineProperties(h,{length:{get:function(){return t.length}}}),h.next=function(){if(!1===i)throw"SiteList::next():  sites have not been sorted";return e<t.length?t[e++]:null},h.getSitesBounds=function(){!1===i&&(a.sortSites(t),e=0,i=!0);var n,o,h,l;return 0===t.length?s(0,0,0,0):(n=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,r(t).each(function(t){t.x<n&&(n=t.x),t.x>o&&(o=t.x)}),h=t[0].y,l=t[t.length-1].y,s(n,h,o-n,l-h))},h.siteColors=function(e){e=o(e,null);var i=[];return r(t).each(function(t){i.push(null!==e?e.getPixel(t.x,t.y):t.color)}),i},h.siteCoords=function(){var e=[];return r(t).each(function(t){e.push(t.coord)}),e},h.circles=function(){var e=[];return r(t).each(function(t){var i=t.nearestEdge(),r=i.isPartOfConvexHull()?0:.5*i.sitesDistance();e.push(n(t.x,t.y,r))}),e},h.regions=function(e){var i=[];return r(t).each(function(t){i.push(t.region(e))}),i},h.nearestSitePoint=function(e,i,r){var n=e.getPixel(i,r);return n>t.length-1?null:t[n].coord},h}},{"../../as3/rectangle":11,"../../janicek/core":19,"../geom/circle":43,"./site":40,lodash:3}],40:[function(t,e,i){"use strict";function r(t,e){return c.distance(t,e)<m}var n=t("lodash"),o=t("./bounds-check"),s=t("./criterion"),a=t("../../janicek/core").def,h=t("./edge"),l=t("./edge-reorderer"),u=t("./lr"),c=t("../../as3/point-core"),d=t("../geom/polygon"),f=t("../../as3/rectangle").core,p=t("./voronoi"),g=t("../geom/winding"),v=[],m=.005,x=function(t,e,i,r){this.init(t,e,i,r)};x.prototype={_coord:null,get coord(){return this._coord},color:0,weight:0,_siteIndex:0,_edges:null,get edges(){return this._edges},_edgeOrientations:null,_region:null,init:function(t,e,i,r){return this._coord=t,this._siteIndex=e,this.weight=i,this.color=r,this._edges=[],this._region=null,this},toString:function(){return"Site "+this._siteIndex+": "+String(this.coord)},dispose:function(){this._coord=null,this._clear(),v.push(this)},_clear:function(){null!==this._edges&&(this._edges=null),null!==this._edgeOrientations&&(this._edgeOrientations=null),null!==this._region&&(this._region=null)},addEdge:function(t){this._edges.push(t)},nearestEdge:function(){return this._edges.sort(h.compareSitesDistances),this._edges[0]},neighborSites:function(){if(null===this._edges||0===this._edges.length)return[];null===this._edgeOrientations&&this._reorderEdges();var t=[];return n.each(this._edges,function(e){t.push(this._neighborSite(e))}),t},_neighborSite:function(t){return this===t.leftSite?t.rightSite:this===t.rightSite?t.leftSite:null},region:function(t){return null===this._edges||0===this._edges.length?[]:(null===this._edgeOrientations&&(this._reorderEdges(),this._region=this._clipToBounds(t),d(this._region).winding()===g.CLOCKWISE&&this._region.reverse()),this._region)},_reorderEdges:function(){var t=l(this._edges,s.vertex);this._edges=t.edges,this._edgeOrientations=t.edgeOrientations,t.dispose()},_clipToBounds:function(t){for(var e=[],i=this._edges.length,r=0,n=null;r<i&&!1===this._edges[r].visible;)++r;if(r===i)return[];n=this._edges[r];var o=this._edgeOrientations[r];e.push(n.clippedEnds[o]),e.push(n.clippedEnds[u.other(o)]);for(var s=r+1;s<i;s++)n=this._edges[s],!1!==n.visible&&this._connect(e,s,t);return this._connect(e,r,t,!0),e},_connect:function(t,e,i,n){n=a(n,!1)
  ;var s=t[t.length-1],h=this._edges[e],l=this._edgeOrientations[e],c=h.clippedEnds[l];if(!r(s,c)){if(s.x!==c.x&&s.y!==c.y){var d,p,g=o.check(s,i),v=o.check(c,i);0!=(g&o.RIGHT)?(d=f(i).right(),0!=(v&o.BOTTOM)?(p=f(i).bottom(),t.push({x:d,y:p})):0!=(v&o.TOP)?(p=f(i).top(),t.push({x:d,y:p})):0!=(v&o.LEFT)&&(p=s.y-i.y+c.y-i.y<i.height?f(i).top():f(i).bottom(),t.push({x:d,y:p}),t.push({x:f(i).left(),y:p}))):0!=(g&o.LEFT)?(d=f(i).left(),0!=(v&o.BOTTOM)?(p=f(i).bottom(),t.push({x:d,y:p})):0!=(v&o.TOP)?(p=f(i).top(),t.push({x:d,y:p})):0!=(v&o.RIGHT)&&(p=s.y-i.y+c.y-i.y<i.height?f(i).top():f(i).bottom(),t.push({x:d,y:p}),t.push({x:f(i).right(),y:p}))):0!=(g&o.TOP)?(p=f(i).top(),0!=(v&o.RIGHT)?(d=f(i).right(),t.push({x:d,y:p})):0!=(v&o.LEFT)?(d=f(i).left(),t.push({x:d,y:p})):0!=(v&o.BOTTOM)&&(d=s.x-i.x+c.x-i.x<i.width?f(i).left():f(i).right(),t.push({x:d,y:p}),t.push({x:d,y:f(i).bottom()}))):0!=(g&o.BOTTOM)&&(p=f(i).bottom(),0!=(v&o.RIGHT)?(d=f(i).right(),t.push({x:d,y:p})):0!=(v&o.LEFT)?(d=f(i).left(),t.push({x:d,y:p})):0!=(v&o.TOP)&&(d=s.x-i.x+c.x-i.x<i.width?f(i).left():f(i).right(),t.push({x:d,y:p}),t.push({x:d,y:f(i).top()})))}if(n)return;t.push(c)}var m=h.clippedEnds[u.other(l)];r(t[0],m)||t.push(m)},get x(){return this._coord.x},get y(){return this._coord.y},dist:function(t){return c.distance(t.coord,this.coord)}},i.create=function(t,e,i,r){return v.length>0?v.pop().init(t,e,i,r):new x(t,e,i,r)},i.sortSites=function(t){t.sort(p.compareSiteByYThenX),n(t).each(function(e,i){t[i]._siteIndex=i})}},{"../../as3/point-core":10,"../../as3/rectangle":11,"../../janicek/core":19,"../geom/polygon":45,"../geom/winding":46,"./bounds-check":28,"./criterion":29,"./edge":33,"./edge-reorderer":32,"./lr":37,"./voronoi":42,lodash:3}],41:[function(t,e,i){"use strict";function r(t,e){return isNaN(t)||isNaN(e)?i.VERTEX_AT_INFINITY:n.length>0?n.pop().init(t,e):new s(t,e)}var n=[],o=0,s=function(t,e){this.init(t,e)};s.prototype={_coord:null,get coord(){return this._coord},vertexIndex:0,init:function(t,e){return this._coord={x:t,y:e},this},dispose:function(){this._coord=null,n.push(this)},setIndex:function(){this.vertexIndex=o++},toString:function(){return"Vertex ("+this.vertexIndex+")"},get x(){return this._coord.x},get y(){return this._coord.y}},i.VERTEX_AT_INFINITY=new s(NaN,NaN),i.intersect=function(e,i){var n,o,s,a,h,l,u,c,d=t("./voronoi"),f=t("./lr");return n=e.edge,o=i.edge,null===n||null===o?null:n.rightSite===o.rightSite?null:-1e-10<(h=n.a*o.b-n.b*o.a)&&h<1e-10?null:(l=(n.c*o.b-o.c*n.b)/h,u=(o.c*n.a-n.c*o.a)/h,d.compareSiteByYThenX(n.rightSite,o.rightSite)<0?(a=e,s=n):(a=i,s=o),c=l>=s.rightSite.x,c&&a.leftRight===f.LEFT||!c&&a.leftRight===f.RIGHT?null:r(l,u))}},{"./lr":37,"./voronoi":42}],42:[function(t,e,i){"use strict";var r=t("lodash"),n=t("./criterion"),o=t("../../janicek/core"),s=t("../../janicek/core").def,a=t("./delaunay"),h=t("./edge-list"),l=t("./edge"),u=t("./edge-reorderer"),c=t("./halfedge"),d=t("./halfedge-priority-queue"),f=t("./kruskal"),p=t("./lr"),g=t("../../as3/point-core"),v=t("../../polygonal/pm-prng"),m=t("./site-list"),x=t("./site"),y=t("./vertex");i.make=function(t,e,b){function T(t,e,i){var r=100*_.nextDouble(),n=x.create(t,i,r,e);w.push(n),E[g.hash(t)]=n}function S(){return r(A).filter(function(t){return t.isPartOfConvexHull()})}var _=v(),w=m(),E={},C=[],A=[],R={};return R.plotBounds=b,R.dispose=function(){var t,e;if(null!==w&&(w.dispose(),w=null),null!==C){for(e=C.length,t=0;t<e;t++)C[t].dispose();C=null}if(null!==A){for(e=A.length,t=0;t<e;t++)A[t].dispose();A=null}R.plotBounds=null,E=null},R.edges=function(){return A},R.region=function(t){var e=E[g.hash(t)];return null===e?[]:e.region(R.plotBounds)},R.neighborSitesForSite=function(t){var e=[],i=E[g.hash(t)];if(null===i)return e;var n=i.neighborSites();return r(n).each(function(t){e.push(t.coord)}),e},R.circles=function(){return w.circles()},R.voronoiBoundaryForSite=function(t){return a.visibleLineSegments(a.selectEdgesForSitePoint(t,A))},R.delaunayLinesForSite=function(t){return a.delaunayLinesForEdges(a.selectEdgesForSitePoint(t,A))},R.voronoiDiagram=function(){return a.visibleLineSegments(A)},R.delaunayTriangulation=function(t){return t=s(t,null),a.delaunayLinesForEdges(a.selectNonIntersectingEdges(t,A))},R.hull=function(){return a.delaunayLinesForEdges(S())},R.hullPointsInOrder=function(){var t=t(),e=[];if(0===t.length)return e;var i=u(t,n.site);t=i.edges;var r=i.edgeOrientations;i.dispose();var o,s,a=t.length;for(s=0;s<a;s++){var h=t[s];o=r[s],e.push(h.site(o).coord)}return e},R.spanningTree=function(t,e){t=s(t,"minimum"),e=s(e,null);var i=a.selectNonIntersectingEdges(e,A),r=a.delaunayLinesForEdges(i);return f.kruskal(r,t)},R.regions=function(){return w.regions(R.plotBounds)},R.siteColors=function(t){return t=s(t,null),w.siteColors(t)},R.nearestSitePoint=function(t,e,i){return w.nearestSitePoint(t,e,i)},R.siteCoords=function(){return w.siteCoords()},function(t){var e={};r(t).each(function(t){if(r(e).has(g.hash(t)))throw"Duplicate points not supported yet!";e[g.hash(t)]=t})}(t),_.seed=1,function(t,e){for(var i=t.length,r=0;r<i;r++)T(t[r],null!==e?e[r]:0,r)}(t,e),function(){function t(t){var e=t.edge;return null===e?I:e.site(p.other(t.leftRight))}var e,n,s,a,u,f,g,v,m,x,b,T,S,_,E=w.getSitesBounds(),C=o.toInt(Math.sqrt(w.length+4)),M=d(E.y,E.height,C),L=h(E.x,E.width,C),F=[],B=[],I=w.next();for(e=w.next();;)if(!1===M.empty()&&(g=M.min()),null!==e&&(M.empty()||i.comparePointByYThenX(e,g)<0))m=L.edgeListLeftNeighbor(e.coord),x=m.edgeListRightNeighbor,n=t(m),_=l.createBisectingEdge(n,e),A.push(_),S=c.create(_,p.LEFT),F.push(S),L.insert(m,S),null!==(f=y.intersect(m,S))&&(B.push(f),M.remove(m),m.vertex=f,m.ystar=f.y+e.dist(f),M.insert(m)),m=S,S=c.create(_,p.RIGHT),F.push(S),L.insert(m,S),null!==(f=y.intersect(S,x))&&(B.push(f),S.vertex=f,S.ystar=f.y+e.dist(f),M.insert(S)),e=w.next();else{if(!1!==M.empty())break;m=M.extractMin(),b=m.edgeListLeftNeighbor,x=m.edgeListRightNeighbor,T=x.edgeListRightNeighbor,n=function(t){var e=t.edge;return null===e?I:e.site(t.leftRight)}(m),s=t(x),u=m.vertex,u.setIndex(),m.edge.setVertex(m.leftRight,u),x.edge.setVertex(x.leftRight,u),L.remove(m),M.remove(x),L.remove(x),v=p.LEFT,n.y>s.y&&(a=n,n=s,s=a,v=p.RIGHT),_=l.createBisectingEdge(n,s),A.push(_),S=c.create(_,v),F.push(S),L.insert(b,S),_.setVertex(p.other(v),u),null!==(f=y.intersect(b,S))&&(B.push(f),M.remove(b),b.vertex=f,b.ystar=f.y+n.dist(f),M.insert(b)),null!==(f=y.intersect(S,T))&&(B.push(f),S.vertex=f,S.ystar=f.y+n.dist(f),M.insert(S))}M.dispose(),L.dispose(),r(F).each(function(t){t.reallyDispose()}),r(A).each(function(t){t.clipVertices(R.plotBounds)}),r(B).each(function(t){t.dispose()})}(),R},i.isInfSite=function(t,e){return t.y<e.y||t.y===e.y&&t.x<e.x},i.comparePointByYThenX=function(t,e){return i.compareByYThenX(t.x,t.y,e.x,e.y)},i.compareSiteByYThenX=function(t,e){return i.compareByYThenX(t.x,t.y,e.x,e.y)},i.compareByYThenX=function(t,e,i,r){return e<r?-1:e>r?1:t<i?-1:t>i?1:0}},{"../../as3/point-core":10,"../../janicek/core":19,"../../polygonal/pm-prng":49,"./criterion":29,"./delaunay":30,"./edge":33,"./edge-list":31,"./edge-reorderer":32,"./halfedge":35,"./halfedge-priority-queue":34,"./kruskal":36,"./lr":37,"./site":40,"./site-list":39,"./vertex":41,lodash:3}],43:[function(t,e,i){"use strict";e.exports=function(t,e,i){return{center:{x:t,y:e},radius:i,toString:function(){return"Circle (center: "+this.center+"; radius: "+this.radius+")"}}}},{}],44:[function(t,e,i){"use strict";var r=t("../../as3/point-core");e.exports=function(t,e){return{p0:t,p1:e}},e.exports.core={compareLengthsMax:function(t,e){var i=r.distance(t.p0,t.p1),n=r.distance(e.p0,e.p1);return i<n?1:i>n?-1:0},compareLengths:function(t,e){return-this.compareLengthsMax(t,e)}}},{"../../as3/point-core":10}],45:[function(t,e,i){"use strict";var r=t("./winding"),n=function(t){this._vertices=t};n.prototype={area:function(){return Math.abs(.5*this.signedDoubleArea())},winding:function(){var t=this.signedDoubleArea();return t<0?r.CLOCKWISE:t>0?r.COUNTERCLOCKWISE:r.NONE},signedDoubleArea:function(){var t,e,i,r,n=this._vertices.length,o=0;for(t=0;t<n;t++)e=(t+1)%n,i=this._vertices[t],r=this._vertices[e],o+=i.x*r.y-r.x*i.y;return o}},e.exports=function(t){return new n(t)}},{"./winding":46}],46:[function(t,e,i){"use strict";e.exports={CLOCKWISE:"clockwise",COUNTERCLOCKWISE:"counterclockwise",NONE:"none"}},{}],47:[function(t,e,i){"use strict";var r=t("lodash"),n=t("./as3/conversion-core"),o=t("./janicek/core"),s=t("./as3/point-core"),a=t("./janicek/pseudo-random-number-generators");e.exports=function(){var t={};return t.path0=[],t.path1=[],t.buildNoisyEdges=function(i,h,l,u){u=o.def(u,.5);var c=a.randomGenerator(l,a.nextParkMiller);r(i.centers).each(function(i){r(i.borders).each(function(i){if(!o.isUndefinedOrNull(i.d0)&&!o.isUndefinedOrNull(i.d1)&&!o.isUndefinedOrNull(i.v0)&&!o.isUndefinedOrNull(i.v1)&&o.isUndefinedOrNull(t.path0[i.index])){var r=u,a=s.interpolate(i.v0.point,i.d0.point,r),l=s.interpolate(i.v0.point,i.d1.point,r),d=s.interpolate(i.v1.point,i.d0.point,r),f=s.interpolate(i.v1.point,i.d1.point,r),p=10;i.d0.biome!==i.d1.biome&&(p=3),i.d0.ocean&&i.d1.ocean&&(p=100),(i.d0.coast||i.d1.coast)&&(p=1),!n.booleanFromInt(i.river)&&o.isUndefinedOrNull(h.lava[i.index])||(p=1),t.path0[i.index]=e.exports.buildNoisyLineSegments(c(),i.v0.point,a,i.midpoint,l,p),t.path1[i.index]=e.exports.buildNoisyLineSegments(c(),i.v1.point,f,i.midpoint,d,p)}})})},t},e.exports.buildNoisyLineSegments=function(t,e,i,r,n,o){function h(t,e,i,r){if(!(s.distanceFromOrigin(s.subtract(t,i))<o||s.distanceFromOrigin(s.subtract(e,r))<o)){var n=a.toFloatRange(l(),.2,.8),c=a.toFloatRange(l(),.2,.8),d=s.interpolate(t,r,n),f=s.interpolate(e,i,n),p=s.interpolate(t,e,c),g=s.interpolate(r,i,c),v=s.interpolate(d,f,c),m=1-a.toFloatRange(l(),-.4,.4),x=1-a.toFloatRange(l(),-.4,.4);h(t,s.interpolate(p,e,m),v,s.interpolate(d,r,x)),u.push(v),h(v,s.interpolate(f,i,m),i,s.interpolate(g,r,x))}}var l=a.randomGenerator(t,a.nextParkMiller),u=[];return u.push(e),h(e,i,r,n),u.push(r),u}},{"./as3/conversion-core":8,"./as3/point-core":10,"./janicek/core":19,"./janicek/pseudo-random-number-generators":24,lodash:3}],48:[function(t,e,i){"use strict";var r=t("./polygonal/pm-prng"),n=t("./as3/rectangle"),o=t("./nodename/delaunay/voronoi"),s={needsMoreRandomness:function(t){return t===s.generateSquare||t===s.generateHexagon},generateRandom:function(t,e,i){return function(n){var o=r();o.seed=i;for(var s=[],a=0;a<n;a++)s.push({x:o.nextDoubleRange(10,t-10),y:o.nextDoubleRange(10,e-10)});return s}},generateRelaxed:function(t,e,i,r){return r=r||2,function(a){for(var h=s.generateRandom(t,e,i)(a),l=0;l<r;l++){for(var u=o.make(h,null,n(0,0,t,e)),c=0;c<h.length;c++){var d=h[c],f=u.region(d);d.x=0,d.y=0;for(var p=0;p<f.length;p++){var g=f[p];d.x+=g.x,d.y+=g.y}d.x/=f.length,d.y/=f.length,f.splice(0,f.length)}u.dispose()}return h}},generateSquare:function(t,e){return function(i){for(var r=[],n=Math.sqrt(i),o=0;o<n;o++)for(var s=0;s<n;s++)r.push({x:(.5+o)/n*t,y:(.5+s)/n*e});return r}},generateHexagon:function(t,e){return function(i){for(var r=[],n=Math.sqrt(i),o=0;o<n;o++)for(var s=0;s<n;s++)r.push({x:(.5+o)/n*t,y:(.25+.5*o%2+s)/n*e});return r}}};e.exports=s},{"./as3/rectangle":11,"./nodename/delaunay/voronoi":42,"./polygonal/pm-prng":49}],49:[function(t,e,i){"use strict";e.exports=function(){return{seed:1,nextDouble:function(){return this.gen()/2147483647},nextIntRange:function(t,e){return t-=.4999,e+=.4999,Math.round(t+(e-t)*this.nextDouble())},nextDoubleRange:function(t,e){return t+(e-t)*this.nextDouble()},gen:function(){return this.seed=16807*this.seed%2147483647,this.seed}}}},{}],50:[function(t,e,i){"use strict";function r(t,e){for(var i=0;i<e.length;i++)t.lineTo(e[i].x,e[i].y)}function n(t,e,i,r,n,o,a,l){var u=c(),d=e.add(i).add(r);d.scaleBy(1/3);var p=i.subtract(e).crossProduct(r.subtract(e));p.normalize();var g=f(-p.x/p.z,-p.y/p.z,0),v=f(d.x-g.x*((d.z-.5)/g.length/g.length),d.y-g.y*((d.z-.5)/g.length/g.length));if(g.length<1e-6){var m=n[0];2===n.length?m=h.interpolateColor(n[0],n[1],d.z):3===n.length&&(m=d.z<.5?h.interpolateColor(n[0],n[1],2*d.z):h.interpolateColor(n[1],n[2],2*d.z-1)),t.fillStyle=h.intToHexColor(m)}else{u.createGradientBox(1,1,0,0,0),u.translate(-.5,-.5),u.scale(1/g.length,1/g.length),u.rotate(Math.atan2(g.y,g.x)),u.translate(v.x,v.y);s(n).map(function(t){return 1}),s(n).map(function(t,e){return 255*e/(n.length-1)})}o(t,a,l),t.fill()}function o(t,e){for(var i=e.length-1;i>=0;)t.lineTo(e[i].x,e[i].y),i--}var s=t("lodash"),a=t("./janicek/canvas"),h=t("./janicek/html-color"),l=t("./as3/conversion-core"),u=t("./janicek/core"),c=t("./as3/matrix"),d=t("./as3/point-core"),f=t("./as3/vector-3d");i.graphicsReset=function(t,e,i,r){t.lineWidth=1,t.clearRect(0,0,2e3,2e3),t.fillStyle="#bbbbaa",t.fillRect(0,0,2e3,2e3),t.fillStyle=h.intToHexColor(r.OCEAN),t.fillRect(0,0,u.toInt(e),u.toInt(i))},i.colorWithSmoothColors=function(t,e,i,r,n){return null!==i&&e.water===i.water&&(t=h.interpolateColor(n[e.biome],n[i.biome],.25)),t},i.renderDebugPolygons=function(t,e,i){var r;0===e.centers.length&&(t.fillStyle="#dddddd",t.fillRect(0,0,u.toInt(e.SIZE.width),u.toInt(e.SIZE.height)),s(e.points).each(function(e){t.beginPath(),t.strokeStyle="#000000",t.fillStyle="#000000",t.arc(e.x,e.y,1.3,Math.PI,2*Math.PI,!1),t.closePath(),t.fill(),t.stroke()})),s(e.centers).each(function(e){r=s.isNull(e.biome)?e.ocean?i.OCEAN:e.water?i.RIVER:16777215:i[e.biome],t.beginPath(),s(e.borders).each(function(i){s.isNull(i.v0)||s.isNull(i.v1)||(t.moveTo(e.point.x,e.point.y),t.lineTo(i.v0.point.x,i.v0.point.y),t.lineTo(i.v1.point.x,i.v1.point.y))}),t.closePath(),t.fillStyle=h.intToHexColor(h.interpolateColor(r,14540253,.2)),t.fill(),s(e.borders).each(function(e){s.isNull(e.v0)||s.isNull(e.v1)||(t.beginPath(),t.moveTo(e.v0.point.x,e.v0.point.y),e.river>0?(t.lineWidth=1,t.strokeStyle=h.intToHexColor(i.RIVER)):(t.lineWidth=.1,t.strokeStyle="#000000"),t.lineTo(e.v1.point.x,e.v1.point.y),t.closePath(),t.stroke())}),t.beginPath(),t.fillStyle=e.water?"#003333":"#000000",t.globalAlpha=.7,t.arc(e.point.x,e.point.y,1.3,Math.PI,2*Math.PI,!1),t.closePath(),t.fill(),t.globalAlpha=1,s(e.corners).each(function(e){t.fillStyle=e.water?"#0000ff":"#009900",t.fillRect(e.point.x-.7,e.point.y-.7,1.5,1.5)})})},i.renderWatersheds=function(t,e,i){var r,n,o;s(e.edges).each(function(r){r.d0&&r.d1&&r.v0&&r.v1&&!r.d0.ocean&&!r.d1.ocean&&(n=i.watersheds[r.d0.index],o=i.watersheds[r.d1.index],n!==o&&(t.beginPath(),t.lineWidth=3.5,t.strokeStyle=h.rgba(0,0,0,.1*Math.sqrt(u.coalesce(e.corners[n].watershedSize,1)+u.coalesce(e.corners[o].watershed.watershedSize,1))),t.moveTo(r.v0.point.x,r.v0.point.y),t.lineTo(r.v1.point.x,r.v1.point.y),t.closePath(),t.stroke()))});for(r in e.edges)l.booleanFromInt(r.river)&&(t.beginPath(),t.lineWidth=1,t.strokeStyle="#6699ff",t.moveTo(r.v0.point.x,r.v0.point.y),t.lineTo(r.v1.point.x,r.v1.point.y),t.closePath(),t.stroke())},i.renderPolygons=function(t,e,i,o,s,a){for(var l=function(t,e,i){var n=a.path0[m.index];t.moveTo(e,i),t.lineTo(n[0].x,n[0].y),r(t,n),t.lineTo(e,i)},c=function(t,e,i){var n=a.path1[m.index];t.moveTo(e,i),t.lineTo(n[0].x,n[0].y),r(t,n),t.lineTo(e,i)},d=0;d<s.centers.length;d++)for(var p=s.centers[d],g=0;g<p.neighbors.length;g++){var v=p.neighbors[g],m=s.lookupEdgeFromCenter(p,v),x=u.coalesce(e[p.biome],0);if(null!==o&&(x=o(x,p,v,m,e)),!u.isUndefinedOrNull(a.path0[m.index])&&!u.isUndefinedOrNull(a.path1[m.index]))if(u.isUndefinedOrNull(i))t.fillStyle=h.intToHexColor(x),t.strokeStyle=t.fillStyle,t.beginPath(),l(t,p.point.x,p.point.y),c(t,p.point.x,p.point.y),t.closePath(),t.fill(),t.stroke();else{var y=m.v0,b=m.v1,T=m.midpoint,S=.5*(y[i]+b[i]);n(t,f(p.point.x,p.point.y,p[i]),f(y.point.x,y.point.y,y[i]),f(T.x,T.y,S),[e.GRADIENT_LOW,e.GRADIENT_HIGH],l,p.point.x,p.point.y),n(t,f(p.point.x,p.point.y,p[i]),f(T.x,T.y,S),f(b.point.x,b.point.y,b[i]),[e.GRADIENT_LOW,e.GRADIENT_HIGH],c,p.point.x,p.point.y)}}},i.renderBridges=function(t,e,i,r){s(e.edges).each(function(e){if(e.river>0&&e.river<4&&!e.d0.water&&!e.d1.water&&(e.d0.elevation>.05||e.d1.elevation>.05)){var n={x:-(e.v1.point.y-e.v0.point.y),y:e.v1.point.x-e.v0.point.x};d.normalize(n,.25+(s.isNull(i.road[e.index])?0:.5)+.75*Math.sqrt(e.river)),t.beginPath(),t.lineWidth=1.1,t.strokeStyle=h.intToHexColor(r.BRIDGE),t.lineCap="square",t.moveTo(e.midpoint.x-n.x,e.midpoint.y-n.y),t.lineTo(e.midpoint.x+n.x,e.midpoint.y+n.y),t.closePath(),t.stroke()}})},i.renderRoads=function(t,e,i,r){function n(t,e,i){var r={x:-(t.v1.point.y-t.v0.point.y),y:t.v1.point.x-t.v0.point.x},n=d.subtract(e,t.midpoint);return r.x*n.x+r.y*n.y<0&&(r.x=-r.x,r.y=-r.y),d.normalize(r,i),r}var o,a,l,c,f,p,g,v,m;s(e.centers).each(function(e){if(!u.isUndefinedOrNull(i.roadConnections[e.index]))if(2===i.roadConnections[e.index].length){for(m=e.borders,c=0;c<m.length;c++)if(g=m[c],i.road[g.index]>0)for(f=c+1;f<m.length;f++)v=m[f],i.road[v.index]>0&&(p=.5*Math.min(d.distanceFromOrigin(d.subtract(g.midpoint,e.point)),d.distanceFromOrigin(d.subtract(v.midpoint,e.point))),o=d.add(n(g,e.point,p),g.midpoint),a=d.add(n(v,e.point,p),v.midpoint),l=d.interpolate(o,a,.5),t.beginPath(),t.lineWidth=1.1,t.strokeStyle=h.intToHexColor(r["ROAD"+i.road[g.index]]),t.moveTo(g.midpoint.x,g.midpoint.y),t.quadraticCurveTo(o.x,o.y,l.x,l.y),t.moveTo(l.x,l.y),t.lineWidth=1.1,t.strokeStyle=h.intToHexColor(r["ROAD"+i.road[v.index]]),t.quadraticCurveTo(a.x,a.y,v.midpoint.x,v.midpoint.y),t.stroke(),t.closePath())}else s(e.borders).each(function(s){i.road[s.index]>0&&(p=.25*d.distanceFromOrigin(d.subtract(s.midpoint,e.point)),o=d.add(n(s,e.point,p),s.midpoint),t.beginPath(),t.lineWidth=1.4,t.strokeStyle=h.intToHexColor(r["ROAD"+i.road[s.index]]),t.moveTo(s.midpoint.x,s.midpoint.y),t.quadraticCurveTo(o.x,o.y,e.point.x,e.point.y),t.stroke(),t.closePath())})})},i.renderEdges=function(t,e,i,n,s,a){a=u.def(a,!0);for(var c,d=0;d<i.centers.length;d++)for(var f=i.centers[d],p=0;p<f.neighbors.length;p++){var g=f.neighbors[p];if(c=i.lookupEdgeFromCenter(f,g),!u.isUndefinedOrNull(n.path0[c.index])&&!u.isUndefinedOrNull(n.path1[c.index])){if(f.ocean!==g.ocean)t.lineWidth=2,t.strokeStyle=h.intToHexColor(e.COAST);else if(l.intFromBoolean(f.water)>0!=l.intFromBoolean(g.water)>0&&"ICE"!==f.biome&&"ICE"!==g.biome)t.lineWidth=1,t.strokeStyle=h.intToHexColor(e.LAKESHORE);else{if(f.water||g.water)continue;if(s.lava[c.index])t.lineWidth=1,t.strokeStyle=h.intToHexColor(e.LAVA);else{if(!(c.river>0&&a))continue;t.lineWidth=Math.sqrt(c.river),t.strokeStyle=h.intToHexColor(e.RIVER)}}t.beginPath(),t.moveTo(n.path0[c.index][0].x,n.path0[c.index][0].y),r(t,n.path0[c.index]),o(t,n.path1[c.index]),t.stroke(),t.closePath()}}},i.renderAllEdges=function(t,e,i,n,s){var a;t.lineWidth=5,t.strokeStyle=h.intToHexColor(e);var l=t.globalAlpha;t.globalAlpha=i;for(var c=0;c<n.centers.length;c++)for(var d=n.centers[c],f=0;f<d.neighbors.length;f++){var p=d.neighbors[f];a=n.lookupEdgeFromCenter(d,p),u.isUndefinedOrNull(s.path0[a.index])||u.isUndefinedOrNull(s.path1[a.index])||d.water||(t.beginPath(),t.moveTo(s.path0[a.index][0].x,s.path0[a.index][0].y),r(t,s.path0[a.index]),o(t,s.path1[a.index]),t.stroke(),t.closePath())}t.globalAlpha=l},i.addNoise=function(t){a.addNoiseToCanvas(t,666,10,!0)}},{"./as3/conversion-core":8,"./as3/matrix":9,"./as3/point-core":10,"./as3/vector-3d":12,"./janicek/canvas":18,"./janicek/core":19,"./janicek/html-color":21,lodash:3}],51:[function(t,e,i){"use strict";function r(t,e,i){var r=s(t.point.x,t.point.y,t.elevation),n=s(e.point.x,e.point.y,e.elevation),o=s(i.point.x,i.point.y,i.elevation),h=n.subtract(r).crossProduct(o.subtract(r));h.z<0&&h.scaleBy(-1),h.normalize();var l=.5+35*h.dotProduct(a);return l<0&&(l=0),l>1&&(l=1),l}var n=t("lodash"),o=t("./janicek/html-color"),s=t("./as3/vector-3d"),a=s(-1,-1,0);i.colorWithSlope=function(t,e,i,s,a){var h=s.v0,l=s.v1;if(n.isNull(h)||n.isNull(l))return a.OCEAN;if(e.water)return t;null!==i&&e.water===i.water&&(t=o.interpolateColor(t,a[i.biome],.4));var u=o.interpolateColor(t,3355443,.7),c=o.interpolateColor(t,16777215,.3),d=r(e,h,l);return d<.5?o.interpolateColor(u,t,2*d):o.interpolateColor(t,c,2*d-1)}},{"./as3/vector-3d":12,"./janicek/html-color":21,lodash:3}],52:[function(t,e,i){"use strict";function r(t,e,i){for(var r=0;r<e.length;r++)t.lineTo(e[r].x,e[r].y),i&&i(r,e[r].x,e[r].y)}function n(t,e,i){for(var r=e.length-1;r>=0;r--)t.lineTo(e[r].x,e[r].y),i&&i(r,e[r].x,e[r].y)}var o=t("lodash"),s=t("./janicek/html-color"),a=t("./as3/conversion-core"),h=t("./janicek/core"),l=t("pixi.js"),u=t("./as3/point-core"),c=t("shape2d"),d=t("pixi-noise-filter");i.graphicsReset=function(t,e,i,r){t.stage=new l.Stage(r.OCEAN),t.root=new l.DisplayObjectContainer,t.stage.addChild(t.root),t.renderer.render(t.stage)},i.renderDebugPolygons=function(t,e,i){var r;0===e.centers.length&&(t.fillStyle="#dddddd",t.fillRect(0,0,h.toInt(e.SIZE.width),h.toInt(e.SIZE.height)),o(e.points).each(function(e){t.beginPath(),t.strokeStyle="#000000",t.fillStyle="#000000",t.arc(e.x,e.y,1.3,Math.PI,2*Math.PI,!1),t.closePath(),t.fill(),t.stroke()}));var n=new l.Graphics;o(e.centers).each(function(e){r=o.isNull(e.biome)?e.ocean?i.OCEAN:e.water?i.RIVER:16777215:i[e.biome],n.lineStyle(),n.beginFill(s.interpolateColor(r,14540253,.2)),o(e.borders).each(function(t){t.v0&&t.v1&&(n.moveTo(e.point.x,e.point.y),n.lineTo(t.v0.point.x,t.v0.point.y),n.lineTo(t.v1.point.x,t.v1.point.y),n.lineTo(e.point.x,e.point.y))}),n.endFill(),o(e.borders).each(function(t){t.v0&&t.v1&&(t.river>0?n.lineStyle(2,i.RIVER):n.lineStyle(1,0,.2),n.moveTo(t.v0.point.x,t.v0.point.y),n.lineTo(t.v1.point.x,t.v1.point.y))}),n.beginFill(e.water?13107:0,.7),n.drawCircle(e.point.x,e.point.y,1.3,1.3),n.endFill(),t.root.addChild(n),n=new l.Graphics}),o(e.centers).each(function(t){o(t.corners).each(function(t){n.beginFill(t.water?255:39168),n.drawRect(t.point.x-1,t.point.y-1,2,2),n.endFill()})}),t.root.addChild(n),t.renderer.render(t.stage)},i.renderWatersheds=function(t,e,i){var r,n,s,h=new l.Graphics;o(e.edges).each(function(t){t.d0&&t.d1&&t.v0&&t.v1&&!t.d0.ocean&&!t.d1.ocean&&(n=i.watersheds[t.d0.index],s=i.watersheds[t.d1.index],n!==s&&(h.lineStyle(3.5,0,.1*Math.sqrt((e.corners[n].watershedSize||1)+(e.corners[s].watershed.watershedSize||1))),h.moveTo(t.v0.point.x,t.v0.point.y),h.lineTo(t.v1.point.x,t.v1.point.y)))});for(r in e.edges)a.booleanFromInt(r.river)&&(h.lineStyle(1,6724095),h.moveTo(r.v0.point.x,r.v0.point.y),h.lineTo(r.v1.point.x,r.v1.point.y));t.root.addChild(h),t.renderer.render(t.stage)},i.renderPolygons=function(t,e,i,n,o,s){var a=new l.Graphics;t.root.addChild(a),a=new l.Graphics;for(var u=function(t,e,i){var n=s.path0[v.index];t.moveTo(e,i),t.lineTo(n[0].x,n[0].y),r(t,n),t.lineTo(e,i)},c=function(t,e,i){var n=s.path1[v.index];t.moveTo(e,i),t.lineTo(n[0].x,n[0].y),r(t,n),t.lineTo(e,i)},d=0;d<o.centers.length;d++)for(var f=o.centers[d],p=0;p<f.neighbors.length;p++){var g=f.neighbors[p],v=o.lookupEdgeFromCenter(f,g),m=h.coalesce(e[f.biome],0);if(null!==n&&(m=n(m,f,g,v,e)),!h.isUndefinedOrNull(s.path0[v.index])&&!h.isUndefinedOrNull(s.path1[v.index]))if(h.isUndefinedOrNull(i))m!==e.OCEAN&&(a.beginFill(m),u(a,f.point.x,f.point.y),c(a,f.point.x,f.point.y),a.endFill());else{var x=v.v0,y=v.v1,b=v.midpoint,T=.5*(x[i]+y[i]);drawGradientTriangle(a,vector3d(f.point.x,f.point.y,f[i]),vector3d(x.point.x,x.point.y,x[i]),vector3d(b.x,b.y,T),[e.GRADIENT_LOW,e.GRADIENT_HIGH],u,f.point.x,f.point.y),drawGradientTriangle(a,vector3d(f.point.x,f.point.y,f[i]),vector3d(b.x,b.y,T),vector3d(y.point.x,y.point.y,y[i]),[e.GRADIENT_LOW,e.GRADIENT_HIGH],c,f.point.x,f.point.y)}}t.root.addChild(a),t.renderer.render(t.stage)},i.renderBridges=function(t,e,i,r){var n=new l.Graphics;o(e.edges).each(function(t){if(t.river>0&&t.river<4&&!t.d0.water&&!t.d1.water&&(t.d0.elevation>.05||t.d1.elevation>.05)){var e={x:-(t.v1.point.y-t.v0.point.y),y:t.v1.point.x-t.v0.point.x};u.normalize(e,.25+(o.isNull(i.road[t.index])?0:.5)+.75*Math.sqrt(t.river)),n.lineStyle(1.1,r.BRIDGE),n.moveTo(t.midpoint.x-e.x,t.midpoint.y-e.y),n.lineTo(t.midpoint.x+e.x,t.midpoint.y+e.y)}}),t.root.addChild(n),t.renderer.render(t.stage)},i.renderRoads=function(t,e,i,n){function s(t,e,i){var r={x:-(t.v1.point.y-t.v0.point.y),y:t.v1.point.x-t.v0.point.x},n=u.subtract(e,t.midpoint);return r.x*n.x+r.y*n.y<0&&(r.x=-r.x,r.y=-r.y),u.normalize(r,i),r}var a,d,f,p,g,v,m,x,y,b=new l.Graphics;o(e.centers).each(function(t){if(!h.isUndefinedOrNull(i.roadConnections[t.index]))if(2===i.roadConnections[t.index].length){for(y=t.borders,p=0;p<y.length;p++)if(m=y[p],i.road[m.index]>0)for(g=p+1;g<y.length;g++)if(x=y[g],i.road[x.index]>0){v=.5*Math.min(u.distanceFromOrigin(u.subtract(m.midpoint,t.point)),u.distanceFromOrigin(u.subtract(x.midpoint,t.point))),a=u.add(s(m,t.point,v),m.midpoint),d=u.add(s(x,t.point,v),x.midpoint),f=u.interpolate(a,d,.5),b.moveTo(m.midpoint.x,m.midpoint.y),b.lineStyle(1.1,n["ROAD"+i.road[m.index]]);var e=new c;e.steps=10,e.moveTo(m.midpoint.x,m.midpoint.y),e.quadraticCurveTo(a.x,a.y,f.x,f.y),e.moveTo(f.x,f.y),r(b,e.points);var l=e.points[e.points.length-1];e=new c,e.steps=10,e.moveTo(l.x,l.y),e.quadraticCurveTo(d.x,d.y,x.midpoint.x,x.midpoint.y),b.lineStyle(1.1,n["ROAD"+i.road[x.index]]),r(b,e.points)}}else o(t.borders).each(function(e){if(i.road[e.index]>0){v=.25*u.distanceFromOrigin(u.subtract(e.midpoint,t.point)),a=u.add(s(e,t.point,v),e.midpoint),b.moveTo(e.midpoint.x,e.midpoint.y),b.lineStyle(1.4,n["ROAD"+i.road[e.index]]);var o=new c;o.steps=10,o.moveTo(e.midpoint.x,e.midpoint.y),o.quadraticCurveTo(a.x,a.y,t.point.x,t.point.y),r(b,o.points)}})}),t.root.addChild(b),t.renderer.render(t.stage)},i.renderEdges=function(t,e,i,o,s,u){u=h.def(u,!0);for(var c,d=0;d<i.centers.length;d++)for(var f=i.centers[d],p=0;p<f.neighbors.length;p++){var g=f.neighbors[p];if(c=i.lookupEdgeFromCenter(f,g),!h.isUndefinedOrNull(o.path0[c.index])&&!h.isUndefinedOrNull(o.path1[c.index])){var v=0,m=0;if(f.ocean!==g.ocean)v=2,m=e.COAST;else if(a.intFromBoolean(f.water)>0!=a.intFromBoolean(g.water)>0&&"ICE"!==f.biome&&"ICE"!==g.biome)v=1,m=e.LAKESHORE;else{if(f.water||g.water)continue;if(s.lava[c.index])v=1,m=e.LAVA;else{if(!(c.river>0&&u))continue;v=Math.sqrt(c.river),m=e.RIVER}}var x=new l.Graphics,y=o.path0[c.index][0];x.moveTo(y.x,y.y),x.lineStyle(v,m),r(x,o.path0[c.index]),t.root.addChild(x),x=new l.Graphics,x.lineStyle(v,m),n(x,o.path1[c.index]),t.root.addChild(x)}}t.renderer.render(t.stage)},i.renderAllEdges=function(t,e,i,o,s){for(var a,u=0;u<o.centers.length;u++)for(var c=o.centers[u],d=0;d<c.neighbors.length;d++){var f=c.neighbors[d];if(a=o.lookupEdgeFromCenter(c,f),!(h.isUndefinedOrNull(s.path0[a.index])||h.isUndefinedOrNull(s.path1[a.index])||c.water)){var p=new l.Graphics;p.moveTo(s.path0[a.index][0].x,s.path0[a.index][0].y),p.lineStyle(5,e,i),r(p,s.path0[a.index]),t.root.addChild(p),p=new l.Graphics,p.lineStyle(5,e,i),n(p,s.path1[a.index]),t.root.addChild(p)}}t.renderer.render(t.stage)},i.addNoise=function(t){var e=new d;e.noiseLevelRGBA=[.05,.05,.05,0],t.stage.filters=[e],t.renderer.render(t.stage)}},{"./as3/conversion-core":8,"./as3/point-core":10,"./janicek/core":19,"./janicek/html-color":21,lodash:3,"pixi-noise-filter":4,"pixi.js":5,shape2d:6}],53:[function(t,e,i){"use strict";var r=t("lodash"),n=t("./janicek/core");e.exports=function(){var t={};return t.road=[],t.roadConnections=[],t.createRoads=function(e,i){var o,s,a=[],h=[],l=[];for(r(e.centers).each(function(t){(t.coast||t.ocean)&&(l[t.index]=1,a.push(t))});a.length>0;){o=a.shift();for(var u=0;u<o.neighbors.length;u++){var c=o.neighbors[u];for(s=n.coalesce(l[o.index],0);c.elevation>i[s]&&!c.water;)s+=1;s<n.coalesce(l[c.index],999)&&(l[c.index]=s,a.push(c))}}r(e.centers).each(function(t){r(t.corners).each(function(e){h[e.index]=n.toInt(Math.min(n.coalesce(h[e.index],999),n.coalesce(l[t.index],999)))})}),r(e.centers).each(function(e){r(e.borders).each(function(i){r.isNull(i.v0)||r.isNull(i.v1)||h[i.v0.index]===h[i.v1.index]||(t.road[i.index]=n.toInt(Math.min(h[i.v0.index],h[i.v1.index])),n.isUndefinedOrNull(t.roadConnections[e.index])&&(t.roadConnections[e.index]=[]),t.roadConnections[e.index].push(i))})})},t}},{"./janicek/core":19,lodash:3}],54:[function(t,e,i){"use strict";i.displayColors={OCEAN:4473978,COAST:3355482,LAKESHORE:2250120,LAKE:3368601,RIVER:2250120,MARSH:3106406,ICE:10092543,BEACH:10522743,ROAD1:4465169,ROAD2:5583650,ROAD3:6702131,BRIDGE:6842464,LAVA:13382451,SNOW:16777215,TUNDRA:12303274,BARE:8947848,SCORCHED:5592405,TAIGA:10070647,SHRUBLAND:8952183,TEMPERATE_DESERT:13226651,TEMPERATE_RAIN_FOREST:4491349,TEMPERATE_DECIDUOUS_FOREST:6788185,GRASSLAND:8956501,SUBTROPICAL_DESERT:13810059,TROPICAL_RAIN_FOREST:3372885,TROPICAL_SEASONAL_FOREST:5609796},i.elevationGradientColors={OCEAN:34816,GRADIENT_LOW:34816,GRADIENT_HIGH:16776960}},{}],55:[function(t,e,i){"use strict";window.voronoiMap={islandShape:t("./island-shape"),lava:t("./lava"),map:t("./map"),mapLands:t("./map-lands"),noisyEdges:t("./noisy-edges"),pointSelector:t("./point-selector"),renderCore:t("./render-core"),renderCanvas:t("./render-canvas"),renderPixi:t("./render-pixi"),roads:t("./roads"),style:t("./style"),watersheds:t("./watersheds")}},{"./island-shape":16,"./lava":25,"./map":27,"./map-lands":26,"./noisy-edges":47,"./point-selector":48,"./render-canvas":50,"./render-core":51,"./render-pixi":52,"./roads":53,"./style":54,"./watersheds":56}],56:[function(t,e,i){"use strict";var r=t("lodash");e.exports=function(){var t={};return t.lowestCorner=[],t.watersheds=[],t.createWatersheds=function(e){var i;r(e.centers).each(function(e){i=null,r(e.corners).each(function(t){(null===i||t.elevation<i.elevation)&&(i=t)}),t.lowestCorner[e.index]=null===i?-1:i.index,t.watersheds[e.index]=null===i?-1:null===i.watershed?-1:i.watershed.index})},t}},{lodash:3}]},{},[55]);