pantograph2d 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/Diagram-2450b2e6.js +1750 -0
  2. package/dist/Diagram-2450b2e6.js.map +1 -0
  3. package/dist/Diagram-57e17509.cjs +4 -0
  4. package/dist/Diagram-57e17509.cjs.map +1 -0
  5. package/dist/QuadraticBezier-e116a2d6.js +3647 -0
  6. package/dist/QuadraticBezier-e116a2d6.js.map +1 -0
  7. package/dist/QuadraticBezier-e3d7218b.cjs +9 -0
  8. package/dist/QuadraticBezier-e3d7218b.cjs.map +1 -0
  9. package/dist/algorithms/intersections/arcsCubicBezierIntersection.d.ts +5 -0
  10. package/dist/algorithms/intersections/arcsQuadraticBezierIntersection.d.ts +5 -0
  11. package/dist/algorithms/intersections/bezierClip.d.ts +28 -0
  12. package/dist/algorithms/intersections/cubicBezierCubicBezierIntersection.d.ts +4 -0
  13. package/dist/algorithms/intersections/lineBezierIntersection.d.ts +5 -0
  14. package/dist/algorithms/intersections/quadraticBezierQuadraticBezierIntersection.d.ts +4 -0
  15. package/dist/algorithms/optimisation/Brent.d.ts +6 -0
  16. package/dist/api/svg.d.ts +1 -0
  17. package/dist/draw-27ac6dae.cjs +2 -0
  18. package/dist/draw-27ac6dae.cjs.map +1 -0
  19. package/dist/draw-c7b2705c.js +344 -0
  20. package/dist/draw-c7b2705c.js.map +1 -0
  21. package/dist/{types/draw.d.ts → draw.d.ts} +15 -0
  22. package/dist/export/json/exportJSON.d.ts +393 -0
  23. package/dist/export/json/jsonDiagram.d.ts +135 -0
  24. package/dist/export/json/jsonFigure.d.ts +132 -0
  25. package/dist/export/json/jsonLoop.d.ts +65 -0
  26. package/dist/export/json/jsonSegment.d.ts +62 -0
  27. package/dist/export/svg/api.d.ts +6 -0
  28. package/dist/{types/export → export}/svg/exportSVG.d.ts +5 -5
  29. package/dist/{types/export → export}/svg/wrapSVG.d.ts +1 -1
  30. package/dist/{types/import → import}/json/importJSON.d.ts +3 -1
  31. package/dist/{types/main.d.ts → main.d.ts} +1 -1
  32. package/dist/{types/models → models}/BoundingBox.d.ts +3 -0
  33. package/dist/{types/models → models}/exports.d.ts +4 -0
  34. package/dist/models/segments/CubicBezier.d.ts +31 -0
  35. package/dist/models/segments/QuadraticBezier.d.ts +30 -0
  36. package/dist/models/segments/utils/deCasteljau.d.ts +3 -0
  37. package/dist/models/segments/utils/isSegment.d.ts +8 -0
  38. package/dist/pantograph/drawShape.cjs +1 -1
  39. package/dist/pantograph/drawShape.cjs.map +1 -1
  40. package/dist/pantograph/drawShape.js +12 -11
  41. package/dist/pantograph/drawShape.js.map +1 -1
  42. package/dist/pantograph/models.cjs +1 -1
  43. package/dist/pantograph/models.js +15 -10
  44. package/dist/pantograph/models.js.map +1 -1
  45. package/dist/pantograph/svg.cjs +2 -0
  46. package/dist/pantograph/svg.cjs.map +1 -0
  47. package/dist/pantograph/svg.js +11 -0
  48. package/dist/pantograph/svg.js.map +1 -0
  49. package/dist/pantograph.cjs +2 -8
  50. package/dist/pantograph.cjs.map +1 -1
  51. package/dist/pantograph.js +368 -375
  52. package/dist/pantograph.js.map +1 -1
  53. package/dist/utils/removeDuplicateValues.d.ts +1 -0
  54. package/dist/wrapSVG-02b823ac.cjs +8 -0
  55. package/dist/wrapSVG-02b823ac.cjs.map +1 -0
  56. package/dist/wrapSVG-0ec8a111.js +62 -0
  57. package/dist/wrapSVG-0ec8a111.js.map +1 -0
  58. package/package.json +33 -22
  59. package/dist/Diagram-ab93c8b7.cjs +0 -11
  60. package/dist/Diagram-ab93c8b7.cjs.map +0 -1
  61. package/dist/Diagram-d848c815.js +0 -4252
  62. package/dist/Diagram-d848c815.js.map +0 -1
  63. package/dist/draw-0f591ea4.cjs +0 -2
  64. package/dist/draw-0f591ea4.cjs.map +0 -1
  65. package/dist/draw-a830827a.js +0 -288
  66. package/dist/draw-a830827a.js.map +0 -1
  67. package/dist/types/export/json/exportJSON.d.ts +0 -196
  68. package/dist/types/export/json/jsonDiagram.d.ts +0 -69
  69. package/dist/types/export/json/jsonFigure.d.ts +0 -66
  70. package/dist/types/export/json/jsonLoop.d.ts +0 -32
  71. package/dist/types/export/json/jsonSegment.d.ts +0 -29
  72. /package/dist/{types/algorithms → algorithms}/boolean/figureBooleans.d.ts +0 -0
  73. /package/dist/{types/algorithms → algorithms}/boolean/loopBooleans.d.ts +0 -0
  74. /package/dist/{types/algorithms → algorithms}/boolean/strandBoolean.d.ts +0 -0
  75. /package/dist/{types/algorithms → algorithms}/boolean/strandsBetweenIntersections.d.ts +0 -0
  76. /package/dist/{types/algorithms → algorithms}/distances/arcArcDistance.d.ts +0 -0
  77. /package/dist/{types/algorithms → algorithms}/distances/genericDistance.d.ts +0 -0
  78. /package/dist/{types/algorithms → algorithms}/distances/index.d.ts +0 -0
  79. /package/dist/{types/algorithms → algorithms}/distances/lineArcDistance.d.ts +0 -0
  80. /package/dist/{types/algorithms → algorithms}/distances/lineLineDistance.d.ts +0 -0
  81. /package/dist/{types/algorithms → algorithms}/filletSegments.d.ts +0 -0
  82. /package/dist/{types/algorithms → algorithms}/intersections/arcArcIntersection.d.ts +0 -0
  83. /package/dist/{types/algorithms → algorithms}/intersections/arcEllipseArcIntersection.d.ts +0 -0
  84. /package/dist/{types/algorithms → algorithms}/intersections/ellipseArcEllipseArcIntersection.d.ts +0 -0
  85. /package/dist/{types/algorithms → algorithms}/intersections/ellipseEllipseIntersection.d.ts +0 -0
  86. /package/dist/{types/algorithms → algorithms}/intersections/index.d.ts +0 -0
  87. /package/dist/{types/algorithms → algorithms}/intersections/lineArcIntersection.d.ts +0 -0
  88. /package/dist/{types/algorithms → algorithms}/intersections/lineEllipseArcIntersection.d.ts +0 -0
  89. /package/dist/{types/algorithms → algorithms}/intersections/lineLineIntersection.d.ts +0 -0
  90. /package/dist/{types/algorithms → algorithms}/intersections/rayIntersections.d.ts +0 -0
  91. /package/dist/{types/algorithms → algorithms}/offsets/offsetFigure.d.ts +0 -0
  92. /package/dist/{types/algorithms → algorithms}/offsets/offsetSegment.d.ts +0 -0
  93. /package/dist/{types/algorithms → algorithms}/offsets/offsetStroke.d.ts +0 -0
  94. /package/dist/{types/algorithms → algorithms}/optimisation/DiRect.d.ts +0 -0
  95. /package/dist/{types/algorithms → algorithms}/organiseLoops.d.ts +0 -0
  96. /package/dist/{types/algorithms → algorithms}/simplify.d.ts +0 -0
  97. /package/dist/{types/algorithms → algorithms}/solvers/solvePolynomials.d.ts +0 -0
  98. /package/dist/{types/algorithms → algorithms}/stitchSegments.d.ts +0 -0
  99. /package/dist/{types/api → api}/drawShape.d.ts +0 -0
  100. /package/dist/{types/api → api}/models.d.ts +0 -0
  101. /package/dist/{types/booleanOperations.d.ts → booleanOperations.d.ts} +0 -0
  102. /package/dist/{types/definitions.d.ts → definitions.d.ts} +0 -0
  103. /package/dist/{types/drawShape → drawShape}/drawCircle.d.ts +0 -0
  104. /package/dist/{types/drawShape → drawShape}/drawRect.d.ts +0 -0
  105. /package/dist/{types/export → export}/svg/svgDiagram.d.ts +0 -0
  106. /package/dist/{types/export → export}/svg/svgFigure.d.ts +0 -0
  107. /package/dist/{types/export → export}/svg/svgLoop.d.ts +0 -0
  108. /package/dist/{types/export → export}/svg/svgSegment.d.ts +0 -0
  109. /package/dist/{types/export → export}/svg/svgStrand.d.ts +0 -0
  110. /package/dist/{types/models → models}/Diagram.d.ts +0 -0
  111. /package/dist/{types/models → models}/Figure.d.ts +0 -0
  112. /package/dist/{types/models → models}/Loop.d.ts +0 -0
  113. /package/dist/{types/models → models}/Strand.d.ts +0 -0
  114. /package/dist/{types/models → models}/Stroke.d.ts +0 -0
  115. /package/dist/{types/models → models}/TransformationMatrix.d.ts +0 -0
  116. /package/dist/{types/models → models}/segments/Arc.d.ts +0 -0
  117. /package/dist/{types/models → models}/segments/EllipseArc.d.ts +0 -0
  118. /package/dist/{types/models → models}/segments/Line.d.ts +0 -0
  119. /package/dist/{types/models → models}/segments/Segment.d.ts +0 -0
  120. /package/dist/{types/models → models}/utils/Transformable.d.ts +0 -0
  121. /package/dist/{types/offsetOperations.d.ts → offsetOperations.d.ts} +0 -0
  122. /package/dist/{types/operations.d.ts → operations.d.ts} +0 -0
  123. /package/dist/{types/utils → utils}/allCombinations.d.ts +0 -0
  124. /package/dist/{types/utils → utils}/allPairs.d.ts +0 -0
  125. /package/dist/{types/utils → utils}/angularDistance.d.ts +0 -0
  126. /package/dist/{types/utils → utils}/listOfFigures.d.ts +0 -0
  127. /package/dist/{types/utils → utils}/projectPointOnLine.d.ts +0 -0
  128. /package/dist/{types/utils → utils}/range.d.ts +0 -0
  129. /package/dist/{types/utils → utils}/removeDuplicatePoints.d.ts +0 -0
  130. /package/dist/{types/utils → utils}/unitAngle.d.ts +0 -0
  131. /package/dist/{types/utils → utils}/zip.d.ts +0 -0
  132. /package/dist/{types/vectorOperations.d.ts → vectorOperations.d.ts} +0 -0
@@ -1,206 +1,211 @@
1
- import { o as ht, D } from "./draw-a830827a.js";
2
- import { d as fn } from "./draw-a830827a.js";
3
- import { F as p, L as P, D as h, f as C, r as gt, z as pt, s as dt, a as wt, c as Pt, i as mt, S as y, l as Mt, d as m, b as vt, p as St, n as K, e as $, g as It, h as Lt, j as kt, k as At, m as Q, o as w, A as M, q as j, t as v, u as $t, v as bt, E as O, R as Et } from "./Diagram-d848c815.js";
4
- import { w as un } from "./Diagram-d848c815.js";
5
- function S(t) {
6
- if (t instanceof p)
1
+ var lt = Object.defineProperty;
2
+ var ut = (t, e, n) => e in t ? lt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var p = (t, e, n) => (ut(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { o as gt, D } from "./draw-c7b2705c.js";
5
+ import { d as Pe } from "./draw-c7b2705c.js";
6
+ import { F as d, L as P, D as g, f as B, s as ht, a as pt, c as dt, i as mt, S as C, l as Pt, p as wt, b as Mt, d as X, e as It } from "./Diagram-2450b2e6.js";
7
+ import { g as Me } from "./Diagram-2450b2e6.js";
8
+ import { r as St, z as bt, l as Lt, d as w, n as Y, s as E, a as vt, b as At, p as kt, c as j, L as S, A as b, e as M, t as Et, f as yt, B as Ft, E as Ct, Q as xt, C as Dt } from "./QuadraticBezier-e116a2d6.js";
9
+ import { s as Rt, a as Ot, b as Bt, c as $t, d as Gt, w as z } from "./wrapSVG-0ec8a111.js";
10
+ function I(t) {
11
+ if (t instanceof d)
7
12
  return [t];
8
13
  if (t instanceof P)
9
- return [new p(t)];
10
- if (t instanceof h)
14
+ return [new d(t)];
15
+ if (t instanceof g)
11
16
  return t.figures;
12
17
  throw new Error("Unknown shape");
13
18
  }
14
- function tt(t, n, e = 1e-9) {
19
+ function tt(t, e, n = 1e-9) {
15
20
  let s = [];
16
- const r = [], i = new Array(n.segments.length).fill(0).map(() => []);
17
- n.segments.forEach((c, f) => {
21
+ const r = [], i = new Array(e.segments.length).fill(0).map(() => []);
22
+ e.segments.forEach((c, f) => {
18
23
  t.segments.forEach((a) => {
19
- const { intersections: u, overlaps: d } = C(
24
+ const { intersections: u, overlaps: m } = B(
20
25
  c,
21
26
  a,
22
- e
27
+ n
23
28
  );
24
- s.push(...u), i[f].push(...u), r.push(...d);
25
- const g = d.flatMap((l) => [
29
+ s.push(...u), i[f].push(...u), r.push(...m);
30
+ const h = m.flatMap((l) => [
26
31
  l.firstPoint,
27
32
  l.lastPoint
28
33
  ]);
29
- s.push(...g), i[f].push(...g);
34
+ s.push(...h), i[f].push(...h);
30
35
  });
31
- }), s = gt(s, e);
32
- const o = pt([n.segments, i]).flatMap(([c, f]) => f.length ? c.splitAt(f) : [c]);
36
+ }), s = St(s, n);
37
+ const o = bt([e.segments, i]).flatMap(([c, f]) => f.length ? c.splitAt(f) : [c]);
33
38
  return Array.from(
34
- dt(
39
+ ht(
35
40
  o,
36
41
  s,
37
42
  r
38
43
  )
39
44
  );
40
45
  }
41
- function G(t, n, e = !1) {
42
- return tt(n, t).filter((r) => {
46
+ function $(t, e, n = !1) {
47
+ return tt(e, t).filter((r) => {
43
48
  const i = r.segments[0].midPoint;
44
- return n.onStroke(i) ? !e : !n.contains(i);
49
+ return e.onStroke(i) ? !n : !e.contains(i);
45
50
  });
46
51
  }
47
- function T(t, n, e = !1) {
48
- return tt(n, t).filter((r) => {
52
+ function G(t, e, n = !1) {
53
+ return tt(e, t).filter((r) => {
49
54
  const i = r.segments[0].midPoint;
50
- return n.onStroke(i) ? !e : n.contains(i);
55
+ return e.onStroke(i) ? !n : e.contains(i);
51
56
  });
52
57
  }
53
- function z(t, n, e = !1) {
54
- const s = G(
58
+ function V(t, e, n = !1) {
59
+ const s = $(
55
60
  t,
56
- n.contour,
57
- e
58
- ), r = n.holes.flatMap(
59
- (i) => T(t, i, e)
61
+ e.contour,
62
+ n
63
+ ), r = e.holes.flatMap(
64
+ (i) => G(t, i, n)
60
65
  );
61
66
  return [...s, ...r];
62
67
  }
63
- function q(t, n, e = !1) {
64
- let s = T(
68
+ function _(t, e, n = !1) {
69
+ let s = G(
65
70
  t,
66
- n.contour,
67
- e
71
+ e.contour,
72
+ n
68
73
  );
69
- return n.holes.forEach((r) => {
74
+ return e.holes.forEach((r) => {
70
75
  s = s.flatMap(
71
- (i) => G(i, r, e)
76
+ (i) => $(i, r, n)
72
77
  );
73
78
  }), s;
74
79
  }
75
- function yt(t, n) {
76
- return new h(
77
- wt(S(t), S(n))
80
+ function Tt(t, e) {
81
+ return new g(
82
+ pt(I(t), I(e))
78
83
  );
79
84
  }
80
- function b(t) {
85
+ function y(t) {
81
86
  return t.reduce(
82
- (n, e) => yt(n, e),
83
- new h()
87
+ (e, n) => Tt(e, n),
88
+ new g()
84
89
  );
85
90
  }
86
- function nt(t, n) {
87
- return new h(
88
- Pt(S(t), S(n))
91
+ function et(t, e) {
92
+ return new g(
93
+ dt(I(t), I(e))
89
94
  );
90
95
  }
91
- function Kt(t, n) {
92
- return new h(
93
- mt(S(t), S(n))
96
+ function oe(t, e) {
97
+ return new g(
98
+ mt(I(t), I(e))
94
99
  );
95
100
  }
96
- function Qt(t, n, e = !0) {
97
- if (n instanceof P)
98
- return G(t, n, e);
99
- if (n instanceof p)
100
- return z(t, n, e);
101
- let s = [new y([...t.segments])];
102
- return n.figures.forEach((r) => {
103
- s = s.flatMap((i) => z(i, r, e));
101
+ function ae(t, e, n = !0) {
102
+ if (e instanceof P)
103
+ return $(t, e, n);
104
+ if (e instanceof d)
105
+ return V(t, e, n);
106
+ let s = [new C([...t.segments])];
107
+ return e.figures.forEach((r) => {
108
+ s = s.flatMap((i) => V(i, r, n));
104
109
  }), s;
105
110
  }
106
- function jt(t, n, e = !1) {
107
- if (n instanceof P)
108
- return T(t, n, e);
109
- if (n instanceof p)
110
- return q(t, n, e);
111
- let s = [new y([...t.segments])];
112
- return n.figures.forEach((r) => {
113
- s = s.flatMap((i) => q(i, r, e));
111
+ function ce(t, e, n = !1) {
112
+ if (e instanceof P)
113
+ return G(t, e, n);
114
+ if (e instanceof d)
115
+ return _(t, e, n);
116
+ let s = [new C([...t.segments])];
117
+ return e.figures.forEach((r) => {
118
+ s = s.flatMap((i) => _(i, r, n));
114
119
  }), s;
115
120
  }
116
121
  function N(t) {
117
122
  return t < 0 ? "before" : t > 1 ? "after" : "between";
118
123
  }
119
- const _ = (t, n, e) => {
120
- if (e === "before")
121
- return t.distanceFrom(n.firstPoint);
122
- if (e === "after")
123
- return t.distanceFrom(n.lastPoint);
124
+ const q = (t, e, n) => {
125
+ if (n === "before")
126
+ return t.distanceFrom(e.firstPoint);
127
+ if (n === "after")
128
+ return t.distanceFrom(e.lastPoint);
124
129
  throw new Error("Invalid position");
125
130
  };
126
- function Ft(t, n) {
127
- const e = Mt(t, n);
128
- if (e === "parallel")
131
+ function Ut(t, e) {
132
+ const n = Lt(t, e);
133
+ if (n === "parallel")
129
134
  return Math.min(
130
- t.distanceFrom(n.firstPoint),
131
- t.distanceFrom(n.lastPoint)
135
+ t.distanceFrom(e.firstPoint),
136
+ t.distanceFrom(e.lastPoint)
132
137
  );
133
- const { intersectionParam1: s, intersectionParam2: r } = e, i = N(s), o = N(r);
138
+ const { intersectionParam1: s, intersectionParam2: r } = n, i = N(s), o = N(r);
134
139
  if (i === "between" && o === "between")
135
140
  return 0;
136
141
  if (i === "between" && o !== "between")
137
- return _(t, n, o);
142
+ return q(t, e, o);
138
143
  if (o === "between" && i !== "between")
139
- return _(n, t, i);
144
+ return q(e, t, i);
140
145
  if (i === "before" && o === "before")
141
- return m(t.firstPoint, n.firstPoint);
146
+ return w(t.firstPoint, e.firstPoint);
142
147
  if (i === "after" && o === "after")
143
- return m(t.lastPoint, n.lastPoint);
148
+ return w(t.lastPoint, e.lastPoint);
144
149
  if (i === "before" && o === "after")
145
- return m(t.firstPoint, n.lastPoint);
150
+ return w(t.firstPoint, e.lastPoint);
146
151
  if (i === "after" && o === "before")
147
- return m(t.lastPoint, n.firstPoint);
152
+ return w(t.lastPoint, e.firstPoint);
148
153
  throw new Error("Invalid position");
149
154
  }
150
- function J(t, n) {
151
- if (vt(t, n).length > 0)
155
+ function J(t, e) {
156
+ if (Pt(t, e).length > 0)
152
157
  return 0;
153
- const e = St(t, n.center);
154
- if (t.isOnSegment(e)) {
155
- const s = m(e, n.center);
156
- if (Math.abs(s - n.radius) < t.precision && n.isOnSegment(e))
158
+ const n = wt(t, e.center);
159
+ if (t.isOnSegment(n)) {
160
+ const s = w(n, e.center);
161
+ if (Math.abs(s - e.radius) < t.precision && e.isOnSegment(n))
157
162
  return 0;
158
- if (s - n.radius > t.precision) {
159
- const r = K(
160
- $(e, n.center)
161
- ), i = It(
162
- n.center,
163
- Lt(r, n.radius)
163
+ if (s - e.radius > t.precision) {
164
+ const r = Y(
165
+ E(n, e.center)
166
+ ), i = vt(
167
+ e.center,
168
+ At(r, e.radius)
164
169
  );
165
- if (n.isOnSegment(i))
166
- return m(i, e);
170
+ if (e.isOnSegment(i))
171
+ return w(i, n);
167
172
  }
168
173
  }
169
174
  return Math.min(
170
- n.distanceFrom(t.firstPoint),
171
- n.distanceFrom(t.lastPoint),
172
- t.distanceFrom(n.firstPoint),
173
- t.distanceFrom(n.lastPoint)
175
+ e.distanceFrom(t.firstPoint),
176
+ e.distanceFrom(t.lastPoint),
177
+ t.distanceFrom(e.firstPoint),
178
+ t.distanceFrom(e.lastPoint)
174
179
  );
175
180
  }
176
- const Dt = (t, n) => {
177
- const e = t.angleToParam(n.firstAngle);
178
- if (t.isValidParameter(e))
181
+ const zt = (t, e) => {
182
+ const n = t.angleToParam(e.firstAngle);
183
+ if (t.isValidParameter(n))
179
184
  return !0;
180
- const s = t.angleToParam(n.lastAngle);
185
+ const s = t.angleToParam(e.lastAngle);
181
186
  return !!t.isValidParameter(s);
182
187
  };
183
- function xt(t, n) {
184
- if (kt(t, n, !0).length > 0)
188
+ function Vt(t, e) {
189
+ if (Mt(t, e, !0).length > 0)
185
190
  return 0;
186
- const e = m(t.center, n.center);
187
- if (e < t.precision && Dt(t, n))
188
- return Math.abs(t.radius - n.radius);
189
- const s = K($(n.center, t.center)), r = e - Math.abs(t.radius - n.radius) < t.precision;
190
- let i = At(s);
191
- r && n.radius > t.radius && (i += Math.PI);
192
- const o = r ? i : i + Math.PI, c = t.angleToParam(i), f = n.angleToParam(o);
193
- return t.isValidParameter(c) && n.isValidParameter(f) ? m(t.paramPoint(c), n.paramPoint(f)) : Math.min(
194
- t.distanceFrom(n.firstPoint),
195
- t.distanceFrom(n.lastPoint),
196
- n.distanceFrom(t.firstPoint),
197
- n.distanceFrom(t.lastPoint)
191
+ const n = w(t.center, e.center);
192
+ if (n < t.precision && zt(t, e))
193
+ return Math.abs(t.radius - e.radius);
194
+ const s = Y(E(e.center, t.center)), r = n - Math.abs(t.radius - e.radius) < t.precision;
195
+ let i = kt(s);
196
+ r && e.radius > t.radius && (i += Math.PI);
197
+ const o = r ? i : i + Math.PI, c = t.angleToParam(i), f = e.angleToParam(o);
198
+ return t.isValidParameter(c) && e.isValidParameter(f) ? w(t.paramPoint(c), e.paramPoint(f)) : Math.min(
199
+ t.distanceFrom(e.firstPoint),
200
+ t.distanceFrom(e.lastPoint),
201
+ e.distanceFrom(t.firstPoint),
202
+ e.distanceFrom(t.lastPoint)
198
203
  );
199
204
  }
200
- function Rt(t, n, e) {
205
+ function _t(t, e, n) {
201
206
  let s = 0, r = t.length - 1;
202
207
  for (; s <= r; ) {
203
- const i = Math.floor((s + r) / 2), o = e(t[i], n);
208
+ const i = Math.floor((s + r) / 2), o = n(t[i], e);
204
209
  if (o < 0)
205
210
  s = i + 1;
206
211
  else if (o > 0)
@@ -210,144 +215,155 @@ function Rt(t, n, e) {
210
215
  }
211
216
  return -(s + 1);
212
217
  }
213
- function Ct(t, n, e) {
214
- const s = Rt(t, n, e);
215
- s < 0 ? t.splice(-(s + 1), 0, n) : t.splice(s, 0, n);
218
+ function Nt(t, e, n) {
219
+ const s = _t(t, e, n);
220
+ s < 0 ? t.splice(-(s + 1), 0, e) : t.splice(s, 0, e);
216
221
  }
217
- class Ot {
222
+ class qt {
218
223
  constructor() {
224
+ p(this, "buckets");
219
225
  this.buckets = [];
220
226
  }
221
- addInterval(n) {
222
- const e = this.buckets[n.rectangle.diagonalBucketIndex];
223
- e === void 0 ? this.buckets[n.rectangle.diagonalBucketIndex] = [n] : Ct(e, n, (s, r) => s.value - r.value);
227
+ addInterval(e) {
228
+ const n = this.buckets[e.rectangle.diagonalBucketIndex];
229
+ n === void 0 ? this.buckets[e.rectangle.diagonalBucketIndex] = [e] : Nt(n, e, (s, r) => s.value - r.value);
224
230
  }
225
- removeInterval(n) {
226
- const e = this.buckets[n.rectangle.diagonalBucketIndex];
227
- if (e === void 0)
231
+ removeInterval(e) {
232
+ const n = this.buckets[e.rectangle.diagonalBucketIndex];
233
+ if (n === void 0)
228
234
  throw new Error("Interval not found");
229
- e.shift();
235
+ n.shift();
230
236
  }
231
237
  getBottomRightHullIntervals() {
232
- const n = [];
233
- for (let e = this.buckets.length - 1; e >= 0; e--) {
234
- const s = this.buckets[e];
238
+ const e = [];
239
+ for (let n = this.buckets.length - 1; n >= 0; n--) {
240
+ const s = this.buckets[n];
235
241
  if (!s === void 0)
236
242
  continue;
237
243
  const r = s[0];
238
244
  if (r !== void 0) {
239
- if (!n.length) {
240
- n.push(r);
245
+ if (!e.length) {
246
+ e.push(r);
241
247
  continue;
242
248
  }
243
- for (; n.length && n[n.length - 1].value >= r.value; )
244
- n.pop();
245
- for (; n.length >= 2; ) {
246
- const i = n[n.length - 1], o = n[n.length - 2], c = (r.value - o.value) / ((r.rectangle.diagonal - o.rectangle.diagonal) * 2);
249
+ for (; e.length && e[e.length - 1].value >= r.value; )
250
+ e.pop();
251
+ for (; e.length >= 2; ) {
252
+ const i = e[e.length - 1], o = e[e.length - 2], c = (r.value - o.value) / ((r.rectangle.diagonal - o.rectangle.diagonal) * 2);
247
253
  if (o.value + (i.rectangle.diagonal - o.rectangle.diagonal) / 2 * c < i.value)
248
- n.pop();
254
+ e.pop();
249
255
  else
250
256
  break;
251
257
  }
252
- n.push(r);
258
+ e.push(r);
253
259
  }
254
260
  }
255
- return n;
261
+ return e;
256
262
  }
257
263
  }
258
- class Gt {
259
- constructor(n, e) {
260
- this.x = n, this.y = e, this.xLength = Math.pow(3, -n), this.yLength = Math.pow(3, -e), this.diagonal = Math.sqrt(
264
+ class Jt {
265
+ constructor(e, n) {
266
+ p(this, "diagonal");
267
+ p(this, "diagonalBucketIndex");
268
+ p(this, "xLength");
269
+ p(this, "yLength");
270
+ p(this, "index");
271
+ this.x = e, this.y = n, this.xLength = Math.pow(3, -e), this.yLength = Math.pow(3, -n), this.diagonal = Math.sqrt(
261
272
  this.xLength * this.xLength + this.yLength * this.yLength
262
- ), this.diagonalBucketIndex = n + e, this.index = `${n},${e}`;
273
+ ), this.diagonalBucketIndex = e + n, this.index = `${e},${n}`;
263
274
  }
264
275
  }
265
- class Tt {
266
- constructor(n, e = 1e-8, s = 1e3, r = 1e-6) {
267
- this.fcn = n, this.endTolerance = e, this.maxIterations = s, this.epsilon = r, this.fcn = n, this.epsilon = r, this.endTolerance = e, this.maxIterations = s, this.rectangles = /* @__PURE__ */ new Map(), this.buckets = new Ot();
276
+ class Qt {
277
+ constructor(e, n = 1e-8, s = 1e3, r = 1e-6) {
278
+ p(this, "rectangles");
279
+ p(this, "buckets");
280
+ p(this, "fMin");
281
+ p(this, "argMin");
282
+ p(this, "tol");
283
+ this.fcn = e, this.endTolerance = n, this.maxIterations = s, this.epsilon = r, this.fcn = e, this.epsilon = r, this.endTolerance = n, this.maxIterations = s, this.rectangles = /* @__PURE__ */ new Map(), this.buckets = new qt();
268
284
  const i = [0.5, 0.5], o = this.rect(0, 0), c = this.fcn(i);
269
- this.buckets.addInterval(new A(i, c, o)), this.fMin = c, this.argMin = i, this.tol = o.diagonal;
285
+ this.buckets.addInterval(new k(i, c, o)), this.fMin = c, this.argMin = i, this.tol = o.diagonal;
270
286
  }
271
- registerInterval(n) {
272
- this.buckets.addInterval(n), n.value <= this.fMin && (this.fMin = n.value, this.argMin = n.center, this.tol = n.rectangle.diagonal);
287
+ registerInterval(e) {
288
+ this.buckets.addInterval(e), e.value <= this.fMin && (this.fMin = e.value, this.argMin = e.center, this.tol = e.rectangle.diagonal);
273
289
  }
274
- rect(n, e) {
275
- const s = `${n},${e}`;
276
- return this.rectangles.has(s) || this.rectangles.set(s, new Gt(n, e)), this.rectangles.get(s);
290
+ rect(e, n) {
291
+ const s = `${e},${n}`;
292
+ return this.rectangles.has(s) || this.rectangles.set(s, new Jt(e, n)), this.rectangles.get(s);
277
293
  }
278
- splitInterval(n) {
279
- let e, s, r;
280
- const [i, o] = n.center;
281
- return n.rectangle.x <= n.rectangle.y ? (e = this.rect(n.rectangle.x + 1, n.rectangle.y), s = [i - e.xLength, o], r = [i + e.xLength, o]) : (e = this.rect(n.rectangle.x, n.rectangle.y + 1), s = [i, o - e.yLength], r = [i, o + e.yLength]), [
282
- new A(s, this.fcn(s), e),
283
- new A(n.center, n.value, e),
284
- new A(r, this.fcn(r), e)
294
+ splitInterval(e) {
295
+ let n, s, r;
296
+ const [i, o] = e.center;
297
+ return e.rectangle.x <= e.rectangle.y ? (n = this.rect(e.rectangle.x + 1, e.rectangle.y), s = [i - n.xLength, o], r = [i + n.xLength, o]) : (n = this.rect(e.rectangle.x, e.rectangle.y + 1), s = [i, o - n.yLength], r = [i, o + n.yLength]), [
298
+ new k(s, this.fcn(s), n),
299
+ new k(e.center, e.value, n),
300
+ new k(r, this.fcn(r), n)
285
301
  ];
286
302
  }
287
303
  single_iteration() {
288
- const n = this.buckets.getBottomRightHullIntervals();
289
- for (; n.length >= 2; ) {
290
- const e = n[0], s = n[1], r = (s.value - e.value) / ((s.rectangle.diagonal - e.rectangle.diagonal) / 2), i = e.value - r * s.value / 2;
304
+ const e = this.buckets.getBottomRightHullIntervals();
305
+ for (; e.length >= 2; ) {
306
+ const n = e[0], s = e[1], r = (s.value - n.value) / ((s.rectangle.diagonal - n.rectangle.diagonal) / 2), i = n.value - r * s.value / 2;
291
307
  if ((this.fMin - i) / Math.abs(this.fMin) < this.epsilon)
292
- n.shift();
308
+ e.shift();
293
309
  else
294
310
  break;
295
311
  }
296
- n.forEach((e) => {
297
- this.buckets.removeInterval(e);
312
+ e.forEach((n) => {
313
+ this.buckets.removeInterval(n);
298
314
  });
299
- for (const e of n) {
300
- const [s, r, i] = this.splitInterval(e);
315
+ for (const n of e) {
316
+ const [s, r, i] = this.splitInterval(n);
301
317
  this.registerInterval(s), this.registerInterval(r), this.registerInterval(i);
302
318
  }
303
319
  }
304
320
  run() {
305
- let n = 0;
306
- for (; this.tol > this.endTolerance / 2 && (this.single_iteration(), n++, !(n > this.maxIterations)); )
321
+ let e = 0;
322
+ for (; this.tol > this.endTolerance / 2 && (this.single_iteration(), e++, !(e > this.maxIterations)); )
307
323
  ;
308
324
  return {
309
325
  fMin: this.fMin,
310
326
  argMin: this.argMin,
311
327
  tol: this.tol,
312
- iterations: n
328
+ iterations: e
313
329
  };
314
330
  }
315
331
  }
316
- class A {
317
- constructor(n, e, s) {
318
- this.center = n, this.value = e, this.rectangle = s;
332
+ class k {
333
+ constructor(e, n, s) {
334
+ this.center = e, this.value = n, this.rectangle = s;
319
335
  }
320
336
  }
321
- function Vt(t, n = 1e-8, e = 1e3, s = 1e-6) {
322
- return new Tt(
337
+ function Zt(t, e = 1e-8, n = 1e3, s = 1e-6) {
338
+ return new Qt(
323
339
  t,
324
- n,
325
340
  e,
341
+ n,
326
342
  s
327
343
  ).run();
328
344
  }
329
- function Ut(t, n, e = 1e-9) {
330
- const s = Vt((r) => {
331
- const i = t.paramPoint(r[0]), o = n.paramPoint(r[1]);
332
- return Q(i, o);
333
- }, e);
345
+ function Ht(t, e, n = 1e-9) {
346
+ const s = Zt((r) => {
347
+ const i = t.paramPoint(r[0]), o = e.paramPoint(r[1]);
348
+ return j(i, o);
349
+ }, n);
334
350
  return Math.sqrt(s.fMin);
335
351
  }
336
- function Bt(t, n) {
337
- return t instanceof w && n instanceof w ? Ft(t, n) : t instanceof w && n instanceof M ? J(t, n) : t instanceof M && n instanceof w ? J(n, t) : t instanceof M && n instanceof M ? xt(t, n) : Ut(t, n);
352
+ function Wt(t, e) {
353
+ return t instanceof S && e instanceof S ? Ut(t, e) : t instanceof S && e instanceof b ? J(t, e) : t instanceof b && e instanceof S ? J(e, t) : t instanceof b && e instanceof b ? Vt(t, e) : Ht(t, e);
338
354
  }
339
- const V = 1e-8;
340
- function x(t, n, e = !0) {
355
+ const T = 1e-8;
356
+ function R(t, e, n = !0) {
341
357
  const s = t.map((a) => ({
342
- offset: ht(a, n),
358
+ offset: gt(a, e),
343
359
  original: a
344
360
  })), r = [];
345
- let i = e ? null : s.at(-1), o = e ? s.at(-1) : null;
361
+ let i = n ? null : s.at(-1), o = n ? s.at(-1) : null;
346
362
  if (r.length === 1)
347
363
  return r;
348
364
  const c = (a) => {
349
- i ? a.offset instanceof D ? v(a.offset.firstPoint, a.offset.lastPoint) || r.push(
350
- new w(a.offset.firstPoint, a.offset.lastPoint)
365
+ i ? a.offset instanceof D ? M(a.offset.firstPoint, a.offset.lastPoint) || r.push(
366
+ new S(a.offset.firstPoint, a.offset.lastPoint)
351
367
  ) : r.push(a.offset) : i = a;
352
368
  }, f = function* () {
353
369
  for (const a of s.slice(0, -1))
@@ -361,107 +377,107 @@ function x(t, n, e = !0) {
361
377
  o = a;
362
378
  continue;
363
379
  }
364
- const u = o.offset.lastPoint, d = a.offset.firstPoint;
365
- if (v(u, d)) {
380
+ const u = o.offset.lastPoint, m = a.offset.firstPoint;
381
+ if (M(u, m)) {
366
382
  c(o), o = a;
367
383
  continue;
368
384
  }
369
- let g = [];
385
+ let h = [];
370
386
  if (!(o.offset instanceof D) && !(a.offset instanceof D)) {
371
- const { intersections: I, overlaps: F } = C(
387
+ const { intersections: L, overlaps: x } = B(
372
388
  o.offset,
373
389
  a.offset,
374
- V / 100
390
+ T / 100
375
391
  );
376
- g = [
377
- ...I,
378
- ...F.flatMap((L) => [L.firstPoint, L.lastPoint])
392
+ h = [
393
+ ...L,
394
+ ...x.flatMap((v) => [v.firstPoint, v.lastPoint])
379
395
  ];
380
396
  }
381
- if (g.length > 0) {
382
- let I = g[0];
383
- if (g.length > 1) {
384
- const lt = o == null ? void 0 : o.original.lastPoint, B = g.map(
385
- (ut) => Q(ut, lt)
397
+ if (h.length > 0) {
398
+ let L = h[0];
399
+ if (h.length > 1) {
400
+ const ct = o == null ? void 0 : o.original.lastPoint, U = h.map(
401
+ (ft) => j(ft, ct)
386
402
  );
387
- I = g[B.indexOf(Math.min(...B))];
403
+ L = h[U.indexOf(Math.min(...U))];
388
404
  }
389
- const F = o.offset.splitAt([
390
- I
391
- ])[0], L = a.offset.splitAt([I]).at(-1);
392
- if (!L)
405
+ const x = o.offset.splitAt([
406
+ L
407
+ ])[0], v = a.offset.splitAt([L]).at(-1);
408
+ if (!v)
393
409
  throw new Error("Bug in the splitting algo in offset");
394
410
  c({
395
- offset: F,
411
+ offset: x,
396
412
  original: o.original
397
- }), o = { offset: L, original: a.original };
413
+ }), o = { offset: v, original: a.original };
398
414
  continue;
399
415
  }
400
- const l = o.original.lastPoint, k = bt(
401
- $(d, l),
402
- $(u, l)
403
- ) > 0, ft = new M(u, d, l, k);
404
- c(o), r.push(ft), o = a;
416
+ const l = o.original.lastPoint, A = yt(
417
+ E(m, l),
418
+ E(u, l)
419
+ ) > 0, at = new b(u, m, l, A);
420
+ c(o), r.push(at), o = a;
405
421
  }
406
422
  return o && c(o), r;
407
423
  }
408
- function et(t) {
409
- const n = /* @__PURE__ */ new Map(), e = (s, r) => {
410
- const i = n.get(s) || [];
411
- n.set(s, [...i, ...r]);
424
+ function nt(t) {
425
+ const e = /* @__PURE__ */ new Map(), n = (s, r) => {
426
+ const i = e.get(s) || [];
427
+ e.set(s, [...i, ...r]);
412
428
  };
413
429
  return t.forEach((s, r) => {
414
430
  t.slice(r + 1).forEach((i, o) => {
415
- const { intersections: c, overlaps: f } = C(s, i, V), a = [
431
+ const { intersections: c, overlaps: f } = B(s, i, T), a = [
416
432
  ...c,
417
433
  ...f.flatMap((u) => [u.firstPoint, u.lastPoint])
418
434
  ].filter((u) => {
419
- const d = v(u, s.firstPoint) || v(u, s.lastPoint), g = v(u, i.firstPoint) || v(u, i.lastPoint);
420
- return !(d && g);
435
+ const m = M(u, s.firstPoint) || M(u, s.lastPoint), h = M(u, i.firstPoint) || M(u, i.lastPoint);
436
+ return !(m && h);
421
437
  });
422
- a.length && (e(r, a), e(o + r + 1, a));
438
+ a.length && (n(r, a), n(o + r + 1, a));
423
439
  });
424
- }), n;
440
+ }), e;
425
441
  }
426
- function st(t, n) {
427
- return n.flatMap((e, s) => {
442
+ function st(t, e) {
443
+ return e.flatMap((n, s) => {
428
444
  if (!t.has(s))
429
- return e;
445
+ return n;
430
446
  const r = t.get(s);
431
- return r ? e.splitAt(r) : e;
447
+ return r ? n.splitAt(r) : n;
432
448
  });
433
449
  }
434
- function it(t, n, e) {
435
- return t.filter((s) => !n.segments.some((i) => Bt(i, s) < Math.abs(e) - V));
450
+ function it(t, e, n) {
451
+ return t.filter((s) => !e.segments.some((i) => Wt(i, s) < Math.abs(n) - T));
436
452
  }
437
- function E(t, n) {
438
- const e = t.clockwise ? n : -n, s = x(t.segments, e);
453
+ function F(t, e) {
454
+ const n = t.clockwise ? e : -e, s = R(t.segments, n);
439
455
  if (s.length < 2)
440
- return new h();
441
- const r = et(s);
456
+ return new g();
457
+ const r = nt(s);
442
458
  if (!r.size) {
443
459
  const a = new P(s);
444
- return new h([new p(a)]);
460
+ return new g([new d(a)]);
445
461
  }
446
462
  const i = st(
447
463
  r,
448
464
  s
449
- ), o = it(i, t, n);
465
+ ), o = it(i, t, e);
450
466
  if (!o.length)
451
- return new h();
452
- const f = j(o).filter((a) => a.length > 1).filter((a) => v(a[0].firstPoint, a.at(-1).lastPoint)).map((a) => new P(a));
453
- return f.length ? new h(f.map((a) => new p(a))) : new h();
467
+ return new g();
468
+ const f = X(o).filter((a) => a.length > 1).filter((a) => M(a[0].firstPoint, a.at(-1).lastPoint)).map((a) => new P(a));
469
+ return f.length ? new g(f.map((a) => new d(a))) : new g();
454
470
  }
455
- function zt(t, n, e = "round") {
456
- const s = n / 2, r = x(t.segments, s, !1), i = x(t.segments, -s, !1).map(
471
+ function Kt(t, e, n = "round") {
472
+ const s = e / 2, r = R(t.segments, s, !1), i = R(t.segments, -s, !1).map(
457
473
  (l) => l.reverse()
458
474
  );
459
475
  i.reverse();
460
- const o = (l, k) => e === "round" ? $t(
476
+ const o = (l, A) => n === "round" ? Et(
461
477
  l.lastPoint,
462
- k.firstPoint,
478
+ A.firstPoint,
463
479
  l.tangentAtLastPoint
464
- ) : new w(l.lastPoint, k.firstPoint), c = [
480
+ ) : new S(l.lastPoint, A.firstPoint), c = [
465
481
  ...r,
466
482
  o(
467
483
  r[r.length - 1],
@@ -472,130 +488,94 @@ function zt(t, n, e = "round") {
472
488
  i[i.length - 1],
473
489
  r[0]
474
490
  )
475
- ], f = et(c);
491
+ ], f = nt(c);
476
492
  if (!f.size) {
477
493
  const l = new P(c);
478
- return new h([new p(l)]);
494
+ return new g([new d(l)]);
479
495
  }
480
496
  const a = st(
481
497
  f,
482
498
  c
483
499
  ), u = it(a, t, s);
484
500
  if (!u.length)
485
- return new h();
486
- const g = j(u).filter((l) => l.length > 1).filter((l) => v(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new P(l));
487
- return g.length ? new h(g.map((l) => new p(l))) : new h();
488
- }
489
- function qt(t, n) {
490
- const e = t.map((s) => {
491
- const r = b(
492
- s.holes.map((i) => E(i, n))
501
+ return new g();
502
+ const h = X(u).filter((l) => l.length > 1).filter((l) => M(l[0].firstPoint, l.at(-1).lastPoint)).map((l) => new P(l));
503
+ return h.length ? new g(h.map((l) => new d(l))) : new g();
504
+ }
505
+ function Xt(t, e) {
506
+ const n = t.map((s) => {
507
+ const r = y(
508
+ s.holes.map((i) => F(i, e))
493
509
  );
494
- return nt(E(s.contour, n), r);
510
+ return et(F(s.contour, e), r);
495
511
  });
496
- return b(e);
512
+ return y(n);
497
513
  }
498
- function Nt(t, n) {
499
- const e = Math.abs(n / 2), s = t.map(
500
- (r) => b(
501
- r.allLoops.map((i) => nt(E(i, e), E(i, -e)))
514
+ function Yt(t, e) {
515
+ const n = Math.abs(e / 2), s = t.map(
516
+ (r) => y(
517
+ r.allLoops.map((i) => et(F(i, n), F(i, -n)))
502
518
  )
503
519
  );
504
- return b(s);
520
+ return y(s);
505
521
  }
506
- function tn(t, n) {
507
- return qt(S(t), n);
522
+ function fe(t, e) {
523
+ return Xt(I(t), e);
508
524
  }
509
- function nn(t, n, { endCap: e = "round" } = {}) {
510
- return t instanceof y ? zt(t, n, e) : Nt(S(t), n);
511
- }
512
- function U(t) {
513
- if (t instanceof w)
514
- return `L ${t.lastPoint.join(" ")}`;
515
- if (t instanceof M)
516
- return `A ${t.radius} ${t.radius} 0 ${t.angularLength > Math.PI ? "1" : "0"} ${t.clockwise ? "0" : "1"} ${t.lastPoint.join(" ")}`;
517
- if (t instanceof O)
518
- return `A ${t.majorRadius} ${t.minorRadius} ${t.tiltAngle * Et} ${t.deltaAngle > Math.PI ? "1" : "0"} ${t.clockwise ? "0" : "1"} ${t.lastPoint.join(" ")}`;
519
- throw new Error("Unknown segment type");
525
+ function le(t, e, { endCap: n = "round" } = {}) {
526
+ return t instanceof C ? Kt(t, e, n) : Yt(I(t), e);
520
527
  }
521
- function rt(t) {
522
- const n = `M ${t.firstPoint.join(" ")}`, e = t.segments.map(U).join(" ");
523
- return `${n} ${e} Z`;
524
- }
525
- function ot(t) {
526
- return `<path d="${t.allLoops.map(rt).join(" ")}" />`;
527
- }
528
- function _t(t) {
529
- return `<g>
530
- ${t.figures.map(ot).join(`
531
- `)}
532
- </g>`;
533
- }
534
- function Jt(t) {
535
- const n = `M ${t.firstPoint.join(" ")}`, e = t.segments.map(U).join(" ");
536
- return `${n} ${e}`;
537
- }
538
- function Ht(t, n = 1) {
539
- const e = t.xMin - n, s = t.yMin - n;
540
- return `${e} ${s} ${t.width + 2 * n} ${t.height + 2 * n}`;
541
- }
542
- function H(t, n, e = 1, s) {
543
- const r = Ht(n, e), i = s ? `width="${n.width + 2 * e}${s}" height="${n.height + 2 * e}${s}"` : "";
544
- return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
545
- <svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="${r}" fill="none" stroke="black" stroke-width="0.2%" vector-effect="non-scaling-stroke" ${i}>
546
- ${t}
547
- </svg>`;
548
- }
549
- function W(t) {
550
- if (t instanceof h)
551
- return _t(t);
552
- if (t instanceof p)
553
- return ot(t);
528
+ function Q(t) {
529
+ if (t instanceof g)
530
+ return Rt(t);
531
+ if (t instanceof d)
532
+ return Ot(t);
554
533
  if (t instanceof P)
555
- return `<path d="${rt(t)}" />`;
556
- if (t instanceof y)
557
- return `<path d="${Jt(t)}" />`;
558
- if (t instanceof M || t instanceof w || t instanceof O)
559
- return `<path d="${`M ${t.firstPoint.join(" ")}`} ${U(
534
+ return `<path d="${Bt(t)}" />`;
535
+ if (t instanceof C)
536
+ return `<path d="${$t(t)}" />`;
537
+ if (It(t))
538
+ return `<path d="${`M ${t.firstPoint.join(" ")}`} ${Gt(
560
539
  t
561
540
  )}" />`;
562
541
  throw new Error("Unknown shape type");
563
542
  }
564
- const X = (t) => "shape" in t ? t.shape : t, Y = (t, n) => {
543
+ const Z = (t) => "shape" in t ? t.shape : t, H = (t, e) => {
565
544
  if (!("shape" in t))
566
- return n;
567
- const { color: e } = t;
568
- return e ? `<g stroke="${e}">${n}</g>` : n;
569
- };
570
- function en(t, {
571
- margin: n = 1,
572
- unit: e = null
545
+ return e;
546
+ const { color: n } = t;
547
+ return n ? `<g stroke="${n}">${e}</g>` : e;
548
+ }, W = (t) => new Ft(t.xMin, -t.yMax, t.xMax, -t.yMin);
549
+ function ue(t, {
550
+ margin: e = 1,
551
+ unit: n = null,
552
+ viewBox: s
573
553
  } = {}) {
574
554
  if (Array.isArray(t)) {
575
- const r = t.map((c) => X(c).mirror()), i = r.map((c, f) => Y(t[f], W(c))).join(`
576
- `), o = r.slice(1).reduce((c, f) => c.merge(f.boundingBox), r[0].boundingBox);
577
- return H(i, o, n, e);
555
+ const i = t.map((f) => Z(f).mirror()), o = i.map((f, a) => H(t[a], Q(f))).join(`
556
+ `), c = i.slice(1).reduce((f, a) => f.merge(a.boundingBox), i[0].boundingBox);
557
+ return z(o, s ? W(s) : c, e, n);
578
558
  }
579
- const s = X(t).mirror();
580
- return H(
581
- Y(t, W(s)),
582
- s.boundingBox,
583
- n,
584
- e
559
+ const r = Z(t).mirror();
560
+ return z(
561
+ H(t, Q(r)),
562
+ s ? W(s) : r.boundingBox,
563
+ e,
564
+ n
585
565
  );
586
566
  }
587
- const at = (t) => {
567
+ const rt = (t) => {
588
568
  if (t.type === "LINE")
589
- return new w(t.firstPoint, t.lastPoint);
569
+ return new S(t.firstPoint, t.lastPoint);
590
570
  if (t.type === "ARC")
591
- return new M(
571
+ return new b(
592
572
  t.firstPoint,
593
573
  t.lastPoint,
594
574
  t.center,
595
575
  t.clockwise
596
576
  );
597
577
  if (t.type === "ELLIPSE_ARC")
598
- return new O(
578
+ return new Ct(
599
579
  t.firstPoint,
600
580
  t.lastPoint,
601
581
  t.center,
@@ -605,54 +585,67 @@ const at = (t) => {
605
585
  t.clockwise,
606
586
  { angleUnits: "rad" }
607
587
  );
588
+ if (t.type === "QUADRATIC_BEZIER")
589
+ return new xt(
590
+ t.firstPoint,
591
+ t.lastPoint,
592
+ t.controlPoint
593
+ );
594
+ if (t.type === "CUBIC_BEZIER")
595
+ return new Dt(
596
+ t.firstPoint,
597
+ t.lastPoint,
598
+ t.firstControlPoint,
599
+ t.lastControlPoint
600
+ );
608
601
  throw new Error("Unknown segment type");
609
- }, R = (t) => {
610
- const n = t.segments.map(at);
611
- return new P(n);
612
- }, ct = (t) => {
613
- const n = R(t.contour), e = t.holes.map(R);
614
- return new p(n, e);
615
- }, Wt = (t) => {
616
- const n = t.figures.map(ct);
617
- return new h(n);
602
+ }, O = (t) => {
603
+ const e = t.segments.map(rt);
604
+ return new P(e);
605
+ }, ot = (t) => {
606
+ const e = O(t.contour), n = t.holes.map(O);
607
+ return new d(e, n);
608
+ }, jt = (t) => {
609
+ const e = t.figures.map(ot);
610
+ return new g(e);
618
611
  };
619
- function sn(t) {
612
+ function ge(t) {
620
613
  if (t.type === "DIAGRAM")
621
- return Wt(t);
614
+ return jt(t);
622
615
  if (t.type === "FIGURE")
623
- return ct(t);
616
+ return ot(t);
624
617
  if (t.type === "LOOP")
625
- return R(t);
626
- if (t.type === "LINE" || t.type === "ARC" || t.type === "ELLIPSE_ARC")
627
- return at(t);
618
+ return O(t);
619
+ if (t.type === "LINE" || t.type === "ARC" || t.type === "ELLIPSE_ARC" || t.type === "CUBIC_BEZIER")
620
+ return rt(t);
628
621
  throw new Error("Unknown shape type");
629
622
  }
630
- const Z = Math.PI / 180, Xt = 180 / Math.PI;
631
- function rn(t, n) {
632
- const e = Math.cos(n * Z) * t, s = Math.sin(n * Z) * t;
633
- return [e, s];
623
+ const K = Math.PI / 180, te = 180 / Math.PI;
624
+ function he(t, e) {
625
+ const n = Math.cos(e * K) * t, s = Math.sin(e * K) * t;
626
+ return [n, s];
634
627
  }
635
- function on([t, n]) {
636
- const e = Math.sqrt(t * t + n * n), s = Math.atan2(n, t) * Xt;
637
- return [e, s];
628
+ function pe([t, e]) {
629
+ const n = Math.sqrt(t * t + e * e), s = Math.atan2(e, t) * te;
630
+ return [n, s];
638
631
  }
639
632
  export {
640
- Z as DEG2RAD,
641
- Xt as RAD2DEG,
642
- on as cartesianToPolar,
643
- jt as confineStrand,
644
- nt as cut,
645
- fn as draw,
646
- Qt as eraseStrand,
647
- un as exportJSON,
648
- en as exportSVG,
649
- yt as fuse,
650
- b as fuseAll,
651
- sn as importJSON,
652
- Kt as intersect,
653
- tn as offset,
654
- nn as outlineStroke,
655
- rn as polarToCartesian,
656
- W as svgBody
633
+ K as DEG2RAD,
634
+ te as RAD2DEG,
635
+ pe as cartesianToPolar,
636
+ ce as confineStrand,
637
+ et as cut,
638
+ Pe as draw,
639
+ ae as eraseStrand,
640
+ Me as exportJSON,
641
+ ue as exportSVG,
642
+ Tt as fuse,
643
+ y as fuseAll,
644
+ ge as importJSON,
645
+ oe as intersect,
646
+ fe as offset,
647
+ le as outlineStroke,
648
+ he as polarToCartesian,
649
+ Q as svgBody
657
650
  };
658
651
  //# sourceMappingURL=pantograph.js.map