replicad-pantograph 0.9.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ var ht$1 = (r, s, t) => (oe$1(r, s, "read from private field"), t ? t.call(r) :
10
10
  function zt(r, s, t, e) {
11
11
  return r <= e && s >= t;
12
12
  }
13
- let mt$2 = class mt {
13
+ let mt$1 = class mt {
14
14
  constructor(s = 1 / 0, t = 1 / 0, e = -1 / 0, n = -1 / 0) {
15
15
  q$2(this, "xMin");
16
16
  q$2(this, "yMin");
@@ -68,8 +68,8 @@ let mt$2 = class mt {
68
68
  );
69
69
  }
70
70
  };
71
- function ce(r) {
72
- return r.reduce((s, t) => s.addPoint(t), new mt$2());
71
+ function ce$1(r) {
72
+ return r.reduce((s, t) => s.addPoint(t), new mt$1());
73
73
  }
74
74
  const ye = (r, s = 1e-9) => {
75
75
  let t = r;
@@ -85,7 +85,7 @@ function Te(r, s = 1e-9) {
85
85
  ).values()
86
86
  );
87
87
  }
88
- const fe = Math.PI / 180, Ue = 180 / Math.PI, Z$1 = (r) => `[${r[0]}, ${r[1]}]`, Y$1 = ([r, s], [t, e], n = 1e-9) => Math.abs(r - t) <= n && Math.abs(s - e) <= n, it$3 = ([r, s], [t, e]) => [r + t, s + e], Q$2 = ([r, s], [t, e]) => [r - t, s - e], It$2 = ([r, s]) => r * r + s * s, an$1 = ([r, s]) => Math.sqrt(It$2([r, s])), nt$2 = ([r, s], t) => [r * t, s * t], Rt$1 = ([r, s], [t, e] = [0, 0]) => (r - t) ** 2 + (s - e) ** 2, J$2 = (r, s = [0, 0]) => Math.sqrt(Rt$1(r, s));
88
+ const fe$1 = Math.PI / 180, Ue = 180 / Math.PI, Z$1 = (r) => `[${r[0]}, ${r[1]}]`, Y$1 = ([r, s], [t, e], n = 1e-9) => Math.abs(r - t) <= n && Math.abs(s - e) <= n, it$3 = ([r, s], [t, e]) => [r + t, s + e], Q$2 = ([r, s], [t, e]) => [r - t, s - e], It$2 = ([r, s]) => r * r + s * s, an$1 = ([r, s]) => Math.sqrt(It$2([r, s])), nt$2 = ([r, s], t) => [r * t, s * t], Rt$1 = ([r, s], [t, e] = [0, 0]) => (r - t) ** 2 + (s - e) ** 2, J$2 = (r, s = [0, 0]) => Math.sqrt(Rt$1(r, s));
89
89
  function St$2([r, s], [t, e]) {
90
90
  return r * e - s * t;
91
91
  }
@@ -117,7 +117,7 @@ function Ie(r, s, t = 1e-9) {
117
117
  function tt$2(r) {
118
118
  return [-r[1], r[0]];
119
119
  }
120
- function Qt(r) {
120
+ function Qt$1(r) {
121
121
  return [r[1], -r[0]];
122
122
  }
123
123
  function Qe(r, s, t) {
@@ -226,7 +226,7 @@ class Ze {
226
226
  }
227
227
  rotate(s, t) {
228
228
  const e = new et$3().rotate(
229
- s * fe,
229
+ s * fe$1,
230
230
  t
231
231
  );
232
232
  return this.transform(e);
@@ -310,7 +310,7 @@ let at$2 = class at extends xt$1 {
310
310
  return new at(this.lastPoint, this.firstPoint);
311
311
  }
312
312
  get boundingBox() {
313
- return this._boundingBox === null && (this._boundingBox = new mt$2(
313
+ return this._boundingBox === null && (this._boundingBox = new mt$1(
314
314
  Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,
315
315
  Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,
316
316
  Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,
@@ -419,7 +419,7 @@ function cn$1(r, s, t = !1, e) {
419
419
  const { intersectionParam1: i, intersectionParam2: o } = n;
420
420
  return !r.isValidParameter(i) || !s.isValidParameter(o) ? null : r.paramPoint(i);
421
421
  }
422
- const Ot = (r, s) => {
422
+ const Ot$1 = (r, s) => {
423
423
  const t = Q$2(r, s);
424
424
  return We(t);
425
425
  };
@@ -488,7 +488,7 @@ let ct$2 = class ct extends xt$1 {
488
488
  );
489
489
  }
490
490
  pointToParam(t) {
491
- const [e, n] = Ot(t, this.center);
491
+ const [e, n] = Ot$1(t, this.center);
492
492
  if (Math.abs(e - this.radius) > this.precision)
493
493
  throw new Error(
494
494
  `Point ${Z$1(t)} is not on segment ${this.repr}`
@@ -548,7 +548,7 @@ let ct$2 = class ct extends xt$1 {
548
548
  get boundingBox() {
549
549
  if (this._boundingBox === null) {
550
550
  const t = this.radius + this.precision, e = (n) => this.isValidParameter(this.angleToParam(n));
551
- this._boundingBox = new mt$2(
551
+ this._boundingBox = new mt$1(
552
552
  e(Math.PI) ? this.center[0] - t : Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,
553
553
  e(Math.PI * 1.5) ? this.center[1] - t : Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,
554
554
  e(0) ? this.center[0] + t : Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,
@@ -558,7 +558,7 @@ let ct$2 = class ct extends xt$1 {
558
558
  return this._boundingBox;
559
559
  }
560
560
  distanceFrom(t) {
561
- const [e, n] = Ot(t, this.center);
561
+ const [e, n] = Ot$1(t, this.center);
562
562
  return this.isValidParameter(this.angleToParam(n)) ? Math.abs(e - this.radius) : Math.sqrt(
563
563
  Math.min(
564
564
  Rt$1(t, this.firstPoint),
@@ -569,7 +569,7 @@ let ct$2 = class ct extends xt$1 {
569
569
  isOnSegment(t) {
570
570
  if (Y$1(t, this.firstPoint) || Y$1(t, this.lastPoint))
571
571
  return !0;
572
- const [e, n] = Ot(t, this.center);
572
+ const [e, n] = Ot$1(t, this.center);
573
573
  if (Math.abs(e - this.radius) > this.precision) return !1;
574
574
  const i = this.angleToParam(n);
575
575
  return this.isValidParameter(i);
@@ -579,22 +579,22 @@ let ct$2 = class ct extends xt$1 {
579
579
  return this.clockwise ? [-i, -o] : [i, o];
580
580
  }
581
581
  tangentAt(t) {
582
- const [e, n] = Ot(t, this.center);
582
+ const [e, n] = Ot$1(t, this.center);
583
583
  if (Math.abs(e - this.radius) > this.precision)
584
584
  throw new Error("Point is not on the arc");
585
585
  const i = this.angleToParam(n);
586
586
  if (!this.isValidParameter(i))
587
587
  throw new Error("Point is not on the arc");
588
588
  const o = Tt(1, n);
589
- return (this.clockwise ? Qt : tt$2)(H$1(o));
589
+ return (this.clockwise ? Qt$1 : tt$2)(H$1(o));
590
590
  }
591
591
  get tangentAtFirstPoint() {
592
592
  const t = Tt(1, this.firstAngle);
593
- return (this.clockwise ? Qt : tt$2)(H$1(t));
593
+ return (this.clockwise ? Qt$1 : tt$2)(H$1(t));
594
594
  }
595
595
  get tangentAtLastPoint() {
596
596
  const t = Tt(1, this.lastAngle);
597
- return (this.clockwise ? Qt : tt$2)(H$1(t));
597
+ return (this.clockwise ? Qt$1 : tt$2)(H$1(t));
598
598
  }
599
599
  splitAt(t) {
600
600
  let e;
@@ -1304,7 +1304,7 @@ function ot$3(r, s, t) {
1304
1304
  if (s < 0 || s > e)
1305
1305
  throw new RangeError("Row index out of range");
1306
1306
  }
1307
- function lt$1(r, s, t) {
1307
+ function lt$2(r, s, t) {
1308
1308
  let e = t ? r.columns : r.columns - 1;
1309
1309
  if (s < 0 || s > e)
1310
1310
  throw new RangeError("Column index out of range");
@@ -1752,7 +1752,7 @@ let V$1 = class V {
1752
1752
  return this;
1753
1753
  }
1754
1754
  getColumn(s) {
1755
- lt$1(this, s);
1755
+ lt$2(this, s);
1756
1756
  let t = [];
1757
1757
  for (let e = 0; e < this.rows; e++)
1758
1758
  t.push(this.get(e, s));
@@ -1762,13 +1762,13 @@ let V$1 = class V {
1762
1762
  return _$3.columnVector(this.getColumn(s));
1763
1763
  }
1764
1764
  setColumn(s, t) {
1765
- lt$1(this, s), t = bt$2(this, t);
1765
+ lt$2(this, s), t = bt$2(this, t);
1766
1766
  for (let e = 0; e < this.rows; e++)
1767
1767
  this.set(e, s, t[e]);
1768
1768
  return this;
1769
1769
  }
1770
1770
  swapColumns(s, t) {
1771
- lt$1(this, s), lt$1(this, t);
1771
+ lt$2(this, s), lt$2(this, t);
1772
1772
  for (let e = 0; e < this.rows; e++) {
1773
1773
  let n = this.get(e, s);
1774
1774
  this.set(e, s, this.get(e, t)), this.set(e, t, n);
@@ -1838,7 +1838,7 @@ let V$1 = class V {
1838
1838
  return this;
1839
1839
  }
1840
1840
  mulColumn(s, t) {
1841
- lt$1(this, s);
1841
+ lt$2(this, s);
1842
1842
  for (let e = 0; e < this.rows; e++)
1843
1843
  this.set(e, s, this.get(e, s) * t);
1844
1844
  return this;
@@ -1948,7 +1948,7 @@ let V$1 = class V {
1948
1948
  return e;
1949
1949
  }
1950
1950
  maxColumn(s) {
1951
- if (lt$1(this, s), this.isEmpty())
1951
+ if (lt$2(this, s), this.isEmpty())
1952
1952
  return NaN;
1953
1953
  let t = this.get(0, s);
1954
1954
  for (let e = 1; e < this.rows; e++)
@@ -1956,14 +1956,14 @@ let V$1 = class V {
1956
1956
  return t;
1957
1957
  }
1958
1958
  maxColumnIndex(s) {
1959
- lt$1(this, s), yt$2(this);
1959
+ lt$2(this, s), yt$2(this);
1960
1960
  let t = this.get(0, s), e = [0, s];
1961
1961
  for (let n = 1; n < this.rows; n++)
1962
1962
  this.get(n, s) > t && (t = this.get(n, s), e[0] = n);
1963
1963
  return e;
1964
1964
  }
1965
1965
  minColumn(s) {
1966
- if (lt$1(this, s), this.isEmpty())
1966
+ if (lt$2(this, s), this.isEmpty())
1967
1967
  return NaN;
1968
1968
  let t = this.get(0, s);
1969
1969
  for (let e = 1; e < this.rows; e++)
@@ -1971,7 +1971,7 @@ let V$1 = class V {
1971
1971
  return t;
1972
1972
  }
1973
1973
  minColumnIndex(s) {
1974
- lt$1(this, s), yt$2(this);
1974
+ lt$2(this, s), yt$2(this);
1975
1975
  let t = this.get(0, s), e = [0, s];
1976
1976
  for (let n = 1; n < this.rows; n++)
1977
1977
  this.get(n, s) < t && (t = this.get(n, s), e[0] = n);
@@ -2426,8 +2426,8 @@ V$1.prototype.diagonal = V$1.prototype.diag;
2426
2426
  V$1.identity = V$1.eye;
2427
2427
  V$1.prototype.negate = V$1.prototype.neg;
2428
2428
  V$1.prototype.tensorProduct = V$1.prototype.kroneckerProduct;
2429
- var Ft$1, ue, dt;
2430
- let _$3 = (dt = class extends V$1 {
2429
+ var Ft$1, ue$1, dt$1;
2430
+ let _$3 = (dt$1 = class extends V$1 {
2431
2431
  constructor(t, e) {
2432
2432
  super();
2433
2433
  le$1(this, Ft$1);
@@ -2435,10 +2435,10 @@ let _$3 = (dt = class extends V$1 {
2435
2435
  * @type {Float64Array[]}
2436
2436
  */
2437
2437
  q$2(this, "data");
2438
- if (dt.isMatrix(t))
2439
- he(this, Ft$1, ue).call(this, t.rows, t.columns), dt.copy(t, this);
2438
+ if (dt$1.isMatrix(t))
2439
+ he(this, Ft$1, ue$1).call(this, t.rows, t.columns), dt$1.copy(t, this);
2440
2440
  else if (Number.isInteger(t) && t >= 0)
2441
- he(this, Ft$1, ue).call(this, t, e);
2441
+ he(this, Ft$1, ue$1).call(this, t, e);
2442
2442
  else if (st$3.isAnyArray(t)) {
2443
2443
  const n = t;
2444
2444
  if (t = n.length, e = t ? n[0].length : 0, typeof e != "number")
@@ -2472,7 +2472,7 @@ let _$3 = (dt = class extends V$1 {
2472
2472
  return e === void 0 && (e = t, t = this.rows), ot$3(this, t, !0), e = Float64Array.from(Pt$2(this, e)), this.data.splice(t, 0, e), this.rows += 1, this;
2473
2473
  }
2474
2474
  removeColumn(t) {
2475
- lt$1(this, t);
2475
+ lt$2(this, t);
2476
2476
  for (let e = 0; e < this.rows; e++) {
2477
2477
  const n = new Float64Array(this.columns - 1);
2478
2478
  for (let i = 0; i < t; i++)
@@ -2484,7 +2484,7 @@ let _$3 = (dt = class extends V$1 {
2484
2484
  return this.columns -= 1, this;
2485
2485
  }
2486
2486
  addColumn(t, e) {
2487
- typeof e > "u" && (e = t, t = this.columns), lt$1(this, t, !0), e = bt$2(this, e);
2487
+ typeof e > "u" && (e = t, t = this.columns), lt$2(this, t, !0), e = bt$2(this, e);
2488
2488
  for (let n = 0; n < this.rows; n++) {
2489
2489
  const i = new Float64Array(this.columns + 1);
2490
2490
  let o = 0;
@@ -2501,14 +2501,14 @@ let _$3 = (dt = class extends V$1 {
2501
2501
  * @param {number} nRows
2502
2502
  * @param {number} nColumns
2503
2503
  */
2504
- ue = function(t, e) {
2504
+ ue$1 = function(t, e) {
2505
2505
  if (this.data = [], Number.isInteger(e) && e >= 0)
2506
2506
  for (let n = 0; n < t; n++)
2507
2507
  this.data.push(new Float64Array(e));
2508
2508
  else
2509
2509
  throw new TypeError("nColumns must be a positive integer");
2510
2510
  this.rows = t, this.columns = e;
2511
- }, dt);
2511
+ }, dt$1);
2512
2512
  cs(V$1, _$3);
2513
2513
  var K$2;
2514
2514
  const Jt = class Jt extends V$1 {
@@ -2755,7 +2755,7 @@ let ft$2 = class ft extends V$1 {
2755
2755
  };
2756
2756
  class Cs extends ft$2 {
2757
2757
  constructor(s, t) {
2758
- lt$1(s, t), super(s, s.rows, 1), this.column = t;
2758
+ lt$2(s, t), super(s, s.rows, 1), this.column = t;
2759
2759
  }
2760
2760
  set(s, t, e) {
2761
2761
  return this.matrix.set(s, this.column, e), this;
@@ -2983,7 +2983,7 @@ let ee$1 = class ee {
2983
2983
  return Array.from(this.pivotVector);
2984
2984
  }
2985
2985
  };
2986
- function ut$1(r, s) {
2986
+ function ut(r, s) {
2987
2987
  let t = 0;
2988
2988
  return Math.abs(r) > Math.abs(s) ? (t = s / r, Math.abs(r) * Math.sqrt(1 + t * t)) : s !== 0 ? (t = r / s, Math.abs(s) * Math.sqrt(1 + t * t)) : 0;
2989
2989
  }
@@ -2994,7 +2994,7 @@ class pe {
2994
2994
  for (h = 0; h < n; h++) {
2995
2995
  let u = 0;
2996
2996
  for (o = h; o < e; o++)
2997
- u = ut$1(u, t.get(o, h));
2997
+ u = ut(u, t.get(o, h));
2998
2998
  if (u !== 0) {
2999
2999
  for (t.get(h, h) < 0 && (u = -u), o = h; o < e; o++)
3000
3000
  t.set(o, h, t.get(o, h) / u);
@@ -3093,7 +3093,7 @@ let vt$2 = class vt {
3093
3093
  if (m < R) {
3094
3094
  w[m] = 0;
3095
3095
  for (let b = m; b < e; b++)
3096
- w[m] = ut$1(w[m], c.get(b, m));
3096
+ w[m] = ut(w[m], c.get(b, m));
3097
3097
  if (w[m] !== 0) {
3098
3098
  c.get(m, m) < 0 && (w[m] = -w[m]);
3099
3099
  for (let b = m; b < e; b++)
@@ -3119,7 +3119,7 @@ let vt$2 = class vt {
3119
3119
  if (m < v) {
3120
3120
  f[m] = 0;
3121
3121
  for (let b = m + 1; b < n; b++)
3122
- f[m] = ut$1(f[m], f[b]);
3122
+ f[m] = ut(f[m], f[b]);
3123
3123
  if (f[m] !== 0) {
3124
3124
  f[m + 1] < 0 && (f[m] = 0 - f[m]);
3125
3125
  for (let b = m + 1; b < n; b++)
@@ -3214,7 +3214,7 @@ let vt$2 = class vt {
3214
3214
  let j = f[S - 2];
3215
3215
  f[S - 2] = 0;
3216
3216
  for (let y = S - 2; y >= m; y--) {
3217
- let C = ut$1(w[y], j), F = w[y] / C, I = j / C;
3217
+ let C = ut(w[y], j), F = w[y] / C, I = j / C;
3218
3218
  if (w[y] = C, y !== m && (j = -I * f[y - 1], f[y - 1] = F * f[y - 1]), a)
3219
3219
  for (let B = 0; B < n; B++)
3220
3220
  C = F * P.get(B, y) + I * P.get(B, S - 1), P.set(B, S - 1, -I * P.get(B, y) + F * P.get(B, S - 1)), P.set(B, y, C);
@@ -3225,7 +3225,7 @@ let vt$2 = class vt {
3225
3225
  let j = f[m - 1];
3226
3226
  f[m - 1] = 0;
3227
3227
  for (let y = m; y < S; y++) {
3228
- let C = ut$1(w[y], j), F = w[y] / C, I = j / C;
3228
+ let C = ut(w[y], j), F = w[y] / C, I = j / C;
3229
3229
  if (w[y] = C, j = -I * f[y], f[y] = F * f[y], h)
3230
3230
  for (let B = 0; B < e; B++)
3231
3231
  C = F * p.get(B, y) + I * p.get(B, m - 1), p.set(B, m - 1, -I * p.get(B, y) + F * p.get(B, m - 1)), p.set(B, y, C);
@@ -3244,13 +3244,13 @@ let vt$2 = class vt {
3244
3244
  (x !== 0 || N !== 0) && (x < 0 ? A = 0 - Math.sqrt(x * x + N) : A = Math.sqrt(x * x + N), A = N / (x + A));
3245
3245
  let O = (I + y) * (I - y) + A, U = I * B;
3246
3246
  for (let T = m; T < S - 1; T++) {
3247
- let z = ut$1(O, U);
3247
+ let z = ut(O, U);
3248
3248
  z === 0 && (z = Number.MIN_VALUE);
3249
3249
  let X = O / z, G = U / z;
3250
3250
  if (T !== m && (f[T - 1] = z), O = X * w[T] + G * f[T], f[T] = X * f[T] - G * w[T], U = G * w[T + 1], w[T + 1] = X * w[T + 1], a)
3251
3251
  for (let W = 0; W < n; W++)
3252
3252
  z = X * P.get(W, T) + G * P.get(W, T + 1), P.set(W, T + 1, -G * P.get(W, T) + X * P.get(W, T + 1)), P.set(W, T, z);
3253
- if (z = ut$1(O, U), z === 0 && (z = Number.MIN_VALUE), X = O / z, G = U / z, w[T] = z, O = X * f[T] + G * w[T + 1], w[T + 1] = -G * f[T] + X * w[T + 1], U = G * f[T + 1], f[T + 1] = X * f[T + 1], h && T < e - 1)
3253
+ if (z = ut(O, U), z === 0 && (z = Number.MIN_VALUE), X = O / z, G = U / z, w[T] = z, O = X * f[T] + G * w[T + 1], w[T + 1] = -G * f[T] + X * w[T + 1], U = G * f[T + 1], f[T + 1] = X * f[T + 1], h && T < e - 1)
3254
3254
  for (let W = 0; W < e; W++)
3255
3255
  z = X * p.get(W, T) + G * p.get(W, T + 1), p.set(W, T + 1, -G * p.get(W, T) + X * p.get(W, T + 1)), p.set(W, T, z);
3256
3256
  }
@@ -3532,10 +3532,10 @@ function Gs(r, s, t, e) {
3532
3532
  u++;
3533
3533
  if (u > a)
3534
3534
  do {
3535
- for (n = t[a], c = (t[a + 1] - n) / (2 * s[a]), g = ut$1(c, 1), c < 0 && (g = -g), t[a] = s[a] / (c + g), t[a + 1] = s[a] * (c + g), d = t[a + 1], i = n - t[a], o = a + 2; o < r; o++)
3535
+ for (n = t[a], c = (t[a + 1] - n) / (2 * s[a]), g = ut(c, 1), c < 0 && (g = -g), t[a] = s[a] / (c + g), t[a + 1] = s[a] * (c + g), d = t[a + 1], i = n - t[a], o = a + 2; o < r; o++)
3536
3536
  t[o] -= i;
3537
3537
  for (R = R + i, c = t[u], w = 1, p = w, P = w, f = s[a + 1], M = 0, E = 0, o = u - 1; o >= a; o--)
3538
- for (P = p, p = w, E = M, n = w * s[o], i = w * c, g = ut$1(c, s[o]), s[o + 1] = M * g, M = s[o] / g, w = c / g, c = w * t[o] - M * n, t[o + 1] = i + M * (w * n + M * t[o]), h = 0; h < r; h++)
3538
+ for (P = p, p = w, E = M, n = w * s[o], i = w * c, g = ut(c, s[o]), s[o + 1] = M * g, M = s[o] / g, w = c / g, c = w * t[o] - M * n, t[o + 1] = i + M * (w * n + M * t[o]), h = 0; h < r; h++)
3539
3539
  i = e.get(h, o + 1), e.set(h, o + 1, M * e.get(h, o) + w * i), e.set(h, o, w * e.get(h, o) - M * i);
3540
3540
  c = -M * E * P * f * s[a] / d, s[a] = M * c, t[a] = w * c;
3541
3541
  } while (Math.abs(s[a]) > L * v);
@@ -3809,7 +3809,7 @@ $.solve = Ve;
3809
3809
  $.wrap = Ls;
3810
3810
  const Ks = Js, Hs = De;
3811
3811
  Re.Matrix && Re.Matrix;
3812
- function qt$1(r, s, t) {
3812
+ function qt(r, s, t) {
3813
3813
  const e = r / t, n = s / t;
3814
3814
  if (!(isFinite(e) && isFinite(n))) {
3815
3815
  const h = -r / s;
@@ -3831,7 +3831,7 @@ function qt$1(r, s, t) {
3831
3831
  function ze(r, s, t, e) {
3832
3832
  const n = t / (3 * e), i = s / (3 * e), o = r / e;
3833
3833
  if (!(isFinite(o) && isFinite(i) && isFinite(n)))
3834
- return qt$1(r, s, t);
3834
+ return qt(r, s, t);
3835
3835
  const l = -n * n + i, h = -i * n + o, a = n * o - i * i, u = 4 * l * a - h * h, c = -2 * n * l + h;
3836
3836
  if (u < 0) {
3837
3837
  const g = Math.sqrt(-0.25 * u), d = -0.5 * c;
@@ -3870,18 +3870,18 @@ function gt$1(r, s) {
3870
3870
  return s == 0 ? Math.abs(r) : Math.abs((r - s) / s);
3871
3871
  }
3872
3872
  function ve(r, s, t, e, n) {
3873
- const i = tn$1(r, s, t, e, n);
3873
+ const i = tn(r, s, t, e, n);
3874
3874
  if (i !== null && i.length == 4) {
3875
3875
  let o = [];
3876
3876
  for (let l = 0; l < 2; l++) {
3877
3877
  const h = i[l * 2], a = i[l * 2 + 1];
3878
- o = o.concat(qt$1(a, h, 1));
3878
+ o = o.concat(qt(a, h, 1));
3879
3879
  }
3880
3880
  return o;
3881
3881
  }
3882
3882
  return null;
3883
3883
  }
3884
- function tn$1(r, s, t, e, n) {
3884
+ function tn(r, s, t, e, n) {
3885
3885
  function i(x, N, A, O) {
3886
3886
  const U = gt$1(x + A, r), T = gt$1(N + x * A + O, s), z = gt$1(N * A + x * O, t);
3887
3887
  return U + T + z;
@@ -3899,7 +3899,7 @@ function tn$1(r, s, t, e, n) {
3899
3899
  d = a * c - 4 * g - 1 / 3 * u * u, w = (a * c + 8 * g - 2 / 9 * u * u) * (1 / 3) * u - c * c - a * a * g;
3900
3900
  if (!isFinite(d) && isFinite(w))
3901
3901
  return null;
3902
- let P = en(d, w);
3902
+ let P = en$1(d, w);
3903
3903
  n && (P *= p);
3904
3904
  const f = r * 0.5, M = 1 / 6 * s + 0.5 * P, E = t - r * M, R = 2 / 3 * s - P - f * f, v = 0.5 * E / R, L = 2 * (e - M * M) / E, S = 0.5 * E / L;
3905
3905
  let k = 0, D = 0, m = 0;
@@ -3947,7 +3947,7 @@ function tn$1(r, s, t, e, n) {
3947
3947
  }
3948
3948
  return [y, C, F, I];
3949
3949
  }
3950
- function en(r, s) {
3950
+ function en$1(r, s) {
3951
3951
  const t = -0.3333333333333333 * r, e = 0.5 * s;
3952
3952
  let n, i = null;
3953
3953
  if ((Math.abs(t) >= 1e102 || Math.abs(e) >= 1e164) && (Math.abs(t) < Math.abs(e) ? i = 1 - t * (t / e) * (t / e) : i = Math.sign(t) * (e / t * (e / t) / t - 1)), i !== null && e == 0)
@@ -4002,9 +4002,9 @@ function rn$1(r) {
4002
4002
  s.push([r[t], r[t + 1]]);
4003
4003
  return s;
4004
4004
  }
4005
- function de(r, s) {
4005
+ function de$1(r, s) {
4006
4006
  const t = rn$1(r).map(([e, n]) => nn$1(e, n, s));
4007
- return r.length === 2 ? [t] : [...de(t, s), t];
4007
+ return r.length === 2 ? [t] : [...de$1(t, s), t];
4008
4008
  }
4009
4009
  let Et$1 = class Et extends xt$1 {
4010
4010
  constructor(t, e, n, i) {
@@ -4026,7 +4026,7 @@ let Et$1 = class Et extends xt$1 {
4026
4026
  this.lastControlPoint[t],
4027
4027
  this.lastPoint[t]
4028
4028
  ], l = -e + 3 * n - 3 * i + o, h = 2 * e - 4 * n + 2 * i, a = -e + n;
4029
- return qt$1(a, h, l).filter(
4029
+ return qt(a, h, l).filter(
4030
4030
  (u) => u >= -this.precision && u <= 1 + this.precision
4031
4031
  );
4032
4032
  }
@@ -4041,10 +4041,10 @@ let Et$1 = class Et extends xt$1 {
4041
4041
  }
4042
4042
  getInflexionParameters() {
4043
4043
  const t = this.alignedCurve, [e, n] = t.firstControlPoint, [i, o] = t.lastControlPoint, [l, h] = t.lastPoint, a = i * n, u = l * n, c = e * o, g = l * o, d = -3 * a + 2 * u + 3 * c - g, w = 3 * a - u - 3 * c, p = c - a;
4044
- return qt$1(p, w, d).filter((P) => P >= 0 && P <= 1);
4044
+ return qt(p, w, d).filter((P) => P >= 0 && P <= 1);
4045
4045
  }
4046
4046
  get boundingBox() {
4047
- return this._boundingBox === null && (this._boundingBox = ce([
4047
+ return this._boundingBox === null && (this._boundingBox = ce$1([
4048
4048
  this.firstPoint,
4049
4049
  ...this.getParametersOfExtrema().map((t) => this.paramPoint(t)),
4050
4050
  this.lastPoint
@@ -4132,7 +4132,7 @@ let Et$1 = class Et extends xt$1 {
4132
4132
  return [];
4133
4133
  let h = !1;
4134
4134
  o > 1 - this.precision && (h = !0);
4135
- const a = (o - i.originalParam) / (1 - i.originalParam), u = de(
4135
+ const a = (o - i.originalParam) / (1 - i.originalParam), u = de$1(
4136
4136
  [
4137
4137
  i.p0,
4138
4138
  i.p1,
@@ -4243,7 +4243,7 @@ let jt$1 = class jt extends xt$1 {
4243
4243
  this.center = n;
4244
4244
  const c = i >= o;
4245
4245
  this.majorRadius = c ? i : o, this.minorRadius = c ? o : i;
4246
- const g = u === "deg" ? l * fe : l;
4246
+ const g = u === "deg" ? l * fe$1 : l;
4247
4247
  if (this.tiltAngle = wt$2(
4248
4248
  c ? g : g + Math.PI / 2
4249
4249
  ), this.clockwise = h, !a) {
@@ -4319,7 +4319,7 @@ let jt$1 = class jt extends xt$1 {
4319
4319
  this.lastPoint,
4320
4320
  ...t
4321
4321
  ];
4322
- this._boundingBox = ce(e).grow(this.precision);
4322
+ this._boundingBox = ce$1(e).grow(this.precision);
4323
4323
  }
4324
4324
  return this._boundingBox;
4325
4325
  }
@@ -4440,7 +4440,7 @@ let jt$1 = class jt extends xt$1 {
4440
4440
  }
4441
4441
  normalAt(t) {
4442
4442
  const e = this.tangentAt(t);
4443
- return this.clockwise ? tt$2(e) : Qt(e);
4443
+ return this.clockwise ? tt$2(e) : Qt$1(e);
4444
4444
  }
4445
4445
  gradientAt(t) {
4446
4446
  const e = this.firstAngle + t * this.deltaAngle * (this.clockwise ? -1 : 1), n = -this.majorRadius * this.deltaAngle * Math.sin(e), i = this.minorRadius * this.deltaAngle * Math.cos(e), o = this.clockwise ? [-n, -i] : [n, i];
@@ -4500,13 +4500,13 @@ let jt$1 = class jt extends xt$1 {
4500
4500
  });
4501
4501
  }
4502
4502
  };
4503
- function pn$2(r, s, t, e, n, i, o) {
4503
+ function pn$1(r, s, t, e, n, i, o) {
4504
4504
  const { center: l, rx: h, ry: a } = on$1(
4505
4505
  r,
4506
4506
  s,
4507
4507
  t,
4508
4508
  e,
4509
- n * fe,
4509
+ n * fe$1,
4510
4510
  !i,
4511
4511
  o
4512
4512
  );
@@ -4570,7 +4570,7 @@ let _t$1 = class _t extends xt$1 {
4570
4570
  );
4571
4571
  }
4572
4572
  get boundingBox() {
4573
- return this._boundingBox === null && (this._boundingBox = ce([
4573
+ return this._boundingBox === null && (this._boundingBox = ce$1([
4574
4574
  this.firstPoint,
4575
4575
  // There is either one or zero extrema in each direction
4576
4576
  ...this.getParametersOfExtrema().map((t) => this.paramPoint(t)),
@@ -4661,7 +4661,7 @@ let _t$1 = class _t extends xt$1 {
4661
4661
  return [];
4662
4662
  let h = !1;
4663
4663
  o > 1 - this.precision && (h = !0);
4664
- const a = (o - i.originalParam) / (1 - i.originalParam), u = de(
4664
+ const a = (o - i.originalParam) / (1 - i.originalParam), u = de$1(
4665
4665
  [i.p0, i.p1, this.lastPoint],
4666
4666
  h ? 1 : a
4667
4667
  ), c = h ? this.lastPoint : (e == null ? void 0 : e.get(o)) ?? u[0][0], g = u[1][0], d = u[1][1], w = new _t(
@@ -4720,7 +4720,7 @@ let _t$1 = class _t extends xt$1 {
4720
4720
  }
4721
4721
  paramsAtY(t) {
4722
4722
  const [e, n, i] = this.polynomialCoefficients[1];
4723
- return qt$1(e - t, n, i).filter(
4723
+ return qt(e - t, n, i).filter(
4724
4724
  (o) => o >= -this.precision && o <= 1 + this.precision
4725
4725
  );
4726
4726
  }
@@ -4735,33 +4735,33 @@ let _t$1 = class _t extends xt$1 {
4735
4735
  }
4736
4736
  };
4737
4737
 
4738
- var tn = Object.defineProperty;
4739
- var nn = (t, n, e) => n in t ? tn(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
4740
- var C = (t, n, e) => nn(t, typeof n != "symbol" ? n + "" : n, e);
4741
- function pn$1(t, n) {
4738
+ var nn = Object.defineProperty;
4739
+ var en = (t, n, e) => n in t ? nn(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
4740
+ var C = (t, n, e) => en(t, typeof n != "symbol" ? n + "" : n, e);
4741
+ function dn$1(t, n) {
4742
4742
  const e = Q$2(n, t.firstPoint), s = Pe(e, t.V) / t.squareLength;
4743
4743
  return t.paramPoint(s);
4744
4744
  }
4745
- function J$1(t, n, e) {
4746
- const s = e || t.precision, i = pn$1(t, n.center), o = J$2(i, n.center);
4745
+ function K$1(t, n, e) {
4746
+ const s = e || t.precision, i = dn$1(t, n.center), o = J$2(i, n.center);
4747
4747
  if (o > n.radius + s) return [];
4748
4748
  if (Math.abs(o - n.radius) < s) {
4749
- const u = i;
4750
- return t.isOnSegment(u) && n.isOnSegment(u) ? [u] : [];
4749
+ const c = i;
4750
+ return t.isOnSegment(c) && n.isOnSegment(c) ? [c] : [];
4751
4751
  }
4752
- const r = [], l = Math.sqrt(
4752
+ const l = [], r = Math.sqrt(
4753
4753
  n.radius * n.radius - o * o
4754
- ), c = t.tangentAtFirstPoint, a = it$3(i, nt$2(c, l));
4755
- t.isOnSegment(a) && n.isOnSegment(a) && r.push(a);
4756
- const f = it$3(i, nt$2(c, -l));
4757
- return t.isOnSegment(f) && n.isOnSegment(f) && r.push(f), r;
4754
+ ), u = t.tangentAtFirstPoint, a = it$3(i, nt$2(u, r));
4755
+ t.isOnSegment(a) && n.isOnSegment(a) && l.push(a);
4756
+ const f = it$3(i, nt$2(u, -r));
4757
+ return t.isOnSegment(f) && n.isOnSegment(f) && l.push(f), l;
4758
4758
  }
4759
- const dn$1 = (t) => {
4759
+ const mn$1 = (t) => {
4760
4760
  const { firstPoint: n, lastPoint: e, center: s, clockwise: i } = t;
4761
4761
  return new ct$2(e, n, s, i, {
4762
4762
  ignoreChecks: !0
4763
4763
  });
4764
- }, mn$1 = (t, n) => {
4764
+ }, gn$1 = (t, n) => {
4765
4765
  if (t.isSame(n))
4766
4766
  return [t];
4767
4767
  const e = Te(
@@ -4777,7 +4777,7 @@ const dn$1 = (t) => {
4777
4777
  if (e.length === 0) return [];
4778
4778
  if (e.length === 1) return [];
4779
4779
  if (e.length === 2)
4780
- return t.isSame(dn$1(n)) ? [] : [new ct$2(e[0], e[1], t.center, t.clockwise)];
4780
+ return t.isSame(mn$1(n)) ? [] : [new ct$2(e[0], e[1], t.center, t.clockwise)];
4781
4781
  if (e.length === 3) {
4782
4782
  const s = Y$1(e[0], n.lastPoint) || Y$1(e[0], n.firstPoint) ? 1 : 0;
4783
4783
  return [
@@ -4795,101 +4795,101 @@ const dn$1 = (t) => {
4795
4795
  ];
4796
4796
  throw new Error("Bug in the arc arc overlap algorithm");
4797
4797
  };
4798
- function qt(t, n, e = !1, s) {
4799
- const i = s || t.precision, o = J$2(t.center, n.center), r = t.radius + n.radius;
4800
- if (o > r + i)
4798
+ function Dt(t, n, e = !1, s) {
4799
+ const i = s || t.precision, o = J$2(t.center, n.center), l = t.radius + n.radius;
4800
+ if (o > l + i)
4801
4801
  return [];
4802
- const l = Math.abs(t.radius - n.radius);
4803
- if (o < l - i)
4802
+ const r = Math.abs(t.radius - n.radius);
4803
+ if (o < r - i)
4804
4804
  return [];
4805
4805
  if (o < i)
4806
- return l > i ? [] : e ? mn$1(t, n) : [];
4807
- const c = H$1(Q$2(n.center, t.center)), a = o > r - i;
4806
+ return r > i ? [] : e ? gn$1(t, n) : [];
4807
+ const u = H$1(Q$2(n.center, t.center)), a = o > l - i;
4808
4808
  if (
4809
4809
  // circles are outside each other
4810
4810
  a || // circles are inside each other
4811
- Math.abs(o - l) < i
4811
+ Math.abs(o - r) < i
4812
4812
  ) {
4813
- const w = a || t.radius > n.radius ? 1 : -1, x = it$3(
4813
+ const g = a || t.radius > n.radius ? 1 : -1, w = it$3(
4814
4814
  t.center,
4815
- nt$2(c, w * t.radius)
4815
+ nt$2(u, g * t.radius)
4816
4816
  );
4817
- return t.isOnSegment(x) && n.isOnSegment(x) ? [x] : [];
4817
+ return t.isOnSegment(w) && n.isOnSegment(w) ? [w] : [];
4818
4818
  }
4819
- const f = t.radius * t.radius / (2 * o) - n.radius * n.radius / (2 * o) + o / 2, u = it$3(
4819
+ const f = t.radius * t.radius / (2 * o) - n.radius * n.radius / (2 * o) + o / 2, c = it$3(
4820
4820
  t.center,
4821
- nt$2(c, f)
4821
+ nt$2(u, f)
4822
4822
  ), h = Math.sqrt(
4823
4823
  t.radius * t.radius - f * f
4824
- ), p = tt$2(c), d = it$3(u, nt$2(p, h)), m = it$3(u, nt$2(p, -h)), P = [];
4825
- return t.isOnSegment(d) && n.isOnSegment(d) && P.push(d), t.isOnSegment(m) && n.isOnSegment(m) && P.push(m), P;
4824
+ ), p = tt$2(u), d = it$3(c, nt$2(p, h)), m = it$3(c, nt$2(p, -h)), x = [];
4825
+ return t.isOnSegment(d) && n.isOnSegment(d) && x.push(d), t.isOnSegment(m) && n.isOnSegment(m) && x.push(m), x;
4826
4826
  }
4827
- function et$2(t, n, e = 1e-9) {
4828
- const s = t.transform(n.ellipseReferenceFrameTransform), i = s.slope, o = s.yIntercept, r = n.majorRadius * n.majorRadius, l = n.minorRadius * n.minorRadius, c = n.majorRadius * n.minorRadius, a = s.slope * s.slope, f = s.yIntercept * s.yIntercept, u = (w) => w.map(
4829
- (x) => n.reverseEllipseReferenceFrameTransform.transform(x)
4830
- ).filter((x) => t.isOnSegment(x) && n.isOnSegment(x));
4827
+ function st$2(t, n, e = 1e-9) {
4828
+ const s = t.transform(n.ellipseReferenceFrameTransform), i = s.slope, o = s.yIntercept, l = n.majorRadius * n.majorRadius, r = n.minorRadius * n.minorRadius, u = n.majorRadius * n.minorRadius, a = s.slope * s.slope, f = s.yIntercept * s.yIntercept, c = (g) => g.map(
4829
+ (w) => n.reverseEllipseReferenceFrameTransform.transform(w)
4830
+ ).filter((w) => t.isOnSegment(w) && n.isOnSegment(w));
4831
4831
  if (!Number.isFinite(i)) {
4832
- const w = s.firstPoint[0];
4833
- if (Math.abs(w) - n.majorRadius > e) return [];
4834
- if (Math.abs(Math.abs(w) - n.majorRadius) < e)
4835
- return u([[w, 0]]);
4836
- const x = n.minorRadius * Math.sqrt(1 - w * w / r), F = [w, x], b = [w, -x];
4837
- return u([F, b]);
4838
- }
4839
- const h = r * a + l - f;
4832
+ const g = s.firstPoint[0];
4833
+ if (Math.abs(g) - n.majorRadius > e) return [];
4834
+ if (Math.abs(Math.abs(g) - n.majorRadius) < e)
4835
+ return c([[g, 0]]);
4836
+ const w = n.minorRadius * Math.sqrt(1 - g * g / l), F = [g, w], y = [g, -w];
4837
+ return c([F, y]);
4838
+ }
4839
+ const h = l * a + r - f;
4840
4840
  if (h < -e)
4841
4841
  return [];
4842
- const p = r * a + l;
4842
+ const p = l * a + r;
4843
4843
  if (Math.abs(h) < e) {
4844
- const w = -(r * i * o) / p, x = l * o / p;
4845
- return u([[w, x]]);
4844
+ const g = -(l * i * o) / p, w = r * o / p;
4845
+ return c([[g, w]]);
4846
4846
  }
4847
4847
  const d = Math.sqrt(h), m = [
4848
- -(r * i * o + c * d) / p,
4849
- (l * o - c * i * d) / p
4850
- ], P = [
4851
- -(r * i * o - c * d) / p,
4852
- (l * o + c * i * d) / p
4848
+ -(l * i * o + u * d) / p,
4849
+ (r * o - u * i * d) / p
4850
+ ], x = [
4851
+ -(l * i * o - u * d) / p,
4852
+ (r * o + u * i * d) / p
4853
4853
  ];
4854
- return u([m, P]);
4855
- }
4856
- function Dt(t, n) {
4857
- const e = Math.max(t.precision, n.precision), s = t.coefficients, i = s.x2, o = s.xy, r = s.y2, l = s.x, c = s.y, a = s.c, f = n.coefficients, u = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, P = f.c, w = {
4858
- z0: a * i * d * d + i * i * P * P - l * i * d * P + u * u * a * a - 2 * i * P * u * a - l * d * u * a + u * l * l * P,
4859
- z1: m * l * l * u - P * d * i * o - 2 * i * P * u * c - a * u * h * l + 2 * d * h * i * a + 2 * m * P * i * i + d * d * i * c - m * d * i * l - 2 * i * m * u * a - a * u * d * o + 2 * a * c * u * u - P * h * i * l - c * u * d * l + 2 * P * o * u * l,
4860
- z2: m * m * i * i + 2 * p * P * i * i - c * u * d * o + P * u * o * o - c * u * h * l - P * h * i * o - 2 * i * m * u * c + 2 * d * h * i * c - p * d * i * l - 2 * i * p * u * a + h * h * i * a + 2 * m * o * u * l + c * c * u * u - r * u * d * l - m * h * i * l + 2 * a * r * u * u - a * u * h * o + p * l * l * u + d * d * i * r - m * d * i * o - 2 * i * P * u * r,
4861
- z3: -2 * i * u * r * m + m * u * o * o + 2 * p * o * u * l - r * u * h * l + h * h * i * c - m * h * i * o - 2 * i * p * u * c - c * u * h * o - p * h * i * l + 2 * m * p * i * i + 2 * c * r * u * u - r * u * d * o + 2 * d * h * i * r - p * d * i * o,
4862
- z4: i * i * p * p - 2 * i * p * u * r + u * u * r * r - o * i * h * p - o * h * u * r + o * o * u * p + r * i * h * h
4854
+ return c([m, x]);
4855
+ }
4856
+ function Rt(t, n) {
4857
+ const e = Math.max(t.precision, n.precision), s = t.coefficients, i = s.x2, o = s.xy, l = s.y2, r = s.x, u = s.y, a = s.c, f = n.coefficients, c = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, x = f.c, g = {
4858
+ z0: a * i * d * d + i * i * x * x - r * i * d * x + c * c * a * a - 2 * i * x * c * a - r * d * c * a + c * r * r * x,
4859
+ z1: m * r * r * c - x * d * i * o - 2 * i * x * c * u - a * c * h * r + 2 * d * h * i * a + 2 * m * x * i * i + d * d * i * u - m * d * i * r - 2 * i * m * c * a - a * c * d * o + 2 * a * u * c * c - x * h * i * r - u * c * d * r + 2 * x * o * c * r,
4860
+ z2: m * m * i * i + 2 * p * x * i * i - u * c * d * o + x * c * o * o - u * c * h * r - x * h * i * o - 2 * i * m * c * u + 2 * d * h * i * u - p * d * i * r - 2 * i * p * c * a + h * h * i * a + 2 * m * o * c * r + u * u * c * c - l * c * d * r - m * h * i * r + 2 * a * l * c * c - a * c * h * o + p * r * r * c + d * d * i * l - m * d * i * o - 2 * i * x * c * l,
4861
+ z3: -2 * i * c * l * m + m * c * o * o + 2 * p * o * c * r - l * c * h * r + h * h * i * u - m * h * i * o - 2 * i * p * c * u - u * c * h * o - p * h * i * r + 2 * m * p * i * i + 2 * u * l * c * c - l * c * d * o + 2 * d * h * i * l - p * d * i * o,
4862
+ z4: i * i * p * p - 2 * i * p * c * l + c * c * l * l - o * i * h * p - o * h * c * l + o * o * c * p + l * i * h * h
4863
4863
  }, F = sn$1(
4864
- [w.z0, w.z1, w.z2, w.z3, w.z4],
4864
+ [g.z0, g.z1, g.z2, g.z3, g.z4],
4865
4865
  e
4866
- ).flatMap((b) => {
4867
- const R = i * h * b + i * d - u * o * b - u * l;
4866
+ ).flatMap((y) => {
4867
+ const R = i * h * y + i * d - c * o * y - c * r;
4868
4868
  if (R)
4869
- return [[-(i * P + i * p * b * b - u * r * b * b + i * m * b - u * c * b - u * a) / R, b]];
4870
- const T = o * b + l, L = -T / (2 * i), j = r * b * b + c * b + a, z = T * T / (4 * i * i) - j / i;
4871
- if (Math.abs(z) < e)
4872
- return [[L, b]];
4873
- if (z > 0) {
4874
- const H = Math.sqrt(z);
4875
- return [[L + H, b], [L - H, b]];
4869
+ return [[-(i * x + i * p * y * y - c * l * y * y + i * m * y - c * u * y - c * a) / R, y]];
4870
+ const T = o * y + r, L = -T / (2 * i), j = l * y * y + u * y + a, q = T * T / (4 * i * i) - j / i;
4871
+ if (Math.abs(q) < e)
4872
+ return [[L, y]];
4873
+ if (q > 0) {
4874
+ const H = Math.sqrt(q);
4875
+ return [[L + H, y], [L - H, y]];
4876
4876
  }
4877
4877
  return [];
4878
4878
  });
4879
4879
  return Te(F, e);
4880
4880
  }
4881
- function mt$1(t, n) {
4882
- return Dt(t, n).filter((s) => t.isOnSegment(s) && n.isOnSegment(s));
4881
+ function gt(t, n) {
4882
+ return Rt(t, n).filter((s) => t.isOnSegment(s) && n.isOnSegment(s));
4883
4883
  }
4884
- const gn$1 = (t) => {
4884
+ const Pn$1 = (t) => {
4885
4885
  const {
4886
4886
  firstPoint: n,
4887
4887
  lastPoint: e,
4888
4888
  center: s,
4889
4889
  majorRadius: i,
4890
4890
  minorRadius: o,
4891
- tiltAngle: r,
4892
- clockwise: l
4891
+ tiltAngle: l,
4892
+ clockwise: r
4893
4893
  } = t;
4894
4894
  return new jt$1(
4895
4895
  e,
@@ -4897,14 +4897,14 @@ const gn$1 = (t) => {
4897
4897
  s,
4898
4898
  i,
4899
4899
  o,
4900
- r,
4901
4900
  l,
4901
+ r,
4902
4902
  {
4903
4903
  ignoreChecks: !0,
4904
4904
  angleUnits: "rad"
4905
4905
  }
4906
4906
  );
4907
- }, Pn$1 = (t, n) => {
4907
+ }, wn$1 = (t, n) => {
4908
4908
  if (t.isSame(n))
4909
4909
  return [t];
4910
4910
  const e = (i, o) => new jt$1(
@@ -4929,7 +4929,7 @@ const gn$1 = (t) => {
4929
4929
  if (s.length === 0) return [];
4930
4930
  if (s.length === 1) return [];
4931
4931
  if (s.length === 2)
4932
- return t.isSame(gn$1(n)) ? [] : [e(s[0], s[1])];
4932
+ return t.isSame(Pn$1(n)) ? [] : [e(s[0], s[1])];
4933
4933
  if (s.length === 3) {
4934
4934
  const i = Y$1(s[0], n.lastPoint) || Y$1(s[0], n.firstPoint) ? 1 : 0;
4935
4935
  return [e(s[0 + i], s[1 + i])];
@@ -4937,38 +4937,38 @@ const gn$1 = (t) => {
4937
4937
  return [e(s[0], s[1]), e(s[2], s[3])];
4938
4938
  throw new Error("Bug in the ellipse arc ellipse arc overlap algorithm");
4939
4939
  };
4940
- function wn$1(t, n, e = !1) {
4940
+ function xn$1(t, n, e = !1) {
4941
4941
  const s = Math.max(t.precision, n.precision);
4942
- return Y$1(t.center, n.center) && Math.abs(t.majorRadius - n.majorRadius) < s && Math.abs(t.minorRadius - n.minorRadius) < s && (Math.abs(t.tiltAngle - n.tiltAngle) < s || Math.abs(Math.abs(t.tiltAngle - n.tiltAngle) - Math.PI) < s) ? e ? Pn$1(t, n) : [] : Dt(t, n).filter((r) => t.isOnSegment(r) && n.isOnSegment(r));
4942
+ return Y$1(t.center, n.center) && Math.abs(t.majorRadius - n.majorRadius) < s && Math.abs(t.minorRadius - n.minorRadius) < s && (Math.abs(t.tiltAngle - n.tiltAngle) < s || Math.abs(Math.abs(t.tiltAngle - n.tiltAngle) - Math.PI) < s) ? e ? wn$1(t, n) : [] : Rt(t, n).filter((l) => t.isOnSegment(l) && n.isOnSegment(l));
4943
4943
  }
4944
- function gt(t, n) {
4945
- const [e, s] = t.firstPoint, [i, o] = t.lastPoint, r = new et$3().translate(-e, -s).rotate(-Math.atan2(o - s, i - e)), l = r.clone().inverse(), c = n.transform(r);
4946
- return c.paramsAtY(0).map((a) => c.paramPoint(a)).map((a) => l.transform(a)).filter((a) => t.isOnSegment(a));
4944
+ function Pt$1(t, n) {
4945
+ const [e, s] = t.firstPoint, [i, o] = t.lastPoint, l = new et$3().translate(-e, -s).rotate(-Math.atan2(o - s, i - e)), r = l.clone().inverse(), u = n.transform(l);
4946
+ return u.paramsAtY(0).map((a) => u.paramPoint(a)).map((a) => r.transform(a)).filter((a) => t.isOnSegment(a));
4947
4947
  }
4948
- const xn$1 = (t, n = 1e-9) => {
4948
+ const Sn$1 = (t, n = 1e-9) => {
4949
4949
  let e = t;
4950
4950
  return Math.abs(t) < n && (e = 0), e.toFixed(-Math.log10(n));
4951
4951
  };
4952
- function Rt(t, n = 1e-9) {
4952
+ function Vt(t, n = 1e-9) {
4953
4953
  return Array.from(
4954
- new Map(t.map((e) => [xn$1(e, n), e])).values()
4954
+ new Map(t.map((e) => [Sn$1(e, n), e])).values()
4955
4955
  );
4956
4956
  }
4957
- const Sn$1 = (t, n) => {
4958
- const [[e, s, i, o], [r, l, c, a]] = n.polynomialCoefficients, f = t.coefficients, u = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, P = f.c, w = e * e, x = s * s, F = i * i, b = o * o, R = r * r, T = l * l, L = c * c, j = a * a, z = P + d * e + u * w + m * r + h * e * r + p * R, H = d * s + 2 * u * e * s + h * s * r + m * l + h * e * l + 2 * p * r * l, Qt = u * x + d * i + 2 * u * e * i + h * i * r + h * s * l + p * T + m * c + h * e * c + 2 * p * r * c, Wt = 2 * u * s * i + d * o + 2 * u * e * o + h * o * r + h * i * l + h * s * c + 2 * p * l * c + m * a + h * e * a + 2 * p * r * a, Jt = u * F + 2 * u * s * o + h * o * l + h * i * c + p * L + h * s * a + 2 * p * l * a, Kt = 2 * u * i * o + h * o * c + h * i * a + 2 * p * c * a, Zt = u * b + h * o * a + p * j;
4959
- return [z, H, Qt, Wt, Jt, Kt, Zt];
4960
- };
4961
- function Pt$1(t, n) {
4962
- const e = Math.max(t.precision, n.precision), s = Sn$1(t, n), i = sn$1(s, e).filter((o) => o >= -n.precision && o <= 1 + n.precision);
4963
- return Rt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
4964
- }
4965
4957
  const yn$1 = (t, n) => {
4966
- const [[e, s, i], [o, r, l]] = n.polynomialCoefficients, c = t.coefficients, a = c.x2, f = c.xy, u = c.y2, h = c.x, p = c.y, d = c.c, m = e * e, P = s * s, w = i * i, x = o * o, F = r * r, b = l * l, R = a * m + f * e * o + u * x + h * e + p * o + d, T = 2 * a * e * s + f * e * r + f * s * o + 2 * u * o * r + h * s + p * r, L = 2 * a * e * i + a * P + f * e * l + f * s * r + f * i * o + 2 * u * o * l + u * F + h * i + p * l, j = 2 * a * s * i + f * s * l + f * i * r + 2 * u * r * l, z = a * w + f * i * l + u * b;
4967
- return [R, T, L, j, z];
4958
+ const [[e, s, i, o], [l, r, u, a]] = n.polynomialCoefficients, f = t.coefficients, c = f.x2, h = f.xy, p = f.y2, d = f.x, m = f.y, x = f.c, g = e * e, w = s * s, F = i * i, y = o * o, R = l * l, T = r * r, L = u * u, j = a * a, q = x + d * e + c * g + m * l + h * e * l + p * R, H = d * s + 2 * c * e * s + h * s * l + m * r + h * e * r + 2 * p * l * r, Wt = c * w + d * i + 2 * c * e * i + h * i * l + h * s * r + p * T + m * u + h * e * u + 2 * p * l * u, Jt = 2 * c * s * i + d * o + 2 * c * e * o + h * o * l + h * i * r + h * s * u + 2 * p * r * u + m * a + h * e * a + 2 * p * l * a, Kt = c * F + 2 * c * s * o + h * o * r + h * i * u + p * L + h * s * a + 2 * p * r * a, Zt = 2 * c * i * o + h * o * u + h * i * a + 2 * p * u * a, tn = c * y + h * o * a + p * j;
4959
+ return [q, H, Wt, Jt, Kt, Zt, tn];
4968
4960
  };
4969
4961
  function wt$1(t, n) {
4970
- const e = Math.max(t.precision, n.precision), s = yn$1(t, n), i = wn$2(...s).filter((o) => o >= -n.precision && o <= 1 + n.precision);
4971
- return Rt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
4962
+ const e = Math.max(t.precision, n.precision), s = yn$1(t, n), i = sn$1(s, e).filter((o) => o >= -n.precision && o <= 1 + n.precision);
4963
+ return Vt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
4964
+ }
4965
+ const bn$1 = (t, n) => {
4966
+ const [[e, s, i], [o, l, r]] = n.polynomialCoefficients, u = t.coefficients, a = u.x2, f = u.xy, c = u.y2, h = u.x, p = u.y, d = u.c, m = e * e, x = s * s, g = i * i, w = o * o, F = l * l, y = r * r, R = a * m + f * e * o + c * w + h * e + p * o + d, T = 2 * a * e * s + f * e * l + f * s * o + 2 * c * o * l + h * s + p * l, L = 2 * a * e * i + a * x + f * e * r + f * s * l + f * i * o + 2 * c * o * r + c * F + h * i + p * r, j = 2 * a * s * i + f * s * r + f * i * l + 2 * c * l * r, q = a * g + f * i * r + c * y;
4967
+ return [R, T, L, j, q];
4968
+ };
4969
+ function xt(t, n) {
4970
+ const e = Math.max(t.precision, n.precision), s = bn$1(t, n), i = wn$2(...s).filter((o) => o >= -n.precision && o <= 1 + n.precision);
4971
+ return Vt(i, e).map((o) => n.paramPoint(o)).filter((o) => t.isOnSegment(o));
4972
4972
  }
4973
4973
  function E(t, { firstPoint: n, lastPoint: e }, s = 1e-9) {
4974
4974
  const i = Q$2(e, n);
@@ -4982,9 +4982,9 @@ let ct$1 = class ct {
4982
4982
  return this.positiveThickness - this.negativeThickness;
4983
4983
  }
4984
4984
  };
4985
- const bn$1 = 3 / 4, Cn$1 = 4 / 9;
4986
- function Mn$1(t) {
4987
- const n = E(t.firstControlPoint, t), e = E(t.lastControlPoint, t), s = n * e > 0 ? bn$1 : Cn$1;
4985
+ const Cn$1 = 3 / 4, Mn$1 = 4 / 9;
4986
+ function In$1(t) {
4987
+ const n = E(t.firstControlPoint, t), e = E(t.lastControlPoint, t), s = n * e > 0 ? Cn$1 : Mn$1;
4988
4988
  return new ct$1(
4989
4989
  t.firstPoint,
4990
4990
  t.lastPoint,
@@ -5001,14 +5001,14 @@ function An$1(t) {
5001
5001
  Math.max(0, n / 2)
5002
5002
  );
5003
5003
  }
5004
- function In$1(t) {
5004
+ function En(t) {
5005
5005
  if (t instanceof Et$1)
5006
- return Mn$1(t);
5006
+ return In$1(t);
5007
5007
  if (t instanceof _t$1)
5008
5008
  return An$1(t);
5009
5009
  throw new Error("Not implemented");
5010
5010
  }
5011
- function En(t) {
5011
+ function Fn(t) {
5012
5012
  const n = t.paramPoint(0.5), e = tt$2(Q$2(n, t.firstPoint)), s = it$3(n, e), i = {
5013
5013
  firstPoint: n,
5014
5014
  lastPoint: s
@@ -5026,7 +5026,7 @@ function En(t) {
5026
5026
  Math.max(...o)
5027
5027
  );
5028
5028
  }
5029
- function xt(t, n) {
5029
+ function St$1(t, n) {
5030
5030
  const e = [];
5031
5031
  for (let s = 1; s < t.length; s++) {
5032
5032
  const i = t[s];
@@ -5034,8 +5034,8 @@ function xt(t, n) {
5034
5034
  e.push(i[0]);
5035
5035
  continue;
5036
5036
  }
5037
- const o = t[s - 1], r = n - o[1], l = n - i[1];
5038
- if (r * l < 0) {
5037
+ const o = t[s - 1], l = n - o[1], r = n - i[1];
5038
+ if (l * r < 0) {
5039
5039
  e.push(
5040
5040
  o[0] + (n - o[1]) * (i[0] - o[0]) / (i[1] - o[1])
5041
5041
  );
@@ -5055,29 +5055,29 @@ class Y {
5055
5055
  return this.from === "start" ? this.to === "end" ? n : n.splitAtParameters([this.to])[0] : this.to === "end" ? n.splitAtParameters([this.from])[1] : n.splitAtParameters([this.from, this.to])[1];
5056
5056
  }
5057
5057
  }
5058
- function Fn(t, n) {
5058
+ function vn(t, n) {
5059
5059
  if (t instanceof Et$1)
5060
- return new Bn$1([
5060
+ return new kn([
5061
5061
  E(t.firstPoint, n),
5062
5062
  E(t.firstControlPoint, n),
5063
5063
  E(t.lastControlPoint, n),
5064
5064
  E(t.lastPoint, n)
5065
5065
  ]);
5066
5066
  if (t instanceof _t$1)
5067
- return new vn([
5067
+ return new Bn$1([
5068
5068
  E(t.firstPoint, n),
5069
5069
  E(t.controlPoint, n),
5070
5070
  E(t.lastPoint, n)
5071
5071
  ]);
5072
5072
  throw new Error("Not implemented");
5073
5073
  }
5074
- class vn {
5074
+ let Bn$1 = class Bn {
5075
5075
  constructor(n) {
5076
5076
  C(this, "topHull", []);
5077
5077
  C(this, "bottomHull", []);
5078
5078
  this.distances = n;
5079
- const [e, s, i] = n, o = [0, e], r = [1 / 2, s], l = [1, i], c = i - e, a = e;
5080
- s - (c * (1 / 2) + a) > 0 ? (this.topHull = [o, r, l], this.bottomHull = [o, l]) : (this.topHull = [o, l], this.bottomHull = [o, r, l]);
5079
+ const [e, s, i] = n, o = [0, e], l = [1 / 2, s], r = [1, i], u = i - e, a = e;
5080
+ s - (u * (1 / 2) + a) > 0 ? (this.topHull = [o, l, r], this.bottomHull = [o, r]) : (this.topHull = [o, r], this.bottomHull = [o, l, r]);
5081
5081
  }
5082
5082
  get startDistance() {
5083
5083
  return this.distances[0];
@@ -5085,19 +5085,19 @@ class vn {
5085
5085
  get endDistance() {
5086
5086
  return this.distances[2];
5087
5087
  }
5088
- }
5089
- let Bn$1 = class Bn {
5088
+ };
5089
+ class kn {
5090
5090
  constructor(n) {
5091
5091
  C(this, "topHull", []);
5092
5092
  C(this, "bottomHull", []);
5093
5093
  this.distances = n;
5094
- const [e, s, i, o] = n, r = [0, e], l = [1 / 3, s], c = [2 / 3, i], a = [1, o], f = o - e, u = e, h = s - (f * (1 / 3) + u), p = i - (f * (2 / 3) + u);
5094
+ const [e, s, i, o] = n, l = [0, e], r = [1 / 3, s], u = [2 / 3, i], a = [1, o], f = o - e, c = e, h = s - (f * (1 / 3) + c), p = i - (f * (2 / 3) + c);
5095
5095
  let d = null, m = null;
5096
5096
  if (h * p < 0)
5097
- d = [r, l, a], m = [r, c, a];
5097
+ d = [l, r, a], m = [l, u, a];
5098
5098
  else {
5099
- const w = h / p;
5100
- w >= 2 ? (d = [r, l, a], m = [r, a]) : w <= 0.5 ? (d = [r, c, a], m = [r, a]) : (d = [r, l, c, a], m = [r, a]);
5099
+ const g = h / p;
5100
+ g >= 2 ? (d = [l, r, a], m = [l, a]) : g <= 0.5 ? (d = [l, u, a], m = [l, a]) : (d = [l, r, u, a], m = [l, a]);
5101
5101
  }
5102
5102
  h < 0 && ([d, m] = [m, d]), this.topHull = d, this.bottomHull = m;
5103
5103
  }
@@ -5107,12 +5107,12 @@ let Bn$1 = class Bn {
5107
5107
  get endDistance() {
5108
5108
  return this.distances[3];
5109
5109
  }
5110
- };
5111
- function St$1(t, n) {
5112
- const e = Fn(n, t), s = xt(
5110
+ }
5111
+ function yt$1(t, n) {
5112
+ const e = vn(n, t), s = St$1(
5113
5113
  e.topHull,
5114
5114
  t.negativeThickness
5115
- ), i = xt(
5115
+ ), i = St$1(
5116
5116
  e.bottomHull,
5117
5117
  t.positiveThickness
5118
5118
  ), o = e.endDistance >= t.negativeThickness && e.endDistance <= t.positiveThickness;
@@ -5124,30 +5124,30 @@ function St$1(t, n) {
5124
5124
  throw new Error(
5125
5125
  "Bug in the clipping algorithm, unexpected number of crossing points"
5126
5126
  );
5127
- const r = s.length ? s : i;
5128
- return r.length === 2 ? new Y(r[0], r[1]) : o ? new Y(r[0], "end") : new Y("start", r[0]);
5127
+ const l = s.length ? s : i;
5128
+ return l.length === 2 ? new Y(l[0], l[1]) : o ? new Y(l[0], "end") : new Y("start", l[0]);
5129
5129
  }
5130
- function yt$1(t, n) {
5131
- const e = In$1(t), s = St$1(e, n);
5130
+ function bt$1(t, n) {
5131
+ const e = En(t), s = yt$1(e, n);
5132
5132
  if (!s)
5133
5133
  return null;
5134
- const i = En(t), o = St$1(
5134
+ const i = Fn(t), o = yt$1(
5135
5135
  i,
5136
5136
  n
5137
5137
  );
5138
5138
  return o ? s.size > o.size ? o.clipCurve(n) : s.clipCurve(n) : null;
5139
5139
  }
5140
5140
  const W$2 = (t) => t instanceof _t$1 ? It$2(Q$2(t.controlPoint, t.firstPoint)) + It$2(Q$2(t.controlPoint, t.lastPoint)) : It$2(Q$2(t.firstControlPoint, t.firstPoint)) + It$2(Q$2(t.lastControlPoint, t.firstControlPoint)) + It$2(Q$2(t.lastControlPoint, t.lastPoint));
5141
- function D$1(t, n, e = 1e-9, { maxIterations: s = 100 } = {}) {
5141
+ function D(t, n, e = 1e-9, { maxIterations: s = 100 } = {}) {
5142
5142
  const i = Math.max(e * e, Number.EPSILON * 10);
5143
- let o = t, r = n, l = W$2(o), c = W$2(r);
5143
+ let o = t, l = n, r = W$2(o), u = W$2(l);
5144
5144
  for (let a = 0; a < s; a++) {
5145
- const f = l > i ? yt$1(r, o) : o;
5145
+ const f = r > i ? bt$1(l, o) : o;
5146
5146
  if (!f) return [];
5147
- const u = W$2(f), h = c > i ? yt$1(f, r) : r;
5147
+ const c = W$2(f), h = u > i ? bt$1(f, l) : l;
5148
5148
  if (!h) return [];
5149
5149
  const p = W$2(h);
5150
- if (u <= i && p <= i)
5150
+ if (c <= i && p <= i)
5151
5151
  return [
5152
5152
  f.boundingBox.intersection(h.boundingBox).center
5153
5153
  ];
@@ -5155,17 +5155,17 @@ function D$1(t, n, e = 1e-9, { maxIterations: s = 100 } = {}) {
5155
5155
  return [f.firstPoint];
5156
5156
  if (Y$1(h.firstPoint, h.lastPoint) && f.isOnSegment(h.firstPoint))
5157
5157
  return [h.firstPoint];
5158
- if (u > 0.8 * l && p > 0.8 * c)
5159
- if (u / l > p / c) {
5158
+ if (c > 0.8 * r && p > 0.8 * u)
5159
+ if (c / r > p / u) {
5160
5160
  const [d, m] = f.splitAtParameters([
5161
5161
  0.5
5162
5162
  ]);
5163
5163
  return Te(
5164
5164
  [
5165
- ...D$1(d, h, e, {
5165
+ ...D(d, h, e, {
5166
5166
  maxIterations: s - a
5167
5167
  }),
5168
- ...D$1(m, h, e, {
5168
+ ...D(m, h, e, {
5169
5169
  maxIterations: s - a
5170
5170
  })
5171
5171
  ],
@@ -5177,21 +5177,21 @@ function D$1(t, n, e = 1e-9, { maxIterations: s = 100 } = {}) {
5177
5177
  ]);
5178
5178
  return Te(
5179
5179
  [
5180
- ...D$1(f, d, e, {
5180
+ ...D(f, d, e, {
5181
5181
  maxIterations: s - a
5182
5182
  }),
5183
- ...D$1(f, m, e, {
5183
+ ...D(f, m, e, {
5184
5184
  maxIterations: s - a
5185
5185
  })
5186
5186
  ],
5187
5187
  e
5188
5188
  );
5189
5189
  }
5190
- o = f, r = h, l = u, c = p;
5190
+ o = f, l = h, r = c, u = p;
5191
5191
  }
5192
5192
  throw new Error("Bézier clip: Maximum number of iterations reached");
5193
5193
  }
5194
- function kn(t, n) {
5194
+ function On$1(t, n) {
5195
5195
  const e = [];
5196
5196
  if ([
5197
5197
  [t.firstPoint, n],
@@ -5212,13 +5212,13 @@ function kn(t, n) {
5212
5212
  function _n(t, n, e = !1) {
5213
5213
  const s = Math.max(t.precision, n.precision);
5214
5214
  if (e) {
5215
- const i = kn(t, n);
5215
+ const i = On$1(t, n);
5216
5216
  if (i)
5217
5217
  return i;
5218
5218
  }
5219
- return D$1(t, n, s);
5219
+ return D(t, n, s);
5220
5220
  }
5221
- function On$1(t, n) {
5221
+ function Tn$1(t, n) {
5222
5222
  const e = [];
5223
5223
  if ([
5224
5224
  [t.firstPoint, n],
@@ -5236,16 +5236,16 @@ function On$1(t, n) {
5236
5236
  if (e.length === 4)
5237
5237
  return [t];
5238
5238
  }
5239
- function Tn$1(t, n, e = !1) {
5239
+ function Ln(t, n, e = !1) {
5240
5240
  const s = Math.max(t.precision, n.precision);
5241
5241
  if (e) {
5242
- const i = On$1(t, n);
5242
+ const i = Tn$1(t, n);
5243
5243
  if (i)
5244
5244
  return i;
5245
5245
  }
5246
- return D$1(t, n, s);
5246
+ return D(t, n, s);
5247
5247
  }
5248
- function ae(t, n, e) {
5248
+ function de(t, n, e) {
5249
5249
  if (t instanceof at$2 && n instanceof at$2) {
5250
5250
  const s = cn$1(
5251
5251
  t,
@@ -5256,14 +5256,14 @@ function ae(t, n, e) {
5256
5256
  return s === null ? [] : [s];
5257
5257
  }
5258
5258
  if (t instanceof at$2 && n instanceof ct$2)
5259
- return J$1(t, n, e);
5259
+ return K$1(t, n, e);
5260
5260
  if (t instanceof ct$2 && n instanceof at$2)
5261
- return J$1(n, t, e);
5261
+ return K$1(n, t, e);
5262
5262
  if (t instanceof ct$2 && n instanceof ct$2)
5263
- return qt(t, n, !1, e);
5263
+ return Dt(t, n, !1, e);
5264
5264
  throw new Error("Not implemented");
5265
5265
  }
5266
- function K$1(t, n, e) {
5266
+ function Z(t, n, e) {
5267
5267
  if (t instanceof at$2 && n instanceof at$2) {
5268
5268
  const s = cn$1(
5269
5269
  t,
@@ -5276,15 +5276,15 @@ function K$1(t, n, e) {
5276
5276
  if (!t.boundingBox.overlaps(n.boundingBox))
5277
5277
  return { intersections: [], overlaps: [], count: 0 };
5278
5278
  if (t instanceof at$2 && n instanceof ct$2) {
5279
- const s = J$1(t, n, e);
5279
+ const s = K$1(t, n, e);
5280
5280
  return { intersections: s, overlaps: [], count: s.length };
5281
5281
  }
5282
5282
  if (t instanceof ct$2 && n instanceof at$2) {
5283
- const s = J$1(n, t, e);
5283
+ const s = K$1(n, t, e);
5284
5284
  return { intersections: s, overlaps: [], count: s.length };
5285
5285
  }
5286
5286
  if (t instanceof ct$2 && n instanceof ct$2) {
5287
- const s = qt(
5287
+ const s = Dt(
5288
5288
  t,
5289
5289
  n,
5290
5290
  !0,
@@ -5301,7 +5301,7 @@ function K$1(t, n, e) {
5301
5301
  } : { intersections: [], overlaps: [], count: 0 };
5302
5302
  }
5303
5303
  if (t instanceof at$2 && n instanceof jt$1) {
5304
- const s = et$2(
5304
+ const s = st$2(
5305
5305
  t,
5306
5306
  n,
5307
5307
  e
@@ -5309,7 +5309,7 @@ function K$1(t, n, e) {
5309
5309
  return { intersections: s, overlaps: [], count: s.length };
5310
5310
  }
5311
5311
  if (n instanceof at$2 && t instanceof jt$1) {
5312
- const s = et$2(
5312
+ const s = st$2(
5313
5313
  n,
5314
5314
  t,
5315
5315
  e
@@ -5317,15 +5317,15 @@ function K$1(t, n, e) {
5317
5317
  return { intersections: s, overlaps: [], count: s.length };
5318
5318
  }
5319
5319
  if (t instanceof ct$2 && n instanceof jt$1) {
5320
- const s = mt$1(t, n);
5320
+ const s = gt(t, n);
5321
5321
  return { intersections: s, overlaps: [], count: s.length };
5322
5322
  }
5323
5323
  if (n instanceof ct$2 && t instanceof jt$1) {
5324
- const s = mt$1(n, t);
5324
+ const s = gt(n, t);
5325
5325
  return { intersections: s, overlaps: [], count: s.length };
5326
5326
  }
5327
5327
  if (t instanceof jt$1 && n instanceof jt$1) {
5328
- const s = wn$1(
5328
+ const s = xn$1(
5329
5329
  t,
5330
5330
  n,
5331
5331
  !0
@@ -5341,31 +5341,31 @@ function K$1(t, n, e) {
5341
5341
  } : { intersections: [], overlaps: [], count: 0 };
5342
5342
  }
5343
5343
  if (t instanceof at$2 && (n instanceof Et$1 || n instanceof _t$1)) {
5344
- const s = gt(t, n);
5344
+ const s = Pt$1(t, n);
5345
5345
  return { intersections: s, overlaps: [], count: s.length };
5346
5346
  }
5347
5347
  if (n instanceof at$2 && (t instanceof Et$1 || t instanceof _t$1)) {
5348
- const s = gt(n, t);
5348
+ const s = Pt$1(n, t);
5349
5349
  return { intersections: s, overlaps: [], count: s.length };
5350
5350
  }
5351
5351
  if ((t instanceof ct$2 || t instanceof jt$1) && n instanceof _t$1) {
5352
- const s = wt$1(t, n);
5352
+ const s = xt(t, n);
5353
5353
  return { intersections: s, overlaps: [], count: s.length };
5354
5354
  }
5355
5355
  if ((n instanceof ct$2 || n instanceof jt$1) && t instanceof _t$1) {
5356
- const s = wt$1(n, t);
5356
+ const s = xt(n, t);
5357
5357
  return { intersections: s, overlaps: [], count: s.length };
5358
5358
  }
5359
5359
  if ((t instanceof ct$2 || t instanceof jt$1) && n instanceof Et$1) {
5360
- const s = Pt$1(t, n);
5360
+ const s = wt$1(t, n);
5361
5361
  return { intersections: s, overlaps: [], count: s.length };
5362
5362
  }
5363
5363
  if ((n instanceof ct$2 || n instanceof jt$1) && t instanceof Et$1) {
5364
- const s = Pt$1(n, t);
5364
+ const s = wt$1(n, t);
5365
5365
  return { intersections: s, overlaps: [], count: s.length };
5366
5366
  }
5367
5367
  if (t instanceof _t$1 && n instanceof _t$1) {
5368
- const s = Tn$1(
5368
+ const s = Ln(
5369
5369
  t,
5370
5370
  n
5371
5371
  );
@@ -5380,7 +5380,7 @@ function K$1(t, n, e) {
5380
5380
  } : { intersections: [], overlaps: [], count: 0 };
5381
5381
  }
5382
5382
  if (t instanceof _t$1 && n instanceof Et$1 || n instanceof _t$1 && t instanceof Et$1) {
5383
- const s = D$1(t, n);
5383
+ const s = D(t, n);
5384
5384
  return { intersections: s, overlaps: [], count: s.length };
5385
5385
  }
5386
5386
  if (t instanceof Et$1 && n instanceof Et$1) {
@@ -5400,23 +5400,23 @@ function K$1(t, n, e) {
5400
5400
  }
5401
5401
  throw new Error("Not implemented");
5402
5402
  }
5403
- function Vt(t) {
5403
+ function Nt(t) {
5404
5404
  const n = [];
5405
5405
  for (let e = 0; e < t; e++)
5406
5406
  for (let s = 0; s <= e; s++)
5407
5407
  n.push([e, s]);
5408
5408
  return n;
5409
5409
  }
5410
- function* st$2(t) {
5411
- for (const [n, e] of Vt(t.length))
5410
+ function* it$2(t) {
5411
+ for (const [n, e] of Nt(t.length))
5412
5412
  n !== e && (yield [t[n], t[e]]);
5413
5413
  }
5414
- class Nt extends Ze {
5414
+ class Ut extends Ze {
5415
5415
  constructor(e, { ignoreChecks: s = !1 } = {}) {
5416
5416
  super();
5417
5417
  C(this, "segments");
5418
5418
  C(this, "_boundingBox", null);
5419
- s || Ut(e), this.segments = e;
5419
+ s || jt(e), this.segments = e;
5420
5420
  }
5421
5421
  get repr() {
5422
5422
  return this.segments.map((e) => e.repr).join(`
@@ -5441,12 +5441,12 @@ class Nt extends Ze {
5441
5441
  intersects(e) {
5442
5442
  return this.boundingBox.overlaps(e.boundingBox) ? this.segments.some(
5443
5443
  (s) => e.segments.some(
5444
- (i) => K$1(s, i).count > 0
5444
+ (i) => Z(s, i).count > 0
5445
5445
  )
5446
5446
  ) : !1;
5447
5447
  }
5448
5448
  overlappingSegments(e) {
5449
- return this.segments.flatMap((s) => e.segments.flatMap((i) => s.boundingBox.overlaps(i.boundingBox) ? K$1(s, i).overlaps : []));
5449
+ return this.segments.flatMap((s) => e.segments.flatMap((i) => s.boundingBox.overlaps(i.boundingBox) ? Z(s, i).overlaps : []));
5450
5450
  }
5451
5451
  get boundingBox() {
5452
5452
  if (this._boundingBox === null) {
@@ -5461,44 +5461,44 @@ class Nt extends Ze {
5461
5461
  return this.repr;
5462
5462
  }
5463
5463
  }
5464
- function Ln(t, n = "Stroke") {
5465
- Vt(t.length).forEach(
5464
+ function qn(t, n = "Stroke") {
5465
+ Nt(t.length).forEach(
5466
5466
  ([e, s]) => {
5467
5467
  if (e === s) return;
5468
- const i = t[e], o = t[s], r = K$1(i, o), l = Math.max(i.precision, o.precision);
5469
- if (r.count !== 0) {
5470
- if (r.count === 1 && !r.overlaps.length) {
5471
- const c = e - s, a = r.intersections[0];
5472
- if (c === 1 && Y$1(i.firstPoint, a, l) || c === -1 && Y$1(i.lastPoint, a, l) || c === t.length - 1 && Y$1(i.lastPoint, a, l) && Y$1(o.firstPoint, a, l) || -c === t.length - 1 && Y$1(i.firstPoint, a, l) && Y$1(o.lastPoint, a, l))
5468
+ const i = t[e], o = t[s], l = Z(i, o), r = Math.max(i.precision, o.precision);
5469
+ if (l.count !== 0) {
5470
+ if (l.count === 1 && !l.overlaps.length) {
5471
+ const u = e - s, a = l.intersections[0];
5472
+ if (u === 1 && Y$1(i.firstPoint, a, r) || u === -1 && Y$1(i.lastPoint, a, r) || u === t.length - 1 && Y$1(i.lastPoint, a, r) && Y$1(o.firstPoint, a, r) || -u === t.length - 1 && Y$1(i.firstPoint, a, r) && Y$1(o.lastPoint, a, r))
5473
5473
  return;
5474
5474
  }
5475
- if (!(r.count === 2 && t.length === 2 && (Y$1(
5475
+ if (!(l.count === 2 && t.length === 2 && (Y$1(
5476
5476
  i.firstPoint,
5477
- r.intersections[0],
5478
- l
5477
+ l.intersections[0],
5478
+ r
5479
5479
  ) && Y$1(
5480
5480
  i.lastPoint,
5481
- r.intersections[1],
5482
- l
5481
+ l.intersections[1],
5482
+ r
5483
5483
  ) || Y$1(
5484
5484
  i.firstPoint,
5485
- r.intersections[1],
5486
- l
5485
+ l.intersections[1],
5486
+ r
5487
5487
  ) && Y$1(
5488
5488
  i.lastPoint,
5489
- r.intersections[0],
5490
- l
5489
+ l.intersections[0],
5490
+ r
5491
5491
  ))))
5492
5492
  throw new Error(
5493
5493
  `${n} segments must not intersect, but segments ${i.info} and ${o.info} do at ${JSON.stringify(
5494
- r.intersections
5494
+ l.intersections
5495
5495
  )}`
5496
5496
  );
5497
5497
  }
5498
5498
  }
5499
5499
  );
5500
5500
  }
5501
- function Ut(t, n = "Stroke") {
5501
+ function jt(t, n = "Stroke") {
5502
5502
  if (t.length === 0)
5503
5503
  throw new Error(`${n} must have at least one segment`);
5504
5504
  Kt([t.slice(0, -1), t.slice(1)]).forEach(
@@ -5508,12 +5508,12 @@ function Ut(t, n = "Stroke") {
5508
5508
  `${n} segments must be connected, but ${e.info} and ${s.info} are not`
5509
5509
  );
5510
5510
  }
5511
- ), Ln(t, n);
5511
+ ), qn(t, n);
5512
5512
  }
5513
- function bt$1(t, n) {
5513
+ function Ct$1(t, n) {
5514
5514
  return !!(t instanceof at$2 && n instanceof at$2 && Ie(t.V, n.V) || t instanceof ct$2 && n instanceof ct$2 && Y$1(t.center, n.center) && t.radius - n.radius < t.precision);
5515
5515
  }
5516
- function Ct$1(t, n) {
5516
+ function Mt$1(t, n) {
5517
5517
  if (t instanceof at$2 && n instanceof at$2)
5518
5518
  return new at$2(t.firstPoint, n.lastPoint);
5519
5519
  if (t instanceof ct$2 && n instanceof ct$2)
@@ -5525,7 +5525,7 @@ function Ct$1(t, n) {
5525
5525
  );
5526
5526
  throw new Error("Not implemented");
5527
5527
  }
5528
- function jt(t) {
5528
+ function Ht(t) {
5529
5529
  let n = !1;
5530
5530
  const e = [];
5531
5531
  for (const s of t.segments) {
@@ -5534,19 +5534,19 @@ function jt(t) {
5534
5534
  continue;
5535
5535
  }
5536
5536
  const i = e[e.length - 1];
5537
- bt$1(i, s) ? (n = !0, e.pop(), e.push(Ct$1(i, s))) : e.push(s);
5537
+ Ct$1(i, s) ? (n = !0, e.pop(), e.push(Mt$1(i, s))) : e.push(s);
5538
5538
  }
5539
- if (Y$1(t.firstPoint, t.lastPoint) && bt$1(
5539
+ if (Y$1(t.firstPoint, t.lastPoint) && Ct$1(
5540
5540
  e[0],
5541
5541
  e[e.length - 1]
5542
5542
  )) {
5543
5543
  n = !0;
5544
5544
  const s = e.pop();
5545
- e[0] = Ct$1(s, e[0]);
5545
+ e[0] = Mt$1(s, e[0]);
5546
5546
  }
5547
5547
  return n ? e : null;
5548
5548
  }
5549
- let B$2 = class B extends Nt {
5549
+ let B$2 = class B extends Ut {
5550
5550
  constructor() {
5551
5551
  super(...arguments);
5552
5552
  C(this, "strokeType", "STRAND");
@@ -5567,7 +5567,7 @@ let B$2 = class B extends Nt {
5567
5567
  return new B([...this.segments, ...e.segments]);
5568
5568
  }
5569
5569
  simplify() {
5570
- const e = jt(this);
5570
+ const e = Ht(this);
5571
5571
  return e ? new B(e, { ignoreChecks: !0 }) : this;
5572
5572
  }
5573
5573
  transform(e) {
@@ -5593,7 +5593,7 @@ const zn$1 = (t, n) => {
5593
5593
  }
5594
5594
  return 1;
5595
5595
  };
5596
- class ut {
5596
+ let at$1 = class at {
5597
5597
  constructor(n) {
5598
5598
  C(this, "_count", 0);
5599
5599
  C(this, "segment");
@@ -5605,26 +5605,26 @@ class ut {
5605
5605
  get count() {
5606
5606
  return this._count;
5607
5607
  }
5608
- }
5609
- const qn = (t, n) => {
5608
+ };
5609
+ const Dn$1 = (t, n) => {
5610
5610
  const e = n.precision, s = Math.abs(t[1] - n.center[1]);
5611
5611
  if (s > n.radius + e) return 0;
5612
- const i = Rt$1(t, n.center), o = n.radius * n.radius, r = e * e;
5613
- if (Math.abs(i - o) < r && n.isOnSegment(t))
5612
+ const i = Rt$1(t, n.center), o = n.radius * n.radius, l = e * e;
5613
+ if (Math.abs(i - o) < l && n.isOnSegment(t))
5614
5614
  return 0;
5615
- const l = i - o > r;
5616
- if (l && n.center[0] < t[0]) return 0;
5617
- const c = Math.sqrt(
5615
+ const r = i - o > l;
5616
+ if (r && n.center[0] < t[0]) return 0;
5617
+ const u = Math.sqrt(
5618
5618
  n.radius * n.radius - s * s
5619
- ), a = new ut(n);
5620
- return a.update([n.center[0] + c, t[1]]), l && a.update([n.center[0] - c, t[1]]), a.count;
5621
- }, Dn$1 = (t, n) => {
5622
- const e = n.boundingBox.xMax + n.boundingBox.width / 2, s = new at$2(t, [e, t[1]]), i = new ut(n);
5623
- return et$2(s, n).forEach((o) => {
5619
+ ), a = new at$1(n);
5620
+ return a.update([n.center[0] + u, t[1]]), r && a.update([n.center[0] - u, t[1]]), a.count;
5621
+ }, Rn$1 = (t, n) => {
5622
+ const e = n.boundingBox.xMax + n.boundingBox.width / 2, s = new at$2(t, [e, t[1]]), i = new at$1(n);
5623
+ return st$2(s, n).forEach((o) => {
5624
5624
  i.update(o, !0);
5625
5625
  }), i.count;
5626
- }, Rn$1 = (t, n) => {
5627
- const e = new ut(n);
5626
+ }, Vn = (t, n) => {
5627
+ const e = new at$1(n);
5628
5628
  return n.paramsAtY(t[1]).map((s) => {
5629
5629
  try {
5630
5630
  return n.paramPoint(s);
@@ -5638,73 +5638,73 @@ const qn = (t, n) => {
5638
5638
  e.update(s, !0);
5639
5639
  }), e.count;
5640
5640
  };
5641
- function Vn(t, n) {
5641
+ function Nn(t, n) {
5642
5642
  if (n instanceof at$2)
5643
5643
  return zn$1(t, n);
5644
5644
  if (n instanceof ct$2)
5645
- return qn(t, n);
5646
- if (n instanceof jt$1)
5647
5645
  return Dn$1(t, n);
5648
- if (n instanceof Et$1 || n instanceof _t$1)
5646
+ if (n instanceof jt$1)
5649
5647
  return Rn$1(t, n);
5648
+ if (n instanceof Et$1 || n instanceof _t$1)
5649
+ return Vn(t, n);
5650
5650
  throw new Error("Not implemented");
5651
5651
  }
5652
- class O extends Nt {
5652
+ let _$2 = class _ extends Ut {
5653
5653
  constructor(e, { ignoreChecks: s = !1 } = {}) {
5654
5654
  super(e, { ignoreChecks: !0 });
5655
5655
  C(this, "strokeType", "LOOP");
5656
5656
  C(this, "_clockwise", null);
5657
- s || Nn(e);
5657
+ s || Un(e);
5658
5658
  }
5659
5659
  get clockwise() {
5660
5660
  if (this._clockwise === null) {
5661
5661
  const e = this.segments.flatMap((i) => i instanceof at$2 ? [i.firstPoint] : [i.firstPoint, i.paramPoint(0.5)]), s = e.map((i, o) => {
5662
- const r = e[(o + 1) % e.length];
5663
- return (r[0] - i[0]) * (r[1] + i[1]);
5662
+ const l = e[(o + 1) % e.length];
5663
+ return (l[0] - i[0]) * (l[1] + i[1]);
5664
5664
  }).reduce((i, o) => i + o, 0);
5665
5665
  this._clockwise = s > 0;
5666
5666
  }
5667
5667
  return this._clockwise;
5668
5668
  }
5669
5669
  clone() {
5670
- return new O(
5670
+ return new _(
5671
5671
  this.segments.map((e) => e.clone()),
5672
5672
  { ignoreChecks: !0 }
5673
5673
  );
5674
5674
  }
5675
5675
  reverse() {
5676
5676
  const e = this.segments.map((s) => s.reverse());
5677
- return e.reverse(), new O(e, { ignoreChecks: !0 });
5677
+ return e.reverse(), new _(e, { ignoreChecks: !0 });
5678
5678
  }
5679
5679
  transform(e) {
5680
- return new O(
5680
+ return new _(
5681
5681
  this.segments.map((s) => s.transform(e)),
5682
5682
  { ignoreChecks: !0 }
5683
5683
  );
5684
5684
  }
5685
- contains(e) {
5686
- return this.onStroke(e) || !this.boundingBox.contains(e) ? !1 : this.segments.reduce((i, o) => i + Vn(e, o), 0) % 2 === 1;
5685
+ contains(e, { strokeIsInside: s = !1 } = {}) {
5686
+ return this.onStroke(e) ? s : this.boundingBox.contains(e) ? this.segments.reduce((o, l) => o + Nn(e, l), 0) % 2 === 1 : !1;
5687
5687
  }
5688
5688
  simplify() {
5689
- const e = jt(this);
5690
- return e ? new O(e, { ignoreChecks: !0 }) : this;
5689
+ const e = Ht(this);
5690
+ return e ? new _(e, { ignoreChecks: !0 }) : this;
5691
5691
  }
5692
- }
5693
- function Nn(t) {
5694
- if (Ut(t, "Loop"), !Y$1(t[0].firstPoint, t[t.length - 1].lastPoint))
5692
+ };
5693
+ function Un(t) {
5694
+ if (jt(t, "Loop"), !Y$1(t[0].firstPoint, t[t.length - 1].lastPoint))
5695
5695
  throw new Error("Loop segment must be closed");
5696
5696
  }
5697
- const Un = [
5697
+ const jn = [
5698
5698
  at$2,
5699
5699
  ct$2,
5700
5700
  jt$1,
5701
5701
  _t$1,
5702
5702
  Et$1
5703
5703
  ];
5704
- function jn(t) {
5705
- return Un.some((n) => t instanceof n);
5704
+ function Hn(t) {
5705
+ return jn.some((n) => t instanceof n);
5706
5706
  }
5707
- function Ht(t) {
5707
+ function $t(t) {
5708
5708
  if (t instanceof at$2)
5709
5709
  return {
5710
5710
  type: t.segmentType,
@@ -5747,37 +5747,37 @@ function Ht(t) {
5747
5747
  };
5748
5748
  throw new Error("Unknown segment type");
5749
5749
  }
5750
- function it$2(t) {
5750
+ function ot$2(t) {
5751
5751
  return {
5752
5752
  type: "LOOP",
5753
- segments: t.segments.map(Ht)
5753
+ segments: t.segments.map($t)
5754
5754
  };
5755
5755
  }
5756
- function $t(t) {
5756
+ function Yt(t) {
5757
5757
  return {
5758
5758
  type: "FIGURE",
5759
- contour: it$2(t.contour),
5760
- holes: t.holes.map(it$2)
5759
+ contour: ot$2(t.contour),
5760
+ holes: t.holes.map(ot$2)
5761
5761
  };
5762
5762
  }
5763
- function Hn(t) {
5763
+ function $n$1(t) {
5764
5764
  return {
5765
5765
  type: "DIAGRAM",
5766
- figures: t.figures.map($t)
5766
+ figures: t.figures.map(Yt)
5767
5767
  };
5768
5768
  }
5769
- function Mt$1(t) {
5770
- if (t instanceof _$2)
5771
- return Hn(t);
5769
+ function It$1(t) {
5770
+ if (t instanceof O$1)
5771
+ return $n$1(t);
5772
5772
  if (t instanceof v$1)
5773
+ return Yt(t);
5774
+ if (t instanceof _$2)
5775
+ return ot$2(t);
5776
+ if (Hn(t))
5773
5777
  return $t(t);
5774
- if (t instanceof O)
5775
- return it$2(t);
5776
- if (jn(t))
5777
- return Ht(t);
5778
5778
  throw new Error("Unknown shape type");
5779
5779
  }
5780
- let $n$1 = class $n {
5780
+ class Yn {
5781
5781
  constructor() {
5782
5782
  this.ids = [], this.values = [], this.length = 0;
5783
5783
  }
@@ -5800,12 +5800,12 @@ let $n$1 = class $n {
5800
5800
  const e = this.ids[0] = this.ids[this.length], s = this.values[0] = this.values[this.length], i = this.length >> 1;
5801
5801
  let o = 0;
5802
5802
  for (; o < i; ) {
5803
- let r = (o << 1) + 1;
5804
- const l = r + 1;
5805
- let c = this.ids[r], a = this.values[r];
5806
- const f = this.values[l];
5807
- if (l < this.length && f < a && (r = l, c = this.ids[l], a = f), a >= s) break;
5808
- this.ids[o] = c, this.values[o] = a, o = r;
5803
+ let l = (o << 1) + 1;
5804
+ const r = l + 1;
5805
+ let u = this.ids[l], a = this.values[l];
5806
+ const f = this.values[r];
5807
+ if (r < this.length && f < a && (l = r, u = this.ids[r], a = f), a >= s) break;
5808
+ this.ids[o] = u, this.values[o] = a, o = l;
5809
5809
  }
5810
5810
  this.ids[o] = e, this.values[o] = s;
5811
5811
  }
@@ -5822,9 +5822,9 @@ let $n$1 = class $n {
5822
5822
  shrink() {
5823
5823
  this.ids.length = this.values.length = this.length;
5824
5824
  }
5825
- };
5826
- const At$1 = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array], nt$1 = 3;
5827
- let at$1 = class at {
5825
+ }
5826
+ const At$1 = [Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array], et$2 = 3;
5827
+ let ft$1 = class ft {
5828
5828
  /**
5829
5829
  * Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
5830
5830
  * @param {ArrayBuffer | SharedArrayBuffer} data
@@ -5840,13 +5840,13 @@ let at$1 = class at {
5840
5840
  if (s !== 251)
5841
5841
  throw new Error("Data does not appear to be in a Flatbush format.");
5842
5842
  const o = i >> 4;
5843
- if (o !== nt$1)
5844
- throw new Error(`Got v${o} data when expected v${nt$1}.`);
5845
- const r = At$1[i & 15];
5846
- if (!r)
5843
+ if (o !== et$2)
5844
+ throw new Error(`Got v${o} data when expected v${et$2}.`);
5845
+ const l = At$1[i & 15];
5846
+ if (!l)
5847
5847
  throw new Error("Unrecognized array type.");
5848
- const [l] = new Uint16Array(n, e + 2, 1), [c] = new Uint32Array(n, e + 4, 1);
5849
- return new at(c, l, r, void 0, n, e);
5848
+ const [r] = new Uint16Array(n, e + 2, 1), [u] = new Uint32Array(n, e + 4, 1);
5849
+ return new ft(u, r, l, void 0, n, e);
5850
5850
  }
5851
5851
  /**
5852
5852
  * Create a Flatbush index that will hold a given number of items.
@@ -5857,20 +5857,20 @@ let at$1 = class at {
5857
5857
  * @param {ArrayBuffer | SharedArrayBuffer} [data] (Only used internally)
5858
5858
  * @param {number} [byteOffset=0] (Only used internally)
5859
5859
  */
5860
- constructor(n, e = 16, s = Float64Array, i = ArrayBuffer, o, r = 0) {
5860
+ constructor(n, e = 16, s = Float64Array, i = ArrayBuffer, o, l = 0) {
5861
5861
  if (n === void 0) throw new Error("Missing required argument: numItems.");
5862
5862
  if (isNaN(n) || n <= 0) throw new Error(`Unexpected numItems value: ${n}.`);
5863
- this.numItems = +n, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.byteOffset = r;
5864
- let l = n, c = l;
5865
- this._levelBounds = [l * 4];
5863
+ this.numItems = +n, this.nodeSize = Math.min(Math.max(+e, 2), 65535), this.byteOffset = l;
5864
+ let r = n, u = r;
5865
+ this._levelBounds = [r * 4];
5866
5866
  do
5867
- l = Math.ceil(l / this.nodeSize), c += l, this._levelBounds.push(c * 4);
5868
- while (l !== 1);
5869
- this.ArrayType = s, this.IndexArrayType = c < 16384 ? Uint16Array : Uint32Array;
5870
- const a = At$1.indexOf(this.ArrayType), f = c * 4 * this.ArrayType.BYTES_PER_ELEMENT;
5867
+ r = Math.ceil(r / this.nodeSize), u += r, this._levelBounds.push(u * 4);
5868
+ while (r !== 1);
5869
+ this.ArrayType = s, this.IndexArrayType = u < 16384 ? Uint16Array : Uint32Array;
5870
+ const a = At$1.indexOf(this.ArrayType), f = u * 4 * this.ArrayType.BYTES_PER_ELEMENT;
5871
5871
  if (a < 0)
5872
5872
  throw new Error(`Unexpected typed array class: ${s}.`);
5873
- o && o.byteLength !== void 0 && !o.buffer ? (this.data = o, this._boxes = new this.ArrayType(this.data, r + 8, c * 4), this._indices = new this.IndexArrayType(this.data, r + 8 + f, c), this._pos = c * 4, this.minX = this._boxes[this._pos - 4], this.minY = this._boxes[this._pos - 3], this.maxX = this._boxes[this._pos - 2], this.maxY = this._boxes[this._pos - 1]) : (this.data = new i(8 + f + c * this.IndexArrayType.BYTES_PER_ELEMENT), this._boxes = new this.ArrayType(this.data, 8, c * 4), this._indices = new this.IndexArrayType(this.data, 8 + f, c), this._pos = 0, this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, new Uint8Array(this.data, 0, 2).set([251, (nt$1 << 4) + a]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = n), this._queue = new $n$1();
5873
+ o && o.byteLength !== void 0 && !o.buffer ? (this.data = o, this._boxes = new this.ArrayType(this.data, l + 8, u * 4), this._indices = new this.IndexArrayType(this.data, l + 8 + f, u), this._pos = u * 4, this.minX = this._boxes[this._pos - 4], this.minY = this._boxes[this._pos - 3], this.maxX = this._boxes[this._pos - 2], this.maxY = this._boxes[this._pos - 1]) : (this.data = new i(8 + f + u * this.IndexArrayType.BYTES_PER_ELEMENT), this._boxes = new this.ArrayType(this.data, 8, u * 4), this._indices = new this.IndexArrayType(this.data, 8 + f, u), this._pos = 0, this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0, new Uint8Array(this.data, 0, 2).set([251, (et$2 << 4) + a]), new Uint16Array(this.data, 2, 1)[0] = e, new Uint32Array(this.data, 4, 1)[0] = n), this._queue = new Yn();
5874
5874
  }
5875
5875
  /**
5876
5876
  * Add a given rectangle to the index.
@@ -5881,8 +5881,8 @@ let at$1 = class at {
5881
5881
  * @returns {number} A zero-based, incremental number that represents the newly added rectangle.
5882
5882
  */
5883
5883
  add(n, e, s = n, i = e) {
5884
- const o = this._pos >> 2, r = this._boxes;
5885
- return this._indices[o] = o, r[this._pos++] = n, r[this._pos++] = e, r[this._pos++] = s, r[this._pos++] = i, n < this.minX && (this.minX = n), e < this.minY && (this.minY = e), s > this.maxX && (this.maxX = s), i > this.maxY && (this.maxY = i), o;
5884
+ const o = this._pos >> 2, l = this._boxes;
5885
+ return this._indices[o] = o, l[this._pos++] = n, l[this._pos++] = e, l[this._pos++] = s, l[this._pos++] = i, n < this.minX && (this.minX = n), e < this.minY && (this.minY = e), s > this.maxX && (this.maxX = s), i > this.maxY && (this.maxY = i), o;
5886
5886
  }
5887
5887
  /** Perform indexing of the added rectangles. */
5888
5888
  finish() {
@@ -5894,19 +5894,19 @@ let at$1 = class at {
5894
5894
  return;
5895
5895
  }
5896
5896
  const e = this.maxX - this.minX || 1, s = this.maxY - this.minY || 1, i = new Uint32Array(this.numItems), o = 65535;
5897
- for (let r = 0, l = 0; r < this.numItems; r++) {
5898
- const c = n[l++], a = n[l++], f = n[l++], u = n[l++], h = Math.floor(o * ((c + f) / 2 - this.minX) / e), p = Math.floor(o * ((a + u) / 2 - this.minY) / s);
5899
- i[r] = Xn(h, p);
5900
- }
5901
- ot$2(i, n, this._indices, 0, this.numItems - 1, this.nodeSize);
5902
- for (let r = 0, l = 0; r < this._levelBounds.length - 1; r++) {
5903
- const c = this._levelBounds[r];
5904
- for (; l < c; ) {
5905
- const a = l;
5906
- let f = n[l++], u = n[l++], h = n[l++], p = n[l++];
5907
- for (let d = 1; d < this.nodeSize && l < c; d++)
5908
- f = Math.min(f, n[l++]), u = Math.min(u, n[l++]), h = Math.max(h, n[l++]), p = Math.max(p, n[l++]);
5909
- this._indices[this._pos >> 2] = a, n[this._pos++] = f, n[this._pos++] = u, n[this._pos++] = h, n[this._pos++] = p;
5897
+ for (let l = 0, r = 0; l < this.numItems; l++) {
5898
+ const u = n[r++], a = n[r++], f = n[r++], c = n[r++], h = Math.floor(o * ((u + f) / 2 - this.minX) / e), p = Math.floor(o * ((a + c) / 2 - this.minY) / s);
5899
+ i[l] = Gn(h, p);
5900
+ }
5901
+ rt$2(i, n, this._indices, 0, this.numItems - 1, this.nodeSize);
5902
+ for (let l = 0, r = 0; l < this._levelBounds.length - 1; l++) {
5903
+ const u = this._levelBounds[l];
5904
+ for (; r < u; ) {
5905
+ const a = r;
5906
+ let f = n[r++], c = n[r++], h = n[r++], p = n[r++];
5907
+ for (let d = 1; d < this.nodeSize && r < u; d++)
5908
+ f = Math.min(f, n[r++]), c = Math.min(c, n[r++]), h = Math.max(h, n[r++]), p = Math.max(p, n[r++]);
5909
+ this._indices[this._pos >> 2] = a, n[this._pos++] = f, n[this._pos++] = c, n[this._pos++] = h, n[this._pos++] = p;
5910
5910
  }
5911
5911
  }
5912
5912
  }
@@ -5922,18 +5922,18 @@ let at$1 = class at {
5922
5922
  search(n, e, s, i, o) {
5923
5923
  if (this._pos !== this._boxes.length)
5924
5924
  throw new Error("Data not yet indexed - call index.finish().");
5925
- let r = this._boxes.length - 4;
5926
- const l = [], c = [];
5927
- for (; r !== void 0; ) {
5928
- const a = Math.min(r + this.nodeSize * 4, Et(r, this._levelBounds));
5929
- for (let f = r; f < a; f += 4) {
5925
+ let l = this._boxes.length - 4;
5926
+ const r = [], u = [];
5927
+ for (; l !== void 0; ) {
5928
+ const a = Math.min(l + this.nodeSize * 4, Ft(l, this._levelBounds));
5929
+ for (let f = l; f < a; f += 4) {
5930
5930
  if (s < this._boxes[f] || i < this._boxes[f + 1] || n > this._boxes[f + 2] || e > this._boxes[f + 3]) continue;
5931
- const u = this._indices[f >> 2] | 0;
5932
- r >= this.numItems * 4 ? l.push(u) : (o === void 0 || o(u)) && c.push(u);
5931
+ const c = this._indices[f >> 2] | 0;
5932
+ l >= this.numItems * 4 ? r.push(c) : (o === void 0 || o(c)) && u.push(c);
5933
5933
  }
5934
- r = l.pop();
5934
+ l = r.pop();
5935
5935
  }
5936
- return c;
5936
+ return u;
5937
5937
  }
5938
5938
  /**
5939
5939
  * Search items in order of distance from the given point.
@@ -5947,25 +5947,25 @@ let at$1 = class at {
5947
5947
  neighbors(n, e, s = 1 / 0, i = 1 / 0, o) {
5948
5948
  if (this._pos !== this._boxes.length)
5949
5949
  throw new Error("Data not yet indexed - call index.finish().");
5950
- let r = this._boxes.length - 4;
5951
- const l = this._queue, c = [], a = i * i;
5952
- t: for (; r !== void 0; ) {
5953
- const f = Math.min(r + this.nodeSize * 4, Et(r, this._levelBounds));
5954
- for (let u = r; u < f; u += 4) {
5955
- const h = this._indices[u >> 2] | 0, p = It$1(n, this._boxes[u], this._boxes[u + 2]), d = It$1(e, this._boxes[u + 1], this._boxes[u + 3]), m = p * p + d * d;
5956
- m > a || (r >= this.numItems * 4 ? l.push(h << 1, m) : (o === void 0 || o(h)) && l.push((h << 1) + 1, m));
5950
+ let l = this._boxes.length - 4;
5951
+ const r = this._queue, u = [], a = i * i;
5952
+ t: for (; l !== void 0; ) {
5953
+ const f = Math.min(l + this.nodeSize * 4, Ft(l, this._levelBounds));
5954
+ for (let c = l; c < f; c += 4) {
5955
+ const h = this._indices[c >> 2] | 0, p = Et(n, this._boxes[c], this._boxes[c + 2]), d = Et(e, this._boxes[c + 1], this._boxes[c + 3]), m = p * p + d * d;
5956
+ m > a || (l >= this.numItems * 4 ? r.push(h << 1, m) : (o === void 0 || o(h)) && r.push((h << 1) + 1, m));
5957
5957
  }
5958
- for (; l.length && l.peek() & 1; )
5959
- if (l.peekValue() > a || (c.push(l.pop() >> 1), c.length === s)) break t;
5960
- r = l.length ? l.pop() >> 1 : void 0;
5958
+ for (; r.length && r.peek() & 1; )
5959
+ if (r.peekValue() > a || (u.push(r.pop() >> 1), u.length === s)) break t;
5960
+ l = r.length ? r.pop() >> 1 : void 0;
5961
5961
  }
5962
- return l.clear(), c;
5962
+ return r.clear(), u;
5963
5963
  }
5964
5964
  };
5965
- function It$1(t, n, e) {
5965
+ function Et(t, n, e) {
5966
5966
  return t < n ? n - t : t <= e ? 0 : t - e;
5967
5967
  }
5968
- function Et(t, n) {
5968
+ function Ft(t, n) {
5969
5969
  let e = 0, s = n.length - 1;
5970
5970
  for (; e < s; ) {
5971
5971
  const i = e + s >> 1;
@@ -5973,70 +5973,70 @@ function Et(t, n) {
5973
5973
  }
5974
5974
  return n[e];
5975
5975
  }
5976
- function ot$2(t, n, e, s, i, o) {
5976
+ function rt$2(t, n, e, s, i, o) {
5977
5977
  if (Math.floor(s / o) >= Math.floor(i / o)) return;
5978
- const r = t[s + i >> 1];
5979
- let l = s - 1, c = i + 1;
5978
+ const l = t[s + i >> 1];
5979
+ let r = s - 1, u = i + 1;
5980
5980
  for (; ; ) {
5981
5981
  do
5982
- l++;
5983
- while (t[l] < r);
5982
+ r++;
5983
+ while (t[r] < l);
5984
5984
  do
5985
- c--;
5986
- while (t[c] > r);
5987
- if (l >= c) break;
5988
- Yn(t, n, e, l, c);
5985
+ u--;
5986
+ while (t[u] > l);
5987
+ if (r >= u) break;
5988
+ Xn(t, n, e, r, u);
5989
5989
  }
5990
- ot$2(t, n, e, s, c, o), ot$2(t, n, e, c + 1, i, o);
5990
+ rt$2(t, n, e, s, u, o), rt$2(t, n, e, u + 1, i, o);
5991
5991
  }
5992
- function Yn(t, n, e, s, i) {
5992
+ function Xn(t, n, e, s, i) {
5993
5993
  const o = t[s];
5994
5994
  t[s] = t[i], t[i] = o;
5995
- const r = 4 * s, l = 4 * i, c = n[r], a = n[r + 1], f = n[r + 2], u = n[r + 3];
5996
- n[r] = n[l], n[r + 1] = n[l + 1], n[r + 2] = n[l + 2], n[r + 3] = n[l + 3], n[l] = c, n[l + 1] = a, n[l + 2] = f, n[l + 3] = u;
5995
+ const l = 4 * s, r = 4 * i, u = n[l], a = n[l + 1], f = n[l + 2], c = n[l + 3];
5996
+ n[l] = n[r], n[l + 1] = n[r + 1], n[l + 2] = n[r + 2], n[l + 3] = n[r + 3], n[r] = u, n[r + 1] = a, n[r + 2] = f, n[r + 3] = c;
5997
5997
  const h = e[s];
5998
5998
  e[s] = e[i], e[i] = h;
5999
5999
  }
6000
- function Xn(t, n) {
6001
- let e = t ^ n, s = 65535 ^ e, i = 65535 ^ (t | n), o = t & (n ^ 65535), r = e | s >> 1, l = e >> 1 ^ e, c = i >> 1 ^ s & o >> 1 ^ i, a = e & i >> 1 ^ o >> 1 ^ o;
6002
- e = r, s = l, i = c, o = a, r = e & e >> 2 ^ s & s >> 2, l = e & s >> 2 ^ s & (e ^ s) >> 2, c ^= e & i >> 2 ^ s & o >> 2, a ^= s & i >> 2 ^ (e ^ s) & o >> 2, e = r, s = l, i = c, o = a, r = e & e >> 4 ^ s & s >> 4, l = e & s >> 4 ^ s & (e ^ s) >> 4, c ^= e & i >> 4 ^ s & o >> 4, a ^= s & i >> 4 ^ (e ^ s) & o >> 4, e = r, s = l, i = c, o = a, c ^= e & i >> 8 ^ s & o >> 8, a ^= s & i >> 8 ^ (e ^ s) & o >> 8, e = c ^ c >> 1, s = a ^ a >> 1;
6003
- let f = t ^ n, u = s | 65535 ^ (f | e);
6004
- return f = (f | f << 8) & 16711935, f = (f | f << 4) & 252645135, f = (f | f << 2) & 858993459, f = (f | f << 1) & 1431655765, u = (u | u << 8) & 16711935, u = (u | u << 4) & 252645135, u = (u | u << 2) & 858993459, u = (u | u << 1) & 1431655765, (u << 1 | f) >>> 0;
6000
+ function Gn(t, n) {
6001
+ let e = t ^ n, s = 65535 ^ e, i = 65535 ^ (t | n), o = t & (n ^ 65535), l = e | s >> 1, r = e >> 1 ^ e, u = i >> 1 ^ s & o >> 1 ^ i, a = e & i >> 1 ^ o >> 1 ^ o;
6002
+ e = l, s = r, i = u, o = a, l = e & e >> 2 ^ s & s >> 2, r = e & s >> 2 ^ s & (e ^ s) >> 2, u ^= e & i >> 2 ^ s & o >> 2, a ^= s & i >> 2 ^ (e ^ s) & o >> 2, e = l, s = r, i = u, o = a, l = e & e >> 4 ^ s & s >> 4, r = e & s >> 4 ^ s & (e ^ s) >> 4, u ^= e & i >> 4 ^ s & o >> 4, a ^= s & i >> 4 ^ (e ^ s) & o >> 4, e = l, s = r, i = u, o = a, u ^= e & i >> 8 ^ s & o >> 8, a ^= s & i >> 8 ^ (e ^ s) & o >> 8, e = u ^ u >> 1, s = a ^ a >> 1;
6003
+ let f = t ^ n, c = s | 65535 ^ (f | e);
6004
+ return f = (f | f << 8) & 16711935, f = (f | f << 4) & 252645135, f = (f | f << 2) & 858993459, f = (f | f << 1) & 1431655765, c = (c | c << 8) & 16711935, c = (c | c << 4) & 252645135, c = (c | c << 2) & 858993459, c = (c | c << 1) & 1431655765, (c << 1 | f) >>> 0;
6005
6005
  }
6006
- function Yt(t, n = 1e-7) {
6006
+ function Xt(t, n = 1e-7) {
6007
6007
  if (t.length === 0) return [];
6008
6008
  if (t.length === 1) return [t];
6009
- const e = new at$1(t.length);
6009
+ const e = new ft$1(t.length);
6010
6010
  t.forEach((o) => {
6011
- const [r, l] = o.firstPoint;
6012
- e.add(r - n, l - n, r + n, l + n);
6011
+ const [l, r] = o.firstPoint;
6012
+ e.add(l - n, r - n, l + n, r + n);
6013
6013
  }), e.finish();
6014
6014
  const s = [], i = /* @__PURE__ */ new Set();
6015
- return t.forEach((o, r) => {
6016
- if (i.has(r)) return;
6017
- const l = [o];
6018
- let c = r;
6019
- i.add(r);
6015
+ return t.forEach((o, l) => {
6016
+ if (i.has(l)) return;
6017
+ const r = [o];
6018
+ let u = l;
6019
+ i.add(l);
6020
6020
  let a = t.length;
6021
6021
  for (; ; ) {
6022
6022
  if (a-- < 0)
6023
6023
  throw new Error("Infinite loop detected");
6024
- const f = l[l.length - 1].lastPoint, [u, h] = f, p = e.search(
6025
- u - n,
6024
+ const f = r[r.length - 1].lastPoint, [c, h] = f, p = e.search(
6025
+ c - n,
6026
6026
  h - n,
6027
- u + n,
6027
+ c + n,
6028
6028
  h + n
6029
- ), d = (x) => Math.abs((c - x) % t.length), m = p.filter((x) => !i.has(x)).map((x) => [
6030
- t[x],
6031
- x,
6032
- d(x)
6033
- ]).sort(([, , x], [, , F]) => d(x) - d(F));
6029
+ ), d = (w) => Math.abs((u - w) % t.length), m = p.filter((w) => !i.has(w)).map((w) => [
6030
+ t[w],
6031
+ w,
6032
+ d(w)
6033
+ ]).sort(([, , w], [, , F]) => d(w) - d(F));
6034
6034
  if (m.length === 0) {
6035
- s.push(l);
6035
+ s.push(r);
6036
6036
  break;
6037
6037
  }
6038
- const [P, w] = m[0];
6039
- l.push(P), i.add(w), c = w;
6038
+ const [x, g] = m[0];
6039
+ r.push(x), i.add(g), u = g;
6040
6040
  }
6041
6041
  }), s;
6042
6042
  }
@@ -6045,7 +6045,7 @@ let v$1 = class v extends Ze {
6045
6045
  super();
6046
6046
  C(this, "contour");
6047
6047
  C(this, "holes");
6048
- i || Gn(e, s), this.contour = e, this.holes = s;
6048
+ i || Qn(e, s), this.contour = e, this.holes = s;
6049
6049
  }
6050
6050
  get boundingBox() {
6051
6051
  return this.contour.boundingBox;
@@ -6068,8 +6068,8 @@ let v$1 = class v extends Ze {
6068
6068
  this.holes.map((s) => s.transform(e))
6069
6069
  );
6070
6070
  }
6071
- contains(e) {
6072
- return this.contour.contains(e) && !this.holes.some((s) => s.contains(e));
6071
+ contains(e, { strokeIsInside: s = !1 } = {}) {
6072
+ return this.contour.contains(e, { strokeIsInside: s }) && !this.holes.some((i) => i.contains(e, { strokeIsInside: s }));
6073
6073
  }
6074
6074
  intersects(e) {
6075
6075
  return this.allLoops.some(
@@ -6077,158 +6077,191 @@ let v$1 = class v extends Ze {
6077
6077
  );
6078
6078
  }
6079
6079
  overlappingStrands(e) {
6080
- const s = e instanceof v ? e.allLoops : [e], i = this.allLoops.flatMap((o) => s.flatMap((r) => o.overlappingSegments(r)));
6081
- return Yt(i).map((o) => new B$2(o));
6080
+ const s = e instanceof v ? e.allLoops : [e], i = this.allLoops.flatMap((o) => s.flatMap((l) => o.overlappingSegments(l)));
6081
+ return Xt(i).map((o) => new B$2(o));
6082
6082
  }
6083
6083
  };
6084
- function Gn(t, n = []) {
6084
+ function Qn(t, n = []) {
6085
6085
  if (!t) throw new Error("Figure must have a contour");
6086
- for (const [e, s] of st$2([t, ...n]))
6086
+ for (const [e, s] of it$2([t, ...n]))
6087
6087
  if (e.intersects(s))
6088
6088
  throw new Error("Loops in a figure must not intersect");
6089
6089
  if (n.some(
6090
6090
  (e) => !t.contains(e.firstPoint) && !t.onStroke(e.firstPoint)
6091
6091
  ))
6092
6092
  throw new Error("Holes must be inside the contour");
6093
- for (const [e, s] of st$2(n))
6093
+ for (const [e, s] of it$2(n))
6094
6094
  if (e.contains(s.firstPoint))
6095
- throw console.error(Mt$1(e), Mt$1(s)), new Error("Holes must not be inside other holes");
6096
- }
6097
- const Qn = (t) => {
6098
- const n = t.map((i, o) => t.slice(o + 1).map((r, l) => [l + o + 1, r]).filter(([, r]) => i.boundingBox.overlaps(r.boundingBox)).map(([r]) => r)), e = [], s = Array(n.length);
6095
+ throw console.error(It$1(e), It$1(s)), new Error("Holes must not be inside other holes");
6096
+ }
6097
+ const J$1 = (t, n, e = 1e-7) => Math.abs(t - n) <= e, Wn = (t, n) => {
6098
+ const e = t.boundingBox, s = n.boundingBox;
6099
+ return J$1(e.xMin, s.xMin) && J$1(e.yMin, s.yMin) && J$1(e.xMax, s.xMax) && J$1(e.yMax, s.yMax);
6100
+ }, Jn = (t, n) => {
6101
+ if (t.segmentsCount !== n.segmentsCount || !Wn(t, n)) return !1;
6102
+ const e = t.segments, s = n.segments, i = e.length, o = (l, r) => {
6103
+ for (let u = 0; u < i; u += 1) {
6104
+ const a = (l + r * u + i) % i;
6105
+ if (!e[u].isSame(s[a])) return !1;
6106
+ }
6107
+ return !0;
6108
+ };
6109
+ for (let l = 0; l < i; l += 1)
6110
+ if (e[0].isSame(s[l]) && (o(l, 1) || o(l, -1)))
6111
+ return !0;
6112
+ return !1;
6113
+ }, Kn = (t) => {
6114
+ const n = [];
6115
+ return t.forEach((e) => {
6116
+ n.some((s) => Jn(e, s)) || n.push(e);
6117
+ }), n;
6118
+ }, Zn = (t) => {
6119
+ const n = t.map((i, o) => t.slice(o + 1).map((l, r) => [r + o + 1, l]).filter(([, l]) => i.boundingBox.overlaps(l.boundingBox)).map(([l]) => l)), e = [], s = Array(n.length);
6099
6120
  return n.forEach((i, o) => {
6100
- let r = s[o];
6101
- r || (r = [], e.push(r)), r.push(t[o]), i.length && i.forEach((l) => {
6102
- s[l] = r;
6121
+ let l = s[o];
6122
+ l || (l = [], e.push(l)), l.push(t[o]), i.length && i.forEach((r) => {
6123
+ s[r] = l;
6103
6124
  });
6104
6125
  }), e;
6105
- }, Xt = (t) => t.map((n, e) => {
6106
- const i = n.segments[0].midPoint, o = t.filter((r, l) => e === l ? !1 : r.contains(i));
6126
+ }, Gt = (t) => t.map((n, e) => {
6127
+ const i = n.segments[0].midPoint, o = t.filter((l, r) => e === r ? !1 : l.contains(i));
6107
6128
  return {
6108
6129
  loop: n,
6109
6130
  isIn: o
6110
6131
  };
6111
- }), Wn = (t, n) => t.flatMap(({ loop: e }) => ft$1(
6132
+ }), te = (t, n) => t.flatMap(({ loop: e }) => ht(
6112
6133
  n.filter(
6113
6134
  ({ loop: s, isIn: i }) => s === e || i.indexOf(e) !== -1
6114
6135
  )
6115
- )), Jn = (t, n) => {
6116
- const e = n.filter(({ isIn: i }) => i.length <= 1), s = ft$1(
6117
- Xt(t.map(({ loop: i }) => i))
6136
+ )), ne = (t, n) => {
6137
+ const e = n.filter(({ isIn: i }) => i.length <= 1), s = ht(
6138
+ Gt(t.map(({ loop: i }) => i))
6118
6139
  );
6119
6140
  return [e, ...s];
6120
- }, ft$1 = (t) => {
6141
+ }, ht = (t) => {
6121
6142
  if (!t.length) return [];
6122
6143
  const n = t.filter(({ isIn: s }) => !s.length), e = t.filter(({ isIn: s }) => s.length > 1);
6123
- return n.length === 1 && e.length === 0 ? [t] : n.length > 1 ? Wn(n, t) : Jn(e, t);
6144
+ return n.length === 1 && e.length === 0 ? [t] : n.length > 1 ? te(n, t) : ne(e, t);
6124
6145
  };
6125
6146
  function X$1(t) {
6126
- return Qn(t).map(Xt).flatMap(ft$1).map((e) => {
6127
- if (e.length === 1) return new v$1(e[0].loop);
6128
- e.sort((o, r) => o.isIn.length - r.isIn.length);
6129
- const [s, ...i] = e.map(({ loop: o }) => o);
6130
- return new v$1(s, i);
6147
+ const n = Kn(t);
6148
+ return Zn(n).map(Gt).flatMap(ht).map((s) => {
6149
+ if (s.length === 1) return new v$1(s[0].loop);
6150
+ s.sort((l, r) => l.isIn.length - r.isIn.length);
6151
+ const [i, ...o] = s.map(({ loop: l }) => l);
6152
+ return new v$1(i, o);
6131
6153
  });
6132
6154
  }
6133
- function Kn(t, n) {
6155
+ function ee(t, n) {
6134
6156
  const e = [];
6135
6157
  for (const s of t)
6136
6158
  for (const i of n)
6137
6159
  e.push([s, i]);
6138
6160
  return e;
6139
6161
  }
6140
- function* Ft(t, n, e) {
6141
- const s = (r) => n.some((l) => Y$1(l, r.lastPoint)), i = (r) => e.some((l) => r.isSame(l));
6142
- let o = [];
6162
+ function* vt$1(t, n, e) {
6163
+ const s = (r) => n.some((u) => Y$1(u, r.lastPoint)), i = (r, u) => r.segmentType !== u.segmentType || !u.isOnSegment(r.firstPoint) || !u.isOnSegment(r.lastPoint) ? !1 : r.segmentType !== "LINE" ? u.isOnSegment(r.midPoint) : !0, o = (r) => e.some((u) => r.isSame(u) || i(r, u));
6164
+ let l = [];
6143
6165
  for (const r of t)
6144
- s(r) ? (o.push(r), yield new B$2(o, { ignoreChecks: !0 }), o = []) : i(r) ? (o.length && (yield new B$2(o, { ignoreChecks: !0 }), o = []), yield new B$2([r], { ignoreChecks: !0 })) : o.push(r);
6145
- o.length && (yield new B$2(o, { ignoreChecks: !0 }));
6166
+ s(r) ? (l.push(r), yield new B$2(l, { ignoreChecks: !0 }), l = []) : o(r) ? (l.length && (yield new B$2(l, { ignoreChecks: !0 }), l = []), yield new B$2([r], { ignoreChecks: !0 })) : l.push(r);
6167
+ l.length && (yield new B$2(l, { ignoreChecks: !0 }));
6146
6168
  }
6147
- const vt$1 = (t, n) => {
6169
+ const Bt = (t, n) => {
6148
6170
  const e = t.findIndex((o) => Y$1(n, o.firstPoint)), s = t.slice(0, e);
6149
6171
  return t.slice(e).concat(s);
6150
- }, Bt = (t, n) => {
6172
+ }, kt = (t, n) => {
6151
6173
  let e = t;
6152
- const s = (l) => Y$1(l.firstPoint, n.firstPoint) && Y$1(l.lastPoint, n.lastPoint);
6174
+ const s = (r) => Y$1(r.firstPoint, n.firstPoint) && Y$1(r.lastPoint, n.lastPoint);
6153
6175
  let i = t.findIndex(s);
6154
6176
  if (i === -1) {
6155
- const l = t.map((c) => c.reverse());
6156
- if (l.reverse(), i = l.findIndex(s), i === -1)
6177
+ const r = t.map((u) => u.reverse());
6178
+ if (r.reverse(), i = r.findIndex(s), i === -1)
6157
6179
  throw console.error(
6158
- l.map((c) => c.repr),
6180
+ r.map((u) => u.repr),
6159
6181
  n.repr
6160
6182
  ), new Error("Failed to rotate to segment start");
6161
- e = l;
6183
+ e = r;
6162
6184
  }
6163
6185
  const o = e.slice(0, i);
6164
6186
  return e.slice(i).concat(o);
6165
6187
  };
6166
- function Zn(t, n, e) {
6188
+ function se(t, n, e) {
6167
6189
  return t.filter((s) => {
6168
- const i = n.filter((l) => Y$1(l.firstPoint, s) || Y$1(l.lastPoint, s));
6190
+ const i = n.filter((r) => Y$1(r.firstPoint, s) || Y$1(r.lastPoint, s));
6169
6191
  if (i.length % 2)
6170
6192
  throw new Error("Bug in the intersection algo on non crossing point");
6171
- const o = i.map((l) => e.contains(l.midPoint));
6172
- return !(o.every((l) => l) || !o.some((l) => l));
6193
+ const o = i.map((r) => e.contains(r.midPoint));
6194
+ return !(o.every((r) => r) || !o.some((r) => r));
6173
6195
  });
6174
6196
  }
6175
- function te(t, n, e) {
6176
- let s = [];
6177
- const i = [], o = new Array(t.segments.length).fill(0).map(() => []), r = new Array(n.segments.length).fill(0).map(() => []);
6178
- if (t.segments.forEach((h, p) => {
6179
- n.segments.forEach((d, m) => {
6180
- const { intersections: P, overlaps: w } = K$1(
6181
- h,
6182
- d,
6197
+ function ie(t, n, e, s = !1) {
6198
+ let i = [];
6199
+ const o = [], l = new Array(t.segments.length).fill(0).map(() => []), r = new Array(n.segments.length).fill(0).map(() => []);
6200
+ if (t.segments.forEach((p, d) => {
6201
+ n.segments.forEach((m, x) => {
6202
+ const { intersections: g, overlaps: w } = Z(
6203
+ p,
6204
+ m,
6183
6205
  e
6184
6206
  );
6185
- s.push(...P), o[p].push(...P), r[m].push(...P), i.push(...w);
6186
- const x = w.flatMap((F) => [
6187
- F.firstPoint,
6188
- F.lastPoint
6207
+ i.push(...g), l[d].push(...g), r[x].push(...g), o.push(...w);
6208
+ const F = w.flatMap((y) => [
6209
+ y.firstPoint,
6210
+ y.lastPoint
6189
6211
  ]);
6190
- s.push(...x), o[p].push(...x), r[m].push(...x);
6212
+ i.push(...F), l[d].push(...F), r[x].push(...F);
6191
6213
  });
6192
- }), s = Te(s, e), !s.length || s.length === 1) return null;
6193
- const l = ([h, p]) => p.length ? h.splitAt(p) : [h];
6194
- let c = Kt([t.segments, o]).flatMap(l), a = Kt([n.segments, r]).flatMap(l);
6195
- if (s = Zn(
6196
- s,
6197
- c,
6214
+ }), i = Te(i, e), !i.length || i.length === 1) return null;
6215
+ const u = ([p, d]) => d.length ? p.splitAt(d) : [p];
6216
+ let a = Kt([t.segments, l]).flatMap(u), f = Kt([n.segments, r]).flatMap(u);
6217
+ if (i = se(
6218
+ i,
6219
+ a,
6198
6220
  n
6199
- ), !s.length && !i.length) return null;
6200
- if (i.length) {
6201
- const h = i[0];
6202
- c = Bt(
6203
- c,
6204
- h
6205
- ), a = Bt(
6221
+ ), !i.length && !o.length) return null;
6222
+ if (o.length) {
6223
+ const p = o[0];
6224
+ a = kt(
6206
6225
  a,
6207
- h
6226
+ p
6227
+ ), f = kt(
6228
+ f,
6229
+ p
6208
6230
  );
6209
6231
  } else {
6210
- const h = s[0];
6211
- c = vt$1(c, h), a = vt$1(a, h);
6232
+ const p = i[0];
6233
+ a = Bt(a, p), f = Bt(f, p);
6212
6234
  }
6213
- let f = Array.from(
6214
- Ft(
6215
- c,
6216
- s,
6217
- i
6218
- )
6219
- ), u = Array.from(
6220
- Ft(
6235
+ let c = Array.from(
6236
+ vt$1(
6221
6237
  a,
6222
- s,
6223
- i
6238
+ i,
6239
+ o
6240
+ )
6241
+ ), h = Array.from(
6242
+ vt$1(
6243
+ f,
6244
+ i,
6245
+ o
6224
6246
  )
6225
6247
  );
6226
6248
  return (!Y$1(
6227
- u[0].lastPoint,
6228
- f[0].lastPoint
6229
- ) || i.length > 0 && u[0].segmentsCount !== 1) && (u = u.map((h) => h.reverse()).reverse(), Y$1(u[0].lastPoint, f[0].lastPoint) || (f = f.map((h) => h.reverse()).reverse())), Kt([f, u]).map(([h, p]) => h.segmentsCount === 1 && i.some((d) => h.segments[0].isSame(d)) ? [h, "same"] : [h, p]);
6249
+ h[0].lastPoint,
6250
+ c[0].lastPoint
6251
+ ) || o.length > 0 && h[0].segmentsCount !== 1) && (h = h.map((p) => p.reverse()).reverse(), Y$1(h[0].lastPoint, c[0].lastPoint) || (c = c.map((p) => p.reverse()).reverse())), Kt([c, h]).map(([p, d]) => {
6252
+ if (s) {
6253
+ if (((x) => x.segments.every(
6254
+ (g) => o.some(
6255
+ (w) => g.isSame(w) || g.segmentType === w.segmentType && w.isOnSegment(g.firstPoint) && w.isOnSegment(g.lastPoint) && (g.segmentType === "LINE" || w.isOnSegment(g.midPoint))
6256
+ )
6257
+ ))(p))
6258
+ return [p, "same"];
6259
+ } else if (p.segmentsCount === 1 && o.some((m) => p.segments[0].isSame(m)))
6260
+ return [p, "same"];
6261
+ return [p, d];
6262
+ });
6230
6263
  }
6231
- function kt(t) {
6264
+ function Ot(t) {
6232
6265
  let n = t[0];
6233
6266
  for (const e of t.slice(1))
6234
6267
  n = n.extend(e);
@@ -6237,106 +6270,133 @@ function kt(t) {
6237
6270
  Z$1(n.firstPoint),
6238
6271
  Z$1(n.lastPoint)
6239
6272
  ), new Error("Bug in the intersection algo on non closing strand");
6240
- return new O(n.segments);
6273
+ return new _$2(n.segments);
6241
6274
  }
6242
- function ne(t, n) {
6275
+ function oe(t, n) {
6243
6276
  const e = Kt([
6244
6277
  n.slice(0, -1),
6245
6278
  n.slice(1)
6246
- ]).map(([i, o]) => kt(t.slice(i, o)));
6279
+ ]).map(([i, o]) => Ot(t.slice(i, o)));
6247
6280
  let s = t.slice(
6248
6281
  n[n.length - 1]
6249
6282
  );
6250
- return n[0] !== 0 && (s = s.concat(t.slice(0, n[0]))), e.push(kt(s)), e;
6283
+ return n[0] !== 0 && (s = s.concat(t.slice(0, n[0]))), e.push(Ot(s)), e;
6251
6284
  }
6252
- function ee(t) {
6285
+ function re(t) {
6253
6286
  if (!t.length) return [];
6254
6287
  const n = t.map((i) => i.firstPoint);
6255
6288
  let e = t.map((i) => i.lastPoint);
6256
6289
  e = e.slice(-1).concat(e.slice(0, -1));
6257
6290
  const s = Kt([n, e]).flatMap(
6258
- ([i, o], r) => Y$1(i, o) ? [] : r
6291
+ ([i, o], l) => Y$1(i, o) ? [] : l
6259
6292
  );
6260
6293
  try {
6261
- return ne(t, s);
6294
+ return oe(t, s);
6262
6295
  } catch {
6263
- return Yt(t.flatMap((o) => o.segments)).filter((o) => o.length > 1).filter((o) => Y$1(o[0].firstPoint, o.at(-1).lastPoint)).map((o) => new O(o));
6296
+ return Xt(t.flatMap((o) => o.segments)).filter((o) => o.length > 1).filter((o) => Y$1(o[0].firstPoint, o.at(-1).lastPoint)).map((o) => new _$2(o));
6264
6297
  }
6265
6298
  }
6266
6299
  const _t = (t, n) => {
6267
6300
  if (t.length === 0) return [n];
6268
6301
  const e = t.at(-1);
6269
6302
  return Y$1(e.lastPoint, n.firstPoint) ? t.slice(0, -1).concat([e.extend(n)]) : Y$1(e.lastPoint, n.lastPoint) ? t.slice(0, -1).concat([e.extend(n.reverse())]) : t.concat([n]);
6270
- }, se = (t, n) => t.length === 0 ? [n] : Y$1(t[0].firstPoint, n.lastPoint) ? [n.extend(t[0])].concat(t.slice(1)) : [n].concat(t);
6271
- function ht(t, n, {
6303
+ }, le = (t, n) => t.length === 0 ? [n] : Y$1(t[0].firstPoint, n.lastPoint) ? [n.extend(t[0])].concat(t.slice(1)) : [n].concat(t);
6304
+ function pt(t, n, {
6272
6305
  firstInside: e,
6273
- secondInside: s
6306
+ secondInside: s,
6307
+ firstBoundaryInside: i = !1,
6308
+ secondBoundaryInside: o = !1
6274
6309
  }) {
6275
- const i = te(t, n);
6276
- if (!i) {
6277
- const c = t.segments[0].midPoint, a = n.contains(c), f = n.segments[0].midPoint, u = t.contains(f);
6310
+ const l = ie(
6311
+ t,
6312
+ n,
6313
+ void 0,
6314
+ i || o
6315
+ );
6316
+ if (!l) {
6317
+ const f = t.segments[0].midPoint, c = n.contains(f, {
6318
+ strokeIsInside: o
6319
+ }), h = n.segments[0].midPoint, p = t.contains(h, {
6320
+ strokeIsInside: i
6321
+ });
6278
6322
  return {
6279
6323
  identical: !1,
6280
- firstCurveInSecond: a,
6281
- secondCurveInFirst: u
6324
+ firstCurveInSecond: c,
6325
+ secondCurveInFirst: p
6282
6326
  };
6283
6327
  }
6284
- if (i.every(([, c]) => c === "same"))
6328
+ if (l.every(([, f]) => f === "same"))
6285
6329
  return { identical: !0 };
6286
- let o = null, r = null;
6287
- const l = i.flatMap(([c, a]) => {
6288
- let f = [], u = 0;
6289
- if (a === "same")
6290
- return r === 1 ? (r = 1, c) : r === 2 || r === 0 ? (r = null, []) : r === null ? (o ? o = o.extend(c) : o = c, []) : (console.error("weird situation"), []);
6291
- const h = c.segments[0].midPoint, p = n.contains(h);
6292
- (e === "keep" && p || e === "remove" && !p) && (u += 1, f = _t(f, c));
6293
- const d = a.segments[0].midPoint, m = t.contains(d);
6294
- if (s === "keep" && m || s === "remove" && !m) {
6295
- const P = a;
6296
- u += 1, u === 2 && f.length ? (f = _t(f, P), o = null) : f = [P];
6297
- }
6298
- return r === null && u === 1 && o && (f = se(f, o)), u === 1 && (r = u, o = null), f.length ? f : (o = null, []);
6330
+ let r = null, u = null;
6331
+ const a = l.flatMap(([f, c]) => {
6332
+ let h = [], p = 0;
6333
+ if (c === "same")
6334
+ return u === 1 ? (u = 1, f) : u === 2 || u === 0 ? (u = null, []) : u === null ? (r ? r = r.extend(f) : r = f, []) : (console.error("weird situation"), []);
6335
+ const d = f.segments[0].midPoint, m = n.contains(d, {
6336
+ strokeIsInside: o
6337
+ });
6338
+ (e === "keep" && m || e === "remove" && !m) && (p += 1, h = _t(h, f));
6339
+ const x = c.segments[0].midPoint, g = t.contains(x, {
6340
+ strokeIsInside: i
6341
+ });
6342
+ if (s === "keep" && g || s === "remove" && !g) {
6343
+ const w = c;
6344
+ p += 1, p === 2 && h.length ? (h = _t(h, w), r = null) : h = [w];
6345
+ }
6346
+ return u === null && p === 1 && r && (h = le(h, r)), p === 1 && (u = p, r = null), h.length ? h : (r = null, []);
6299
6347
  });
6300
- return ee(l);
6348
+ return re(a);
6301
6349
  }
6302
- const ie = (t, n) => {
6303
- const e = ht(t, n, {
6350
+ const ue = (t, n, e) => {
6351
+ const s = pt(t, n, {
6304
6352
  firstInside: "remove",
6305
- secondInside: "remove"
6353
+ secondInside: "remove",
6354
+ ...e
6306
6355
  });
6307
- return Array.isArray(e) ? e : e.identical ? [t] : e.firstCurveInSecond ? [n] : e.secondCurveInFirst ? [t] : [t, n];
6308
- }, Z = (t, n) => {
6309
- const e = ht(t, n, {
6356
+ return Array.isArray(s) ? s : s.identical ? [t] : s.firstCurveInSecond ? [n] : s.secondCurveInFirst ? [t] : [t, n];
6357
+ }, tt$1 = (t, n, e) => {
6358
+ const s = pt(t, n, {
6310
6359
  firstInside: "remove",
6311
- secondInside: "keep"
6360
+ secondInside: "keep",
6361
+ ...e
6312
6362
  });
6313
- return Array.isArray(e) ? e : e.identical ? [] : e.firstCurveInSecond ? [] : e.secondCurveInFirst ? [t, n] : [t];
6314
- }, pt = (t, n) => {
6315
- const e = ht(t, n, {
6363
+ return Array.isArray(s) ? s : s.identical ? [] : s.firstCurveInSecond ? [] : s.secondCurveInFirst ? [t, n] : [t];
6364
+ }, dt = (t, n, e) => {
6365
+ const s = (e == null ? void 0 : e.firstBoundaryInside) ?? !1, i = (e == null ? void 0 : e.secondBoundaryInside) ?? !1, o = s || i, l = (u, a, f) => u.segments.every(
6366
+ (c) => a.contains(c.midPoint, { strokeIsInside: f })
6367
+ );
6368
+ if (o) {
6369
+ if (l(t, n, i))
6370
+ return [t];
6371
+ if (l(n, t, s))
6372
+ return [n];
6373
+ }
6374
+ const r = pt(t, n, {
6316
6375
  firstInside: "keep",
6317
- secondInside: "keep"
6376
+ secondInside: "keep",
6377
+ ...e
6318
6378
  });
6319
- return Array.isArray(e) ? e : e.identical ? [t] : e.firstCurveInSecond ? [t] : e.secondCurveInFirst ? [n] : [];
6379
+ return Array.isArray(r) ? r : r.identical ? [t] : r.firstCurveInSecond ? [t] : r.secondCurveInFirst ? [n] : [];
6320
6380
  };
6321
- function oe(t) {
6381
+ function ce(t) {
6322
6382
  const n = /* @__PURE__ */ new Map(), e = [];
6323
6383
  return t.forEach((s, i) => {
6324
6384
  let o;
6325
- n.has(i) ? o = n.get(i) : (o = { current: [s], fusedWith: /* @__PURE__ */ new Set([i]) }, e.push(o)), t.slice(i + 1).forEach((r, l) => {
6326
- const c = o.current, a = i + l + 1;
6385
+ n.has(i) ? o = n.get(i) : (o = { current: [s], fusedWith: /* @__PURE__ */ new Set([i]) }, e.push(o)), t.slice(i + 1).forEach((l, r) => {
6386
+ const u = o.current, a = i + r + 1;
6327
6387
  if (o.fusedWith.has(a)) return;
6328
- let f = [r], u = !1;
6329
- if (n.has(a) && (f = n.get(a).current, u = !0), !c.some(
6388
+ let f = [l], c = !1;
6389
+ if (n.has(a) && (f = n.get(a).current, c = !0), !u.some(
6330
6390
  (d) => f.some((m) => d.intersects(m))
6331
6391
  )) return;
6332
6392
  let p;
6333
- c.length > 1 || f.length > 1 ? p = G(c, f) : p = Gt(c[0], f[0]), o.fusedWith.add(a), o.current = p, u || n.set(a, o);
6393
+ u.length > 1 || f.length > 1 ? p = G(u, f) : p = Qt(u[0], f[0]), o.fusedWith.add(a), o.current = p, c || n.set(a, o);
6334
6394
  });
6335
6395
  }), e.flatMap(({ current: s }) => s);
6336
6396
  }
6337
- function Gt(t, n) {
6338
- const e = ie(t.contour, n.contour), s = n.holes.flatMap((r) => Z(r, t.contour)), i = t.holes.flatMap((r) => Z(r, n.contour)), o = Kn(t.holes, n.holes).flatMap(
6339
- ([r, l]) => pt(r, l)
6397
+ function Qt(t, n) {
6398
+ const e = ue(t.contour, n.contour), s = n.holes.flatMap((l) => tt$1(l, t.contour)), i = t.holes.flatMap((l) => tt$1(l, n.contour)), o = ee(t.holes, n.holes).flatMap(
6399
+ ([l, r]) => dt(l, r)
6340
6400
  );
6341
6401
  return X$1([
6342
6402
  ...e,
@@ -6345,12 +6405,12 @@ function Gt(t, n) {
6345
6405
  ...o
6346
6406
  ]);
6347
6407
  }
6348
- function tt$1(t, n) {
6408
+ function nt$1(t, n) {
6349
6409
  if (t.isFull && n.isFull)
6350
- return X$1(Z(t.contour, n.contour));
6410
+ return X$1(tt$1(t.contour, n.contour));
6351
6411
  if (t.isFull) {
6352
- const s = Z(t.contour, n.contour), i = n.holes.flatMap(
6353
- (o) => pt(o, t.contour)
6412
+ const s = tt$1(t.contour, n.contour), i = n.holes.flatMap(
6413
+ (o) => dt(o, t.contour, { firstBoundaryInside: !0 })
6354
6414
  );
6355
6415
  return X$1([...s, ...i]);
6356
6416
  } else if (n.isFull && !t.contour.intersects(n.contour))
@@ -6365,13 +6425,13 @@ function tt$1(t, n) {
6365
6425
  ]);
6366
6426
  } else
6367
6427
  return [t];
6368
- let e = tt$1(new v$1(t.contour), n);
6428
+ let e = nt$1(new v$1(t.contour), n);
6369
6429
  return t.holes.forEach((s) => {
6370
- e = e.flatMap((i) => tt$1(i, new v$1(s)));
6430
+ e = e.flatMap((i) => nt$1(i, new v$1(s)));
6371
6431
  }), e;
6372
6432
  }
6373
- function re(t, n) {
6374
- const e = pt(t.contour, n.contour);
6433
+ function ae(t, n) {
6434
+ const e = dt(t.contour, n.contour);
6375
6435
  if (!e.length) return [];
6376
6436
  let s = X$1(e);
6377
6437
  return s = Q$1(
@@ -6386,42 +6446,42 @@ function G(t, n) {
6386
6446
  if (!t.length) return n;
6387
6447
  if (!n.length) return t;
6388
6448
  if (t.length === 1 && n.length > 1 || n.length === 1 && t.length > 1)
6389
- return oe([...t, ...n]);
6449
+ return ce([...t, ...n]);
6390
6450
  if (t.length > 1 && n.length > 1) {
6391
6451
  let e = G([t[0]], n);
6392
6452
  return t.slice(1).forEach((s) => {
6393
6453
  e = G([s], e);
6394
6454
  }), e;
6395
6455
  }
6396
- return t.length === 1 && n.length === 1 ? Gt(t[0], n[0]) : [];
6456
+ return t.length === 1 && n.length === 1 ? Qt(t[0], n[0]) : [];
6397
6457
  }
6398
6458
  function Q$1(t, n) {
6399
6459
  if (!t.length) return [];
6400
6460
  if (!n.length) return t;
6401
6461
  if (t.length === 1 && n.length === 1)
6402
- return tt$1(t[0], n[0]);
6462
+ return nt$1(t[0], n[0]);
6403
6463
  if (t.length > 1)
6404
6464
  return t.flatMap((s) => Q$1([s], n));
6405
- let e = tt$1(t[0], n[0]);
6465
+ let e = nt$1(t[0], n[0]);
6406
6466
  return n.slice(1).forEach((s) => {
6407
6467
  e = Q$1(e, [s]);
6408
6468
  }), e;
6409
6469
  }
6410
- function rt$2(t, n) {
6411
- return !t.length || !n.length ? [] : t.length === 1 && n.length === 1 ? re(t[0], n[0]) : t.length > 1 ? t.flatMap((e) => rt$2([e], n)) : n.flatMap((e) => rt$2(t, [e]));
6470
+ function lt$1(t, n) {
6471
+ return !t.length || !n.length ? [] : t.length === 1 && n.length === 1 ? ae(t[0], n[0]) : t.length > 1 ? t.flatMap((e) => lt$1([e], n)) : n.flatMap((e) => lt$1(t, [e]));
6412
6472
  }
6413
- let _$2 = class _ extends Ze {
6473
+ let O$1 = class O extends Ze {
6414
6474
  constructor(e = [], { ignoreChecks: s = !1 } = {}) {
6415
6475
  super();
6416
6476
  C(this, "figures");
6417
6477
  C(this, "_boundingBox", null);
6418
- s || le(e), this.figures = e;
6478
+ s || fe(e), this.figures = e;
6419
6479
  }
6420
6480
  get isEmpty() {
6421
6481
  return this.figures.length === 0;
6422
6482
  }
6423
6483
  get boundingBox() {
6424
- if (this.isEmpty) return new mt$2();
6484
+ if (this.isEmpty) return new mt$1();
6425
6485
  if (this._boundingBox === null) {
6426
6486
  let e = this.figures[0].boundingBox;
6427
6487
  for (const s of this.figures.slice(1))
@@ -6431,13 +6491,15 @@ let _$2 = class _ extends Ze {
6431
6491
  return this._boundingBox;
6432
6492
  }
6433
6493
  clone() {
6434
- return new _(this.figures.map((e) => e.clone()));
6494
+ return new O(this.figures.map((e) => e.clone()));
6435
6495
  }
6436
6496
  transform(e) {
6437
- return new _(this.figures.map((s) => s.transform(e)));
6497
+ return new O(this.figures.map((s) => s.transform(e)));
6438
6498
  }
6439
- contains(e) {
6440
- return this.figures.some((s) => s.contains(e));
6499
+ contains(e, { strokeIsInside: s = !1 } = {}) {
6500
+ return this.figures.some(
6501
+ (i) => i.contains(e, { strokeIsInside: s })
6502
+ );
6441
6503
  }
6442
6504
  intersects(e) {
6443
6505
  return this.figures.some(
@@ -6445,22 +6507,22 @@ let _$2 = class _ extends Ze {
6445
6507
  );
6446
6508
  }
6447
6509
  overlappingStrands(e) {
6448
- return this.figures.flatMap((s) => e instanceof _ ? e.figures.flatMap(
6510
+ return this.figures.flatMap((s) => e instanceof O ? e.figures.flatMap(
6449
6511
  (i) => s.overlappingStrands(i)
6450
6512
  ) : s.overlappingStrands(e));
6451
6513
  }
6452
6514
  fuse(e) {
6453
- return new _(G(this.figures, e.figures));
6515
+ return new O(G(this.figures, e.figures));
6454
6516
  }
6455
6517
  cut(e) {
6456
- return new _(Q$1(this.figures, e.figures));
6518
+ return new O(Q$1(this.figures, e.figures));
6457
6519
  }
6458
6520
  intersect(e) {
6459
- return new _(rt$2(this.figures, e.figures));
6521
+ return new O(lt$1(this.figures, e.figures));
6460
6522
  }
6461
6523
  };
6462
- function le(t) {
6463
- for (const [n, e] of st$2(t))
6524
+ function fe(t) {
6525
+ for (const [n, e] of it$2(t))
6464
6526
  if (n.intersects(e))
6465
6527
  throw new Error("Diagram figures must not intersect");
6466
6528
  }
@@ -6588,14 +6650,14 @@ function M(e, t, n) {
6588
6650
  return null;
6589
6651
  let h;
6590
6652
  try {
6591
- h = ae(o, a, 1e-9).at(-1);
6653
+ h = de(o, a, 1e-9).at(-1);
6592
6654
  } catch {
6593
6655
  return null;
6594
6656
  }
6595
6657
  if (!h)
6596
6658
  return null;
6597
6659
  const c = h, p = (v, O) => {
6598
- const I = O.tangentAt(c), N = Qt(I), Y = it$3(c, nt$2(N, s));
6660
+ const I = O.tangentAt(c), N = Qt$1(I), Y = it$3(c, nt$2(N, s));
6599
6661
  return v.splitAt(Y);
6600
6662
  }, [f] = p(e, o), [, g] = p(t, a);
6601
6663
  return { first: f, second: g, center: c };
@@ -6636,12 +6698,12 @@ const st$1 = (e) => {
6636
6698
  startTangent: s
6637
6699
  } = t;
6638
6700
  let o;
6639
- typeof n == "number" ? o = Tt(1, n * fe) : o = n;
6701
+ typeof n == "number" ? o = Tt(1, n * fe$1) : o = n;
6640
6702
  let a;
6641
- return typeof s == "number" ? a = Tt(1, s * fe) : a = s, { endTangent: o, startFactor: r, endFactor: i, startTangent: a };
6703
+ return typeof s == "number" ? a = Tt(1, s * fe$1) : a = s, { endTangent: o, startFactor: r, endFactor: i, startTangent: a };
6642
6704
  };
6643
6705
  function z$1(e, { ignoreChecks: t = !1 } = {}) {
6644
- return new _$2([new v$1(new O([...e], { ignoreChecks: t }))]);
6706
+ return new O$1([new v$1(new _$2([...e], { ignoreChecks: t }))]);
6645
6707
  }
6646
6708
  let ot$1 = class ot {
6647
6709
  constructor(t = [0, 0]) {
@@ -6690,11 +6752,11 @@ let ot$1 = class ot {
6690
6752
  return this.lineTo([t, this.pointer[1]]);
6691
6753
  }
6692
6754
  polarLineTo([t, n]) {
6693
- const r = n * fe, i = Tt(t, r);
6755
+ const r = n * fe$1, i = Tt(t, r);
6694
6756
  return this.lineTo(i);
6695
6757
  }
6696
6758
  polarLine(t, n) {
6697
- const r = n * fe, [i, s] = Tt(t, r);
6759
+ const r = n * fe$1, [i, s] = Tt(t, r);
6698
6760
  return this.line(i, s);
6699
6761
  }
6700
6762
  tangentLine(t) {
@@ -6766,7 +6828,7 @@ let ot$1 = class ot {
6766
6828
  }
6767
6829
  ellipseTo(t, n, r, i, s, o) {
6768
6830
  return this.saveSegment(
6769
- pn$2(this.pointer, t, n, r, i, s, o)
6831
+ pn$1(this.pointer, t, n, r, i, s, o)
6770
6832
  ), this.pointer = t, this;
6771
6833
  }
6772
6834
  ellipse(t, n, r, i, s, o, a) {
@@ -6953,9 +7015,9 @@ var P = (n, t, e) => Ct(n, typeof t != "symbol" ? t + "" : t, e);
6953
7015
  function L(n) {
6954
7016
  if (n instanceof v$1)
6955
7017
  return [n];
6956
- if (n instanceof O)
6957
- return [new v$1(n)];
6958
7018
  if (n instanceof _$2)
7019
+ return [new v$1(n)];
7020
+ if (n instanceof O$1)
6959
7021
  return n.figures;
6960
7022
  throw new Error("Unknown shape");
6961
7023
  }
@@ -6964,7 +7026,7 @@ function mt(n, t, e = 1e-9) {
6964
7026
  const r = [], i = new Array(t.segments.length).fill(0).map(() => []);
6965
7027
  t.segments.forEach((a, f) => {
6966
7028
  n.segments.forEach((c) => {
6967
- const { intersections: l, overlaps: p } = K$1(
7029
+ const { intersections: l, overlaps: p } = Z(
6968
7030
  a,
6969
7031
  c,
6970
7032
  e
@@ -6979,7 +7041,7 @@ function mt(n, t, e = 1e-9) {
6979
7041
  }), s = Te(s, e);
6980
7042
  const o = Kt([t.segments, i]).flatMap(([a, f]) => f.length ? a.splitAt(f) : [a]);
6981
7043
  return Array.from(
6982
- Ft(
7044
+ vt$1(
6983
7045
  o,
6984
7046
  s,
6985
7047
  r
@@ -7021,28 +7083,28 @@ function j(n, t, e = !1) {
7021
7083
  }), s;
7022
7084
  }
7023
7085
  function sn(n, t) {
7024
- return new _$2(
7086
+ return new O$1(
7025
7087
  G(L(n), L(t))
7026
7088
  );
7027
7089
  }
7028
7090
  function z(n) {
7029
7091
  return n.reduce(
7030
7092
  (t, e) => sn(t, e),
7031
- new _$2()
7093
+ new O$1()
7032
7094
  );
7033
7095
  }
7034
7096
  function Pt(n, t) {
7035
- return new _$2(
7097
+ return new O$1(
7036
7098
  Q$1(L(n), L(t))
7037
7099
  );
7038
7100
  }
7039
7101
  function yn(n, t) {
7040
- return new _$2(
7041
- rt$2(L(n), L(t))
7102
+ return new O$1(
7103
+ lt$1(L(n), L(t))
7042
7104
  );
7043
7105
  }
7044
7106
  function Cn(n, t, e = !0) {
7045
- if (t instanceof O)
7107
+ if (t instanceof _$2)
7046
7108
  return J(n, t, e);
7047
7109
  if (t instanceof v$1)
7048
7110
  return W(n, t, e);
@@ -7052,7 +7114,7 @@ function Cn(n, t, e = !0) {
7052
7114
  }), s;
7053
7115
  }
7054
7116
  function xn(n, t, e = !1) {
7055
- if (t instanceof O)
7117
+ if (t instanceof _$2)
7056
7118
  return Q(n, t, e);
7057
7119
  if (t instanceof v$1)
7058
7120
  return j(n, t, e);
@@ -7096,9 +7158,9 @@ function rn(n, t) {
7096
7158
  throw new Error("Invalid position");
7097
7159
  }
7098
7160
  function et(n, t) {
7099
- if (J$1(n, t).length > 0)
7161
+ if (K$1(n, t).length > 0)
7100
7162
  return 0;
7101
- const e = pn$1(n, t.center);
7163
+ const e = dn$1(n, t.center);
7102
7164
  if (n.isOnSegment(e)) {
7103
7165
  const s = J$2(e, t.center);
7104
7166
  if (Math.abs(s - t.radius) < n.precision && t.isOnSegment(e))
@@ -7128,7 +7190,7 @@ const on = (n, t) => {
7128
7190
  return !!n.isValidParameter(s);
7129
7191
  };
7130
7192
  function an(n, t) {
7131
- if (qt(n, t, !0).length > 0) return 0;
7193
+ if (Dt(n, t, !0).length > 0) return 0;
7132
7194
  const e = J$2(n.center, t.center);
7133
7195
  if (e < n.precision && on(n, t))
7134
7196
  return Math.abs(n.radius - t.radius);
@@ -7222,7 +7284,7 @@ class hn {
7222
7284
  P(this, "tol");
7223
7285
  this.fcn = t, this.endTolerance = e, this.maxIterations = s, this.epsilon = r, this.fcn = t, this.epsilon = r, this.endTolerance = e, this.maxIterations = s, this.rectangles = /* @__PURE__ */ new Map(), this.buckets = new ln();
7224
7286
  const i = [0.5, 0.5], o = this.rect(0, 0), a = this.fcn(i);
7225
- this.buckets.addInterval(new D(i, a, o)), this.fMin = a, this.argMin = i, this.tol = o.diagonal;
7287
+ this.buckets.addInterval(new O(i, a, o)), this.fMin = a, this.argMin = i, this.tol = o.diagonal;
7226
7288
  }
7227
7289
  registerInterval(t) {
7228
7290
  this.buckets.addInterval(t), t.value <= this.fMin && (this.fMin = t.value, this.argMin = t.center, this.tol = t.rectangle.diagonal);
@@ -7235,9 +7297,9 @@ class hn {
7235
7297
  let e, s, r;
7236
7298
  const [i, o] = t.center;
7237
7299
  return t.rectangle.x <= t.rectangle.y ? (e = this.rect(t.rectangle.x + 1, t.rectangle.y), s = [i - e.xLength, o], r = [i + e.xLength, o]) : (e = this.rect(t.rectangle.x, t.rectangle.y + 1), s = [i, o - e.yLength], r = [i, o + e.yLength]), [
7238
- new D(s, this.fcn(s), e),
7239
- new D(t.center, t.value, e),
7240
- new D(r, this.fcn(r), e)
7300
+ new O(s, this.fcn(s), e),
7301
+ new O(t.center, t.value, e),
7302
+ new O(r, this.fcn(r), e)
7241
7303
  ];
7242
7304
  }
7243
7305
  single_iteration() {
@@ -7269,7 +7331,7 @@ class hn {
7269
7331
  };
7270
7332
  }
7271
7333
  }
7272
- class D {
7334
+ class O {
7273
7335
  constructor(t, e, s) {
7274
7336
  this.center = t, this.value = e, this.rectangle = s;
7275
7337
  }
@@ -7321,14 +7383,14 @@ function mn(n) {
7321
7383
  const l = Math.cos(f), p = Math.sin(f), g = Math.cos(c), d = Math.sin(c), [u, S] = n.center, M = n.minorRadius, v = n.majorRadius, k = new et$3().rotate(
7322
7384
  n.tiltAngle,
7323
7385
  n.center
7324
- ), C = (Ft) => k.transform(Ft), O = C([u + v * l, S + M * p]), G = C([
7386
+ ), C = (Ft) => k.transform(Ft), D = C([u + v * l, S + M * p]), G = C([
7325
7387
  u + v * (l - r * p * i),
7326
7388
  S + M * (p + r * l * i)
7327
7389
  ]), kt = C([
7328
7390
  u + v * (g + r * d * i),
7329
7391
  S + M * (d - r * g * i)
7330
7392
  ]), Et = C([u + v * g, S + M * d]);
7331
- return new Et$1(O, Et, G, kt);
7393
+ return new Et$1(D, Et, G, kt);
7332
7394
  });
7333
7395
  }
7334
7396
  const X = 1e-8, Mt = (n) => n.flatMap((t) => t instanceof at$2 ? [t] : t instanceof ct$2 ? [t] : t instanceof jt$1 ? mn(t).flatMap(
@@ -7363,7 +7425,7 @@ function q(n, t, e = !0) {
7363
7425
  }
7364
7426
  let g = [];
7365
7427
  if (!(o.offset instanceof S) && !(c.offset instanceof S)) {
7366
- const { intersections: M, overlaps: v } = K$1(
7428
+ const { intersections: M, overlaps: v } = Z(
7367
7429
  o.offset,
7368
7430
  c.offset,
7369
7431
  X / 100
@@ -7376,10 +7438,10 @@ function q(n, t, e = !0) {
7376
7438
  if (g.length > 0) {
7377
7439
  let M = g[0];
7378
7440
  if (g.length > 1) {
7379
- const C = o == null ? void 0 : o.original.lastPoint, O = g.map(
7441
+ const C = o == null ? void 0 : o.original.lastPoint, D = g.map(
7380
7442
  (G) => Rt$1(G, C)
7381
7443
  );
7382
- M = g[O.indexOf(Math.min(...O))];
7444
+ M = g[D.indexOf(Math.min(...D))];
7383
7445
  }
7384
7446
  const v = o.offset.splitAt([
7385
7447
  M
@@ -7406,7 +7468,7 @@ function It(n) {
7406
7468
  };
7407
7469
  return n.forEach((s, r) => {
7408
7470
  n.slice(r + 1).forEach((i, o) => {
7409
- const { intersections: a, overlaps: f } = K$1(s, i, X), c = [
7471
+ const { intersections: a, overlaps: f } = Z(s, i, X), c = [
7410
7472
  ...a,
7411
7473
  ...f.flatMap((l) => [l.firstPoint, l.lastPoint])
7412
7474
  ].filter((l) => {
@@ -7429,19 +7491,19 @@ function bt(n, t, e) {
7429
7491
  }
7430
7492
  function T(n, t) {
7431
7493
  const e = n.clockwise ? t : -t, s = Mt(n.segments), r = q(s, e);
7432
- if (r.length < 2) return new _$2();
7494
+ if (r.length < 2) return new O$1();
7433
7495
  const i = It(r);
7434
7496
  if (!i.size) {
7435
- const l = new O(r);
7436
- return new _$2([new v$1(l)]);
7497
+ const l = new _$2(r);
7498
+ return new O$1([new v$1(l)]);
7437
7499
  }
7438
7500
  const o = St(
7439
7501
  i,
7440
7502
  r
7441
7503
  ), a = bt(o, n, t);
7442
- if (!a.length) return new _$2();
7443
- const c = Yt(a).filter((l) => l.length > 1).filter((l) => Y$1(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new O(l));
7444
- return c.length ? new _$2(c.map((l) => new v$1(l))) : new _$2();
7504
+ if (!a.length) return new O$1();
7505
+ const c = Xt(a).filter((l) => l.length > 1).filter((l) => Y$1(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new _$2(l));
7506
+ return c.length ? new O$1(c.map((l) => new v$1(l))) : new O$1();
7445
7507
  }
7446
7508
  function Pn(n, t, e = "round") {
7447
7509
  const s = t / 2, r = Mt(n.segments), i = q(r, s, !1), o = q(
@@ -7467,16 +7529,16 @@ function Pn(n, t, e = "round") {
7467
7529
  )
7468
7530
  ], c = It(f);
7469
7531
  if (!c.size) {
7470
- const u = new O(f);
7471
- return new _$2([new v$1(u)]);
7532
+ const u = new _$2(f);
7533
+ return new O$1([new v$1(u)]);
7472
7534
  }
7473
7535
  const l = St(
7474
7536
  c,
7475
7537
  f
7476
7538
  ), p = bt(l, n, s);
7477
- if (!p.length) return new _$2();
7478
- const d = Yt(p).filter((u) => u.length > 1).filter((u) => Y$1(u[0].firstPoint, u.at(-1).lastPoint)).map((u) => new O(u));
7479
- return d.length ? new _$2(d.map((u) => new v$1(u))) : new _$2();
7539
+ if (!p.length) return new O$1();
7540
+ const d = Xt(p).filter((u) => u.length > 1).filter((u) => Y$1(u[0].firstPoint, u.at(-1).lastPoint)).map((u) => new _$2(u));
7541
+ return d.length ? new O$1(d.map((u) => new v$1(u))) : new O$1();
7480
7542
  }
7481
7543
  function wn(n, t) {
7482
7544
  const e = n.map((s) => {
@@ -7495,10 +7557,10 @@ function Mn(n, t) {
7495
7557
  );
7496
7558
  return z(s);
7497
7559
  }
7498
- function On(n, t) {
7560
+ function Dn(n, t) {
7499
7561
  return wn(L(n), t);
7500
7562
  }
7501
- function Dn(n, t, { endCap: e = "round" } = {}) {
7563
+ function On(n, t, { endCap: e = "round" } = {}) {
7502
7564
  return n instanceof B$2 ? Pn(n, t, e) : Mn(L(n), t);
7503
7565
  }
7504
7566
  class In {
@@ -7598,7 +7660,7 @@ class x extends In {
7598
7660
  function e({ element: s }) {
7599
7661
  const r = s.firstCurve.tangentAtLastPoint, i = s.secondCurve.tangentAtFirstPoint;
7600
7662
  return Math.abs(
7601
- rt(un$1(r, i)) - rt(fe * t)
7663
+ rt(un$1(r, i)) - rt(fe$1 * t)
7602
7664
  ) < 1e-9;
7603
7665
  }
7604
7666
  return this.filters.push(e), this;
@@ -7643,39 +7705,39 @@ function At(n, t, e, s = () => !0) {
7643
7705
  if (!f) throw new Error("Bug in the stroke filletting algo");
7644
7706
  i(f, a);
7645
7707
  }), !r.at(-1)) throw new Error("Bug in the stroke corner algo");
7646
- if (t instanceof O) {
7708
+ if (t instanceof _$2) {
7647
7709
  const a = r.pop(), f = r.shift();
7648
7710
  if (!a || !f)
7649
7711
  throw new Error("Bug in the filletting algo");
7650
- return i(a, f), new O(r, { ignoreChecks: !0 });
7712
+ return i(a, f), new _$2(r, { ignoreChecks: !0 });
7651
7713
  } else
7652
7714
  return new B$2(r, { ignoreChecks: !0 });
7653
7715
  }
7654
7716
  function B(n, t, e) {
7655
7717
  const s = typeof e == "function" ? e(new x()) : e, r = s && s.asFilterFun();
7656
- if (n instanceof O || n instanceof B$2)
7718
+ if (n instanceof _$2 || n instanceof B$2)
7657
7719
  return At(V, n, t, r);
7658
7720
  if (n instanceof v$1) {
7659
7721
  const i = B(n.contour, t, s), o = n.holes.map((a) => B(a, t, s));
7660
7722
  return new v$1(i, o, { ignoreChecks: !0 });
7661
7723
  }
7662
- if (n instanceof _$2) {
7724
+ if (n instanceof O$1) {
7663
7725
  const i = n.figures.map((o) => B(o, t, s));
7664
- return new _$2(i, { ignoreChecks: !0 });
7726
+ return new O$1(i, { ignoreChecks: !0 });
7665
7727
  }
7666
7728
  throw new Error("invalid shape to fillet");
7667
7729
  }
7668
7730
  function R(n, t, e) {
7669
7731
  const s = typeof e == "function" ? e(new x()) : e, r = s && s.asFilterFun();
7670
- if (n instanceof O || n instanceof B$2)
7732
+ if (n instanceof _$2 || n instanceof B$2)
7671
7733
  return At(V, n, t, r);
7672
7734
  if (n instanceof v$1) {
7673
7735
  const i = R(n.contour, t, s), o = n.holes.map((a) => R(a, t, s));
7674
7736
  return new v$1(i, o, { ignoreChecks: !0 });
7675
7737
  }
7676
- if (n instanceof _$2) {
7738
+ if (n instanceof O$1) {
7677
7739
  const i = n.figures.map((o) => R(o, t, s));
7678
- return new _$2(i, { ignoreChecks: !0 });
7740
+ return new O$1(i, { ignoreChecks: !0 });
7679
7741
  }
7680
7742
  throw new Error("invalid shape to chamfer");
7681
7743
  }
@@ -7694,15 +7756,15 @@ function Bn(n) {
7694
7756
  return new Sn(n);
7695
7757
  }
7696
7758
  function it(n) {
7697
- if (n instanceof _$2)
7759
+ if (n instanceof O$1)
7698
7760
  return d(n);
7699
7761
  if (n instanceof v$1)
7700
7762
  return p(n);
7701
- if (n instanceof O)
7763
+ if (n instanceof _$2)
7702
7764
  return `<path d="${w(n)}" />`;
7703
7765
  if (n instanceof B$2)
7704
7766
  return `<path d="${j$1(n)}" />`;
7705
- if (jn(n))
7767
+ if (Hn(n))
7706
7768
  return `<path d="${`M ${n.firstPoint.join(" ")}`} ${s(
7707
7769
  n
7708
7770
  )}" />`;
@@ -7712,7 +7774,7 @@ const ot = (n) => "shape" in n ? n.shape : n, at = (n, t) => {
7712
7774
  if (!("shape" in n)) return t;
7713
7775
  const { color: e } = n;
7714
7776
  return e ? `<g stroke="${e}">${t}</g>` : t;
7715
- }, ct = (n) => new mt$2(n.xMin, -n.yMax, n.xMax, -n.yMin);
7777
+ }, ct = (n) => new mt$1(n.xMin, -n.yMax, n.xMax, -n.yMin);
7716
7778
  function Rn(n, {
7717
7779
  margin: t = 1,
7718
7780
  unit: e = null,
@@ -7768,13 +7830,13 @@ const vt = (n) => {
7768
7830
  throw new Error("Unknown segment type");
7769
7831
  }, H = (n) => {
7770
7832
  const t = n.segments.map(vt);
7771
- return new O(t);
7833
+ return new _$2(t);
7772
7834
  }, Lt = (n) => {
7773
7835
  const t = H(n.contour), e = n.holes.map(H);
7774
7836
  return new v$1(t, e);
7775
7837
  }, bn = (n) => {
7776
7838
  const t = n.figures.map(Lt);
7777
- return new _$2(t);
7839
+ return new O$1(t);
7778
7840
  };
7779
7841
  function zn(n) {
7780
7842
  if (n.type === "DIAGRAM")
@@ -7800,6 +7862,7 @@ function $n([n, t]) {
7800
7862
  var pantograph = /*#__PURE__*/Object.freeze({
7801
7863
  __proto__: null,
7802
7864
  DEG2RAD: ft,
7865
+ DrawingPen: ot$1,
7803
7866
  RAD2DEG: An,
7804
7867
  cartesianToPolar: $n,
7805
7868
  chamfer: R,
@@ -7807,15 +7870,15 @@ var pantograph = /*#__PURE__*/Object.freeze({
7807
7870
  cut: Pt,
7808
7871
  draw: lt,
7809
7872
  eraseStrand: Cn,
7810
- exportJSON: Mt$1,
7873
+ exportJSON: It$1,
7811
7874
  exportSVG: Rn,
7812
7875
  fillet: B,
7813
7876
  fuse: sn,
7814
7877
  fuseAll: z,
7815
7878
  importJSON: zn,
7816
7879
  intersect: yn,
7817
- offset: On,
7818
- outlineStroke: Dn,
7880
+ offset: Dn,
7881
+ outlineStroke: On,
7819
7882
  polarToCartesian: Tn,
7820
7883
  selectCorners: Bn,
7821
7884
  svgBody: it
@@ -7882,13 +7945,13 @@ function sketchOnPlane(pantographObject, planeInput = "XY", origin = [0, 0, 0])
7882
7945
  const plane = planeInput instanceof Plane
7883
7946
  ? makePlane(planeInput)
7884
7947
  : makePlane(planeInput, origin);
7885
- if (pantographObject instanceof _$2) {
7948
+ if (pantographObject instanceof O$1) {
7886
7949
  return sketchDiagram(pantographObject, plane);
7887
7950
  }
7888
7951
  if (pantographObject instanceof v$1) {
7889
7952
  return sketchFigure(pantographObject, plane);
7890
7953
  }
7891
- if (pantographObject instanceof O) {
7954
+ if (pantographObject instanceof _$2) {
7892
7955
  return sketchStroke(pantographObject, plane);
7893
7956
  }
7894
7957
  if (pantographObject instanceof at$2 ||
@@ -7900,20 +7963,20 @@ function sketchOnPlane(pantographObject, planeInput = "XY", origin = [0, 0, 0])
7900
7963
  }
7901
7964
  throw new Error(`Unsupported object type "${pantographObject.constructor.name}"`);
7902
7965
  }
7903
- function toSVGPaths(shape) {
7904
- if (shape instanceof _$2) {
7905
- return shape.figures.flatMap(toSVGPaths);
7966
+ function svgPathsForShape(shape) {
7967
+ if (shape instanceof O$1) {
7968
+ return shape.figures.flatMap(svgPathsForShape);
7906
7969
  }
7907
7970
  else if (shape instanceof v$1) {
7908
7971
  return shape.allLoops.map((loop) => w(loop));
7909
7972
  }
7910
- else if (shape instanceof O) {
7973
+ else if (shape instanceof _$2) {
7911
7974
  return [w(shape)];
7912
7975
  }
7913
7976
  else if (shape instanceof B$2) {
7914
7977
  return [j$1(shape)];
7915
7978
  }
7916
- else if (jn(shape)) {
7979
+ else if (Hn(shape)) {
7917
7980
  return [`M ${shape.firstPoint.join(" ")} ${s(shape)}`];
7918
7981
  }
7919
7982
  throw new Error(`Failed to export ${shape}`);
@@ -7923,15 +7986,18 @@ function toSVGViewBox(shape) {
7923
7986
  return v(boundingBox);
7924
7987
  }
7925
7988
  function wrapPantograph(pantographObject) {
7926
- const isPantograph = jn(pantographObject) ||
7927
- pantographObject instanceof O ||
7989
+ const isPantograph = Hn(pantographObject) ||
7990
+ pantographObject instanceof _$2 ||
7928
7991
  pantographObject instanceof v$1 ||
7929
- pantographObject instanceof _$2;
7992
+ pantographObject instanceof O$1 ||
7993
+ pantographObject instanceof Drawing;
7930
7994
  if (!isPantograph)
7931
7995
  return pantographObject;
7932
7996
  const shape = pantographObject.mirror();
7997
+ if (pantographObject instanceof Drawing)
7998
+ return pantographObject;
7933
7999
  return {
7934
- toSVGPaths: () => toSVGPaths(shape),
8000
+ toSVGPaths: () => svgPathsForShape(shape),
7935
8001
  toSVGViewBox: () => toSVGViewBox(shape),
7936
8002
  };
7937
8003
  }
@@ -7940,5 +8006,96 @@ function initStudioIntegration() {
7940
8006
  return;
7941
8007
  globalThis.registerShapeStandardizer("pantograph", wrapPantograph);
7942
8008
  }
8009
+ class Drawing {
8010
+ diagram;
8011
+ constructor(diagram = new O$1()) {
8012
+ this.diagram = diagram;
8013
+ }
8014
+ clone() {
8015
+ return new Drawing(this.diagram.clone());
8016
+ }
8017
+ serialize() {
8018
+ return JSON.stringify(It$1(this.diagram));
8019
+ }
8020
+ get boundingBox() {
8021
+ return this.diagram.boundingBox;
8022
+ }
8023
+ get repr() {
8024
+ return JSON.stringify(It$1(this.diagram));
8025
+ }
8026
+ rotate(angle, center) {
8027
+ return new Drawing(this.diagram.rotate(angle, center));
8028
+ }
8029
+ translate(xDist, yDist) {
8030
+ return new Drawing(this.diagram.translate(xDist, yDist));
8031
+ }
8032
+ translateTo(translationVector) {
8033
+ return new Drawing(this.diagram.translateTo(translationVector));
8034
+ }
8035
+ scale(scaleFactor, center) {
8036
+ return new Drawing(this.diagram.scale(scaleFactor, center));
8037
+ }
8038
+ mirror(directionOrAxis, origin) {
8039
+ if (!directionOrAxis || typeof directionOrAxis === "string") {
8040
+ return new Drawing(this.diagram.mirror(directionOrAxis));
8041
+ }
8042
+ return new Drawing(this.diagram.mirror(directionOrAxis, origin));
8043
+ }
8044
+ mirrorCenter(center) {
8045
+ return new Drawing(this.diagram.mirrorCenter(center));
8046
+ }
8047
+ cut(other) {
8048
+ const base = this.diagram;
8049
+ const tool = other.diagram;
8050
+ return new Drawing(Pt(base, tool));
8051
+ }
8052
+ fuse(other) {
8053
+ const base = this.diagram;
8054
+ const tool = other.diagram;
8055
+ return new Drawing(sn(base, tool));
8056
+ }
8057
+ intersect(other) {
8058
+ const base = this.diagram;
8059
+ const tool = other.diagram;
8060
+ return new Drawing(yn(base, tool));
8061
+ }
8062
+ fillet(radius, filter) {
8063
+ return new Drawing(B(this.diagram, radius, filter));
8064
+ }
8065
+ chamfer(radius, filter) {
8066
+ return new Drawing(R(this.diagram, radius, filter));
8067
+ }
8068
+ sketchOnPlane(inputPlane = "XY", origin = [0, 0, 0]) {
8069
+ if (typeof inputPlane !== "string") {
8070
+ return sketchOnPlane(this.diagram, inputPlane);
8071
+ }
8072
+ return sketchOnPlane(this.diagram, inputPlane, origin);
8073
+ }
8074
+ toSVG(margin) {
8075
+ return Rn(this.diagram, { margin });
8076
+ }
8077
+ toSVGViewBox(margin = 1) {
8078
+ return v(this.diagram.boundingBox, margin);
8079
+ }
8080
+ toSVGPaths() {
8081
+ return svgPathsForShape(this.diagram);
8082
+ }
8083
+ offset(distance) {
8084
+ return new Drawing(Dn(this.diagram, distance));
8085
+ }
8086
+ }
8087
+ class ReDrawingPen extends ot$1 {
8088
+ // @ts-expect-error forcing a different type
8089
+ close() {
8090
+ return new Drawing(super.close());
8091
+ }
8092
+ // @ts-expect-error forcing a different type
8093
+ closeWithMirror() {
8094
+ return new Drawing(super.close());
8095
+ }
8096
+ }
8097
+ function redraw(p) {
8098
+ return new ReDrawingPen(p);
8099
+ }
7943
8100
 
7944
- export { drawShape, initStudioIntegration, pantograph, sketchDiagram, sketchFigure, sketchOnPlane, sketchSegment, sketchStroke };
8101
+ export { Drawing, ReDrawingPen, drawShape, initStudioIntegration, pantograph, redraw, sketchDiagram, sketchFigure, sketchOnPlane, sketchSegment, sketchStroke };