svg-path-commander 2.0.10 → 2.1.0

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