modern-path2d 0.2.0 → 0.2.1

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/dist/index.cjs CHANGED
@@ -3089,6 +3089,16 @@ function parseSvg(svg) {
3089
3089
  return parseNode(parseSvgToDom(svg), {});
3090
3090
  }
3091
3091
 
3092
+ function getPathsBoundingBox(paths) {
3093
+ if (!paths.length) {
3094
+ return void 0;
3095
+ }
3096
+ const min = Vector2.MAX;
3097
+ const max = Vector2.MIN;
3098
+ paths.forEach((path) => path.getMinMax(min, max));
3099
+ return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
3100
+ }
3101
+
3092
3102
  exports.BoundingBox = BoundingBox;
3093
3103
  exports.CircleCurve = CircleCurve;
3094
3104
  exports.CubicBezierCurve = CubicBezierCurve;
@@ -3105,6 +3115,7 @@ exports.RectangularCurve = RectangularCurve;
3105
3115
  exports.SplineCurve = SplineCurve;
3106
3116
  exports.Vector2 = Vector2;
3107
3117
  exports.addPathCommandsToPath2D = addPathCommandsToPath2D;
3118
+ exports.getPathsBoundingBox = getPathsBoundingBox;
3108
3119
  exports.parseArcCommand = parseArcCommand;
3109
3120
  exports.parsePathDataArgs = parsePathDataArgs;
3110
3121
  exports.parseSvg = parseSvg;
package/dist/index.d.cts CHANGED
@@ -481,4 +481,6 @@ declare function pathDataToPathCommands(d: string): PathCommand[];
481
481
  declare function parseSvgToDom(svg: string | SVGElement): SVGElement;
482
482
  declare function parseSvg(svg: string | SVGElement): Path2D[];
483
483
 
484
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, type FillRule, HeartCurve, LineCurve, Matrix3, Path2D, type PathCommand, type PathDrawStyle, type PathStyle, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, Vector2, type VectorLike, addPathCommandsToPath2D, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
484
+ declare function getPathsBoundingBox(paths: Path2D[]): BoundingBox | undefined;
485
+
486
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, type FillRule, HeartCurve, LineCurve, Matrix3, Path2D, type PathCommand, type PathDrawStyle, type PathStyle, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, Vector2, type VectorLike, addPathCommandsToPath2D, getPathsBoundingBox, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
package/dist/index.d.mts CHANGED
@@ -481,4 +481,6 @@ declare function pathDataToPathCommands(d: string): PathCommand[];
481
481
  declare function parseSvgToDom(svg: string | SVGElement): SVGElement;
482
482
  declare function parseSvg(svg: string | SVGElement): Path2D[];
483
483
 
484
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, type FillRule, HeartCurve, LineCurve, Matrix3, Path2D, type PathCommand, type PathDrawStyle, type PathStyle, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, Vector2, type VectorLike, addPathCommandsToPath2D, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
484
+ declare function getPathsBoundingBox(paths: Path2D[]): BoundingBox | undefined;
485
+
486
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, type FillRule, HeartCurve, LineCurve, Matrix3, Path2D, type PathCommand, type PathDrawStyle, type PathStyle, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, Vector2, type VectorLike, addPathCommandsToPath2D, getPathsBoundingBox, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
package/dist/index.d.ts CHANGED
@@ -481,4 +481,6 @@ declare function pathDataToPathCommands(d: string): PathCommand[];
481
481
  declare function parseSvgToDom(svg: string | SVGElement): SVGElement;
482
482
  declare function parseSvg(svg: string | SVGElement): Path2D[];
483
483
 
484
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, type FillRule, HeartCurve, LineCurve, Matrix3, Path2D, type PathCommand, type PathDrawStyle, type PathStyle, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, Vector2, type VectorLike, addPathCommandsToPath2D, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
484
+ declare function getPathsBoundingBox(paths: Path2D[]): BoundingBox | undefined;
485
+
486
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, type FillRule, HeartCurve, LineCurve, Matrix3, Path2D, type PathCommand, type PathDrawStyle, type PathStyle, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, type StrokeLinecap, type StrokeLinejoin, Vector2, type VectorLike, addPathCommandsToPath2D, getPathsBoundingBox, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- (function(x,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(x=typeof globalThis<"u"?globalThis:x||self,C(x.modernPath2d={}))})(this,function(x){"use strict";var te=Object.defineProperty;var ee=(x,C,L)=>C in x?te(x,C,{enumerable:!0,configurable:!0,writable:!0,value:L}):x[C]=L;var T=(x,C,L)=>ee(x,typeof C!="symbol"?C+"":C,L);const C={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function L(r,e){const{fill:t="#000",stroke:s="none",strokeWidth:n=s==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:c=0,strokeDasharray:a=[],strokeDashoffset:h=0,shadowOffsetX:l=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:p="rgba(0, 0, 0, 0)"}=e;r.fillStyle=t,r.strokeStyle=s,r.lineWidth=n,r.lineCap=o,r.lineJoin=C[i],r.miterLimit=c,r.setLineDash(a),r.lineDashOffset=h,r.shadowOffsetX=l,r.shadowOffsetY=y,r.shadowBlur=f,r.shadowColor=p}class u{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new u(1/0,1/0)}static get MIN(){return new u(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const s=-e/180*Math.PI,n=this.x-t.x,o=-(this.y-t.y),i=Math.sin(s),c=Math.cos(s);return this.set(t.x+(n*c-o*i),t.y-(n*i+o*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,s={x:0,y:0}){const n=e<0?s.x-this.x+s.x:this.x,o=t<0?s.y-this.y+s.y:this.y;return this.x=n*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,s={x:0,y:0}){const n=this.x-s.x,o=this.y-s.y;return this.x=s.x+(n+Math.tan(e)*o),this.y=s.y+(o+Math.tan(t)*n),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new u(this.x,this.y)}}class q{constructor(e=0,t=0,s=0,n=0){this.left=e,this.top=t,this.width=s,this.height=n}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){if(e.length===0)return new q;if(e.length===1)return e[0].clone();const t=e[0],s=e.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new q(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new u((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new q(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class b{constructor(e=1,t=0,s=0,n=0,o=1,i=0,c=0,a=0,h=1){T(this,"elements",[]);this.set(e,t,s,n,o,i,c,a,h)}set(e,t,s,n,o,i,c,a,h){const l=this.elements;return l[0]=e,l[1]=n,l[2]=c,l[3]=t,l[4]=o,l[5]=a,l[6]=s,l[7]=i,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,o=this.elements,i=s[0],c=s[3],a=s[6],h=s[1],l=s[4],y=s[7],f=s[2],p=s[5],g=s[8],d=n[0],M=n[3],w=n[6],$=n[1],v=n[4],S=n[7],N=n[2],z=n[5],D=n[8];return o[0]=i*d+c*$+a*N,o[3]=i*M+c*v+a*z,o[6]=i*w+c*S+a*D,o[1]=h*d+l*$+y*N,o[4]=h*M+l*v+y*z,o[7]=h*w+l*S+y*D,o[2]=f*d+p*$+g*N,o[5]=f*M+p*v+g*z,o[8]=f*w+p*S+g*D,this}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],o=e[3],i=e[4],c=e[5],a=e[6],h=e[7],l=e[8],y=l*i-c*h,f=c*a-l*o,p=h*o-i*a,g=t*y+s*f+n*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const d=1/g;return e[0]=y*d,e[1]=(n*h-l*s)*d,e[2]=(c*s-n*i)*d,e[3]=f*d,e[4]=(l*t-n*a)*d,e[5]=(n*o-c*t)*d,e[6]=p*d,e[7]=(s*a-h*t)*d,e[8]=(i*t-s*o)*d,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(W.makeScale(e,t)),this}rotate(e){return this.premultiply(W.makeRotation(-e)),this}translate(e,t){return this.premultiply(W.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const W=new b;function Z(r,e,t,s){const n=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let i=Math.acos(Math.max(-1,Math.min(1,n/o)));return r*s-e*t<0&&(i=-i),i}function J(r,e,t,s,n,o,i,c){if(e===0||t===0){r.lineTo(c.x,c.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const a=(i.x-c.x)/2,h=(i.y-c.y)/2,l=Math.cos(s)*a+Math.sin(s)*h,y=-Math.sin(s)*a+Math.cos(s)*h;let f=e*e,p=t*t;const g=l*l,d=y*y,M=g/f+d/p;if(M>1){const wt=Math.sqrt(M);e=wt*e,t=wt*t,f=e*e,p=t*t}const w=f*d+p*g,$=(f*p-w)/w;let v=Math.sqrt(Math.max(0,$));n===o&&(v=-v);const S=v*e*y/t,N=-v*t*l/e,z=Math.cos(s)*S-Math.sin(s)*N+(i.x+c.x)/2,D=Math.sin(s)*S+Math.cos(s)*N+(i.y+c.y)/2,Y=Z(1,0,(l-S)/e,(y-N)/t),j=Z((l-S)/e,(y-N)/t,(-l-S)/e,(-y-N)/t)%(Math.PI*2);r.ellipse(z,D,e,t,s,Y,Y+j,o===1)}function X(r,e){return r-(e-r)}function B(r,e){const t=new u,s=new u;for(let n=0,o=r.length;n<o;n++){const i=r[n];if(i.type==="m"||i.type==="M")i.type==="m"?t.add(i):t.copy(i),e.moveTo(t.x,t.y),s.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?t.add(i):t.copy(i),e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(X(t.x,s.x),X(t.y,s.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(X(t.x,s.x),X(t.y,s.y),i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),s.x=t.x+i.x1,s.y=t.y+i.y1,t.add(i)):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),s.x=i.x1,s.y=i.y1,t.copy(i));else if(i.type==="t"||i.type==="T"){const c=X(t.x,s.x),a=X(t.y,s.y);s.x=c,s.y=a,i.type==="t"?(e.quadraticCurveTo(c,a,t.x+i.x,t.y+i.y),t.add(i)):(e.quadraticCurveTo(c,a,i.x,i.y),t.copy(i))}else if(i.type==="a"||i.type==="A"){const c=t.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.add(i)}else{if(t.equals(i))continue;t.copy(i)}s.copy(t),J(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,c,t)}else i.type==="z"||i.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",i)}}const m={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function A(r,e,t=0){let c=0,a=!0,h="",l="";const y=[];function f(M,w,$){const v=new SyntaxError(`Unexpected character "${M}" at index ${w}.`);throw v.partial=$,v}function p(){h!==""&&(l===""?y.push(Number(h)):y.push(Number(h)*10**Number(l))),h="",l=""}let g;const d=r.length;for(let M=0;M<d;M++){if(g=r[M],Array.isArray(e)&&e.includes(y.length%t)&&m.FLAGS.test(g)){c=1,h=g,p();continue}if(c===0){if(m.WHITESPACE.test(g))continue;if(m.DIGIT.test(g)||m.SIGN.test(g)){c=1,h=g;continue}if(m.POINT.test(g)){c=2,h=g;continue}m.COMMA.test(g)&&(a&&f(g,M,y),a=!0)}if(c===1){if(m.DIGIT.test(g)){h+=g;continue}if(m.POINT.test(g)){h+=g,c=2;continue}if(m.EXP.test(g)){c=3;continue}m.SIGN.test(g)&&h.length===1&&m.SIGN.test(h[0])&&f(g,M,y)}if(c===2){if(m.DIGIT.test(g)){h+=g;continue}if(m.EXP.test(g)){c=3;continue}m.POINT.test(g)&&h[h.length-1]==="."&&f(g,M,y)}if(c===3){if(m.DIGIT.test(g)){l+=g;continue}if(m.SIGN.test(g)){if(l===""){l+=g;continue}l.length===1&&m.SIGN.test(l)&&f(g,M,y)}}m.WHITESPACE.test(g)?(p(),c=0,a=!1):m.COMMA.test(g)?(p(),c=0,a=!0):m.SIGN.test(g)?(p(),c=1,h=g):m.POINT.test(g)?(p(),c=2,h=g):f(g,M,y)}return p(),y}function Tt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function K(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${Tt(r[t])} `;return e}const Ct=/[a-df-z][^a-df-z]*/gi;function G(r){const e=[],t=r.match(Ct);if(!t)return e;for(let s=0,n=t.length;s<n;s++){const o=t[s],i=o.charAt(0),c=o.slice(1).trim();let a;switch(i){case"m":case"M":a=A(c);for(let h=0,l=a.length;h<l;h+=2)h===0?e.push({type:i,x:a[h],y:a[h+1]}):e.push({type:i==="m"?"l":"L",x:a[h],y:a[h+1]});break;case"h":case"H":a=A(c);for(let h=0,l=a.length;h<l;h++)e.push({type:i,x:a[h]});break;case"v":case"V":a=A(c);for(let h=0,l=a.length;h<l;h++)e.push({type:i,y:a[h]});break;case"l":case"L":a=A(c);for(let h=0,l=a.length;h<l;h+=2)e.push({type:i,x:a[h],y:a[h+1]});break;case"c":case"C":a=A(c);for(let h=0,l=a.length;h<l;h+=6)e.push({type:i,x1:a[h],y1:a[h+1],x2:a[h+2],y2:a[h+3],x:a[h+4],y:a[h+5]});break;case"s":case"S":a=A(c);for(let h=0,l=a.length;h<l;h+=4)e.push({type:i,x2:a[h],y2:a[h+1],x:a[h+2],y:a[h+3]});break;case"q":case"Q":a=A(c);for(let h=0,l=a.length;h<l;h+=4)e.push({type:i,x1:a[h],y1:a[h+1],x:a[h+2],y:a[h+3]});break;case"t":case"T":a=A(c);for(let h=0,l=a.length;h<l;h+=2)e.push({type:i,x:a[h],y:a[h+1]});break;case"a":case"A":a=A(c,[3,4],7);for(let h=0,l=a.length;h<l;h+=7)e.push({type:i,rx:a[h],ry:a[h+1],angle:a[h+2],largeArcFlag:a[h+3],sweepFlag:a[h+4],x:a[h+5],y:a[h+6]});break;case"z":case"Z":e.push({type:i});break;default:console.warn(o)}}return e}class k{constructor(){T(this,"arcLengthDivisions",200);T(this,"_cacheArcLengths");T(this,"_needsUpdate",!1)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),s=this.getPoint(1);return(t.x-e.x)*(s.y-t.y)-(t.y-e.y)*(s.x-t.x)<0}getPointAt(e,t=new u){return this.getPoint(this.getUToTMapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}forEachControlPoints(e){return this.getControlPoints().forEach(e),this}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,n=this.getPoint(0),o=0;t.push(0);for(let i=1;i<=e;i++)s=this.getPoint(i/e),o+=s.distanceTo(n),t.push(o),n=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(e,t){const s=this.getLengths();let n=0;const o=s.length;let i;t?i=t:i=e*s[o-1];let c=0,a=o-1,h;for(;c<=a;)if(n=Math.floor(c+(a-c)/2),h=s[n]-i,h<0)c=n+1;else if(h>0)a=n-1;else{a=n;break}if(n=a,s[n]===i)return n/(o-1);const l=s[n],f=s[n+1]-l,p=(i-l)/f;return(n+p)/(o-1)}getTangent(e,t=new u){const n=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(n)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new u){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let s=0,n=1,o=(s+n)/2;for(;n-s>t;){o=(s+n)/2;const i=this.getPoint(o);if(i.distanceTo(e)<t)return o;i.x<e.x?s=o:n=o}return o}matrix(e){return this.forEachControlPoints(t=>t.applyMatrix3(e)),this}getMinMax(e=u.MAX,t=u.MIN){return this.getPoints().forEach(s=>{e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),t.x=Math.max(t.x,s.x),t.y=Math.max(t.y,s.y)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new q(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}toData(){return K(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class _ extends k{constructor(e,t,s=0,n=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=n}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().scale(t))}getTangent(e,t=new u){const{x:s,y:n}=this.getNormal(e);return t.set(-n,s)}getNormal(e,t=new u){const{start:s,end:n}=this,o=e*(n-s)+s-.5*Math.PI;return t.set(Math.cos(o),Math.sin(o))}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function tt(r,e,t,s,n){const o=(s-e)*.5,i=(n-t)*.5,c=r*r,a=r*c;return(2*t-2*s+o+i)*a+(-3*t+3*s-2*o-i)*c+o*r+t}function vt(r,e){const t=1-r;return t*t*e}function bt(r,e){return 2*(1-r)*r*e}function At(r,e){return r*r*e}function et(r,e,t,s){return vt(r,e)+bt(r,t)+At(r,s)}function kt(r,e){const t=1-r;return t*t*t*e}function It(r,e){const t=1-r;return 3*t*t*r*e}function St(r,e){return 3*(1-r)*r*r*e}function Nt(r,e){return r*r*r*e}function st(r,e,t,s,n){return kt(r,e)+It(r,t)+St(r,s)+Nt(r,n)}class nt extends k{constructor(e=new u,t=new u,s=new u,n=new u){super(),this.start=e,this.startControl=t,this.endControl=s,this.end=n}getPoint(e,t=new u){const{start:s,startControl:n,endControl:o,end:i}=this;return t.set(st(e,s.x,n.x,o.x,i.x),st(e,s.y,n.y,o.y,i.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(e,t,s){const n=t*t-4*e*s;if(n<0)return[];const o=Math.sqrt(n),i=(-t+o)/(2*e),c=(-t-o)/(2*e);return[i,c].filter(a=>a>=0&&a<=1)}getMinMax(e=u.MAX,t=u.MIN){const s=this.start,n=this.startControl,o=this.endControl,i=this.end,c=this._solveQuadratic(3*(n.x-s.x),6*(o.x-n.x),3*(i.x-o.x)),a=this._solveQuadratic(3*(n.y-s.y),6*(o.y-n.y),3*(i.y-o.y)),h=[0,1,...c,...a];return((y,f)=>{for(const p of y)for(let g=0;g<=f;g++){const d=g/f-.5,M=Math.min(1,Math.max(0,p+d)),w=this.getPoint(M);e.x=Math.min(e.x,w.x),e.y=Math.min(e.y,w.y),t.x=Math.max(t.x,w.x),t.y=Math.max(t.y,w.y)}})(h,10),{min:e,max:t}}toCommands(){const{start:e,startControl:t,endControl:s,end:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:n.x,y:n.y}]}drawTo(e){const{start:t,startControl:s,endControl:n,end:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(s.x,s.y,n.x,n.y,o.x,o.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const Et=new b,rt=new b,it=new b,F=new u;class ot extends k{constructor(e=new u,t=1,s=1,n=0,o=0,i=Math.PI*2,c=!1){super(),this.center=e,this.radiusX=t,this.radiusY=s,this.rotation=n,this.startAngle=o,this.endAngle=i,this.clockwise=c}isClockwise(){return this.clockwise}getPoint(e,t=new u){const s=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(o?n=0:n=s),this.clockwise&&!o&&(n===s?n=-s:n=n-s);const i=this.startAngle+e*n;let c=this.center.x+this.radiusX*Math.cos(i),a=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const h=Math.cos(this.rotation),l=Math.sin(this.rotation),y=c-this.center.x,f=a-this.center.y;c=y*h-f*l+this.center.x,a=y*l+f*h+this.center.y}return t.set(c,a)}toCommands(){const{center:e,radiusX:t,radiusY:s,startAngle:n,endAngle:o,clockwise:i,rotation:c}=this,{x:a,y:h}=e,l=a+t*Math.cos(n)*Math.cos(c)-s*Math.sin(n)*Math.sin(c),y=h+t*Math.cos(n)*Math.sin(c)+s*Math.sin(n)*Math.cos(c),f=Math.abs(n-o),p=f>Math.PI?1:0,g=i?1:0,d=c*180/Math.PI;if(f>=2*Math.PI){const M=n+Math.PI,w=a+t*Math.cos(M)*Math.cos(c)-s*Math.sin(M)*Math.sin(c),$=h+t*Math.cos(M)*Math.sin(c)+s*Math.sin(M)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:d,largeArcFlag:0,sweepFlag:g,x:w,y:$},{type:"A",rx:t,ry:s,angle:d,largeArcFlag:0,sweepFlag:g,x:l,y}]}else{const M=a+t*Math.cos(o)*Math.cos(c)-s*Math.sin(o)*Math.sin(c),w=h+t*Math.cos(o)*Math.sin(c)+s*Math.sin(o)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:d,largeArcFlag:p,sweepFlag:g,x:M,y:w}]}}drawTo(e){const{center:t,radiusX:s,radiusY:n,rotation:o,startAngle:i,endAngle:c,clockwise:a}=this;return e.ellipse(t.x,t.y,s,n,o,i,c,!a),this}matrix(e){return F.set(this.center.x,this.center.y),F.applyMatrix3(e),this.center.x=F.x,this.center.y=F.y,qt(e)?$t(this,e):Lt(this,e),this}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){const{center:s,radiusX:n,radiusY:o,rotation:i}=this,{x:c,y:a}=s,h=Math.cos(i),l=Math.sin(i),y=Math.sqrt(n*n*h*h+o*o*l*l),f=Math.sqrt(n*n*l*l+o*o*h*h);return e.x=Math.min(e.x,c-y),e.y=Math.min(e.y,a-f),t.x=Math.max(t.x,c+y),t.y=Math.max(t.y,a+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function $t(r,e){const t=r.radiusX,s=r.radiusY,n=Math.cos(r.rotation),o=Math.sin(r.rotation),i=new u(t*n,t*o),c=new u(-s*o,s*n),a=i.applyMatrix3(e),h=c.applyMatrix3(e),l=Et.set(a.x,h.x,0,a.y,h.y,0,0,0,1),y=rt.copy(l).invert(),g=it.copy(y).transpose().multiply(y).elements,d=zt(g[0],g[1],g[4]),M=Math.sqrt(d.rt1),w=Math.sqrt(d.rt2);if(r.radiusX=1/M,r.radiusY=1/w,r.rotation=Math.atan2(d.sn,d.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=rt.set(M,0,0,0,w,0,0,0,1),S=it.set(d.cs,d.sn,0,-d.sn,d.cs,0,0,0,1),N=v.multiply(S).multiply(l),z=D=>{const{x:Y,y:j}=new u(Math.cos(D),Math.sin(D)).applyMatrix3(N);return Math.atan2(j,Y)};r.startAngle=z(r.startAngle),r.endAngle=z(r.endAngle),ht(e)&&(r.clockwise=!r.clockwise)}}function Lt(r,e){const t=at(e),s=ct(e);r.radiusX*=t,r.radiusY*=s;const n=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=n,ht(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function ht(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function qt(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=at(r),n=ct(r);return Math.abs(t/(s*n))>Number.EPSILON}function at(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ct(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function zt(r,e,t){let s,n,o,i,c;const a=r+t,h=r-t,l=Math.sqrt(h*h+4*e*e);return a>0?(s=.5*(a+l),c=1/s,n=r*c*t-e*c*e):a<0?n=.5*(a-l):(s=.5*l,n=-.5*l),h>0?o=h+l:o=h-l,Math.abs(o)>2*Math.abs(e)?(c=-2*e/o,i=1/Math.sqrt(1+c*c),o=c*i):Math.abs(e)===0?(o=1,i=0):(c=-.5*o/e,o=1/Math.sqrt(1+c*c),i=c*o),h>0&&(c=o,o=-i,i=c),{rt1:s,rt2:n,cs:o,sn:i}}class O extends k{constructor(e=new u,t=new u){super(),this.start=e,this.end=t}getPoint(e,t=new u){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new u){return this.getPoint(e,t)}getTangent(e,t=new u){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new u){return this.getTangent(e,t)}getControlPoints(){return[this.start,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,end:n}=this;return e.x=Math.min(e.x,s.x,n.x),e.y=Math.min(e.y,s.y,n.y),t.x=Math.max(t.x,s.x,n.x),t.y=Math.max(t.y,s.y,n.y),{min:e,max:t}}toCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{start:t,end:s}=this;return e.lineTo(t.x,t.y),e.lineTo(s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class Dt extends k{constructor(t,s,n=0,o=1){super();T(this,"curveT",0);this.center=t,this.size=s,this.start=n,this.end=o,this.update()}update(){const{x:t,y:s}=this.center,n=new u(t+.5*this.size,s-.5*this.size),o=new u(t-.5*this.size,s-.5*this.size),i=new u(t,s+.5*this.size),c=new _(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),a=new _(o,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),h=new _(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),l=new u(t,s+this.size),y=new u(t+this.size,s),f=new u().lerpVectors(y,l,.75),p=new u(t-this.size,s),g=new u().lerpVectors(p,l,.75),d=new O(y,f),M=new O(g,p);return this.curves=[c,d,h,M,a],this}getPoint(t){return this.getCurve(t).getPoint(this.curveT)}getPointAt(t){return this.getPoint(t)}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let n;const o=.5*Math.PI;return s<o?(n=0,this.curveT=s/o):s<o+.75?(n=1,this.curveT=(s-o)/.75):s<5*Math.PI/8+.75?(n=2,this.curveT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(n=3,this.curveT=(s-5*Math.PI/8-.75)/.75):(n=4,this.curveT=(s-5*Math.PI/8-1.5)/o),this.curves[n]}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class Ot extends k{constructor(t,s=0,n=0,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);T(this,"points",[]);this.center=t,this.radius=s,this.number=n,this.start=o,this.end=i,this.update()}update(){for(let t=0;t<this.number;t++){let s=t*2*Math.PI/this.number;s-=.5*Math.PI,this.points.push(new u(this.radius*Math.cos(s),this.radius*Math.sin(s)).add(this.center))}for(let t=0;t<this.number;t++)this.curves.push(new O(this.points[t],this.points[(t+1)%this.number]));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const n=s*this.number,o=Math.floor(n);return this.curveT=n-o,this.curves[o]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class lt extends k{constructor(e=new u,t=new u,s=new u){super(),this.start=e,this.control=t,this.end=s}getPoint(e,t=new u){const{start:s,control:n,end:o}=this;return t.set(et(e,s.x,n.x,o.x),et(e,s.y,n.y,o.y)),t}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,control:n,end:o}=this,i=.5*(s.x+n.x),c=.5*(s.y+n.y),a=.5*(s.x+o.x),h=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,i,a),e.y=Math.min(e.y,s.y,o.y,c,h),t.x=Math.max(t.x,s.x,o.x,i,a),t.y=Math.max(t.y,s.y,o.y,c,h),{min:e,max:t}}toCommands(){const{start:e,control:t,end:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{start:t,control:s,end:n}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(s.x,s.y,n.x,n.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class ut extends k{constructor(t,s,n=1,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);this.center=t,this.rx=s,this.aspectRatio=n,this.start=o,this.end=i,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:s}=this.center,n=this.rx,o=this.rx/this.aspectRatio,i=[new u(t-n,s-o),new u(t+n,s-o),new u(t+n,s+o),new u(t-n,s+o)];for(let c=0;c<4;c++)this.curves.push(new O(i[c].clone(),i[(c+1)%4].clone()));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let n;return s<this.aspectRatio?(n=0,this.curveT=s/this.aspectRatio):s<this.aspectRatio+1?(n=1,this.curveT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(n=2,this.curveT=(s-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=(s-2*this.aspectRatio-1)/1),this.curves[n]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class yt extends k{constructor(e=[]){super(),this.points=e}getPoint(e,t=new u){const{points:s}=this,n=(s.length-1)*e,o=Math.floor(n),i=n-o,c=s[o===0?o:o-1],a=s[o],h=s[o>s.length-2?s.length-1:o+1],l=s[o>s.length-3?s.length-1:o+2];return t.set(tt(i,c.x,a.x,h.x,l.x),tt(i,c.y,a.y,h.y,l.y)),t}getControlPoints(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class R extends k{constructor(t){super();T(this,"curves",[]);T(this,"startPoint");T(this,"currentPoint",new u);T(this,"autoClose",!1);T(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,n=t.length;s<n;s++){const{x:o,y:i}=t[s];this.lineTo(o,i)}return this}addCommands(t){return B(t,this),this}addData(t){return this.addCommands(G(t)),this}getPoint(t,s=new u){const n=t*this.getLength(),o=this.getCurveLengths();let i=0;for(;i<o.length;){if(o[i]>=n){const c=o[i]-n,a=this.curves[i],h=a.getLength();return a.getPointAt(h===0?0:1-c/h,s)}i++}return s}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let n=0,o=this.curves.length;n<o;n++)s+=this.curves[n].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let n=0;n<=t;n++)s.push(this.getPoint(n/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[],n=this.curves;let o;for(let i=0,c=n.length;i<c;i++){const h=n[i].getPoints(t);for(let l=0;l<h.length;l++){const y=h[l];o!=null&&o.equals(y)||(s.push(y),o=y)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const s=this.currentPoint;t.equals(s)||(this.curves.push(new O(s.clone(),t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,s){return this.currentPoint.set(t,s),this.startPoint=this.currentPoint.clone(),this}lineTo(t,s){return this.currentPoint.equals({x:t,y:s})||this.curves.push(new O(this.currentPoint.clone(),new u(t,s))),this._setCurrentPoint({x:t,y:s}),this}bezierCurveTo(t,s,n,o,i,c){return this.currentPoint.equals({x:i,y:c})||this.curves.push(new nt(this.currentPoint.clone(),new u(t,s),new u(n,o),new u(i,c))),this._setCurrentPoint({x:i,y:c}),this}quadraticCurveTo(t,s,n,o){return this.currentPoint.equals({x:n,y:o})||this.curves.push(new lt(this.currentPoint.clone(),new u(t,s),new u(n,o))),this._setCurrentPoint({x:n,y:o}),this}arc(t,s,n,o,i,c){return this.ellipse(t,s,n,n,0,o,i,c),this}relativeArc(t,s,n,o,i,c){const a=this.currentPoint;return this.arc(t+a.x,s+a.y,n,o,i,c),this}arcTo(t,s,n,o,i){return console.warn("Method arcTo not supported yet"),this}ellipse(t,s,n,o,i,c,a,h=!0){const l=new ot(new u(t,s),n,o,i,c,a,!h);if(this.curves.length>0){const y=l.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,s,n,o,i,c,a,h){const l=this.currentPoint;return this.ellipse(t+l.x,s+l.y,n,o,i,c,a,h),this}rect(t,s,n,o){return this.curves.push(new ut(new u(t+n/2,s+o/2),n/2,n/o)),this._setCurrentPoint({x:t,y:s}),this}splineThru(t){return this.curves.push(new yt([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getBoundingBox(){const{min:t,max:s}=this.getMinMax();return new q(t.x,t.y,s.x-t.x,s.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var n;const s=(n=this.curves[0])==null?void 0:n.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,n=t.curves.length;s<n;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function Xt(r){return r.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Rt(r,e,t,s){const n=e.clone().sub(r),o=s.clone().sub(t),i=t.clone().sub(r),c=n.cross(o);if(c===0)return new u((r.x+t.x)/2,(r.y+t.y)/2);const a=i.cross(o)/c;return Math.abs(a)>1?new u((r.x+t.x)/2,(r.y+t.y)/2):new u(r.x+a*n.x,r.y+a*n.y)}class I{constructor(e){T(this,"currentPath",new R);T(this,"paths",[this.currentPath]);T(this,"style",{});e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new R().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:s,curves:n}=this.currentPath;return s.equals({x:e,y:t})||(n.length?(this.currentPath=new R().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,n,o,i){return this.currentPath.bezierCurveTo(e,t,s,n,o,i),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}arc(e,t,s,n,o,i){return this.currentPath.arc(e,t,s,n,o,i),this}arcTo(e,t,s,n,o){return this.currentPath.arcTo(e,t,s,n,o),this}ellipse(e,t,s,n,o,i,c,a){return this.currentPath.ellipse(e,t,s,n,o,i,c,a),this}rect(e,t,s,n){return this.currentPath.rect(e,t,s,n),this}addCommands(e){return B(e,this),this}addData(e){return this.addCommands(G(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}getControlPoints(){return this.paths.flatMap(e=>e.getControlPoints())}getCurves(){return this.paths.flatMap(e=>e.curves)}scale(e,t=e,s={x:0,y:0}){return this.getControlPoints().forEach(n=>{n.scale(e,t,s)}),this}skew(e,t=0,s={x:0,y:0}){return this.getControlPoints().forEach(n=>{n.skew(e,t,s)}),this}rotate(e,t={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getCurves(),s=[],n=[],o=[];t.forEach((c,a)=>{const h=c.getControlPoints(),l=c.isClockwise();o[a]=h,n[a]=l;const y=h[0],f=h[h.length-1]??y;s.push({start:l?f:y,end:l?y:f,index:a})});const i=[];return s.forEach((c,a)=>{i[a]=[],s.forEach((h,l)=>{l!==a&&h.start.equals(c.end)&&i[a].push(h.index)})}),t.forEach((c,a)=>{const h=n[a];o[a].forEach(y=>{const f=c.getTForPoint(y),p=c.getNormal(f).scale(h?e:-e);y.add(p)})}),i.forEach((c,a)=>{const h=o[a];c.forEach(l=>{const y=o[l],f=Rt(h[h.length-1],h[h.length-2]??h[h.length-1],y[0],y[1]??y[0]);f&&(h[h.length-1].copy(f),y[0].copy(f))})}),this}matrix(e){return this.getCurves().forEach(t=>t.matrix(e)),this}getMinMax(e=u.MAX,t=u.MIN,s=!0){if(this.getCurves().forEach(n=>n.getMinMax(e,t)),s){const n=this.strokeWidth/2;e.x-=n,e.y-=n,t.x+=n,t.y+=n}return{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:s}=this.getMinMax(void 0,void 0,e);return new q(t.x,t.y,s.x-t.x,s.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:n="none"}=t;return e.beginPath(),e.save(),L(e,t),this.paths.forEach(o=>{o.drawTo(e)}),s!=="none"&&e.fill(),n!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:n="none"}=t;return e.beginPath(),e.save(),L(e,t),this.getControlPoints().forEach(o=>{e.moveTo(o.x,o.y),e.arc(o.x,o.y,4,0,Math.PI*2)}),s!=="none"&&e.fill(),n!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.paths.flatMap(e=>e.toCommands())}toData(){return this.paths.map(e=>e.toData()).join(" ")}toSvgPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const n in e)e[n]!==void 0&&(t[Xt(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const n in t)t[n]!==void 0&&(s+=`${n}:${t[n]};`);return`<path d="${this.toData()}" style="${s}"></path>`}toSvgString(){const{x:e,y:t,width:s,height:n}=this.getBoundingBox(),o=this.toSvgPathString();return`<svg viewBox="${e} ${t} ${s} ${n}" width="${s}px" height="${n}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...s}=e,{left:n,top:o,width:i,height:c}=this.getBoundingBox(),a=document.createElement("canvas");a.width=i*t,a.height=c*t,a.style.width=`${i}px`,a.style.height=`${c}px`;const h=a.getContext("2d");return h&&(h.scale(t,t),h.translate(-n,-o),this.drawTo(h,s)),a}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}clone(){return new this.constructor().copy(this)}}const Q="px",gt=90,ft=["mm","cm","in","pt","pc","px"],V={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function P(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,n=ft.length;s<n;s++){const o=ft[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&Q!=="px"?t=V.in[Q]/gt:(t=V[e][Q],t<0&&(t=V[e].in*gt)),t*Number.parseFloat(r)}const _t=new b,U=new b,pt=new b,dt=new b;function Ft(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=Ut(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Ut(r){const e=new b,t=_t;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(P(r.getAttribute("x")),P(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let n=s.length-1;n>=0;n--){const o=s[n].trim();if(o==="")continue;const i=o.indexOf("("),c=o.length;if(i>0&&i<c){const a=o.slice(0,i),h=A(o.slice(i+1));switch(t.identity(),a){case"translate":if(h.length>=1){const l=h[0];let y=0;h.length>=2&&(y=h[1]),t.translate(l,y)}break;case"rotate":if(h.length>=1){let l=0,y=0,f=0;l=h[0]*Math.PI/180,h.length>=3&&(y=h[1],f=h[2]),U.makeTranslation(-y,-f),pt.makeRotation(l),dt.multiplyMatrices(pt,U),U.makeTranslation(y,f),t.multiplyMatrices(U,dt)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function Yt(r){return new I().addPath(new R().arc(P(r.getAttribute("cx")||0),P(r.getAttribute("cy")||0),P(r.getAttribute("r")||0),0,Math.PI*2))}function Wt(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const n=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<n.length;o++){const i=Object.fromEntries(Object.entries(s.style).filter(([,c])=>c!==""));e[n[o]]=Object.assign(e[n[o]]||{},i)}}}function Bt(r){return new I().addPath(new R().ellipse(P(r.getAttribute("cx")||0),P(r.getAttribute("cy")||0),P(r.getAttribute("rx")||0),P(r.getAttribute("ry")||0),0,0,Math.PI*2))}function Gt(r){return new I().moveTo(P(r.getAttribute("x1")||0),P(r.getAttribute("y1")||0)).lineTo(P(r.getAttribute("x2")||0),P(r.getAttribute("y2")||0))}function Qt(r){const e=new I,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Vt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Ht(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Vt,(n,o,i)=>{const c=P(o),a=P(i);return t===0?e.moveTo(c,a):e.lineTo(c,a),t++,n}),e.currentPath.autoClose=!0,e}const jt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Zt(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(jt,(n,o,i)=>{const c=P(o),a=P(i);return t===0?e.moveTo(c,a):e.lineTo(c,a),t++,n}),e.currentPath.autoClose=!1,e}function Jt(r){const e=P(r.getAttribute("x")||0),t=P(r.getAttribute("y")||0),s=P(r.getAttribute("rx")||r.getAttribute("ry")||0),n=P(r.getAttribute("ry")||r.getAttribute("rx")||0),o=P(r.getAttribute("width")),i=P(r.getAttribute("height")),c=1-.551915024494,a=new I;return a.moveTo(e+s,t),a.lineTo(e+o-s,t),(s!==0||n!==0)&&a.bezierCurveTo(e+o-s*c,t,e+o,t+n*c,e+o,t+n),a.lineTo(e+o,t+i-n),(s!==0||n!==0)&&a.bezierCurveTo(e+o,t+i-n*c,e+o-s*c,t+i,e+o-s,t+i),a.lineTo(e+s,t+i),(s!==0||n!==0)&&a.bezierCurveTo(e+s*c,t+i,e,t+i-n*c,e,t+i-n),a.lineTo(e,t+n),(s!==0||n!==0)&&a.bezierCurveTo(e,t+n*c,e+s*c,t,e+s,t),a}function E(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const a=r.getAttribute("class").split(/\s/).filter(Boolean).map(h=>h.trim());for(let h=0;h<a.length;h++)s=Object.assign(s,t[`.${a[h]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function n(a,h,l){l===void 0&&(l=function(f){return f.startsWith("url")&&console.warn("url access in attributes is not implemented."),f}),r.hasAttribute(a)&&(e[h]=l(r.getAttribute(a))),s[a]&&(e[h]=l(s[a])),r.style&&r.style[a]!==""&&(e[h]=l(r.style[a]))}function o(a){return Math.max(0,Math.min(1,P(a)))}function i(a){return Math.max(0,P(a))}function c(a){return a.split(" ").filter(h=>h!=="").map(h=>P(h))}return n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",i),n("stroke-linecap","strokeLinecap"),n("stroke-linejoin","strokeLinejoin"),n("stroke-miterlimit","strokeMiterlimit",i),n("stroke-dasharray","strokeDasharray",c),n("stroke-dashoffset","strokeDashoffset",P),n("visibility","visibility"),e}function H(r,e,t=[]){var l;if(r.nodeType!==1)return t;let s=!1,n=null;const o={};switch(r.nodeName){case"svg":e=E(r,e,o);break;case"style":Wt(r,o);break;case"g":e=E(r,e,o);break;case"path":e=E(r,e,o),r.hasAttribute("d")&&(n=Qt(r));break;case"rect":e=E(r,e,o),n=Jt(r);break;case"polygon":e=E(r,e,o),n=Ht(r);break;case"polyline":e=E(r,e,o),n=Zt(r);break;case"circle":e=E(r,e,o),n=Yt(r);break;case"ellipse":e=E(r,e,o),n=Bt(r);break;case"line":e=E(r,e,o),n=Gt(r);break;case"defs":s=!0;break;case"use":{e=E(r,e,o);const f=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),p=(l=r.viewportElement)==null?void 0:l.getElementById(f);p?H(p,e,t):console.warn(`'use node' references non-existent node id: ${f}`);break}default:console.warn(r);break}const i=new b,c=[],a=Ft(r,i,c);n&&(n.matrix(i),t.push(n),n.style=e);const h=r.childNodes;for(let y=0,f=h.length;y<f;y++){const p=h[y];s&&p.nodeName!=="style"&&p.nodeName!=="defs"||H(p,e,t)}return a&&(c.pop(),c.length>0?i.copy(c[c.length-1]):i.identity()),t}const xt="data:image/svg+xml;",Mt=`${xt}base64,`,Pt=`${xt}charset=utf8,`;function mt(r){if(typeof r=="string"){let e;return r.startsWith(Mt)?(r=r.substring(Mt.length,r.length),e=atob(r)):r.startsWith(Pt)?(r=r.substring(Pt.length,r.length),e=decodeURIComponent(r)):e=r,new DOMParser().parseFromString(e,"image/svg+xml").documentElement}else return r}function Kt(r){return H(mt(r),{})}x.BoundingBox=q,x.CircleCurve=_,x.CubicBezierCurve=nt,x.Curve=k,x.CurvePath=R,x.EllipseCurve=ot,x.HeartCurve=Dt,x.LineCurve=O,x.Matrix3=b,x.Path2D=I,x.PloygonCurve=Ot,x.QuadraticBezierCurve=lt,x.RectangularCurve=ut,x.SplineCurve=yt,x.Vector2=u,x.addPathCommandsToPath2D=B,x.parseArcCommand=J,x.parsePathDataArgs=A,x.parseSvg=Kt,x.parseSvgToDom=mt,x.pathCommandsToPathData=K,x.pathDataToPathCommands=G,x.setCanvasContext=L,Object.defineProperty(x,Symbol.toStringTag,{value:"Module"})});
1
+ (function(d,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(d=typeof globalThis<"u"?globalThis:d||self,C(d.modernPath2d={}))})(this,function(d){"use strict";var ee=Object.defineProperty;var se=(d,C,q)=>C in d?ee(d,C,{enumerable:!0,configurable:!0,writable:!0,value:q}):d[C]=q;var T=(d,C,q)=>se(d,typeof C!="symbol"?C+"":C,q);const C={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function q(r,e){const{fill:t="#000",stroke:s="none",strokeWidth:n=s==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:i="miter",strokeMiterlimit:c=0,strokeDasharray:a=[],strokeDashoffset:h=0,shadowOffsetX:l=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:p="rgba(0, 0, 0, 0)"}=e;r.fillStyle=t,r.strokeStyle=s,r.lineWidth=n,r.lineCap=o,r.lineJoin=C[i],r.miterLimit=c,r.setLineDash(a),r.lineDashOffset=h,r.shadowOffsetX=l,r.shadowOffsetY=y,r.shadowBlur=f,r.shadowColor=p}class u{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new u(1/0,1/0)}static get MIN(){return new u(-1/0,-1/0)}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const s=-e/180*Math.PI,n=this.x-t.x,o=-(this.y-t.y),i=Math.sin(s),c=Math.cos(s);return this.set(t.x+(n*c-o*i),t.y-(n*i+o*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,s={x:0,y:0}){const n=e<0?s.x-this.x+s.x:this.x,o=t<0?s.y-this.y+s.y:this.y;return this.x=n*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=0,s={x:0,y:0}){const n=this.x-s.x,o=this.y-s.y;return this.x=s.x+(n+Math.tan(e)*o),this.y=s.y+(o+Math.tan(t)*n),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,n=e.elements;return this.x=n[0]*t+n[3]*s+n[6],this.y=n[1]*t+n[4]*s+n[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new u(this.x,this.y)}}class L{constructor(e=0,t=0,s=0,n=0){this.left=e,this.top=t,this.width=s,this.height=n}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}static from(...e){if(e.length===0)return new L;if(e.length===1)return e[0].clone();const t=e[0],s=e.slice(1).reduce((n,o)=>(n.left=Math.min(n.left,o.left),n.top=Math.min(n.top,o.top),n.right=Math.max(n.right,o.right),n.bottom=Math.max(n.bottom,o.bottom),n),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new L(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}getCenterPoint(){return new u((this.left+this.right)/2,(this.top+this.bottom)/2)}clone(){return new L(this.left,this.top,this.width,this.height)}toArray(){return[this.left,this.top,this.width,this.height]}}class b{constructor(e=1,t=0,s=0,n=0,o=1,i=0,c=0,a=0,h=1){T(this,"elements",[]);this.set(e,t,s,n,o,i,c,a,h)}set(e,t,s,n,o,i,c,a,h){const l=this.elements;return l[0]=e,l[1]=n,l[2]=c,l[3]=t,l[4]=o,l[5]=a,l[6]=s,l[7]=i,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,n=t.elements,o=this.elements,i=s[0],c=s[3],a=s[6],h=s[1],l=s[4],y=s[7],f=s[2],p=s[5],g=s[8],x=n[0],M=n[3],w=n[6],$=n[1],v=n[4],S=n[7],N=n[2],z=n[5],D=n[8];return o[0]=i*x+c*$+a*N,o[3]=i*M+c*v+a*z,o[6]=i*w+c*S+a*D,o[1]=h*x+l*$+y*N,o[4]=h*M+l*v+y*z,o[7]=h*w+l*S+y*D,o[2]=f*x+p*$+g*N,o[5]=f*M+p*v+g*z,o[8]=f*w+p*S+g*D,this}invert(){const e=this.elements,t=e[0],s=e[1],n=e[2],o=e[3],i=e[4],c=e[5],a=e[6],h=e[7],l=e[8],y=l*i-c*h,f=c*a-l*o,p=h*o-i*a,g=t*y+s*f+n*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=y*x,e[1]=(n*h-l*s)*x,e[2]=(c*s-n*i)*x,e[3]=f*x,e[4]=(l*t-n*a)*x,e[5]=(n*o-c*t)*x,e[6]=p*x,e[7]=(s*a-h*t)*x,e[8]=(i*t-s*o)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(Y.makeScale(e,t)),this}rotate(e){return this.premultiply(Y.makeRotation(-e)),this}translate(e,t){return this.premultiply(Y.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const Y=new b;function Z(r,e,t,s){const n=r*t+e*s,o=Math.sqrt(r*r+e*e)*Math.sqrt(t*t+s*s);let i=Math.acos(Math.max(-1,Math.min(1,n/o)));return r*s-e*t<0&&(i=-i),i}function J(r,e,t,s,n,o,i,c){if(e===0||t===0){r.lineTo(c.x,c.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const a=(i.x-c.x)/2,h=(i.y-c.y)/2,l=Math.cos(s)*a+Math.sin(s)*h,y=-Math.sin(s)*a+Math.cos(s)*h;let f=e*e,p=t*t;const g=l*l,x=y*y,M=g/f+x/p;if(M>1){const wt=Math.sqrt(M);e=wt*e,t=wt*t,f=e*e,p=t*t}const w=f*x+p*g,$=(f*p-w)/w;let v=Math.sqrt(Math.max(0,$));n===o&&(v=-v);const S=v*e*y/t,N=-v*t*l/e,z=Math.cos(s)*S-Math.sin(s)*N+(i.x+c.x)/2,D=Math.sin(s)*S+Math.cos(s)*N+(i.y+c.y)/2,U=Z(1,0,(l-S)/e,(y-N)/t),j=Z((l-S)/e,(y-N)/t,(-l-S)/e,(-y-N)/t)%(Math.PI*2);r.ellipse(z,D,e,t,s,U,U+j,o===1)}function O(r,e){return r-(e-r)}function W(r,e){const t=new u,s=new u;for(let n=0,o=r.length;n<o;n++){const i=r[n];if(i.type==="m"||i.type==="M")i.type==="m"?t.add(i):t.copy(i),e.moveTo(t.x,t.y),s.copy(t);else if(i.type==="h"||i.type==="H")i.type==="h"?t.x+=i.x:t.x=i.x,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="v"||i.type==="V")i.type==="v"?t.y+=i.y:t.y=i.y,e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="l"||i.type==="L")i.type==="l"?t.add(i):t.copy(i),e.lineTo(t.x,t.y),s.copy(t);else if(i.type==="c"||i.type==="C")i.type==="c"?(e.bezierCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(i.x1,i.y1,i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="s"||i.type==="S")i.type==="s"?(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),t.x+i.x2,t.y+i.y2,t.x+i.x,t.y+i.y),s.x=t.x+i.x2,s.y=t.y+i.y2,t.add(i)):(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),i.x2,i.y2,i.x,i.y),s.x=i.x2,s.y=i.y2,t.copy(i));else if(i.type==="q"||i.type==="Q")i.type==="q"?(e.quadraticCurveTo(t.x+i.x1,t.y+i.y1,t.x+i.x,t.y+i.y),s.x=t.x+i.x1,s.y=t.y+i.y1,t.add(i)):(e.quadraticCurveTo(i.x1,i.y1,i.x,i.y),s.x=i.x1,s.y=i.y1,t.copy(i));else if(i.type==="t"||i.type==="T"){const c=O(t.x,s.x),a=O(t.y,s.y);s.x=c,s.y=a,i.type==="t"?(e.quadraticCurveTo(c,a,t.x+i.x,t.y+i.y),t.add(i)):(e.quadraticCurveTo(c,a,i.x,i.y),t.copy(i))}else if(i.type==="a"||i.type==="A"){const c=t.clone();if(i.type==="a"){if(i.x===0&&i.y===0)continue;t.add(i)}else{if(t.equals(i))continue;t.copy(i)}s.copy(t),J(e,i.rx,i.ry,i.angle,i.largeArcFlag,i.sweepFlag,c,t)}else i.type==="z"||i.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",i)}}const m={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function A(r,e,t=0){let c=0,a=!0,h="",l="";const y=[];function f(M,w,$){const v=new SyntaxError(`Unexpected character "${M}" at index ${w}.`);throw v.partial=$,v}function p(){h!==""&&(l===""?y.push(Number(h)):y.push(Number(h)*10**Number(l))),h="",l=""}let g;const x=r.length;for(let M=0;M<x;M++){if(g=r[M],Array.isArray(e)&&e.includes(y.length%t)&&m.FLAGS.test(g)){c=1,h=g,p();continue}if(c===0){if(m.WHITESPACE.test(g))continue;if(m.DIGIT.test(g)||m.SIGN.test(g)){c=1,h=g;continue}if(m.POINT.test(g)){c=2,h=g;continue}m.COMMA.test(g)&&(a&&f(g,M,y),a=!0)}if(c===1){if(m.DIGIT.test(g)){h+=g;continue}if(m.POINT.test(g)){h+=g,c=2;continue}if(m.EXP.test(g)){c=3;continue}m.SIGN.test(g)&&h.length===1&&m.SIGN.test(h[0])&&f(g,M,y)}if(c===2){if(m.DIGIT.test(g)){h+=g;continue}if(m.EXP.test(g)){c=3;continue}m.POINT.test(g)&&h[h.length-1]==="."&&f(g,M,y)}if(c===3){if(m.DIGIT.test(g)){l+=g;continue}if(m.SIGN.test(g)){if(l===""){l+=g;continue}l.length===1&&m.SIGN.test(l)&&f(g,M,y)}}m.WHITESPACE.test(g)?(p(),c=0,a=!1):m.COMMA.test(g)?(p(),c=0,a=!0):m.SIGN.test(g)?(p(),c=1,h=g):m.POINT.test(g)?(p(),c=2,h=g):f(g,M,y)}return p(),y}function Tt(r){switch(r.type){case"m":case"M":return`${r.type} ${r.x} ${r.y}`;case"h":case"H":return`${r.type} ${r.x}`;case"v":case"V":return`${r.type} ${r.y}`;case"l":case"L":return`${r.type} ${r.x} ${r.y}`;case"c":case"C":return`${r.type} ${r.x1} ${r.y1} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"s":case"S":return`${r.type} ${r.x2} ${r.y2} ${r.x} ${r.y}`;case"q":case"Q":return`${r.type} ${r.x1} ${r.y1} ${r.x} ${r.y}`;case"t":case"T":return`${r.type} ${r.x} ${r.y}`;case"a":case"A":return`${r.type} ${r.rx} ${r.ry} ${r.angle} ${r.largeArcFlag} ${r.sweepFlag} ${r.x} ${r.y}`;case"z":case"Z":return r.type;default:return""}}function K(r){let e="";for(let t=0,s=r.length;t<s;t++)e+=`${Tt(r[t])} `;return e}const Ct=/[a-df-z][^a-df-z]*/gi;function G(r){const e=[],t=r.match(Ct);if(!t)return e;for(let s=0,n=t.length;s<n;s++){const o=t[s],i=o.charAt(0),c=o.slice(1).trim();let a;switch(i){case"m":case"M":a=A(c);for(let h=0,l=a.length;h<l;h+=2)h===0?e.push({type:i,x:a[h],y:a[h+1]}):e.push({type:i==="m"?"l":"L",x:a[h],y:a[h+1]});break;case"h":case"H":a=A(c);for(let h=0,l=a.length;h<l;h++)e.push({type:i,x:a[h]});break;case"v":case"V":a=A(c);for(let h=0,l=a.length;h<l;h++)e.push({type:i,y:a[h]});break;case"l":case"L":a=A(c);for(let h=0,l=a.length;h<l;h+=2)e.push({type:i,x:a[h],y:a[h+1]});break;case"c":case"C":a=A(c);for(let h=0,l=a.length;h<l;h+=6)e.push({type:i,x1:a[h],y1:a[h+1],x2:a[h+2],y2:a[h+3],x:a[h+4],y:a[h+5]});break;case"s":case"S":a=A(c);for(let h=0,l=a.length;h<l;h+=4)e.push({type:i,x2:a[h],y2:a[h+1],x:a[h+2],y:a[h+3]});break;case"q":case"Q":a=A(c);for(let h=0,l=a.length;h<l;h+=4)e.push({type:i,x1:a[h],y1:a[h+1],x:a[h+2],y:a[h+3]});break;case"t":case"T":a=A(c);for(let h=0,l=a.length;h<l;h+=2)e.push({type:i,x:a[h],y:a[h+1]});break;case"a":case"A":a=A(c,[3,4],7);for(let h=0,l=a.length;h<l;h+=7)e.push({type:i,rx:a[h],ry:a[h+1],angle:a[h+2],largeArcFlag:a[h+3],sweepFlag:a[h+4],x:a[h+5],y:a[h+6]});break;case"z":case"Z":e.push({type:i});break;default:console.warn(o)}}return e}class k{constructor(){T(this,"arcLengthDivisions",200);T(this,"_cacheArcLengths");T(this,"_needsUpdate",!1)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),s=this.getPoint(1);return(t.x-e.x)*(s.y-t.y)-(t.y-e.y)*(s.x-t.x)<0}getPointAt(e,t=new u){return this.getPoint(this.getUToTMapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}forEachControlPoints(e){return this.getControlPoints().forEach(e),this}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,n=this.getPoint(0),o=0;t.push(0);for(let i=1;i<=e;i++)s=this.getPoint(i/e),o+=s.distanceTo(n),t.push(o),n=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(e,t){const s=this.getLengths();let n=0;const o=s.length;let i;t?i=t:i=e*s[o-1];let c=0,a=o-1,h;for(;c<=a;)if(n=Math.floor(c+(a-c)/2),h=s[n]-i,h<0)c=n+1;else if(h>0)a=n-1;else{a=n;break}if(n=a,s[n]===i)return n/(o-1);const l=s[n],f=s[n+1]-l,p=(i-l)/f;return(n+p)/(o-1)}getTangent(e,t=new u){const n=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(n)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new u){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let s=0,n=1,o=(s+n)/2;for(;n-s>t;){o=(s+n)/2;const i=this.getPoint(o);if(i.distanceTo(e)<t)return o;i.x<e.x?s=o:n=o}return o}matrix(e){return this.forEachControlPoints(t=>t.applyMatrix3(e)),this}getMinMax(e=u.MAX,t=u.MIN){return this.getPoints().forEach(s=>{e.x=Math.min(e.x,s.x),e.y=Math.min(e.y,s.y),t.x=Math.max(t.x,s.x),t.y=Math.max(t.y,s.y)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new L(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}toData(){return K(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class _ extends k{constructor(e,t,s=0,n=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=n}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().scale(t))}getTangent(e,t=new u){const{x:s,y:n}=this.getNormal(e);return t.set(-n,s)}getNormal(e,t=new u){const{start:s,end:n}=this,o=e*(n-s)+s-.5*Math.PI;return t.set(Math.cos(o),Math.sin(o))}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function tt(r,e,t,s,n){const o=(s-e)*.5,i=(n-t)*.5,c=r*r,a=r*c;return(2*t-2*s+o+i)*a+(-3*t+3*s-2*o-i)*c+o*r+t}function vt(r,e){const t=1-r;return t*t*e}function bt(r,e){return 2*(1-r)*r*e}function At(r,e){return r*r*e}function et(r,e,t,s){return vt(r,e)+bt(r,t)+At(r,s)}function kt(r,e){const t=1-r;return t*t*t*e}function It(r,e){const t=1-r;return 3*t*t*r*e}function St(r,e){return 3*(1-r)*r*r*e}function Nt(r,e){return r*r*r*e}function st(r,e,t,s,n){return kt(r,e)+It(r,t)+St(r,s)+Nt(r,n)}class nt extends k{constructor(e=new u,t=new u,s=new u,n=new u){super(),this.start=e,this.startControl=t,this.endControl=s,this.end=n}getPoint(e,t=new u){const{start:s,startControl:n,endControl:o,end:i}=this;return t.set(st(e,s.x,n.x,o.x,i.x),st(e,s.y,n.y,o.y,i.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(e,t,s){const n=t*t-4*e*s;if(n<0)return[];const o=Math.sqrt(n),i=(-t+o)/(2*e),c=(-t-o)/(2*e);return[i,c].filter(a=>a>=0&&a<=1)}getMinMax(e=u.MAX,t=u.MIN){const s=this.start,n=this.startControl,o=this.endControl,i=this.end,c=this._solveQuadratic(3*(n.x-s.x),6*(o.x-n.x),3*(i.x-o.x)),a=this._solveQuadratic(3*(n.y-s.y),6*(o.y-n.y),3*(i.y-o.y)),h=[0,1,...c,...a];return((y,f)=>{for(const p of y)for(let g=0;g<=f;g++){const x=g/f-.5,M=Math.min(1,Math.max(0,p+x)),w=this.getPoint(M);e.x=Math.min(e.x,w.x),e.y=Math.min(e.y,w.y),t.x=Math.max(t.x,w.x),t.y=Math.max(t.y,w.y)}})(h,10),{min:e,max:t}}toCommands(){const{start:e,startControl:t,endControl:s,end:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:n.x,y:n.y}]}drawTo(e){const{start:t,startControl:s,endControl:n,end:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(s.x,s.y,n.x,n.y,o.x,o.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const Et=new b,rt=new b,it=new b,F=new u;class ot extends k{constructor(e=new u,t=1,s=1,n=0,o=0,i=Math.PI*2,c=!1){super(),this.center=e,this.radiusX=t,this.radiusY=s,this.rotation=n,this.startAngle=o,this.endAngle=i,this.clockwise=c}isClockwise(){return this.clockwise}getPoint(e,t=new u){const s=Math.PI*2;let n=this.endAngle-this.startAngle;const o=Math.abs(n)<Number.EPSILON;for(;n<0;)n+=s;for(;n>s;)n-=s;n<Number.EPSILON&&(o?n=0:n=s),this.clockwise&&!o&&(n===s?n=-s:n=n-s);const i=this.startAngle+e*n;let c=this.center.x+this.radiusX*Math.cos(i),a=this.center.y+this.radiusY*Math.sin(i);if(this.rotation!==0){const h=Math.cos(this.rotation),l=Math.sin(this.rotation),y=c-this.center.x,f=a-this.center.y;c=y*h-f*l+this.center.x,a=y*l+f*h+this.center.y}return t.set(c,a)}toCommands(){const{center:e,radiusX:t,radiusY:s,startAngle:n,endAngle:o,clockwise:i,rotation:c}=this,{x:a,y:h}=e,l=a+t*Math.cos(n)*Math.cos(c)-s*Math.sin(n)*Math.sin(c),y=h+t*Math.cos(n)*Math.sin(c)+s*Math.sin(n)*Math.cos(c),f=Math.abs(n-o),p=f>Math.PI?1:0,g=i?1:0,x=c*180/Math.PI;if(f>=2*Math.PI){const M=n+Math.PI,w=a+t*Math.cos(M)*Math.cos(c)-s*Math.sin(M)*Math.sin(c),$=h+t*Math.cos(M)*Math.sin(c)+s*Math.sin(M)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:w,y:$},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:l,y}]}else{const M=a+t*Math.cos(o)*Math.cos(c)-s*Math.sin(o)*Math.sin(c),w=h+t*Math.cos(o)*Math.sin(c)+s*Math.sin(o)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:p,sweepFlag:g,x:M,y:w}]}}drawTo(e){const{center:t,radiusX:s,radiusY:n,rotation:o,startAngle:i,endAngle:c,clockwise:a}=this;return e.ellipse(t.x,t.y,s,n,o,i,c,!a),this}matrix(e){return F.set(this.center.x,this.center.y),F.applyMatrix3(e),this.center.x=F.x,this.center.y=F.y,qt(e)?$t(this,e):Lt(this,e),this}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){const{center:s,radiusX:n,radiusY:o,rotation:i}=this,{x:c,y:a}=s,h=Math.cos(i),l=Math.sin(i),y=Math.sqrt(n*n*h*h+o*o*l*l),f=Math.sqrt(n*n*l*l+o*o*h*h);return e.x=Math.min(e.x,c-y),e.y=Math.min(e.y,a-f),t.x=Math.max(t.x,c+y),t.y=Math.max(t.y,a+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function $t(r,e){const t=r.radiusX,s=r.radiusY,n=Math.cos(r.rotation),o=Math.sin(r.rotation),i=new u(t*n,t*o),c=new u(-s*o,s*n),a=i.applyMatrix3(e),h=c.applyMatrix3(e),l=Et.set(a.x,h.x,0,a.y,h.y,0,0,0,1),y=rt.copy(l).invert(),g=it.copy(y).transpose().multiply(y).elements,x=zt(g[0],g[1],g[4]),M=Math.sqrt(x.rt1),w=Math.sqrt(x.rt2);if(r.radiusX=1/M,r.radiusY=1/w,r.rotation=Math.atan2(x.sn,x.cs),!((r.endAngle-r.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=rt.set(M,0,0,0,w,0,0,0,1),S=it.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),N=v.multiply(S).multiply(l),z=D=>{const{x:U,y:j}=new u(Math.cos(D),Math.sin(D)).applyMatrix3(N);return Math.atan2(j,U)};r.startAngle=z(r.startAngle),r.endAngle=z(r.endAngle),ht(e)&&(r.clockwise=!r.clockwise)}}function Lt(r,e){const t=at(e),s=ct(e);r.radiusX*=t,r.radiusY*=s;const n=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);r.rotation+=n,ht(e)&&(r.startAngle*=-1,r.endAngle*=-1,r.clockwise=!r.clockwise)}function ht(r){const e=r.elements;return e[0]*e[4]-e[1]*e[3]<0}function qt(r){const e=r.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=at(r),n=ct(r);return Math.abs(t/(s*n))>Number.EPSILON}function at(r){const e=r.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ct(r){const e=r.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function zt(r,e,t){let s,n,o,i,c;const a=r+t,h=r-t,l=Math.sqrt(h*h+4*e*e);return a>0?(s=.5*(a+l),c=1/s,n=r*c*t-e*c*e):a<0?n=.5*(a-l):(s=.5*l,n=-.5*l),h>0?o=h+l:o=h-l,Math.abs(o)>2*Math.abs(e)?(c=-2*e/o,i=1/Math.sqrt(1+c*c),o=c*i):Math.abs(e)===0?(o=1,i=0):(c=-.5*o/e,o=1/Math.sqrt(1+c*c),i=c*o),h>0&&(c=o,o=-i,i=c),{rt1:s,rt2:n,cs:o,sn:i}}class X extends k{constructor(e=new u,t=new u){super(),this.start=e,this.end=t}getPoint(e,t=new u){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new u){return this.getPoint(e,t)}getTangent(e,t=new u){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new u){return this.getTangent(e,t)}getControlPoints(){return[this.start,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,end:n}=this;return e.x=Math.min(e.x,s.x,n.x),e.y=Math.min(e.y,s.y,n.y),t.x=Math.max(t.x,s.x,n.x),t.y=Math.max(t.y,s.y,n.y),{min:e,max:t}}toCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{start:t,end:s}=this;return e.lineTo(t.x,t.y),e.lineTo(s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class Dt extends k{constructor(t,s,n=0,o=1){super();T(this,"curveT",0);this.center=t,this.size=s,this.start=n,this.end=o,this.update()}update(){const{x:t,y:s}=this.center,n=new u(t+.5*this.size,s-.5*this.size),o=new u(t-.5*this.size,s-.5*this.size),i=new u(t,s+.5*this.size),c=new _(n,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),a=new _(o,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),h=new _(i,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),l=new u(t,s+this.size),y=new u(t+this.size,s),f=new u().lerpVectors(y,l,.75),p=new u(t-this.size,s),g=new u().lerpVectors(p,l,.75),x=new X(y,f),M=new X(g,p);return this.curves=[c,x,h,M,a],this}getPoint(t){return this.getCurve(t).getPoint(this.curveT)}getPointAt(t){return this.getPoint(t)}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let n;const o=.5*Math.PI;return s<o?(n=0,this.curveT=s/o):s<o+.75?(n=1,this.curveT=(s-o)/.75):s<5*Math.PI/8+.75?(n=2,this.curveT=(s-o-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(n=3,this.curveT=(s-5*Math.PI/8-.75)/.75):(n=4,this.curveT=(s-5*Math.PI/8-1.5)/o),this.curves[n]}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class Xt extends k{constructor(t,s=0,n=0,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);T(this,"points",[]);this.center=t,this.radius=s,this.number=n,this.start=o,this.end=i,this.update()}update(){for(let t=0;t<this.number;t++){let s=t*2*Math.PI/this.number;s-=.5*Math.PI,this.points.push(new u(this.radius*Math.cos(s),this.radius*Math.sin(s)).add(this.center))}for(let t=0;t<this.number;t++)this.curves.push(new X(this.points[t],this.points[(t+1)%this.number]));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const n=s*this.number,o=Math.floor(n);return this.curveT=n-o,this.curves[o]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class lt extends k{constructor(e=new u,t=new u,s=new u){super(),this.start=e,this.control=t,this.end=s}getPoint(e,t=new u){const{start:s,control:n,end:o}=this;return t.set(et(e,s.x,n.x,o.x),et(e,s.y,n.y,o.y)),t}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,control:n,end:o}=this,i=.5*(s.x+n.x),c=.5*(s.y+n.y),a=.5*(s.x+o.x),h=.5*(s.y+o.y);return e.x=Math.min(e.x,s.x,o.x,i,a),e.y=Math.min(e.y,s.y,o.y,c,h),t.x=Math.max(t.x,s.x,o.x,i,a),t.y=Math.max(t.y,s.y,o.y,c,h),{min:e,max:t}}toCommands(){const{start:e,control:t,end:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{start:t,control:s,end:n}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(s.x,s.y,n.x,n.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class ut extends k{constructor(t,s,n=1,o=0,i=1){super();T(this,"curves",[]);T(this,"curveT",0);this.center=t,this.rx=s,this.aspectRatio=n,this.start=o,this.end=i,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:s}=this.center,n=this.rx,o=this.rx/this.aspectRatio,i=[new u(t-n,s-o),new u(t+n,s-o),new u(t+n,s+o),new u(t-n,s+o)];for(let c=0;c<4;c++)this.curves.push(new X(i[c].clone(),i[(c+1)%4].clone()));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let n;return s<this.aspectRatio?(n=0,this.curveT=s/this.aspectRatio):s<this.aspectRatio+1?(n=1,this.curveT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(n=2,this.curveT=(s-this.aspectRatio-1)/this.aspectRatio):(n=3,this.curveT=(s-2*this.aspectRatio-1)/1),this.curves[n]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class yt extends k{constructor(e=[]){super(),this.points=e}getPoint(e,t=new u){const{points:s}=this,n=(s.length-1)*e,o=Math.floor(n),i=n-o,c=s[o===0?o:o-1],a=s[o],h=s[o>s.length-2?s.length-1:o+1],l=s[o>s.length-3?s.length-1:o+2];return t.set(tt(i,c.x,a.x,h.x,l.x),tt(i,c.y,a.y,h.y,l.y)),t}getControlPoints(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class R extends k{constructor(t){super();T(this,"curves",[]);T(this,"startPoint");T(this,"currentPoint",new u);T(this,"autoClose",!1);T(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,n=t.length;s<n;s++){const{x:o,y:i}=t[s];this.lineTo(o,i)}return this}addCommands(t){return W(t,this),this}addData(t){return this.addCommands(G(t)),this}getPoint(t,s=new u){const n=t*this.getLength(),o=this.getCurveLengths();let i=0;for(;i<o.length;){if(o[i]>=n){const c=o[i]-n,a=this.curves[i],h=a.getLength();return a.getPointAt(h===0?0:1-c/h,s)}i++}return s}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let n=0,o=this.curves.length;n<o;n++)s+=this.curves[n].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let n=0;n<=t;n++)s.push(this.getPoint(n/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[],n=this.curves;let o;for(let i=0,c=n.length;i<c;i++){const h=n[i].getPoints(t);for(let l=0;l<h.length;l++){const y=h[l];o!=null&&o.equals(y)||(s.push(y),o=y)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const s=this.currentPoint;t.equals(s)||(this.curves.push(new X(s.clone(),t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,s){return this.currentPoint.set(t,s),this.startPoint=this.currentPoint.clone(),this}lineTo(t,s){return this.currentPoint.equals({x:t,y:s})||this.curves.push(new X(this.currentPoint.clone(),new u(t,s))),this._setCurrentPoint({x:t,y:s}),this}bezierCurveTo(t,s,n,o,i,c){return this.currentPoint.equals({x:i,y:c})||this.curves.push(new nt(this.currentPoint.clone(),new u(t,s),new u(n,o),new u(i,c))),this._setCurrentPoint({x:i,y:c}),this}quadraticCurveTo(t,s,n,o){return this.currentPoint.equals({x:n,y:o})||this.curves.push(new lt(this.currentPoint.clone(),new u(t,s),new u(n,o))),this._setCurrentPoint({x:n,y:o}),this}arc(t,s,n,o,i,c){return this.ellipse(t,s,n,n,0,o,i,c),this}relativeArc(t,s,n,o,i,c){const a=this.currentPoint;return this.arc(t+a.x,s+a.y,n,o,i,c),this}arcTo(t,s,n,o,i){return console.warn("Method arcTo not supported yet"),this}ellipse(t,s,n,o,i,c,a,h=!0){const l=new ot(new u(t,s),n,o,i,c,a,!h);if(this.curves.length>0){const y=l.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,s,n,o,i,c,a,h){const l=this.currentPoint;return this.ellipse(t+l.x,s+l.y,n,o,i,c,a,h),this}rect(t,s,n,o){return this.curves.push(new ut(new u(t+n/2,s+o/2),n/2,n/o)),this._setCurrentPoint({x:t,y:s}),this}splineThru(t){return this.curves.push(new yt([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(n=>n.getMinMax(t,s)),{min:t,max:s}}getBoundingBox(){const{min:t,max:s}=this.getMinMax();return new L(t.x,t.y,s.x-t.x,s.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var n;const s=(n=this.curves[0])==null?void 0:n.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,n=t.curves.length;s<n;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function Ot(r){return r.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Rt(r,e,t,s){const n=e.clone().sub(r),o=s.clone().sub(t),i=t.clone().sub(r),c=n.cross(o);if(c===0)return new u((r.x+t.x)/2,(r.y+t.y)/2);const a=i.cross(o)/c;return Math.abs(a)>1?new u((r.x+t.x)/2,(r.y+t.y)/2):new u(r.x+a*n.x,r.y+a*n.y)}class I{constructor(e){T(this,"currentPath",new R);T(this,"paths",[this.currentPath]);T(this,"style",{});e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e))}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new R().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:s,curves:n}=this.currentPath;return s.equals({x:e,y:t})||(n.length?(this.currentPath=new R().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,n,o,i){return this.currentPath.bezierCurveTo(e,t,s,n,o,i),this}quadraticCurveTo(e,t,s,n){return this.currentPath.quadraticCurveTo(e,t,s,n),this}arc(e,t,s,n,o,i){return this.currentPath.arc(e,t,s,n,o,i),this}arcTo(e,t,s,n,o){return this.currentPath.arcTo(e,t,s,n,o),this}ellipse(e,t,s,n,o,i,c,a){return this.currentPath.ellipse(e,t,s,n,o,i,c,a),this}rect(e,t,s,n){return this.currentPath.rect(e,t,s,n),this}addCommands(e){return W(e,this),this}addData(e){return this.addCommands(G(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}getControlPoints(){return this.paths.flatMap(e=>e.getControlPoints())}getCurves(){return this.paths.flatMap(e=>e.curves)}scale(e,t=e,s={x:0,y:0}){return this.getControlPoints().forEach(n=>{n.scale(e,t,s)}),this}skew(e,t=0,s={x:0,y:0}){return this.getControlPoints().forEach(n=>{n.skew(e,t,s)}),this}rotate(e,t={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getCurves(),s=[],n=[],o=[];t.forEach((c,a)=>{const h=c.getControlPoints(),l=c.isClockwise();o[a]=h,n[a]=l;const y=h[0],f=h[h.length-1]??y;s.push({start:l?f:y,end:l?y:f,index:a})});const i=[];return s.forEach((c,a)=>{i[a]=[],s.forEach((h,l)=>{l!==a&&h.start.equals(c.end)&&i[a].push(h.index)})}),t.forEach((c,a)=>{const h=n[a];o[a].forEach(y=>{const f=c.getTForPoint(y),p=c.getNormal(f).scale(h?e:-e);y.add(p)})}),i.forEach((c,a)=>{const h=o[a];c.forEach(l=>{const y=o[l],f=Rt(h[h.length-1],h[h.length-2]??h[h.length-1],y[0],y[1]??y[0]);f&&(h[h.length-1].copy(f),y[0].copy(f))})}),this}matrix(e){return this.getCurves().forEach(t=>t.matrix(e)),this}getMinMax(e=u.MAX,t=u.MIN,s=!0){if(this.getCurves().forEach(n=>n.getMinMax(e,t)),s){const n=this.strokeWidth/2;e.x-=n,e.y-=n,t.x+=n,t.y+=n}return{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:s}=this.getMinMax(void 0,void 0,e);return new L(t.x,t.y,s.x-t.x,s.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:n="none"}=t;return e.beginPath(),e.save(),q(e,t),this.paths.forEach(o=>{o.drawTo(e)}),s!=="none"&&e.fill(),n!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:n="none"}=t;return e.beginPath(),e.save(),q(e,t),this.getControlPoints().forEach(o=>{e.moveTo(o.x,o.y),e.arc(o.x,o.y,4,0,Math.PI*2)}),s!=="none"&&e.fill(),n!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.paths.flatMap(e=>e.toCommands())}toData(){return this.paths.map(e=>e.toData()).join(" ")}toSvgPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const n in e)e[n]!==void 0&&(t[Ot(n)]=e[n]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const n in t)t[n]!==void 0&&(s+=`${n}:${t[n]};`);return`<path d="${this.toData()}" style="${s}"></path>`}toSvgString(){const{x:e,y:t,width:s,height:n}=this.getBoundingBox(),o=this.toSvgPathString();return`<svg viewBox="${e} ${t} ${s} ${n}" width="${s}px" height="${n}px" xmlns="http://www.w3.org/2000/svg">${o}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...s}=e,{left:n,top:o,width:i,height:c}=this.getBoundingBox(),a=document.createElement("canvas");a.width=i*t,a.height=c*t,a.style.width=`${i}px`,a.style.height=`${c}px`;const h=a.getContext("2d");return h&&(h.scale(t,t),h.translate(-n,-o),this.drawTo(h,s)),a}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}clone(){return new this.constructor().copy(this)}}const Q="px",gt=90,ft=["mm","cm","in","pt","pc","px"],V={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function P(r){let e="px";if(typeof r=="string"||r instanceof String)for(let s=0,n=ft.length;s<n;s++){const o=ft[s];if(r.endsWith(o)){e=o,r=r.substring(0,r.length-o.length);break}}let t;return e==="px"&&Q!=="px"?t=V.in[Q]/gt:(t=V[e][Q],t<0&&(t=V[e].in*gt)),t*Number.parseFloat(r)}const _t=new b,B=new b,pt=new b,dt=new b;function Ft(r,e,t){if(!(r.hasAttribute("transform")||r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))))return null;const s=Bt(r);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Bt(r){const e=new b,t=_t;if(r.nodeName==="use"&&(r.hasAttribute("x")||r.hasAttribute("y"))&&e.translate(P(r.getAttribute("x")),P(r.getAttribute("y"))),r.hasAttribute("transform")){const s=r.getAttribute("transform").split(")");for(let n=s.length-1;n>=0;n--){const o=s[n].trim();if(o==="")continue;const i=o.indexOf("("),c=o.length;if(i>0&&i<c){const a=o.slice(0,i),h=A(o.slice(i+1));switch(t.identity(),a){case"translate":if(h.length>=1){const l=h[0];let y=0;h.length>=2&&(y=h[1]),t.translate(l,y)}break;case"rotate":if(h.length>=1){let l=0,y=0,f=0;l=h[0]*Math.PI/180,h.length>=3&&(y=h[1],f=h[2]),B.makeTranslation(-y,-f),pt.makeRotation(l),dt.multiplyMatrices(pt,B),B.makeTranslation(y,f),t.multiplyMatrices(B,dt)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function Ut(r){return new I().addPath(new R().arc(P(r.getAttribute("cx")||0),P(r.getAttribute("cy")||0),P(r.getAttribute("r")||0),0,Math.PI*2))}function Yt(r,e){if(!(!r.sheet||!r.sheet.cssRules||!r.sheet.cssRules.length))for(let t=0;t<r.sheet.cssRules.length;t++){const s=r.sheet.cssRules[t];if(s.type!==1)continue;const n=s.selectorText.split(/,/g).filter(Boolean).map(o=>o.trim());for(let o=0;o<n.length;o++){const i=Object.fromEntries(Object.entries(s.style).filter(([,c])=>c!==""));e[n[o]]=Object.assign(e[n[o]]||{},i)}}}function Wt(r){return new I().addPath(new R().ellipse(P(r.getAttribute("cx")||0),P(r.getAttribute("cy")||0),P(r.getAttribute("rx")||0),P(r.getAttribute("ry")||0),0,0,Math.PI*2))}function Gt(r){return new I().moveTo(P(r.getAttribute("x1")||0),P(r.getAttribute("y1")||0)).lineTo(P(r.getAttribute("x2")||0),P(r.getAttribute("y2")||0))}function Qt(r){const e=new I,t=r.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const Vt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Ht(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(Vt,(n,o,i)=>{const c=P(o),a=P(i);return t===0?e.moveTo(c,a):e.lineTo(c,a),t++,n}),e.currentPath.autoClose=!0,e}const jt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Zt(r){var s;const e=new I;let t=0;return(s=r.getAttribute("points"))==null||s.replace(jt,(n,o,i)=>{const c=P(o),a=P(i);return t===0?e.moveTo(c,a):e.lineTo(c,a),t++,n}),e.currentPath.autoClose=!1,e}function Jt(r){const e=P(r.getAttribute("x")||0),t=P(r.getAttribute("y")||0),s=P(r.getAttribute("rx")||r.getAttribute("ry")||0),n=P(r.getAttribute("ry")||r.getAttribute("rx")||0),o=P(r.getAttribute("width")),i=P(r.getAttribute("height")),c=1-.551915024494,a=new I;return a.moveTo(e+s,t),a.lineTo(e+o-s,t),(s!==0||n!==0)&&a.bezierCurveTo(e+o-s*c,t,e+o,t+n*c,e+o,t+n),a.lineTo(e+o,t+i-n),(s!==0||n!==0)&&a.bezierCurveTo(e+o,t+i-n*c,e+o-s*c,t+i,e+o-s,t+i),a.lineTo(e+s,t+i),(s!==0||n!==0)&&a.bezierCurveTo(e+s*c,t+i,e,t+i-n*c,e,t+i-n),a.lineTo(e,t+n),(s!==0||n!==0)&&a.bezierCurveTo(e,t+n*c,e+s*c,t,e+s,t),a}function E(r,e,t){e=Object.assign({},e);let s={};if(r.hasAttribute("class")){const a=r.getAttribute("class").split(/\s/).filter(Boolean).map(h=>h.trim());for(let h=0;h<a.length;h++)s=Object.assign(s,t[`.${a[h]}`])}r.hasAttribute("id")&&(s=Object.assign(s,t[`#${r.getAttribute("id")}`]));function n(a,h,l){l===void 0&&(l=function(f){return f.startsWith("url")&&console.warn("url access in attributes is not implemented."),f}),r.hasAttribute(a)&&(e[h]=l(r.getAttribute(a))),s[a]&&(e[h]=l(s[a])),r.style&&r.style[a]!==""&&(e[h]=l(r.style[a]))}function o(a){return Math.max(0,Math.min(1,P(a)))}function i(a){return Math.max(0,P(a))}function c(a){return a.split(" ").filter(h=>h!=="").map(h=>P(h))}return n("fill","fill"),n("fill-opacity","fillOpacity",o),n("fill-rule","fillRule"),n("opacity","opacity",o),n("stroke","stroke"),n("stroke-opacity","strokeOpacity",o),n("stroke-width","strokeWidth",i),n("stroke-linecap","strokeLinecap"),n("stroke-linejoin","strokeLinejoin"),n("stroke-miterlimit","strokeMiterlimit",i),n("stroke-dasharray","strokeDasharray",c),n("stroke-dashoffset","strokeDashoffset",P),n("visibility","visibility"),e}function H(r,e,t=[]){var l;if(r.nodeType!==1)return t;let s=!1,n=null;const o={};switch(r.nodeName){case"svg":e=E(r,e,o);break;case"style":Yt(r,o);break;case"g":e=E(r,e,o);break;case"path":e=E(r,e,o),r.hasAttribute("d")&&(n=Qt(r));break;case"rect":e=E(r,e,o),n=Jt(r);break;case"polygon":e=E(r,e,o),n=Ht(r);break;case"polyline":e=E(r,e,o),n=Zt(r);break;case"circle":e=E(r,e,o),n=Ut(r);break;case"ellipse":e=E(r,e,o),n=Wt(r);break;case"line":e=E(r,e,o),n=Gt(r);break;case"defs":s=!0;break;case"use":{e=E(r,e,o);const f=(r.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),p=(l=r.viewportElement)==null?void 0:l.getElementById(f);p?H(p,e,t):console.warn(`'use node' references non-existent node id: ${f}`);break}default:console.warn(r);break}const i=new b,c=[],a=Ft(r,i,c);n&&(n.matrix(i),t.push(n),n.style=e);const h=r.childNodes;for(let y=0,f=h.length;y<f;y++){const p=h[y];s&&p.nodeName!=="style"&&p.nodeName!=="defs"||H(p,e,t)}return a&&(c.pop(),c.length>0?i.copy(c[c.length-1]):i.identity()),t}const xt="data:image/svg+xml;",Mt=`${xt}base64,`,Pt=`${xt}charset=utf8,`;function mt(r){if(typeof r=="string"){let e;return r.startsWith(Mt)?(r=r.substring(Mt.length,r.length),e=atob(r)):r.startsWith(Pt)?(r=r.substring(Pt.length,r.length),e=decodeURIComponent(r)):e=r,new DOMParser().parseFromString(e,"image/svg+xml").documentElement}else return r}function Kt(r){return H(mt(r),{})}function te(r){if(!r.length)return;const e=u.MAX,t=u.MIN;return r.forEach(s=>s.getMinMax(e,t)),new L(e.x,e.y,t.x-e.x,t.y-e.y)}d.BoundingBox=L,d.CircleCurve=_,d.CubicBezierCurve=nt,d.Curve=k,d.CurvePath=R,d.EllipseCurve=ot,d.HeartCurve=Dt,d.LineCurve=X,d.Matrix3=b,d.Path2D=I,d.PloygonCurve=Xt,d.QuadraticBezierCurve=lt,d.RectangularCurve=ut,d.SplineCurve=yt,d.Vector2=u,d.addPathCommandsToPath2D=W,d.getPathsBoundingBox=te,d.parseArcCommand=J,d.parsePathDataArgs=A,d.parseSvg=Kt,d.parseSvgToDom=mt,d.pathCommandsToPathData=K,d.pathDataToPathCommands=G,d.setCanvasContext=q,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -3087,4 +3087,14 @@ function parseSvg(svg) {
3087
3087
  return parseNode(parseSvgToDom(svg), {});
3088
3088
  }
3089
3089
 
3090
- export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, Vector2, addPathCommandsToPath2D, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
3090
+ function getPathsBoundingBox(paths) {
3091
+ if (!paths.length) {
3092
+ return void 0;
3093
+ }
3094
+ const min = Vector2.MAX;
3095
+ const max = Vector2.MIN;
3096
+ paths.forEach((path) => path.getMinMax(min, max));
3097
+ return new BoundingBox(min.x, min.y, max.x - min.x, max.y - min.y);
3098
+ }
3099
+
3100
+ export { BoundingBox, CircleCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, HeartCurve, LineCurve, Matrix3, Path2D, PloygonCurve, QuadraticBezierCurve, RectangularCurve, SplineCurve, Vector2, addPathCommandsToPath2D, getPathsBoundingBox, parseArcCommand, parsePathDataArgs, parseSvg, parseSvgToDom, pathCommandsToPathData, pathDataToPathCommands, setCanvasContext };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.2.1",
5
5
  "packageManager": "pnpm@9.9.0",
6
6
  "description": "A modern Path2D library, fully compatible with Web Path2D, with additional support for path animation, path deformation, path playback, etc.",
7
7
  "author": "wxm",