@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.js CHANGED
@@ -1,6 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: !0 });
3
- var color = require("@sanity/color");
3
+ var v3_v2 = require("./_chunks-cjs/v3_v2.js"), color = require("@sanity/color");
4
+ function isColorBlendModeValue(str) {
5
+ return v3_v2.THEME_COLOR_BLEND_MODES.includes(str);
6
+ }
7
+ function isColorHueKey(str) {
8
+ return color.COLOR_HUES.includes(str);
9
+ }
10
+ function isColorTintKey(str) {
11
+ return color.COLOR_TINTS.includes(str);
12
+ }
13
+ function isColorButtonMode(str) {
14
+ return v3_v2.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];
4
17
  function createSelectableTones(opts, base, dark, solid, muted) {
5
18
  return {
6
19
  default: _createSelectableStates(opts, base, dark, solid, muted, "default"),
@@ -1118,7 +1131,6 @@ function _createColor(opts, dark, name) {
1118
1131
  };
1119
1132
  }
1120
1133
  const defaultThemeConfig = {
1121
- _version: 2,
1122
1134
  avatar: {
1123
1135
  sizes: [{
1124
1136
  distance: -4,
@@ -1173,7 +1185,7 @@ const defaultThemeConfig = {
1173
1185
  zOffset: 200
1174
1186
  }
1175
1187
  },
1176
- radius: [0, 1, 5, 9, 13, 21, 33],
1188
+ radius: [0, 1, 5, 9, 13, 17, 25, 45, 77, 129],
1177
1189
  shadow: [null, {
1178
1190
  umbra: [0, 0, 0, 0],
1179
1191
  penumbra: [0, 0, 0, 0],
@@ -1238,18 +1250,6 @@ const defaultThemeConfig = {
1238
1250
  width: 1
1239
1251
  }
1240
1252
  }
1241
- },
1242
- style: {
1243
- button: {
1244
- root: {
1245
- transition: "background-color 100ms,border-color 100ms,color 100ms"
1246
- }
1247
- }
1248
- // card: {
1249
- // root: {
1250
- // transition: 'background-color 100ms,border-color 100ms,color 100ms',
1251
- // },
1252
- // },
1253
1253
  }
1254
1254
  }, defaultThemeFonts = {
1255
1255
  code: {
@@ -1299,11 +1299,12 @@ const defaultThemeConfig = {
1299
1299
  },
1300
1300
  heading: {
1301
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",
1302
1303
  weights: {
1303
- regular: 700,
1304
- medium: 800,
1305
- semibold: 900,
1306
- bold: 900
1304
+ regular: 400,
1305
+ medium: 500,
1306
+ semibold: 600,
1307
+ bold: 700
1307
1308
  },
1308
1309
  sizes: [{
1309
1310
  ascenderHeight: 5,
@@ -1325,37 +1326,37 @@ const defaultThemeConfig = {
1325
1326
  fontSize: 21,
1326
1327
  iconSize: 33,
1327
1328
  lineHeight: 29,
1328
- letterSpacing: 0
1329
+ letterSpacing: -0.25
1329
1330
  }, {
1330
1331
  ascenderHeight: 8,
1331
1332
  descenderHeight: 8,
1332
1333
  fontSize: 27,
1333
1334
  iconSize: 41,
1334
1335
  lineHeight: 35,
1335
- letterSpacing: 0
1336
+ letterSpacing: -0.5
1336
1337
  }, {
1337
1338
  ascenderHeight: 9.5,
1338
1339
  descenderHeight: 8.5,
1339
1340
  fontSize: 33,
1340
1341
  iconSize: 49,
1341
1342
  lineHeight: 41,
1342
- letterSpacing: 0
1343
+ letterSpacing: -1
1343
1344
  }, {
1344
1345
  ascenderHeight: 10.5,
1345
1346
  descenderHeight: 9.5,
1346
1347
  fontSize: 38,
1347
1348
  iconSize: 53,
1348
1349
  lineHeight: 47,
1349
- letterSpacing: 0
1350
+ letterSpacing: -1
1350
1351
  }]
1351
1352
  },
1352
1353
  label: {
1353
1354
  family: 'Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Liberation Sans", system-ui, sans-serif',
1354
1355
  weights: {
1355
- regular: 600,
1356
- medium: 700,
1357
- semibold: 800,
1358
- bold: 900
1356
+ regular: 500,
1357
+ medium: 600,
1358
+ semibold: 700,
1359
+ bold: 800
1359
1360
  },
1360
1361
  sizes: [{
1361
1362
  ascenderHeight: 2,
@@ -1365,8 +1366,8 @@ const defaultThemeConfig = {
1365
1366
  lineHeight: 10,
1366
1367
  letterSpacing: 0.5
1367
1368
  }, {
1368
- ascenderHeight: 2,
1369
- descenderHeight: 2,
1369
+ ascenderHeight: 1.5,
1370
+ descenderHeight: 2.5,
1370
1371
  fontSize: 9.5,
1371
1372
  iconSize: 15,
1372
1373
  lineHeight: 11,
@@ -1386,8 +1387,8 @@ const defaultThemeConfig = {
1386
1387
  lineHeight: 13,
1387
1388
  letterSpacing: 0.5
1388
1389
  }, {
1389
- ascenderHeight: 2,
1390
- descenderHeight: 2,
1390
+ ascenderHeight: 1.5,
1391
+ descenderHeight: 2.5,
1391
1392
  fontSize: 13.6,
1392
1393
  iconSize: 21,
1393
1394
  lineHeight: 14,
@@ -1446,324 +1447,655 @@ const defaultThemeConfig = {
1446
1447
  letterSpacing: 0
1447
1448
  }]
1448
1449
  }
1449
- }, cache$4 = /* @__PURE__ */ new WeakMap();
1450
- function themeColor_v0_v2(color_v0) {
1451
- const cached_v2 = cache$4.get(color_v0);
1452
- if (cached_v2) return cached_v2;
1453
- const base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled), color_v2 = {
1454
- _blend: color_v0._blend || (color_v0.dark ? "screen" : "multiply"),
1455
- _dark: color_v0.dark,
1456
- accent: base.accent,
1457
- avatar: base.avatar,
1458
- backdrop: color_v0.base.shadow.ambient,
1459
- badge: base.badge,
1460
- bg: color_v0.base.bg,
1461
- border: color_v0.base.border,
1462
- button: {
1463
- default: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.default),
1464
- ghost: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.ghost),
1465
- bleed: stateTonesThemeColor_v0_v2(color_v0, color_v0.button.bleed)
1466
- },
1467
- code: base.code,
1468
- fg: color_v0.base.fg,
1469
- focusRing: color_v0.base.focusRing,
1470
- icon: base.muted.fg,
1471
- input: {
1472
- default: inputStatesThemeColor_v0_v2(color_v0.input.default),
1473
- invalid: inputStatesThemeColor_v0_v2(color_v0.input.invalid)
1474
- },
1475
- kbd: base.kbd,
1476
- link: base.link,
1477
- muted: {
1478
- ...base.muted,
1479
- 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 color2 = getColor();
1454
+ if (!color2)
1455
+ throw new Error(`Invalid color: ${str}`);
1456
+ const opacity = getOpacity(), mix2 = getMixPercentage();
1457
+ return {
1458
+ color: color2,
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: v3_v2.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: v3_v2.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)
1480
1586
  },
1481
- selectable: stateTonesThemeColor_v0_v2(color_v0, color_v0.selectable || color_v0.muted),
1482
- shadow: color_v0.base.shadow,
1483
1587
  skeleton: {
1484
- from: color_v0.skeleton?.from || color_v0.base.border,
1485
- to: color_v0.skeleton?.to || color_v0.base.border
1486
- },
1487
- 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
+ ...v3_v2.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
+ ...v3_v2.THEME_COLOR_STATE_TONES.reduce((acc, tone) => ({
1640
+ ...acc,
1641
+ [tone]: buildColorElement_v3(tokens.variant.tinted[tone], {
1642
+ scheme
1643
+ })
1644
+ }), {})
1645
+ }
1646
+ }
1488
1647
  };
1489
- return cache$4.set(color_v0, color_v2), color_v2;
1490
1648
  }
1491
- 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
+ };
1492
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
+ },
1493
1867
  default: {
1494
- enabled: stateThemeColor_v0_v2(v0, t.default.enabled),
1495
- hovered: stateThemeColor_v0_v2(v0, t.default.hovered),
1496
- pressed: stateThemeColor_v0_v2(v0, t.default.pressed),
1497
- selected: stateThemeColor_v0_v2(v0, t.default.selected),
1498
- 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
+ }
1499
1886
  },
1500
1887
  primary: {
1501
- enabled: stateThemeColor_v0_v2(v0, t.primary.enabled),
1502
- hovered: stateThemeColor_v0_v2(v0, t.primary.hovered),
1503
- pressed: stateThemeColor_v0_v2(v0, t.primary.pressed),
1504
- selected: stateThemeColor_v0_v2(v0, t.primary.selected),
1505
- disabled: stateThemeColor_v0_v2(v0, t.primary.disabled)
1888
+ _hue: "blue"
1889
+ },
1890
+ suggest: {
1891
+ _hue: "purple"
1506
1892
  },
1507
1893
  positive: {
1508
- enabled: stateThemeColor_v0_v2(v0, t.positive.enabled),
1509
- hovered: stateThemeColor_v0_v2(v0, t.positive.hovered),
1510
- pressed: stateThemeColor_v0_v2(v0, t.positive.pressed),
1511
- selected: stateThemeColor_v0_v2(v0, t.positive.selected),
1512
- disabled: stateThemeColor_v0_v2(v0, t.positive.disabled)
1894
+ _hue: "green"
1513
1895
  },
1514
1896
  caution: {
1515
- enabled: stateThemeColor_v0_v2(v0, t.caution.enabled),
1516
- hovered: stateThemeColor_v0_v2(v0, t.caution.hovered),
1517
- pressed: stateThemeColor_v0_v2(v0, t.caution.pressed),
1518
- selected: stateThemeColor_v0_v2(v0, t.caution.selected),
1519
- disabled: stateThemeColor_v0_v2(v0, t.caution.disabled)
1897
+ _hue: "yellow"
1520
1898
  },
1521
1899
  critical: {
1522
- enabled: stateThemeColor_v0_v2(v0, t.critical.enabled),
1523
- hovered: stateThemeColor_v0_v2(v0, t.critical.hovered),
1524
- pressed: stateThemeColor_v0_v2(v0, t.critical.pressed),
1525
- selected: stateThemeColor_v0_v2(v0, t.critical.selected),
1526
- 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
+ ...v3_v2.THEME_COLOR_CARD_TONES.reduce((acc, tone) => ({
1936
+ ...acc,
1937
+ [tone]: resolveCardColorTokens(merge(tokens.color?.["*"], tokens.color?.[tone]))
1938
+ }), {})
1527
1939
  }
1528
1940
  };
1529
1941
  }
1530
- function stateThemeColor_v0_v2(v0, state) {
1942
+ function resolveCardColorTokens(tokens) {
1531
1943
  return {
1532
- ...state,
1944
+ _hue: tokens?._hue ?? "gray",
1533
1945
  avatar: {
1534
1946
  gray: {
1535
- bg: v0.spot.gray,
1536
- 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"]
1537
1950
  },
1538
1951
  blue: {
1539
- bg: v0.spot.blue,
1540
- 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"]
1541
1955
  },
1542
1956
  purple: {
1543
- bg: v0.spot.purple,
1544
- 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"]
1545
1960
  },
1546
1961
  magenta: {
1547
- bg: v0.spot.magenta,
1548
- 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"]
1549
1965
  },
1550
1966
  red: {
1551
- bg: v0.spot.red,
1552
- 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"]
1553
1970
  },
1554
1971
  orange: {
1555
- bg: v0.spot.orange,
1556
- 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"]
1557
1975
  },
1558
1976
  yellow: {
1559
- bg: v0.spot.yellow,
1560
- 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"]
1561
1980
  },
1562
1981
  green: {
1563
- bg: v0.spot.green,
1564
- 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"]
1565
1985
  },
1566
1986
  cyan: {
1567
- bg: v0.spot.cyan,
1568
- 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"]
1569
1990
  }
1570
1991
  },
1571
- badge: {
1572
- default: {
1573
- bg: v0.muted.default.enabled.bg,
1574
- fg: v0.muted.default.enabled.fg,
1575
- dot: v0.muted.default.enabled.muted.fg,
1576
- icon: v0.muted.default.enabled.muted.fg
1577
- },
1578
- primary: {
1579
- bg: v0.muted.primary.enabled.bg,
1580
- fg: v0.muted.primary.enabled.fg,
1581
- dot: v0.muted.primary.enabled.muted.fg,
1582
- icon: v0.muted.primary.enabled.muted.fg
1583
- },
1584
- positive: {
1585
- bg: v0.muted.positive.enabled.bg,
1586
- fg: v0.muted.positive.enabled.fg,
1587
- dot: v0.muted.positive.enabled.muted.fg,
1588
- icon: v0.muted.positive.enabled.muted.fg
1589
- },
1590
- caution: {
1591
- bg: v0.muted.caution.enabled.bg,
1592
- fg: v0.muted.caution.enabled.fg,
1593
- dot: v0.muted.caution.enabled.muted.fg,
1594
- icon: v0.muted.caution.enabled.muted.fg
1595
- },
1596
- critical: {
1597
- bg: v0.muted.critical.enabled.bg,
1598
- fg: v0.muted.critical.enabled.fg,
1599
- dot: v0.muted.critical.enabled.muted.fg,
1600
- icon: v0.muted.critical.enabled.muted.fg
1601
- }
1602
- },
1603
- kbd: {
1604
- bg: v0.muted.default.enabled.bg,
1605
- fg: v0.muted.default.enabled.fg,
1606
- 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"]
1607
1996
  },
1608
- muted: {
1609
- ...v0.muted.default.enabled.muted,
1610
- 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"]
1611
2002
  },
1612
2003
  skeleton: {
1613
- from: state.skeleton?.from || state.border,
1614
- 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
+ ...v3_v2.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
+ ...v3_v2.THEME_COLOR_STATE_TONES.reduce((acc, tone) => (acc[tone] = resolveElementTokens(merge(tokens, tokens?.variant?.tinted?.["*"], tokens?.variant?.tinted?.[tone])), acc), {})
2053
+ }
1615
2054
  }
1616
2055
  };
1617
2056
  }
1618
- function inputStatesThemeColor_v0_v2(states) {
1619
- return {
1620
- enabled: inputStateThemeColor_v0_v2(states.enabled),
1621
- disabled: inputStateThemeColor_v0_v2(states.disabled),
1622
- readOnly: inputStateThemeColor_v0_v2(states.readOnly),
1623
- hovered: inputStateThemeColor_v0_v2(states.hovered)
1624
- };
1625
- }
1626
- function inputStateThemeColor_v0_v2(state) {
2057
+ function resolveElementTokens(tokens) {
1627
2058
  return {
1628
- bg: state.bg,
1629
- border: state.border,
1630
- fg: state.fg,
1631
- muted: {
1632
- bg: state.bg2
1633
- },
1634
- placeholder: state.placeholder
1635
- };
1636
- }
1637
- const cache$3 = /* @__PURE__ */ new WeakMap();
1638
- function getTheme_v2(theme) {
1639
- if (theme.sanity.v2?._resolved) return theme.sanity.v2;
1640
- const cached_v2 = cache$3.get(theme);
1641
- if (cached_v2) return cached_v2;
1642
- const v2 = {
1643
- _version: 2,
1644
- _resolved: !0,
1645
- avatar: {
1646
- ...defaultThemeConfig.avatar,
1647
- ...theme.sanity.avatar
1648
- },
1649
- button: {
1650
- ...defaultThemeConfig.button,
1651
- ...theme.sanity.button
2059
+ _hue: tokens?._hue ?? "gray",
2060
+ bg: {
2061
+ 0: tokens?.bg?.[0] ?? defaultElementTokens.bg[0],
2062
+ 4: tokens?.bg?.[4] ?? defaultElementTokens.bg[4]
1652
2063
  },
1653
- card: defaultThemeConfig.card,
1654
- color: themeColor_v0_v2(theme.sanity.color),
1655
- container: theme.sanity.container,
1656
- font: theme.sanity.fonts,
1657
- input: {
1658
- ...defaultThemeConfig.input,
1659
- ...theme.sanity.input,
1660
- checkbox: {
1661
- ...defaultThemeConfig.input.checkbox,
1662
- ...theme.sanity.input.checkbox
1663
- },
1664
- radio: {
1665
- ...defaultThemeConfig.input.radio,
1666
- ...theme.sanity.input.radio
1667
- },
1668
- switch: {
1669
- ...defaultThemeConfig.input.switch,
1670
- ...theme.sanity.input.switch
1671
- }
2064
+ border: {
2065
+ 0: tokens?.border?.[0] ?? defaultElementTokens.border[0],
2066
+ 4: tokens?.border?.[4] ?? defaultElementTokens.border[4]
1672
2067
  },
1673
- layer: theme.sanity.layer ?? defaultThemeConfig.layer,
1674
- media: theme.sanity.media,
1675
- radius: theme.sanity.radius,
1676
- shadow: theme.sanity.shadows,
1677
- space: theme.sanity.space,
1678
- style: theme.sanity.styles
2068
+ fg: {
2069
+ 0: tokens?.fg?.[0] ?? defaultElementTokens.fg[0],
2070
+ 4: tokens?.fg?.[4] ?? defaultElementTokens.fg[4]
2071
+ }
1679
2072
  };
1680
- return cache$3.set(theme, v2), v2;
1681
- }
1682
- function is_v0(themeProp) {
1683
- return themeProp._version === 0;
1684
- }
1685
- function is_v2(themeProp) {
1686
- return themeProp._version === 2;
1687
2073
  }
1688
- const cache$2 = /* @__PURE__ */ new WeakMap();
1689
- function v0_v2(v0) {
1690
- if (v0.v2) return v0.v2;
1691
- const cached_v2 = cache$2.get(v0);
1692
- if (cached_v2) return cached_v2;
2074
+ function buildTheme_v3(options) {
1693
2075
  const {
1694
- avatar,
1695
- button,
1696
- color: color2,
1697
- container,
1698
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1699
- focusRing: _unused_focusRing,
1700
- fonts: font,
1701
- input,
1702
- layer,
1703
- media,
1704
- radius,
1705
- shadows: shadow,
1706
- space,
1707
- styles: style
1708
- } = v0, v2 = {
1709
- _version: 2,
1710
- avatar: {
1711
- ...defaultThemeConfig.avatar,
1712
- ...avatar
1713
- },
1714
- button: {
1715
- ...defaultThemeConfig.button,
1716
- ...button
1717
- },
1718
- card: defaultThemeConfig.card,
1719
- color: {
1720
- light: {
1721
- transparent: themeColor_v0_v2(color2.light.transparent),
1722
- default: themeColor_v0_v2(color2.light.default),
1723
- primary: themeColor_v0_v2(color2.light.primary),
1724
- positive: themeColor_v0_v2(color2.light.positive),
1725
- caution: themeColor_v0_v2(color2.light.caution),
1726
- critical: themeColor_v0_v2(color2.light.critical)
1727
- },
1728
- dark: {
1729
- transparent: themeColor_v0_v2(color2.dark.transparent),
1730
- default: themeColor_v0_v2(color2.dark.default),
1731
- primary: themeColor_v0_v2(color2.dark.primary),
1732
- positive: themeColor_v0_v2(color2.dark.positive),
1733
- caution: themeColor_v0_v2(color2.dark.caution),
1734
- critical: themeColor_v0_v2(color2.dark.critical)
1735
- }
1736
- },
1737
- container,
1738
- font,
1739
- input: {
1740
- ...defaultThemeConfig.input,
1741
- ...input,
1742
- checkbox: {
1743
- ...defaultThemeConfig.input.checkbox,
1744
- ...input.checkbox
1745
- },
1746
- radio: {
1747
- ...defaultThemeConfig.input.radio,
1748
- ...input.radio
1749
- },
1750
- switch: {
1751
- ...defaultThemeConfig.input.switch,
1752
- ...input.switch
1753
- }
1754
- },
1755
- layer: layer ?? defaultThemeConfig.layer,
1756
- media,
1757
- radius,
1758
- shadow,
1759
- space,
1760
- style
1761
- };
1762
- return cache$2.set(v0, v2), v2;
1763
- }
1764
- const cache$1 = /* @__PURE__ */ new WeakMap();
1765
- function v2_v0(v2) {
1766
- 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);
1767
2099
  if (cachedTheme) return cachedTheme;
1768
2100
  const {
1769
2101
  avatar,
@@ -1809,7 +2141,8 @@ function v2_v0(v2) {
1809
2141
  shadows,
1810
2142
  space,
1811
2143
  styles,
1812
- v2
2144
+ v2,
2145
+ v3
1813
2146
  };
1814
2147
  }
1815
2148
  function themeColor_v2_v0(color_v2) {
@@ -1868,96 +2201,236 @@ function inputStateThemeColor_v2_v0(t) {
1868
2201
  placeholder: t.placeholder
1869
2202
  };
1870
2203
  }
1871
- 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.COLOR_HUES;
1872
- function isColorBlendModeValue(str) {
1873
- 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_v2(v3), v3);
1874
2209
  }
1875
- function isColorHueKey(str) {
1876
- return color.COLOR_HUES.includes(str);
2210
+ function mixChannel(b, s, weight) {
2211
+ const delta = (s - b) * weight;
2212
+ return b + delta;
1877
2213
  }
1878
- function isColorTintKey(str) {
1879
- return color.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
+ };
1880
2220
  }
1881
- function isColorButtonMode(str) {
1882
- return THEME_COLOR_BUTTON_MODES.includes(str);
2221
+ function multiplyChannel(b, s) {
2222
+ return b * s;
1883
2223
  }
1884
- 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];
1885
- function parseTokenKey(str) {
1886
- const segments = str.split("/"), segment0 = segments.shift() || "";
1887
- if (isColorConfigBaseTone(segment0)) {
1888
- const key = segments.join("/");
1889
- if (isColorConfigBaseKey(key))
1890
- return {
1891
- type: "base",
1892
- tone: segment0,
1893
- key
1894
- };
1895
- if (isColorConfigBlendKey(key))
1896
- return {
1897
- type: "base",
1898
- tone: segment0,
1899
- key
1900
- };
1901
- }
1902
- if (segment0 === "button") {
1903
- const segment1 = segments.shift() || "";
1904
- if (isColorConfigStateTone(segment1)) {
1905
- const segment2 = segments.shift() || "";
1906
- if (isColorButtonMode(segment2)) {
1907
- const key = segments.join("/");
1908
- if (isColorConfigStateKey(key))
1909
- return {
1910
- type: "button",
1911
- tone: segment1,
1912
- mode: segment2,
1913
- key
1914
- };
1915
- if (isColorConfigBlendKey(key))
1916
- return {
1917
- type: "button",
1918
- tone: segment1,
1919
- mode: segment2,
1920
- key
1921
- };
1922
- }
1923
- }
1924
- }
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
+ };
1925
2230
  }
1926
- function isColorMixPercentValue(str) {
1927
- return /^\d+%$/.test(str);
2231
+ function screenChannel(b, s) {
2232
+ return b + s - b * s;
1928
2233
  }
1929
- function parseTokenValue(str) {
1930
- const segments = str.split("/");
1931
- let nextSegment = segments.shift() || "";
1932
- const [segment0, segment0mix] = nextSegment.split(" ");
1933
- if (isColorTintKey(segment0)) {
1934
- const tint = segment0, segment1 = segments.shift() || "";
1935
- if (isColorMixPercentValue(segment0mix)) {
1936
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
1937
- return {
1938
- type: "color",
1939
- tint,
1940
- mix: mix2
1941
- };
1942
- }
1943
- if (isColorOpacityValue(segment1)) {
1944
- const opacity = Number(segment1);
1945
- return {
1946
- type: "color",
1947
- tint,
1948
- opacity
1949
- };
1950
- }
1951
- return {
1952
- type: "color",
1953
- tint
1954
- };
1955
- }
1956
- if (isColorValue(segment0)) {
1957
- const key = segment0, segment1 = segments.shift() || "";
1958
- if (isColorMixPercentValue(segment0mix)) {
1959
- const mix2 = Number(segment0mix.slice(0, -1)) / 100;
1960
- return {
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);
2250
+ return {
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(color2) {
2272
+ 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));
2273
+ return "a" in color2 ? `rgba(${r},${g},${b},${color2.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(color2) {
2319
+ if (!color2) return {
2320
+ r: 0,
2321
+ g: 0,
2322
+ b: 0
2323
+ };
2324
+ if (typeof color2 != "string")
2325
+ throw new Error("parseColor: expected a string");
2326
+ if (isHex(color2))
2327
+ return hexToRgb(color2);
2328
+ if (color2.startsWith("hsl("))
2329
+ return hslToRgb(parseHsl(color2));
2330
+ if (color2.startsWith("rgba("))
2331
+ return rgbaToRGBA(color2);
2332
+ throw new Error(`parseColor: unexpected color format: "${color2}"`);
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(color2, a) {
2352
+ if (typeof color2 == "string" && color2.startsWith("var("))
2353
+ return `color-mix(in srgb, transparent, ${color2} ${a * 100}%)`;
2354
+ const rgb = parseColor(color2);
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 = ["*", ...v3_v2.THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...v3_v2.THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...v3_v2.THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...v3_v2.THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...v3_v2.THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...v3_v2.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
+ };
2428
+ }
2429
+ if (isColorValue(segment0)) {
2430
+ const key = segment0, segment1 = segments.shift() || "";
2431
+ if (isColorMixPercentValue(segment0mix)) {
2432
+ const mix2 = Number(segment0mix.slice(0, -1)) / 100;
2433
+ return {
1961
2434
  type: "color",
1962
2435
  key,
1963
2436
  mix: mix2
@@ -2041,2077 +2514,341 @@ function isColorValue(str) {
2041
2514
  function isColorOpacityValue(str) {
2042
2515
  return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
2043
2516
  }
2044
- function compileColorTokenValue(node) {
2045
- let key = "";
2046
- 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);
2047
- }
2048
- const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
2049
- function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
2050
- const {
2051
- hue,
2052
- scheme
2053
- } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
2054
- if (!node || node.type !== "color")
2055
- throw new Error(`Invalid color token: ${value[0]}`);
2056
- return compileColorTokenValue({
2057
- ...node,
2058
- hue: node.hue || hue
2059
- });
2517
+ function is_v2(themeProp) {
2518
+ return themeProp._version === 2;
2060
2519
  }
2061
- const defaultColorTokens = {
2062
- base: {
2063
- "*": {
2064
- _blend: ["multiply", "screen"],
2065
- accent: {
2066
- fg: ["purple/600", "purple/400"]
2067
- },
2068
- avatar: {
2069
- "*": {
2070
- _blend: ["screen", "multiply"],
2071
- bg: ["500", "400"],
2072
- fg: ["white", "black"]
2073
- }
2074
- },
2075
- backdrop: ["gray/200/0.5", "black/0.5"],
2076
- badge: {
2077
- "*": {
2078
- bg: ["100", "900"],
2079
- fg: ["600", "400"],
2080
- icon: ["500", "500"],
2081
- dot: ["500", "500"]
2082
- },
2083
- positive: {
2084
- bg: ["200 50%", "900"],
2085
- fg: ["600", "500"]
2086
- },
2087
- caution: {
2088
- bg: ["200 50%", "900"],
2089
- fg: ["600", "500"]
2090
- }
2091
- },
2092
- bg: ["50", "950"],
2093
- border: ["200", "800"],
2094
- code: {
2095
- bg: ["50", "950"],
2096
- fg: ["600", "400"]
2097
- },
2098
- fg: ["800", "200"],
2099
- focusRing: ["blue/500", "blue/500"],
2100
- icon: ["600", "400"],
2101
- kbd: {
2102
- bg: ["white", "black"],
2103
- fg: ["600", "400"],
2104
- border: ["200", "800"]
2105
- },
2106
- link: {
2107
- fg: ["blue/600", "blue/300"]
2108
- },
2109
- muted: {
2110
- bg: ["50", "950"],
2111
- fg: ["700 75%", "300 75%"]
2112
- },
2113
- shadow: {
2114
- outline: ["500/0.3", "500/0.4"],
2115
- umbra: ["gray/500/0.1", "black/0.2"],
2116
- penumbra: ["gray/500/0.07", "black/0.14"],
2117
- ambient: ["gray/500/0.06", "black/0.12"]
2520
+ function themeColor_v0_v2_9(color2) {
2521
+ if ("neutral" in color2.badge)
2522
+ return color2;
2523
+ const colors2 = color2;
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
2118
2536
  },
2119
- skeleton: {
2120
- from: ["100", "900"],
2121
- 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
2122
2546
  }
2123
2547
  },
2124
- transparent: {
2125
- bg: ["50", "black"]
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)
2126
2572
  },
2127
- default: {
2128
- bg: ["white", "950"],
2129
- fg: ["800", "200"],
2130
- muted: {
2131
- fg: ["600", "400"]
2132
- }
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)
2133
2580
  },
2134
- primary: {
2135
- _hue: "blue"
2136
- },
2137
- positive: {
2138
- _hue: "green",
2139
- shadow: {
2140
- outline: ["500/0.4", "500/0.4"]
2141
- }
2142
- },
2143
- caution: {
2144
- _hue: "yellow",
2145
- shadow: {
2146
- outline: ["600/0.3", "500/0.4"]
2147
- }
2148
- },
2149
- critical: {
2150
- _hue: "red"
2151
- }
2152
- },
2153
- button: {
2154
- default: {
2155
- "*": {
2156
- "*": {
2157
- _blend: ["screen", "multiply"],
2158
- accent: {
2159
- fg: ["purple/300", "purple/700"]
2160
- },
2161
- avatar: {
2162
- "*": {
2163
- _blend: ["screen", "multiply"],
2164
- bg: ["500", "400"],
2165
- fg: ["white", "black"]
2166
- }
2167
- },
2168
- badge: {
2169
- "*": {
2170
- bg: ["900", "100"],
2171
- fg: ["400", "600"],
2172
- dot: ["500", "500"],
2173
- icon: ["500", "500"]
2174
- }
2175
- },
2176
- bg: ["500", "400"],
2177
- border: ["500/0", "400/0"],
2178
- code: {
2179
- bg: ["500 20%", "400 20%"],
2180
- fg: ["200", "600"]
2181
- },
2182
- fg: ["white", "black"],
2183
- icon: ["100 70%", "900 70%"],
2184
- kbd: {
2185
- bg: ["black", "white"],
2186
- fg: ["200", "600"],
2187
- border: ["800", "200"]
2188
- },
2189
- link: {
2190
- fg: ["blue/200", "blue/600"]
2191
- },
2192
- muted: {
2193
- bg: ["950", "50"],
2194
- fg: ["100 70%", "900 70%"]
2195
- },
2196
- skeleton: {
2197
- from: ["900", "100"],
2198
- to: ["900 50%", "100 50%"]
2199
- }
2200
- },
2201
- hovered: {
2202
- bg: ["700", "300"],
2203
- border: ["700/0", "300/0"]
2204
- },
2205
- pressed: {
2206
- bg: ["700", "300"]
2207
- },
2208
- selected: {
2209
- bg: ["700", "300"]
2210
- },
2211
- disabled: {
2212
- _hue: "gray",
2213
- accent: {
2214
- fg: ["100 70%", "900 70%"]
2215
- },
2216
- avatar: {
2217
- "*": {
2218
- _blend: ["screen", "multiply"],
2219
- bg: ["gray/500", "gray/400"],
2220
- fg: ["white", "black"]
2221
- }
2222
- },
2223
- badge: {
2224
- "*": {
2225
- bg: ["gray/700", "gray/300"],
2226
- fg: ["white", "black"],
2227
- dot: ["white", "black"],
2228
- icon: ["white", "black"]
2229
- }
2230
- },
2231
- bg: ["300", "600"],
2232
- code: {
2233
- bg: ["950", "50"],
2234
- fg: ["300", "600"]
2235
- },
2236
- fg: ["300", "600"],
2237
- muted: {
2238
- bg: ["950", "50"],
2239
- fg: ["300", "600"]
2240
- },
2241
- kbd: {
2242
- bg: ["black", "white"],
2243
- fg: ["white", "black"],
2244
- border: ["700", "300"]
2245
- },
2246
- link: {
2247
- fg: ["100 70%", "900 70%"]
2248
- }
2249
- }
2250
- },
2251
- default: {
2252
- "*": {
2253
- avatar: {
2254
- "*": {
2255
- _blend: ["screen", "multiply"],
2256
- bg: ["500", "400"],
2257
- fg: ["white", "black"]
2258
- }
2259
- },
2260
- bg: ["800", "200"],
2261
- muted: {
2262
- bg: ["950", "50"],
2263
- fg: ["400", "600"]
2264
- }
2265
- },
2266
- hovered: {
2267
- bg: ["900", "100"]
2268
- },
2269
- pressed: {
2270
- bg: ["black", "white"]
2271
- },
2272
- selected: {
2273
- bg: ["black", "white"]
2274
- }
2275
- }
2276
- },
2277
- ghost: {
2278
- "*": {
2279
- "*": {
2280
- _blend: ["multiply", "screen"],
2281
- accent: {
2282
- fg: ["purple/700 60%", "purple/300 70%"]
2283
- },
2284
- avatar: {
2285
- "*": {
2286
- _blend: ["screen", "multiply"],
2287
- bg: ["500", "400"],
2288
- fg: ["white", "black"]
2289
- }
2290
- },
2291
- badge: {
2292
- "*": {
2293
- bg: ["100", "900"],
2294
- fg: ["600", "400"],
2295
- dot: ["500", "500"],
2296
- icon: ["500", "500"]
2297
- }
2298
- },
2299
- bg: ["50", "950"],
2300
- border: ["100", "900"],
2301
- code: {
2302
- bg: ["500 10%", "400 10%"],
2303
- fg: ["700 60%", "400 60%"]
2304
- },
2305
- fg: ["600", "400"],
2306
- icon: ["700 60%", "300 60%"],
2307
- kbd: {
2308
- bg: ["white", "black"],
2309
- fg: ["600", "400"],
2310
- border: ["200", "800"]
2311
- },
2312
- link: {
2313
- fg: ["blue/700 60%", "blue/300 60%"]
2314
- },
2315
- muted: {
2316
- bg: ["100", "950"],
2317
- fg: ["700 60%", "300 60%"]
2318
- },
2319
- skeleton: {
2320
- from: ["100", "900"],
2321
- to: ["100 50%", "900 50%"]
2322
- }
2323
- },
2324
- hovered: {
2325
- bg: ["100", "900"],
2326
- fg: ["700", "300"]
2327
- },
2328
- pressed: {
2329
- bg: ["100", "900"],
2330
- fg: ["800", "200"]
2331
- },
2332
- selected: {
2333
- bg: ["100", "900"],
2334
- fg: ["800", "200"]
2335
- },
2336
- disabled: {
2337
- _hue: "gray",
2338
- accent: {
2339
- fg: ["200", "800"]
2340
- },
2341
- avatar: {
2342
- "*": {
2343
- _blend: ["screen", "multiply"],
2344
- bg: ["gray/100", "gray/900"],
2345
- fg: ["white", "black"]
2346
- }
2347
- },
2348
- badge: {
2349
- "*": {
2350
- _hue: "gray",
2351
- bg: ["50", "950"],
2352
- fg: ["gray/200", "gray/800"],
2353
- dot: ["gray/200", "gray/800"],
2354
- icon: ["gray/200", "gray/800"]
2355
- }
2356
- },
2357
- border: ["100", "900"],
2358
- code: {
2359
- bg: ["50", "950"],
2360
- fg: ["200", "800"]
2361
- },
2362
- fg: ["400", "600"],
2363
- icon: ["300", "700"],
2364
- muted: {
2365
- fg: ["300", "700"]
2366
- },
2367
- kbd: {
2368
- bg: ["white", "black"],
2369
- fg: ["200", "800"],
2370
- border: ["100", "900"]
2371
- },
2372
- link: {
2373
- fg: ["200", "800"]
2374
- }
2375
- }
2376
- },
2377
- positive: {
2378
- "*": {
2379
- border: ["600 20%", "800"]
2380
- }
2381
- },
2382
- caution: {
2383
- "*": {
2384
- border: ["600 20%", "800"]
2385
- }
2386
- }
2387
- },
2388
- bleed: {
2389
- "*": {
2390
- "*": {
2391
- _blend: ["multiply", "screen"],
2392
- accent: {
2393
- fg: ["purple/700 70%", "purple/300 70%"]
2394
- },
2395
- avatar: {
2396
- "*": {
2397
- _blend: ["screen", "multiply"],
2398
- bg: ["500", "400"],
2399
- fg: ["white", "black"]
2400
- }
2401
- },
2402
- badge: {
2403
- "*": {
2404
- bg: ["100", "900"],
2405
- fg: ["600", "400"],
2406
- dot: ["500", "500"],
2407
- icon: ["500", "500"]
2408
- }
2409
- },
2410
- bg: ["white", "black"],
2411
- border: ["white/0", "black/0"],
2412
- code: {
2413
- bg: ["50", "950"],
2414
- fg: ["700 75%", "300 75%"]
2415
- },
2416
- fg: ["700", "300"],
2417
- icon: ["700 75%", "300 75%"],
2418
- kbd: {
2419
- bg: ["white", "black"],
2420
- fg: ["700", "300"],
2421
- border: ["200", "800"]
2422
- },
2423
- link: {
2424
- fg: ["blue/700 70%", "blue/300 70%"]
2425
- },
2426
- muted: {
2427
- bg: ["100", "950"],
2428
- fg: ["700 75%", "300 75%"]
2429
- },
2430
- skeleton: {
2431
- from: ["100", "900"],
2432
- to: ["100 50%", "900 50%"]
2433
- }
2434
- },
2435
- hovered: {
2436
- bg: ["50", "950"],
2437
- icon: ["700 70%", "400 70%"]
2438
- },
2439
- pressed: {
2440
- bg: ["100", "900"],
2441
- fg: ["800", "200"],
2442
- icon: ["800 70%", "200 70%"]
2443
- },
2444
- selected: {
2445
- bg: ["100", "900"],
2446
- fg: ["800", "200"],
2447
- icon: ["800 60%", "200 60%"]
2448
- },
2449
- disabled: {
2450
- _hue: "gray",
2451
- accent: {
2452
- fg: ["200", "800"]
2453
- },
2454
- avatar: {
2455
- "*": {
2456
- _blend: ["screen", "multiply"],
2457
- bg: ["gray/100", "gray/900"],
2458
- fg: ["white", "black"]
2459
- }
2460
- },
2461
- badge: {
2462
- "*": {
2463
- _hue: "gray",
2464
- bg: ["50", "950"],
2465
- fg: ["gray/200", "gray/800"],
2466
- dot: ["gray/200", "gray/800"],
2467
- icon: ["gray/200", "gray/800"]
2468
- }
2469
- },
2470
- code: {
2471
- bg: ["50", "950"],
2472
- fg: ["200", "800"]
2473
- },
2474
- fg: ["400", "600"],
2475
- icon: ["300", "700"],
2476
- muted: {
2477
- fg: ["400", "600"]
2478
- },
2479
- kbd: {
2480
- bg: ["white", "black"],
2481
- fg: ["200", "800"],
2482
- border: ["100", "900"]
2483
- },
2484
- link: {
2485
- fg: ["200", "800"]
2486
- }
2487
- }
2488
- }
2489
- }
2490
- },
2491
- input: {
2492
- "*": {
2493
- "*": {
2494
- _blend: ["multiply", "screen"],
2495
- bg: ["white", "black"],
2496
- border: ["200", "700"],
2497
- fg: ["black", "200"],
2498
- muted: {
2499
- bg: ["50", "950"]
2500
- },
2501
- placeholder: ["400", "600"]
2502
- },
2503
- hovered: {
2504
- border: ["300", "700"]
2505
- },
2506
- readOnly: {
2507
- bg: ["50", "950"],
2508
- border: ["200", "800"],
2509
- fg: ["800", "200"]
2510
- },
2511
- disabled: {
2512
- bg: ["50", "950"],
2513
- fg: ["400", "600"],
2514
- border: ["100", "900"],
2515
- placeholder: ["200", "800 50%"]
2516
- }
2517
- },
2518
- invalid: {
2519
- "*": {
2520
- _hue: "red",
2521
- bg: ["100", "950"]
2522
- }
2523
- }
2524
- },
2525
- selectable: {
2526
- "*": {
2527
- "*": {
2528
- _blend: ["multiply", "screen"],
2529
- accent: {
2530
- fg: ["purple/700 70%", "purple/300 70%"]
2531
- },
2532
- avatar: {
2533
- "*": {
2534
- _blend: ["screen", "multiply"],
2535
- bg: ["500", "400"],
2536
- fg: ["white", "black"]
2537
- }
2538
- },
2539
- badge: {
2540
- "*": {
2541
- bg: ["100", "900"],
2542
- fg: ["600", "400"],
2543
- dot: ["500", "500"],
2544
- icon: ["500", "500"]
2545
- }
2546
- },
2547
- bg: ["white", "black"],
2548
- border: ["200", "800"],
2549
- code: {
2550
- bg: ["50", "950"],
2551
- fg: ["600", "400"]
2552
- },
2553
- fg: ["700", "300"],
2554
- icon: ["700 75%", "300 75%"],
2555
- kbd: {
2556
- bg: ["white", "black"],
2557
- fg: ["600", "400"],
2558
- border: ["200", "800"]
2559
- },
2560
- link: {
2561
- fg: ["blue/700 70%", "blue/300 70%"]
2562
- },
2563
- muted: {
2564
- bg: ["50", "950"],
2565
- fg: ["700 75%", "300 75%"]
2566
- },
2567
- skeleton: {
2568
- from: ["100", "900"],
2569
- to: ["100 50%", "900 50%"]
2570
- }
2571
- },
2572
- hovered: {
2573
- bg: ["50", "950"]
2574
- },
2575
- pressed: {
2576
- bg: ["100", "900"]
2577
- },
2578
- selected: {
2579
- _blend: ["screen", "multiply"],
2580
- accent: {
2581
- fg: ["purple/300", "purple/700"]
2582
- },
2583
- avatar: {
2584
- "*": {
2585
- _blend: ["multiply", "screen"],
2586
- bg: ["white", "black"],
2587
- fg: ["black", "white"]
2588
- }
2589
- },
2590
- badge: {
2591
- "*": {
2592
- bg: ["900", "100"],
2593
- fg: ["400", "600"],
2594
- dot: ["500", "500"],
2595
- icon: ["500", "500"]
2596
- }
2597
- },
2598
- bg: ["500", "400"],
2599
- border: ["500 20%", "400 20%"],
2600
- code: {
2601
- bg: ["500 20%", "400 20%"],
2602
- fg: ["200", "600"]
2603
- },
2604
- fg: ["white", "black"],
2605
- icon: ["100 70%", "900 70%"],
2606
- kbd: {
2607
- bg: ["black", "white"],
2608
- fg: ["200", "600"],
2609
- border: ["800", "200"]
2610
- },
2611
- link: {
2612
- fg: ["blue/200", "blue/600"]
2613
- },
2614
- muted: {
2615
- bg: ["500 10%", "400 10%"],
2616
- fg: ["100 70%", "900 70%"]
2617
- },
2618
- skeleton: {
2619
- from: ["900", "100"],
2620
- to: ["900 50%", "100 50%"]
2621
- }
2622
- },
2623
- disabled: {
2624
- _hue: "gray",
2625
- accent: {
2626
- fg: ["200", "800"]
2627
- },
2628
- avatar: {
2629
- "*": {
2630
- _blend: ["screen", "multiply"],
2631
- bg: ["gray/100", "gray/900"],
2632
- fg: ["white", "black"]
2633
- }
2634
- },
2635
- badge: {
2636
- "*": {
2637
- _hue: "gray",
2638
- bg: ["50", "950"],
2639
- fg: ["gray/200", "gray/800"],
2640
- dot: ["gray/200", "gray/800"],
2641
- icon: ["gray/200", "gray/800"]
2642
- }
2643
- },
2644
- border: ["100", "900"],
2645
- code: {
2646
- bg: ["50", "950"],
2647
- fg: ["200", "800"]
2648
- },
2649
- fg: ["200", "800"],
2650
- icon: ["200", "800"],
2651
- kbd: {
2652
- bg: ["white", "black"],
2653
- fg: ["200", "800"],
2654
- border: ["100", "900"]
2655
- },
2656
- link: {
2657
- fg: ["200", "800"]
2658
- },
2659
- muted: {
2660
- bg: ["50 50%", "950 50%"],
2661
- fg: ["200", "800"]
2662
- }
2663
- }
2664
- },
2665
- default: {
2666
- selected: {
2667
- _hue: "blue"
2668
- }
2669
- },
2670
- critical: {
2671
- disabled: {
2672
- bg: ["50 50%", "950 50%"]
2673
- }
2674
- }
2675
- },
2676
- syntax: {
2677
- atrule: ["purple/600", "purple/400"],
2678
- attrName: ["green/600", "green/400"],
2679
- attrValue: ["yellow/600", "yellow/400"],
2680
- attribute: ["yellow/600", "yellow/400"],
2681
- boolean: ["purple/600", "purple/400"],
2682
- builtin: ["purple/600", "purple/400"],
2683
- cdata: ["yellow/600", "yellow/400"],
2684
- char: ["yellow/600", "yellow/400"],
2685
- class: ["orange/600", "orange/400"],
2686
- className: ["cyan/600", "cyan/400"],
2687
- comment: ["gray/400", "gray/600"],
2688
- constant: ["purple/600", "purple/400"],
2689
- deleted: ["red/600", "red/400"],
2690
- entity: ["red/600", "red/400"],
2691
- function: ["green/600", "green/400"],
2692
- hexcode: ["blue/600", "blue/400"],
2693
- id: ["purple/600", "purple/400"],
2694
- important: ["purple/600", "purple/400"],
2695
- inserted: ["yellow/600", "yellow/400"],
2696
- keyword: ["magenta/600", "magenta/400"],
2697
- number: ["purple/600", "purple/400"],
2698
- operator: ["magenta/600", "magenta/400"],
2699
- property: ["blue/600", "blue/400"],
2700
- pseudoClass: ["yellow/600", "yellow/400"],
2701
- pseudoElement: ["yellow/600", "yellow/400"],
2702
- punctuation: ["gray/600", "gray/400"],
2703
- regex: ["blue/600", "blue/400"],
2704
- selector: ["red/600", "red/400"],
2705
- string: ["yellow/600", "yellow/400"],
2706
- symbol: ["purple/600", "purple/400"],
2707
- tag: ["red/600", "red/400"],
2708
- unit: ["orange/600", "orange/400"],
2709
- url: ["red/600", "red/400"],
2710
- variable: ["red/600", "red/400"]
2711
- }
2712
- };
2713
- function isRecord(value) {
2714
- return !!(value && typeof value == "object" && !Array.isArray(value));
2715
- }
2716
- function merge(...records) {
2717
- const _records = records.filter(Boolean);
2718
- return _records.length === 0 ? {} : _records.reduce(_merge, {});
2719
- }
2720
- function _merge(acc, source) {
2721
- for (const key of Object.keys(source)) {
2722
- const prevValue = acc[key], nextValue = source[key];
2723
- isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
2724
- }
2725
- return acc;
2726
- }
2727
- function resolveColorTokens(inputTokens) {
2728
- const tokens = merge(defaultColorTokens, inputTokens);
2729
- return {
2730
- base: resolveBaseColorTokens(tokens),
2731
- button: resolveButtonColorTokens(tokens),
2732
- input: resolveInputColorTokens(tokens),
2733
- selectable: resolveSelectableColorTokens(tokens),
2734
- syntax: tokens.syntax
2735
- };
2736
- }
2737
- function resolveBaseColorTokens(sparseTokens) {
2738
- const tokens = {};
2739
- for (const tone of THEME_COLOR_CARD_TONES)
2740
- tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
2741
- return tokens;
2742
- }
2743
- function resolveBaseColorTones(inputTokens, tone) {
2744
- const spec = merge(inputTokens?.base?.["*"], inputTokens?.base?.[tone]), hue = spec._hue || inputTokens?.base?.[tone]?._hue || "gray";
2745
- return {
2746
- ...spec,
2747
- _hue: hue,
2748
- avatar: {
2749
- gray: merge({
2750
- _hue: "gray"
2751
- }, spec.avatar?.["*"], spec.avatar?.gray),
2752
- blue: merge({
2753
- _hue: "blue"
2754
- }, spec.avatar?.["*"], spec.avatar?.blue),
2755
- purple: merge({
2756
- _hue: "purple"
2757
- }, spec.avatar?.["*"], spec.avatar?.purple),
2758
- magenta: merge({
2759
- _hue: "magenta"
2760
- }, spec.avatar?.["*"], spec.avatar?.magenta),
2761
- red: merge({
2762
- _hue: "red"
2763
- }, spec.avatar?.["*"], spec.avatar?.red),
2764
- orange: merge({
2765
- _hue: "orange"
2766
- }, spec.avatar?.["*"], spec.avatar?.orange),
2767
- yellow: merge({
2768
- _hue: "yellow"
2769
- }, spec.avatar?.["*"], spec.avatar?.yellow),
2770
- green: merge({
2771
- _hue: "green"
2772
- }, spec.avatar?.["*"], spec.avatar?.green),
2773
- cyan: merge({
2774
- _hue: "cyan"
2775
- }, spec.avatar?.["*"], spec.avatar?.cyan)
2776
- },
2777
- badge: {
2778
- default: {
2779
- _hue: inputTokens?.base?.default?._hue || hue,
2780
- ...spec.badge?.["*"],
2781
- ...spec.badge?.default
2782
- },
2783
- primary: {
2784
- _hue: inputTokens?.base?.primary?._hue || hue,
2785
- ...spec.badge?.["*"],
2786
- ...spec.badge?.primary
2787
- },
2788
- positive: {
2789
- _hue: inputTokens?.base?.positive?._hue || hue,
2790
- ...spec.badge?.["*"],
2791
- ...spec.badge?.positive
2792
- },
2793
- caution: {
2794
- _hue: inputTokens?.base?.caution?._hue || hue,
2795
- ...spec.badge?.["*"],
2796
- ...spec.badge?.caution
2797
- },
2798
- critical: {
2799
- _hue: inputTokens?.base?.critical?._hue || hue,
2800
- ...spec.badge?.["*"],
2801
- ...spec.badge?.critical
2802
- }
2803
- }
2804
- };
2805
- }
2806
- function resolveButtonColorTokens(inputTokens) {
2807
- const tokens = {};
2808
- for (const mode of THEME_COLOR_BUTTON_MODES)
2809
- tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
2810
- return tokens;
2811
- }
2812
- function resolveButtonToneColorTokens(inputTokens, mode) {
2813
- const tokens = {};
2814
- for (const tone of THEME_COLOR_STATE_TONES)
2815
- tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
2816
- return tokens;
2817
- }
2818
- function resolveButtonModeColorTokens(inputTokens, mode, tone) {
2819
- const tokens = {};
2820
- for (const state of THEME_COLOR_STATES)
2821
- tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
2822
- return tokens;
2823
- }
2824
- function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
2825
- 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;
2826
- return {
2827
- ...spec,
2828
- _hue: hue,
2829
- avatar: {
2830
- gray: merge({
2831
- _hue: "gray"
2832
- }, spec.avatar?.["*"], spec.avatar?.gray),
2833
- blue: merge({
2834
- _hue: "blue"
2835
- }, spec.avatar?.["*"], spec.avatar?.blue),
2836
- purple: merge({
2837
- _hue: "purple"
2838
- }, spec.avatar?.["*"], spec.avatar?.purple),
2839
- magenta: merge({
2840
- _hue: "magenta"
2841
- }, spec.avatar?.["*"], spec.avatar?.magenta),
2842
- red: merge({
2843
- _hue: "red"
2844
- }, spec.avatar?.["*"], spec.avatar?.red),
2845
- orange: merge({
2846
- _hue: "orange"
2847
- }, spec.avatar?.["*"], spec.avatar?.orange),
2848
- yellow: merge({
2849
- _hue: "yellow"
2850
- }, spec.avatar?.["*"], spec.avatar?.yellow),
2851
- green: merge({
2852
- _hue: "green"
2853
- }, spec.avatar?.["*"], spec.avatar?.green),
2854
- cyan: merge({
2855
- _hue: "cyan"
2856
- }, spec.avatar?.["*"], spec.avatar?.cyan)
2857
- },
2858
- badge: {
2859
- default: {
2860
- _hue: inputTokens?.base?.default?._hue,
2861
- ...spec.badge?.["*"],
2862
- ...spec.badge?.default
2863
- },
2864
- primary: {
2865
- _hue: inputTokens?.base?.primary?._hue,
2866
- ...spec.badge?.["*"],
2867
- ...spec.badge?.primary
2868
- },
2869
- positive: {
2870
- _hue: inputTokens?.base?.positive?._hue,
2871
- ...spec.badge?.["*"],
2872
- ...spec.badge?.positive
2873
- },
2874
- caution: {
2875
- _hue: inputTokens?.base?.caution?._hue,
2876
- ...spec.badge?.["*"],
2877
- ...spec.badge?.caution
2878
- },
2879
- critical: {
2880
- _hue: inputTokens?.base?.critical?._hue,
2881
- ...spec.badge?.["*"],
2882
- ...spec.badge?.critical
2883
- }
2884
- }
2885
- };
2886
- }
2887
- function resolveInputColorTokens(inputTokens) {
2888
- const tokens = {};
2889
- for (const mode of THEME_COLOR_INPUT_MODES)
2890
- tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
2891
- return tokens;
2892
- }
2893
- function resolveInputModeColorTokens(inputTokens, mode) {
2894
- const states = {};
2895
- for (const state of THEME_COLOR_INPUT_STATES)
2896
- states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
2897
- return states;
2898
- }
2899
- function resolveInputStateColorTokens(inputTokens, mode, state) {
2900
- const spec = merge(inputTokens?.input?.["*"]?.["*"], inputTokens?.input?.[mode]?.["*"], inputTokens?.input?.["*"]?.[state], inputTokens?.input?.[mode]?.[state]), hue = spec._hue || inputTokens?.input?.[mode]?._hue;
2901
- return {
2902
- ...spec,
2903
- _hue: hue
2904
- };
2905
- }
2906
- function resolveSelectableColorTokens(inputTokens) {
2907
- const tokens = {};
2908
- for (const tone of THEME_COLOR_STATE_TONES)
2909
- tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
2910
- return tokens;
2911
- }
2912
- function resolveSelectableToneColorTokens(inputTokens, tone) {
2913
- const states = {
2914
- _hue: inputTokens?.selectable?.[tone]?._hue || inputTokens?.base?.[tone]?._hue
2915
- };
2916
- for (const state of THEME_COLOR_STATES)
2917
- states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
2918
- return states;
2919
- }
2920
- function resolveSelectableStateColorTokens(inputTokens, tone, state) {
2921
- const spec = merge(inputTokens?.selectable?.["*"]?.["*"], inputTokens?.selectable?.[tone]?.["*"], inputTokens?.selectable?.["*"]?.[state], inputTokens?.selectable?.[tone]?.[state]), hue = spec._hue || inputTokens?.base?.[tone]?._hue;
2922
- return {
2923
- ...spec,
2924
- _hue: hue,
2925
- avatar: {
2926
- gray: merge({
2927
- _hue: "gray"
2928
- }, spec.avatar?.["*"], spec.avatar?.gray),
2929
- blue: merge({
2930
- _hue: "blue"
2931
- }, spec.avatar?.["*"], spec.avatar?.blue),
2932
- purple: merge({
2933
- _hue: "purple"
2934
- }, spec.avatar?.["*"], spec.avatar?.purple),
2935
- magenta: merge({
2936
- _hue: "magenta"
2937
- }, spec.avatar?.["*"], spec.avatar?.magenta),
2938
- red: merge({
2939
- _hue: "red"
2940
- }, spec.avatar?.["*"], spec.avatar?.red),
2941
- orange: merge({
2942
- _hue: "orange"
2943
- }, spec.avatar?.["*"], spec.avatar?.orange),
2944
- yellow: merge({
2945
- _hue: "yellow"
2946
- }, spec.avatar?.["*"], spec.avatar?.yellow),
2947
- green: merge({
2948
- _hue: "green"
2949
- }, spec.avatar?.["*"], spec.avatar?.green),
2950
- cyan: merge({
2951
- _hue: "cyan"
2952
- }, spec.avatar?.["*"], spec.avatar?.cyan)
2953
- },
2954
- badge: {
2955
- default: {
2956
- _hue: inputTokens?.base?.default?._hue,
2957
- ...spec.badge?.["*"],
2958
- ...spec.badge?.default
2959
- },
2960
- primary: {
2961
- _hue: inputTokens?.base?.primary?._hue,
2962
- ...spec.badge?.["*"],
2963
- ...spec.badge?.primary
2964
- },
2965
- positive: {
2966
- _hue: inputTokens?.base?.positive?._hue,
2967
- ...spec.badge?.["*"],
2968
- ...spec.badge?.positive
2969
- },
2970
- caution: {
2971
- _hue: inputTokens?.base?.caution?._hue,
2972
- ...spec.badge?.["*"],
2973
- ...spec.badge?.caution
2974
- },
2975
- critical: {
2976
- _hue: inputTokens?.base?.critical?._hue,
2977
- ...spec.badge?.["*"],
2978
- ...spec.badge?.critical
2979
- }
2980
- }
2981
- };
2982
- }
2983
- function buildColorTheme(config) {
2984
- const resolvedConfig = {
2985
- ...config,
2986
- color: resolveColorTokens(config?.color)
2987
- };
2988
- return {
2989
- light: buildColorScheme({
2990
- scheme: "light"
2991
- }, resolvedConfig),
2992
- dark: buildColorScheme({
2993
- scheme: "dark"
2994
- }, resolvedConfig)
2995
- };
2996
- }
2997
- function buildColorScheme(options, config) {
2998
- const {
2999
- scheme
3000
- } = options;
3001
- return {
3002
- transparent: buildCardColorTheme({
3003
- scheme,
3004
- tone: "transparent"
3005
- }, config),
3006
- default: buildCardColorTheme({
3007
- scheme,
3008
- tone: "default"
3009
- }, config),
3010
- primary: buildCardColorTheme({
3011
- scheme,
3012
- tone: "primary"
3013
- }, config),
3014
- positive: buildCardColorTheme({
3015
- scheme,
3016
- tone: "positive"
3017
- }, config),
3018
- caution: buildCardColorTheme({
3019
- scheme,
3020
- tone: "caution"
3021
- }, config),
3022
- critical: buildCardColorTheme({
3023
- scheme,
3024
- tone: "critical"
3025
- }, config)
3026
- };
3027
- }
3028
- function buildCardColorTheme(options, config) {
3029
- const {
3030
- scheme,
3031
- tone
3032
- } = options, tokens = config?.color?.base?.[tone], context = {
3033
- hue: tokens?._hue || "gray",
3034
- scheme
3035
- };
3036
- return {
3037
- _blend: (tokens?._blend || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
3038
- _dark: scheme === "dark",
3039
- accent: {
3040
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3041
- },
3042
- avatar: buildAvatarColorTheme({
3043
- scheme
3044
- }, tokens),
3045
- backdrop: resolveColorTokenValue(context, tokens?.backdrop),
3046
- badge: buildBadgeColorTheme(tokens?.badge, {
3047
- scheme
3048
- }, config),
3049
- bg: resolveColorTokenValue(context, tokens?.bg),
3050
- border: resolveColorTokenValue(context, tokens?.border),
3051
- button: buildButtonColorTheme({
3052
- scheme
3053
- }, config),
3054
- code: {
3055
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3056
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3057
- },
3058
- fg: resolveColorTokenValue(context, tokens?.fg),
3059
- focusRing: resolveColorTokenValue(context, tokens?.focusRing),
3060
- icon: resolveColorTokenValue(context, tokens?.icon),
3061
- input: buildInputColorTheme({
3062
- scheme,
3063
- tone
3064
- }, config),
3065
- kbd: {
3066
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3067
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3068
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3069
- },
3070
- link: {
3071
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
3072
- },
3073
- muted: {
3074
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3075
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3076
- },
3077
- selectable: buildSelectableColorTheme({
3078
- scheme
3079
- }, config),
3080
- shadow: buildShadowColorTheme({
3081
- scheme,
3082
- tone
3083
- }, config),
3084
- skeleton: {
3085
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3086
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3087
- },
3088
- syntax: buildSyntaxColorTheme({
3089
- scheme
3090
- }, config)
3091
- };
3092
- }
3093
- function buildShadowColorTheme(options, config) {
3094
- const {
3095
- scheme,
3096
- tone
3097
- } = options, tokens = config?.color?.base?.[tone], context = {
3098
- hue: tokens?._hue || "gray",
3099
- scheme
3100
- };
3101
- return {
3102
- outline: resolveColorTokenValue(context, tokens?.shadow?.outline),
3103
- umbra: resolveColorTokenValue(context, tokens?.shadow?.umbra),
3104
- penumbra: resolveColorTokenValue(context, tokens?.shadow?.penumbra),
3105
- ambient: resolveColorTokenValue(context, tokens?.shadow?.ambient)
3106
- };
3107
- }
3108
- function buildAvatarColorTheme(options, stateTokens) {
3109
- const {
3110
- scheme
3111
- } = options;
3112
- return {
3113
- gray: _buildAvatarColorTheme({
3114
- color: "gray",
3115
- scheme
3116
- }, stateTokens),
3117
- blue: _buildAvatarColorTheme({
3118
- color: "blue",
3119
- scheme
3120
- }, stateTokens),
3121
- purple: _buildAvatarColorTheme({
3122
- color: "purple",
3123
- scheme
3124
- }, stateTokens),
3125
- magenta: _buildAvatarColorTheme({
3126
- color: "magenta",
3127
- scheme
3128
- }, stateTokens),
3129
- red: _buildAvatarColorTheme({
3130
- color: "red",
3131
- scheme
3132
- }, stateTokens),
3133
- orange: _buildAvatarColorTheme({
3134
- color: "orange",
3135
- scheme
3136
- }, stateTokens),
3137
- yellow: _buildAvatarColorTheme({
3138
- color: "yellow",
3139
- scheme
3140
- }, stateTokens),
3141
- green: _buildAvatarColorTheme({
3142
- color: "green",
3143
- scheme
3144
- }, stateTokens),
3145
- cyan: _buildAvatarColorTheme({
3146
- color: "cyan",
3147
- scheme
3148
- }, stateTokens)
3149
- };
3150
- }
3151
- function _buildAvatarColorTheme(options, stateTokens) {
3152
- const {
3153
- color: color2,
3154
- scheme
3155
- } = options, tokens = stateTokens?.avatar?.[color2], context = {
3156
- hue: tokens?._hue || "gray",
3157
- scheme
3158
- };
3159
- return {
3160
- _blend: (tokens?._blend || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
3161
- bg: resolveColorTokenValue(context, tokens?.bg),
3162
- fg: resolveColorTokenValue(context, tokens?.fg)
3163
- };
3164
- }
3165
- function buildBadgeColorTheme(tokens, options, config) {
3166
- const {
3167
- scheme
3168
- } = options;
3169
- return {
3170
- default: _buildBadgeColorTheme(tokens, {
3171
- scheme,
3172
- tone: "default"
3173
- }, config),
3174
- primary: _buildBadgeColorTheme(tokens, {
3175
- scheme,
3176
- tone: "primary"
3177
- }, config),
3178
- positive: _buildBadgeColorTheme(tokens, {
3179
- scheme,
3180
- tone: "positive"
3181
- }, config),
3182
- caution: _buildBadgeColorTheme(tokens, {
3183
- scheme,
3184
- tone: "caution"
3185
- }, config),
3186
- critical: _buildBadgeColorTheme(tokens, {
3187
- scheme,
3188
- tone: "critical"
3189
- }, config)
3190
- };
3191
- }
3192
- function _buildBadgeColorTheme(parentTokens, options, config) {
3193
- const {
3194
- scheme,
3195
- tone
3196
- } = options, tokens = parentTokens?.[tone], context = {
3197
- hue: tokens?._hue || config?.color?.base?.[tone]?._hue || "gray",
3198
- scheme
3199
- };
3200
- return {
3201
- bg: resolveColorTokenValue(context, tokens?.bg),
3202
- fg: resolveColorTokenValue(context, tokens?.fg),
3203
- dot: resolveColorTokenValue(context, tokens?.dot),
3204
- icon: resolveColorTokenValue(context, tokens?.icon)
3205
- };
3206
- }
3207
- function buildButtonColorTheme(options, config) {
3208
- const {
3209
- scheme
3210
- } = options, modes = {};
3211
- for (const mode of THEME_COLOR_BUTTON_MODES)
3212
- modes[mode] = buildButtonTonesColorTheme({
3213
- scheme,
3214
- mode
3215
- }, config);
3216
- return modes;
3217
- }
3218
- function buildButtonTonesColorTheme(options, config) {
3219
- const {
3220
- mode,
3221
- scheme
3222
- } = options, tones2 = {};
3223
- for (const tone of THEME_COLOR_STATE_TONES)
3224
- tones2[tone] = buildButtonStatesColorTheme({
3225
- mode,
3226
- scheme,
3227
- tone
3228
- }, config);
3229
- return tones2;
3230
- }
3231
- function buildButtonStatesColorTheme(options, config) {
3232
- const {
3233
- mode,
3234
- scheme,
3235
- tone
3236
- } = options, states = {};
3237
- for (const state of THEME_COLOR_STATES)
3238
- states[state] = buildButtonStateColorTheme({
3239
- mode,
3240
- tone,
3241
- scheme,
3242
- state
3243
- }, config);
3244
- return states;
3245
- }
3246
- function buildButtonStateColorTheme(options, config) {
3247
- const {
3248
- mode,
3249
- tone,
3250
- scheme,
3251
- state
3252
- } = options, tokens = config?.color?.button?.[mode]?.[tone]?.[state], hue = tokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3253
- hue,
3254
- scheme
3255
- };
3256
- return {
3257
- _blend: blendMode[scheme === "light" ? 0 : 1],
3258
- accent: {
3259
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3260
- },
3261
- avatar: buildAvatarColorTheme({
3262
- scheme
3263
- }, tokens),
3264
- badge: buildBadgeColorTheme(tokens?.badge, {
3265
- scheme
3266
- }, config),
3267
- bg: resolveColorTokenValue(context, tokens?.bg),
3268
- border: resolveColorTokenValue(context, tokens?.border),
3269
- code: {
3270
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3271
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3272
- },
3273
- fg: resolveColorTokenValue(context, tokens?.fg),
3274
- icon: resolveColorTokenValue(context, tokens?.icon),
3275
- muted: {
3276
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3277
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3278
- },
3279
- kbd: {
3280
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3281
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3282
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3283
- },
3284
- link: {
3285
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
3286
- },
3287
- skeleton: {
3288
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3289
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3290
- }
3291
- };
3292
- }
3293
- function buildInputColorTheme(options, config) {
3294
- const {
3295
- scheme,
3296
- tone
3297
- } = options;
3298
- return {
3299
- default: buildInputStatesColorTheme({
3300
- mode: "default",
3301
- scheme,
3302
- tone
3303
- }, config),
3304
- invalid: buildInputStatesColorTheme({
3305
- mode: "invalid",
3306
- scheme,
3307
- tone
3308
- }, config)
3309
- };
3310
- }
3311
- function buildInputStatesColorTheme(options, config) {
3312
- const {
3313
- mode,
3314
- scheme,
3315
- tone
3316
- } = options;
3317
- return {
3318
- enabled: buildInputStateColorTheme({
3319
- mode,
3320
- scheme,
3321
- state: "enabled",
3322
- tone
3323
- }, config),
3324
- hovered: buildInputStateColorTheme({
3325
- mode,
3326
- scheme,
3327
- state: "hovered",
3328
- tone
3329
- }, config),
3330
- readOnly: buildInputStateColorTheme({
3331
- mode,
3332
- scheme,
3333
- state: "readOnly",
3334
- tone
3335
- }, config),
3336
- disabled: buildInputStateColorTheme({
3337
- mode,
3338
- scheme,
3339
- state: "disabled",
3340
- tone
3341
- }, config)
3342
- };
3343
- }
3344
- function buildInputStateColorTheme(options, config) {
3345
- const {
3346
- mode,
3347
- tone,
3348
- scheme,
3349
- state
3350
- } = options, tokens = config?.color?.input?.[mode]?.[state], hue = tokens?._hue || config?.color?.base?.[tone]?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3351
- hue,
3352
- scheme
3353
- };
3354
- return {
3355
- _blend: blendMode[scheme === "light" ? 0 : 1],
3356
- bg: resolveColorTokenValue(context, tokens?.bg),
3357
- border: resolveColorTokenValue(context, tokens?.border),
3358
- fg: resolveColorTokenValue(context, tokens?.fg),
3359
- muted: {
3360
- bg: resolveColorTokenValue(context, tokens?.muted?.bg)
3361
- },
3362
- placeholder: resolveColorTokenValue(context, tokens?.placeholder)
3363
- };
3364
- }
3365
- function buildSelectableColorTheme(options, config) {
3366
- const {
3367
- scheme
3368
- } = options, tones2 = {};
3369
- for (const tone of THEME_COLOR_STATE_TONES)
3370
- tones2[tone] = buildSelectableStatesColorTheme({
3371
- scheme,
3372
- tone
3373
- }, config);
3374
- return tones2;
3375
- }
3376
- function buildSelectableStatesColorTheme(options, config) {
3377
- const {
3378
- scheme,
3379
- tone
3380
- } = options, states = {};
3381
- for (const state of THEME_COLOR_STATES)
3382
- states[state] = buildSelectableStateColorTheme({
3383
- tone,
3384
- scheme,
3385
- state
3386
- }, config);
3387
- return states;
3388
- }
3389
- function buildSelectableStateColorTheme(options, config) {
3390
- const {
3391
- scheme,
3392
- state,
3393
- tone
3394
- } = options, tokens = config?.color?.selectable?.[tone]?.[state], hue = tokens?._hue || "gray", blendMode = tokens?._blend || ["screen", "multiply"], context = {
3395
- hue,
3396
- scheme
3397
- };
3398
- return {
3399
- _blend: blendMode[scheme === "light" ? 0 : 1],
3400
- accent: {
3401
- fg: resolveColorTokenValue(context, tokens?.accent?.fg)
3402
- },
3403
- avatar: buildAvatarColorTheme({
3404
- scheme
3405
- }, tokens),
3406
- badge: buildBadgeColorTheme(tokens?.badge, {
3407
- scheme
3408
- }, config),
3409
- bg: resolveColorTokenValue(context, tokens?.bg),
3410
- border: resolveColorTokenValue(context, tokens?.border),
3411
- code: {
3412
- bg: resolveColorTokenValue(context, tokens?.code?.bg),
3413
- fg: resolveColorTokenValue(context, tokens?.code?.fg)
3414
- },
3415
- fg: resolveColorTokenValue(context, tokens?.fg),
3416
- icon: resolveColorTokenValue(context, tokens?.icon),
2581
+ kbd: base.kbd,
2582
+ link: base.link,
3417
2583
  muted: {
3418
- bg: resolveColorTokenValue(context, tokens?.muted?.bg),
3419
- fg: resolveColorTokenValue(context, tokens?.muted?.fg)
3420
- },
3421
- kbd: {
3422
- bg: resolveColorTokenValue(context, tokens?.kbd?.bg),
3423
- fg: resolveColorTokenValue(context, tokens?.kbd?.fg),
3424
- border: resolveColorTokenValue(context, tokens?.kbd?.border)
3425
- },
3426
- link: {
3427
- fg: resolveColorTokenValue(context, tokens?.link?.fg)
2584
+ ...base.muted,
2585
+ bg: color_v0.selectable?.default.enabled.bg2 || color_v0.base.bg
3428
2586
  },
2587
+ selectable: stateTonesThemeColor_v0_v2(color_v0, color_v0.selectable || color_v0.muted),
2588
+ shadow: color_v0.base.shadow,
3429
2589
  skeleton: {
3430
- from: resolveColorTokenValue(context, tokens?.skeleton?.from),
3431
- to: resolveColorTokenValue(context, tokens?.skeleton?.to)
3432
- }
3433
- };
3434
- }
3435
- function buildSyntaxColorTheme(options, config) {
3436
- const {
3437
- scheme
3438
- } = options, tokens = config?.color?.syntax, context = {
3439
- hue: "gray",
3440
- scheme
3441
- };
3442
- return {
3443
- atrule: resolveColorTokenValue(context, tokens?.atrule),
3444
- attrName: resolveColorTokenValue(context, tokens?.attrName),
3445
- attrValue: resolveColorTokenValue(context, tokens?.attrValue),
3446
- attribute: resolveColorTokenValue(context, tokens?.attribute),
3447
- boolean: resolveColorTokenValue(context, tokens?.boolean),
3448
- builtin: resolveColorTokenValue(context, tokens?.builtin),
3449
- cdata: resolveColorTokenValue(context, tokens?.cdata),
3450
- char: resolveColorTokenValue(context, tokens?.char),
3451
- class: resolveColorTokenValue(context, tokens?.class),
3452
- className: resolveColorTokenValue(context, tokens?.className),
3453
- comment: resolveColorTokenValue(context, tokens?.comment),
3454
- constant: resolveColorTokenValue(context, tokens?.constant),
3455
- deleted: resolveColorTokenValue(context, tokens?.deleted),
3456
- doctype: resolveColorTokenValue(context, tokens?.doctype),
3457
- entity: resolveColorTokenValue(context, tokens?.entity),
3458
- function: resolveColorTokenValue(context, tokens?.function),
3459
- hexcode: resolveColorTokenValue(context, tokens?.hexcode),
3460
- id: resolveColorTokenValue(context, tokens?.id),
3461
- important: resolveColorTokenValue(context, tokens?.important),
3462
- inserted: resolveColorTokenValue(context, tokens?.inserted),
3463
- keyword: resolveColorTokenValue(context, tokens?.keyword),
3464
- number: resolveColorTokenValue(context, tokens?.number),
3465
- operator: resolveColorTokenValue(context, tokens?.operator),
3466
- prolog: resolveColorTokenValue(context, tokens?.prolog),
3467
- property: resolveColorTokenValue(context, tokens?.property),
3468
- pseudoClass: resolveColorTokenValue(context, tokens?.pseudoClass),
3469
- pseudoElement: resolveColorTokenValue(context, tokens?.pseudoElement),
3470
- punctuation: resolveColorTokenValue(context, tokens?.punctuation),
3471
- regex: resolveColorTokenValue(context, tokens?.regex),
3472
- selector: resolveColorTokenValue(context, tokens?.selector),
3473
- string: resolveColorTokenValue(context, tokens?.string),
3474
- symbol: resolveColorTokenValue(context, tokens?.symbol),
3475
- tag: resolveColorTokenValue(context, tokens?.tag),
3476
- unit: resolveColorTokenValue(context, tokens?.unit),
3477
- url: resolveColorTokenValue(context, tokens?.url),
3478
- variable: resolveColorTokenValue(context, tokens?.variable)
3479
- };
3480
- }
3481
- const defaultColorPalette = color.color;
3482
- function mixChannel(b, s, weight) {
3483
- const delta = (s - b) * weight;
3484
- return b + delta;
3485
- }
3486
- function mix(b, s, weight) {
3487
- return {
3488
- r: mixChannel(b.r, s.r, weight),
3489
- g: mixChannel(b.g, s.g, weight),
3490
- b: mixChannel(b.b, s.b, weight)
3491
- };
3492
- }
3493
- function multiplyChannel(b, s) {
3494
- return b * s;
3495
- }
3496
- function multiply(b, s) {
3497
- return {
3498
- r: multiplyChannel(b.r / 255, s.r / 255) * 255,
3499
- g: multiplyChannel(b.g / 255, s.g / 255) * 255,
3500
- b: multiplyChannel(b.b / 255, s.b / 255) * 255
3501
- };
3502
- }
3503
- function screenChannel(b, s) {
3504
- return b + s - b * s;
3505
- }
3506
- function screen(b, s) {
3507
- return {
3508
- r: screenChannel(b.r / 255, s.r / 255) * 255,
3509
- g: screenChannel(b.g / 255, s.g / 255) * 255,
3510
- b: screenChannel(b.b / 255, s.b / 255) * 255
3511
- };
3512
- }
3513
- function lerp(x, y, a) {
3514
- return x * (1 - a) + y * a;
3515
- }
3516
- function invlerp(x, y, a) {
3517
- return clamp((a - x) / (y - x));
3518
- }
3519
- function clamp(a, min = 0, max = 1) {
3520
- return Math.min(max, Math.max(min, a));
3521
- }
3522
- function range(x1, y1, x2, y2, a) {
3523
- return lerp(x2, y2, invlerp(x1, y1, a));
3524
- }
3525
- function round(value) {
3526
- return Math.round(value);
3527
- }
3528
- function hexToRgb(hex) {
3529
- if (hex.length === 4) {
3530
- const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
3531
- return {
3532
- r: parseInt(hexR + hexR, 16),
3533
- g: parseInt(hexG + hexG, 16),
3534
- b: parseInt(hexB + hexB, 16)
3535
- };
3536
- }
3537
- return {
3538
- r: parseInt(hex.slice(1, 3), 16),
3539
- g: parseInt(hex.slice(3, 5), 16),
3540
- b: parseInt(hex.slice(5, 7), 16)
3541
- };
3542
- }
3543
- function rgbaToRGBA(rgba2) {
3544
- const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
3545
- return {
3546
- r: parseInt(values[0]),
3547
- g: parseInt(values[1]),
3548
- b: parseInt(values[2]),
3549
- a: parseFloat(values[3])
3550
- };
3551
- }
3552
- function rgbToHex(color2) {
3553
- 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));
3554
- return "a" in color2 ? `rgba(${r},${g},${b},${color2.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3555
- }
3556
- function rgbToHsl({
3557
- r,
3558
- g,
3559
- b
3560
- }) {
3561
- r /= 255, g /= 255, b /= 255;
3562
- const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
3563
- let h = 0, s = 0, l = 0;
3564
- 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), {
3565
- h,
3566
- s,
3567
- l
3568
- };
3569
- }
3570
- function hslToRgb(hsl) {
3571
- 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;
3572
- let r = 0, g = 0, b = 0;
3573
- 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), {
3574
- r: Math.round((r + m) * 255),
3575
- g: Math.round((g + m) * 255),
3576
- b: Math.round((b + m) * 255)
3577
- };
3578
- }
3579
- const HEX_CHARS = "0123456789ABCDEFabcdef", HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
3580
- function isHexChars(str) {
3581
- for (const c of str)
3582
- if (HEX_CHARS.indexOf(c) === -1)
3583
- return !1;
3584
- return !0;
3585
- }
3586
- function isHex(str) {
3587
- return str[0] !== "#" || !(str.length === 4 || str.length === 7) ? !1 : isHexChars(str.slice(1));
3588
- }
3589
- function parseHsl(str) {
3590
- const res = HSL_RE.exec(str);
3591
- if (!res)
3592
- throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
3593
- return {
3594
- h: parseInt(res[1]),
3595
- s: parseFloat(res[3]),
3596
- l: parseFloat(res[5])
3597
- };
3598
- }
3599
- function parseColor(color2) {
3600
- if (!color2) return {
3601
- r: 0,
3602
- g: 0,
3603
- b: 0
3604
- };
3605
- if (typeof color2 != "string")
3606
- throw new Error("parseColor: expected a string");
3607
- if (isHex(color2))
3608
- return hexToRgb(color2);
3609
- if (color2.startsWith("hsl("))
3610
- return hslToRgb(parseHsl(color2));
3611
- if (color2.startsWith("rgba("))
3612
- return rgbaToRGBA(color2);
3613
- throw new Error(`parseColor: unexpected color format: "${color2}"`);
3614
- }
3615
- function getContrastRatio(bg, fg) {
3616
- const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
3617
- return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
3618
- }
3619
- function rgb_lrgb({
3620
- r,
3621
- g,
3622
- b
3623
- }) {
3624
- return [rgb_lrgb1(r / 255), rgb_lrgb1(g / 255), rgb_lrgb1(b / 255)];
3625
- }
3626
- function rgb_lrgb1(v) {
3627
- return v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
3628
- }
3629
- function lrgb_luminance([r, g, b]) {
3630
- return 0.2126 * r + 0.7152 * g + 0.0722 * b;
3631
- }
3632
- function rgba(color2, a) {
3633
- const rgb = parseColor(color2);
3634
- return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
3635
- }
3636
- const RGB_RANGE = [0, 255];
3637
- function mixThemeColor(value, options) {
3638
- const {
3639
- blendMode
3640
- } = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
3641
- r: [black2.r, white2.r],
3642
- g: [black2.g, white2.g],
3643
- b: [black2.b, white2.b]
3644
- }, convertedBgColor = {
3645
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
3646
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
3647
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
3648
- }, convertedColor = {
3649
- r: clamp(range(...paletteRange.r, ...RGB_RANGE, color2.r), ...RGB_RANGE),
3650
- g: clamp(range(...paletteRange.g, ...RGB_RANGE, color2.g), ...RGB_RANGE),
3651
- b: clamp(range(...paletteRange.b, ...RGB_RANGE, color2.b), ...RGB_RANGE)
3652
- }, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor), v = {
3653
- r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
3654
- g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
3655
- b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
3656
- };
3657
- return rgbToHex(v);
3658
- }
3659
- function renderColorValue(str, options) {
3660
- const {
3661
- bg,
3662
- blendMode,
3663
- colorPalette
3664
- } = options;
3665
- if (bg === "white")
3666
- throw new Error("Cannot blend with white background");
3667
- const node = parseTokenValue(str);
3668
- if (!node || node.type !== "color")
3669
- throw new Error(`Invalid color token value: ${str}`);
3670
- let hex = "";
3671
- 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)
3672
- throw new Error(`Invalid color token value: ${str}`);
3673
- const hexBeforeMix = hex, mixOptions = {
3674
- blendMode,
3675
- bg,
3676
- black: renderColorHex(colorPalette.black),
3677
- // opacity: node.opacity,
3678
- white: renderColorHex(colorPalette.white)
3679
- };
3680
- try {
3681
- if (hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0) {
3682
- const from = hexToRgb(bg), to = hexToRgb(hex);
3683
- hex = rgbToHex(mix(from, to, node.mix));
3684
- }
3685
- } catch (err) {
3686
- throw console.warn("could not blend", hex, mixOptions), err;
3687
- }
3688
- return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
3689
- }
3690
- function renderColorHex(color2) {
3691
- return typeof color2 == "string" ? color2 : color2.hex;
3692
- }
3693
- function renderThemeColorSchemes(value, config) {
3694
- const colorPalette = config?.palette ?? defaultColorPalette;
3695
- return {
3696
- light: renderThemeColorScheme(colorPalette, value.light),
3697
- dark: renderThemeColorScheme(colorPalette, value.dark)
2590
+ from: color_v0.skeleton?.from || color_v0.base.border,
2591
+ to: color_v0.skeleton?.to || color_v0.base.border
2592
+ },
2593
+ syntax: color_v0.syntax
3698
2594
  };
2595
+ return cache$3.set(color_v0, color_v2), color_v2;
3699
2596
  }
3700
- function renderThemeColorScheme(colorPalette, value) {
3701
- const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, {
3702
- colorPalette
3703
- }), renderedDefaultTone = renderThemeColor(defaultTone, {
3704
- colorPalette
3705
- }), bg = renderedDefaultTone.bg;
3706
- if (bg === "white")
3707
- throw new Error("Cannot blend with white background");
3708
- return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(([k]) => k !== "default" && k !== "transparent").map(([k, v]) => [k, renderThemeColor(v, {
3709
- bg,
3710
- colorPalette
3711
- })])]);
3712
- }
3713
- function renderThemeColor(value, options) {
3714
- const {
3715
- colorPalette,
3716
- bg
3717
- } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, {
3718
- colorPalette,
3719
- bg,
3720
- blendMode
3721
- }), colorOptions = {
3722
- colorPalette,
3723
- bg: baseBg,
3724
- blendMode
3725
- }, button = renderThemeColorButton(value.button, {
3726
- baseBg,
3727
- blendMode,
3728
- colorPalette
3729
- }), selectable = renderThemeColorSelectable(value.selectable, {
3730
- colorPalette,
3731
- baseBg,
3732
- blendMode
3733
- }), shadow = {
3734
- outline: renderColorValue(value.shadow.outline, colorOptions),
3735
- umbra: renderColorValue(value.shadow.umbra, {
3736
- ...colorOptions,
3737
- bg: void 0,
3738
- colorPalette: {
3739
- ...colorPalette,
3740
- black: "#000000"
3741
- }
3742
- }),
3743
- penumbra: renderColorValue(value.shadow.penumbra, {
3744
- ...colorOptions,
3745
- bg: void 0,
3746
- colorPalette: {
3747
- ...colorPalette,
3748
- black: "#000000"
3749
- }
3750
- }),
3751
- ambient: renderColorValue(value.shadow.ambient, {
3752
- ...colorOptions,
3753
- bg: void 0,
3754
- colorPalette: {
3755
- ...colorPalette,
3756
- black: "#000000"
3757
- }
3758
- })
3759
- };
2597
+ function stateTonesThemeColor_v0_v2(v0, t) {
3760
2598
  return {
3761
- _blend: blendMode,
3762
- _dark: value._dark,
3763
- accent: {
3764
- fg: renderColorValue(value.accent.fg, colorOptions)
3765
- },
3766
- avatar: renderThemeColorAvatar(value.avatar, {
3767
- baseBg,
3768
- colorPalette,
3769
- blendMode
3770
- }),
3771
- backdrop: renderColorValue(value.backdrop, colorOptions),
3772
- badge: renderThemeColorBadge(value.badge, {
3773
- baseBg,
3774
- colorPalette,
3775
- blendMode
3776
- }),
3777
- bg: baseBg,
3778
- border: renderColorValue(value.border, colorOptions),
3779
- button,
3780
- code: {
3781
- bg: renderColorValue(value.code.bg, colorOptions),
3782
- fg: renderColorValue(value.code.fg, colorOptions)
3783
- },
3784
- fg: renderColorValue(value.fg, colorOptions),
3785
- focusRing: renderColorValue(value.focusRing, colorOptions),
3786
- icon: renderColorValue(value.icon, colorOptions),
3787
- input: renderThemeColorInput(value.input, {
3788
- baseBg,
3789
- colorPalette,
3790
- blendMode
3791
- }),
3792
- kbd: renderThemeColorKBD(value.kbd, {
3793
- baseBg,
3794
- colorPalette,
3795
- blendMode
3796
- }),
3797
- link: {
3798
- fg: renderColorValue(value.link.fg, colorOptions)
2599
+ default: {
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)
3799
2605
  },
3800
- muted: {
3801
- bg: renderColorValue(value.muted.bg, colorOptions),
3802
- fg: renderColorValue(value.muted.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)
3803
2612
  },
3804
- shadow,
3805
- skeleton: {
3806
- from: renderColorValue(value.skeleton.from, colorOptions),
3807
- to: renderColorValue(value.skeleton.to, 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)
3808
2619
  },
3809
- syntax: renderSyntaxColorTheme(value.syntax, {
3810
- baseBg,
3811
- colorPalette,
3812
- blendMode
3813
- }),
3814
- selectable
3815
- };
3816
- }
3817
- function renderThemeColorKBD(value, options) {
3818
- const {
3819
- baseBg,
3820
- blendMode,
3821
- colorPalette
3822
- } = options, rootOptions = {
3823
- bg: baseBg,
3824
- blendMode,
3825
- colorPalette
3826
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3827
- bg,
3828
- blendMode,
3829
- colorPalette
3830
- };
3831
- return {
3832
- bg,
3833
- fg: renderColorValue(value.fg, colorOptions),
3834
- border: renderColorValue(value.border, colorOptions)
3835
- };
3836
- }
3837
- function renderThemeColorAvatar(value, options) {
3838
- return {
3839
- gray: renderThemeColorAvatarColor(value.gray, options),
3840
- blue: renderThemeColorAvatarColor(value.blue, options),
3841
- purple: renderThemeColorAvatarColor(value.purple, options),
3842
- magenta: renderThemeColorAvatarColor(value.magenta, options),
3843
- red: renderThemeColorAvatarColor(value.red, options),
3844
- orange: renderThemeColorAvatarColor(value.orange, options),
3845
- yellow: renderThemeColorAvatarColor(value.yellow, options),
3846
- green: renderThemeColorAvatarColor(value.green, options),
3847
- cyan: renderThemeColorAvatarColor(value.cyan, options)
3848
- };
3849
- }
3850
- function renderThemeColorAvatarColor(value, options) {
3851
- const {
3852
- baseBg,
3853
- blendMode: rootBlendMode,
3854
- colorPalette
3855
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3856
- bg: baseBg,
3857
- blendMode: rootBlendMode,
3858
- colorPalette
3859
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3860
- bg,
3861
- blendMode,
3862
- colorPalette
3863
- };
3864
- return {
3865
- _blend: blendMode,
3866
- bg,
3867
- fg: renderColorValue(value.fg, colorOptions)
3868
- };
3869
- }
3870
- function renderThemeColorBadge(value, options) {
3871
- return {
3872
- default: renderThemeColorBadgeColor(value.default, options),
3873
- primary: renderThemeColorBadgeColor(value.primary, options),
3874
- positive: renderThemeColorBadgeColor(value.positive, options),
3875
- caution: renderThemeColorBadgeColor(value.caution, options),
3876
- critical: renderThemeColorBadgeColor(value.critical, options)
3877
- };
3878
- }
3879
- function renderThemeColorBadgeColor(value, options) {
3880
- const {
3881
- baseBg,
3882
- blendMode: rootBlendMode,
3883
- colorPalette
3884
- } = options, blendMode = rootBlendMode, rootOptions = {
3885
- bg: baseBg,
3886
- blendMode: rootBlendMode,
3887
- colorPalette
3888
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3889
- bg,
3890
- blendMode,
3891
- colorPalette
3892
- };
3893
- return {
3894
- bg,
3895
- dot: renderColorValue(value.dot, colorOptions),
3896
- fg: renderColorValue(value.fg, colorOptions),
3897
- icon: renderColorValue(value.icon, colorOptions)
3898
- };
3899
- }
3900
- function renderThemeColorButton(value, options) {
3901
- return {
3902
- default: renderThemeColorButtonTones(value.default, options),
3903
- ghost: renderThemeColorButtonTones(value.ghost, options),
3904
- bleed: renderThemeColorButtonTones(value.bleed, options)
3905
- };
3906
- }
3907
- function renderThemeColorButtonTones(value, options) {
3908
- return {
3909
- default: renderThemeColorButtonStates(value.default, options),
3910
- primary: renderThemeColorButtonStates(value.primary, options),
3911
- positive: renderThemeColorButtonStates(value.positive, options),
3912
- caution: renderThemeColorButtonStates(value.caution, options),
3913
- critical: renderThemeColorButtonStates(value.critical, options)
3914
- };
3915
- }
3916
- function renderThemeColorButtonStates(value, options) {
3917
- return {
3918
- enabled: renderThemeColorState(value.enabled, options),
3919
- hovered: renderThemeColorState(value.hovered, options),
3920
- pressed: renderThemeColorState(value.pressed, options),
3921
- selected: renderThemeColorState(value.selected, options),
3922
- disabled: renderThemeColorState(value.disabled, options)
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)
2626
+ },
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)
2633
+ },
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)
2640
+ },
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
+ }
3923
2648
  };
3924
2649
  }
3925
- function renderThemeColorState(value, options) {
3926
- const {
3927
- baseBg,
3928
- blendMode: rootBlendMode,
3929
- colorPalette
3930
- } = options, blendMode = value._blend || "multiply", rootOptions = {
3931
- bg: baseBg,
3932
- blendMode: rootBlendMode,
3933
- colorPalette
3934
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
3935
- bg,
3936
- blendMode,
3937
- colorPalette
3938
- };
2650
+ function stateThemeColor_v0_v2(v0, state) {
3939
2651
  return {
3940
- _blend: blendMode,
3941
- accent: {
3942
- 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
+ }
3943
2690
  },
3944
- avatar: renderThemeColorAvatar(value.avatar, {
3945
- baseBg: bg,
3946
- colorPalette,
3947
- blendMode
3948
- }),
3949
- badge: renderThemeColorBadge(value.badge, {
3950
- baseBg: bg,
3951
- colorPalette,
3952
- blendMode
3953
- }),
3954
- bg,
3955
- border: renderColorValue(value.border, colorOptions),
3956
- code: {
3957
- bg: renderColorValue(value.code.bg, colorOptions),
3958
- 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
+ }
3959
2734
  },
3960
- fg: renderColorValue(value.fg, colorOptions),
3961
- icon: renderColorValue(value.icon, colorOptions),
3962
- link: {
3963
- 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
3964
2739
  },
3965
2740
  muted: {
3966
- bg: renderColorValue(value.muted.bg, colorOptions),
3967
- fg: renderColorValue(value.muted.fg, colorOptions)
3968
- },
3969
- kbd: {
3970
- bg: renderColorValue(value.kbd.bg, colorOptions),
3971
- fg: renderColorValue(value.kbd.fg, colorOptions),
3972
- border: renderColorValue(value.kbd.border, colorOptions)
2741
+ ...v0.muted.default.enabled.muted,
2742
+ bg: state.bg2 || state.bg
3973
2743
  },
3974
2744
  skeleton: {
3975
- from: renderColorValue(value.skeleton?.from, colorOptions),
3976
- to: renderColorValue(value.skeleton?.to, colorOptions)
2745
+ from: state.skeleton?.from || state.border,
2746
+ to: state.skeleton?.to || state.border
3977
2747
  }
3978
2748
  };
3979
2749
  }
3980
- function renderThemeColorInput(value, options) {
3981
- return {
3982
- default: renderInputStatesColorTheme(value.default, options),
3983
- invalid: renderInputStatesColorTheme(value.invalid, options)
3984
- };
3985
- }
3986
- function renderInputStatesColorTheme(value, options) {
2750
+ function inputStatesThemeColor_v0_v2(states) {
3987
2751
  return {
3988
- enabled: renderInputStateColorTheme(value.enabled, options),
3989
- hovered: renderInputStateColorTheme(value.hovered, options),
3990
- readOnly: renderInputStateColorTheme(value.readOnly, options),
3991
- 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)
3992
2756
  };
3993
2757
  }
3994
- function renderInputStateColorTheme(value, options) {
3995
- const {
3996
- baseBg,
3997
- blendMode: rootBlendMode,
3998
- colorPalette
3999
- } = options, blendMode = value._blend || "multiply", rootOptions = {
4000
- colorPalette,
4001
- bg: baseBg,
4002
- blendMode: rootBlendMode
4003
- }, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
4004
- colorPalette,
4005
- bg,
4006
- blendMode
4007
- };
2758
+ function inputStateThemeColor_v0_v2(state) {
4008
2759
  return {
4009
- _blend: blendMode,
4010
- bg,
4011
- border: renderColorValue(value.border, colorOptions),
4012
- fg: renderColorValue(value.fg, colorOptions),
2760
+ bg: state.bg,
2761
+ border: state.border,
2762
+ fg: state.fg,
4013
2763
  muted: {
4014
- bg: renderColorValue(value.muted.bg, colorOptions)
2764
+ bg: state.bg2
4015
2765
  },
4016
- placeholder: renderColorValue(value.placeholder, colorOptions)
4017
- };
4018
- }
4019
- function renderThemeColorSelectable(value, options) {
4020
- return {
4021
- default: renderThemeColorSelectableStates(value.default, options),
4022
- primary: renderThemeColorSelectableStates(value.primary, options),
4023
- positive: renderThemeColorSelectableStates(value.positive, options),
4024
- caution: renderThemeColorSelectableStates(value.caution, options),
4025
- critical: renderThemeColorSelectableStates(value.critical, options)
4026
- };
4027
- }
4028
- function renderThemeColorSelectableStates(value, options) {
4029
- return {
4030
- enabled: renderThemeColorState(value.enabled, options),
4031
- hovered: renderThemeColorState(value.hovered, options),
4032
- pressed: renderThemeColorState(value.pressed, options),
4033
- selected: renderThemeColorState(value.selected, options),
4034
- disabled: renderThemeColorState(value.disabled, options)
2766
+ placeholder: state.placeholder
4035
2767
  };
4036
2768
  }
4037
- 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;
4038
2774
  const {
4039
- colorPalette,
4040
- baseBg,
4041
- blendMode
4042
- } = options, colorOptions = {
4043
- colorPalette,
4044
- bg: baseBg,
4045
- blendMode
4046
- };
4047
- return {
4048
- atrule: renderColorValue(value.atrule, colorOptions),
4049
- attrName: renderColorValue(value.attrName, colorOptions),
4050
- attrValue: renderColorValue(value.attrValue, colorOptions),
4051
- attribute: renderColorValue(value.attribute, colorOptions),
4052
- boolean: renderColorValue(value.boolean, colorOptions),
4053
- builtin: renderColorValue(value.builtin, colorOptions),
4054
- cdata: renderColorValue(value.cdata, colorOptions),
4055
- char: renderColorValue(value.char, colorOptions),
4056
- class: renderColorValue(value.class, colorOptions),
4057
- className: renderColorValue(value.className, colorOptions),
4058
- comment: renderColorValue(value.comment, colorOptions),
4059
- constant: renderColorValue(value.constant, colorOptions),
4060
- deleted: renderColorValue(value.deleted, colorOptions),
4061
- doctype: renderColorValue(value.doctype, colorOptions),
4062
- entity: renderColorValue(value.entity, colorOptions),
4063
- function: renderColorValue(value.function, colorOptions),
4064
- hexcode: renderColorValue(value.hexcode, colorOptions),
4065
- id: renderColorValue(value.id, colorOptions),
4066
- important: renderColorValue(value.important, colorOptions),
4067
- inserted: renderColorValue(value.inserted, colorOptions),
4068
- keyword: renderColorValue(value.keyword, colorOptions),
4069
- number: renderColorValue(value.number, colorOptions),
4070
- operator: renderColorValue(value.operator, colorOptions),
4071
- prolog: renderColorValue(value.prolog, colorOptions),
4072
- property: renderColorValue(value.property, colorOptions),
4073
- pseudoClass: renderColorValue(value.pseudoClass, colorOptions),
4074
- pseudoElement: renderColorValue(value.pseudoElement, colorOptions),
4075
- punctuation: renderColorValue(value.punctuation, colorOptions),
4076
- regex: renderColorValue(value.regex, colorOptions),
4077
- selector: renderColorValue(value.selector, colorOptions),
4078
- string: renderColorValue(value.string, colorOptions),
4079
- symbol: renderColorValue(value.symbol, colorOptions),
4080
- tag: renderColorValue(value.tag, colorOptions),
4081
- unit: renderColorValue(value.unit, colorOptions),
4082
- url: renderColorValue(value.url, colorOptions),
4083
- variable: renderColorValue(value.variable, colorOptions)
4084
- };
4085
- }
4086
- function buildTheme(config) {
4087
- const colorTheme = buildColorTheme(config), v2 = {
2775
+ avatar,
2776
+ button,
2777
+ color: color2,
2778
+ container,
2779
+ fonts: font,
2780
+ input,
2781
+ layer,
2782
+ media,
2783
+ radius,
2784
+ shadows: shadow,
2785
+ space,
2786
+ styles: style
2787
+ } = v0, v2 = {
4088
2788
  _version: 2,
4089
- avatar: config?.avatar ?? defaultThemeConfig.avatar,
4090
- button: config?.button ?? defaultThemeConfig.button,
4091
- card: config?.card ?? defaultThemeConfig.card,
4092
- // How colors are generated:
4093
- // 1. Merge custom tokens with default tokens
4094
- // 2. Generate tree of color keys (gray/500, black, white, etc.)
4095
- // 3. Apply mixing and render to hex values
4096
- // render(build(mergeWithDefaults()))
4097
- color: renderThemeColorSchemes(colorTheme, config),
4098
- container: config?.container ?? defaultThemeConfig.container,
4099
- font: config?.font ?? defaultThemeFonts,
4100
- input: config?.input ?? defaultThemeConfig.input,
4101
- layer: config?.layer ?? defaultThemeConfig.layer,
4102
- media: config?.media ?? defaultThemeConfig.media,
4103
- radius: config?.radius ?? defaultThemeConfig.radius,
4104
- shadow: config?.shadow ?? defaultThemeConfig.shadow,
4105
- space: config?.space ?? defaultThemeConfig.space,
4106
- 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(color2.light.transparent),
2801
+ default: themeColor_v0_v2(color2.light.default),
2802
+ neutral: themeColor_v0_v2(color2.light.transparent),
2803
+ primary: themeColor_v0_v2(color2.light.primary),
2804
+ suggest: themeColor_v0_v2(color2.light.primary),
2805
+ positive: themeColor_v0_v2(color2.light.positive),
2806
+ caution: themeColor_v0_v2(color2.light.caution),
2807
+ critical: themeColor_v0_v2(color2.light.critical)
2808
+ },
2809
+ dark: {
2810
+ transparent: themeColor_v0_v2(color2.dark.transparent),
2811
+ default: themeColor_v0_v2(color2.dark.default),
2812
+ neutral: themeColor_v0_v2(color2.dark.transparent),
2813
+ primary: themeColor_v0_v2(color2.dark.primary),
2814
+ suggest: themeColor_v0_v2(color2.dark.primary),
2815
+ positive: themeColor_v0_v2(color2.dark.positive),
2816
+ caution: themeColor_v0_v2(color2.dark.caution),
2817
+ critical: themeColor_v0_v2(color2.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
4107
2844
  };
4108
- return v2_v0(v2);
2845
+ return cache$2.set(v0, v2), v2;
4109
2846
  }
4110
- const cache = /* @__PURE__ */ new Map();
2847
+ const cache$1 = /* @__PURE__ */ new Map();
4111
2848
  function getScopedTheme(themeProp, scheme, tone) {
4112
2849
  const cachedTheme = _getCachedTheme(themeProp, scheme, tone);
4113
2850
  if (cachedTheme) return cachedTheme;
4114
- 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 = {
4115
2852
  sanity: {
4116
2853
  ...v0,
4117
2854
  color: color_v0,
@@ -4119,7 +2856,7 @@ function getScopedTheme(themeProp, scheme, tone) {
4119
2856
  v2: {
4120
2857
  ...v2,
4121
2858
  _resolved: !0,
4122
- color: color_v2,
2859
+ color: color_v2_9,
4123
2860
  layer: layer_v2
4124
2861
  }
4125
2862
  }
@@ -4127,17 +2864,71 @@ function getScopedTheme(themeProp, scheme, tone) {
4127
2864
  return _setCachedTheme(themeProp, scheme, tone, theme), theme;
4128
2865
  }
4129
2866
  function _getCachedTheme(rootTheme, scheme, tone) {
4130
- const schemeCache = cache.get(scheme);
2867
+ const schemeCache = cache$1.get(scheme);
4131
2868
  if (!schemeCache) return;
4132
2869
  const toneCache = schemeCache.get(tone);
4133
2870
  if (toneCache)
4134
2871
  return toneCache.get(rootTheme);
4135
2872
  }
4136
2873
  function _setCachedTheme(rootTheme, scheme, tone, theme) {
4137
- cache.has(scheme) || cache.set(scheme, /* @__PURE__ */ new Map());
4138
- const schemeCache = cache.get(scheme);
2874
+ cache$1.has(scheme) || cache$1.set(scheme, /* @__PURE__ */ new Map());
2875
+ const schemeCache = cache$1.get(scheme);
4139
2876
  schemeCache.has(tone) || schemeCache.set(tone, /* @__PURE__ */ new WeakMap()), schemeCache.get(tone).set(rootTheme, theme);
4140
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
+ }
2923
+ exports.THEME_COLOR_AVATAR_COLORS = v3_v2.THEME_COLOR_AVATAR_COLORS;
2924
+ exports.THEME_COLOR_BLEND_MODES = v3_v2.THEME_COLOR_BLEND_MODES;
2925
+ exports.THEME_COLOR_BUTTON_MODES = v3_v2.THEME_COLOR_BUTTON_MODES;
2926
+ exports.THEME_COLOR_CARD_TONES = v3_v2.THEME_COLOR_CARD_TONES;
2927
+ exports.THEME_COLOR_INPUT_MODES = v3_v2.THEME_COLOR_INPUT_MODES;
2928
+ exports.THEME_COLOR_INPUT_STATES = v3_v2.THEME_COLOR_INPUT_STATES;
2929
+ exports.THEME_COLOR_SCHEMES = v3_v2.THEME_COLOR_SCHEMES;
2930
+ exports.THEME_COLOR_STATES = v3_v2.THEME_COLOR_STATES;
2931
+ exports.THEME_COLOR_STATE_TONES = v3_v2.THEME_COLOR_STATE_TONES;
4141
2932
  exports.AVATAR_SIZE = AVATAR_SIZE;
4142
2933
  exports.COLOR_CONFIG_AVATAR_COLORS = COLOR_CONFIG_AVATAR_COLORS;
4143
2934
  exports.COLOR_CONFIG_BLEND_KEYS = COLOR_CONFIG_BLEND_KEYS;
@@ -4153,20 +2944,17 @@ exports.FONT_CODE_SIZE = FONT_CODE_SIZE;
4153
2944
  exports.FONT_HEADING_SIZE = FONT_HEADING_SIZE;
4154
2945
  exports.FONT_LABEL_SIZE = FONT_LABEL_SIZE;
4155
2946
  exports.FONT_TEXT_SIZE = FONT_TEXT_SIZE;
2947
+ exports.HUES = HUES;
4156
2948
  exports.RADIUS = RADIUS;
4157
2949
  exports.SHADOW = SHADOW;
4158
2950
  exports.SPACE = SPACE;
4159
- exports.THEME_COLOR_AVATAR_COLORS = THEME_COLOR_AVATAR_COLORS;
4160
- exports.THEME_COLOR_BLEND_MODES = THEME_COLOR_BLEND_MODES;
4161
- exports.THEME_COLOR_BUTTON_MODES = THEME_COLOR_BUTTON_MODES;
4162
- exports.THEME_COLOR_CARD_TONES = THEME_COLOR_CARD_TONES;
4163
- exports.THEME_COLOR_INPUT_MODES = THEME_COLOR_INPUT_MODES;
4164
- exports.THEME_COLOR_INPUT_STATES = THEME_COLOR_INPUT_STATES;
4165
- exports.THEME_COLOR_SCHEMES = THEME_COLOR_SCHEMES;
4166
- exports.THEME_COLOR_STATES = THEME_COLOR_STATES;
4167
- exports.THEME_COLOR_STATE_TONES = THEME_COLOR_STATE_TONES;
2951
+ exports.TINTS = TINTS;
2952
+ exports.buildColor_v3 = buildColor_v3;
4168
2953
  exports.buildTheme = buildTheme;
2954
+ exports.buildTheme_v3 = buildTheme_v3;
4169
2955
  exports.createColorTheme = createColorTheme;
2956
+ exports.defaultPalette = defaultPalette;
2957
+ exports.defaultTokens = defaultTokens;
4170
2958
  exports.getContrastRatio = getContrastRatio;
4171
2959
  exports.getScopedTheme = getScopedTheme;
4172
2960
  exports.getTheme_v2 = getTheme_v2;
@@ -4184,18 +2972,16 @@ exports.isColorOpacityValue = isColorOpacityValue;
4184
2972
  exports.isColorTintKey = isColorTintKey;
4185
2973
  exports.isColorTokenValue = isColorTokenValue;
4186
2974
  exports.isColorValue = isColorValue;
4187
- exports.is_v0 = is_v0;
4188
- exports.is_v2 = is_v2;
4189
2975
  exports.mix = mix;
4190
2976
  exports.multiply = multiply;
4191
2977
  exports.parseColor = parseColor;
4192
2978
  exports.parseTokenKey = parseTokenKey;
4193
2979
  exports.parseTokenValue = parseTokenValue;
2980
+ exports.renderColor = renderColor;
2981
+ exports.resolveTokens = resolveTokens;
4194
2982
  exports.rgbToHex = rgbToHex;
4195
2983
  exports.rgbToHsl = rgbToHsl;
4196
2984
  exports.rgba = rgba;
4197
2985
  exports.rgbaToRGBA = rgbaToRGBA;
4198
2986
  exports.screen = screen;
4199
- exports.v0_v2 = v0_v2;
4200
- exports.v2_v0 = v2_v0;
4201
2987
  //# sourceMappingURL=theme.js.map