pimath 0.2.14 → 0.2.15

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 (59) hide show
  1. package/dist/pimath.js +850 -1879
  2. package/dist/pimath.js.map +1 -1
  3. package/package.json +1 -1
  4. package/src/algebra/equation.ts +562 -558
  5. package/src/algebra/equationSolver.ts +489 -489
  6. package/src/algebra/factor.ts +396 -392
  7. package/src/algebra/linearSystem.ts +446 -442
  8. package/src/algebra/matrix.ts +515 -511
  9. package/src/algebra/monom.ts +932 -928
  10. package/src/algebra/polyFactor.ts +724 -720
  11. package/src/algebra/polynom.ts +1233 -1229
  12. package/src/coefficients/fraction.ts +907 -748
  13. package/src/coefficients/root.ts +500 -359
  14. package/src/geometry/TupleN.ts +129 -129
  15. package/src/geometry/circle.ts +455 -455
  16. package/src/geometry/line.ts +658 -654
  17. package/src/geometry/point.ts +105 -105
  18. package/src/geometry/sphere3.ts +2 -2
  19. package/src/geometry/triangle.ts +488 -488
  20. package/src/geometry/vector.ts +230 -226
  21. package/src/numeric.ts +136 -51
  22. package/src/pimath.interface.ts +2 -0
  23. package/types/algebra/equation.d.ts +1 -0
  24. package/types/algebra/equation.d.ts.map +1 -1
  25. package/types/algebra/equationSolver.d.ts.map +1 -1
  26. package/types/algebra/factor.d.ts +1 -0
  27. package/types/algebra/factor.d.ts.map +1 -1
  28. package/types/algebra/linearSystem.d.ts +1 -0
  29. package/types/algebra/linearSystem.d.ts.map +1 -1
  30. package/types/algebra/matrix.d.ts +6 -5
  31. package/types/algebra/matrix.d.ts.map +1 -1
  32. package/types/algebra/monom.d.ts +1 -0
  33. package/types/algebra/monom.d.ts.map +1 -1
  34. package/types/algebra/polyFactor.d.ts +1 -0
  35. package/types/algebra/polyFactor.d.ts.map +1 -1
  36. package/types/algebra/polynom.d.ts +1 -0
  37. package/types/algebra/polynom.d.ts.map +1 -1
  38. package/types/coefficients/fraction.d.ts +62 -53
  39. package/types/coefficients/fraction.d.ts.map +1 -1
  40. package/types/coefficients/root.d.ts +3 -0
  41. package/types/coefficients/root.d.ts.map +1 -1
  42. package/types/geometry/TupleN.d.ts +1 -1
  43. package/types/geometry/TupleN.d.ts.map +1 -1
  44. package/types/geometry/circle.d.ts.map +1 -1
  45. package/types/geometry/line.d.ts +1 -0
  46. package/types/geometry/line.d.ts.map +1 -1
  47. package/types/geometry/point.d.ts.map +1 -1
  48. package/types/geometry/sphere3.d.ts +2 -2
  49. package/types/geometry/sphere3.d.ts.map +1 -1
  50. package/types/geometry/triangle.d.ts.map +1 -1
  51. package/types/geometry/vector.d.ts +1 -0
  52. package/types/geometry/vector.d.ts.map +1 -1
  53. package/types/index.d.ts +3 -3
  54. package/types/numeric.d.ts +4 -4
  55. package/types/numeric.d.ts.map +1 -1
  56. package/types/pimath.interface.d.ts +1 -0
  57. package/types/pimath.interface.d.ts.map +1 -1
  58. package/types/primes.data.d.ts +2 -0
  59. package/types/primes.data.d.ts.map +1 -0
package/dist/pimath.js CHANGED
@@ -3,1318 +3,99 @@ var e = class extends Error {
3
3
  constructor(e, t) {
4
4
  super(e, t), this.name = new.target.name;
5
5
  }
6
- }, t = class extends e {}, n = class extends e {}, r = class extends e {}, i = class extends e {}, a = class extends e {}, o = class extends e {}, s = class extends e {};
7
- //#endregion
8
- //#region src/numeric.ts
9
- function c(e) {
10
- let t = u(e), n = [], r, i;
6
+ }, t = class extends e {}, n = class extends e {}, r = class extends e {}, i = class extends e {}, a = class extends e {}, o = class extends e {}, s = class extends e {}, c = 1e4, l;
7
+ function u(e) {
8
+ let t = new Uint8Array(e + 1), n = [];
9
+ for (let r = 2; r <= e; r++) if (t[r] === 0) {
10
+ n.push(r);
11
+ for (let n = r * r; n <= e; n += r) t[n] = 1;
12
+ }
13
+ return n;
14
+ }
15
+ function d(e) {
16
+ let t = ee(e), n = [], r, i;
11
17
  for (; t.length > 0;) r = t.shift() ?? 1, i = (t.length > 0 ? t.pop() : +r) ?? 1, n.push([r, i]);
12
18
  return n;
13
19
  }
14
- function l(...e) {
15
- let t = d(...e);
20
+ function f(...e) {
21
+ let t = p(...e);
16
22
  return e.map((e) => e / t);
17
23
  }
18
- function u(e) {
24
+ function ee(e) {
25
+ if (!Number.isInteger(e)) throw new i(`dividers expects a finite integer, got ${e}`);
19
26
  let t = Math.abs(e), n = Math.sqrt(t), r = [];
20
27
  for (let i = 1; i <= n; i++) e % i === 0 && (r.push(i), r.push(t / i));
21
28
  return r.sort(function(e, t) {
22
29
  return e - t;
23
30
  }), [...new Set(r)];
24
31
  }
25
- function d(...e) {
32
+ function p(...e) {
26
33
  let t = function(e, n) {
27
34
  return isNaN(e) || isNaN(n) ? NaN : n === 0 ? e : e === 0 ? n : t(n, e % n);
28
35
  }, n = 1, r = 2;
29
36
  if (e.length === 0) return 1;
30
- if (e.length === 1) return e[0] === 0 ? 1 : e[0];
37
+ if (e.length === 1) return e[0] === 0 ? 1 : Math.abs(e[0]);
31
38
  if (n = t(e[0], e[1]), n === 1) return 1;
32
39
  for (r = 2; r < e.length && (n = t(n, e[r]), n !== 1); r++);
33
40
  return Math.abs(n);
34
41
  }
35
- function f(...e) {
42
+ function te(...e) {
36
43
  return e.reduce(function(e, t) {
37
- return Math.abs(e * t / d(e, t));
38
- });
44
+ return Math.abs(e / p(e, t) * t);
45
+ }, 1);
39
46
  }
40
- function ee(e, t = 3) {
41
- return +e.toFixed(t);
47
+ function ne(e, t = 3) {
48
+ let n = Math.min(100, Math.max(0, Math.trunc(t)));
49
+ return +e.toFixed(n);
42
50
  }
43
- function te(e) {
44
- if (Number.isSafeInteger(e) || e.toString().split(".")[0].length < 10) return 0;
45
- throw new a("Periodic value: Not implemented yet");
51
+ function re(e) {
52
+ return l ??= u(c), e === void 0 ? [...l] : l.slice(0, Math.min(l.length, e));
46
53
  }
47
- function ne(e) {
48
- let t = [
49
- 2,
50
- 3,
51
- 5,
52
- 7,
53
- 11,
54
- 13,
55
- 17,
56
- 19,
57
- 23,
58
- 29,
59
- 31,
60
- 37,
61
- 41,
62
- 43,
63
- 47,
64
- 53,
65
- 59,
66
- 61,
67
- 67,
68
- 71,
69
- 73,
70
- 79,
71
- 83,
72
- 89,
73
- 97,
74
- 101,
75
- 103,
76
- 107,
77
- 109,
78
- 113,
79
- 127,
80
- 131,
81
- 137,
82
- 139,
83
- 149,
84
- 151,
85
- 157,
86
- 163,
87
- 167,
88
- 173,
89
- 179,
90
- 181,
91
- 191,
92
- 193,
93
- 197,
94
- 199,
95
- 211,
96
- 223,
97
- 227,
98
- 229,
99
- 233,
100
- 239,
101
- 241,
102
- 251,
103
- 257,
104
- 263,
105
- 269,
106
- 271,
107
- 277,
108
- 281,
109
- 283,
110
- 293,
111
- 307,
112
- 311,
113
- 313,
114
- 317,
115
- 331,
116
- 337,
117
- 347,
118
- 349,
119
- 353,
120
- 359,
121
- 367,
122
- 373,
123
- 379,
124
- 383,
125
- 389,
126
- 397,
127
- 401,
128
- 409,
129
- 419,
130
- 421,
131
- 431,
132
- 433,
133
- 439,
134
- 443,
135
- 449,
136
- 457,
137
- 461,
138
- 463,
139
- 467,
140
- 479,
141
- 487,
142
- 491,
143
- 499,
144
- 503,
145
- 509,
146
- 521,
147
- 523,
148
- 541,
149
- 547,
150
- 557,
151
- 563,
152
- 569,
153
- 571,
154
- 577,
155
- 587,
156
- 593,
157
- 599,
158
- 601,
159
- 607,
160
- 613,
161
- 617,
162
- 619,
163
- 631,
164
- 641,
165
- 643,
166
- 647,
167
- 653,
168
- 659,
169
- 661,
170
- 673,
171
- 677,
172
- 683,
173
- 691,
174
- 701,
175
- 709,
176
- 719,
177
- 727,
178
- 733,
179
- 739,
180
- 743,
181
- 751,
182
- 757,
183
- 761,
184
- 769,
185
- 773,
186
- 787,
187
- 797,
188
- 809,
189
- 811,
190
- 821,
191
- 823,
192
- 827,
193
- 829,
194
- 839,
195
- 853,
196
- 857,
197
- 859,
198
- 863,
199
- 877,
200
- 881,
201
- 883,
202
- 887,
203
- 907,
204
- 911,
205
- 919,
206
- 929,
207
- 937,
208
- 941,
209
- 947,
210
- 953,
211
- 967,
212
- 971,
213
- 977,
214
- 983,
215
- 991,
216
- 997,
217
- 1009,
218
- 1013,
219
- 1019,
220
- 1021,
221
- 1031,
222
- 1033,
223
- 1039,
224
- 1049,
225
- 1051,
226
- 1061,
227
- 1063,
228
- 1069,
229
- 1087,
230
- 1091,
231
- 1093,
232
- 1097,
233
- 1103,
234
- 1109,
235
- 1117,
236
- 1123,
237
- 1129,
238
- 1151,
239
- 1153,
240
- 1163,
241
- 1171,
242
- 1181,
243
- 1187,
244
- 1193,
245
- 1201,
246
- 1213,
247
- 1217,
248
- 1223,
249
- 1229,
250
- 1231,
251
- 1237,
252
- 1249,
253
- 1259,
254
- 1277,
255
- 1279,
256
- 1283,
257
- 1289,
258
- 1291,
259
- 1297,
260
- 1301,
261
- 1303,
262
- 1307,
263
- 1319,
264
- 1321,
265
- 1327,
266
- 1361,
267
- 1367,
268
- 1373,
269
- 1381,
270
- 1399,
271
- 1409,
272
- 1423,
273
- 1427,
274
- 1429,
275
- 1433,
276
- 1439,
277
- 1447,
278
- 1451,
279
- 1453,
280
- 1459,
281
- 1471,
282
- 1481,
283
- 1483,
284
- 1487,
285
- 1489,
286
- 1493,
287
- 1499,
288
- 1511,
289
- 1523,
290
- 1531,
291
- 1543,
292
- 1549,
293
- 1553,
294
- 1559,
295
- 1567,
296
- 1571,
297
- 1579,
298
- 1583,
299
- 1597,
300
- 1601,
301
- 1607,
302
- 1609,
303
- 1613,
304
- 1619,
305
- 1621,
306
- 1627,
307
- 1637,
308
- 1657,
309
- 1663,
310
- 1667,
311
- 1669,
312
- 1693,
313
- 1697,
314
- 1699,
315
- 1709,
316
- 1721,
317
- 1723,
318
- 1733,
319
- 1741,
320
- 1747,
321
- 1753,
322
- 1759,
323
- 1777,
324
- 1783,
325
- 1787,
326
- 1789,
327
- 1801,
328
- 1811,
329
- 1823,
330
- 1831,
331
- 1847,
332
- 1861,
333
- 1867,
334
- 1871,
335
- 1873,
336
- 1877,
337
- 1879,
338
- 1889,
339
- 1901,
340
- 1907,
341
- 1913,
342
- 1931,
343
- 1933,
344
- 1949,
345
- 1951,
346
- 1973,
347
- 1979,
348
- 1987,
349
- 1993,
350
- 1997,
351
- 1999,
352
- 2003,
353
- 2011,
354
- 2017,
355
- 2027,
356
- 2029,
357
- 2039,
358
- 2053,
359
- 2063,
360
- 2069,
361
- 2081,
362
- 2083,
363
- 2087,
364
- 2089,
365
- 2099,
366
- 2111,
367
- 2113,
368
- 2129,
369
- 2131,
370
- 2137,
371
- 2141,
372
- 2143,
373
- 2153,
374
- 2161,
375
- 2179,
376
- 2203,
377
- 2207,
378
- 2213,
379
- 2221,
380
- 2237,
381
- 2239,
382
- 2243,
383
- 2251,
384
- 2267,
385
- 2269,
386
- 2273,
387
- 2281,
388
- 2287,
389
- 2293,
390
- 2297,
391
- 2309,
392
- 2311,
393
- 2333,
394
- 2339,
395
- 2341,
396
- 2347,
397
- 2351,
398
- 2357,
399
- 2371,
400
- 2377,
401
- 2381,
402
- 2383,
403
- 2389,
404
- 2393,
405
- 2399,
406
- 2411,
407
- 2417,
408
- 2423,
409
- 2437,
410
- 2441,
411
- 2447,
412
- 2459,
413
- 2467,
414
- 2473,
415
- 2477,
416
- 2503,
417
- 2521,
418
- 2531,
419
- 2539,
420
- 2543,
421
- 2549,
422
- 2551,
423
- 2557,
424
- 2579,
425
- 2591,
426
- 2593,
427
- 2609,
428
- 2617,
429
- 2621,
430
- 2633,
431
- 2647,
432
- 2657,
433
- 2659,
434
- 2663,
435
- 2671,
436
- 2677,
437
- 2683,
438
- 2687,
439
- 2689,
440
- 2693,
441
- 2699,
442
- 2707,
443
- 2711,
444
- 2713,
445
- 2719,
446
- 2729,
447
- 2731,
448
- 2741,
449
- 2749,
450
- 2753,
451
- 2767,
452
- 2777,
453
- 2789,
454
- 2791,
455
- 2797,
456
- 2801,
457
- 2803,
458
- 2819,
459
- 2833,
460
- 2837,
461
- 2843,
462
- 2851,
463
- 2857,
464
- 2861,
465
- 2879,
466
- 2887,
467
- 2897,
468
- 2903,
469
- 2909,
470
- 2917,
471
- 2927,
472
- 2939,
473
- 2953,
474
- 2957,
475
- 2963,
476
- 2969,
477
- 2971,
478
- 2999,
479
- 3001,
480
- 3011,
481
- 3019,
482
- 3023,
483
- 3037,
484
- 3041,
485
- 3049,
486
- 3061,
487
- 3067,
488
- 3079,
489
- 3083,
490
- 3089,
491
- 3109,
492
- 3119,
493
- 3121,
494
- 3137,
495
- 3163,
496
- 3167,
497
- 3169,
498
- 3181,
499
- 3187,
500
- 3191,
501
- 3203,
502
- 3209,
503
- 3217,
504
- 3221,
505
- 3229,
506
- 3251,
507
- 3253,
508
- 3257,
509
- 3259,
510
- 3271,
511
- 3299,
512
- 3301,
513
- 3307,
514
- 3313,
515
- 3319,
516
- 3323,
517
- 3329,
518
- 3331,
519
- 3343,
520
- 3347,
521
- 3359,
522
- 3361,
523
- 3371,
524
- 3373,
525
- 3389,
526
- 3391,
527
- 3407,
528
- 3413,
529
- 3433,
530
- 3449,
531
- 3457,
532
- 3461,
533
- 3463,
534
- 3467,
535
- 3469,
536
- 3491,
537
- 3499,
538
- 3511,
539
- 3517,
540
- 3527,
541
- 3529,
542
- 3533,
543
- 3539,
544
- 3541,
545
- 3547,
546
- 3557,
547
- 3559,
548
- 3571,
549
- 3581,
550
- 3583,
551
- 3593,
552
- 3607,
553
- 3613,
554
- 3617,
555
- 3623,
556
- 3631,
557
- 3637,
558
- 3643,
559
- 3659,
560
- 3671,
561
- 3673,
562
- 3677,
563
- 3691,
564
- 3697,
565
- 3701,
566
- 3709,
567
- 3719,
568
- 3727,
569
- 3733,
570
- 3739,
571
- 3761,
572
- 3767,
573
- 3769,
574
- 3779,
575
- 3793,
576
- 3797,
577
- 3803,
578
- 3821,
579
- 3823,
580
- 3833,
581
- 3847,
582
- 3851,
583
- 3853,
584
- 3863,
585
- 3877,
586
- 3881,
587
- 3889,
588
- 3907,
589
- 3911,
590
- 3917,
591
- 3919,
592
- 3923,
593
- 3929,
594
- 3931,
595
- 3943,
596
- 3947,
597
- 3967,
598
- 3989,
599
- 4001,
600
- 4003,
601
- 4007,
602
- 4013,
603
- 4019,
604
- 4021,
605
- 4027,
606
- 4049,
607
- 4051,
608
- 4057,
609
- 4073,
610
- 4079,
611
- 4091,
612
- 4093,
613
- 4099,
614
- 4111,
615
- 4127,
616
- 4129,
617
- 4133,
618
- 4139,
619
- 4153,
620
- 4157,
621
- 4159,
622
- 4177,
623
- 4201,
624
- 4211,
625
- 4217,
626
- 4219,
627
- 4229,
628
- 4231,
629
- 4241,
630
- 4243,
631
- 4253,
632
- 4259,
633
- 4261,
634
- 4271,
635
- 4273,
636
- 4283,
637
- 4289,
638
- 4297,
639
- 4327,
640
- 4337,
641
- 4339,
642
- 4349,
643
- 4357,
644
- 4363,
645
- 4373,
646
- 4391,
647
- 4397,
648
- 4409,
649
- 4421,
650
- 4423,
651
- 4441,
652
- 4447,
653
- 4451,
654
- 4457,
655
- 4463,
656
- 4481,
657
- 4483,
658
- 4493,
659
- 4507,
660
- 4513,
661
- 4517,
662
- 4519,
663
- 4523,
664
- 4547,
665
- 4549,
666
- 4561,
667
- 4567,
668
- 4583,
669
- 4591,
670
- 4597,
671
- 4603,
672
- 4621,
673
- 4637,
674
- 4639,
675
- 4643,
676
- 4649,
677
- 4651,
678
- 4657,
679
- 4663,
680
- 4673,
681
- 4679,
682
- 4691,
683
- 4703,
684
- 4721,
685
- 4723,
686
- 4729,
687
- 4733,
688
- 4751,
689
- 4759,
690
- 4783,
691
- 4787,
692
- 4789,
693
- 4793,
694
- 4799,
695
- 4801,
696
- 4813,
697
- 4817,
698
- 4831,
699
- 4861,
700
- 4871,
701
- 4877,
702
- 4889,
703
- 4903,
704
- 4909,
705
- 4919,
706
- 4931,
707
- 4933,
708
- 4937,
709
- 4943,
710
- 4951,
711
- 4957,
712
- 4967,
713
- 4969,
714
- 4973,
715
- 4987,
716
- 4993,
717
- 4999,
718
- 5003,
719
- 5009,
720
- 5011,
721
- 5021,
722
- 5023,
723
- 5039,
724
- 5051,
725
- 5059,
726
- 5077,
727
- 5081,
728
- 5087,
729
- 5099,
730
- 5101,
731
- 5107,
732
- 5113,
733
- 5119,
734
- 5147,
735
- 5153,
736
- 5167,
737
- 5171,
738
- 5179,
739
- 5189,
740
- 5197,
741
- 5209,
742
- 5227,
743
- 5231,
744
- 5233,
745
- 5237,
746
- 5261,
747
- 5273,
748
- 5279,
749
- 5281,
750
- 5297,
751
- 5303,
752
- 5309,
753
- 5323,
754
- 5333,
755
- 5347,
756
- 5351,
757
- 5381,
758
- 5387,
759
- 5393,
760
- 5399,
761
- 5407,
762
- 5413,
763
- 5417,
764
- 5419,
765
- 5431,
766
- 5437,
767
- 5441,
768
- 5443,
769
- 5449,
770
- 5471,
771
- 5477,
772
- 5479,
773
- 5483,
774
- 5501,
775
- 5503,
776
- 5507,
777
- 5519,
778
- 5521,
779
- 5527,
780
- 5531,
781
- 5557,
782
- 5563,
783
- 5569,
784
- 5573,
785
- 5581,
786
- 5591,
787
- 5623,
788
- 5639,
789
- 5641,
790
- 5647,
791
- 5651,
792
- 5653,
793
- 5657,
794
- 5659,
795
- 5669,
796
- 5683,
797
- 5689,
798
- 5693,
799
- 5701,
800
- 5711,
801
- 5717,
802
- 5737,
803
- 5741,
804
- 5743,
805
- 5749,
806
- 5779,
807
- 5783,
808
- 5791,
809
- 5801,
810
- 5807,
811
- 5813,
812
- 5821,
813
- 5827,
814
- 5839,
815
- 5843,
816
- 5849,
817
- 5851,
818
- 5857,
819
- 5861,
820
- 5867,
821
- 5869,
822
- 5879,
823
- 5881,
824
- 5897,
825
- 5903,
826
- 5923,
827
- 5927,
828
- 5939,
829
- 5953,
830
- 5981,
831
- 5987,
832
- 6007,
833
- 6011,
834
- 6029,
835
- 6037,
836
- 6043,
837
- 6047,
838
- 6053,
839
- 6067,
840
- 6073,
841
- 6079,
842
- 6089,
843
- 6091,
844
- 6101,
845
- 6113,
846
- 6121,
847
- 6131,
848
- 6133,
849
- 6143,
850
- 6151,
851
- 6163,
852
- 6173,
853
- 6197,
854
- 6199,
855
- 6203,
856
- 6211,
857
- 6217,
858
- 6221,
859
- 6229,
860
- 6247,
861
- 6257,
862
- 6263,
863
- 6269,
864
- 6271,
865
- 6277,
866
- 6287,
867
- 6299,
868
- 6301,
869
- 6311,
870
- 6317,
871
- 6323,
872
- 6329,
873
- 6337,
874
- 6343,
875
- 6353,
876
- 6359,
877
- 6361,
878
- 6367,
879
- 6373,
880
- 6379,
881
- 6389,
882
- 6397,
883
- 6421,
884
- 6427,
885
- 6449,
886
- 6451,
887
- 6469,
888
- 6473,
889
- 6481,
890
- 6491,
891
- 6521,
892
- 6529,
893
- 6547,
894
- 6551,
895
- 6553,
896
- 6563,
897
- 6569,
898
- 6571,
899
- 6577,
900
- 6581,
901
- 6599,
902
- 6607,
903
- 6619,
904
- 6637,
905
- 6653,
906
- 6659,
907
- 6661,
908
- 6673,
909
- 6679,
910
- 6689,
911
- 6691,
912
- 6701,
913
- 6703,
914
- 6709,
915
- 6719,
916
- 6733,
917
- 6737,
918
- 6761,
919
- 6763,
920
- 6779,
921
- 6781,
922
- 6791,
923
- 6793,
924
- 6803,
925
- 6823,
926
- 6827,
927
- 6829,
928
- 6833,
929
- 6841,
930
- 6857,
931
- 6863,
932
- 6869,
933
- 6871,
934
- 6883,
935
- 6899,
936
- 6907,
937
- 6911,
938
- 6917,
939
- 6947,
940
- 6949,
941
- 6959,
942
- 6961,
943
- 6967,
944
- 6971,
945
- 6977,
946
- 6983,
947
- 6991,
948
- 6997,
949
- 7001,
950
- 7013,
951
- 7019,
952
- 7027,
953
- 7039,
954
- 7043,
955
- 7057,
956
- 7069,
957
- 7079,
958
- 7103,
959
- 7109,
960
- 7121,
961
- 7127,
962
- 7129,
963
- 7151,
964
- 7159,
965
- 7177,
966
- 7187,
967
- 7193,
968
- 7207,
969
- 7211,
970
- 7213,
971
- 7219,
972
- 7229,
973
- 7237,
974
- 7243,
975
- 7247,
976
- 7253,
977
- 7283,
978
- 7297,
979
- 7307,
980
- 7309,
981
- 7321,
982
- 7331,
983
- 7333,
984
- 7349,
985
- 7351,
986
- 7369,
987
- 7393,
988
- 7411,
989
- 7417,
990
- 7433,
991
- 7451,
992
- 7457,
993
- 7459,
994
- 7477,
995
- 7481,
996
- 7487,
997
- 7489,
998
- 7499,
999
- 7507,
1000
- 7517,
1001
- 7523,
1002
- 7529,
1003
- 7537,
1004
- 7541,
1005
- 7547,
1006
- 7549,
1007
- 7559,
1008
- 7561,
1009
- 7573,
1010
- 7577,
1011
- 7583,
1012
- 7589,
1013
- 7591,
1014
- 7603,
1015
- 7607,
1016
- 7621,
1017
- 7639,
1018
- 7643,
1019
- 7649,
1020
- 7669,
1021
- 7673,
1022
- 7681,
1023
- 7687,
1024
- 7691,
1025
- 7699,
1026
- 7703,
1027
- 7717,
1028
- 7723,
1029
- 7727,
1030
- 7741,
1031
- 7753,
1032
- 7757,
1033
- 7759,
1034
- 7789,
1035
- 7793,
1036
- 7817,
1037
- 7823,
1038
- 7829,
1039
- 7841,
1040
- 7853,
1041
- 7867,
1042
- 7873,
1043
- 7877,
1044
- 7879,
1045
- 7883,
1046
- 7901,
1047
- 7907,
1048
- 7919,
1049
- 7927,
1050
- 7933,
1051
- 7937,
1052
- 7949,
1053
- 7951,
1054
- 7963,
1055
- 7993,
1056
- 8009,
1057
- 8011,
1058
- 8017,
1059
- 8039,
1060
- 8053,
1061
- 8059,
1062
- 8069,
1063
- 8081,
1064
- 8087,
1065
- 8089,
1066
- 8093,
1067
- 8101,
1068
- 8111,
1069
- 8117,
1070
- 8123,
1071
- 8147,
1072
- 8161,
1073
- 8167,
1074
- 8171,
1075
- 8179,
1076
- 8191,
1077
- 8209,
1078
- 8219,
1079
- 8221,
1080
- 8231,
1081
- 8233,
1082
- 8237,
1083
- 8243,
1084
- 8263,
1085
- 8269,
1086
- 8273,
1087
- 8287,
1088
- 8291,
1089
- 8293,
1090
- 8297,
1091
- 8311,
1092
- 8317,
1093
- 8329,
1094
- 8353,
1095
- 8363,
1096
- 8369,
1097
- 8377,
1098
- 8387,
1099
- 8389,
1100
- 8419,
1101
- 8423,
1102
- 8429,
1103
- 8431,
1104
- 8443,
1105
- 8447,
1106
- 8461,
1107
- 8467,
1108
- 8501,
1109
- 8513,
1110
- 8521,
1111
- 8527,
1112
- 8537,
1113
- 8539,
1114
- 8543,
1115
- 8563,
1116
- 8573,
1117
- 8581,
1118
- 8597,
1119
- 8599,
1120
- 8609,
1121
- 8623,
1122
- 8627,
1123
- 8629,
1124
- 8641,
1125
- 8647,
1126
- 8663,
1127
- 8669,
1128
- 8677,
1129
- 8681,
1130
- 8689,
1131
- 8693,
1132
- 8699,
1133
- 8707,
1134
- 8713,
1135
- 8719,
1136
- 8731,
1137
- 8737,
1138
- 8741,
1139
- 8747,
1140
- 8753,
1141
- 8761,
1142
- 8779,
1143
- 8783,
1144
- 8803,
1145
- 8807,
1146
- 8819,
1147
- 8821,
1148
- 8831,
1149
- 8837,
1150
- 8839,
1151
- 8849,
1152
- 8861,
1153
- 8863,
1154
- 8867,
1155
- 8887,
1156
- 8893,
1157
- 8923,
1158
- 8929,
1159
- 8933,
1160
- 8941,
1161
- 8951,
1162
- 8963,
1163
- 8969,
1164
- 8971,
1165
- 8999,
1166
- 9001,
1167
- 9007,
1168
- 9011,
1169
- 9013,
1170
- 9029,
1171
- 9041,
1172
- 9043,
1173
- 9049,
1174
- 9059,
1175
- 9067,
1176
- 9091,
1177
- 9103,
1178
- 9109,
1179
- 9127,
1180
- 9133,
1181
- 9137,
1182
- 9151,
1183
- 9157,
1184
- 9161,
1185
- 9173,
1186
- 9181,
1187
- 9187,
1188
- 9199,
1189
- 9203,
1190
- 9209,
1191
- 9221,
1192
- 9227,
1193
- 9239,
1194
- 9241,
1195
- 9257,
1196
- 9277,
1197
- 9281,
1198
- 9283,
1199
- 9293,
1200
- 9311,
1201
- 9319,
1202
- 9323,
1203
- 9337,
1204
- 9341,
1205
- 9343,
1206
- 9349,
1207
- 9371,
1208
- 9377,
1209
- 9391,
1210
- 9397,
1211
- 9403,
1212
- 9413,
1213
- 9419,
1214
- 9421,
1215
- 9431,
1216
- 9433,
1217
- 9437,
1218
- 9439,
1219
- 9461,
1220
- 9463,
1221
- 9467,
1222
- 9473,
1223
- 9479,
1224
- 9491,
1225
- 9497,
1226
- 9511,
1227
- 9521,
1228
- 9533,
1229
- 9539,
1230
- 9547,
1231
- 9551,
1232
- 9587,
1233
- 9601,
1234
- 9613,
1235
- 9619,
1236
- 9623,
1237
- 9629,
1238
- 9631,
1239
- 9643,
1240
- 9649,
1241
- 9661,
1242
- 9677,
1243
- 9679,
1244
- 9689,
1245
- 9697,
1246
- 9719,
1247
- 9721,
1248
- 9733,
1249
- 9739,
1250
- 9743,
1251
- 9749,
1252
- 9767,
1253
- 9769,
1254
- 9781,
1255
- 9787,
1256
- 9791,
1257
- 9803,
1258
- 9811,
1259
- 9817,
1260
- 9829,
1261
- 9833,
1262
- 9839,
1263
- 9851,
1264
- 9857,
1265
- 9859,
1266
- 9871,
1267
- 9883,
1268
- 9887,
1269
- 9901,
1270
- 9907,
1271
- 9923,
1272
- 9929,
1273
- 9931,
1274
- 9941,
1275
- 9949,
1276
- 9967,
1277
- 9973
1278
- ];
1279
- return e === void 0 ? t : t.slice(0, Math.min(t.length, e));
1280
- }
1281
- function re(e, t) {
1282
- let n = [], r = t === !0 ? +e : e ** 2;
1283
- for (let t = 0; t <= e; t++) for (let i = 0; i <= e; i++) t ** 2 + i ** 2 === r && n.push([
54
+ function ie(e, t) {
55
+ let n = t === !0 ? e : e ** 2, r = t === !0 ? Math.sqrt(e) : e, i = [];
56
+ for (let e = 0; e <= r; e++) for (let t = 0; t <= r; t++) e ** 2 + t ** 2 === n && i.push([
57
+ e,
1284
58
  t,
1285
- i,
1286
- e
59
+ r
1287
60
  ]);
1288
- return n;
61
+ return i;
1289
62
  }
1290
- function ie(e, t = 2) {
1291
- let n = Math.round(Number(`${e}e${t}`));
1292
- return Number(`${n}e-${t}`);
63
+ function ae(e, t = 2) {
64
+ let n = Math.trunc(t), r = Math.round(Number(`${e}e${n}`));
65
+ return Number(`${r}e${-n}`);
1293
66
  }
1294
- function ae(e, t) {
1295
- let n = Math.floor(e ** (1 / t)), r = e;
67
+ function m(e, t) {
68
+ if (t <= 0) return 1;
69
+ if (e < 0) return t % 2 == 1 ? -m(-e, t) : 1;
70
+ let n = Math.floor(e ** (1 / t));
1296
71
  for (; n > 1;) {
1297
- let e = n ** +t;
1298
- if (r % e === 0) return e;
72
+ let r = n ** +t;
73
+ if (e % r === 0) return r;
1299
74
  n--;
1300
75
  }
1301
76
  return 1;
1302
77
  }
1303
- var p = {
1304
- decompose: c,
1305
- dividers: u,
1306
- divideNumbersByGCD: l,
1307
- gcd: d,
1308
- lcm: f,
1309
- numberCorrection: ee,
1310
- periodic: te,
1311
- primes: ne,
1312
- pythagoreanTripletsWithTarget: re,
1313
- round: ie,
1314
- greatestPower: ae
1315
- }, oe = /* @__PURE__ */ function(e) {
78
+ function h(e, t) {
79
+ if (t <= 0) return NaN;
80
+ if (e < 0) return t % 2 == 1 ? -h(-e, t) : NaN;
81
+ let n = e ** (1 / t), r = Math.round(n);
82
+ return r ** +t === e ? r : n;
83
+ }
84
+ var g = Object.freeze({
85
+ decompose: d,
86
+ dividers: ee,
87
+ divideNumbersByGCD: f,
88
+ gcd: p,
89
+ lcm: te,
90
+ numberCorrection: ne,
91
+ primes: re,
92
+ pythagoreanTripletsWithTarget: ie,
93
+ round: ae,
94
+ greatestPower: m,
95
+ nthRoot: h
96
+ }), oe = /* @__PURE__ */ function(e) {
1316
97
  return e.frac = "frac", e.dfrac = "dfrac", e.tfrac = "tfrac", e;
1317
- }({}), m = class e {
98
+ }({}), _ = class e {
1318
99
  #e = 1;
1319
100
  #t = 3;
1320
101
  #n = !0;
@@ -1324,11 +105,13 @@ var p = {
1324
105
  constructor(e, t) {
1325
106
  return e !== void 0 && this.parse(e, t), this;
1326
107
  }
1327
- parse = (t, n) => t === "" ? (this.#r = 0, this.#e = 1, this) : typeof t == "number" && isNaN(t) ? this.invalid() : typeof t == "number" && !isFinite(t) ? (this.infinite(), t < 0 && this.opposite(), this) : typeof t == "string" ? this.fromString(t) : typeof t == "number" && n === void 0 ? this.fromNumber(t) : typeof t == "number" && typeof n == "number" ? this.fromNumbers(t, n) : t instanceof e ? this.copy(t) : this;
1328
- clone = () => {
108
+ parse(t, n) {
109
+ return t === "" ? (this.#r = 0, this.#e = 1, this) : typeof t == "number" && isNaN(t) ? this.invalid() : typeof t == "number" && !isFinite(t) ? (this.infinite(), t < 0 && this.opposite(), this) : typeof t == "string" ? this.fromString(t) : typeof t == "number" && n === void 0 ? this.fromNumber(t) : typeof t == "number" && typeof n == "number" ? this.fromNumbers(t, n) : t instanceof e ? this.copy(t) : this;
110
+ }
111
+ clone() {
1329
112
  let t = new e();
1330
113
  return t.numerator = this.#r, t.denominator = this.#e, t.exact = this.exact, t.#i = this.#i, t.#t = this.#t, t.#a = this.#a, t;
1331
- };
114
+ }
1332
115
  copy(e) {
1333
116
  return this.#r = e.numerator, this.#e = e.denominator, this.#n = e.exact, this;
1334
117
  }
@@ -1342,12 +125,14 @@ var p = {
1342
125
  let e = this.#a && this.isPositive() ? "+" : "";
1343
126
  return this.exact ? this.#e === 1 ? `${e}${this.#r}` : `${e}${this.#r}/${this.#e}` : e + this.value.toFixed(this.#t);
1344
127
  }
1345
- static areEquals = (...e) => e.every((t) => t.isEqual(e[0]));
1346
- static average = (...t) => {
128
+ static areEquals(...e) {
129
+ return e.every((t) => t.isEqual(e[0]));
130
+ }
131
+ static average(...t) {
1347
132
  let n = new e().zero();
1348
133
  for (let e of t) n.add(e);
1349
134
  return n.divide(t.length), n;
1350
- };
135
+ }
1351
136
  static isFraction(t) {
1352
137
  if (t instanceof e || typeof t == "number" && !isNaN(t)) return !0;
1353
138
  if (typeof t == "string") {
@@ -1356,53 +141,56 @@ var p = {
1356
141
  }
1357
142
  return !1;
1358
143
  }
1359
- static max = (...t) => {
144
+ static max(...t) {
1360
145
  let n = new e(t[0]);
1361
146
  for (let r of t) {
1362
147
  let t = new e(r);
1363
148
  t.isGreater(n) && (n = t.clone());
1364
149
  }
1365
150
  return n;
1366
- };
1367
- static min = (...t) => {
151
+ }
152
+ static min(...t) {
1368
153
  let n = new e(t[0]);
1369
154
  for (let r of t) {
1370
155
  let t = new e(r);
1371
156
  t.isLesser(n) && (n = t.clone());
1372
157
  }
1373
158
  return n;
1374
- };
1375
- static sort = (t, n) => {
159
+ }
160
+ static sort(t, n) {
1376
161
  let r = t.map((t) => t instanceof e ? t : new e(t)).sort((e, t) => e.value - t.value);
1377
162
  return n && r.reverse(), r;
1378
- };
163
+ }
1379
164
  static toSameDenominateur(...t) {
1380
- let n = t.map((t) => new e(t)), r = p.lcm(...n.map((e) => e.denominator));
165
+ let n = t.map((t) => new e(t)), r = g.lcm(...n.map((e) => e.denominator));
1381
166
  return n.forEach((e) => e.amplify(r / e.denominator)), n;
1382
167
  }
1383
- static unique = (t) => {
168
+ static unique(t) {
1384
169
  let n = {}, r = [];
1385
170
  return t.forEach((t) => {
1386
171
  t instanceof e || (t = new e(t)), n[t.clone().reduce().tex] || (r.push(t.clone()), n[t.clone().reduce().tex] = !0);
1387
172
  }), r;
1388
- };
1389
- static xMultiply = (...t) => {
173
+ }
174
+ static xMultiply(...t) {
1390
175
  let n = new e();
1391
176
  return t.forEach((e) => n.multiply(e, !1)), n;
1392
- };
1393
- abs = () => (this.#r = Math.abs(this.#r), this.#e = Math.abs(this.#e), this);
1394
- add = (t) => {
177
+ }
178
+ abs() {
179
+ return this.#r = Math.abs(this.#r), this.#e = Math.abs(this.#e), this;
180
+ }
181
+ add(t) {
1395
182
  if (t instanceof e) {
1396
183
  let e = this.#r, n = this.#e;
1397
184
  this.#r = e * t.denominator + t.numerator * n, this.#e = n * t.denominator, this.exact = this.exact && t.exact;
1398
185
  } else return this.add(new e(t));
1399
186
  return this.reduce();
1400
- };
1401
- amplify = (e) => {
187
+ }
188
+ amplify(e) {
1402
189
  if (!Number.isSafeInteger(e)) throw new i("The amplification factor must be a safe integer.");
190
+ if (e === 0) throw new i("The amplification factor cannot be zero.");
1403
191
  return this.#r *= e, this.#e *= e, this;
1404
- };
1405
- compare = (t, n) => {
192
+ }
193
+ compare(t, n) {
1406
194
  n ??= "=";
1407
195
  let r;
1408
196
  switch (r = t instanceof e ? t.clone() : new e(t), n) {
@@ -1418,122 +206,228 @@ var p = {
1418
206
  case "<>": return this.#r * r.denominator !== r.numerator * this.#e;
1419
207
  default: return !1;
1420
208
  }
1421
- };
209
+ }
1422
210
  get denominator() {
1423
211
  return this.#e;
1424
212
  }
1425
213
  set denominator(e) {
1426
214
  this.#e = e;
1427
215
  }
1428
- get dfrac() {
216
+ get asDfrac() {
1429
217
  return this.#i = "dfrac", this;
1430
218
  }
1431
219
  digits(e) {
1432
220
  return this.#t = e, this;
1433
221
  }
1434
- divide = (t) => {
222
+ divide(t) {
1435
223
  let n = new e(t);
1436
- if (n.numerator === 0) return this.infinite();
224
+ if (n.numerator === 0) {
225
+ let e = this.sign();
226
+ return this.infinite(), e === -1 ? this.opposite() : this;
227
+ }
1437
228
  let r = this.#r, i = this.#e;
1438
229
  return this.#r = r * n.denominator, this.#e = i * n.numerator, this.exact = this.exact && n.exact, this.reduce();
1439
- };
230
+ }
1440
231
  get exact() {
1441
232
  return this.#n;
1442
233
  }
1443
234
  set exact(e) {
1444
235
  this.#n = e;
1445
236
  }
1446
- get frac() {
237
+ get asFrac() {
1447
238
  return this.#i = "frac", this;
1448
239
  }
1449
240
  fromNumber(e) {
1450
241
  if (Number.isSafeInteger(e)) return this.#r = e, this.#e = 1, this.#n = !0, this;
242
+ if (e.toString().includes("e") || e.toString().includes("E")) throw new i(`Exponential notation is not supported: ${e}`);
1451
243
  let [, t] = e.toString().split("."), n = t ? t.length : 0, r = 10 ** n;
1452
- return this.#r = e * r, this.#e = r, this.#r = p.numberCorrection(this.#r), this.#e = p.numberCorrection(this.#e), this.reduce(), this.#n = n < 10, this;
244
+ return this.#r = e * r, this.#e = r, this.#r = g.numberCorrection(this.#r), this.#e = g.numberCorrection(this.#e), this.reduce(), this.#n = n < 10, this;
1453
245
  }
1454
246
  fromNumbers(e, t) {
1455
- return Number.isSafeInteger(e) && Number.isSafeInteger(t) ? (this.#r = e, this.#e = t, this.#n = !0, this) : this.fromNumber(e / t);
247
+ return t === 0 ? e === 0 ? this.invalid() : e < 0 ? this.infinite().opposite() : this.infinite() : Number.isSafeInteger(e) && Number.isSafeInteger(t) ? (this.#r = e, this.#e = t, this.#n = !0, this) : this.fromNumber(e / t);
1456
248
  }
1457
249
  fromPeriodic(e, t) {
1458
250
  let [, n] = e.toString().split(/[.,]/), r = n ? n.length : 0;
1459
251
  if (!Number.isSafeInteger(t) || t <= 0) throw new i("The periodic length must be a positive integer.");
1460
252
  if (t > r) throw new i(`The periodic length (${t}) cannot exceed the number of decimal digits (${r}).`);
1461
- let a = 10 ** r;
1462
- return this.#r = +e * a - Math.floor(e * 10 ** (r - t)), this.#e = a - 10 ** (r - t), this.#n = !0, this;
253
+ let a = 10 ** r, o = 10 ** (r - t), s = +e, c = s < 0 ? -1 : 1, l = Math.abs(s);
254
+ return this.#r = c * Math.round(l * a - Math.floor(l * o)), this.#e = a - o, this.#n = !0, this.reduce();
1463
255
  }
1464
256
  fromString(e) {
1465
- let t = e.split("/").map(Number);
1466
- return this.#n = !0, t.length > 2 || t.some((e) => isNaN(e)) ? (this.#r = NaN, this) : t.length === 1 ? this.fromNumber(+e) : t[1] === 0 ? this.infinite() : (this.#r = t[0], this.#e = t[1], this);
257
+ let t = /^([+-]?)(\d*)\.(\d*)\((\d+)\)$/.exec(e);
258
+ if (t) {
259
+ let [, e, n, r, i] = t, a = `${n || "0"}.${r}${i}`;
260
+ return this.fromPeriodic(a, i.length), e === "-" && this.opposite(), this.reduce();
261
+ }
262
+ if (e.includes("(") || e.includes(")")) return this.invalid();
263
+ let n = e.split("/").map(Number);
264
+ return this.#n = !0, n.length > 2 || n.some((e) => isNaN(e)) ? (this.#r = NaN, this) : n.length === 1 ? this.fromNumber(+e) : this.fromNumbers(n[0], n[1]);
1467
265
  }
1468
- infinite = () => (this.#r = Infinity, this.#e = 1, this.exact = !0, this);
1469
- invalid = () => (this.#r = NaN, this.#e = 1, this.exact = !0, this);
1470
- inverse = () => {
266
+ infinite() {
267
+ return this.#r = Infinity, this.#e = 1, this.exact = !0, this;
268
+ }
269
+ invalid() {
270
+ return this.#r = NaN, this.#e = 1, this.exact = !0, this;
271
+ }
272
+ inverse() {
1471
273
  let e = this.sign(), t = Math.abs(this.#r);
1472
274
  return this.#r = Math.abs(this.#e) * e, this.#e = t, this;
1473
- };
1474
- isEqual = (e) => this.compare(e, "=");
1475
- isEven = () => this.isRelative() && this.value % 2 == 0;
1476
- isFinite = () => !this.isInfinity() && !this.isNaN();
1477
- isGeq = (e) => this.compare(e, ">=");
1478
- isGreater = (e) => this.compare(e, ">");
1479
- isInfinity = () => Math.abs(this.#r) === Infinity;
1480
- isLeq = (e) => this.compare(e, "<=");
1481
- isLesser = (e) => this.compare(e, "<");
1482
- isNaN = () => isNaN(this.#r);
1483
- isNatural = () => this.isRelative() && this.isPositive();
1484
- isNegative = () => this.sign() === -1;
1485
- isNotEqual = (e) => this.compare(e, "<>");
1486
- isNotZero = () => this.#r !== 0;
1487
- isOdd = () => this.isRelative() && Math.abs(this.value % 2) === 1;
1488
- isOne = () => this.#r === 1 && this.#e === 1;
1489
- isPositive = () => this.sign() === 1;
1490
- isRational = () => this.exact && !this.isRelative();
1491
- isReduced = () => Math.abs(p.gcd(this.#r, this.#e)) === 1;
1492
- isRelative = () => this.exact && this.clone().reduce().denominator === 1;
1493
- isSquare = () => Math.sqrt(this.#r) % 1 == 0 && Math.sqrt(this.#e) % 1 == 0;
1494
- isStrictlyNegative = () => this.value < 0;
1495
- isStrictlyPositive = () => this.value > 0;
275
+ }
276
+ isEqual(e) {
277
+ return this.compare(e, "=");
278
+ }
279
+ isEven() {
280
+ return this.isRelative() && this.value % 2 == 0;
281
+ }
282
+ isFinite() {
283
+ return !this.isInfinity() && !this.isNaN();
284
+ }
285
+ isGeq(e) {
286
+ return this.compare(e, ">=");
287
+ }
288
+ isGreater(e) {
289
+ return this.compare(e, ">");
290
+ }
291
+ isInfinity() {
292
+ return Math.abs(this.#r) === Infinity;
293
+ }
294
+ isLeq(e) {
295
+ return this.compare(e, "<=");
296
+ }
297
+ isLesser(e) {
298
+ return this.compare(e, "<");
299
+ }
300
+ isNaN() {
301
+ return isNaN(this.#r);
302
+ }
303
+ isNatural() {
304
+ return this.isRelative() && this.isPositive();
305
+ }
306
+ isNegative() {
307
+ return this.sign() === -1;
308
+ }
309
+ isNotEqual(e) {
310
+ return this.compare(e, "<>");
311
+ }
312
+ isNotZero() {
313
+ return this.#r !== 0;
314
+ }
315
+ isOdd() {
316
+ return this.isRelative() && Math.abs(this.value % 2) === 1;
317
+ }
318
+ isOne() {
319
+ return this.#r === 1 && this.#e === 1;
320
+ }
321
+ isPeriodic() {
322
+ if (!this.exact || !this.isFinite()) return !1;
323
+ let e = Math.abs(this.clone().reduce().denominator);
324
+ for (; e % 2 == 0;) e /= 2;
325
+ for (; e % 5 == 0;) e /= 5;
326
+ return e !== 1;
327
+ }
328
+ isPositive() {
329
+ return this.sign() === 1;
330
+ }
331
+ isRational() {
332
+ return this.exact && this.isFinite();
333
+ }
334
+ hasFractionalPart() {
335
+ return this.exact && !this.isRelative();
336
+ }
337
+ isReduced() {
338
+ return Math.abs(g.gcd(this.#r, this.#e)) === 1;
339
+ }
340
+ isRelative() {
341
+ return this.exact && this.clone().reduce().denominator === 1;
342
+ }
343
+ isSquare() {
344
+ let e = this.clone().reduce();
345
+ if (e.isNegative()) return !1;
346
+ let t = Math.abs(e.numerator), n = Math.abs(e.denominator), r = Math.round(Math.sqrt(t)), i = Math.round(Math.sqrt(n));
347
+ return r * r === t && i * i === n;
348
+ }
349
+ isStrictlyNegative() {
350
+ return this.value < 0;
351
+ }
352
+ isStrictlyPositive() {
353
+ return this.value > 0;
354
+ }
1496
355
  isUnit() {
1497
356
  return Math.abs(this.#r) === 1 && this.#e === 1;
1498
357
  }
1499
- isZero = () => this.#r === 0;
1500
- multiply = (t, n = !0) => {
358
+ isZero() {
359
+ return this.#r === 0;
360
+ }
361
+ multiply(t, n = !0) {
1501
362
  let r = new e(t);
1502
363
  return this.#r *= r.numerator, this.#e *= r.denominator, this.exact = this.exact && r.exact, n ? this.reduce() : this;
1503
- };
364
+ }
1504
365
  get numerator() {
1505
366
  return this.#r;
1506
367
  }
1507
368
  set numerator(e) {
1508
369
  this.#r = e;
1509
370
  }
1510
- one = () => this.fromNumber(1);
1511
- opposite = () => (this.#r = -this.#r, this);
1512
- pow = (t) => {
371
+ one() {
372
+ return this.fromNumber(1);
373
+ }
374
+ opposite() {
375
+ return this.#r = -this.#r, this;
376
+ }
377
+ pow(t) {
1513
378
  if (t instanceof e) return this.pow(t.value);
1514
379
  this.reduce(), t < 0 && this.inverse();
1515
- let n = Math.abs(t), r = this.#r ** +n, i = this.#e ** +n, a = Math.floor(r), o = Math.floor(i);
1516
- return a === r && o === i ? (this.#r = a, this.#e = o) : (this.#r = r / i, this.#e = 1, this.exact = !1), this;
1517
- };
1518
- reduce = () => {
1519
- let e = p.gcd(this.#r, this.#e);
380
+ let n = Math.abs(t);
381
+ if (Number.isInteger(n)) return this.#r = Math.round(this.#r ** +n), this.#e = Math.round(this.#e ** +n), this;
382
+ let r = Math.round(this.#r ** +n), i = Math.round(this.#e ** +n);
383
+ return Math.round(r ** (1 / n)) === this.#r && Math.round(i ** (1 / n)) === this.#e ? (this.#r = r, this.#e = i) : (this.#r = this.#r ** +n / this.#e ** +n, this.#e = 1, this.exact = !1), this;
384
+ }
385
+ reduce() {
386
+ let e = g.gcd(this.#r, this.#e);
1520
387
  return this.#r /= e, this.#e /= e, this.#e < 0 && (this.#e = -this.#e, this.#r = -this.#r), this;
1521
- };
1522
- root = (e) => {
388
+ }
389
+ root(e) {
1523
390
  if (e === 0) return this;
1524
391
  if (!Number.isSafeInteger(e)) throw new i("The root must be an integer.");
1525
- if (e < 0 && this.inverse(), this.isNegative() && e % 2 == 0) throw new r("The root of a negative number must be odd.");
392
+ if (this.isNegative() && e % 2 == 0) throw new r("The root of a negative number must be odd.");
393
+ e < 0 && this.inverse();
1526
394
  let t = this.sign();
1527
395
  this.abs(), this.reduce();
1528
- let n = Math.floor(this.#r ** +Math.abs(1 / e)), a = Math.floor(this.#e ** +Math.abs(1 / e));
1529
- return this.#r **= +Math.abs(1 / e), this.#e **= +Math.abs(1 / e), (n !== this.#r || a !== this.#e) && (this.#r /= this.#e, this.#e = 1, this.exact = !1), this.multiply(t), this;
1530
- };
1531
- sign = () => this.#r * this.#e >= 0 ? 1 : -1;
1532
- sqrt = () => this.root(2);
1533
- subtract = (t) => t instanceof e ? this.add(t.clone().opposite()) : this.add(-t);
1534
- get tfrac() {
396
+ let n = Math.abs(e), a = Math.round(this.#r ** (1 / n)), o = Math.round(this.#e ** (1 / n));
397
+ return a ** +n === this.#r && o ** +n === this.#e ? (this.#r = a, this.#e = o) : (this.#r = this.#r ** (1 / n) / this.#e ** (1 / n), this.#e = 1, this.exact = !1), this.multiply(t), this;
398
+ }
399
+ sign() {
400
+ return this.#r * this.#e >= 0 ? 1 : -1;
401
+ }
402
+ sqrt() {
403
+ return this.root(2);
404
+ }
405
+ subtract(t) {
406
+ return t instanceof e ? this.add(t.clone().opposite()) : this.add(-t);
407
+ }
408
+ get asTfrac() {
1535
409
  return this.#i = "tfrac", this;
1536
410
  }
411
+ toRepeatingDecimal() {
412
+ if (!this.exact || !this.isFinite()) throw new i("Cannot decompose a non-exact or infinite fraction.");
413
+ let e = this.clone().reduce(), t = e.sign(), n = Math.abs(e.numerator), r = Math.abs(e.denominator), a = Math.floor(n / r).toString(), o = n % r, s = [], c = /* @__PURE__ */ new Map(), l = -1;
414
+ for (; o !== 0;) {
415
+ let e = c.get(o);
416
+ if (e !== void 0) {
417
+ l = e;
418
+ break;
419
+ }
420
+ c.set(o, s.length), o *= 10, s.push(Math.floor(o / r)), o %= r;
421
+ }
422
+ let u = (l === -1 ? s : s.slice(0, l)).join(""), d = l === -1 ? "" : s.slice(l).join("");
423
+ return {
424
+ sign: t,
425
+ integerPart: a,
426
+ nonPeriodic: u,
427
+ periodic: d,
428
+ periodLength: d.length
429
+ };
430
+ }
1537
431
  get value() {
1538
432
  let e = this.#r / this.#e;
1539
433
  return e === 0 ? 0 : e;
@@ -1544,70 +438,52 @@ var p = {
1544
438
  get withoutSign() {
1545
439
  return this.#a = !1, this;
1546
440
  }
1547
- zero = () => this.fromNumber(0);
1548
- };
1549
- //#endregion
1550
- //#region src/helpers.ts
1551
- function se(e, t = !0) {
1552
- return t ? `\\left( ${e} \\right)` : `(${e})`;
1553
- }
1554
- function h(e) {
1555
- if (!e.startsWith("(") || !e.endsWith(")")) return e;
1556
- let t = 0;
1557
- for (let n = 0; n < e.length - 1; n++) if (e[n] === "(" ? t++ : e[n] === ")" && t--, t === 0) return e;
1558
- return e.slice(1, -1);
1559
- }
1560
- function g(e, t, n, r, i) {
1561
- return e.map((e, a) => r !== void 0 && a < r || i !== void 0 && a > i ? e : e === t ? n : e);
1562
- }
1563
- function _(e, t) {
1564
- if (t.length !== 1) throw new i(`splitChar must be a single character, got: "${t}"`);
1565
- let n = 0, r = 0, a = [];
1566
- for (let i = 0; i < e.length; i++) {
1567
- let o = e[i];
1568
- o === "(" ? n++ : o === ")" ? n-- : o === t && n === 0 && (a.push(e.substring(r, i)), r = i + 1);
441
+ zero() {
442
+ return this.fromNumber(0);
1569
443
  }
1570
- return a.push(e.substring(r)), a;
1571
- }
1572
- //#endregion
1573
- //#region src/coefficients/root.ts
1574
- var v = class e {
444
+ }, v = class e {
1575
445
  #e;
1576
446
  #t;
1577
447
  #n;
1578
448
  #r = !1;
1579
449
  constructor(e) {
1580
- return this.#t = 2, this.#e = new m().zero(), this.#n = new m().zero(), e && this.parse(e), this;
450
+ return this.#t = 2, this.#e = new _().zero(), this.#n = new _().zero(), e !== void 0 && this.parse(e), this;
1581
451
  }
1582
452
  parse(t) {
1583
- if (t instanceof e) return this.index = t.index, this.radical = t.radical.clone(), this.factor = t.factor.clone(), this;
1584
- if (t instanceof m) return this.index = 2, this.factor = t.clone(), this.radical.one(), this;
1585
- if (typeof t == "string") {
1586
- if (t.includes("sqrt")) return this.#s(t);
1587
- if (t.includes("root")) return this.#o(t);
1588
- }
1589
- return this.index = 2, this.factor = new m(t), this.radical.one(), this;
453
+ return t instanceof e ? this.copy(t) : t instanceof _ ? this.fromFraction(t) : typeof t == "string" ? this.fromString(t) : this.#i(t);
454
+ }
455
+ copy(e) {
456
+ return this.index = e.index, this.radical = e.radical.clone(), this.factor = e.factor.clone(), this;
457
+ }
458
+ fromFraction(e) {
459
+ return this.index = 2, this.factor = e.clone(), this.radical.one(), this;
460
+ }
461
+ fromString(e) {
462
+ return e.includes("sqrt") ? this.#f(e) : e.includes("root") ? this.#d(e) : this.#i(e);
463
+ }
464
+ #i(e) {
465
+ let n = new _(e);
466
+ if (n.isNaN()) throw new t(`Cannot parse "${e}" as a root or fraction`);
467
+ return this.index = 2, this.factor = n, this.radical.one(), this;
1590
468
  }
1591
469
  clone() {
1592
- return new e().from(this.index, this.radical, this.factor);
470
+ let t = new e().from(this.index, this.radical, this.factor);
471
+ return t.#r = this.#r, t;
1593
472
  }
1594
473
  get tex() {
1595
474
  let e = this.#r && this.factor.isPositive() ? "+" : "", t = e && this.#e.numerator === 1 ? " " : "";
1596
- if (this.value === 0) return `${e}0`;
1597
- let n = this.#a(this.#e.denominator, this.#n.denominator), r = this.#a(this.#e.numerator, this.#n.numerator) ?? "1";
475
+ if (this.isZero()) return `${e}0`;
476
+ let n = this.#l(this.#e.denominator, this.#n.denominator), r = this.#l(this.#e.numerator, this.#n.numerator) ?? "1";
1598
477
  return n === null ? `${e}${t}${r}` : `${e}${t}\\frac{ ${r} }{ ${n} }`;
1599
478
  }
1600
479
  get display() {
1601
480
  let e = this.#r && this.factor.isPositive() ? "+" : "";
1602
- if (this.value === 0) return `${e}0`;
1603
- let t = this.#i(this.#e.denominator, this.#n.denominator, !0), n = this.#i(this.#e.numerator, this.#n.numerator, t !== null) ?? "1";
481
+ if (this.isZero()) return `${e}0`;
482
+ let t = this.#c(this.#e.denominator, this.#n.denominator, !0), n = this.#c(this.#e.numerator, this.#n.numerator, t !== null) ?? "1";
1604
483
  return t === null ? `${e}${n}` : `${e}${n}/${t}`;
1605
484
  }
1606
- add(t) {
1607
- this.reduce();
1608
- let n = new e(t).reduce();
1609
- if (this.index !== n.index || !this.radical.isEqual(n.radical)) throw new r("Add can only be done with two same index and radical");
1610
- return this.factor.add(n.factor), this;
485
+ add(e) {
486
+ return this.#s(e, !1);
1611
487
  }
1612
488
  divide(t) {
1613
489
  return this.multiply(new e(t).inverse());
@@ -1618,8 +494,17 @@ var v = class e {
1618
494
  set factor(e) {
1619
495
  this.#e = e;
1620
496
  }
1621
- from(e, t, n) {
1622
- return this.index = e, this.radical = new m(t), this.factor = n ? new m(n) : new m().one(), this;
497
+ from(e, n, r) {
498
+ this.index = e;
499
+ let i = new _(n);
500
+ if (i.isNaN()) throw new t(`Cannot build a root from an invalid radical: "${n}"`);
501
+ if (this.radical = i, r === void 0) this.factor = new _().one();
502
+ else {
503
+ let e = new _(r);
504
+ if (e.isNaN()) throw new t(`Cannot build a root from an invalid factor: "${r}"`);
505
+ this.factor = e;
506
+ }
507
+ return this;
1623
508
  }
1624
509
  group() {
1625
510
  return this.radical.multiply(this.factor.pow(this.index)), this.factor.one(), this;
@@ -1632,13 +517,23 @@ var v = class e {
1632
517
  this.#t = e;
1633
518
  }
1634
519
  get indexAsPow() {
1635
- return new m(this.index).inverse();
520
+ return new _(this.index).inverse();
1636
521
  }
1637
522
  inverse() {
1638
523
  return this.factor.inverse(), this.radical.inverse(), this;
1639
524
  }
1640
525
  isEqual(e) {
1641
- return this.value === e.value;
526
+ if (this.isZero() && e.isZero()) return !0;
527
+ if (!this.#a() || !e.#a() || this.#o() !== e.#o()) return !1;
528
+ let t = g.lcm(this.index, e.index), n = this.factor.clone().abs().pow(t).multiply(this.radical.clone().abs().pow(t / this.index)), r = e.factor.clone().abs().pow(t).multiply(e.radical.clone().abs().pow(t / e.index));
529
+ return n.isEqual(r);
530
+ }
531
+ #a() {
532
+ return !(this.radical.isNegative() && this.index % 2 == 0);
533
+ }
534
+ #o() {
535
+ let e = this.index % 2 == 1 ? this.radical.sign() : 1;
536
+ return this.factor.sign() * e;
1642
537
  }
1643
538
  isOne() {
1644
539
  return this.factor.isOne() && this.radical.isOne();
@@ -1651,13 +546,14 @@ var v = class e {
1651
546
  return this.factor.isZero() || this.radical.isZero();
1652
547
  }
1653
548
  multiply(t) {
1654
- let n = new e(t);
1655
- if (this.factor.multiply(n.factor), this.index === n.index) return this.radical.multiply(n.radical), this;
1656
- if (this.radical.isEqual(n.radical)) {
1657
- let e = this.indexAsPow.add(n.indexAsPow).reduce();
1658
- return this.index = e.denominator, this.radical = this.radical.pow(e.numerator), this;
549
+ let n = this.clone(), i = new e(t);
550
+ if (n.index !== i.index && !n.radical.isEqual(i.radical)) throw new r("Multiply can only be done if radical or index as equals.");
551
+ if (n.factor.multiply(i.factor), n.index === i.index) n.radical.multiply(i.radical);
552
+ else {
553
+ let e = n.indexAsPow.add(i.indexAsPow).reduce();
554
+ n.index = e.denominator, n.radical = n.radical.pow(e.numerator);
1659
555
  }
1660
- throw new r("Multiply can only be done if radical or index as equals.");
556
+ return this.parse(n);
1661
557
  }
1662
558
  one() {
1663
559
  return this.radical.one(), this.factor.one(), this;
@@ -1667,7 +563,7 @@ var v = class e {
1667
563
  }
1668
564
  pow(e) {
1669
565
  this.factor.pow(e);
1670
- let t = p.gcd(this.index, e);
566
+ let t = g.gcd(this.index, e);
1671
567
  return this.index /= t, this.radical.pow(e / t), this;
1672
568
  }
1673
569
  get radical() {
@@ -1677,12 +573,12 @@ var v = class e {
1677
573
  this.#n = e;
1678
574
  }
1679
575
  reduce() {
1680
- if (this.radical.isRational()) {
1681
- let e = this.radical.denominator;
1682
- this.radical.denominator = 1, this.radical.numerator *= e, this.factor.divide(e);
576
+ if (this.radical.hasFractionalPart()) {
577
+ let e = this.radical.numerator, t = this.radical.denominator;
578
+ this.radical = new _(e * t ** (this.index - 1)), this.factor.divide(t);
1683
579
  }
1684
- let e = p.greatestPower(this.radical.value, this.index);
1685
- return this.factor.multiply(e ** (1 / this.index)), this.radical.divide(e), this;
580
+ let e = g.greatestPower(this.radical.value, this.index);
581
+ return this.factor.multiply(g.nthRoot(e, this.index)), this.radical.divide(e), this;
1686
582
  }
1687
583
  root(e) {
1688
584
  return this.group(), this.index *= e, this;
@@ -1690,12 +586,17 @@ var v = class e {
1690
586
  sqrt() {
1691
587
  return this.root(2);
1692
588
  }
1693
- subtract(t) {
1694
- let n = new e(t);
1695
- return this.add(n.opposite());
589
+ subtract(e) {
590
+ return this.#s(e, !0);
591
+ }
592
+ #s(t, n) {
593
+ let i = this.clone().reduce(), a = new e(t).reduce();
594
+ if (i.index !== a.index || !i.radical.isEqual(a.radical)) throw new r("Roots must share the same index and radical to be added or subtracted");
595
+ return n ? i.factor.subtract(a.factor) : i.factor.add(a.factor), this.parse(i);
1696
596
  }
1697
597
  get value() {
1698
- return p.numberCorrection(this.factor.value * this.radical.value ** (1 / this.index));
598
+ let e = this.radical.value;
599
+ return e < 0 ? this.index % 2 == 0 ? NaN : g.numberCorrection(this.factor.value * -((-e) ** (1 / this.index))) : g.numberCorrection(this.factor.value * e ** (1 / this.index));
1699
600
  }
1700
601
  get withSign() {
1701
602
  return this.#r = !0, this;
@@ -1706,23 +607,43 @@ var v = class e {
1706
607
  zero() {
1707
608
  return this.radical.zero(), this.factor.zero(), this;
1708
609
  }
1709
- #i(e, t, n) {
1710
- let r = this.#t === 2 ? "sqrt" : `root(${this.#t})`, i = [e === 1 || e === 0 ? null : e === -1 ? "-" : e.toString(), t !== 1 && t !== 0 ? `${r}(${t})` : null].filter((e) => e !== null);
1711
- return i.length === 0 ? null : n && i.length === 2 ? `(${i.join("")})` : i.join("");
610
+ #c(e, t, n) {
611
+ let r = this.#t === 2 ? "sqrt" : `root(${this.#t})`;
612
+ return this.#u(e, t, {
613
+ radical: (e) => `${r}(${e})`,
614
+ separator: "",
615
+ wrap: n
616
+ });
1712
617
  }
1713
- #a(e, t) {
1714
- let n = this.#t === 2 ? "\\sqrt" : `\\sqrt[ ${this.#t} ]`, r = [e === 1 || e === 0 ? null : e === -1 ? "-" : e.toString(), t !== 1 && t !== 0 ? `${n}{ ${t} }` : null].filter((e) => e !== null);
1715
- return r.length === 0 ? null : r.join(" ");
618
+ #l(e, t) {
619
+ let n = this.#t === 2 ? "\\sqrt" : `\\sqrt[ ${this.#t} ]`;
620
+ return this.#u(e, t, {
621
+ radical: (e) => `${n}{ ${e} }`,
622
+ separator: " "
623
+ });
1716
624
  }
1717
- #o(e) {
625
+ #u(e, t, n) {
626
+ let r = [e === 1 || e === 0 ? null : e === -1 ? "-" : e.toString(), t !== 1 && t !== 0 ? n.radical(t) : null].filter((e) => e !== null);
627
+ return r.length === 0 ? null : n.wrap && r.length === 2 ? `(${r.join(n.separator)})` : r.join(n.separator);
628
+ }
629
+ #d(e) {
1718
630
  let n = /^(.*?)root\((\d+)\)\(?([^)]+)/.exec(e);
1719
631
  if (!n) throw new t(`Invalid root format: "${e}"`);
1720
632
  let [, r, i, a] = n;
1721
- return this.index = +i, this.radical = new m(a), this.factor = r === "" ? new m().one() : new m(r.trim()), this;
633
+ return this.index = +i, this.radical = new _(a), this.factor = r === "" ? new _().one() : new _(r.trim()), this;
1722
634
  }
1723
- #s(e) {
1724
- let [t, n] = e.split("sqrt");
1725
- return this.index = 2, this.radical = new m(h(n)), this.factor = t === "" ? new m().one() : new m(t), this;
635
+ #f(e) {
636
+ let n = /^\((.+)\)\/(\d+)$/.exec(e);
637
+ if (n) return this.#f(n[1]), this.factor.divide(+n[2]), this;
638
+ let r = /^([+-]?\d*(?:\/\d+)?)sqrt(?:\((-?\d+(?:\/\d+)?)\)|(\d+))(?:\/(\d+))?$/.exec(e);
639
+ if (!r) throw new t(`Invalid sqrt format: "${e}"`);
640
+ let i = r[1], a = r.at(2), o = r.at(3), s = r.at(4);
641
+ this.index = 2, this.radical = new _(a ?? o ?? "");
642
+ let c;
643
+ if (i === "" || i === "+" || i === "-") c = new _(i === "-" ? -1 : 1);
644
+ else if (/^[+-]?\d+(?:\/\d+)?$/.test(i)) c = new _(i);
645
+ else throw new t(`Invalid sqrt format: "${e}"`);
646
+ return s !== void 0 && c.divide(+s), this.factor = c, this;
1726
647
  }
1727
648
  }, y = class e {
1728
649
  #e;
@@ -1733,13 +654,13 @@ var v = class e {
1733
654
  #a;
1734
655
  #o;
1735
656
  constructor() {
1736
- this.#o = "x", this.#n = !1, this.#t = null, this.#a = null, this.#r = new m().zero(), this.#i = new v(), this.#e = 1;
657
+ this.#o = "x", this.#n = !1, this.#t = null, this.#a = null, this.#r = new _().zero(), this.#i = new v(), this.#e = 1;
1737
658
  }
1738
659
  get tex() {
1739
660
  if (this.#a) return this.#a;
1740
661
  if (this.#i.isZero()) return this.#r.tex;
1741
662
  if (this.#r.isZero()) return this.#i.tex;
1742
- let [e] = m.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator} ${t.withSign.tex}`;
663
+ let [e] = _.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator} ${t.withSign.tex}`;
1743
664
  return e.denominator === 1 ? n : `\\frac{ ${n} }{ ${e.denominator} }`;
1744
665
  }
1745
666
  set tex(e) {
@@ -1749,7 +670,7 @@ var v = class e {
1749
670
  if (this.#t) return this.#t;
1750
671
  if (this.#i.isZero()) return this.#r.display;
1751
672
  if (this.#r.isZero()) return this.#i.display;
1752
- let [e] = m.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator}${t.withSign.display}`;
673
+ let [e] = _.toSameDenominateur(this.#r, this.#i.factor), t = this.#i.clone().multiply(e.denominator).reduce(), n = `${e.numerator}${t.withSign.display}`;
1753
674
  return e.denominator === 1 ? n : `(${n})/${e.denominator}`;
1754
675
  }
1755
676
  set display(e) {
@@ -1758,7 +679,7 @@ var v = class e {
1758
679
  static fromFraction(t) {
1759
680
  let n = new e();
1760
681
  n.setExact();
1761
- let r = new m(t);
682
+ let r = new _(t);
1762
683
  return n.display = r.display, n.tex = r.tex, n.fraction = r, n.root = new v(), n;
1763
684
  }
1764
685
  static fromQuadratic(t, n, r) {
@@ -1766,7 +687,7 @@ var v = class e {
1766
687
  t,
1767
688
  n,
1768
689
  r
1769
- ].map((e) => new m(e)), s = a.clone().pow(2).subtract(i.clone().multiply(o).multiply(4));
690
+ ].map((e) => new _(e)), s = a.clone().pow(2).subtract(i.clone().multiply(o).multiply(4));
1770
691
  if (s.isNegative()) return [];
1771
692
  if (s.isSquare()) {
1772
693
  let t = s.sqrt(), n = a.clone().opposite().subtract(t).divide(i.clone().multiply(2)), r = a.clone().opposite().add(t).divide(i.clone().multiply(2));
@@ -1819,11 +740,11 @@ var v = class e {
1819
740
  set variable(e) {
1820
741
  e !== void 0 && (this.#o = e);
1821
742
  }
1822
- }, ce = class {
743
+ }, se = class {
1823
744
  #e;
1824
745
  #t;
1825
746
  constructor(e) {
1826
- this.#e = e instanceof R || e instanceof P ? new R(e) : new R().fromPolynom(e), this.#t = this.#e.getRoots();
747
+ this.#e = e instanceof L || e instanceof F ? new L(e) : new L().fromPolynom(e), this.#t = this.#e.getRoots();
1827
748
  }
1828
749
  get fx() {
1829
750
  return this.#e;
@@ -1866,10 +787,10 @@ var v = class e {
1866
787
  }
1867
788
  #r(e, t) {
1868
789
  let n = new y();
1869
- return n.exact = !1, n.tex = t?.tex ?? null, n.display = t?.display ?? null, n.fraction = new m(e), n.fraction.exact = !1, n.variable = this.#n, n;
790
+ return n.exact = !1, n.tex = t?.tex ?? null, n.display = t?.display ?? null, n.fraction = new _(e), n.fraction.exact = !1, n.variable = this.#n, n;
1870
791
  }
1871
792
  #i(e) {
1872
- return e instanceof m && !e.exact ? this.#r(e.value) : y.fromFraction(e);
793
+ return e instanceof _ && !e.exact ? this.#r(e.value) : y.fromFraction(e);
1873
794
  }
1874
795
  #a(e) {
1875
796
  let t = [], n = e.degree().value, [r, ...i] = e.getCoefficients(), a = 2 + Math.max(...i.map((e) => e.value / r.value)), o = this.#s(e, a, 100);
@@ -1897,7 +818,7 @@ var v = class e {
1897
818
  #s(e, t, n) {
1898
819
  let r = [], i = 2 * t / n;
1899
820
  for (let n = -t; n <= t; n += i) {
1900
- let t = p.numberCorrection(n);
821
+ let t = g.numberCorrection(n);
1901
822
  r.push({
1902
823
  x: t,
1903
824
  fx: e.evaluate(t, !0)
@@ -1922,9 +843,9 @@ var v = class e {
1922
843
  let e = t.monoms.reduce((e, t) => t.degree().value < e.degree().value ? t : e), r = e.coefficient;
1923
844
  e.clone().divide(r), t.divide(e);
1924
845
  }
1925
- let o = p.dividers(i.value), s = p.dividers(a.value), c = [];
846
+ let o = g.dividers(i.value), s = g.dividers(a.value), c = [];
1926
847
  for (let e of o) for (let t of s) {
1927
- let n = new m(t, e);
848
+ let n = new _(t, e);
1928
849
  c.find((e) => e.value === n.value) || (c.push(n.clone()), c.push(n.opposite().clone()));
1929
850
  }
1930
851
  c.forEach((e) => {
@@ -1983,15 +904,15 @@ var v = class e {
1983
904
  }
1984
905
  #p(e, t, n) {
1985
906
  let r = e.clone().multiply(2), i = new y();
1986
- i.fraction = t.clone().opposite().divide(r.clone()), i.root.radical = n.clone(), i.root.factor = new m().one().divide(r.clone()), i.exact = !0;
907
+ i.fraction = t.clone().opposite().divide(r.clone()), i.root.radical = n.clone(), i.root.factor = new _().one().divide(r.clone()), i.exact = !0;
1987
908
  let a = new y();
1988
- return a.fraction = t.clone().opposite().divide(r.clone()), a.root.radical = n.clone(), a.root.factor = new m().one().divide(r.clone()).opposite(), a.exact = !0, [i, a].sort((e, t) => e.value - t.value);
909
+ return a.fraction = t.clone().opposite().divide(r.clone()), a.root.radical = n.clone(), a.root.factor = new _().one().divide(r.clone()).opposite(), a.exact = !0, [i, a].sort((e, t) => e.value - t.value);
1989
910
  }
1990
- }, le = class extends Error {
911
+ }, ce = class extends Error {
1991
912
  constructor(e, t) {
1992
913
  super(e, t), this.name = new.target.name;
1993
914
  }
1994
- }, x = class extends le {}, S = class extends le {}, ue = class extends S {}, C = {
915
+ }, x = class extends ce {}, S = class extends ce {}, le = class extends S {}, C = {
1995
916
  pi: Math.PI,
1996
917
  e: Math.exp(1)
1997
918
  }, w = /* @__PURE__ */ function(e) {
@@ -1999,7 +920,7 @@ var v = class e {
1999
920
  }({}), T = /* @__PURE__ */ function(e) {
2000
921
  return e.EXPRESSION = "expression", e.POLYNOM = "polynom", e.SET = "set", e.NUMERIC = "numeric", e;
2001
922
  }({});
2002
- function de(e, t) {
923
+ function ue(e, t) {
2003
924
  if (e = e.replace(/\s+/g, ""), e.length <= 1) return e;
2004
925
  let n = Object.keys(t).filter((e) => t[e].type === w.FUNCTION).map((e) => e);
2005
926
  n.sort((e, t) => t.length - e.length);
@@ -2045,14 +966,14 @@ function de(e, t) {
2045
966
  default: l = w.VARIABLE;
2046
967
  }
2047
968
  if (u === void 0 || l === void 0) throw Error("The token is undefined");
2048
- s += fe(c, l), s += u;
969
+ s += de(c, l), s += u;
2049
970
  }
2050
971
  return s;
2051
972
  }
2052
- function fe(e, t) {
973
+ function de(e, t) {
2053
974
  return e === void 0 || e === w.OPERATION || t === w.OPERATION || e === w.LEFT_PARENTHESIS || e === w.FUNCTION || e === w.FUNCTION_ARGUMENT || t === w.RIGHT_PARENTHESIS || t === w.FUNCTION_ARGUMENT ? "" : "*";
2054
975
  }
2055
- var pe = {
976
+ var fe = {
2056
977
  "^": {
2057
978
  precedence: 4,
2058
979
  associative: "right",
@@ -2167,12 +1088,12 @@ var pe = {
2167
1088
  };
2168
1089
  function E(...e) {
2169
1090
  let t = {};
2170
- for (let n of e) t[n] = pe[n];
1091
+ for (let n of e) t[n] = fe[n];
2171
1092
  return t;
2172
1093
  }
2173
- var me = {};
2174
- for (let [e, t] of Object.entries(pe)) t.type === w.FUNCTION && (me[e] = t.arity ?? 1);
2175
- var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin", "cos", "tan", "asin", "acos", "atan", "sqrt", "nthrt", "ln", "log", "logn"), ge = D, _e = E("&", "|", "!", "-"), O = class {
1094
+ var pe = {};
1095
+ for (let [e, t] of Object.entries(fe)) t.type === w.FUNCTION && (pe[e] = t.arity ?? 1);
1096
+ var me = E("^", "*", "/", "+", "-"), he = E("^", "*", "/", "+", "-", "%", "sin", "cos", "tan", "asin", "acos", "atan", "sqrt", "nthrt", "ln", "log", "logn"), ge = he, _e = E("&", "|", "!", "-"), D = class {
2176
1097
  #e;
2177
1098
  #t = [];
2178
1099
  #n = {};
@@ -2188,7 +1109,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2188
1109
  return this.#t.map((e) => e.token);
2189
1110
  }
2190
1111
  tokenConfigInitialization() {
2191
- return this.#e === T.SET ? (this.#n = _e, this.#i = !1) : this.#e === T.NUMERIC ? (this.#n = D, this.#i = !0) : this.#e === T.EXPRESSION ? (this.#n = ge, this.#i = !0) : (this.#n = he, this.#i = !0), this.#r = Object.keys(this.#n).sort((e, t) => t.length - e.length), this.#n;
1112
+ return this.#e === T.SET ? (this.#n = _e, this.#i = !1) : this.#e === T.NUMERIC ? (this.#n = he, this.#i = !0) : this.#e === T.EXPRESSION ? (this.#n = ge, this.#i = !0) : (this.#n = me, this.#i = !0), this.#r = Object.keys(this.#n).sort((e, t) => t.length - e.length), this.#n;
2192
1113
  }
2193
1114
  NextToken(e, t) {
2194
1115
  let n, r;
@@ -2221,7 +1142,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2221
1142
  }
2222
1143
  parse(e, t) {
2223
1144
  let n = [], r = [], i = 0;
2224
- for ((t ?? this.#i) && (e = de(e, this.#n)); i < e.length;) {
1145
+ for ((t ?? this.#i) && (e = ue(e, this.#n)); i < e.length;) {
2225
1146
  let t = i, { token: a, nextPos: o, type: s } = this.NextToken(e, i);
2226
1147
  if (i = o, i <= t) throw new x(`Parser stalled at position ${t} in "${e}"`);
2227
1148
  switch (s) {
@@ -2285,13 +1206,13 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2285
1206
  if (r.some((e) => e.token === "(")) throw new x(`Mismatched parentheses (unclosed '(') in "${e}"`);
2286
1207
  return this.#t = n.concat(r.reverse()), this;
2287
1208
  }
2288
- }, k = class {
1209
+ }, ve = class {
2289
1210
  _rpn;
2290
1211
  _expression;
2291
1212
  constructor(e, t) {
2292
1213
  this._expression = e;
2293
1214
  try {
2294
- this._rpn = new O(T.NUMERIC).parse(e, t).rpn;
1215
+ this._rpn = new D(T.NUMERIC).parse(e, t).rpn;
2295
1216
  } catch (t) {
2296
1217
  throw new x(`There was a problem parsing: ${e}`, { cause: t });
2297
1218
  }
@@ -2323,7 +1244,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2323
1244
  --e;
2324
1245
  break;
2325
1246
  case w.FUNCTION: {
2326
- let n = me[t.token] ?? 1;
1247
+ let n = pe[t.token] ?? 1;
2327
1248
  if (e < n) return !1;
2328
1249
  e += 1 - n;
2329
1250
  break;
@@ -2336,7 +1257,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2336
1257
  let t = [];
2337
1258
  for (let n of this._rpn) if (n.tokenType === w.COEFFICIENT) t.push(+n.token);
2338
1259
  else if (n.tokenType === w.VARIABLE) {
2339
- if (e === void 0 || !Object.hasOwn(e, n.token)) throw new ue(`Missing value for variable "${n.token}"`);
1260
+ if (e === void 0 || !Object.hasOwn(e, n.token)) throw new le(`Missing value for variable "${n.token}"`);
2340
1261
  t.push(e[n.token]);
2341
1262
  } else if (n.tokenType === w.CONSTANT) t.push(C[n.token]);
2342
1263
  else if (n.tokenType === w.OPERATION) {
@@ -2393,14 +1314,17 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2393
1314
  _numberCorrection(e, t = 8) {
2394
1315
  return +e.toFixed(t);
2395
1316
  }
2396
- }, A = class e {
1317
+ }, O = class e {
2397
1318
  #e;
2398
1319
  #t;
2399
1320
  constructor(e) {
2400
- return this.#e = new m().zero(), this.#t = {}, e !== void 0 && this.parse(e), this;
1321
+ return this.#e = new _().zero(), this.#t = {}, e !== void 0 && this.parse(e), this;
2401
1322
  }
2402
1323
  parse(t) {
2403
- return this.#e = new m(), this.#t = {}, t instanceof e ? (this.#e = t.#e.clone(), this.#n(t), this) : t instanceof m ? (this.#e = t.clone(), this) : typeof t == "number" ? (this.#e = new m(t), this) : (isNaN(Number(t)) ? this.#s(t) : this.#e = new m(Number(t)), this);
1324
+ return this.#e = new _(), this.#t = {}, t instanceof e ? (this.#e = t.#e.clone(), this.#n(t), this) : t instanceof _ ? (this.#e = t.clone(), this) : typeof t == "number" ? (this.#e = new _(t), this) : (isNaN(Number(t)) ? this.#s(t) : this.#e = new _(Number(t)), this);
1325
+ }
1326
+ copy() {
1327
+ throw new a("copy() is not yet implemented for Monom");
2404
1328
  }
2405
1329
  clone = () => {
2406
1330
  let t = new e();
@@ -2417,10 +1341,10 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2417
1341
  static gcd = (...t) => {
2418
1342
  for (let n of t) if (n.containsRationalPower()) return new e().zero();
2419
1343
  let n = new e();
2420
- n.coefficient = new m(p.gcd(...t.map((e) => e.coefficient.numerator)), p.lcm(...t.map((e) => e.coefficient.denominator))).reduce();
1344
+ n.coefficient = new _(g.gcd(...t.map((e) => e.coefficient.numerator)), g.lcm(...t.map((e) => e.coefficient.denominator))).reduce();
2421
1345
  for (let e of t) {
2422
1346
  for (let t in n.literal) t in e.literal || n.removeVariable(t);
2423
- for (let t in e.literal) !n.hasVariable(t) && e.literal[t].isStrictlyPositive() ? n.literal[t] = e.literal[t].clone() : n.literal[t] = new m(Math.min(e.literal[t].value, n.literal[t].value));
1347
+ for (let t in e.literal) !n.hasVariable(t) && e.literal[t].isStrictlyPositive() ? n.literal[t] = e.literal[t].clone() : n.literal[t] = new _(Math.min(e.literal[t].value, n.literal[t].value));
2424
1348
  }
2425
1349
  return n;
2426
1350
  };
@@ -2441,14 +1365,14 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2441
1365
  return this.#e;
2442
1366
  }
2443
1367
  set coefficient(e) {
2444
- this.#e = new m(e);
1368
+ this.#e = new _(e);
2445
1369
  }
2446
- containsRationalPower = () => Object.values(this.#t).some((e) => e.isRational());
2447
- degree = (e) => this.variables.length === 0 ? new m().zero() : e === void 0 ? Object.values(this.#t).reduce((e, t) => e.clone().add(t)) : this.hasVariable(e) ? this.#t[e].clone() : new m().zero();
1370
+ containsRationalPower = () => Object.values(this.#t).some((e) => e.hasFractionalPart());
1371
+ degree = (e) => this.variables.length === 0 ? new _().zero() : e === void 0 ? Object.values(this.#t).reduce((e, t) => e.clone().add(t)) : this.hasVariable(e) ? this.#t[e].clone() : new _().zero();
2448
1372
  derivative = (t = "x") => {
2449
1373
  if (this.hasVariable(t)) {
2450
1374
  let e = this.#t[t].clone(), n = this.clone();
2451
- return n.#t[t].subtract(1), n.#e.multiply(new m(e.clone())), n;
1375
+ return n.#t[t].subtract(1), n.#e.multiply(new _(e.clone())), n;
2452
1376
  }
2453
1377
  return new e().zero();
2454
1378
  };
@@ -2462,42 +1386,42 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2462
1386
  };
2463
1387
  get dividers() {
2464
1388
  if (!this.coefficient.isRelative() || this.containsRationalPower() || this.coefficient.numerator > 1e6) return [this.clone()];
2465
- let t = p.dividers(Math.abs(this.coefficient.numerator)), n = [];
1389
+ let t = g.dividers(Math.abs(this.coefficient.numerator)), n = [];
2466
1390
  for (let e in this.literal) n = this.#a(n, e);
2467
1391
  let r = [];
2468
1392
  if (n.length > 0 && t.length > 0) for (let i of t) for (let t of n) {
2469
1393
  let n = new e();
2470
- n.coefficient = new m(i), n.literal = t, r.push(n);
1394
+ n.coefficient = new _(i), n.literal = t, r.push(n);
2471
1395
  }
2472
1396
  else if (t.length === 0) for (let t of n) {
2473
1397
  let n = new e();
2474
- n.coefficient = new m().one(), n.literal = t, r.push(n);
1398
+ n.coefficient = new _().one(), n.literal = t, r.push(n);
2475
1399
  }
2476
1400
  else for (let n of t) {
2477
1401
  let t = new e();
2478
- t.coefficient = new m(n), r.push(t);
1402
+ t.coefficient = new _(n), r.push(t);
2479
1403
  }
2480
1404
  return r.length === 0 ? [new e().one()] : r;
2481
1405
  }
2482
1406
  evaluate = (e, t) => {
2483
1407
  if (t === !0) {
2484
- if (e instanceof m) return this.#r(e.value);
1408
+ if (e instanceof _) return this.#r(e.value);
2485
1409
  if (typeof e == "number") return this.#r(e);
2486
1410
  if (typeof e == "object") {
2487
1411
  let t = {};
2488
- for (let n in e) t[n] = new m(e[n]).value;
1412
+ for (let n in e) t[n] = new _(e[n]).value;
2489
1413
  return this.#r(t);
2490
1414
  }
2491
1415
  }
2492
1416
  let n = this.coefficient.clone();
2493
- if (typeof e == "number" || e instanceof m) {
1417
+ if (typeof e == "number" || e instanceof _) {
2494
1418
  let t = {};
2495
- return t[this.variables[0]] = new m(e), this.evaluate(t);
1419
+ return t[this.variables[0]] = new _(e), this.evaluate(t);
2496
1420
  }
2497
1421
  if (typeof e == "object") {
2498
1422
  if (this.variables.length === 0) return this.coefficient;
2499
1423
  for (let t in this.#t) {
2500
- let r = new m(e[t]);
1424
+ let r = new _(e[t]);
2501
1425
  n.multiply(r.pow(this.#t[t]));
2502
1426
  }
2503
1427
  }
@@ -2517,11 +1441,11 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2517
1441
  if (e.degree().isStrictlyPositive()) {
2518
1442
  for (let t of e.variables) if (!this.degree(t).isGeq(e.degree(t))) return !1;
2519
1443
  }
2520
- return this.coefficient.isRational() || e.coefficient.isRational() ? !0 : this.coefficient.clone().divide(e.coefficient).isRelative();
1444
+ return this.coefficient.hasFractionalPart() || e.coefficient.hasFractionalPart() ? !0 : this.coefficient.clone().divide(e.coefficient).isRelative();
2521
1445
  };
2522
1446
  isEqual = (e) => this.isSameAs(e) && this.#e.isEqual(e.coefficient);
2523
1447
  isLiteralSquare = () => {
2524
- for (let e in this.literal) if (this.literal[e].isRational() || this.literal[e].isOdd()) return !1;
1448
+ for (let e in this.literal) if (this.literal[e].hasFractionalPart() || this.literal[e].isOdd()) return !1;
2525
1449
  return !0;
2526
1450
  };
2527
1451
  isOne = () => this.#e.value === 1 && this.variables.length === 0;
@@ -2543,8 +1467,8 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2543
1467
  this.#t = e;
2544
1468
  }
2545
1469
  set literalStr(e) {
2546
- for (let t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) t[1] in this.#t || (this.#t[t[1]] = new m().zero()), this.#t[t[1]].add(+t[2]);
2547
- for (let t of [...e.matchAll(/([a-z](?!\^))/g)]) t[1] in this.#t || (this.#t[t[1]] = new m().zero()), this.#t[t[1]].add(1);
1470
+ for (let t of [...e.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) t[1] in this.#t || (this.#t[t[1]] = new _().zero()), this.#t[t[1]].add(+t[2]);
1471
+ for (let t of [...e.matchAll(/([a-z](?!\^))/g)]) t[1] in this.#t || (this.#t[t[1]] = new _().zero()), this.#t[t[1]].add(1);
2548
1472
  }
2549
1473
  multiply = (...t) => {
2550
1474
  for (let n of t) {
@@ -2554,7 +1478,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2554
1478
  }
2555
1479
  return this;
2556
1480
  };
2557
- one = () => (this.#e = new m().one(), this.#t = {}, this);
1481
+ one = () => (this.#e = new _().one(), this.#t = {}, this);
2558
1482
  opposite = () => (this.#e.opposite(), this);
2559
1483
  get plotFunction() {
2560
1484
  return this.#i("plot");
@@ -2566,7 +1490,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2566
1490
  };
2567
1491
  primitive = (e = "x") => {
2568
1492
  let t = this.clone(), n;
2569
- return t.hasVariable(e) ? (n = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(n), t.setLetter(e, n)) : (t.coefficient.isZero() && (t.coefficient = new m().one()), t.setLetter(e, 1)), t;
1493
+ return t.hasVariable(e) ? (n = t.degree(e).clone().add(1), t.coefficient = t.coefficient.clone().divide(n), t.setLetter(e, n)) : (t.coefficient.isZero() && (t.coefficient = new _().one()), t.setLetter(e, 1)), t;
2570
1494
  };
2571
1495
  reduce = () => {
2572
1496
  this.coefficient.reduce();
@@ -2579,7 +1503,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2579
1503
  root = () => {
2580
1504
  throw new a("Method not implemented.");
2581
1505
  };
2582
- setLetter = (e, t) => t instanceof m ? this.hasVariable(e) && t.isZero() ? (this.removeVariable(e), this) : (this.#t[e] = t.clone(), this) : this.setLetter(e, new m(t));
1506
+ setLetter = (e, t) => t instanceof _ ? this.hasVariable(e) && t.isZero() ? (this.removeVariable(e), this) : (this.#t[e] = t.clone(), this) : this.setLetter(e, new _(t));
2583
1507
  sqrt = () => {
2584
1508
  if (this.isSquare()) {
2585
1509
  this.#e.sqrt();
@@ -2601,7 +1525,7 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2601
1525
  n.isZero() || e.push(t);
2602
1526
  }), e.sort(), e;
2603
1527
  }
2604
- zero = () => (this.#e = new m().zero(), this.#t = {}, this);
1528
+ zero = () => (this.#e = new _().zero(), this.#t = {}, this);
2605
1529
  #n(e) {
2606
1530
  for (let t in e.literal) this.#t[t] = e.literal[t].clone();
2607
1531
  }
@@ -2611,40 +1535,40 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2611
1535
  let t = {}, n = this.variables[0];
2612
1536
  return t[n] = e, this.#r(t);
2613
1537
  }
2614
- if (e instanceof m) {
1538
+ if (e instanceof _) {
2615
1539
  let t = {};
2616
- return t[this.variables[0]] = new m(e).value, this.#r(t);
1540
+ return t[this.variables[0]] = new _(e).value, this.#r(t);
2617
1541
  }
2618
1542
  if (typeof e == "object") {
2619
1543
  if (this.variables.length === 0) return this.coefficient.value;
2620
1544
  for (let n in this.#t) {
2621
1545
  let r = e[n];
2622
- r instanceof m ? t *= r.value ** this.#t[n].value : t *= r ** this.#t[n].value;
1546
+ r instanceof _ ? t *= r.value ** this.#t[n].value : t *= r ** this.#t[n].value;
2623
1547
  }
2624
1548
  }
2625
1549
  return t;
2626
1550
  };
2627
1551
  #i = (e) => {
2628
1552
  let t = "", n = Object.keys(this.#t).sort();
2629
- for (let r of n) this.#t[r].isNotZero() && (e === "plot" && t !== "" && (t += "*"), t += r, this.#t[r].isNotEqual(1) && (t += e === "tex" ? `^{ ${this.#t[r].tfrac.tex} }` : `^(${this.#t[r].display})`));
2630
- let r = e === "tex" ? this.#e.frac.tex : this.#e.display;
1553
+ for (let r of n) this.#t[r].isNotZero() && (e === "plot" && t !== "" && (t += "*"), t += r, this.#t[r].isNotEqual(1) && (t += e === "tex" ? `^{ ${this.#t[r].asTfrac.tex} }` : `^(${this.#t[r].display})`));
1554
+ let r = e === "tex" ? this.#e.asFrac.tex : this.#e.display;
2631
1555
  return t === "" ? this.#e.value === 0 ? "0" : r : this.#e.value === 1 ? t : this.#e.value === -1 ? `-${t}` : this.#e.value === 0 ? "0" : e === "plot" ? `${r}*${t}` : `${r}${t}`;
2632
1556
  };
2633
1557
  #a(e, t) {
2634
1558
  let n = [];
2635
1559
  for (let r = 0; r <= this.literal[t].value; r++) if (e.length === 0) {
2636
1560
  let e = {};
2637
- e[t] = new m(r), n.push(e);
1561
+ e[t] = new _(r), n.push(e);
2638
1562
  } else for (let i of e) {
2639
1563
  let e = {};
2640
1564
  for (let t in i) e[t] = i[t];
2641
- e[t] = new m(r), n.push(e);
1565
+ e[t] = new _(r), n.push(e);
2642
1566
  }
2643
1567
  return n;
2644
1568
  }
2645
1569
  #o = (t, n) => {
2646
1570
  let r, i, a, o, s;
2647
- if (n.tokenType === w.COEFFICIENT) t.push(new e(new m(n.token)));
1571
+ if (n.tokenType === w.COEFFICIENT) t.push(new e(new _(n.token)));
2648
1572
  else if (n.tokenType === w.VARIABLE) {
2649
1573
  let r = new e().one();
2650
1574
  r.setLetter(n.token, 1), t.push(r.clone());
@@ -2658,13 +1582,13 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2658
1582
  case "/":
2659
1583
  i = t.pop() ?? new e().one(), r = t.pop() ?? new e().one(), t.push(r.divide(i));
2660
1584
  break;
2661
- case "^": s = t.pop()?.coefficient ?? new m().one(), a = t.pop() ?? new e().one(), o = a.variables[0], o && a.setLetter(o, s), t.push(a);
1585
+ case "^": s = t.pop()?.coefficient ?? new _().one(), a = t.pop() ?? new e().one(), o = a.variables[0], o && a.setLetter(o, s), t.push(a);
2662
1586
  }
2663
1587
  };
2664
1588
  #s = (e) => {
2665
1589
  let n;
2666
1590
  try {
2667
- n = new O().parse(e);
1591
+ n = new D().parse(e);
2668
1592
  } catch (n) {
2669
1593
  throw new t(`Cannot parse "${e}" as a Monom`, { cause: n });
2670
1594
  }
@@ -2672,15 +1596,38 @@ var he = E("^", "*", "/", "+", "-"), D = E("^", "*", "/", "+", "-", "%", "sin",
2672
1596
  if (r.length === 0) return this.zero(), this;
2673
1597
  if (r.length === 1) {
2674
1598
  let e = r[0];
2675
- return this.one(), e.tokenType === w.COEFFICIENT ? this.coefficient = new m(e.token) : e.tokenType === w.VARIABLE && this.setLetter(e.token, 1), this;
1599
+ return this.one(), e.tokenType === w.COEFFICIENT ? this.coefficient = new _(e.token) : e.tokenType === w.VARIABLE && this.setLetter(e.token, 1), this;
2676
1600
  }
2677
1601
  for (let e of r) this.#o(i, e);
2678
1602
  return this.one(), this.multiply(i[0]), this;
2679
1603
  };
2680
1604
  };
2681
1605
  //#endregion
2682
- //#region src/algebra/operations.ts
1606
+ //#region src/helpers.ts
1607
+ function ye(e, t = !0) {
1608
+ return t ? `\\left( ${e} \\right)` : `(${e})`;
1609
+ }
1610
+ function k(e) {
1611
+ if (!e.startsWith("(") || !e.endsWith(")")) return e;
1612
+ let t = 0;
1613
+ for (let n = 0; n < e.length - 1; n++) if (e[n] === "(" ? t++ : e[n] === ")" && t--, t === 0) return e;
1614
+ return e.slice(1, -1);
1615
+ }
1616
+ function A(e, t, n, r, i) {
1617
+ return e.map((e, a) => r !== void 0 && a < r || i !== void 0 && a > i ? e : e === t ? n : e);
1618
+ }
2683
1619
  function j(e, t) {
1620
+ if (t.length !== 1) throw new i(`splitChar must be a single character, got: "${t}"`);
1621
+ let n = 0, r = 0, a = [];
1622
+ for (let i = 0; i < e.length; i++) {
1623
+ let o = e[i];
1624
+ o === "(" ? n++ : o === ")" ? n-- : o === t && n === 0 && (a.push(e.substring(r, i)), r = i + 1);
1625
+ }
1626
+ return a.push(e.substring(r)), a;
1627
+ }
1628
+ //#endregion
1629
+ //#region src/algebra/operations.ts
1630
+ function M(e, t) {
2684
1631
  if (!Number.isSafeInteger(t)) throw new i("Can only raise item by an integer");
2685
1632
  if (t < 0) throw new i("Can only raise item by a positive integer");
2686
1633
  if (t === 0) return e.one();
@@ -2690,7 +1637,7 @@ function j(e, t) {
2690
1637
  }
2691
1638
  //#endregion
2692
1639
  //#region src/algebra/polynom.ts
2693
- var M = class e {
1640
+ var N = class e {
2694
1641
  #e = "x";
2695
1642
  #t;
2696
1643
  #n;
@@ -2701,13 +1648,16 @@ var M = class e {
2701
1648
  }
2702
1649
  parse(t, ...n) {
2703
1650
  if (this.#n = [], this.#t = [], this.#u(), typeof t == "string") return this.#h(t, ...n);
2704
- if ((typeof t == "number" || t instanceof m || t instanceof A) && n.length === 0) this.#n.push(new A(t));
2705
- else if (t instanceof A && n.length > 0) this.#n.push(new A(t)), n.forEach((e) => {
2706
- this.#n.push(new A(e));
1651
+ if ((typeof t == "number" || t instanceof _ || t instanceof O) && n.length === 0) this.#n.push(new O(t));
1652
+ else if (t instanceof O && n.length > 0) this.#n.push(new O(t)), n.forEach((e) => {
1653
+ this.#n.push(new O(e));
2707
1654
  });
2708
1655
  else if (t instanceof e) for (let e of t.monoms) this.#n.push(e.clone());
2709
1656
  return this;
2710
1657
  }
1658
+ copy() {
1659
+ throw new a("copy() is not yet implemented for Polynom");
1660
+ }
2711
1661
  clone() {
2712
1662
  let t = new e(), n = [];
2713
1663
  t.#e = this.#e;
@@ -2727,21 +1677,21 @@ var M = class e {
2727
1677
  }), n;
2728
1678
  }
2729
1679
  add(...t) {
2730
- for (let n of t) n instanceof e ? this.#n = this.#n.concat(n.monoms.map((e) => e.clone())) : n instanceof A ? this.#n.push(n.clone()) : typeof n == "number" && Number.isSafeInteger(n) ? this.#n.push(new A(n.toString())) : this.#n.push(new A(n));
1680
+ for (let n of t) n instanceof e ? this.#n = this.#n.concat(n.monoms.map((e) => e.clone())) : n instanceof O ? this.#n.push(n.clone()) : typeof n == "number" && Number.isSafeInteger(n) ? this.#n.push(new O(n.toString())) : this.#n.push(new O(n));
2731
1681
  return this.reduce();
2732
1682
  }
2733
1683
  commonMonom() {
2734
- let e = new A().one();
2735
- e.coefficient = new m(this.gcdNumerator(), this.gcdDenominator());
1684
+ let e = new O().one();
1685
+ e.coefficient = new _(this.gcdNumerator(), this.gcdDenominator());
2736
1686
  for (let t of this.variables) {
2737
1687
  e.setLetter(t, this.degree(t));
2738
- for (let n of this.#n) if (e.setLetter(t, m.min(n.degree(t), e.degree(t))), e.degree(t).isZero()) break;
1688
+ for (let n of this.#n) if (e.setLetter(t, _.min(n.degree(t), e.degree(t))), e.degree(t).isZero()) break;
2739
1689
  }
2740
1690
  return e;
2741
1691
  }
2742
1692
  degree(e) {
2743
- let t = new m().zero();
2744
- for (let n of this.#n) t = m.max(n.degree(e).value, t);
1693
+ let t = new _().zero();
1694
+ for (let n of this.#n) t = _.max(n.degree(e).value, t);
2745
1695
  return t;
2746
1696
  }
2747
1697
  derivative(t) {
@@ -2750,9 +1700,9 @@ var M = class e {
2750
1700
  return n.reduce();
2751
1701
  }
2752
1702
  divide(t) {
2753
- if (t instanceof m) return this.#o(t);
1703
+ if (t instanceof _) return this.#o(t);
2754
1704
  if (typeof t == "number" && Number.isSafeInteger(t)) return this.#s(t);
2755
- if (t instanceof A) return this.divide(new e(t));
1705
+ if (t instanceof O) return this.divide(new e(t));
2756
1706
  if (t instanceof e) {
2757
1707
  if (t.monoms.length === 1 && t.variables.length === 0) return this.#o(t.monoms[0].coefficient);
2758
1708
  {
@@ -2781,7 +1731,7 @@ var M = class e {
2781
1731
  }
2782
1732
  evaluate(e, t) {
2783
1733
  if (t) return this.#c(e);
2784
- let n = new m().zero();
1734
+ let n = new _().zero();
2785
1735
  return this.#n.forEach((r) => {
2786
1736
  n.add(r.evaluate(e, t));
2787
1737
  }), n;
@@ -2793,7 +1743,7 @@ var M = class e {
2793
1743
  let i = new b(n).solve();
2794
1744
  if (i.length === 0) return this.#t.length === 0 ? this.#t = [this.clone()] : this.#t.push(n), this.#t;
2795
1745
  if (i.forEach((t) => {
2796
- if (t.exact && t.root.isZero()) for (let n = 0; n < t.count; n++) t.fraction.isRational() ? this.#t.push(new e().fromCoefficients(t.fraction.denominator, -t.fraction.numerator)) : this.#t.push(new e().fromCoefficients(1, t.fraction.clone().opposite()));
1746
+ if (t.exact && t.root.isZero()) for (let n = 0; n < t.count; n++) t.fraction.hasFractionalPart() ? this.#t.push(new e().fromCoefficients(t.fraction.denominator, -t.fraction.numerator)) : this.#t.push(new e().fromCoefficients(1, t.fraction.clone().opposite()));
2797
1747
  }), this.#t.map((e) => e.degree().value).reduce((e, t) => e + t, 0) < this.degree().value) {
2798
1748
  let t = e.xMultiply(...this.#t);
2799
1749
  this.#t.push(this.clone().divide(t));
@@ -2807,19 +1757,19 @@ var M = class e {
2807
1757
  this.#n = [];
2808
1758
  let t = this.#e ?? "x";
2809
1759
  return e.reverse().forEach((e, n) => {
2810
- let r = new A();
2811
- r.coefficient = new m(e), r.setLetter(t, n), this.#n.push(r);
1760
+ let r = new O();
1761
+ r.coefficient = new _(e), r.setLetter(t, n), this.#n.push(r);
2812
1762
  }), this.#u(), this.reorder();
2813
1763
  }
2814
1764
  gcdDenominator() {
2815
- return p.gcd(...this.getDenominators());
1765
+ return g.gcd(...this.getDenominators());
2816
1766
  }
2817
1767
  gcdNumerator() {
2818
- return p.gcd(...this.getNumerators());
1768
+ return g.gcd(...this.getNumerators());
2819
1769
  }
2820
1770
  getCoefficients() {
2821
1771
  if (!this.degree().isNatural()) throw new r("getCoefficients() requires a polynomial with integer degrees");
2822
- let e = this.clone().reorder(), t = this.degree().value + 1, n = Array.from({ length: t }, () => new m(0));
1772
+ let e = this.clone().reorder(), t = this.degree().value + 1, n = Array.from({ length: t }, () => new _(0));
2823
1773
  return e.monoms.forEach((e) => {
2824
1774
  let r = t - e.degree().value - 1;
2825
1775
  n[r] = e.coefficient.clone();
@@ -2843,7 +1793,7 @@ var M = class e {
2843
1793
  }
2844
1794
  integrate(e, t, n = "x") {
2845
1795
  let r = this.primitive(n), i = {}, a = {};
2846
- return i[n] = new m(e), a[n] = new m(t), r.evaluate(a).subtract(r.evaluate(i));
1796
+ return i[n] = new _(e), a[n] = new _(t), r.evaluate(a).subtract(r.evaluate(i));
2847
1797
  }
2848
1798
  inverse() {}
2849
1799
  isDeveloped(t) {
@@ -2881,33 +1831,33 @@ var M = class e {
2881
1831
  return this.#n.length === 1 && this.#n[0].coefficient.isZero() || this.#n.length === 0;
2882
1832
  }
2883
1833
  lcmDenominator() {
2884
- return p.lcm(...this.getDenominators());
1834
+ return g.lcm(...this.getDenominators());
2885
1835
  }
2886
1836
  lcmNumerator() {
2887
- return p.lcm(...this.getNumerators());
1837
+ return g.lcm(...this.getNumerators());
2888
1838
  }
2889
1839
  get length() {
2890
1840
  return this.#n.length;
2891
1841
  }
2892
1842
  limitTo(e, t) {
2893
- let n = new m(e);
1843
+ let n = new _(e);
2894
1844
  if (n.isFinite()) {
2895
1845
  let e = t ?? this.variables[0] ?? "x";
2896
1846
  return this.evaluate({ [e]: n });
2897
1847
  }
2898
1848
  let r = this.monomByDegree(void 0, t), i = r.coefficient.sign(), a = r.degree(t);
2899
- return a.isZero() ? r.coefficient.clone() : a.isStrictlyPositive() ? n.isPositive() ? i === 1 ? new m().infinite() : new m().infinite().opposite() : (a.value % 2 == 0 ? i : -i) === 1 ? new m().infinite() : new m().infinite().opposite() : new m().zero();
1849
+ return a.isZero() ? r.coefficient.clone() : a.isStrictlyPositive() ? n.isPositive() ? i === 1 ? new _().infinite() : new _().infinite().opposite() : (a.value % 2 == 0 ? i : -i) === 1 ? new _().infinite() : new _().infinite().opposite() : new _().zero();
2900
1850
  }
2901
1851
  monomByDegree(e, t) {
2902
1852
  if (e === void 0) return this.monomByDegree(this.degree(t), t);
2903
1853
  let n = this.clone().reduce();
2904
1854
  for (let r of n.#n) if (r.degree(t).isEqual(e)) return r.clone();
2905
- return new A().zero();
1855
+ return new O().zero();
2906
1856
  }
2907
1857
  monomByLetter(e) {
2908
1858
  let t = this.clone().reduce();
2909
1859
  for (let n of t.#n) if (n.hasVariable(e)) return n.clone();
2910
- return new A().zero();
1860
+ return new O().zero();
2911
1861
  }
2912
1862
  get monoms() {
2913
1863
  return this.#n;
@@ -2923,11 +1873,11 @@ var M = class e {
2923
1873
  }
2924
1874
  multiply(t) {
2925
1875
  if (t instanceof e) return this.#m(t);
2926
- if (t instanceof m) return this.#d(t);
2927
- if (t instanceof A) return this.#p(t);
1876
+ if (t instanceof _) return this.#d(t);
1877
+ if (t instanceof O) return this.#p(t);
2928
1878
  if (Number.isSafeInteger(t) && typeof t == "number") return this.#f(t);
2929
1879
  if (typeof t == "string") try {
2930
- let e = new m(t);
1880
+ let e = new _(t);
2931
1881
  return this.#d(e);
2932
1882
  } catch (e) {
2933
1883
  throw new r("Cannot multiply by this value.", { cause: e });
@@ -2938,7 +1888,7 @@ var M = class e {
2938
1888
  return this.variables.length;
2939
1889
  }
2940
1890
  one() {
2941
- return this.#n = [], this.#n.push(new A().one()), this.#u(), this;
1891
+ return this.#n = [], this.#n.push(new O().one()), this.#u(), this;
2942
1892
  }
2943
1893
  opposite() {
2944
1894
  return this.#n = this.#n.map((e) => e.opposite()), this.#u(), this;
@@ -2947,7 +1897,7 @@ var M = class e {
2947
1897
  return this.#l("tex", !1, !1, !0);
2948
1898
  }
2949
1899
  pow(e) {
2950
- return j(this, e).reduce();
1900
+ return M(this, e).reduce();
2951
1901
  }
2952
1902
  primitive(t) {
2953
1903
  let n = new e();
@@ -2957,7 +1907,7 @@ var M = class e {
2957
1907
  reduce() {
2958
1908
  let e = 0;
2959
1909
  for (; e < this.#n.length;) {
2960
- for (let t = e + 1; t < this.#n.length; t++) this.#n[e].isSameAs(this.#n[t]) && (this.#n[e].add(this.#n[t]), this.#n.splice(t, 1), this.#n[e].isZero() && (this.#n[e] = new A().zero()), t--);
1910
+ for (let t = e + 1; t < this.#n.length; t++) this.#n[e].isSameAs(this.#n[t]) && (this.#n[e].add(this.#n[t]), this.#n.splice(t, 1), this.#n[e].isZero() && (this.#n[e] = new O().zero()), t--);
2961
1911
  e++;
2962
1912
  }
2963
1913
  this.#n = this.#n.filter((e) => !e.coefficient.isZero());
@@ -3001,14 +1951,14 @@ var M = class e {
3001
1951
  throw new r("Cannot take the square root from a polynom");
3002
1952
  }
3003
1953
  subtract(...t) {
3004
- for (let n of t) n instanceof e ? this.add(n.clone().opposite()) : n instanceof A ? this.#n.push(n.clone().opposite()) : this.#n.push(new A(n).opposite());
1954
+ for (let n of t) n instanceof e ? this.add(n.clone().opposite()) : n instanceof O ? this.#n.push(n.clone().opposite()) : this.#n.push(new O(n).opposite());
3005
1955
  return this.reduce();
3006
1956
  }
3007
1957
  tableOfSigns() {
3008
1958
  let e = this.roots, t = Array(2 * e.length + 1).fill("").map((e, t) => t % 2 == 0 ? "" : "z");
3009
1959
  if (t.length === 1) {
3010
1960
  let [e] = this.getCoefficients().map((e) => e.value);
3011
- t = g(t, "", e > 0 ? "+" : "-");
1961
+ t = A(t, "", e > 0 ? "+" : "-");
3012
1962
  } else if (this.degree().isOne()) {
3013
1963
  let [e] = this.getCoefficients().map((e) => e.value);
3014
1964
  t[0] = e > 0 ? "-" : "+", t[1] = "z", t[2] = e > 0 ? "+" : "-";
@@ -3028,7 +1978,7 @@ var M = class e {
3028
1978
  return [...new Set(this.#n.flatMap((e) => e.variables))].sort();
3029
1979
  }
3030
1980
  zero() {
3031
- return this.#n = [], this.#n.push(new A().zero()), this.#u(), this;
1981
+ return this.#n = [], this.#n.push(new O().zero()), this.#u(), this;
3032
1982
  }
3033
1983
  get zeroes() {
3034
1984
  return this.getZeroes();
@@ -3047,7 +1997,7 @@ var M = class e {
3047
1997
  return this.#u(), this;
3048
1998
  }
3049
1999
  #s(e) {
3050
- let t = new m(e);
2000
+ let t = new _(e);
3051
2001
  for (let e of this.#n) e.coefficient.divide(t);
3052
2002
  return this.#u(), this;
3053
2003
  }
@@ -3074,7 +2024,7 @@ var M = class e {
3074
2024
  return this.reduce();
3075
2025
  }
3076
2026
  #f(e) {
3077
- return this.#d(new m(e));
2027
+ return this.#d(new _(e));
3078
2028
  }
3079
2029
  #p(e) {
3080
2030
  for (let t of this.#n) t.multiply(e);
@@ -3082,33 +2032,33 @@ var M = class e {
3082
2032
  }
3083
2033
  #m(e) {
3084
2034
  let t = [];
3085
- for (let n of this.#n) for (let r of e.monoms) t.push(A.xMultiply(n, r));
2035
+ for (let n of this.#n) for (let r of e.monoms) t.push(O.xMultiply(n, r));
3086
2036
  return this.#n = t, this.reduce();
3087
2037
  }
3088
2038
  #h(e, ...t) {
3089
2039
  if (t.length === 0) {
3090
2040
  if (e !== "" && !isNaN(Number(e))) {
3091
2041
  this.empty();
3092
- let t = new A(Number(e));
2042
+ let t = new O(Number(e));
3093
2043
  return this.add(t), this;
3094
2044
  }
3095
2045
  return this.#_(e);
3096
2046
  }
3097
2047
  if (/^[a-z]+$/.test(e)) {
3098
2048
  this.empty();
3099
- let n = t.map((e) => new m(e));
2049
+ let n = t.map((e) => new _(e));
3100
2050
  if (e.length > 1) {
3101
2051
  let t = e.split("");
3102
2052
  if (n.length > t.length + 1) throw new i(`Too many values: ${t.length} letters but ${n.length} values provided`);
3103
2053
  let r = 0;
3104
2054
  for (let e of n) {
3105
- let n = new A();
2055
+ let n = new O();
3106
2056
  n.coefficient = e.clone(), n.literalStr = t[r] ?? "", this.add(n), r++;
3107
2057
  }
3108
2058
  } else {
3109
2059
  let t = n.length - 1;
3110
2060
  for (let r of n) {
3111
- let n = new A();
2061
+ let n = new O();
3112
2062
  n.coefficient = r.clone(), n.literalStr = `${e}^${t}`, this.add(n), t--;
3113
2063
  }
3114
2064
  }
@@ -3122,7 +2072,7 @@ var M = class e {
3122
2072
  n.push(new e(i.token));
3123
2073
  break;
3124
2074
  case w.VARIABLE:
3125
- n.push(new e().add(new A(i.token)));
2075
+ n.push(new e().add(new O(i.token)));
3126
2076
  break;
3127
2077
  case w.CONSTANT: throw new t("Unsupported CONSTANT token in Polynom parser");
3128
2078
  case w.OPERATION:
@@ -3155,7 +2105,7 @@ var M = class e {
3155
2105
  #_(e) {
3156
2106
  let n;
3157
2107
  try {
3158
- n = new O().parse(e);
2108
+ n = new D().parse(e);
3159
2109
  } catch (n) {
3160
2110
  throw new t(`Cannot parse "${e}" as a Polynom`, { cause: n });
3161
2111
  }
@@ -3165,23 +2115,26 @@ var M = class e {
3165
2115
  for (let e of r) this.#g(i, e);
3166
2116
  return i.length === 1 && this.add(i[0]), this.reorder();
3167
2117
  }
3168
- }, N = class e {
2118
+ }, P = class e {
3169
2119
  #e;
3170
2120
  #t;
3171
2121
  #n;
3172
2122
  constructor(t, n, r) {
3173
- if (this.#e = new M().zero(), this.#t = new M().zero(), this.#n = "=", t !== void 0 && n === void 0) {
2123
+ if (this.#e = new N().zero(), this.#t = new N().zero(), this.#n = "=", t !== void 0 && n === void 0) {
3174
2124
  if (t instanceof e) return t.clone();
3175
2125
  typeof t == "string" && this.parse(t);
3176
- } else t !== void 0 && n !== void 0 && (this.left = new M(t), this.right = new M(n));
2126
+ } else t !== void 0 && n !== void 0 && (this.left = new N(t), this.right = new N(n));
3177
2127
  return r !== void 0 && (this.sign = r), this;
3178
2128
  }
3179
2129
  parse = (e) => {
3180
2130
  let n = this.#r(e);
3181
2131
  if (n === !1) throw new t("The equation is not valid (no sign found)");
3182
2132
  let r = e.split(n);
3183
- return this.create(new M(r[0]), new M(r[1]), this.#i(n));
2133
+ return this.create(new N(r[0]), new N(r[1]), this.#i(n));
3184
2134
  };
2135
+ copy() {
2136
+ throw new a("copy() is not yet implemented for Equation");
2137
+ }
3185
2138
  clone = () => new e(this.#e.clone(), this.#t.clone(), this.#n);
3186
2139
  get tex() {
3187
2140
  return `${this.#e.tex}${this.signAsTex}${this.#t.tex}`;
@@ -3199,13 +2152,13 @@ var M = class e {
3199
2152
  add(t) {
3200
2153
  if (t instanceof e) return this.#e.add(t.left), this.#t.add(t.right), this;
3201
2154
  if (typeof t == "string" && !e.isEquationString(t)) return this.add(new e(t));
3202
- let n = new M(t);
2155
+ let n = new N(t);
3203
2156
  return this.#e.add(n), this.#t.add(n), this;
3204
2157
  }
3205
2158
  create = (e, t, n) => (this.#e = e, this.#t = t, this.#n = this.#i(n ?? "="), this);
3206
- degree = (e) => m.max(this.#e.degree(e), this.#t.degree(e));
2159
+ degree = (e) => _.max(this.#e.degree(e), this.#t.degree(e));
3207
2160
  divide = (e) => {
3208
- let t = new m(e);
2161
+ let t = new _(e);
3209
2162
  return t.isZero() ? this : this.multiply(t.inverse());
3210
2163
  };
3211
2164
  evaluate(e, t) {
@@ -3245,7 +2198,7 @@ var M = class e {
3245
2198
  letters = () => [.../* @__PURE__ */ new Set([...this.#e.variables, ...this.#t.variables])];
3246
2199
  moveLeft = () => (this.#e.subtract(this.#t), this.#t.zero(), this);
3247
2200
  multiply = (e) => {
3248
- let t = new m(e);
2201
+ let t = new _(e);
3249
2202
  return this.#e.multiply(t), this.#t.multiply(t), this.#n !== "=" && t.sign() === -1 && this.#a(), this;
3250
2203
  };
3251
2204
  get numberOfVars() {
@@ -3278,7 +2231,7 @@ var M = class e {
3278
2231
  get signAsTex() {
3279
2232
  return this.#n === ">=" ? "\\geq" : this.#n === "<=" ? "\\leq" : this.#n;
3280
2233
  }
3281
- simplify = () => (this.multiply(p.lcm(...this.#e.getDenominators(), ...this.#t.getDenominators())), this.divide(p.gcd(...this.#e.getNumerators(), ...this.#t.getNumerators())), this);
2234
+ simplify = () => (this.multiply(g.lcm(...this.#e.getDenominators(), ...this.#t.getDenominators())), this.divide(g.gcd(...this.#e.getNumerators(), ...this.#t.getNumerators())), this);
3282
2235
  solve = () => new b(this.clone()).solve();
3283
2236
  split() {
3284
2237
  return [this.#e.clone(), this.#t.clone()];
@@ -3286,7 +2239,7 @@ var M = class e {
3286
2239
  subtract(t) {
3287
2240
  if (t instanceof e) return this.#e.subtract(t.left), this.#t.subtract(t.right), this;
3288
2241
  if (typeof t == "string" && !e.isEquationString(t)) return this.subtract(new e(t));
3289
- let n = new M(t);
2242
+ let n = new N(t);
3290
2243
  return this.#e.subtract(n), this.#t.subtract(n), this;
3291
2244
  }
3292
2245
  test = (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e));
@@ -3307,27 +2260,30 @@ var M = class e {
3307
2260
  };
3308
2261
  #i = (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=";
3309
2262
  #a = () => this.#n === "=" ? this : this.#n.includes("<") ? (this.#n.replace("<", ">"), this) : (this.#n.includes(">") && this.#n.replace(">", "<"), this);
3310
- }, P = class e {
2263
+ }, F = class e {
3311
2264
  #e;
3312
2265
  #t;
3313
2266
  #n;
3314
2267
  #r = !1;
3315
2268
  constructor(t, n) {
3316
- return t instanceof e ? (this.#t = t.polynom.clone(), this.#n = t.power.clone(), n !== void 0 && this.#n.multiply(new m(n))) : t === void 0 ? (this.#t = new M(), this.#n = new m(1)) : (this.#t = new M(t), this.#n = new m(n ?? 1)), this.#e = 1, this;
2269
+ return t instanceof e ? (this.#t = t.polynom.clone(), this.#n = t.power.clone(), n !== void 0 && this.#n.multiply(new _(n))) : t === void 0 ? (this.#t = new N(), this.#n = new _(1)) : (this.#t = new N(t), this.#n = new _(n ?? 1)), this.#e = 1, this;
3317
2270
  }
3318
2271
  parse() {
3319
2272
  throw new a("Method not implemented.");
3320
2273
  }
2274
+ copy() {
2275
+ throw new a("copy() is not yet implemented for Factor");
2276
+ }
3321
2277
  clone() {
3322
2278
  return new e(this);
3323
2279
  }
3324
2280
  get tex() {
3325
2281
  let e = this.power.numerator, t = this.power.denominator, n, r;
3326
- return this.#e === 0 && t > 1 ? (n = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, r = e === 1 ? "" : `^{ ${e} }`) : (n = this.#r && this.power.isOne() ? this.polynom.tex : se(this.polynom.tex), r = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `\\frac{ 1 }{ ${n} }`), n;
2282
+ return this.#e === 0 && t > 1 ? (n = `\\sqrt${t === 2 ? "" : `[ ${t} ]`}{ ${this.polynom.tex} }`, r = e === 1 ? "" : `^{ ${e} }`) : (n = this.#r && this.power.isOne() ? this.polynom.tex : ye(this.polynom.tex), r = t === 1 && e === 1 ? "" : `^{ ${this.power.tex} }`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `\\frac{ 1 }{ ${n} }`), n;
3327
2283
  }
3328
2284
  get display() {
3329
2285
  let e = this.power.numerator, t = this.power.denominator, n, r;
3330
- return this.#e === 0 && t > 1 ? (n = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, r = e === 1 ? "" : `^(${e})`) : (n = this.#r && this.power.isOne() ? this.polynom.display : se(this.polynom.display, !1), r = t === 1 && e === 1 ? "" : `^(${this.power.display})`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `1/(${n})`), n;
2286
+ return this.#e === 0 && t > 1 ? (n = `${t === 2 ? "sqrt" : `root(${t})`}(${this.polynom.display})`, r = e === 1 ? "" : `^(${e})`) : (n = this.#r && this.power.isOne() ? this.polynom.display : ye(this.polynom.display, !1), r = t === 1 && e === 1 ? "" : `^(${this.power.display})`), n = `${n}${r}`, this.#e === 0 && e < 0 && (n = `1/(${n})`), n;
3331
2287
  }
3332
2288
  add() {
3333
2289
  throw new r("Adding two factors is not possible");
@@ -3351,7 +2307,7 @@ var M = class e {
3351
2307
  }
3352
2308
  divide(t) {
3353
2309
  if (t instanceof e && this.isSameAs(t)) return this.power.subtract(t.power), this;
3354
- let n = new M(t);
2310
+ let n = new N(t);
3355
2311
  if (this.isSameAs(n)) return this.power.subtract(1), this;
3356
2312
  throw new r("The two factors must be the same");
3357
2313
  }
@@ -3359,7 +2315,7 @@ var M = class e {
3359
2315
  return t ? this.polynom.evaluate(e, !0) ** this.power.value : this.polynom.evaluate(e).pow(this.power);
3360
2316
  }
3361
2317
  fromPolynom(e) {
3362
- return this.#t = new M(e), this.#n = new m(1), this;
2318
+ return this.#t = new N(e), this.#n = new _(1), this;
3363
2319
  }
3364
2320
  hasVariable(e) {
3365
2321
  return this.polynom.hasVariable(e);
@@ -3375,7 +2331,7 @@ var M = class e {
3375
2331
  }
3376
2332
  isSameAs(t) {
3377
2333
  let n;
3378
- return n = t instanceof e ? t.polynom : t instanceof M ? t : new M(t), this.polynom.isEqual(n);
2334
+ return n = t instanceof e ? t.polynom : t instanceof N ? t : new N(t), this.polynom.isEqual(n);
3379
2335
  }
3380
2336
  isZero() {
3381
2337
  return this.polynom.isZero();
@@ -3384,7 +2340,7 @@ var M = class e {
3384
2340
  let n = new e(t);
3385
2341
  if (this.polynom.monoms.length === 1 && this.power.isOne() && n.polynom.monoms.length === 1 && this.power.isOne()) return this.polynom.multiply(n.polynom), this;
3386
2342
  if (t instanceof e && this.isSameAs(t)) return this.power.add(t.power), this;
3387
- let i = new M(t);
2343
+ let i = new N(t);
3388
2344
  if (this.isSameAs(i)) return this.power.add(1), this;
3389
2345
  throw new r("The two factors must be the same");
3390
2346
  }
@@ -3407,7 +2363,7 @@ var M = class e {
3407
2363
  return this.#n;
3408
2364
  }
3409
2365
  set power(e) {
3410
- this.#n = new m(e);
2366
+ this.#n = new _(e);
3411
2367
  }
3412
2368
  primitive() {
3413
2369
  throw new a("Method not implemented.");
@@ -3426,7 +2382,7 @@ var M = class e {
3426
2382
  }
3427
2383
  tableOfSigns() {
3428
2384
  let e = this.power.clone().reduce(), t = this.polynom.tableOfSigns();
3429
- return e.isStrictlyNegative() && (t.signs = g(t.signs, "z", "d")), e.denominator % 2 == 0 ? t.signs = g(t.signs, "-", "h") : e.numerator % 2 == 0 && (t.signs = g(t.signs, "-", "+")), {
2385
+ return e.isStrictlyNegative() && (t.signs = A(t.signs, "z", "d")), e.denominator % 2 == 0 ? t.signs = A(t.signs, "-", "h") : e.numerator % 2 == 0 && (t.signs = A(t.signs, "-", "+")), {
3430
2386
  roots: t.roots,
3431
2387
  signs: t.signs
3432
2388
  };
@@ -3444,9 +2400,9 @@ var M = class e {
3444
2400
  return this.#t.zero(), this.#n.one(), this;
3445
2401
  }
3446
2402
  static checkParseAsFactors(e) {
3447
- let t = _(e, "+");
2403
+ let t = j(e, "+");
3448
2404
  if (t[0] === "" && t.shift(), t.length > 1) return !1;
3449
- let n = _(e, "-");
2405
+ let n = j(e, "-");
3450
2406
  return n[0] === "" && n.shift(), !(n.length > 1);
3451
2407
  }
3452
2408
  static factorsFromString(t, n = !0) {
@@ -3454,19 +2410,22 @@ var M = class e {
3454
2410
  let r = n ? 1 : -1, i = [];
3455
2411
  for (let n of t.matchAll(/\(([^)]+)\)(?:\^(-?[0-9]+(?:\/[0-9]+)?|\(-?[0-9]+(?:\/[0-9]+)?\)))?|([^(]+)/g)) if (n[1] !== void 0) {
3456
2412
  let t = (n[2] ?? "1").replace(/[()]/g, "");
3457
- i.push(new e(new M(n[1]), new m(t).multiply(r)));
3458
- } else n[3]?.trim() && i.push(new e(new M(n[3].trim()), new m(r)));
2413
+ i.push(new e(new N(n[1]), new _(t).multiply(r)));
2414
+ } else n[3]?.trim() && i.push(new e(new N(n[3].trim()), new _(r)));
3459
2415
  return i;
3460
2416
  }
3461
- }, F = /* @__PURE__ */ function(e) {
2417
+ }, I = /* @__PURE__ */ function(e) {
3462
2418
  return e[e.ROOT = 0] = "ROOT", e[e.POWER = 1] = "POWER", e;
3463
- }({}), I = class e {
2419
+ }({}), be = class e {
3464
2420
  #e;
3465
2421
  #t;
3466
2422
  constructor(...e) {
3467
2423
  return this.#e = [], this.#t = [], e.length > 0 && this.parse(...e), this;
3468
2424
  }
3469
- parse = (...e) => (this.#e = e.map((e) => new N(e)), this.#n(), this);
2425
+ parse = (...e) => (this.#e = e.map((e) => new P(e)), this.#n(), this);
2426
+ copy() {
2427
+ throw new a("copy() is not yet implemented for LinearSystem");
2428
+ }
3470
2429
  clone = () => new e().parse(...this.#e.map((e) => e.clone()));
3471
2430
  get tex() {
3472
2431
  let e = this.clone().reorder();
@@ -3479,7 +2438,7 @@ var M = class e {
3479
2438
  let i = t[0].length;
3480
2439
  if (t.some((e) => e.length !== i)) throw new n("All rows must have the same number of columns");
3481
2440
  let a = r.split("").splice(0, i - 1);
3482
- return new e(...t.map((e) => new N(new M(a.join(""), ...e), 0)));
2441
+ return new e(...t.map((e) => new P(new N(a.join(""), ...e), 0)));
3483
2442
  }
3484
2443
  static solutionAsDisplay(e) {
3485
2444
  return `(${e.map((e) => e.display).join(";")})`;
@@ -3494,7 +2453,7 @@ var M = class e {
3494
2453
  for (let n = 0; n < e; n++) this.#e[n].add(t.equations[n]);
3495
2454
  } else {
3496
2455
  if (r === void 0 || r < 0 || r >= this.#e.length) throw new o("Index out of range");
3497
- let e = new N(t);
2456
+ let e = new P(t);
3498
2457
  this.#e[r].add(e);
3499
2458
  }
3500
2459
  return this;
@@ -3517,7 +2476,7 @@ var M = class e {
3517
2476
  return t !== void 0 && t.length > 0 && (o = t[0].length), `\\left\\{\\begin{array}{${"r".repeat(i.length)}cl ${"|l".repeat(o)}}${a.join("\\\\ ")}\\end{array}\\right.`;
3518
2477
  };
3519
2478
  degree(e) {
3520
- return m.max(...this.#e.map((t) => t.degree(e)));
2479
+ return _.max(...this.#e.map((t) => t.degree(e)));
3521
2480
  }
3522
2481
  get equations() {
3523
2482
  return this.#e;
@@ -3583,7 +2542,7 @@ var M = class e {
3583
2542
  let t = [], n = this.equations.map((t) => t.left.monomByLetter(e).coefficient.value);
3584
2543
  return n.forEach((e, r) => {
3585
2544
  for (let i = r + 1; i < n.length; i++) {
3586
- let a = p.lcm(e, n[i]), o = e < 0 ? -1 : 1;
2545
+ let a = g.lcm(e, n[i]), o = e < 0 ? -1 : 1;
3587
2546
  t.push([{
3588
2547
  id: r,
3589
2548
  factor: o * a / e
@@ -3601,7 +2560,7 @@ var M = class e {
3601
2560
  for (let n = 0; n < e; n++) this.#e[n].subtract(t.equations[n]);
3602
2561
  } else {
3603
2562
  if (r === void 0 || r < 0 || r >= this.#e.length) throw new o("Index out of range");
3604
- let e = new N(t);
2563
+ let e = new P(t);
3605
2564
  this.#e[r].subtract(e);
3606
2565
  }
3607
2566
  return this;
@@ -3636,14 +2595,14 @@ var M = class e {
3636
2595
  n.variable = e, t.push(n);
3637
2596
  }), t);
3638
2597
  }
3639
- }, L = class {
2598
+ }, xe = class {
3640
2599
  #e;
3641
2600
  constructor(e) {
3642
2601
  return this.#e = [], e !== void 0 && this.parse(e), this;
3643
2602
  }
3644
2603
  parse = (e) => {
3645
2604
  try {
3646
- this.#e = new O(T.SET).parse(e).rpn;
2605
+ this.#e = new D(T.SET).parse(e).rpn;
3647
2606
  } catch (n) {
3648
2607
  throw new t(`Cannot parse "${e}" as a LogicalSet`, { cause: n });
3649
2608
  }
@@ -3796,8 +2755,8 @@ var M = class e {
3796
2755
  }
3797
2756
  return [...n[0]].sort();
3798
2757
  }
3799
- }, R = class e {
3800
- #e = F.POWER;
2758
+ }, L = class e {
2759
+ #e = I.POWER;
3801
2760
  #t = [];
3802
2761
  constructor(...e) {
3803
2762
  return this.parse(...e), this;
@@ -3805,9 +2764,12 @@ var M = class e {
3805
2764
  parse(...t) {
3806
2765
  return this.#t = [], t.length === 0 || t.forEach((t) => {
3807
2766
  if (typeof t == "string") return this.fromString(t);
3808
- t instanceof e ? this.#t.push(...t.factors.map((e) => e.clone())) : this.#t.push(new P(t));
2767
+ t instanceof e ? this.#t.push(...t.factors.map((e) => e.clone())) : this.#t.push(new F(t));
3809
2768
  }), this;
3810
2769
  }
2770
+ copy() {
2771
+ throw new a("copy() is not yet implemented for PolyFactor");
2772
+ }
3811
2773
  clone() {
3812
2774
  return new e(...this.#t.map((e) => e.clone()));
3813
2775
  }
@@ -3820,16 +2782,16 @@ var M = class e {
3820
2782
  return t.length === 0 ? e.length === 1 ? e[0].asSingle.display : e.map((e, t) => t === 0 && e.polynom.monoms.length === 1 ? e.asSingle.display : e.display).join("") : `(${e.length === 1 ? e[0].asSingle.display : e.map((e) => e.display).join("")})/(${t.length === 1 ? t[0].asSingle.display : t.map((e) => e.display).join("")})`;
3821
2783
  }
3822
2784
  static #n(t, n) {
3823
- let r = z(t), i = z(n), a = Object.keys(r).filter((e) => Object.hasOwn(i, e)).map((e) => {
3824
- let t = r[e].reduce((e, t) => e.add(t.power), new m("0")), n = i[e].reduce((e, t) => e.add(t.power), new m("0"));
3825
- return new P(e, m.min(t, n));
2785
+ let r = R(t), i = R(n), a = Object.keys(r).filter((e) => Object.hasOwn(i, e)).map((e) => {
2786
+ let t = r[e].reduce((e, t) => e.add(t.power), new _("0")), n = i[e].reduce((e, t) => e.add(t.power), new _("0"));
2787
+ return new F(e, _.min(t, n));
3826
2788
  });
3827
2789
  return new e(...a);
3828
2790
  }
3829
2791
  static #r(t, n) {
3830
- let r = z(t), i = z(n), a = [.../* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])].map((e) => {
3831
- let t = Object.hasOwn(r, e) ? r[e].reduce((e, t) => e.add(t.power), new m("0")) : new m(0), n = Object.hasOwn(i, e) ? i[e].reduce((e, t) => e.add(t.power), new m("0")) : new m(0);
3832
- return new P(e, m.max(t, n));
2792
+ let r = R(t), i = R(n), a = [.../* @__PURE__ */ new Set([...Object.keys(r), ...Object.keys(i)])].map((e) => {
2793
+ let t = Object.hasOwn(r, e) ? r[e].reduce((e, t) => e.add(t.power), new _("0")) : new _(0), n = Object.hasOwn(i, e) ? i[e].reduce((e, t) => e.add(t.power), new _("0")) : new _(0);
2794
+ return new F(e, _.max(t, n));
3833
2795
  });
3834
2796
  return new e(...a);
3835
2797
  }
@@ -3854,17 +2816,17 @@ var M = class e {
3854
2816
  e.multiply(t.clone().divide(r[n]));
3855
2817
  }), i = t;
3856
2818
  }
3857
- let a = e.gcd(...n), o = new M(0).add(...n.map((e) => e.divide(a).reduce().develop().factors[0].polynom)).reduce();
3858
- return this.#t = [...a.factors, new P(o)], i && this.divide(i), this.#t = this.#t.filter((e) => !e.power.isZero()), this;
2819
+ let a = e.gcd(...n), o = new N(0).add(...n.map((e) => e.divide(a).reduce().develop().factors[0].polynom)).reduce();
2820
+ return this.#t = [...a.factors, new F(o)], i && this.divide(i), this.#t = this.#t.filter((e) => !e.power.isZero()), this;
3859
2821
  }
3860
2822
  get asPower() {
3861
- return this.#e = F.POWER, this;
2823
+ return this.#e = I.POWER, this;
3862
2824
  }
3863
2825
  get asRoot() {
3864
- return this.#e = F.ROOT, this;
2826
+ return this.#e = I.ROOT, this;
3865
2827
  }
3866
2828
  degree(e) {
3867
- return this.#t.reduce((t, n) => t.add(n.degree(e)), new m("0"));
2829
+ return this.#t.reduce((t, n) => t.add(n.degree(e)), new _("0"));
3868
2830
  }
3869
2831
  get denominator() {
3870
2832
  return new e(...this.#t.filter((e) => e.power.isNegative()).map((e) => e.clone().inverse()));
@@ -3880,7 +2842,7 @@ var M = class e {
3880
2842
  return r !== void 0 && (this.#t = r.factors), this.add(...t);
3881
2843
  }
3882
2844
  develop() {
3883
- let t = new M("1"), n = new M("1");
2845
+ let t = new N("1"), n = new N("1");
3884
2846
  return this.numerator.factors.forEach((e) => {
3885
2847
  t.multiply(e.develop());
3886
2848
  }), this.denominator.factors.forEach((e) => {
@@ -3891,7 +2853,7 @@ var M = class e {
3891
2853
  return this.#t = this.#t.concat(e.clone().factors.map((e) => e.inverse())), this;
3892
2854
  }
3893
2855
  evaluate(e, t) {
3894
- return t ? this.#t.reduce((n, r) => n * r.evaluate(e, t), 1) : this.#t.reduce((t, n) => t.multiply(n.evaluate(e)), new m("1"));
2856
+ return t ? this.#t.reduce((n, r) => n * r.evaluate(e, t), 1) : this.#t.reduce((t, n) => t.multiply(n.evaluate(e)), new _("1"));
3895
2857
  }
3896
2858
  factorize(t) {
3897
2859
  let n = [];
@@ -3899,7 +2861,7 @@ var M = class e {
3899
2861
  let r = e.polynom.factorize(t);
3900
2862
  if (r.length > 1) {
3901
2863
  let t = e.power.clone();
3902
- n.push(...r.map((e) => new P(e, t)));
2864
+ n.push(...r.map((e) => new F(e, t)));
3903
2865
  } else n.push(e.clone());
3904
2866
  });
3905
2867
  let r = new e(...n), i = r.numerator.reduce(), a = r.denominator.reduce();
@@ -3912,20 +2874,20 @@ var M = class e {
3912
2874
  this.#t = e;
3913
2875
  }
3914
2876
  fromPolynom(e, t) {
3915
- if (this.#t = [new P(new M(e))], t) {
3916
- let e = new M(t);
2877
+ if (this.#t = [new F(new N(e))], t) {
2878
+ let e = new N(t);
3917
2879
  if (e.isOne()) return this;
3918
2880
  if (e.isZero()) throw new r("Cannot divide by zero");
3919
- this.#t.push(new P(e, -1));
2881
+ this.#t.push(new F(e, -1));
3920
2882
  }
3921
2883
  return this;
3922
2884
  }
3923
2885
  fromString(e) {
3924
2886
  this.#t = [];
3925
- let [n, ...r] = _(e, "/");
2887
+ let [n, ...r] = j(e, "/");
3926
2888
  if (n === "") throw new t("Parsing a PolyFactor from a string requires a numerator");
3927
2889
  if (r.length > 1) throw new t("Parsing a PolyFactor from a string only allows max one signe \"/\"");
3928
- return this.#t = r.length === 0 ? P.factorsFromString(h(n), !0) : [...P.factorsFromString(h(n), !0), ...P.factorsFromString(h(r[0]), !1)], this;
2890
+ return this.#t = r.length === 0 ? F.factorsFromString(k(n), !0) : [...F.factorsFromString(k(n), !0), ...F.factorsFromString(k(r[0]), !1)], this;
3929
2891
  }
3930
2892
  getRoots() {
3931
2893
  return [];
@@ -3960,11 +2922,11 @@ var M = class e {
3960
2922
  return new e(...this.#t.filter((e) => e.power.isPositive()));
3961
2923
  }
3962
2924
  one() {
3963
- return this.#t = [new P("1", "1")], this;
2925
+ return this.#t = [new F("1", "1")], this;
3964
2926
  }
3965
2927
  opposite() {
3966
2928
  let e = this.#t.findIndex((e) => e.display === "(-1)");
3967
- return e >= 0 ? this.#t.splice(e, 1) : this.#t.push(new P("-1", "1")), this;
2929
+ return e >= 0 ? this.#t.splice(e, 1) : this.#t.push(new F("-1", "1")), this;
3968
2930
  }
3969
2931
  pow(e) {
3970
2932
  return this.#t = this.#t.map((t) => t.pow(e)), this;
@@ -3973,14 +2935,14 @@ var M = class e {
3973
2935
  throw new a("Method not implemented.");
3974
2936
  }
3975
2937
  reduce() {
3976
- let e = z(this);
2938
+ let e = R(this);
3977
2939
  this.#t = Object.values(e).map((e) => {
3978
2940
  let t = e[0].polynom;
3979
- return new P(t, e.reduce((e, t) => e.add(t.power), new m("0")).reduce());
2941
+ return new F(t, e.reduce((e, t) => e.add(t.power), new _("0")).reduce());
3980
2942
  }).filter((e) => !e.power.isZero());
3981
- let t = new P(1), n = new P(1), r = this.#t.filter((e) => e.polynom.monoms.length === 1 && e.power.isRelative());
2943
+ let t = new F(1), n = new F(1), r = this.#t.filter((e) => e.polynom.monoms.length === 1 && e.power.isRelative());
3982
2944
  return r.length > 0 && (r.forEach((e) => {
3983
- e.power.isPositive() ? t.multiply(new P(e.polynom.clone().pow(e.power.value))) : n.multiply(new P(e.polynom.clone().pow(-e.power.value)));
2945
+ e.power.isPositive() ? t.multiply(new F(e.polynom.clone().pow(e.power.value))) : n.multiply(new F(e.polynom.clone().pow(-e.power.value)));
3984
2946
  }), this.#t = this.#t.filter((e) => !(e.polynom.monoms.length === 1 && e.power.isRelative())), n.polynom.isOne() || this.#t.push(n.inverse()), t.polynom.isOne() || this.#t.push(t)), this;
3985
2947
  }
3986
2948
  root(e) {
@@ -4004,7 +2966,7 @@ var M = class e {
4004
2966
  }
4005
2967
  tableOfSigns() {
4006
2968
  let e = this.getZeroes(), t = e.map((e) => e.value), n = this.factorize().factors.map((e) => ({
4007
- factor: new P(e),
2969
+ factor: new F(e),
4008
2970
  ...e.tableOfSigns()
4009
2971
  }));
4010
2972
  return n.forEach((n) => {
@@ -4038,18 +3000,18 @@ var M = class e {
4038
3000
  return this.#t.reduce((e, t) => e.concat(t.variables), []);
4039
3001
  }
4040
3002
  zero() {
4041
- return this.#t = [new P("0", "1")], this;
3003
+ return this.#t = [new F("0", "1")], this;
4042
3004
  }
4043
3005
  #i() {
4044
3006
  let e, t = [];
4045
- return this.#e === F.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = this.#t, e.length === 0 && (e = [new P("1")]), {
3007
+ return this.#e === I.ROOT ? (e = this.numerator.factors, t = this.denominator.factors) : e = this.#t, e.length === 0 && (e = [new F("1")]), {
4046
3008
  num: e,
4047
3009
  den: t
4048
3010
  };
4049
3011
  }
4050
3012
  };
4051
- function z(e) {
4052
- let t = new m().one(), n = new m().one(), r = e.factors.reduce((e, r) => {
3013
+ function R(e) {
3014
+ let t = new _().one(), n = new _().one(), r = e.factors.reduce((e, r) => {
4053
3015
  if (r.polynom.degree().isZero() && r.power.isRelative()) {
4054
3016
  let i = r.polynom.monoms[0].coefficient.pow(r.power.clone().abs());
4055
3017
  return r.power.isPositive() ? t.multiply(i) : n.multiply(i), e;
@@ -4057,11 +3019,11 @@ function z(e) {
4057
3019
  let i = r.polynom.display;
4058
3020
  return Object.hasOwn(e, i) ? e[i].push(r) : e[i] = [r], e;
4059
3021
  }, {}), { numerator: i, denominator: a } = t.divide(n).reduce();
4060
- return i !== 1 && (r[i.toString()] = [new P(i, 1)]), a !== 1 && (r[a.toString()] = [new P(a, -1)]), r;
3022
+ return i !== 1 && (r[i.toString()] = [new F(i, 1)]), a !== 1 && (r[a.toString()] = [new F(a, -1)]), r;
4061
3023
  }
4062
3024
  //#endregion
4063
3025
  //#region src/algebra/matrix.ts
4064
- var ve = class e {
3026
+ var Se = class e {
4065
3027
  #e = null;
4066
3028
  #t = 0;
4067
3029
  #n = [];
@@ -4071,6 +3033,9 @@ var ve = class e {
4071
3033
  parse(e) {
4072
3034
  return this.fromValues(e);
4073
3035
  }
3036
+ copy() {
3037
+ throw new a("copy() is not yet implemented for Matrix");
3038
+ }
4074
3039
  clone() {
4075
3040
  let t = [];
4076
3041
  return this.#n.forEach((e) => {
@@ -4109,10 +3074,10 @@ var ve = class e {
4109
3074
  aij(e, t) {
4110
3075
  return e < 0 || e > this.dimension.rows || t < 0 || t > this.dimension.cols ? null : this.#n[e][t];
4111
3076
  }
4112
- get bmatrix() {
3077
+ get asBmatrix() {
4113
3078
  return this.#t = 1, this;
4114
3079
  }
4115
- get Bmatrix() {
3080
+ get asBraceMatrix() {
4116
3081
  return this.#t = 2, this;
4117
3082
  }
4118
3083
  canBeAdded(e) {
@@ -4126,7 +3091,7 @@ var ve = class e {
4126
3091
  return this.dimension.cols === e.dimension.rows;
4127
3092
  }
4128
3093
  characteristic_polynom(t) {
4129
- return t ??= "k", this.clone().subtract(new e(this.dimension.rows).one().multiply(new M(t))).determinant();
3094
+ return t ??= "k", this.clone().subtract(new e(this.dimension.rows).one().multiply(new N(t))).determinant();
4130
3095
  }
4131
3096
  cofactor(e, t) {
4132
3097
  let n = this.clone();
@@ -4135,14 +3100,14 @@ var ve = class e {
4135
3100
  }), n.determinant().multiply((-1) ** (e + t));
4136
3101
  }
4137
3102
  get cols() {
4138
- let e = Array.from({ length: this.dimension.cols }, () => Array.from({ length: this.dimension.rows }, () => new M()));
3103
+ let e = Array.from({ length: this.dimension.cols }, () => Array.from({ length: this.dimension.rows }, () => new N()));
4139
3104
  return this.forEach((t, n, r) => {
4140
3105
  e[r][n] = t;
4141
3106
  }), e;
4142
3107
  }
4143
3108
  determinant() {
4144
3109
  if (!this.isSquare()) throw new n("Matrix is not square");
4145
- let e = new M();
3110
+ let e = new N();
4146
3111
  return this.#n.length === 1 ? this.#n[0][0].clone() : (this.values[0].forEach((t, n) => {
4147
3112
  let r = this.cofactor(0, n);
4148
3113
  e.add(t.clone().multiply(r));
@@ -4165,12 +3130,12 @@ var ve = class e {
4165
3130
  });
4166
3131
  }
4167
3132
  fromDimensions(e, t) {
4168
- return this.#n = Array.from({ length: e }, () => Array.from({ length: t }, () => new M())), this;
3133
+ return this.#n = Array.from({ length: e }, () => Array.from({ length: t }, () => new N())), this;
4169
3134
  }
4170
3135
  fromString(e) {
4171
3136
  if (e.startsWith("((") && e.endsWith("))")) return this.fromString(e.substring(1, e.length - 1));
4172
3137
  let t = e.split("),(");
4173
- return this.#n = t.map((e, n) => n === 0 ? e.substring(1).split(",") : n === t.length - 1 ? e.substring(0, e.length - 1).split(",") : e.split(",")).map((e) => e.map((e) => new M(e))), this;
3138
+ return this.#n = t.map((e, n) => n === 0 ? e.substring(1).split(",") : n === t.length - 1 ? e.substring(0, e.length - 1).split(",") : e.split(",")).map((e) => e.map((e) => new N(e))), this;
4174
3139
  }
4175
3140
  fromValues(e) {
4176
3141
  this.#n = [];
@@ -4179,7 +3144,7 @@ var ve = class e {
4179
3144
  return e.forEach((e) => {
4180
3145
  let t = [];
4181
3146
  e.forEach((e) => {
4182
- t.push(new M(e));
3147
+ t.push(new N(e));
4183
3148
  }), this.#n.push(t);
4184
3149
  }), this;
4185
3150
  }
@@ -4189,7 +3154,7 @@ var ve = class e {
4189
3154
  if (e.some((e) => e.dimension !== t)) throw new n("Each vectors must be the same dimension");
4190
3155
  return this.fromDimensions(e[0].dimension, e.length), e.forEach((e, t) => {
4191
3156
  e.array.forEach((e, n) => {
4192
- this.#n[n][t] = new M(e);
3157
+ this.#n[n][t] = new N(e);
4193
3158
  });
4194
3159
  }), this;
4195
3160
  }
@@ -4232,7 +3197,7 @@ var ve = class e {
4232
3197
  if (!this.canBeMultiplied(t)) throw new n("Cannot multiply a matrix with incompatibles dimensions");
4233
3198
  let r = new e(this.dimension.rows, t.dimension.cols);
4234
3199
  return r.forEach((e, n, i) => {
4235
- let a = this.rows[n], o = t.cols[i], s = new M();
3200
+ let a = this.rows[n], o = t.cols[i], s = new N();
4236
3201
  a.forEach((e, t) => {
4237
3202
  s.add(e.clone().multiply(o[t]));
4238
3203
  }), r.setValue(n, i, s);
@@ -4252,17 +3217,17 @@ var ve = class e {
4252
3217
  e.opposite();
4253
3218
  }), this;
4254
3219
  }
4255
- get pmatrix() {
3220
+ get asPmatrix() {
4256
3221
  return this.#t = 0, this;
4257
3222
  }
4258
- get vmatrix() {
3223
+ get asVmatrix() {
4259
3224
  return this.#t = 3, this;
4260
3225
  }
4261
- get Vmatrix() {
3226
+ get asDoubleVmatrix() {
4262
3227
  return this.#t = 4, this;
4263
3228
  }
4264
3229
  pow(e) {
4265
- return j(this, e);
3230
+ return M(this, e);
4266
3231
  }
4267
3232
  reduce() {
4268
3233
  throw new a("Not yet implemented");
@@ -4273,7 +3238,7 @@ var ve = class e {
4273
3238
  setValue(e, t, n) {
4274
3239
  let { rows: r, cols: i } = this.dimension;
4275
3240
  if (e < 0 || e >= r || t < 0 || t >= i) throw new o(`${e}x${t} is out of range (${r}x${i})`);
4276
- return this.#n[e][t] = new M(n), this;
3241
+ return this.#n[e][t] = new N(n), this;
4277
3242
  }
4278
3243
  subtract(e) {
4279
3244
  if (!this.canBeAdded(e)) throw new n("Cannot subtract a matrix with different dimensions.");
@@ -4298,31 +3263,31 @@ var ve = class e {
4298
3263
  };
4299
3264
  //#endregion
4300
3265
  //#region src/geometry/geomMath.ts
4301
- function ye(e, t) {
3266
+ function Ce(e, t) {
4302
3267
  return e.dimension === t.dimension && e.array.every((e, n) => t.array[n].isEqual(e));
4303
3268
  }
4304
- function be(e, t) {
3269
+ function we(e, t) {
4305
3270
  if (e.dimension !== t.dimension) return !1;
4306
3271
  let n = t.array[0].value / e.array[0].value;
4307
3272
  return e.array.every((e, r) => t.array[r].value === e.value * n);
4308
3273
  }
4309
- function xe(e, t) {
4310
- return e.dimension === t.dimension ? e.array.reduce((e, n, r) => e.add(n.clone().multiply(t.array[r])), new m(0)) : new m().invalid();
3274
+ function Te(e, t) {
3275
+ return e.dimension === t.dimension ? e.array.reduce((e, n, r) => e.add(n.clone().multiply(t.array[r])), new _(0)) : new _().invalid();
4311
3276
  }
4312
- function Se(...e) {
3277
+ function Ee(...e) {
4313
3278
  if (e.some((t) => t.dimension !== e[0].dimension)) throw new n("All vectors must have the same dimension");
4314
3279
  if (e[0].dimension !== e.length) throw new n(`The determinant of dimension ${e[0].dimension} must have the same number of vectors (${e.length} given)`);
4315
3280
  return e[0].dimension === 2 ? e[0].array[0].clone().multiply(e[1].array[1]).subtract(e[0].array[1].clone().multiply(e[1].array[0])) : e[0].array[0].clone().multiply(e[1].array[1].clone().multiply(e[2].array[2]).subtract(e[1].array[2].clone().multiply(e[2].array[1]))).subtract(e[0].array[1].clone().multiply(e[1].array[0].clone().multiply(e[2].array[2]).subtract(e[1].array[2].clone().multiply(e[2].array[0])))).add(e[0].array[2].clone().multiply(e[1].array[0].clone().multiply(e[2].array[1]).subtract(e[1].array[1].clone().multiply(e[2].array[0]))));
4316
3281
  }
4317
3282
  //#endregion
4318
3283
  //#region src/geometry/TupleN.ts
4319
- var B = class {
3284
+ var z = class {
4320
3285
  #e = [];
4321
3286
  #t;
4322
3287
  constructor(...e) {
4323
- this.#e = e.map((e) => new m(e));
3288
+ this.#e = e.map((e) => new _(e));
4324
3289
  }
4325
- copy() {
3290
+ cloneCoordinates() {
4326
3291
  return this.#e.map((e) => e.clone());
4327
3292
  }
4328
3293
  get array() {
@@ -4337,7 +3302,7 @@ var B = class {
4337
3302
  fromString(e) {
4338
3303
  e.startsWith("(") && (e = e.substring(1)), e.endsWith(")") && (e = e.substring(0, e.length - 1));
4339
3304
  let t = e.split(/[,;\s]/g).filter((e) => e.trim() !== "");
4340
- return t.length < 2 || (this.#e = t.map((e) => new m(e))), this;
3305
+ return t.length < 2 || (this.#e = t.map((e) => new _(e))), this;
4341
3306
  }
4342
3307
  get onChange() {
4343
3308
  return this.#t;
@@ -4348,20 +3313,20 @@ var B = class {
4348
3313
  setDimension(e = 2) {
4349
3314
  if (e < 2) throw new n("Dimension must be at least 2");
4350
3315
  if (e < this.dimension) this.#e = this.#e.slice(0, e);
4351
- else if (e > this.dimension) for (let t = this.dimension; t < e; t++) this.#e.push(new m(0));
3316
+ else if (e > this.dimension) for (let t = this.dimension; t < e; t++) this.#e.push(new _(0));
4352
3317
  return this;
4353
3318
  }
4354
3319
  get x() {
4355
3320
  return this.#e[0];
4356
3321
  }
4357
3322
  set x(e) {
4358
- this.#e[0] = new m(e), this.#t?.();
3323
+ this.#e[0] = new _(e), this.#t?.();
4359
3324
  }
4360
3325
  get y() {
4361
3326
  return this.#e[1];
4362
3327
  }
4363
3328
  set y(e) {
4364
- this.#e[1] = new m(e), this.#t?.();
3329
+ this.#e[1] = new _(e), this.#t?.();
4365
3330
  }
4366
3331
  get z() {
4367
3332
  if (this.dimension < 3) throw new n("Vector is not 3D");
@@ -4369,28 +3334,28 @@ var B = class {
4369
3334
  }
4370
3335
  set z(e) {
4371
3336
  if (this.dimension < 3) throw new n("Vector is not 3D");
4372
- this.#e[2] = new m(e), this.#t?.();
3337
+ this.#e[2] = new _(e), this.#t?.();
4373
3338
  }
4374
3339
  zero = () => (this.#e.forEach((e) => e.zero()), this.#t?.(), this);
4375
- }, V = class e extends B {
3340
+ }, B = class e extends z {
4376
3341
  constructor(...e) {
4377
3342
  super(), e.length > 0 && this.parse(...e);
4378
3343
  }
4379
3344
  parse(...n) {
4380
3345
  if (n.length === 1) {
4381
- if (n[0] instanceof B) return this.array = n[0].copy(), this;
3346
+ if (n[0] instanceof z) return this.array = n[0].cloneCoordinates(), this;
4382
3347
  if (typeof n[0] == "string") return this.fromString(n[0]), this;
4383
3348
  }
4384
3349
  if (n.length > 1) {
4385
3350
  if (n.some((t) => t instanceof e)) throw new i("Creating a point with multiple argument requires an input fraction");
4386
- let r = n.map((e) => new m(e));
3351
+ let r = n.map((e) => new _(e));
4387
3352
  if (r.some((e) => e.isNaN())) throw new t("The given values are not a valid point string (a,b): ");
4388
3353
  this.array = r;
4389
3354
  }
4390
3355
  return this;
4391
3356
  }
4392
3357
  clone() {
4393
- return new e(...this.copy());
3358
+ return new e(...this.cloneCoordinates());
4394
3359
  }
4395
3360
  get tex() {
4396
3361
  return `\\left(${this.array.map((e) => e.tex).join(";")}\\right)`;
@@ -4400,7 +3365,7 @@ var B = class {
4400
3365
  }
4401
3366
  distanceTo(e) {
4402
3367
  if (this.dimension !== e.dimension) throw new n("The two points must have the same dimensions.");
4403
- let t = this.array.map((t, n) => e.array[n].clone().subtract(t)).reduce((e, t) => e.add(t.clone().pow(2)), new m(0));
3368
+ let t = this.array.map((t, n) => e.array[n].clone().subtract(t)).reduce((e, t) => e.add(t.clone().pow(2)), new _(0));
4404
3369
  return new v().from(2, t).reduce();
4405
3370
  }
4406
3371
  isEqual(e) {
@@ -4415,28 +3380,31 @@ var B = class {
4415
3380
  this.array.push(e.clone().add(t.array[n]).divide(2));
4416
3381
  }), this;
4417
3382
  }
4418
- }, H = class e extends B {
3383
+ }, V = class e extends z {
4419
3384
  constructor(...e) {
4420
3385
  return super(), e.length > 0 && this.parse(...e), this;
4421
3386
  }
4422
3387
  parse(...e) {
4423
3388
  if (e.length === 0) throw new i("Invalid value");
4424
3389
  if (e.length === 1) {
4425
- if (e[0] instanceof B) return this.array = e[0].copy(), this;
3390
+ if (e[0] instanceof z) return this.array = e[0].cloneCoordinates(), this;
4426
3391
  if (typeof e[0] == "string") return this.fromString(e[0]);
4427
3392
  throw new i("Invalid value");
4428
3393
  }
4429
3394
  if (e.length === 2) {
4430
3395
  let [t, r] = e;
4431
- if (t instanceof B && r instanceof B) {
3396
+ if (t instanceof z && r instanceof z) {
4432
3397
  if (t.dimension !== r.dimension) throw new n("Vectors must have the same dimension");
4433
3398
  return this.array = r.array.map((e, n) => e.clone().subtract(t.array[n])), this;
4434
3399
  }
4435
3400
  }
4436
- return this.array = e.map((e) => new m(e)), this;
3401
+ return this.array = e.map((e) => new _(e)), this;
4437
3402
  }
4438
3403
  clone() {
4439
- return new e(...this.copy());
3404
+ return new e(...this.cloneCoordinates());
3405
+ }
3406
+ copy() {
3407
+ throw new a("copy() is not yet implemented for Vector");
4440
3408
  }
4441
3409
  get tex() {
4442
3410
  return `\\begin{pmatrix} ${this.array.map((e) => e.tex).join(" \\\\ ")} \\end{pmatrix}`;
@@ -4459,13 +3427,13 @@ var B = class {
4459
3427
  if (this.dimension !== 3 || t.dimension !== 3) throw new n("Cross product can only be determined in 3D");
4460
3428
  return new e(this.y.clone().multiply(t.z).subtract(this.z.clone().multiply(t.y)), this.z.clone().multiply(t.x).subtract(this.x.clone().multiply(t.z)), this.x.clone().multiply(t.y).subtract(this.y.clone().multiply(t.x)));
4461
3429
  }
4462
- divideByScalar = (e) => this.multiplyByScalar(new m(e).inverse());
4463
- dot = (e) => xe(this, e);
3430
+ divideByScalar = (e) => this.multiplyByScalar(new _(e).inverse());
3431
+ dot = (e) => Te(this, e);
4464
3432
  fromString(e) {
4465
3433
  return e.startsWith("((") && e.endsWith("))") ? super.fromString(e.slice(1, -1)) : super.fromString(e);
4466
3434
  }
4467
- isColinearTo = (e) => be(this, e);
4468
- isEqual = (e) => ye(this, e);
3435
+ isColinearTo = (e) => we(this, e);
3436
+ isEqual = (e) => Ce(this, e);
4469
3437
  isNormalTo = (e) => this.dot(e).isZero();
4470
3438
  get isNull() {
4471
3439
  return this.array.every((e) => e.isZero());
@@ -4477,14 +3445,14 @@ var B = class {
4477
3445
  return this.array.every((e) => e.isZero());
4478
3446
  }
4479
3447
  multiplyByScalar = (e) => {
4480
- let t = new m(e);
3448
+ let t = new _(e);
4481
3449
  return this.array.forEach((e) => e.multiply(t)), this;
4482
3450
  };
4483
3451
  get norm() {
4484
3452
  return Math.sqrt(this.normSquare.value);
4485
3453
  }
4486
3454
  get normSquare() {
4487
- return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new m(0));
3455
+ return this.array.reduce((e, t) => e.add(t.clone().pow(2)), new _(0));
4488
3456
  }
4489
3457
  normal = () => {
4490
3458
  if (this.dimension >= 3) throw new n("Normal vector can only be determined in 2D");
@@ -4494,8 +3462,8 @@ var B = class {
4494
3462
  one = () => (this.zero(), this.x.one(), this);
4495
3463
  opposite = () => (this.array.forEach((e) => e.opposite()), this);
4496
3464
  simplify = () => {
4497
- let e = p.lcm(...this.array.map((e) => e.denominator)), t = p.gcd(...this.array.map((e) => e.numerator));
4498
- return this.multiplyByScalar(new m(e, t)), this.x.isNegative() && this.opposite(), this;
3465
+ let e = g.lcm(...this.array.map((e) => e.denominator)), t = g.gcd(...this.array.map((e) => e.numerator));
3466
+ return this.multiplyByScalar(new _(e, t)), this.x.isNegative() && this.opposite(), this;
4499
3467
  };
4500
3468
  subtract = (e) => this.add(e.clone().opposite());
4501
3469
  translate(...e) {
@@ -4505,43 +3473,43 @@ var B = class {
4505
3473
  let e = this.norm;
4506
3474
  return e === 0 ? this : this.divideByScalar(e);
4507
3475
  };
4508
- }, U = /* @__PURE__ */ function(e) {
3476
+ }, H = /* @__PURE__ */ function(e) {
4509
3477
  return e.None = "none", e.Parallel = "parallel", e.Perpendicular = "perpendicular", e.Tangent = "tangent", e;
4510
- }({}), Ce = /* @__PURE__ */ function(e) {
3478
+ }({}), De = /* @__PURE__ */ function(e) {
4511
3479
  return e.None = "none", e.Parallel = "parallel", e.Perpendicular = "perpendicular", e.Tangent = "tangent", e;
4512
3480
  }({});
4513
3481
  //#endregion
4514
3482
  //#region src/randomization/rndHelpers.ts
4515
- function we(e = .5) {
3483
+ function Oe(e = .5) {
4516
3484
  return Math.random() < e;
4517
3485
  }
4518
- function W(e, t, n) {
4519
- if (t === void 0) return e >= 0 ? W(0, e) : W(e, 0);
3486
+ function U(e, t, n) {
3487
+ if (t === void 0) return e >= 0 ? U(0, e) : U(e, 0);
4520
3488
  if (e === t) return e;
4521
3489
  if (n === void 0) return Math.floor(Math.random() * (t - e + 1) + e);
4522
3490
  if (Math.abs(t - e) <= n.length) throw new i("The number of excluded values is too high.");
4523
- let r = W(e, t);
4524
- for (; n.includes(r);) r = W(e, t);
3491
+ let r = U(e, t);
3492
+ for (; n.includes(r);) r = U(e, t);
4525
3493
  return r;
4526
3494
  }
4527
- function G(e, t) {
4528
- return t === !1 ? we() ? W(1, e) : -W(1, e) : W(-e, e);
3495
+ function W(e, t) {
3496
+ return t === !1 ? Oe() ? U(1, e) : -U(1, e) : U(-e, e);
4529
3497
  }
4530
- function Te(e, t) {
4531
- let n = p.pythagoreanTripletsWithTarget(e).filter((e) => t === !0 || !e.includes(0));
4532
- return n.length === 0 ? null : K(n);
3498
+ function ke(e, t) {
3499
+ let n = g.pythagoreanTripletsWithTarget(e).filter((e) => t === !0 || !e.includes(0));
3500
+ return n.length === 0 ? null : G(n);
4533
3501
  }
4534
- function Ee(e) {
4535
- let t = p.primes();
4536
- return e !== void 0 && (t = t.filter((t) => t < e)), K(t);
3502
+ function Ae(e) {
3503
+ let t = g.primes();
3504
+ return e !== void 0 && (t = t.filter((t) => t < e)), G(t);
4537
3505
  }
4538
- function De(e, t) {
4539
- return t === void 0 && (t = 1), e.length <= 0 ? Object.values(e) : Oe(e).slice(0, t);
3506
+ function je(e, t) {
3507
+ return t === void 0 && (t = 1), e.length <= 0 ? Object.values(e) : Me(e).slice(0, t);
4540
3508
  }
4541
- function K(e) {
4542
- return e.length === 0 ? null : e[W(0, e.length - 1)];
3509
+ function G(e) {
3510
+ return e.length === 0 ? null : e[U(0, e.length - 1)];
4543
3511
  }
4544
- function Oe(e) {
3512
+ function Me(e) {
4545
3513
  let t = Object.values(e);
4546
3514
  for (let e = t.length - 1; e > 0; e--) {
4547
3515
  let n = Math.floor(Math.random() * (e + 1)), r = t[e];
@@ -4551,9 +3519,9 @@ function Oe(e) {
4551
3519
  }
4552
3520
  //#endregion
4553
3521
  //#region src/geometry/line.ts
4554
- var q = class e {
4555
- static PARALLEL = U.Parallel;
4556
- static PERPENDICULAR = U.Perpendicular;
3522
+ var K = class e {
3523
+ static PARALLEL = H.Parallel;
3524
+ static PERPENDICULAR = H.Perpendicular;
4557
3525
  #e;
4558
3526
  #t;
4559
3527
  #n;
@@ -4561,36 +3529,39 @@ var q = class e {
4561
3529
  #i;
4562
3530
  #a = 1;
4563
3531
  constructor(...e) {
4564
- return this.#t = new m().zero(), this.#n = new m().zero(), this.#r = new m().zero(), this.#e = new H(), this.#i = "lr", e.length > 0 && this.parse(...e), this;
3532
+ return this.#t = new _().zero(), this.#n = new _().zero(), this.#r = new _().zero(), this.#e = new V(), this.#i = "lr", e.length > 0 && this.parse(...e), this;
4565
3533
  }
4566
3534
  parse = (...n) => {
4567
3535
  if (n.length === 0) return this;
4568
3536
  if (n.length === 1) {
4569
3537
  if (n[0] instanceof e) return this.fromCoefficient(n[0].a, n[0].b, n[0].c);
4570
- if (n[0] instanceof N) return this.fromEquation(n[0]);
3538
+ if (n[0] instanceof P) return this.fromEquation(n[0]);
4571
3539
  if (typeof n[0] == "string") try {
4572
- let e = new N(n[0]);
3540
+ let e = new P(n[0]);
4573
3541
  return this.parse(e);
4574
3542
  } catch (e) {
4575
3543
  throw new t(`Cannot parse "${n[0]}" as a Line`, { cause: e });
4576
3544
  }
4577
3545
  }
4578
3546
  if (n.length === 2) {
4579
- if (n[0] instanceof V && n[1] instanceof V) return this.fromPoints(n[0], n[1]);
4580
- if (n[0] instanceof V && n[1] instanceof H) return this.fromPointAndDirection(n[0], n[1]);
3547
+ if (n[0] instanceof B && n[1] instanceof B) return this.fromPoints(n[0], n[1]);
3548
+ if (n[0] instanceof B && n[1] instanceof V) return this.fromPointAndDirection(n[0], n[1]);
4581
3549
  }
4582
- return n.length === 3 && n.every((e) => m.isFraction(e)) ? this.fromCoefficient(n[0], n[1], n[2]) : (console.warn("Something wrong happened while creating the line"), console.warn(n), this);
3550
+ return n.length === 3 && n.every((e) => _.isFraction(e)) ? this.fromCoefficient(n[0], n[1], n[2]) : (console.warn("Something wrong happened while creating the line"), console.warn(n), this);
4583
3551
  };
3552
+ copy() {
3553
+ throw new a("copy() is not yet implemented for Line");
3554
+ }
4584
3555
  clone = () => new e().fromCoefficient(this.#t, this.#n, this.#r);
4585
3556
  get tex() {
4586
3557
  let e = this.#a;
4587
3558
  switch (this.#a = 1, e) {
4588
3559
  case 0: return this.getEquation().reorder().tex;
4589
- case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new M().parse("x", this.slope, this.height).tex;
3560
+ case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.tex : "y=" + new N().parse("x", this.slope, this.height).tex;
4590
3561
  case 3:
4591
3562
  case 4: {
4592
3563
  let t = this.d.clone().simplify();
4593
- return e === 3 ? `${H.asTex("x", "y")} = ${H.asTex(this.#e.x.tex, this.#e.y.tex)} + k\\cdot ${H.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}\n\tx &= ${new M(this.#e.x).add(new A(t.x).multiply(new A("k"))).reorder("k", !0).tex}\\\\\n\ty &= ${new M(this.#e.y).add(new A(t.y).multiply(new A("k"))).reorder("k", !0).tex}\n\\end{aligned}\\right.`;
3564
+ return e === 3 ? `${V.asTex("x", "y")} = ${V.asTex(this.#e.x.tex, this.#e.y.tex)} + k\\cdot ${V.asTex(t.x.tex, t.y.tex)}` : `\\left\\{\\begin{aligned}\n\tx &= ${new N(this.#e.x).add(new O(t.x).multiply(new O("k"))).reorder("k", !0).tex}\\\\\n\ty &= ${new N(this.#e.y).add(new O(t.y).multiply(new O("k"))).reorder("k", !0).tex}\n\\end{aligned}\\right.`;
4594
3565
  }
4595
3566
  default: {
4596
3567
  let e = this.getEquation();
@@ -4602,13 +3573,13 @@ var q = class e {
4602
3573
  let e = this.#a;
4603
3574
  switch (this.#a = 1, e) {
4604
3575
  case 0: return this.getEquation().reorder().display;
4605
- case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new M().parse("x", this.slope, this.height).display;
3576
+ case 2: return this.slope.isInfinity() ? "x=" + this.OA.x.display : "y=" + new N().parse("x", this.slope, this.height).display;
4606
3577
  case 3: {
4607
3578
  let e = this.d.clone().simplify();
4608
3579
  return `((x,y))=((${this.#e.x.display},${this.#e.y.display}))+k((${e.x.display},${e.y.display}))`;
4609
3580
  }
4610
3581
  case 4: {
4611
- let e = this.d.clone().simplify(), t = new M(this.#e.x).add(new A(e.x).multiply(new A("k"))).reorder("k", !0), n = new M(this.#e.y).add(new A(e.y).multiply(new A("k"))).reorder("k", !0);
3582
+ let e = this.d.clone().simplify(), t = new N(this.#e.x).add(new O(e.x).multiply(new O("k"))).reorder("k", !0), n = new N(this.#e.y).add(new O(e.y).multiply(new O("k"))).reorder("k", !0);
4612
3583
  return `{(x,=,${t.display}),(y,=,${n.display}):}`;
4613
3584
  }
4614
3585
  default: {
@@ -4661,7 +3632,7 @@ var q = class e {
4661
3632
  return this.#t.isZero() || (t = this.#t.isOne() ? "x" : this.#t.clone().opposite().isOne() ? "-x" : this.#t.value.toFixed(e) + "x"), this.#n.isZero() || (this.#n.isPositive() && (t += "+"), t += this.#n.value.toFixed(e) + "y"), this.#r.isZero() || (this.#r.isPositive() && (t += "+"), t += this.#r.value.toFixed(e)), t + "=0";
4662
3633
  }
4663
3634
  get d() {
4664
- let e = new H(this.#n.clone(), this.#t.clone().opposite());
3635
+ let e = new V(this.#n.clone(), this.#t.clone().opposite());
4665
3636
  return (this.#i === "lr" && e.x.isNegative() || this.#i === "rl" && e.x.isPositive()) && e.opposite(), e;
4666
3637
  }
4667
3638
  set d(e) {
@@ -4675,19 +3646,19 @@ var q = class e {
4675
3646
  return n.isZero() ? new v(0) : new v().from(2, n.inverse(), t).reduce();
4676
3647
  }
4677
3648
  fromCoefficient(e, t, n) {
4678
- this.#t = new m(e), this.#n = new m(t), this.#r = new m(n);
3649
+ this.#t = new _(e), this.#n = new _(t), this.#r = new _(n);
4679
3650
  let r = [
4680
3651
  this.#t,
4681
3652
  this.#n,
4682
3653
  this.#r
4683
- ].every((e) => e.exact) ? p.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator) : 1;
4684
- if (r > 1 && (this.#t.multiply(r).reduce(), this.#n.multiply(r).reduce(), this.#r.multiply(r).reduce()), this.#n.isZero()) return this.#e = new H(this.#r.clone().divide(this.#t).opposite(), 0), this;
3654
+ ].every((e) => e.exact) ? g.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator) : 1;
3655
+ if (r > 1 && (this.#t.multiply(r).reduce(), this.#n.multiply(r).reduce(), this.#r.multiply(r).reduce()), this.#n.isZero()) return this.#e = new V(this.#r.clone().divide(this.#t).opposite(), 0), this;
4685
3656
  for (let e = 0; e < this.#n.value; e++) {
4686
3657
  let t = this.#t.clone().divide(this.#n).multiply(e).subtract(this.#r.clone().divide(this.#n)).reduce();
4687
- if (this.#e = new H(e, t), t.isRelative()) return this;
3658
+ if (this.#e = new V(e, t), t.isRelative()) return this;
4688
3659
  }
4689
3660
  let i = this.#r.clone().divide(this.#n).opposite().reduce();
4690
- return this.#e = new H(0, i), this;
3661
+ return this.#e = new V(0, i), this;
4691
3662
  }
4692
3663
  fromEquation(e) {
4693
3664
  e.reorder(!0);
@@ -4705,23 +3676,23 @@ var q = class e {
4705
3676
  fromPointAndDirection(e, t) {
4706
3677
  return this.#i = t.x.isPositive() ? "lr" : "rl", this.fromPointAndNormal(e, t.clone().normal());
4707
3678
  }
4708
- fromPointAndLine(e, t, n = U.Parallel) {
4709
- return n === U.Perpendicular ? this.fromPointAndNormal(e, t.director) : this.fromPointAndNormal(e, t.normal);
3679
+ fromPointAndLine(e, t, n = H.Parallel) {
3680
+ return n === H.Perpendicular ? this.fromPointAndNormal(e, t.director) : this.fromPointAndNormal(e, t.normal);
4710
3681
  }
4711
- fromPointAndNormal = (e, t) => t.isZero() ? (console.warn("Normal vector is null."), this) : (this.fromCoefficient(t.x, t.y, e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()), this.#e = new H(e.clone()), this);
3682
+ fromPointAndNormal = (e, t) => t.isZero() ? (console.warn("Normal vector is null."), this) : (this.fromCoefficient(t.x, t.y, e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()), this.#e = new V(e.clone()), this);
4712
3683
  fromPoints(e, t) {
4713
- return this.fromPointAndNormal(e, new H(e, t).normal());
3684
+ return this.fromPointAndNormal(e, new V(e, t).normal());
4714
3685
  }
4715
3686
  getEquation() {
4716
- return new N(new M().parse("xy", this.#t, this.#n, this.#r), new M("0")).simplify();
3687
+ return new P(new N().parse("xy", this.#t, this.#n, this.#r), new N("0")).simplify();
4717
3688
  }
4718
3689
  getValueAtX = (e) => {
4719
- let t = this.getEquation().isolate("y"), n = new m(e);
4720
- return t instanceof N ? t.right.evaluate({ x: n }) : new m().invalid();
3690
+ let t = this.getEquation().isolate("y"), n = new _(e);
3691
+ return t instanceof P ? t.right.evaluate({ x: n }) : new _().invalid();
4721
3692
  };
4722
3693
  getValueAtY = (e) => {
4723
- let t = this.getEquation().isolate("x"), n = new m(e);
4724
- return t instanceof N ? t.right.evaluate({ y: n }) : new m().invalid();
3694
+ let t = this.getEquation().isolate("x"), n = new _(e);
3695
+ return t instanceof P ? t.right.evaluate({ y: n }) : new _().invalid();
4725
3696
  };
4726
3697
  get height() {
4727
3698
  return this.#r.clone().opposite().divide(this.#n);
@@ -4731,8 +3702,8 @@ var q = class e {
4731
3702
  return r.hasIntersection ? r.point.x.value >= Math.min(t.x.value, n.x.value) && r.point.x.value <= Math.max(t.x.value, n.x.value) && r.point.y.value >= Math.min(t.y.value, n.y.value) && r.point.y.value <= Math.max(t.y.value, n.y.value) : !1;
4732
3703
  }
4733
3704
  intersection = (e) => {
4734
- let t = new V(), n = !1, r = !1;
4735
- return this.#n.isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new m().invalid(), t.y = new m().invalid(), n = !0) : this.isSameAs(e) ? (t.x = new m().invalid(), t.y = new m().invalid(), r = !0) : (t.x = this.#n.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.b)).divide(this.#t.clone().multiply(e.b).subtract(this.#n.clone().multiply(e.a))), t.y = this.#t.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.a)).divide(this.#n.clone().multiply(e.a).subtract(this.#t.clone().multiply(e.b)))), {
3705
+ let t = new B(), n = !1, r = !1;
3706
+ return this.#n.isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new _().invalid(), t.y = new _().invalid(), n = !0) : this.isSameAs(e) ? (t.x = new _().invalid(), t.y = new _().invalid(), r = !0) : (t.x = this.#n.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.b)).divide(this.#t.clone().multiply(e.b).subtract(this.#n.clone().multiply(e.a))), t.y = this.#t.clone().multiply(e.c).subtract(this.#r.clone().multiply(e.a)).divide(this.#n.clone().multiply(e.a).subtract(this.#t.clone().multiply(e.b)))), {
4736
3707
  point: t,
4737
3708
  hasIntersection: !(n || r),
4738
3709
  isParallel: n,
@@ -4753,25 +3724,25 @@ var q = class e {
4753
3724
  return this.d.normal();
4754
3725
  }
4755
3726
  get normal() {
4756
- return new H(this.#t, this.#n);
3727
+ return new V(this.#t, this.#n);
4757
3728
  }
4758
3729
  randomNearPoint = (e) => {
4759
3730
  let t = this.randomPoint(e), n = 10;
4760
- for (; this.isOnLine(t) && n > 0;) t.x.add(G(1, !1)), t.y.add(G(1, !1)), n--;
3731
+ for (; this.isOnLine(t) && n > 0;) t.x.add(W(1, !1)), t.y.add(W(1, !1)), n--;
4761
3732
  return t;
4762
3733
  };
4763
- randomPoint = (e) => new V(this.d.clone().multiplyByScalar(G(e === void 0 || e <= 1 ? 3 : e, !1)).add(this.#e));
3734
+ randomPoint = (e) => new B(this.d.clone().multiplyByScalar(W(e === void 0 || e <= 1 ? 3 : e, !1)).add(this.#e));
4764
3735
  simplify = () => {
4765
- let e = p.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator), t = p.gcd(this.#t.numerator, this.#n.numerator, this.#r.numerator);
3736
+ let e = g.lcm(this.#t.denominator, this.#n.denominator, this.#r.denominator), t = g.gcd(this.#t.numerator, this.#n.numerator, this.#r.numerator);
4766
3737
  return this.fromCoefficient(this.#t.clone().multiply(e).divide(t), this.#n.clone().multiply(e).divide(t), this.#r.clone().multiply(e).divide(t)), this;
4767
3738
  };
4768
3739
  get slope() {
4769
3740
  return this.#t.clone().opposite().divide(this.#n);
4770
3741
  }
4771
- }, J = class e {
4772
- #e = new V();
4773
- #t = new V();
4774
- #n = new V();
3742
+ }, q = class e {
3743
+ #e = new B();
3744
+ #t = new B();
3745
+ #n = new B();
4775
3746
  #r = !1;
4776
3747
  #i = null;
4777
3748
  #a = !0;
@@ -4792,11 +3763,11 @@ var q = class e {
4792
3763
  let [e, n, r] = t;
4793
3764
  return this.fromLines(e, n, r);
4794
3765
  }
4795
- if (t.every((e) => e instanceof q)) return this.fromLines(t[0], t[1], t[2]);
4796
- if (t.every((e) => e instanceof V)) return this.fromPoints(t[0], t[1], t[2]);
3766
+ if (t.every((e) => e instanceof K)) return this.fromLines(t[0], t[1], t[2]);
3767
+ if (t.every((e) => e instanceof B)) return this.fromPoints(t[0], t[1], t[2]);
4797
3768
  }
4798
3769
  if (t.length === 6) {
4799
- let e = t.map((e) => new m(e));
3770
+ let e = t.map((e) => new _(e));
4800
3771
  if (e.some((e) => e.isNaN())) throw new i("One of the values is not a valid number");
4801
3772
  return this.fromCoordinates(e[0], e[1], e[2], e[3], e[4], e[5]);
4802
3773
  }
@@ -4849,10 +3820,10 @@ var q = class e {
4849
3820
  return this.#a = !0, this;
4850
3821
  }
4851
3822
  fromCoordinates(e, t, n, r, i, a) {
4852
- return this.fromPoints(new V(e, t), new V(n, r), new V(i, a));
3823
+ return this.fromPoints(new B(e, t), new B(n, r), new B(i, a));
4853
3824
  }
4854
3825
  fromLines(e, t, n) {
4855
- let r = new q(e).clone(), i = new q(t).clone(), a = new q(n).clone(), o = r.intersection(i);
3826
+ let r = new K(e).clone(), i = new K(t).clone(), a = new K(n).clone(), o = r.intersection(i);
4856
3827
  if (o.hasIntersection) this.#t = o.point;
4857
3828
  else return this.#r = !1, this;
4858
3829
  if (o = i.intersection(a), o.hasIntersection) this.#n = o.point;
@@ -4895,7 +3866,7 @@ var q = class e {
4895
3866
  }
4896
3867
  getHeights() {
4897
3868
  if (!this.#o.heights) {
4898
- let e = new q().fromPointAndNormal(this.#e, new H(this.#t, this.#n)), t = new q().fromPointAndNormal(this.#t, new H(this.#e, this.#n)), n = new q().fromPointAndNormal(this.#n, new H(this.#e, this.#t)), r = e.intersection(t).point;
3869
+ let e = new K().fromPointAndNormal(this.#e, new V(this.#t, this.#n)), t = new K().fromPointAndNormal(this.#t, new V(this.#e, this.#n)), n = new K().fromPointAndNormal(this.#n, new V(this.#e, this.#t)), r = e.intersection(t).point;
4899
3870
  this.#o.heights = {
4900
3871
  A: e,
4901
3872
  B: t,
@@ -4908,7 +3879,7 @@ var q = class e {
4908
3879
  getMedians() {
4909
3880
  let e = this.getMiddles();
4910
3881
  if (!this.#o.medians) {
4911
- let t = new q().fromPoints(this.#e, e.BC), n = new q().fromPoints(this.#t, e.AC), r = new q().fromPoints(this.#n, e.AB), i = t.intersection(n).point;
3882
+ let t = new K().fromPoints(this.#e, e.BC), n = new K().fromPoints(this.#t, e.AC), r = new K().fromPoints(this.#n, e.AB), i = t.intersection(n).point;
4912
3883
  this.#o.medians = {
4913
3884
  A: t,
4914
3885
  B: n,
@@ -4921,7 +3892,7 @@ var q = class e {
4921
3892
  getMediators() {
4922
3893
  let e = this.getMiddles();
4923
3894
  if (!this.#o.mediators) {
4924
- let t = new q().fromPointAndNormal(e.BC, new H(this.#t, this.#n)), n = new q().fromPointAndNormal(e.AC, new H(this.#e, this.#n)), r = new q().fromPointAndNormal(e.AB, new H(this.#e, this.#t)), i = t.intersection(n).point;
3895
+ let t = new K().fromPointAndNormal(e.BC, new V(this.#t, this.#n)), n = new K().fromPointAndNormal(e.AC, new V(this.#e, this.#n)), r = new K().fromPointAndNormal(e.AB, new V(this.#e, this.#t)), i = t.intersection(n).point;
4925
3896
  this.#o.mediators = {
4926
3897
  a: t,
4927
3898
  b: n,
@@ -4933,9 +3904,9 @@ var q = class e {
4933
3904
  }
4934
3905
  getMiddles() {
4935
3906
  return {
4936
- AB: new V().middleOf(this.#e, this.#t),
4937
- AC: new V().middleOf(this.#e, this.#n),
4938
- BC: new V().middleOf(this.#t, this.#n)
3907
+ AB: new B().middleOf(this.#e, this.#t),
3908
+ AC: new B().middleOf(this.#e, this.#n),
3909
+ BC: new B().middleOf(this.#t, this.#n)
4939
3910
  };
4940
3911
  }
4941
3912
  getPoints() {
@@ -4974,9 +3945,9 @@ var q = class e {
4974
3945
  }
4975
3946
  get lines() {
4976
3947
  return this.#i === null && (this.#i = {
4977
- AB: new q(this.#e, this.#t),
4978
- BC: new q(this.#t, this.#n),
4979
- AC: new q(this.#e, this.#n)
3948
+ AB: new K(this.#e, this.#t),
3949
+ BC: new K(this.#t, this.#n),
3950
+ AC: new K(this.#e, this.#n)
4980
3951
  }), this.#i;
4981
3952
  }
4982
3953
  medianA() {
@@ -5001,14 +3972,14 @@ var q = class e {
5001
3972
  }, this;
5002
3973
  }
5003
3974
  #s(e, t = !0) {
5004
- let n = this.lines, r = new H(), i = new H(), a = new V();
3975
+ let n = this.lines, r = new V(), i = new V(), a = new B();
5005
3976
  if (e === "A" ? (a = this.A.clone(), r = n.AB.clone().d, i = n.AC.clone().d) : e === "B" ? (a = this.B.clone(), r = n.AB.clone().d.opposite(), i = n.BC.clone().d) : e === "C" && (a = this.C.clone(), r = n.BC.clone().d.opposite(), i = n.AC.clone().d.opposite()), r === void 0 || i === void 0) throw new o(`The point ${e} does not exist`);
5006
3977
  let s = t ? r.unit().add(i.unit()) : r.unit().subtract(i.unit());
5007
- return new q().fromPointAndDirection(a, s);
3978
+ return new K().fromPointAndDirection(a, s);
5008
3979
  }
5009
3980
  #c(e, t, n) {
5010
3981
  let r = (t ** 2 + n ** 2 - e ** 2) / (2 * t * n);
5011
- return this.#a ? Math.acos(r) : p.numberCorrection(Math.acos(r) * 180 / Math.PI);
3982
+ return this.#a ? Math.acos(r) : g.numberCorrection(Math.acos(r) * 180 / Math.PI);
5012
3983
  }
5013
3984
  #l = (e) => {
5014
3985
  switch (e.toUpperCase()) {
@@ -5018,8 +3989,8 @@ var q = class e {
5018
3989
  }
5019
3990
  return this.#e;
5020
3991
  };
5021
- #u = (e, t) => new H(this.#l(e), this.#l(t));
5022
- }, Y = class e {
3992
+ #u = (e, t) => new V(this.#l(e), this.#l(t));
3993
+ }, J = class e {
5023
3994
  #e = null;
5024
3995
  #t = null;
5025
3996
  #n = 1;
@@ -5028,7 +3999,7 @@ var q = class e {
5028
3999
  e.length > 0 && this.parse(...e);
5029
4000
  }
5030
4001
  parse(...t) {
5031
- return typeof t[0] == "string" ? this.fromString(t[0]) : t[0] instanceof N ? this.fromEquation(t[0]) : t[0] instanceof e ? this.copy(t[0]) : t.length === 2 && t[0] instanceof V && t[1] instanceof V ? this.fromCenterPoint(t[0], t[1]) : t.length >= 2 && t[0] instanceof V && (t[1] instanceof m || typeof t[1] == "number") ? this.fromCenterRadius(t[0], t[1], typeof t[2] == "boolean" && t[2]) : this;
4002
+ return typeof t[0] == "string" ? this.fromString(t[0]) : t[0] instanceof P ? this.fromEquation(t[0]) : t[0] instanceof e ? this.copy(t[0]) : t.length === 2 && t[0] instanceof B && t[1] instanceof B ? this.fromCenterPoint(t[0], t[1]) : t.length >= 2 && t[0] instanceof B && (t[1] instanceof _ || typeof t[1] == "number") ? this.fromCenterRadius(t[0], t[1], typeof t[2] == "boolean" && t[2]) : this;
5032
4003
  }
5033
4004
  clone() {
5034
4005
  return new e().fromCenterRadius(this.center.clone(), this.squareRadius.clone(), !0);
@@ -5053,36 +4024,36 @@ var q = class e {
5053
4024
  return this.#n = 1, this;
5054
4025
  }
5055
4026
  get center() {
5056
- return this.#e ?? new V();
4027
+ return this.#e ?? new B();
5057
4028
  }
5058
4029
  get equation() {
5059
- return this.#t?.clone() ?? new N("0=0");
4030
+ return this.#t?.clone() ?? new P("0=0");
5060
4031
  }
5061
4032
  fromCenterPoint(e, t) {
5062
- return this.#e = e.clone(), this.#r = new H(this.#e, t).normSquare, this.#i(), this;
4033
+ return this.#e = e.clone(), this.#r = new V(this.#e, t).normSquare, this.#i(), this;
5063
4034
  }
5064
4035
  fromCenterRadius(e, t, n) {
5065
- return this.#e = e.clone(), this.#r = n ? new m(t) : new m(t).pow(2), this.#i(), this;
4036
+ return this.#e = e.clone(), this.#r = n ? new _(t) : new _(t).pow(2), this.#i(), this;
5066
4037
  }
5067
4038
  fromEquation(e) {
5068
4039
  if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
5069
4040
  let t = e.left.monomByDegree(2, "x"), n = e.left.monomByDegree(2, "y"), r, i, a;
5070
- if (t.coefficient.isEqual(n.coefficient)) return e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), i = e.left.monomByDegree(1, "y"), a = e.left.monomByDegree(0), this.#e = new V(r.coefficient.clone().divide(2).opposite(), i.coefficient.clone().divide(2).opposite()), this.#r = a.coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)), this.#i(), this;
4041
+ if (t.coefficient.isEqual(n.coefficient)) return e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), i = e.left.monomByDegree(1, "y"), a = e.left.monomByDegree(0), this.#e = new B(r.coefficient.clone().divide(2).opposite(), i.coefficient.clone().divide(2).opposite()), this.#r = a.coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)), this.#i(), this;
5071
4042
  this.#a();
5072
4043
  }
5073
4044
  return this;
5074
4045
  }
5075
4046
  fromPoints(e, t, n) {
5076
- let r = new J(e, t, n);
4047
+ let r = new q(e, t, n);
5077
4048
  if (!r.isValid || !r.remarquables) return this.#a(), this;
5078
4049
  let i = r.getMediators().c.clone(), a = r.getMediators().b.clone();
5079
4050
  return this.fromCenterPoint(i.intersection(a).point, e);
5080
4051
  }
5081
4052
  fromString(e) {
5082
- return this.fromEquation(new N(e));
4053
+ return this.fromEquation(new P(e));
5083
4054
  }
5084
4055
  getPointsOnCircle() {
5085
- let e = p.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), t = [];
4056
+ let e = g.pythagoreanTripletsWithTarget(this.squareRadius.value, !0), t = [];
5086
4057
  return e.forEach((e) => {
5087
4058
  for (let n of [
5088
4059
  [1, 1],
@@ -5091,7 +4062,7 @@ var q = class e {
5091
4062
  [1, -1]
5092
4063
  ]) {
5093
4064
  let r = this.center.x.clone().add(n[0] * e[0]), i = this.center.y.clone().add(n[1] * e[1]);
5094
- t.every((e) => !e.isEqualXY(r, i)) && t.push(new V(r, i));
4065
+ t.every((e) => !e.isEqualXY(r, i)) && t.push(new B(r, i));
5095
4066
  }
5096
4067
  }), t;
5097
4068
  }
@@ -5108,10 +4079,10 @@ var q = class e {
5108
4079
  if (s.length === 0) return [];
5109
4080
  if (s.length === 1) {
5110
4081
  let e = r.add(n.clone().multiplyByScalar(s[0].fraction));
5111
- return [new V(e.x, e.y)];
4082
+ return [new B(e.x, e.y)];
5112
4083
  }
5113
4084
  let c = s[0].exact ? r.clone().add(n.clone().multiplyByScalar(s[0].fraction)) : r.clone().add(n.clone().multiplyByScalar(s[0].value)), l = s[1].exact ? r.clone().add(n.clone().multiplyByScalar(s[1].fraction)) : r.clone().add(n.clone().multiplyByScalar(s[1].value));
5114
- return [new V(c.x, c.y), new V(l.x, l.y)].sort((e, t) => n.x.isZero() ? n.y.isPositive() ? e.y.value - t.y.value : t.y.value - e.y.value : n.x.isPositive() ? e.x.value - t.x.value : t.x.value - e.x.value);
4085
+ return [new B(c.x, c.y), new B(l.x, l.y)].sort((e, t) => n.x.isZero() ? n.y.isPositive() ? e.y.value - t.y.value : t.y.value - e.y.value : n.x.isPositive() ? e.x.value - t.x.value : t.x.value - e.x.value);
5115
4086
  }
5116
4087
  get radius() {
5117
4088
  return new v().from(2, this.#r ?? 0);
@@ -5122,57 +4093,57 @@ var q = class e {
5122
4093
  return t - n > 1e-10 ? 0 : Math.abs(t - n) < 1e-10 ? 1 : 2;
5123
4094
  }
5124
4095
  setRadius(e, t) {
5125
- return this.#r = t ? new m(e) : new m(e).pow(2), this.#i(), this;
4096
+ return this.#r = t ? new _(e) : new _(e).pow(2), this.#i(), this;
5126
4097
  }
5127
4098
  get squareRadius() {
5128
- return this.#r?.clone() ?? new m(-1);
4099
+ return this.#r?.clone() ?? new _(-1);
5129
4100
  }
5130
- tangents = (e) => e instanceof m ? this.#c(e) : this.isPointOnCircle(e) ? this.#o(e) : this.#e !== null && this.#e.distanceTo(e).value > this.radius.value ? this.#s(e) : [];
4101
+ tangents = (e) => e instanceof _ ? this.#c(e) : this.isPointOnCircle(e) ? this.#o(e) : this.#e !== null && this.#e.distanceTo(e).value > this.radius.value ? this.#s(e) : [];
5131
4102
  #i() {
5132
- this.#t = new N(new M(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`), new M(this.squareRadius.display)).moveLeft();
4103
+ this.#t = new P(new N(`(x-(${this.center.x.display}))^2+(y-(${this.center.y.display}))^2`), new N(this.squareRadius.display)).moveLeft();
5133
4104
  }
5134
4105
  #a() {
5135
4106
  this.#e = null, this.#r = null, this.#t = null;
5136
4107
  }
5137
4108
  #o = (e) => {
5138
- let t = new H(this.center, e);
5139
- return [new q().fromPointAndNormal(e, t)];
4109
+ let t = new V(this.center, e);
4110
+ return [new K().fromPointAndNormal(e, t)];
5140
4111
  };
5141
4112
  #s = (e) => {
5142
- let t = this.center.x.clone().subtract(e.x), n = this.center.y.clone().subtract(e.y), r = new M("x"), i = new M("x^2+1");
5143
- return r.multiply(t).subtract(n).pow(2), i.multiply(this.squareRadius), new N(r, i).solve().map((t) => {
5144
- let n, r = new N("y", "x");
5145
- return t.exact ? (n = e.x.clone().opposite().multiply(t.fraction).add(e.y), r.right.multiply(t.fraction).add(n)) : (n = e.x.clone().opposite().multiply(t.value).add(e.y), r.right.multiply(t.value).add(n)), new q(r);
4113
+ let t = this.center.x.clone().subtract(e.x), n = this.center.y.clone().subtract(e.y), r = new N("x"), i = new N("x^2+1");
4114
+ return r.multiply(t).subtract(n).pow(2), i.multiply(this.squareRadius), new P(r, i).solve().map((t) => {
4115
+ let n, r = new P("y", "x");
4116
+ return t.exact ? (n = e.x.clone().opposite().multiply(t.fraction).add(e.y), r.right.multiply(t.fraction).add(n)) : (n = e.x.clone().opposite().multiply(t.value).add(e.y), r.right.multiply(t.value).add(n)), new K(r);
5146
4117
  });
5147
4118
  };
5148
4119
  #c = (e) => {
5149
4120
  let t = e.numerator, n = -e.denominator, r = this.center.x.clone(), i = this.center.y.clone(), a = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), o = r.clone().multiply(t).opposite().subtract(i.clone().multiply(n)).add(a.clone().sqrt()), s = r.clone().multiply(t).opposite().subtract(i.clone().multiply(n)).subtract(a.clone().sqrt());
5150
- return [new q(t, n, o), new q(t, n, s)];
4121
+ return [new K(t, n, o), new K(t, n, s)];
5151
4122
  };
5152
- }, X = class e {
5153
- static PARALLEL = Ce.Parallel;
5154
- static PERPENDICULAR = Ce.Perpendicular;
5155
- #e = new V();
5156
- #t = new H();
4123
+ }, Y = class e {
4124
+ static PARALLEL = De.Parallel;
4125
+ static PERPENDICULAR = De.Perpendicular;
4126
+ #e = new B();
4127
+ #t = new V();
5157
4128
  constructor(e, t) {
5158
- return this.#e = e.clone(), this.#t = t instanceof V ? new H(e, t) : t.clone(), this;
4129
+ return this.#e = e.clone(), this.#t = t instanceof B ? new V(e, t) : t.clone(), this;
5159
4130
  }
5160
4131
  clone = () => (this.#t = this.#t.clone(), this.#e = this.#e.clone(), this);
5161
4132
  get tex() {
5162
4133
  return {
5163
- parametric: `${H.asTex("x", "y", "z")} = ${H.asTex(this.#e.x.tex, this.#e.y.tex, this.#e.z.tex)} + k\\cdot ${H.asTex(this.#t.x.tex, this.#t.y.tex, this.#t.z.tex)}`,
4134
+ parametric: `${V.asTex("x", "y", "z")} = ${V.asTex(this.#e.x.tex, this.#e.y.tex, this.#e.z.tex)} + k\\cdot ${V.asTex(this.#t.x.tex, this.#t.y.tex, this.#t.z.tex)}`,
5164
4135
  system: `\\left\\{\\begin{aligned}
5165
- x &= ${new M(this.#e.x).add(new A(this.#t.x).multiply(new A("k"))).reorder("k", !0).tex}\\\\
5166
- y &= ${new M(this.#e.y).add(new A(this.#t.y).multiply(new A("k"))).reorder("k", !0).tex}\\\\
5167
- z &= ${new M(this.#e.z).add(new A(this.#t.z).multiply(new A("k"))).reorder("k", !0).tex}
4136
+ x &= ${new N(this.#e.x).add(new O(this.#t.x).multiply(new O("k"))).reorder("k", !0).tex}\\\\
4137
+ y &= ${new N(this.#e.y).add(new O(this.#t.y).multiply(new O("k"))).reorder("k", !0).tex}\\\\
4138
+ z &= ${new N(this.#e.z).add(new O(this.#t.z).multiply(new O("k"))).reorder("k", !0).tex}
5168
4139
  \\end{aligned}\\right.`,
5169
- cartesian: `\\frac{ ${new M("x", 1, this.#e.x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new M("y", 1, this.#e.y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new M("z", 1, this.#e.z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
4140
+ cartesian: `\\frac{ ${new N("x", 1, this.#e.x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new N("y", 1, this.#e.y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new N("z", 1, this.#e.z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
5170
4141
  };
5171
4142
  }
5172
4143
  get display() {
5173
4144
  let e = this.#e.x.display, t = this.#e.y.display, n = this.#e.z.display, r = this.direction.simplify(), i = r.x.display, a = r.y.display, o = r.z.display;
5174
4145
  return {
5175
- parametric: `${H.asDisplay("x", "y", "z")} = ${H.asDisplay(this.#e.x.display, this.#e.y.display, this.#e.z.display)} + k\\cdot ${H.asDisplay(this.#t.x.display, this.#t.y.display, this.#t.z.display)}`,
4146
+ parametric: `${V.asDisplay("x", "y", "z")} = ${V.asDisplay(this.#e.x.display, this.#e.y.display, this.#e.z.display)} + k\\cdot ${V.asDisplay(this.#t.x.display, this.#t.y.display, this.#t.z.display)}`,
5176
4147
  system: "",
5177
4148
  cartesian: `(x-${e})/${i} = (y-${t})/${a} = (z-${n})/${o}`
5178
4149
  };
@@ -5193,7 +4164,7 @@ var q = class e {
5193
4164
  return this.#t.clone();
5194
4165
  }
5195
4166
  distanceTo(e) {
5196
- let t = new H(this.#e, e), n = this.direction, r = this.direction.normSquare, i = t.cross(n).normSquare.clone().divide(r), a = i.clone().sqrt();
4167
+ let t = new V(this.#e, e), n = this.direction, r = this.direction.normSquare, i = t.cross(n).normSquare.clone().divide(r), a = i.clone().sqrt();
5197
4168
  return {
5198
4169
  value: Math.sqrt(i.value),
5199
4170
  fraction: i.clone().sqrt(),
@@ -5224,15 +4195,15 @@ var q = class e {
5224
4195
  return this.#e.clone();
5225
4196
  }
5226
4197
  randomPoint = (e = 5) => {
5227
- let t = this.#e.clone(), n = new m(G(e, !1));
5228
- return new V(t.x.clone().add(this.#t.x.clone().multiply(n)), t.y.clone().add(this.#t.y.clone().multiply(n)), t.z.clone().add(this.#t.z.clone().multiply(n)));
4198
+ let t = this.#e.clone(), n = new _(W(e, !1));
4199
+ return new B(t.x.clone().add(this.#t.x.clone().multiply(n)), t.y.clone().add(this.#t.y.clone().multiply(n)), t.z.clone().add(this.#t.z.clone().multiply(n)));
5229
4200
  };
5230
4201
  simplify = () => {
5231
4202
  throw new a("Method not implemented.");
5232
4203
  };
5233
- }, ke = class e {
5234
- #e = new H(0, 0, 1);
5235
- #t = new V(0, 0, 0);
4204
+ }, Ne = class e {
4205
+ #e = new V(0, 0, 1);
4206
+ #t = new B(0, 0, 0);
5236
4207
  constructor(e) {
5237
4208
  return e && this.parse(e), this;
5238
4209
  }
@@ -5249,25 +4220,25 @@ var q = class e {
5249
4220
  }
5250
4221
  if (e.equation) {
5251
4222
  let t = e.equation.moveLeft().reduce().left, n = t.monomByLetter("x").coefficient, r = t.monomByLetter("y").coefficient, i = t.monomByLetter("z").coefficient, a = t.monomByDegree(0).coefficient;
5252
- this.normal = new H(n, r, i), this.point = n.isNotZero() ? new V(a.clone().divide(n).opposite(), 0, 0) : r.isNotZero() ? new V(0, a.clone().divide(r).opposite(), 0) : new V(0, 0, a.clone().divide(i).opposite());
4223
+ this.normal = new V(n, r, i), this.point = n.isNotZero() ? new B(a.clone().divide(n).opposite(), 0, 0) : r.isNotZero() ? new B(0, a.clone().divide(r).opposite(), 0) : new B(0, 0, a.clone().divide(i).opposite());
5253
4224
  return;
5254
4225
  }
5255
- if (e.points?.length === 3 && e.points.every((e) => e instanceof H)) {
5256
- let t = e.points[0], n = e.points[1], r = e.points[2], i = new H(t, n), a = new H(t, r);
4226
+ if (e.points?.length === 3 && e.points.every((e) => e instanceof V)) {
4227
+ let t = e.points[0], n = e.points[1], r = e.points[2], i = new V(t, n), a = new V(t, r);
5257
4228
  this.normal = i.cross(a), this.point = t;
5258
4229
  return;
5259
4230
  }
5260
4231
  if (e.coefficients?.length === 4) {
5261
4232
  let [t, n, r, i] = e.coefficients;
5262
- this.normal = new H(t, n, r), this.point = new V(0, 0, -i);
4233
+ this.normal = new V(t, n, r), this.point = new B(0, 0, -i);
5263
4234
  return;
5264
4235
  }
5265
4236
  }
5266
4237
  get tex() {
5267
- return new N(new M("xyz", this.a, this.b, this.c, this.d), new M(0)).reduce().tex;
4238
+ return new P(new N("xyz", this.a, this.b, this.c, this.d), new N(0)).reduce().tex;
5268
4239
  }
5269
4240
  get display() {
5270
- return new N(new M("xyz", this.a, this.b, this.c, this.d), new M(0)).reduce().display;
4241
+ return new P(new N("xyz", this.a, this.b, this.c, this.d), new N(0)).reduce().display;
5271
4242
  }
5272
4243
  get a() {
5273
4244
  return this.#e.x;
@@ -5275,7 +4246,7 @@ var q = class e {
5275
4246
  angle(t, r, i) {
5276
4247
  if (t instanceof e) return this.normal.angle(t.normal, r, i);
5277
4248
  let a;
5278
- if (t instanceof H) {
4249
+ if (t instanceof V) {
5279
4250
  if (t.dimension !== 3) throw new n("Vector is not 3D");
5280
4251
  a = t;
5281
4252
  } else a = t.direction;
@@ -5295,10 +4266,10 @@ var q = class e {
5295
4266
  }
5296
4267
  intersectWithLine(e) {
5297
4268
  let { point: t, direction: n } = e, r = this.normal.dot(t).add(this.d).divide(this.normal.dot(n).opposite());
5298
- return new V(new H(t).add(n.clone().multiplyByScalar(r)));
4269
+ return new B(new V(t).add(n.clone().multiplyByScalar(r)));
5299
4270
  }
5300
4271
  intersectWithPlane(e) {
5301
- throw this.normal.cross(e.normal), new V(0, 0, 0), new a("Intersection with plane not yet implemented !");
4272
+ throw this.normal.cross(e.normal), new B(0, 0, 0), new a("Intersection with plane not yet implemented !");
5302
4273
  }
5303
4274
  isPointOnPlane(e) {
5304
4275
  return this.normal.dot(e).add(this.d).isZero();
@@ -5307,33 +4278,33 @@ var q = class e {
5307
4278
  return this.#e;
5308
4279
  }
5309
4280
  set normal(e) {
5310
- this.#e = new H(e);
4281
+ this.#e = new V(e);
5311
4282
  }
5312
4283
  get point() {
5313
4284
  return this.#t;
5314
4285
  }
5315
4286
  set point(e) {
5316
- this.#t = new V(e);
4287
+ this.#t = new B(e);
5317
4288
  }
5318
- }, Ae = /* @__PURE__ */ function(e) {
4289
+ }, X = /* @__PURE__ */ function(e) {
5319
4290
  return e[e.INTERIOR = 0] = "INTERIOR", e[e.EXTERIOR = 1] = "EXTERIOR", e[e.SECANT = 2] = "SECANT", e[e.TANGENT_INSIDE = 3] = "TANGENT_INSIDE", e[e.TANGENT_OUTSIDE = 4] = "TANGENT_OUTSIDE", e[e.SUPERPOSED = 5] = "SUPERPOSED", e[e.CONCENTRIC = 6] = "CONCENTRIC", e;
5320
- }({}), je = class {
4291
+ }({}), Pe = class {
5321
4292
  #e = void 0;
5322
4293
  #t = void 0;
5323
4294
  #n = void 0;
5324
4295
  #r = 1;
5325
4296
  constructor(e, t) {
5326
- return e && t && (this.#e = e, this.#t = new m(t).clone().pow(2), this.#a()), this;
4297
+ return e && t && (this.#e = e, this.#t = new _(t).clone().pow(2), this.#a()), this;
5327
4298
  }
5328
4299
  fromEquation(e) {
5329
- let t = new N(e).moveLeft().reduce(), n = [
4300
+ let t = new P(e).moveLeft().reduce(), n = [
5330
4301
  "x",
5331
4302
  "y",
5332
4303
  "z"
5333
4304
  ];
5334
4305
  if (n.some((e) => t.degree(e).value !== 2)) return this.makeUndefined();
5335
4306
  let r = t.left.monomByDegree(2, "x").coefficient;
5336
- return n.some((e) => t.left.monomByDegree(2, e).coefficient.isNotEqual(r)) ? this.makeUndefined() : (this.#e = new V(t.left.monomByDegree(1, "x").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "y").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "z").coefficient.clone().opposite().divide(2)), this.#t = t.left.monomByDegree(0).coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)).add(this.#e.z.clone().pow(2)), this.#a(), this);
4307
+ return n.some((e) => t.left.monomByDegree(2, e).coefficient.isNotEqual(r)) ? this.makeUndefined() : (this.#e = new B(t.left.monomByDegree(1, "x").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "y").coefficient.clone().opposite().divide(2), t.left.monomByDegree(1, "z").coefficient.clone().opposite().divide(2)), this.#t = t.left.monomByDegree(0).coefficient.clone().opposite().add(this.#e.x.clone().pow(2)).add(this.#e.y.clone().pow(2)).add(this.#e.z.clone().pow(2)), this.#a(), this);
5337
4308
  }
5338
4309
  get center() {
5339
4310
  if (this.#e === void 0) throw new s("Sphere3 is undefined");
@@ -5362,10 +4333,10 @@ var q = class e {
5362
4333
  makeUndefined() {
5363
4334
  return this.#e = void 0, this.#t = void 0, this.#n = void 0, this;
5364
4335
  }
5365
- get centerRadius() {
4336
+ get asCenterRadius() {
5366
4337
  return this.#r = 1, this;
5367
4338
  }
5368
- get developped() {
4339
+ get asDeveloped() {
5369
4340
  return this.#r = 0, this;
5370
4341
  }
5371
4342
  get tex() {
@@ -5385,15 +4356,15 @@ var q = class e {
5385
4356
  ].forEach((n) => {
5386
4357
  if (this.center[n].isZero()) t.push(`${n}^2`);
5387
4358
  else {
5388
- let r = new M(n).subtract(this.center[n]);
4359
+ let r = new N(n).subtract(this.center[n]);
5389
4360
  t.push(e ? `\\(${r.tex}\\)^2` : `(${r.display})^2`);
5390
4361
  }
5391
4362
  }), t.join("+") + "=" + (e ? this.squareRadius.tex : this.squareRadius.display);
5392
4363
  };
5393
4364
  #a() {
5394
- this.#n = new N(new M("x").subtract(this.center.x).pow(2).add(new M("y").subtract(this.center.y).pow(2)).add(new M("z").subtract(this.center.z).pow(2)), new M(this.squareRadius)).reduce();
4365
+ this.#n = new P(new N("x").subtract(this.center.x).pow(2).add(new N("y").subtract(this.center.y).pow(2)).add(new N("z").subtract(this.center.z).pow(2)), new N(this.squareRadius)).reduce();
5395
4366
  }
5396
- static RELATIVE_POSITION = Ae;
4367
+ static RELATIVE_POSITION = X;
5397
4368
  relativePosition = (e) => {
5398
4369
  let t = this.center.distanceTo(e.center).value, n = this.radius.value, r = e.radius.value;
5399
4370
  return t > n + r ? 1 : t === n + r ? 4 : t === 0 ? n === r ? 5 : 6 : t === Math.abs(n - r) ? 3 : t < Math.abs(n - r) ? 0 : 2;
@@ -5413,23 +4384,23 @@ function Z(e) {
5413
4384
  reduced: !0,
5414
4385
  zero: !0,
5415
4386
  natural: !1
5416
- }, e), n = new m();
5417
- if (n.numerator = t.negative ? G(t.max, t.zero) : W(+!t.zero, t.max), t.natural) n.denominator = 1;
4387
+ }, e), n = new _();
4388
+ if (n.numerator = t.negative ? W(t.max, t.zero) : U(+!t.zero, t.max), t.natural) n.denominator = 1;
5418
4389
  else {
5419
4390
  let e = 0;
5420
- for (; n.isRelative() && e < 10;) n.denominator = W(1, t.max), e++;
4391
+ for (; n.isRelative() && e < 10;) n.denominator = U(1, t.max), e++;
5421
4392
  }
5422
4393
  return t.reduced ? n.reduce() : n;
5423
4394
  }
5424
4395
  //#endregion
5425
4396
  //#region src/randomization/algebra/rndMonom.ts
5426
- function Me(e) {
4397
+ function Fe(e) {
5427
4398
  let t = Object.assign({
5428
4399
  letters: "x",
5429
4400
  degree: 2,
5430
4401
  fraction: !0,
5431
4402
  zero: !1
5432
- }, e), n = new A();
4403
+ }, e), n = new O();
5433
4404
  if (n.coefficient = Z(Object.assign({}, {
5434
4405
  zero: t.zero,
5435
4406
  reduced: !0,
@@ -5437,7 +4408,7 @@ function Me(e) {
5437
4408
  }, typeof t.fraction == "boolean" ? {} : t.fraction)), t.letters.length > 1) {
5438
4409
  for (let e of t.letters.split("")) n.setLetter(e, 0);
5439
4410
  for (let e = 0; e < t.degree; e++) {
5440
- let e = K(t.letters.split(""));
4411
+ let e = G(t.letters.split(""));
5441
4412
  n.setLetter(e, n.degree(e).clone().add(1));
5442
4413
  }
5443
4414
  } else n.setLetter(t.letters, t.degree);
@@ -5445,7 +4416,7 @@ function Me(e) {
5445
4416
  }
5446
4417
  //#endregion
5447
4418
  //#region src/randomization/algebra/rndPolynom.ts
5448
- var Ne = {
4419
+ var Ie = {
5449
4420
  letters: "x",
5450
4421
  degree: 2,
5451
4422
  fraction: !1,
@@ -5458,35 +4429,35 @@ var Ne = {
5458
4429
  positive: !0
5459
4430
  };
5460
4431
  function Q(e) {
5461
- let t = Object.assign({}, Ne, e);
5462
- if (t.factorable) return Pe(t);
5463
- let n = new M().empty(), r, i = t.degree ?? 2;
5464
- for (let e = i; e >= 0; e--) r = Me({
4432
+ let t = Object.assign({}, Ie, e);
4433
+ if (t.factorable) return Le(t);
4434
+ let n = new N().empty(), r, i = t.degree ?? 2;
4435
+ for (let e = i; e >= 0; e--) r = Fe({
5465
4436
  letters: t.letters,
5466
4437
  degree: e,
5467
4438
  fraction: t.fraction,
5468
4439
  zero: e !== i && t.allowNullMonom
5469
4440
  }), t.unit && i === e && r.coefficient.one(), n.add(r);
5470
4441
  if (t.positive && n.monomByDegree().coefficient.isNegative() && n.opposite(), t.numberOfMonoms && t.numberOfMonoms > 0 && t.numberOfMonoms < n.length) for (; n.length > t.numberOfMonoms;) {
5471
- let e = W(1, n.length - 1);
4442
+ let e = U(1, n.length - 1);
5472
4443
  n.monoms.splice(e, 1);
5473
4444
  }
5474
4445
  return n.reduce();
5475
4446
  }
5476
- function Pe(e) {
5477
- let t = Object.assign(Ne, e), n = { ...t };
4447
+ function Le(e) {
4448
+ let t = Object.assign(Ie, e), n = { ...t };
5478
4449
  n.degree = 1, n.factorable = !1;
5479
4450
  let r = [], i = t.degree ?? 2;
5480
4451
  for (; r.length < i;) r.push(Q(n));
5481
4452
  if (e?.commonConstant !== !1) {
5482
- let t = G(10, !1);
5483
- e?.commonConstant === !0 && (t === 1 || t === -1) && (t *= W(2, 5)), t !== 1 && t !== -1 && r.unshift(new M(t));
4453
+ let t = W(10, !1);
4454
+ e?.commonConstant === !0 && (t === 1 || t === -1) && (t *= U(2, 5)), t !== 1 && t !== -1 && r.unshift(new N(t));
5484
4455
  }
5485
- return M.xMultiply(...r);
4456
+ return N.xMultiply(...r);
5486
4457
  }
5487
4458
  //#endregion
5488
4459
  //#region src/randomization/algebra/rndEquation.ts
5489
- function Fe(e) {
4460
+ function Re(e) {
5490
4461
  let t = Object.assign({
5491
4462
  letters: "x",
5492
4463
  degree: 1,
@@ -5503,7 +4474,7 @@ function Fe(e) {
5503
4474
  nothing: !1,
5504
4475
  everything: !1
5505
4476
  }
5506
- }, e), n = new M().one();
4477
+ }, e), n = new N().one();
5507
4478
  for (let e = 0; e < t.degree; e++) {
5508
4479
  let e = Q({
5509
4480
  degree: 1,
@@ -5514,7 +4485,7 @@ function Fe(e) {
5514
4485
  });
5515
4486
  n.multiply(e);
5516
4487
  }
5517
- return new N(n, 0);
4488
+ return new P(n, 0);
5518
4489
  }
5519
4490
  //#endregion
5520
4491
  //#region src/randomization/geometry/rndPoint.ts
@@ -5527,15 +4498,15 @@ function $(e) {
5527
4498
  }, e), n = t.axis === "x", r = t.axis === "y", i = t.fraction ? Z({
5528
4499
  max: t.max,
5529
4500
  zero: n
5530
- }) : new m(G(t.max, n)), a = t.fraction ? Z({
4501
+ }) : new _(W(t.max, n)), a = t.fraction ? Z({
5531
4502
  max: t.max,
5532
4503
  zero: r
5533
- }) : new m(G(t.max, r));
5534
- return Number(t.quadrant) === 1 && (i.abs(), a.abs()), Number(t.quadrant) === 2 && (i.isPositive() && i.opposite(), a.isNegative() && a.opposite()), Number(t.quadrant) === 3 && (i.isPositive() && i.opposite(), a.isPositive() && a.opposite()), Number(t.quadrant) === 4 && (i.isNegative() && i.opposite(), a.isPositive() && a.opposite()), new V(i, a);
4504
+ }) : new _(W(t.max, r));
4505
+ return Number(t.quadrant) === 1 && (i.abs(), a.abs()), Number(t.quadrant) === 2 && (i.isPositive() && i.opposite(), a.isNegative() && a.opposite()), Number(t.quadrant) === 3 && (i.isPositive() && i.opposite(), a.isPositive() && a.opposite()), Number(t.quadrant) === 4 && (i.isNegative() && i.opposite(), a.isPositive() && a.opposite()), new B(i, a);
5535
4506
  }
5536
4507
  //#endregion
5537
4508
  //#region src/randomization/geometry/rndCircle.ts
5538
- function Ie(e) {
4509
+ function ze(e) {
5539
4510
  let t = Object.assign({
5540
4511
  center: {
5541
4512
  x: {
@@ -5549,77 +4520,77 @@ function Ie(e) {
5549
4520
  },
5550
4521
  pointsOnCircle: 8
5551
4522
  }, e), n = $(t.center), r, i;
5552
- return t.pointsOnCircle === 8 ? (r = W(1, 3), i = r ** 2 + (r + 1) ** 2) : i = W(1, 20), new Y(n, i, !0);
4523
+ return t.pointsOnCircle === 8 ? (r = U(1, 3), i = r ** 2 + (r + 1) ** 2) : i = U(1, 20), new J(n, i, !0);
5553
4524
  }
5554
4525
  //#endregion
5555
4526
  //#region src/randomization/geometry/rndLine.ts
5556
- function Le(e) {
4527
+ function Be(e) {
5557
4528
  let t = Object.assign({ A: {
5558
- x: G(10),
5559
- y: G(10)
5560
- } }, e), n = new H(0, 0);
5561
- for (; n.isNull;) n.x = G(10, t.allow?.vertical ?? !0), n.y = G(10, t.allow?.horizontal ?? !0);
5562
- return t.slope === 1 ? n.x.sign() !== n.y.sign() && n.y.opposite() : t.slope === -1 && n.x.sign() !== n.y.sign() && n.y.opposite(), new q().fromPointAndDirection(new H(t.A.x, t.A.y), n);
4529
+ x: W(10),
4530
+ y: W(10)
4531
+ } }, e), n = new V(0, 0);
4532
+ for (; n.isNull;) n.x = W(10, t.allow?.vertical ?? !0), n.y = W(10, t.allow?.horizontal ?? !0);
4533
+ return t.slope === 1 ? n.x.sign() !== n.y.sign() && n.y.opposite() : t.slope === -1 && n.x.sign() !== n.y.sign() && n.y.opposite(), new K().fromPointAndDirection(new V(t.A.x, t.A.y), n);
5563
4534
  }
5564
4535
  //#endregion
5565
4536
  //#region src/randomization/geometry/rndLine3.ts
5566
- function Re(e) {
4537
+ function Ve(e) {
5567
4538
  let t = Object.assign({
5568
4539
  A: {
5569
- x: G(10),
5570
- y: G(10),
5571
- z: G(10)
4540
+ x: W(10),
4541
+ y: W(10),
4542
+ z: W(10)
5572
4543
  },
5573
4544
  direction: {
5574
- x: G(10),
5575
- y: G(10),
5576
- z: G(10)
4545
+ x: W(10),
4546
+ y: W(10),
4547
+ z: W(10)
5577
4548
  }
5578
4549
  }, e);
5579
- return new X(new V(t.A.x, t.A.y, t.A.z), new H(t.direction.x, t.direction.y, t.direction.z));
4550
+ return new Y(new B(t.A.x, t.A.y, t.A.z), new V(t.direction.x, t.direction.y, t.direction.z));
5580
4551
  }
5581
4552
  //#endregion
5582
4553
  //#region src/randomization/random.ts
5583
- var ze = {
5584
- equation: (e) => Fe(e),
4554
+ var He = {
4555
+ equation: (e) => Re(e),
5585
4556
  polynom: (e) => Q(e),
5586
- monom: (e) => Me(e),
4557
+ monom: (e) => Fe(e),
5587
4558
  fraction: (e) => Z(e),
5588
- number: (e, t, n) => W(e, t, n),
5589
- numberSym: (e, t) => G(e, t),
5590
- prime: (e) => Ee(e),
5591
- triplet: (e, t) => Te(e, t),
5592
- bool: (e) => we(e),
5593
- array: (e, t) => De(e, t),
5594
- item: (e) => K(e),
5595
- shuffle: (e) => Oe(e),
5596
- line: (e) => Le(e),
5597
- line3: (e) => Re(e),
5598
- vector: (e) => new H($(e)),
4559
+ number: (e, t, n) => U(e, t, n),
4560
+ numberSym: (e, t) => W(e, t),
4561
+ prime: (e) => Ae(e),
4562
+ triplet: (e, t) => ke(e, t),
4563
+ bool: (e) => Oe(e),
4564
+ array: (e, t) => je(e, t),
4565
+ item: (e) => G(e),
4566
+ shuffle: (e) => Me(e),
4567
+ line: (e) => Be(e),
4568
+ line3: (e) => Ve(e),
4569
+ vector: (e) => new V($(e)),
5599
4570
  point: (e) => $(e),
5600
- circle: (e) => Ie(e)
5601
- }, Be = {
5602
- Numeric: p,
5603
- Fraction: m,
4571
+ circle: (e) => ze(e)
4572
+ }, Ue = {
4573
+ Numeric: g,
4574
+ Fraction: _,
5604
4575
  Root: v,
5605
- Monom: A,
5606
- Polynom: M,
5607
- Equation: N,
5608
- Matrix: ve,
5609
- LinearSystem: I,
5610
- Factor: P,
5611
- PolyFactor: R,
5612
- LogicalSet: L,
5613
- Random: ze,
4576
+ Monom: O,
4577
+ Polynom: N,
4578
+ Equation: P,
4579
+ Matrix: Se,
4580
+ LinearSystem: be,
4581
+ Factor: F,
4582
+ PolyFactor: L,
4583
+ LogicalSet: xe,
4584
+ Random: He,
5614
4585
  Geometry: {
5615
- Vector: H,
5616
- Point: V,
5617
- Line: q,
5618
- Triangle: J,
5619
- Circle: Y,
5620
- Line3: X,
5621
- Plane3: ke,
5622
- Sphere3: je
4586
+ Vector: V,
4587
+ Point: B,
4588
+ Line: K,
4589
+ Triangle: q,
4590
+ Circle: J,
4591
+ Line3: Y,
4592
+ Plane3: Ne,
4593
+ Sphere3: Pe
5623
4594
  },
5624
4595
  Errors: {
5625
4596
  PiMathError: e,
@@ -5631,9 +4602,9 @@ var ze = {
5631
4602
  IndexError: o,
5632
4603
  StateError: s
5633
4604
  },
5634
- NumExp: k
4605
+ NumExp: ve
5635
4606
  };
5636
4607
  //#endregion
5637
- export { Y as Circle, n as DimensionError, N as Equation, b as EquationSolver, F as FACTOR_DISPLAY, oe as FRAC_TYPE, P as Factor, m as Fraction, o as IndexError, i as InvalidArgumentError, q as Line, X as Line3, I as LinearSystem, L as LogicalSet, r as MathError, ve as Matrix, A as Monom, a as NotImplementedError, k as NumExp, p as Numeric, t as ParseError, e as PiMathError, ke as Plane3, V as Point, R as PolyFactor, M as Polynom, ze as Random, v as Root, Ae as SPHERE3_RELATIVE_POSITION, y as Solution, je as Sphere3, s as StateError, ce as TableOfSigns, J as Triangle, H as Vector, be as areVectorsColinears, ye as areVectorsEquals, Be as default, Se as determinantFromVectors, xe as dotProduct };
4608
+ export { J as Circle, n as DimensionError, P as Equation, b as EquationSolver, I as FACTOR_DISPLAY, oe as FRAC_TYPE, F as Factor, _ as Fraction, o as IndexError, i as InvalidArgumentError, K as Line, Y as Line3, be as LinearSystem, xe as LogicalSet, r as MathError, Se as Matrix, O as Monom, a as NotImplementedError, ve as NumExp, g as Numeric, t as ParseError, e as PiMathError, Ne as Plane3, B as Point, L as PolyFactor, N as Polynom, He as Random, v as Root, X as SPHERE3_RELATIVE_POSITION, y as Solution, Pe as Sphere3, s as StateError, se as TableOfSigns, q as Triangle, V as Vector, we as areVectorsColinears, Ce as areVectorsEquals, Ue as default, Ee as determinantFromVectors, Te as dotProduct };
5638
4609
 
5639
4610
  //# sourceMappingURL=pimath.js.map