@joint/core 4.1.3 → 4.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/geometry.js +128 -123
- package/dist/geometry.min.js +2 -2
- package/dist/joint.d.ts +77 -16
- package/dist/joint.js +2238 -1727
- package/dist/joint.min.js +2 -2
- package/dist/joint.nowrap.js +2237 -1724
- package/dist/joint.nowrap.min.js +2 -2
- package/dist/vectorizer.js +469 -272
- package/dist/vectorizer.min.js +2 -2
- package/dist/version.mjs +1 -1
- package/package.json +28 -22
- package/src/V/create.mjs +51 -0
- package/src/V/index.mjs +69 -154
- package/src/V/namespace.mjs +9 -0
- package/src/V/transform.mjs +183 -0
- package/src/V/traverse.mjs +16 -0
- package/src/anchors/index.mjs +140 -33
- package/src/cellTools/Boundary.mjs +1 -1
- package/src/cellTools/Control.mjs +1 -1
- package/src/connectionPoints/index.mjs +24 -9
- package/src/connectionStrategies/index.mjs +1 -1
- package/src/connectors/jumpover.mjs +1 -1
- package/src/dia/Cell.mjs +6 -2
- package/src/dia/CellView.mjs +47 -39
- package/src/dia/Element.mjs +79 -35
- package/src/dia/HighlighterView.mjs +32 -11
- package/src/dia/Paper.mjs +134 -22
- package/src/dia/PaperLayer.mjs +9 -2
- package/src/dia/attributes/text.mjs +12 -3
- package/src/dia/layers/GridLayer.mjs +5 -0
- package/src/dia/ports.mjs +152 -39
- package/src/env/index.mjs +1 -1
- package/src/g/rect.mjs +7 -0
- package/src/highlighters/stroke.mjs +1 -1
- package/src/linkAnchors/index.mjs +2 -2
- package/src/linkTools/Anchor.mjs +2 -2
- package/src/linkTools/Vertices.mjs +4 -6
- package/src/util/util.mjs +1 -1
- package/src/util/utilHelpers.mjs +2 -0
- package/types/geometry.d.ts +2 -0
- package/types/joint.d.ts +79 -20
- package/src/V/annotation.mjs +0 -0
package/dist/geometry.min.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/*! JointJS v4.
|
|
1
|
+
/*! JointJS v4.2.0-alpha.0 (2025-06-16) - JavaScript diagramming library
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
5
5
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
6
6
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
7
7
|
*/
|
|
8
|
-
((t,n)=>{"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).g={})})(this,function(t){let{round:M,floor:W,PI:j}=Math;function r(t){return t%360+(t<0?360:0)}function e(t,n){return n*M(t/n)}function s(t){return 180*t/j%360}function o(t,n){return(t=(n=n||!1)?t:t%360)*j/180}function h(t,n){var e;return void 0===n?(n=void 0===t?1:t,t=0):n<t&&(e=t,t=n,n=e),W(Math.random()*(n-t+1)+t)}function k(t,n){var e=o(t.y),i=o(n.y),t=t.x,n=n.x,n=o(n-t),t=Z(n)*u(i),e=u(e)*Z(i)-Z(e)*u(i)*u(n);return(i=s(B(t,e))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function V(t,n){var e=t.x,t=t.y;return(e-=n.x)*e+(t-=n.y)*t}function F(t,n){return Math.sqrt(V(t,n))}function d(t,n){if(!(this instanceof d))return new d(t,n);var e;"string"==typeof t?(e=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(e[0]),n=parseFloat(e[1])):Object(t)===t&&(n=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===n?0:n}let{cos:u,sin:Z,atan2:B}=Math,a={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:c,cos:G,sin:U,sqrt:X,min:Y,max:$,atan2:H,round:J,pow:_,PI:K}=Math;d.fromPolar=function(t,n,e){e=new d(e);var i=c(t*G(n)),t=c(t*U(n)),n=r(s(n));return n<90?t=-t:n<180?(i=-i,t=-t):n<270&&(i=-i),new d(e.x+i,e.y+t)},d.random=function(t,n,e,i){return new d(h(t,n),h(e,i))},d.prototype={type:a.Point,chooseClosest:function(t){var n=t.length;if(1===n)return new d(t[0]);for(var e=null,i=1/0,r=0;r<n;r++){var s=new d(t[r]),o=this.squaredDistance(s);o<i&&(e=s,i=o)}return e},adhereToRect:function(t){return t.containsPoint(this)||(this.x=Y($(this.x,t.x),t.x+t.width),this.y=Y($(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,n){n=this.equals(t)||this.equals(n)?NaN:this.theta(n)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return k(this,t)},changeInAngle:function(t,n,e){return this.clone().offset(-t,-n).theta(e)-this.theta(e)},clone:function(){return new d(this)},cross:function(t,n){return t&&n?(n.x-this.x)*(t.y-this.y)-(n.y-this.y)*(t.x-this.x):NaN},difference:function(t,n){return Object(t)===t&&(n=t.y,t=t.x),new d(this.x-(t||0),this.y-(n||0))},distance:function(t){return F(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,n){var e=this.x,i=this.y;return new d((1-n)*e+n*t.x,(1-n)*i+n*t.y)},magnitude:function(){return X(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return c(t.x-this.x)+c(t.y-this.y)},move:function(t,n){t=o(new d(t).theta(this));return this.offset(G(t)*n,-U(t)*n)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},offset:function(t,n){return Object(t)===t&&(n=t.y,t=t.x),this.x+=t||0,this.y+=n||0,this},reflection:function(t){return new d(t).move(this,this.distance(t))},rotate:function(t,n){var e,i;return 0!==n&&(t=t||new d(0,0),n=o(r(-n)),e=G(n),n=U(n),i=e*(this.x-t.x)-n*(this.y-t.y)+t.x,n=n*(this.x-t.x)+e*(this.y-t.y)+t.y,this.x=i,this.y=n),this},round:function(t){let n=1;if(t)switch(t){case 1:n=10;break;case 2:n=100;break;case 3:n=1e3;break;default:n=_(10,t)}return this.x=J(this.x*n)/n,this.y=J(this.y*n)/n,this},scale:function(t,n,e){return e=e&&new d(e)||new d(0,0),this.x=e.x+t*(this.x-e.x),this.y=e.y+n*(this.y-e.y),this},snapToGrid:function(t,n){return this.x=e(this.x,t),this.y=e(this.y,n||t),this},squaredDistance:function(t){return V(this,t)},theta:function(t){var n=-((t=new d(t)).y-this.y),t=t.x-this.x,n=H(n,t);return 180*(n=n<0?2*K+n:n)/K},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new d(t)||new d(0,0);var n=this.x,e=this.y;return this.x=X((n-t.x)*(n-t.x)+(e-t.y)*(e-t.y)),this.y=o(t.theta(new d(n,e))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,n){return Object(t)===t&&(n=t.y,t=t.x),this.x=t||0,this.y=n||0,this},vectorAngle:function(t){return new d(0,0).angleBetween(this,t)}},d.prototype.translate=d.prototype.offset;var Q=d;let{max:tt,min:nt}=Math,g=function(t,n){return this instanceof g?t instanceof g?new g(t.start,t.end):(this.start=new d(t),void(this.end=new d(n))):new g(t,n)};g.prototype={type:a.Line,angle:function(){var t=new d(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=nt(this.start.x,this.end.x),n=nt(this.start.y,this.end.y),e=tt(this.start.x,this.end.x),i=tt(this.start.y,this.end.y);return new A(t,n,e-t,i-n)},bearing:function(){return k(this.start,this.end)},clone:function(){return new g(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){t=this.vector().dot(new g(this.start,t).vector()),t=nt(1,tt(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var n,e=this.start,i=this.end;return 0===e.cross(t,i)&&(n=this.length(),!(new g(e,t).length()>n||new g(t,i).length()>n))},divideAt:function(t){t=this.pointAt(t);return[new g(this.start,t),new g(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new g(this.start,t),new g(t,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,n){return t&&t.intersectionWithLine?(n=t.intersectionWithLine(this,n))&&t instanceof g?n[0]:n:null},intersectionWithLine:function(t){var n=new d(this.end.x-this.start.x,this.end.y-this.start.y),e=new d(t.end.x-t.start.x,t.end.y-t.start.y),i=n.x*e.y-n.y*e.x,t=new d(t.start.x-this.start.x,t.start.y-this.start.y),e=t.x*e.y-t.y*e.x,t=t.x*n.y-t.y*n.x;if(0==i||e*i<0||t*i<0)return null;if(0<i){if(i<e||i<t)return null}else if(e<i||t<i)return null;return[new d(this.start.x+e*n.x/i,this.start.y+e*n.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return F(this.start,this.end)},midpoint:function(){return new d((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var n,e,i,r,s=this.clone();return this.isDifferentiable()&&({start:n,end:e}=s,i=n.clone().rotate(e,270),r=e.clone().rotate(n,90),n.move(r,t),e.move(i,t)),s},pointAt:function(t){var n=this.start,e=this.end;return t<=0?n.clone():1<=t?e.clone():n.lerp(e,t)},pointAtLength:function(t){var n=this.start,e=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?e:n).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new d(t);var n=this.start,e=this.end;return((e.x-n.x)*(t.y-n.y)-(e.y-n.y)*(t.x-n.x))/this.length()},rotate:function(t,n){return this.start.rotate(t,n),this.end.rotate(t,n),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,n,e){return this.start.scale(t,n,e),this.end.scale(t,n,e),this},setLength:function(t){var n=this.length();return n?this.scale(t=t/n,t,this.start):this},squaredLength:function(){return V(this.start,this.end)},tangentAt:function(t){var n,e;return this.isDifferentiable()?(n=this.start,e=this.end,t=this.pointAt(t),(e=new g(n,e)).translate(t.x-n.x,t.y-n.y),e):null},tangentAtLength:function(t){var n,e;return this.isDifferentiable()?(n=this.start,e=this.end,t=this.pointAtLength(t),(e=new g(n,e)).translate(t.x-n.x,t.y-n.y),e):null},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,n){return this.start.translate(t,n),this.end.translate(t,n),this},vector:function(){return new d(this.end.x-this.start.x,this.end.y-this.start.y)}},g.prototype.intersection=g.prototype.intersect;var et=g;function i(t,n,e){return this instanceof i?t instanceof i?new i(new d(t.x,t.y),t.a,t.b):(t=new d(t),this.x=t.x,this.y=t.y,this.a=n,void(this.b=e)):new i(t,n,e)}let{sqrt:it,round:l,pow:rt}=Math;i.fromRect=function(t){return t=new A(t),new i(t.center(),t.width/2,t.height/2)},i.prototype={type:a.Ellipse,bbox:function(){return new A(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new d(this.x,this.y)},clone:function(){return new i(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,n){return void 0===t&&(t=0),void 0===n&&(n=t),this.a+=2*t,this.b+=2*n,this},intersectionWithLine:function(t){var n=[],e=t.start,i=t.end,r=this.a,s=this.b,t=t.vector(),o=e.difference(new d(this)),h=new d(t.x/(r*r),t.y/(s*s)),r=new d(o.x/(r*r),o.y/(s*s)),s=t.dot(h),h=t.dot(r),t=h*h-s*(o.dot(r)-1);if(t<0)return null;if(0<t){o=it(t),r=(-h-o)/s,t=(-h+o)/s;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&n.push(e.lerp(i,r)),0<=t&&t<=1&&n.push(e.lerp(i,t))}else{o=-h/s;if(!(0<=o&&o<=1))return null;n.push(e.lerp(i,o))}return n},intersectionWithLineFromCenterToPoint:function(t,n){t=new d(t),n&&t.rotate(new d(this.x,this.y),n);var e,i,r,s=t.x-this.x,o=t.y-this.y;return r=0==s?this.bbox().pointNearestToPoint(t):(o=(t=o/s)*t,i=this.a*this.a,e=this.b*this.b,i=it(1/(1/i+o/e)),o=t*(i=s<0?-i:i),new d(this.x+i,this.y+o)),n?r.rotate(new d(this.x,this.y),-n):r},normalizedDistance:function(t){var n=t.x,t=t.y,e=this.a,i=this.b,r=this.x,s=this.y;return(n-r)*(n-r)/(e*e)+(t-s)*(t-s)/(i*i)},round:function(t){let n=1;if(t)switch(t){case 1:n=10;break;case 2:n=100;break;case 3:n=1e3;break;default:n=rt(10,t)}return this.x=l(this.x*n)/n,this.y=l(this.y*n)/n,this.a=l(this.a*n)/n,this.b=l(this.b*n)/n,this},tangentTheta:function(t){var n,e,i=t.x,r=t.y,s=this.a,o=this.b,h=this.bbox().center(),u=h.x,a=h.y;return h.x+s/2<i||i<h.x-s/2?e=s*s/(i-u)-s*s*(r-a)*((n=i>h.x?r-30:r+30)-a)/(o*o*(i-u))+u:n=o*o/(r-a)-o*o*(i-u)*((e=r>h.y?i+30:i-30)-u)/(s*s*(r-a))+a,new d(e,n).theta(t)},toString:function(){return new d(this.x,this.y).toString()+" "+this.a+" "+this.b}};var st=i;let{abs:ot,cos:ht,sin:ut,min:f,max:at,round:p,pow:ct}=Math,A=function(t,n,e,i){if(!(this instanceof A))return new A(t,n,e,i);Object(t)===t&&(n=t.y,e=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===n?0:n,this.width=void 0===e?0:e,this.height=void 0===i?0:i};A.fromEllipse=function(t){return t=new i(t),new A(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},A.fromPointUnion=function(){if(0===arguments.length)return null;var n=new d;let e,i,r,s;e=i=1/0,r=s=-1/0;for(let t=0;t<arguments.length;t++){n.update(t<0||arguments.length<=t?void 0:arguments[t]);var o=n.x,h=n.y;o<e&&(e=o),o>r&&(r=o),h<i&&(i=h),h>s&&(s=h)}return new A(e,i,r-e,s-i)},A.fromRectUnion=function(){if(0===arguments.length)return null;var n=new A;let e,i,r,s;e=i=1/0,r=s=-1/0;for(let t=0;t<arguments.length;t++){n.update(t<0||arguments.length<=t?void 0:arguments[t]);var o=n.x,h=n.y,u=o+n.width,a=h+n.height;o<e&&(e=o),u>r&&(r=u),h<i&&(i=h),a>s&&(s=a)}return new A(e,i,r-e,s-i)},A.prototype={type:a.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var n,e,i,r;return t&&({width:i,height:n}=this,t=o(t),r=i*(e=ot(ut(t)))+n*(t=ot(ht(t))),this.x+=(i-(i=i*t+n*e))/2,this.y+=(n-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new d(this.x,this.y+this.height)},bottomLine:function(){return new g(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new d(this.x+this.width/2,this.y+this.height)},center:function(){return new d(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new A(this)},containsPoint:function(t,n){let e,i;return t&&"string"!=typeof t?{x:e=0,y:i=0}=t:{x:e,y:i}=new d(t),n&&n.strict?e>this.x&&e<this.x+this.width&&i>this.y&&i<this.y+this.height:e>=this.x&&e<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var n,e,i=new A(this).normalize(),t=new A(t).normalize(),r=i.width,s=i.height,o=t.width,h=t.height;return!!(r&&s&&o&&h)&&(n=i.x,i=i.y,o+=e=t.x,r+=n,h+=t=t.y,s+=i,n<=e)&&o<=r&&i<=t&&h<=s},corner:function(){return new d(this.x+this.width,this.y+this.height)},equals:function(t){var n=new A(this).normalize(),t=new A(t).normalize();return n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height},inflate:function(t,n){return void 0===t&&(t=0),void 0===n&&(n=t),this.x-=t,this.y-=n,this.width+=2*t,this.height+=2*n,this},intersect:function(t){var n,e=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=e.x||t.y<=e.y||r.x>=i.x||r.y>=i.y?null:(n=at(e.x,r.x),e=at(e.y,r.y),new A(n,e,f(i.x,t.x)-n,f(i.y,t.y)-e))},intersectionWithLine:function(t){for(var n,e=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],s=e.length,o=0;o<s;o++)null!==(n=t.intersect(e[o]))&&r.indexOf(n.toString())<0&&(i.push(n),r.push(n.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,n){t=new d(t);for(var e,i=new d(this.x+this.width/2,this.y+this.height/2),r=(n&&t.rotate(i,n),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),s=new g(i,t),o=r.length-1;0<=o;--o){var h=r[o].intersection(s);if(null!==h){e=h;break}}return e&&n&&e.rotate(i,-n),e},leftLine:function(){return new g(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new d(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,n){t=new A(t);var e,i,r,s,o,h,u,a=(n=n||t.center()).x,n=n.y,c=e=i=r=s=o=h=u=1/0,l=t.topLeft(),l=(l.x<a&&(c=(this.x-a)/(l.x-a)),l.y<n&&(s=(this.y-n)/(l.y-n)),t.bottomRight()),l=(l.x>a&&(e=(this.x+this.width-a)/(l.x-a)),n<l.y&&(o=(this.y+this.height-n)/(l.y-n)),t.topRight()),l=(l.x>a&&(i=(this.x+this.width-a)/(l.x-a)),l.y<n&&(h=(this.y-n)/(l.y-n)),t.bottomLeft());return l.x<a&&(r=(this.x-a)/(l.x-a)),n<l.y&&(u=(this.y+this.height-n)/(l.y-n)),{sx:f(c,e,i,r),sy:f(s,o,h,u)}},maxRectUniformScaleToFit:function(t,n){t=this.maxRectScaleToFit(t,n);return f(t.sx,t.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},normalize:function(){var t=this.x,n=this.y,e=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,e=-this.width),this.height<0&&(n=this.y+this.height,i=-this.height),this.x=t,this.y=n,this.width=e,this.height=i,this},offset:function(t,n){return d.prototype.offset.call(this,t,n)},origin:function(){return new d(this.x,this.y)},pointNearestToPoint:function(t){if(t=new d(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new d(this.x+this.width,t.y);case"left":return new d(this.x,t.y);case"bottom":return new d(t.x,this.y+this.height);case"top":return new d(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new g(this.topRight(),this.bottomRight())},rightMiddle:function(){return new d(this.x+this.width,this.y+this.height/2)},round:function(t){let n=1;if(t)switch(t){case 1:n=10;break;case 2:n=100;break;case 3:n=1e3;break;default:n=ct(10,t)}return this.x=p(this.x*n)/n,this.y=p(this.y*n)/n,this.width=p(this.width*n)/n,this.height=p(this.height*n)/n,this},scale:function(t,n,e){return e=this.origin().scale(t,n,e),this.x=e.x,this.y=e.y,this.width*=t,this.height*=n,this},sideNearestToPoint:function(t){var n=(t=new d(t)).x-this.x,e=this.x+this.width-t.x,i=t.y-this.y,r="left";return e<n&&(n=e,r="right"),i<n&&(n=i,r="top"),r=this.y+this.height-t.y<n?"bottom":r},snapToGrid:function(t,n){var e=this.origin().snapToGrid(t,n),t=this.corner().snapToGrid(t,n);return this.x=e.x,this.y=e.y,this.width=t.x-e.x,this.height=t.y-e.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new g(this.topLeft(),this.topRight())},topMiddle:function(){return new d(this.x+this.width/2,this.y)},topRight:function(){return new d(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return A.fromRectUnion(this,t)},update:function(t,n,e,i){return Object(t)===t&&(n=t.y,e=t.width,i=t.height,t=t.x),this.x=t||0,this.y=n||0,this.width=e||0,this.height=i||0,this}},A.prototype.bottomRight=A.prototype.corner,A.prototype.topLeft=A.prototype.origin,A.prototype.translate=A.prototype.offset;var lt=A;function ft(t){t=t.trim();if(""===t)return[];var n=[],e=t.split(/\b\s*,\s*|,\s*|\s+/),i=e.length;for(let t=0;t<i;t+=2)n.push({x:+e[t],y:+e[t+1]});return n}function dt(n){var e=n.length;if(0===e)return[];var i=[];for(let t=0;t<e;t++){var r=n[t].clone();i.push(r)}return i}function gt(t){var n,e=Math.abs,i=t.length;if(0===i)return[];for(s=0;s<i;s++)(void 0===n||t[s].y<n.y||t[s].y===n.y&&t[s].x>n.x)&&(n=t[s]);for(var r=[],s=0;s<i;s++){var o=n.theta(t[s]),o=(0===o&&(o=360),[t[s],s,o]);r.push(o)}r.sort(function(t,n){var e=t[2]-n[2];return e=0===e?n[1]-t[1]:e}),2<r.length&&r.unshift(r[r.length-1]);for(var h,u,a,c={},l=[];0!==r.length;)if(u=(h=r.pop())[0],!c.hasOwnProperty(h[0]+"@@"+h[1]))for(var f,d,g,p,v,y=!1;!y;)l.length<2?(l.push(h),y=!0):(d=(f=l.pop())[0],(v=(p=(g=l.pop())[0]).cross(d,u))<0?(l.push(g),l.push(f),l.push(h),y=!0):0!==v||e((v=d.angleBetween(p,u))-180)<1e-10||d.equals(u)||p.equals(d)?(c[f[0]+"@@"+f[1]]=d,l.push(g)):e((v+1)%360-1)<1e-10&&(l.push(g),r.push(f)));2<l.length&&l.pop();var w=-1,m=l.length;for(s=0;s<m;s++){var x=l[s][1];(void 0===a||x<a)&&(a=x,w=s)}var b,S,P=[],A=[];for(m=(P=0<w?(b=l.slice(w),S=l.slice(0,w),b.concat(S)):l).length,s=0;s<m;s++)A.push(P[s][0]);return A}function v(t){return this instanceof v?"string"==typeof t?new v.parse(t):void(this.points=Array.isArray(t)?t.map(d):[]):new v(t)}function y(t,n,e,i){return this instanceof y?t instanceof y?new y(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new d(t),this.controlPoint1=new d(n),this.controlPoint2=new d(e),void(this.end=new d(i))):new y(t,n,e,i)}v.parse=function(t){return new v(ft(t))},v.fromRect=function(t){return new v([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},v.prototype={type:a.Polyline,bbox:function(){var t=1/0,n=-1/0,e=1/0,i=-1/0,r=this.points,s=r.length;if(0===s)return null;for(var o=0;o<s;o++){var h=r[o],u=h.x,h=h.y;u<t&&(t=u),n<u&&(n=u),h<e&&(e=h),i<h&&(i=h)}return new A(t,e,n-t,i-e)},clone:function(){return new v(dt(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},closestPointLength:function(t){var n,e=this.lengthPoints(),i=e.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,s=0,o=i-1,h=0;h<o;h++){var u=new g(e[h],e[h+1]),a=u.length(),c=u.closestPointNormalizedLength(t),u=u.pointAt(c).squaredDistance(t);u<r&&(r=u,n=s+c*a),s+=a}return n},closestPointNormalizedLength:function(t){var n,t=this.closestPointLength(t);return 0===t||0===(n=this.length())?0:t/n},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},containsPoint:function(t){var n=this.points,e=n.length;if(0===e)return!1;for(var i=t.x,r=t.y,s=e-1,o=0,h=0,u=new g,a=new g,c=new d;o<e;o++){var l=n[s],f=n[o];if(t.equals(l))return!0;if(u.start=l,u.end=f,u.containsPoint(t))return!0;(r<=l.y&&r>f.y||r>l.y&&r<=f.y)&&0<=(l=l.x-i>f.x-i?l.x-i:f.x-i)&&(c.x=i+l,c.y=r,a.start=t,a.end=c,u.intersect(a))&&h++,s=o}return h%2==1},close:function(){var{start:t,end:n,points:e}=this;return t&&n&&!t.equals(n)&&e.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new v(gt(this.points))},equals:function(t){if(!t)return!1;var n=this.points,e=t.points,i=n.length;if(e.length!==i)return!1;for(var r=0;r<i;r++){var s=n[r],o=t.points[r];if(!s.equals(o))return!1}return!0},intersectionWithLine:function(t){for(var n=new g(t),e=[],i=this.lengthPoints(),r=new g,s=0,o=i.length-1;s<o;s++){r.start=i[s],r.end=i[s+1];var h=n.intersectionWithLine(r);h&&e.push(h[0])}return 0<e.length?e:null},isDifferentiable:function(){var t=this.points,n=t.length;if(0!==n)for(var e=new g,i=n-1,r=0;r<i;r++)if(e.start=t[r],e.end=t[r+1],e.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),n=t.length;if(0===n)return 0;for(var e=0,i=n-1,r=0;r<i;r++)e+=t[r].distance(t[r+1]);return e},pointAt:function(t){var n=this.lengthPoints(),e=n.length;return 0===e?null:1===e||t<=0?n[0].clone():1<=t?n[e-1].clone():(n=this.length(),this.pointAtLength(n*t))},pointAtLength:function(t){var n=this.lengthPoints(),e=n.length;if(0===e)return null;if(1===e)return n[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),s=e-1,o=0;o<s;o++){var h=i?o:s-1-o,u=n[h],h=n[h+1],a=new g(u,h),u=u.distance(h);if(t<=r+u)return a.pointAtLength((i?1:-1)*(t-r));r+=u}return(i?n[e-1]:n[0]).clone()},round:function(t){for(var n=this.points,e=n.length,i=0;i<e;i++)n[i].round(t);return this},scale:function(t,n,e){for(var i=this.points,r=i.length,s=0;s<r;s++)i[s].scale(t,n,e);return this},simplify:function(){var n=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},e=this.points;if(!(e.length<3)){var i=n.threshold||1e-10;let t=0;for(;e[t+2];){var r=t,s=t+1,o=t+2,r=e[r],h=e[s],o=e[o];new g(r,o).closestPoint(h).distance(h)<=i?e.splice(s,1):t+=1}}return this},tangentAt:function(t){var n=this.lengthPoints().length;if(0===n)return null;if(1===n)return null;1<(t=t<0?0:t)&&(t=1);n=this.length();return this.tangentAtLength(n*t)},tangentAtLength:function(t){var n=this.lengthPoints(),e=n.length;if(0===e)return null;if(1===e)return null;for(var i,r=!0,s=(t<0&&(r=!1,t=-t),0),o=e-1,h=0;h<o;h++){var u=r?h:o-1-h,a=n[u],u=n[u+1],c=new g(a,u),a=a.distance(u);if(c.isDifferentiable()){if(t<=s+a)return c.tangentAtLength((r?1:-1)*(t-s));i=c}s+=a}return i?i.tangentAt(r?1:0):null},toString:function(){return this.points+""},translate:function(t,n){for(var e=this.points,i=e.length,r=0;r<i;r++)e[r].translate(t,n);return this},serialize:function(){var t=this.points,n=t.length;if(0===n)return"";for(var e="",i=0;i<n;i++){var r=t[i];e+=r.x+","+r.y+" "}return e.trim()}},Object.defineProperty(v.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(v.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});let{abs:L,sqrt:pt,min:vt,max:yt,pow:wt}=Math;function mt(t){var n=t.length,e=[],i=[],r=2;e[0]=t[0]/r;for(var s=1;s<n;s++)i[s]=1/r,e[s]=(t[s]-e[s-1])/(r=(s<n-1?4:3.5)-i[s]);for(s=1;s<n;s++)e[n-s-1]-=i[n-s]*e[n-s];return e}function n(t){for(var n=[],e=arguments.length,i=1;i<e;i++)n.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(e=n.length,i=0;i<e;i++){var s,o,h=n[i];for(o in h)h.hasOwnProperty(o)&&(delete r[o],s=Object.getOwnPropertyDescriptor(h,o),Object.defineProperty(r,o,s))}return r}y.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var n=(t=>{var n=[],e=[],i=t.length-1;if(1==i)n[0]=new d((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),e[0]=new d(2*n[0].x-t[0].x,2*n[0].y-t[0].y);else{for(var r=[],s=1;s<i-1;s++)r[s]=4*t[s].x+2*t[s+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var o=mt(r);for(s=1;s<i-1;++s)r[s]=4*t[s].y+2*t[s+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var h=mt(r);for(s=0;s<i;s++)n.push(new d(o[s],h[s])),e.push(s<i-1?new d(2*t[s+1].x-o[s+1],2*t[s+1].y-h[s+1]):new d((t[i].x+o[i-1])/2,(t[i].y+h[i-1])/2))}return[n,e]})(t),e=[],i=n[0].length,r=0;r<i;r++){var s=new d(n[0][r].x,n[0][r].y),o=new d(n[1][r].x,n[1][r].y);e.push(new y(t[r],s,o,t[r+1]))}return e},y.prototype={type:a.Curve,bbox:function(){for(var t,n,e,i,r,s=this.start,o=this.controlPoint1,h=this.controlPoint2,u=this.end,a=s.x,c=s.y,l=o.x,f=o.y,d=h.x,g=h.y,p=u.x,v=u.y,y=new Array,w=new Array,m=[new Array,new Array],x=0;x<2;++x)i=0===x?(n=6*a-12*l+6*d,t=-3*a+9*l-9*d+3*p,3*l-3*a):(n=6*c-12*f+6*g,t=-3*c+9*f-9*g+3*v,3*f-3*c),L(t)<1e-12?L(n)<1e-12||0<(e=-i/n)&&e<1&&w.push(e):(i=n*n-4*i*t,r=pt(i),i<0||(0<(i=(-n+r)/(2*t))&&i<1&&w.push(i),0<(i=(-n-r)/(2*t))&&i<1&&w.push(i)));for(var b,S,P=w.length,s=P;P--;)e=w[P],m[0][P]=b=(S=1-e)*S*S*a+3*S*S*e*l+3*S*e*e*d+e*e*e*p,m[1][P]=S=S*S*S*c+3*S*S*e*f+3*S*e*e*g+e*e*e*v,y[P]={X:b,Y:S};w[s]=0,w[s+1]=1,y[s]={X:a,Y:c},y[s+1]={X:p,Y:v},m[0][s]=a,m[1][s]=c,m[0][s+1]=p,m[1][s+1]=v,w.length=s+2,m[0].length=s+2,m[1].length=s+2,y.length=s+2;o=vt.apply(null,m[0]),h=vt.apply(null,m[1]),u=yt.apply(null,m[0]),s=yt.apply(null,m[1]);return new A(o,h,u-o,s-h)},clone:function(){return new y(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,n){return this.pointAtT(this.closestPointT(t,n))},closestPointLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,subdivisions:void 0===n.subdivisions?this.getSubdivisions({precision:e}):n.subdivisions};return this.lengthAtT(this.closestPointT(t,e),e)},closestPointNormalizedLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,subdivisions:void 0===n.subdivisions?this.getSubdivisions({precision:e}):n.subdivisions},n=this.closestPointLength(t,e);return!n||0===(t=this.length(e))?0:n/t},closestPointT:function(t,n){for(var e,i,r,s,o,h,u=void 0===(n=n||{}).precision?this.PRECISION:n.precision,a=void 0===n.subdivisions?this.getSubdivisions({precision:u}):n.subdivisions,c=a.length,l=c?1/c:0,f=0;f<c;f++){var d=a[f],g=d.start.distance(t),p=d.end.distance(t),v=g+p;(!h||v<h)&&(i=f*l,r=(f+1)*l,s=g,A=p,o=(e=d).start.distance(d.end),h=v)}for(var y=wt(10,-u);;){var w=s?L(s-A)/s:0,m=A?L(s-A)/A:0;if(w<y||m<y||(!s||s<o*y||(!A||A<o*y)))return s<=A?i:r;var w=e.divide(.5),m=(l/=2,w[0].start.distance(t)),x=w[0].end.distance(t),b=m+x,S=w[1].start.distance(t),P=w[1].end.distance(t),A=b<=S+P?(e=w[0],r-=l,s=m,x):(e=w[1],i+=l,s=S,P)}},closestPointTangent:function(t,n){return this.tangentAtT(this.closestPointT(t,n))},containsPoint:function(t,n){return this.toPolyline(n).containsPoint(t)},divideAt:function(t,n){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,n),this.divideAtT(t))},divideAtLength:function(t,n){t=this.tAtLength(t,n);return this.divideAtT(t)},divideAtT:function(t){var n,e,i=this.start,r=this.controlPoint1,s=this.controlPoint2,o=this.end;return t<=0?[new y(i,i,i,i),new y(i,r,s,o)]:1<=t?[new y(i,r,s,o),new y(o,o,o,o)]:(s=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,n=r.divider,e=r.dividerControlPoint1,r=r.dividerControlPoint2,[new y(i,s,t,n),new y(n,e,r,o)])},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var n=this.start,e=this.controlPoint1,i=this.controlPoint2,r=this.end;return t<=0?{startControlPoint1:n.clone(),startControlPoint2:n.clone(),divider:n.clone(),dividerControlPoint1:e.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:e.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(n=new g(n,e).pointAt(t),e=new g(e,i).pointAt(t),i=new g(i,r).pointAt(t),r=new g(n,e).pointAt(t),e=new g(e,i).pointAt(t),{startControlPoint1:n,startControlPoint2:r,divider:new g(r,e).pointAt(t),dividerControlPoint1:e,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,e=this.controlPoint1,i=this.controlPoint2,r=this.end,s=[new y(n,e,i,r)];if(0===t)return s;if(!this.isDifferentiable())return s;for(var o=this.endpointDistance(),h=wt(10,-t),u=2,a=(0===e.cross(n,r)&&0===i.cross(n,r)&&(u=2*t),0);;){a+=1;for(var c=[],l=s.length,f=0;f<l;f++){var d=s[f].divide(.5);c.push(d[0],d[1])}for(var g=0,p=c.length,v=0;v<p;v++)g+=c[v].endpointDistance();if(u<=a)if((0!==g?(g-o)/g:0)<h)return c;s=c,o=g}},isDifferentiable:function(){var t=this.start,n=this.controlPoint1,e=this.controlPoint2,i=this.end;return!(t.equals(n)&&n.equals(e)&&e.equals(i))},length:function(t){for(var n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=void 0===t.subdivisions?this.getSubdivisions({precision:n}):t.subdivisions,i=0,r=e.length,s=0;s<r;s++)i+=e[s].endpointDistance();return i},lengthAtT:function(t,n){return t<=0?0:(n=void 0===(n=n||{}).precision?this.PRECISION:n.precision,this.divide(t)[0].length({precision:n}))},pointAt:function(t,n){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,n),this.pointAtT(t))},pointAtLength:function(t,n){t=this.tAtLength(t,n);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,n,e){return this.start.scale(t,n,e),this.controlPoint1.scale(t,n,e),this.controlPoint2.scale(t,n,e),this.end.scale(t,n,e),this},tangentAt:function(t,n){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);t=this.tAt(t,n);return this.tangentAtT(t)},tangentAtLength:function(t,n){return this.isDifferentiable()?(t=this.tAtLength(t,n),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),n=t.startControlPoint2,e=t.dividerControlPoint1,t=t.divider,e=new g(n,e);return e.translate(t.x-n.x,t.y-n.y),e},tAt:function(t,n){var e;return t<=0?0:1<=t?1:(e={precision:e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,subdivisions:void 0===n.subdivisions?this.getSubdivisions({precision:e}):n.subdivisions},n=this.length(e),this.tAtLength(n*t,e))},tAtLength:function(t,n){for(var e,i,r,s=!0,o=(t<0&&(s=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),h=void 0===n.subdivisions?this.getSubdivisions({precision:o}):n.subdivisions,n={precision:o,subdivisions:h},u=0,a=h.length,c=1/a,l=0;l<a;l++){var f=s?l:a-1-l,d=h[l],g=d.endpointDistance();if(t<=u+g){e=d,i=f*c,r=(f+1)*c,b=s?t-u:g+u-t,S=s?g+u-t:t-u;break}u+=g}if(!e)return s?1:0;for(var p=this.length(n),v=wt(10,-o);;){var y,w=0!==p?b/p:0;if(w<v)return i;if((0!==p?S/p:0)<v)return r;var w=e.divide(.5),m=(c/=2,w[0].endpointDistance()),x=w[1].endpointDistance(),w=b<=m?(e=w[0],r-=c,m-(y=b)):(e=w[1],i+=c,x-(y=b-m)),b=y,S=w}},toPoints:function(t){for(var n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=void 0===t.subdivisions?this.getSubdivisions({precision:n}):t.subdivisions,i=[e[0].start.clone()],r=e.length,s=0;s<r;s++){var o=e[s];i.push(o.end.clone())}return i},toPolyline:function(t){return new v(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,n){return this.start.translate(t,n),this.controlPoint1.translate(t,n),this.controlPoint2.translate(t,n),this.end.translate(t,n),this}},y.prototype.divide=y.prototype.divideAtT;function S(t){if(!(this instanceof S))return new S(t);if("string"==typeof t)return new S.parse(t);var n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce(function(t,n){return t.concat(n)},[])).length,t[0].isSegment)for(r=0;r<n;r++){var e=t[r];this.appendSegment(e)}else for(var i=null,r=0;r<n;r++){var s=t[r];if(!(s instanceof g||s instanceof y))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(S.createSegment("M",s.start)),i&&!i.end.equals(s.start)&&this.appendSegment(S.createSegment("M",s.start)),s instanceof g?this.appendSegment(S.createSegment("L",s.end)):s instanceof y&&this.appendSegment(S.createSegment("C",s.controlPoint1,s.controlPoint2,s.end)),i=s}else if(t.isSegment)this.appendSegment(t);else if(t instanceof g)this.appendSegment(S.createSegment("M",t.start)),this.appendSegment(S.createSegment("L",t.end));else if(t instanceof y)this.appendSegment(S.createSegment("M",t.start)),this.appendSegment(S.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof v))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(n=t.points.length,r=0;r<n;r++){var o=t.points[r];0===r?this.appendSegment(S.createSegment("M",o)):this.appendSegment(S.createSegment("L",o))}}}function w(t,n){return n.unshift(null),new(Function.prototype.bind.apply(t,n))}S.parse=function(t){if(!t)return new S;for(var n=new S,e=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=e.length,r=0;r<i;r++){var s=e[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),s=S.createSegment.apply(this,s);n.appendSegment(s)}return n},S.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var n=S.segmentTypes[t];if(!n)throw new Error(t+" is not a recognized path segment type.");for(var e=[],i=arguments.length,r=1;r<i;r++)e.push(arguments[r]);return w(n,e)},S.prototype={type:a.Path,appendSegment:function(t){var n=this.segments,e=n.length,i=0!==e?n[e-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,n){return t.concat(n)},[]))[0].isSegment)throw new Error("Segments required.");for(var r=t.length,s=0;s<r;s++){var o=t[s],h=this.prepareSegment(o,i,null);n.push(h),i=h}}else{if(!t||!t.isSegment)throw new Error("Segment required.");h=this.prepareSegment(t,i,null),n.push(h)}},bbox:function(){var t=this.segments,n=t.length;if(0===n)return null;for(var e,i=0;i<n;i++){var r,s=t[i];s.isVisible&&(s=s.bbox(),r=r?r.union(s):s)}return r||(e=t[n-1],new A(e.end.x,e.end.y,0,0))},clone:function(){for(var t=this.segments,n=t.length,e=new S,i=0;i<n;i++){var r=t[i].clone();e.appendSegment(r)}return e},closestPoint:function(t,n){t=this.closestPointT(t,n);return t?this.pointAtT(t):null},closestPointLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.closestPointT(t,e);return n?this.lengthAtT(n,e):0},closestPointNormalizedLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.closestPointLength(t,e);return 0===n||0===(t=this.length(e))?0:n/t},closestPointT:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r,s=void 0===(n=n||{}).precision?this.PRECISION:n.precision,o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=1/0,u=0;u<i;u++){var a=e[u],c=o[u];a.isVisible&&(c=a.closestPointT(t,{precision:s,subdivisions:c}),a=a.pointAtT(c),(a=new g(a,t).squaredLength())<h)&&(r={segmentIndex:u,value:c},h=a)}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r,s=void 0===(n=n||{}).precision?this.PRECISION:n.precision,o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=1/0,u=0;u<i;u++){var a,c=e[u],l=o[u];c.isDifferentiable()&&(l=c.closestPointT(t,{precision:s,subdivisions:l}),a=c.pointAtT(l),(a=new g(a,t).squaredLength())<h)&&(r=c.tangentAtT(l),h=a)}return r||null},containsPoint:function(t,n){var e=this.toPolylines(n);if(!e)return!1;for(var i=e.length,r=0,s=0;s<i;s++)e[s].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,n){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e);return this.divideAtLength(n*t,e)},divideAtLength:function(t,n){var e=this.segments.length;if(0===e)return null;for(var i,r,s,o,h=!0,u=(t<0&&(h=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),a=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:u}):n.segmentSubdivisions,c=0,l=0;l<e;l++){var f=h?l:e-1-l,d=this.getSegment(f),g=a[f],p=d.length({precision:u,subdivisions:g});if(d.isDifferentiable()&&(s=d,o=f,t<=c+p)){r=f,i=d.divideAtLength((h?1:-1)*(t-c),{precision:u,subdivisions:g});break}c+=p}if(!s)return null;i||(r=o,i=s.divideAtT(h?1:0));var v=this.clone(),n=(v.replaceSegment(r,i),r),y=r+1,w=r+2,m=(i[0].isDifferentiable()||(v.removeSegment(n),--y,--w),v.getSegment(y).start),x=(v.insertSegment(y,S.createSegment("M",m)),w+=1,i[1].isDifferentiable()||(v.removeSegment(w-1),--w),w-n-1);for(l=w;l<v.segments.length;l++){var b=this.getSegment(l-x);"Z"!==(d=v.getSegment(l)).type||b.subpathStartSegment.end.equals(d.subpathStartSegment.end)||(b=S.createSegment("L",b.end),v.replaceSegment(l,b))}return[new S(v.segments.slice(0,y)),new S(v.segments.slice(y))]},equals:function(t){if(!t)return!1;var n=this.segments,e=t.segments,i=n.length;if(e.length!==i)return!1;for(var r=0;r<i;r++){var s=n[r],o=e[r];if(s.type!==o.type||!s.equals(o))return!1}return!0},getSegment:function(t){var n=this.segments,e=n.length;if(0===e)throw new Error("Path has no segments.");if(e<=(t=t<0?e+t:t)||t<0)throw new Error("Index out of range.");return n[t]},getSegmentSubdivisions:function(t){for(var n=this.segments,e=n.length,i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],s=0;s<e;s++){var o=n[s].getSubdivisions({precision:i});r.push(o)}return r},getSubpaths:function(){var n=this.clone().validate().segments,e=n.length,i=[];for(let t=0;t<e;t++){var r=n[t];r.isSubpathStart?i.push(new S(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,n){var e=this.segments,i=e.length;if(i<(t=t<0?i+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,s=null;if(0!==i&&(s=1<=t?(r=e[t-1]).nextSegment:e[0]),Array.isArray(n)){if(!(n=n.reduce(function(t,n){return t.concat(n)},[]))[0].isSegment)throw new Error("Segments required.");for(var o=n.length,h=0;h<o;h++){var u=n[h],a=this.prepareSegment(u,r,s);e.splice(t+h,0,a),r=a}}else{if(!n||!n.isSegment)throw new Error("Segment required.");a=this.prepareSegment(n,r,s),e.splice(t,0,a)}},intersectionWithLine:function(t,n){var e=null,i=this.toPolylines(n);if(!i)return null;for(var r=0,s=i.length;r<s;r++){var o=i[r],o=t.intersect(o);o&&(e=e||[],Array.isArray(o)?Array.prototype.push.apply(e,o):e.push(o))}return e},isDifferentiable:function(){for(var t=this.segments,n=t.length,e=0;e<n;e++)if(t[e].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var n=this.segments,e=n.length;if(0===e)return 0;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,s=0,o=0;o<e;o++){var h=n[o],u=r[o];s+=h.length({subdivisions:u})}return s},lengthAtT:function(t,n){var e=this.segments,i=e.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;for(var t=t.value,s=(i<=r?(r=i-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(n=n||{}).precision?this.PRECISION:n.precision),o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=0,u=0;u<r;u++){var a=e[u],c=o[u];h+=a.length({precisison:s,subdivisions:c})}return c=o[r],h+=(a=e[r]).lengthAtT(t,{precisison:s,subdivisions:c})},pointAt:function(t,n){var e;return 0===this.segments.length?null:t<=0?this.start.clone():1<=t?this.end.clone():(e={precision:e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e),this.pointAtLength(n*t,e))},pointAtLength:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;if(0===t)return this.start.clone();for(var r,s=!0,o=(t<0&&(s=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),h=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):n.segmentSubdivisions,u=0,a=0;a<i;a++){var c=s?a:i-1-a,l=e[c],c=h[c],f=l.length({precision:o,subdivisions:c});if(l.isVisible){if(t<=u+f)return l.pointAtLength((s?1:-1)*(t-u),{precision:o,subdivisions:c});r=l}u+=f}return r?s?r.end:r.start:e[i-1].end.clone()},pointAtT:function(t){var n,e=this.segments,i=e.length;return 0===i?null:(n=t.segmentIndex)<0?e[0].pointAtT(0):i<=n?e[i-1].pointAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),e[n].pointAtT(i))},PRECISION:3,prepareSegment:function(t,n,e){t.previousSegment=n,t.nextSegment=e,n&&(n.nextSegment=t),e&&(e.previousSegment=t);n=t;return t.isSubpathStart&&(t.subpathStartSegment=t,n=e),n&&this.updateSubpathStartSegment(n),t},removeSegment:function(t){var n=this.segments,e=n.length;if(0===e)throw new Error("Path has no segments.");if(e<=(t=t<0?e+t:t)||t<0)throw new Error("Index out of range.");e=n.splice(t,1)[0],n=e.previousSegment,t=e.nextSegment;n&&(n.nextSegment=t),t&&(t.previousSegment=n),e.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,n){var e=this.segments,i=e.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");var i=e[t],r=i.previousSegment,s=i.nextSegment,o=i.isSubpathStart;if(Array.isArray(n)){if(!(n=n.reduce(function(t,n){return t.concat(n)},[]))[0].isSegment)throw new Error("Segments required.");e.splice(t,1);for(var h=n.length,u=0;u<h;u++){var a=n[u],c=this.prepareSegment(a,r,s);e.splice(t+u,0,c),r=c,o&&c.isSubpathStart&&(o=!1)}}else{if(!n||!n.isSegment)throw new Error("Segment required.");c=this.prepareSegment(n,r,s),e.splice(t,1,c),o&&c.isSubpathStart&&(o=!1)}o&&s&&this.updateSubpathStartSegment(s)},round:function(t){for(var n=this.segments,e=n.length,i=0;i<e;i++)n[i].round(t);return this},scale:function(t,n,e){for(var i=this.segments,r=i.length,s=0;s<r;s++)i[s].scale(t,n,e);return this},segmentAt:function(t,n){t=this.segmentIndexAt(t,n);return t?this.getSegment(t):null},segmentAtLength:function(t,n){t=this.segmentIndexAtLength(t,n);return t?this.getSegment(t):null},segmentIndexAt:function(t,n){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e);return this.segmentIndexAtLength(n*t,e)},segmentIndexAtLength:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r=!0,s=(t<0&&(r=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=null,u=0,a=0;a<i;a++){var c=r?a:i-1-a,l=e[c],f=o[c],f=l.length({precision:s,subdivisions:f});if(l.isVisible){if(t<=u+f)return c;h=c}u+=f}return h},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,n){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e);return this.tangentAtLength(n*t,e)},tangentAtLength:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r,s=!0,o=(t<0&&(s=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),h=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):n.segmentSubdivisions,u=0,a=0;a<i;a++){var c=s?a:i-1-a,l=e[c],c=h[c],f=l.length({precision:o,subdivisions:c});if(l.isDifferentiable()){if(t<=u+f)return l.tangentAtLength((s?1:-1)*(t-u),{precision:o,subdivisions:c});r=l}u+=f}return r?r.tangentAtT(s?1:0):null},tangentAtT:function(t){var n,e=this.segments,i=e.length;return 0===i?null:(n=t.segmentIndex)<0?e[0].tangentAtT(0):i<=n?e[i-1].tangentAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),e[n].tangentAtT(i))},toPoints:function(t){var n=this.segments,e=n.length;if(0===e)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,s=[],o=[],h=0;h<e;h++){var u,a=n[h];a.isVisible?0<(u=r[h]).length?(u=u.map(function(t){return t.start}),Array.prototype.push.apply(o,u)):o.push(a.start):0<o.length&&(o.push(n[h-1].end),s.push(o),o=[])}return 0<o.length&&(o.push(this.end),s.push(o)),s},toPolylines:function(t){var n=[],e=this.toPoints(t);if(!e)return null;for(var i=0,r=e.length;i<r;i++)n.push(new v(e[i]));return n},toString:function(){for(var t=this.segments,n=t.length,e="",i=0;i<n;i++)e+=t[i].serialize()+" ";return e.trim()},translate:function(t,n){for(var e=this.segments,i=e.length,r=0;r<i;r++)e[r].translate(t,n);return this},updateSubpathStartSegment:function(t){for(var n=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=n?n.subpathStartSegment:null,t=(n=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,S.createSegment("M",0,0)),this}},Object.defineProperty(S.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,n=t.length;if(0===n)return null;for(var e=0;e<n;e++){var i=t[e];if(i.isVisible)return i.start}return t[n-1].end}}),Object.defineProperty(S.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,n=t.length;if(0===n)return null;for(var e=n-1;0<=e;e--){var i=t[e];if(i.isVisible)return i.end}return t[n-1].end}});function m(){for(var t=[],n=arguments.length,e=0;e<n;e++)t.push(arguments[e]);if(!(this instanceof m))return w(m,t);if(0===n)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(t[0]instanceof g){if(1===n)return this.end=t[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+n+" lines provided).")}if("string"==typeof t[0]||"number"==typeof t[0]){if(2===n)return this.end=new d(+t[0],+t[1]),this;if(n<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var i,r=[],e=0;e<n;e+=2)i=t.slice(e,e+2),r.push(w(m,i))}else{if(1===n)return this.end=new d(t[0]),this;for(r=[],e=0;e<n;e+=1)r.push(new m(t[e]))}return r}function x(){for(var t,n=[],e=arguments.length,i=0;i<e;i++)n.push(arguments[i]);if(!(this instanceof x))return w(x,n);if(0===e)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(n[0]instanceof y){if(1===e)return this.controlPoint1=n[0].controlPoint1.clone(),this.controlPoint2=n[0].controlPoint2.clone(),this.end=n[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+e+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(6===e)return this.controlPoint1=new d(+n[0],+n[1]),this.controlPoint2=new d(+n[2],+n[3]),this.end=new d(+n[4],+n[5]),this;if(e<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+e+" coordinates provided).");for(var r,s=[],i=0;i<e;i+=6)r=n.slice(i,i+6),s.push(w(x,r))}else{if(3===e)return this.controlPoint1=new d(n[0]),this.controlPoint2=new d(n[1]),this.end=new d(n[2]),this;if(e<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+e+" points provided).");for(s=[],i=0;i<e;i+=3)t=n.slice(i,i+3),s.push(w(x,t))}return s}function b(){for(var t,n=[],e=arguments.length,i=0;i<e;i++)n.push(arguments[i]);if(!(this instanceof b))return w(b,n);if(0===e)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof g){if(1===e)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+e+" lines provided).")}if(n[0]instanceof y){if(1===e)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+e+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===e)return this.end=new d(+n[0],+n[1]),this;if(e<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+e+" coordinates provided).");for(var r,s=[],i=0;i<e;i+=2)r=n.slice(i,i+2),0===i?s.push(w(b,r)):s.push(w(m,r))}else{if(1===e)return this.end=new d(n[0]),this;for(s=[],i=0;i<e;i+=1)t=n[i],0===i?s.push(new b(t)):s.push(new m(t))}return s}function P(){for(var t=[],n=arguments.length,e=0;e<n;e++)t.push(arguments[e]);if(!(this instanceof P))return w(P,t);if(0<n)throw new Error("Closepath constructor expects no arguments.");return this}var E={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){var n;return t<=0?0:(n=this.length(),1<=t?n:n*t)},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}},T=(Object.defineProperty(E,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(E,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)")}}),Object.defineProperty(E,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),{clone:function(){return new m(this.end)},divideAt:function(t){t=new g(this.start,this.end).divideAt(t);return[new m(t[0]),new m(t[1])]},divideAtLength:function(t){t=new g(this.start,this.end).divideAtLength(t);return[new m(t[0]),new m(t[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,n,e){return this.end.scale(t,n,e),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,n){return this.end.translate(t,n),this}}),T=(Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"L"}),m.prototype=n(E,g.prototype,T),{clone:function(){return new x(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,n){t=new y(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,n);return[new x(t[0]),new x(t[1])]},divideAtLength:function(t,n){t=new y(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,n);return[new x(t[0]),new x(t[1])]},divideAtT:function(t){t=new y(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new x(t[0]),new x(t[1])]},isDifferentiable:function(){var t,n,e,i;return!(!this.previousSegment||(t=this.start,n=this.controlPoint1,e=this.controlPoint2,i=this.end,t.equals(n)&&n.equals(e)&&e.equals(i)))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,n,e){return this.controlPoint1.scale(t,n,e),this.controlPoint2.scale(t,n,e),this.end.scale(t,n,e),this},serialize:function(){var t=this.controlPoint1,n=this.controlPoint2,e=this.end;return this.type+" "+t.x+" "+t.y+" "+n.x+" "+n.y+" "+e.x+" "+e.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,n){return this.controlPoint1.translate(t,n),this.controlPoint2.translate(t,n),this.end.translate(t,n),this}}),T=(Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"C"}),x.prototype=n(E,y.prototype,T),{bbox:function(){return null},clone:function(){return new b(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,n,e){return this.end.scale(t,n,e),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,n){return this.end.translate(t,n),this}}),T=(Object.defineProperty(T,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"M"}),b.prototype=n(E,T),{clone:function(){return new P},divideAt:function(t){t=new g(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new m(t[0]):this.clone(),new m(t[1])]},divideAtLength:function(t){t=new g(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new m(t[0]):this.clone(),new m(t[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment||this.start.equals(this.end))},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}}),E=(Object.defineProperty(T,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)")}}),Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"Z"}),P.prototype=n(E,g.prototype,T),S.segmentTypes={L:m,C:x,M:b,Z:P,z:P}),T=(S.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(E).join("")+",.]*$"),S.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},{curveThroughPoints:function(t){return console.warn("deprecated"),new S(y.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var n=[],e=[],i=t.length-1;if(1==i)n[0]=new d((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),e[0]=new d(2*n[0].x-t[0].x,2*n[0].y-t[0].y);else{for(var r=[],s=1;s<i-1;s++)r[s]=4*t[s].x+2*t[s+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var o=this.getFirstControlPoints(r);for(s=1;s<i-1;++s)r[s]=4*t[s].y+2*t[s+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var h=this.getFirstControlPoints(r);for(s=0;s<i;s++)n.push(new d(o[s],h[s])),e.push(s<i-1?new d(2*t[s+1].x-o[s+1],2*t[s+1].y-h[s+1]):new d((t[i].x+o[i-1])/2,(t[i].y+h[i-1])/2))}return[n,e]},getCurveDivider:function(t,n,e,i){console.warn("deprecated");var r=new y(t,n,e,i);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var n=t.length,e=[],i=[],r=2;e[0]=t[0]/r;for(var s=1;s<n;s++)i[s]=1/r,e[s]=(t[s]-e[s-1])/(r=(s<n-1?4:3.5)-i[s]);for(s=1;s<n;s++)e[n-s-1]-=i[n-s]*e[n-s];return e},getInversionSolver:function(t,n,e,i){console.warn("deprecated");var r=new y(t,n,e,i);return function(t){return r.closestPointT(t)}}});let I=function(t){return this instanceof I?"string"==typeof t?new I.parse(t):void(this.points=Array.isArray(t)?t.map(d):[]):new I(t)};function C(t,n){var e=t.start.x,i=t.start.y,r=t.end.x,t=t.end.y,s=n.start.x,o=n.start.y,r=r-e,t=t-i,h=n.end.x-s,n=n.end.y-o,e=e-s,s=i-o,i=r*n-h*t,o=(r*s-t*e)/i,r=(h*s-n*e)/i;return 0<=o&&o<=1&&0<=r&&r<=1}function xt(t,n){var e=t.a,i=t.b,r=t.x,t=t.y,s=n.start.x-r,r=n.end.x-r,o=n.start.y-t,e=e*e,i=i*i,r=r-s,n=n.end.y-t-o,t=r*r/e+n*n/i,r=2*s*r/e+2*o*n/i,n=r*r-4*t*(s*s/e+o*o/i-1);return 0==n?0<=(s=-r/2/t)&&s<=1:0<n&&(o=(-r-(e=Math.sqrt(n)))/2/t,0<=(i=(-r+e)/2/t)&&i<=1||0<=o&&o<=1)}function bt(I,C){{var R=0,D=0;let{cos:t,sin:n}=Math,e=n(R),i=t(R),r=n(D),s=t(D),o=e*e,h=i*i,u=e*i,a=r*r,c=s*s,l=r*s,f=I.a*I.a,d=I.b*I.b,g=C.a*C.a,p=C.b*C.b,v=f*o+d*h,y=g*a+p*c,w=f*h+d*o,m=g*c+p*a,x=2*(d-f)*u,b=2*(p-g)*l,S=-2*v*I.x-x*I.y,P=-2*y*C.x-b*C.y,A=-x*I.x-2*w*I.y,L=-b*C.x-2*m*C.y,E=v*I.x*I.x+w*I.y*I.y+x*I.x*I.y-f*d,T=y*C.x*C.x+m*C.y*C.y+b*C.x*C.y-g*p;x/=2,b/=2,S/=2,P/=2,A/=2,L/=2;var R=z([[v,x,S],[x,w,A],[S,A,E]]),D=z([[y,b,P],[b,m,L],[P,L,T]]),I=.33333333*(z([[y,x,S],[b,w,A],[P,A,E]])+z([[v,b,S],[x,m,A],[S,L,E]])+z([[v,x,P],[x,w,L],[S,A,T]])),C=.33333333*(z([[v,b,P],[x,m,L],[S,L,T]])+z([[y,x,P],[b,w,L],[P,A,T]])+z([[y,b,S],[b,m,A],[P,L,E]])),O=q([[R,I],[I,C]]),R=q([[R,C],[I,D]]),D=q([[I,C],[C,D]]);return!(0<(O=q([[2*O,R],[R,2*D]]))&&(0<C||0<I))}}function St(t,n){var{start:e,end:i}=n,{x:r,y:s,width:o,height:h}=t;return!(e.x>r+o&&i.x>r+o||e.x<r&&i.x<r||e.y>s+h&&i.y>s+h||e.y<s&&i.y<s)&&(!(!t.containsPoint(n.start)&&!t.containsPoint(n.end))||C(t.topLine(),n)||C(t.rightLine(),n)||C(t.bottomLine(),n)||C(t.leftLine(),n))}function Pt(t,n){return!!At(t,A.fromEllipse(n))&&D(I.fromRect(t),n)}function At(t,n){return t.x<n.x+n.width&&t.x+t.width>n.x&&t.y<n.y+n.height&&t.y+t.height>n.y}function R(t,n){return Wt(t,n,{interior:!1})}function Lt(t,n){return jt(t,n,{interior:!1})}function Et(t,n){return kt(t,n,{interior:!1})}function Tt(t,n){return N(t,n,{interior:!1})}function It(t,n){return Wt(t,n,{interior:!0})}function D(t,n){return jt(t,n,{interior:!0})}function Ct(t,n){return kt(t,n,{interior:!0})}function Rt(t,n){return N(t,n,{interior:!0})}function Dt(t,n){return Ft(t,n,{interior:!0})}function Ot(t,e,i){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?It:R)(n,e)})}function Nt(t,e,i){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?D:Lt)(n,e)})}function qt(t,n,e){return O(t,I.fromRect(n),e)}function zt(t,n,e){return Vt(t,n,e,{interior:!1})}function O(t,n,e){return Vt(t,n,e,{interior:!0})}function Mt(t,e,i,r){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?O:zt)(e,n,r)})}function Wt(t,n,e){var{interior:e=!1}=2<arguments.length&&void 0!==e?e:{};let i;if(e){if(t.containsPoint(n.start))return!0;var{start:e,end:r,points:s}=t;i=r.equals(e)?s:[...s,e]}else i=t.points;var o=i.length,h=new g;for(let t=0;t<o-1;t++)if(h.start=i[t],h.end=i[t+1],C(n,h))return!0;return!1}function jt(t,n,e){var e=2<arguments.length&&void 0!==e?e:{},{start:i,end:r,points:s}=t;if(n.containsPoint(i))return!0;let o;var{interior:e=!1}=e;if(e){if(t.containsPoint(n.center()))return!0;o=r.equals(i)?s:[...s,i]}else o=s;var h=o.length,u=new g;for(let t=0;t<h-1;t++)if(u.start=o[t],u.end=o[t+1],xt(n,u))return!0;return!1}function kt(t,n,e){return Ft(t,I.fromRect(n),e)}function Vt(t,e,i,r){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ft:N)(e,n,r)})}function N(t,n,e){var{interior:e=!1}=2<arguments.length&&void 0!==e?e:{};let i;if(e){e=n.start;if(t.containsPoint(e))return!0;i=t.clone().close()}else i=t;var r=n.points,s=r.length,o=new g;for(let t=0;t<s-1;t++)if(o.start=r[t],o.end=r[t+1],R(i,o))return!0;return!1}function Ft(t,n,e){return n.containsPoint(t.start)||N(t,n.clone().close(),e)}function q(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function z(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}I.parse=function(t){return new I(ft(t))},I.fromRect=function(t){return new I([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},I.prototype=n(v.prototype,{type:a.Polygon,clone:function(){return new I(dt(this.points))},convexHull:function(){return new I(gt(this.points))},lengthPoints:function(){var{start:t,end:n,points:e}=this;return e.length<=1||t.equals(n)?e:[...e,t.clone()]}});E={exists:function t(n,e,i,r){switch(n.type){case a.Line:if(e.type===a.Line)return C(n,e);break;case a.Ellipse:switch(e.type){case a.Line:return xt(n,e);case a.Ellipse:return bt(n,e)}break;case a.Rect:switch(e.type){case a.Line:return St(n,e);case a.Ellipse:return Pt(n,e);case a.Rect:return At(n,e)}break;case a.Polyline:switch(e.type){case a.Line:return R(n,e);case a.Ellipse:return Lt(n,e);case a.Rect:return Et(n,e);case a.Polyline:return Tt(n,e)}break;case a.Polygon:switch(e.type){case a.Line:return It(n,e);case a.Ellipse:return D(n,e);case a.Rect:return Ct(n,e);case a.Polyline:return Rt(n,e);case a.Polygon:return Dt(n,e)}break;case a.Path:switch(e.type){case a.Line:return Ot(n,e,i);case a.Ellipse:return Nt(n,e,i);case a.Rect:return qt(n,e,i);case a.Polyline:return zt(n,e,i);case a.Polygon:return O(n,e,i);case a.Path:return Mt(n,e,i,r)}}switch(e.type){case a.Ellipse:case a.Rect:case a.Polyline:case a.Polygon:case a.Path:return t(e,n,r,i);default:throw Error(`The intersection for ${n} and ${e} could not be found.`)}},lineWithLine:C,ellipseWithLine:xt,ellipseWithEllipse:bt,rectWithLine:St,rectWithEllipse:Pt,rectWithRect:At,polylineWithLine:R,polylineWithEllipse:Lt,polylineWithRect:Et,polylineWithPolyline:Tt,polygonWithLine:It,polygonWithEllipse:D,polygonWithRect:Ct,polygonWithPolyline:Rt,polygonWithPolygon:Dt,pathWithLine:Ot,pathWithEllipse:Nt,pathWithRect:qt,pathWithPolyline:zt,pathWithPolygon:O,pathWithPath:Mt};t.Curve=y,t.Ellipse=i,t.Line=g,t.Path=S,t.Point=d,t.Polygon=I,t.Polyline=v,t.Rect=A,t.bezier=T,t.ellipse=st,t.intersection=E,t.line=et,t.normalizeAngle=r,t.point=Q,t.random=h,t.rect=lt,t.scale={linear:function(t,n,e){var i=t[1]-t[0],r=n[1]-n[0];return(e-t[0])/i*r+n[0]||0}},t.snapToGrid=e,t.toDeg=s,t.toRad=o,t.types=a,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
8
|
+
((t,n)=>{"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).g={})})(this,function(t){let{round:M,floor:W,PI:j}=Math;function r(t){return t%360+(t<0?360:0)}function e(t,n){return n*M(t/n)}function s(t){return 180*t/j%360}function o(t,n){return(t=(n=n||!1)?t:t%360)*j/180}function h(t,n){var e;return void 0===n?(n=void 0===t?1:t,t=0):n<t&&(e=t,t=n,n=e),W(Math.random()*(n-t+1)+t)}function k(t,n){var e=o(t.y),i=o(n.y),t=t.x,n=n.x,n=o(n-t),t=Z(n)*u(i),e=u(e)*Z(i)-Z(e)*u(i)*u(n);return(i=s(B(t,e))-22.5)<0&&(i+=360),["NE","E","SE","S","SW","W","NW","N"][i=parseInt(i/45)]}function V(t,n){var e=t.x,t=t.y;return(e-=n.x)*e+(t-=n.y)*t}function F(t,n){return Math.sqrt(V(t,n))}function d(t,n){if(!(this instanceof d))return new d(t,n);var e;"string"==typeof t?(e=t.split(-1===t.indexOf("@")?" ":"@"),t=parseFloat(e[0]),n=parseFloat(e[1])):Object(t)===t&&(n=t.y,t=t.x),this.x=void 0===t?0:t,this.y=void 0===n?0:n}let{cos:u,sin:Z,atan2:B}=Math,a={Point:1,Line:2,Ellipse:3,Rect:4,Polyline:5,Polygon:6,Curve:7,Path:8},{abs:c,cos:G,sin:U,sqrt:_,min:X,max:Y,atan2:$,round:H,pow:J,PI:K}=Math;d.fromPolar=function(t,n,e){e=new d(e);var i=c(t*G(n)),t=c(t*U(n)),n=r(s(n));return n<90?t=-t:n<180?(i=-i,t=-t):n<270&&(i=-i),new d(e.x+i,e.y+t)},d.random=function(t,n,e,i){return new d(h(t,n),h(e,i))},d.prototype={type:a.Point,chooseClosest:function(t){var n=t.length;if(1===n)return new d(t[0]);for(var e=null,i=1/0,r=0;r<n;r++){var s=new d(t[r]),o=this.squaredDistance(s);o<i&&(e=s,i=o)}return e},adhereToRect:function(t){return t.containsPoint(this)||(this.x=X(Y(this.x,t.x),t.x+t.width),this.y=X(Y(this.y,t.y),t.y+t.height)),this},angleBetween:function(t,n){n=this.equals(t)||this.equals(n)?NaN:this.theta(n)-this.theta(t);return n<0&&(n+=360),n},bearing:function(t){return k(this,t)},changeInAngle:function(t,n,e){return this.clone().offset(-t,-n).theta(e)-this.theta(e)},clone:function(){return new d(this)},cross:function(t,n){return t&&n?(n.x-this.x)*(t.y-this.y)-(n.y-this.y)*(t.x-this.x):NaN},difference:function(t,n){return Object(t)===t&&(n=t.y,t=t.x),new d(this.x-(t||0),this.y-(n||0))},distance:function(t){return F(this,t)},dot:function(t){return t?this.x*t.x+this.y*t.y:NaN},equals:function(t){return!!t&&this.x===t.x&&this.y===t.y},lerp:function(t,n){var e=this.x,i=this.y;return new d((1-n)*e+n*t.x,(1-n)*i+n*t.y)},magnitude:function(){return _(this.x*this.x+this.y*this.y)||.01},manhattanDistance:function(t){return c(t.x-this.x)+c(t.y-this.y)},move:function(t,n){t=o(new d(t).theta(this));return this.offset(G(t)*n,-U(t)*n)},normalize:function(t){t=(t||1)/this.magnitude();return this.scale(t,t)},offset:function(t,n){return Object(t)===t&&(n=t.y,t=t.x),this.x+=t||0,this.y+=n||0,this},reflection:function(t){return new d(t).move(this,this.distance(t))},rotate:function(t,n){var e,i;return 0!==n&&(t=t||new d(0,0),n=o(r(-n)),e=G(n),n=U(n),i=e*(this.x-t.x)-n*(this.y-t.y)+t.x,n=n*(this.x-t.x)+e*(this.y-t.y)+t.y,this.x=i,this.y=n),this},round:function(t){let n=1;if(t)switch(t){case 1:n=10;break;case 2:n=100;break;case 3:n=1e3;break;default:n=J(10,t)}return this.x=H(this.x*n)/n,this.y=H(this.y*n)/n,this},scale:function(t,n,e){return e=e&&new d(e)||new d(0,0),this.x=e.x+t*(this.x-e.x),this.y=e.y+n*(this.y-e.y),this},snapToGrid:function(t,n){return this.x=e(this.x,t),this.y=e(this.y,n||t),this},squaredDistance:function(t){return V(this,t)},theta:function(t){var n=-((t=new d(t)).y-this.y),t=t.x-this.x,n=$(n,t);return 180*(n=n<0?2*K+n:n)/K},toJSON:function(){return{x:this.x,y:this.y}},toPolar:function(t){t=t&&new d(t)||new d(0,0);var n=this.x,e=this.y;return this.x=_((n-t.x)*(n-t.x)+(e-t.y)*(e-t.y)),this.y=o(t.theta(new d(n,e))),this},toString:function(){return this.x+"@"+this.y},serialize:function(){return this.x+","+this.y},update:function(t,n){return Object(t)===t&&(n=t.y,t=t.x),this.x=t||0,this.y=n||0,this},vectorAngle:function(t){return new d(0,0).angleBetween(this,t)}},d.prototype.translate=d.prototype.offset;var Q=d;let{max:tt,min:nt}=Math,g=function(t,n){return this instanceof g?t instanceof g?new g(t.start,t.end):(this.start=new d(t),void(this.end=new d(n))):new g(t,n)};g.prototype={type:a.Line,angle:function(){var t=new d(this.start.x+1,this.start.y);return this.start.angleBetween(this.end,t)},bbox:function(){var t=nt(this.start.x,this.end.x),n=nt(this.start.y,this.end.y),e=tt(this.start.x,this.end.x),i=tt(this.start.y,this.end.y);return new A(t,n,e-t,i-n)},bearing:function(){return k(this.start,this.end)},clone:function(){return new g(this.start,this.end)},closestPoint:function(t){return this.pointAt(this.closestPointNormalizedLength(t))},closestPointLength:function(t){return this.closestPointNormalizedLength(t)*this.length()},closestPointNormalizedLength:function(t){t=this.vector().dot(new g(this.start,t).vector()),t=nt(1,tt(0,t/this.squaredLength()));return t!=t?0:t},closestPointTangent:function(t){return this.tangentAt(this.closestPointNormalizedLength(t))},containsPoint:function(t){var n,e=this.start,i=this.end;return 0===e.cross(t,i)&&(n=this.length(),!(new g(e,t).length()>n||new g(t,i).length()>n))},divideAt:function(t){t=this.pointAt(t);return[new g(this.start,t),new g(t,this.end)]},divideAtLength:function(t){t=this.pointAtLength(t);return[new g(this.start,t),new g(t,this.end)]},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.end.x===t.end.x&&this.end.y===t.end.y},intersect:function(t,n){return t&&t.intersectionWithLine?(n=t.intersectionWithLine(this,n))&&t instanceof g?n[0]:n:null},intersectionWithLine:function(t){var n=new d(this.end.x-this.start.x,this.end.y-this.start.y),e=new d(t.end.x-t.start.x,t.end.y-t.start.y),i=n.x*e.y-n.y*e.x,t=new d(t.start.x-this.start.x,t.start.y-this.start.y),e=t.x*e.y-t.y*e.x,t=t.x*n.y-t.y*n.x;if(0==i||e*i<0||t*i<0)return null;if(0<i){if(i<e||i<t)return null}else if(e<i||t<i)return null;return[new d(this.start.x+e*n.x/i,this.start.y+e*n.y/i)]},isDifferentiable:function(){return!this.start.equals(this.end)},length:function(){return F(this.start,this.end)},midpoint:function(){return new d((this.start.x+this.end.x)/2,(this.start.y+this.end.y)/2)},parallel:function(t){var n,e,i,r,s=this.clone();return this.isDifferentiable()&&({start:n,end:e}=s,i=n.clone().rotate(e,270),r=e.clone().rotate(n,90),n.move(r,t),e.move(i,t)),s},pointAt:function(t){var n=this.start,e=this.end;return t<=0?n.clone():1<=t?e.clone():n.lerp(e,t)},pointAtLength:function(t){var n=this.start,e=this.end,i=!0,r=(t<0&&(i=!1,t=-t),this.length());return r<=t?(i?e:n).clone():this.pointAt((i?t:r-t)/r)},pointOffset:function(t){t=new d(t);var n=this.start,e=this.end;return((e.x-n.x)*(t.y-n.y)-(e.y-n.y)*(t.x-n.x))/this.length()},rotate:function(t,n){return this.start.rotate(t,n),this.end.rotate(t,n),this},round:function(t){return this.start.round(t),this.end.round(t),this},scale:function(t,n,e){return this.start.scale(t,n,e),this.end.scale(t,n,e),this},setLength:function(t){var n=this.length();return n?this.scale(t=t/n,t,this.start):this},squaredLength:function(){return V(this.start,this.end)},tangentAt:function(t){var n,e;return this.isDifferentiable()?(n=this.start,e=this.end,t=this.pointAt(t),(e=new g(n,e)).translate(t.x-n.x,t.y-n.y),e):null},tangentAtLength:function(t){var n,e;return this.isDifferentiable()?(n=this.start,e=this.end,t=this.pointAtLength(t),(e=new g(n,e)).translate(t.x-n.x,t.y-n.y),e):null},toString:function(){return this.start.toString()+" "+this.end.toString()},serialize:function(){return this.start.serialize()+" "+this.end.serialize()},translate:function(t,n){return this.start.translate(t,n),this.end.translate(t,n),this},vector:function(){return new d(this.end.x-this.start.x,this.end.y-this.start.y)}},g.prototype.intersection=g.prototype.intersect;var et=g;function i(t,n,e){return this instanceof i?t instanceof i?new i(new d(t.x,t.y),t.a,t.b):(t=new d(t),this.x=t.x,this.y=t.y,this.a=n,void(this.b=e)):new i(t,n,e)}let{sqrt:it,round:l,pow:rt}=Math;i.fromRect=function(t){return t=new A(t),new i(t.center(),t.width/2,t.height/2)},i.prototype={type:a.Ellipse,bbox:function(){return new A(this.x-this.a,this.y-this.b,2*this.a,2*this.b)},center:function(){return new d(this.x,this.y)},clone:function(){return new i(this)},containsPoint:function(t){return this.normalizedDistance(t)<=1},equals:function(t){return!!t&&t.x===this.x&&t.y===this.y&&t.a===this.a&&t.b===this.b},inflate:function(t,n){return void 0===t&&(t=0),void 0===n&&(n=t),this.a+=2*t,this.b+=2*n,this},intersectionWithLine:function(t){var n=[],e=t.start,i=t.end,r=this.a,s=this.b,t=t.vector(),o=e.difference(new d(this)),h=new d(t.x/(r*r),t.y/(s*s)),r=new d(o.x/(r*r),o.y/(s*s)),s=t.dot(h),h=t.dot(r),t=h*h-s*(o.dot(r)-1);if(t<0)return null;if(0<t){o=it(t),r=(-h-o)/s,t=(-h+o)/s;if((r<0||1<r)&&(t<0||1<t))return null;0<=r&&r<=1&&n.push(e.lerp(i,r)),0<=t&&t<=1&&n.push(e.lerp(i,t))}else{o=-h/s;if(!(0<=o&&o<=1))return null;n.push(e.lerp(i,o))}return n},intersectionWithLineFromCenterToPoint:function(t,n){t=new d(t),n&&t.rotate(new d(this.x,this.y),n);var e,i,r,s=t.x-this.x,o=t.y-this.y;return r=0==s?this.bbox().pointNearestToPoint(t):(o=(t=o/s)*t,i=this.a*this.a,e=this.b*this.b,i=it(1/(1/i+o/e)),o=t*(i=s<0?-i:i),new d(this.x+i,this.y+o)),n?r.rotate(new d(this.x,this.y),-n):r},normalizedDistance:function(t){var n=t.x,t=t.y,e=this.a,i=this.b,r=this.x,s=this.y;return(n-r)*(n-r)/(e*e)+(t-s)*(t-s)/(i*i)},round:function(t){let n=1;if(t)switch(t){case 1:n=10;break;case 2:n=100;break;case 3:n=1e3;break;default:n=rt(10,t)}return this.x=l(this.x*n)/n,this.y=l(this.y*n)/n,this.a=l(this.a*n)/n,this.b=l(this.b*n)/n,this},tangentTheta:function(t){var n,e,i=t.x,r=t.y,s=this.a,o=this.b,h=this.bbox().center(),u=h.x,a=h.y;return h.x+s/2<i||i<h.x-s/2?e=s*s/(i-u)-s*s*(r-a)*((n=i>h.x?r-30:r+30)-a)/(o*o*(i-u))+u:n=o*o/(r-a)-o*o*(i-u)*((e=r>h.y?i+30:i-30)-u)/(s*s*(r-a))+a,new d(e,n).theta(t)},toString:function(){return new d(this.x,this.y).toString()+" "+this.a+" "+this.b}};var st=i;let{abs:ot,cos:ht,sin:ut,min:f,max:at,round:p,pow:ct}=Math,A=function(t,n,e,i){if(!(this instanceof A))return new A(t,n,e,i);Object(t)===t&&(n=t.y,e=t.width,i=t.height,t=t.x),this.x=void 0===t?0:t,this.y=void 0===n?0:n,this.width=void 0===e?0:e,this.height=void 0===i?0:i};A.fromEllipse=function(t){return t=new i(t),new A(t.x-t.a,t.y-t.b,2*t.a,2*t.b)},A.fromPointUnion=function(...n){if(0===n.length)return null;var e=new d;let i,r,s,o;i=r=1/0,s=o=-1/0;for(let t=0;t<n.length;t++){e.update(n[t]);var h=e.x,u=e.y;h<i&&(i=h),h>s&&(s=h),u<r&&(r=u),u>o&&(o=u)}return new A(i,r,s-i,o-r)},A.fromRectUnion=function(...n){if(0===n.length)return null;var e=new A;let i,r,s,o;i=r=1/0,s=o=-1/0;for(let t=0;t<n.length;t++){e.update(n[t]);var h=e.x,u=e.y,a=h+e.width,c=u+e.height;h<i&&(i=h),a>s&&(s=a),u<r&&(r=u),c>o&&(o=c)}return new A(i,r,s-i,o-r)},A.prototype={type:a.Rect,bbox:function(t){return this.clone().rotateAroundCenter(t)},rotateAroundCenter:function(t){var n,e,i,r;return t&&({width:i,height:n}=this,t=o(t),r=i*(e=ot(ut(t)))+n*(t=ot(ht(t))),this.x+=(i-(i=i*t+n*e))/2,this.y+=(n-r)/2,this.width=i,this.height=r),this},bottomLeft:function(){return new d(this.x,this.y+this.height)},bottomLine:function(){return new g(this.bottomLeft(),this.bottomRight())},bottomMiddle:function(){return new d(this.x+this.width/2,this.y+this.height)},center:function(){return new d(this.x+this.width/2,this.y+this.height/2)},clone:function(){return new A(this)},containsPoint:function(t,n){let e,i;return t&&"string"!=typeof t?{x:e=0,y:i=0}=t:{x:e,y:i}=new d(t),n&&n.strict?e>this.x&&e<this.x+this.width&&i>this.y&&i<this.y+this.height:e>=this.x&&e<=this.x+this.width&&i>=this.y&&i<=this.y+this.height},containsRect:function(t){var n,e,i=new A(this).normalize(),t=new A(t).normalize(),r=i.width,s=i.height,o=t.width,h=t.height;return!!(r&&s&&o&&h)&&(n=i.x,i=i.y,o+=e=t.x,r+=n,h+=t=t.y,s+=i,n<=e)&&o<=r&&i<=t&&h<=s},corner:function(){return new d(this.x+this.width,this.y+this.height)},equals:function(t){var n=new A(this).normalize(),t=new A(t).normalize();return n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height},inflate:function(t,n){return void 0===t&&(t=0),void 0===n&&(n=t),this.x-=t,this.y-=n,this.width+=2*t,this.height+=2*n,this},intersect:function(t){var n,e=this.origin(),i=this.corner(),r=t.origin(),t=t.corner();return t.x<=e.x||t.y<=e.y||r.x>=i.x||r.y>=i.y?null:(n=at(e.x,r.x),e=at(e.y,r.y),new A(n,e,f(i.x,t.x)-n,f(i.y,t.y)-e))},intersectionWithLine:function(t){for(var n,e=[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()],i=[],r=[],s=e.length,o=0;o<s;o++)null!==(n=t.intersect(e[o]))&&r.indexOf(n.toString())<0&&(i.push(n),r.push(n.toString()));return 0<i.length?i:null},intersectionWithLineFromCenterToPoint:function(t,n){t=new d(t);for(var e,i=new d(this.x+this.width/2,this.y+this.height/2),r=(n&&t.rotate(i,n),[this.topLine(),this.rightLine(),this.bottomLine(),this.leftLine()]),s=new g(i,t),o=r.length-1;0<=o;--o){var h=r[o].intersection(s);if(null!==h){e=h;break}}return e&&n&&e.rotate(i,-n),e},leftLine:function(){return new g(this.topLeft(),this.bottomLeft())},leftMiddle:function(){return new d(this.x,this.y+this.height/2)},maxRectScaleToFit:function(t,n){t=new A(t);var e,i,r,s,o,h,u,a=(n=n||t.center()).x,n=n.y,c=e=i=r=s=o=h=u=1/0,l=t.topLeft(),l=(l.x<a&&(c=(this.x-a)/(l.x-a)),l.y<n&&(s=(this.y-n)/(l.y-n)),t.bottomRight()),l=(l.x>a&&(e=(this.x+this.width-a)/(l.x-a)),n<l.y&&(o=(this.y+this.height-n)/(l.y-n)),t.topRight()),l=(l.x>a&&(i=(this.x+this.width-a)/(l.x-a)),l.y<n&&(h=(this.y-n)/(l.y-n)),t.bottomLeft());return l.x<a&&(r=(this.x-a)/(l.x-a)),n<l.y&&(u=(this.y+this.height-n)/(l.y-n)),{sx:f(c,e,i,r),sy:f(s,o,h,u)}},maxRectUniformScaleToFit:function(t,n){t=this.maxRectScaleToFit(t,n);return f(t.sx,t.sy)},moveAndExpand:function(t){return this.x+=t.x||0,this.y+=t.y||0,this.width+=t.width||0,this.height+=t.height||0,this},moveAroundPoint:function(t,n){t=this.center().rotate(t,n);return this.x=t.x-this.width/2,this.y=t.y-this.height/2,this},normalize:function(){var t=this.x,n=this.y,e=this.width,i=this.height;return this.width<0&&(t=this.x+this.width,e=-this.width),this.height<0&&(n=this.y+this.height,i=-this.height),this.x=t,this.y=n,this.width=e,this.height=i,this},offset:function(t,n){return d.prototype.offset.call(this,t,n)},origin:function(){return new d(this.x,this.y)},pointNearestToPoint:function(t){if(t=new d(t),this.containsPoint(t))switch(this.sideNearestToPoint(t)){case"right":return new d(this.x+this.width,t.y);case"left":return new d(this.x,t.y);case"bottom":return new d(t.x,this.y+this.height);case"top":return new d(t.x,this.y)}return t.adhereToRect(this)},rightLine:function(){return new g(this.topRight(),this.bottomRight())},rightMiddle:function(){return new d(this.x+this.width,this.y+this.height/2)},round:function(t){let n=1;if(t)switch(t){case 1:n=10;break;case 2:n=100;break;case 3:n=1e3;break;default:n=ct(10,t)}return this.x=p(this.x*n)/n,this.y=p(this.y*n)/n,this.width=p(this.width*n)/n,this.height=p(this.height*n)/n,this},scale:function(t,n,e){return e=this.origin().scale(t,n,e),this.x=e.x,this.y=e.y,this.width*=t,this.height*=n,this},sideNearestToPoint:function(t){var n=(t=new d(t)).x-this.x,e=this.x+this.width-t.x,i=t.y-this.y,r="left";return e<n&&(n=e,r="right"),i<n&&(n=i,r="top"),r=this.y+this.height-t.y<n?"bottom":r},snapToGrid:function(t,n){var e=this.origin().snapToGrid(t,n),t=this.corner().snapToGrid(t,n);return this.x=e.x,this.y=e.y,this.width=t.x-e.x,this.height=t.y-e.y,this},toJSON:function(){return{x:this.x,y:this.y,width:this.width,height:this.height}},topLine:function(){return new g(this.topLeft(),this.topRight())},topMiddle:function(){return new d(this.x+this.width/2,this.y)},topRight:function(){return new d(this.x+this.width,this.y)},toString:function(){return this.origin().toString()+" "+this.corner().toString()},union:function(t){return A.fromRectUnion(this,t)},update:function(t,n,e,i){return Object(t)===t&&(n=t.y,e=t.width,i=t.height,t=t.x),this.x=t||0,this.y=n||0,this.width=e||0,this.height=i||0,this}},A.prototype.bottomRight=A.prototype.corner,A.prototype.topLeft=A.prototype.origin,A.prototype.translate=A.prototype.offset;var lt=A;function ft(t){t=t.trim();if(""===t)return[];var n=[],e=t.split(/\b\s*,\s*|,\s*|\s+/),i=e.length;for(let t=0;t<i;t+=2)n.push({x:+e[t],y:+e[t+1]});return n}function dt(n){var e=n.length;if(0===e)return[];var i=[];for(let t=0;t<e;t++){var r=n[t].clone();i.push(r)}return i}function gt(t){var n,e=Math.abs,i=t.length;if(0===i)return[];for(s=0;s<i;s++)(void 0===n||t[s].y<n.y||t[s].y===n.y&&t[s].x>n.x)&&(n=t[s]);for(var r=[],s=0;s<i;s++){var o=n.theta(t[s]),o=(0===o&&(o=360),[t[s],s,o]);r.push(o)}r.sort(function(t,n){var e=t[2]-n[2];return e=0===e?n[1]-t[1]:e}),2<r.length&&r.unshift(r[r.length-1]);for(var h,u,a,c={},l=[];0!==r.length;)if(u=(h=r.pop())[0],!c.hasOwnProperty(h[0]+"@@"+h[1]))for(var f,d,g,p,v,y=!1;!y;)l.length<2?(l.push(h),y=!0):(d=(f=l.pop())[0],(v=(p=(g=l.pop())[0]).cross(d,u))<0?(l.push(g),l.push(f),l.push(h),y=!0):0!==v||e((v=d.angleBetween(p,u))-180)<1e-10||d.equals(u)||p.equals(d)?(c[f[0]+"@@"+f[1]]=d,l.push(g)):e((v+1)%360-1)<1e-10&&(l.push(g),r.push(f)));2<l.length&&l.pop();var w=-1,m=l.length;for(s=0;s<m;s++){var x=l[s][1];(void 0===a||x<a)&&(a=x,w=s)}var b,S,P=[],A=[];for(m=(P=0<w?(b=l.slice(w),S=l.slice(0,w),b.concat(S)):l).length,s=0;s<m;s++)A.push(P[s][0]);return A}function v(t){return this instanceof v?"string"==typeof t?new v.parse(t):void(this.points=Array.isArray(t)?t.map(d):[]):new v(t)}function y(t,n,e,i){return this instanceof y?t instanceof y?new y(t.start,t.controlPoint1,t.controlPoint2,t.end):(this.start=new d(t),this.controlPoint1=new d(n),this.controlPoint2=new d(e),void(this.end=new d(i))):new y(t,n,e,i)}v.parse=function(t){return new v(ft(t))},v.fromRect=function(t){return new v([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft(),t.topLeft()])},v.prototype={type:a.Polyline,bbox:function(){var t=1/0,n=-1/0,e=1/0,i=-1/0,r=this.points,s=r.length;if(0===s)return null;for(var o=0;o<s;o++){var h=r[o],u=h.x,h=h.y;u<t&&(t=u),n<u&&(n=u),h<e&&(e=h),i<h&&(i=h)}return new A(t,e,n-t,i-e)},clone:function(){return new v(dt(this.points))},closestPoint:function(t){t=this.closestPointLength(t);return this.pointAtLength(t)},closestPointLength:function(t){var n,e=this.lengthPoints(),i=e.length;if(0===i)return 0;if(1===i)return 0;for(var r=1/0,s=0,o=i-1,h=0;h<o;h++){var u=new g(e[h],e[h+1]),a=u.length(),c=u.closestPointNormalizedLength(t),u=u.pointAt(c).squaredDistance(t);u<r&&(r=u,n=s+c*a),s+=a}return n},closestPointNormalizedLength:function(t){var n,t=this.closestPointLength(t);return 0===t||0===(n=this.length())?0:t/n},closestPointTangent:function(t){t=this.closestPointLength(t);return this.tangentAtLength(t)},containsPoint:function(t){var n=this.points,e=n.length;if(0===e)return!1;for(var i=t.x,r=t.y,s=e-1,o=0,h=0,u=new g,a=new g,c=new d;o<e;o++){var l=n[s],f=n[o];if(t.equals(l))return!0;if(u.start=l,u.end=f,u.containsPoint(t))return!0;(r<=l.y&&r>f.y||r>l.y&&r<=f.y)&&0<=(l=l.x-i>f.x-i?l.x-i:f.x-i)&&(c.x=i+l,c.y=r,a.start=t,a.end=c,u.intersect(a))&&h++,s=o}return h%2==1},close:function(){var{start:t,end:n,points:e}=this;return t&&n&&!t.equals(n)&&e.push(t.clone()),this},lengthPoints:function(){return this.points},convexHull:function(){return new v(gt(this.points))},equals:function(t){if(!t)return!1;var n=this.points,e=t.points,i=n.length;if(e.length!==i)return!1;for(var r=0;r<i;r++){var s=n[r],o=t.points[r];if(!s.equals(o))return!1}return!0},intersectionWithLine:function(t){for(var n=new g(t),e=[],i=this.lengthPoints(),r=new g,s=0,o=i.length-1;s<o;s++){r.start=i[s],r.end=i[s+1];var h=n.intersectionWithLine(r);h&&e.push(h[0])}return 0<e.length?e:null},isDifferentiable:function(){var t=this.points,n=t.length;if(0!==n)for(var e=new g,i=n-1,r=0;r<i;r++)if(e.start=t[r],e.end=t[r+1],e.isDifferentiable())return!0;return!1},length:function(){var t=this.lengthPoints(),n=t.length;if(0===n)return 0;for(var e=0,i=n-1,r=0;r<i;r++)e+=t[r].distance(t[r+1]);return e},pointAt:function(t){var n=this.lengthPoints(),e=n.length;return 0===e?null:1===e||t<=0?n[0].clone():1<=t?n[e-1].clone():(n=this.length(),this.pointAtLength(n*t))},pointAtLength:function(t){var n=this.lengthPoints(),e=n.length;if(0===e)return null;if(1===e)return n[0].clone();for(var i=!0,r=(t<0&&(i=!1,t=-t),0),s=e-1,o=0;o<s;o++){var h=i?o:s-1-o,u=n[h],h=n[h+1],a=new g(u,h),u=u.distance(h);if(t<=r+u)return a.pointAtLength((i?1:-1)*(t-r));r+=u}return(i?n[e-1]:n[0]).clone()},round:function(t){for(var n=this.points,e=n.length,i=0;i<e;i++)n[i].round(t);return this},scale:function(t,n,e){for(var i=this.points,r=i.length,s=0;s<r;s++)i[s].scale(t,n,e);return this},simplify:function(n={}){var e=this.points;if(!(e.length<3)){var i=n.threshold||1e-10;let t=0;for(;e[t+2];){var r=t,s=t+1,o=t+2,r=e[r],h=e[s],o=e[o];new g(r,o).closestPoint(h).distance(h)<=i?e.splice(s,1):t+=1}}return this},tangentAt:function(t){var n=this.lengthPoints().length;if(0===n)return null;if(1===n)return null;1<(t=t<0?0:t)&&(t=1);n=this.length();return this.tangentAtLength(n*t)},tangentAtLength:function(t){var n=this.lengthPoints(),e=n.length;if(0===e)return null;if(1===e)return null;for(var i,r=!0,s=(t<0&&(r=!1,t=-t),0),o=e-1,h=0;h<o;h++){var u=r?h:o-1-h,a=n[u],u=n[u+1],c=new g(a,u),a=a.distance(u);if(c.isDifferentiable()){if(t<=s+a)return c.tangentAtLength((r?1:-1)*(t-s));i=c}s+=a}return i?i.tangentAt(r?1:0):null},toString:function(){return this.points+""},translate:function(t,n){for(var e=this.points,i=e.length,r=0;r<i;r++)e[r].translate(t,n);return this},serialize:function(){var t=this.points,n=t.length;if(0===n)return"";for(var e="",i=0;i<n;i++){var r=t[i];e+=r.x+","+r.y+" "}return e.trim()}},Object.defineProperty(v.prototype,"start",{configurable:!0,enumerable:!0,get:function(){return 0===this.points.length?null:this.points[0]}}),Object.defineProperty(v.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.points.length;return 0===t?null:this.points[t-1]}});let{abs:L,sqrt:pt,min:vt,max:yt,pow:wt}=Math;function mt(t){var n=t.length,e=[],i=[],r=2;e[0]=t[0]/r;for(var s=1;s<n;s++)i[s]=1/r,e[s]=(t[s]-e[s-1])/(r=(s<n-1?4:3.5)-i[s]);for(s=1;s<n;s++)e[n-s-1]-=i[n-s]*e[n-s];return e}function n(t){for(var n=[],e=arguments.length,i=1;i<e;i++)n.push(arguments[i]);if(!t)throw new Error("Missing a parent object.");var r=Object.create(t);for(e=n.length,i=0;i<e;i++){var s,o,h=n[i];for(o in h)h.hasOwnProperty(o)&&(delete r[o],s=Object.getOwnPropertyDescriptor(h,o),Object.defineProperty(r,o,s))}return r}y.throughPoints=function(t){if(!t||Array.isArray(t)&&t.length<2)throw new Error("At least 2 points are required");for(var n=(t=>{var n=[],e=[],i=t.length-1;if(1==i)n[0]=new d((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),e[0]=new d(2*n[0].x-t[0].x,2*n[0].y-t[0].y);else{for(var r=[],s=1;s<i-1;s++)r[s]=4*t[s].x+2*t[s+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var o=mt(r);for(s=1;s<i-1;++s)r[s]=4*t[s].y+2*t[s+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var h=mt(r);for(s=0;s<i;s++)n.push(new d(o[s],h[s])),e.push(s<i-1?new d(2*t[s+1].x-o[s+1],2*t[s+1].y-h[s+1]):new d((t[i].x+o[i-1])/2,(t[i].y+h[i-1])/2))}return[n,e]})(t),e=[],i=n[0].length,r=0;r<i;r++){var s=new d(n[0][r].x,n[0][r].y),o=new d(n[1][r].x,n[1][r].y);e.push(new y(t[r],s,o,t[r+1]))}return e},y.prototype={type:a.Curve,bbox:function(){for(var t,n,e,i,r,s=this.start,o=this.controlPoint1,h=this.controlPoint2,u=this.end,a=s.x,c=s.y,l=o.x,f=o.y,d=h.x,g=h.y,p=u.x,v=u.y,y=new Array,w=new Array,m=[new Array,new Array],x=0;x<2;++x)i=0===x?(n=6*a-12*l+6*d,t=-3*a+9*l-9*d+3*p,3*l-3*a):(n=6*c-12*f+6*g,t=-3*c+9*f-9*g+3*v,3*f-3*c),L(t)<1e-12?L(n)<1e-12||0<(e=-i/n)&&e<1&&w.push(e):(i=n*n-4*i*t,r=pt(i),i<0||(0<(i=(-n+r)/(2*t))&&i<1&&w.push(i),0<(i=(-n-r)/(2*t))&&i<1&&w.push(i)));for(var b,S,P=w.length,s=P;P--;)e=w[P],m[0][P]=b=(S=1-e)*S*S*a+3*S*S*e*l+3*S*e*e*d+e*e*e*p,m[1][P]=S=S*S*S*c+3*S*S*e*f+3*S*e*e*g+e*e*e*v,y[P]={X:b,Y:S};w[s]=0,w[s+1]=1,y[s]={X:a,Y:c},y[s+1]={X:p,Y:v},m[0][s]=a,m[1][s]=c,m[0][s+1]=p,m[1][s+1]=v,w.length=s+2,m[0].length=s+2,m[1].length=s+2,y.length=s+2;o=vt.apply(null,m[0]),h=vt.apply(null,m[1]),u=yt.apply(null,m[0]),s=yt.apply(null,m[1]);return new A(o,h,u-o,s-h)},clone:function(){return new y(this.start,this.controlPoint1,this.controlPoint2,this.end)},closestPoint:function(t,n){return this.pointAtT(this.closestPointT(t,n))},closestPointLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,subdivisions:void 0===n.subdivisions?this.getSubdivisions({precision:e}):n.subdivisions};return this.lengthAtT(this.closestPointT(t,e),e)},closestPointNormalizedLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,subdivisions:void 0===n.subdivisions?this.getSubdivisions({precision:e}):n.subdivisions},n=this.closestPointLength(t,e);return!n||0===(t=this.length(e))?0:n/t},closestPointT:function(t,n){for(var e,i,r,s,o,h,u=void 0===(n=n||{}).precision?this.PRECISION:n.precision,a=void 0===n.subdivisions?this.getSubdivisions({precision:u}):n.subdivisions,c=a.length,l=c?1/c:0,f=0;f<c;f++){var d=a[f],g=d.start.distance(t),p=d.end.distance(t),v=g+p;(!h||v<h)&&(i=f*l,r=(f+1)*l,s=g,A=p,o=(e=d).start.distance(d.end),h=v)}for(var y=wt(10,-u);;){var w=s?L(s-A)/s:0,m=A?L(s-A)/A:0;if(w<y||m<y||(!s||s<o*y||(!A||A<o*y)))return s<=A?i:r;var w=e.divide(.5),m=(l/=2,w[0].start.distance(t)),x=w[0].end.distance(t),b=m+x,S=w[1].start.distance(t),P=w[1].end.distance(t),A=b<=S+P?(e=w[0],r-=l,s=m,x):(e=w[1],i+=l,s=S,P)}},closestPointTangent:function(t,n){return this.tangentAtT(this.closestPointT(t,n))},containsPoint:function(t,n){return this.toPolyline(n).containsPoint(t)},divideAt:function(t,n){return t<=0?this.divideAtT(0):1<=t?this.divideAtT(1):(t=this.tAt(t,n),this.divideAtT(t))},divideAtLength:function(t,n){t=this.tAtLength(t,n);return this.divideAtT(t)},divideAtT:function(t){var n,e,i=this.start,r=this.controlPoint1,s=this.controlPoint2,o=this.end;return t<=0?[new y(i,i,i,i),new y(i,r,s,o)]:1<=t?[new y(i,r,s,o),new y(o,o,o,o)]:(s=(r=this.getSkeletonPoints(t)).startControlPoint1,t=r.startControlPoint2,n=r.divider,e=r.dividerControlPoint1,r=r.dividerControlPoint2,[new y(i,s,t,n),new y(n,e,r,o)])},endpointDistance:function(){return this.start.distance(this.end)},equals:function(t){return!!t&&this.start.x===t.start.x&&this.start.y===t.start.y&&this.controlPoint1.x===t.controlPoint1.x&&this.controlPoint1.y===t.controlPoint1.y&&this.controlPoint2.x===t.controlPoint2.x&&this.controlPoint2.y===t.controlPoint2.y&&this.end.x===t.end.x&&this.end.y===t.end.y},getSkeletonPoints:function(t){var n=this.start,e=this.controlPoint1,i=this.controlPoint2,r=this.end;return t<=0?{startControlPoint1:n.clone(),startControlPoint2:n.clone(),divider:n.clone(),dividerControlPoint1:e.clone(),dividerControlPoint2:i.clone()}:1<=t?{startControlPoint1:e.clone(),startControlPoint2:i.clone(),divider:r.clone(),dividerControlPoint1:r.clone(),dividerControlPoint2:r.clone()}:(n=new g(n,e).pointAt(t),e=new g(e,i).pointAt(t),i=new g(i,r).pointAt(t),r=new g(n,e).pointAt(t),e=new g(e,i).pointAt(t),{startControlPoint1:n,startControlPoint2:r,divider:new g(r,e).pointAt(t),dividerControlPoint1:e,dividerControlPoint2:i})},getSubdivisions:function(t){var t=void 0===(t=t||{}).precision?this.PRECISION:t.precision,n=this.start,e=this.controlPoint1,i=this.controlPoint2,r=this.end,s=[new y(n,e,i,r)];if(0===t)return s;if(!this.isDifferentiable())return s;for(var o=this.endpointDistance(),h=wt(10,-t),u=2,a=(0===e.cross(n,r)&&0===i.cross(n,r)&&(u=2*t),0);;){a+=1;for(var c=[],l=s.length,f=0;f<l;f++){var d=s[f].divide(.5);c.push(d[0],d[1])}for(var g=0,p=c.length,v=0;v<p;v++)g+=c[v].endpointDistance();if(u<=a)if((0!==g?(g-o)/g:0)<h)return c;s=c,o=g}},isDifferentiable:function(){var t=this.start,n=this.controlPoint1,e=this.controlPoint2,i=this.end;return!(t.equals(n)&&n.equals(e)&&e.equals(i))},length:function(t){for(var n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=void 0===t.subdivisions?this.getSubdivisions({precision:n}):t.subdivisions,i=0,r=e.length,s=0;s<r;s++)i+=e[s].endpointDistance();return i},lengthAtT:function(t,n){return t<=0?0:(n=void 0===(n=n||{}).precision?this.PRECISION:n.precision,this.divide(t)[0].length({precision:n}))},pointAt:function(t,n){return t<=0?this.start.clone():1<=t?this.end.clone():(t=this.tAt(t,n),this.pointAtT(t))},pointAtLength:function(t,n){t=this.tAtLength(t,n);return this.pointAtT(t)},pointAtT:function(t){return t<=0?this.start.clone():1<=t?this.end.clone():this.getSkeletonPoints(t).divider},PRECISION:3,round:function(t){return this.start.round(t),this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,n,e){return this.start.scale(t,n,e),this.controlPoint1.scale(t,n,e),this.controlPoint2.scale(t,n,e),this.end.scale(t,n,e),this},tangentAt:function(t,n){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);t=this.tAt(t,n);return this.tangentAtT(t)},tangentAtLength:function(t,n){return this.isDifferentiable()?(t=this.tAtLength(t,n),this.tangentAtT(t)):null},tangentAtT:function(t){if(!this.isDifferentiable())return null;t<0?t=0:1<t&&(t=1);var t=this.getSkeletonPoints(t),n=t.startControlPoint2,e=t.dividerControlPoint1,t=t.divider,e=new g(n,e);return e.translate(t.x-n.x,t.y-n.y),e},tAt:function(t,n){var e;return t<=0?0:1<=t?1:(e={precision:e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,subdivisions:void 0===n.subdivisions?this.getSubdivisions({precision:e}):n.subdivisions},n=this.length(e),this.tAtLength(n*t,e))},tAtLength:function(t,n){for(var e,i,r,s=!0,o=(t<0&&(s=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),h=void 0===n.subdivisions?this.getSubdivisions({precision:o}):n.subdivisions,n={precision:o,subdivisions:h},u=0,a=h.length,c=1/a,l=0;l<a;l++){var f=s?l:a-1-l,d=h[l],g=d.endpointDistance();if(t<=u+g){e=d,i=f*c,r=(f+1)*c,b=s?t-u:g+u-t,S=s?g+u-t:t-u;break}u+=g}if(!e)return s?1:0;for(var p=this.length(n),v=wt(10,-o);;){var y,w=0!==p?b/p:0;if(w<v)return i;if((0!==p?S/p:0)<v)return r;var w=e.divide(.5),m=(c/=2,w[0].endpointDistance()),x=w[1].endpointDistance(),w=b<=m?(e=w[0],r-=c,m-(y=b)):(e=w[1],i+=c,x-(y=b-m)),b=y,S=w}},toPoints:function(t){for(var n=void 0===(t=t||{}).precision?this.PRECISION:t.precision,e=void 0===t.subdivisions?this.getSubdivisions({precision:n}):t.subdivisions,i=[e[0].start.clone()],r=e.length,s=0;s<r;s++){var o=e[s];i.push(o.end.clone())}return i},toPolyline:function(t){return new v(this.toPoints(t))},toString:function(){return this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,n){return this.start.translate(t,n),this.controlPoint1.translate(t,n),this.controlPoint2.translate(t,n),this.end.translate(t,n),this}},y.prototype.divide=y.prototype.divideAtT;function S(t){if(!(this instanceof S))return new S(t);if("string"==typeof t)return new S.parse(t);var n;if(this.segments=[],t)if(Array.isArray(t)&&0!==t.length)if(n=(t=t.reduce(function(t,n){return t.concat(n)},[])).length,t[0].isSegment)for(r=0;r<n;r++){var e=t[r];this.appendSegment(e)}else for(var i=null,r=0;r<n;r++){var s=t[r];if(!(s instanceof g||s instanceof y))throw new Error("Cannot construct a path segment from the provided object.");0===r&&this.appendSegment(S.createSegment("M",s.start)),i&&!i.end.equals(s.start)&&this.appendSegment(S.createSegment("M",s.start)),s instanceof g?this.appendSegment(S.createSegment("L",s.end)):s instanceof y&&this.appendSegment(S.createSegment("C",s.controlPoint1,s.controlPoint2,s.end)),i=s}else if(t.isSegment)this.appendSegment(t);else if(t instanceof g)this.appendSegment(S.createSegment("M",t.start)),this.appendSegment(S.createSegment("L",t.end));else if(t instanceof y)this.appendSegment(S.createSegment("M",t.start)),this.appendSegment(S.createSegment("C",t.controlPoint1,t.controlPoint2,t.end));else{if(!(t instanceof v))throw new Error("Cannot construct a path from the provided object.");if(t.points&&0!==t.points.length)for(n=t.points.length,r=0;r<n;r++){var o=t.points[r];0===r?this.appendSegment(S.createSegment("M",o)):this.appendSegment(S.createSegment("L",o))}}}function w(t,n){return n.unshift(null),new(Function.prototype.bind.apply(t,n))}S.parse=function(t){if(!t)return new S;for(var n=new S,e=t.match(/(?:[a-zA-Z] *)(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)? *,? *)|(?:-?\.\d+ *,? *))+|(?:[a-zA-Z] *)(?! |\d|-|\.)/g),i=e.length,r=0;r<i;r++){var s=e[r].match(/(?:[a-zA-Z])|(?:(?:-?\d+(?:\.\d+)?(?:e[-+]?\d+)?))|(?:(?:-?\.\d+))/g),s=S.createSegment.apply(this,s);n.appendSegment(s)}return n},S.createSegment=function(t){if(!t)throw new Error("Type must be provided.");var n=S.segmentTypes[t];if(!n)throw new Error(t+" is not a recognized path segment type.");for(var e=[],i=arguments.length,r=1;r<i;r++)e.push(arguments[r]);return w(n,e)},S.prototype={type:a.Path,appendSegment:function(t){var n=this.segments,e=n.length,i=0!==e?n[e-1]:null;if(Array.isArray(t)){if(!(t=t.reduce(function(t,n){return t.concat(n)},[]))[0].isSegment)throw new Error("Segments required.");for(var r=t.length,s=0;s<r;s++){var o=t[s],h=this.prepareSegment(o,i,null);n.push(h),i=h}}else{if(!t||!t.isSegment)throw new Error("Segment required.");h=this.prepareSegment(t,i,null),n.push(h)}},bbox:function(){var t=this.segments,n=t.length;if(0===n)return null;for(var e,i=0;i<n;i++){var r,s=t[i];s.isVisible&&(s=s.bbox(),r=r?r.union(s):s)}return r||(e=t[n-1],new A(e.end.x,e.end.y,0,0))},clone:function(){for(var t=this.segments,n=t.length,e=new S,i=0;i<n;i++){var r=t[i].clone();e.appendSegment(r)}return e},closestPoint:function(t,n){t=this.closestPointT(t,n);return t?this.pointAtT(t):null},closestPointLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.closestPointT(t,e);return n?this.lengthAtT(n,e):0},closestPointNormalizedLength:function(t,n){var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.closestPointLength(t,e);return 0===n||0===(t=this.length(e))?0:n/t},closestPointT:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r,s=void 0===(n=n||{}).precision?this.PRECISION:n.precision,o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=1/0,u=0;u<i;u++){var a=e[u],c=o[u];a.isVisible&&(c=a.closestPointT(t,{precision:s,subdivisions:c}),a=a.pointAtT(c),(a=new g(a,t).squaredLength())<h)&&(r={segmentIndex:u,value:c},h=a)}return r||{segmentIndex:i-1,value:1}},closestPointTangent:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r,s=void 0===(n=n||{}).precision?this.PRECISION:n.precision,o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=1/0,u=0;u<i;u++){var a,c=e[u],l=o[u];c.isDifferentiable()&&(l=c.closestPointT(t,{precision:s,subdivisions:l}),a=c.pointAtT(l),(a=new g(a,t).squaredLength())<h)&&(r=c.tangentAtT(l),h=a)}return r||null},containsPoint:function(t,n){var e=this.toPolylines(n);if(!e)return!1;for(var i=e.length,r=0,s=0;s<i;s++)e[s].containsPoint(t)&&r++;return r%2==1},divideAt:function(t,n){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e);return this.divideAtLength(n*t,e)},divideAtLength:function(t,n){var e=this.segments.length;if(0===e)return null;for(var i,r,s,o,h=!0,u=(t<0&&(h=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),a=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:u}):n.segmentSubdivisions,c=0,l=0;l<e;l++){var f=h?l:e-1-l,d=this.getSegment(f),g=a[f],p=d.length({precision:u,subdivisions:g});if(d.isDifferentiable()&&(s=d,o=f,t<=c+p)){r=f,i=d.divideAtLength((h?1:-1)*(t-c),{precision:u,subdivisions:g});break}c+=p}if(!s)return null;i||(r=o,i=s.divideAtT(h?1:0));var v=this.clone(),n=(v.replaceSegment(r,i),r),y=r+1,w=r+2,m=(i[0].isDifferentiable()||(v.removeSegment(n),--y,--w),v.getSegment(y).start),x=(v.insertSegment(y,S.createSegment("M",m)),w+=1,i[1].isDifferentiable()||(v.removeSegment(w-1),--w),w-n-1);for(l=w;l<v.segments.length;l++){var b=this.getSegment(l-x);"Z"!==(d=v.getSegment(l)).type||b.subpathStartSegment.end.equals(d.subpathStartSegment.end)||(b=S.createSegment("L",b.end),v.replaceSegment(l,b))}return[new S(v.segments.slice(0,y)),new S(v.segments.slice(y))]},equals:function(t){if(!t)return!1;var n=this.segments,e=t.segments,i=n.length;if(e.length!==i)return!1;for(var r=0;r<i;r++){var s=n[r],o=e[r];if(s.type!==o.type||!s.equals(o))return!1}return!0},getSegment:function(t){var n=this.segments,e=n.length;if(0===e)throw new Error("Path has no segments.");if(e<=(t=t<0?e+t:t)||t<0)throw new Error("Index out of range.");return n[t]},getSegmentSubdivisions:function(t){for(var n=this.segments,e=n.length,i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=[],s=0;s<e;s++){var o=n[s].getSubdivisions({precision:i});r.push(o)}return r},getSubpaths:function(){var n=this.clone().validate().segments,e=n.length,i=[];for(let t=0;t<e;t++){var r=n[t];r.isSubpathStart?i.push(new S(r)):i[i.length-1].appendSegment(r)}return i},insertSegment:function(t,n){var e=this.segments,i=e.length;if(i<(t=t<0?i+t+1:t)||t<0)throw new Error("Index out of range.");var r=null,s=null;if(0!==i&&(s=1<=t?(r=e[t-1]).nextSegment:e[0]),Array.isArray(n)){if(!(n=n.reduce(function(t,n){return t.concat(n)},[]))[0].isSegment)throw new Error("Segments required.");for(var o=n.length,h=0;h<o;h++){var u=n[h],a=this.prepareSegment(u,r,s);e.splice(t+h,0,a),r=a}}else{if(!n||!n.isSegment)throw new Error("Segment required.");a=this.prepareSegment(n,r,s),e.splice(t,0,a)}},intersectionWithLine:function(t,n){var e=null,i=this.toPolylines(n);if(!i)return null;for(var r=0,s=i.length;r<s;r++){var o=i[r],o=t.intersect(o);o&&(e=e||[],Array.isArray(o)?Array.prototype.push.apply(e,o):e.push(o))}return e},isDifferentiable:function(){for(var t=this.segments,n=t.length,e=0;e<n;e++)if(t[e].isDifferentiable())return!0;return!1},isValid:function(){var t=this.segments;return 0===t.length||"M"===t[0].type},length:function(t){var n=this.segments,e=n.length;if(0===e)return 0;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,s=0,o=0;o<e;o++){var h=n[o],u=r[o];s+=h.length({subdivisions:u})}return s},lengthAtT:function(t,n){var e=this.segments,i=e.length;if(0===i)return 0;var r=t.segmentIndex;if(r<0)return 0;for(var t=t.value,s=(i<=r?(r=i-1,t=1):t<0?t=0:1<t&&(t=1),void 0===(n=n||{}).precision?this.PRECISION:n.precision),o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=0,u=0;u<r;u++){var a=e[u],c=o[u];h+=a.length({precisison:s,subdivisions:c})}return c=o[r],h+=(a=e[r]).lengthAtT(t,{precisison:s,subdivisions:c})},pointAt:function(t,n){var e;return 0===this.segments.length?null:t<=0?this.start.clone():1<=t?this.end.clone():(e={precision:e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e),this.pointAtLength(n*t,e))},pointAtLength:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;if(0===t)return this.start.clone();for(var r,s=!0,o=(t<0&&(s=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),h=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):n.segmentSubdivisions,u=0,a=0;a<i;a++){var c=s?a:i-1-a,l=e[c],c=h[c],f=l.length({precision:o,subdivisions:c});if(l.isVisible){if(t<=u+f)return l.pointAtLength((s?1:-1)*(t-u),{precision:o,subdivisions:c});r=l}u+=f}return r?s?r.end:r.start:e[i-1].end.clone()},pointAtT:function(t){var n,e=this.segments,i=e.length;return 0===i?null:(n=t.segmentIndex)<0?e[0].pointAtT(0):i<=n?e[i-1].pointAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),e[n].pointAtT(i))},PRECISION:3,prepareSegment:function(t,n,e){t.previousSegment=n,t.nextSegment=e,n&&(n.nextSegment=t),e&&(e.previousSegment=t);n=t;return t.isSubpathStart&&(t.subpathStartSegment=t,n=e),n&&this.updateSubpathStartSegment(n),t},removeSegment:function(t){var n=this.segments,e=n.length;if(0===e)throw new Error("Path has no segments.");if(e<=(t=t<0?e+t:t)||t<0)throw new Error("Index out of range.");e=n.splice(t,1)[0],n=e.previousSegment,t=e.nextSegment;n&&(n.nextSegment=t),t&&(t.previousSegment=n),e.isSubpathStart&&t&&this.updateSubpathStartSegment(t)},replaceSegment:function(t,n){var e=this.segments,i=e.length;if(0===i)throw new Error("Path has no segments.");if(i<=(t=t<0?i+t:t)||t<0)throw new Error("Index out of range.");var i=e[t],r=i.previousSegment,s=i.nextSegment,o=i.isSubpathStart;if(Array.isArray(n)){if(!(n=n.reduce(function(t,n){return t.concat(n)},[]))[0].isSegment)throw new Error("Segments required.");e.splice(t,1);for(var h=n.length,u=0;u<h;u++){var a=n[u],c=this.prepareSegment(a,r,s);e.splice(t+u,0,c),r=c,o&&c.isSubpathStart&&(o=!1)}}else{if(!n||!n.isSegment)throw new Error("Segment required.");c=this.prepareSegment(n,r,s),e.splice(t,1,c),o&&c.isSubpathStart&&(o=!1)}o&&s&&this.updateSubpathStartSegment(s)},round:function(t){for(var n=this.segments,e=n.length,i=0;i<e;i++)n[i].round(t);return this},scale:function(t,n,e){for(var i=this.segments,r=i.length,s=0;s<r;s++)i[s].scale(t,n,e);return this},segmentAt:function(t,n){t=this.segmentIndexAt(t,n);return t?this.getSegment(t):null},segmentAtLength:function(t,n){t=this.segmentIndexAtLength(t,n);return t?this.getSegment(t):null},segmentIndexAt:function(t,n){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e);return this.segmentIndexAtLength(n*t,e)},segmentIndexAtLength:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r=!0,s=(t<0&&(r=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),o=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:s}):n.segmentSubdivisions,h=null,u=0,a=0;a<i;a++){var c=r?a:i-1-a,l=e[c],f=o[c],f=l.length({precision:s,subdivisions:f});if(l.isVisible){if(t<=u+f)return c;h=c}u+=f}return h},serialize:function(){if(this.isValid())return this.toString();throw new Error("Invalid path segments.")},tangentAt:function(t,n){if(0===this.segments.length)return null;1<(t=t<0?0:t)&&(t=1);var e=void 0===(n=n||{}).precision?this.PRECISION:n.precision,e={precision:e,segmentSubdivisions:void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:e}):n.segmentSubdivisions},n=this.length(e);return this.tangentAtLength(n*t,e)},tangentAtLength:function(t,n){var e=this.segments,i=e.length;if(0===i)return null;for(var r,s=!0,o=(t<0&&(s=!1,t=-t),void 0===(n=n||{}).precision?this.PRECISION:n.precision),h=void 0===n.segmentSubdivisions?this.getSegmentSubdivisions({precision:o}):n.segmentSubdivisions,u=0,a=0;a<i;a++){var c=s?a:i-1-a,l=e[c],c=h[c],f=l.length({precision:o,subdivisions:c});if(l.isDifferentiable()){if(t<=u+f)return l.tangentAtLength((s?1:-1)*(t-u),{precision:o,subdivisions:c});r=l}u+=f}return r?r.tangentAtT(s?1:0):null},tangentAtT:function(t){var n,e=this.segments,i=e.length;return 0===i?null:(n=t.segmentIndex)<0?e[0].tangentAtT(0):i<=n?e[i-1].tangentAtT(1):((i=t.value)<0?i=0:1<i&&(i=1),e[n].tangentAtT(i))},toPoints:function(t){var n=this.segments,e=n.length;if(0===e)return null;for(var i=void 0===(t=t||{}).precision?this.PRECISION:t.precision,r=void 0===t.segmentSubdivisions?this.getSegmentSubdivisions({precision:i}):t.segmentSubdivisions,s=[],o=[],h=0;h<e;h++){var u,a=n[h];a.isVisible?0<(u=r[h]).length?(u=u.map(function(t){return t.start}),Array.prototype.push.apply(o,u)):o.push(a.start):0<o.length&&(o.push(n[h-1].end),s.push(o),o=[])}return 0<o.length&&(o.push(this.end),s.push(o)),s},toPolylines:function(t){var n=[],e=this.toPoints(t);if(!e)return null;for(var i=0,r=e.length;i<r;i++)n.push(new v(e[i]));return n},toString:function(){for(var t=this.segments,n=t.length,e="",i=0;i<n;i++)e+=t[i].serialize()+" ";return e.trim()},translate:function(t,n){for(var e=this.segments,i=e.length,r=0;r<i;r++)e[r].translate(t,n);return this},updateSubpathStartSegment:function(t){for(var n=t.previousSegment;t&&!t.isSubpathStart;)t.subpathStartSegment=n?n.subpathStartSegment:null,t=(n=t).nextSegment},validate:function(){return this.isValid()||this.insertSegment(0,S.createSegment("M",0,0)),this}},Object.defineProperty(S.prototype,"start",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,n=t.length;if(0===n)return null;for(var e=0;e<n;e++){var i=t[e];if(i.isVisible)return i.start}return t[n-1].end}}),Object.defineProperty(S.prototype,"end",{configurable:!0,enumerable:!0,get:function(){var t=this.segments,n=t.length;if(0===n)return null;for(var e=n-1;0<=e;e--){var i=t[e];if(i.isVisible)return i.end}return t[n-1].end}});function m(){for(var t=[],n=arguments.length,e=0;e<n;e++)t.push(arguments[e]);if(!(this instanceof m))return w(m,t);if(0===n)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates (none provided).");if(t[0]instanceof g){if(1===n)return this.end=t[0].end.clone(),this;throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+n+" lines provided).")}if("string"==typeof t[0]||"number"==typeof t[0]){if(2===n)return this.end=new d(+t[0],+t[1]),this;if(n<2)throw new Error("Lineto constructor expects a line, 1 point, or 2 coordinates ("+n+" coordinates provided).");for(var i,r=[],e=0;e<n;e+=2)i=t.slice(e,e+2),r.push(w(m,i))}else{if(1===n)return this.end=new d(t[0]),this;for(r=[],e=0;e<n;e+=1)r.push(new m(t[e]))}return r}function x(){for(var t,n=[],e=arguments.length,i=0;i<e;i++)n.push(arguments[i]);if(!(this instanceof x))return w(x,n);if(0===e)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates (none provided).");if(n[0]instanceof y){if(1===e)return this.controlPoint1=n[0].controlPoint1.clone(),this.controlPoint2=n[0].controlPoint2.clone(),this.end=n[0].end.clone(),this;throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+e+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(6===e)return this.controlPoint1=new d(+n[0],+n[1]),this.controlPoint2=new d(+n[2],+n[3]),this.end=new d(+n[4],+n[5]),this;if(e<6)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+e+" coordinates provided).");for(var r,s=[],i=0;i<e;i+=6)r=n.slice(i,i+6),s.push(w(x,r))}else{if(3===e)return this.controlPoint1=new d(n[0]),this.controlPoint2=new d(n[1]),this.end=new d(n[2]),this;if(e<3)throw new Error("Curveto constructor expects a curve, 3 points, or 6 coordinates ("+e+" points provided).");for(s=[],i=0;i<e;i+=3)t=n.slice(i,i+3),s.push(w(x,t))}return s}function b(){for(var t,n=[],e=arguments.length,i=0;i<e;i++)n.push(arguments[i]);if(!(this instanceof b))return w(b,n);if(0===e)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates (none provided).");if(n[0]instanceof g){if(1===e)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+e+" lines provided).")}if(n[0]instanceof y){if(1===e)return this.end=n[0].end.clone(),this;throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+e+" curves provided).")}if("string"==typeof n[0]||"number"==typeof n[0]){if(2===e)return this.end=new d(+n[0],+n[1]),this;if(e<2)throw new Error("Moveto constructor expects a line, a curve, 1 point, or 2 coordinates ("+e+" coordinates provided).");for(var r,s=[],i=0;i<e;i+=2)r=n.slice(i,i+2),0===i?s.push(w(b,r)):s.push(w(m,r))}else{if(1===e)return this.end=new d(n[0]),this;for(s=[],i=0;i<e;i+=1)t=n[i],0===i?s.push(new b(t)):s.push(new m(t))}return s}function P(){for(var t=[],n=arguments.length,e=0;e<n;e++)t.push(arguments[e]);if(!(this instanceof P))return w(P,t);if(0<n)throw new Error("Closepath constructor expects no arguments.");return this}var E={bbox:function(){throw new Error("Declaration missing for virtual function.")},clone:function(){throw new Error("Declaration missing for virtual function.")},closestPoint:function(){throw new Error("Declaration missing for virtual function.")},closestPointLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointNormalizedLength:function(){throw new Error("Declaration missing for virtual function.")},closestPointT:function(t){if(this.closestPointNormalizedLength)return this.closestPointNormalizedLength(t);throw new Error("Neither closestPointT() nor closestPointNormalizedLength() function is implemented.")},closestPointTangent:function(){throw new Error("Declaration missing for virtual function.")},divideAt:function(){throw new Error("Declaration missing for virtual function.")},divideAtLength:function(){throw new Error("Declaration missing for virtual function.")},divideAtT:function(t){if(this.divideAt)return this.divideAt(t);throw new Error("Neither divideAtT() nor divideAt() function is implemented.")},equals:function(){throw new Error("Declaration missing for virtual function.")},getSubdivisions:function(){throw new Error("Declaration missing for virtual function.")},isDifferentiable:function(){throw new Error("Declaration missing for virtual function.")},isSegment:!0,isSubpathStart:!1,isVisible:!0,length:function(){throw new Error("Declaration missing for virtual function.")},lengthAtT:function(t){var n;return t<=0?0:(n=this.length(),1<=t?n:n*t)},nextSegment:null,pointAt:function(){throw new Error("Declaration missing for virtual function.")},pointAtLength:function(){throw new Error("Declaration missing for virtual function.")},pointAtT:function(t){if(this.pointAt)return this.pointAt(t);throw new Error("Neither pointAtT() nor pointAt() function is implemented.")},previousSegment:null,round:function(){throw new Error("Declaration missing for virtual function.")},subpathStartSegment:null,scale:function(){throw new Error("Declaration missing for virtual function.")},serialize:function(){throw new Error("Declaration missing for virtual function.")},tangentAt:function(){throw new Error("Declaration missing for virtual function.")},tangentAtLength:function(){throw new Error("Declaration missing for virtual function.")},tangentAtT:function(t){if(this.tangentAt)return this.tangentAt(t);throw new Error("Neither tangentAtT() nor tangentAt() function is implemented.")},toString:function(){throw new Error("Declaration missing for virtual function.")},translate:function(){throw new Error("Declaration missing for virtual function.")}},T=(Object.defineProperty(E,"end",{configurable:!0,enumerable:!0,writable:!0}),Object.defineProperty(E,"start",{configurable:!0,enumerable:!0,get:function(){if(this.previousSegment)return this.previousSegment.end;throw new Error("Missing previous segment. (This segment cannot be the first segment of a path; OR segment has not yet been added to a path.)")}}),Object.defineProperty(E,"type",{configurable:!0,enumerable:!0,get:function(){throw new Error("Bad segment declaration. No type specified.")}}),{clone:function(){return new m(this.end)},divideAt:function(t){t=new g(this.start,this.end).divideAt(t);return[new m(t[0]),new m(t[1])]},divideAtLength:function(t){t=new g(this.start,this.end).divideAtLength(t);return[new m(t[0]),new m(t[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!!this.previousSegment&&!this.start.equals(this.end)},round:function(t){return this.end.round(t),this},scale:function(t,n,e){return this.end.scale(t,n,e),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(t,n){return this.end.translate(t,n),this}}),T=(Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"L"}),m.prototype=n(E,g.prototype,T),{clone:function(){return new x(this.controlPoint1,this.controlPoint2,this.end)},divideAt:function(t,n){t=new y(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAt(t,n);return[new x(t[0]),new x(t[1])]},divideAtLength:function(t,n){t=new y(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtLength(t,n);return[new x(t[0]),new x(t[1])]},divideAtT:function(t){t=new y(this.start,this.controlPoint1,this.controlPoint2,this.end).divideAtT(t);return[new x(t[0]),new x(t[1])]},isDifferentiable:function(){var t,n,e,i;return!(!this.previousSegment||(t=this.start,n=this.controlPoint1,e=this.controlPoint2,i=this.end,t.equals(n)&&n.equals(e)&&e.equals(i)))},round:function(t){return this.controlPoint1.round(t),this.controlPoint2.round(t),this.end.round(t),this},scale:function(t,n,e){return this.controlPoint1.scale(t,n,e),this.controlPoint2.scale(t,n,e),this.end.scale(t,n,e),this},serialize:function(){var t=this.controlPoint1,n=this.controlPoint2,e=this.end;return this.type+" "+t.x+" "+t.y+" "+n.x+" "+n.y+" "+e.x+" "+e.y},toString:function(){return this.type+" "+this.start+" "+this.controlPoint1+" "+this.controlPoint2+" "+this.end},translate:function(t,n){return this.controlPoint1.translate(t,n),this.controlPoint2.translate(t,n),this.end.translate(t,n),this}}),T=(Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"C"}),x.prototype=n(E,y.prototype,T),{bbox:function(){return null},clone:function(){return new b(this.end)},closestPoint:function(){return this.end.clone()},closestPointNormalizedLength:function(){return 0},closestPointLength:function(){return 0},closestPointT:function(){return 1},closestPointTangent:function(){return null},divideAt:function(){return[this.clone(),this.clone()]},divideAtLength:function(){return[this.clone(),this.clone()]},equals:function(t){return this.end.equals(t.end)},getSubdivisions:function(){return[]},isDifferentiable:function(){return!1},isSubpathStart:!0,isVisible:!1,length:function(){return 0},lengthAtT:function(){return 0},pointAt:function(){return this.end.clone()},pointAtLength:function(){return this.end.clone()},pointAtT:function(){return this.end.clone()},round:function(t){return this.end.round(t),this},scale:function(t,n,e){return this.end.scale(t,n,e),this},serialize:function(){var t=this.end;return this.type+" "+t.x+" "+t.y},tangentAt:function(){return null},tangentAtLength:function(){return null},tangentAtT:function(){return null},toString:function(){return this.type+" "+this.end},translate:function(t,n){return this.end.translate(t,n),this}}),T=(Object.defineProperty(T,"start",{configurable:!0,enumerable:!0,get:function(){throw new Error("Illegal access. Moveto segments should not need a start property.")}}),Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"M"}),b.prototype=n(E,T),{clone:function(){return new P},divideAt:function(t){t=new g(this.start,this.end).divideAt(t);return[t[1].isDifferentiable()?new m(t[0]):this.clone(),new m(t[1])]},divideAtLength:function(t){t=new g(this.start,this.end).divideAtLength(t);return[t[1].isDifferentiable()?new m(t[0]):this.clone(),new m(t[1])]},getSubdivisions:function(){return[]},isDifferentiable:function(){return!(!this.previousSegment||!this.subpathStartSegment||this.start.equals(this.end))},round:function(){return this},scale:function(){return this},serialize:function(){return this.type},toString:function(){return this.type+" "+this.start+" "+this.end},translate:function(){return this}}),E=(Object.defineProperty(T,"end",{configurable:!0,enumerable:!0,get:function(){if(this.subpathStartSegment)return this.subpathStartSegment.end;throw new Error("Missing subpath start segment. (This segment needs a subpath start segment (e.g. Moveto); OR segment has not yet been added to a path.)")}}),Object.defineProperty(T,"type",{configurable:!0,enumerable:!0,value:"Z"}),P.prototype=n(E,g.prototype,T),S.segmentTypes={L:m,C:x,M:b,Z:P,z:P}),T=(S.regexSupportedData=new RegExp("^[\\s\\d"+Object.keys(E).join("")+",.]*$"),S.isDataSupported=function(t){return"string"==typeof t&&this.regexSupportedData.test(t)},{curveThroughPoints:function(t){return console.warn("deprecated"),new S(y.throughPoints(t)).serialize()},getCurveControlPoints:function(t){console.warn("deprecated");var n=[],e=[],i=t.length-1;if(1==i)n[0]=new d((2*t[0].x+t[1].x)/3,(2*t[0].y+t[1].y)/3),e[0]=new d(2*n[0].x-t[0].x,2*n[0].y-t[0].y);else{for(var r=[],s=1;s<i-1;s++)r[s]=4*t[s].x+2*t[s+1].x;r[0]=t[0].x+2*t[1].x,r[i-1]=(8*t[i-1].x+t[i].x)/2;var o=this.getFirstControlPoints(r);for(s=1;s<i-1;++s)r[s]=4*t[s].y+2*t[s+1].y;r[0]=t[0].y+2*t[1].y,r[i-1]=(8*t[i-1].y+t[i].y)/2;var h=this.getFirstControlPoints(r);for(s=0;s<i;s++)n.push(new d(o[s],h[s])),e.push(s<i-1?new d(2*t[s+1].x-o[s+1],2*t[s+1].y-h[s+1]):new d((t[i].x+o[i-1])/2,(t[i].y+h[i-1])/2))}return[n,e]},getCurveDivider:function(t,n,e,i){console.warn("deprecated");var r=new y(t,n,e,i);return function(t){t=r.divide(t);return[{p0:t[0].start,p1:t[0].controlPoint1,p2:t[0].controlPoint2,p3:t[0].end},{p0:t[1].start,p1:t[1].controlPoint1,p2:t[1].controlPoint2,p3:t[1].end}]}},getFirstControlPoints:function(t){console.warn("deprecated");var n=t.length,e=[],i=[],r=2;e[0]=t[0]/r;for(var s=1;s<n;s++)i[s]=1/r,e[s]=(t[s]-e[s-1])/(r=(s<n-1?4:3.5)-i[s]);for(s=1;s<n;s++)e[n-s-1]-=i[n-s]*e[n-s];return e},getInversionSolver:function(t,n,e,i){console.warn("deprecated");var r=new y(t,n,e,i);return function(t){return r.closestPointT(t)}}});let I=function(t){return this instanceof I?"string"==typeof t?new I.parse(t):void(this.points=Array.isArray(t)?t.map(d):[]):new I(t)};function C(t,n){var e=t.start.x,i=t.start.y,r=t.end.x,t=t.end.y,s=n.start.x,o=n.start.y,r=r-e,t=t-i,h=n.end.x-s,n=n.end.y-o,e=e-s,s=i-o,i=r*n-h*t,o=(r*s-t*e)/i,r=(h*s-n*e)/i;return 0<=o&&o<=1&&0<=r&&r<=1}function xt(t,n){var e=t.a,i=t.b,r=t.x,t=t.y,s=n.start.x-r,r=n.end.x-r,o=n.start.y-t,e=e*e,i=i*i,r=r-s,n=n.end.y-t-o,t=r*r/e+n*n/i,r=2*s*r/e+2*o*n/i,n=r*r-4*t*(s*s/e+o*o/i-1);return 0==n?0<=(s=-r/2/t)&&s<=1:0<n&&(o=(-r-(e=Math.sqrt(n)))/2/t,0<=(i=(-r+e)/2/t)&&i<=1||0<=o&&o<=1)}function bt(I,C){{var R=0,D=0;let{cos:t,sin:n}=Math,e=n(R),i=t(R),r=n(D),s=t(D),o=e*e,h=i*i,u=e*i,a=r*r,c=s*s,l=r*s,f=I.a*I.a,d=I.b*I.b,g=C.a*C.a,p=C.b*C.b,v=f*o+d*h,y=g*a+p*c,w=f*h+d*o,m=g*c+p*a,x=2*(d-f)*u,b=2*(p-g)*l,S=-2*v*I.x-x*I.y,P=-2*y*C.x-b*C.y,A=-x*I.x-2*w*I.y,L=-b*C.x-2*m*C.y,E=v*I.x*I.x+w*I.y*I.y+x*I.x*I.y-f*d,T=y*C.x*C.x+m*C.y*C.y+b*C.x*C.y-g*p;x/=2,b/=2,S/=2,P/=2,A/=2,L/=2;var R=z([[v,x,S],[x,w,A],[S,A,E]]),D=z([[y,b,P],[b,m,L],[P,L,T]]),I=.33333333*(z([[y,x,S],[b,w,A],[P,A,E]])+z([[v,b,S],[x,m,A],[S,L,E]])+z([[v,x,P],[x,w,L],[S,A,T]])),C=.33333333*(z([[v,b,P],[x,m,L],[S,L,T]])+z([[y,x,P],[b,w,L],[P,A,T]])+z([[y,b,S],[b,m,A],[P,L,E]])),N=q([[R,I],[I,C]]),R=q([[R,C],[I,D]]),D=q([[I,C],[C,D]]);return!(0<(N=q([[2*N,R],[R,2*D]]))&&(0<C||0<I))}}function St(t,n){var{start:e,end:i}=n,{x:r,y:s,width:o,height:h}=t;return!(e.x>r+o&&i.x>r+o||e.x<r&&i.x<r||e.y>s+h&&i.y>s+h||e.y<s&&i.y<s)&&(!(!t.containsPoint(n.start)&&!t.containsPoint(n.end))||C(t.topLine(),n)||C(t.rightLine(),n)||C(t.bottomLine(),n)||C(t.leftLine(),n))}function Pt(t,n){return!!At(t,A.fromEllipse(n))&&D(I.fromRect(t),n)}function At(t,n){return t.x<n.x+n.width&&t.x+t.width>n.x&&t.y<n.y+n.height&&t.y+t.height>n.y}function R(t,n){return Wt(t,n,{interior:!1})}function Lt(t,n){return jt(t,n,{interior:!1})}function Et(t,n){return kt(t,n,{interior:!1})}function Tt(t,n){return O(t,n,{interior:!1})}function It(t,n){return Wt(t,n,{interior:!0})}function D(t,n){return jt(t,n,{interior:!0})}function Ct(t,n){return kt(t,n,{interior:!0})}function Rt(t,n){return O(t,n,{interior:!0})}function Dt(t,n){return Ft(t,n,{interior:!0})}function Nt(t,e,i){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?It:R)(n,e)})}function Ot(t,e,i){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?D:Lt)(n,e)})}function qt(t,n,e){return N(t,I.fromRect(n),e)}function zt(t,n,e){return Vt(t,n,e,{interior:!1})}function N(t,n,e){return Vt(t,n,e,{interior:!0})}function Mt(t,e,i,r){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?N:zt)(e,n,r)})}function Wt(t,n,e={}){var{interior:e=!1}=e;let i;if(e){if(t.containsPoint(n.start))return!0;var{start:e,end:r,points:s}=t;i=r.equals(e)?s:[...s,e]}else i=t.points;var o=i.length,h=new g;for(let t=0;t<o-1;t++)if(h.start=i[t],h.end=i[t+1],C(n,h))return!0;return!1}function jt(t,n,e={}){var{start:i,end:r,points:s}=t;if(n.containsPoint(i))return!0;let o;var{interior:e=!1}=e;if(e){if(t.containsPoint(n.center()))return!0;o=r.equals(i)?s:[...s,i]}else o=s;var h=o.length,u=new g;for(let t=0;t<h-1;t++)if(u.start=o[t],u.end=o[t+1],xt(n,u))return!0;return!1}function kt(t,n,e){return Ft(t,I.fromRect(n),e)}function Vt(t,e,i,r){return t.getSubpaths().some(t=>{var[n]=t.toPolylines(i),t=t.getSegment(-1).type;return("Z"===t?Ft:O)(e,n,r)})}function O(t,n,e={}){var{interior:e=!1}=e;let i;if(e){e=n.start;if(t.containsPoint(e))return!0;i=t.clone().close()}else i=t;var r=n.points,s=r.length,o=new g;for(let t=0;t<s-1;t++)if(o.start=r[t],o.end=r[t+1],R(i,o))return!0;return!1}function Ft(t,n,e){return n.containsPoint(t.start)||O(t,n.clone().close(),e)}function q(t){return t[0][0]*t[1][1]-t[0][1]*t[1][0]}function z(t){return t[0][0]*t[1][1]*t[2][2]-t[0][0]*t[1][2]*t[2][1]-t[0][1]*t[1][0]*t[2][2]+t[0][1]*t[1][2]*t[2][0]+t[0][2]*t[1][0]*t[2][1]-t[0][2]*t[1][1]*t[2][0]}I.parse=function(t){return new I(ft(t))},I.fromRect=function(t){return new I([t.topLeft(),t.topRight(),t.bottomRight(),t.bottomLeft()])},I.prototype=n(v.prototype,{type:a.Polygon,clone:function(){return new I(dt(this.points))},convexHull:function(){return new I(gt(this.points))},lengthPoints:function(){var{start:t,end:n,points:e}=this;return e.length<=1||t.equals(n)?e:[...e,t.clone()]}});E={__proto__:null,ellipseWithEllipse:bt,ellipseWithLine:xt,exists:function t(n,e,i,r){switch(n.type){case a.Line:if(e.type===a.Line)return C(n,e);break;case a.Ellipse:switch(e.type){case a.Line:return xt(n,e);case a.Ellipse:return bt(n,e)}break;case a.Rect:switch(e.type){case a.Line:return St(n,e);case a.Ellipse:return Pt(n,e);case a.Rect:return At(n,e)}break;case a.Polyline:switch(e.type){case a.Line:return R(n,e);case a.Ellipse:return Lt(n,e);case a.Rect:return Et(n,e);case a.Polyline:return Tt(n,e)}break;case a.Polygon:switch(e.type){case a.Line:return It(n,e);case a.Ellipse:return D(n,e);case a.Rect:return Ct(n,e);case a.Polyline:return Rt(n,e);case a.Polygon:return Dt(n,e)}break;case a.Path:switch(e.type){case a.Line:return Nt(n,e,i);case a.Ellipse:return Ot(n,e,i);case a.Rect:return qt(n,e,i);case a.Polyline:return zt(n,e,i);case a.Polygon:return N(n,e,i);case a.Path:return Mt(n,e,i,r)}}switch(e.type){case a.Ellipse:case a.Rect:case a.Polyline:case a.Polygon:case a.Path:return t(e,n,r,i);default:throw Error(`The intersection for ${n} and ${e} could not be found.`)}},lineWithLine:C,pathWithEllipse:Ot,pathWithLine:Nt,pathWithPath:Mt,pathWithPolygon:N,pathWithPolyline:zt,pathWithRect:qt,polygonWithEllipse:D,polygonWithLine:It,polygonWithPolygon:Dt,polygonWithPolyline:Rt,polygonWithRect:Ct,polylineWithEllipse:Lt,polylineWithLine:R,polylineWithPolyline:Tt,polylineWithRect:Et,rectWithEllipse:Pt,rectWithLine:St,rectWithRect:At};t.Curve=y,t.Ellipse=i,t.Line=g,t.Path=S,t.Point=d,t.Polygon=I,t.Polyline=v,t.Rect=A,t.bezier=T,t.ellipse=st,t.intersection=E,t.line=et,t.normalizeAngle=r,t.point=Q,t.random=h,t.rect=lt,t.scale={linear:function(t,n,e){var i=t[1]-t[0],r=n[1]-n[0];return(e-t[0])/i*r+n[0]||0}},t.snapToGrid=e,t.toDeg=s,t.toRad=o,t.types=a});
|
package/dist/joint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! JointJS v4.
|
|
1
|
+
/*! JointJS v4.2.0-alpha.0 (2025-06-16) - JavaScript diagramming library
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
This Source Code Form is subject to the terms of the Mozilla Public
|
|
@@ -20,7 +20,11 @@ export as namespace joint;
|
|
|
20
20
|
|
|
21
21
|
export declare namespace anchors {
|
|
22
22
|
|
|
23
|
-
export interface
|
|
23
|
+
export interface ElementAnchorArguments {
|
|
24
|
+
useModelGeometry?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface RotateAnchorArguments extends ElementAnchorArguments {
|
|
24
28
|
rotate?: boolean;
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -29,7 +33,7 @@ export declare namespace anchors {
|
|
|
29
33
|
dy?: number | string;
|
|
30
34
|
}
|
|
31
35
|
|
|
32
|
-
export interface PaddingAnchorArguments {
|
|
36
|
+
export interface PaddingAnchorArguments extends ElementAnchorArguments {
|
|
33
37
|
padding?: number;
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -936,6 +940,7 @@ export declare namespace dia {
|
|
|
936
940
|
export interface GenericAttributes<T> {
|
|
937
941
|
attrs?: T;
|
|
938
942
|
z?: number;
|
|
943
|
+
layer?: string;
|
|
939
944
|
[key: string]: any;
|
|
940
945
|
}
|
|
941
946
|
|
|
@@ -1124,6 +1129,8 @@ export declare namespace dia {
|
|
|
1124
1129
|
|
|
1125
1130
|
getBBox(): g.Rect;
|
|
1126
1131
|
|
|
1132
|
+
getCenter(): g.Point;
|
|
1133
|
+
|
|
1127
1134
|
getPointFromConnectedLink(link: dia.Link, endType: dia.LinkEnd): g.Point;
|
|
1128
1135
|
|
|
1129
1136
|
getPointRotatedAroundCenter(angle: number, x: number, y: number): g.Point;
|
|
@@ -1176,6 +1183,7 @@ export declare namespace dia {
|
|
|
1176
1183
|
position?: PositionType;
|
|
1177
1184
|
markup?: string | MarkupJSON;
|
|
1178
1185
|
attrs?: Cell.Selectors;
|
|
1186
|
+
size?: Size;
|
|
1179
1187
|
label?: {
|
|
1180
1188
|
markup?: string | MarkupJSON;
|
|
1181
1189
|
position?: PositionType;
|
|
@@ -1187,7 +1195,11 @@ export declare namespace dia {
|
|
|
1187
1195
|
markup?: string | MarkupJSON;
|
|
1188
1196
|
group?: string;
|
|
1189
1197
|
attrs?: Cell.Selectors;
|
|
1198
|
+
position?: {
|
|
1199
|
+
args?: { [key: string]: any };
|
|
1200
|
+
};
|
|
1190
1201
|
args?: { [key: string]: any };
|
|
1202
|
+
size?: Size;
|
|
1191
1203
|
label?: {
|
|
1192
1204
|
markup?: string | MarkupJSON;
|
|
1193
1205
|
position?: PositionType;
|
|
@@ -1199,6 +1211,10 @@ export declare namespace dia {
|
|
|
1199
1211
|
angle: number;
|
|
1200
1212
|
}
|
|
1201
1213
|
|
|
1214
|
+
export interface PortRect extends BBox {
|
|
1215
|
+
angle: number;
|
|
1216
|
+
}
|
|
1217
|
+
|
|
1202
1218
|
export interface TranslateOptions extends Cell.Options {
|
|
1203
1219
|
restrictedArea?: BBox | Paper.PointConstraintCallback;
|
|
1204
1220
|
transition?: Cell.TransitionOptions;
|
|
@@ -1213,9 +1229,26 @@ export declare namespace dia {
|
|
|
1213
1229
|
direction?: Direction;
|
|
1214
1230
|
}
|
|
1215
1231
|
|
|
1216
|
-
export interface
|
|
1232
|
+
export interface FitToChildrenOptions {
|
|
1233
|
+
filter?: (cell: Cell) => boolean;
|
|
1234
|
+
deep?: boolean;
|
|
1235
|
+
padding?: Padding;
|
|
1236
|
+
minRect?: g.Rect;
|
|
1237
|
+
expandOnly?: boolean;
|
|
1238
|
+
shrinkOnly?: boolean;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1241
|
+
export interface FitParentOptions extends FitToChildrenOptions {
|
|
1242
|
+
terminator?: Cell | Cell.ID;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
export interface RotateOptions {
|
|
1217
1246
|
rotate?: boolean;
|
|
1218
1247
|
}
|
|
1248
|
+
|
|
1249
|
+
export interface BBoxOptions extends Cell.EmbeddableOptions, RotateOptions {
|
|
1250
|
+
|
|
1251
|
+
}
|
|
1219
1252
|
}
|
|
1220
1253
|
|
|
1221
1254
|
export class Element<A extends ObjectHash = Element.Attributes, S extends mvc.ModelSetOptions = dia.ModelSetOptions> extends Cell<A, S> {
|
|
@@ -1237,10 +1270,10 @@ export declare namespace dia {
|
|
|
1237
1270
|
|
|
1238
1271
|
scale(scaleX: number, scaleY: number, origin?: Point, opt?: { [key: string]: any }): this;
|
|
1239
1272
|
|
|
1240
|
-
fitEmbeds(opt?:
|
|
1241
|
-
fitToChildren(opt?:
|
|
1273
|
+
fitEmbeds(opt?: Element.FitToChildrenOptions): this;
|
|
1274
|
+
fitToChildren(opt?: Element.FitToChildrenOptions): this;
|
|
1242
1275
|
|
|
1243
|
-
fitParent(opt?:
|
|
1276
|
+
fitParent(opt?: Element.FitParentOptions): this;
|
|
1244
1277
|
|
|
1245
1278
|
getBBox(opt?: Element.BBoxOptions): g.Rect;
|
|
1246
1279
|
|
|
@@ -1267,6 +1300,14 @@ export declare namespace dia {
|
|
|
1267
1300
|
|
|
1268
1301
|
getPortsPositions(groupName: string): { [id: string]: Element.PortPosition };
|
|
1269
1302
|
|
|
1303
|
+
getPortRelativePosition(portId: string): Element.PortPosition;
|
|
1304
|
+
|
|
1305
|
+
getPortRelativeRect(portId: string): Element.PortRect;
|
|
1306
|
+
|
|
1307
|
+
getPortCenter(portId: string): g.Point;
|
|
1308
|
+
|
|
1309
|
+
getPortBBox(portId: string, opt?: Element.RotateOptions): g.Rect;
|
|
1310
|
+
|
|
1270
1311
|
getPortIndex(port: string | Element.Port): number;
|
|
1271
1312
|
|
|
1272
1313
|
getPortGroupNames(): string[];
|
|
@@ -1549,6 +1590,10 @@ export declare namespace dia {
|
|
|
1549
1590
|
|
|
1550
1591
|
isIntersecting(geometryShape: g.Shape, geometryData?: g.SegmentSubdivisionsOpt | null): boolean;
|
|
1551
1592
|
|
|
1593
|
+
cleanNodesCache(): void;
|
|
1594
|
+
|
|
1595
|
+
cleanNodeCache(node: SVGElement): void
|
|
1596
|
+
|
|
1552
1597
|
protected isEnclosedIn(area: g.Rect): boolean;
|
|
1553
1598
|
|
|
1554
1599
|
protected isInArea(area: g.Rect, options: g.StrictOpt): boolean;
|
|
@@ -1605,8 +1650,6 @@ export declare namespace dia {
|
|
|
1605
1650
|
|
|
1606
1651
|
protected addLinkFromMagnet(magnet: SVGElement, x: number, y: number): LinkView;
|
|
1607
1652
|
|
|
1608
|
-
protected cleanNodesCache(): void;
|
|
1609
|
-
|
|
1610
1653
|
protected nodeCache(magnet: SVGElement): CellView.NodeMetrics;
|
|
1611
1654
|
|
|
1612
1655
|
protected getNodeData(magnet: SVGElement): CellView.NodeData;
|
|
@@ -1968,6 +2011,7 @@ export declare namespace dia {
|
|
|
1968
2011
|
export type RestrictTranslateCallback = (elementView: ElementView, x0: number, y0: number) => BBox | boolean | PointConstraintCallback;
|
|
1969
2012
|
export type FindParentByType = 'bbox' | 'pointer' | PositionName;
|
|
1970
2013
|
export type FindParentByCallback = ((this: dia.Graph, elementView: ElementView, evt: dia.Event, x: number, y: number) => Cell[]);
|
|
2014
|
+
export type MeasureNodeCallback = (node: SVGGraphicsElement, cellView: dia.CellView) => g.Rect;
|
|
1971
2015
|
|
|
1972
2016
|
export interface Options extends mvc.ViewOptions<Graph> {
|
|
1973
2017
|
// appearance
|
|
@@ -2003,6 +2047,7 @@ export declare namespace dia {
|
|
|
2003
2047
|
// views
|
|
2004
2048
|
elementView?: typeof ElementView | ((element: Element) => typeof ElementView);
|
|
2005
2049
|
linkView?: typeof LinkView | ((link: Link) => typeof LinkView);
|
|
2050
|
+
measureNode?: MeasureNodeCallback;
|
|
2006
2051
|
// embedding
|
|
2007
2052
|
embeddingMode?: boolean;
|
|
2008
2053
|
frontParentOnly?: boolean;
|
|
@@ -2354,7 +2399,7 @@ export declare namespace dia {
|
|
|
2354
2399
|
|
|
2355
2400
|
getLayerNode(layerName: Paper.Layers | string): SVGGElement;
|
|
2356
2401
|
|
|
2357
|
-
getLayerView(layerName: Paper.Layers | string):
|
|
2402
|
+
getLayerView(layerName: Paper.Layers | string): PaperLayer;
|
|
2358
2403
|
|
|
2359
2404
|
hasLayerView(layerName: Paper.Layers | string): boolean;
|
|
2360
2405
|
|
|
@@ -2364,6 +2409,18 @@ export declare namespace dia {
|
|
|
2364
2409
|
|
|
2365
2410
|
protected resetLayers(): void;
|
|
2366
2411
|
|
|
2412
|
+
addLayer(layerName: string, layerView: PaperLayer, options?: { insertBefore?: string }): void;
|
|
2413
|
+
|
|
2414
|
+
removeLayer(layer: string | PaperLayer): void;
|
|
2415
|
+
|
|
2416
|
+
moveLayer(layer: string | PaperLayer, insertBefore: string | PaperLayer | null): void;
|
|
2417
|
+
|
|
2418
|
+
hasLayer(layer: string | PaperLayer): boolean;
|
|
2419
|
+
|
|
2420
|
+
getLayerNames(): string[];
|
|
2421
|
+
|
|
2422
|
+
getLayers(): Array<PaperLayer>;
|
|
2423
|
+
|
|
2367
2424
|
// rendering
|
|
2368
2425
|
|
|
2369
2426
|
freeze(opt?: Paper.FreezeOptions): void;
|
|
@@ -3563,6 +3620,8 @@ export declare namespace g {
|
|
|
3563
3620
|
|
|
3564
3621
|
moveAndExpand(r: PlainRect): this;
|
|
3565
3622
|
|
|
3623
|
+
moveAroundPoint(origin: PlainPoint | string, angle: number): this;
|
|
3624
|
+
|
|
3566
3625
|
normalize(): this;
|
|
3567
3626
|
|
|
3568
3627
|
offset(dx?: number, dy?: number): this;
|
|
@@ -4666,7 +4725,7 @@ export declare namespace mvc {
|
|
|
4666
4725
|
|
|
4667
4726
|
/**
|
|
4668
4727
|
* Events hash or a method returning the events hash that maps events/selectors to methods on your View.
|
|
4669
|
-
* For assigning events as object hash, do it like this: this.events = <any>{ "event:selector": callback, ... }
|
|
4728
|
+
* For assigning events as object hash, do it like this: `this.events = <any>{ "event:selector": callback, ... };`
|
|
4670
4729
|
* That works only if you set it in the constructor or the initialize method.
|
|
4671
4730
|
*/
|
|
4672
4731
|
events(): EventsHash;
|
|
@@ -5221,11 +5280,7 @@ export declare namespace util {
|
|
|
5221
5280
|
|
|
5222
5281
|
export function parseCssNumeric(val: any, restrictUnits: string | string[]): { value: number, unit?: string } | null;
|
|
5223
5282
|
|
|
5224
|
-
export type
|
|
5225
|
-
text: string,
|
|
5226
|
-
size: { width: number, height?: number },
|
|
5227
|
-
attrs?: attributes.NativeSVGAttributes,
|
|
5228
|
-
opt?: {
|
|
5283
|
+
export type BreakTextOptions = {
|
|
5229
5284
|
svgDocument?: SVGElement;
|
|
5230
5285
|
separator?: string | any;
|
|
5231
5286
|
eol?: string;
|
|
@@ -5234,6 +5289,12 @@ export declare namespace util {
|
|
|
5234
5289
|
maxLineCount?: number;
|
|
5235
5290
|
preserveSpaces?: boolean;
|
|
5236
5291
|
}
|
|
5292
|
+
|
|
5293
|
+
export type BreakTextFunction = (
|
|
5294
|
+
text: string,
|
|
5295
|
+
size: { width: number, height?: number },
|
|
5296
|
+
attrs?: attributes.NativeSVGAttributes,
|
|
5297
|
+
opt?: BreakTextOptions
|
|
5237
5298
|
) => string;
|
|
5238
5299
|
|
|
5239
5300
|
var breakText: BreakTextFunction;
|