pimath 0.1.18 → 0.1.20

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 (75) hide show
  1. package/{types → dist}/algebra/equation.d.ts +1 -2
  2. package/dist/algebra/index.d.ts +8 -0
  3. package/dist/coefficients/index.d.ts +2 -0
  4. package/{types → dist}/geometry/circle.d.ts +2 -2
  5. package/dist/geometry/index.d.ts +9 -0
  6. package/{types → dist}/geometry/line.d.ts +1 -7
  7. package/{types → dist}/geometry/line3.d.ts +3 -8
  8. package/{types → dist}/geometry/plane3.d.ts +1 -10
  9. package/{types → dist}/geometry/triangle.d.ts +1 -32
  10. package/{types → dist}/index.d.ts +6 -17
  11. package/{types → dist}/pimath.interface.d.ts +55 -0
  12. package/dist/pimath.js +1500 -1486
  13. package/dist/pimath.js.map +1 -0
  14. package/dist/randomization/random.d.ts +20 -0
  15. package/package.json +7 -11
  16. package/types/algebra/equation.d.ts.map +0 -1
  17. package/types/algebra/equationSolver.d.ts.map +0 -1
  18. package/types/algebra/factor.d.ts.map +0 -1
  19. package/types/algebra/linearSystem.d.ts.map +0 -1
  20. package/types/algebra/logicalset.d.ts.map +0 -1
  21. package/types/algebra/monom.d.ts.map +0 -1
  22. package/types/algebra/polyFactor.d.ts.map +0 -1
  23. package/types/algebra/polynom.d.ts.map +0 -1
  24. package/types/coefficients/fraction.d.ts.map +0 -1
  25. package/types/coefficients/nthRoot.d.ts.map +0 -1
  26. package/types/geometry/circle.d.ts.map +0 -1
  27. package/types/geometry/geomMath.d.ts.map +0 -1
  28. package/types/geometry/line.d.ts.map +0 -1
  29. package/types/geometry/line3.d.ts.map +0 -1
  30. package/types/geometry/matrix.d.ts.map +0 -1
  31. package/types/geometry/plane3.d.ts.map +0 -1
  32. package/types/geometry/point.d.ts.map +0 -1
  33. package/types/geometry/triangle.d.ts.map +0 -1
  34. package/types/geometry/vector.d.ts.map +0 -1
  35. package/types/helpers.d.ts.map +0 -1
  36. package/types/index.d.ts.map +0 -1
  37. package/types/numeric.d.ts.map +0 -1
  38. package/types/pimath.interface.d.ts.map +0 -1
  39. package/types/randomization/algebra/rndEquation.d.ts.map +0 -1
  40. package/types/randomization/algebra/rndMonom.d.ts.map +0 -1
  41. package/types/randomization/algebra/rndPolynom.d.ts.map +0 -1
  42. package/types/randomization/coefficient/rndFraction.d.ts.map +0 -1
  43. package/types/randomization/geometry/rndCircle.d.ts.map +0 -1
  44. package/types/randomization/geometry/rndLine.d.ts.map +0 -1
  45. package/types/randomization/geometry/rndLine3.d.ts.map +0 -1
  46. package/types/randomization/geometry/rndVector.d.ts.map +0 -1
  47. package/types/randomization/random.d.ts +0 -20
  48. package/types/randomization/random.d.ts.map +0 -1
  49. package/types/randomization/rndHelpers.d.ts.map +0 -1
  50. package/types/randomization/rndTypes.d.ts.map +0 -1
  51. /package/{types → dist}/algebra/equationSolver.d.ts +0 -0
  52. /package/{types → dist}/algebra/factor.d.ts +0 -0
  53. /package/{types → dist}/algebra/linearSystem.d.ts +0 -0
  54. /package/{types → dist}/algebra/logicalset.d.ts +0 -0
  55. /package/{types → dist}/algebra/monom.d.ts +0 -0
  56. /package/{types → dist}/algebra/polyFactor.d.ts +0 -0
  57. /package/{types → dist}/algebra/polynom.d.ts +0 -0
  58. /package/{types → dist}/coefficients/fraction.d.ts +0 -0
  59. /package/{types → dist}/coefficients/nthRoot.d.ts +0 -0
  60. /package/{types → dist}/geometry/geomMath.d.ts +0 -0
  61. /package/{types → dist}/geometry/matrix.d.ts +0 -0
  62. /package/{types → dist}/geometry/point.d.ts +0 -0
  63. /package/{types → dist}/geometry/vector.d.ts +0 -0
  64. /package/{types → dist}/helpers.d.ts +0 -0
  65. /package/{types → dist}/numeric.d.ts +0 -0
  66. /package/{types → dist}/randomization/algebra/rndEquation.d.ts +0 -0
  67. /package/{types → dist}/randomization/algebra/rndMonom.d.ts +0 -0
  68. /package/{types → dist}/randomization/algebra/rndPolynom.d.ts +0 -0
  69. /package/{types → dist}/randomization/coefficient/rndFraction.d.ts +0 -0
  70. /package/{types → dist}/randomization/geometry/rndCircle.d.ts +0 -0
  71. /package/{types → dist}/randomization/geometry/rndLine.d.ts +0 -0
  72. /package/{types → dist}/randomization/geometry/rndLine3.d.ts +0 -0
  73. /package/{types → dist}/randomization/geometry/rndVector.d.ts +0 -0
  74. /package/{types → dist}/randomization/rndHelpers.d.ts +0 -0
  75. /package/{types → dist}/randomization/rndTypes.d.ts +0 -0
package/dist/pimath.js CHANGED
@@ -1,22 +1,22 @@
1
- var Bi = Object.defineProperty;
2
- var mi = (o) => {
1
+ var Si = Object.defineProperty;
2
+ var yi = (o) => {
3
3
  throw TypeError(o);
4
4
  };
5
- var Si = (o, e, t) => e in o ? Bi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
- var a = (o, e, t) => Si(o, typeof e != "symbol" ? e + "" : e, t), Kt = (o, e, t) => e.has(o) || mi("Cannot " + t);
7
- var s = (o, e, t) => (Kt(o, e, "read from private field"), t ? t.call(o) : e.get(o)), p = (o, e, t) => e.has(o) ? mi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (Kt(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), O = (o, e, t) => (Kt(o, e, "access private method"), t);
8
- function Ri(o) {
9
- const e = yi(o), t = [];
5
+ var Ri = (o, e, t) => e in o ? Si(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
6
+ var a = (o, e, t) => Ri(o, typeof e != "symbol" ? e + "" : e, t), Jt = (o, e, t) => e.has(o) || yi("Cannot " + t);
7
+ var s = (o, e, t) => (Jt(o, e, "read from private field"), t ? t.call(o) : e.get(o)), p = (o, e, t) => e.has(o) ? yi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, i) => (Jt(o, e, "write to private field"), i ? i.call(o, t) : e.set(o, t), t), O = (o, e, t) => (Jt(o, e, "access private method"), t);
8
+ function zi(o) {
9
+ const e = vi(o), t = [];
10
10
  let i, n;
11
11
  for (; e.length > 0; )
12
12
  i = e.shift() ?? 1, n = (e.length > 0 ? e.pop() : +i) ?? 1, t.push([i, n]);
13
13
  return t;
14
14
  }
15
- function zi(...o) {
16
- const e = ci(...o);
15
+ function Li(...o) {
16
+ const e = fi(...o);
17
17
  return o.map((t) => t / e);
18
18
  }
19
- function yi(o) {
19
+ function vi(o) {
20
20
  const e = Math.abs(o), t = Math.sqrt(e), i = [];
21
21
  for (let n = 1; n <= t; n++)
22
22
  o % n === 0 && (i.push(n), i.push(e / n));
@@ -24,7 +24,7 @@ function yi(o) {
24
24
  return n - r;
25
25
  }), [...new Set(i)];
26
26
  }
27
- function ci(...o) {
27
+ function fi(...o) {
28
28
  const e = function(n, r) {
29
29
  return r === 0 ? n : e(r, n % r);
30
30
  };
@@ -39,52 +39,52 @@ function ci(...o) {
39
39
  ;
40
40
  return Math.abs(t);
41
41
  }
42
- function Li(...o) {
42
+ function Di(...o) {
43
43
  return o.reduce(function(e, t) {
44
- return Math.abs(e * t / ci(e, t));
44
+ return Math.abs(e * t / fi(e, t));
45
45
  });
46
46
  }
47
- function Di(o, e = 3) {
47
+ function Vi(o, e = 3) {
48
48
  return +o.toFixed(e);
49
49
  }
50
- function Vi(o) {
50
+ function Zi(o) {
51
51
  if (Number.isSafeInteger(o) || o.toString().split(".")[0].length < 10)
52
52
  return 0;
53
53
  throw new Error("Periodic value: Not implemented yet");
54
54
  }
55
- function Zi(o) {
55
+ function Fi(o) {
56
56
  const e = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973];
57
57
  return o === void 0 ? e : e.slice(0, Math.min(e.length, o));
58
58
  }
59
- function Fi(o, e) {
59
+ function ji(o, e) {
60
60
  const t = [], i = e === !0 ? +o : o ** 2;
61
61
  for (let n = 0; n <= o; n++)
62
62
  for (let r = 0; r <= o; r++)
63
63
  n ** 2 + r ** 2 === i && t.push([n, r, o]);
64
64
  return t;
65
65
  }
66
- function ji(o, e = 2) {
66
+ function Ui(o, e = 2) {
67
67
  return +`${Math.round(+`${o}e${e}`)}e-${e}`;
68
68
  }
69
69
  const G = {
70
- decompose: Ri,
71
- dividers: yi,
72
- divideNumbersByGCD: zi,
73
- gcd: ci,
74
- lcm: Li,
75
- numberCorrection: Di,
76
- periodic: Vi,
77
- primes: Zi,
78
- pythagoreanTripletsWithTarget: Fi,
79
- round: ji
70
+ decompose: zi,
71
+ dividers: vi,
72
+ divideNumbersByGCD: Li,
73
+ gcd: fi,
74
+ lcm: Di,
75
+ numberCorrection: Vi,
76
+ periodic: Zi,
77
+ primes: Fi,
78
+ pythagoreanTripletsWithTarget: ji,
79
+ round: Ui
80
80
  };
81
- var lt, b, w, Re;
81
+ var ct, b, w, ze;
82
82
  const $ = class $ {
83
83
  constructor(e, t) {
84
- p(this, lt, !1);
84
+ p(this, ct, !1);
85
85
  p(this, b, 1);
86
86
  p(this, w, 1);
87
- p(this, Re, "frac");
87
+ p(this, ze, "frac");
88
88
  // ------------------------------------------
89
89
  /**
90
90
  * Parse the value to get the numerator and denominator
@@ -181,7 +181,7 @@ const $ = class $ {
181
181
  const e = +s(this, w);
182
182
  return h(this, w, +s(this, b)), h(this, b, e), this;
183
183
  });
184
- a(this, "isApproximative", () => s(this, lt) || s(this, w).toString().length >= 15 && s(this, b).toString().length >= 15);
184
+ a(this, "isApproximative", () => s(this, ct) || s(this, w).toString().length >= 15 && s(this, b).toString().length >= 15);
185
185
  a(this, "isEqual", (e) => this.compare(e, "="));
186
186
  a(this, "isEven", () => this.isRelative() && this.value % 2 === 0);
187
187
  a(this, "isExact", () => !this.isApproximative());
@@ -240,7 +240,7 @@ const $ = class $ {
240
240
  const t = this.sign();
241
241
  this.abs(), this.reduce();
242
242
  const i = Math.floor(Math.pow(s(this, w), Math.abs(1 / e))), n = Math.floor(Math.pow(s(this, b), Math.abs(1 / e)));
243
- return h(this, w, Math.pow(s(this, w), Math.abs(1 / e))), h(this, b, Math.pow(s(this, b), Math.abs(1 / e))), (i !== s(this, w) || n !== s(this, b)) && (h(this, w, s(this, w) / s(this, b)), h(this, b, 1), h(this, lt, !0)), this.multiply(t), this;
243
+ return h(this, w, Math.pow(s(this, w), Math.abs(1 / e))), h(this, b, Math.pow(s(this, b), Math.abs(1 / e))), (i !== s(this, w) || n !== s(this, b)) && (h(this, w, s(this, w) / s(this, b)), h(this, b, 1), h(this, ct, !0)), this.multiply(t), this;
244
244
  });
245
245
  // ------------------------------------------
246
246
  // Getter and setter
@@ -257,13 +257,13 @@ const $ = class $ {
257
257
  h(this, b, e);
258
258
  }
259
259
  get dfrac() {
260
- return h(this, Re, "dfrac"), this;
260
+ return h(this, ze, "dfrac"), this;
261
261
  }
262
262
  get display() {
263
263
  return this.isExact() ? s(this, b) === 1 ? `${s(this, w)}` : `${s(this, w)}/${s(this, b)}` : this.value.toFixed(3);
264
264
  }
265
265
  get frac() {
266
- return h(this, Re, "frac"), this;
266
+ return h(this, ze, "frac"), this;
267
267
  }
268
268
  // ------------------------------------------
269
269
  get numerator() {
@@ -274,20 +274,20 @@ const $ = class $ {
274
274
  }
275
275
  // Display getter
276
276
  get tex() {
277
- return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? s(this, b) === 1 ? `${s(this, w)}` : s(this, w) < 0 ? `-\\${s(this, Re)}{ ${-s(this, w)} }{ ${s(this, b)} }` : `\\${s(this, Re)}{ ${s(this, w)} }{ ${s(this, b)} }` : this.value.toFixed(3);
277
+ return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? s(this, b) === 1 ? `${s(this, w)}` : s(this, w) < 0 ? `-\\${s(this, ze)}{ ${-s(this, w)} }{ ${s(this, b)} }` : `\\${s(this, ze)}{ ${s(this, w)} }{ ${s(this, b)} }` : this.value.toFixed(3);
278
278
  }
279
279
  get texWithSign() {
280
280
  return this.isPositive() ? `+${this.tex}` : this.tex;
281
281
  }
282
282
  get tfrac() {
283
- return h(this, Re, "tfrac"), this;
283
+ return h(this, ze, "tfrac"), this;
284
284
  }
285
285
  get value() {
286
286
  const e = s(this, w) / s(this, b);
287
287
  return e === 0 ? 0 : e;
288
288
  }
289
289
  };
290
- lt = new WeakMap(), b = new WeakMap(), w = new WeakMap(), Re = new WeakMap(), a($, "average", (...e) => {
290
+ ct = new WeakMap(), b = new WeakMap(), w = new WeakMap(), ze = new WeakMap(), a($, "average", (...e) => {
291
291
  const t = new $().zero();
292
292
  for (const i of e)
293
293
  t.add(i);
@@ -325,17 +325,17 @@ a($, "unique", (e) => {
325
325
  return t;
326
326
  });
327
327
  let u = $;
328
- var Z, ee, ie, He;
329
- class wt {
328
+ var Z, ee, ie, Xe;
329
+ class vt {
330
330
  constructor(...e) {
331
331
  p(this, Z);
332
332
  p(this, ee);
333
333
  p(this, ie);
334
- p(this, He);
334
+ p(this, Xe);
335
335
  // ------------------------------------------
336
336
  // Creation / parsing functions
337
337
  // ------------------------------------------
338
- a(this, "parse", (e, t, i) => (h(this, ie, i ?? 1), h(this, ee, t ?? 2), h(this, Z, e), s(this, ee) % 2 === 0 && s(this, Z) < 0 && h(this, He, !1), this));
338
+ a(this, "parse", (e, t, i) => (h(this, ie, i ?? 1), h(this, ee, t ?? 2), h(this, Z, e), s(this, ee) % 2 === 0 && s(this, Z) < 0 && h(this, Xe, !1), this));
339
339
  // ------------------------------------------
340
340
  // Mathematical operations
341
341
  // ------------------------------------------
@@ -354,8 +354,8 @@ class wt {
354
354
  // ------------------------------------------
355
355
  // Help functions
356
356
  // ------------------------------------------
357
- a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this, He)));
358
- h(this, Z, 1), h(this, ie, 1), h(this, ee, 2), h(this, He, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
357
+ a(this, "hasRadical", () => !(s(this, Z) === 1 || s(this, Z) === 0 || !s(this, Xe)));
358
+ h(this, Z, 1), h(this, ie, 1), h(this, ee, 2), h(this, Xe, !0), e.length > 0 && this.parse(e[0], e[1], e[2]);
359
359
  }
360
360
  // ------------------------------------------
361
361
  // Getter and setter
@@ -390,21 +390,155 @@ class wt {
390
390
  return s(this, ie) * Math.pow(s(this, Z), 1 / s(this, ee));
391
391
  }
392
392
  }
393
- Z = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), He = new WeakMap();
394
- var Ui = Object.defineProperty, wi = (o) => {
393
+ Z = new WeakMap(), ee = new WeakMap(), ie = new WeakMap(), Xe = new WeakMap();
394
+ var ce, je, P, ot, ye, bi, ti, xi, Ei, Ni;
395
+ const mi = class mi {
396
+ constructor(e, t, i = "x") {
397
+ p(this, P);
398
+ p(this, ce);
399
+ p(this, je);
400
+ if (h(this, je, i), Object.hasOwn(e, "moveLeft")) {
401
+ const n = e;
402
+ h(this, ce, n.left.clone().subtract(n.right));
403
+ } else
404
+ h(this, ce, e.clone().subtract(t ?? 0));
405
+ }
406
+ solve() {
407
+ if (s(this, ce).degree().isOne())
408
+ return O(this, P, xi).call(this);
409
+ if (s(this, ce).degree().value === 2)
410
+ return O(this, P, Ei).call(this);
411
+ const e = O(this, P, bi).call(this);
412
+ if (e.length > 0)
413
+ return e;
414
+ if (s(this, ce).degree().value === 3)
415
+ return O(this, P, ti).call(this);
416
+ throw new Error("The equation degree is too high.");
417
+ }
418
+ solveAsCardan() {
419
+ if (s(this, ce).degree().value !== 3)
420
+ throw new Error("The equation is not cubic.");
421
+ return O(this, P, ti).call(this);
422
+ }
423
+ };
424
+ ce = new WeakMap(), je = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
425
+ return {
426
+ variable: s(this, je),
427
+ exact: !1,
428
+ value: +e.toFixed(10),
429
+ tex: (t == null ? void 0 : t.tex) ?? "",
430
+ display: (t == null ? void 0 : t.display) ?? ""
431
+ };
432
+ }, ye = function(e) {
433
+ if (e instanceof u && e.isApproximative())
434
+ return O(this, P, ot).call(this, e.value);
435
+ const t = new u(e);
436
+ return {
437
+ variable: s(this, je),
438
+ exact: t,
439
+ value: t.value,
440
+ tex: t.tex,
441
+ display: t.display
442
+ };
443
+ }, bi = function() {
444
+ let e = s(this, ce).clone(), t = [];
445
+ const i = e.lcmDenominator();
446
+ i !== 1 && e.multiply(i);
447
+ const n = e.monomByDegree().coefficient;
448
+ let r = e.monomByDegree(0).coefficient;
449
+ for (; r.isZero(); )
450
+ t.length === 0 && t.push(O(this, P, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
451
+ const l = G.dividers(n.value), c = G.dividers(r.value);
452
+ for (const f of l)
453
+ for (const g of c) {
454
+ const E = new u(g, f);
455
+ e.evaluate(E).isZero() && !t.find((V) => V.value === E.value) && t.push(O(this, P, ye).call(this, E)), E.opposite(), e.evaluate(E).isZero() && !t.find((V) => V.value === E.value) && t.push(O(this, P, ye).call(this, E));
456
+ }
457
+ for (const f of t) {
458
+ if (f.exact !== !1 && f.exact.isZero())
459
+ continue;
460
+ const g = s(this, ce).clone().parse("x", f.exact.denominator, -f.exact.numerator);
461
+ for (; e.isDividableBy(g); )
462
+ e = e.divide(g);
463
+ }
464
+ if (e.degree().isZero())
465
+ return t.sort((f, g) => f.value - g.value);
466
+ if (e.degree().value > 3)
467
+ return [];
468
+ const d = new mi(e, e.clone().parse("0"), s(this, je));
469
+ return t = t.concat(d.solve()), t.sort((f, g) => f.value - g.value);
470
+ }, ti = function() {
471
+ const e = s(this, ce), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t), d = r.clone().divide(t), f = c.clone().subtract(l.clone().pow(2).divide(3)), g = d.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), E = g.clone().opposite(), V = f.clone().opposite().pow(3).divide(27), de = E.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
472
+ if (de.isNegative()) {
473
+ const he = g.clone().opposite().add(de.clone().opposite().sqrt()).divide(2).root(3), ae = g.clone().opposite().subtract(de.clone().opposite().sqrt()).divide(2).root(3), ge = he.clone().add(ae).subtract(l.clone().divide(3));
474
+ return [O(this, P, ye).call(this, ge)];
475
+ }
476
+ if (de.isZero()) {
477
+ const he = g.clone().opposite().divide(2).root(3), ae = he.clone().opposite().subtract(l.clone().divide(3)), ge = he.clone().multiply(2).subtract(l.clone().divide(3));
478
+ return ae.isEqual(ge) ? [O(this, P, ye).call(this, ae)] : [
479
+ O(this, P, ye).call(this, ge),
480
+ O(this, P, ye).call(this, ae)
481
+ ].sort((pe, le) => pe.value - le.value);
482
+ }
483
+ if (de.isPositive()) {
484
+ const he = [], ae = f.value, ge = g.value, pe = l.value;
485
+ for (let le = 0; le < 3; le++)
486
+ he.push(2 * Math.sqrt(-ae / 3) * Math.cos(Math.acos(3 * ge / (2 * ae) * Math.sqrt(-3 / ae)) / 3 + 2 * Math.PI * le / 3) - pe / 3);
487
+ return he.map((le) => O(this, P, ot).call(this, le)).sort((le, nt) => le.value - nt.value);
488
+ }
489
+ return [];
490
+ }, xi = function() {
491
+ const e = s(this, ce).monomByDegree(0).coefficient.clone().opposite().divide(s(this, ce).monomByDegree(1).coefficient);
492
+ return [
493
+ O(this, P, ye).call(this, e)
494
+ ];
495
+ }, Ei = function() {
496
+ const e = s(this, ce), t = e.monomByDegree(2).coefficient, i = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
497
+ if (r.isNegative())
498
+ return [];
499
+ if (r.isSquare()) {
500
+ const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), d = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
501
+ return l.isZero() ? [O(this, P, ye).call(this, c)] : [
502
+ O(this, P, ye).call(this, c),
503
+ O(this, P, ye).call(this, d)
504
+ ].sort((f, g) => f.value - g.value);
505
+ }
506
+ return O(this, P, Ni).call(this, t, i, r);
507
+ }, Ni = function(e, t, i) {
508
+ const n = G.dividers(i.value).filter((pe) => Math.sqrt(pe) % 1 === 0).map((pe) => Math.sqrt(pe)).pop() ?? 1, r = G.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), d = i.clone().divide(n ** 2), f = Math.abs(n / r), g = n === 1 ? "-" : `-${f} `, E = n === 1 ? "+" : `+${f} `;
509
+ function V(pe, le, nt, Kt) {
510
+ return `\\frac{ ${le} ${nt}\\sqrt{ ${Kt} } }{ ${pe} }`;
511
+ }
512
+ function de(pe, le, nt, Kt) {
513
+ return `(${le}${nt}sqrt(${Kt}))/${pe}`;
514
+ }
515
+ const he = i.value ** 0.5, ae = (-t.value - he) / (2 * e.value), ge = (-t.value + he) / (2 * e.value);
516
+ return [
517
+ O(this, P, ot).call(this, ae, {
518
+ tex: V(c.tex, l.tex, g.toString(), d.tex),
519
+ display: de(c.display, l.display, g.toString(), d.display)
520
+ }),
521
+ O(this, P, ot).call(this, ge, {
522
+ tex: V(c.tex, l.tex, E.toString(), d.tex),
523
+ display: de(c.display, l.display, E.toString(), d.display)
524
+ })
525
+ ].sort((pe, le) => pe.value - le.value);
526
+ };
527
+ let Nt = mi;
528
+ var Gi = Object.defineProperty, Ti = (o) => {
395
529
  throw TypeError(o);
396
- }, Gi = (o, e, t) => e in o ? Ui(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, Jt = (o, e, t) => Gi(o, typeof e != "symbol" ? e + "" : e, t), vi = (o, e, t) => e.has(o) || wi("Cannot " + t), _ = (o, e, t) => (vi(o, e, "read from private field"), t ? t.call(o) : e.get(o)), nt = (o, e, t) => e.has(o) ? wi("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), be = (o, e, t, i) => (vi(o, e, "write to private field"), e.set(o, t), t);
397
- const ui = {
530
+ }, Wi = (o, e, t) => e in o ? Gi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, _t = (o, e, t) => Wi(o, typeof e != "symbol" ? e + "" : e, t), Ai = (o, e, t) => e.has(o) || Ti("Cannot " + t), _ = (o, e, t) => (Ai(o, e, "read from private field"), t ? t.call(o) : e.get(o)), rt = (o, e, t) => e.has(o) ? Ti("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), xe = (o, e, t, i) => (Ai(o, e, "write to private field"), e.set(o, t), t);
531
+ const di = {
398
532
  pi: Math.PI,
399
533
  e: Math.exp(1)
400
534
  };
401
- var m = /* @__PURE__ */ ((o) => (o.VARIABLE = "variable", o.COEFFICIENT = "coefficient", o.OPERATION = "operation", o.CONSTANT = "constant", o.FUNCTION = "function", o.FUNCTION_ARGUMENT = "function-argument", o.MONOM = "monom", o.LEFT_PARENTHESIS = "(", o.RIGHT_PARENTHESIS = ")", o))(m || {}), Ze = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Ze || {});
402
- function Wi(o, e) {
535
+ var m = /* @__PURE__ */ ((o) => (o.VARIABLE = "variable", o.COEFFICIENT = "coefficient", o.OPERATION = "operation", o.CONSTANT = "constant", o.FUNCTION = "function", o.FUNCTION_ARGUMENT = "function-argument", o.MONOM = "monom", o.LEFT_PARENTHESIS = "(", o.RIGHT_PARENTHESIS = ")", o))(m || {}), Fe = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(Fe || {});
536
+ function Hi(o, e) {
403
537
  if (o.length <= 1)
404
538
  return o;
405
539
  const t = Object.keys(e).filter((E) => e[E].type === m.FUNCTION).map((E) => E);
406
540
  t.sort((E, V) => V.length - E.length);
407
- const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(ui);
541
+ const i = new RegExp(`^(${t.join("|")})\\(`), n = Object.keys(di);
408
542
  n.sort((E, V) => V.length - E.length);
409
543
  const r = new RegExp(`^(${n.join("|")})`), l = /^(\d+(\.\d+)?)/;
410
544
  let c = "", d, f, g;
@@ -441,20 +575,20 @@ function Wi(o, e) {
441
575
  }
442
576
  if (g === void 0 || f === void 0)
443
577
  throw new Error("The token is undefined");
444
- c += Hi(d, f), c += g;
578
+ c += Xi(d, f), c += g;
445
579
  }
446
580
  return c;
447
581
  }
448
- function Hi(o, e) {
582
+ function Xi(o, e) {
449
583
  return o === void 0 || o === m.OPERATION || e === m.OPERATION || o === m.LEFT_PARENTHESIS || o === m.FUNCTION || o === m.FUNCTION_ARGUMENT || e === m.RIGHT_PARENTHESIS || e === m.FUNCTION_ARGUMENT ? "" : "*";
450
584
  }
451
- const Xi = {
585
+ const Yi = {
452
586
  "^": { precedence: 4, associative: "right", type: m.OPERATION },
453
587
  "*": { precedence: 3, associative: "left", type: m.OPERATION },
454
588
  "/": { precedence: 3, associative: "left", type: m.OPERATION },
455
589
  "+": { precedence: 2, associative: "left", type: m.OPERATION },
456
590
  "-": { precedence: 2, associative: "left", type: m.OPERATION }
457
- }, Yi = {
591
+ }, Qi = {
458
592
  "^": { precedence: 4, associative: "right", type: m.OPERATION },
459
593
  "*": { precedence: 3, associative: "left", type: m.OPERATION },
460
594
  "/": { precedence: 3, associative: "left", type: m.OPERATION },
@@ -467,7 +601,7 @@ const Xi = {
467
601
  sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
468
602
  nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
469
603
  ",": { precedence: 2, associative: "left", type: m.FUNCTION_ARGUMENT }
470
- }, Qi = {
604
+ }, Ki = {
471
605
  "^": { precedence: 4, associative: "right", type: m.OPERATION },
472
606
  "*": { precedence: 3, associative: "left", type: m.OPERATION },
473
607
  "/": { precedence: 3, associative: "left", type: m.OPERATION },
@@ -481,26 +615,26 @@ const Xi = {
481
615
  nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
482
616
  ln: { precedence: 4, associative: "right", type: m.FUNCTION },
483
617
  log: { precedence: 4, associative: "right", type: m.FUNCTION }
484
- }, Ki = {
618
+ }, Ji = {
485
619
  "&": { precedence: 3, associative: "left", type: m.OPERATION },
486
620
  "|": { precedence: 3, associative: "left", type: m.OPERATION },
487
621
  "!": { precedence: 4, associative: "right", type: m.OPERATION },
488
622
  "-": { precedence: 2, associative: "left", type: m.OPERATION }
489
623
  };
490
- var Ge, rt, te, vt, De;
491
- class Yt {
624
+ var We, ht, te, bt, Ve;
625
+ class Qt {
492
626
  constructor(e) {
493
- nt(this, Ge), nt(this, rt, []), nt(this, te, {}), nt(this, vt, []), nt(this, De), be(this, Ge, typeof e > "u" ? Ze.POLYNOM : e), this.tokenConfigInitialization();
627
+ rt(this, We), rt(this, ht, []), rt(this, te, {}), rt(this, bt, []), rt(this, Ve), xe(this, We, typeof e > "u" ? Fe.POLYNOM : e), this.tokenConfigInitialization();
494
628
  }
495
629
  // Getter
496
630
  get rpn() {
497
- return _(this, rt);
631
+ return _(this, ht);
498
632
  }
499
633
  get rpnToken() {
500
- return _(this, rt).map((e) => e.token);
634
+ return _(this, ht).map((e) => e.token);
501
635
  }
502
636
  tokenConfigInitialization() {
503
- return _(this, Ge) === Ze.SET ? (be(this, te, Ki), be(this, De, !1)) : _(this, Ge) === Ze.NUMERIC ? (be(this, te, Qi), be(this, De, !0)) : _(this, Ge) === Ze.EXPRESSION ? (be(this, te, Yi), be(this, De, !0)) : (be(this, te, Xi), be(this, De, !0)), be(this, vt, Object.keys(_(this, te)).sort((e, t) => t.length - e.length)), _(this, te);
637
+ return _(this, We) === Fe.SET ? (xe(this, te, Ji), xe(this, Ve, !1)) : _(this, We) === Fe.NUMERIC ? (xe(this, te, Ki), xe(this, Ve, !0)) : _(this, We) === Fe.EXPRESSION ? (xe(this, te, Qi), xe(this, Ve, !0)) : (xe(this, te, Yi), xe(this, Ve, !0)), xe(this, bt, Object.keys(_(this, te)).sort((e, t) => t.length - e.length)), _(this, te);
504
638
  }
505
639
  /**
506
640
  * Get the next token to analyse.
@@ -516,12 +650,12 @@ class Yt {
516
650
  else if (e[t] === ",")
517
651
  i = ",", n = m.FUNCTION_ARGUMENT;
518
652
  else {
519
- for (const r of _(this, vt))
653
+ for (const r of _(this, bt))
520
654
  if (e.substring(t, t + r.length) === r) {
521
655
  i += r, n = _(this, te)[r].type;
522
656
  break;
523
657
  }
524
- for (const r in ui)
658
+ for (const r in di)
525
659
  if (e.substring(t, t + r.length) === r) {
526
660
  i += r, n = m.CONSTANT;
527
661
  break;
@@ -549,7 +683,7 @@ class Yt {
549
683
  parse(e, t) {
550
684
  const i = [], n = [];
551
685
  let r = "", l = 0, c;
552
- (t ?? _(this, De)) && (e = Wi(e, _(this, te)));
686
+ (t ?? _(this, Ve)) && (e = Hi(e, _(this, te)));
553
687
  const d = 50;
554
688
  let f = 50, g;
555
689
  for (; l < e.length; ) {
@@ -613,15 +747,15 @@ class Yt {
613
747
  throw new Error(`Token type ${r} is not handled`);
614
748
  }
615
749
  }
616
- return be(this, rt, i.concat(n.reverse())), this;
750
+ return xe(this, ht, i.concat(n.reverse())), this;
617
751
  }
618
752
  }
619
- Ge = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), vt = /* @__PURE__ */ new WeakMap(), De = /* @__PURE__ */ new WeakMap();
620
- class Ji {
753
+ We = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), bt = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap();
754
+ class _i {
621
755
  constructor(e, t) {
622
- Jt(this, "_rpn"), Jt(this, "_expression"), Jt(this, "_isValid"), this._expression = e;
756
+ _t(this, "_rpn"), _t(this, "_expression"), _t(this, "_isValid"), this._expression = e;
623
757
  try {
624
- this._rpn = new Yt(Ze.NUMERIC).parse(e, t).rpn;
758
+ this._rpn = new Qt(Fe.NUMERIC).parse(e, t).rpn;
625
759
  } catch {
626
760
  throw this._rpn = null, this._isValid = !1, new Error(`There was a problem parsing: ${e}`);
627
761
  }
@@ -662,7 +796,7 @@ class Ji {
662
796
  else if (i.tokenType === m.VARIABLE && e !== void 0)
663
797
  Object.hasOwn(e, i.token) && t.push(+e[i.token]);
664
798
  else if (i.tokenType === m.CONSTANT)
665
- t.push(ui[i.token]);
799
+ t.push(di[i.token]);
666
800
  else if (i.tokenType === m.OPERATION) {
667
801
  if (i.token === "*") {
668
802
  const n = t.pop(), r = t.pop();
@@ -717,10 +851,10 @@ class Ji {
717
851
  return +e.toFixed(t);
718
852
  }
719
853
  }
720
- var T, v, Xe, bt, ze, Ot, qt;
854
+ var T, v, Ye, xt, Le, qt, kt;
721
855
  const I = class I {
722
856
  constructor(e) {
723
- p(this, Xe);
857
+ p(this, Ye);
724
858
  p(this, T);
725
859
  p(this, v);
726
860
  /**
@@ -740,7 +874,7 @@ const I = class I {
740
874
  a(this, "add", (...e) => {
741
875
  for (const t of e) {
742
876
  const i = t instanceof I ? t : new I(t);
743
- this.isSameAs(i) ? (this.isZero() && O(this, Xe, bt).call(this, i), s(this, T).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
877
+ this.isSameAs(i) ? (this.isZero() && O(this, Ye, xt).call(this, i), s(this, T).add(i.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", i.display);
744
878
  }
745
879
  return this;
746
880
  });
@@ -782,16 +916,16 @@ const I = class I {
782
916
  a(this, "evaluate", (e, t) => {
783
917
  if (t === !0) {
784
918
  if (e instanceof u)
785
- return s(this, ze).call(this, e.value);
786
- if (e instanceof wt)
919
+ return s(this, Le).call(this, e.value);
920
+ if (e instanceof vt)
787
921
  return new u().invalid();
788
922
  if (typeof e == "number")
789
- return s(this, ze).call(this, e);
923
+ return s(this, Le).call(this, e);
790
924
  if (typeof e == "object") {
791
925
  const n = {};
792
926
  for (const r in e)
793
927
  n[r] = new u(e[r]).value;
794
- return s(this, ze).call(this, n);
928
+ return s(this, Le).call(this, n);
795
929
  }
796
930
  }
797
931
  const i = this.coefficient.clone();
@@ -799,7 +933,7 @@ const I = class I {
799
933
  const n = {};
800
934
  return n[this.variables[0]] = new u(e), this.evaluate(n);
801
935
  }
802
- if (e instanceof wt)
936
+ if (e instanceof vt)
803
937
  return new u().invalid();
804
938
  if (typeof e == "object") {
805
939
  if (this.variables.length === 0)
@@ -942,7 +1076,7 @@ const I = class I {
942
1076
  a(this, "subtract", (...e) => {
943
1077
  for (const t of e) {
944
1078
  const i = t instanceof I ? t : new I(t);
945
- this.isSameAs(i) ? (this.isZero() && O(this, Xe, bt).call(this, i), s(this, T).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
1079
+ this.isSameAs(i) ? (this.isZero() && O(this, Ye, xt).call(this, i), s(this, T).add(i.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", i.display);
946
1080
  }
947
1081
  return this;
948
1082
  });
@@ -950,17 +1084,17 @@ const I = class I {
950
1084
  * Create a zero value monom
951
1085
  */
952
1086
  a(this, "zero", () => (h(this, T, new u().zero()), h(this, v, {}), this));
953
- p(this, ze, (e) => {
1087
+ p(this, Le, (e) => {
954
1088
  let t = this.coefficient.value;
955
1089
  if (typeof e == "number") {
956
1090
  const i = {}, n = this.variables[0];
957
- return i[n] = e, s(this, ze).call(this, i);
1091
+ return i[n] = e, s(this, Le).call(this, i);
958
1092
  }
959
1093
  if (e instanceof u) {
960
1094
  const i = {};
961
- return i[this.variables[0]] = new u(e).value, s(this, ze).call(this, i);
1095
+ return i[this.variables[0]] = new u(e).value, s(this, Le).call(this, i);
962
1096
  }
963
- if (e instanceof wt)
1097
+ if (e instanceof vt)
964
1098
  return NaN;
965
1099
  if (typeof e == "object") {
966
1100
  if (this.variables.length === 0)
@@ -972,8 +1106,8 @@ const I = class I {
972
1106
  }
973
1107
  return t;
974
1108
  });
975
- p(this, Ot, (e) => {
976
- const i = new Yt().parse(e).rpn, n = [];
1109
+ p(this, qt, (e) => {
1110
+ const i = new Qt().parse(e).rpn, n = [];
977
1111
  if (i.length === 0)
978
1112
  return this.zero(), this;
979
1113
  if (i.length === 1) {
@@ -981,10 +1115,10 @@ const I = class I {
981
1115
  return this.one(), r.tokenType === m.COEFFICIENT ? this.coefficient = new u(r.token) : r.tokenType === m.VARIABLE && this.setLetter(r.token, 1), this;
982
1116
  } else
983
1117
  for (const r of i)
984
- s(this, qt).call(this, n, r);
1118
+ s(this, kt).call(this, n, r);
985
1119
  return this.one(), this.multiply(n[0]), this;
986
1120
  });
987
- p(this, qt, (e, t) => {
1121
+ p(this, kt, (e, t) => {
988
1122
  var d;
989
1123
  let i, n, r, l, c;
990
1124
  if (t.tokenType === m.COEFFICIENT)
@@ -1017,7 +1151,7 @@ const I = class I {
1017
1151
  * @param inputStr
1018
1152
  */
1019
1153
  parse(e) {
1020
- return h(this, T, new u()), h(this, v, {}), typeof e == "string" ? s(this, Ot).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof I && (h(this, T, s(e, T).clone()), O(this, Xe, bt).call(this, e)), this;
1154
+ return h(this, T, new u()), h(this, v, {}), typeof e == "string" ? s(this, qt).call(this, e) : typeof e == "number" ? h(this, T, new u(e)) : e instanceof u ? h(this, T, e.clone()) : e instanceof I && (h(this, T, s(e, T).clone()), O(this, Ye, xt).call(this, e)), this;
1021
1155
  }
1022
1156
  /**
1023
1157
  * Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
@@ -1164,10 +1298,10 @@ const I = class I {
1164
1298
  return i;
1165
1299
  }
1166
1300
  };
1167
- T = new WeakMap(), v = new WeakMap(), Xe = new WeakSet(), bt = function(e) {
1301
+ T = new WeakMap(), v = new WeakMap(), Ye = new WeakSet(), xt = function(e) {
1168
1302
  for (const t in e.literal)
1169
1303
  s(this, v)[t] = e.literal[t].clone();
1170
- }, ze = new WeakMap(), Ot = new WeakMap(), qt = new WeakMap(), a(I, "gcd", (...e) => {
1304
+ }, Le = new WeakMap(), qt = new WeakMap(), kt = new WeakMap(), a(I, "gcd", (...e) => {
1171
1305
  for (const r of e)
1172
1306
  if (r.containsRationalPower())
1173
1307
  return new I().zero();
@@ -1191,162 +1325,28 @@ a(I, "xMultiply", (...e) => {
1191
1325
  return t;
1192
1326
  });
1193
1327
  let M = I;
1194
- var ce, Fe, P, ot, ye, bi, ei, xi, Ei, Ni;
1195
- const di = class di {
1196
- constructor(e, t, i = "x") {
1197
- p(this, P);
1198
- p(this, ce);
1199
- p(this, Fe);
1200
- if (h(this, Fe, i), Object.hasOwn(e, "moveLeft")) {
1201
- const n = e;
1202
- h(this, ce, n.left.clone().subtract(n.right));
1203
- } else
1204
- h(this, ce, e.clone().subtract(t ?? 0));
1205
- }
1206
- solve() {
1207
- if (s(this, ce).degree().isOne())
1208
- return O(this, P, xi).call(this);
1209
- if (s(this, ce).degree().value === 2)
1210
- return O(this, P, Ei).call(this);
1211
- const e = O(this, P, bi).call(this);
1212
- if (e.length > 0)
1213
- return e;
1214
- if (s(this, ce).degree().value === 3)
1215
- return O(this, P, ei).call(this);
1216
- throw new Error("The equation degree is too high.");
1217
- }
1218
- solveAsCardan() {
1219
- if (s(this, ce).degree().value !== 3)
1220
- throw new Error("The equation is not cubic.");
1221
- return O(this, P, ei).call(this);
1222
- }
1223
- };
1224
- ce = new WeakMap(), Fe = new WeakMap(), P = new WeakSet(), ot = function(e, t) {
1225
- return {
1226
- variable: s(this, Fe),
1227
- exact: !1,
1228
- value: +e.toFixed(10),
1229
- tex: (t == null ? void 0 : t.tex) ?? "",
1230
- display: (t == null ? void 0 : t.display) ?? ""
1231
- };
1232
- }, ye = function(e) {
1233
- if (e instanceof u && e.isApproximative())
1234
- return O(this, P, ot).call(this, e.value);
1235
- const t = new u(e);
1236
- return {
1237
- variable: s(this, Fe),
1238
- exact: t,
1239
- value: t.value,
1240
- tex: t.tex,
1241
- display: t.display
1242
- };
1243
- }, bi = function() {
1244
- let e = s(this, ce).clone(), t = [];
1245
- const i = e.lcmDenominator();
1246
- i !== 1 && e.multiply(i);
1247
- const n = e.monomByDegree().coefficient;
1248
- let r = e.monomByDegree(0).coefficient;
1249
- for (; r.isZero(); )
1250
- t.length === 0 && t.push(O(this, P, ye).call(this, 0)), e = e.divide("x"), r = e.monomByDegree(0).coefficient;
1251
- const l = G.dividers(n.value), c = G.dividers(r.value);
1252
- for (const f of l)
1253
- for (const g of c) {
1254
- const E = new u(g, f);
1255
- e.evaluate(E).isZero() && !t.find((V) => V.value === E.value) && t.push(O(this, P, ye).call(this, E)), E.opposite(), e.evaluate(E).isZero() && !t.find((V) => V.value === E.value) && t.push(O(this, P, ye).call(this, E));
1256
- }
1257
- for (const f of t) {
1258
- if (f.exact !== !1 && f.exact.isZero())
1259
- continue;
1260
- const g = s(this, ce).clone().parse("x", f.exact.denominator, -f.exact.numerator);
1261
- for (; e.isDividableBy(g); )
1262
- e = e.divide(g);
1263
- }
1264
- if (e.degree().isZero())
1265
- return t.sort((f, g) => f.value - g.value);
1266
- if (e.degree().value > 3)
1267
- return [];
1268
- const d = new di(e, e.clone().parse("0"), s(this, Fe));
1269
- return t = t.concat(d.solve()), t.sort((f, g) => f.value - g.value);
1270
- }, ei = function() {
1271
- const e = s(this, ce), t = e.monomByDegree(3).coefficient, i = e.monomByDegree(2).coefficient, n = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, l = i.clone().divide(t), c = n.clone().divide(t), d = r.clone().divide(t), f = c.clone().subtract(l.clone().pow(2).divide(3)), g = d.clone().subtract(l.clone().multiply(c).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), E = g.clone().opposite(), V = f.clone().opposite().pow(3).divide(27), de = E.clone().pow(2).subtract(V.clone().multiply(4)).opposite();
1272
- if (de.isNegative()) {
1273
- const he = g.clone().opposite().add(de.clone().opposite().sqrt()).divide(2).root(3), ae = g.clone().opposite().subtract(de.clone().opposite().sqrt()).divide(2).root(3), ge = he.clone().add(ae).subtract(l.clone().divide(3));
1274
- return [O(this, P, ye).call(this, ge)];
1275
- }
1276
- if (de.isZero()) {
1277
- const he = g.clone().opposite().divide(2).root(3), ae = he.clone().opposite().subtract(l.clone().divide(3)), ge = he.clone().multiply(2).subtract(l.clone().divide(3));
1278
- return ae.isEqual(ge) ? [O(this, P, ye).call(this, ae)] : [
1279
- O(this, P, ye).call(this, ge),
1280
- O(this, P, ye).call(this, ae)
1281
- ].sort((pe, le) => pe.value - le.value);
1282
- }
1283
- if (de.isPositive()) {
1284
- const he = [], ae = f.value, ge = g.value, pe = l.value;
1285
- for (let le = 0; le < 3; le++)
1286
- he.push(2 * Math.sqrt(-ae / 3) * Math.cos(Math.acos(3 * ge / (2 * ae) * Math.sqrt(-3 / ae)) / 3 + 2 * Math.PI * le / 3) - pe / 3);
1287
- return he.map((le) => O(this, P, ot).call(this, le)).sort((le, st) => le.value - st.value);
1288
- }
1289
- return [];
1290
- }, xi = function() {
1291
- const e = s(this, ce).monomByDegree(0).coefficient.clone().opposite().divide(s(this, ce).monomByDegree(1).coefficient);
1292
- return [
1293
- O(this, P, ye).call(this, e)
1294
- ];
1295
- }, Ei = function() {
1296
- const e = s(this, ce), t = e.monomByDegree(2).coefficient, i = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, r = i.clone().pow(2).subtract(t.clone().multiply(n).multiply(4));
1297
- if (r.isNegative())
1298
- return [];
1299
- if (r.isSquare()) {
1300
- const l = r.sqrt(), c = i.clone().opposite().add(l).divide(t.clone().multiply(2)), d = i.clone().opposite().subtract(l).divide(t.clone().multiply(2));
1301
- return l.isZero() ? [O(this, P, ye).call(this, c)] : [
1302
- O(this, P, ye).call(this, c),
1303
- O(this, P, ye).call(this, d)
1304
- ].sort((f, g) => f.value - g.value);
1305
- }
1306
- return O(this, P, Ni).call(this, t, i, r);
1307
- }, Ni = function(e, t, i) {
1308
- const n = G.dividers(i.value).filter((pe) => Math.sqrt(pe) % 1 === 0).map((pe) => Math.sqrt(pe)).pop() ?? 1, r = G.gcd(2 * e.value, t.value, n) * (e.isNegative() ? -1 : 1), l = t.clone().divide(r).opposite(), c = e.clone().divide(r).multiply(2), d = i.clone().divide(n ** 2), f = Math.abs(n / r), g = n === 1 ? "-" : `-${f} `, E = n === 1 ? "+" : `+${f} `;
1309
- function V(pe, le, st, Qt) {
1310
- return `\\frac{ ${le} ${st}\\sqrt{ ${Qt} } }{ ${pe} }`;
1311
- }
1312
- function de(pe, le, st, Qt) {
1313
- return `(${le}${st}sqrt(${Qt}))/${pe}`;
1314
- }
1315
- const he = i.value ** 0.5, ae = (-t.value - he) / (2 * e.value), ge = (-t.value + he) / (2 * e.value);
1316
- return [
1317
- O(this, P, ot).call(this, ae, {
1318
- tex: V(c.tex, l.tex, g.toString(), d.tex),
1319
- display: de(c.display, l.display, g.toString(), d.display)
1320
- }),
1321
- O(this, P, ot).call(this, ge, {
1322
- tex: V(c.tex, l.tex, E.toString(), d.tex),
1323
- display: de(c.display, l.display, E.toString(), d.display)
1324
- })
1325
- ].sort((pe, le) => pe.value - le.value);
1326
- };
1327
- let Et = di;
1328
- function gi(o, e = !0) {
1328
+ function wi(o, e = !0) {
1329
1329
  return e ? `\\left( ${o} \\right)` : `(${o})`;
1330
1330
  }
1331
- function Se(o, e, t, i, n) {
1331
+ function Re(o, e, t, i, n) {
1332
1332
  return o.map((r, l) => i !== void 0 && l < i || n !== void 0 && l > n ? r : r === e ? t : r);
1333
1333
  }
1334
- var je, y, Ye, ct, Qe, ut, kt, Mt, Ct, Ke, $t, ft, It, Pt, Bt, St, Ti, Rt, zt;
1334
+ var Ue, y, Qe, ut, Ke, ft, Mt, Ct, $t, Je, It, dt, Pt, Bt, St, Rt, Oi, zt, Lt;
1335
1335
  const C = class C {
1336
1336
  constructor(e, ...t) {
1337
- p(this, St);
1338
- p(this, je);
1337
+ p(this, Rt);
1338
+ p(this, Ue);
1339
1339
  p(this, y);
1340
- p(this, Ye);
1341
- p(this, ct, !1);
1340
+ p(this, Qe);
1341
+ p(this, ut, !1);
1342
1342
  /**
1343
1343
  * Parse a string to a polynom.
1344
1344
  * @param inputStr
1345
1345
  * @param values
1346
1346
  */
1347
1347
  a(this, "parse", (e, ...t) => {
1348
- if (h(this, y, []), h(this, je, []), typeof e == "string")
1349
- return O(this, St, Ti).call(this, e, ...t);
1348
+ if (h(this, y, []), h(this, Ue, []), typeof e == "string")
1349
+ return O(this, Rt, Oi).call(this, e, ...t);
1350
1350
  if ((typeof e == "number" || e instanceof u || e instanceof M) && t.length === 0)
1351
1351
  s(this, y).push(new M(e));
1352
1352
  else if (e instanceof M && t.length > 0)
@@ -1397,14 +1397,14 @@ const C = class C {
1397
1397
  });
1398
1398
  a(this, "divide", (e) => {
1399
1399
  if (e instanceof u)
1400
- return s(this, ut).call(this, e);
1400
+ return s(this, ft).call(this, e);
1401
1401
  if (typeof e == "number" && Number.isSafeInteger(e))
1402
- return s(this, kt).call(this, e);
1402
+ return s(this, Mt).call(this, e);
1403
1403
  if (e instanceof M)
1404
1404
  return this.divide(new C(e));
1405
1405
  if (e instanceof C) {
1406
1406
  if (e.monoms.length === 1 && e.variables.length === 0)
1407
- return s(this, ut).call(this, e.monoms[0].coefficient);
1407
+ return s(this, ft).call(this, e.monoms[0].coefficient);
1408
1408
  {
1409
1409
  const { quotient: t, reminder: i } = this.euclidean(e);
1410
1410
  if (i.isZero())
@@ -1435,7 +1435,7 @@ const C = class C {
1435
1435
  });
1436
1436
  a(this, "evaluate", (e, t) => {
1437
1437
  if (t)
1438
- return s(this, Mt).call(this, e);
1438
+ return s(this, Ct).call(this, e);
1439
1439
  const i = new u().zero();
1440
1440
  return s(this, y).forEach((n) => {
1441
1441
  i.add(n.evaluate(e, t));
@@ -1462,7 +1462,7 @@ const C = class C {
1462
1462
  t.push(i.clone()), i.one();
1463
1463
  break;
1464
1464
  } else {
1465
- let c = s(this, $t).call(this, i, l, e ?? "x");
1465
+ let c = s(this, It).call(this, i, l, e ?? "x");
1466
1466
  for (l = i.degree(e).value; c.length > 0; ) {
1467
1467
  const d = c[0];
1468
1468
  if (!i.isDividableBy(d))
@@ -1476,7 +1476,7 @@ const C = class C {
1476
1476
  }
1477
1477
  }
1478
1478
  }
1479
- return i.isOne() || t.push(i.clone()), h(this, je, t), s(this, je);
1479
+ return i.isOne() || t.push(i.clone()), h(this, Ue, t), s(this, Ue);
1480
1480
  });
1481
1481
  a(this, "gcdDenominator", () => G.gcd(...this.getDenominators()));
1482
1482
  a(this, "gcdNumerator", () => G.gcd(...this.getNumerators()));
@@ -1493,7 +1493,7 @@ const C = class C {
1493
1493
  e.push(t.coefficient.numerator);
1494
1494
  return e;
1495
1495
  });
1496
- a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new Et(this.clone()).solve(), this.roots));
1496
+ a(this, "getZeroes", () => this.degree().isZero() ? [] : (this.roots = new Nt(this.clone()).solve(), this.roots));
1497
1497
  a(this, "integrate", (e, t, i = "x") => {
1498
1498
  const n = this.primitive(i), r = {}, l = {};
1499
1499
  return r[i] = new u(e), l[i] = new u(t), n.evaluate(l).subtract(n.evaluate(r));
@@ -1519,8 +1519,8 @@ const C = class C {
1519
1519
  return t.isZero();
1520
1520
  }
1521
1521
  });
1522
- a(this, "isEqual", (e) => s(this, Qe).call(this, e, "="));
1523
- a(this, "isOppositeAt", (e) => s(this, Qe).call(this, e.clone().opposite(), "="));
1522
+ a(this, "isEqual", (e) => s(this, Ke).call(this, e, "="));
1523
+ a(this, "isOppositeAt", (e) => s(this, Ke).call(this, e.clone().opposite(), "="));
1524
1524
  a(this, "isReduced", (e) => {
1525
1525
  if (!this.isDeveloped(e))
1526
1526
  return !1;
@@ -1532,7 +1532,7 @@ const C = class C {
1532
1532
  return !1;
1533
1533
  return !1;
1534
1534
  });
1535
- a(this, "isSameAs", (e) => s(this, Qe).call(this, e, "same"));
1535
+ a(this, "isSameAs", (e) => s(this, Ke).call(this, e, "same"));
1536
1536
  a(this, "lcmDenominator", () => G.lcm(...this.getDenominators()));
1537
1537
  a(this, "lcmNumerator", () => G.lcm(...this.getNumerators()));
1538
1538
  a(this, "letters", () => {
@@ -1574,7 +1574,7 @@ const C = class C {
1574
1574
  r.degree(t).isEqual(e) && i.push(r.clone());
1575
1575
  return i;
1576
1576
  });
1577
- a(this, "multiply", (e) => e instanceof C ? s(this, Bt).call(this, e) : e instanceof u ? s(this, ft).call(this, e) : e instanceof M ? s(this, Pt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, It).call(this, e) : this);
1577
+ a(this, "multiply", (e) => e instanceof C ? s(this, St).call(this, e) : e instanceof u ? s(this, dt).call(this, e) : e instanceof M ? s(this, Bt).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? s(this, Pt).call(this, e) : this);
1578
1578
  a(this, "one", () => (h(this, y, []), s(this, y).push(new M().one()), this));
1579
1579
  // ------------------------------------------
1580
1580
  a(this, "opposite", () => (h(this, y, s(this, y).map((e) => e.opposite())), this));
@@ -1647,7 +1647,7 @@ const C = class C {
1647
1647
  * @returns {this}
1648
1648
  */
1649
1649
  a(this, "zero", () => (h(this, y, []), s(this, y).push(new M().zero()), this));
1650
- p(this, Qe, (e, t) => {
1650
+ p(this, Ke, (e, t) => {
1651
1651
  t === void 0 && (t = "=");
1652
1652
  const i = this.clone().reduce().reorder(), n = e.clone().reduce().reorder();
1653
1653
  switch (t) {
@@ -1659,24 +1659,24 @@ const C = class C {
1659
1659
  return !1;
1660
1660
  }
1661
1661
  });
1662
- p(this, ut, (e) => {
1662
+ p(this, ft, (e) => {
1663
1663
  for (const t of s(this, y))
1664
1664
  t.coefficient.divide(e);
1665
1665
  return this;
1666
1666
  });
1667
- p(this, kt, (e) => {
1667
+ p(this, Mt, (e) => {
1668
1668
  const t = new u(e);
1669
1669
  for (const i of s(this, y))
1670
1670
  i.coefficient.divide(t);
1671
1671
  return this;
1672
1672
  });
1673
- p(this, Mt, (e) => {
1673
+ p(this, Ct, (e) => {
1674
1674
  let t = 0;
1675
1675
  return s(this, y).forEach((i) => {
1676
1676
  t += i.evaluate(e, !0);
1677
1677
  }), t;
1678
1678
  });
1679
- p(this, Ct, (e) => {
1679
+ p(this, $t, (e) => {
1680
1680
  var E;
1681
1681
  let t, i, n, r, l, c, d, f, g;
1682
1682
  if (this.numberOfVars === 1)
@@ -1689,7 +1689,7 @@ const C = class C {
1689
1689
  new C(e).subtract(f.display).multiply(f.denominator)
1690
1690
  ]) : [this.clone()];
1691
1691
  if (n = this.monomByDegree(2, e), r = this.monomByDegree(1, e), l = this.monomByDegree(0, e), n.isLiteralSquare() && l.isLiteralSquare() && r.clone().pow(2).isSameAs(n.clone().multiply(l))) {
1692
- const V = new C("x", n.coefficient, r.coefficient, l.coefficient), de = s(E = V, Ct).call(E, "x"), he = [];
1692
+ const V = new C("x", n.coefficient, r.coefficient, l.coefficient), de = s(E = V, $t).call(E, "x"), he = [];
1693
1693
  let ae;
1694
1694
  if (de.length >= 2) {
1695
1695
  for (const ge of de)
@@ -1699,7 +1699,7 @@ const C = class C {
1699
1699
  }
1700
1700
  return [this.clone()];
1701
1701
  });
1702
- p(this, Ke, (e, t, i, n) => {
1702
+ p(this, Je, (e, t, i, n) => {
1703
1703
  let r = "";
1704
1704
  for (const l of s(this, y)) {
1705
1705
  if (l.coefficient.value === 0)
@@ -1709,7 +1709,7 @@ const C = class C {
1709
1709
  }
1710
1710
  return i === !0 && this.length > 1 && (e === "tex" ? r = `\\left( ${r} \\right)` : r = `(${r})`), r === "" && (r = "0"), r;
1711
1711
  });
1712
- p(this, $t, (e, t, i) => {
1712
+ p(this, It, (e, t, i) => {
1713
1713
  const n = e.monoms[0].dividers, r = e.monoms[e.monoms.length - 1].dividers, l = [];
1714
1714
  return n.forEach((c) => {
1715
1715
  c.degree(i).isLeq(t) && r.forEach((d) => {
@@ -1717,18 +1717,18 @@ const C = class C {
1717
1717
  });
1718
1718
  }), l;
1719
1719
  });
1720
- p(this, ft, (e) => {
1720
+ p(this, dt, (e) => {
1721
1721
  for (const t of s(this, y))
1722
1722
  t.coefficient.multiply(e);
1723
1723
  return this.reduce();
1724
1724
  });
1725
- p(this, It, (e) => s(this, ft).call(this, new u(e)));
1726
- p(this, Pt, (e) => {
1725
+ p(this, Pt, (e) => s(this, dt).call(this, new u(e)));
1726
+ p(this, Bt, (e) => {
1727
1727
  for (const t of s(this, y))
1728
1728
  t.multiply(e);
1729
1729
  return this.reduce();
1730
1730
  });
1731
- p(this, Bt, (e) => {
1731
+ p(this, St, (e) => {
1732
1732
  const t = [];
1733
1733
  for (const i of s(this, y))
1734
1734
  for (const n of e.monoms)
@@ -1739,15 +1739,15 @@ const C = class C {
1739
1739
  * Main parse using a shutting yard class
1740
1740
  * @param inputStr
1741
1741
  */
1742
- p(this, Rt, (e) => {
1743
- const i = new Yt().parse(e).rpn;
1742
+ p(this, zt, (e) => {
1743
+ const i = new Qt().parse(e).rpn;
1744
1744
  this.zero();
1745
1745
  const n = [];
1746
1746
  for (const r of i)
1747
- s(this, zt).call(this, n, r);
1747
+ s(this, Lt).call(this, n, r);
1748
1748
  return n.length === 1 && this.add(n[0]), this.reorder();
1749
1749
  });
1750
- p(this, zt, (e, t) => {
1750
+ p(this, Lt, (e, t) => {
1751
1751
  switch (t.tokenType) {
1752
1752
  case m.COEFFICIENT:
1753
1753
  e.push(new C(t.token));
@@ -1797,10 +1797,10 @@ const C = class C {
1797
1797
  break;
1798
1798
  }
1799
1799
  });
1800
- return h(this, y, []), h(this, je, []), h(this, Ye, []), e !== void 0 && this.parse(e, ...t), this;
1800
+ return h(this, y, []), h(this, Ue, []), h(this, Qe, []), e !== void 0 && this.parse(e, ...t), this;
1801
1801
  }
1802
1802
  get display() {
1803
- return s(this, Ke).call(this);
1803
+ return s(this, Je).call(this);
1804
1804
  }
1805
1805
  hasVariable(e) {
1806
1806
  return this.variables.includes(e);
@@ -1830,16 +1830,16 @@ const C = class C {
1830
1830
  return this.variables.length;
1831
1831
  }
1832
1832
  get plotFunction() {
1833
- return s(this, Ke).call(this, "tex", !1, !1, !0);
1833
+ return s(this, Je).call(this, "tex", !1, !1, !0);
1834
1834
  }
1835
1835
  root() {
1836
1836
  throw new Error("Cannot take the root from a polynom");
1837
1837
  }
1838
1838
  get roots() {
1839
- return s(this, ct) ? s(this, Ye) : this.getZeroes();
1839
+ return s(this, ut) ? s(this, Qe) : this.getZeroes();
1840
1840
  }
1841
1841
  set roots(e) {
1842
- h(this, ct, !0), h(this, Ye, e);
1842
+ h(this, ut, !0), h(this, Qe, e);
1843
1843
  }
1844
1844
  sqrt() {
1845
1845
  throw new Error("Cannot take the square root from a polynom");
@@ -1850,15 +1850,15 @@ const C = class C {
1850
1850
  throw new Error("Some roots cannot be found !");
1851
1851
  let n = [""];
1852
1852
  if (t.forEach(() => n.push("t", "")), t.length === 0)
1853
- n = Se(n, "", this.monomsByDegree()[0].coefficient.isPositive() ? "+" : "-");
1853
+ n = Re(n, "", this.monomsByDegree()[0].coefficient.isPositive() ? "+" : "-");
1854
1854
  else if (this.degree().isOne()) {
1855
1855
  const r = this.monomsByDegree(1)[0].coefficient.sign(), l = t.findIndex((c) => c.value === i[0].value) * 2 + 1;
1856
- n[l] = "z", n = Se(n, "", r === 1 ? "-" : "+", 0, l), n = Se(n, "", r === 1 ? "+" : "-", l);
1856
+ n[l] = "z", n = Re(n, "", r === 1 ? "-" : "+", 0, l), n = Re(n, "", r === 1 ? "+" : "-", l);
1857
1857
  } else {
1858
1858
  let r = 0, l, c = "+";
1859
1859
  i.forEach((d, f) => {
1860
1860
  const g = t.findIndex((V) => V.value === i[f].value);
1861
- f === 0 && (l = g * 2 + 1, n[l] = "z", n = Se(
1861
+ f === 0 && (l = g * 2 + 1, n[l] = "z", n = Re(
1862
1862
  n,
1863
1863
  "",
1864
1864
  this.evaluate(d.value - 1, !0) < 0 ? "-" : "+",
@@ -1866,13 +1866,13 @@ const C = class C {
1866
1866
  l
1867
1867
  )), r = g * 2 + 1, l = f === i.length - 1 ? n.length : t.findIndex((V) => V.value === i[f + 1].value) * 2 + 1;
1868
1868
  const E = f === i.length - 1 ? d.value + 1 : (d.value + i[f + 1].value) / 2;
1869
- c = this.evaluate(E, !0) < 0 ? "-" : "+", n[r] = "z", n = Se(n, "", c, r, l), r = +l, l = n.length;
1869
+ c = this.evaluate(E, !0) < 0 ? "-" : "+", n[r] = "z", n = Re(n, "", c, r, l), r = +l, l = n.length;
1870
1870
  });
1871
1871
  }
1872
1872
  return { roots: t, signs: n };
1873
1873
  }
1874
1874
  get tex() {
1875
- return s(this, Ke).call(this, "tex");
1875
+ return s(this, Je).call(this, "tex");
1876
1876
  }
1877
1877
  get variables() {
1878
1878
  let e = [];
@@ -1884,14 +1884,14 @@ const C = class C {
1884
1884
  return this.getZeroes();
1885
1885
  }
1886
1886
  };
1887
- je = new WeakMap(), y = new WeakMap(), Ye = new WeakMap(), ct = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), kt = new WeakMap(), Mt = new WeakMap(), Ct = new WeakMap(), Ke = new WeakMap(), $t = new WeakMap(), ft = new WeakMap(), It = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), St = new WeakSet(), Ti = function(e, ...t) {
1887
+ Ue = new WeakMap(), y = new WeakMap(), Qe = new WeakMap(), ut = new WeakMap(), Ke = new WeakMap(), ft = new WeakMap(), Mt = new WeakMap(), Ct = new WeakMap(), $t = new WeakMap(), Je = new WeakMap(), It = new WeakMap(), dt = new WeakMap(), Pt = new WeakMap(), Bt = new WeakMap(), St = new WeakMap(), Rt = new WeakSet(), Oi = function(e, ...t) {
1888
1888
  if (t.length === 0) {
1889
1889
  if (e = "" + e, e !== "" && !isNaN(Number(e))) {
1890
1890
  this.empty();
1891
1891
  const i = new M(e);
1892
1892
  return this.add(i), this;
1893
1893
  }
1894
- return s(this, Rt).call(this, e);
1894
+ return s(this, zt).call(this, e);
1895
1895
  } else if (/^[a-z]+/.test(e)) {
1896
1896
  this.empty();
1897
1897
  const i = t.map((n) => new u(n));
@@ -1912,54 +1912,287 @@ je = new WeakMap(), y = new WeakMap(), Ye = new WeakMap(), ct = new WeakMap(), Q
1912
1912
  return this;
1913
1913
  } else
1914
1914
  return this.zero();
1915
- }, Rt = new WeakMap(), zt = new WeakMap();
1915
+ }, zt = new WeakMap(), Lt = new WeakMap();
1916
1916
  let q = C;
1917
- var Ee, Ne, Te, Je;
1918
- const we = class we {
1917
+ var A, k, se, Dt, _e, Vt;
1918
+ const Ee = class Ee {
1919
+ constructor(e, t, i) {
1920
+ // Left part of the equation
1921
+ p(this, A);
1922
+ // Right part of the equation
1923
+ p(this, k);
1924
+ // Signe of the equation
1925
+ p(this, se);
1926
+ // ------------------------------------------
1927
+ a(this, "parse", (e) => {
1928
+ const t = s(this, Dt).call(this, e);
1929
+ if (t === !1)
1930
+ throw new Error("The equation is not valid (no sign found)");
1931
+ const i = e.split(t);
1932
+ return this.create(new q(i[0]), new q(i[1]), s(this, _e).call(this, t));
1933
+ });
1934
+ a(this, "create", (e, t, i) => (h(this, A, e), h(this, k, t), h(this, se, s(this, _e).call(this, i ?? "=")), this));
1935
+ a(this, "clone", () => new Ee(s(this, A).clone(), s(this, k).clone(), s(this, se)));
1936
+ /**
1937
+ * Get the degree of the equation
1938
+ * @param letter
1939
+ */
1940
+ a(this, "degree", (e) => u.max(s(this, A).degree(e), s(this, k).degree(e)));
1941
+ /**
1942
+ * divide an equation by a given value (transformed as a fraction)
1943
+ *
1944
+ * ```
1945
+ * 8x+10=6x \vert 2
1946
+ * 4x+5=3x
1947
+ * ```
1948
+ *
1949
+ * |>Alternatively with $3x-4$ maybe it's working ?
1950
+ * $$\frac{3x}{5}$$
1951
+ *
1952
+ * @param value
1953
+ * @returns {Equation}
1954
+ */
1955
+ a(this, "divide", (e) => {
1956
+ const t = new u(e);
1957
+ return t.isZero() ? this : this.multiply(t.inverse());
1958
+ });
1959
+ /**
1960
+ * Determine if the equation contains a variable.
1961
+ * @param letter
1962
+ */
1963
+ a(this, "hasVariable", (e) => this.variables.includes(e));
1964
+ a(this, "isLinearTo", (e) => {
1965
+ const t = e.clone().moveLeft().simplify().left, i = this.clone().moveLeft().simplify().left;
1966
+ return t.isEqual(i) || t.isOppositeAt(i);
1967
+ });
1968
+ /**
1969
+ * Determine if the equation contains more than one letter/variable.
1970
+ */
1971
+ a(this, "isMultiVariable", () => s(this, A).isMultiVariable || s(this, k).isMultiVariable);
1972
+ // -----------------------------------------------
1973
+ // Equations helpers
1974
+ a(this, "isEqualTo", (e) => {
1975
+ const t = e.clone().moveLeft().left, i = this.clone().moveLeft().left;
1976
+ return t.isEqual(i) || t.isOppositeAt(i);
1977
+ });
1978
+ /**
1979
+ * Reorder the polynom to have only one letter on the left, the rest on the right.
1980
+ * @param letter
1981
+ */
1982
+ a(this, "isolate", (e) => {
1983
+ if (!this.degree(e).isOne() || this.isMultiVariable())
1984
+ return !1;
1985
+ let t;
1986
+ s(this, A).subtract(s(this, k)), s(this, k).zero();
1987
+ const i = [...s(this, A).monoms];
1988
+ for (const r of i)
1989
+ r.hasVariable(e) || (t = r.clone(), s(this, A).subtract(t), s(this, k).subtract(t));
1990
+ if (s(this, A).length !== 1)
1991
+ return !1;
1992
+ const n = s(this, A).monoms[0].coefficient.clone();
1993
+ return s(this, A).divide(n), s(this, k).divide(n), this;
1994
+ });
1995
+ // -----------------------------------------------
1996
+ // Equations operations
1997
+ // -----------------------------------------------
1998
+ a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this, A).letters(), ...s(this, k).letters()])]);
1999
+ // -----------------------------------------------
2000
+ /**
2001
+ * Reorder will move all monoms containing a letter on the left, all the other on the right.
2002
+ */
2003
+ a(this, "moveLeft", () => (s(this, A).subtract(s(this, k)), s(this, k).zero(), this));
2004
+ /**
2005
+ * Multiple an equation by a fraction value.
2006
+ * @param value
2007
+ */
2008
+ a(this, "multiply", (e) => {
2009
+ const t = new u(e);
2010
+ return s(this, A).multiply(t), s(this, k).multiply(t), s(this, se) !== "=" && t.sign() === -1 && s(this, Vt).call(this), this;
2011
+ });
2012
+ a(this, "opposite", () => (h(this, A, s(this, A).opposite()), h(this, k, s(this, k).opposite()), this));
2013
+ a(this, "reorder", (e) => (s(this, A).subtract(s(this, k)), s(this, k).zero(), s(this, A).reorder(), e ? this : (s(this, A).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
2014
+ const i = t.clone();
2015
+ s(this, A).subtract(i), s(this, k).subtract(i);
2016
+ }), s(this, A).reorder(), s(this, k).reorder(), this)));
2017
+ // ------------------------------------------
2018
+ a(this, "replaceBy", (e, t) => (s(this, A).replaceBy(e, t), s(this, k).replaceBy(e, t), this));
2019
+ /**
2020
+ * Multiply by the lcm denominator and divide by the gcm numerators.
2021
+ */
2022
+ a(this, "simplify", () => (this.multiply(G.lcm(...s(this, A).getDenominators(), ...s(this, k).getDenominators())), this.divide(G.gcd(...s(this, A).getNumerators(), ...s(this, k).getNumerators())), this));
2023
+ // -----------------------------------------------
2024
+ a(this, "solve", () => new Nt(this.clone()).solve());
2025
+ a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
2026
+ p(this, Dt, (e) => {
2027
+ if (e.includes("geq"))
2028
+ return e.includes("\\geq") ? "\\geq" : "geq";
2029
+ if (e.includes("leq"))
2030
+ return e.includes("\\leq") ? "\\leq" : "leq";
2031
+ if (e.includes(">="))
2032
+ return ">=";
2033
+ if (e.includes("=>"))
2034
+ return "=>";
2035
+ if (e.includes(">"))
2036
+ return ">";
2037
+ if (e.includes("<="))
2038
+ return "<=";
2039
+ if (e.includes("=<"))
2040
+ return "=<";
2041
+ if (e.includes("<"))
2042
+ return "<";
2043
+ if (e.includes("="))
2044
+ return "=";
2045
+ throw new Error("The equation is not valid (no sign found)");
2046
+ });
2047
+ // -----------------------------------------------
2048
+ // Equations solving algorithms
2049
+ p(this, _e, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
2050
+ p(this, Vt, () => s(this, se) === "=" ? this : s(this, se).includes("<") ? (s(this, se).replace("<", ">"), this) : s(this, se).includes(">") ? (s(this, se).replace(">", "<"), this) : this);
2051
+ if (h(this, A, new q().zero()), h(this, k, new q().zero()), h(this, se, "="), e !== void 0 && t === void 0) {
2052
+ if (e instanceof Ee)
2053
+ return e.clone();
2054
+ typeof e == "string" && this.parse(e);
2055
+ } else e !== void 0 && t !== void 0 && (this.left = new q(e), this.right = new q(t));
2056
+ return i !== void 0 && (this.sign = i), this;
2057
+ }
2058
+ /**
2059
+ * Add a value to the equation
2060
+ * if value is an equation, add the left part to the left part of the equation
2061
+ * and the right part to the right part of the equation
2062
+ * if value is a string, try to create an equation
2063
+ * if it fails, create a polynom and add it to the left and right part of the equation
2064
+ * @param value | Polynom | Monom | Fraction | string | monom
2065
+ */
2066
+ add(e) {
2067
+ if (e instanceof Ee)
2068
+ return s(this, A).add(e.left), s(this, k).add(e.right), this;
2069
+ if (typeof e == "string" && !Ee.isEquationString(e))
2070
+ return this.add(new Ee(e));
2071
+ const t = new q(e);
2072
+ return s(this, A).add(t), s(this, k).add(t), this;
2073
+ }
2074
+ /**
2075
+ * Create an Equation using two polynoms.
2076
+ * Markdown *support* is cool
2077
+ * @param values
2078
+ * @param asNumeric
2079
+ */
2080
+ evaluate(e, t) {
2081
+ const i = s(this, A).evaluate(e, t), n = s(this, k).evaluate(e, t);
2082
+ return t ? i === n : i.isEqual(n);
2083
+ }
2084
+ isEqual(e) {
2085
+ const t = new Ee(e);
2086
+ return t.left.isEqual(s(this, A)) && t.right.isEqual(s(this, k));
2087
+ }
2088
+ pow(e) {
2089
+ return s(this, A).pow(e), s(this, k).pow(e), this;
2090
+ }
2091
+ reduce() {
2092
+ return this.moveLeft(), s(this, A).reduce(), this.simplify(), s(this, A).monoms[0].coefficient.isNegative() && this.multiply(-1), this;
2093
+ }
2094
+ split() {
2095
+ return [s(this, A).clone(), s(this, k).clone()];
2096
+ }
2097
+ subtract(e) {
2098
+ if (e instanceof Ee)
2099
+ return s(this, A).subtract(e.left), s(this, k).subtract(e.right), this;
2100
+ if (typeof e == "string" && !Ee.isEquationString(e))
2101
+ return this.subtract(new Ee(e));
2102
+ const t = new q(e);
2103
+ return s(this, A).subtract(t), s(this, k).subtract(t), this;
2104
+ }
2105
+ static isEquationString(e) {
2106
+ return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
2107
+ }
2108
+ static makeSolutionsUnique(e, t) {
2109
+ const i = [], n = e.filter((r) => i.includes(r.tex) ? !1 : (i.push(r.tex), !0));
2110
+ return t === !0 && n.sort((r, l) => r.value - l.value), n;
2111
+ }
2112
+ get display() {
2113
+ return `${s(this, A).display}${this.signAsTex}${s(this, k).display}`;
2114
+ }
2115
+ // Getter and setter
2116
+ get left() {
2117
+ return s(this, A);
2118
+ }
2119
+ set left(e) {
2120
+ h(this, A, e);
2121
+ }
2122
+ get numberOfVars() {
2123
+ return this.variables.length;
2124
+ }
2125
+ get right() {
2126
+ return s(this, k);
2127
+ }
2128
+ set right(e) {
2129
+ h(this, k, e);
2130
+ }
2131
+ // ------------------------------------------
2132
+ get sign() {
2133
+ return s(this, se);
2134
+ }
2135
+ set sign(e) {
2136
+ h(this, se, s(this, _e).call(this, e));
2137
+ }
2138
+ get signAsTex() {
2139
+ return s(this, se) === ">=" ? "\\geq" : s(this, se) === "<=" ? "\\leq" : s(this, se);
2140
+ }
2141
+ get tex() {
2142
+ return `${s(this, A).tex}${this.signAsTex}${s(this, k).tex}`;
2143
+ }
2144
+ get variables() {
2145
+ return [...new Set(s(this, k).variables.concat(s(this, A).variables))];
2146
+ }
2147
+ };
2148
+ A = new WeakMap(), k = new WeakMap(), se = new WeakMap(), Dt = new WeakMap(), _e = new WeakMap(), Vt = new WeakMap();
2149
+ let H = Ee;
2150
+ var Ne, Te, Ae, et;
2151
+ const ve = class ve {
1919
2152
  constructor(e, t) {
1920
- p(this, Ee);
1921
2153
  p(this, Ne);
1922
2154
  p(this, Te);
1923
- p(this, Je, !1);
1924
- if (e instanceof we)
1925
- h(this, Ne, e.polynom.clone()), h(this, Te, e.power.clone());
2155
+ p(this, Ae);
2156
+ p(this, et, !1);
2157
+ if (e instanceof ve)
2158
+ h(this, Te, e.polynom.clone()), h(this, Ae, e.power.clone());
1926
2159
  else if (typeof e == "string" && t === void 0) {
1927
2160
  const [i, n = "1"] = e.split("^");
1928
- h(this, Ne, new q(i)), h(this, Te, new u(n.replace("(", "").replace(")", "")));
2161
+ h(this, Te, new q(i)), h(this, Ae, new u(n.replace("(", "").replace(")", "")));
1929
2162
  } else
1930
- h(this, Ne, new q(e)), h(this, Te, new u(t ?? 1));
1931
- return h(this, Ee, 1), this;
2163
+ h(this, Te, new q(e)), h(this, Ae, new u(t ?? 1));
2164
+ return h(this, Ne, 1), this;
1932
2165
  }
1933
2166
  parse() {
1934
2167
  throw new Error("Method not implemented.");
1935
2168
  }
1936
2169
  clone() {
1937
- return new we(this);
2170
+ return new ve(this);
1938
2171
  }
1939
2172
  get tex() {
1940
2173
  const e = this.power.numerator, t = this.power.denominator;
1941
2174
  let i, n;
1942
- return s(this, Ee) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this, Je) && this.power.isOne() ? this.polynom.tex : gi(this.polynom.tex), n = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Ee) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
2175
+ return s(this, Ne) === 0 && t > 1 ? (i = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, n = e === 1 ? "" : `^{ ${e} }`) : (i = s(this, et) && this.power.isOne() ? this.polynom.tex : wi(this.polynom.tex), n = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), i = `${i}${n}`, s(this, Ne) === 0 && e < 0 && (i = `\\frac{ 1 }{ ${i} }`), i;
1943
2176
  }
1944
2177
  get display() {
1945
2178
  const e = this.power.numerator, t = this.power.denominator;
1946
2179
  let i, n;
1947
- return s(this, Ee) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this, Je) && this.power.isOne() ? this.polynom.display : gi(this.polynom.display, !1), n = t === 1 && e === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Ee) === 0 && e < 0 && (i = `1/(${i})`), i;
2180
+ return s(this, Ne) === 0 && t > 1 ? (i = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, n = e === 1 ? "" : `^(${e})`) : (i = s(this, et) && this.power.isOne() ? this.polynom.display : wi(this.polynom.display, !1), n = t === 1 && e === 1 ? "" : `^(${this.power.display})`), i = `${i}${n}`, s(this, Ne) === 0 && e < 0 && (i = `1/(${i})`), i;
1948
2181
  }
1949
2182
  add() {
1950
2183
  throw new Error("Adding two factors is not possible");
1951
2184
  }
1952
2185
  get asSingle() {
1953
- return h(this, Je, !0), this;
2186
+ return h(this, et, !0), this;
1954
2187
  }
1955
2188
  degree(e) {
1956
2189
  return this.polynom.degree(e).multiply(this.power);
1957
2190
  }
1958
2191
  derivative() {
1959
- return this.power.isZero() ? [new we("0", "1")] : this.power.isOne() ? [new we(this.polynom.clone().derivative())] : [
1960
- new we(this.power.clone()),
1961
- new we(this.polynom.clone().derivative()),
1962
- new we(this.polynom.clone(), this.power.clone().subtract(1))
2192
+ return this.power.isZero() ? [new ve("0", "1")] : this.power.isOne() ? [new ve(this.polynom.clone().derivative())] : [
2193
+ new ve(this.power.clone()),
2194
+ new ve(this.polynom.clone().derivative()),
2195
+ new ve(this.polynom.clone(), this.power.clone().subtract(1))
1963
2196
  ];
1964
2197
  }
1965
2198
  develop() {
@@ -1968,7 +2201,7 @@ const we = class we {
1968
2201
  throw new Error("The power must be a natural number");
1969
2202
  }
1970
2203
  divide(e) {
1971
- if (e instanceof we && this.isSameAs(e))
2204
+ if (e instanceof ve && this.isSameAs(e))
1972
2205
  return this.power.subtract(e.power), this;
1973
2206
  const t = new q(e);
1974
2207
  if (this.isSameAs(t))
@@ -1992,13 +2225,13 @@ const we = class we {
1992
2225
  }
1993
2226
  isSameAs(e) {
1994
2227
  let t;
1995
- return e instanceof we ? t = e.polynom : e instanceof q ? t = e : t = new q(e), this.polynom.isEqual(t);
2228
+ return e instanceof ve ? t = e.polynom : e instanceof q ? t = e : t = new q(e), this.polynom.isEqual(t);
1996
2229
  }
1997
2230
  isZero() {
1998
2231
  return this.polynom.isZero();
1999
2232
  }
2000
2233
  multiply(e) {
2001
- if (e instanceof we && this.isSameAs(e))
2234
+ if (e instanceof ve && this.isSameAs(e))
2002
2235
  return this.power.add(e.power), this;
2003
2236
  const t = new q(e);
2004
2237
  if (this.isSameAs(t))
@@ -2006,25 +2239,25 @@ const we = class we {
2006
2239
  throw new Error("The two factors must be the same");
2007
2240
  }
2008
2241
  one() {
2009
- return s(this, Ne).one(), s(this, Te).one(), this;
2242
+ return s(this, Te).one(), s(this, Ae).one(), this;
2010
2243
  }
2011
2244
  opposite() {
2012
2245
  throw new Error("Method not implemented.");
2013
2246
  }
2014
2247
  get polynom() {
2015
- return s(this, Ne);
2248
+ return s(this, Te);
2016
2249
  }
2017
2250
  set polynom(e) {
2018
- h(this, Ne, e);
2251
+ h(this, Te, e);
2019
2252
  }
2020
2253
  pow(e) {
2021
2254
  return this.power.multiply(e), this;
2022
2255
  }
2023
2256
  get power() {
2024
- return s(this, Te);
2257
+ return s(this, Ae);
2025
2258
  }
2026
2259
  set power(e) {
2027
- h(this, Te, new u(e));
2260
+ h(this, Ae, new u(e));
2028
2261
  }
2029
2262
  primitive() {
2030
2263
  throw new Error("Method not implemented.");
@@ -2043,648 +2276,558 @@ const we = class we {
2043
2276
  }
2044
2277
  tableOfSigns(e) {
2045
2278
  const t = this.power.clone().reduce(), i = this.polynom.tableOfSigns(e);
2046
- return t.isStrictlyNegative() && (i.signs = Se(i.signs, "z", "d")), t.denominator % 2 === 0 ? i.signs = Se(i.signs, "-", "h") : t.numerator % 2 === 0 && (i.signs = Se(i.signs, "-", "+")), { roots: i.roots, signs: i.signs };
2279
+ return t.isStrictlyNegative() && (i.signs = Re(i.signs, "z", "d")), t.denominator % 2 === 0 ? i.signs = Re(i.signs, "-", "h") : t.numerator % 2 === 0 && (i.signs = Re(i.signs, "-", "+")), { roots: i.roots, signs: i.signs };
2047
2280
  }
2048
2281
  get variables() {
2049
2282
  return this.polynom.variables;
2050
2283
  }
2051
2284
  get withPower() {
2052
- return h(this, Ee, 1), this;
2285
+ return h(this, Ne, 1), this;
2053
2286
  }
2054
2287
  get withRoot() {
2055
- return h(this, Ee, 0), this;
2288
+ return h(this, Ne, 0), this;
2056
2289
  }
2057
2290
  zero() {
2058
- return s(this, Ne).zero(), s(this, Te).one(), this;
2291
+ return s(this, Te).zero(), s(this, Ae).one(), this;
2059
2292
  }
2060
2293
  };
2061
- Ee = new WeakMap(), Ne = new WeakMap(), Te = new WeakMap(), Je = new WeakMap();
2062
- let ue = we;
2063
- var ht = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(ht || {}), _e, N, dt, ii, pt, si;
2064
- const me = class me {
2294
+ Ne = new WeakMap(), Te = new WeakMap(), Ae = new WeakMap(), et = new WeakMap();
2295
+ let ue = ve;
2296
+ var at = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(at || {}), D, $e, Zt, Ft;
2297
+ const He = class He {
2065
2298
  constructor(...e) {
2066
- p(this, pt);
2067
- p(this, _e, ht.POWER);
2068
- p(this, N, []);
2069
- return this.parse(...e), this;
2070
- }
2071
- parse(...e) {
2072
- return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
2073
- if (typeof t == "string") {
2074
- const i = t.split(")(").join(")*(").split("*");
2075
- s(this, N).push(...i.map((n) => new ue(n)));
2076
- } else t instanceof me ? s(this, N).push(...t.factors.map((i) => i.clone())) : s(this, N).push(new ue(t));
2077
- }), this);
2078
- }
2079
- clone() {
2080
- return new me(...s(this, N).map((e) => e.clone()));
2081
- }
2082
- get tex() {
2083
- const { num: e, den: t } = O(this, pt, si).call(this);
2084
- if (t.length === 0)
2085
- return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
2086
- const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
2087
- return `\\frac{ ${i} }{ ${n} }`;
2088
- }
2089
- get display() {
2090
- const { num: e, den: t } = O(this, pt, si).call(this);
2091
- if (t.length === 0)
2092
- return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
2093
- const i = e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join(""), n = t.length === 1 ? t[0].asSingle.display : t.map((r) => r.display).join("");
2094
- return `(${i})/(${n})`;
2095
- }
2096
- static gcd(...e) {
2097
- var i;
2098
- if (e.length === 0)
2099
- return new me().one();
2100
- if (e.length === 1)
2101
- return e[0];
2102
- if (e.length === 2)
2103
- return O(i = me, dt, ii).call(i, e[0], e[1]);
2104
- let t = e[0];
2105
- return e.shift(), e.forEach((n) => {
2106
- var r;
2107
- return t = O(r = me, dt, ii).call(r, t, n);
2108
- }), t;
2109
- }
2110
- add(...e) {
2111
- let t = [this, ...e];
2112
- const i = me.gcd(...t);
2113
- t = t.map((r) => r.divide(i).reduce());
2114
- const n = new q("0");
2115
- return t.forEach((r) => n.add(r.develop())), h(this, N, [
2116
- ...i.factors,
2117
- new ue(n)
2118
- ]), this;
2299
+ p(this, D);
2300
+ // Determine the letters in the linear system, usually ['x', 'y']
2301
+ p(this, $e);
2302
+ a(this, "parse", (...e) => (h(this, D, e.map((t) => new H(t))), s(this, Zt).call(this), this));
2303
+ a(this, "clone", () => new He().parse(...s(this, D).map((e) => e.clone())));
2304
+ a(this, "buildTex", (e, t) => {
2305
+ let i, n, r = [];
2306
+ const l = [];
2307
+ for (const d of e)
2308
+ r = r.concat(d.letters());
2309
+ r = [...new Set(r)], r.sort();
2310
+ for (let d = 0; d < e.length; d++) {
2311
+ const f = e[d];
2312
+ i = [];
2313
+ for (const g of r)
2314
+ n = f.left.monomByLetter(g), i.length === 0 ? i.push(n.isZero() ? "" : n.tex) : i.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
2315
+ if (i.push("="), i.push(f.right.tex), (t == null ? void 0 : t[d]) !== void 0) {
2316
+ i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
2317
+ for (const g of t[d])
2318
+ i.push(`\\ \\cdot\\ ${g.startsWith("-") ? "\\left(" + g + "\\right)" : g}`);
2319
+ }
2320
+ l.push(i.join("&"));
2321
+ }
2322
+ let c = 0;
2323
+ return t !== void 0 && t.length > 0 && (c = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(c)}}${l.join("\\\\ ")}\\end{array}\\right.`;
2324
+ });
2325
+ a(this, "mergeEquations", (e, t, i, n) => {
2326
+ const r = e.clone().multiply(new u(i)), l = t.clone().multiply(new u(n));
2327
+ return r.left.add(l.left), r.right.add(l.right), r;
2328
+ });
2329
+ // ------------------------------------------
2330
+ a(this, "reorder", () => {
2331
+ for (const e of s(this, D))
2332
+ e.reorder();
2333
+ return this;
2334
+ });
2335
+ a(this, "solveMatrix", () => {
2336
+ const [e, t] = this.matrix, i = e.map((n, r) => [...n, t[r]]);
2337
+ for (let n = 0; n < e.length; n++) {
2338
+ const r = i[n][n].clone();
2339
+ i[n] = i[n].map((l) => l.divide(r));
2340
+ for (let l = 0; l < e.length; l++) {
2341
+ if (l === n)
2342
+ continue;
2343
+ const c = i[l][n].clone().opposite();
2344
+ for (let d = 0; d < i[l].length; d++)
2345
+ i[l][d].add(i[n][d].clone().multiply(c));
2346
+ if (i[l].slice(0, i[l].length - 1).every((d) => d.isZero()))
2347
+ return i[l][i[l].length - 1].isZero() ? [new u().infinite()] : [];
2348
+ }
2349
+ }
2350
+ return i.map((n) => n[n.length - 1]);
2351
+ });
2352
+ p(this, Zt, () => (h(this, $e, s(this, D).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, $e).sort(), this));
2353
+ p(this, Ft, () => {
2354
+ const e = [], t = [];
2355
+ for (const i of s(this, D)) {
2356
+ const n = [], r = i.clone().reorder();
2357
+ for (const l of this.variables) {
2358
+ const c = r.left.monomByLetter(l);
2359
+ n.push(c.coefficient);
2360
+ }
2361
+ t.push(r.right.monoms[0].coefficient), e.push(n);
2362
+ }
2363
+ return [e, t];
2364
+ });
2365
+ return h(this, D, []), h(this, $e, []), e.length > 0 && this.parse(...e), this;
2119
2366
  }
2120
- get asPower() {
2121
- return h(this, _e, ht.POWER), this;
2367
+ static fromMatrix(e, t = "xyz") {
2368
+ const i = e[0].length;
2369
+ if (e.some((r) => r.length !== i))
2370
+ throw new Error("All rows must have the same number of columns");
2371
+ const n = t.split("").splice(0, i - 1);
2372
+ return new He(
2373
+ ...e.map((r) => {
2374
+ const l = new q(n.join(""), ...r);
2375
+ return new H(l, 0);
2376
+ })
2377
+ );
2122
2378
  }
2123
- get asRoot() {
2124
- return h(this, _e, ht.ROOT), this;
2379
+ add(e, t) {
2380
+ if (e instanceof He) {
2381
+ const i = e.equations.length;
2382
+ if (i !== s(this, D).length)
2383
+ throw new Error("The number of equations must be the same");
2384
+ for (let n = 0; n < i; n++)
2385
+ s(this, D)[n].add(e.equations[n]);
2386
+ } else {
2387
+ if (t === void 0 || t < 0 || t >= s(this, D).length)
2388
+ throw new Error("Index out of range");
2389
+ const i = new H(e);
2390
+ s(this, D)[t].add(i);
2391
+ }
2392
+ return this;
2125
2393
  }
2126
2394
  degree(e) {
2127
- return s(this, N).reduce((t, i) => t.add(i.degree(e)), new u("0"));
2128
- }
2129
- get denominator() {
2130
- return s(this, N).filter((e) => e.power.isNegative());
2395
+ return u.max(...s(this, D).map((t) => t.degree(e)));
2131
2396
  }
2132
- derivative() {
2133
- const e = [], t = s(this, N).length;
2134
- for (let n = 0; n < t; n++) {
2135
- const r = s(this, N).slice(), l = r.splice(n, 1)[0];
2136
- e.push(new me(...r).multiply(new me(...l.derivative())));
2137
- }
2138
- e.forEach((n) => n.reduce());
2139
- const i = e.shift();
2140
- return i !== void 0 && h(this, N, i.factors), this.add(...e);
2397
+ get display() {
2398
+ return this.tex + "as display";
2141
2399
  }
2142
- develop() {
2143
- const e = new q("1");
2144
- return s(this, N).forEach((t) => {
2145
- e.multiply(t.develop());
2146
- }), e;
2400
+ // ------------------------------------------
2401
+ get equations() {
2402
+ return s(this, D);
2147
2403
  }
2148
- divide(e) {
2149
- return h(this, N, s(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
2404
+ set equations(e) {
2405
+ h(this, D, e);
2150
2406
  }
2151
2407
  evaluate(e, t) {
2152
- return t ? s(this, N).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, N).reduce((i, n) => i.multiply(n.evaluate(e)), new u("1"));
2153
- }
2154
- get factors() {
2155
- return s(this, N);
2156
- }
2157
- set factors(e) {
2158
- h(this, N, e);
2159
- }
2160
- fromPolynom(e, t) {
2161
- return h(this, N, new q(e).factorize(t).map((i) => new ue(i))), this;
2162
- }
2163
- getFactors() {
2164
- return s(this, N);
2165
- }
2166
- getZeroes() {
2167
- const e = [].concat(...s(this, N).map((t) => t.polynom.getZeroes()));
2168
- return e.sort((t, i) => t.value - i.value), e.filter(
2169
- (t, i, n) => i === n.findIndex(
2170
- (r) => r.value === t.value
2171
- )
2172
- );
2408
+ throw new Error("Method not implemented.");
2173
2409
  }
2174
2410
  hasVariable(e) {
2175
- return s(this, N).some((t) => t.hasVariable(e));
2176
- }
2177
- inverse() {
2178
- return h(this, N, s(this, N).map((e) => e.inverse())), this;
2411
+ return s(this, $e).includes(e);
2179
2412
  }
2180
2413
  isEqual(e) {
2181
- const t = me.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
2182
- return i.isOne() && n.isOne();
2183
- }
2184
- isOne() {
2185
- return s(this, N).every((e) => e.isOne());
2186
- }
2187
- isZero() {
2188
- return s(this, N).every((e) => e.isZero());
2189
- }
2190
- multiply(...e) {
2191
- return e.forEach((t) => {
2192
- h(this, N, s(this, N).concat(t.clone().factors));
2193
- }), this;
2194
- }
2195
- get numerator() {
2196
- return s(this, N).filter((e) => e.power.isPositive());
2197
- }
2198
- one() {
2199
- return h(this, N, [new ue("1", "1")]), this;
2414
+ return this.equations.every((t, i) => t.isEqual(e.equations[i]));
2200
2415
  }
2201
- opposite() {
2202
- const e = s(this, N).findIndex((t) => t.display === "(-1)");
2203
- return e >= 0 ? s(this, N).splice(e, 1) : s(this, N).push(new ue("-1", "1")), this;
2416
+ get isSolvable() {
2417
+ return this.variables.length === s(this, D).length;
2204
2418
  }
2205
- pow(e) {
2206
- return h(this, N, s(this, N).map((t) => t.pow(e))), this;
2419
+ get matrix() {
2420
+ return s(this, Ft).call(this);
2207
2421
  }
2208
- primitive() {
2209
- throw new Error("Method not implemented.");
2422
+ multiply(e, t) {
2423
+ if (Array.isArray(e)) {
2424
+ if (e.length !== s(this, D).length)
2425
+ throw new Error("The number of values must be the same as the number of equations");
2426
+ for (let i = 0; i < e.length; i++)
2427
+ s(this, D)[i].multiply(e[i]);
2428
+ return this;
2429
+ }
2430
+ if (t === void 0 || t < 0 || t >= s(this, D).length)
2431
+ throw new Error("Index out of range");
2432
+ return s(this, D)[t].multiply(e), this;
2210
2433
  }
2211
2434
  reduce() {
2212
- const e = _t(this);
2213
- return h(this, N, Object.values(e).map((t) => {
2214
- const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
2215
- return new ue(i, n.reduce());
2216
- }).filter((t) => !t.power.isZero())), this;
2217
- }
2218
- root(e) {
2219
- return h(this, N, s(this, N).map((t) => t.root(e))), this;
2220
- }
2221
- sort() {
2222
- return h(this, N, s(this, N).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
2435
+ throw new Error("Method not implemented.");
2223
2436
  }
2224
- sqrt() {
2225
- return h(this, N, s(this, N).map((e) => e.sqrt())), this;
2437
+ solve() {
2438
+ return [];
2226
2439
  }
2227
- subtract(...e) {
2228
- return this.add(...e.map((t) => t.opposite()));
2440
+ subtract(e, t) {
2441
+ if (e instanceof He) {
2442
+ const i = e.equations.length;
2443
+ if (i !== s(this, D).length)
2444
+ throw new Error("The number of equations must be the same");
2445
+ for (let n = 0; n < i; n++)
2446
+ s(this, D)[n].subtract(e.equations[n]);
2447
+ } else {
2448
+ if (t === void 0 || t < 0 || t >= s(this, D).length)
2449
+ throw new Error("Index out of range");
2450
+ const i = new H(e);
2451
+ s(this, D)[t].subtract(i);
2452
+ }
2453
+ return this;
2229
2454
  }
2230
- tableOfSigns() {
2231
- const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new ue(n), ...n.tableOfSigns(e) }));
2232
- return { signs: t.map((n) => n.signs).reduce((n, r) => (n.length === 0 ? n = r : r.forEach((l, c) => {
2233
- switch (l) {
2234
- case "d":
2235
- n[c] = "d";
2236
- break;
2237
- case "z":
2238
- n[c] = n[c] === "d" ? "d" : "z";
2239
- break;
2240
- case "h":
2241
- n[c] = "h";
2242
- break;
2243
- case "-":
2244
- n[c] = n[c] === "h" ? "h" : n[c] === "-" ? "+" : "-";
2245
- break;
2246
- }
2247
- }), n), []), roots: e, factors: t };
2455
+ get tex() {
2456
+ const e = this.clone().reorder();
2457
+ return this.buildTex(e.equations);
2248
2458
  }
2249
2459
  get variables() {
2250
- return s(this, N).reduce((e, t) => e.concat(t.variables), []);
2460
+ return s(this, $e);
2251
2461
  }
2252
- zero() {
2253
- return h(this, N, [new ue("0", "1")]), this;
2462
+ set variables(e) {
2463
+ const t = typeof e == "string" ? e.split("") : [...e];
2464
+ t.sort(), h(this, $e, t);
2254
2465
  }
2255
2466
  };
2256
- _e = new WeakMap(), N = new WeakMap(), dt = new WeakSet(), ii = function(e, t) {
2257
- const i = _t(e), n = _t(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
2258
- const d = i[c].reduce((g, E) => g.add(E.power), new u("0")), f = n[c].reduce((g, E) => g.add(E.power), new u("0"));
2259
- return new ue(c, u.min(d, f));
2260
- });
2261
- return new me(...l);
2262
- }, pt = new WeakSet(), si = function() {
2263
- let e, t = [];
2264
- return s(this, _e) === ht.ROOT ? (e = this.numerator, t = this.denominator.map((i) => i.clone().inverse())) : e = s(this, N), e.length === 0 && (e = [new ue("1")]), { num: e, den: t };
2265
- }, p(me, dt);
2266
- let ti = me;
2267
- function _t(o) {
2268
- const e = new u().one(), t = o.factors.reduce((i, n) => {
2269
- if (n.polynom.degree().isZero())
2270
- return n.polynom.monoms.length > 0 && e.multiply(n.polynom.monoms[0].coefficient), i;
2271
- const r = n.polynom.display;
2272
- return Object.hasOwn(i, r) ? i[r].push(n) : i[r] = [n], i;
2273
- }, {});
2274
- return e.isOne() || (t[e.display] = [new ue(e.display, 1)]), t;
2275
- }
2276
- var A, k, se, Lt, et, Dt;
2277
- const xe = class xe {
2278
- constructor(e, t, i) {
2279
- // Left part of the equation
2280
- p(this, A);
2281
- // Right part of the equation
2282
- p(this, k);
2283
- // Signe of the equation
2284
- p(this, se);
2285
- // ------------------------------------------
2286
- a(this, "parse", (e) => {
2287
- const t = s(this, Lt).call(this, e);
2288
- if (t === !1)
2289
- throw new Error("The equation is not valid (no sign found)");
2290
- const i = e.split(t);
2291
- return this.create(new q(i[0]), new q(i[1]), s(this, et).call(this, t));
2292
- });
2293
- a(this, "create", (e, t, i) => (h(this, A, e), h(this, k, t), h(this, se, s(this, et).call(this, i ?? "=")), this));
2294
- a(this, "clone", () => new xe(s(this, A).clone(), s(this, k).clone(), s(this, se)));
2295
- /**
2296
- * Get the degree of the equation
2297
- * @param letter
2298
- */
2299
- a(this, "degree", (e) => u.max(s(this, A).degree(e), s(this, k).degree(e)));
2300
- /**
2301
- * divide an equation by a given value (transformed as a fraction)
2302
- *
2303
- * ```
2304
- * 8x+10=6x \vert 2
2305
- * 4x+5=3x
2306
- * ```
2307
- *
2308
- * |>Alternatively with $3x-4$ maybe it's working ?
2309
- * $$\frac{3x}{5}$$
2310
- *
2311
- * @param value
2312
- * @returns {Equation}
2313
- */
2314
- a(this, "divide", (e) => {
2315
- const t = new u(e);
2316
- return t.isZero() ? this : this.multiply(t.inverse());
2317
- });
2318
- /**
2319
- * Determine if the equation contains a variable.
2320
- * @param letter
2321
- */
2322
- a(this, "hasVariable", (e) => this.variables.includes(e));
2323
- a(this, "isLinearTo", (e) => {
2324
- const t = e.clone().moveLeft().simplify().left, i = this.clone().moveLeft().simplify().left;
2325
- return t.isEqual(i) || t.isOppositeAt(i);
2326
- });
2327
- /**
2328
- * Determine if the equation contains more than one letter/variable.
2329
- */
2330
- a(this, "isMultiVariable", () => s(this, A).isMultiVariable || s(this, k).isMultiVariable);
2331
- // -----------------------------------------------
2332
- // Equations helpers
2333
- a(this, "isEqualTo", (e) => {
2334
- const t = e.clone().moveLeft().left, i = this.clone().moveLeft().left;
2335
- return t.isEqual(i) || t.isOppositeAt(i);
2336
- });
2337
- /**
2338
- * Reorder the polynom to have only one letter on the left, the rest on the right.
2339
- * @param letter
2340
- */
2341
- a(this, "isolate", (e) => {
2342
- if (!this.degree(e).isOne() || this.isMultiVariable())
2343
- return !1;
2344
- let t;
2345
- s(this, A).subtract(s(this, k)), s(this, k).zero();
2346
- const i = [...s(this, A).monoms];
2347
- for (const r of i)
2348
- r.hasVariable(e) || (t = r.clone(), s(this, A).subtract(t), s(this, k).subtract(t));
2349
- if (s(this, A).length !== 1)
2350
- return !1;
2351
- const n = s(this, A).monoms[0].coefficient.clone();
2352
- return s(this, A).divide(n), s(this, k).divide(n), this;
2353
- });
2354
- // -----------------------------------------------
2355
- // Equations operations
2356
- // -----------------------------------------------
2357
- a(this, "letters", () => [.../* @__PURE__ */ new Set([...s(this, A).letters(), ...s(this, k).letters()])]);
2358
- // -----------------------------------------------
2359
- /**
2360
- * Reorder will move all monoms containing a letter on the left, all the other on the right.
2361
- */
2362
- a(this, "moveLeft", () => (s(this, A).subtract(s(this, k)), s(this, k).zero(), this));
2363
- /**
2364
- * Multiple an equation by a fraction value.
2365
- * @param value
2366
- */
2367
- a(this, "multiply", (e) => {
2368
- const t = new u(e);
2369
- return s(this, A).multiply(t), s(this, k).multiply(t), s(this, se) !== "=" && t.sign() === -1 && s(this, Dt).call(this), this;
2370
- });
2371
- a(this, "opposite", () => (h(this, A, s(this, A).opposite()), h(this, k, s(this, k).opposite()), this));
2372
- a(this, "reorder", (e) => (s(this, A).subtract(s(this, k)), s(this, k).zero(), s(this, A).reorder(), e ? this : (s(this, A).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
2373
- const i = t.clone();
2374
- s(this, A).subtract(i), s(this, k).subtract(i);
2375
- }), s(this, A).reorder(), s(this, k).reorder(), this)));
2376
- // ------------------------------------------
2377
- a(this, "replaceBy", (e, t) => (s(this, A).replaceBy(e, t), s(this, k).replaceBy(e, t), this));
2378
- /**
2379
- * Multiply by the lcm denominator and divide by the gcm numerators.
2380
- */
2381
- a(this, "simplify", () => (this.multiply(G.lcm(...s(this, A).getDenominators(), ...s(this, k).getDenominators())), this.divide(G.gcd(...s(this, A).getNumerators(), ...s(this, k).getNumerators())), this));
2382
- // -----------------------------------------------
2383
- a(this, "solve", () => new Et(this.clone()).solve());
2384
- a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
2385
- p(this, Lt, (e) => {
2386
- if (e.includes("geq"))
2387
- return e.includes("\\geq") ? "\\geq" : "geq";
2388
- if (e.includes("leq"))
2389
- return e.includes("\\leq") ? "\\leq" : "leq";
2390
- if (e.includes(">="))
2391
- return ">=";
2392
- if (e.includes("=>"))
2393
- return "=>";
2394
- if (e.includes(">"))
2395
- return ">";
2396
- if (e.includes("<="))
2397
- return "<=";
2398
- if (e.includes("=<"))
2399
- return "=<";
2400
- if (e.includes("<"))
2401
- return "<";
2402
- if (e.includes("="))
2403
- return "=";
2404
- throw new Error("The equation is not valid (no sign found)");
2405
- });
2406
- // -----------------------------------------------
2407
- // Equations solving algorithms
2408
- p(this, et, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
2409
- p(this, Dt, () => s(this, se) === "=" ? this : s(this, se).includes("<") ? (s(this, se).replace("<", ">"), this) : s(this, se).includes(">") ? (s(this, se).replace(">", "<"), this) : this);
2410
- if (h(this, A, new q().zero()), h(this, k, new q().zero()), h(this, se, "="), e !== void 0 && t === void 0) {
2411
- if (e instanceof xe)
2412
- return e.clone();
2413
- typeof e == "string" && this.parse(e);
2414
- } else e !== void 0 && t !== void 0 && (this.left = new q(e), this.right = new q(t));
2415
- return i !== void 0 && (this.sign = i), this;
2416
- }
2467
+ D = new WeakMap(), $e = new WeakMap(), Zt = new WeakMap(), Ft = new WeakMap();
2468
+ let ii = He;
2469
+ var Oe, pt, si;
2470
+ class es {
2417
2471
  /**
2418
- * Add a value to the equation
2419
- * if value is an equation, add the left part to the left part of the equation
2420
- * and the right part to the right part of the equation
2421
- * if value is a string, try to create an equation
2422
- * if it fails, create a polynom and add it to the left and right part of the equation
2423
- * @param value | Polynom | Monom | Fraction | string | monom
2472
+ *
2473
+ * @param {string} value (optional) Default polynom to parse on class creation
2424
2474
  */
2425
- add(e) {
2426
- if (e instanceof xe)
2427
- return s(this, A).add(e.left), s(this, k).add(e.right), this;
2428
- if (typeof e == "string" && !xe.isEquationString(e))
2429
- return this.add(new xe(e));
2430
- const t = new q(e);
2431
- return s(this, A).add(t), s(this, k).add(t), this;
2475
+ constructor(e) {
2476
+ p(this, pt);
2477
+ p(this, Oe);
2478
+ a(this, "parse", (e) => (h(this, Oe, new Qt(Fe.SET).parse(e).rpn), this));
2479
+ return h(this, Oe, []), e !== void 0 && this.parse(e), this;
2432
2480
  }
2433
- /**
2434
- * Create an Equation using two polynoms.
2435
- * Markdown *support* is cool
2436
- * @param values
2437
- * @param asNumeric
2438
- */
2439
- evaluate(e, t) {
2440
- const i = s(this, A).evaluate(e, t), n = s(this, k).evaluate(e, t);
2441
- return t ? i === n : i.isEqual(n);
2481
+ evaluate(e) {
2482
+ this.variables.forEach((i) => {
2483
+ Object.hasOwn(e, i) || (e[i] = !1);
2484
+ });
2485
+ const t = [];
2486
+ for (const i of s(this, Oe))
2487
+ if (console.log(i), i.tokenType === "variable")
2488
+ t.push(e[i.token]);
2489
+ else if (i.tokenType === "operation")
2490
+ if (i.token === "!")
2491
+ if (t.length >= 1) {
2492
+ const n = t.pop();
2493
+ t.push(!n);
2494
+ } else
2495
+ return !1;
2496
+ else {
2497
+ const n = t.pop(), r = t.pop();
2498
+ if (n !== void 0 && r !== void 0)
2499
+ switch (i.token) {
2500
+ case "&":
2501
+ t.push(n && r);
2502
+ break;
2503
+ case "|":
2504
+ t.push(n || r);
2505
+ break;
2506
+ case "-":
2507
+ return !1;
2508
+ }
2509
+ else
2510
+ return !1;
2511
+ }
2512
+ return t.length === 1 && t[0];
2442
2513
  }
2443
- isEqual(e) {
2444
- const t = new xe(e);
2445
- return t.left.isEqual(s(this, A)) && t.right.isEqual(s(this, k));
2514
+ get rpn() {
2515
+ return s(this, Oe);
2446
2516
  }
2447
- pow(e) {
2448
- return s(this, A).pow(e), s(this, k).pow(e), this;
2517
+ get tex() {
2518
+ const e = [];
2519
+ for (const t of s(this, Oe))
2520
+ if (t.tokenType === "variable")
2521
+ e.push(t);
2522
+ else
2523
+ switch (t.token) {
2524
+ case "&":
2525
+ if (e.length >= 2) {
2526
+ const i = e.pop(), n = e.pop();
2527
+ i && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${n.token} \\cap ${i.token}`, tokenType: "mix" }));
2528
+ }
2529
+ break;
2530
+ case "|":
2531
+ if (e.length >= 2) {
2532
+ const i = e.pop(), n = e.pop();
2533
+ i && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${n.token} \\cup ${i.token}`, tokenType: "mix" }));
2534
+ }
2535
+ break;
2536
+ case "-":
2537
+ if (e.length >= 2) {
2538
+ const i = e.pop(), n = e.pop();
2539
+ i && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${n.token} \\setminus ${i.token}`, tokenType: "mix" }));
2540
+ }
2541
+ break;
2542
+ case "!":
2543
+ if (e.length >= 1) {
2544
+ const i = e.pop();
2545
+ i && e.push({ token: `\\overline{ ${i.token} }`, tokenType: "variable" });
2546
+ }
2547
+ break;
2548
+ }
2549
+ return e[0].token;
2449
2550
  }
2450
- reduce() {
2451
- return this.moveLeft(), s(this, A).reduce(), this.simplify(), s(this, A).monoms[0].coefficient.isNegative() && this.multiply(-1), this;
2551
+ get variables() {
2552
+ return s(this, Oe).filter((e) => e.tokenType === "variable").map((e) => e.token);
2452
2553
  }
2453
- split() {
2454
- return [s(this, A).clone(), s(this, k).clone()];
2554
+ vennAB() {
2555
+ return O(this, pt, si).call(this, {
2556
+ A: ["A", "AB"],
2557
+ B: ["B", "AB"]
2558
+ }, ["A", "B", "AB", "E"]);
2455
2559
  }
2456
- subtract(e) {
2457
- if (e instanceof xe)
2458
- return s(this, A).subtract(e.left), s(this, k).subtract(e.right), this;
2459
- if (typeof e == "string" && !xe.isEquationString(e))
2460
- return this.subtract(new xe(e));
2461
- const t = new q(e);
2462
- return s(this, A).subtract(t), s(this, k).subtract(t), this;
2560
+ vennABC() {
2561
+ return O(this, pt, si).call(this, {
2562
+ A: ["A", "AB", "AC", "ABC"],
2563
+ B: ["B", "AB", "BC", "ABC"],
2564
+ C: ["C", "AC", "BC", "ABC"]
2565
+ }, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
2566
+ }
2567
+ }
2568
+ Oe = new WeakMap(), pt = new WeakSet(), si = function(e, t) {
2569
+ const i = [];
2570
+ let n;
2571
+ if (t === void 0) {
2572
+ n = /* @__PURE__ */ new Set();
2573
+ for (const r in e)
2574
+ n = /* @__PURE__ */ new Set([
2575
+ ...n,
2576
+ ...e[r] ?? []
2577
+ ]);
2578
+ } else
2579
+ n = new Set(t);
2580
+ for (const r of s(this, Oe))
2581
+ if (r.tokenType === "variable")
2582
+ e[r.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[r.token]));
2583
+ else
2584
+ switch (r.token) {
2585
+ case "&":
2586
+ if (i.length >= 2) {
2587
+ const l = i.pop(), c = i.pop();
2588
+ c && l && i.push(new Set([...c].filter((d) => l.has(d))));
2589
+ }
2590
+ break;
2591
+ case "|":
2592
+ if (i.length >= 2) {
2593
+ const l = i.pop(), c = i.pop();
2594
+ c && l && i.push(/* @__PURE__ */ new Set([...c, ...l]));
2595
+ }
2596
+ break;
2597
+ case "-":
2598
+ if (i.length >= 2) {
2599
+ const l = i.pop(), c = i.pop();
2600
+ c && l && i.push(new Set([...c].filter((d) => !l.has(d))));
2601
+ }
2602
+ break;
2603
+ case "!":
2604
+ if (i.length >= 1) {
2605
+ const l = i.pop();
2606
+ l && i.push(new Set([...n].filter((c) => !l.has(c))));
2607
+ }
2608
+ break;
2609
+ }
2610
+ return [...i[0]].sort();
2611
+ };
2612
+ var tt, N, mt, ri, gt, oi;
2613
+ const me = class me {
2614
+ constructor(...e) {
2615
+ p(this, gt);
2616
+ p(this, tt, at.POWER);
2617
+ p(this, N, []);
2618
+ return this.parse(...e), this;
2619
+ }
2620
+ parse(...e) {
2621
+ return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
2622
+ if (typeof t == "string") {
2623
+ const i = t.split(")(").join(")*(").split("*");
2624
+ s(this, N).push(...i.map((n) => new ue(n)));
2625
+ } else t instanceof me ? s(this, N).push(...t.factors.map((i) => i.clone())) : s(this, N).push(new ue(t));
2626
+ }), this);
2627
+ }
2628
+ clone() {
2629
+ return new me(...s(this, N).map((e) => e.clone()));
2630
+ }
2631
+ get tex() {
2632
+ const { num: e, den: t } = O(this, gt, oi).call(this);
2633
+ if (t.length === 0)
2634
+ return e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join("");
2635
+ const i = e.length === 1 ? e[0].asSingle.tex : e.map((r) => r.tex).join(""), n = t.length === 1 ? t[0].asSingle.tex : t.map((r) => r.tex).join("");
2636
+ return `\\frac{ ${i} }{ ${n} }`;
2637
+ }
2638
+ get display() {
2639
+ const { num: e, den: t } = O(this, gt, oi).call(this);
2640
+ if (t.length === 0)
2641
+ return e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join("");
2642
+ const i = e.length === 1 ? e[0].asSingle.display : e.map((r) => r.display).join(""), n = t.length === 1 ? t[0].asSingle.display : t.map((r) => r.display).join("");
2643
+ return `(${i})/(${n})`;
2463
2644
  }
2464
- static isEquationString(e) {
2465
- return e.includes("=") || e.includes("<") || e.includes(">") || e.includes("<=") || e.includes(">=");
2645
+ static gcd(...e) {
2646
+ var i;
2647
+ if (e.length === 0)
2648
+ return new me().one();
2649
+ if (e.length === 1)
2650
+ return e[0];
2651
+ if (e.length === 2)
2652
+ return O(i = me, mt, ri).call(i, e[0], e[1]);
2653
+ let t = e[0];
2654
+ return e.shift(), e.forEach((n) => {
2655
+ var r;
2656
+ return t = O(r = me, mt, ri).call(r, t, n);
2657
+ }), t;
2466
2658
  }
2467
- static makeSolutionsUnique(e, t) {
2468
- const i = [], n = e.filter((r) => i.includes(r.tex) ? !1 : (i.push(r.tex), !0));
2469
- return t === !0 && n.sort((r, l) => r.value - l.value), n;
2659
+ add(...e) {
2660
+ let t = [this, ...e];
2661
+ const i = me.gcd(...t);
2662
+ t = t.map((r) => r.divide(i).reduce());
2663
+ const n = new q("0");
2664
+ return t.forEach((r) => n.add(r.develop())), h(this, N, [
2665
+ ...i.factors,
2666
+ new ue(n)
2667
+ ]), this;
2470
2668
  }
2471
- get display() {
2472
- return `${s(this, A).display}${this.signAsTex}${s(this, k).display}`;
2669
+ get asPower() {
2670
+ return h(this, tt, at.POWER), this;
2473
2671
  }
2474
- // Getter and setter
2475
- get left() {
2476
- return s(this, A);
2672
+ get asRoot() {
2673
+ return h(this, tt, at.ROOT), this;
2477
2674
  }
2478
- set left(e) {
2479
- h(this, A, e);
2675
+ degree(e) {
2676
+ return s(this, N).reduce((t, i) => t.add(i.degree(e)), new u("0"));
2480
2677
  }
2481
- get numberOfVars() {
2482
- return this.variables.length;
2678
+ get denominator() {
2679
+ return s(this, N).filter((e) => e.power.isNegative());
2483
2680
  }
2484
- get right() {
2485
- return s(this, k);
2681
+ derivative() {
2682
+ const e = [], t = s(this, N).length;
2683
+ for (let n = 0; n < t; n++) {
2684
+ const r = s(this, N).slice(), l = r.splice(n, 1)[0];
2685
+ e.push(new me(...r).multiply(new me(...l.derivative())));
2686
+ }
2687
+ e.forEach((n) => n.reduce());
2688
+ const i = e.shift();
2689
+ return i !== void 0 && h(this, N, i.factors), this.add(...e);
2486
2690
  }
2487
- set right(e) {
2488
- h(this, k, e);
2691
+ develop() {
2692
+ const e = new q("1");
2693
+ return s(this, N).forEach((t) => {
2694
+ e.multiply(t.develop());
2695
+ }), e;
2489
2696
  }
2490
- // ------------------------------------------
2491
- get sign() {
2492
- return s(this, se);
2697
+ divide(e) {
2698
+ return h(this, N, s(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
2493
2699
  }
2494
- set sign(e) {
2495
- h(this, se, s(this, et).call(this, e));
2700
+ evaluate(e, t) {
2701
+ return t ? s(this, N).reduce((i, n) => i * n.evaluate(e, t), 1) : s(this, N).reduce((i, n) => i.multiply(n.evaluate(e)), new u("1"));
2496
2702
  }
2497
- get signAsTex() {
2498
- return s(this, se) === ">=" ? "\\geq" : s(this, se) === "<=" ? "\\leq" : s(this, se);
2703
+ get factors() {
2704
+ return s(this, N);
2499
2705
  }
2500
- get tex() {
2501
- return `${s(this, A).tex}${this.signAsTex}${s(this, k).tex}`;
2706
+ set factors(e) {
2707
+ h(this, N, e);
2502
2708
  }
2503
- get variables() {
2504
- return [...new Set(s(this, k).variables.concat(s(this, A).variables))];
2709
+ fromPolynom(e, t) {
2710
+ return h(this, N, new q(e).factorize(t).map((i) => new ue(i))), this;
2505
2711
  }
2506
- };
2507
- A = new WeakMap(), k = new WeakMap(), se = new WeakMap(), Lt = new WeakMap(), et = new WeakMap(), Dt = new WeakMap();
2508
- let H = xe;
2509
- var D, Ce, Vt, Zt;
2510
- const We = class We {
2511
- constructor(...e) {
2512
- p(this, D);
2513
- // Determine the letters in the linear system, usually ['x', 'y']
2514
- p(this, Ce);
2515
- a(this, "parse", (...e) => (h(this, D, e.map((t) => new H(t))), s(this, Vt).call(this), this));
2516
- a(this, "clone", () => new We().parse(...s(this, D).map((e) => e.clone())));
2517
- a(this, "buildTex", (e, t) => {
2518
- let i, n, r = [];
2519
- const l = [];
2520
- for (const d of e)
2521
- r = r.concat(d.letters());
2522
- r = [...new Set(r)], r.sort();
2523
- for (let d = 0; d < e.length; d++) {
2524
- const f = e[d];
2525
- i = [];
2526
- for (const g of r)
2527
- n = f.left.monomByLetter(g), i.length === 0 ? i.push(n.isZero() ? "" : n.tex) : i.push(n.isZero() ? "" : (n.coefficient.sign() === 1 ? "+" : "") + n.tex);
2528
- if (i.push("="), i.push(f.right.tex), (t == null ? void 0 : t[d]) !== void 0) {
2529
- i[i.length - 1] = i[i.length - 1] + " \\phantom{\\quad}";
2530
- for (const g of t[d])
2531
- i.push(`\\ \\cdot\\ ${g.startsWith("-") ? "\\left(" + g + "\\right)" : g}`);
2532
- }
2533
- l.push(i.join("&"));
2534
- }
2535
- let c = 0;
2536
- return t !== void 0 && t.length > 0 && (c = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(r.length)}cl ${"|l".repeat(c)}}${l.join("\\\\ ")}\\end{array}\\right.`;
2537
- });
2538
- a(this, "mergeEquations", (e, t, i, n) => {
2539
- const r = e.clone().multiply(new u(i)), l = t.clone().multiply(new u(n));
2540
- return r.left.add(l.left), r.right.add(l.right), r;
2541
- });
2542
- // ------------------------------------------
2543
- a(this, "reorder", () => {
2544
- for (const e of s(this, D))
2545
- e.reorder();
2546
- return this;
2547
- });
2548
- a(this, "solveMatrix", () => {
2549
- const [e, t] = this.matrix, i = e.map((n, r) => [...n, t[r]]);
2550
- for (let n = 0; n < e.length; n++) {
2551
- const r = i[n][n].clone();
2552
- i[n] = i[n].map((l) => l.divide(r));
2553
- for (let l = 0; l < e.length; l++) {
2554
- if (l === n)
2555
- continue;
2556
- const c = i[l][n].clone().opposite();
2557
- for (let d = 0; d < i[l].length; d++)
2558
- i[l][d].add(i[n][d].clone().multiply(c));
2559
- if (i[l].slice(0, i[l].length - 1).every((d) => d.isZero()))
2560
- return i[l][i[l].length - 1].isZero() ? [new u().infinite()] : [];
2561
- }
2562
- }
2563
- return i.map((n) => n[n.length - 1]);
2564
- });
2565
- p(this, Vt, () => (h(this, Ce, s(this, D).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), s(this, Ce).sort(), this));
2566
- p(this, Zt, () => {
2567
- const e = [], t = [];
2568
- for (const i of s(this, D)) {
2569
- const n = [], r = i.clone().reorder();
2570
- for (const l of this.variables) {
2571
- const c = r.left.monomByLetter(l);
2572
- n.push(c.coefficient);
2573
- }
2574
- t.push(r.right.monoms[0].coefficient), e.push(n);
2575
- }
2576
- return [e, t];
2577
- });
2578
- return h(this, D, []), h(this, Ce, []), e.length > 0 && this.parse(...e), this;
2712
+ getFactors() {
2713
+ return s(this, N);
2579
2714
  }
2580
- static fromMatrix(e, t = "xyz") {
2581
- const i = e[0].length;
2582
- if (e.some((r) => r.length !== i))
2583
- throw new Error("All rows must have the same number of columns");
2584
- const n = t.split("").splice(0, i - 1);
2585
- return new We(
2586
- ...e.map((r) => {
2587
- const l = new q(n.join(""), ...r);
2588
- return new H(l, 0);
2589
- })
2715
+ getZeroes() {
2716
+ const e = [].concat(...s(this, N).map((t) => t.polynom.getZeroes()));
2717
+ return e.sort((t, i) => t.value - i.value), e.filter(
2718
+ (t, i, n) => i === n.findIndex(
2719
+ (r) => r.value === t.value
2720
+ )
2590
2721
  );
2591
2722
  }
2592
- add(e, t) {
2593
- if (e instanceof We) {
2594
- const i = e.equations.length;
2595
- if (i !== s(this, D).length)
2596
- throw new Error("The number of equations must be the same");
2597
- for (let n = 0; n < i; n++)
2598
- s(this, D)[n].add(e.equations[n]);
2599
- } else {
2600
- if (t === void 0 || t < 0 || t >= s(this, D).length)
2601
- throw new Error("Index out of range");
2602
- const i = new H(e);
2603
- s(this, D)[t].add(i);
2604
- }
2605
- return this;
2723
+ hasVariable(e) {
2724
+ return s(this, N).some((t) => t.hasVariable(e));
2606
2725
  }
2607
- degree(e) {
2608
- return u.max(...s(this, D).map((t) => t.degree(e)));
2726
+ inverse() {
2727
+ return h(this, N, s(this, N).map((e) => e.inverse())), this;
2609
2728
  }
2610
- get display() {
2611
- return this.tex + "as display";
2729
+ isEqual(e) {
2730
+ const t = me.gcd(this, e), i = this.clone().divide(t).reduce(), n = e.clone().divide(t).reduce();
2731
+ return i.isOne() && n.isOne();
2612
2732
  }
2613
- // ------------------------------------------
2614
- get equations() {
2615
- return s(this, D);
2733
+ isOne() {
2734
+ return s(this, N).every((e) => e.isOne());
2616
2735
  }
2617
- set equations(e) {
2618
- h(this, D, e);
2736
+ isZero() {
2737
+ return s(this, N).every((e) => e.isZero());
2619
2738
  }
2620
- evaluate(e, t) {
2621
- throw new Error("Method not implemented.");
2739
+ multiply(...e) {
2740
+ return e.forEach((t) => {
2741
+ h(this, N, s(this, N).concat(t.clone().factors));
2742
+ }), this;
2622
2743
  }
2623
- hasVariable(e) {
2624
- return s(this, Ce).includes(e);
2744
+ get numerator() {
2745
+ return s(this, N).filter((e) => e.power.isPositive());
2625
2746
  }
2626
- isEqual(e) {
2627
- return this.equations.every((t, i) => t.isEqual(e.equations[i]));
2747
+ one() {
2748
+ return h(this, N, [new ue("1", "1")]), this;
2628
2749
  }
2629
- get isSolvable() {
2630
- return this.variables.length === s(this, D).length;
2750
+ opposite() {
2751
+ const e = s(this, N).findIndex((t) => t.display === "(-1)");
2752
+ return e >= 0 ? s(this, N).splice(e, 1) : s(this, N).push(new ue("-1", "1")), this;
2631
2753
  }
2632
- get matrix() {
2633
- return s(this, Zt).call(this);
2754
+ pow(e) {
2755
+ return h(this, N, s(this, N).map((t) => t.pow(e))), this;
2634
2756
  }
2635
- multiply(e, t) {
2636
- if (Array.isArray(e)) {
2637
- if (e.length !== s(this, D).length)
2638
- throw new Error("The number of values must be the same as the number of equations");
2639
- for (let i = 0; i < e.length; i++)
2640
- s(this, D)[i].multiply(e[i]);
2641
- return this;
2642
- }
2643
- if (t === void 0 || t < 0 || t >= s(this, D).length)
2644
- throw new Error("Index out of range");
2645
- return s(this, D)[t].multiply(e), this;
2757
+ primitive() {
2758
+ throw new Error("Method not implemented.");
2646
2759
  }
2647
2760
  reduce() {
2648
- throw new Error("Method not implemented.");
2761
+ const e = ei(this);
2762
+ return h(this, N, Object.values(e).map((t) => {
2763
+ const i = t[0].polynom, n = t.reduce((r, l) => r.add(l.power), new u("0"));
2764
+ return new ue(i, n.reduce());
2765
+ }).filter((t) => !t.power.isZero())), this;
2649
2766
  }
2650
- solve() {
2651
- return [];
2767
+ root(e) {
2768
+ return h(this, N, s(this, N).map((t) => t.root(e))), this;
2652
2769
  }
2653
- subtract(e, t) {
2654
- if (e instanceof We) {
2655
- const i = e.equations.length;
2656
- if (i !== s(this, D).length)
2657
- throw new Error("The number of equations must be the same");
2658
- for (let n = 0; n < i; n++)
2659
- s(this, D)[n].subtract(e.equations[n]);
2660
- } else {
2661
- if (t === void 0 || t < 0 || t >= s(this, D).length)
2662
- throw new Error("Index out of range");
2663
- const i = new H(e);
2664
- s(this, D)[t].subtract(i);
2665
- }
2666
- return this;
2770
+ sort() {
2771
+ return h(this, N, s(this, N).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
2772
+ }
2773
+ sqrt() {
2774
+ return h(this, N, s(this, N).map((e) => e.sqrt())), this;
2775
+ }
2776
+ subtract(...e) {
2777
+ return this.add(...e.map((t) => t.opposite()));
2667
2778
  }
2668
- get tex() {
2669
- const e = this.clone().reorder();
2670
- return this.buildTex(e.equations);
2779
+ tableOfSigns() {
2780
+ const e = this.getZeroes(), t = this.factors.map((n) => ({ factor: new ue(n), ...n.tableOfSigns(e) }));
2781
+ return { signs: t.map((n) => n.signs).reduce((n, r) => (n.length === 0 ? n = r : r.forEach((l, c) => {
2782
+ switch (l) {
2783
+ case "d":
2784
+ n[c] = "d";
2785
+ break;
2786
+ case "z":
2787
+ n[c] = n[c] === "d" ? "d" : "z";
2788
+ break;
2789
+ case "h":
2790
+ n[c] = "h";
2791
+ break;
2792
+ case "-":
2793
+ n[c] = n[c] === "h" ? "h" : n[c] === "-" ? "+" : "-";
2794
+ break;
2795
+ }
2796
+ }), n), []), roots: e, factors: t };
2671
2797
  }
2672
2798
  get variables() {
2673
- return s(this, Ce);
2799
+ return s(this, N).reduce((e, t) => e.concat(t.variables), []);
2674
2800
  }
2675
- set variables(e) {
2676
- const t = typeof e == "string" ? e.split("") : [...e];
2677
- t.sort(), h(this, Ce, t);
2801
+ zero() {
2802
+ return h(this, N, [new ue("0", "1")]), this;
2678
2803
  }
2679
2804
  };
2680
- D = new WeakMap(), Ce = new WeakMap(), Vt = new WeakMap(), Zt = new WeakMap();
2681
- let ni = We;
2682
- function _i(o, e) {
2805
+ tt = new WeakMap(), N = new WeakMap(), mt = new WeakSet(), ri = function(e, t) {
2806
+ const i = ei(e), n = ei(t), l = Object.keys(i).filter((c) => Object.hasOwn(n, c)).map((c) => {
2807
+ const d = i[c].reduce((g, E) => g.add(E.power), new u("0")), f = n[c].reduce((g, E) => g.add(E.power), new u("0"));
2808
+ return new ue(c, u.min(d, f));
2809
+ });
2810
+ return new me(...l);
2811
+ }, gt = new WeakSet(), oi = function() {
2812
+ let e, t = [];
2813
+ return s(this, tt) === at.ROOT ? (e = this.numerator, t = this.denominator.map((i) => i.clone().inverse())) : e = s(this, N), e.length === 0 && (e = [new ue("1")]), { num: e, den: t };
2814
+ }, p(me, mt);
2815
+ let ni = me;
2816
+ function ei(o) {
2817
+ const e = new u().one(), t = o.factors.reduce((i, n) => {
2818
+ if (n.polynom.degree().isZero())
2819
+ return n.polynom.monoms.length > 0 && e.multiply(n.polynom.monoms[0].coefficient), i;
2820
+ const r = n.polynom.display;
2821
+ return Object.hasOwn(i, r) ? i[r].push(n) : i[r] = [n], i;
2822
+ }, {});
2823
+ return e.isOne() || (t[e.display] = [new ue(e.display, 1)]), t;
2824
+ }
2825
+ function ts(o, e) {
2683
2826
  return o.dimension === e.dimension && o.array.every(
2684
2827
  (t, i) => e.array[i].isEqual(t)
2685
2828
  );
2686
2829
  }
2687
- function es(o, e) {
2830
+ function is(o, e) {
2688
2831
  if (o.dimension !== e.dimension)
2689
2832
  return !1;
2690
2833
  const t = e.array[0].value / o.array[0].value;
@@ -2692,13 +2835,13 @@ function es(o, e) {
2692
2835
  (i, n) => e.array[n].value === i.value * t
2693
2836
  );
2694
2837
  }
2695
- function ts(o, e) {
2838
+ function ss(o, e) {
2696
2839
  return o.dimension !== e.dimension ? new u().invalid() : o.array.reduce(
2697
2840
  (t, i, n) => t.add(i.clone().multiply(e.array[n])),
2698
2841
  new u(0)
2699
2842
  );
2700
2843
  }
2701
- function is(...o) {
2844
+ function ns(...o) {
2702
2845
  return o.some((e) => e.dimension !== o[0].dimension) ? new u().invalid() : o[0].dimension === 2 && o.length !== 2 ? new u().invalid() : o[0].dimension === 3 && o.length !== 3 ? new u().invalid() : o[0].dimension === 2 ? o[0].array[0].clone().multiply(o[1].array[1]).subtract(o[0].array[1].clone().multiply(o[1].array[0])) : o[0].array[0].clone().multiply(
2703
2846
  o[1].array[1].clone().multiply(o[2].array[2]).subtract(o[1].array[2].clone().multiply(o[2].array[1]))
2704
2847
  ).subtract(
@@ -2707,11 +2850,11 @@ function is(...o) {
2707
2850
  )
2708
2851
  ).add(o[0].array[2].clone().multiply(o[1].array[0].clone().multiply(o[2].array[1]).subtract(o[1].array[1].clone().multiply(o[2].array[0]))));
2709
2852
  }
2710
- var F, Le;
2711
- const Be = class Be {
2853
+ var F, De;
2854
+ const Se = class Se {
2712
2855
  constructor(...e) {
2713
2856
  p(this, F, []);
2714
- p(this, Le, !1);
2857
+ p(this, De, !1);
2715
2858
  a(this, "zero", () => (s(this, F).forEach((e) => e.zero()), this));
2716
2859
  a(this, "one", () => (this.zero(), this.x.one(), this));
2717
2860
  a(this, "opposite", () => (s(this, F).forEach((e) => e.opposite()), this));
@@ -2721,15 +2864,15 @@ const Be = class Be {
2721
2864
  const e = this.norm;
2722
2865
  return e === 0 ? this : this.divideByScalar(e);
2723
2866
  });
2724
- a(this, "dot", (e) => ts(this, e));
2867
+ a(this, "dot", (e) => ss(this, e));
2725
2868
  a(this, "normal", () => {
2726
2869
  if (this.dimension >= 3)
2727
2870
  throw new Error("Normal vector can only be determined in 2D");
2728
2871
  const e = this.x.clone().opposite(), t = this.y.clone();
2729
2872
  return s(this, F)[0] = t, s(this, F)[1] = e, this;
2730
2873
  });
2731
- a(this, "isEqual", (e) => _i(this, e));
2732
- a(this, "isColinearTo", (e) => es(this, e));
2874
+ a(this, "isEqual", (e) => ts(this, e));
2875
+ a(this, "isColinearTo", (e) => is(this, e));
2733
2876
  a(this, "isNormalTo", (e) => this.dot(e).isZero());
2734
2877
  a(this, "multiplyByScalar", (e) => {
2735
2878
  const t = new u(e);
@@ -2786,10 +2929,10 @@ const Be = class Be {
2786
2929
  s(this, F)[2] = new u(e);
2787
2930
  }
2788
2931
  get asPoint() {
2789
- return s(this, Le);
2932
+ return s(this, De);
2790
2933
  }
2791
2934
  set asPoint(e) {
2792
- h(this, Le, e);
2935
+ h(this, De, e);
2793
2936
  }
2794
2937
  get normSquare() {
2795
2938
  return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new u(0));
@@ -2798,10 +2941,10 @@ const Be = class Be {
2798
2941
  return Math.sqrt(this.normSquare.value);
2799
2942
  }
2800
2943
  get tex() {
2801
- return s(this, Le) ? `\\left(${this.array.map((e) => e.tex).join(";")}\\right)` : `\\begin{pmatrix} ${this.array.map((e) => e.tex).join(" \\\\ ")} \\end{pmatrix}`;
2944
+ return s(this, De) ? `\\left(${this.array.map((e) => e.tex).join(";")}\\right)` : `\\begin{pmatrix} ${this.array.map((e) => e.tex).join(" \\\\ ")} \\end{pmatrix}`;
2802
2945
  }
2803
2946
  get display() {
2804
- return s(this, Le) ? `(${this.array.map((e) => e.display).join(";")})` : `((${this.array.map((e) => e.display).join(",")}))`;
2947
+ return s(this, De) ? `(${this.array.map((e) => e.display).join(";")})` : `((${this.array.map((e) => e.display).join(",")}))`;
2805
2948
  }
2806
2949
  setDimension(e = 2) {
2807
2950
  if (e < 2)
@@ -2829,13 +2972,13 @@ const Be = class Be {
2829
2972
  return `((${e.join(",")}))`;
2830
2973
  }
2831
2974
  defineAsPoint(e) {
2832
- return h(this, Le, e !== !1), this;
2975
+ return h(this, De, e !== !1), this;
2833
2976
  }
2834
2977
  parse(...e) {
2835
2978
  if (e.length === 0)
2836
2979
  throw new Error("Invalid value");
2837
2980
  if (e.length === 1) {
2838
- if (e[0] instanceof Be)
2981
+ if (e[0] instanceof Se)
2839
2982
  return e[0].clone();
2840
2983
  if (typeof e[0] == "string")
2841
2984
  return this.fromString(e[0]);
@@ -2843,7 +2986,7 @@ const Be = class Be {
2843
2986
  }
2844
2987
  if (e.length === 2) {
2845
2988
  const [t, i] = e;
2846
- if (t instanceof Be && i instanceof Be) {
2989
+ if (t instanceof Se && i instanceof Se) {
2847
2990
  if (t.dimension !== i.dimension)
2848
2991
  throw new Error("Vectors must have the same dimension");
2849
2992
  return h(this, F, i.array.map((n, r) => n.clone().subtract(t.array[r]))), this;
@@ -2852,7 +2995,7 @@ const Be = class Be {
2852
2995
  return h(this, F, e.map((t) => new u(t))), this;
2853
2996
  }
2854
2997
  clone() {
2855
- const e = new Be();
2998
+ const e = new Se();
2856
2999
  return e.array = this.copy(), e.asPoint = this.asPoint, e;
2857
3000
  }
2858
3001
  copy() {
@@ -2871,7 +3014,7 @@ const Be = class Be {
2871
3014
  cross(e) {
2872
3015
  if (this.dimension !== 3 || e.dimension !== 3)
2873
3016
  throw new Error("Cross product can only be determined in 3D");
2874
- return new Be(
3017
+ return new Se(
2875
3018
  this.y.clone().multiply(e.z).subtract(this.z.clone().multiply(e.y)),
2876
3019
  this.z.clone().multiply(e.x).subtract(this.x.clone().multiply(e.z)),
2877
3020
  this.x.clone().multiply(e.y).subtract(this.y.clone().multiply(e.x))
@@ -2884,7 +3027,7 @@ const Be = class Be {
2884
3027
  return this.array.every((e, t) => t === 0 ? e.isOne() : e.isZero());
2885
3028
  }
2886
3029
  distanceTo(e) {
2887
- const t = new Be(this, e);
3030
+ const t = new Se(this, e);
2888
3031
  return {
2889
3032
  value: t.norm,
2890
3033
  fraction: t.normSquare,
@@ -2892,9 +3035,10 @@ const Be = class Be {
2892
3035
  };
2893
3036
  }
2894
3037
  };
2895
- F = new WeakMap(), Le = new WeakMap();
2896
- let x = Be;
2897
- function Ai(o = 0.5) {
3038
+ F = new WeakMap(), De = new WeakMap();
3039
+ let x = Se;
3040
+ var we = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(we || {}), hi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(hi || {});
3041
+ function qi(o = 0.5) {
2898
3042
  return Math.random() < o;
2899
3043
  }
2900
3044
  function fe(o, e, t) {
@@ -2912,19 +3056,19 @@ function fe(o, e, t) {
2912
3056
  return i;
2913
3057
  }
2914
3058
  function Y(o, e) {
2915
- return e === !1 ? Ai() ? fe(1, o) : -fe(1, o) : fe(-o, o);
3059
+ return e === !1 ? qi() ? fe(1, o) : -fe(1, o) : fe(-o, o);
2916
3060
  }
2917
- function ss(o) {
3061
+ function rs(o) {
2918
3062
  let e = G.primes();
2919
- return o !== void 0 && (e = e.filter((t) => t < o)), fi(e);
3063
+ return o !== void 0 && (e = e.filter((t) => t < o)), pi(e);
2920
3064
  }
2921
- function ns(o, e) {
2922
- return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : Oi(o).slice(0, e);
3065
+ function os(o, e) {
3066
+ return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : ki(o).slice(0, e);
2923
3067
  }
2924
- function fi(o) {
3068
+ function pi(o) {
2925
3069
  return o.length === 0 ? null : o[fe(0, o.length - 1)];
2926
3070
  }
2927
- function Oi(o) {
3071
+ function ki(o) {
2928
3072
  const e = Object.values(o);
2929
3073
  for (let t = e.length - 1; t > 0; t--) {
2930
3074
  const i = Math.floor(Math.random() * (t + 1)), n = e[t];
@@ -2958,23 +3102,23 @@ class B extends x {
2958
3102
  return e.array = this.copy(), e.asPoint = !0, e;
2959
3103
  }
2960
3104
  }
2961
- var qi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(qi || {}), $e, S, z, U, ne, Q, Ie, ve;
2962
- const Ve = class Ve {
3105
+ var Ie, S, z, U, ne, Q, Pe, be;
3106
+ const Ze = class Ze {
2963
3107
  /**
2964
3108
  * Value can be a mix of:
2965
3109
  *
2966
3110
  * @param values
2967
3111
  */
2968
3112
  constructor(...e) {
2969
- p(this, $e);
3113
+ p(this, Ie);
2970
3114
  // ax + by + c = 0
2971
3115
  p(this, S);
2972
3116
  p(this, z);
2973
3117
  p(this, U);
2974
3118
  p(this, ne);
2975
3119
  p(this, Q);
2976
- p(this, Ie);
2977
- p(this, ve, "canonical");
3120
+ p(this, Pe);
3121
+ p(this, be, "canonical");
2978
3122
  a(this, "randomPoint", (e) => {
2979
3123
  const t = s(this, Q).clone().multiplyByScalar(Y(e === void 0 || e <= 1 ? 3 : e, !1)).add(s(this, ne));
2980
3124
  return t.asPoint = !0, t;
@@ -2998,7 +3142,7 @@ const Ve = class Ve {
2998
3142
  if (e.length === 0)
2999
3143
  return this;
3000
3144
  if (e.length === 1) {
3001
- if (e[0] instanceof Ve)
3145
+ if (e[0] instanceof Ze)
3002
3146
  return this.fromCoefficient(e[0].a, e[0].b, e[0].c);
3003
3147
  if (e[0] instanceof H)
3004
3148
  return this.fromEquation(e[0]);
@@ -3019,22 +3163,12 @@ const Ve = class Ve {
3019
3163
  }
3020
3164
  if (e.length === 3) {
3021
3165
  if (e[0] instanceof x && e[1] instanceof x) {
3022
- if (e[2] === "perpendicular")
3166
+ if (e[2] === we.Perpendicular)
3023
3167
  return this.fromPointAndNormal(e[0], e[1]);
3024
- if (e[2] === "parallel")
3168
+ if (e[2] === we.Parallel)
3025
3169
  return this.fromPointAndDirection(e[0], e[1]);
3026
3170
  }
3027
- return e[0] instanceof x && e[1] instanceof Ve ? e[2] === "parallel" || e[2] === null ? this.fromPointAndLine(
3028
- e[0],
3029
- e[1],
3030
- "parallel"
3031
- /* Parallel */
3032
- ) : this.fromPointAndLine(
3033
- e[0],
3034
- e[1],
3035
- "perpendicular"
3036
- /* Perpendicular */
3037
- ) : this.fromCoefficient(
3171
+ return e[0] instanceof x && e[1] instanceof Ze ? e[2] === we.Parallel || e[2] === null ? this.fromPointAndLine(e[0], e[1], we.Parallel) : this.fromPointAndLine(e[0], e[1], we.Perpendicular) : this.fromCoefficient(
3038
3172
  e[0],
3039
3173
  e[1],
3040
3174
  e[2]
@@ -3055,19 +3189,19 @@ const Ve = class Ve {
3055
3189
  e.left.monomByDegree(0).coefficient
3056
3190
  );
3057
3191
  });
3058
- a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this, Q, new x(s(this, z).clone(), s(this, S).clone().opposite())), h(this, ne, new x(new u().zero(), s(this, U).clone())), h(this, Ie, s(this, Q).clone().normal()), this));
3192
+ a(this, "fromCoefficient", (e, t, i) => (h(this, S, new u(e)), h(this, z, new u(t)), h(this, U, new u(i)), h(this, Q, new x(s(this, z).clone(), s(this, S).clone().opposite())), h(this, ne, new x(new u().zero(), s(this, U).clone())), h(this, Pe, s(this, Q).clone().normal()), this));
3059
3193
  a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
3060
3194
  t.y,
3061
3195
  t.x.clone().opposite(),
3062
3196
  e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
3063
- ), h(this, ne, e.clone()), h(this, Q, t.clone()), h(this, Ie, s(this, Q).clone().normal()), this));
3197
+ ), h(this, ne, e.clone()), h(this, Q, t.clone()), h(this, Pe, s(this, Q).clone().normal()), this));
3064
3198
  a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
3065
3199
  t.x,
3066
3200
  t.y,
3067
3201
  e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
3068
3202
  ));
3069
- a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = "parallel"), i === "parallel" ? this.fromPointAndNormal(e, t.normal) : i === "perpendicular" ? this.fromPointAndNormal(e, t.director) : this));
3070
- a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this, Q, s(this, Q).clone()), h(this, ne, s(this, ne).clone()), h(this, Ie, s(this, Ie).clone()), this));
3203
+ a(this, "fromPointAndLine", (e, t, i) => (i === void 0 && (i = we.Parallel), i === we.Parallel ? this.fromPointAndNormal(e, t.normal) : i === we.Perpendicular ? this.fromPointAndNormal(e, t.director) : this));
3204
+ a(this, "clone", () => (h(this, S, s(this, S).clone()), h(this, z, s(this, z).clone()), h(this, U, s(this, U).clone()), h(this, Q, s(this, Q).clone()), h(this, ne, s(this, ne).clone()), h(this, Pe, s(this, Pe).clone()), this));
3071
3205
  // ------------------------------------------
3072
3206
  // Mathematical operations
3073
3207
  // ------------------------------------------
@@ -3105,7 +3239,7 @@ const Ve = class Ve {
3105
3239
  const t = this.getEquation().isolate("x"), i = new u(e);
3106
3240
  return t instanceof H ? t.right.evaluate({ y: i }) : new u().invalid();
3107
3241
  });
3108
- return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this, ne, new x()), h(this, Q, new x()), h(this, Ie, new x()), h(this, $e, !0), e.length > 0 && this.parse(...e), this;
3242
+ return h(this, S, new u().zero()), h(this, z, new u().zero()), h(this, U, new u().zero()), h(this, ne, new x()), h(this, Q, new x()), h(this, Pe, new x()), h(this, Ie, !0), e.length > 0 && this.parse(...e), this;
3109
3243
  }
3110
3244
  get a() {
3111
3245
  return s(this, S);
@@ -3140,12 +3274,12 @@ const Ve = class Ve {
3140
3274
  h(this, Q, e);
3141
3275
  }
3142
3276
  get n() {
3143
- return s(this, Ie);
3277
+ return s(this, Pe);
3144
3278
  }
3145
3279
  // ------------------------------------------
3146
3280
  getEquation() {
3147
3281
  const e = new H(new q().parse("xy", s(this, S), s(this, z), s(this, U)), new q("0"));
3148
- return s(this, $e) ? e.simplify() : e;
3282
+ return s(this, Ie) ? e.simplify() : e;
3149
3283
  }
3150
3284
  // get system(): { x: Equation, y: Equation } {
3151
3285
  // const e1 = new Equation(
@@ -3161,23 +3295,23 @@ const Ve = class Ve {
3161
3295
  // return { x: e1, y: e2 }
3162
3296
  // }
3163
3297
  get canonical() {
3164
- return h(this, ve, "canonical"), this;
3298
+ return h(this, be, "canonical"), this;
3165
3299
  }
3166
3300
  get equation() {
3167
- return h(this, ve, "equation"), this;
3301
+ return h(this, be, "equation"), this;
3168
3302
  }
3169
3303
  get mxh() {
3170
- return h(this, ve, "mxh"), this;
3304
+ return h(this, be, "mxh"), this;
3171
3305
  }
3172
3306
  get parametric() {
3173
- return h(this, ve, "parametric"), this;
3307
+ return h(this, be, "parametric"), this;
3174
3308
  }
3175
3309
  get system() {
3176
- return h(this, ve, "system"), this;
3310
+ return h(this, be, "system"), this;
3177
3311
  }
3178
3312
  get tex() {
3179
- const e = s(this, ve);
3180
- switch (h(this, ve, "canonical"), e) {
3313
+ const e = s(this, be);
3314
+ switch (h(this, be, "canonical"), e) {
3181
3315
  case "equation":
3182
3316
  return this.getEquation().reorder().tex;
3183
3317
  case "mxh":
@@ -3185,7 +3319,7 @@ const Ve = class Ve {
3185
3319
  case "parametric":
3186
3320
  case "system": {
3187
3321
  const t = s(this, Q).clone();
3188
- return s(this, $e) && t.simplify(), e === "parametric" ? `${x.asTex("x", "y")} = ${x.asTex(s(this, ne).x.tex, s(this, ne).y.tex)} + k\\cdot ${x.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
3322
+ return s(this, Ie) && t.simplify(), e === "parametric" ? `${x.asTex("x", "y")} = ${x.asTex(s(this, ne).x.tex, s(this, ne).y.tex)} + k\\cdot ${x.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}
3189
3323
  x &= ${new q(s(this, ne).x).add(new M(s(this, Q).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
3190
3324
  y &= ${new q(s(this, ne).y).add(new M(s(this, Q).y).multiply(new M("k"))).reorder("k", !0).tex}
3191
3325
  \\end{aligned}\\right.`;
@@ -3197,21 +3331,21 @@ const Ve = class Ve {
3197
3331
  }
3198
3332
  }
3199
3333
  get reduceBeforeDisplay() {
3200
- return s(this, $e);
3334
+ return s(this, Ie);
3201
3335
  }
3202
3336
  set reduceBeforeDisplay(e) {
3203
- h(this, $e, e);
3337
+ h(this, Ie, e);
3204
3338
  }
3205
3339
  get display() {
3206
- const e = s(this, ve);
3207
- switch (h(this, ve, "canonical"), e) {
3340
+ const e = s(this, be);
3341
+ switch (h(this, be, "canonical"), e) {
3208
3342
  case "equation":
3209
3343
  return this.getEquation().reorder().display;
3210
3344
  case "mxh":
3211
3345
  return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new q().parse("x", this.slope, this.height).display;
3212
3346
  case "parametric": {
3213
3347
  const t = s(this, Q).clone();
3214
- return s(this, $e) && t.simplify(), `((x,y))=((${s(this, ne).x.display},${s(this, ne).y.display}))+k((${t.x.display},${t.y.display}))`;
3348
+ return s(this, Ie) && t.simplify(), `((x,y))=((${s(this, ne).x.display},${s(this, ne).y.display}))+k((${t.x.display},${t.y.display}))`;
3215
3349
  }
3216
3350
  default: {
3217
3351
  const t = this.getEquation();
@@ -3255,7 +3389,7 @@ const Ve = class Ve {
3255
3389
  }
3256
3390
  hitSegment(e, t) {
3257
3391
  const i = this.intersection(
3258
- new Ve().fromPoints(e, t)
3392
+ new Ze().fromPoints(e, t)
3259
3393
  );
3260
3394
  return i.hasIntersection ? i.point.x.value >= Math.min(e.x.value, t.x.value) && i.point.x.value <= Math.max(e.x.value, t.x.value) && i.point.y.value >= Math.min(e.y.value, t.y.value) && i.point.y.value <= Math.max(e.y.value, t.y.value) : !1;
3261
3395
  }
@@ -3268,16 +3402,16 @@ const Ve = class Ve {
3268
3402
  return s(this, S).isZero() || (s(this, S).isOne() ? t = "x" : s(this, S).clone().opposite().isOne() ? t = "-x" : t = s(this, S).value.toFixed(e) + "x"), s(this, z).isZero() || (s(this, z).isPositive() && (t += "+"), t += s(this, z).value.toFixed(e) + "y"), s(this, U).isZero() || (s(this, U).isPositive() && (t += "+"), t += s(this, U).value.toFixed(e)), t + "=0";
3269
3403
  }
3270
3404
  };
3271
- $e = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(), ne = new WeakMap(), Q = new WeakMap(), Ie = new WeakMap(), ve = new WeakMap(), // A line is defined as the canonical form
3272
- a(Ve, "PERPENDICULAR", "perpendicular"), a(Ve, "PARALLEL", "parallel");
3273
- let R = Ve;
3274
- var re, j, Ae, Ft, jt, Ut, oe, ki, xt, Mi, Ci, $i, ri;
3275
- const Gt = class Gt {
3405
+ Ie = new WeakMap(), S = new WeakMap(), z = new WeakMap(), U = new WeakMap(), ne = new WeakMap(), Q = new WeakMap(), Pe = new WeakMap(), be = new WeakMap(), // A line is defined as the canonical form
3406
+ a(Ze, "PERPENDICULAR", we.Perpendicular), a(Ze, "PARALLEL", we.Parallel);
3407
+ let R = Ze;
3408
+ var re, j, qe, jt, Ut, Gt, oe, Mi, Et, Ci, $i, Ii, ai;
3409
+ const Wt = class Wt {
3276
3410
  constructor(...e) {
3277
3411
  p(this, oe);
3278
3412
  p(this, re);
3279
3413
  p(this, j);
3280
- p(this, Ae);
3414
+ p(this, qe);
3281
3415
  /**
3282
3416
  * Get the relative position between circle and line. It corresponds to the number of intersection.
3283
3417
  * @param {Line} L
@@ -3291,15 +3425,15 @@ const Gt = class Gt {
3291
3425
  });
3292
3426
  a(this, "lineIntersection", (e) => {
3293
3427
  const t = [];
3294
- if (s(this, Ae) === void 0)
3428
+ if (s(this, qe) === void 0)
3295
3429
  return [];
3296
- const i = s(this, Ae).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
3430
+ const i = s(this, qe).clone(), n = e.getEquation().clone().isolate("x"), r = e.getEquation().clone().isolate("y");
3297
3431
  return n instanceof H && r instanceof H && (i.replaceBy("y", r.right).simplify(), i.solve()), t;
3298
3432
  });
3299
- a(this, "tangents", (e) => e instanceof u ? s(this, Ut).call(this, e) : this.isPointOnCircle(e) ? s(this, Ft).call(this, e) : s(this, re) !== void 0 && s(this, re).distanceTo(e).value > this.radius.value ? s(this, jt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
3433
+ a(this, "tangents", (e) => e instanceof u ? s(this, Gt).call(this, e) : this.isPointOnCircle(e) ? s(this, jt).call(this, e) : s(this, re) !== void 0 && s(this, re).distanceTo(e).value > this.radius.value ? s(this, Ut).call(this, e) : (console.log("No tangents as the point is inside !"), []));
3300
3434
  a(this, "isPointOnCircle", (e) => {
3301
3435
  var t;
3302
- return ((t = s(this, Ae)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
3436
+ return ((t = s(this, qe)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
3303
3437
  });
3304
3438
  a(this, "getPointsOnCircle", (e) => {
3305
3439
  const t = G.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), i = [];
@@ -3313,11 +3447,11 @@ const Gt = class Gt {
3313
3447
  );
3314
3448
  }), i;
3315
3449
  });
3316
- p(this, Ft, (e) => {
3450
+ p(this, jt, (e) => {
3317
3451
  const t = new x(this.center, e);
3318
- return [new R(e, t, qi.Perpendicular)];
3452
+ return [new R(e, t, we.Perpendicular)];
3319
3453
  });
3320
- p(this, jt, (e) => {
3454
+ p(this, Ut, (e) => {
3321
3455
  const t = this.center.x.clone().subtract(e.x), i = this.center.y.clone().subtract(e.y), n = new q("x"), r = new q("x^2+1");
3322
3456
  return n.multiply(t).subtract(i).pow(2), r.multiply(this.squareRadius), new H(n, r).solve().map((d) => {
3323
3457
  let f;
@@ -3325,7 +3459,7 @@ const Gt = class Gt {
3325
3459
  return d.exact instanceof u ? (f = e.x.clone().opposite().multiply(d.exact).add(e.y), g.right.multiply(d.exact).add(f)) : (f = e.x.clone().opposite().multiply(d.value).add(e.y), g.right.multiply(d.value).add(f)), new R(g);
3326
3460
  });
3327
3461
  });
3328
- p(this, Ut, (e) => {
3462
+ p(this, Gt, (e) => {
3329
3463
  const t = e.numerator, i = -e.denominator, n = this.center.x.clone(), r = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), c = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).add(l.clone().sqrt()), d = n.clone().multiply(t).opposite().subtract(r.clone().multiply(i)).subtract(l.clone().sqrt());
3330
3464
  return [new R(t, i, c), new R(t, i, d)];
3331
3465
  });
@@ -3338,91 +3472,319 @@ const Gt = class Gt {
3338
3472
  return s(this, j) ?? new u(0);
3339
3473
  }
3340
3474
  get cartesian() {
3341
- if (s(this, Ae) === void 0)
3475
+ if (s(this, qe) === void 0)
3342
3476
  throw new Error("Cartesian equation not defined");
3343
- return s(this, Ae);
3477
+ return s(this, qe);
3478
+ }
3479
+ get radius() {
3480
+ return s(this, j) === void 0 ? { tex: "", display: "", value: 0 } : s(this, j).isSquare() ? {
3481
+ tex: s(this, j).clone().sqrt().tex,
3482
+ display: s(this, j).clone().sqrt().display,
3483
+ value: s(this, j).clone().sqrt().value
3484
+ } : {
3485
+ tex: `\\sqrt{${s(this, j).tex}}`,
3486
+ display: `sqrt(${s(this, j).display})`,
3487
+ value: s(this, j).clone().sqrt().value
3488
+ };
3489
+ }
3490
+ get tex() {
3491
+ let e, t;
3492
+ return this.center.x.isZero() ? e = "x^2" : e = `\\left(x${this.center.x.isNegative() ? "+" : "-"}${this.center.x.clone().abs().tex}\\right)^2`, this.center.y.isZero() ? t = "y^2" : t = `\\left(y${this.center.y.isNegative() ? "+" : "-"}${this.center.y.clone().abs().tex}\\right)^2`, `${e}+${t}=${this.squareRadius.tex}`;
3493
+ }
3494
+ get developed() {
3495
+ return this.cartesian.tex;
3496
+ }
3497
+ get display() {
3498
+ let e, t;
3499
+ return this.center.x.isZero() ? e = "x^2" : e = `(x${this.center.x.isNegative() ? "+" : "-"}${this.center.x.clone().abs().tex})^2`, this.center.y.isZero() ? t = "y^2" : t = `(y${this.center.y.isNegative() ? "+" : "-"}${this.center.y.clone().abs().tex})^2`, `${e}+${t}=${this.squareRadius.display}`;
3500
+ }
3501
+ clone() {
3502
+ return new Wt(
3503
+ this.center.clone(),
3504
+ this.squareRadius.clone(),
3505
+ !0
3506
+ );
3507
+ }
3508
+ setRadius(e, t) {
3509
+ return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), O(this, oe, Et).call(this), this;
3510
+ }
3511
+ parse(...e) {
3512
+ return O(this, oe, Mi).call(this), typeof e[0] == "string" ? O(this, oe, ai).call(this, new H(e[0])) : e[0] instanceof H ? O(this, oe, ai).call(this, e[0]) : e[0] instanceof Wt ? O(this, oe, Ci).call(this, e[0]) : e[0] instanceof B && e.length > 1 && (e[1] instanceof B ? e[2] instanceof B || O(this, oe, Ii).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && O(this, oe, $i).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), O(this, oe, Et).call(this), this;
3513
+ }
3514
+ // private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
3515
+ // const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
3516
+ // mAC = T.remarquables.mediators.AC.clone()
3517
+ // this.parse(mAB.intersection(mAC).point, A)
3518
+ // return this
3519
+ // }
3520
+ };
3521
+ re = new WeakMap(), j = new WeakMap(), qe = new WeakMap(), jt = new WeakMap(), Ut = new WeakMap(), Gt = new WeakMap(), oe = new WeakSet(), Mi = function() {
3522
+ return h(this, re, void 0), h(this, j, void 0), h(this, qe, void 0), this;
3523
+ }, Et = function() {
3524
+ h(this, qe, new H(
3525
+ new q(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
3526
+ new q(this.squareRadius.display)
3527
+ ).moveLeft());
3528
+ }, Ci = function(e) {
3529
+ return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()), O(this, oe, Et).call(this), this;
3530
+ }, $i = function(e, t, i) {
3531
+ return h(this, re, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
3532
+ }, Ii = function(e, t) {
3533
+ return h(this, re, e.clone()), h(this, j, new x(s(this, re), t).normSquare), this;
3534
+ }, ai = function(e) {
3535
+ if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
3536
+ const t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y");
3537
+ let n, r, l;
3538
+ t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, re, new B(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this, j, l.coefficient.clone().opposite().add(s(this, re).x.clone().pow(2)).add(s(this, re).y.clone().pow(2)))) : (h(this, re, void 0), h(this, j, void 0));
3539
+ }
3540
+ return this;
3541
+ };
3542
+ let Tt = Wt;
3543
+ var L, W;
3544
+ const lt = class lt {
3545
+ constructor(e, t) {
3546
+ // ax + by + c = 0
3547
+ p(this, L, new B());
3548
+ p(this, W, new x());
3549
+ a(this, "clone", () => (h(this, W, s(this, W).clone()), h(this, L, s(this, L).clone()), this));
3550
+ // ------------------------------------------
3551
+ // Mathematical operations
3552
+ // ------------------------------------------
3553
+ a(this, "isOnLine", (e) => !1);
3554
+ a(this, "isParallelTo", (e) => {
3555
+ throw new Error("Method not implemented.");
3556
+ });
3557
+ a(this, "isSameAs", (e) => {
3558
+ throw new Error("Method not implemented.");
3559
+ });
3560
+ a(this, "isPerpendicularTo", (e) => {
3561
+ throw new Error("Method not implemented.");
3562
+ });
3563
+ a(this, "isVertical", () => {
3564
+ throw new Error("Method not implemented.");
3565
+ });
3566
+ a(this, "simplify", () => {
3567
+ throw new Error("Method not implemented.");
3568
+ });
3569
+ a(this, "intersection", (e) => {
3570
+ throw new Error("Method not implemented.");
3571
+ });
3572
+ // getValueAtX = (value: Fraction | number): Fraction => {
3573
+ // const equ = this.equation.clone().isolate('y'),
3574
+ // F = new Fraction(value)
3575
+ // if (equ instanceof Equation) {
3576
+ // return equ.right.evaluate({ x: F }) as Fraction
3577
+ // }
3578
+ // return new Fraction().invalid()
3579
+ // }
3580
+ // getValueAtY = (value: Fraction | number): Fraction => {
3581
+ // const equ = this.equation.clone().isolate('x'),
3582
+ // F = new Fraction(value)
3583
+ // if (equ instanceof Equation) {
3584
+ // return equ.right.evaluate({ y: F }) as Fraction
3585
+ // }
3586
+ // return new Fraction().invalid()
3587
+ // }
3588
+ a(this, "randomPoint", (e = 5) => {
3589
+ const t = s(this, L).clone(), i = new u(Y(e, !1));
3590
+ return new B(
3591
+ t.x.clone().add(s(this, W).x.clone().multiply(i)),
3592
+ t.y.clone().add(s(this, W).y.clone().multiply(i)),
3593
+ t.z.clone().add(s(this, W).z.clone().multiply(i))
3594
+ );
3595
+ });
3596
+ return h(this, L, e.clone()), h(this, W, t.asPoint ? new x(e, t) : t.clone()), this;
3597
+ }
3598
+ get OA() {
3599
+ return s(this, L);
3600
+ }
3601
+ set OA(e) {
3602
+ h(this, L, e);
3603
+ }
3604
+ get point() {
3605
+ return s(this, L).clone();
3606
+ }
3607
+ get d() {
3608
+ return s(this, W);
3609
+ }
3610
+ set d(e) {
3611
+ h(this, W, e);
3612
+ }
3613
+ get tex() {
3614
+ return {
3615
+ parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${x.asTex(s(this, W).x.tex, s(this, W).y.tex, s(this, W).z.tex)}`,
3616
+ system: `\\left\\{\\begin{aligned}
3617
+ x &= ${new q(s(this, L).x).add(new M(s(this, W).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
3618
+ y &= ${new q(s(this, L).y).add(new M(s(this, W).y).multiply(new M("k"))).reorder("k", !0).tex}\\\\
3619
+ z &= ${new q(s(this, L).z).add(new M(s(this, W).z).multiply(new M("k"))).reorder("k", !0).tex}
3620
+ \\end{aligned}\\right.`,
3621
+ cartesian: `\\frac{ ${new q("x", 1, s(this, L).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new q("y", 1, s(this, L).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new q("z", 1, s(this, L).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
3622
+ };
3623
+ }
3624
+ get display() {
3625
+ const e = s(this, L).x.display, t = s(this, L).y.display, i = s(this, L).z.display, n = this.direction.simplify(), r = n.x.display, l = n.y.display, c = n.z.display;
3626
+ return {
3627
+ parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(s(this, L).x.display, s(this, L).y.display, s(this, L).z.display)} + k\\cdot ${x.asDisplay(s(this, W).x.display, s(this, W).y.display, s(this, W).z.display)}`,
3628
+ system: "",
3629
+ cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${i})/${c}`
3630
+ };
3631
+ }
3632
+ get direction() {
3633
+ return s(this, W).clone();
3634
+ }
3635
+ distanceTo(e) {
3636
+ const t = new x(s(this, L), e), i = this.direction, n = this.direction.normSquare, r = t.cross(i).normSquare, l = r.clone().divide(n), c = l.clone().sqrt();
3637
+ return console.log("CROSS", t.cross(i).display), {
3638
+ value: Math.sqrt(l.value),
3639
+ fraction: l.clone().sqrt(),
3640
+ tex: c.isExact() ? c.tex : `\\sqrt{${l.tex}}`
3641
+ };
3642
+ }
3643
+ hitSegment(e, t) {
3644
+ const i = this.intersection(
3645
+ new lt(e, t)
3646
+ );
3647
+ return i.hasIntersection ? i.point.x.value >= Math.min(e.x.value, t.x.value) && i.point.x.value <= Math.max(e.x.value, t.x.value) && i.point.y.value >= Math.min(e.y.value, t.y.value) && i.point.y.value <= Math.max(e.y.value, t.y.value) && i.point.z.value >= Math.min(e.z.value, t.z.value) && i.point.z.value <= Math.max(e.z.value, t.z.value) : !1;
3648
+ }
3649
+ };
3650
+ L = new WeakMap(), W = new WeakMap(), // A line is defined as the canonical form
3651
+ a(lt, "PERPENDICULAR", hi.Perpendicular), a(lt, "PARALLEL", hi.Parallel);
3652
+ let At = lt;
3653
+ var ke;
3654
+ class hs {
3655
+ constructor(...e) {
3656
+ p(this, ke, []);
3657
+ return h(this, ke, e), this;
3658
+ }
3659
+ get values() {
3660
+ return s(this, ke);
3661
+ }
3662
+ get array() {
3663
+ return s(this, ke).map((e) => e.array);
3664
+ }
3665
+ get dimension() {
3666
+ return [s(this, ke).length, s(this, ke)[0].dimension];
3667
+ }
3668
+ isSquare() {
3669
+ return s(this, ke).length === s(this, ke)[0].dimension;
3670
+ }
3671
+ determinant() {
3672
+ if (!this.isSquare())
3673
+ throw new Error("Matrix is not square");
3674
+ return ns(...this.values);
3675
+ }
3676
+ }
3677
+ ke = new WeakMap();
3678
+ var Me, Ge;
3679
+ const gi = class gi {
3680
+ constructor(e) {
3681
+ p(this, Me, new x(0, 0, 1));
3682
+ p(this, Ge, new B(0, 0, 0));
3683
+ return e && this.parse(e), this;
3684
+ }
3685
+ get normal() {
3686
+ return s(this, Me);
3687
+ }
3688
+ set normal(e) {
3689
+ h(this, Me, e), s(this, Me).asPoint = !1;
3690
+ }
3691
+ get point() {
3692
+ return s(this, Ge);
3693
+ }
3694
+ set point(e) {
3695
+ h(this, Ge, e), s(this, Ge).asPoint = !0;
3696
+ }
3697
+ get a() {
3698
+ return s(this, Me).x;
3699
+ }
3700
+ get b() {
3701
+ return s(this, Me).y;
3702
+ }
3703
+ get c() {
3704
+ return s(this, Me).z;
3344
3705
  }
3345
- get radius() {
3346
- return s(this, j) === void 0 ? { tex: "", display: "", value: 0 } : s(this, j).isSquare() ? {
3347
- tex: s(this, j).clone().sqrt().tex,
3348
- display: s(this, j).clone().sqrt().display,
3349
- value: s(this, j).clone().sqrt().value
3350
- } : {
3351
- tex: `\\sqrt{${s(this, j).tex}}`,
3352
- display: `sqrt(${s(this, j).display})`,
3353
- value: s(this, j).clone().sqrt().value
3354
- };
3706
+ get d() {
3707
+ return s(this, Me).dot(s(this, Ge)).opposite();
3355
3708
  }
3356
3709
  get tex() {
3357
- let e, t;
3358
- return this.center.x.isZero() ? e = "x^2" : e = `\\left(x${this.center.x.isNegative() ? "+" : "-"}${this.center.x.clone().abs().tex}\\right)^2`, this.center.y.isZero() ? t = "y^2" : t = `\\left(y${this.center.y.isNegative() ? "+" : "-"}${this.center.y.clone().abs().tex}\\right)^2`, `${e}+${t}=${this.squareRadius.tex}`;
3710
+ return new H(
3711
+ new q("xyz", this.a, this.b, this.c, this.d),
3712
+ new q(0)
3713
+ ).reduce().tex;
3359
3714
  }
3360
- get developed() {
3361
- return this.cartesian.tex;
3715
+ parse(e) {
3716
+ var t, i, n;
3717
+ if (e.point && e.normal) {
3718
+ this.point = e.point, this.normal = e.normal;
3719
+ return;
3720
+ }
3721
+ if (e.point && ((t = e.directions) == null ? void 0 : t.length) === 2) {
3722
+ this.point = e.point;
3723
+ const [r, l] = e.directions;
3724
+ this.normal = r.cross(l);
3725
+ return;
3726
+ }
3727
+ if (e.equation) {
3728
+ const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient, d = r.monomByLetter("z").coefficient, f = r.monomByDegree(0).coefficient;
3729
+ this.normal = new x(l, c, d), l.isNotZero() ? this.point = new B(f.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new B(0, f.clone().divide(c).opposite(), 0) : this.point = new B(0, 0, f.clone().divide(d).opposite());
3730
+ return;
3731
+ }
3732
+ if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof x)) {
3733
+ const r = e.points[0], l = e.points[1], c = e.points[2], d = new x(r, l), f = new x(r, c);
3734
+ this.normal = d.cross(f), this.point = r;
3735
+ return;
3736
+ }
3737
+ if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
3738
+ const [r, l, c, d] = e.coefficients;
3739
+ this.normal = new x(r, l, c), this.point = new B(0, 0, -d);
3740
+ return;
3741
+ }
3362
3742
  }
3363
- get display() {
3364
- let e, t;
3365
- return this.center.x.isZero() ? e = "x^2" : e = `(x${this.center.x.isNegative() ? "+" : "-"}${this.center.x.clone().abs().tex})^2`, this.center.y.isZero() ? t = "y^2" : t = `(y${this.center.y.isNegative() ? "+" : "-"}${this.center.y.clone().abs().tex})^2`, `${e}+${t}=${this.squareRadius.display}`;
3743
+ angle(e, t, i) {
3744
+ if (e instanceof gi)
3745
+ return this.normal.angle(e.normal, t, i);
3746
+ let n;
3747
+ if (e instanceof x) {
3748
+ if (e.dimension !== 3)
3749
+ throw new Error("Vector is not 3D");
3750
+ n = e;
3751
+ } else
3752
+ n = e.direction;
3753
+ return (i ? Math.PI / 2 : 90) - this.normal.angle(n, !0, i);
3366
3754
  }
3367
- clone() {
3368
- return new Gt(
3369
- this.center.clone(),
3370
- this.squareRadius.clone(),
3371
- !0
3372
- );
3755
+ distanceTo(e) {
3756
+ return this.normal.dot(e).add(this.d).abs().value / this.normal.norm;
3373
3757
  }
3374
- setRadius(e, t) {
3375
- return t ? h(this, j, new u(e)) : h(this, j, new u(e).pow(2)), O(this, oe, xt).call(this), this;
3758
+ intersectWithLine(e) {
3759
+ const { point: t, direction: i } = e, n = this.normal.dot(t).add(this.d).divide(this.normal.dot(i).opposite());
3760
+ return t.clone().add(i.clone().multiplyByScalar(n));
3376
3761
  }
3377
- parse(...e) {
3378
- return O(this, oe, ki).call(this), typeof e[0] == "string" ? O(this, oe, ri).call(this, new H(e[0])) : e[0] instanceof H ? O(this, oe, ri).call(this, e[0]) : e[0] instanceof Gt ? O(this, oe, Mi).call(this, e[0]) : e[0] instanceof B && e.length > 1 && (e[1] instanceof B ? e[2] instanceof B || O(this, oe, $i).call(this, e[0], e[1]) : (e[1] instanceof u || typeof e[1] == "number") && O(this, oe, Ci).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), O(this, oe, xt).call(this), this;
3762
+ intersectWithPlane(e) {
3763
+ throw this.normal.cross(e.normal), new B(0, 0, 0), new Error("Intersection with plane not yet implemented !");
3379
3764
  }
3380
- // private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
3381
- // const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
3382
- // mAC = T.remarquables.mediators.AC.clone()
3383
- // this.parse(mAB.intersection(mAC).point, A)
3384
- // return this
3385
- // }
3386
- };
3387
- re = new WeakMap(), j = new WeakMap(), Ae = new WeakMap(), Ft = new WeakMap(), jt = new WeakMap(), Ut = new WeakMap(), oe = new WeakSet(), ki = function() {
3388
- return h(this, re, void 0), h(this, j, void 0), h(this, Ae, void 0), this;
3389
- }, xt = function() {
3390
- h(this, Ae, new H(
3391
- new q(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`),
3392
- new q(this.squareRadius.display)
3393
- ).moveLeft());
3394
- }, Mi = function(e) {
3395
- return h(this, re, e.center.clone()), h(this, j, e.squareRadius.clone()), O(this, oe, xt).call(this), this;
3396
- }, Ci = function(e, t, i) {
3397
- return h(this, re, e.clone()), i ? h(this, j, new u(t)) : h(this, j, new u(t).pow(2)), this;
3398
- }, $i = function(e, t) {
3399
- return h(this, re, e.clone()), h(this, j, new x(s(this, re), t).normSquare), this;
3400
- }, ri = function(e) {
3401
- if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
3402
- const t = e.left.monomByDegree(2, "x"), i = e.left.monomByDegree(2, "y");
3403
- let n, r, l;
3404
- t.coefficient.isEqual(i.coefficient) ? (e.divide(t.coefficient), n = e.left.monomByDegree(1, "x"), r = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, re, new B(n.coefficient.clone().divide(2).opposite(), r.coefficient.clone().divide(2).opposite())), h(this, j, l.coefficient.clone().opposite().add(s(this, re).x.clone().pow(2)).add(s(this, re).y.clone().pow(2)))) : (h(this, re, void 0), h(this, j, void 0));
3765
+ isPointOnPlane(e) {
3766
+ return this.normal.dot(e).add(this.d).isZero();
3405
3767
  }
3406
- return this;
3407
3768
  };
3408
- let Nt = Gt;
3409
- var X, K, J, tt, Oe, mt, Wt, gt, Pe, Ht, it;
3410
- const Xt = class Xt {
3769
+ Me = new WeakMap(), Ge = new WeakMap();
3770
+ let li = gi;
3771
+ var X, K, J, it, Ce, yt, Ht, wt, Be, Xt, st;
3772
+ const Yt = class Yt {
3411
3773
  constructor(...e) {
3412
3774
  p(this, X, new B());
3413
3775
  p(this, K, new B());
3414
3776
  p(this, J, new B());
3415
- p(this, tt, {
3777
+ p(this, it, {
3416
3778
  AB: new R(),
3417
3779
  AC: new R(),
3418
3780
  BC: new R()
3419
3781
  });
3420
- p(this, Oe, {
3782
+ p(this, Ce, {
3421
3783
  AB: new B(),
3422
3784
  AC: new B(),
3423
3785
  BC: new B()
3424
3786
  });
3425
- p(this, mt, null);
3787
+ p(this, yt, null);
3426
3788
  // ------------------------------------------
3427
3789
  // Creation / parsing functions
3428
3790
  // ------------------------------------------
@@ -3450,7 +3812,7 @@ const Xt = class Xt {
3450
3812
  );
3451
3813
  if (e.every((t) => t instanceof R)) {
3452
3814
  const t = e[0].clone(), i = e[1].clone(), n = e[2].clone();
3453
- h(this, tt, { AB: t, BC: i, AC: n });
3815
+ h(this, it, { AB: t, BC: i, AC: n });
3454
3816
  let r = t.intersection(i);
3455
3817
  if (r.hasIntersection)
3456
3818
  h(this, K, r.point.clone());
@@ -3464,19 +3826,19 @@ const Xt = class Xt {
3464
3826
  h(this, X, r.point.clone());
3465
3827
  else
3466
3828
  throw new Error("Lines do not intersect !");
3467
- } else e.every((t) => t instanceof B) && (h(this, X, e[0].clone()), h(this, K, e[1].clone()), h(this, J, e[2].clone()), h(this, tt, {
3829
+ } else e.every((t) => t instanceof B) && (h(this, X, e[0].clone()), h(this, K, e[1].clone()), h(this, J, e[2].clone()), h(this, it, {
3468
3830
  AB: new R(s(this, X), s(this, K)),
3469
3831
  BC: new R(s(this, K), s(this, J)),
3470
3832
  AC: new R(s(this, X), s(this, J))
3471
3833
  }));
3472
- } else if (e.length === 1 && e[0] instanceof Xt)
3834
+ } else if (e.length === 1 && e[0] instanceof Yt)
3473
3835
  return e[0].clone();
3474
- return s(this, Wt).call(this), this;
3836
+ return s(this, Ht).call(this), this;
3475
3837
  });
3476
3838
  /**
3477
3839
  * Clone the Triangle class
3478
3840
  */
3479
- a(this, "clone", () => new Xt(
3841
+ a(this, "clone", () => new Yt(
3480
3842
  s(this, X).clone(),
3481
3843
  s(this, K).clone(),
3482
3844
  s(this, J).clone()
@@ -3487,18 +3849,18 @@ const Xt = class Xt {
3487
3849
  /**
3488
3850
  * Generate the Line object for the three segments of the triangle
3489
3851
  */
3490
- p(this, Wt, () => {
3491
- s(this, X).asPoint = !0, s(this, K).asPoint = !0, s(this, J).asPoint = !0, h(this, Oe, {
3852
+ p(this, Ht, () => {
3853
+ s(this, X).asPoint = !0, s(this, K).asPoint = !0, s(this, J).asPoint = !0, h(this, Ce, {
3492
3854
  AB: new B().middleOf(s(this, X), s(this, K)),
3493
3855
  AC: new B().middleOf(s(this, X), s(this, J)),
3494
3856
  BC: new B().middleOf(s(this, K), s(this, J))
3495
- }), h(this, mt, s(this, Ht).call(this));
3857
+ }), h(this, yt, s(this, Xt).call(this));
3496
3858
  });
3497
3859
  /**
3498
3860
  * Get the Vector2D class for the given name
3499
3861
  * @param ptName
3500
3862
  */
3501
- p(this, gt, (e) => {
3863
+ p(this, wt, (e) => {
3502
3864
  switch (e.toUpperCase()) {
3503
3865
  case "A":
3504
3866
  return s(this, X);
@@ -3514,27 +3876,27 @@ const Xt = class Xt {
3514
3876
  * @param ptName1
3515
3877
  * @param ptName2
3516
3878
  */
3517
- p(this, Pe, (e, t) => new x(
3518
- s(this, gt).call(this, e),
3519
- s(this, gt).call(this, t)
3879
+ p(this, Be, (e, t) => new x(
3880
+ s(this, wt).call(this, e),
3881
+ s(this, wt).call(this, t)
3520
3882
  ));
3521
- p(this, Ht, () => {
3883
+ p(this, Xt, () => {
3522
3884
  const e = {
3523
- A: new R().fromPoints(s(this, X), s(this, Oe).BC),
3524
- B: new R().fromPoints(s(this, K), s(this, Oe).AC),
3525
- C: new R().fromPoints(s(this, J), s(this, Oe).AB),
3885
+ A: new R().fromPoints(s(this, X), s(this, Ce).BC),
3886
+ B: new R().fromPoints(s(this, K), s(this, Ce).AC),
3887
+ C: new R().fromPoints(s(this, J), s(this, Ce).AB),
3526
3888
  intersection: null
3527
3889
  }, t = {
3528
- AB: new R().fromPointAndNormal(s(this, Oe).AB, new x(s(this, X), s(this, K)).normal()),
3529
- AC: new R().fromPointAndNormal(s(this, Oe).AC, new x(s(this, X), s(this, J)).normal()),
3530
- BC: new R().fromPointAndNormal(s(this, Oe).BC, new x(s(this, K), s(this, J)).normal()),
3890
+ AB: new R().fromPointAndNormal(s(this, Ce).AB, new x(s(this, X), s(this, K)).normal()),
3891
+ AC: new R().fromPointAndNormal(s(this, Ce).AC, new x(s(this, X), s(this, J)).normal()),
3892
+ BC: new R().fromPointAndNormal(s(this, Ce).BC, new x(s(this, K), s(this, J)).normal()),
3531
3893
  intersection: null
3532
3894
  }, i = {
3533
3895
  A: new R().fromPointAndNormal(s(this, X), new x(s(this, K), s(this, J)).normal()),
3534
3896
  B: new R().fromPointAndNormal(s(this, K), new x(s(this, X), s(this, J)).normal()),
3535
3897
  C: new R().fromPointAndNormal(s(this, J), new x(s(this, X), s(this, K)).normal()),
3536
3898
  intersection: null
3537
- }, n = s(this, it).call(this, "A"), r = s(this, it).call(this, "B"), l = s(this, it).call(this, "C"), c = {
3899
+ }, n = s(this, st).call(this, "A"), r = s(this, st).call(this, "B"), l = s(this, st).call(this, "C"), c = {
3538
3900
  A: n.internal,
3539
3901
  B: r.internal,
3540
3902
  C: r.internal,
@@ -3549,297 +3911,69 @@ const Xt = class Xt {
3549
3911
  mediators: t,
3550
3912
  heights: i,
3551
3913
  bisectors: c,
3552
- externalBisectors: d
3553
- };
3554
- return f.medians.intersection = f.medians.A.intersection(f.medians.B).point, f.mediators.intersection = f.mediators.AB.intersection(f.mediators.BC).point, f.heights.intersection = f.heights.A.intersection(f.heights.B).point, f.bisectors.intersection = f.bisectors.A.intersection(f.bisectors.B).point, f;
3555
- });
3556
- p(this, it, (e) => {
3557
- const t = this.lines;
3558
- let i, n;
3559
- if (e === "A" ? (i = t.AB, n = t.AC) : e === "B" ? (i = t.AB, n = t.BC) : e === "C" && (i = t.BC, n = t.AC), i === void 0 || n === void 0)
3560
- throw new Error(`The point ${e} does not exist`);
3561
- const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), d = n.getEquation().multiply(r), f = new R(c.clone().subtract(d).simplify()), g = new R(d.clone().subtract(c).simplify());
3562
- return e === "A" ? f.hitSegment(this.B, this.C) ? { internal: f, external: g } : { internal: g, external: f } : e === "B" ? f.hitSegment(this.A, this.C) ? { internal: f, external: g } : { internal: g, external: f } : e === "C" ? f.hitSegment(this.B, this.A) ? { internal: f, external: g } : { internal: g, external: f } : { internal: f, external: g };
3563
- });
3564
- return e.length > 0 && this.parse(...e), this;
3565
- }
3566
- // ------------------------------------------
3567
- // Getter and setters
3568
- // ------------------------------------------
3569
- get A() {
3570
- return s(this, X);
3571
- }
3572
- get B() {
3573
- return s(this, K);
3574
- }
3575
- get C() {
3576
- return s(this, J);
3577
- }
3578
- get AB() {
3579
- return s(this, Pe).call(this, "A", "B");
3580
- }
3581
- get BA() {
3582
- return s(this, Pe).call(this, "B", "A");
3583
- }
3584
- get BC() {
3585
- return s(this, Pe).call(this, "B", "C");
3586
- }
3587
- get CB() {
3588
- return s(this, Pe).call(this, "C", "B");
3589
- }
3590
- get AC() {
3591
- return s(this, Pe).call(this, "A", "C");
3592
- }
3593
- get CA() {
3594
- return s(this, Pe).call(this, "C", "A");
3595
- }
3596
- get isRectangle() {
3597
- return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
3598
- }
3599
- get isEquilateral() {
3600
- return this.AB.normSquare.isEqual(this.BC.normSquare) && this.AB.normSquare.isEqual(this.AC.normSquare);
3601
- }
3602
- get isIsocele() {
3603
- return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
3604
- }
3605
- get lines() {
3606
- return s(this, tt);
3607
- }
3608
- get remarquables() {
3609
- return s(this, mt);
3610
- }
3611
- };
3612
- X = new WeakMap(), K = new WeakMap(), J = new WeakMap(), tt = new WeakMap(), Oe = new WeakMap(), mt = new WeakMap(), Wt = new WeakMap(), gt = new WeakMap(), Pe = new WeakMap(), Ht = new WeakMap(), it = new WeakMap();
3613
- let oi = Xt;
3614
- var L, W;
3615
- const at = class at {
3616
- constructor(e, t) {
3617
- // ax + by + c = 0
3618
- p(this, L, new B());
3619
- p(this, W, new x());
3620
- a(this, "clone", () => (h(this, W, s(this, W).clone()), h(this, L, s(this, L).clone()), this));
3621
- // ------------------------------------------
3622
- // Mathematical operations
3623
- // ------------------------------------------
3624
- a(this, "isOnLine", (e) => !1);
3625
- a(this, "isParallelTo", (e) => {
3626
- throw new Error("Method not implemented.");
3627
- });
3628
- a(this, "isSameAs", (e) => {
3629
- throw new Error("Method not implemented.");
3630
- });
3631
- a(this, "isPerpendicularTo", (e) => {
3632
- throw new Error("Method not implemented.");
3633
- });
3634
- a(this, "isVertical", () => {
3635
- throw new Error("Method not implemented.");
3636
- });
3637
- a(this, "simplify", () => {
3638
- throw new Error("Method not implemented.");
3639
- });
3640
- a(this, "intersection", (e) => {
3641
- throw new Error("Method not implemented.");
3642
- });
3643
- // getValueAtX = (value: Fraction | number): Fraction => {
3644
- // const equ = this.equation.clone().isolate('y'),
3645
- // F = new Fraction(value)
3646
- // if (equ instanceof Equation) {
3647
- // return equ.right.evaluate({ x: F }) as Fraction
3648
- // }
3649
- // return new Fraction().invalid()
3650
- // }
3651
- // getValueAtY = (value: Fraction | number): Fraction => {
3652
- // const equ = this.equation.clone().isolate('x'),
3653
- // F = new Fraction(value)
3654
- // if (equ instanceof Equation) {
3655
- // return equ.right.evaluate({ y: F }) as Fraction
3656
- // }
3657
- // return new Fraction().invalid()
3658
- // }
3659
- a(this, "randomPoint", (e = 5) => {
3660
- const t = s(this, L).clone(), i = new u(Y(e, !1));
3661
- return new B(
3662
- t.x.clone().add(s(this, W).x.clone().multiply(i)),
3663
- t.y.clone().add(s(this, W).y.clone().multiply(i)),
3664
- t.z.clone().add(s(this, W).z.clone().multiply(i))
3665
- );
3666
- });
3667
- return h(this, L, e.clone()), h(this, W, t.asPoint ? new x(e, t) : t.clone()), this;
3668
- }
3669
- get OA() {
3670
- return s(this, L);
3671
- }
3672
- set OA(e) {
3673
- h(this, L, e);
3674
- }
3675
- get point() {
3676
- return s(this, L).clone();
3677
- }
3678
- get d() {
3679
- return s(this, W);
3680
- }
3681
- set d(e) {
3682
- h(this, W, e);
3683
- }
3684
- get tex() {
3685
- return {
3686
- parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(s(this, L).x.tex, s(this, L).y.tex, s(this, L).z.tex)} + k\\cdot ${x.asTex(s(this, W).x.tex, s(this, W).y.tex, s(this, W).z.tex)}`,
3687
- system: `\\left\\{\\begin{aligned}
3688
- x &= ${new q(s(this, L).x).add(new M(s(this, W).x).multiply(new M("k"))).reorder("k", !0).tex}\\\\
3689
- y &= ${new q(s(this, L).y).add(new M(s(this, W).y).multiply(new M("k"))).reorder("k", !0).tex}\\\\
3690
- z &= ${new q(s(this, L).z).add(new M(s(this, W).z).multiply(new M("k"))).reorder("k", !0).tex}
3691
- \\end{aligned}\\right.`,
3692
- cartesian: `\\frac{ ${new q("x", 1, s(this, L).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new q("y", 1, s(this, L).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new q("z", 1, s(this, L).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
3693
- };
3694
- }
3695
- get display() {
3696
- const e = s(this, L).x.display, t = s(this, L).y.display, i = s(this, L).z.display, n = this.direction.simplify(), r = n.x.display, l = n.y.display, c = n.z.display;
3697
- return {
3698
- parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(s(this, L).x.display, s(this, L).y.display, s(this, L).z.display)} + k\\cdot ${x.asDisplay(s(this, W).x.display, s(this, W).y.display, s(this, W).z.display)}`,
3699
- system: "",
3700
- cartesian: `(x-${e})/${r} = (y-${t})/${l} = (z-${i})/${c}`
3701
- };
3702
- }
3703
- get direction() {
3704
- return s(this, W).clone();
3705
- }
3706
- distanceTo(e) {
3707
- const t = new x(s(this, L), e), i = this.direction, n = this.direction.normSquare, r = t.cross(i).normSquare, l = r.clone().divide(n), c = l.clone().sqrt();
3708
- return console.log("CROSS", t.cross(i).display), {
3709
- value: Math.sqrt(l.value),
3710
- fraction: l.clone().sqrt(),
3711
- tex: c.isExact() ? c.tex : `\\sqrt{${l.tex}}`
3712
- };
3713
- }
3714
- hitSegment(e, t) {
3715
- const i = this.intersection(
3716
- new at(e, t)
3717
- );
3718
- return i.hasIntersection ? i.point.x.value >= Math.min(e.x.value, t.x.value) && i.point.x.value <= Math.max(e.x.value, t.x.value) && i.point.y.value >= Math.min(e.y.value, t.y.value) && i.point.y.value <= Math.max(e.y.value, t.y.value) && i.point.z.value >= Math.min(e.z.value, t.z.value) && i.point.z.value <= Math.max(e.z.value, t.z.value) : !1;
3719
- }
3720
- };
3721
- L = new WeakMap(), W = new WeakMap(), // A line is defined as the canonical form
3722
- a(at, "PERPENDICULAR", "perpendicular"), a(at, "PARALLEL", "parallel");
3723
- let Tt = at;
3724
- var qe, Ue;
3725
- const pi = class pi {
3726
- constructor(e) {
3727
- p(this, qe, new x(0, 0, 1));
3728
- p(this, Ue, new B(0, 0, 0));
3729
- return e && this.parse(e), this;
3730
- }
3731
- get normal() {
3732
- return s(this, qe);
3914
+ externalBisectors: d
3915
+ };
3916
+ return f.medians.intersection = f.medians.A.intersection(f.medians.B).point, f.mediators.intersection = f.mediators.AB.intersection(f.mediators.BC).point, f.heights.intersection = f.heights.A.intersection(f.heights.B).point, f.bisectors.intersection = f.bisectors.A.intersection(f.bisectors.B).point, f;
3917
+ });
3918
+ p(this, st, (e) => {
3919
+ const t = this.lines;
3920
+ let i, n;
3921
+ if (e === "A" ? (i = t.AB, n = t.AC) : e === "B" ? (i = t.AB, n = t.BC) : e === "C" && (i = t.BC, n = t.AC), i === void 0 || n === void 0)
3922
+ throw new Error(`The point ${e} does not exist`);
3923
+ const r = i.n.simplify().norm, l = n.n.simplify().norm, c = i.getEquation().multiply(l), d = n.getEquation().multiply(r), f = new R(c.clone().subtract(d).simplify()), g = new R(d.clone().subtract(c).simplify());
3924
+ return e === "A" ? f.hitSegment(this.B, this.C) ? { internal: f, external: g } : { internal: g, external: f } : e === "B" ? f.hitSegment(this.A, this.C) ? { internal: f, external: g } : { internal: g, external: f } : e === "C" ? f.hitSegment(this.B, this.A) ? { internal: f, external: g } : { internal: g, external: f } : { internal: f, external: g };
3925
+ });
3926
+ return e.length > 0 && this.parse(...e), this;
3733
3927
  }
3734
- set normal(e) {
3735
- h(this, qe, e), s(this, qe).asPoint = !1;
3928
+ // ------------------------------------------
3929
+ // Getter and setters
3930
+ // ------------------------------------------
3931
+ get A() {
3932
+ return s(this, X);
3736
3933
  }
3737
- get point() {
3738
- return s(this, Ue);
3934
+ get B() {
3935
+ return s(this, K);
3739
3936
  }
3740
- set point(e) {
3741
- h(this, Ue, e), s(this, Ue).asPoint = !0;
3937
+ get C() {
3938
+ return s(this, J);
3742
3939
  }
3743
- get a() {
3744
- return s(this, qe).x;
3940
+ get AB() {
3941
+ return s(this, Be).call(this, "A", "B");
3745
3942
  }
3746
- get b() {
3747
- return s(this, qe).y;
3943
+ get BA() {
3944
+ return s(this, Be).call(this, "B", "A");
3748
3945
  }
3749
- get c() {
3750
- return s(this, qe).z;
3946
+ get BC() {
3947
+ return s(this, Be).call(this, "B", "C");
3751
3948
  }
3752
- get d() {
3753
- return s(this, qe).dot(s(this, Ue)).opposite();
3949
+ get CB() {
3950
+ return s(this, Be).call(this, "C", "B");
3754
3951
  }
3755
- get tex() {
3756
- return new H(
3757
- new q("xyz", this.a, this.b, this.c, this.d),
3758
- new q(0)
3759
- ).reduce().tex;
3952
+ get AC() {
3953
+ return s(this, Be).call(this, "A", "C");
3760
3954
  }
3761
- parse(e) {
3762
- var t, i, n;
3763
- if (e.point && e.normal) {
3764
- this.point = e.point, this.normal = e.normal;
3765
- return;
3766
- }
3767
- if (e.point && ((t = e.directions) == null ? void 0 : t.length) === 2) {
3768
- this.point = e.point;
3769
- const [r, l] = e.directions;
3770
- this.normal = r.cross(l);
3771
- return;
3772
- }
3773
- if (e.equation) {
3774
- const r = e.equation.moveLeft().reduce().left, l = r.monomByLetter("x").coefficient, c = r.monomByLetter("y").coefficient, d = r.monomByLetter("z").coefficient, f = r.monomByDegree(0).coefficient;
3775
- this.normal = new x(l, c, d), l.isNotZero() ? this.point = new B(f.clone().divide(l).opposite(), 0, 0) : c.isNotZero() ? this.point = new B(0, f.clone().divide(c).opposite(), 0) : this.point = new B(0, 0, f.clone().divide(d).opposite());
3776
- return;
3777
- }
3778
- if (((i = e.points) == null ? void 0 : i.length) === 3 && e.points.every((r) => r instanceof x)) {
3779
- const r = e.points[0], l = e.points[1], c = e.points[2], d = new x(r, l), f = new x(r, c);
3780
- this.normal = d.cross(f), this.point = r;
3781
- return;
3782
- }
3783
- if (((n = e.coefficients) == null ? void 0 : n.length) === 4) {
3784
- const [r, l, c, d] = e.coefficients;
3785
- this.normal = new x(r, l, c), this.point = new B(0, 0, -d);
3786
- return;
3787
- }
3955
+ get CA() {
3956
+ return s(this, Be).call(this, "C", "A");
3788
3957
  }
3789
- angle(e, t, i) {
3790
- if (e instanceof pi)
3791
- return this.normal.angle(e.normal, t, i);
3792
- let n;
3793
- if (e instanceof x) {
3794
- if (e.dimension !== 3)
3795
- throw new Error("Vector is not 3D");
3796
- n = e;
3797
- } else
3798
- n = e.direction;
3799
- return (i ? Math.PI / 2 : 90) - this.normal.angle(n, !0, i);
3958
+ get isRectangle() {
3959
+ return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
3800
3960
  }
3801
- distanceTo(e) {
3802
- return this.normal.dot(e).add(this.d).abs().value / this.normal.norm;
3961
+ get isEquilateral() {
3962
+ return this.AB.normSquare.isEqual(this.BC.normSquare) && this.AB.normSquare.isEqual(this.AC.normSquare);
3803
3963
  }
3804
- intersectWithLine(e) {
3805
- const { point: t, direction: i } = e, n = this.normal.dot(t).add(this.d).divide(this.normal.dot(i).opposite());
3806
- return t.clone().add(i.clone().multiplyByScalar(n));
3964
+ get isIsocele() {
3965
+ return this.AB.normSquare.isEqual(this.BC.normSquare) || this.AB.normSquare.isEqual(this.AC.normSquare) || this.BC.normSquare.isEqual(this.AC.normSquare);
3807
3966
  }
3808
- intersectWithPlane(e) {
3809
- throw this.normal.cross(e.normal), new B(0, 0, 0), new Error("Intersection with plane not yet implemented !");
3967
+ get lines() {
3968
+ return s(this, it);
3810
3969
  }
3811
- isPointOnPlane(e) {
3812
- return this.normal.dot(e).add(this.d).isZero();
3970
+ get remarquables() {
3971
+ return s(this, yt);
3813
3972
  }
3814
3973
  };
3815
- qe = new WeakMap(), Ue = new WeakMap();
3816
- let hi = pi;
3817
- var ke;
3818
- class rs {
3819
- constructor(...e) {
3820
- p(this, ke, []);
3821
- return h(this, ke, e), this;
3822
- }
3823
- get values() {
3824
- return s(this, ke);
3825
- }
3826
- get array() {
3827
- return s(this, ke).map((e) => e.array);
3828
- }
3829
- get dimension() {
3830
- return [s(this, ke).length, s(this, ke)[0].dimension];
3831
- }
3832
- isSquare() {
3833
- return s(this, ke).length === s(this, ke)[0].dimension;
3834
- }
3835
- determinant() {
3836
- if (!this.isSquare())
3837
- throw new Error("Matrix is not square");
3838
- return is(...this.values);
3839
- }
3840
- }
3841
- ke = new WeakMap();
3842
- function At(o) {
3974
+ X = new WeakMap(), K = new WeakMap(), J = new WeakMap(), it = new WeakMap(), Ce = new WeakMap(), yt = new WeakMap(), Ht = new WeakMap(), wt = new WeakMap(), Be = new WeakMap(), Xt = new WeakMap(), st = new WeakMap();
3975
+ let ci = Yt;
3976
+ function Ot(o) {
3843
3977
  const e = Object.assign(
3844
3978
  {
3845
3979
  negative: !0,
@@ -3859,7 +3993,7 @@ function At(o) {
3859
3993
  }
3860
3994
  return e.reduced ? t.reduce() : t;
3861
3995
  }
3862
- function Ii(o) {
3996
+ function Pi(o) {
3863
3997
  const e = Object.assign(
3864
3998
  {
3865
3999
  letters: "x",
@@ -3869,7 +4003,7 @@ function Ii(o) {
3869
4003
  },
3870
4004
  o
3871
4005
  ), t = new M();
3872
- if (t.coefficient = At({
4006
+ if (t.coefficient = Ot({
3873
4007
  zero: e.zero,
3874
4008
  reduced: !0,
3875
4009
  natural: !e.fraction
@@ -3877,14 +4011,14 @@ function Ii(o) {
3877
4011
  for (const i of e.letters.split(""))
3878
4012
  t.setLetter(i, 0);
3879
4013
  for (let i = 0; i < e.degree; i++) {
3880
- const n = fi(e.letters.split(""));
4014
+ const n = pi(e.letters.split(""));
3881
4015
  t.setLetter(n, t.degree(n).clone().add(1));
3882
4016
  }
3883
4017
  } else
3884
4018
  t.setLetter(e.letters, e.degree);
3885
4019
  return t;
3886
4020
  }
3887
- const os = {
4021
+ const as = {
3888
4022
  letters: "x",
3889
4023
  degree: 2,
3890
4024
  fraction: !1,
@@ -3895,14 +4029,14 @@ const os = {
3895
4029
  numberOfMonoms: 0,
3896
4030
  positive: !0
3897
4031
  };
3898
- function Pi(o) {
4032
+ function Bi(o) {
3899
4033
  const e = Object.assign(
3900
- os,
4034
+ as,
3901
4035
  o
3902
4036
  ), t = new q().empty();
3903
4037
  let i;
3904
4038
  for (let n = e.degree; n >= 0; n--)
3905
- i = Ii({
4039
+ i = Pi({
3906
4040
  letters: e.letters,
3907
4041
  degree: n,
3908
4042
  fraction: e.fraction,
@@ -3915,7 +4049,7 @@ function Pi(o) {
3915
4049
  }
3916
4050
  return t.reduce();
3917
4051
  }
3918
- function hs(o) {
4052
+ function ls(o) {
3919
4053
  const e = Object.assign(
3920
4054
  {
3921
4055
  letters: "x",
@@ -3937,7 +4071,7 @@ function hs(o) {
3937
4071
  o
3938
4072
  ), t = new q().one();
3939
4073
  for (let i = 0; i < e.degree; i++) {
3940
- const n = Pi({
4074
+ const n = Bi({
3941
4075
  degree: 1,
3942
4076
  unit: e.unit,
3943
4077
  fraction: e.fraction,
@@ -3948,7 +4082,7 @@ function hs(o) {
3948
4082
  }
3949
4083
  return new H(t, 0);
3950
4084
  }
3951
- function ai(o) {
4085
+ function ui(o) {
3952
4086
  const e = Object.assign(
3953
4087
  {
3954
4088
  axis: !0,
@@ -3957,10 +4091,10 @@ function ai(o) {
3957
4091
  quadrant: null
3958
4092
  },
3959
4093
  o
3960
- ), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? At({ max: e.max, zero: t }) : new u(Y(e.max, t)), r = e.fraction ? At({ max: e.max, zero: i }) : new u(Y(e.max, i));
4094
+ ), t = e.axis === "x", i = e.axis === "y", n = e.fraction ? Ot({ max: e.max, zero: t }) : new u(Y(e.max, t)), r = e.fraction ? Ot({ max: e.max, zero: i }) : new u(Y(e.max, i));
3961
4095
  return Number(e.quadrant) === 1 && (n.abs(), r.abs()), Number(e.quadrant) === 2 && (n.isPositive() && n.opposite(), r.isNegative() && r.opposite()), Number(e.quadrant) === 3 && (n.isPositive() && n.opposite(), r.isPositive() && r.opposite()), Number(e.quadrant) === 4 && (n.isNegative() && n.opposite(), r.isPositive() && r.opposite()), new B(n, r);
3962
4096
  }
3963
- function as(o) {
4097
+ function cs(o) {
3964
4098
  const e = Object.assign(
3965
4099
  {
3966
4100
  center: {
@@ -3970,11 +4104,11 @@ function as(o) {
3970
4104
  pointsOnCircle: 8
3971
4105
  },
3972
4106
  o
3973
- ), t = ai(e.center);
4107
+ ), t = ui(e.center);
3974
4108
  let i, n;
3975
- return e.pointsOnCircle === 8 ? (i = fe(1, 3), n = i ** 2 + (i + 1) ** 2) : n = fe(1, 20), new Nt(t, n, !0);
4109
+ return e.pointsOnCircle === 8 ? (i = fe(1, 3), n = i ** 2 + (i + 1) ** 2) : n = fe(1, 20), new Tt(t, n, !0);
3976
4110
  }
3977
- function ls(o) {
4111
+ function us(o) {
3978
4112
  const e = Object.assign(
3979
4113
  {
3980
4114
  A: {
@@ -3991,7 +4125,7 @@ function ls(o) {
3991
4125
  t.x = Y(10), t.y = Y(10);
3992
4126
  return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new R(new x(e.A.x, e.A.y), t);
3993
4127
  }
3994
- function cs(o) {
4128
+ function fs(o) {
3995
4129
  const e = Object.assign(
3996
4130
  {
3997
4131
  A: {
@@ -4007,196 +4141,76 @@ function cs(o) {
4007
4141
  },
4008
4142
  o
4009
4143
  ), t = new B(e.A.x, e.A.y, e.A.z), i = new x(e.direction.x, e.direction.y, e.direction.z);
4010
- return new Tt(t, i);
4144
+ return new At(t, i);
4011
4145
  }
4012
- const us = {
4013
- equation: (o) => hs(o),
4014
- polynom: (o) => Pi(o),
4015
- monom: (o) => Ii(o),
4016
- fraction: (o) => At(o),
4146
+ const ds = {
4147
+ equation: (o) => ls(o),
4148
+ polynom: (o) => Bi(o),
4149
+ monom: (o) => Pi(o),
4150
+ fraction: (o) => Ot(o),
4017
4151
  number: (o, e, t) => fe(o, e, t),
4018
4152
  numberSym: (o, e) => Y(o, e),
4019
- prime: (o) => ss(o),
4020
- bool: (o) => Ai(o),
4021
- array: (o, e) => ns(o, e),
4022
- item: (o) => fi(o),
4023
- shuffle: (o) => Oi(o),
4024
- line: (o) => ls(o),
4025
- line3: (o) => cs(o),
4026
- vector: (o) => ai(o),
4153
+ prime: (o) => rs(o),
4154
+ bool: (o) => qi(o),
4155
+ array: (o, e) => os(o, e),
4156
+ item: (o) => pi(o),
4157
+ shuffle: (o) => ki(o),
4158
+ line: (o) => us(o),
4159
+ line3: (o) => fs(o),
4160
+ vector: (o) => ui(o),
4027
4161
  point: (o) => {
4028
- const e = ai(o);
4162
+ const e = ui(o);
4029
4163
  return e.asPoint = !0, e;
4030
4164
  },
4031
- circle: (o) => as(o)
4032
- };
4033
- var Me, yt, li;
4034
- class fs {
4035
- /**
4036
- *
4037
- * @param {string} value (optional) Default polynom to parse on class creation
4038
- */
4039
- constructor(e) {
4040
- p(this, yt);
4041
- p(this, Me);
4042
- a(this, "parse", (e) => (h(this, Me, new Yt(Ze.SET).parse(e).rpn), this));
4043
- return h(this, Me, []), e !== void 0 && this.parse(e), this;
4044
- }
4045
- evaluate(e) {
4046
- this.variables.forEach((i) => {
4047
- Object.hasOwn(e, i) || (e[i] = !1);
4048
- });
4049
- const t = [];
4050
- for (const i of s(this, Me))
4051
- if (console.log(i), i.tokenType === "variable")
4052
- t.push(e[i.token]);
4053
- else if (i.tokenType === "operation")
4054
- if (i.token === "!")
4055
- if (t.length >= 1) {
4056
- const n = t.pop();
4057
- t.push(!n);
4058
- } else
4059
- return !1;
4060
- else {
4061
- const n = t.pop(), r = t.pop();
4062
- if (n !== void 0 && r !== void 0)
4063
- switch (i.token) {
4064
- case "&":
4065
- t.push(n && r);
4066
- break;
4067
- case "|":
4068
- t.push(n || r);
4069
- break;
4070
- case "-":
4071
- return !1;
4072
- }
4073
- else
4074
- return !1;
4075
- }
4076
- return t.length === 1 && t[0];
4077
- }
4078
- get rpn() {
4079
- return s(this, Me);
4080
- }
4081
- get tex() {
4082
- const e = [];
4083
- for (const t of s(this, Me))
4084
- if (t.tokenType === "variable")
4085
- e.push(t);
4086
- else
4087
- switch (t.token) {
4088
- case "&":
4089
- if (e.length >= 2) {
4090
- const i = e.pop(), n = e.pop();
4091
- i && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${n.token} \\cap ${i.token}`, tokenType: "mix" }));
4092
- }
4093
- break;
4094
- case "|":
4095
- if (e.length >= 2) {
4096
- const i = e.pop(), n = e.pop();
4097
- i && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${n.token} \\cup ${i.token}`, tokenType: "mix" }));
4098
- }
4099
- break;
4100
- case "-":
4101
- if (e.length >= 2) {
4102
- const i = e.pop(), n = e.pop();
4103
- i && n && (n.tokenType === "mix" && (n.token = `( ${n.token} )`), i.tokenType === "mix" && (i.token = `( ${i.token} )`), e.push({ token: `${n.token} \\setminus ${i.token}`, tokenType: "mix" }));
4104
- }
4105
- break;
4106
- case "!":
4107
- if (e.length >= 1) {
4108
- const i = e.pop();
4109
- i && e.push({ token: `\\overline{ ${i.token} }`, tokenType: "variable" });
4110
- }
4111
- break;
4112
- }
4113
- return e[0].token;
4114
- }
4115
- get variables() {
4116
- return s(this, Me).filter((e) => e.tokenType === "variable").map((e) => e.token);
4117
- }
4118
- vennAB() {
4119
- return O(this, yt, li).call(this, {
4120
- A: ["A", "AB"],
4121
- B: ["B", "AB"]
4122
- }, ["A", "B", "AB", "E"]);
4123
- }
4124
- vennABC() {
4125
- return O(this, yt, li).call(this, {
4126
- A: ["A", "AB", "AC", "ABC"],
4127
- B: ["B", "AB", "BC", "ABC"],
4128
- C: ["C", "AC", "BC", "ABC"]
4129
- }, ["A", "B", "C", "AB", "AC", "BC", "ABC", "E"]);
4130
- }
4131
- }
4132
- Me = new WeakMap(), yt = new WeakSet(), li = function(e, t) {
4133
- const i = [];
4134
- let n;
4135
- if (t === void 0) {
4136
- n = /* @__PURE__ */ new Set();
4137
- for (const r in e)
4138
- n = /* @__PURE__ */ new Set([
4139
- ...n,
4140
- ...e[r] ?? []
4141
- ]);
4142
- } else
4143
- n = new Set(t);
4144
- for (const r of s(this, Me))
4145
- if (r.tokenType === "variable")
4146
- e[r.token] === void 0 ? i.push(/* @__PURE__ */ new Set()) : i.push(new Set(e[r.token]));
4147
- else
4148
- switch (r.token) {
4149
- case "&":
4150
- if (i.length >= 2) {
4151
- const l = i.pop(), c = i.pop();
4152
- c && l && i.push(new Set([...c].filter((d) => l.has(d))));
4153
- }
4154
- break;
4155
- case "|":
4156
- if (i.length >= 2) {
4157
- const l = i.pop(), c = i.pop();
4158
- c && l && i.push(/* @__PURE__ */ new Set([...c, ...l]));
4159
- }
4160
- break;
4161
- case "-":
4162
- if (i.length >= 2) {
4163
- const l = i.pop(), c = i.pop();
4164
- c && l && i.push(new Set([...c].filter((d) => !l.has(d))));
4165
- }
4166
- break;
4167
- case "!":
4168
- if (i.length >= 1) {
4169
- const l = i.pop();
4170
- l && i.push(new Set([...n].filter((c) => !l.has(c))));
4171
- }
4172
- break;
4173
- }
4174
- return [...i[0]].sort();
4175
- };
4176
- const ds = {
4177
- Vector: x,
4178
- Point: B,
4179
- Line: R,
4180
- Triangle: oi,
4181
- Circle: Nt,
4182
- Line3: Tt,
4183
- Plane3: hi
4165
+ circle: (o) => cs(o)
4184
4166
  }, ms = {
4185
4167
  Numeric: G,
4186
4168
  Fraction: u,
4187
- Root: wt,
4169
+ Root: vt,
4188
4170
  Monom: M,
4189
4171
  Polynom: q,
4190
4172
  Equation: H,
4191
- Matrix: rs,
4192
- LinearSystem: ni,
4173
+ Matrix: hs,
4174
+ LinearSystem: ii,
4193
4175
  Factor: ue,
4194
- PolyFactor: ti,
4195
- LogicalSet: fs,
4196
- Random: us,
4197
- Geometry: ds,
4198
- NumExp: Ji
4176
+ PolyFactor: ni,
4177
+ LogicalSet: es,
4178
+ Random: ds,
4179
+ Geometry: {
4180
+ Vector: x,
4181
+ Point: B,
4182
+ Line: R,
4183
+ Triangle: ci,
4184
+ Circle: Tt,
4185
+ Line3: At,
4186
+ Plane3: li
4187
+ },
4188
+ NumExp: _i
4199
4189
  };
4200
4190
  export {
4201
- ms as default
4191
+ Tt as Circle,
4192
+ H as Equation,
4193
+ Nt as EquationSolver,
4194
+ at as FACTOR_DISPLAY,
4195
+ ue as Factor,
4196
+ u as Fraction,
4197
+ R as Line,
4198
+ At as Line3,
4199
+ ii as LinearSystem,
4200
+ es as LogicalSet,
4201
+ hs as Matrix,
4202
+ M as Monom,
4203
+ vt as NthRoot,
4204
+ li as Plane3,
4205
+ B as Point,
4206
+ ni as PolyFactor,
4207
+ q as Polynom,
4208
+ ci as Triangle,
4209
+ x as Vector,
4210
+ is as areVectorsColinears,
4211
+ ts as areVectorsEquals,
4212
+ ms as default,
4213
+ ns as determinant,
4214
+ ss as dotProduct
4202
4215
  };
4216
+ //# sourceMappingURL=pimath.js.map