@tspro/ts-utils-lib 1.19.1 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /* TsUtilsLib v1.19.1 | (c) 2023 PahkaSoft | Licensed under the MIT License */
1
+ /* TsUtilsLib v1.21.0 | (c) 2023 PahkaSoft | Licensed under the MIT License */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __export = (target, all) => {
@@ -64,6 +64,7 @@ __export(assert_exports, {
64
64
  isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined,
65
65
  isNonEmptyString: () => isNonEmptyString,
66
66
  isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined,
67
+ isNotThrowing: () => isNotThrowing,
67
68
  isNull: () => isNull,
68
69
  isNullish: () => isNullish,
69
70
  isNumber: () => isNumber,
@@ -459,6 +460,11 @@ function isThrowing(throwTestFn, msg) {
459
460
  _fail(`Expected to throw`, msg);
460
461
  return true;
461
462
  }
463
+ function isNotThrowing(throwTestFn, msg) {
464
+ if (!guard_exports.isNotThrowing(throwTestFn))
465
+ _fail(`Expected to throw`, msg);
466
+ return true;
467
+ }
462
468
 
463
469
  // src/web/cookies.ts
464
470
  var cookies_exports = {};
@@ -706,6 +712,7 @@ __export(guard_exports, {
706
712
  isNonEmptyArrayOrUndefined: () => isNonEmptyArrayOrUndefined2,
707
713
  isNonEmptyString: () => isNonEmptyString2,
708
714
  isNonEmptyStringOrUndefined: () => isNonEmptyStringOrUndefined2,
715
+ isNotThrowing: () => isNotThrowing2,
709
716
  isNull: () => isNull2,
710
717
  isNullish: () => isNullish2,
711
718
  isNumber: () => isNumber2,
@@ -955,6 +962,14 @@ function isThrowing2(throwTestFn) {
955
962
  return true;
956
963
  }
957
964
  }
965
+ function isNotThrowing2(throwTestFn) {
966
+ try {
967
+ throwTestFn();
968
+ return true;
969
+ } catch (err) {
970
+ return false;
971
+ }
972
+ }
958
973
  function tryOr(tryFn, orVal) {
959
974
  try {
960
975
  return tryFn();
@@ -1388,99 +1403,19 @@ __export(str_exports, {
1388
1403
  removeAt: () => removeAt,
1389
1404
  repeatString: () => repeatString,
1390
1405
  replaceAt: () => replaceAt,
1406
+ stringify: () => stringify,
1391
1407
  toCharArray: () => toCharArray
1392
1408
  });
1393
- function toCharArray(str2) {
1394
- return str2.split("");
1395
- }
1396
- function repeatString(repeatString2, repeatCount) {
1397
- if (!isInteger2(repeatCount) || repeatCount < 0) {
1398
- throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
1399
- }
1400
- return new Array(repeatCount + 1).join(repeatString2);
1401
- }
1402
- function chunkString(str2, chunkSize) {
1403
- if (!isInteger2(chunkSize) || chunkSize < 1) {
1404
- throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
1405
- }
1406
- let result = [];
1407
- for (let i = 0; i < str2.length; i += chunkSize) {
1408
- result.push(str2.slice(i, i + chunkSize));
1409
- }
1410
- return result;
1411
- }
1412
- function replaceAt(str2, pos, removeCount, insert) {
1413
- if (!isInteger2(removeCount) || removeCount < 0) {
1414
- throw new Error("replaceAt: Invalid removeCount = " + removeCount);
1415
- } else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
1416
- throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
1417
- } else {
1418
- return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
1419
- }
1420
- }
1421
- function insertAt(str2, pos, insertStr) {
1422
- return replaceAt(str2, pos, 0, insertStr);
1423
- }
1424
- function removeAt(str2, pos, removeCount) {
1425
- return replaceAt(str2, pos, removeCount, "");
1426
- }
1427
- function charCount(str2, ch) {
1428
- if (ch.length !== 1 || str2.length === 0) return 0;
1429
- let count = 0;
1430
- for (let i = 0; i < str2.length; i++) {
1431
- if (str2[i] === ch) count++;
1432
- }
1433
- return count;
1434
- }
1435
- function makeSentenceFromPascal(PascalString) {
1436
- if (PascalString === "") {
1437
- return "";
1438
- }
1439
- let word = PascalString.charAt(0);
1440
- let sentence = "";
1441
- const addWord = () => {
1442
- if (word !== "") {
1443
- if (sentence === "") {
1444
- sentence += word.charAt(0).toUpperCase() + word.substring(1);
1445
- } else {
1446
- sentence += " " + word;
1447
- }
1448
- word = "";
1449
- }
1450
- };
1451
- const isLetterAndCapital = (c) => {
1452
- return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
1453
- };
1454
- for (let i = 1; i < PascalString.length; i++) {
1455
- let c = PascalString.charAt(i);
1456
- if (isLetterAndCapital(c)) {
1457
- addWord();
1458
- }
1459
- word += c.toLowerCase();
1460
- }
1461
- addWord();
1462
- return sentence;
1463
- }
1464
-
1465
- // src/utils/index.ts
1466
- var Is = guard_exports;
1467
1409
 
1468
- // src/core/format-value.ts
1469
- function formatValue(value) {
1470
- if (isString2(value)) {
1471
- return `"${value}"`;
1472
- } else if (isArray2(value)) {
1473
- return `[ ${value.map((e) => formatValue(e)).join(", ")} ]`.replaceAll(" ", " ");
1474
- } else if (isFunction2(value.toString)) {
1475
- return value.toString();
1476
- } else {
1477
- return JSON.stringify(value);
1478
- }
1479
- }
1410
+ // src/core/base.ts
1411
+ var DefaultEqualityFn = (a, b) => a === b;
1412
+ var BaseContainer = class {
1413
+ };
1480
1414
 
1481
1415
  // src/core/stack.ts
1482
- var Stack = class {
1416
+ var Stack = class extends BaseContainer {
1483
1417
  constructor() {
1418
+ super();
1484
1419
  __publicField(this, "data", []);
1485
1420
  }
1486
1421
  assertId(id) {
@@ -1541,13 +1476,14 @@ var Stack = class {
1541
1476
  this.data.length = 0;
1542
1477
  }
1543
1478
  toString() {
1544
- return `Stack(${this.length})${formatValue(this.data)}`;
1479
+ return `Stack(${this.length})${stringify(this.data)}`;
1545
1480
  }
1546
1481
  };
1547
1482
 
1548
1483
  // src/core/vec.ts
1549
- var Vec = class _Vec {
1484
+ var Vec = class _Vec extends BaseContainer {
1550
1485
  constructor(...coords) {
1486
+ super();
1551
1487
  __publicField(this, "coords");
1552
1488
  if (coords.length < 2) {
1553
1489
  throw new TypeError("Vec needs minumum two coords!");
@@ -1675,8 +1611,179 @@ var Vec = class _Vec {
1675
1611
  }
1676
1612
  };
1677
1613
 
1678
- // src/core/div-rect.ts
1679
- var DivRect = class _DivRect {
1614
+ // src/core/rect.ts
1615
+ var Rect = class _Rect {
1616
+ constructor(...args) {
1617
+ __publicField(this, "x");
1618
+ __publicField(this, "y");
1619
+ __publicField(this, "width");
1620
+ __publicField(this, "height");
1621
+ if (args.length === 0) {
1622
+ this.x = this.y = this.width = this.height = 0;
1623
+ } else if (args.length === 2) {
1624
+ this.x = this.y = 0;
1625
+ this.width = args[0];
1626
+ this.height = args[1];
1627
+ } else {
1628
+ this.x = args[0];
1629
+ this.y = args[1];
1630
+ this.width = args[2];
1631
+ this.height = args[3];
1632
+ }
1633
+ if (this.width < 0 || this.height < 0)
1634
+ throw new Error("Rect width and height must be non-negative.");
1635
+ }
1636
+ set(...args) {
1637
+ if (args.length === 0) {
1638
+ this.x = this.y = this.width = this.height = 0;
1639
+ } else if (args.length === 2) {
1640
+ this.x = this.y = 0;
1641
+ this.width = args[0];
1642
+ this.height = args[1];
1643
+ } else {
1644
+ this.x = args[0];
1645
+ this.y = args[1];
1646
+ this.width = args[2];
1647
+ this.height = args[3];
1648
+ }
1649
+ if (this.width < 0 || this.height < 0)
1650
+ throw new Error("Rect width and height must be non-negative.");
1651
+ return this;
1652
+ }
1653
+ // --- Static Constructors ---
1654
+ static fromPoints(p1, p2) {
1655
+ const x = Math.min(p1.x, p2.x);
1656
+ const y = Math.min(p1.y, p2.y);
1657
+ const w = Math.abs(p1.x - p2.x);
1658
+ const h = Math.abs(p1.y - p2.y);
1659
+ return new _Rect(x, y, w, h);
1660
+ }
1661
+ static fromCenter(cx, cy, width, height) {
1662
+ return new _Rect(cx - width / 2, cy - height / 2, width, height);
1663
+ }
1664
+ // --- Derived Properties ---
1665
+ get left() {
1666
+ return this.x;
1667
+ }
1668
+ get top() {
1669
+ return this.y;
1670
+ }
1671
+ get right() {
1672
+ return this.x + this.width;
1673
+ }
1674
+ get bottom() {
1675
+ return this.y + this.height;
1676
+ }
1677
+ get centerX() {
1678
+ return this.x + this.width / 2;
1679
+ }
1680
+ get centerY() {
1681
+ return this.y + this.height / 2;
1682
+ }
1683
+ get center() {
1684
+ return { x: this.centerX, y: this.centerY };
1685
+ }
1686
+ get area() {
1687
+ return this.width * this.height;
1688
+ }
1689
+ get isEmpty() {
1690
+ return this.width <= 0 || this.height <= 0;
1691
+ }
1692
+ // --- Geometric Tests ---
1693
+ containsPoint(px, py) {
1694
+ return px >= this.left && px <= this.right && py >= this.top && py <= this.bottom;
1695
+ }
1696
+ containsRect(other) {
1697
+ return other.left >= this.left && other.right <= this.right && other.top >= this.top && other.bottom <= this.bottom;
1698
+ }
1699
+ intersects(other) {
1700
+ return !(other.right < this.left || other.left > this.right || other.bottom < this.top || other.top > this.bottom);
1701
+ }
1702
+ // --- Operations ---
1703
+ intersectionCopy(other) {
1704
+ const x1 = Math.max(this.left, other.left);
1705
+ const y1 = Math.max(this.top, other.top);
1706
+ const x2 = Math.min(this.right, other.right);
1707
+ const y2 = Math.min(this.bottom, other.bottom);
1708
+ if (x2 <= x1 || y2 <= y1) return new _Rect();
1709
+ return new _Rect(x1, y1, x2 - x1, y2 - y1);
1710
+ }
1711
+ unionCopy(other) {
1712
+ const x1 = Math.min(this.left, other.left);
1713
+ const y1 = Math.min(this.top, other.top);
1714
+ const x2 = Math.max(this.right, other.right);
1715
+ const y2 = Math.max(this.bottom, other.bottom);
1716
+ return new _Rect(x1, y1, x2 - x1, y2 - y1);
1717
+ }
1718
+ insetCopy(dx, dy) {
1719
+ return new _Rect(this.x + dx, this.y + dy, this.width - 2 * dx, this.height - 2 * dy);
1720
+ }
1721
+ inflateCopy(dx, dy) {
1722
+ return new _Rect(this.x - dx, this.y - dy, this.width + 2 * dx, this.height + 2 * dy);
1723
+ }
1724
+ offsetInPlace(dx, dy) {
1725
+ this.x += dx;
1726
+ this.y += dy;
1727
+ return this;
1728
+ }
1729
+ offsetCopy(dx, dy) {
1730
+ return new _Rect(this.x + dx, this.y + dy, this.width, this.height);
1731
+ }
1732
+ scaleInPlace(scaleX, scaleY = scaleX) {
1733
+ this.x = this.centerX - this.width * scaleX / 2;
1734
+ this.width *= scaleX;
1735
+ this.y = this.centerY - this.height * scaleY / 2;
1736
+ this.height *= scaleY;
1737
+ return this;
1738
+ }
1739
+ scaleCopy(scaleX, scaleY = scaleX) {
1740
+ return this.clone().scaleInPlace(scaleX, scaleY);
1741
+ }
1742
+ roundCopy() {
1743
+ const left = Math.round(this.left);
1744
+ const top = Math.round(this.top);
1745
+ const right = Math.round(this.right);
1746
+ const bottom = Math.round(this.bottom);
1747
+ return new _Rect(left, top, right - left, bottom - top);
1748
+ }
1749
+ floorCopy() {
1750
+ const left = Math.floor(this.left);
1751
+ const top = Math.floor(this.top);
1752
+ const right = Math.floor(this.right);
1753
+ const bottom = Math.floor(this.bottom);
1754
+ return new _Rect(left, top, right - left, bottom - top);
1755
+ }
1756
+ ceilCopy() {
1757
+ const left = Math.ceil(this.left);
1758
+ const top = Math.ceil(this.top);
1759
+ const right = Math.ceil(this.right);
1760
+ const bottom = Math.ceil(this.bottom);
1761
+ return new _Rect(left, top, right - left, bottom - top);
1762
+ }
1763
+ expandCopy(px, py) {
1764
+ const left = Math.min(this.left, px);
1765
+ const top = Math.min(this.top, py);
1766
+ const right = Math.max(this.right, px);
1767
+ const bottom = Math.max(this.bottom, py);
1768
+ return new _Rect(left, top, right - left, bottom - top);
1769
+ }
1770
+ // --- Utilities ---
1771
+ equals(other) {
1772
+ return this.x === other.x && this.y === other.y && this.width === other.width && this.height === other.height;
1773
+ }
1774
+ clone() {
1775
+ return new _Rect(this.x, this.y, this.width, this.height);
1776
+ }
1777
+ toString() {
1778
+ return `Rect(x=${this.x}, y=${this.y}, w=${this.width}, h=${this.height})`;
1779
+ }
1780
+ toAnchoredRect() {
1781
+ return new AnchoredRect(this.left, this.right, this.top, this.bottom);
1782
+ }
1783
+ };
1784
+
1785
+ // src/core/anchor-rect.ts
1786
+ var AnchoredRect = class _AnchoredRect {
1680
1787
  constructor(...args) {
1681
1788
  __publicField(this, "left");
1682
1789
  __publicField(this, "anchorX");
@@ -1702,8 +1809,31 @@ var DivRect = class _DivRect {
1702
1809
  this.left = this.anchorX = this.right = 0;
1703
1810
  this.top = this.anchorY = this.bottom = 0;
1704
1811
  } else {
1705
- throw new TypeError(`Invalid DivRect args: ${args}`);
1812
+ throw new TypeError(`Invalid AnchoredRect args: ${args}`);
1813
+ }
1814
+ }
1815
+ set(...args) {
1816
+ if (args.length === 6) {
1817
+ this.left = args[0];
1818
+ this.anchorX = args[1];
1819
+ this.right = args[2];
1820
+ this.top = args[3];
1821
+ this.anchorY = args[4];
1822
+ this.bottom = args[5];
1823
+ } else if (args.length === 4) {
1824
+ this.left = args[0];
1825
+ this.right = args[1];
1826
+ this.anchorX = (this.left + this.right) / 2;
1827
+ this.top = args[2];
1828
+ this.bottom = args[3];
1829
+ this.anchorY = (this.top + this.bottom) / 2;
1830
+ } else if (args.length === 0) {
1831
+ this.left = this.anchorX = this.right = 0;
1832
+ this.top = this.anchorY = this.bottom = 0;
1833
+ } else {
1834
+ throw new TypeError(`Invalid AnchoredRect args: ${args}`);
1706
1835
  }
1836
+ return this;
1707
1837
  }
1708
1838
  /**
1709
1839
  * Create rect from basic left, top, width and height arguments.
@@ -1712,10 +1842,10 @@ var DivRect = class _DivRect {
1712
1842
  * @param top - Top coordinate.
1713
1843
  * @param width - Width.
1714
1844
  * @param height - Height.
1715
- * @returns - DivRect.
1845
+ * @returns - AnchoredRect.
1716
1846
  */
1717
1847
  static create(left, top, width, height) {
1718
- return new _DivRect(left, left + width, top, top + height);
1848
+ return new _AnchoredRect(left, left + width, top, top + height);
1719
1849
  }
1720
1850
  /**
1721
1851
  * Create rect from anchorX, anchorY, width, height arguments.
@@ -1724,10 +1854,10 @@ var DivRect = class _DivRect {
1724
1854
  * @param centerY - Center y-coordinate.
1725
1855
  * @param width - Width.
1726
1856
  * @param height - Height.
1727
- * @returns - DivRect.
1857
+ * @returns - AnchoredRect.
1728
1858
  */
1729
1859
  static createCentered(centerX, centerY, width, height) {
1730
- return new _DivRect(
1860
+ return new _AnchoredRect(
1731
1861
  centerX - width / 2,
1732
1862
  centerX,
1733
1863
  centerX + width / 2,
@@ -1743,26 +1873,22 @@ var DivRect = class _DivRect {
1743
1873
  * @param rightw - Right section width.
1744
1874
  * @param toph - Top section height.
1745
1875
  * @param bottomh - Bottomsection height.
1746
- * @returns - DivRect.
1876
+ * @returns - AnchoredRect.
1747
1877
  */
1748
1878
  static createSections(leftw, rightw, toph, bottomh) {
1749
- return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
1879
+ return new _AnchoredRect(-leftw, 0, rightw, -toph, 0, bottomh);
1750
1880
  }
1751
- /** @deprecated - Renamed to anchorX. */
1881
+ /**
1882
+ * Get center x-coordinate.
1883
+ */
1752
1884
  get centerX() {
1753
- return this.anchorX;
1754
- }
1755
- /** @deprecated - Renamed to anchorX. */
1756
- set centerX(x) {
1757
- this.anchorX = x;
1885
+ return this.left + this.width / 2;
1758
1886
  }
1759
- /** @deprecated - Renamed to anchorY. */
1887
+ /**
1888
+ * Get center ycoordinate.
1889
+ */
1760
1890
  get centerY() {
1761
- return this.anchorY;
1762
- }
1763
- /** @deprecated - Renamed to anchorY. */
1764
- set centerY(y) {
1765
- this.anchorY = y;
1891
+ return this.top + this.height / 2;
1766
1892
  }
1767
1893
  /**
1768
1894
  * Width getter.
@@ -1813,8 +1939,8 @@ var DivRect = class _DivRect {
1813
1939
  /**
1814
1940
  * Do a and b rects overlap?
1815
1941
  *
1816
- * @param a - DivRect a.
1817
- * @param b - DivRect b.
1942
+ * @param a - AnchoredRect a.
1943
+ * @param b - AnchoredRect b.
1818
1944
  * @returns - True/false.
1819
1945
  */
1820
1946
  static overlap(a, b) {
@@ -1823,8 +1949,8 @@ var DivRect = class _DivRect {
1823
1949
  /**
1824
1950
  * Do horizontal measures of a and b rects overlap?
1825
1951
  *
1826
- * @param a - DivRect a.
1827
- * @param b - DivRect b.
1952
+ * @param a - AnchoredRect a.
1953
+ * @param b - AnchoredRect b.
1828
1954
  * @returns - True/false.
1829
1955
  */
1830
1956
  static overlapX(a, b) {
@@ -1832,8 +1958,8 @@ var DivRect = class _DivRect {
1832
1958
  }
1833
1959
  /**
1834
1960
  * Check if given rects are equal.
1835
- * @param a - DivRect a.
1836
- * @param b - DivRect b.
1961
+ * @param a - AnchoredRect a.
1962
+ * @param b - AnchoredRect b.
1837
1963
  * @returns - True/false.
1838
1964
  */
1839
1965
  static equals(a, b) {
@@ -1851,13 +1977,13 @@ var DivRect = class _DivRect {
1851
1977
  * @returns - True/false.
1852
1978
  */
1853
1979
  equals(other) {
1854
- return _DivRect.equals(this, other);
1980
+ return _AnchoredRect.equals(this, other);
1855
1981
  }
1856
1982
  /**
1857
1983
  * Check if edges of given rects are equal, ignoring anchorX and anchorY.
1858
1984
  *
1859
- * @param a - DivRect a.
1860
- * @param b - DivRect b.
1985
+ * @param a - AnchoredRect a.
1986
+ * @param b - AnchoredRect b.
1861
1987
  * @returns - True/false.
1862
1988
  */
1863
1989
  static equalsEdges(a, b) {
@@ -1872,30 +1998,25 @@ var DivRect = class _DivRect {
1872
1998
  /**
1873
1999
  * Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
1874
2000
  *
1875
- * @param other - The other DivRect.
2001
+ * @param other - The other AnchoredRect.
1876
2002
  * @returns - True/false.
1877
2003
  */
1878
2004
  equalsEdges(other) {
1879
- return _DivRect.equalsEdges(this, other);
1880
- }
1881
- /** @deprecated - Use `DivRect.equalsEdges()` instead. */
1882
- static equalsFrame(a, b) {
1883
- return _DivRect.equalsEdges(a, b);
2005
+ return _AnchoredRect.equalsEdges(this, other);
1884
2006
  }
1885
2007
  /**
1886
2008
  * Created duplicate of this Rect.
1887
- *
1888
2009
  * @returns - Duplicate.
1889
2010
  */
1890
- copy() {
1891
- return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
2011
+ clone() {
2012
+ return new _AnchoredRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
1892
2013
  }
1893
2014
  /**
1894
2015
  * Move this rect by (dx, dy). Modifies this Rect.
1895
2016
  *
1896
2017
  * @param dx - Offset amount in x-direction.
1897
2018
  * @param dy - Offset amount in y-direction.
1898
- * @returns - This DivRect instance.
2019
+ * @returns - This AnchoredRect instance.
1899
2020
  */
1900
2021
  offsetInPlace(dx, dy) {
1901
2022
  this.left += dx;
@@ -1911,16 +2032,16 @@ var DivRect = class _DivRect {
1911
2032
  *
1912
2033
  * @param dx - Offset amount in x-direction.
1913
2034
  * @param dy - Offset amount in y-direction.
1914
- * @returns - DivRect copy with applied offset.
2035
+ * @returns - AnchoredRect copy with applied offset.
1915
2036
  */
1916
2037
  offsetCopy(dx, dy) {
1917
- return this.copy().offsetInPlace(dx, dy);
2038
+ return this.clone().offsetInPlace(dx, dy);
1918
2039
  }
1919
2040
  /**
1920
2041
  * Expand this Rect by given Rect. Modifies this Rect.
1921
2042
  *
1922
- * @param rect - DivRect to expand this instance with.
1923
- * @returns - This DivRect instance.
2043
+ * @param rect - AnchoredRect to expand this instance with.
2044
+ * @returns - This AnchoredRect instance.
1924
2045
  */
1925
2046
  expandInPlace(rect) {
1926
2047
  this.left = Math.min(this.left, rect.left);
@@ -1932,17 +2053,17 @@ var DivRect = class _DivRect {
1932
2053
  /**
1933
2054
  * Expand this Rect by given Rect. Immutable, returns modified copy.
1934
2055
  *
1935
- * @param rect - DivRect to expand this instance with.
1936
- * @returns - Expanded copy of this DivRect.
2056
+ * @param rect - AnchoredRect to expand this instance with.
2057
+ * @returns - Expanded copy of this AnchoredRect.
1937
2058
  */
1938
2059
  expandCopy(rect) {
1939
- return this.copy().expandInPlace(rect);
2060
+ return this.clone().expandInPlace(rect);
1940
2061
  }
1941
2062
  /**
1942
2063
  * Clip this Rect by given Rect. Mmodifies this Rect.
1943
2064
  *
1944
- * @param clipRect - DivRect to clip this instance with.
1945
- * @returns - This DivRect instance.
2065
+ * @param clipRect - AnchoredRect to clip this instance with.
2066
+ * @returns - This AnchoredRect instance.
1946
2067
  */
1947
2068
  clipInPlace(clipRect) {
1948
2069
  this.left = Math.max(this.left, clipRect.left);
@@ -1956,21 +2077,20 @@ var DivRect = class _DivRect {
1956
2077
  /**
1957
2078
  * Clip this Rect by given Rect. Immutable, return modified copy.
1958
2079
  *
1959
- * @param clipRect - DivRecto to clip this instance with.
1960
- * @returns - Clipped DivRect copy.
2080
+ * @param clipRect - AnchoredRecto to clip this instance with.
2081
+ * @returns - Clipped AnchoredRect copy.
1961
2082
  */
1962
2083
  clipCopy(clipRect) {
1963
- return this.copy().clipInPlace(clipRect);
2084
+ return this.clone().clipInPlace(clipRect);
1964
2085
  }
1965
2086
  /**
1966
2087
  * Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
1967
2088
  *
1968
2089
  * @param scaleX - Scale x-amount.
1969
2090
  * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
1970
- * @returns This DivRect instance.
2091
+ * @returns This AnchoredRect instance.
1971
2092
  */
1972
- scaleInPlace(scaleX, scaleY) {
1973
- scaleY = scaleY ?? scaleX;
2093
+ scaleInPlace(scaleX, scaleY = scaleX) {
1974
2094
  this.left = this.anchorX - this.leftw * scaleX;
1975
2095
  this.right = this.anchorX + this.rightw * scaleX;
1976
2096
  this.top = this.anchorY - this.toph * scaleY;
@@ -1982,24 +2102,28 @@ var DivRect = class _DivRect {
1982
2102
  *
1983
2103
  * @param scaleX - Scale x-amount.
1984
2104
  * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
1985
- * @returns Scaled copy of this DivRect.
2105
+ * @returns Scaled copy of this AnchoredRect.
1986
2106
  */
1987
- scaleCopy(scaleX, scaleY) {
1988
- return this.copy().scaleInPlace(scaleX, scaleY);
2107
+ scaleCopy(scaleX, scaleY = scaleX) {
2108
+ return this.clone().scaleInPlace(scaleX, scaleY);
1989
2109
  }
1990
2110
  /**
1991
- * Get this DivRect instance.
1992
- * @returns - This DivRect instance.
2111
+ * Get this AnchoredRect instance.
2112
+ * @returns - This AnchoredRect instance.
1993
2113
  */
1994
2114
  getRect() {
1995
2115
  return this;
1996
2116
  }
2117
+ toRect() {
2118
+ return new Rect(this.left, this.right, this.width, this.height);
2119
+ }
1997
2120
  };
1998
2121
 
1999
2122
  // src/core/LRU-cache.ts
2000
- var LRUCache = class {
2123
+ var LRUCache = class extends BaseContainer {
2001
2124
  // Maximum key length.
2002
2125
  constructor(maxSize, maxKeyLength = Infinity) {
2126
+ super();
2003
2127
  __publicField(this, "cache");
2004
2128
  // Stores the actual key-value pairs
2005
2129
  __publicField(this, "next");
@@ -2091,11 +2215,31 @@ var LRUCache = class {
2091
2215
  }
2092
2216
  this.tail = key;
2093
2217
  }
2218
+ *keys() {
2219
+ for (let key = this.head; key != null; key = this.next[key])
2220
+ yield key;
2221
+ }
2222
+ *values() {
2223
+ for (let key = this.head; key != null; key = this.next[key])
2224
+ yield this.cache[key];
2225
+ }
2226
+ *entries() {
2227
+ for (let key = this.head; key != null; key = this.next[key])
2228
+ yield [key, this.cache[key]];
2229
+ }
2230
+ *[Symbol.iterator]() {
2231
+ yield* this.entries();
2232
+ }
2233
+ toString() {
2234
+ const entries = [...this.entries()];
2235
+ return entries.length === 0 ? `LRUCache(0){ }` : `LRUCache(${entries.length}){ ${entries.map((e) => `${stringify(e[0])}: ${stringify(e[1])}`).join(", ")} }`;
2236
+ }
2094
2237
  };
2095
2238
 
2096
2239
  // src/core/index-array.ts
2097
- var IndexArray = class _IndexArray {
2240
+ var IndexArray = class _IndexArray extends BaseContainer {
2098
2241
  constructor(entries) {
2242
+ super();
2099
2243
  __publicField(this, "posVal");
2100
2244
  __publicField(this, "hasPos");
2101
2245
  // Number of values
@@ -2308,14 +2452,20 @@ var IndexArray = class _IndexArray {
2308
2452
  return this.valuesArray();
2309
2453
  }
2310
2454
  toString() {
2311
- const entries = this.entriesArray().map(([id, v]) => `${formatValue(id)}: ${formatValue(v)}`).join(", ");
2312
- return `IndexArray[ ${entries} ]`.replaceAll(" ", " ");
2455
+ let isRegularArray = true;
2456
+ for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
2457
+ if (!this.hasPos[i]) isRegularArray = false;
2458
+ if (isRegularArray)
2459
+ return stringify(this.posVal.slice(0, this.hasPos.length));
2460
+ const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
2461
+ return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
2313
2462
  }
2314
2463
  };
2315
2464
 
2316
2465
  // src/core/signed-index-array.ts
2317
- var SignedIndexArray = class _SignedIndexArray {
2466
+ var SignedIndexArray = class _SignedIndexArray extends BaseContainer {
2318
2467
  constructor(entries) {
2468
+ super();
2319
2469
  // For indexes >= 0
2320
2470
  __publicField(this, "posVal");
2321
2471
  __publicField(this, "hasPos");
@@ -2571,21 +2721,28 @@ var SignedIndexArray = class _SignedIndexArray {
2571
2721
  return this.valuesArray();
2572
2722
  }
2573
2723
  toString() {
2574
- const entries = this.entriesArray().map(([id, v]) => `${formatValue(id)}: ${formatValue(v)}`).join(", ");
2575
- return `SignedIndexArray[ ${entries} ]`.replaceAll(" ", " ");
2724
+ let isRegularArray = this.hasNeg.length === 0;
2725
+ for (let i = 0; i < this.hasPos.length && isRegularArray; i++)
2726
+ if (!this.hasPos[i]) isRegularArray = false;
2727
+ if (isRegularArray)
2728
+ return stringify(this.posVal.slice(0, this.hasPos.length));
2729
+ const entries = this.entriesArray().map(([id, v]) => `${stringify(id)}: ${stringify(v)}`).join(", ");
2730
+ return entries.length === 0 ? `[ ]` : `[ ${entries} ]`;
2576
2731
  }
2577
2732
  };
2578
2733
 
2579
2734
  // src/core/default-array.ts
2580
- var DefaultArray = class _DefaultArray {
2581
- constructor(lengthOrValues, defaultValue) {
2582
- this.defaultValue = defaultValue;
2735
+ var DefaultArray = class _DefaultArray extends BaseContainer {
2736
+ constructor(...args) {
2737
+ super();
2738
+ __publicField(this, "defaultValue");
2583
2739
  __publicField(this, "data");
2584
- if (typeof lengthOrValues === "number") {
2585
- this.data = Array(lengthOrValues).fill(defaultValue);
2740
+ this.defaultValue = args.pop();
2741
+ if (typeof args[0] === "number") {
2742
+ this.data = Array(args[0]).fill(this.defaultValue);
2586
2743
  } else {
2587
- this.data = Array.from(lengthOrValues).map(
2588
- (v) => v === void 0 ? defaultValue : v
2744
+ this.data = Array.from(args[0]).map(
2745
+ (v) => v === void 0 ? this.defaultValue : v
2589
2746
  );
2590
2747
  }
2591
2748
  }
@@ -2686,9 +2843,7 @@ var DefaultArray = class _DefaultArray {
2686
2843
  }
2687
2844
  clone() {
2688
2845
  const ctor = this.constructor;
2689
- const clone = new ctor(this.length, this.defaultValue);
2690
- clone.data = this.data.slice();
2691
- return clone;
2846
+ return new ctor(this.values(), this.defaultValue);
2692
2847
  }
2693
2848
  merge(other, conflictResolver) {
2694
2849
  if (this.constructor !== other.constructor)
@@ -2774,62 +2929,92 @@ var DefaultArray = class _DefaultArray {
2774
2929
  return this.valuesArray();
2775
2930
  }
2776
2931
  toString() {
2777
- const entries = this.entriesArray().map(([id, v]) => `${formatValue(id)}: ${formatValue(v)}`).join(", ");
2778
- return `DefaultArray[ ${entries} ]`.replaceAll(" ", " ");
2932
+ return stringify(this.data);
2779
2933
  }
2780
2934
  };
2781
2935
 
2782
- // src/core/map1.ts
2783
- var Map1 = class _Map1 {
2784
- constructor(entries) {
2785
- __publicField(this, "map1");
2786
- this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
2936
+ // src/core/uni-map.ts
2937
+ var UniMap = class _UniMap extends BaseContainer {
2938
+ constructor(...args) {
2939
+ super();
2940
+ __publicField(this, "map");
2941
+ __publicField(this, "keyEquals");
2942
+ const maybeEquals = args.at(-1);
2943
+ this.keyEquals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
2944
+ const entries = args[0];
2945
+ this.map = new Map(entries);
2787
2946
  }
2788
- has(key1) {
2789
- return this.map1.has(key1);
2947
+ static createDeep(arg) {
2948
+ return arg ? new _UniMap(arg, isDeepEqual2) : new _UniMap(isDeepEqual2);
2790
2949
  }
2791
- set(key1, value) {
2792
- this.map1.set(key1, value);
2950
+ has(key) {
2951
+ if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
2952
+ return this.map.has(key);
2953
+ for (const [k, v] of this.map)
2954
+ if (this.keyEquals(k, key))
2955
+ return true;
2956
+ return false;
2957
+ }
2958
+ set(key, value) {
2959
+ if (this.keyEquals === DefaultEqualityFn || this.map.has(key)) {
2960
+ this.map.set(key, value);
2961
+ return value;
2962
+ }
2963
+ for (const key2 of this.map.keys())
2964
+ if (this.keyEquals(key2, key)) {
2965
+ this.map.set(key2, value);
2966
+ return value;
2967
+ }
2968
+ this.map.set(key, value);
2793
2969
  return value;
2794
2970
  }
2795
- get(key1) {
2796
- return this.map1.get(key1);
2971
+ get(key) {
2972
+ if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
2973
+ return this.map.get(key);
2974
+ for (const [k, v] of this.map)
2975
+ if (this.keyEquals(k, key))
2976
+ return v;
2977
+ return void 0;
2797
2978
  }
2798
- getOrDefault(key1, defaultValue) {
2799
- return this.get(key1) ?? defaultValue;
2979
+ delete(key) {
2980
+ if (this.keyEquals === DefaultEqualityFn || this.map.has(key))
2981
+ return this.map.delete(key);
2982
+ for (const k of this.map.keys())
2983
+ if (this.keyEquals(k, key))
2984
+ return this.map.delete(k);
2985
+ return this.map.delete(key);
2800
2986
  }
2801
- getOrCreate(key1, creatorOrValue) {
2802
- if (!this.has(key1)) {
2987
+ getOrDefault(key, defaultValue) {
2988
+ return this.get(key) ?? defaultValue;
2989
+ }
2990
+ getOrCreate(key, creatorOrValue) {
2991
+ if (!this.has(key)) {
2803
2992
  const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
2804
- this.set(key1, value);
2805
- return value;
2993
+ return this.set(key, value);
2806
2994
  }
2807
- return this.get(key1);
2808
- }
2809
- delete(key1) {
2810
- return this.map1.delete(key1);
2995
+ return this.get(key);
2811
2996
  }
2812
2997
  clear() {
2813
- this.map1.clear();
2998
+ this.map.clear();
2814
2999
  }
2815
3000
  get size() {
2816
- return this.map1.size;
3001
+ return this.map.size;
2817
3002
  }
2818
3003
  isEmpty() {
2819
3004
  return this.size === 0;
2820
3005
  }
2821
3006
  forEach(callbackfn, thisArg) {
2822
- this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
3007
+ this.map.forEach((value, key) => callbackfn.call(thisArg, value, key, this));
2823
3008
  }
2824
3009
  *keys() {
2825
- yield* this.map1.keys();
3010
+ yield* this.map.keys();
2826
3011
  }
2827
3012
  *values() {
2828
- yield* this.map1.values();
3013
+ yield* this.map.values();
2829
3014
  }
2830
3015
  *entries() {
2831
- for (const [key1, value] of this.map1)
2832
- yield [key1, value];
3016
+ for (const [key, value] of this.map)
3017
+ yield [key, value];
2833
3018
  }
2834
3019
  keysArray() {
2835
3020
  return [...this.keys()];
@@ -2859,34 +3044,34 @@ var Map1 = class _Map1 {
2859
3044
  yield* this.entries();
2860
3045
  }
2861
3046
  clone() {
2862
- return new _Map1(this);
3047
+ return new _UniMap(this, this.keyEquals);
2863
3048
  }
2864
3049
  merge(other, conflictResolver) {
2865
- for (const [key1, value] of other.entries()) {
2866
- if (this.has(key1) && conflictResolver) {
2867
- this.set(key1, conflictResolver(this.get(key1), value, key1));
3050
+ for (const [key, value] of other.entries()) {
3051
+ if (this.has(key) && conflictResolver) {
3052
+ this.set(key, conflictResolver(this.get(key), value, key));
2868
3053
  } else {
2869
- this.set(key1, value);
3054
+ this.set(key, value);
2870
3055
  }
2871
3056
  }
2872
3057
  return this;
2873
3058
  }
2874
3059
  some(fn) {
2875
- for (const [key1, value] of this.map1) {
2876
- if (fn(value, key1)) return true;
3060
+ for (const [key, value] of this.map) {
3061
+ if (fn(value, key)) return true;
2877
3062
  }
2878
3063
  return false;
2879
3064
  }
2880
3065
  every(fn) {
2881
- for (const [key1, value] of this.map1) {
2882
- if (!fn(value, key1)) return false;
3066
+ for (const [key, value] of this.map) {
3067
+ if (!fn(value, key)) return false;
2883
3068
  }
2884
3069
  return true;
2885
3070
  }
2886
3071
  filter(predicate) {
2887
3072
  const result = new this.constructor();
2888
- for (const [key1, value] of this.map1) {
2889
- if (predicate(value, key1, this)) result.set(key1, value);
3073
+ for (const [key, value] of this.map) {
3074
+ if (predicate(value, key, this)) result.set(key, value);
2890
3075
  }
2891
3076
  return result;
2892
3077
  }
@@ -2909,41 +3094,48 @@ var Map1 = class _Map1 {
2909
3094
  start = first;
2910
3095
  }
2911
3096
  for (let current = start; !current.done; current = iterator.next()) {
2912
- const [key1, value] = current.value;
2913
- acc = fn(acc, value, key1);
3097
+ const [key, value] = current.value;
3098
+ acc = fn(acc, value, key);
2914
3099
  }
2915
3100
  return acc;
2916
3101
  }
2917
3102
  mapEntries(fn) {
2918
3103
  let result = [];
2919
- for (const [key1, value] of this.map1) {
2920
- result.push(fn(value, key1));
3104
+ for (const [key, value] of this.map) {
3105
+ result.push(fn(value, key));
2921
3106
  }
2922
3107
  return result;
2923
3108
  }
2924
3109
  mapValues(fn) {
2925
- let result = new _Map1();
2926
- for (const [key1, value] of this.map1) {
2927
- result.set(key1, fn(value, key1));
3110
+ let result = new _UniMap();
3111
+ for (const [key, value] of this.map) {
3112
+ result.set(key, fn(value, key));
2928
3113
  }
2929
3114
  return result;
2930
3115
  }
2931
3116
  toMap() {
2932
- return new Map(this.map1);
3117
+ return new Map(this.map);
2933
3118
  }
2934
3119
  toString() {
2935
- const entries = [...this.map1].map(([k, v]) => `${formatValue(k)} => ${formatValue(v)}`).join(", ");
2936
- return `Map1(${this.size}){ ${entries} }`.replaceAll(" ", " ");
3120
+ const entries = [...this.map].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
3121
+ return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
2937
3122
  }
2938
3123
  };
2939
3124
 
2940
- // src/core/map2.ts
2941
- var Map2 = class _Map2 {
3125
+ // src/core/bi-map.ts
3126
+ var BiMap = class _BiMap extends BaseContainer {
2942
3127
  constructor(entries) {
2943
- __publicField(this, "map1", /* @__PURE__ */ new Map());
2944
- if (entries instanceof _Map2) {
2945
- for (const [key1, inner] of entries.map1) {
2946
- this.map1.set(key1, new Map(inner));
3128
+ super();
3129
+ __publicField(this, "map1");
3130
+ __publicField(this, "key1Equals", DefaultEqualityFn);
3131
+ __publicField(this, "key2Equals", DefaultEqualityFn);
3132
+ this.map1 = new UniMap(this.key1Equals);
3133
+ if (entries instanceof _BiMap) {
3134
+ for (const [key1, map2] of entries.map1) {
3135
+ const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
3136
+ for (const [key2, value] of map2) {
3137
+ newMap2.set(key2, value);
3138
+ }
2947
3139
  }
2948
3140
  } else if (entries) {
2949
3141
  for (const [key1, key2, value] of entries) {
@@ -2955,9 +3147,7 @@ var Map2 = class _Map2 {
2955
3147
  return this.map1.get(key1)?.has(key2) ?? false;
2956
3148
  }
2957
3149
  set(key1, key2, value) {
2958
- let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
2959
- map2.set(key2, value);
2960
- return value;
3150
+ return this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals)).set(key2, value);
2961
3151
  }
2962
3152
  get(key1, key2) {
2963
3153
  return this.map1.get(key1)?.get(key2);
@@ -3035,7 +3225,7 @@ var Map2 = class _Map2 {
3035
3225
  yield* this.entries();
3036
3226
  }
3037
3227
  clone() {
3038
- return new _Map2(this);
3228
+ return new _BiMap(this);
3039
3229
  }
3040
3230
  merge(other, conflictResolver) {
3041
3231
  for (const [key1, key2, value] of other.entries()) {
@@ -3106,7 +3296,7 @@ var Map2 = class _Map2 {
3106
3296
  return result;
3107
3297
  }
3108
3298
  mapValues(fn) {
3109
- let result = new _Map2();
3299
+ let result = new _BiMap();
3110
3300
  for (const [key1, map2] of this.map1) {
3111
3301
  for (const [key2, value] of map2) {
3112
3302
  result.set(key1, key2, fn(value, key1, key2));
@@ -3126,24 +3316,28 @@ var Map2 = class _Map2 {
3126
3316
  toString() {
3127
3317
  const entries = [];
3128
3318
  for (const [key1, map2] of this.map1) {
3129
- const inner = [...map2].map(([key2, v]) => `${formatValue(key2)} => ${formatValue(v)}`).join(", ");
3130
- entries.push(`${formatValue(key1)} => { ${inner} }`);
3319
+ const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
3320
+ entries.push(`${stringify(key1)} => { ${inner} }`);
3131
3321
  }
3132
- return `Map2(${this.size}){ ${entries} }`.replaceAll(" ", " ");
3322
+ return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
3133
3323
  }
3134
3324
  };
3135
3325
 
3136
- // src/core/map3.ts
3137
- var Map3 = class _Map3 {
3326
+ // src/core/tri-map.ts
3327
+ var TriMap = class _TriMap extends BaseContainer {
3138
3328
  constructor(entries) {
3139
- __publicField(this, "map1", /* @__PURE__ */ new Map());
3140
- if (entries instanceof _Map3) {
3329
+ super();
3330
+ __publicField(this, "map1");
3331
+ __publicField(this, "key1Equals", DefaultEqualityFn);
3332
+ __publicField(this, "key2Equals", DefaultEqualityFn);
3333
+ __publicField(this, "key3Equals", DefaultEqualityFn);
3334
+ this.map1 = new UniMap(this.key1Equals);
3335
+ if (entries instanceof _TriMap) {
3141
3336
  for (const [key1, map2] of entries.map1) {
3142
- const newMap2 = /* @__PURE__ */ new Map();
3337
+ const newMap2 = this.map1.set(key1, new UniMap(this.key2Equals));
3143
3338
  for (const [key2, map3] of map2) {
3144
- newMap2.set(key2, new Map(map3));
3339
+ newMap2.set(key2, new UniMap(map3, this.key3Equals));
3145
3340
  }
3146
- this.map1.set(key1, newMap2);
3147
3341
  }
3148
3342
  } else if (entries) {
3149
3343
  for (const [key1, key2, key3, value] of entries) {
@@ -3155,10 +3349,8 @@ var Map3 = class _Map3 {
3155
3349
  return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
3156
3350
  }
3157
3351
  set(key1, key2, key3, value) {
3158
- let map2 = this.map1.get(key1);
3159
- if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
3160
- let map3 = map2.get(key2);
3161
- if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
3352
+ let map2 = this.map1.getOrCreate(key1, () => new UniMap(this.key2Equals));
3353
+ let map3 = map2.getOrCreate(key2, () => new UniMap(this.key3Equals));
3162
3354
  map3.set(key3, value);
3163
3355
  return value;
3164
3356
  }
@@ -3250,7 +3442,7 @@ var Map3 = class _Map3 {
3250
3442
  yield* this.entries();
3251
3443
  }
3252
3444
  clone() {
3253
- return new _Map3(this);
3445
+ return new _TriMap(this);
3254
3446
  }
3255
3447
  merge(other, conflictResolver) {
3256
3448
  for (const [key1, key2, key3, value] of other.entries()) {
@@ -3329,7 +3521,7 @@ var Map3 = class _Map3 {
3329
3521
  return result;
3330
3522
  }
3331
3523
  mapValues(fn) {
3332
- let result = new _Map3();
3524
+ let result = new _TriMap();
3333
3525
  for (const [key1, map2] of this.map1) {
3334
3526
  for (const [key2, map3] of map2) {
3335
3527
  for (const [key3, value] of map3) {
@@ -3354,22 +3546,32 @@ var Map3 = class _Map3 {
3354
3546
  const entries = [];
3355
3547
  for (const [key1, map2] of this.map1) {
3356
3548
  for (const [key2, map3] of map2) {
3357
- const inner = [...map3].map(([key3, v]) => `${formatValue(key3)} => ${formatValue(v)}`).join(", ");
3358
- entries.push(`${formatValue(key1)} => ${formatValue(key2)} => { ${inner} }`);
3549
+ const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
3550
+ entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
3359
3551
  }
3360
3552
  }
3361
- return `Map3(${this.size}){ ${entries.join(", ")} }`.replaceAll(" ", " ");
3553
+ return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
3362
3554
  }
3363
3555
  };
3364
3556
 
3365
3557
  // src/core/set.ts
3366
- var SetBase = class {
3367
- constructor(entries) {
3558
+ var ValueSet = class _ValueSet extends BaseContainer {
3559
+ constructor(...args) {
3560
+ super();
3368
3561
  __publicField(this, "data");
3369
- this.data = new Set(entries ?? []);
3562
+ __publicField(this, "equals");
3563
+ const maybeEquals = args.at(-1);
3564
+ this.equals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
3565
+ const entries = args[0];
3566
+ this.data = new Set(entries);
3567
+ }
3568
+ static createDeep(arg) {
3569
+ return arg ? new _ValueSet(arg, isDeepEqual2) : new _ValueSet(isDeepEqual2);
3370
3570
  }
3371
3571
  has(value) {
3372
- return this.some((v) => this.valueEquals(v, value));
3572
+ if (this.equals === DefaultEqualityFn)
3573
+ return this.data.has(value);
3574
+ return this.some((v) => this.equals(v, value));
3373
3575
  }
3374
3576
  add(value) {
3375
3577
  if (!this.has(value))
@@ -3378,8 +3580,8 @@ var SetBase = class {
3378
3580
  }
3379
3581
  /** @internal - This method exists only for interface `KVComponent` compatibility.*/
3380
3582
  set(key, value) {
3381
- if (!this.valueEquals(key, value))
3382
- throw new TypeError("SetBase.set() requires key === value.");
3583
+ if (!this.equals(key, value))
3584
+ throw new TypeError("ValueSet.set() requires key === value.");
3383
3585
  this.add(value);
3384
3586
  }
3385
3587
  /** @internal - This method exists only for interface `KVComponent` compatibility.*/
@@ -3399,9 +3601,10 @@ var SetBase = class {
3399
3601
  return this.get(key);
3400
3602
  }
3401
3603
  delete(value) {
3402
- if (!this.has(value)) return false;
3604
+ if (this.equals === DefaultEqualityFn || this.data.has(value))
3605
+ return this.data.delete(value);
3403
3606
  for (const v of this.values()) {
3404
- if (this.valueEquals(v, value)) {
3607
+ if (this.equals(v, value)) {
3405
3608
  this.data.delete(v);
3406
3609
  return true;
3407
3610
  }
@@ -3448,7 +3651,7 @@ var SetBase = class {
3448
3651
  yield* this.values();
3449
3652
  }
3450
3653
  clone() {
3451
- const result = this.createEmpty();
3654
+ const result = new _ValueSet();
3452
3655
  for (const v of this.values()) result.add(v);
3453
3656
  return result;
3454
3657
  }
@@ -3471,7 +3674,7 @@ var SetBase = class {
3471
3674
  return true;
3472
3675
  }
3473
3676
  filter(predicate) {
3474
- const result = this.createEmpty();
3677
+ const result = new _ValueSet();
3475
3678
  for (const value of this.data)
3476
3679
  if (predicate(value, this)) result.add(value);
3477
3680
  return result;
@@ -3481,7 +3684,7 @@ var SetBase = class {
3481
3684
  let first = iterator.next();
3482
3685
  if (first.done) {
3483
3686
  if (arguments.length < 2) {
3484
- throw new TypeError("Reduce of empty SetBase with no initial value!");
3687
+ throw new TypeError("Reduce of empty ValueSet with no initial value!");
3485
3688
  }
3486
3689
  return init;
3487
3690
  }
@@ -3501,7 +3704,7 @@ var SetBase = class {
3501
3704
  return acc;
3502
3705
  }
3503
3706
  mapValues(fn) {
3504
- let result = this.createEmpty();
3707
+ let result = new _ValueSet();
3505
3708
  for (const value of this.data) {
3506
3709
  result.add(fn(value));
3507
3710
  }
@@ -3515,7 +3718,7 @@ var SetBase = class {
3515
3718
  return result;
3516
3719
  }
3517
3720
  map(fn) {
3518
- let result = this.createEmpty();
3721
+ let result = new _ValueSet();
3519
3722
  for (const value of this.values()) {
3520
3723
  result.add(fn(value));
3521
3724
  }
@@ -3528,41 +3731,14 @@ var SetBase = class {
3528
3731
  return [...this.values()];
3529
3732
  }
3530
3733
  toString() {
3531
- return `${this.getName()}(${this.size})${formatValue([...this.data])}`.replaceAll(" ", " ");
3532
- }
3533
- };
3534
- var Set1 = class _Set1 extends SetBase {
3535
- constructor(entries) {
3536
- super(entries);
3537
- }
3538
- createEmpty() {
3539
- return new _Set1();
3540
- }
3541
- valueEquals(a, b) {
3542
- return a === b;
3543
- }
3544
- getName() {
3545
- return "Set1";
3546
- }
3547
- };
3548
- var DeepSet = class _DeepSet extends SetBase {
3549
- constructor(entries) {
3550
- super(entries);
3551
- }
3552
- createEmpty() {
3553
- return new _DeepSet();
3554
- }
3555
- valueEquals(a, b) {
3556
- return isDeepEqual2(a, b);
3557
- }
3558
- getName() {
3559
- return "DeepSet";
3734
+ return stringify(this.data);
3560
3735
  }
3561
3736
  };
3562
3737
 
3563
3738
  // src/core/multi-container.ts
3564
- var MultiContainer = class {
3739
+ var MultiContainer = class extends BaseContainer {
3565
3740
  constructor(base) {
3741
+ super();
3566
3742
  this.base = base;
3567
3743
  }
3568
3744
  isEmpty() {
@@ -3618,17 +3794,382 @@ var MultiContainer = class {
3618
3794
  const entries = [];
3619
3795
  for (const keys of this.keys()) {
3620
3796
  const arr = this.getAll(...keys);
3621
- const keyStr = Array.isArray(keys) ? formatValue(keys) : "[ ]";
3622
- const valuesStr = Array.isArray(arr) ? formatValue(arr) : "[ ]";
3797
+ const keyStr = Array.isArray(keys) ? stringify(keys) : "[ ]";
3798
+ const valuesStr = Array.isArray(arr) ? stringify(arr) : "[ ]";
3623
3799
  entries.push(`${keyStr} => ${valuesStr}`);
3624
3800
  }
3625
- return `MultiContainer{ ${entries.join(", ")} }`.replaceAll(" ", " ");
3801
+ return entries.length === 0 ? `MultiContainer{ }` : `MultiContainer{ ${entries.join(", ")} }`;
3626
3802
  }
3627
3803
  };
3628
3804
  function asMulti(base) {
3629
3805
  return new MultiContainer(base);
3630
3806
  }
3631
3807
 
3808
+ // src/core/linked-list.ts
3809
+ var LinkedListNode = class {
3810
+ constructor(value) {
3811
+ this.value = value;
3812
+ __publicField(this, "next", null);
3813
+ __publicField(this, "prev", null);
3814
+ }
3815
+ };
3816
+ var LinkedList = class _LinkedList extends BaseContainer {
3817
+ constructor(...args) {
3818
+ super();
3819
+ __publicField(this, "_head", null);
3820
+ __publicField(this, "_tail", null);
3821
+ __publicField(this, "_size", 0);
3822
+ __publicField(this, "equals");
3823
+ const maybeEquals = args.at(-1);
3824
+ this.equals = isFunction2(maybeEquals) ? args.pop() : DefaultEqualityFn;
3825
+ const entries = args[0];
3826
+ if (entries) {
3827
+ for (const v of entries) {
3828
+ this.push(v);
3829
+ }
3830
+ }
3831
+ }
3832
+ static createDeep(entries) {
3833
+ if (entries) {
3834
+ return new _LinkedList(entries, isDeepEqual2);
3835
+ } else {
3836
+ return new _LinkedList(isDeepEqual2);
3837
+ }
3838
+ }
3839
+ get length() {
3840
+ return this._size;
3841
+ }
3842
+ get first() {
3843
+ return this._head?.value;
3844
+ }
3845
+ get last() {
3846
+ return this._tail?.value;
3847
+ }
3848
+ /** Add item to the end of the list */
3849
+ push(value) {
3850
+ const node = new LinkedListNode(value);
3851
+ if (!this._tail) {
3852
+ this._head = this._tail = node;
3853
+ } else {
3854
+ node.prev = this._tail;
3855
+ this._tail.next = node;
3856
+ this._tail = node;
3857
+ }
3858
+ this._size++;
3859
+ }
3860
+ /** Remove item from the end of the list */
3861
+ pop() {
3862
+ if (!this._tail) return void 0;
3863
+ const value = this._tail.value;
3864
+ this._tail = this._tail.prev;
3865
+ if (this._tail) this._tail.next = null;
3866
+ else this._head = null;
3867
+ this._size--;
3868
+ return value;
3869
+ }
3870
+ /** Add item to the beginning of the list */
3871
+ unshift(value) {
3872
+ const node = new LinkedListNode(value);
3873
+ if (!this._head) {
3874
+ this._head = this._tail = node;
3875
+ } else {
3876
+ node.next = this._head;
3877
+ this._head.prev = node;
3878
+ this._head = node;
3879
+ }
3880
+ this._size++;
3881
+ }
3882
+ /** Remove item from the beginning of the list */
3883
+ shift() {
3884
+ if (!this._head) return void 0;
3885
+ const value = this._head.value;
3886
+ this._head = this._head.next;
3887
+ if (this._head) this._head.prev = null;
3888
+ else this._tail = null;
3889
+ this._size--;
3890
+ return value;
3891
+ }
3892
+ /** Check if value exists in the list */
3893
+ has(value) {
3894
+ for (let node = this._head; node; node = node.next) {
3895
+ if (this.equals(node.value, value)) return true;
3896
+ }
3897
+ return false;
3898
+ }
3899
+ /** Get value at index (O(n/2)) */
3900
+ get(index) {
3901
+ return this.nodeAt(index)?.value;
3902
+ }
3903
+ /** Set value at index (O(n/2)) */
3904
+ set(index, value) {
3905
+ const node = this.nodeAt(index);
3906
+ if (!node) return false;
3907
+ node.value = value;
3908
+ return true;
3909
+ }
3910
+ /** Insert value at index (O(n/2)) */
3911
+ insertAt(index, value) {
3912
+ if (index < 0 || index > this._size) return false;
3913
+ if (index === 0) {
3914
+ this.unshift(value);
3915
+ return true;
3916
+ }
3917
+ if (index === this._size) {
3918
+ this.push(value);
3919
+ return true;
3920
+ }
3921
+ const nextNode = this.nodeAt(index);
3922
+ if (!nextNode) return false;
3923
+ const prevNode = nextNode.prev;
3924
+ const newNode = new LinkedListNode(value);
3925
+ newNode.next = nextNode;
3926
+ newNode.prev = prevNode;
3927
+ if (prevNode) prevNode.next = newNode;
3928
+ nextNode.prev = newNode;
3929
+ this._size++;
3930
+ return true;
3931
+ }
3932
+ /** Remove value at index (O(n/2)) */
3933
+ removeAt(index) {
3934
+ const node = this.nodeAt(index);
3935
+ if (!node) return void 0;
3936
+ if (node.prev) node.prev.next = node.next;
3937
+ else this._head = node.next;
3938
+ if (node.next) node.next.prev = node.prev;
3939
+ else this._tail = node.prev;
3940
+ this._size--;
3941
+ return node.value;
3942
+ }
3943
+ /** Remove first matching value (O(n)) */
3944
+ remove(value) {
3945
+ for (let node = this._head; node; node = node.next) {
3946
+ if (this.equals(node.value, value)) {
3947
+ if (node.prev) node.prev.next = node.next;
3948
+ else this._head = node.next;
3949
+ if (node.next) node.next.prev = node.prev;
3950
+ else this._tail = node.prev;
3951
+ this._size--;
3952
+ return true;
3953
+ }
3954
+ }
3955
+ return false;
3956
+ }
3957
+ /** Convert to array */
3958
+ toArray() {
3959
+ const result = [];
3960
+ for (const v of this) result.push(v);
3961
+ return result;
3962
+ }
3963
+ /** Replace contents from array */
3964
+ fromArray(values) {
3965
+ this.clear();
3966
+ for (const v of values) this.push(v);
3967
+ }
3968
+ /** Clear all nodes */
3969
+ clear() {
3970
+ this._head = this._tail = null;
3971
+ this._size = 0;
3972
+ }
3973
+ /** Iterator support */
3974
+ *[Symbol.iterator]() {
3975
+ yield* this.values();
3976
+ }
3977
+ *keys() {
3978
+ for (let id = 0; id < this._size; id++)
3979
+ yield id;
3980
+ }
3981
+ *values() {
3982
+ let node = this._head;
3983
+ while (node) {
3984
+ yield node.value;
3985
+ node = node.next;
3986
+ }
3987
+ }
3988
+ *entries() {
3989
+ let node = this._head;
3990
+ let id = 0;
3991
+ while (node) {
3992
+ yield [id++, node.value];
3993
+ node = node.next;
3994
+ }
3995
+ }
3996
+ toString() {
3997
+ return this._size === 0 ? `LinkedList(0)[ ]` : `LinkedList(${this._size})[ ${this.toArray().join(", ")} ]`;
3998
+ }
3999
+ // ---- Private helpers ----
4000
+ nodeAt(index) {
4001
+ if (index < 0 || index >= this._size) return null;
4002
+ let node;
4003
+ if (index < this._size / 2) {
4004
+ node = this._head;
4005
+ for (let i = 0; i < index; i++) node = node.next;
4006
+ } else {
4007
+ node = this._tail;
4008
+ for (let i = this._size - 1; i > index; i--) node = node.prev;
4009
+ }
4010
+ return node;
4011
+ }
4012
+ clone() {
4013
+ return new _LinkedList(this);
4014
+ }
4015
+ };
4016
+
4017
+ // src/utils/str/index.ts
4018
+ function toCharArray(str2) {
4019
+ return str2.split("");
4020
+ }
4021
+ function repeatString(repeatString2, repeatCount) {
4022
+ if (!isInteger2(repeatCount) || repeatCount < 0) {
4023
+ throw new Error("repeatStr: Invalid repeatCount = " + repeatCount);
4024
+ }
4025
+ return new Array(repeatCount + 1).join(repeatString2);
4026
+ }
4027
+ function chunkString(str2, chunkSize) {
4028
+ if (!isInteger2(chunkSize) || chunkSize < 1) {
4029
+ throw new Error("chunckString: Invalid chuckSize = " + chunkSize);
4030
+ }
4031
+ let result = [];
4032
+ for (let i = 0; i < str2.length; i += chunkSize) {
4033
+ result.push(str2.slice(i, i + chunkSize));
4034
+ }
4035
+ return result;
4036
+ }
4037
+ function replaceAt(str2, pos, removeCount, insert) {
4038
+ if (!isInteger2(removeCount) || removeCount < 0) {
4039
+ throw new Error("replaceAt: Invalid removeCount = " + removeCount);
4040
+ } else if (!isInteger2(pos) || pos < 0 || pos + removeCount > str2.length) {
4041
+ throw new Error("replaceAt: Invalid pos = " + pos + ", removeCount = " + removeCount + ", str.length = " + str2.length);
4042
+ } else {
4043
+ return str2.substring(0, pos) + insert + str2.substring(pos + removeCount);
4044
+ }
4045
+ }
4046
+ function insertAt(str2, pos, insertStr) {
4047
+ return replaceAt(str2, pos, 0, insertStr);
4048
+ }
4049
+ function removeAt(str2, pos, removeCount) {
4050
+ return replaceAt(str2, pos, removeCount, "");
4051
+ }
4052
+ function charCount(str2, ch) {
4053
+ if (ch.length !== 1 || str2.length === 0) return 0;
4054
+ let count = 0;
4055
+ for (let i = 0; i < str2.length; i++) {
4056
+ if (str2[i] === ch) count++;
4057
+ }
4058
+ return count;
4059
+ }
4060
+ function makeSentenceFromPascal(PascalString) {
4061
+ if (PascalString === "") {
4062
+ return "";
4063
+ }
4064
+ let word = PascalString.charAt(0);
4065
+ let sentence = "";
4066
+ const addWord = () => {
4067
+ if (word !== "") {
4068
+ if (sentence === "") {
4069
+ sentence += word.charAt(0).toUpperCase() + word.substring(1);
4070
+ } else {
4071
+ sentence += " " + word;
4072
+ }
4073
+ word = "";
4074
+ }
4075
+ };
4076
+ const isLetterAndCapital = (c) => {
4077
+ return c.toUpperCase() !== c.toLowerCase() && c === c.toUpperCase();
4078
+ };
4079
+ for (let i = 1; i < PascalString.length; i++) {
4080
+ let c = PascalString.charAt(i);
4081
+ if (isLetterAndCapital(c)) {
4082
+ addWord();
4083
+ }
4084
+ word += c.toLowerCase();
4085
+ }
4086
+ addWord();
4087
+ return sentence;
4088
+ }
4089
+ function stringify(value, maxDepth = 5, seen = /* @__PURE__ */ new WeakSet()) {
4090
+ if (value === null) return "null";
4091
+ if (value === void 0) return "undefined";
4092
+ const t = typeof value;
4093
+ switch (t) {
4094
+ case "boolean":
4095
+ return value ? "true" : "false";
4096
+ case "number":
4097
+ if (isNaNValue2(value)) return "NaN";
4098
+ if (!isFinite3(value))
4099
+ return value < 0 ? "-Infinity" : "Infinity";
4100
+ return value.toString();
4101
+ case "bigint":
4102
+ return `${value}n`;
4103
+ case "string":
4104
+ return `"${value}"`;
4105
+ case "symbol":
4106
+ return value.description ? `Symbol(${value.description})` : "Symbol()";
4107
+ case "function":
4108
+ return `[Function${value.name ? ` ${value.name}` : ""}]`;
4109
+ }
4110
+ if (seen.has(value))
4111
+ return "[Circular]";
4112
+ if (maxDepth <= 0)
4113
+ return "[Depth limit]";
4114
+ maxDepth--;
4115
+ seen.add(value);
4116
+ const strfy = (v) => stringify(v, maxDepth, seen);
4117
+ if (isArray2(value)) {
4118
+ const inner = value.map((v) => strfy(v)).join(", ");
4119
+ return inner.length === 0 ? "[ ]" : `[ ${inner} ]`;
4120
+ }
4121
+ if (ArrayBuffer.isView(value)) {
4122
+ if (value instanceof DataView)
4123
+ return `DataView(${value.byteLength})`;
4124
+ const inner = Array.from(value).map((v) => strfy(v)).join(", ");
4125
+ return `${value.constructor.name}[ ${inner} ]`;
4126
+ }
4127
+ if (value instanceof ArrayBuffer)
4128
+ return `ArrayBuffer(${value.byteLength})`;
4129
+ if (value instanceof Map) {
4130
+ const entries = Array.from(value.entries()).map(([k, v]) => `${strfy(k)} => ${strfy(v)}`).join(", ");
4131
+ return entries.length === 0 ? `Map(${value.size}){ }` : `Map(${value.size}){ ${entries} }`;
4132
+ }
4133
+ if (value instanceof Set) {
4134
+ const entries = Array.from(value.values()).map((v) => strfy(v)).join(", ");
4135
+ return entries.length === 0 ? `Set(${value.size}){ }` : `Set(${value.size}){ ${entries} }`;
4136
+ }
4137
+ if (value instanceof WeakMap)
4138
+ return "WeakMap{ ? }";
4139
+ if (value instanceof WeakSet)
4140
+ return "WeakSet{ ? }";
4141
+ if (typeof BaseContainer !== "undefined" && value instanceof BaseContainer)
4142
+ return value.toString();
4143
+ if (value instanceof Date)
4144
+ return `Date("${value.toISOString()}")`;
4145
+ if (value instanceof RegExp)
4146
+ return value.toString();
4147
+ if (value instanceof Error)
4148
+ return `${value.name}("${value.message}")`;
4149
+ if (value instanceof Promise)
4150
+ return "Promise{ ? }";
4151
+ if (value instanceof URL)
4152
+ return `URL("${value.href}")`;
4153
+ if (value instanceof URLSearchParams)
4154
+ return `URLSearchParams("${value.toString()}")`;
4155
+ if (value === Math) return "Math";
4156
+ if (value === JSON) return "JSON";
4157
+ if (value === Reflect) return "Reflect";
4158
+ if (value === Intl) return "Intl";
4159
+ if (t === "object") {
4160
+ const ctorName = value.constructor?.name ?? "Object";
4161
+ const entries = Object.entries(value).map(
4162
+ ([key, val]) => `${strfy(key)}: ${strfy(val)}`
4163
+ );
4164
+ if (entries.length === 0) return `${ctorName}{ }`;
4165
+ return `${ctorName}{ ${entries.join(", ")} }`;
4166
+ }
4167
+ return String(value);
4168
+ }
4169
+
4170
+ // src/utils/index.ts
4171
+ var Is = guard_exports;
4172
+
3632
4173
  // src/deprecated/vec2.ts
3633
4174
  var Vec2 = class _Vec2 {
3634
4175
  constructor(x, y) {
@@ -3705,26 +4246,1181 @@ var SmallIntCache = class {
3705
4246
  this.neg = [];
3706
4247
  }
3707
4248
  };
4249
+
4250
+ // src/deprecated/map1.ts
4251
+ var Map1 = class _Map1 extends BaseContainer {
4252
+ constructor(entries) {
4253
+ super();
4254
+ __publicField(this, "map1");
4255
+ this.map1 = entries instanceof _Map1 ? new Map(entries.map1) : new Map(entries);
4256
+ }
4257
+ has(key1) {
4258
+ return this.map1.has(key1);
4259
+ }
4260
+ set(key1, value) {
4261
+ this.map1.set(key1, value);
4262
+ return value;
4263
+ }
4264
+ get(key1) {
4265
+ return this.map1.get(key1);
4266
+ }
4267
+ getOrDefault(key1, defaultValue) {
4268
+ return this.get(key1) ?? defaultValue;
4269
+ }
4270
+ getOrCreate(key1, creatorOrValue) {
4271
+ if (!this.has(key1)) {
4272
+ const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
4273
+ this.set(key1, value);
4274
+ return value;
4275
+ }
4276
+ return this.get(key1);
4277
+ }
4278
+ delete(key1) {
4279
+ return this.map1.delete(key1);
4280
+ }
4281
+ clear() {
4282
+ this.map1.clear();
4283
+ }
4284
+ get size() {
4285
+ return this.map1.size;
4286
+ }
4287
+ isEmpty() {
4288
+ return this.size === 0;
4289
+ }
4290
+ forEach(callbackfn, thisArg) {
4291
+ this.map1.forEach((value, key1) => callbackfn.call(thisArg, value, key1, this));
4292
+ }
4293
+ *keys() {
4294
+ yield* this.map1.keys();
4295
+ }
4296
+ *values() {
4297
+ yield* this.map1.values();
4298
+ }
4299
+ *entries() {
4300
+ for (const [key1, value] of this.map1)
4301
+ yield [key1, value];
4302
+ }
4303
+ keysArray() {
4304
+ return [...this.keys()];
4305
+ }
4306
+ valuesArray() {
4307
+ return [...this.values()];
4308
+ }
4309
+ entriesArray() {
4310
+ return [...this.entries()];
4311
+ }
4312
+ *kvKeys() {
4313
+ for (const key of this.keys()) {
4314
+ yield [key];
4315
+ }
4316
+ }
4317
+ *kvValues() {
4318
+ for (const el of this.values()) {
4319
+ yield el;
4320
+ }
4321
+ }
4322
+ *kvEntries() {
4323
+ for (const [key, el] of this.entries()) {
4324
+ yield [[key], el];
4325
+ }
4326
+ }
4327
+ *[Symbol.iterator]() {
4328
+ yield* this.entries();
4329
+ }
4330
+ clone() {
4331
+ return new _Map1(this);
4332
+ }
4333
+ merge(other, conflictResolver) {
4334
+ for (const [key1, value] of other.entries()) {
4335
+ if (this.has(key1) && conflictResolver) {
4336
+ this.set(key1, conflictResolver(this.get(key1), value, key1));
4337
+ } else {
4338
+ this.set(key1, value);
4339
+ }
4340
+ }
4341
+ return this;
4342
+ }
4343
+ some(fn) {
4344
+ for (const [key1, value] of this.map1) {
4345
+ if (fn(value, key1)) return true;
4346
+ }
4347
+ return false;
4348
+ }
4349
+ every(fn) {
4350
+ for (const [key1, value] of this.map1) {
4351
+ if (!fn(value, key1)) return false;
4352
+ }
4353
+ return true;
4354
+ }
4355
+ filter(predicate) {
4356
+ const result = new this.constructor();
4357
+ for (const [key1, value] of this.map1) {
4358
+ if (predicate(value, key1, this)) result.set(key1, value);
4359
+ }
4360
+ return result;
4361
+ }
4362
+ reduce(fn, init) {
4363
+ let iterator = this.entries();
4364
+ let first = iterator.next();
4365
+ if (first.done) {
4366
+ if (arguments.length < 2) {
4367
+ throw new TypeError("Reduce of empty Map1 with no initial value!");
4368
+ }
4369
+ return init;
4370
+ }
4371
+ let acc;
4372
+ let start;
4373
+ if (arguments.length < 2) {
4374
+ acc = first.value[1];
4375
+ start = iterator.next();
4376
+ } else {
4377
+ acc = init;
4378
+ start = first;
4379
+ }
4380
+ for (let current = start; !current.done; current = iterator.next()) {
4381
+ const [key1, value] = current.value;
4382
+ acc = fn(acc, value, key1);
4383
+ }
4384
+ return acc;
4385
+ }
4386
+ mapEntries(fn) {
4387
+ let result = [];
4388
+ for (const [key1, value] of this.map1) {
4389
+ result.push(fn(value, key1));
4390
+ }
4391
+ return result;
4392
+ }
4393
+ mapValues(fn) {
4394
+ let result = new _Map1();
4395
+ for (const [key1, value] of this.map1) {
4396
+ result.set(key1, fn(value, key1));
4397
+ }
4398
+ return result;
4399
+ }
4400
+ toMap() {
4401
+ return new Map(this.map1);
4402
+ }
4403
+ toString() {
4404
+ const entries = [...this.map1].map(([k, v]) => `${stringify(k)} => ${stringify(v)}`).join(", ");
4405
+ return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
4406
+ }
4407
+ };
4408
+
4409
+ // src/deprecated/map2.ts
4410
+ var Map2 = class _Map2 extends BaseContainer {
4411
+ constructor(entries) {
4412
+ super();
4413
+ __publicField(this, "map1", /* @__PURE__ */ new Map());
4414
+ if (entries instanceof _Map2) {
4415
+ for (const [key1, inner] of entries.map1) {
4416
+ this.map1.set(key1, new Map(inner));
4417
+ }
4418
+ } else if (entries) {
4419
+ for (const [key1, key2, value] of entries) {
4420
+ this.set(key1, key2, value);
4421
+ }
4422
+ }
4423
+ }
4424
+ has(key1, key2) {
4425
+ return this.map1.get(key1)?.has(key2) ?? false;
4426
+ }
4427
+ set(key1, key2, value) {
4428
+ let map2 = this.map1.get(key1) ?? this.map1.set(key1, /* @__PURE__ */ new Map()).get(key1);
4429
+ map2.set(key2, value);
4430
+ return value;
4431
+ }
4432
+ get(key1, key2) {
4433
+ return this.map1.get(key1)?.get(key2);
4434
+ }
4435
+ getOrDefault(key1, key2, defaultValue) {
4436
+ return this.get(key1, key2) ?? defaultValue;
4437
+ }
4438
+ getOrCreate(key1, key2, creatorOrValue) {
4439
+ if (!this.has(key1, key2)) {
4440
+ const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
4441
+ this.set(key1, key2, value);
4442
+ return value;
4443
+ }
4444
+ return this.get(key1, key2);
4445
+ }
4446
+ delete(key1, key2) {
4447
+ if (key2 === void 0) return this.map1.delete(key1);
4448
+ const map2 = this.map1.get(key1);
4449
+ if (!map2) return false;
4450
+ return map2.delete(key2);
4451
+ }
4452
+ clear() {
4453
+ this.map1.clear();
4454
+ }
4455
+ get size() {
4456
+ let count = 0;
4457
+ for (const map2 of this.map1.values()) {
4458
+ count += map2.size;
4459
+ }
4460
+ return count;
4461
+ }
4462
+ isEmpty() {
4463
+ return this.size === 0;
4464
+ }
4465
+ forEach(callbackfn, thisArg) {
4466
+ this.map1.forEach((map2, key1) => map2.forEach((value, key2) => callbackfn.call(thisArg, value, key1, key2, this)));
4467
+ }
4468
+ *keys() {
4469
+ for (const [key1, map2] of this.map1)
4470
+ for (const key2 of map2.keys())
4471
+ yield [key1, key2];
4472
+ }
4473
+ *values() {
4474
+ for (const map2 of this.map1.values())
4475
+ for (const value of map2.values())
4476
+ yield value;
4477
+ }
4478
+ *entries() {
4479
+ for (const [key1, map2] of this.map1)
4480
+ for (const [key2, value] of map2)
4481
+ yield [key1, key2, value];
4482
+ }
4483
+ keysArray() {
4484
+ return [...this.keys()];
4485
+ }
4486
+ valuesArray() {
4487
+ return [...this.values()];
4488
+ }
4489
+ entriesArray() {
4490
+ return [...this.entries()];
4491
+ }
4492
+ *kvKeys() {
4493
+ for (const [key1, key2] of this.keys())
4494
+ yield [key1, key2];
4495
+ }
4496
+ *kvValues() {
4497
+ for (const el of this.values())
4498
+ yield el;
4499
+ }
4500
+ *kvEntries() {
4501
+ for (const [key1, key2, el] of this.entries())
4502
+ yield [[key1, key2], el];
4503
+ }
4504
+ *[Symbol.iterator]() {
4505
+ yield* this.entries();
4506
+ }
4507
+ clone() {
4508
+ return new _Map2(this);
4509
+ }
4510
+ merge(other, conflictResolver) {
4511
+ for (const [key1, key2, value] of other.entries()) {
4512
+ if (this.has(key1, key2) && conflictResolver) {
4513
+ this.set(key1, key2, conflictResolver(this.get(key1, key2), value, key1, key2));
4514
+ } else {
4515
+ this.set(key1, key2, value);
4516
+ }
4517
+ }
4518
+ return this;
4519
+ }
4520
+ some(fn) {
4521
+ for (const [key1, map2] of this.map1) {
4522
+ for (const [key2, value] of map2) {
4523
+ if (fn(value, key1, key2)) return true;
4524
+ }
4525
+ }
4526
+ return false;
4527
+ }
4528
+ every(fn) {
4529
+ for (const [key1, map2] of this.map1) {
4530
+ for (const [key2, value] of map2) {
4531
+ if (!fn(value, key1, key2)) return false;
4532
+ }
4533
+ }
4534
+ return true;
4535
+ }
4536
+ filter(predicate) {
4537
+ const result = new this.constructor();
4538
+ for (const [key1, map2] of this.map1) {
4539
+ for (const [key2, value] of map2) {
4540
+ if (predicate(value, key1, key2, this)) result.set(key1, key2, value);
4541
+ }
4542
+ }
4543
+ return result;
4544
+ }
4545
+ reduce(fn, init) {
4546
+ let iterator = this.entries();
4547
+ let first = iterator.next();
4548
+ if (first.done) {
4549
+ if (arguments.length < 2) {
4550
+ throw new TypeError("Reduce of empty Map2 with no initial value!");
4551
+ }
4552
+ return init;
4553
+ }
4554
+ let acc;
4555
+ let start;
4556
+ if (arguments.length < 2) {
4557
+ acc = first.value[2];
4558
+ start = iterator.next();
4559
+ } else {
4560
+ acc = init;
4561
+ start = first;
4562
+ }
4563
+ for (let current = start; !current.done; current = iterator.next()) {
4564
+ const [key1, key2, value] = current.value;
4565
+ acc = fn(acc, value, key1, key2);
4566
+ }
4567
+ return acc;
4568
+ }
4569
+ mapEntries(fn) {
4570
+ let result = [];
4571
+ for (const [key1, map2] of this.map1) {
4572
+ for (const [key2, value] of map2) {
4573
+ result.push(fn(value, key1, key2));
4574
+ }
4575
+ }
4576
+ return result;
4577
+ }
4578
+ mapValues(fn) {
4579
+ let result = new _Map2();
4580
+ for (const [key1, map2] of this.map1) {
4581
+ for (const [key2, value] of map2) {
4582
+ result.set(key1, key2, fn(value, key1, key2));
4583
+ }
4584
+ }
4585
+ return result;
4586
+ }
4587
+ toMap() {
4588
+ let result = /* @__PURE__ */ new Map();
4589
+ for (const [key1, map2] of this.map1) {
4590
+ for (const [key2, value] of map2) {
4591
+ result.set([key1, key2], value);
4592
+ }
4593
+ }
4594
+ return result;
4595
+ }
4596
+ toString() {
4597
+ const entries = [];
4598
+ for (const [key1, map2] of this.map1) {
4599
+ const inner = [...map2].map(([key2, v]) => `${stringify(key2)} => ${stringify(v)}`).join(", ");
4600
+ entries.push(`${stringify(key1)} => { ${inner} }`);
4601
+ }
4602
+ return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries} }`;
4603
+ }
4604
+ };
4605
+
4606
+ // src/deprecated/map3.ts
4607
+ var Map3 = class _Map3 extends BaseContainer {
4608
+ constructor(entries) {
4609
+ super();
4610
+ __publicField(this, "map1", /* @__PURE__ */ new Map());
4611
+ if (entries instanceof _Map3) {
4612
+ for (const [key1, map2] of entries.map1) {
4613
+ const newMap2 = /* @__PURE__ */ new Map();
4614
+ for (const [key2, map3] of map2) {
4615
+ newMap2.set(key2, new Map(map3));
4616
+ }
4617
+ this.map1.set(key1, newMap2);
4618
+ }
4619
+ } else if (entries) {
4620
+ for (const [key1, key2, key3, value] of entries) {
4621
+ this.set(key1, key2, key3, value);
4622
+ }
4623
+ }
4624
+ }
4625
+ has(key1, key2, key3) {
4626
+ return this.map1.get(key1)?.get(key2)?.has(key3) ?? false;
4627
+ }
4628
+ set(key1, key2, key3, value) {
4629
+ let map2 = this.map1.get(key1);
4630
+ if (!map2) this.map1.set(key1, map2 = /* @__PURE__ */ new Map());
4631
+ let map3 = map2.get(key2);
4632
+ if (!map3) map2.set(key2, map3 = /* @__PURE__ */ new Map());
4633
+ map3.set(key3, value);
4634
+ return value;
4635
+ }
4636
+ get(key1, key2, key3) {
4637
+ return this.map1.get(key1)?.get(key2)?.get(key3);
4638
+ }
4639
+ getOrDefault(key1, key2, key3, defaultValue) {
4640
+ return this.get(key1, key2, key3) ?? defaultValue;
4641
+ }
4642
+ getOrCreate(key1, key2, key3, creatorOrValue) {
4643
+ if (!this.has(key1, key2, key3)) {
4644
+ const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
4645
+ this.set(key1, key2, key3, value);
4646
+ return value;
4647
+ }
4648
+ return this.get(key1, key2, key3);
4649
+ }
4650
+ delete(key1, key2, key3) {
4651
+ if (key3 === void 0) {
4652
+ if (key2 === void 0) return this.map1.delete(key1);
4653
+ const map2 = this.map1.get(key1);
4654
+ if (!map2) return false;
4655
+ return map2.delete(key2);
4656
+ } else {
4657
+ if (key2 === void 0) return this.map1.delete(key1);
4658
+ const map3 = this.map1.get(key1)?.get(key2);
4659
+ if (!map3) return false;
4660
+ return map3.delete(key3);
4661
+ }
4662
+ }
4663
+ clear() {
4664
+ this.map1.clear();
4665
+ }
4666
+ get size() {
4667
+ let count = 0;
4668
+ for (const map2 of this.map1.values()) {
4669
+ for (const map3 of map2.values()) {
4670
+ count += map3.size;
4671
+ }
4672
+ }
4673
+ return count;
4674
+ }
4675
+ isEmpty() {
4676
+ return this.size === 0;
4677
+ }
4678
+ forEach(callbackfn, thisArg) {
4679
+ this.map1.forEach((map2, key1) => map2.forEach((map3, key2) => map3.forEach((value, key3) => callbackfn.call(thisArg, value, key1, key2, key3, this))));
4680
+ }
4681
+ *keys() {
4682
+ for (const [key1, map2] of this.map1)
4683
+ for (const [key2, map3] of map2)
4684
+ for (const key3 of map3.keys())
4685
+ yield [key1, key2, key3];
4686
+ }
4687
+ *values() {
4688
+ for (const map2 of this.map1.values())
4689
+ for (const map3 of map2.values())
4690
+ for (const value of map3.values())
4691
+ yield value;
4692
+ }
4693
+ *entries() {
4694
+ for (const [key1, map2] of this.map1)
4695
+ for (const [key2, map3] of map2)
4696
+ for (const [key3, value] of map3)
4697
+ yield [key1, key2, key3, value];
4698
+ }
4699
+ keysArray() {
4700
+ return [...this.keys()];
4701
+ }
4702
+ valuesArray() {
4703
+ return [...this.values()];
4704
+ }
4705
+ entriesArray() {
4706
+ return [...this.entries()];
4707
+ }
4708
+ *kvKeys() {
4709
+ for (const [key1, key2, key3] of this.keys())
4710
+ yield [key1, key2, key3];
4711
+ }
4712
+ *kvValues() {
4713
+ for (const el of this.values())
4714
+ yield el;
4715
+ }
4716
+ *kvEntries() {
4717
+ for (const [key1, key2, key3, el] of this.entries())
4718
+ yield [[key1, key2, key3], el];
4719
+ }
4720
+ *[Symbol.iterator]() {
4721
+ yield* this.entries();
4722
+ }
4723
+ clone() {
4724
+ return new _Map3(this);
4725
+ }
4726
+ merge(other, conflictResolver) {
4727
+ for (const [key1, key2, key3, value] of other.entries()) {
4728
+ if (this.has(key1, key2, key3) && conflictResolver) {
4729
+ this.set(key1, key2, key3, conflictResolver(this.get(key1, key2, key3), value, key1, key2, key3));
4730
+ } else {
4731
+ this.set(key1, key2, key3, value);
4732
+ }
4733
+ }
4734
+ return this;
4735
+ }
4736
+ some(fn) {
4737
+ for (const [key1, map2] of this.map1) {
4738
+ for (const [key2, map3] of map2) {
4739
+ for (const [key3, value] of map3) {
4740
+ if (fn(value, key1, key2, key3)) return true;
4741
+ }
4742
+ }
4743
+ }
4744
+ return false;
4745
+ }
4746
+ every(fn) {
4747
+ for (const [key1, map2] of this.map1) {
4748
+ for (const [key2, map3] of map2) {
4749
+ for (const [key3, value] of map3) {
4750
+ if (!fn(value, key1, key2, key3)) return false;
4751
+ }
4752
+ }
4753
+ }
4754
+ return true;
4755
+ }
4756
+ filter(predicate) {
4757
+ const result = new this.constructor();
4758
+ for (const [key1, map2] of this.map1) {
4759
+ for (const [key2, map3] of map2) {
4760
+ for (const [key3, value] of map3) {
4761
+ if (predicate(value, key1, key2, key3, this)) result.set(key1, key2, key3, value);
4762
+ }
4763
+ }
4764
+ }
4765
+ return result;
4766
+ }
4767
+ reduce(fn, init) {
4768
+ let iterator = this.entries();
4769
+ let first = iterator.next();
4770
+ if (first.done) {
4771
+ if (arguments.length < 2) {
4772
+ throw new TypeError("Reduce of empty Map3 with no initial value!");
4773
+ }
4774
+ return init;
4775
+ }
4776
+ let acc;
4777
+ let start;
4778
+ if (arguments.length < 2) {
4779
+ acc = first.value[3];
4780
+ start = iterator.next();
4781
+ } else {
4782
+ acc = init;
4783
+ start = first;
4784
+ }
4785
+ for (let current = start; !current.done; current = iterator.next()) {
4786
+ const [key1, key2, key3, value] = current.value;
4787
+ acc = fn(acc, value, key1, key2, key3);
4788
+ }
4789
+ return acc;
4790
+ }
4791
+ mapEntries(fn) {
4792
+ let result = [];
4793
+ for (const [key1, map2] of this.map1) {
4794
+ for (const [key2, map3] of map2) {
4795
+ for (const [key3, value] of map3) {
4796
+ result.push(fn(value, key1, key2, key3));
4797
+ }
4798
+ }
4799
+ }
4800
+ return result;
4801
+ }
4802
+ mapValues(fn) {
4803
+ let result = new _Map3();
4804
+ for (const [key1, map2] of this.map1) {
4805
+ for (const [key2, map3] of map2) {
4806
+ for (const [key3, value] of map3) {
4807
+ result.set(key1, key2, key3, fn(value, key1, key2, key3));
4808
+ }
4809
+ }
4810
+ }
4811
+ return result;
4812
+ }
4813
+ toMap() {
4814
+ let result = /* @__PURE__ */ new Map();
4815
+ for (const [key1, map2] of this.map1) {
4816
+ for (const [key2, map3] of map2) {
4817
+ for (const [key3, value] of map3) {
4818
+ result.set([key1, key2, key3], value);
4819
+ }
4820
+ }
4821
+ }
4822
+ return result;
4823
+ }
4824
+ toString() {
4825
+ const entries = [];
4826
+ for (const [key1, map2] of this.map1) {
4827
+ for (const [key2, map3] of map2) {
4828
+ const inner = [...map3].map(([key3, v]) => `${stringify(key3)} => ${stringify(v)}`).join(", ");
4829
+ entries.push(`${stringify(key1)} => ${stringify(key2)} => { ${inner} }`);
4830
+ }
4831
+ }
4832
+ return entries.length === 0 ? `Map(${this.size}){ }` : `Map(${this.size}){ ${entries.join(", ")} }`;
4833
+ }
4834
+ };
4835
+
4836
+ // src/deprecated/set.ts
4837
+ var SetBase = class extends BaseContainer {
4838
+ constructor(entries) {
4839
+ super();
4840
+ __publicField(this, "data");
4841
+ this.data = new Set(entries ?? []);
4842
+ }
4843
+ has(value) {
4844
+ return this.some((v) => this.valueEquals(v, value));
4845
+ }
4846
+ add(value) {
4847
+ if (!this.has(value))
4848
+ this.data.add(value);
4849
+ return value;
4850
+ }
4851
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
4852
+ set(key, value) {
4853
+ if (!this.valueEquals(key, value))
4854
+ throw new TypeError("SetBase.set() requires key === value.");
4855
+ this.add(value);
4856
+ }
4857
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
4858
+ get(key) {
4859
+ return this.has(key) ? key : void 0;
4860
+ }
4861
+ /** @internal - This method exists only for interface `KVComponent` compatibility.*/
4862
+ getOrDefault(key, defaultValue) {
4863
+ return this.get(key) ?? defaultValue;
4864
+ }
4865
+ getOrCreate(key, creatorOrValue) {
4866
+ if (!this.has(key)) {
4867
+ const value = isFunction2(creatorOrValue) ? creatorOrValue() : creatorOrValue;
4868
+ this.set(key, value);
4869
+ return value;
4870
+ }
4871
+ return this.get(key);
4872
+ }
4873
+ delete(value) {
4874
+ if (!this.has(value)) return false;
4875
+ for (const v of this.values()) {
4876
+ if (this.valueEquals(v, value)) {
4877
+ this.data.delete(v);
4878
+ return true;
4879
+ }
4880
+ }
4881
+ return false;
4882
+ }
4883
+ clear() {
4884
+ this.data.clear();
4885
+ }
4886
+ get size() {
4887
+ return this.data.size;
4888
+ }
4889
+ isEmpty() {
4890
+ return this.size === 0;
4891
+ }
4892
+ forEach(callbackfn, thisArg) {
4893
+ this.data.forEach((value) => callbackfn.call(thisArg, value, this));
4894
+ }
4895
+ *keys() {
4896
+ yield* this.data.keys();
4897
+ }
4898
+ *values() {
4899
+ yield* this.data.values();
4900
+ }
4901
+ *entries() {
4902
+ yield* this.data.entries();
4903
+ }
4904
+ *kvKeys() {
4905
+ for (const key of this.keys()) {
4906
+ yield [key];
4907
+ }
4908
+ }
4909
+ *kvValues() {
4910
+ for (const el of this.values()) {
4911
+ yield el;
4912
+ }
4913
+ }
4914
+ *kvEntries() {
4915
+ for (const [key, el] of this.entries()) {
4916
+ yield [[key], el];
4917
+ }
4918
+ }
4919
+ *[Symbol.iterator]() {
4920
+ yield* this.values();
4921
+ }
4922
+ clone() {
4923
+ const result = this.createEmpty();
4924
+ for (const v of this.values()) result.add(v);
4925
+ return result;
4926
+ }
4927
+ merge(other) {
4928
+ for (const value of other.values()) {
4929
+ this.add(value);
4930
+ }
4931
+ return this;
4932
+ }
4933
+ some(fn) {
4934
+ for (const value of this.data) {
4935
+ if (fn(value)) return true;
4936
+ }
4937
+ return false;
4938
+ }
4939
+ every(fn) {
4940
+ for (const value of this.data) {
4941
+ if (!fn(value)) return false;
4942
+ }
4943
+ return true;
4944
+ }
4945
+ filter(predicate) {
4946
+ const result = this.createEmpty();
4947
+ for (const value of this.data)
4948
+ if (predicate(value, this)) result.add(value);
4949
+ return result;
4950
+ }
4951
+ reduce(fn, init) {
4952
+ let iterator = this.values();
4953
+ let first = iterator.next();
4954
+ if (first.done) {
4955
+ if (arguments.length < 2) {
4956
+ throw new TypeError("Reduce of empty SetBase with no initial value!");
4957
+ }
4958
+ return init;
4959
+ }
4960
+ let acc;
4961
+ let start;
4962
+ if (arguments.length < 2) {
4963
+ acc = first.value;
4964
+ start = iterator.next();
4965
+ } else {
4966
+ acc = init;
4967
+ start = first;
4968
+ }
4969
+ for (let current = start; !current.done; current = iterator.next()) {
4970
+ const value = current.value;
4971
+ acc = fn(acc, value);
4972
+ }
4973
+ return acc;
4974
+ }
4975
+ mapValues(fn) {
4976
+ let result = this.createEmpty();
4977
+ for (const value of this.data) {
4978
+ result.add(fn(value));
4979
+ }
4980
+ return result;
4981
+ }
4982
+ mapToArray(fn) {
4983
+ let result = [];
4984
+ for (const value of this.values()) {
4985
+ result.push(fn(value));
4986
+ }
4987
+ return result;
4988
+ }
4989
+ map(fn) {
4990
+ let result = this.createEmpty();
4991
+ for (const value of this.values()) {
4992
+ result.add(fn(value));
4993
+ }
4994
+ return result;
4995
+ }
4996
+ toSet() {
4997
+ return new Set(this.data);
4998
+ }
4999
+ toArray() {
5000
+ return [...this.values()];
5001
+ }
5002
+ toString() {
5003
+ return stringify(this.data);
5004
+ }
5005
+ };
5006
+ var Set1 = class _Set1 extends SetBase {
5007
+ constructor(entries) {
5008
+ super(entries);
5009
+ }
5010
+ createEmpty() {
5011
+ return new _Set1();
5012
+ }
5013
+ valueEquals(a, b) {
5014
+ return a === b;
5015
+ }
5016
+ };
5017
+ var DeepSet = class _DeepSet extends SetBase {
5018
+ constructor(entries) {
5019
+ super(entries);
5020
+ }
5021
+ createEmpty() {
5022
+ return new _DeepSet();
5023
+ }
5024
+ valueEquals(a, b) {
5025
+ return isDeepEqual2(a, b);
5026
+ }
5027
+ };
5028
+
5029
+ // src/deprecated/div-rect.ts
5030
+ var DivRect = class _DivRect {
5031
+ constructor(...args) {
5032
+ __publicField(this, "left");
5033
+ __publicField(this, "anchorX");
5034
+ __publicField(this, "right");
5035
+ __publicField(this, "top");
5036
+ __publicField(this, "anchorY");
5037
+ __publicField(this, "bottom");
5038
+ if (args.length === 6) {
5039
+ this.left = args[0];
5040
+ this.anchorX = args[1];
5041
+ this.right = args[2];
5042
+ this.top = args[3];
5043
+ this.anchorY = args[4];
5044
+ this.bottom = args[5];
5045
+ } else if (args.length === 4) {
5046
+ this.left = args[0];
5047
+ this.right = args[1];
5048
+ this.anchorX = (this.left + this.right) / 2;
5049
+ this.top = args[2];
5050
+ this.bottom = args[3];
5051
+ this.anchorY = (this.top + this.bottom) / 2;
5052
+ } else if (args.length === 0) {
5053
+ this.left = this.anchorX = this.right = 0;
5054
+ this.top = this.anchorY = this.bottom = 0;
5055
+ } else {
5056
+ throw new TypeError(`Invalid DivRect args: ${args}`);
5057
+ }
5058
+ }
5059
+ set(...args) {
5060
+ if (args.length === 6) {
5061
+ this.left = args[0];
5062
+ this.anchorX = args[1];
5063
+ this.right = args[2];
5064
+ this.top = args[3];
5065
+ this.anchorY = args[4];
5066
+ this.bottom = args[5];
5067
+ } else if (args.length === 4) {
5068
+ this.left = args[0];
5069
+ this.right = args[1];
5070
+ this.anchorX = (this.left + this.right) / 2;
5071
+ this.top = args[2];
5072
+ this.bottom = args[3];
5073
+ this.anchorY = (this.top + this.bottom) / 2;
5074
+ } else if (args.length === 0) {
5075
+ this.left = this.anchorX = this.right = 0;
5076
+ this.top = this.anchorY = this.bottom = 0;
5077
+ } else {
5078
+ throw new TypeError(`Invalid DivRect args: ${args}`);
5079
+ }
5080
+ return this;
5081
+ }
5082
+ /**
5083
+ * Create rect from basic left, top, width and height arguments.
5084
+ *
5085
+ * @param left - Left coordinate.
5086
+ * @param top - Top coordinate.
5087
+ * @param width - Width.
5088
+ * @param height - Height.
5089
+ * @returns - DivRect.
5090
+ */
5091
+ static create(left, top, width, height) {
5092
+ return new _DivRect(left, left + width, top, top + height);
5093
+ }
5094
+ /**
5095
+ * Create rect from anchorX, anchorY, width, height arguments.
5096
+ *
5097
+ * @param centerX - Center x-coordinate.
5098
+ * @param centerY - Center y-coordinate.
5099
+ * @param width - Width.
5100
+ * @param height - Height.
5101
+ * @returns - DivRect.
5102
+ */
5103
+ static createCentered(centerX, centerY, width, height) {
5104
+ return new _DivRect(
5105
+ centerX - width / 2,
5106
+ centerX,
5107
+ centerX + width / 2,
5108
+ centerY - height / 2,
5109
+ centerY,
5110
+ centerY + height / 2
5111
+ );
5112
+ }
5113
+ /**
5114
+ * Create rect from sections.
5115
+ *
5116
+ * @param leftw - Left section width.
5117
+ * @param rightw - Right section width.
5118
+ * @param toph - Top section height.
5119
+ * @param bottomh - Bottomsection height.
5120
+ * @returns - DivRect.
5121
+ */
5122
+ static createSections(leftw, rightw, toph, bottomh) {
5123
+ return new _DivRect(-leftw, 0, rightw, -toph, 0, bottomh);
5124
+ }
5125
+ /**
5126
+ * @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
5127
+ * @private
5128
+ * */
5129
+ get centerX() {
5130
+ return this.anchorX;
5131
+ }
5132
+ /**
5133
+ * @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
5134
+ * @private
5135
+ * */
5136
+ set centerX(x) {
5137
+ this.anchorX = x;
5138
+ }
5139
+ /**
5140
+ * @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
5141
+ * @private
5142
+ * */
5143
+ get centerY() {
5144
+ return this.anchorY;
5145
+ }
5146
+ /**
5147
+ * @deprecated - Renamed to anchorX. Will be removed in v2.0.0.
5148
+ * @private
5149
+ * */
5150
+ set centerY(y) {
5151
+ this.anchorY = y;
5152
+ }
5153
+ /**
5154
+ * Width getter.
5155
+ */
5156
+ get width() {
5157
+ return this.right - this.left;
5158
+ }
5159
+ /**
5160
+ * Height getter.
5161
+ */
5162
+ get height() {
5163
+ return this.bottom - this.top;
5164
+ }
5165
+ /**
5166
+ * Left section width getter.
5167
+ */
5168
+ get leftw() {
5169
+ return this.anchorX - this.left;
5170
+ }
5171
+ /**
5172
+ * Right section width getter.
5173
+ */
5174
+ get rightw() {
5175
+ return this.right - this.anchorX;
5176
+ }
5177
+ /**
5178
+ * Top section height getter.
5179
+ */
5180
+ get toph() {
5181
+ return this.anchorY - this.top;
5182
+ }
5183
+ /**
5184
+ * Bottom section height getter.
5185
+ */
5186
+ get bottomh() {
5187
+ return this.bottom - this.anchorY;
5188
+ }
5189
+ /**
5190
+ * Does this Rect contain given (x, y)-point?
5191
+ *
5192
+ * @param x - X-coordinate.
5193
+ * @param y - Y-coordinate.
5194
+ * @returns - True/false.
5195
+ */
5196
+ contains(x, y) {
5197
+ return x >= this.left && x <= this.right && y >= this.top && y <= this.bottom;
5198
+ }
5199
+ /**
5200
+ * Do a and b rects overlap?
5201
+ *
5202
+ * @param a - DivRect a.
5203
+ * @param b - DivRect b.
5204
+ * @returns - True/false.
5205
+ */
5206
+ static overlap(a, b) {
5207
+ return a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
5208
+ }
5209
+ /**
5210
+ * Do horizontal measures of a and b rects overlap?
5211
+ *
5212
+ * @param a - DivRect a.
5213
+ * @param b - DivRect b.
5214
+ * @returns - True/false.
5215
+ */
5216
+ static overlapX(a, b) {
5217
+ return a.right > b.left && a.left < b.right;
5218
+ }
5219
+ /**
5220
+ * Check if given rects are equal.
5221
+ * @param a - DivRect a.
5222
+ * @param b - DivRect b.
5223
+ * @returns - True/false.
5224
+ */
5225
+ static equals(a, b) {
5226
+ if (a == null && b == null) {
5227
+ return true;
5228
+ } else if (a == null || b == null) {
5229
+ return false;
5230
+ } else {
5231
+ return a === b || a.left === b.left && a.anchorX === b.anchorX && a.right === b.right && a.top === b.top && a.anchorY === b.anchorY && a.bottom === b.bottom;
5232
+ }
5233
+ }
5234
+ /**
5235
+ * Check if this rect equals with another rect.
5236
+ * @param other - The other rect.
5237
+ * @returns - True/false.
5238
+ */
5239
+ equals(other) {
5240
+ return _DivRect.equals(this, other);
5241
+ }
5242
+ /**
5243
+ * Check if edges of given rects are equal, ignoring anchorX and anchorY.
5244
+ *
5245
+ * @param a - DivRect a.
5246
+ * @param b - DivRect b.
5247
+ * @returns - True/false.
5248
+ */
5249
+ static equalsEdges(a, b) {
5250
+ if (a == null && b == null) {
5251
+ return true;
5252
+ } else if (a == null || b == null) {
5253
+ return false;
5254
+ } else {
5255
+ return a === b || a.left === b.left && a.right === b.right && a.top === b.top && a.bottom === b.bottom;
5256
+ }
5257
+ }
5258
+ /**
5259
+ * Check if edges of this Rect equals with given Rect, ignoring anchorX and anchorY.
5260
+ *
5261
+ * @param other - The other DivRect.
5262
+ * @returns - True/false.
5263
+ */
5264
+ equalsEdges(other) {
5265
+ return _DivRect.equalsEdges(this, other);
5266
+ }
5267
+ /**
5268
+ * @deprecated - Use {@link equalsEdges()} instead. Will be removed in v2.0.0.
5269
+ * @private
5270
+ */
5271
+ static equalsFrame(a, b) {
5272
+ return _DivRect.equalsEdges(a, b);
5273
+ }
5274
+ /**
5275
+ * @deprecated - Use {@link clone()} instead. Will be removed in v2.0.0.
5276
+ * @private
5277
+ */
5278
+ copy() {
5279
+ return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
5280
+ }
5281
+ /**
5282
+ * Created duplicate of this Rect.
5283
+ * @returns - Duplicate.
5284
+ */
5285
+ clone() {
5286
+ return new _DivRect(this.left, this.anchorX, this.right, this.top, this.anchorY, this.bottom);
5287
+ }
5288
+ /**
5289
+ * Move this rect by (dx, dy). Modifies this Rect.
5290
+ *
5291
+ * @param dx - Offset amount in x-direction.
5292
+ * @param dy - Offset amount in y-direction.
5293
+ * @returns - This DivRect instance.
5294
+ */
5295
+ offsetInPlace(dx, dy) {
5296
+ this.left += dx;
5297
+ this.anchorX += dx;
5298
+ this.right += dx;
5299
+ this.top += dy;
5300
+ this.anchorY += dy;
5301
+ this.bottom += dy;
5302
+ return this;
5303
+ }
5304
+ /**
5305
+ * Move this rect by (dx, dy). Immutable, returns modified copy.
5306
+ *
5307
+ * @param dx - Offset amount in x-direction.
5308
+ * @param dy - Offset amount in y-direction.
5309
+ * @returns - DivRect copy with applied offset.
5310
+ */
5311
+ offsetCopy(dx, dy) {
5312
+ return this.clone().offsetInPlace(dx, dy);
5313
+ }
5314
+ /**
5315
+ * Expand this Rect by given Rect. Modifies this Rect.
5316
+ *
5317
+ * @param rect - DivRect to expand this instance with.
5318
+ * @returns - This DivRect instance.
5319
+ */
5320
+ expandInPlace(rect) {
5321
+ this.left = Math.min(this.left, rect.left);
5322
+ this.right = Math.max(this.right, rect.right);
5323
+ this.top = Math.min(this.top, rect.top);
5324
+ this.bottom = Math.max(this.bottom, rect.bottom);
5325
+ return this;
5326
+ }
5327
+ /**
5328
+ * Expand this Rect by given Rect. Immutable, returns modified copy.
5329
+ *
5330
+ * @param rect - DivRect to expand this instance with.
5331
+ * @returns - Expanded copy of this DivRect.
5332
+ */
5333
+ expandCopy(rect) {
5334
+ return this.clone().expandInPlace(rect);
5335
+ }
5336
+ /**
5337
+ * Clip this Rect by given Rect. Mmodifies this Rect.
5338
+ *
5339
+ * @param clipRect - DivRect to clip this instance with.
5340
+ * @returns - This DivRect instance.
5341
+ */
5342
+ clipInPlace(clipRect) {
5343
+ this.left = Math.max(this.left, clipRect.left);
5344
+ this.right = Math.min(this.right, clipRect.right);
5345
+ this.anchorX = clamp(this.anchorX, this.left, this.right);
5346
+ this.top = Math.max(this.top, clipRect.top);
5347
+ this.bottom = Math.min(this.bottom, clipRect.bottom);
5348
+ this.anchorY = clamp(this.anchorY, this.top, this.bottom);
5349
+ return this;
5350
+ }
5351
+ /**
5352
+ * Clip this Rect by given Rect. Immutable, return modified copy.
5353
+ *
5354
+ * @param clipRect - DivRecto to clip this instance with.
5355
+ * @returns - Clipped DivRect copy.
5356
+ */
5357
+ clipCopy(clipRect) {
5358
+ return this.clone().clipInPlace(clipRect);
5359
+ }
5360
+ /**
5361
+ * Scale Rect. Anchor pos is (anchorX, anchorY). Modifies this Rect.
5362
+ *
5363
+ * @param scaleX - Scale x-amount.
5364
+ * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
5365
+ * @returns This DivRect instance.
5366
+ */
5367
+ scaleInPlace(scaleX, scaleY = scaleX) {
5368
+ this.left = this.anchorX - this.leftw * scaleX;
5369
+ this.right = this.anchorX + this.rightw * scaleX;
5370
+ this.top = this.anchorY - this.toph * scaleY;
5371
+ this.bottom = this.anchorY + this.bottomh * scaleY;
5372
+ return this;
5373
+ }
5374
+ /**
5375
+ * Scale Rect. Anchor pos is (anchorX, anchorY). Immutable, returns modified copy.
5376
+ *
5377
+ * @param scaleX - Scale x-amount.
5378
+ * @param scaleY - Scale y-amount. If undefined then scale x-amount is used.
5379
+ * @returns Scaled copy of this DivRect.
5380
+ */
5381
+ scaleCopy(scaleX, scaleY = scaleX) {
5382
+ return this.clone().scaleInPlace(scaleX, scaleY);
5383
+ }
5384
+ /**
5385
+ * Get this DivRect instance.
5386
+ * @returns - This DivRect instance.
5387
+ */
5388
+ getRect() {
5389
+ return this;
5390
+ }
5391
+ toRect() {
5392
+ return new Rect(this.left, this.right, this.width, this.height);
5393
+ }
5394
+ };
3708
5395
  export {
5396
+ AnchoredRect,
3709
5397
  assert_exports as Assert,
5398
+ BaseContainer,
5399
+ BiMap,
3710
5400
  cookies_exports as Cookies,
3711
5401
  DeepSet,
3712
5402
  DefaultArray,
5403
+ DefaultEqualityFn,
3713
5404
  device_exports as Device,
3714
5405
  DivRect,
3715
5406
  guard_exports as Guard,
3716
5407
  IndexArray,
3717
5408
  LRUCache,
5409
+ LinkedList,
3718
5410
  Map1,
3719
5411
  Map2,
3720
5412
  Map3,
3721
5413
  MultiContainer,
5414
+ Rect,
3722
5415
  Set1,
3723
5416
  SetBase,
3724
5417
  SignedIndexArray,
3725
5418
  SmallIntCache,
3726
5419
  Stack,
5420
+ TriMap,
5421
+ UniMap,
3727
5422
  utils_exports as Utils,
5423
+ ValueSet,
3728
5424
  Vec,
3729
5425
  Vec2,
3730
5426
  asMulti