paper.js/dist/paper-full.min.js

39 lines
239 KiB
JavaScript
Raw Normal View History

/*!
* Paper.js v0.12.7 - The Swiss Army Knife of Vector Graphics Scripting.
* http://paperjs.org/
*
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
* http://juerglehni.com/ & https://puckey.studio/
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*
2024-06-20 03:39:06 -04:00
* Date: Wed Jun 19 18:51:21 2024 +0000
*
***
*
* Straps.js - Class inheritance library with support for bean-style accessors
*
* Copyright (c) 2006 - 2020 Jürg Lehni
* http://juerglehni.com/
*
* Distributed under the MIT license.
*
***
*
* Acorn.js
* https://marijnhaverbeke.nl/acorn/
*
* Acorn is a tiny, fast JavaScript parser written in JavaScript,
* created by Marijn Haverbeke and released under an MIT license.
*
*/
var paper=function(t,e){t=t||require("./node/self.js");var n=t.window?t.window:t,i=t.document,r=new function(){function t(t,e,r,s,a){function u(i,u){u=u||(u=o(e,i))&&(u.get?u:u.value),"string"==typeof u&&"#"===u[0]&&(u=t[u.substring(1)]||u);var c,f="function"==typeof u,d=u,_=a||f&&!u.base?u&&u.get?i in t:t[i]:null;a&&_||(f&&_&&(u.base=_),f&&s!==!1&&(c=i.match(/^([gs]et|is)(([A-Z])(.*))$/))&&(l[c[3].toLowerCase()+c[4]]=c[2]),d&&!f&&d.get&&"function"==typeof d.get&&n.isPlainObject(d)||(d={value:d,writable:!0}),(o(t,i)||{configurable:!0}).configurable&&(d.configurable=!0,d.enumerable=null!=r?r:!c),h(t,i,d))}var l={};if(e){for(var c in e)e.hasOwnProperty(c)&&!i.test(c)&&u(c);for(var c in l){var f=l[c],d=t["set"+f],_=t["get"+f]||d&&t["is"+f];!_||s!==!0&&0!==_.length||u(c,{get:_,set:d})}}return t}function n(){for(var t=0,e=arguments.length;t<e;t++){var n=arguments[t];n&&c(this,n)}return this}var i=/^(statics|enumerable|beans|preserve)$/,r=[],s=r.slice,a=Object.create,o=Object.getOwnPropertyDescriptor,h=Object.defineProperty,u=r.forEach||function(t,e){for(var n=0,i=this.length;n<i;n++)t.call(e,this[n],n,this)},l=function(t,e){for(var n in this)this.hasOwnProperty(n)&&t.call(e,this[n],n,this)},c=Object.assign||function(t){for(var e=1,n=arguments.length;e<n;e++){var i=arguments[e];for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}return t},f=function(t,e,n){if(t){var i=o(t,"length");(i&&"number"==typeof i.value?u:l).call(t,e,n=n||t)}return n};return t(n,{inject:function(e){if(e){var n=e.statics===!0?e:e.statics,i=e.beans,r=e.preserve;n!==e&&t(this.prototype,e,e.enumerable,i,r),t(this,n,null,i,r)}for(var s=1,a=arguments.length;s<a;s++)this.inject(arguments[s]);return this},extend:function(){for(var e,n,i,r=this,s=0,o=arguments.length;s<o&&(!e||!n);s++)i=arguments[s],e=e||i.initialize,n=n||i.prototype;return e=e||function(){r.apply(this,arguments)},n=e.prototype=n||a(this.prototype),h(n,"constructor",{value:e,writable:!0,configurable:!0}),t(e,this),arguments.length&&this.inject.apply(e,arguments),e.base=r,e}}).inject({enumerable:!1,initialize:n,set:n,inject:function(){for(var e=0,n=arguments.length;e<n;e++){var i=arguments[e];i&&t(this,i,i.enumerable,i.beans,i.preserve)}return this},extend:function(){var t=a(this);return t.inject.apply(t,arguments)},each:function(t,e){return f(this,t,e)},clone:function(){return new this.constructor(this)},statics:{set:c,each:f,create:a,define:h,describe:o,clone:function(t){return c(new t.constructor,t)},isPlainObject:function(t){var e=null!=t&&t.constructor;return e&&(e===Object||e===n||"Object"===e.name)},pick:function(t,n){return t!==e?t:n},slice:function(t,e,n){return s.call(t,e,n)}}})};"undefined"!=typeof module&&(module.exports=r),r.inject({enumerable:!1,toString:function(){return null!=this._id?(this._class||"Object")+(this._name?" '"+this._name+"'":" @"+this._id):"{ "+r.each(this,function(t,e){if(!/^_/.test(e)){var n=typeof t;this.push(e+": "+("number"===n?u.instance.number(t):"string"===n?"'"+t+"'":t))}},[]).join(", ")+" }"},getClassName:function(){return this._class||""},importJSON:function(t){return r.importJSON(t,this)},exportJSON:function(t){return r.exportJSON(this,t)},toJSON:function(){return r.serialize(this)},set:function(t,e){return t&&r.filter(this,t,e,this._prioritize),this}},{beans:!1,statics:{exports:{},extend:function ot(){var t=ot.base.apply(this,arguments),e=t.prototype._class;return e&&!r.exports[e]&&(r.exports[e]=t),t},equals:function(t,e){if(t===e)return!0;if(t&&t.equals)return t.equals(e);if(e&&e.equals)return e.equals(t);if(t&&e&&"object"==typeof t&&"object"==typeof e){if(Array.isArray(t)&&Array.isArray(e)){var n=t.length;if(n!==e.length)return!1;for(;n--;)if(!r.equals(t[n],e[n]))return!1}else{var i=Object.keys(t),n=i.length;if(n!==Object.keys(e).length)return!1;for(;n--;){var s=i[n];if(!e.hasOwnProperty(s)||!r.equals(t[s],e[s]))return!1}}return!0}return!1},read:function(t,n,i,s){if(this===r){var a=this.peek(t,n);return t.__index++,a}var o=this.prototype,h=o._readIndex,u=n||h&&t.__index||0,l=t.length,c=t[u];if(s=s||l-u,c instanceof this||i&&i.readNull&&null==c&&s<=1)retu
var n="set"+e;this[n]=function(){this._dontNotify=!0,t[n].apply(this,arguments),this._dontNotify=!1,this._owner[this._setter](this)}},{isSelected:function(){return!!(2&this._owner._selection)},setSelected:function(t){var e=this._owner;e._changeSelection&&e._changeSelection(2,t)}}))}),m=r.extend({_class:"Matrix",initialize:function lt(t,e){var n=arguments,i=n.length,r=!0;if(i>=6?this._set.apply(this,n):1===i||2===i?t instanceof lt?this._set(t._a,t._b,t._c,t._d,t._tx,t._ty,e):Array.isArray(t)?this._set.apply(this,e?t.concat([e]):t):r=!1:i?r=!1:this.reset(),!r)throw new Error("Unsupported matrix parameters");return this},set:"#initialize",_set:function(t,e,n,i,r,s,a){return this._a=t,this._b=e,this._c=n,this._d=i,this._tx=r,this._ty=s,a||this._changed(),this},_serialize:function(t,e){return r.serialize(this.getValues(),t,!0,e)},_changed:function(){var t=this._owner;t&&(t._applyMatrix?t.transform(null,!0):t._changed(25))},clone:function(){return new m(this._a,this._b,this._c,this._d,this._tx,this._ty)},equals:function(t){return t===this||t&&this._a===t._a&&this._b===t._b&&this._c===t._c&&this._d===t._d&&this._tx===t._tx&&this._ty===t._ty},toString:function(){var t=u.instance;return"[["+[t.number(this._a),t.number(this._c),t.number(this._tx)].join(", ")+"], ["+[t.number(this._b),t.number(this._d),t.number(this._ty)].join(", ")+"]]"},reset:function(t){return this._a=this._d=1,this._b=this._c=this._tx=this._ty=0,t||this._changed(),this},apply:function(t,e){var n=this._owner;return!!n&&(n.transform(null,r.pick(t,!0),e),this.isIdentity())},translate:function(){var t=f.read(arguments),e=t.x,n=t.y;return this._tx+=e*this._a+n*this._c,this._ty+=e*this._b+n*this._d,this._changed(),this},scale:function(){var t=arguments,e=f.read(t),n=f.read(t,0,{readNull:!0});return n&&this.translate(n),this._a*=e.x,this._b*=e.x,this._c*=e.y,this._d*=e.y,n&&this.translate(n.negate()),this._changed(),this},rotate:function(t){t*=Math.PI/180;var e=f.read(arguments,1),n=e.x,i=e.y,r=Math.cos(t),s=Math.sin(t),a=n-n*r+i*s,o=i-n*s-i*r,h=this._a,u=this._b,l=this._c,c=this._d;return this._a=r*h+s*l,this._b=r*u+s*c,this._c=-s*h+r*l,this._d=-s*u+r*c,this._tx+=a*h+o*l,this._ty+=a*u+o*c,this._changed(),this},shear:function(){var t=arguments,e=f.read(t),n=f.read(t,0,{readNull:!0});n&&this.translate(n);var i=this._a,r=this._b;return this._a+=e.y*this._c,this._b+=e.y*this._d,this._c+=e.x*i,this._d+=e.x*r,n&&this.translate(n.negate()),this._changed(),this},skew:function(){var t=arguments,e=f.read(t),n=f.read(t,0,{readNull:!0}),i=Math.PI/180,r=new f(Math.tan(e.x*i),Math.tan(e.y*i));return this.shear(r,n)},append:function(t,e){if(t){var n=this._a,i=this._b,r=this._c,s=this._d,a=t._a,o=t._c,h=t._b,u=t._d,l=t._tx,c=t._ty;this._a=a*n+h*r,this._c=o*n+u*r,this._b=a*i+h*s,this._d=o*i+u*s,this._tx+=l*n+c*r,this._ty+=l*i+c*s,e||this._changed()}return this},prepend:function(t,e){if(t){var n=this._a,i=this._b,r=this._c,s=this._d,a=this._tx,o=this._ty,h=t._a,u=t._c,l=t._b,c=t._d,f=t._tx,d=t._ty;this._a=h*n+u*i,this._c=h*r+u*s,this._b=l*n+c*i,this._d=l*r+c*s,this._tx=h*a+u*o+f,this._ty=l*a+c*o+d,e||this._changed()}return this},appended:function(t){return this.clone().append(t)},prepended:function(t){return this.clone().prepend(t)},invert:function(){var t=this._a,e=this._b,n=this._c,i=this._d,r=this._tx,s=this._ty,a=t*i-e*n,o=null;return a&&!isNaN(a)&&isFinite(r)&&isFinite(s)&&(this._a=i/a,this._b=-e/a,this._c=-n/a,this._d=t/a,this._tx=(n*s-i*r)/a,this._ty=(e*r-t*s)/a,o=this),o},inverted:function(){return this.clone().invert()},concatenate:"#append",preConcatenate:"#prepend",chain:"#appended",_shiftless:function(){return new m(this._a,this._b,this._c,this._d,0,0)},_orNullIfIdentity:function(){return this.isIdentity()?null:this},isIdentity:function(){return 1===this._a&&0===this._b&&0===this._c&&1===this._d&&0===this._tx&&0===this._ty},isInvertible:function(){var t=this._a*this._d-this._c*this._b;return t&&!isNaN(t)&&isFinite(this._tx)&&isFinite(this._ty)},isSingular:function(){return!this.isInvertible()},transform:function(t,e,n){return arguments.length<3?this._transformPoint(f.read
return!0}},globalToLocal:function(){return this.getGlobalMatrix(!0)._inverseTransform(f.read(arguments))},localToGlobal:function(){return this.getGlobalMatrix(!0)._transformPoint(f.read(arguments))},parentToLocal:function(){return this._matrix._inverseTransform(f.read(arguments))},localToParent:function(){return this._matrix._transformPoint(f.read(arguments))},fitBounds:function(t,e){t=v.read(arguments);var n=this.getBounds(),i=n.height/n.width,r=t.height/t.width,s=(e?i>r:i<r)?t.width/n.width:t.height/n.height,a=new v(new f,new _(n.width*s,n.height*s));a.setCenter(t.getCenter()),this.setBounds(a)}}),{_setStyles:function(t,e,n,i){var r=this._style,s=this._matrix;if(r.hasFill()&&(t.fillStyle=r.getFillColor().toCanvasStyle(t,s,i)),r.hasStroke()){t.strokeStyle=r.getStrokeColor().toCanvasStyle(t,s,i),t.lineWidth=r.getStrokeWidth();var a=r.getStrokeJoin(),o=r.getStrokeCap(),h=r.getMiterLimit();if(a&&(t.lineJoin=a),o&&(t.lineCap=o),h&&(t.miterLimit=h),at.support.nativeDash){var u=r.getDashArray(),l=r.getDashOffset();u&&u.length&&("setLineDash"in t?(t.setLineDash(u),t.lineDashOffset=l):(t.mozDash=u,t.mozDashOffset=l))}}if(r.hasShadow()){var c=e.pixelRatio||1,d=n._shiftless().prepend((new m).scale(c,c)),_=d.transform(new f(r.getShadowBlur(),0)),g=d.transform(this.getShadowOffset());t.shadowColor=r.getShadowColor().toCanvasStyle(t),t.shadowBlur=_.getLength(),t.shadowOffsetX=g.x,t.shadowOffsetY=g.y}},draw:function(t,e,n){this._updateVersion=this._project._updateVersion;if(this._visible&&0!==this._opacity){var i=e.matrices,r=e.viewMatrix,s=this._matrix,a=i[i.length-1].appended(s);if(a.isInvertible()){r=r?r.appended(a):a,i.push(a),e.updateMatrix&&(this._globalMatrix=a);var o,h,u,c=this._blendMode,f=l.clamp(this._opacity,0,1),d="normal"===c,_=it.nativeModes[c],g=d&&1===f||e.dontStart||e.clip||(_||d&&f<1)&&this._canComposite(),v=e.pixelRatio||1;if(!g){var p=this.getStrokeBounds(r);if(!p.width||!p.height)return void i.pop();u=e.offset,h=e.offset=p.getTopLeft().floor(),o=t,t=nt.getContext(p.getSize().ceil().add(1).multiply(v)),1!==v&&t.scale(v,v)}t.save();var m=n?n.appended(s):this._canScaleStroke&&!this.getStrokeScaling(!0)&&r,y=!g&&e.clipItem,w=!m||y;if(g?(t.globalAlpha=f,_&&(t.globalCompositeOperation=c)):w&&t.translate(-h.x,-h.y),w&&(g?s:r).applyToContext(t),y&&e.clipItem.draw(t,e.extend({clip:!0})),m){t.setTransform(v,0,0,v,0,0);var x=e.offset;x&&t.translate(-x.x,-x.y)}this._draw(t,e,r,m),t.restore(),i.pop(),e.clip&&!e.dontFinish&&t.clip(this.getFillRule()),g||(it.process(c,t,o,f,h.subtract(u).multiply(v)),nt.release(t),e.offset=u)}}},_isUpdated:function(t){var e=this._parent;if(e instanceof N)return e._isUpdated(t);var n=this._updateVersion===t;return!n&&e&&e._visible&&e._isUpdated(t)&&(this._updateVersion=t,n=!0),n},_drawSelection:function(t,e,n,i,r){var s=this._selection,a=1&s,o=2&s||a&&this._selectBounds,h=4&s;if(this._drawSelected||(a=!1),(a||o||h)&&this._isUpdated(r)){var u,l=this.getSelectedColor(!0)||(u=this.getLayer())&&u.getSelectedColor(!0),c=e.appended(this.getGlobalMatrix(!0)),f=n/2;if(t.strokeStyle=t.fillStyle=l?l.toCanvasStyle(t):"#009dec",t.lineWidth=2.5,a&&this._drawSelected(t,c,i),h){var d=this.getPosition(!0),_=this._parent,g=_?_.localToGlobal(d):d,v=g.x,p=g.y;t.beginPath(),t.arc(v,p,f,0,2*Math.PI,!0),t.stroke();for(var m=[[0,-1],[1,0],[0,1],[-1,0]],y=f,w=n+1,x=0;x<4;x++){var b=m[x],C=b[0],S=b[1];t.moveTo(v+C*y,p+S*y),t.lineTo(v+C*w,p+S*w),t.stroke()}}if(o){var k=c._transformCorners(this.getInternalBounds());t.beginPath();for(var x=0;x<8;x++)t[x?"lineTo":"moveTo"](k[x],k[++x]);t.closePath(),t.stroke();for(var x=0;x<8;x++)t.fillRect(k[x]-f,k[++x]-f,n,n)}}},_canComposite:function(){return!1}},r.each(["down","drag","up","move"],function(t){this["removeOn"+r.capitalize(t)]=function(){var e={};return e[t]=!0,this.removeOn(e)}},{removeOn:function(t){for(var e in t)if(t[e]){var n="mouse"+e,i=this._project,r=i._removeSets=i._removeSets||{};r[n]=r[n]||{},r[n][this._id]=this}return this}}),{tween:function(t,e,n){function i(t){o._handleFrame(1e3*t.time),o.running||this.off("frame",i)}n||(n=e,e=t,t=null,n||(n=e,e=null));var
e.clone()}},{}),r.each({isStraight:function(t,e,n,i){if(e.isZero()&&n.isZero())return!0;var r=i.subtract(t);if(r.isZero())return!1;if(r.isCollinear(e)&&r.isCollinear(n)){var s=new y(t,i),a=1e-7;if(s.getDistance(t.add(e))<a&&s.getDistance(i.add(n))<a){var o=r.dot(r),h=r.dot(e)/o,u=r.dot(n)/o;return h>=0&&h<=1&&u<=0&&u>=-1}}return!1},isLinear:function(t,e,n,i){var r=i.subtract(t).divide(3);return e.equals(r)&&n.negate().equals(r)}},function(t,e){this[e]=function(e){var n=this._segment1,i=this._segment2;return t(n._point,n._handleOut,i._handleIn,i._point,e)},this.statics[e]=function(e,n){var i=e[0],r=e[1],s=e[6],a=e[7];return t(new f(i,r),new f(e[2]-i,e[3]-r),new f(e[4]-s,e[5]-a),new f(s,a),n)}},{statics:{},hasHandles:function(){return!this._segment1._handleOut.isZero()||!this._segment2._handleIn.isZero()},hasLength:function(t){return(!this.getPoint1().equals(this.getPoint2())||this.hasHandles())&&this.getLength()>(t||0)},isCollinear:function(t){return t&&this.isStraight()&&t.isStraight()&&this.getLine().isCollinear(t.getLine())},isHorizontal:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).y)<1e-8},isVertical:function(){return this.isStraight()&&Math.abs(this.getTangentAtTime(.5).x)<1e-8}}),{beans:!1,getLocationAt:function(t,e){return this.getLocationAtTime(e?t:this.getTimeAt(t))},getLocationAtTime:function(t){return null!=t&&t>=0&&t<=1?new O(this,t):null},getTimeAt:function(t,e){return z.getTimeAt(this.getValues(),t,e)},getParameterAt:"#getTimeAt",getTimesWithTangent:function(){var t=f.read(arguments);return t.isZero()?[]:z.getTimesWithTangent(this.getValues(),t)},getOffsetAtTime:function(t){return this.getPartLength(0,t)},getLocationOf:function(){return this.getLocationAtTime(this.getTimeOf(f.read(arguments)))},getOffsetOf:function(){var t=this.getLocationOf.apply(this,arguments);return t?t.getOffset():null},getTimeOf:function(){return z.getTimeOf(this.getValues(),f.read(arguments))},getParameterOf:"#getTimeOf",getNearestLocation:function(){var t=f.read(arguments),e=this.getValues(),n=z.getNearestTime(e,t),i=z.getPoint(e,n);return new O(this,n,i,null,t.getDistance(i))},getNearestPoint:function(){var t=this.getNearestLocation.apply(this,arguments);return t?t.getPoint():t}},new function(){var t=["getPoint","getTangent","getNormal","getWeightedTangent","getWeightedNormal","getCurvature"];return r.each(t,function(t){this[t+"At"]=function(e,n){var i=this.getValues();return z[t](i,n?e:z.getTimeAt(i,e))},this[t+"AtTime"]=function(e){return z[t](this.getValues(),e)}},{statics:{_evaluateMethods:t}})},new function(){function t(t){var e=t[0],n=t[1],i=t[2],r=t[3],s=t[4],a=t[5],o=t[6],h=t[7],u=9*(i-s)+3*(o-e),l=6*(e+s)-12*i,c=3*(i-e),f=9*(r-a)+3*(h-n),d=6*(n+a)-12*r,_=3*(r-n);return function(t){var e=(u*t+l)*t+c,n=(f*t+d)*t+_;return Math.sqrt(e*e+n*n)}}function n(t,e){return Math.max(2,Math.min(16,Math.ceil(32*Math.abs(e-t))))}function i(t,e,n,i){if(null==e||e<0||e>1)return null;var r=t[0],s=t[1],a=t[2],o=t[3],h=t[4],u=t[5],c=t[6],d=t[7],_=l.isZero;_(a-r)&&_(o-s)&&(a=r,o=s),_(h-c)&&_(u-d)&&(h=c,u=d);var g,v,p=3*(a-r),m=3*(h-a)-p,y=c-r-p-m,w=3*(o-s),x=3*(u-o)-w,b=d-s-w-x;if(0===n)g=0===e?r:1===e?c:((y*e+m)*e+p)*e+r,v=0===e?s:1===e?d:((b*e+x)*e+w)*e+s;else{var C=1e-8,S=1-C;if(e<C?(g=p,v=w):e>S?(g=3*(c-h),v=3*(d-u)):(g=(3*y*e+2*m)*e+p,v=(3*b*e+2*x)*e+w),i){0===g&&0===v&&(e<C||e>S)&&(g=h-a,v=u-o);var k=Math.sqrt(g*g+v*v);k&&(g/=k,v/=k)}if(3===n){var h=6*y*e+2*m,u=6*b*e+2*x,I=Math.pow(g*g+v*v,1.5);g=0!==I?(g*u-v*h)/I:0,v=0}}return 2===n?new f(v,(-g)):new f(g,v)}return{statics:{classify:function(t){function n(t,n,i){var r=n!==e,s=r&&n>0&&n<1,a=r&&i>0&&i<1;return!r||(s||a)&&("loop"!==t||s&&a)||(t="arch",s=a=!1),{type:t,roots:s||a?s&&a?n<i?[n,i]:[i,n]:[s?n:i]:null}}var i=t[0],r=t[1],s=t[2],a=t[3],o=t[4],h=t[5],u=t[6],c=t[7],f=i*(c-h)+r*(o-u)+u*h-c*o,d=s*(r-c)+a*(u-i)+i*c-r*u,_=o*(a-r)+h*(i-s)+s*r-a*i,g=3*_,v=g-d,p=v-d+f,m=Math.sqrt(p*p+v*v+g*g),y=0!==m?1/m:0,w=l.isZero,x="serpentine";if(p*=y,v*=y,g*=y,w(p))return w(v)?n(w(g)?"line":"quadratic"):n(x,g/(3*v));var b=3*v*v-4*p*g;if(w(b))return n("cusp",v/(2*p));var C=b>0?
}else if(t&&t.getPath&&t.getPath()===this)return t;return null},getOffsetsWithTangent:function(){var t=f.read(arguments);if(t.isZero())return[];for(var e=[],n=0,i=this.getCurves(),r=0,s=i.length;r<s;r++){for(var a=i[r],o=a.getTimesWithTangent(t),h=0,u=o.length;h<u;h++){var l=n+a.getOffsetAtTime(o[h]);e.indexOf(l)<0&&e.push(l)}n+=a.length}return e}}),new function(){function t(t,e,n,i,r){function s(e){var n=u[e],i=u[e+1];a==n&&o==i||(t.beginPath(),t.moveTo(a,o),t.lineTo(n,i),t.moveTo(n-h,i),t.lineTo(n,i+h),t.lineTo(n+h,i),t.lineTo(n,i-h),t.closePath(),t.stroke())}if(!(i<=0))for(var a,o,h=i/2,u=new Array(6),l=0,c=e.length;l<c;l++){var f=e[l],d=f._selection;f._transformCoordinates(n,u),a=u[0],o=u[1],2&d&&!r&&s(2),4&d&&!r&&s(4),t.beginPath(),t.arc(a,o,h,0,2*Math.PI,!0),t.stroke();var _=t.fillStyle;1&d||(t.fillStyle="rgba(255, 255, 255, 0.5)"),t.fill(),t.fillStyle=_}}function e(t,e,n){function i(e){if(n)e._transformCoordinates(n,_),r=_[0],s=_[1];else{var i=e._point;r=i._x,s=i._y}if(g)t.moveTo(r,s),g=!1;else{if(n)h=_[2],u=_[3];else{var f=e._handleIn;h=r+f._x,u=s+f._y}h===r&&u===s&&l===a&&c===o?t.lineTo(r,s):t.bezierCurveTo(l,c,h,u,r,s)}if(a=r,o=s,n)l=_[4],c=_[5];else{var f=e._handleOut;l=a+f._x,c=o+f._y}}for(var r,s,a,o,h,u,l,c,f=e._segments,d=f.length,_=new Array(6),g=!0,v=0;v<d;v++)i(f[v]);e._closed&&d>0&&i(f[0])}return{_draw:function(t,n,i,r){function s(t){return c[(t%f+f)%f]}var a=n.dontStart,o=n.dontFinish||n.clip,h=this.getStyle(),u=h.hasFill(),l=h.hasStroke(),c=h.getDashArray(),f=!at.support.nativeDash&&l&&c&&c.length;if(a||t.beginPath(),(u||l&&!f||o)&&(e(t,this,r),this._closed&&t.closePath()),!o&&(u||l)&&(this._setStyles(t,n,i,r),u&&(t.fill(h.getFillRule()),t.shadowColor="rgba(0,0,0,0)"),l)){if(f){a||t.beginPath();var d,_=new B(this,.25,32,(!1),r),g=_.length,v=-h.getDashOffset(),p=0;for(v%=g;v>0;)v-=s(p--)+s(p--);for(;v<g;)d=v+s(p++),(v>0||d>0)&&_.drawPart(t,Math.max(v,0),Math.max(d,0)),v=d+s(p++)}t.stroke()}},_drawSelected:function(n,i){n.beginPath(),e(n,this,i),n.stroke(),t(n,this._segments,i,at.settings.handleSize,this.isFullySelected())}}},new function(){function t(t){var e=t._segments;if(!e.length)throw new Error("Use a moveTo() command first");return e[e.length-1]}return{moveTo:function(){var t=this._segments;1===t.length&&this.removeSegment(0),t.length||this._add([new M(f.read(arguments))])},moveBy:function(){throw new Error("moveBy() is unsupported on Path items.")},lineTo:function(){this._add([new M(f.read(arguments))])},cubicCurveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),r=f.read(e),s=t(this);s.setHandleOut(n.subtract(s._point)),this._add([new M(r,i.subtract(r))])},quadraticCurveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),r=t(this)._point;this.cubicCurveTo(n.add(r.subtract(n).multiply(1/3)),n.add(i.subtract(n).multiply(1/3)),i)},curveTo:function(){var e=arguments,n=f.read(e),i=f.read(e),s=r.pick(r.read(e),.5),a=1-s,o=t(this)._point,h=n.subtract(o.multiply(a*a)).subtract(i.multiply(s*s)).divide(2*s*a);if(h.isNaN())throw new Error("Cannot put a curve through points with parameter = "+s);this.quadraticCurveTo(h,i)},arcTo:function(){var e,n,i,s,a,o=arguments,h=Math.abs,u=Math.sqrt,c=t(this),d=c._point,g=f.read(o),v=r.peek(o),p=r.pick(v,!0);if("boolean"==typeof p)var w=d.add(g).divide(2),e=w.add(w.subtract(d).rotate(p?-90:90));else if(r.remain(o)<=2)e=g,g=f.read(o);else if(!d.equals(g)){var x=_.read(o),b=l.isZero;if(b(x.width)||b(x.height))return this.lineTo(g);var C=r.read(o),p=!!r.read(o),S=!!r.read(o),w=d.add(g).divide(2),k=d.subtract(w).rotate(-C),I=k.x,P=k.y,T=h(x.width),A=h(x.height),z=T*T,O=A*A,L=I*I,E=P*P,N=u(L/z+E/O);if(N>1&&(T*=N,A*=N,z=T*T,O=A*A),N=(z*O-z*E-O*L)/(z*E+O*L),h(N)<1e-12&&(N=0),N<0)throw new Error("Cannot create an arc with the given arguments");n=new f(T*P/A,-A*I/T).multiply((S===p?-1:1)*u(N)).rotate(C).add(w),a=(new m).translate(n).rotate(C).scale(T,A),s=a._inverseTransform(d),i=s.getDirectedAngle(a._inverseTransform(g)),!p&&i>0?i-=360:p&&i<0&&(i+=360)}if(e){var B=new y(d.add(e).divide(2),e.subtract(d).rotate(90),(!0)),F=new y(e.add(g).divide(2),g.subtract(e).rotate(9
return[o,u,h]},"hsl-rgb":function(t,e,n){if(t=(t/360%1+1)%1,0===e)return[n,n,n];for(var i=[t+1/3,t,t-1/3],r=n<.5?n*(1+e):n+e-n*e,s=2*n-r,a=[],o=0;o<3;o++){var h=i[o];h<0&&(h+=1),h>1&&(h-=1),a[o]=6*h<1?s+6*(r-s)*h:2*h<1?r:3*h<2?s+(r-s)*(2/3-h)*6:s}return a},"rgb-gray":function(t,e,n){return[.2989*t+.587*e+.114*n]},"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(i,function(t,e){s[e]=[],r.each(t,function(t,n){var a=r.capitalize(t),o=/^(hue|saturation)$/.test(t),h=s[e][n]="gradient"===e?"gradient"===t?function(t){var e=this._components[0];return t=q.read(Array.isArray(t)?t:arguments,0,{readNull:!0}),e!==t&&(e&&e._removeOwner(this),t&&t._addOwner(this)),t}:function(){return f.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[n]:this._convert(e)[n]},this["set"+a]=function(t){this._type===e||o&&/^hs[bl]$/.test(this._type)||(this._components=this._convert(e),this._properties=i[e],this._type=e),this._components[n]=h.call(this,t),this._changed()}},this)},{_class:"Color",_readIndex:!0,initialize:function l(e){var n,a,o,h,u=arguments,c=this.__read,f=0;Array.isArray(e)&&(u=e,e=u[0]);var d=null!=e&&typeof e;if("string"===d&&e in i&&(n=e,e=u[1],Array.isArray(e)?(a=e,o=u[2]):(c&&(f=1),u=r.slice(u,1),d=typeof e)),!a){if(h="number"===d?u:"object"===d&&null!=e.length?e:null){n||(n=h.length>=3?"rgb":"gray");var _=i[n].length;o=h[_],c&&(f+=h===arguments?_+(null!=o?1:0):1),h.length>_&&(h=r.slice(h,0,_))}else if("string"===d){var g=t(e);n=g[0],a=g[1],4===a.length&&(o=a[3],a.length--)}else if("object"===d)if(e.constructor===l){if(n=e._type,a=e._components.slice(),o=e._alpha,"gradient"===n)for(var v=1,p=a.length;v<p;v++){var m=a[v];m&&(a[v]=m.clone())}}else if(e.constructor===q)n="gradient",h=u;else{n="hue"in e?"lightness"in e?"hsl":"hsb":"gradient"in e||"stops"in e||"radial"in e?"gradient":"gray"in e?"gray":"rgb";var y=i[n],w=s[n];this._components=a=[];for(var v=0,p=y.length;v<p;v++){var x=e[y[v]];null==x&&!v&&"gradient"===n&&"stops"in e&&(x={stops:e.stops,radial:e.radial}),x=w[v].call(this,x),null!=x&&(a[v]=x)}o=e.alpha}c&&n&&(f=1)}if(this._type=n||"rgb",!a){this._components=a=[];for(var w=s[this._type],v=0,p=w.length;v<p;v++){var x=w[v].call(this,h&&h[v]);null!=x&&(a[v]=x)}}return this._components=a,this._properties=i[this._type],this._alpha=o,c&&(this.__read=f),this},set:"#initialize",_serialize:function(t,e){var n=this.getComponents();return r.serialize(/^(gray|rgb)$/.test(this._type)?n:[this._type].concat(n),t,!0,e)},_changed:function(){this._canvasStyle=null,this._owner&&(this._setter?this._owner[this._setter](this):this._owner._changed(129))},_convert:function(t){var e;return this._type===t?this._components.slice():(e=h[this._type+"-"+t])?e.apply(this,this._components):h["rgb-"+t].apply(this,h[this._type+"-rgb"].apply(this,this._components))},convert:function(t){return new R(t,this._convert(t),this._alpha)},getType:function(){return this._type},setType:function(t){this._components=this._convert(t),this._properties=i[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)?R.read(arguments):t;return e===this||e&&this._class===e._class&&this._type===e._type&&this.getAlpha()===e.getAlpha()&&r.equals(this._components,e._components)||!1},toString:function(){for(var t=this._properties,e=[],n="gradient"===this._type,i=u.instance,r=0,s=t.length;r<s;r++){var a=this._components[r];null!=a&&e.push(t[r]+": "+(n?a:i.number(a)))}return null!=this._alpha&&e.push("alpha: "+i.number(this._alpha)),"{ "+e.join(", ")+" }"},toCSS:function(t){function e(t){return Mat
2024-04-24 17:50:29 -04:00
this._setProperty(o,h)}else s=h&&h.clone?h.clone():h;n[a]=s}return n},_resolveValue:function(t,e){if(e){if(Array.isArray(e)&&2===e.length){var n=e[0];return n&&n.match&&n.match(/^[+\-\*\/]=/)?this._calculate(t,n[0],e[1]):e}if("string"==typeof e){var i=e.match(/^[+\-*/]=(.*)/);if(i){var r=JSON.parse(i[1].replace(/(['"])?([a-zA-Z0-9_]+)(['"])?:/g,'"$2": '));return this._calculate(t,e[0],r)}}}return e},_calculate:function(t,e,n){return at.PaperScript.calculateBinary(t,e,n)},_parseKeys:function(t){for(var e={},n=0,i=t.length;n<i;n++){var r=t[n],s=r.replace(/\.([^.]*)/g,"/$1").replace(/\[['"]?([^'"\]]*)['"]?\]/g,"/$1");e[r]=s.split("/")}return e},_getProperty:function(t,e){for(var n=this.object,i=0,r=t.length-(e||0);i<r&&n;i++)n=n[t[i]];return n},_setProperty:function(t,e){var n=this._getProperty(t,1);n&&(n[t[t.length-1]]=e)}}),et={request:function(e){var n=new t.XMLHttpRequest;return n.open((e.method||"get").toUpperCase(),e.url,r.pick(e.async,!0)),e.mimeType&&n.overrideMimeType(e.mimeType),n.onload=function(){var t=n.status;0===t||200===t?e.onLoad&&e.onLoad.call(n,n.responseText):n.onerror()},n.onerror=function(){var t=n.status,i='Could not load "'+e.url+'" (Status: '+t+")";if(!e.onError)throw new Error(i);e.onError(i,t)},n.send(null)}},nt={canvases:[],getCanvas:function(t,e){if(!n)return null;var r,s=!0;"object"==typeof t&&(e=t.height,t=t.width),this.canvases.length?r=this.canvases.pop():(r=i.createElement("canvas"),s=!1);var a=r.getContext("2d");if(!a)throw new Error("Canvas "+r+" is unable to provide 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 n=this.getCanvas(t,e);return n?n.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))}},it=new function(){function t(t,e,n){return.2989*t+.587*e+.114*n}function e(e,n,i,r){var s=r-t(e,n,i);d=e+s,_=n+s,g=i+s;var r=t(d,_,g),a=v(d,_,g),o=p(d,_,g);if(a<0){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 n(t,e,n){return p(t,e,n)-v(t,e,n)}function i(t,e,n,i){var r,s=[t,e,n],a=p(t,e,n),o=v(t,e,n);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])*i/(s[a]-s[o]),s[a]=i):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=u<128?2*u*s/255:255-2*(255-u)*(255-s)/255,_=l<128?2*l*a/255:255-2*(255-l)*(255-a)/255,g=c<128?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=s<128?2*s*u/255:255-2*(255-s)*(255-u)/255,_=a<128?2*a*l/255:255-2*(255-a)*(255-l)/255,g=o<128?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=u<s?u:s,_=l<a?l:a,g=c<o?c:o},lighten:function(){d=u>s?u:s,_=l>a?l:a,g=c>o?c:o},difference:function(){d=u-s,d<0&&(d=-d),_=l-a,_<0&&(_=-_),g=c-o,g<0&&(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(){i(s,a,o,n(u,l,c)),e(d,_,g,t(u,l,c))},saturation:function(){i(u,l,c,n(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","s
null!==_t&&(this.source=_t)}function L(){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 E(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=Tt,ct.locations&&(t.loc.end=Mt),ct.ranges&&(t.range[1]=Tt),t}function B(t){return ct.ecmaVersion>=5&&"ExpressionStatement"===t.type&&"Literal"===t.expression.type&&"use strict"===t.expression.value}function F(t){if(bt===t)return M(),!0}function j(){return!ct.strictSemicolons&&(bt===jt||bt===_e||Je.test(ft.slice(Tt,mt)))}function D(){F(me)||j()||q()}function R(t){bt===t?M():q()}function q(){n(mt,"Unexpected token")}function V(t){"Identifier"!==t.type&&"MemberExpression"!==t.type&&n(t.start,"Assigning to rvalue"),Ot&&"Identifier"===t.type&&Ve(t.name)&&n(t.start,"Assigning to "+t.name+" in strict mode")}function U(t){Pt=Tt=pt,ct.locations&&(Mt=new r),At=Ot=null,zt=[],y();var e=t||L(),n=!0;for(t||(e.body=[]);bt!==jt;){var i=H();e.body.push(i),n&&B(i)&&A(!0),n=!1}return N(e,"Program")}function H(){(bt===be||bt===Se&&"/="==Ct)&&y(!0);var t=bt,e=L();switch(t){case Dt:case Vt:M();var i=t===Dt;F(me)||j()?e.label=null:bt!==Ft?q():(e.label=lt(),D());for(var r=0;r<zt.length;++r){var s=zt[r];if(null==e.label||s.name===e.label.name){if(null!=s.kind&&(i||"loop"===s.kind))break;if(e.label&&i)break}}return r===zt.length&&n(e.start,"Unsyntactic "+t.keyword),N(e,i?"BreakStatement":"ContinueStatement");case Ut:return M(),D(),N(e,"DebuggerStatement");case Zt:return M(),zt.push(Ye),e.body=H(),zt.pop(),R(ne),e.test=Z(),D(),N(e,"DoWhileStatement");case Gt:if(M(),zt.push(Ye),R(ge),bt===me)return $(e,null);if(bt===ee){var a=L();return M(),J(a,!0),N(a,"VariableDeclaration"),1===a.declarations.length&&F(ue)?G(e,a):$(e,a)}var a=X(!1,!0);return F(ue)?(V(a),G(e,a)):$(e,a);case Jt:return M(),ht(e,!0);case Xt:return M(),e.test=Z(),e.consequent=H(),e.alternate=F(Wt)?H():null,N(e,"IfStatement");case Kt:return At||ct.allowReturnOutsideFunction||n(mt,"'return' outside of function"),M(),F(me)||j()?e.argument=null:(e.argument=X(),D()),N(e,"ReturnStatement");case Qt:M(),e.discriminant=Z(),e.cases=[],R(de),zt.push(tn);for(var o,h;bt!=_e;)if(bt===Rt||bt===Ht){var u=bt===Rt;o&&N(o,"SwitchCase"),e.cases.push(o=L()),o.consequent=[],M(),u?o.test=X():(h&&n(Pt,"Multiple default clauses"),h=!0,o.test=null),R(ye)}else o||q(),o.consequent.push(H());return o&&N(o,"SwitchCase"),M(),zt.pop(),N(e,"SwitchStatement");case Yt:return M(),Je.test(ft.slice(Tt,mt))&&n(Tt,"Illegal newline after throw"),e.argument=X(),D(),N(e,"ThrowStatement");case te:if(M(),e.block=W(),e.handler=null,bt===qt){var l=L();M(),R(ge),l.param=lt(),Ot&&Ve(l.param.name)&&n(l.param.start,"Binding "+l.param.name+" in strict mode"),R(ve),l.guard=null,l.body=W(),e.handler=N(l,"CatchClause")}return e.guardedHandlers=Lt,e.finalizer=F($t)?W():null,e.handler||e.finalizer||n(e.start,"Missing catch or finally clause"),N(e,"TryStatement");case ee:return M(),J(e),D(),N(e,"VariableDeclaration");case ne:return M(),e.test=Z(),zt.push(Ye),e.body=H(),zt.pop(),N(e,"WhileStatement");case ie:return Ot&&n(mt,"'with' in strict mode"),M(),e.object=Z(),e.body=H(),N(e,"WithStatement");case de:return W();case me:return M(),N(e,"EmptyStatement");default:var c=Ct,f=X();if(t===Ft&&"Identifier"===f.type&&F(ye)){for(var r=0;r<zt.length;++r)zt[r].name===c&&n(f.start,"Label '"+c+"' is already declared");var d=bt.isLoop?"loop":bt===Qt?"switch":null;return zt.push({name:c,kind:d}),e.body=H(),zt.pop(),e.label=f,N(e,"LabeledStatement")}return e.expression=f,D(),N(e,"ExpressionStatement")}}function Z(){R(ge);var t=X();return R(ve),t}function W(t){var e,n=L(),i=!0,r=!1;for(n.body=[],R(de);!F(_e);){var s=H();n.body.push(s),i&&t&&B(s)&&(e=r,A(r=!0)),i=!1}return r&&!e&&A(!1),N(n,"BlockStatement")}function $(t,e){return t.init=e,R(me),t.test=bt===me?null:X(),R(me),t.update=bt===ve?null:X(),R(ve),t.body=H(),zt.pop(),N(t,"ForStatement")}function G(t,e){return t.left=e,t.right=X(),R(ve),t.body=H(),zt.pop(),