modern-path2d 1.2.1 → 1.2.3

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
@@ -1579,8 +1579,6 @@ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
1579
1579
  }
1580
1580
 
1581
1581
  class Curve {
1582
- startT = 0;
1583
- endT = 1;
1584
1582
  arcLengthDivision = 200;
1585
1583
  _arcLengths;
1586
1584
  getPointAt(u, output = new Vector2()) {
@@ -1757,19 +1755,13 @@ class Curve {
1757
1755
  }
1758
1756
  fillTriangulate(options) {
1759
1757
  return fillTriangulate(
1760
- this.getPoints().reduce((arr, p) => {
1761
- arr.push(p.x, p.y);
1762
- return arr;
1763
- }, []),
1758
+ this.getAdaptivePointArray(),
1764
1759
  options
1765
1760
  );
1766
1761
  }
1767
1762
  strokeTriangulate(options) {
1768
1763
  return strokeTriangulate(
1769
- this.getPoints().reduce((arr, p) => {
1770
- arr.push(p.x, p.y);
1771
- return arr;
1772
- }, []),
1764
+ this.getAdaptivePointArray(),
1773
1765
  options
1774
1766
  );
1775
1767
  }
@@ -1816,7 +1808,7 @@ const tempTransform1$1 = new Matrix3();
1816
1808
  const tempTransform2$1 = new Matrix3();
1817
1809
  const tempV2 = new Vector2();
1818
1810
  class RoundCurve extends Curve {
1819
- constructor(_center, _radius, _diff, rotate = 0, startAngle = 0, endAngle = Math.PI * 2, clockwise = false) {
1811
+ constructor(_center = new Vector2(), _radius = new Vector2(), _diff = new Vector2(), rotate = 0, startAngle = 0, endAngle = Math.PI * 2, clockwise = false) {
1820
1812
  super();
1821
1813
  this._center = _center;
1822
1814
  this._radius = _radius;
@@ -2091,6 +2083,8 @@ class RoundCurve extends Curve {
2091
2083
  this.cy = source.cy;
2092
2084
  this.rx = source.rx;
2093
2085
  this.ry = source.ry;
2086
+ this.dx = source.dx;
2087
+ this.dy = source.dy;
2094
2088
  this.startAngle = source.startAngle;
2095
2089
  this.endAngle = source.endAngle;
2096
2090
  this.clockwise = source.clockwise;
@@ -2249,14 +2243,13 @@ class ArcCurve extends RoundCurve {
2249
2243
  endAngle,
2250
2244
  clockwise
2251
2245
  );
2252
- this.radius = radius;
2253
2246
  }
2254
2247
  drawTo(ctx) {
2255
- const { cx, cy, radius, startAngle, endAngle, clockwise } = this;
2248
+ const { cx, cy, rx, startAngle, endAngle, clockwise } = this;
2256
2249
  ctx.arc(
2257
2250
  cx,
2258
2251
  cy,
2259
- radius,
2252
+ rx,
2260
2253
  startAngle,
2261
2254
  endAngle,
2262
2255
  !clockwise
@@ -2264,14 +2257,14 @@ class ArcCurve extends RoundCurve {
2264
2257
  return this;
2265
2258
  }
2266
2259
  getAdaptivePointArray(output = []) {
2267
- const { cx, cy, radius, startAngle, endAngle, clockwise } = this;
2260
+ const { cx, cy, rx, startAngle, endAngle, clockwise } = this;
2268
2261
  let dist = Math.abs(startAngle - endAngle);
2269
2262
  if (!clockwise && startAngle > endAngle) {
2270
2263
  dist = 2 * Math.PI - dist;
2271
2264
  } else if (clockwise && endAngle > startAngle) {
2272
2265
  dist = 2 * Math.PI - dist;
2273
2266
  }
2274
- let steps = Math.max(6, Math.floor(6 * radius ** (1 / 3) * (dist / Math.PI)));
2267
+ let steps = Math.max(6, Math.floor(6 * rx ** (1 / 3) * (dist / Math.PI)));
2275
2268
  steps = Math.max(steps, 3);
2276
2269
  let f = dist / steps;
2277
2270
  let t = startAngle;
@@ -2279,8 +2272,8 @@ class ArcCurve extends RoundCurve {
2279
2272
  for (let i = 0; i < steps + 1; i++) {
2280
2273
  const cs = Math.cos(t);
2281
2274
  const sn = Math.sin(t);
2282
- const nx = cx + cs * radius;
2283
- const ny = cy + sn * radius;
2275
+ const nx = cx + cs * rx;
2276
+ const ny = cy + sn * rx;
2284
2277
  output.push(nx, ny);
2285
2278
  t += f;
2286
2279
  }
@@ -2358,10 +2351,15 @@ class CompositeCurve extends Curve {
2358
2351
  this.curves.forEach((curve) => curve.drawTo(ctx));
2359
2352
  return this;
2360
2353
  }
2354
+ copy(source) {
2355
+ super.copy(source);
2356
+ this.curves = source.curves.map((curve) => curve.clone());
2357
+ return this;
2358
+ }
2361
2359
  }
2362
2360
 
2363
2361
  class CubicBezierCurve extends Curve {
2364
- constructor(p1, cp1, cp2, p2) {
2362
+ constructor(p1 = new Vector2(), cp1 = new Vector2(), cp2 = new Vector2(), p2 = new Vector2()) {
2365
2363
  super();
2366
2364
  this.p1 = p1;
2367
2365
  this.cp1 = cp1;
@@ -2489,7 +2487,7 @@ class EllipseCurve extends RoundCurve {
2489
2487
  }
2490
2488
 
2491
2489
  class LineCurve extends Curve {
2492
- constructor(p1, p2) {
2490
+ constructor(p1 = new Vector2(), p2 = new Vector2()) {
2493
2491
  super();
2494
2492
  this.p1 = p1;
2495
2493
  this.p2 = p2;
@@ -2564,6 +2562,15 @@ class PloygonCurve extends CompositeCurve {
2564
2562
 
2565
2563
  class EquilateralPloygonCurve extends PloygonCurve {
2566
2564
  constructor(cx = 0, cy = 0, radius = 1, sideCount = 3) {
2565
+ super();
2566
+ this.cx = cx;
2567
+ this.cy = cy;
2568
+ this.radius = radius;
2569
+ this.sideCount = sideCount;
2570
+ this.update();
2571
+ }
2572
+ update() {
2573
+ const { cx, cy, radius, sideCount } = this;
2567
2574
  const points = [];
2568
2575
  for (let i = 0; i < sideCount; i++) {
2569
2576
  const radian = i * 2 * Math.PI / sideCount - 0.5 * Math.PI;
@@ -2583,16 +2590,22 @@ class EquilateralPloygonCurve extends PloygonCurve {
2583
2590
  )
2584
2591
  );
2585
2592
  }
2586
- super(curves);
2587
- this.cx = cx;
2588
- this.cy = cy;
2589
- this.radius = radius;
2590
- this.sideCount = sideCount;
2593
+ this.curves = curves;
2594
+ return this;
2595
+ }
2596
+ copy(source) {
2597
+ super.copy(source);
2598
+ this.cx = source.cx;
2599
+ this.cy = source.cy;
2600
+ this.radius = source.radius;
2601
+ this.sideCount = source.sideCount;
2602
+ this.update();
2603
+ return this;
2591
2604
  }
2592
2605
  }
2593
2606
 
2594
2607
  class QuadraticBezierCurve extends Curve {
2595
- constructor(p1, cp, p2) {
2608
+ constructor(p1 = new Vector2(), cp = new Vector2(), p2 = new Vector2()) {
2596
2609
  super();
2597
2610
  this.p1 = p1;
2598
2611
  this.cp = cp;
@@ -2664,22 +2677,28 @@ class QuadraticBezierCurve extends Curve {
2664
2677
 
2665
2678
  class RectangleCurve extends PloygonCurve {
2666
2679
  constructor(x = 0, y = 0, width = 0, height = 0) {
2680
+ super();
2681
+ this.x = x;
2682
+ this.y = y;
2683
+ this.width = width;
2684
+ this.height = height;
2685
+ this.update();
2686
+ }
2687
+ update() {
2688
+ const { x, y, width, height } = this;
2667
2689
  const points = [
2668
2690
  new Vector2(x, y),
2669
2691
  new Vector2(x + width, y),
2670
2692
  new Vector2(x + width, y + height),
2671
2693
  new Vector2(x, y + height)
2672
2694
  ];
2673
- super([
2695
+ this.curves = [
2674
2696
  new LineCurve(points[0], points[1]),
2675
2697
  new LineCurve(points[1], points[2]),
2676
2698
  new LineCurve(points[2], points[3]),
2677
2699
  new LineCurve(points[3], points[0])
2678
- ]);
2679
- this.x = x;
2680
- this.y = y;
2681
- this.width = width;
2682
- this.height = height;
2700
+ ];
2701
+ return this;
2683
2702
  }
2684
2703
  drawTo(ctx) {
2685
2704
  ctx.rect(this.x, this.y, this.width, this.height);
@@ -2727,10 +2746,29 @@ class RectangleCurve extends PloygonCurve {
2727
2746
  indices[indicesOffset++] = verticesIndex + 2;
2728
2747
  return { vertices, indices };
2729
2748
  }
2749
+ copy(source) {
2750
+ super.copy(source);
2751
+ this.x = source.x;
2752
+ this.y = source.y;
2753
+ this.width = source.width;
2754
+ this.height = source.height;
2755
+ this.update();
2756
+ return this;
2757
+ }
2730
2758
  }
2731
2759
 
2732
2760
  class RoundRectangleCurve extends RoundCurve {
2733
2761
  constructor(x = 0, y = 0, width = 1, height = 1, radius = 1) {
2762
+ super();
2763
+ this.x = x;
2764
+ this.y = y;
2765
+ this.width = width;
2766
+ this.height = height;
2767
+ this.radius = radius;
2768
+ this.update();
2769
+ }
2770
+ update() {
2771
+ const { x, y, width, height, radius } = this;
2734
2772
  const halfWidth = width / 2;
2735
2773
  const halfHeight = height / 2;
2736
2774
  const cx = x + halfWidth;
@@ -2739,22 +2777,26 @@ class RoundRectangleCurve extends RoundCurve {
2739
2777
  const ry = rx;
2740
2778
  const dx = halfWidth - rx;
2741
2779
  const dy = halfHeight - ry;
2742
- super(
2743
- new Vector2(cx, cy),
2744
- new Vector2(rx, ry),
2745
- new Vector2(dx, dy)
2746
- );
2747
- this.x = x;
2748
- this.y = y;
2749
- this.width = width;
2750
- this.height = height;
2751
- this.radius = radius;
2780
+ this._center = new Vector2(cx, cy);
2781
+ this._radius = new Vector2(rx, ry);
2782
+ this._diff = new Vector2(dx, dy);
2783
+ return this;
2752
2784
  }
2753
2785
  drawTo(ctx) {
2754
2786
  const { x, y, width, height, radius } = this;
2755
2787
  ctx.roundRect(x, y, width, height, radius);
2756
2788
  return this;
2757
2789
  }
2790
+ copy(source) {
2791
+ super.copy(source);
2792
+ this.x = source.x;
2793
+ this.y = source.y;
2794
+ this.width = source.width;
2795
+ this.height = source.height;
2796
+ this.radius = source.radius;
2797
+ this.update();
2798
+ return this;
2799
+ }
2758
2800
  }
2759
2801
 
2760
2802
  class SplineCurve extends Curve {
@@ -2995,10 +3037,6 @@ class CurvePath extends CompositeCurve {
2995
3037
  }
2996
3038
  copy(source) {
2997
3039
  super.copy(source);
2998
- this.curves = [];
2999
- for (let i = 0, len = source.curves.length; i < len; i++) {
3000
- this.curves.push(source.curves[i].clone());
3001
- }
3002
3040
  this.autoClose = source.autoClose;
3003
3041
  this.currentPoint = source.currentPoint?.clone();
3004
3042
  return this;
@@ -3119,6 +3157,12 @@ class Path2D extends CompositeCurve {
3119
3157
  this.currentCurve.roundRect(x, y, width, height, radii);
3120
3158
  return this;
3121
3159
  }
3160
+ reset() {
3161
+ this.currentCurve = new CurvePath();
3162
+ this.curves.push(this.currentCurve);
3163
+ this.style = {};
3164
+ return this;
3165
+ }
3122
3166
  addCommands(commands) {
3123
3167
  svgPathCommandsAddToPath2D(commands, this);
3124
3168
  return this;
@@ -3316,14 +3360,11 @@ class Path2D extends CompositeCurve {
3316
3360
  return `<path d="${this.toData()}" style="${cssText}"></path>`;
3317
3361
  }
3318
3362
  copy(source) {
3363
+ super.copy(source);
3319
3364
  this.currentCurve = source.currentCurve.clone();
3320
- this.curves = source.curves.map((path) => path.clone());
3321
3365
  this.style = { ...source.style };
3322
3366
  return this;
3323
3367
  }
3324
- clone() {
3325
- return new this.constructor().copy(this);
3326
- }
3327
3368
  }
3328
3369
 
3329
3370
  class Path2DSet {
package/dist/index.d.cts CHANGED
@@ -130,8 +130,6 @@ declare class BoundingBox {
130
130
  }
131
131
 
132
132
  declare abstract class Curve {
133
- startT: number;
134
- endT: number;
135
133
  arcLengthDivision: number;
136
134
  protected _arcLengths?: number[];
137
135
  abstract getPoint(t: number, output?: Vector2): Vector2;
@@ -190,7 +188,7 @@ declare class RoundCurve extends Curve {
190
188
  set dx(val: number);
191
189
  get dy(): number;
192
190
  set dy(val: number);
193
- constructor(_center: Vector2, _radius: Vector2, _diff: Vector2, rotate?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
191
+ constructor(_center?: Vector2, _radius?: Vector2, _diff?: Vector2, rotate?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
194
192
  isClockwise(): boolean;
195
193
  getPoint(t: number, output?: Vector2): Vector2;
196
194
  toCommands(): Path2DCommand[];
@@ -207,7 +205,6 @@ declare class RoundCurve extends Curve {
207
205
  }
208
206
 
209
207
  declare class ArcCurve extends RoundCurve {
210
- readonly radius: number;
211
208
  constructor(cx?: number, cy?: number, radius?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
212
209
  drawTo(ctx: CanvasRenderingContext2D): this;
213
210
  getAdaptivePointArray(output?: number[]): number[];
@@ -228,6 +225,7 @@ declare class CompositeCurve<T extends Curve = Curve> extends Curve {
228
225
  getBoundingBox(): BoundingBox;
229
226
  toCommands(): Path2DCommand[];
230
227
  drawTo(ctx: CanvasRenderingContext2D): this;
228
+ copy(source: CompositeCurve<T>): this;
231
229
  }
232
230
 
233
231
  declare class CubicBezierCurve extends Curve {
@@ -236,7 +234,7 @@ declare class CubicBezierCurve extends Curve {
236
234
  cp2: Vector2;
237
235
  p2: Vector2;
238
236
  static from(p1x: number, p1y: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, p2x: number, p2y: number): CubicBezierCurve;
239
- constructor(p1: Vector2, cp1: Vector2, cp2: Vector2, p2: Vector2);
237
+ constructor(p1?: Vector2, cp1?: Vector2, cp2?: Vector2, p2?: Vector2);
240
238
  getPoint(t: number, output?: Vector2): Vector2;
241
239
  getAdaptivePointArray(output?: number[]): number[];
242
240
  getControlPointRefs(): Vector2[];
@@ -259,7 +257,7 @@ declare class LineCurve extends Curve {
259
257
  p1: Vector2;
260
258
  p2: Vector2;
261
259
  static from(p1x: number, p1y: number, p2x: number, p2y: number): LineCurve;
262
- constructor(p1: Vector2, p2: Vector2);
260
+ constructor(p1?: Vector2, p2?: Vector2);
263
261
  getPoint(t: number, output?: Vector2): Vector2;
264
262
  getPointAt(u: number, output?: Vector2): Vector2;
265
263
  getTangent(_t: number, output?: Vector2): Vector2;
@@ -279,11 +277,13 @@ declare class PloygonCurve extends CompositeCurve<LineCurve> {
279
277
  }
280
278
 
281
279
  declare class EquilateralPloygonCurve extends PloygonCurve {
282
- readonly cx: number;
283
- readonly cy: number;
284
- readonly radius: number;
285
- readonly sideCount: number;
280
+ cx: number;
281
+ cy: number;
282
+ radius: number;
283
+ sideCount: number;
286
284
  constructor(cx?: number, cy?: number, radius?: number, sideCount?: number);
285
+ update(): this;
286
+ copy(source: EquilateralPloygonCurve): this;
287
287
  }
288
288
 
289
289
  declare class QuadraticBezierCurve extends Curve {
@@ -291,7 +291,7 @@ declare class QuadraticBezierCurve extends Curve {
291
291
  cp: Vector2;
292
292
  p2: Vector2;
293
293
  static from(p1x: number, p1y: number, cpx: number, cpy: number, p2x: number, p2y: number): QuadraticBezierCurve;
294
- constructor(p1: Vector2, cp: Vector2, p2: Vector2);
294
+ constructor(p1?: Vector2, cp?: Vector2, p2?: Vector2);
295
295
  getPoint(t: number, output?: Vector2): Vector2;
296
296
  getControlPointRefs(): Vector2[];
297
297
  getAdaptivePointArray(output?: number[]): number[];
@@ -305,23 +305,27 @@ declare class QuadraticBezierCurve extends Curve {
305
305
  }
306
306
 
307
307
  declare class RectangleCurve extends PloygonCurve {
308
- readonly x: number;
309
- readonly y: number;
310
- readonly width: number;
311
- readonly height: number;
308
+ x: number;
309
+ y: number;
310
+ width: number;
311
+ height: number;
312
312
  constructor(x?: number, y?: number, width?: number, height?: number);
313
+ update(): this;
313
314
  drawTo(ctx: CanvasRenderingContext2D): this;
314
315
  fillTriangulate(options?: FillTriangulateOptions): FillTriangulateResult;
316
+ copy(source: RectangleCurve): this;
315
317
  }
316
318
 
317
319
  declare class RoundRectangleCurve extends RoundCurve {
318
- readonly x: number;
319
- readonly y: number;
320
- readonly width: number;
321
- readonly height: number;
322
- readonly radius: number;
320
+ x: number;
321
+ y: number;
322
+ width: number;
323
+ height: number;
324
+ radius: number;
323
325
  constructor(x?: number, y?: number, width?: number, height?: number, radius?: number);
326
+ update(): this;
324
327
  drawTo(ctx: CanvasRenderingContext2D): this;
328
+ copy(source: RoundRectangleCurve): this;
325
329
  }
326
330
 
327
331
  declare class SplineCurve extends Curve {
@@ -469,6 +473,7 @@ declare class Path2D extends CompositeCurve<CurvePath> {
469
473
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
470
474
  rect(x: number, y: number, width: number, height: number): this;
471
475
  roundRect(x: number, y: number, width: number, height: number, radii: number): this;
476
+ reset(): this;
472
477
  addCommands(commands: Path2DCommand[]): this;
473
478
  addData(data: Path2DData): this;
474
479
  splineThru(points: Vector2[]): this;
@@ -488,7 +493,6 @@ declare class Path2D extends CompositeCurve<CurvePath> {
488
493
  toData(): Path2DData;
489
494
  toSVGPathString(): string;
490
495
  copy(source: Path2D): this;
491
- clone(): this;
492
496
  }
493
497
 
494
498
  declare class Path2DSet {
package/dist/index.d.mts CHANGED
@@ -130,8 +130,6 @@ declare class BoundingBox {
130
130
  }
131
131
 
132
132
  declare abstract class Curve {
133
- startT: number;
134
- endT: number;
135
133
  arcLengthDivision: number;
136
134
  protected _arcLengths?: number[];
137
135
  abstract getPoint(t: number, output?: Vector2): Vector2;
@@ -190,7 +188,7 @@ declare class RoundCurve extends Curve {
190
188
  set dx(val: number);
191
189
  get dy(): number;
192
190
  set dy(val: number);
193
- constructor(_center: Vector2, _radius: Vector2, _diff: Vector2, rotate?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
191
+ constructor(_center?: Vector2, _radius?: Vector2, _diff?: Vector2, rotate?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
194
192
  isClockwise(): boolean;
195
193
  getPoint(t: number, output?: Vector2): Vector2;
196
194
  toCommands(): Path2DCommand[];
@@ -207,7 +205,6 @@ declare class RoundCurve extends Curve {
207
205
  }
208
206
 
209
207
  declare class ArcCurve extends RoundCurve {
210
- readonly radius: number;
211
208
  constructor(cx?: number, cy?: number, radius?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
212
209
  drawTo(ctx: CanvasRenderingContext2D): this;
213
210
  getAdaptivePointArray(output?: number[]): number[];
@@ -228,6 +225,7 @@ declare class CompositeCurve<T extends Curve = Curve> extends Curve {
228
225
  getBoundingBox(): BoundingBox;
229
226
  toCommands(): Path2DCommand[];
230
227
  drawTo(ctx: CanvasRenderingContext2D): this;
228
+ copy(source: CompositeCurve<T>): this;
231
229
  }
232
230
 
233
231
  declare class CubicBezierCurve extends Curve {
@@ -236,7 +234,7 @@ declare class CubicBezierCurve extends Curve {
236
234
  cp2: Vector2;
237
235
  p2: Vector2;
238
236
  static from(p1x: number, p1y: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, p2x: number, p2y: number): CubicBezierCurve;
239
- constructor(p1: Vector2, cp1: Vector2, cp2: Vector2, p2: Vector2);
237
+ constructor(p1?: Vector2, cp1?: Vector2, cp2?: Vector2, p2?: Vector2);
240
238
  getPoint(t: number, output?: Vector2): Vector2;
241
239
  getAdaptivePointArray(output?: number[]): number[];
242
240
  getControlPointRefs(): Vector2[];
@@ -259,7 +257,7 @@ declare class LineCurve extends Curve {
259
257
  p1: Vector2;
260
258
  p2: Vector2;
261
259
  static from(p1x: number, p1y: number, p2x: number, p2y: number): LineCurve;
262
- constructor(p1: Vector2, p2: Vector2);
260
+ constructor(p1?: Vector2, p2?: Vector2);
263
261
  getPoint(t: number, output?: Vector2): Vector2;
264
262
  getPointAt(u: number, output?: Vector2): Vector2;
265
263
  getTangent(_t: number, output?: Vector2): Vector2;
@@ -279,11 +277,13 @@ declare class PloygonCurve extends CompositeCurve<LineCurve> {
279
277
  }
280
278
 
281
279
  declare class EquilateralPloygonCurve extends PloygonCurve {
282
- readonly cx: number;
283
- readonly cy: number;
284
- readonly radius: number;
285
- readonly sideCount: number;
280
+ cx: number;
281
+ cy: number;
282
+ radius: number;
283
+ sideCount: number;
286
284
  constructor(cx?: number, cy?: number, radius?: number, sideCount?: number);
285
+ update(): this;
286
+ copy(source: EquilateralPloygonCurve): this;
287
287
  }
288
288
 
289
289
  declare class QuadraticBezierCurve extends Curve {
@@ -291,7 +291,7 @@ declare class QuadraticBezierCurve extends Curve {
291
291
  cp: Vector2;
292
292
  p2: Vector2;
293
293
  static from(p1x: number, p1y: number, cpx: number, cpy: number, p2x: number, p2y: number): QuadraticBezierCurve;
294
- constructor(p1: Vector2, cp: Vector2, p2: Vector2);
294
+ constructor(p1?: Vector2, cp?: Vector2, p2?: Vector2);
295
295
  getPoint(t: number, output?: Vector2): Vector2;
296
296
  getControlPointRefs(): Vector2[];
297
297
  getAdaptivePointArray(output?: number[]): number[];
@@ -305,23 +305,27 @@ declare class QuadraticBezierCurve extends Curve {
305
305
  }
306
306
 
307
307
  declare class RectangleCurve extends PloygonCurve {
308
- readonly x: number;
309
- readonly y: number;
310
- readonly width: number;
311
- readonly height: number;
308
+ x: number;
309
+ y: number;
310
+ width: number;
311
+ height: number;
312
312
  constructor(x?: number, y?: number, width?: number, height?: number);
313
+ update(): this;
313
314
  drawTo(ctx: CanvasRenderingContext2D): this;
314
315
  fillTriangulate(options?: FillTriangulateOptions): FillTriangulateResult;
316
+ copy(source: RectangleCurve): this;
315
317
  }
316
318
 
317
319
  declare class RoundRectangleCurve extends RoundCurve {
318
- readonly x: number;
319
- readonly y: number;
320
- readonly width: number;
321
- readonly height: number;
322
- readonly radius: number;
320
+ x: number;
321
+ y: number;
322
+ width: number;
323
+ height: number;
324
+ radius: number;
323
325
  constructor(x?: number, y?: number, width?: number, height?: number, radius?: number);
326
+ update(): this;
324
327
  drawTo(ctx: CanvasRenderingContext2D): this;
328
+ copy(source: RoundRectangleCurve): this;
325
329
  }
326
330
 
327
331
  declare class SplineCurve extends Curve {
@@ -469,6 +473,7 @@ declare class Path2D extends CompositeCurve<CurvePath> {
469
473
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
470
474
  rect(x: number, y: number, width: number, height: number): this;
471
475
  roundRect(x: number, y: number, width: number, height: number, radii: number): this;
476
+ reset(): this;
472
477
  addCommands(commands: Path2DCommand[]): this;
473
478
  addData(data: Path2DData): this;
474
479
  splineThru(points: Vector2[]): this;
@@ -488,7 +493,6 @@ declare class Path2D extends CompositeCurve<CurvePath> {
488
493
  toData(): Path2DData;
489
494
  toSVGPathString(): string;
490
495
  copy(source: Path2D): this;
491
- clone(): this;
492
496
  }
493
497
 
494
498
  declare class Path2DSet {
package/dist/index.d.ts CHANGED
@@ -130,8 +130,6 @@ declare class BoundingBox {
130
130
  }
131
131
 
132
132
  declare abstract class Curve {
133
- startT: number;
134
- endT: number;
135
133
  arcLengthDivision: number;
136
134
  protected _arcLengths?: number[];
137
135
  abstract getPoint(t: number, output?: Vector2): Vector2;
@@ -190,7 +188,7 @@ declare class RoundCurve extends Curve {
190
188
  set dx(val: number);
191
189
  get dy(): number;
192
190
  set dy(val: number);
193
- constructor(_center: Vector2, _radius: Vector2, _diff: Vector2, rotate?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
191
+ constructor(_center?: Vector2, _radius?: Vector2, _diff?: Vector2, rotate?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
194
192
  isClockwise(): boolean;
195
193
  getPoint(t: number, output?: Vector2): Vector2;
196
194
  toCommands(): Path2DCommand[];
@@ -207,7 +205,6 @@ declare class RoundCurve extends Curve {
207
205
  }
208
206
 
209
207
  declare class ArcCurve extends RoundCurve {
210
- readonly radius: number;
211
208
  constructor(cx?: number, cy?: number, radius?: number, startAngle?: number, endAngle?: number, clockwise?: boolean);
212
209
  drawTo(ctx: CanvasRenderingContext2D): this;
213
210
  getAdaptivePointArray(output?: number[]): number[];
@@ -228,6 +225,7 @@ declare class CompositeCurve<T extends Curve = Curve> extends Curve {
228
225
  getBoundingBox(): BoundingBox;
229
226
  toCommands(): Path2DCommand[];
230
227
  drawTo(ctx: CanvasRenderingContext2D): this;
228
+ copy(source: CompositeCurve<T>): this;
231
229
  }
232
230
 
233
231
  declare class CubicBezierCurve extends Curve {
@@ -236,7 +234,7 @@ declare class CubicBezierCurve extends Curve {
236
234
  cp2: Vector2;
237
235
  p2: Vector2;
238
236
  static from(p1x: number, p1y: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, p2x: number, p2y: number): CubicBezierCurve;
239
- constructor(p1: Vector2, cp1: Vector2, cp2: Vector2, p2: Vector2);
237
+ constructor(p1?: Vector2, cp1?: Vector2, cp2?: Vector2, p2?: Vector2);
240
238
  getPoint(t: number, output?: Vector2): Vector2;
241
239
  getAdaptivePointArray(output?: number[]): number[];
242
240
  getControlPointRefs(): Vector2[];
@@ -259,7 +257,7 @@ declare class LineCurve extends Curve {
259
257
  p1: Vector2;
260
258
  p2: Vector2;
261
259
  static from(p1x: number, p1y: number, p2x: number, p2y: number): LineCurve;
262
- constructor(p1: Vector2, p2: Vector2);
260
+ constructor(p1?: Vector2, p2?: Vector2);
263
261
  getPoint(t: number, output?: Vector2): Vector2;
264
262
  getPointAt(u: number, output?: Vector2): Vector2;
265
263
  getTangent(_t: number, output?: Vector2): Vector2;
@@ -279,11 +277,13 @@ declare class PloygonCurve extends CompositeCurve<LineCurve> {
279
277
  }
280
278
 
281
279
  declare class EquilateralPloygonCurve extends PloygonCurve {
282
- readonly cx: number;
283
- readonly cy: number;
284
- readonly radius: number;
285
- readonly sideCount: number;
280
+ cx: number;
281
+ cy: number;
282
+ radius: number;
283
+ sideCount: number;
286
284
  constructor(cx?: number, cy?: number, radius?: number, sideCount?: number);
285
+ update(): this;
286
+ copy(source: EquilateralPloygonCurve): this;
287
287
  }
288
288
 
289
289
  declare class QuadraticBezierCurve extends Curve {
@@ -291,7 +291,7 @@ declare class QuadraticBezierCurve extends Curve {
291
291
  cp: Vector2;
292
292
  p2: Vector2;
293
293
  static from(p1x: number, p1y: number, cpx: number, cpy: number, p2x: number, p2y: number): QuadraticBezierCurve;
294
- constructor(p1: Vector2, cp: Vector2, p2: Vector2);
294
+ constructor(p1?: Vector2, cp?: Vector2, p2?: Vector2);
295
295
  getPoint(t: number, output?: Vector2): Vector2;
296
296
  getControlPointRefs(): Vector2[];
297
297
  getAdaptivePointArray(output?: number[]): number[];
@@ -305,23 +305,27 @@ declare class QuadraticBezierCurve extends Curve {
305
305
  }
306
306
 
307
307
  declare class RectangleCurve extends PloygonCurve {
308
- readonly x: number;
309
- readonly y: number;
310
- readonly width: number;
311
- readonly height: number;
308
+ x: number;
309
+ y: number;
310
+ width: number;
311
+ height: number;
312
312
  constructor(x?: number, y?: number, width?: number, height?: number);
313
+ update(): this;
313
314
  drawTo(ctx: CanvasRenderingContext2D): this;
314
315
  fillTriangulate(options?: FillTriangulateOptions): FillTriangulateResult;
316
+ copy(source: RectangleCurve): this;
315
317
  }
316
318
 
317
319
  declare class RoundRectangleCurve extends RoundCurve {
318
- readonly x: number;
319
- readonly y: number;
320
- readonly width: number;
321
- readonly height: number;
322
- readonly radius: number;
320
+ x: number;
321
+ y: number;
322
+ width: number;
323
+ height: number;
324
+ radius: number;
323
325
  constructor(x?: number, y?: number, width?: number, height?: number, radius?: number);
326
+ update(): this;
324
327
  drawTo(ctx: CanvasRenderingContext2D): this;
328
+ copy(source: RoundRectangleCurve): this;
325
329
  }
326
330
 
327
331
  declare class SplineCurve extends Curve {
@@ -469,6 +473,7 @@ declare class Path2D extends CompositeCurve<CurvePath> {
469
473
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): this;
470
474
  rect(x: number, y: number, width: number, height: number): this;
471
475
  roundRect(x: number, y: number, width: number, height: number, radii: number): this;
476
+ reset(): this;
472
477
  addCommands(commands: Path2DCommand[]): this;
473
478
  addData(data: Path2DData): this;
474
479
  splineThru(points: Vector2[]): this;
@@ -488,7 +493,6 @@ declare class Path2D extends CompositeCurve<CurvePath> {
488
493
  toData(): Path2DData;
489
494
  toSVGPathString(): string;
490
495
  copy(source: Path2D): this;
491
- clone(): this;
492
496
  }
493
497
 
494
498
  declare class Path2DSet {
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(v,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(v=typeof globalThis<"u"?globalThis:v||self,R(v.modernPath2d={}))})(this,function(v){"use strict";var En=Object.defineProperty;var Ln=(v,R,nt)=>R in v?En(v,R,{enumerable:!0,configurable:!0,writable:!0,value:nt}):v[R]=nt;var X=(v,R,nt)=>Ln(v,typeof R!="symbol"?R+"":R,nt);function R(i,e,t,n={}){const{radius:r=1}=n;i.moveTo(e,t),i.arc(e,t,r,0,Math.PI*2)}const nt={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function At(i,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:h=0,strokeDasharray:c=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:f=0,shadowBlur:y=0,shadowColor:x="rgba(0, 0, 0, 0)"}=e;i.fillStyle=t,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=nt[s],i.miterLimit=h,i.setLineDash(c),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=f,i.shadowBlur=y,i.shadowColor=x}class m{constructor(e=0,t=0){this.x=e,this.y=t}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]}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,o=-(this.y-t.y),s=Math.sin(n),h=Math.cos(n);return this.set(t.x+(r*h-o*s),t.y-(r*s+o*h)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){const r=e<0?n.x-this.x+n.x:this.x,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=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(e)*o),this.y=n.y+(o+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new m(this.x,this.y)}}class V{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}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(...e){if(e.length===0)return new V;if(e.length===1)return e[0].clone();const t=e[0],n=e.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:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new V(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new V(this.left,this.top,this.width,this.height)}}class z{constructor(e=1,t=0,n=0,r=0,o=1,s=0,h=0,c=0,a=1){X(this,"elements",[]);this.set(e,t,n,r,o,s,h,c,a)}set(e,t,n,r,o,s,h,c,a){const l=this.elements;return l[0]=e,l[1]=r,l[2]=h,l[3]=t,l[4]=o,l[5]=c,l[6]=n,l[7]=s,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,s=n[0],h=n[3],c=n[6],a=n[1],l=n[4],f=n[7],y=n[2],x=n[5],u=n[8],d=r[0],M=r[3],b=r[6],S=r[1],P=r[4],w=r[7],k=r[2],E=r[5],p=r[8];return o[0]=s*d+h*S+c*k,o[3]=s*M+h*P+c*E,o[6]=s*b+h*w+c*p,o[1]=a*d+l*S+f*k,o[4]=a*M+l*P+f*E,o[7]=a*b+l*w+f*p,o[2]=y*d+x*S+u*k,o[5]=y*M+x*P+u*E,o[8]=y*b+x*w+u*p,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],s=e[4],h=e[5],c=e[6],a=e[7],l=e[8],f=l*s-h*a,y=h*c-l*o,x=a*o-s*c,u=t*f+n*y+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const d=1/u;return e[0]=f*d,e[1]=(r*a-l*n)*d,e[2]=(h*n-r*s)*d,e[3]=y*d,e[4]=(l*t-r*c)*d,e[5]=(r*o-h*t)*d,e[6]=x*d,e[7]=(n*c-a*t)*d,e[8]=(s*t-n*o)*d,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(bt.makeScale(e,t)),this}rotate(e){return this.premultiply(bt.makeRotation(-e)),this}translate(e,t){return this.premultiply(bt.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new z;function zt(i,e,t,n){const r=i*t+e*n,o=Math.sqrt(i*i+e*e)*Math.sqrt(t*t+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-e*t<0&&(s=-s),s}function Zt(i,e,t,n,r,o,s,h){if(e===0||t===0){i.lineTo(h.x,h.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(s.x-h.x)/2,a=(s.y-h.y)/2,l=Math.cos(n)*c+Math.sin(n)*a,f=-Math.sin(n)*c+Math.cos(n)*a;let y=e*e,x=t*t;const u=l*l,d=f*f,M=u/y+d/x;if(M>1){const O=Math.sqrt(M);e=O*e,t=O*t,y=e*e,x=t*t}const b=y*d+x*u,S=(y*x-b)/b;let P=Math.sqrt(Math.max(0,S));r===o&&(P=-P);const w=P*e*f/t,k=-P*t*l/e,E=Math.cos(n)*w-Math.sin(n)*k+(s.x+h.x)/2,p=Math.sin(n)*w+Math.cos(n)*k+(s.y+h.y)/2,g=zt(1,0,(l-w)/e,(f-k)/t),q=zt((l-w)/e,(f-k)/t,(-l-w)/e,(-f-k)/t)%(Math.PI*2);i.ellipse(E,p,e,t,n,g,g+q,o===0)}const D={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Z(i,e,t=0){let h=0,c=!0,a="",l="";const f=[];function y(M,b,S){const P=new SyntaxError(`Unexpected character "${M}" at index ${b}.`);throw P.partial=S,P}function x(){a!==""&&(l===""?f.push(Number(a)):f.push(Number(a)*10**Number(l))),a="",l=""}let u;const d=i.length;for(let M=0;M<d;M++){if(u=i[M],Array.isArray(e)&&e.includes(f.length%t)&&D.FLAGS.test(u)){h=1,a=u,x();continue}if(h===0){if(D.WHITESPACE.test(u))continue;if(D.DIGIT.test(u)||D.SIGN.test(u)){h=1,a=u;continue}if(D.POINT.test(u)){h=2,a=u;continue}D.COMMA.test(u)&&(c&&y(u,M,f),c=!0)}if(h===1){if(D.DIGIT.test(u)){a+=u;continue}if(D.POINT.test(u)){a+=u,h=2;continue}if(D.EXP.test(u)){h=3;continue}D.SIGN.test(u)&&a.length===1&&D.SIGN.test(a[0])&&y(u,M,f)}if(h===2){if(D.DIGIT.test(u)){a+=u;continue}if(D.EXP.test(u)){h=3;continue}D.POINT.test(u)&&a[a.length-1]==="."&&y(u,M,f)}if(h===3){if(D.DIGIT.test(u)){l+=u;continue}if(D.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&D.SIGN.test(l)&&y(u,M,f)}}D.WHITESPACE.test(u)?(x(),h=0,c=!1):D.COMMA.test(u)?(x(),h=0,c=!0):D.SIGN.test(u)?(x(),h=1,a=u):D.POINT.test(u)?(x(),h=2,a=u):y(u,M,f)}return x(),f}function st(i,e){return i-(e-i)}function kt(i,e){const t=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"?t.add(s):t.copy(s),e.moveTo(t.x,t.y),n.copy(t);else if(s.type==="h"||s.type==="H")s.type==="h"?t.x+=s.x:t.x=s.x,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="v"||s.type==="V")s.type==="v"?t.y+=s.y:t.y=s.y,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="l"||s.type==="L")s.type==="l"?t.add(s):t.copy(s),e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="c"||s.type==="C")s.type==="c"?(e.bezierCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(st(t.x,n.x),st(t.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(e.quadraticCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x,t.y+s.y),n.x=t.x+s.x1,n.y=t.y+s.y1,t.add(s)):(e.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,t.copy(s));else if(s.type==="t"||s.type==="T"){const h=st(t.x,n.x),c=st(t.y,n.y);n.x=h,n.y=c,s.type==="t"?(e.quadraticCurveTo(h,c,t.x+s.x,t.y+s.y),t.add(s)):(e.quadraticCurveTo(h,c,s.x,s.y),t.copy(s))}else if(s.type==="a"||s.type==="A"){const h=t.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;t.add(s)}else{if(t.equals(s))continue;t.copy(s)}n.copy(t),Zt(e,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,h,t)}else s.type==="z"||s.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",s)}}function jt(i){let e,t;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)===(t==null?void 0:t.x.toFixed(4))&&s.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y},e={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),t={x:s.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),t={x:(t==null?void 0:t.x)??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),t={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}`),t={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),t={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}`),t={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const Ce=/[a-df-z][^a-df-z]*/gi;function It(i){const e=[],t=i.match(Ce);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],s=o.charAt(0),h=o.slice(1).trim();let c;switch(s){case"m":case"M":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)a===0?e.push({type:s,x:c[a],y:c[a+1]}):e.push({type:s==="m"?"l":"L",x:c[a],y:c[a+1]});break;case"h":case"H":c=Z(h);for(let a=0,l=c.length;a<l;a++)e.push({type:s,x:c[a]});break;case"v":case"V":c=Z(h);for(let a=0,l=c.length;a<l;a++)e.push({type:s,y:c[a]});break;case"l":case"L":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)e.push({type:s,x:c[a],y:c[a+1]});break;case"c":case"C":c=Z(h);for(let a=0,l=c.length;a<l;a+=6)e.push({type:s,x1:c[a],y1:c[a+1],x2:c[a+2],y2:c[a+3],x:c[a+4],y:c[a+5]});break;case"s":case"S":c=Z(h);for(let a=0,l=c.length;a<l;a+=4)e.push({type:s,x2:c[a],y2:c[a+1],x:c[a+2],y:c[a+3]});break;case"q":case"Q":c=Z(h);for(let a=0,l=c.length;a<l;a+=4)e.push({type:s,x1:c[a],y1:c[a+1],x:c[a+2],y:c[a+3]});break;case"t":case"T":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)e.push({type:s,x:c[a],y:c[a+1]});break;case"a":case"A":c=Z(h,[3,4],7);for(let a=0,l=c.length;a<l;a+=7)e.push({type:s,rx:c[a],ry:c[a+1],angle:c[a+2],largeArcFlag:c[a+3],sweepFlag:c[a+4],x:c[a+5],y:c[a+6]});break;case"z":case"Z":e.push({type:s});break;default:console.warn(o)}}return e}function St(i,e,t,n,r){const o=(n-e)*.5,s=(r-t)*.5,h=i*i,c=i*h;return(2*t-2*n+o+s)*c+(-3*t+3*n-2*o-s)*h+o*i+t}function Ae(i,e){const t=1-i;return t*t*t*e}function be(i,e){const t=1-i;return 3*t*t*i*e}function ke(i,e){return 3*(1-i)*i*i*e}function Ie(i,e){return i*i*i*e}function Et(i,e,t,n,r){return Ae(i,e)+be(i,t)+ke(i,n)+Ie(i,r)}function Se(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Ut(i,0,r,t,!0);const s=[];if(!o||o.next===o.prev)return s;let h,c,a;if(n&&(o=De(i,e,o,t)),i.length>80*t){h=1/0,c=1/0;let l=-1/0,f=-1/0;for(let y=t;y<r;y+=t){const x=i[y],u=i[y+1];x<h&&(h=x),u<c&&(c=u),x>l&&(l=x),u>f&&(f=u)}a=Math.max(l-h,f-c),a=a!==0?32767/a:0}return ot(o,s,t,h,c,a,0),s}function Ut(i,e,t,n,r){let o;if(r===Ge(i,e,t,n)>0)for(let s=e;s<t;s+=n)o=Vt(s/n|0,i[s],i[s+1],o);else for(let s=t-n;s>=e;s-=n)o=Vt(s/n|0,i[s],i[s+1],o);return o&&it(o,o.next)&&(at(o),o=o.next),o}function H(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(it(t,t.next)||N(t.prev,t,t.next)===0)){if(at(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ot(i,e,t,n,r,o,s){if(!i)return;!s&&o&&Re(i,n,r,o);let h=i;for(;i.prev!==i.next;){const c=i.prev,a=i.next;if(o?Le(i,n,r,o):Ee(i)){e.push(c.i,i.i,a.i),at(i),i=a.next,h=a.next;continue}if(i=a,i===h){s?s===1?(i=$e(H(i),e),ot(i,e,t,n,r,o,2)):s===2&&Ne(i,e,t,n,r,o):ot(H(i),e,t,n,r,o,1);break}}}function Ee(i){const e=i.prev,t=i,n=i.next;if(N(e,t,n)>=0)return!1;const r=e.x,o=t.x,s=n.x,h=e.y,c=t.y,a=n.y,l=Math.min(r,o,s),f=Math.min(h,c,a),y=Math.max(r,o,s),x=Math.max(h,c,a);let u=n.next;for(;u!==e;){if(u.x>=l&&u.x<=y&&u.y>=f&&u.y<=x&&ct(r,h,o,c,s,a,u.x,u.y)&&N(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function Le(i,e,t,n){const r=i.prev,o=i,s=i.next;if(N(r,o,s)>=0)return!1;const h=r.x,c=o.x,a=s.x,l=r.y,f=o.y,y=s.y,x=Math.min(h,c,a),u=Math.min(l,f,y),d=Math.max(h,c,a),M=Math.max(l,f,y),b=Lt(x,u,e,t,n),S=Lt(d,M,e,t,n);let P=i.prevZ,w=i.nextZ;for(;P&&P.z>=b&&w&&w.z<=S;){if(P.x>=x&&P.x<=d&&P.y>=u&&P.y<=M&&P!==r&&P!==s&&ct(h,l,c,f,a,y,P.x,P.y)&&N(P.prev,P,P.next)>=0||(P=P.prevZ,w.x>=x&&w.x<=d&&w.y>=u&&w.y<=M&&w!==r&&w!==s&&ct(h,l,c,f,a,y,w.x,w.y)&&N(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;P&&P.z>=b;){if(P.x>=x&&P.x<=d&&P.y>=u&&P.y<=M&&P!==r&&P!==s&&ct(h,l,c,f,a,y,P.x,P.y)&&N(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;w&&w.z<=S;){if(w.x>=x&&w.x<=d&&w.y>=u&&w.y<=M&&w!==r&&w!==s&&ct(h,l,c,f,a,y,w.x,w.y)&&N(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function $e(i,e){let t=i;do{const n=t.prev,r=t.next.next;!it(n,r)&&Gt(n,t,t.next,r)&&ht(n,r)&&ht(r,n)&&(e.push(n.i,t.i,r.i),at(t),at(t.next),t=i=r),t=t.next}while(t!==i);return H(t)}function Ne(i,e,t,n,r,o){let s=i;do{let h=s.next.next;for(;h!==s.prev;){if(s.i!==h.i&&je(s,h)){let c=Bt(s,h);s=H(s,s.next),c=H(c,c.next),ot(s,e,t,n,r,o,0),ot(c,e,t,n,r,o,0);return}h=h.next}s=s.next}while(s!==i)}function De(i,e,t,n){const r=[];for(let o=0,s=e.length;o<s;o++){const h=e[o]*n,c=o<s-1?e[o+1]*n:i.length,a=Ut(i,h,c,n,!1);a===a.next&&(a.steiner=!0),r.push(Ze(a))}r.sort(qe);for(let o=0;o<r.length;o++)t=Oe(r[o],t);return t}function qe(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function Oe(i,e){const t=Fe(i,e);if(!t)return e;const n=Bt(t,i);return H(n,n.next),H(t,t.next)}function Fe(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,s;if(it(i,t))return t;do{if(it(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const f=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(f<=n&&f>o&&(o=f,s=t.x<t.next.x?t:t.next,f===n))return s}t=t.next}while(t!==e);if(!s)return null;const h=s,c=s.x,a=s.y;let l=1/0;t=s;do{if(n>=t.x&&t.x>=c&&n!==t.x&&Xt(r<a?n:o,r,c,a,r<a?o:n,r,t.x,t.y)){const f=Math.abs(r-t.y)/(n-t.x);ht(t,i)&&(f<l||f===l&&(t.x>s.x||t.x===s.x&&_e(s,t)))&&(s=t,l=f)}t=t.next}while(t!==h);return s}function _e(i,e){return N(i.prev,i,e.prev)<0&&N(e.next,i,i.next)<0}function Re(i,e,t,n){let r=i;do r.z===0&&(r.z=Lt(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,ze(r)}function ze(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let s=n,h=0;for(let a=0;a<t&&(h++,s=s.nextZ,!!s);a++);let c=t;for(;h>0||c>0&&s;)h!==0&&(c===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,h--):(r=s,s=s.nextZ,c--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,t*=2}while(e>1);return i}function Lt(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function Ze(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Xt(i,e,t,n,r,o,s,h){return(r-s)*(e-h)>=(i-s)*(o-h)&&(i-s)*(n-h)>=(t-s)*(e-h)&&(t-s)*(o-h)>=(r-s)*(n-h)}function ct(i,e,t,n,r,o,s,h){return!(i===s&&e===h)&&Xt(i,e,t,n,r,o,s,h)}function je(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Ue(i,e)&&(ht(i,e)&&ht(e,i)&&Xe(i,e)&&(N(i.prev,i,e.prev)||N(i,e.prev,e))||it(i,e)&&N(i.prev,i,i.next)>0&&N(e.prev,e,e.next)>0)}function N(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function it(i,e){return i.x===e.x&&i.y===e.y}function Gt(i,e,t,n){const r=pt(N(i,e,t)),o=pt(N(i,e,n)),s=pt(N(t,n,i)),h=pt(N(t,n,e));return!!(r!==o&&s!==h||r===0&&xt(i,t,e)||o===0&&xt(i,n,e)||s===0&&xt(t,i,n)||h===0&&xt(t,e,n))}function xt(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function pt(i){return i>0?1:i<0?-1:0}function Ue(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Gt(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ht(i,e){return N(i.prev,i,i.next)<0?N(i,e,i.next)>=0&&N(i,i.prev,e)>=0:N(i,e,i.prev)<0||N(i,i.next,e)<0}function Xe(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Bt(i,e){const t=$t(i.i,i.x,i.y),n=$t(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Vt(i,e,t,n){const r=$t(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function at(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,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ge(i,e,t,n){let r=0;for(let o=e,s=t-n;o<t;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Wt(i,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=0,indicesOffset:h=0}=e;const c=Se(i,r,2);if(c){for(let l=0;l<c.length;l+=3)n[h++]=c[l]+s,n[h++]=c[l+1]+s,n[h++]=c[l+2]+s;let a=s*o;for(let l=0;l<i.length;l+=2)t[a]=i[l],t[a+1]=i[l+1],a+=o}return{vertices:t,indices:n}}const Be=8,gt=11920929e-14,Ve=1;function Ht(i,e,t,n,r,o,s,h,c=.5,a){const f=Math.min(.99,Math.max(0,c));let y=(Ve-f)/1;return y*=y,Nt(i,e,t,n,r,o,s,h,a,y,0),a.push(s,h),a}function Nt(i,e,t,n,r,o,s,h,c,a,l){if(l>Be)return;const f=(i+t)/2,y=(e+n)/2,x=(t+r)/2,u=(n+o)/2,d=(r+s)/2,M=(o+h)/2,b=(f+x)/2,S=(y+u)/2,P=(x+d)/2,w=(u+M)/2,k=(b+P)/2,E=(S+w)/2;if(l>0){let p=s-i,g=h-e;const q=Math.abs((t-s)*g-(n-h)*p),O=Math.abs((r-s)*g-(o-h)*p);if(q>gt&&O>gt){if((q+O)*(q+O)<=a*(p*p+g*g)){c.push(k,E);return}}else if(q>gt){if(q*q<=a*(p*p+g*g)){c.push(k,E);return}}else if(O>gt){if(O*O<=a*(p*p+g*g)){c.push(k,E);return}}else if(p=k-(i+s)/2,g=E-(e+h)/2,p*p+g*g<=a){c.push(k,E);return}}Nt(i,e,f,y,b,S,k,E,c,a,l+1),Nt(k,E,P,w,d,M,s,h,c,a,l+1)}const We=8,He=11920929e-14,Qe=1;function Qt(i,e,t,n,r,o,s=.5,h){const a=Math.min(.99,Math.max(0,s));let l=(Qe-a)/1;return l*=l,Dt(h,i,e,t,n,r,o,l,0),h.push(r,o),h}function Dt(i,e,t,n,r,o,s,h,c){if(c>We)return;const a=(e+n)/2,l=(t+r)/2,f=(n+o)/2,y=(r+s)/2,x=(a+f)/2,u=(l+y)/2;let d=o-e,M=s-t;const b=Math.abs((n-o)*M-(r-s)*d);if(b>He){if(b*b<=h*(d*d+M*M)){i.push(x,u);return}}else if(d=x-(e+o)/2,M=u-(t+s)/2,d*d+M*M<=h){i.push(x,u);return}Dt(i,e,t,a,l,x,u,h,c+1),Dt(i,x,u,f,y,o,s,h,c+1)}function Ye(i,e){const t=1-i;return t*t*e}function Je(i,e){return 2*(1-i)*i*e}function Ke(i,e){return i*i*e}function qt(i,e,t,n){return Ye(i,e)+Je(i,t)+Ke(i,n)}const tn=1e-4,Yt=1e-4;function Jt(i,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=e,h=tn;if(i.length===0)return{vertices:t,indices:n};const c=r;let a=c.alignment;if(r.alignment!==.5){let $=en(i);o&&($*=-1),a=(a-.5)*$+.5}const l={x:i[0],y:i[1]},f={x:i[i.length-2],y:i[i.length-1]},y=s,x=Math.abs(l.x-f.x)<h&&Math.abs(l.y-f.y)<h;if(y){i=i.slice(),x&&(i.pop(),i.pop(),f.x=i[i.length-2],f.y=i[i.length-1]);const $=(l.x+f.x)*.5,W=(f.y+l.y)*.5;i.unshift($,W),i.push($,W)}const u=t,d=i.length/2;let M=i.length;const b=u.length/2,S=c.width/2,P=S*S,w=c.miterLimit*c.miterLimit;let k=i[0],E=i[1],p=i[2],g=i[3],q=0,O=0,C=-(E-g),A=k-p,F=0,_=0,U=Math.sqrt(C*C+A*A);C/=U,A/=U,C*=S,A*=S;const Me=a,T=(1-Me)*2,I=Me*2;y||(c.cap==="round"?M+=Q(k-C*(T-I)*.5,E-A*(T-I)*.5,k-C*T,E-A*T,k+C*I,E+A*I,u,!0)+2:c.cap==="square"&&(M+=Kt(k,E,C,A,T,I,!0,u))),u.push(k-C*T,E-A*T),u.push(k+C*I,E+A*I);for(let $=1;$<d-1;++$){k=i[($-1)*2],E=i[($-1)*2+1],p=i[$*2],g=i[$*2+1],q=i[($+1)*2],O=i[($+1)*2+1],C=-(E-g),A=k-p,U=Math.sqrt(C*C+A*A),C/=U,A/=U,C*=S,A*=S,F=-(g-O),_=p-q,U=Math.sqrt(F*F+_*_),F/=U,_/=U,F*=S,_*=S;const W=p-k,lt=E-g,ut=p-q,ft=O-g,Pe=W*ut+lt*ft,vt=lt*ut-ft*W,yt=vt<0;if(Math.abs(vt)<.001*Math.abs(Pe)){u.push(p-C*T,g-A*T),u.push(p+C*I,g+A*I),Pe>=0&&(c.join==="round"?M+=Q(p,g,p-C*T,g-A*T,p-F*T,g-_*T,u,!1)+4:M+=2,u.push(p-F*I,g-_*I),u.push(p+F*T,g+_*T));continue}const we=(-C+k)*(-A+g)-(-C+p)*(-A+E),ve=(-F+q)*(-_+g)-(-F+p)*(-_+O),Tt=(W*ve-ut*we)/vt,Ct=(ft*we-lt*ve)/vt,Rt=(Tt-p)*(Tt-p)+(Ct-g)*(Ct-g),J=p+(Tt-p)*T,K=g+(Ct-g)*T,tt=p-(Tt-p)*I,et=g-(Ct-g)*I,In=Math.min(W*W+lt*lt,ut*ut+ft*ft),Te=yt?T:I,Sn=In+Te*Te*P;Rt<=Sn?c.join==="bevel"||Rt/P>w?(yt?(u.push(J,K),u.push(p+C*I,g+A*I),u.push(J,K),u.push(p+F*I,g+_*I)):(u.push(p-C*T,g-A*T),u.push(tt,et),u.push(p-F*T,g-_*T),u.push(tt,et)),M+=2):c.join==="round"?yt?(u.push(J,K),u.push(p+C*I,g+A*I),M+=Q(p,g,p+C*I,g+A*I,p+F*I,g+_*I,u,!0)+4,u.push(J,K),u.push(p+F*I,g+_*I)):(u.push(p-C*T,g-A*T),u.push(tt,et),M+=Q(p,g,p-C*T,g-A*T,p-F*T,g-_*T,u,!1)+4,u.push(p-F*T,g-_*T),u.push(tt,et)):(u.push(J,K),u.push(tt,et)):(u.push(p-C*T,g-A*T),u.push(p+C*I,g+A*I),c.join==="round"?yt?M+=Q(p,g,p+C*I,g+A*I,p+F*I,g+_*I,u,!0)+2:M+=Q(p,g,p-C*T,g-A*T,p-F*T,g-_*T,u,!1)+2:c.join==="miter"&&Rt/P<=w&&(yt?(u.push(tt,et),u.push(tt,et)):(u.push(J,K),u.push(J,K)),M+=2),u.push(p-F*T,g-_*T),u.push(p+F*I,g+_*I),M+=2)}k=i[(d-2)*2],E=i[(d-2)*2+1],p=i[(d-1)*2],g=i[(d-1)*2+1],C=-(E-g),A=k-p,U=Math.sqrt(C*C+A*A),C/=U,A/=U,C*=S,A*=S,u.push(p-C*T,g-A*T),u.push(p+C*I,g+A*I),y||(c.cap==="round"?M+=Q(p-C*(T-I)*.5,g-A*(T-I)*.5,p-C*T,g-A*T,p+C*I,g+A*I,u,!1)+2:c.cap==="square"&&(M+=Kt(p,g,C,A,T,I,!1,u)));const kn=Yt*Yt;for(let $=b;$<M+b-2;++$)k=u[$*2],E=u[$*2+1],p=u[($+1)*2],g=u[($+1)*2+1],q=u[($+2)*2],O=u[($+2)*2+1],!(Math.abs(k*(g-O)+p*(O-E)+q*(E-g))<kn)&&n.push($,$+1,$+2);return{vertices:t,indices:n}}function en(i){const e=i.length;if(e<6)return 1;let t=0;for(let n=0,r=i[e-2],o=i[e-1];n<e;n+=2){const s=i[n],h=i[n+1];t+=(s-r)*(h+o),r=s,o=h}return t<0?-1:1}function Kt(i,e,t,n,r,o,s,h){const c=i-t*r,a=e-n*r,l=i+t*o,f=e+n*o;let y,x;s?(y=n,x=-t):(y=-n,x=t);const u=c+y,d=a+x,M=l+y,b=f+x;return h.push(u,d),h.push(M,b),2}function Q(i,e,t,n,r,o,s,h){const c=t-i,a=n-e;let l=Math.atan2(c,a),f=Math.atan2(r-i,o-e);h&&l<f?l+=Math.PI*2:!h&&l>f&&(f+=Math.PI*2);let y=l;const x=f-l,u=Math.abs(x),d=Math.sqrt(c*c+a*a),M=(15*u*Math.sqrt(d)/Math.PI>>0)+1,b=x/M;if(y+=b,h){s.push(i,e),s.push(t,n);for(let S=1,P=y;S<M;S++,P+=b)s.push(i,e),s.push(i+Math.sin(P)*d,e+Math.cos(P)*d);s.push(i,e),s.push(r,o)}else{s.push(t,n),s.push(i,e);for(let S=1,P=y;S<M;S++,P+=b)s.push(i+Math.sin(P)*d,e+Math.cos(P)*d),s.push(i,e);s.push(r,o),s.push(i,e)}return M*2}class Y{constructor(){X(this,"startT",0);X(this,"endT",1);X(this,"arcLengthDivision",200);X(this,"_arcLengths")}getPointAt(e,t=new m){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){return this.getControlPointRefs().forEach(t=>{t.applyMatrix3(e)}),this}getUnevenPointArray(e=5,t=[]){const n=new m;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedPointArray(e=5,t=[]){const n=new m;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,n),t.push(n.x,n.y);return t}getAdaptivePointArray(e=[]){return this.getUnevenPointArray(5,e)}_pointArrayToPoint(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){const o=e[n],s=e[n+1];t.push(new m(o,s))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedPointArray(e);return this._pointArrayToPoint(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenPointArray(e);return this._pointArrayToPoint(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptivePointArray();return this._pointArrayToPoint(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenPointArray(e):n=this.getAdaptivePointArray(),this._pointArrayToPoint(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),o=1;o<=e;o++){const s=this.getPoint(o/e);n+=s.distanceTo(r),t.push(n),r=s}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/n[0];let s=0,h=0,c=r-1,a;for(;h<=c;)if(s=Math.floor(h+(c-h)/2),a=n[s]-o,a<0)h=s+1;else if(a>0)c=s-1;else{c=s;break}if(s=c,n[s]===o)return s/(r-1);const l=n[s],y=n[s+1]-l,x=(o-l)/y;return(s+x)/(r-1)}getTangent(e,t=new m){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new m){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(e)<t)return o;s.x<e.x?n=o:r=o}return o}getMinMax(e=m.MAX,t=m.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];e.min(s),t.max(s)}return{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new V(e.x,e.y,t.x-e.x,t.y-e.y)}fillTriangulate(e){return Wt(this.getPoints().reduce((t,n)=>(t.push(n.x,n.y),t),[]),e)}strokeTriangulate(e){return Jt(this.getPoints().reduce((t,n)=>(t.push(n.x,n.y),t),[]),e)}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return jt(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const nn=new z,te=new z,ee=new z,dt=new m;class Ot extends Y{constructor(e,t,n,r=0,o=0,s=Math.PI*2,h=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=h}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}getPoint(e,t=new m){const n=Math.PI*2;let r=this.endAngle-this.startAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(o?r=0:r=n),this.clockwise&&!o&&(r===n?r=-n:r=r-n);const s=this.startAngle+e*r;let h=this.cx+this.rx*Math.cos(s),c=this.cy+this.ry*Math.sin(s);if(this.rotate!==0){const a=Math.cos(this.rotate),l=Math.sin(this.rotate),f=h-this.cx,y=c-this.cy;h=f*a-y*l+this.cx,c=f*l+y*a+this.cy}return t.set(h,c)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:h,rotate:c}=this,a=e+n*Math.cos(o)*Math.cos(c)-r*Math.sin(o)*Math.sin(c),l=t+n*Math.cos(o)*Math.sin(c)+r*Math.sin(o)*Math.cos(c),f=Math.abs(o-s),y=f>Math.PI?1:0,x=h?1:0,u=c*180/Math.PI;if(f>=2*Math.PI){const d=o+Math.PI,M=e+n*Math.cos(d)*Math.cos(c)-r*Math.sin(d)*Math.sin(c),b=t+n*Math.cos(d)*Math.sin(c)+r*Math.sin(d)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:M,y:b},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const d=e+n*Math.cos(s)*Math.cos(c)-r*Math.sin(s)*Math.sin(c),M=t+n*Math.cos(s)*Math.sin(c)+r*Math.sin(s)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:y,sweepFlag:x,x:d,y:M}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:s,startAngle:h,endAngle:c,clockwise:a}=this;return e.ellipse(t,n,r,o,s,h,c,!a),this}applyTransform(e){return dt.set(this.cx,this.cy),dt.applyMatrix3(e),this.cx=dt.x,this.cy=dt.y,on(e)?sn(this,e):rn(this,e),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:h}=this;if(!(r>=0&&o>=0&&s>=0&&h>=0))return e;const c=Math.ceil(2.3*Math.sqrt(r+o)),a=c*8+(s?4:0)+(h?4:0);if(a===0)return e;const l=[];if(c===0)l[0]=l[6]=t+s,l[1]=l[3]=n+h,l[2]=l[4]=t-s,l[5]=l[7]=n-h;else{let f=0,y=c*4+(s?2:0)+2,x=y,u=a,d=s+r,M=h,b=t+d,S=t-d,P=n+M;if(l[f++]=b,l[f++]=P,l[--y]=P,l[--y]=S,h){const k=n-M;l[x++]=S,l[x++]=k,l[--u]=k,l[--u]=b}for(let k=1;k<c;k++){const E=Math.PI/2*(k/c),p=s+Math.cos(E)*r,g=h+Math.sin(E)*o,q=t+p,O=t-p,C=n+g,A=n-g;l[f++]=q,l[f++]=C,l[--y]=C,l[--y]=O,l[x++]=O,l[x++]=A,l[--u]=A,l[--u]=q}d=s,M=h+o,b=t+d,S=t-d,P=n+M;const w=n-M;l[f++]=b,l[f++]=P,l[--u]=w,l[--u]=b,s&&(l[f++]=S,l[f++]=P,l[--u]=w,l[--u]=S)}return Array.prototype.push.apply(e,l),e}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=0,indicesOffset:s=0}=e;const h=this.getAdaptivePointArray();if(h.length===0)return{vertices:t,indices:n};let c=0,a=0;for(let y=0;y<h.length;y+=2)c+=h[y],a+=h[y+1];c/=h.length/2,a/=h.length/2;let l=o;t[l*r]=c,t[l*r+1]=a;const f=l++;for(let y=0;y<h.length;y+=2)t[l*r]=h[y],t[l*r+1]=h[y+1],y>0&&(n[s++]=l,n[s++]=f,n[s++]=l-1),l++;return n[s++]=f+1,n[s++]=f,n[s++]=l-1,{vertices:t,indices:n}}getMinMax(e=m.MAX,t=m.MIN){const{cx:n,cy:r,rx:o,ry:s,rotate:h}=this,c=Math.cos(h),a=Math.sin(h),l=Math.sqrt(o*o*c*c+s*s*a*a),f=Math.sqrt(o*o*a*a+s*s*c*c);return e.x=Math.min(e.x,n-l),e.y=Math.min(e.y,r-f),t.x=Math.max(t.x,n+l),t.y=Math.max(t.y,r+f),{min:e,max:t}}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function sn(i,e){const t=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new m(t*r,t*o),h=new m(-n*o,n*r),c=s.applyMatrix3(e),a=h.applyMatrix3(e),l=nn.set(c.x,a.x,0,c.y,a.y,0,0,0,1),f=te.copy(l).invert(),u=ee.copy(f).transpose().multiply(f).elements,d=cn(u[0],u[1],u[4]),M=Math.sqrt(d.rt1),b=Math.sqrt(d.rt2);if(i.rx=1/M,i.ry=1/b,i.rotate=Math.atan2(d.sn,d.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=te.set(M,0,0,0,b,0,0,0,1),w=ee.set(d.cs,d.sn,0,-d.sn,d.cs,0,0,0,1),k=P.multiply(w).multiply(l),E=p=>{const{x:g,y:q}=new m(Math.cos(p),Math.sin(p)).applyMatrix3(k);return Math.atan2(q,g)};i.startAngle=E(i.startAngle),i.endAngle=E(i.endAngle),ne(e)&&(i.clockwise=!i.clockwise)}}function rn(i,e){const t=se(e),n=ie(e);i.rx*=t,i.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);i.rotate+=r,ne(e)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ne(i){const e=i.elements;return e[0]*e[4]-e[1]*e[3]<0}function on(i){const e=i.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=se(i),r=ie(i);return Math.abs(t/(n*r))>Number.EPSILON}function se(i){const e=i.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ie(i){const e=i.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function cn(i,e,t){let n,r,o,s,h;const c=i+t,a=i-t,l=Math.sqrt(a*a+4*e*e);return c>0?(n=.5*(c+l),h=1/n,r=i*h*t-e*h*e):c<0?r=.5*(c-l):(n=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(e)?(h=-2*e/o,s=1/Math.sqrt(1+h*h),o=h*s):Math.abs(e)===0?(o=1,s=0):(h=-.5*o/e,o=1/Math.sqrt(1+h*h),s=h*o),a>0&&(h=o,o=-s,s=h),{rt1:n,rt2:r,cs:o,sn:s}}class re extends Ot{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,s=!1){super(new m(e,t),new m(n,n),new m(0,0),0,r,o,s),this.radius=n}drawTo(e){const{cx:t,cy:n,radius:r,startAngle:o,endAngle:s,clockwise:h}=this;return e.arc(t,n,r,o,s,!h),this}getAdaptivePointArray(e=[]){const{cx:t,cy:n,radius:r,startAngle:o,endAngle:s,clockwise:h}=this;let c=Math.abs(o-s);(!h&&o>s||h&&s>o)&&(c=2*Math.PI-c);let a=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI)));a=Math.max(a,3);let l=c/a,f=o;l*=h?1:-1;for(let y=0;y<a+1;y++){const x=Math.cos(f),u=Math.sin(f),d=t+x*r,M=n+u*r;e.push(d,M),f+=l}return e}}class mt extends Y{constructor(e=[]){super(),this.curves=e}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new m){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,h=this.curves[o],c=h.getLength();return h.getPointAt(c===0?0:1-s/c,t)}o++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}getAdaptivePointArray(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptivePointArray(e),t&&e[t-1]===e[t+1]&&e[t]===e[t+2]&&e.splice(t+1,2),t=e.length-1}),e}getMinMax(e=m.MAX,t=m.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new V(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}}class Mt extends Y{constructor(e,t,n,r){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,s,h,c){return new Mt(new m(e,t),new m(n,r),new m(o,s),new m(h,c))}getPoint(e,t=new m){const{p1:n,cp1:r,cp2:o,p2:s}=this;return t.set(Et(e,n.x,r.x,o.x,s.x),Et(e,n.y,r.y,o.y,s.y))}getAdaptivePointArray(e=[]){return Ht(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,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){const r=t*t-4*e*n;if(r<0)return[];const o=Math.sqrt(r),s=(-t+o)/(2*e),h=(-t-o)/(2*e);return[s,h].filter(c=>c>=0&&c<=1)}getMinMax(e=m.MAX,t=m.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,h=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),c=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),a=[0,1,...h,...c];return((f,y)=>{for(const x of f)for(let u=0;u<=y;u++){const d=u/y-.5,M=Math.min(1,Math.max(0,x+d)),b=this.getPoint(M);e.x=Math.min(e.x,b.x),e.y=Math.min(e.y,b.y),t.x=Math.max(t.x,b.x),t.y=Math.max(t.y,b.y)}})(a,10),{min:e,max:t}}toCommands(){const{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp1:n,cp2:r,p2:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class oe extends Ot{constructor(e=0,t=0,n=1,r=1,o=0,s=0,h=Math.PI*2,c=!1){super(new m(e,t),new m(n,r),new m,o,s,h,c)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class G extends Y{constructor(e,t){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new G(new m(e,t),new m(n,r))}getPoint(e,t=new m){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new m){return this.getPoint(e,t)}getTangent(e,t=new m){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new m){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=m.MAX,t=m.MIN){const{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e,max:t}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class Ft extends mt{}class hn extends Ft{constructor(e=0,t=0,n=1,r=3){const o=[];for(let h=0;h<r;h++){const c=h*2*Math.PI/r-.5*Math.PI;o.push(new m(n*Math.cos(c),n*Math.sin(c)).add({x:e,y:t}))}const s=[];for(let h=0;h<r;h++)s.push(new G(o[h],o[(h+1)%r]));super(s),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r}}class Pt extends Y{constructor(e,t,n){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,s){return new Pt(new m(e,t),new m(n,r),new m(o,s))}getPoint(e,t=new m){const{p1:n,cp:r,p2:o}=this;return t.set(qt(e,n.x,r.x,o.x),qt(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(e=[]){return Qt(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=m.MAX,t=m.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),h=.5*(n.y+r.y),c=.5*(n.x+o.x),a=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,s,c),e.y=Math.min(e.y,n.y,o.y,h,a),t.x=Math.max(t.x,n.x,o.x,s,c),t.y=Math.max(t.y,n.y,o.y,h,a),{min:e,max:t}}toCommands(){const{p1:e,cp:t,p2:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){const{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class ce extends Ft{constructor(e=0,t=0,n=0,r=0){const o=[new m(e,t),new m(e+n,t),new m(e+n,t+r),new m(e,t+r)];super([new G(o[0],o[1]),new G(o[1],o[2]),new G(o[2],o[3]),new G(o[3],o[0])]),this.x=e,this.y=t,this.width=n,this.height=r}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=0,indicesOffset:s=0}=e;const{x:h,y:c,width:a,height:l}=this,f=[h,c,h+a,c,h+a,c+l,h,c+l];let y=0;o*=r,t[o+y]=f[0],t[o+y+1]=f[1],y+=r,t[o+y]=f[2],t[o+y+1]=f[3],y+=r,t[o+y]=f[6],t[o+y+1]=f[7],y+=r,t[o+y]=f[4],t[o+y+1]=f[5],y+=r;const x=o/r;return n[s++]=x,n[s++]=x+1,n[s++]=x+2,n[s++]=x+1,n[s++]=x+3,n[s++]=x+2,{vertices:t,indices:n}}}class he extends Ot{constructor(e=0,t=0,n=1,r=1,o=1){const s=n/2,h=r/2,c=e+s,a=t+h,l=Math.max(0,Math.min(o,Math.min(s,h))),f=l,y=s-l,x=h-f;super(new m(c,a),new m(l,f),new m(y,x)),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o}drawTo(e){const{x:t,y:n,width:r,height:o,radius:s}=this;return e.roundRect(t,n,r,o,s),this}}class ae extends Y{constructor(e=[]){super(),this.points=e}getPoint(e,t=new m){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),s=r-o,h=n[o===0?o:o-1],c=n[o],a=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return t.set(St(s,h.x,c.x,a.x,l.x),St(s,h.y,c.y,a.y,l.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class rt extends mt{constructor(t){super();X(this,"startPoint");X(this,"currentPoint");X(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:o,y:s}=t[n];this.lineTo(o,s)}return this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}getUnevenPointArray(t=40,n=[]){return super.getUnevenPointArray(t,n),this.autoClose&&n.length>=4&&n[0]!==n[n.length-2]&&n[1]!==n[n.length-1]&&n.push(n[0],n[1]),n}getSpacedPointArray(t=40,n=[]){return super.getSpacedPointArray(t,n),this.autoClose&&n.length>=4&&n[0]!==n[n.length-2]&&n[1]!==n[n.length-1]&&n.push(n[0],n[1]),n}_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 n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new G(n,t)),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new m(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(G.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,o,s,h){const c=this.currentPoint;return c!=null&&c.equals({x:s,y:h})||this.curves.push(Mt.from((c==null?void 0:c.x)??0,(c==null?void 0:c.y)??0,t,n,r,o,s,h)),this._setCurrentPoint({x:s,y:h}),this}quadraticCurveTo(t,n,r,o){const s=this.currentPoint;return s!=null&&s.equals({x:r,y:o})||this.curves.push(Pt.from((s==null?void 0:s.x)??0,(s==null?void 0:s.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,s,h){const c=new re(t,n,r,o,s,!h);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeArc(t,n,r,o,s,h){var c,a;return t+=((c=this.currentPoint)==null?void 0:c.x)??0,n+=((a=this.currentPoint)==null?void 0:a.y)??0,this.arc(t,n,r,o,s,h),this}arcTo(t,n,r,o,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,s,h,c,a=!0){const l=new oe(t,n,r,o,s,h,c,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,n,r,o,s,h,c,a){var l,f;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((f=this.currentPoint)==null?void 0:f.y)??0,this.ellipse(t,n,r,o,s,h,c,a),this}rect(t,n,r,o){const s=new ce(t,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,s){const h=new he(t,n,r,o,s);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new m;return this.curves.push(new ae([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;super.copy(t),this.curves=[];for(let r=0,o=t.curves.length;r<o;r++)this.curves.push(t.curves[r].clone());return this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function an(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function ln(i,e,t,n){const r=e.clone().sub(i),o=n.clone().sub(t),s=t.clone().sub(i),h=r.cross(o);if(h===0)return new m((i.x+t.x)/2,(i.y+t.y)/2);const c=s.cross(o)/h;return Math.abs(c)>1?new m((i.x+t.x)/2,(i.y+t.y)/2):new m(i.x+c*r.x,i.y+c*r.y)}class j extends mt{constructor(t,n={}){super();X(this,"currentCurve",new rt);X(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof j?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}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)}addPath(t){return t instanceof j?this.curves.push(...t.curves.map(n=>n.clone())):this.curves.push(t),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length>0&&(this.currentCurve=new rt().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new rt,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,o,s,h){return this.currentCurve.bezierCurveTo(t,n,r,o,s,h),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,s,h){return this.currentCurve.arc(t,n,r,o,s,h),this}arcTo(t,n,r,o,s){return this.currentCurve.arcTo(t,n,r,o,s),this}ellipse(t,n,r,o,s,h,c,a){return this.currentCurve.ellipse(t,n,r,o,s,h,c,a),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,s){return this.currentCurve.roundRect(t,n,r,o,s),this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.curves,r=[],o=[],s=[];n.forEach((c,a)=>{if(!c.getLength())return;const l=c.getControlPointRefs(),f=c.isClockwise();s[a]=l,o[a]=f;const y=l[0],x=l[l.length-1]??y;r.push({start:f?x:y,end:f?y:x,index:a})});const h=[];return r.forEach((c,a)=>{h[a]=[],r.forEach((l,f)=>{f!==a&&l.start.equals(c.end)&&h[a].push(l.index)})}),n.forEach((c,a)=>{if(!c.getLength())return;const l=o[a];s[a].forEach(y=>{const x=c.getTForPoint(y),u=c.getNormal(x).scale(l?t:-t);y.add(u)})}),h.forEach((c,a)=>{const l=s[a];c.forEach(f=>{const y=s[f],x=ln(l[l.length-1],l[l.length-2]??l[l.length-1],y[0],y[1]??y[0]);x&&(l[l.length-1].copy(x),y[0].copy(x))})}),this}applyTransform(t){return this.curves.forEach(n=>n.applyTransform(t)),this}getMinMax(t=m.MAX,n=m.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,n),r&&o>1){const h=o/2,c=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const f=s.getPoint(l),y=s.getNormal(l),x=y.clone().scale(c?h:-h),u=y.clone().scale(c?-h:h);a.push(f.clone().add(x),f.clone().add(u),f.clone().add({x:h,y:0}),f.clone().add({x:-h,y:0}),f.clone().add({x:0,y:h}),f.clone().add({x:0,y:-h}),f.clone().add({x:h,y:h}),f.clone().add({x:-h,y:-h}))}t.min(...a),n.max(...a)}}),{min:t,max:n}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new V(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.curves.forEach(s=>{s.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.getControlPointRefs().forEach(s=>{R(t,s.x,s.y,{radius:4})}),r!=="none"&&t.fill(),o!=="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"},n={};for(const o in t)t[o]!==void 0&&(n[an(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return this.currentCurve=t.currentCurve.clone(),this.curves=t.curves.map(n=>n.clone()),this.style={...t.style},this}clone(){return new this.constructor().copy(this)}}class le{constructor(e=[]){this.paths=e}getBoundingBox(e=!0){if(!this.paths.length)return;const t=m.MAX,n=m.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new V(t.x,t.y,n.x-t.x,n.y-t.y)}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${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(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:o,width:s,height:h}=this.getBoundingBox(),c=document.createElement("canvas");c.width=s*t,c.height=h*t,c.style.width=`${s}px`,c.style.height=`${h}px`;const a=c.getContext("2d");return a&&(a.scale(t,t),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,n)})),c}}const ue="data:image/svg+xml;",fe=`${ue}base64,`,ye=`${ue}charset=utf8,`;function xe(i){if(typeof i=="string"){let e;i.startsWith(fe)?(i=i.substring(fe.length,i.length),e=atob(i)):i.startsWith(ye)?(i=i.substring(ye.length,i.length),e=decodeURIComponent(i)):e=i;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
2
- ${e}`);return t.documentElement}else return i}const un="px",fn=90,pe=["mm","cm","in","pt","pc","px"],ge={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 L(i){let e="px";if(typeof i=="string"||i instanceof String)for(let n=0,r=pe.length;n<r;n++){const o=pe[n];if(i.endsWith(o)){e=o,i=i.substring(0,i.length-o.length);break}}let t;return t=ge[e][un],t<0&&(t=ge[e].in*fn),t*Number.parseFloat(i)}const yn=new z,wt=new z,de=new z,me=new z;function xn(i,e,t){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=pn(i);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function pn(i){const e=new z,t=yn;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&e.translate(L(i.getAttribute("x")),L(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("("),h=o.length;if(s>0&&s<h){const c=o.slice(0,s),a=Z(o.slice(s+1));switch(t.identity(),c){case"translate":if(a.length>=1){const l=a[0];let f=0;a.length>=2&&(f=a[1]),t.translate(l,f)}break;case"rotate":if(a.length>=1){let l=0,f=0,y=0;l=a[0]*Math.PI/180,a.length>=3&&(f=a[1],y=a[2]),wt.makeTranslation(-f,-y),de.makeRotation(l),me.multiplyMatrices(de,wt),wt.makeTranslation(f,y),t.multiplyMatrices(wt,me)}break;case"scale":a.length>=1&&t.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&t.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&t.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&t.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}e.premultiply(t)}}return e}function gn(i){return new j().addPath(new rt().arc(L(i.getAttribute("cx")||0),L(i.getAttribute("cy")||0),L(i.getAttribute("r")||0),0,Math.PI*2))}function dn(i,e){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let t=0;t<i.sheet.cssRules.length;t++){const n=i.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,h=0;h<s;h++){const c=n.style.item(h);o[c]=n.style.getPropertyValue(c)}for(let s=0;s<r.length;s++)e[r[s]]=Object.assign(e[r[s]]||{},{...o})}}function mn(i){return new j().addPath(new rt().ellipse(L(i.getAttribute("cx")||0),L(i.getAttribute("cy")||0),L(i.getAttribute("rx")||0),L(i.getAttribute("ry")||0),0,0,Math.PI*2))}function Mn(i){return new j().moveTo(L(i.getAttribute("x1")||0),L(i.getAttribute("y1")||0)).lineTo(L(i.getAttribute("x2")||0),L(i.getAttribute("y2")||0))}function Pn(i){const e=new j,t=i.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const wn=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function vn(i){var n;const e=new j;let t=0;return(n=i.getAttribute("points"))==null||n.replace(wn,(r,o,s)=>{const h=L(o),c=L(s);return t===0?e.moveTo(h,c):e.lineTo(h,c),t++,r}),e.currentPath.autoClose=!0,e}const Tn=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Cn(i){var n;const e=new j;let t=0;return(n=i.getAttribute("points"))==null||n.replace(Tn,(r,o,s)=>{const h=L(o),c=L(s);return t===0?e.moveTo(h,c):e.lineTo(h,c),t++,r}),e.currentPath.autoClose=!1,e}function An(i){const e=L(i.getAttribute("x")||0),t=L(i.getAttribute("y")||0),n=L(i.getAttribute("rx")||i.getAttribute("ry")||0),r=L(i.getAttribute("ry")||i.getAttribute("rx")||0),o=L(i.getAttribute("width")),s=L(i.getAttribute("height")),h=1-.551915024494,c=new j;return c.moveTo(e+n,t),c.lineTo(e+o-n,t),(n!==0||r!==0)&&c.bezierCurveTo(e+o-n*h,t,e+o,t+r*h,e+o,t+r),c.lineTo(e+o,t+s-r),(n!==0||r!==0)&&c.bezierCurveTo(e+o,t+s-r*h,e+o-n*h,t+s,e+o-n,t+s),c.lineTo(e+n,t+s),(n!==0||r!==0)&&c.bezierCurveTo(e+n*h,t+s,e,t+s-r*h,e,t+s-r),c.lineTo(e,t+r),(n!==0||r!==0)&&c.bezierCurveTo(e,t+r*h,e+n*h,t,e+n,t),c}function B(i,e,t){e=Object.assign({},e);let n={};if(i.hasAttribute("class")){const a=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)n=Object.assign(n,t[`.${a[l]}`])}i.hasAttribute("id")&&(n=Object.assign(n,t[`#${i.getAttribute("id")}`]));for(let a=i.style.length,l=0;l<a;l++){const f=i.style.item(l),y=i.style.getPropertyValue(f);e[f]=y,n[f]=y}function r(a,l,f=o){i.hasAttribute(a)&&(e[l]=f(i.getAttribute(a))),n[a]&&(e[l]=f(n[a]))}function o(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function s(a){return Math.max(0,Math.min(1,L(a)))}function h(a){return Math.max(0,L(a))}function c(a){return a.split(" ").filter(l=>l!=="").map(l=>L(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",h),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",h),r("stroke-dasharray","strokeDasharray",c),r("stroke-dashoffset","strokeDashoffset",L),r("visibility","visibility"),e}function _t(i,e,t=[],n={}){var f;if(i.nodeType!==1)return t;let r=!1,o=null,s={...e};switch(i.nodeName){case"svg":s=B(i,s,n);break;case"style":dn(i,n);break;case"g":s=B(i,s,n);break;case"path":s=B(i,s,n),i.hasAttribute("d")&&(o=Pn(i));break;case"rect":s=B(i,s,n),o=An(i);break;case"polygon":s=B(i,s,n),o=vn(i);break;case"polyline":s=B(i,s,n),o=Cn(i);break;case"circle":s=B(i,s,n),o=gn(i);break;case"ellipse":s=B(i,s,n),o=mn(i);break;case"line":s=B(i,s,n),o=Mn(i);break;case"defs":r=!0;break;case"use":{s=B(i,s,n);const x=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),u=(f=i.viewportElement)==null?void 0:f.getElementById(x);u?_t(u,s,t,n):console.warn(`'use node' references non-existent node id: ${x}`);break}default:console.warn(i);break}if(s.display==="none")return t;Object.assign(e,s);const h=new z,c=[],a=xn(i,h,c);o&&(o.applyTransform(h),t.push(o),o.style=e);const l=i.childNodes;for(let y=0,x=l.length;y<x;y++){const u=l[y];r&&u.nodeName!=="style"&&u.nodeName!=="defs"||_t(u,e,t,n)}return a&&(c.pop(),c.length>0?h.copy(c[c.length-1]):h.identity()),t}function bn(i){return new le(_t(xe(i),{}))}v.ArcCurve=re,v.BoundingBox=V,v.CompositeCurve=mt,v.CubicBezierCurve=Mt,v.Curve=Y,v.CurvePath=rt,v.EllipseCurve=oe,v.EquilateralPloygonCurve=hn,v.LineCurve=G,v.Matrix3=z,v.Path2D=j,v.Path2DSet=le,v.PloygonCurve=Ft,v.QuadraticBezierCurve=Pt,v.RectangleCurve=ce,v.RoundRectangleCurve=he,v.SplineCurve=ae,v.Vector2=m,v.catmullRom=St,v.cubicBezier=Et,v.drawPoint=R,v.fillTriangulate=Wt,v.getAdaptiveCubicBezierCurvePoints=Ht,v.getAdaptiveQuadraticBezierCurvePoints=Qt,v.parseArcCommand=Zt,v.parsePathDataArgs=Z,v.quadraticBezier=qt,v.setCanvasContext=At,v.strokeTriangulate=Jt,v.svgPathCommandsAddToPath2D=kt,v.svgPathCommandsToData=jt,v.svgPathDataToCommands=It,v.svgToDOM=xe,v.svgToPath2DSet=bn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
1
+ (function(v,R){typeof exports=="object"&&typeof module<"u"?R(exports):typeof define=="function"&&define.amd?define(["exports"],R):(v=typeof globalThis<"u"?globalThis:v||self,R(v.modernPath2d={}))})(this,function(v){"use strict";var En=Object.defineProperty;var Ln=(v,R,st)=>R in v?En(v,R,{enumerable:!0,configurable:!0,writable:!0,value:st}):v[R]=st;var V=(v,R,st)=>Ln(v,typeof R!="symbol"?R+"":R,st);function R(i,e,t,n={}){const{radius:r=1}=n;i.moveTo(e,t),i.arc(e,t,r,0,Math.PI*2)}const st={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function At(i,e){const{fill:t="#000",stroke:n="none",strokeWidth:r=n==="none"?0:1,strokeLinecap:o="round",strokeLinejoin:s="miter",strokeMiterlimit:h=0,strokeDasharray:c=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:x="rgba(0, 0, 0, 0)"}=e;i.fillStyle=t,i.strokeStyle=n,i.lineWidth=r,i.lineCap=o,i.lineJoin=st[s],i.miterLimit=h,i.setLineDash(c),i.lineDashOffset=a,i.shadowOffsetX=l,i.shadowOffsetY=y,i.shadowBlur=f,i.shadowColor=x}class p{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new p(1/0,1/0)}static get MIN(){return new p(-1/0,-1/0)}get array(){return[this.x,this.y]}set(e,t){return this.x=e,this.y=t,this}add(e){return this.x+=e.x,this.y+=e.y,this}sub(e){return this.x-=e.x,this.y-=e.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}divide(e){return this.x/=e.x,this.y/=e.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}rotate(e,t={x:0,y:0}){const n=-e/180*Math.PI,r=this.x-t.x,o=-(this.y-t.y),s=Math.sin(n),h=Math.cos(n);return this.set(t.x+(r*h-o*s),t.y-(r*s+o*h)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,n={x:0,y:0}){const r=e<0?n.x-this.x+n.x:this.x,o=t<0?n.y-this.y+n.y:this.y;return this.x=r*Math.abs(e),this.y=o*Math.abs(t),this}skew(e,t=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(e)*o),this.y=n.y+(o+Math.tan(t)*r),this}min(...e){return this.x=Math.min(this.x,...e.map(t=>t.x)),this.y=Math.min(this.y,...e.map(t=>t.y)),this}max(...e){return this.x=Math.max(this.x,...e.map(t=>t.x)),this.y=Math.max(this.y,...e.map(t=>t.y)),this}normalize(){return this.scale(1/(this.length()||1))}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this}divideVectors(e,t){return this.x=e.x/t.x,this.y=e.y/t.y,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new p(this.x,this.y)}}class B{constructor(e=0,t=0,n=0,r=0){this.left=e,this.top=t,this.width=n,this.height=r}get x(){return this.left}set x(e){this.left=e}get y(){return this.top}set y(e){this.top=e}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return new p((this.left+this.right)/2,(this.top+this.bottom)/2)}get array(){return[this.left,this.top,this.width,this.height]}static from(...e){if(e.length===0)return new B;if(e.length===1)return e[0].clone();const t=e[0],n=e.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:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new B(n.left,n.top,n.right-n.left,n.bottom-n.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new B(this.left,this.top,this.width,this.height)}}class z{constructor(e=1,t=0,n=0,r=0,o=1,s=0,h=0,c=0,a=1){V(this,"elements",[]);this.set(e,t,n,r,o,s,h,c,a)}set(e,t,n,r,o,s,h,c,a){const l=this.elements;return l[0]=e,l[1]=r,l[2]=h,l[3]=t,l[4]=o,l[5]=c,l[6]=n,l[7]=s,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,s=n[0],h=n[3],c=n[6],a=n[1],l=n[4],y=n[7],f=n[2],x=n[5],u=n[8],m=r[0],M=r[3],b=r[6],S=r[1],P=r[4],w=r[7],k=r[2],E=r[5],g=r[8];return o[0]=s*m+h*S+c*k,o[3]=s*M+h*P+c*E,o[6]=s*b+h*w+c*g,o[1]=a*m+l*S+y*k,o[4]=a*M+l*P+y*E,o[7]=a*b+l*w+y*g,o[2]=f*m+x*S+u*k,o[5]=f*M+x*P+u*E,o[8]=f*b+x*w+u*g,this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],s=e[4],h=e[5],c=e[6],a=e[7],l=e[8],y=l*s-h*a,f=h*c-l*o,x=a*o-s*c,u=t*y+n*f+r*x;if(u===0)return this.set(0,0,0,0,0,0,0,0,0);const m=1/u;return e[0]=y*m,e[1]=(r*a-l*n)*m,e[2]=(h*n-r*s)*m,e[3]=f*m,e[4]=(l*t-r*c)*m,e[5]=(r*o-h*t)*m,e[6]=x*m,e[7]=(n*c-a*t)*m,e[8]=(s*t-n*o)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(bt.makeScale(e,t)),this}rotate(e){return this.premultiply(bt.makeRotation(-e)),this}translate(e,t){return this.premultiply(bt.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const bt=new z;function zt(i,e,t,n){const r=i*t+e*n,o=Math.sqrt(i*i+e*e)*Math.sqrt(t*t+n*n);let s=Math.acos(Math.max(-1,Math.min(1,r/o)));return i*n-e*t<0&&(s=-s),s}function Zt(i,e,t,n,r,o,s,h){if(e===0||t===0){i.lineTo(h.x,h.y);return}n=n*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const c=(s.x-h.x)/2,a=(s.y-h.y)/2,l=Math.cos(n)*c+Math.sin(n)*a,y=-Math.sin(n)*c+Math.cos(n)*a;let f=e*e,x=t*t;const u=l*l,m=y*y,M=u/f+m/x;if(M>1){const O=Math.sqrt(M);e=O*e,t=O*t,f=e*e,x=t*t}const b=f*m+x*u,S=(f*x-b)/b;let P=Math.sqrt(Math.max(0,S));r===o&&(P=-P);const w=P*e*y/t,k=-P*t*l/e,E=Math.cos(n)*w-Math.sin(n)*k+(s.x+h.x)/2,g=Math.sin(n)*w+Math.cos(n)*k+(s.y+h.y)/2,d=zt(1,0,(l-w)/e,(y-k)/t),q=zt((l-w)/e,(y-k)/t,(-l-w)/e,(-y-k)/t)%(Math.PI*2);i.ellipse(E,g,e,t,n,d,d+q,o===0)}const D={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function Z(i,e,t=0){let h=0,c=!0,a="",l="";const y=[];function f(M,b,S){const P=new SyntaxError(`Unexpected character "${M}" at index ${b}.`);throw P.partial=S,P}function x(){a!==""&&(l===""?y.push(Number(a)):y.push(Number(a)*10**Number(l))),a="",l=""}let u;const m=i.length;for(let M=0;M<m;M++){if(u=i[M],Array.isArray(e)&&e.includes(y.length%t)&&D.FLAGS.test(u)){h=1,a=u,x();continue}if(h===0){if(D.WHITESPACE.test(u))continue;if(D.DIGIT.test(u)||D.SIGN.test(u)){h=1,a=u;continue}if(D.POINT.test(u)){h=2,a=u;continue}D.COMMA.test(u)&&(c&&f(u,M,y),c=!0)}if(h===1){if(D.DIGIT.test(u)){a+=u;continue}if(D.POINT.test(u)){a+=u,h=2;continue}if(D.EXP.test(u)){h=3;continue}D.SIGN.test(u)&&a.length===1&&D.SIGN.test(a[0])&&f(u,M,y)}if(h===2){if(D.DIGIT.test(u)){a+=u;continue}if(D.EXP.test(u)){h=3;continue}D.POINT.test(u)&&a[a.length-1]==="."&&f(u,M,y)}if(h===3){if(D.DIGIT.test(u)){l+=u;continue}if(D.SIGN.test(u)){if(l===""){l+=u;continue}l.length===1&&D.SIGN.test(l)&&f(u,M,y)}}D.WHITESPACE.test(u)?(x(),h=0,c=!1):D.COMMA.test(u)?(x(),h=0,c=!0):D.SIGN.test(u)?(x(),h=1,a=u):D.POINT.test(u)?(x(),h=2,a=u):f(u,M,y)}return x(),y}function it(i,e){return i-(e-i)}function kt(i,e){const t=new p,n=new p;for(let r=0,o=i.length;r<o;r++){const s=i[r];if(s.type==="m"||s.type==="M")s.type==="m"?t.add(s):t.copy(s),e.moveTo(t.x,t.y),n.copy(t);else if(s.type==="h"||s.type==="H")s.type==="h"?t.x+=s.x:t.x=s.x,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="v"||s.type==="V")s.type==="v"?t.y+=s.y:t.y=s.y,e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="l"||s.type==="L")s.type==="l"?t.add(s):t.copy(s),e.lineTo(t.x,t.y),n.copy(t);else if(s.type==="c"||s.type==="C")s.type==="c"?(e.bezierCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(s.x1,s.y1,s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="s"||s.type==="S")s.type==="s"?(e.bezierCurveTo(it(t.x,n.x),it(t.y,n.y),t.x+s.x2,t.y+s.y2,t.x+s.x,t.y+s.y),n.x=t.x+s.x2,n.y=t.y+s.y2,t.add(s)):(e.bezierCurveTo(it(t.x,n.x),it(t.y,n.y),s.x2,s.y2,s.x,s.y),n.x=s.x2,n.y=s.y2,t.copy(s));else if(s.type==="q"||s.type==="Q")s.type==="q"?(e.quadraticCurveTo(t.x+s.x1,t.y+s.y1,t.x+s.x,t.y+s.y),n.x=t.x+s.x1,n.y=t.y+s.y1,t.add(s)):(e.quadraticCurveTo(s.x1,s.y1,s.x,s.y),n.x=s.x1,n.y=s.y1,t.copy(s));else if(s.type==="t"||s.type==="T"){const h=it(t.x,n.x),c=it(t.y,n.y);n.x=h,n.y=c,s.type==="t"?(e.quadraticCurveTo(h,c,t.x+s.x,t.y+s.y),t.add(s)):(e.quadraticCurveTo(h,c,s.x,s.y),t.copy(s))}else if(s.type==="a"||s.type==="A"){const h=t.clone();if(s.type==="a"){if(s.x===0&&s.y===0)continue;t.add(s)}else{if(t.equals(s))continue;t.copy(s)}n.copy(t),Zt(e,s.rx,s.ry,s.angle,s.largeArcFlag,s.sweepFlag,h,t)}else s.type==="z"||s.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",s)}}function jt(i){let e,t;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)===(t==null?void 0:t.x.toFixed(4))&&s.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;n.push(`${s.type} ${s.x} ${s.y}`),t={x:s.x,y:s.y},e={x:s.x,y:s.y};break;case"h":case"H":n.push(`${s.type} ${s.x}`),t={x:s.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":n.push(`${s.type} ${s.y}`),t={x:(t==null?void 0:t.x)??0,y:s.y};break;case"l":case"L":n.push(`${s.type} ${s.x} ${s.y}`),t={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}`),t={x:s.x,y:s.y};break;case"s":case"S":n.push(`${s.type} ${s.x2} ${s.y2} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"q":case"Q":n.push(`${s.type} ${s.x1} ${s.y1} ${s.x} ${s.y}`),t={x:s.x,y:s.y};break;case"t":case"T":n.push(`${s.type} ${s.x} ${s.y}`),t={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}`),t={x:s.x,y:s.y};break;case"z":case"Z":n.push(s.type),e&&(t={x:e.x,y:e.y});break}}return n.join(" ")}const Ce=/[a-df-z][^a-df-z]*/gi;function It(i){const e=[],t=i.match(Ce);if(!t)return e;for(let n=0,r=t.length;n<r;n++){const o=t[n],s=o.charAt(0),h=o.slice(1).trim();let c;switch(s){case"m":case"M":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)a===0?e.push({type:s,x:c[a],y:c[a+1]}):e.push({type:s==="m"?"l":"L",x:c[a],y:c[a+1]});break;case"h":case"H":c=Z(h);for(let a=0,l=c.length;a<l;a++)e.push({type:s,x:c[a]});break;case"v":case"V":c=Z(h);for(let a=0,l=c.length;a<l;a++)e.push({type:s,y:c[a]});break;case"l":case"L":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)e.push({type:s,x:c[a],y:c[a+1]});break;case"c":case"C":c=Z(h);for(let a=0,l=c.length;a<l;a+=6)e.push({type:s,x1:c[a],y1:c[a+1],x2:c[a+2],y2:c[a+3],x:c[a+4],y:c[a+5]});break;case"s":case"S":c=Z(h);for(let a=0,l=c.length;a<l;a+=4)e.push({type:s,x2:c[a],y2:c[a+1],x:c[a+2],y:c[a+3]});break;case"q":case"Q":c=Z(h);for(let a=0,l=c.length;a<l;a+=4)e.push({type:s,x1:c[a],y1:c[a+1],x:c[a+2],y:c[a+3]});break;case"t":case"T":c=Z(h);for(let a=0,l=c.length;a<l;a+=2)e.push({type:s,x:c[a],y:c[a+1]});break;case"a":case"A":c=Z(h,[3,4],7);for(let a=0,l=c.length;a<l;a+=7)e.push({type:s,rx:c[a],ry:c[a+1],angle:c[a+2],largeArcFlag:c[a+3],sweepFlag:c[a+4],x:c[a+5],y:c[a+6]});break;case"z":case"Z":e.push({type:s});break;default:console.warn(o)}}return e}function St(i,e,t,n,r){const o=(n-e)*.5,s=(r-t)*.5,h=i*i,c=i*h;return(2*t-2*n+o+s)*c+(-3*t+3*n-2*o-s)*h+o*i+t}function Ae(i,e){const t=1-i;return t*t*t*e}function be(i,e){const t=1-i;return 3*t*t*i*e}function ke(i,e){return 3*(1-i)*i*i*e}function Ie(i,e){return i*i*i*e}function Et(i,e,t,n,r){return Ae(i,e)+be(i,t)+ke(i,n)+Ie(i,r)}function Se(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Ut(i,0,r,t,!0);const s=[];if(!o||o.next===o.prev)return s;let h,c,a;if(n&&(o=De(i,e,o,t)),i.length>80*t){h=1/0,c=1/0;let l=-1/0,y=-1/0;for(let f=t;f<r;f+=t){const x=i[f],u=i[f+1];x<h&&(h=x),u<c&&(c=u),x>l&&(l=x),u>y&&(y=u)}a=Math.max(l-h,y-c),a=a!==0?32767/a:0}return ot(o,s,t,h,c,a,0),s}function Ut(i,e,t,n,r){let o;if(r===Ge(i,e,t,n)>0)for(let s=e;s<t;s+=n)o=Vt(s/n|0,i[s],i[s+1],o);else for(let s=t-n;s>=e;s-=n)o=Vt(s/n|0,i[s],i[s+1],o);return o&&rt(o,o.next)&&(at(o),o=o.next),o}function H(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(rt(t,t.next)||N(t.prev,t,t.next)===0)){if(at(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function ot(i,e,t,n,r,o,s){if(!i)return;!s&&o&&Re(i,n,r,o);let h=i;for(;i.prev!==i.next;){const c=i.prev,a=i.next;if(o?Le(i,n,r,o):Ee(i)){e.push(c.i,i.i,a.i),at(i),i=a.next,h=a.next;continue}if(i=a,i===h){s?s===1?(i=$e(H(i),e),ot(i,e,t,n,r,o,2)):s===2&&Ne(i,e,t,n,r,o):ot(H(i),e,t,n,r,o,1);break}}}function Ee(i){const e=i.prev,t=i,n=i.next;if(N(e,t,n)>=0)return!1;const r=e.x,o=t.x,s=n.x,h=e.y,c=t.y,a=n.y,l=Math.min(r,o,s),y=Math.min(h,c,a),f=Math.max(r,o,s),x=Math.max(h,c,a);let u=n.next;for(;u!==e;){if(u.x>=l&&u.x<=f&&u.y>=y&&u.y<=x&&ct(r,h,o,c,s,a,u.x,u.y)&&N(u.prev,u,u.next)>=0)return!1;u=u.next}return!0}function Le(i,e,t,n){const r=i.prev,o=i,s=i.next;if(N(r,o,s)>=0)return!1;const h=r.x,c=o.x,a=s.x,l=r.y,y=o.y,f=s.y,x=Math.min(h,c,a),u=Math.min(l,y,f),m=Math.max(h,c,a),M=Math.max(l,y,f),b=Lt(x,u,e,t,n),S=Lt(m,M,e,t,n);let P=i.prevZ,w=i.nextZ;for(;P&&P.z>=b&&w&&w.z<=S;){if(P.x>=x&&P.x<=m&&P.y>=u&&P.y<=M&&P!==r&&P!==s&&ct(h,l,c,y,a,f,P.x,P.y)&&N(P.prev,P,P.next)>=0||(P=P.prevZ,w.x>=x&&w.x<=m&&w.y>=u&&w.y<=M&&w!==r&&w!==s&&ct(h,l,c,y,a,f,w.x,w.y)&&N(w.prev,w,w.next)>=0))return!1;w=w.nextZ}for(;P&&P.z>=b;){if(P.x>=x&&P.x<=m&&P.y>=u&&P.y<=M&&P!==r&&P!==s&&ct(h,l,c,y,a,f,P.x,P.y)&&N(P.prev,P,P.next)>=0)return!1;P=P.prevZ}for(;w&&w.z<=S;){if(w.x>=x&&w.x<=m&&w.y>=u&&w.y<=M&&w!==r&&w!==s&&ct(h,l,c,y,a,f,w.x,w.y)&&N(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function $e(i,e){let t=i;do{const n=t.prev,r=t.next.next;!rt(n,r)&&Gt(n,t,t.next,r)&&ht(n,r)&&ht(r,n)&&(e.push(n.i,t.i,r.i),at(t),at(t.next),t=i=r),t=t.next}while(t!==i);return H(t)}function Ne(i,e,t,n,r,o){let s=i;do{let h=s.next.next;for(;h!==s.prev;){if(s.i!==h.i&&je(s,h)){let c=Bt(s,h);s=H(s,s.next),c=H(c,c.next),ot(s,e,t,n,r,o,0),ot(c,e,t,n,r,o,0);return}h=h.next}s=s.next}while(s!==i)}function De(i,e,t,n){const r=[];for(let o=0,s=e.length;o<s;o++){const h=e[o]*n,c=o<s-1?e[o+1]*n:i.length,a=Ut(i,h,c,n,!1);a===a.next&&(a.steiner=!0),r.push(Ze(a))}r.sort(qe);for(let o=0;o<r.length;o++)t=Oe(r[o],t);return t}function qe(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function Oe(i,e){const t=Fe(i,e);if(!t)return e;const n=Bt(t,i);return H(n,n.next),H(t,t.next)}function Fe(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,s;if(rt(i,t))return t;do{if(rt(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const y=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(y<=n&&y>o&&(o=y,s=t.x<t.next.x?t:t.next,y===n))return s}t=t.next}while(t!==e);if(!s)return null;const h=s,c=s.x,a=s.y;let l=1/0;t=s;do{if(n>=t.x&&t.x>=c&&n!==t.x&&Xt(r<a?n:o,r,c,a,r<a?o:n,r,t.x,t.y)){const y=Math.abs(r-t.y)/(n-t.x);ht(t,i)&&(y<l||y===l&&(t.x>s.x||t.x===s.x&&_e(s,t)))&&(s=t,l=y)}t=t.next}while(t!==h);return s}function _e(i,e){return N(i.prev,i,e.prev)<0&&N(e.next,i,i.next)<0}function Re(i,e,t,n){let r=i;do r.z===0&&(r.z=Lt(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,ze(r)}function ze(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let s=n,h=0;for(let a=0;a<t&&(h++,s=s.nextZ,!!s);a++);let c=t;for(;h>0||c>0&&s;)h!==0&&(c===0||!s||n.z<=s.z)?(r=n,n=n.nextZ,h--):(r=s,s=s.nextZ,c--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=s}o.nextZ=null,t*=2}while(e>1);return i}function Lt(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function Ze(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Xt(i,e,t,n,r,o,s,h){return(r-s)*(e-h)>=(i-s)*(o-h)&&(i-s)*(n-h)>=(t-s)*(e-h)&&(t-s)*(o-h)>=(r-s)*(n-h)}function ct(i,e,t,n,r,o,s,h){return!(i===s&&e===h)&&Xt(i,e,t,n,r,o,s,h)}function je(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Ue(i,e)&&(ht(i,e)&&ht(e,i)&&Xe(i,e)&&(N(i.prev,i,e.prev)||N(i,e.prev,e))||rt(i,e)&&N(i.prev,i,i.next)>0&&N(e.prev,e,e.next)>0)}function N(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function rt(i,e){return i.x===e.x&&i.y===e.y}function Gt(i,e,t,n){const r=pt(N(i,e,t)),o=pt(N(i,e,n)),s=pt(N(t,n,i)),h=pt(N(t,n,e));return!!(r!==o&&s!==h||r===0&&xt(i,t,e)||o===0&&xt(i,n,e)||s===0&&xt(t,i,n)||h===0&&xt(t,e,n))}function xt(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function pt(i){return i>0?1:i<0?-1:0}function Ue(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&Gt(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function ht(i,e){return N(i.prev,i,i.next)<0?N(i,e,i.next)>=0&&N(i,i.prev,e)>=0:N(i,e,i.prev)<0||N(i,i.next,e)<0}function Xe(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function Bt(i,e){const t=$t(i.i,i.x,i.y),n=$t(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function Vt(i,e,t,n){const r=$t(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function at(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,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Ge(i,e,t,n){let r=0;for(let o=e,s=t-n;o<t;o+=n)r+=(i[s]-i[o])*(i[o+1]+i[s+1]),s=o;return r}function Wt(i,e={}){let{vertices:t=[],indices:n=[],holes:r=[],verticesStride:o=2,verticesOffset:s=0,indicesOffset:h=0}=e;const c=Se(i,r,2);if(c){for(let l=0;l<c.length;l+=3)n[h++]=c[l]+s,n[h++]=c[l+1]+s,n[h++]=c[l+2]+s;let a=s*o;for(let l=0;l<i.length;l+=2)t[a]=i[l],t[a+1]=i[l+1],a+=o}return{vertices:t,indices:n}}const Be=8,gt=11920929e-14,Ve=1;function Ht(i,e,t,n,r,o,s,h,c=.5,a){const y=Math.min(.99,Math.max(0,c));let f=(Ve-y)/1;return f*=f,Nt(i,e,t,n,r,o,s,h,a,f,0),a.push(s,h),a}function Nt(i,e,t,n,r,o,s,h,c,a,l){if(l>Be)return;const y=(i+t)/2,f=(e+n)/2,x=(t+r)/2,u=(n+o)/2,m=(r+s)/2,M=(o+h)/2,b=(y+x)/2,S=(f+u)/2,P=(x+m)/2,w=(u+M)/2,k=(b+P)/2,E=(S+w)/2;if(l>0){let g=s-i,d=h-e;const q=Math.abs((t-s)*d-(n-h)*g),O=Math.abs((r-s)*d-(o-h)*g);if(q>gt&&O>gt){if((q+O)*(q+O)<=a*(g*g+d*d)){c.push(k,E);return}}else if(q>gt){if(q*q<=a*(g*g+d*d)){c.push(k,E);return}}else if(O>gt){if(O*O<=a*(g*g+d*d)){c.push(k,E);return}}else if(g=k-(i+s)/2,d=E-(e+h)/2,g*g+d*d<=a){c.push(k,E);return}}Nt(i,e,y,f,b,S,k,E,c,a,l+1),Nt(k,E,P,w,m,M,s,h,c,a,l+1)}const We=8,He=11920929e-14,Qe=1;function Qt(i,e,t,n,r,o,s=.5,h){const a=Math.min(.99,Math.max(0,s));let l=(Qe-a)/1;return l*=l,Dt(h,i,e,t,n,r,o,l,0),h.push(r,o),h}function Dt(i,e,t,n,r,o,s,h,c){if(c>We)return;const a=(e+n)/2,l=(t+r)/2,y=(n+o)/2,f=(r+s)/2,x=(a+y)/2,u=(l+f)/2;let m=o-e,M=s-t;const b=Math.abs((n-o)*M-(r-s)*m);if(b>He){if(b*b<=h*(m*m+M*M)){i.push(x,u);return}}else if(m=x-(e+o)/2,M=u-(t+s)/2,m*m+M*M<=h){i.push(x,u);return}Dt(i,e,t,a,l,x,u,h,c+1),Dt(i,x,u,y,f,o,s,h,c+1)}function Ye(i,e){const t=1-i;return t*t*e}function Je(i,e){return 2*(1-i)*i*e}function Ke(i,e){return i*i*e}function qt(i,e,t,n){return Ye(i,e)+Je(i,t)+Ke(i,n)}const tn=1e-4,Yt=1e-4;function Jt(i,e={}){const{vertices:t=[],indices:n=[],lineStyle:r={alignment:.5,cap:"butt",join:"miter",width:1,miterLimit:10},flipAlignment:o=!1,closed:s=!0}=e,h=tn;if(i.length===0)return{vertices:t,indices:n};const c=r;let a=c.alignment;if(r.alignment!==.5){let $=en(i);o&&($*=-1),a=(a-.5)*$+.5}const l={x:i[0],y:i[1]},y={x:i[i.length-2],y:i[i.length-1]},f=s,x=Math.abs(l.x-y.x)<h&&Math.abs(l.y-y.y)<h;if(f){i=i.slice(),x&&(i.pop(),i.pop(),y.x=i[i.length-2],y.y=i[i.length-1]);const $=(l.x+y.x)*.5,W=(y.y+l.y)*.5;i.unshift($,W),i.push($,W)}const u=t,m=i.length/2;let M=i.length;const b=u.length/2,S=c.width/2,P=S*S,w=c.miterLimit*c.miterLimit;let k=i[0],E=i[1],g=i[2],d=i[3],q=0,O=0,C=-(E-d),A=k-g,F=0,_=0,U=Math.sqrt(C*C+A*A);C/=U,A/=U,C*=S,A*=S;const Me=a,T=(1-Me)*2,I=Me*2;f||(c.cap==="round"?M+=Q(k-C*(T-I)*.5,E-A*(T-I)*.5,k-C*T,E-A*T,k+C*I,E+A*I,u,!0)+2:c.cap==="square"&&(M+=Kt(k,E,C,A,T,I,!0,u))),u.push(k-C*T,E-A*T),u.push(k+C*I,E+A*I);for(let $=1;$<m-1;++$){k=i[($-1)*2],E=i[($-1)*2+1],g=i[$*2],d=i[$*2+1],q=i[($+1)*2],O=i[($+1)*2+1],C=-(E-d),A=k-g,U=Math.sqrt(C*C+A*A),C/=U,A/=U,C*=S,A*=S,F=-(d-O),_=g-q,U=Math.sqrt(F*F+_*_),F/=U,_/=U,F*=S,_*=S;const W=g-k,lt=E-d,ut=g-q,yt=O-d,Pe=W*ut+lt*yt,vt=lt*ut-yt*W,ft=vt<0;if(Math.abs(vt)<.001*Math.abs(Pe)){u.push(g-C*T,d-A*T),u.push(g+C*I,d+A*I),Pe>=0&&(c.join==="round"?M+=Q(g,d,g-C*T,d-A*T,g-F*T,d-_*T,u,!1)+4:M+=2,u.push(g-F*I,d-_*I),u.push(g+F*T,d+_*T));continue}const we=(-C+k)*(-A+d)-(-C+g)*(-A+E),ve=(-F+q)*(-_+d)-(-F+g)*(-_+O),Tt=(W*ve-ut*we)/vt,Ct=(yt*we-lt*ve)/vt,Rt=(Tt-g)*(Tt-g)+(Ct-d)*(Ct-d),K=g+(Tt-g)*T,tt=d+(Ct-d)*T,et=g-(Tt-g)*I,nt=d-(Ct-d)*I,In=Math.min(W*W+lt*lt,ut*ut+yt*yt),Te=ft?T:I,Sn=In+Te*Te*P;Rt<=Sn?c.join==="bevel"||Rt/P>w?(ft?(u.push(K,tt),u.push(g+C*I,d+A*I),u.push(K,tt),u.push(g+F*I,d+_*I)):(u.push(g-C*T,d-A*T),u.push(et,nt),u.push(g-F*T,d-_*T),u.push(et,nt)),M+=2):c.join==="round"?ft?(u.push(K,tt),u.push(g+C*I,d+A*I),M+=Q(g,d,g+C*I,d+A*I,g+F*I,d+_*I,u,!0)+4,u.push(K,tt),u.push(g+F*I,d+_*I)):(u.push(g-C*T,d-A*T),u.push(et,nt),M+=Q(g,d,g-C*T,d-A*T,g-F*T,d-_*T,u,!1)+4,u.push(g-F*T,d-_*T),u.push(et,nt)):(u.push(K,tt),u.push(et,nt)):(u.push(g-C*T,d-A*T),u.push(g+C*I,d+A*I),c.join==="round"?ft?M+=Q(g,d,g+C*I,d+A*I,g+F*I,d+_*I,u,!0)+2:M+=Q(g,d,g-C*T,d-A*T,g-F*T,d-_*T,u,!1)+2:c.join==="miter"&&Rt/P<=w&&(ft?(u.push(et,nt),u.push(et,nt)):(u.push(K,tt),u.push(K,tt)),M+=2),u.push(g-F*T,d-_*T),u.push(g+F*I,d+_*I),M+=2)}k=i[(m-2)*2],E=i[(m-2)*2+1],g=i[(m-1)*2],d=i[(m-1)*2+1],C=-(E-d),A=k-g,U=Math.sqrt(C*C+A*A),C/=U,A/=U,C*=S,A*=S,u.push(g-C*T,d-A*T),u.push(g+C*I,d+A*I),f||(c.cap==="round"?M+=Q(g-C*(T-I)*.5,d-A*(T-I)*.5,g-C*T,d-A*T,g+C*I,d+A*I,u,!1)+2:c.cap==="square"&&(M+=Kt(g,d,C,A,T,I,!1,u)));const kn=Yt*Yt;for(let $=b;$<M+b-2;++$)k=u[$*2],E=u[$*2+1],g=u[($+1)*2],d=u[($+1)*2+1],q=u[($+2)*2],O=u[($+2)*2+1],!(Math.abs(k*(d-O)+g*(O-E)+q*(E-d))<kn)&&n.push($,$+1,$+2);return{vertices:t,indices:n}}function en(i){const e=i.length;if(e<6)return 1;let t=0;for(let n=0,r=i[e-2],o=i[e-1];n<e;n+=2){const s=i[n],h=i[n+1];t+=(s-r)*(h+o),r=s,o=h}return t<0?-1:1}function Kt(i,e,t,n,r,o,s,h){const c=i-t*r,a=e-n*r,l=i+t*o,y=e+n*o;let f,x;s?(f=n,x=-t):(f=-n,x=t);const u=c+f,m=a+x,M=l+f,b=y+x;return h.push(u,m),h.push(M,b),2}function Q(i,e,t,n,r,o,s,h){const c=t-i,a=n-e;let l=Math.atan2(c,a),y=Math.atan2(r-i,o-e);h&&l<y?l+=Math.PI*2:!h&&l>y&&(y+=Math.PI*2);let f=l;const x=y-l,u=Math.abs(x),m=Math.sqrt(c*c+a*a),M=(15*u*Math.sqrt(m)/Math.PI>>0)+1,b=x/M;if(f+=b,h){s.push(i,e),s.push(t,n);for(let S=1,P=f;S<M;S++,P+=b)s.push(i,e),s.push(i+Math.sin(P)*m,e+Math.cos(P)*m);s.push(i,e),s.push(r,o)}else{s.push(t,n),s.push(i,e);for(let S=1,P=f;S<M;S++,P+=b)s.push(i+Math.sin(P)*m,e+Math.cos(P)*m),s.push(i,e);s.push(r,o),s.push(i,e)}return M*2}class Y{constructor(){V(this,"arcLengthDivision",200);V(this,"_arcLengths")}getPointAt(e,t=new p){return this.getPoint(this.getUToTMapping(e),t)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),n=this.getPoint(1);return(t.x-e.x)*(n.y-t.y)-(t.y-e.y)*(n.x-t.x)<0}getControlPointRefs(){return[]}applyTransform(e){return this.getControlPointRefs().forEach(t=>{t.applyMatrix3(e)}),this}getUnevenPointArray(e=5,t=[]){const n=new p;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPoint(r/o,n),t.push(n.x,n.y);return t}getSpacedPointArray(e=5,t=[]){const n=new p;for(let r=0,o=Math.max(1,e)-1;r<=o;r++)this.getPointAt(r/o,n),t.push(n.x,n.y);return t}getAdaptivePointArray(e=[]){return this.getUnevenPointArray(5,e)}_pointArrayToPoint(e,t=[]){for(let n=0,r=e.length;n<r;n+=2){const o=e[n],s=e[n+1];t.push(new p(o,s))}return t}getSpacedPoints(e,t=[]){const n=this.getSpacedPointArray(e);return this._pointArrayToPoint(n,t),t}getUnevenPoints(e,t=[]){const n=this.getUnevenPointArray(e);return this._pointArrayToPoint(n,t),t}getAdaptivePoints(e=[]){const t=this.getAdaptivePointArray();return this._pointArrayToPoint(t,e),e}getPoints(e,t=[]){let n;return e?n=this.getUnevenPointArray(e):n=this.getAdaptivePointArray(),this._pointArrayToPoint(n,t),t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(){return(!this._arcLengths||this._arcLengths.length!==this.arcLengthDivision+1)&&this.updateLengths(),this._arcLengths}updateLengths(){const e=this.arcLengthDivision,t=[0];for(let n=0,r=this.getPoint(0),o=1;o<=e;o++){const s=this.getPoint(o/e);n+=s.distanceTo(r),t.push(n),r=s}this._arcLengths=t}getUToTMapping(e,t){const n=this.getLengths(),r=n.length,o=t??e*n[r-1];if(r<2)return o/n[0];let s=0,h=0,c=r-1,a;for(;h<=c;)if(s=Math.floor(h+(c-h)/2),a=n[s]-o,a<0)h=s+1;else if(a>0)c=s-1;else{c=s;break}if(s=c,n[s]===o)return s/(r-1);const l=n[s],f=n[s+1]-l,x=(o-l)/f;return(s+x)/(r-1)}getTangent(e,t=new p){const r=Math.max(0,e-1e-4),o=Math.min(1,e+1e-4);return t.copy(this.getPoint(o).sub(this.getPoint(r)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new p){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let n=0,r=1,o=(n+r)/2;for(;r-n>t;){o=(n+r)/2;const s=this.getPoint(o);if(s.distanceTo(e)<t)return o;s.x<e.x?n=o:r=o}return o}getMinMax(e=p.MAX,t=p.MIN){const n=this.getPoints();for(let r=0,o=n.length;r<o;r++){const s=n[r];e.min(s),t.max(s)}return{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new B(e.x,e.y,t.x-e.x,t.y-e.y)}fillTriangulate(e){return Wt(this.getAdaptivePointArray(),e)}strokeTriangulate(e){return Jt(this.getAdaptivePointArray(),e)}toCommands(){const e=[],t=this.getPoints();for(let n=0,r=t.length;n<r;n++){const o=t[n];n===0?e.push({type:"M",x:o.x,y:o.y}):e.push({type:"L",x:o.x,y:o.y})}return e}toData(){return jt(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivision=e.arcLengthDivision,this}clone(){return new this.constructor().copy(this)}}const nn=new z,te=new z,ee=new z,dt=new p;class Ot extends Y{constructor(e=new p,t=new p,n=new p,r=0,o=0,s=Math.PI*2,h=!1){super(),this._center=e,this._radius=t,this._diff=n,this.rotate=r,this.startAngle=o,this.endAngle=s,this.clockwise=h}get cx(){return this._center.x}set cx(e){this._center.x=e}get cy(){return this._center.y}set cy(e){this._center.y=e}get rx(){return this._radius.x}set rx(e){this._radius.x=e}get ry(){return this._radius.y}set ry(e){this._radius.y=e}get dx(){return this._diff.x}set dx(e){this._diff.x=e}get dy(){return this._diff.y}set dy(e){this._diff.y=e}isClockwise(){return this.clockwise}getPoint(e,t=new p){const n=Math.PI*2;let r=this.endAngle-this.startAngle;const o=Math.abs(r)<Number.EPSILON;for(;r<0;)r+=n;for(;r>n;)r-=n;r<Number.EPSILON&&(o?r=0:r=n),this.clockwise&&!o&&(r===n?r=-n:r=r-n);const s=this.startAngle+e*r;let h=this.cx+this.rx*Math.cos(s),c=this.cy+this.ry*Math.sin(s);if(this.rotate!==0){const a=Math.cos(this.rotate),l=Math.sin(this.rotate),y=h-this.cx,f=c-this.cy;h=y*a-f*l+this.cx,c=y*l+f*a+this.cy}return t.set(h,c)}toCommands(){const{cx:e,cy:t,rx:n,ry:r,startAngle:o,endAngle:s,clockwise:h,rotate:c}=this,a=e+n*Math.cos(o)*Math.cos(c)-r*Math.sin(o)*Math.sin(c),l=t+n*Math.cos(o)*Math.sin(c)+r*Math.sin(o)*Math.cos(c),y=Math.abs(o-s),f=y>Math.PI?1:0,x=h?1:0,u=c*180/Math.PI;if(y>=2*Math.PI){const m=o+Math.PI,M=e+n*Math.cos(m)*Math.cos(c)-r*Math.sin(m)*Math.sin(c),b=t+n*Math.cos(m)*Math.sin(c)+r*Math.sin(m)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:M,y:b},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:0,sweepFlag:x,x:a,y:l}]}else{const m=e+n*Math.cos(s)*Math.cos(c)-r*Math.sin(s)*Math.sin(c),M=t+n*Math.cos(s)*Math.sin(c)+r*Math.sin(s)*Math.cos(c);return[{type:"M",x:a,y:l},{type:"A",rx:n,ry:r,angle:u,largeArcFlag:f,sweepFlag:x,x:m,y:M}]}}drawTo(e){const{cx:t,cy:n,rx:r,ry:o,rotate:s,startAngle:h,endAngle:c,clockwise:a}=this;return e.ellipse(t,n,r,o,s,h,c,!a),this}applyTransform(e){return dt.set(this.cx,this.cy),dt.applyMatrix3(e),this.cx=dt.x,this.cy=dt.y,on(e)?sn(this,e):rn(this,e),this}getControlPointRefs(){return[this._center]}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,ry:o,dx:s,dy:h}=this;if(!(r>=0&&o>=0&&s>=0&&h>=0))return e;const c=Math.ceil(2.3*Math.sqrt(r+o)),a=c*8+(s?4:0)+(h?4:0);if(a===0)return e;const l=[];if(c===0)l[0]=l[6]=t+s,l[1]=l[3]=n+h,l[2]=l[4]=t-s,l[5]=l[7]=n-h;else{let y=0,f=c*4+(s?2:0)+2,x=f,u=a,m=s+r,M=h,b=t+m,S=t-m,P=n+M;if(l[y++]=b,l[y++]=P,l[--f]=P,l[--f]=S,h){const k=n-M;l[x++]=S,l[x++]=k,l[--u]=k,l[--u]=b}for(let k=1;k<c;k++){const E=Math.PI/2*(k/c),g=s+Math.cos(E)*r,d=h+Math.sin(E)*o,q=t+g,O=t-g,C=n+d,A=n-d;l[y++]=q,l[y++]=C,l[--f]=C,l[--f]=O,l[x++]=O,l[x++]=A,l[--u]=A,l[--u]=q}m=s,M=h+o,b=t+m,S=t-m,P=n+M;const w=n-M;l[y++]=b,l[y++]=P,l[--u]=w,l[--u]=b,s&&(l[y++]=S,l[y++]=P,l[--u]=w,l[--u]=S)}return Array.prototype.push.apply(e,l),e}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=0,indicesOffset:s=0}=e;const h=this.getAdaptivePointArray();if(h.length===0)return{vertices:t,indices:n};let c=0,a=0;for(let f=0;f<h.length;f+=2)c+=h[f],a+=h[f+1];c/=h.length/2,a/=h.length/2;let l=o;t[l*r]=c,t[l*r+1]=a;const y=l++;for(let f=0;f<h.length;f+=2)t[l*r]=h[f],t[l*r+1]=h[f+1],f>0&&(n[s++]=l,n[s++]=y,n[s++]=l-1),l++;return n[s++]=y+1,n[s++]=y,n[s++]=l-1,{vertices:t,indices:n}}getMinMax(e=p.MAX,t=p.MIN){const{cx:n,cy:r,rx:o,ry:s,rotate:h}=this,c=Math.cos(h),a=Math.sin(h),l=Math.sqrt(o*o*c*c+s*s*a*a),y=Math.sqrt(o*o*a*a+s*s*c*c);return e.x=Math.min(e.x,n-l),e.y=Math.min(e.y,r-y),t.x=Math.max(t.x,n+l),t.y=Math.max(t.y,r+y),{min:e,max:t}}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.rx=e.rx,this.ry=e.ry,this.dx=e.dx,this.dy=e.dy,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotate=e.rotate,this}}function sn(i,e){const t=i.rx,n=i.ry,r=Math.cos(i.rotate),o=Math.sin(i.rotate),s=new p(t*r,t*o),h=new p(-n*o,n*r),c=s.applyMatrix3(e),a=h.applyMatrix3(e),l=nn.set(c.x,a.x,0,c.y,a.y,0,0,0,1),y=te.copy(l).invert(),u=ee.copy(y).transpose().multiply(y).elements,m=cn(u[0],u[1],u[4]),M=Math.sqrt(m.rt1),b=Math.sqrt(m.rt2);if(i.rx=1/M,i.ry=1/b,i.rotate=Math.atan2(m.sn,m.cs),!((i.endAngle-i.startAngle)%(2*Math.PI)<Number.EPSILON)){const P=te.set(M,0,0,0,b,0,0,0,1),w=ee.set(m.cs,m.sn,0,-m.sn,m.cs,0,0,0,1),k=P.multiply(w).multiply(l),E=g=>{const{x:d,y:q}=new p(Math.cos(g),Math.sin(g)).applyMatrix3(k);return Math.atan2(q,d)};i.startAngle=E(i.startAngle),i.endAngle=E(i.endAngle),ne(e)&&(i.clockwise=!i.clockwise)}}function rn(i,e){const t=se(e),n=ie(e);i.rx*=t,i.ry*=n;const r=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);i.rotate+=r,ne(e)&&(i.startAngle*=-1,i.endAngle*=-1,i.clockwise=!i.clockwise)}function ne(i){const e=i.elements;return e[0]*e[4]-e[1]*e[3]<0}function on(i){const e=i.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const n=se(i),r=ie(i);return Math.abs(t/(n*r))>Number.EPSILON}function se(i){const e=i.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ie(i){const e=i.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function cn(i,e,t){let n,r,o,s,h;const c=i+t,a=i-t,l=Math.sqrt(a*a+4*e*e);return c>0?(n=.5*(c+l),h=1/n,r=i*h*t-e*h*e):c<0?r=.5*(c-l):(n=.5*l,r=-.5*l),a>0?o=a+l:o=a-l,Math.abs(o)>2*Math.abs(e)?(h=-2*e/o,s=1/Math.sqrt(1+h*h),o=h*s):Math.abs(e)===0?(o=1,s=0):(h=-.5*o/e,o=1/Math.sqrt(1+h*h),s=h*o),a>0&&(h=o,o=-s,s=h),{rt1:n,rt2:r,cs:o,sn:s}}class re extends Ot{constructor(e=0,t=0,n=1,r=0,o=Math.PI*2,s=!1){super(new p(e,t),new p(n,n),new p(0,0),0,r,o,s)}drawTo(e){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:h}=this;return e.arc(t,n,r,o,s,!h),this}getAdaptivePointArray(e=[]){const{cx:t,cy:n,rx:r,startAngle:o,endAngle:s,clockwise:h}=this;let c=Math.abs(o-s);(!h&&o>s||h&&s>o)&&(c=2*Math.PI-c);let a=Math.max(6,Math.floor(6*r**(1/3)*(c/Math.PI)));a=Math.max(a,3);let l=c/a,y=o;l*=h?1:-1;for(let f=0;f<a+1;f++){const x=Math.cos(y),u=Math.sin(y),m=t+x*r,M=n+u*r;e.push(m,M),y+=l}return e}}class mt extends Y{constructor(e=[]){super(),this.curves=e}addCurve(e){return this.curves.push(e),this}getPoint(e,t=new p){const n=e*this.getLength(),r=this.getLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const s=r[o]-n,h=this.curves[o],c=h.getLength();return h.getPointAt(c===0?0:1-s/c,t)}o++}return t}updateLengths(){const e=[];for(let t=0,n=0,r=this.curves.length;t<r;t++)n+=this.curves[t].getLength(),e.push(n);this._arcLengths=e}getControlPointRefs(){return this.curves.flatMap(e=>e.getControlPointRefs())}getAdaptivePointArray(e=[]){let t;return this.curves.forEach(n=>{n.getAdaptivePointArray(e),t&&e[t-1]===e[t+1]&&e[t]===e[t+2]&&e.splice(t+1,2),t=e.length-1}),e}getMinMax(e=p.MAX,t=p.MIN){return this.curves.forEach(n=>n.getMinMax(e,t)),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new B(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.curves.flatMap(e=>e.toCommands())}drawTo(e){var n;const t=(n=this.curves[0])==null?void 0:n.getPoint(0);return t&&e.moveTo(t.x,t.y),this.curves.forEach(r=>r.drawTo(e)),this}copy(e){return super.copy(e),this.curves=e.curves.map(t=>t.clone()),this}}class Mt extends Y{constructor(e=new p,t=new p,n=new p,r=new p){super(),this.p1=e,this.cp1=t,this.cp2=n,this.p2=r}static from(e,t,n,r,o,s,h,c){return new Mt(new p(e,t),new p(n,r),new p(o,s),new p(h,c))}getPoint(e,t=new p){const{p1:n,cp1:r,cp2:o,p2:s}=this;return t.set(Et(e,n.x,r.x,o.x,s.x),Et(e,n.y,r.y,o.y,s.y))}getAdaptivePointArray(e=[]){return Ht(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,e)}getControlPointRefs(){return[this.p1,this.cp1,this.cp2,this.p2]}_solveQuadratic(e,t,n){const r=t*t-4*e*n;if(r<0)return[];const o=Math.sqrt(r),s=(-t+o)/(2*e),h=(-t-o)/(2*e);return[s,h].filter(c=>c>=0&&c<=1)}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,cp1:r,cp2:o,p2:s}=this,h=this._solveQuadratic(3*(r.x-n.x),6*(o.x-r.x),3*(s.x-o.x)),c=this._solveQuadratic(3*(r.y-n.y),6*(o.y-r.y),3*(s.y-o.y)),a=[0,1,...h,...c];return((y,f)=>{for(const x of y)for(let u=0;u<=f;u++){const m=u/f-.5,M=Math.min(1,Math.max(0,x+m)),b=this.getPoint(M);e.x=Math.min(e.x,b.x),e.y=Math.min(e.y,b.y),t.x=Math.max(t.x,b.x),t.y=Math.max(t.y,b.y)}})(a,10),{min:e,max:t}}toCommands(){const{p1:e,cp1:t,cp2:n,p2:r}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:n.x,y2:n.y,x:r.x,y:r.y}]}drawTo(e){const{p1:t,cp1:n,cp2:r,p2:o}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(n.x,n.y,r.x,r.y,o.x,o.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp1.copy(e.cp1),this.cp2.copy(e.cp2),this.p2.copy(e.p2),this}}class oe extends Ot{constructor(e=0,t=0,n=1,r=1,o=0,s=0,h=Math.PI*2,c=!1){super(new p(e,t),new p(n,r),new p,o,s,h,c)}drawTo(e){return e.ellipse(this.cx,this.cy,this.rx,this.ry,this.rotate,this.startAngle,this.endAngle,!this.clockwise),this}}class X extends Y{constructor(e=new p,t=new p){super(),this.p1=e,this.p2=t}static from(e,t,n,r){return new X(new p(e,t),new p(n,r))}getPoint(e,t=new p){return e===1?t.copy(this.p2):t.copy(this.p2).sub(this.p1).scale(e).add(this.p1),t}getPointAt(e,t=new p){return this.getPoint(e,t)}getTangent(e,t=new p){return t.subVectors(this.p2,this.p1).normalize()}getTangentAt(e,t=new p){return this.getTangent(e,t)}getControlPointRefs(){return[this.p1,this.p2]}getAdaptivePointArray(e=[]){return e.push(this.p1.x,this.p1.y,this.p2.x,this.p2.y),e}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,p2:r}=this;return e.x=Math.min(e.x,n.x,r.x),e.y=Math.min(e.y,n.y,r.y),t.x=Math.max(t.x,n.x,r.x),t.y=Math.max(t.y,n.y,r.y),{min:e,max:t}}toCommands(){const{p1:e,p2:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{p1:t,p2:n}=this;return e.lineTo(t.x,t.y),e.lineTo(n.x,n.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.p2.copy(e.p2),this}}class Ft extends mt{}class hn extends Ft{constructor(e=0,t=0,n=1,r=3){super(),this.cx=e,this.cy=t,this.radius=n,this.sideCount=r,this.update()}update(){const{cx:e,cy:t,radius:n,sideCount:r}=this,o=[];for(let h=0;h<r;h++){const c=h*2*Math.PI/r-.5*Math.PI;o.push(new p(n*Math.cos(c),n*Math.sin(c)).add({x:e,y:t}))}const s=[];for(let h=0;h<r;h++)s.push(new X(o[h],o[(h+1)%r]));return this.curves=s,this}copy(e){return super.copy(e),this.cx=e.cx,this.cy=e.cy,this.radius=e.radius,this.sideCount=e.sideCount,this.update(),this}}class Pt extends Y{constructor(e=new p,t=new p,n=new p){super(),this.p1=e,this.cp=t,this.p2=n}static from(e,t,n,r,o,s){return new Pt(new p(e,t),new p(n,r),new p(o,s))}getPoint(e,t=new p){const{p1:n,cp:r,p2:o}=this;return t.set(qt(e,n.x,r.x,o.x),qt(e,n.y,r.y,o.y)),t}getControlPointRefs(){return[this.p1,this.cp,this.p2]}getAdaptivePointArray(e=[]){return Qt(this.p1.x,this.p1.y,this.cp.x,this.cp.y,this.p2.x,this.p2.y,.5,e)}getMinMax(e=p.MAX,t=p.MIN){const{p1:n,cp:r,p2:o}=this,s=.5*(n.x+r.x),h=.5*(n.y+r.y),c=.5*(n.x+o.x),a=.5*(n.y+o.y);return e.x=Math.min(e.x,n.x,o.x,s,c),e.y=Math.min(e.y,n.y,o.y,h,a),t.x=Math.max(t.x,n.x,o.x,s,c),t.y=Math.max(t.y,n.y,o.y,h,a),{min:e,max:t}}toCommands(){const{p1:e,cp:t,p2:n}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:n.x,y:n.y}]}drawTo(e){const{p1:t,cp:n,p2:r}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(n.x,n.y,r.x,r.y),this}copy(e){return super.copy(e),this.p1.copy(e.p1),this.cp.copy(e.cp),this.p2.copy(e.p2),this}}class ce extends Ft{constructor(e=0,t=0,n=0,r=0){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.update()}update(){const{x:e,y:t,width:n,height:r}=this,o=[new p(e,t),new p(e+n,t),new p(e+n,t+r),new p(e,t+r)];return this.curves=[new X(o[0],o[1]),new X(o[1],o[2]),new X(o[2],o[3]),new X(o[3],o[0])],this}drawTo(e){return e.rect(this.x,this.y,this.width,this.height),this}fillTriangulate(e={}){let{vertices:t=[],indices:n=[],verticesStride:r=2,verticesOffset:o=0,indicesOffset:s=0}=e;const{x:h,y:c,width:a,height:l}=this,y=[h,c,h+a,c,h+a,c+l,h,c+l];let f=0;o*=r,t[o+f]=y[0],t[o+f+1]=y[1],f+=r,t[o+f]=y[2],t[o+f+1]=y[3],f+=r,t[o+f]=y[6],t[o+f+1]=y[7],f+=r,t[o+f]=y[4],t[o+f+1]=y[5],f+=r;const x=o/r;return n[s++]=x,n[s++]=x+1,n[s++]=x+2,n[s++]=x+1,n[s++]=x+3,n[s++]=x+2,{vertices:t,indices:n}}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.update(),this}}class he extends Ot{constructor(e=0,t=0,n=1,r=1,o=1){super(),this.x=e,this.y=t,this.width=n,this.height=r,this.radius=o,this.update()}update(){const{x:e,y:t,width:n,height:r,radius:o}=this,s=n/2,h=r/2,c=e+s,a=t+h,l=Math.max(0,Math.min(o,Math.min(s,h))),y=l,f=s-l,x=h-y;return this._center=new p(c,a),this._radius=new p(l,y),this._diff=new p(f,x),this}drawTo(e){const{x:t,y:n,width:r,height:o,radius:s}=this;return e.roundRect(t,n,r,o,s),this}copy(e){return super.copy(e),this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this.radius=e.radius,this.update(),this}}class ae extends Y{constructor(e=[]){super(),this.points=e}getPoint(e,t=new p){const{points:n}=this,r=(n.length-1)*e,o=Math.floor(r),s=r-o,h=n[o===0?o:o-1],c=n[o],a=n[o>n.length-2?n.length-1:o+1],l=n[o>n.length-3?n.length-1:o+2];return t.set(St(s,h.x,c.x,a.x,l.x),St(s,h.y,c.y,a.y,l.y)),t}getControlPointRefs(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++)this.points.push(e.points[t].clone());return this}}class J extends mt{constructor(t){super();V(this,"startPoint");V(this,"currentPoint");V(this,"autoClose",!1);t&&this.addPoints(t)}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let n=1,r=t.length;n<r;n++){const{x:o,y:s}=t[n];this.lineTo(o,s)}return this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}getUnevenPointArray(t=40,n=[]){return super.getUnevenPointArray(t,n),this.autoClose&&n.length>=4&&n[0]!==n[n.length-2]&&n[1]!==n[n.length-1]&&n.push(n[0],n[1]),n}getSpacedPointArray(t=40,n=[]){return super.getSpacedPointArray(t,n),this.autoClose&&n.length>=4&&n[0]!==n[n.length-2]&&n[1]!==n[n.length-1]&&n.push(n[0],n[1]),n}_setCurrentPoint(t){return this.currentPoint=new p(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}_connetLineTo(t){if(this.curves.length>0){const n=t.getPoint(0);(!this.currentPoint||!n.equals(this.currentPoint))&&this.lineTo(n.x,n.y)}return this}closePath(){const t=this.startPoint;if(t){const n=this.currentPoint;n&&!t.equals(n)&&(this.curves.push(new X(n,t)),n.copy(t)),this.startPoint=void 0}return this}moveTo(t,n){return this.currentPoint=new p(t,n),this.startPoint=this.currentPoint.clone(),this}lineTo(t,n){const r=this.currentPoint;return r!=null&&r.equals({x:t,y:n})||this.curves.push(X.from((r==null?void 0:r.x)??0,(r==null?void 0:r.y)??0,t,n)),this._setCurrentPoint({x:t,y:n}),this}bezierCurveTo(t,n,r,o,s,h){const c=this.currentPoint;return c!=null&&c.equals({x:s,y:h})||this.curves.push(Mt.from((c==null?void 0:c.x)??0,(c==null?void 0:c.y)??0,t,n,r,o,s,h)),this._setCurrentPoint({x:s,y:h}),this}quadraticCurveTo(t,n,r,o){const s=this.currentPoint;return s!=null&&s.equals({x:r,y:o})||this.curves.push(Pt.from((s==null?void 0:s.x)??0,(s==null?void 0:s.y)??0,t,n,r,o)),this._setCurrentPoint({x:r,y:o}),this}arc(t,n,r,o,s,h){const c=new re(t,n,r,o,s,!h);return this._connetLineTo(c),this.curves.push(c),this._setCurrentPoint(c.getPoint(1)),this}relativeArc(t,n,r,o,s,h){var c,a;return t+=((c=this.currentPoint)==null?void 0:c.x)??0,n+=((a=this.currentPoint)==null?void 0:a.y)??0,this.arc(t,n,r,o,s,h),this}arcTo(t,n,r,o,s){return console.warn("Method arcTo not supported yet"),this}ellipse(t,n,r,o,s,h,c,a=!0){const l=new oe(t,n,r,o,s,h,c,!a);return this._connetLineTo(l),this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,n,r,o,s,h,c,a){var l,y;return t+=((l=this.currentPoint)==null?void 0:l.x)??0,n+=((y=this.currentPoint)==null?void 0:y.y)??0,this.ellipse(t,n,r,o,s,h,c,a),this}rect(t,n,r,o){const s=new ce(t,n,r,o);return this._connetLineTo(s),this.curves.push(s),this._setCurrentPoint({x:t,y:n}),this}roundRect(t,n,r,o,s){const h=new he(t,n,r,o,s);return this._connetLineTo(h),this.curves.push(h),this._setCurrentPoint({x:t,y:n}),this}splineThru(t){const n=this.currentPoint??new p;return this.curves.push(new ae([n].concat(t))),this._setCurrentPoint(t[t.length-1]),this}drawTo(t){var r;const n=(r=this.curves[0])==null?void 0:r.getPoint(0);return n&&t.moveTo(n.x,n.y),this.curves.forEach(o=>o.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var n;return super.copy(t),this.autoClose=t.autoClose,this.currentPoint=(n=t.currentPoint)==null?void 0:n.clone(),this}}function an(i){return i.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function ln(i,e,t,n){const r=e.clone().sub(i),o=n.clone().sub(t),s=t.clone().sub(i),h=r.cross(o);if(h===0)return new p((i.x+t.x)/2,(i.y+t.y)/2);const c=s.cross(o)/h;return Math.abs(c)>1?new p((i.x+t.x)/2,(i.y+t.y)/2):new p(i.x+c*r.x,i.y+c*r.y)}class j extends mt{constructor(t,n={}){super();V(this,"currentCurve",new J);V(this,"style");this.curves.push(this.currentCurve),this.style=n,t&&(t instanceof j?this.addPath(t):Array.isArray(t)?this.addCommands(t):this.addData(t))}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)}addPath(t){return t instanceof j?this.curves.push(...t.curves.map(n=>n.clone())):this.curves.push(t),this}closePath(){const t=this.startPoint;return t&&(this.currentCurve.closePath(),this.currentCurve.curves.length>0&&(this.currentCurve=new J().moveTo(t.x,t.y),this.curves.push(this.currentCurve))),this}moveTo(t,n){var r;return(r=this.currentCurve.currentPoint)!=null&&r.equals({x:t,y:n})||(this.currentCurve.curves.length&&(this.currentCurve=new J,this.curves.push(this.currentCurve)),this.currentCurve.moveTo(t,n)),this}lineTo(t,n){return this.currentCurve.lineTo(t,n),this}bezierCurveTo(t,n,r,o,s,h){return this.currentCurve.bezierCurveTo(t,n,r,o,s,h),this}quadraticCurveTo(t,n,r,o){return this.currentCurve.quadraticCurveTo(t,n,r,o),this}arc(t,n,r,o,s,h){return this.currentCurve.arc(t,n,r,o,s,h),this}arcTo(t,n,r,o,s){return this.currentCurve.arcTo(t,n,r,o,s),this}ellipse(t,n,r,o,s,h,c,a){return this.currentCurve.ellipse(t,n,r,o,s,h,c,a),this}rect(t,n,r,o){return this.currentCurve.rect(t,n,r,o),this}roundRect(t,n,r,o,s){return this.currentCurve.roundRect(t,n,r,o,s),this}reset(){return this.currentCurve=new J,this.curves.push(this.currentCurve),this.style={},this}addCommands(t){return kt(t,this),this}addData(t){return this.addCommands(It(t)),this}splineThru(t){return this.currentCurve.splineThru(t),this}scale(t,n=t,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.scale(t,n,r)}),this}skew(t,n=0,r={x:0,y:0}){return this.getControlPointRefs().forEach(o=>{o.skew(t,n,r)}),this}rotate(t,n={x:0,y:0}){return this.getControlPointRefs().forEach(r=>{r.rotate(t,n)}),this}bold(t){if(t===0)return this;const n=this.curves,r=[],o=[],s=[];n.forEach((c,a)=>{if(!c.getLength())return;const l=c.getControlPointRefs(),y=c.isClockwise();s[a]=l,o[a]=y;const f=l[0],x=l[l.length-1]??f;r.push({start:y?x:f,end:y?f:x,index:a})});const h=[];return r.forEach((c,a)=>{h[a]=[],r.forEach((l,y)=>{y!==a&&l.start.equals(c.end)&&h[a].push(l.index)})}),n.forEach((c,a)=>{if(!c.getLength())return;const l=o[a];s[a].forEach(f=>{const x=c.getTForPoint(f),u=c.getNormal(x).scale(l?t:-t);f.add(u)})}),h.forEach((c,a)=>{const l=s[a];c.forEach(y=>{const f=s[y],x=ln(l[l.length-1],l[l.length-2]??l[l.length-1],f[0],f[1]??f[0]);x&&(l[l.length-1].copy(x),f[0].copy(x))})}),this}applyTransform(t){return this.curves.forEach(n=>n.applyTransform(t)),this}getMinMax(t=p.MAX,n=p.MIN,r=!0){const o=this.strokeWidth;return this.curves.forEach(s=>{if(s.getMinMax(t,n),r&&o>1){const h=o/2,c=s.isClockwise(),a=[];for(let l=0;l<=1;l+=1/s.arcLengthDivision){const y=s.getPoint(l),f=s.getNormal(l),x=f.clone().scale(c?h:-h),u=f.clone().scale(c?-h:h);a.push(y.clone().add(x),y.clone().add(u),y.clone().add({x:h,y:0}),y.clone().add({x:-h,y:0}),y.clone().add({x:0,y:h}),y.clone().add({x:0,y:-h}),y.clone().add({x:h,y:h}),y.clone().add({x:-h,y:-h}))}t.min(...a),n.max(...a)}}),{min:t,max:n}}getBoundingBox(t=!0){const{min:n,max:r}=this.getMinMax(void 0,void 0,t);return new B(n.x,n.y,r.x-n.x,r.y-n.y)}drawTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.curves.forEach(s=>{s.drawTo(t)}),r!=="none"&&t.fill(),o!=="none"&&t.stroke(),t.restore(),this}drawControlPointsTo(t,n={}){n={...this.style,...n};const{fill:r="#000",stroke:o="none"}=n;return t.beginPath(),t.save(),At(t,n),this.getControlPointRefs().forEach(s=>{R(t,s.x,s.y,{radius:4})}),r!=="none"&&t.fill(),o!=="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"},n={};for(const o in t)t[o]!==void 0&&(n[an(o)]=t[o]);Object.assign(n,{"stroke-width":`${this.strokeWidth}px`});let r="";for(const o in n)n[o]!==void 0&&(r+=`${o}:${n[o]};`);return`<path d="${this.toData()}" style="${r}"></path>`}copy(t){return super.copy(t),this.currentCurve=t.currentCurve.clone(),this.style={...t.style},this}}class le{constructor(e=[]){this.paths=e}getBoundingBox(e=!0){if(!this.paths.length)return;const t=p.MAX,n=p.MIN;return this.paths.forEach(r=>r.getMinMax(t,n,e)),new B(t.x,t.y,n.x-t.x,n.y-t.y)}toSVGString(){const{x:e,y:t,width:n,height:r}=this.getBoundingBox(),o=this.paths.map(s=>s.toSVGPathString()).join("");return`<svg viewBox="${e} ${t} ${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(e={}){const{pixelRatio:t=2,...n}=e,{left:r,top:o,width:s,height:h}=this.getBoundingBox(),c=document.createElement("canvas");c.width=s*t,c.height=h*t,c.style.width=`${s}px`,c.style.height=`${h}px`;const a=c.getContext("2d");return a&&(a.scale(t,t),a.translate(-r,-o),this.paths.forEach(l=>{l.drawTo(a,n)})),c}}const ue="data:image/svg+xml;",ye=`${ue}base64,`,fe=`${ue}charset=utf8,`;function xe(i){if(typeof i=="string"){let e;i.startsWith(ye)?(i=i.substring(ye.length,i.length),e=atob(i)):i.startsWith(fe)?(i=i.substring(fe.length,i.length),e=decodeURIComponent(i)):e=i;const t=new DOMParser().parseFromString(e,"text/xml"),n=t.querySelector("parsererror");if(n)throw new Error(`${n.textContent??"parser error"}
2
+ ${e}`);return t.documentElement}else return i}const un="px",yn=90,pe=["mm","cm","in","pt","pc","px"],ge={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 L(i){let e="px";if(typeof i=="string"||i instanceof String)for(let n=0,r=pe.length;n<r;n++){const o=pe[n];if(i.endsWith(o)){e=o,i=i.substring(0,i.length-o.length);break}}let t;return t=ge[e][un],t<0&&(t=ge[e].in*yn),t*Number.parseFloat(i)}const fn=new z,wt=new z,de=new z,me=new z;function xn(i,e,t){if(!(i.hasAttribute("transform")||i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))))return null;const n=pn(i);return t.length>0&&n.premultiply(t[t.length-1]),e.copy(n),t.push(n),n}function pn(i){const e=new z,t=fn;if(i.nodeName==="use"&&(i.hasAttribute("x")||i.hasAttribute("y"))&&e.translate(L(i.getAttribute("x")),L(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("("),h=o.length;if(s>0&&s<h){const c=o.slice(0,s),a=Z(o.slice(s+1));switch(t.identity(),c){case"translate":if(a.length>=1){const l=a[0];let y=0;a.length>=2&&(y=a[1]),t.translate(l,y)}break;case"rotate":if(a.length>=1){let l=0,y=0,f=0;l=a[0]*Math.PI/180,a.length>=3&&(y=a[1],f=a[2]),wt.makeTranslation(-y,-f),de.makeRotation(l),me.multiplyMatrices(de,wt),wt.makeTranslation(y,f),t.multiplyMatrices(wt,me)}break;case"scale":a.length>=1&&t.scale(a[0],a[1]??a[0]);break;case"skewX":a.length===1&&t.set(1,Math.tan(a[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":a.length===1&&t.set(1,0,0,Math.tan(a[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":a.length===6&&t.set(a[0],a[2],a[4],a[1],a[3],a[5],0,0,1);break}}e.premultiply(t)}}return e}function gn(i){return new j().addPath(new J().arc(L(i.getAttribute("cx")||0),L(i.getAttribute("cy")||0),L(i.getAttribute("r")||0),0,Math.PI*2))}function dn(i,e){if(!(!i.sheet||!i.sheet.cssRules||!i.sheet.cssRules.length))for(let t=0;t<i.sheet.cssRules.length;t++){const n=i.sheet.cssRules[t];if(n.type!==1)continue;const r=n.selectorText.split(/,/g).filter(Boolean).map(s=>s.trim()),o={};for(let s=n.style.length,h=0;h<s;h++){const c=n.style.item(h);o[c]=n.style.getPropertyValue(c)}for(let s=0;s<r.length;s++)e[r[s]]=Object.assign(e[r[s]]||{},{...o})}}function mn(i){return new j().addPath(new J().ellipse(L(i.getAttribute("cx")||0),L(i.getAttribute("cy")||0),L(i.getAttribute("rx")||0),L(i.getAttribute("ry")||0),0,0,Math.PI*2))}function Mn(i){return new j().moveTo(L(i.getAttribute("x1")||0),L(i.getAttribute("y1")||0)).lineTo(L(i.getAttribute("x2")||0),L(i.getAttribute("y2")||0))}function Pn(i){const e=new j,t=i.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const wn=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function vn(i){var n;const e=new j;let t=0;return(n=i.getAttribute("points"))==null||n.replace(wn,(r,o,s)=>{const h=L(o),c=L(s);return t===0?e.moveTo(h,c):e.lineTo(h,c),t++,r}),e.currentPath.autoClose=!0,e}const Tn=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Cn(i){var n;const e=new j;let t=0;return(n=i.getAttribute("points"))==null||n.replace(Tn,(r,o,s)=>{const h=L(o),c=L(s);return t===0?e.moveTo(h,c):e.lineTo(h,c),t++,r}),e.currentPath.autoClose=!1,e}function An(i){const e=L(i.getAttribute("x")||0),t=L(i.getAttribute("y")||0),n=L(i.getAttribute("rx")||i.getAttribute("ry")||0),r=L(i.getAttribute("ry")||i.getAttribute("rx")||0),o=L(i.getAttribute("width")),s=L(i.getAttribute("height")),h=1-.551915024494,c=new j;return c.moveTo(e+n,t),c.lineTo(e+o-n,t),(n!==0||r!==0)&&c.bezierCurveTo(e+o-n*h,t,e+o,t+r*h,e+o,t+r),c.lineTo(e+o,t+s-r),(n!==0||r!==0)&&c.bezierCurveTo(e+o,t+s-r*h,e+o-n*h,t+s,e+o-n,t+s),c.lineTo(e+n,t+s),(n!==0||r!==0)&&c.bezierCurveTo(e+n*h,t+s,e,t+s-r*h,e,t+s-r),c.lineTo(e,t+r),(n!==0||r!==0)&&c.bezierCurveTo(e,t+r*h,e+n*h,t,e+n,t),c}function G(i,e,t){e=Object.assign({},e);let n={};if(i.hasAttribute("class")){const a=i.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)n=Object.assign(n,t[`.${a[l]}`])}i.hasAttribute("id")&&(n=Object.assign(n,t[`#${i.getAttribute("id")}`]));for(let a=i.style.length,l=0;l<a;l++){const y=i.style.item(l),f=i.style.getPropertyValue(y);e[y]=f,n[y]=f}function r(a,l,y=o){i.hasAttribute(a)&&(e[l]=y(i.getAttribute(a))),n[a]&&(e[l]=y(n[a]))}function o(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function s(a){return Math.max(0,Math.min(1,L(a)))}function h(a){return Math.max(0,L(a))}function c(a){return a.split(" ").filter(l=>l!=="").map(l=>L(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",h),r("stroke-linecap","strokeLinecap"),r("stroke-linejoin","strokeLinejoin"),r("stroke-miterlimit","strokeMiterlimit",h),r("stroke-dasharray","strokeDasharray",c),r("stroke-dashoffset","strokeDashoffset",L),r("visibility","visibility"),e}function _t(i,e,t=[],n={}){var y;if(i.nodeType!==1)return t;let r=!1,o=null,s={...e};switch(i.nodeName){case"svg":s=G(i,s,n);break;case"style":dn(i,n);break;case"g":s=G(i,s,n);break;case"path":s=G(i,s,n),i.hasAttribute("d")&&(o=Pn(i));break;case"rect":s=G(i,s,n),o=An(i);break;case"polygon":s=G(i,s,n),o=vn(i);break;case"polyline":s=G(i,s,n),o=Cn(i);break;case"circle":s=G(i,s,n),o=gn(i);break;case"ellipse":s=G(i,s,n),o=mn(i);break;case"line":s=G(i,s,n),o=Mn(i);break;case"defs":r=!0;break;case"use":{s=G(i,s,n);const x=(i.getAttributeNS("http://www.w3.org/1999/xlink","href")||i.getAttribute("href")||"").substring(1),u=(y=i.viewportElement)==null?void 0:y.getElementById(x);u?_t(u,s,t,n):console.warn(`'use node' references non-existent node id: ${x}`);break}default:console.warn(i);break}if(s.display==="none")return t;Object.assign(e,s);const h=new z,c=[],a=xn(i,h,c);o&&(o.applyTransform(h),t.push(o),o.style=e);const l=i.childNodes;for(let f=0,x=l.length;f<x;f++){const u=l[f];r&&u.nodeName!=="style"&&u.nodeName!=="defs"||_t(u,e,t,n)}return a&&(c.pop(),c.length>0?h.copy(c[c.length-1]):h.identity()),t}function bn(i){return new le(_t(xe(i),{}))}v.ArcCurve=re,v.BoundingBox=B,v.CompositeCurve=mt,v.CubicBezierCurve=Mt,v.Curve=Y,v.CurvePath=J,v.EllipseCurve=oe,v.EquilateralPloygonCurve=hn,v.LineCurve=X,v.Matrix3=z,v.Path2D=j,v.Path2DSet=le,v.PloygonCurve=Ft,v.QuadraticBezierCurve=Pt,v.RectangleCurve=ce,v.RoundRectangleCurve=he,v.SplineCurve=ae,v.Vector2=p,v.catmullRom=St,v.cubicBezier=Et,v.drawPoint=R,v.fillTriangulate=Wt,v.getAdaptiveCubicBezierCurvePoints=Ht,v.getAdaptiveQuadraticBezierCurvePoints=Qt,v.parseArcCommand=Zt,v.parsePathDataArgs=Z,v.quadraticBezier=qt,v.setCanvasContext=At,v.strokeTriangulate=Jt,v.svgPathCommandsAddToPath2D=kt,v.svgPathCommandsToData=jt,v.svgPathDataToCommands=It,v.svgToDOM=xe,v.svgToPath2DSet=bn,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1573,8 +1573,6 @@ function round(cx, cy, sx, sy, ex, ey, verts, clockwise) {
1573
1573
  }
1574
1574
 
1575
1575
  class Curve {
1576
- startT = 0;
1577
- endT = 1;
1578
1576
  arcLengthDivision = 200;
1579
1577
  _arcLengths;
1580
1578
  getPointAt(u, output = new Vector2()) {
@@ -1751,19 +1749,13 @@ class Curve {
1751
1749
  }
1752
1750
  fillTriangulate(options) {
1753
1751
  return fillTriangulate(
1754
- this.getPoints().reduce((arr, p) => {
1755
- arr.push(p.x, p.y);
1756
- return arr;
1757
- }, []),
1752
+ this.getAdaptivePointArray(),
1758
1753
  options
1759
1754
  );
1760
1755
  }
1761
1756
  strokeTriangulate(options) {
1762
1757
  return strokeTriangulate(
1763
- this.getPoints().reduce((arr, p) => {
1764
- arr.push(p.x, p.y);
1765
- return arr;
1766
- }, []),
1758
+ this.getAdaptivePointArray(),
1767
1759
  options
1768
1760
  );
1769
1761
  }
@@ -1810,7 +1802,7 @@ const tempTransform1$1 = new Matrix3();
1810
1802
  const tempTransform2$1 = new Matrix3();
1811
1803
  const tempV2 = new Vector2();
1812
1804
  class RoundCurve extends Curve {
1813
- constructor(_center, _radius, _diff, rotate = 0, startAngle = 0, endAngle = Math.PI * 2, clockwise = false) {
1805
+ constructor(_center = new Vector2(), _radius = new Vector2(), _diff = new Vector2(), rotate = 0, startAngle = 0, endAngle = Math.PI * 2, clockwise = false) {
1814
1806
  super();
1815
1807
  this._center = _center;
1816
1808
  this._radius = _radius;
@@ -2085,6 +2077,8 @@ class RoundCurve extends Curve {
2085
2077
  this.cy = source.cy;
2086
2078
  this.rx = source.rx;
2087
2079
  this.ry = source.ry;
2080
+ this.dx = source.dx;
2081
+ this.dy = source.dy;
2088
2082
  this.startAngle = source.startAngle;
2089
2083
  this.endAngle = source.endAngle;
2090
2084
  this.clockwise = source.clockwise;
@@ -2243,14 +2237,13 @@ class ArcCurve extends RoundCurve {
2243
2237
  endAngle,
2244
2238
  clockwise
2245
2239
  );
2246
- this.radius = radius;
2247
2240
  }
2248
2241
  drawTo(ctx) {
2249
- const { cx, cy, radius, startAngle, endAngle, clockwise } = this;
2242
+ const { cx, cy, rx, startAngle, endAngle, clockwise } = this;
2250
2243
  ctx.arc(
2251
2244
  cx,
2252
2245
  cy,
2253
- radius,
2246
+ rx,
2254
2247
  startAngle,
2255
2248
  endAngle,
2256
2249
  !clockwise
@@ -2258,14 +2251,14 @@ class ArcCurve extends RoundCurve {
2258
2251
  return this;
2259
2252
  }
2260
2253
  getAdaptivePointArray(output = []) {
2261
- const { cx, cy, radius, startAngle, endAngle, clockwise } = this;
2254
+ const { cx, cy, rx, startAngle, endAngle, clockwise } = this;
2262
2255
  let dist = Math.abs(startAngle - endAngle);
2263
2256
  if (!clockwise && startAngle > endAngle) {
2264
2257
  dist = 2 * Math.PI - dist;
2265
2258
  } else if (clockwise && endAngle > startAngle) {
2266
2259
  dist = 2 * Math.PI - dist;
2267
2260
  }
2268
- let steps = Math.max(6, Math.floor(6 * radius ** (1 / 3) * (dist / Math.PI)));
2261
+ let steps = Math.max(6, Math.floor(6 * rx ** (1 / 3) * (dist / Math.PI)));
2269
2262
  steps = Math.max(steps, 3);
2270
2263
  let f = dist / steps;
2271
2264
  let t = startAngle;
@@ -2273,8 +2266,8 @@ class ArcCurve extends RoundCurve {
2273
2266
  for (let i = 0; i < steps + 1; i++) {
2274
2267
  const cs = Math.cos(t);
2275
2268
  const sn = Math.sin(t);
2276
- const nx = cx + cs * radius;
2277
- const ny = cy + sn * radius;
2269
+ const nx = cx + cs * rx;
2270
+ const ny = cy + sn * rx;
2278
2271
  output.push(nx, ny);
2279
2272
  t += f;
2280
2273
  }
@@ -2352,10 +2345,15 @@ class CompositeCurve extends Curve {
2352
2345
  this.curves.forEach((curve) => curve.drawTo(ctx));
2353
2346
  return this;
2354
2347
  }
2348
+ copy(source) {
2349
+ super.copy(source);
2350
+ this.curves = source.curves.map((curve) => curve.clone());
2351
+ return this;
2352
+ }
2355
2353
  }
2356
2354
 
2357
2355
  class CubicBezierCurve extends Curve {
2358
- constructor(p1, cp1, cp2, p2) {
2356
+ constructor(p1 = new Vector2(), cp1 = new Vector2(), cp2 = new Vector2(), p2 = new Vector2()) {
2359
2357
  super();
2360
2358
  this.p1 = p1;
2361
2359
  this.cp1 = cp1;
@@ -2483,7 +2481,7 @@ class EllipseCurve extends RoundCurve {
2483
2481
  }
2484
2482
 
2485
2483
  class LineCurve extends Curve {
2486
- constructor(p1, p2) {
2484
+ constructor(p1 = new Vector2(), p2 = new Vector2()) {
2487
2485
  super();
2488
2486
  this.p1 = p1;
2489
2487
  this.p2 = p2;
@@ -2558,6 +2556,15 @@ class PloygonCurve extends CompositeCurve {
2558
2556
 
2559
2557
  class EquilateralPloygonCurve extends PloygonCurve {
2560
2558
  constructor(cx = 0, cy = 0, radius = 1, sideCount = 3) {
2559
+ super();
2560
+ this.cx = cx;
2561
+ this.cy = cy;
2562
+ this.radius = radius;
2563
+ this.sideCount = sideCount;
2564
+ this.update();
2565
+ }
2566
+ update() {
2567
+ const { cx, cy, radius, sideCount } = this;
2561
2568
  const points = [];
2562
2569
  for (let i = 0; i < sideCount; i++) {
2563
2570
  const radian = i * 2 * Math.PI / sideCount - 0.5 * Math.PI;
@@ -2577,16 +2584,22 @@ class EquilateralPloygonCurve extends PloygonCurve {
2577
2584
  )
2578
2585
  );
2579
2586
  }
2580
- super(curves);
2581
- this.cx = cx;
2582
- this.cy = cy;
2583
- this.radius = radius;
2584
- this.sideCount = sideCount;
2587
+ this.curves = curves;
2588
+ return this;
2589
+ }
2590
+ copy(source) {
2591
+ super.copy(source);
2592
+ this.cx = source.cx;
2593
+ this.cy = source.cy;
2594
+ this.radius = source.radius;
2595
+ this.sideCount = source.sideCount;
2596
+ this.update();
2597
+ return this;
2585
2598
  }
2586
2599
  }
2587
2600
 
2588
2601
  class QuadraticBezierCurve extends Curve {
2589
- constructor(p1, cp, p2) {
2602
+ constructor(p1 = new Vector2(), cp = new Vector2(), p2 = new Vector2()) {
2590
2603
  super();
2591
2604
  this.p1 = p1;
2592
2605
  this.cp = cp;
@@ -2658,22 +2671,28 @@ class QuadraticBezierCurve extends Curve {
2658
2671
 
2659
2672
  class RectangleCurve extends PloygonCurve {
2660
2673
  constructor(x = 0, y = 0, width = 0, height = 0) {
2674
+ super();
2675
+ this.x = x;
2676
+ this.y = y;
2677
+ this.width = width;
2678
+ this.height = height;
2679
+ this.update();
2680
+ }
2681
+ update() {
2682
+ const { x, y, width, height } = this;
2661
2683
  const points = [
2662
2684
  new Vector2(x, y),
2663
2685
  new Vector2(x + width, y),
2664
2686
  new Vector2(x + width, y + height),
2665
2687
  new Vector2(x, y + height)
2666
2688
  ];
2667
- super([
2689
+ this.curves = [
2668
2690
  new LineCurve(points[0], points[1]),
2669
2691
  new LineCurve(points[1], points[2]),
2670
2692
  new LineCurve(points[2], points[3]),
2671
2693
  new LineCurve(points[3], points[0])
2672
- ]);
2673
- this.x = x;
2674
- this.y = y;
2675
- this.width = width;
2676
- this.height = height;
2694
+ ];
2695
+ return this;
2677
2696
  }
2678
2697
  drawTo(ctx) {
2679
2698
  ctx.rect(this.x, this.y, this.width, this.height);
@@ -2721,10 +2740,29 @@ class RectangleCurve extends PloygonCurve {
2721
2740
  indices[indicesOffset++] = verticesIndex + 2;
2722
2741
  return { vertices, indices };
2723
2742
  }
2743
+ copy(source) {
2744
+ super.copy(source);
2745
+ this.x = source.x;
2746
+ this.y = source.y;
2747
+ this.width = source.width;
2748
+ this.height = source.height;
2749
+ this.update();
2750
+ return this;
2751
+ }
2724
2752
  }
2725
2753
 
2726
2754
  class RoundRectangleCurve extends RoundCurve {
2727
2755
  constructor(x = 0, y = 0, width = 1, height = 1, radius = 1) {
2756
+ super();
2757
+ this.x = x;
2758
+ this.y = y;
2759
+ this.width = width;
2760
+ this.height = height;
2761
+ this.radius = radius;
2762
+ this.update();
2763
+ }
2764
+ update() {
2765
+ const { x, y, width, height, radius } = this;
2728
2766
  const halfWidth = width / 2;
2729
2767
  const halfHeight = height / 2;
2730
2768
  const cx = x + halfWidth;
@@ -2733,22 +2771,26 @@ class RoundRectangleCurve extends RoundCurve {
2733
2771
  const ry = rx;
2734
2772
  const dx = halfWidth - rx;
2735
2773
  const dy = halfHeight - ry;
2736
- super(
2737
- new Vector2(cx, cy),
2738
- new Vector2(rx, ry),
2739
- new Vector2(dx, dy)
2740
- );
2741
- this.x = x;
2742
- this.y = y;
2743
- this.width = width;
2744
- this.height = height;
2745
- this.radius = radius;
2774
+ this._center = new Vector2(cx, cy);
2775
+ this._radius = new Vector2(rx, ry);
2776
+ this._diff = new Vector2(dx, dy);
2777
+ return this;
2746
2778
  }
2747
2779
  drawTo(ctx) {
2748
2780
  const { x, y, width, height, radius } = this;
2749
2781
  ctx.roundRect(x, y, width, height, radius);
2750
2782
  return this;
2751
2783
  }
2784
+ copy(source) {
2785
+ super.copy(source);
2786
+ this.x = source.x;
2787
+ this.y = source.y;
2788
+ this.width = source.width;
2789
+ this.height = source.height;
2790
+ this.radius = source.radius;
2791
+ this.update();
2792
+ return this;
2793
+ }
2752
2794
  }
2753
2795
 
2754
2796
  class SplineCurve extends Curve {
@@ -2989,10 +3031,6 @@ class CurvePath extends CompositeCurve {
2989
3031
  }
2990
3032
  copy(source) {
2991
3033
  super.copy(source);
2992
- this.curves = [];
2993
- for (let i = 0, len = source.curves.length; i < len; i++) {
2994
- this.curves.push(source.curves[i].clone());
2995
- }
2996
3034
  this.autoClose = source.autoClose;
2997
3035
  this.currentPoint = source.currentPoint?.clone();
2998
3036
  return this;
@@ -3113,6 +3151,12 @@ class Path2D extends CompositeCurve {
3113
3151
  this.currentCurve.roundRect(x, y, width, height, radii);
3114
3152
  return this;
3115
3153
  }
3154
+ reset() {
3155
+ this.currentCurve = new CurvePath();
3156
+ this.curves.push(this.currentCurve);
3157
+ this.style = {};
3158
+ return this;
3159
+ }
3116
3160
  addCommands(commands) {
3117
3161
  svgPathCommandsAddToPath2D(commands, this);
3118
3162
  return this;
@@ -3310,14 +3354,11 @@ class Path2D extends CompositeCurve {
3310
3354
  return `<path d="${this.toData()}" style="${cssText}"></path>`;
3311
3355
  }
3312
3356
  copy(source) {
3357
+ super.copy(source);
3313
3358
  this.currentCurve = source.currentCurve.clone();
3314
- this.curves = source.curves.map((path) => path.clone());
3315
3359
  this.style = { ...source.style };
3316
3360
  return this;
3317
3361
  }
3318
- clone() {
3319
- return new this.constructor().copy(this);
3320
- }
3321
3362
  }
3322
3363
 
3323
3364
  class Path2DSet {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "1.2.1",
4
+ "version": "1.2.3",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "A modern Path2D library, fully compatible with Web Path2D, with additional support for path animation, path deformation, path playback, etc.",
7
7
  "author": "wxm",