svg-path-commander 2.0.10 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/.eslintrc.cjs +1 -0
  2. package/README.md +64 -8
  3. package/dist/svg-path-commander.cjs +1 -1
  4. package/dist/svg-path-commander.cjs.map +1 -1
  5. package/dist/svg-path-commander.d.ts +236 -43
  6. package/dist/svg-path-commander.js +1 -1
  7. package/dist/svg-path-commander.js.map +1 -1
  8. package/dist/svg-path-commander.mjs +790 -650
  9. package/dist/svg-path-commander.mjs.map +1 -1
  10. package/package.json +20 -22
  11. package/src/convert/pathToAbsolute.ts +16 -70
  12. package/src/convert/pathToCurve.ts +36 -28
  13. package/src/convert/pathToRelative.ts +33 -62
  14. package/src/index.ts +37 -39
  15. package/src/interface.ts +33 -33
  16. package/src/math/arcTools.ts +394 -0
  17. package/src/math/bezier.ts +253 -0
  18. package/src/math/cubicTools.ts +122 -0
  19. package/src/math/distanceSquareRoot.ts +3 -1
  20. package/src/math/lineTools.ts +67 -0
  21. package/src/math/midPoint.ts +3 -1
  22. package/src/math/polygonArea.ts +3 -1
  23. package/src/math/polygonLength.ts +2 -1
  24. package/src/math/quadTools.ts +98 -0
  25. package/src/parser/isMoveCommand.ts +17 -0
  26. package/src/parser/parsePathString.ts +5 -5
  27. package/src/parser/scanSegment.ts +12 -3
  28. package/src/process/absolutizeSegment.ts +58 -0
  29. package/src/process/iterate.ts +33 -0
  30. package/src/process/normalizePath.ts +34 -28
  31. package/src/process/normalizeSegment.ts +8 -9
  32. package/src/process/projection2d.ts +2 -1
  33. package/src/process/relativizeSegment.ts +61 -0
  34. package/src/process/reversePath.ts +1 -1
  35. package/src/process/roundPath.ts +8 -10
  36. package/src/process/segmentToCubic.ts +1 -1
  37. package/src/process/shortenSegment.ts +3 -3
  38. package/src/process/splitCubic.ts +8 -7
  39. package/src/process/splitPath.ts +39 -5
  40. package/src/process/transformPath.ts +81 -94
  41. package/src/types.ts +40 -1
  42. package/src/util/distanceEpsilon.ts +3 -0
  43. package/src/util/getClosestPoint.ts +1 -1
  44. package/src/util/getPathArea.ts +3 -3
  45. package/src/util/getPathBBox.ts +86 -18
  46. package/src/util/getPointAtLength.ts +98 -4
  47. package/src/util/getPropertiesAtLength.ts +4 -3
  48. package/src/util/getPropertiesAtPoint.ts +4 -1
  49. package/src/util/getTotalLength.ts +71 -4
  50. package/src/util/isPointInStroke.ts +2 -1
  51. package/src/util/shapeToPathArray.ts +8 -4
  52. package/test/class.test.ts +502 -0
  53. package/test/fixtures/getMarkup.ts +17 -0
  54. package/{cypress → test}/fixtures/shapes.js +39 -39
  55. package/test/fixtures/simpleShapes.js +75 -0
  56. package/test/static.test.ts +324 -0
  57. package/tsconfig.json +9 -4
  58. package/{vite.config.ts → vite.config.mts} +10 -1
  59. package/vitest.config-ui.mts +26 -0
  60. package/vitest.config.mts +26 -0
  61. package/cypress/e2e/svg-path-commander.spec.ts +0 -868
  62. package/cypress/fixtures/simpleShapes.js +0 -75
  63. package/cypress/plugins/esbuild-istanbul.ts +0 -50
  64. package/cypress/plugins/tsCompile.ts +0 -34
  65. package/cypress/support/commands.ts +0 -37
  66. package/cypress/support/e2e.ts +0 -21
  67. package/cypress/test.html +0 -36
  68. package/cypress.config.ts +0 -29
  69. package/src/process/fixArc.ts +0 -23
  70. package/src/util/pathLengthFactory.ts +0 -114
  71. package/src/util/segmentArcFactory.ts +0 -219
  72. package/src/util/segmentCubicFactory.ts +0 -114
  73. package/src/util/segmentLineFactory.ts +0 -45
  74. package/src/util/segmentQuadFactory.ts +0 -109
  75. /package/{cypress/fixtures/shapeObjects.js → test/fixtures/shapeObjects.ts} +0 -0
@@ -1,10 +1,10 @@
1
- var te = Object.defineProperty;
2
- var ee = (e, t, n) => t in e ? te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var N = (e, t, n) => ee(e, typeof t != "symbol" ? t + "" : t, n);
4
- const mt = {
1
+ var he = Object.defineProperty;
2
+ var fe = (e, t, n) => t in e ? he(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var N = (e, t, n) => fe(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const st = {
5
5
  origin: [0, 0, 0],
6
6
  round: 4
7
- }, k = "SVGPathCommander Error", U = {
7
+ }, E = "SVGPathCommander Error", tt = {
8
8
  a: 7,
9
9
  c: 6,
10
10
  h: 1,
@@ -16,12 +16,12 @@ const mt = {
16
16
  t: 2,
17
17
  v: 1,
18
18
  z: 0
19
- }, Tt = (e) => {
19
+ }, $t = (e) => {
20
20
  let t = e.pathValue[e.segmentStart], n = t.toLowerCase();
21
21
  const { data: r } = e;
22
- for (; r.length >= U[n] && (n === "m" && r.length > 2 ? (e.segments.push([t, ...r.splice(0, 2)]), n = "l", t = t === "m" ? "l" : "L") : e.segments.push([t, ...r.splice(0, U[n])]), !!U[n]); )
22
+ for (; r.length >= tt[n] && (n === "m" && r.length > 2 ? (e.segments.push([t, ...r.splice(0, 2)]), n = "l", t = t === "m" ? "l" : "L") : e.segments.push([t, ...r.splice(0, tt[n])]), !!tt[n]); )
23
23
  ;
24
- }, ne = (e) => {
24
+ }, ye = (e) => {
25
25
  const { index: t, pathValue: n } = e, r = n.charCodeAt(t);
26
26
  if (r === 48) {
27
27
  e.param = 0, e.index += 1;
@@ -31,47 +31,47 @@ const mt = {
31
31
  e.param = 1, e.index += 1;
32
32
  return;
33
33
  }
34
- e.err = `${k}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`;
35
- }, D = (e) => e >= 48 && e <= 57, R = "Invalid path value", se = (e) => {
34
+ e.err = `${E}: invalid Arc flag "${n[t]}", expecting 0 or 1 at index ${t}`;
35
+ }, F = (e) => e >= 48 && e <= 57, U = "Invalid path value", ge = (e) => {
36
36
  const { max: t, pathValue: n, index: r } = e;
37
- let s = r, i = !1, o = !1, a = !1, l = !1, c;
37
+ let s = r, i = !1, o = !1, c = !1, l = !1, a;
38
38
  if (s >= t) {
39
- e.err = `${k}: ${R} at index ${s}, "pathValue" is missing param`;
39
+ e.err = `${E}: ${U} at index ${s}, "pathValue" is missing param`;
40
40
  return;
41
41
  }
42
- if (c = n.charCodeAt(s), (c === 43 || c === 45) && (s += 1, c = n.charCodeAt(s)), !D(c) && c !== 46) {
43
- e.err = `${k}: ${R} at index ${s}, "${n[s]}" is not a number`;
42
+ if (a = n.charCodeAt(s), (a === 43 || a === 45) && (s += 1, a = n.charCodeAt(s)), !F(a) && a !== 46) {
43
+ e.err = `${E}: ${U} at index ${s}, "${n[s]}" is not a number`;
44
44
  return;
45
45
  }
46
- if (c !== 46) {
47
- if (i = c === 48, s += 1, c = n.charCodeAt(s), i && s < t && c && D(c)) {
48
- e.err = `${k}: ${R} at index ${r}, "${n[r]}" illegal number`;
46
+ if (a !== 46) {
47
+ if (i = a === 48, s += 1, a = n.charCodeAt(s), i && s < t && a && F(a)) {
48
+ e.err = `${E}: ${U} at index ${r}, "${n[r]}" illegal number`;
49
49
  return;
50
50
  }
51
- for (; s < t && D(n.charCodeAt(s)); )
51
+ for (; s < t && F(n.charCodeAt(s)); )
52
52
  s += 1, o = !0;
53
- c = n.charCodeAt(s);
53
+ a = n.charCodeAt(s);
54
54
  }
55
- if (c === 46) {
56
- for (l = !0, s += 1; D(n.charCodeAt(s)); )
57
- s += 1, a = !0;
58
- c = n.charCodeAt(s);
55
+ if (a === 46) {
56
+ for (l = !0, s += 1; F(n.charCodeAt(s)); )
57
+ s += 1, c = !0;
58
+ a = n.charCodeAt(s);
59
59
  }
60
- if (c === 101 || c === 69) {
61
- if (l && !o && !a) {
62
- e.err = `${k}: ${R} at index ${s}, "${n[s]}" invalid float exponent`;
60
+ if (a === 101 || a === 69) {
61
+ if (l && !o && !c) {
62
+ e.err = `${E}: ${U} at index ${s}, "${n[s]}" invalid float exponent`;
63
63
  return;
64
64
  }
65
- if (s += 1, c = n.charCodeAt(s), (c === 43 || c === 45) && (s += 1), s < t && D(n.charCodeAt(s)))
66
- for (; s < t && D(n.charCodeAt(s)); )
65
+ if (s += 1, a = n.charCodeAt(s), (a === 43 || a === 45) && (s += 1), s < t && F(n.charCodeAt(s)))
66
+ for (; s < t && F(n.charCodeAt(s)); )
67
67
  s += 1;
68
68
  else {
69
- e.err = `${k}: ${R} at index ${s}, "${n[s]}" invalid integer exponent`;
69
+ e.err = `${E}: ${U} at index ${s}, "${n[s]}" invalid integer exponent`;
70
70
  return;
71
71
  }
72
72
  }
73
73
  e.index = s, e.param = +e.pathValue.slice(r, s);
74
- }, re = (e) => [
74
+ }, xe = (e) => [
75
75
  // Special spaces
76
76
  5760,
77
77
  6158,
@@ -101,11 +101,11 @@ const mt = {
101
101
  11,
102
102
  12,
103
103
  160
104
- ].includes(e), V = (e) => {
104
+ ].includes(e), et = (e) => {
105
105
  const { pathValue: t, max: n } = e;
106
- for (; e.index < n && re(t.charCodeAt(e.index)); )
106
+ for (; e.index < n && xe(t.charCodeAt(e.index)); )
107
107
  e.index += 1;
108
- }, ie = (e) => {
108
+ }, pe = (e) => {
109
109
  switch (e | 32) {
110
110
  case 109:
111
111
  case 122:
@@ -121,53 +121,64 @@ const mt = {
121
121
  default:
122
122
  return !1;
123
123
  }
124
- }, oe = (e) => D(e) || e === 43 || e === 45 || e === 46, ce = (e) => (e | 32) === 97, jt = (e) => {
125
- const { max: t, pathValue: n, index: r } = e, s = n.charCodeAt(r), i = U[n[r].toLowerCase()];
126
- if (e.segmentStart = r, !ie(s)) {
127
- e.err = `${k}: ${R} "${n[r]}" is not a path command`;
124
+ }, de = (e) => F(e) || e === 43 || e === 45 || e === 46, Me = (e) => (e | 32) === 97, be = (e) => {
125
+ switch (e | 32) {
126
+ case 109:
127
+ case 77:
128
+ return !0;
129
+ default:
130
+ return !1;
131
+ }
132
+ }, Qt = (e) => {
133
+ var l;
134
+ const { max: t, pathValue: n, index: r, segments: s } = e, i = n.charCodeAt(r), o = tt[n[r].toLowerCase()];
135
+ if (e.segmentStart = r, !pe(i)) {
136
+ e.err = `${E}: ${U} "${n[r]}" is not a path command at index ${r}`;
128
137
  return;
129
138
  }
130
- if (e.index += 1, V(e), e.data = [], !i) {
131
- Tt(e);
139
+ const c = s[s.length - 1];
140
+ if (!be(i) && ((l = c == null ? void 0 : c[0]) == null ? void 0 : l.toLocaleLowerCase()) === "z") {
141
+ e.err = `${E}: ${U} "${n[r]}" is not a MoveTo path command at index ${r}`;
142
+ return;
143
+ }
144
+ if (e.index += 1, et(e), e.data = [], !o) {
145
+ $t(e);
132
146
  return;
133
147
  }
134
148
  for (; ; ) {
135
- for (let o = i; o > 0; o -= 1) {
136
- if (ce(s) && (o === 3 || o === 4) ? ne(e) : se(e), e.err.length)
149
+ for (let a = o; a > 0; a -= 1) {
150
+ if (Me(i) && (a === 3 || a === 4) ? ye(e) : ge(e), e.err.length)
137
151
  return;
138
- e.data.push(e.param), V(e), e.index < t && n.charCodeAt(e.index) === 44 && (e.index += 1, V(e));
152
+ e.data.push(e.param), et(e), e.index < t && n.charCodeAt(e.index) === 44 && (e.index += 1, et(e));
139
153
  }
140
- if (e.index >= e.max || !oe(n.charCodeAt(e.index)))
154
+ if (e.index >= e.max || !de(n.charCodeAt(e.index)))
141
155
  break;
142
156
  }
143
- Tt(e);
157
+ $t(e);
144
158
  };
145
- class zt {
159
+ class Xt {
146
160
  constructor(t) {
147
161
  this.segments = [], this.pathValue = t, this.max = t.length, this.index = 0, this.param = 0, this.segmentStart = 0, this.data = [], this.err = "";
148
162
  }
149
163
  }
150
- const _ = (e) => Array.isArray(e) && e.every((t) => {
151
- const n = t[0].toLowerCase();
152
- return U[n] === t.length - 1 && "achlmqstvz".includes(n) && t.slice(1).every(Number.isFinite);
153
- }) && e.length > 0, Z = (e) => {
154
- if (_(e))
155
- return [...e];
156
- const t = new zt(e);
157
- for (V(t); t.index < t.max && !t.err.length; )
158
- jt(t);
159
- if (t.err && t.err.length)
164
+ const q = (e) => {
165
+ if (typeof e != "string")
166
+ return e.slice(0);
167
+ const t = new Xt(e);
168
+ for (et(t); t.index < t.max && !t.err.length; )
169
+ Qt(t);
170
+ if (t != null && t.err.length)
160
171
  throw TypeError(t.err);
161
172
  return t.segments;
162
- }, le = (e) => {
173
+ }, we = (e) => {
163
174
  const t = e.length;
164
175
  let n = -1, r, s = e[t - 1], i = 0;
165
176
  for (; ++n < t; )
166
177
  r = s, s = e[n], i += r[1] * s[0] - r[0] * s[1];
167
178
  return i / 2;
168
- }, W = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), ae = (e) => e.reduce((t, n, r) => r ? t + W(e[r - 1], n) : 0, 0);
169
- var me = Object.defineProperty, he = (e, t, n) => t in e ? me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => he(e, typeof t != "symbol" ? t + "" : t, n);
170
- const ue = {
179
+ }, Pt = (e, t) => Math.sqrt((e[0] - t[0]) * (e[0] - t[0]) + (e[1] - t[1]) * (e[1] - t[1])), Ne = (e) => e.reduce((t, n, r) => r ? t + Pt(e[r - 1], n) : 0, 0);
180
+ var Ae = Object.defineProperty, Ce = (e, t, n) => t in e ? Ae(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, k = (e, t, n) => Ce(e, typeof t != "symbol" ? t + "" : t, n);
181
+ const ve = {
171
182
  a: 1,
172
183
  b: 0,
173
184
  c: 0,
@@ -192,21 +203,21 @@ const ue = {
192
203
  m44: 1,
193
204
  is2D: !0,
194
205
  isIdentity: !0
195
- }, It = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), Dt = (e) => e instanceof DOMMatrix || e instanceof v || typeof e == "object" && Object.keys(ue).every((t) => e && t in e), G = (e) => {
206
+ }, Bt = (e) => (e instanceof Float64Array || e instanceof Float32Array || Array.isArray(e) && e.every((t) => typeof t == "number")) && [6, 16].some((t) => e.length === t), Yt = (e) => e instanceof DOMMatrix || e instanceof v || typeof e == "object" && Object.keys(ve).every((t) => e && t in e), it = (e) => {
196
207
  const t = new v(), n = Array.from(e);
197
- if (!It(n))
208
+ if (!Bt(n))
198
209
  throw TypeError(`CSSMatrix: "${n.join(",")}" must be an array with 6/16 numbers.`);
199
210
  if (n.length === 16) {
200
- const [r, s, i, o, a, l, c, m, u, y, g, f, h, x, p, b] = n;
201
- t.m11 = r, t.a = r, t.m21 = a, t.c = a, t.m31 = u, t.m41 = h, t.e = h, t.m12 = s, t.b = s, t.m22 = l, t.d = l, t.m32 = y, t.m42 = x, t.f = x, t.m13 = i, t.m23 = c, t.m33 = g, t.m43 = p, t.m14 = o, t.m24 = m, t.m34 = f, t.m44 = b;
211
+ const [r, s, i, o, c, l, a, m, u, g, f, h, y, x, p, d] = n;
212
+ t.m11 = r, t.a = r, t.m21 = c, t.c = c, t.m31 = u, t.m41 = y, t.e = y, t.m12 = s, t.b = s, t.m22 = l, t.d = l, t.m32 = g, t.m42 = x, t.f = x, t.m13 = i, t.m23 = a, t.m33 = f, t.m43 = p, t.m14 = o, t.m24 = m, t.m34 = h, t.m44 = d;
202
213
  } else if (n.length === 6) {
203
- const [r, s, i, o, a, l] = n;
204
- t.m11 = r, t.a = r, t.m12 = s, t.b = s, t.m21 = i, t.c = i, t.m22 = o, t.d = o, t.m41 = a, t.e = a, t.m42 = l, t.f = l;
214
+ const [r, s, i, o, c, l] = n;
215
+ t.m11 = r, t.a = r, t.m12 = s, t.b = s, t.m21 = i, t.c = i, t.m22 = o, t.d = o, t.m41 = c, t.e = c, t.m42 = l, t.f = l;
205
216
  }
206
217
  return t;
207
- }, Zt = (e) => {
208
- if (Dt(e))
209
- return G([
218
+ }, Ht = (e) => {
219
+ if (Yt(e))
220
+ return it([
210
221
  e.m11,
211
222
  e.m12,
212
223
  e.m13,
@@ -234,38 +245,38 @@ const ue = {
234
245
  return t.split(")").filter((s) => s).forEach((s) => {
235
246
  const [i, o] = s.split("(");
236
247
  if (!o) throw TypeError(r);
237
- const a = o.split(",").map((f) => f.includes("rad") ? parseFloat(f) * (180 / Math.PI) : parseFloat(f)), [l, c, m, u] = a, y = [l, c, m], g = [l, c, m, u];
238
- if (i === "perspective" && l && [c, m].every((f) => f === void 0))
248
+ const c = o.split(",").map((h) => h.includes("rad") ? parseFloat(h) * (180 / Math.PI) : parseFloat(h)), [l, a, m, u] = c, g = [l, a, m], f = [l, a, m, u];
249
+ if (i === "perspective" && l && [a, m].every((h) => h === void 0))
239
250
  n.m34 = -1 / l;
240
- else if (i.includes("matrix") && [6, 16].includes(a.length) && a.every((f) => !Number.isNaN(+f))) {
241
- const f = a.map((h) => Math.abs(h) < 1e-6 ? 0 : h);
242
- n = n.multiply(G(f));
243
- } else if (i === "translate3d" && y.every((f) => !Number.isNaN(+f)))
244
- n = n.translate(l, c, m);
251
+ else if (i.includes("matrix") && [6, 16].includes(c.length) && c.every((h) => !Number.isNaN(+h))) {
252
+ const h = c.map((y) => Math.abs(y) < 1e-6 ? 0 : y);
253
+ n = n.multiply(it(h));
254
+ } else if (i === "translate3d" && g.every((h) => !Number.isNaN(+h)))
255
+ n = n.translate(l, a, m);
245
256
  else if (i === "translate" && l && m === void 0)
246
- n = n.translate(l, c || 0, 0);
247
- else if (i === "rotate3d" && g.every((f) => !Number.isNaN(+f)) && u)
248
- n = n.rotateAxisAngle(l, c, m, u);
249
- else if (i === "rotate" && l && [c, m].every((f) => f === void 0))
257
+ n = n.translate(l, a || 0, 0);
258
+ else if (i === "rotate3d" && f.every((h) => !Number.isNaN(+h)) && u)
259
+ n = n.rotateAxisAngle(l, a, m, u);
260
+ else if (i === "rotate" && l && [a, m].every((h) => h === void 0))
250
261
  n = n.rotate(0, 0, l);
251
- else if (i === "scale3d" && y.every((f) => !Number.isNaN(+f)) && y.some((f) => f !== 1))
252
- n = n.scale(l, c, m);
262
+ else if (i === "scale3d" && g.every((h) => !Number.isNaN(+h)) && g.some((h) => h !== 1))
263
+ n = n.scale(l, a, m);
253
264
  else if (i === "scale" && !Number.isNaN(l) && l !== 1 && m === void 0) {
254
- const f = Number.isNaN(+c) ? l : c;
255
- n = n.scale(l, f, 1);
256
- } else if (i === "skew" && (l || !Number.isNaN(l) && c) && m === void 0)
257
- n = n.skew(l, c || 0);
258
- else if (["translate", "rotate", "scale", "skew"].some((f) => i.includes(f)) && /[XYZ]/.test(i) && l && [c, m].every((f) => f === void 0))
265
+ const h = Number.isNaN(+a) ? l : a;
266
+ n = n.scale(l, h, 1);
267
+ } else if (i === "skew" && (l || !Number.isNaN(l) && a) && m === void 0)
268
+ n = n.skew(l, a || 0);
269
+ else if (["translate", "rotate", "scale", "skew"].some((h) => i.includes(h)) && /[XYZ]/.test(i) && l && [a, m].every((h) => h === void 0))
259
270
  if (i === "skewX" || i === "skewY")
260
271
  n = n[i](l);
261
272
  else {
262
- const f = i.replace(/[XYZ]/, ""), h = i.replace(f, ""), x = ["X", "Y", "Z"].indexOf(h), p = f === "scale" ? 1 : 0, b = [x === 0 ? l : p, x === 1 ? l : p, x === 2 ? l : p];
263
- n = n[f](...b);
273
+ const h = i.replace(/[XYZ]/, ""), y = i.replace(h, ""), x = ["X", "Y", "Z"].indexOf(y), p = h === "scale" ? 1 : 0, d = [x === 0 ? l : p, x === 1 ? l : p, x === 2 ? l : p];
274
+ n = n[h](...d);
264
275
  }
265
276
  else
266
277
  throw TypeError(r);
267
278
  }), n;
268
- }, bt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [
279
+ }, wt = (e, t) => t ? [e.a, e.b, e.c, e.d, e.e, e.f] : [
269
280
  e.m11,
270
281
  e.m12,
271
282
  e.m13,
@@ -282,32 +293,32 @@ const ue = {
282
293
  e.m42,
283
294
  e.m43,
284
295
  e.m44
285
- ], Rt = (e, t, n) => {
296
+ ], Ut = (e, t, n) => {
286
297
  const r = new v();
287
298
  return r.m41 = e, r.e = e, r.m42 = t, r.f = t, r.m43 = n, r;
288
- }, Xt = (e, t, n) => {
289
- const r = new v(), s = Math.PI / 180, i = e * s, o = t * s, a = n * s, l = Math.cos(i), c = -Math.sin(i), m = Math.cos(o), u = -Math.sin(o), y = Math.cos(a), g = -Math.sin(a), f = m * y, h = -m * g;
290
- r.m11 = f, r.a = f, r.m12 = h, r.b = h, r.m13 = u;
291
- const x = c * u * y + l * g;
299
+ }, Vt = (e, t, n) => {
300
+ const r = new v(), s = Math.PI / 180, i = e * s, o = t * s, c = n * s, l = Math.cos(i), a = -Math.sin(i), m = Math.cos(o), u = -Math.sin(o), g = Math.cos(c), f = -Math.sin(c), h = m * g, y = -m * f;
301
+ r.m11 = h, r.a = h, r.m12 = y, r.b = y, r.m13 = u;
302
+ const x = a * u * g + l * f;
292
303
  r.m21 = x, r.c = x;
293
- const p = l * y - c * u * g;
294
- return r.m22 = p, r.d = p, r.m23 = -c * m, r.m31 = c * g - l * u * y, r.m32 = c * y + l * u * g, r.m33 = l * m, r;
295
- }, Qt = (e, t, n, r) => {
304
+ const p = l * g - a * u * f;
305
+ return r.m22 = p, r.d = p, r.m23 = -a * m, r.m31 = a * f - l * u * g, r.m32 = a * g + l * u * f, r.m33 = l * m, r;
306
+ }, _t = (e, t, n, r) => {
296
307
  const s = new v(), i = Math.sqrt(e * e + t * t + n * n);
297
308
  if (i === 0)
298
309
  return s;
299
- const o = e / i, a = t / i, l = n / i, c = r * (Math.PI / 360), m = Math.sin(c), u = Math.cos(c), y = m * m, g = o * o, f = a * a, h = l * l, x = 1 - 2 * (f + h) * y;
310
+ const o = e / i, c = t / i, l = n / i, a = r * (Math.PI / 360), m = Math.sin(a), u = Math.cos(a), g = m * m, f = o * o, h = c * c, y = l * l, x = 1 - 2 * (h + y) * g;
300
311
  s.m11 = x, s.a = x;
301
- const p = 2 * (o * a * y + l * m * u);
302
- s.m12 = p, s.b = p, s.m13 = 2 * (o * l * y - a * m * u);
303
- const b = 2 * (a * o * y - l * m * u);
304
- s.m21 = b, s.c = b;
305
- const A = 1 - 2 * (h + g) * y;
306
- return s.m22 = A, s.d = A, s.m23 = 2 * (a * l * y + o * m * u), s.m31 = 2 * (l * o * y + a * m * u), s.m32 = 2 * (l * a * y - o * m * u), s.m33 = 1 - 2 * (g + f) * y, s;
307
- }, Ht = (e, t, n) => {
312
+ const p = 2 * (o * c * g + l * m * u);
313
+ s.m12 = p, s.b = p, s.m13 = 2 * (o * l * g - c * m * u);
314
+ const d = 2 * (c * o * g - l * m * u);
315
+ s.m21 = d, s.c = d;
316
+ const C = 1 - 2 * (y + f) * g;
317
+ return s.m22 = C, s.d = C, s.m23 = 2 * (c * l * g + o * m * u), s.m31 = 2 * (l * o * g + c * m * u), s.m32 = 2 * (l * c * g - o * m * u), s.m33 = 1 - 2 * (f + h) * g, s;
318
+ }, Jt = (e, t, n) => {
308
319
  const r = new v();
309
320
  return r.m11 = e, r.a = e, r.m22 = t, r.d = t, r.m33 = n, r;
310
- }, ht = (e, t) => {
321
+ }, yt = (e, t) => {
311
322
  const n = new v();
312
323
  if (e) {
313
324
  const r = e * Math.PI / 180, s = Math.tan(r);
@@ -318,9 +329,9 @@ const ue = {
318
329
  n.m12 = s, n.b = s;
319
330
  }
320
331
  return n;
321
- }, Yt = (e) => ht(e, 0), Bt = (e) => ht(0, e), O = (e, t) => {
322
- const n = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41, r = t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42, s = t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43, i = t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44, o = t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41, a = t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42, l = t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43, c = t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44, m = t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41, u = t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42, y = t.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43, g = t.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44, f = t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41, h = t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42, x = t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43, p = t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44;
323
- return G([n, r, s, i, o, a, l, c, m, u, y, g, f, h, x, p]);
332
+ }, Kt = (e) => yt(e, 0), Wt = (e) => yt(0, e), j = (e, t) => {
333
+ const n = t.m11 * e.m11 + t.m12 * e.m21 + t.m13 * e.m31 + t.m14 * e.m41, r = t.m11 * e.m12 + t.m12 * e.m22 + t.m13 * e.m32 + t.m14 * e.m42, s = t.m11 * e.m13 + t.m12 * e.m23 + t.m13 * e.m33 + t.m14 * e.m43, i = t.m11 * e.m14 + t.m12 * e.m24 + t.m13 * e.m34 + t.m14 * e.m44, o = t.m21 * e.m11 + t.m22 * e.m21 + t.m23 * e.m31 + t.m24 * e.m41, c = t.m21 * e.m12 + t.m22 * e.m22 + t.m23 * e.m32 + t.m24 * e.m42, l = t.m21 * e.m13 + t.m22 * e.m23 + t.m23 * e.m33 + t.m24 * e.m43, a = t.m21 * e.m14 + t.m22 * e.m24 + t.m23 * e.m34 + t.m24 * e.m44, m = t.m31 * e.m11 + t.m32 * e.m21 + t.m33 * e.m31 + t.m34 * e.m41, u = t.m31 * e.m12 + t.m32 * e.m22 + t.m33 * e.m32 + t.m34 * e.m42, g = t.m31 * e.m13 + t.m32 * e.m23 + t.m33 * e.m33 + t.m34 * e.m43, f = t.m31 * e.m14 + t.m32 * e.m24 + t.m33 * e.m34 + t.m34 * e.m44, h = t.m41 * e.m11 + t.m42 * e.m21 + t.m43 * e.m31 + t.m44 * e.m41, y = t.m41 * e.m12 + t.m42 * e.m22 + t.m43 * e.m32 + t.m44 * e.m42, x = t.m41 * e.m13 + t.m42 * e.m23 + t.m43 * e.m33 + t.m44 * e.m43, p = t.m41 * e.m14 + t.m42 * e.m24 + t.m43 * e.m34 + t.m44 * e.m44;
334
+ return it([n, r, s, i, o, c, l, a, m, u, g, f, h, y, x, p]);
324
335
  };
325
336
  class v {
326
337
  /**
@@ -367,7 +378,7 @@ class v {
367
378
  * @return the matrix instance
368
379
  */
369
380
  setMatrixValue(t) {
370
- return typeof t == "string" && t.length && t !== "none" ? Ft(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? G(t) : typeof t == "object" ? Zt(t) : this;
381
+ return typeof t == "string" && t.length && t !== "none" ? Ft(t) : Array.isArray(t) || t instanceof Float64Array || t instanceof Float32Array ? it(t) : typeof t == "object" ? Ht(t) : this;
371
382
  }
372
383
  /**
373
384
  * Returns a *Float32Array* containing elements which comprise the matrix.
@@ -378,7 +389,7 @@ class v {
378
389
  * @return an *Array* representation of the matrix
379
390
  */
380
391
  toFloat32Array(t) {
381
- return Float32Array.from(bt(this, t));
392
+ return Float32Array.from(wt(this, t));
382
393
  }
383
394
  /**
384
395
  * Returns a *Float64Array* containing elements which comprise the matrix.
@@ -389,7 +400,7 @@ class v {
389
400
  * @return an *Array* representation of the matrix
390
401
  */
391
402
  toFloat64Array(t) {
392
- return Float64Array.from(bt(this, t));
403
+ return Float64Array.from(wt(this, t));
393
404
  }
394
405
  /**
395
406
  * Creates and returns a string representation of the matrix in `CSS` matrix syntax,
@@ -427,7 +438,7 @@ class v {
427
438
  * @return The resulted matrix.
428
439
  */
429
440
  multiply(t) {
430
- return O(this, t);
441
+ return j(this, t);
431
442
  }
432
443
  /**
433
444
  * The translate method returns a new matrix which is this matrix post
@@ -443,7 +454,7 @@ class v {
443
454
  translate(t, n, r) {
444
455
  const s = t;
445
456
  let i = n, o = r;
446
- return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0), O(this, Rt(s, i, o));
457
+ return typeof i > "u" && (i = 0), typeof o > "u" && (o = 0), j(this, Ut(s, i, o));
447
458
  }
448
459
  /**
449
460
  * The scale method returns a new matrix which is this matrix post multiplied by
@@ -459,7 +470,7 @@ class v {
459
470
  scale(t, n, r) {
460
471
  const s = t;
461
472
  let i = n, o = r;
462
- return typeof i > "u" && (i = t), typeof o > "u" && (o = 1), O(this, Ht(s, i, o));
473
+ return typeof i > "u" && (i = t), typeof o > "u" && (o = 1), j(this, Jt(s, i, o));
463
474
  }
464
475
  /**
465
476
  * The rotate method returns a new matrix which is this matrix post multiplied
@@ -475,7 +486,7 @@ class v {
475
486
  */
476
487
  rotate(t, n, r) {
477
488
  let s = t, i = n || 0, o = r || 0;
478
- return typeof t == "number" && typeof n > "u" && typeof r > "u" && (o = s, s = 0, i = 0), O(this, Xt(s, i, o));
489
+ return typeof t == "number" && typeof n > "u" && typeof r > "u" && (o = s, s = 0, i = 0), j(this, Vt(s, i, o));
479
490
  }
480
491
  /**
481
492
  * The rotateAxisAngle method returns a new matrix which is this matrix post
@@ -492,7 +503,7 @@ class v {
492
503
  rotateAxisAngle(t, n, r, s) {
493
504
  if ([t, n, r, s].some((i) => Number.isNaN(+i)))
494
505
  throw new TypeError("CSSMatrix: expecting 4 values");
495
- return O(this, Qt(t, n, r, s));
506
+ return j(this, _t(t, n, r, s));
496
507
  }
497
508
  /**
498
509
  * Specifies a skew transformation along the `x-axis` by the given angle.
@@ -502,7 +513,7 @@ class v {
502
513
  * @return The resulted matrix
503
514
  */
504
515
  skewX(t) {
505
- return O(this, Yt(t));
516
+ return j(this, Kt(t));
506
517
  }
507
518
  /**
508
519
  * Specifies a skew transformation along the `y-axis` by the given angle.
@@ -512,7 +523,7 @@ class v {
512
523
  * @return The resulted matrix
513
524
  */
514
525
  skewY(t) {
515
- return O(this, Bt(t));
526
+ return j(this, Wt(t));
516
527
  }
517
528
  /**
518
529
  * Specifies a skew transformation along both the `x-axis` and `y-axis`.
@@ -523,7 +534,7 @@ class v {
523
534
  * @return The resulted matrix
524
535
  */
525
536
  skew(t, n) {
526
- return O(this, ht(t, n));
537
+ return j(this, yt(t, n));
527
538
  }
528
539
  /**
529
540
  * Transforms a specified vector using the matrix, returning a new
@@ -546,67 +557,8 @@ class v {
546
557
  };
547
558
  }
548
559
  }
549
- C(v, "Translate", Rt), C(v, "Rotate", Xt), C(v, "RotateAxisAngle", Qt), C(v, "Scale", Ht), C(v, "SkewX", Yt), C(v, "SkewY", Bt), C(v, "Skew", ht), C(v, "Multiply", O), C(v, "fromArray", G), C(v, "fromMatrix", Zt), C(v, "fromString", Ft), C(v, "toArray", bt), C(v, "isCompatibleArray", It), C(v, "isCompatibleObject", Dt);
550
- const wt = (e) => _(e) && // `isPathArray` also checks if it's `Array`
551
- e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
552
- if (wt(e))
553
- return [...e];
554
- const t = Z(e);
555
- let n = 0, r = 0, s = 0, i = 0;
556
- return t.map((o) => {
557
- const a = o.slice(1).map(Number), [l] = o, c = l.toUpperCase();
558
- if (l === "M")
559
- return [n, r] = a, s = n, i = r, ["M", n, r];
560
- let m = [];
561
- if (l !== c)
562
- if (c === "A")
563
- m = [
564
- c,
565
- a[0],
566
- a[1],
567
- a[2],
568
- a[3],
569
- a[4],
570
- a[5] + n,
571
- a[6] + r
572
- ];
573
- else if (c === "V")
574
- m = [c, a[0] + r];
575
- else if (c === "H")
576
- m = [c, a[0] + n];
577
- else {
578
- const u = a.map((y, g) => y + (g % 2 ? r : n));
579
- m = [c, ...u];
580
- }
581
- else
582
- m = [c, ...a];
583
- return c === "Z" ? (n = s, r = i) : c === "H" ? [, n] = m : c === "V" ? [, r] = m : ([n, r] = m.slice(-2), c === "M" && (s = n, i = r)), m;
584
- });
585
- }, fe = (e, t) => {
586
- const [n] = e, { x1: r, y1: s, x2: i, y2: o } = t, a = e.slice(1).map(Number);
587
- let l = e;
588
- if ("TQ".includes(n) || (t.qx = null, t.qy = null), n === "H")
589
- l = ["L", e[1], s];
590
- else if (n === "V")
591
- l = ["L", r, e[1]];
592
- else if (n === "S") {
593
- const c = r * 2 - i, m = s * 2 - o;
594
- t.x1 = c, t.y1 = m, l = ["C", c, m, ...a];
595
- } else if (n === "T") {
596
- const c = r * 2 - (t.qx ? t.qx : (
597
- /* istanbul ignore next */
598
- 0
599
- )), m = s * 2 - (t.qy ? t.qy : (
600
- /* istanbul ignore next */
601
- 0
602
- ));
603
- t.qx = c, t.qy = m, l = ["Q", c, m, ...a];
604
- } else if (n === "Q") {
605
- const [c, m] = a;
606
- t.qx = c, t.qy = m;
607
- }
608
- return l;
609
- }, vt = (e) => wt(e) && e.every(([t]) => "ACLMQZ".includes(t)), ut = {
560
+ k(v, "Translate", Ut), k(v, "Rotate", Vt), k(v, "RotateAxisAngle", _t), k(v, "Scale", Jt), k(v, "SkewX", Kt), k(v, "SkewY", Wt), k(v, "Skew", yt), k(v, "Multiply", j), k(v, "fromArray", it), k(v, "fromMatrix", Ht), k(v, "fromString", Ft), k(v, "toArray", wt), k(v, "isCompatibleArray", Bt), k(v, "isCompatibleObject", Yt);
561
+ const gt = {
610
562
  x1: 0,
611
563
  y1: 0,
612
564
  x2: 0,
@@ -615,208 +567,357 @@ e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
615
567
  y: 0,
616
568
  qx: null,
617
569
  qy: null
618
- }, z = (e) => {
619
- if (vt(e))
620
- return [...e];
621
- const t = Q(e), n = { ...ut }, r = t.length;
622
- for (let s = 0; s < r; s += 1) {
623
- t[s], t[s] = fe(t[s], n);
624
- const i = t[s], o = i.length;
625
- n.x1 = +i[o - 2], n.y1 = +i[o - 1], n.x2 = +i[o - 4] || n.x1, n.y2 = +i[o - 3] || n.y1;
570
+ }, D = (e, t) => {
571
+ const n = { ...gt };
572
+ let r = e.length, s;
573
+ for (let i = 0; i < r; i += 1) {
574
+ s = e[i];
575
+ const o = t(s, n, i);
576
+ e[i] = o, o[0] === "C" && (r = e.length), s = e[i];
577
+ const c = s.length;
578
+ n.x1 = +s[c - 2], n.y1 = +s[c - 1], n.x2 = +s[c - 4] || n.x1, n.y2 = +s[c - 3] || n.y1;
626
579
  }
627
- return t;
628
- }, E = (e, t, n) => {
580
+ return e;
581
+ }, V = (e, t) => {
582
+ const [n] = e, { x: r, y: s } = t, i = e.slice(1).map(Number), o = n.toUpperCase();
583
+ if (!(o === n)) {
584
+ if (o === "A")
585
+ return [
586
+ o,
587
+ i[0],
588
+ i[1],
589
+ i[2],
590
+ i[3],
591
+ i[4],
592
+ i[5] + r,
593
+ i[6] + s
594
+ ];
595
+ if (o === "V")
596
+ return [o, i[0] + s];
597
+ if (o === "H")
598
+ return [o, i[0] + r];
599
+ {
600
+ const l = i.map((a, m) => a + (m % 2 ? s : r));
601
+ return [o, ...l];
602
+ }
603
+ }
604
+ return e;
605
+ }, G = (e, t) => {
606
+ const [n] = e, { x1: r, y1: s, x2: i, y2: o } = t, c = e.slice(1).map(Number);
607
+ if ("TQ".includes(n) || (t.qx = null, t.qy = null), n === "H")
608
+ return ["L", e[1], s];
609
+ if (n === "V")
610
+ return ["L", r, e[1]];
611
+ if (n === "S") {
612
+ const l = r * 2 - i, a = s * 2 - o;
613
+ return t.x1 = l, t.y1 = a, ["C", l, a, ...c];
614
+ } else if (n === "T") {
615
+ const l = r * 2 - (t.qx ? t.qx : (
616
+ /* istanbul ignore next */
617
+ 0
618
+ )), a = s * 2 - (t.qy ? t.qy : (
619
+ /* istanbul ignore next */
620
+ 0
621
+ ));
622
+ return t.qx = l, t.qy = a, ["Q", l, a, ...c];
623
+ } else if (n === "Q") {
624
+ const [l, a] = c;
625
+ t.qx = l, t.qy = a;
626
+ }
627
+ return e;
628
+ }, R = (e, t, n) => {
629
629
  const [r, s] = e, [i, o] = t;
630
630
  return [r + (i - r) * n, s + (o - s) * n];
631
- }, dt = (e, t, n, r, s) => {
632
- const i = W([e, t], [n, r]);
633
- let o = { x: 0, y: 0 };
631
+ }, at = (e, t, n, r) => Pt([e, t], [n, r]), Gt = (e, t, n, r, s) => {
632
+ const i = Pt([e, t], [n, r]);
633
+ let o = { x: e, y: t };
634
634
  if (typeof s == "number")
635
635
  if (s <= 0)
636
636
  o = { x: e, y: t };
637
637
  else if (s >= i)
638
638
  o = { x: n, y: r };
639
639
  else {
640
- const [a, l] = E([e, t], [n, r], s / i);
641
- o = { x: a, y: l };
640
+ const [c, l] = R([e, t], [n, r], s / i);
641
+ o = { x: c, y: l };
642
642
  }
643
+ return o;
644
+ }, kt = (e, t, n, r) => {
645
+ const { min: s, max: i } = Math;
643
646
  return {
644
- length: i,
645
- point: o,
646
647
  min: {
647
- x: Math.min(e, n),
648
- y: Math.min(t, r)
648
+ x: s(e, n),
649
+ y: s(t, r)
649
650
  },
650
651
  max: {
651
- x: Math.max(e, n),
652
- y: Math.max(t, r)
652
+ x: i(e, n),
653
+ y: i(t, r)
653
654
  }
654
655
  };
655
- }, Lt = (e, t) => {
656
- const { x: n, y: r } = e, { x: s, y: i } = t, o = n * s + r * i, a = Math.sqrt((n ** 2 + r ** 2) * (s ** 2 + i ** 2));
657
- return (n * i - r * s < 0 ? -1 : 1) * Math.acos(o / a);
658
- }, ye = (e, t, n, r, s, i, o, a, l, c) => {
659
- const { abs: m, sin: u, cos: y, sqrt: g, PI: f } = Math;
660
- let h = m(n), x = m(r);
661
- const b = (s % 360 + 360) % 360 * (f / 180);
662
- if (e === a && t === l)
663
- return { x: e, y: t };
664
- if (h === 0 || x === 0)
665
- return dt(e, t, a, l, c).point;
666
- const A = (e - a) / 2, d = (t - l) / 2, M = {
667
- x: y(b) * A + u(b) * d,
668
- y: -u(b) * A + y(b) * d
669
- }, T = M.x ** 2 / h ** 2 + M.y ** 2 / x ** 2;
670
- T > 1 && (h *= g(T), x *= g(T));
671
- const j = h ** 2 * x ** 2 - h ** 2 * M.y ** 2 - x ** 2 * M.x ** 2, H = h ** 2 * M.y ** 2 + x ** 2 * M.x ** 2;
672
- let F = j / H;
673
- F = F < 0 ? 0 : F;
674
- const tt = (i !== o ? 1 : -1) * g(F), S = {
675
- x: tt * (h * M.y / x),
676
- y: tt * (-(x * M.x) / h)
677
- }, et = {
678
- x: y(b) * S.x - u(b) * S.y + (e + a) / 2,
679
- y: u(b) * S.x + y(b) * S.y + (t + l) / 2
680
- }, Y = {
656
+ }, te = (e, t, n) => {
657
+ const r = n / 2, s = Math.sin(r), i = Math.cos(r), o = e ** 2 * s ** 2, c = t ** 2 * i ** 2, l = Math.sqrt(o + c) * n;
658
+ return Math.abs(l);
659
+ }, K = (e, t, n, r, s, i) => {
660
+ const o = Math.cos(i), c = Math.sin(i), l = r * Math.cos(e), a = s * Math.sin(e);
661
+ return {
662
+ x: t + o * l - c * a,
663
+ y: n + c * l + o * a
664
+ };
665
+ }, qt = (e, t) => {
666
+ const { x: n, y: r } = e, { x: s, y: i } = t, o = n * s + r * i, c = Math.sqrt((n ** 2 + r ** 2) * (s ** 2 + i ** 2));
667
+ return (n * i - r * s < 0 ? -1 : 1) * Math.acos(o / c);
668
+ }, Lt = (e, t, n, r, s, i, o, c, l) => {
669
+ const { abs: a, sin: m, cos: u, sqrt: g, PI: f } = Math;
670
+ let h = a(n), y = a(r);
671
+ const p = (s % 360 + 360) % 360 * (f / 180);
672
+ if (e === c && t === l)
673
+ return {
674
+ rx: h,
675
+ ry: y,
676
+ startAngle: 0,
677
+ endAngle: 0,
678
+ center: { x: c, y: l }
679
+ };
680
+ if (h === 0 || y === 0)
681
+ return {
682
+ rx: h,
683
+ ry: y,
684
+ startAngle: 0,
685
+ endAngle: 0,
686
+ center: { x: c, y: l }
687
+ };
688
+ const d = (e - c) / 2, C = (t - l) / 2, M = {
689
+ x: u(p) * d + m(p) * C,
690
+ y: -m(p) * d + u(p) * C
691
+ }, b = M.x ** 2 / h ** 2 + M.y ** 2 / y ** 2;
692
+ b > 1 && (h *= g(b), y *= g(b));
693
+ const w = h ** 2 * y ** 2 - h ** 2 * M.y ** 2 - y ** 2 * M.x ** 2, T = h ** 2 * M.y ** 2 + y ** 2 * M.x ** 2;
694
+ let P = w / T;
695
+ P = P < 0 ? 0 : P;
696
+ const $ = (i !== o ? 1 : -1) * g(P), S = {
697
+ x: $ * (h * M.y / y),
698
+ y: $ * (-(y * M.x) / h)
699
+ }, _ = {
700
+ x: u(p) * S.x - m(p) * S.y + (e + c) / 2,
701
+ y: m(p) * S.x + u(p) * S.y + (t + l) / 2
702
+ }, X = {
681
703
  x: (M.x - S.x) / h,
682
- y: (M.y - S.y) / x
683
- }, nt = Lt({ x: 1, y: 0 }, Y), st = {
704
+ y: (M.y - S.y) / y
705
+ }, Q = qt({ x: 1, y: 0 }, X), B = {
684
706
  x: (-M.x - S.x) / h,
685
- y: (-M.y - S.y) / x
707
+ y: (-M.y - S.y) / y
686
708
  };
687
- let $ = Lt(Y, st);
688
- !o && $ > 0 ? $ -= 2 * f : o && $ < 0 && ($ += 2 * f), $ %= 2 * f;
689
- const q = nt + $ * c, B = h * y(q), J = x * u(q);
709
+ let I = qt(X, B);
710
+ !o && I > 0 ? I -= 2 * f : o && I < 0 && (I += 2 * f), I %= 2 * f;
711
+ const J = Q + I;
690
712
  return {
691
- x: y(b) * B - u(b) * J + et.x,
692
- y: u(b) * B + y(b) * J + et.y
713
+ center: _,
714
+ startAngle: Q,
715
+ endAngle: J,
716
+ rx: h,
717
+ ry: y
693
718
  };
694
- }, ge = (e, t, n, r, s, i, o, a, l, c) => {
695
- const m = typeof c == "number";
696
- let u = e, y = t, g = 0, f = [u, y, g], h = [u, y], x = 0, p = { x: 0, y: 0 }, b = [{ x: u, y }];
697
- m && c <= 0 && (p = { x: u, y });
698
- const A = 300;
699
- for (let d = 0; d <= A; d += 1) {
700
- if (x = d / A, { x: u, y } = ye(e, t, n, r, s, i, o, a, l, x), b = [...b, { x: u, y }], g += W(h, [u, y]), h = [u, y], m && g > c && c > f[2]) {
701
- const M = (g - c) / (g - f[2]);
702
- p = {
703
- x: h[0] * (1 - M) + f[0] * M,
704
- y: h[1] * (1 - M) + f[1] * M
719
+ }, ee = (e, t, n, r, s, i, o, c, l) => {
720
+ const { rx: a, ry: m, startAngle: u, endAngle: g } = Lt(e, t, n, r, s, i, o, c, l);
721
+ return te(a, m, g - u);
722
+ }, Pe = (e, t, n, r, s, i, o, c, l, a) => {
723
+ let m = { x: e, y: t };
724
+ const { center: u, rx: g, ry: f, startAngle: h, endAngle: y } = Lt(e, t, n, r, s, i, o, c, l), x = te(g, f, y - h);
725
+ if (typeof a == "number")
726
+ if (a <= 0)
727
+ m = { x: e, y: t };
728
+ else if (a >= x)
729
+ m = { x: c, y: l };
730
+ else {
731
+ if (e === c && t === l)
732
+ return { x: c, y: l };
733
+ if (g === 0 || f === 0)
734
+ return Gt(e, t, c, l, a);
735
+ const { PI: p, cos: d, sin: C } = Math, M = y - h, w = (s % 360 + 360) % 360 * (p / 180), T = h + M * (a / x), P = g * d(T), $ = f * C(T);
736
+ m = {
737
+ x: d(w) * P - C(w) * $ + u.x,
738
+ y: C(w) * P + d(w) * $ + u.y
705
739
  };
706
740
  }
707
- f = [u, y, g];
708
- }
709
- return m && c >= g && (p = { x: a, y: l }), {
710
- length: g,
711
- point: p,
741
+ return m;
742
+ }, Le = (e, t, n, r, s, i, o, c, l) => {
743
+ const { center: a, rx: m, ry: u, startAngle: g, endAngle: f } = Lt(e, t, n, r, s, i, o, c, l), h = f - g, y = { x: c, y: l }, [x, p] = [a.x, a.y], d = [y], C = s * Math.PI / 180, M = Math.tan(C), b = Math.atan2(-u * M, m), w = b, T = b + Math.PI, P = Math.atan2(u, m * M), $ = P + Math.PI, S = [e, c], _ = [t, l], X = Math.min(...S), Q = Math.max(...S), B = Math.min(..._), I = Math.max(..._), J = f - h * 1e-3, z = K(J, x, p, m, u, C), ot = f - h * 0.999, Y = K(ot, x, p, m, u, C);
744
+ return (z.x > Q || Y.x > Q) && d.push(K(w, x, p, m, u, C)), (z.x < X || Y.x < X) && d.push(K(T, x, p, m, u, C)), (z.y < B || Y.y < B) && d.push(K($, x, p, m, u, C)), (z.y > I || Y.y > I) && d.push(K(P, x, p, m, u, C)), {
712
745
  min: {
713
- x: Math.min(...b.map((d) => d.x)),
714
- y: Math.min(...b.map((d) => d.y))
746
+ x: Math.min(...d.map((O) => O.x)),
747
+ y: Math.min(...d.map((O) => O.y))
715
748
  },
716
749
  max: {
717
- x: Math.max(...b.map((d) => d.x)),
718
- y: Math.max(...b.map((d) => d.y))
750
+ x: Math.max(...d.map((O) => O.x)),
751
+ y: Math.max(...d.map((O) => O.y))
719
752
  }
720
753
  };
721
- }, xe = (e, t, n, r, s, i, o, a, l) => {
722
- const c = 1 - l;
723
- return {
724
- x: c ** 3 * e + 3 * c ** 2 * l * n + 3 * c * l ** 2 * s + l ** 3 * o,
725
- y: c ** 3 * t + 3 * c ** 2 * l * r + 3 * c * l ** 2 * i + l ** 3 * a
754
+ }, Te = { x: 0, y: 0 }, It = [
755
+ -0.06405689286260563,
756
+ 0.06405689286260563,
757
+ -0.1911188674736163,
758
+ 0.1911188674736163,
759
+ -0.3150426796961634,
760
+ 0.3150426796961634,
761
+ -0.4337935076260451,
762
+ 0.4337935076260451,
763
+ -0.5454214713888396,
764
+ 0.5454214713888396,
765
+ -0.6480936519369755,
766
+ 0.6480936519369755,
767
+ -0.7401241915785544,
768
+ 0.7401241915785544,
769
+ -0.820001985973903,
770
+ 0.820001985973903,
771
+ -0.8864155270044011,
772
+ 0.8864155270044011,
773
+ -0.9382745520027328,
774
+ 0.9382745520027328,
775
+ -0.9747285559713095,
776
+ 0.9747285559713095,
777
+ -0.9951872199970213,
778
+ 0.9951872199970213
779
+ ], Se = [
780
+ 0.12793819534675216,
781
+ 0.12793819534675216,
782
+ 0.1258374563468283,
783
+ 0.1258374563468283,
784
+ 0.12167047292780339,
785
+ 0.12167047292780339,
786
+ 0.1155056680537256,
787
+ 0.1155056680537256,
788
+ 0.10744427011596563,
789
+ 0.10744427011596563,
790
+ 0.09761865210411388,
791
+ 0.09761865210411388,
792
+ 0.08619016153195327,
793
+ 0.08619016153195327,
794
+ 0.0733464814110803,
795
+ 0.0733464814110803,
796
+ 0.05929858491543678,
797
+ 0.05929858491543678,
798
+ 0.04427743881741981,
799
+ 0.04427743881741981,
800
+ 0.028531388628933663,
801
+ 0.028531388628933663,
802
+ 0.0123412297999872,
803
+ 0.0123412297999872
804
+ ], $e = (e) => {
805
+ const t = [];
806
+ for (let n = e, r = n.length, s = r - 1; r > 1; r -= 1, s -= 1) {
807
+ const i = [];
808
+ for (let o = 0; o < s; o += 1)
809
+ i.push({
810
+ x: s * (n[o + 1].x - n[o].x),
811
+ y: s * (n[o + 1].y - n[o].y),
812
+ t: 0
813
+ });
814
+ t.push(i), n = i;
815
+ }
816
+ return t;
817
+ }, ke = (e, t) => {
818
+ if (t === 0)
819
+ return e[0].t = 0, e[0];
820
+ const n = e.length - 1;
821
+ if (t === 1)
822
+ return e[n].t = 1, e[n];
823
+ const r = 1 - t;
824
+ let s = e;
825
+ if (n === 0)
826
+ return e[0].t = t, e[0];
827
+ if (n === 1)
828
+ return {
829
+ x: r * s[0].x + t * s[1].x,
830
+ y: r * s[0].y + t * s[1].y,
831
+ t
832
+ };
833
+ const i = r * r, o = t * t;
834
+ let c = 0, l = 0, a = 0, m = 0;
835
+ return n === 2 ? (s = [s[0], s[1], s[2], Te], c = i, l = r * t * 2, a = o) : n === 3 && (c = i * r, l = i * t * 3, a = r * o * 3, m = t * o), {
836
+ x: c * s[0].x + l * s[1].x + a * s[2].x + m * s[3].x,
837
+ y: c * s[0].y + l * s[1].y + a * s[2].y + m * s[3].y,
838
+ t
726
839
  };
727
- }, pe = (e, t, n, r, s, i, o, a, l) => {
728
- const c = typeof l == "number";
729
- let m = e, u = t, y = 0, g = [m, u, y], f = [m, u], h = 0, x = { x: 0, y: 0 }, p = [{ x: m, y: u }];
730
- c && l <= 0 && (x = { x: m, y: u });
731
- const b = 300;
732
- for (let A = 0; A <= b; A += 1) {
733
- if (h = A / b, { x: m, y: u } = xe(e, t, n, r, s, i, o, a, h), p = [...p, { x: m, y: u }], y += W(f, [m, u]), f = [m, u], c && y > l && l > g[2]) {
734
- const d = (y - l) / (y - g[2]);
735
- x = {
736
- x: f[0] * (1 - d) + g[0] * d,
737
- y: f[1] * (1 - d) + g[1] * d
738
- };
840
+ }, qe = (e, t) => {
841
+ const n = e(t), r = n.x * n.x + n.y * n.y;
842
+ return Math.sqrt(r);
843
+ }, Ie = (e) => {
844
+ const n = It.length;
845
+ let r = 0;
846
+ for (let s = 0, i; s < n; s++)
847
+ i = 0.5 * It[s] + 0.5, r += Se[s] * qe(e, i);
848
+ return 0.5 * r;
849
+ }, xt = (e) => {
850
+ const t = [];
851
+ for (let r = 0, s = e.length, i = 2; r < s; r += i)
852
+ t.push({
853
+ x: e[r],
854
+ y: e[r + 1]
855
+ });
856
+ const n = $e(t);
857
+ return Ie((r) => ke(n[0], r));
858
+ }, Ee = 1e-8, Nt = (e) => {
859
+ const t = Math.min(e[0], e[2]), n = Math.max(e[0], e[2]);
860
+ if (e[1] >= e[0] ? e[2] >= e[1] : e[2] <= e[1])
861
+ return [t, n];
862
+ const r = (e[0] * e[2] - e[1] * e[1]) / (e[0] - 2 * e[1] + e[2]);
863
+ return r < t ? [r, n] : [t, r];
864
+ }, Et = (e) => {
865
+ const t = e[0] - 3 * e[1] + 3 * e[2] - e[3];
866
+ if (Math.abs(t) < Ee)
867
+ return e[0] === e[3] && e[0] === e[1] ? [e[0], e[3]] : Nt([e[0], -0.5 * e[0] + 1.5 * e[1], e[0] - 3 * e[1] + 3 * e[2]]);
868
+ const n = -e[0] * e[2] + e[0] * e[3] - e[1] * e[2] - e[1] * e[3] + e[1] * e[1] + e[2] * e[2];
869
+ if (n <= 0)
870
+ return [Math.min(e[0], e[3]), Math.max(e[0], e[3])];
871
+ const r = Math.sqrt(n);
872
+ let s = Math.min(e[0], e[3]), i = Math.max(e[0], e[3]);
873
+ const o = e[0] - 2 * e[1] + e[2];
874
+ for (let c = (o + r) / t, l = 1; l <= 2; c = (o - r) / t, l++)
875
+ if (c > 0 && c < 1) {
876
+ const a = e[0] * (1 - c) * (1 - c) * (1 - c) + e[1] * 3 * (1 - c) * (1 - c) * c + e[2] * 3 * (1 - c) * c * c + e[3] * c * c * c;
877
+ a < s && (s = a), a > i && (i = a);
739
878
  }
740
- g = [m, u, y];
879
+ return [s, i];
880
+ }, ze = ([e, t, n, r, s, i, o, c], l) => {
881
+ const a = 1 - l;
882
+ return {
883
+ x: a ** 3 * e + 3 * a ** 2 * l * n + 3 * a * l ** 2 * s + l ** 3 * o,
884
+ y: a ** 3 * t + 3 * a ** 2 * l * r + 3 * a * l ** 2 * i + l ** 3 * c
885
+ };
886
+ }, ne = (e, t, n, r, s, i, o, c) => xt([e, t, n, r, s, i, o, c]), Ze = (e, t, n, r, s, i, o, c, l) => {
887
+ const a = typeof l == "number";
888
+ let m = { x: e, y: t };
889
+ if (a) {
890
+ const u = xt([e, t, n, r, s, i, o, c]);
891
+ l <= 0 || (l >= u ? m = { x: o, y: c } : m = ze([e, t, n, r, s, i, o, c], l / u));
741
892
  }
742
- return c && l >= y && (x = { x: o, y: a }), {
743
- length: y,
744
- point: x,
745
- min: {
746
- x: Math.min(...p.map((A) => A.x)),
747
- y: Math.min(...p.map((A) => A.y))
748
- },
749
- max: {
750
- x: Math.max(...p.map((A) => A.x)),
751
- y: Math.max(...p.map((A) => A.y))
752
- }
893
+ return m;
894
+ }, Oe = (e, t, n, r, s, i, o, c) => {
895
+ const l = Et([e, n, s, o]), a = Et([t, r, i, c]);
896
+ return {
897
+ min: { x: l[0], y: a[0] },
898
+ max: { x: l[1], y: a[1] }
753
899
  };
754
- }, be = (e, t, n, r, s, i, o) => {
755
- const a = 1 - o;
900
+ }, je = ([e, t, n, r, s, i], o) => {
901
+ const c = 1 - o;
756
902
  return {
757
- x: a ** 2 * e + 2 * a * o * n + o ** 2 * s,
758
- y: a ** 2 * t + 2 * a * o * r + o ** 2 * i
903
+ x: c ** 2 * e + 2 * c * o * n + o ** 2 * s,
904
+ y: c ** 2 * t + 2 * c * o * r + o ** 2 * i
759
905
  };
760
- }, de = (e, t, n, r, s, i, o) => {
761
- const a = typeof o == "number";
762
- let l = e, c = t, m = 0, u = [l, c, m], y = [l, c], g = 0, f = { x: 0, y: 0 }, h = [{ x: l, y: c }];
763
- a && o <= 0 && (f = { x: l, y: c });
764
- const x = 300;
765
- for (let p = 0; p <= x; p += 1) {
766
- if (g = p / x, { x: l, y: c } = be(e, t, n, r, s, i, g), h = [...h, { x: l, y: c }], m += W(y, [l, c]), y = [l, c], a && m > o && o > u[2]) {
767
- const b = (m - o) / (m - u[2]);
768
- f = {
769
- x: y[0] * (1 - b) + u[0] * b,
770
- y: y[1] * (1 - b) + u[1] * b
771
- };
772
- }
773
- u = [l, c, m];
906
+ }, se = (e, t, n, r, s, i) => xt([e, t, n, r, s, i]), Re = (e, t, n, r, s, i, o) => {
907
+ const c = typeof o == "number";
908
+ let l = { x: e, y: t };
909
+ if (c) {
910
+ const a = xt([e, t, n, r, s, i]);
911
+ o <= 0 || (o >= a ? l = { x: s, y: i } : l = je([e, t, n, r, s, i], o / a));
774
912
  }
775
- return a && o >= m && (f = { x: s, y: i }), {
776
- length: m,
777
- point: f,
778
- min: {
779
- x: Math.min(...h.map((p) => p.x)),
780
- y: Math.min(...h.map((p) => p.y))
781
- },
782
- max: {
783
- x: Math.max(...h.map((p) => p.x)),
784
- y: Math.max(...h.map((p) => p.y))
785
- }
786
- };
787
- }, ft = (e, t) => {
788
- const n = z(e), r = typeof t == "number";
789
- let s, i = [], o, a = 0, l = 0, c = 0, m = 0, u, y = [], g = [], f = 0, h = { x: 0, y: 0 }, x = h, p = h, b = h, A = 0;
790
- for (let d = 0, M = n.length; d < M; d += 1)
791
- u = n[d], [o] = u, s = o === "M", i = s ? i : [a, l, ...u.slice(1)], s ? ([, c, m] = u, h = { x: c, y: m }, x = h, f = 0, r && t < 1e-3 && (b = h)) : o === "L" ? { length: f, min: h, max: x, point: p } = dt(
792
- ...i,
793
- (t || 0) - A
794
- ) : o === "A" ? { length: f, min: h, max: x, point: p } = ge(
795
- ...i,
796
- (t || 0) - A
797
- ) : o === "C" ? { length: f, min: h, max: x, point: p } = pe(
798
- ...i,
799
- (t || 0) - A
800
- ) : o === "Q" ? { length: f, min: h, max: x, point: p } = de(
801
- ...i,
802
- (t || 0) - A
803
- ) : o === "Z" && (i = [a, l, c, m], { length: f, min: h, max: x, point: p } = dt(
804
- ...i,
805
- (t || 0) - A
806
- )), r && A < t && A + f >= t && (b = p), g = [...g, x], y = [...y, h], A += f, [a, l] = o !== "Z" ? u.slice(-2) : [c, m];
807
- return r && t >= A && (b = { x: a, y: l }), {
808
- length: A,
809
- point: b,
810
- min: {
811
- x: Math.min(...y.map((d) => d.x)),
812
- y: Math.min(...y.map((d) => d.y))
813
- },
814
- max: {
815
- x: Math.max(...g.map((d) => d.x)),
816
- y: Math.max(...g.map((d) => d.y))
817
- }
913
+ return l;
914
+ }, De = (e, t, n, r, s, i) => {
915
+ const o = Nt([e, n, s]), c = Nt([t, r, i]);
916
+ return {
917
+ min: { x: o[0], y: c[0] },
918
+ max: { x: o[1], y: c[1] }
818
919
  };
819
- }, kt = (e) => {
920
+ }, zt = (e) => {
820
921
  if (!e)
821
922
  return {
822
923
  x: 0,
@@ -829,160 +930,183 @@ e.every(([t]) => t === t.toUpperCase()), Q = (e) => {
829
930
  cy: 0,
830
931
  cz: 0
831
932
  };
832
- const {
833
- min: { x: t, y: n },
834
- max: { x: r, y: s }
835
- } = ft(e), i = r - t, o = s - n;
933
+ const t = q(e);
934
+ let n = [], r = "M", s = 0, i = 0, o = 0, c = 0;
935
+ const l = [], a = [];
936
+ let m = { x: s, y: i }, u = { x: s, y: i };
937
+ D(t, (d, C) => {
938
+ const M = V(d, C), b = G(M, C);
939
+ return [r] = b, n = [s, i, ...b.slice(1)], r === "M" ? ([, o, c] = b, m = { x: o, y: c }, u = { x: o, y: c }) : r === "L" ? { min: m, max: u } = kt(...n) : r === "A" ? { min: m, max: u } = Le(...n) : r === "C" ? { min: m, max: u } = Oe(...n) : r === "Q" ? { min: m, max: u } = De(...n) : r === "Z" && (n = [s, i, o, c], { min: m, max: u } = kt(...n)), l.push(m), a.push(u), r === "Z" ? (s = o, i = c) : ([s, i] = b.slice(-2), r === "M" && (o = s, c = i)), C.x = s, C.y = i, b;
940
+ });
941
+ const g = Math.min(...l.map((d) => d.x)), f = Math.max(...a.map((d) => d.x)), h = Math.min(...l.map((d) => d.y)), y = Math.max(...a.map((d) => d.y)), x = f - g, p = y - h;
836
942
  return {
837
- width: i,
838
- height: o,
839
- x: t,
840
- y: n,
841
- x2: r,
842
- y2: s,
843
- cx: t + i / 2,
844
- cy: n + o / 2,
845
- // an estimted guess
846
- cz: Math.max(i, o) + Math.min(i, o) / 2
943
+ width: x,
944
+ height: p,
945
+ x: g,
946
+ y: h,
947
+ x2: f,
948
+ y2: y,
949
+ cx: g + x / 2,
950
+ cy: h + p / 2,
951
+ // an estimated guess
952
+ cz: Math.max(x, p) + Math.min(x, p) / 2
847
953
  };
848
- }, Mt = (e, t, n) => {
849
- if (e[n].length > 7) {
850
- e[n].shift();
851
- const r = e[n];
852
- let s = n;
853
- for (; r.length; )
854
- t[n] = "A", e.splice(s += 1, 0, ["C", ...r.splice(0, 6)]);
855
- e.splice(n, 1);
856
- }
857
- }, Jt = (e) => vt(e) && e.every(([t]) => "MC".includes(t)), rt = (e, t, n) => {
954
+ }, ct = (e, t, n) => {
858
955
  const r = e * Math.cos(n) - t * Math.sin(n), s = e * Math.sin(n) + t * Math.cos(n);
859
956
  return { x: r, y: s };
860
- }, Ut = (e, t, n, r, s, i, o, a, l, c) => {
861
- let m = e, u = t, y = n, g = r, f = a, h = l;
957
+ }, re = (e, t, n, r, s, i, o, c, l, a) => {
958
+ let m = e, u = t, g = n, f = r, h = c, y = l;
862
959
  const x = Math.PI * 120 / 180, p = Math.PI / 180 * (+s || 0);
863
- let b = [], A, d, M, T, j;
864
- if (c)
865
- [d, M, T, j] = c;
960
+ let d = [], C, M, b, w, T;
961
+ if (a)
962
+ [M, b, w, T] = a;
866
963
  else {
867
- A = rt(m, u, -p), m = A.x, u = A.y, A = rt(f, h, -p), f = A.x, h = A.y;
868
- const P = (m - f) / 2, L = (u - h) / 2;
869
- let I = P * P / (y * y) + L * L / (g * g);
870
- I > 1 && (I = Math.sqrt(I), y *= I, g *= I);
871
- const xt = y * y, pt = g * g, Ct = (i === o ? -1 : 1) * Math.sqrt(Math.abs((xt * pt - xt * L * L - pt * P * P) / (xt * L * L + pt * P * P)));
872
- T = Ct * y * L / g + (m + f) / 2, j = Ct * -g * P / y + (u + h) / 2, d = Math.asin(((u - j) / g * 10 ** 9 >> 0) / 10 ** 9), M = Math.asin(((h - j) / g * 10 ** 9 >> 0) / 10 ** 9), d = m < T ? Math.PI - d : d, M = f < T ? Math.PI - M : M, d < 0 && (d = Math.PI * 2 + d), M < 0 && (M = Math.PI * 2 + M), o && d > M && (d -= Math.PI * 2), !o && M > d && (M -= Math.PI * 2);
964
+ C = ct(m, u, -p), m = C.x, u = C.y, C = ct(h, y, -p), h = C.x, y = C.y;
965
+ const L = (m - h) / 2, Z = (u - y) / 2;
966
+ let H = L * L / (g * g) + Z * Z / (f * f);
967
+ H > 1 && (H = Math.sqrt(H), g *= H, f *= H);
968
+ const Mt = g * g, bt = f * f, St = (i === o ? -1 : 1) * Math.sqrt(Math.abs((Mt * bt - Mt * Z * Z - bt * L * L) / (Mt * Z * Z + bt * L * L)));
969
+ w = St * g * Z / f + (m + h) / 2, T = St * -f * L / g + (u + y) / 2, M = Math.asin(((u - T) / f * 10 ** 9 >> 0) / 10 ** 9), b = Math.asin(((y - T) / f * 10 ** 9 >> 0) / 10 ** 9), M = m < w ? Math.PI - M : M, b = h < w ? Math.PI - b : b, M < 0 && (M = Math.PI * 2 + M), b < 0 && (b = Math.PI * 2 + b), o && M > b && (M -= Math.PI * 2), !o && b > M && (b -= Math.PI * 2);
873
970
  }
874
- let H = M - d;
875
- if (Math.abs(H) > x) {
876
- const P = M, L = f, I = h;
877
- M = d + x * (o && M > d ? 1 : -1), f = T + y * Math.cos(M), h = j + g * Math.sin(M), b = Ut(f, h, y, g, s, 0, o, L, I, [M, P, T, j]);
971
+ let P = b - M;
972
+ if (Math.abs(P) > x) {
973
+ const L = b, Z = h, H = y;
974
+ b = M + x * (o && b > M ? 1 : -1), h = w + g * Math.cos(b), y = T + f * Math.sin(b), d = re(h, y, g, f, s, 0, o, Z, H, [b, L, w, T]);
878
975
  }
879
- H = M - d;
880
- const F = Math.cos(d), tt = Math.sin(d), S = Math.cos(M), et = Math.sin(M), Y = Math.tan(H / 4), nt = 4 / 3 * y * Y, st = 4 / 3 * g * Y, $ = [m, u], q = [m + nt * tt, u - st * F], B = [f + nt * et, h - st * S], J = [f, h];
881
- if (q[0] = 2 * $[0] - q[0], q[1] = 2 * $[1] - q[1], c)
882
- return [...q, ...B, ...J, ...b];
883
- b = [...q, ...B, ...J, ...b];
884
- const gt = [];
885
- for (let P = 0, L = b.length; P < L; P += 1)
886
- gt[P] = P % 2 ? rt(b[P - 1], b[P], p).y : rt(b[P], b[P + 1], p).x;
887
- return gt;
888
- }, Me = (e, t, n, r, s, i) => {
889
- const o = 0.3333333333333333, a = 2 / 3;
976
+ P = b - M;
977
+ const $ = Math.cos(M), S = Math.sin(M), _ = Math.cos(b), X = Math.sin(b), Q = Math.tan(P / 4), B = 4 / 3 * g * Q, I = 4 / 3 * f * Q, J = [m, u], z = [m + B * S, u - I * $], ot = [h + B * X, y - I * _], Y = [h, y];
978
+ if (z[0] = 2 * J[0] - z[0], z[1] = 2 * J[1] - z[1], a)
979
+ return [...z, ...ot, ...Y, ...d];
980
+ d = [...z, ...ot, ...Y, ...d];
981
+ const O = [];
982
+ for (let L = 0, Z = d.length; L < Z; L += 1)
983
+ O[L] = L % 2 ? ct(d[L - 1], d[L], p).y : ct(d[L], d[L + 1], p).x;
984
+ return O;
985
+ }, Qe = (e, t, n, r, s, i) => {
986
+ const o = 0.3333333333333333, c = 2 / 3;
890
987
  return [
891
- o * e + a * n,
988
+ o * e + c * n,
892
989
  // cpx1
893
- o * t + a * r,
990
+ o * t + c * r,
894
991
  // cpy1
895
- o * s + a * n,
992
+ o * s + c * n,
896
993
  // cpx2
897
- o * i + a * r,
994
+ o * i + c * r,
898
995
  // cpy2
899
996
  s,
900
997
  i
901
998
  // x,y
902
999
  ];
903
- }, St = (e, t, n, r) => {
904
- const s = E([e, t], [n, r], 0.3333333333333333), i = E([e, t], [n, r], 2 / 3);
1000
+ }, Zt = (e, t, n, r) => {
1001
+ const s = R([e, t], [n, r], 0.3333333333333333), i = R([e, t], [n, r], 2 / 3);
905
1002
  return [...s, ...i, n, r];
906
- }, ot = (e, t) => {
1003
+ }, ie = (e, t) => {
907
1004
  const [n] = e, r = e.slice(1).map(Number), [s, i] = r;
908
1005
  let o;
909
- const { x1: a, y1: l, x: c, y: m } = t;
910
- return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = s, t.y = i, e) : n === "A" ? (o = [a, l, ...r], ["C", ...Ut(...o)]) : n === "Q" ? (t.qx = s, t.qy = i, o = [a, l, ...r], ["C", ...Me(...o)]) : n === "L" ? ["C", ...St(a, l, s, i)] : n === "Z" ? ["C", ...St(a, l, c, m)] : e;
911
- }, ct = (e) => {
912
- if (Jt(e))
913
- return [...e];
914
- const t = z(e), n = { ...ut }, r = [];
915
- let s = "", i = t.length;
916
- for (let o = 0; o < i; o += 1) {
917
- [s] = t[o], r[o] = s, t[o] = ot(t[o], n), Mt(t, r, o), i = t.length;
918
- const a = t[o], l = a.length;
919
- n.x1 = +a[l - 2], n.y1 = +a[l - 1], n.x2 = +a[l - 4] || n.x1, n.y2 = +a[l - 3] || n.y1;
920
- }
921
- return t;
922
- }, Ae = (e, t, n, r, s, i, o, a) => 3 * ((a - t) * (n + s) - (o - e) * (r + i) + r * (e - s) - n * (t - i) + a * (s + e / 3) - o * (i + t / 3)) / 20, Vt = (e) => {
1006
+ const { x1: c, y1: l, x: a, y: m } = t;
1007
+ return "TQ".includes(n) || (t.qx = null, t.qy = null), n === "M" ? (t.x = s, t.y = i, e) : n === "A" ? (o = [c, l, ...r], ["C", ...re(...o)]) : n === "Q" ? (t.qx = s, t.qy = i, o = [c, l, ...r], ["C", ...Qe(...o)]) : n === "L" ? ["C", ...Zt(c, l, s, i)] : n === "Z" ? ["C", ...Zt(c, l, a, m)] : e;
1008
+ }, mt = (e) => {
1009
+ let t = 0, n = 0, r = 0, s = 0, i = "M";
1010
+ const o = q(e);
1011
+ return D(o, (c, l, a) => {
1012
+ const m = V(c, l);
1013
+ [i] = m;
1014
+ const u = i.toUpperCase(), g = G(m, l);
1015
+ let f = ie(g, l);
1016
+ return f[0] === "C" && f.length > 7 && (o.splice(a + 1, 0, ["C", ...f.slice(7)]), f = f.slice(0, 7)), u === "Z" ? (t = r, n = s) : ([t, n] = f.slice(-2), u === "M" && (r = t, s = n)), l.x = t, l.y = n, f;
1017
+ });
1018
+ }, Xe = (e, t, n, r, s, i, o, c) => 3 * ((c - t) * (n + s) - (o - e) * (r + i) + r * (e - s) - n * (t - i) + c * (s + e / 3) - o * (i + t / 3)) / 20, oe = (e) => {
923
1019
  let t = 0, n = 0, r = 0;
924
- return ct(e).map((s) => {
1020
+ return mt(e).map((s) => {
925
1021
  switch (s[0]) {
926
1022
  case "M":
927
1023
  return [, t, n] = s, 0;
928
1024
  default:
929
- return r = Ae(t, n, ...s.slice(1)), [t, n] = s.slice(-2), r;
1025
+ return r = Xe(t, n, ...s.slice(1)), [t, n] = s.slice(-2), r;
930
1026
  }
931
1027
  }).reduce((s, i) => s + i, 0);
932
- }, X = (e) => ft(e).length, Ne = (e) => Vt(ct(e)) >= 0, K = (e, t) => ft(e, t).point, Pt = (e, t) => {
933
- const n = Z(e);
934
- let r = [...n], s = X(r), i = r.length - 1, o = 0, a = 0, l = n[0];
935
- const [c, m] = l.slice(-2), u = { x: c, y: m };
1028
+ }, W = (e) => {
1029
+ const t = q(e);
1030
+ let n = !1, r = [], s = "M", i = 0, o = 0, c = 0, l = 0, a = 0;
1031
+ return D(t, (m, u) => {
1032
+ const g = V(m, u), f = G(g, u);
1033
+ return [s] = f, n = s === "M", r = n ? r : [i, o, ...f.slice(1)], n ? [, c, l] = m : s === "L" ? a += at(...r) : s === "A" ? a += ee(...r) : s === "C" ? a += ne(...r) : s === "Q" ? a += se(...r) : s === "Z" && (r = [i, o, c, l], a += at(...r)), s === "Z" ? (i = c, o = l) : ([i, o] = f.slice(-2), n && (c = i, l = o)), u.x = i, u.y = o, f;
1034
+ }), a;
1035
+ }, Be = (e) => oe(mt(e)) >= 0, At = 1e-5, nt = (e, t) => {
1036
+ const n = q(e);
1037
+ let r = !1, s = [], i = "M", o = 0, c = 0, [l, a] = n[0].slice(1);
1038
+ const m = typeof t == "number";
1039
+ let u = { x: l, y: a }, g = 0, f = u, h = 0;
1040
+ return m ? (t < At && (f = u), D(n, (y, x) => {
1041
+ const p = V(y, x), d = G(p, x);
1042
+ return [i] = d, r = i === "M", s = r ? s : [o, c, ...d.slice(1)], r ? ([, l, a] = y, u = { x: l, y: a }, g = 0) : i === "L" ? (u = Gt(...s, t - h), g = at(...s)) : i === "A" ? (u = Pe(...s, t - h), g = ee(...s)) : i === "C" ? (u = Ze(...s, t - h), g = ne(...s)) : i === "Q" ? (u = Re(...s, t - h), g = se(...s)) : i === "Z" && (s = [o, c, l, a], u = { x: l, y: a }, g = at(...s)), h < t && h + g >= t && (f = u), h += g, i === "Z" ? (o = l, c = a) : ([o, c] = d.slice(-2), i === "M" && (l = o, a = c)), x.x = o, x.y = c, d;
1043
+ }), t > h - At && (f = { x: o, y: c }), f) : u;
1044
+ }, Tt = (e, t) => {
1045
+ const n = q(e);
1046
+ let r = n.slice(0), s = W(r), i = r.length - 1, o = 0, c = 0, l = n[0];
1047
+ const [a, m] = l.slice(-2), u = { x: a, y: m };
936
1048
  if (i <= 0 || !t || !Number.isFinite(t))
937
1049
  return {
938
1050
  segment: l,
939
1051
  index: 0,
940
- length: a,
1052
+ length: c,
941
1053
  point: u,
942
1054
  lengthAtSegment: o
943
1055
  };
944
1056
  if (t >= s)
945
- return r = n.slice(0, -1), o = X(r), a = s - o, {
1057
+ return r = n.slice(0, -1), o = W(r), c = s - o, {
946
1058
  segment: n[i],
947
1059
  index: i,
948
- length: a,
1060
+ length: c,
949
1061
  lengthAtSegment: o
950
1062
  };
951
- const y = [];
1063
+ const g = [];
952
1064
  for (; i > 0; )
953
- l = r[i], r = r.slice(0, -1), o = X(r), a = s - o, s = o, y.push({
1065
+ l = r[i], r = r.slice(0, -1), o = W(r), c = s - o, s = o, g.push({
954
1066
  segment: l,
955
1067
  index: i,
956
- length: a,
1068
+ length: c,
957
1069
  lengthAtSegment: o
958
1070
  }), i -= 1;
959
- return y.find(({ lengthAtSegment: g }) => g <= t);
960
- }, yt = (e, t) => {
961
- const n = Z(e), r = z(n), s = X(n), i = (d) => {
962
- const M = d.x - t.x, T = d.y - t.y;
963
- return M * M + T * T;
1071
+ return g.find(({ lengthAtSegment: f }) => f <= t);
1072
+ }, rt = (e) => {
1073
+ let t = 0, n = 0, r = 0, s = 0, i = "M";
1074
+ return D(q(e), (o, c) => {
1075
+ const l = V(o, c), a = G(l, c);
1076
+ [i] = a;
1077
+ const m = i.toUpperCase();
1078
+ return m === "Z" ? (t = r, n = s) : ([t, n] = a.slice(-2), m === "M" && (r = t, s = n)), c.x = t, c.y = n, a;
1079
+ });
1080
+ }, pt = (e, t) => {
1081
+ const n = q(e), r = rt(n), s = W(n), i = (M) => {
1082
+ const b = M.x - t.x, w = M.y - t.y;
1083
+ return b * b + w * w;
964
1084
  };
965
- let o = 8, a, l = { x: 0, y: 0 }, c = 0, m = 0, u = 1 / 0;
966
- for (let d = 0; d <= s; d += o)
967
- a = K(r, d), c = i(a), c < u && (l = a, m = d, u = c);
1085
+ let o = 8, c, l = { x: 0, y: 0 }, a = 0, m = 0, u = 1 / 0;
1086
+ for (let M = 0; M <= s; M += o)
1087
+ c = nt(r, M), a = i(c), a < u && (l = c, m = M, u = a);
968
1088
  o /= 2;
969
- let y, g, f = 0, h = 0, x = 0, p = 0;
970
- for (; o > 0.5; )
971
- f = m - o, y = K(r, f), x = i(y), h = m + o, g = K(r, h), p = i(g), f >= 0 && x < u ? (l = y, m = f, u = x) : h <= s && p < u ? (l = g, m = h, u = p) : o /= 2;
972
- const b = Pt(n, m), A = Math.sqrt(u);
973
- return { closest: l, distance: A, segment: b };
974
- }, we = (e, t) => yt(e, t).closest, ve = (e, t) => yt(e, t).segment, Pe = (e, t) => Pt(e, t).segment, Ce = (e, t) => {
975
- const { distance: n } = yt(e, t);
976
- return Math.abs(n) < 1e-3;
977
- }, Kt = (e) => {
1089
+ let g, f, h = 0, y = 0, x = 0, p = 0;
1090
+ for (; o > 1e-6 && (h = m - o, g = nt(r, h), x = i(g), y = m + o, f = nt(r, y), p = i(f), h >= 0 && x < u ? (l = g, m = h, u = x) : y <= s && p < u ? (l = f, m = y, u = p) : o /= 2, !(o < 1e-5)); )
1091
+ ;
1092
+ const d = Tt(n, m), C = Math.sqrt(u);
1093
+ return { closest: l, distance: C, segment: d };
1094
+ }, Ye = (e, t) => pt(e, t).closest, He = (e, t) => pt(e, t).segment, Fe = (e, t) => Tt(e, t).segment, Ue = (e, t) => {
1095
+ const { distance: n } = pt(e, t);
1096
+ return Math.abs(n) < At;
1097
+ }, ce = (e) => {
978
1098
  if (typeof e != "string" || !e.length)
979
1099
  return !1;
980
- const t = new zt(e);
981
- for (V(t); t.index < t.max && !t.err.length; )
982
- jt(t);
1100
+ const t = new Xt(e);
1101
+ for (et(t); t.index < t.max && !t.err.length; )
1102
+ Qt(t);
983
1103
  return !t.err.length && "mM".includes(t.segments[0][0]);
984
- }, _t = (e) => _(e) && // `isPathArray` checks if it's `Array`
985
- e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
1104
+ }, dt = (e) => Array.isArray(e) && e.every((t) => {
1105
+ const n = t[0].toLowerCase();
1106
+ return tt[n] === t.length - 1 && "achlmqstvz".includes(n) && t.slice(1).every(Number.isFinite);
1107
+ }) && e.length > 0, le = (e) => dt(e) && // `isPathArray` also checks if it's `Array`
1108
+ e.every(([t]) => t === t.toUpperCase()), Ve = (e) => dt(e) && // `isPathArray` checks if it's `Array`
1109
+ e.slice(1).every(([t]) => t === t.toLowerCase()), ae = (e) => le(e) && e.every(([t]) => "ACLMQZ".includes(t)), _e = (e) => ae(e) && e.every(([t]) => "MC".includes(t)), ut = {
986
1110
  line: ["x1", "y1", "x2", "y2"],
987
1111
  circle: ["cx", "cy", "r"],
988
1112
  ellipse: ["cx", "cy", "rx", "ry"],
@@ -990,33 +1114,33 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
990
1114
  polygon: ["points"],
991
1115
  polyline: ["points"],
992
1116
  glyph: ["d"]
993
- }, Te = (e) => {
1117
+ }, Je = (e) => {
994
1118
  let { x1: t, y1: n, x2: r, y2: s } = e;
995
1119
  return [t, n, r, s] = [t, n, r, s].map((i) => +i), [
996
1120
  ["M", t, n],
997
1121
  ["L", r, s]
998
1122
  ];
999
- }, Le = (e) => {
1123
+ }, Ke = (e) => {
1000
1124
  const t = [], n = (e.points || "").trim().split(/[\s|,]/).map((s) => +s);
1001
1125
  let r = 0;
1002
1126
  for (; r < n.length; )
1003
1127
  t.push([r ? "L" : "M", n[r], n[r + 1]]), r += 2;
1004
1128
  return e.type === "polygon" ? [...t, ["z"]] : t;
1005
- }, ke = (e) => {
1129
+ }, We = (e) => {
1006
1130
  let { cx: t, cy: n, r } = e;
1007
1131
  return [t, n, r] = [t, n, r].map((s) => +s), [
1008
1132
  ["M", t - r, n],
1009
1133
  ["a", r, r, 0, 1, 0, 2 * r, 0],
1010
1134
  ["a", r, r, 0, 1, 0, -2 * r, 0]
1011
1135
  ];
1012
- }, Se = (e) => {
1136
+ }, Ge = (e) => {
1013
1137
  let { cx: t, cy: n } = e, r = e.rx || 0, s = e.ry || r;
1014
1138
  return [t, n, r, s] = [t, n, r, s].map((i) => +i), [
1015
1139
  ["M", t - r, n],
1016
1140
  ["a", r, s, 0, 1, 0, 2 * r, 0],
1017
1141
  ["a", r, s, 0, 1, 0, -2 * r, 0]
1018
1142
  ];
1019
- }, $e = (e) => {
1143
+ }, tn = (e) => {
1020
1144
  const t = +e.x || 0, n = +e.y || 0, r = +e.width, s = +e.height;
1021
1145
  let i = +(e.rx || 0), o = +(e.ry || i);
1022
1146
  return i || o ? (i * 2 > r && (i -= (i * 2 - r) / 2), o * 2 > s && (o -= (o * 2 - s) / 2), [
@@ -1030,134 +1154,158 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
1030
1154
  ["v", -s + o * 2],
1031
1155
  ["s", 0, -o, i, -o]
1032
1156
  ]) : [["M", t, n], ["h", r], ["v", s], ["H", t], ["Z"]];
1033
- }, Wt = (e, t) => {
1157
+ }, me = (e, t) => {
1034
1158
  const r = (t || document).defaultView || /* istanbul ignore next */
1035
- window, s = Object.keys(lt), i = e instanceof r.SVGElement, o = i ? e.tagName : null;
1159
+ window, s = Object.keys(ut), i = e instanceof r.SVGElement, o = i ? e.tagName : null;
1036
1160
  if (o && [...s, "path"].every((u) => o !== u))
1037
- throw TypeError(`${k}: "${o}" is not SVGElement`);
1038
- const a = i ? o : e.type, l = lt[a], c = { type: a };
1161
+ throw TypeError(`${E}: "${o}" is not SVGElement`);
1162
+ const c = i ? o : e.type, l = ut[c], a = { type: c };
1039
1163
  i ? l.forEach((u) => {
1040
- c[u] = e.getAttribute(u);
1041
- }) : Object.assign(c, e);
1164
+ a[u] = e.getAttribute(u);
1165
+ }) : Object.assign(a, e);
1042
1166
  let m = [];
1043
- return a === "circle" ? m = ke(c) : a === "ellipse" ? m = Se(c) : ["polyline", "polygon"].includes(a) ? m = Le(c) : a === "rect" ? m = $e(c) : a === "line" ? m = Te(c) : ["glyph", "path"].includes(a) && (m = Z(i ? e.getAttribute("d") || "" : e.d || "")), _(m) && m.length ? m : !1;
1044
- }, at = (e, t) => {
1045
- let { round: n } = mt;
1046
- if (t === "off" || n === "off") return [...e];
1167
+ return c === "circle" ? m = We(a) : c === "ellipse" ? m = Ge(a) : ["polyline", "polygon"].includes(c) ? m = Ke(a) : c === "rect" ? m = tn(a) : c === "line" ? m = Je(a) : ["glyph", "path"].includes(c) && (m = q(
1168
+ i ? e.getAttribute("d") || /* istanbul ignore next @preserve */
1169
+ "" : e.d || ""
1170
+ )), dt(m) && m.length ? m : !1;
1171
+ }, ht = (e, t) => {
1172
+ let { round: n } = st;
1173
+ if (t === "off" || n === "off") return e.slice(0);
1047
1174
  n = typeof t == "number" && t >= 0 ? t : n;
1048
1175
  const r = typeof n == "number" && n >= 1 ? 10 ** n : 1;
1049
- return e.map((s) => {
1050
- const i = s.slice(1).map(Number).map((o) => n ? Math.round(o * r) / r : Math.round(o));
1176
+ return D(e, (s) => {
1177
+ const i = s.slice(1).map((o) => n ? Math.round(o * r) / r : Math.round(o));
1051
1178
  return [s[0], ...i];
1052
1179
  });
1053
- }, At = (e, t) => at(e, t).map((n) => n[0] + n.slice(1).join(" ")).join(""), qe = (e, t, n) => {
1180
+ }, Ct = (e, t) => ht(e, t).map((n) => n[0] + n.slice(1).join(" ")).join(""), en = (e, t, n) => {
1054
1181
  const r = n || document, s = r.defaultView || /* istanbul ignore next */
1055
- window, i = Object.keys(lt), o = e instanceof s.SVGElement, a = o ? e.tagName : null;
1056
- if (a === "path") throw TypeError(`${k}: "${a}" is already SVGPathElement`);
1057
- if (a && i.every((h) => a !== h)) throw TypeError(`${k}: "${a}" is not SVGElement`);
1058
- const l = r.createElementNS("http://www.w3.org/2000/svg", "path"), c = o ? a : e.type, m = lt[c], u = { type: c }, y = mt.round, g = Wt(e, r), f = g && g.length ? At(g, y) : "";
1059
- return o ? (m.forEach((h) => {
1060
- u[h] = e.getAttribute(h);
1061
- }), Object.values(e.attributes).forEach(({ name: h, value: x }) => {
1062
- m.includes(h) || l.setAttribute(h, x);
1063
- })) : (Object.assign(u, e), Object.keys(u).forEach((h) => {
1064
- !m.includes(h) && h !== "type" && l.setAttribute(
1065
- h.replace(/[A-Z]/g, (x) => `-${x.toLowerCase()}`),
1066
- u[h]
1182
+ window, i = Object.keys(ut), o = e instanceof s.SVGElement, c = o ? e.tagName : null;
1183
+ if (c === "path") throw TypeError(`${E}: "${c}" is already SVGPathElement`);
1184
+ if (c && i.every((y) => c !== y)) throw TypeError(`${E}: "${c}" is not SVGElement`);
1185
+ const l = r.createElementNS("http://www.w3.org/2000/svg", "path"), a = o ? c : e.type, m = ut[a], u = { type: a }, g = st.round, f = me(e, r), h = f && f.length ? Ct(f, g) : "";
1186
+ return o ? (m.forEach((y) => {
1187
+ u[y] = e.getAttribute(y);
1188
+ }), Object.values(e.attributes).forEach(({ name: y, value: x }) => {
1189
+ m.includes(y) || l.setAttribute(y, x);
1190
+ })) : (Object.assign(u, e), Object.keys(u).forEach((y) => {
1191
+ !m.includes(y) && y !== "type" && l.setAttribute(
1192
+ y.replace(/[A-Z]/g, (x) => `-${x.toLowerCase()}`),
1193
+ u[y]
1067
1194
  );
1068
- })), Kt(f) ? (l.setAttribute("d", f), t && o && (e.before(l, e), e.remove()), l) : !1;
1069
- }, $t = (e) => {
1195
+ })), ce(h) ? (l.setAttribute("d", h), t && o && (e.before(l, e), e.remove()), l) : !1;
1196
+ }, Ot = (e) => {
1070
1197
  const t = [];
1071
- let n, r = -1;
1072
- return e.forEach((s) => {
1073
- s[0] === "M" ? (n = [s], r += 1) : n = [...n, s], t[r] = n;
1198
+ let n, r = -1, s = 0, i = 0, o = 0, c = 0;
1199
+ const l = { ...gt };
1200
+ return e.forEach((a) => {
1201
+ const [m] = a, u = m.toUpperCase(), g = m.toLowerCase(), f = m === g, h = a.slice(1);
1202
+ u === "M" ? (r += 1, [s, i] = h, s += f ? l.x : 0, i += f ? l.y : 0, o = s, c = i, n = [f ? [u, o, c] : a]) : (u === "Z" ? (s = o, i = c) : u === "H" ? ([, s] = a, s += f ? l.x : (
1203
+ /* istanbul ignore next @preserve */
1204
+ 0
1205
+ )) : u === "V" ? ([, i] = a, i += f ? l.y : (
1206
+ /* istanbul ignore next @preserve */
1207
+ 0
1208
+ )) : ([s, i] = a.slice(-2), s += f ? l.x : 0, i += f ? l.y : 0), n.push(a)), l.x = s, l.y = i, t[r] = n;
1074
1209
  }), t;
1075
- }, Gt = (e) => {
1210
+ }, ue = (e) => {
1076
1211
  let t = new v();
1077
- const { origin: n } = e, [r, s] = n, { translate: i } = e, { rotate: o } = e, { skew: a } = e, { scale: l } = e;
1078
- return Array.isArray(i) && i.length >= 2 && i.every((c) => !Number.isNaN(+c)) && i.some((c) => c !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || a || l) && (t = t.translate(r, s), Array.isArray(o) && o.length >= 2 && o.every((c) => !Number.isNaN(+c)) && o.some((c) => c !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(a) && a.length === 2 && a.every((c) => !Number.isNaN(+c)) && a.some((c) => c !== 0) ? (t = a[0] ? t.skewX(a[0]) : t, t = a[1] ? t.skewY(a[1]) : t) : typeof a == "number" && !Number.isNaN(a) && (t = t.skewX(a)), Array.isArray(l) && l.length >= 2 && l.every((c) => !Number.isNaN(+c)) && l.some((c) => c !== 1) ? t = t.scale(...l) : typeof l == "number" && !Number.isNaN(l) && (t = t.scale(l)), t = t.translate(-r, -s)), t;
1079
- }, Nt = (e) => {
1080
- if (_t(e))
1081
- return [...e];
1082
- const t = Z(e);
1083
- let n = 0, r = 0, s = 0, i = 0;
1084
- return t.map((o) => {
1085
- const a = o.slice(1).map(Number), [l] = o, c = l.toLowerCase();
1086
- if (l === "M")
1087
- return [n, r] = a, s = n, i = r, ["M", n, r];
1088
- let m = [];
1089
- if (l !== c)
1090
- if (c === "a")
1091
- m = [
1092
- c,
1093
- a[0],
1094
- a[1],
1095
- a[2],
1096
- a[3],
1097
- a[4],
1098
- a[5] - n,
1099
- a[6] - r
1100
- ];
1101
- else if (c === "v")
1102
- m = [c, a[0] - r];
1103
- else if (c === "h")
1104
- m = [c, a[0] - n];
1105
- else {
1106
- const y = a.map((g, f) => g - (f % 2 ? r : n));
1107
- m = [c, ...y];
1108
- }
1109
- else
1110
- l === "m" && (s = a[0] + n, i = a[1] + r), m = [c, ...a];
1111
- const u = m.length;
1112
- return c === "z" ? (n = s, r = i) : c === "h" ? n += m[1] : c === "v" ? r += m[1] : (n += m[u - 2], r += m[u - 1]), m;
1212
+ const { origin: n } = e, [r, s] = n, { translate: i } = e, { rotate: o } = e, { skew: c } = e, { scale: l } = e;
1213
+ return Array.isArray(i) && i.length >= 2 && i.every((a) => !Number.isNaN(+a)) && i.some((a) => a !== 0) ? t = t.translate(...i) : typeof i == "number" && !Number.isNaN(i) && (t = t.translate(i)), (o || c || l) && (t = t.translate(r, s), Array.isArray(o) && o.length >= 2 && o.every((a) => !Number.isNaN(+a)) && o.some((a) => a !== 0) ? t = t.rotate(...o) : typeof o == "number" && !Number.isNaN(o) && (t = t.rotate(o)), Array.isArray(c) && c.length === 2 && c.every((a) => !Number.isNaN(+a)) && c.some((a) => a !== 0) ? (t = c[0] ? t.skewX(c[0]) : t, t = c[1] ? t.skewY(c[1]) : t) : typeof c == "number" && !Number.isNaN(c) && (t = t.skewX(c)), Array.isArray(l) && l.length >= 2 && l.every((a) => !Number.isNaN(+a)) && l.some((a) => a !== 1) ? t = t.scale(...l) : typeof l == "number" && !Number.isNaN(l) && (t = t.scale(l)), t = t.translate(-r, -s)), t;
1214
+ }, ft = (e) => {
1215
+ let t = 0, n = 0, r = 0, s = 0, i = "M";
1216
+ const o = q(e);
1217
+ return D(o, (c, l) => {
1218
+ [i] = c;
1219
+ const a = V(c, l), m = i.toUpperCase();
1220
+ return m === "Z" ? (t = r, n = s) : m === "H" ? [, t] = a : m === "V" ? [, n] = a : ([t, n] = a.slice(-2), m === "M" && (r = t, s = n)), l.x = t, l.y = n, a;
1221
+ });
1222
+ }, nn = (e, t, n) => {
1223
+ const [r] = e, { x: s, y: i } = t, o = e.slice(1).map(Number), c = r.toLowerCase();
1224
+ if (n === 0 && r === "M")
1225
+ return e;
1226
+ if (r !== c) {
1227
+ if (c === "a")
1228
+ return [
1229
+ c,
1230
+ o[0],
1231
+ o[1],
1232
+ o[2],
1233
+ o[3],
1234
+ o[4],
1235
+ o[5] - s,
1236
+ o[6] - i
1237
+ ];
1238
+ if (c === "v")
1239
+ return [c, o[0] - i];
1240
+ if (c === "h")
1241
+ return [c, o[0] - s];
1242
+ {
1243
+ const l = o.map((a, m) => a - (m % 2 ? i : s));
1244
+ return [c, ...l];
1245
+ }
1246
+ }
1247
+ return e;
1248
+ }, vt = (e) => {
1249
+ let t = 0, n = 0, r = 0, s = 0, i = "M";
1250
+ const o = q(e);
1251
+ return D(o, (c, l, a) => {
1252
+ [i] = c;
1253
+ const m = nn(c, l, a), [u] = m, g = i.toUpperCase(), f = i.toLowerCase(), h = u === f;
1254
+ return g === "Z" ? (t = r, n = s) : g === "H" ? ([, t] = m, t += h ? l.x : (
1255
+ /* istanbul ignore next @preserve */
1256
+ 0
1257
+ )) : g === "V" ? ([, n] = m, n += h ? l.y : (
1258
+ /* istanbul ignore next @preserve */
1259
+ 0
1260
+ )) : ([t, n] = m.slice(-2), t += h ? l.x : 0, n += h ? l.y : 0, g === "M" && (r = t, s = n)), l.x = t, l.y = n, m;
1113
1261
  });
1114
- }, Oe = (e, t, n, r) => {
1115
- const [s] = e, i = (p) => Math.round(p * 10 ** 4) / 10 ** 4, o = e.slice(1).map((p) => +p), a = t.slice(1).map((p) => +p), { x1: l, y1: c, x2: m, y2: u, x: y, y: g } = n;
1116
- let f = e;
1117
- const [h, x] = a.slice(-2);
1262
+ }, sn = (e, t, n, r) => {
1263
+ const [s] = e, i = (p) => Math.round(p * 10 ** 4) / 10 ** 4, o = e.slice(1), c = t.slice(1), { x1: l, y1: a, x2: m, y2: u, x: g, y: f } = n;
1264
+ let h = e;
1265
+ const [y, x] = c.slice(-2);
1118
1266
  if ("TQ".includes(s) || (n.qx = null, n.qy = null), ["V", "H", "S", "T", "Z"].includes(s))
1119
- f = [s, ...o];
1267
+ h = [s, ...o];
1120
1268
  else if (s === "L")
1121
- i(y) === i(h) ? f = ["V", x] : i(g) === i(x) && (f = ["H", h]);
1269
+ i(g) === i(y) ? h = ["V", x] : i(f) === i(x) && (h = ["H", y]);
1122
1270
  else if (s === "C") {
1123
- const [p, b] = a;
1124
- "CS".includes(r) && (i(p) === i(l * 2 - m) && i(b) === i(c * 2 - u) || i(l) === i(m * 2 - y) && i(c) === i(u * 2 - g)) && (f = ["S", ...a.slice(-4)]), n.x1 = p, n.y1 = b;
1271
+ const [p, d] = c;
1272
+ "CS".includes(r) && (i(p) === i(l * 2 - m) && i(d) === i(a * 2 - u) || i(l) === i(m * 2 - g) && i(a) === i(u * 2 - f)) && (h = ["S", ...c.slice(-4)]), n.x1 = p, n.y1 = d;
1125
1273
  } else if (s === "Q") {
1126
- const [p, b] = a;
1127
- n.qx = p, n.qy = b, "QT".includes(r) && (i(p) === i(l * 2 - m) && i(b) === i(c * 2 - u) || i(l) === i(m * 2 - y) && i(c) === i(u * 2 - g)) && (f = ["T", ...a.slice(-2)]);
1274
+ const [p, d] = c;
1275
+ n.qx = p, n.qy = d, "QT".includes(r) && (i(p) === i(l * 2 - m) && i(d) === i(a * 2 - u) || i(l) === i(m * 2 - g) && i(a) === i(u * 2 - f)) && (h = ["T", ...c.slice(-2)]);
1128
1276
  }
1129
- return f;
1130
- }, qt = (e, t) => {
1131
- const n = Q(e), r = z(n), s = { ...ut }, i = [], o = n.length;
1132
- let a = "", l = "", c = 0, m = 0, u = 0, y = 0;
1133
- for (let h = 0; h < o; h += 1) {
1134
- [a] = n[h], i[h] = a, h && (l = i[h - 1]), n[h] = Oe(n[h], r[h], s, l);
1135
- const x = n[h], p = x.length;
1136
- switch (s.x1 = +x[p - 2], s.y1 = +x[p - 1], s.x2 = +x[p - 4] || s.x1, s.y2 = +x[p - 3] || s.y1, a) {
1277
+ return h;
1278
+ }, jt = (e, t) => {
1279
+ const n = ft(e), r = rt(n), s = { ...gt }, i = [], o = n.length;
1280
+ let c = "", l = "", a = 0, m = 0, u = 0, g = 0;
1281
+ for (let y = 0; y < o; y += 1) {
1282
+ [c] = n[y], i[y] = c, y && (l = i[y - 1]), n[y] = sn(n[y], r[y], s, l);
1283
+ const x = n[y], p = x.length;
1284
+ switch (s.x1 = +x[p - 2], s.y1 = +x[p - 1], s.x2 = +x[p - 4] || s.x1, s.y2 = +x[p - 3] || s.y1, c) {
1137
1285
  case "Z":
1138
- c = u, m = y;
1286
+ a = u, m = g;
1139
1287
  break;
1140
1288
  case "H":
1141
- [, c] = x;
1289
+ [, a] = x;
1142
1290
  break;
1143
1291
  case "V":
1144
1292
  [, m] = x;
1145
1293
  break;
1146
1294
  default:
1147
- [c, m] = x.slice(-2).map(Number), a === "M" && (u = c, y = m);
1295
+ [a, m] = x.slice(-2).map(Number), c === "M" && (u = a, g = m);
1148
1296
  }
1149
- s.x = c, s.y = m;
1297
+ s.x = a, s.y = m;
1150
1298
  }
1151
- const g = at(n, t), f = at(Nt(n), t);
1152
- return g.map((h, x) => x ? h.join("").length < f[x].join("").length ? h : f[x] : h);
1153
- }, Ee = (e) => {
1299
+ const f = ht(n, t), h = ht(vt(n), t);
1300
+ return f.map((y, x) => x ? y.join("").length < h[x].join("").length ? y : h[x] : y);
1301
+ }, rn = (e) => {
1154
1302
  const t = e.slice(1).map(
1155
1303
  (n, r, s) => r ? [...s[r - 1].slice(-2), ...n.slice(1)] : [...e[0].slice(1), ...n.slice(1)]
1156
1304
  ).map((n) => n.map((r, s) => n[n.length - s - 2 * (1 - s % 2)])).reverse();
1157
1305
  return [["M", ...t[0].slice(0, 2)], ...t.map((n) => ["C", ...n.slice(2)])];
1158
- }, it = (e) => {
1159
- const t = Q(e), n = t.slice(-1)[0][0] === "Z", r = z(t).map((s, i) => {
1160
- const [o, a] = s.slice(-2).map(Number);
1306
+ }, lt = (e) => {
1307
+ const t = ft(e), n = t.slice(-1)[0][0] === "Z", r = rt(t).map((s, i) => {
1308
+ const [o, c] = s.slice(-2).map(Number);
1161
1309
  return {
1162
1310
  seg: t[i],
1163
1311
  // absolute
@@ -1167,124 +1315,115 @@ e.slice(1).every(([t]) => t === t.toLowerCase()), lt = {
1167
1315
  // pathCommand
1168
1316
  x: o,
1169
1317
  // x
1170
- y: a
1318
+ y: c
1171
1319
  // y
1172
1320
  };
1173
1321
  }).map((s, i, o) => {
1174
- const a = s.seg, l = s.n, c = i && o[i - 1], m = o[i + 1], u = s.c, y = o.length, g = i ? o[i - 1].x : o[y - 1].x, f = i ? o[i - 1].y : o[y - 1].y;
1175
- let h = [];
1322
+ const c = s.seg, l = s.n, a = i && o[i - 1], m = o[i + 1], u = s.c, g = o.length, f = i ? o[i - 1].x : o[g - 1].x, h = i ? o[i - 1].y : o[g - 1].y;
1323
+ let y = [];
1176
1324
  switch (u) {
1177
1325
  case "M":
1178
- h = n ? ["Z"] : [u, g, f];
1326
+ y = n ? ["Z"] : [u, f, h];
1179
1327
  break;
1180
1328
  case "A":
1181
- h = [u, ...a.slice(1, -3), a[5] === 1 ? 0 : 1, g, f];
1329
+ y = [u, ...c.slice(1, -3), c[5] === 1 ? 0 : 1, f, h];
1182
1330
  break;
1183
1331
  case "C":
1184
- m && m.c === "S" ? h = ["S", a[1], a[2], g, f] : h = [u, a[3], a[4], a[1], a[2], g, f];
1332
+ m && m.c === "S" ? y = ["S", c[1], c[2], f, h] : y = [u, c[3], c[4], c[1], c[2], f, h];
1185
1333
  break;
1186
1334
  case "S":
1187
- c && "CS".includes(c.c) && (!m || m.c !== "S") ? h = ["C", l[3], l[4], l[1], l[2], g, f] : h = [u, l[1], l[2], g, f];
1335
+ a && "CS".includes(a.c) && (!m || m.c !== "S") ? y = ["C", l[3], l[4], l[1], l[2], f, h] : y = [u, l[1], l[2], f, h];
1188
1336
  break;
1189
1337
  case "Q":
1190
- m && m.c === "T" ? h = ["T", g, f] : h = [u, ...a.slice(1, -2), g, f];
1338
+ m && m.c === "T" ? y = ["T", f, h] : y = [u, ...c.slice(1, -2), f, h];
1191
1339
  break;
1192
1340
  case "T":
1193
- c && "QT".includes(c.c) && (!m || m.c !== "T") ? h = ["Q", l[1], l[2], g, f] : h = [u, g, f];
1341
+ a && "QT".includes(a.c) && (!m || m.c !== "T") ? y = ["Q", l[1], l[2], f, h] : y = [u, f, h];
1194
1342
  break;
1195
1343
  case "Z":
1196
- h = ["M", g, f];
1344
+ y = ["M", f, h];
1197
1345
  break;
1198
1346
  case "H":
1199
- h = [u, g];
1347
+ y = [u, f];
1200
1348
  break;
1201
1349
  case "V":
1202
- h = [u, f];
1350
+ y = [u, h];
1203
1351
  break;
1204
1352
  default:
1205
- h = [u, ...a.slice(1, -2), g, f];
1353
+ y = [u, ...c.slice(1, -2), f, h];
1206
1354
  }
1207
- return h;
1355
+ return y;
1208
1356
  });
1209
1357
  return n ? r.reverse() : [r[0], ...r.slice(1).reverse()];
1210
- }, je = (e, t) => {
1358
+ }, on = (e, t) => {
1211
1359
  let n = v.Translate(...t.slice(0, -1));
1212
1360
  return [, , , n.m44] = t, n = e.multiply(n), [n.m41, n.m42, n.m43, n.m44];
1213
- }, Ot = (e, t, n) => {
1214
- const [r, s, i] = n, [o, a, l] = je(e, [...t, 0, 1]), c = o - r, m = a - s, u = l - i;
1361
+ }, Rt = (e, t, n) => {
1362
+ const [r, s, i] = n, [o, c, l] = on(e, [...t, 0, 1]), a = o - r, m = c - s, u = l - i;
1215
1363
  return [
1216
1364
  // protect against division by ZERO
1217
- c * (Math.abs(i) / Math.abs(u) || 1) + r,
1365
+ a * (Math.abs(i) / Math.abs(u) || 1) + r,
1218
1366
  m * (Math.abs(i) / Math.abs(u) || 1) + s
1219
1367
  ];
1220
- }, Et = (e, t) => {
1221
- let n = 0, r = 0, s, i, o, a, l, c;
1222
- const m = Q(e), u = t && Object.keys(t);
1223
- if (!t || u && !u.length) return [...m];
1224
- const y = z(m);
1225
- if (!t.origin) {
1226
- const { origin: M } = mt;
1227
- Object.assign(t, { origin: M });
1228
- }
1229
- const g = Gt(t), { origin: f } = t, h = { ...ut };
1230
- let x = [], p = 0, b = "", A = [];
1231
- const d = [];
1232
- if (!g.isIdentity) {
1233
- for (s = 0, o = m.length; s < o; s += 1) {
1234
- x = m[s], m[s] && ([b] = x), d[s] = b, b === "A" && (x = ot(y[s], h), m[s] = ot(y[s], h), Mt(m, d, s), y[s] = ot(y[s], h), Mt(y, d, s), o = Math.max(m.length, y.length)), x = y[s], p = x.length, h.x1 = +x[p - 2], h.y1 = +x[p - 1], h.x2 = +x[p - 4] || h.x1, h.y2 = +x[p - 3] || h.y1;
1235
- const M = {
1236
- s: m[s],
1237
- c: m[s][0],
1238
- x: h.x1,
1239
- y: h.y1
1240
- };
1241
- A = [...A, M];
1242
- }
1243
- return A.map((M) => {
1244
- if (b = M.c, x = M.s, b === "L" || b === "H" || b === "V")
1245
- return [l, c] = Ot(g, [M.x, M.y], f), n !== l && r !== c ? x = ["L", l, c] : r === c ? x = ["H", l] : n === l && (x = ["V", c]), n = l, r = c, x;
1246
- for (i = 1, a = x.length; i < a; i += 2)
1247
- [n, r] = Ot(g, [+x[i], +x[i + 1]], f), x[i] = n, x[i + 1] = r;
1248
- return x;
1249
- });
1250
- }
1251
- return [...m];
1252
- }, ze = (e) => {
1253
- const n = e.slice(0, 2), r = e.slice(2, 4), s = e.slice(4, 6), i = e.slice(6, 8), o = E(n, r, 0.5), a = E(r, s, 0.5), l = E(s, i, 0.5), c = E(o, a, 0.5), m = E(a, l, 0.5), u = E(c, m, 0.5);
1368
+ }, Dt = (e, t) => {
1369
+ let n = 0, r = 0, s = 0, i = 0, o = 0, c = 0, l = 0, a = 0, m = 0, u = 0, g = "M";
1370
+ const f = { ...gt }, h = q(e), y = t && Object.keys(t);
1371
+ if (!t || y && !y.length) return h;
1372
+ t.origin || Object.assign(t, { origin: st.origin });
1373
+ const x = t.origin, p = ue(t);
1374
+ return p.isIdentity ? h : D(h, (d, C, M) => {
1375
+ const b = V(d, f);
1376
+ [g] = b;
1377
+ let w = g === "A" ? ie(b, f) : ["V", "H"].includes(g) ? G(b, f) : b;
1378
+ const T = w[0] === "C" && w.length > 7, P = T ? w.slice(0, 7) : w.slice(0);
1379
+ if (T && (h.splice(M + 1, 0, ["C", ...w.slice(7)]), w = w.slice(0, 7)), w[0] === "L") {
1380
+ const S = w.slice(-2);
1381
+ [o, c] = Rt(p, S, x), n !== o && r !== c ? w = ["L", o, c] : r === c ? w = ["H", o] : n === o && (w = ["V", c]);
1382
+ } else
1383
+ for (l = 1, a = w.length; l < a; l += 2)
1384
+ [o, c] = Rt(p, [+w[l], +w[l + 1]], x), w[l] = o, w[l + 1] = c;
1385
+ n = o, r = c, g === "Z" ? (m = s, u = i) : ([m, u] = P.slice(-2), g === "M" && (s = m, i = u));
1386
+ const $ = P.length;
1387
+ return f.x1 = +P[$ - 2], f.y1 = +P[$ - 1], f.x2 = +P[$ - 4] || f.x1, f.y2 = +P[$ - 3] || f.y1, f.x = m, f.y = u, w;
1388
+ });
1389
+ }, cn = (e, t = 0.5) => {
1390
+ const n = t, r = e.slice(0, 2), s = e.slice(2, 4), i = e.slice(4, 6), o = e.slice(6, 8), c = R(r, s, n), l = R(s, i, n), a = R(i, o, n), m = R(c, l, n), u = R(l, a, n), g = R(m, u, n);
1254
1391
  return [
1255
- ["C", ...o, ...c, ...u],
1256
- ["C", ...m, ...l, ...i]
1392
+ ["C", ...c, ...m, ...g],
1393
+ ["C", ...u, ...a, ...o]
1257
1394
  ];
1258
1395
  };
1259
- class w {
1396
+ class A {
1260
1397
  /**
1261
1398
  * @constructor
1262
- * @param {string} pathValue the path string
1263
- * @param {any} config instance options
1399
+ * @param pathValue the path string
1400
+ * @param config instance options
1264
1401
  */
1265
1402
  constructor(t, n) {
1266
1403
  const r = n || {}, s = typeof t > "u";
1267
1404
  if (s || !t.length)
1268
- throw TypeError(`${k}: "pathValue" is ${s ? "undefined" : "empty"}`);
1269
- const i = Z(t);
1405
+ throw TypeError(`${E}: "pathValue" is ${s ? "undefined" : "empty"}`);
1406
+ const i = q(t);
1270
1407
  this.segments = i;
1271
- const { width: o, height: a, cx: l, cy: c, cz: m } = this.getBBox(), { round: u, origin: y } = r;
1272
- let g;
1273
- if (u === "auto") {
1274
- const h = `${Math.floor(Math.max(o, a))}`.length;
1275
- g = h >= 4 ? 0 : 4 - h;
1276
- } else Number.isInteger(u) || u === "off" ? g = u : g = mt.round;
1277
- let f;
1278
- if (Array.isArray(y) && y.length >= 2) {
1279
- const [h, x, p] = y.map(Number);
1280
- f = [
1281
- Number.isNaN(h) ? l : h,
1282
- Number.isNaN(x) ? c : x,
1283
- Number.isNaN(p) ? m : p
1408
+ const { round: o, origin: c } = r;
1409
+ let l;
1410
+ Number.isInteger(o) || o === "off" ? l = o : l = st.round;
1411
+ let a = st.origin;
1412
+ if (Array.isArray(c) && c.length >= 2) {
1413
+ const [m, u, g] = c.map(Number);
1414
+ a = [
1415
+ Number.isNaN(m) ? 0 : m,
1416
+ Number.isNaN(u) ? 0 : u,
1417
+ Number.isNaN(g) ? 0 : g
1284
1418
  ];
1285
- } else
1286
- f = [l, c, m];
1287
- return this.round = g, this.origin = f, this;
1419
+ }
1420
+ return this.round = l, this.origin = a, this;
1421
+ }
1422
+ get bbox() {
1423
+ return zt(this.segments);
1424
+ }
1425
+ get length() {
1426
+ return W(this.segments);
1288
1427
  }
1289
1428
  /**
1290
1429
  * Returns the path bounding box, equivalent to native `path.getBBox()`.
@@ -1293,7 +1432,7 @@ class w {
1293
1432
  * @returns the pathBBox
1294
1433
  */
1295
1434
  getBBox() {
1296
- return kt(this.segments);
1435
+ return this.bbox;
1297
1436
  }
1298
1437
  /**
1299
1438
  * Returns the total path length, equivalent to native `path.getTotalLength()`.
@@ -1302,7 +1441,7 @@ class w {
1302
1441
  * @returns the path total length
1303
1442
  */
1304
1443
  getTotalLength() {
1305
- return X(this.segments);
1444
+ return this.length;
1306
1445
  }
1307
1446
  /**
1308
1447
  * Returns an `{x,y}` point in the path stroke at a given length,
@@ -1313,7 +1452,7 @@ class w {
1313
1452
  * @returns the requested point
1314
1453
  */
1315
1454
  getPointAtLength(t) {
1316
- return K(this.segments, t);
1455
+ return nt(this.segments, t);
1317
1456
  }
1318
1457
  /**
1319
1458
  * Convert path to absolute values
@@ -1322,7 +1461,7 @@ class w {
1322
1461
  */
1323
1462
  toAbsolute() {
1324
1463
  const { segments: t } = this;
1325
- return this.segments = Q(t), this;
1464
+ return this.segments = ft(t), this;
1326
1465
  }
1327
1466
  /**
1328
1467
  * Convert path to relative values
@@ -1331,7 +1470,7 @@ class w {
1331
1470
  */
1332
1471
  toRelative() {
1333
1472
  const { segments: t } = this;
1334
- return this.segments = Nt(t), this;
1473
+ return this.segments = vt(t), this;
1335
1474
  }
1336
1475
  /**
1337
1476
  * Convert path to cubic-bezier values. In addition, un-necessary `Z`
@@ -1341,7 +1480,7 @@ class w {
1341
1480
  */
1342
1481
  toCurve() {
1343
1482
  const { segments: t } = this;
1344
- return this.segments = ct(t), this;
1483
+ return this.segments = mt(t), this;
1345
1484
  }
1346
1485
  /**
1347
1486
  * Reverse the order of the segments and their values.
@@ -1351,9 +1490,9 @@ class w {
1351
1490
  */
1352
1491
  reverse(t) {
1353
1492
  this.toAbsolute();
1354
- const { segments: n } = this, r = $t(n), s = r.length > 1 ? r : !1, i = s ? [...s].map((a, l) => t ? l ? it(a) : [...a] : it(a)) : [...n];
1493
+ const { segments: n } = this, r = Ot(n), s = r.length > 1 ? r : !1, i = s ? s.map((c, l) => t ? l ? lt(c) : c.slice(0) : lt(c)) : n.slice(0);
1355
1494
  let o = [];
1356
- return s ? o = i.flat(1) : o = t ? n : it(n), this.segments = [...o], this;
1495
+ return s ? o = i.flat(1) : o = t ? n : lt(n), this.segments = o.slice(0), this;
1357
1496
  }
1358
1497
  /**
1359
1498
  * Normalize path in 2 steps:
@@ -1364,7 +1503,7 @@ class w {
1364
1503
  */
1365
1504
  normalize() {
1366
1505
  const { segments: t } = this;
1367
- return this.segments = z(t), this;
1506
+ return this.segments = rt(t), this;
1368
1507
  }
1369
1508
  /**
1370
1509
  * Optimize `pathArray` values:
@@ -1376,7 +1515,7 @@ class w {
1376
1515
  */
1377
1516
  optimize() {
1378
1517
  const { segments: t } = this;
1379
- return this.segments = qt(t, this.round), this;
1518
+ return this.segments = jt(t, this.round), this;
1380
1519
  }
1381
1520
  /**
1382
1521
  * Transform path using values from an `Object` defined as `transformObject`.
@@ -1393,15 +1532,15 @@ class w {
1393
1532
  segments: n,
1394
1533
  origin: [r, s, i]
1395
1534
  } = this, o = {};
1396
- for (const [l, c] of Object.entries(t))
1397
- l === "skew" && Array.isArray(c) || (l === "rotate" || l === "translate" || l === "origin" || l === "scale") && Array.isArray(c) ? o[l] = c.map(Number) : l !== "origin" && typeof Number(c) == "number" && (o[l] = Number(c));
1398
- const { origin: a } = o;
1399
- if (Array.isArray(a) && a.length >= 2) {
1400
- const [l, c, m] = a.map(Number);
1401
- o.origin = [Number.isNaN(l) ? r : l, Number.isNaN(c) ? s : c, m || i];
1535
+ for (const [l, a] of Object.entries(t))
1536
+ l === "skew" && Array.isArray(a) || (l === "rotate" || l === "translate" || l === "origin" || l === "scale") && Array.isArray(a) ? o[l] = a.map(Number) : l !== "origin" && typeof Number(a) == "number" && (o[l] = Number(a));
1537
+ const { origin: c } = o;
1538
+ if (Array.isArray(c) && c.length >= 2) {
1539
+ const [l, a, m] = c.map(Number);
1540
+ o.origin = [Number.isNaN(l) ? r : l, Number.isNaN(a) ? s : a, m || i];
1402
1541
  } else
1403
1542
  o.origin = [r, s, i];
1404
- return this.segments = Et(n, o), this;
1543
+ return this.segments = Dt(n, o), this;
1405
1544
  }
1406
1545
  /**
1407
1546
  * Rotate path 180deg vertically
@@ -1409,7 +1548,8 @@ class w {
1409
1548
  * @public
1410
1549
  */
1411
1550
  flipX() {
1412
- return this.transform({ rotate: [0, 180, 0] }), this;
1551
+ const { cx: t, cy: n } = this.bbox;
1552
+ return this.transform({ rotate: [0, 180, 0], origin: [t, n, 0] }), this;
1413
1553
  }
1414
1554
  /**
1415
1555
  * Rotate path 180deg horizontally
@@ -1417,7 +1557,8 @@ class w {
1417
1557
  * @public
1418
1558
  */
1419
1559
  flipY() {
1420
- return this.transform({ rotate: [180, 0, 0] }), this;
1560
+ const { cx: t, cy: n } = this.bbox;
1561
+ return this.transform({ rotate: [180, 0, 0], origin: [t, n, 0] }), this;
1421
1562
  }
1422
1563
  /**
1423
1564
  * Export the current path to be used
@@ -1427,12 +1568,11 @@ class w {
1427
1568
  * @return the path string
1428
1569
  */
1429
1570
  toString() {
1430
- return At(this.segments, this.round);
1571
+ return Ct(this.segments, this.round);
1431
1572
  }
1432
1573
  }
1433
- // bring main utilities to front
1434
- N(w, "CSSMatrix", v), N(w, "getSVGMatrix", Gt), N(w, "getPathBBox", kt), N(w, "getPathArea", Vt), N(w, "getTotalLength", X), N(w, "getDrawDirection", Ne), N(w, "getPointAtLength", K), N(w, "pathLengthFactory", ft), N(w, "getPropertiesAtLength", Pt), N(w, "getPropertiesAtPoint", yt), N(w, "polygonLength", ae), N(w, "polygonArea", le), N(w, "getClosestPoint", we), N(w, "getSegmentOfPoint", ve), N(w, "getSegmentAtLength", Pe), N(w, "isPointInStroke", Ce), N(w, "isValidPath", Kt), N(w, "isPathArray", _), N(w, "isAbsoluteArray", wt), N(w, "isRelativeArray", _t), N(w, "isCurveArray", Jt), N(w, "isNormalizedArray", vt), N(w, "shapeToPath", qe), N(w, "shapeToPathArray", Wt), N(w, "parsePathString", Z), N(w, "roundPath", at), N(w, "splitPath", $t), N(w, "splitCubic", ze), N(w, "optimizePath", qt), N(w, "reverseCurve", Ee), N(w, "reversePath", it), N(w, "normalizePath", z), N(w, "transformPath", Et), N(w, "pathToAbsolute", Q), N(w, "pathToRelative", Nt), N(w, "pathToCurve", ct), N(w, "pathToString", At);
1574
+ N(A, "CSSMatrix", v), N(A, "getSVGMatrix", ue), N(A, "getPathBBox", zt), N(A, "getPathArea", oe), N(A, "getTotalLength", W), N(A, "getDrawDirection", Be), N(A, "getPointAtLength", nt), N(A, "getPropertiesAtLength", Tt), N(A, "getPropertiesAtPoint", pt), N(A, "polygonLength", Ne), N(A, "polygonArea", we), N(A, "getClosestPoint", Ye), N(A, "getSegmentOfPoint", He), N(A, "getSegmentAtLength", Fe), N(A, "isPointInStroke", Ue), N(A, "isValidPath", ce), N(A, "isPathArray", dt), N(A, "isAbsoluteArray", le), N(A, "isRelativeArray", Ve), N(A, "isCurveArray", _e), N(A, "isNormalizedArray", ae), N(A, "shapeToPath", en), N(A, "shapeToPathArray", me), N(A, "parsePathString", q), N(A, "roundPath", ht), N(A, "splitPath", Ot), N(A, "splitCubic", cn), N(A, "optimizePath", jt), N(A, "reverseCurve", rn), N(A, "reversePath", lt), N(A, "normalizePath", rt), N(A, "transformPath", Dt), N(A, "pathToAbsolute", ft), N(A, "pathToRelative", vt), N(A, "pathToCurve", mt), N(A, "pathToString", Ct);
1435
1575
  export {
1436
- w as default
1576
+ A as default
1437
1577
  };
1438
1578
  //# sourceMappingURL=svg-path-commander.mjs.map