@sanity/ui 3.0.0-static.1 → 3.0.0-static.2

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 (660) hide show
  1. package/LICENSE +1 -1
  2. package/bin/ui.js +0 -1
  3. package/dist/_chunks-cjs/_visual-editing.js +3059 -0
  4. package/dist/_chunks-cjs/_visual-editing.js.map +1 -0
  5. package/dist/_chunks-cjs/buildCommand.js +14 -3524
  6. package/dist/_chunks-cjs/buildCommand.js.map +1 -1
  7. package/dist/_chunks-cjs/refractor.js +27 -0
  8. package/dist/_chunks-cjs/refractor.js.map +1 -0
  9. package/dist/_chunks-cjs/v3_v2.js +251 -0
  10. package/dist/_chunks-cjs/v3_v2.js.map +1 -0
  11. package/dist/_chunks-es/_visual-editing.mjs +3066 -0
  12. package/dist/_chunks-es/_visual-editing.mjs.map +1 -0
  13. package/dist/_chunks-es/refractor.mjs +26 -0
  14. package/dist/_chunks-es/refractor.mjs.map +1 -0
  15. package/dist/_chunks-es/v3_v2.mjs +252 -0
  16. package/dist/_chunks-es/v3_v2.mjs.map +1 -0
  17. package/dist/_visual-editing.d.mts +806 -0
  18. package/dist/_visual-editing.d.ts +806 -0
  19. package/dist/_visual-editing.js +31 -0
  20. package/dist/_visual-editing.js.map +1 -0
  21. package/dist/_visual-editing.mjs +31 -0
  22. package/dist/_visual-editing.mjs.map +1 -0
  23. package/dist/cli.js +337 -5
  24. package/dist/cli.js.map +1 -1
  25. package/dist/css.d.mts +1446 -373
  26. package/dist/css.d.ts +1446 -373
  27. package/dist/css.js +2665 -1747
  28. package/dist/css.js.map +1 -1
  29. package/dist/css.mjs +2651 -1732
  30. package/dist/css.mjs.map +1 -1
  31. package/dist/index.d.mts +418 -520
  32. package/dist/index.d.ts +418 -520
  33. package/dist/index.js +737 -4617
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +633 -4522
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/sanity-palette.css +9 -0
  38. package/dist/sanity-theme.css +1 -25
  39. package/dist/system.css +596 -404
  40. package/dist/theme.d.mts +431 -110
  41. package/dist/theme.d.ts +431 -110
  42. package/dist/theme.js +1216 -2430
  43. package/dist/theme.js.map +1 -1
  44. package/dist/theme.mjs +1238 -2450
  45. package/dist/theme.mjs.map +1 -1
  46. package/exports/_visual-editing.ts +31 -0
  47. package/package.json +92 -81
  48. package/src/{css/cli → cli}/buildCommand.ts +21 -9
  49. package/src/{css/cli → cli}/index.ts +1 -1
  50. package/src/core/StyleTags.tsx +24 -0
  51. package/src/core/_compat/index.ts +8 -1
  52. package/src/core/_compat/styles/_responsive.ts +19 -0
  53. package/src/core/_compat/styles/index.ts +1 -5
  54. package/src/core/{theme → _compat/theme}/theme.test.tsx +2 -2
  55. package/src/core/{theme → _compat/theme}/themeColorProvider.tsx +4 -2
  56. package/src/core/{theme → _compat/theme}/themeContext.ts +1 -1
  57. package/src/core/{theme → _compat/theme}/themeProvider.tsx +10 -11
  58. package/src/core/{theme → _compat/theme}/useRootTheme.ts +1 -0
  59. package/src/core/{theme → _compat/theme}/useTheme.ts +2 -2
  60. package/src/core/_compat/types.ts +11 -11
  61. package/src/core/components/autocomplete/__mocks__/apiStore.ts +1 -1
  62. package/src/core/components/autocomplete/__workshop__/async.tsx +1 -0
  63. package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +4 -2
  64. package/src/core/components/autocomplete/__workshop__/custom.tsx +3 -2
  65. package/src/core/components/autocomplete/__workshop__/example.tsx +3 -2
  66. package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +1 -0
  67. package/src/core/components/autocomplete/autocomplete.tsx +54 -61
  68. package/src/core/components/autocomplete/autocompleteOption.tsx +5 -4
  69. package/src/core/components/autocomplete/types.ts +2 -2
  70. package/src/core/components/breadcrumbs/__workshop__/example.tsx +7 -0
  71. package/src/core/components/breadcrumbs/breadcrumbs.tsx +32 -16
  72. package/src/core/components/dialog/__workshop__/activate.tsx +2 -1
  73. package/src/core/components/dialog/__workshop__/nested.tsx +3 -3
  74. package/src/core/components/dialog/__workshop__/onScroll.tsx +2 -2
  75. package/src/core/components/dialog/__workshop__/panes.tsx +1 -0
  76. package/src/core/components/dialog/__workshop__/position.tsx +2 -1
  77. package/src/core/components/dialog/__workshop__/props.tsx +2 -1
  78. package/src/core/components/dialog/__workshop__/wrapped.tsx +1 -3
  79. package/src/core/components/dialog/dialog.tsx +50 -27
  80. package/src/core/components/dialog/dialogProvider.tsx +4 -3
  81. package/src/core/components/dialog/useDialog.ts +1 -0
  82. package/src/core/components/hotkeys/hotkeys.tsx +20 -14
  83. package/src/core/components/menu/__workshop__/asComponent.tsx +2 -1
  84. package/src/core/components/menu/__workshop__/avatarMenu.tsx +1 -0
  85. package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +1 -0
  86. package/src/core/components/menu/__workshop__/customSelectedState.tsx +1 -0
  87. package/src/core/components/menu/__workshop__/menuButton.tsx +2 -1
  88. package/src/core/components/menu/__workshop__/shouldFocus.tsx +1 -0
  89. package/src/core/components/menu/__workshop__/tones.tsx +7 -7
  90. package/src/core/components/menu/menu.test.tsx +4 -5
  91. package/src/core/components/menu/menu.tsx +49 -22
  92. package/src/core/components/menu/menuButton.tsx +47 -61
  93. package/src/core/components/menu/menuContext.ts +6 -4
  94. package/src/core/components/menu/menuDivider.tsx +9 -3
  95. package/src/core/components/menu/menuGroup.tsx +50 -26
  96. package/src/core/components/menu/menuItem.tsx +31 -38
  97. package/src/core/components/menu/useMenu.ts +1 -0
  98. package/src/core/components/menu/useMenuController.ts +18 -7
  99. package/src/core/components/skeleton/__workshop__/delay.tsx +2 -1
  100. package/src/core/components/skeleton/__workshop__/skeleton.tsx +2 -1
  101. package/src/core/components/skeleton/skeleton.tsx +4 -3
  102. package/src/core/components/skeleton/textSkeleton.tsx +11 -25
  103. package/src/core/components/tab/tab.tsx +21 -14
  104. package/src/core/components/tab/tabList.tsx +24 -11
  105. package/src/core/components/tab/tabPanel.tsx +5 -4
  106. package/src/core/components/toast/__workshop__/hook.tsx +1 -1
  107. package/src/core/components/toast/__workshop__/toast.tsx +2 -1
  108. package/src/core/components/toast/toast.test.tsx +0 -1
  109. package/src/core/components/toast/toast.tsx +130 -40
  110. package/src/core/components/toast/toastLayer.tsx +38 -0
  111. package/src/core/components/toast/toastProvider.tsx +60 -140
  112. package/src/core/components/toast/toastState.ts +6 -0
  113. package/src/core/components/toast/types.ts +10 -2
  114. package/src/core/components/toast/useToast.ts +1 -0
  115. package/src/core/components/tree/__workshop__/basic.tsx +1 -0
  116. package/src/core/components/tree/__workshop__/tabFromElement.tsx +2 -1
  117. package/src/core/components/tree/tree.tsx +16 -13
  118. package/src/core/components/tree/treeGroup.tsx +5 -7
  119. package/src/core/components/tree/treeItem.tsx +41 -34
  120. package/src/core/components/tree/useTree.ts +1 -0
  121. package/src/core/constants.ts +45 -23
  122. package/src/core/helpers/focus.ts +3 -3
  123. package/src/core/helpers/index.ts +1 -0
  124. package/src/core/helpers/props.ts +10 -0
  125. package/src/core/hooks/useArrayProp.ts +19 -15
  126. package/src/core/hooks/useClickOutside.test.tsx +3 -4
  127. package/src/core/hooks/useClickOutside.ts +1 -0
  128. package/src/core/hooks/useClickOutsideEvent.test.tsx +0 -1
  129. package/src/core/hooks/useClickOutsideEvent.ts +2 -1
  130. package/src/core/hooks/useDelayed.test.ts +2 -1
  131. package/src/core/hooks/useDelayedState.ts +2 -3
  132. package/src/core/hooks/useElementRect/__workshop__/example.tsx +3 -2
  133. package/src/core/hooks/useElementSize.ts +2 -1
  134. package/src/core/hooks/useForwardedRef.ts +2 -2
  135. package/src/core/hooks/useGlobalKeyDown.ts +9 -4
  136. package/src/core/hooks/useMatchMedia.ts +1 -1
  137. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +3 -2
  138. package/src/core/hooks/useMediaIndex/useMediaIndex.ts +2 -1
  139. package/src/core/hooks/usePrefersDark.hydration.test.tsx +0 -1
  140. package/src/core/hooks/usePrefersDark.test.tsx +2 -1
  141. package/src/core/hooks/usePrefersDark.ts +1 -1
  142. package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -1
  143. package/src/core/hooks/usePrefersReducedMotion.test.tsx +2 -1
  144. package/src/core/hooks/usePrefersReducedMotion.ts +1 -1
  145. package/src/core/index.ts +2 -3
  146. package/src/core/lib/createGlobalScopedContext.ts +2 -1
  147. package/src/core/lib/globalScope.ts +0 -1
  148. package/src/core/primitives/_selectable/selectable.tsx +9 -5
  149. package/src/core/primitives/avatar/__workshop__/asButton.tsx +2 -1
  150. package/src/core/primitives/avatar/__workshop__/stack.tsx +2 -1
  151. package/src/core/primitives/avatar/__workshop__/withinButton.tsx +4 -3
  152. package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +26 -23
  153. package/src/core/primitives/avatar/avatar.tsx +42 -80
  154. package/src/core/primitives/avatar/avatarCounter.tsx +26 -57
  155. package/src/core/primitives/avatar/avatarStack.tsx +37 -55
  156. package/src/core/primitives/avatar/types.ts +1 -0
  157. package/src/core/primitives/badge/__workshop__/props.tsx +2 -1
  158. package/src/core/primitives/badge/__workshop__/tones.tsx +2 -1
  159. package/src/core/primitives/badge/badge.test.tsx +1 -0
  160. package/src/core/primitives/badge/badge.tsx +10 -5
  161. package/src/core/primitives/box/__workshop__/props.tsx +2 -1
  162. package/src/core/primitives/box/box.tsx +45 -12
  163. package/src/core/primitives/button/__workshop__/custom.tsx +7 -4
  164. package/src/core/primitives/button/__workshop__/disabled.tsx +1 -0
  165. package/src/core/primitives/button/__workshop__/props.tsx +7 -2
  166. package/src/core/primitives/button/__workshop__/stacked.tsx +2 -1
  167. package/src/core/primitives/button/button.test.tsx +1 -0
  168. package/src/core/primitives/button/button.tsx +137 -113
  169. package/src/core/primitives/card/__workshop__/allTones.tsx +21 -21
  170. package/src/core/primitives/card/__workshop__/asButton.tsx +44 -25
  171. package/src/core/primitives/card/__workshop__/asComponent.tsx +2 -2
  172. package/src/core/primitives/card/__workshop__/checkered.tsx +17 -7
  173. package/src/core/primitives/card/__workshop__/interactive.tsx +10 -3
  174. package/src/core/primitives/card/__workshop__/listNavigation.tsx +6 -3
  175. package/src/core/primitives/card/__workshop__/props.tsx +13 -7
  176. package/src/core/primitives/card/__workshop__/selected.tsx +11 -9
  177. package/src/core/primitives/card/card.tsx +47 -55
  178. package/src/core/primitives/card/types.ts +1 -0
  179. package/src/core/primitives/checkbox/__workshop__/tones.tsx +6 -0
  180. package/src/core/primitives/checkbox/checkbox.tsx +9 -5
  181. package/src/core/primitives/code/__workshop__/props.tsx +3 -2
  182. package/src/core/primitives/code/code.tsx +11 -11
  183. package/src/core/primitives/code/refractor.tsx +20 -0
  184. package/src/core/primitives/container/__workshop__/example.tsx +3 -2
  185. package/src/core/primitives/container/container.tsx +7 -4
  186. package/src/core/primitives/flex/__workshop__/example.tsx +5 -4
  187. package/src/core/primitives/flex/__workshop__/gap.tsx +6 -6
  188. package/src/core/primitives/flex/flex.tsx +9 -12
  189. package/src/core/primitives/grid/__workshop__/responsive.tsx +12 -12
  190. package/src/core/primitives/grid/grid.tsx +7 -11
  191. package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +13 -25
  192. package/src/core/primitives/heading/__workshop__/plain.tsx +3 -2
  193. package/src/core/primitives/heading/heading.tsx +19 -39
  194. package/src/core/primitives/inline/__workshop__/plain.tsx +5 -4
  195. package/src/core/primitives/inline/inline.tsx +10 -7
  196. package/src/core/primitives/kbd/kbd.tsx +8 -6
  197. package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +13 -7
  198. package/src/core/primitives/label/__workshop__/plain.tsx +22 -8
  199. package/src/core/primitives/label/label.tsx +26 -50
  200. package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +3 -2
  201. package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +5 -4
  202. package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +1 -1
  203. package/src/core/primitives/popover/__workshop__/PlainStory.tsx +3 -2
  204. package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +5 -2
  205. package/src/core/primitives/popover/__workshop__/TestStory.tsx +5 -4
  206. package/src/core/primitives/popover/floating-ui/size.ts +2 -1
  207. package/src/core/primitives/popover/helpers.ts +4 -3
  208. package/src/core/primitives/popover/popover.tsx +51 -44
  209. package/src/core/primitives/popover/popoverCard.tsx +22 -27
  210. package/src/core/primitives/radio/__workshop__/plain.tsx +2 -2
  211. package/src/core/primitives/radio/radio.tsx +10 -11
  212. package/src/core/primitives/select/__workshop__/plain.tsx +5 -2
  213. package/src/core/primitives/select/__workshop__/readOnly.tsx +1 -1
  214. package/src/core/primitives/select/select.tsx +40 -41
  215. package/src/core/primitives/spinner/__workshop__/Props.tsx +2 -1
  216. package/src/core/primitives/spinner/spinner.tsx +5 -3
  217. package/src/core/primitives/stack/__workshop__/plain.tsx +2 -1
  218. package/src/core/primitives/stack/stack.tsx +10 -11
  219. package/src/core/primitives/switch/switch.tsx +22 -13
  220. package/src/core/primitives/text/__workshop__/colored.tsx +8 -14
  221. package/src/core/primitives/text/__workshop__/example.tsx +8 -7
  222. package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +11 -21
  223. package/src/core/primitives/text/text.tsx +20 -38
  224. package/src/core/primitives/textArea/__workshop__/plain.tsx +4 -3
  225. package/src/core/primitives/textArea/textArea.tsx +28 -75
  226. package/src/core/primitives/textInput/__workshop__/index.ts +0 -5
  227. package/src/core/primitives/textInput/__workshop__/plain.tsx +8 -3
  228. package/src/core/primitives/textInput/__workshop__/readOnly.tsx +6 -2
  229. package/src/core/primitives/textInput/__workshop__/tones.tsx +38 -0
  230. package/src/core/primitives/textInput/__workshop__/typed.tsx +2 -1
  231. package/src/core/primitives/textInput/textInput.tsx +133 -220
  232. package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +2 -1
  233. package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +2 -1
  234. package/src/core/primitives/tooltip/__workshop__/props.tsx +8 -3
  235. package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +2 -1
  236. package/src/core/primitives/tooltip/tooltip.test.tsx +4 -2
  237. package/src/core/primitives/tooltip/tooltip.tsx +64 -61
  238. package/src/core/primitives/tooltip/tooltipCard.tsx +31 -26
  239. package/src/core/primitives/tooltip/tooltipDelayGroup/index.ts +1 -1
  240. package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +4 -6
  241. package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +0 -1
  242. package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +1 -0
  243. package/src/core/primitives/types.ts +5 -5
  244. package/src/core/types/box.ts +0 -3
  245. package/src/core/types/button.ts +2 -0
  246. package/src/core/types/flex.ts +0 -4
  247. package/src/core/types/grid.ts +5 -7
  248. package/src/core/types/gridItem.ts +4 -9
  249. package/src/core/types/index.ts +1 -0
  250. package/src/core/types/props.ts +18 -0
  251. package/src/core/types/selectable.ts +1 -0
  252. package/src/core/utils/arrow/arrow.tsx +34 -97
  253. package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -1
  254. package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +4 -3
  255. package/src/core/utils/boundaryElement/index.ts +1 -1
  256. package/src/core/utils/boundaryElement/useBoundaryElement.ts +1 -0
  257. package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +5 -3
  258. package/src/core/utils/elementQuery/elementQuery.tsx +21 -21
  259. package/src/core/utils/errorBoundary.tsx +5 -4
  260. package/src/core/utils/getElementRef.ts +26 -0
  261. package/src/core/utils/layer/__workshop__/multipleRoots.tsx +1 -0
  262. package/src/core/utils/layer/__workshop__/nested.tsx +1 -0
  263. package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +1 -0
  264. package/src/core/utils/layer/index.ts +1 -1
  265. package/src/core/utils/layer/layer.test.tsx +0 -1
  266. package/src/core/utils/layer/layer.tsx +15 -11
  267. package/src/core/utils/layer/layerProvider.tsx +6 -5
  268. package/src/core/utils/layer/useLayer.ts +1 -0
  269. package/src/core/utils/portal/portal.test.tsx +0 -1
  270. package/src/core/utils/portal/portal.ts +4 -2
  271. package/src/core/utils/portal/portalProvider.tsx +4 -3
  272. package/src/core/utils/portal/usePortal.ts +1 -0
  273. package/src/core/utils/spanWithTextOverflow.tsx +10 -0
  274. package/src/core/utils/srOnly/srOnly.tsx +17 -18
  275. package/src/core/utils/virtualList/virtualList.tsx +55 -37
  276. package/src/css/_resp.ts +4 -1
  277. package/src/css/compile/compilePalette.ts +60 -0
  278. package/src/css/compile/compileRule.ts +45 -13
  279. package/src/css/compile/compileRules.test.ts +35 -0
  280. package/src/css/compile/compileRules.ts +14 -30
  281. package/src/css/compile/compileTheme.ts +8 -505
  282. package/src/css/compile/compileTheme_v3.ts +410 -0
  283. package/src/css/compile/types.ts +6 -0
  284. package/src/css/components/breadcrumbs/breadcrumbs.ts +1 -1
  285. package/src/css/components/dialog/{classes.ts → dialog.ts} +7 -7
  286. package/src/css/components/dialog/index.ts +1 -1
  287. package/src/css/components/dialog/rules.ts +2 -1
  288. package/src/css/components/menu/menu.ts +5 -1
  289. package/src/css/components/menu/rules.ts +6 -1
  290. package/src/css/components/skeleton/rules.ts +28 -22
  291. package/src/css/components/skeleton/skeleton.ts +5 -5
  292. package/src/css/components/skeleton/types.ts +2 -0
  293. package/src/css/components/toast/index.ts +1 -0
  294. package/src/css/components/toast/rules.ts +17 -68
  295. package/src/css/components/toast/toast.ts +21 -0
  296. package/src/css/components/tree/rules.ts +3 -2
  297. package/src/css/components/tree/tree.ts +1 -1
  298. package/src/css/composeClassNames.ts +12 -2
  299. package/src/css/index.ts +12 -23
  300. package/src/css/primitives/_arrow/_arrow.ts +14 -0
  301. package/src/css/primitives/_arrow/index.ts +1 -0
  302. package/src/css/primitives/_arrow/rules.ts +71 -0
  303. package/src/css/primitives/_input/index.ts +2 -0
  304. package/src/css/primitives/_input/input.ts +25 -0
  305. package/src/css/primitives/_input/rules.ts +163 -0
  306. package/src/css/primitives/_input/types.ts +12 -0
  307. package/src/css/primitives/{selectable → _selectable}/__style.ts +1 -1
  308. package/src/css/primitives/_selectable/_contants.ts +11 -0
  309. package/src/css/primitives/_selectable/rules.ts +129 -0
  310. package/src/css/primitives/_selectable/selectable.ts +9 -0
  311. package/src/css/primitives/_selectable/types.ts +8 -0
  312. package/src/css/primitives/avatar/avatar.ts +10 -15
  313. package/src/css/primitives/avatar/rules.ts +85 -99
  314. package/src/css/primitives/avatar/types.ts +1 -2
  315. package/src/css/primitives/badge/badge.ts +2 -2
  316. package/src/css/primitives/badge/rules.ts +13 -16
  317. package/src/css/primitives/badge/types.ts +2 -2
  318. package/src/css/primitives/box/box.ts +24 -14
  319. package/src/css/primitives/box/rules.ts +5 -2
  320. package/src/css/primitives/box/types.ts +24 -19
  321. package/src/css/primitives/button/_constants.ts +17 -0
  322. package/src/css/primitives/button/button.ts +27 -12
  323. package/src/css/primitives/button/rules.ts +275 -40
  324. package/src/css/primitives/card/_constants.ts +13 -0
  325. package/src/css/primitives/card/card.ts +8 -13
  326. package/src/css/primitives/card/index.ts +1 -0
  327. package/src/css/primitives/card/rules.ts +353 -123
  328. package/src/css/primitives/card/types.ts +11 -0
  329. package/src/css/primitives/checkbox/checkbox.ts +2 -2
  330. package/src/css/primitives/checkbox/rules.ts +31 -15
  331. package/src/css/primitives/code/code.ts +2 -2
  332. package/src/css/primitives/code/rules.ts +27 -2
  333. package/src/css/primitives/code/types.ts +1 -1
  334. package/src/css/primitives/container/container.ts +2 -2
  335. package/src/css/primitives/container/types.ts +1 -0
  336. package/src/css/primitives/heading/heading.ts +3 -2
  337. package/src/css/primitives/heading/rules.ts +77 -6
  338. package/src/css/primitives/heading/types.ts +2 -2
  339. package/src/css/primitives/kbd/kbd.ts +2 -2
  340. package/src/css/primitives/kbd/rules.ts +5 -5
  341. package/src/css/primitives/kbd/types.ts +3 -1
  342. package/src/css/primitives/label/label.ts +2 -2
  343. package/src/css/primitives/label/rules.ts +54 -2
  344. package/src/css/primitives/label/types.ts +1 -1
  345. package/src/css/primitives/popover/popover.ts +1 -1
  346. package/src/css/primitives/radio/radio.ts +1 -1
  347. package/src/css/primitives/radio/rules.ts +117 -1
  348. package/src/css/primitives/select/index.ts +1 -0
  349. package/src/css/primitives/select/rules.ts +18 -1
  350. package/src/css/primitives/select/select.ts +8 -2
  351. package/src/css/primitives/select/types.ts +5 -0
  352. package/src/css/primitives/spinner/spinner.ts +2 -2
  353. package/src/css/primitives/switch/rules.ts +264 -56
  354. package/src/css/primitives/switch/switch.ts +17 -1
  355. package/src/css/primitives/text/rules.ts +93 -4
  356. package/src/css/primitives/text/text.ts +3 -2
  357. package/src/css/primitives/text/types.ts +2 -2
  358. package/src/css/primitives/textArea/index.ts +1 -0
  359. package/src/css/primitives/textArea/rules.ts +3 -1
  360. package/src/css/primitives/textArea/textArea.ts +4 -2
  361. package/src/css/primitives/textArea/types.ts +5 -0
  362. package/src/css/primitives/textInput/rules.ts +33 -130
  363. package/src/css/primitives/textInput/textInput.ts +4 -11
  364. package/src/css/primitives/textInput/types.ts +8 -5
  365. package/src/css/primitives/token/rules.ts +37 -37
  366. package/src/css/primitives/tooltip/rules.ts +2 -0
  367. package/src/css/primitives/tooltip/tooltip.ts +2 -2
  368. package/src/css/rules.ts +16 -2
  369. package/src/css/styles/border/border.ts +1 -1
  370. package/src/css/styles/display/display.ts +7 -0
  371. package/src/css/styles/display/index.ts +2 -0
  372. package/src/css/styles/display/rules.ts +2 -2
  373. package/src/css/styles/display/types.ts +17 -0
  374. package/src/css/styles/flex/flex.ts +1 -1
  375. package/src/css/styles/flexItem/flexItem.ts +1 -1
  376. package/src/css/styles/flexItem/rules.ts +1 -0
  377. package/src/css/styles/font/font.ts +1 -1
  378. package/src/css/styles/font/rules.ts +4 -4
  379. package/src/css/styles/gap/gap.ts +1 -1
  380. package/src/css/styles/gap/rules.ts +1 -0
  381. package/src/css/styles/gap/types.ts +1 -0
  382. package/src/css/styles/grid/grid.ts +1 -1
  383. package/src/css/styles/gridItem/gridItem.ts +1 -1
  384. package/src/css/styles/index.ts +19 -0
  385. package/src/css/styles/inset/index.ts +2 -0
  386. package/src/css/styles/inset/inset.ts +13 -0
  387. package/src/css/styles/inset/rules.ts +16 -0
  388. package/src/css/styles/inset/types.ts +13 -0
  389. package/src/css/styles/margin/margin.ts +1 -1
  390. package/src/css/styles/margin/rules.ts +1 -0
  391. package/src/css/styles/maxWidth/rules.ts +8 -31
  392. package/src/css/styles/maxWidth/types.ts +2 -1
  393. package/src/css/styles/overflow/overflow.ts +1 -1
  394. package/src/css/styles/padding/padding.ts +1 -1
  395. package/src/css/styles/padding/rules.ts +1 -0
  396. package/src/css/styles/padding/types.ts +9 -7
  397. package/src/css/styles/pointerEvents/pointerEvents.ts +1 -1
  398. package/src/css/styles/position/position.ts +2 -2
  399. package/src/css/styles/position/rules.ts +0 -7
  400. package/src/css/styles/position/types.ts +0 -4
  401. package/src/css/styles/radius/radius.ts +1 -1
  402. package/src/css/styles/radius/rules.ts +1 -1
  403. package/src/css/styles/radius/types.ts +1 -0
  404. package/src/css/styles/shadow/index.ts +2 -0
  405. package/src/css/styles/shadow/rules.ts +5 -5
  406. package/src/css/styles/shadow/shadow.ts +7 -0
  407. package/src/css/styles/shadow/types.ts +8 -0
  408. package/src/css/styles/textOverflow/index.ts +2 -0
  409. package/src/css/styles/textOverflow/rules.ts +17 -0
  410. package/src/css/styles/textOverflow/textOverflow.ts +6 -0
  411. package/src/css/styles/textOverflow/types.ts +8 -0
  412. package/src/css/styles/width/index.ts +1 -1
  413. package/src/css/styles/width/types.ts +3 -2
  414. package/src/css/types.ts +457 -289
  415. package/src/css/util.ts +27 -0
  416. package/src/css/utils/srOnly/index.ts +1 -0
  417. package/src/css/utils/srOnly/rules.ts +11 -0
  418. package/src/css/utils/srOnly/srOnly.ts +5 -0
  419. package/src/css/varNames.ts +352 -260
  420. package/src/css/vars.ts +330 -286
  421. package/src/theme/{system/_constants.ts → _constants.ts} +5 -4
  422. package/src/theme/{system/_types.ts → _types.ts} +1 -1
  423. package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +1 -1
  424. package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +1 -1
  425. package/src/theme/build/_deprecated/color/button/createButtonModes.ts +1 -6
  426. package/src/theme/build/_deprecated/color/button/createButtonTones.ts +2 -2
  427. package/src/theme/build/_deprecated/color/card/createCardStates.ts +2 -2
  428. package/src/theme/build/_deprecated/color/factory.ts +8 -9
  429. package/src/theme/build/_deprecated/color/input/createInputModes.ts +1 -1
  430. package/src/theme/build/_deprecated/color/muted/createMuted.ts +2 -2
  431. package/src/theme/build/_deprecated/color/spot/createSpot.ts +1 -1
  432. package/src/theme/build/buildColorTheme.ts +62 -52
  433. package/src/theme/build/buildTheme.ts +8 -32
  434. package/src/theme/build/colorToken/colorToken.ts +1 -1
  435. package/src/theme/build/lib/color-fns/rgba.ts +4 -0
  436. package/src/theme/build/merge.ts +0 -2
  437. package/src/theme/build/mixThemeColor.ts +1 -1
  438. package/src/theme/build/renderColorTheme.ts +34 -37
  439. package/src/theme/build/renderColorValue.ts +4 -3
  440. package/src/theme/build/resolveColorTokens.ts +57 -120
  441. package/src/theme/config/helpers.ts +2 -2
  442. package/src/theme/config/system.ts +3 -2
  443. package/src/theme/config/tokens/color/types.ts +5 -18
  444. package/src/theme/config/tokens/parseTokenKey.ts +1 -1
  445. package/src/theme/config/tokens/parseTokenValue.ts +1 -1
  446. package/src/theme/config/tokens/types.ts +3 -2
  447. package/src/theme/config/types.ts +4 -4
  448. package/src/theme/defaults/colorTokens.ts +6 -4
  449. package/src/theme/defaults/config.ts +2 -2
  450. package/src/theme/defaults/fonts.ts +18 -17
  451. package/src/theme/getScopedTheme.ts +10 -4
  452. package/src/theme/index.ts +7 -1
  453. package/src/theme/palette/constants.ts +15 -0
  454. package/src/theme/palette/index.ts +2 -0
  455. package/src/theme/palette/types.ts +16 -0
  456. package/src/theme/types.ts +32 -0
  457. package/src/theme/{system/v0 → v0}/color/_generic.ts +1 -1
  458. package/src/theme/v0/color/_system.ts +17 -0
  459. package/src/theme/{system/v0 → v0}/color/color.ts +3 -2
  460. package/src/theme/{system/v0 → v0}/color/input.ts +1 -1
  461. package/src/theme/{system/v0 → v0}/color/spot.ts +1 -1
  462. package/src/theme/{system → v0}/css.ts +1 -2
  463. package/src/theme/{system → v0}/font.ts +1 -0
  464. package/src/theme/{system → v0}/index.ts +0 -4
  465. package/src/theme/v0/theme.ts +72 -0
  466. package/src/theme/{system → v2}/avatar.ts +1 -1
  467. package/src/theme/{system → v2}/color/_constants.ts +6 -2
  468. package/src/theme/{system → v2}/color/_helpers.ts +1 -0
  469. package/src/theme/v2/color/badge.ts +16 -0
  470. package/src/theme/{system → v2}/color/color.ts +1 -1
  471. package/src/theme/{system/v0 → v2}/index.ts +2 -1
  472. package/src/theme/{system → v2}/input.ts +1 -1
  473. package/src/theme/v2/theme.ts +49 -0
  474. package/src/theme/v3/buildTheme_v3.test.ts +40 -0
  475. package/src/theme/v3/buildTheme_v3.ts +30 -0
  476. package/src/theme/v3/color/buildColor_v3.ts +193 -0
  477. package/src/theme/v3/color/card.ts +116 -0
  478. package/src/theme/v3/color/color.ts +94 -0
  479. package/src/theme/v3/color/element.ts +19 -0
  480. package/src/theme/v3/color/index.ts +7 -0
  481. package/src/theme/v3/color/parseColor.test.ts +79 -0
  482. package/src/theme/v3/color/parseColor.ts +167 -0
  483. package/src/theme/v3/color/renderColor.test.ts +19 -0
  484. package/src/theme/v3/color/renderColor.ts +33 -0
  485. package/src/theme/v3/color/token.ts +17 -0
  486. package/src/theme/v3/color/tokens.ts +5 -0
  487. package/src/theme/v3/defaults.ts +205 -0
  488. package/src/theme/v3/index.ts +6 -0
  489. package/src/theme/v3/merge.ts +22 -0
  490. package/src/theme/v3/resolveTokens.ts +199 -0
  491. package/src/theme/v3/tokens.ts +16 -0
  492. package/src/theme/v3/types.ts +48 -0
  493. package/src/theme/versioning/getTheme_v2.ts +2 -1
  494. package/src/theme/versioning/index.ts +0 -4
  495. package/src/theme/versioning/is_v0.ts +2 -1
  496. package/src/theme/versioning/is_v2.ts +2 -1
  497. package/src/theme/versioning/themeColor_v0_v2.ts +33 -5
  498. package/src/theme/versioning/themeColor_v2_v2_9.ts +49 -0
  499. package/src/theme/versioning/themeColor_v3_v2.ts +206 -0
  500. package/src/theme/versioning/v0_v2.ts +6 -1
  501. package/src/theme/versioning/v2_v0.ts +6 -6
  502. package/src/theme/versioning/v3_v2.ts +108 -0
  503. package/dist/css.esm.js +0 -3794
  504. package/dist/css.esm.js.map +0 -1
  505. package/dist/index.esm.js +0 -5431
  506. package/dist/index.esm.js.map +0 -1
  507. package/dist/theme.esm.js +0 -4201
  508. package/dist/theme.esm.js.map +0 -1
  509. package/src/core/__workshop__/constants.ts +0 -305
  510. package/src/core/__workshop__/fontsPlugin.tsx +0 -76
  511. package/src/core/_compat/styles/border/borderStyle.ts +0 -61
  512. package/src/core/_compat/styles/border/index.ts +0 -2
  513. package/src/core/_compat/styles/border/types.ts +0 -11
  514. package/src/core/_compat/styles/box/boxStyle.ts +0 -74
  515. package/src/core/_compat/styles/box/index.ts +0 -2
  516. package/src/core/_compat/styles/box/types.ts +0 -11
  517. package/src/core/_compat/styles/card/_cardColorStyle.ts +0 -101
  518. package/src/core/_compat/styles/card/index.ts +0 -1
  519. package/src/core/_compat/styles/flex/flexItemStyle.ts +0 -26
  520. package/src/core/_compat/styles/flex/flexStyle.ts +0 -69
  521. package/src/core/_compat/styles/flex/index.ts +0 -3
  522. package/src/core/_compat/styles/flex/types.ts +0 -24
  523. package/src/core/_compat/styles/focusRing/index.ts +0 -25
  524. package/src/core/_compat/styles/font/codeFontStyle.ts +0 -12
  525. package/src/core/_compat/styles/font/headingFontStyle.ts +0 -12
  526. package/src/core/_compat/styles/font/index.ts +0 -6
  527. package/src/core/_compat/styles/font/labelFontStyle.ts +0 -12
  528. package/src/core/_compat/styles/font/responsiveFont.ts +0 -101
  529. package/src/core/_compat/styles/font/textAlignStyle.ts +0 -18
  530. package/src/core/_compat/styles/font/textFontStyle.ts +0 -12
  531. package/src/core/_compat/styles/font/types.ts +0 -34
  532. package/src/core/_compat/styles/grid/gridItemStyle.ts +0 -81
  533. package/src/core/_compat/styles/grid/gridStyle.ts +0 -97
  534. package/src/core/_compat/styles/grid/index.ts +0 -3
  535. package/src/core/_compat/styles/grid/types.ts +0 -37
  536. package/src/core/_compat/styles/helpers.ts +0 -81
  537. package/src/core/_compat/styles/input/index.ts +0 -2
  538. package/src/core/_compat/styles/input/responsiveInputPaddingStyle.ts +0 -77
  539. package/src/core/_compat/styles/input/textInputStyle.ts +0 -263
  540. package/src/core/_compat/styles/internal.ts +0 -12
  541. package/src/core/_compat/styles/margin/index.ts +0 -2
  542. package/src/core/_compat/styles/margin/marginStyle.ts +0 -20
  543. package/src/core/_compat/styles/margin/marginsStyle.test.ts +0 -32
  544. package/src/core/_compat/styles/margin/types.ts +0 -9
  545. package/src/core/_compat/styles/padding/index.ts +0 -2
  546. package/src/core/_compat/styles/padding/paddingStyle.test.ts +0 -32
  547. package/src/core/_compat/styles/padding/paddingStyle.ts +0 -20
  548. package/src/core/_compat/styles/padding/types.ts +0 -12
  549. package/src/core/_compat/styles/radius/index.ts +0 -2
  550. package/src/core/_compat/styles/radius/radiusStyle.ts +0 -22
  551. package/src/core/_compat/styles/radius/types.ts +0 -8
  552. package/src/core/_compat/styles/shadow/index.ts +0 -2
  553. package/src/core/_compat/styles/shadow/shadowStyle.ts +0 -29
  554. package/src/core/_compat/styles/shadow/types.ts +0 -6
  555. package/src/core/_compat/styles/types.ts +0 -8
  556. package/src/core/components/autocomplete/__workshop__/.eslintrc +0 -5
  557. package/src/core/components/breadcrumbs/__workshop__/.eslintrc +0 -5
  558. package/src/core/components/dialog/__workshop__/.eslintrc +0 -5
  559. package/src/core/components/hotkeys/__workshop__/.eslintrc +0 -5
  560. package/src/core/components/menu/__workshop__/.eslintrc +0 -5
  561. package/src/core/components/skeleton/__workshop__/.eslintrc +0 -5
  562. package/src/core/components/tab/__workshop__/.eslintrc +0 -5
  563. package/src/core/components/toast/__workshop__/.eslintrc +0 -5
  564. package/src/core/components/tree/__workshop__/.eslintrc +0 -5
  565. package/src/core/hooks/useElementRect/__workshop__/.eslintrc +0 -5
  566. package/src/core/hooks/useMediaIndex/__workshop__/.eslintrc +0 -5
  567. package/src/core/lib/styled/elements.ts +0 -135
  568. package/src/core/lib/styled/index.ts +0 -2
  569. package/src/core/lib/styled/members.ts +0 -15
  570. package/src/core/lib/styled/styled.ts +0 -79
  571. package/src/core/primitives/avatar/__workshop__/.eslintrc +0 -5
  572. package/src/core/primitives/avatar/styles.ts +0 -166
  573. package/src/core/primitives/badge/__workshop__/.eslintrc +0 -5
  574. package/src/core/primitives/badge/styles.ts +0 -19
  575. package/src/core/primitives/box/__workshop__/.eslintrc +0 -5
  576. package/src/core/primitives/button/__workshop__/.eslintrc +0 -5
  577. package/src/core/primitives/button/styles.ts +0 -116
  578. package/src/core/primitives/card/RootCardContext.ts +0 -3
  579. package/src/core/primitives/card/__workshop__/.eslintrc +0 -5
  580. package/src/core/primitives/checkbox/__workshop__/.eslintrc +0 -5
  581. package/src/core/primitives/code/__workshop__/.eslintrc +0 -5
  582. package/src/core/primitives/code/styles.ts +0 -77
  583. package/src/core/primitives/container/__workshop__/.eslintrc +0 -5
  584. package/src/core/primitives/container/styles.ts +0 -22
  585. package/src/core/primitives/flex/__workshop__/.eslintrc +0 -5
  586. package/src/core/primitives/grid/__workshop__/.eslintrc +0 -5
  587. package/src/core/primitives/heading/__workshop__/.eslintrc +0 -5
  588. package/src/core/primitives/heading/styles.ts +0 -63
  589. package/src/core/primitives/heading/types.ts +0 -7
  590. package/src/core/primitives/inline/__workshop__/.eslintrc +0 -5
  591. package/src/core/primitives/inline/styles.ts +0 -31
  592. package/src/core/primitives/kbd/__workshop__/.eslintrc +0 -5
  593. package/src/core/primitives/label/__workshop__/.eslintrc +0 -5
  594. package/src/core/primitives/label/styles.ts +0 -44
  595. package/src/core/primitives/popover/__workshop__/.eslintrc +0 -5
  596. package/src/core/primitives/radio/__workshop__/.eslintrc +0 -5
  597. package/src/core/primitives/radio/styles.ts +0 -116
  598. package/src/core/primitives/select/__workshop__/.eslintrc +0 -5
  599. package/src/core/primitives/select/styles.ts +0 -166
  600. package/src/core/primitives/spinner/__workshop__/.eslintrc +0 -5
  601. package/src/core/primitives/stack/__workshop__/.eslintrc +0 -5
  602. package/src/core/primitives/stack/styles.ts +0 -31
  603. package/src/core/primitives/switch/__workshop__/.eslintrc +0 -5
  604. package/src/core/primitives/switch/styles.ts +0 -172
  605. package/src/core/primitives/text/__workshop__/.eslintrc +0 -5
  606. package/src/core/primitives/text/styles.ts +0 -73
  607. package/src/core/primitives/textArea/__workshop__/.eslintrc +0 -5
  608. package/src/core/primitives/textInput/__workshop__/.eslintrc +0 -5
  609. package/src/core/primitives/textInput/__workshop__/multipleTones.tsx +0 -20
  610. package/src/core/primitives/tooltip/__workshop__/.eslintrc +0 -5
  611. package/src/core/theme/__workshop__/.eslintrc +0 -5
  612. package/src/core/theme/__workshop__/build/Root.tsx +0 -367
  613. package/src/core/theme/__workshop__/build/helpers.ts +0 -46
  614. package/src/core/theme/__workshop__/build/story.tsx +0 -457
  615. package/src/core/theme/__workshop__/canvas.tsx +0 -350
  616. package/src/core/theme/__workshop__/color.tsx +0 -62
  617. package/src/core/theme/__workshop__/debug/story.tsx +0 -401
  618. package/src/core/theme/__workshop__/index.ts +0 -39
  619. package/src/core/theme/__workshop__/layer.tsx +0 -78
  620. package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
  621. package/src/core/utils/boundaryElement/__workshop__/.eslintrc +0 -5
  622. package/src/core/utils/elementQuery/__workshop__/.eslintrc +0 -5
  623. package/src/core/utils/layer/__workshop__/.eslintrc +0 -5
  624. package/src/core/utils/portal/__workshop__/.eslintrc +0 -5
  625. package/src/core/utils/virtualList/__workshop__/.eslintrc +0 -5
  626. package/src/css/primitives/selectable/rules.ts +0 -27
  627. package/src/css/primitives/selectable/selectable.ts +0 -9
  628. package/src/css/primitives/selectable/types.ts +0 -6
  629. package/src/theme/system/color/badge.ts +0 -20
  630. package/src/theme/system/theme.ts +0 -138
  631. package/src/theme/system/v0/color/_system.ts +0 -13
  632. package/theme.js +0 -2
  633. package/src/core/{theme → _compat/theme}/index.ts +1 -1
  634. package/src/core/{theme → _compat/theme}/types.ts +0 -0
  635. package/src/core/components/autocomplete/{__fixtures__ → __mocks__}/countries.ts +0 -0
  636. package/src/core/primitives/kbd/{index.tsx → index.ts} +0 -0
  637. package/src/css/primitives/{selectable → _selectable}/index.ts +0 -0
  638. package/src/theme/{system/v0 → v0}/avatar.ts +0 -0
  639. package/src/theme/{system/v0 → v0}/color/base.ts +0 -0
  640. package/src/theme/{system/v0 → v0}/color/button.ts +0 -0
  641. package/src/theme/{system/v0 → v0}/color/card.ts +0 -0
  642. package/src/theme/{system/v0 → v0}/color/index.ts +1 -1
  643. package/src/theme/{system/v0 → v0}/color/muted.ts +0 -0
  644. package/src/theme/{system/v0 → v0}/color/selectable.ts +0 -0
  645. package/src/theme/{system/v0 → v0}/color/solid.ts +0 -0
  646. package/src/theme/{system → v0}/focusRing.ts +0 -0
  647. package/src/theme/{system/v0 → v0}/input.ts +0 -0
  648. package/src/theme/{system → v0}/layer.ts +0 -0
  649. package/src/theme/{system → v0}/shadow.ts +0 -0
  650. package/src/theme/{system → v0}/styles.ts +0 -0
  651. package/src/theme/{system → v2}/color/_system.ts +1 -1
  652. /package/src/theme/{system → v2}/color/avatar.ts +0 -0
  653. /package/src/theme/{system → v2}/color/button.ts +0 -0
  654. /package/src/theme/{system → v2}/color/index.ts +0 -0
  655. /package/src/theme/{system → v2}/color/input.ts +0 -0
  656. /package/src/theme/{system → v2}/color/kbd.ts +0 -0
  657. /package/src/theme/{system → v2}/color/selectable.ts +0 -0
  658. /package/src/theme/{system → v2}/color/shadow.ts +0 -0
  659. /package/src/theme/{system → v2}/color/state.ts +0 -0
  660. /package/src/theme/{system → v2}/color/syntax.ts +0 -0
package/dist/theme.mjs CHANGED
@@ -1,4 +1,19 @@
1
- import { COLOR_HUES, COLOR_TINTS, color } from "@sanity/color";
1
+ import { THEME_COLOR_BLEND_MODES, THEME_COLOR_BUTTON_MODES, THEME_COLOR_CARD_TONES, THEME_COLOR_STATE_TONES, THEME_COLOR_AVATAR_COLORS, v3_v2, THEME_COLOR_STATES, THEME_COLOR_INPUT_MODES, THEME_COLOR_INPUT_STATES } from "./_chunks-es/v3_v2.mjs";
2
+ import { THEME_COLOR_SCHEMES } from "./_chunks-es/v3_v2.mjs";
3
+ import { COLOR_HUES, COLOR_TINTS } from "@sanity/color";
4
+ function isColorBlendModeValue(str) {
5
+ return THEME_COLOR_BLEND_MODES.includes(str);
6
+ }
7
+ function isColorHueKey(str) {
8
+ return COLOR_HUES.includes(str);
9
+ }
10
+ function isColorTintKey(str) {
11
+ return COLOR_TINTS.includes(str);
12
+ }
13
+ function isColorButtonMode(str) {
14
+ return THEME_COLOR_BUTTON_MODES.includes(str);
15
+ }
16
+ const AVATAR_SIZE = [0, 1, 2, 3], CONTAINER = [0, 1, 2, 3, 4, 5], RADIUS = [0, 1, 2, 3, 4, 5, 6, "full"], SPACE = [0, 0.5, 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];
2
17
  function createSelectableTones(opts, base, dark, solid, muted) {
3
18
  return {
4
19
  default: _createSelectableStates(opts, base, dark, solid, muted, "default"),
@@ -505,13 +520,13 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
505
520
  state,
506
521
  tone
507
522
  }) => {
508
- const color2 = colors[tone];
523
+ const color = colors[tone];
509
524
  return state === "hovered" ? {
510
- bg: dark ? color2.light : color2.dark,
511
- bg2: dark ? color2.light : color2.dark,
512
- border: dark ? color2.lighter : color2.darker,
513
- fg: dark ? color2.darkest : color2.lightest,
514
- icon: dark ? color2.darkest : color2.lightest,
525
+ bg: dark ? color.light : color.dark,
526
+ bg2: dark ? color.light : color.dark,
527
+ border: dark ? color.lighter : color.darker,
528
+ fg: dark ? color.darkest : color.lightest,
529
+ icon: dark ? color.darkest : color.lightest,
515
530
  muted: {
516
531
  fg: black
517
532
  },
@@ -527,11 +542,11 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
527
542
  },
528
543
  skeleton: base.skeleton
529
544
  } : {
530
- bg: color2.base,
531
- bg2: color2.base,
532
- border: dark ? color2.light : color2.dark,
533
- fg: dark ? color2.darkest : color2.lightest,
534
- icon: dark ? color2.darkest : color2.lightest,
545
+ bg: color.base,
546
+ bg2: color.base,
547
+ border: dark ? color.light : color.dark,
548
+ fg: dark ? color.darkest : color.lightest,
549
+ icon: dark ? color.darkest : color.lightest,
535
550
  muted: {
536
551
  fg: black
537
552
  },
@@ -554,13 +569,13 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
554
569
  state,
555
570
  tone
556
571
  }) => {
557
- const color2 = colors[tone];
572
+ const color = colors[tone];
558
573
  return state === "hovered" ? {
559
- bg: dark ? color2.darker : color2.lighter,
560
- bg2: dark ? color2.darker : color2.lighter,
561
- border: dark ? color2.lighter : color2.darker,
562
- fg: dark ? color2.lightest : color2.darkest,
563
- icon: dark ? color2.lightest : color2.darkest,
574
+ bg: dark ? color.darker : color.lighter,
575
+ bg2: dark ? color.darker : color.lighter,
576
+ border: dark ? color.lighter : color.darker,
577
+ fg: dark ? color.lightest : color.darkest,
578
+ icon: dark ? color.lightest : color.darkest,
564
579
  muted: {
565
580
  fg: black
566
581
  },
@@ -576,11 +591,11 @@ const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
576
591
  },
577
592
  skeleton: base.skeleton
578
593
  } : {
579
- bg: dark ? color2.darkest : color2.lightest,
580
- bg2: dark ? color2.darkest : color2.lightest,
581
- border: dark ? color2.darker : color2.lighter,
582
- fg: dark ? color2.lighter : color2.darker,
583
- icon: dark ? color2.lighter : color2.darker,
594
+ bg: dark ? color.darkest : color.lightest,
595
+ bg2: dark ? color.darkest : color.lightest,
596
+ border: dark ? color.darker : color.lighter,
597
+ fg: dark ? color.lighter : color.darker,
598
+ icon: dark ? color.lighter : color.darker,
584
599
  muted: {
585
600
  fg: black
586
601
  },
@@ -1116,7 +1131,6 @@ function _createColor(opts, dark, name) {
1116
1131
  };
1117
1132
  }
1118
1133
  const defaultThemeConfig = {
1119
- _version: 2,
1120
1134
  avatar: {
1121
1135
  sizes: [{
1122
1136
  distance: -4,
@@ -1171,7 +1185,7 @@ const defaultThemeConfig = {
1171
1185
  zOffset: 200
1172
1186
  }
1173
1187
  },
1174
- radius: [0, 1, 5, 9, 13, 21, 33],
1188
+ radius: [0, 1, 5, 9, 13, 17, 25, 45, 77, 129],
1175
1189
  shadow: [null, {
1176
1190
  umbra: [0, 0, 0, 0],
1177
1191
  penumbra: [0, 0, 0, 0],
@@ -1236,18 +1250,6 @@ const defaultThemeConfig = {
1236
1250
  width: 1
1237
1251
  }
1238
1252
  }
1239
- },
1240
- style: {
1241
- button: {
1242
- root: {
1243
- transition: "background-color 100ms,border-color 100ms,color 100ms"
1244
- }
1245
- }
1246
- // card: {
1247
- // root: {
1248
- // transition: 'background-color 100ms,border-color 100ms,color 100ms',
1249
- // },
1250
- // },
1251
1253
  }
1252
1254
  }, defaultThemeFonts = {
1253
1255
  code: {
@@ -1297,11 +1299,12 @@ const defaultThemeConfig = {
1297
1299
  },
1298
1300
  heading: {
1299
1301
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", Helvetica, Arial, system-ui, sans-serif',
1302
+ featureSettings: "'liga' 1, 'calt' 1, 'ss01' 1, 'ss03' 1, 'zero' 1",
1300
1303
  weights: {
1301
- regular: 700,
1302
- medium: 800,
1303
- semibold: 900,
1304
- bold: 900
1304
+ regular: 400,
1305
+ medium: 500,
1306
+ semibold: 600,
1307
+ bold: 700
1305
1308
  },
1306
1309
  sizes: [{
1307
1310
  ascenderHeight: 5,
@@ -1323,37 +1326,37 @@ const defaultThemeConfig = {
1323
1326
  fontSize: 21,
1324
1327
  iconSize: 33,
1325
1328
  lineHeight: 29,
1326
- letterSpacing: 0
1329
+ letterSpacing: -0.25
1327
1330
  }, {
1328
1331
  ascenderHeight: 8,
1329
1332
  descenderHeight: 8,
1330
1333
  fontSize: 27,
1331
1334
  iconSize: 41,
1332
1335
  lineHeight: 35,
1333
- letterSpacing: 0
1336
+ letterSpacing: -0.5
1334
1337
  }, {
1335
1338
  ascenderHeight: 9.5,
1336
1339
  descenderHeight: 8.5,
1337
1340
  fontSize: 33,
1338
1341
  iconSize: 49,
1339
1342
  lineHeight: 41,
1340
- letterSpacing: 0
1343
+ letterSpacing: -1
1341
1344
  }, {
1342
1345
  ascenderHeight: 10.5,
1343
1346
  descenderHeight: 9.5,
1344
1347
  fontSize: 38,
1345
1348
  iconSize: 53,
1346
1349
  lineHeight: 47,
1347
- letterSpacing: 0
1350
+ letterSpacing: -1
1348
1351
  }]
1349
1352
  },
1350
1353
  label: {
1351
1354
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
1352
1355
  weights: {
1353
- regular: 600,
1354
- medium: 700,
1355
- semibold: 800,
1356
- bold: 900
1356
+ regular: 500,
1357
+ medium: 600,
1358
+ semibold: 700,
1359
+ bold: 800
1357
1360
  },
1358
1361
  sizes: [{
1359
1362
  ascenderHeight: 2,
@@ -1363,8 +1366,8 @@ const defaultThemeConfig = {
1363
1366
  lineHeight: 10,
1364
1367
  letterSpacing: 0.5
1365
1368
  }, {
1366
- ascenderHeight: 2,
1367
- descenderHeight: 2,
1369
+ ascenderHeight: 1.5,
1370
+ descenderHeight: 2.5,
1368
1371
  fontSize: 9.5,
1369
1372
  iconSize: 15,
1370
1373
  lineHeight: 11,
@@ -1384,8 +1387,8 @@ const defaultThemeConfig = {
1384
1387
  lineHeight: 13,
1385
1388
  letterSpacing: 0.5
1386
1389
  }, {
1387
- ascenderHeight: 2,
1388
- descenderHeight: 2,
1390
+ ascenderHeight: 1.5,
1391
+ descenderHeight: 2.5,
1389
1392
  fontSize: 13.6,
1390
1393
  iconSize: 21,
1391
1394
  lineHeight: 14,
@@ -1444,329 +1447,660 @@ const defaultThemeConfig = {
1444
1447
  letterSpacing: 0
1445
1448
  }]
1446
1449
  }
1447
- }, cache$4 = /* @__PURE__ */ new WeakMap();
1448
- function themeColor_v0_v2(color_v0) {
1449
- const cached_v2 = cache$4.get(color_v0);
1450
- if (cached_v2) return cached_v2;
1451
- const base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled), color_v2 = {
1452
- _blend: color_v0._blend || (color_v0.dark ? "screen" : "multiply"),
1453
- _dark: color_v0.dark,
1454
- accent: base.accent,
1455
- avatar: base.avatar,
1456
- backdrop: color_v0.base.shadow.ambient,
1457
- badge: base.badge,
1458
- bg: color_v0.base.bg,
1459
- border: color_v0.base.border,
1460
- button: {
1461
- default: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.default),
1462
- ghost: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.ghost),
1463
- bleed: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.bleed)
1464
- },
1465
- code: base.code,
1466
- fg: color_v0.base.fg,
1467
- focusRing: color_v0.base.focusRing,
1468
- icon: base.muted.fg,
1469
- input: {
1470
- default: inputStatesThemeColor_v0_v2(color_v0.input.default),
1471
- invalid: inputStatesThemeColor_v0_v2(color_v0.input.invalid)
1472
- },
1473
- kbd: base.kbd,
1474
- link: base.link,
1475
- muted: {
1476
- ...base.muted,
1477
- bg: color_v0.selectable?.default.enabled.bg2 || color_v0.base.bg
1450
+ }, HUES = ["gray", "blue", "purple", "magenta", "red", "orange", "yellow", "green", "cyan"], TINTS = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950], RE_PERCENTAGE = /^([0-9]+)%/, RE_OPACITY = /^(1|0\.[0-9]+)?/;
1451
+ function parseColor$1(str) {
1452
+ let cursor = 0;
1453
+ const color = getColor();
1454
+ if (!color)
1455
+ throw new Error(`Invalid color: ${str}`);
1456
+ const opacity = getOpacity(), mix2 = getMixPercentage();
1457
+ return {
1458
+ color,
1459
+ mix: mix2,
1460
+ opacity
1461
+ };
1462
+ function _consume(s) {
1463
+ if (str.startsWith(s, cursor))
1464
+ return cursor += s.length, s;
1465
+ }
1466
+ function _peek() {
1467
+ return str[cursor];
1468
+ }
1469
+ function getColor() {
1470
+ ignoreWhitespace();
1471
+ let v = _consume("black") || _consume("white");
1472
+ if (v)
1473
+ return {
1474
+ type: v
1475
+ };
1476
+ for (const hue of HUES)
1477
+ if (v = _consume(String(hue)), v) {
1478
+ if (_peek() !== "/")
1479
+ throw new Error("Expected slash after hue");
1480
+ cursor += 1;
1481
+ const tint2 = getTint();
1482
+ if (!tint2)
1483
+ throw new Error("Expected tint after hue");
1484
+ return {
1485
+ type: "hue",
1486
+ hue,
1487
+ tint: tint2
1488
+ };
1489
+ }
1490
+ const tint = getTint();
1491
+ if (tint)
1492
+ return {
1493
+ type: "hue",
1494
+ hue: void 0,
1495
+ tint
1496
+ };
1497
+ }
1498
+ function getTint() {
1499
+ ignoreWhitespace();
1500
+ let v = Number(str.slice(cursor, cursor + 3));
1501
+ if (TINTS.includes(v))
1502
+ return cursor += 3, v;
1503
+ if (v = Number(str.slice(cursor, cursor + 2)), TINTS.includes(v))
1504
+ return cursor += 2, v;
1505
+ }
1506
+ function getMixPercentage() {
1507
+ ignoreWhitespace();
1508
+ const match = RE_PERCENTAGE.exec(str.slice(cursor));
1509
+ if (match)
1510
+ return cursor += match[0].length, parseFloat(match[1]);
1511
+ }
1512
+ function getOpacity() {
1513
+ if (ignoreWhitespace(), _peek() === "/") {
1514
+ cursor += 1;
1515
+ const match = RE_OPACITY.exec(str.slice(cursor));
1516
+ if (match)
1517
+ return cursor += match[0].length, parseFloat(match[1]);
1518
+ cursor -= 1;
1519
+ }
1520
+ }
1521
+ function ignoreWhitespace() {
1522
+ for (; _peek() === " "; )
1523
+ cursor++;
1524
+ }
1525
+ }
1526
+ function renderColor(token, context) {
1527
+ const {
1528
+ bgVar,
1529
+ hue,
1530
+ scheme
1531
+ } = context, result = parseColor$1(token[scheme === "dark" ? 0 : 1]), colorVar = result.color.type === "hue" ? `--${result.color.hue ?? hue}-${result.color.tint}` : `--${result.color.type}`;
1532
+ return result.mix !== void 0 ? `color-mix(in srgb, var(${bgVar}), var(${colorVar}) ${result.mix}%)` : result.opacity !== void 0 ? `color-mix(in srgb, transparent, var(${colorVar}) ${result.opacity * 100}%)` : `var(${colorVar})`;
1533
+ }
1534
+ function buildColor_v3(tokens) {
1535
+ return {
1536
+ dark: buildColorScheme_v3(tokens, {
1537
+ scheme: "dark"
1538
+ }),
1539
+ light: buildColorScheme_v3(tokens, {
1540
+ scheme: "light"
1541
+ })
1542
+ };
1543
+ }
1544
+ function buildColorScheme_v3(tokens, options) {
1545
+ const {
1546
+ scheme
1547
+ } = options;
1548
+ return {
1549
+ card: THEME_COLOR_CARD_TONES.reduce((acc, tone) => (acc[tone] = buildColorCard_v3(tokens[tone], {
1550
+ scheme
1551
+ }), acc), {})
1552
+ };
1553
+ }
1554
+ function buildColorCard_v3(tokens, options) {
1555
+ const {
1556
+ scheme
1557
+ } = options, context = {
1558
+ bgVar: "--color-bg-1",
1559
+ hue: tokens._hue,
1560
+ scheme
1561
+ };
1562
+ return {
1563
+ _hue: tokens._hue ?? "gray",
1564
+ avatar: THEME_COLOR_AVATAR_COLORS.reduce((acc, hue) => {
1565
+ const avatarTokens = tokens.avatar[hue];
1566
+ return acc[hue] = {
1567
+ bg: renderColor(avatarTokens.bg, {
1568
+ bgVar: "--color-bg-1",
1569
+ hue: avatarTokens._hue,
1570
+ scheme
1571
+ }),
1572
+ fg: renderColor(avatarTokens.fg, {
1573
+ bgVar: "--color-bg-1",
1574
+ hue: avatarTokens._hue,
1575
+ scheme
1576
+ })
1577
+ }, acc;
1578
+ }, {}),
1579
+ backdrop: renderColor(tokens.backdrop, context),
1580
+ focusRing: renderColor(tokens.focusRing, context),
1581
+ shadow: {
1582
+ outline: renderColor(tokens.shadow.outline, context),
1583
+ umbra: renderColor(tokens.shadow.umbra, context),
1584
+ penumbra: renderColor(tokens.shadow.penumbra, context),
1585
+ ambient: renderColor(tokens.shadow.ambient, context)
1478
1586
  },
1479
- selectable: stateTonesThemeColor_v0_v2(color_v0, color_v0.selectable || color_v0.muted),
1480
- shadow: color_v0.base.shadow,
1481
1587
  skeleton: {
1482
- from: color_v0.skeleton?.from || color_v0.base.border,
1483
- to: color_v0.skeleton?.to || color_v0.base.border
1484
- },
1485
- syntax: color_v0.syntax
1588
+ from: renderColor(tokens.skeleton.from, context),
1589
+ to: renderColor(tokens.skeleton.to, context)
1590
+ },
1591
+ token: {
1592
+ atrule: renderColor(tokens.token.atrule, context),
1593
+ attrName: renderColor(tokens.token.attrName, context),
1594
+ attrValue: renderColor(tokens.token.attrValue, context),
1595
+ attribute: renderColor(tokens.token.attribute, context),
1596
+ boolean: renderColor(tokens.token.boolean, context),
1597
+ builtin: renderColor(tokens.token.builtin, context),
1598
+ cdata: renderColor(tokens.token.cdata, context),
1599
+ char: renderColor(tokens.token.char, context),
1600
+ class: renderColor(tokens.token.class, context),
1601
+ className: renderColor(tokens.token.className, context),
1602
+ comment: renderColor(tokens.token.comment, context),
1603
+ constant: renderColor(tokens.token.constant, context),
1604
+ deleted: renderColor(tokens.token.deleted, context),
1605
+ doctype: renderColor(tokens.token.doctype, context),
1606
+ entity: renderColor(tokens.token.entity, context),
1607
+ function: renderColor(tokens.token.function, context),
1608
+ hexcode: renderColor(tokens.token.hexcode, context),
1609
+ id: renderColor(tokens.token.id, context),
1610
+ important: renderColor(tokens.token.important, context),
1611
+ inserted: renderColor(tokens.token.inserted, context),
1612
+ keyword: renderColor(tokens.token.keyword, context),
1613
+ number: renderColor(tokens.token.number, context),
1614
+ operator: renderColor(tokens.token.operator, context),
1615
+ prolog: renderColor(tokens.token.prolog, context),
1616
+ property: renderColor(tokens.token.property, context),
1617
+ pseudoClass: renderColor(tokens.token.pseudoClass, context),
1618
+ pseudoElement: renderColor(tokens.token.pseudoElement, context),
1619
+ punctuation: renderColor(tokens.token.punctuation, context),
1620
+ regex: renderColor(tokens.token.regex, context),
1621
+ selector: renderColor(tokens.token.selector, context),
1622
+ string: renderColor(tokens.token.string, context),
1623
+ symbol: renderColor(tokens.token.symbol, context),
1624
+ tag: renderColor(tokens.token.tag, context),
1625
+ unit: renderColor(tokens.token.unit, context),
1626
+ url: renderColor(tokens.token.url, context),
1627
+ variable: renderColor(tokens.token.variable, context)
1628
+ },
1629
+ variant: {
1630
+ solid: {
1631
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
1632
+ ...acc,
1633
+ [tone]: buildColorElement_v3(tokens.variant.solid[tone], {
1634
+ scheme
1635
+ })
1636
+ }), {})
1637
+ },
1638
+ tinted: {
1639
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
1640
+ ...acc,
1641
+ [tone]: buildColorElement_v3(tokens.variant.tinted[tone], {
1642
+ scheme
1643
+ })
1644
+ }), {})
1645
+ }
1646
+ }
1486
1647
  };
1487
- return cache$4.set(color_v0, color_v2), color_v2;
1488
1648
  }
1489
- function stateTonesThemeColor_v0_v2(v0, t) {
1649
+ function buildColorElement_v3(tokens, options) {
1650
+ const {
1651
+ scheme
1652
+ } = options, context = {
1653
+ bgVar: "--bg",
1654
+ hue: tokens._hue,
1655
+ scheme
1656
+ };
1490
1657
  return {
1658
+ _hue: tokens._hue ?? "gray",
1659
+ bg: {
1660
+ 0: renderColor(tokens.bg[0], context),
1661
+ 4: renderColor(tokens.bg[4], context)
1662
+ },
1663
+ border: {
1664
+ 0: renderColor(tokens.border[0], context),
1665
+ 4: renderColor(tokens.border[4], context)
1666
+ },
1667
+ fg: {
1668
+ 0: renderColor(tokens.fg[0], context),
1669
+ 4: renderColor(tokens.fg[4], context)
1670
+ }
1671
+ };
1672
+ }
1673
+ const defaultPalette = {
1674
+ chroma: {
1675
+ min: 5e-3,
1676
+ max: 0.2325
1677
+ },
1678
+ luminosity: {
1679
+ min: 0.1875,
1680
+ max: 1
1681
+ },
1682
+ hues: {
1683
+ gray: {
1684
+ h: 277,
1685
+ c: 0.04
1686
+ },
1687
+ blue: {
1688
+ h: 273,
1689
+ c: 0.185
1690
+ },
1691
+ purple: {
1692
+ h: 295,
1693
+ c: 0.4
1694
+ },
1695
+ magenta: {
1696
+ h: 12,
1697
+ c: 0.4
1698
+ },
1699
+ red: {
1700
+ h: 30,
1701
+ c: 0.4
1702
+ },
1703
+ orange: {
1704
+ h: 68,
1705
+ c: 0.4
1706
+ },
1707
+ yellow: {
1708
+ h: 90,
1709
+ c: 0.4
1710
+ },
1711
+ green: {
1712
+ h: 171,
1713
+ c: 0.4
1714
+ },
1715
+ cyan: {
1716
+ h: 194,
1717
+ c: 0.4
1718
+ }
1719
+ }
1720
+ }, defaultTokens = {
1721
+ color: {
1722
+ "*": {
1723
+ // backdrop: ['black/0.2', '200/0.2'],
1724
+ backdrop: ["black/0.5", "gray/100/0.5"],
1725
+ focusRing: ["blue/500", "blue/300"],
1726
+ link: {
1727
+ fg: ["blue/400", "blue/600"]
1728
+ },
1729
+ shadow: {
1730
+ outline: ["500/0.4", "500/0.3"],
1731
+ umbra: ["black/0.2", "500/0.1"],
1732
+ penumbra: ["black/0.14", "500/0.07"],
1733
+ ambient: ["black/0.12", "500/0.06"]
1734
+ },
1735
+ token: {
1736
+ atrule: ["purple/300", "purple/600"],
1737
+ attrName: ["green/300", "green/600"],
1738
+ attrValue: ["yellow/300", "yellow/600"],
1739
+ attribute: ["yellow/300", "yellow/600"],
1740
+ boolean: ["purple/300", "purple/600"],
1741
+ builtin: ["purple/300", "purple/600"],
1742
+ cdata: ["yellow/300", "yellow/600"],
1743
+ char: ["yellow/300", "yellow/600"],
1744
+ class: ["orange/300", "orange/600"],
1745
+ className: ["cyan/300", "cyan/600"],
1746
+ comment: ["gray/600", "gray/300"],
1747
+ constant: ["purple/300", "purple/600"],
1748
+ deleted: ["red/300", "red/600"],
1749
+ entity: ["red/300", "red/600"],
1750
+ function: ["green/300", "green/600"],
1751
+ hexcode: ["blue/300", "blue/600"],
1752
+ id: ["purple/300", "purple/600"],
1753
+ important: ["purple/300", "purple/600"],
1754
+ inserted: ["green/300", "green/600"],
1755
+ keyword: ["magenta/300", "magenta/600"],
1756
+ number: ["purple/300", "purple/600"],
1757
+ operator: ["magenta/300", "magenta/600"],
1758
+ prolog: ["gray/300", "gray/600"],
1759
+ property: ["blue/300", "blue/600"],
1760
+ pseudoClass: ["yellow/300", "yellow/600"],
1761
+ pseudoElement: ["yellow/300", "yellow/600"],
1762
+ punctuation: ["gray/300", "gray/600"],
1763
+ regex: ["blue/300", "blue/600"],
1764
+ selector: ["red/300", "red/600"],
1765
+ string: ["yellow/300", "yellow/600"],
1766
+ symbol: ["purple/300", "purple/600"],
1767
+ tag: ["red/300", "red/600"],
1768
+ unit: ["orange/300", "orange/600"],
1769
+ url: ["red/300", "red/600"],
1770
+ variable: ["red/300", "red/600"]
1771
+ },
1772
+ variant: {
1773
+ tinted: {
1774
+ "*": {
1775
+ bg: {
1776
+ 0: ["900", "50"],
1777
+ 4: ["800", "150"]
1778
+ },
1779
+ border: {
1780
+ 0: ["800", "150"],
1781
+ 4: ["600", "350"]
1782
+ },
1783
+ fg: {
1784
+ 0: ["100", "900"],
1785
+ 4: ["300", "700"]
1786
+ }
1787
+ },
1788
+ primary: {
1789
+ _hue: "blue"
1790
+ },
1791
+ suggest: {
1792
+ _hue: "purple"
1793
+ },
1794
+ positive: {
1795
+ _hue: "green"
1796
+ },
1797
+ caution: {
1798
+ _hue: "yellow"
1799
+ },
1800
+ critical: {
1801
+ _hue: "red"
1802
+ }
1803
+ },
1804
+ solid: {
1805
+ "*": {
1806
+ bg: {
1807
+ 0: ["300", "500"],
1808
+ 4: ["200", "600"]
1809
+ },
1810
+ border: {
1811
+ 0: ["200", "400"],
1812
+ 4: ["100", "500"]
1813
+ },
1814
+ fg: {
1815
+ 0: ["black", "white"],
1816
+ 4: ["600", "400"]
1817
+ }
1818
+ },
1819
+ default: {
1820
+ bg: {
1821
+ 0: ["200", "800"],
1822
+ 4: ["white", "black"]
1823
+ },
1824
+ border: {
1825
+ 0: ["300", "700"],
1826
+ 4: ["200", "800"]
1827
+ }
1828
+ },
1829
+ primary: {
1830
+ _hue: "blue"
1831
+ },
1832
+ suggest: {
1833
+ _hue: "purple"
1834
+ },
1835
+ positive: {
1836
+ _hue: "green"
1837
+ },
1838
+ caution: {
1839
+ _hue: "yellow"
1840
+ },
1841
+ critical: {
1842
+ _hue: "red"
1843
+ }
1844
+ }
1845
+ }
1846
+ },
1847
+ transparent: {
1848
+ variant: {
1849
+ tinted: {
1850
+ "*": {
1851
+ bg: {
1852
+ 0: ["black", "gray/50"],
1853
+ 4: ["900", "150"]
1854
+ },
1855
+ border: {
1856
+ 0: ["900", "150"],
1857
+ 4: ["700", "350"]
1858
+ },
1859
+ fg: {
1860
+ 0: ["150", "black"],
1861
+ 4: ["550", "600"]
1862
+ }
1863
+ }
1864
+ }
1865
+ }
1866
+ },
1491
1867
  default: {
1492
- enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
1493
- hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
1494
- pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
1495
- selected: stateThemeColor_v0_v2(v0, t.default.selected),
1496
- disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
1868
+ variant: {
1869
+ tinted: {
1870
+ "*": {
1871
+ bg: {
1872
+ 0: ["gray/950", "white"],
1873
+ 4: ["850", "100"]
1874
+ },
1875
+ border: {
1876
+ 0: ["850", "100"],
1877
+ 4: ["650", "300"]
1878
+ },
1879
+ fg: {
1880
+ 0: ["white", "black"],
1881
+ 4: ["400", "600"]
1882
+ }
1883
+ }
1884
+ }
1885
+ }
1497
1886
  },
1498
1887
  primary: {
1499
- enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
1500
- hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
1501
- pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
1502
- selected: stateThemeColor_v0_v2(v0, t.primary.selected),
1503
- disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
1888
+ _hue: "blue"
1889
+ },
1890
+ suggest: {
1891
+ _hue: "purple"
1504
1892
  },
1505
1893
  positive: {
1506
- enabled: stateThemeColor_v0_v2(v0, t.positive.enabled),
1507
- hovered: stateThemeColor_v0_v2(v0, t.positive.hovered),
1508
- pressed: stateThemeColor_v0_v2(v0, t.positive.pressed),
1509
- selected: stateThemeColor_v0_v2(v0, t.positive.selected),
1510
- disabled: stateThemeColor_v0_v2(v0, t.positive.disabled)
1894
+ _hue: "green"
1511
1895
  },
1512
1896
  caution: {
1513
- enabled: stateThemeColor_v0_v2(v0, t.caution.enabled),
1514
- hovered: stateThemeColor_v0_v2(v0, t.caution.hovered),
1515
- pressed: stateThemeColor_v0_v2(v0, t.caution.pressed),
1516
- selected: stateThemeColor_v0_v2(v0, t.caution.selected),
1517
- disabled: stateThemeColor_v0_v2(v0, t.caution.disabled)
1897
+ _hue: "yellow"
1518
1898
  },
1519
1899
  critical: {
1520
- enabled: stateThemeColor_v0_v2(v0, t.critical.enabled),
1521
- hovered: stateThemeColor_v0_v2(v0, t.critical.hovered),
1522
- pressed: stateThemeColor_v0_v2(v0, t.critical.pressed),
1523
- selected: stateThemeColor_v0_v2(v0, t.critical.selected),
1524
- disabled: stateThemeColor_v0_v2(v0, t.critical.disabled)
1900
+ _hue: "red"
1901
+ }
1902
+ }
1903
+ };
1904
+ function merge(...records) {
1905
+ return records.filter(Boolean).reduce(_merge, {});
1906
+ }
1907
+ function _merge(acc, source) {
1908
+ for (const key of Object.keys(source)) {
1909
+ const prevValue = acc[key], nextValue = source[key];
1910
+ isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
1911
+ }
1912
+ return acc;
1913
+ }
1914
+ function isRecord(value) {
1915
+ return value !== null && typeof value == "object" && !Array.isArray(value);
1916
+ }
1917
+ const defaultElementTokens = {
1918
+ bg: {
1919
+ 0: ["950", "50"],
1920
+ 4: ["700", "300"]
1921
+ },
1922
+ border: {
1923
+ 0: ["700", "300"],
1924
+ 4: ["400", "600"]
1925
+ },
1926
+ fg: {
1927
+ 0: ["100", "900"],
1928
+ 4: ["400", "600"]
1929
+ }
1930
+ };
1931
+ function resolveTokens(tokens = {}) {
1932
+ return {
1933
+ color: {
1934
+ "*": resolveCardColorTokens(tokens.color?.["*"]),
1935
+ ...THEME_COLOR_CARD_TONES.reduce((acc, tone) => ({
1936
+ ...acc,
1937
+ [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
1938
+ }), {})
1525
1939
  }
1526
1940
  };
1527
1941
  }
1528
- function stateThemeColor_v0_v2(v0, state) {
1942
+ function resolveCardColorTokens(tokens) {
1529
1943
  return {
1530
- ...state,
1944
+ _hue: tokens?._hue ?? "gray",
1531
1945
  avatar: {
1532
1946
  gray: {
1533
- bg: v0.spot.gray,
1534
- fg: v0.base.bg
1947
+ _hue: tokens?.avatar?.gray?._hue ?? "gray",
1948
+ bg: tokens?.avatar?.gray?.bg ?? ["400", "400"],
1949
+ fg: tokens?.avatar?.gray?.fg ?? ["900", "900"]
1535
1950
  },
1536
1951
  blue: {
1537
- bg: v0.spot.blue,
1538
- fg: v0.base.bg
1952
+ _hue: tokens?.avatar?.blue?._hue ?? "blue",
1953
+ bg: tokens?.avatar?.blue?.bg ?? ["400", "400"],
1954
+ fg: tokens?.avatar?.blue?.fg ?? ["900", "900"]
1539
1955
  },
1540
1956
  purple: {
1541
- bg: v0.spot.purple,
1542
- fg: v0.base.bg
1957
+ _hue: tokens?.avatar?.purple?._hue ?? "purple",
1958
+ bg: tokens?.avatar?.purple?.bg ?? ["400", "400"],
1959
+ fg: tokens?.avatar?.purple?.fg ?? ["900", "900"]
1543
1960
  },
1544
1961
  magenta: {
1545
- bg: v0.spot.magenta,
1546
- fg: v0.base.bg
1962
+ _hue: tokens?.avatar?.magenta?._hue ?? "magenta",
1963
+ bg: tokens?.avatar?.magenta?.bg ?? ["400", "400"],
1964
+ fg: tokens?.avatar?.magenta?.fg ?? ["900", "900"]
1547
1965
  },
1548
1966
  red: {
1549
- bg: v0.spot.red,
1550
- fg: v0.base.bg
1967
+ _hue: tokens?.avatar?.red?._hue ?? "red",
1968
+ bg: tokens?.avatar?.red?.bg ?? ["400", "400"],
1969
+ fg: tokens?.avatar?.red?.fg ?? ["900", "900"]
1551
1970
  },
1552
1971
  orange: {
1553
- bg: v0.spot.orange,
1554
- fg: v0.base.bg
1972
+ _hue: tokens?.avatar?.orange?._hue ?? "orange",
1973
+ bg: tokens?.avatar?.orange?.bg ?? ["400", "400"],
1974
+ fg: tokens?.avatar?.orange?.fg ?? ["900", "900"]
1555
1975
  },
1556
1976
  yellow: {
1557
- bg: v0.spot.yellow,
1558
- fg: v0.base.bg
1977
+ _hue: tokens?.avatar?.yellow?._hue ?? "yellow",
1978
+ bg: tokens?.avatar?.yellow?.bg ?? ["400", "400"],
1979
+ fg: tokens?.avatar?.yellow?.fg ?? ["900", "900"]
1559
1980
  },
1560
1981
  green: {
1561
- bg: v0.spot.green,
1562
- fg: v0.base.bg
1982
+ _hue: tokens?.avatar?.green?._hue ?? "green",
1983
+ bg: tokens?.avatar?.green?.bg ?? ["400", "400"],
1984
+ fg: tokens?.avatar?.green?.fg ?? ["900", "900"]
1563
1985
  },
1564
1986
  cyan: {
1565
- bg: v0.spot.cyan,
1566
- fg: v0.base.bg
1987
+ _hue: tokens?.avatar?.cyan?._hue ?? "cyan",
1988
+ bg: tokens?.avatar?.cyan?.bg ?? ["400", "400"],
1989
+ fg: tokens?.avatar?.cyan?.fg ?? ["900", "900"]
1567
1990
  }
1568
1991
  },
1569
- badge: {
1570
- default: {
1571
- bg: v0.muted.default.enabled.bg,
1572
- fg: v0.muted.default.enabled.fg,
1573
- dot: v0.muted.default.enabled.muted.fg,
1574
- icon: v0.muted.default.enabled.muted.fg
1575
- },
1576
- primary: {
1577
- bg: v0.muted.primary.enabled.bg,
1578
- fg: v0.muted.primary.enabled.fg,
1579
- dot: v0.muted.primary.enabled.muted.fg,
1580
- icon: v0.muted.primary.enabled.muted.fg
1581
- },
1582
- positive: {
1583
- bg: v0.muted.positive.enabled.bg,
1584
- fg: v0.muted.positive.enabled.fg,
1585
- dot: v0.muted.positive.enabled.muted.fg,
1586
- icon: v0.muted.positive.enabled.muted.fg
1587
- },
1588
- caution: {
1589
- bg: v0.muted.caution.enabled.bg,
1590
- fg: v0.muted.caution.enabled.fg,
1591
- dot: v0.muted.caution.enabled.muted.fg,
1592
- icon: v0.muted.caution.enabled.muted.fg
1593
- },
1594
- critical: {
1595
- bg: v0.muted.critical.enabled.bg,
1596
- fg: v0.muted.critical.enabled.fg,
1597
- dot: v0.muted.critical.enabled.muted.fg,
1598
- icon: v0.muted.critical.enabled.muted.fg
1599
- }
1600
- },
1601
- kbd: {
1602
- bg: v0.muted.default.enabled.bg,
1603
- fg: v0.muted.default.enabled.fg,
1604
- border: v0.muted.default.enabled.border
1992
+ backdrop: tokens?.backdrop ?? ["900", "100"],
1993
+ focusRing: tokens?.focusRing ?? ["500", "500"],
1994
+ link: {
1995
+ fg: tokens?.link?.fg ?? ["400", "600"]
1605
1996
  },
1606
- muted: {
1607
- ...v0.muted.default.enabled.muted,
1608
- bg: state.bg2 || state.bg
1997
+ shadow: {
1998
+ outline: tokens?.shadow?.outline ?? ["500", "500"],
1999
+ umbra: tokens?.shadow?.umbra ?? ["500", "500"],
2000
+ penumbra: tokens?.shadow?.penumbra ?? ["500", "500"],
2001
+ ambient: tokens?.shadow?.ambient ?? ["500", "500"]
1609
2002
  },
1610
2003
  skeleton: {
1611
- from: state.skeleton?.from || state.border,
1612
- to: state.skeleton?.to || state.border
2004
+ from: tokens?.skeleton?.from ?? ["900", "100"],
2005
+ to: tokens?.skeleton?.to ?? ["950", "50"]
2006
+ },
2007
+ token: {
2008
+ atrule: tokens?.token?.atrule ?? ["400", "600"],
2009
+ attribute: tokens?.token?.attribute ?? ["400", "600"],
2010
+ attrName: tokens?.token?.attrName ?? ["400", "600"],
2011
+ attrValue: tokens?.token?.attrValue ?? ["400", "600"],
2012
+ boolean: tokens?.token?.boolean ?? ["400", "600"],
2013
+ builtin: tokens?.token?.builtin ?? ["400", "600"],
2014
+ cdata: tokens?.token?.cdata ?? ["400", "600"],
2015
+ char: tokens?.token?.char ?? ["400", "600"],
2016
+ class: tokens?.token?.class ?? ["400", "600"],
2017
+ className: tokens?.token?.className ?? ["400", "600"],
2018
+ comment: tokens?.token?.comment ?? ["600", "400"],
2019
+ constant: tokens?.token?.constant ?? ["400", "600"],
2020
+ deleted: tokens?.token?.deleted ?? ["400", "600"],
2021
+ doctype: tokens?.token?.doctype ?? ["400", "600"],
2022
+ entity: tokens?.token?.entity ?? ["400", "600"],
2023
+ function: tokens?.token?.function ?? ["400", "600"],
2024
+ hexcode: tokens?.token?.hexcode ?? ["400", "600"],
2025
+ id: tokens?.token?.id ?? ["400", "600"],
2026
+ important: tokens?.token?.important ?? ["400", "600"],
2027
+ inserted: tokens?.token?.inserted ?? ["400", "600"],
2028
+ keyword: tokens?.token?.keyword ?? ["400", "600"],
2029
+ number: tokens?.token?.number ?? ["400", "600"],
2030
+ operator: tokens?.token?.operator ?? ["400", "600"],
2031
+ prolog: tokens?.token?.prolog ?? ["400", "600"],
2032
+ property: tokens?.token?.property ?? ["400", "600"],
2033
+ pseudoClass: tokens?.token?.pseudoClass ?? ["400", "600"],
2034
+ pseudoElement: tokens?.token?.pseudoElement ?? ["400", "600"],
2035
+ punctuation: tokens?.token?.punctuation ?? ["400", "600"],
2036
+ regex: tokens?.token?.regex ?? ["400", "600"],
2037
+ selector: tokens?.token?.selector ?? ["400", "600"],
2038
+ string: tokens?.token?.string ?? ["400", "600"],
2039
+ symbol: tokens?.token?.symbol ?? ["400", "600"],
2040
+ tag: tokens?.token?.tag ?? ["400", "600"],
2041
+ unit: tokens?.token?.unit ?? ["400", "600"],
2042
+ url: tokens?.token?.url ?? ["400", "600"],
2043
+ variable: tokens?.token?.variable ?? ["400", "600"]
2044
+ },
2045
+ variant: {
2046
+ solid: {
2047
+ "*": resolveElementTokens(tokens?.variant?.solid?.["*"]),
2048
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.solid?.["*"], tokens?.variant?.solid?.[tone])), acc), {})
2049
+ },
2050
+ tinted: {
2051
+ "*": resolveElementTokens(tokens?.variant?.tinted?.["*"]),
2052
+ ...THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
2053
+ }
1613
2054
  }
1614
2055
  };
1615
2056
  }
1616
- function inputStatesThemeColor_v0_v2(states) {
1617
- return {
1618
- enabled: inputStateThemeColor_v0_v2(states.enabled),
1619
- disabled: inputStateThemeColor_v0_v2(states.disabled),
1620
- readOnly: inputStateThemeColor_v0_v2(states.readOnly),
1621
- hovered: inputStateThemeColor_v0_v2(states.hovered)
1622
- };
1623
- }
1624
- function inputStateThemeColor_v0_v2(state) {
2057
+ function resolveElementTokens(tokens) {
1625
2058
  return {
1626
- bg: state.bg,
1627
- border: state.border,
1628
- fg: state.fg,
1629
- muted: {
1630
- bg: state.bg2
2059
+ _hue: tokens?._hue ?? "gray",
2060
+ bg: {
2061
+ 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
2062
+ 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
1631
2063
  },
1632
- placeholder: state.placeholder
1633
- };
1634
- }
1635
- const cache$3 = /* @__PURE__ */ new WeakMap();
1636
- function getTheme_v2(theme) {
1637
- if (theme.sanity.v2?._resolved) return theme.sanity.v2;
1638
- const cached_v2 = cache$3.get(theme);
1639
- if (cached_v2) return cached_v2;
1640
- const v2 = {
1641
- _version: 2,
1642
- _resolved: !0,
1643
- avatar: {
1644
- ...defaultThemeConfig.avatar,
1645
- ...theme.sanity.avatar
1646
- },
1647
- button: {
1648
- ...defaultThemeConfig.button,
1649
- ...theme.sanity.button
1650
- },
1651
- card: defaultThemeConfig.card,
1652
- color: themeColor_v0_v2(theme.sanity.color),
1653
- container: theme.sanity.container,
1654
- font: theme.sanity.fonts,
1655
- input: {
1656
- ...defaultThemeConfig.input,
1657
- ...theme.sanity.input,
1658
- checkbox: {
1659
- ...defaultThemeConfig.input.checkbox,
1660
- ...theme.sanity.input.checkbox
1661
- },
1662
- radio: {
1663
- ...defaultThemeConfig.input.radio,
1664
- ...theme.sanity.input.radio
1665
- },
1666
- switch: {
1667
- ...defaultThemeConfig.input.switch,
1668
- ...theme.sanity.input.switch
1669
- }
2064
+ border: {
2065
+ 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
2066
+ 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
1670
2067
  },
1671
- layer: theme.sanity.layer ?? defaultThemeConfig.layer,
1672
- media: theme.sanity.media,
1673
- radius: theme.sanity.radius,
1674
- shadow: theme.sanity.shadows,
1675
- space: theme.sanity.space,
1676
- style: theme.sanity.styles
2068
+ fg: {
2069
+ 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
2070
+ 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
2071
+ }
1677
2072
  };
1678
- return cache$3.set(theme, v2), v2;
1679
- }
1680
- function is_v0(themeProp) {
1681
- return themeProp._version === 0;
1682
- }
1683
- function is_v2(themeProp) {
1684
- return themeProp._version === 2;
1685
2073
  }
1686
- const cache$2 = /* @__PURE__ */ new WeakMap();
1687
- function v0_v2(v0) {
1688
- if (v0.v2) return v0.v2;
1689
- const cached_v2 = cache$2.get(v0);
1690
- if (cached_v2) return cached_v2;
2074
+ function buildTheme_v3(options) {
1691
2075
  const {
1692
- avatar,
1693
- button,
1694
- color: color2,
1695
- container,
1696
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1697
- focusRing: _unused_focusRing,
1698
- fonts: font,
1699
- input,
1700
- layer,
1701
- media,
1702
- radius,
1703
- shadows: shadow,
1704
- space,
1705
- styles: style
1706
- } = v0, v2 = {
1707
- _version: 2,
1708
- avatar: {
1709
- ...defaultThemeConfig.avatar,
1710
- ...avatar
1711
- },
1712
- button: {
1713
- ...defaultThemeConfig.button,
1714
- ...button
1715
- },
1716
- card: defaultThemeConfig.card,
1717
- color: {
1718
- light: {
1719
- transparent: themeColor_v0_v2(color2.light.transparent),
1720
- default: themeColor_v0_v2(color2.light.default),
1721
- primary: themeColor_v0_v2(color2.light.primary),
1722
- positive: themeColor_v0_v2(color2.light.positive),
1723
- caution: themeColor_v0_v2(color2.light.caution),
1724
- critical: themeColor_v0_v2(color2.light.critical)
1725
- },
1726
- dark: {
1727
- transparent: themeColor_v0_v2(color2.dark.transparent),
1728
- default: themeColor_v0_v2(color2.dark.default),
1729
- primary: themeColor_v0_v2(color2.dark.primary),
1730
- positive: themeColor_v0_v2(color2.dark.positive),
1731
- caution: themeColor_v0_v2(color2.dark.caution),
1732
- critical: themeColor_v0_v2(color2.dark.critical)
1733
- }
1734
- },
1735
- container,
1736
- font,
1737
- input: {
1738
- ...defaultThemeConfig.input,
1739
- ...input,
1740
- checkbox: {
1741
- ...defaultThemeConfig.input.checkbox,
1742
- ...input.checkbox
1743
- },
1744
- radio: {
1745
- ...defaultThemeConfig.input.radio,
1746
- ...input.radio
1747
- },
1748
- switch: {
1749
- ...defaultThemeConfig.input.switch,
1750
- ...input.switch
1751
- }
1752
- },
1753
- layer: layer ?? defaultThemeConfig.layer,
1754
- media,
1755
- radius,
1756
- shadow,
1757
- space,
1758
- style
1759
- };
1760
- return cache$2.set(v0, v2), v2;
1761
- }
1762
- const cache$1 = /* @__PURE__ */ new WeakMap();
1763
- function v2_v0(v2) {
1764
- const cachedTheme = cache$1.get(v2);
2076
+ v2
2077
+ } = options ?? {}, tokens = resolveTokens(options?.tokens ?? defaultTokens);
2078
+ return {
2079
+ _version: 3,
2080
+ _palette: options?.palette ?? defaultPalette,
2081
+ _tokens: tokens,
2082
+ avatar: v2?.avatar ?? defaultThemeConfig.avatar,
2083
+ button: v2?.button ?? defaultThemeConfig.button,
2084
+ card: v2?.card ?? defaultThemeConfig.card,
2085
+ color: buildColor_v3(tokens.color),
2086
+ container: v2?.container ?? defaultThemeConfig.container,
2087
+ font: v2?.font ?? defaultThemeFonts,
2088
+ input: v2?.input ?? defaultThemeConfig.input,
2089
+ layer: v2?.layer ?? defaultThemeConfig.layer,
2090
+ media: v2?.media ?? defaultThemeConfig.media,
2091
+ radius: v2?.radius ?? defaultThemeConfig.radius,
2092
+ shadow: v2?.shadow ?? defaultThemeConfig.shadow,
2093
+ space: v2?.space ?? defaultThemeConfig.space
2094
+ };
2095
+ }
2096
+ const cache$4 = /* @__PURE__ */ new WeakMap();
2097
+ function v2_v0(v2, v3) {
2098
+ const cachedTheme = cache$4.get(v2);
1765
2099
  if (cachedTheme) return cachedTheme;
1766
2100
  const {
1767
2101
  avatar,
1768
2102
  button,
1769
- color: color2,
2103
+ color,
1770
2104
  container,
1771
2105
  font: fonts,
1772
2106
  input,
@@ -1783,20 +2117,20 @@ function v2_v0(v2) {
1783
2117
  container,
1784
2118
  color: {
1785
2119
  light: {
1786
- transparent: themeColor_v2_v0(color2.light.transparent),
1787
- default: themeColor_v2_v0(color2.light.default),
1788
- primary: themeColor_v2_v0(color2.light.primary),
1789
- positive: themeColor_v2_v0(color2.light.positive),
1790
- caution: themeColor_v2_v0(color2.light.caution),
1791
- critical: themeColor_v2_v0(color2.light.critical)
2120
+ transparent: themeColor_v2_v0(color.light.transparent),
2121
+ default: themeColor_v2_v0(color.light.default),
2122
+ primary: themeColor_v2_v0(color.light.primary),
2123
+ positive: themeColor_v2_v0(color.light.positive),
2124
+ caution: themeColor_v2_v0(color.light.caution),
2125
+ critical: themeColor_v2_v0(color.light.critical)
1792
2126
  },
1793
2127
  dark: {
1794
- transparent: themeColor_v2_v0(color2.dark.transparent),
1795
- default: themeColor_v2_v0(color2.dark.default),
1796
- primary: themeColor_v2_v0(color2.dark.primary),
1797
- positive: themeColor_v2_v0(color2.dark.positive),
1798
- caution: themeColor_v2_v0(color2.dark.caution),
1799
- critical: themeColor_v2_v0(color2.dark.critical)
2128
+ transparent: themeColor_v2_v0(color.dark.transparent),
2129
+ default: themeColor_v2_v0(color.dark.default),
2130
+ primary: themeColor_v2_v0(color.dark.primary),
2131
+ positive: themeColor_v2_v0(color.dark.positive),
2132
+ caution: themeColor_v2_v0(color.dark.caution),
2133
+ critical: themeColor_v2_v0(color.dark.critical)
1800
2134
  }
1801
2135
  },
1802
2136
  focusRing: input.text.focusRing,
@@ -1807,7 +2141,8 @@ function v2_v0(v2) {
1807
2141
  shadows,
1808
2142
  space,
1809
2143
  styles,
1810
- v2
2144
+ v2,
2145
+ v3
1811
2146
  };
1812
2147
  }
1813
2148
  function themeColor_v2_v0(color_v2) {
@@ -1866,90 +2201,230 @@ function inputStateThemeColor_v2_v0(t) {
1866
2201
  placeholder: t.placeholder
1867
2202
  };
1868
2203
  }
1869
- const AVATAR_SIZE = [0, 1, 2, 3], CONTAINER = [0, 1, 2, 3, 4, 5], RADIUS = [0, 1, 2, 3, 4, 5, 6, "full"], SPACE = [0, 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9], FONT_CODE_SIZE = [0, 1, 2, 3, 4, 5], FONT_HEADING_SIZE = [0, 1, 2, 3, 4, 5, 6], FONT_LABEL_SIZE = [0, 1, 2, 3, 4, 5, 6], FONT_TEXT_SIZE = [0, 1, 2, 3, 4, 5], SHADOW = [0, 1, 2, 3, 4, 5], THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = ["transparent", "default", "primary", "positive", "caution", "critical"], THEME_COLOR_STATE_TONES = ["default", "primary", "positive", "caution", "critical"], 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_HUES;
1870
- function isColorBlendModeValue(str) {
1871
- return THEME_COLOR_BLEND_MODES.includes(str);
2204
+ function buildTheme(_config) {
2205
+ const v3 = buildTheme_v3({
2206
+ v2: _config
2207
+ });
2208
+ return v2_v0(v3_v2(v3), v3);
1872
2209
  }
1873
- function isColorHueKey(str) {
1874
- return COLOR_HUES.includes(str);
2210
+ function mixChannel(b, s, weight) {
2211
+ const delta = (s - b) * weight;
2212
+ return b + delta;
1875
2213
  }
1876
- function isColorTintKey(str) {
1877
- return COLOR_TINTS.includes(str);
2214
+ function mix(b, s, weight) {
2215
+ return {
2216
+ r: mixChannel(b.r, s.r, weight),
2217
+ g: mixChannel(b.g, s.g, weight),
2218
+ b: mixChannel(b.b, s.b, weight)
2219
+ };
1878
2220
  }
1879
- function isColorButtonMode(str) {
1880
- return THEME_COLOR_BUTTON_MODES.includes(str);
2221
+ function multiplyChannel(b, s) {
2222
+ return b * s;
1881
2223
  }
1882
- 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];
1883
- function parseTokenKey(str) {
1884
- const segments = str.split("/"), segment0 = segments.shift() || "";
1885
- if (isColorConfigBaseTone(segment0)) {
1886
- const key = segments.join("/");
1887
- if (isColorConfigBaseKey(key))
1888
- return {
1889
- type: "base",
1890
- tone: segment0,
1891
- key
1892
- };
1893
- if (isColorConfigBlendKey(key))
1894
- return {
1895
- type: "base",
1896
- tone: segment0,
1897
- key
1898
- };
1899
- }
1900
- if (segment0 === "button") {
1901
- const segment1 = segments.shift() || "";
1902
- if (isColorConfigStateTone(segment1)) {
1903
- const segment2 = segments.shift() || "";
1904
- if (isColorButtonMode(segment2)) {
1905
- const key = segments.join("/");
1906
- if (isColorConfigStateKey(key))
1907
- return {
1908
- type: "button",
1909
- tone: segment1,
1910
- mode: segment2,
1911
- key
1912
- };
1913
- if (isColorConfigBlendKey(key))
1914
- return {
1915
- type: "button",
1916
- tone: segment1,
1917
- mode: segment2,
1918
- key
1919
- };
1920
- }
1921
- }
1922
- }
2224
+ function multiply(b, s) {
2225
+ return {
2226
+ r: multiplyChannel(b.r / 255, s.r / 255) * 255,
2227
+ g: multiplyChannel(b.g / 255, s.g / 255) * 255,
2228
+ b: multiplyChannel(b.b / 255, s.b / 255) * 255
2229
+ };
1923
2230
  }
1924
- function isColorMixPercentValue(str) {
1925
- return /^\d+%$/.test(str);
2231
+ function screenChannel(b, s) {
2232
+ return b + s - b * s;
1926
2233
  }
1927
- function parseTokenValue(str) {
1928
- const segments = str.split("/");
1929
- let nextSegment = segments.shift() || "";
1930
- const [segment0, segment0mix] = nextSegment.split(" ");
1931
- if (isColorTintKey(segment0)) {
1932
- const tint = segment0, segment1 = segments.shift() || "";
1933
- if (isColorMixPercentValue(segment0mix)) {
1934
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
1935
- return {
1936
- type: "color",
1937
- tint,
1938
- mix: mix2
1939
- };
1940
- }
1941
- if (isColorOpacityValue(segment1)) {
1942
- const opacity = Number(segment1);
1943
- return {
1944
- type: "color",
1945
- tint,
1946
- opacity
1947
- };
1948
- }
2234
+ function screen(b, s) {
2235
+ return {
2236
+ r: screenChannel(b.r / 255, s.r / 255) * 255,
2237
+ g: screenChannel(b.g / 255, s.g / 255) * 255,
2238
+ b: screenChannel(b.b / 255, s.b / 255) * 255
2239
+ };
2240
+ }
2241
+ function clamp(a, min = 0, max = 1) {
2242
+ return Math.min(max, Math.max(min, a));
2243
+ }
2244
+ function round(value) {
2245
+ return Math.round(value);
2246
+ }
2247
+ function hexToRgb(hex) {
2248
+ if (hex.length === 4) {
2249
+ const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
1949
2250
  return {
1950
- type: "color",
1951
- tint
1952
- };
2251
+ r: parseInt(hexR + hexR, 16),
2252
+ g: parseInt(hexG + hexG, 16),
2253
+ b: parseInt(hexB + hexB, 16)
2254
+ };
2255
+ }
2256
+ return {
2257
+ r: parseInt(hex.slice(1, 3), 16),
2258
+ g: parseInt(hex.slice(3, 5), 16),
2259
+ b: parseInt(hex.slice(5, 7), 16)
2260
+ };
2261
+ }
2262
+ function rgbaToRGBA(rgba2) {
2263
+ const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
2264
+ return {
2265
+ r: parseInt(values[0]),
2266
+ g: parseInt(values[1]),
2267
+ b: parseInt(values[2]),
2268
+ a: parseFloat(values[3])
2269
+ };
2270
+ }
2271
+ function rgbToHex(color) {
2272
+ const r = round(clamp(Math.round(color.r), 0, 255)), g = round(clamp(Math.round(color.g), 0, 255)), b = round(clamp(Math.round(color.b), 0, 255));
2273
+ return "a" in color ? `rgba(${r},${g},${b},${color.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
2274
+ }
2275
+ function rgbToHsl({
2276
+ r,
2277
+ g,
2278
+ b
2279
+ }) {
2280
+ r /= 255, g /= 255, b /= 255;
2281
+ const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
2282
+ let h = 0, s = 0, l = 0;
2283
+ return delta == 0 ? h = 0 : cmax == r ? h = (g - b) / delta % 6 : cmax == g ? h = (b - r) / delta + 2 : h = (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), {
2284
+ h,
2285
+ s,
2286
+ l
2287
+ };
2288
+ }
2289
+ function hslToRgb(hsl) {
2290
+ const s = hsl.s / 100, l = hsl.l / 100, c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1)), m = l - c / 2;
2291
+ let r = 0, g = 0, b = 0;
2292
+ return 0 <= hsl.h && hsl.h < 60 ? (r = c, g = x, b = 0) : 60 <= hsl.h && hsl.h < 120 ? (r = x, g = c, b = 0) : 120 <= hsl.h && hsl.h < 180 ? (r = 0, g = c, b = x) : 180 <= hsl.h && hsl.h < 240 ? (r = 0, g = x, b = c) : 240 <= hsl.h && hsl.h < 300 ? (r = x, g = 0, b = c) : 300 <= hsl.h && hsl.h < 360 && (r = c, g = 0, b = x), {
2293
+ r: Math.round((r + m) * 255),
2294
+ g: Math.round((g + m) * 255),
2295
+ b: Math.round((b + m) * 255)
2296
+ };
2297
+ }
2298
+ const HEX_CHARS = "0123456789ABCDEFabcdef", HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
2299
+ function isHexChars(str) {
2300
+ for (const c of str)
2301
+ if (HEX_CHARS.indexOf(c) === -1)
2302
+ return !1;
2303
+ return !0;
2304
+ }
2305
+ function isHex(str) {
2306
+ return str[0] !== "#" || !(str.length === 4 || str.length === 7) ? !1 : isHexChars(str.slice(1));
2307
+ }
2308
+ function parseHsl(str) {
2309
+ const res = HSL_RE.exec(str);
2310
+ if (!res)
2311
+ throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
2312
+ return {
2313
+ h: parseInt(res[1]),
2314
+ s: parseFloat(res[3]),
2315
+ l: parseFloat(res[5])
2316
+ };
2317
+ }
2318
+ function parseColor(color) {
2319
+ if (!color) return {
2320
+ r: 0,
2321
+ g: 0,
2322
+ b: 0
2323
+ };
2324
+ if (typeof color != "string")
2325
+ throw new Error("parseColor: expected a string");
2326
+ if (isHex(color))
2327
+ return hexToRgb(color);
2328
+ if (color.startsWith("hsl("))
2329
+ return hslToRgb(parseHsl(color));
2330
+ if (color.startsWith("rgba("))
2331
+ return rgbaToRGBA(color);
2332
+ throw new Error(`parseColor: unexpected color format: "${color}"`);
2333
+ }
2334
+ function getContrastRatio(bg, fg) {
2335
+ const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
2336
+ return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
2337
+ }
2338
+ function rgb_lrgb({
2339
+ r,
2340
+ g,
2341
+ b
2342
+ }) {
2343
+ return [rgb_lrgb1(r / 255), rgb_lrgb1(g / 255), rgb_lrgb1(b / 255)];
2344
+ }
2345
+ function rgb_lrgb1(v) {
2346
+ return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
2347
+ }
2348
+ function lrgb_luminance([r, g, b]) {
2349
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
2350
+ }
2351
+ function rgba(color, a) {
2352
+ if (typeof color == "string" && color.startsWith("var("))
2353
+ return `color-mix(in srgb, transparent, ${color} ${a * 100}%)`;
2354
+ const rgb = parseColor(color);
2355
+ return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
2356
+ }
2357
+ 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];
2358
+ function parseTokenKey(str) {
2359
+ const segments = str.split("/"), segment0 = segments.shift() || "";
2360
+ if (isColorConfigBaseTone(segment0)) {
2361
+ const key = segments.join("/");
2362
+ if (isColorConfigBaseKey(key))
2363
+ return {
2364
+ type: "base",
2365
+ tone: segment0,
2366
+ key
2367
+ };
2368
+ if (isColorConfigBlendKey(key))
2369
+ return {
2370
+ type: "base",
2371
+ tone: segment0,
2372
+ key
2373
+ };
2374
+ }
2375
+ if (segment0 === "button") {
2376
+ const segment1 = segments.shift() || "";
2377
+ if (isColorConfigStateTone(segment1)) {
2378
+ const segment2 = segments.shift() || "";
2379
+ if (isColorButtonMode(segment2)) {
2380
+ const key = segments.join("/");
2381
+ if (isColorConfigStateKey(key))
2382
+ return {
2383
+ type: "button",
2384
+ tone: segment1,
2385
+ mode: segment2,
2386
+ key
2387
+ };
2388
+ if (isColorConfigBlendKey(key))
2389
+ return {
2390
+ type: "button",
2391
+ tone: segment1,
2392
+ mode: segment2,
2393
+ key
2394
+ };
2395
+ }
2396
+ }
2397
+ }
2398
+ }
2399
+ function isColorMixPercentValue(str) {
2400
+ return /^\d+%$/.test(str);
2401
+ }
2402
+ function parseTokenValue(str) {
2403
+ const segments = str.split("/");
2404
+ let nextSegment = segments.shift() || "";
2405
+ const [segment0, segment0mix] = nextSegment.split(" ");
2406
+ if (isColorTintKey(segment0)) {
2407
+ const tint = segment0, segment1 = segments.shift() || "";
2408
+ if (isColorMixPercentValue(segment0mix)) {
2409
+ const mix2 = Number(segment0mix.slice(0, -1)) / 100;
2410
+ return {
2411
+ type: "color",
2412
+ tint,
2413
+ mix: mix2
2414
+ };
2415
+ }
2416
+ if (isColorOpacityValue(segment1)) {
2417
+ const opacity = Number(segment1);
2418
+ return {
2419
+ type: "color",
2420
+ tint,
2421
+ opacity
2422
+ };
2423
+ }
2424
+ return {
2425
+ type: "color",
2426
+ tint
2427
+ };
1953
2428
  }
1954
2429
  if (isColorValue(segment0)) {
1955
2430
  const key = segment0, segment1 = segments.shift() || "";
@@ -2039,2077 +2514,341 @@ function isColorValue(str) {
2039
2514
  function isColorOpacityValue(str) {
2040
2515
  return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
2041
2516
  }
2042
- function compileColorTokenValue(node) {
2043
- let key = "";
2044
- 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);
2045
- }
2046
- const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
2047
- function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
2048
- const {
2049
- hue,
2050
- scheme
2051
- } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
2052
- if (!node || node.type !== "color")
2053
- throw new Error(`Invalid color token: ${value[0]}`);
2054
- return compileColorTokenValue({
2055
- ...node,
2056
- hue: node.hue || hue
2057
- });
2517
+ function is_v2(themeProp) {
2518
+ return themeProp._version === 2;
2058
2519
  }
2059
- const defaultColorTokens = {
2060
- base: {
2061
- "*": {
2062
- _blend: ["multiply", "screen"],
2063
- accent: {
2064
- fg: ["purple/600", "purple/400"]
2065
- },
2066
- avatar: {
2067
- "*": {
2068
- _blend: ["screen", "multiply"],
2069
- bg: ["500", "400"],
2070
- fg: ["white", "black"]
2071
- }
2072
- },
2073
- backdrop: ["gray/200/0.5", "black/0.5"],
2074
- badge: {
2075
- "*": {
2076
- bg: ["100", "900"],
2077
- fg: ["600", "400"],
2078
- icon: ["500", "500"],
2079
- dot: ["500", "500"]
2080
- },
2081
- positive: {
2082
- bg: ["200 50%", "900"],
2083
- fg: ["600", "500"]
2084
- },
2085
- caution: {
2086
- bg: ["200 50%", "900"],
2087
- fg: ["600", "500"]
2088
- }
2089
- },
2090
- bg: ["50", "950"],
2091
- border: ["200", "800"],
2092
- code: {
2093
- bg: ["50", "950"],
2094
- fg: ["600", "400"]
2095
- },
2096
- fg: ["800", "200"],
2097
- focusRing: ["blue/500", "blue/500"],
2098
- icon: ["600", "400"],
2099
- kbd: {
2100
- bg: ["white", "black"],
2101
- fg: ["600", "400"],
2102
- border: ["200", "800"]
2103
- },
2104
- link: {
2105
- fg: ["blue/600", "blue/300"]
2106
- },
2107
- muted: {
2108
- bg: ["50", "950"],
2109
- fg: ["700 75%", "300 75%"]
2110
- },
2111
- shadow: {
2112
- outline: ["500/0.3", "500/0.4"],
2113
- umbra: ["gray/500/0.1", "black/0.2"],
2114
- penumbra: ["gray/500/0.07", "black/0.14"],
2115
- ambient: ["gray/500/0.06", "black/0.12"]
2520
+ function themeColor_v0_v2_9(color) {
2521
+ if ("neutral" in color.badge)
2522
+ return color;
2523
+ const colors2 = color;
2524
+ return {
2525
+ ...colors2,
2526
+ badge: {
2527
+ ...colors2.badge,
2528
+ neutral: colors2.badge.default,
2529
+ suggest: colors2.badge.primary
2530
+ },
2531
+ button: {
2532
+ bleed: {
2533
+ ...colors2.button.bleed,
2534
+ neutral: colors2.button.bleed.default,
2535
+ suggest: colors2.button.bleed.primary
2116
2536
  },
2117
- skeleton: {
2118
- from: ["100", "900"],
2119
- to: ["100 50%", "900 50%"]
2537
+ default: {
2538
+ ...colors2.button.default,
2539
+ neutral: colors2.button.default.default,
2540
+ suggest: colors2.button.default.primary
2541
+ },
2542
+ ghost: {
2543
+ ...colors2.button.ghost,
2544
+ neutral: colors2.button.ghost.default,
2545
+ suggest: colors2.button.ghost.primary
2120
2546
  }
2121
2547
  },
2122
- transparent: {
2123
- bg: ["50", "black"]
2124
- },
2125
- default: {
2126
- bg: ["white", "950"],
2127
- fg: ["800", "200"],
2128
- muted: {
2129
- fg: ["600", "400"]
2130
- }
2548
+ selectable: {
2549
+ ...colors2.selectable,
2550
+ neutral: colors2.selectable.default,
2551
+ suggest: colors2.selectable.primary
2552
+ }
2553
+ };
2554
+ }
2555
+ const cache$3 = /* @__PURE__ */ new WeakMap();
2556
+ function themeColor_v0_v2(color_v0) {
2557
+ const cached_v2 = cache$3.get(color_v0);
2558
+ if (cached_v2) return cached_v2;
2559
+ const base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled), color_v2 = {
2560
+ _blend: color_v0._blend || (color_v0.dark ? "screen" : "multiply"),
2561
+ _dark: color_v0.dark,
2562
+ accent: base.accent,
2563
+ avatar: base.avatar,
2564
+ backdrop: color_v0.base.shadow.ambient,
2565
+ badge: base.badge,
2566
+ bg: color_v0.base.bg,
2567
+ border: color_v0.base.border,
2568
+ button: {
2569
+ default: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.default),
2570
+ ghost: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.ghost),
2571
+ bleed: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.bleed)
2131
2572
  },
2132
- primary: {
2133
- _hue: "blue"
2573
+ code: base.code,
2574
+ fg: color_v0.base.fg,
2575
+ focusRing: color_v0.base.focusRing,
2576
+ icon: base.muted.fg,
2577
+ input: {
2578
+ default: inputStatesThemeColor_v0_v2(color_v0.input.default),
2579
+ invalid: inputStatesThemeColor_v0_v2(color_v0.input.invalid)
2134
2580
  },
2135
- positive: {
2136
- _hue: "green",
2137
- shadow: {
2138
- outline: ["500/0.4", "500/0.4"]
2139
- }
2581
+ kbd: base.kbd,
2582
+ link: base.link,
2583
+ muted: {
2584
+ ...base.muted,
2585
+ bg: color_v0.selectable?.default.enabled.bg2 || color_v0.base.bg
2140
2586
  },
2141
- caution: {
2142
- _hue: "yellow",
2143
- shadow: {
2144
- outline: ["600/0.3", "500/0.4"]
2145
- }
2587
+ selectable: stateTonesThemeColor_v0_v2(color_v0, color_v0.selectable || color_v0.muted),
2588
+ shadow: color_v0.base.shadow,
2589
+ skeleton: {
2590
+ from: color_v0.skeleton?.from || color_v0.base.border,
2591
+ to: color_v0.skeleton?.to || color_v0.base.border
2146
2592
  },
2147
- critical: {
2148
- _hue: "red"
2149
- }
2150
- },
2151
- button: {
2593
+ syntax: color_v0.syntax
2594
+ };
2595
+ return cache$3.set(color_v0, color_v2), color_v2;
2596
+ }
2597
+ function stateTonesThemeColor_v0_v2(v0, t) {
2598
+ return {
2152
2599
  default: {
2153
- "*": {
2154
- "*": {
2155
- _blend: ["screen", "multiply"],
2156
- accent: {
2157
- fg: ["purple/300", "purple/700"]
2158
- },
2159
- avatar: {
2160
- "*": {
2161
- _blend: ["screen", "multiply"],
2162
- bg: ["500", "400"],
2163
- fg: ["white", "black"]
2164
- }
2165
- },
2166
- badge: {
2167
- "*": {
2168
- bg: ["900", "100"],
2169
- fg: ["400", "600"],
2170
- dot: ["500", "500"],
2171
- icon: ["500", "500"]
2172
- }
2173
- },
2174
- bg: ["500", "400"],
2175
- border: ["500/0", "400/0"],
2176
- code: {
2177
- bg: ["500 20%", "400 20%"],
2178
- fg: ["200", "600"]
2179
- },
2180
- fg: ["white", "black"],
2181
- icon: ["100 70%", "900 70%"],
2182
- kbd: {
2183
- bg: ["black", "white"],
2184
- fg: ["200", "600"],
2185
- border: ["800", "200"]
2186
- },
2187
- link: {
2188
- fg: ["blue/200", "blue/600"]
2189
- },
2190
- muted: {
2191
- bg: ["950", "50"],
2192
- fg: ["100 70%", "900 70%"]
2193
- },
2194
- skeleton: {
2195
- from: ["900", "100"],
2196
- to: ["900 50%", "100 50%"]
2197
- }
2198
- },
2199
- hovered: {
2200
- bg: ["700", "300"],
2201
- border: ["700/0", "300/0"]
2202
- },
2203
- pressed: {
2204
- bg: ["700", "300"]
2205
- },
2206
- selected: {
2207
- bg: ["700", "300"]
2208
- },
2209
- disabled: {
2210
- _hue: "gray",
2211
- accent: {
2212
- fg: ["100 70%", "900 70%"]
2213
- },
2214
- avatar: {
2215
- "*": {
2216
- _blend: ["screen", "multiply"],
2217
- bg: ["gray/500", "gray/400"],
2218
- fg: ["white", "black"]
2219
- }
2220
- },
2221
- badge: {
2222
- "*": {
2223
- bg: ["gray/700", "gray/300"],
2224
- fg: ["white", "black"],
2225
- dot: ["white", "black"],
2226
- icon: ["white", "black"]
2227
- }
2228
- },
2229
- bg: ["300", "600"],
2230
- code: {
2231
- bg: ["950", "50"],
2232
- fg: ["300", "600"]
2233
- },
2234
- fg: ["300", "600"],
2235
- muted: {
2236
- bg: ["950", "50"],
2237
- fg: ["300", "600"]
2238
- },
2239
- kbd: {
2240
- bg: ["black", "white"],
2241
- fg: ["white", "black"],
2242
- border: ["700", "300"]
2243
- },
2244
- link: {
2245
- fg: ["100 70%", "900 70%"]
2246
- }
2247
- }
2248
- },
2249
- default: {
2250
- "*": {
2251
- avatar: {
2252
- "*": {
2253
- _blend: ["screen", "multiply"],
2254
- bg: ["500", "400"],
2255
- fg: ["white", "black"]
2256
- }
2257
- },
2258
- bg: ["800", "200"],
2259
- muted: {
2260
- bg: ["950", "50"],
2261
- fg: ["400", "600"]
2262
- }
2263
- },
2264
- hovered: {
2265
- bg: ["900", "100"]
2266
- },
2267
- pressed: {
2268
- bg: ["black", "white"]
2269
- },
2270
- selected: {
2271
- bg: ["black", "white"]
2272
- }
2273
- }
2274
- },
2275
- ghost: {
2276
- "*": {
2277
- "*": {
2278
- _blend: ["multiply", "screen"],
2279
- accent: {
2280
- fg: ["purple/700 60%", "purple/300 70%"]
2281
- },
2282
- avatar: {
2283
- "*": {
2284
- _blend: ["screen", "multiply"],
2285
- bg: ["500", "400"],
2286
- fg: ["white", "black"]
2287
- }
2288
- },
2289
- badge: {
2290
- "*": {
2291
- bg: ["100", "900"],
2292
- fg: ["600", "400"],
2293
- dot: ["500", "500"],
2294
- icon: ["500", "500"]
2295
- }
2296
- },
2297
- bg: ["50", "950"],
2298
- border: ["100", "900"],
2299
- code: {
2300
- bg: ["500 10%", "400 10%"],
2301
- fg: ["700 60%", "400 60%"]
2302
- },
2303
- fg: ["600", "400"],
2304
- icon: ["700 60%", "300 60%"],
2305
- kbd: {
2306
- bg: ["white", "black"],
2307
- fg: ["600", "400"],
2308
- border: ["200", "800"]
2309
- },
2310
- link: {
2311
- fg: ["blue/700 60%", "blue/300 60%"]
2312
- },
2313
- muted: {
2314
- bg: ["100", "950"],
2315
- fg: ["700 60%", "300 60%"]
2316
- },
2317
- skeleton: {
2318
- from: ["100", "900"],
2319
- to: ["100 50%", "900 50%"]
2320
- }
2321
- },
2322
- hovered: {
2323
- bg: ["100", "900"],
2324
- fg: ["700", "300"]
2325
- },
2326
- pressed: {
2327
- bg: ["100", "900"],
2328
- fg: ["800", "200"]
2329
- },
2330
- selected: {
2331
- bg: ["100", "900"],
2332
- fg: ["800", "200"]
2333
- },
2334
- disabled: {
2335
- _hue: "gray",
2336
- accent: {
2337
- fg: ["200", "800"]
2338
- },
2339
- avatar: {
2340
- "*": {
2341
- _blend: ["screen", "multiply"],
2342
- bg: ["gray/100", "gray/900"],
2343
- fg: ["white", "black"]
2344
- }
2345
- },
2346
- badge: {
2347
- "*": {
2348
- _hue: "gray",
2349
- bg: ["50", "950"],
2350
- fg: ["gray/200", "gray/800"],
2351
- dot: ["gray/200", "gray/800"],
2352
- icon: ["gray/200", "gray/800"]
2353
- }
2354
- },
2355
- border: ["100", "900"],
2356
- code: {
2357
- bg: ["50", "950"],
2358
- fg: ["200", "800"]
2359
- },
2360
- fg: ["400", "600"],
2361
- icon: ["300", "700"],
2362
- muted: {
2363
- fg: ["300", "700"]
2364
- },
2365
- kbd: {
2366
- bg: ["white", "black"],
2367
- fg: ["200", "800"],
2368
- border: ["100", "900"]
2369
- },
2370
- link: {
2371
- fg: ["200", "800"]
2372
- }
2373
- }
2374
- },
2375
- positive: {
2376
- "*": {
2377
- border: ["600 20%", "800"]
2378
- }
2379
- },
2380
- caution: {
2381
- "*": {
2382
- border: ["600 20%", "800"]
2383
- }
2384
- }
2385
- },
2386
- bleed: {
2387
- "*": {
2388
- "*": {
2389
- _blend: ["multiply", "screen"],
2390
- accent: {
2391
- fg: ["purple/700 70%", "purple/300 70%"]
2392
- },
2393
- avatar: {
2394
- "*": {
2395
- _blend: ["screen", "multiply"],
2396
- bg: ["500", "400"],
2397
- fg: ["white", "black"]
2398
- }
2399
- },
2400
- badge: {
2401
- "*": {
2402
- bg: ["100", "900"],
2403
- fg: ["600", "400"],
2404
- dot: ["500", "500"],
2405
- icon: ["500", "500"]
2406
- }
2407
- },
2408
- bg: ["white", "black"],
2409
- border: ["white/0", "black/0"],
2410
- code: {
2411
- bg: ["50", "950"],
2412
- fg: ["700 75%", "300 75%"]
2413
- },
2414
- fg: ["700", "300"],
2415
- icon: ["700 75%", "300 75%"],
2416
- kbd: {
2417
- bg: ["white", "black"],
2418
- fg: ["700", "300"],
2419
- border: ["200", "800"]
2420
- },
2421
- link: {
2422
- fg: ["blue/700 70%", "blue/300 70%"]
2423
- },
2424
- muted: {
2425
- bg: ["100", "950"],
2426
- fg: ["700 75%", "300 75%"]
2427
- },
2428
- skeleton: {
2429
- from: ["100", "900"],
2430
- to: ["100 50%", "900 50%"]
2431
- }
2432
- },
2433
- hovered: {
2434
- bg: ["50", "950"],
2435
- icon: ["700 70%", "400 70%"]
2436
- },
2437
- pressed: {
2438
- bg: ["100", "900"],
2439
- fg: ["800", "200"],
2440
- icon: ["800 70%", "200 70%"]
2441
- },
2442
- selected: {
2443
- bg: ["100", "900"],
2444
- fg: ["800", "200"],
2445
- icon: ["800 60%", "200 60%"]
2446
- },
2447
- disabled: {
2448
- _hue: "gray",
2449
- accent: {
2450
- fg: ["200", "800"]
2451
- },
2452
- avatar: {
2453
- "*": {
2454
- _blend: ["screen", "multiply"],
2455
- bg: ["gray/100", "gray/900"],
2456
- fg: ["white", "black"]
2457
- }
2458
- },
2459
- badge: {
2460
- "*": {
2461
- _hue: "gray",
2462
- bg: ["50", "950"],
2463
- fg: ["gray/200", "gray/800"],
2464
- dot: ["gray/200", "gray/800"],
2465
- icon: ["gray/200", "gray/800"]
2466
- }
2467
- },
2468
- code: {
2469
- bg: ["50", "950"],
2470
- fg: ["200", "800"]
2471
- },
2472
- fg: ["400", "600"],
2473
- icon: ["300", "700"],
2474
- muted: {
2475
- fg: ["400", "600"]
2476
- },
2477
- kbd: {
2478
- bg: ["white", "black"],
2479
- fg: ["200", "800"],
2480
- border: ["100", "900"]
2481
- },
2482
- link: {
2483
- fg: ["200", "800"]
2484
- }
2485
- }
2486
- }
2487
- }
2488
- },
2489
- input: {
2490
- "*": {
2491
- "*": {
2492
- _blend: ["multiply", "screen"],
2493
- bg: ["white", "black"],
2494
- border: ["200", "700"],
2495
- fg: ["black", "200"],
2496
- muted: {
2497
- bg: ["50", "950"]
2498
- },
2499
- placeholder: ["400", "600"]
2500
- },
2501
- hovered: {
2502
- border: ["300", "700"]
2503
- },
2504
- readOnly: {
2505
- bg: ["50", "950"],
2506
- border: ["200", "800"],
2507
- fg: ["800", "200"]
2508
- },
2509
- disabled: {
2510
- bg: ["50", "950"],
2511
- fg: ["400", "600"],
2512
- border: ["100", "900"],
2513
- placeholder: ["200", "800 50%"]
2514
- }
2515
- },
2516
- invalid: {
2517
- "*": {
2518
- _hue: "red",
2519
- bg: ["100", "950"]
2520
- }
2521
- }
2522
- },
2523
- selectable: {
2524
- "*": {
2525
- "*": {
2526
- _blend: ["multiply", "screen"],
2527
- accent: {
2528
- fg: ["purple/700 70%", "purple/300 70%"]
2529
- },
2530
- avatar: {
2531
- "*": {
2532
- _blend: ["screen", "multiply"],
2533
- bg: ["500", "400"],
2534
- fg: ["white", "black"]
2535
- }
2536
- },
2537
- badge: {
2538
- "*": {
2539
- bg: ["100", "900"],
2540
- fg: ["600", "400"],
2541
- dot: ["500", "500"],
2542
- icon: ["500", "500"]
2543
- }
2544
- },
2545
- bg: ["white", "black"],
2546
- border: ["200", "800"],
2547
- code: {
2548
- bg: ["50", "950"],
2549
- fg: ["600", "400"]
2550
- },
2551
- fg: ["700", "300"],
2552
- icon: ["700 75%", "300 75%"],
2553
- kbd: {
2554
- bg: ["white", "black"],
2555
- fg: ["600", "400"],
2556
- border: ["200", "800"]
2557
- },
2558
- link: {
2559
- fg: ["blue/700 70%", "blue/300 70%"]
2560
- },
2561
- muted: {
2562
- bg: ["50", "950"],
2563
- fg: ["700 75%", "300 75%"]
2564
- },
2565
- skeleton: {
2566
- from: ["100", "900"],
2567
- to: ["100 50%", "900 50%"]
2568
- }
2569
- },
2570
- hovered: {
2571
- bg: ["50", "950"]
2572
- },
2573
- pressed: {
2574
- bg: ["100", "900"]
2575
- },
2576
- selected: {
2577
- _blend: ["screen", "multiply"],
2578
- accent: {
2579
- fg: ["purple/300", "purple/700"]
2580
- },
2581
- avatar: {
2582
- "*": {
2583
- _blend: ["multiply", "screen"],
2584
- bg: ["white", "black"],
2585
- fg: ["black", "white"]
2586
- }
2587
- },
2588
- badge: {
2589
- "*": {
2590
- bg: ["900", "100"],
2591
- fg: ["400", "600"],
2592
- dot: ["500", "500"],
2593
- icon: ["500", "500"]
2594
- }
2595
- },
2596
- bg: ["500", "400"],
2597
- border: ["500 20%", "400 20%"],
2598
- code: {
2599
- bg: ["500 20%", "400 20%"],
2600
- fg: ["200", "600"]
2601
- },
2602
- fg: ["white", "black"],
2603
- icon: ["100 70%", "900 70%"],
2604
- kbd: {
2605
- bg: ["black", "white"],
2606
- fg: ["200", "600"],
2607
- border: ["800", "200"]
2608
- },
2609
- link: {
2610
- fg: ["blue/200", "blue/600"]
2611
- },
2612
- muted: {
2613
- bg: ["500 10%", "400 10%"],
2614
- fg: ["100 70%", "900 70%"]
2615
- },
2616
- skeleton: {
2617
- from: ["900", "100"],
2618
- to: ["900 50%", "100 50%"]
2619
- }
2620
- },
2621
- disabled: {
2622
- _hue: "gray",
2623
- accent: {
2624
- fg: ["200", "800"]
2625
- },
2626
- avatar: {
2627
- "*": {
2628
- _blend: ["screen", "multiply"],
2629
- bg: ["gray/100", "gray/900"],
2630
- fg: ["white", "black"]
2631
- }
2632
- },
2633
- badge: {
2634
- "*": {
2635
- _hue: "gray",
2636
- bg: ["50", "950"],
2637
- fg: ["gray/200", "gray/800"],
2638
- dot: ["gray/200", "gray/800"],
2639
- icon: ["gray/200", "gray/800"]
2640
- }
2641
- },
2642
- border: ["100", "900"],
2643
- code: {
2644
- bg: ["50", "950"],
2645
- fg: ["200", "800"]
2646
- },
2647
- fg: ["200", "800"],
2648
- icon: ["200", "800"],
2649
- kbd: {
2650
- bg: ["white", "black"],
2651
- fg: ["200", "800"],
2652
- border: ["100", "900"]
2653
- },
2654
- link: {
2655
- fg: ["200", "800"]
2656
- },
2657
- muted: {
2658
- bg: ["50 50%", "950 50%"],
2659
- fg: ["200", "800"]
2660
- }
2661
- }
2662
- },
2663
- default: {
2664
- selected: {
2665
- _hue: "blue"
2666
- }
2667
- },
2668
- critical: {
2669
- disabled: {
2670
- bg: ["50 50%", "950 50%"]
2671
- }
2672
- }
2673
- },
2674
- syntax: {
2675
- atrule: ["purple/600", "purple/400"],
2676
- attrName: ["green/600", "green/400"],
2677
- attrValue: ["yellow/600", "yellow/400"],
2678
- attribute: ["yellow/600", "yellow/400"],
2679
- boolean: ["purple/600", "purple/400"],
2680
- builtin: ["purple/600", "purple/400"],
2681
- cdata: ["yellow/600", "yellow/400"],
2682
- char: ["yellow/600", "yellow/400"],
2683
- class: ["orange/600", "orange/400"],
2684
- className: ["cyan/600", "cyan/400"],
2685
- comment: ["gray/400", "gray/600"],
2686
- constant: ["purple/600", "purple/400"],
2687
- deleted: ["red/600", "red/400"],
2688
- entity: ["red/600", "red/400"],
2689
- function: ["green/600", "green/400"],
2690
- hexcode: ["blue/600", "blue/400"],
2691
- id: ["purple/600", "purple/400"],
2692
- important: ["purple/600", "purple/400"],
2693
- inserted: ["yellow/600", "yellow/400"],
2694
- keyword: ["magenta/600", "magenta/400"],
2695
- number: ["purple/600", "purple/400"],
2696
- operator: ["magenta/600", "magenta/400"],
2697
- property: ["blue/600", "blue/400"],
2698
- pseudoClass: ["yellow/600", "yellow/400"],
2699
- pseudoElement: ["yellow/600", "yellow/400"],
2700
- punctuation: ["gray/600", "gray/400"],
2701
- regex: ["blue/600", "blue/400"],
2702
- selector: ["red/600", "red/400"],
2703
- string: ["yellow/600", "yellow/400"],
2704
- symbol: ["purple/600", "purple/400"],
2705
- tag: ["red/600", "red/400"],
2706
- unit: ["orange/600", "orange/400"],
2707
- url: ["red/600", "red/400"],
2708
- variable: ["red/600", "red/400"]
2709
- }
2710
- };
2711
- function isRecord(value) {
2712
- return !!(value && typeof value == "object" && !Array.isArray(value));
2713
- }
2714
- function merge(...records) {
2715
- const _records = records.filter(Boolean);
2716
- return _records.length === 0 ? {} : _records.reduce(_merge, {});
2717
- }
2718
- function _merge(acc, source) {
2719
- for (const key of Object.keys(source)) {
2720
- const prevValue = acc[key], nextValue = source[key];
2721
- isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
2722
- }
2723
- return acc;
2724
- }
2725
- function resolveColorTokens(inputTokens) {
2726
- const tokens = merge(defaultColorTokens, inputTokens);
2727
- return {
2728
- base: resolveBaseColorTokens(tokens),
2729
- button: resolveButtonColorTokens(tokens),
2730
- input: resolveInputColorTokens(tokens),
2731
- selectable: resolveSelectableColorTokens(tokens),
2732
- syntax: tokens.syntax
2733
- };
2734
- }
2735
- function resolveBaseColorTokens(sparseTokens) {
2736
- const tokens = {};
2737
- for (const tone of THEME_COLOR_CARD_TONES)
2738
- tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
2739
- return tokens;
2740
- }
2741
- function resolveBaseColorTones(inputTokens, tone) {
2742
- const spec = merge(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
2743
- return {
2744
- ...spec,
2745
- _hue: hue,
2746
- avatar: {
2747
- gray: merge({
2748
- _hue: "gray"
2749
- }, spec.avatar?.["*"], spec.avatar?.gray),
2750
- blue: merge({
2751
- _hue: "blue"
2752
- }, spec.avatar?.["*"], spec.avatar?.blue),
2753
- purple: merge({
2754
- _hue: "purple"
2755
- }, spec.avatar?.["*"], spec.avatar?.purple),
2756
- magenta: merge({
2757
- _hue: "magenta"
2758
- }, spec.avatar?.["*"], spec.avatar?.magenta),
2759
- red: merge({
2760
- _hue: "red"
2761
- }, spec.avatar?.["*"], spec.avatar?.red),
2762
- orange: merge({
2763
- _hue: "orange"
2764
- }, spec.avatar?.["*"], spec.avatar?.orange),
2765
- yellow: merge({
2766
- _hue: "yellow"
2767
- }, spec.avatar?.["*"], spec.avatar?.yellow),
2768
- green: merge({
2769
- _hue: "green"
2770
- }, spec.avatar?.["*"], spec.avatar?.green),
2771
- cyan: merge({
2772
- _hue: "cyan"
2773
- }, spec.avatar?.["*"], spec.avatar?.cyan)
2774
- },
2775
- badge: {
2776
- default: {
2777
- _hue: inputTokens?.base?.default?._hue || hue,
2778
- ...spec.badge?.["*"],
2779
- ...spec.badge?.default
2780
- },
2781
- primary: {
2782
- _hue: inputTokens?.base?.primary?._hue || hue,
2783
- ...spec.badge?.["*"],
2784
- ...spec.badge?.primary
2785
- },
2786
- positive: {
2787
- _hue: inputTokens?.base?.positive?._hue || hue,
2788
- ...spec.badge?.["*"],
2789
- ...spec.badge?.positive
2790
- },
2791
- caution: {
2792
- _hue: inputTokens?.base?.caution?._hue || hue,
2793
- ...spec.badge?.["*"],
2794
- ...spec.badge?.caution
2795
- },
2796
- critical: {
2797
- _hue: inputTokens?.base?.critical?._hue || hue,
2798
- ...spec.badge?.["*"],
2799
- ...spec.badge?.critical
2800
- }
2801
- }
2802
- };
2803
- }
2804
- function resolveButtonColorTokens(inputTokens) {
2805
- const tokens = {};
2806
- for (const mode of THEME_COLOR_BUTTON_MODES)
2807
- tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
2808
- return tokens;
2809
- }
2810
- function resolveButtonToneColorTokens(inputTokens, mode) {
2811
- const tokens = {};
2812
- for (const tone of THEME_COLOR_STATE_TONES)
2813
- tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
2814
- return tokens;
2815
- }
2816
- function resolveButtonModeColorTokens(inputTokens, mode, tone) {
2817
- const tokens = {};
2818
- for (const state of THEME_COLOR_STATES)
2819
- tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
2820
- return tokens;
2821
- }
2822
- function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
2823
- const spec = merge(inputTokens?.button?.[mode]?.["*"]?.["*"], inputTokens?.button?.[mode]?.[tone]?.["*"], inputTokens?.button?.[mode]?.["*"]?.[state], inputTokens?.button?.[mode]?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2824
- return {
2825
- ...spec,
2826
- _hue: hue,
2827
- avatar: {
2828
- gray: merge({
2829
- _hue: "gray"
2830
- }, spec.avatar?.["*"], spec.avatar?.gray),
2831
- blue: merge({
2832
- _hue: "blue"
2833
- }, spec.avatar?.["*"], spec.avatar?.blue),
2834
- purple: merge({
2835
- _hue: "purple"
2836
- }, spec.avatar?.["*"], spec.avatar?.purple),
2837
- magenta: merge({
2838
- _hue: "magenta"
2839
- }, spec.avatar?.["*"], spec.avatar?.magenta),
2840
- red: merge({
2841
- _hue: "red"
2842
- }, spec.avatar?.["*"], spec.avatar?.red),
2843
- orange: merge({
2844
- _hue: "orange"
2845
- }, spec.avatar?.["*"], spec.avatar?.orange),
2846
- yellow: merge({
2847
- _hue: "yellow"
2848
- }, spec.avatar?.["*"], spec.avatar?.yellow),
2849
- green: merge({
2850
- _hue: "green"
2851
- }, spec.avatar?.["*"], spec.avatar?.green),
2852
- cyan: merge({
2853
- _hue: "cyan"
2854
- }, spec.avatar?.["*"], spec.avatar?.cyan)
2855
- },
2856
- badge: {
2857
- default: {
2858
- _hue: inputTokens?.base?.default?._hue,
2859
- ...spec.badge?.["*"],
2860
- ...spec.badge?.default
2861
- },
2862
- primary: {
2863
- _hue: inputTokens?.base?.primary?._hue,
2864
- ...spec.badge?.["*"],
2865
- ...spec.badge?.primary
2866
- },
2867
- positive: {
2868
- _hue: inputTokens?.base?.positive?._hue,
2869
- ...spec.badge?.["*"],
2870
- ...spec.badge?.positive
2871
- },
2872
- caution: {
2873
- _hue: inputTokens?.base?.caution?._hue,
2874
- ...spec.badge?.["*"],
2875
- ...spec.badge?.caution
2876
- },
2877
- critical: {
2878
- _hue: inputTokens?.base?.critical?._hue,
2879
- ...spec.badge?.["*"],
2880
- ...spec.badge?.critical
2881
- }
2882
- }
2883
- };
2884
- }
2885
- function resolveInputColorTokens(inputTokens) {
2886
- const tokens = {};
2887
- for (const mode of THEME_COLOR_INPUT_MODES)
2888
- tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
2889
- return tokens;
2890
- }
2891
- function resolveInputModeColorTokens(inputTokens, mode) {
2892
- const states = {};
2893
- for (const state of THEME_COLOR_INPUT_STATES)
2894
- states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
2895
- return states;
2896
- }
2897
- function resolveInputStateColorTokens(inputTokens, mode, state) {
2898
- const spec = merge(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
2899
- return {
2900
- ...spec,
2901
- _hue: hue
2902
- };
2903
- }
2904
- function resolveSelectableColorTokens(inputTokens) {
2905
- const tokens = {};
2906
- for (const tone of THEME_COLOR_STATE_TONES)
2907
- tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
2908
- return tokens;
2909
- }
2910
- function resolveSelectableToneColorTokens(inputTokens, tone) {
2911
- const states = {
2912
- _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue
2913
- };
2914
- for (const state of THEME_COLOR_STATES)
2915
- states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
2916
- return states;
2917
- }
2918
- function resolveSelectableStateColorTokens(inputTokens, tone, state) {
2919
- const spec = merge(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2920
- return {
2921
- ...spec,
2922
- _hue: hue,
2923
- avatar: {
2924
- gray: merge({
2925
- _hue: "gray"
2926
- }, spec.avatar?.["*"], spec.avatar?.gray),
2927
- blue: merge({
2928
- _hue: "blue"
2929
- }, spec.avatar?.["*"], spec.avatar?.blue),
2930
- purple: merge({
2931
- _hue: "purple"
2932
- }, spec.avatar?.["*"], spec.avatar?.purple),
2933
- magenta: merge({
2934
- _hue: "magenta"
2935
- }, spec.avatar?.["*"], spec.avatar?.magenta),
2936
- red: merge({
2937
- _hue: "red"
2938
- }, spec.avatar?.["*"], spec.avatar?.red),
2939
- orange: merge({
2940
- _hue: "orange"
2941
- }, spec.avatar?.["*"], spec.avatar?.orange),
2942
- yellow: merge({
2943
- _hue: "yellow"
2944
- }, spec.avatar?.["*"], spec.avatar?.yellow),
2945
- green: merge({
2946
- _hue: "green"
2947
- }, spec.avatar?.["*"], spec.avatar?.green),
2948
- cyan: merge({
2949
- _hue: "cyan"
2950
- }, spec.avatar?.["*"], spec.avatar?.cyan)
2951
- },
2952
- badge: {
2953
- default: {
2954
- _hue: inputTokens?.base?.default?._hue,
2955
- ...spec.badge?.["*"],
2956
- ...spec.badge?.default
2957
- },
2958
- primary: {
2959
- _hue: inputTokens?.base?.primary?._hue,
2960
- ...spec.badge?.["*"],
2961
- ...spec.badge?.primary
2962
- },
2963
- positive: {
2964
- _hue: inputTokens?.base?.positive?._hue,
2965
- ...spec.badge?.["*"],
2966
- ...spec.badge?.positive
2967
- },
2968
- caution: {
2969
- _hue: inputTokens?.base?.caution?._hue,
2970
- ...spec.badge?.["*"],
2971
- ...spec.badge?.caution
2972
- },
2973
- critical: {
2974
- _hue: inputTokens?.base?.critical?._hue,
2975
- ...spec.badge?.["*"],
2976
- ...spec.badge?.critical
2977
- }
2978
- }
2979
- };
2980
- }
2981
- function buildColorTheme(config) {
2982
- const resolvedConfig = {
2983
- ...config,
2984
- color: resolveColorTokens(config?.color)
2985
- };
2986
- return {
2987
- light: buildColorScheme({
2988
- scheme: "light"
2989
- }, resolvedConfig),
2990
- dark: buildColorScheme({
2991
- scheme: "dark"
2992
- }, resolvedConfig)
2993
- };
2994
- }
2995
- function buildColorScheme(options, config) {
2996
- const {
2997
- scheme
2998
- } = options;
2999
- return {
3000
- transparent: buildCardColorTheme({
3001
- scheme,
3002
- tone: "transparent"
3003
- }, config),
3004
- default: buildCardColorTheme({
3005
- scheme,
3006
- tone: "default"
3007
- }, config),
3008
- primary: buildCardColorTheme({
3009
- scheme,
3010
- tone: "primary"
3011
- }, config),
3012
- positive: buildCardColorTheme({
3013
- scheme,
3014
- tone: "positive"
3015
- }, config),
3016
- caution: buildCardColorTheme({
3017
- scheme,
3018
- tone: "caution"
3019
- }, config),
3020
- critical: buildCardColorTheme({
3021
- scheme,
3022
- tone: "critical"
3023
- }, config)
3024
- };
3025
- }
3026
- function buildCardColorTheme(options, config) {
3027
- const {
3028
- scheme,
3029
- tone
3030
- } = options, tokens = config?.color?.base?.[tone], context = {
3031
- hue: tokens?._hue || "gray",
3032
- scheme
3033
- };
3034
- return {
3035
- _blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
3036
- _dark: scheme === "dark",
3037
- accent: {
3038
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3039
- },
3040
- avatar: buildAvatarColorTheme({
3041
- scheme
3042
- }, tokens),
3043
- backdrop: resolveColorTokenValue(context, tokens?.backdrop),
3044
- badge: buildBadgeColorTheme(tokens?.badge, {
3045
- scheme
3046
- }, config),
3047
- bg: resolveColorTokenValue(context, tokens?.bg),
3048
- border: resolveColorTokenValue(context, tokens?.border),
3049
- button: buildButtonColorTheme({
3050
- scheme
3051
- }, config),
3052
- code: {
3053
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3054
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3055
- },
3056
- fg: resolveColorTokenValue(context, tokens?.fg),
3057
- focusRing: resolveColorTokenValue(context, tokens?.focusRing),
3058
- icon: resolveColorTokenValue(context, tokens?.icon),
3059
- input: buildInputColorTheme({
3060
- scheme,
3061
- tone
3062
- }, config),
3063
- kbd: {
3064
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3065
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3066
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3067
- },
3068
- link: {
3069
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
3070
- },
3071
- muted: {
3072
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3073
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3074
- },
3075
- selectable: buildSelectableColorTheme({
3076
- scheme
3077
- }, config),
3078
- shadow: buildShadowColorTheme({
3079
- scheme,
3080
- tone
3081
- }, config),
3082
- skeleton: {
3083
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3084
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3085
- },
3086
- syntax: buildSyntaxColorTheme({
3087
- scheme
3088
- }, config)
3089
- };
3090
- }
3091
- function buildShadowColorTheme(options, config) {
3092
- const {
3093
- scheme,
3094
- tone
3095
- } = options, tokens = config?.color?.base?.[tone], context = {
3096
- hue: tokens?._hue || "gray",
3097
- scheme
3098
- };
3099
- return {
3100
- outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
3101
- umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
3102
- penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
3103
- ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
3104
- };
3105
- }
3106
- function buildAvatarColorTheme(options, stateTokens) {
3107
- const {
3108
- scheme
3109
- } = options;
3110
- return {
3111
- gray: _buildAvatarColorTheme({
3112
- color: "gray",
3113
- scheme
3114
- }, stateTokens),
3115
- blue: _buildAvatarColorTheme({
3116
- color: "blue",
3117
- scheme
3118
- }, stateTokens),
3119
- purple: _buildAvatarColorTheme({
3120
- color: "purple",
3121
- scheme
3122
- }, stateTokens),
3123
- magenta: _buildAvatarColorTheme({
3124
- color: "magenta",
3125
- scheme
3126
- }, stateTokens),
3127
- red: _buildAvatarColorTheme({
3128
- color: "red",
3129
- scheme
3130
- }, stateTokens),
3131
- orange: _buildAvatarColorTheme({
3132
- color: "orange",
3133
- scheme
3134
- }, stateTokens),
3135
- yellow: _buildAvatarColorTheme({
3136
- color: "yellow",
3137
- scheme
3138
- }, stateTokens),
3139
- green: _buildAvatarColorTheme({
3140
- color: "green",
3141
- scheme
3142
- }, stateTokens),
3143
- cyan: _buildAvatarColorTheme({
3144
- color: "cyan",
3145
- scheme
3146
- }, stateTokens)
3147
- };
3148
- }
3149
- function _buildAvatarColorTheme(options, stateTokens) {
3150
- const {
3151
- color: color2,
3152
- scheme
3153
- } = options, tokens = stateTokens?.avatar?.[color2], context = {
3154
- hue: tokens?._hue || "gray",
3155
- scheme
3156
- };
3157
- return {
3158
- _blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
3159
- bg: resolveColorTokenValue(context, tokens?.bg),
3160
- fg: resolveColorTokenValue(context, tokens?.fg)
3161
- };
3162
- }
3163
- function buildBadgeColorTheme(tokens, options, config) {
3164
- const {
3165
- scheme
3166
- } = options;
3167
- return {
3168
- default: _buildBadgeColorTheme(tokens, {
3169
- scheme,
3170
- tone: "default"
3171
- }, config),
3172
- primary: _buildBadgeColorTheme(tokens, {
3173
- scheme,
3174
- tone: "primary"
3175
- }, config),
3176
- positive: _buildBadgeColorTheme(tokens, {
3177
- scheme,
3178
- tone: "positive"
3179
- }, config),
3180
- caution: _buildBadgeColorTheme(tokens, {
3181
- scheme,
3182
- tone: "caution"
3183
- }, config),
3184
- critical: _buildBadgeColorTheme(tokens, {
3185
- scheme,
3186
- tone: "critical"
3187
- }, config)
3188
- };
3189
- }
3190
- function _buildBadgeColorTheme(parentTokens, options, config) {
3191
- const {
3192
- scheme,
3193
- tone
3194
- } = options, tokens = parentTokens?.[tone], context = {
3195
- hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
3196
- scheme
3197
- };
3198
- return {
3199
- bg: resolveColorTokenValue(context, tokens?.bg),
3200
- fg: resolveColorTokenValue(context, tokens?.fg),
3201
- dot: resolveColorTokenValue(context, tokens?.dot),
3202
- icon: resolveColorTokenValue(context, tokens?.icon)
3203
- };
3204
- }
3205
- function buildButtonColorTheme(options, config) {
3206
- const {
3207
- scheme
3208
- } = options, modes = {};
3209
- for (const mode of THEME_COLOR_BUTTON_MODES)
3210
- modes[mode] = buildButtonTonesColorTheme({
3211
- scheme,
3212
- mode
3213
- }, config);
3214
- return modes;
3215
- }
3216
- function buildButtonTonesColorTheme(options, config) {
3217
- const {
3218
- mode,
3219
- scheme
3220
- } = options, tones2 = {};
3221
- for (const tone of THEME_COLOR_STATE_TONES)
3222
- tones2[tone] = buildButtonStatesColorTheme({
3223
- mode,
3224
- scheme,
3225
- tone
3226
- }, config);
3227
- return tones2;
3228
- }
3229
- function buildButtonStatesColorTheme(options, config) {
3230
- const {
3231
- mode,
3232
- scheme,
3233
- tone
3234
- } = options, states = {};
3235
- for (const state of THEME_COLOR_STATES)
3236
- states[state] = buildButtonStateColorTheme({
3237
- mode,
3238
- tone,
3239
- scheme,
3240
- state
3241
- }, config);
3242
- return states;
3243
- }
3244
- function buildButtonStateColorTheme(options, config) {
3245
- const {
3246
- mode,
3247
- tone,
3248
- scheme,
3249
- state
3250
- } = options, tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3251
- hue,
3252
- scheme
3253
- };
3254
- return {
3255
- _blend: blendMode[scheme === "light" ? 0 : 1],
3256
- accent: {
3257
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3258
- },
3259
- avatar: buildAvatarColorTheme({
3260
- scheme
3261
- }, tokens),
3262
- badge: buildBadgeColorTheme(tokens?.badge, {
3263
- scheme
3264
- }, config),
3265
- bg: resolveColorTokenValue(context, tokens?.bg),
3266
- border: resolveColorTokenValue(context, tokens?.border),
3267
- code: {
3268
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3269
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3270
- },
3271
- fg: resolveColorTokenValue(context, tokens?.fg),
3272
- icon: resolveColorTokenValue(context, tokens?.icon),
3273
- muted: {
3274
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3275
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3276
- },
3277
- kbd: {
3278
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3279
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3280
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3281
- },
3282
- link: {
3283
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
3284
- },
3285
- skeleton: {
3286
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3287
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3288
- }
3289
- };
3290
- }
3291
- function buildInputColorTheme(options, config) {
3292
- const {
3293
- scheme,
3294
- tone
3295
- } = options;
3296
- return {
3297
- default: buildInputStatesColorTheme({
3298
- mode: "default",
3299
- scheme,
3300
- tone
3301
- }, config),
3302
- invalid: buildInputStatesColorTheme({
3303
- mode: "invalid",
3304
- scheme,
3305
- tone
3306
- }, config)
3307
- };
3308
- }
3309
- function buildInputStatesColorTheme(options, config) {
3310
- const {
3311
- mode,
3312
- scheme,
3313
- tone
3314
- } = options;
3315
- return {
3316
- enabled: buildInputStateColorTheme({
3317
- mode,
3318
- scheme,
3319
- state: "enabled",
3320
- tone
3321
- }, config),
3322
- hovered: buildInputStateColorTheme({
3323
- mode,
3324
- scheme,
3325
- state: "hovered",
3326
- tone
3327
- }, config),
3328
- readOnly: buildInputStateColorTheme({
3329
- mode,
3330
- scheme,
3331
- state: "readOnly",
3332
- tone
3333
- }, config),
3334
- disabled: buildInputStateColorTheme({
3335
- mode,
3336
- scheme,
3337
- state: "disabled",
3338
- tone
3339
- }, config)
3340
- };
3341
- }
3342
- function buildInputStateColorTheme(options, config) {
3343
- const {
3344
- mode,
3345
- tone,
3346
- scheme,
3347
- state
3348
- } = options, tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || config?.color?.base?.[tone]?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3349
- hue,
3350
- scheme
3351
- };
3352
- return {
3353
- _blend: blendMode[scheme === "light" ? 0 : 1],
3354
- bg: resolveColorTokenValue(context, tokens?.bg),
3355
- border: resolveColorTokenValue(context, tokens?.border),
3356
- fg: resolveColorTokenValue(context, tokens?.fg),
3357
- muted: {
3358
- bg: resolveColorTokenValue(context, tokens?.muted?.bg)
3359
- },
3360
- placeholder: resolveColorTokenValue(context, tokens?.placeholder)
3361
- };
3362
- }
3363
- function buildSelectableColorTheme(options, config) {
3364
- const {
3365
- scheme
3366
- } = options, tones2 = {};
3367
- for (const tone of THEME_COLOR_STATE_TONES)
3368
- tones2[tone] = buildSelectableStatesColorTheme({
3369
- scheme,
3370
- tone
3371
- }, config);
3372
- return tones2;
3373
- }
3374
- function buildSelectableStatesColorTheme(options, config) {
3375
- const {
3376
- scheme,
3377
- tone
3378
- } = options, states = {};
3379
- for (const state of THEME_COLOR_STATES)
3380
- states[state] = buildSelectableStateColorTheme({
3381
- tone,
3382
- scheme,
3383
- state
3384
- }, config);
3385
- return states;
3386
- }
3387
- function buildSelectableStateColorTheme(options, config) {
3388
- const {
3389
- scheme,
3390
- state,
3391
- tone
3392
- } = options, tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3393
- hue,
3394
- scheme
3395
- };
3396
- return {
3397
- _blend: blendMode[scheme === "light" ? 0 : 1],
3398
- accent: {
3399
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3400
- },
3401
- avatar: buildAvatarColorTheme({
3402
- scheme
3403
- }, tokens),
3404
- badge: buildBadgeColorTheme(tokens?.badge, {
3405
- scheme
3406
- }, config),
3407
- bg: resolveColorTokenValue(context, tokens?.bg),
3408
- border: resolveColorTokenValue(context, tokens?.border),
3409
- code: {
3410
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3411
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3412
- },
3413
- fg: resolveColorTokenValue(context, tokens?.fg),
3414
- icon: resolveColorTokenValue(context, tokens?.icon),
3415
- muted: {
3416
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3417
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3418
- },
3419
- kbd: {
3420
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3421
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3422
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3423
- },
3424
- link: {
3425
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
2600
+ enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
2601
+ hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
2602
+ pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
2603
+ selected: stateThemeColor_v0_v2(v0, t.default.selected),
2604
+ disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
3426
2605
  },
3427
- skeleton: {
3428
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3429
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3430
- }
3431
- };
3432
- }
3433
- function buildSyntaxColorTheme(options, config) {
3434
- const {
3435
- scheme
3436
- } = options, tokens = config?.color?.syntax, context = {
3437
- hue: "gray",
3438
- scheme
3439
- };
3440
- return {
3441
- atrule: resolveColorTokenValue(context, tokens?.atrule),
3442
- attrName: resolveColorTokenValue(context, tokens?.attrName),
3443
- attrValue: resolveColorTokenValue(context, tokens?.attrValue),
3444
- attribute: resolveColorTokenValue(context, tokens?.attribute),
3445
- boolean: resolveColorTokenValue(context, tokens?.boolean),
3446
- builtin: resolveColorTokenValue(context, tokens?.builtin),
3447
- cdata: resolveColorTokenValue(context, tokens?.cdata),
3448
- char: resolveColorTokenValue(context, tokens?.char),
3449
- class: resolveColorTokenValue(context, tokens?.class),
3450
- className: resolveColorTokenValue(context, tokens?.className),
3451
- comment: resolveColorTokenValue(context, tokens?.comment),
3452
- constant: resolveColorTokenValue(context, tokens?.constant),
3453
- deleted: resolveColorTokenValue(context, tokens?.deleted),
3454
- doctype: resolveColorTokenValue(context, tokens?.doctype),
3455
- entity: resolveColorTokenValue(context, tokens?.entity),
3456
- function: resolveColorTokenValue(context, tokens?.function),
3457
- hexcode: resolveColorTokenValue(context, tokens?.hexcode),
3458
- id: resolveColorTokenValue(context, tokens?.id),
3459
- important: resolveColorTokenValue(context, tokens?.important),
3460
- inserted: resolveColorTokenValue(context, tokens?.inserted),
3461
- keyword: resolveColorTokenValue(context, tokens?.keyword),
3462
- number: resolveColorTokenValue(context, tokens?.number),
3463
- operator: resolveColorTokenValue(context, tokens?.operator),
3464
- prolog: resolveColorTokenValue(context, tokens?.prolog),
3465
- property: resolveColorTokenValue(context, tokens?.property),
3466
- pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
3467
- pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
3468
- punctuation: resolveColorTokenValue(context, tokens?.punctuation),
3469
- regex: resolveColorTokenValue(context, tokens?.regex),
3470
- selector: resolveColorTokenValue(context, tokens?.selector),
3471
- string: resolveColorTokenValue(context, tokens?.string),
3472
- symbol: resolveColorTokenValue(context, tokens?.symbol),
3473
- tag: resolveColorTokenValue(context, tokens?.tag),
3474
- unit: resolveColorTokenValue(context, tokens?.unit),
3475
- url: resolveColorTokenValue(context, tokens?.url),
3476
- variable: resolveColorTokenValue(context, tokens?.variable)
3477
- };
3478
- }
3479
- const defaultColorPalette = color;
3480
- function mixChannel(b, s, weight) {
3481
- const delta = (s - b) * weight;
3482
- return b + delta;
3483
- }
3484
- function mix(b, s, weight) {
3485
- return {
3486
- r: mixChannel(b.r, s.r, weight),
3487
- g: mixChannel(b.g, s.g, weight),
3488
- b: mixChannel(b.b, s.b, weight)
3489
- };
3490
- }
3491
- function multiplyChannel(b, s) {
3492
- return b * s;
3493
- }
3494
- function multiply(b, s) {
3495
- return {
3496
- r: multiplyChannel(b.r / 255, s.r / 255) * 255,
3497
- g: multiplyChannel(b.g / 255, s.g / 255) * 255,
3498
- b: multiplyChannel(b.b / 255, s.b / 255) * 255
3499
- };
3500
- }
3501
- function screenChannel(b, s) {
3502
- return b + s - b * s;
3503
- }
3504
- function screen(b, s) {
3505
- return {
3506
- r: screenChannel(b.r / 255, s.r / 255) * 255,
3507
- g: screenChannel(b.g / 255, s.g / 255) * 255,
3508
- b: screenChannel(b.b / 255, s.b / 255) * 255
3509
- };
3510
- }
3511
- function lerp(x, y, a) {
3512
- return x * (1 - a) + y * a;
3513
- }
3514
- function invlerp(x, y, a) {
3515
- return clamp((a - x) / (y - x));
3516
- }
3517
- function clamp(a, min = 0, max = 1) {
3518
- return Math.min(max, Math.max(min, a));
3519
- }
3520
- function range(x1, y1, x2, y2, a) {
3521
- return lerp(x2, y2, invlerp(x1, y1, a));
3522
- }
3523
- function round(value) {
3524
- return Math.round(value);
3525
- }
3526
- function hexToRgb(hex) {
3527
- if (hex.length === 4) {
3528
- const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
3529
- return {
3530
- r: parseInt(hexR + hexR, 16),
3531
- g: parseInt(hexG + hexG, 16),
3532
- b: parseInt(hexB + hexB, 16)
3533
- };
3534
- }
3535
- return {
3536
- r: parseInt(hex.slice(1, 3), 16),
3537
- g: parseInt(hex.slice(3, 5), 16),
3538
- b: parseInt(hex.slice(5, 7), 16)
3539
- };
3540
- }
3541
- function rgbaToRGBA(rgba2) {
3542
- const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
3543
- return {
3544
- r: parseInt(values[0]),
3545
- g: parseInt(values[1]),
3546
- b: parseInt(values[2]),
3547
- a: parseFloat(values[3])
3548
- };
3549
- }
3550
- function rgbToHex(color2) {
3551
- const r = round(clamp(Math.round(color2.r), 0, 255)), g = round(clamp(Math.round(color2.g), 0, 255)), b = round(clamp(Math.round(color2.b), 0, 255));
3552
- return "a" in color2 ? `rgba(${r},${g},${b},${color2.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3553
- }
3554
- function rgbToHsl({
3555
- r,
3556
- g,
3557
- b
3558
- }) {
3559
- r /= 255, g /= 255, b /= 255;
3560
- const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
3561
- let h = 0, s = 0, l = 0;
3562
- return delta == 0 ? h = 0 : cmax == r ? h = (g - b) / delta % 6 : cmax == g ? h = (b - r) / delta + 2 : h = (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), {
3563
- h,
3564
- s,
3565
- l
3566
- };
3567
- }
3568
- function hslToRgb(hsl) {
3569
- const s = hsl.s / 100, l = hsl.l / 100, c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1)), m = l - c / 2;
3570
- let r = 0, g = 0, b = 0;
3571
- return 0 <= hsl.h && hsl.h < 60 ? (r = c, g = x, b = 0) : 60 <= hsl.h && hsl.h < 120 ? (r = x, g = c, b = 0) : 120 <= hsl.h && hsl.h < 180 ? (r = 0, g = c, b = x) : 180 <= hsl.h && hsl.h < 240 ? (r = 0, g = x, b = c) : 240 <= hsl.h && hsl.h < 300 ? (r = x, g = 0, b = c) : 300 <= hsl.h && hsl.h < 360 && (r = c, g = 0, b = x), {
3572
- r: Math.round((r + m) * 255),
3573
- g: Math.round((g + m) * 255),
3574
- b: Math.round((b + m) * 255)
3575
- };
3576
- }
3577
- const HEX_CHARS = "0123456789ABCDEFabcdef", HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
3578
- function isHexChars(str) {
3579
- for (const c of str)
3580
- if (HEX_CHARS.indexOf(c) === -1)
3581
- return !1;
3582
- return !0;
3583
- }
3584
- function isHex(str) {
3585
- return str[0] !== "#" || !(str.length === 4 || str.length === 7) ? !1 : isHexChars(str.slice(1));
3586
- }
3587
- function parseHsl(str) {
3588
- const res = HSL_RE.exec(str);
3589
- if (!res)
3590
- throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
3591
- return {
3592
- h: parseInt(res[1]),
3593
- s: parseFloat(res[3]),
3594
- l: parseFloat(res[5])
3595
- };
3596
- }
3597
- function parseColor(color2) {
3598
- if (!color2) return {
3599
- r: 0,
3600
- g: 0,
3601
- b: 0
3602
- };
3603
- if (typeof color2 != "string")
3604
- throw new Error("parseColor: expected a string");
3605
- if (isHex(color2))
3606
- return hexToRgb(color2);
3607
- if (color2.startsWith("hsl("))
3608
- return hslToRgb(parseHsl(color2));
3609
- if (color2.startsWith("rgba("))
3610
- return rgbaToRGBA(color2);
3611
- throw new Error(`parseColor: unexpected color format: "${color2}"`);
3612
- }
3613
- function getContrastRatio(bg, fg) {
3614
- const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
3615
- return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
3616
- }
3617
- function rgb_lrgb({
3618
- r,
3619
- g,
3620
- b
3621
- }) {
3622
- return [rgb_lrgb1(r / 255), rgb_lrgb1(g / 255), rgb_lrgb1(b / 255)];
3623
- }
3624
- function rgb_lrgb1(v) {
3625
- return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
3626
- }
3627
- function lrgb_luminance([r, g, b]) {
3628
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
3629
- }
3630
- function rgba(color2, a) {
3631
- const rgb = parseColor(color2);
3632
- return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
3633
- }
3634
- const RGB_RANGE = [0, 255];
3635
- function mixThemeColor(value, options) {
3636
- const {
3637
- blendMode
3638
- } = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
3639
- r: [black2.r, white2.r],
3640
- g: [black2.g, white2.g],
3641
- b: [black2.b, white2.b]
3642
- }, convertedBgColor = {
3643
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
3644
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
3645
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
3646
- }, convertedColor = {
3647
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, color2.r), ...RGB_RANGE),
3648
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, color2.g), ...RGB_RANGE),
3649
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, color2.b), ...RGB_RANGE)
3650
- }, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor), v = {
3651
- r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
3652
- g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
3653
- b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
3654
- };
3655
- return rgbToHex(v);
3656
- }
3657
- function renderColorValue(str, options) {
3658
- const {
3659
- bg,
3660
- blendMode,
3661
- colorPalette
3662
- } = options;
3663
- if (bg === "white")
3664
- throw new Error("Cannot blend with white background");
3665
- const node = parseTokenValue(str);
3666
- if (!node || node.type !== "color")
3667
- throw new Error(`Invalid color token value: ${str}`);
3668
- let hex = "";
3669
- 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)
3670
- throw new Error(`Invalid color token value: ${str}`);
3671
- const hexBeforeMix = hex, mixOptions = {
3672
- blendMode,
3673
- bg,
3674
- black: renderColorHex(colorPalette.black),
3675
- // opacity: node.opacity,
3676
- white: renderColorHex(colorPalette.white)
3677
- };
3678
- try {
3679
- if (hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0) {
3680
- const from = hexToRgb(bg), to = hexToRgb(hex);
3681
- hex = rgbToHex(mix(from, to, node.mix));
3682
- }
3683
- } catch (err) {
3684
- throw console.warn("could not blend", hex, mixOptions), err;
3685
- }
3686
- return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
3687
- }
3688
- function renderColorHex(color2) {
3689
- return typeof color2 == "string" ? color2 : color2.hex;
3690
- }
3691
- function renderThemeColorSchemes(value, config) {
3692
- const colorPalette = config?.palette ?? defaultColorPalette;
3693
- return {
3694
- light: renderThemeColorScheme(colorPalette, value.light),
3695
- dark: renderThemeColorScheme(colorPalette, value.dark)
3696
- };
3697
- }
3698
- function renderThemeColorScheme(colorPalette, value) {
3699
- const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, {
3700
- colorPalette
3701
- }), renderedDefaultTone = renderThemeColor(defaultTone, {
3702
- colorPalette
3703
- }), bg = renderedDefaultTone.bg;
3704
- if (bg === "white")
3705
- throw new Error("Cannot blend with white background");
3706
- return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(([k]) => k !== "default" && k !== "transparent").map(([k, v]) => [k, renderThemeColor(v, {
3707
- bg,
3708
- colorPalette
3709
- })])]);
3710
- }
3711
- function renderThemeColor(value, options) {
3712
- const {
3713
- colorPalette,
3714
- bg
3715
- } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
3716
- colorPalette,
3717
- bg,
3718
- blendMode
3719
- }), colorOptions = {
3720
- colorPalette,
3721
- bg: baseBg,
3722
- blendMode
3723
- }, button = renderThemeColorButton(value.button, {
3724
- baseBg,
3725
- blendMode,
3726
- colorPalette
3727
- }), selectable = renderThemeColorSelectable(value.selectable, {
3728
- colorPalette,
3729
- baseBg,
3730
- blendMode
3731
- }), shadow = {
3732
- outline: renderColorValue(value.shadow.outline, colorOptions),
3733
- umbra: renderColorValue(value.shadow.umbra, {
3734
- ...colorOptions,
3735
- bg: void 0,
3736
- colorPalette: {
3737
- ...colorPalette,
3738
- black: "#000000"
3739
- }
3740
- }),
3741
- penumbra: renderColorValue(value.shadow.penumbra, {
3742
- ...colorOptions,
3743
- bg: void 0,
3744
- colorPalette: {
3745
- ...colorPalette,
3746
- black: "#000000"
3747
- }
3748
- }),
3749
- ambient: renderColorValue(value.shadow.ambient, {
3750
- ...colorOptions,
3751
- bg: void 0,
3752
- colorPalette: {
3753
- ...colorPalette,
3754
- black: "#000000"
3755
- }
3756
- })
3757
- };
3758
- return {
3759
- _blend: blendMode,
3760
- _dark: value._dark,
3761
- accent: {
3762
- fg: renderColorValue(value.accent.fg, colorOptions)
2606
+ neutral: {
2607
+ enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
2608
+ hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
2609
+ pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
2610
+ selected: stateThemeColor_v0_v2(v0, t.default.selected),
2611
+ disabled: stateThemeColor_v0_v2(v0, t.default.disabled)
3763
2612
  },
3764
- avatar: renderThemeColorAvatar(value.avatar, {
3765
- baseBg,
3766
- colorPalette,
3767
- blendMode
3768
- }),
3769
- backdrop: renderColorValue(value.backdrop, colorOptions),
3770
- badge: renderThemeColorBadge(value.badge, {
3771
- baseBg,
3772
- colorPalette,
3773
- blendMode
3774
- }),
3775
- bg: baseBg,
3776
- border: renderColorValue(value.border, colorOptions),
3777
- button,
3778
- code: {
3779
- bg: renderColorValue(value.code.bg, colorOptions),
3780
- fg: renderColorValue(value.code.fg, colorOptions)
2613
+ primary: {
2614
+ enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
2615
+ hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
2616
+ pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
2617
+ selected: stateThemeColor_v0_v2(v0, t.primary.selected),
2618
+ disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
3781
2619
  },
3782
- fg: renderColorValue(value.fg, colorOptions),
3783
- focusRing: renderColorValue(value.focusRing, colorOptions),
3784
- icon: renderColorValue(value.icon, colorOptions),
3785
- input: renderThemeColorInput(value.input, {
3786
- baseBg,
3787
- colorPalette,
3788
- blendMode
3789
- }),
3790
- kbd: renderThemeColorKBD(value.kbd, {
3791
- baseBg,
3792
- colorPalette,
3793
- blendMode
3794
- }),
3795
- link: {
3796
- fg: renderColorValue(value.link.fg, colorOptions)
2620
+ suggest: {
2621
+ enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
2622
+ hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
2623
+ pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
2624
+ selected: stateThemeColor_v0_v2(v0, t.primary.selected),
2625
+ disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
3797
2626
  },
3798
- muted: {
3799
- bg: renderColorValue(value.muted.bg, colorOptions),
3800
- fg: renderColorValue(value.muted.fg, colorOptions)
2627
+ positive: {
2628
+ enabled: stateThemeColor_v0_v2(v0, t.positive.enabled),
2629
+ hovered: stateThemeColor_v0_v2(v0, t.positive.hovered),
2630
+ pressed: stateThemeColor_v0_v2(v0, t.positive.pressed),
2631
+ selected: stateThemeColor_v0_v2(v0, t.positive.selected),
2632
+ disabled: stateThemeColor_v0_v2(v0, t.positive.disabled)
3801
2633
  },
3802
- shadow,
3803
- skeleton: {
3804
- from: renderColorValue(value.skeleton.from, colorOptions),
3805
- to: renderColorValue(value.skeleton.to, colorOptions)
2634
+ caution: {
2635
+ enabled: stateThemeColor_v0_v2(v0, t.caution.enabled),
2636
+ hovered: stateThemeColor_v0_v2(v0, t.caution.hovered),
2637
+ pressed: stateThemeColor_v0_v2(v0, t.caution.pressed),
2638
+ selected: stateThemeColor_v0_v2(v0, t.caution.selected),
2639
+ disabled: stateThemeColor_v0_v2(v0, t.caution.disabled)
3806
2640
  },
3807
- syntax: renderSyntaxColorTheme(value.syntax, {
3808
- baseBg,
3809
- colorPalette,
3810
- blendMode
3811
- }),
3812
- selectable
3813
- };
3814
- }
3815
- function renderThemeColorKBD(value, options) {
3816
- const {
3817
- baseBg,
3818
- blendMode,
3819
- colorPalette
3820
- } = options, rootOptions = {
3821
- bg: baseBg,
3822
- blendMode,
3823
- colorPalette
3824
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3825
- bg,
3826
- blendMode,
3827
- colorPalette
3828
- };
3829
- return {
3830
- bg,
3831
- fg: renderColorValue(value.fg, colorOptions),
3832
- border: renderColorValue(value.border, colorOptions)
3833
- };
3834
- }
3835
- function renderThemeColorAvatar(value, options) {
3836
- return {
3837
- gray: renderThemeColorAvatarColor(value.gray, options),
3838
- blue: renderThemeColorAvatarColor(value.blue, options),
3839
- purple: renderThemeColorAvatarColor(value.purple, options),
3840
- magenta: renderThemeColorAvatarColor(value.magenta, options),
3841
- red: renderThemeColorAvatarColor(value.red, options),
3842
- orange: renderThemeColorAvatarColor(value.orange, options),
3843
- yellow: renderThemeColorAvatarColor(value.yellow, options),
3844
- green: renderThemeColorAvatarColor(value.green, options),
3845
- cyan: renderThemeColorAvatarColor(value.cyan, options)
3846
- };
3847
- }
3848
- function renderThemeColorAvatarColor(value, options) {
3849
- const {
3850
- baseBg,
3851
- blendMode: rootBlendMode,
3852
- colorPalette
3853
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3854
- bg: baseBg,
3855
- blendMode: rootBlendMode,
3856
- colorPalette
3857
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3858
- bg,
3859
- blendMode,
3860
- colorPalette
3861
- };
3862
- return {
3863
- _blend: blendMode,
3864
- bg,
3865
- fg: renderColorValue(value.fg, colorOptions)
3866
- };
3867
- }
3868
- function renderThemeColorBadge(value, options) {
3869
- return {
3870
- default: renderThemeColorBadgeColor(value.default, options),
3871
- primary: renderThemeColorBadgeColor(value.primary, options),
3872
- positive: renderThemeColorBadgeColor(value.positive, options),
3873
- caution: renderThemeColorBadgeColor(value.caution, options),
3874
- critical: renderThemeColorBadgeColor(value.critical, options)
3875
- };
3876
- }
3877
- function renderThemeColorBadgeColor(value, options) {
3878
- const {
3879
- baseBg,
3880
- blendMode: rootBlendMode,
3881
- colorPalette
3882
- } = options, blendMode = rootBlendMode, rootOptions = {
3883
- bg: baseBg,
3884
- blendMode: rootBlendMode,
3885
- colorPalette
3886
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3887
- bg,
3888
- blendMode,
3889
- colorPalette
3890
- };
3891
- return {
3892
- bg,
3893
- dot: renderColorValue(value.dot, colorOptions),
3894
- fg: renderColorValue(value.fg, colorOptions),
3895
- icon: renderColorValue(value.icon, colorOptions)
3896
- };
3897
- }
3898
- function renderThemeColorButton(value, options) {
3899
- return {
3900
- default: renderThemeColorButtonTones(value.default, options),
3901
- ghost: renderThemeColorButtonTones(value.ghost, options),
3902
- bleed: renderThemeColorButtonTones(value.bleed, options)
3903
- };
3904
- }
3905
- function renderThemeColorButtonTones(value, options) {
3906
- return {
3907
- default: renderThemeColorButtonStates(value.default, options),
3908
- primary: renderThemeColorButtonStates(value.primary, options),
3909
- positive: renderThemeColorButtonStates(value.positive, options),
3910
- caution: renderThemeColorButtonStates(value.caution, options),
3911
- critical: renderThemeColorButtonStates(value.critical, options)
3912
- };
3913
- }
3914
- function renderThemeColorButtonStates(value, options) {
3915
- return {
3916
- enabled: renderThemeColorState(value.enabled, options),
3917
- hovered: renderThemeColorState(value.hovered, options),
3918
- pressed: renderThemeColorState(value.pressed, options),
3919
- selected: renderThemeColorState(value.selected, options),
3920
- disabled: renderThemeColorState(value.disabled, options)
2641
+ critical: {
2642
+ enabled: stateThemeColor_v0_v2(v0, t.critical.enabled),
2643
+ hovered: stateThemeColor_v0_v2(v0, t.critical.hovered),
2644
+ pressed: stateThemeColor_v0_v2(v0, t.critical.pressed),
2645
+ selected: stateThemeColor_v0_v2(v0, t.critical.selected),
2646
+ disabled: stateThemeColor_v0_v2(v0, t.critical.disabled)
2647
+ }
3921
2648
  };
3922
2649
  }
3923
- function renderThemeColorState(value, options) {
3924
- const {
3925
- baseBg,
3926
- blendMode: rootBlendMode,
3927
- colorPalette
3928
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3929
- bg: baseBg,
3930
- blendMode: rootBlendMode,
3931
- colorPalette
3932
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3933
- bg,
3934
- blendMode,
3935
- colorPalette
3936
- };
2650
+ function stateThemeColor_v0_v2(v0, state) {
3937
2651
  return {
3938
- _blend: blendMode,
3939
- accent: {
3940
- fg: renderColorValue(value.accent.fg, colorOptions)
2652
+ ...state,
2653
+ avatar: {
2654
+ gray: {
2655
+ bg: v0.spot.gray,
2656
+ fg: v0.base.bg
2657
+ },
2658
+ blue: {
2659
+ bg: v0.spot.blue,
2660
+ fg: v0.base.bg
2661
+ },
2662
+ purple: {
2663
+ bg: v0.spot.purple,
2664
+ fg: v0.base.bg
2665
+ },
2666
+ magenta: {
2667
+ bg: v0.spot.magenta,
2668
+ fg: v0.base.bg
2669
+ },
2670
+ red: {
2671
+ bg: v0.spot.red,
2672
+ fg: v0.base.bg
2673
+ },
2674
+ orange: {
2675
+ bg: v0.spot.orange,
2676
+ fg: v0.base.bg
2677
+ },
2678
+ yellow: {
2679
+ bg: v0.spot.yellow,
2680
+ fg: v0.base.bg
2681
+ },
2682
+ green: {
2683
+ bg: v0.spot.green,
2684
+ fg: v0.base.bg
2685
+ },
2686
+ cyan: {
2687
+ bg: v0.spot.cyan,
2688
+ fg: v0.base.bg
2689
+ }
3941
2690
  },
3942
- avatar: renderThemeColorAvatar(value.avatar, {
3943
- baseBg: bg,
3944
- colorPalette,
3945
- blendMode
3946
- }),
3947
- badge: renderThemeColorBadge(value.badge, {
3948
- baseBg: bg,
3949
- colorPalette,
3950
- blendMode
3951
- }),
3952
- bg,
3953
- border: renderColorValue(value.border, colorOptions),
3954
- code: {
3955
- bg: renderColorValue(value.code.bg, colorOptions),
3956
- fg: renderColorValue(value.code.fg, colorOptions)
2691
+ badge: {
2692
+ default: {
2693
+ bg: v0.muted.default.enabled.bg,
2694
+ fg: v0.muted.default.enabled.fg,
2695
+ dot: v0.muted.default.enabled.muted.fg,
2696
+ icon: v0.muted.default.enabled.muted.fg
2697
+ },
2698
+ neutral: {
2699
+ bg: v0.muted.transparent.enabled.bg,
2700
+ fg: v0.muted.transparent.enabled.fg,
2701
+ dot: v0.muted.transparent.enabled.muted.fg,
2702
+ icon: v0.muted.transparent.enabled.muted.fg
2703
+ },
2704
+ primary: {
2705
+ bg: v0.muted.primary.enabled.bg,
2706
+ fg: v0.muted.primary.enabled.fg,
2707
+ dot: v0.muted.primary.enabled.muted.fg,
2708
+ icon: v0.muted.primary.enabled.muted.fg
2709
+ },
2710
+ suggest: {
2711
+ bg: v0.muted.primary.enabled.bg,
2712
+ fg: v0.muted.primary.enabled.fg,
2713
+ dot: v0.muted.primary.enabled.muted.fg,
2714
+ icon: v0.muted.primary.enabled.muted.fg
2715
+ },
2716
+ positive: {
2717
+ bg: v0.muted.positive.enabled.bg,
2718
+ fg: v0.muted.positive.enabled.fg,
2719
+ dot: v0.muted.positive.enabled.muted.fg,
2720
+ icon: v0.muted.positive.enabled.muted.fg
2721
+ },
2722
+ caution: {
2723
+ bg: v0.muted.caution.enabled.bg,
2724
+ fg: v0.muted.caution.enabled.fg,
2725
+ dot: v0.muted.caution.enabled.muted.fg,
2726
+ icon: v0.muted.caution.enabled.muted.fg
2727
+ },
2728
+ critical: {
2729
+ bg: v0.muted.critical.enabled.bg,
2730
+ fg: v0.muted.critical.enabled.fg,
2731
+ dot: v0.muted.critical.enabled.muted.fg,
2732
+ icon: v0.muted.critical.enabled.muted.fg
2733
+ }
3957
2734
  },
3958
- fg: renderColorValue(value.fg, colorOptions),
3959
- icon: renderColorValue(value.icon, colorOptions),
3960
- link: {
3961
- fg: renderColorValue(value.link.fg, colorOptions)
2735
+ kbd: {
2736
+ bg: v0.muted.default.enabled.bg,
2737
+ fg: v0.muted.default.enabled.fg,
2738
+ border: v0.muted.default.enabled.border
3962
2739
  },
3963
2740
  muted: {
3964
- bg: renderColorValue(value.muted.bg, colorOptions),
3965
- fg: renderColorValue(value.muted.fg, colorOptions)
3966
- },
3967
- kbd: {
3968
- bg: renderColorValue(value.kbd.bg, colorOptions),
3969
- fg: renderColorValue(value.kbd.fg, colorOptions),
3970
- border: renderColorValue(value.kbd.border, colorOptions)
2741
+ ...v0.muted.default.enabled.muted,
2742
+ bg: state.bg2 || state.bg
3971
2743
  },
3972
2744
  skeleton: {
3973
- from: renderColorValue(value.skeleton?.from, colorOptions),
3974
- to: renderColorValue(value.skeleton?.to, colorOptions)
2745
+ from: state.skeleton?.from || state.border,
2746
+ to: state.skeleton?.to || state.border
3975
2747
  }
3976
2748
  };
3977
2749
  }
3978
- function renderThemeColorInput(value, options) {
3979
- return {
3980
- default: renderInputStatesColorTheme(value.default, options),
3981
- invalid: renderInputStatesColorTheme(value.invalid, options)
3982
- };
3983
- }
3984
- function renderInputStatesColorTheme(value, options) {
2750
+ function inputStatesThemeColor_v0_v2(states) {
3985
2751
  return {
3986
- enabled: renderInputStateColorTheme(value.enabled, options),
3987
- hovered: renderInputStateColorTheme(value.hovered, options),
3988
- readOnly: renderInputStateColorTheme(value.readOnly, options),
3989
- disabled: renderInputStateColorTheme(value.disabled, options)
2752
+ enabled: inputStateThemeColor_v0_v2(states.enabled),
2753
+ disabled: inputStateThemeColor_v0_v2(states.disabled),
2754
+ readOnly: inputStateThemeColor_v0_v2(states.readOnly),
2755
+ hovered: inputStateThemeColor_v0_v2(states.hovered)
3990
2756
  };
3991
2757
  }
3992
- function renderInputStateColorTheme(value, options) {
3993
- const {
3994
- baseBg,
3995
- blendMode: rootBlendMode,
3996
- colorPalette
3997
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3998
- colorPalette,
3999
- bg: baseBg,
4000
- blendMode: rootBlendMode
4001
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
4002
- colorPalette,
4003
- bg,
4004
- blendMode
4005
- };
2758
+ function inputStateThemeColor_v0_v2(state) {
4006
2759
  return {
4007
- _blend: blendMode,
4008
- bg,
4009
- border: renderColorValue(value.border, colorOptions),
4010
- fg: renderColorValue(value.fg, colorOptions),
2760
+ bg: state.bg,
2761
+ border: state.border,
2762
+ fg: state.fg,
4011
2763
  muted: {
4012
- bg: renderColorValue(value.muted.bg, colorOptions)
2764
+ bg: state.bg2
4013
2765
  },
4014
- placeholder: renderColorValue(value.placeholder, colorOptions)
4015
- };
4016
- }
4017
- function renderThemeColorSelectable(value, options) {
4018
- return {
4019
- default: renderThemeColorSelectableStates(value.default, options),
4020
- primary: renderThemeColorSelectableStates(value.primary, options),
4021
- positive: renderThemeColorSelectableStates(value.positive, options),
4022
- caution: renderThemeColorSelectableStates(value.caution, options),
4023
- critical: renderThemeColorSelectableStates(value.critical, options)
4024
- };
4025
- }
4026
- function renderThemeColorSelectableStates(value, options) {
4027
- return {
4028
- enabled: renderThemeColorState(value.enabled, options),
4029
- hovered: renderThemeColorState(value.hovered, options),
4030
- pressed: renderThemeColorState(value.pressed, options),
4031
- selected: renderThemeColorState(value.selected, options),
4032
- disabled: renderThemeColorState(value.disabled, options)
2766
+ placeholder: state.placeholder
4033
2767
  };
4034
2768
  }
4035
- function renderSyntaxColorTheme(value, options) {
2769
+ const cache$2 = /* @__PURE__ */ new WeakMap();
2770
+ function v0_v2(v0) {
2771
+ if (v0.v2) return v0.v2;
2772
+ const cached_v2 = cache$2.get(v0);
2773
+ if (cached_v2) return cached_v2;
4036
2774
  const {
4037
- colorPalette,
4038
- baseBg,
4039
- blendMode
4040
- } = options, colorOptions = {
4041
- colorPalette,
4042
- bg: baseBg,
4043
- blendMode
4044
- };
4045
- return {
4046
- atrule: renderColorValue(value.atrule, colorOptions),
4047
- attrName: renderColorValue(value.attrName, colorOptions),
4048
- attrValue: renderColorValue(value.attrValue, colorOptions),
4049
- attribute: renderColorValue(value.attribute, colorOptions),
4050
- boolean: renderColorValue(value.boolean, colorOptions),
4051
- builtin: renderColorValue(value.builtin, colorOptions),
4052
- cdata: renderColorValue(value.cdata, colorOptions),
4053
- char: renderColorValue(value.char, colorOptions),
4054
- class: renderColorValue(value.class, colorOptions),
4055
- className: renderColorValue(value.className, colorOptions),
4056
- comment: renderColorValue(value.comment, colorOptions),
4057
- constant: renderColorValue(value.constant, colorOptions),
4058
- deleted: renderColorValue(value.deleted, colorOptions),
4059
- doctype: renderColorValue(value.doctype, colorOptions),
4060
- entity: renderColorValue(value.entity, colorOptions),
4061
- function: renderColorValue(value.function, colorOptions),
4062
- hexcode: renderColorValue(value.hexcode, colorOptions),
4063
- id: renderColorValue(value.id, colorOptions),
4064
- important: renderColorValue(value.important, colorOptions),
4065
- inserted: renderColorValue(value.inserted, colorOptions),
4066
- keyword: renderColorValue(value.keyword, colorOptions),
4067
- number: renderColorValue(value.number, colorOptions),
4068
- operator: renderColorValue(value.operator, colorOptions),
4069
- prolog: renderColorValue(value.prolog, colorOptions),
4070
- property: renderColorValue(value.property, colorOptions),
4071
- pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
4072
- pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
4073
- punctuation: renderColorValue(value.punctuation, colorOptions),
4074
- regex: renderColorValue(value.regex, colorOptions),
4075
- selector: renderColorValue(value.selector, colorOptions),
4076
- string: renderColorValue(value.string, colorOptions),
4077
- symbol: renderColorValue(value.symbol, colorOptions),
4078
- tag: renderColorValue(value.tag, colorOptions),
4079
- unit: renderColorValue(value.unit, colorOptions),
4080
- url: renderColorValue(value.url, colorOptions),
4081
- variable: renderColorValue(value.variable, colorOptions)
4082
- };
4083
- }
4084
- function buildTheme(config) {
4085
- const colorTheme = buildColorTheme(config), v2 = {
2775
+ avatar,
2776
+ button,
2777
+ color,
2778
+ container,
2779
+ fonts: font,
2780
+ input,
2781
+ layer,
2782
+ media,
2783
+ radius,
2784
+ shadows: shadow,
2785
+ space,
2786
+ styles: style
2787
+ } = v0, v2 = {
4086
2788
  _version: 2,
4087
- avatar: config?.avatar ?? defaultThemeConfig.avatar,
4088
- button: config?.button ?? defaultThemeConfig.button,
4089
- card: config?.card ?? defaultThemeConfig.card,
4090
- // How colors are generated:
4091
- // 1. Merge custom tokens with default tokens
4092
- // 2. Generate tree of color keys (gray/500, black, white, etc.)
4093
- // 3. Apply mixing and render to hex values
4094
- // render(build(mergeWithDefaults()))
4095
- color: renderThemeColorSchemes(colorTheme, config),
4096
- container: config?.container ?? defaultThemeConfig.container,
4097
- font: config?.font ?? defaultThemeFonts,
4098
- input: config?.input ?? defaultThemeConfig.input,
4099
- layer: config?.layer ?? defaultThemeConfig.layer,
4100
- media: config?.media ?? defaultThemeConfig.media,
4101
- radius: config?.radius ?? defaultThemeConfig.radius,
4102
- shadow: config?.shadow ?? defaultThemeConfig.shadow,
4103
- space: config?.space ?? defaultThemeConfig.space,
4104
- style: config?.style ?? defaultThemeConfig.style
2789
+ avatar: {
2790
+ ...defaultThemeConfig.avatar,
2791
+ ...avatar
2792
+ },
2793
+ button: {
2794
+ ...defaultThemeConfig.button,
2795
+ ...button
2796
+ },
2797
+ card: defaultThemeConfig.card,
2798
+ color: {
2799
+ light: {
2800
+ transparent: themeColor_v0_v2(color.light.transparent),
2801
+ default: themeColor_v0_v2(color.light.default),
2802
+ neutral: themeColor_v0_v2(color.light.transparent),
2803
+ primary: themeColor_v0_v2(color.light.primary),
2804
+ suggest: themeColor_v0_v2(color.light.primary),
2805
+ positive: themeColor_v0_v2(color.light.positive),
2806
+ caution: themeColor_v0_v2(color.light.caution),
2807
+ critical: themeColor_v0_v2(color.light.critical)
2808
+ },
2809
+ dark: {
2810
+ transparent: themeColor_v0_v2(color.dark.transparent),
2811
+ default: themeColor_v0_v2(color.dark.default),
2812
+ neutral: themeColor_v0_v2(color.dark.transparent),
2813
+ primary: themeColor_v0_v2(color.dark.primary),
2814
+ suggest: themeColor_v0_v2(color.dark.primary),
2815
+ positive: themeColor_v0_v2(color.dark.positive),
2816
+ caution: themeColor_v0_v2(color.dark.caution),
2817
+ critical: themeColor_v0_v2(color.dark.critical)
2818
+ }
2819
+ },
2820
+ container,
2821
+ font,
2822
+ input: {
2823
+ ...defaultThemeConfig.input,
2824
+ ...input,
2825
+ checkbox: {
2826
+ ...defaultThemeConfig.input.checkbox,
2827
+ ...input.checkbox
2828
+ },
2829
+ radio: {
2830
+ ...defaultThemeConfig.input.radio,
2831
+ ...input.radio
2832
+ },
2833
+ switch: {
2834
+ ...defaultThemeConfig.input.switch,
2835
+ ...input.switch
2836
+ }
2837
+ },
2838
+ layer: layer ?? defaultThemeConfig.layer,
2839
+ media,
2840
+ radius,
2841
+ shadow,
2842
+ space,
2843
+ style
4105
2844
  };
4106
- return v2_v0(v2);
2845
+ return cache$2.set(v0, v2), v2;
4107
2846
  }
4108
- const cache = /* @__PURE__ */ new Map();
2847
+ const cache$1 = /* @__PURE__ */ new Map();
4109
2848
  function getScopedTheme(themeProp, scheme, tone) {
4110
2849
  const cachedTheme = _getCachedTheme(themeProp, scheme, tone);
4111
2850
  if (cachedTheme) return cachedTheme;
4112
- const v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp, v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp), colorScheme_v0 = v0.color[scheme] || v0.color.light, color_v0 = colorScheme_v0[tone] || colorScheme_v0.default, layer_v0 = v0.layer || defaultThemeConfig.layer, colorScheme_v2 = v2.color[scheme] || v2.color.light, color_v2 = colorScheme_v2[tone] || colorScheme_v2.default, layer_v2 = v2.layer || defaultThemeConfig.layer, theme = {
2851
+ const v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp, v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp), colorScheme_v0 = v0.color[scheme] || v0.color.light, color_v0 = colorScheme_v0[tone] || colorScheme_v0.default, layer_v0 = v0.layer || defaultThemeConfig.layer, colorScheme_v2 = v2.color[scheme] || v2.color.light, color_v2 = colorScheme_v2[tone] || colorScheme_v2.default, color_v2_9 = themeColor_v0_v2_9(color_v2), layer_v2 = v2.layer || defaultThemeConfig.layer, theme = {
4113
2852
  sanity: {
4114
2853
  ...v0,
4115
2854
  color: color_v0,
@@ -4117,7 +2856,7 @@ function getScopedTheme(themeProp, scheme, tone) {
4117
2856
  v2: {
4118
2857
  ...v2,
4119
2858
  _resolved: !0,
4120
- color: color_v2,
2859
+ color: color_v2_9,
4121
2860
  layer: layer_v2
4122
2861
  }
4123
2862
  }
@@ -4125,17 +2864,62 @@ function getScopedTheme(themeProp, scheme, tone) {
4125
2864
  return _setCachedTheme(themeProp, scheme, tone, theme), theme;
4126
2865
  }
4127
2866
  function _getCachedTheme(rootTheme, scheme, tone) {
4128
- const schemeCache = cache.get(scheme);
2867
+ const schemeCache = cache$1.get(scheme);
4129
2868
  if (!schemeCache) return;
4130
2869
  const toneCache = schemeCache.get(tone);
4131
2870
  if (toneCache)
4132
2871
  return toneCache.get(rootTheme);
4133
2872
  }
4134
2873
  function _setCachedTheme(rootTheme, scheme, tone, theme) {
4135
- cache.has(scheme) || cache.set(scheme, /* @__PURE__ */ new Map());
4136
- const schemeCache = cache.get(scheme);
2874
+ cache$1.has(scheme) || cache$1.set(scheme, /* @__PURE__ */ new Map());
2875
+ const schemeCache = cache$1.get(scheme);
4137
2876
  schemeCache.has(tone) || schemeCache.set(tone, /* @__PURE__ */ new WeakMap()), schemeCache.get(tone).set(rootTheme, theme);
4138
2877
  }
2878
+ const cache = /* @__PURE__ */ new WeakMap();
2879
+ function getTheme_v2(theme) {
2880
+ if (theme.sanity.v2?._resolved) return theme.sanity.v2;
2881
+ const cached_v2 = cache.get(theme);
2882
+ if (cached_v2) return cached_v2;
2883
+ const v2 = {
2884
+ _version: 2,
2885
+ _resolved: !0,
2886
+ avatar: {
2887
+ ...defaultThemeConfig.avatar,
2888
+ ...theme.sanity.avatar
2889
+ },
2890
+ button: {
2891
+ ...defaultThemeConfig.button,
2892
+ ...theme.sanity.button
2893
+ },
2894
+ card: defaultThemeConfig.card,
2895
+ color: themeColor_v0_v2(theme.sanity.color),
2896
+ container: theme.sanity.container,
2897
+ font: theme.sanity.fonts,
2898
+ input: {
2899
+ ...defaultThemeConfig.input,
2900
+ ...theme.sanity.input,
2901
+ checkbox: {
2902
+ ...defaultThemeConfig.input.checkbox,
2903
+ ...theme.sanity.input.checkbox
2904
+ },
2905
+ radio: {
2906
+ ...defaultThemeConfig.input.radio,
2907
+ ...theme.sanity.input.radio
2908
+ },
2909
+ switch: {
2910
+ ...defaultThemeConfig.input.switch,
2911
+ ...theme.sanity.input.switch
2912
+ }
2913
+ },
2914
+ layer: theme.sanity.layer ?? defaultThemeConfig.layer,
2915
+ media: theme.sanity.media,
2916
+ radius: theme.sanity.radius,
2917
+ shadow: theme.sanity.shadows,
2918
+ space: theme.sanity.space,
2919
+ style: theme.sanity.styles
2920
+ };
2921
+ return cache.set(theme, v2), v2;
2922
+ }
4139
2923
  export {
4140
2924
  AVATAR_SIZE,
4141
2925
  COLOR_CONFIG_AVATAR_COLORS,
@@ -4152,6 +2936,7 @@ export {
4152
2936
  FONT_HEADING_SIZE,
4153
2937
  FONT_LABEL_SIZE,
4154
2938
  FONT_TEXT_SIZE,
2939
+ HUES,
4155
2940
  RADIUS,
4156
2941
  SHADOW,
4157
2942
  SPACE,
@@ -4164,8 +2949,13 @@ export {
4164
2949
  THEME_COLOR_SCHEMES,
4165
2950
  THEME_COLOR_STATES,
4166
2951
  THEME_COLOR_STATE_TONES,
2952
+ TINTS,
2953
+ buildColor_v3,
4167
2954
  buildTheme,
2955
+ buildTheme_v3,
4168
2956
  createColorTheme,
2957
+ defaultPalette,
2958
+ defaultTokens,
4169
2959
  getContrastRatio,
4170
2960
  getScopedTheme,
4171
2961
  getTheme_v2,
@@ -4183,19 +2973,17 @@ export {
4183
2973
  isColorTintKey,
4184
2974
  isColorTokenValue,
4185
2975
  isColorValue,
4186
- is_v0,
4187
- is_v2,
4188
2976
  mix,
4189
2977
  multiply,
4190
2978
  parseColor,
4191
2979
  parseTokenKey,
4192
2980
  parseTokenValue,
2981
+ renderColor,
2982
+ resolveTokens,
4193
2983
  rgbToHex,
4194
2984
  rgbToHsl,
4195
2985
  rgba,
4196
2986
  rgbaToRGBA,
4197
- screen,
4198
- v0_v2,
4199
- v2_v0
2987
+ screen
4200
2988
  };
4201
2989
  //# sourceMappingURL=theme.mjs.map