modern-path2d 0.2.7 → 0.2.9

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
@@ -252,15 +252,9 @@ class BoundingBox {
252
252
  }
253
253
  }
254
254
 
255
- var __defProp$6 = Object.defineProperty;
256
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
257
- var __publicField$6 = (obj, key, value) => {
258
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
259
- return value;
260
- };
261
255
  class Matrix3 {
256
+ elements = [];
262
257
  constructor(n11 = 1, n12 = 0, n13 = 0, n21 = 0, n22 = 1, n23 = 0, n31 = 0, n32 = 0, n33 = 1) {
263
- __publicField$6(this, "elements", []);
264
258
  this.set(n11, n12, n13, n21, n22, n23, n31, n32, n33);
265
259
  }
266
260
  set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
@@ -497,7 +491,7 @@ function parseArcCommand(path, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, s
497
491
  const cy = Math.sin(xAxisRotation) * cxp + Math.cos(xAxisRotation) * cyp + (start.y + end.y) / 2;
498
492
  const theta = svgAngle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
499
493
  const delta = svgAngle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry) % (Math.PI * 2);
500
- path.ellipse(cx, cy, rx, ry, xAxisRotation, theta, theta + delta, sweepFlag === 1);
494
+ path.ellipse(cx, cy, rx, ry, xAxisRotation, theta, theta + delta, sweepFlag === 0);
501
495
  }
502
496
 
503
497
  function getReflection(a, b) {
@@ -698,8 +692,7 @@ function parsePathDataArgs(input, flags, stride = 0) {
698
692
  if (number !== "") {
699
693
  if (exponent === "")
700
694
  result.push(Number(number));
701
- else
702
- result.push(Number(number) * 10 ** Number(exponent));
695
+ else result.push(Number(number) * 10 ** Number(exponent));
703
696
  }
704
697
  number = "";
705
698
  exponent = "";
@@ -808,69 +801,69 @@ function parsePathDataArgs(input, flags, stride = 0) {
808
801
  function pathCommandsToPathData(commands) {
809
802
  let first;
810
803
  let prev;
811
- let data = "";
804
+ const data = [];
812
805
  for (let i = 0, len = commands.length; i < len; i++) {
813
806
  const cmd = commands[i];
814
807
  switch (cmd.type) {
815
808
  case "m":
816
809
  case "M":
817
- if (cmd.x === prev?.x && cmd.y === prev?.y) {
810
+ if (cmd.x.toFixed(4) === prev?.x.toFixed(4) && cmd.y.toFixed(4) === prev?.y.toFixed(4)) {
818
811
  continue;
819
812
  }
820
- data += `${cmd.type} ${cmd.x} ${cmd.y}`;
813
+ data.push(`${cmd.type} ${cmd.x} ${cmd.y}`);
821
814
  prev = { x: cmd.x, y: cmd.y };
822
815
  first = { x: cmd.x, y: cmd.y };
823
816
  break;
824
817
  case "h":
825
818
  case "H":
826
- data += `${cmd.type} ${cmd.x}`;
819
+ data.push(`${cmd.type} ${cmd.x}`);
827
820
  prev = { x: cmd.x, y: prev?.y ?? 0 };
828
821
  break;
829
822
  case "v":
830
823
  case "V":
831
- data += `${cmd.type} ${cmd.y}`;
824
+ data.push(`${cmd.type} ${cmd.y}`);
832
825
  prev = { x: prev?.x ?? 0, y: cmd.y };
833
826
  break;
834
827
  case "l":
835
828
  case "L":
836
- data += `${cmd.type} ${cmd.x} ${cmd.y}`;
829
+ data.push(`${cmd.type} ${cmd.x} ${cmd.y}`);
837
830
  prev = { x: cmd.x, y: cmd.y };
838
831
  break;
839
832
  case "c":
840
833
  case "C":
841
- data += `${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`;
834
+ data.push(`${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`);
842
835
  prev = { x: cmd.x, y: cmd.y };
843
836
  break;
844
837
  case "s":
845
838
  case "S":
846
- data += `${cmd.type} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`;
839
+ data.push(`${cmd.type} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`);
847
840
  prev = { x: cmd.x, y: cmd.y };
848
841
  break;
849
842
  case "q":
850
843
  case "Q":
851
- data += `${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x} ${cmd.y}`;
844
+ data.push(`${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x} ${cmd.y}`);
852
845
  prev = { x: cmd.x, y: cmd.y };
853
846
  break;
854
847
  case "t":
855
848
  case "T":
856
- data += `${cmd.type} ${cmd.x} ${cmd.y}`;
849
+ data.push(`${cmd.type} ${cmd.x} ${cmd.y}`);
857
850
  prev = { x: cmd.x, y: cmd.y };
858
851
  break;
859
852
  case "a":
860
853
  case "A":
861
- data += `${cmd.type} ${cmd.rx} ${cmd.ry} ${cmd.angle} ${cmd.largeArcFlag} ${cmd.sweepFlag} ${cmd.x} ${cmd.y}`;
854
+ data.push(`${cmd.type} ${cmd.rx} ${cmd.ry} ${cmd.angle} ${cmd.largeArcFlag} ${cmd.sweepFlag} ${cmd.x} ${cmd.y}`);
862
855
  prev = { x: cmd.x, y: cmd.y };
863
856
  break;
864
857
  case "z":
865
858
  case "Z":
866
- data += cmd.type;
859
+ data.push(cmd.type);
867
860
  if (first) {
868
861
  prev = { x: first.x, y: first.y };
869
862
  }
870
863
  break;
871
864
  }
872
865
  }
873
- return data;
866
+ return data.join(" ");
874
867
  }
875
868
 
876
869
  const RE$2 = /[a-df-z][^a-df-z]*/gi;
@@ -999,18 +992,10 @@ function pathDataToPathCommands(d) {
999
992
  return commands;
1000
993
  }
1001
994
 
1002
- var __defProp$5 = Object.defineProperty;
1003
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1004
- var __publicField$5 = (obj, key, value) => {
1005
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
1006
- return value;
1007
- };
1008
995
  class Curve {
1009
- constructor() {
1010
- __publicField$5(this, "arcLengthDivisions", 200);
1011
- __publicField$5(this, "_cacheArcLengths");
1012
- __publicField$5(this, "_needsUpdate", false);
1013
- }
996
+ arcLengthDivisions = 200;
997
+ _cacheArcLengths;
998
+ _needsUpdate = false;
1014
999
  isClockwise() {
1015
1000
  const prev = this.getPoint(1);
1016
1001
  const cur = this.getPoint(0.5);
@@ -1364,10 +1349,8 @@ class EllipseCurve extends Curve {
1364
1349
  const twoPi = Math.PI * 2;
1365
1350
  let deltaAngle = this.endAngle - this.startAngle;
1366
1351
  const samePoints = Math.abs(deltaAngle) < Number.EPSILON;
1367
- while (deltaAngle < 0)
1368
- deltaAngle += twoPi;
1369
- while (deltaAngle > twoPi)
1370
- deltaAngle -= twoPi;
1352
+ while (deltaAngle < 0) deltaAngle += twoPi;
1353
+ while (deltaAngle > twoPi) deltaAngle -= twoPi;
1371
1354
  if (deltaAngle < Number.EPSILON) {
1372
1355
  if (samePoints) {
1373
1356
  deltaAngle = 0;
@@ -1679,12 +1662,6 @@ class LineCurve extends Curve {
1679
1662
  }
1680
1663
  }
1681
1664
 
1682
- var __defProp$4 = Object.defineProperty;
1683
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1684
- var __publicField$4 = (obj, key, value) => {
1685
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1686
- return value;
1687
- };
1688
1665
  class HeartCurve extends Curve {
1689
1666
  constructor(center, size, start = 0, end = 1) {
1690
1667
  super();
@@ -1692,9 +1669,9 @@ class HeartCurve extends Curve {
1692
1669
  this.size = size;
1693
1670
  this.start = start;
1694
1671
  this.end = end;
1695
- __publicField$4(this, "curveT", 0);
1696
1672
  this.update();
1697
1673
  }
1674
+ curveT = 0;
1698
1675
  update() {
1699
1676
  const { x, y } = this.center;
1700
1677
  const A = new Vector2(x + 0.5 * this.size, y - 0.5 * this.size);
@@ -1765,12 +1742,6 @@ class HeartCurve extends Curve {
1765
1742
  }
1766
1743
  }
1767
1744
 
1768
- var __defProp$3 = Object.defineProperty;
1769
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1770
- var __publicField$3 = (obj, key, value) => {
1771
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1772
- return value;
1773
- };
1774
1745
  class PloygonCurve extends Curve {
1775
1746
  constructor(center, radius = 0, number = 0, start = 0, end = 1) {
1776
1747
  super();
@@ -1779,11 +1750,11 @@ class PloygonCurve extends Curve {
1779
1750
  this.number = number;
1780
1751
  this.start = start;
1781
1752
  this.end = end;
1782
- __publicField$3(this, "curves", []);
1783
- __publicField$3(this, "curveT", 0);
1784
- __publicField$3(this, "points", []);
1785
1753
  this.update();
1786
1754
  }
1755
+ curves = [];
1756
+ curveT = 0;
1757
+ points = [];
1787
1758
  update() {
1788
1759
  for (let i = 0; i < this.number; i++) {
1789
1760
  let radian = i * 2 * Math.PI / this.number;
@@ -1892,12 +1863,6 @@ class QuadraticBezierCurve extends Curve {
1892
1863
  }
1893
1864
  }
1894
1865
 
1895
- var __defProp$2 = Object.defineProperty;
1896
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1897
- var __publicField$2 = (obj, key, value) => {
1898
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1899
- return value;
1900
- };
1901
1866
  class RectangularCurve extends Curve {
1902
1867
  constructor(center, rx, aspectRatio = 1, start = 0, end = 1) {
1903
1868
  super();
@@ -1906,10 +1871,10 @@ class RectangularCurve extends Curve {
1906
1871
  this.aspectRatio = aspectRatio;
1907
1872
  this.start = start;
1908
1873
  this.end = end;
1909
- __publicField$2(this, "curves", []);
1910
- __publicField$2(this, "curveT", 0);
1911
1874
  this.update();
1912
1875
  }
1876
+ curves = [];
1877
+ curveT = 0;
1913
1878
  get x() {
1914
1879
  return this.center.x - this.rx;
1915
1880
  }
@@ -2018,20 +1983,14 @@ class SplineCurve extends Curve {
2018
1983
  }
2019
1984
  }
2020
1985
 
2021
- var __defProp$1 = Object.defineProperty;
2022
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2023
- var __publicField$1 = (obj, key, value) => {
2024
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2025
- return value;
2026
- };
2027
1986
  class CurvePath extends Curve {
1987
+ curves = [];
1988
+ startPoint;
1989
+ currentPoint;
1990
+ autoClose = false;
1991
+ _cacheLengths = [];
2028
1992
  constructor(points) {
2029
1993
  super();
2030
- __publicField$1(this, "curves", []);
2031
- __publicField$1(this, "startPoint");
2032
- __publicField$1(this, "currentPoint", new Vector2());
2033
- __publicField$1(this, "autoClose", false);
2034
- __publicField$1(this, "_cacheLengths", []);
2035
1994
  if (points) {
2036
1995
  this.addPoints(points);
2037
1996
  }
@@ -2127,7 +2086,7 @@ class CurvePath extends Curve {
2127
2086
  return points;
2128
2087
  }
2129
2088
  _setCurrentPoint(point) {
2130
- this.currentPoint.copy(point);
2089
+ this.currentPoint = new Vector2(point.x, point.y);
2131
2090
  if (!this.startPoint) {
2132
2091
  this.startPoint = this.currentPoint.clone();
2133
2092
  }
@@ -2137,24 +2096,25 @@ class CurvePath extends Curve {
2137
2096
  const start = this.startPoint;
2138
2097
  if (start) {
2139
2098
  const end = this.currentPoint;
2140
- if (!start.equals(end)) {
2099
+ if (end && !start.equals(end)) {
2141
2100
  this.curves.push(new LineCurve(end.clone(), start));
2142
- this.currentPoint.copy(start);
2101
+ end.copy(start);
2143
2102
  }
2144
2103
  this.startPoint = void 0;
2145
2104
  }
2146
2105
  return this;
2147
2106
  }
2148
2107
  moveTo(x, y) {
2149
- this.currentPoint.set(x, y);
2108
+ this.currentPoint = new Vector2(x, y);
2150
2109
  this.startPoint = this.currentPoint.clone();
2151
2110
  return this;
2152
2111
  }
2153
2112
  lineTo(x, y) {
2154
- if (!this.currentPoint.equals({ x, y })) {
2113
+ const start = this.currentPoint;
2114
+ if (!start?.equals({ x, y })) {
2155
2115
  this.curves.push(
2156
2116
  new LineCurve(
2157
- this.currentPoint.clone(),
2117
+ start?.clone() ?? new Vector2(),
2158
2118
  new Vector2(x, y)
2159
2119
  )
2160
2120
  );
@@ -2163,10 +2123,11 @@ class CurvePath extends Curve {
2163
2123
  return this;
2164
2124
  }
2165
2125
  bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
2166
- if (!this.currentPoint.equals({ x, y })) {
2126
+ const start = this.currentPoint;
2127
+ if (!start?.equals({ x, y })) {
2167
2128
  this.curves.push(
2168
2129
  new CubicBezierCurve(
2169
- this.currentPoint.clone(),
2130
+ start?.clone() ?? new Vector2(),
2170
2131
  new Vector2(cp1x, cp1y),
2171
2132
  new Vector2(cp2x, cp2y),
2172
2133
  new Vector2(x, y)
@@ -2177,10 +2138,11 @@ class CurvePath extends Curve {
2177
2138
  return this;
2178
2139
  }
2179
2140
  quadraticCurveTo(cpx, cpy, x, y) {
2180
- if (!this.currentPoint.equals({ x, y })) {
2141
+ const start = this.currentPoint;
2142
+ if (!start?.equals({ x, y })) {
2181
2143
  this.curves.push(
2182
2144
  new QuadraticBezierCurve(
2183
- this.currentPoint.clone(),
2145
+ start?.clone() ?? new Vector2(),
2184
2146
  new Vector2(cpx, cpy),
2185
2147
  new Vector2(x, y)
2186
2148
  )
@@ -2194,7 +2156,7 @@ class CurvePath extends Curve {
2194
2156
  return this;
2195
2157
  }
2196
2158
  relativeArc(x, y, radius, startAngle, endAngle, counterclockwise) {
2197
- const point = this.currentPoint;
2159
+ const point = this.currentPoint ?? new Vector2();
2198
2160
  this.arc(x + point.x, y + point.y, radius, startAngle, endAngle, counterclockwise);
2199
2161
  return this;
2200
2162
  }
@@ -2216,7 +2178,7 @@ class CurvePath extends Curve {
2216
2178
  );
2217
2179
  if (this.curves.length > 0) {
2218
2180
  const first = curve.getPoint(0);
2219
- if (!first.equals(this.currentPoint)) {
2181
+ if (!this.currentPoint || !first.equals(this.currentPoint)) {
2220
2182
  this.lineTo(first.x, first.y);
2221
2183
  }
2222
2184
  }
@@ -2225,7 +2187,7 @@ class CurvePath extends Curve {
2225
2187
  return this;
2226
2188
  }
2227
2189
  relativeEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
2228
- const point = this.currentPoint;
2190
+ const point = this.currentPoint ?? new Vector2();
2229
2191
  this.ellipse(x + point.x, y + point.y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
2230
2192
  return this;
2231
2193
  }
@@ -2241,7 +2203,8 @@ class CurvePath extends Curve {
2241
2203
  return this;
2242
2204
  }
2243
2205
  splineThru(points) {
2244
- this.curves.push(new SplineCurve([this.currentPoint.clone()].concat(points)));
2206
+ const currentPoint = this.currentPoint ?? new Vector2();
2207
+ this.curves.push(new SplineCurve([currentPoint].concat(points)));
2245
2208
  this._setCurrentPoint(points[points.length - 1]);
2246
2209
  return this;
2247
2210
  }
@@ -2274,7 +2237,7 @@ class CurvePath extends Curve {
2274
2237
  this.curves.push(source.curves[i].clone());
2275
2238
  }
2276
2239
  this.autoClose = source.autoClose;
2277
- this.currentPoint.copy(source.currentPoint);
2240
+ this.currentPoint = source.currentPoint?.clone();
2278
2241
  return this;
2279
2242
  }
2280
2243
  }
@@ -2306,17 +2269,20 @@ function getIntersectionPoint(p1, p2, q1, q2) {
2306
2269
  );
2307
2270
  }
2308
2271
 
2309
- var __defProp = Object.defineProperty;
2310
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2311
- var __publicField = (obj, key, value) => {
2312
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2313
- return value;
2314
- };
2315
2272
  class Path2D {
2273
+ currentPath = new CurvePath();
2274
+ paths = [this.currentPath];
2275
+ style;
2276
+ get startPoint() {
2277
+ return this.currentPath.startPoint;
2278
+ }
2279
+ get currentPoint() {
2280
+ return this.currentPath.currentPoint;
2281
+ }
2282
+ get strokeWidth() {
2283
+ return this.style.strokeWidth ?? ((this.style.stroke ?? "none") === "none" ? 0 : 1);
2284
+ }
2316
2285
  constructor(path, style = {}) {
2317
- __publicField(this, "currentPath", new CurvePath());
2318
- __publicField(this, "paths", [this.currentPath]);
2319
- __publicField(this, "style");
2320
2286
  if (path) {
2321
2287
  if (path instanceof Path2D) {
2322
2288
  this.addPath(path);
@@ -2328,15 +2294,6 @@ class Path2D {
2328
2294
  }
2329
2295
  this.style = style;
2330
2296
  }
2331
- get startPoint() {
2332
- return this.currentPath.startPoint;
2333
- }
2334
- get currentPoint() {
2335
- return this.currentPath.currentPoint;
2336
- }
2337
- get strokeWidth() {
2338
- return this.style.strokeWidth ?? ((this.style.stroke ?? "none") === "none" ? 0 : 1);
2339
- }
2340
2297
  addPath(path) {
2341
2298
  if (path instanceof Path2D) {
2342
2299
  this.paths.push(...path.paths.map((v) => v.clone()));
@@ -2358,7 +2315,7 @@ class Path2D {
2358
2315
  }
2359
2316
  moveTo(x, y) {
2360
2317
  const { currentPoint, curves } = this.currentPath;
2361
- if (!currentPoint.equals({ x, y })) {
2318
+ if (!currentPoint?.equals({ x, y })) {
2362
2319
  if (curves.length) {
2363
2320
  this.currentPath = new CurvePath().moveTo(x, y);
2364
2321
  this.paths.push(this.currentPath);
@@ -2694,9 +2651,7 @@ function parseFloatWithUnits(string) {
2694
2651
  }
2695
2652
  }
2696
2653
  let scale;
2697
- if (theUnit === "px" && defaultUnit !== "px") {
2698
- scale = unitConversion.in[defaultUnit] / defaultDPI;
2699
- } else {
2654
+ {
2700
2655
  scale = unitConversion[theUnit][defaultUnit];
2701
2656
  if (scale < 0) {
2702
2657
  scale = unitConversion[theUnit].in * defaultDPI;
@@ -3149,10 +3104,13 @@ function parseSvgToDom(svg) {
3149
3104
  } else {
3150
3105
  xml = svg;
3151
3106
  }
3152
- return new DOMParser().parseFromString(
3153
- xml,
3154
- "image/svg+xml"
3155
- ).documentElement;
3107
+ const doc = new DOMParser().parseFromString(xml, "text/xml");
3108
+ const error = doc.querySelector("parsererror");
3109
+ if (error) {
3110
+ throw new Error(`${error.textContent ?? "parser error"}
3111
+ ${xml}`);
3112
+ }
3113
+ return doc.documentElement;
3156
3114
  } else {
3157
3115
  return svg;
3158
3116
  }
package/dist/index.d.cts CHANGED
@@ -369,7 +369,7 @@ declare class SplineCurve extends Curve {
369
369
  declare class CurvePath extends Curve {
370
370
  curves: Curve[];
371
371
  startPoint?: Vector2;
372
- currentPoint: Vector2;
372
+ currentPoint?: Vector2;
373
373
  autoClose: boolean;
374
374
  protected _cacheLengths: number[];
375
375
  constructor(points?: Vector2[]);
@@ -408,7 +408,7 @@ declare class CurvePath extends Curve {
408
408
  }
409
409
 
410
410
  /**
411
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D
411
+ * @link https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D
412
412
  */
413
413
  declare class Path2D {
414
414
  currentPath: CurvePath;
@@ -464,8 +464,8 @@ declare class Path2D {
464
464
  declare function addPathCommandsToPath2D(commands: PathCommand[], path: Path2D | CurvePath): void;
465
465
 
466
466
  /**
467
- * https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
468
- * https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
467
+ * @link https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
468
+ * @link https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
469
469
  * From
470
470
  * rx ry x-axis-rotation large-arc-flag sweep-flag x y
471
471
  * To
package/dist/index.d.mts CHANGED
@@ -369,7 +369,7 @@ declare class SplineCurve extends Curve {
369
369
  declare class CurvePath extends Curve {
370
370
  curves: Curve[];
371
371
  startPoint?: Vector2;
372
- currentPoint: Vector2;
372
+ currentPoint?: Vector2;
373
373
  autoClose: boolean;
374
374
  protected _cacheLengths: number[];
375
375
  constructor(points?: Vector2[]);
@@ -408,7 +408,7 @@ declare class CurvePath extends Curve {
408
408
  }
409
409
 
410
410
  /**
411
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D
411
+ * @link https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D
412
412
  */
413
413
  declare class Path2D {
414
414
  currentPath: CurvePath;
@@ -464,8 +464,8 @@ declare class Path2D {
464
464
  declare function addPathCommandsToPath2D(commands: PathCommand[], path: Path2D | CurvePath): void;
465
465
 
466
466
  /**
467
- * https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
468
- * https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
467
+ * @link https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
468
+ * @link https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
469
469
  * From
470
470
  * rx ry x-axis-rotation large-arc-flag sweep-flag x y
471
471
  * To
package/dist/index.d.ts CHANGED
@@ -369,7 +369,7 @@ declare class SplineCurve extends Curve {
369
369
  declare class CurvePath extends Curve {
370
370
  curves: Curve[];
371
371
  startPoint?: Vector2;
372
- currentPoint: Vector2;
372
+ currentPoint?: Vector2;
373
373
  autoClose: boolean;
374
374
  protected _cacheLengths: number[];
375
375
  constructor(points?: Vector2[]);
@@ -408,7 +408,7 @@ declare class CurvePath extends Curve {
408
408
  }
409
409
 
410
410
  /**
411
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D
411
+ * @link https://developer.mozilla.org/zh-CN/docs/Web/API/Path2D
412
412
  */
413
413
  declare class Path2D {
414
414
  currentPath: CurvePath;
@@ -464,8 +464,8 @@ declare class Path2D {
464
464
  declare function addPathCommandsToPath2D(commands: PathCommand[], path: Path2D | CurvePath): void;
465
465
 
466
466
  /**
467
- * https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
468
- * https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
467
+ * @link https://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes
468
+ * @link https://mortoray.com/2017/02/16/rendering-an-svg-elliptical-arc-as-bezier-curves/ Appendix: Endpoint to center arc conversion
469
469
  * From
470
470
  * rx ry x-axis-rotation large-arc-flag sweep-flag x y
471
471
  * To
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- (function(p,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(p=typeof globalThis<"u"?globalThis:p||self,C(p.modernPath2d={}))})(this,function(p){"use strict";var ie=Object.defineProperty;var re=(p,C,q)=>C in p?ie(p,C,{enumerable:!0,configurable:!0,writable:!0,value:q}):p[C]=q;var T=(p,C,q)=>re(p,typeof C!="symbol"?C+"":C,q);const C={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function q(o,e){const{fill:t="#000",stroke:s="none",strokeWidth:i=s==="none"?0:1,strokeLinecap:r="round",strokeLinejoin:n="miter",strokeMiterlimit:c=0,strokeDasharray:h=[],strokeDashoffset:a=0,shadowOffsetX:l=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:d="rgba(0, 0, 0, 0)"}=e;o.fillStyle=t,o.strokeStyle=s,o.lineWidth=i,o.lineCap=r,o.lineJoin=C[n],o.miterLimit=c,o.setLineDash(h),o.lineDashOffset=a,o.shadowOffsetX=l,o.shadowOffsetY=y,o.shadowBlur=f,o.shadowColor=d}class u{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new u(1/0,1/0)}static get MIN(){return new u(-1/0,-1/0)}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 s=-e/180*Math.PI,i=this.x-t.x,r=-(this.y-t.y),n=Math.sin(s),c=Math.cos(s);return this.set(t.x+(i*c-r*n),t.y-(i*n+r*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,s={x:0,y:0}){const i=e<0?s.x-this.x+s.x:this.x,r=t<0?s.y-this.y+s.y:this.y;return this.x=i*Math.abs(e),this.y=r*Math.abs(t),this}skew(e,t=0,s={x:0,y:0}){const i=this.x-s.x,r=this.y-s.y;return this.x=s.x+(i+Math.tan(e)*r),this.y=s.y+(r+Math.tan(t)*i),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,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new u(this.x,this.y)}}class L{constructor(e=0,t=0,s=0,i=0){this.left=e,this.top=t,this.width=s,this.height=i}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 u((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 L;if(e.length===1)return e[0].clone();const t=e[0],s=e.slice(1).reduce((i,r)=>(i.left=Math.min(i.left,r.left),i.top=Math.min(i.top,r.top),i.right=Math.max(i.right,r.right),i.bottom=Math.max(i.bottom,r.bottom),i),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new L(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new L(this.left,this.top,this.width,this.height)}}class b{constructor(e=1,t=0,s=0,i=0,r=1,n=0,c=0,h=0,a=1){T(this,"elements",[]);this.set(e,t,s,i,r,n,c,h,a)}set(e,t,s,i,r,n,c,h,a){const l=this.elements;return l[0]=e,l[1]=i,l[2]=c,l[3]=t,l[4]=r,l[5]=h,l[6]=s,l[7]=n,l[8]=a,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,n=s[0],c=s[3],h=s[6],a=s[1],l=s[4],y=s[7],f=s[2],d=s[5],g=s[8],x=i[0],m=i[3],w=i[6],E=i[1],v=i[4],S=i[7],N=i[2],z=i[5],D=i[8];return r[0]=n*x+c*E+h*N,r[3]=n*m+c*v+h*z,r[6]=n*w+c*S+h*D,r[1]=a*x+l*E+y*N,r[4]=a*m+l*v+y*z,r[7]=a*w+l*S+y*D,r[2]=f*x+d*E+g*N,r[5]=f*m+d*v+g*z,r[8]=f*w+d*S+g*D,this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],c=e[5],h=e[6],a=e[7],l=e[8],y=l*n-c*a,f=c*h-l*r,d=a*r-n*h,g=t*y+s*f+i*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=y*x,e[1]=(i*a-l*s)*x,e[2]=(c*s-i*n)*x,e[3]=f*x,e[4]=(l*t-i*h)*x,e[5]=(i*r-c*t)*x,e[6]=d*x,e[7]=(s*h-a*t)*x,e[8]=(n*t-s*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(W.makeScale(e,t)),this}rotate(e){return this.premultiply(W.makeRotation(-e)),this}translate(e,t){return this.premultiply(W.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const W=new b;function K(o,e,t,s){const i=o*t+e*s,r=Math.sqrt(o*o+e*e)*Math.sqrt(t*t+s*s);let n=Math.acos(Math.max(-1,Math.min(1,i/r)));return o*s-e*t<0&&(n=-n),n}function tt(o,e,t,s,i,r,n,c){if(e===0||t===0){o.lineTo(c.x,c.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const h=(n.x-c.x)/2,a=(n.y-c.y)/2,l=Math.cos(s)*h+Math.sin(s)*a,y=-Math.sin(s)*h+Math.cos(s)*a;let f=e*e,d=t*t;const g=l*l,x=y*y,m=g/f+x/d;if(m>1){const Ct=Math.sqrt(m);e=Ct*e,t=Ct*t,f=e*e,d=t*t}const w=f*x+d*g,E=(f*d-w)/w;let v=Math.sqrt(Math.max(0,E));i===r&&(v=-v);const S=v*e*y/t,N=-v*t*l/e,z=Math.cos(s)*S-Math.sin(s)*N+(n.x+c.x)/2,D=Math.sin(s)*S+Math.cos(s)*N+(n.y+c.y)/2,U=K(1,0,(l-S)/e,(y-N)/t),J=K((l-S)/e,(y-N)/t,(-l-S)/e,(-y-N)/t)%(Math.PI*2);o.ellipse(z,D,e,t,s,U,U+J,r===1)}function O(o,e){return o-(e-o)}function Y(o,e){const t=new u,s=new u;for(let i=0,r=o.length;i<r;i++){const n=o[i];if(n.type==="m"||n.type==="M")n.type==="m"?t.add(n):t.copy(n),e.moveTo(t.x,t.y),s.copy(t);else if(n.type==="h"||n.type==="H")n.type==="h"?t.x+=n.x:t.x=n.x,e.lineTo(t.x,t.y),s.copy(t);else if(n.type==="v"||n.type==="V")n.type==="v"?t.y+=n.y:t.y=n.y,e.lineTo(t.x,t.y),s.copy(t);else if(n.type==="l"||n.type==="L")n.type==="l"?t.add(n):t.copy(n),e.lineTo(t.x,t.y),s.copy(t);else if(n.type==="c"||n.type==="C")n.type==="c"?(e.bezierCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.add(n)):(e.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.copy(n));else if(n.type==="s"||n.type==="S")n.type==="s"?(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.add(n)):(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.copy(n));else if(n.type==="q"||n.type==="Q")n.type==="q"?(e.quadraticCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x,t.y+n.y),s.x=t.x+n.x1,s.y=t.y+n.y1,t.add(n)):(e.quadraticCurveTo(n.x1,n.y1,n.x,n.y),s.x=n.x1,s.y=n.y1,t.copy(n));else if(n.type==="t"||n.type==="T"){const c=O(t.x,s.x),h=O(t.y,s.y);s.x=c,s.y=h,n.type==="t"?(e.quadraticCurveTo(c,h,t.x+n.x,t.y+n.y),t.add(n)):(e.quadraticCurveTo(c,h,n.x,n.y),t.copy(n))}else if(n.type==="a"||n.type==="A"){const c=t.clone();if(n.type==="a"){if(n.x===0&&n.y===0)continue;t.add(n)}else{if(t.equals(n))continue;t.copy(n)}s.copy(t),tt(e,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,c,t)}else n.type==="z"||n.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",n)}}const P={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function A(o,e,t=0){let c=0,h=!0,a="",l="";const y=[];function f(m,w,E){const v=new SyntaxError(`Unexpected character "${m}" at index ${w}.`);throw v.partial=E,v}function d(){a!==""&&(l===""?y.push(Number(a)):y.push(Number(a)*10**Number(l))),a="",l=""}let g;const x=o.length;for(let m=0;m<x;m++){if(g=o[m],Array.isArray(e)&&e.includes(y.length%t)&&P.FLAGS.test(g)){c=1,a=g,d();continue}if(c===0){if(P.WHITESPACE.test(g))continue;if(P.DIGIT.test(g)||P.SIGN.test(g)){c=1,a=g;continue}if(P.POINT.test(g)){c=2,a=g;continue}P.COMMA.test(g)&&(h&&f(g,m,y),h=!0)}if(c===1){if(P.DIGIT.test(g)){a+=g;continue}if(P.POINT.test(g)){a+=g,c=2;continue}if(P.EXP.test(g)){c=3;continue}P.SIGN.test(g)&&a.length===1&&P.SIGN.test(a[0])&&f(g,m,y)}if(c===2){if(P.DIGIT.test(g)){a+=g;continue}if(P.EXP.test(g)){c=3;continue}P.POINT.test(g)&&a[a.length-1]==="."&&f(g,m,y)}if(c===3){if(P.DIGIT.test(g)){l+=g;continue}if(P.SIGN.test(g)){if(l===""){l+=g;continue}l.length===1&&P.SIGN.test(l)&&f(g,m,y)}}P.WHITESPACE.test(g)?(d(),c=0,h=!1):P.COMMA.test(g)?(d(),c=0,h=!0):P.SIGN.test(g)?(d(),c=1,a=g):P.POINT.test(g)?(d(),c=2,a=g):f(g,m,y)}return d(),y}function et(o){let e,t,s="";for(let i=0,r=o.length;i<r;i++){const n=o[i];switch(n.type){case"m":case"M":if(n.x===(t==null?void 0:t.x)&&n.y===(t==null?void 0:t.y))continue;s+=`${n.type} ${n.x} ${n.y}`,t={x:n.x,y:n.y},e={x:n.x,y:n.y};break;case"h":case"H":s+=`${n.type} ${n.x}`,t={x:n.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":s+=`${n.type} ${n.y}`,t={x:(t==null?void 0:t.x)??0,y:n.y};break;case"l":case"L":s+=`${n.type} ${n.x} ${n.y}`,t={x:n.x,y:n.y};break;case"c":case"C":s+=`${n.type} ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}`,t={x:n.x,y:n.y};break;case"s":case"S":s+=`${n.type} ${n.x2} ${n.y2} ${n.x} ${n.y}`,t={x:n.x,y:n.y};break;case"q":case"Q":s+=`${n.type} ${n.x1} ${n.y1} ${n.x} ${n.y}`,t={x:n.x,y:n.y};break;case"t":case"T":s+=`${n.type} ${n.x} ${n.y}`,t={x:n.x,y:n.y};break;case"a":case"A":s+=`${n.type} ${n.rx} ${n.ry} ${n.angle} ${n.largeArcFlag} ${n.sweepFlag} ${n.x} ${n.y}`,t={x:n.x,y:n.y};break;case"z":case"Z":s+=n.type,e&&(t={x:e.x,y:e.y});break}}return s}const vt=/[a-df-z][^a-df-z]*/gi;function G(o){const e=[],t=o.match(vt);if(!t)return e;for(let s=0,i=t.length;s<i;s++){const r=t[s],n=r.charAt(0),c=r.slice(1).trim();let h;switch(n){case"m":case"M":h=A(c);for(let a=0,l=h.length;a<l;a+=2)a===0?e.push({type:n,x:h[a],y:h[a+1]}):e.push({type:n==="m"?"l":"L",x:h[a],y:h[a+1]});break;case"h":case"H":h=A(c);for(let a=0,l=h.length;a<l;a++)e.push({type:n,x:h[a]});break;case"v":case"V":h=A(c);for(let a=0,l=h.length;a<l;a++)e.push({type:n,y:h[a]});break;case"l":case"L":h=A(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:n,x:h[a],y:h[a+1]});break;case"c":case"C":h=A(c);for(let a=0,l=h.length;a<l;a+=6)e.push({type:n,x1:h[a],y1:h[a+1],x2:h[a+2],y2:h[a+3],x:h[a+4],y:h[a+5]});break;case"s":case"S":h=A(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:n,x2:h[a],y2:h[a+1],x:h[a+2],y:h[a+3]});break;case"q":case"Q":h=A(c);for(let a=0,l=h.length;a<l;a+=4)e.push({type:n,x1:h[a],y1:h[a+1],x:h[a+2],y:h[a+3]});break;case"t":case"T":h=A(c);for(let a=0,l=h.length;a<l;a+=2)e.push({type:n,x:h[a],y:h[a+1]});break;case"a":case"A":h=A(c,[3,4],7);for(let a=0,l=h.length;a<l;a+=7)e.push({type:n,rx:h[a],ry:h[a+1],angle:h[a+2],largeArcFlag:h[a+3],sweepFlag:h[a+4],x:h[a+5],y:h[a+6]});break;case"z":case"Z":e.push({type:n});break;default:console.warn(r)}}return e}class k{constructor(){T(this,"arcLengthDivisions",200);T(this,"_cacheArcLengths");T(this,"_needsUpdate",!1)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),s=this.getPoint(1);return(t.x-e.x)*(s.y-t.y)-(t.y-e.y)*(s.x-t.x)<0}getPointAt(e,t=new u){return this.getPoint(this.getUToTMapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}forEachControlPoints(e){return this.getControlPoints().forEach(e),this}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,i=this.getPoint(0),r=0;t.push(0);for(let n=1;n<=e;n++)s=this.getPoint(n/e),r+=s.distanceTo(i),t.push(r),i=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(e,t){const s=this.getLengths();let i=0;const r=s.length;let n;t?n=t:n=e*s[r-1];let c=0,h=r-1,a;for(;c<=h;)if(i=Math.floor(c+(h-c)/2),a=s[i]-n,a<0)c=i+1;else if(a>0)h=i-1;else{h=i;break}if(i=h,s[i]===n)return i/(r-1);const l=s[i],f=s[i+1]-l,d=(n-l)/f;return(i+d)/(r-1)}getTangent(e,t=new u){const i=Math.max(0,e-1e-4),r=Math.min(1,e+1e-4);return t.copy(this.getPoint(r).sub(this.getPoint(i)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new u){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let s=0,i=1,r=(s+i)/2;for(;i-s>t;){r=(s+i)/2;const n=this.getPoint(r);if(n.distanceTo(e)<t)return r;n.x<e.x?s=r:i=r}return r}matrix(e){return this.forEachControlPoints(t=>t.applyMatrix3(e)),this}getMinMax(e=u.MAX,t=u.MIN){return this.getPoints().forEach(s=>{e.min(s),t.max(s)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new L(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}toData(){return et(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class F extends k{constructor(e,t,s=0,i=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=i}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().scale(t))}getTangent(e,t=new u){const{x:s,y:i}=this.getNormal(e);return t.set(-i,s)}getNormal(e,t=new u){const{start:s,end:i}=this,r=e*(i-s)+s-.5*Math.PI;return t.set(Math.cos(r),Math.sin(r))}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function st(o,e,t,s,i){const r=(s-e)*.5,n=(i-t)*.5,c=o*o,h=o*c;return(2*t-2*s+r+n)*h+(-3*t+3*s-2*r-n)*c+r*o+t}function bt(o,e){const t=1-o;return t*t*e}function At(o,e){return 2*(1-o)*o*e}function kt(o,e){return o*o*e}function nt(o,e,t,s){return bt(o,e)+At(o,t)+kt(o,s)}function It(o,e){const t=1-o;return t*t*t*e}function St(o,e){const t=1-o;return 3*t*t*o*e}function Nt(o,e){return 3*(1-o)*o*o*e}function $t(o,e){return o*o*o*e}function it(o,e,t,s,i){return It(o,e)+St(o,t)+Nt(o,s)+$t(o,i)}class rt extends k{constructor(e=new u,t=new u,s=new u,i=new u){super(),this.start=e,this.startControl=t,this.endControl=s,this.end=i}getPoint(e,t=new u){const{start:s,startControl:i,endControl:r,end:n}=this;return t.set(it(e,s.x,i.x,r.x,n.x),it(e,s.y,i.y,r.y,n.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(e,t,s){const i=t*t-4*e*s;if(i<0)return[];const r=Math.sqrt(i),n=(-t+r)/(2*e),c=(-t-r)/(2*e);return[n,c].filter(h=>h>=0&&h<=1)}getMinMax(e=u.MAX,t=u.MIN){const s=this.start,i=this.startControl,r=this.endControl,n=this.end,c=this._solveQuadratic(3*(i.x-s.x),6*(r.x-i.x),3*(n.x-r.x)),h=this._solveQuadratic(3*(i.y-s.y),6*(r.y-i.y),3*(n.y-r.y)),a=[0,1,...c,...h];return((y,f)=>{for(const d of y)for(let g=0;g<=f;g++){const x=g/f-.5,m=Math.min(1,Math.max(0,d+x)),w=this.getPoint(m);e.x=Math.min(e.x,w.x),e.y=Math.min(e.y,w.y),t.x=Math.max(t.x,w.x),t.y=Math.max(t.y,w.y)}})(a,10),{min:e,max:t}}toCommands(){const{start:e,startControl:t,endControl:s,end:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:i.x,y:i.y}]}drawTo(e){const{start:t,startControl:s,endControl:i,end:r}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(s.x,s.y,i.x,i.y,r.x,r.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const Et=new b,ot=new b,at=new b,_=new u;class ht extends k{constructor(e=new u,t=1,s=1,i=0,r=0,n=Math.PI*2,c=!1){super(),this.center=e,this.radiusX=t,this.radiusY=s,this.rotation=i,this.startAngle=r,this.endAngle=n,this.clockwise=c}isClockwise(){return this.clockwise}getPoint(e,t=new u){const s=Math.PI*2;let i=this.endAngle-this.startAngle;const r=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=s;for(;i>s;)i-=s;i<Number.EPSILON&&(r?i=0:i=s),this.clockwise&&!r&&(i===s?i=-s:i=i-s);const n=this.startAngle+e*i;let c=this.center.x+this.radiusX*Math.cos(n),h=this.center.y+this.radiusY*Math.sin(n);if(this.rotation!==0){const a=Math.cos(this.rotation),l=Math.sin(this.rotation),y=c-this.center.x,f=h-this.center.y;c=y*a-f*l+this.center.x,h=y*l+f*a+this.center.y}return t.set(c,h)}toCommands(){const{center:e,radiusX:t,radiusY:s,startAngle:i,endAngle:r,clockwise:n,rotation:c}=this,{x:h,y:a}=e,l=h+t*Math.cos(i)*Math.cos(c)-s*Math.sin(i)*Math.sin(c),y=a+t*Math.cos(i)*Math.sin(c)+s*Math.sin(i)*Math.cos(c),f=Math.abs(i-r),d=f>Math.PI?1:0,g=n?1:0,x=c*180/Math.PI;if(f>=2*Math.PI){const m=i+Math.PI,w=h+t*Math.cos(m)*Math.cos(c)-s*Math.sin(m)*Math.sin(c),E=a+t*Math.cos(m)*Math.sin(c)+s*Math.sin(m)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:w,y:E},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:l,y}]}else{const m=h+t*Math.cos(r)*Math.cos(c)-s*Math.sin(r)*Math.sin(c),w=a+t*Math.cos(r)*Math.sin(c)+s*Math.sin(r)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:d,sweepFlag:g,x:m,y:w}]}}drawTo(e){const{center:t,radiusX:s,radiusY:i,rotation:r,startAngle:n,endAngle:c,clockwise:h}=this;return e.ellipse(t.x,t.y,s,i,r,n,c,!h),this}matrix(e){return _.set(this.center.x,this.center.y),_.applyMatrix3(e),this.center.x=_.x,this.center.y=_.y,zt(e)?Lt(this,e):qt(this,e),this}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){const{center:s,radiusX:i,radiusY:r,rotation:n}=this,{x:c,y:h}=s,a=Math.cos(n),l=Math.sin(n),y=Math.sqrt(i*i*a*a+r*r*l*l),f=Math.sqrt(i*i*l*l+r*r*a*a);return e.x=Math.min(e.x,c-y),e.y=Math.min(e.y,h-f),t.x=Math.max(t.x,c+y),t.y=Math.max(t.y,h+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function Lt(o,e){const t=o.radiusX,s=o.radiusY,i=Math.cos(o.rotation),r=Math.sin(o.rotation),n=new u(t*i,t*r),c=new u(-s*r,s*i),h=n.applyMatrix3(e),a=c.applyMatrix3(e),l=Et.set(h.x,a.x,0,h.y,a.y,0,0,0,1),y=ot.copy(l).invert(),g=at.copy(y).transpose().multiply(y).elements,x=Dt(g[0],g[1],g[4]),m=Math.sqrt(x.rt1),w=Math.sqrt(x.rt2);if(o.radiusX=1/m,o.radiusY=1/w,o.rotation=Math.atan2(x.sn,x.cs),!((o.endAngle-o.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=ot.set(m,0,0,0,w,0,0,0,1),S=at.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),N=v.multiply(S).multiply(l),z=D=>{const{x:U,y:J}=new u(Math.cos(D),Math.sin(D)).applyMatrix3(N);return Math.atan2(J,U)};o.startAngle=z(o.startAngle),o.endAngle=z(o.endAngle),ct(e)&&(o.clockwise=!o.clockwise)}}function qt(o,e){const t=lt(e),s=ut(e);o.radiusX*=t,o.radiusY*=s;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);o.rotation+=i,ct(e)&&(o.startAngle*=-1,o.endAngle*=-1,o.clockwise=!o.clockwise)}function ct(o){const e=o.elements;return e[0]*e[4]-e[1]*e[3]<0}function zt(o){const e=o.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=lt(o),i=ut(o);return Math.abs(t/(s*i))>Number.EPSILON}function lt(o){const e=o.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ut(o){const e=o.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function Dt(o,e,t){let s,i,r,n,c;const h=o+t,a=o-t,l=Math.sqrt(a*a+4*e*e);return h>0?(s=.5*(h+l),c=1/s,i=o*c*t-e*c*e):h<0?i=.5*(h-l):(s=.5*l,i=-.5*l),a>0?r=a+l:r=a-l,Math.abs(r)>2*Math.abs(e)?(c=-2*e/r,n=1/Math.sqrt(1+c*c),r=c*n):Math.abs(e)===0?(r=1,n=0):(c=-.5*r/e,r=1/Math.sqrt(1+c*c),n=c*r),a>0&&(c=r,r=-n,n=c),{rt1:s,rt2:i,cs:r,sn:n}}class X extends k{constructor(e=new u,t=new u){super(),this.start=e,this.end=t}getPoint(e,t=new u){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new u){return this.getPoint(e,t)}getTangent(e,t=new u){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new u){return this.getTangent(e,t)}getControlPoints(){return[this.start,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,end:i}=this;return e.x=Math.min(e.x,s.x,i.x),e.y=Math.min(e.y,s.y,i.y),t.x=Math.max(t.x,s.x,i.x),t.y=Math.max(t.y,s.y,i.y),{min:e,max:t}}toCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{start:t,end:s}=this;return e.lineTo(t.x,t.y),e.lineTo(s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class Xt extends k{constructor(t,s,i=0,r=1){super();T(this,"curveT",0);this.center=t,this.size=s,this.start=i,this.end=r,this.update()}update(){const{x:t,y:s}=this.center,i=new u(t+.5*this.size,s-.5*this.size),r=new u(t-.5*this.size,s-.5*this.size),n=new u(t,s+.5*this.size),c=new F(i,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),h=new F(r,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),a=new F(n,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),l=new u(t,s+this.size),y=new u(t+this.size,s),f=new u().lerpVectors(y,l,.75),d=new u(t-this.size,s),g=new u().lerpVectors(d,l,.75),x=new X(y,f),m=new X(g,d);return this.curves=[c,x,a,m,h],this}getPoint(t){return this.getCurve(t).getPoint(this.curveT)}getPointAt(t){return this.getPoint(t)}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let i;const r=.5*Math.PI;return s<r?(i=0,this.curveT=s/r):s<r+.75?(i=1,this.curveT=(s-r)/.75):s<5*Math.PI/8+.75?(i=2,this.curveT=(s-r-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(i=3,this.curveT=(s-5*Math.PI/8-.75)/.75):(i=4,this.curveT=(s-5*Math.PI/8-1.5)/r),this.curves[i]}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class Ot extends k{constructor(t,s=0,i=0,r=0,n=1){super();T(this,"curves",[]);T(this,"curveT",0);T(this,"points",[]);this.center=t,this.radius=s,this.number=i,this.start=r,this.end=n,this.update()}update(){for(let t=0;t<this.number;t++){let s=t*2*Math.PI/this.number;s-=.5*Math.PI,this.points.push(new u(this.radius*Math.cos(s),this.radius*Math.sin(s)).add(this.center))}for(let t=0;t<this.number;t++)this.curves.push(new X(this.points[t],this.points[(t+1)%this.number]));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const i=s*this.number,r=Math.floor(i);return this.curveT=i-r,this.curves[r]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class yt extends k{constructor(e=new u,t=new u,s=new u){super(),this.start=e,this.control=t,this.end=s}getPoint(e,t=new u){const{start:s,control:i,end:r}=this;return t.set(nt(e,s.x,i.x,r.x),nt(e,s.y,i.y,r.y)),t}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,control:i,end:r}=this,n=.5*(s.x+i.x),c=.5*(s.y+i.y),h=.5*(s.x+r.x),a=.5*(s.y+r.y);return e.x=Math.min(e.x,s.x,r.x,n,h),e.y=Math.min(e.y,s.y,r.y,c,a),t.x=Math.max(t.x,s.x,r.x,n,h),t.y=Math.max(t.y,s.y,r.y,c,a),{min:e,max:t}}toCommands(){const{start:e,control:t,end:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{start:t,control:s,end:i}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(s.x,s.y,i.x,i.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class gt extends k{constructor(t,s,i=1,r=0,n=1){super();T(this,"curves",[]);T(this,"curveT",0);this.center=t,this.rx=s,this.aspectRatio=i,this.start=r,this.end=n,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:s}=this.center,i=this.rx,r=this.rx/this.aspectRatio,n=[new u(t-i,s-r),new u(t+i,s-r),new u(t+i,s+r),new u(t-i,s+r)];for(let c=0;c<4;c++)this.curves.push(new X(n[c].clone(),n[(c+1)%4].clone()));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let i;return s<this.aspectRatio?(i=0,this.curveT=s/this.aspectRatio):s<this.aspectRatio+1?(i=1,this.curveT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(i=2,this.curveT=(s-this.aspectRatio-1)/this.aspectRatio):(i=3,this.curveT=(s-2*this.aspectRatio-1)/1),this.curves[i]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class ft extends k{constructor(e=[]){super(),this.points=e}getPoint(e,t=new u){const{points:s}=this,i=(s.length-1)*e,r=Math.floor(i),n=i-r,c=s[r===0?r:r-1],h=s[r],a=s[r>s.length-2?s.length-1:r+1],l=s[r>s.length-3?s.length-1:r+2];return t.set(st(n,c.x,h.x,a.x,l.x),st(n,c.y,h.y,a.y,l.y)),t}getControlPoints(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class R extends k{constructor(t){super();T(this,"curves",[]);T(this,"startPoint");T(this,"currentPoint",new u);T(this,"autoClose",!1);T(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,i=t.length;s<i;s++){const{x:r,y:n}=t[s];this.lineTo(r,n)}return this}addCommands(t){return Y(t,this),this}addData(t){return this.addCommands(G(t)),this}getPoint(t,s=new u){const i=t*this.getLength(),r=this.getCurveLengths();let n=0;for(;n<r.length;){if(r[n]>=i){const c=r[n]-i,h=this.curves[n],a=h.getLength();return h.getPointAt(a===0?0:1-c/a,s)}n++}return s}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let i=0,r=this.curves.length;i<r;i++)s+=this.curves[i].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let i=0;i<=t;i++)s.push(this.getPoint(i/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[],i=this.curves;let r;for(let n=0,c=i.length;n<c;n++){const a=i[n].getPoints(t);for(let l=0;l<a.length;l++){const y=a[l];r!=null&&r.equals(y)||(s.push(y),r=y)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}_setCurrentPoint(t){return this.currentPoint.copy(t),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const s=this.currentPoint;t.equals(s)||(this.curves.push(new X(s.clone(),t)),this.currentPoint.copy(t)),this.startPoint=void 0}return this}moveTo(t,s){return this.currentPoint.set(t,s),this.startPoint=this.currentPoint.clone(),this}lineTo(t,s){return this.currentPoint.equals({x:t,y:s})||this.curves.push(new X(this.currentPoint.clone(),new u(t,s))),this._setCurrentPoint({x:t,y:s}),this}bezierCurveTo(t,s,i,r,n,c){return this.currentPoint.equals({x:n,y:c})||this.curves.push(new rt(this.currentPoint.clone(),new u(t,s),new u(i,r),new u(n,c))),this._setCurrentPoint({x:n,y:c}),this}quadraticCurveTo(t,s,i,r){return this.currentPoint.equals({x:i,y:r})||this.curves.push(new yt(this.currentPoint.clone(),new u(t,s),new u(i,r))),this._setCurrentPoint({x:i,y:r}),this}arc(t,s,i,r,n,c){return this.ellipse(t,s,i,i,0,r,n,c),this}relativeArc(t,s,i,r,n,c){const h=this.currentPoint;return this.arc(t+h.x,s+h.y,i,r,n,c),this}arcTo(t,s,i,r,n){return console.warn("Method arcTo not supported yet"),this}ellipse(t,s,i,r,n,c,h,a=!0){const l=new ht(new u(t,s),i,r,n,c,h,!a);if(this.curves.length>0){const y=l.getPoint(0);y.equals(this.currentPoint)||this.lineTo(y.x,y.y)}return this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,s,i,r,n,c,h,a){const l=this.currentPoint;return this.ellipse(t+l.x,s+l.y,i,r,n,c,h,a),this}rect(t,s,i,r){return this.curves.push(new gt(new u(t+i/2,s+r/2),i/2,i/r)),this._setCurrentPoint({x:t,y:s}),this}splineThru(t){return this.curves.push(new ft([this.currentPoint.clone()].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}getBoundingBox(){const{min:t,max:s}=this.getMinMax();return new L(t.x,t.y,s.x-t.x,s.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var i;const s=(i=this.curves[0])==null?void 0:i.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(r=>r.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){super.copy(t),this.curves=[];for(let s=0,i=t.curves.length;s<i;s++)this.curves.push(t.curves[s].clone());return this.autoClose=t.autoClose,this.currentPoint.copy(t.currentPoint),this}}function Rt(o){return o.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Ft(o,e,t,s){const i=e.clone().sub(o),r=s.clone().sub(t),n=t.clone().sub(o),c=i.cross(r);if(c===0)return new u((o.x+t.x)/2,(o.y+t.y)/2);const h=n.cross(r)/c;return Math.abs(h)>1?new u((o.x+t.x)/2,(o.y+t.y)/2):new u(o.x+h*i.x,o.y+h*i.y)}class I{constructor(e,t={}){T(this,"currentPath",new R);T(this,"paths",[this.currentPath]);T(this,"style");e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e)),this.style=t}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new R().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:s,curves:i}=this.currentPath;return s.equals({x:e,y:t})||(i.length?(this.currentPath=new R().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,i,r,n){return this.currentPath.bezierCurveTo(e,t,s,i,r,n),this}quadraticCurveTo(e,t,s,i){return this.currentPath.quadraticCurveTo(e,t,s,i),this}arc(e,t,s,i,r,n){return this.currentPath.arc(e,t,s,i,r,n),this}arcTo(e,t,s,i,r){return this.currentPath.arcTo(e,t,s,i,r),this}ellipse(e,t,s,i,r,n,c,h){return this.currentPath.ellipse(e,t,s,i,r,n,c,h),this}rect(e,t,s,i){return this.currentPath.rect(e,t,s,i),this}addCommands(e){return Y(e,this),this}addData(e){return this.addCommands(G(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}getControlPoints(){return this.paths.flatMap(e=>e.getControlPoints())}getCurves(){return this.paths.flatMap(e=>e.curves)}scale(e,t=e,s={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.scale(e,t,s)}),this}skew(e,t=0,s={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.skew(e,t,s)}),this}rotate(e,t={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getCurves(),s=[],i=[],r=[];t.forEach((c,h)=>{const a=c.getControlPoints(),l=c.isClockwise();r[h]=a,i[h]=l;const y=a[0],f=a[a.length-1]??y;s.push({start:l?f:y,end:l?y:f,index:h})});const n=[];return s.forEach((c,h)=>{n[h]=[],s.forEach((a,l)=>{l!==h&&a.start.equals(c.end)&&n[h].push(a.index)})}),t.forEach((c,h)=>{const a=i[h];r[h].forEach(y=>{const f=c.getTForPoint(y),d=c.getNormal(f).scale(a?e:-e);y.add(d)})}),n.forEach((c,h)=>{const a=r[h];c.forEach(l=>{const y=r[l],f=Ft(a[a.length-1],a[a.length-2]??a[a.length-1],y[0],y[1]??y[0]);f&&(a[a.length-1].copy(f),y[0].copy(f))})}),this}matrix(e){return this.getCurves().forEach(t=>t.matrix(e)),this}getMinMax(e=u.MAX,t=u.MIN,s=!0){const i=this.strokeWidth;return this.getCurves().forEach(r=>{if(r.getMinMax(e,t),s&&i>1){const n=i/2,c=r.isClockwise(),h=[];for(let a=0;a<=1;a+=1/r.arcLengthDivisions){const l=r.getPoint(a),y=r.getNormal(a),f=y.clone().scale(c?n:-n),d=y.clone().scale(c?-n:n);h.push(l.clone().add(f),l.clone().add(d),l.clone().add({x:n,y:0}),l.clone().add({x:-n,y:0}),l.clone().add({x:0,y:n}),l.clone().add({x:0,y:-n}),l.clone().add({x:n,y:n}),l.clone().add({x:-n,y:-n}))}e.min(...h),t.max(...h)}}),{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:s}=this.getMinMax(void 0,void 0,e);return new L(t.x,t.y,s.x-t.x,s.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),q(e,t),this.paths.forEach(r=>{r.drawTo(e)}),s!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),q(e,t),this.getControlPoints().forEach(r=>{e.moveTo(r.x,r.y),e.arc(r.x,r.y,4,0,Math.PI*2)}),s!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.paths.flatMap(e=>e.toCommands())}toData(){return this.paths.map(e=>e.toData()).join(" ")}toSvgPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const i in e)e[i]!==void 0&&(t[Rt(i)]=e[i]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const i in t)t[i]!==void 0&&(s+=`${i}:${t[i]};`);return`<path d="${this.toData()}" style="${s}"></path>`}toSvgString(){const{x:e,y:t,width:s,height:i}=this.getBoundingBox(),r=this.toSvgPathString();return`<svg viewBox="${e} ${t} ${s} ${i}" width="${s}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${r}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...s}=e,{left:i,top:r,width:n,height:c}=this.getBoundingBox(),h=document.createElement("canvas");h.width=n*t,h.height=c*t,h.style.width=`${n}px`,h.style.height=`${c}px`;const a=h.getContext("2d");return a&&(a.scale(t,t),a.translate(-i,-r),this.drawTo(a,s)),h}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}clone(){return new this.constructor().copy(this)}}const Q="px",pt=90,dt=["mm","cm","in","pt","pc","px"],V={mm:{mm:1,cm:.1,in:1/25.4,pt:72/25.4,pc:6/25.4,px:-1},cm:{mm:10,cm:1,in:1/2.54,pt:72/2.54,pc:6/2.54,px:-1},in:{mm:25.4,cm:2.54,in:1,pt:72,pc:6,px:-1},pt:{mm:25.4/72,cm:2.54/72,in:1/72,pt:1,pc:6/72,px:-1},pc:{mm:25.4/6,cm:2.54/6,in:1/6,pt:72/6,pc:1,px:-1},px:{px:1}};function M(o){let e="px";if(typeof o=="string"||o instanceof String)for(let s=0,i=dt.length;s<i;s++){const r=dt[s];if(o.endsWith(r)){e=r,o=o.substring(0,o.length-r.length);break}}let t;return e==="px"&&Q!=="px"?t=V.in[Q]/pt:(t=V[e][Q],t<0&&(t=V[e].in*pt)),t*Number.parseFloat(o)}const _t=new b,B=new b,xt=new b,mt=new b;function Bt(o,e,t){if(!(o.hasAttribute("transform")||o.nodeName==="use"&&(o.hasAttribute("x")||o.hasAttribute("y"))))return null;const s=Ut(o);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Ut(o){const e=new b,t=_t;if(o.nodeName==="use"&&(o.hasAttribute("x")||o.hasAttribute("y"))&&e.translate(M(o.getAttribute("x")),M(o.getAttribute("y"))),o.hasAttribute("transform")){const s=o.getAttribute("transform").split(")");for(let i=s.length-1;i>=0;i--){const r=s[i].trim();if(r==="")continue;const n=r.indexOf("("),c=r.length;if(n>0&&n<c){const h=r.slice(0,n),a=A(r.slice(n+1));switch(t.identity(),h){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]),B.makeTranslation(-y,-f),xt.makeRotation(l),mt.multiplyMatrices(xt,B),B.makeTranslation(y,f),t.multiplyMatrices(B,mt)}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 Wt(o){return new I().addPath(new R().arc(M(o.getAttribute("cx")||0),M(o.getAttribute("cy")||0),M(o.getAttribute("r")||0),0,Math.PI*2))}function Yt(o,e){if(!(!o.sheet||!o.sheet.cssRules||!o.sheet.cssRules.length))for(let t=0;t<o.sheet.cssRules.length;t++){const s=o.sheet.cssRules[t];if(s.type!==1)continue;const i=s.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),r={};for(let n=s.style.length,c=0;c<n;c++){const h=s.style.item(c);r[h]=s.style.getPropertyValue(h)}for(let n=0;n<i.length;n++)e[i[n]]=Object.assign(e[i[n]]||{},{...r})}}function Gt(o){return new I().addPath(new R().ellipse(M(o.getAttribute("cx")||0),M(o.getAttribute("cy")||0),M(o.getAttribute("rx")||0),M(o.getAttribute("ry")||0),0,0,Math.PI*2))}function Qt(o){return new I().moveTo(M(o.getAttribute("x1")||0),M(o.getAttribute("y1")||0)).lineTo(M(o.getAttribute("x2")||0),M(o.getAttribute("y2")||0))}function Vt(o){const e=new I,t=o.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const jt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Ht(o){var s;const e=new I;let t=0;return(s=o.getAttribute("points"))==null||s.replace(jt,(i,r,n)=>{const c=M(r),h=M(n);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,i}),e.currentPath.autoClose=!0,e}const Zt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Jt(o){var s;const e=new I;let t=0;return(s=o.getAttribute("points"))==null||s.replace(Zt,(i,r,n)=>{const c=M(r),h=M(n);return t===0?e.moveTo(c,h):e.lineTo(c,h),t++,i}),e.currentPath.autoClose=!1,e}function Kt(o){const e=M(o.getAttribute("x")||0),t=M(o.getAttribute("y")||0),s=M(o.getAttribute("rx")||o.getAttribute("ry")||0),i=M(o.getAttribute("ry")||o.getAttribute("rx")||0),r=M(o.getAttribute("width")),n=M(o.getAttribute("height")),c=1-.551915024494,h=new I;return h.moveTo(e+s,t),h.lineTo(e+r-s,t),(s!==0||i!==0)&&h.bezierCurveTo(e+r-s*c,t,e+r,t+i*c,e+r,t+i),h.lineTo(e+r,t+n-i),(s!==0||i!==0)&&h.bezierCurveTo(e+r,t+n-i*c,e+r-s*c,t+n,e+r-s,t+n),h.lineTo(e+s,t+n),(s!==0||i!==0)&&h.bezierCurveTo(e+s*c,t+n,e,t+n-i*c,e,t+n-i),h.lineTo(e,t+i),(s!==0||i!==0)&&h.bezierCurveTo(e,t+i*c,e+s*c,t,e+s,t),h}function $(o,e,t){e=Object.assign({},e);let s={};if(o.hasAttribute("class")){const a=o.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<a.length;l++)s=Object.assign(s,t[`.${a[l]}`])}o.hasAttribute("id")&&(s=Object.assign(s,t[`#${o.getAttribute("id")}`]));for(let a=o.style.length,l=0;l<a;l++){const y=o.style.item(l),f=o.style.getPropertyValue(y);e[y]=f,s[y]=f}function i(a,l,y=r){o.hasAttribute(a)&&(e[l]=y(o.getAttribute(a))),s[a]&&(e[l]=y(s[a]))}function r(a){return a.startsWith("url")&&console.warn("url access in attributes is not implemented."),a}function n(a){return Math.max(0,Math.min(1,M(a)))}function c(a){return Math.max(0,M(a))}function h(a){return a.split(" ").filter(l=>l!=="").map(l=>M(l))}return i("fill","fill"),i("fill-opacity","fillOpacity",n),i("fill-rule","fillRule"),i("opacity","opacity",n),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",n),i("stroke-width","strokeWidth",c),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",c),i("stroke-dasharray","strokeDasharray",h),i("stroke-dashoffset","strokeDashoffset",M),i("visibility","visibility"),e}function j(o,e,t=[],s={}){var y;if(o.nodeType!==1)return t;let i=!1,r=null,n={...e};switch(o.nodeName){case"svg":n=$(o,n,s);break;case"style":Yt(o,s);break;case"g":n=$(o,n,s);break;case"path":n=$(o,n,s),o.hasAttribute("d")&&(r=Vt(o));break;case"rect":n=$(o,n,s),r=Kt(o);break;case"polygon":n=$(o,n,s),r=Ht(o);break;case"polyline":n=$(o,n,s),r=Jt(o);break;case"circle":n=$(o,n,s),r=Wt(o);break;case"ellipse":n=$(o,n,s),r=Gt(o);break;case"line":n=$(o,n,s),r=Qt(o);break;case"defs":i=!0;break;case"use":{n=$(o,n,s);const d=(o.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),g=(y=o.viewportElement)==null?void 0:y.getElementById(d);g?j(g,n,t,s):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(o);break}if(n.display==="none")return t;Object.assign(e,n);const c=new b,h=[],a=Bt(o,c,h);r&&(r.matrix(c),t.push(r),r.style=e);const l=o.childNodes;for(let f=0,d=l.length;f<d;f++){const g=l[f];i&&g.nodeName!=="style"&&g.nodeName!=="defs"||j(g,e,t,s)}return a&&(h.pop(),h.length>0?c.copy(h[h.length-1]):c.identity()),t}const Mt="data:image/svg+xml;",Pt=`${Mt}base64,`,wt=`${Mt}charset=utf8,`;function Tt(o){if(typeof o=="string"){let e;return o.startsWith(Pt)?(o=o.substring(Pt.length,o.length),e=atob(o)):o.startsWith(wt)?(o=o.substring(wt.length,o.length),e=decodeURIComponent(o)):e=o,new DOMParser().parseFromString(e,"image/svg+xml").documentElement}else return o}function te(o){return j(Tt(o),{})}function H(o,e=!0){if(!o.length)return;const t=u.MAX,s=u.MIN;return o.forEach(i=>i.getMinMax(t,s,e)),new L(t.x,t.y,s.x-t.x,s.y-t.y)}function Z(o){const{x:e,y:t,width:s,height:i}=H(o),r=o.map(n=>n.toSvgPathString()).join("");return`<svg viewBox="${e} ${t} ${s} ${i}" width="${s}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${r}</svg>`}function ee(o){return`data:image/svg+xml;base64,${btoa(Z(o))}`}function se(o){return new DOMParser().parseFromString(Z(o),"image/svg+xml").documentElement}function ne(o,e={}){const{pixelRatio:t=2,...s}=e,{left:i,top:r,width:n,height:c}=H(o),h=document.createElement("canvas");h.width=n*t,h.height=c*t,h.style.width=`${n}px`,h.style.height=`${c}px`;const a=h.getContext("2d");return a&&(a.scale(t,t),a.translate(-i,-r),o.forEach(l=>{l.drawTo(a,s)})),h}p.BoundingBox=L,p.CircleCurve=F,p.CubicBezierCurve=rt,p.Curve=k,p.CurvePath=R,p.EllipseCurve=ht,p.HeartCurve=Xt,p.LineCurve=X,p.Matrix3=b,p.Path2D=I,p.PloygonCurve=Ot,p.QuadraticBezierCurve=yt,p.RectangularCurve=gt,p.SplineCurve=ft,p.Vector2=u,p.addPathCommandsToPath2D=Y,p.getPathsBoundingBox=H,p.parseArcCommand=tt,p.parsePathDataArgs=A,p.parseSvg=te,p.parseSvgToDom=Tt,p.pathCommandsToPathData=et,p.pathDataToPathCommands=G,p.pathsToCanvas=ne,p.pathsToSvg=se,p.pathsToSvgString=Z,p.pathsToSvgUrl=ee,p.setCanvasContext=q,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
1
+ (function(p,C){typeof exports=="object"&&typeof module<"u"?C(exports):typeof define=="function"&&define.amd?define(["exports"],C):(p=typeof globalThis<"u"?globalThis:p||self,C(p.modernPath2d={}))})(this,function(p){"use strict";var ie=Object.defineProperty;var re=(p,C,q)=>C in p?ie(p,C,{enumerable:!0,configurable:!0,writable:!0,value:q}):p[C]=q;var T=(p,C,q)=>re(p,typeof C!="symbol"?C+"":C,q);const C={arcs:"bevel",bevel:"bevel",miter:"miter","miter-clip":"miter",round:"round"};function q(o,e){const{fill:t="#000",stroke:s="none",strokeWidth:i=s==="none"?0:1,strokeLinecap:r="round",strokeLinejoin:n="miter",strokeMiterlimit:c=0,strokeDasharray:a=[],strokeDashoffset:h=0,shadowOffsetX:l=0,shadowOffsetY:y=0,shadowBlur:f=0,shadowColor:d="rgba(0, 0, 0, 0)"}=e;o.fillStyle=t,o.strokeStyle=s,o.lineWidth=i,o.lineCap=r,o.lineJoin=C[n],o.miterLimit=c,o.setLineDash(a),o.lineDashOffset=h,o.shadowOffsetX=l,o.shadowOffsetY=y,o.shadowBlur=f,o.shadowColor=d}class u{constructor(e=0,t=0){this.x=e,this.y=t}static get MAX(){return new u(1/0,1/0)}static get MIN(){return new u(-1/0,-1/0)}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 s=-e/180*Math.PI,i=this.x-t.x,r=-(this.y-t.y),n=Math.sin(s),c=Math.cos(s);return this.set(t.x+(i*c-r*n),t.y-(i*n+r*c)),this}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}lengthSquared(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.lengthSquared())}scale(e,t=e,s={x:0,y:0}){const i=e<0?s.x-this.x+s.x:this.x,r=t<0?s.y-this.y+s.y:this.y;return this.x=i*Math.abs(e),this.y=r*Math.abs(t),this}skew(e,t=0,s={x:0,y:0}){const i=this.x-s.x,r=this.y-s.y;return this.x=s.x+(i+Math.tan(e)*r),this.y=s.y+(r+Math.tan(t)*i),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,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return this.x===e.x&&this.y===e.y}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}copy(e){return this.x=e.x,this.y=e.y,this}clone(){return new u(this.x,this.y)}}class L{constructor(e=0,t=0,s=0,i=0){this.left=e,this.top=t,this.width=s,this.height=i}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 u((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 L;if(e.length===1)return e[0].clone();const t=e[0],s=e.slice(1).reduce((i,r)=>(i.left=Math.min(i.left,r.left),i.top=Math.min(i.top,r.top),i.right=Math.max(i.right,r.right),i.bottom=Math.max(i.bottom,r.bottom),i),{left:(t==null?void 0:t.left)??0,top:(t==null?void 0:t.top)??0,right:(t==null?void 0:t.right)??0,bottom:(t==null?void 0:t.bottom)??0});return new L(s.left,s.top,s.right-s.left,s.bottom-s.top)}translate(e,t){return this.left+=e,this.top+=t,this}copy(e){return this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height,this}clone(){return new L(this.left,this.top,this.width,this.height)}}class b{constructor(e=1,t=0,s=0,i=0,r=1,n=0,c=0,a=0,h=1){T(this,"elements",[]);this.set(e,t,s,i,r,n,c,a,h)}set(e,t,s,i,r,n,c,a,h){const l=this.elements;return l[0]=e,l[1]=i,l[2]=c,l[3]=t,l[4]=r,l[5]=a,l[6]=s,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,n=s[0],c=s[3],a=s[6],h=s[1],l=s[4],y=s[7],f=s[2],d=s[5],g=s[8],x=i[0],m=i[3],w=i[6],E=i[1],v=i[4],S=i[7],$=i[2],z=i[5],D=i[8];return r[0]=n*x+c*E+a*$,r[3]=n*m+c*v+a*z,r[6]=n*w+c*S+a*D,r[1]=h*x+l*E+y*$,r[4]=h*m+l*v+y*z,r[7]=h*w+l*S+y*D,r[2]=f*x+d*E+g*$,r[5]=f*m+d*v+g*z,r[8]=f*w+d*S+g*D,this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],c=e[5],a=e[6],h=e[7],l=e[8],y=l*n-c*h,f=c*a-l*r,d=h*r-n*a,g=t*y+s*f+i*d;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=y*x,e[1]=(i*h-l*s)*x,e[2]=(c*s-i*n)*x,e[3]=f*x,e[4]=(l*t-i*a)*x,e[5]=(i*r-c*t)*x,e[6]=d*x,e[7]=(s*a-h*t)*x,e[8]=(n*t-s*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}scale(e,t){return this.premultiply(W.makeScale(e,t)),this}rotate(e){return this.premultiply(W.makeRotation(-e)),this}translate(e,t){return this.premultiply(W.makeTranslation(e,t)),this}makeTranslation(e,t){return this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}clone(){return new this.constructor().fromArray(this.elements)}}const W=new b;function Z(o,e,t,s){const i=o*t+e*s,r=Math.sqrt(o*o+e*e)*Math.sqrt(t*t+s*s);let n=Math.acos(Math.max(-1,Math.min(1,i/r)));return o*s-e*t<0&&(n=-n),n}function J(o,e,t,s,i,r,n,c){if(e===0||t===0){o.lineTo(c.x,c.y);return}s=s*Math.PI/180,e=Math.abs(e),t=Math.abs(t);const a=(n.x-c.x)/2,h=(n.y-c.y)/2,l=Math.cos(s)*a+Math.sin(s)*h,y=-Math.sin(s)*a+Math.cos(s)*h;let f=e*e,d=t*t;const g=l*l,x=y*y,m=g/f+x/d;if(m>1){const wt=Math.sqrt(m);e=wt*e,t=wt*t,f=e*e,d=t*t}const w=f*x+d*g,E=(f*d-w)/w;let v=Math.sqrt(Math.max(0,E));i===r&&(v=-v);const S=v*e*y/t,$=-v*t*l/e,z=Math.cos(s)*S-Math.sin(s)*$+(n.x+c.x)/2,D=Math.sin(s)*S+Math.cos(s)*$+(n.y+c.y)/2,U=Z(1,0,(l-S)/e,(y-$)/t),H=Z((l-S)/e,(y-$)/t,(-l-S)/e,(-y-$)/t)%(Math.PI*2);o.ellipse(z,D,e,t,s,U,U+H,r===0)}function O(o,e){return o-(e-o)}function Y(o,e){const t=new u,s=new u;for(let i=0,r=o.length;i<r;i++){const n=o[i];if(n.type==="m"||n.type==="M")n.type==="m"?t.add(n):t.copy(n),e.moveTo(t.x,t.y),s.copy(t);else if(n.type==="h"||n.type==="H")n.type==="h"?t.x+=n.x:t.x=n.x,e.lineTo(t.x,t.y),s.copy(t);else if(n.type==="v"||n.type==="V")n.type==="v"?t.y+=n.y:t.y=n.y,e.lineTo(t.x,t.y),s.copy(t);else if(n.type==="l"||n.type==="L")n.type==="l"?t.add(n):t.copy(n),e.lineTo(t.x,t.y),s.copy(t);else if(n.type==="c"||n.type==="C")n.type==="c"?(e.bezierCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.add(n)):(e.bezierCurveTo(n.x1,n.y1,n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.copy(n));else if(n.type==="s"||n.type==="S")n.type==="s"?(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),t.x+n.x2,t.y+n.y2,t.x+n.x,t.y+n.y),s.x=t.x+n.x2,s.y=t.y+n.y2,t.add(n)):(e.bezierCurveTo(O(t.x,s.x),O(t.y,s.y),n.x2,n.y2,n.x,n.y),s.x=n.x2,s.y=n.y2,t.copy(n));else if(n.type==="q"||n.type==="Q")n.type==="q"?(e.quadraticCurveTo(t.x+n.x1,t.y+n.y1,t.x+n.x,t.y+n.y),s.x=t.x+n.x1,s.y=t.y+n.y1,t.add(n)):(e.quadraticCurveTo(n.x1,n.y1,n.x,n.y),s.x=n.x1,s.y=n.y1,t.copy(n));else if(n.type==="t"||n.type==="T"){const c=O(t.x,s.x),a=O(t.y,s.y);s.x=c,s.y=a,n.type==="t"?(e.quadraticCurveTo(c,a,t.x+n.x,t.y+n.y),t.add(n)):(e.quadraticCurveTo(c,a,n.x,n.y),t.copy(n))}else if(n.type==="a"||n.type==="A"){const c=t.clone();if(n.type==="a"){if(n.x===0&&n.y===0)continue;t.add(n)}else{if(t.equals(n))continue;t.copy(n)}s.copy(t),J(e,n.rx,n.ry,n.angle,n.largeArcFlag,n.sweepFlag,c,t)}else n.type==="z"||n.type==="Z"?(e.startPoint&&t.copy(e.startPoint),e.closePath()):console.warn("Unsupported commands",n)}}const P={SEPARATOR:/[ \t\r\n,.\-+]/,WHITESPACE:/[ \t\r\n]/,DIGIT:/\d/,SIGN:/[-+]/,POINT:/\./,COMMA:/,/,EXP:/e/i,FLAGS:/[01]/};function A(o,e,t=0){let c=0,a=!0,h="",l="";const y=[];function f(m,w,E){const v=new SyntaxError(`Unexpected character "${m}" at index ${w}.`);throw v.partial=E,v}function d(){h!==""&&(l===""?y.push(Number(h)):y.push(Number(h)*10**Number(l))),h="",l=""}let g;const x=o.length;for(let m=0;m<x;m++){if(g=o[m],Array.isArray(e)&&e.includes(y.length%t)&&P.FLAGS.test(g)){c=1,h=g,d();continue}if(c===0){if(P.WHITESPACE.test(g))continue;if(P.DIGIT.test(g)||P.SIGN.test(g)){c=1,h=g;continue}if(P.POINT.test(g)){c=2,h=g;continue}P.COMMA.test(g)&&(a&&f(g,m,y),a=!0)}if(c===1){if(P.DIGIT.test(g)){h+=g;continue}if(P.POINT.test(g)){h+=g,c=2;continue}if(P.EXP.test(g)){c=3;continue}P.SIGN.test(g)&&h.length===1&&P.SIGN.test(h[0])&&f(g,m,y)}if(c===2){if(P.DIGIT.test(g)){h+=g;continue}if(P.EXP.test(g)){c=3;continue}P.POINT.test(g)&&h[h.length-1]==="."&&f(g,m,y)}if(c===3){if(P.DIGIT.test(g)){l+=g;continue}if(P.SIGN.test(g)){if(l===""){l+=g;continue}l.length===1&&P.SIGN.test(l)&&f(g,m,y)}}P.WHITESPACE.test(g)?(d(),c=0,a=!1):P.COMMA.test(g)?(d(),c=0,a=!0):P.SIGN.test(g)?(d(),c=1,h=g):P.POINT.test(g)?(d(),c=2,h=g):f(g,m,y)}return d(),y}function K(o){let e,t;const s=[];for(let i=0,r=o.length;i<r;i++){const n=o[i];switch(n.type){case"m":case"M":if(n.x.toFixed(4)===(t==null?void 0:t.x.toFixed(4))&&n.y.toFixed(4)===(t==null?void 0:t.y.toFixed(4)))continue;s.push(`${n.type} ${n.x} ${n.y}`),t={x:n.x,y:n.y},e={x:n.x,y:n.y};break;case"h":case"H":s.push(`${n.type} ${n.x}`),t={x:n.x,y:(t==null?void 0:t.y)??0};break;case"v":case"V":s.push(`${n.type} ${n.y}`),t={x:(t==null?void 0:t.x)??0,y:n.y};break;case"l":case"L":s.push(`${n.type} ${n.x} ${n.y}`),t={x:n.x,y:n.y};break;case"c":case"C":s.push(`${n.type} ${n.x1} ${n.y1} ${n.x2} ${n.y2} ${n.x} ${n.y}`),t={x:n.x,y:n.y};break;case"s":case"S":s.push(`${n.type} ${n.x2} ${n.y2} ${n.x} ${n.y}`),t={x:n.x,y:n.y};break;case"q":case"Q":s.push(`${n.type} ${n.x1} ${n.y1} ${n.x} ${n.y}`),t={x:n.x,y:n.y};break;case"t":case"T":s.push(`${n.type} ${n.x} ${n.y}`),t={x:n.x,y:n.y};break;case"a":case"A":s.push(`${n.type} ${n.rx} ${n.ry} ${n.angle} ${n.largeArcFlag} ${n.sweepFlag} ${n.x} ${n.y}`),t={x:n.x,y:n.y};break;case"z":case"Z":s.push(n.type),e&&(t={x:e.x,y:e.y});break}}return s.join(" ")}const Tt=/[a-df-z][^a-df-z]*/gi;function G(o){const e=[],t=o.match(Tt);if(!t)return e;for(let s=0,i=t.length;s<i;s++){const r=t[s],n=r.charAt(0),c=r.slice(1).trim();let a;switch(n){case"m":case"M":a=A(c);for(let h=0,l=a.length;h<l;h+=2)h===0?e.push({type:n,x:a[h],y:a[h+1]}):e.push({type:n==="m"?"l":"L",x:a[h],y:a[h+1]});break;case"h":case"H":a=A(c);for(let h=0,l=a.length;h<l;h++)e.push({type:n,x:a[h]});break;case"v":case"V":a=A(c);for(let h=0,l=a.length;h<l;h++)e.push({type:n,y:a[h]});break;case"l":case"L":a=A(c);for(let h=0,l=a.length;h<l;h+=2)e.push({type:n,x:a[h],y:a[h+1]});break;case"c":case"C":a=A(c);for(let h=0,l=a.length;h<l;h+=6)e.push({type:n,x1:a[h],y1:a[h+1],x2:a[h+2],y2:a[h+3],x:a[h+4],y:a[h+5]});break;case"s":case"S":a=A(c);for(let h=0,l=a.length;h<l;h+=4)e.push({type:n,x2:a[h],y2:a[h+1],x:a[h+2],y:a[h+3]});break;case"q":case"Q":a=A(c);for(let h=0,l=a.length;h<l;h+=4)e.push({type:n,x1:a[h],y1:a[h+1],x:a[h+2],y:a[h+3]});break;case"t":case"T":a=A(c);for(let h=0,l=a.length;h<l;h+=2)e.push({type:n,x:a[h],y:a[h+1]});break;case"a":case"A":a=A(c,[3,4],7);for(let h=0,l=a.length;h<l;h+=7)e.push({type:n,rx:a[h],ry:a[h+1],angle:a[h+2],largeArcFlag:a[h+3],sweepFlag:a[h+4],x:a[h+5],y:a[h+6]});break;case"z":case"Z":e.push({type:n});break;default:console.warn(r)}}return e}class k{constructor(){T(this,"arcLengthDivisions",200);T(this,"_cacheArcLengths");T(this,"_needsUpdate",!1)}isClockwise(){const e=this.getPoint(1),t=this.getPoint(.5),s=this.getPoint(1);return(t.x-e.x)*(s.y-t.y)-(t.y-e.y)*(s.x-t.x)<0}getPointAt(e,t=new u){return this.getPoint(this.getUToTMapping(e),t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}forEachControlPoints(e){return this.getControlPoints().forEach(e),this}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this._cacheArcLengths&&this._cacheArcLengths.length===e+1&&!this._needsUpdate)return this._cacheArcLengths;this._needsUpdate=!1;const t=[];let s,i=this.getPoint(0),r=0;t.push(0);for(let n=1;n<=e;n++)s=this.getPoint(n/e),r+=s.distanceTo(i),t.push(r),i=s;return this._cacheArcLengths=t,t}updateArcLengths(){this._needsUpdate=!0,this.getLengths()}getUToTMapping(e,t){const s=this.getLengths();let i=0;const r=s.length;let n;t?n=t:n=e*s[r-1];let c=0,a=r-1,h;for(;c<=a;)if(i=Math.floor(c+(a-c)/2),h=s[i]-n,h<0)c=i+1;else if(h>0)a=i-1;else{a=i;break}if(i=a,s[i]===n)return i/(r-1);const l=s[i],f=s[i+1]-l,d=(n-l)/f;return(i+d)/(r-1)}getTangent(e,t=new u){const i=Math.max(0,e-1e-4),r=Math.min(1,e+1e-4);return t.copy(this.getPoint(r).sub(this.getPoint(i)).normalize())}getTangentAt(e,t){return this.getTangent(this.getUToTMapping(e),t)}getNormal(e,t=new u){return this.getTangent(e,t),t.set(-t.y,t.x).normalize()}getNormalAt(e,t){return this.getNormal(this.getUToTMapping(e),t)}getTForPoint(e,t=.001){let s=0,i=1,r=(s+i)/2;for(;i-s>t;){r=(s+i)/2;const n=this.getPoint(r);if(n.distanceTo(e)<t)return r;n.x<e.x?s=r:i=r}return r}matrix(e){return this.forEachControlPoints(t=>t.applyMatrix3(e)),this}getMinMax(e=u.MAX,t=u.MIN){return this.getPoints().forEach(s=>{e.min(s),t.max(s)}),{min:e,max:t}}getBoundingBox(){const{min:e,max:t}=this.getMinMax();return new L(e.x,e.y,t.x-e.x,t.y-e.y)}toCommands(){return this.getPoints().map((e,t)=>t===0?{type:"M",x:e.x,y:e.y}:{type:"L",x:e.x,y:e.y})}toData(){return K(this.toCommands())}drawTo(e){return this.toCommands().forEach(t=>{switch(t.type){case"M":e.moveTo(t.x,t.y);break;case"L":e.lineTo(t.x,t.y);break}}),this}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}clone(){return new this.constructor().copy(this)}}class R extends k{constructor(e,t,s=0,i=Math.PI*2){super(),this.center=e,this.radius=t,this.start=s,this.end=i}getPoint(e){const{radius:t,center:s}=this;return s.clone().add(this.getNormal(e).clone().scale(t))}getTangent(e,t=new u){const{x:s,y:i}=this.getNormal(e);return t.set(-i,s)}getNormal(e,t=new u){const{start:s,end:i}=this,r=e*(i-s)+s-.5*Math.PI;return t.set(Math.cos(r),Math.sin(r))}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){return e.x=Math.min(e.x,this.center.x-this.radius),e.y=Math.min(e.y,this.center.y-this.radius),t.x=Math.max(t.x,this.center.x+this.radius),t.y=Math.max(t.y,this.center.y+this.radius),{min:e,max:t}}}function tt(o,e,t,s,i){const r=(s-e)*.5,n=(i-t)*.5,c=o*o,a=o*c;return(2*t-2*s+r+n)*a+(-3*t+3*s-2*r-n)*c+r*o+t}function Ct(o,e){const t=1-o;return t*t*e}function vt(o,e){return 2*(1-o)*o*e}function bt(o,e){return o*o*e}function et(o,e,t,s){return Ct(o,e)+vt(o,t)+bt(o,s)}function At(o,e){const t=1-o;return t*t*t*e}function kt(o,e){const t=1-o;return 3*t*t*o*e}function It(o,e){return 3*(1-o)*o*o*e}function St(o,e){return o*o*o*e}function st(o,e,t,s,i){return At(o,e)+kt(o,t)+It(o,s)+St(o,i)}class nt extends k{constructor(e=new u,t=new u,s=new u,i=new u){super(),this.start=e,this.startControl=t,this.endControl=s,this.end=i}getPoint(e,t=new u){const{start:s,startControl:i,endControl:r,end:n}=this;return t.set(st(e,s.x,i.x,r.x,n.x),st(e,s.y,i.y,r.y,n.y))}getControlPoints(){return[this.start,this.startControl,this.endControl,this.end]}_solveQuadratic(e,t,s){const i=t*t-4*e*s;if(i<0)return[];const r=Math.sqrt(i),n=(-t+r)/(2*e),c=(-t-r)/(2*e);return[n,c].filter(a=>a>=0&&a<=1)}getMinMax(e=u.MAX,t=u.MIN){const s=this.start,i=this.startControl,r=this.endControl,n=this.end,c=this._solveQuadratic(3*(i.x-s.x),6*(r.x-i.x),3*(n.x-r.x)),a=this._solveQuadratic(3*(i.y-s.y),6*(r.y-i.y),3*(n.y-r.y)),h=[0,1,...c,...a];return((y,f)=>{for(const d of y)for(let g=0;g<=f;g++){const x=g/f-.5,m=Math.min(1,Math.max(0,d+x)),w=this.getPoint(m);e.x=Math.min(e.x,w.x),e.y=Math.min(e.y,w.y),t.x=Math.max(t.x,w.x),t.y=Math.max(t.y,w.y)}})(h,10),{min:e,max:t}}toCommands(){const{start:e,startControl:t,endControl:s,end:i}=this;return[{type:"M",x:e.x,y:e.y},{type:"C",x1:t.x,y1:t.y,x2:s.x,y2:s.y,x:i.x,y:i.y}]}drawTo(e){const{start:t,startControl:s,endControl:i,end:r}=this;return e.lineTo(t.x,t.y),e.bezierCurveTo(s.x,s.y,i.x,i.y,r.x,r.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.startControl.copy(e.startControl),this.endControl.copy(e.endControl),this.end.copy(e.end),this}}const $t=new b,it=new b,rt=new b,_=new u;class ot extends k{constructor(e=new u,t=1,s=1,i=0,r=0,n=Math.PI*2,c=!1){super(),this.center=e,this.radiusX=t,this.radiusY=s,this.rotation=i,this.startAngle=r,this.endAngle=n,this.clockwise=c}isClockwise(){return this.clockwise}getPoint(e,t=new u){const s=Math.PI*2;let i=this.endAngle-this.startAngle;const r=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=s;for(;i>s;)i-=s;i<Number.EPSILON&&(r?i=0:i=s),this.clockwise&&!r&&(i===s?i=-s:i=i-s);const n=this.startAngle+e*i;let c=this.center.x+this.radiusX*Math.cos(n),a=this.center.y+this.radiusY*Math.sin(n);if(this.rotation!==0){const h=Math.cos(this.rotation),l=Math.sin(this.rotation),y=c-this.center.x,f=a-this.center.y;c=y*h-f*l+this.center.x,a=y*l+f*h+this.center.y}return t.set(c,a)}toCommands(){const{center:e,radiusX:t,radiusY:s,startAngle:i,endAngle:r,clockwise:n,rotation:c}=this,{x:a,y:h}=e,l=a+t*Math.cos(i)*Math.cos(c)-s*Math.sin(i)*Math.sin(c),y=h+t*Math.cos(i)*Math.sin(c)+s*Math.sin(i)*Math.cos(c),f=Math.abs(i-r),d=f>Math.PI?1:0,g=n?1:0,x=c*180/Math.PI;if(f>=2*Math.PI){const m=i+Math.PI,w=a+t*Math.cos(m)*Math.cos(c)-s*Math.sin(m)*Math.sin(c),E=h+t*Math.cos(m)*Math.sin(c)+s*Math.sin(m)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:w,y:E},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:0,sweepFlag:g,x:l,y}]}else{const m=a+t*Math.cos(r)*Math.cos(c)-s*Math.sin(r)*Math.sin(c),w=h+t*Math.cos(r)*Math.sin(c)+s*Math.sin(r)*Math.cos(c);return[{type:"M",x:l,y},{type:"A",rx:t,ry:s,angle:x,largeArcFlag:d,sweepFlag:g,x:m,y:w}]}}drawTo(e){const{center:t,radiusX:s,radiusY:i,rotation:r,startAngle:n,endAngle:c,clockwise:a}=this;return e.ellipse(t.x,t.y,s,i,r,n,c,!a),this}matrix(e){return _.set(this.center.x,this.center.y),_.applyMatrix3(e),this.center.x=_.x,this.center.y=_.y,Lt(e)?Nt(this,e):Et(this,e),this}getControlPoints(){return[this.center]}getMinMax(e=u.MAX,t=u.MIN){const{center:s,radiusX:i,radiusY:r,rotation:n}=this,{x:c,y:a}=s,h=Math.cos(n),l=Math.sin(n),y=Math.sqrt(i*i*h*h+r*r*l*l),f=Math.sqrt(i*i*l*l+r*r*h*h);return e.x=Math.min(e.x,c-y),e.y=Math.min(e.y,a-f),t.x=Math.max(t.x,c+y),t.y=Math.max(t.y,a+f),{min:e,max:t}}copy(e){return super.copy(e),this.center.x=e.center.x,this.center.y=e.center.y,this.radiusX=e.radiusX,this.radiusY=e.radiusY,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}}function Nt(o,e){const t=o.radiusX,s=o.radiusY,i=Math.cos(o.rotation),r=Math.sin(o.rotation),n=new u(t*i,t*r),c=new u(-s*r,s*i),a=n.applyMatrix3(e),h=c.applyMatrix3(e),l=$t.set(a.x,h.x,0,a.y,h.y,0,0,0,1),y=it.copy(l).invert(),g=rt.copy(y).transpose().multiply(y).elements,x=qt(g[0],g[1],g[4]),m=Math.sqrt(x.rt1),w=Math.sqrt(x.rt2);if(o.radiusX=1/m,o.radiusY=1/w,o.rotation=Math.atan2(x.sn,x.cs),!((o.endAngle-o.startAngle)%(2*Math.PI)<Number.EPSILON)){const v=it.set(m,0,0,0,w,0,0,0,1),S=rt.set(x.cs,x.sn,0,-x.sn,x.cs,0,0,0,1),$=v.multiply(S).multiply(l),z=D=>{const{x:U,y:H}=new u(Math.cos(D),Math.sin(D)).applyMatrix3($);return Math.atan2(H,U)};o.startAngle=z(o.startAngle),o.endAngle=z(o.endAngle),ht(e)&&(o.clockwise=!o.clockwise)}}function Et(o,e){const t=at(e),s=ct(e);o.radiusX*=t,o.radiusY*=s;const i=t>Number.EPSILON?Math.atan2(e.elements[1],e.elements[0]):Math.atan2(-e.elements[3],e.elements[4]);o.rotation+=i,ht(e)&&(o.startAngle*=-1,o.endAngle*=-1,o.clockwise=!o.clockwise)}function ht(o){const e=o.elements;return e[0]*e[4]-e[1]*e[3]<0}function Lt(o){const e=o.elements,t=e[0]*e[3]+e[1]*e[4];if(t===0)return!1;const s=at(o),i=ct(o);return Math.abs(t/(s*i))>Number.EPSILON}function at(o){const e=o.elements;return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function ct(o){const e=o.elements;return Math.sqrt(e[3]*e[3]+e[4]*e[4])}function qt(o,e,t){let s,i,r,n,c;const a=o+t,h=o-t,l=Math.sqrt(h*h+4*e*e);return a>0?(s=.5*(a+l),c=1/s,i=o*c*t-e*c*e):a<0?i=.5*(a-l):(s=.5*l,i=-.5*l),h>0?r=h+l:r=h-l,Math.abs(r)>2*Math.abs(e)?(c=-2*e/r,n=1/Math.sqrt(1+c*c),r=c*n):Math.abs(e)===0?(r=1,n=0):(c=-.5*r/e,r=1/Math.sqrt(1+c*c),n=c*r),h>0&&(c=r,r=-n,n=c),{rt1:s,rt2:i,cs:r,sn:n}}class X extends k{constructor(e=new u,t=new u){super(),this.start=e,this.end=t}getPoint(e,t=new u){return e===1?t.copy(this.end):t.copy(this.end).sub(this.start).scale(e).add(this.start),t}getPointAt(e,t=new u){return this.getPoint(e,t)}getTangent(e,t=new u){return t.subVectors(this.end,this.start).normalize()}getTangentAt(e,t=new u){return this.getTangent(e,t)}getControlPoints(){return[this.start,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,end:i}=this;return e.x=Math.min(e.x,s.x,i.x),e.y=Math.min(e.y,s.y,i.y),t.x=Math.max(t.x,s.x,i.x),t.y=Math.max(t.y,s.y,i.y),{min:e,max:t}}toCommands(){const{start:e,end:t}=this;return[{type:"M",x:e.x,y:e.y},{type:"L",x:t.x,y:t.y}]}drawTo(e){const{start:t,end:s}=this;return e.lineTo(t.x,t.y),e.lineTo(s.x,s.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.end.copy(e.end),this}}class zt extends k{constructor(t,s,i=0,r=1){super();T(this,"curveT",0);this.center=t,this.size=s,this.start=i,this.end=r,this.update()}update(){const{x:t,y:s}=this.center,i=new u(t+.5*this.size,s-.5*this.size),r=new u(t-.5*this.size,s-.5*this.size),n=new u(t,s+.5*this.size),c=new R(i,Math.SQRT1_2*this.size,-.25*Math.PI,.75*Math.PI),a=new R(r,Math.SQRT1_2*this.size,-.75*Math.PI,.25*Math.PI),h=new R(n,.5*Math.SQRT1_2*this.size,.75*Math.PI,1.25*Math.PI),l=new u(t,s+this.size),y=new u(t+this.size,s),f=new u().lerpVectors(y,l,.75),d=new u(t-this.size,s),g=new u().lerpVectors(d,l,.75),x=new X(y,f),m=new X(g,d);return this.curves=[c,x,h,m,a],this}getPoint(t){return this.getCurve(t).getPoint(this.curveT)}getPointAt(t){return this.getPoint(t)}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=9*Math.PI/8+1.5;let i;const r=.5*Math.PI;return s<r?(i=0,this.curveT=s/r):s<r+.75?(i=1,this.curveT=(s-r)/.75):s<5*Math.PI/8+.75?(i=2,this.curveT=(s-r-.75)/(Math.PI/8)):s<5*Math.PI/8+1.5?(i=3,this.curveT=(s-5*Math.PI/8-.75)/.75):(i=4,this.curveT=(s-5*Math.PI/8-1.5)/r),this.curves[i]}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class Dt extends k{constructor(t,s=0,i=0,r=0,n=1){super();T(this,"curves",[]);T(this,"curveT",0);T(this,"points",[]);this.center=t,this.radius=s,this.number=i,this.start=r,this.end=n,this.update()}update(){for(let t=0;t<this.number;t++){let s=t*2*Math.PI/this.number;s-=.5*Math.PI,this.points.push(new u(this.radius*Math.cos(s),this.radius*Math.sin(s)).add(this.center))}for(let t=0;t<this.number;t++)this.curves.push(new X(this.points[t],this.points[(t+1)%this.number]));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1);const i=s*this.number,r=Math.floor(i);return this.curveT=i-r,this.curves[r]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class lt extends k{constructor(e=new u,t=new u,s=new u){super(),this.start=e,this.control=t,this.end=s}getPoint(e,t=new u){const{start:s,control:i,end:r}=this;return t.set(et(e,s.x,i.x,r.x),et(e,s.y,i.y,r.y)),t}getControlPoints(){return[this.start,this.control,this.end]}getMinMax(e=u.MAX,t=u.MIN){const{start:s,control:i,end:r}=this,n=.5*(s.x+i.x),c=.5*(s.y+i.y),a=.5*(s.x+r.x),h=.5*(s.y+r.y);return e.x=Math.min(e.x,s.x,r.x,n,a),e.y=Math.min(e.y,s.y,r.y,c,h),t.x=Math.max(t.x,s.x,r.x,n,a),t.y=Math.max(t.y,s.y,r.y,c,h),{min:e,max:t}}toCommands(){const{start:e,control:t,end:s}=this;return[{type:"M",x:e.x,y:e.y},{type:"Q",x1:t.x,y1:t.y,x:s.x,y:s.y}]}drawTo(e){const{start:t,control:s,end:i}=this;return e.lineTo(t.x,t.y),e.quadraticCurveTo(s.x,s.y,i.x,i.y),this}copy(e){return super.copy(e),this.start.copy(e.start),this.control.copy(e.control),this.end.copy(e.end),this}}class ut extends k{constructor(t,s,i=1,r=0,n=1){super();T(this,"curves",[]);T(this,"curveT",0);this.center=t,this.rx=s,this.aspectRatio=i,this.start=r,this.end=n,this.update()}get x(){return this.center.x-this.rx}get y(){return this.center.y-this.rx/this.aspectRatio}get width(){return this.rx*2}get height(){return this.rx/this.aspectRatio*2}update(){const{x:t,y:s}=this.center,i=this.rx,r=this.rx/this.aspectRatio,n=[new u(t-i,s-r),new u(t+i,s-r),new u(t+i,s+r),new u(t-i,s+r)];for(let c=0;c<4;c++)this.curves.push(new X(n[c].clone(),n[(c+1)%4].clone()));return this}getCurve(t){let s=(t*(this.end-this.start)+this.start)%1;s<0&&(s+=1),s*=(1+this.aspectRatio)*2;let i;return s<this.aspectRatio?(i=0,this.curveT=s/this.aspectRatio):s<this.aspectRatio+1?(i=1,this.curveT=(s-this.aspectRatio)/1):s<2*this.aspectRatio+1?(i=2,this.curveT=(s-this.aspectRatio-1)/this.aspectRatio):(i=3,this.curveT=(s-2*this.aspectRatio-1)/1),this.curves[i]}getPoint(t,s){return this.getCurve(t).getPoint(this.curveT,s)}getPointAt(t,s){return this.getPoint(t,s)}getTangent(t,s){return this.getCurve(t).getTangent(this.curveT,s)}getNormal(t,s){return this.getCurve(t).getNormal(this.curveT,s)}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){return this.curves.forEach(s=>s.drawTo(t)),this}}class yt extends k{constructor(e=[]){super(),this.points=e}getPoint(e,t=new u){const{points:s}=this,i=(s.length-1)*e,r=Math.floor(i),n=i-r,c=s[r===0?r:r-1],a=s[r],h=s[r>s.length-2?s.length-1:r+1],l=s[r>s.length-3?s.length-1:r+2];return t.set(tt(n,c.x,a.x,h.x,l.x),tt(n,c.y,a.y,h.y,l.y)),t}getControlPoints(){return this.points}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t<s;t++)this.points.push(e.points[t].clone());return this}}class F extends k{constructor(t){super();T(this,"curves",[]);T(this,"startPoint");T(this,"currentPoint");T(this,"autoClose",!1);T(this,"_cacheLengths",[]);t&&this.addPoints(t)}addCurve(t){return this.curves.push(t),this}addPoints(t){this.moveTo(t[0].x,t[0].y);for(let s=1,i=t.length;s<i;s++){const{x:r,y:n}=t[s];this.lineTo(r,n)}return this}addCommands(t){return Y(t,this),this}addData(t){return this.addCommands(G(t)),this}getPoint(t,s=new u){const i=t*this.getLength(),r=this.getCurveLengths();let n=0;for(;n<r.length;){if(r[n]>=i){const c=r[n]-i,a=this.curves[n],h=a.getLength();return a.getPointAt(h===0?0:1-c/h,s)}n++}return s}getControlPoints(){return this.curves.flatMap(t=>t.getControlPoints())}getLength(){const t=this.getCurveLengths();return t[t.length-1]}updateArcLengths(){super.updateArcLengths(),this._cacheLengths=[],this.getCurveLengths()}getCurveLengths(){if(this._cacheLengths.length===this.curves.length)return this._cacheLengths;const t=[];let s=0;for(let i=0,r=this.curves.length;i<r;i++)s+=this.curves[i].getLength(),t.push(s);return this._cacheLengths=t,t}getSpacedPoints(t=40){const s=[];for(let i=0;i<=t;i++)s.push(this.getPoint(i/t));return this.autoClose&&s.push(s[0]),s}getPoints(t=12){const s=[],i=this.curves;let r;for(let n=0,c=i.length;n<c;n++){const h=i[n].getPoints(t);for(let l=0;l<h.length;l++){const y=h[l];r!=null&&r.equals(y)||(s.push(y),r=y)}}return this.autoClose&&s.length>1&&!s[s.length-1].equals(s[0])&&s.push(s[0]),s}_setCurrentPoint(t){return this.currentPoint=new u(t.x,t.y),this.startPoint||(this.startPoint=this.currentPoint.clone()),this}closePath(){const t=this.startPoint;if(t){const s=this.currentPoint;s&&!t.equals(s)&&(this.curves.push(new X(s.clone(),t)),s.copy(t)),this.startPoint=void 0}return this}moveTo(t,s){return this.currentPoint=new u(t,s),this.startPoint=this.currentPoint.clone(),this}lineTo(t,s){const i=this.currentPoint;return i!=null&&i.equals({x:t,y:s})||this.curves.push(new X((i==null?void 0:i.clone())??new u,new u(t,s))),this._setCurrentPoint({x:t,y:s}),this}bezierCurveTo(t,s,i,r,n,c){const a=this.currentPoint;return a!=null&&a.equals({x:n,y:c})||this.curves.push(new nt((a==null?void 0:a.clone())??new u,new u(t,s),new u(i,r),new u(n,c))),this._setCurrentPoint({x:n,y:c}),this}quadraticCurveTo(t,s,i,r){const n=this.currentPoint;return n!=null&&n.equals({x:i,y:r})||this.curves.push(new lt((n==null?void 0:n.clone())??new u,new u(t,s),new u(i,r))),this._setCurrentPoint({x:i,y:r}),this}arc(t,s,i,r,n,c){return this.ellipse(t,s,i,i,0,r,n,c),this}relativeArc(t,s,i,r,n,c){const a=this.currentPoint??new u;return this.arc(t+a.x,s+a.y,i,r,n,c),this}arcTo(t,s,i,r,n){return console.warn("Method arcTo not supported yet"),this}ellipse(t,s,i,r,n,c,a,h=!0){const l=new ot(new u(t,s),i,r,n,c,a,!h);if(this.curves.length>0){const y=l.getPoint(0);(!this.currentPoint||!y.equals(this.currentPoint))&&this.lineTo(y.x,y.y)}return this.curves.push(l),this._setCurrentPoint(l.getPoint(1)),this}relativeEllipse(t,s,i,r,n,c,a,h){const l=this.currentPoint??new u;return this.ellipse(t+l.x,s+l.y,i,r,n,c,a,h),this}rect(t,s,i,r){return this.curves.push(new ut(new u(t+i/2,s+r/2),i/2,i/r)),this._setCurrentPoint({x:t,y:s}),this}splineThru(t){const s=this.currentPoint??new u;return this.curves.push(new yt([s].concat(t))),this._setCurrentPoint(t[t.length-1]),this}getMinMax(t=u.MAX,s=u.MIN){return this.curves.forEach(i=>i.getMinMax(t,s)),{min:t,max:s}}getBoundingBox(){const{min:t,max:s}=this.getMinMax();return new L(t.x,t.y,s.x-t.x,s.y-t.y)}toCommands(){return this.curves.flatMap(t=>t.toCommands())}drawTo(t){var i;const s=(i=this.curves[0])==null?void 0:i.getPoint(0);return s&&t.moveTo(s.x,s.y),this.curves.forEach(r=>r.drawTo(t)),this.autoClose&&t.closePath(),this}copy(t){var s;super.copy(t),this.curves=[];for(let i=0,r=t.curves.length;i<r;i++)this.curves.push(t.curves[i].clone());return this.autoClose=t.autoClose,this.currentPoint=(s=t.currentPoint)==null?void 0:s.clone(),this}}function Xt(o){return o.replace(/[^a-z0-9]/gi,"-").replace(/\B([A-Z])/g,"-$1").toLowerCase()}function Ot(o,e,t,s){const i=e.clone().sub(o),r=s.clone().sub(t),n=t.clone().sub(o),c=i.cross(r);if(c===0)return new u((o.x+t.x)/2,(o.y+t.y)/2);const a=n.cross(r)/c;return Math.abs(a)>1?new u((o.x+t.x)/2,(o.y+t.y)/2):new u(o.x+a*i.x,o.y+a*i.y)}class I{constructor(e,t={}){T(this,"currentPath",new F);T(this,"paths",[this.currentPath]);T(this,"style");e&&(e instanceof I?this.addPath(e):Array.isArray(e)?this.addCommands(e):this.addData(e)),this.style=t}get startPoint(){return this.currentPath.startPoint}get currentPoint(){return this.currentPath.currentPoint}get strokeWidth(){return this.style.strokeWidth??((this.style.stroke??"none")==="none"?0:1)}addPath(e){return e instanceof I?this.paths.push(...e.paths.map(t=>t.clone())):this.paths.push(e),this}closePath(){const e=this.startPoint;return e&&(this.currentPath.closePath(),this.currentPath.curves.length>0&&(this.currentPath=new F().moveTo(e.x,e.y),this.paths.push(this.currentPath))),this}moveTo(e,t){const{currentPoint:s,curves:i}=this.currentPath;return s!=null&&s.equals({x:e,y:t})||(i.length?(this.currentPath=new F().moveTo(e,t),this.paths.push(this.currentPath)):this.currentPath.moveTo(e,t)),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}bezierCurveTo(e,t,s,i,r,n){return this.currentPath.bezierCurveTo(e,t,s,i,r,n),this}quadraticCurveTo(e,t,s,i){return this.currentPath.quadraticCurveTo(e,t,s,i),this}arc(e,t,s,i,r,n){return this.currentPath.arc(e,t,s,i,r,n),this}arcTo(e,t,s,i,r){return this.currentPath.arcTo(e,t,s,i,r),this}ellipse(e,t,s,i,r,n,c,a){return this.currentPath.ellipse(e,t,s,i,r,n,c,a),this}rect(e,t,s,i){return this.currentPath.rect(e,t,s,i),this}addCommands(e){return Y(e,this),this}addData(e){return this.addCommands(G(e)),this}splineThru(e){return this.currentPath.splineThru(e),this}getControlPoints(){return this.paths.flatMap(e=>e.getControlPoints())}getCurves(){return this.paths.flatMap(e=>e.curves)}scale(e,t=e,s={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.scale(e,t,s)}),this}skew(e,t=0,s={x:0,y:0}){return this.getControlPoints().forEach(i=>{i.skew(e,t,s)}),this}rotate(e,t={x:0,y:0}){return this.getControlPoints().forEach(s=>{s.rotate(e,t)}),this}bold(e){if(e===0)return this;const t=this.getCurves(),s=[],i=[],r=[];t.forEach((c,a)=>{const h=c.getControlPoints(),l=c.isClockwise();r[a]=h,i[a]=l;const y=h[0],f=h[h.length-1]??y;s.push({start:l?f:y,end:l?y:f,index:a})});const n=[];return s.forEach((c,a)=>{n[a]=[],s.forEach((h,l)=>{l!==a&&h.start.equals(c.end)&&n[a].push(h.index)})}),t.forEach((c,a)=>{const h=i[a];r[a].forEach(y=>{const f=c.getTForPoint(y),d=c.getNormal(f).scale(h?e:-e);y.add(d)})}),n.forEach((c,a)=>{const h=r[a];c.forEach(l=>{const y=r[l],f=Ot(h[h.length-1],h[h.length-2]??h[h.length-1],y[0],y[1]??y[0]);f&&(h[h.length-1].copy(f),y[0].copy(f))})}),this}matrix(e){return this.getCurves().forEach(t=>t.matrix(e)),this}getMinMax(e=u.MAX,t=u.MIN,s=!0){const i=this.strokeWidth;return this.getCurves().forEach(r=>{if(r.getMinMax(e,t),s&&i>1){const n=i/2,c=r.isClockwise(),a=[];for(let h=0;h<=1;h+=1/r.arcLengthDivisions){const l=r.getPoint(h),y=r.getNormal(h),f=y.clone().scale(c?n:-n),d=y.clone().scale(c?-n:n);a.push(l.clone().add(f),l.clone().add(d),l.clone().add({x:n,y:0}),l.clone().add({x:-n,y:0}),l.clone().add({x:0,y:n}),l.clone().add({x:0,y:-n}),l.clone().add({x:n,y:n}),l.clone().add({x:-n,y:-n}))}e.min(...a),t.max(...a)}}),{min:e,max:t}}getBoundingBox(e=!0){const{min:t,max:s}=this.getMinMax(void 0,void 0,e);return new L(t.x,t.y,s.x-t.x,s.y-t.y)}drawTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),q(e,t),this.paths.forEach(r=>{r.drawTo(e)}),s!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}drawControlPointsTo(e,t={}){t={...this.style,...t};const{fill:s="#000",stroke:i="none"}=t;return e.beginPath(),e.save(),q(e,t),this.getControlPoints().forEach(r=>{e.moveTo(r.x,r.y),e.arc(r.x,r.y,4,0,Math.PI*2)}),s!=="none"&&e.fill(),i!=="none"&&e.stroke(),e.restore(),this}toCommands(){return this.paths.flatMap(e=>e.toCommands())}toData(){return this.paths.map(e=>e.toData()).join(" ")}toSvgPathString(){const e={...this.style,fill:this.style.fill??"#000",stroke:this.style.stroke??"none"},t={};for(const i in e)e[i]!==void 0&&(t[Xt(i)]=e[i]);Object.assign(t,{"stroke-width":`${this.strokeWidth}px`});let s="";for(const i in t)t[i]!==void 0&&(s+=`${i}:${t[i]};`);return`<path d="${this.toData()}" style="${s}"></path>`}toSvgString(){const{x:e,y:t,width:s,height:i}=this.getBoundingBox(),r=this.toSvgPathString();return`<svg viewBox="${e} ${t} ${s} ${i}" width="${s}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${r}</svg>`}toSvgUrl(){return`data:image/svg+xml;base64,${btoa(this.toSvgString())}`}toSvg(){return new DOMParser().parseFromString(this.toSvgString(),"image/svg+xml").documentElement}toCanvas(e={}){const{pixelRatio:t=2,...s}=e,{left:i,top:r,width:n,height:c}=this.getBoundingBox(),a=document.createElement("canvas");a.width=n*t,a.height=c*t,a.style.width=`${n}px`,a.style.height=`${c}px`;const h=a.getContext("2d");return h&&(h.scale(t,t),h.translate(-i,-r),this.drawTo(h,s)),a}copy(e){return this.currentPath=e.currentPath.clone(),this.paths=e.paths.map(t=>t.clone()),this.style={...e.style},this}clone(){return new this.constructor().copy(this)}}const Ft="px",Rt=90,gt=["mm","cm","in","pt","pc","px"],ft={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 M(o){let e="px";if(typeof o=="string"||o instanceof String)for(let s=0,i=gt.length;s<i;s++){const r=gt[s];if(o.endsWith(r)){e=r,o=o.substring(0,o.length-r.length);break}}let t;return t=ft[e][Ft],t<0&&(t=ft[e].in*Rt),t*Number.parseFloat(o)}const _t=new b,B=new b,pt=new b,dt=new b;function Bt(o,e,t){if(!(o.hasAttribute("transform")||o.nodeName==="use"&&(o.hasAttribute("x")||o.hasAttribute("y"))))return null;const s=Ut(o);return t.length>0&&s.premultiply(t[t.length-1]),e.copy(s),t.push(s),s}function Ut(o){const e=new b,t=_t;if(o.nodeName==="use"&&(o.hasAttribute("x")||o.hasAttribute("y"))&&e.translate(M(o.getAttribute("x")),M(o.getAttribute("y"))),o.hasAttribute("transform")){const s=o.getAttribute("transform").split(")");for(let i=s.length-1;i>=0;i--){const r=s[i].trim();if(r==="")continue;const n=r.indexOf("("),c=r.length;if(n>0&&n<c){const a=r.slice(0,n),h=A(r.slice(n+1));switch(t.identity(),a){case"translate":if(h.length>=1){const l=h[0];let y=0;h.length>=2&&(y=h[1]),t.translate(l,y)}break;case"rotate":if(h.length>=1){let l=0,y=0,f=0;l=h[0]*Math.PI/180,h.length>=3&&(y=h[1],f=h[2]),B.makeTranslation(-y,-f),pt.makeRotation(l),dt.multiplyMatrices(pt,B),B.makeTranslation(y,f),t.multiplyMatrices(B,dt)}break;case"scale":h.length>=1&&t.scale(h[0],h[1]??h[0]);break;case"skewX":h.length===1&&t.set(1,Math.tan(h[0]*Math.PI/180),0,0,1,0,0,0,1);break;case"skewY":h.length===1&&t.set(1,0,0,Math.tan(h[0]*Math.PI/180),1,0,0,0,1);break;case"matrix":h.length===6&&t.set(h[0],h[2],h[4],h[1],h[3],h[5],0,0,1);break}}e.premultiply(t)}}return e}function Wt(o){return new I().addPath(new F().arc(M(o.getAttribute("cx")||0),M(o.getAttribute("cy")||0),M(o.getAttribute("r")||0),0,Math.PI*2))}function Yt(o,e){if(!(!o.sheet||!o.sheet.cssRules||!o.sheet.cssRules.length))for(let t=0;t<o.sheet.cssRules.length;t++){const s=o.sheet.cssRules[t];if(s.type!==1)continue;const i=s.selectorText.split(/,/g).filter(Boolean).map(n=>n.trim()),r={};for(let n=s.style.length,c=0;c<n;c++){const a=s.style.item(c);r[a]=s.style.getPropertyValue(a)}for(let n=0;n<i.length;n++)e[i[n]]=Object.assign(e[i[n]]||{},{...r})}}function Gt(o){return new I().addPath(new F().ellipse(M(o.getAttribute("cx")||0),M(o.getAttribute("cy")||0),M(o.getAttribute("rx")||0),M(o.getAttribute("ry")||0),0,0,Math.PI*2))}function Qt(o){return new I().moveTo(M(o.getAttribute("x1")||0),M(o.getAttribute("y1")||0)).lineTo(M(o.getAttribute("x2")||0),M(o.getAttribute("y2")||0))}function Vt(o){const e=new I,t=o.getAttribute("d");return!t||t==="none"?null:(e.addData(t),e)}const jt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Ht(o){var s;const e=new I;let t=0;return(s=o.getAttribute("points"))==null||s.replace(jt,(i,r,n)=>{const c=M(r),a=M(n);return t===0?e.moveTo(c,a):e.lineTo(c,a),t++,i}),e.currentPath.autoClose=!0,e}const Zt=/([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(?:,|\s)([+-]?\d*\.?\d+(?:e[+-]?\d+)?)/g;function Jt(o){var s;const e=new I;let t=0;return(s=o.getAttribute("points"))==null||s.replace(Zt,(i,r,n)=>{const c=M(r),a=M(n);return t===0?e.moveTo(c,a):e.lineTo(c,a),t++,i}),e.currentPath.autoClose=!1,e}function Kt(o){const e=M(o.getAttribute("x")||0),t=M(o.getAttribute("y")||0),s=M(o.getAttribute("rx")||o.getAttribute("ry")||0),i=M(o.getAttribute("ry")||o.getAttribute("rx")||0),r=M(o.getAttribute("width")),n=M(o.getAttribute("height")),c=1-.551915024494,a=new I;return a.moveTo(e+s,t),a.lineTo(e+r-s,t),(s!==0||i!==0)&&a.bezierCurveTo(e+r-s*c,t,e+r,t+i*c,e+r,t+i),a.lineTo(e+r,t+n-i),(s!==0||i!==0)&&a.bezierCurveTo(e+r,t+n-i*c,e+r-s*c,t+n,e+r-s,t+n),a.lineTo(e+s,t+n),(s!==0||i!==0)&&a.bezierCurveTo(e+s*c,t+n,e,t+n-i*c,e,t+n-i),a.lineTo(e,t+i),(s!==0||i!==0)&&a.bezierCurveTo(e,t+i*c,e+s*c,t,e+s,t),a}function N(o,e,t){e=Object.assign({},e);let s={};if(o.hasAttribute("class")){const h=o.getAttribute("class").split(/\s/).filter(Boolean).map(l=>l.trim());for(let l=0;l<h.length;l++)s=Object.assign(s,t[`.${h[l]}`])}o.hasAttribute("id")&&(s=Object.assign(s,t[`#${o.getAttribute("id")}`]));for(let h=o.style.length,l=0;l<h;l++){const y=o.style.item(l),f=o.style.getPropertyValue(y);e[y]=f,s[y]=f}function i(h,l,y=r){o.hasAttribute(h)&&(e[l]=y(o.getAttribute(h))),s[h]&&(e[l]=y(s[h]))}function r(h){return h.startsWith("url")&&console.warn("url access in attributes is not implemented."),h}function n(h){return Math.max(0,Math.min(1,M(h)))}function c(h){return Math.max(0,M(h))}function a(h){return h.split(" ").filter(l=>l!=="").map(l=>M(l))}return i("fill","fill"),i("fill-opacity","fillOpacity",n),i("fill-rule","fillRule"),i("opacity","opacity",n),i("stroke","stroke"),i("stroke-opacity","strokeOpacity",n),i("stroke-width","strokeWidth",c),i("stroke-linecap","strokeLinecap"),i("stroke-linejoin","strokeLinejoin"),i("stroke-miterlimit","strokeMiterlimit",c),i("stroke-dasharray","strokeDasharray",a),i("stroke-dashoffset","strokeDashoffset",M),i("visibility","visibility"),e}function Q(o,e,t=[],s={}){var y;if(o.nodeType!==1)return t;let i=!1,r=null,n={...e};switch(o.nodeName){case"svg":n=N(o,n,s);break;case"style":Yt(o,s);break;case"g":n=N(o,n,s);break;case"path":n=N(o,n,s),o.hasAttribute("d")&&(r=Vt(o));break;case"rect":n=N(o,n,s),r=Kt(o);break;case"polygon":n=N(o,n,s),r=Ht(o);break;case"polyline":n=N(o,n,s),r=Jt(o);break;case"circle":n=N(o,n,s),r=Wt(o);break;case"ellipse":n=N(o,n,s),r=Gt(o);break;case"line":n=N(o,n,s),r=Qt(o);break;case"defs":i=!0;break;case"use":{n=N(o,n,s);const d=(o.getAttributeNS("http://www.w3.org/1999/xlink","href")||"").substring(1),g=(y=o.viewportElement)==null?void 0:y.getElementById(d);g?Q(g,n,t,s):console.warn(`'use node' references non-existent node id: ${d}`);break}default:console.warn(o);break}if(n.display==="none")return t;Object.assign(e,n);const c=new b,a=[],h=Bt(o,c,a);r&&(r.matrix(c),t.push(r),r.style=e);const l=o.childNodes;for(let f=0,d=l.length;f<d;f++){const g=l[f];i&&g.nodeName!=="style"&&g.nodeName!=="defs"||Q(g,e,t,s)}return h&&(a.pop(),a.length>0?c.copy(a[a.length-1]):c.identity()),t}const xt="data:image/svg+xml;",mt=`${xt}base64,`,Mt=`${xt}charset=utf8,`;function Pt(o){if(typeof o=="string"){let e;o.startsWith(mt)?(o=o.substring(mt.length,o.length),e=atob(o)):o.startsWith(Mt)?(o=o.substring(Mt.length,o.length),e=decodeURIComponent(o)):e=o;const t=new DOMParser().parseFromString(e,"text/xml"),s=t.querySelector("parsererror");if(s)throw new Error(`${s.textContent??"parser error"}
2
+ ${e}`);return t.documentElement}else return o}function te(o){return Q(Pt(o),{})}function V(o,e=!0){if(!o.length)return;const t=u.MAX,s=u.MIN;return o.forEach(i=>i.getMinMax(t,s,e)),new L(t.x,t.y,s.x-t.x,s.y-t.y)}function j(o){const{x:e,y:t,width:s,height:i}=V(o),r=o.map(n=>n.toSvgPathString()).join("");return`<svg viewBox="${e} ${t} ${s} ${i}" width="${s}px" height="${i}px" xmlns="http://www.w3.org/2000/svg">${r}</svg>`}function ee(o){return`data:image/svg+xml;base64,${btoa(j(o))}`}function se(o){return new DOMParser().parseFromString(j(o),"image/svg+xml").documentElement}function ne(o,e={}){const{pixelRatio:t=2,...s}=e,{left:i,top:r,width:n,height:c}=V(o),a=document.createElement("canvas");a.width=n*t,a.height=c*t,a.style.width=`${n}px`,a.style.height=`${c}px`;const h=a.getContext("2d");return h&&(h.scale(t,t),h.translate(-i,-r),o.forEach(l=>{l.drawTo(h,s)})),a}p.BoundingBox=L,p.CircleCurve=R,p.CubicBezierCurve=nt,p.Curve=k,p.CurvePath=F,p.EllipseCurve=ot,p.HeartCurve=zt,p.LineCurve=X,p.Matrix3=b,p.Path2D=I,p.PloygonCurve=Dt,p.QuadraticBezierCurve=lt,p.RectangularCurve=ut,p.SplineCurve=yt,p.Vector2=u,p.addPathCommandsToPath2D=Y,p.getPathsBoundingBox=V,p.parseArcCommand=J,p.parsePathDataArgs=A,p.parseSvg=te,p.parseSvgToDom=Pt,p.pathCommandsToPathData=K,p.pathDataToPathCommands=G,p.pathsToCanvas=ne,p.pathsToSvg=se,p.pathsToSvgString=j,p.pathsToSvgUrl=ee,p.setCanvasContext=q,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -250,15 +250,9 @@ class BoundingBox {
250
250
  }
251
251
  }
252
252
 
253
- var __defProp$6 = Object.defineProperty;
254
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
255
- var __publicField$6 = (obj, key, value) => {
256
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
257
- return value;
258
- };
259
253
  class Matrix3 {
254
+ elements = [];
260
255
  constructor(n11 = 1, n12 = 0, n13 = 0, n21 = 0, n22 = 1, n23 = 0, n31 = 0, n32 = 0, n33 = 1) {
261
- __publicField$6(this, "elements", []);
262
256
  this.set(n11, n12, n13, n21, n22, n23, n31, n32, n33);
263
257
  }
264
258
  set(n11, n12, n13, n21, n22, n23, n31, n32, n33) {
@@ -495,7 +489,7 @@ function parseArcCommand(path, rx, ry, xAxisRotation, largeArcFlag, sweepFlag, s
495
489
  const cy = Math.sin(xAxisRotation) * cxp + Math.cos(xAxisRotation) * cyp + (start.y + end.y) / 2;
496
490
  const theta = svgAngle(1, 0, (x1p - cxp) / rx, (y1p - cyp) / ry);
497
491
  const delta = svgAngle((x1p - cxp) / rx, (y1p - cyp) / ry, (-x1p - cxp) / rx, (-y1p - cyp) / ry) % (Math.PI * 2);
498
- path.ellipse(cx, cy, rx, ry, xAxisRotation, theta, theta + delta, sweepFlag === 1);
492
+ path.ellipse(cx, cy, rx, ry, xAxisRotation, theta, theta + delta, sweepFlag === 0);
499
493
  }
500
494
 
501
495
  function getReflection(a, b) {
@@ -696,8 +690,7 @@ function parsePathDataArgs(input, flags, stride = 0) {
696
690
  if (number !== "") {
697
691
  if (exponent === "")
698
692
  result.push(Number(number));
699
- else
700
- result.push(Number(number) * 10 ** Number(exponent));
693
+ else result.push(Number(number) * 10 ** Number(exponent));
701
694
  }
702
695
  number = "";
703
696
  exponent = "";
@@ -806,69 +799,69 @@ function parsePathDataArgs(input, flags, stride = 0) {
806
799
  function pathCommandsToPathData(commands) {
807
800
  let first;
808
801
  let prev;
809
- let data = "";
802
+ const data = [];
810
803
  for (let i = 0, len = commands.length; i < len; i++) {
811
804
  const cmd = commands[i];
812
805
  switch (cmd.type) {
813
806
  case "m":
814
807
  case "M":
815
- if (cmd.x === prev?.x && cmd.y === prev?.y) {
808
+ if (cmd.x.toFixed(4) === prev?.x.toFixed(4) && cmd.y.toFixed(4) === prev?.y.toFixed(4)) {
816
809
  continue;
817
810
  }
818
- data += `${cmd.type} ${cmd.x} ${cmd.y}`;
811
+ data.push(`${cmd.type} ${cmd.x} ${cmd.y}`);
819
812
  prev = { x: cmd.x, y: cmd.y };
820
813
  first = { x: cmd.x, y: cmd.y };
821
814
  break;
822
815
  case "h":
823
816
  case "H":
824
- data += `${cmd.type} ${cmd.x}`;
817
+ data.push(`${cmd.type} ${cmd.x}`);
825
818
  prev = { x: cmd.x, y: prev?.y ?? 0 };
826
819
  break;
827
820
  case "v":
828
821
  case "V":
829
- data += `${cmd.type} ${cmd.y}`;
822
+ data.push(`${cmd.type} ${cmd.y}`);
830
823
  prev = { x: prev?.x ?? 0, y: cmd.y };
831
824
  break;
832
825
  case "l":
833
826
  case "L":
834
- data += `${cmd.type} ${cmd.x} ${cmd.y}`;
827
+ data.push(`${cmd.type} ${cmd.x} ${cmd.y}`);
835
828
  prev = { x: cmd.x, y: cmd.y };
836
829
  break;
837
830
  case "c":
838
831
  case "C":
839
- data += `${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`;
832
+ data.push(`${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`);
840
833
  prev = { x: cmd.x, y: cmd.y };
841
834
  break;
842
835
  case "s":
843
836
  case "S":
844
- data += `${cmd.type} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`;
837
+ data.push(`${cmd.type} ${cmd.x2} ${cmd.y2} ${cmd.x} ${cmd.y}`);
845
838
  prev = { x: cmd.x, y: cmd.y };
846
839
  break;
847
840
  case "q":
848
841
  case "Q":
849
- data += `${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x} ${cmd.y}`;
842
+ data.push(`${cmd.type} ${cmd.x1} ${cmd.y1} ${cmd.x} ${cmd.y}`);
850
843
  prev = { x: cmd.x, y: cmd.y };
851
844
  break;
852
845
  case "t":
853
846
  case "T":
854
- data += `${cmd.type} ${cmd.x} ${cmd.y}`;
847
+ data.push(`${cmd.type} ${cmd.x} ${cmd.y}`);
855
848
  prev = { x: cmd.x, y: cmd.y };
856
849
  break;
857
850
  case "a":
858
851
  case "A":
859
- data += `${cmd.type} ${cmd.rx} ${cmd.ry} ${cmd.angle} ${cmd.largeArcFlag} ${cmd.sweepFlag} ${cmd.x} ${cmd.y}`;
852
+ data.push(`${cmd.type} ${cmd.rx} ${cmd.ry} ${cmd.angle} ${cmd.largeArcFlag} ${cmd.sweepFlag} ${cmd.x} ${cmd.y}`);
860
853
  prev = { x: cmd.x, y: cmd.y };
861
854
  break;
862
855
  case "z":
863
856
  case "Z":
864
- data += cmd.type;
857
+ data.push(cmd.type);
865
858
  if (first) {
866
859
  prev = { x: first.x, y: first.y };
867
860
  }
868
861
  break;
869
862
  }
870
863
  }
871
- return data;
864
+ return data.join(" ");
872
865
  }
873
866
 
874
867
  const RE$2 = /[a-df-z][^a-df-z]*/gi;
@@ -997,18 +990,10 @@ function pathDataToPathCommands(d) {
997
990
  return commands;
998
991
  }
999
992
 
1000
- var __defProp$5 = Object.defineProperty;
1001
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1002
- var __publicField$5 = (obj, key, value) => {
1003
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
1004
- return value;
1005
- };
1006
993
  class Curve {
1007
- constructor() {
1008
- __publicField$5(this, "arcLengthDivisions", 200);
1009
- __publicField$5(this, "_cacheArcLengths");
1010
- __publicField$5(this, "_needsUpdate", false);
1011
- }
994
+ arcLengthDivisions = 200;
995
+ _cacheArcLengths;
996
+ _needsUpdate = false;
1012
997
  isClockwise() {
1013
998
  const prev = this.getPoint(1);
1014
999
  const cur = this.getPoint(0.5);
@@ -1362,10 +1347,8 @@ class EllipseCurve extends Curve {
1362
1347
  const twoPi = Math.PI * 2;
1363
1348
  let deltaAngle = this.endAngle - this.startAngle;
1364
1349
  const samePoints = Math.abs(deltaAngle) < Number.EPSILON;
1365
- while (deltaAngle < 0)
1366
- deltaAngle += twoPi;
1367
- while (deltaAngle > twoPi)
1368
- deltaAngle -= twoPi;
1350
+ while (deltaAngle < 0) deltaAngle += twoPi;
1351
+ while (deltaAngle > twoPi) deltaAngle -= twoPi;
1369
1352
  if (deltaAngle < Number.EPSILON) {
1370
1353
  if (samePoints) {
1371
1354
  deltaAngle = 0;
@@ -1677,12 +1660,6 @@ class LineCurve extends Curve {
1677
1660
  }
1678
1661
  }
1679
1662
 
1680
- var __defProp$4 = Object.defineProperty;
1681
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1682
- var __publicField$4 = (obj, key, value) => {
1683
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
1684
- return value;
1685
- };
1686
1663
  class HeartCurve extends Curve {
1687
1664
  constructor(center, size, start = 0, end = 1) {
1688
1665
  super();
@@ -1690,9 +1667,9 @@ class HeartCurve extends Curve {
1690
1667
  this.size = size;
1691
1668
  this.start = start;
1692
1669
  this.end = end;
1693
- __publicField$4(this, "curveT", 0);
1694
1670
  this.update();
1695
1671
  }
1672
+ curveT = 0;
1696
1673
  update() {
1697
1674
  const { x, y } = this.center;
1698
1675
  const A = new Vector2(x + 0.5 * this.size, y - 0.5 * this.size);
@@ -1763,12 +1740,6 @@ class HeartCurve extends Curve {
1763
1740
  }
1764
1741
  }
1765
1742
 
1766
- var __defProp$3 = Object.defineProperty;
1767
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1768
- var __publicField$3 = (obj, key, value) => {
1769
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
1770
- return value;
1771
- };
1772
1743
  class PloygonCurve extends Curve {
1773
1744
  constructor(center, radius = 0, number = 0, start = 0, end = 1) {
1774
1745
  super();
@@ -1777,11 +1748,11 @@ class PloygonCurve extends Curve {
1777
1748
  this.number = number;
1778
1749
  this.start = start;
1779
1750
  this.end = end;
1780
- __publicField$3(this, "curves", []);
1781
- __publicField$3(this, "curveT", 0);
1782
- __publicField$3(this, "points", []);
1783
1751
  this.update();
1784
1752
  }
1753
+ curves = [];
1754
+ curveT = 0;
1755
+ points = [];
1785
1756
  update() {
1786
1757
  for (let i = 0; i < this.number; i++) {
1787
1758
  let radian = i * 2 * Math.PI / this.number;
@@ -1890,12 +1861,6 @@ class QuadraticBezierCurve extends Curve {
1890
1861
  }
1891
1862
  }
1892
1863
 
1893
- var __defProp$2 = Object.defineProperty;
1894
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1895
- var __publicField$2 = (obj, key, value) => {
1896
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
1897
- return value;
1898
- };
1899
1864
  class RectangularCurve extends Curve {
1900
1865
  constructor(center, rx, aspectRatio = 1, start = 0, end = 1) {
1901
1866
  super();
@@ -1904,10 +1869,10 @@ class RectangularCurve extends Curve {
1904
1869
  this.aspectRatio = aspectRatio;
1905
1870
  this.start = start;
1906
1871
  this.end = end;
1907
- __publicField$2(this, "curves", []);
1908
- __publicField$2(this, "curveT", 0);
1909
1872
  this.update();
1910
1873
  }
1874
+ curves = [];
1875
+ curveT = 0;
1911
1876
  get x() {
1912
1877
  return this.center.x - this.rx;
1913
1878
  }
@@ -2016,20 +1981,14 @@ class SplineCurve extends Curve {
2016
1981
  }
2017
1982
  }
2018
1983
 
2019
- var __defProp$1 = Object.defineProperty;
2020
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2021
- var __publicField$1 = (obj, key, value) => {
2022
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2023
- return value;
2024
- };
2025
1984
  class CurvePath extends Curve {
1985
+ curves = [];
1986
+ startPoint;
1987
+ currentPoint;
1988
+ autoClose = false;
1989
+ _cacheLengths = [];
2026
1990
  constructor(points) {
2027
1991
  super();
2028
- __publicField$1(this, "curves", []);
2029
- __publicField$1(this, "startPoint");
2030
- __publicField$1(this, "currentPoint", new Vector2());
2031
- __publicField$1(this, "autoClose", false);
2032
- __publicField$1(this, "_cacheLengths", []);
2033
1992
  if (points) {
2034
1993
  this.addPoints(points);
2035
1994
  }
@@ -2125,7 +2084,7 @@ class CurvePath extends Curve {
2125
2084
  return points;
2126
2085
  }
2127
2086
  _setCurrentPoint(point) {
2128
- this.currentPoint.copy(point);
2087
+ this.currentPoint = new Vector2(point.x, point.y);
2129
2088
  if (!this.startPoint) {
2130
2089
  this.startPoint = this.currentPoint.clone();
2131
2090
  }
@@ -2135,24 +2094,25 @@ class CurvePath extends Curve {
2135
2094
  const start = this.startPoint;
2136
2095
  if (start) {
2137
2096
  const end = this.currentPoint;
2138
- if (!start.equals(end)) {
2097
+ if (end && !start.equals(end)) {
2139
2098
  this.curves.push(new LineCurve(end.clone(), start));
2140
- this.currentPoint.copy(start);
2099
+ end.copy(start);
2141
2100
  }
2142
2101
  this.startPoint = void 0;
2143
2102
  }
2144
2103
  return this;
2145
2104
  }
2146
2105
  moveTo(x, y) {
2147
- this.currentPoint.set(x, y);
2106
+ this.currentPoint = new Vector2(x, y);
2148
2107
  this.startPoint = this.currentPoint.clone();
2149
2108
  return this;
2150
2109
  }
2151
2110
  lineTo(x, y) {
2152
- if (!this.currentPoint.equals({ x, y })) {
2111
+ const start = this.currentPoint;
2112
+ if (!start?.equals({ x, y })) {
2153
2113
  this.curves.push(
2154
2114
  new LineCurve(
2155
- this.currentPoint.clone(),
2115
+ start?.clone() ?? new Vector2(),
2156
2116
  new Vector2(x, y)
2157
2117
  )
2158
2118
  );
@@ -2161,10 +2121,11 @@ class CurvePath extends Curve {
2161
2121
  return this;
2162
2122
  }
2163
2123
  bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
2164
- if (!this.currentPoint.equals({ x, y })) {
2124
+ const start = this.currentPoint;
2125
+ if (!start?.equals({ x, y })) {
2165
2126
  this.curves.push(
2166
2127
  new CubicBezierCurve(
2167
- this.currentPoint.clone(),
2128
+ start?.clone() ?? new Vector2(),
2168
2129
  new Vector2(cp1x, cp1y),
2169
2130
  new Vector2(cp2x, cp2y),
2170
2131
  new Vector2(x, y)
@@ -2175,10 +2136,11 @@ class CurvePath extends Curve {
2175
2136
  return this;
2176
2137
  }
2177
2138
  quadraticCurveTo(cpx, cpy, x, y) {
2178
- if (!this.currentPoint.equals({ x, y })) {
2139
+ const start = this.currentPoint;
2140
+ if (!start?.equals({ x, y })) {
2179
2141
  this.curves.push(
2180
2142
  new QuadraticBezierCurve(
2181
- this.currentPoint.clone(),
2143
+ start?.clone() ?? new Vector2(),
2182
2144
  new Vector2(cpx, cpy),
2183
2145
  new Vector2(x, y)
2184
2146
  )
@@ -2192,7 +2154,7 @@ class CurvePath extends Curve {
2192
2154
  return this;
2193
2155
  }
2194
2156
  relativeArc(x, y, radius, startAngle, endAngle, counterclockwise) {
2195
- const point = this.currentPoint;
2157
+ const point = this.currentPoint ?? new Vector2();
2196
2158
  this.arc(x + point.x, y + point.y, radius, startAngle, endAngle, counterclockwise);
2197
2159
  return this;
2198
2160
  }
@@ -2214,7 +2176,7 @@ class CurvePath extends Curve {
2214
2176
  );
2215
2177
  if (this.curves.length > 0) {
2216
2178
  const first = curve.getPoint(0);
2217
- if (!first.equals(this.currentPoint)) {
2179
+ if (!this.currentPoint || !first.equals(this.currentPoint)) {
2218
2180
  this.lineTo(first.x, first.y);
2219
2181
  }
2220
2182
  }
@@ -2223,7 +2185,7 @@ class CurvePath extends Curve {
2223
2185
  return this;
2224
2186
  }
2225
2187
  relativeEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
2226
- const point = this.currentPoint;
2188
+ const point = this.currentPoint ?? new Vector2();
2227
2189
  this.ellipse(x + point.x, y + point.y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
2228
2190
  return this;
2229
2191
  }
@@ -2239,7 +2201,8 @@ class CurvePath extends Curve {
2239
2201
  return this;
2240
2202
  }
2241
2203
  splineThru(points) {
2242
- this.curves.push(new SplineCurve([this.currentPoint.clone()].concat(points)));
2204
+ const currentPoint = this.currentPoint ?? new Vector2();
2205
+ this.curves.push(new SplineCurve([currentPoint].concat(points)));
2243
2206
  this._setCurrentPoint(points[points.length - 1]);
2244
2207
  return this;
2245
2208
  }
@@ -2272,7 +2235,7 @@ class CurvePath extends Curve {
2272
2235
  this.curves.push(source.curves[i].clone());
2273
2236
  }
2274
2237
  this.autoClose = source.autoClose;
2275
- this.currentPoint.copy(source.currentPoint);
2238
+ this.currentPoint = source.currentPoint?.clone();
2276
2239
  return this;
2277
2240
  }
2278
2241
  }
@@ -2304,17 +2267,20 @@ function getIntersectionPoint(p1, p2, q1, q2) {
2304
2267
  );
2305
2268
  }
2306
2269
 
2307
- var __defProp = Object.defineProperty;
2308
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2309
- var __publicField = (obj, key, value) => {
2310
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
2311
- return value;
2312
- };
2313
2270
  class Path2D {
2271
+ currentPath = new CurvePath();
2272
+ paths = [this.currentPath];
2273
+ style;
2274
+ get startPoint() {
2275
+ return this.currentPath.startPoint;
2276
+ }
2277
+ get currentPoint() {
2278
+ return this.currentPath.currentPoint;
2279
+ }
2280
+ get strokeWidth() {
2281
+ return this.style.strokeWidth ?? ((this.style.stroke ?? "none") === "none" ? 0 : 1);
2282
+ }
2314
2283
  constructor(path, style = {}) {
2315
- __publicField(this, "currentPath", new CurvePath());
2316
- __publicField(this, "paths", [this.currentPath]);
2317
- __publicField(this, "style");
2318
2284
  if (path) {
2319
2285
  if (path instanceof Path2D) {
2320
2286
  this.addPath(path);
@@ -2326,15 +2292,6 @@ class Path2D {
2326
2292
  }
2327
2293
  this.style = style;
2328
2294
  }
2329
- get startPoint() {
2330
- return this.currentPath.startPoint;
2331
- }
2332
- get currentPoint() {
2333
- return this.currentPath.currentPoint;
2334
- }
2335
- get strokeWidth() {
2336
- return this.style.strokeWidth ?? ((this.style.stroke ?? "none") === "none" ? 0 : 1);
2337
- }
2338
2295
  addPath(path) {
2339
2296
  if (path instanceof Path2D) {
2340
2297
  this.paths.push(...path.paths.map((v) => v.clone()));
@@ -2356,7 +2313,7 @@ class Path2D {
2356
2313
  }
2357
2314
  moveTo(x, y) {
2358
2315
  const { currentPoint, curves } = this.currentPath;
2359
- if (!currentPoint.equals({ x, y })) {
2316
+ if (!currentPoint?.equals({ x, y })) {
2360
2317
  if (curves.length) {
2361
2318
  this.currentPath = new CurvePath().moveTo(x, y);
2362
2319
  this.paths.push(this.currentPath);
@@ -2692,9 +2649,7 @@ function parseFloatWithUnits(string) {
2692
2649
  }
2693
2650
  }
2694
2651
  let scale;
2695
- if (theUnit === "px" && defaultUnit !== "px") {
2696
- scale = unitConversion.in[defaultUnit] / defaultDPI;
2697
- } else {
2652
+ {
2698
2653
  scale = unitConversion[theUnit][defaultUnit];
2699
2654
  if (scale < 0) {
2700
2655
  scale = unitConversion[theUnit].in * defaultDPI;
@@ -3147,10 +3102,13 @@ function parseSvgToDom(svg) {
3147
3102
  } else {
3148
3103
  xml = svg;
3149
3104
  }
3150
- return new DOMParser().parseFromString(
3151
- xml,
3152
- "image/svg+xml"
3153
- ).documentElement;
3105
+ const doc = new DOMParser().parseFromString(xml, "text/xml");
3106
+ const error = doc.querySelector("parsererror");
3107
+ if (error) {
3108
+ throw new Error(`${error.textContent ?? "parser error"}
3109
+ ${xml}`);
3110
+ }
3111
+ return doc.documentElement;
3154
3112
  } else {
3155
3113
  return svg;
3156
3114
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "modern-path2d",
3
3
  "type": "module",
4
- "version": "0.2.7",
5
- "packageManager": "pnpm@9.9.0",
4
+ "version": "0.2.9",
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",
8
8
  "license": "MIT",
@@ -56,17 +56,17 @@
56
56
  "prepare": "simple-git-hooks"
57
57
  },
58
58
  "devDependencies": {
59
- "@antfu/eslint-config": "^3.7.1",
60
- "@types/node": "^22.6.1",
61
- "bumpp": "^9.5.2",
59
+ "@antfu/eslint-config": "^3.12.0",
60
+ "@types/node": "^22.10.2",
61
+ "bumpp": "^9.9.2",
62
62
  "conventional-changelog-cli": "^5.0.0",
63
- "eslint": "^9.11.1",
64
- "lint-staged": "^15.2.10",
63
+ "eslint": "^9.17.0",
64
+ "lint-staged": "^15.2.11",
65
65
  "simple-git-hooks": "^2.11.1",
66
- "typescript": "^5.6.2",
67
- "unbuild": "^2.0.0",
68
- "vite": "^5.4.7",
69
- "vitest": "^2.1.1"
66
+ "typescript": "^5.7.2",
67
+ "unbuild": "^3.0.1",
68
+ "vite": "^6.0.5",
69
+ "vitest": "^2.1.8"
70
70
  },
71
71
  "simple-git-hooks": {
72
72
  "pre-commit": "pnpm lint-staged"