@sanity/ui 3.0.0-static.25 → 3.0.0-static.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/_chunks-cjs/_visual-editing.cjs +197 -197
  2. package/dist/_chunks-cjs/_visual-editing.cjs.map +1 -1
  3. package/dist/_chunks-es/_visual-editing.js +199 -199
  4. package/dist/_chunks-es/_visual-editing.js.map +1 -1
  5. package/dist/_visual-editing.d.cts +1 -0
  6. package/dist/_visual-editing.d.ts +1 -0
  7. package/dist/css.cjs +1 -1
  8. package/dist/css.d.cts +1 -1
  9. package/dist/css.d.ts +1 -1
  10. package/dist/css.js +1 -1
  11. package/dist/index.cjs +141 -141
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +1 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +143 -143
  16. package/dist/index.js.map +1 -1
  17. package/dist/theme.cjs +2605 -1075
  18. package/dist/theme.cjs.map +1 -1
  19. package/dist/theme.d.cts +1 -1
  20. package/dist/theme.d.ts +1 -1
  21. package/dist/theme.js +2689 -1159
  22. package/dist/theme.js.map +1 -1
  23. package/dist/ui.css +1 -1
  24. package/exports/_visual-editing.ts +1 -1
  25. package/package.json +13 -26
  26. package/src/core/components/dialog/dialog.tsx +2 -9
  27. package/src/core/components/dialog/dialogCard.tsx +2 -1
  28. package/src/core/components/index.ts +1 -0
  29. package/src/core/components/menu/menu.tsx +1 -2
  30. package/src/core/components/toast/toastLayer.tsx +1 -2
  31. package/src/core/components/toast/toastProvider.tsx +1 -1
  32. package/src/core/{utils → components}/virtualList/__workshop__/index.ts +1 -1
  33. package/src/core/primitives/badge/badge.tsx +2 -1
  34. package/src/core/primitives/index.ts +3 -0
  35. package/src/core/{utils → primitives}/layer/__workshop__/index.ts +1 -1
  36. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +1 -0
  37. package/src/core/primitives/popover/popover.tsx +2 -1
  38. package/src/core/primitives/popover/popoverLayer.tsx +2 -1
  39. package/src/core/primitives/stack/stack.tsx +1 -0
  40. package/src/core/primitives/switch/switch.tsx +1 -1
  41. package/src/core/primitives/tooltip/tooltip.tsx +2 -1
  42. package/src/core/primitives/tooltip/tooltipLayer.tsx +2 -1
  43. package/src/core/utils/getElementRef.ts +1 -0
  44. package/src/core/utils/index.ts +0 -4
  45. package/src/css/primitives/avatar/avatar.css.ts +21 -4
  46. package/src/css/primitives/badge/badge.css.ts +2 -1
  47. package/src/css/primitives/label/label.css.ts +1 -0
  48. package/src/css/props/textOverflow/textOverflow.css.ts +2 -0
  49. package/src/css/props/width/types.ts +1 -1
  50. package/src/css/props/width/width.css.ts +3 -0
  51. package/src/theme/v2/build/buildTheme.test.ts +8 -8
  52. package/src/theme/v2/build/buildTheme.ts +32 -7
  53. /package/src/core/{utils → components}/virtualList/__workshop__/changingProps.tsx +0 -0
  54. /package/src/core/{utils → components}/virtualList/__workshop__/elementScroll.tsx +0 -0
  55. /package/src/core/{utils → components}/virtualList/__workshop__/infiniteList.tsx +0 -0
  56. /package/src/core/{utils → components}/virtualList/__workshop__/windowScrolll.tsx +0 -0
  57. /package/src/core/{utils → components}/virtualList/index.ts +0 -0
  58. /package/src/core/{utils → components}/virtualList/virtualList.tsx +0 -0
  59. /package/src/core/{utils → primitives}/arrow/arrow.tsx +0 -0
  60. /package/src/core/{utils → primitives}/arrow/cmds.ts +0 -0
  61. /package/src/core/{utils → primitives}/arrow/index.ts +0 -0
  62. /package/src/core/{utils → primitives}/layer/__workshop__/_debug.tsx +0 -0
  63. /package/src/core/{utils → primitives}/layer/__workshop__/multipleRoots.tsx +0 -0
  64. /package/src/core/{utils → primitives}/layer/__workshop__/nested.tsx +0 -0
  65. /package/src/core/{utils → primitives}/layer/__workshop__/responsiveZOffset.tsx +0 -0
  66. /package/src/core/{utils → primitives}/layer/getLayerContext.test.ts +0 -0
  67. /package/src/core/{utils → primitives}/layer/getLayerContext.ts +0 -0
  68. /package/src/core/{utils → primitives}/layer/index.ts +0 -0
  69. /package/src/core/{utils → primitives}/layer/layer.test.tsx +0 -0
  70. /package/src/core/{utils → primitives}/layer/layer.tsx +0 -0
  71. /package/src/core/{utils → primitives}/layer/layerCard.tsx +0 -0
  72. /package/src/core/{utils → primitives}/layer/layerContext.ts +0 -0
  73. /package/src/core/{utils → primitives}/layer/layerProvider.tsx +0 -0
  74. /package/src/core/{utils → primitives}/layer/types.ts +0 -0
  75. /package/src/core/{utils → primitives}/layer/useLayer.ts +0 -0
  76. /package/src/core/{utils → primitives}/srOnly/index.ts +0 -0
  77. /package/src/core/{utils → primitives}/srOnly/srOnly.tsx +0 -0
package/dist/theme.cjs CHANGED
@@ -121,6 +121,18 @@ const defaultThemeConfig = {
121
121
  width: 1
122
122
  }
123
123
  }
124
+ },
125
+ style: {
126
+ button: {
127
+ root: {
128
+ transition: "background-color 100ms,border-color 100ms,color 100ms"
129
+ }
130
+ }
131
+ // card: {
132
+ // root: {
133
+ // transition: 'background-color 100ms,border-color 100ms,color 100ms',
134
+ // },
135
+ // },
124
136
  }
125
137
  };
126
138
  function is_v2(themeProp) {
@@ -1708,494 +1720,437 @@ function _createColor(opts, dark, name) {
1708
1720
  muted
1709
1721
  };
1710
1722
  }
1711
- const AVATAR_SIZE = [0, 1, 2, 3], CONTAINER_SCALE = [0, 1, 2, 3, 4, 5], CONTAINER = [...CONTAINER_SCALE, "auto"], RADIUS = [0, 1, 2, 3, 4, 5, 6], SPACE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], FONT_CODE_SIZE = [0, 1, 2, 3, 4], FONT_HEADING_SIZE = [0, 1, 2, 3, 4, 5], FONT_LABEL_SIZE = [0, 1, 2, 3, 4, 5], FONT_TEXT_SIZE = [0, 1, 2, 3, 4], SHADOW = [0, 1, 2, 3, 4, 5], HUES = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], TINTS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], RE_PERCENTAGE = /^([0-9]+)%/, RE_OPACITY = /^(1|0\.[0-9]+)?/;
1712
- function _parseColorToken(str, options) {
1713
- const {
1714
- defaultHue
1715
- } = options;
1716
- let cursor = 0;
1717
- return parseColorNode();
1718
- function _consume(s) {
1719
- if (str.startsWith(s, cursor))
1720
- return cursor += s.length, s;
1721
- }
1722
- function _peek() {
1723
- return str[cursor];
1724
- }
1725
- function parseColorNode() {
1726
- ignoreWhitespace();
1727
- let v = _consume("black") || _consume("white");
1728
- if (v)
1729
- return {
1730
- type: "color",
1731
- name: v,
1732
- opacity: parseOpacity() ?? 1,
1733
- mix: parseMix() ?? 1
1734
- };
1735
- for (const hue of HUES)
1736
- if (v = _consume(String(hue)), v) {
1737
- if (_peek() !== "-")
1738
- throw new Error('Expected "-" after hue key');
1739
- cursor += 1;
1740
- const tint2 = parseTint();
1741
- if (!tint2)
1742
- throw new Error("Expected tint after hue");
1743
- return {
1744
- type: "tint",
1745
- hue,
1746
- tint: tint2,
1747
- opacity: parseOpacity() ?? 1,
1748
- mix: parseMix() ?? 1
1749
- };
1750
- }
1751
- const tint = parseTint();
1752
- if (tint)
1753
- return {
1754
- type: "tint",
1755
- hue: defaultHue,
1756
- tint,
1757
- opacity: parseOpacity() ?? 1,
1758
- mix: parseMix() ?? 1
1759
- };
1760
- if (str === "inherit")
1761
- return {
1762
- type: "inherit"
1763
- };
1764
- throw new Error(`Invalid color: ${str}`);
1765
- }
1766
- function parseTint() {
1767
- ignoreWhitespace();
1768
- let v = Number(str.slice(cursor, cursor + 3));
1769
- if (TINTS.includes(v))
1770
- return cursor += 3, v;
1771
- if (v = Number(str.slice(cursor, cursor + 2)), TINTS.includes(v))
1772
- return cursor += 2, v;
1773
- }
1774
- function parseMix() {
1775
- ignoreWhitespace();
1776
- const match = RE_PERCENTAGE.exec(str.slice(cursor));
1777
- if (match)
1778
- return cursor += match[0].length, parseFloat(match[1]) / 100;
1779
- }
1780
- function parseOpacity() {
1781
- if (ignoreWhitespace(), _peek() === "/") {
1782
- cursor += 1;
1783
- const match = RE_OPACITY.exec(str.slice(cursor));
1784
- if (match)
1785
- return cursor += match[0].length, parseFloat(match[1]);
1786
- cursor -= 1;
1787
- }
1788
- }
1789
- function ignoreWhitespace() {
1790
- for (; _peek() === " "; )
1791
- cursor++;
1792
- }
1793
- }
1794
- const defaultThemeFonts = {
1723
+ const defaultThemeFonts$1 = {
1795
1724
  code: {
1796
1725
  family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
1797
- weight: {
1726
+ weights: {
1798
1727
  regular: 400,
1799
1728
  medium: 500,
1800
1729
  semibold: 600,
1801
1730
  bold: 700
1802
1731
  },
1803
- scale: [{
1732
+ sizes: [{
1804
1733
  ascenderHeight: 4,
1805
1734
  descenderHeight: 4,
1806
1735
  fontSize: 10,
1807
1736
  iconSize: 17,
1808
1737
  lineHeight: 15,
1809
- letterSpacing: 0,
1810
- customIconSize: 12
1738
+ letterSpacing: 0
1811
1739
  }, {
1812
1740
  ascenderHeight: 5,
1813
1741
  descenderHeight: 5,
1814
1742
  fontSize: 13,
1815
1743
  iconSize: 21,
1816
1744
  lineHeight: 19,
1817
- letterSpacing: 0,
1818
- customIconSize: 16
1745
+ letterSpacing: 0
1819
1746
  }, {
1820
1747
  ascenderHeight: 6,
1821
1748
  descenderHeight: 6,
1822
1749
  fontSize: 16,
1823
1750
  iconSize: 25,
1824
1751
  lineHeight: 23,
1825
- letterSpacing: 0,
1826
- customIconSize: 20
1752
+ letterSpacing: 0
1827
1753
  }, {
1828
1754
  ascenderHeight: 7,
1829
1755
  descenderHeight: 7,
1830
1756
  fontSize: 19,
1831
1757
  iconSize: 29,
1832
1758
  lineHeight: 27,
1833
- letterSpacing: 0,
1834
- customIconSize: 24
1759
+ letterSpacing: 0
1835
1760
  }, {
1836
1761
  ascenderHeight: 8,
1837
1762
  descenderHeight: 8,
1838
1763
  fontSize: 22,
1839
1764
  iconSize: 33,
1840
1765
  lineHeight: 31,
1841
- letterSpacing: 0,
1842
- customIconSize: 28
1766
+ letterSpacing: 0
1843
1767
  }]
1844
1768
  },
1845
1769
  heading: {
1846
1770
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1847
- featureSettings: "'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'zero' 1",
1848
- weight: {
1771
+ weights: {
1849
1772
  regular: 600,
1850
1773
  medium: 700,
1851
1774
  semibold: 800,
1852
1775
  bold: 900
1853
1776
  },
1854
- scale: [{
1777
+ sizes: [{
1855
1778
  ascenderHeight: 5,
1856
1779
  descenderHeight: 5,
1857
1780
  fontSize: 13,
1858
1781
  iconSize: 17,
1859
1782
  lineHeight: 19,
1860
- letterSpacing: 0,
1861
- customIconSize: 12
1783
+ letterSpacing: 0
1862
1784
  }, {
1863
1785
  ascenderHeight: 6,
1864
1786
  descenderHeight: 6,
1865
1787
  fontSize: 16,
1866
1788
  iconSize: 25,
1867
1789
  lineHeight: 23,
1868
- letterSpacing: 0,
1869
- customIconSize: 20
1790
+ letterSpacing: 0
1870
1791
  }, {
1871
1792
  ascenderHeight: 7,
1872
1793
  descenderHeight: 7,
1873
1794
  fontSize: 21,
1874
1795
  iconSize: 33,
1875
1796
  lineHeight: 29,
1876
- letterSpacing: -0.25,
1877
- customIconSize: 28
1797
+ letterSpacing: -0.25
1878
1798
  }, {
1879
1799
  ascenderHeight: 8,
1880
1800
  descenderHeight: 8,
1881
1801
  fontSize: 27,
1882
1802
  iconSize: 41,
1883
1803
  lineHeight: 35,
1884
- letterSpacing: -0.5,
1885
- customIconSize: 36
1804
+ letterSpacing: -0.5
1886
1805
  }, {
1887
1806
  ascenderHeight: 9.5,
1888
1807
  descenderHeight: 8.5,
1889
1808
  fontSize: 33,
1890
1809
  iconSize: 49,
1891
1810
  lineHeight: 41,
1892
- letterSpacing: -1,
1893
- customIconSize: 44
1811
+ letterSpacing: -1
1894
1812
  }, {
1895
1813
  ascenderHeight: 10.5,
1896
1814
  descenderHeight: 9.5,
1897
1815
  fontSize: 38,
1898
1816
  iconSize: 53,
1899
1817
  lineHeight: 47,
1900
- letterSpacing: -1,
1901
- customIconSize: 48
1818
+ letterSpacing: -1
1902
1819
  }]
1903
1820
  },
1904
1821
  label: {
1905
1822
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
1906
- weight: {
1823
+ weights: {
1907
1824
  regular: 500,
1908
1825
  medium: 600,
1909
1826
  semibold: 700,
1910
1827
  bold: 800
1911
1828
  },
1912
- scale: [{
1829
+ sizes: [{
1913
1830
  ascenderHeight: 2,
1914
1831
  descenderHeight: 2,
1915
1832
  fontSize: 8.1,
1916
1833
  iconSize: 13,
1917
1834
  lineHeight: 10,
1918
- letterSpacing: 0.5,
1919
- customIconSize: 8
1835
+ letterSpacing: 0.5
1920
1836
  }, {
1921
1837
  ascenderHeight: 1.5,
1922
1838
  descenderHeight: 2.5,
1923
1839
  fontSize: 9.5,
1924
1840
  iconSize: 15,
1925
1841
  lineHeight: 11,
1926
- letterSpacing: 0.5,
1927
- customIconSize: 10
1842
+ letterSpacing: 0.5
1928
1843
  }, {
1929
1844
  ascenderHeight: 2,
1930
1845
  descenderHeight: 2,
1931
1846
  fontSize: 10.8,
1932
1847
  iconSize: 17,
1933
1848
  lineHeight: 12,
1934
- letterSpacing: 0.5,
1935
- customIconSize: 12
1849
+ letterSpacing: 0.5
1936
1850
  }, {
1937
1851
  ascenderHeight: 2,
1938
1852
  descenderHeight: 2,
1939
1853
  fontSize: 12.25,
1940
1854
  iconSize: 19,
1941
1855
  lineHeight: 13,
1942
- letterSpacing: 0.5,
1943
- customIconSize: 14
1856
+ letterSpacing: 0.5
1944
1857
  }, {
1945
1858
  ascenderHeight: 1.5,
1946
1859
  descenderHeight: 2.5,
1947
1860
  fontSize: 13.6,
1948
1861
  iconSize: 21,
1949
1862
  lineHeight: 14,
1950
- letterSpacing: 0.5,
1951
- customIconSize: 16
1863
+ letterSpacing: 0.5
1952
1864
  }, {
1953
1865
  ascenderHeight: 2,
1954
1866
  descenderHeight: 2,
1955
1867
  fontSize: 15,
1956
1868
  iconSize: 23,
1957
1869
  lineHeight: 15,
1958
- letterSpacing: 0.5,
1959
- customIconSize: 18
1870
+ letterSpacing: 0.5
1960
1871
  }]
1961
1872
  },
1962
1873
  text: {
1963
1874
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1964
- weight: {
1875
+ weights: {
1965
1876
  regular: 400,
1966
1877
  medium: 500,
1967
1878
  semibold: 600,
1968
1879
  bold: 700
1969
1880
  },
1970
- scale: [{
1881
+ sizes: [{
1971
1882
  ascenderHeight: 4,
1972
1883
  descenderHeight: 4,
1973
1884
  fontSize: 10,
1974
1885
  iconSize: 17,
1975
1886
  lineHeight: 15,
1976
- letterSpacing: 0,
1977
- customIconSize: 12
1887
+ letterSpacing: 0
1978
1888
  }, {
1979
1889
  ascenderHeight: 5,
1980
1890
  descenderHeight: 5,
1981
1891
  fontSize: 13,
1982
1892
  iconSize: 21,
1983
1893
  lineHeight: 19,
1984
- letterSpacing: 0,
1985
- customIconSize: 16
1894
+ letterSpacing: 0
1986
1895
  }, {
1987
1896
  ascenderHeight: 6,
1988
1897
  descenderHeight: 6,
1989
1898
  fontSize: 15,
1990
1899
  iconSize: 25,
1991
1900
  lineHeight: 23,
1992
- letterSpacing: 0,
1993
- customIconSize: 20
1901
+ letterSpacing: 0
1994
1902
  }, {
1995
1903
  ascenderHeight: 7,
1996
1904
  descenderHeight: 7,
1997
1905
  fontSize: 18,
1998
1906
  iconSize: 29,
1999
1907
  lineHeight: 27,
2000
- letterSpacing: 0,
2001
- customIconSize: 24
1908
+ letterSpacing: 0
2002
1909
  }, {
2003
1910
  ascenderHeight: 8,
2004
1911
  descenderHeight: 8,
2005
1912
  fontSize: 21,
2006
1913
  iconSize: 33,
2007
1914
  lineHeight: 31,
2008
- letterSpacing: 0,
2009
- customIconSize: 28
1915
+ letterSpacing: 0
2010
1916
  }]
2011
1917
  }
2012
- }, defaultTokens = {
2013
- color: {
2014
- "*": {
2015
- backdrop: ["gray-100/0.5", "black/0.5"],
2016
- code: {
2017
- bg: ["50", "950"],
2018
- fg: ["700", "300"],
2019
- token: {
2020
- atrule: ["purple-600", "purple-400"],
2021
- attrName: ["green-600", "green-400"],
2022
- attrValue: ["yellow-600", "yellow-400"],
2023
- attribute: ["yellow-600", "yellow-400"],
2024
- boolean: ["purple-600", "purple-400"],
2025
- builtin: ["purple-600", "purple-400"],
2026
- cdata: ["yellow-600", "yellow-400"],
2027
- char: ["yellow-600", "yellow-400"],
2028
- class: ["orange-600", "orange-400"],
2029
- className: ["cyan-600", "cyan-400"],
2030
- comment: ["gray-400", "gray-600"],
2031
- constant: ["purple-600", "purple-400"],
2032
- deleted: ["red-600", "red-400"],
2033
- entity: ["red-600", "red-400"],
2034
- function: ["green-600", "green-400"],
2035
- hexcode: ["blue-600", "blue-400"],
2036
- id: ["purple-600", "purple-400"],
2037
- important: ["purple-600", "purple-400"],
2038
- inserted: ["green-600", "green-400"],
2039
- keyword: ["magenta-600", "magenta-400"],
2040
- number: ["purple-600", "purple-400"],
2041
- operator: ["magenta-600", "magenta-400"],
2042
- prolog: ["gray-600", "gray-400"],
2043
- property: ["blue-600", "blue-400"],
2044
- pseudoClass: ["yellow-600", "yellow-400"],
2045
- pseudoElement: ["yellow-600", "yellow-400"],
2046
- punctuation: ["gray-600", "gray-400"],
2047
- regex: ["blue-600", "blue-400"],
2048
- selector: ["red-600", "red-400"],
2049
- string: ["yellow-600", "yellow-400"],
2050
- symbol: ["purple-600", "purple-400"],
2051
- tag: ["red-600", "red-400"],
2052
- unit: ["orange-600", "orange-400"],
2053
- url: ["red-600", "red-400"],
2054
- variable: ["red-600", "red-400"]
2055
- }
2056
- },
2057
- focusRing: ["blue-500", "blue-500"],
2058
- link: {
2059
- fg: ["blue-600", "blue-400"]
2060
- },
2061
- shadow: {
2062
- outline: ["600/0.3", "500/0.4"],
2063
- umbra: ["600/0.1", "black/0.2"],
2064
- penumbra: ["600/0.07", "black/0.14"],
2065
- ambient: ["600/0.06", "black/0.12"]
2066
- },
2067
- skeleton: {
2068
- from: ["200 70%", "800 35%"],
2069
- to: ["200 40%", "800 50%"]
2070
- },
2071
- variant: {
2072
- tinted: {
2073
- "*": {
2074
- bg: {
2075
- 0: ["100 75%", "900 75%"],
2076
- 4: ["300", "700"]
2077
- },
2078
- border: {
2079
- 0: ["200", "700 50%"],
2080
- 4: ["300 75%", "500"]
2081
- },
2082
- fg: {
2083
- 0: ["900", "100"],
2084
- 4: ["700", "300"]
2085
- }
2086
- },
2087
- primary: {
2088
- _hue: "blue",
2089
- bg: {
2090
- 0: ["inherit", "inherit"]
2091
- }
2092
- },
2093
- suggest: {
2094
- _hue: "purple",
2095
- bg: {
2096
- 0: ["inherit", "inherit"]
2097
- }
2098
- },
2099
- positive: {
2100
- _hue: "green",
2101
- bg: {
2102
- 0: ["inherit", "inherit"]
2103
- }
2104
- },
2105
- caution: {
2106
- _hue: "yellow",
2107
- bg: {
2108
- 0: ["inherit", "inherit"]
2109
- }
2110
- },
2111
- critical: {
2112
- _hue: "red",
2113
- bg: {
2114
- 0: ["inherit", "inherit"]
2115
- }
2116
- }
2117
- },
2118
- solid: {
2119
- "*": {
2120
- bg: {
2121
- 0: ["500", "400"],
2122
- 4: ["600", "300"]
2123
- },
2124
- border: {
2125
- 0: ["400", "200"],
2126
- 4: ["500", "100"]
2127
- },
2128
- fg: {
2129
- 0: ["white", "black"],
2130
- 4: ["200", "700"]
2131
- }
2132
- },
2133
- default: {
2134
- bg: {
2135
- 0: ["800", "200"],
2136
- 4: ["black", "white"]
2137
- },
2138
- border: {
2139
- 0: ["700", "300"],
2140
- 4: ["800", "200"]
2141
- }
2142
- },
2143
- primary: {
2144
- _hue: "blue"
2145
- },
2146
- suggest: {
2147
- _hue: "purple"
2148
- },
2149
- positive: {
2150
- _hue: "green"
2151
- },
2152
- caution: {
2153
- _hue: "yellow"
2154
- },
2155
- critical: {
2156
- _hue: "red"
2157
- }
1918
+ }, THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
1919
+ "transparent",
1920
+ "default",
1921
+ "neutral",
1922
+ "primary",
1923
+ // deprecated
1924
+ "suggest",
1925
+ "positive",
1926
+ "caution",
1927
+ "critical"
1928
+ ], THEME_COLOR_STATE_TONES = [
1929
+ "default",
1930
+ "neutral",
1931
+ "primary",
1932
+ // deprecated
1933
+ "suggest",
1934
+ "positive",
1935
+ "caution",
1936
+ "critical"
1937
+ ], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = color.COLOR_HUES;
1938
+ function isColorBlendModeValue(str) {
1939
+ return THEME_COLOR_BLEND_MODES.includes(str);
1940
+ }
1941
+ function isColorHueKey(str) {
1942
+ return color.COLOR_HUES.includes(str);
1943
+ }
1944
+ function isColorTintKey(str) {
1945
+ return color.COLOR_TINTS.includes(str);
1946
+ }
1947
+ function isColorButtonMode(str) {
1948
+ return THEME_COLOR_BUTTON_MODES.includes(str);
1949
+ }
1950
+ const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "accent/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to", "status/dot", "status/icon"], COLOR_CONFIG_CARD_KEYS = [...COLOR_CONFIG_STATE_KEYS, "_hue", "bg", "fg", "border", "focusRing", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient"], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
1951
+ function isColorConfigBaseTone(str) {
1952
+ return COLOR_CONFIG_CARD_TONES.includes(str);
1953
+ }
1954
+ function isColorConfigBaseKey(str) {
1955
+ return COLOR_CONFIG_CARD_KEYS.includes(str);
1956
+ }
1957
+ function isColorConfigStateKey(str) {
1958
+ return COLOR_CONFIG_STATE_KEYS.includes(str);
1959
+ }
1960
+ function isColorConfigStateTone(str) {
1961
+ return COLOR_CONFIG_STATE_TONES.includes(str);
1962
+ }
1963
+ function isColorConfigBlendKey(str) {
1964
+ return COLOR_CONFIG_BLEND_KEYS.includes(str);
1965
+ }
1966
+ function isColorValue(str) {
1967
+ return str === "black" || str === "white";
1968
+ }
1969
+ function isColorOpacityValue(str) {
1970
+ return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
1971
+ }
1972
+ function isColorMixPercentValue(str) {
1973
+ return /^\d+%$/.test(str);
1974
+ }
1975
+ function parseTokenValue(str) {
1976
+ const segments = str.split("/");
1977
+ let nextSegment = segments.shift() || "";
1978
+ const [segment0, segment0mix] = nextSegment.split(" ");
1979
+ if (isColorTintKey(segment0)) {
1980
+ const tint = segment0, segment1 = segments.shift() || "";
1981
+ if (isColorMixPercentValue(segment0mix)) {
1982
+ const mix2 = Number(segment0mix.slice(0, -1)) / 100;
1983
+ return {
1984
+ type: "color",
1985
+ tint,
1986
+ mix: mix2
1987
+ };
1988
+ }
1989
+ if (isColorOpacityValue(segment1)) {
1990
+ const opacity = Number(segment1);
1991
+ return {
1992
+ type: "color",
1993
+ tint,
1994
+ opacity
1995
+ };
1996
+ }
1997
+ return {
1998
+ type: "color",
1999
+ tint
2000
+ };
2001
+ }
2002
+ if (isColorValue(segment0)) {
2003
+ const key = segment0, segment1 = segments.shift() || "";
2004
+ if (isColorMixPercentValue(segment0mix)) {
2005
+ const mix2 = Number(segment0mix.slice(0, -1)) / 100;
2006
+ return {
2007
+ type: "color",
2008
+ key,
2009
+ mix: mix2
2010
+ };
2011
+ }
2012
+ if (isColorOpacityValue(segment1)) {
2013
+ const opacity = Number(segment1);
2014
+ return {
2015
+ type: "color",
2016
+ key,
2017
+ opacity
2018
+ };
2019
+ }
2020
+ return {
2021
+ type: "color",
2022
+ key
2023
+ };
2024
+ }
2025
+ if (isColorHueKey(segment0)) {
2026
+ const hue = segment0;
2027
+ nextSegment = segments.shift() || "";
2028
+ const [segment1, segment1mix] = nextSegment.split(" ");
2029
+ if (isColorTintKey(segment1)) {
2030
+ const tint = segment1, segment2 = segments.shift() || "";
2031
+ if (isColorMixPercentValue(segment1mix)) {
2032
+ const mix2 = Number(segment1mix.slice(0, -1)) / 100;
2033
+ return {
2034
+ type: "color",
2035
+ hue,
2036
+ tint,
2037
+ mix: mix2
2038
+ };
2039
+ }
2040
+ if (isColorOpacityValue(segment2)) {
2041
+ const opacity = Number(segment2);
2042
+ return {
2043
+ type: "color",
2044
+ hue,
2045
+ tint,
2046
+ opacity
2047
+ };
2048
+ }
2049
+ return {
2050
+ type: "color",
2051
+ hue,
2052
+ tint
2053
+ };
2054
+ }
2055
+ return {
2056
+ type: "hue",
2057
+ value: hue
2058
+ };
2059
+ }
2060
+ if (isColorBlendModeValue(segment0))
2061
+ return {
2062
+ type: "blendMode",
2063
+ value: segment0
2064
+ };
2065
+ }
2066
+ function compileColorTokenValue(node) {
2067
+ let key = "";
2068
+ return node.key === "black" || node.key === "white" ? key = node.key : key = `${node.hue}/${node.tint}`, node.mix !== void 0 ? `${key} ${node.mix * 100}%` : (node.opacity !== void 0 && (key += `/${node.opacity}`), key);
2069
+ }
2070
+ const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
2071
+ function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
2072
+ const {
2073
+ hue,
2074
+ scheme
2075
+ } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
2076
+ if (!node || node.type !== "color")
2077
+ throw new Error(`Invalid color token: ${value[0]}`);
2078
+ return compileColorTokenValue({
2079
+ ...node,
2080
+ hue: node.hue || hue
2081
+ });
2082
+ }
2083
+ const defaultColorTokens = {
2084
+ base: {
2085
+ "*": {
2086
+ _blend: ["multiply", "screen"],
2087
+ accent: {
2088
+ fg: ["purple/600", "purple/400"]
2089
+ },
2090
+ avatar: {
2091
+ "*": {
2092
+ _blend: ["screen", "multiply"],
2093
+ bg: ["500", "400"],
2094
+ fg: ["white", "black"]
2095
+ }
2096
+ },
2097
+ backdrop: ["gray/200/0.5", "black/0.5"],
2098
+ badge: {
2099
+ "*": {
2100
+ bg: ["100", "900"],
2101
+ fg: ["600", "400"],
2102
+ icon: ["500", "500"],
2103
+ dot: ["500", "500"]
2104
+ },
2105
+ positive: {
2106
+ bg: ["200 50%", "900"],
2107
+ fg: ["600", "500"]
2108
+ },
2109
+ caution: {
2110
+ bg: ["200 50%", "900"],
2111
+ fg: ["600", "500"]
2158
2112
  }
2113
+ },
2114
+ bg: ["50", "950"],
2115
+ border: ["200", "800"],
2116
+ code: {
2117
+ bg: ["50", "950"],
2118
+ fg: ["600", "400"]
2119
+ },
2120
+ fg: ["800", "200"],
2121
+ focusRing: ["blue/500", "blue/500"],
2122
+ icon: ["600", "400"],
2123
+ kbd: {
2124
+ bg: ["white", "black"],
2125
+ fg: ["600", "400"],
2126
+ border: ["200", "800"]
2127
+ },
2128
+ link: {
2129
+ fg: ["blue/600", "blue/300"]
2130
+ },
2131
+ muted: {
2132
+ bg: ["50", "950"],
2133
+ fg: ["700 75%", "300 75%"]
2134
+ },
2135
+ shadow: {
2136
+ outline: ["500/0.3", "500/0.4"],
2137
+ umbra: ["gray/500/0.1", "black/0.2"],
2138
+ penumbra: ["gray/500/0.07", "black/0.14"],
2139
+ ambient: ["gray/500/0.06", "black/0.12"]
2140
+ },
2141
+ skeleton: {
2142
+ from: ["100", "900"],
2143
+ to: ["100 50%", "900 50%"]
2159
2144
  }
2160
2145
  },
2161
2146
  transparent: {
2162
- variant: {
2163
- tinted: {
2164
- "*": {
2165
- bg: {
2166
- 0: ["gray-50", "black"],
2167
- 4: ["200", "800"]
2168
- },
2169
- border: {
2170
- 0: ["200 50%", "800 50%"],
2171
- 4: ["300", "600"]
2172
- },
2173
- fg: {
2174
- 0: ["black", "100"],
2175
- 4: ["700", "400"]
2176
- }
2177
- }
2178
- }
2179
- }
2147
+ bg: ["50", "black"]
2180
2148
  },
2181
2149
  default: {
2182
- variant: {
2183
- tinted: {
2184
- "*": {
2185
- bg: {
2186
- 0: ["white", "950"],
2187
- 4: ["200", "800"]
2188
- },
2189
- border: {
2190
- 0: ["200 50%", "800 50%"],
2191
- 4: ["300 75%", "600"]
2192
- },
2193
- fg: {
2194
- 0: ["black", "white"],
2195
- 4: ["600", "400"]
2196
- }
2197
- }
2198
- }
2150
+ bg: ["white", "950"],
2151
+ fg: ["800", "200"],
2152
+ muted: {
2153
+ fg: ["600", "400"]
2199
2154
  }
2200
2155
  },
2201
2156
  primary: {
@@ -2205,707 +2160,1262 @@ const defaultThemeFonts = {
2205
2160
  _hue: "purple"
2206
2161
  },
2207
2162
  positive: {
2208
- _hue: "green"
2163
+ _hue: "green",
2164
+ shadow: {
2165
+ outline: ["500/0.4", "500/0.4"]
2166
+ }
2209
2167
  },
2210
2168
  caution: {
2211
- _hue: "yellow"
2169
+ _hue: "yellow",
2170
+ shadow: {
2171
+ outline: ["600/0.3", "500/0.4"]
2172
+ }
2212
2173
  },
2213
2174
  critical: {
2214
2175
  _hue: "red"
2215
2176
  }
2216
- }
2217
- };
2218
- function merge(...records) {
2219
- return records.filter(Boolean).reduce(_merge, {});
2220
- }
2221
- function _merge(acc, source) {
2222
- for (const key of Object.keys(source)) {
2223
- const prevValue = acc[key], nextValue = source[key];
2224
- isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
2225
- }
2226
- return acc;
2227
- }
2228
- function isRecord(value) {
2229
- return value !== null && typeof value == "object" && !Array.isArray(value);
2230
- }
2231
- const defaultElementTokens = {
2232
- bg: {
2233
- 0: ["950", "50"],
2234
- 4: ["700", "300"]
2235
- },
2236
- border: {
2237
- 0: ["700", "300"],
2238
- 4: ["400", "600"]
2239
2177
  },
2240
- fg: {
2241
- 0: ["100", "900"],
2242
- 4: ["400", "600"]
2243
- }
2244
- };
2245
- function resolveTokens(tokens = {}) {
2246
- return {
2247
- color: {
2248
- "*": resolveCardColorTokens(tokens.color?.["*"]),
2249
- ...THEME_COLOR_CARD_TONES.reduce((acc, tone) => ({
2250
- ...acc,
2251
- [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
2252
- }), {})
2253
- }
2254
- };
2255
- }
2256
- function resolveCardColorTokens(tokens) {
2257
- return {
2258
- _hue: tokens?._hue ?? "gray",
2259
- avatar: {
2260
- gray: {
2261
- _hue: tokens?.avatar?.gray?._hue ?? "gray",
2262
- bg: tokens?.avatar?.gray?.bg ?? ["500", "400"],
2263
- fg: tokens?.avatar?.gray?.fg ?? ["white", "900"]
2178
+ button: {
2179
+ default: {
2180
+ "*": {
2181
+ "*": {
2182
+ _blend: ["screen", "multiply"],
2183
+ accent: {
2184
+ fg: ["purple/300", "purple/700"]
2185
+ },
2186
+ avatar: {
2187
+ "*": {
2188
+ _blend: ["screen", "multiply"],
2189
+ bg: ["500", "400"],
2190
+ fg: ["white", "black"]
2191
+ }
2192
+ },
2193
+ badge: {
2194
+ "*": {
2195
+ bg: ["900", "100"],
2196
+ fg: ["400", "600"],
2197
+ dot: ["500", "500"],
2198
+ icon: ["500", "500"]
2199
+ }
2200
+ },
2201
+ bg: ["500", "400"],
2202
+ border: ["500/0", "400/0"],
2203
+ code: {
2204
+ bg: ["500 20%", "400 20%"],
2205
+ fg: ["200", "600"]
2206
+ },
2207
+ fg: ["white", "black"],
2208
+ icon: ["100 70%", "900 70%"],
2209
+ kbd: {
2210
+ bg: ["black", "white"],
2211
+ fg: ["200", "600"],
2212
+ border: ["800", "200"]
2213
+ },
2214
+ link: {
2215
+ fg: ["blue/200", "blue/600"]
2216
+ },
2217
+ muted: {
2218
+ bg: ["950", "50"],
2219
+ fg: ["100 70%", "900 70%"]
2220
+ },
2221
+ skeleton: {
2222
+ from: ["900", "100"],
2223
+ to: ["900 50%", "100 50%"]
2224
+ }
2225
+ },
2226
+ hovered: {
2227
+ bg: ["600", "300"],
2228
+ border: ["700/0", "300/0"]
2229
+ },
2230
+ pressed: {
2231
+ bg: ["700", "300"]
2232
+ },
2233
+ selected: {
2234
+ bg: ["700", "300"]
2235
+ },
2236
+ disabled: {
2237
+ _hue: "gray",
2238
+ accent: {
2239
+ fg: ["100 70%", "900 70%"]
2240
+ },
2241
+ avatar: {
2242
+ "*": {
2243
+ _blend: ["screen", "multiply"],
2244
+ bg: ["gray/500", "gray/400"],
2245
+ fg: ["white", "black"]
2246
+ }
2247
+ },
2248
+ badge: {
2249
+ "*": {
2250
+ bg: ["gray/700", "gray/300"],
2251
+ fg: ["white", "black"],
2252
+ dot: ["white", "black"],
2253
+ icon: ["white", "black"]
2254
+ }
2255
+ },
2256
+ bg: ["300", "600"],
2257
+ code: {
2258
+ bg: ["950", "50"],
2259
+ fg: ["300", "600"]
2260
+ },
2261
+ fg: ["300", "600"],
2262
+ muted: {
2263
+ bg: ["950", "50"],
2264
+ fg: ["300", "600"]
2265
+ },
2266
+ kbd: {
2267
+ bg: ["black", "white"],
2268
+ fg: ["white", "black"],
2269
+ border: ["700", "300"]
2270
+ },
2271
+ link: {
2272
+ fg: ["100 70%", "900 70%"]
2273
+ }
2274
+ }
2264
2275
  },
2265
- blue: {
2266
- _hue: tokens?.avatar?.blue?._hue ?? "blue",
2267
- bg: tokens?.avatar?.blue?.bg ?? ["500", "400"],
2268
- fg: tokens?.avatar?.blue?.fg ?? ["white", "900"]
2276
+ default: {
2277
+ "*": {
2278
+ avatar: {
2279
+ "*": {
2280
+ _blend: ["screen", "multiply"],
2281
+ bg: ["500", "400"],
2282
+ fg: ["white", "black"]
2283
+ }
2284
+ },
2285
+ bg: ["800", "200"],
2286
+ muted: {
2287
+ bg: ["950", "50"],
2288
+ fg: ["400", "600"]
2289
+ }
2290
+ },
2291
+ hovered: {
2292
+ bg: ["900", "100"]
2293
+ },
2294
+ pressed: {
2295
+ bg: ["black", "white"]
2296
+ },
2297
+ selected: {
2298
+ bg: ["black", "white"]
2299
+ }
2300
+ }
2301
+ },
2302
+ ghost: {
2303
+ "*": {
2304
+ "*": {
2305
+ _blend: ["multiply", "screen"],
2306
+ accent: {
2307
+ fg: ["purple/700 60%", "purple/300 70%"]
2308
+ },
2309
+ avatar: {
2310
+ "*": {
2311
+ _blend: ["screen", "multiply"],
2312
+ bg: ["500", "400"],
2313
+ fg: ["white", "black"]
2314
+ }
2315
+ },
2316
+ badge: {
2317
+ "*": {
2318
+ bg: ["100", "900"],
2319
+ fg: ["600", "400"],
2320
+ dot: ["500", "500"],
2321
+ icon: ["500", "500"]
2322
+ }
2323
+ },
2324
+ bg: ["50", "950"],
2325
+ border: ["100", "900"],
2326
+ code: {
2327
+ bg: ["500 10%", "400 10%"],
2328
+ fg: ["700 60%", "400 60%"]
2329
+ },
2330
+ fg: ["600", "400"],
2331
+ icon: ["700 60%", "300 60%"],
2332
+ kbd: {
2333
+ bg: ["white", "black"],
2334
+ fg: ["600", "400"],
2335
+ border: ["200", "800"]
2336
+ },
2337
+ link: {
2338
+ fg: ["blue/700 60%", "blue/300 60%"]
2339
+ },
2340
+ muted: {
2341
+ bg: ["100", "950"],
2342
+ fg: ["700 60%", "300 60%"]
2343
+ },
2344
+ skeleton: {
2345
+ from: ["100", "900"],
2346
+ to: ["100 50%", "900 50%"]
2347
+ }
2348
+ },
2349
+ hovered: {
2350
+ bg: ["100", "900"],
2351
+ fg: ["700", "300"]
2352
+ },
2353
+ pressed: {
2354
+ bg: ["200", "800"],
2355
+ fg: ["800", "200"]
2356
+ },
2357
+ selected: {
2358
+ bg: ["200", "800"],
2359
+ fg: ["800", "200"]
2360
+ },
2361
+ disabled: {
2362
+ _hue: "gray",
2363
+ accent: {
2364
+ fg: ["200", "800"]
2365
+ },
2366
+ avatar: {
2367
+ "*": {
2368
+ _blend: ["screen", "multiply"],
2369
+ bg: ["gray/100", "gray/900"],
2370
+ fg: ["white", "black"]
2371
+ }
2372
+ },
2373
+ badge: {
2374
+ "*": {
2375
+ _hue: "gray",
2376
+ bg: ["50", "950"],
2377
+ fg: ["gray/200", "gray/800"],
2378
+ dot: ["gray/200", "gray/800"],
2379
+ icon: ["gray/200", "gray/800"]
2380
+ }
2381
+ },
2382
+ border: ["100", "900"],
2383
+ code: {
2384
+ bg: ["50", "950"],
2385
+ fg: ["200", "800"]
2386
+ },
2387
+ fg: ["400", "600"],
2388
+ icon: ["300", "700"],
2389
+ muted: {
2390
+ fg: ["300", "700"]
2391
+ },
2392
+ kbd: {
2393
+ bg: ["white", "black"],
2394
+ fg: ["200", "800"],
2395
+ border: ["100", "900"]
2396
+ },
2397
+ link: {
2398
+ fg: ["200", "800"]
2399
+ }
2400
+ }
2269
2401
  },
2270
- purple: {
2271
- _hue: tokens?.avatar?.purple?._hue ?? "purple",
2272
- bg: tokens?.avatar?.purple?.bg ?? ["500", "400"],
2273
- fg: tokens?.avatar?.purple?.fg ?? ["white", "900"]
2402
+ positive: {
2403
+ "*": {
2404
+ border: ["600 20%", "800"]
2405
+ }
2274
2406
  },
2275
- magenta: {
2276
- _hue: tokens?.avatar?.magenta?._hue ?? "magenta",
2277
- bg: tokens?.avatar?.magenta?.bg ?? ["500", "400"],
2278
- fg: tokens?.avatar?.magenta?.fg ?? ["white", "900"]
2407
+ caution: {
2408
+ "*": {
2409
+ border: ["600 20%", "800"]
2410
+ }
2411
+ }
2412
+ },
2413
+ bleed: {
2414
+ "*": {
2415
+ "*": {
2416
+ _blend: ["multiply", "screen"],
2417
+ accent: {
2418
+ fg: ["purple/700 70%", "purple/300 70%"]
2419
+ },
2420
+ avatar: {
2421
+ "*": {
2422
+ _blend: ["screen", "multiply"],
2423
+ bg: ["500", "400"],
2424
+ fg: ["white", "black"]
2425
+ }
2426
+ },
2427
+ badge: {
2428
+ "*": {
2429
+ bg: ["100", "900"],
2430
+ fg: ["600", "400"],
2431
+ dot: ["500", "500"],
2432
+ icon: ["500", "500"]
2433
+ }
2434
+ },
2435
+ bg: ["white", "black"],
2436
+ border: ["white/0", "black/0"],
2437
+ code: {
2438
+ bg: ["50", "950"],
2439
+ fg: ["700 75%", "300 75%"]
2440
+ },
2441
+ fg: ["700", "300"],
2442
+ icon: ["700 75%", "300 75%"],
2443
+ kbd: {
2444
+ bg: ["white", "black"],
2445
+ fg: ["700", "300"],
2446
+ border: ["200", "800"]
2447
+ },
2448
+ link: {
2449
+ fg: ["blue/700 70%", "blue/300 70%"]
2450
+ },
2451
+ muted: {
2452
+ bg: ["100", "950"],
2453
+ fg: ["700 75%", "300 75%"]
2454
+ },
2455
+ skeleton: {
2456
+ from: ["100", "900"],
2457
+ to: ["100 50%", "900 50%"]
2458
+ }
2459
+ },
2460
+ hovered: {
2461
+ bg: ["50", "900"],
2462
+ fg: ["800", "200"],
2463
+ icon: ["800 70%", "300 70%"]
2464
+ },
2465
+ pressed: {
2466
+ bg: ["100", "800"],
2467
+ fg: ["800", "200"],
2468
+ icon: ["800 70%", "200 70%"]
2469
+ },
2470
+ selected: {
2471
+ bg: ["100", "900"],
2472
+ fg: ["800", "200"],
2473
+ icon: ["800 60%", "200 60%"]
2474
+ },
2475
+ disabled: {
2476
+ _hue: "gray",
2477
+ accent: {
2478
+ fg: ["200", "800"]
2479
+ },
2480
+ avatar: {
2481
+ "*": {
2482
+ _blend: ["screen", "multiply"],
2483
+ bg: ["gray/100", "gray/900"],
2484
+ fg: ["white", "black"]
2485
+ }
2486
+ },
2487
+ badge: {
2488
+ "*": {
2489
+ _hue: "gray",
2490
+ bg: ["50", "950"],
2491
+ fg: ["gray/200", "gray/800"],
2492
+ dot: ["gray/200", "gray/800"],
2493
+ icon: ["gray/200", "gray/800"]
2494
+ }
2495
+ },
2496
+ code: {
2497
+ bg: ["50", "950"],
2498
+ fg: ["200", "800"]
2499
+ },
2500
+ fg: ["400", "600"],
2501
+ icon: ["300", "700"],
2502
+ muted: {
2503
+ fg: ["400", "600"]
2504
+ },
2505
+ kbd: {
2506
+ bg: ["white", "black"],
2507
+ fg: ["200", "800"],
2508
+ border: ["100", "900"]
2509
+ },
2510
+ link: {
2511
+ fg: ["200", "800"]
2512
+ }
2513
+ }
2514
+ }
2515
+ }
2516
+ },
2517
+ input: {
2518
+ "*": {
2519
+ "*": {
2520
+ _blend: ["multiply", "screen"],
2521
+ bg: ["white", "black"],
2522
+ border: ["200", "700"],
2523
+ fg: ["black", "200"],
2524
+ muted: {
2525
+ bg: ["50", "950"]
2526
+ },
2527
+ placeholder: ["400", "600"]
2279
2528
  },
2280
- red: {
2281
- _hue: tokens?.avatar?.red?._hue ?? "red",
2282
- bg: tokens?.avatar?.red?.bg ?? ["500", "400"],
2283
- fg: tokens?.avatar?.red?.fg ?? ["white", "900"]
2529
+ hovered: {
2530
+ border: ["300", "700"]
2284
2531
  },
2285
- orange: {
2286
- _hue: tokens?.avatar?.orange?._hue ?? "orange",
2287
- bg: tokens?.avatar?.orange?.bg ?? ["500", "400"],
2288
- fg: tokens?.avatar?.orange?.fg ?? ["white", "900"]
2532
+ readOnly: {
2533
+ bg: ["50", "950"],
2534
+ border: ["200", "800"],
2535
+ fg: ["800", "200"]
2289
2536
  },
2290
- yellow: {
2291
- _hue: tokens?.avatar?.yellow?._hue ?? "yellow",
2292
- bg: tokens?.avatar?.yellow?.bg ?? ["500", "400"],
2293
- fg: tokens?.avatar?.yellow?.fg ?? ["white", "900"]
2537
+ disabled: {
2538
+ bg: ["50", "950"],
2539
+ fg: ["400", "600"],
2540
+ border: ["100", "900"],
2541
+ placeholder: ["200", "800 50%"]
2542
+ }
2543
+ },
2544
+ invalid: {
2545
+ "*": {
2546
+ _hue: "red",
2547
+ bg: ["100", "950"]
2548
+ }
2549
+ }
2550
+ },
2551
+ selectable: {
2552
+ "*": {
2553
+ "*": {
2554
+ _blend: ["multiply", "screen"],
2555
+ accent: {
2556
+ fg: ["purple/700 70%", "purple/300 70%"]
2557
+ },
2558
+ avatar: {
2559
+ "*": {
2560
+ _blend: ["screen", "multiply"],
2561
+ bg: ["500", "400"],
2562
+ fg: ["white", "black"]
2563
+ }
2564
+ },
2565
+ badge: {
2566
+ "*": {
2567
+ bg: ["100", "900"],
2568
+ fg: ["600", "400"],
2569
+ dot: ["500", "500"],
2570
+ icon: ["500", "500"]
2571
+ }
2572
+ },
2573
+ bg: ["white", "black"],
2574
+ border: ["200", "800"],
2575
+ code: {
2576
+ bg: ["50", "950"],
2577
+ fg: ["600", "400"]
2578
+ },
2579
+ fg: ["700", "300"],
2580
+ icon: ["700 75%", "300 75%"],
2581
+ kbd: {
2582
+ bg: ["white", "black"],
2583
+ fg: ["600", "400"],
2584
+ border: ["200", "800"]
2585
+ },
2586
+ link: {
2587
+ fg: ["blue/700 70%", "blue/300 70%"]
2588
+ },
2589
+ muted: {
2590
+ bg: ["50", "950"],
2591
+ fg: ["700 75%", "300 75%"]
2592
+ },
2593
+ skeleton: {
2594
+ from: ["100", "900"],
2595
+ to: ["100 50%", "900 50%"]
2596
+ }
2294
2597
  },
2295
- green: {
2296
- _hue: tokens?.avatar?.green?._hue ?? "green",
2297
- bg: tokens?.avatar?.green?.bg ?? ["500", "400"],
2298
- fg: tokens?.avatar?.green?.fg ?? ["white", "900"]
2598
+ hovered: {
2599
+ bg: ["50", "950"]
2299
2600
  },
2300
- cyan: {
2301
- _hue: tokens?.avatar?.cyan?._hue ?? "cyan",
2302
- bg: tokens?.avatar?.cyan?.bg ?? ["500", "400"],
2303
- fg: tokens?.avatar?.cyan?.fg ?? ["white", "900"]
2601
+ pressed: {
2602
+ bg: ["100", "900"]
2603
+ },
2604
+ selected: {
2605
+ _blend: ["screen", "multiply"],
2606
+ accent: {
2607
+ fg: ["purple/300", "purple/700"]
2608
+ },
2609
+ avatar: {
2610
+ "*": {
2611
+ _blend: ["multiply", "screen"],
2612
+ bg: ["white", "black"],
2613
+ fg: ["black", "white"]
2614
+ }
2615
+ },
2616
+ badge: {
2617
+ "*": {
2618
+ bg: ["900", "100"],
2619
+ fg: ["400", "600"],
2620
+ dot: ["500", "500"],
2621
+ icon: ["500", "500"]
2622
+ }
2623
+ },
2624
+ bg: ["500", "400"],
2625
+ border: ["500 20%", "400 20%"],
2626
+ code: {
2627
+ bg: ["500 20%", "400 20%"],
2628
+ fg: ["200", "600"]
2629
+ },
2630
+ fg: ["white", "black"],
2631
+ icon: ["100 70%", "900 70%"],
2632
+ kbd: {
2633
+ bg: ["black", "white"],
2634
+ fg: ["200", "600"],
2635
+ border: ["800", "200"]
2636
+ },
2637
+ link: {
2638
+ fg: ["blue/200", "blue/600"]
2639
+ },
2640
+ muted: {
2641
+ bg: ["500 10%", "400 10%"],
2642
+ fg: ["100 70%", "900 70%"]
2643
+ },
2644
+ skeleton: {
2645
+ from: ["900", "100"],
2646
+ to: ["900 50%", "100 50%"]
2647
+ }
2648
+ },
2649
+ disabled: {
2650
+ _hue: "gray",
2651
+ accent: {
2652
+ fg: ["200", "800"]
2653
+ },
2654
+ avatar: {
2655
+ "*": {
2656
+ _blend: ["screen", "multiply"],
2657
+ bg: ["gray/100", "gray/900"],
2658
+ fg: ["white", "black"]
2659
+ }
2660
+ },
2661
+ badge: {
2662
+ "*": {
2663
+ _hue: "gray",
2664
+ bg: ["50", "950"],
2665
+ fg: ["gray/200", "gray/800"],
2666
+ dot: ["gray/200", "gray/800"],
2667
+ icon: ["gray/200", "gray/800"]
2668
+ }
2669
+ },
2670
+ border: ["100", "900"],
2671
+ code: {
2672
+ bg: ["50", "950"],
2673
+ fg: ["200", "800"]
2674
+ },
2675
+ fg: ["200", "800"],
2676
+ icon: ["200", "800"],
2677
+ kbd: {
2678
+ bg: ["white", "black"],
2679
+ fg: ["200", "800"],
2680
+ border: ["100", "900"]
2681
+ },
2682
+ link: {
2683
+ fg: ["200", "800"]
2684
+ },
2685
+ muted: {
2686
+ bg: ["50 50%", "950 50%"],
2687
+ fg: ["200", "800"]
2688
+ }
2304
2689
  }
2305
2690
  },
2306
- backdrop: tokens?.backdrop ?? ["100", "900"],
2307
- code: {
2308
- bg: tokens?.code?.bg ?? ["50", "950"],
2309
- fg: tokens?.code?.fg ?? ["600", "400"],
2310
- token: {
2311
- atrule: tokens?.code?.token?.atrule ?? ["600", "400"],
2312
- attribute: tokens?.code?.token?.attribute ?? ["600", "400"],
2313
- attrName: tokens?.code?.token?.attrName ?? ["600", "400"],
2314
- attrValue: tokens?.code?.token?.attrValue ?? ["600", "400"],
2315
- boolean: tokens?.code?.token?.boolean ?? ["600", "400"],
2316
- builtin: tokens?.code?.token?.builtin ?? ["600", "400"],
2317
- cdata: tokens?.code?.token?.cdata ?? ["600", "400"],
2318
- char: tokens?.code?.token?.char ?? ["600", "400"],
2319
- class: tokens?.code?.token?.class ?? ["600", "400"],
2320
- className: tokens?.code?.token?.className ?? ["600", "400"],
2321
- comment: tokens?.code?.token?.comment ?? ["400", "600"],
2322
- constant: tokens?.code?.token?.constant ?? ["600", "400"],
2323
- deleted: tokens?.code?.token?.deleted ?? ["600", "400"],
2324
- doctype: tokens?.code?.token?.doctype ?? ["600", "400"],
2325
- entity: tokens?.code?.token?.entity ?? ["600", "400"],
2326
- function: tokens?.code?.token?.function ?? ["600", "400"],
2327
- hexcode: tokens?.code?.token?.hexcode ?? ["600", "400"],
2328
- id: tokens?.code?.token?.id ?? ["600", "400"],
2329
- important: tokens?.code?.token?.important ?? ["600", "400"],
2330
- inserted: tokens?.code?.token?.inserted ?? ["600", "400"],
2331
- keyword: tokens?.code?.token?.keyword ?? ["600", "400"],
2332
- number: tokens?.code?.token?.number ?? ["600", "400"],
2333
- operator: tokens?.code?.token?.operator ?? ["600", "400"],
2334
- prolog: tokens?.code?.token?.prolog ?? ["600", "400"],
2335
- property: tokens?.code?.token?.property ?? ["600", "400"],
2336
- pseudoClass: tokens?.code?.token?.pseudoClass ?? ["600", "400"],
2337
- pseudoElement: tokens?.code?.token?.pseudoElement ?? ["600", "400"],
2338
- punctuation: tokens?.code?.token?.punctuation ?? ["600", "400"],
2339
- regex: tokens?.code?.token?.regex ?? ["600", "400"],
2340
- selector: tokens?.code?.token?.selector ?? ["600", "400"],
2341
- string: tokens?.code?.token?.string ?? ["600", "400"],
2342
- symbol: tokens?.code?.token?.symbol ?? ["600", "400"],
2343
- tag: tokens?.code?.token?.tag ?? ["600", "400"],
2344
- unit: tokens?.code?.token?.unit ?? ["600", "400"],
2345
- url: tokens?.code?.token?.url ?? ["600", "400"],
2346
- variable: tokens?.code?.token?.variable ?? ["600", "400"]
2691
+ default: {
2692
+ selected: {
2693
+ _hue: "blue"
2347
2694
  }
2348
2695
  },
2349
- focusRing: tokens?.focusRing ?? ["500", "500"],
2350
- link: {
2351
- fg: tokens?.link?.fg ?? ["600", "400"]
2352
- },
2353
- shadow: {
2354
- outline: tokens?.shadow?.outline ?? ["500", "500"],
2355
- umbra: tokens?.shadow?.umbra ?? ["500", "500"],
2356
- penumbra: tokens?.shadow?.penumbra ?? ["500", "500"],
2357
- ambient: tokens?.shadow?.ambient ?? ["500", "500"]
2358
- },
2359
- skeleton: {
2360
- from: tokens?.skeleton?.from ?? ["100", "900"],
2361
- to: tokens?.skeleton?.to ?? ["50", "950"]
2362
- },
2363
- variant: {
2364
- solid: {
2365
- "*": resolveElementTokens(tokens?.variant?.solid?.["*"]),
2366
- ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.solid?.["*"], tokens?.variant?.solid?.[tone])), acc), {})
2367
- },
2368
- tinted: {
2369
- "*": resolveElementTokens(tokens?.variant?.tinted?.["*"]),
2370
- ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
2696
+ critical: {
2697
+ disabled: {
2698
+ bg: ["50 50%", "950 50%"]
2371
2699
  }
2372
2700
  }
2701
+ },
2702
+ syntax: {
2703
+ atrule: ["purple/600", "purple/400"],
2704
+ attrName: ["green/600", "green/400"],
2705
+ attrValue: ["yellow/600", "yellow/400"],
2706
+ attribute: ["yellow/600", "yellow/400"],
2707
+ boolean: ["purple/600", "purple/400"],
2708
+ builtin: ["purple/600", "purple/400"],
2709
+ cdata: ["yellow/600", "yellow/400"],
2710
+ char: ["yellow/600", "yellow/400"],
2711
+ class: ["orange/600", "orange/400"],
2712
+ className: ["cyan/600", "cyan/400"],
2713
+ comment: ["gray/400", "gray/600"],
2714
+ constant: ["purple/600", "purple/400"],
2715
+ deleted: ["red/600", "red/400"],
2716
+ entity: ["red/600", "red/400"],
2717
+ function: ["green/600", "green/400"],
2718
+ hexcode: ["blue/600", "blue/400"],
2719
+ id: ["purple/600", "purple/400"],
2720
+ important: ["purple/600", "purple/400"],
2721
+ inserted: ["yellow/600", "yellow/400"],
2722
+ keyword: ["magenta/600", "magenta/400"],
2723
+ number: ["purple/600", "purple/400"],
2724
+ operator: ["magenta/600", "magenta/400"],
2725
+ property: ["blue/600", "blue/400"],
2726
+ pseudoClass: ["yellow/600", "yellow/400"],
2727
+ pseudoElement: ["yellow/600", "yellow/400"],
2728
+ punctuation: ["gray/600", "gray/400"],
2729
+ regex: ["blue/600", "blue/400"],
2730
+ selector: ["red/600", "red/400"],
2731
+ string: ["yellow/600", "yellow/400"],
2732
+ symbol: ["purple/600", "purple/400"],
2733
+ tag: ["red/600", "red/400"],
2734
+ unit: ["orange/600", "orange/400"],
2735
+ url: ["red/600", "red/400"],
2736
+ variable: ["red/600", "red/400"]
2737
+ }
2738
+ };
2739
+ function isRecord$1(value) {
2740
+ return !!(value && typeof value == "object" && !Array.isArray(value));
2741
+ }
2742
+ function merge$1(...records) {
2743
+ const _records = records.filter(Boolean);
2744
+ return _records.length === 0 ? {} : _records.reduce(_merge$1, {});
2745
+ }
2746
+ function _merge$1(acc, source) {
2747
+ for (const key of Object.keys(source)) {
2748
+ const prevValue = acc[key], nextValue = source[key];
2749
+ isRecord$1(prevValue) && isRecord$1(nextValue) ? acc[key] = merge$1(prevValue, nextValue) : acc[key] = nextValue;
2750
+ }
2751
+ return acc;
2752
+ }
2753
+ function resolveColorTokens(inputTokens) {
2754
+ const tokens = merge$1(defaultColorTokens, inputTokens);
2755
+ return {
2756
+ base: resolveBaseColorTokens(tokens),
2757
+ button: resolveButtonColorTokens(tokens),
2758
+ input: resolveInputColorTokens(tokens),
2759
+ selectable: resolveSelectableColorTokens(tokens),
2760
+ syntax: tokens.syntax
2373
2761
  };
2374
2762
  }
2375
- function resolveElementTokens(tokens) {
2763
+ function resolveBaseColorTokens(sparseTokens) {
2764
+ const tokens = {};
2765
+ for (const tone of THEME_COLOR_CARD_TONES)
2766
+ tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
2767
+ return tokens;
2768
+ }
2769
+ function resolveBaseColorTones(inputTokens, tone) {
2770
+ const spec = merge$1(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
2376
2771
  return {
2377
- _hue: tokens?._hue ?? "gray",
2378
- bg: {
2379
- 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
2380
- 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
2381
- },
2382
- border: {
2383
- 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
2384
- 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
2385
- },
2386
- fg: {
2387
- 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
2388
- 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
2389
- }
2772
+ ...spec,
2773
+ _hue: hue,
2774
+ avatar: color.COLOR_HUES.reduce((acc, hue2) => ({
2775
+ ...acc,
2776
+ [hue2]: merge$1({
2777
+ _hue: hue2
2778
+ }, spec.avatar?.["*"], spec.avatar?.[hue2])
2779
+ }), {}),
2780
+ badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2781
+ ...acc,
2782
+ [tone2]: {
2783
+ _hue: inputTokens?.base?.[tone2]?._hue || hue,
2784
+ ...spec.badge?.["*"],
2785
+ ...spec.badge?.[tone2]
2786
+ }
2787
+ }), {})
2390
2788
  };
2391
2789
  }
2392
- function buildTheme_v3(options) {
2393
- const {
2394
- v2
2395
- } = options ?? {}, tokens = resolveTokens(options?.tokens ?? defaultTokens);
2790
+ function resolveButtonColorTokens(inputTokens) {
2791
+ const tokens = {};
2792
+ for (const mode of THEME_COLOR_BUTTON_MODES)
2793
+ tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
2794
+ return tokens;
2795
+ }
2796
+ function resolveButtonToneColorTokens(inputTokens, mode) {
2797
+ const tokens = {};
2798
+ for (const tone of THEME_COLOR_STATE_TONES)
2799
+ tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
2800
+ return tokens;
2801
+ }
2802
+ function resolveButtonModeColorTokens(inputTokens, mode, tone) {
2803
+ const tokens = {};
2804
+ for (const state of THEME_COLOR_STATES)
2805
+ tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
2806
+ return tokens;
2807
+ }
2808
+ function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
2809
+ const spec = merge$1(inputTokens?.button?.[mode]?.["*"]?.["*"], inputTokens?.button?.[mode]?.[tone]?.["*"], inputTokens?.button?.[mode]?.["*"]?.[state], inputTokens?.button?.[mode]?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2396
2810
  return {
2397
- _version: 3,
2398
- _tokens: tokens,
2399
- avatar: v2?.avatar ?? defaultThemeConfig.avatar,
2400
- button: v2?.button ?? defaultThemeConfig.button,
2401
- card: v2?.card ?? defaultThemeConfig.card,
2402
- color: tokens.color,
2403
- container: v2?.container ?? defaultThemeConfig.container,
2404
- font: defaultThemeFonts,
2405
- input: v2?.input ?? defaultThemeConfig.input,
2406
- layer: v2?.layer ?? defaultThemeConfig.layer,
2407
- media: v2?.media ?? defaultThemeConfig.media,
2408
- palette: {
2409
- black: color.black,
2410
- white: color.white,
2411
- hues: color.hues
2412
- },
2413
- // TODO
2414
- radius: v2?.radius ?? defaultThemeConfig.radius,
2415
- // TODO
2416
- shadow: v2?.shadow ?? defaultThemeConfig.shadow,
2417
- // TODO
2418
- space: v2?.space ?? defaultThemeConfig.space
2811
+ ...spec,
2812
+ _hue: hue,
2813
+ avatar: color.COLOR_HUES.reduce((acc, hue2) => ({
2814
+ ...acc,
2815
+ [hue2]: merge$1({
2816
+ _hue: hue2
2817
+ }, spec.avatar?.["*"], spec.avatar?.[hue2])
2818
+ }), {}),
2819
+ badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2820
+ ...acc,
2821
+ [tone2]: {
2822
+ _hue: inputTokens?.base?.[tone2]?._hue || hue,
2823
+ ...spec.badge?.["*"],
2824
+ ...spec.badge?.[tone2]
2825
+ }
2826
+ }), {})
2419
2827
  };
2420
2828
  }
2421
- const COLOR_VARIANTS = ["tinted", "solid"], AVATAR_COLORS = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"];
2422
- function renderColor(colorToken, options) {
2423
- const {
2424
- defaultHue,
2425
- palette
2426
- } = options, color2 = _parseColorToken(colorToken, {
2427
- defaultHue
2428
- });
2429
- return color2.type === "color" ? palette[color2.name].hex : color2.type === "tint" ? palette.hues[color2.hue][color2.tint].hex : "#000";
2829
+ function resolveInputColorTokens(inputTokens) {
2830
+ const tokens = {};
2831
+ for (const mode of THEME_COLOR_INPUT_MODES)
2832
+ tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
2833
+ return tokens;
2430
2834
  }
2431
- function themeColor_v3_v2(options) {
2432
- const {
2433
- color: color2,
2434
- dark,
2435
- palette
2436
- } = options, i = dark ? 1 : 0, defaultHue = color2._hue, colorOptions = {
2437
- defaultHue,
2438
- palette
2835
+ function resolveInputModeColorTokens(inputTokens, mode) {
2836
+ const states = {};
2837
+ for (const state of THEME_COLOR_INPUT_STATES)
2838
+ states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
2839
+ return states;
2840
+ }
2841
+ function resolveInputStateColorTokens(inputTokens, mode, state) {
2842
+ const spec = merge$1(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
2843
+ return {
2844
+ ...spec,
2845
+ _hue: hue
2439
2846
  };
2847
+ }
2848
+ function resolveSelectableColorTokens(inputTokens) {
2849
+ const tokens = {};
2850
+ for (const tone of THEME_COLOR_STATE_TONES)
2851
+ tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
2852
+ return tokens;
2853
+ }
2854
+ function resolveSelectableToneColorTokens(inputTokens, tone) {
2855
+ const states = {
2856
+ _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue
2857
+ };
2858
+ for (const state of THEME_COLOR_STATES)
2859
+ states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
2860
+ return states;
2861
+ }
2862
+ function resolveSelectableStateColorTokens(inputTokens, tone, state) {
2863
+ const spec = merge$1(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2440
2864
  return {
2441
- _blend: "screen",
2442
- _dark: dark,
2443
- ...buildColorState({
2444
- cardColor: color2,
2445
- dark,
2446
- palette,
2447
- state: "enabled",
2448
- tone: "default",
2449
- variant: "tinted"
2450
- }),
2451
- backdrop: renderColor(color2.backdrop[i], colorOptions),
2452
- button: THEME_COLOR_BUTTON_MODES.reduce((modes, mode) => (modes[mode] = THEME_COLOR_STATE_TONES.reduce((tones2, tone) => (tones2[tone] = THEME_COLOR_STATES.reduce((states, state) => (states[state] = buildColorState({
2453
- cardColor: color2,
2454
- dark,
2455
- palette,
2456
- state,
2457
- tone,
2458
- variant: mode === "default" ? "solid" : "tinted"
2459
- }), mode === "bleed" && (states[state].border = "transparent"), states), {}), tones2), {}), modes), {}),
2460
- focusRing: renderColor(color2.focusRing[i], colorOptions),
2461
- input: THEME_COLOR_INPUT_MODES.reduce((modes, mode) => (modes[mode] = THEME_COLOR_INPUT_STATES.reduce((states, state) => (states[state] = buildInputState(color2.variant.tinted.default, {
2462
- dark,
2463
- defaultHue,
2464
- palette
2465
- }), states), {}), modes), {}),
2466
- selectable: THEME_COLOR_STATE_TONES.reduce((tones2, tone) => (tones2[tone] = THEME_COLOR_STATES.reduce((states, state) => (states[state] = buildColorState({
2467
- cardColor: color2,
2468
- dark,
2469
- palette,
2470
- state,
2471
- tone,
2472
- variant: "tinted"
2473
- }), states), {}), tones2), {}),
2474
- shadow: {
2475
- outline: renderColor(color2.shadow.outline[i], colorOptions),
2476
- umbra: renderColor(color2.shadow.umbra[i], colorOptions),
2477
- penumbra: renderColor(color2.shadow.penumbra[i], colorOptions),
2478
- ambient: renderColor(color2.shadow.ambient[i], colorOptions)
2479
- },
2480
- syntax: {
2481
- atrule: renderColor(color2.code.token.atrule[i], colorOptions),
2482
- attrName: renderColor(color2.code.token.attrName[i], colorOptions),
2483
- attrValue: renderColor(color2.code.token.attrValue[i], colorOptions),
2484
- attribute: renderColor(color2.code.token.attribute[i], colorOptions),
2485
- boolean: renderColor(color2.code.token.boolean[i], colorOptions),
2486
- builtin: renderColor(color2.code.token.builtin[i], colorOptions),
2487
- cdata: renderColor(color2.code.token.cdata[i], colorOptions),
2488
- char: renderColor(color2.code.token.char[i], colorOptions),
2489
- class: renderColor(color2.code.token.class[i], colorOptions),
2490
- className: renderColor(color2.code.token.className[i], colorOptions),
2491
- comment: renderColor(color2.code.token.comment[i], colorOptions),
2492
- constant: renderColor(color2.code.token.constant[i], colorOptions),
2493
- deleted: renderColor(color2.code.token.deleted[i], colorOptions),
2494
- doctype: renderColor(color2.code.token.doctype[i], colorOptions),
2495
- entity: renderColor(color2.code.token.entity[i], colorOptions),
2496
- function: renderColor(color2.code.token.function[i], colorOptions),
2497
- hexcode: renderColor(color2.code.token.hexcode[i], colorOptions),
2498
- id: renderColor(color2.code.token.id[i], colorOptions),
2499
- important: renderColor(color2.code.token.important[i], colorOptions),
2500
- inserted: renderColor(color2.code.token.inserted[i], colorOptions),
2501
- keyword: renderColor(color2.code.token.keyword[i], colorOptions),
2502
- number: renderColor(color2.code.token.number[i], colorOptions),
2503
- operator: renderColor(color2.code.token.operator[i], colorOptions),
2504
- prolog: renderColor(color2.code.token.prolog[i], colorOptions),
2505
- property: renderColor(color2.code.token.property[i], colorOptions),
2506
- pseudoClass: renderColor(color2.code.token.pseudoClass[i], colorOptions),
2507
- pseudoElement: renderColor(color2.code.token.pseudoElement[i], colorOptions),
2508
- punctuation: renderColor(color2.code.token.punctuation[i], colorOptions),
2509
- regex: renderColor(color2.code.token.regex[i], colorOptions),
2510
- selector: renderColor(color2.code.token.selector[i], colorOptions),
2511
- string: renderColor(color2.code.token.string[i], colorOptions),
2512
- symbol: renderColor(color2.code.token.symbol[i], colorOptions),
2513
- tag: renderColor(color2.code.token.tag[i], colorOptions),
2514
- unit: renderColor(color2.code.token.unit[i], colorOptions),
2515
- url: renderColor(color2.code.token.url[i], colorOptions),
2516
- variable: renderColor(color2.code.token.variable[i], colorOptions)
2517
- }
2865
+ ...spec,
2866
+ _hue: hue,
2867
+ avatar: color.COLOR_HUES.reduce((acc, hue2) => ({
2868
+ ...acc,
2869
+ [hue2]: merge$1({
2870
+ _hue: hue2
2871
+ }, spec.avatar?.["*"], spec.avatar?.[hue2])
2872
+ }), {}),
2873
+ badge: THEME_COLOR_STATE_TONES.reduce((acc, tone2) => ({
2874
+ ...acc,
2875
+ [tone2]: {
2876
+ _hue: inputTokens?.base?.[tone2]?._hue || hue,
2877
+ ...spec.badge?.["*"],
2878
+ ...spec.badge?.[tone2]
2879
+ }
2880
+ }), {})
2518
2881
  };
2519
2882
  }
2520
- const stateShades = {
2521
- enabled: {
2522
- bg: [0, 1, 2],
2523
- border: [0, 1, 2],
2524
- fg: [0, 1, 2]
2525
- },
2526
- hovered: {
2527
- bg: [1, 2, 3],
2528
- border: [1, 2, 3],
2529
- fg: [1, 2, 3]
2530
- },
2531
- pressed: {
2532
- bg: [2, 3, 4],
2533
- border: [2, 3, 4],
2534
- fg: [2, 3, 4]
2535
- },
2536
- selected: {
2537
- bg: [3, 4, 4],
2538
- border: [3, 4, 4],
2539
- fg: [3, 4, 4]
2540
- },
2541
- disabled: {
2542
- bg: [4, 4, 4],
2543
- border: [4, 4, 4],
2544
- fg: [4, 4, 4]
2545
- }
2546
- };
2547
- function mix$1(tokens, index, options) {
2883
+ function buildColorTheme(config) {
2884
+ const resolvedConfig = {
2885
+ color: resolveColorTokens(config?.color)
2886
+ };
2887
+ return {
2888
+ light: buildColorScheme({
2889
+ scheme: "light"
2890
+ }, resolvedConfig),
2891
+ dark: buildColorScheme({
2892
+ scheme: "dark"
2893
+ }, resolvedConfig)
2894
+ };
2895
+ }
2896
+ function buildColorScheme(options, config) {
2548
2897
  const {
2549
- dark,
2550
- defaultHue,
2551
- palette
2552
- } = options, colorOptions = {
2553
- defaultHue,
2554
- palette
2555
- }, i = dark ? 1 : 0, from = renderColor(tokens[0][i], colorOptions), to = renderColor(tokens[4][i], colorOptions);
2556
- return index === 0 ? from : index === 4 ? to : `color-mix(in oklch, ${from}, ${to} ${index * 25}%)`;
2898
+ scheme
2899
+ } = options, colorScheme = {};
2900
+ for (const tone of THEME_COLOR_CARD_TONES)
2901
+ colorScheme[tone] = buildCardColorTheme({
2902
+ scheme,
2903
+ tone
2904
+ }, config);
2905
+ return colorScheme;
2557
2906
  }
2558
- function buildColorState(options) {
2907
+ function buildCardColorTheme(options, config) {
2559
2908
  const {
2560
- cardColor,
2561
- dark,
2562
- palette,
2563
- state,
2564
- tone,
2565
- variant
2566
- } = options, color2 = cardColor.variant[variant][tone], shades = stateShades[state], defaultHue = cardColor._hue, colorOptions = {
2567
- defaultHue,
2568
- palette
2569
- }, i = dark ? 1 : 0;
2909
+ scheme,
2910
+ tone
2911
+ } = options, tokens = config?.color?.base?.[tone], context = {
2912
+ hue: tokens?._hue || "gray",
2913
+ scheme
2914
+ };
2570
2915
  return {
2916
+ _blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
2917
+ _dark: scheme === "dark",
2571
2918
  accent: {
2572
- fg: renderColor(color2.fg[4][i], colorOptions)
2573
- },
2574
- avatar: {
2575
- gray: {
2576
- bg: renderColor(cardColor.avatar.gray.bg[i], colorOptions),
2577
- fg: renderColor(cardColor.avatar.gray.fg[i], colorOptions)
2578
- },
2579
- blue: {
2580
- bg: renderColor(cardColor.avatar.blue.bg[i], colorOptions),
2581
- fg: renderColor(cardColor.avatar.blue.fg[i], colorOptions)
2582
- },
2583
- purple: {
2584
- bg: renderColor(cardColor.avatar.purple.bg[i], colorOptions),
2585
- fg: renderColor(cardColor.avatar.purple.fg[i], colorOptions)
2586
- },
2587
- magenta: {
2588
- bg: renderColor(cardColor.avatar.magenta.bg[i], colorOptions),
2589
- fg: renderColor(cardColor.avatar.magenta.fg[i], colorOptions)
2590
- },
2591
- red: {
2592
- bg: renderColor(cardColor.avatar.red.bg[i], colorOptions),
2593
- fg: renderColor(cardColor.avatar.red.fg[i], colorOptions)
2594
- },
2595
- orange: {
2596
- bg: renderColor(cardColor.avatar.orange.bg[i], colorOptions),
2597
- fg: renderColor(cardColor.avatar.orange.fg[i], colorOptions)
2598
- },
2599
- yellow: {
2600
- bg: renderColor(cardColor.avatar.yellow.bg[i], colorOptions),
2601
- fg: renderColor(cardColor.avatar.yellow.fg[i], colorOptions)
2602
- },
2603
- green: {
2604
- bg: renderColor(cardColor.avatar.green.bg[i], colorOptions),
2605
- fg: renderColor(cardColor.avatar.green.fg[i], colorOptions)
2606
- },
2607
- cyan: {
2608
- bg: renderColor(cardColor.avatar.cyan.bg[i], colorOptions),
2609
- fg: renderColor(cardColor.avatar.cyan.fg[i], colorOptions)
2610
- }
2919
+ fg: resolveColorTokenValue(context, tokens?.accent?.fg)
2611
2920
  },
2612
- // avatar: cardColor.avatar,
2613
- badge: THEME_COLOR_STATE_TONES.reduce((tones2, tone2) => (tones2[tone2] = {
2614
- bg: mix$1(color2.bg, 1, {
2615
- dark,
2616
- defaultHue,
2617
- palette
2618
- }),
2619
- fg: mix$1(color2.fg, 1, {
2620
- dark,
2621
- defaultHue,
2622
- palette
2623
- }),
2624
- dot: mix$1(color2.fg, 3, {
2625
- dark,
2626
- defaultHue,
2627
- palette
2628
- }),
2629
- icon: mix$1(color2.fg, 3, {
2630
- dark,
2631
- defaultHue,
2632
- palette
2633
- })
2634
- }, tones2), {}),
2635
- bg: mix$1(color2.bg, shades.bg[0], {
2636
- dark,
2637
- defaultHue,
2638
- palette
2639
- }),
2640
- border: mix$1(color2.border, shades.border[0], {
2641
- dark,
2642
- defaultHue,
2643
- palette
2644
- }),
2645
- fg: mix$1(color2.fg, shades.fg[0], {
2646
- dark,
2647
- defaultHue,
2648
- palette
2649
- }),
2921
+ avatar: buildAvatarColorTheme({
2922
+ scheme
2923
+ }, tokens),
2924
+ backdrop: resolveColorTokenValue(context, tokens?.backdrop),
2925
+ badge: buildBadgeColorTheme(tokens?.badge, {
2926
+ scheme
2927
+ }, config),
2928
+ bg: resolveColorTokenValue(context, tokens?.bg),
2929
+ border: resolveColorTokenValue(context, tokens?.border),
2930
+ button: buildButtonColorTheme({
2931
+ scheme,
2932
+ tone
2933
+ }, config),
2650
2934
  code: {
2651
- bg: mix$1(color2.bg, shades.bg[1], {
2652
- dark,
2653
- defaultHue,
2654
- palette
2655
- }),
2656
- fg: mix$1(color2.fg, shades.fg[2], {
2657
- dark,
2658
- defaultHue,
2659
- palette
2660
- })
2935
+ bg: resolveColorTokenValue(context, tokens?.code?.bg),
2936
+ fg: resolveColorTokenValue(context, tokens?.code?.fg)
2661
2937
  },
2662
- icon: mix$1(color2.fg, shades.fg[2], {
2663
- dark,
2664
- defaultHue,
2665
- palette
2666
- }),
2938
+ fg: resolveColorTokenValue(context, tokens?.fg),
2939
+ focusRing: resolveColorTokenValue(context, tokens?.focusRing),
2940
+ icon: resolveColorTokenValue(context, tokens?.icon),
2941
+ input: buildInputColorTheme({
2942
+ scheme,
2943
+ tone
2944
+ }, config),
2667
2945
  kbd: {
2668
- bg: mix$1(color2.bg, 0, {
2669
- dark,
2670
- defaultHue,
2671
- palette
2672
- }),
2673
- fg: mix$1(color2.fg, 0, {
2674
- dark,
2675
- defaultHue,
2676
- palette
2677
- }),
2678
- border: mix$1(color2.bg, 0, {
2679
- dark,
2680
- defaultHue,
2681
- palette
2682
- })
2946
+ bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
2947
+ fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
2948
+ border: resolveColorTokenValue(context, tokens?.kbd?.border)
2683
2949
  },
2684
2950
  link: {
2685
- fg: mix$1(color2.fg, shades.fg[2], {
2686
- dark,
2687
- defaultHue,
2688
- palette
2689
- })
2951
+ fg: resolveColorTokenValue(context, tokens?.link?.fg)
2690
2952
  },
2691
2953
  muted: {
2692
- bg: mix$1(color2.bg, shades.bg[1], {
2693
- dark,
2694
- defaultHue,
2695
- palette
2696
- }),
2697
- fg: mix$1(color2.fg, shades.fg[2], {
2698
- dark,
2699
- defaultHue,
2700
- palette
2701
- })
2954
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg),
2955
+ fg: resolveColorTokenValue(context, tokens?.muted?.fg)
2702
2956
  },
2957
+ selectable: buildSelectableColorTheme({
2958
+ scheme,
2959
+ tone
2960
+ }, config),
2961
+ shadow: buildShadowColorTheme({
2962
+ scheme,
2963
+ tone
2964
+ }, config),
2703
2965
  skeleton: {
2704
- from: renderColor(cardColor.skeleton.from[i], colorOptions),
2705
- to: renderColor(cardColor.skeleton.to[i], colorOptions)
2706
- }
2966
+ from: resolveColorTokenValue(context, tokens?.skeleton?.from),
2967
+ to: resolveColorTokenValue(context, tokens?.skeleton?.to)
2968
+ },
2969
+ syntax: buildSyntaxColorTheme({
2970
+ scheme
2971
+ }, config)
2707
2972
  };
2708
2973
  }
2709
- function buildInputState(colorElement, options) {
2974
+ function buildShadowColorTheme(options, config) {
2710
2975
  const {
2711
- dark,
2712
- defaultHue,
2713
- palette
2714
- } = options, colorOptions = {
2715
- defaultHue,
2716
- palette
2717
- }, i = dark ? 1 : 0;
2718
- return {
2719
- bg: renderColor(colorElement.bg[0][i], colorOptions),
2720
- border: renderColor(colorElement.bg[0][i], colorOptions),
2721
- fg: renderColor(colorElement.fg[0][i], colorOptions),
2722
- muted: {
2723
- bg: renderColor(colorElement.bg[0][i], colorOptions)
2724
- },
2725
- placeholder: renderColor(colorElement.fg[0][i], colorOptions)
2976
+ scheme,
2977
+ tone
2978
+ } = options, tokens = config?.color?.base?.[tone], context = {
2979
+ hue: tokens?._hue || "gray",
2980
+ scheme
2726
2981
  };
2727
- }
2728
- function v3_v2(theme_v3) {
2729
- const palette = theme_v3.palette;
2730
2982
  return {
2731
- _version: 2,
2732
- avatar: theme_v3.avatar,
2733
- button: theme_v3.button,
2734
- card: theme_v3.card,
2735
- color: {
2736
- dark: {
2737
- transparent: themeColor_v3_v2({
2738
- color: theme_v3.color.transparent,
2739
- dark: !0,
2740
- palette
2741
- }),
2742
- default: themeColor_v3_v2({
2743
- color: theme_v3.color.default,
2744
- dark: !0,
2745
- palette
2746
- }),
2747
- neutral: themeColor_v3_v2({
2748
- color: theme_v3.color.neutral,
2749
- dark: !0,
2750
- palette
2751
- }),
2752
- primary: themeColor_v3_v2({
2753
- color: theme_v3.color.primary,
2754
- dark: !0,
2755
- palette
2756
- }),
2757
- suggest: themeColor_v3_v2({
2758
- color: theme_v3.color.suggest,
2759
- dark: !0,
2760
- palette
2761
- }),
2762
- positive: themeColor_v3_v2({
2763
- color: theme_v3.color.positive,
2764
- dark: !0,
2765
- palette
2766
- }),
2767
- caution: themeColor_v3_v2({
2768
- color: theme_v3.color.caution,
2769
- dark: !0,
2770
- palette
2771
- }),
2772
- critical: themeColor_v3_v2({
2773
- color: theme_v3.color.critical,
2774
- dark: !0,
2775
- palette
2776
- })
2777
- },
2778
- light: {
2779
- transparent: themeColor_v3_v2({
2780
- color: theme_v3.color.transparent,
2781
- dark: !1,
2782
- palette
2783
- }),
2784
- default: themeColor_v3_v2({
2785
- color: theme_v3.color.default,
2786
- dark: !1,
2787
- palette
2788
- }),
2789
- neutral: themeColor_v3_v2({
2790
- color: theme_v3.color.neutral,
2791
- dark: !1,
2792
- palette
2793
- }),
2794
- primary: themeColor_v3_v2({
2795
- color: theme_v3.color.primary,
2796
- dark: !1,
2797
- palette
2798
- }),
2799
- suggest: themeColor_v3_v2({
2800
- color: theme_v3.color.suggest,
2801
- dark: !1,
2802
- palette
2803
- }),
2804
- positive: themeColor_v3_v2({
2805
- color: theme_v3.color.positive,
2806
- dark: !1,
2807
- palette
2808
- }),
2809
- caution: themeColor_v3_v2({
2810
- color: theme_v3.color.caution,
2811
- dark: !1,
2812
- palette
2813
- }),
2814
- critical: themeColor_v3_v2({
2815
- color: theme_v3.color.critical,
2816
- dark: !1,
2817
- palette
2818
- })
2819
- }
2820
- },
2821
- container: theme_v3.container,
2822
- font: {
2823
- code: {
2824
- family: theme_v3.font.code.family,
2825
- weights: theme_v3.font.code.weight,
2826
- sizes: theme_v3.font.code.scale
2827
- },
2828
- heading: {
2829
- family: theme_v3.font.heading.family,
2830
- weights: theme_v3.font.heading.weight,
2831
- sizes: theme_v3.font.heading.scale
2832
- },
2833
- label: {
2834
- family: theme_v3.font.label.family,
2835
- weights: theme_v3.font.label.weight,
2836
- sizes: theme_v3.font.label.scale
2837
- },
2838
- text: {
2839
- family: theme_v3.font.text.family,
2840
- weights: theme_v3.font.text.weight,
2841
- sizes: theme_v3.font.text.scale
2842
- }
2843
- },
2844
- input: theme_v3.input,
2845
- layer: theme_v3.layer,
2846
- media: theme_v3.media,
2847
- radius: Object.values(theme_v3.radius),
2848
- shadow: Object.values(theme_v3.shadow),
2849
- space: Object.values(theme_v3.space)
2983
+ outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
2984
+ umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
2985
+ penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
2986
+ ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
2850
2987
  };
2851
2988
  }
2852
- function buildTheme(_config) {
2853
- const v3 = buildTheme_v3({
2854
- v2: _config
2855
- });
2856
- return v2_v0(v3_v2(v3), v3);
2857
- }
2858
- function mixChannel(b, s, weight) {
2859
- const delta = (s - b) * weight;
2860
- return b + delta;
2861
- }
2862
- function mix(b, s, weight) {
2989
+ function buildAvatarColorTheme(options, stateTokens) {
2990
+ const {
2991
+ scheme
2992
+ } = options;
2863
2993
  return {
2864
- r: mixChannel(b.r, s.r, weight),
2865
- g: mixChannel(b.g, s.g, weight),
2866
- b: mixChannel(b.b, s.b, weight)
2994
+ gray: _buildAvatarColorTheme({
2995
+ color: "gray",
2996
+ scheme
2997
+ }, stateTokens),
2998
+ blue: _buildAvatarColorTheme({
2999
+ color: "blue",
3000
+ scheme
3001
+ }, stateTokens),
3002
+ purple: _buildAvatarColorTheme({
3003
+ color: "purple",
3004
+ scheme
3005
+ }, stateTokens),
3006
+ magenta: _buildAvatarColorTheme({
3007
+ color: "magenta",
3008
+ scheme
3009
+ }, stateTokens),
3010
+ red: _buildAvatarColorTheme({
3011
+ color: "red",
3012
+ scheme
3013
+ }, stateTokens),
3014
+ orange: _buildAvatarColorTheme({
3015
+ color: "orange",
3016
+ scheme
3017
+ }, stateTokens),
3018
+ yellow: _buildAvatarColorTheme({
3019
+ color: "yellow",
3020
+ scheme
3021
+ }, stateTokens),
3022
+ green: _buildAvatarColorTheme({
3023
+ color: "green",
3024
+ scheme
3025
+ }, stateTokens),
3026
+ cyan: _buildAvatarColorTheme({
3027
+ color: "cyan",
3028
+ scheme
3029
+ }, stateTokens)
2867
3030
  };
2868
3031
  }
2869
- function multiplyChannel(b, s) {
2870
- return b * s;
2871
- }
2872
- function multiply(b, s) {
3032
+ function _buildAvatarColorTheme(options, stateTokens) {
3033
+ const {
3034
+ color: color2,
3035
+ scheme
3036
+ } = options, tokens = stateTokens?.avatar?.[color2], context = {
3037
+ hue: tokens?._hue || "gray",
3038
+ scheme
3039
+ };
2873
3040
  return {
2874
- r: multiplyChannel(b.r / 255, s.r / 255) * 255,
2875
- g: multiplyChannel(b.g / 255, s.g / 255) * 255,
2876
- b: multiplyChannel(b.b / 255, s.b / 255) * 255
3041
+ _blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
3042
+ bg: resolveColorTokenValue(context, tokens?.bg),
3043
+ fg: resolveColorTokenValue(context, tokens?.fg)
2877
3044
  };
2878
3045
  }
2879
- function screenChannel(b, s) {
2880
- return b + s - b * s;
3046
+ function buildBadgeColorTheme(tokens, options, config) {
3047
+ const {
3048
+ scheme
3049
+ } = options, colorBadge = {};
3050
+ for (const tone of THEME_COLOR_STATE_TONES)
3051
+ colorBadge[tone] = _buildBadgeColorTheme(tokens, {
3052
+ scheme,
3053
+ tone
3054
+ }, config);
3055
+ return colorBadge;
2881
3056
  }
2882
- function screen(b, s) {
3057
+ function _buildBadgeColorTheme(parentTokens, options, config) {
3058
+ const {
3059
+ scheme,
3060
+ tone
3061
+ } = options, tokens = parentTokens?.[tone], context = {
3062
+ hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
3063
+ scheme
3064
+ };
2883
3065
  return {
2884
- r: screenChannel(b.r / 255, s.r / 255) * 255,
2885
- g: screenChannel(b.g / 255, s.g / 255) * 255,
2886
- b: screenChannel(b.b / 255, s.b / 255) * 255
3066
+ bg: resolveColorTokenValue(context, tokens?.bg),
3067
+ fg: resolveColorTokenValue(context, tokens?.fg),
3068
+ dot: resolveColorTokenValue(context, tokens?.dot),
3069
+ icon: resolveColorTokenValue(context, tokens?.icon)
2887
3070
  };
2888
3071
  }
2889
- function clamp(a, min = 0, max = 1) {
2890
- return Math.min(max, Math.max(min, a));
3072
+ function buildButtonColorTheme(options, config) {
3073
+ const {
3074
+ scheme,
3075
+ tone: cardTone
3076
+ } = options, modes = {};
3077
+ for (const mode of THEME_COLOR_BUTTON_MODES)
3078
+ modes[mode] = buildButtonTonesColorTheme({
3079
+ cardTone,
3080
+ scheme,
3081
+ mode
3082
+ }, config);
3083
+ return modes;
2891
3084
  }
2892
- function round(value) {
2893
- return Math.round(value);
3085
+ function buildButtonTonesColorTheme(options, config) {
3086
+ const {
3087
+ cardTone,
3088
+ mode,
3089
+ scheme
3090
+ } = options, tones2 = {};
3091
+ for (const tone of THEME_COLOR_STATE_TONES)
3092
+ tones2[tone] = buildButtonStatesColorTheme({
3093
+ cardTone,
3094
+ mode,
3095
+ scheme,
3096
+ tone
3097
+ }, config);
3098
+ return tones2;
2894
3099
  }
2895
- function hexToRgb(hex) {
2896
- if (hex.length === 4) {
2897
- const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
2898
- return {
2899
- r: parseInt(hexR + hexR, 16),
2900
- g: parseInt(hexG + hexG, 16),
2901
- b: parseInt(hexB + hexB, 16)
2902
- };
2903
- }
2904
- return {
2905
- r: parseInt(hex.slice(1, 3), 16),
2906
- g: parseInt(hex.slice(3, 5), 16),
2907
- b: parseInt(hex.slice(5, 7), 16)
2908
- };
3100
+ function buildButtonStatesColorTheme(options, config) {
3101
+ const {
3102
+ cardTone,
3103
+ mode,
3104
+ scheme,
3105
+ tone
3106
+ } = options, states = {};
3107
+ for (const state of THEME_COLOR_STATES)
3108
+ states[state] = buildButtonStateColorTheme({
3109
+ cardTone,
3110
+ mode,
3111
+ tone,
3112
+ scheme,
3113
+ state
3114
+ }, config);
3115
+ return states;
3116
+ }
3117
+ function buildButtonStateColorTheme(options, config) {
3118
+ const {
3119
+ cardTone,
3120
+ mode,
3121
+ tone,
3122
+ scheme,
3123
+ state
3124
+ } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3125
+ hue,
3126
+ scheme
3127
+ };
3128
+ return {
3129
+ _blend: blendMode[scheme === "light" ? 0 : 1],
3130
+ accent: {
3131
+ fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3132
+ },
3133
+ avatar: buildAvatarColorTheme({
3134
+ scheme
3135
+ }, tokens),
3136
+ badge: buildBadgeColorTheme(tokens?.badge, {
3137
+ scheme
3138
+ }, config),
3139
+ bg: resolveColorTokenValue(context, tokens?.bg),
3140
+ border: resolveColorTokenValue(context, tokens?.border),
3141
+ code: {
3142
+ bg: resolveColorTokenValue(context, tokens?.code?.bg),
3143
+ fg: resolveColorTokenValue(context, tokens?.code?.fg)
3144
+ },
3145
+ fg: resolveColorTokenValue(context, tokens?.fg),
3146
+ icon: resolveColorTokenValue(context, tokens?.icon),
3147
+ muted: {
3148
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3149
+ fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3150
+ },
3151
+ kbd: {
3152
+ bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3153
+ fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3154
+ border: resolveColorTokenValue(context, tokens?.kbd?.border)
3155
+ },
3156
+ link: {
3157
+ fg: resolveColorTokenValue(context, tokens?.link?.fg)
3158
+ },
3159
+ skeleton: {
3160
+ from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3161
+ to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3162
+ }
3163
+ };
3164
+ }
3165
+ function buildInputColorTheme(options, config) {
3166
+ const {
3167
+ scheme,
3168
+ tone
3169
+ } = options;
3170
+ return {
3171
+ default: buildInputStatesColorTheme({
3172
+ mode: "default",
3173
+ scheme,
3174
+ tone
3175
+ }, config),
3176
+ invalid: buildInputStatesColorTheme({
3177
+ mode: "invalid",
3178
+ scheme,
3179
+ tone
3180
+ }, config)
3181
+ };
3182
+ }
3183
+ function buildInputStatesColorTheme(options, config) {
3184
+ const {
3185
+ mode,
3186
+ scheme,
3187
+ tone
3188
+ } = options;
3189
+ return {
3190
+ enabled: buildInputStateColorTheme({
3191
+ mode,
3192
+ scheme,
3193
+ state: "enabled",
3194
+ cardTone: tone
3195
+ }, config),
3196
+ hovered: buildInputStateColorTheme({
3197
+ mode,
3198
+ scheme,
3199
+ state: "hovered",
3200
+ cardTone: tone
3201
+ }, config),
3202
+ readOnly: buildInputStateColorTheme({
3203
+ mode,
3204
+ scheme,
3205
+ state: "readOnly",
3206
+ cardTone: tone
3207
+ }, config),
3208
+ disabled: buildInputStateColorTheme({
3209
+ mode,
3210
+ scheme,
3211
+ state: "disabled",
3212
+ cardTone: tone
3213
+ }, config)
3214
+ };
3215
+ }
3216
+ function buildInputStateColorTheme(options, config) {
3217
+ const {
3218
+ cardTone,
3219
+ mode,
3220
+ scheme,
3221
+ state
3222
+ } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3223
+ hue,
3224
+ scheme
3225
+ };
3226
+ return {
3227
+ _blend: blendMode[scheme === "light" ? 0 : 1],
3228
+ bg: resolveColorTokenValue(context, tokens?.bg),
3229
+ border: resolveColorTokenValue(context, tokens?.border),
3230
+ fg: resolveColorTokenValue(context, tokens?.fg),
3231
+ muted: {
3232
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg)
3233
+ },
3234
+ placeholder: resolveColorTokenValue(context, tokens?.placeholder)
3235
+ };
3236
+ }
3237
+ function buildSelectableColorTheme(options, config) {
3238
+ const {
3239
+ scheme,
3240
+ tone: cardTone
3241
+ } = options, tones2 = {};
3242
+ for (const tone of THEME_COLOR_STATE_TONES)
3243
+ tones2[tone] = buildSelectableStatesColorTheme({
3244
+ cardTone,
3245
+ scheme,
3246
+ tone
3247
+ }, config);
3248
+ return tones2;
3249
+ }
3250
+ function buildSelectableStatesColorTheme(options, config) {
3251
+ const {
3252
+ cardTone,
3253
+ scheme,
3254
+ tone
3255
+ } = options, states = {};
3256
+ for (const state of THEME_COLOR_STATES)
3257
+ states[state] = buildSelectableStateColorTheme({
3258
+ cardTone,
3259
+ tone,
3260
+ scheme,
3261
+ state
3262
+ }, config);
3263
+ return states;
3264
+ }
3265
+ function buildSelectableStateColorTheme(options, config) {
3266
+ const {
3267
+ cardTone,
3268
+ scheme,
3269
+ state,
3270
+ tone
3271
+ } = options, cardTokens = config?.color?.base?.[cardTone], tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || cardTokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3272
+ hue,
3273
+ scheme
3274
+ };
3275
+ return {
3276
+ _blend: blendMode[scheme === "light" ? 0 : 1],
3277
+ accent: {
3278
+ fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3279
+ },
3280
+ avatar: buildAvatarColorTheme({
3281
+ scheme
3282
+ }, tokens),
3283
+ badge: buildBadgeColorTheme(tokens?.badge, {
3284
+ scheme
3285
+ }, config),
3286
+ bg: resolveColorTokenValue(context, tokens?.bg),
3287
+ border: resolveColorTokenValue(context, tokens?.border),
3288
+ code: {
3289
+ bg: resolveColorTokenValue(context, tokens?.code?.bg),
3290
+ fg: resolveColorTokenValue(context, tokens?.code?.fg)
3291
+ },
3292
+ fg: resolveColorTokenValue(context, tokens?.fg),
3293
+ icon: resolveColorTokenValue(context, tokens?.icon),
3294
+ muted: {
3295
+ bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3296
+ fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3297
+ },
3298
+ kbd: {
3299
+ bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3300
+ fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3301
+ border: resolveColorTokenValue(context, tokens?.kbd?.border)
3302
+ },
3303
+ link: {
3304
+ fg: resolveColorTokenValue(context, tokens?.link?.fg)
3305
+ },
3306
+ skeleton: {
3307
+ from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3308
+ to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3309
+ }
3310
+ };
3311
+ }
3312
+ function buildSyntaxColorTheme(options, config) {
3313
+ const {
3314
+ scheme
3315
+ } = options, tokens = config?.color?.syntax, context = {
3316
+ hue: "gray",
3317
+ scheme
3318
+ };
3319
+ return {
3320
+ atrule: resolveColorTokenValue(context, tokens?.atrule),
3321
+ attrName: resolveColorTokenValue(context, tokens?.attrName),
3322
+ attrValue: resolveColorTokenValue(context, tokens?.attrValue),
3323
+ attribute: resolveColorTokenValue(context, tokens?.attribute),
3324
+ boolean: resolveColorTokenValue(context, tokens?.boolean),
3325
+ builtin: resolveColorTokenValue(context, tokens?.builtin),
3326
+ cdata: resolveColorTokenValue(context, tokens?.cdata),
3327
+ char: resolveColorTokenValue(context, tokens?.char),
3328
+ class: resolveColorTokenValue(context, tokens?.class),
3329
+ className: resolveColorTokenValue(context, tokens?.className),
3330
+ comment: resolveColorTokenValue(context, tokens?.comment),
3331
+ constant: resolveColorTokenValue(context, tokens?.constant),
3332
+ deleted: resolveColorTokenValue(context, tokens?.deleted),
3333
+ doctype: resolveColorTokenValue(context, tokens?.doctype),
3334
+ entity: resolveColorTokenValue(context, tokens?.entity),
3335
+ function: resolveColorTokenValue(context, tokens?.function),
3336
+ hexcode: resolveColorTokenValue(context, tokens?.hexcode),
3337
+ id: resolveColorTokenValue(context, tokens?.id),
3338
+ important: resolveColorTokenValue(context, tokens?.important),
3339
+ inserted: resolveColorTokenValue(context, tokens?.inserted),
3340
+ keyword: resolveColorTokenValue(context, tokens?.keyword),
3341
+ number: resolveColorTokenValue(context, tokens?.number),
3342
+ operator: resolveColorTokenValue(context, tokens?.operator),
3343
+ prolog: resolveColorTokenValue(context, tokens?.prolog),
3344
+ property: resolveColorTokenValue(context, tokens?.property),
3345
+ pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
3346
+ pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
3347
+ punctuation: resolveColorTokenValue(context, tokens?.punctuation),
3348
+ regex: resolveColorTokenValue(context, tokens?.regex),
3349
+ selector: resolveColorTokenValue(context, tokens?.selector),
3350
+ string: resolveColorTokenValue(context, tokens?.string),
3351
+ symbol: resolveColorTokenValue(context, tokens?.symbol),
3352
+ tag: resolveColorTokenValue(context, tokens?.tag),
3353
+ unit: resolveColorTokenValue(context, tokens?.unit),
3354
+ url: resolveColorTokenValue(context, tokens?.url),
3355
+ variable: resolveColorTokenValue(context, tokens?.variable)
3356
+ };
3357
+ }
3358
+ const defaultColorPalette = color.color;
3359
+ function mixChannel(b, s, weight) {
3360
+ const delta = (s - b) * weight;
3361
+ return b + delta;
3362
+ }
3363
+ function mix(b, s, weight) {
3364
+ return {
3365
+ r: mixChannel(b.r, s.r, weight),
3366
+ g: mixChannel(b.g, s.g, weight),
3367
+ b: mixChannel(b.b, s.b, weight)
3368
+ };
3369
+ }
3370
+ function multiplyChannel(b, s) {
3371
+ return b * s;
3372
+ }
3373
+ function multiply(b, s) {
3374
+ return {
3375
+ r: multiplyChannel(b.r / 255, s.r / 255) * 255,
3376
+ g: multiplyChannel(b.g / 255, s.g / 255) * 255,
3377
+ b: multiplyChannel(b.b / 255, s.b / 255) * 255
3378
+ };
3379
+ }
3380
+ function screenChannel(b, s) {
3381
+ return b + s - b * s;
3382
+ }
3383
+ function screen(b, s) {
3384
+ return {
3385
+ r: screenChannel(b.r / 255, s.r / 255) * 255,
3386
+ g: screenChannel(b.g / 255, s.g / 255) * 255,
3387
+ b: screenChannel(b.b / 255, s.b / 255) * 255
3388
+ };
3389
+ }
3390
+ function lerp(x, y, a) {
3391
+ return x * (1 - a) + y * a;
3392
+ }
3393
+ function invlerp(x, y, a) {
3394
+ return clamp((a - x) / (y - x));
3395
+ }
3396
+ function clamp(a, min = 0, max = 1) {
3397
+ return Math.min(max, Math.max(min, a));
3398
+ }
3399
+ function range(x1, y1, x2, y2, a) {
3400
+ return lerp(x2, y2, invlerp(x1, y1, a));
3401
+ }
3402
+ function round(value) {
3403
+ return Math.round(value);
3404
+ }
3405
+ function hexToRgb(hex) {
3406
+ if (hex.length === 4) {
3407
+ const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
3408
+ return {
3409
+ r: parseInt(hexR + hexR, 16),
3410
+ g: parseInt(hexG + hexG, 16),
3411
+ b: parseInt(hexB + hexB, 16)
3412
+ };
3413
+ }
3414
+ return {
3415
+ r: parseInt(hex.slice(1, 3), 16),
3416
+ g: parseInt(hex.slice(3, 5), 16),
3417
+ b: parseInt(hex.slice(5, 7), 16)
3418
+ };
2909
3419
  }
2910
3420
  function rgbaToRGBA(rgba2) {
2911
3421
  const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
@@ -3002,155 +3512,1175 @@ function rgba(color2, a) {
3002
3512
  const rgb = parseColor(color2);
3003
3513
  return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
3004
3514
  }
3005
- const THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
3006
- "transparent",
3007
- "default",
3008
- "neutral",
3009
- "primary",
3010
- // deprecated
3011
- "suggest",
3012
- "positive",
3013
- "caution",
3014
- "critical"
3015
- ], THEME_COLOR_STATE_TONES = [
3016
- "default",
3017
- "neutral",
3018
- "primary",
3019
- // deprecated
3020
- "suggest",
3021
- "positive",
3022
- "caution",
3023
- "critical"
3024
- ], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = color.COLOR_HUES;
3025
- function isColorBlendModeValue(str) {
3026
- return THEME_COLOR_BLEND_MODES.includes(str);
3515
+ const RGB_RANGE = [0, 255];
3516
+ function mixThemeColor(value, options) {
3517
+ const {
3518
+ blendMode
3519
+ } = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
3520
+ r: [black2.r, white2.r],
3521
+ g: [black2.g, white2.g],
3522
+ b: [black2.b, white2.b]
3523
+ }, convertedBgColor = {
3524
+ r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
3525
+ g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
3526
+ b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
3527
+ }, convertedColor = {
3528
+ r: clamp(range(...paletteRange.r, ...RGB_RANGE, color2.r), ...RGB_RANGE),
3529
+ g: clamp(range(...paletteRange.g, ...RGB_RANGE, color2.g), ...RGB_RANGE),
3530
+ b: clamp(range(...paletteRange.b, ...RGB_RANGE, color2.b), ...RGB_RANGE)
3531
+ }, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor), v = {
3532
+ r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
3533
+ g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
3534
+ b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
3535
+ };
3536
+ return rgbToHex(v);
3027
3537
  }
3028
- function isColorHueKey(str) {
3029
- return color.COLOR_HUES.includes(str);
3538
+ function renderColorValue(str, options) {
3539
+ const {
3540
+ bg,
3541
+ blendMode,
3542
+ colorPalette
3543
+ } = options;
3544
+ if (bg === "white")
3545
+ throw new Error("Cannot blend with white background");
3546
+ const node = parseTokenValue(str);
3547
+ if (!node || node.type !== "color")
3548
+ throw new Error(`Invalid color token value: ${str}`);
3549
+ let hex = "";
3550
+ if (node.key === "black" && (hex = renderColorHex(colorPalette.black)), node.key === "white" && (hex = renderColorHex(colorPalette.white)), node.hue && node.tint && (hex = renderColorHex(colorPalette[node.hue][node.tint])), !hex)
3551
+ throw new Error(`Invalid color token value: ${str}`);
3552
+ const hexBeforeMix = hex, mixOptions = {
3553
+ blendMode,
3554
+ bg,
3555
+ black: renderColorHex(colorPalette.black),
3556
+ // opacity: node.opacity,
3557
+ white: renderColorHex(colorPalette.white)
3558
+ };
3559
+ try {
3560
+ if (hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0) {
3561
+ const from = hexToRgb(bg), to = hexToRgb(hex);
3562
+ hex = rgbToHex(mix(from, to, node.mix));
3563
+ }
3564
+ } catch (err) {
3565
+ throw console.warn("could not blend", hex, mixOptions), err;
3566
+ }
3567
+ return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
3030
3568
  }
3031
- function isColorTintKey(str) {
3032
- return color.COLOR_TINTS.includes(str);
3569
+ function renderColorHex(color2) {
3570
+ return typeof color2 == "string" ? color2 : color2.hex;
3033
3571
  }
3034
- function isColorButtonMode(str) {
3035
- return THEME_COLOR_BUTTON_MODES.includes(str);
3572
+ function renderThemeColorSchemes(value, config) {
3573
+ const colorPalette = config?.palette ?? defaultColorPalette;
3574
+ return {
3575
+ light: renderThemeColorScheme(colorPalette, value.light),
3576
+ dark: renderThemeColorScheme(colorPalette, value.dark)
3577
+ };
3036
3578
  }
3037
- const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "accent/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to", "status/dot", "status/icon"], COLOR_CONFIG_CARD_KEYS = [...COLOR_CONFIG_STATE_KEYS, "_hue", "bg", "fg", "border", "focusRing", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient"], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
3038
- function isColorConfigBaseTone(str) {
3039
- return COLOR_CONFIG_CARD_TONES.includes(str);
3579
+ function renderThemeColorScheme(colorPalette, value) {
3580
+ const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, {
3581
+ colorPalette
3582
+ }), renderedDefaultTone = renderThemeColor(defaultTone, {
3583
+ colorPalette
3584
+ }), bg = renderedDefaultTone.bg;
3585
+ if (bg === "white")
3586
+ throw new Error("Cannot blend with white background");
3587
+ return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(([k]) => k !== "default" && k !== "transparent").map(([k, v]) => [k, renderThemeColor(v, {
3588
+ bg,
3589
+ colorPalette
3590
+ })])]);
3040
3591
  }
3041
- function isColorConfigBaseKey(str) {
3042
- return COLOR_CONFIG_CARD_KEYS.includes(str);
3592
+ function renderThemeColor(value, options) {
3593
+ const {
3594
+ colorPalette,
3595
+ bg
3596
+ } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
3597
+ colorPalette,
3598
+ bg,
3599
+ blendMode
3600
+ }), colorOptions = {
3601
+ colorPalette,
3602
+ bg: baseBg,
3603
+ blendMode
3604
+ }, button = renderThemeColorButton(value.button, {
3605
+ baseBg,
3606
+ blendMode,
3607
+ colorPalette
3608
+ }), selectable = renderThemeColorSelectable(value.selectable, {
3609
+ colorPalette,
3610
+ baseBg,
3611
+ blendMode
3612
+ }), shadow = {
3613
+ outline: renderColorValue(value.shadow.outline, colorOptions),
3614
+ umbra: renderColorValue(value.shadow.umbra, {
3615
+ ...colorOptions,
3616
+ bg: void 0,
3617
+ colorPalette: {
3618
+ ...colorPalette,
3619
+ black: "#000000"
3620
+ }
3621
+ }),
3622
+ penumbra: renderColorValue(value.shadow.penumbra, {
3623
+ ...colorOptions,
3624
+ bg: void 0,
3625
+ colorPalette: {
3626
+ ...colorPalette,
3627
+ black: "#000000"
3628
+ }
3629
+ }),
3630
+ ambient: renderColorValue(value.shadow.ambient, {
3631
+ ...colorOptions,
3632
+ bg: void 0,
3633
+ colorPalette: {
3634
+ ...colorPalette,
3635
+ black: "#000000"
3636
+ }
3637
+ })
3638
+ };
3639
+ return {
3640
+ _blend: blendMode,
3641
+ _dark: value._dark,
3642
+ accent: {
3643
+ fg: renderColorValue(value.accent.fg, colorOptions)
3644
+ },
3645
+ avatar: renderThemeColorAvatar(value.avatar, {
3646
+ baseBg,
3647
+ colorPalette,
3648
+ blendMode
3649
+ }),
3650
+ backdrop: renderColorValue(value.backdrop, colorOptions),
3651
+ badge: renderThemeColorBadge(value.badge, {
3652
+ baseBg,
3653
+ colorPalette,
3654
+ blendMode
3655
+ }),
3656
+ bg: baseBg,
3657
+ border: renderColorValue(value.border, colorOptions),
3658
+ button,
3659
+ code: {
3660
+ bg: renderColorValue(value.code.bg, colorOptions),
3661
+ fg: renderColorValue(value.code.fg, colorOptions)
3662
+ },
3663
+ fg: renderColorValue(value.fg, colorOptions),
3664
+ focusRing: renderColorValue(value.focusRing, colorOptions),
3665
+ icon: renderColorValue(value.icon, colorOptions),
3666
+ input: renderThemeColorInput(value.input, {
3667
+ baseBg,
3668
+ colorPalette,
3669
+ blendMode
3670
+ }),
3671
+ kbd: renderThemeColorKBD(value.kbd, {
3672
+ baseBg,
3673
+ colorPalette,
3674
+ blendMode
3675
+ }),
3676
+ link: {
3677
+ fg: renderColorValue(value.link.fg, colorOptions)
3678
+ },
3679
+ muted: {
3680
+ bg: renderColorValue(value.muted.bg, colorOptions),
3681
+ fg: renderColorValue(value.muted.fg, colorOptions)
3682
+ },
3683
+ shadow,
3684
+ skeleton: {
3685
+ from: renderColorValue(value.skeleton.from, colorOptions),
3686
+ to: renderColorValue(value.skeleton.to, colorOptions)
3687
+ },
3688
+ syntax: renderSyntaxColorTheme(value.syntax, {
3689
+ baseBg,
3690
+ colorPalette,
3691
+ blendMode
3692
+ }),
3693
+ selectable
3694
+ };
3043
3695
  }
3044
- function isColorConfigStateKey(str) {
3045
- return COLOR_CONFIG_STATE_KEYS.includes(str);
3696
+ function renderThemeColorKBD(value, options) {
3697
+ const {
3698
+ baseBg,
3699
+ blendMode,
3700
+ colorPalette
3701
+ } = options, rootOptions = {
3702
+ bg: baseBg,
3703
+ blendMode,
3704
+ colorPalette
3705
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3706
+ bg,
3707
+ blendMode,
3708
+ colorPalette
3709
+ };
3710
+ return {
3711
+ bg,
3712
+ fg: renderColorValue(value.fg, colorOptions),
3713
+ border: renderColorValue(value.border, colorOptions)
3714
+ };
3046
3715
  }
3047
- function isColorConfigStateTone(str) {
3048
- return COLOR_CONFIG_STATE_TONES.includes(str);
3716
+ function renderThemeColorAvatar(value, options) {
3717
+ const colorAvatar = {};
3718
+ for (const hue of color.COLOR_HUES)
3719
+ colorAvatar[hue] = renderThemeColorAvatarColor(value[hue], options);
3720
+ return colorAvatar;
3049
3721
  }
3050
- function isColorConfigBlendKey(str) {
3051
- return COLOR_CONFIG_BLEND_KEYS.includes(str);
3722
+ function renderThemeColorAvatarColor(value, options) {
3723
+ const {
3724
+ baseBg,
3725
+ blendMode: rootBlendMode,
3726
+ colorPalette
3727
+ } = options, blendMode = value._blend || "multiply", rootOptions = {
3728
+ bg: baseBg,
3729
+ blendMode: rootBlendMode,
3730
+ colorPalette
3731
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3732
+ bg,
3733
+ blendMode,
3734
+ colorPalette
3735
+ };
3736
+ return {
3737
+ _blend: blendMode,
3738
+ bg,
3739
+ fg: renderColorValue(value.fg, colorOptions)
3740
+ };
3052
3741
  }
3053
- function isColorValue(str) {
3054
- return str === "black" || str === "white";
3742
+ function renderThemeColorBadge(value, options) {
3743
+ const colorBadge = {};
3744
+ for (const tone of THEME_COLOR_STATE_TONES)
3745
+ colorBadge[tone] = renderThemeColorBadgeColor(value[tone], options);
3746
+ return colorBadge;
3055
3747
  }
3056
- function isColorOpacityValue(str) {
3057
- return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
3748
+ function renderThemeColorBadgeColor(value, options) {
3749
+ const {
3750
+ baseBg,
3751
+ blendMode: rootBlendMode,
3752
+ colorPalette
3753
+ } = options, blendMode = rootBlendMode, rootOptions = {
3754
+ bg: baseBg,
3755
+ blendMode: rootBlendMode,
3756
+ colorPalette
3757
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3758
+ bg,
3759
+ blendMode,
3760
+ colorPalette
3761
+ };
3762
+ return {
3763
+ bg,
3764
+ dot: renderColorValue(value.dot, colorOptions),
3765
+ fg: renderColorValue(value.fg, colorOptions),
3766
+ icon: renderColorValue(value.icon, colorOptions)
3767
+ };
3058
3768
  }
3059
- function isColorMixPercentValue(str) {
3060
- return /^\d+%$/.test(str);
3769
+ function renderThemeColorButton(value, options) {
3770
+ return {
3771
+ default: renderThemeColorButtonTones(value.default, options),
3772
+ ghost: renderThemeColorButtonTones(value.ghost, options),
3773
+ bleed: renderThemeColorButtonTones(value.bleed, options)
3774
+ };
3061
3775
  }
3062
- function parseTokenValue(str) {
3063
- const segments = str.split("/");
3064
- let nextSegment = segments.shift() || "";
3065
- const [segment0, segment0mix] = nextSegment.split(" ");
3066
- if (isColorTintKey(segment0)) {
3067
- const tint = segment0, segment1 = segments.shift() || "";
3068
- if (isColorMixPercentValue(segment0mix)) {
3069
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
3070
- return {
3071
- type: "color",
3072
- tint,
3073
- mix: mix2
3074
- };
3075
- }
3076
- if (isColorOpacityValue(segment1)) {
3077
- const opacity = Number(segment1);
3078
- return {
3079
- type: "color",
3080
- tint,
3081
- opacity
3082
- };
3083
- }
3084
- return {
3085
- type: "color",
3086
- tint
3087
- };
3088
- }
3089
- if (isColorValue(segment0)) {
3090
- const key = segment0, segment1 = segments.shift() || "";
3091
- if (isColorMixPercentValue(segment0mix)) {
3092
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
3093
- return {
3094
- type: "color",
3095
- key,
3096
- mix: mix2
3097
- };
3776
+ function renderThemeColorButtonTones(value, options) {
3777
+ const colorButtonMode = {};
3778
+ for (const tone of THEME_COLOR_STATE_TONES)
3779
+ colorButtonMode[tone] = renderThemeColorButtonStates(value[tone], options);
3780
+ return colorButtonMode;
3781
+ }
3782
+ function renderThemeColorButtonStates(value, options) {
3783
+ return {
3784
+ enabled: renderThemeColorState(value.enabled, options),
3785
+ hovered: renderThemeColorState(value.hovered, options),
3786
+ pressed: renderThemeColorState(value.pressed, options),
3787
+ selected: renderThemeColorState(value.selected, options),
3788
+ disabled: renderThemeColorState(value.disabled, options)
3789
+ };
3790
+ }
3791
+ function renderThemeColorState(value, options) {
3792
+ const {
3793
+ baseBg,
3794
+ blendMode: rootBlendMode,
3795
+ colorPalette
3796
+ } = options, blendMode = value._blend || "multiply", rootOptions = {
3797
+ bg: baseBg,
3798
+ blendMode: rootBlendMode,
3799
+ colorPalette
3800
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3801
+ bg,
3802
+ blendMode,
3803
+ colorPalette
3804
+ };
3805
+ return {
3806
+ _blend: blendMode,
3807
+ accent: {
3808
+ fg: renderColorValue(value.accent.fg, colorOptions)
3809
+ },
3810
+ avatar: renderThemeColorAvatar(value.avatar, {
3811
+ baseBg: bg,
3812
+ colorPalette,
3813
+ blendMode
3814
+ }),
3815
+ badge: renderThemeColorBadge(value.badge, {
3816
+ baseBg: bg,
3817
+ colorPalette,
3818
+ blendMode
3819
+ }),
3820
+ bg,
3821
+ border: renderColorValue(value.border, colorOptions),
3822
+ code: {
3823
+ bg: renderColorValue(value.code.bg, colorOptions),
3824
+ fg: renderColorValue(value.code.fg, colorOptions)
3825
+ },
3826
+ fg: renderColorValue(value.fg, colorOptions),
3827
+ icon: renderColorValue(value.icon, colorOptions),
3828
+ link: {
3829
+ fg: renderColorValue(value.link.fg, colorOptions)
3830
+ },
3831
+ muted: {
3832
+ bg: renderColorValue(value.muted.bg, colorOptions),
3833
+ fg: renderColorValue(value.muted.fg, colorOptions)
3834
+ },
3835
+ kbd: {
3836
+ bg: renderColorValue(value.kbd.bg, colorOptions),
3837
+ fg: renderColorValue(value.kbd.fg, colorOptions),
3838
+ border: renderColorValue(value.kbd.border, colorOptions)
3839
+ },
3840
+ skeleton: {
3841
+ from: renderColorValue(value.skeleton?.from, colorOptions),
3842
+ to: renderColorValue(value.skeleton?.to, colorOptions)
3098
3843
  }
3099
- if (isColorOpacityValue(segment1)) {
3100
- const opacity = Number(segment1);
3844
+ };
3845
+ }
3846
+ function renderThemeColorInput(value, options) {
3847
+ return {
3848
+ default: renderInputStatesColorTheme(value.default, options),
3849
+ invalid: renderInputStatesColorTheme(value.invalid, options)
3850
+ };
3851
+ }
3852
+ function renderInputStatesColorTheme(value, options) {
3853
+ return {
3854
+ enabled: renderInputStateColorTheme(value.enabled, options),
3855
+ hovered: renderInputStateColorTheme(value.hovered, options),
3856
+ readOnly: renderInputStateColorTheme(value.readOnly, options),
3857
+ disabled: renderInputStateColorTheme(value.disabled, options)
3858
+ };
3859
+ }
3860
+ function renderInputStateColorTheme(value, options) {
3861
+ const {
3862
+ baseBg,
3863
+ blendMode: rootBlendMode,
3864
+ colorPalette
3865
+ } = options, blendMode = value._blend || "multiply", rootOptions = {
3866
+ colorPalette,
3867
+ bg: baseBg,
3868
+ blendMode: rootBlendMode
3869
+ }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3870
+ colorPalette,
3871
+ bg,
3872
+ blendMode
3873
+ };
3874
+ return {
3875
+ _blend: blendMode,
3876
+ bg,
3877
+ border: renderColorValue(value.border, colorOptions),
3878
+ fg: renderColorValue(value.fg, colorOptions),
3879
+ muted: {
3880
+ bg: renderColorValue(value.muted.bg, colorOptions)
3881
+ },
3882
+ placeholder: renderColorValue(value.placeholder, colorOptions)
3883
+ };
3884
+ }
3885
+ function renderThemeColorSelectable(value, options) {
3886
+ const colorSelectable = {};
3887
+ for (const tone of THEME_COLOR_STATE_TONES)
3888
+ colorSelectable[tone] = renderThemeColorSelectableStates(value[tone], options);
3889
+ return colorSelectable;
3890
+ }
3891
+ function renderThemeColorSelectableStates(value, options) {
3892
+ return {
3893
+ enabled: renderThemeColorState(value.enabled, options),
3894
+ hovered: renderThemeColorState(value.hovered, options),
3895
+ pressed: renderThemeColorState(value.pressed, options),
3896
+ selected: renderThemeColorState(value.selected, options),
3897
+ disabled: renderThemeColorState(value.disabled, options)
3898
+ };
3899
+ }
3900
+ function renderSyntaxColorTheme(value, options) {
3901
+ const {
3902
+ colorPalette,
3903
+ baseBg,
3904
+ blendMode
3905
+ } = options, colorOptions = {
3906
+ colorPalette,
3907
+ bg: baseBg,
3908
+ blendMode
3909
+ };
3910
+ return {
3911
+ atrule: renderColorValue(value.atrule, colorOptions),
3912
+ attrName: renderColorValue(value.attrName, colorOptions),
3913
+ attrValue: renderColorValue(value.attrValue, colorOptions),
3914
+ attribute: renderColorValue(value.attribute, colorOptions),
3915
+ boolean: renderColorValue(value.boolean, colorOptions),
3916
+ builtin: renderColorValue(value.builtin, colorOptions),
3917
+ cdata: renderColorValue(value.cdata, colorOptions),
3918
+ char: renderColorValue(value.char, colorOptions),
3919
+ class: renderColorValue(value.class, colorOptions),
3920
+ className: renderColorValue(value.className, colorOptions),
3921
+ comment: renderColorValue(value.comment, colorOptions),
3922
+ constant: renderColorValue(value.constant, colorOptions),
3923
+ deleted: renderColorValue(value.deleted, colorOptions),
3924
+ doctype: renderColorValue(value.doctype, colorOptions),
3925
+ entity: renderColorValue(value.entity, colorOptions),
3926
+ function: renderColorValue(value.function, colorOptions),
3927
+ hexcode: renderColorValue(value.hexcode, colorOptions),
3928
+ id: renderColorValue(value.id, colorOptions),
3929
+ important: renderColorValue(value.important, colorOptions),
3930
+ inserted: renderColorValue(value.inserted, colorOptions),
3931
+ keyword: renderColorValue(value.keyword, colorOptions),
3932
+ number: renderColorValue(value.number, colorOptions),
3933
+ operator: renderColorValue(value.operator, colorOptions),
3934
+ prolog: renderColorValue(value.prolog, colorOptions),
3935
+ property: renderColorValue(value.property, colorOptions),
3936
+ pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
3937
+ pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
3938
+ punctuation: renderColorValue(value.punctuation, colorOptions),
3939
+ regex: renderColorValue(value.regex, colorOptions),
3940
+ selector: renderColorValue(value.selector, colorOptions),
3941
+ string: renderColorValue(value.string, colorOptions),
3942
+ symbol: renderColorValue(value.symbol, colorOptions),
3943
+ tag: renderColorValue(value.tag, colorOptions),
3944
+ unit: renderColorValue(value.unit, colorOptions),
3945
+ url: renderColorValue(value.url, colorOptions),
3946
+ variable: renderColorValue(value.variable, colorOptions)
3947
+ };
3948
+ }
3949
+ function buildTheme(config) {
3950
+ const colorTheme = buildColorTheme(config), v2 = {
3951
+ _version: 2,
3952
+ avatar: config?.avatar ?? defaultThemeConfig.avatar,
3953
+ button: config?.button ?? defaultThemeConfig.button,
3954
+ card: config?.card ?? defaultThemeConfig.card,
3955
+ // How colors are generated:
3956
+ // 1. Merge custom tokens with default tokens
3957
+ // 2. Generate tree of color keys (gray/500, black, white, etc.)
3958
+ // 3. Apply mixing and render to hex values
3959
+ // render(build(mergeWithDefaults()))
3960
+ color: renderThemeColorSchemes(colorTheme, config),
3961
+ container: config?.container ?? defaultThemeConfig.container,
3962
+ font: config?.font ?? defaultThemeFonts$1,
3963
+ input: config?.input ?? defaultThemeConfig.input,
3964
+ layer: config?.layer ?? defaultThemeConfig.layer,
3965
+ media: config?.media ?? defaultThemeConfig.media,
3966
+ radius: config?.radius ?? defaultThemeConfig.radius,
3967
+ shadow: config?.shadow ?? defaultThemeConfig.shadow,
3968
+ space: config?.space ?? defaultThemeConfig.space,
3969
+ style: config?.style ?? defaultThemeConfig.style
3970
+ };
3971
+ return v2_v0(v2);
3972
+ }
3973
+ const AVATAR_SIZE = [0, 1, 2, 3], CONTAINER_SCALE = [0, 1, 2, 3, 4, 5], CONTAINER = [...CONTAINER_SCALE, "auto"], RADIUS = [0, 1, 2, 3, 4, 5, 6], SPACE = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], FONT_CODE_SIZE = [0, 1, 2, 3, 4], FONT_HEADING_SIZE = [0, 1, 2, 3, 4, 5], FONT_LABEL_SIZE = [0, 1, 2, 3, 4, 5], FONT_TEXT_SIZE = [0, 1, 2, 3, 4], SHADOW = [0, 1, 2, 3, 4, 5], HUES = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], TINTS = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950], RE_PERCENTAGE = /^([0-9]+)%/, RE_OPACITY = /^(1|0\.[0-9]+)?/;
3974
+ function _parseColorToken(str, options) {
3975
+ const {
3976
+ defaultHue
3977
+ } = options;
3978
+ let cursor = 0;
3979
+ return parseColorNode();
3980
+ function _consume(s) {
3981
+ if (str.startsWith(s, cursor))
3982
+ return cursor += s.length, s;
3983
+ }
3984
+ function _peek() {
3985
+ return str[cursor];
3986
+ }
3987
+ function parseColorNode() {
3988
+ ignoreWhitespace();
3989
+ let v = _consume("black") || _consume("white");
3990
+ if (v)
3101
3991
  return {
3102
3992
  type: "color",
3103
- key,
3104
- opacity
3993
+ name: v,
3994
+ opacity: parseOpacity() ?? 1,
3995
+ mix: parseMix() ?? 1
3105
3996
  };
3106
- }
3107
- return {
3108
- type: "color",
3109
- key
3110
- };
3111
- }
3112
- if (isColorHueKey(segment0)) {
3113
- const hue = segment0;
3114
- nextSegment = segments.shift() || "";
3115
- const [segment1, segment1mix] = nextSegment.split(" ");
3116
- if (isColorTintKey(segment1)) {
3117
- const tint = segment1, segment2 = segments.shift() || "";
3118
- if (isColorMixPercentValue(segment1mix)) {
3119
- const mix2 = Number(segment1mix.slice(0, -1)) / 100;
3120
- return {
3121
- type: "color",
3122
- hue,
3123
- tint,
3124
- mix: mix2
3125
- };
3126
- }
3127
- if (isColorOpacityValue(segment2)) {
3128
- const opacity = Number(segment2);
3997
+ for (const hue of HUES)
3998
+ if (v = _consume(String(hue)), v) {
3999
+ if (_peek() !== "-")
4000
+ throw new Error('Expected "-" after hue key');
4001
+ cursor += 1;
4002
+ const tint2 = parseTint();
4003
+ if (!tint2)
4004
+ throw new Error("Expected tint after hue");
3129
4005
  return {
3130
- type: "color",
4006
+ type: "tint",
3131
4007
  hue,
3132
- tint,
3133
- opacity
4008
+ tint: tint2,
4009
+ opacity: parseOpacity() ?? 1,
4010
+ mix: parseMix() ?? 1
3134
4011
  };
3135
4012
  }
4013
+ const tint = parseTint();
4014
+ if (tint)
3136
4015
  return {
3137
- type: "color",
3138
- hue,
3139
- tint
4016
+ type: "tint",
4017
+ hue: defaultHue,
4018
+ tint,
4019
+ opacity: parseOpacity() ?? 1,
4020
+ mix: parseMix() ?? 1
4021
+ };
4022
+ if (str === "inherit")
4023
+ return {
4024
+ type: "inherit"
3140
4025
  };
4026
+ throw new Error(`Invalid color: ${str}`);
4027
+ }
4028
+ function parseTint() {
4029
+ ignoreWhitespace();
4030
+ let v = Number(str.slice(cursor, cursor + 3));
4031
+ if (TINTS.includes(v))
4032
+ return cursor += 3, v;
4033
+ if (v = Number(str.slice(cursor, cursor + 2)), TINTS.includes(v))
4034
+ return cursor += 2, v;
4035
+ }
4036
+ function parseMix() {
4037
+ ignoreWhitespace();
4038
+ const match = RE_PERCENTAGE.exec(str.slice(cursor));
4039
+ if (match)
4040
+ return cursor += match[0].length, parseFloat(match[1]) / 100;
4041
+ }
4042
+ function parseOpacity() {
4043
+ if (ignoreWhitespace(), _peek() === "/") {
4044
+ cursor += 1;
4045
+ const match = RE_OPACITY.exec(str.slice(cursor));
4046
+ if (match)
4047
+ return cursor += match[0].length, parseFloat(match[1]);
4048
+ cursor -= 1;
3141
4049
  }
3142
- return {
3143
- type: "hue",
3144
- value: hue
3145
- };
3146
4050
  }
3147
- if (isColorBlendModeValue(segment0))
3148
- return {
3149
- type: "blendMode",
3150
- value: segment0
3151
- };
4051
+ function ignoreWhitespace() {
4052
+ for (; _peek() === " "; )
4053
+ cursor++;
4054
+ }
4055
+ }
4056
+ const defaultThemeFonts = {
4057
+ code: {
4058
+ family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
4059
+ weight: {
4060
+ regular: 400,
4061
+ medium: 500,
4062
+ semibold: 600,
4063
+ bold: 700
4064
+ },
4065
+ scale: [{
4066
+ ascenderHeight: 4,
4067
+ descenderHeight: 4,
4068
+ fontSize: 10,
4069
+ iconSize: 17,
4070
+ lineHeight: 15,
4071
+ letterSpacing: 0,
4072
+ customIconSize: 12
4073
+ }, {
4074
+ ascenderHeight: 5,
4075
+ descenderHeight: 5,
4076
+ fontSize: 13,
4077
+ iconSize: 21,
4078
+ lineHeight: 19,
4079
+ letterSpacing: 0,
4080
+ customIconSize: 16
4081
+ }, {
4082
+ ascenderHeight: 6,
4083
+ descenderHeight: 6,
4084
+ fontSize: 16,
4085
+ iconSize: 25,
4086
+ lineHeight: 23,
4087
+ letterSpacing: 0,
4088
+ customIconSize: 20
4089
+ }, {
4090
+ ascenderHeight: 7,
4091
+ descenderHeight: 7,
4092
+ fontSize: 19,
4093
+ iconSize: 29,
4094
+ lineHeight: 27,
4095
+ letterSpacing: 0,
4096
+ customIconSize: 24
4097
+ }, {
4098
+ ascenderHeight: 8,
4099
+ descenderHeight: 8,
4100
+ fontSize: 22,
4101
+ iconSize: 33,
4102
+ lineHeight: 31,
4103
+ letterSpacing: 0,
4104
+ customIconSize: 28
4105
+ }]
4106
+ },
4107
+ heading: {
4108
+ family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
4109
+ featureSettings: "'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'zero' 1",
4110
+ weight: {
4111
+ regular: 600,
4112
+ medium: 700,
4113
+ semibold: 800,
4114
+ bold: 900
4115
+ },
4116
+ scale: [{
4117
+ ascenderHeight: 5,
4118
+ descenderHeight: 5,
4119
+ fontSize: 13,
4120
+ iconSize: 17,
4121
+ lineHeight: 19,
4122
+ letterSpacing: 0,
4123
+ customIconSize: 12
4124
+ }, {
4125
+ ascenderHeight: 6,
4126
+ descenderHeight: 6,
4127
+ fontSize: 16,
4128
+ iconSize: 25,
4129
+ lineHeight: 23,
4130
+ letterSpacing: 0,
4131
+ customIconSize: 20
4132
+ }, {
4133
+ ascenderHeight: 7,
4134
+ descenderHeight: 7,
4135
+ fontSize: 21,
4136
+ iconSize: 33,
4137
+ lineHeight: 29,
4138
+ letterSpacing: -0.25,
4139
+ customIconSize: 28
4140
+ }, {
4141
+ ascenderHeight: 8,
4142
+ descenderHeight: 8,
4143
+ fontSize: 27,
4144
+ iconSize: 41,
4145
+ lineHeight: 35,
4146
+ letterSpacing: -0.5,
4147
+ customIconSize: 36
4148
+ }, {
4149
+ ascenderHeight: 9.5,
4150
+ descenderHeight: 8.5,
4151
+ fontSize: 33,
4152
+ iconSize: 49,
4153
+ lineHeight: 41,
4154
+ letterSpacing: -1,
4155
+ customIconSize: 44
4156
+ }, {
4157
+ ascenderHeight: 10.5,
4158
+ descenderHeight: 9.5,
4159
+ fontSize: 38,
4160
+ iconSize: 53,
4161
+ lineHeight: 47,
4162
+ letterSpacing: -1,
4163
+ customIconSize: 48
4164
+ }]
4165
+ },
4166
+ label: {
4167
+ family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
4168
+ weight: {
4169
+ regular: 500,
4170
+ medium: 600,
4171
+ semibold: 700,
4172
+ bold: 800
4173
+ },
4174
+ scale: [{
4175
+ ascenderHeight: 2,
4176
+ descenderHeight: 2,
4177
+ fontSize: 8.1,
4178
+ iconSize: 13,
4179
+ lineHeight: 10,
4180
+ letterSpacing: 0.5,
4181
+ customIconSize: 8
4182
+ }, {
4183
+ ascenderHeight: 1.5,
4184
+ descenderHeight: 2.5,
4185
+ fontSize: 9.5,
4186
+ iconSize: 15,
4187
+ lineHeight: 11,
4188
+ letterSpacing: 0.5,
4189
+ customIconSize: 10
4190
+ }, {
4191
+ ascenderHeight: 2,
4192
+ descenderHeight: 2,
4193
+ fontSize: 10.8,
4194
+ iconSize: 17,
4195
+ lineHeight: 12,
4196
+ letterSpacing: 0.5,
4197
+ customIconSize: 12
4198
+ }, {
4199
+ ascenderHeight: 2,
4200
+ descenderHeight: 2,
4201
+ fontSize: 12.25,
4202
+ iconSize: 19,
4203
+ lineHeight: 13,
4204
+ letterSpacing: 0.5,
4205
+ customIconSize: 14
4206
+ }, {
4207
+ ascenderHeight: 1.5,
4208
+ descenderHeight: 2.5,
4209
+ fontSize: 13.6,
4210
+ iconSize: 21,
4211
+ lineHeight: 14,
4212
+ letterSpacing: 0.5,
4213
+ customIconSize: 16
4214
+ }, {
4215
+ ascenderHeight: 2,
4216
+ descenderHeight: 2,
4217
+ fontSize: 15,
4218
+ iconSize: 23,
4219
+ lineHeight: 15,
4220
+ letterSpacing: 0.5,
4221
+ customIconSize: 18
4222
+ }]
4223
+ },
4224
+ text: {
4225
+ family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
4226
+ weight: {
4227
+ regular: 400,
4228
+ medium: 500,
4229
+ semibold: 600,
4230
+ bold: 700
4231
+ },
4232
+ scale: [{
4233
+ ascenderHeight: 4,
4234
+ descenderHeight: 4,
4235
+ fontSize: 10,
4236
+ iconSize: 17,
4237
+ lineHeight: 15,
4238
+ letterSpacing: 0,
4239
+ customIconSize: 12
4240
+ }, {
4241
+ ascenderHeight: 5,
4242
+ descenderHeight: 5,
4243
+ fontSize: 13,
4244
+ iconSize: 21,
4245
+ lineHeight: 19,
4246
+ letterSpacing: 0,
4247
+ customIconSize: 16
4248
+ }, {
4249
+ ascenderHeight: 6,
4250
+ descenderHeight: 6,
4251
+ fontSize: 15,
4252
+ iconSize: 25,
4253
+ lineHeight: 23,
4254
+ letterSpacing: 0,
4255
+ customIconSize: 20
4256
+ }, {
4257
+ ascenderHeight: 7,
4258
+ descenderHeight: 7,
4259
+ fontSize: 18,
4260
+ iconSize: 29,
4261
+ lineHeight: 27,
4262
+ letterSpacing: 0,
4263
+ customIconSize: 24
4264
+ }, {
4265
+ ascenderHeight: 8,
4266
+ descenderHeight: 8,
4267
+ fontSize: 21,
4268
+ iconSize: 33,
4269
+ lineHeight: 31,
4270
+ letterSpacing: 0,
4271
+ customIconSize: 28
4272
+ }]
4273
+ }
4274
+ }, defaultTokens = {
4275
+ color: {
4276
+ "*": {
4277
+ backdrop: ["gray-100/0.5", "black/0.5"],
4278
+ code: {
4279
+ bg: ["50", "950"],
4280
+ fg: ["700", "300"],
4281
+ token: {
4282
+ atrule: ["purple-600", "purple-400"],
4283
+ attrName: ["green-600", "green-400"],
4284
+ attrValue: ["yellow-600", "yellow-400"],
4285
+ attribute: ["yellow-600", "yellow-400"],
4286
+ boolean: ["purple-600", "purple-400"],
4287
+ builtin: ["purple-600", "purple-400"],
4288
+ cdata: ["yellow-600", "yellow-400"],
4289
+ char: ["yellow-600", "yellow-400"],
4290
+ class: ["orange-600", "orange-400"],
4291
+ className: ["cyan-600", "cyan-400"],
4292
+ comment: ["gray-400", "gray-600"],
4293
+ constant: ["purple-600", "purple-400"],
4294
+ deleted: ["red-600", "red-400"],
4295
+ entity: ["red-600", "red-400"],
4296
+ function: ["green-600", "green-400"],
4297
+ hexcode: ["blue-600", "blue-400"],
4298
+ id: ["purple-600", "purple-400"],
4299
+ important: ["purple-600", "purple-400"],
4300
+ inserted: ["green-600", "green-400"],
4301
+ keyword: ["magenta-600", "magenta-400"],
4302
+ number: ["purple-600", "purple-400"],
4303
+ operator: ["magenta-600", "magenta-400"],
4304
+ prolog: ["gray-600", "gray-400"],
4305
+ property: ["blue-600", "blue-400"],
4306
+ pseudoClass: ["yellow-600", "yellow-400"],
4307
+ pseudoElement: ["yellow-600", "yellow-400"],
4308
+ punctuation: ["gray-600", "gray-400"],
4309
+ regex: ["blue-600", "blue-400"],
4310
+ selector: ["red-600", "red-400"],
4311
+ string: ["yellow-600", "yellow-400"],
4312
+ symbol: ["purple-600", "purple-400"],
4313
+ tag: ["red-600", "red-400"],
4314
+ unit: ["orange-600", "orange-400"],
4315
+ url: ["red-600", "red-400"],
4316
+ variable: ["red-600", "red-400"]
4317
+ }
4318
+ },
4319
+ focusRing: ["blue-500", "blue-500"],
4320
+ link: {
4321
+ fg: ["blue-600", "blue-400"]
4322
+ },
4323
+ shadow: {
4324
+ outline: ["600/0.3", "500/0.4"],
4325
+ umbra: ["600/0.1", "black/0.2"],
4326
+ penumbra: ["600/0.07", "black/0.14"],
4327
+ ambient: ["600/0.06", "black/0.12"]
4328
+ },
4329
+ skeleton: {
4330
+ from: ["200 70%", "800 35%"],
4331
+ to: ["200 40%", "800 50%"]
4332
+ },
4333
+ variant: {
4334
+ tinted: {
4335
+ "*": {
4336
+ bg: {
4337
+ 0: ["100 75%", "900 75%"],
4338
+ 4: ["300", "700"]
4339
+ },
4340
+ border: {
4341
+ 0: ["200", "700 50%"],
4342
+ 4: ["300 75%", "500"]
4343
+ },
4344
+ fg: {
4345
+ 0: ["900", "100"],
4346
+ 4: ["700", "300"]
4347
+ }
4348
+ },
4349
+ primary: {
4350
+ _hue: "blue",
4351
+ bg: {
4352
+ 0: ["inherit", "inherit"]
4353
+ }
4354
+ },
4355
+ suggest: {
4356
+ _hue: "purple",
4357
+ bg: {
4358
+ 0: ["inherit", "inherit"]
4359
+ }
4360
+ },
4361
+ positive: {
4362
+ _hue: "green",
4363
+ bg: {
4364
+ 0: ["inherit", "inherit"]
4365
+ }
4366
+ },
4367
+ caution: {
4368
+ _hue: "yellow",
4369
+ bg: {
4370
+ 0: ["inherit", "inherit"]
4371
+ }
4372
+ },
4373
+ critical: {
4374
+ _hue: "red",
4375
+ bg: {
4376
+ 0: ["inherit", "inherit"]
4377
+ }
4378
+ }
4379
+ },
4380
+ solid: {
4381
+ "*": {
4382
+ bg: {
4383
+ 0: ["500", "400"],
4384
+ 4: ["600", "300"]
4385
+ },
4386
+ border: {
4387
+ 0: ["400", "200"],
4388
+ 4: ["500", "100"]
4389
+ },
4390
+ fg: {
4391
+ 0: ["white", "black"],
4392
+ 4: ["200", "700"]
4393
+ }
4394
+ },
4395
+ default: {
4396
+ bg: {
4397
+ 0: ["800", "200"],
4398
+ 4: ["black", "white"]
4399
+ },
4400
+ border: {
4401
+ 0: ["700", "300"],
4402
+ 4: ["800", "200"]
4403
+ }
4404
+ },
4405
+ primary: {
4406
+ _hue: "blue"
4407
+ },
4408
+ suggest: {
4409
+ _hue: "purple"
4410
+ },
4411
+ positive: {
4412
+ _hue: "green"
4413
+ },
4414
+ caution: {
4415
+ _hue: "yellow"
4416
+ },
4417
+ critical: {
4418
+ _hue: "red"
4419
+ }
4420
+ }
4421
+ }
4422
+ },
4423
+ transparent: {
4424
+ variant: {
4425
+ tinted: {
4426
+ "*": {
4427
+ bg: {
4428
+ 0: ["gray-50", "black"],
4429
+ 4: ["200", "800"]
4430
+ },
4431
+ border: {
4432
+ 0: ["200 50%", "800 50%"],
4433
+ 4: ["300", "600"]
4434
+ },
4435
+ fg: {
4436
+ 0: ["black", "100"],
4437
+ 4: ["700", "400"]
4438
+ }
4439
+ }
4440
+ }
4441
+ }
4442
+ },
4443
+ default: {
4444
+ variant: {
4445
+ tinted: {
4446
+ "*": {
4447
+ bg: {
4448
+ 0: ["white", "950"],
4449
+ 4: ["200", "800"]
4450
+ },
4451
+ border: {
4452
+ 0: ["200 50%", "800 50%"],
4453
+ 4: ["300 75%", "600"]
4454
+ },
4455
+ fg: {
4456
+ 0: ["black", "white"],
4457
+ 4: ["600", "400"]
4458
+ }
4459
+ }
4460
+ }
4461
+ }
4462
+ },
4463
+ primary: {
4464
+ _hue: "blue"
4465
+ },
4466
+ suggest: {
4467
+ _hue: "purple"
4468
+ },
4469
+ positive: {
4470
+ _hue: "green"
4471
+ },
4472
+ caution: {
4473
+ _hue: "yellow"
4474
+ },
4475
+ critical: {
4476
+ _hue: "red"
4477
+ }
4478
+ }
4479
+ };
4480
+ function merge(...records) {
4481
+ return records.filter(Boolean).reduce(_merge, {});
4482
+ }
4483
+ function _merge(acc, source) {
4484
+ for (const key of Object.keys(source)) {
4485
+ const prevValue = acc[key], nextValue = source[key];
4486
+ isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
4487
+ }
4488
+ return acc;
4489
+ }
4490
+ function isRecord(value) {
4491
+ return value !== null && typeof value == "object" && !Array.isArray(value);
4492
+ }
4493
+ const defaultElementTokens = {
4494
+ bg: {
4495
+ 0: ["950", "50"],
4496
+ 4: ["700", "300"]
4497
+ },
4498
+ border: {
4499
+ 0: ["700", "300"],
4500
+ 4: ["400", "600"]
4501
+ },
4502
+ fg: {
4503
+ 0: ["100", "900"],
4504
+ 4: ["400", "600"]
4505
+ }
4506
+ };
4507
+ function resolveTokens(tokens = {}) {
4508
+ return {
4509
+ color: {
4510
+ "*": resolveCardColorTokens(tokens.color?.["*"]),
4511
+ ...THEME_COLOR_CARD_TONES.reduce((acc, tone) => ({
4512
+ ...acc,
4513
+ [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
4514
+ }), {})
4515
+ }
4516
+ };
4517
+ }
4518
+ function resolveCardColorTokens(tokens) {
4519
+ return {
4520
+ _hue: tokens?._hue ?? "gray",
4521
+ avatar: {
4522
+ gray: {
4523
+ _hue: tokens?.avatar?.gray?._hue ?? "gray",
4524
+ bg: tokens?.avatar?.gray?.bg ?? ["500", "400"],
4525
+ fg: tokens?.avatar?.gray?.fg ?? ["white", "900"]
4526
+ },
4527
+ blue: {
4528
+ _hue: tokens?.avatar?.blue?._hue ?? "blue",
4529
+ bg: tokens?.avatar?.blue?.bg ?? ["500", "400"],
4530
+ fg: tokens?.avatar?.blue?.fg ?? ["white", "900"]
4531
+ },
4532
+ purple: {
4533
+ _hue: tokens?.avatar?.purple?._hue ?? "purple",
4534
+ bg: tokens?.avatar?.purple?.bg ?? ["500", "400"],
4535
+ fg: tokens?.avatar?.purple?.fg ?? ["white", "900"]
4536
+ },
4537
+ magenta: {
4538
+ _hue: tokens?.avatar?.magenta?._hue ?? "magenta",
4539
+ bg: tokens?.avatar?.magenta?.bg ?? ["500", "400"],
4540
+ fg: tokens?.avatar?.magenta?.fg ?? ["white", "900"]
4541
+ },
4542
+ red: {
4543
+ _hue: tokens?.avatar?.red?._hue ?? "red",
4544
+ bg: tokens?.avatar?.red?.bg ?? ["500", "400"],
4545
+ fg: tokens?.avatar?.red?.fg ?? ["white", "900"]
4546
+ },
4547
+ orange: {
4548
+ _hue: tokens?.avatar?.orange?._hue ?? "orange",
4549
+ bg: tokens?.avatar?.orange?.bg ?? ["500", "400"],
4550
+ fg: tokens?.avatar?.orange?.fg ?? ["white", "900"]
4551
+ },
4552
+ yellow: {
4553
+ _hue: tokens?.avatar?.yellow?._hue ?? "yellow",
4554
+ bg: tokens?.avatar?.yellow?.bg ?? ["500", "400"],
4555
+ fg: tokens?.avatar?.yellow?.fg ?? ["white", "900"]
4556
+ },
4557
+ green: {
4558
+ _hue: tokens?.avatar?.green?._hue ?? "green",
4559
+ bg: tokens?.avatar?.green?.bg ?? ["500", "400"],
4560
+ fg: tokens?.avatar?.green?.fg ?? ["white", "900"]
4561
+ },
4562
+ cyan: {
4563
+ _hue: tokens?.avatar?.cyan?._hue ?? "cyan",
4564
+ bg: tokens?.avatar?.cyan?.bg ?? ["500", "400"],
4565
+ fg: tokens?.avatar?.cyan?.fg ?? ["white", "900"]
4566
+ }
4567
+ },
4568
+ backdrop: tokens?.backdrop ?? ["100", "900"],
4569
+ code: {
4570
+ bg: tokens?.code?.bg ?? ["50", "950"],
4571
+ fg: tokens?.code?.fg ?? ["600", "400"],
4572
+ token: {
4573
+ atrule: tokens?.code?.token?.atrule ?? ["600", "400"],
4574
+ attribute: tokens?.code?.token?.attribute ?? ["600", "400"],
4575
+ attrName: tokens?.code?.token?.attrName ?? ["600", "400"],
4576
+ attrValue: tokens?.code?.token?.attrValue ?? ["600", "400"],
4577
+ boolean: tokens?.code?.token?.boolean ?? ["600", "400"],
4578
+ builtin: tokens?.code?.token?.builtin ?? ["600", "400"],
4579
+ cdata: tokens?.code?.token?.cdata ?? ["600", "400"],
4580
+ char: tokens?.code?.token?.char ?? ["600", "400"],
4581
+ class: tokens?.code?.token?.class ?? ["600", "400"],
4582
+ className: tokens?.code?.token?.className ?? ["600", "400"],
4583
+ comment: tokens?.code?.token?.comment ?? ["400", "600"],
4584
+ constant: tokens?.code?.token?.constant ?? ["600", "400"],
4585
+ deleted: tokens?.code?.token?.deleted ?? ["600", "400"],
4586
+ doctype: tokens?.code?.token?.doctype ?? ["600", "400"],
4587
+ entity: tokens?.code?.token?.entity ?? ["600", "400"],
4588
+ function: tokens?.code?.token?.function ?? ["600", "400"],
4589
+ hexcode: tokens?.code?.token?.hexcode ?? ["600", "400"],
4590
+ id: tokens?.code?.token?.id ?? ["600", "400"],
4591
+ important: tokens?.code?.token?.important ?? ["600", "400"],
4592
+ inserted: tokens?.code?.token?.inserted ?? ["600", "400"],
4593
+ keyword: tokens?.code?.token?.keyword ?? ["600", "400"],
4594
+ number: tokens?.code?.token?.number ?? ["600", "400"],
4595
+ operator: tokens?.code?.token?.operator ?? ["600", "400"],
4596
+ prolog: tokens?.code?.token?.prolog ?? ["600", "400"],
4597
+ property: tokens?.code?.token?.property ?? ["600", "400"],
4598
+ pseudoClass: tokens?.code?.token?.pseudoClass ?? ["600", "400"],
4599
+ pseudoElement: tokens?.code?.token?.pseudoElement ?? ["600", "400"],
4600
+ punctuation: tokens?.code?.token?.punctuation ?? ["600", "400"],
4601
+ regex: tokens?.code?.token?.regex ?? ["600", "400"],
4602
+ selector: tokens?.code?.token?.selector ?? ["600", "400"],
4603
+ string: tokens?.code?.token?.string ?? ["600", "400"],
4604
+ symbol: tokens?.code?.token?.symbol ?? ["600", "400"],
4605
+ tag: tokens?.code?.token?.tag ?? ["600", "400"],
4606
+ unit: tokens?.code?.token?.unit ?? ["600", "400"],
4607
+ url: tokens?.code?.token?.url ?? ["600", "400"],
4608
+ variable: tokens?.code?.token?.variable ?? ["600", "400"]
4609
+ }
4610
+ },
4611
+ focusRing: tokens?.focusRing ?? ["500", "500"],
4612
+ link: {
4613
+ fg: tokens?.link?.fg ?? ["600", "400"]
4614
+ },
4615
+ shadow: {
4616
+ outline: tokens?.shadow?.outline ?? ["500", "500"],
4617
+ umbra: tokens?.shadow?.umbra ?? ["500", "500"],
4618
+ penumbra: tokens?.shadow?.penumbra ?? ["500", "500"],
4619
+ ambient: tokens?.shadow?.ambient ?? ["500", "500"]
4620
+ },
4621
+ skeleton: {
4622
+ from: tokens?.skeleton?.from ?? ["100", "900"],
4623
+ to: tokens?.skeleton?.to ?? ["50", "950"]
4624
+ },
4625
+ variant: {
4626
+ solid: {
4627
+ "*": resolveElementTokens(tokens?.variant?.solid?.["*"]),
4628
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.solid?.["*"], tokens?.variant?.solid?.[tone])), acc), {})
4629
+ },
4630
+ tinted: {
4631
+ "*": resolveElementTokens(tokens?.variant?.tinted?.["*"]),
4632
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
4633
+ }
4634
+ }
4635
+ };
4636
+ }
4637
+ function resolveElementTokens(tokens) {
4638
+ return {
4639
+ _hue: tokens?._hue ?? "gray",
4640
+ bg: {
4641
+ 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
4642
+ 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
4643
+ },
4644
+ border: {
4645
+ 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
4646
+ 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
4647
+ },
4648
+ fg: {
4649
+ 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
4650
+ 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
4651
+ }
4652
+ };
4653
+ }
4654
+ function buildTheme_v3(options) {
4655
+ const {
4656
+ v2
4657
+ } = options ?? {}, tokens = resolveTokens(options?.tokens ?? defaultTokens);
4658
+ return {
4659
+ _version: 3,
4660
+ _tokens: tokens,
4661
+ avatar: v2?.avatar ?? defaultThemeConfig.avatar,
4662
+ button: v2?.button ?? defaultThemeConfig.button,
4663
+ card: v2?.card ?? defaultThemeConfig.card,
4664
+ color: tokens.color,
4665
+ container: v2?.container ?? defaultThemeConfig.container,
4666
+ font: defaultThemeFonts,
4667
+ input: v2?.input ?? defaultThemeConfig.input,
4668
+ layer: v2?.layer ?? defaultThemeConfig.layer,
4669
+ media: v2?.media ?? defaultThemeConfig.media,
4670
+ palette: {
4671
+ black: color.black,
4672
+ white: color.white,
4673
+ hues: color.hues
4674
+ },
4675
+ // TODO
4676
+ radius: v2?.radius ?? defaultThemeConfig.radius,
4677
+ // TODO
4678
+ shadow: v2?.shadow ?? defaultThemeConfig.shadow,
4679
+ // TODO
4680
+ space: v2?.space ?? defaultThemeConfig.space
4681
+ };
3152
4682
  }
3153
- const cache = /* @__PURE__ */ new WeakMap();
4683
+ const COLOR_VARIANTS = ["tinted", "solid"], AVATAR_COLORS = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], cache = /* @__PURE__ */ new WeakMap();
3154
4684
  function getTheme_v2(theme) {
3155
4685
  if (theme.sanity.v2?._resolved) return theme.sanity.v2;
3156
4686
  const cached_v2 = cache.get(theme);