modern-path2d 1.4.8 → 1.4.10

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
@@ -1783,37 +1783,50 @@ function windingNumber(px, py, path) {
1783
1783
  }
1784
1784
  return wn;
1785
1785
  }
1786
+ function distance(p1, p2) {
1787
+ const dx = p2[0] - p1[0];
1788
+ const dy = p2[1] - p1[1];
1789
+ return Math.sqrt(dx * dx + dy * dy);
1790
+ }
1786
1791
  function nonzeroFillRule(paths) {
1787
1792
  const pathsLen = paths.length;
1788
- const results = paths.map((_, i) => ({ index: i, parentIndex: null, wn: 0 }));
1793
+ const results = paths.map((_, i) => ({
1794
+ index: i,
1795
+ dist: 0,
1796
+ wn: 0,
1797
+ parentIndex: void 0
1798
+ }));
1789
1799
  for (let i = 0; i < pathsLen; i++) {
1790
- let best = null;
1791
1800
  if (signedArea(paths[i]) < 0) {
1792
1801
  continue;
1793
1802
  }
1794
- const points = [
1795
- paths[i][0],
1796
- paths[i][1]
1803
+ const firstPoint = paths[i];
1804
+ const testPointArray = [
1805
+ ...firstPoint
1797
1806
  ];
1807
+ let parent;
1798
1808
  for (let j = 0; j < pathsLen; j++) {
1799
1809
  if (i === j) {
1800
1810
  continue;
1801
1811
  }
1802
- let wn0 = 0;
1803
- for (let p = 0; p < points.length; p += 2) {
1804
- wn0 = wn0 || windingNumber(points[p], points[p + 1], paths[j]);
1805
- if (wn0) {
1812
+ let wn = 0;
1813
+ for (let p = 0; p < testPointArray.length; p += 2) {
1814
+ wn = wn || windingNumber(testPointArray[p], testPointArray[p + 1], paths[j]);
1815
+ if (wn) {
1806
1816
  break;
1807
1817
  }
1808
1818
  }
1809
- const absWn = Math.abs(wn0);
1810
- if (absWn !== 0 && (!best || absWn > Math.abs(best.wn))) {
1811
- best = { idx: j, wn: wn0 };
1819
+ if (Math.abs(wn) > 0) {
1820
+ const dist = distance(firstPoint, paths[j]);
1821
+ if (!parent || dist < parent.dist) {
1822
+ parent = { index: j, dist, wn };
1823
+ }
1812
1824
  }
1813
1825
  }
1814
- if (best) {
1815
- results[i].parentIndex = best.idx;
1816
- results[i].wn = best.wn;
1826
+ if (parent) {
1827
+ results[i].dist = parent.dist;
1828
+ results[i].wn = parent.wn;
1829
+ results[i].parentIndex = parent.index;
1817
1830
  }
1818
1831
  }
1819
1832
  return results;
@@ -3710,6 +3723,7 @@ class CurvePath extends CompositeCurve {
3710
3723
  }
3711
3724
 
3712
3725
  class Path2D extends CompositeCurve {
3726
+ _meta;
3713
3727
  currentCurve = new CurvePath();
3714
3728
  style;
3715
3729
  get startPoint() {
@@ -3735,6 +3749,13 @@ class Path2D extends CompositeCurve {
3735
3749
  }
3736
3750
  }
3737
3751
  }
3752
+ getMeta() {
3753
+ return this._meta;
3754
+ }
3755
+ setMeta(meta) {
3756
+ this._meta = meta;
3757
+ return this;
3758
+ }
3738
3759
  addPath(path) {
3739
3760
  const index = this.curves.findIndex((v) => v === this.currentCurve);
3740
3761
  if (index > -1) {
@@ -4085,10 +4106,11 @@ class Path2DSet {
4085
4106
  }
4086
4107
  toTriangulatedSvgString(result = this.paths.map((p) => p.fillTriangulate()), padding = 0) {
4087
4108
  let polygonStr = "";
4109
+ let pointStr = "";
4088
4110
  const min = { x: -padding, y: -padding };
4089
4111
  const max = { x: padding, y: padding };
4090
4112
  const results = Array.isArray(result) ? result : [result];
4091
- results.forEach(({ vertices, indices }) => {
4113
+ results.forEach(({ vertices, indices, points = [] }) => {
4092
4114
  const getPoint = (indice) => {
4093
4115
  const x = vertices[indice * 2];
4094
4116
  const y = vertices[indice * 2 + 1];
@@ -4102,11 +4124,35 @@ class Path2DSet {
4102
4124
  const p1 = getPoint(indices[i]);
4103
4125
  const p2 = getPoint(indices[i + 1]);
4104
4126
  const p3 = getPoint(indices[i + 2]);
4105
- polygonStr += `<polygon points="${p1.join(",")} ${p2.join(",")} ${p3.join(",")}" stroke="none" fill="black" />`;
4127
+ polygonStr += `<polygon
4128
+ points="${p1.join(",")} ${p2.join(",")} ${p3.join(",")}"
4129
+ stroke="#28a745"
4130
+ stroke-width="#stroke-width"
4131
+ fill="rgba(40, 167, 69, 0.15)"
4132
+ onmouseover="this.style.fill='rgba(40, 167, 69, 0.5)'"
4133
+ onmouseout="this.style.fill='rgba(40, 167, 69, 0.15)'"
4134
+ />`;
4135
+ }
4136
+ for (let i = 0, len = points.length; i < len; i += 2) {
4137
+ pointStr += `<circle
4138
+ cx="${points[i]}"
4139
+ cy="${points[i + 1]}"
4140
+ r="#r"
4141
+ fill="#dc3545"
4142
+ />`;
4106
4143
  }
4107
4144
  });
4108
4145
  const viewBox = [min.x, min.y, max.x - min.x, max.y - min.y];
4109
- return `<svg width="${viewBox[2]}" height="${viewBox[3]}" viewBox="${viewBox.join(" ")}" xmlns="http://www.w3.org/2000/svg">${polygonStr}</svg>`;
4146
+ const strokeWidth = Math.max(viewBox[2], viewBox[3]) * 1e-3;
4147
+ return `<svg
4148
+ width="${viewBox[2]}"
4149
+ height="${viewBox[3]}"
4150
+ viewBox="${viewBox.join(" ")}"
4151
+ xmlns="http://www.w3.org/2000/svg"
4152
+ >
4153
+ ${polygonStr.replace(/#stroke-width/g, String(strokeWidth))}
4154
+ ${pointStr.replace(/#r/g, String(strokeWidth))}
4155
+ </svg>`;
4110
4156
  }
4111
4157
  toTriangulatedSvg(result, padding) {
4112
4158
  return new DOMParser().parseFromString(this.toTriangulatedSvgString(result, padding), "image/svg+xml").documentElement;
@@ -4114,7 +4160,14 @@ class Path2DSet {
4114
4160
  toSvgString() {
4115
4161
  const { x, y, width, height } = this.getBoundingBox();
4116
4162
  const content = this.paths.map((path) => path.toSvgPathString()).join("");
4117
- return `<svg viewBox="${x} ${y} ${width} ${height}" width="${width}px" height="${height}px" xmlns="http://www.w3.org/2000/svg">${content}</svg>`;
4163
+ return `<svg
4164
+ viewBox="${x} ${y} ${width} ${height}"
4165
+ width="${width}px"
4166
+ height="${height}px"
4167
+ xmlns="http://www.w3.org/2000/svg"
4168
+ >
4169
+ ${content}
4170
+ </svg>`;
4118
4171
  }
4119
4172
  toSvgUrl() {
4120
4173
  return `data:image/svg+xml;base64,${btoa(this.toSvgString())}`;
package/dist/index.d.cts CHANGED
@@ -201,8 +201,9 @@ declare function getIntersectionPoint(p1: Vector2, p2: Vector2, q1: Vector2, q2:
201
201
 
202
202
  interface Grouping {
203
203
  index: number;
204
- parentIndex: number | null;
204
+ dist: number;
205
205
  wn: number;
206
+ parentIndex?: number;
206
207
  }
207
208
  declare function nonzeroFillRule(paths: number[][]): Grouping[];
208
209
 
@@ -485,13 +486,16 @@ declare class CurvePath extends CompositeCurve {
485
486
  * ----CubicBezierCurve
486
487
  * ----...
487
488
  */
488
- declare class Path2D extends CompositeCurve<CurvePath> {
489
+ declare class Path2D<T = any> extends CompositeCurve<CurvePath> {
490
+ protected _meta?: T;
489
491
  currentCurve: CurvePath;
490
492
  style: Partial<Path2DStyle>;
491
493
  get startPoint(): Vector2 | undefined;
492
494
  get currentPoint(): Vector2 | undefined;
493
495
  get strokeWidth(): number;
494
496
  constructor(path?: Path2D | Path2DCommand[] | Path2DData, style?: Partial<Path2DStyle>);
497
+ getMeta(): T | undefined;
498
+ setMeta(meta: T | undefined): this;
495
499
  addPath(path: Path2D | CurvePath): this;
496
500
  closePath(): this;
497
501
  moveTo(x: number, y: number): this;
@@ -526,13 +530,18 @@ declare class Path2D extends CompositeCurve<CurvePath> {
526
530
  copy(source: Path2D): this;
527
531
  }
528
532
 
529
- declare class Path2DSet {
530
- paths: Path2D[];
533
+ interface TriangulatedResult {
534
+ vertices: number[];
535
+ indices: number[];
536
+ points?: number[];
537
+ }
538
+ declare class Path2DSet<T = any> {
539
+ paths: Path2D<T>[];
531
540
  viewBox?: number[] | undefined;
532
- constructor(paths?: Path2D[], viewBox?: number[] | undefined);
541
+ constructor(paths?: Path2D<T>[], viewBox?: number[] | undefined);
533
542
  getBoundingBox(withStyle?: boolean): BoundingBox | undefined;
534
- toTriangulatedSvgString(result?: FillTriangulatedResult | StrokeTriangulatedResult | (FillTriangulatedResult | StrokeTriangulatedResult)[], padding?: number): string;
535
- toTriangulatedSvg(result?: FillTriangulatedResult | StrokeTriangulatedResult | (FillTriangulatedResult | StrokeTriangulatedResult)[], padding?: number): SVGElement;
543
+ toTriangulatedSvgString(result?: TriangulatedResult | TriangulatedResult[], padding?: number): string;
544
+ toTriangulatedSvg(result?: TriangulatedResult | TriangulatedResult[], padding?: number): SVGElement;
536
545
  toSvgString(): string;
537
546
  toSvgUrl(): string;
538
547
  toSvg(): SVGElement;
@@ -584,4 +593,4 @@ declare function svgToDom(svg: string | SVGElement): SVGElement;
584
593
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
585
594
 
586
595
  export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, Matrix3, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
587
- export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, VectorLike };
596
+ export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, TriangulatedResult, VectorLike };
package/dist/index.d.mts CHANGED
@@ -201,8 +201,9 @@ declare function getIntersectionPoint(p1: Vector2, p2: Vector2, q1: Vector2, q2:
201
201
 
202
202
  interface Grouping {
203
203
  index: number;
204
- parentIndex: number | null;
204
+ dist: number;
205
205
  wn: number;
206
+ parentIndex?: number;
206
207
  }
207
208
  declare function nonzeroFillRule(paths: number[][]): Grouping[];
208
209
 
@@ -485,13 +486,16 @@ declare class CurvePath extends CompositeCurve {
485
486
  * ----CubicBezierCurve
486
487
  * ----...
487
488
  */
488
- declare class Path2D extends CompositeCurve<CurvePath> {
489
+ declare class Path2D<T = any> extends CompositeCurve<CurvePath> {
490
+ protected _meta?: T;
489
491
  currentCurve: CurvePath;
490
492
  style: Partial<Path2DStyle>;
491
493
  get startPoint(): Vector2 | undefined;
492
494
  get currentPoint(): Vector2 | undefined;
493
495
  get strokeWidth(): number;
494
496
  constructor(path?: Path2D | Path2DCommand[] | Path2DData, style?: Partial<Path2DStyle>);
497
+ getMeta(): T | undefined;
498
+ setMeta(meta: T | undefined): this;
495
499
  addPath(path: Path2D | CurvePath): this;
496
500
  closePath(): this;
497
501
  moveTo(x: number, y: number): this;
@@ -526,13 +530,18 @@ declare class Path2D extends CompositeCurve<CurvePath> {
526
530
  copy(source: Path2D): this;
527
531
  }
528
532
 
529
- declare class Path2DSet {
530
- paths: Path2D[];
533
+ interface TriangulatedResult {
534
+ vertices: number[];
535
+ indices: number[];
536
+ points?: number[];
537
+ }
538
+ declare class Path2DSet<T = any> {
539
+ paths: Path2D<T>[];
531
540
  viewBox?: number[] | undefined;
532
- constructor(paths?: Path2D[], viewBox?: number[] | undefined);
541
+ constructor(paths?: Path2D<T>[], viewBox?: number[] | undefined);
533
542
  getBoundingBox(withStyle?: boolean): BoundingBox | undefined;
534
- toTriangulatedSvgString(result?: FillTriangulatedResult | StrokeTriangulatedResult | (FillTriangulatedResult | StrokeTriangulatedResult)[], padding?: number): string;
535
- toTriangulatedSvg(result?: FillTriangulatedResult | StrokeTriangulatedResult | (FillTriangulatedResult | StrokeTriangulatedResult)[], padding?: number): SVGElement;
543
+ toTriangulatedSvgString(result?: TriangulatedResult | TriangulatedResult[], padding?: number): string;
544
+ toTriangulatedSvg(result?: TriangulatedResult | TriangulatedResult[], padding?: number): SVGElement;
536
545
  toSvgString(): string;
537
546
  toSvgUrl(): string;
538
547
  toSvg(): SVGElement;
@@ -584,4 +593,4 @@ declare function svgToDom(svg: string | SVGElement): SVGElement;
584
593
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
585
594
 
586
595
  export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, Matrix3, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
587
- export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, VectorLike };
596
+ export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, TriangulatedResult, VectorLike };
package/dist/index.d.ts CHANGED
@@ -201,8 +201,9 @@ declare function getIntersectionPoint(p1: Vector2, p2: Vector2, q1: Vector2, q2:
201
201
 
202
202
  interface Grouping {
203
203
  index: number;
204
- parentIndex: number | null;
204
+ dist: number;
205
205
  wn: number;
206
+ parentIndex?: number;
206
207
  }
207
208
  declare function nonzeroFillRule(paths: number[][]): Grouping[];
208
209
 
@@ -485,13 +486,16 @@ declare class CurvePath extends CompositeCurve {
485
486
  * ----CubicBezierCurve
486
487
  * ----...
487
488
  */
488
- declare class Path2D extends CompositeCurve<CurvePath> {
489
+ declare class Path2D<T = any> extends CompositeCurve<CurvePath> {
490
+ protected _meta?: T;
489
491
  currentCurve: CurvePath;
490
492
  style: Partial<Path2DStyle>;
491
493
  get startPoint(): Vector2 | undefined;
492
494
  get currentPoint(): Vector2 | undefined;
493
495
  get strokeWidth(): number;
494
496
  constructor(path?: Path2D | Path2DCommand[] | Path2DData, style?: Partial<Path2DStyle>);
497
+ getMeta(): T | undefined;
498
+ setMeta(meta: T | undefined): this;
495
499
  addPath(path: Path2D | CurvePath): this;
496
500
  closePath(): this;
497
501
  moveTo(x: number, y: number): this;
@@ -526,13 +530,18 @@ declare class Path2D extends CompositeCurve<CurvePath> {
526
530
  copy(source: Path2D): this;
527
531
  }
528
532
 
529
- declare class Path2DSet {
530
- paths: Path2D[];
533
+ interface TriangulatedResult {
534
+ vertices: number[];
535
+ indices: number[];
536
+ points?: number[];
537
+ }
538
+ declare class Path2DSet<T = any> {
539
+ paths: Path2D<T>[];
531
540
  viewBox?: number[] | undefined;
532
- constructor(paths?: Path2D[], viewBox?: number[] | undefined);
541
+ constructor(paths?: Path2D<T>[], viewBox?: number[] | undefined);
533
542
  getBoundingBox(withStyle?: boolean): BoundingBox | undefined;
534
- toTriangulatedSvgString(result?: FillTriangulatedResult | StrokeTriangulatedResult | (FillTriangulatedResult | StrokeTriangulatedResult)[], padding?: number): string;
535
- toTriangulatedSvg(result?: FillTriangulatedResult | StrokeTriangulatedResult | (FillTriangulatedResult | StrokeTriangulatedResult)[], padding?: number): SVGElement;
543
+ toTriangulatedSvgString(result?: TriangulatedResult | TriangulatedResult[], padding?: number): string;
544
+ toTriangulatedSvg(result?: TriangulatedResult | TriangulatedResult[], padding?: number): SVGElement;
536
545
  toSvgString(): string;
537
546
  toSvgUrl(): string;
538
547
  toSvg(): SVGElement;
@@ -584,4 +593,4 @@ declare function svgToDom(svg: string | SVGElement): SVGElement;
584
593
  declare function svgToPath2DSet(svg: string | SVGElement): Path2DSet;
585
594
 
586
595
  export { ArcCurve, BoundingBox, CompositeCurve, CubicBezierCurve, Curve, CurvePath, EllipseCurve, EquilateralPloygonCurve, FFDControlGrid, LineCurve, Matrix3, Path2D, Path2DSet, PloygonCurve, QuadraticBezierCurve, RectangleCurve, RoundRectangleCurve, SplineCurve, Vector2, applyFFD, catmullRom, cubicBezier, drawPoint, fillTriangulate, getAdaptiveCubicBezierCurvePoints, getAdaptiveQuadraticBezierCurvePoints, getDirectedArea, getIntersectionPoint, nonzeroFillRule, parseArcCommand, parsePathDataArgs, quadraticBezier, setCanvasContext, strokeTriangulate, svgPathCommandsAddToPath2D, svgPathCommandsToData, svgPathDataToCommands, svgToDom, svgToPath2DSet, toKebabCase };
587
- export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, VectorLike };
596
+ export type { DrawPointOptions, FillRule, FillTriangulateOptions, FillTriangulatedResult, LineCap, LineJoin, LineStyle, Path2DCommand, Path2DData, Path2DDrawStyle, Path2DStyle, StrokeLinecap, StrokeLinejoin, StrokeTriangulateOptions, StrokeTriangulatedResult, TriangulatedResult, VectorLike };
package/dist/index.js CHANGED
@@ -1,2 +1,29 @@
1
- (function(b,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(b=typeof globalThis<"u"?globalThis:b||self,tt(b.modernPath2d={}))})(this,function(b){"use strict";function tt(i,t,e,n={}){const{radius:r=1}=n;i.moveTo(t,e),i.arc(t,e,r,0,Math.PI*2)}const ke={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ct(i,t){const{fill:e="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:c=0,strokeDasharray:l=[],strokeDashoffset:h=0,shadowOffsetX:a=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:p="rgba(0, 0, 0, 0)"}=t;i.fillStyle=e,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=ke[s],i.miterLimit=c,i.setLineDash(l),i.lineDashOffset=h,i.shadowOffsetX=a,i.shadowOffsetY=y,i.shadowBlur=f,i.shadowColor=p}class d{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new d(1/0,1/0)}static get MIN(){return new d(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const n=-t/180*Math.PI,r=this.x-e.x,o=-(this.y-e.y),s=Math.sin(n),c=Math.cos(n);return this.set(e.x+(r*c-o*s),e.y-(r*s+o*c)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,n={x:0,y:0}){const r=t<0?n.x-this.x+n.x:this.x,o=e<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(t)*o),this.y=n.y+(o+Math.tan(e)*r),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new d(this.x,this.y)}}class U{constructor(t=0,e=0,n=0,r=0){this.left=t,this.top=e,this.width=n,this.height=r}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new d((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new U;if(t.length===1)return t[0].clone();const e=t[0],n=t.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:e?.left??0,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0});return new U(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new U(this.left,this.top,this.width,this.height)}}class z{elements=[];constructor(t=1,e=0,n=0,r=0,o=1,s=0,c=0,l=0,h=1){this.set(t,e,n,r,o,s,c,l,h)}set(t,e,n,r,o,s,c,l,h){const a=this.elements;return a[0]=t,a[1]=r,a[2]=c,a[3]=e,a[4]=o,a[5]=l,a[6]=n,a[7]=s,a[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,o=this.elements,s=n[0],c=n[3],l=n[6],h=n[1],a=n[4],y=n[7],f=n[2],p=n[5],u=n[8],x=r[0],m=r[3],P=r[6],A=r[1],w=r[4],v=r[7],C=r[2],S=r[5],g=r[8];return o[0]=s*x+c*A+l*C,o[3]=s*m+c*w+l*S,o[6]=s*P+c*v+l*g,o[1]=h*x+a*A+y*C,o[4]=h*m+a*w+y*S,o[7]=h*P+a*v+y*g,o[2]=f*x+p*A+u*C,o[5]=f*m+p*w+u*S,o[8]=f*P+p*v+u*g,this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],o=t[3],s=t[4],c=t[5],l=t[6],h=t[7],a=t[8],y=a*s-c*h,f=c*l-a*o,p=h*o-s*l,u=e*y+n*f+r*p;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/u;return t[0]=y*x,t[1]=(r*h-a*n)*x,t[2]=(c*n-r*s)*x,t[3]=f*x,t[4]=(a*e-r*l)*x,t[5]=(r*o-c*e)*x,t[6]=p*x,t[7]=(n*l-h*e)*x,t[8]=(s*e-n*o)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(bt.makeScale(t,e)),this}rotate(t){return this.premultiply(bt.makeRotation(-t)),this}translate(t,e){return this.premultiply(bt.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new z;function zt(i,t,e,n){const r=i*e+t*n,o=Math.sqrt(i*i+t*t)*Math.sqrt(e*e+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-t*e<0&&(s=-s),s}function Ot(i,t,e,n,r,o,s,c){if(t===0||e===0){i.lineTo(c.x,c.y);return}n=n*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const l=(s.x-c.x)/2,h=(s.y-c.y)/2,a=Math.cos(n)*l+Math.sin(n)*h,y=-Math.sin(n)*l+Math.cos(n)*h;let f=t*t,p=e*e;const u=a*a,x=y*y,m=u/f+x/p;if(m>1){const $=Math.sqrt(m);t=$*t,e=$*e,f=t*t,p=e*e}const P=f*x+p*u,A=(f*p-P)/P;let w=Math.sqrt(Math.max(0,A));r===o&&(w=-w);const v=w*t*y/e,C=-w*e*a/t,S=Math.cos(n)*v-Math.sin(n)*C+(s.x+c.x)/2,g=Math.sin(n)*v+Math.cos(n)*C+(s.y+c.y)/2,M=zt(1,0,(a-v)/t,(y-C)/e),q=zt((a-v)/t,(y-C)/e,(-a-v)/t,(-y-C)/e)%(Math.PI*2);i.ellipse(S,g,t,e,n,M,M+q,o===0)}const V={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function O(i,t,e=0){let c=0,l=!0,h="",a="";const y=[];function f(m,P,A){const w=new SyntaxError(`Unexpected character "${m}" at index ${P}.`);throw w.partial=A,w}function p(){h!==""&&(a===""?y.push(Number(h)):y.push(Number(h)*10**Number(a))),h="",a=""}let u;const x=i.length;for(let m=0;m<x;m++){if(u=i[m],Array.isArray(t)&&t.includes(y.length%e)&&V.FLAGS.test(u)){c=1,h=u,p();continue}if(c===0){if(V.WHITESPACE.test(u))continue;if(V.DIGIT.test(u)||V.SIGN.test(u)){c=1,h=u;continue}if(V.POINT.test(u)){c=2,h=u;continue}V.COMMA.test(u)&&(l&&f(u,m,y),l=!0)}if(c===1){if(V.DIGIT.test(u)){h+=u;continue}if(V.POINT.test(u)){h+=u,c=2;continue}if(V.EXP.test(u)){c=3;continue}V.SIGN.test(u)&&h.length===1&&V.SIGN.test(h[0])&&f(u,m,y)}if(c===2){if(V.DIGIT.test(u)){h+=u;continue}if(V.EXP.test(u)){c=3;continue}V.POINT.test(u)&&h[h.length-1]==="."&&f(u,m,y)}if(c===3){if(V.DIGIT.test(u)){a+=u;continue}if(V.SIGN.test(u)){if(a===""){a+=u;continue}a.length===1&&V.SIGN.test(a)&&f(u,m,y)}}V.WHITESPACE.test(u)?(p(),c=0,l=!1):V.COMMA.test(u)?(p(),c=0,l=!0):V.SIGN.test(u)?(p(),c=1,h=u):V.POINT.test(u)?(p(),c=2,h=u):f(u,m,y)}return p(),y}function et(i,t){return i-(t-i)}function At(i,t){const e=new d,n=new d;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?e.add(s):e.copy(s),t.moveTo(e.x,e.y),n.copy(e);else if(s.type==="h"||s.type==="H")s.type==="h"?e.x+=s.x:e.x=s.x,t.lineTo(e.x,e.y),n.copy(e);else if(s.type==="v"||s.type==="V")s.type==="v"?e.y+=s.y:e.y=s.y,t.lineTo(e.x,e.y),n.copy(e);else if(s.type==="l"||s.type==="L")s.type==="l"?e.add(s):e.copy(s),t.lineTo(e.x,e.y),n.copy(e);else if(s.type==="c"||s.type==="C")s.type==="c"?(t.bezierCurveTo(e.x+s.x1,e.y+s.y1,e.x+s.x2,e.y+s.y2,e.x+s.x,e.y+s.y),n.x=e.x+s.x2,n.y=e.y+s.y2,e.add(s)):(t.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,e.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(t.bezierCurveTo(et(e.x,n.x),et(e.y,n.y),e.x+s.x2,e.y+s.y2,e.x+s.x,e.y+s.y),n.x=e.x+s.x2,n.y=e.y+s.y2,e.add(s)):(t.bezierCurveTo(et(e.x,n.x),et(e.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,e.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(t.quadraticCurveTo(e.x+s.x1,e.y+s.y1,e.x+s.x,e.y+s.y),n.x=e.x+s.x1,n.y=e.y+s.y1,e.add(s)):(t.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,e.copy(s));else if(s.type==="t"||s.type==="T"){const c=et(e.x,n.x),l=et(e.y,n.y);n.x=c,n.y=l,s.type==="t"?(t.quadraticCurveTo(c,l,e.x+s.x,e.y+s.y),e.add(s)):(t.quadraticCurveTo(c,l,s.x,s.y),e.copy(s))}else if(s.type==="a"||s.type==="A"){const c=e.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;e.add(s)}else{if(e.equals(s))continue;e.copy(s)}n.copy(e),Ot(t,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,c,e)}else s.type==="z"||s.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",s)}}function Bt(i){let t,e;const n=[];for(let r=0,o=i.length;r<o;r++){const s=i[r];switch(s.type){case"m":case"M":if(s.x.toFixed(4)===e?.x.toFixed(4)&&s.y.toFixed(4)===e?.y.toFixed(4))continue;n.push(`${s.type} ${s.x} ${s.y}`),e={x:s.x,y:s.y},t={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),e={x:s.x,y:e?.y??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),e={x:e?.x??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"c":case"C":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x2} ${s.y2} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"a":case"A":n.push(`${s.type} ${s.rx} ${s.ry} ${s.angle} ${s.largeArcFlag} ${s.sweepFlag} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),t&&(e={x:t.x,y:t.y});break}}return n.join(" ")}const Ie=/[a-df-z][^a-df-z]*/gi;function kt(i){const t=[],e=i.match(Ie);if(!e)return t;for(let n=0,r=e.length;n<r;n++){const o=e[n],s=o.charAt(0),c=o.slice(1).trim();let l;switch(s){case"m":case"M":l=O(c);for(let h=0,a=l.length;h<a;h+=2)h===0?t.push({type:s,x:l[h],y:l[h+1]}):t.push({type:s==="m"?"l":"L",x:l[h],y:l[h+1]});break;case"h":case"H":l=O(c);for(let h=0,a=l.length;h<a;h++)t.push({type:s,x:l[h]});break;case"v":case"V":l=O(c);for(let h=0,a=l.length;h<a;h++)t.push({type:s,y:l[h]});break;case"l":case"L":l=O(c);for(let h=0,a=l.length;h<a;h+=2)t.push({type:s,x:l[h],y:l[h+1]});break;case"c":case"C":l=O(c);for(let h=0,a=l.length;h<a;h+=6)t.push({type:s,x1:l[h],y1:l[h+1],x2:l[h+2],y2:l[h+3],x:l[h+4],y:l[h+5]});break;case"s":case"S":l=O(c);for(let h=0,a=l.length;h<a;h+=4)t.push({type:s,x2:l[h],y2:l[h+1],x:l[h+2],y:l[h+3]});break;case"q":case"Q":l=O(c);for(let h=0,a=l.length;h<a;h+=4)t.push({type:s,x1:l[h],y1:l[h+1],x:l[h+2],y:l[h+3]});break;case"t":case"T":l=O(c);for(let h=0,a=l.length;h<a;h+=2)t.push({type:s,x:l[h],y:l[h+1]});break;case"a":case"A":l=O(c,[3,4],7);for(let h=0,a=l.length;h<a;h+=7)t.push({type:s,rx:l[h],ry:l[h+1],angle:l[h+2],largeArcFlag:l[h+3],sweepFlag:l[h+4],x:l[h+5],y:l[h+6]});break;case"z":case"Z":t.push({type:s});break;default:console.warn(o)}}return t}const jt="data:image/svg+xml;",Zt=`${jt}base64,`,Ut=`${jt}charset=utf8,`;function Xt(i){if(typeof i=="string"){let t;i.startsWith(Zt)?(i=i.substring(Zt.length,i.length),t=atob(i)):i.startsWith(Ut)?(i=i.substring(Ut.length,i.length),t=decodeURIComponent(i)):t=i;const e=new DOMParser().parseFromString(t,"text/xml"),n=e.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
2
- ${t}`);return e.documentElement}else return i}const Se="px",Ee=90,Wt=["mm","cm","in","pt","pc","px"],Gt={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 _(i){let t="px";if(typeof i=="string")for(let n=0,r=Wt.length;n<r;n++){const o=Wt[n];if(i.endsWith(o)){t=o,i=i.substring(0,i.length-o.length);break}}let e;return e=Gt[t][Se],e<0&&(e=Gt[t].in*Ee),e*Number.parseFloat(i)}const _e=new z,xt=new z,Ht=new z,Qt=new z;function Le(i,t,e){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=$e(i);return e.length>0&&n.premultiply(e[e.length-1]),t.copy(n),e.push(n),n}function $e(i){const t=new z,e=_e;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&t.translate(_(i.getAttribute("x")),_(i.getAttribute("y"))),i.hasAttribute("transform")){const n=i.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const s=o.indexOf("("),c=o.length;if(s>0&&s<c){const l=o.slice(0,s),h=O(o.slice(s+1));switch(e.identity(),l){case"translate":if(h.length>=1){const a=h[0];let y=0;h.length>=2&&(y=h[1]),e.translate(a,y)}break;case"rotate":if(h.length>=1){let a=0,y=0,f=0;a=h[0]*Math.PI/180,h.length>=3&&(y=h[1],f=h[2]),xt.makeTranslation(-y,-f),Ht.makeRotation(a),Qt.multiplyMatrices(Ht,xt),xt.makeTranslation(y,f),e.multiplyMatrices(xt,Qt)}break;case"scale":h.length>=1&&e.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&e.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&e.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&e.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}t.premultiply(e)}}return t}function Fe(i){return new j().arc(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("r")||0),0,Math.PI*2)}function Ne(i,t){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let e=0;e<i.sheet.cssRules.length;e++){const n=i.sheet.cssRules[e];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,c=0;c<s;c++){const l=n.style.item(c);o[l]=n.style.getPropertyValue(l)}for(let s=0;s<r.length;s++)t[r[s]]=Object.assign(t[r[s]]||{},{...o})}}function De(i){return new j().ellipse(_(i.getAttribute("cx")||0),_(i.getAttribute("cy")||0),_(i.getAttribute("rx")||0),_(i.getAttribute("ry")||0),0,0,Math.PI*2)}function Ve(i){return new j().moveTo(_(i.getAttribute("x1")||0),_(i.getAttribute("y1")||0)).lineTo(_(i.getAttribute("x2")||0),_(i.getAttribute("y2")||0))}function qe(i){const t=new j,e=i.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const Re=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ze(i){const t=new j;let e=0;return i.getAttribute("points")?.replace(Re,(n,r,o)=>{const s=_(r),c=_(o);return e===0?t.moveTo(s,c):t.lineTo(s,c),e++,n}),t.currentCurve.autoClose=!0,t}const Oe=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Be(i){const t=new j;let e=0;return i.getAttribute("points")?.replace(Oe,(n,r,o)=>{const s=_(r),c=_(o);return e===0?t.moveTo(s,c):t.lineTo(s,c),e++,n}),t.currentCurve.autoClose=!1,t}function je(i){const t=_(i.getAttribute("x")||0),e=_(i.getAttribute("y")||0),n=_(i.getAttribute("rx")||i.getAttribute("ry")||0),r=_(i.getAttribute("ry")||i.getAttribute("rx")||0),o=_(i.getAttribute("width")),s=_(i.getAttribute("height")),c=1-.551915024494,l=new j;return l.moveTo(t+n,e),l.lineTo(t+o-n,e),(n!==0||r!==0)&&l.bezierCurveTo(t+o-n*c,e,t+o,e+r*c,t+o,e+r),l.lineTo(t+o,e+s-r),(n!==0||r!==0)&&l.bezierCurveTo(t+o,e+s-r*c,t+o-n*c,e+s,t+o-n,e+s),l.lineTo(t+n,e+s),(n!==0||r!==0)&&l.bezierCurveTo(t+n*c,e+s,t,e+s-r*c,t,e+s-r),l.lineTo(t,e+r),(n!==0||r!==0)&&l.bezierCurveTo(t,e+r*c,t+n*c,e,t+n,e),l}function Z(i,t,e){t=Object.assign({},t);let n={};if(i.hasAttribute("class")){const h=i.getAttribute("class").split(/\s/).filter(Boolean).map(a=>a.trim());for(let a=0;a<h.length;a++)n=Object.assign(n,e[`.${h[a]}`])}i.hasAttribute("id")&&(n=Object.assign(n,e[`#${i.getAttribute("id")}`]));for(let h=i.style.length,a=0;a<h;a++){const y=i.style.item(a),f=i.style.getPropertyValue(y);t[y]=f,n[y]=f}function r(h,a,y=o){i.hasAttribute(h)&&(t[a]=y(i.getAttribute(h))),n[h]&&(t[a]=y(n[h]))}function o(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function s(h){return Math.max(0,Math.min(1,_(h)))}function c(h){return Math.max(0,_(h))}function l(h){return h.split(" ").filter(a=>a!=="").map(a=>_(a))}return r("fill","fill"),r("fill-opacity","fillOpacity",s),r("fill-rule","fillRule"),r("opacity","opacity",s),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",s),r("stroke-width","strokeWidth",c),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",c),r("stroke-dasharray","strokeDasharray",l),r("stroke-dashoffset","strokeDashoffset",_),r("visibility","visibility"),t}function It(i,t,e=[],n={}){if(i.nodeType!==1)return e;let r=!1,o=null,s={...t};switch(i.nodeName){case"svg":s=Z(i,s,n);break;case"style":Ne(i,n);break;case"g":s=Z(i,s,n);break;case"path":s=Z(i,s,n),i.hasAttribute("d")&&(o=qe(i));break;case"rect":s=Z(i,s,n),o=je(i);break;case"polygon":s=Z(i,s,n),o=ze(i);break;case"polyline":s=Z(i,s,n),o=Be(i);break;case"circle":s=Z(i,s,n),o=Fe(i);break;case"ellipse":s=Z(i,s,n),o=De(i);break;case"line":s=Z(i,s,n),o=Ve(i);break;case"defs":r=!0;break;case"use":{s=Z(i,s,n);const f=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),p=i.viewportElement?.getElementById(f);p?It(p,s,e,n):console.warn(`'use node' references non-existent node id: ${f}`);break}default:console.warn(i);break}if(s.display==="none")return e;const c=new z,l=[],h=Le(i,c,l);o&&(o.applyTransform(c),e.push(o),o.style={...s});const a=i.childNodes;for(let y=0,f=a.length;y<f;y++){const p=a[y];r&&p.nodeName!=="style"&&p.nodeName!=="defs"||It(p,s,e,n)}return h&&(l.pop(),l.length>0?c.copy(l[l.length-1]):c.identity()),e}function Ze(i){const t=Xt(i);return new ve(It(t,{}),t.getAttribute("viewBox")?.trim().split(" ").map(e=>Number(e)))}function St(i,t,e,n,r){const o=(n-t)*.5,s=(r-e)*.5,c=i*i,l=i*c;return(2*e-2*n+o+s)*l+(-3*e+3*n-2*o-s)*c+o*i+e}function Ue(i,t){const e=1-i;return e*e*e*t}function Xe(i,t){const e=1-i;return 3*e*e*i*t}function We(i,t){return 3*(1-i)*i*i*t}function Ge(i,t){return i*i*i*t}function Et(i,t,e,n,r){return Ue(i,t)+Xe(i,e)+We(i,n)+Ge(i,r)}function He(i,t,e=2){const n=t&&t.length,r=n?t[0]*e:i.length;let o=Yt(i,0,r,e,!0);const s=[];if(!o||o.next===o.prev)return s;let c,l,h;if(n&&(o=tn(i,t,o,e)),i.length>80*e){c=i[0],l=i[1];let a=c,y=l;for(let f=e;f<r;f+=e){const p=i[f],u=i[f+1];p<c&&(c=p),u<l&&(l=u),p>a&&(a=p),u>y&&(y=u)}h=Math.max(a-c,y-l),h=h!==0?32767/h:0}return it(o,s,e,c,l,h,0),s}function Yt(i,t,e,n,r){let o;if(r===fn(i,t,e,n)>0)for(let s=t;s<e;s+=n)o=ee(s/n|0,i[s],i[s+1],o);else for(let s=e-n;s>=t;s-=n)o=ee(s/n|0,i[s],i[s+1],o);return o&&nt(o,o.next)&&(ct(o),o=o.next),o}function W(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(nt(e,e.next)||F(e.prev,e,e.next)===0)){if(ct(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function it(i,t,e,n,r,o,s){if(!i)return;!s&&o&&on(i,n,r,o);let c=i;for(;i.prev!==i.next;){const l=i.prev,h=i.next;if(o?Ye(i,n,r,o):Qe(i)){t.push(l.i,i.i,h.i),ct(i),i=h.next,c=h.next;continue}if(i=h,i===c){s?s===1?(i=Je(W(i),t),it(i,t,e,n,r,o,2)):s===2&&Ke(i,t,e,n,r,o):it(W(i),t,e,n,r,o,1);break}}}function Qe(i){const t=i.prev,e=i,n=i.next;if(F(t,e,n)>=0)return!1;const r=t.x,o=e.x,s=n.x,c=t.y,l=e.y,h=n.y,a=Math.min(r,o,s),y=Math.min(c,l,h),f=Math.max(r,o,s),p=Math.max(c,l,h);let u=n.next;for(;u!==t;){if(u.x>=a&&u.x<=f&&u.y>=y&&u.y<=p&&rt(r,c,o,l,s,h,u.x,u.y)&&F(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function Ye(i,t,e,n){const r=i.prev,o=i,s=i.next;if(F(r,o,s)>=0)return!1;const c=r.x,l=o.x,h=s.x,a=r.y,y=o.y,f=s.y,p=Math.min(c,l,h),u=Math.min(a,y,f),x=Math.max(c,l,h),m=Math.max(a,y,f),P=_t(p,u,t,e,n),A=_t(x,m,t,e,n);let w=i.prevZ,v=i.nextZ;for(;w&&w.z>=P&&v&&v.z<=A;){if(w.x>=p&&w.x<=x&&w.y>=u&&w.y<=m&&w!==r&&w!==s&&rt(c,a,l,y,h,f,w.x,w.y)&&F(w.prev,w,w.next)>=0||(w=w.prevZ,v.x>=p&&v.x<=x&&v.y>=u&&v.y<=m&&v!==r&&v!==s&&rt(c,a,l,y,h,f,v.x,v.y)&&F(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;w&&w.z>=P;){if(w.x>=p&&w.x<=x&&w.y>=u&&w.y<=m&&w!==r&&w!==s&&rt(c,a,l,y,h,f,w.x,w.y)&&F(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=x&&v.y>=u&&v.y<=m&&v!==r&&v!==s&&rt(c,a,l,y,h,f,v.x,v.y)&&F(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Je(i,t){let e=i;do{const n=e.prev,r=e.next.next;!nt(n,r)&&Kt(n,e,e.next,r)&&ot(n,r)&&ot(r,n)&&(t.push(n.i,e.i,r.i),ct(e),ct(e.next),e=i=r),e=e.next}while(e!==i);return W(e)}function Ke(i,t,e,n,r,o){let s=i;do{let c=s.next.next;for(;c!==s.prev;){if(s.i!==c.i&&ln(s,c)){let l=te(s,c);s=W(s,s.next),l=W(l,l.next),it(s,t,e,n,r,o,0),it(l,t,e,n,r,o,0);return}c=c.next}s=s.next}while(s!==i)}function tn(i,t,e,n){const r=[];for(let o=0,s=t.length;o<s;o++){const c=t[o]*n,l=o<s-1?t[o+1]*n:i.length,h=Yt(i,c,l,n,!1);h===h.next&&(h.steiner=!0),r.push(hn(h))}r.sort(en);for(let o=0;o<r.length;o++)e=nn(r[o],e);return e}function en(i,t){let e=i.x-t.x;if(e===0&&(e=i.y-t.y,e===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=n-r}return e}function nn(i,t){const e=sn(i,t);if(!e)return t;const n=te(e,i);return W(n,n.next),W(e,e.next)}function sn(i,t){let e=t;const n=i.x,r=i.y;let o=-1/0,s;if(nt(i,e))return e;do{if(nt(i,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const y=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(y<=n&&y>o&&(o=y,s=e.x<e.next.x?e:e.next,y===n))return s}e=e.next}while(e!==t);if(!s)return null;const c=s,l=s.x,h=s.y;let a=1/0;e=s;do{if(n>=e.x&&e.x>=l&&n!==e.x&&Jt(r<h?n:o,r,l,h,r<h?o:n,r,e.x,e.y)){const y=Math.abs(r-e.y)/(n-e.x);ot(e,i)&&(y<a||y===a&&(e.x>s.x||e.x===s.x&&rn(s,e)))&&(s=e,a=y)}e=e.next}while(e!==c);return s}function rn(i,t){return F(i.prev,i,t.prev)<0&&F(t.next,i,i.next)<0}function on(i,t,e,n){let r=i;do r.z===0&&(r.z=_t(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,cn(r)}function cn(i){let t,e=1;do{let n=i,r;i=null;let o=null;for(t=0;n;){t++;let s=n,c=0;for(let h=0;h<e&&(c++,s=s.nextZ,!!s);h++);let l=e;for(;c>0||l>0&&s;)c!==0&&(l===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,c--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,e*=2}while(t>1);return i}function _t(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function hn(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Jt(i,t,e,n,r,o,s,c){return(r-s)*(t-c)>=(i-s)*(o-c)&&(i-s)*(n-c)>=(e-s)*(t-c)&&(e-s)*(o-c)>=(r-s)*(n-c)}function rt(i,t,e,n,r,o,s,c){return!(i===s&&t===c)&&Jt(i,t,e,n,r,o,s,c)}function ln(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!an(i,t)&&(ot(i,t)&&ot(t,i)&&un(i,t)&&(F(i.prev,i,t.prev)||F(i,t.prev,t))||nt(i,t)&&F(i.prev,i,i.next)>0&&F(t.prev,t,t.next)>0)}function F(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function nt(i,t){return i.x===t.x&&i.y===t.y}function Kt(i,t,e,n){const r=gt(F(i,t,e)),o=gt(F(i,t,n)),s=gt(F(e,n,i)),c=gt(F(e,n,t));return!!(r!==o&&s!==c||r===0&&pt(i,e,t)||o===0&&pt(i,n,t)||s===0&&pt(e,i,n)||c===0&&pt(e,t,n))}function pt(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function gt(i){return i>0?1:i<0?-1:0}function an(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Kt(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ot(i,t){return F(i.prev,i,i.next)<0?F(i,t,i.next)>=0&&F(i,i.prev,t)>=0:F(i,t,i.prev)<0||F(i,i.next,t)<0}function un(i,t){let e=i,n=!1;const r=(i.x+t.x)/2,o=(i.y+t.y)/2;do e.y>o!=e.next.y>o&&e.next.y!==e.y&&r<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function te(i,t){const e=Lt(i.i,i.x,i.y),n=Lt(t.i,t.x,t.y),r=i.next,o=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,o.next=n,n.prev=o,n}function ee(i,t,e,n){const r=Lt(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ct(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Lt(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function fn(i,t,e,n){let r=0;for(let o=t,s=e-n;o<e;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function $t(i,t={}){let{vertices:e=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=e.length/o,indicesOffset:c=n.length}=t;const l=He(i,r,2);if(l.length){for(let a=0;a<l.length;a+=3)n[c++]=l[a]+s,n[c++]=l[a+1]+s,n[c++]=l[a+2]+s;let h=s*o;for(let a=0;a<i.length;a+=2)e[h]=i[a],e[h+1]=i[a+1],h+=o}return{vertices:e,indices:n}}const yn=8,dt=11920929e-14,xn=1;function ne(i,t,e,n,r,o,s,c,l=.5,h=[]){const y=Math.min(.99,Math.max(0,l));let f=(xn-y)/1;return f*=f,Ft(i,t,e,n,r,o,s,c,h,f,0),h.push(s,c),h}function Ft(i,t,e,n,r,o,s,c,l,h,a){if(a>yn)return;const y=(i+e)/2,f=(t+n)/2,p=(e+r)/2,u=(n+o)/2,x=(r+s)/2,m=(o+c)/2,P=(y+p)/2,A=(f+u)/2,w=(p+x)/2,v=(u+m)/2,C=(P+w)/2,S=(A+v)/2;if(a>0){let g=s-i,M=c-t;const q=Math.abs((e-s)*M-(n-c)*g),$=Math.abs((r-s)*M-(o-c)*g);if(q>dt&&$>dt){if((q+$)*(q+$)<=h*(g*g+M*M)){l.push(C,S);return}}else if(q>dt){if(q*q<=h*(g*g+M*M)){l.push(C,S);return}}else if($>dt){if($*$<=h*(g*g+M*M)){l.push(C,S);return}}else if(g=C-(i+s)/2,M=S-(t+c)/2,g*g+M*M<=h){l.push(C,S);return}}Ft(i,t,y,f,P,A,C,S,l,h,a+1),Ft(C,S,w,v,x,m,s,c,l,h,a+1)}const pn=8,gn=11920929e-14,dn=1;function se(i,t,e,n,r,o,s=.5,c=[]){const h=Math.min(.99,Math.max(0,s));let a=(dn-h)/1;return a*=a,Nt(c,i,t,e,n,r,o,a,0),c.push(r,o),c}function Nt(i,t,e,n,r,o,s,c,l){if(l>pn)return;const h=(t+n)/2,a=(e+r)/2,y=(n+o)/2,f=(r+s)/2,p=(h+y)/2,u=(a+f)/2;let x=o-t,m=s-e;const P=Math.abs((n-o)*m-(r-s)*x);if(P>gn){if(P*P<=c*(x*x+m*m)){i.push(p,u);return}}else if(x=p-(t+o)/2,m=u-(e+s)/2,x*x+m*m<=c){i.push(p,u);return}Nt(i,t,e,h,a,p,u,c,l+1),Nt(i,p,u,y,f,o,s,c,l+1)}function mn(i){let t=0;const e=i.length;for(let n=0;n<e;n+=2){const r=i[n],o=i[n+1],s=i[(n+2)%(e-1)],c=i[(n+3)%e];t+=r*c-s*o}return t/2}function ie(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function re(i,t,e,n){const r=t.clone().sub(i),o=n.clone().sub(e),s=e.clone().sub(i),c=r.cross(o);if(c===0)return new d((i.x+e.x)/2,(i.y+e.y)/2);const l=s.cross(o)/c;return Math.abs(l)>1?new d((i.x+e.x)/2,(i.y+e.y)/2):new d(i.x+l*r.x,i.y+l*r.y)}function Mn(i){let t=0;const e=i.length/2;for(let n=0;n<e;n++){const r=i[2*n],o=i[2*n+1],s=(n+1)%e,c=i[2*s],l=i[2*s+1];t+=(c-r)*(l+o)}return t}function oe(i,t,e,n,r,o){return(e-i)*(o-t)-(r-i)*(n-t)}function wn(i,t,e){const n=e.length;let r=0;for(let o=0,s=n-2;o<n;s=o,o+=2){const c=e[o],l=e[o+1],h=e[s],a=e[s+1];l<=t?a>t&&oe(h,a,c,l,i,t)>0&&r++:a<=t&&oe(h,a,c,l,i,t)<0&&r--}return r}function ce(i){const t=i.length,e=i.map((n,r)=>({index:r,parentIndex:null,wn:0}));for(let n=0;n<t;n++){let r=null;if(Mn(i[n])<0)continue;const o=[i[n][0],i[n][1]];for(let s=0;s<t;s++){if(n===s)continue;let c=0;for(let h=0;h<o.length&&(c=c||wn(o[h],o[h+1],i[s]),!c);h+=2);const l=Math.abs(c);l!==0&&(!r||l>Math.abs(r.wn))&&(r={idx:s,wn:c})}r&&(e[n].parentIndex=r.idx,e[n].wn=r.wn)}return e}function vn(i,t){const e=1-i;return e*e*t}function Pn(i,t){return 2*(1-i)*i*t}function Tn(i,t){return i*i*t}function Dt(i,t,e,n){return vn(i,t)+Pn(i,e)+Tn(i,n)}const Cn=1e-4,he=1e-4;function le(i,t={}){const{vertices:e=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=t,c=Cn;if(i.length===0)return{vertices:e,indices:n};const l=r;let h=l.alignment;if(r.alignment!==.5){let L=bn(i);o&&(L*=-1),h=(h-.5)*L+.5}const a={x:i[0],y:i[1]},y={x:i[i.length-2],y:i[i.length-1]},f=s,p=Math.abs(a.x-y.x)<c&&Math.abs(a.y-y.y)<c;if(f){i=i.slice(),p&&(i.pop(),i.pop(),y.x=i[i.length-2],y.y=i[i.length-1]);const L=(a.x+y.x)*.5,X=(y.y+a.y)*.5;i.unshift(L,X),i.push(L,X)}const u=e,x=i.length/2;let m=i.length;const P=u.length/2,A=l.width/2,w=A*A,v=l.miterLimit*l.miterLimit;let C=i[0],S=i[1],g=i[2],M=i[3],q=0,$=0,k=-(S-M),I=C-g,N=0,D=0,R=Math.sqrt(k*k+I*I);k/=R,I/=R,k*=A,I*=A;const lt=h,T=(1-lt)*2,E=lt*2;f||(l.cap==="round"?m+=G(C-k*(T-E)*.5,S-I*(T-E)*.5,C-k*T,S-I*T,C+k*E,S+I*E,u,!0)+2:l.cap==="square"&&(m+=ae(C,S,k,I,T,E,!0,u))),u.push(C-k*T,S-I*T),u.push(C+k*E,S+I*E);for(let L=1;L<x-1;++L){C=i[(L-1)*2],S=i[(L-1)*2+1],g=i[L*2],M=i[L*2+1],q=i[(L+1)*2],$=i[(L+1)*2+1],k=-(S-M),I=C-g,R=Math.sqrt(k*k+I*I),k/=R,I/=R,k*=A,I*=A,N=-(M-$),D=g-q,R=Math.sqrt(N*N+D*D),N/=R,D/=R,N*=A,D*=A;const X=g-C,at=S-M,ut=g-q,ft=$-M,Te=X*ut+at*ft,vt=at*ut-ft*X,yt=vt<0;if(Math.abs(vt)<.001*Math.abs(Te)){u.push(g-k*T,M-I*T),u.push(g+k*E,M+I*E),Te>=0&&(l.join==="round"?m+=G(g,M,g-k*T,M-I*T,g-N*T,M-D*T,u,!1)+4:m+=2,u.push(g-N*E,M-D*E),u.push(g+N*T,M+D*T));continue}const Ce=(-k+C)*(-I+M)-(-k+g)*(-I+S),be=(-N+q)*(-D+M)-(-N+g)*(-D+$),Pt=(X*be-ut*Ce)/vt,Tt=(ft*Ce-at*be)/vt,Rt=(Pt-g)*(Pt-g)+(Tt-M)*(Tt-M),Q=g+(Pt-g)*T,Y=M+(Tt-M)*T,J=g-(Pt-g)*E,K=M-(Tt-M)*E,Nn=Math.min(X*X+at*at,ut*ut+ft*ft),Ae=yt?T:E,Dn=Nn+Ae*Ae*w;Rt<=Dn?l.join==="bevel"||Rt/w>v?(yt?(u.push(Q,Y),u.push(g+k*E,M+I*E),u.push(Q,Y),u.push(g+N*E,M+D*E)):(u.push(g-k*T,M-I*T),u.push(J,K),u.push(g-N*T,M-D*T),u.push(J,K)),m+=2):l.join==="round"?yt?(u.push(Q,Y),u.push(g+k*E,M+I*E),m+=G(g,M,g+k*E,M+I*E,g+N*E,M+D*E,u,!0)+4,u.push(Q,Y),u.push(g+N*E,M+D*E)):(u.push(g-k*T,M-I*T),u.push(J,K),m+=G(g,M,g-k*T,M-I*T,g-N*T,M-D*T,u,!1)+4,u.push(g-N*T,M-D*T),u.push(J,K)):(u.push(Q,Y),u.push(J,K)):(u.push(g-k*T,M-I*T),u.push(g+k*E,M+I*E),l.join==="round"?yt?m+=G(g,M,g+k*E,M+I*E,g+N*E,M+D*E,u,!0)+2:m+=G(g,M,g-k*T,M-I*T,g-N*T,M-D*T,u,!1)+2:l.join==="miter"&&Rt/w<=v&&(yt?(u.push(J,K),u.push(J,K)):(u.push(Q,Y),u.push(Q,Y)),m+=2),u.push(g-N*T,M-D*T),u.push(g+N*E,M+D*E),m+=2)}C=i[(x-2)*2],S=i[(x-2)*2+1],g=i[(x-1)*2],M=i[(x-1)*2+1],k=-(S-M),I=C-g,R=Math.sqrt(k*k+I*I),k/=R,I/=R,k*=A,I*=A,u.push(g-k*T,M-I*T),u.push(g+k*E,M+I*E),f||(l.cap==="round"?m+=G(g-k*(T-E)*.5,M-I*(T-E)*.5,g-k*T,M-I*T,g+k*E,M+I*E,u,!1)+2:l.cap==="square"&&(m+=ae(g,M,k,I,T,E,!1,u)));const Fn=he*he;for(let L=P;L<m+P-2;++L)C=u[L*2],S=u[L*2+1],g=u[(L+1)*2],M=u[(L+1)*2+1],q=u[(L+2)*2],$=u[(L+2)*2+1],!(Math.abs(C*(M-$)+g*($-S)+q*(S-M))<Fn)&&n.push(L,L+1,L+2);return{vertices:e,indices:n}}function bn(i){const t=i.length;if(t<6)return 1;let e=0;for(let n=0,r=i[t-2],o=i[t-1];n<t;n+=2){const s=i[n],c=i[n+1];e+=(s-r)*(c+o),r=s,o=c}return e<0?-1:1}function ae(i,t,e,n,r,o,s,c){const l=i-e*r,h=t-n*r,a=i+e*o,y=t+n*o;let f,p;s?(f=n,p=-e):(f=-n,p=e);const u=l+f,x=h+p,m=a+f,P=y+p;return c.push(u,x),c.push(m,P),2}function G(i,t,e,n,r,o,s,c){const l=e-i,h=n-t;let a=Math.atan2(l,h),y=Math.atan2(r-i,o-t);c&&a<y?a+=Math.PI*2:!c&&a>y&&(y+=Math.PI*2);let f=a;const p=y-a,u=Math.abs(p),x=Math.sqrt(l*l+h*h),m=(15*u*Math.sqrt(x)/Math.PI>>0)+1,P=p/m;if(f+=P,c){s.push(i,t),s.push(e,n);for(let A=1,w=f;A<m;A++,w+=P)s.push(i,t),s.push(i+Math.sin(w)*x,t+Math.cos(w)*x);s.push(i,t),s.push(r,o)}else{s.push(e,n),s.push(i,t);for(let A=1,w=f;A<m;A++,w+=P)s.push(i+Math.sin(w)*x,t+Math.cos(w)*x),s.push(i,t);s.push(r,o),s.push(i,t)}return m*2}class H{arcLengthDivision=200;_arcLengths;getPointAt(t,e=new d){return this.getPoint(this.getUToTMapping(t),e)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(t){const e=typeof t=="function";return this.getControlPointRefs().forEach(n=>{e?t(n):n.applyMatrix3(t)}),this}getUnevenVertices(t=5,e=[]){const n=new d;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPoint(r/o,n),e.push(n.x,n.y);return e}getSpacedVertices(t=5,e=[]){const n=new d;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPointAt(r/o,n),e.push(n.x,n.y);return e}getAdaptiveVertices(t=[]){return this.getUnevenVertices(5,t)}_verticesToPoints(t,e=[]){for(let n=0,r=t.length;n<r;n+=2){const o=t[n],s=t[n+1];e.push(new d(o,s))}return e}getSpacedPoints(t,e=[]){const n=this.getSpacedVertices(t);return this._verticesToPoints(n,e),e}getUnevenPoints(t,e=[]){const n=this.getUnevenVertices(t);return this._verticesToPoints(n,e),e}getAdaptivePoints(t=[]){const e=this.getAdaptiveVertices();return this._verticesToPoints(e,t),t}getPoints(t,e=[]){let n;return t?n=this.getUnevenVertices(t):n=this.getAdaptiveVertices(),this._verticesToPoints(n,e),e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const t=this.arcLengthDivision,e=[0];for(let n=0,r=this.getPoint(0),o=1;o<=t;o++){const s=this.getPoint(o/t);n+=s.distanceTo(r),e.push(n),r=s}this._arcLengths=e}getUToTMapping(t,e){const n=this.getLengths(),r=n.length,o=e??t*n[r-1];if(r<2)return o/n[0];let s=0,c=0,l=r-1,h;for(;c<=l;)if(s=Math.floor(c+(l-c)/2),h=n[s]-o,h<0)c=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,n[s]===o)return s/(r-1);const a=n[s],f=n[s+1]-a,p=(o-a)/f;return(s+p)/(r-1)}getTangent(t,e=new d){const r=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new d){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let n=0,r=1,o=(n+r)/2;for(;r-n>e;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(t)<e)return o;s.x<t.x?n=o:r=o}return o}getMinMax(t=d.MAX,e=d.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];t.min(s),e.max(s)}return{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}getFillVertices(t){return this.getAdaptiveVertices()}fillTriangulate(t){return $t(this.getFillVertices(t),t)}strokeTriangulate(t){return le(this.getAdaptiveVertices(),t)}toCommands(){const t=[],e=this.getPoints();for(let n=0,r=e.length;n<r;n++){const o=e[n];n===0?t.push({type:"M",x:o.x,y:o.y}):t.push({type:"L",x:o.x,y:o.y})}return t}toData(){return Bt(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivision=t.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const An=new z,ue=new z,fe=new z,mt=new d;class Vt extends H{constructor(t=new d,e=new d,n=new d,r=0,o=0,s=Math.PI*2,c=!1){super(),this._center=t,this._radius=e,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=c}get cx(){return this._center.x}set cx(t){this._center.x=t}get cy(){return this._center.y}set cy(t){this._center.y=t}get rx(){return this._radius.x}set rx(t){this._radius.x=t}get ry(){return this._radius.y}set ry(t){this._radius.y=t}get dx(){return this._diff.x}set dx(t){this._diff.x=t}get dy(){return this._diff.y}set dy(t){this._diff.y=t}isClockwise(){return this.clockwise}_getDeltaAngle(){const t=Math.PI*2;let e=this.endAngle-this.startAngle;const n=Math.abs(e)<Number.EPSILON;return e=(e%t+t)%t,n?e=0:this.clockwise||(e=e===0?-t:e-t),e}getPoint(t,e=new d){const n=this._getDeltaAngle(),r=this.startAngle+t*n;let o=this.cx+this.rx*Math.cos(r),s=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const c=Math.cos(this.rotate),l=Math.sin(this.rotate),h=o-this.cx,a=s-this.cy;o=h*c-a*l+this.cx,s=h*l+a*c+this.cy}return e.set(o,s)}toCommands(){const{cx:t,cy:e,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:c,rotate:l}=this,h=t+n*Math.cos(o)*Math.cos(l)-r*Math.sin(o)*Math.sin(l),a=e+n*Math.cos(o)*Math.sin(l)+r*Math.sin(o)*Math.cos(l),y=Math.abs(o-s),f=y>Math.PI?1:0,p=c?1:0,u=l*180/Math.PI;if(y>=2*Math.PI){const x=o+Math.PI,m=t+n*Math.cos(x)*Math.cos(l)-r*Math.sin(x)*Math.sin(l),P=e+n*Math.cos(x)*Math.sin(l)+r*Math.sin(x)*Math.cos(l);return[{type:"M",x:h,y:a},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:p,x:m,y:P},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:p,x:h,y:a}]}else{const x=t+n*Math.cos(s)*Math.cos(l)-r*Math.sin(s)*Math.sin(l),m=e+n*Math.cos(s)*Math.sin(l)+r*Math.sin(s)*Math.cos(l);return[{type:"M",x:h,y:a},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:f,sweepFlag:p,x,y:m}]}}drawTo(t){const{cx:e,cy:n,rx:r,ry:o,rotate:s,startAngle:c,endAngle:l,clockwise:h}=this;return t.ellipse(e,n,r,o,s,c,l,!h),this}applyTransform(t){return mt.set(this.cx,this.cy),mt.applyMatrix3(t),this.cx=mt.x,this.cy=mt.y,Sn(t)?kn(this,t):In(this,t),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(t=[]){const{cx:e,cy:n,rx:r,ry:o,dx:s,dy:c,startAngle:l,endAngle:h,clockwise:a,rotate:y}=this,f=!a;let p=Math.abs(l-h);(!f&&l>h||f&&h>l)&&(p=2*Math.PI-p);const u=Math.max(12,Math.floor(12*r**(1/3)*(p/Math.PI)));let x=p/u,m=l;x*=f?-1:1;const P=Math.cos(f?y:-y),A=Math.sin(f?y:-y);for(let w=0;w<u+1;w++){const v=s+Math.cos(m)*r,C=c+Math.sin(m)*o,S=v*P-C*A,g=v*A+C*P;t.push(e+S,n+g),m+=x}return t}_getAdaptiveVerticesByCircle(t=[]){const{cx:e,cy:n,rx:r,ry:o,dx:s,dy:c,rotate:l,clockwise:h}=this;if(!(r>=0&&o>=0&&s>=0&&c>=0))return t;const a=Math.ceil(2.3*Math.sqrt(r+o)),y=a*8+(s?4:0)+(c?4:0),f=[];if(y===0)return t;{const x=f.length;if(a===0)f[x]=f[x+6]=e+s,f[x+1]=f[x+3]=n+c,f[x+2]=f[x+4]=e-s,f[x+5]=f[x+7]=n-c;else{let m=x,P=x+a*4+(s?2:0)+2,A=P,w=y,v=s+r,C=c,S=e+v,g=e-v,M=n+C;if(f[m++]=S,f[m++]=M,f[--P]=M,f[--P]=g,c){const $=n-C;f[A++]=g,f[A++]=$,f[--w]=$,f[--w]=S}for(let $=1;$<a;$++){const k=Math.PI/2*($/a),I=s+Math.cos(k)*r,N=c+Math.sin(k)*o,D=e+I,R=e-I,lt=n+N,T=n-N;f[m++]=D,f[m++]=lt,f[--P]=lt,f[--P]=R,f[A++]=R,f[A++]=T,f[--w]=T,f[--w]=D}v=s,C=c+o,S=e+v,g=e-v,M=n+C;const q=n-C;f[m++]=S,f[m++]=M,f[--w]=q,f[--w]=S,s&&(f[m++]=g,f[m++]=M,f[--w]=q,f[--w]=g)}}const p=Math.cos(h?-l:l),u=Math.sin(h?-l:l);for(let x=0;x<f.length;x+=2){const m=f[x],P=f[x+1],A=m-e,w=P-n,v=A*p-w*u,C=A*u+w*p;t.push(e+v,n+C)}return t}getAdaptiveVertices(t=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(t):this._getAdaptiveVerticesByArc(t)}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.rx=t.rx,this.ry=t.ry,this.dx=t.dx,this.dy=t.dy,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotate=t.rotate,this}}function kn(i,t){const e=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new d(e*r,e*o),c=new d(-n*o,n*r),l=s.applyMatrix3(t),h=c.applyMatrix3(t),a=An.set(l.x,h.x,0,l.y,h.y,0,0,0,1),y=ue.copy(a).invert(),u=fe.copy(y).transpose().multiply(y).elements,x=En(u[0],u[1],u[4]),m=Math.sqrt(x.rt1),P=Math.sqrt(x.rt2);if(i.rx=1/m,i.ry=1/P,i.rotate=Math.atan2(x.sn,x.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=ue.set(m,0,0,0,P,0,0,0,1),v=fe.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),C=w.multiply(v).multiply(a),S=g=>{const{x:M,y:q}=new d(Math.cos(g),Math.sin(g)).applyMatrix3(C);return Math.atan2(q,M)};i.startAngle=S(i.startAngle),i.endAngle=S(i.endAngle),ye(t)&&(i.clockwise=!i.clockwise)}}function In(i,t){const e=xe(t),n=pe(t);i.rx*=e,i.ry*=n;const r=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);i.rotate+=r,ye(t)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ye(i){const t=i.elements;return t[0]*t[4]-t[1]*t[3]<0}function Sn(i){const t=i.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const n=xe(i),r=pe(i);return Math.abs(e/(n*r))>Number.EPSILON}function xe(i){const t=i.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function pe(i){const t=i.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function En(i,t,e){let n,r,o,s,c;const l=i+e,h=i-e,a=Math.sqrt(h*h+4*t*t);return l>0?(n=.5*(l+a),c=1/n,r=i*c*e-t*c*t):l<0?r=.5*(l-a):(n=.5*a,r=-.5*a),h>0?o=h+a:o=h-a,Math.abs(o)>2*Math.abs(t)?(c=-2*t/o,s=1/Math.sqrt(1+c*c),o=c*s):Math.abs(t)===0?(o=1,s=0):(c=-.5*o/t,o=1/Math.sqrt(1+c*c),s=c*o),h>0&&(c=o,o=-s,s=c),{rt1:n,rt2:r,cs:o,sn:s}}class ge extends Vt{constructor(t=0,e=0,n=1,r=0,o=Math.PI*2,s=!1){super(new d(t,e),new d(n,n),new d,0,r,o,s)}drawTo(t){const{cx:e,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;return t.arc(e,n,r,o,s,!c),this}}class B extends H{constructor(t=new d,e=new d){super(),this.p1=t,this.p2=e}static from(t,e,n,r){return new B(new d(t,e),new d(n,r))}getPoint(t,e=new d){return t===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(t).add(this.p1),e}getPointAt(t,e=new d){return this.getPoint(t,e)}getTangent(t,e=new d){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(t,e=new d){return this.getTangent(t,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(t=[]){return t.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),t}getMinMax(t=d.MAX,e=d.MIN){const{p1:n,p2:r}=this;return t.x=Math.min(t.x,n.x,r.x),t.y=Math.min(t.y,n.y,r.y),e.x=Math.max(e.x,n.x,r.x),e.y=Math.max(e.y,n.y,r.y),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,p2:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}getFillVertices(t={}){const e=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),o=Math.max(this.p1.y,this.p2.y),s=e,c=r,l=n-e||t.style?.strokeWidth||0,h=o-r||t.style?.strokeWidth||0;return[s,c,s+l,c,s+l,c+h,s,c+h]}drawTo(t){const{p1:e,p2:n}=this;return t.lineTo(e.x,e.y),t.lineTo(n.x,n.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.p2.copy(t.p2),this}}class st extends H{constructor(t=[]){super(),this.curves=t}getFlatCurves(){return this.curves.flatMap(t=>t instanceof st?t.getFlatCurves():t)}addCurve(t){return this.curves.push(t),this}getPoint(t,e=new d){const n=t*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,c=this.curves[o],l=c.getLength();return c.getPointAt(l===0?0:1-s/l,e)}o++}return e}updateLengths(){const t=[];for(let e=0,n=0,r=this.curves.length;e<r;e++)n+=this.curves[e].getLength(),t.push(n);this._arcLengths=t}getControlPointRefs(){return this.curves.flatMap(t=>t.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(t,e){const n=[t[e-1],t[e]],r=[t[e+1],t[e+2]];return n[0]===r[0]&&n[1]===r[1]&&t.splice(e+1,2),t}getSpacedVertices(t=5,e=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(t,e),n&&this._removeNextPointIfEqualPrevPoint(e,n),n=e.length-1}),e}getAdaptiveVertices(t=[]){let e;return this.curves.forEach(n=>{n.getAdaptiveVertices(t),e&&this._removeNextPointIfEqualPrevPoint(t,e),e=t.length-1}),t}strokeTriangulate(t){return this.curves.length===1?this.curves[0].strokeTriangulate(t):super.strokeTriangulate(t)}getFillVertices(t){if(this.curves.length===1)return this.curves[0].getFillVertices(t);{const e=[];let n;return this.curves.forEach(r=>{let o;r instanceof B?o=r.getAdaptiveVertices():o=r.getFillVertices(t),e.push(...o),n&&this._removeNextPointIfEqualPrevPoint(e,n),n=e.length-1}),e}}applyTransform(t){return this.curves.forEach(e=>e.applyTransform(t)),this}getMinMax(t=d.MAX,e=d.MIN){return this.curves.forEach(n=>n.getMinMax(t,e)),{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(n=>n.drawTo(t)),this}copy(t){return super.copy(t),this.curves=t.curves.map(e=>e.clone()),this}}class Mt extends H{constructor(t=new d,e=new d,n=new d,r=new d){super(),this.p1=t,this.cp1=e,this.cp2=n,this.p2=r}static from(t,e,n,r,o,s,c,l){return new Mt(new d(t,e),new d(n,r),new d(o,s),new d(c,l))}getPoint(t,e=new d){const{p1:n,cp1:r,cp2:o,p2:s}=this;return e.set(Et(t,n.x,r.x,o.x,s.x),Et(t,n.y,r.y,o.y,s.y))}getAdaptiveVertices(t=[]){return ne(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,t)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(t,e,n){const r=e*e-4*t*n;if(r<0)return[];const o=Math.sqrt(r),s=(-e+o)/(2*t),c=(-e-o)/(2*t);return[s,c].filter(l=>l>=0&&l<=1)}getMinMax(t=d.MAX,e=d.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,c=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),l=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),h=[0,1,...c,...l];return((y,f)=>{for(const p of y)for(let u=0;u<=f;u++){const x=u/f-.5,m=Math.min(1,Math.max(0,p+x)),P=this.getPoint(m);t.x=Math.min(t.x,P.x),t.y=Math.min(t.y,P.y),e.x=Math.max(e.x,P.x),e.y=Math.max(e.y,P.y)}})(h,10),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp1:e,cp2:n,p2:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(t){const{p1:e,cp1:n,cp2:r,p2:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp1.copy(t.cp1),this.cp2.copy(t.cp2),this.p2.copy(t.p2),this}}class de extends Vt{constructor(t=0,e=0,n=1,r=1,o=0,s=0,c=Math.PI*2,l=!1){super(new d(t,e),new d(n,r),new d,o,s,c,l)}drawTo(t){return t.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class qt extends st{}class _n extends qt{constructor(t=0,e=0,n=1,r=3){super(),this.cx=t,this.cy=e,this.radius=n,this.sideCount=r,this.update()}update(){const{cx:t,cy:e,radius:n,sideCount:r}=this,o=[];for(let c=0;c<r;c++){const l=c*2*Math.PI/r-.5*Math.PI;o.push(new d(n*Math.cos(l),n*Math.sin(l)).add({x:t,y:e}))}const s=[];for(let c=0;c<r;c++)s.push(new B(o[c],o[(c+1)%r]));return this.curves=s,this}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.radius=t.radius,this.sideCount=t.sideCount,this.update(),this}}class wt extends H{constructor(t=new d,e=new d,n=new d){super(),this.p1=t,this.cp=e,this.p2=n}static from(t,e,n,r,o,s){return new wt(new d(t,e),new d(n,r),new d(o,s))}getPoint(t,e=new d){const{p1:n,cp:r,p2:o}=this;return e.set(Dt(t,n.x,r.x,o.x),Dt(t,n.y,r.y,o.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(t=[]){return se(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,t)}getMinMax(t=d.MAX,e=d.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),c=.5*(n.y+r.y),l=.5*(n.x+o.x),h=.5*(n.y+o.y);return t.x=Math.min(t.x,n.x,o.x,s,l),t.y=Math.min(t.y,n.y,o.y,c,h),e.x=Math.max(e.x,n.x,o.x,s,l),e.y=Math.max(e.y,n.y,o.y,c,h),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp:e,p2:n}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:n.x,y:n.y}]}drawTo(t){const{p1:e,cp:n,p2:r}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp.copy(t.cp),this.p2.copy(t.p2),this}}class me extends qt{constructor(t=0,e=0,n=0,r=0){super(),this.x=t,this.y=e,this.width=n,this.height=r,this.update()}update(){const{x:t,y:e,width:n,height:r}=this,o=[new d(t,e),new d(t+n,e),new d(t+n,e+r),new d(t,e+r)];return this.curves=[new B(o[0],o[1]),new B(o[1],o[2]),new B(o[2],o[3]),new B(o[3],o[0])],this}drawTo(t){return t.rect(this.x,this.y,this.width,this.height),this}getFillVertices(t={}){const{x:e,y:n,width:r,height:o}=this;return[e,n,e+r,n,e+r,n+o,e,n+o]}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update(),this}}class Me extends Vt{constructor(t=0,e=0,n=1,r=1,o=1){super(),this.x=t,this.y=e,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:t,y:e,width:n,height:r,radius:o}=this,s=n/2,c=r/2,l=t+s,h=e+c,a=Math.max(0,Math.min(o,Math.min(s,c))),y=a;return this._center=new d(l,h),this._radius=new d(a,y),this._diff=new d(s-a,c-y),this}drawTo(t){const{x:e,y:n,width:r,height:o,radius:s}=this;return t.roundRect(e,n,r,o,s),this}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.radius=t.radius,this.update(),this}}class we extends H{constructor(t=[]){super(),this.points=t}getPoint(t,e=new d){const{points:n}=this,r=(n.length-1)*t,o=Math.floor(r),s=r-o,c=n[o===0?o:o-1],l=n[o],h=n[o>n.length-2?n.length-1:o+1],a=n[o>n.length-3?n.length-1:o+2];return e.set(St(s,c.x,l.x,h.x,a.x),St(s,c.y,l.y,h.y,a.y)),e}getControlPointRefs(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++)this.points.push(t.points[e].clone());return this}}class ht extends st{startPoint;currentPoint;autoClose=!1;constructor(t){super(),t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++){const{x:r,y:o}=t[e];this.lineTo(r,o)}return this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,e=[]){return this._closeVertices(super.getUnevenVertices(t,e))}getSpacedVertices(t=40,e=[]){return this._closeVertices(super.getSpacedVertices(t,e))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new d(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const e=t.getPoint(0);(!this.currentPoint||!e.equals(this.currentPoint))&&this.lineTo(e.x,e.y)}return this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;e&&!t.equals(e)&&(this.curves.push(new B(e.clone(),t.clone())),e.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint=new d(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){const n=this.currentPoint;return n?.equals({x:t,y:e})||this.curves.push(B.from(n?.x??0,n?.y??0,t,e)),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,n,r,o,s){const c=this.currentPoint;return c?.equals({x:o,y:s})||this.curves.push(Mt.from(c?.x??0,c?.y??0,t,e,n,r,o,s)),this._setCurrentPoint({x:o,y:s}),this}quadraticCurveTo(t,e,n,r){const o=this.currentPoint;return o?.equals({x:n,y:r})||this.curves.push(wt.from(o?.x??0,o?.y??0,t,e,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(t,e,n,r,o,s){const c=new ge(t,e,n,r,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeArc(t,e,n,r,o,s){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.arc(t,e,n,r,o,s),this}arcTo(t,e,n,r,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,n,r,o,s,c,l=!0){const h=new de(t,e,n,r,o,s,c,!l);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeEllipse(t,e,n,r,o,s,c,l){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.ellipse(t,e,n,r,o,s,c,l),this}rect(t,e,n,r){const o=new me(t,e,n,r);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:t,y:e}),this}roundRect(t,e,n,r,o){const s=new Me(t,e,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){const e=this.currentPoint??new d;return this.curves.push(new we([e].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(n=>n.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=t.currentPoint?.clone(),this}}class j extends st{currentCurve=new ht;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(t,e={}){super(),this.curves.push(this.currentCurve),this.style=e,t&&(t instanceof j?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}addPath(t){const e=this.curves.findIndex(n=>n===this.currentCurve);return e>-1&&this.curves.splice(e,1),t instanceof j?this.curves.push(...t.curves.filter(n=>n.curves.length).map(n=>n.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new ht().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,e){return this.currentCurve.currentPoint?.equals({x:t,y:e})||(this.currentCurve.curves.length&&(this.currentCurve=new ht,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,e)),this}lineTo(t,e){return this.currentCurve.lineTo(t,e),this}bezierCurveTo(t,e,n,r,o,s){return this.currentCurve.bezierCurveTo(t,e,n,r,o,s),this}quadraticCurveTo(t,e,n,r){return this.currentCurve.quadraticCurveTo(t,e,n,r),this}arc(t,e,n,r,o,s){return this.currentCurve.arc(t,e,n,r,o,s),this}arcTo(t,e,n,r,o){return this.currentCurve.arcTo(t,e,n,r,o),this}ellipse(t,e,n,r,o,s,c,l){return this.currentCurve.ellipse(t,e,n,r,o,s,c,l),this}rect(t,e,n,r){return this.currentCurve.rect(t,e,n,r),this}roundRect(t,e,n,r,o){return this.currentCurve.roundRect(t,e,n,r,o),this}reset(){return this.currentCurve=new ht,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,e=t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(t,e,n)}),this}skew(t,e=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(t,e,n)}),this}rotate(t,e={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getFlatCurves(),n=[],r=[],o=[];e.forEach((c,l)=>{const h=c.getControlPointRefs(),a=c.isClockwise();o[l]=h,r[l]=a;const y=h[0],f=h[h.length-1]??y;n.push({start:a?f:y,end:a?y:f,index:l})});const s=[];return n.forEach((c,l)=>{s[l]=[],n.forEach((h,a)=>{h.start&&c.end&&a!==l&&h.start?.equals(c.end)&&s[l].push(h.index)})}),e.forEach((c,l)=>{const h=r[l];o[l].forEach(a=>{a.add(c.getNormal(c.getTForPoint(a)).scale(h?t:-t))})}),s.forEach((c,l)=>{const h=o[l];c.forEach(a=>{const y=o[a],f=re(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}getMinMax(t=d.MAX,e=d.MIN,n=!0){const r=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(t,e),n&&r>1){const s=r/2,c=o.isClockwise(),l=[];for(let h=0;h<=1;h+=1/o.arcLengthDivision){const a=o.getPoint(h),y=o.getNormal(h),f=y.clone().scale(c?s:-s),p=y.clone().scale(c?-s:s);l.push(a.clone().add(f),a.clone().add(p),a.clone().add({x:s,y:0}),a.clone().add({x:-s,y:0}),a.clone().add({x:0,y:s}),a.clone().add({x:0,y:-s}),a.clone().add({x:s,y:s}),a.clone().add({x:-s,y:-s}))}t.min(...l),e.max(...l)}}),{min:t.finite(),max:e.finite()}}strokeTriangulate(t){const e=t?.indices??[],n=t?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...t,indices:e,vertices:n,style:{...this.style}})}),{indices:e,vertices:n}}fillTriangulate(t){const e={...t,style:{...this.style,...t?.style}},n=e.indices??[],r=e.vertices??[];if((e.style.fillRule??"nonzero")==="nonzero"){const s=this.curves.map(h=>h.getFillVertices(e)),c=ce(s),l=c.length;for(let h=0;h<l;h++){const a=c[h],y=s[h];if(a.wn||!y.length)continue;const f=y.slice(),p=[];for(let u=0;u<l;u++){const x=c[u];x.parentIndex===h&&(p.push(f.length/2),f.push(...s[x.index]))}$t(f,{...t,indices:n,vertices:r,holes:p,style:{...this.style}})}}else this.curves.forEach(s=>{s.fillTriangulate({...t,indices:n,vertices:r,style:{...this.style}})});return{indices:n,vertices:r}}getBoundingBox(t=!0){const{min:e,max:n}=this.getMinMax(void 0,void 0,t);return new U(e.x,e.y,n.x-e.x,n.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:n="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.curves.forEach(o=>{o.drawTo(t)}),n!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:n="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.getControlPointRefs().forEach(o=>{tt(t,o.x,o.y,{radius:4})}),n!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const r in t)t[r]!==void 0&&(e[ie(r)]=t[r]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let n="";for(const r in e)e[r]!==void 0&&(n+=`${r}:${e[r]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class ve{constructor(t=[],e){this.paths=t,this.viewBox=e}getBoundingBox(t=!0){if(!this.paths.length)return;const e=d.MAX,n=d.MIN;return this.paths.forEach(r=>r.getMinMax(e,n,t)),new U(e.x,e.y,n.x-e.x,n.y-e.y)}toTriangulatedSvgString(t=this.paths.map(n=>n.fillTriangulate()),e=0){let n="";const r={x:-e,y:-e},o={x:e,y:e};(Array.isArray(t)?t:[t]).forEach(({vertices:l,indices:h})=>{const a=y=>{const f=l[y*2],p=l[y*2+1];return r.x=Math.min(r.x,f+e),o.x=Math.max(o.x,f+e),r.y=Math.min(r.y,p+e),o.y=Math.max(o.y,p+e),[f,p]};for(let y=0,f=h.length;y<f;y+=3){const p=a(h[y]),u=a(h[y+1]),x=a(h[y+2]);n+=`<polygon points="${p.join(",")} ${u.join(",")} ${x.join(",")}" stroke="none" fill="black" />`}});const c=[r.x,r.y,o.x-r.x,o.y-r.y];return`<svg width="${c[2]}" height="${c[3]}" viewBox="${c.join(" ")}" xmlns="http://www.w3.org/2000/svg">${n}</svg>`}toTriangulatedSvg(t,e){return new DOMParser().parseFromString(this.toTriangulatedSvgString(t,e),"image/svg+xml").documentElement}toSvgString(){const{x:t,y:e,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSvgPathString()).join("");return`<svg viewBox="${t} ${e} ${n} ${r}" width="${n}px" height="${r}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(t={}){const{pixelRatio:e=2,...n}=t,{left:r,top:o,width:s,height:c}=this.getBoundingBox(),l=document.createElement("canvas");l.width=s*e,l.height=c*e,l.style.width=`${s}px`,l.style.height=`${c}px`;const h=l.getContext("2d");return h&&(h.scale(e,e),h.translate(-r,-o),this.paths.forEach(a=>{a.drawTo(h,n)})),l}}class Ln{constructor(t,e,n=1,r=1){this.rows=t,this.cols=e,this.width=n,this.height=r;for(let o=0;o<t;o++){this.controlPoints[o]=[];for(let s=0;s<e;s++)this.controlPoints[o][s]={x:s/(e-1)*n,y:o/(t-1)*r}}}controlPoints=[];moveControlPoint(t,e,n,r){return this.controlPoints[t][e].x+=n,this.controlPoints[t][e].y+=r,this}}function Pe(i){const t=[];return t[0]=(1-i)**3/6,t[1]=(3*i**3-6*i**2+4)/6,t[2]=(-3*i**3+3*i**2+3*i+1)/6,t[3]=i**3/6,t}function $n(i,t,e=t.width,n=t.height){const r=i.x/e*(t.cols-1),o=i.y/n*(t.rows-1),s=Math.floor(r),c=Math.floor(o),l=r-s,h=o-c,a=Pe(l),y=Pe(h);let f=0,p=0;for(let u=0;u<4;u++)for(let x=0;x<4;x++){const m=Math.min(Math.max(c-1+u,0),t.rows-1),P=Math.min(Math.max(s-1+x,0),t.cols-1),A=t.controlPoints[m][P],w=a[x]*y[u];f+=A.x*w,p+=A.y*w}i.set(f,p)}b.ArcCurve=ge,b.BoundingBox=U,b.CompositeCurve=st,b.CubicBezierCurve=Mt,b.Curve=H,b.CurvePath=ht,b.EllipseCurve=de,b.EquilateralPloygonCurve=_n,b.FFDControlGrid=Ln,b.LineCurve=B,b.Matrix3=z,b.Path2D=j,b.Path2DSet=ve,b.PloygonCurve=qt,b.QuadraticBezierCurve=wt,b.RectangleCurve=me,b.RoundRectangleCurve=Me,b.SplineCurve=we,b.Vector2=d,b.applyFFD=$n,b.catmullRom=St,b.cubicBezier=Et,b.drawPoint=tt,b.fillTriangulate=$t,b.getAdaptiveCubicBezierCurvePoints=ne,b.getAdaptiveQuadraticBezierCurvePoints=se,b.getDirectedArea=mn,b.getIntersectionPoint=re,b.nonzeroFillRule=ce,b.parseArcCommand=Ot,b.parsePathDataArgs=O,b.quadraticBezier=Dt,b.setCanvasContext=Ct,b.strokeTriangulate=le,b.svgPathCommandsAddToPath2D=At,b.svgPathCommandsToData=Bt,b.svgPathDataToCommands=kt,b.svgToDom=Xt,b.svgToPath2DSet=Ze,b.toKebabCase=ie,Object.defineProperty(b,Symbol.toStringTag,{value:"Module"})});
1
+ (function(A,tt){typeof exports=="object"&&typeof module<"u"?tt(exports):typeof define=="function"&&define.amd?define(["exports"],tt):(A=typeof globalThis<"u"?globalThis:A||self,tt(A.modernPath2d={}))})(this,(function(A){"use strict";function tt(i,t,e,n={}){const{radius:r=1}=n;i.moveTo(t,e),i.arc(t,e,r,0,Math.PI*2)}const ke={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function Ct(i,t){const{fill:e="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="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)"}=t;i.fillStyle=e,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=ke[s],i.miterLimit=c,i.setLineDash(a),i.lineDashOffset=h,i.shadowOffsetX=l,i.shadowOffsetY=y,i.shadowBlur=f,i.shadowColor=p}class m{constructor(t=0,e=0){this.x=t,this.y=e}static get MAX(){return new m(1/0,1/0)}static get MIN(){return new m(-1/0,-1/0)}get array(){return[this.x,this.y]}finite(){return this.x=Number.isFinite(this.x)?this.x:0,this.y=Number.isFinite(this.y)?this.y:0,this}set(t,e){return this.x=t,this.y=e,this}add(t){return this.x+=t.x,this.y+=t.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}divide(t){return this.x/=t.x,this.y/=t.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}rotate(t,e={x:0,y:0}){const n=-t/180*Math.PI,r=this.x-e.x,o=-(this.y-e.y),s=Math.sin(n),c=Math.cos(n);return this.set(e.x+(r*c-o*s),e.y-(r*s+o*c)),this}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(t,e=t,n={x:0,y:0}){const r=t<0?n.x-this.x+n.x:this.x,o=e<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(t),this.y=o*Math.abs(e),this}skew(t,e=0,n={x:0,y:0}){const r=this.x-n.x,o=this.y-n.y;return this.x=n.x+(r+Math.tan(t)*o),this.y=n.y+(o+Math.tan(e)*r),this}min(...t){return this.x=Math.min(this.x,...t.map(e=>e.x)),this.y=Math.min(this.y,...t.map(e=>e.y)),this}max(...t){return this.x=Math.max(this.x,...t.map(e=>e.x)),this.y=Math.max(this.y,...t.map(e=>e.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this}divideVectors(t,e){return this.x=t.x/e.x,this.y=t.y/e.y,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return this.x===t.x&&this.y===t.y}applyMatrix3(t){const e=this.x,n=this.y,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6],this.y=r[1]*e+r[4]*n+r[7],this}copy(t){return this.x=t.x,this.y=t.y,this}clone(){return new m(this.x,this.y)}}class U{constructor(t=0,e=0,n=0,r=0){this.left=t,this.top=e,this.width=n,this.height=r}get x(){return this.left}set x(t){this.left=t}get y(){return this.top}set y(t){this.top=t}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new m((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...t){if(t.length===0)return new U;if(t.length===1)return t[0].clone();const e=t[0],n=t.slice(1).reduce((r,o)=>(r.left=Math.min(r.left,o.left),r.top=Math.min(r.top,o.top),r.right=Math.max(r.right,o.right),r.bottom=Math.max(r.bottom,o.bottom),r),{left:e?.left??0,top:e?.top??0,right:e?.right??0,bottom:e?.bottom??0});return new U(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(t,e){return this.left+=t,this.top+=e,this}copy(t){return this.left=t.left,this.top=t.top,this.width=t.width,this.height=t.height,this}clone(){return new U(this.left,this.top,this.width,this.height)}}class z{elements=[];constructor(t=1,e=0,n=0,r=0,o=1,s=0,c=0,a=0,h=1){this.set(t,e,n,r,o,s,c,a,h)}set(t,e,n,r,o,s,c,a,h){const l=this.elements;return l[0]=t,l[1]=r,l[2]=c,l[3]=e,l[4]=o,l[5]=a,l[6]=n,l[7]=s,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,r=e.elements,o=this.elements,s=n[0],c=n[3],a=n[6],h=n[1],l=n[4],y=n[7],f=n[2],p=n[5],u=n[8],x=r[0],g=r[3],P=r[6],C=r[1],w=r[4],v=r[7],b=r[2],S=r[5],d=r[8];return o[0]=s*x+c*C+a*b,o[3]=s*g+c*w+a*S,o[6]=s*P+c*v+a*d,o[1]=h*x+l*C+y*b,o[4]=h*g+l*w+y*S,o[7]=h*P+l*v+y*d,o[2]=f*x+p*C+u*b,o[5]=f*g+p*w+u*S,o[8]=f*P+p*v+u*d,this}invert(){const t=this.elements,e=t[0],n=t[1],r=t[2],o=t[3],s=t[4],c=t[5],a=t[6],h=t[7],l=t[8],y=l*s-c*h,f=c*a-l*o,p=h*o-s*a,u=e*y+n*f+r*p;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/u;return t[0]=y*x,t[1]=(r*h-l*n)*x,t[2]=(c*n-r*s)*x,t[3]=f*x,t[4]=(l*e-r*a)*x,t[5]=(r*o-c*e)*x,t[6]=p*x,t[7]=(n*a-h*e)*x,t[8]=(s*e-n*o)*x,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}scale(t,e){return this.premultiply(bt.makeScale(t,e)),this}rotate(t){return this.premultiply(bt.makeRotation(-t)),this}translate(t,e){return this.premultiply(bt.makeTranslation(t,e)),this}makeTranslation(t,e){return this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new z;function zt(i,t,e,n){const r=i*e+t*n,o=Math.sqrt(i*i+t*t)*Math.sqrt(e*e+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-t*e<0&&(s=-s),s}function Ot(i,t,e,n,r,o,s,c){if(t===0||e===0){i.lineTo(c.x,c.y);return}n=n*Math.PI/180,t=Math.abs(t),e=Math.abs(e);const a=(s.x-c.x)/2,h=(s.y-c.y)/2,l=Math.cos(n)*a+Math.sin(n)*h,y=-Math.sin(n)*a+Math.cos(n)*h;let f=t*t,p=e*e;const u=l*l,x=y*y,g=u/f+x/p;if(g>1){const L=Math.sqrt(g);t=L*t,e=L*e,f=t*t,p=e*e}const P=f*x+p*u,C=(f*p-P)/P;let w=Math.sqrt(Math.max(0,C));r===o&&(w=-w);const v=w*t*y/e,b=-w*e*l/t,S=Math.cos(n)*v-Math.sin(n)*b+(s.x+c.x)/2,d=Math.sin(n)*v+Math.cos(n)*b+(s.y+c.y)/2,M=zt(1,0,(l-v)/t,(y-b)/e),V=zt((l-v)/t,(y-b)/e,(-l-v)/t,(-y-b)/e)%(Math.PI*2);i.ellipse(S,d,t,e,n,M,M+V,o===0)}const q={WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function O(i,t,e=0){let c=0,a=!0,h="",l="";const y=[];function f(g,P,C){const w=new SyntaxError(`Unexpected character "${g}" at index ${P}.`);throw w.partial=C,w}function p(){h!==""&&(l===""?y.push(Number(h)):y.push(Number(h)*10**Number(l))),h="",l=""}let u;const x=i.length;for(let g=0;g<x;g++){if(u=i[g],Array.isArray(t)&&t.includes(y.length%e)&&q.FLAGS.test(u)){c=1,h=u,p();continue}if(c===0){if(q.WHITESPACE.test(u))continue;if(q.DIGIT.test(u)||q.SIGN.test(u)){c=1,h=u;continue}if(q.POINT.test(u)){c=2,h=u;continue}q.COMMA.test(u)&&(a&&f(u,g,y),a=!0)}if(c===1){if(q.DIGIT.test(u)){h+=u;continue}if(q.POINT.test(u)){h+=u,c=2;continue}if(q.EXP.test(u)){c=3;continue}q.SIGN.test(u)&&h.length===1&&q.SIGN.test(h[0])&&f(u,g,y)}if(c===2){if(q.DIGIT.test(u)){h+=u;continue}if(q.EXP.test(u)){c=3;continue}q.POINT.test(u)&&h[h.length-1]==="."&&f(u,g,y)}if(c===3){if(q.DIGIT.test(u)){l+=u;continue}if(q.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&q.SIGN.test(l)&&f(u,g,y)}}q.WHITESPACE.test(u)?(p(),c=0,a=!1):q.COMMA.test(u)?(p(),c=0,a=!0):q.SIGN.test(u)?(p(),c=1,h=u):q.POINT.test(u)?(p(),c=2,h=u):f(u,g,y)}return p(),y}function et(i,t){return i-(t-i)}function At(i,t){const e=new m,n=new m;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?e.add(s):e.copy(s),t.moveTo(e.x,e.y),n.copy(e);else if(s.type==="h"||s.type==="H")s.type==="h"?e.x+=s.x:e.x=s.x,t.lineTo(e.x,e.y),n.copy(e);else if(s.type==="v"||s.type==="V")s.type==="v"?e.y+=s.y:e.y=s.y,t.lineTo(e.x,e.y),n.copy(e);else if(s.type==="l"||s.type==="L")s.type==="l"?e.add(s):e.copy(s),t.lineTo(e.x,e.y),n.copy(e);else if(s.type==="c"||s.type==="C")s.type==="c"?(t.bezierCurveTo(e.x+s.x1,e.y+s.y1,e.x+s.x2,e.y+s.y2,e.x+s.x,e.y+s.y),n.x=e.x+s.x2,n.y=e.y+s.y2,e.add(s)):(t.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,e.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(t.bezierCurveTo(et(e.x,n.x),et(e.y,n.y),e.x+s.x2,e.y+s.y2,e.x+s.x,e.y+s.y),n.x=e.x+s.x2,n.y=e.y+s.y2,e.add(s)):(t.bezierCurveTo(et(e.x,n.x),et(e.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,e.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(t.quadraticCurveTo(e.x+s.x1,e.y+s.y1,e.x+s.x,e.y+s.y),n.x=e.x+s.x1,n.y=e.y+s.y1,e.add(s)):(t.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,e.copy(s));else if(s.type==="t"||s.type==="T"){const c=et(e.x,n.x),a=et(e.y,n.y);n.x=c,n.y=a,s.type==="t"?(t.quadraticCurveTo(c,a,e.x+s.x,e.y+s.y),e.add(s)):(t.quadraticCurveTo(c,a,s.x,s.y),e.copy(s))}else if(s.type==="a"||s.type==="A"){const c=e.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;e.add(s)}else{if(e.equals(s))continue;e.copy(s)}n.copy(e),Ot(t,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,c,e)}else s.type==="z"||s.type==="Z"?(t.startPoint&&e.copy(t.startPoint),t.closePath()):console.warn("Unsupported commands",s)}}function Bt(i){let t,e;const n=[];for(let r=0,o=i.length;r<o;r++){const s=i[r];switch(s.type){case"m":case"M":if(s.x.toFixed(4)===e?.x.toFixed(4)&&s.y.toFixed(4)===e?.y.toFixed(4))continue;n.push(`${s.type} ${s.x} ${s.y}`),e={x:s.x,y:s.y},t={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),e={x:s.x,y:e?.y??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),e={x:e?.x??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"c":case"C":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x2} ${s.y2} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"a":case"A":n.push(`${s.type} ${s.rx} ${s.ry} ${s.angle} ${s.largeArcFlag} ${s.sweepFlag} ${s.x} ${s.y}`),e={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),t&&(e={x:t.x,y:t.y});break}}return n.join(" ")}const Ie=/[a-df-z][^a-df-z]*/gi;function kt(i){const t=[],e=i.match(Ie);if(!e)return t;for(let n=0,r=e.length;n<r;n++){const o=e[n],s=o.charAt(0),c=o.slice(1).trim();let a;switch(s){case"m":case"M":a=O(c);for(let h=0,l=a.length;h<l;h+=2)h===0?t.push({type:s,x:a[h],y:a[h+1]}):t.push({type:s==="m"?"l":"L",x:a[h],y:a[h+1]});break;case"h":case"H":a=O(c);for(let h=0,l=a.length;h<l;h++)t.push({type:s,x:a[h]});break;case"v":case"V":a=O(c);for(let h=0,l=a.length;h<l;h++)t.push({type:s,y:a[h]});break;case"l":case"L":a=O(c);for(let h=0,l=a.length;h<l;h+=2)t.push({type:s,x:a[h],y:a[h+1]});break;case"c":case"C":a=O(c);for(let h=0,l=a.length;h<l;h+=6)t.push({type:s,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=O(c);for(let h=0,l=a.length;h<l;h+=4)t.push({type:s,x2:a[h],y2:a[h+1],x:a[h+2],y:a[h+3]});break;case"q":case"Q":a=O(c);for(let h=0,l=a.length;h<l;h+=4)t.push({type:s,x1:a[h],y1:a[h+1],x:a[h+2],y:a[h+3]});break;case"t":case"T":a=O(c);for(let h=0,l=a.length;h<l;h+=2)t.push({type:s,x:a[h],y:a[h+1]});break;case"a":case"A":a=O(c,[3,4],7);for(let h=0,l=a.length;h<l;h+=7)t.push({type:s,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":t.push({type:s});break;default:console.warn(o)}}return t}const jt="data:image/svg+xml;",Zt=`${jt}base64,`,Ut=`${jt}charset=utf8,`;function Xt(i){if(typeof i=="string"){let t;i.startsWith(Zt)?(i=i.substring(Zt.length,i.length),t=atob(i)):i.startsWith(Ut)?(i=i.substring(Ut.length,i.length),t=decodeURIComponent(i)):t=i;const e=new DOMParser().parseFromString(t,"text/xml"),n=e.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
2
+ ${t}`);return e.documentElement}else return i}const Se="px",_e=90,Wt=["mm","cm","in","pt","pc","px"],Gt={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 E(i){let t="px";if(typeof i=="string")for(let n=0,r=Wt.length;n<r;n++){const o=Wt[n];if(i.endsWith(o)){t=o,i=i.substring(0,i.length-o.length);break}}let e;return e=Gt[t][Se],e<0&&(e=Gt[t].in*_e),e*Number.parseFloat(i)}const Ee=new z,xt=new z,Ht=new z,Qt=new z;function $e(i,t,e){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=Le(i);return e.length>0&&n.premultiply(e[e.length-1]),t.copy(n),e.push(n),n}function Le(i){const t=new z,e=Ee;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&t.translate(E(i.getAttribute("x")),E(i.getAttribute("y"))),i.hasAttribute("transform")){const n=i.getAttribute("transform").split(")");for(let r=n.length-1;r>=0;r--){const o=n[r].trim();if(o==="")continue;const s=o.indexOf("("),c=o.length;if(s>0&&s<c){const a=o.slice(0,s),h=O(o.slice(s+1));switch(e.identity(),a){case"translate":if(h.length>=1){const l=h[0];let y=0;h.length>=2&&(y=h[1]),e.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]),xt.makeTranslation(-y,-f),Ht.makeRotation(l),Qt.multiplyMatrices(Ht,xt),xt.makeTranslation(y,f),e.multiplyMatrices(xt,Qt)}break;case"scale":h.length>=1&&e.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&e.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&e.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&e.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}t.premultiply(e)}}return t}function Fe(i){return new j().arc(E(i.getAttribute("cx")||0),E(i.getAttribute("cy")||0),E(i.getAttribute("r")||0),0,Math.PI*2)}function Ne(i,t){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let e=0;e<i.sheet.cssRules.length;e++){const n=i.sheet.cssRules[e];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,c=0;c<s;c++){const a=n.style.item(c);o[a]=n.style.getPropertyValue(a)}for(let s=0;s<r.length;s++)t[r[s]]=Object.assign(t[r[s]]||{},{...o})}}function De(i){return new j().ellipse(E(i.getAttribute("cx")||0),E(i.getAttribute("cy")||0),E(i.getAttribute("rx")||0),E(i.getAttribute("ry")||0),0,0,Math.PI*2)}function qe(i){return new j().moveTo(E(i.getAttribute("x1")||0),E(i.getAttribute("y1")||0)).lineTo(E(i.getAttribute("x2")||0),E(i.getAttribute("y2")||0))}function Ve(i){const t=new j,e=i.getAttribute("d");return!e||e==="none"?null:(t.addData(e),t)}const Re=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function ze(i){const t=new j;let e=0;return i.getAttribute("points")?.replace(Re,(n,r,o)=>{const s=E(r),c=E(o);return e===0?t.moveTo(s,c):t.lineTo(s,c),e++,n}),t.currentCurve.autoClose=!0,t}const Oe=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Be(i){const t=new j;let e=0;return i.getAttribute("points")?.replace(Oe,(n,r,o)=>{const s=E(r),c=E(o);return e===0?t.moveTo(s,c):t.lineTo(s,c),e++,n}),t.currentCurve.autoClose=!1,t}function je(i){const t=E(i.getAttribute("x")||0),e=E(i.getAttribute("y")||0),n=E(i.getAttribute("rx")||i.getAttribute("ry")||0),r=E(i.getAttribute("ry")||i.getAttribute("rx")||0),o=E(i.getAttribute("width")),s=E(i.getAttribute("height")),c=1-.551915024494,a=new j;return a.moveTo(t+n,e),a.lineTo(t+o-n,e),(n!==0||r!==0)&&a.bezierCurveTo(t+o-n*c,e,t+o,e+r*c,t+o,e+r),a.lineTo(t+o,e+s-r),(n!==0||r!==0)&&a.bezierCurveTo(t+o,e+s-r*c,t+o-n*c,e+s,t+o-n,e+s),a.lineTo(t+n,e+s),(n!==0||r!==0)&&a.bezierCurveTo(t+n*c,e+s,t,e+s-r*c,t,e+s-r),a.lineTo(t,e+r),(n!==0||r!==0)&&a.bezierCurveTo(t,e+r*c,t+n*c,e,t+n,e),a}function Z(i,t,e){t=Object.assign({},t);let n={};if(i.hasAttribute("class")){const h=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<h.length;l++)n=Object.assign(n,e[`.${h[l]}`])}i.hasAttribute("id")&&(n=Object.assign(n,e[`#${i.getAttribute("id")}`]));for(let h=i.style.length,l=0;l<h;l++){const y=i.style.item(l),f=i.style.getPropertyValue(y);t[y]=f,n[y]=f}function r(h,l,y=o){i.hasAttribute(h)&&(t[l]=y(i.getAttribute(h))),n[h]&&(t[l]=y(n[h]))}function o(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function s(h){return Math.max(0,Math.min(1,E(h)))}function c(h){return Math.max(0,E(h))}function a(h){return h.split(" ").filter(l=>l!=="").map(l=>E(l))}return r("fill","fill"),r("fill-opacity","fillOpacity",s),r("fill-rule","fillRule"),r("opacity","opacity",s),r("stroke","stroke"),r("stroke-opacity","strokeOpacity",s),r("stroke-width","strokeWidth",c),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",c),r("stroke-dasharray","strokeDasharray",a),r("stroke-dashoffset","strokeDashoffset",E),r("visibility","visibility"),t}function It(i,t,e=[],n={}){if(i.nodeType!==1)return e;let r=!1,o=null,s={...t};switch(i.nodeName){case"svg":s=Z(i,s,n);break;case"style":Ne(i,n);break;case"g":s=Z(i,s,n);break;case"path":s=Z(i,s,n),i.hasAttribute("d")&&(o=Ve(i));break;case"rect":s=Z(i,s,n),o=je(i);break;case"polygon":s=Z(i,s,n),o=ze(i);break;case"polyline":s=Z(i,s,n),o=Be(i);break;case"circle":s=Z(i,s,n),o=Fe(i);break;case"ellipse":s=Z(i,s,n),o=De(i);break;case"line":s=Z(i,s,n),o=qe(i);break;case"defs":r=!0;break;case"use":{s=Z(i,s,n);const f=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),p=i.viewportElement?.getElementById(f);p?It(p,s,e,n):console.warn(`'use node' references non-existent node id: ${f}`);break}default:console.warn(i);break}if(s.display==="none")return e;const c=new z,a=[],h=$e(i,c,a);o&&(o.applyTransform(c),e.push(o),o.style={...s});const l=i.childNodes;for(let y=0,f=l.length;y<f;y++){const p=l[y];r&&p.nodeName!=="style"&&p.nodeName!=="defs"||It(p,s,e,n)}return h&&(a.pop(),a.length>0?c.copy(a[a.length-1]):c.identity()),e}function Ze(i){const t=Xt(i);return new ve(It(t,{}),t.getAttribute("viewBox")?.trim().split(" ").map(e=>Number(e)))}function St(i,t,e,n,r){const o=(n-t)*.5,s=(r-e)*.5,c=i*i,a=i*c;return(2*e-2*n+o+s)*a+(-3*e+3*n-2*o-s)*c+o*i+e}function Ue(i,t){const e=1-i;return e*e*e*t}function Xe(i,t){const e=1-i;return 3*e*e*i*t}function We(i,t){return 3*(1-i)*i*i*t}function Ge(i,t){return i*i*i*t}function _t(i,t,e,n,r){return Ue(i,t)+Xe(i,e)+We(i,n)+Ge(i,r)}function He(i,t,e=2){const n=t&&t.length,r=n?t[0]*e:i.length;let o=Yt(i,0,r,e,!0);const s=[];if(!o||o.next===o.prev)return s;let c,a,h;if(n&&(o=tn(i,t,o,e)),i.length>80*e){c=i[0],a=i[1];let l=c,y=a;for(let f=e;f<r;f+=e){const p=i[f],u=i[f+1];p<c&&(c=p),u<a&&(a=u),p>l&&(l=p),u>y&&(y=u)}h=Math.max(l-c,y-a),h=h!==0?32767/h:0}return it(o,s,e,c,a,h,0),s}function Yt(i,t,e,n,r){let o;if(r===fn(i,t,e,n)>0)for(let s=t;s<e;s+=n)o=ee(s/n|0,i[s],i[s+1],o);else for(let s=e-n;s>=t;s-=n)o=ee(s/n|0,i[s],i[s+1],o);return o&&nt(o,o.next)&&(ct(o),o=o.next),o}function W(i,t){if(!i)return i;t||(t=i);let e=i,n;do if(n=!1,!e.steiner&&(nt(e,e.next)||F(e.prev,e,e.next)===0)){if(ct(e),e=t=e.prev,e===e.next)break;n=!0}else e=e.next;while(n||e!==t);return t}function it(i,t,e,n,r,o,s){if(!i)return;!s&&o&&on(i,n,r,o);let c=i;for(;i.prev!==i.next;){const a=i.prev,h=i.next;if(o?Ye(i,n,r,o):Qe(i)){t.push(a.i,i.i,h.i),ct(i),i=h.next,c=h.next;continue}if(i=h,i===c){s?s===1?(i=Je(W(i),t),it(i,t,e,n,r,o,2)):s===2&&Ke(i,t,e,n,r,o):it(W(i),t,e,n,r,o,1);break}}}function Qe(i){const t=i.prev,e=i,n=i.next;if(F(t,e,n)>=0)return!1;const r=t.x,o=e.x,s=n.x,c=t.y,a=e.y,h=n.y,l=Math.min(r,o,s),y=Math.min(c,a,h),f=Math.max(r,o,s),p=Math.max(c,a,h);let u=n.next;for(;u!==t;){if(u.x>=l&&u.x<=f&&u.y>=y&&u.y<=p&&rt(r,c,o,a,s,h,u.x,u.y)&&F(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function Ye(i,t,e,n){const r=i.prev,o=i,s=i.next;if(F(r,o,s)>=0)return!1;const c=r.x,a=o.x,h=s.x,l=r.y,y=o.y,f=s.y,p=Math.min(c,a,h),u=Math.min(l,y,f),x=Math.max(c,a,h),g=Math.max(l,y,f),P=Et(p,u,t,e,n),C=Et(x,g,t,e,n);let w=i.prevZ,v=i.nextZ;for(;w&&w.z>=P&&v&&v.z<=C;){if(w.x>=p&&w.x<=x&&w.y>=u&&w.y<=g&&w!==r&&w!==s&&rt(c,l,a,y,h,f,w.x,w.y)&&F(w.prev,w,w.next)>=0||(w=w.prevZ,v.x>=p&&v.x<=x&&v.y>=u&&v.y<=g&&v!==r&&v!==s&&rt(c,l,a,y,h,f,v.x,v.y)&&F(v.prev,v,v.next)>=0))return!1;v=v.nextZ}for(;w&&w.z>=P;){if(w.x>=p&&w.x<=x&&w.y>=u&&w.y<=g&&w!==r&&w!==s&&rt(c,l,a,y,h,f,w.x,w.y)&&F(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;v&&v.z<=C;){if(v.x>=p&&v.x<=x&&v.y>=u&&v.y<=g&&v!==r&&v!==s&&rt(c,l,a,y,h,f,v.x,v.y)&&F(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Je(i,t){let e=i;do{const n=e.prev,r=e.next.next;!nt(n,r)&&Kt(n,e,e.next,r)&&ot(n,r)&&ot(r,n)&&(t.push(n.i,e.i,r.i),ct(e),ct(e.next),e=i=r),e=e.next}while(e!==i);return W(e)}function Ke(i,t,e,n,r,o){let s=i;do{let c=s.next.next;for(;c!==s.prev;){if(s.i!==c.i&&an(s,c)){let a=te(s,c);s=W(s,s.next),a=W(a,a.next),it(s,t,e,n,r,o,0),it(a,t,e,n,r,o,0);return}c=c.next}s=s.next}while(s!==i)}function tn(i,t,e,n){const r=[];for(let o=0,s=t.length;o<s;o++){const c=t[o]*n,a=o<s-1?t[o+1]*n:i.length,h=Yt(i,c,a,n,!1);h===h.next&&(h.steiner=!0),r.push(hn(h))}r.sort(en);for(let o=0;o<r.length;o++)e=nn(r[o],e);return e}function en(i,t){let e=i.x-t.x;if(e===0&&(e=i.y-t.y,e===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(t.next.y-t.y)/(t.next.x-t.x);e=n-r}return e}function nn(i,t){const e=sn(i,t);if(!e)return t;const n=te(e,i);return W(n,n.next),W(e,e.next)}function sn(i,t){let e=t;const n=i.x,r=i.y;let o=-1/0,s;if(nt(i,e))return e;do{if(nt(i,e.next))return e.next;if(r<=e.y&&r>=e.next.y&&e.next.y!==e.y){const y=e.x+(r-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(y<=n&&y>o&&(o=y,s=e.x<e.next.x?e:e.next,y===n))return s}e=e.next}while(e!==t);if(!s)return null;const c=s,a=s.x,h=s.y;let l=1/0;e=s;do{if(n>=e.x&&e.x>=a&&n!==e.x&&Jt(r<h?n:o,r,a,h,r<h?o:n,r,e.x,e.y)){const y=Math.abs(r-e.y)/(n-e.x);ot(e,i)&&(y<l||y===l&&(e.x>s.x||e.x===s.x&&rn(s,e)))&&(s=e,l=y)}e=e.next}while(e!==c);return s}function rn(i,t){return F(i.prev,i,t.prev)<0&&F(t.next,i,i.next)<0}function on(i,t,e,n){let r=i;do r.z===0&&(r.z=Et(r.x,r.y,t,e,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,cn(r)}function cn(i){let t,e=1;do{let n=i,r;i=null;let o=null;for(t=0;n;){t++;let s=n,c=0;for(let h=0;h<e&&(c++,s=s.nextZ,!!s);h++);let a=e;for(;c>0||a>0&&s;)c!==0&&(a===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,c--):(r=s,s=s.nextZ,a--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,e*=2}while(t>1);return i}function Et(i,t,e,n,r){return i=(i-e)*r|0,t=(t-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,i|t<<1}function hn(i){let t=i,e=i;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==i);return e}function Jt(i,t,e,n,r,o,s,c){return(r-s)*(t-c)>=(i-s)*(o-c)&&(i-s)*(n-c)>=(e-s)*(t-c)&&(e-s)*(o-c)>=(r-s)*(n-c)}function rt(i,t,e,n,r,o,s,c){return!(i===s&&t===c)&&Jt(i,t,e,n,r,o,s,c)}function an(i,t){return i.next.i!==t.i&&i.prev.i!==t.i&&!ln(i,t)&&(ot(i,t)&&ot(t,i)&&un(i,t)&&(F(i.prev,i,t.prev)||F(i,t.prev,t))||nt(i,t)&&F(i.prev,i,i.next)>0&&F(t.prev,t,t.next)>0)}function F(i,t,e){return(t.y-i.y)*(e.x-t.x)-(t.x-i.x)*(e.y-t.y)}function nt(i,t){return i.x===t.x&&i.y===t.y}function Kt(i,t,e,n){const r=gt(F(i,t,e)),o=gt(F(i,t,n)),s=gt(F(e,n,i)),c=gt(F(e,n,t));return!!(r!==o&&s!==c||r===0&&pt(i,e,t)||o===0&&pt(i,n,t)||s===0&&pt(e,i,n)||c===0&&pt(e,t,n))}function pt(i,t,e){return t.x<=Math.max(i.x,e.x)&&t.x>=Math.min(i.x,e.x)&&t.y<=Math.max(i.y,e.y)&&t.y>=Math.min(i.y,e.y)}function gt(i){return i>0?1:i<0?-1:0}function ln(i,t){let e=i;do{if(e.i!==i.i&&e.next.i!==i.i&&e.i!==t.i&&e.next.i!==t.i&&Kt(e,e.next,i,t))return!0;e=e.next}while(e!==i);return!1}function ot(i,t){return F(i.prev,i,i.next)<0?F(i,t,i.next)>=0&&F(i,i.prev,t)>=0:F(i,t,i.prev)<0||F(i,i.next,t)<0}function un(i,t){let e=i,n=!1;const r=(i.x+t.x)/2,o=(i.y+t.y)/2;do e.y>o!=e.next.y>o&&e.next.y!==e.y&&r<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(n=!n),e=e.next;while(e!==i);return n}function te(i,t){const e=$t(i.i,i.x,i.y),n=$t(t.i,t.x,t.y),r=i.next,o=t.prev;return i.next=t,t.prev=i,e.next=r,r.prev=e,n.next=e,e.prev=n,o.next=n,n.prev=o,n}function ee(i,t,e,n){const r=$t(i,t,e);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function ct(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function $t(i,t,e){return{i,x:t,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function fn(i,t,e,n){let r=0;for(let o=t,s=e-n;o<e;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Lt(i,t={}){let{vertices:e=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=e.length/o,indicesOffset:c=n.length}=t;const a=He(i,r,2);if(a.length){for(let l=0;l<a.length;l+=3)n[c++]=a[l]+s,n[c++]=a[l+1]+s,n[c++]=a[l+2]+s;let h=s*o;for(let l=0;l<i.length;l+=2)e[h]=i[l],e[h+1]=i[l+1],h+=o}return{vertices:e,indices:n}}const yn=8,dt=11920929e-14,xn=1;function ne(i,t,e,n,r,o,s,c,a=.5,h=[]){const y=Math.min(.99,Math.max(0,a));let f=(xn-y)/1;return f*=f,Ft(i,t,e,n,r,o,s,c,h,f,0),h.push(s,c),h}function Ft(i,t,e,n,r,o,s,c,a,h,l){if(l>yn)return;const y=(i+e)/2,f=(t+n)/2,p=(e+r)/2,u=(n+o)/2,x=(r+s)/2,g=(o+c)/2,P=(y+p)/2,C=(f+u)/2,w=(p+x)/2,v=(u+g)/2,b=(P+w)/2,S=(C+v)/2;if(l>0){let d=s-i,M=c-t;const V=Math.abs((e-s)*M-(n-c)*d),L=Math.abs((r-s)*M-(o-c)*d);if(V>dt&&L>dt){if((V+L)*(V+L)<=h*(d*d+M*M)){a.push(b,S);return}}else if(V>dt){if(V*V<=h*(d*d+M*M)){a.push(b,S);return}}else if(L>dt){if(L*L<=h*(d*d+M*M)){a.push(b,S);return}}else if(d=b-(i+s)/2,M=S-(t+c)/2,d*d+M*M<=h){a.push(b,S);return}}Ft(i,t,y,f,P,C,b,S,a,h,l+1),Ft(b,S,w,v,x,g,s,c,a,h,l+1)}const pn=8,gn=11920929e-14,dn=1;function se(i,t,e,n,r,o,s=.5,c=[]){const h=Math.min(.99,Math.max(0,s));let l=(dn-h)/1;return l*=l,Nt(c,i,t,e,n,r,o,l,0),c.push(r,o),c}function Nt(i,t,e,n,r,o,s,c,a){if(a>pn)return;const h=(t+n)/2,l=(e+r)/2,y=(n+o)/2,f=(r+s)/2,p=(h+y)/2,u=(l+f)/2;let x=o-t,g=s-e;const P=Math.abs((n-o)*g-(r-s)*x);if(P>gn){if(P*P<=c*(x*x+g*g)){i.push(p,u);return}}else if(x=p-(t+o)/2,g=u-(e+s)/2,x*x+g*g<=c){i.push(p,u);return}Nt(i,t,e,h,l,p,u,c,a+1),Nt(i,p,u,y,f,o,s,c,a+1)}function mn(i){let t=0;const e=i.length;for(let n=0;n<e;n+=2){const r=i[n],o=i[n+1],s=i[(n+2)%(e-1)],c=i[(n+3)%e];t+=r*c-s*o}return t/2}function ie(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function re(i,t,e,n){const r=t.clone().sub(i),o=n.clone().sub(e),s=e.clone().sub(i),c=r.cross(o);if(c===0)return new m((i.x+e.x)/2,(i.y+e.y)/2);const a=s.cross(o)/c;return Math.abs(a)>1?new m((i.x+e.x)/2,(i.y+e.y)/2):new m(i.x+a*r.x,i.y+a*r.y)}function Mn(i){let t=0;const e=i.length/2;for(let n=0;n<e;n++){const r=i[2*n],o=i[2*n+1],s=(n+1)%e,c=i[2*s],a=i[2*s+1];t+=(c-r)*(a+o)}return t}function oe(i,t,e,n,r,o){return(e-i)*(o-t)-(r-i)*(n-t)}function wn(i,t,e){const n=e.length;let r=0;for(let o=0,s=n-2;o<n;s=o,o+=2){const c=e[o],a=e[o+1],h=e[s],l=e[s+1];a<=t?l>t&&oe(h,l,c,a,i,t)>0&&r++:l<=t&&oe(h,l,c,a,i,t)<0&&r--}return r}function vn(i,t){const e=t[0]-i[0],n=t[1]-i[1];return Math.sqrt(e*e+n*n)}function ce(i){const t=i.length,e=i.map((n,r)=>({index:r,dist:0,wn:0,parentIndex:void 0}));for(let n=0;n<t;n++){if(Mn(i[n])<0)continue;const r=i[n],o=[...r];let s;for(let c=0;c<t;c++){if(n===c)continue;let a=0;for(let h=0;h<o.length&&(a=a||wn(o[h],o[h+1],i[c]),!a);h+=2);if(Math.abs(a)>0){const h=vn(r,i[c]);(!s||h<s.dist)&&(s={index:c,dist:h,wn:a})}}s&&(e[n].dist=s.dist,e[n].wn=s.wn,e[n].parentIndex=s.index)}return e}function Pn(i,t){const e=1-i;return e*e*t}function Tn(i,t){return 2*(1-i)*i*t}function Cn(i,t){return i*i*t}function Dt(i,t,e,n){return Pn(i,t)+Tn(i,e)+Cn(i,n)}const bn=1e-4,he=1e-4;function ae(i,t={}){const{vertices:e=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=t,c=bn;if(i.length===0)return{vertices:e,indices:n};const a=r;let h=a.alignment;if(r.alignment!==.5){let $=An(i);o&&($*=-1),h=(h-.5)*$+.5}const l={x:i[0],y:i[1]},y={x:i[i.length-2],y:i[i.length-1]},f=s,p=Math.abs(l.x-y.x)<c&&Math.abs(l.y-y.y)<c;if(f){i=i.slice(),p&&(i.pop(),i.pop(),y.x=i[i.length-2],y.y=i[i.length-1]);const $=(l.x+y.x)*.5,X=(y.y+l.y)*.5;i.unshift($,X),i.push($,X)}const u=e,x=i.length/2;let g=i.length;const P=u.length/2,C=a.width/2,w=C*C,v=a.miterLimit*a.miterLimit;let b=i[0],S=i[1],d=i[2],M=i[3],V=0,L=0,k=-(S-M),I=b-d,N=0,D=0,R=Math.sqrt(k*k+I*I);k/=R,I/=R,k*=C,I*=C;const at=h,T=(1-at)*2,_=at*2;f||(a.cap==="round"?g+=G(b-k*(T-_)*.5,S-I*(T-_)*.5,b-k*T,S-I*T,b+k*_,S+I*_,u,!0)+2:a.cap==="square"&&(g+=le(b,S,k,I,T,_,!0,u))),u.push(b-k*T,S-I*T),u.push(b+k*_,S+I*_);for(let $=1;$<x-1;++$){b=i[($-1)*2],S=i[($-1)*2+1],d=i[$*2],M=i[$*2+1],V=i[($+1)*2],L=i[($+1)*2+1],k=-(S-M),I=b-d,R=Math.sqrt(k*k+I*I),k/=R,I/=R,k*=C,I*=C,N=-(M-L),D=d-V,R=Math.sqrt(N*N+D*D),N/=R,D/=R,N*=C,D*=C;const X=d-b,lt=S-M,ut=d-V,ft=L-M,Te=X*ut+lt*ft,vt=lt*ut-ft*X,yt=vt<0;if(Math.abs(vt)<.001*Math.abs(Te)){u.push(d-k*T,M-I*T),u.push(d+k*_,M+I*_),Te>=0&&(a.join==="round"?g+=G(d,M,d-k*T,M-I*T,d-N*T,M-D*T,u,!1)+4:g+=2,u.push(d-N*_,M-D*_),u.push(d+N*T,M+D*T));continue}const Ce=(-k+b)*(-I+M)-(-k+d)*(-I+S),be=(-N+V)*(-D+M)-(-N+d)*(-D+L),Pt=(X*be-ut*Ce)/vt,Tt=(ft*Ce-lt*be)/vt,Rt=(Pt-d)*(Pt-d)+(Tt-M)*(Tt-M),Q=d+(Pt-d)*T,Y=M+(Tt-M)*T,J=d-(Pt-d)*_,K=M-(Tt-M)*_,Dn=Math.min(X*X+lt*lt,ut*ut+ft*ft),Ae=yt?T:_,qn=Dn+Ae*Ae*w;Rt<=qn?a.join==="bevel"||Rt/w>v?(yt?(u.push(Q,Y),u.push(d+k*_,M+I*_),u.push(Q,Y),u.push(d+N*_,M+D*_)):(u.push(d-k*T,M-I*T),u.push(J,K),u.push(d-N*T,M-D*T),u.push(J,K)),g+=2):a.join==="round"?yt?(u.push(Q,Y),u.push(d+k*_,M+I*_),g+=G(d,M,d+k*_,M+I*_,d+N*_,M+D*_,u,!0)+4,u.push(Q,Y),u.push(d+N*_,M+D*_)):(u.push(d-k*T,M-I*T),u.push(J,K),g+=G(d,M,d-k*T,M-I*T,d-N*T,M-D*T,u,!1)+4,u.push(d-N*T,M-D*T),u.push(J,K)):(u.push(Q,Y),u.push(J,K)):(u.push(d-k*T,M-I*T),u.push(d+k*_,M+I*_),a.join==="round"?yt?g+=G(d,M,d+k*_,M+I*_,d+N*_,M+D*_,u,!0)+2:g+=G(d,M,d-k*T,M-I*T,d-N*T,M-D*T,u,!1)+2:a.join==="miter"&&Rt/w<=v&&(yt?(u.push(J,K),u.push(J,K)):(u.push(Q,Y),u.push(Q,Y)),g+=2),u.push(d-N*T,M-D*T),u.push(d+N*_,M+D*_),g+=2)}b=i[(x-2)*2],S=i[(x-2)*2+1],d=i[(x-1)*2],M=i[(x-1)*2+1],k=-(S-M),I=b-d,R=Math.sqrt(k*k+I*I),k/=R,I/=R,k*=C,I*=C,u.push(d-k*T,M-I*T),u.push(d+k*_,M+I*_),f||(a.cap==="round"?g+=G(d-k*(T-_)*.5,M-I*(T-_)*.5,d-k*T,M-I*T,d+k*_,M+I*_,u,!1)+2:a.cap==="square"&&(g+=le(d,M,k,I,T,_,!1,u)));const Nn=he*he;for(let $=P;$<g+P-2;++$)b=u[$*2],S=u[$*2+1],d=u[($+1)*2],M=u[($+1)*2+1],V=u[($+2)*2],L=u[($+2)*2+1],!(Math.abs(b*(M-L)+d*(L-S)+V*(S-M))<Nn)&&n.push($,$+1,$+2);return{vertices:e,indices:n}}function An(i){const t=i.length;if(t<6)return 1;let e=0;for(let n=0,r=i[t-2],o=i[t-1];n<t;n+=2){const s=i[n],c=i[n+1];e+=(s-r)*(c+o),r=s,o=c}return e<0?-1:1}function le(i,t,e,n,r,o,s,c){const a=i-e*r,h=t-n*r,l=i+e*o,y=t+n*o;let f,p;s?(f=n,p=-e):(f=-n,p=e);const u=a+f,x=h+p,g=l+f,P=y+p;return c.push(u,x),c.push(g,P),2}function G(i,t,e,n,r,o,s,c){const a=e-i,h=n-t;let l=Math.atan2(a,h),y=Math.atan2(r-i,o-t);c&&l<y?l+=Math.PI*2:!c&&l>y&&(y+=Math.PI*2);let f=l;const p=y-l,u=Math.abs(p),x=Math.sqrt(a*a+h*h),g=(15*u*Math.sqrt(x)/Math.PI>>0)+1,P=p/g;if(f+=P,c){s.push(i,t),s.push(e,n);for(let C=1,w=f;C<g;C++,w+=P)s.push(i,t),s.push(i+Math.sin(w)*x,t+Math.cos(w)*x);s.push(i,t),s.push(r,o)}else{s.push(e,n),s.push(i,t);for(let C=1,w=f;C<g;C++,w+=P)s.push(i+Math.sin(w)*x,t+Math.cos(w)*x),s.push(i,t);s.push(r,o),s.push(i,t)}return g*2}class H{arcLengthDivision=200;_arcLengths;getPointAt(t,e=new m){return this.getPoint(this.getUToTMapping(t),e)}isClockwise(){return!1}getControlPointRefs(){return[]}applyTransform(t){const e=typeof t=="function";return this.getControlPointRefs().forEach(n=>{e?t(n):n.applyMatrix3(t)}),this}getUnevenVertices(t=5,e=[]){const n=new m;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPoint(r/o,n),e.push(n.x,n.y);return e}getSpacedVertices(t=5,e=[]){const n=new m;for(let r=0,o=Math.max(1,t)-1;r<=o;r++)this.getPointAt(r/o,n),e.push(n.x,n.y);return e}getAdaptiveVertices(t=[]){return this.getUnevenVertices(5,t)}_verticesToPoints(t,e=[]){for(let n=0,r=t.length;n<r;n+=2){const o=t[n],s=t[n+1];e.push(new m(o,s))}return e}getSpacedPoints(t,e=[]){const n=this.getSpacedVertices(t);return this._verticesToPoints(n,e),e}getUnevenPoints(t,e=[]){const n=this.getUnevenVertices(t);return this._verticesToPoints(n,e),e}getAdaptivePoints(t=[]){const e=this.getAdaptiveVertices();return this._verticesToPoints(e,t),t}getPoints(t,e=[]){let n;return t?n=this.getUnevenVertices(t):n=this.getAdaptiveVertices(),this._verticesToPoints(n,e),e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const t=this.arcLengthDivision,e=[0];for(let n=0,r=this.getPoint(0),o=1;o<=t;o++){const s=this.getPoint(o/t);n+=s.distanceTo(r),e.push(n),r=s}this._arcLengths=e}getUToTMapping(t,e){const n=this.getLengths(),r=n.length,o=e??t*n[r-1];if(r<2)return o/n[0];let s=0,c=0,a=r-1,h;for(;c<=a;)if(s=Math.floor(c+(a-c)/2),h=n[s]-o,h<0)c=s+1;else if(h>0)a=s-1;else{a=s;break}if(s=a,n[s]===o)return s/(r-1);const l=n[s],f=n[s+1]-l,p=(o-l)/f;return(s+p)/(r-1)}getTangent(t,e=new m){const r=Math.max(0,t-1e-4),o=Math.min(1,t+1e-4);return e.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(t,e){return this.getTangent(this.getUToTMapping(t),e)}getNormal(t,e=new m){return this.getTangent(t,e),e.set(-e.y,e.x).normalize()}getNormalAt(t,e){return this.getNormal(this.getUToTMapping(t),e)}getTForPoint(t,e=.001){let n=0,r=1,o=(n+r)/2;for(;r-n>e;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(t)<e)return o;s.x<t.x?n=o:r=o}return o}getMinMax(t=m.MAX,e=m.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];t.min(s),e.max(s)}return{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}getFillVertices(t){return this.getAdaptiveVertices()}fillTriangulate(t){return Lt(this.getFillVertices(t),t)}strokeTriangulate(t){return ae(this.getAdaptiveVertices(),t)}toCommands(){const t=[],e=this.getPoints();for(let n=0,r=e.length;n<r;n++){const o=e[n];n===0?t.push({type:"M",x:o.x,y:o.y}):t.push({type:"L",x:o.x,y:o.y})}return t}toData(){return Bt(this.toCommands())}drawTo(t){return this.toCommands().forEach(e=>{switch(e.type){case"M":t.moveTo(e.x,e.y);break;case"L":t.lineTo(e.x,e.y);break}}),this}copy(t){return this.arcLengthDivision=t.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const kn=new z,ue=new z,fe=new z,mt=new m;class qt extends H{constructor(t=new m,e=new m,n=new m,r=0,o=0,s=Math.PI*2,c=!1){super(),this._center=t,this._radius=e,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=c}get cx(){return this._center.x}set cx(t){this._center.x=t}get cy(){return this._center.y}set cy(t){this._center.y=t}get rx(){return this._radius.x}set rx(t){this._radius.x=t}get ry(){return this._radius.y}set ry(t){this._radius.y=t}get dx(){return this._diff.x}set dx(t){this._diff.x=t}get dy(){return this._diff.y}set dy(t){this._diff.y=t}isClockwise(){return this.clockwise}_getDeltaAngle(){const t=Math.PI*2;let e=this.endAngle-this.startAngle;const n=Math.abs(e)<Number.EPSILON;return e=(e%t+t)%t,n?e=0:this.clockwise||(e=e===0?-t:e-t),e}getPoint(t,e=new m){const n=this._getDeltaAngle(),r=this.startAngle+t*n;let o=this.cx+this.rx*Math.cos(r),s=this.cy+this.ry*Math.sin(r);if(this.rotate!==0){const c=Math.cos(this.rotate),a=Math.sin(this.rotate),h=o-this.cx,l=s-this.cy;o=h*c-l*a+this.cx,s=h*a+l*c+this.cy}return e.set(o,s)}toCommands(){const{cx:t,cy:e,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:c,rotate:a}=this,h=t+n*Math.cos(o)*Math.cos(a)-r*Math.sin(o)*Math.sin(a),l=e+n*Math.cos(o)*Math.sin(a)+r*Math.sin(o)*Math.cos(a),y=Math.abs(o-s),f=y>Math.PI?1:0,p=c?1:0,u=a*180/Math.PI;if(y>=2*Math.PI){const x=o+Math.PI,g=t+n*Math.cos(x)*Math.cos(a)-r*Math.sin(x)*Math.sin(a),P=e+n*Math.cos(x)*Math.sin(a)+r*Math.sin(x)*Math.cos(a);return[{type:"M",x:h,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:p,x:g,y:P},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:p,x:h,y:l}]}else{const x=t+n*Math.cos(s)*Math.cos(a)-r*Math.sin(s)*Math.sin(a),g=e+n*Math.cos(s)*Math.sin(a)+r*Math.sin(s)*Math.cos(a);return[{type:"M",x:h,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:f,sweepFlag:p,x,y:g}]}}drawTo(t){const{cx:e,cy:n,rx:r,ry:o,rotate:s,startAngle:c,endAngle:a,clockwise:h}=this;return t.ellipse(e,n,r,o,s,c,a,!h),this}applyTransform(t){return mt.set(this.cx,this.cy),mt.applyMatrix3(t),this.cx=mt.x,this.cy=mt.y,_n(t)?In(this,t):Sn(this,t),this}getControlPointRefs(){return[this._center]}_getAdaptiveVerticesByArc(t=[]){const{cx:e,cy:n,rx:r,ry:o,dx:s,dy:c,startAngle:a,endAngle:h,clockwise:l,rotate:y}=this,f=!l;let p=Math.abs(a-h);(!f&&a>h||f&&h>a)&&(p=2*Math.PI-p);const u=Math.max(12,Math.floor(12*r**(1/3)*(p/Math.PI)));let x=p/u,g=a;x*=f?-1:1;const P=Math.cos(f?y:-y),C=Math.sin(f?y:-y);for(let w=0;w<u+1;w++){const v=s+Math.cos(g)*r,b=c+Math.sin(g)*o,S=v*P-b*C,d=v*C+b*P;t.push(e+S,n+d),g+=x}return t}_getAdaptiveVerticesByCircle(t=[]){const{cx:e,cy:n,rx:r,ry:o,dx:s,dy:c,rotate:a,clockwise:h}=this;if(!(r>=0&&o>=0&&s>=0&&c>=0))return t;const l=Math.ceil(2.3*Math.sqrt(r+o)),y=l*8+(s?4:0)+(c?4:0),f=[];if(y===0)return t;{const x=f.length;if(l===0)f[x]=f[x+6]=e+s,f[x+1]=f[x+3]=n+c,f[x+2]=f[x+4]=e-s,f[x+5]=f[x+7]=n-c;else{let g=x,P=x+l*4+(s?2:0)+2,C=P,w=y,v=s+r,b=c,S=e+v,d=e-v,M=n+b;if(f[g++]=S,f[g++]=M,f[--P]=M,f[--P]=d,c){const L=n-b;f[C++]=d,f[C++]=L,f[--w]=L,f[--w]=S}for(let L=1;L<l;L++){const k=Math.PI/2*(L/l),I=s+Math.cos(k)*r,N=c+Math.sin(k)*o,D=e+I,R=e-I,at=n+N,T=n-N;f[g++]=D,f[g++]=at,f[--P]=at,f[--P]=R,f[C++]=R,f[C++]=T,f[--w]=T,f[--w]=D}v=s,b=c+o,S=e+v,d=e-v,M=n+b;const V=n-b;f[g++]=S,f[g++]=M,f[--w]=V,f[--w]=S,s&&(f[g++]=d,f[g++]=M,f[--w]=V,f[--w]=d)}}const p=Math.cos(h?-a:a),u=Math.sin(h?-a:a);for(let x=0;x<f.length;x+=2){const g=f[x],P=f[x+1],C=g-e,w=P-n,v=C*p-w*u,b=C*u+w*p;t.push(e+v,n+b)}return t}getAdaptiveVertices(t=[]){return this.startAngle===0&&this.endAngle===Math.PI*2?this._getAdaptiveVerticesByCircle(t):this._getAdaptiveVerticesByArc(t)}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.rx=t.rx,this.ry=t.ry,this.dx=t.dx,this.dy=t.dy,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotate=t.rotate,this}}function In(i,t){const e=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new m(e*r,e*o),c=new m(-n*o,n*r),a=s.applyMatrix3(t),h=c.applyMatrix3(t),l=kn.set(a.x,h.x,0,a.y,h.y,0,0,0,1),y=ue.copy(l).invert(),u=fe.copy(y).transpose().multiply(y).elements,x=En(u[0],u[1],u[4]),g=Math.sqrt(x.rt1),P=Math.sqrt(x.rt2);if(i.rx=1/g,i.ry=1/P,i.rotate=Math.atan2(x.sn,x.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const w=ue.set(g,0,0,0,P,0,0,0,1),v=fe.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),b=w.multiply(v).multiply(l),S=d=>{const{x:M,y:V}=new m(Math.cos(d),Math.sin(d)).applyMatrix3(b);return Math.atan2(V,M)};i.startAngle=S(i.startAngle),i.endAngle=S(i.endAngle),ye(t)&&(i.clockwise=!i.clockwise)}}function Sn(i,t){const e=xe(t),n=pe(t);i.rx*=e,i.ry*=n;const r=e>Number.EPSILON?Math.atan2(t.elements[1],t.elements[0]):Math.atan2(-t.elements[3],t.elements[4]);i.rotate+=r,ye(t)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ye(i){const t=i.elements;return t[0]*t[4]-t[1]*t[3]<0}function _n(i){const t=i.elements,e=t[0]*t[3]+t[1]*t[4];if(e===0)return!1;const n=xe(i),r=pe(i);return Math.abs(e/(n*r))>Number.EPSILON}function xe(i){const t=i.elements;return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function pe(i){const t=i.elements;return Math.sqrt(t[3]*t[3]+t[4]*t[4])}function En(i,t,e){let n,r,o,s,c;const a=i+e,h=i-e,l=Math.sqrt(h*h+4*t*t);return a>0?(n=.5*(a+l),c=1/n,r=i*c*e-t*c*t):a<0?r=.5*(a-l):(n=.5*l,r=-.5*l),h>0?o=h+l:o=h-l,Math.abs(o)>2*Math.abs(t)?(c=-2*t/o,s=1/Math.sqrt(1+c*c),o=c*s):Math.abs(t)===0?(o=1,s=0):(c=-.5*o/t,o=1/Math.sqrt(1+c*c),s=c*o),h>0&&(c=o,o=-s,s=c),{rt1:n,rt2:r,cs:o,sn:s}}class ge extends qt{constructor(t=0,e=0,n=1,r=0,o=Math.PI*2,s=!1){super(new m(t,e),new m(n,n),new m,0,r,o,s)}drawTo(t){const{cx:e,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:c}=this;return t.arc(e,n,r,o,s,!c),this}}class B extends H{constructor(t=new m,e=new m){super(),this.p1=t,this.p2=e}static from(t,e,n,r){return new B(new m(t,e),new m(n,r))}getPoint(t,e=new m){return t===1?e.copy(this.p2):e.copy(this.p2).sub(this.p1).scale(t).add(this.p1),e}getPointAt(t,e=new m){return this.getPoint(t,e)}getTangent(t,e=new m){return e.subVectors(this.p2,this.p1).normalize()}getTangentAt(t,e=new m){return this.getTangent(t,e)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptiveVertices(t=[]){return t.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),t}getMinMax(t=m.MAX,e=m.MIN){const{p1:n,p2:r}=this;return t.x=Math.min(t.x,n.x,r.x),t.y=Math.min(t.y,n.y,r.y),e.x=Math.max(e.x,n.x,r.x),e.y=Math.max(e.y,n.y,r.y),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,p2:e}=this;return[{type:"M",x:t.x,y:t.y},{type:"L",x:e.x,y:e.y}]}getFillVertices(t={}){const e=Math.min(this.p1.x,this.p2.x),n=Math.max(this.p1.x,this.p2.x),r=Math.min(this.p1.y,this.p2.y),o=Math.max(this.p1.y,this.p2.y),s=e,c=r,a=n-e||t.style?.strokeWidth||0,h=o-r||t.style?.strokeWidth||0;return[s,c,s+a,c,s+a,c+h,s,c+h]}drawTo(t){const{p1:e,p2:n}=this;return t.lineTo(e.x,e.y),t.lineTo(n.x,n.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.p2.copy(t.p2),this}}class st extends H{constructor(t=[]){super(),this.curves=t}getFlatCurves(){return this.curves.flatMap(t=>t instanceof st?t.getFlatCurves():t)}addCurve(t){return this.curves.push(t),this}getPoint(t,e=new m){const n=t*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,c=this.curves[o],a=c.getLength();return c.getPointAt(a===0?0:1-s/a,e)}o++}return e}updateLengths(){const t=[];for(let e=0,n=0,r=this.curves.length;e<r;e++)n+=this.curves[e].getLength(),t.push(n);this._arcLengths=t}getControlPointRefs(){return this.curves.flatMap(t=>t.getControlPointRefs())}_removeNextPointIfEqualPrevPoint(t,e){const n=[t[e-1],t[e]],r=[t[e+1],t[e+2]];return n[0]===r[0]&&n[1]===r[1]&&t.splice(e+1,2),t}getSpacedVertices(t=5,e=[]){let n;return this.curves.forEach(r=>{r.getSpacedVertices(t,e),n&&this._removeNextPointIfEqualPrevPoint(e,n),n=e.length-1}),e}getAdaptiveVertices(t=[]){let e;return this.curves.forEach(n=>{n.getAdaptiveVertices(t),e&&this._removeNextPointIfEqualPrevPoint(t,e),e=t.length-1}),t}strokeTriangulate(t){return this.curves.length===1?this.curves[0].strokeTriangulate(t):super.strokeTriangulate(t)}getFillVertices(t){if(this.curves.length===1)return this.curves[0].getFillVertices(t);{const e=[];let n;return this.curves.forEach(r=>{let o;r instanceof B?o=r.getAdaptiveVertices():o=r.getFillVertices(t),e.push(...o),n&&this._removeNextPointIfEqualPrevPoint(e,n),n=e.length-1}),e}}applyTransform(t){return this.curves.forEach(e=>e.applyTransform(t)),this}getMinMax(t=m.MAX,e=m.MIN){return this.curves.forEach(n=>n.getMinMax(t,e)),{min:t.finite(),max:e.finite()}}getBoundingBox(){const{min:t,max:e}=this.getMinMax();return new U(t.x,t.y,e.x-t.x,e.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(n=>n.drawTo(t)),this}copy(t){return super.copy(t),this.curves=t.curves.map(e=>e.clone()),this}}class Mt extends H{constructor(t=new m,e=new m,n=new m,r=new m){super(),this.p1=t,this.cp1=e,this.cp2=n,this.p2=r}static from(t,e,n,r,o,s,c,a){return new Mt(new m(t,e),new m(n,r),new m(o,s),new m(c,a))}getPoint(t,e=new m){const{p1:n,cp1:r,cp2:o,p2:s}=this;return e.set(_t(t,n.x,r.x,o.x,s.x),_t(t,n.y,r.y,o.y,s.y))}getAdaptiveVertices(t=[]){return ne(this.p1.x,this.p1.y,this.cp1.x,this.cp1.y,this.cp2.x,this.cp2.y,this.p2.x,this.p2.y,.5,t)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(t,e,n){const r=e*e-4*t*n;if(r<0)return[];const o=Math.sqrt(r),s=(-e+o)/(2*t),c=(-e-o)/(2*t);return[s,c].filter(a=>a>=0&&a<=1)}getMinMax(t=m.MAX,e=m.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,c=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),a=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),h=[0,1,...c,...a];return((y,f)=>{for(const p of y)for(let u=0;u<=f;u++){const x=u/f-.5,g=Math.min(1,Math.max(0,p+x)),P=this.getPoint(g);t.x=Math.min(t.x,P.x),t.y=Math.min(t.y,P.y),e.x=Math.max(e.x,P.x),e.y=Math.max(e.y,P.y)}})(h,10),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp1:e,cp2:n,p2:r}=this;return[{type:"M",x:t.x,y:t.y},{type:"C",x1:e.x,y1:e.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(t){const{p1:e,cp1:n,cp2:r,p2:o}=this;return t.lineTo(e.x,e.y),t.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp1.copy(t.cp1),this.cp2.copy(t.cp2),this.p2.copy(t.p2),this}}class de extends qt{constructor(t=0,e=0,n=1,r=1,o=0,s=0,c=Math.PI*2,a=!1){super(new m(t,e),new m(n,r),new m,o,s,c,a)}drawTo(t){return t.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class Vt extends st{}class $n extends Vt{constructor(t=0,e=0,n=1,r=3){super(),this.cx=t,this.cy=e,this.radius=n,this.sideCount=r,this.update()}update(){const{cx:t,cy:e,radius:n,sideCount:r}=this,o=[];for(let c=0;c<r;c++){const a=c*2*Math.PI/r-.5*Math.PI;o.push(new m(n*Math.cos(a),n*Math.sin(a)).add({x:t,y:e}))}const s=[];for(let c=0;c<r;c++)s.push(new B(o[c],o[(c+1)%r]));return this.curves=s,this}copy(t){return super.copy(t),this.cx=t.cx,this.cy=t.cy,this.radius=t.radius,this.sideCount=t.sideCount,this.update(),this}}class wt extends H{constructor(t=new m,e=new m,n=new m){super(),this.p1=t,this.cp=e,this.p2=n}static from(t,e,n,r,o,s){return new wt(new m(t,e),new m(n,r),new m(o,s))}getPoint(t,e=new m){const{p1:n,cp:r,p2:o}=this;return e.set(Dt(t,n.x,r.x,o.x),Dt(t,n.y,r.y,o.y)),e}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptiveVertices(t=[]){return se(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,t)}getMinMax(t=m.MAX,e=m.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),c=.5*(n.y+r.y),a=.5*(n.x+o.x),h=.5*(n.y+o.y);return t.x=Math.min(t.x,n.x,o.x,s,a),t.y=Math.min(t.y,n.y,o.y,c,h),e.x=Math.max(e.x,n.x,o.x,s,a),e.y=Math.max(e.y,n.y,o.y,c,h),{min:t.finite(),max:e.finite()}}toCommands(){const{p1:t,cp:e,p2:n}=this;return[{type:"M",x:t.x,y:t.y},{type:"Q",x1:e.x,y1:e.y,x:n.x,y:n.y}]}drawTo(t){const{p1:e,cp:n,p2:r}=this;return t.lineTo(e.x,e.y),t.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(t){return super.copy(t),this.p1.copy(t.p1),this.cp.copy(t.cp),this.p2.copy(t.p2),this}}class me extends Vt{constructor(t=0,e=0,n=0,r=0){super(),this.x=t,this.y=e,this.width=n,this.height=r,this.update()}update(){const{x:t,y:e,width:n,height:r}=this,o=[new m(t,e),new m(t+n,e),new m(t+n,e+r),new m(t,e+r)];return this.curves=[new B(o[0],o[1]),new B(o[1],o[2]),new B(o[2],o[3]),new B(o[3],o[0])],this}drawTo(t){return t.rect(this.x,this.y,this.width,this.height),this}getFillVertices(t={}){const{x:e,y:n,width:r,height:o}=this;return[e,n,e+r,n,e+r,n+o,e,n+o]}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update(),this}}class Me extends qt{constructor(t=0,e=0,n=1,r=1,o=1){super(),this.x=t,this.y=e,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:t,y:e,width:n,height:r,radius:o}=this,s=n/2,c=r/2,a=t+s,h=e+c,l=Math.max(0,Math.min(o,Math.min(s,c))),y=l;return this._center=new m(a,h),this._radius=new m(l,y),this._diff=new m(s-l,c-y),this}drawTo(t){const{x:e,y:n,width:r,height:o,radius:s}=this;return t.roundRect(e,n,r,o,s),this}copy(t){return super.copy(t),this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.radius=t.radius,this.update(),this}}class we extends H{constructor(t=[]){super(),this.points=t}getPoint(t,e=new m){const{points:n}=this,r=(n.length-1)*t,o=Math.floor(r),s=r-o,c=n[o===0?o:o-1],a=n[o],h=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return e.set(St(s,c.x,a.x,h.x,l.x),St(s,c.y,a.y,h.y,l.y)),e}getControlPointRefs(){return this.points}copy(t){super.copy(t),this.points=[];for(let e=0,n=t.points.length;e<n;e++)this.points.push(t.points[e].clone());return this}}class ht extends st{startPoint;currentPoint;autoClose=!1;constructor(t){super(),t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let e=1,n=t.length;e<n;e++){const{x:r,y:o}=t[e];this.lineTo(r,o)}return this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}_closeVertices(t){return this.autoClose&&t.length>=4&&t[0]!==t[t.length-2]&&t[1]!==t[t.length-1]&&t.push(t[0],t[1]),t}getUnevenVertices(t=40,e=[]){return this._closeVertices(super.getUnevenVertices(t,e))}getSpacedVertices(t=40,e=[]){return this._closeVertices(super.getSpacedVertices(t,e))}getAdaptiveVertices(t=[]){return this._closeVertices(super.getAdaptiveVertices(t))}getFillVertices(t){return this._closeVertices(super.getFillVertices(t))}_setCurrentPoint(t){return this.currentPoint=new m(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const e=t.getPoint(0);(!this.currentPoint||!e.equals(this.currentPoint))&&this.lineTo(e.x,e.y)}return this}closePath(){const t=this.startPoint;if(t){const e=this.currentPoint;e&&!t.equals(e)&&(this.curves.push(new B(e.clone(),t.clone())),e.copy(t)),this.startPoint=void 0}return this}moveTo(t,e){return this.currentPoint=new m(t,e),this.startPoint=this.currentPoint.clone(),this}lineTo(t,e){const n=this.currentPoint;return n?.equals({x:t,y:e})||this.curves.push(B.from(n?.x??0,n?.y??0,t,e)),this._setCurrentPoint({x:t,y:e}),this}bezierCurveTo(t,e,n,r,o,s){const c=this.currentPoint;return c?.equals({x:o,y:s})||this.curves.push(Mt.from(c?.x??0,c?.y??0,t,e,n,r,o,s)),this._setCurrentPoint({x:o,y:s}),this}quadraticCurveTo(t,e,n,r){const o=this.currentPoint;return o?.equals({x:n,y:r})||this.curves.push(wt.from(o?.x??0,o?.y??0,t,e,n,r)),this._setCurrentPoint({x:n,y:r}),this}arc(t,e,n,r,o,s){const c=new ge(t,e,n,r,o,!s);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeArc(t,e,n,r,o,s){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.arc(t,e,n,r,o,s),this}arcTo(t,e,n,r,o){return console.warn("Method arcTo not supported yet"),this}ellipse(t,e,n,r,o,s,c,a=!0){const h=new de(t,e,n,r,o,s,c,!a);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint(h.getPoint(1)),this}relativeEllipse(t,e,n,r,o,s,c,a){return t+=this.currentPoint?.x??0,e+=this.currentPoint?.y??0,this.ellipse(t,e,n,r,o,s,c,a),this}rect(t,e,n,r){const o=new me(t,e,n,r);return this._connetLineTo(o),this.curves.push(o),this._setCurrentPoint({x:t,y:e}),this}roundRect(t,e,n,r,o){const s=new Me(t,e,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:e}),this}splineThru(t){const e=this.currentPoint??new m;return this.curves.push(new we([e].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){const e=this.curves[0]?.getPoint(0);return e&&t.moveTo(e.x,e.y),this.curves.forEach(n=>n.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=t.currentPoint?.clone(),this}}class j extends st{_meta;currentCurve=new ht;style;get startPoint(){return this.currentCurve.startPoint}get currentPoint(){return this.currentCurve.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}constructor(t,e={}){super(),this.curves.push(this.currentCurve),this.style=e,t&&(t instanceof j?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}getMeta(){return this._meta}setMeta(t){return this._meta=t,this}addPath(t){const e=this.curves.findIndex(n=>n===this.currentCurve);return e>-1&&this.curves.splice(e,1),t instanceof j?this.curves.push(...t.curves.filter(n=>n.curves.length).map(n=>n.clone())):t.curves.length&&this.curves.push(t),this.curves.push(this.currentCurve),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length&&(this.currentCurve=new ht().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,e){return this.currentCurve.currentPoint?.equals({x:t,y:e})||(this.currentCurve.curves.length&&(this.currentCurve=new ht,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,e)),this}lineTo(t,e){return this.currentCurve.lineTo(t,e),this}bezierCurveTo(t,e,n,r,o,s){return this.currentCurve.bezierCurveTo(t,e,n,r,o,s),this}quadraticCurveTo(t,e,n,r){return this.currentCurve.quadraticCurveTo(t,e,n,r),this}arc(t,e,n,r,o,s){return this.currentCurve.arc(t,e,n,r,o,s),this}arcTo(t,e,n,r,o){return this.currentCurve.arcTo(t,e,n,r,o),this}ellipse(t,e,n,r,o,s,c,a){return this.currentCurve.ellipse(t,e,n,r,o,s,c,a),this}rect(t,e,n,r){return this.currentCurve.rect(t,e,n,r),this}roundRect(t,e,n,r,o){return this.currentCurve.roundRect(t,e,n,r,o),this}reset(){return this.currentCurve=new ht,this.curves=[this.currentCurve],this.style={},this}addCommands(t){return At(t,this),this}addData(t){return this.addCommands(kt(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,e=t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.scale(t,e,n)}),this}skew(t,e=0,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.skew(t,e,n)}),this}rotate(t,e={x:0,y:0}){return this.getControlPointRefs().forEach(n=>{n.rotate(t,e)}),this}bold(t){if(t===0)return this;const e=this.getFlatCurves(),n=[],r=[],o=[];e.forEach((c,a)=>{const h=c.getControlPointRefs(),l=c.isClockwise();o[a]=h,r[a]=l;const y=h[0],f=h[h.length-1]??y;n.push({start:l?f:y,end:l?y:f,index:a})});const s=[];return n.forEach((c,a)=>{s[a]=[],n.forEach((h,l)=>{h.start&&c.end&&l!==a&&h.start?.equals(c.end)&&s[a].push(h.index)})}),e.forEach((c,a)=>{const h=r[a];o[a].forEach(l=>{l.add(c.getNormal(c.getTForPoint(l)).scale(h?t:-t))})}),s.forEach((c,a)=>{const h=o[a];c.forEach(l=>{const y=o[l],f=re(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}getMinMax(t=m.MAX,e=m.MIN,n=!0){const r=this.strokeWidth;return this.curves.forEach(o=>{if(o.getMinMax(t,e),n&&r>1){const s=r/2,c=o.isClockwise(),a=[];for(let h=0;h<=1;h+=1/o.arcLengthDivision){const l=o.getPoint(h),y=o.getNormal(h),f=y.clone().scale(c?s:-s),p=y.clone().scale(c?-s:s);a.push(l.clone().add(f),l.clone().add(p),l.clone().add({x:s,y:0}),l.clone().add({x:-s,y:0}),l.clone().add({x:0,y:s}),l.clone().add({x:0,y:-s}),l.clone().add({x:s,y:s}),l.clone().add({x:-s,y:-s}))}t.min(...a),e.max(...a)}}),{min:t.finite(),max:e.finite()}}strokeTriangulate(t){const e=t?.indices??[],n=t?.vertices??[];return this.curves.forEach(r=>{r.strokeTriangulate({...t,indices:e,vertices:n,style:{...this.style}})}),{indices:e,vertices:n}}fillTriangulate(t){const e={...t,style:{...this.style,...t?.style}},n=e.indices??[],r=e.vertices??[];if((e.style.fillRule??"nonzero")==="nonzero"){const s=this.curves.map(h=>h.getFillVertices(e)),c=ce(s),a=c.length;for(let h=0;h<a;h++){const l=c[h],y=s[h];if(l.wn||!y.length)continue;const f=y.slice(),p=[];for(let u=0;u<a;u++){const x=c[u];x.parentIndex===h&&(p.push(f.length/2),f.push(...s[x.index]))}Lt(f,{...t,indices:n,vertices:r,holes:p,style:{...this.style}})}}else this.curves.forEach(s=>{s.fillTriangulate({...t,indices:n,vertices:r,style:{...this.style}})});return{indices:n,vertices:r}}getBoundingBox(t=!0){const{min:e,max:n}=this.getMinMax(void 0,void 0,t);return new U(e.x,e.y,n.x-e.x,n.y-e.y)}drawTo(t,e={}){e={...this.style,...e};const{fill:n="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.curves.forEach(o=>{o.drawTo(t)}),n!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,e={}){e={...this.style,...e};const{fill:n="#000",stroke:r="none"}=e;return t.beginPath(),t.save(),Ct(t,e),this.getControlPointRefs().forEach(o=>{tt(t,o.x,o.y,{radius:4})}),n!=="none"&&t.fill(),r!=="none"&&t.stroke(),t.restore(),this}toCommands(){return this.curves.flatMap(t=>t.toCommands())}toData(){return this.curves.filter(t=>t.curves.length).map(t=>t.toData()).join(" ")}toSvgPathString(){const t={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},e={};for(const r in t)t[r]!==void 0&&(e[ie(r)]=t[r]);Object.assign(e,{"stroke-width":`${this.strokeWidth}px`});let n="";for(const r in e)e[r]!==void 0&&(n+=`${r}:${e[r]};`);return`<path d="${this.toData()}" style="${n}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class ve{constructor(t=[],e){this.paths=t,this.viewBox=e}getBoundingBox(t=!0){if(!this.paths.length)return;const e=m.MAX,n=m.MIN;return this.paths.forEach(r=>r.getMinMax(e,n,t)),new U(e.x,e.y,n.x-e.x,n.y-e.y)}toTriangulatedSvgString(t=this.paths.map(n=>n.fillTriangulate()),e=0){let n="",r="";const o={x:-e,y:-e},s={x:e,y:e};(Array.isArray(t)?t:[t]).forEach(({vertices:l,indices:y,points:f=[]})=>{const p=u=>{const x=l[u*2],g=l[u*2+1];return o.x=Math.min(o.x,x+e),s.x=Math.max(s.x,x+e),o.y=Math.min(o.y,g+e),s.y=Math.max(s.y,g+e),[x,g]};for(let u=0,x=y.length;u<x;u+=3){const g=p(y[u]),P=p(y[u+1]),C=p(y[u+2]);n+=`<polygon
3
+ points="${g.join(",")} ${P.join(",")} ${C.join(",")}"
4
+ stroke="#28a745"
5
+ stroke-width="#stroke-width"
6
+ fill="rgba(40, 167, 69, 0.15)"
7
+ onmouseover="this.style.fill='rgba(40, 167, 69, 0.5)'"
8
+ onmouseout="this.style.fill='rgba(40, 167, 69, 0.15)'"
9
+ />`}for(let u=0,x=f.length;u<x;u+=2)r+=`<circle
10
+ cx="${f[u]}"
11
+ cy="${f[u+1]}"
12
+ r="#r"
13
+ fill="#dc3545"
14
+ />`});const a=[o.x,o.y,s.x-o.x,s.y-o.y],h=Math.max(a[2],a[3])*.001;return`<svg
15
+ width="${a[2]}"
16
+ height="${a[3]}"
17
+ viewBox="${a.join(" ")}"
18
+ xmlns="http://www.w3.org/2000/svg"
19
+ >
20
+ ${n.replace(/#stroke-width/g,String(h))}
21
+ ${r.replace(/#r/g,String(h))}
22
+ </svg>`}toTriangulatedSvg(t,e){return new DOMParser().parseFromString(this.toTriangulatedSvgString(t,e),"image/svg+xml").documentElement}toSvgString(){const{x:t,y:e,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSvgPathString()).join("");return`<svg
23
+ viewBox="${t} ${e} ${n} ${r}"
24
+ width="${n}px"
25
+ height="${r}px"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ >
28
+ ${o}
29
+ </svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(t={}){const{pixelRatio:e=2,...n}=t,{left:r,top:o,width:s,height:c}=this.getBoundingBox(),a=document.createElement("canvas");a.width=s*e,a.height=c*e,a.style.width=`${s}px`,a.style.height=`${c}px`;const h=a.getContext("2d");return h&&(h.scale(e,e),h.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(h,n)})),a}}class Ln{constructor(t,e,n=1,r=1){this.rows=t,this.cols=e,this.width=n,this.height=r;for(let o=0;o<t;o++){this.controlPoints[o]=[];for(let s=0;s<e;s++)this.controlPoints[o][s]={x:s/(e-1)*n,y:o/(t-1)*r}}}controlPoints=[];moveControlPoint(t,e,n,r){return this.controlPoints[t][e].x+=n,this.controlPoints[t][e].y+=r,this}}function Pe(i){const t=[];return t[0]=(1-i)**3/6,t[1]=(3*i**3-6*i**2+4)/6,t[2]=(-3*i**3+3*i**2+3*i+1)/6,t[3]=i**3/6,t}function Fn(i,t,e=t.width,n=t.height){const r=i.x/e*(t.cols-1),o=i.y/n*(t.rows-1),s=Math.floor(r),c=Math.floor(o),a=r-s,h=o-c,l=Pe(a),y=Pe(h);let f=0,p=0;for(let u=0;u<4;u++)for(let x=0;x<4;x++){const g=Math.min(Math.max(c-1+u,0),t.rows-1),P=Math.min(Math.max(s-1+x,0),t.cols-1),C=t.controlPoints[g][P],w=l[x]*y[u];f+=C.x*w,p+=C.y*w}i.set(f,p)}A.ArcCurve=ge,A.BoundingBox=U,A.CompositeCurve=st,A.CubicBezierCurve=Mt,A.Curve=H,A.CurvePath=ht,A.EllipseCurve=de,A.EquilateralPloygonCurve=$n,A.FFDControlGrid=Ln,A.LineCurve=B,A.Matrix3=z,A.Path2D=j,A.Path2DSet=ve,A.PloygonCurve=Vt,A.QuadraticBezierCurve=wt,A.RectangleCurve=me,A.RoundRectangleCurve=Me,A.SplineCurve=we,A.Vector2=m,A.applyFFD=Fn,A.catmullRom=St,A.cubicBezier=_t,A.drawPoint=tt,A.fillTriangulate=Lt,A.getAdaptiveCubicBezierCurvePoints=ne,A.getAdaptiveQuadraticBezierCurvePoints=se,A.getDirectedArea=mn,A.getIntersectionPoint=re,A.nonzeroFillRule=ce,A.parseArcCommand=Ot,A.parsePathDataArgs=O,A.quadraticBezier=Dt,A.setCanvasContext=Ct,A.strokeTriangulate=ae,A.svgPathCommandsAddToPath2D=At,A.svgPathCommandsToData=Bt,A.svgPathDataToCommands=kt,A.svgToDom=Xt,A.svgToPath2DSet=Ze,A.toKebabCase=ie,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})}));
package/dist/index.mjs CHANGED
@@ -1777,37 +1777,50 @@ function windingNumber(px, py, path) {
1777
1777
  }
1778
1778
  return wn;
1779
1779
  }
1780
+ function distance(p1, p2) {
1781
+ const dx = p2[0] - p1[0];
1782
+ const dy = p2[1] - p1[1];
1783
+ return Math.sqrt(dx * dx + dy * dy);
1784
+ }
1780
1785
  function nonzeroFillRule(paths) {
1781
1786
  const pathsLen = paths.length;
1782
- const results = paths.map((_, i) => ({ index: i, parentIndex: null, wn: 0 }));
1787
+ const results = paths.map((_, i) => ({
1788
+ index: i,
1789
+ dist: 0,
1790
+ wn: 0,
1791
+ parentIndex: void 0
1792
+ }));
1783
1793
  for (let i = 0; i < pathsLen; i++) {
1784
- let best = null;
1785
1794
  if (signedArea(paths[i]) < 0) {
1786
1795
  continue;
1787
1796
  }
1788
- const points = [
1789
- paths[i][0],
1790
- paths[i][1]
1797
+ const firstPoint = paths[i];
1798
+ const testPointArray = [
1799
+ ...firstPoint
1791
1800
  ];
1801
+ let parent;
1792
1802
  for (let j = 0; j < pathsLen; j++) {
1793
1803
  if (i === j) {
1794
1804
  continue;
1795
1805
  }
1796
- let wn0 = 0;
1797
- for (let p = 0; p < points.length; p += 2) {
1798
- wn0 = wn0 || windingNumber(points[p], points[p + 1], paths[j]);
1799
- if (wn0) {
1806
+ let wn = 0;
1807
+ for (let p = 0; p < testPointArray.length; p += 2) {
1808
+ wn = wn || windingNumber(testPointArray[p], testPointArray[p + 1], paths[j]);
1809
+ if (wn) {
1800
1810
  break;
1801
1811
  }
1802
1812
  }
1803
- const absWn = Math.abs(wn0);
1804
- if (absWn !== 0 && (!best || absWn > Math.abs(best.wn))) {
1805
- best = { idx: j, wn: wn0 };
1813
+ if (Math.abs(wn) > 0) {
1814
+ const dist = distance(firstPoint, paths[j]);
1815
+ if (!parent || dist < parent.dist) {
1816
+ parent = { index: j, dist, wn };
1817
+ }
1806
1818
  }
1807
1819
  }
1808
- if (best) {
1809
- results[i].parentIndex = best.idx;
1810
- results[i].wn = best.wn;
1820
+ if (parent) {
1821
+ results[i].dist = parent.dist;
1822
+ results[i].wn = parent.wn;
1823
+ results[i].parentIndex = parent.index;
1811
1824
  }
1812
1825
  }
1813
1826
  return results;
@@ -3704,6 +3717,7 @@ class CurvePath extends CompositeCurve {
3704
3717
  }
3705
3718
 
3706
3719
  class Path2D extends CompositeCurve {
3720
+ _meta;
3707
3721
  currentCurve = new CurvePath();
3708
3722
  style;
3709
3723
  get startPoint() {
@@ -3729,6 +3743,13 @@ class Path2D extends CompositeCurve {
3729
3743
  }
3730
3744
  }
3731
3745
  }
3746
+ getMeta() {
3747
+ return this._meta;
3748
+ }
3749
+ setMeta(meta) {
3750
+ this._meta = meta;
3751
+ return this;
3752
+ }
3732
3753
  addPath(path) {
3733
3754
  const index = this.curves.findIndex((v) => v === this.currentCurve);
3734
3755
  if (index > -1) {
@@ -4079,10 +4100,11 @@ class Path2DSet {
4079
4100
  }
4080
4101
  toTriangulatedSvgString(result = this.paths.map((p) => p.fillTriangulate()), padding = 0) {
4081
4102
  let polygonStr = "";
4103
+ let pointStr = "";
4082
4104
  const min = { x: -padding, y: -padding };
4083
4105
  const max = { x: padding, y: padding };
4084
4106
  const results = Array.isArray(result) ? result : [result];
4085
- results.forEach(({ vertices, indices }) => {
4107
+ results.forEach(({ vertices, indices, points = [] }) => {
4086
4108
  const getPoint = (indice) => {
4087
4109
  const x = vertices[indice * 2];
4088
4110
  const y = vertices[indice * 2 + 1];
@@ -4096,11 +4118,35 @@ class Path2DSet {
4096
4118
  const p1 = getPoint(indices[i]);
4097
4119
  const p2 = getPoint(indices[i + 1]);
4098
4120
  const p3 = getPoint(indices[i + 2]);
4099
- polygonStr += `<polygon points="${p1.join(",")} ${p2.join(",")} ${p3.join(",")}" stroke="none" fill="black" />`;
4121
+ polygonStr += `<polygon
4122
+ points="${p1.join(",")} ${p2.join(",")} ${p3.join(",")}"
4123
+ stroke="#28a745"
4124
+ stroke-width="#stroke-width"
4125
+ fill="rgba(40, 167, 69, 0.15)"
4126
+ onmouseover="this.style.fill='rgba(40, 167, 69, 0.5)'"
4127
+ onmouseout="this.style.fill='rgba(40, 167, 69, 0.15)'"
4128
+ />`;
4129
+ }
4130
+ for (let i = 0, len = points.length; i < len; i += 2) {
4131
+ pointStr += `<circle
4132
+ cx="${points[i]}"
4133
+ cy="${points[i + 1]}"
4134
+ r="#r"
4135
+ fill="#dc3545"
4136
+ />`;
4100
4137
  }
4101
4138
  });
4102
4139
  const viewBox = [min.x, min.y, max.x - min.x, max.y - min.y];
4103
- return `<svg width="${viewBox[2]}" height="${viewBox[3]}" viewBox="${viewBox.join(" ")}" xmlns="http://www.w3.org/2000/svg">${polygonStr}</svg>`;
4140
+ const strokeWidth = Math.max(viewBox[2], viewBox[3]) * 1e-3;
4141
+ return `<svg
4142
+ width="${viewBox[2]}"
4143
+ height="${viewBox[3]}"
4144
+ viewBox="${viewBox.join(" ")}"
4145
+ xmlns="http://www.w3.org/2000/svg"
4146
+ >
4147
+ ${polygonStr.replace(/#stroke-width/g, String(strokeWidth))}
4148
+ ${pointStr.replace(/#r/g, String(strokeWidth))}
4149
+ </svg>`;
4104
4150
  }
4105
4151
  toTriangulatedSvg(result, padding) {
4106
4152
  return new DOMParser().parseFromString(this.toTriangulatedSvgString(result, padding), "image/svg+xml").documentElement;
@@ -4108,7 +4154,14 @@ class Path2DSet {
4108
4154
  toSvgString() {
4109
4155
  const { x, y, width, height } = this.getBoundingBox();
4110
4156
  const content = this.paths.map((path) => path.toSvgPathString()).join("");
4111
- return `<svg viewBox="${x} ${y} ${width} ${height}" width="${width}px" height="${height}px" xmlns="http://www.w3.org/2000/svg">${content}</svg>`;
4157
+ return `<svg
4158
+ viewBox="${x} ${y} ${width} ${height}"
4159
+ width="${width}px"
4160
+ height="${height}px"
4161
+ xmlns="http://www.w3.org/2000/svg"
4162
+ >
4163
+ ${content}
4164
+ </svg>`;
4112
4165
  }
4113
4166
  toSvgUrl() {
4114
4167
  return `data:image/svg+xml;base64,${btoa(this.toSvgString())}`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "1.4.8",
4
+ "version": "1.4.10",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A Path2D library, fully compatible with Web Path2D, with additional support for triangulate、animation、deformation etc.",
7
7
  "author": "wxm",
@@ -59,17 +59,17 @@
59
59
  "earcut": "^3.0.2"
60
60
  },
61
61
  "devDependencies": {
62
- "@antfu/eslint-config": "^4.17.0",
62
+ "@antfu/eslint-config": "^5.4.1",
63
63
  "@types/earcut": "^3.0.0",
64
- "@types/node": "^24.1.0",
65
- "bumpp": "^10.2.0",
64
+ "@types/node": "^24.5.2",
65
+ "bumpp": "^10.2.3",
66
66
  "conventional-changelog-cli": "^5.0.0",
67
- "eslint": "^9.31.0",
68
- "lint-staged": "^16.1.2",
69
- "simple-git-hooks": "^2.13.0",
70
- "typescript": "^5.8.3",
71
- "unbuild": "^3.5.0",
72
- "vite": "^7.0.5",
67
+ "eslint": "^9.36.0",
68
+ "lint-staged": "^16.2.0",
69
+ "simple-git-hooks": "^2.13.1",
70
+ "typescript": "^5.9.2",
71
+ "unbuild": "^3.6.1",
72
+ "vite": "^7.1.7",
73
73
  "vitest": "^3.2.4"
74
74
  },
75
75
  "simple-git-hooks": {