@tenphi/tasty 0.0.0-snapshot.d9b45b3 → 0.0.0-snapshot.da07bc6

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 (382) hide show
  1. package/README.md +441 -363
  2. package/dist/babel-types-docs8f4c.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-DmSCYjYl.js +60 -0
  6. package/dist/chunks/build-config-DmSCYjYl.js.map +1 -0
  7. package/dist/chunks/collector-8w5r-xFl.js +210 -0
  8. package/dist/chunks/collector-8w5r-xFl.js.map +1 -0
  9. package/dist/chunks/config-engine-DjRv6Axa.js +272 -0
  10. package/dist/chunks/config-engine-DjRv6Axa.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-_UidGa56.js +910 -0
  14. package/dist/chunks/css-definitions-_UidGa56.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/{debug.js → chunks/debug-B6dZq3uH.js} +196 -147
  18. package/dist/chunks/debug-B6dZq3uH.js.map +1 -0
  19. package/dist/chunks/dsl-rgu6XQcD.js +1386 -0
  20. package/dist/chunks/dsl-rgu6XQcD.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DS1cEAMK.js +689 -0
  24. package/dist/chunks/react-runtime-DS1cEAMK.js.map +1 -0
  25. package/dist/chunks/runtime-engine-DFCZN1nF.js +2432 -0
  26. package/dist/chunks/runtime-engine-DFCZN1nF.js.map +1 -0
  27. package/dist/chunks/runtime-state-C8MzPjBR.js +152 -0
  28. package/dist/chunks/runtime-state-C8MzPjBR.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +60 -56
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-DoGrZPBB.js +5576 -0
  32. package/dist/chunks/style-engine-DoGrZPBB.js.map +1 -0
  33. package/dist/chunks/zero-engine-CiVidroC.js +310 -0
  34. package/dist/chunks/zero-engine-CiVidroC.js.map +1 -0
  35. package/dist/collector-CTU-nl0g.d.ts +164 -0
  36. package/dist/config-DDY7NlZ1.d.ts +1367 -0
  37. package/dist/core/index.d.ts +5 -34
  38. package/dist/core/index.js +9 -27
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-enN6b6o_.d.ts +1962 -0
  41. package/dist/index.d.ts +5 -51
  42. package/dist/index.js +11 -36
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-DSkVc6CD.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +2 -20
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +11 -8
  57. package/dist/ssr/astro-middleware.js +2 -14
  58. package/dist/ssr/astro-middleware.js.map +1 -1
  59. package/dist/ssr/astro.d.ts +37 -16
  60. package/dist/ssr/astro.js +197 -130
  61. package/dist/ssr/astro.js.map +1 -1
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -4
  65. package/dist/ssr/index.js +6 -6
  66. package/dist/ssr/index.js.map +1 -1
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +13 -10
  71. package/dist/ssr/next.js +32 -46
  72. package/dist/ssr/next.js.map +1 -1
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -3
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +1 -2
  77. package/dist/static/inject.js.map +1 -1
  78. package/dist/types-DJEM_BOJ.d.ts +1567 -0
  79. package/dist/zero/babel.d.ts +12 -121
  80. package/dist/zero/babel.js +126 -149
  81. package/dist/zero/babel.js.map +1 -1
  82. package/dist/zero/index.d.ts +136 -3
  83. package/dist/zero/index.js +25 -3
  84. package/dist/zero/index.js.map +1 -0
  85. package/dist/zero/next.d.ts +4 -5
  86. package/dist/zero/next.js +3 -38
  87. package/dist/zero/next.js.map +1 -1
  88. package/docs/README.md +23 -12
  89. package/docs/adoption.md +72 -37
  90. package/docs/ai-agents.md +258 -0
  91. package/docs/comparison.md +83 -54
  92. package/docs/configuration.md +712 -81
  93. package/docs/debug.md +39 -24
  94. package/docs/design-system.md +174 -41
  95. package/docs/dsl.md +668 -197
  96. package/docs/getting-started.md +132 -52
  97. package/docs/injector.md +164 -73
  98. package/docs/methodology.md +107 -50
  99. package/docs/migration-v3.md +285 -0
  100. package/docs/pipeline.md +768 -0
  101. package/docs/plugins.md +333 -0
  102. package/docs/react-api.md +746 -0
  103. package/docs/runtime-benchmarks.md +388 -0
  104. package/docs/ssr.md +312 -111
  105. package/docs/styles.md +186 -47
  106. package/docs/tasty-static.md +298 -118
  107. package/package.json +146 -40
  108. package/tasty.config.ts +6 -0
  109. package/dist/_virtual/_rolldown/runtime.js +0 -7
  110. package/dist/chunks/cacheKey.d.ts +0 -1
  111. package/dist/chunks/cacheKey.js +0 -77
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -258
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/index.d.ts +0 -1
  117. package/dist/chunks/renderChunk.d.ts +0 -1
  118. package/dist/chunks/renderChunk.js +0 -59
  119. package/dist/chunks/renderChunk.js.map +0 -1
  120. package/dist/compute-styles.d.ts +0 -31
  121. package/dist/compute-styles.js +0 -335
  122. package/dist/compute-styles.js.map +0 -1
  123. package/dist/config.d.ts +0 -367
  124. package/dist/config.js +0 -502
  125. package/dist/config.js.map +0 -1
  126. package/dist/counter-style/index.js +0 -51
  127. package/dist/counter-style/index.js.map +0 -1
  128. package/dist/debug.d.ts +0 -89
  129. package/dist/debug.js.map +0 -1
  130. package/dist/font-face/index.js +0 -63
  131. package/dist/font-face/index.js.map +0 -1
  132. package/dist/hooks/index.d.ts +0 -7
  133. package/dist/hooks/useCounterStyle.d.ts +0 -52
  134. package/dist/hooks/useCounterStyle.js +0 -45
  135. package/dist/hooks/useCounterStyle.js.map +0 -1
  136. package/dist/hooks/useFontFace.d.ts +0 -45
  137. package/dist/hooks/useFontFace.js +0 -68
  138. package/dist/hooks/useFontFace.js.map +0 -1
  139. package/dist/hooks/useGlobalStyles.d.ts +0 -41
  140. package/dist/hooks/useGlobalStyles.js +0 -79
  141. package/dist/hooks/useGlobalStyles.js.map +0 -1
  142. package/dist/hooks/useKeyframes.d.ts +0 -58
  143. package/dist/hooks/useKeyframes.js +0 -42
  144. package/dist/hooks/useKeyframes.js.map +0 -1
  145. package/dist/hooks/useProperty.d.ts +0 -81
  146. package/dist/hooks/useProperty.js +0 -98
  147. package/dist/hooks/useProperty.js.map +0 -1
  148. package/dist/hooks/useRawCSS.d.ts +0 -16
  149. package/dist/hooks/useRawCSS.js +0 -43
  150. package/dist/hooks/useRawCSS.js.map +0 -1
  151. package/dist/hooks/useStyles.d.ts +0 -40
  152. package/dist/hooks/useStyles.js +0 -29
  153. package/dist/hooks/useStyles.js.map +0 -1
  154. package/dist/injector/index.d.ts +0 -182
  155. package/dist/injector/index.js +0 -185
  156. package/dist/injector/index.js.map +0 -1
  157. package/dist/injector/injector.d.ts +0 -193
  158. package/dist/injector/injector.js +0 -564
  159. package/dist/injector/injector.js.map +0 -1
  160. package/dist/injector/sheet-manager.d.ts +0 -132
  161. package/dist/injector/sheet-manager.js +0 -698
  162. package/dist/injector/sheet-manager.js.map +0 -1
  163. package/dist/injector/types.d.ts +0 -228
  164. package/dist/keyframes/index.js +0 -206
  165. package/dist/keyframes/index.js.map +0 -1
  166. package/dist/parser/classify.js +0 -319
  167. package/dist/parser/classify.js.map +0 -1
  168. package/dist/parser/const.js +0 -60
  169. package/dist/parser/const.js.map +0 -1
  170. package/dist/parser/lru.js +0 -109
  171. package/dist/parser/lru.js.map +0 -1
  172. package/dist/parser/parser.d.ts +0 -25
  173. package/dist/parser/parser.js +0 -115
  174. package/dist/parser/parser.js.map +0 -1
  175. package/dist/parser/tokenizer.js +0 -69
  176. package/dist/parser/tokenizer.js.map +0 -1
  177. package/dist/parser/types.d.ts +0 -51
  178. package/dist/parser/types.js +0 -46
  179. package/dist/parser/types.js.map +0 -1
  180. package/dist/pipeline/conditions.d.ts +0 -134
  181. package/dist/pipeline/conditions.js +0 -406
  182. package/dist/pipeline/conditions.js.map +0 -1
  183. package/dist/pipeline/exclusive.js +0 -230
  184. package/dist/pipeline/exclusive.js.map +0 -1
  185. package/dist/pipeline/index.d.ts +0 -55
  186. package/dist/pipeline/index.js +0 -708
  187. package/dist/pipeline/index.js.map +0 -1
  188. package/dist/pipeline/materialize.js +0 -1103
  189. package/dist/pipeline/materialize.js.map +0 -1
  190. package/dist/pipeline/parseStateKey.d.ts +0 -15
  191. package/dist/pipeline/parseStateKey.js +0 -446
  192. package/dist/pipeline/parseStateKey.js.map +0 -1
  193. package/dist/pipeline/simplify.js +0 -515
  194. package/dist/pipeline/simplify.js.map +0 -1
  195. package/dist/pipeline/warnings.js +0 -18
  196. package/dist/pipeline/warnings.js.map +0 -1
  197. package/dist/plugins/index.d.ts +0 -2
  198. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  199. package/dist/plugins/okhsl-plugin.js +0 -97
  200. package/dist/plugins/okhsl-plugin.js.map +0 -1
  201. package/dist/plugins/types.d.ts +0 -76
  202. package/dist/properties/index.js +0 -222
  203. package/dist/properties/index.js.map +0 -1
  204. package/dist/properties/property-type-resolver.d.ts +0 -24
  205. package/dist/properties/property-type-resolver.js +0 -90
  206. package/dist/properties/property-type-resolver.js.map +0 -1
  207. package/dist/rsc-cache.js +0 -69
  208. package/dist/rsc-cache.js.map +0 -1
  209. package/dist/ssr/async-storage.d.ts +0 -17
  210. package/dist/ssr/async-storage.js +0 -34
  211. package/dist/ssr/async-storage.js.map +0 -1
  212. package/dist/ssr/collect-auto-properties.js +0 -39
  213. package/dist/ssr/collect-auto-properties.js.map +0 -1
  214. package/dist/ssr/collector.d.ts +0 -102
  215. package/dist/ssr/collector.js +0 -219
  216. package/dist/ssr/collector.js.map +0 -1
  217. package/dist/ssr/format-global-rules.js +0 -22
  218. package/dist/ssr/format-global-rules.js.map +0 -1
  219. package/dist/ssr/format-keyframes.js +0 -69
  220. package/dist/ssr/format-keyframes.js.map +0 -1
  221. package/dist/ssr/format-property.js +0 -49
  222. package/dist/ssr/format-property.js.map +0 -1
  223. package/dist/ssr/format-rules.js +0 -73
  224. package/dist/ssr/format-rules.js.map +0 -1
  225. package/dist/ssr/hydrate.d.ts +0 -22
  226. package/dist/ssr/hydrate.js +0 -49
  227. package/dist/ssr/hydrate.js.map +0 -1
  228. package/dist/ssr/ssr-collector-ref.js +0 -12
  229. package/dist/ssr/ssr-collector-ref.js.map +0 -1
  230. package/dist/states/index.d.ts +0 -49
  231. package/dist/states/index.js +0 -170
  232. package/dist/states/index.js.map +0 -1
  233. package/dist/static/tastyStatic.d.ts +0 -46
  234. package/dist/static/tastyStatic.js +0 -30
  235. package/dist/static/tastyStatic.js.map +0 -1
  236. package/dist/static/types.d.ts +0 -49
  237. package/dist/static/types.js +0 -24
  238. package/dist/static/types.js.map +0 -1
  239. package/dist/styles/border.d.ts +0 -25
  240. package/dist/styles/border.js +0 -120
  241. package/dist/styles/border.js.map +0 -1
  242. package/dist/styles/color.d.ts +0 -14
  243. package/dist/styles/color.js +0 -26
  244. package/dist/styles/color.js.map +0 -1
  245. package/dist/styles/const.js +0 -17
  246. package/dist/styles/const.js.map +0 -1
  247. package/dist/styles/createStyle.js +0 -79
  248. package/dist/styles/createStyle.js.map +0 -1
  249. package/dist/styles/dimension.js +0 -109
  250. package/dist/styles/dimension.js.map +0 -1
  251. package/dist/styles/directional.js +0 -133
  252. package/dist/styles/directional.js.map +0 -1
  253. package/dist/styles/display.d.ts +0 -30
  254. package/dist/styles/display.js +0 -73
  255. package/dist/styles/display.js.map +0 -1
  256. package/dist/styles/fade.d.ts +0 -15
  257. package/dist/styles/fade.js +0 -62
  258. package/dist/styles/fade.js.map +0 -1
  259. package/dist/styles/fill.d.ts +0 -42
  260. package/dist/styles/fill.js +0 -51
  261. package/dist/styles/fill.js.map +0 -1
  262. package/dist/styles/flow.d.ts +0 -16
  263. package/dist/styles/flow.js +0 -12
  264. package/dist/styles/flow.js.map +0 -1
  265. package/dist/styles/gap.d.ts +0 -31
  266. package/dist/styles/gap.js +0 -38
  267. package/dist/styles/gap.js.map +0 -1
  268. package/dist/styles/height.d.ts +0 -17
  269. package/dist/styles/height.js +0 -19
  270. package/dist/styles/height.js.map +0 -1
  271. package/dist/styles/index.d.ts +0 -1
  272. package/dist/styles/index.js +0 -8
  273. package/dist/styles/index.js.map +0 -1
  274. package/dist/styles/inset.d.ts +0 -24
  275. package/dist/styles/inset.js +0 -34
  276. package/dist/styles/inset.js.map +0 -1
  277. package/dist/styles/list.d.ts +0 -16
  278. package/dist/styles/list.js +0 -100
  279. package/dist/styles/list.js.map +0 -1
  280. package/dist/styles/margin.d.ts +0 -24
  281. package/dist/styles/margin.js +0 -32
  282. package/dist/styles/margin.js.map +0 -1
  283. package/dist/styles/outline.d.ts +0 -29
  284. package/dist/styles/outline.js +0 -55
  285. package/dist/styles/outline.js.map +0 -1
  286. package/dist/styles/padding.d.ts +0 -24
  287. package/dist/styles/padding.js +0 -32
  288. package/dist/styles/padding.js.map +0 -1
  289. package/dist/styles/placement.d.ts +0 -37
  290. package/dist/styles/placement.js +0 -74
  291. package/dist/styles/placement.js.map +0 -1
  292. package/dist/styles/predefined.d.ts +0 -71
  293. package/dist/styles/predefined.js +0 -237
  294. package/dist/styles/predefined.js.map +0 -1
  295. package/dist/styles/preset.d.ts +0 -52
  296. package/dist/styles/preset.js +0 -127
  297. package/dist/styles/preset.js.map +0 -1
  298. package/dist/styles/radius.d.ts +0 -12
  299. package/dist/styles/radius.js +0 -83
  300. package/dist/styles/radius.js.map +0 -1
  301. package/dist/styles/scrollMargin.d.ts +0 -24
  302. package/dist/styles/scrollMargin.js +0 -32
  303. package/dist/styles/scrollMargin.js.map +0 -1
  304. package/dist/styles/scrollbar.d.ts +0 -25
  305. package/dist/styles/scrollbar.js +0 -51
  306. package/dist/styles/scrollbar.js.map +0 -1
  307. package/dist/styles/shadow.d.ts +0 -14
  308. package/dist/styles/shadow.js +0 -25
  309. package/dist/styles/shadow.js.map +0 -1
  310. package/dist/styles/shared.js +0 -17
  311. package/dist/styles/shared.js.map +0 -1
  312. package/dist/styles/transition.d.ts +0 -14
  313. package/dist/styles/transition.js +0 -159
  314. package/dist/styles/transition.js.map +0 -1
  315. package/dist/styles/types.d.ts +0 -564
  316. package/dist/styles/width.d.ts +0 -17
  317. package/dist/styles/width.js +0 -19
  318. package/dist/styles/width.js.map +0 -1
  319. package/dist/tasty.d.ts +0 -134
  320. package/dist/tasty.js +0 -243
  321. package/dist/tasty.js.map +0 -1
  322. package/dist/types.d.ts +0 -184
  323. package/dist/utils/cache-wrapper.js +0 -21
  324. package/dist/utils/cache-wrapper.js.map +0 -1
  325. package/dist/utils/case-converter.js +0 -8
  326. package/dist/utils/case-converter.js.map +0 -1
  327. package/dist/utils/color-math.d.ts +0 -46
  328. package/dist/utils/color-math.js +0 -749
  329. package/dist/utils/color-math.js.map +0 -1
  330. package/dist/utils/color-space.d.ts +0 -5
  331. package/dist/utils/color-space.js +0 -228
  332. package/dist/utils/color-space.js.map +0 -1
  333. package/dist/utils/colors.d.ts +0 -5
  334. package/dist/utils/colors.js +0 -10
  335. package/dist/utils/colors.js.map +0 -1
  336. package/dist/utils/css-types.d.ts +0 -7
  337. package/dist/utils/dotize.d.ts +0 -26
  338. package/dist/utils/dotize.js +0 -122
  339. package/dist/utils/dotize.js.map +0 -1
  340. package/dist/utils/filter-base-props.d.ts +0 -15
  341. package/dist/utils/filter-base-props.js +0 -45
  342. package/dist/utils/filter-base-props.js.map +0 -1
  343. package/dist/utils/get-display-name.d.ts +0 -7
  344. package/dist/utils/get-display-name.js +0 -10
  345. package/dist/utils/get-display-name.js.map +0 -1
  346. package/dist/utils/has-keys.js +0 -13
  347. package/dist/utils/has-keys.js.map +0 -1
  348. package/dist/utils/is-dev-env.js +0 -19
  349. package/dist/utils/is-dev-env.js.map +0 -1
  350. package/dist/utils/is-valid-element-type.js +0 -15
  351. package/dist/utils/is-valid-element-type.js.map +0 -1
  352. package/dist/utils/merge-styles.js.map +0 -1
  353. package/dist/utils/mod-attrs.d.ts +0 -6
  354. package/dist/utils/mod-attrs.js +0 -20
  355. package/dist/utils/mod-attrs.js.map +0 -1
  356. package/dist/utils/process-tokens.d.ts +0 -17
  357. package/dist/utils/process-tokens.js +0 -83
  358. package/dist/utils/process-tokens.js.map +0 -1
  359. package/dist/utils/resolve-recipes.d.ts +0 -17
  360. package/dist/utils/resolve-recipes.js +0 -146
  361. package/dist/utils/resolve-recipes.js.map +0 -1
  362. package/dist/utils/selector-transform.js +0 -32
  363. package/dist/utils/selector-transform.js.map +0 -1
  364. package/dist/utils/string.js +0 -8
  365. package/dist/utils/string.js.map +0 -1
  366. package/dist/utils/styles.d.ts +0 -99
  367. package/dist/utils/styles.js +0 -220
  368. package/dist/utils/styles.js.map +0 -1
  369. package/dist/utils/typography.d.ts +0 -47
  370. package/dist/utils/typography.js +0 -51
  371. package/dist/utils/typography.js.map +0 -1
  372. package/dist/utils/warnings.d.ts +0 -16
  373. package/dist/utils/warnings.js +0 -16
  374. package/dist/utils/warnings.js.map +0 -1
  375. package/dist/zero/css-writer.d.ts +0 -45
  376. package/dist/zero/css-writer.js +0 -73
  377. package/dist/zero/css-writer.js.map +0 -1
  378. package/dist/zero/extractor.d.ts +0 -24
  379. package/dist/zero/extractor.js +0 -266
  380. package/dist/zero/extractor.js.map +0 -1
  381. package/docs/PIPELINE.md +0 -519
  382. package/docs/runtime.md +0 -575
@@ -0,0 +1,1386 @@
1
+ import { a as warnOnceDev, o as isDevEnv } from "./shared-utils-y-HjvPN4.js";
2
+ //#region src/parser/const.ts
3
+ const VALUE_KEYWORDS = /* @__PURE__ */ new Set([
4
+ "auto",
5
+ "max-content",
6
+ "min-content",
7
+ "fit-content",
8
+ "stretch",
9
+ "initial",
10
+ "inherit",
11
+ "revert",
12
+ "unset",
13
+ "revert-layer"
14
+ ]);
15
+ const CSS_WIDE_KEYWORDS = /* @__PURE__ */ new Set([
16
+ "initial",
17
+ "inherit",
18
+ "revert",
19
+ "unset",
20
+ "revert-layer"
21
+ ]);
22
+ const DERIVED_COLOR_FUNCS_LIST = [
23
+ "color-mix",
24
+ "color-contrast",
25
+ "contrast-color",
26
+ "light-dark"
27
+ ];
28
+ const DERIVED_COLOR_FUNCS = new Set(DERIVED_COLOR_FUNCS_LIST);
29
+ const COLOR_FUNCS = /* @__PURE__ */ new Set([
30
+ "rgb",
31
+ "rgba",
32
+ "hsl",
33
+ "hsla",
34
+ "hwb",
35
+ "lab",
36
+ "lch",
37
+ "oklab",
38
+ "oklch",
39
+ "color",
40
+ "device-cmyk",
41
+ "gray",
42
+ ...DERIVED_COLOR_FUNCS_LIST
43
+ ]);
44
+ const RE_FUNC_CALL = /^([a-z][a-z0-9-]*)\((.+)\)$/i;
45
+ const RE_UNIT_NUM = /^[+-]?(?:\d*\.\d+|\d+)([a-z][a-z0-9]*)$/;
46
+ const RE_NUMBER = /^[+-]?(?:\d*\.\d+|\d+)$/;
47
+ const RE_HEX = /^(?:[0-9a-f]{3,4}|[0-9a-f]{6}(?:[0-9a-f]{2})?)$/;
48
+ const RE_RAW_UNIT = /^([+-]?(?:\d*\.\d+|\d+))([a-z%]+)$/;
49
+ const CANONICAL_FUNC_CASE = /* @__PURE__ */ new Map([
50
+ ["translatex", "translateX"],
51
+ ["translatey", "translateY"],
52
+ ["translatez", "translateZ"],
53
+ ["scalex", "scaleX"],
54
+ ["scaley", "scaleY"],
55
+ ["scalez", "scaleZ"],
56
+ ["rotatex", "rotateX"],
57
+ ["rotatey", "rotateY"],
58
+ ["rotatez", "rotateZ"],
59
+ ["skewx", "skewX"],
60
+ ["skewy", "skewY"]
61
+ ]);
62
+ function canonicalFuncName(lowered) {
63
+ return CANONICAL_FUNC_CASE.get(lowered) ?? lowered;
64
+ }
65
+ //#endregion
66
+ //#region src/utils/string.ts
67
+ function toSnakeCase(str) {
68
+ return str.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
69
+ }
70
+ function normalizeDslName(name) {
71
+ if (!name) return name;
72
+ const first = name[0];
73
+ const lower = first.toLowerCase();
74
+ return lower === first ? name : lower + name.slice(1);
75
+ }
76
+ const RE_DSL_IDENTIFIER = /(\$\$?|##?|--)([a-zA-Z_][a-zA-Z0-9_-]*)/g;
77
+ function foldDslCase(src) {
78
+ const folded = src.toLowerCase();
79
+ if (folded === src || !src.includes("$") && !src.includes("#") && !src.includes("--")) return folded;
80
+ RE_DSL_IDENTIFIER.lastIndex = 0;
81
+ let out = "";
82
+ let last = 0;
83
+ let match;
84
+ while (match = RE_DSL_IDENTIFIER.exec(src)) {
85
+ const [whole, prefix, body] = match;
86
+ out += src.slice(last, match.index).toLowerCase();
87
+ out += prefix + (prefix === "--" ? body : prefix[0] === "#" && RE_HEX.test(body.toLowerCase()) ? body.toLowerCase() : normalizeDslName(body));
88
+ last = match.index + whole.length;
89
+ }
90
+ return out + src.slice(last).toLowerCase();
91
+ }
92
+ //#endregion
93
+ //#region src/utils/color-math.ts
94
+ const OKLab_to_LMS_ab = [
95
+ [.3963377773761749, .2158037573099136],
96
+ [-.1055613458156586, -.0638541728258133],
97
+ [-.0894841775298119, -1.2914855480194092]
98
+ ];
99
+ const LMS_to_linear_sRGB_M = [
100
+ [
101
+ 4.076741636075959,
102
+ -3.307711539258062,
103
+ .2309699031821041
104
+ ],
105
+ [
106
+ -1.2684379732850313,
107
+ 2.6097573492876878,
108
+ -.3413193760026569
109
+ ],
110
+ [
111
+ -.004196076138675526,
112
+ -.703418617935936,
113
+ 1.7076146940746113
114
+ ]
115
+ ];
116
+ const OKLab_to_linear_sRGB_coefficients = [
117
+ [[-1.8817030993265873, -.8093650129914302], [
118
+ 1.19086277,
119
+ 1.76576728,
120
+ .59662641,
121
+ .75515197,
122
+ .56771245
123
+ ]],
124
+ [[1.8144407988010998, -1.194452667805235], [
125
+ .73956515,
126
+ -.45954404,
127
+ .08285427,
128
+ .1254107,
129
+ .14503204
130
+ ]],
131
+ [[.13110757611180954, 1.813339709266608], [
132
+ 1.35733652,
133
+ -.00915799,
134
+ -1.1513021,
135
+ -.50559606,
136
+ .00692167
137
+ ]]
138
+ ];
139
+ const dotXY = (vector, x, y) => vector[0] * x + vector[1] * y;
140
+ const dotXYZ = (matrix, x, y, z) => matrix[0] * x + matrix[1] * y + matrix[2] * z;
141
+ const INV_GAMMA = 1 / 2.4;
142
+ function srgbLinearToGamma(val) {
143
+ const sign = val < 0 ? -1 : 1;
144
+ const abs = Math.abs(val);
145
+ return abs > .0031308 ? sign * (1.055 * abs ** INV_GAMMA - .055) : 12.92 * val;
146
+ }
147
+ const TAU = 2 * Math.PI;
148
+ const K1 = .206;
149
+ const K2 = .03;
150
+ const K3 = 1.206 / 1.03;
151
+ const clamp$1 = (value, min, max) => Math.max(Math.min(value, max), min);
152
+ const constrainAngle = (angle) => (angle % 360 + 360) % 360;
153
+ const toe = (x) => .5 * (K3 * x - K1 + Math.sqrt((K3 * x - K1) * (K3 * x - K1) + 4 * K2 * K3 * x));
154
+ const toeInv = (x) => (x ** 2 + K1 * x) / (K3 * (x + K2));
155
+ const OKHST_REF_EPS = .05;
156
+ function yToL(y) {
157
+ return toe(Math.cbrt(Math.max(0, y)));
158
+ }
159
+ function yFromTone(t, eps = OKHST_REF_EPS) {
160
+ const den = Math.log(1 + eps) - Math.log(eps);
161
+ return Math.exp(t / 100 * den + Math.log(eps)) - eps;
162
+ }
163
+ function fromTone(t, eps = OKHST_REF_EPS) {
164
+ return yToL(yFromTone(t, eps));
165
+ }
166
+ const oklabToLinearSrgb = (lab) => {
167
+ const L = lab[0];
168
+ const a = lab[1];
169
+ const b = lab[2];
170
+ const l_ = L + .3963377773761749 * a + .2158037573099136 * b;
171
+ const m_ = L - .1055613458156586 * a - .0638541728258133 * b;
172
+ const s_ = L - .0894841775298119 * a - 1.2914855480194092 * b;
173
+ const l = l_ * l_ * l_;
174
+ const m = m_ * m_ * m_;
175
+ const s = s_ * s_ * s_;
176
+ return [
177
+ 4.076741636075959 * l - 3.307711539258062 * m + .2309699031821041 * s,
178
+ -1.2684379732850313 * l + 2.6097573492876878 * m - .3413193760026569 * s,
179
+ -.004196076138675526 * l - .703418617935936 * m + 1.7076146940746113 * s
180
+ ];
181
+ };
182
+ const computeMaxSaturationOKLC = (a, b) => {
183
+ const okCoeff = OKLab_to_linear_sRGB_coefficients;
184
+ const lmsToRgb = LMS_to_linear_sRGB_M;
185
+ let chnlCoeff;
186
+ let chnlLMS;
187
+ if (dotXY(okCoeff[0][0], a, b) > 1) {
188
+ chnlCoeff = okCoeff[0][1];
189
+ chnlLMS = lmsToRgb[0];
190
+ } else if (dotXY(okCoeff[1][0], a, b) > 1) {
191
+ chnlCoeff = okCoeff[1][1];
192
+ chnlLMS = lmsToRgb[1];
193
+ } else {
194
+ chnlCoeff = okCoeff[2][1];
195
+ chnlLMS = lmsToRgb[2];
196
+ }
197
+ const [k0, k1, k2, k3, k4] = chnlCoeff;
198
+ const [wl, wm, ws] = chnlLMS;
199
+ let sat = k0 + k1 * a + k2 * b + k3 * (a * a) + k4 * a * b;
200
+ const kl = dotXY(OKLab_to_LMS_ab[0], a, b);
201
+ const km = dotXY(OKLab_to_LMS_ab[1], a, b);
202
+ const ks = dotXY(OKLab_to_LMS_ab[2], a, b);
203
+ const l_ = 1 + sat * kl;
204
+ const m_ = 1 + sat * km;
205
+ const s_ = 1 + sat * ks;
206
+ const l = l_ ** 3;
207
+ const m = m_ ** 3;
208
+ const s = s_ ** 3;
209
+ const lds = 3 * kl * (l_ * l_);
210
+ const mds = 3 * km * (m_ * m_);
211
+ const sds = 3 * ks * (s_ * s_);
212
+ const lds2 = 6 * (kl * kl) * l_;
213
+ const mds2 = 6 * (km * km) * m_;
214
+ const sds2 = 6 * (ks * ks) * s_;
215
+ const f = wl * l + wm * m + ws * s;
216
+ const f1 = wl * lds + wm * mds + ws * sds;
217
+ const f2 = wl * lds2 + wm * mds2 + ws * sds2;
218
+ sat = sat - f * f1 / (f1 * f1 - .5 * f * f2);
219
+ return sat;
220
+ };
221
+ const findCuspOKLCH = (a, b) => {
222
+ const S_cusp = computeMaxSaturationOKLC(a, b);
223
+ const lab = [
224
+ 1,
225
+ S_cusp * a,
226
+ S_cusp * b
227
+ ];
228
+ const rgb_at_max = oklabToLinearSrgb(lab);
229
+ const L_cusp = Math.cbrt(1 / Math.max(Math.max(rgb_at_max[0], rgb_at_max[1]), Math.max(rgb_at_max[2], 0)));
230
+ return [L_cusp, L_cusp * S_cusp];
231
+ };
232
+ const findGamutIntersectionOKLCH = (a, b, l1, c1, l0, cusp) => {
233
+ const lmsToRgb = LMS_to_linear_sRGB_M;
234
+ let t;
235
+ if ((l1 - l0) * cusp[1] - (cusp[0] - l0) * c1 <= 0) {
236
+ const denom = c1 * cusp[0] + cusp[1] * (l0 - l1);
237
+ t = denom === 0 ? 0 : cusp[1] * l0 / denom;
238
+ } else {
239
+ const denom = c1 * (cusp[0] - 1) + cusp[1] * (l0 - l1);
240
+ t = denom === 0 ? 0 : cusp[1] * (l0 - 1) / denom;
241
+ const dl = l1 - l0;
242
+ const dc = c1;
243
+ const kl = dotXY(OKLab_to_LMS_ab[0], a, b);
244
+ const km = dotXY(OKLab_to_LMS_ab[1], a, b);
245
+ const ks = dotXY(OKLab_to_LMS_ab[2], a, b);
246
+ const ldt_ = dl + dc * kl;
247
+ const mdt_ = dl + dc * km;
248
+ const sdt_ = dl + dc * ks;
249
+ const L = l0 * (1 - t) + t * l1;
250
+ const C = t * c1;
251
+ const l_ = L + C * kl;
252
+ const m_ = L + C * km;
253
+ const s_ = L + C * ks;
254
+ const l = l_ ** 3;
255
+ const m = m_ ** 3;
256
+ const s = s_ ** 3;
257
+ const ldt = 3 * ldt_ * l_ * l_;
258
+ const mdt = 3 * mdt_ * m_ * m_;
259
+ const sdt = 3 * sdt_ * s_ * s_;
260
+ const ldt2 = 6 * ldt_ * ldt_ * l_;
261
+ const mdt2 = 6 * mdt_ * mdt_ * m_;
262
+ const sdt2 = 6 * sdt_ * sdt_ * s_;
263
+ let correction = Number.MAX_VALUE;
264
+ for (const matrix of lmsToRgb) {
265
+ const value = dotXYZ(matrix, l, m, s) - 1;
266
+ const slope = dotXYZ(matrix, ldt, mdt, sdt);
267
+ const slope2 = dotXYZ(matrix, ldt2, mdt2, sdt2);
268
+ const u = slope / (slope * slope - .5 * value * slope2);
269
+ if (u >= 0) correction = Math.min(correction, -value * u);
270
+ }
271
+ t += correction;
272
+ }
273
+ return t;
274
+ };
275
+ const computeSt = (cusp) => [cusp[1] / cusp[0], cusp[1] / (1 - cusp[0])];
276
+ const computeStMid = (a, b) => [.11516993 + 1 / (7.4477897 + 4.1590124 * b + a * (-2.19557347 + 1.75198401 * b + a * (-2.13704948 - 10.02301043 * b + a * (-4.24894561 + 5.38770819 * b + 4.69891013 * a)))), .11239642 + 1 / (1.6132032 - .68124379 * b + a * (.40370612 + .90148123 * b + a * (-.27087943 + .6122399 * b + a * (.00299215 - .45399568 * b - .14661872 * a))))];
277
+ const getCs = (L, a, b, cusp) => {
278
+ const cMax = findGamutIntersectionOKLCH(a, b, L, 1, L, cusp);
279
+ const stMax = computeSt(cusp);
280
+ const k = cMax / Math.min(L * stMax[0], (1 - L) * stMax[1]);
281
+ const stMid = computeStMid(a, b);
282
+ let ca = L * stMid[0];
283
+ let cb = (1 - L) * stMid[1];
284
+ const cMid = .9 * k * Math.sqrt(Math.sqrt(1 / (1 / ca ** 4 + 1 / cb ** 4)));
285
+ ca = L * .4;
286
+ cb = (1 - L) * .8;
287
+ return [
288
+ Math.sqrt(1 / (1 / ca ** 2 + 1 / cb ** 2)),
289
+ cMid,
290
+ cMax
291
+ ];
292
+ };
293
+ const okhslToOklab = (hsl) => {
294
+ let h = hsl[0];
295
+ const s = hsl[1];
296
+ const l = hsl[2];
297
+ const L = toeInv(l);
298
+ let a = 0;
299
+ let b = 0;
300
+ h = constrainAngle(h) / 360;
301
+ if (L !== 0 && L !== 1 && s !== 0) {
302
+ const a_ = Math.cos(TAU * h);
303
+ const b_ = Math.sin(TAU * h);
304
+ const cusp = findCuspOKLCH(a_, b_);
305
+ const [c0, cMid, cMax] = getCs(L, a_, b_, cusp);
306
+ const mid = .8;
307
+ const midInv = 1.25;
308
+ let t, k0, k1, k2;
309
+ if (s < mid) {
310
+ t = midInv * s;
311
+ k0 = 0;
312
+ k1 = mid * c0;
313
+ k2 = 1 - k1 / cMid;
314
+ } else {
315
+ t = 5 * (s - .8);
316
+ k0 = cMid;
317
+ k1 = .2 * cMid ** 2 * 1.25 ** 2 / c0;
318
+ k2 = 1 - k1 / (cMax - cMid);
319
+ }
320
+ const c = k0 + t * k1 / (1 - k2 * t);
321
+ a = c * a_;
322
+ b = c * b_;
323
+ }
324
+ return [
325
+ L,
326
+ a,
327
+ b
328
+ ];
329
+ };
330
+ function hslToRgbValues(h, s, l) {
331
+ const a = s * Math.min(l, 1 - l);
332
+ const f = (n) => {
333
+ const k = (n + h / 30) % 12;
334
+ return l - a * Math.max(-1, Math.min(k - 3, 9 - k, 1));
335
+ };
336
+ return [
337
+ f(0) * 255,
338
+ f(8) * 255,
339
+ f(4) * 255
340
+ ];
341
+ }
342
+ function okhslToSrgb(h, s, l) {
343
+ const oklab = okhslToOklab([
344
+ h,
345
+ s,
346
+ l
347
+ ]);
348
+ const linearRGB = oklabToLinearSrgb(oklab);
349
+ return [
350
+ clamp$1(srgbLinearToGamma(linearRGB[0]), 0, 1),
351
+ clamp$1(srgbLinearToGamma(linearRGB[1]), 0, 1),
352
+ clamp$1(srgbLinearToGamma(linearRGB[2]), 0, 1)
353
+ ];
354
+ }
355
+ function okhstToSrgb(h, s, t) {
356
+ return okhslToSrgb(h, clamp$1(s, 0, 1), clamp$1(fromTone(t * 100), 0, 1));
357
+ }
358
+ function oklchToRgbValues(L, C, H) {
359
+ const hRad = H * Math.PI / 180;
360
+ const a = C * Math.cos(hRad);
361
+ const b = C * Math.sin(hRad);
362
+ const linear = oklabToLinearSrgb([
363
+ L,
364
+ a,
365
+ b
366
+ ]);
367
+ return [
368
+ clamp$1(srgbLinearToGamma(linear[0]), 0, 1) * 255,
369
+ clamp$1(srgbLinearToGamma(linear[1]), 0, 1) * 255,
370
+ clamp$1(srgbLinearToGamma(linear[2]), 0, 1) * 255
371
+ ];
372
+ }
373
+ let _namedColorHex = null;
374
+ function getNamedColorHex() {
375
+ if (_namedColorHex) return _namedColorHex;
376
+ const names = "aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen".split(" ");
377
+ const hex = "f0f8fffaebd700ffff7fffd4f0fffff5f5dcffe4c4000000ffebcd0000ff8a2be2a52a2adeb8875f9ea07fff00d2691eff7f506495edfff8dcdc143c00ffff00008b008b8bb8860ba9a9a9006400a9a9a9bdb76b8b008b556b2fff8c009932cc8b0000e9967a8fbc8f483d8b2f4f4f2f4f4f00ced19400d3ff149300bfff6969696969691e90ffb22222fffaf0228b22ff00ffdcdcdcf8f8ffffd700daa520808080008000adff2f808080f0fff0ff69b4cd5c5c4b0082fffff0f0e68ce6e6fafff0f57cfc00fffacdadd8e6f08080e0fffffafad2d3d3d390ee90d3d3d3ffb6c1ffa07a20b2aa87cefa778899778899b0c4deffffe000ff0032cd32faf0e6ff00ff80000066cdaa0000cdba55d39370db3cb3717b68ee00fa9a48d1ccc71585191970f5fffaffe4e1ffe4b5ffdead000080fdf5e68080006b8e23ffa500ff4500da70d6eee8aa98fb98afeeeedb7093ffefd5ffdab9cd853fffc0cbdda0ddb0e0e6800080663399ff0000bc8f8f4169e18b4513fa8072f4a4602e8b57fff5eea0522dc0c0c087ceeb6a5acd708090708090fffafa00ff7f4682b4d2b48c008080d8bfd8ff634740e0d0ee82eef5deb3fffffff5f5f5ffff009acd32";
378
+ const colors = /* @__PURE__ */ new Map();
379
+ for (let i = 0; i < names.length; i++) colors.set(names[i], `#${hex.slice(i * 6, i * 6 + 6)}`);
380
+ return _namedColorHex = colors;
381
+ }
382
+ const SYSTEM_COLORS = new Set("accentcolor accentcolortext activetext buttonborder buttonface buttontext canvas canvastext field fieldtext graytext highlight highlighttext linktext mark marktext selecteditem selecteditemtext visitedtext".split(" "));
383
+ function isColorKeyword(name) {
384
+ const lower = name.toLowerCase();
385
+ return getNamedColorHex().has(lower) || SYSTEM_COLORS.has(lower);
386
+ }
387
+ function hexToRgb(hex) {
388
+ const matched = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, (_m, r, g, b) => "#" + r + r + g + g + b + b).substring(1).match(/.{2}/g);
389
+ if (!matched) return null;
390
+ const rgba = matched.map((x, i) => parseInt(x, 16) * (i === 3 ? 1 / 255 : 1));
391
+ if (rgba.some((v) => Number.isNaN(v))) return null;
392
+ if (rgba.length >= 3) return `rgb(${rgba.slice(0, 3).join(" ")}${rgba.length > 3 ? ` / ${rgba[3]}` : ""})`;
393
+ return null;
394
+ }
395
+ function getRgbValuesFromRgbaString(str) {
396
+ const match = str.match(/rgba?\(([^)]+)\)/i);
397
+ if (!match) return [];
398
+ const [colorPart] = match[1].trim().split("/");
399
+ return colorPart.trim().split(/[,\s]+/).filter(Boolean).slice(0, 3).map((part) => {
400
+ part = part.trim();
401
+ if (part.endsWith("%")) return parseFloat(part) / 100 * 255;
402
+ return parseFloat(part);
403
+ });
404
+ }
405
+ function strToRgb(color, _ignoreAlpha = false) {
406
+ if (!color) return void 0;
407
+ if (color.startsWith("rgb")) return color;
408
+ if (color.startsWith("#")) return hexToRgb(color);
409
+ if (color.startsWith("oklch(")) return oklchStringToRgb(color);
410
+ if (color.startsWith("hsl")) return hslStringToRgb(color);
411
+ const namedHex = getNamedColorHex().get(color.toLowerCase());
412
+ if (namedHex) return hexToRgb(namedHex);
413
+ return null;
414
+ }
415
+ function hslStringToRgb(hslStr) {
416
+ const match = hslStr.match(/hsla?\(([^)]+)\)/i);
417
+ if (!match) return null;
418
+ const [colorPart, slashAlpha] = match[1].trim().split("/");
419
+ const parts = colorPart.trim().split(/[,\s]+/).filter(Boolean);
420
+ if (parts.length < 3) return null;
421
+ const alphaPart = slashAlpha?.trim() || (parts.length >= 4 ? parts[3] : null);
422
+ let h = parseFloat(parts[0]);
423
+ const hueStr = parts[0].toLowerCase();
424
+ if (hueStr.endsWith("turn")) h = parseFloat(hueStr) * 360;
425
+ else if (hueStr.endsWith("rad")) h = parseFloat(hueStr) * 180 / Math.PI;
426
+ h = (h % 360 + 360) % 360;
427
+ const parsePercent = (val) => {
428
+ const num = parseFloat(val);
429
+ return val.includes("%") ? num / 100 : num;
430
+ };
431
+ const s = Math.max(0, Math.min(1, parsePercent(parts[1])));
432
+ const l = Math.max(0, Math.min(1, parsePercent(parts[2])));
433
+ const [r, g, b] = hslToRgbValues(h, s, l);
434
+ if (alphaPart) {
435
+ const alpha = parseFloat(alphaPart.trim());
436
+ return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${alpha})`;
437
+ }
438
+ return `rgb(${Math.round(r)} ${Math.round(g)} ${Math.round(b)})`;
439
+ }
440
+ function oklchStringToRgb(oklchStr) {
441
+ const match = oklchStr.match(/oklch\(([^)]+)\)/i);
442
+ if (!match) return null;
443
+ const [colorPart, alphaPart] = match[1].trim().split("/");
444
+ const parts = colorPart.trim().split(/[,\s]+/).filter(Boolean);
445
+ if (parts.length < 3) return null;
446
+ const parsePercent = (val) => {
447
+ const num = parseFloat(val);
448
+ return val.includes("%") ? num / 100 : num;
449
+ };
450
+ const L = Math.max(0, Math.min(1, parsePercent(parts[0])));
451
+ const C = Math.max(0, parseFloat(parts[1]));
452
+ let H = parseFloat(parts[2]);
453
+ const hueStr = parts[2].toLowerCase();
454
+ if (hueStr.endsWith("turn")) H = parseFloat(hueStr) * 360;
455
+ else if (hueStr.endsWith("rad")) H = parseFloat(hueStr) * 180 / Math.PI;
456
+ else if (hueStr.endsWith("deg")) H = parseFloat(hueStr);
457
+ const [r, g, b] = oklchToRgbValues(L, C, H);
458
+ if (alphaPart) {
459
+ const alpha = parseFloat(alphaPart.trim());
460
+ return `rgba(${Math.round(r)}, ${Math.round(g)}, ${Math.round(b)}, ${alpha})`;
461
+ }
462
+ return `rgb(${Math.round(r)} ${Math.round(g)} ${Math.round(b)})`;
463
+ }
464
+ //#endregion
465
+ //#region src/utils/color-space.ts
466
+ function mixColorAlpha(color, percentage) {
467
+ return `color-mix(in oklab, ${color} ${percentage}, transparent)`;
468
+ }
469
+ const RE_ALPHA_MIX = /^color-mix\(in oklab,\s*(.+) (\S+%|calc\(.+ \* 100%\)),\s*transparent\)$/;
470
+ function parseAlphaMix(value) {
471
+ const match = value.match(RE_ALPHA_MIX);
472
+ return match ? {
473
+ color: match[1],
474
+ percentage: match[2]
475
+ } : null;
476
+ }
477
+ function alphaToPercentage(alpha) {
478
+ return `${Number(((Number.isNaN(alpha) ? 1 : Math.min(1, Math.max(0, alpha))) * 100).toFixed(6))}%`;
479
+ }
480
+ //#endregion
481
+ //#region src/parser/types.ts
482
+ const makeEmptyPart = () => ({
483
+ mods: [],
484
+ values: [],
485
+ colors: [],
486
+ all: [],
487
+ output: ""
488
+ });
489
+ const makeEmptyDetails = () => ({
490
+ input: "",
491
+ output: "",
492
+ mods: [],
493
+ values: [],
494
+ colors: [],
495
+ all: [],
496
+ parts: []
497
+ });
498
+ //#endregion
499
+ //#region src/parser/classify.ts
500
+ function alphaSuffixToPercentage(rawAlpha) {
501
+ if (rawAlpha.startsWith("$")) return `calc(var(--${rawAlpha.slice(1)}) * 100%)`;
502
+ if (rawAlpha === "0") return "0%";
503
+ const digits = rawAlpha.length === 1 ? `${rawAlpha}0` : rawAlpha;
504
+ const whole = String(Number(digits.slice(0, 2)));
505
+ const fraction = digits.slice(2).replace(/0+$/, "");
506
+ return `${fraction ? `${whole}.${fraction}` : whole}%`;
507
+ }
508
+ function fadeColor(color, rawAlpha) {
509
+ return mixColorAlpha(color, alphaSuffixToPercentage(rawAlpha));
510
+ }
511
+ function hasColorArgs(parsed) {
512
+ return parsed.groups.some((group) => group.colors.length > 0);
513
+ }
514
+ function isSingleColor(group) {
515
+ return !!group && group.all.length === 1 && group.colors.length === 1;
516
+ }
517
+ function resolveUntilStable(value, opts, recurse, maxIterations = 10) {
518
+ let current = value;
519
+ for (let i = 0; i < maxIterations; i++) {
520
+ const unitMatch = current.match(RE_UNIT_NUM);
521
+ if (!unitMatch) break;
522
+ const unitName = unitMatch[1];
523
+ if (!opts.units || !(unitName in opts.units)) break;
524
+ const result = recurse(current);
525
+ if (result.output === current) break;
526
+ current = result.output;
527
+ }
528
+ return current;
529
+ }
530
+ function classify(raw, opts, recurse) {
531
+ const token = raw.trim();
532
+ if (!token) return {
533
+ bucket: 2,
534
+ processed: ""
535
+ };
536
+ if (token.includes("(")) {
537
+ let depth = 0;
538
+ let inQuote = 0;
539
+ for (let i = 0; i < token.length; i++) {
540
+ const ch = token[i];
541
+ if (inQuote) {
542
+ if (ch === inQuote && token[i - 1] !== "\\") inQuote = 0;
543
+ continue;
544
+ }
545
+ if (ch === "\"" || ch === "'") {
546
+ inQuote = ch;
547
+ continue;
548
+ }
549
+ if (ch === "(") depth++;
550
+ else if (ch === ")" && depth) depth--;
551
+ }
552
+ if (depth !== 0) {
553
+ if (process.env.NODE_ENV !== "production") console.warn("[Tasty] skipped invalid function token with unmatched parentheses:", token);
554
+ return {
555
+ bucket: 2,
556
+ processed: ""
557
+ };
558
+ }
559
+ }
560
+ if (token.startsWith("\"") && token.endsWith("\"") || token.startsWith("'") && token.endsWith("'")) return {
561
+ bucket: 1,
562
+ processed: token
563
+ };
564
+ if (token.startsWith("$$")) {
565
+ const rest = token.slice(2);
566
+ const openIdx = rest.indexOf("(");
567
+ if (openIdx > 0 && rest.endsWith(")")) {
568
+ const fname = rest.slice(0, openIdx);
569
+ if (/^[a-z_][a-z0-9-_]*$/i.test(fname)) {
570
+ const inner = rest.slice(openIdx + 1, -1).trim();
571
+ const cssName = `--${fname}`;
572
+ if (opts.functions && cssName in opts.functions) {
573
+ const groups = inner ? new StyleParser(opts).process(inner).groups : [];
574
+ const funcResult = opts.functions[cssName](groups);
575
+ if (funcResult !== "") return classify(funcResult, {
576
+ ...opts,
577
+ functions: void 0
578
+ }, recurse);
579
+ }
580
+ return {
581
+ bucket: 1,
582
+ processed: `--${fname}(${inner ? recurse(inner).output : ""})`
583
+ };
584
+ }
585
+ }
586
+ if (/^[a-z_][a-z0-9-_]*$/i.test(rest)) return {
587
+ bucket: 1,
588
+ processed: `--${rest}`
589
+ };
590
+ }
591
+ if (token.startsWith("##")) {
592
+ const rest = token.slice(2);
593
+ const openIdx = rest.indexOf("(");
594
+ if (openIdx > 0 && rest.endsWith(")")) {
595
+ const fname = rest.slice(0, openIdx);
596
+ if (/^[a-z_][a-z0-9-_]*$/i.test(fname)) {
597
+ const inner = rest.slice(openIdx + 1, -1).trim();
598
+ return {
599
+ bucket: 1,
600
+ processed: `--${fname}-color(${inner ? recurse(inner).output : ""})`
601
+ };
602
+ }
603
+ }
604
+ if (/^[a-z_][a-z0-9-_]*$/i.test(rest)) return {
605
+ bucket: 1,
606
+ processed: `--${rest}-color`
607
+ };
608
+ }
609
+ if (token === "#current") return {
610
+ bucket: 0,
611
+ processed: "currentcolor"
612
+ };
613
+ const currentAlphaMatch = token.match(/^#current\.(\$[a-z_][a-z0-9-_]*|[0-9]+)$/i);
614
+ if (currentAlphaMatch) return {
615
+ bucket: 0,
616
+ processed: fadeColor("currentcolor", currentAlphaMatch[1])
617
+ };
618
+ if (token[0] === "$" || token[0] === "#") {
619
+ const predefinedTokens = getGlobalPredefinedTokens();
620
+ if (predefinedTokens) {
621
+ const lookupKey = token.toLowerCase();
622
+ if (lookupKey in predefinedTokens) {
623
+ const tokenValue = predefinedTokens[lookupKey];
624
+ return classify(foldDslCase(tokenValue), opts, recurse);
625
+ }
626
+ if (token[0] === "#") {
627
+ const alphaMatch = token.match(/^(#[a-z0-9-]+)\.(\$[a-z_][a-z0-9-_]*|[0-9]+)$/i);
628
+ if (alphaMatch) {
629
+ const [, baseToken, rawAlpha] = alphaMatch;
630
+ const baseKey = baseToken.toLowerCase();
631
+ if (baseKey in predefinedTokens) {
632
+ const resolvedValue = predefinedTokens[baseKey];
633
+ if (resolvedValue.trim().toLowerCase() === "transparent") return {
634
+ bucket: 0,
635
+ processed: "transparent"
636
+ };
637
+ if (resolvedValue.startsWith("#")) return classify(`${foldDslCase(resolvedValue)}.${rawAlpha}`, opts, recurse);
638
+ const funcMatch = resolvedValue.match(RE_FUNC_CALL);
639
+ if (funcMatch) {
640
+ const [, funcName, args] = funcMatch;
641
+ const lowerFunc = funcName.toLowerCase();
642
+ if (DERIVED_COLOR_FUNCS.has(lowerFunc)) return {
643
+ bucket: 0,
644
+ processed: fadeColor(classify(foldDslCase(resolvedValue), opts, recurse).processed, rawAlpha)
645
+ };
646
+ const isCustomFunc = !!(opts.functions && lowerFunc in opts.functions && !COLOR_FUNCS.has(lowerFunc) && !COLOR_FUNCS.has(funcName.replace(/a$/i, "").toLowerCase()));
647
+ const normalizedFunc = isCustomFunc ? lowerFunc : funcName.replace(/a$/i, "").toLowerCase();
648
+ if (!(COLOR_FUNCS.has(normalizedFunc) || COLOR_FUNCS.has(lowerFunc) || isCustomFunc)) return classify(`${resolvedValue}.${rawAlpha}`, opts, recurse);
649
+ let alpha;
650
+ if (rawAlpha.startsWith("$")) alpha = `var(--${rawAlpha.slice(1)})`;
651
+ else alpha = rawAlpha === "0" ? "0" : `.${rawAlpha}`;
652
+ const normalizeArgs = (a) => {
653
+ let result = "";
654
+ let depth = 0;
655
+ for (let i = 0; i < a.length; i++) {
656
+ const c = a[i];
657
+ if (c === "(") {
658
+ depth++;
659
+ result += c;
660
+ } else if (c === ")") {
661
+ depth = Math.max(0, depth - 1);
662
+ result += c;
663
+ } else if (c === "," && depth === 0) {
664
+ while (i + 1 < a.length && /\s/.test(a[i + 1])) i++;
665
+ result += " ";
666
+ } else result += c;
667
+ }
668
+ return result;
669
+ };
670
+ const findLastTopLevel = (str, ch) => {
671
+ let depth = 0;
672
+ for (let i = str.length - 1; i >= 0; i--) {
673
+ const c = str[i];
674
+ if (c === ")") depth++;
675
+ else if (c === "(") depth = Math.max(0, depth - 1);
676
+ else if (c === ch && depth === 0) return i;
677
+ }
678
+ return -1;
679
+ };
680
+ const slashIdx = findLastTopLevel(args, "/");
681
+ const hasModernAlpha = slashIdx !== -1;
682
+ let topLevelCommaCount = 0;
683
+ let lastTopLevelComma = -1;
684
+ {
685
+ let depth = 0;
686
+ for (let i = 0; i < args.length; i++) {
687
+ const c = args[i];
688
+ if (c === "(") depth++;
689
+ else if (c === ")") depth = Math.max(0, depth - 1);
690
+ else if (c === "," && depth === 0) {
691
+ topLevelCommaCount++;
692
+ lastTopLevelComma = i;
693
+ }
694
+ }
695
+ }
696
+ const hasLegacyAlpha = !hasModernAlpha && /a$/i.test(funcName) && topLevelCommaCount === 3;
697
+ const constructed = `${normalizedFunc}(${hasModernAlpha || hasLegacyAlpha ? normalizeArgs(hasModernAlpha ? args.slice(0, slashIdx).trim() : args.slice(0, lastTopLevelComma).trim()) : normalizeArgs(args)} / ${alpha})`;
698
+ if (!COLOR_FUNCS.has(normalizedFunc) && opts.functions && normalizedFunc in opts.functions) return classify(constructed, opts, recurse);
699
+ return {
700
+ bucket: 0,
701
+ processed: constructed
702
+ };
703
+ }
704
+ const keyword = resolvedValue.trim().toLowerCase();
705
+ if (keyword === "currentcolor" || isColorKeyword(keyword)) return {
706
+ bucket: 0,
707
+ processed: fadeColor(keyword, rawAlpha)
708
+ };
709
+ return classify(`${resolvedValue}.${rawAlpha}`, opts, recurse);
710
+ }
711
+ }
712
+ }
713
+ }
714
+ }
715
+ if (token.match(/^var\(--([a-zA-Z0-9-]+)-color\)$/)) return {
716
+ bucket: 0,
717
+ processed: token
718
+ };
719
+ if (token.startsWith("url(")) return {
720
+ bucket: 1,
721
+ processed: token
722
+ };
723
+ if (token[0] === "$") {
724
+ const identMatch = token.match(/^\$([a-z_][a-zA-Z0-9-_]*)$/);
725
+ if (identMatch) {
726
+ const name = identMatch[1];
727
+ const processed = `var(--${name})`;
728
+ return {
729
+ bucket: name.endsWith("-color") ? 3 : 1,
730
+ processed
731
+ };
732
+ }
733
+ }
734
+ if (token[0] === "#" && token.length > 1) {
735
+ const alphaMatch = token.match(/^#([a-z0-9-]+)\.(\$[a-z_][a-z0-9-_]*|[0-9]+)$/i);
736
+ if (alphaMatch) {
737
+ const [, base, rawAlpha] = alphaMatch;
738
+ return {
739
+ bucket: 0,
740
+ processed: fadeColor(RE_HEX.test(base) ? `var(--${base}-color, #${base})` : `var(--${base}-color)`, rawAlpha)
741
+ };
742
+ }
743
+ const name = token.slice(1);
744
+ if (RE_HEX.test(name)) return {
745
+ bucket: 0,
746
+ processed: `var(--${name}-color, #${name})`
747
+ };
748
+ return {
749
+ bucket: 0,
750
+ processed: `var(--${name}-color)`
751
+ };
752
+ }
753
+ const openIdx = token.indexOf("(");
754
+ if (openIdx > 0 && token.endsWith(")")) {
755
+ const fname = token.slice(0, openIdx);
756
+ const inner = token.slice(openIdx + 1, -1);
757
+ if (COLOR_FUNCS.has(fname)) {
758
+ const parsedInner = recurse(inner);
759
+ const argProcessed = parsedInner.output.replace(/,\s+/g, ",");
760
+ const processed = `${canonicalFuncName(fname)}(${argProcessed})`;
761
+ return {
762
+ bucket: fname === "light-dark" && !hasColorArgs(parsedInner) ? 1 : 0,
763
+ processed
764
+ };
765
+ }
766
+ if (opts.functions && fname in opts.functions) {
767
+ const tmp = new StyleParser(opts).process(inner);
768
+ return classify(opts.functions[fname](tmp.groups), {
769
+ ...opts,
770
+ functions: void 0
771
+ }, recurse);
772
+ }
773
+ const parsedInner = recurse(inner);
774
+ return {
775
+ bucket: fname === "var" && parsedInner.groups.length === 2 && isSingleColor(parsedInner.groups[1]) ? 0 : 1,
776
+ processed: `${canonicalFuncName(fname)}(${parsedInner.output})`
777
+ };
778
+ }
779
+ if (token.startsWith("(") && token.endsWith(")")) {
780
+ const colorMatch = token.slice(1, -1).match(/^#([a-z0-9-]+)\s*,\s*(.*)$/i);
781
+ if (colorMatch) {
782
+ const [, name, fallback] = colorMatch;
783
+ return {
784
+ bucket: 0,
785
+ processed: `var(--${name}-color, ${recurse(fallback).output})`
786
+ };
787
+ }
788
+ }
789
+ if (token.startsWith("(") && token.endsWith(")")) {
790
+ const match = token.slice(1, -1).match(/^\$([a-z_][a-zA-Z0-9-_]*)\s*,\s*(.*)$/);
791
+ if (match) {
792
+ const [, name, fallback] = match;
793
+ const parsedFallback = recurse(fallback);
794
+ return {
795
+ bucket: name.endsWith("-color") ? 3 : parsedFallback.groups.length === 1 && isSingleColor(parsedFallback.groups[0]) ? 0 : 1,
796
+ processed: `var(--${name}, ${parsedFallback.output})`
797
+ };
798
+ }
799
+ }
800
+ if (token[0] === "(" && token[token.length - 1] === ")") return {
801
+ bucket: 1,
802
+ processed: `calc(${recurse(token.slice(1, -1)).output})`
803
+ };
804
+ const um = token.match(RE_UNIT_NUM);
805
+ if (um) {
806
+ const unit = um[1];
807
+ const numericPart = parseFloat(token.slice(0, -unit.length));
808
+ const handler = opts.units && opts.units[unit];
809
+ if (handler) {
810
+ if (typeof handler === "string") {
811
+ const rawMatch = handler.match(RE_RAW_UNIT);
812
+ if (rawMatch) {
813
+ const [, baseNum, cssUnit] = rawMatch;
814
+ return {
815
+ bucket: 1,
816
+ processed: resolveUntilStable(`${numericPart * parseFloat(baseNum)}${cssUnit}`, opts, recurse)
817
+ };
818
+ }
819
+ const base = handler;
820
+ if (numericPart === 1) return {
821
+ bucket: 1,
822
+ processed: base
823
+ };
824
+ return {
825
+ bucket: 1,
826
+ processed: `calc(${numericPart} * ${base})`
827
+ };
828
+ } else return {
829
+ bucket: 1,
830
+ processed: handler(numericPart)
831
+ };
832
+ }
833
+ }
834
+ if (/^[+-]?(?:\d*\.\d+|\d+)[a-z%]+$/.test(token)) return {
835
+ bucket: 1,
836
+ processed: token
837
+ };
838
+ if (RE_NUMBER.test(token)) return {
839
+ bucket: 1,
840
+ processed: token
841
+ };
842
+ if (VALUE_KEYWORDS.has(token)) return {
843
+ bucket: 1,
844
+ processed: token
845
+ };
846
+ if (token === "transparent" || token === "currentcolor" || isColorKeyword(token)) return {
847
+ bucket: 0,
848
+ processed: token
849
+ };
850
+ return {
851
+ bucket: 2,
852
+ processed: token
853
+ };
854
+ }
855
+ //#endregion
856
+ //#region src/parser/lru.ts
857
+ var Lru = class {
858
+ limit;
859
+ map = /* @__PURE__ */ new Map();
860
+ head = null;
861
+ tail = null;
862
+ onEvict;
863
+ constructor(limit = 1e3, onEvict) {
864
+ this.limit = limit;
865
+ let normalized = Number.isFinite(this.limit) ? Math.floor(this.limit) : 1e3;
866
+ if (normalized <= 0) normalized = 1e3;
867
+ this.limit = normalized;
868
+ this.onEvict = onEvict;
869
+ }
870
+ setOnEvict(fn) {
871
+ this.onEvict = fn;
872
+ }
873
+ get(key) {
874
+ const node = this.map.get(key);
875
+ if (node === void 0) return void 0;
876
+ if (this.head !== node) this.moveToHead(node);
877
+ return node.value;
878
+ }
879
+ set(key, value) {
880
+ const existing = this.map.get(key);
881
+ if (existing !== void 0) {
882
+ existing.value = value;
883
+ if (this.head !== existing) this.moveToHead(existing);
884
+ return;
885
+ }
886
+ const node = {
887
+ key,
888
+ prev: null,
889
+ next: this.head,
890
+ value
891
+ };
892
+ if (this.head) this.head.prev = node;
893
+ this.head = node;
894
+ if (!this.tail) this.tail = node;
895
+ this.map.set(key, node);
896
+ if (this.map.size > this.limit) this.evict();
897
+ }
898
+ delete(key) {
899
+ const node = this.map.get(key);
900
+ if (node === void 0) return;
901
+ this.detach(node);
902
+ this.map.delete(key);
903
+ }
904
+ keys() {
905
+ return this.map.keys();
906
+ }
907
+ detach(node) {
908
+ if (node.prev) node.prev.next = node.next;
909
+ if (node.next) node.next.prev = node.prev;
910
+ if (this.head === node) this.head = node.next;
911
+ if (this.tail === node) this.tail = node.prev;
912
+ node.prev = null;
913
+ node.next = null;
914
+ }
915
+ moveToHead(node) {
916
+ this.detach(node);
917
+ node.next = this.head;
918
+ if (this.head) this.head.prev = node;
919
+ this.head = node;
920
+ if (!this.tail) this.tail = node;
921
+ }
922
+ evict() {
923
+ const node = this.tail;
924
+ if (!node) return;
925
+ this.detach(node);
926
+ this.map.delete(node.key);
927
+ if (this.onEvict) try {
928
+ this.onEvict(node.key, node.value);
929
+ } catch {}
930
+ }
931
+ clear() {
932
+ this.map.clear();
933
+ this.head = this.tail = null;
934
+ }
935
+ };
936
+ //#endregion
937
+ //#region src/parser/tokenizer.ts
938
+ const isWhitespace = (ch) => ch === " " || ch === "\n" || ch === " " || ch === "\r" || ch === "\f";
939
+ function scan(src, cb) {
940
+ let depth = 0;
941
+ let inQuote = 0;
942
+ let start = 0;
943
+ let i = 0;
944
+ let pendingSlash = false;
945
+ const flush = (isComma, isSlash) => {
946
+ const actualSlash = isSlash || pendingSlash;
947
+ pendingSlash = false;
948
+ if (start < i) cb(src.slice(start, i), isComma, actualSlash);
949
+ else if (isComma) cb("", true, false);
950
+ else if (actualSlash) cb("", false, true);
951
+ start = i + 1;
952
+ };
953
+ for (; i < src.length; i++) {
954
+ const ch = src[i];
955
+ if (inQuote) {
956
+ if (ch === inQuote && src[i - 1] !== "\\") inQuote = 0;
957
+ continue;
958
+ }
959
+ if (ch === "\"" || ch === "'") {
960
+ inQuote = ch;
961
+ continue;
962
+ }
963
+ if (ch === "(") {
964
+ depth++;
965
+ continue;
966
+ }
967
+ if (ch === ")") {
968
+ if (depth) depth--;
969
+ continue;
970
+ }
971
+ if (!depth) {
972
+ if (ch === ",") {
973
+ flush(true, false);
974
+ continue;
975
+ }
976
+ if (ch === "/") {
977
+ const prevIsWhitespace = isWhitespace(src[i - 1]);
978
+ const nextIsWhitespace = isWhitespace(src[i + 1]);
979
+ if (prevIsWhitespace && nextIsWhitespace) {
980
+ pendingSlash = true;
981
+ start = i + 1;
982
+ continue;
983
+ }
984
+ continue;
985
+ }
986
+ if (isWhitespace(ch)) {
987
+ flush(false, false);
988
+ continue;
989
+ }
990
+ }
991
+ }
992
+ flush(false, false);
993
+ }
994
+ //#endregion
995
+ //#region src/parser/parser.ts
996
+ var StyleParser = class {
997
+ opts;
998
+ cache;
999
+ constructor(opts = {}) {
1000
+ this.opts = opts;
1001
+ this.cache = new Lru(this.opts.cacheSize ?? 1e3);
1002
+ }
1003
+ process(src) {
1004
+ const key = String(src);
1005
+ const hit = this.cache.get(key);
1006
+ if (hit) return hit;
1007
+ const stripped = foldDslCase(src.replace(/\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g, ""));
1008
+ const groups = [];
1009
+ let currentGroup = makeEmptyDetails();
1010
+ let currentPart = makeEmptyPart();
1011
+ let parts = [];
1012
+ const pushToken = (bucket, processed) => {
1013
+ if (!processed) return;
1014
+ if (currentPart.values.length > 0 && currentPart.values[currentPart.values.length - 1].startsWith("url(")) {
1015
+ currentPart.values[currentPart.values.length - 1] += ` ${processed}`;
1016
+ currentPart.all[currentPart.all.length - 1] += ` ${processed}`;
1017
+ return;
1018
+ }
1019
+ switch (bucket) {
1020
+ case 0:
1021
+ currentPart.colors.push(processed);
1022
+ break;
1023
+ case 1:
1024
+ currentPart.values.push(processed);
1025
+ break;
1026
+ case 2:
1027
+ currentPart.mods.push(processed);
1028
+ break;
1029
+ case 3:
1030
+ currentPart.colors.push(processed);
1031
+ currentPart.values.push(processed);
1032
+ }
1033
+ currentPart.all.push(processed);
1034
+ };
1035
+ const endPart = (reset = true) => {
1036
+ if (currentPart.all.length > 0) {
1037
+ currentPart.output = currentPart.all.join(" ");
1038
+ parts.push(currentPart);
1039
+ }
1040
+ if (reset) currentPart = makeEmptyPart();
1041
+ };
1042
+ const endGroup = (reset = true) => {
1043
+ endPart(reset);
1044
+ if (parts.length === 0) parts.push(makeEmptyPart());
1045
+ currentGroup.parts = parts;
1046
+ for (const part of parts) {
1047
+ currentGroup.mods.push(...part.mods);
1048
+ currentGroup.values.push(...part.values);
1049
+ currentGroup.colors.push(...part.colors);
1050
+ currentGroup.all.push(...part.all);
1051
+ }
1052
+ currentGroup.output = parts.length === 1 ? parts[0].output : parts.map((part) => part.output).join(" / ");
1053
+ groups.push(currentGroup);
1054
+ if (reset) {
1055
+ currentGroup = makeEmptyDetails();
1056
+ parts = [];
1057
+ }
1058
+ };
1059
+ scan(stripped, (tok, isComma, isSlash) => {
1060
+ if (tok) {
1061
+ if (currentGroup.input) currentGroup.input += ` ${tok}`;
1062
+ else currentGroup.input = tok;
1063
+ const { bucket, processed } = classify(tok, this.opts, (sub) => this.process(sub));
1064
+ pushToken(bucket, processed);
1065
+ }
1066
+ if (isSlash) endPart();
1067
+ if (isComma) endGroup();
1068
+ });
1069
+ if (currentPart.all.length || parts.length || !groups.length) endGroup(false);
1070
+ const result = {
1071
+ output: groups.length === 1 ? groups[0].output : groups.map((group) => group.output).join(", "),
1072
+ groups
1073
+ };
1074
+ Object.freeze(result);
1075
+ this.cache.set(key, result);
1076
+ return result;
1077
+ }
1078
+ setFunctions(functions) {
1079
+ this.opts.functions = functions;
1080
+ this.cache.clear();
1081
+ }
1082
+ setUnits(units) {
1083
+ this.opts.units = units;
1084
+ this.cache.clear();
1085
+ }
1086
+ updateOptions(patch) {
1087
+ Object.assign(this.opts, patch);
1088
+ if (patch.cacheSize) this.cache = new Lru(patch.cacheSize);
1089
+ else this.cache.clear();
1090
+ }
1091
+ clearCache() {
1092
+ this.cache.clear();
1093
+ }
1094
+ getUnits() {
1095
+ return this.opts.units;
1096
+ }
1097
+ };
1098
+ //#endregion
1099
+ //#region src/plugins/color-func.ts
1100
+ const clamp = (value, min, max) => Math.max(Math.min(value, max), min);
1101
+ const parseAngle = (value) => {
1102
+ const match = value.match(/^([+-]?\d*\.?\d+)(deg|turn|rad)?$/);
1103
+ if (!match) return 0;
1104
+ const num = parseFloat(match[1]);
1105
+ switch (match[2]) {
1106
+ case "turn": return num * 360;
1107
+ case "rad": return num * 180 / Math.PI;
1108
+ default: return num;
1109
+ }
1110
+ };
1111
+ const parsePercentage = (value) => {
1112
+ const match = value.match(/^([+-]?\d*\.?\d+)%?$/);
1113
+ if (!match) return 0;
1114
+ const num = parseFloat(match[1]);
1115
+ return value.includes("%") ? num / 100 : num;
1116
+ };
1117
+ function createColorFunc(name, convert, label) {
1118
+ const conversionCache = new Lru(500);
1119
+ const expected = label ? ` (${label})` : "";
1120
+ return (groups) => {
1121
+ if (groups.length === 0 || groups[0].all.length < 3) {
1122
+ if (isDevEnv()) console.warn(`[Tasty] ${name}(): expected 3 values${expected}, got:`, groups);
1123
+ return "rgb(0% 0% 0%)";
1124
+ }
1125
+ const group = groups[0];
1126
+ const tokens = group.all;
1127
+ const alpha = group.parts.length > 1 && group.parts[1].all.length > 0 ? group.parts[1].output : void 0;
1128
+ const cacheKey = tokens.slice(0, 3).join(" ") + (alpha ? ` / ${alpha}` : "");
1129
+ const cached = conversionCache.get(cacheKey);
1130
+ if (cached) return cached;
1131
+ const h = parseAngle(tokens[0]);
1132
+ const c2 = parsePercentage(tokens[1]);
1133
+ const c3 = parsePercentage(tokens[2]);
1134
+ const misscaled = [tokens[1], tokens[2]].filter((raw, i) => !raw.includes("%") && (i === 0 ? c2 : c3) > 1);
1135
+ if (misscaled.length) warnOnceDev(`${name}:percent-scale`, `${name}(): channels are factors (0-1) or percentages, so ${misscaled.map((v) => `"${v}"`).join(" and ")} ${misscaled.length > 1 ? "clamp" : "clamps"} to 1 — add the missing '%', or write the value as a 0-1 number.`);
1136
+ const [r, g, b] = convert(h, clamp(c2, 0, 1), clamp(c3, 0, 1));
1137
+ const format = (n) => {
1138
+ const pct = n * 100;
1139
+ return parseFloat(pct.toFixed(1)).toString() + "%";
1140
+ };
1141
+ const result = alpha ? `rgb(${format(r)} ${format(g)} ${format(b)} / ${alpha})` : `rgb(${format(r)} ${format(g)} ${format(b)})`;
1142
+ conversionCache.set(cacheKey, result);
1143
+ return result;
1144
+ };
1145
+ }
1146
+ //#endregion
1147
+ //#region src/plugins/okhsl-plugin.ts
1148
+ const okhslFunction = createColorFunc("okhsl", okhslToSrgb, "H S L");
1149
+ const okhslPlugin = () => ({
1150
+ name: "okhsl",
1151
+ functions: { okhsl: okhslFunction }
1152
+ });
1153
+ //#endregion
1154
+ //#region src/plugins/okhst-plugin.ts
1155
+ const okhstFunction = createColorFunc("okhst", okhstToSrgb, "H S T");
1156
+ const okhstPlugin = () => ({
1157
+ name: "okhst",
1158
+ functions: { okhst: okhstFunction }
1159
+ });
1160
+ //#endregion
1161
+ //#region src/plugins/defaults.ts
1162
+ function registerDefaultFunctions() {
1163
+ customFunction("okhsl", okhslFunction);
1164
+ customFunction("okhst", okhstFunction);
1165
+ }
1166
+ //#endregion
1167
+ //#region src/utils/styles.ts
1168
+ function normalizeColorTokenValue(value) {
1169
+ if (value === true) return "transparent";
1170
+ if (value === false) return null;
1171
+ return value;
1172
+ }
1173
+ const devMode = process.env.NODE_ENV !== "production";
1174
+ const COLOR_VAR_PATTERN = /^var\(--([a-z0-9-]+)-color[,)]/;
1175
+ const RGB_ALPHA_PATTERN = /\/\s*([0-9.]+)\)/;
1176
+ const RE_HEX_COLOR = /^#[0-9a-fA-F]{3,8}$/;
1177
+ const RE_VAR_COLOR = /^var\(--[a-z0-9-]+-color/;
1178
+ function isSimpleColorFast(val) {
1179
+ switch (val.charCodeAt(0)) {
1180
+ case 35: return RE_HEX_COLOR.test(val);
1181
+ case 114:
1182
+ if (val.charCodeAt(1) === 103 && val.charCodeAt(2) === 98) return true;
1183
+ break;
1184
+ case 104:
1185
+ if (val.charCodeAt(1) === 115 && val.charCodeAt(2) === 108) return true;
1186
+ break;
1187
+ case 108:
1188
+ if (val.charCodeAt(1) === 99 && val.charCodeAt(2) === 104) return true;
1189
+ break;
1190
+ case 111:
1191
+ if (val.startsWith("oklch(")) return true;
1192
+ break;
1193
+ case 118:
1194
+ if (RE_VAR_COLOR.test(val)) return true;
1195
+ break;
1196
+ case 99:
1197
+ if (val === "currentColor" || val === "currentcolor") return true;
1198
+ break;
1199
+ case 116: if (val === "transparent") return true;
1200
+ }
1201
+ return isColorKeyword(val);
1202
+ }
1203
+ let colorWarningCount = 0;
1204
+ const MAX_COLOR_WARNINGS = 10;
1205
+ const CUSTOM_UNITS = {
1206
+ r: "6px",
1207
+ cr: "10px",
1208
+ bw: "1px",
1209
+ ow: "3px",
1210
+ x: "8px",
1211
+ sf: function sf(num) {
1212
+ return `minmax(0, ${num}fr)`;
1213
+ }
1214
+ };
1215
+ const DIRECTIONS = [
1216
+ "top",
1217
+ "right",
1218
+ "bottom",
1219
+ "left"
1220
+ ];
1221
+ let __tastyParser = null;
1222
+ function getOrCreateParser() {
1223
+ if (!__tastyParser) {
1224
+ __tastyParser = new StyleParser({ units: CUSTOM_UNITS });
1225
+ __tastyParser.setFunctions(__tastyParseFunctions);
1226
+ registerDefaultFunctions();
1227
+ }
1228
+ return __tastyParser;
1229
+ }
1230
+ const __tastyParseFunctions = {};
1231
+ function customFunction(name, fn) {
1232
+ __tastyParseFunctions[name] = fn;
1233
+ getOrCreateParser().setFunctions(__tastyParseFunctions);
1234
+ }
1235
+ function resetGlobalParseFunctions() {
1236
+ for (const key of Object.keys(__tastyParseFunctions)) delete __tastyParseFunctions[key];
1237
+ registerDefaultFunctions();
1238
+ getOrCreateParser().setFunctions(__tastyParseFunctions);
1239
+ }
1240
+ function getGlobalParser() {
1241
+ return getOrCreateParser();
1242
+ }
1243
+ function getGlobalParseFunctions() {
1244
+ return __tastyParseFunctions;
1245
+ }
1246
+ const DEFAULT_PREDEFINED_TOKENS = { "#clear": "transparent" };
1247
+ let __globalPredefinedTokens = { ...DEFAULT_PREDEFINED_TOKENS };
1248
+ function setGlobalPredefinedTokens(tokens) {
1249
+ const normalizedTokens = {};
1250
+ for (const [key, value] of Object.entries(tokens)) {
1251
+ const lowerKey = key.toLowerCase();
1252
+ const lowerValue = value.toLowerCase();
1253
+ if (lowerKey.startsWith("#") && lowerValue === "#current") {
1254
+ if (process.env.NODE_ENV !== "production") console.warn(`[Tasty] Using #current to define color token "${key}" is not supported. The #current token represents currentcolor which cannot be used as a base for other tokens.`);
1255
+ continue;
1256
+ }
1257
+ normalizedTokens[lowerKey] = value;
1258
+ }
1259
+ __globalPredefinedTokens = {
1260
+ ...__globalPredefinedTokens,
1261
+ ...normalizedTokens
1262
+ };
1263
+ getOrCreateParser().clearCache();
1264
+ }
1265
+ function getGlobalPredefinedTokens() {
1266
+ return __globalPredefinedTokens;
1267
+ }
1268
+ function resetGlobalPredefinedTokens() {
1269
+ __globalPredefinedTokens = { ...DEFAULT_PREDEFINED_TOKENS };
1270
+ getOrCreateParser().clearCache();
1271
+ }
1272
+ function parseStyle(value) {
1273
+ let str;
1274
+ if (typeof value === "string") str = value;
1275
+ else if (typeof value === "number") str = String(value);
1276
+ else str = "";
1277
+ return getOrCreateParser().process(str);
1278
+ }
1279
+ const RE_CUSTOM_PROPERTY_REF = /\$[a-zA-Z_$]/;
1280
+ function resolveCustomProperties(value) {
1281
+ if (!RE_CUSTOM_PROPERTY_REF.test(value)) return value;
1282
+ return parseStyle(value).output || value;
1283
+ }
1284
+ function parseColor(val, ignoreError = false) {
1285
+ if (typeof val !== "string") val = String(val ?? "");
1286
+ val = val.trim();
1287
+ if (!val) return {};
1288
+ const isSimpleColor = isSimpleColorFast(val);
1289
+ let firstColor;
1290
+ if (isSimpleColor) firstColor = val;
1291
+ else {
1292
+ const extractedColor = parseStyle(val).groups.find((g) => g.colors.length)?.colors[0];
1293
+ if (!extractedColor) {
1294
+ if (!ignoreError && devMode && colorWarningCount < MAX_COLOR_WARNINGS) {
1295
+ console.warn("[Tasty] unable to parse color:", val);
1296
+ colorWarningCount++;
1297
+ if (colorWarningCount === MAX_COLOR_WARNINGS) console.warn("[Tasty] color parsing warnings will be suppressed from now on");
1298
+ }
1299
+ return {};
1300
+ }
1301
+ firstColor = extractedColor;
1302
+ }
1303
+ const faded = parseAlphaMix(firstColor);
1304
+ const baseColor = faded ? faded.color : firstColor;
1305
+ const nameMatch = baseColor.match(COLOR_VAR_PATTERN);
1306
+ let opacity;
1307
+ if (faded) {
1308
+ const v = parseFloat(faded.percentage);
1309
+ if (!isNaN(v)) opacity = v;
1310
+ } else if (baseColor.startsWith("rgb") || baseColor.startsWith("hsl") || baseColor.startsWith("lch") || baseColor.startsWith("oklch")) {
1311
+ const alphaMatch = baseColor.match(RGB_ALPHA_PATTERN);
1312
+ if (alphaMatch) {
1313
+ const v = parseFloat(alphaMatch[1]);
1314
+ if (!isNaN(v)) opacity = v * 100;
1315
+ }
1316
+ }
1317
+ return {
1318
+ color: firstColor,
1319
+ name: nameMatch ? nameMatch[1] : void 0,
1320
+ opacity
1321
+ };
1322
+ }
1323
+ function filterMods(mods, allowedMods) {
1324
+ const filtered = [];
1325
+ for (const mod of mods) if (allowedMods.includes(mod)) filtered.push(mod);
1326
+ return filtered;
1327
+ }
1328
+ const _innerCache = /* @__PURE__ */ new WeakMap();
1329
+ const _topLevelCache = /* @__PURE__ */ new WeakMap();
1330
+ function stringifyStyles(styles) {
1331
+ if (styles == null || typeof styles !== "object") return "";
1332
+ const cached = _topLevelCache.get(styles);
1333
+ if (cached !== void 0) return cached;
1334
+ const obj = styles;
1335
+ const keys = Object.keys(obj).sort();
1336
+ const parts = [];
1337
+ for (const k of keys) {
1338
+ const v = obj[k];
1339
+ if (v === void 0 || typeof v === "function" || typeof v === "symbol") continue;
1340
+ const c0 = k.charCodeAt(0);
1341
+ const needsInnerSort = (c0 >= 65 && c0 <= 90 || c0 === 38) && v && typeof v === "object" && !Array.isArray(v);
1342
+ let sv;
1343
+ if (needsInnerSort) {
1344
+ sv = _innerCache.get(v);
1345
+ if (sv === void 0) {
1346
+ const innerObj = v;
1347
+ const innerKeys = Object.keys(innerObj).sort();
1348
+ const innerParts = [];
1349
+ for (const ik of innerKeys) {
1350
+ const ivs = JSON.stringify(innerObj[ik]);
1351
+ if (ivs !== void 0) innerParts.push(JSON.stringify(ik) + ":" + ivs);
1352
+ }
1353
+ sv = "{" + innerParts.join(",") + "}";
1354
+ _innerCache.set(v, sv);
1355
+ }
1356
+ } else sv = JSON.stringify(v);
1357
+ parts.push(JSON.stringify(k) + ":" + sv);
1358
+ }
1359
+ const result = "{" + parts.join(",") + "}";
1360
+ _topLevelCache.set(styles, result);
1361
+ return result;
1362
+ }
1363
+ //#endregion
1364
+ //#region src/utils/function-color.ts
1365
+ const RE_FUNC_NAME = /^([a-z][a-z0-9-]*)\s*\(/i;
1366
+ const RE_COLOR_OUT = /^(?:rgb|hsl|hwb|lab|lch|oklab|oklch|color)\(|^#|^var\(--/i;
1367
+ function resolveFunctionColor(str) {
1368
+ const m = RE_FUNC_NAME.exec(str);
1369
+ if (!m) return null;
1370
+ const name = m[1].toLowerCase();
1371
+ getGlobalParser();
1372
+ if (!(name in getGlobalParseFunctions())) return null;
1373
+ const out = getGlobalParser().process(str).output;
1374
+ if (!out || !RE_COLOR_OUT.test(out)) return null;
1375
+ return out;
1376
+ }
1377
+ //#endregion
1378
+ //#region src/utils/colors.ts
1379
+ function color(name, opacity = 1) {
1380
+ if (opacity !== 1) return mixColorAlpha(`var(--${name}-color)`, alphaToPercentage(opacity));
1381
+ return `var(--${name}-color)`;
1382
+ }
1383
+ //#endregion
1384
+ export { isColorKeyword as A, StyleParser as C, getRgbValuesFromRgbaString as D, getNamedColorHex as E, RE_NUMBER as F, RE_RAW_UNIT as I, normalizeDslName as M, toSnakeCase as N, hexToRgb as O, CSS_WIDE_KEYWORDS as P, createColorFunc as S, makeEmptyDetails as T, stringifyStyles as _, customFunction as a, okhslFunction as b, getGlobalParser as c, parseColor as d, parseStyle as f, setGlobalPredefinedTokens as g, resolveCustomProperties as h, DIRECTIONS as i, strToRgb as j, hslToRgbValues as k, getGlobalPredefinedTokens as l, resetGlobalPredefinedTokens as m, resolveFunctionColor as n, filterMods as o, resetGlobalParseFunctions as p, CUSTOM_UNITS as r, getGlobalParseFunctions as s, color as t, normalizeColorTokenValue as u, okhstFunction as v, Lru as w, okhslPlugin as x, okhstPlugin as y };
1385
+
1386
+ //# sourceMappingURL=dsl-rgu6XQcD.js.map