pantograph2d 0.8.0 → 0.9.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 (167) hide show
  1. package/LICENSE +4 -658
  2. package/dist/QuadraticBezier-BKElJOgn.cjs +9 -0
  3. package/dist/QuadraticBezier-BKElJOgn.cjs.map +1 -0
  4. package/dist/QuadraticBezier-PcRS9HZK.js +4773 -0
  5. package/dist/QuadraticBezier-PcRS9HZK.js.map +1 -0
  6. package/dist/draw-L71G180-.cjs +2 -0
  7. package/dist/draw-L71G180-.cjs.map +1 -0
  8. package/dist/draw-N2ntigsw.js +417 -0
  9. package/dist/draw-N2ntigsw.js.map +1 -0
  10. package/dist/models-BXU-Gx3U.cjs +4 -0
  11. package/dist/models-BXU-Gx3U.cjs.map +1 -0
  12. package/dist/{Diagram-2450b2e6.js → models-BjaFYsN2.js} +278 -279
  13. package/dist/models-BjaFYsN2.js.map +1 -0
  14. package/dist/pantograph/drawShape.cjs +1 -1
  15. package/dist/pantograph/drawShape.cjs.map +1 -1
  16. package/dist/pantograph/drawShape.js +12 -14
  17. package/dist/pantograph/drawShape.js.map +1 -1
  18. package/dist/pantograph/models.cjs +1 -1
  19. package/dist/pantograph/models.js +2 -2
  20. package/dist/pantograph/svg.cjs +1 -1
  21. package/dist/pantograph/svg.js +5 -6
  22. package/dist/pantograph/svg.js.map +1 -1
  23. package/dist/pantograph.cjs +2 -2
  24. package/dist/pantograph.cjs.map +1 -1
  25. package/dist/pantograph.js +432 -400
  26. package/dist/pantograph.js.map +1 -1
  27. package/dist/{wrapSVG-02b823ac.cjs → svg-ZTvNxsWu.cjs} +2 -2
  28. package/dist/svg-ZTvNxsWu.cjs.map +1 -0
  29. package/dist/{wrapSVG-0ec8a111.js → svg-hNHYuj_r.js} +2 -2
  30. package/dist/svg-hNHYuj_r.js.map +1 -0
  31. package/dist/types/examples/importSVG.d.ts +4 -0
  32. package/dist/{algorithms → types/src/algorithms}/boolean/figureBooleans.d.ts +1 -1
  33. package/dist/{algorithms → types/src/algorithms}/boolean/loopBooleans.d.ts +1 -1
  34. package/dist/{algorithms → types/src/algorithms}/boolean/strandBoolean.d.ts +4 -4
  35. package/dist/{algorithms → types/src/algorithms}/boolean/strandsBetweenIntersections.d.ts +3 -3
  36. package/dist/types/src/algorithms/conversions/bezierToArcs.d.ts +7 -0
  37. package/dist/types/src/algorithms/conversions/bezierToSafeBezier.d.ts +12 -0
  38. package/dist/types/src/algorithms/conversions/ellipseToArcs.d.ts +0 -0
  39. package/dist/types/src/algorithms/conversions/ellipseToBezier.d.ts +3 -0
  40. package/dist/types/src/algorithms/conversions/helpers.d.ts +13 -0
  41. package/dist/{algorithms → types/src/algorithms}/distances/arcArcDistance.d.ts +1 -1
  42. package/dist/{algorithms → types/src/algorithms}/distances/genericDistance.d.ts +1 -1
  43. package/dist/{algorithms → types/src/algorithms}/distances/index.d.ts +1 -1
  44. package/dist/types/src/algorithms/distances/lineArcDistance.d.ts +3 -0
  45. package/dist/{algorithms → types/src/algorithms}/distances/lineLineDistance.d.ts +1 -1
  46. package/dist/{algorithms → types/src/algorithms}/filletSegments.d.ts +1 -1
  47. package/dist/{algorithms → types/src/algorithms}/intersections/arcArcIntersection.d.ts +2 -2
  48. package/dist/types/src/algorithms/intersections/arcEllipseArcIntersection.d.ts +3 -0
  49. package/dist/types/src/algorithms/intersections/arcsCubicBezierIntersection.d.ts +5 -0
  50. package/dist/types/src/algorithms/intersections/arcsQuadraticBezierIntersection.d.ts +5 -0
  51. package/dist/{algorithms → types/src/algorithms}/intersections/bezierClip.d.ts +3 -3
  52. package/dist/{algorithms → types/src/algorithms}/intersections/cubicBezierCubicBezierIntersection.d.ts +2 -2
  53. package/dist/{algorithms → types/src/algorithms}/intersections/ellipseArcEllipseArcIntersection.d.ts +2 -2
  54. package/dist/types/src/algorithms/intersections/ellipseEllipseIntersection.d.ts +4 -0
  55. package/dist/types/src/algorithms/intersections/fullLinesIntersection.d.ts +18 -0
  56. package/dist/{algorithms → types/src/algorithms}/intersections/index.d.ts +2 -2
  57. package/dist/types/src/algorithms/intersections/lineArcIntersection.d.ts +4 -0
  58. package/dist/types/src/algorithms/intersections/lineBezierIntersection.d.ts +5 -0
  59. package/dist/types/src/algorithms/intersections/lineEllipseArcIntersection.d.ts +4 -0
  60. package/dist/{algorithms → types/src/algorithms}/intersections/lineLineIntersection.d.ts +4 -4
  61. package/dist/{algorithms → types/src/algorithms}/intersections/quadraticBezierQuadraticBezierIntersection.d.ts +2 -2
  62. package/dist/types/src/algorithms/intersections/rayIntersections.d.ts +3 -0
  63. package/dist/{algorithms → types/src/algorithms}/offsets/offsetFigure.d.ts +2 -2
  64. package/dist/types/src/algorithms/offsets/offsetSegment.d.ts +15 -0
  65. package/dist/types/src/algorithms/offsets/offsetStroke.d.ts +11 -0
  66. package/dist/{algorithms → types/src/algorithms}/organiseLoops.d.ts +2 -2
  67. package/dist/types/src/algorithms/simplify.d.ts +3 -0
  68. package/dist/types/src/algorithms/solvers/findZeroViaNewton.d.ts +1 -0
  69. package/dist/{algorithms → types/src/algorithms}/stitchSegments.d.ts +1 -1
  70. package/dist/types/src/api/drawShape.d.ts +2 -0
  71. package/dist/types/src/api/models.d.ts +1 -0
  72. package/dist/types/src/api/svg.d.ts +1 -0
  73. package/dist/{booleanOperations.d.ts → types/src/booleanOperations.d.ts} +5 -5
  74. package/dist/types/src/conversionOperations.d.ts +8 -0
  75. package/dist/{draw.d.ts → types/src/draw.d.ts} +4 -4
  76. package/dist/{drawShape → types/src/drawShape}/drawCircle.d.ts +1 -1
  77. package/dist/types/src/drawShape/drawEllipse.d.ts +2 -0
  78. package/dist/{drawShape → types/src/drawShape}/drawRect.d.ts +1 -1
  79. package/dist/types/src/drawShape/drawSVGPath.d.ts +2 -0
  80. package/dist/types/src/drawShape/index.d.ts +4 -0
  81. package/dist/{export → types/src/export}/json/exportJSON.d.ts +94 -94
  82. package/dist/{export → types/src/export}/json/jsonDiagram.d.ts +31 -31
  83. package/dist/{export → types/src/export}/json/jsonFigure.d.ts +31 -31
  84. package/dist/{export → types/src/export}/json/jsonLoop.d.ts +16 -16
  85. package/dist/{export → types/src/export}/json/jsonSegment.d.ts +16 -16
  86. package/dist/types/src/export/svg/api.d.ts +6 -0
  87. package/dist/{export → types/src/export}/svg/exportSVG.d.ts +6 -6
  88. package/dist/{export → types/src/export}/svg/svgDiagram.d.ts +1 -1
  89. package/dist/{export → types/src/export}/svg/svgFigure.d.ts +1 -1
  90. package/dist/{export → types/src/export}/svg/svgLoop.d.ts +1 -1
  91. package/dist/{export → types/src/export}/svg/svgSegment.d.ts +1 -1
  92. package/dist/{export → types/src/export}/svg/svgStrand.d.ts +1 -1
  93. package/dist/{export → types/src/export}/svg/wrapSVG.d.ts +1 -1
  94. package/dist/types/src/import/json/importJSON.d.ts +9 -0
  95. package/dist/{main.d.ts → types/src/main.d.ts} +7 -7
  96. package/dist/{models → types/src/models}/BoundingBox.d.ts +1 -1
  97. package/dist/{models → types/src/models}/Diagram.d.ts +7 -7
  98. package/dist/{models → types/src/models}/Figure.d.ts +7 -7
  99. package/dist/{models → types/src/models}/Loop.d.ts +4 -4
  100. package/dist/{models → types/src/models}/Strand.d.ts +2 -2
  101. package/dist/{models → types/src/models}/Stroke.d.ts +5 -5
  102. package/dist/{models → types/src/models}/TransformationMatrix.d.ts +1 -1
  103. package/dist/types/src/models/exports.d.ts +15 -0
  104. package/dist/types/src/models/segments/AbstractSegment.d.ts +25 -0
  105. package/dist/{models → types/src/models}/segments/Arc.d.ts +5 -4
  106. package/dist/{models → types/src/models}/segments/CubicBezier.d.ts +11 -4
  107. package/dist/{models → types/src/models}/segments/EllipseArc.d.ts +5 -5
  108. package/dist/{models → types/src/models}/segments/Line.d.ts +4 -4
  109. package/dist/{models → types/src/models}/segments/QuadraticBezier.d.ts +9 -4
  110. package/dist/{models → types/src/models}/segments/Segment.d.ts +4 -4
  111. package/dist/{models → types/src/models}/segments/utils/deCasteljau.d.ts +1 -1
  112. package/dist/types/src/models/segments/utils/isSegment.d.ts +8 -0
  113. package/dist/{models → types/src/models}/utils/Transformable.d.ts +2 -2
  114. package/dist/{offsetOperations.d.ts → types/src/offsetOperations.d.ts} +4 -4
  115. package/dist/types/src/operations.d.ts +2 -0
  116. package/dist/types/src/utils/applyMixins.d.ts +1 -0
  117. package/dist/types/src/utils/listOfFigures.d.ts +4 -0
  118. package/dist/types/src/utils/projectPointOnLine.d.ts +3 -0
  119. package/dist/{utils → types/src/utils}/removeDuplicatePoints.d.ts +1 -1
  120. package/dist/{vectorOperations.d.ts → types/src/vectorOperations.d.ts} +1 -1
  121. package/package.json +4 -4
  122. package/dist/Diagram-2450b2e6.js.map +0 -1
  123. package/dist/Diagram-57e17509.cjs +0 -4
  124. package/dist/Diagram-57e17509.cjs.map +0 -1
  125. package/dist/QuadraticBezier-e116a2d6.js +0 -3647
  126. package/dist/QuadraticBezier-e116a2d6.js.map +0 -1
  127. package/dist/QuadraticBezier-e3d7218b.cjs +0 -9
  128. package/dist/QuadraticBezier-e3d7218b.cjs.map +0 -1
  129. package/dist/algorithms/distances/lineArcDistance.d.ts +0 -3
  130. package/dist/algorithms/intersections/arcEllipseArcIntersection.d.ts +0 -3
  131. package/dist/algorithms/intersections/arcsCubicBezierIntersection.d.ts +0 -5
  132. package/dist/algorithms/intersections/arcsQuadraticBezierIntersection.d.ts +0 -5
  133. package/dist/algorithms/intersections/ellipseEllipseIntersection.d.ts +0 -4
  134. package/dist/algorithms/intersections/lineArcIntersection.d.ts +0 -4
  135. package/dist/algorithms/intersections/lineBezierIntersection.d.ts +0 -5
  136. package/dist/algorithms/intersections/lineEllipseArcIntersection.d.ts +0 -4
  137. package/dist/algorithms/intersections/rayIntersections.d.ts +0 -3
  138. package/dist/algorithms/offsets/offsetSegment.d.ts +0 -12
  139. package/dist/algorithms/offsets/offsetStroke.d.ts +0 -9
  140. package/dist/algorithms/simplify.d.ts +0 -3
  141. package/dist/api/drawShape.d.ts +0 -2
  142. package/dist/api/models.d.ts +0 -1
  143. package/dist/api/svg.d.ts +0 -1
  144. package/dist/draw-27ac6dae.cjs +0 -2
  145. package/dist/draw-27ac6dae.cjs.map +0 -1
  146. package/dist/draw-c7b2705c.js +0 -344
  147. package/dist/draw-c7b2705c.js.map +0 -1
  148. package/dist/export/svg/api.d.ts +0 -6
  149. package/dist/import/json/importJSON.d.ts +0 -9
  150. package/dist/models/exports.d.ts +0 -15
  151. package/dist/models/segments/utils/isSegment.d.ts +0 -8
  152. package/dist/operations.d.ts +0 -2
  153. package/dist/utils/listOfFigures.d.ts +0 -4
  154. package/dist/utils/projectPointOnLine.d.ts +0 -3
  155. package/dist/wrapSVG-02b823ac.cjs.map +0 -1
  156. package/dist/wrapSVG-0ec8a111.js.map +0 -1
  157. /package/dist/{algorithms → types/src/algorithms}/optimisation/Brent.d.ts +0 -0
  158. /package/dist/{algorithms → types/src/algorithms}/optimisation/DiRect.d.ts +0 -0
  159. /package/dist/{algorithms → types/src/algorithms}/solvers/solvePolynomials.d.ts +0 -0
  160. /package/dist/{definitions.d.ts → types/src/definitions.d.ts} +0 -0
  161. /package/dist/{utils → types/src/utils}/allCombinations.d.ts +0 -0
  162. /package/dist/{utils → types/src/utils}/allPairs.d.ts +0 -0
  163. /package/dist/{utils → types/src/utils}/angularDistance.d.ts +0 -0
  164. /package/dist/{utils → types/src/utils}/range.d.ts +0 -0
  165. /package/dist/{utils → types/src/utils}/removeDuplicateValues.d.ts +0 -0
  166. /package/dist/{utils → types/src/utils}/unitAngle.d.ts +0 -0
  167. /package/dist/{utils → types/src/utils}/zip.d.ts +0 -0
@@ -0,0 +1,4773 @@
1
+ var Oe = Object.defineProperty;
2
+ var Me = (r) => {
3
+ throw TypeError(r);
4
+ };
5
+ var Be = (r, s, t) => s in r ? Oe(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
6
+ var q = (r, s, t) => Be(r, typeof s != "symbol" ? s + "" : s, t), oe = (r, s, t) => s.has(r) || Me("Cannot " + t);
7
+ var ht = (r, s, t) => (oe(r, s, "read from private field"), t ? t.call(r) : s.get(r)), le = (r, s, t) => s.has(r) ? Me("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(r) : s.set(r, t), Dt = (r, s, t, e) => (oe(r, s, "write to private field"), e ? e.call(r, t) : s.set(r, t), t), he = (r, s, t) => (oe(r, s, "access private method"), t);
8
+ function zt(r, s, t, e) {
9
+ return r <= e && s >= t;
10
+ }
11
+ class mt {
12
+ constructor(s = 1 / 0, t = 1 / 0, e = -1 / 0, n = -1 / 0) {
13
+ q(this, "xMin");
14
+ q(this, "yMin");
15
+ q(this, "xMax");
16
+ q(this, "yMax");
17
+ this.xMin = s, this.yMin = t, this.xMax = e, this.yMax = n;
18
+ }
19
+ get width() {
20
+ return this.xMax - this.xMin;
21
+ }
22
+ get height() {
23
+ return this.yMax - this.yMin;
24
+ }
25
+ get center() {
26
+ return [(this.xMin + this.xMax) / 2, (this.yMin + this.yMax) / 2];
27
+ }
28
+ grow(s) {
29
+ return new mt(
30
+ this.xMin - s,
31
+ this.yMin - s,
32
+ this.xMax + s,
33
+ this.yMax + s
34
+ );
35
+ }
36
+ contains(s) {
37
+ const [t, e] = s;
38
+ return zt(this.xMin, this.xMax, t, t) && zt(this.yMin, this.yMax, e, e);
39
+ }
40
+ overlaps(s) {
41
+ return zt(this.xMin, this.xMax, s.xMin, s.xMax) && zt(this.yMin, this.yMax, s.yMin, s.yMax);
42
+ }
43
+ addPoint(s) {
44
+ const [t, e] = s;
45
+ return new mt(
46
+ Math.min(this.xMin, t),
47
+ Math.min(this.yMin, e),
48
+ Math.max(this.xMax, t),
49
+ Math.max(this.yMax, e)
50
+ );
51
+ }
52
+ merge(s) {
53
+ return new mt(
54
+ Math.min(this.xMin, s.xMin),
55
+ Math.min(this.yMin, s.yMin),
56
+ Math.max(this.xMax, s.xMax),
57
+ Math.max(this.yMax, s.yMax)
58
+ );
59
+ }
60
+ intersection(s) {
61
+ return new mt(
62
+ Math.max(this.xMin, s.xMin),
63
+ Math.max(this.yMin, s.yMin),
64
+ Math.min(this.xMax, s.xMax),
65
+ Math.min(this.yMax, s.yMax)
66
+ );
67
+ }
68
+ }
69
+ function ce(r) {
70
+ return r.reduce((s, t) => s.addPoint(t), new mt());
71
+ }
72
+ const ye = (r, s = 1e-9) => {
73
+ let t = r;
74
+ return Math.abs(r) < s && (t = 0), t.toFixed(-Math.log10(s));
75
+ };
76
+ function Te(r, s = 1e-9) {
77
+ return Array.from(
78
+ new Map(
79
+ r.map(([t, e]) => [
80
+ `[${ye(t, s)},${ye(e, s)}]`,
81
+ [t, e]
82
+ ])
83
+ ).values()
84
+ );
85
+ }
86
+ const fe = Math.PI / 180, Ue = 180 / Math.PI, Z = (r) => `[${r[0]}, ${r[1]}]`, Y = ([r, s], [t, e], n = 1e-9) => Math.abs(r - t) <= n && Math.abs(s - e) <= n, it = ([r, s], [t, e]) => [r + t, s + e], Q = ([r, s], [t, e]) => [r - t, s - e], It = ([r, s]) => r * r + s * s, an = ([r, s]) => Math.sqrt(It([r, s])), nt = ([r, s], t) => [r * t, s * t], Rt = ([r, s], [t, e] = [0, 0]) => (r - t) ** 2 + (s - e) ** 2, J = (r, s = [0, 0]) => Math.sqrt(Rt(r, s));
87
+ function St([r, s], [t, e]) {
88
+ return r * e - s * t;
89
+ }
90
+ function Pe([r, s], [t, e]) {
91
+ return r * t + s * e;
92
+ }
93
+ const un = ([r, s], [t, e] = [0, 0]) => Math.atan2(e * r - s * t, r * t + s * e);
94
+ function H([r, s]) {
95
+ const t = J([r, s]);
96
+ return [r / t, s / t];
97
+ }
98
+ function Tt(r, s) {
99
+ const t = Math.cos(s) * r, e = Math.sin(s) * r;
100
+ return [t, e];
101
+ }
102
+ function Ye([r, s]) {
103
+ return Math.atan2(s, r);
104
+ }
105
+ function We(r) {
106
+ const s = J(r), t = Ye(r);
107
+ return [s, t];
108
+ }
109
+ function Ie(r, s, t = 1e-9) {
110
+ const e = St(r, s), n = It(r), i = It(s);
111
+ return e * e < n * i * t * t;
112
+ }
113
+ function tt(r) {
114
+ return [-r[1], r[0]];
115
+ }
116
+ function Qt(r) {
117
+ return [r[1], -r[0]];
118
+ }
119
+ function Qe(r, s, t) {
120
+ return Y(t, r) || Ie(Q(t, r), s);
121
+ }
122
+ const Mt = (r, s) => {
123
+ const [t, e, n, i, o, l, h, a, u] = r, [c, g, d, w, p, P, f, M, E] = s;
124
+ return [
125
+ t * c + e * w + n * f,
126
+ t * g + e * p + n * M,
127
+ t * d + e * P + n * E,
128
+ i * c + o * w + l * f,
129
+ i * g + o * p + l * M,
130
+ i * d + o * P + l * E,
131
+ h * c + a * w + u * f,
132
+ h * g + a * p + u * M,
133
+ h * d + a * P + u * E
134
+ ];
135
+ }, Ge = (r) => {
136
+ const [s, t, e, n, i, o, l, h, a] = r, u = s * (i * a - o * h) - t * (n * a - o * l) + e * (n * h - i * l);
137
+ return [
138
+ (i * a - o * h) / u,
139
+ (e * h - t * a) / u,
140
+ (t * o - e * i) / u,
141
+ (o * l - n * a) / u,
142
+ (s * a - e * l) / u,
143
+ (e * n - s * o) / u,
144
+ (n * h - i * l) / u,
145
+ (t * l - s * h) / u,
146
+ (s * i - t * n) / u
147
+ ];
148
+ }, Xe = (r) => {
149
+ const [s, t, e, n, i, o, l, h, a] = r;
150
+ return [s, n, l, t, i, h, e, o, a];
151
+ };
152
+ class et {
153
+ constructor(s) {
154
+ q(this, "_matrix", [1, 0, 0, 0, 1, 0, 0, 0, 1]);
155
+ s && (this._matrix = [...s]);
156
+ }
157
+ clone() {
158
+ return new et(this._matrix);
159
+ }
160
+ transpose() {
161
+ return this._matrix = Xe(this._matrix), this;
162
+ }
163
+ inverse() {
164
+ return this._matrix = Ge(this._matrix), this;
165
+ }
166
+ translate(s, t) {
167
+ return this._matrix = Mt([1, 0, s, 0, 1, t, 0, 0, 1], this._matrix), this;
168
+ }
169
+ rotate(s, t) {
170
+ const e = Math.cos(s), n = Math.sin(s), i = [e, -n, 0, n, e, 0, 0, 0, 1];
171
+ return t && this.translate(-t[0], -t[1]), this._matrix = Mt(i, this._matrix), t && this.translate(t[0], t[1]), this;
172
+ }
173
+ mirrorX() {
174
+ return this._matrix = Mt([1, 0, 0, 0, -1, 0, 0, 0, 1], this._matrix), this;
175
+ }
176
+ mirrorY() {
177
+ return this._matrix = Mt([-1, 0, 0, 0, 1, 0, 0, 0, 1], this._matrix), this;
178
+ }
179
+ mirrorLine(s, t) {
180
+ const [e, n] = s, i = Math.atan2(n, e);
181
+ return t && this.translate(-t[0], -t[1]), this.rotate(-i), this.mirrorX(), this.rotate(i), t && this.translate(t[0], t[1]), this;
182
+ }
183
+ mirrorCenter(s) {
184
+ return s && this.translate(-s[0], -s[1]), this._matrix = Mt([-1, 0, 0, 0, -1, 0, 0, 0, 1], this._matrix), s && this.translate(s[0], s[1]), this;
185
+ }
186
+ scale(s, t) {
187
+ return t && this.translate(-t[0], -t[1]), this._matrix = Mt([s, 0, 0, 0, s, 0, 0, 0, 1], this._matrix), t && this.translate(t[0], t[1]), this;
188
+ }
189
+ transform(s) {
190
+ const [t, e] = s, [n, i, o, l, h, a] = this._matrix;
191
+ return [n * t + i * e + o, l * t + h * e + a];
192
+ }
193
+ transformAngle(s) {
194
+ const [t, e] = this.transform([Math.cos(s), Math.sin(s)]), [n, i] = this.transform([0, 0]);
195
+ return Math.atan2(e - i, t - n);
196
+ }
197
+ keepsOrientation() {
198
+ const [s, , , , t] = this._matrix;
199
+ return s * t > 0;
200
+ }
201
+ scaleFactor() {
202
+ const [s, , , t] = this._matrix;
203
+ return Math.sqrt(s * s + t * t);
204
+ }
205
+ }
206
+ class Ze {
207
+ translateX(s) {
208
+ const t = new et().translate(s, 0);
209
+ return this.transform(t);
210
+ }
211
+ translateY(s) {
212
+ const t = new et().translate(0, s);
213
+ return this.transform(t);
214
+ }
215
+ translate(s, t) {
216
+ const e = new et().translate(s, t);
217
+ return this.transform(e);
218
+ }
219
+ translateTo([s, t]) {
220
+ const e = new et().translate(s, t);
221
+ return this.transform(e);
222
+ }
223
+ rotate(s, t) {
224
+ const e = new et().rotate(
225
+ s * fe,
226
+ t
227
+ );
228
+ return this.transform(e);
229
+ }
230
+ scale(s, t) {
231
+ const e = new et().scale(s, t);
232
+ return this.transform(e);
233
+ }
234
+ mirrorCenter(s) {
235
+ const t = new et().mirrorCenter(s);
236
+ return this.transform(t);
237
+ }
238
+ mirror(s = "x", t) {
239
+ const e = new et();
240
+ return s === "x" ? e.mirrorX() : s === "y" ? e.mirrorY() : e.mirrorLine(s, t), this.transform(e);
241
+ }
242
+ }
243
+ class xt extends Ze {
244
+ constructor(t, e) {
245
+ super();
246
+ q(this, "precision", 1e-9);
247
+ this.firstPoint = t, this.lastPoint = e, this.firstPoint = t, this.lastPoint = e;
248
+ }
249
+ get repr() {
250
+ return `${this.segmentType} ${Z(this.firstPoint)} - ${Z(
251
+ this.lastPoint
252
+ )}`;
253
+ }
254
+ get info() {
255
+ return this.repr;
256
+ }
257
+ [Symbol.for("nodejs.util.inspect.custom")]() {
258
+ return this.repr;
259
+ }
260
+ }
261
+ class at extends xt {
262
+ constructor() {
263
+ super(...arguments);
264
+ q(this, "segmentType", "LINE");
265
+ q(this, "_V", null);
266
+ q(this, "_slope", null);
267
+ q(this, "_yIntercept", null);
268
+ q(this, "_boundingBox", null);
269
+ }
270
+ isValidParameter(t) {
271
+ const e = this.length * this.precision;
272
+ return t >= -e && 1 - t >= -e;
273
+ }
274
+ paramPoint(t) {
275
+ return it(this.firstPoint, nt(this.V, t));
276
+ }
277
+ get length() {
278
+ return J(this.firstPoint, this.lastPoint);
279
+ }
280
+ get squareLength() {
281
+ return Rt(this.firstPoint, this.lastPoint);
282
+ }
283
+ get V() {
284
+ return this._V === null && (this._V = Q(this.lastPoint, this.firstPoint)), this._V;
285
+ }
286
+ get slope() {
287
+ if (this._slope === null) {
288
+ const [t, e] = this.V;
289
+ this._slope = e / t;
290
+ }
291
+ return this._slope;
292
+ }
293
+ get yIntercept() {
294
+ return this._yIntercept === null && (this._yIntercept = this.firstPoint[1] - this.slope * this.firstPoint[0]), this._yIntercept;
295
+ }
296
+ get midPoint() {
297
+ return it(this.firstPoint, nt(this.V, 0.5));
298
+ }
299
+ isSame(t) {
300
+ return t instanceof at ? Y(this.firstPoint, t.firstPoint) && Y(this.lastPoint, t.lastPoint) || Y(this.lastPoint, t.firstPoint) && Y(this.firstPoint, t.lastPoint) : !1;
301
+ }
302
+ clone() {
303
+ return new at(this.firstPoint, this.lastPoint);
304
+ }
305
+ reverse() {
306
+ return new at(this.lastPoint, this.firstPoint);
307
+ }
308
+ get boundingBox() {
309
+ return this._boundingBox === null && (this._boundingBox = new mt(
310
+ Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,
311
+ Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,
312
+ Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,
313
+ Math.max(this.firstPoint[1], this.lastPoint[1]) + this.precision
314
+ )), this._boundingBox;
315
+ }
316
+ distanceFrom(t) {
317
+ const e = Q(t, this.firstPoint), n = Pe(e, this.V) / this.squareLength;
318
+ if (n < 0)
319
+ return J(t, this.firstPoint);
320
+ if (n > 1)
321
+ return J(t, this.lastPoint);
322
+ const i = this.paramPoint(n);
323
+ return J(t, i);
324
+ }
325
+ isOnSegment(t) {
326
+ if (Y(t, this.firstPoint, this.precision)) return !0;
327
+ const e = Q(t, this.firstPoint);
328
+ if (!Ie(this.V, e)) return !1;
329
+ const n = Pe(e, this.V) / this.squareLength;
330
+ return this.isValidParameter(n);
331
+ }
332
+ gradientAt(t) {
333
+ return this.V;
334
+ }
335
+ tangentAt(t) {
336
+ if (!this.isOnSegment(t)) throw new Error("Point is not on segment");
337
+ return H(this.V);
338
+ }
339
+ get normalVector() {
340
+ return tt(H(this.V));
341
+ }
342
+ get tangentAtFirstPoint() {
343
+ return H(this.V);
344
+ }
345
+ get tangentAtLastPoint() {
346
+ return H(this.V);
347
+ }
348
+ splitAt(t) {
349
+ let e;
350
+ if (Array.isArray(t) && t.length === 0)
351
+ return [this];
352
+ Array.isArray(t[0]) ? e = t : e = [t], e.forEach((a) => {
353
+ if (!this.isOnSegment(a))
354
+ throw new Error(
355
+ `Point ${Z(a)} is not on segment ${this.repr}`
356
+ );
357
+ });
358
+ const n = [this.firstPoint, ...e, this.lastPoint], i = Te(n), o = this.lastPoint[0] - this.firstPoint[0];
359
+ let l = Math.sign(o), h = 0;
360
+ return Math.abs(o) < this.precision && (l = Math.sign(this.lastPoint[1] - this.firstPoint[1]), h = 1), i.sort(
361
+ (a, u) => l * (a[h] - u[h])
362
+ ), i.flatMap((a, u) => u === i.length - 1 ? [] : new at(a, i[u + 1]));
363
+ }
364
+ transform(t) {
365
+ return new at(
366
+ t.transform(this.firstPoint),
367
+ t.transform(this.lastPoint)
368
+ );
369
+ }
370
+ }
371
+ function Je(r) {
372
+ return Array.from(Array(r).keys());
373
+ }
374
+ function Kt(r) {
375
+ const s = Math.min(...r.map((t) => t.length));
376
+ return Je(s).map((t) => r.map((e) => e[t]));
377
+ }
378
+ function wt(r, s = 1e-9) {
379
+ return r < 0 ? r + 2 * Math.PI : r >= 2 * Math.PI ? r % (2 * Math.PI) : r > 2 * Math.PI - s ? 0 : r;
380
+ }
381
+ function Zt(r, s, t, e = 1e-9) {
382
+ let n = s - r;
383
+ return t && (n = -n), n < 0 && (n += 2 * Math.PI), n > 2 * Math.PI - e ? 0 : n;
384
+ }
385
+ const me = (r, s, t) => {
386
+ const e = St(r.V, s.V), n = It(r.V), i = It(s.V), o = t ? t * t : r.precision * s.precision;
387
+ if (e * e < n * i * o)
388
+ return "parallel";
389
+ const l = Q(s.firstPoint, r.firstPoint), h = St(l, s.V) / e, a = St(l, r.V) / e;
390
+ return {
391
+ intersectionParam1: h,
392
+ intersectionParam2: a
393
+ };
394
+ };
395
+ function cn(r, s, t = !1, e) {
396
+ const n = me(r, s, e);
397
+ if (n === "parallel") {
398
+ if (!t) return null;
399
+ if (r.isSame(s)) return r;
400
+ const l = Te(
401
+ [
402
+ s.isOnSegment(r.firstPoint) ? r.firstPoint : null,
403
+ s.isOnSegment(r.lastPoint) ? r.lastPoint : null,
404
+ r.isOnSegment(s.firstPoint) ? s.firstPoint : null,
405
+ r.isOnSegment(s.lastPoint) ? s.lastPoint : null
406
+ ].filter((h) => h !== null)
407
+ ).sort((h, a) => h[0] - a[0]);
408
+ if (l.length === 0) return null;
409
+ if (l.length === 1) return null;
410
+ if (l.length === 2) return new at(l[0], l[1]);
411
+ throw console.error(l), new Error(
412
+ "Unexpected number of points while intersecting parallel lines"
413
+ );
414
+ }
415
+ const { intersectionParam1: i, intersectionParam2: o } = n;
416
+ return !r.isValidParameter(i) || !s.isValidParameter(o) ? null : r.paramPoint(i);
417
+ }
418
+ const Ot = (r, s) => {
419
+ const t = Q(r, s);
420
+ return We(t);
421
+ };
422
+ class ct extends xt {
423
+ constructor(t, e, n, i = !1, { ignoreChecks: o = !1 } = {}) {
424
+ super(t, e);
425
+ q(this, "segmentType", "ARC");
426
+ q(this, "center");
427
+ q(this, "clockwise");
428
+ q(this, "_coefficients", null);
429
+ q(this, "_angularLength", null);
430
+ q(this, "_radius", null);
431
+ q(this, "_firstAngle", null);
432
+ q(this, "_lastAngle", null);
433
+ q(this, "_boundingBox", null);
434
+ if (this.center = n, this.clockwise = i, !o) {
435
+ if (Y(t, e))
436
+ throw new Error("Invalid arc, cannot be a full circle");
437
+ if (Math.abs(this.radius - J(this.lastPoint, this.center)) > this.precision)
438
+ throw new Error(
439
+ `Invalid arc, radius does not match between ${Z(
440
+ t
441
+ )} and ${Z(e)}} (center ${Z(n)})`
442
+ );
443
+ }
444
+ }
445
+ get info() {
446
+ return `ARC(${Z(this.firstPoint)}, ${Z(
447
+ this.lastPoint
448
+ )}, ${Z(this.center)}, ${this.clockwise ? "CW" : "CCW"})`;
449
+ }
450
+ get coefficients() {
451
+ if (this._coefficients === null) {
452
+ const [t, e] = this.center, n = this.radius * this.radius;
453
+ this._coefficients = {
454
+ x2: 1 / n,
455
+ xy: 0,
456
+ y2: 1 / n,
457
+ x: -(2 * t) / n,
458
+ y: -(2 * e) / n,
459
+ c: (t * t + e * e - n) / n
460
+ };
461
+ }
462
+ return this._coefficients;
463
+ }
464
+ isValidParameter(t) {
465
+ return 1 - t >= -this.precision && t >= -this.precision;
466
+ }
467
+ angleToParam(t) {
468
+ return Zt(this.firstAngle, wt(t), this.clockwise) / this.angularLength;
469
+ }
470
+ get angularLength() {
471
+ return this._angularLength || (this._angularLength = Zt(
472
+ this.firstAngle,
473
+ this.lastAngle,
474
+ this.clockwise
475
+ )), this._angularLength;
476
+ }
477
+ paramPoint(t) {
478
+ return it(
479
+ this.center,
480
+ Tt(
481
+ this.radius,
482
+ this.firstAngle + t * this.angularLength * (this.clockwise ? -1 : 1)
483
+ )
484
+ );
485
+ }
486
+ pointToParam(t) {
487
+ const [e, n] = Ot(t, this.center);
488
+ if (Math.abs(e - this.radius) > this.precision)
489
+ throw new Error(
490
+ `Point ${Z(t)} is not on segment ${this.repr}`
491
+ );
492
+ const i = this.angleToParam(n);
493
+ if (!this.isValidParameter(i))
494
+ throw new Error(
495
+ `Point ${Z(t)} is not on segment ${this.repr}`
496
+ );
497
+ return i;
498
+ }
499
+ get radius() {
500
+ return this._radius === null && (this._radius = J(this.firstPoint, this.center)), this._radius;
501
+ }
502
+ get firstAngle() {
503
+ if (this._firstAngle === null) {
504
+ const [t, e] = Q(this.firstPoint, this.center);
505
+ this._firstAngle = wt(Math.atan2(e, t));
506
+ }
507
+ return this._firstAngle;
508
+ }
509
+ get lastAngle() {
510
+ if (this._lastAngle === null) {
511
+ const [t, e] = Q(this.lastPoint, this.center);
512
+ this._lastAngle = wt(Math.atan2(e, t));
513
+ }
514
+ return this._lastAngle;
515
+ }
516
+ get length() {
517
+ return this.radius * this.angularLength;
518
+ }
519
+ get squareLength() {
520
+ return this.length * this.length;
521
+ }
522
+ get midPoint() {
523
+ return this.paramPoint(0.5);
524
+ }
525
+ isSame(t) {
526
+ return !(t instanceof ct) || !Y(this.center, t.center) ? !1 : Y(this.firstPoint, t.firstPoint) && Y(this.lastPoint, t.lastPoint) && this.clockwise === t.clockwise || Y(this.lastPoint, t.firstPoint) && Y(this.firstPoint, t.lastPoint) && this.clockwise === !t.clockwise;
527
+ }
528
+ clone() {
529
+ return new ct(
530
+ this.firstPoint,
531
+ this.lastPoint,
532
+ this.center,
533
+ this.clockwise
534
+ );
535
+ }
536
+ reverse() {
537
+ return new ct(
538
+ this.lastPoint,
539
+ this.firstPoint,
540
+ this.center,
541
+ !this.clockwise
542
+ );
543
+ }
544
+ get boundingBox() {
545
+ if (this._boundingBox === null) {
546
+ const t = this.radius + this.precision, e = (n) => this.isValidParameter(this.angleToParam(n));
547
+ this._boundingBox = new mt(
548
+ e(Math.PI) ? this.center[0] - t : Math.min(this.firstPoint[0], this.lastPoint[0]) - this.precision,
549
+ e(Math.PI * 1.5) ? this.center[1] - t : Math.min(this.firstPoint[1], this.lastPoint[1]) - this.precision,
550
+ e(0) ? this.center[0] + t : Math.max(this.firstPoint[0], this.lastPoint[0]) + this.precision,
551
+ e(Math.PI / 2) ? this.center[1] + t : Math.max(this.firstPoint[1], this.lastPoint[1]) + this.precision
552
+ );
553
+ }
554
+ return this._boundingBox;
555
+ }
556
+ distanceFrom(t) {
557
+ const [e, n] = Ot(t, this.center);
558
+ return this.isValidParameter(this.angleToParam(n)) ? Math.abs(e - this.radius) : Math.sqrt(
559
+ Math.min(
560
+ Rt(t, this.firstPoint),
561
+ Rt(t, this.lastPoint)
562
+ )
563
+ );
564
+ }
565
+ isOnSegment(t) {
566
+ if (Y(t, this.firstPoint) || Y(t, this.lastPoint))
567
+ return !0;
568
+ const [e, n] = Ot(t, this.center);
569
+ if (Math.abs(e - this.radius) > this.precision) return !1;
570
+ const i = this.angleToParam(n);
571
+ return this.isValidParameter(i);
572
+ }
573
+ gradientAt(t) {
574
+ const e = this.firstAngle + t * this.angularLength * (this.clockwise ? -1 : 1), n = this.radius * this.angularLength, i = -n * Math.sin(e), o = n * Math.cos(e);
575
+ return this.clockwise ? [-i, -o] : [i, o];
576
+ }
577
+ tangentAt(t) {
578
+ const [e, n] = Ot(t, this.center);
579
+ if (Math.abs(e - this.radius) > this.precision)
580
+ throw new Error("Point is not on the arc");
581
+ const i = this.angleToParam(n);
582
+ if (!this.isValidParameter(i))
583
+ throw new Error("Point is not on the arc");
584
+ const o = Tt(1, n);
585
+ return (this.clockwise ? Qt : tt)(H(o));
586
+ }
587
+ get tangentAtFirstPoint() {
588
+ const t = Tt(1, this.firstAngle);
589
+ return (this.clockwise ? Qt : tt)(H(t));
590
+ }
591
+ get tangentAtLastPoint() {
592
+ const t = Tt(1, this.lastAngle);
593
+ return (this.clockwise ? Qt : tt)(H(t));
594
+ }
595
+ splitAt(t) {
596
+ let e;
597
+ if (Array.isArray(t) && t.length === 0)
598
+ return [this];
599
+ Array.isArray(t[0]) ? e = t : e = [t];
600
+ const i = [0, 1, ...e.map((h) => this.pointToParam(h))], o = new Map(
601
+ Kt([i, [this.firstPoint, this.lastPoint, ...e]])
602
+ );
603
+ i.sort((h, a) => h - a);
604
+ let l = null;
605
+ return i.flatMap((h, a) => {
606
+ if (a === i.length - 1) return [];
607
+ const u = i[a + 1];
608
+ if (u - h < this.precision)
609
+ return l === null && (l = h), [];
610
+ const c = l === null ? h : l, g = new ct(
611
+ o.get(c) || this.paramPoint(c),
612
+ o.get(u) || this.paramPoint(u),
613
+ this.center,
614
+ this.clockwise
615
+ );
616
+ return l = null, g;
617
+ });
618
+ }
619
+ transform(t) {
620
+ return new ct(
621
+ t.transform(this.firstPoint),
622
+ t.transform(this.lastPoint),
623
+ t.transform(this.center),
624
+ t.keepsOrientation() ? this.clockwise : !this.clockwise
625
+ );
626
+ }
627
+ }
628
+ function fn(r, s, t) {
629
+ const e = new at(s, r), n = new at(s, t), i = tt(e.tangentAtFirstPoint), o = tt(n.tangentAtLastPoint), l = me(
630
+ { firstPoint: e.midPoint, V: i, precision: 1e-9 },
631
+ { firstPoint: n.midPoint, V: o, precision: 1e-9 }
632
+ );
633
+ if (l === "parallel")
634
+ throw new Error("Cannot create an arc from three colinear points");
635
+ const h = St(
636
+ Q(r, s),
637
+ Q(t, s)
638
+ ) > 0;
639
+ return new ct(
640
+ r,
641
+ t,
642
+ it(e.midPoint, nt(i, l.intersectionParam1)),
643
+ h,
644
+ { ignoreChecks: !0 }
645
+ );
646
+ }
647
+ function mn(r, s, t) {
648
+ const e = new at(r, s), n = tt(e.tangentAtFirstPoint), i = me(
649
+ { firstPoint: e.midPoint, V: n, precision: 1e-9 },
650
+ {
651
+ firstPoint: r,
652
+ V: tt(t),
653
+ precision: 1e-9
654
+ }
655
+ );
656
+ if (i === "parallel")
657
+ throw new Error("Cannot create an arc from three colinear points");
658
+ const o = it(
659
+ e.midPoint,
660
+ nt(n, i.intersectionParam1)
661
+ ), l = St(
662
+ Q(o, r),
663
+ Q(o, it(r, t))
664
+ ) < 0;
665
+ return new ct(r, s, o, l, {
666
+ ignoreChecks: !0
667
+ });
668
+ }
669
+ const be = 1e-21, Bt = 1.618034;
670
+ function Ee(r, s = 0, t = 1, e = 110, n = 1e3) {
671
+ let i, o, l, h, a, u, c, g, d, w, p, P, f;
672
+ for (o = r(s), l = r(t), o < l && ([s, t] = [t, s], [o, l] = [l, o]), f = t + Bt * (t - s), h = r(f), a = 3, c = 0; h < l; ) {
673
+ if (g = (t - s) * (l - h), d = (t - f) * (l - o), w = d - g, Math.abs(w) < be ? i = 2 * be : i = 2 * w, p = t - ((t - f) * d - (t - s) * g) / i, P = t + e * (f - t), c > n)
674
+ throw new Error("Too many iterations.");
675
+ if (c += 1, (p - f) * (t - p) > 0) {
676
+ if (u = r(p), a += 1, u < h)
677
+ return s = t, t = p, o = l, l = u, [s, t, f, o, l, h, a];
678
+ if (u > l)
679
+ return f = p, h = u, [s, t, f, o, l, h, a];
680
+ p = f + Bt * (f - t), u = r(p), a += 1;
681
+ } else
682
+ (p - P) * (P - f) >= 0 ? (p = P, u = r(p), a += 1) : (p - P) * (f - p) > 0 ? (u = r(p), a += 1, u < h && (t = f, f = p, p = f + Bt * (f - t), l = h, h = u, u = r(p), a += 1)) : (p = f + Bt * (f - t), u = r(p), a += 1);
683
+ s = t, t = f, f = p, o = l, l = h, h = u;
684
+ }
685
+ return [s, t, f, o, l, h, a];
686
+ }
687
+ const _e = 0.381966, Ke = 1e-11;
688
+ class He {
689
+ constructor(s, t = 148e-10, e = 500) {
690
+ q(this, "xmin");
691
+ q(this, "fval");
692
+ q(this, "iter");
693
+ q(this, "funcalls");
694
+ q(this, "brack");
695
+ this.func = s, this.tol = t, this.maxiter = e, this.func = s, this.tol = t, this.maxiter = e, this.xmin = 1 / 0, this.fval = 1 / 0, this.iter = 0, this.funcalls = 0, this.brack = null;
696
+ }
697
+ setBracket(s = null) {
698
+ this.brack = s;
699
+ }
700
+ getBracketInfo() {
701
+ let s, t, e, n, i, o, l;
702
+ const h = this.func, a = this.brack;
703
+ if (a === null)
704
+ [i, o, l, s, t, e, n] = Ee(h);
705
+ else if (a.length === 2)
706
+ [i, o, l, s, t, e, n] = Ee(h, a[0], a[1]);
707
+ else if (a.length === 3) {
708
+ if ([i, o, l] = a, i > l && ([l, i] = [i, l]), !(i < o && o < l))
709
+ throw new Error("Not a bracketing interval.");
710
+ if (s = h(i), t = h(o), e = h(l), !(t < s && t < e))
711
+ throw new Error("Not a bracketing interval.");
712
+ n = 3;
713
+ } else
714
+ throw new Error(
715
+ "Bracketing interval must be length 2 or 3 sequence."
716
+ );
717
+ return [i, o, l, s, t, e, n];
718
+ }
719
+ optimize() {
720
+ const s = this.func;
721
+ let [t, e, n, , , , i] = this.getBracketInfo(), o = e, l = e, h = e, a = s(o), u = a, c = a, g, d;
722
+ t < n ? (g = t, d = n) : (g = n, d = t);
723
+ let w = 0;
724
+ i = 1;
725
+ let p = 0, P = 0, f;
726
+ for (; p < this.maxiter; ) {
727
+ const M = this.tol * Math.abs(o) + Ke, E = 2 * M, R = 0.5 * (g + d);
728
+ if (Math.abs(o - R) < E - 0.5 * (d - g))
729
+ break;
730
+ if (Math.abs(w) <= M)
731
+ o >= R ? w = g - o : w = d - o, P = _e * w;
732
+ else {
733
+ const L = (o - l) * (c - u);
734
+ let S = (o - h) * (c - a), k = (o - h) * S - (o - l) * L;
735
+ S = 2 * (S - L), S > 0 && (k = -k), S = Math.abs(S);
736
+ const D = w;
737
+ w = P, k > S * (g - o) && k < S * (d - o) && Math.abs(k) < Math.abs(0.5 * S * D) ? (P = k * 1 / S, f = o + P, (f - g < E || d - f < E) && (R - o >= 0 ? P = M : P = -M)) : (o >= R ? w = g - o : w = d - o, P = _e * w);
738
+ }
739
+ Math.abs(P) < M ? P >= 0 ? f = o + M : f = o - M : f = o + P;
740
+ const v = s(f);
741
+ i += 1, v > c ? (f < o ? g = f : d = f, v <= a || l === o ? (h = l, l = f, u = a, a = v) : (v <= u || h === o || h === l) && (h = f, u = v)) : (f >= o ? g = o : d = o, h = l, l = o, o = f, u = a, a = c, c = v), p += 1;
742
+ }
743
+ this.xmin = o, this.fval = c, this.iter = p, this.funcalls = i;
744
+ }
745
+ results() {
746
+ return {
747
+ argMin: this.xmin,
748
+ fMin: this.fval,
749
+ iterations: this.iter,
750
+ funcCalls: this.funcalls
751
+ };
752
+ }
753
+ run() {
754
+ return this.optimize(), this.results();
755
+ }
756
+ }
757
+ function Ce(r, s = 1e-8, t = 1e3) {
758
+ const e = new He(r, s, t);
759
+ return e.setBracket([0, 1]), e.run();
760
+ }
761
+ function qe(r) {
762
+ if (r.__esModule) return r;
763
+ var s = r.default;
764
+ if (typeof s == "function") {
765
+ var t = function e() {
766
+ return this instanceof e ? Reflect.construct(s, arguments, this.constructor) : s.apply(this, arguments);
767
+ };
768
+ t.prototype = s.prototype;
769
+ } else t = {};
770
+ return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(r).forEach(function(e) {
771
+ var n = Object.getOwnPropertyDescriptor(r, e);
772
+ Object.defineProperty(t, e, n.get ? n : {
773
+ enumerable: !0,
774
+ get: function() {
775
+ return r[e];
776
+ }
777
+ });
778
+ }), t;
779
+ }
780
+ var $ = {};
781
+ const ts = Object.prototype.toString;
782
+ function Ct(r) {
783
+ const s = ts.call(r);
784
+ return s.endsWith("Array]") && !s.includes("Big");
785
+ }
786
+ const es = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
787
+ __proto__: null,
788
+ isAnyArray: Ct
789
+ }, Symbol.toStringTag, { value: "Module" })), ss = /* @__PURE__ */ qe(es);
790
+ function ns(r) {
791
+ var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
792
+ if (!Ct(r))
793
+ throw new TypeError("input must be an array");
794
+ if (r.length === 0)
795
+ throw new TypeError("input must not be empty");
796
+ var t = s.fromIndex, e = t === void 0 ? 0 : t, n = s.toIndex, i = n === void 0 ? r.length : n;
797
+ if (e < 0 || e >= r.length || !Number.isInteger(e))
798
+ throw new Error("fromIndex must be a positive integer smaller than length");
799
+ if (i <= e || i > r.length || !Number.isInteger(i))
800
+ throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");
801
+ for (var o = r[e], l = e + 1; l < i; l++)
802
+ r[l] > o && (o = r[l]);
803
+ return o;
804
+ }
805
+ function is(r) {
806
+ var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
807
+ if (!Ct(r))
808
+ throw new TypeError("input must be an array");
809
+ if (r.length === 0)
810
+ throw new TypeError("input must not be empty");
811
+ var t = s.fromIndex, e = t === void 0 ? 0 : t, n = s.toIndex, i = n === void 0 ? r.length : n;
812
+ if (e < 0 || e >= r.length || !Number.isInteger(e))
813
+ throw new Error("fromIndex must be a positive integer smaller than length");
814
+ if (i <= e || i > r.length || !Number.isInteger(i))
815
+ throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");
816
+ for (var o = r[e], l = e + 1; l < i; l++)
817
+ r[l] < o && (o = r[l]);
818
+ return o;
819
+ }
820
+ function rs(r) {
821
+ var s = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
822
+ if (Ct(r)) {
823
+ if (r.length === 0)
824
+ throw new TypeError("input must not be empty");
825
+ } else throw new TypeError("input must be an array");
826
+ var t;
827
+ if (s.output !== void 0) {
828
+ if (!Ct(s.output))
829
+ throw new TypeError("output option must be an array if specified");
830
+ t = s.output;
831
+ } else
832
+ t = new Array(r.length);
833
+ var e = is(r), n = ns(r);
834
+ if (e === n)
835
+ throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");
836
+ var i = s.min, o = i === void 0 ? s.autoMinMax ? e : 0 : i, l = s.max, h = l === void 0 ? s.autoMinMax ? n : 1 : l;
837
+ if (o >= h)
838
+ throw new RangeError("min option must be smaller than max option");
839
+ for (var a = (h - o) / (n - e), u = 0; u < r.length; u++)
840
+ t[u] = (r[u] - e) * a + o;
841
+ return t;
842
+ }
843
+ const os = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
844
+ __proto__: null,
845
+ default: rs
846
+ }, Symbol.toStringTag, { value: "Module" })), ls = /* @__PURE__ */ qe(os);
847
+ Object.defineProperty($, "__esModule", { value: !0 });
848
+ var st = ss, je = ls;
849
+ const Ut = " ".repeat(2), Fe = " ".repeat(4);
850
+ function hs() {
851
+ return xe(this);
852
+ }
853
+ function xe(r, s = {}) {
854
+ const {
855
+ maxRows: t = 15,
856
+ maxColumns: e = 10,
857
+ maxNumSize: n = 8,
858
+ padMinus: i = "auto"
859
+ } = s;
860
+ return `${r.constructor.name} {
861
+ ${Ut}[
862
+ ${Fe}${as(r, t, e, n, i)}
863
+ ${Ut}]
864
+ ${Ut}rows: ${r.rows}
865
+ ${Ut}columns: ${r.columns}
866
+ }`;
867
+ }
868
+ function as(r, s, t, e, n) {
869
+ const { rows: i, columns: o } = r, l = Math.min(i, s), h = Math.min(o, t), a = [];
870
+ if (n === "auto") {
871
+ n = !1;
872
+ t: for (let u = 0; u < l; u++)
873
+ for (let c = 0; c < h; c++)
874
+ if (r.get(u, c) < 0) {
875
+ n = !0;
876
+ break t;
877
+ }
878
+ }
879
+ for (let u = 0; u < l; u++) {
880
+ let c = [];
881
+ for (let g = 0; g < h; g++)
882
+ c.push(us(r.get(u, g), e, n));
883
+ a.push(`${c.join(" ")}`);
884
+ }
885
+ return h !== o && (a[a.length - 1] += ` ... ${o - t} more columns`), l !== i && a.push(`... ${i - s} more rows`), a.join(`
886
+ ${Fe}`);
887
+ }
888
+ function us(r, s, t) {
889
+ return (r >= 0 && t ? ` ${Se(r, s - 1)}` : Se(r, s)).padEnd(s);
890
+ }
891
+ function Se(r, s) {
892
+ let t = r.toString();
893
+ if (t.length <= s) return t;
894
+ let e = r.toFixed(s);
895
+ if (e.length > s && (e = r.toFixed(Math.max(0, s - (e.length - s)))), e.length <= s && !e.startsWith("0.000") && !e.startsWith("-0.000"))
896
+ return e;
897
+ let n = r.toExponential(s);
898
+ return n.length > s && (n = r.toExponential(Math.max(0, s - (n.length - s)))), n.slice(0);
899
+ }
900
+ function cs(r, s) {
901
+ r.prototype.add = function(e) {
902
+ return typeof e == "number" ? this.addS(e) : this.addM(e);
903
+ }, r.prototype.addS = function(e) {
904
+ for (let n = 0; n < this.rows; n++)
905
+ for (let i = 0; i < this.columns; i++)
906
+ this.set(n, i, this.get(n, i) + e);
907
+ return this;
908
+ }, r.prototype.addM = function(e) {
909
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
910
+ throw new RangeError("Matrices dimensions must be equal");
911
+ for (let n = 0; n < this.rows; n++)
912
+ for (let i = 0; i < this.columns; i++)
913
+ this.set(n, i, this.get(n, i) + e.get(n, i));
914
+ return this;
915
+ }, r.add = function(e, n) {
916
+ return new s(e).add(n);
917
+ }, r.prototype.sub = function(e) {
918
+ return typeof e == "number" ? this.subS(e) : this.subM(e);
919
+ }, r.prototype.subS = function(e) {
920
+ for (let n = 0; n < this.rows; n++)
921
+ for (let i = 0; i < this.columns; i++)
922
+ this.set(n, i, this.get(n, i) - e);
923
+ return this;
924
+ }, r.prototype.subM = function(e) {
925
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
926
+ throw new RangeError("Matrices dimensions must be equal");
927
+ for (let n = 0; n < this.rows; n++)
928
+ for (let i = 0; i < this.columns; i++)
929
+ this.set(n, i, this.get(n, i) - e.get(n, i));
930
+ return this;
931
+ }, r.sub = function(e, n) {
932
+ return new s(e).sub(n);
933
+ }, r.prototype.subtract = r.prototype.sub, r.prototype.subtractS = r.prototype.subS, r.prototype.subtractM = r.prototype.subM, r.subtract = r.sub, r.prototype.mul = function(e) {
934
+ return typeof e == "number" ? this.mulS(e) : this.mulM(e);
935
+ }, r.prototype.mulS = function(e) {
936
+ for (let n = 0; n < this.rows; n++)
937
+ for (let i = 0; i < this.columns; i++)
938
+ this.set(n, i, this.get(n, i) * e);
939
+ return this;
940
+ }, r.prototype.mulM = function(e) {
941
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
942
+ throw new RangeError("Matrices dimensions must be equal");
943
+ for (let n = 0; n < this.rows; n++)
944
+ for (let i = 0; i < this.columns; i++)
945
+ this.set(n, i, this.get(n, i) * e.get(n, i));
946
+ return this;
947
+ }, r.mul = function(e, n) {
948
+ return new s(e).mul(n);
949
+ }, r.prototype.multiply = r.prototype.mul, r.prototype.multiplyS = r.prototype.mulS, r.prototype.multiplyM = r.prototype.mulM, r.multiply = r.mul, r.prototype.div = function(e) {
950
+ return typeof e == "number" ? this.divS(e) : this.divM(e);
951
+ }, r.prototype.divS = function(e) {
952
+ for (let n = 0; n < this.rows; n++)
953
+ for (let i = 0; i < this.columns; i++)
954
+ this.set(n, i, this.get(n, i) / e);
955
+ return this;
956
+ }, r.prototype.divM = function(e) {
957
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
958
+ throw new RangeError("Matrices dimensions must be equal");
959
+ for (let n = 0; n < this.rows; n++)
960
+ for (let i = 0; i < this.columns; i++)
961
+ this.set(n, i, this.get(n, i) / e.get(n, i));
962
+ return this;
963
+ }, r.div = function(e, n) {
964
+ return new s(e).div(n);
965
+ }, r.prototype.divide = r.prototype.div, r.prototype.divideS = r.prototype.divS, r.prototype.divideM = r.prototype.divM, r.divide = r.div, r.prototype.mod = function(e) {
966
+ return typeof e == "number" ? this.modS(e) : this.modM(e);
967
+ }, r.prototype.modS = function(e) {
968
+ for (let n = 0; n < this.rows; n++)
969
+ for (let i = 0; i < this.columns; i++)
970
+ this.set(n, i, this.get(n, i) % e);
971
+ return this;
972
+ }, r.prototype.modM = function(e) {
973
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
974
+ throw new RangeError("Matrices dimensions must be equal");
975
+ for (let n = 0; n < this.rows; n++)
976
+ for (let i = 0; i < this.columns; i++)
977
+ this.set(n, i, this.get(n, i) % e.get(n, i));
978
+ return this;
979
+ }, r.mod = function(e, n) {
980
+ return new s(e).mod(n);
981
+ }, r.prototype.modulus = r.prototype.mod, r.prototype.modulusS = r.prototype.modS, r.prototype.modulusM = r.prototype.modM, r.modulus = r.mod, r.prototype.and = function(e) {
982
+ return typeof e == "number" ? this.andS(e) : this.andM(e);
983
+ }, r.prototype.andS = function(e) {
984
+ for (let n = 0; n < this.rows; n++)
985
+ for (let i = 0; i < this.columns; i++)
986
+ this.set(n, i, this.get(n, i) & e);
987
+ return this;
988
+ }, r.prototype.andM = function(e) {
989
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
990
+ throw new RangeError("Matrices dimensions must be equal");
991
+ for (let n = 0; n < this.rows; n++)
992
+ for (let i = 0; i < this.columns; i++)
993
+ this.set(n, i, this.get(n, i) & e.get(n, i));
994
+ return this;
995
+ }, r.and = function(e, n) {
996
+ return new s(e).and(n);
997
+ }, r.prototype.or = function(e) {
998
+ return typeof e == "number" ? this.orS(e) : this.orM(e);
999
+ }, r.prototype.orS = function(e) {
1000
+ for (let n = 0; n < this.rows; n++)
1001
+ for (let i = 0; i < this.columns; i++)
1002
+ this.set(n, i, this.get(n, i) | e);
1003
+ return this;
1004
+ }, r.prototype.orM = function(e) {
1005
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
1006
+ throw new RangeError("Matrices dimensions must be equal");
1007
+ for (let n = 0; n < this.rows; n++)
1008
+ for (let i = 0; i < this.columns; i++)
1009
+ this.set(n, i, this.get(n, i) | e.get(n, i));
1010
+ return this;
1011
+ }, r.or = function(e, n) {
1012
+ return new s(e).or(n);
1013
+ }, r.prototype.xor = function(e) {
1014
+ return typeof e == "number" ? this.xorS(e) : this.xorM(e);
1015
+ }, r.prototype.xorS = function(e) {
1016
+ for (let n = 0; n < this.rows; n++)
1017
+ for (let i = 0; i < this.columns; i++)
1018
+ this.set(n, i, this.get(n, i) ^ e);
1019
+ return this;
1020
+ }, r.prototype.xorM = function(e) {
1021
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
1022
+ throw new RangeError("Matrices dimensions must be equal");
1023
+ for (let n = 0; n < this.rows; n++)
1024
+ for (let i = 0; i < this.columns; i++)
1025
+ this.set(n, i, this.get(n, i) ^ e.get(n, i));
1026
+ return this;
1027
+ }, r.xor = function(e, n) {
1028
+ return new s(e).xor(n);
1029
+ }, r.prototype.leftShift = function(e) {
1030
+ return typeof e == "number" ? this.leftShiftS(e) : this.leftShiftM(e);
1031
+ }, r.prototype.leftShiftS = function(e) {
1032
+ for (let n = 0; n < this.rows; n++)
1033
+ for (let i = 0; i < this.columns; i++)
1034
+ this.set(n, i, this.get(n, i) << e);
1035
+ return this;
1036
+ }, r.prototype.leftShiftM = function(e) {
1037
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
1038
+ throw new RangeError("Matrices dimensions must be equal");
1039
+ for (let n = 0; n < this.rows; n++)
1040
+ for (let i = 0; i < this.columns; i++)
1041
+ this.set(n, i, this.get(n, i) << e.get(n, i));
1042
+ return this;
1043
+ }, r.leftShift = function(e, n) {
1044
+ return new s(e).leftShift(n);
1045
+ }, r.prototype.signPropagatingRightShift = function(e) {
1046
+ return typeof e == "number" ? this.signPropagatingRightShiftS(e) : this.signPropagatingRightShiftM(e);
1047
+ }, r.prototype.signPropagatingRightShiftS = function(e) {
1048
+ for (let n = 0; n < this.rows; n++)
1049
+ for (let i = 0; i < this.columns; i++)
1050
+ this.set(n, i, this.get(n, i) >> e);
1051
+ return this;
1052
+ }, r.prototype.signPropagatingRightShiftM = function(e) {
1053
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
1054
+ throw new RangeError("Matrices dimensions must be equal");
1055
+ for (let n = 0; n < this.rows; n++)
1056
+ for (let i = 0; i < this.columns; i++)
1057
+ this.set(n, i, this.get(n, i) >> e.get(n, i));
1058
+ return this;
1059
+ }, r.signPropagatingRightShift = function(e, n) {
1060
+ return new s(e).signPropagatingRightShift(n);
1061
+ }, r.prototype.rightShift = function(e) {
1062
+ return typeof e == "number" ? this.rightShiftS(e) : this.rightShiftM(e);
1063
+ }, r.prototype.rightShiftS = function(e) {
1064
+ for (let n = 0; n < this.rows; n++)
1065
+ for (let i = 0; i < this.columns; i++)
1066
+ this.set(n, i, this.get(n, i) >>> e);
1067
+ return this;
1068
+ }, r.prototype.rightShiftM = function(e) {
1069
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
1070
+ throw new RangeError("Matrices dimensions must be equal");
1071
+ for (let n = 0; n < this.rows; n++)
1072
+ for (let i = 0; i < this.columns; i++)
1073
+ this.set(n, i, this.get(n, i) >>> e.get(n, i));
1074
+ return this;
1075
+ }, r.rightShift = function(e, n) {
1076
+ return new s(e).rightShift(n);
1077
+ }, r.prototype.zeroFillRightShift = r.prototype.rightShift, r.prototype.zeroFillRightShiftS = r.prototype.rightShiftS, r.prototype.zeroFillRightShiftM = r.prototype.rightShiftM, r.zeroFillRightShift = r.rightShift, r.prototype.not = function() {
1078
+ for (let e = 0; e < this.rows; e++)
1079
+ for (let n = 0; n < this.columns; n++)
1080
+ this.set(e, n, ~this.get(e, n));
1081
+ return this;
1082
+ }, r.not = function(e) {
1083
+ return new s(e).not();
1084
+ }, r.prototype.abs = function() {
1085
+ for (let e = 0; e < this.rows; e++)
1086
+ for (let n = 0; n < this.columns; n++)
1087
+ this.set(e, n, Math.abs(this.get(e, n)));
1088
+ return this;
1089
+ }, r.abs = function(e) {
1090
+ return new s(e).abs();
1091
+ }, r.prototype.acos = function() {
1092
+ for (let e = 0; e < this.rows; e++)
1093
+ for (let n = 0; n < this.columns; n++)
1094
+ this.set(e, n, Math.acos(this.get(e, n)));
1095
+ return this;
1096
+ }, r.acos = function(e) {
1097
+ return new s(e).acos();
1098
+ }, r.prototype.acosh = function() {
1099
+ for (let e = 0; e < this.rows; e++)
1100
+ for (let n = 0; n < this.columns; n++)
1101
+ this.set(e, n, Math.acosh(this.get(e, n)));
1102
+ return this;
1103
+ }, r.acosh = function(e) {
1104
+ return new s(e).acosh();
1105
+ }, r.prototype.asin = function() {
1106
+ for (let e = 0; e < this.rows; e++)
1107
+ for (let n = 0; n < this.columns; n++)
1108
+ this.set(e, n, Math.asin(this.get(e, n)));
1109
+ return this;
1110
+ }, r.asin = function(e) {
1111
+ return new s(e).asin();
1112
+ }, r.prototype.asinh = function() {
1113
+ for (let e = 0; e < this.rows; e++)
1114
+ for (let n = 0; n < this.columns; n++)
1115
+ this.set(e, n, Math.asinh(this.get(e, n)));
1116
+ return this;
1117
+ }, r.asinh = function(e) {
1118
+ return new s(e).asinh();
1119
+ }, r.prototype.atan = function() {
1120
+ for (let e = 0; e < this.rows; e++)
1121
+ for (let n = 0; n < this.columns; n++)
1122
+ this.set(e, n, Math.atan(this.get(e, n)));
1123
+ return this;
1124
+ }, r.atan = function(e) {
1125
+ return new s(e).atan();
1126
+ }, r.prototype.atanh = function() {
1127
+ for (let e = 0; e < this.rows; e++)
1128
+ for (let n = 0; n < this.columns; n++)
1129
+ this.set(e, n, Math.atanh(this.get(e, n)));
1130
+ return this;
1131
+ }, r.atanh = function(e) {
1132
+ return new s(e).atanh();
1133
+ }, r.prototype.cbrt = function() {
1134
+ for (let e = 0; e < this.rows; e++)
1135
+ for (let n = 0; n < this.columns; n++)
1136
+ this.set(e, n, Math.cbrt(this.get(e, n)));
1137
+ return this;
1138
+ }, r.cbrt = function(e) {
1139
+ return new s(e).cbrt();
1140
+ }, r.prototype.ceil = function() {
1141
+ for (let e = 0; e < this.rows; e++)
1142
+ for (let n = 0; n < this.columns; n++)
1143
+ this.set(e, n, Math.ceil(this.get(e, n)));
1144
+ return this;
1145
+ }, r.ceil = function(e) {
1146
+ return new s(e).ceil();
1147
+ }, r.prototype.clz32 = function() {
1148
+ for (let e = 0; e < this.rows; e++)
1149
+ for (let n = 0; n < this.columns; n++)
1150
+ this.set(e, n, Math.clz32(this.get(e, n)));
1151
+ return this;
1152
+ }, r.clz32 = function(e) {
1153
+ return new s(e).clz32();
1154
+ }, r.prototype.cos = function() {
1155
+ for (let e = 0; e < this.rows; e++)
1156
+ for (let n = 0; n < this.columns; n++)
1157
+ this.set(e, n, Math.cos(this.get(e, n)));
1158
+ return this;
1159
+ }, r.cos = function(e) {
1160
+ return new s(e).cos();
1161
+ }, r.prototype.cosh = function() {
1162
+ for (let e = 0; e < this.rows; e++)
1163
+ for (let n = 0; n < this.columns; n++)
1164
+ this.set(e, n, Math.cosh(this.get(e, n)));
1165
+ return this;
1166
+ }, r.cosh = function(e) {
1167
+ return new s(e).cosh();
1168
+ }, r.prototype.exp = function() {
1169
+ for (let e = 0; e < this.rows; e++)
1170
+ for (let n = 0; n < this.columns; n++)
1171
+ this.set(e, n, Math.exp(this.get(e, n)));
1172
+ return this;
1173
+ }, r.exp = function(e) {
1174
+ return new s(e).exp();
1175
+ }, r.prototype.expm1 = function() {
1176
+ for (let e = 0; e < this.rows; e++)
1177
+ for (let n = 0; n < this.columns; n++)
1178
+ this.set(e, n, Math.expm1(this.get(e, n)));
1179
+ return this;
1180
+ }, r.expm1 = function(e) {
1181
+ return new s(e).expm1();
1182
+ }, r.prototype.floor = function() {
1183
+ for (let e = 0; e < this.rows; e++)
1184
+ for (let n = 0; n < this.columns; n++)
1185
+ this.set(e, n, Math.floor(this.get(e, n)));
1186
+ return this;
1187
+ }, r.floor = function(e) {
1188
+ return new s(e).floor();
1189
+ }, r.prototype.fround = function() {
1190
+ for (let e = 0; e < this.rows; e++)
1191
+ for (let n = 0; n < this.columns; n++)
1192
+ this.set(e, n, Math.fround(this.get(e, n)));
1193
+ return this;
1194
+ }, r.fround = function(e) {
1195
+ return new s(e).fround();
1196
+ }, r.prototype.log = function() {
1197
+ for (let e = 0; e < this.rows; e++)
1198
+ for (let n = 0; n < this.columns; n++)
1199
+ this.set(e, n, Math.log(this.get(e, n)));
1200
+ return this;
1201
+ }, r.log = function(e) {
1202
+ return new s(e).log();
1203
+ }, r.prototype.log1p = function() {
1204
+ for (let e = 0; e < this.rows; e++)
1205
+ for (let n = 0; n < this.columns; n++)
1206
+ this.set(e, n, Math.log1p(this.get(e, n)));
1207
+ return this;
1208
+ }, r.log1p = function(e) {
1209
+ return new s(e).log1p();
1210
+ }, r.prototype.log10 = function() {
1211
+ for (let e = 0; e < this.rows; e++)
1212
+ for (let n = 0; n < this.columns; n++)
1213
+ this.set(e, n, Math.log10(this.get(e, n)));
1214
+ return this;
1215
+ }, r.log10 = function(e) {
1216
+ return new s(e).log10();
1217
+ }, r.prototype.log2 = function() {
1218
+ for (let e = 0; e < this.rows; e++)
1219
+ for (let n = 0; n < this.columns; n++)
1220
+ this.set(e, n, Math.log2(this.get(e, n)));
1221
+ return this;
1222
+ }, r.log2 = function(e) {
1223
+ return new s(e).log2();
1224
+ }, r.prototype.round = function() {
1225
+ for (let e = 0; e < this.rows; e++)
1226
+ for (let n = 0; n < this.columns; n++)
1227
+ this.set(e, n, Math.round(this.get(e, n)));
1228
+ return this;
1229
+ }, r.round = function(e) {
1230
+ return new s(e).round();
1231
+ }, r.prototype.sign = function() {
1232
+ for (let e = 0; e < this.rows; e++)
1233
+ for (let n = 0; n < this.columns; n++)
1234
+ this.set(e, n, Math.sign(this.get(e, n)));
1235
+ return this;
1236
+ }, r.sign = function(e) {
1237
+ return new s(e).sign();
1238
+ }, r.prototype.sin = function() {
1239
+ for (let e = 0; e < this.rows; e++)
1240
+ for (let n = 0; n < this.columns; n++)
1241
+ this.set(e, n, Math.sin(this.get(e, n)));
1242
+ return this;
1243
+ }, r.sin = function(e) {
1244
+ return new s(e).sin();
1245
+ }, r.prototype.sinh = function() {
1246
+ for (let e = 0; e < this.rows; e++)
1247
+ for (let n = 0; n < this.columns; n++)
1248
+ this.set(e, n, Math.sinh(this.get(e, n)));
1249
+ return this;
1250
+ }, r.sinh = function(e) {
1251
+ return new s(e).sinh();
1252
+ }, r.prototype.sqrt = function() {
1253
+ for (let e = 0; e < this.rows; e++)
1254
+ for (let n = 0; n < this.columns; n++)
1255
+ this.set(e, n, Math.sqrt(this.get(e, n)));
1256
+ return this;
1257
+ }, r.sqrt = function(e) {
1258
+ return new s(e).sqrt();
1259
+ }, r.prototype.tan = function() {
1260
+ for (let e = 0; e < this.rows; e++)
1261
+ for (let n = 0; n < this.columns; n++)
1262
+ this.set(e, n, Math.tan(this.get(e, n)));
1263
+ return this;
1264
+ }, r.tan = function(e) {
1265
+ return new s(e).tan();
1266
+ }, r.prototype.tanh = function() {
1267
+ for (let e = 0; e < this.rows; e++)
1268
+ for (let n = 0; n < this.columns; n++)
1269
+ this.set(e, n, Math.tanh(this.get(e, n)));
1270
+ return this;
1271
+ }, r.tanh = function(e) {
1272
+ return new s(e).tanh();
1273
+ }, r.prototype.trunc = function() {
1274
+ for (let e = 0; e < this.rows; e++)
1275
+ for (let n = 0; n < this.columns; n++)
1276
+ this.set(e, n, Math.trunc(this.get(e, n)));
1277
+ return this;
1278
+ }, r.trunc = function(e) {
1279
+ return new s(e).trunc();
1280
+ }, r.pow = function(e, n) {
1281
+ return new s(e).pow(n);
1282
+ }, r.prototype.pow = function(e) {
1283
+ return typeof e == "number" ? this.powS(e) : this.powM(e);
1284
+ }, r.prototype.powS = function(e) {
1285
+ for (let n = 0; n < this.rows; n++)
1286
+ for (let i = 0; i < this.columns; i++)
1287
+ this.set(n, i, this.get(n, i) ** e);
1288
+ return this;
1289
+ }, r.prototype.powM = function(e) {
1290
+ if (e = s.checkMatrix(e), this.rows !== e.rows || this.columns !== e.columns)
1291
+ throw new RangeError("Matrices dimensions must be equal");
1292
+ for (let n = 0; n < this.rows; n++)
1293
+ for (let i = 0; i < this.columns; i++)
1294
+ this.set(n, i, this.get(n, i) ** e.get(n, i));
1295
+ return this;
1296
+ };
1297
+ }
1298
+ function ot(r, s, t) {
1299
+ let e = t ? r.rows : r.rows - 1;
1300
+ if (s < 0 || s > e)
1301
+ throw new RangeError("Row index out of range");
1302
+ }
1303
+ function lt(r, s, t) {
1304
+ let e = t ? r.columns : r.columns - 1;
1305
+ if (s < 0 || s > e)
1306
+ throw new RangeError("Column index out of range");
1307
+ }
1308
+ function Pt(r, s) {
1309
+ if (s.to1DArray && (s = s.to1DArray()), s.length !== r.columns)
1310
+ throw new RangeError(
1311
+ "vector size must be the same as the number of columns"
1312
+ );
1313
+ return s;
1314
+ }
1315
+ function bt(r, s) {
1316
+ if (s.to1DArray && (s = s.to1DArray()), s.length !== r.rows)
1317
+ throw new RangeError("vector size must be the same as the number of rows");
1318
+ return s;
1319
+ }
1320
+ function ge(r, s) {
1321
+ if (!st.isAnyArray(s))
1322
+ throw new TypeError("row indices must be an array");
1323
+ for (let t = 0; t < s.length; t++)
1324
+ if (s[t] < 0 || s[t] >= r.rows)
1325
+ throw new RangeError("row indices are out of range");
1326
+ }
1327
+ function we(r, s) {
1328
+ if (!st.isAnyArray(s))
1329
+ throw new TypeError("column indices must be an array");
1330
+ for (let t = 0; t < s.length; t++)
1331
+ if (s[t] < 0 || s[t] >= r.columns)
1332
+ throw new RangeError("column indices are out of range");
1333
+ }
1334
+ function ae(r, s, t, e, n) {
1335
+ if (arguments.length !== 5)
1336
+ throw new RangeError("expected 4 arguments");
1337
+ if (Yt("startRow", s), Yt("endRow", t), Yt("startColumn", e), Yt("endColumn", n), s > t || e > n || s < 0 || s >= r.rows || t < 0 || t >= r.rows || e < 0 || e >= r.columns || n < 0 || n >= r.columns)
1338
+ throw new RangeError("Submatrix indices are out of range");
1339
+ }
1340
+ function Ht(r, s = 0) {
1341
+ let t = [];
1342
+ for (let e = 0; e < r; e++)
1343
+ t.push(s);
1344
+ return t;
1345
+ }
1346
+ function Yt(r, s) {
1347
+ if (typeof s != "number")
1348
+ throw new TypeError(`${r} must be a number`);
1349
+ }
1350
+ function yt(r) {
1351
+ if (r.isEmpty())
1352
+ throw new Error("Empty matrix has no elements to index");
1353
+ }
1354
+ function fs(r) {
1355
+ let s = Ht(r.rows);
1356
+ for (let t = 0; t < r.rows; ++t)
1357
+ for (let e = 0; e < r.columns; ++e)
1358
+ s[t] += r.get(t, e);
1359
+ return s;
1360
+ }
1361
+ function ms(r) {
1362
+ let s = Ht(r.columns);
1363
+ for (let t = 0; t < r.rows; ++t)
1364
+ for (let e = 0; e < r.columns; ++e)
1365
+ s[e] += r.get(t, e);
1366
+ return s;
1367
+ }
1368
+ function gs(r) {
1369
+ let s = 0;
1370
+ for (let t = 0; t < r.rows; t++)
1371
+ for (let e = 0; e < r.columns; e++)
1372
+ s += r.get(t, e);
1373
+ return s;
1374
+ }
1375
+ function ws(r) {
1376
+ let s = Ht(r.rows, 1);
1377
+ for (let t = 0; t < r.rows; ++t)
1378
+ for (let e = 0; e < r.columns; ++e)
1379
+ s[t] *= r.get(t, e);
1380
+ return s;
1381
+ }
1382
+ function ps(r) {
1383
+ let s = Ht(r.columns, 1);
1384
+ for (let t = 0; t < r.rows; ++t)
1385
+ for (let e = 0; e < r.columns; ++e)
1386
+ s[e] *= r.get(t, e);
1387
+ return s;
1388
+ }
1389
+ function ds(r) {
1390
+ let s = 1;
1391
+ for (let t = 0; t < r.rows; t++)
1392
+ for (let e = 0; e < r.columns; e++)
1393
+ s *= r.get(t, e);
1394
+ return s;
1395
+ }
1396
+ function Ms(r, s, t) {
1397
+ const e = r.rows, n = r.columns, i = [];
1398
+ for (let o = 0; o < e; o++) {
1399
+ let l = 0, h = 0, a = 0;
1400
+ for (let u = 0; u < n; u++)
1401
+ a = r.get(o, u) - t[o], l += a, h += a * a;
1402
+ s ? i.push((h - l * l / n) / (n - 1)) : i.push((h - l * l / n) / n);
1403
+ }
1404
+ return i;
1405
+ }
1406
+ function ys(r, s, t) {
1407
+ const e = r.rows, n = r.columns, i = [];
1408
+ for (let o = 0; o < n; o++) {
1409
+ let l = 0, h = 0, a = 0;
1410
+ for (let u = 0; u < e; u++)
1411
+ a = r.get(u, o) - t[o], l += a, h += a * a;
1412
+ s ? i.push((h - l * l / e) / (e - 1)) : i.push((h - l * l / e) / e);
1413
+ }
1414
+ return i;
1415
+ }
1416
+ function Ps(r, s, t) {
1417
+ const e = r.rows, n = r.columns, i = e * n;
1418
+ let o = 0, l = 0, h = 0;
1419
+ for (let a = 0; a < e; a++)
1420
+ for (let u = 0; u < n; u++)
1421
+ h = r.get(a, u) - t, o += h, l += h * h;
1422
+ return s ? (l - o * o / i) / (i - 1) : (l - o * o / i) / i;
1423
+ }
1424
+ function bs(r, s) {
1425
+ for (let t = 0; t < r.rows; t++)
1426
+ for (let e = 0; e < r.columns; e++)
1427
+ r.set(t, e, r.get(t, e) - s[t]);
1428
+ }
1429
+ function Es(r, s) {
1430
+ for (let t = 0; t < r.rows; t++)
1431
+ for (let e = 0; e < r.columns; e++)
1432
+ r.set(t, e, r.get(t, e) - s[e]);
1433
+ }
1434
+ function _s(r, s) {
1435
+ for (let t = 0; t < r.rows; t++)
1436
+ for (let e = 0; e < r.columns; e++)
1437
+ r.set(t, e, r.get(t, e) - s);
1438
+ }
1439
+ function js(r) {
1440
+ const s = [];
1441
+ for (let t = 0; t < r.rows; t++) {
1442
+ let e = 0;
1443
+ for (let n = 0; n < r.columns; n++)
1444
+ e += r.get(t, n) ** 2 / (r.columns - 1);
1445
+ s.push(Math.sqrt(e));
1446
+ }
1447
+ return s;
1448
+ }
1449
+ function Ss(r, s) {
1450
+ for (let t = 0; t < r.rows; t++)
1451
+ for (let e = 0; e < r.columns; e++)
1452
+ r.set(t, e, r.get(t, e) / s[t]);
1453
+ }
1454
+ function ks(r) {
1455
+ const s = [];
1456
+ for (let t = 0; t < r.columns; t++) {
1457
+ let e = 0;
1458
+ for (let n = 0; n < r.rows; n++)
1459
+ e += r.get(n, t) ** 2 / (r.rows - 1);
1460
+ s.push(Math.sqrt(e));
1461
+ }
1462
+ return s;
1463
+ }
1464
+ function Rs(r, s) {
1465
+ for (let t = 0; t < r.rows; t++)
1466
+ for (let e = 0; e < r.columns; e++)
1467
+ r.set(t, e, r.get(t, e) / s[e]);
1468
+ }
1469
+ function vs(r) {
1470
+ const s = r.size - 1;
1471
+ let t = 0;
1472
+ for (let e = 0; e < r.columns; e++)
1473
+ for (let n = 0; n < r.rows; n++)
1474
+ t += r.get(n, e) ** 2 / s;
1475
+ return Math.sqrt(t);
1476
+ }
1477
+ function Ts(r, s) {
1478
+ for (let t = 0; t < r.rows; t++)
1479
+ for (let e = 0; e < r.columns; e++)
1480
+ r.set(t, e, r.get(t, e) / s);
1481
+ }
1482
+ class V {
1483
+ static from1DArray(s, t, e) {
1484
+ if (s * t !== e.length)
1485
+ throw new RangeError("data length does not match given dimensions");
1486
+ let i = new _(s, t);
1487
+ for (let o = 0; o < s; o++)
1488
+ for (let l = 0; l < t; l++)
1489
+ i.set(o, l, e[o * t + l]);
1490
+ return i;
1491
+ }
1492
+ static rowVector(s) {
1493
+ let t = new _(1, s.length);
1494
+ for (let e = 0; e < s.length; e++)
1495
+ t.set(0, e, s[e]);
1496
+ return t;
1497
+ }
1498
+ static columnVector(s) {
1499
+ let t = new _(s.length, 1);
1500
+ for (let e = 0; e < s.length; e++)
1501
+ t.set(e, 0, s[e]);
1502
+ return t;
1503
+ }
1504
+ static zeros(s, t) {
1505
+ return new _(s, t);
1506
+ }
1507
+ static ones(s, t) {
1508
+ return new _(s, t).fill(1);
1509
+ }
1510
+ static rand(s, t, e = {}) {
1511
+ if (typeof e != "object")
1512
+ throw new TypeError("options must be an object");
1513
+ const { random: n = Math.random } = e;
1514
+ let i = new _(s, t);
1515
+ for (let o = 0; o < s; o++)
1516
+ for (let l = 0; l < t; l++)
1517
+ i.set(o, l, n());
1518
+ return i;
1519
+ }
1520
+ static randInt(s, t, e = {}) {
1521
+ if (typeof e != "object")
1522
+ throw new TypeError("options must be an object");
1523
+ const { min: n = 0, max: i = 1e3, random: o = Math.random } = e;
1524
+ if (!Number.isInteger(n)) throw new TypeError("min must be an integer");
1525
+ if (!Number.isInteger(i)) throw new TypeError("max must be an integer");
1526
+ if (n >= i) throw new RangeError("min must be smaller than max");
1527
+ let l = i - n, h = new _(s, t);
1528
+ for (let a = 0; a < s; a++)
1529
+ for (let u = 0; u < t; u++) {
1530
+ let c = n + Math.round(o() * l);
1531
+ h.set(a, u, c);
1532
+ }
1533
+ return h;
1534
+ }
1535
+ static eye(s, t, e) {
1536
+ t === void 0 && (t = s), e === void 0 && (e = 1);
1537
+ let n = Math.min(s, t), i = this.zeros(s, t);
1538
+ for (let o = 0; o < n; o++)
1539
+ i.set(o, o, e);
1540
+ return i;
1541
+ }
1542
+ static diag(s, t, e) {
1543
+ let n = s.length;
1544
+ t === void 0 && (t = n), e === void 0 && (e = t);
1545
+ let i = Math.min(n, t, e), o = this.zeros(t, e);
1546
+ for (let l = 0; l < i; l++)
1547
+ o.set(l, l, s[l]);
1548
+ return o;
1549
+ }
1550
+ static min(s, t) {
1551
+ s = this.checkMatrix(s), t = this.checkMatrix(t);
1552
+ let e = s.rows, n = s.columns, i = new _(e, n);
1553
+ for (let o = 0; o < e; o++)
1554
+ for (let l = 0; l < n; l++)
1555
+ i.set(o, l, Math.min(s.get(o, l), t.get(o, l)));
1556
+ return i;
1557
+ }
1558
+ static max(s, t) {
1559
+ s = this.checkMatrix(s), t = this.checkMatrix(t);
1560
+ let e = s.rows, n = s.columns, i = new this(e, n);
1561
+ for (let o = 0; o < e; o++)
1562
+ for (let l = 0; l < n; l++)
1563
+ i.set(o, l, Math.max(s.get(o, l), t.get(o, l)));
1564
+ return i;
1565
+ }
1566
+ static checkMatrix(s) {
1567
+ return V.isMatrix(s) ? s : new _(s);
1568
+ }
1569
+ static isMatrix(s) {
1570
+ return s != null && s.klass === "Matrix";
1571
+ }
1572
+ get size() {
1573
+ return this.rows * this.columns;
1574
+ }
1575
+ apply(s) {
1576
+ if (typeof s != "function")
1577
+ throw new TypeError("callback must be a function");
1578
+ for (let t = 0; t < this.rows; t++)
1579
+ for (let e = 0; e < this.columns; e++)
1580
+ s.call(this, t, e);
1581
+ return this;
1582
+ }
1583
+ to1DArray() {
1584
+ let s = [];
1585
+ for (let t = 0; t < this.rows; t++)
1586
+ for (let e = 0; e < this.columns; e++)
1587
+ s.push(this.get(t, e));
1588
+ return s;
1589
+ }
1590
+ to2DArray() {
1591
+ let s = [];
1592
+ for (let t = 0; t < this.rows; t++) {
1593
+ s.push([]);
1594
+ for (let e = 0; e < this.columns; e++)
1595
+ s[t].push(this.get(t, e));
1596
+ }
1597
+ return s;
1598
+ }
1599
+ toJSON() {
1600
+ return this.to2DArray();
1601
+ }
1602
+ isRowVector() {
1603
+ return this.rows === 1;
1604
+ }
1605
+ isColumnVector() {
1606
+ return this.columns === 1;
1607
+ }
1608
+ isVector() {
1609
+ return this.rows === 1 || this.columns === 1;
1610
+ }
1611
+ isSquare() {
1612
+ return this.rows === this.columns;
1613
+ }
1614
+ isEmpty() {
1615
+ return this.rows === 0 || this.columns === 0;
1616
+ }
1617
+ isSymmetric() {
1618
+ if (this.isSquare()) {
1619
+ for (let s = 0; s < this.rows; s++)
1620
+ for (let t = 0; t <= s; t++)
1621
+ if (this.get(s, t) !== this.get(t, s))
1622
+ return !1;
1623
+ return !0;
1624
+ }
1625
+ return !1;
1626
+ }
1627
+ isDistance() {
1628
+ if (!this.isSymmetric()) return !1;
1629
+ for (let s = 0; s < this.rows; s++)
1630
+ if (this.get(s, s) !== 0) return !1;
1631
+ return !0;
1632
+ }
1633
+ isEchelonForm() {
1634
+ let s = 0, t = 0, e = -1, n = !0, i = !1;
1635
+ for (; s < this.rows && n; ) {
1636
+ for (t = 0, i = !1; t < this.columns && i === !1; )
1637
+ this.get(s, t) === 0 ? t++ : this.get(s, t) === 1 && t > e ? (i = !0, e = t) : (n = !1, i = !0);
1638
+ s++;
1639
+ }
1640
+ return n;
1641
+ }
1642
+ isReducedEchelonForm() {
1643
+ let s = 0, t = 0, e = -1, n = !0, i = !1;
1644
+ for (; s < this.rows && n; ) {
1645
+ for (t = 0, i = !1; t < this.columns && i === !1; )
1646
+ this.get(s, t) === 0 ? t++ : this.get(s, t) === 1 && t > e ? (i = !0, e = t) : (n = !1, i = !0);
1647
+ for (let o = t + 1; o < this.rows; o++)
1648
+ this.get(s, o) !== 0 && (n = !1);
1649
+ s++;
1650
+ }
1651
+ return n;
1652
+ }
1653
+ echelonForm() {
1654
+ let s = this.clone(), t = 0, e = 0;
1655
+ for (; t < s.rows && e < s.columns; ) {
1656
+ let n = t;
1657
+ for (let i = t; i < s.rows; i++)
1658
+ s.get(i, e) > s.get(n, e) && (n = i);
1659
+ if (s.get(n, e) === 0)
1660
+ e++;
1661
+ else {
1662
+ s.swapRows(t, n);
1663
+ let i = s.get(t, e);
1664
+ for (let o = e; o < s.columns; o++)
1665
+ s.set(t, o, s.get(t, o) / i);
1666
+ for (let o = t + 1; o < s.rows; o++) {
1667
+ let l = s.get(o, e) / s.get(t, e);
1668
+ s.set(o, e, 0);
1669
+ for (let h = e + 1; h < s.columns; h++)
1670
+ s.set(o, h, s.get(o, h) - s.get(t, h) * l);
1671
+ }
1672
+ t++, e++;
1673
+ }
1674
+ }
1675
+ return s;
1676
+ }
1677
+ reducedEchelonForm() {
1678
+ let s = this.echelonForm(), t = s.columns, e = s.rows, n = e - 1;
1679
+ for (; n >= 0; )
1680
+ if (s.maxRow(n) === 0)
1681
+ n--;
1682
+ else {
1683
+ let i = 0, o = !1;
1684
+ for (; i < e && o === !1; )
1685
+ s.get(n, i) === 1 ? o = !0 : i++;
1686
+ for (let l = 0; l < n; l++) {
1687
+ let h = s.get(l, i);
1688
+ for (let a = i; a < t; a++) {
1689
+ let u = s.get(l, a) - h * s.get(n, a);
1690
+ s.set(l, a, u);
1691
+ }
1692
+ }
1693
+ n--;
1694
+ }
1695
+ return s;
1696
+ }
1697
+ set() {
1698
+ throw new Error("set method is unimplemented");
1699
+ }
1700
+ get() {
1701
+ throw new Error("get method is unimplemented");
1702
+ }
1703
+ repeat(s = {}) {
1704
+ if (typeof s != "object")
1705
+ throw new TypeError("options must be an object");
1706
+ const { rows: t = 1, columns: e = 1 } = s;
1707
+ if (!Number.isInteger(t) || t <= 0)
1708
+ throw new TypeError("rows must be a positive integer");
1709
+ if (!Number.isInteger(e) || e <= 0)
1710
+ throw new TypeError("columns must be a positive integer");
1711
+ let n = new _(this.rows * t, this.columns * e);
1712
+ for (let i = 0; i < t; i++)
1713
+ for (let o = 0; o < e; o++)
1714
+ n.setSubMatrix(this, this.rows * i, this.columns * o);
1715
+ return n;
1716
+ }
1717
+ fill(s) {
1718
+ for (let t = 0; t < this.rows; t++)
1719
+ for (let e = 0; e < this.columns; e++)
1720
+ this.set(t, e, s);
1721
+ return this;
1722
+ }
1723
+ neg() {
1724
+ return this.mulS(-1);
1725
+ }
1726
+ getRow(s) {
1727
+ ot(this, s);
1728
+ let t = [];
1729
+ for (let e = 0; e < this.columns; e++)
1730
+ t.push(this.get(s, e));
1731
+ return t;
1732
+ }
1733
+ getRowVector(s) {
1734
+ return _.rowVector(this.getRow(s));
1735
+ }
1736
+ setRow(s, t) {
1737
+ ot(this, s), t = Pt(this, t);
1738
+ for (let e = 0; e < this.columns; e++)
1739
+ this.set(s, e, t[e]);
1740
+ return this;
1741
+ }
1742
+ swapRows(s, t) {
1743
+ ot(this, s), ot(this, t);
1744
+ for (let e = 0; e < this.columns; e++) {
1745
+ let n = this.get(s, e);
1746
+ this.set(s, e, this.get(t, e)), this.set(t, e, n);
1747
+ }
1748
+ return this;
1749
+ }
1750
+ getColumn(s) {
1751
+ lt(this, s);
1752
+ let t = [];
1753
+ for (let e = 0; e < this.rows; e++)
1754
+ t.push(this.get(e, s));
1755
+ return t;
1756
+ }
1757
+ getColumnVector(s) {
1758
+ return _.columnVector(this.getColumn(s));
1759
+ }
1760
+ setColumn(s, t) {
1761
+ lt(this, s), t = bt(this, t);
1762
+ for (let e = 0; e < this.rows; e++)
1763
+ this.set(e, s, t[e]);
1764
+ return this;
1765
+ }
1766
+ swapColumns(s, t) {
1767
+ lt(this, s), lt(this, t);
1768
+ for (let e = 0; e < this.rows; e++) {
1769
+ let n = this.get(e, s);
1770
+ this.set(e, s, this.get(e, t)), this.set(e, t, n);
1771
+ }
1772
+ return this;
1773
+ }
1774
+ addRowVector(s) {
1775
+ s = Pt(this, s);
1776
+ for (let t = 0; t < this.rows; t++)
1777
+ for (let e = 0; e < this.columns; e++)
1778
+ this.set(t, e, this.get(t, e) + s[e]);
1779
+ return this;
1780
+ }
1781
+ subRowVector(s) {
1782
+ s = Pt(this, s);
1783
+ for (let t = 0; t < this.rows; t++)
1784
+ for (let e = 0; e < this.columns; e++)
1785
+ this.set(t, e, this.get(t, e) - s[e]);
1786
+ return this;
1787
+ }
1788
+ mulRowVector(s) {
1789
+ s = Pt(this, s);
1790
+ for (let t = 0; t < this.rows; t++)
1791
+ for (let e = 0; e < this.columns; e++)
1792
+ this.set(t, e, this.get(t, e) * s[e]);
1793
+ return this;
1794
+ }
1795
+ divRowVector(s) {
1796
+ s = Pt(this, s);
1797
+ for (let t = 0; t < this.rows; t++)
1798
+ for (let e = 0; e < this.columns; e++)
1799
+ this.set(t, e, this.get(t, e) / s[e]);
1800
+ return this;
1801
+ }
1802
+ addColumnVector(s) {
1803
+ s = bt(this, s);
1804
+ for (let t = 0; t < this.rows; t++)
1805
+ for (let e = 0; e < this.columns; e++)
1806
+ this.set(t, e, this.get(t, e) + s[t]);
1807
+ return this;
1808
+ }
1809
+ subColumnVector(s) {
1810
+ s = bt(this, s);
1811
+ for (let t = 0; t < this.rows; t++)
1812
+ for (let e = 0; e < this.columns; e++)
1813
+ this.set(t, e, this.get(t, e) - s[t]);
1814
+ return this;
1815
+ }
1816
+ mulColumnVector(s) {
1817
+ s = bt(this, s);
1818
+ for (let t = 0; t < this.rows; t++)
1819
+ for (let e = 0; e < this.columns; e++)
1820
+ this.set(t, e, this.get(t, e) * s[t]);
1821
+ return this;
1822
+ }
1823
+ divColumnVector(s) {
1824
+ s = bt(this, s);
1825
+ for (let t = 0; t < this.rows; t++)
1826
+ for (let e = 0; e < this.columns; e++)
1827
+ this.set(t, e, this.get(t, e) / s[t]);
1828
+ return this;
1829
+ }
1830
+ mulRow(s, t) {
1831
+ ot(this, s);
1832
+ for (let e = 0; e < this.columns; e++)
1833
+ this.set(s, e, this.get(s, e) * t);
1834
+ return this;
1835
+ }
1836
+ mulColumn(s, t) {
1837
+ lt(this, s);
1838
+ for (let e = 0; e < this.rows; e++)
1839
+ this.set(e, s, this.get(e, s) * t);
1840
+ return this;
1841
+ }
1842
+ max(s) {
1843
+ if (this.isEmpty())
1844
+ return NaN;
1845
+ switch (s) {
1846
+ case "row": {
1847
+ const t = new Array(this.rows).fill(Number.NEGATIVE_INFINITY);
1848
+ for (let e = 0; e < this.rows; e++)
1849
+ for (let n = 0; n < this.columns; n++)
1850
+ this.get(e, n) > t[e] && (t[e] = this.get(e, n));
1851
+ return t;
1852
+ }
1853
+ case "column": {
1854
+ const t = new Array(this.columns).fill(Number.NEGATIVE_INFINITY);
1855
+ for (let e = 0; e < this.rows; e++)
1856
+ for (let n = 0; n < this.columns; n++)
1857
+ this.get(e, n) > t[n] && (t[n] = this.get(e, n));
1858
+ return t;
1859
+ }
1860
+ case void 0: {
1861
+ let t = this.get(0, 0);
1862
+ for (let e = 0; e < this.rows; e++)
1863
+ for (let n = 0; n < this.columns; n++)
1864
+ this.get(e, n) > t && (t = this.get(e, n));
1865
+ return t;
1866
+ }
1867
+ default:
1868
+ throw new Error(`invalid option: ${s}`);
1869
+ }
1870
+ }
1871
+ maxIndex() {
1872
+ yt(this);
1873
+ let s = this.get(0, 0), t = [0, 0];
1874
+ for (let e = 0; e < this.rows; e++)
1875
+ for (let n = 0; n < this.columns; n++)
1876
+ this.get(e, n) > s && (s = this.get(e, n), t[0] = e, t[1] = n);
1877
+ return t;
1878
+ }
1879
+ min(s) {
1880
+ if (this.isEmpty())
1881
+ return NaN;
1882
+ switch (s) {
1883
+ case "row": {
1884
+ const t = new Array(this.rows).fill(Number.POSITIVE_INFINITY);
1885
+ for (let e = 0; e < this.rows; e++)
1886
+ for (let n = 0; n < this.columns; n++)
1887
+ this.get(e, n) < t[e] && (t[e] = this.get(e, n));
1888
+ return t;
1889
+ }
1890
+ case "column": {
1891
+ const t = new Array(this.columns).fill(Number.POSITIVE_INFINITY);
1892
+ for (let e = 0; e < this.rows; e++)
1893
+ for (let n = 0; n < this.columns; n++)
1894
+ this.get(e, n) < t[n] && (t[n] = this.get(e, n));
1895
+ return t;
1896
+ }
1897
+ case void 0: {
1898
+ let t = this.get(0, 0);
1899
+ for (let e = 0; e < this.rows; e++)
1900
+ for (let n = 0; n < this.columns; n++)
1901
+ this.get(e, n) < t && (t = this.get(e, n));
1902
+ return t;
1903
+ }
1904
+ default:
1905
+ throw new Error(`invalid option: ${s}`);
1906
+ }
1907
+ }
1908
+ minIndex() {
1909
+ yt(this);
1910
+ let s = this.get(0, 0), t = [0, 0];
1911
+ for (let e = 0; e < this.rows; e++)
1912
+ for (let n = 0; n < this.columns; n++)
1913
+ this.get(e, n) < s && (s = this.get(e, n), t[0] = e, t[1] = n);
1914
+ return t;
1915
+ }
1916
+ maxRow(s) {
1917
+ if (ot(this, s), this.isEmpty())
1918
+ return NaN;
1919
+ let t = this.get(s, 0);
1920
+ for (let e = 1; e < this.columns; e++)
1921
+ this.get(s, e) > t && (t = this.get(s, e));
1922
+ return t;
1923
+ }
1924
+ maxRowIndex(s) {
1925
+ ot(this, s), yt(this);
1926
+ let t = this.get(s, 0), e = [s, 0];
1927
+ for (let n = 1; n < this.columns; n++)
1928
+ this.get(s, n) > t && (t = this.get(s, n), e[1] = n);
1929
+ return e;
1930
+ }
1931
+ minRow(s) {
1932
+ if (ot(this, s), this.isEmpty())
1933
+ return NaN;
1934
+ let t = this.get(s, 0);
1935
+ for (let e = 1; e < this.columns; e++)
1936
+ this.get(s, e) < t && (t = this.get(s, e));
1937
+ return t;
1938
+ }
1939
+ minRowIndex(s) {
1940
+ ot(this, s), yt(this);
1941
+ let t = this.get(s, 0), e = [s, 0];
1942
+ for (let n = 1; n < this.columns; n++)
1943
+ this.get(s, n) < t && (t = this.get(s, n), e[1] = n);
1944
+ return e;
1945
+ }
1946
+ maxColumn(s) {
1947
+ if (lt(this, s), this.isEmpty())
1948
+ return NaN;
1949
+ let t = this.get(0, s);
1950
+ for (let e = 1; e < this.rows; e++)
1951
+ this.get(e, s) > t && (t = this.get(e, s));
1952
+ return t;
1953
+ }
1954
+ maxColumnIndex(s) {
1955
+ lt(this, s), yt(this);
1956
+ let t = this.get(0, s), e = [0, s];
1957
+ for (let n = 1; n < this.rows; n++)
1958
+ this.get(n, s) > t && (t = this.get(n, s), e[0] = n);
1959
+ return e;
1960
+ }
1961
+ minColumn(s) {
1962
+ if (lt(this, s), this.isEmpty())
1963
+ return NaN;
1964
+ let t = this.get(0, s);
1965
+ for (let e = 1; e < this.rows; e++)
1966
+ this.get(e, s) < t && (t = this.get(e, s));
1967
+ return t;
1968
+ }
1969
+ minColumnIndex(s) {
1970
+ lt(this, s), yt(this);
1971
+ let t = this.get(0, s), e = [0, s];
1972
+ for (let n = 1; n < this.rows; n++)
1973
+ this.get(n, s) < t && (t = this.get(n, s), e[0] = n);
1974
+ return e;
1975
+ }
1976
+ diag() {
1977
+ let s = Math.min(this.rows, this.columns), t = [];
1978
+ for (let e = 0; e < s; e++)
1979
+ t.push(this.get(e, e));
1980
+ return t;
1981
+ }
1982
+ norm(s = "frobenius") {
1983
+ switch (s) {
1984
+ case "max":
1985
+ return this.max();
1986
+ case "frobenius":
1987
+ return Math.sqrt(this.dot(this));
1988
+ default:
1989
+ throw new RangeError(`unknown norm type: ${s}`);
1990
+ }
1991
+ }
1992
+ cumulativeSum() {
1993
+ let s = 0;
1994
+ for (let t = 0; t < this.rows; t++)
1995
+ for (let e = 0; e < this.columns; e++)
1996
+ s += this.get(t, e), this.set(t, e, s);
1997
+ return this;
1998
+ }
1999
+ dot(s) {
2000
+ V.isMatrix(s) && (s = s.to1DArray());
2001
+ let t = this.to1DArray();
2002
+ if (t.length !== s.length)
2003
+ throw new RangeError("vectors do not have the same size");
2004
+ let e = 0;
2005
+ for (let n = 0; n < t.length; n++)
2006
+ e += t[n] * s[n];
2007
+ return e;
2008
+ }
2009
+ mmul(s) {
2010
+ s = _.checkMatrix(s);
2011
+ let t = this.rows, e = this.columns, n = s.columns, i = new _(t, n), o = new Float64Array(e);
2012
+ for (let l = 0; l < n; l++) {
2013
+ for (let h = 0; h < e; h++)
2014
+ o[h] = s.get(h, l);
2015
+ for (let h = 0; h < t; h++) {
2016
+ let a = 0;
2017
+ for (let u = 0; u < e; u++)
2018
+ a += this.get(h, u) * o[u];
2019
+ i.set(h, l, a);
2020
+ }
2021
+ }
2022
+ return i;
2023
+ }
2024
+ mpow(s) {
2025
+ if (!this.isSquare())
2026
+ throw new RangeError("Matrix must be square");
2027
+ if (!Number.isInteger(s) || s < 0)
2028
+ throw new RangeError("Exponent must be a non-negative integer");
2029
+ let t = _.eye(this.rows), e = this;
2030
+ for (let n = s; n > 1; n /= 2)
2031
+ n & 1 && (t = t.mmul(e)), e = e.mmul(e);
2032
+ return t;
2033
+ }
2034
+ strassen2x2(s) {
2035
+ s = _.checkMatrix(s);
2036
+ let t = new _(2, 2);
2037
+ const e = this.get(0, 0), n = s.get(0, 0), i = this.get(0, 1), o = s.get(0, 1), l = this.get(1, 0), h = s.get(1, 0), a = this.get(1, 1), u = s.get(1, 1), c = (e + a) * (n + u), g = (l + a) * n, d = e * (o - u), w = a * (h - n), p = (e + i) * u, P = (l - e) * (n + o), f = (i - a) * (h + u), M = c + w - p + f, E = d + p, R = g + w, v = c - g + d + P;
2038
+ return t.set(0, 0, M), t.set(0, 1, E), t.set(1, 0, R), t.set(1, 1, v), t;
2039
+ }
2040
+ strassen3x3(s) {
2041
+ s = _.checkMatrix(s);
2042
+ let t = new _(3, 3);
2043
+ const e = this.get(0, 0), n = this.get(0, 1), i = this.get(0, 2), o = this.get(1, 0), l = this.get(1, 1), h = this.get(1, 2), a = this.get(2, 0), u = this.get(2, 1), c = this.get(2, 2), g = s.get(0, 0), d = s.get(0, 1), w = s.get(0, 2), p = s.get(1, 0), P = s.get(1, 1), f = s.get(1, 2), M = s.get(2, 0), E = s.get(2, 1), R = s.get(2, 2), v = (e + n + i - o - l - u - c) * P, L = (e - o) * (-d + P), S = l * (-g + d + p - P - f - M + R), k = (-e + o + l) * (g - d + P), D = (o + l) * (-g + d), m = e * g, b = (-e + a + u) * (g - w + f), j = (-e + a) * (w - f), y = (a + u) * (-g + w), C = (e + n + i - l - h - a - u) * f, F = u * (-g + w + p - P - f - M + E), I = (-i + u + c) * (P + M - E), B = (i - c) * (P - E), x = i * M, N = (u + c) * (-M + E), A = (-i + l + h) * (f + M - R), O = (i - h) * (f - R), U = (l + h) * (-M + R), T = n * p, z = h * E, X = o * w, G = a * d, W = c * R, se = m + x + T, ne = v + k + D + m + I + x + N, ie = m + b + y + C + x + A + U, re = L + S + k + m + x + A + O, At = L + k + D + m + z, Vt = x + A + O + U + X, Nt = m + b + j + F + I + B + x, $t = I + B + x + N + G, Lt = m + b + j + y + W;
2044
+ return t.set(0, 0, se), t.set(0, 1, ne), t.set(0, 2, ie), t.set(1, 0, re), t.set(1, 1, At), t.set(1, 2, Vt), t.set(2, 0, Nt), t.set(2, 1, $t), t.set(2, 2, Lt), t;
2045
+ }
2046
+ mmulStrassen(s) {
2047
+ s = _.checkMatrix(s);
2048
+ let t = this.clone(), e = t.rows, n = t.columns, i = s.rows, o = s.columns;
2049
+ n !== i && console.warn(
2050
+ `Multiplying ${e} x ${n} and ${i} x ${o} matrix: dimensions do not match.`
2051
+ );
2052
+ function l(c, g, d) {
2053
+ let w = c.rows, p = c.columns;
2054
+ if (w === g && p === d)
2055
+ return c;
2056
+ {
2057
+ let P = V.zeros(g, d);
2058
+ return P = P.setSubMatrix(c, 0, 0), P;
2059
+ }
2060
+ }
2061
+ let h = Math.max(e, i), a = Math.max(n, o);
2062
+ t = l(t, h, a), s = l(s, h, a);
2063
+ function u(c, g, d, w) {
2064
+ if (d <= 512 || w <= 512)
2065
+ return c.mmul(g);
2066
+ d % 2 === 1 && w % 2 === 1 ? (c = l(c, d + 1, w + 1), g = l(g, d + 1, w + 1)) : d % 2 === 1 ? (c = l(c, d + 1, w), g = l(g, d + 1, w)) : w % 2 === 1 && (c = l(c, d, w + 1), g = l(g, d, w + 1));
2067
+ let p = parseInt(c.rows / 2, 10), P = parseInt(c.columns / 2, 10), f = c.subMatrix(0, p - 1, 0, P - 1), M = g.subMatrix(0, p - 1, 0, P - 1), E = c.subMatrix(0, p - 1, P, c.columns - 1), R = g.subMatrix(0, p - 1, P, g.columns - 1), v = c.subMatrix(p, c.rows - 1, 0, P - 1), L = g.subMatrix(p, g.rows - 1, 0, P - 1), S = c.subMatrix(p, c.rows - 1, P, c.columns - 1), k = g.subMatrix(p, g.rows - 1, P, g.columns - 1), D = u(
2068
+ V.add(f, S),
2069
+ V.add(M, k),
2070
+ p,
2071
+ P
2072
+ ), m = u(V.add(v, S), M, p, P), b = u(f, V.sub(R, k), p, P), j = u(S, V.sub(L, M), p, P), y = u(V.add(f, E), k, p, P), C = u(
2073
+ V.sub(v, f),
2074
+ V.add(M, R),
2075
+ p,
2076
+ P
2077
+ ), F = u(
2078
+ V.sub(E, S),
2079
+ V.add(L, k),
2080
+ p,
2081
+ P
2082
+ ), I = V.add(D, j);
2083
+ I.sub(y), I.add(F);
2084
+ let B = V.add(b, y), x = V.add(m, j), N = V.sub(D, m);
2085
+ N.add(b), N.add(C);
2086
+ let A = V.zeros(2 * I.rows, 2 * I.columns);
2087
+ return A = A.setSubMatrix(I, 0, 0), A = A.setSubMatrix(B, I.rows, 0), A = A.setSubMatrix(x, 0, I.columns), A = A.setSubMatrix(N, I.rows, I.columns), A.subMatrix(0, d - 1, 0, w - 1);
2088
+ }
2089
+ return u(t, s, h, a);
2090
+ }
2091
+ scaleRows(s = {}) {
2092
+ if (typeof s != "object")
2093
+ throw new TypeError("options must be an object");
2094
+ const { min: t = 0, max: e = 1 } = s;
2095
+ if (!Number.isFinite(t)) throw new TypeError("min must be a number");
2096
+ if (!Number.isFinite(e)) throw new TypeError("max must be a number");
2097
+ if (t >= e) throw new RangeError("min must be smaller than max");
2098
+ let n = new _(this.rows, this.columns);
2099
+ for (let i = 0; i < this.rows; i++) {
2100
+ const o = this.getRow(i);
2101
+ o.length > 0 && je(o, { min: t, max: e, output: o }), n.setRow(i, o);
2102
+ }
2103
+ return n;
2104
+ }
2105
+ scaleColumns(s = {}) {
2106
+ if (typeof s != "object")
2107
+ throw new TypeError("options must be an object");
2108
+ const { min: t = 0, max: e = 1 } = s;
2109
+ if (!Number.isFinite(t)) throw new TypeError("min must be a number");
2110
+ if (!Number.isFinite(e)) throw new TypeError("max must be a number");
2111
+ if (t >= e) throw new RangeError("min must be smaller than max");
2112
+ let n = new _(this.rows, this.columns);
2113
+ for (let i = 0; i < this.columns; i++) {
2114
+ const o = this.getColumn(i);
2115
+ o.length && je(o, {
2116
+ min: t,
2117
+ max: e,
2118
+ output: o
2119
+ }), n.setColumn(i, o);
2120
+ }
2121
+ return n;
2122
+ }
2123
+ flipRows() {
2124
+ const s = Math.ceil(this.columns / 2);
2125
+ for (let t = 0; t < this.rows; t++)
2126
+ for (let e = 0; e < s; e++) {
2127
+ let n = this.get(t, e), i = this.get(t, this.columns - 1 - e);
2128
+ this.set(t, e, i), this.set(t, this.columns - 1 - e, n);
2129
+ }
2130
+ return this;
2131
+ }
2132
+ flipColumns() {
2133
+ const s = Math.ceil(this.rows / 2);
2134
+ for (let t = 0; t < this.columns; t++)
2135
+ for (let e = 0; e < s; e++) {
2136
+ let n = this.get(e, t), i = this.get(this.rows - 1 - e, t);
2137
+ this.set(e, t, i), this.set(this.rows - 1 - e, t, n);
2138
+ }
2139
+ return this;
2140
+ }
2141
+ kroneckerProduct(s) {
2142
+ s = _.checkMatrix(s);
2143
+ let t = this.rows, e = this.columns, n = s.rows, i = s.columns, o = new _(t * n, e * i);
2144
+ for (let l = 0; l < t; l++)
2145
+ for (let h = 0; h < e; h++)
2146
+ for (let a = 0; a < n; a++)
2147
+ for (let u = 0; u < i; u++)
2148
+ o.set(n * l + a, i * h + u, this.get(l, h) * s.get(a, u));
2149
+ return o;
2150
+ }
2151
+ kroneckerSum(s) {
2152
+ if (s = _.checkMatrix(s), !this.isSquare() || !s.isSquare())
2153
+ throw new Error("Kronecker Sum needs two Square Matrices");
2154
+ let t = this.rows, e = s.rows, n = this.kroneckerProduct(_.eye(e, e)), i = _.eye(t, t).kroneckerProduct(s);
2155
+ return n.add(i);
2156
+ }
2157
+ transpose() {
2158
+ let s = new _(this.columns, this.rows);
2159
+ for (let t = 0; t < this.rows; t++)
2160
+ for (let e = 0; e < this.columns; e++)
2161
+ s.set(e, t, this.get(t, e));
2162
+ return s;
2163
+ }
2164
+ sortRows(s = ke) {
2165
+ for (let t = 0; t < this.rows; t++)
2166
+ this.setRow(t, this.getRow(t).sort(s));
2167
+ return this;
2168
+ }
2169
+ sortColumns(s = ke) {
2170
+ for (let t = 0; t < this.columns; t++)
2171
+ this.setColumn(t, this.getColumn(t).sort(s));
2172
+ return this;
2173
+ }
2174
+ subMatrix(s, t, e, n) {
2175
+ ae(this, s, t, e, n);
2176
+ let i = new _(
2177
+ t - s + 1,
2178
+ n - e + 1
2179
+ );
2180
+ for (let o = s; o <= t; o++)
2181
+ for (let l = e; l <= n; l++)
2182
+ i.set(o - s, l - e, this.get(o, l));
2183
+ return i;
2184
+ }
2185
+ subMatrixRow(s, t, e) {
2186
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.columns - 1), t > e || t < 0 || t >= this.columns || e < 0 || e >= this.columns)
2187
+ throw new RangeError("Argument out of range");
2188
+ let n = new _(s.length, e - t + 1);
2189
+ for (let i = 0; i < s.length; i++)
2190
+ for (let o = t; o <= e; o++) {
2191
+ if (s[i] < 0 || s[i] >= this.rows)
2192
+ throw new RangeError(`Row index out of range: ${s[i]}`);
2193
+ n.set(i, o - t, this.get(s[i], o));
2194
+ }
2195
+ return n;
2196
+ }
2197
+ subMatrixColumn(s, t, e) {
2198
+ if (t === void 0 && (t = 0), e === void 0 && (e = this.rows - 1), t > e || t < 0 || t >= this.rows || e < 0 || e >= this.rows)
2199
+ throw new RangeError("Argument out of range");
2200
+ let n = new _(e - t + 1, s.length);
2201
+ for (let i = 0; i < s.length; i++)
2202
+ for (let o = t; o <= e; o++) {
2203
+ if (s[i] < 0 || s[i] >= this.columns)
2204
+ throw new RangeError(`Column index out of range: ${s[i]}`);
2205
+ n.set(o - t, i, this.get(o, s[i]));
2206
+ }
2207
+ return n;
2208
+ }
2209
+ setSubMatrix(s, t, e) {
2210
+ if (s = _.checkMatrix(s), s.isEmpty())
2211
+ return this;
2212
+ let n = t + s.rows - 1, i = e + s.columns - 1;
2213
+ ae(this, t, n, e, i);
2214
+ for (let o = 0; o < s.rows; o++)
2215
+ for (let l = 0; l < s.columns; l++)
2216
+ this.set(t + o, e + l, s.get(o, l));
2217
+ return this;
2218
+ }
2219
+ selection(s, t) {
2220
+ ge(this, s), we(this, t);
2221
+ let e = new _(s.length, t.length);
2222
+ for (let n = 0; n < s.length; n++) {
2223
+ let i = s[n];
2224
+ for (let o = 0; o < t.length; o++) {
2225
+ let l = t[o];
2226
+ e.set(n, o, this.get(i, l));
2227
+ }
2228
+ }
2229
+ return e;
2230
+ }
2231
+ trace() {
2232
+ let s = Math.min(this.rows, this.columns), t = 0;
2233
+ for (let e = 0; e < s; e++)
2234
+ t += this.get(e, e);
2235
+ return t;
2236
+ }
2237
+ clone() {
2238
+ return this.constructor.copy(this, new _(this.rows, this.columns));
2239
+ }
2240
+ /**
2241
+ * @template {AbstractMatrix} M
2242
+ * @param {AbstractMatrix} from
2243
+ * @param {M} to
2244
+ * @return {M}
2245
+ */
2246
+ static copy(s, t) {
2247
+ for (const [e, n, i] of s.entries())
2248
+ t.set(e, n, i);
2249
+ return t;
2250
+ }
2251
+ sum(s) {
2252
+ switch (s) {
2253
+ case "row":
2254
+ return fs(this);
2255
+ case "column":
2256
+ return ms(this);
2257
+ case void 0:
2258
+ return gs(this);
2259
+ default:
2260
+ throw new Error(`invalid option: ${s}`);
2261
+ }
2262
+ }
2263
+ product(s) {
2264
+ switch (s) {
2265
+ case "row":
2266
+ return ws(this);
2267
+ case "column":
2268
+ return ps(this);
2269
+ case void 0:
2270
+ return ds(this);
2271
+ default:
2272
+ throw new Error(`invalid option: ${s}`);
2273
+ }
2274
+ }
2275
+ mean(s) {
2276
+ const t = this.sum(s);
2277
+ switch (s) {
2278
+ case "row": {
2279
+ for (let e = 0; e < this.rows; e++)
2280
+ t[e] /= this.columns;
2281
+ return t;
2282
+ }
2283
+ case "column": {
2284
+ for (let e = 0; e < this.columns; e++)
2285
+ t[e] /= this.rows;
2286
+ return t;
2287
+ }
2288
+ case void 0:
2289
+ return t / this.size;
2290
+ default:
2291
+ throw new Error(`invalid option: ${s}`);
2292
+ }
2293
+ }
2294
+ variance(s, t = {}) {
2295
+ if (typeof s == "object" && (t = s, s = void 0), typeof t != "object")
2296
+ throw new TypeError("options must be an object");
2297
+ const { unbiased: e = !0, mean: n = this.mean(s) } = t;
2298
+ if (typeof e != "boolean")
2299
+ throw new TypeError("unbiased must be a boolean");
2300
+ switch (s) {
2301
+ case "row": {
2302
+ if (!st.isAnyArray(n))
2303
+ throw new TypeError("mean must be an array");
2304
+ return Ms(this, e, n);
2305
+ }
2306
+ case "column": {
2307
+ if (!st.isAnyArray(n))
2308
+ throw new TypeError("mean must be an array");
2309
+ return ys(this, e, n);
2310
+ }
2311
+ case void 0: {
2312
+ if (typeof n != "number")
2313
+ throw new TypeError("mean must be a number");
2314
+ return Ps(this, e, n);
2315
+ }
2316
+ default:
2317
+ throw new Error(`invalid option: ${s}`);
2318
+ }
2319
+ }
2320
+ standardDeviation(s, t) {
2321
+ typeof s == "object" && (t = s, s = void 0);
2322
+ const e = this.variance(s, t);
2323
+ if (s === void 0)
2324
+ return Math.sqrt(e);
2325
+ for (let n = 0; n < e.length; n++)
2326
+ e[n] = Math.sqrt(e[n]);
2327
+ return e;
2328
+ }
2329
+ center(s, t = {}) {
2330
+ if (typeof s == "object" && (t = s, s = void 0), typeof t != "object")
2331
+ throw new TypeError("options must be an object");
2332
+ const { center: e = this.mean(s) } = t;
2333
+ switch (s) {
2334
+ case "row": {
2335
+ if (!st.isAnyArray(e))
2336
+ throw new TypeError("center must be an array");
2337
+ return bs(this, e), this;
2338
+ }
2339
+ case "column": {
2340
+ if (!st.isAnyArray(e))
2341
+ throw new TypeError("center must be an array");
2342
+ return Es(this, e), this;
2343
+ }
2344
+ case void 0: {
2345
+ if (typeof e != "number")
2346
+ throw new TypeError("center must be a number");
2347
+ return _s(this, e), this;
2348
+ }
2349
+ default:
2350
+ throw new Error(`invalid option: ${s}`);
2351
+ }
2352
+ }
2353
+ scale(s, t = {}) {
2354
+ if (typeof s == "object" && (t = s, s = void 0), typeof t != "object")
2355
+ throw new TypeError("options must be an object");
2356
+ let e = t.scale;
2357
+ switch (s) {
2358
+ case "row": {
2359
+ if (e === void 0)
2360
+ e = js(this);
2361
+ else if (!st.isAnyArray(e))
2362
+ throw new TypeError("scale must be an array");
2363
+ return Ss(this, e), this;
2364
+ }
2365
+ case "column": {
2366
+ if (e === void 0)
2367
+ e = ks(this);
2368
+ else if (!st.isAnyArray(e))
2369
+ throw new TypeError("scale must be an array");
2370
+ return Rs(this, e), this;
2371
+ }
2372
+ case void 0: {
2373
+ if (e === void 0)
2374
+ e = vs(this);
2375
+ else if (typeof e != "number")
2376
+ throw new TypeError("scale must be a number");
2377
+ return Ts(this, e), this;
2378
+ }
2379
+ default:
2380
+ throw new Error(`invalid option: ${s}`);
2381
+ }
2382
+ }
2383
+ toString(s) {
2384
+ return xe(this, s);
2385
+ }
2386
+ [Symbol.iterator]() {
2387
+ return this.entries();
2388
+ }
2389
+ /**
2390
+ * iterator from left to right, from top to bottom
2391
+ * yield [row, column, value]
2392
+ * @returns {Generator<[number, number, number], void, void>}
2393
+ */
2394
+ *entries() {
2395
+ for (let s = 0; s < this.rows; s++)
2396
+ for (let t = 0; t < this.columns; t++)
2397
+ yield [s, t, this.get(s, t)];
2398
+ }
2399
+ /**
2400
+ * iterator from left to right, from top to bottom
2401
+ * yield value
2402
+ * @returns {Generator<number, void, void>}
2403
+ */
2404
+ *values() {
2405
+ for (let s = 0; s < this.rows; s++)
2406
+ for (let t = 0; t < this.columns; t++)
2407
+ yield this.get(s, t);
2408
+ }
2409
+ }
2410
+ V.prototype.klass = "Matrix";
2411
+ typeof Symbol < "u" && (V.prototype[Symbol.for("nodejs.util.inspect.custom")] = hs);
2412
+ function ke(r, s) {
2413
+ return r - s;
2414
+ }
2415
+ function Is(r) {
2416
+ return r.every((s) => typeof s == "number");
2417
+ }
2418
+ V.random = V.rand;
2419
+ V.randomInt = V.randInt;
2420
+ V.diagonal = V.diag;
2421
+ V.prototype.diagonal = V.prototype.diag;
2422
+ V.identity = V.eye;
2423
+ V.prototype.negate = V.prototype.neg;
2424
+ V.prototype.tensorProduct = V.prototype.kroneckerProduct;
2425
+ var Ft, ue, dt;
2426
+ let _ = (dt = class extends V {
2427
+ constructor(t, e) {
2428
+ super();
2429
+ le(this, Ft);
2430
+ /**
2431
+ * @type {Float64Array[]}
2432
+ */
2433
+ q(this, "data");
2434
+ if (dt.isMatrix(t))
2435
+ he(this, Ft, ue).call(this, t.rows, t.columns), dt.copy(t, this);
2436
+ else if (Number.isInteger(t) && t >= 0)
2437
+ he(this, Ft, ue).call(this, t, e);
2438
+ else if (st.isAnyArray(t)) {
2439
+ const n = t;
2440
+ if (t = n.length, e = t ? n[0].length : 0, typeof e != "number")
2441
+ throw new TypeError(
2442
+ "Data must be a 2D array with at least one element"
2443
+ );
2444
+ this.data = [];
2445
+ for (let i = 0; i < t; i++) {
2446
+ if (n[i].length !== e)
2447
+ throw new RangeError("Inconsistent array dimensions");
2448
+ if (!Is(n[i]))
2449
+ throw new TypeError("Input data contains non-numeric values");
2450
+ this.data.push(Float64Array.from(n[i]));
2451
+ }
2452
+ this.rows = t, this.columns = e;
2453
+ } else
2454
+ throw new TypeError(
2455
+ "First argument must be a positive number or an array"
2456
+ );
2457
+ }
2458
+ set(t, e, n) {
2459
+ return this.data[t][e] = n, this;
2460
+ }
2461
+ get(t, e) {
2462
+ return this.data[t][e];
2463
+ }
2464
+ removeRow(t) {
2465
+ return ot(this, t), this.data.splice(t, 1), this.rows -= 1, this;
2466
+ }
2467
+ addRow(t, e) {
2468
+ return e === void 0 && (e = t, t = this.rows), ot(this, t, !0), e = Float64Array.from(Pt(this, e)), this.data.splice(t, 0, e), this.rows += 1, this;
2469
+ }
2470
+ removeColumn(t) {
2471
+ lt(this, t);
2472
+ for (let e = 0; e < this.rows; e++) {
2473
+ const n = new Float64Array(this.columns - 1);
2474
+ for (let i = 0; i < t; i++)
2475
+ n[i] = this.data[e][i];
2476
+ for (let i = t + 1; i < this.columns; i++)
2477
+ n[i - 1] = this.data[e][i];
2478
+ this.data[e] = n;
2479
+ }
2480
+ return this.columns -= 1, this;
2481
+ }
2482
+ addColumn(t, e) {
2483
+ typeof e > "u" && (e = t, t = this.columns), lt(this, t, !0), e = bt(this, e);
2484
+ for (let n = 0; n < this.rows; n++) {
2485
+ const i = new Float64Array(this.columns + 1);
2486
+ let o = 0;
2487
+ for (; o < t; o++)
2488
+ i[o] = this.data[n][o];
2489
+ for (i[o++] = e[n]; o < this.columns + 1; o++)
2490
+ i[o] = this.data[n][o - 1];
2491
+ this.data[n] = i;
2492
+ }
2493
+ return this.columns += 1, this;
2494
+ }
2495
+ }, Ft = new WeakSet(), /**
2496
+ * Init an empty matrix
2497
+ * @param {number} nRows
2498
+ * @param {number} nColumns
2499
+ */
2500
+ ue = function(t, e) {
2501
+ if (this.data = [], Number.isInteger(e) && e >= 0)
2502
+ for (let n = 0; n < t; n++)
2503
+ this.data.push(new Float64Array(e));
2504
+ else
2505
+ throw new TypeError("nColumns must be a positive integer");
2506
+ this.rows = t, this.columns = e;
2507
+ }, dt);
2508
+ cs(V, _);
2509
+ var K;
2510
+ const Jt = class Jt extends V {
2511
+ /**
2512
+ * @param {number | AbstractMatrix | ArrayLike<ArrayLike<number>>} diagonalSize
2513
+ * @return {this}
2514
+ */
2515
+ constructor(t) {
2516
+ super();
2517
+ /** @type {Matrix} */
2518
+ le(this, K);
2519
+ if (_.isMatrix(t)) {
2520
+ if (!t.isSymmetric())
2521
+ throw new TypeError("not symmetric data");
2522
+ Dt(this, K, _.copy(
2523
+ t,
2524
+ new _(t.rows, t.rows)
2525
+ ));
2526
+ } else if (Number.isInteger(t) && t >= 0)
2527
+ Dt(this, K, new _(t, t));
2528
+ else if (Dt(this, K, new _(t)), !this.isSymmetric())
2529
+ throw new TypeError("not symmetric data");
2530
+ }
2531
+ get size() {
2532
+ return ht(this, K).size;
2533
+ }
2534
+ get rows() {
2535
+ return ht(this, K).rows;
2536
+ }
2537
+ get columns() {
2538
+ return ht(this, K).columns;
2539
+ }
2540
+ get diagonalSize() {
2541
+ return this.rows;
2542
+ }
2543
+ /**
2544
+ * not the same as matrix.isSymmetric()
2545
+ * Here is to check if it's instanceof SymmetricMatrix without bundling issues
2546
+ *
2547
+ * @param value
2548
+ * @returns {boolean}
2549
+ */
2550
+ static isSymmetricMatrix(t) {
2551
+ return _.isMatrix(t) && t.klassType === "SymmetricMatrix";
2552
+ }
2553
+ /**
2554
+ * @param diagonalSize
2555
+ * @return {SymmetricMatrix}
2556
+ */
2557
+ static zeros(t) {
2558
+ return new this(t);
2559
+ }
2560
+ /**
2561
+ * @param diagonalSize
2562
+ * @return {SymmetricMatrix}
2563
+ */
2564
+ static ones(t) {
2565
+ return new this(t).fill(1);
2566
+ }
2567
+ clone() {
2568
+ const t = new Jt(this.diagonalSize);
2569
+ for (const [e, n, i] of this.upperRightEntries())
2570
+ t.set(e, n, i);
2571
+ return t;
2572
+ }
2573
+ toMatrix() {
2574
+ return new _(this);
2575
+ }
2576
+ get(t, e) {
2577
+ return ht(this, K).get(t, e);
2578
+ }
2579
+ set(t, e, n) {
2580
+ return ht(this, K).set(t, e, n), ht(this, K).set(e, t, n), this;
2581
+ }
2582
+ removeCross(t) {
2583
+ return ht(this, K).removeRow(t), ht(this, K).removeColumn(t), this;
2584
+ }
2585
+ addCross(t, e) {
2586
+ e === void 0 && (e = t, t = this.diagonalSize);
2587
+ const n = e.slice();
2588
+ return n.splice(t, 1), ht(this, K).addRow(t, n), ht(this, K).addColumn(t, e), this;
2589
+ }
2590
+ /**
2591
+ * @param {Mask[]} mask
2592
+ */
2593
+ applyMask(t) {
2594
+ if (t.length !== this.diagonalSize)
2595
+ throw new RangeError("Mask size do not match with matrix size");
2596
+ const e = [];
2597
+ for (const [n, i] of t.entries())
2598
+ i || e.push(n);
2599
+ e.reverse();
2600
+ for (const n of e)
2601
+ this.removeCross(n);
2602
+ return this;
2603
+ }
2604
+ /**
2605
+ * Compact format upper-right corner of matrix
2606
+ * iterate from left to right, from top to bottom.
2607
+ *
2608
+ * ```
2609
+ * A B C D
2610
+ * A 1 2 3 4
2611
+ * B 2 5 6 7
2612
+ * C 3 6 8 9
2613
+ * D 4 7 9 10
2614
+ * ```
2615
+ *
2616
+ * will return compact 1D array `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]`
2617
+ *
2618
+ * length is S(i=0, n=sideSize) => 10 for a 4 sideSized matrix
2619
+ *
2620
+ * @returns {number[]}
2621
+ */
2622
+ toCompact() {
2623
+ const { diagonalSize: t } = this, e = new Array(t * (t + 1) / 2);
2624
+ for (let n = 0, i = 0, o = 0; o < e.length; o++)
2625
+ e[o] = this.get(i, n), ++n >= t && (n = ++i);
2626
+ return e;
2627
+ }
2628
+ /**
2629
+ * @param {number[]} compact
2630
+ * @return {SymmetricMatrix}
2631
+ */
2632
+ static fromCompact(t) {
2633
+ const e = t.length, n = (Math.sqrt(8 * e + 1) - 1) / 2;
2634
+ if (!Number.isInteger(n))
2635
+ throw new TypeError(
2636
+ `This array is not a compact representation of a Symmetric Matrix, ${JSON.stringify(
2637
+ t
2638
+ )}`
2639
+ );
2640
+ const i = new Jt(n);
2641
+ for (let o = 0, l = 0, h = 0; h < e; h++)
2642
+ i.set(o, l, t[h]), ++o >= n && (o = ++l);
2643
+ return i;
2644
+ }
2645
+ /**
2646
+ * half iterator upper-right-corner from left to right, from top to bottom
2647
+ * yield [row, column, value]
2648
+ *
2649
+ * @returns {Generator<[number, number, number], void, void>}
2650
+ */
2651
+ *upperRightEntries() {
2652
+ for (let t = 0, e = 0; t < this.diagonalSize; void 0) {
2653
+ const n = this.get(t, e);
2654
+ yield [t, e, n], ++e >= this.diagonalSize && (e = ++t);
2655
+ }
2656
+ }
2657
+ /**
2658
+ * half iterator upper-right-corner from left to right, from top to bottom
2659
+ * yield value
2660
+ *
2661
+ * @returns {Generator<[number, number, number], void, void>}
2662
+ */
2663
+ *upperRightValues() {
2664
+ for (let t = 0, e = 0; t < this.diagonalSize; void 0)
2665
+ yield this.get(t, e), ++e >= this.diagonalSize && (e = ++t);
2666
+ }
2667
+ };
2668
+ K = new WeakMap();
2669
+ let pt = Jt;
2670
+ pt.prototype.klassType = "SymmetricMatrix";
2671
+ class te extends pt {
2672
+ /**
2673
+ * not the same as matrix.isSymmetric()
2674
+ * Here is to check if it's instanceof SymmetricMatrix without bundling issues
2675
+ *
2676
+ * @param value
2677
+ * @returns {boolean}
2678
+ */
2679
+ static isDistanceMatrix(s) {
2680
+ return pt.isSymmetricMatrix(s) && s.klassSubType === "DistanceMatrix";
2681
+ }
2682
+ constructor(s) {
2683
+ if (super(s), !this.isDistance())
2684
+ throw new TypeError("Provided arguments do no produce a distance matrix");
2685
+ }
2686
+ set(s, t, e) {
2687
+ return s === t && (e = 0), super.set(s, t, e);
2688
+ }
2689
+ addCross(s, t) {
2690
+ return t === void 0 && (t = s, s = this.diagonalSize), t = t.slice(), t[s] = 0, super.addCross(s, t);
2691
+ }
2692
+ toSymmetricMatrix() {
2693
+ return new pt(this);
2694
+ }
2695
+ clone() {
2696
+ const s = new te(this.diagonalSize);
2697
+ for (const [t, e, n] of this.upperRightEntries())
2698
+ t !== e && s.set(t, e, n);
2699
+ return s;
2700
+ }
2701
+ /**
2702
+ * Compact format upper-right corner of matrix
2703
+ * no diagonal (only zeros)
2704
+ * iterable from left to right, from top to bottom.
2705
+ *
2706
+ * ```
2707
+ * A B C D
2708
+ * A 0 1 2 3
2709
+ * B 1 0 4 5
2710
+ * C 2 4 0 6
2711
+ * D 3 5 6 0
2712
+ * ```
2713
+ *
2714
+ * will return compact 1D array `[1, 2, 3, 4, 5, 6]`
2715
+ *
2716
+ * length is S(i=0, n=sideSize-1) => 6 for a 4 side sized matrix
2717
+ *
2718
+ * @returns {number[]}
2719
+ */
2720
+ toCompact() {
2721
+ const { diagonalSize: s } = this, t = (s - 1) * s / 2, e = new Array(t);
2722
+ for (let n = 1, i = 0, o = 0; o < e.length; o++)
2723
+ e[o] = this.get(i, n), ++n >= s && (n = ++i + 1);
2724
+ return e;
2725
+ }
2726
+ /**
2727
+ * @param {number[]} compact
2728
+ */
2729
+ static fromCompact(s) {
2730
+ const t = s.length;
2731
+ if (t === 0)
2732
+ return new this(0);
2733
+ const e = (Math.sqrt(8 * t + 1) + 1) / 2;
2734
+ if (!Number.isInteger(e))
2735
+ throw new TypeError(
2736
+ `This array is not a compact representation of a DistanceMatrix, ${JSON.stringify(
2737
+ s
2738
+ )}`
2739
+ );
2740
+ const n = new this(e);
2741
+ for (let i = 1, o = 0, l = 0; l < t; l++)
2742
+ n.set(i, o, s[l]), ++i >= e && (i = ++o + 1);
2743
+ return n;
2744
+ }
2745
+ }
2746
+ te.prototype.klassSubType = "DistanceMatrix";
2747
+ class ft extends V {
2748
+ constructor(s, t, e) {
2749
+ super(), this.matrix = s, this.rows = t, this.columns = e;
2750
+ }
2751
+ }
2752
+ class Cs extends ft {
2753
+ constructor(s, t) {
2754
+ lt(s, t), super(s, s.rows, 1), this.column = t;
2755
+ }
2756
+ set(s, t, e) {
2757
+ return this.matrix.set(s, this.column, e), this;
2758
+ }
2759
+ get(s) {
2760
+ return this.matrix.get(s, this.column);
2761
+ }
2762
+ }
2763
+ class qs extends ft {
2764
+ constructor(s, t) {
2765
+ we(s, t), super(s, s.rows, t.length), this.columnIndices = t;
2766
+ }
2767
+ set(s, t, e) {
2768
+ return this.matrix.set(s, this.columnIndices[t], e), this;
2769
+ }
2770
+ get(s, t) {
2771
+ return this.matrix.get(s, this.columnIndices[t]);
2772
+ }
2773
+ }
2774
+ class Fs extends ft {
2775
+ constructor(s) {
2776
+ super(s, s.rows, s.columns);
2777
+ }
2778
+ set(s, t, e) {
2779
+ return this.matrix.set(s, this.columns - t - 1, e), this;
2780
+ }
2781
+ get(s, t) {
2782
+ return this.matrix.get(s, this.columns - t - 1);
2783
+ }
2784
+ }
2785
+ class xs extends ft {
2786
+ constructor(s) {
2787
+ super(s, s.rows, s.columns);
2788
+ }
2789
+ set(s, t, e) {
2790
+ return this.matrix.set(this.rows - s - 1, t, e), this;
2791
+ }
2792
+ get(s, t) {
2793
+ return this.matrix.get(this.rows - s - 1, t);
2794
+ }
2795
+ }
2796
+ class As extends ft {
2797
+ constructor(s, t) {
2798
+ ot(s, t), super(s, 1, s.columns), this.row = t;
2799
+ }
2800
+ set(s, t, e) {
2801
+ return this.matrix.set(this.row, t, e), this;
2802
+ }
2803
+ get(s, t) {
2804
+ return this.matrix.get(this.row, t);
2805
+ }
2806
+ }
2807
+ class Vs extends ft {
2808
+ constructor(s, t) {
2809
+ ge(s, t), super(s, t.length, s.columns), this.rowIndices = t;
2810
+ }
2811
+ set(s, t, e) {
2812
+ return this.matrix.set(this.rowIndices[s], t, e), this;
2813
+ }
2814
+ get(s, t) {
2815
+ return this.matrix.get(this.rowIndices[s], t);
2816
+ }
2817
+ }
2818
+ class Gt extends ft {
2819
+ constructor(s, t, e) {
2820
+ ge(s, t), we(s, e), super(s, t.length, e.length), this.rowIndices = t, this.columnIndices = e;
2821
+ }
2822
+ set(s, t, e) {
2823
+ return this.matrix.set(
2824
+ this.rowIndices[s],
2825
+ this.columnIndices[t],
2826
+ e
2827
+ ), this;
2828
+ }
2829
+ get(s, t) {
2830
+ return this.matrix.get(
2831
+ this.rowIndices[s],
2832
+ this.columnIndices[t]
2833
+ );
2834
+ }
2835
+ }
2836
+ class Ns extends ft {
2837
+ constructor(s, t, e, n, i) {
2838
+ ae(s, t, e, n, i), super(s, e - t + 1, i - n + 1), this.startRow = t, this.startColumn = n;
2839
+ }
2840
+ set(s, t, e) {
2841
+ return this.matrix.set(
2842
+ this.startRow + s,
2843
+ this.startColumn + t,
2844
+ e
2845
+ ), this;
2846
+ }
2847
+ get(s, t) {
2848
+ return this.matrix.get(
2849
+ this.startRow + s,
2850
+ this.startColumn + t
2851
+ );
2852
+ }
2853
+ }
2854
+ class $s extends ft {
2855
+ constructor(s) {
2856
+ super(s, s.columns, s.rows);
2857
+ }
2858
+ set(s, t, e) {
2859
+ return this.matrix.set(t, s, e), this;
2860
+ }
2861
+ get(s, t) {
2862
+ return this.matrix.get(t, s);
2863
+ }
2864
+ }
2865
+ class Ae extends V {
2866
+ constructor(s, t = {}) {
2867
+ const { rows: e = 1 } = t;
2868
+ if (s.length % e !== 0)
2869
+ throw new Error("the data length is not divisible by the number of rows");
2870
+ super(), this.rows = e, this.columns = s.length / e, this.data = s;
2871
+ }
2872
+ set(s, t, e) {
2873
+ let n = this._calculateIndex(s, t);
2874
+ return this.data[n] = e, this;
2875
+ }
2876
+ get(s, t) {
2877
+ let e = this._calculateIndex(s, t);
2878
+ return this.data[e];
2879
+ }
2880
+ _calculateIndex(s, t) {
2881
+ return s * this.columns + t;
2882
+ }
2883
+ }
2884
+ class rt extends V {
2885
+ constructor(s) {
2886
+ super(), this.data = s, this.rows = s.length, this.columns = s[0].length;
2887
+ }
2888
+ set(s, t, e) {
2889
+ return this.data[s][t] = e, this;
2890
+ }
2891
+ get(s, t) {
2892
+ return this.data[s][t];
2893
+ }
2894
+ }
2895
+ function Ls(r, s) {
2896
+ if (st.isAnyArray(r))
2897
+ return r[0] && st.isAnyArray(r[0]) ? new rt(r) : new Ae(r, s);
2898
+ throw new Error("the argument is not an array");
2899
+ }
2900
+ class ee {
2901
+ constructor(s) {
2902
+ s = rt.checkMatrix(s);
2903
+ let t = s.clone(), e = t.rows, n = t.columns, i = new Float64Array(e), o = 1, l, h, a, u, c, g, d, w, p;
2904
+ for (l = 0; l < e; l++)
2905
+ i[l] = l;
2906
+ for (w = new Float64Array(e), h = 0; h < n; h++) {
2907
+ for (l = 0; l < e; l++)
2908
+ w[l] = t.get(l, h);
2909
+ for (l = 0; l < e; l++) {
2910
+ for (p = Math.min(l, h), c = 0, a = 0; a < p; a++)
2911
+ c += t.get(l, a) * w[a];
2912
+ w[l] -= c, t.set(l, h, w[l]);
2913
+ }
2914
+ for (u = h, l = h + 1; l < e; l++)
2915
+ Math.abs(w[l]) > Math.abs(w[u]) && (u = l);
2916
+ if (u !== h) {
2917
+ for (a = 0; a < n; a++)
2918
+ g = t.get(u, a), t.set(u, a, t.get(h, a)), t.set(h, a, g);
2919
+ d = i[u], i[u] = i[h], i[h] = d, o = -o;
2920
+ }
2921
+ if (h < e && t.get(h, h) !== 0)
2922
+ for (l = h + 1; l < e; l++)
2923
+ t.set(l, h, t.get(l, h) / t.get(h, h));
2924
+ }
2925
+ this.LU = t, this.pivotVector = i, this.pivotSign = o;
2926
+ }
2927
+ isSingular() {
2928
+ let s = this.LU, t = s.columns;
2929
+ for (let e = 0; e < t; e++)
2930
+ if (s.get(e, e) === 0)
2931
+ return !0;
2932
+ return !1;
2933
+ }
2934
+ solve(s) {
2935
+ s = _.checkMatrix(s);
2936
+ let t = this.LU;
2937
+ if (t.rows !== s.rows)
2938
+ throw new Error("Invalid matrix dimensions");
2939
+ if (this.isSingular())
2940
+ throw new Error("LU matrix is singular");
2941
+ let n = s.columns, i = s.subMatrixRow(this.pivotVector, 0, n - 1), o = t.columns, l, h, a;
2942
+ for (a = 0; a < o; a++)
2943
+ for (l = a + 1; l < o; l++)
2944
+ for (h = 0; h < n; h++)
2945
+ i.set(l, h, i.get(l, h) - i.get(a, h) * t.get(l, a));
2946
+ for (a = o - 1; a >= 0; a--) {
2947
+ for (h = 0; h < n; h++)
2948
+ i.set(a, h, i.get(a, h) / t.get(a, a));
2949
+ for (l = 0; l < a; l++)
2950
+ for (h = 0; h < n; h++)
2951
+ i.set(l, h, i.get(l, h) - i.get(a, h) * t.get(l, a));
2952
+ }
2953
+ return i;
2954
+ }
2955
+ get determinant() {
2956
+ let s = this.LU;
2957
+ if (!s.isSquare())
2958
+ throw new Error("Matrix must be square");
2959
+ let t = this.pivotSign, e = s.columns;
2960
+ for (let n = 0; n < e; n++)
2961
+ t *= s.get(n, n);
2962
+ return t;
2963
+ }
2964
+ get lowerTriangularMatrix() {
2965
+ let s = this.LU, t = s.rows, e = s.columns, n = new _(t, e);
2966
+ for (let i = 0; i < t; i++)
2967
+ for (let o = 0; o < e; o++)
2968
+ i > o ? n.set(i, o, s.get(i, o)) : i === o ? n.set(i, o, 1) : n.set(i, o, 0);
2969
+ return n;
2970
+ }
2971
+ get upperTriangularMatrix() {
2972
+ let s = this.LU, t = s.rows, e = s.columns, n = new _(t, e);
2973
+ for (let i = 0; i < t; i++)
2974
+ for (let o = 0; o < e; o++)
2975
+ i <= o ? n.set(i, o, s.get(i, o)) : n.set(i, o, 0);
2976
+ return n;
2977
+ }
2978
+ get pivotPermutationVector() {
2979
+ return Array.from(this.pivotVector);
2980
+ }
2981
+ }
2982
+ function ut(r, s) {
2983
+ let t = 0;
2984
+ 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;
2985
+ }
2986
+ class pe {
2987
+ constructor(s) {
2988
+ s = rt.checkMatrix(s);
2989
+ let t = s.clone(), e = s.rows, n = s.columns, i = new Float64Array(n), o, l, h, a;
2990
+ for (h = 0; h < n; h++) {
2991
+ let u = 0;
2992
+ for (o = h; o < e; o++)
2993
+ u = ut(u, t.get(o, h));
2994
+ if (u !== 0) {
2995
+ for (t.get(h, h) < 0 && (u = -u), o = h; o < e; o++)
2996
+ t.set(o, h, t.get(o, h) / u);
2997
+ for (t.set(h, h, t.get(h, h) + 1), l = h + 1; l < n; l++) {
2998
+ for (a = 0, o = h; o < e; o++)
2999
+ a += t.get(o, h) * t.get(o, l);
3000
+ for (a = -a / t.get(h, h), o = h; o < e; o++)
3001
+ t.set(o, l, t.get(o, l) + a * t.get(o, h));
3002
+ }
3003
+ }
3004
+ i[h] = -u;
3005
+ }
3006
+ this.QR = t, this.Rdiag = i;
3007
+ }
3008
+ solve(s) {
3009
+ s = _.checkMatrix(s);
3010
+ let t = this.QR, e = t.rows;
3011
+ if (s.rows !== e)
3012
+ throw new Error("Matrix row dimensions must agree");
3013
+ if (!this.isFullRank())
3014
+ throw new Error("Matrix is rank deficient");
3015
+ let n = s.columns, i = s.clone(), o = t.columns, l, h, a, u;
3016
+ for (a = 0; a < o; a++)
3017
+ for (h = 0; h < n; h++) {
3018
+ for (u = 0, l = a; l < e; l++)
3019
+ u += t.get(l, a) * i.get(l, h);
3020
+ for (u = -u / t.get(a, a), l = a; l < e; l++)
3021
+ i.set(l, h, i.get(l, h) + u * t.get(l, a));
3022
+ }
3023
+ for (a = o - 1; a >= 0; a--) {
3024
+ for (h = 0; h < n; h++)
3025
+ i.set(a, h, i.get(a, h) / this.Rdiag[a]);
3026
+ for (l = 0; l < a; l++)
3027
+ for (h = 0; h < n; h++)
3028
+ i.set(l, h, i.get(l, h) - i.get(a, h) * t.get(l, a));
3029
+ }
3030
+ return i.subMatrix(0, o - 1, 0, n - 1);
3031
+ }
3032
+ isFullRank() {
3033
+ let s = this.QR.columns;
3034
+ for (let t = 0; t < s; t++)
3035
+ if (this.Rdiag[t] === 0)
3036
+ return !1;
3037
+ return !0;
3038
+ }
3039
+ get upperTriangularMatrix() {
3040
+ let s = this.QR, t = s.columns, e = new _(t, t), n, i;
3041
+ for (n = 0; n < t; n++)
3042
+ for (i = 0; i < t; i++)
3043
+ n < i ? e.set(n, i, s.get(n, i)) : n === i ? e.set(n, i, this.Rdiag[n]) : e.set(n, i, 0);
3044
+ return e;
3045
+ }
3046
+ get orthogonalMatrix() {
3047
+ let s = this.QR, t = s.rows, e = s.columns, n = new _(t, e), i, o, l, h;
3048
+ for (l = e - 1; l >= 0; l--) {
3049
+ for (i = 0; i < t; i++)
3050
+ n.set(i, l, 0);
3051
+ for (n.set(l, l, 1), o = l; o < e; o++)
3052
+ if (s.get(l, l) !== 0) {
3053
+ for (h = 0, i = l; i < t; i++)
3054
+ h += s.get(i, l) * n.get(i, o);
3055
+ for (h = -h / s.get(l, l), i = l; i < t; i++)
3056
+ n.set(i, o, n.get(i, o) + h * s.get(i, l));
3057
+ }
3058
+ }
3059
+ return n;
3060
+ }
3061
+ }
3062
+ class vt {
3063
+ constructor(s, t = {}) {
3064
+ if (s = rt.checkMatrix(s), s.isEmpty())
3065
+ throw new Error("Matrix must be non-empty");
3066
+ let e = s.rows, n = s.columns;
3067
+ const {
3068
+ computeLeftSingularVectors: i = !0,
3069
+ computeRightSingularVectors: o = !0,
3070
+ autoTranspose: l = !1
3071
+ } = t;
3072
+ let h = !!i, a = !!o, u = !1, c;
3073
+ if (e < n)
3074
+ if (!l)
3075
+ c = s.clone(), console.warn(
3076
+ "Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose"
3077
+ );
3078
+ else {
3079
+ c = s.transpose(), e = c.rows, n = c.columns, u = !0;
3080
+ let m = h;
3081
+ h = a, a = m;
3082
+ }
3083
+ else
3084
+ c = s.clone();
3085
+ let g = Math.min(e, n), d = Math.min(e + 1, n), w = new Float64Array(d), p = new _(e, g), P = new _(n, n), f = new Float64Array(n), M = new Float64Array(e), E = new Float64Array(d);
3086
+ for (let m = 0; m < d; m++) E[m] = m;
3087
+ let R = Math.min(e - 1, n), v = Math.max(0, Math.min(n - 2, e)), L = Math.max(R, v);
3088
+ for (let m = 0; m < L; m++) {
3089
+ if (m < R) {
3090
+ w[m] = 0;
3091
+ for (let b = m; b < e; b++)
3092
+ w[m] = ut(w[m], c.get(b, m));
3093
+ if (w[m] !== 0) {
3094
+ c.get(m, m) < 0 && (w[m] = -w[m]);
3095
+ for (let b = m; b < e; b++)
3096
+ c.set(b, m, c.get(b, m) / w[m]);
3097
+ c.set(m, m, c.get(m, m) + 1);
3098
+ }
3099
+ w[m] = -w[m];
3100
+ }
3101
+ for (let b = m + 1; b < n; b++) {
3102
+ if (m < R && w[m] !== 0) {
3103
+ let j = 0;
3104
+ for (let y = m; y < e; y++)
3105
+ j += c.get(y, m) * c.get(y, b);
3106
+ j = -j / c.get(m, m);
3107
+ for (let y = m; y < e; y++)
3108
+ c.set(y, b, c.get(y, b) + j * c.get(y, m));
3109
+ }
3110
+ f[b] = c.get(m, b);
3111
+ }
3112
+ if (h && m < R)
3113
+ for (let b = m; b < e; b++)
3114
+ p.set(b, m, c.get(b, m));
3115
+ if (m < v) {
3116
+ f[m] = 0;
3117
+ for (let b = m + 1; b < n; b++)
3118
+ f[m] = ut(f[m], f[b]);
3119
+ if (f[m] !== 0) {
3120
+ f[m + 1] < 0 && (f[m] = 0 - f[m]);
3121
+ for (let b = m + 1; b < n; b++)
3122
+ f[b] /= f[m];
3123
+ f[m + 1] += 1;
3124
+ }
3125
+ if (f[m] = -f[m], m + 1 < e && f[m] !== 0) {
3126
+ for (let b = m + 1; b < e; b++)
3127
+ M[b] = 0;
3128
+ for (let b = m + 1; b < e; b++)
3129
+ for (let j = m + 1; j < n; j++)
3130
+ M[b] += f[j] * c.get(b, j);
3131
+ for (let b = m + 1; b < n; b++) {
3132
+ let j = -f[b] / f[m + 1];
3133
+ for (let y = m + 1; y < e; y++)
3134
+ c.set(y, b, c.get(y, b) + j * M[y]);
3135
+ }
3136
+ }
3137
+ if (a)
3138
+ for (let b = m + 1; b < n; b++)
3139
+ P.set(b, m, f[b]);
3140
+ }
3141
+ }
3142
+ let S = Math.min(n, e + 1);
3143
+ if (R < n && (w[R] = c.get(R, R)), e < S && (w[S - 1] = 0), v + 1 < S && (f[v] = c.get(v, S - 1)), f[S - 1] = 0, h) {
3144
+ for (let m = R; m < g; m++) {
3145
+ for (let b = 0; b < e; b++)
3146
+ p.set(b, m, 0);
3147
+ p.set(m, m, 1);
3148
+ }
3149
+ for (let m = R - 1; m >= 0; m--)
3150
+ if (w[m] !== 0) {
3151
+ for (let b = m + 1; b < g; b++) {
3152
+ let j = 0;
3153
+ for (let y = m; y < e; y++)
3154
+ j += p.get(y, m) * p.get(y, b);
3155
+ j = -j / p.get(m, m);
3156
+ for (let y = m; y < e; y++)
3157
+ p.set(y, b, p.get(y, b) + j * p.get(y, m));
3158
+ }
3159
+ for (let b = m; b < e; b++)
3160
+ p.set(b, m, -p.get(b, m));
3161
+ p.set(m, m, 1 + p.get(m, m));
3162
+ for (let b = 0; b < m - 1; b++)
3163
+ p.set(b, m, 0);
3164
+ } else {
3165
+ for (let b = 0; b < e; b++)
3166
+ p.set(b, m, 0);
3167
+ p.set(m, m, 1);
3168
+ }
3169
+ }
3170
+ if (a)
3171
+ for (let m = n - 1; m >= 0; m--) {
3172
+ if (m < v && f[m] !== 0)
3173
+ for (let b = m + 1; b < n; b++) {
3174
+ let j = 0;
3175
+ for (let y = m + 1; y < n; y++)
3176
+ j += P.get(y, m) * P.get(y, b);
3177
+ j = -j / P.get(m + 1, m);
3178
+ for (let y = m + 1; y < n; y++)
3179
+ P.set(y, b, P.get(y, b) + j * P.get(y, m));
3180
+ }
3181
+ for (let b = 0; b < n; b++)
3182
+ P.set(b, m, 0);
3183
+ P.set(m, m, 1);
3184
+ }
3185
+ let k = S - 1, D = Number.EPSILON;
3186
+ for (; S > 0; ) {
3187
+ let m, b;
3188
+ for (m = S - 2; m >= -1 && m !== -1; m--) {
3189
+ const j = Number.MIN_VALUE + D * Math.abs(w[m] + Math.abs(w[m + 1]));
3190
+ if (Math.abs(f[m]) <= j || Number.isNaN(f[m])) {
3191
+ f[m] = 0;
3192
+ break;
3193
+ }
3194
+ }
3195
+ if (m === S - 2)
3196
+ b = 4;
3197
+ else {
3198
+ let j;
3199
+ for (j = S - 1; j >= m && j !== m; j--) {
3200
+ let y = (j !== S ? Math.abs(f[j]) : 0) + (j !== m + 1 ? Math.abs(f[j - 1]) : 0);
3201
+ if (Math.abs(w[j]) <= D * y) {
3202
+ w[j] = 0;
3203
+ break;
3204
+ }
3205
+ }
3206
+ j === m ? b = 3 : j === S - 1 ? b = 1 : (b = 2, m = j);
3207
+ }
3208
+ switch (m++, b) {
3209
+ case 1: {
3210
+ let j = f[S - 2];
3211
+ f[S - 2] = 0;
3212
+ for (let y = S - 2; y >= m; y--) {
3213
+ let C = ut(w[y], j), F = w[y] / C, I = j / C;
3214
+ if (w[y] = C, y !== m && (j = -I * f[y - 1], f[y - 1] = F * f[y - 1]), a)
3215
+ for (let B = 0; B < n; B++)
3216
+ 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);
3217
+ }
3218
+ break;
3219
+ }
3220
+ case 2: {
3221
+ let j = f[m - 1];
3222
+ f[m - 1] = 0;
3223
+ for (let y = m; y < S; y++) {
3224
+ let C = ut(w[y], j), F = w[y] / C, I = j / C;
3225
+ if (w[y] = C, j = -I * f[y], f[y] = F * f[y], h)
3226
+ for (let B = 0; B < e; B++)
3227
+ 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);
3228
+ }
3229
+ break;
3230
+ }
3231
+ case 3: {
3232
+ const j = Math.max(
3233
+ Math.abs(w[S - 1]),
3234
+ Math.abs(w[S - 2]),
3235
+ Math.abs(f[S - 2]),
3236
+ Math.abs(w[m]),
3237
+ Math.abs(f[m])
3238
+ ), y = w[S - 1] / j, C = w[S - 2] / j, F = f[S - 2] / j, I = w[m] / j, B = f[m] / j, x = ((C + y) * (C - y) + F * F) / 2, N = y * F * (y * F);
3239
+ let A = 0;
3240
+ (x !== 0 || N !== 0) && (x < 0 ? A = 0 - Math.sqrt(x * x + N) : A = Math.sqrt(x * x + N), A = N / (x + A));
3241
+ let O = (I + y) * (I - y) + A, U = I * B;
3242
+ for (let T = m; T < S - 1; T++) {
3243
+ let z = ut(O, U);
3244
+ z === 0 && (z = Number.MIN_VALUE);
3245
+ let X = O / z, G = U / z;
3246
+ 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)
3247
+ for (let W = 0; W < n; W++)
3248
+ 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);
3249
+ 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)
3250
+ for (let W = 0; W < e; W++)
3251
+ 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);
3252
+ }
3253
+ f[S - 2] = O;
3254
+ break;
3255
+ }
3256
+ case 4: {
3257
+ if (w[m] <= 0 && (w[m] = w[m] < 0 ? -w[m] : 0, a))
3258
+ for (let j = 0; j <= k; j++)
3259
+ P.set(j, m, -P.get(j, m));
3260
+ for (; m < k && !(w[m] >= w[m + 1]); ) {
3261
+ let j = w[m];
3262
+ if (w[m] = w[m + 1], w[m + 1] = j, a && m < n - 1)
3263
+ for (let y = 0; y < n; y++)
3264
+ j = P.get(y, m + 1), P.set(y, m + 1, P.get(y, m)), P.set(y, m, j);
3265
+ if (h && m < e - 1)
3266
+ for (let y = 0; y < e; y++)
3267
+ j = p.get(y, m + 1), p.set(y, m + 1, p.get(y, m)), p.set(y, m, j);
3268
+ m++;
3269
+ }
3270
+ S--;
3271
+ break;
3272
+ }
3273
+ }
3274
+ }
3275
+ if (u) {
3276
+ let m = P;
3277
+ P = p, p = m;
3278
+ }
3279
+ this.m = e, this.n = n, this.s = w, this.U = p, this.V = P;
3280
+ }
3281
+ solve(s) {
3282
+ let t = s, e = this.threshold, n = this.s.length, i = _.zeros(n, n);
3283
+ for (let g = 0; g < n; g++)
3284
+ Math.abs(this.s[g]) <= e ? i.set(g, g, 0) : i.set(g, g, 1 / this.s[g]);
3285
+ let o = this.U, l = this.rightSingularVectors, h = l.mmul(i), a = l.rows, u = o.rows, c = _.zeros(a, u);
3286
+ for (let g = 0; g < a; g++)
3287
+ for (let d = 0; d < u; d++) {
3288
+ let w = 0;
3289
+ for (let p = 0; p < n; p++)
3290
+ w += h.get(g, p) * o.get(d, p);
3291
+ c.set(g, d, w);
3292
+ }
3293
+ return c.mmul(t);
3294
+ }
3295
+ solveForDiagonal(s) {
3296
+ return this.solve(_.diag(s));
3297
+ }
3298
+ inverse() {
3299
+ let s = this.V, t = this.threshold, e = s.rows, n = s.columns, i = new _(e, this.s.length);
3300
+ for (let u = 0; u < e; u++)
3301
+ for (let c = 0; c < n; c++)
3302
+ Math.abs(this.s[c]) > t && i.set(u, c, s.get(u, c) / this.s[c]);
3303
+ let o = this.U, l = o.rows, h = o.columns, a = new _(e, l);
3304
+ for (let u = 0; u < e; u++)
3305
+ for (let c = 0; c < l; c++) {
3306
+ let g = 0;
3307
+ for (let d = 0; d < h; d++)
3308
+ g += i.get(u, d) * o.get(c, d);
3309
+ a.set(u, c, g);
3310
+ }
3311
+ return a;
3312
+ }
3313
+ get condition() {
3314
+ return this.s[0] / this.s[Math.min(this.m, this.n) - 1];
3315
+ }
3316
+ get norm2() {
3317
+ return this.s[0];
3318
+ }
3319
+ get rank() {
3320
+ let s = Math.max(this.m, this.n) * this.s[0] * Number.EPSILON, t = 0, e = this.s;
3321
+ for (let n = 0, i = e.length; n < i; n++)
3322
+ e[n] > s && t++;
3323
+ return t;
3324
+ }
3325
+ get diagonal() {
3326
+ return Array.from(this.s);
3327
+ }
3328
+ get threshold() {
3329
+ return Number.EPSILON / 2 * Math.max(this.m, this.n) * this.s[0];
3330
+ }
3331
+ get leftSingularVectors() {
3332
+ return this.U;
3333
+ }
3334
+ get rightSingularVectors() {
3335
+ return this.V;
3336
+ }
3337
+ get diagonalMatrix() {
3338
+ return _.diag(this.s);
3339
+ }
3340
+ }
3341
+ function Ds(r, s = !1) {
3342
+ return r = rt.checkMatrix(r), s ? new vt(r).inverse() : Ve(r, _.eye(r.rows));
3343
+ }
3344
+ function Ve(r, s, t = !1) {
3345
+ return r = rt.checkMatrix(r), s = rt.checkMatrix(s), t ? new vt(r).solve(s) : r.isSquare() ? new ee(r).solve(s) : new pe(r).solve(s);
3346
+ }
3347
+ function Xt(r) {
3348
+ if (r = _.checkMatrix(r), r.isSquare()) {
3349
+ if (r.columns === 0)
3350
+ return 1;
3351
+ let s, t, e, n;
3352
+ if (r.columns === 2)
3353
+ return s = r.get(0, 0), t = r.get(0, 1), e = r.get(1, 0), n = r.get(1, 1), s * n - t * e;
3354
+ if (r.columns === 3) {
3355
+ let i, o, l;
3356
+ return i = new Gt(r, [1, 2], [1, 2]), o = new Gt(r, [1, 2], [0, 2]), l = new Gt(r, [1, 2], [0, 1]), s = r.get(0, 0), t = r.get(0, 1), e = r.get(0, 2), s * Xt(i) - t * Xt(o) + e * Xt(l);
3357
+ } else
3358
+ return new ee(r).determinant;
3359
+ } else
3360
+ throw Error("determinant can only be calculated for a square matrix");
3361
+ }
3362
+ function zs(r, s) {
3363
+ let t = [];
3364
+ for (let e = 0; e < r; e++)
3365
+ e !== s && t.push(e);
3366
+ return t;
3367
+ }
3368
+ function Os(r, s, t, e = 1e-9, n = 1e-9) {
3369
+ if (r > n)
3370
+ return new Array(s.rows + 1).fill(0);
3371
+ {
3372
+ let i = s.addRow(t, [0]);
3373
+ for (let o = 0; o < i.rows; o++)
3374
+ Math.abs(i.get(o, 0)) < e && i.set(o, 0, 0);
3375
+ return i.to1DArray();
3376
+ }
3377
+ }
3378
+ function Bs(r, s = {}) {
3379
+ const { thresholdValue: t = 1e-9, thresholdError: e = 1e-9 } = s;
3380
+ r = _.checkMatrix(r);
3381
+ let n = r.rows, i = new _(n, n);
3382
+ for (let o = 0; o < n; o++) {
3383
+ let l = _.columnVector(r.getRow(o)), h = r.subMatrixRow(zs(n, o)).transpose(), u = new vt(h).solve(l), c = _.sub(l, h.mmul(u)).abs().max();
3384
+ i.setRow(
3385
+ o,
3386
+ Os(c, u, o, t, e)
3387
+ );
3388
+ }
3389
+ return i;
3390
+ }
3391
+ function Us(r, s = Number.EPSILON) {
3392
+ if (r = _.checkMatrix(r), r.isEmpty())
3393
+ return r.transpose();
3394
+ let t = new vt(r, { autoTranspose: !0 }), e = t.leftSingularVectors, n = t.rightSingularVectors, i = t.diagonal;
3395
+ for (let o = 0; o < i.length; o++)
3396
+ Math.abs(i[o]) > s ? i[o] = 1 / i[o] : i[o] = 0;
3397
+ return n.mmul(_.diag(i).mmul(e.transpose()));
3398
+ }
3399
+ function Ys(r, s = r, t = {}) {
3400
+ r = new _(r);
3401
+ let e = !1;
3402
+ if (typeof s == "object" && !_.isMatrix(s) && !st.isAnyArray(s) ? (t = s, s = r, e = !0) : s = new _(s), r.rows !== s.rows)
3403
+ throw new TypeError("Both matrices must have the same number of rows");
3404
+ const { center: n = !0 } = t;
3405
+ n && (r = r.center("column"), e || (s = s.center("column")));
3406
+ const i = r.transpose().mmul(s);
3407
+ for (let o = 0; o < i.rows; o++)
3408
+ for (let l = 0; l < i.columns; l++)
3409
+ i.set(o, l, i.get(o, l) * (1 / (r.rows - 1)));
3410
+ return i;
3411
+ }
3412
+ function Ws(r, s = r, t = {}) {
3413
+ r = new _(r);
3414
+ let e = !1;
3415
+ if (typeof s == "object" && !_.isMatrix(s) && !st.isAnyArray(s) ? (t = s, s = r, e = !0) : s = new _(s), r.rows !== s.rows)
3416
+ throw new TypeError("Both matrices must have the same number of rows");
3417
+ const { center: n = !0, scale: i = !0 } = t;
3418
+ n && (r.center("column"), e || s.center("column")), i && (r.scale("column"), e || s.scale("column"));
3419
+ const o = r.standardDeviation("column", { unbiased: !0 }), l = e ? o : s.standardDeviation("column", { unbiased: !0 }), h = r.transpose().mmul(s);
3420
+ for (let a = 0; a < h.rows; a++)
3421
+ for (let u = 0; u < h.columns; u++)
3422
+ h.set(
3423
+ a,
3424
+ u,
3425
+ h.get(a, u) * (1 / (o[a] * l[u])) * (1 / (r.rows - 1))
3426
+ );
3427
+ return h;
3428
+ }
3429
+ let Ne = class {
3430
+ constructor(s, t = {}) {
3431
+ const { assumeSymmetric: e = !1 } = t;
3432
+ if (s = rt.checkMatrix(s), !s.isSquare())
3433
+ throw new Error("Matrix is not a square matrix");
3434
+ if (s.isEmpty())
3435
+ throw new Error("Matrix must be non-empty");
3436
+ let n = s.columns, i = new _(n, n), o = new Float64Array(n), l = new Float64Array(n), h = s, a, u, c = !1;
3437
+ if (e ? c = !0 : c = s.isSymmetric(), c) {
3438
+ for (a = 0; a < n; a++)
3439
+ for (u = 0; u < n; u++)
3440
+ i.set(a, u, h.get(a, u));
3441
+ Qs(n, l, o, i), Gs(n, l, o, i);
3442
+ } else {
3443
+ let g = new _(n, n), d = new Float64Array(n);
3444
+ for (u = 0; u < n; u++)
3445
+ for (a = 0; a < n; a++)
3446
+ g.set(a, u, h.get(a, u));
3447
+ Xs(n, g, d, i), Zs(n, l, o, i, g);
3448
+ }
3449
+ this.n = n, this.e = l, this.d = o, this.V = i;
3450
+ }
3451
+ get realEigenvalues() {
3452
+ return Array.from(this.d);
3453
+ }
3454
+ get imaginaryEigenvalues() {
3455
+ return Array.from(this.e);
3456
+ }
3457
+ get eigenvectorMatrix() {
3458
+ return this.V;
3459
+ }
3460
+ get diagonalMatrix() {
3461
+ let s = this.n, t = this.e, e = this.d, n = new _(s, s), i, o;
3462
+ for (i = 0; i < s; i++) {
3463
+ for (o = 0; o < s; o++)
3464
+ n.set(i, o, 0);
3465
+ n.set(i, i, e[i]), t[i] > 0 ? n.set(i, i + 1, t[i]) : t[i] < 0 && n.set(i, i - 1, t[i]);
3466
+ }
3467
+ return n;
3468
+ }
3469
+ };
3470
+ function Qs(r, s, t, e) {
3471
+ let n, i, o, l, h, a, u, c;
3472
+ for (h = 0; h < r; h++)
3473
+ t[h] = e.get(r - 1, h);
3474
+ for (l = r - 1; l > 0; l--) {
3475
+ for (c = 0, o = 0, a = 0; a < l; a++)
3476
+ c = c + Math.abs(t[a]);
3477
+ if (c === 0)
3478
+ for (s[l] = t[l - 1], h = 0; h < l; h++)
3479
+ t[h] = e.get(l - 1, h), e.set(l, h, 0), e.set(h, l, 0);
3480
+ else {
3481
+ for (a = 0; a < l; a++)
3482
+ t[a] /= c, o += t[a] * t[a];
3483
+ for (n = t[l - 1], i = Math.sqrt(o), n > 0 && (i = -i), s[l] = c * i, o = o - n * i, t[l - 1] = n - i, h = 0; h < l; h++)
3484
+ s[h] = 0;
3485
+ for (h = 0; h < l; h++) {
3486
+ for (n = t[h], e.set(h, l, n), i = s[h] + e.get(h, h) * n, a = h + 1; a <= l - 1; a++)
3487
+ i += e.get(a, h) * t[a], s[a] += e.get(a, h) * n;
3488
+ s[h] = i;
3489
+ }
3490
+ for (n = 0, h = 0; h < l; h++)
3491
+ s[h] /= o, n += s[h] * t[h];
3492
+ for (u = n / (o + o), h = 0; h < l; h++)
3493
+ s[h] -= u * t[h];
3494
+ for (h = 0; h < l; h++) {
3495
+ for (n = t[h], i = s[h], a = h; a <= l - 1; a++)
3496
+ e.set(a, h, e.get(a, h) - (n * s[a] + i * t[a]));
3497
+ t[h] = e.get(l - 1, h), e.set(l, h, 0);
3498
+ }
3499
+ }
3500
+ t[l] = o;
3501
+ }
3502
+ for (l = 0; l < r - 1; l++) {
3503
+ if (e.set(r - 1, l, e.get(l, l)), e.set(l, l, 1), o = t[l + 1], o !== 0) {
3504
+ for (a = 0; a <= l; a++)
3505
+ t[a] = e.get(a, l + 1) / o;
3506
+ for (h = 0; h <= l; h++) {
3507
+ for (i = 0, a = 0; a <= l; a++)
3508
+ i += e.get(a, l + 1) * e.get(a, h);
3509
+ for (a = 0; a <= l; a++)
3510
+ e.set(a, h, e.get(a, h) - i * t[a]);
3511
+ }
3512
+ }
3513
+ for (a = 0; a <= l; a++)
3514
+ e.set(a, l + 1, 0);
3515
+ }
3516
+ for (h = 0; h < r; h++)
3517
+ t[h] = e.get(r - 1, h), e.set(r - 1, h, 0);
3518
+ e.set(r - 1, r - 1, 1), s[0] = 0;
3519
+ }
3520
+ function Gs(r, s, t, e) {
3521
+ let n, i, o, l, h, a, u, c, g, d, w, p, P, f, M, E;
3522
+ for (o = 1; o < r; o++)
3523
+ s[o - 1] = s[o];
3524
+ s[r - 1] = 0;
3525
+ let R = 0, v = 0, L = Number.EPSILON;
3526
+ for (a = 0; a < r; a++) {
3527
+ for (v = Math.max(v, Math.abs(t[a]) + Math.abs(s[a])), u = a; u < r && !(Math.abs(s[u]) <= L * v); )
3528
+ u++;
3529
+ if (u > a)
3530
+ do {
3531
+ 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++)
3532
+ t[o] -= i;
3533
+ 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--)
3534
+ 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++)
3535
+ 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);
3536
+ c = -M * E * P * f * s[a] / d, s[a] = M * c, t[a] = w * c;
3537
+ } while (Math.abs(s[a]) > L * v);
3538
+ t[a] = t[a] + R, s[a] = 0;
3539
+ }
3540
+ for (o = 0; o < r - 1; o++) {
3541
+ for (h = o, c = t[o], l = o + 1; l < r; l++)
3542
+ t[l] < c && (h = l, c = t[l]);
3543
+ if (h !== o)
3544
+ for (t[h] = t[o], t[o] = c, l = 0; l < r; l++)
3545
+ c = e.get(l, o), e.set(l, o, e.get(l, h)), e.set(l, h, c);
3546
+ }
3547
+ }
3548
+ function Xs(r, s, t, e) {
3549
+ let n = 0, i = r - 1, o, l, h, a, u, c, g;
3550
+ for (c = n + 1; c <= i - 1; c++) {
3551
+ for (g = 0, a = c; a <= i; a++)
3552
+ g = g + Math.abs(s.get(a, c - 1));
3553
+ if (g !== 0) {
3554
+ for (h = 0, a = i; a >= c; a--)
3555
+ t[a] = s.get(a, c - 1) / g, h += t[a] * t[a];
3556
+ for (l = Math.sqrt(h), t[c] > 0 && (l = -l), h = h - t[c] * l, t[c] = t[c] - l, u = c; u < r; u++) {
3557
+ for (o = 0, a = i; a >= c; a--)
3558
+ o += t[a] * s.get(a, u);
3559
+ for (o = o / h, a = c; a <= i; a++)
3560
+ s.set(a, u, s.get(a, u) - o * t[a]);
3561
+ }
3562
+ for (a = 0; a <= i; a++) {
3563
+ for (o = 0, u = i; u >= c; u--)
3564
+ o += t[u] * s.get(a, u);
3565
+ for (o = o / h, u = c; u <= i; u++)
3566
+ s.set(a, u, s.get(a, u) - o * t[u]);
3567
+ }
3568
+ t[c] = g * t[c], s.set(c, c - 1, g * l);
3569
+ }
3570
+ }
3571
+ for (a = 0; a < r; a++)
3572
+ for (u = 0; u < r; u++)
3573
+ e.set(a, u, a === u ? 1 : 0);
3574
+ for (c = i - 1; c >= n + 1; c--)
3575
+ if (s.get(c, c - 1) !== 0) {
3576
+ for (a = c + 1; a <= i; a++)
3577
+ t[a] = s.get(a, c - 1);
3578
+ for (u = c; u <= i; u++) {
3579
+ for (l = 0, a = c; a <= i; a++)
3580
+ l += t[a] * e.get(a, u);
3581
+ for (l = l / t[c] / s.get(c, c - 1), a = c; a <= i; a++)
3582
+ e.set(a, u, e.get(a, u) + l * t[a]);
3583
+ }
3584
+ }
3585
+ }
3586
+ function Zs(r, s, t, e, n) {
3587
+ let i = r - 1, o = 0, l = r - 1, h = Number.EPSILON, a = 0, u = 0, c = 0, g = 0, d = 0, w = 0, p = 0, P = 0, f, M, E, R, v, L, S, k, D, m, b, j, y, C, F;
3588
+ for (f = 0; f < r; f++)
3589
+ for ((f < o || f > l) && (t[f] = n.get(f, f), s[f] = 0), M = Math.max(f - 1, 0); M < r; M++)
3590
+ u = u + Math.abs(n.get(f, M));
3591
+ for (; i >= o; ) {
3592
+ for (R = i; R > o && (w = Math.abs(n.get(R - 1, R - 1)) + Math.abs(n.get(R, R)), w === 0 && (w = u), !(Math.abs(n.get(R, R - 1)) < h * w)); )
3593
+ R--;
3594
+ if (R === i)
3595
+ n.set(i, i, n.get(i, i) + a), t[i] = n.get(i, i), s[i] = 0, i--, P = 0;
3596
+ else if (R === i - 1) {
3597
+ if (S = n.get(i, i - 1) * n.get(i - 1, i), c = (n.get(i - 1, i - 1) - n.get(i, i)) / 2, g = c * c + S, p = Math.sqrt(Math.abs(g)), n.set(i, i, n.get(i, i) + a), n.set(i - 1, i - 1, n.get(i - 1, i - 1) + a), k = n.get(i, i), g >= 0) {
3598
+ for (p = c >= 0 ? c + p : c - p, t[i - 1] = k + p, t[i] = t[i - 1], p !== 0 && (t[i] = k - S / p), s[i - 1] = 0, s[i] = 0, k = n.get(i, i - 1), w = Math.abs(k) + Math.abs(p), c = k / w, g = p / w, d = Math.sqrt(c * c + g * g), c = c / d, g = g / d, M = i - 1; M < r; M++)
3599
+ p = n.get(i - 1, M), n.set(i - 1, M, g * p + c * n.get(i, M)), n.set(i, M, g * n.get(i, M) - c * p);
3600
+ for (f = 0; f <= i; f++)
3601
+ p = n.get(f, i - 1), n.set(f, i - 1, g * p + c * n.get(f, i)), n.set(f, i, g * n.get(f, i) - c * p);
3602
+ for (f = o; f <= l; f++)
3603
+ p = e.get(f, i - 1), e.set(f, i - 1, g * p + c * e.get(f, i)), e.set(f, i, g * e.get(f, i) - c * p);
3604
+ } else
3605
+ t[i - 1] = k + c, t[i] = k + c, s[i - 1] = p, s[i] = -p;
3606
+ i = i - 2, P = 0;
3607
+ } else {
3608
+ if (k = n.get(i, i), D = 0, S = 0, R < i && (D = n.get(i - 1, i - 1), S = n.get(i, i - 1) * n.get(i - 1, i)), P === 10) {
3609
+ for (a += k, f = o; f <= i; f++)
3610
+ n.set(f, f, n.get(f, f) - k);
3611
+ w = Math.abs(n.get(i, i - 1)) + Math.abs(n.get(i - 1, i - 2)), k = D = 0.75 * w, S = -0.4375 * w * w;
3612
+ }
3613
+ if (P === 30 && (w = (D - k) / 2, w = w * w + S, w > 0)) {
3614
+ for (w = Math.sqrt(w), D < k && (w = -w), w = k - S / ((D - k) / 2 + w), f = o; f <= i; f++)
3615
+ n.set(f, f, n.get(f, f) - w);
3616
+ a += w, k = D = S = 0.964;
3617
+ }
3618
+ for (P = P + 1, v = i - 2; v >= R && (p = n.get(v, v), d = k - p, w = D - p, c = (d * w - S) / n.get(v + 1, v) + n.get(v, v + 1), g = n.get(v + 1, v + 1) - p - d - w, d = n.get(v + 2, v + 1), w = Math.abs(c) + Math.abs(g) + Math.abs(d), c = c / w, g = g / w, d = d / w, !(v === R || Math.abs(n.get(v, v - 1)) * (Math.abs(g) + Math.abs(d)) < h * (Math.abs(c) * (Math.abs(n.get(v - 1, v - 1)) + Math.abs(p) + Math.abs(n.get(v + 1, v + 1)))))); )
3619
+ v--;
3620
+ for (f = v + 2; f <= i; f++)
3621
+ n.set(f, f - 2, 0), f > v + 2 && n.set(f, f - 3, 0);
3622
+ for (E = v; E <= i - 1 && (C = E !== i - 1, E !== v && (c = n.get(E, E - 1), g = n.get(E + 1, E - 1), d = C ? n.get(E + 2, E - 1) : 0, k = Math.abs(c) + Math.abs(g) + Math.abs(d), k !== 0 && (c = c / k, g = g / k, d = d / k)), k !== 0); E++)
3623
+ if (w = Math.sqrt(c * c + g * g + d * d), c < 0 && (w = -w), w !== 0) {
3624
+ for (E !== v ? n.set(E, E - 1, -w * k) : R !== v && n.set(E, E - 1, -n.get(E, E - 1)), c = c + w, k = c / w, D = g / w, p = d / w, g = g / c, d = d / c, M = E; M < r; M++)
3625
+ c = n.get(E, M) + g * n.get(E + 1, M), C && (c = c + d * n.get(E + 2, M), n.set(E + 2, M, n.get(E + 2, M) - c * p)), n.set(E, M, n.get(E, M) - c * k), n.set(E + 1, M, n.get(E + 1, M) - c * D);
3626
+ for (f = 0; f <= Math.min(i, E + 3); f++)
3627
+ c = k * n.get(f, E) + D * n.get(f, E + 1), C && (c = c + p * n.get(f, E + 2), n.set(f, E + 2, n.get(f, E + 2) - c * d)), n.set(f, E, n.get(f, E) - c), n.set(f, E + 1, n.get(f, E + 1) - c * g);
3628
+ for (f = o; f <= l; f++)
3629
+ c = k * e.get(f, E) + D * e.get(f, E + 1), C && (c = c + p * e.get(f, E + 2), e.set(f, E + 2, e.get(f, E + 2) - c * d)), e.set(f, E, e.get(f, E) - c), e.set(f, E + 1, e.get(f, E + 1) - c * g);
3630
+ }
3631
+ }
3632
+ }
3633
+ if (u !== 0) {
3634
+ for (i = r - 1; i >= 0; i--)
3635
+ if (c = t[i], g = s[i], g === 0)
3636
+ for (R = i, n.set(i, i, 1), f = i - 1; f >= 0; f--) {
3637
+ for (S = n.get(f, f) - c, d = 0, M = R; M <= i; M++)
3638
+ d = d + n.get(f, M) * n.get(M, i);
3639
+ if (s[f] < 0)
3640
+ p = S, w = d;
3641
+ else if (R = f, s[f] === 0 ? n.set(f, i, S !== 0 ? -d / S : -d / (h * u)) : (k = n.get(f, f + 1), D = n.get(f + 1, f), g = (t[f] - c) * (t[f] - c) + s[f] * s[f], L = (k * w - p * d) / g, n.set(f, i, L), n.set(
3642
+ f + 1,
3643
+ i,
3644
+ Math.abs(k) > Math.abs(p) ? (-d - S * L) / k : (-w - D * L) / p
3645
+ )), L = Math.abs(n.get(f, i)), h * L * L > 1)
3646
+ for (M = f; M <= i; M++)
3647
+ n.set(M, i, n.get(M, i) / L);
3648
+ }
3649
+ else if (g < 0)
3650
+ for (R = i - 1, Math.abs(n.get(i, i - 1)) > Math.abs(n.get(i - 1, i)) ? (n.set(i - 1, i - 1, g / n.get(i, i - 1)), n.set(i - 1, i, -(n.get(i, i) - c) / n.get(i, i - 1))) : (F = Wt(0, -n.get(i - 1, i), n.get(i - 1, i - 1) - c, g), n.set(i - 1, i - 1, F[0]), n.set(i - 1, i, F[1])), n.set(i, i - 1, 0), n.set(i, i, 1), f = i - 2; f >= 0; f--) {
3651
+ for (m = 0, b = 0, M = R; M <= i; M++)
3652
+ m = m + n.get(f, M) * n.get(M, i - 1), b = b + n.get(f, M) * n.get(M, i);
3653
+ if (S = n.get(f, f) - c, s[f] < 0)
3654
+ p = S, d = m, w = b;
3655
+ else if (R = f, s[f] === 0 ? (F = Wt(-m, -b, S, g), n.set(f, i - 1, F[0]), n.set(f, i, F[1])) : (k = n.get(f, f + 1), D = n.get(f + 1, f), j = (t[f] - c) * (t[f] - c) + s[f] * s[f] - g * g, y = (t[f] - c) * 2 * g, j === 0 && y === 0 && (j = h * u * (Math.abs(S) + Math.abs(g) + Math.abs(k) + Math.abs(D) + Math.abs(p))), F = Wt(
3656
+ k * d - p * m + g * b,
3657
+ k * w - p * b - g * m,
3658
+ j,
3659
+ y
3660
+ ), n.set(f, i - 1, F[0]), n.set(f, i, F[1]), Math.abs(k) > Math.abs(p) + Math.abs(g) ? (n.set(
3661
+ f + 1,
3662
+ i - 1,
3663
+ (-m - S * n.get(f, i - 1) + g * n.get(f, i)) / k
3664
+ ), n.set(
3665
+ f + 1,
3666
+ i,
3667
+ (-b - S * n.get(f, i) - g * n.get(f, i - 1)) / k
3668
+ )) : (F = Wt(
3669
+ -d - D * n.get(f, i - 1),
3670
+ -w - D * n.get(f, i),
3671
+ p,
3672
+ g
3673
+ ), n.set(f + 1, i - 1, F[0]), n.set(f + 1, i, F[1]))), L = Math.max(Math.abs(n.get(f, i - 1)), Math.abs(n.get(f, i))), h * L * L > 1)
3674
+ for (M = f; M <= i; M++)
3675
+ n.set(M, i - 1, n.get(M, i - 1) / L), n.set(M, i, n.get(M, i) / L);
3676
+ }
3677
+ for (f = 0; f < r; f++)
3678
+ if (f < o || f > l)
3679
+ for (M = f; M < r; M++)
3680
+ e.set(f, M, n.get(f, M));
3681
+ for (M = r - 1; M >= o; M--)
3682
+ for (f = o; f <= l; f++) {
3683
+ for (p = 0, E = o; E <= Math.min(M, l); E++)
3684
+ p = p + e.get(f, E) * n.get(E, M);
3685
+ e.set(f, M, p);
3686
+ }
3687
+ }
3688
+ }
3689
+ function Wt(r, s, t, e) {
3690
+ let n, i;
3691
+ return Math.abs(t) > Math.abs(e) ? (n = e / t, i = t + n * e, [(r + n * s) / i, (s - n * r) / i]) : (n = t / e, i = e + n * t, [(n * r + s) / i, (n * s - r) / i]);
3692
+ }
3693
+ class $e {
3694
+ constructor(s) {
3695
+ if (s = rt.checkMatrix(s), !s.isSymmetric())
3696
+ throw new Error("Matrix is not symmetric");
3697
+ let t = s, e = t.rows, n = new _(e, e), i = !0, o, l, h;
3698
+ for (l = 0; l < e; l++) {
3699
+ let a = 0;
3700
+ for (h = 0; h < l; h++) {
3701
+ let u = 0;
3702
+ for (o = 0; o < h; o++)
3703
+ u += n.get(h, o) * n.get(l, o);
3704
+ u = (t.get(l, h) - u) / n.get(h, h), n.set(l, h, u), a = a + u * u;
3705
+ }
3706
+ for (a = t.get(l, l) - a, i && (i = a > 0), n.set(l, l, Math.sqrt(Math.max(a, 0))), h = l + 1; h < e; h++)
3707
+ n.set(l, h, 0);
3708
+ }
3709
+ this.L = n, this.positiveDefinite = i;
3710
+ }
3711
+ isPositiveDefinite() {
3712
+ return this.positiveDefinite;
3713
+ }
3714
+ solve(s) {
3715
+ s = rt.checkMatrix(s);
3716
+ let t = this.L, e = t.rows;
3717
+ if (s.rows !== e)
3718
+ throw new Error("Matrix dimensions do not match");
3719
+ if (this.isPositiveDefinite() === !1)
3720
+ throw new Error("Matrix is not positive definite");
3721
+ let n = s.columns, i = s.clone(), o, l, h;
3722
+ for (h = 0; h < e; h++)
3723
+ for (l = 0; l < n; l++) {
3724
+ for (o = 0; o < h; o++)
3725
+ i.set(h, l, i.get(h, l) - i.get(o, l) * t.get(h, o));
3726
+ i.set(h, l, i.get(h, l) / t.get(h, h));
3727
+ }
3728
+ for (h = e - 1; h >= 0; h--)
3729
+ for (l = 0; l < n; l++) {
3730
+ for (o = h + 1; o < e; o++)
3731
+ i.set(h, l, i.get(h, l) - i.get(o, l) * t.get(o, h));
3732
+ i.set(h, l, i.get(h, l) / t.get(h, h));
3733
+ }
3734
+ return i;
3735
+ }
3736
+ get lowerTriangularMatrix() {
3737
+ return this.L;
3738
+ }
3739
+ }
3740
+ class Le {
3741
+ constructor(s, t = {}) {
3742
+ s = rt.checkMatrix(s);
3743
+ let { Y: e } = t;
3744
+ const {
3745
+ scaleScores: n = !1,
3746
+ maxIterations: i = 1e3,
3747
+ terminationCriteria: o = 1e-10
3748
+ } = t;
3749
+ let l;
3750
+ if (e) {
3751
+ if (st.isAnyArray(e) && typeof e[0] == "number" ? e = _.columnVector(e) : e = rt.checkMatrix(e), e.rows !== s.rows)
3752
+ throw new Error("Y should have the same number of rows as X");
3753
+ l = e.getColumnVector(0);
3754
+ } else
3755
+ l = s.getColumnVector(0);
3756
+ let h = 1, a, u, c, g;
3757
+ for (let d = 0; d < i && h > o; d++)
3758
+ c = s.transpose().mmul(l).div(l.transpose().mmul(l).get(0, 0)), c = c.div(c.norm()), a = s.mmul(c).div(c.transpose().mmul(c).get(0, 0)), d > 0 && (h = a.clone().sub(g).pow(2).sum()), g = a.clone(), e ? (u = e.transpose().mmul(a).div(a.transpose().mmul(a).get(0, 0)), u = u.div(u.norm()), l = e.mmul(u).div(u.transpose().mmul(u).get(0, 0))) : l = a;
3759
+ if (e) {
3760
+ let d = s.transpose().mmul(a).div(a.transpose().mmul(a).get(0, 0));
3761
+ d = d.div(d.norm());
3762
+ let w = s.clone().sub(a.clone().mmul(d.transpose())), p = l.transpose().mmul(a).div(a.transpose().mmul(a).get(0, 0)), P = e.clone().sub(
3763
+ a.clone().mulS(p.get(0, 0)).mmul(u.transpose())
3764
+ );
3765
+ this.t = a, this.p = d.transpose(), this.w = c.transpose(), this.q = u, this.u = l, this.s = a.transpose().mmul(a), this.xResidual = w, this.yResidual = P, this.betas = p;
3766
+ } else
3767
+ this.w = c.transpose(), this.s = a.transpose().mmul(a).sqrt(), n ? this.t = a.clone().div(this.s.get(0, 0)) : this.t = a, this.xResidual = s.sub(a.mmul(c.transpose()));
3768
+ }
3769
+ }
3770
+ $.AbstractMatrix = V;
3771
+ $.CHO = $e;
3772
+ $.CholeskyDecomposition = $e;
3773
+ $.DistanceMatrix = te;
3774
+ $.EVD = Ne;
3775
+ var Js = $.EigenvalueDecomposition = Ne;
3776
+ $.LU = ee;
3777
+ $.LuDecomposition = ee;
3778
+ var De = $.Matrix = _;
3779
+ $.MatrixColumnSelectionView = qs;
3780
+ $.MatrixColumnView = Cs;
3781
+ $.MatrixFlipColumnView = Fs;
3782
+ $.MatrixFlipRowView = xs;
3783
+ $.MatrixRowSelectionView = Vs;
3784
+ $.MatrixRowView = As;
3785
+ $.MatrixSelectionView = Gt;
3786
+ $.MatrixSubView = Ns;
3787
+ $.MatrixTransposeView = $s;
3788
+ $.NIPALS = Le;
3789
+ $.Nipals = Le;
3790
+ $.QR = pe;
3791
+ $.QrDecomposition = pe;
3792
+ $.SVD = vt;
3793
+ $.SingularValueDecomposition = vt;
3794
+ $.SymmetricMatrix = pt;
3795
+ $.WrapperMatrix1D = Ae;
3796
+ $.WrapperMatrix2D = rt;
3797
+ $.correlation = Ws;
3798
+ $.covariance = Ys;
3799
+ var Re = $.default = _;
3800
+ $.determinant = Xt;
3801
+ $.inverse = Ds;
3802
+ $.linearDependencies = Bs;
3803
+ $.pseudoInverse = Us;
3804
+ $.solve = Ve;
3805
+ $.wrap = Ls;
3806
+ const Ks = Js, Hs = De;
3807
+ Re.Matrix && Re.Matrix;
3808
+ function qt(r, s, t) {
3809
+ const e = r / t, n = s / t;
3810
+ if (!(isFinite(e) && isFinite(n))) {
3811
+ const h = -r / s;
3812
+ return isFinite(h) ? [h] : r == 0 && s == 0 ? [0] : [];
3813
+ }
3814
+ const i = n * n - 4 * e;
3815
+ let o = 0;
3816
+ if (isFinite(i)) {
3817
+ if (i < 0)
3818
+ return [];
3819
+ if (i == 0)
3820
+ return [-0.5 * n];
3821
+ o = -0.5 * (n + kt(Math.sqrt(i), n));
3822
+ } else
3823
+ o = -n;
3824
+ const l = e / o;
3825
+ return isFinite(l) ? l > o ? [o, l] : [l, o] : [o];
3826
+ }
3827
+ function ze(r, s, t, e) {
3828
+ const n = t / (3 * e), i = s / (3 * e), o = r / e;
3829
+ if (!(isFinite(o) && isFinite(i) && isFinite(n)))
3830
+ return qt(r, s, t);
3831
+ 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;
3832
+ if (u < 0) {
3833
+ const g = Math.sqrt(-0.25 * u), d = -0.5 * c;
3834
+ return [Math.cbrt(d + g) + Math.cbrt(d - g) - n];
3835
+ } else if (u == 0) {
3836
+ const g = kt(Math.sqrt(-l), c);
3837
+ return [g - n, -2 * g - n];
3838
+ } else {
3839
+ const g = Math.atan2(Math.sqrt(u), -c) / 3, d = Math.cos(g), w = Math.sin(g) * Math.sqrt(3), p = 0.5 * (-d + w), P = 0.5 * (-d - w), f = 2 * Math.sqrt(-l);
3840
+ return [f * d - n, f * p - n, f * P - n];
3841
+ }
3842
+ }
3843
+ function wn(r, s, t, e, n) {
3844
+ if (n == 0)
3845
+ return ze(r, s, t, e);
3846
+ const i = e / n, o = t / n, l = s / n, h = r / n;
3847
+ let a = ve(i, o, l, h, !1);
3848
+ if (a !== null)
3849
+ return a;
3850
+ const u = 716e74;
3851
+ for (let c = 0; c < 2; c++)
3852
+ if (a = ve(
3853
+ i / u,
3854
+ o / (u * u),
3855
+ l / (u * u * u),
3856
+ h / (u * u * u * u),
3857
+ c != 0
3858
+ ), a !== null) {
3859
+ for (let g = 0; g < a.length; g++)
3860
+ a[g] *= u;
3861
+ return a;
3862
+ }
3863
+ return [];
3864
+ }
3865
+ function gt(r, s) {
3866
+ return s == 0 ? Math.abs(r) : Math.abs((r - s) / s);
3867
+ }
3868
+ function ve(r, s, t, e, n) {
3869
+ const i = tn(r, s, t, e, n);
3870
+ if (i !== null && i.length == 4) {
3871
+ let o = [];
3872
+ for (let l = 0; l < 2; l++) {
3873
+ const h = i[l * 2], a = i[l * 2 + 1];
3874
+ o = o.concat(qt(a, h, 1));
3875
+ }
3876
+ return o;
3877
+ }
3878
+ return null;
3879
+ }
3880
+ function tn(r, s, t, e, n) {
3881
+ function i(x, N, A, O) {
3882
+ const U = gt(x + A, r), T = gt(N + x * A + O, s), z = gt(N * A + x * O, t);
3883
+ return U + T + z;
3884
+ }
3885
+ function o(x, N, A, O) {
3886
+ return i(x, N, A, O) + gt(N * O, e);
3887
+ }
3888
+ const l = 9 * r * r - 24 * s, h = l >= 0 ? -2 * s / (3 * r + kt(Math.sqrt(l), r)) : -0.25 * r, a = r + 4 * h, u = s + 3 * h * (r + 2 * h), c = t + h * (2 * s + h * (3 * r + 4 * h)), g = e + h * (t + h * (s + h * (r + h)));
3889
+ let d = 0, w = 0;
3890
+ const p = 349e100;
3891
+ if (n) {
3892
+ const x = a / p, N = u / p, A = c / p, O = g / p;
3893
+ d = x * A - 4 / p * O - 1 / 3 * N * N, w = (x * A - 8 / p * O - 2 / 9 * N * N) * (1 / 3) * N - A * (A / p) - x * x * O;
3894
+ } else
3895
+ 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;
3896
+ if (!isFinite(d) && isFinite(w))
3897
+ return null;
3898
+ let P = en(d, w);
3899
+ n && (P *= p);
3900
+ 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;
3901
+ let k = 0, D = 0, m = 0;
3902
+ for (let x = 0; x < 3; x++) {
3903
+ const N = x == 1 ? S : R, A = x == 0 ? v : L, O = gt(N + f * f + 2 * M, s), U = gt(2 * (N * A + f * M), t), T = gt(N * A * A + M * M, e), z = O + U + T;
3904
+ (x == 0 || z < m) && (k = N, D = A, m = z);
3905
+ }
3906
+ const b = k, j = D;
3907
+ let y = 0, C = 0, F = 0, I = 0;
3908
+ if (b < 0) {
3909
+ const x = Math.sqrt(-b);
3910
+ if (y = f + x, C = M + x * j, F = f - x, I = M - x * j, Math.abs(I) < Math.abs(C) ? I = e / C : Math.abs(I) > Math.abs(C) && (C = e / I), Math.abs(y) != Math.abs(F)) {
3911
+ let N = null, A = null;
3912
+ if (Math.abs(y) < Math.abs(F)) {
3913
+ const U = (t - C * F) / I, T = (s - I - C) / F;
3914
+ N = [r - F, U, T], A = [F, F, F];
3915
+ } else {
3916
+ const U = (t - y * I) / C, T = (s - I - C) / y, z = r - y;
3917
+ N = [y, y, y], A = [z, U, T];
3918
+ }
3919
+ let O = 0;
3920
+ for (let U = 0; U < 3; U++) {
3921
+ const T = N[U], z = A[U];
3922
+ if (isFinite(T) && isFinite(z)) {
3923
+ const X = i(T, C, z, I);
3924
+ (U == 0 || X < O) && (y = T, F = z, O = X);
3925
+ }
3926
+ }
3927
+ }
3928
+ } else if (b == 0) {
3929
+ const x = e - M * M;
3930
+ y = f, C = M + Math.sqrt(-x), F = f, I = M - Math.sqrt(-x), Math.abs(C) > Math.abs(I) ? I = e / C : Math.abs(I) > Math.abs(C) && (C = e / I);
3931
+ } else
3932
+ return [];
3933
+ let B = o(y, C, F, I);
3934
+ for (let x = 0; x < 8 && B != 0; x++) {
3935
+ const N = C * I - e, A = C * F + y * I - t, O = C + y * F + I - s, U = y + F - r, T = y - F, z = C * C - C * (F * T + 2 * I) + I * (y * T + I);
3936
+ if (z == 0)
3937
+ break;
3938
+ const X = 1 / z, G = I - C, W = C * F - y * I, se = T * N + G * A + W * O - (C * G + y * W) * U, ne = (y * T + G) * N - C * (T * A + G * O + W * U), ie = -T * N - G * A - W * O + (F * W + I * G) * U, re = -(F * T + G) * N + I * (T * A + G * O + W * U), At = y - X * se, Vt = C - X * ne, Nt = F - X * ie, $t = I - X * re, Lt = o(At, Vt, Nt, $t);
3939
+ if (Lt < B)
3940
+ y = At, C = Vt, F = Nt, I = $t, B = Lt;
3941
+ else
3942
+ break;
3943
+ }
3944
+ return [y, C, F, I];
3945
+ }
3946
+ function en(r, s) {
3947
+ const t = -0.3333333333333333 * r, e = 0.5 * s;
3948
+ let n, i = null;
3949
+ 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)
3950
+ r > 0 ? n = 0 : n = Math.sqrt(-r);
3951
+ else if (i !== null ? i < 0 : e * e < t * t * t) {
3952
+ const a = i !== null ? e / t / Math.sqrt(t) : e / Math.sqrt(t * t * t);
3953
+ n = -2 * Math.sqrt(t) * kt(Math.cos(Math.acos(Math.abs(a)) * (1 / 3)), a);
3954
+ } else {
3955
+ let a;
3956
+ i !== null ? Math.abs(t) < Math.abs(e) ? a = -e * (1 + Math.sqrt(i)) : a = -e - kt(Math.sqrt(Math.abs(t)) * t * Math.sqrt(i), e) : a = Math.cbrt(-e - kt(Math.sqrt(e * e - t * t * t), e));
3957
+ const u = a == 0 ? 0 : t / a;
3958
+ n = a + u;
3959
+ }
3960
+ let o = n, l = (o * o + r) * o + s;
3961
+ if (Math.abs(l) < 222045e-21 * Math.max(o * o * o, r * o, s))
3962
+ return o;
3963
+ for (let a = 0; a < 8; a++) {
3964
+ const u = 3 * o * o + r;
3965
+ if (u == 0)
3966
+ break;
3967
+ const c = o - l / u, g = (c * c + r) * c + s;
3968
+ if (g == 0)
3969
+ return c;
3970
+ if (Math.abs(g) >= Math.abs(l))
3971
+ break;
3972
+ o = c, l = g;
3973
+ }
3974
+ return o;
3975
+ }
3976
+ function kt(r, s) {
3977
+ const t = Math.abs(r);
3978
+ return s < 0 ? -t : t;
3979
+ }
3980
+ function sn(r, s = 1e-9) {
3981
+ if (r[r.length - 1] == 0)
3982
+ return sn(r.slice(0, -1), s);
3983
+ const t = new Hs([
3984
+ r.slice(0, -1).reverse().map((n) => -n / r[r.length - 1]),
3985
+ ...Array.from({ length: r.length - 2 }, (n, i) => {
3986
+ const o = new Array(r.length - 1).fill(0);
3987
+ return o[i] = 1, o;
3988
+ })
3989
+ ]), e = new Ks(t);
3990
+ return e.realEigenvalues.filter(
3991
+ (n, i) => Math.abs(e.imaginaryEigenvalues[i]) < s
3992
+ );
3993
+ }
3994
+ const nn = (r, s, t) => [r[0] * (1 - t) + s[0] * t, r[1] * (1 - t) + s[1] * t];
3995
+ function rn(r) {
3996
+ const s = [];
3997
+ for (let t = 0; t < r.length - 1; t++)
3998
+ s.push([r[t], r[t + 1]]);
3999
+ return s;
4000
+ }
4001
+ function de(r, s) {
4002
+ const t = rn(r).map(([e, n]) => nn(e, n, s));
4003
+ return r.length === 2 ? [t] : [...de(t, s), t];
4004
+ }
4005
+ class Et extends xt {
4006
+ constructor(t, e, n, i) {
4007
+ super(t, e);
4008
+ q(this, "segmentType", "CUBIC_BEZIER");
4009
+ q(this, "firstControlPoint");
4010
+ q(this, "lastControlPoint");
4011
+ q(this, "_boundingBox", null);
4012
+ q(this, "_polynomialCoefficients", null);
4013
+ this.firstControlPoint = n, this.lastControlPoint = i;
4014
+ }
4015
+ get midPoint() {
4016
+ return this.paramPoint(0.5);
4017
+ }
4018
+ _extremaInDirection(t) {
4019
+ const [e, n, i, o] = [
4020
+ this.firstPoint[t],
4021
+ this.firstControlPoint[t],
4022
+ this.lastControlPoint[t],
4023
+ this.lastPoint[t]
4024
+ ], l = -e + 3 * n - 3 * i + o, h = 2 * e - 4 * n + 2 * i, a = -e + n;
4025
+ return qt(a, h, l).filter(
4026
+ (u) => u >= -this.precision && u <= 1 + this.precision
4027
+ );
4028
+ }
4029
+ getParametersOfExtrema() {
4030
+ return Array.from(
4031
+ new Set(this._extremaInDirection(0).concat(this._extremaInDirection(1)))
4032
+ );
4033
+ }
4034
+ get alignedCurve() {
4035
+ const t = [-this.firstPoint[0], -this.firstPoint[1]], e = Q(this.lastPoint, this.firstPoint), n = Math.atan2(e[1], e[0]), i = new et();
4036
+ return i.translate(t[0], t[1]), i.rotate(-n), this.transform(i);
4037
+ }
4038
+ getInflexionParameters() {
4039
+ 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;
4040
+ return qt(p, w, d).filter((P) => P >= 0 && P <= 1);
4041
+ }
4042
+ get boundingBox() {
4043
+ return this._boundingBox === null && (this._boundingBox = ce([
4044
+ this.firstPoint,
4045
+ ...this.getParametersOfExtrema().map((t) => this.paramPoint(t)),
4046
+ this.lastPoint
4047
+ ]).grow(this.precision)), this._boundingBox;
4048
+ }
4049
+ clone() {
4050
+ return new Et(
4051
+ this.firstPoint,
4052
+ this.lastPoint,
4053
+ this.firstControlPoint,
4054
+ this.lastControlPoint
4055
+ );
4056
+ }
4057
+ reverse() {
4058
+ return new Et(
4059
+ this.lastPoint,
4060
+ this.firstPoint,
4061
+ this.lastControlPoint,
4062
+ this.firstControlPoint
4063
+ );
4064
+ }
4065
+ isSame(t) {
4066
+ return t.segmentType !== "CUBIC_BEZIER" ? !1 : Y(this.firstPoint, t.firstPoint) && Y(this.lastPoint, t.lastPoint) && Y(this.firstControlPoint, t.firstControlPoint) && Y(this.lastControlPoint, t.lastControlPoint);
4067
+ }
4068
+ distanceFrom(t) {
4069
+ const n = Ce((i) => Rt(this.paramPoint(i), t), this.precision);
4070
+ return n.argMin < -this.precision || n.argMin > 1 + this.precision ? Math.min(
4071
+ J(this.firstPoint, t),
4072
+ J(this.lastPoint, t)
4073
+ ) : Math.sqrt(n.fMin);
4074
+ }
4075
+ isOnSegment(t) {
4076
+ if (!this.boundingBox.contains(t))
4077
+ return !1;
4078
+ try {
4079
+ const e = this.pointToParam(t);
4080
+ return e >= -this.precision && e <= 1 + this.precision;
4081
+ } catch {
4082
+ return !1;
4083
+ }
4084
+ }
4085
+ gradientAt(t) {
4086
+ const e = 1 - t, n = e * e, i = t * t, o = 3 * n, l = 6 * e * t, h = 3 * i, a = Q(this.firstControlPoint, this.firstPoint), u = Q(this.lastControlPoint, this.firstControlPoint), c = Q(this.lastPoint, this.lastControlPoint);
4087
+ return [
4088
+ o * a[0] + l * u[0] + h * c[0],
4089
+ o * a[1] + l * u[1] + h * c[1]
4090
+ ];
4091
+ }
4092
+ secondDerivativeAt(t) {
4093
+ const e = it(this.firstPoint, this.lastControlPoint), n = nt(this.firstControlPoint, 2), i = it(this.firstControlPoint, this.lastPoint), o = nt(this.lastControlPoint, 2), l = nt(Q(e, n), 6 * (1 - t)), h = nt(Q(i, o), 6 * t);
4094
+ return it(l, h);
4095
+ }
4096
+ tangentAt(t) {
4097
+ const e = this.pointToParam(t);
4098
+ return H(this.gradientAt(e));
4099
+ }
4100
+ get tangentAtFirstPoint() {
4101
+ return H(Q(this.firstControlPoint, this.firstPoint));
4102
+ }
4103
+ get tangentAtLastPoint() {
4104
+ return H(Q(this.lastPoint, this.lastControlPoint));
4105
+ }
4106
+ normalAt(t) {
4107
+ const e = this.tangentAt(t);
4108
+ return tt(e);
4109
+ }
4110
+ get normalAtFirstPoint() {
4111
+ return tt(this.tangentAtFirstPoint);
4112
+ }
4113
+ get normalAtLastPoint() {
4114
+ return tt(this.tangentAtLastPoint);
4115
+ }
4116
+ splitAtParameters(t, e = null) {
4117
+ const n = [...t];
4118
+ n.sort((o, l) => o - l);
4119
+ let i = {
4120
+ originalParam: 0,
4121
+ param: 0,
4122
+ p0: this.firstPoint,
4123
+ p1: this.firstControlPoint,
4124
+ p2: this.lastControlPoint
4125
+ };
4126
+ return n.flatMap((o, l) => {
4127
+ if (o - i.originalParam < this.precision)
4128
+ return [];
4129
+ let h = !1;
4130
+ o > 1 - this.precision && (h = !0);
4131
+ const a = (o - i.originalParam) / (1 - i.originalParam), u = de(
4132
+ [
4133
+ i.p0,
4134
+ i.p1,
4135
+ i.p2,
4136
+ this.lastPoint
4137
+ ],
4138
+ h ? 1 : a
4139
+ ), c = h ? this.lastPoint : (e == null ? void 0 : e.get(o)) ?? u[0][0], g = u[1][0], d = u[2][0], w = u[1][1], p = u[2][2], P = new Et(
4140
+ i.p0,
4141
+ c,
4142
+ d,
4143
+ g
4144
+ );
4145
+ return i = {
4146
+ param: a,
4147
+ originalParam: o,
4148
+ p0: c,
4149
+ p1: w,
4150
+ p2: p
4151
+ }, l === n.length - 1 && !h ? [
4152
+ P,
4153
+ new Et(
4154
+ i.p0,
4155
+ this.lastPoint,
4156
+ i.p1,
4157
+ i.p2
4158
+ )
4159
+ ] : P;
4160
+ });
4161
+ }
4162
+ splitAt(t) {
4163
+ let e;
4164
+ if (Array.isArray(t) && t.length === 0)
4165
+ return [this];
4166
+ Array.isArray(t[0]) ? e = t : e = [t];
4167
+ const n = e.map((o) => this.pointToParam(o)), i = new Map(
4168
+ Kt([n, e])
4169
+ );
4170
+ return this.splitAtParameters(n, i);
4171
+ }
4172
+ transform(t) {
4173
+ return new Et(
4174
+ t.transform(this.firstPoint),
4175
+ t.transform(this.lastPoint),
4176
+ t.transform(this.firstControlPoint),
4177
+ t.transform(this.lastControlPoint)
4178
+ );
4179
+ }
4180
+ paramPoint(t) {
4181
+ const e = 1 - t, n = e * e, i = t * t, o = n * e, l = 3 * n * t, h = 3 * e * i, a = i * t;
4182
+ return [
4183
+ o * this.firstPoint[0] + l * this.firstControlPoint[0] + h * this.lastControlPoint[0] + a * this.lastPoint[0],
4184
+ o * this.firstPoint[1] + l * this.firstControlPoint[1] + h * this.lastControlPoint[1] + a * this.lastPoint[1]
4185
+ ];
4186
+ }
4187
+ get polynomialCoefficients() {
4188
+ if (this._polynomialCoefficients === null) {
4189
+ const t = (e) => {
4190
+ const n = this.firstPoint[e], i = this.firstControlPoint[e], o = this.lastControlPoint[e], l = this.lastPoint[e], h = -n + 3 * i - 3 * o + l, a = 3 * n - 6 * i + 3 * o, u = -3 * n + 3 * i;
4191
+ return [n, u, a, h];
4192
+ };
4193
+ this._polynomialCoefficients = [t(0), t(1)];
4194
+ }
4195
+ return this._polynomialCoefficients;
4196
+ }
4197
+ paramsAtY(t) {
4198
+ const [e, n, i, o] = this.polynomialCoefficients[1];
4199
+ return ze(e - t, n, i, o).filter((l) => l >= -this.precision && l <= 1 + this.precision);
4200
+ }
4201
+ pointToParam(t) {
4202
+ if (Y(t, this.firstPoint, this.precision)) return 0;
4203
+ if (Y(t, this.lastPoint, this.precision)) return 1;
4204
+ const e = this.paramsAtY(t[1]);
4205
+ if (e.length === 0)
4206
+ throw new Error("Point is not on the curve");
4207
+ const n = (o) => Math.abs(this.paramPoint(o)[0] - t[0]) <= this.precision, i = e.find(n);
4208
+ if (i === void 0)
4209
+ throw new Error("Point is not on the curve");
4210
+ return i;
4211
+ }
4212
+ }
4213
+ class jt extends xt {
4214
+ constructor(t, e, n, i, o, l, h = !1, {
4215
+ ignoreChecks: a = !1,
4216
+ angleUnits: u = "deg"
4217
+ } = {}) {
4218
+ super(t, e);
4219
+ q(this, "segmentType", "ELLIPSE_ARC");
4220
+ // I would need to do some more work to improve the precision that I can have
4221
+ // on an ellipse with intersection algorithms
4222
+ q(this, "precision", 1e-6);
4223
+ q(this, "majorRadius");
4224
+ q(this, "minorRadius");
4225
+ q(this, "center");
4226
+ q(this, "tiltAngle");
4227
+ q(this, "clockwise");
4228
+ q(this, "_coefficients", null);
4229
+ q(this, "_boundingBox");
4230
+ q(this, "_linearExentricity");
4231
+ q(this, "_exentricity");
4232
+ q(this, "_focals");
4233
+ q(this, "_ellipseReferenceFrameTransform");
4234
+ q(this, "_reverseEllipseReferenceFrameTransform");
4235
+ q(this, "_rotateFromEllipseReferenceFrame");
4236
+ q(this, "_firstAngle");
4237
+ q(this, "_lastAngle");
4238
+ q(this, "_deltaAngle");
4239
+ this.center = n;
4240
+ const c = i >= o;
4241
+ this.majorRadius = c ? i : o, this.minorRadius = c ? o : i;
4242
+ const g = u === "deg" ? l * fe : l;
4243
+ if (this.tiltAngle = wt(
4244
+ c ? g : g + Math.PI / 2
4245
+ ), this.clockwise = h, !a) {
4246
+ if (Y(t, e))
4247
+ throw new Error("Invalid arc, cannot be a full circle");
4248
+ if (!this.isPointOnEllipse(t))
4249
+ throw new Error(
4250
+ `First point ${Z(
4251
+ t
4252
+ )} not on the ellipse defined by ${this.info}`
4253
+ );
4254
+ if (!this.isPointOnEllipse(e))
4255
+ throw new Error(
4256
+ `Last point ${Z(e)} not on the ellipse defined by ${this.info}`
4257
+ );
4258
+ if (Math.abs(this.majorRadius - this.minorRadius) < this.precision)
4259
+ throw new Error(
4260
+ "Both radii should be different, create an arc instead"
4261
+ );
4262
+ }
4263
+ }
4264
+ get coefficients() {
4265
+ if (this._coefficients === null) {
4266
+ const [t, e] = this.center, n = this.majorRadius * this.majorRadius, i = this.minorRadius * this.minorRadius, o = Math.cos(this.tiltAngle), l = Math.sin(this.tiltAngle), h = n * l * l + i * o * o, a = 2 * (i - n) * l * o, u = n * o * o + i * l * l;
4267
+ this._coefficients = {
4268
+ x2: h,
4269
+ xy: a,
4270
+ y2: u,
4271
+ x: -2 * h * t - a * e,
4272
+ y: -2 * u * e - a * t,
4273
+ c: h * t * t + a * t * e + u * e * e - n * i
4274
+ };
4275
+ }
4276
+ return this._coefficients;
4277
+ }
4278
+ get info() {
4279
+ return `ELLIPSE_ARC(${Z(this.firstPoint)}, ${Z(
4280
+ this.lastPoint
4281
+ )}, ${Z(this.center)}, ${this.majorRadius}, ${this.minorRadius}, ${this.tiltAngle * Ue}, ${this.clockwise ? "CW" : "CCW"})`;
4282
+ }
4283
+ reverse() {
4284
+ return new jt(
4285
+ this.lastPoint,
4286
+ this.firstPoint,
4287
+ this.center,
4288
+ this.majorRadius,
4289
+ this.minorRadius,
4290
+ this.tiltAngle,
4291
+ !this.clockwise,
4292
+ { ignoreChecks: !0, angleUnits: "rad" }
4293
+ );
4294
+ }
4295
+ clone() {
4296
+ return new jt(
4297
+ this.firstPoint,
4298
+ this.lastPoint,
4299
+ this.center,
4300
+ this.majorRadius,
4301
+ this.minorRadius,
4302
+ this.tiltAngle,
4303
+ this.clockwise,
4304
+ { ignoreChecks: !0, angleUnits: "rad" }
4305
+ );
4306
+ }
4307
+ computeEllipseExtrema() {
4308
+ const t = Math.tan(this.tiltAngle), e = this.minorRadius / this.majorRadius, n = -Math.atan(e * t), i = Math.atan(e / t);
4309
+ return [n, Math.PI + n, i, Math.PI + i].map((l) => this.thetaToParam(l)).filter((l) => this.isValidParameter(l)).map((l) => this.paramPoint(l));
4310
+ }
4311
+ get boundingBox() {
4312
+ if (this._boundingBox === void 0) {
4313
+ const t = this.computeEllipseExtrema(), e = [
4314
+ this.firstPoint,
4315
+ this.lastPoint,
4316
+ ...t
4317
+ ];
4318
+ this._boundingBox = ce(e).grow(this.precision);
4319
+ }
4320
+ return this._boundingBox;
4321
+ }
4322
+ get linearExentricity() {
4323
+ return this._linearExentricity === void 0 && (this._linearExentricity = Math.sqrt(
4324
+ this.majorRadius * this.majorRadius - this.minorRadius * this.minorRadius
4325
+ )), this._linearExentricity;
4326
+ }
4327
+ get exentricity() {
4328
+ return this._exentricity === void 0 && (this._exentricity = this.linearExentricity / this.majorRadius), this._exentricity;
4329
+ }
4330
+ get focals() {
4331
+ if (this._focals === void 0) {
4332
+ const t = this.majorAxis;
4333
+ this._focals = [
4334
+ it(this.center, nt(t, this.linearExentricity)),
4335
+ it(this.center, nt(t, -this.linearExentricity))
4336
+ ];
4337
+ }
4338
+ return this._focals;
4339
+ }
4340
+ get majorAxis() {
4341
+ return Tt(1, this.tiltAngle);
4342
+ }
4343
+ paramPoint(t) {
4344
+ const e = this.firstAngle + t * this.deltaAngle * (this.clockwise ? -1 : 1);
4345
+ return this.reverseEllipseReferenceFrameTransform.transform([
4346
+ this.majorRadius * Math.cos(e),
4347
+ this.minorRadius * Math.sin(e)
4348
+ ]);
4349
+ }
4350
+ pointToParam(t) {
4351
+ if (!this.isPointOnEllipse(t))
4352
+ throw new Error(
4353
+ `Point ${Z(t)} not on the ellipse defined by ${this.repr}`
4354
+ );
4355
+ const e = this.thetaToParam(this.pointTheta(t));
4356
+ if (!this.isValidParameter(e))
4357
+ throw new Error(
4358
+ `Point ${Z(t)} is not on segment ${this.repr}`
4359
+ );
4360
+ return e;
4361
+ }
4362
+ get midPoint() {
4363
+ return this.paramPoint(0.5);
4364
+ }
4365
+ isValidParameter(t) {
4366
+ return 1 - t >= -this.precision && t >= -this.precision;
4367
+ }
4368
+ isSame(t) {
4369
+ return Y(this.center, t.center) && Math.abs(this.majorRadius - t.majorRadius) < this.precision && Math.abs(this.minorRadius - t.minorRadius) < this.precision && (Math.abs(this.tiltAngle - t.tiltAngle) < this.precision || Math.abs(Math.abs(this.tiltAngle - t.tiltAngle) - Math.PI) < this.precision) && (Y(this.firstPoint, t.firstPoint) && this.clockwise === t.clockwise || Y(this.firstPoint, t.lastPoint) && this.clockwise !== t.clockwise);
4370
+ }
4371
+ pointTheta(t) {
4372
+ const e = this.ellipseReferenceFrameTransform.transform(t), n = Math.atan2(
4373
+ e[1] / this.minorRadius,
4374
+ e[0] / this.majorRadius
4375
+ );
4376
+ return wt(n);
4377
+ }
4378
+ thetaToParam(t) {
4379
+ return Zt(this.firstAngle, wt(t), this.clockwise) / this.deltaAngle;
4380
+ }
4381
+ isPointOnEllipse(t) {
4382
+ const [e, n] = this.focals, i = J(t, e), o = J(t, n);
4383
+ return Math.abs(2 * this.majorRadius - i - o) < this.precision;
4384
+ }
4385
+ isOnSegment(t) {
4386
+ return this.isPointOnEllipse(t) ? this.isValidParameter(this.thetaToParam(this.pointTheta(t))) : !1;
4387
+ }
4388
+ distanceFrom(t) {
4389
+ let e;
4390
+ if (Y(t, this.center) ? e = it(
4391
+ this.center,
4392
+ nt(tt(this.majorAxis), this.minorRadius)
4393
+ ) : e = this.reverseEllipseReferenceFrameTransform.transform(
4394
+ ln(
4395
+ this.majorRadius,
4396
+ this.minorRadius,
4397
+ this.ellipseReferenceFrameTransform.transform(t)
4398
+ )
4399
+ ), this.isValidParameter(this.thetaToParam(this.pointTheta(t))))
4400
+ return J(t, e);
4401
+ if (Qe(t, this.majorAxis, this.center)) {
4402
+ const n = wt(
4403
+ 2 * Math.PI - this.pointTheta(t)
4404
+ ), i = this.thetaToParam(n);
4405
+ if (this.isValidParameter(i))
4406
+ return J(t, this.paramPoint(i));
4407
+ }
4408
+ return Math.min(
4409
+ J(t, this.firstPoint),
4410
+ J(t, this.lastPoint)
4411
+ );
4412
+ }
4413
+ get ellipseReferenceFrameTransform() {
4414
+ return this._ellipseReferenceFrameTransform === void 0 && (this._ellipseReferenceFrameTransform = new et().translate(-this.center[0], -this.center[1]).rotate(-this.tiltAngle)), this._ellipseReferenceFrameTransform;
4415
+ }
4416
+ get reverseEllipseReferenceFrameTransform() {
4417
+ return this._reverseEllipseReferenceFrameTransform === void 0 && (this._reverseEllipseReferenceFrameTransform = new et().rotate(this.tiltAngle).translate(this.center[0], this.center[1])), this._reverseEllipseReferenceFrameTransform;
4418
+ }
4419
+ get rotateFromEllipseReferenceFrame() {
4420
+ return this._rotateFromEllipseReferenceFrame === void 0 && (this._rotateFromEllipseReferenceFrame = new et().rotate(
4421
+ this.tiltAngle
4422
+ )), this._rotateFromEllipseReferenceFrame;
4423
+ }
4424
+ get firstAngle() {
4425
+ return this._firstAngle === void 0 && (this._firstAngle = this.pointTheta(this.firstPoint)), this._firstAngle;
4426
+ }
4427
+ get lastAngle() {
4428
+ return this._lastAngle === void 0 && (this._lastAngle = this.pointTheta(this.lastPoint)), this._lastAngle;
4429
+ }
4430
+ get deltaAngle() {
4431
+ return this._deltaAngle === void 0 && (this._deltaAngle = Zt(
4432
+ this.firstAngle,
4433
+ this.lastAngle,
4434
+ this.clockwise
4435
+ )), this._deltaAngle;
4436
+ }
4437
+ normalAt(t) {
4438
+ const e = this.tangentAt(t);
4439
+ return this.clockwise ? tt(e) : Qt(e);
4440
+ }
4441
+ gradientAt(t) {
4442
+ 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];
4443
+ return this.rotateFromEllipseReferenceFrame.transform(o);
4444
+ }
4445
+ tangentAt(t) {
4446
+ const e = this.pointTheta(t), n = -this.majorRadius * Math.sin(e), i = this.minorRadius * Math.cos(e), o = this.clockwise ? [-n, -i] : [n, i];
4447
+ return H(this.rotateFromEllipseReferenceFrame.transform(o));
4448
+ }
4449
+ get tangentAtFirstPoint() {
4450
+ const t = -this.majorRadius * Math.sin(this.firstAngle), e = this.minorRadius * Math.cos(this.firstAngle), n = this.clockwise ? [-t, -e] : [t, e];
4451
+ return H(this.rotateFromEllipseReferenceFrame.transform(n));
4452
+ }
4453
+ get tangentAtLastPoint() {
4454
+ const t = -this.majorRadius * Math.sin(this.lastAngle), e = this.minorRadius * Math.cos(this.lastAngle), n = this.clockwise ? [-t, -e] : [t, e];
4455
+ return H(this.rotateFromEllipseReferenceFrame.transform(n));
4456
+ }
4457
+ transform(t) {
4458
+ const e = t.transformAngle(this.tiltAngle), n = t.scaleFactor();
4459
+ return new jt(
4460
+ t.transform(this.firstPoint),
4461
+ t.transform(this.lastPoint),
4462
+ t.transform(this.center),
4463
+ this.majorRadius * n,
4464
+ this.minorRadius * n,
4465
+ e,
4466
+ t.keepsOrientation() ? this.clockwise : !this.clockwise,
4467
+ { angleUnits: "rad" }
4468
+ );
4469
+ }
4470
+ splitAt(t) {
4471
+ let e;
4472
+ if (Array.isArray(t) && t.length === 0)
4473
+ return [this];
4474
+ Array.isArray(t[0]) ? e = t : e = [t];
4475
+ const i = [0, 1, ...e.map((h) => this.pointToParam(h))], o = new Map(
4476
+ Kt([i, [this.firstPoint, this.lastPoint, ...e]])
4477
+ );
4478
+ i.sort((h, a) => h - a);
4479
+ let l = null;
4480
+ return i.flatMap((h, a) => {
4481
+ if (a === i.length - 1) return [];
4482
+ const u = i[a + 1];
4483
+ if (u - h < this.precision)
4484
+ return l === null && (l = h), [];
4485
+ const c = l === null ? h : l, g = new jt(
4486
+ o.get(c) || this.paramPoint(c),
4487
+ o.get(u) || this.paramPoint(u),
4488
+ this.center,
4489
+ this.majorRadius,
4490
+ this.minorRadius,
4491
+ this.tiltAngle,
4492
+ this.clockwise,
4493
+ { angleUnits: "rad" }
4494
+ );
4495
+ return l = null, g;
4496
+ });
4497
+ }
4498
+ }
4499
+ function pn(r, s, t, e, n, i, o) {
4500
+ const { center: l, rx: h, ry: a } = on(
4501
+ r,
4502
+ s,
4503
+ t,
4504
+ e,
4505
+ n * fe,
4506
+ !i,
4507
+ o
4508
+ );
4509
+ return Math.abs(h - a) < 1e-9 ? new ct(r, s, l, o) : new jt(r, s, l, h, a, n, o);
4510
+ }
4511
+ function on([r, s], [t, e], n, i, o, l, h) {
4512
+ if (n < 0 && (n = -n), i < 0 && (i = -i), n == 0 || i == 0)
4513
+ throw Error("rx and ry can not be 0");
4514
+ const a = Math.sin(o), u = Math.cos(o), c = (r - t) / 2, g = (s - e) / 2, d = (r + t) / 2, w = (s + e) / 2, p = u * c + a * g, P = u * g - a * c, f = p * p / (n * n) + P * P / (i * i);
4515
+ f > 1 && (n = n * Math.sqrt(f), i = i * Math.sqrt(f));
4516
+ const M = n * i, E = n * P, R = i * p, v = E * E + R * R;
4517
+ if (!v)
4518
+ throw Error("start point can not be same as end point");
4519
+ let L = Math.sqrt(Math.abs((M * M - v) / v));
4520
+ l == h && (L = -L);
4521
+ const S = L * E / i, k = -L * R / n, D = u * S - a * k + d, m = a * S + u * k + w;
4522
+ return {
4523
+ center: [D, m],
4524
+ rx: n,
4525
+ ry: i
4526
+ };
4527
+ }
4528
+ function ln(r, s, t) {
4529
+ const e = Math.abs(t[0]), n = Math.abs(t[1]);
4530
+ let i = 0.707, o = 0.707;
4531
+ const l = r, h = s;
4532
+ for (let a = 0; a < 3; a++) {
4533
+ const u = l * i, c = h * o, g = (l * l - h * h) * i ** 3 / l, d = (h * h - l * l) * o ** 3 / h, w = u - g, p = c - d, P = e - g, f = n - d, M = Math.hypot(w, p), E = Math.hypot(P, f);
4534
+ i = Math.min(1, Math.max(0, (P * M / E + g) / l)), o = Math.min(1, Math.max(0, (f * M / E + d) / h));
4535
+ const R = Math.hypot(i, o);
4536
+ i /= R, o /= R;
4537
+ }
4538
+ return [l * i * Math.sign(t[0]), h * o * Math.sign(t[1])];
4539
+ }
4540
+ class _t extends xt {
4541
+ constructor(t, e, n) {
4542
+ super(t, e);
4543
+ q(this, "segmentType", "QUADRATIC_BEZIER");
4544
+ q(this, "controlPoint");
4545
+ q(this, "_boundingBox", null);
4546
+ q(this, "_polynomialCoefficients", null);
4547
+ this.controlPoint = n;
4548
+ }
4549
+ get midPoint() {
4550
+ return this.paramPoint(0.5);
4551
+ }
4552
+ _extremaInDirection(t) {
4553
+ const [e, n, i] = [
4554
+ this.firstPoint[t],
4555
+ this.controlPoint[t],
4556
+ this.lastPoint[t]
4557
+ ], o = e - 2 * n + i;
4558
+ if (!o)
4559
+ return [];
4560
+ const l = (e - n) / o;
4561
+ return l >= -this.precision && l <= 1 + this.precision ? [l] : [];
4562
+ }
4563
+ getParametersOfExtrema() {
4564
+ return Array.from(
4565
+ new Set(this._extremaInDirection(0).concat(this._extremaInDirection(1)))
4566
+ );
4567
+ }
4568
+ get boundingBox() {
4569
+ return this._boundingBox === null && (this._boundingBox = ce([
4570
+ this.firstPoint,
4571
+ // There is either one or zero extrema in each direction
4572
+ ...this.getParametersOfExtrema().map((t) => this.paramPoint(t)),
4573
+ this.lastPoint
4574
+ ]).grow(this.precision)), this._boundingBox;
4575
+ }
4576
+ clone() {
4577
+ return new _t(
4578
+ this.firstPoint,
4579
+ this.lastPoint,
4580
+ this.controlPoint
4581
+ );
4582
+ }
4583
+ reverse() {
4584
+ return new _t(
4585
+ this.lastPoint,
4586
+ this.firstPoint,
4587
+ this.controlPoint
4588
+ );
4589
+ }
4590
+ isSame(t) {
4591
+ return t.segmentType !== "QUADRATIC_BEZIER" ? !1 : Y(this.firstPoint, t.firstPoint) && Y(this.lastPoint, t.lastPoint) && Y(this.controlPoint, t.controlPoint);
4592
+ }
4593
+ distanceFrom(t) {
4594
+ const n = Ce((i) => Rt(this.paramPoint(i), t), this.precision);
4595
+ return n.argMin < -this.precision || n.argMin > 1 + this.precision ? Math.min(
4596
+ J(this.firstPoint, t),
4597
+ J(this.lastPoint, t)
4598
+ ) : Math.sqrt(n.fMin);
4599
+ }
4600
+ isOnSegment(t) {
4601
+ if (!this.boundingBox.contains(t))
4602
+ return !1;
4603
+ try {
4604
+ const e = this.pointToParam(t);
4605
+ return e >= -this.precision && e <= 1 + this.precision;
4606
+ } catch {
4607
+ return !1;
4608
+ }
4609
+ }
4610
+ gradientAt(t) {
4611
+ const e = (n) => {
4612
+ const i = this.firstPoint[n], o = this.controlPoint[n], l = this.lastPoint[n];
4613
+ return 2 * (t * (i - 2 * o + l) - i + o);
4614
+ };
4615
+ return [e(0), e(1)];
4616
+ }
4617
+ secondDerivativeAt(t) {
4618
+ return nt(
4619
+ Q(
4620
+ it(this.firstPoint, this.lastPoint),
4621
+ nt(this.controlPoint, 2)
4622
+ ),
4623
+ 2
4624
+ );
4625
+ }
4626
+ tangentAt(t) {
4627
+ const e = this.pointToParam(t);
4628
+ return H(this.gradientAt(e));
4629
+ }
4630
+ get tangentAtFirstPoint() {
4631
+ return H(Q(this.controlPoint, this.firstPoint));
4632
+ }
4633
+ get tangentAtLastPoint() {
4634
+ return H(Q(this.lastPoint, this.controlPoint));
4635
+ }
4636
+ normalAt(t) {
4637
+ const e = this.tangentAt(t);
4638
+ return tt(e);
4639
+ }
4640
+ get normalAtFirstPoint() {
4641
+ return tt(this.tangentAtFirstPoint);
4642
+ }
4643
+ get normalAtLastPoint() {
4644
+ return tt(this.tangentAtLastPoint);
4645
+ }
4646
+ splitAtParameters(t, e = null) {
4647
+ const n = [...t];
4648
+ n.sort((o, l) => o - l);
4649
+ let i = {
4650
+ originalParam: 0,
4651
+ param: 0,
4652
+ p0: this.firstPoint,
4653
+ p1: this.controlPoint
4654
+ };
4655
+ return n.flatMap((o, l) => {
4656
+ if (o - i.originalParam < this.precision)
4657
+ return [];
4658
+ let h = !1;
4659
+ o > 1 - this.precision && (h = !0);
4660
+ const a = (o - i.originalParam) / (1 - i.originalParam), u = de(
4661
+ [i.p0, i.p1, this.lastPoint],
4662
+ h ? 1 : a
4663
+ ), 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(
4664
+ i.p0,
4665
+ c,
4666
+ g
4667
+ );
4668
+ return i = {
4669
+ param: a,
4670
+ originalParam: o,
4671
+ p0: c,
4672
+ p1: d
4673
+ }, l === n.length - 1 && !h ? [
4674
+ w,
4675
+ new _t(
4676
+ i.p0,
4677
+ this.lastPoint,
4678
+ i.p1
4679
+ )
4680
+ ] : w;
4681
+ });
4682
+ }
4683
+ splitAt(t) {
4684
+ let e;
4685
+ if (Array.isArray(t) && t.length === 0)
4686
+ return [this];
4687
+ Array.isArray(t[0]) ? e = t : e = [t];
4688
+ const n = e.map((o) => this.pointToParam(o)), i = new Map(
4689
+ Kt([n, e])
4690
+ );
4691
+ return this.splitAtParameters(n, i);
4692
+ }
4693
+ transform(t) {
4694
+ return new _t(
4695
+ t.transform(this.firstPoint),
4696
+ t.transform(this.lastPoint),
4697
+ t.transform(this.controlPoint)
4698
+ );
4699
+ }
4700
+ paramPoint(t) {
4701
+ const e = 1 - t, n = e * e, i = 2 * e * t, o = t * t;
4702
+ return [
4703
+ n * this.firstPoint[0] + i * this.controlPoint[0] + o * this.lastPoint[0],
4704
+ n * this.firstPoint[1] + i * this.controlPoint[1] + o * this.lastPoint[1]
4705
+ ];
4706
+ }
4707
+ get polynomialCoefficients() {
4708
+ if (this._polynomialCoefficients === null) {
4709
+ const t = (e) => {
4710
+ const n = this.firstPoint[e], i = this.controlPoint[e], o = this.lastPoint[e], l = n - 2 * i + o, h = 2 * (i - n);
4711
+ return [n, h, l];
4712
+ };
4713
+ this._polynomialCoefficients = [t(0), t(1)];
4714
+ }
4715
+ return this._polynomialCoefficients;
4716
+ }
4717
+ paramsAtY(t) {
4718
+ const [e, n, i] = this.polynomialCoefficients[1];
4719
+ return qt(e - t, n, i).filter(
4720
+ (o) => o >= -this.precision && o <= 1 + this.precision
4721
+ );
4722
+ }
4723
+ pointToParam(t) {
4724
+ const e = this.paramsAtY(t[1]);
4725
+ if (e.length === 0)
4726
+ throw new Error("Point is not on the curve!");
4727
+ const n = (o) => Math.abs(this.paramPoint(o)[0] - t[0]) <= this.precision, i = e.find(n);
4728
+ if (i === void 0)
4729
+ throw new Error("Point is not on the curve");
4730
+ return i;
4731
+ }
4732
+ }
4733
+ export {
4734
+ ct as A,
4735
+ mt as B,
4736
+ Et as C,
4737
+ fe as D,
4738
+ jt as E,
4739
+ Ze as F,
4740
+ Ie as G,
4741
+ Z as H,
4742
+ at as L,
4743
+ _t as Q,
4744
+ Ue as R,
4745
+ et as T,
4746
+ it as a,
4747
+ Q as b,
4748
+ St as c,
4749
+ Pe as d,
4750
+ J as e,
4751
+ Qt as f,
4752
+ Y as g,
4753
+ fn as h,
4754
+ pn as i,
4755
+ We as j,
4756
+ Tt as k,
4757
+ me as l,
4758
+ Ye as m,
4759
+ H as n,
4760
+ Rt as o,
4761
+ tt as p,
4762
+ un as q,
4763
+ Te as r,
4764
+ nt as s,
4765
+ mn as t,
4766
+ sn as u,
4767
+ wn as v,
4768
+ It as w,
4769
+ an as x,
4770
+ cn as y,
4771
+ Kt as z
4772
+ };
4773
+ //# sourceMappingURL=QuadraticBezier-PcRS9HZK.js.map