svg-path-commander 2.1.0 → 2.1.1

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