vara=i[r],o=a._matrix;n[a._id]||a._drawSelected(t,o.isIdentity()?e:e.chain(o))}}},newfunction(){functiont(t,e){varn=t._children;if(e&&0===n.length)throwError("Use a moveTo() command first");returnn[n.length-1]}varn={moveTo:function(){vare=t(this),n=e&&e.isEmpty()?e:newA(m.NO_INSERT);n!==e&&this.addChild(n),n.moveTo.apply(n,arguments)},moveBy:function(){vare=t(this,!0),n=e&&e.getLastSegment(),i=h.read(arguments);this.moveTo(n?i.add(n._point):i)},closePath:function(e){t(this,!0).closePath(e)}};returne.each(["lineTo","cubicCurveTo","quadraticCurveTo","curveTo","arcTo","lineBy","cubicCurveBy","quadraticCurveBy","curveBy","arcBy"],function(e){n[e]=function(){varn=t(this,!0);n[e].apply(n,arguments)}}),n});z.inject(newfunction(){functione(t,e){varn=t.clone(!1).reduce().transform(null,!0,!0);returne?n.resolveCrossings().reorient():n}functionn(t,e,n,i,r){vars=newt(m.NO_INSERT);returns.addChildren(e,!0),r&&(s=s.reduce()),s.insertAbove(i&&n.isSibling(i)&&n.getIndex()<i.getIndex()?i:n),s.setStyle(n._style),s}functioni(t,i,s){functiona(t){for(vare=0,n=t.length;n>e;e++){vari=t[e];f.push.apply(f,i._segments),g.push.apply(g,i._getMonoCurves())}}if(!t._children&&!t._closed)returnr(t,i,s);varh=e(t,!0),u=i&&t!==i&&e(i,!0);u&&/^(subtract|exclude)$/.test(s)^u.isClockwise()!==h.isClockwise()&&u.reverse();vard=M.expand(h.getIntersections(u,function(t){returnu&&t.isOverlap()||t.isCrossing()}));o(d);varf=[],g=[];a(h._children||[h]),u&&a(u._children||[u]);for(var_=0,v=d.length;v>_;_++)l(d[_]._segment,h,u,g,s);for(var_=0,v=f.length;v>_;_++){varp=f[_];null==p._winding&&l(p,h,u,g,s)}returnn(O,c(f,s),t,i,!0)}functionr(i,r,s){functiona(e){returnh.contains(e.getPointAt(e.getLength()/2))^l?(c.unshift(e),!0):t}if(!r||!r._children&&!r._closed||!/^(subtract|intersect)$/.test(s))returnnull;for(varo=e(i,!1),h=e(r,!1),u=o.getIntersections(h,function(t){returnt.isOverlap()||t.isCrossing()}),l="subtract"===s,c=[],d=u.length-1;d>=0;d--){varf=u[d].split();f&&(a(f)&&f.getFirstSegment().setHandleIn(0,0),o.getLastSegment().setHandleOut(0,0))}returna(o),n(y,c,i,r)}functions(t,e){for(varn=t;n;){if(n===e)return;n=n._prev}for(;t._next&&t._next!==e;)t=t._next;if(!t._next){for(;e._prev;)e=e._prev;t._next=e,e._prev=t}}functiono(t){for(vare,n,i=4e-7,r=1-i,a=!1,o=[],h=t.length-1;h>=0;h--){varu=t[h],l=u._curve,c=u._parameter,d=c;l!==e?a=!l.hasHandles():n>0&&(c/=n);varf;i>c?f=l._segment1:c>r?f=l._segment2:(f=l.divide(c,!0,!0)._segment1,a&&o.push(f)),u._setSegment(f);varg=f._intersection,_=u._intersection;if(g){s(g,_);for(varv=g;v;)s(v._intersection,g),v=v._next}elsef._intersection=_;e=l,n=d}for(varh=0,p=o.length;p>h;h++)o[h].clearHandles()}functionu(t,e,n,i){varr=2e-7,s=4e-7,o=1-s,l=t.x,c=t.y,d=0,f=0,g=[],_=Math.abs;if(n){for(varv=-(1/0),p=1/0,m=c-r,y=c+r,w=0,x=e.length;x>w;w++){varb=e[w].values;if(I.solveCubic(b,0,l,g,0,1)>0)for(varC=g.length-1;C>=0;C--){varS=I.getPoint(b,g[C]).y;m>S&&S>v?v=S:S>y&&p>S&&(p=S)}}v=(v+c)/2,p=(p+c)/2,v>-(1/0)&&(d=u(newh(l,v),e,!1,i)),1/0>p&&(f=u(newh(l,p),e,!1,i))}elsefor(varP,k,M=l-r,z=l+r,A=!1,w=0,x=e.length;x>w;w++){varO=e[w],b=O.values,T=O.winding;if(T&&(1===T&&c>=b[1]&&c<=b[7]||c>=b[7]&&c<=b[1])&&1===I.solveCubic(b,1,c,g,0,1)){varE=g[0];if(!(E>o&&A&&O.next!==e[w+1]||s>E&&k>o&&O.previous===P)){varL=I.getPoint(b,E).x,N=I.getTangent(b,E).y,j=!1;a.isZero(N)&&!I.isStraight(b)||s>E&&N*I.getTangent(O.previous.values,1).y<0||E>o&&N*I.getTangent(O.next.values,0).y<0?i&&L>=M&&z>=L&&(++d,++f,j=!0):M>=L?(d+=T,j=!0):L>=z&&(f+=T,j=!0),O.previous!==e[w-1]&&(A=s>E&&j)}P=O,k=E}}returnMath.max(_(d),_(f))}functionl(t,e,n,i,r){vars=2e-7,a=[],o=t,h=0,l=0;do{varc=t.getCurve(),d=c.getLength();a.push({segment:t,curve:c,length:d}),h+=d,t=t.getNext()}while(t&&!t._intersection&&t!==o);for(varf=0;3>f;f++)for(vard=h*(f+1)/4,g=0,_=a.length;_>g;g++){varv=a[g],p=v.length;if(p>=d){(s>d||s>p-d)&&(d=p/2);varc=v.curve,m=c._path,y=m._parent,w=c.getPointAt(d),x=c.isHorizontal();yinstanceofO&&(m=y),l+="subtract"===r&&n&&(m===e&&n._getWinding(w,x)||m===n&&!e._getWinding(w,x))?0:u(w,i,x);break}d-=p}for(varb=
this._transform((newg).translate(h.read(arguments).negate()))},play:function(){this._animate=!0,this._requested||this._requestFrame()},pause:function(){this._animate=!1},draw:function(){this.update()},projectToView:function(){returnthis._matrix._transformPoint(h.read(arguments))},viewToProject:function(){returnthis._matrix._inverseTransform(h.read(arguments))}},{statics:{_views:[],_viewsById:{},_id:0,create:function(t,e){return"string"==typeofe&&(e=document.getElementById(e)),newH(t,e)}}},newfunction(){functiont(t){vare=q.getTarget(t);returne.getAttribute&&V._viewsById[e.getAttribute("id")]}functione(t,e){returnt.viewToProject(q.getOffset(e,t._element))}functionn(){if(!V._focused||!V._focused.isVisible())for(vart=0,e=V._views.length;e>t;t++){varn=V._views[t];if(n&&n.isVisible()){V._focused=a=n;break}}}functioni(t,e,n){t._handleEvent("mousemove",e,n);vari=t._scope.tool;returni&&i._handleEvent(l&&i.responds("mousedrag")?"mousedrag":"mousemove",e,n),t.update(),i}varr,s,a,o,h,u,l=!1,c=window.navigator;c.pointerEnabled||c.msPointerEnabled?(o="pointerdown MSPointerDown",h="pointermove MSPointerMove",u="pointerup pointercancel MSPointerUp MSPointerCancel"):(o="touchstart",h="touchmove",u="touchend touchcancel","ontouchstart"inwindow&&c.userAgent.match(/mobile|tablet|ip(ad|hone|od)|android|silk/i)||(o+=" mousedown",h+=" mousemove",u+=" mouseup"));vard={"selectstart dragstart":function(t){l&&t.preventDefault()}},f={mouseout:function(t){varn=V._focused,r=q.getRelatedTarget(t);!n||r&&"HTML"!==r.nodeName||i(n,e(n,t),t)},scroll:n};d[o]=function(n){vari=V._focused=t(n),s=e(i,n);l=!0,i._handleEvent("mousedown",s,n),(r=i._scope.tool)&&r._handleEvent("mousedown",s,n),i.update()},f[h]=function(o){varh=V._focused;if(!l){varu=t(o);u?(h!==u&&i(h,e(h,o),o),s=h,h=V._focused=a=u):a&&a===h&&(h=V._focused=s,n())}if(h){varc=e(h,o);(l||h.getBounds().contains(c))&&(r=i(h,c,o))}},f[u]=function(t){varn=V._focused;if(n&&l){vari=e(n,t);l=!1,n._handleEvent("mouseup",i,t),r&&r._handleEvent("mouseup",i,t),n.update()}},q.add(document,f),q.add(window,{load:n});varg={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}};return{_viewEvents:d,_handleEvent:function(){},_installEvent:function(t){vare=this._eventCounters;if(e)for(varning)e[n]=(e[n]||0)+(g[n][t]||0)},_uninstallEvent:function(t){vare=this._eventCounters;if(e)for(varning)e[n]-=g[n][t]||0},statics:{updateFocus:n}}}),H=V.extend({_class:"CanvasView",initialize:function(t,e){if(!(einstanceofHTMLCanvasElement)){varn=l.read(arguments,1);if(n.isZero())throwError("Cannot create CanvasView with the provided argument: "+[].slice.call(arguments,1));e=Y.getCanvas(n)}if(this._context=e.getContext("2d"),this._eventCounters={},this._pixelRatio=1,!/^off|false$/.test(i.getAttribute(e,"hidpi"))){varr=window.devicePixelRatio||1,s=F.getPrefixed(this._context,"backingStorePixelRatio")||1;this._pixelRatio=r/s}V.call(this,t,e)},_setViewSize:function(t){vare=this._element,n=this._pixelRatio,r=t.width,s=t.height;if(e.width=r*n,e.height=s*n,1!==n){if(!i.hasAttribute(e,"resize")){vara=e.style;a.width=r+"px",a.height=s+"px"}this._context.scale(n,n)}},getPixelSize:function(t){vare,n=paper.browser;if(n&&n.firefox){vari=this._element.parentNode,r=document.createElement("div");r.style.fontSize=t,i.appendChild(r),e=parseFloat(F.getStyles(r).fontSize),i.removeChild(r)}else{vars=this._context,a=s.font;s.font=t+" serif",e=parseFloat(s.font),s.font=a}returne},getTextWidth:function(t,e){varn=this._context,i=n.font,r=0;n.font=t;for(vars=0,a=e.length;a>s;s++)r=Math.max(r,n.measureText(e[s]).width);returnn.font=i,r},update:function(t){vare=this._project;if(!e||!t&&!e._needsUpdate)return!1;varn=this._context,i=this._viewSize;returnn.clearRect(0,0,i.width+1,i.height+1),e.draw(n,this._matrix,this._pixelRatio),e._needsUpdate=!1,!0}},newfunction(){functione(e,n,i,r,s,a){functiono(e){returne.responds(n)&&(h||(h=newG(n,i,r,s,a?r.subtract(a):null)),e.emit(n,h)&&h.isStoppe
e(a)}n+="}"}elsee(t);returnFunction("str",n)}functionr(){this.line=Pt,this.column=pt-kt}functions(){Pt=1,pt=kt=0,St=!0,u()}functiona(t,e){yt=pt,ct.locations&&(xt=newr),bt=t,u(),Ct=e,St=t.beforeExpr}functiono(){vart=ct.onComment&&ct.locations&&newr,e=pt,i=dt.indexOf("*/",pt+=2);if(-1===i&&n(pt-2,"Unterminated comment"),pt=i+2,ct.locations){Je.lastIndex=e;for(vars;(s=Je.exec(dt))&&s.index<pt;)++Pt,kt=s.index+s[0].length}ct.onComment&&ct.onComment(!0,dt.slice(e+2,i),e,pt,t,ct.locations&&newr)}functionh(){for(vart=pt,e=ct.onComment&&ct.locations&&newr,n=dt.charCodeAt(pt+=2);ft>pt&&10!==n&&13!==n&&8232!==n&&8233!==n;)++pt,n=dt.charCodeAt(pt);ct.onComment&&ct.onComment(!1,dt.slice(t+2,pt),t,pt,e,ct.locations&&newr)}functionu(){for(;ft>pt;){vart=dt.charCodeAt(pt);if(32===t)++pt;elseif(13===t){++pt;vare=dt.charCodeAt(pt);10===e&&++pt,ct.locations&&(++Pt,kt=pt)}elseif(10===t||8232===t||8233===t)++pt,ct.locations&&(++Pt,kt=pt);elseif(t>8&&14>t)++pt;elseif(47===t){vare=dt.charCodeAt(pt+1);if(42===e)o();else{if(47!==e)break;h()}}elseif(160===t)++pt;else{if(!(t>=5760&&Ze.test(String.fromCharCode(t))))break;++pt}}}functionl(){vart=dt.charCodeAt(pt+1);returnt>=48&&57>=t?S(!0):(++pt,a(we))}functionc(){vart=dt.charCodeAt(pt+1);returnSt?(++pt,x()):61===t?w(Se,2):w(be,1)}functiond(){vart=dt.charCodeAt(pt+1);return61===t?w(Se,2):w(je,1)}functionf(t){vare=dt.charCodeAt(pt+1);returne===t?w(124===t?Me:ze,2):61===e?w(Se,2):w(124===t?Ae:Te,1)}functiong(){vart=dt.charCodeAt(pt+1);return61===t?w(Se,2):w(Oe,1)}function_(t){vare=dt.charCodeAt(pt+1);returne===t?45==e&&62==dt.charCodeAt(pt+2)&&Xe.test(dt.slice(Mt,pt))?(pt+=3,h(),u(),y()):w(ke,2):61===e?w(Se,2):w(Pe,1)}functionv(t){vare=dt.charCodeAt(pt+1),n=1;returne===t?(n=62===t&&62===dt.charCodeAt(pt+2)?3:2,61===dt.charCodeAt(pt+n)?w(Se,n+1):w(Ne,n)):33==e&&60==t&&45==dt.charCodeAt(pt+2)&&45==dt.charCodeAt(pt+3)?(pt+=4,h(),u(),y()):(61===e&&(n=61===dt.charCodeAt(pt+2)?3:2),w(Le,n))}functionp(t){vare=dt.charCodeAt(pt+1);return61===e?w(Ee,61===dt.charCodeAt(pt+2)?3:2):w(61===t?Ce:Ie,1)}functionm(t){switch(t){case46:returnl();case40:return++pt,a(_e);case41:return++pt,a(ve);case59:return++pt,a(me);case44:return++pt,a(pe);case91:return++pt,a(ce);case93:return++pt,a(de);case123:return++pt,a(fe);case125:return++pt,a(ge);case58:return++pt,a(ye);case63:return++pt,a(xe);case48:vare=dt.charCodeAt(pt+1);if(120===e||88===e)returnC();case49:case50:case51:case52:case53:case54:case55:case56:case57:returnS(!1);case34:case39:returnP(t);case47:returnc(t);case37:case42:returnd();case124:case38:returnf(t);case94:returng();case43:case45:return_(t);case60:case62:returnv(t);case61:case33:returnp(t);case126:returnw(Ie,1)}return!1}functiony(t){if(t?pt=mt+1:mt=pt,ct.locations&&(wt=newr),t)returnx();if(pt>=ft)returna(Rt);vare=dt.charCodeAt(pt);if(Ye(e)||92===e)returnM();vari=m(e);if(i===!1){vars=String.fromCharCode(e);if("\\"===s||Ge.test(s))returnM();n(pt,"Unexpected character '"+s+"'")}returni}functionw(t,e){varn=dt.slice(pt,pt+e);pt+=e,a(t,n)}functionx(){for(vart,e,i="",r=pt;;){pt>=ft&&n(r,"Unterminated regular expression");vars=dt.charAt(pt);if(Xe.test(s)&&n(r,"Unterminated regular expression"),t)t=!1;else{if("["===s)e=!0;elseif("]"===s&&e)e=!1;elseif("/"===s&&!e)break;t="\\"===s}++pt}vari=dt.slice(r,pt);++pt;varo=I();returno&&!/^[gmsiy]*$/.test(o)&&n(r,"Invalid regexp flag"),a(Nt,RegExp(i,o))}functionb(t,e){for(varn=pt,i=0,r=0,s=null==e?1/0:e;s>r;++r){vara,o=dt.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,i=i*t+a}returnpt===n||null!=e&&pt-n!==e?null:i}functionC(){pt+=2;vart=b(16);returnnull==t&&n(mt+2,"Expected hexadecimal number"),Ye(dt.charCodeAt(pt))&&n(pt,"Identifier directly after number"),a(Lt,t)}functionS(t){vare=pt,i=!1,r=48===dt.charCodeAt(pt);t||null!==b(10)||n(e,"Invalid number"),46===dt.charCodeAt(pt)&&(++pt,b(10),i=!0);vars=dt.charCodeAt(pt);(69===s||101===s)&&(s=dt.charCodeAt(++pt),(43===s||45===s)&&++pt,null===b(10)&&n(e,"Invalid number"),