From 3ea1b2e7f2c4ac13f17abd291a5193f93aab6bd1 Mon Sep 17 00:00:00 2001 From: "Paper.js Bot" Date: Fri, 10 Jun 2016 11:45:10 +0000 Subject: [PATCH] Prebuilt module for commit 964d8cf7d61ae5b6b54104100e36953a638a4b5d --- CHANGELOG.md | 2 ++ dist/docs/assets/js/paper.js | 8 ++++---- dist/paper-core.js | 2 +- dist/paper-core.min.js | 2 +- dist/paper-full.js | 8 ++++---- dist/paper-full.min.js | 4 ++-- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ac32b88..5e7cffba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,8 @@ contribute to the code. - `Matrix` properties `#b` and `#c` have been reversed to match common standard. - `#importSVG()`: improve handling of style inheritance for nested ``. - Move `PaperScript#execute()` URL argument into `options.url` (#902). +- PaperScript: Only translate `==` to `equals() calls for `Point`, `Size` and + `Color` (#1043). ### Added - Use unified code-base for browsers, Node.js, Electron, and anything diff --git a/dist/docs/assets/js/paper.js b/dist/docs/assets/js/paper.js index bce7bfd1..d3cd3639 100644 --- a/dist/docs/assets/js/paper.js +++ b/dist/docs/assets/js/paper.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Fri Jun 10 13:04:57 2016 +0200 + * Date: Fri Jun 10 13:41:36 2016 +0200 * *** * @@ -14149,8 +14149,8 @@ Base.exports.PaperScript = (function() { '*': '__multiply', '/': '__divide', '%': '__modulo', - '==': 'equals', - '!=': 'equals' + '==': '__equals', + '!=': '__equals' }; var unaryOperators = { @@ -14159,7 +14159,7 @@ Base.exports.PaperScript = (function() { }; var fields = Base.each( - ['add', 'subtract', 'multiply', 'divide', 'modulo', 'negate'], + ['add', 'subtract', 'multiply', 'divide', 'modulo', 'equals', 'negate'], function(name) { this['__' + name] = '#' + name; }, diff --git a/dist/paper-core.js b/dist/paper-core.js index 414f5a79..5a86be47 100644 --- a/dist/paper-core.js +++ b/dist/paper-core.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Fri Jun 10 13:04:57 2016 +0200 + * Date: Fri Jun 10 13:41:36 2016 +0200 * *** * diff --git a/dist/paper-core.min.js b/dist/paper-core.min.js index 65ae0066..d683b5a0 100644 --- a/dist/paper-core.min.js +++ b/dist/paper-core.min.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Fri Jun 10 13:04:57 2016 +0200 + * Date: Fri Jun 10 13:41:36 2016 +0200 * *** * diff --git a/dist/paper-full.js b/dist/paper-full.js index bce7bfd1..d3cd3639 100644 --- a/dist/paper-full.js +++ b/dist/paper-full.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Fri Jun 10 13:04:57 2016 +0200 + * Date: Fri Jun 10 13:41:36 2016 +0200 * *** * @@ -14149,8 +14149,8 @@ Base.exports.PaperScript = (function() { '*': '__multiply', '/': '__divide', '%': '__modulo', - '==': 'equals', - '!=': 'equals' + '==': '__equals', + '!=': '__equals' }; var unaryOperators = { @@ -14159,7 +14159,7 @@ Base.exports.PaperScript = (function() { }; var fields = Base.each( - ['add', 'subtract', 'multiply', 'divide', 'modulo', 'negate'], + ['add', 'subtract', 'multiply', 'divide', 'modulo', 'equals', 'negate'], function(name) { this['__' + name] = '#' + name; }, diff --git a/dist/paper-full.min.js b/dist/paper-full.min.js index a8f84bbd..592682bf 100644 --- a/dist/paper-full.min.js +++ b/dist/paper-full.min.js @@ -9,7 +9,7 @@ * * All rights reserved. * - * Date: Fri Jun 10 13:04:57 2016 +0200 + * Date: Fri Jun 10 13:41:36 2016 +0200 * *** * @@ -36,4 +36,4 @@ var F=l+(c-l)*v,j=l+(c-l)*p;if(Math.max(d-f,j-F)<1e-9){var D=(F+j)/2,R=(f+d)/2;r s(o.add(u)),s(o.subtract(u))},getHandleBounds:function(t,e,i,n,r){var s,a,o=i.getStyle(),h=r.stroke&&o.hasStroke();if(h){var u=i._getStrokeMatrix(n,r),l=o.getStrokeWidth()/2,c=l;"miter"===o.getStrokeJoin()&&(c=l*o.getMiterLimit()),"square"===o.getStrokeCap()&&(c=Math.max(c,l*Math.sqrt(2))),s=E._getStrokePadding(l,u),a=E._getStrokePadding(c,u)}for(var f=new Array(6),d=1/0,_=-d,v=d,p=_,m=0,y=t.length;y>m;m++){var w=t[m];w._transformCoordinates(n,f);for(var x=0;6>x;x+=2){var b=0===x?a:s,C=b?b[0]:0,S=b?b[1]:0,k=f[x],I=f[x+1],P=k-C,A=k+C,M=I-S,T=I+S;d>P&&(d=P),A>_&&(_=A),v>M&&(v=M),T>p&&(p=T)}}return new g(d,v,_-d,p-v)}}});E.inject({statics:new function(){function t(t,e,i){var n=r.getNamed(i),s=new E(n&&n.insert===!1&&w.NO_INSERT);return s._add(t),s._closed=e,s.set(n)}function e(e,i,r){for(var s=new Array(4),a=0;4>a;a++){var o=n[a];s[a]=new A(o._point.multiply(i).add(e),o._handleIn.multiply(i),o._handleOut.multiply(i))}return t(s,!0,r)}var i=.5522847498307936,n=[new A([-1,0],[0,i],[0,-i]),new A([0,-1],[-i,0],[i,0]),new A([1,0],[0,-i],[0,i]),new A([0,1],[i,0],[-i,0])];return{Line:function(){return t([new A(c.readNamed(arguments,"from")),new A(c.readNamed(arguments,"to"))],!1,arguments)},Circle:function(){var t=c.readNamed(arguments,"center"),i=r.readNamed(arguments,"radius");return e(t,new d(i),arguments)},Rectangle:function(){var e,n=g.readNamed(arguments,"rectangle"),r=d.readNamed(arguments,"radius",0,{readNull:!0}),s=n.getBottomLeft(!0),a=n.getTopLeft(!0),o=n.getTopRight(!0),h=n.getBottomRight(!0);if(!r||r.isZero())e=[new A(s),new A(a),new A(o),new A(h)];else{r=d.min(r,n.getSize(!0).divide(2));var u=r.width,l=r.height,c=u*i,f=l*i;e=[new A(s.add(u,0),null,[-c,0]),new A(s.subtract(0,l),[0,f]),new A(a.add(0,l),null,[0,-f]),new A(a.add(u,0),[-c,0],null),new A(o.subtract(u,0),null,[c,0]),new A(o.add(0,l),[0,-f],null),new A(h.subtract(0,l),null,[0,f]),new A(h.subtract(u,0),[c,0])]}return t(e,!0,arguments)},RoundRectangle:"#Rectangle",Ellipse:function(){var t=C._readEllipse(arguments);return e(t.center,t.radius,arguments)},Oval:"#Ellipse",Arc:function(){var t=c.readNamed(arguments,"from"),e=c.readNamed(arguments,"through"),i=c.readNamed(arguments,"to"),n=r.getNamed(arguments),s=new E(n&&n.insert===!1&&w.NO_INSERT);return s.moveTo(t),s.arcTo(e,i),s.set(n)},RegularPolygon:function(){for(var e=c.readNamed(arguments,"center"),i=r.readNamed(arguments,"sides"),n=r.readNamed(arguments,"radius"),s=360/i,a=i%3===0,o=new c(0,a?-n:n),h=a?-1:.5,u=new Array(i),l=0;i>l;l++)u[l]=new A(e.add(o.rotate((l+h)*s)));return t(u,!0,arguments)},Star:function(){for(var e=c.readNamed(arguments,"center"),i=2*r.readNamed(arguments,"points"),n=r.readNamed(arguments,"radius1"),s=r.readNamed(arguments,"radius2"),a=360/i,o=new c(0,-1),h=new Array(i),u=0;i>u;u++)h[u]=new A(e.add(o.rotate(a*u).multiply(u%2?s:n)));return t(h,!0,arguments)}}}});var L=O.extend({_class:"CompoundPath",_serializeFields:{children:[]},initialize:function(t){this._children=[],this._namedChildren={},this._initialize(t)||("string"==typeof t?this.setPathData(t):this.addChildren(Array.isArray(t)?t:arguments))},insertChildren:function mt(t,i,n){for(var r=i.length-1;r>=0;r--){var s=i[r];s instanceof L&&(i=i.slice(),i.splice.apply(i,[r,1].concat(s.removeChildren())),s.remove())}i=mt.base.call(this,t,i,n,E);for(var r=0,a=!n&&i&&i.length;a>r;r++){var s=i[r];s._clockwise===e&&s.setClockwise(0===s._index)}return i},reduce:function yt(t){for(var e=this._children,i=e.length-1;i>=0;i--){var n=e[i].reduce(t);n.isEmpty()&&n.remove()}if(0===e.length){var n=new E(w.NO_INSERT);return n.copyAttributes(this),n.insertAbove(this),this.remove(),n}return yt.base.call(this)},isClockwise:function(){var t=this.getFirstChild();return t&&t.isClockwise()},setClockwise:function(t){this.isClockwise()^!!t&&this.reverse()},getFirstSegment:function(){var t=this.getFirstChild();return t&&t.getFirstSegment()},getLastSegment:function(){var t=this.getLastChild();return t&&t.getLastSegment()},getCurves:function(){for(var t=this._children,e=[],i=0,n=t.length;n>i;i++)e.push.apply(e,t[i].getCurves());return e},getFirstCurve:function(){var t=this.getFirstChild();return t&&t.getFirstCurve()},getLastCurve:function(){var t=this.getLastChild();return t&&t.getFirstCurve()},getArea:function(){for(var t=this._children,e=0,i=0,n=t.length;n>i;i++)e+=t[i].getArea();return e}},{beans:!0,getPathData:function(t,e){for(var i=this._children,n=[],r=0,s=i.length;s>r;r++){var a=i[r],o=a._matrix;n.push(a.getPathData(t&&!o.isIdentity()?t.appended(o):t,e))}return n.join(" ")}},{_hitTestChildren:function wt(t,e,i){return wt.base.call(this,t,e["class"]===E||"path"===e.type?e:r.set({},e,{fill:!1}),i)},_draw:function(t,e,i,n){var r=this._children;if(0!==r.length){e=e.extend({dontStart:!0,dontFinish:!0}),t.beginPath();for(var s=0,a=r.length;a>s;s++)r[s].draw(t,e,n);if(!e.clip){this._setStyles(t,e,i);var o=this._style;o.hasFill()&&(t.fill(o.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),o.hasStroke()&&t.stroke()}}},_drawSelected:function(t,e,i){for(var n=this._children,r=0,s=n.length;s>r;r++){var a=n[r],o=a._matrix;i[a._id]||a._drawSelected(t,o.isIdentity()?e:e.appended(o))}}},new function(){function t(t,e){var i=t._children;if(e&&0===i.length)throw new Error("Use a moveTo() command first");return i[i.length-1]}return r.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(e){this[e]=function(){var i=t(this,!0);i[e].apply(i,arguments)}},{moveTo:function(){var e=t(this),i=e&&e.isEmpty()?e:new E(w.NO_INSERT);i!==e&&this.addChild(i),i.moveTo.apply(i,arguments)},moveBy:function(){var e=t(this,!0),i=e&&e.getLastSegment(),n=c.read(arguments);this.moveTo(i?n.add(i._point):n)},closePath:function(e){t(this,!0).closePath(e)}})},r.each(["reverse","flatten","simplify","smooth"],function(t){this[t]=function(e){for(var i,n=this._children,r=0,s=n.length;s>r;r++)i=n[r][t](e)||i;return i}},{}));O.inject(new function(){function t(t,e){var i=t.clone(!1).reduce({simplify:!0}).transform(null,!0,!0);return e?i.resolveCrossings():i}function e(t,e,i,n,r){var s=new t(w.NO_INSERT);return s.addChildren(e,!0),i&&(s=s.reduce({simplify:!0})),s.insertAbove(r&&n.isSibling(r)&&n.getIndex()e;e++){var n=t[e];g.push.apply(g,n._segments),v.push.apply(v,n._getMonoCurves()),n._overlapsOnly=n._validOverlapsOnly=!0}}var u=f[s];if(u[s]=!0,!i._children&&!i._closed)return n(i,r,u);var c=t(i,!0),d=r&&i!==r&&t(r,!0);d&&(u.subtract||u.exclude)^(d.isClockwise()^c.isClockwise())&&d.reverse();var _=a(z.expand(c.getCrossings(d))),g=[],v=[];o(c._children||[c]),d&&o(d._children||[d]);for(var p=0,m=_.length;m>p;p++)h(_[p]._segment,c,d,v,u);for(var p=0,m=g.length;m>p;p++){var y=g[p],w=y._intersection;if(null==y._winding&&h(y,c,d,v,u),!w||!w._overlap){var x=y._path;x._overlapsOnly=!1,u[y._winding]&&(x._validOverlapsOnly=!1)}}return e(L,l(g,u),!0,i,r)}function n(i,n,r){function s(t){return o.contains(t.getPointAt(t.getLength()/2))^u?(l.unshift(t),!0):void 0}if(!n||!n._children&&!n._closed||!r.subtract&&!r.intersect)return null;for(var a=t(i,!1),o=t(n,!1),h=a.getCrossings(o),u=r.subtract,l=[],c=h.length-1;c>=0;c--){var f=h[c].split();f&&(s(f)&&f.getFirstSegment().setHandleIn(0,0),a.getLastSegment().setHandleOut(0,0))}return s(a),e(x,l,!1,i,n)}function s(t,e){for(var i=t;i;){if(i===e)return;i=i._previous}for(;t._next&&t._next!==e;)t=t._next;if(!t._next){for(;e._previous;)e=e._previous;t._next=e,e._previous=t}}function a(t,e){for(var i,n,r=e&&[],a=4e-7,o=1-a,h=!1,u=[],l=t.length-1;l>=0;l--){var c=t[l];if(e){if(!e(c))continue;r.unshift(c)}var f,d=c._curve,_=c._time,g=_;if(d!==i?h=!d.hasHandles():n>=a&&o>=n&&(_/=n),a>_)f=d._segment1;else if(_>o)f=d._segment2;else{var v=d.divideAtTime(_,!0);h&&u.push(d,v),f=v._segment1}c._setSegment(f);var p=f._intersection,m=c._intersection;if(p){s(p,m);for(var y=p;y;)s(y._intersection,p),y=y._next}else f._intersection=m;i=d,n=g}for(var l=0,w=u.length;w>l;l++)u[l].clearHandles();return r||t}function o(t,e,i,n){var r=2e-7,s=t.x,a=t.y,h=0,u=0,l=e.length,f=[],d=Math.abs;if(n){for(var _=-(1/0),g=1/0,v=a-r,p=a+r,m=0;l>m;m++)for(var y=e[m].values,w=T.solveCubic(y,0,s,f,0,1),x=w-1;x>=0;x--){var b=T.getPoint(y,f[x]).y;v>b&&b>_?_=b:b>p&&g>b&&(g=b)}_=(_+a)/2,g=(g+a)/2,_>-(1/0)&&(h=o(new c(s,_),e,i)),1/0>g&&(u=o(new c(s,g),e,i))}else{for(var C,S,k=s-r,I=s+r,P=0,A=0,M=!1,m=0;l>m;m++){var z=e[m],O=z.winding,y=z.values,E=y[1],L=y[7];if(z.last&&(C=z.last.winding,S=z.last.values[6],M=!1),a>=E&&L>=a||a>=L&&E>=a)if(O){var N=a===E?y[0]:a===L?y[6]:1===T.solveCubic(y,1,a,f,0,1)?T.getPoint(y,f[0]).x:null;null!=N&&(N>=k&&I>=N?M=!0:a===E&&O===C||a===E&&0>(s-N)*(s-S)||(k>N?h+=O:N>I&&(u+=O))),C=O,S=y[6]}else(s-y[0])*(s-y[6])<=0&&(M=!0);M&&(m>=l-1||e[m+1].last)&&(P+=1,A-=1)}0===h&&0===u&&(h=P,u=A)}return i&&i.unite&&!h^!u?1:Math.max(d(h),d(u))}function h(t,e,i,n,r){var s=[],a=t,h=0,u=0;do{var l=t.getCurve(),c=l.getLength();s.push({segment:t,curve:l,length:c}),h+=c,t=t.getNext()}while(t&&!t._intersection&&t!==a);for(var f=0;3>f;f++)for(var c=h*(f+1)/4,d=0,_=s.length;_>d;d++){var g=s[d],v=g.length;if(v>=c){var l=g.curve,p=l._path,m=p._parent,y=l.getTimeAt(c),w=l.getPointAtTime(y),x=Math.abs(l.getTangentAtTime(y).y)<1e-7;m instanceof L&&(p=m),r.subtract&&i&&(p===e&&i._getWinding(w,r,x)||p===i&&!e._getWinding(w,r,x))||(u+=o(w,n,r,x));break}c-=v}for(var b=Math.round(u/3),d=s.length-1;d>=0;d--)s[d].segment._winding=b}function l(t,e){function i(t){return!(t._visited||e&&!e[t._winding])}function n(t){return t===a||t===o}function s(t,r,s){if(!t._next)return t;for(;t;){var a=t._segment,o=a.getNext(),h=o._intersection;if(a!==r&&(n(a)||n(o)||!a._visited&&!o._visited&&(!e||(!s||i(a))&&(!(s&&h&&h._overlap)&&i(o)||!s&&h&&i(h._segment)))))return t;t=t._next}return null}for(var a,o,h=[],l=0,c=t.length;c>l;l++){var f,d=null,_=!1,g=t[l],v=g._intersection;if(!g._visited&&g._path._overlapsOnly){var p=g._path,m=v._segment._path,y=p._segments,x=m._segments;if(r.equals(y,x)){(e.unite||e.intersect)&&p.getArea()&&h.push(p.clone(!1));for(var b=0,C=y.length;C>b;b++)y[b]._visited=x[b]._visited=!0}}if(!(!i(g)||!g._path._validOverlapsOnly&&v&&g._winding&&v._overlap)){for(a=o=null;;){v=v&&(s(v,g,!0)||s(v,g,!1))||v;var S=v&&v._segment;if(n(g)?_=!0:S&&(n(S)?(_=!0,g=S):i(S)&&(e&&v._overlap&&(e.intersect||e.subtract)&&(g._visited=!0),g=S)),_||g._visited){g._visited=!0;break}if(g._path._validOverlapsOnly&&!i(g))break;d||(d=new E(w.NO_INSERT),a=g,o=S);var k=g.getNext();d.add(new A(g._point,f,k&&g._handleOut)),g._visited=!0,g=k||g._path.getFirstSegment(),f=k&&k._handleIn,v=g._intersection}if(_)d.firstSegment.setHandleIn(f),d.setClosed(!0);else if(d){var I=d.getLength();I>=2e-7&&console.error("Boolean operation resulted in open path","segments =",d._segments.length,"length =",I),d=null}d&&(d._segments.length>8||!u.isZero(d.getArea()))&&(h.push(d),d=null)}}return h}var f={unite:{1:!0},intersect:{2:!0},subtract:{1:!0},exclude:{1:!0}};return{_getWinding:function(t,e,i){return o(t,this._getMonoCurves(),e,i)},unite:function(t){return i(this,t,"unite")},intersect:function(t){return i(this,t,"intersect")},subtract:function(t){return i(this,t,"subtract")},exclude:function(t){return i(this,t,"exclude")},divide:function(t){return e(x,[this.subtract(t),this.intersect(t)],!0,this,t)},resolveCrossings:function(){function t(t){var e=t&&t._intersection;return e&&e._overlap}var e=this._children,i=e||[this],n=!1,s=!1,o=this.getIntersections(null,function(t){return t._overlap&&(n=!0)||t.isCrossing()&&(s=!0)});if(o=z.expand(o),n)for(var h=a(o,function(t){return t._overlap}),u=h.length-1;u>=0;u--){var c=h[u]._segment,f=c.getPrevious(),d=c.getNext();if(c._path&&t(f)&&t(d)){c.remove(),f._handleOut.set(0,0),d._handleIn.set(0,0);var _=f.getCurve();_.isStraight()&&0===_.getLength()&&f.remove()}}s&&(a(o,n&&function(t){var e=t.getCurve(),i=t._intersection._curve,n=t._segment;return e&&i&&e._path&&i._path?!0:void(n&&(n._intersection=null))}),i=l(r.each(i,function(t){this.push.apply(this,t._segments)},[])));var g,v=i.length;if(v>1){i=i.slice().sort(function(t,e){return e.getBounds().getArea()-t.getBounds().getArea()});for(var p=i[0],m=[p],y={},x="nonzero"===this.getFillRule(),b=x&&r.each(i,function(t){this.push(t.isClockwise()?1:-1)},[]),u=1;v>u;u++){for(var C=i[u],S=C.getInteriorPoint(),k=!1,I=null,P=!1,A=u-1;A>=0&&!I;A--)if(i[A].contains(S)){if(x&&!k&&(b[u]+=b[A],b[u]&&b[A])){P=y[u]=!0;break}k=!0,I=!y[A]&&i[A]}P||(C.setClockwise(I?!I.isClockwise():p.isClockwise()),m.push(C))}i=m,v=m.length}return v>1&&e?(i!==e&&this.setChildren(i,!0),g=this):1!==v||e||(i[0]!==this&&this.setSegments(i[0].removeSegments()),g=this),g||(g=new L(w.NO_INSERT),g.addChildren(i,!0),g=g.reduce(),g.copyAttributes(this),this.replaceWith(g)),g}}}),E.inject({_getMonoCurves:function(){function t(t){var e=t[1],r=t[7],s=Math.abs((e-r)/(t[0]-t[6]))<2e-7?0:e>r?-1:1,a={values:t,winding:s};n.push(a),s&&(i=a)}function e(e){if(0!==T.getLength(e)){var i=e[1],n=e[3],r=e[5],s=e[7];if(T.isStraight(e)||i>=n==n>=r&&n>=r==r>=s)t(e);else{var a=3*(n-r)-i+s,o=2*(i+r)-4*n,h=n-i,l=4e-7,c=1-l,f=[],d=u.solveQuadratic(a,o,h,f,l,c);if(0===d)t(e);else{f.sort();var _=f[0],g=T.subdivide(e,_);t(g[0]),d>1&&(_=(f[1]-_)/(1-_),g=T.subdivide(g[1],_),t(g[0])),t(g[1])}}}}var i,n=this._monoCurves;if(!n){n=this._monoCurves=[];for(var r=this.getCurves(),s=this._segments,a=0,o=r.length;o>a;a++)e(r[a].getValues());if(!this._closed&&s.length>1){var h=s[s.length-1]._point,l=s[0]._point,c=h._x,f=h._y,d=l._x,_=l._y;e([c,f,c,f,d,_,d,_])}n.length>0&&(n[0].last=i)}return n},getInteriorPoint:function(){var t=this.getBounds(),e=t.getCenter(!0);if(!this.contains(e)){for(var i=this._getMonoCurves(),n=[],r=e.y,s=[],a=0,o=i.length;o>a;a++){var h=i[a].values;if(1===i[a].winding&&r>h[1]&&r<=h[7]||r>=h[7]&&r=0;l--)s.push(T.getPoint(h,n[l]).x)}s.sort(function(t,e){return t-e}),e.x=(s[0]+s[1])/2}return e}}),L.inject({_getMonoCurves:function(){for(var t=this._children,e=[],i=0,n=t.length;n>i;i++)e.push.apply(e,t[i]._getMonoCurves());return e}});var N=r.extend({_class:"PathIterator",initialize:function(t,e,i,n,r){function s(t,e){var i=T.getValues(t,e,r);h.push(i),a(i,t._index,0,1)}function a(t,i,r,s){if(!(s-r>c)||n&&T.isStraight(t)||T.isFlatEnough(t,e||.25)){var o=t[6]-t[0],h=t[7]-t[1],f=Math.sqrt(o*o+h*h);f>0&&(l+=f,u.push({offset:l,curve:t,index:i,time:s}))}else{var d=T.subdivide(t,.5),_=(r+s)/2;a(d[0],i,r,_),a(d[1],i,_,s)}}for(var o,h=[],u=[],l=0,c=1/(i||32),f=t._segments,d=f[0],_=1,g=f.length;g>_;_++)o=f[_],s(d,o),d=o;t._closed&&s(o,f[0]),this.curves=h,this.parts=u,this.length=l,this.index=0},_get:function(t){for(var e,i=this.index;e=i,!(0===i||this.parts[--i].offsete;e++){var r=this.parts[e];if(r.offset>=t){this.index=e;var s=this.parts[e-1],a=s&&s.index===r.index?s.time:0,o=s?s.offset:0;return{index:r.index,time:a+(r.time-a)*(t-o)/(r.offset-o)}}}var r=this.parts[this.parts.length-1];return{index:r.index,time:1}},drawPart:function(t,e,i){for(var n=this._get(e),r=this._get(i),s=n.index,a=r.index;a>=s;s++){var o=T.getPart(this.curves[s],s===n.index?n.time:0,s===r.index?r.time:1);s===n.index&&t.moveTo(o[0],o[1]),t.bezierCurveTo.apply(t,o.slice(2))}}},r.each(T._evaluateMethods,function(t){this[t+"At"]=function(e){var i=this._get(e);return T[t](this.curves[i.index],i.time)}},{})),B=r.extend({initialize:function(t){for(var e,i=this.points=[],n=t._segments,r=t._closed,s=0,a=n.length;a>s;s++){var o=n[s].point;e&&e.equals(o)||i.push(e=o.clone())}r&&(i.unshift(i[i.length-1]),i.push(i[1])),this.closed=r},fit:function(t){var e=this.points,i=e.length,n=null;return i>0&&(n=[new A(e[0])],i>1&&(this.fitCubic(n,t,0,i-1,e[1].subtract(e[0]),e[i-2].subtract(e[i-1])),this.closed&&(n.shift(),n.pop()))),n},fitCubic:function(t,e,i,n,r,s){var a=this.points;if(n-i===1){var o=a[i],h=a[n],u=o.getDistance(h)/3;return void this.addCurve(t,[o,o.add(r.normalize(u)),h.add(s.normalize(u)),h])}for(var l,c=this.chordLengthParameterize(i,n),f=Math.max(e,e*e),d=!0,_=0;4>=_;_++){var g=this.generateBezier(i,n,c,r,s),v=this.findMaxError(i,n,g,c);if(v.error=f)break;d=this.reparameterize(i,n,c,g),f=v.error}var p=a[l-1].subtract(a[l+1]);this.fitCubic(t,e,i,l,r,p),this.fitCubic(t,e,l,n,p.negate(),s)},addCurve:function(t,e){var i=t[t.length-1];i.setHandleOut(e[1].subtract(e[0])),t.push(new A(e[3],e[2].subtract(e[3])))},generateBezier:function(t,e,i,n,r){for(var s=1e-12,a=Math.abs,o=this.points,h=o[t],u=o[e],l=[[0,0],[0,0]],c=[0,0],f=0,d=e-t+1;d>f;f++){var _=i[f],g=1-_,v=3*_*g,p=g*g*g,m=v*g,y=v*_,w=_*_*_,x=n.normalize(m),b=r.normalize(y),C=o[t+f].subtract(h.multiply(p+m)).subtract(u.multiply(y+w));l[0][0]+=x.dot(x),l[0][1]+=x.dot(b),l[1][0]=l[0][1],l[1][1]+=b.dot(b),c[0]+=x.dot(C),c[1]+=b.dot(C)}var S,k,I=l[0][0]*l[1][1]-l[1][0]*l[0][1];if(a(I)>s){var P=l[0][0]*c[1]-l[1][0]*c[0],A=c[0]*l[1][1]-c[1]*l[0][1];S=A/I,k=P/I}else{var M=l[0][0]+l[0][1],T=l[1][0]+l[1][1];S=k=a(M)>s?c[0]/M:a(T)>s?c[1]/T:0}var z,O,E=u.getDistance(h),L=s*E;if(L>S||L>k)S=k=E/3;else{var N=u.subtract(h);z=n.normalize(S),O=r.normalize(k),z.dot(N)-O.dot(N)>E*E&&(S=k=E/3,z=O=null)}return[h,h.add(z||n.normalize(S)),u.add(O||r.normalize(k)),u]},reparameterize:function(t,e,i,n){for(var r=t;e>=r;r++)i[r-t]=this.findRoot(n,this.points[r],i[r-t]);for(var r=1,s=i.length;s>r;r++)if(i[r]<=i[r-1])return!1;return!0},findRoot:function(t,e,i){for(var n=[],r=[],s=0;2>=s;s++)n[s]=t[s+1].subtract(t[s]).multiply(3);for(var s=0;1>=s;s++)r[s]=n[s+1].subtract(n[s]).multiply(2);var a=this.evaluate(3,t,i),o=this.evaluate(2,n,i),h=this.evaluate(1,r,i),u=a.subtract(e),l=o.dot(o)+u.dot(h);return Math.abs(l)<1e-6?i:i-u.dot(o)/l},evaluate:function(t,e,i){for(var n=e.slice(),r=1;t>=r;r++)for(var s=0;t-r>=s;s++)n[s]=n[s].multiply(1-i).add(n[s+1].multiply(i));return n[0]},chordLengthParameterize:function(t,e){for(var i=[0],n=t+1;e>=n;n++)i[n-t]=i[n-t-1]+this.points[n].getDistance(this.points[n-1]);for(var n=1,r=e-t;r>=n;n++)i[n]/=i[r];return i},findMaxError:function(t,e,i,n){for(var r=Math.floor((e-t+1)/2),s=0,a=t+1;e>a;a++){var o=this.evaluate(3,i,n[a-t]),h=o.subtract(this.points[a]),u=h.x*h.x+h.y*h.y;u>=s&&(s=u,r=a)}return{error:s,index:r}}}),F=w.extend({_class:"TextItem",_applyMatrix:!1,_canApplyMatrix:!1,_serializeFields:{content:null},_boundsOptions:{stroke:!1,handle:!1},initialize:function(t){this._content="",this._lines=[];var i=t&&r.isPlainObject(t)&&t.x===e&&t.y===e;this._initialize(i&&t,!i&&c.read(arguments))},_equals:function(t){return this._content===t._content},copyContent:function(t){this.setContent(t._content)},getContent:function(){return this._content},setContent:function(t){this._content=""+t,this._lines=this._content.split(/\r\n|\n|\r/gm),this._changed(265)},isEmpty:function(){return!this._content},getCharacterStyle:"#getStyle",setCharacterStyle:"#setStyle",getParagraphStyle:"#getStyle",setParagraphStyle:"#setStyle"}),j=F.extend({_class:"PointText",initialize:function(){F.apply(this,arguments)},getPoint:function(){var t=this._matrix.getTranslation();return new f(t.x,t.y,this,"setPoint")},setPoint:function(){var t=c.read(arguments);this.translate(t.subtract(this._matrix.getTranslation()))},_draw:function(t,e,i){if(this._content){this._setStyles(t,e,i);var n=this._lines,r=this._style,s=r.hasFill(),a=r.hasStroke(),o=r.getLeading(),h=t.shadowColor;t.font=r.getFontStyle(),t.textAlign=r.getJustification();for(var u=0,l=n.length;l>u;u++){t.shadowColor=h;var c=n[u];s&&(t.fillText(c,0,0),t.shadowColor="rgba(0,0,0,0)"),a&&t.strokeText(c,0,0),t.translate(0,o)}}},_getBounds:function(t,e){var i=this._style,n=this._lines,r=n.length,s=i.getJustification(),a=i.getLeading(),o=this.getView().getTextWidth(i.getFontStyle(),n),h=0;"left"!==s&&(h-=o/("center"===s?2:1));var u=new g(h,r?-.75*a:0,o,r*a);return t?t._transformBounds(u,u):u}}),D=r.extend(new function(){function t(t){var n,r=t.match(/^#(\w{1,2})(\w{1,2})(\w{1,2})$/);if(r){n=[0,0,0];for(var s=0;3>s;s++){var o=r[s+1];n[s]=parseInt(1==o.length?o+o:o,16)/255}}else if(r=t.match(/^rgba?\((.*)\)$/)){n=r[1].split(",");for(var s=0,h=n.length;h>s;s++){var o=+n[s];n[s]=3>s?o/255:o}}else if(i){var u=a[t];if(!u){e||(e=tt.getContext(1,1),e.globalCompositeOperation="copy"),e.fillStyle="rgba(0,0,0,0)",e.fillStyle=t,e.fillRect(0,0,1,1);var l=e.getImageData(0,0,1,1).data;u=a[t]=[l[0]/255,l[1]/255,l[2]/255]}n=u.slice()}else n=[0,0,0];return n}var e,n={gray:["gray"],rgb:["red","green","blue"],hsb:["hue","saturation","brightness"],hsl:["hue","saturation","lightness"],gradient:["gradient","origin","destination","highlight"]},s={},a={},o=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]],u={"rgb-hsb":function(t,e,i){var n=Math.max(t,e,i),r=Math.min(t,e,i),s=n-r,a=0===s?0:60*(n==t?(e-i)/s+(i>e?6:0):n==e?(i-t)/s+2:(t-e)/s+4);return[a,0===n?0:s/n,n]},"hsb-rgb":function(t,e,i){t=(t/60%6+6)%6;var n=Math.floor(t),r=t-n,n=o[n],s=[i,i*(1-e),i*(1-e*r),i*(1-e*(1-r))];return[s[n[0]],s[n[1]],s[n[2]]]},"rgb-hsl":function(t,e,i){var n=Math.max(t,e,i),r=Math.min(t,e,i),s=n-r,a=0===s,o=a?0:60*(n==t?(e-i)/s+(i>e?6:0):n==e?(i-t)/s+2:(t-e)/s+4),h=(n+r)/2,u=a?0:.5>h?s/(n+r):s/(2-n-r);return[o,u,h]},"hsl-rgb":function(t,e,i){if(t=(t/360%1+1)%1,0===e)return[i,i,i];for(var n=[t+1/3,t,t-1/3],r=.5>i?i*(1+e):i+e-i*e,s=2*i-r,a=[],o=0;3>o;o++){var h=n[o];0>h&&(h+=1),h>1&&(h-=1),a[o]=1>6*h?s+6*(r-s)*h:1>2*h?r:2>3*h?s+(r-s)*(2/3-h)*6:s}return a},"rgb-gray":function(t,e,i){return[.2989*t+.587*e+.114*i]},"gray-rgb":function(t){return[t,t,t]},"gray-hsb":function(t){return[0,0,t]},"gray-hsl":function(t){return[0,0,t]},"gradient-rgb":function(){return[]},"rgb-gradient":function(){return[]}};return r.each(n,function(t,e){s[e]=[],r.each(t,function(t,i){var a=r.capitalize(t),o=/^(hue|saturation)$/.test(t),h=s[e][i]="gradient"===t?function(t){var e=this._components[0];return t=R.read(Array.isArray(t)?t:arguments,0,{readNull:!0}),e!==t&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:"gradient"===e?function(){return c.read(arguments,0,{readNull:"highlight"===t,clone:!0})}:function(t){return null==t||isNaN(t)?0:t};this["get"+a]=function(){return this._type===e||o&&/^hs[bl]$/.test(this._type)?this._components[i]:this._convert(e)[i]},this["set"+a]=function(t){this._type===e||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(e),this._properties=n[e],this._type=e),this._components[i]=h.call(this,t),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function f(e){var i,r,a,o,h=Array.prototype.slice,u=arguments,c=0;Array.isArray(e)&&(u=e,e=u[0]);var d=null!=e&&typeof e;if("string"===d&&e in n&&(i=e,e=u[1],Array.isArray(e)?(r=e,a=u[2]):(this.__read&&(c=1),u=h.call(u,1),d=typeof e)),!r){if(o="number"===d?u:"object"===d&&null!=e.length?e:null){i||(i=o.length>=3?"rgb":"gray");var _=n[i].length;a=o[_],this.__read&&(c+=o===arguments?_+(null!=a?1:0):1),o.length>_&&(o=h.call(o,0,_))}else if("string"===d)i="rgb",r=t(e),4===r.length&&(a=r[3],r.length--);else if("object"===d)if(e.constructor===f){if(i=e._type,r=e._components.slice(),a=e._alpha,"gradient"===i)for(var g=1,v=r.length;v>g;g++){var p=r[g];p&&(r[g]=p.clone())}}else if(e.constructor===R)i="gradient",o=u;else{i="hue"in e?"lightness"in e?"hsl":"hsb":"gradient"in e||"stops"in e||"radial"in e?"gradient":"gray"in e?"gray":"rgb";var m=n[i],y=s[i];this._components=r=[];for(var g=0,v=m.length;v>g;g++){var w=e[m[g]];null==w&&0===g&&"gradient"===i&&"stops"in e&&(w={stops:e.stops,radial:e.radial}),w=y[g].call(this,w),null!=w&&(r[g]=w)}a=e.alpha}this.__read&&i&&(c=1)}if(this._type=i||"rgb",this._id=l.get(f),!r){this._components=r=[];for(var y=s[this._type],g=0,v=y.length;v>g;g++){var w=y[g].call(this,o&&o[g]);null!=w&&(r[g]=w)}}this._components=r,this._properties=n[this._type],this._alpha=a,this.__read&&(this.__read=c)},_serialize:function(t,e){var i=this.getComponents();return r.serialize(/^(gray|rgb)$/.test(this._type)?i:[this._type].concat(i),t,!0,e)},_changed:function(){this._canvasStyle=null,this._owner&&this._owner._changed(65)},_convert:function(t){var e;return this._type===t?this._components.slice():(e=u[this._type+"-"+t])?e.apply(this,this._components):u["rgb-"+t].apply(this,u[this._type+"-rgb"].apply(this,this._components))},convert:function(t){return new D(t,this._convert(t),this._alpha)},getType:function(){return this._type},setType:function(t){this._components=this._convert(t),this._properties=n[t],this._type=t},getComponents:function(){var t=this._components.slice();return null!=this._alpha&&t.push(this._alpha),t},getAlpha:function(){return null!=this._alpha?this._alpha:1},setAlpha:function(t){this._alpha=null==t?null:Math.min(Math.max(t,0),1),this._changed()},hasAlpha:function(){return null!=this._alpha},equals:function(t){var e=r.isPlainValue(t,!0)?D.read(arguments):t;return e===this||e&&this._class===e._class&&this._type===e._type&&this._alpha===e._alpha&&r.equals(this._components,e._components)||!1},toString:function(){for(var t=this._properties,e=[],i="gradient"===this._type,n=h.instance,r=0,s=t.length;s>r;r++){var a=this._components[r];null!=a&&e.push(t[r]+": "+(i?a:n.number(a)))}return null!=this._alpha&&e.push("alpha: "+n.number(this._alpha)),"{ "+e.join(", ")+" }"},toCSS:function(t){function e(t){return Math.round(255*(0>t?0:t>1?1:t))}var i=this._convert("rgb"),n=t||null==this._alpha?1:this._alpha;return i=[e(i[0]),e(i[1]),e(i[2])],1>n&&i.push(0>n?0:n),t?"#"+((1<<24)+(i[0]<<16)+(i[1]<<8)+i[2]).toString(16).slice(1):(4==i.length?"rgba(":"rgb(")+i.join(",")+")"},toCanvasStyle:function(t){if(this._canvasStyle)return this._canvasStyle;if("gradient"!==this._type)return this._canvasStyle=this.toCSS();var e,i=this._components,n=i[0],r=n._stops,s=i[1],a=i[2];if(n._radial){var o=a.getDistance(s),h=i[3];if(h){var u=h.subtract(s);u.getLength()>o&&(h=s.add(u.normalize(o-.1)))}var l=h||s;e=t.createRadialGradient(l.x,l.y,0,s.x,s.y,o)}else e=t.createLinearGradient(s.x,s.y,a.x,a.y);for(var c=0,f=r.length;f>c;c++){var d=r[c];e.addColorStop(d._offset||c/(f-1),d._color.toCanvasStyle())}return this._canvasStyle=e},transform:function(t){if("gradient"===this._type){for(var e=this._components,i=1,n=e.length;n>i;i++){var r=e[i];t._transformPoint(r,r,!0)}this._changed()}},statics:{_types:n,random:function(){var t=Math.random;return new D(t(),t(),t())}}})},new function(){var t={add:function(t,e){return t+e},subtract:function(t,e){return t-e},multiply:function(t,e){return t*e},divide:function(t,e){return t/e}};return r.each(t,function(t,e){this[e]=function(e){e=D.read(arguments);for(var i=this._type,n=this._components,r=e._convert(i),s=0,a=n.length;a>s;s++)r[s]=t(n[s],r[s]);return new D(i,r,null!=this._alpha?t(this._alpha,e.getAlpha()):null)}},{})}),R=r.extend({_class:"Gradient",initialize:function(t,e){this._id=l.get(),t&&this._set(t)&&(t=e=null),this._stops||this.setStops(t||["white","black"]),null==this._radial&&this.setRadial("string"==typeof e&&"radial"===e||e||!1)},_serialize:function(t,e){return e.add(this,function(){return r.serialize([this._stops,this._radial],t,!0,e)})},_changed:function(){for(var t=0,e=this._owners&&this._owners.length;e>t;t++)this._owners[t]._changed()},_addOwner:function(t){this._owners||(this._owners=[]),this._owners.push(t)},_removeOwner:function(t){var i=this._owners?this._owners.indexOf(t):-1;-1!=i&&(this._owners.splice(i,1),0===this._owners.length&&(this._owners=e))},clone:function(){for(var t=[],e=0,i=this._stops.length;i>e;e++)t[e]=this._stops[e].clone();return new R(t,this._radial)},getStops:function(){return this._stops},setStops:function(t){if(t.length<2)throw new Error("Gradient stop list needs to contain at least two stops.");var i=this._stops;if(i)for(var n=0,r=i.length;r>n;n++)i[n]._owner=e;i=this._stops=q.readAll(t,0,{clone:!0});for(var n=0,r=i.length;r>n;n++)i[n]._owner=this;this._changed()},getRadial:function(){return this._radial},setRadial:function(t){this._radial=t,this._changed()},equals:function(t){if(t===this)return!0;if(t&&this._class===t._class){var e=this._stops,i=t._stops,n=e.length;if(n===i.length){for(var r=0;n>r;r++)if(!e[r].equals(i[r]))return!1;return!0}}return!1}}),q=r.extend({_class:"GradientStop",initialize:function(t,i){var n=t,r=i;"object"==typeof t&&i===e&&(Array.isArray(t)&&"number"!=typeof t[0]?(n=t[0],r=t[1]):("color"in t||"offset"in t||"rampPoint"in t)&&(n=t.color,r=t.offset||t.rampPoint||0)),this.setColor(n),this.setOffset(r)},clone:function(){return new q(this._color.clone(),this._offset)},_serialize:function(t,e){var i=this._color,n=this._offset;return r.serialize(null==n?[i]:[i,n],t,!0,e)},_changed:function(){this._owner&&this._owner._changed(65)},getOffset:function(){return this._offset},setOffset:function(t){this._offset=t,this._changed()},getRampPoint:"#getOffset",setRampPoint:"#setOffset",getColor:function(){return this._color},setColor:function(){var t=D.read(arguments,0,{clone:!0});t&&(t._owner=this),this._color=t,this._changed()},equals:function(t){return t===this||t&&this._class===t._class&&this._color.equals(t._color)&&this._offset==t._offset||!1}}),V=r.extend(new function(){var t={fillColor:null,fillRule:"nonzero",strokeColor:null,strokeWidth:1,strokeCap:"butt",strokeJoin:"miter",strokeScaling:!0,miterLimit:10,dashOffset:0,dashArray:[],shadowColor:null,shadowBlur:0,shadowOffset:new c,selectedColor:null},i=r.set({},t,{fontFamily:"sans-serif",fontWeight:"normal",fontSize:12,leading:null,justification:"left"}),n=r.set({},i,{fillColor:new D}),s={strokeWidth:97,strokeCap:97,strokeJoin:97,strokeScaling:105,miterLimit:97,fontFamily:9,fontWeight:9,fontSize:9,font:9,leading:9,justification:9},a={beans:!0},o={_class:"Style",beans:!0,initialize:function(e,r,s){this._values={},this._owner=r,this._project=r&&r._project||s||paper.project,this._defaults=!r||r instanceof x?i:r instanceof F?n:t,e&&this.set(e)}};return r.each(i,function(t,i){var n=/Color$/.test(i),h="shadowOffset"===i,u=r.capitalize(i),l=s[i],f="set"+u,d="get"+u;o[f]=function(t){var r=this._owner,s=r&&r._children;if(s&&s.length>0&&!(r instanceof L))for(var a=0,o=s.length;o>a;a++)s[a]._style[f](t);else if(i in this._defaults){var h=this._values[i];h!==t&&(n&&(h&&(h._owner=e),t&&t.constructor===D&&(t._owner&&(t=t.clone()),t._owner=r)),this._values[i]=t,r&&r._changed(l||65))}},o[d]=function(t){var s,a=this._owner,o=a&&a._children;if(i in this._defaults&&(!o||0===o.length||t||a instanceof L)){var s=this._values[i];if(s===e)s=this._defaults[i],s&&s.clone&&(s=s.clone());else{var u=n?D:h?c:null;!u||s&&s.constructor===u||(this._values[i]=s=u.read([s],0,{readNull:!0,clone:!0}),s&&n&&(s._owner=a))}}else if(o)for(var l=0,f=o.length;f>l;l++){var _=o[l]._style[d]();if(0===l)s=_;else if(!r.equals(s,_))return e}return s},a[d]=function(t){return this._style[d](t)},a[f]=function(t){this._style[f](t)}}),r.each({Font:"FontFamily",WindingRule:"FillRule"},function(t,e){var i="get"+e,n="set"+e;o[i]=a[i]="#get"+t,o[n]=a[n]="#set"+t}),w.inject(a),o},{set:function(t){var e=t instanceof V,i=e?t._values:t;if(i)for(var n in i)if(n in this._defaults){var r=i[n];this[n]=r&&e&&r.clone?r.clone():r}},equals:function(t){return t===this||t&&this._class===t._class&&r.equals(this._values,t._values)||!1},hasFill:function(){var t=this.getFillColor();return!!t&&t.alpha>0},hasStroke:function(){var t=this.getStrokeColor();return!!t&&t.alpha>0&&this.getStrokeWidth()>0},hasShadow:function(){var t=this.getShadowColor();return!!t&&t.alpha>0&&(this.getShadowBlur()>0||!this.getShadowOffset().isZero())},getView:function(){return this._project._view},getFontStyle:function(){var t=this.getFontSize();return this.getFontWeight()+" "+t+(/[a-z]/i.test(t+"")?" ":"px ")+this.getFontFamily()},getFont:"#getFontFamily",setFont:"#setFontFamily",getLeading:function xt(){var t=xt.base.call(this),e=this.getFontSize();return/pt|em|%|px/.test(e)&&(e=this.getView().getPixelSize(e)),null!=t?t:1.2*e}}),H=new function(){function t(t,e,i,n){for(var r=["","webkit","moz","Moz","ms","o"],s=e[0].toUpperCase()+e.substring(1),a=0;6>a;a++){var o=r[a],h=o?o+s:e;if(h in t){if(!i)return t[h];t[h]=n;break}} }return{getStyles:function(t){var e=t&&9!==t.nodeType?t.ownerDocument:t,i=e&&e.defaultView;return i&&i.getComputedStyle(t,"")},getBounds:function(t,e){var i,n=t.ownerDocument,r=n.body,s=n.documentElement;try{i=t.getBoundingClientRect()}catch(a){i={left:0,top:0,width:0,height:0}}var o=i.left-(s.clientLeft||r.clientLeft||0),h=i.top-(s.clientTop||r.clientTop||0);if(!e){var u=n.defaultView;o+=u.pageXOffset||s.scrollLeft||r.scrollLeft,h+=u.pageYOffset||s.scrollTop||r.scrollTop}return new g(o,h,i.width,i.height)},getViewportBounds:function(t){var e=t.ownerDocument,i=e.defaultView,n=e.documentElement;return new g(0,0,i.innerWidth||n.clientWidth,i.innerHeight||n.clientHeight)},getOffset:function(t,e){return H.getBounds(t,e).getPoint()},getSize:function(t){return H.getBounds(t,!0).getSize()},isInvisible:function(t){return H.getSize(t).equals(new d(0,0))},isInView:function(t){return!H.isInvisible(t)&&H.getViewportBounds(t).intersects(H.getBounds(t,!0))},isInserted:function(t){return n.body.contains(t)},getPrefixed:function(e,i){return e&&t(e,i)},setPrefixed:function(e,i,n){if("object"==typeof i)for(var r in i)t(e,r,!0,i[r]);else t(e,i,!0,n)}}},U={add:function(t,e){if(t)for(var i in e)for(var n=e[i],r=i.split(/[\s,]+/g),s=0,a=r.length;a>s;s++)t.addEventListener(r[s],n,!1)},remove:function(t,e){if(t)for(var i in e)for(var n=e[i],r=i.split(/[\s,]+/g),s=0,a=r.length;a>s;s++)t.removeEventListener(r[s],n,!1)},getPoint:function(t){var e=t.targetTouches?t.targetTouches.length?t.targetTouches[0]:t.changedTouches[0]:t;return new c(e.pageX||e.clientX+n.documentElement.scrollLeft,e.pageY||e.clientY+n.documentElement.scrollTop)},getTarget:function(t){return t.target||t.srcElement},getRelatedTarget:function(t){return t.relatedTarget||t.toElement},getOffset:function(t,e){return U.getPoint(t).subtract(H.getOffset(e||U.getTarget(t)))}};U.requestAnimationFrame=new function(){function t(){var e=s;s=[];for(var i=0,a=e.length;a>i;i++)e[i]();r=n&&s.length,r&&n(t)}var e,n=H.getPrefixed(i,"requestAnimationFrame"),r=!1,s=[];return function(i){s.push(i),n?r||(n(t),r=!0):e||(e=setInterval(t,1e3/60))}};var Z=r.extend(s,{_class:"View",initialize:function bt(t,e){function r(t){return e[t]||parseInt(e.getAttribute(t),10)}function s(){var t=H.getSize(e);return t.isNaN()||t.isZero()?new d(r("width"),r("height")):t}var o;if(i&&e){this._id=e.getAttribute("id"),null==this._id&&e.setAttribute("id",this._id="view-"+bt._id++),U.add(e,this._viewEvents);var h="none";if(H.setPrefixed(e.style,{userDrag:h,userSelect:h,touchCallout:h,contentZooming:h,tapHighlightColor:"rgba(0,0,0,0)"}),a.hasAttribute(e,"resize")){var u=this;U.add(i,this._windowEvents={resize:function(){u.setViewSize(s())}})}if(o=s(),a.hasAttribute(e,"stats")&&"undefined"!=typeof Stats){this._stats=new Stats;var l=this._stats.domElement,c=l.style,f=H.getOffset(e);c.position="absolute",c.left=f.x+"px",c.top=f.y+"px",n.body.appendChild(l)}}else o=new d(e),e=null;this._project=t,this._scope=t._scope,this._element=e,this._pixelRatio||(this._pixelRatio=i&&i.devicePixelRatio||1),this._setElementSize(o.width,o.height),this._viewSize=o,bt._views.push(this),bt._viewsById[this._id]=this,(this._matrix=new p)._owner=this,this._zoom=1,bt._focused||(bt._focused=this),this._frameItems={},this._frameItemCount=0,this._itemEvents={"native":{},virtual:{}},this._autoUpdate=!paper.agent.node,this._needsUpdate=!1},remove:function(){if(!this._project)return!1;Z._focused===this&&(Z._focused=null),Z._views.splice(Z._views.indexOf(this),1),delete Z._viewsById[this._id];var t=this._project;return t._view===this&&(t._view=null),U.remove(this._element,this._viewEvents),U.remove(i,this._windowEvents),this._element=this._project=null,this.off("frame"),this._animate=!1,this._frameItems={},!0},_events:r.each(w._itemHandlers.concat(["onResize","onKeyDown","onKeyUp"]),function(t){this[t]={}},{onFrame:{install:function(){this.play()},uninstall:function(){this.pause()}}}),_animate:!1,_time:0,_count:0,getAutoUpdate:function(){return this._autoUpdate},setAutoUpdate:function(t){this._autoUpdate=t,t&&this.requestUpdate()},update:function(){},draw:function(){this.update()},requestUpdate:function(){if(!this._requested){var t=this;U.requestAnimationFrame(function(){if(t._requested=!1,t._animate){t.requestUpdate();var e=t._element;H.getPrefixed(n,"hidden")&&"true"!==a.getAttribute(e,"keepalive")||!H.isInView(e)||t._handleFrame()}t._autoUpdate&&t.update()}),this._requested=!0}},play:function(){this._animate=!0,this.requestUpdate()},pause:function(){this._animate=!1},_handleFrame:function(){paper=this._scope;var t=Date.now()/1e3,e=this._last?t-this._last:0;this._last=t,this.emit("frame",new r({delta:e,time:this._time+=e,count:this._count++})),this._stats&&this._stats.update()},_animateItem:function(t,e){var i=this._frameItems;e?(i[t._id]={item:t,time:0,count:0},1===++this._frameItemCount&&this.on("frame",this._handleFrameItems)):(delete i[t._id],0===--this._frameItemCount&&this.off("frame",this._handleFrameItems))},_handleFrameItems:function(t){for(var e in this._frameItems){var i=this._frameItems[e];i.item.emit("frame",new r(t,{time:i.time+=t.delta,count:i.count++}))}},_changed:function(){this._project._changed(2049),this._bounds=null},getElement:function(){return this._element},getPixelRatio:function(){return this._pixelRatio},getResolution:function(){return 72*this._pixelRatio},getViewSize:function(){var t=this._viewSize;return new _(t.width,t.height,this,"setViewSize")},setViewSize:function(){var t=d.read(arguments),e=t.width,i=t.height,n=t.subtract(this._viewSize);n.isZero()||(this._setElementSize(e,i),this._viewSize.set(e,i),this.emit("resize",{size:t,delta:n}),this._changed(),this._autoUpdate&&this.requestUpdate())},_setElementSize:function(t,e){var i=this._element;i&&(i.width!==t&&(i.width=t),i.height!==e&&(i.height=e))},getBounds:function(){return this._bounds||(this._bounds=this._matrix.inverted()._transformBounds(new g(new c,this._viewSize))),this._bounds},getSize:function(){return this.getBounds().getSize()},getCenter:function(){return this.getBounds().getCenter()},setCenter:function(){var t=c.read(arguments);this.translate(this.getCenter().subtract(t))},getZoom:function(){return this._zoom},setZoom:function(t){this.transform((new p).scale(t/this._zoom,this.getCenter())),this._zoom=t},getMatrix:function(){return this._matrix},setMatrix:function(){var t=this._matrix;t.initialize.apply(t,arguments)},isVisible:function(){return H.isInView(this._element)},isInserted:function(){return H.isInserted(this._element)},getPixelSize:function(t){var e,i=this._element;if(i){var r=i.parentNode,s=n.createElement("div");s.style.fontSize=t,r.appendChild(s),e=parseFloat(H.getStyles(s).fontSize),r.removeChild(s)}else e=parseFloat(e);return e},getTextWidth:function(t,e){return 0}},r.each(["rotate","scale","shear","skew"],function(t){var e="rotate"===t;this[t]=function(){var i=(e?r:c).read(arguments),n=c.read(arguments,0,{readNull:!0});return this.transform((new p)[t](i,n||this.getCenter(!0)))}},{translate:function(){var t=new p;return this.transform(t.translate.apply(t,arguments))},transform:function(t){this._matrix.append(t)},scrollBy:function(){this.translate(c.read(arguments).negate())}}),{projectToView:function(){return this._matrix._transformPoint(c.read(arguments))},viewToProject:function(){return this._matrix._inverseTransform(c.read(arguments))},getEventPoint:function(t){return this.viewToProject(U.getOffset(t,this._element))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(t,e){n&&"string"==typeof e&&(e=n.getElementById(e));var r=i?W:Z;return new r(t,e)}}},new function(){function t(t){var e=U.getTarget(t);return e.getAttribute&&Z._viewsById[e.getAttribute("id")]}function r(){var t=Z._focused;if(!t||!t.isVisible())for(var e=0,i=Z._views.length;i>e;e++)if((t=Z._views[e]).isVisible()){Z._focused=u=t;break}}function s(t,e,i){t._handleMouseEvent("mousemove",e,i)}function a(t,e,i,n,r,s){function a(t,e){if(t.responds(e)){if(o||(o=new X(e,i,n,h,r?n.subtract(r):null)),t.emit(e,o)&&(P=!0,o.prevented&&(A=!0),o.stopped))return u=!0}else{var s=M[e];if(s)return a(t,s)}}for(var o,h=t,u=!1;t&&t!==s&&!a(t,e);)t=t._parent;return u}function o(t,e,i,n,r,s){return t._project.removeOn(i),A=P=!1,b&&a(b,i,n,r,s)||e&&e!==b&&!e.isDescendant(b)&&a(e,M[i]||i,n,r,s,b)||a(t,i,n,r,s)}if(i){var h,u,l,c,f,d=!1,_=!1,g=i.navigator;g.pointerEnabled||g.msPointerEnabled?(l="pointerdown MSPointerDown",c="pointermove MSPointerMove",f="pointerup pointercancel MSPointerUp MSPointerCancel"):(l="touchstart",c="touchmove",f="touchend touchcancel","ontouchstart"in i&&g.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i)||(l+=" mousedown",c+=" mousemove",f+=" mouseup"));var v={},p={mouseout:function(t){var e=Z._focused,i=U.getRelatedTarget(t);if(e&&(!i||"HTML"===i.nodeName)){var n=U.getOffset(t,e._element),r=n.x,a=Math.abs,o=a(r),h=1<<25,u=o-h;n.x=a(u)r?-1:1):r,s(e,t,e.viewToProject(n))}},scroll:r};v[l]=function(e){var i=Z._focused=t(e);d||(d=!0,i._handleMouseEvent("mousedown",e))},p[c]=function(e){var i=Z._focused;if(!_){var n=t(e);n?i!==n&&(i&&s(i,e),h||(h=i),i=Z._focused=u=n):u&&u===i&&(h&&!h.isInserted()&&(h=null),i=Z._focused=h,h=null,r())}i&&s(i,e)},p[l]=function(){_=!0},p[f]=function(t){var e=Z._focused;e&&d&&e._handleMouseEvent("mouseup",t),_=d=!1},U.add(n,p),U.add(i,{load:r});var m,y,w,x,b,C,S,k,I,P=!1,A=!1,M={doubleclick:"click",mousedrag:"mousemove"},T={mousedown:{mousedown:1,mousedrag:1,click:1,doubleclick:1},mouseup:{mouseup:1,mousedrag:1,click:1,doubleclick:1},mousemove:{mousedrag:1,mousemove:1,mouseenter:1,mouseleave:1}},z=!1;return{_viewEvents:v,_handleMouseEvent:function(t,i,n){function r(t){return s.virtual[t]||l.responds(t)||u&&u.responds(t)}var s=this._itemEvents,h=s["native"][t],u=this._scope.tool,l=this;"mousemove"===t&&d&&r("mousedrag")&&(t="mousedrag"),n||(n=this.getEventPoint(i));var c=this.getBounds().contains(n),f=c&&h&&this._project.hitTest(n,{tolerance:0,fill:!0,stroke:!0}),_=f&&f.item||e,g=!1,v={};v[t.substr(5)]=!0;var p=v.move||v.drag?t:"mousemove";_!==x&&(x&&a(x,"mouseleave",i,n),_&&a(_,"mouseenter",i,n)),x=_,z^c&&(a(this,c?"mouseenter":"mouseleave",i,n),I=c?this:null,g=!0),!c&&!v.drag||n.equals(y)||(o(this,_,p,i,n,y),g=!0),z=c,(v.down&&c||v.up&&m)&&(o(this,_,t,i,n,m),v.down?(k=_===C&&Date.now()-S<300,w=C=_,b=!A&&_,m=n):v.up&&(A||_!==w||(S=Date.now(),o(this,_,k?"doubleclick":"click",i,n,m),k=!1),w=b=null),z=!1,g=!0),y=n,g&&u&&(P=u._handleMouseEvent(t,i,n,v)||P),(P&&!v.move||v.down&&r("mouseup"))&&i.preventDefault()},_handleKeyEvent:function(t,e,i,n){function r(r){r.responds(t)&&(paper=a,r.emit(t,s=s||new $(t,e,i,n)))}var s,a=this._scope,o=a.tool;this.isVisible()&&(r(this),o&&o.responds(t)&&r(o))},_countItemEvent:function(t,e){var i=this._itemEvents,n=i["native"],r=i.virtual;for(var s in T)n[s]=(n[s]||0)+(T[s][t]||0)*e;r[t]=(r[t]||0)+e},statics:{updateFocus:r}}}}),W=Z.extend({_class:"CanvasView",initialize:function(t,e){if(!(e instanceof i.HTMLCanvasElement)){var n=d.read(arguments,1);if(n.isZero())throw new Error("Cannot create CanvasView with the provided argument: "+[].slice.call(arguments,1));e=tt.getCanvas(n)}var r=this._context=e.getContext("2d");if(r.save(),this._pixelRatio=1,!/^off|false$/.test(a.getAttribute(e,"hidpi"))){var s=i.devicePixelRatio||1,o=H.getPrefixed(r,"backingStorePixelRatio")||1;this._pixelRatio=s/o}Z.call(this,t,e),this._needsUpdate=!0},remove:function Ct(){return this._context.restore(),Ct.base.call(this)},_setElementSize:function St(t,e){var i=this._pixelRatio;if(St.base.call(this,t*i,e*i),1!==i){var n=this._element,r=this._context;if(!a.hasAttribute(n,"resize")){var s=n.style;s.width=t+"px",s.height=e+"px"}r.restore(),r.save(),r.scale(i,i)}},getPixelSize:function kt(t){var e,i=paper.agent;if(i&&i.firefox)e=kt.base.call(this,t);else{var n=this._context,r=n.font;n.font=t+" serif",e=parseFloat(n.font),n.font=r}return e},getTextWidth:function(t,e){var i=this._context,n=i.font,r=0;i.font=t;for(var s=0,a=e.length;a>s;s++)r=Math.max(r,i.measureText(e[s]).width);return i.font=n,r},update:function(){if(!this._needsUpdate)return!1;var t=this._project,e=this._context,i=this._viewSize;return e.clearRect(0,0,i.width+1,i.height+1),t&&t.draw(e,this._matrix,this._pixelRatio),this._needsUpdate=!1,!0}}),G=r.extend({_class:"Event",initialize:function(t){this.event=t,this.type=t&&t.type},prevented:!1,stopped:!1,preventDefault:function(){this.prevented=!0,this.event.preventDefault()},stopPropagation:function(){this.stopped=!0,this.event.stopPropagation()},stop:function(){this.stopPropagation(),this.preventDefault()},getTimeStamp:function(){return this.event.timeStamp},getModifiers:function(){return J.modifiers}}),$=G.extend({_class:"KeyEvent",initialize:function(t,e,i,n){this.type=t,this.event=e,this.key=i,this.character=n},toString:function(){return"{ type: '"+this.type+"', key: '"+this.key+"', character: '"+this.character+"', modifiers: "+this.getModifiers()+" }"}}),J=new function(){function t(t){var e=t.key||t.keyIdentifier;return e=/^U\+/.test(e)?String.fromCharCode(parseInt(e.substr(2),16)):/^Arrow[A-Z]/.test(e)?e.substr(5):"Unidentified"===e?String.fromCharCode(t.keyCode):e,o[e]||(e.length>1?r.hyphenate(e):e.toLowerCase())}function e(t,i,n,a){var o,h=Z._focused;if(u[i]=t,t?l[i]=n:delete l[i],i.length>1&&(o=r.camelize(i))in modifiers){modifiers[o]=t;var c=paper&&paper.agent;if("meta"===o&&c&&c.mac)if(t)s={};else{for(var f in s)f in l&&e(!1,f,s[f],a);s=null}}else t&&s&&(s[i]=n);h&&h._handleKeyEvent(t?"keydown":"keyup",a,i,n)}var s,a,o={" ":"tab"," ":"space","\b":"backspace","":"delete",Spacebar:"space",Del:"delete",Win:"meta",Esc:"escape"},h={tab:" ",space:" ",enter:"\r"},u={},l={};return modifiers=new r({shift:!1,control:!1,alt:!1,meta:!1,capsLock:!1,space:!1}).inject({option:{get:function(){return this.alt}},command:{get:function(){var t=paper&&paper.agent;return t&&t.mac?this.meta:this.control}}}),U.add(n,{keydown:function(i){var n=t(i),r=paper&&paper.agent;n.length>1||r&&r.chrome&&(i.altKey||r.mac&&i.metaKey||!r.mac&&i.ctrlKey)?e(!0,n,h[n]||(n.length>1?"":n),i):a=n},keypress:function(i){if(a){var n=t(i),r=i.charCode,s=r>=32?String.fromCharCode(r):n.length>1?"":n;n!==a&&(n=s.toLowerCase()),e(!0,n,s,i),a=null}},keyup:function(i){var n=t(i);n in l&&e(!1,n,l[n],i)}}),U.add(i,{blur:function(t){for(var i in l)e(!1,i,l[i],t)}}),{modifiers:modifiers,isDown:function(t){return!!u[t]}}},X=G.extend({_class:"MouseEvent",initialize:function(t,e,i,n,r){this.type=t,this.event=e,this.point=i,this.target=n,this.delta=r},toString:function(){return"{ type: '"+this.type+"', point: "+this.point+", target: "+this.target+(this.delta?", delta: "+this.delta:"")+", modifiers: "+this.getModifiers()+" }"}}),Y=G.extend({_class:"ToolEvent",_item:null,initialize:function(t,e,i){this.tool=t,this.type=e,this.event=i},_choosePoint:function(t,e){return t?t:e?e.clone():null},getPoint:function(){return this._choosePoint(this._point,this.tool._point)},setPoint:function(t){this._point=t},getLastPoint:function(){return this._choosePoint(this._lastPoint,this.tool._lastPoint)},setLastPoint:function(t){this._lastPoint=t},getDownPoint:function(){return this._choosePoint(this._downPoint,this.tool._downPoint)},setDownPoint:function(t){this._downPoint=t},getMiddlePoint:function(){return!this._middlePoint&&this.tool._lastPoint?this.tool._point.add(this.tool._lastPoint).divide(2):this._middlePoint},setMiddlePoint:function(t){this._middlePoint=t},getDelta:function(){return!this._delta&&this.tool._lastPoint?this.tool._point.subtract(this.tool._lastPoint):this._delta},setDelta:function(t){this._delta=t},getCount:function(){return this.tool[/^mouse(down|up)$/.test(this.type)?"_downCount":"_moveCount"]},setCount:function(t){this.tool[/^mouse(down|up)$/.test(this.type)?"downCount":"count"]=t},getItem:function(){if(!this._item){var t=this.tool._scope.project.hitTest(this.getPoint());if(t){for(var e=t.item,i=e._parent;/^(Group|CompoundPath)$/.test(i._class);)e=i,i=i._parent;this._item=e}}return this._item},setItem:function(t){this._item=t},toString:function(){return"{ type: "+this.type+", point: "+this.getPoint()+", count: "+this.getCount()+", modifiers: "+this.getModifiers()+" }"}}),K=o.extend({_class:"Tool",_list:"tools",_reference:"tool",_events:["onMouseDown","onMouseUp","onMouseDrag","onMouseMove","onActivate","onDeactivate","onEditOptions","onKeyDown","onKeyUp"],initialize:function(t){o.call(this),this._moveCount=-1,this._downCount=-1,this._set(t)},getMinDistance:function(){return this._minDistance},setMinDistance:function(t){this._minDistance=t,null!=t&&null!=this._maxDistance&&t>this._maxDistance&&(this._maxDistance=t)},getMaxDistance:function(){return this._maxDistance},setMaxDistance:function(t){this._maxDistance=t,null!=this._minDistance&&null!=t&&th)return!1;e&&(r=s.add(o.normalize(Math.min(h,e))))}c._moveCount++}return c._point=r,c._lastPoint=s||r,n.down&&(c._moveCount=-1,c._downPoint=r,c._downCount++),!0}function s(){o&&(l=c.emit(t,new Y(c,t,e))||l)}paper=this._scope,n.drag&&!this.responds(t)&&(t="mousemove");var a=n.move||n.drag,o=this.responds(t),h=this.minDistance,u=this.maxDistance,l=!1,c=this;if(n.down)r(),s();else if(n.up)r(null,u),s();else if(o)for(;r(h,u);)s();return l}}),Q={request:function(t){var e=new i.XMLHttpRequest;return e.open((t.method||"get").toUpperCase(),t.url,r.pick(t.async,!0)),t.mimeType&&e.overrideMimeType(t.mimeType),e.onload=function(){var i=e.status;0===i||200===i?t.onLoad&&t.onLoad.call(e,e.responseText):e.onerror()},e.onerror=function(){var i=e.status,n='Could not load "'+t.url+'" (Status: '+i+")";if(!t.onError)throw new Error(n);t.onError(n,i)},e.send(null)}},tt={canvases:[],getCanvas:function(t,e){if(!i)return null;var r,s=!0;"object"==typeof t&&(e=t.height,t=t.width),this.canvases.length?r=this.canvases.pop():(r=n.createElement("canvas"),s=!1);var a=r.getContext("2d");if(!a)throw new Error("Canvas "+r+" is unable toprovide a 2D context.");return r.width===t&&r.height===e?s&&a.clearRect(0,0,t+1,e+1):(r.width=t,r.height=e),a.save(),r},getContext:function(t,e){var i=this.getCanvas(t,e);return i?i.getContext("2d"):null},release:function(t){var e=t&&t.canvas?t.canvas:t;e&&e.getContext&&(e.getContext("2d").restore(),this.canvases.push(e))}},et=new function(){function t(t,e,i){return.2989*t+.587*e+.114*i}function e(e,i,n,r){var s=r-t(e,i,n);d=e+s,_=i+s,g=n+s;var r=t(d,_,g),a=v(d,_,g),o=p(d,_,g);if(0>a){var h=r-a;d=r+(d-r)*r/h,_=r+(_-r)*r/h,g=r+(g-r)*r/h}if(o>255){var u=255-r,l=o-r;d=r+(d-r)*u/l,_=r+(_-r)*u/l,g=r+(g-r)*u/l}}function i(t,e,i){return p(t,e,i)-v(t,e,i)}function n(t,e,i,n){var r,s=[t,e,i],a=p(t,e,i),o=v(t,e,i);o=o===t?0:o===e?1:2,a=a===t?0:a===e?1:2,r=0===v(o,a)?1===p(o,a)?2:1:0,s[a]>s[o]?(s[r]=(s[r]-s[o])*n/(s[a]-s[o]),s[a]=n):s[r]=s[a]=0,s[o]=0,d=s[0],_=s[1],g=s[2]}var s,a,o,h,u,l,c,f,d,_,g,v=Math.min,p=Math.max,m=Math.abs,y={multiply:function(){d=u*s/255,_=l*a/255,g=c*o/255},screen:function(){d=u+s-u*s/255,_=l+a-l*a/255,g=c+o-c*o/255},overlay:function(){d=128>u?2*u*s/255:255-2*(255-u)*(255-s)/255,_=128>l?2*l*a/255:255-2*(255-l)*(255-a)/255,g=128>c?2*c*o/255:255-2*(255-c)*(255-o)/255},"soft-light":function(){var t=s*u/255;d=t+u*(255-(255-u)*(255-s)/255-t)/255,t=a*l/255,_=t+l*(255-(255-l)*(255-a)/255-t)/255,t=o*c/255,g=t+c*(255-(255-c)*(255-o)/255-t)/255},"hard-light":function(){d=128>s?2*s*u/255:255-2*(255-s)*(255-u)/255,_=128>a?2*a*l/255:255-2*(255-a)*(255-l)/255,g=128>o?2*o*c/255:255-2*(255-o)*(255-c)/255},"color-dodge":function(){d=0===u?0:255===s?255:v(255,255*u/(255-s)),_=0===l?0:255===a?255:v(255,255*l/(255-a)),g=0===c?0:255===o?255:v(255,255*c/(255-o))},"color-burn":function(){d=255===u?255:0===s?0:p(0,255-255*(255-u)/s),_=255===l?255:0===a?0:p(0,255-255*(255-l)/a),g=255===c?255:0===o?0:p(0,255-255*(255-c)/o)},darken:function(){d=s>u?u:s,_=a>l?l:a,g=o>c?c:o},lighten:function(){d=u>s?u:s,_=l>a?l:a,g=c>o?c:o},difference:function(){d=u-s,0>d&&(d=-d),_=l-a,0>_&&(_=-_),g=c-o,0>g&&(g=-g)},exclusion:function(){d=u+s*(255-u-u)/255,_=l+a*(255-l-l)/255,g=c+o*(255-c-c)/255},hue:function(){n(s,a,o,i(u,l,c)),e(d,_,g,t(u,l,c))},saturation:function(){n(u,l,c,i(s,a,o)),e(d,_,g,t(u,l,c))},luminosity:function(){e(u,l,c,t(s,a,o))},color:function(){e(s,a,o,t(u,l,c))},add:function(){d=v(u+s,255),_=v(l+a,255),g=v(c+o,255)},subtract:function(){d=p(u-s,0),_=p(l-a,0),g=p(c-o,0)},average:function(){d=(u+s)/2,_=(l+a)/2,g=(c+o)/2},negation:function(){d=255-m(255-s-u),_=255-m(255-a-l),g=255-m(255-o-c)}},w=this.nativeModes=r.each(["source-over","source-in","source-out","source-atop","destination-over","destination-in","destination-out","destination-atop","lighter","darker","copy","xor"],function(t){this[t]=!0},{}),x=tt.getContext(1,1);x&&(r.each(y,function(t,e){var i="darken"===e,n=!1;x.save();try{x.fillStyle=i?"#300":"#a00",x.fillRect(0,0,1,1),x.globalCompositeOperation=e,x.globalCompositeOperation===e&&(x.fillStyle=i?"#a00":"#300",x.fillRect(0,0,1,1),n=x.getImageData(0,0,1,1).data[0]!==i?170:51)}catch(r){}x.restore(),w[e]=n}),tt.release(x)),this.process=function(t,e,i,n,r){var v=e.canvas,p="normal"===t;if(p||w[t])i.save(),i.setTransform(1,0,0,1,0,0),i.globalAlpha=n,p||(i.globalCompositeOperation=t),i.drawImage(v,r.x,r.y),i.restore();else{var m=y[t];if(!m)return;for(var x=i.getImageData(r.x,r.y,v.width,v.height),b=x.data,C=e.getImageData(0,0,v.width,v.height).data,S=0,k=b.length;k>S;S+=4){s=C[S],u=b[S],a=C[S+1],l=b[S+1],o=C[S+2],c=b[S+2],h=C[S+3],f=b[S+3],m();var I=h*n/255,P=1-I;b[S]=I*d+P*u,b[S+1]=I*_+P*l,b[S+2]=I*g+P*c,b[S+3]=h*n+P*f}i.putImageData(x,r.x,r.y)}}},it=new function(){function t(t,e,s){return i(n.createElementNS(r,t),e,s)}function e(t,e){var i=o[e],n=i?t.getAttributeNS(i,e):t.getAttribute(e);return"null"===n?null:n}function i(t,e,i){for(var n in e){var r=e[n],s=o[n];"number"==typeof r&&i&&(r=i.number(r)),s?t.setAttributeNS(s,n,r):t.setAttribute(n,r)}return t}var r="http://www.w3.org/2000/svg",s="http://www.w3.org/2000/xmlns",a="http://www.w3.org/1999/xlink",o={href:a,xlink:s,xmlns:s+"/","xmlns:xlink":s+"/"};return{svg:r,xmlns:s,xlink:a,create:t,get:e,set:i}},nt=r.each({fillColor:["fill","color"],fillRule:["fill-rule","string"],strokeColor:["stroke","color"],strokeWidth:["stroke-width","number"],strokeCap:["stroke-linecap","string"],strokeJoin:["stroke-linejoin","string"],strokeScaling:["vector-effect","lookup",{"true":"none","false":"non-scaling-stroke"},function(t,e){return!e&&(t instanceof O||t instanceof C||t instanceof F)}],miterLimit:["stroke-miterlimit","number"],dashArray:["stroke-dasharray","array"],dashOffset:["stroke-dashoffset","number"],fontFamily:["font-family","string"],fontWeight:["font-weight","string"],fontSize:["font-size","number"],justification:["text-anchor","lookup",{left:"start",center:"middle",right:"end"}],opacity:["opacity","number"],blendMode:["mix-blend-mode","style"]},function(t,e){var i=r.capitalize(e),n=t[2];this[e]={type:t[1],property:e,attribute:t[0],toSVG:n,fromSVG:n&&r.each(n,function(t,e){this[t]=e},{}),exportFilter:t[3],get:"get"+i,set:"set"+i}},{});return new function(){function t(t,e,i){var n=new r,s=t.getTranslation();if(e){t=t._shiftless();var a=t._inverseTransform(s);n[i?"cx":"x"]=a.x,n[i?"cy":"y"]=a.y,s=null}if(!t.isIdentity()){var o=t.decompose();if(o){var h=[],l=o.rotation,c=o.scaling,f=o.skewing;s&&!s.isZero()&&h.push("translate("+C.point(s)+")"),l&&h.push("rotate("+C.number(l)+")"),u.isZero(c.x-1)&&u.isZero(c.y-1)||h.push("scale("+C.point(c)+")"),f&&f.x&&h.push("skewX("+C.number(f.x)+")"),f&&f.y&&h.push("skewY("+C.number(f.y)+")"),n.transform=h.join(" ")}else n.transform="matrix("+t.getValues().join(",")+")"}return n}function e(e,i){for(var n=t(e._matrix),r=e._children,s=it.create("g",n,C),a=0,o=r.length;o>a;a++){var h=r[a],u=x(h,i);if(u)if(h.isClipMask()){var l=it.create("clipPath");l.appendChild(u),v(h,l,"clip"),it.set(s,{"clip-path":"url(#"+l.id+")"})}else s.appendChild(u)}return s}function n(e,i){var n=t(e._matrix,!0),r=e.getSize(),s=e.getImage();return n.x-=r.width/2,n.y-=r.height/2,n.width=r.width,n.height=r.height,n.href=i.embedImages===!1&&s&&s.src||e.toDataURL(),it.create("image",n,C)}function s(e,i){var n=i.matchShapes;if(n){var r=e.toShape(!1);if(r)return a(r,i)}var s,o=e._segments,h=o.length,u=t(e._matrix);if(n&&h>=2&&!e.hasHandles())if(h>2){s=e._closed?"polygon":"polyline";for(var l=[],c=0;h>c;c++)l.push(C.point(o[c]._point));u.points=l.join(" ")}else{s="line";var f=o[0]._point,d=o[1]._point;u.set({x1:f.x,y1:f.y,x2:d.x,y2:d.y})}else s="path",u.d=e.getPathData(null,i.precision);return it.create(s,u,C)}function a(e){var i=e._type,n=e._radius,r=t(e._matrix,!0,"rectangle"!==i);if("rectangle"===i){i="rect";var s=e._size,a=s.width,o=s.height;r.x-=a/2,r.y-=o/2,r.width=a,r.height=o,n.isZero()&&(n=null)}return n&&("circle"===i?r.r=n:(r.rx=n.width,r.ry=n.height)),it.create(i,r,C)}function o(e,i){var n=t(e._matrix),r=e.getPathData(null,i.precision);return r&&(n.d=r),it.create("path",n,C)}function l(e,i){var n=t(e._matrix,!0),r=e._definition,s=_(r,"symbol"),a=r._item,o=a.getBounds();return s||(s=it.create("symbol",{viewBox:C.rectangle(o)}),s.appendChild(x(a,i)),v(r,s,"symbol")),n.href="#"+s.id,n.x+=o.x,n.y+=o.y,n.width=o.width,n.height=o.height,n.overflow="visible",it.create("use",n,C)}function c(t){var e=_(t,"color");if(!e){var i,n=t.getGradient(),r=n._radial,s=t.getOrigin(),a=t.getDestination();if(r){i={cx:s.x,cy:s.y,r:s.getDistance(a)};var o=t.getHighlight();o&&(i.fx=o.x,i.fy=o.y)}else i={x1:s.x,y1:s.y,x2:a.x,y2:a.y};i.gradientUnits="userSpaceOnUse",e=it.create((r?"radial":"linear")+"Gradient",i,C);for(var h=n._stops,u=0,l=h.length;l>u;u++){var c=h[u],f=c._color,d=f.getAlpha();i={offset:c._offset||u/(l-1)},f&&(i["stop-color"]=f.toCSS(!0)),1>d&&(i["stop-opacity"]=d),e.appendChild(it.create("stop",i,C))}v(t,e,"color")}return"url(#"+e.id+")"}function f(e){var i=it.create("text",t(e._matrix,!0),C);return i.textContent=e._content,i}function d(t,e,i){var n={},s=!i&&t.getParent(),a=[];return null!=t._name&&(n.id=t._name),r.each(nt,function(e){var i=e.get,o=e.type,h=t[i]();if(e.exportFilter?e.exportFilter(t,h):!s||!r.equals(s[i](),h)){if("color"===o&&null!=h){var u=h.getAlpha();1>u&&(n[e.attribute+"-opacity"]=u)}"style"===o?a.push(e.attribute+": "+h):n[e.attribute]=null==h?"none":"color"===o?h.gradient?c(h,t):h.toCSS(!0):"array"===o?h.join(","):"lookup"===o?e.toSVG[h]:h}}),a.length&&(n.style=a.join(";")),1===n.opacity&&delete n.opacity,t._visible||(n.visibility="hidden"),it.set(e,n,C)}function _(t,e){return S||(S={ids:{},svgs:{}}),t&&S.svgs[e+"-"+t._id]}function v(t,e,i){S||_();var n=S.ids[i]=(S.ids[i]||0)+1;e.id=i+"-"+n,S.svgs[i+"-"+t._id]=e}function m(t,e){var n=t,r=null;if(S){n="svg"===t.nodeName.toLowerCase()&&t;for(var s in S.svgs)r||(n||(n=it.create("svg"),n.appendChild(t)),r=n.insertBefore(it.create("defs"),n.firstChild)),r.appendChild(S.svgs[s]);S=null}return e.asString?(new i.XMLSerializer).serializeToString(n):n}function x(t,e,i){var n=k[t._class],r=n&&n(t,e);if(r){var s=e.onExport;s&&(r=s(t,r,e)||r);var a=JSON.stringify(t._data);a&&"{}"!==a&&"null"!==a&&r.setAttribute("data-paper-data",a)}return r&&d(t,r,i)}function b(t){return t||(t={}),C=new h(t.precision),t}var C,S,k={Group:e,Layer:e,Raster:n,Path:s,Shape:a,CompoundPath:o,SymbolItem:l,PointText:f};w.inject({exportSVG:function(t){return t=b(t),m(x(this,t,!0),t)}}),y.inject({exportSVG:function(e){e=b(e);var i=this._children,n=this.getView(),s=r.pick(e.bounds,"view"),a=e.matrix||"view"===s&&n._matrix,o=a&&p.read([a]),h="view"===s?new g([0,0],n.getViewSize()):"content"===s?w._getBounds(i,o,{stroke:!0}):g.read([s],0,{readNull:!0}),u={version:"1.1",xmlns:it.svg,"xmlns:xlink":it.xlink};h&&(u.width=h.width,u.height=h.height,(h.x||h.y)&&(u.viewBox=C.rectangle(h)));var l=it.create("svg",u,C),c=l;o&&!o.isIdentity()&&(c=l.appendChild(it.create("g",t(o),C)));for(var f=0,d=i.length;d>f;f++)c.appendChild(x(i[f],e,!0));return m(l,e)}})},new function(){function t(t,e,i,n,r){var s=it.get(t,e),a=null==s?n?null:i?"":0:i?s:parseFloat(s);return/%\s*$/.test(s)?a/100*(r?1:M[/x|^width/.test(e)?"width":"height"]):a}function s(e,i,n,r,s){return i=t(e,i||"x",!1,r,s),n=t(e,n||"y",!1,r,s),!r||null!=i&&null!=n?new c(i,n):null}function a(e,i,n,r,s){return i=t(e,i||"width",!1,r,s),n=t(e,n||"height",!1,r,s),!r||null!=i&&null!=n?new d(i,n):null}function o(t,e,i){return"none"===t?null:"number"===e?parseFloat(t):"array"===e?t?t.split(/[\s,]+/g).map(parseFloat):[]:"color"===e?k(t)||t:"lookup"===e?i[t]:t}function h(t,e,i,n){var r=t.childNodes,s="clippath"===e,a="defs"===e,o=new x,h=o._project,u=h._currentStyle,l=[];if(s||a||(o=b(o,t,n),h._currentStyle=o._style.clone()),n)for(var c=t.querySelectorAll("defs"),f=0,d=c.length;d>f;f++)P(c[f],i,!1);for(var f=0,d=r.length;d>f;f++){var _,g=r[f];1!==g.nodeType||/^defs$/i.test(g.nodeName)||!(_=P(g,i,!1))||_ instanceof I||l.push(_)}return o.addChildren(l),s&&(o=b(o.reduce(),t,n)),h._currentStyle=u,(s||a)&&(o.remove(),o=null),o}function u(t,e){for(var i=t.getAttribute("points").match(/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g),n=[],r=0,s=i.length;s>r;r+=2)n.push(new c(parseFloat(i[r]),parseFloat(i[r+1])));var a=new E(n);return"polygon"===e&&a.closePath(),a}function l(t){return O.create(t.getAttribute("d"))}function f(e,i){var n,r=(t(e,"href",!0)||"").substring(1),a="radialgradient"===i;if(r)n=L[r].getGradient(),n._radial^a&&(n=n.clone(),n._radial=a);else{for(var o=e.childNodes,h=[],u=0,l=o.length;l>u;u++){var c=o[u];1===c.nodeType&&h.push(b(new q,c))}n=new R(h,a)}var f,d,_,g="userSpaceOnUse"!==t(e,"gradientUnits",!0);a?(f=s(e,"cx","cy",!1,g),d=f.add(t(e,"r",!1,!1,g),0),_=s(e,"fx","fy",!0,g)):(f=s(e,"x1","y1",!1,g),d=s(e,"x2","y2",!1,g));var v=b(new D(n,f,d,_),e);return v._scaleToBounds=g,null}function _(t,e,i,n){if(t.transform){for(var r=(n.getAttribute(i)||"").split(/\)\s*/g),s=new p,a=0,o=r.length;o>a;a++){var h=r[a];if(!h)break;for(var u=h.split(/\(\s*/),l=u[0],c=u[1].split(/[\s,]+/g),f=0,d=c.length;d>f;f++)c[f]=parseFloat(c[f]);switch(l){case"matrix":s.append(new p(c[0],c[1],c[2],c[3],c[4],c[5]));break;case"rotate":s.rotate(c[0],c[1],c[2]);break;case"translate":s.translate(c[0],c[1]);break;case"scale":s.scale(c);break;case"skewX":s.skew(c[0],0);break;case"skewY":s.skew(0,c[0])}}t.transform(s)}}function v(t,e,i){var n="fill-opacity"===i?"getFillColor":"getStrokeColor",r=t[n]&&t[n]();r&&r.setAlpha(parseFloat(e))}function m(t,i,n){var s=t.attributes[i],a=s&&s.value;if(!a){var o=r.camelize(i);a=t.style[o],a||n.node[o]===n.parent[o]||(a=n.node[o])}return a?"none"===a?null:a:e}function b(t,i,n){var s=i.parentNode,a={node:H.getStyles(i)||{},parent:!n&&!/^defs$/i.test(s.tagName)&&H.getStyles(s)||{}};return r.each(z,function(n,r){var s=m(i,r,a);t=s!==e&&n(t,s,r,i,a)||t}),t}function k(t){var e=t&&t.match(/\((?:["'#]*)([^"')]+)/),n=e&&L[e[1].replace(i.location.href.split("#")[0]+"#","")];return n&&n._scaleToBounds&&(n=n.clone(),n._scaleToBounds=!0),n}function P(t,e,i){var s,o,h,u=t.nodeName.toLowerCase(),l="#document"!==u,c=n.body;i&&l&&(M=a(t,null,null,!0)||paper.getView().getSize(),s=it.create("svg",{style:"stroke-width: 1px; stroke-miterlimit: 10"}),o=t.parentNode,h=t.nextSibling,s.appendChild(t),c.appendChild(s));var f=paper.settings,d=f.applyMatrix,_=f.insertItems;f.applyMatrix=!1,f.insertItems=!1;var g=T[u],v=g&&g(t,u,e,i)||null;if(f.insertItems=_,f.applyMatrix=d,v){!l||v instanceof x||(v=b(v,t,i));var p=e.onImport,m=l&&t.getAttribute("data-paper-data");p&&(v=p(t,v,e)||v),e.expandShapes&&v instanceof C&&(v.remove(),v=v.toPath()),m&&(v._data=JSON.parse(m))}return s&&(c.removeChild(s),o&&(h?o.insertBefore(t,h):o.appendChild(t))),i&&(L={},v&&r.pick(e.applyMatrix,d)&&v.matrix.apply(!0,!0)),v}function A(t,r,s){function a(n){try{var a="object"==typeof n?n:(new i.DOMParser).parseFromString(n,"image/svg+xml"); if(!a.nodeName)throw a=null,new Error("Unsupported SVG source: "+t);paper=h,u=P(a,r,!0),r&&r.insert===!1||s._insertItem(e,u);var l=r.onLoad;l&&l(u,n)}catch(c){o(c)}}function o(t,e){var i=r.onError;if(!i)throw new Error(t);i(t,e)}if(!t)return null;r="function"==typeof r?{onLoad:r}:r||{};var h=paper,u=null;if("string"!=typeof t||/^.*s;s++){var o=r[s];if(1===o.nodeType)return P(o,i,n)}},g:h,svg:h,clippath:h,polygon:u,polyline:u,path:l,lineargradient:f,radialgradient:f,image:function(e){var i=new S(t(e,"href",!0));return i.on("load",function(){var t=a(e);this.setSize(t);var i=this._matrix._transformPoint(s(e).add(t.divide(2)));this.translate(i)}),i},symbol:function(t,e,i,n){return new I(h(t,e,i,n),!0)},defs:h,use:function(e){var i=(t(e,"href",!0)||"").substring(1),n=L[i],r=s(e);return n?n instanceof I?n.place(r):n.clone().translate(r):null},circle:function(e){return new C.Circle(s(e,"cx","cy"),t(e,"r"))},ellipse:function(t){return new C.Ellipse({center:s(t,"cx","cy"),radius:a(t,"rx","ry")})},rect:function(t){return new C.Rectangle(new g(s(t),a(t)),a(t,"rx","ry"))},line:function(t){return new E.Line(s(t,"x1","y1"),s(t,"x2","y2"))},text:function(t){var e=new j(s(t).add(s(t,"dx","dy")));return e.setContent(t.textContent.trim()||""),e}},z=r.set(r.each(nt,function(t){this[t.attribute]=function(e,i){if(e[t.set]&&(e[t.set](o(i,t.type,t.fromSVG)),"color"===t.type)){var n=e[t.get]();if(n){if(n._scaleToBounds){var r=e.getBounds();n.transform((new p).translate(r.getPoint()).scale(r.getSize()))}e instanceof C&&n.transform((new p).translate(e.getPosition(!0).negate()))}}}},{}),{id:function(t,e){L[e]=t,t.setName&&t.setName(e)},"clip-path":function(t,e){var i=k(e);if(i){if(i=i.clone(),i.setClipMask(!0),!(t instanceof x))return new x(i,t);t.insertChild(0,i)}},gradientTransform:_,transform:_,"fill-opacity":v,"stroke-opacity":v,visibility:function(t,e){t.setVisible&&t.setVisible("visible"===e)},display:function(t,e){t.setVisible&&t.setVisible(null!==e)},"stop-color":function(t,e){t.setColor&&t.setColor(e)},"stop-opacity":function(t,e){t._color&&t._color.setAlpha(parseFloat(e))},offset:function(t,e){if(t.setOffset){var i=e.match(/(.*)%$/);t.setOffset(i?i[1]/100:parseFloat(e))}},viewBox:function(t,e,i,n,r){var s,h,u=new g(o(e,"array")),l=a(n,null,null,!0);if(t instanceof x){var c=l?l.divide(u.getSize()):1,h=(new p).scale(c).translate(u.getPoint().negate());s=t}else t instanceof I&&(l&&u.setSize(l),s=t._item);if(s){if("visible"!==m(n,"overflow",r)){var f=new C.Rectangle(u);f.setClipMask(!0),s.addChild(f)}h&&s.transform(h)}}}),L={};w.inject({importSVG:function(t,e){return A(t,e,this)}}),y.inject({importSVG:function(t,e){return this.activate(),A(t,e,this)}})},r.exports.PaperScript=function(){function t(t,e,i){var n=p[e];if(t&&t[n]){var r=t[n](i);return"!="===e?!r:r}switch(e){case"+":return t+i;case"-":return t-i;case"*":return t*i;case"/":return t/i;case"%":return t%i;case"==":return t==i;case"!=":return t!=i}}function e(t,e){var i=m[t];if(i&&e&&e[i])return e[i]();switch(t){case"+":return+e;case"-":return-e}}function s(t,e){return v.acorn.parse(t,e)}function o(t,e){function r(t){for(var e=0,i=f.length;i>e;e++){var n=f[e];if(n[0]>=t)break;t+=n[1]}return t}function a(e){return t.substring(r(e.range[0]),r(e.range[1]))}function o(e,i){return t.substring(r(e.range[1]),r(i.range[0]))}function h(e,i){for(var n=r(e.range[0]),s=r(e.range[1]),a=0,o=f.length-1;o>=0;o--)if(n>f[o][0]){a=o+1;break}f.splice(a,0,[n,i.length-s+n]),t=t.substring(0,n)+i+t.substring(s)}function u(t,e){if(t){for(var i in t)if("range"!==i&&"loc"!==i){var n=t[i];if(Array.isArray(n))for(var r=0,s=n.length;s>r;r++)u(n[r],t);else n&&"object"==typeof n&&u(n,t)}switch(t.type){case"UnaryExpression":if(t.operator in m&&"Literal"!==t.argument.type){var l=a(t.argument);h(t,'$__("'+t.operator+'", '+l+")")}break;case"BinaryExpression":if(t.operator in p&&"Literal"!==t.left.type){var c=a(t.left),f=a(t.right),d=o(t.left,t.right),_=t.operator;h(t,"__$__("+c+","+d.replace(new RegExp("\\"+_),'"'+_+'"')+", "+f+")")}break;case"UpdateExpression":case"AssignmentExpression":var g=e&&e.type;if(!("ForStatement"===g||"BinaryExpression"===g&&/^[=!<>]/.test(e.operator)||"MemberExpression"===g&&e.computed))if("UpdateExpression"===t.type){var l=a(t.argument),v="__$__("+l+', "'+t.operator[0]+'", 1)',y=l+" = "+v;t.prefix||"AssignmentExpression"!==g&&"VariableDeclarator"!==g||(a(e.left||e.id)===l&&(y=v),y=l+"; "+y),h(t,y)}else if(/^.=$/.test(t.operator)&&"Literal"!==t.left.type){var c=a(t.left),f=a(t.right);h(t,c+" = __$__("+c+', "'+t.operator[0]+'", '+f+")")}}}}function l(t){var e="",i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(t=(Math.abs(t)<<1)+(0>t?1:0);t||!e;){var n=31&t;t>>=5,t&&(n|=32),e+=i[n]}return e}if(!t)return"";e=e||{};var c,f=[],d=e.url||"",_=paper.agent,g=_.versionNumber,v=!1,y=e.sourceMaps,w=e.source||t,x=/\r\n|\n|\r/gm,b=e.offset||0;if(y&&(_.chrome&&g>=30||_.webkit&&g>=537.76||_.firefox&&g>=23||_.node)){if(_.node)b-=2;else if(i&&d&&!i.location.href.indexOf(d)){var C=n.getElementsByTagName("html")[0].innerHTML;b=C.substr(0,C.indexOf(t)+1).match(x).length+1}v=b>0&&!(_.chrome&&g>=36||_.safari&&g>=600||_.firefox&&g>=40||_.node);var S=["AA"+l(v?0:b)+"A"];S.length=(t.match(x)||[]).length+1+(v?b:0),c={version:3,file:d,names:[],mappings:S.join(";AACA"),sourceRoot:"",sources:[d],sourcesContent:[w]}}return u(s(t,{ranges:!0})),c&&(v&&(t=new Array(b+1).join("\n")+t),/^(inline|both)$/.test(y)&&(t+="\n//# sourceMappingURL=data:application/json;base64,"+i.btoa(unescape(encodeURIComponent(JSON.stringify(c))))),t+="\n//# sourceURL="+(d||"paperscript")),{url:d,source:w,code:t,map:c}}function h(i,s,a){function h(t,e){for(var n in t)!e&&/^_/.test(n)||!new RegExp("([\\b\\s\\W]|^)"+n.replace(/\$/g,"\\$")+"\\b").test(i)||(g.push(n),v.push(t[n]))}paper=s;var u,l=s.getView(),f=/\btool\.\w+|\s+on(?:Key|Mouse)(?:Up|Down|Move|Drag)\b/.test(i)&&!/\bnew\s+Tool\b/.test(i)?new K:null,d=f?f._events:[],_=["onFrame","onResize"].concat(d),g=[],v=[],p="object"==typeof i?i:o(i,a);i=p.code,h({__$__:t,$__:e,paper:s,view:l,tool:f},!0),h(s),_=r.each(_,function(t){new RegExp("\\s+"+t+"\\b").test(i)&&(g.push(t),this.push(t+": "+t))},[]).join(", "),_&&(i+="\nreturn { "+_+" };");var m=paper.agent;if(n&&(m.chrome||m.firefox&&m.versionNumber<40)){var y=n.createElement("script"),w=n.head||n.getElementsByTagName("head")[0];m.firefox&&(i="\n"+i),y.appendChild(n.createTextNode("paper._execute = function("+g+") {"+i+"\n}")),w.appendChild(y),u=paper._execute,delete paper._execute,w.removeChild(y)}else u=Function(g,i);var x=u.apply(s,v)||{};return r.each(d,function(t){var e=x[t];e&&(f[t]=e)}),l&&(x.onResize&&l.setOnResize(x.onResize),l.emit("resize",{size:l.size,delta:new c}),x.onFrame&&l.setOnFrame(x.onFrame),l.requestUpdate()),p}function u(t){if(/^text\/(?:x-|)paperscript$/.test(t.type)&&"true"!==a.getAttribute(t,"ignore")){var e=a.getAttribute(t,"canvas"),i=n.getElementById(e),r=t.src||t.getAttribute("data-src"),s=a.hasAttribute(t,"async"),o="data-paper-scope";if(!i)throw new Error('Unable to find canvas with id "'+e+'"');var u=a.get(i.getAttribute(o))||(new a).setup(i);return i.setAttribute(o,u._id),r?Q.request({url:r,async:s,mimeType:"text/plain",onLoad:function(t){h(t,u,r)}}):h(t.innerHTML,u,t.baseURI),t.setAttribute("data-paper-ignore","true"),u}}function l(){r.each(n&&n.getElementsByTagName("script"),u)}function f(t){return t?u(t):l()}var _,g,v=this;!function(t,e){return"object"==typeof _&&"object"==typeof module?e(_):"function"==typeof g&&g.amd?g(["exports"],e):void e(t.acorn||(t.acorn={}))}(this,function(t){"use strict";function e(t){ct=t||{};for(var e in gt)Object.prototype.hasOwnProperty.call(ct,e)||(ct[e]=gt[e]);_t=ct.sourceFile||null}function i(t,e){var i=vt(ft,t);e+=" ("+i.line+":"+i.column+")";var n=new SyntaxError(e);throw n.pos=t,n.loc=i,n.raisedAt=pt,n}function n(t){function e(t){if(1==t.length)return i+="return str === "+JSON.stringify(t[0])+";";i+="switch(str){";for(var e=0;e3){n.sort(function(t,e){return e.length-t.length}),i+="switch(str.length){";for(var r=0;rpt&&10!==i&&13!==i&&8232!==i&&8233!==i;)++pt,i=ft.charCodeAt(pt);ct.onComment&&ct.onComment(!1,ft.slice(t+2,pt),t,pt,e,ct.locations&&new r)}function u(){for(;dt>pt;){var t=ft.charCodeAt(pt);if(32===t)++pt;else if(13===t){++pt;var e=ft.charCodeAt(pt);10===e&&++pt,ct.locations&&(++kt,It=pt)}else if(10===t||8232===t||8233===t)++pt,ct.locations&&(++kt,It=pt);else if(t>8&&14>t)++pt;else if(47===t){var e=ft.charCodeAt(pt+1);if(42===e)o();else{if(47!==e)break;h()}}else if(160===t)++pt;else{if(!(t>=5760&&Ue.test(String.fromCharCode(t))))break;++pt}}}function l(){var t=ft.charCodeAt(pt+1);return t>=48&&57>=t?S(!0):(++pt,a(we))}function c(){var t=ft.charCodeAt(pt+1);return St?(++pt,x()):61===t?w(Se,2):w(be,1)}function f(){var t=ft.charCodeAt(pt+1);return 61===t?w(Se,2):w(Be,1)}function d(t){var e=ft.charCodeAt(pt+1);return e===t?w(124===t?Pe:Ae,2):61===e?w(Se,2):w(124===t?Me:ze,1)}function _(){var t=ft.charCodeAt(pt+1);return 61===t?w(Se,2):w(Te,1)}function g(t){var e=ft.charCodeAt(pt+1);return e===t?45==e&&62==ft.charCodeAt(pt+2)&&Je.test(ft.slice(At,pt))?(pt+=3,h(),u(),y()):w(ke,2):61===e?w(Se,2):w(Ne,1)}function v(t){var e=ft.charCodeAt(pt+1),i=1;return e===t?(i=62===t&&62===ft.charCodeAt(pt+2)?3:2,61===ft.charCodeAt(pt+i)?w(Se,i+1):w(Le,i)):33==e&&60==t&&45==ft.charCodeAt(pt+2)&&45==ft.charCodeAt(pt+3)?(pt+=4,h(),u(),y()):(61===e&&(i=61===ft.charCodeAt(pt+2)?3:2),w(Ee,i))}function p(t){var e=ft.charCodeAt(pt+1);return 61===e?w(Oe,61===ft.charCodeAt(pt+2)?3:2):w(61===t?Ce:Ie,1)}function m(t){switch(t){case 46:return l();case 40:return++pt,a(ge);case 41:return++pt,a(ve);case 59:return++pt,a(me);case 44:return++pt,a(pe);case 91:return++pt,a(ce);case 93:return++pt,a(fe);case 123:return++pt,a(de);case 125:return++pt,a(_e);case 58:return++pt,a(ye);case 63:return++pt,a(xe);case 48:var e=ft.charCodeAt(pt+1);if(120===e||88===e)return C();case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return S(!1);case 34:case 39:return k(t);case 47:return c(t);case 37:case 42:return f();case 124:case 38:return d(t);case 94:return _();case 43:case 45:return g(t);case 60:case 62:return v(t);case 61:case 33:return p(t);case 126:return w(Ie,1)}return!1}function y(t){if(t?pt=mt+1:mt=pt,ct.locations&&(wt=new r),t)return x();if(pt>=dt)return a(jt);var e=ft.charCodeAt(pt);if(Ye(e)||92===e)return A();var n=m(e);if(n===!1){var s=String.fromCharCode(e);if("\\"===s||Ge.test(s))return A();i(pt,"Unexpected character '"+s+"'")}return n}function w(t,e){var i=ft.slice(pt,pt+e);pt+=e,a(t,i)}function x(){for(var t,e,n="",r=pt;;){pt>=dt&&i(r,"Unterminated regular expression");var s=ft.charAt(pt);if(Je.test(s)&&i(r,"Unterminated regular expression"),t)t=!1;else{if("["===s)e=!0;else if("]"===s&&e)e=!1;else if("/"===s&&!e)break;t="\\"===s}++pt}var n=ft.slice(r,pt);++pt;var o=P();o&&!/^[gmsiy]*$/.test(o)&&i(r,"Invalid regexp flag");try{var h=new RegExp(n,o)}catch(u){u instanceof SyntaxError&&i(r,u.message),i(u)}return a(Nt,h)}function b(t,e){for(var i=pt,n=0,r=0,s=null==e?1/0:e;s>r;++r){var a,o=ft.charCodeAt(pt);if(a=o>=97?o-97+10:o>=65?o-65+10:o>=48&&57>=o?o-48:1/0,a>=t)break;++pt,n=n*t+a}return pt===i||null!=e&&pt-i!==e?null:n}function C(){pt+=2;var t=b(16);return null==t&&i(mt+2,"Expected hexadecimal number"),Ye(ft.charCodeAt(pt))&&i(pt,"Identifier directly after number"),a(Lt,t)}function S(t){var e=pt,n=!1,r=48===ft.charCodeAt(pt);t||null!==b(10)||i(e,"Invalid number"),46===ft.charCodeAt(pt)&&(++pt,b(10),n=!0);var s=ft.charCodeAt(pt);69!==s&&101!==s||(s=ft.charCodeAt(++pt),43!==s&&45!==s||++pt,null===b(10)&&i(e,"Invalid number"),n=!0),Ye(ft.charCodeAt(pt))&&i(pt,"Identifier directly after number");var o,h=ft.slice(e,pt);return n?o=parseFloat(h):r&&1!==h.length?/[89]/.test(h)||Ot?i(e,"Invalid number"):o=parseInt(h,8):o=parseInt(h,10),a(Lt,o)}function k(t){pt++;for(var e="";;){pt>=dt&&i(mt,"Unterminated string constant");var n=ft.charCodeAt(pt);if(n===t)return++pt,a(Bt,e);if(92===n){n=ft.charCodeAt(++pt);var r=/^[0-7]+/.exec(ft.slice(pt,pt+3));for(r&&(r=r[0]);r&&parseInt(r,8)>255;)r=r.slice(0,-1);if("0"===r&&(r=null),++pt,r)Ot&&i(pt-2,"Octal literal in strict mode"),e+=String.fromCharCode(parseInt(r,8)),pt+=r.length-1;else switch(n){case 110:e+="\n";break;case 114:e+="\r";break;case 120:e+=String.fromCharCode(I(2));break;case 117:e+=String.fromCharCode(I(4));break;case 85:e+=String.fromCharCode(I(8));break;case 116:e+=" ";break;case 98:e+="\b";break;case 118:e+="\x0B";break;case 102:e+="\f";break;case 48:e+="\x00";break;case 13:10===ft.charCodeAt(pt)&&++pt;case 10:ct.locations&&(It=pt,++kt);break;default:e+=String.fromCharCode(n)}}else 13!==n&&10!==n&&8232!==n&&8233!==n||i(mt,"Unterminated string constant"),e+=String.fromCharCode(n),++pt}}function I(t){var e=b(16,t);return null===e&&i(mt,"Bad character escape sequence"),e}function P(){je=!1;for(var t,e=!0,n=pt;;){var r=ft.charCodeAt(pt);if(Ke(r))je&&(t+=ft.charAt(pt)),++pt;else{if(92!==r)break;je||(t=ft.slice(n,pt)),je=!0,117!=ft.charCodeAt(++pt)&&i(pt,"Expecting Unicode escape sequence \\uXXXX"),++pt;var s=I(4),a=String.fromCharCode(s);a||i(pt-1,"Invalid Unicode escape"),(e?Ye(s):Ke(s))||i(pt-4,"Invalid Unicode escape"),t+=a}e=!1}return je?t:ft.slice(n,pt)}function A(){var t=P(),e=Ft;return!je&&He(t)&&(e=le[t]),a(e,t)}function M(){Pt=mt,At=yt,Mt=xt,y()}function T(t){if(Ot=t,pt=mt,ct.locations)for(;It>pt;)It=ft.lastIndexOf("\n",It-2)+1,--kt;u(),y()}function z(){this.type=null,this.start=mt,this.end=null}function O(){this.start=wt,this.end=null,null!==_t&&(this.source=_t)}function E(){var t=new z;return ct.locations&&(t.loc=new O),ct.directSourceFile&&(t.sourceFile=ct.directSourceFile),ct.ranges&&(t.range=[mt,0]),t}function L(t){var e=new z;return e.start=t.start,ct.locations&&(e.loc=new O,e.loc.start=t.loc.start),ct.ranges&&(e.range=[t.range[0],0]),e}function N(t,e){return t.type=e,t.end=At,ct.locations&&(t.loc.end=Mt),ct.ranges&&(t.range[1]=At),t}function B(t){return ct.ecmaVersion>=5&&"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"use strict"===t.expression.value}function F(t){return bt===t?(M(),!0):void 0}function j(){return!ct.strictSemicolons&&(bt===jt||bt===_e||Je.test(ft.slice(At,mt)))}function D(){F(me)||j()||q()}function R(t){bt===t?M():q()}function q(){i(mt,"Unexpected token")}function V(t){"Identifier"!==t.type&&"MemberExpression"!==t.type&&i(t.start,"Assigning to rvalue"),Ot&&"Identifier"===t.type&&Ve(t.name)&&i(t.start,"Assigning to "+t.name+" in strict mode")}function H(t){Pt=At=pt,ct.locations&&(Mt=new r),Tt=Ot=null,zt=[],y();var e=t||E(),i=!0;for(t||(e.body=[]);bt!==jt;){var n=U();e.body.push(n),i&&B(n)&&T(!0),i=!1}return N(e,"Program")}function U(){(bt===be||bt===Se&&"/="==Ct)&&y(!0);var t=bt,e=E();switch(t){case Dt:case Vt:M();var n=t===Dt;F(me)||j()?e.label=null:bt!==Ft?q():(e.label=lt(),D());for(var r=0;re){var r=L(t);r.left=t,r.operator=Ct;var s=bt;M(),r.right=tt(et(),n,i);var a=N(r,s===Pe||s===Ae?"LogicalExpression":"BinaryExpression");return tt(a,e,i)}return t}function et(){if(bt.prefix){var t=E(),e=bt.isUpdate;return t.operator=Ct,t.prefix=!0,St=!0,M(),t.argument=et(),e?V(t.argument):Ot&&"delete"===t.operator&&"Identifier"===t.argument.type&&i(t.start,"Deleting local variable in strict mode"),N(t,e?"UpdateExpression":"UnaryExpression")}for(var n=it();bt.postfix&&!j();){var t=L(n);t.operator=Ct,t.prefix=!1,t.argument=n,V(n),M(),n=N(t,"UpdateExpression")}return n}function it(){return nt(rt())}function nt(t,e){if(F(we)){var i=L(t);return i.object=t,i.property=lt(!0),i.computed=!1,nt(N(i,"MemberExpression"),e)}if(F(ce)){var i=L(t);return i.object=t,i.property=X(),i.computed=!0,R(fe),nt(N(i,"MemberExpression"),e)}if(!e&&F(ge)){var i=L(t);return i.callee=t,i.arguments=ut(ve,!1),nt(N(i,"CallExpression"),e)}return t}function rt(){switch(bt){case se:var t=E();return M(),N(t,"ThisExpression");case Ft:return lt();case Lt:case Bt:case Nt:var t=E();return t.value=Ct,t.raw=ft.slice(mt,yt),M(),N(t,"Literal");case ae:case oe:case he:var t=E();return t.value=bt.atomValue,t.raw=bt.keyword,M(),N(t,"Literal");case ge:var e=wt,i=mt;M();var n=X();return n.start=i,n.end=yt,ct.locations&&(n.loc.start=e,n.loc.end=xt),ct.ranges&&(n.range=[i,yt]),R(ve),n;case ce:var t=E();return M(),t.elements=ut(fe,!0,!0),N(t,"ArrayExpression");case de:return at();case Jt:var t=E();return M(),ht(t,!1);case re:return st();default:q()}}function st(){var t=E();return M(),t.callee=nt(rt(),!0),F(ge)?t.arguments=ut(ve,!1):t.arguments=Et,N(t,"NewExpression")}function at(){var t=E(),e=!0,n=!1;for(t.properties=[],M();!F(_e);){if(e)e=!1;else if(R(pe),ct.allowTrailingCommas&&F(_e))break;var r,s={key:ot()},a=!1;if(F(ye)?(s.value=X(!0),r=s.kind="init"):ct.ecmaVersion>=5&&"Identifier"===s.key.type&&("get"===s.key.name||"set"===s.key.name)?(a=n=!0,r=s.kind=s.key.name,s.key=ot(),bt!==ge&&q(),s.value=ht(E(),!1)):q(),"Identifier"===s.key.type&&(Ot||n))for(var o=0;oa?t.id:t.params[a];if((qe(o.name)||Ve(o.name))&&i(o.start,"Defining '"+o.name+"' in strict mode"),a>=0)for(var h=0;a>h;++h)o.name===t.params[h].name&&i(o.start,"Argument name clash in strict mode")}return N(t,e?"FunctionDeclaration":"FunctionExpression")}function ut(t,e,i){for(var n=[],r=!0;!F(t);){if(r)r=!1;else if(R(pe),e&&ct.allowTrailingCommas&&F(t))break;i&&bt===pe?n.push(null):n.push(X(!0))}return n}function lt(t){var e=E();return t&&"everywhere"==ct.forbidReserved&&(t=!1),bt===Ft?(!t&&(ct.forbidReserved&&(3===ct.ecmaVersion?De:Re)(Ct)||Ot&&qe(Ct))&&-1==ft.slice(mt,yt).indexOf("\\")&&i(mt,"The keyword '"+Ct+"' is reserved"),e.name=Ct):t&&bt.keyword?e.name=bt.keyword:q(),St=!1,M(),N(e,"Identifier")}t.version="0.5.0";var ct,ft,dt,_t;t.parse=function(t,i){return ft=String(t),dt=ft.length,e(i),s(),H(ct.program)};var gt=t.defaultOptions={ecmaVersion:5,strictSemicolons:!1,allowTrailingCommas:!0,forbidReserved:!1,allowReturnOutsideFunction:!1,locations:!1,onComment:null,ranges:!1,program:null,sourceFile:null,directSourceFile:null},vt=t.getLineInfo=function(t,e){for(var i=1,n=0;;){Xe.lastIndex=n;var r=Xe.exec(t);if(!(r&&r.indext?36===t:91>t?!0:97>t?95===t:123>t?!0:t>=170&&Ge.test(String.fromCharCode(t))},Ke=t.isIdentifierChar=function(t){return 48>t?36===t:58>t?!0:65>t?!1:91>t?!0:97>t?95===t:123>t?!0:t>=170&&$e.test(String.fromCharCode(t))},Qe={kind:"loop"},ti={kind:"switch"}});var p={"+":"__add","-":"__subtract","*":"__multiply","/":"__divide","%":"__modulo","==":"equals","!=":"equals"},m={"-":"__negate","+":null},y=r.each(["add","subtract","multiply","divide","modulo","negate"],function(t){this["__"+t]="#"+t},{});return c.inject(y),d.inject(y),D.inject(y),i&&("complete"===n.readyState?setTimeout(l):U.add(i,{load:l})),{compile:o,execute:h,load:f,parse:s}}.call(this),paper=new(a.inject(r.exports,{enumerable:!0,Base:r,Numerical:u,Key:J,DomEvent:U,DomElement:H,document:n,window:i,Symbol:I,PlacedSymbol:k})),paper.agent.node&&require("./node/extend")(paper),"function"==typeof define&&define.amd?define("paper",paper):"object"==typeof module&&module&&(module.exports=paper),paper}("object"==typeof self?self:null); \ No newline at end of file +return 65>t?36===t:91>t?!0:97>t?95===t:123>t?!0:t>=170&&Ge.test(String.fromCharCode(t))},Ke=t.isIdentifierChar=function(t){return 48>t?36===t:58>t?!0:65>t?!1:91>t?!0:97>t?95===t:123>t?!0:t>=170&&$e.test(String.fromCharCode(t))},Qe={kind:"loop"},ti={kind:"switch"}});var p={"+":"__add","-":"__subtract","*":"__multiply","/":"__divide","%":"__modulo","==":"__equals","!=":"__equals"},m={"-":"__negate","+":null},y=r.each(["add","subtract","multiply","divide","modulo","equals","negate"],function(t){this["__"+t]="#"+t},{});return c.inject(y),d.inject(y),D.inject(y),i&&("complete"===n.readyState?setTimeout(l):U.add(i,{load:l})),{compile:o,execute:h,load:f,parse:s}}.call(this),paper=new(a.inject(r.exports,{enumerable:!0,Base:r,Numerical:u,Key:J,DomEvent:U,DomElement:H,document:n,window:i,Symbol:I,PlacedSymbol:k})),paper.agent.node&&require("./node/extend")(paper),"function"==typeof define&&define.amd?define("paper",paper):"object"==typeof module&&module&&(module.exports=paper),paper}("object"==typeof self?self:null); \ No newline at end of file