@fluixi-css/core 0.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/base.css +4 -0
  4. package/components.css +1 -0
  5. package/dist/base.css +4 -0
  6. package/dist/components.css +1 -0
  7. package/dist/index.css +2 -0
  8. package/dist/package.json +139 -0
  9. package/dist/reset.css +168 -0
  10. package/dist/src/ast.d.ts +298 -0
  11. package/dist/src/ast.js +2240 -0
  12. package/dist/src/ast.js.map +1 -0
  13. package/dist/src/commons/constants.d.ts +1193 -0
  14. package/dist/src/commons/constants.js +1323 -0
  15. package/dist/src/commons/constants.js.map +1 -0
  16. package/dist/src/commons/helper.d.ts +1298 -0
  17. package/dist/src/commons/helper.js +1310 -0
  18. package/dist/src/commons/helper.js.map +1 -0
  19. package/dist/src/commons/index.d.ts +3 -0
  20. package/dist/src/commons/index.js +4 -0
  21. package/dist/src/commons/index.js.map +1 -0
  22. package/dist/src/commons/properties.d.ts +1431 -0
  23. package/dist/src/commons/properties.js +2855 -0
  24. package/dist/src/commons/properties.js.map +1 -0
  25. package/dist/src/commons/types.d.ts +359 -0
  26. package/dist/src/commons/types.js +4 -0
  27. package/dist/src/commons/types.js.map +1 -0
  28. package/dist/src/components/avatar/index.d.ts +19 -0
  29. package/dist/src/components/avatar/index.js +22 -0
  30. package/dist/src/components/avatar/index.js.map +1 -0
  31. package/dist/src/components/button/index.d.ts +48 -0
  32. package/dist/src/components/button/index.js +51 -0
  33. package/dist/src/components/button/index.js.map +1 -0
  34. package/dist/src/components/card/index.d.ts +44 -0
  35. package/dist/src/components/card/index.js +47 -0
  36. package/dist/src/components/card/index.js.map +1 -0
  37. package/dist/src/components/checkbox/index.d.ts +69 -0
  38. package/dist/src/components/checkbox/index.js +80 -0
  39. package/dist/src/components/checkbox/index.js.map +1 -0
  40. package/dist/src/components/daterangepicker/index.d.ts +147 -0
  41. package/dist/src/components/daterangepicker/index.js +150 -0
  42. package/dist/src/components/daterangepicker/index.js.map +1 -0
  43. package/dist/src/components/dialog/index.d.ts +71 -0
  44. package/dist/src/components/dialog/index.js +74 -0
  45. package/dist/src/components/dialog/index.js.map +1 -0
  46. package/dist/src/components/drawer/index.d.ts +26 -0
  47. package/dist/src/components/drawer/index.js +29 -0
  48. package/dist/src/components/drawer/index.js.map +1 -0
  49. package/dist/src/components/dropdown/index.d.ts +101 -0
  50. package/dist/src/components/dropdown/index.js +104 -0
  51. package/dist/src/components/dropdown/index.js.map +1 -0
  52. package/dist/src/components/forms/index.d.ts +58 -0
  53. package/dist/src/components/forms/index.js +62 -0
  54. package/dist/src/components/forms/index.js.map +1 -0
  55. package/dist/src/components/index.d.ts +1228 -0
  56. package/dist/src/components/index.js +64 -0
  57. package/dist/src/components/index.js.map +1 -0
  58. package/dist/src/components/layout/index.d.ts +28 -0
  59. package/dist/src/components/layout/index.js +33 -0
  60. package/dist/src/components/layout/index.js.map +1 -0
  61. package/dist/src/components/list/index.d.ts +65 -0
  62. package/dist/src/components/list/index.js +68 -0
  63. package/dist/src/components/list/index.js.map +1 -0
  64. package/dist/src/components/popover/index.d.ts +79 -0
  65. package/dist/src/components/popover/index.js +82 -0
  66. package/dist/src/components/popover/index.js.map +1 -0
  67. package/dist/src/components/radio/index.d.ts +77 -0
  68. package/dist/src/components/radio/index.js +80 -0
  69. package/dist/src/components/radio/index.js.map +1 -0
  70. package/dist/src/components/select/index.d.ts +102 -0
  71. package/dist/src/components/select/index.js +105 -0
  72. package/dist/src/components/select/index.js.map +1 -0
  73. package/dist/src/components/sidenav/index.d.ts +98 -0
  74. package/dist/src/components/sidenav/index.js +101 -0
  75. package/dist/src/components/sidenav/index.js.map +1 -0
  76. package/dist/src/components/table/index.d.ts +95 -0
  77. package/dist/src/components/table/index.js +98 -0
  78. package/dist/src/components/table/index.js.map +1 -0
  79. package/dist/src/constants.d.ts +3 -0
  80. package/dist/src/constants.js +29 -0
  81. package/dist/src/constants.js.map +1 -0
  82. package/dist/src/css-ast.d.ts +48 -0
  83. package/dist/src/css-ast.js +2 -0
  84. package/dist/src/css-ast.js.map +1 -0
  85. package/dist/src/css-generator.d.ts +29 -0
  86. package/dist/src/css-generator.js +104 -0
  87. package/dist/src/css-generator.js.map +1 -0
  88. package/dist/src/css-helpers.d.ts +76 -0
  89. package/dist/src/css-helpers.js +272 -0
  90. package/dist/src/css-helpers.js.map +1 -0
  91. package/dist/src/css-lexer.d.ts +48 -0
  92. package/dist/src/css-lexer.js +255 -0
  93. package/dist/src/css-lexer.js.map +1 -0
  94. package/dist/src/css-parser.cjs +2047 -0
  95. package/dist/src/css-parser.cjs.map +1 -0
  96. package/dist/src/css-parser.d.ts +100 -0
  97. package/dist/src/css-parser.js +1098 -0
  98. package/dist/src/css-parser.js.map +1 -0
  99. package/dist/src/css-parser.mjs +2028 -0
  100. package/dist/src/css-parser.mjs.map +1 -0
  101. package/dist/src/design-system.d.ts +210 -0
  102. package/dist/src/design-system.js +1034 -0
  103. package/dist/src/design-system.js.map +1 -0
  104. package/dist/src/engine/ast.d.ts +44 -0
  105. package/dist/src/engine/ast.js +92 -0
  106. package/dist/src/engine/ast.js.map +1 -0
  107. package/dist/src/engine/atom.d.ts +74 -0
  108. package/dist/src/engine/atom.js +227 -0
  109. package/dist/src/engine/atom.js.map +1 -0
  110. package/dist/src/engine/compile.d.ts +5 -0
  111. package/dist/src/engine/compile.js +79 -0
  112. package/dist/src/engine/compile.js.map +1 -0
  113. package/dist/src/engine/defaults.d.ts +2 -0
  114. package/dist/src/engine/defaults.js +14 -0
  115. package/dist/src/engine/defaults.js.map +1 -0
  116. package/dist/src/engine/directives.d.ts +2 -0
  117. package/dist/src/engine/directives.js +191 -0
  118. package/dist/src/engine/directives.js.map +1 -0
  119. package/dist/src/engine/index.d.ts +41 -0
  120. package/dist/src/engine/index.js +88 -0
  121. package/dist/src/engine/index.js.map +1 -0
  122. package/dist/src/engine/registry.d.ts +46 -0
  123. package/dist/src/engine/registry.js +49 -0
  124. package/dist/src/engine/registry.js.map +1 -0
  125. package/dist/src/engine/scanner.d.ts +1 -0
  126. package/dist/src/engine/scanner.js +45 -0
  127. package/dist/src/engine/scanner.js.map +1 -0
  128. package/dist/src/engine/source.d.ts +12 -0
  129. package/dist/src/engine/source.js +81 -0
  130. package/dist/src/engine/source.js.map +1 -0
  131. package/dist/src/engine/theme-defaults.d.ts +2 -0
  132. package/dist/src/engine/theme-defaults.js +54 -0
  133. package/dist/src/engine/theme-defaults.js.map +1 -0
  134. package/dist/src/engine/theme-source.d.ts +5 -0
  135. package/dist/src/engine/theme-source.js +71 -0
  136. package/dist/src/engine/theme-source.js.map +1 -0
  137. package/dist/src/engine/theme.d.ts +10 -0
  138. package/dist/src/engine/theme.js +42 -0
  139. package/dist/src/engine/theme.js.map +1 -0
  140. package/dist/src/engine/transform.d.ts +25 -0
  141. package/dist/src/engine/transform.js +91 -0
  142. package/dist/src/engine/transform.js.map +1 -0
  143. package/dist/src/engine/ui-preset.d.ts +4 -0
  144. package/dist/src/engine/ui-preset.js +56 -0
  145. package/dist/src/engine/ui-preset.js.map +1 -0
  146. package/dist/src/engine/utilities/backgrounds.d.ts +2 -0
  147. package/dist/src/engine/utilities/backgrounds.js +32 -0
  148. package/dist/src/engine/utilities/backgrounds.js.map +1 -0
  149. package/dist/src/engine/utilities/borders.d.ts +2 -0
  150. package/dist/src/engine/utilities/borders.js +95 -0
  151. package/dist/src/engine/utilities/borders.js.map +1 -0
  152. package/dist/src/engine/utilities/effects.d.ts +2 -0
  153. package/dist/src/engine/utilities/effects.js +61 -0
  154. package/dist/src/engine/utilities/effects.js.map +1 -0
  155. package/dist/src/engine/utilities/flexgrid.d.ts +2 -0
  156. package/dist/src/engine/utilities/flexgrid.js +125 -0
  157. package/dist/src/engine/utilities/flexgrid.js.map +1 -0
  158. package/dist/src/engine/utilities/index.d.ts +3 -0
  159. package/dist/src/engine/utilities/index.js +20 -0
  160. package/dist/src/engine/utilities/index.js.map +1 -0
  161. package/dist/src/engine/utilities/layout.d.ts +2 -0
  162. package/dist/src/engine/utilities/layout.js +84 -0
  163. package/dist/src/engine/utilities/layout.js.map +1 -0
  164. package/dist/src/engine/utilities/sizing.d.ts +2 -0
  165. package/dist/src/engine/utilities/sizing.js +21 -0
  166. package/dist/src/engine/utilities/sizing.js.map +1 -0
  167. package/dist/src/engine/utilities/spacing.d.ts +2 -0
  168. package/dist/src/engine/utilities/spacing.js +39 -0
  169. package/dist/src/engine/utilities/spacing.js.map +1 -0
  170. package/dist/src/engine/utilities/typography.d.ts +2 -0
  171. package/dist/src/engine/utilities/typography.js +120 -0
  172. package/dist/src/engine/utilities/typography.js.map +1 -0
  173. package/dist/src/engine/utilities/values.d.ts +16 -0
  174. package/dist/src/engine/utilities/values.js +91 -0
  175. package/dist/src/engine/utilities/values.js.map +1 -0
  176. package/dist/src/engine/variants.d.ts +2 -0
  177. package/dist/src/engine/variants.js +99 -0
  178. package/dist/src/engine/variants.js.map +1 -0
  179. package/dist/src/extractor.d.ts +146 -0
  180. package/dist/src/extractor.js +3862 -0
  181. package/dist/src/extractor.js.map +1 -0
  182. package/dist/src/index.cjs +4518 -0
  183. package/dist/src/index.cjs.map +1 -0
  184. package/dist/src/index.d.ts +1 -0
  185. package/dist/src/index.js +9 -0
  186. package/dist/src/index.js.map +1 -0
  187. package/dist/src/index.mjs +4480 -0
  188. package/dist/src/index.mjs.map +1 -0
  189. package/dist/src/keyframes.cjs +367 -0
  190. package/dist/src/keyframes.cjs.map +1 -0
  191. package/dist/src/keyframes.d.ts +27 -0
  192. package/dist/src/keyframes.js +188 -0
  193. package/dist/src/keyframes.js.map +1 -0
  194. package/dist/src/keyframes.mjs +362 -0
  195. package/dist/src/keyframes.mjs.map +1 -0
  196. package/dist/src/logger.d.ts +2 -0
  197. package/dist/src/logger.js +31 -0
  198. package/dist/src/logger.js.map +1 -0
  199. package/dist/src/plugin.cjs +43 -0
  200. package/dist/src/plugin.cjs.map +1 -0
  201. package/dist/src/plugin.d.ts +12 -0
  202. package/dist/src/plugin.js +39 -0
  203. package/dist/src/plugin.js.map +1 -0
  204. package/dist/src/plugin.mjs +41 -0
  205. package/dist/src/plugin.mjs.map +1 -0
  206. package/dist/src/presets-plugins.cjs +99 -0
  207. package/dist/src/presets-plugins.cjs.map +1 -0
  208. package/dist/src/presets-plugins.d.ts +1 -0
  209. package/dist/src/presets-plugins.js +56 -0
  210. package/dist/src/presets-plugins.js.map +1 -0
  211. package/dist/src/presets-plugins.mjs +97 -0
  212. package/dist/src/presets-plugins.mjs.map +1 -0
  213. package/dist/src/state.d.ts +76 -0
  214. package/dist/src/state.js +314 -0
  215. package/dist/src/state.js.map +1 -0
  216. package/dist/src/theme/constants.d.ts +22 -0
  217. package/dist/src/theme/constants.js +17 -0
  218. package/dist/src/theme/constants.js.map +1 -0
  219. package/dist/src/theme/index.d.ts +2 -0
  220. package/dist/src/theme/index.js +48 -0
  221. package/dist/src/theme/index.js.map +1 -0
  222. package/dist/src/theme/types.d.ts +13 -0
  223. package/dist/src/theme/types.js +2 -0
  224. package/dist/src/theme/types.js.map +1 -0
  225. package/dist/src/types/ast.d.ts +23 -0
  226. package/dist/src/types/ast.js +2 -0
  227. package/dist/src/types/ast.js.map +1 -0
  228. package/dist/src/types/base-types.d.ts +53 -0
  229. package/dist/src/types/base-types.js +2 -0
  230. package/dist/src/types/base-types.js.map +1 -0
  231. package/dist/src/types/components-types.d.ts +28 -0
  232. package/dist/src/types/components-types.js +2 -0
  233. package/dist/src/types/components-types.js.map +1 -0
  234. package/dist/src/types/config.d.ts +90 -0
  235. package/dist/src/types/config.js +3 -0
  236. package/dist/src/types/config.js.map +1 -0
  237. package/dist/src/types/css-parser.d.ts +361 -0
  238. package/dist/src/types/css-parser.js +2 -0
  239. package/dist/src/types/css-parser.js.map +1 -0
  240. package/dist/src/types/keyframes-type.d.ts +47 -0
  241. package/dist/src/types/keyframes-type.js +2 -0
  242. package/dist/src/types/keyframes-type.js.map +1 -0
  243. package/dist/src/types/plugin.d.ts +10 -0
  244. package/dist/src/types/plugin.js +2 -0
  245. package/dist/src/types/plugin.js.map +1 -0
  246. package/dist/src/types/screens-types.d.ts +47 -0
  247. package/dist/src/types/screens-types.js +2 -0
  248. package/dist/src/types/screens-types.js.map +1 -0
  249. package/dist/src/types/utilities-types.d.ts +147 -0
  250. package/dist/src/types/utilities-types.js +2 -0
  251. package/dist/src/types/utilities-types.js.map +1 -0
  252. package/dist/src/types.d.ts +77 -0
  253. package/dist/src/types.js +12 -0
  254. package/dist/src/types.js.map +1 -0
  255. package/dist/src/units/constants.d.ts +35 -0
  256. package/dist/src/units/constants.js +9 -0
  257. package/dist/src/units/constants.js.map +1 -0
  258. package/dist/src/units/index.d.ts +15 -0
  259. package/dist/src/units/index.js +7 -0
  260. package/dist/src/units/index.js.map +1 -0
  261. package/dist/src/units/types.d.ts +9 -0
  262. package/dist/src/units/types.js +2 -0
  263. package/dist/src/units/types.js.map +1 -0
  264. package/dist/src/utilities/backgrounds/constants.d.ts +2810 -0
  265. package/dist/src/utilities/backgrounds/constants.js +119 -0
  266. package/dist/src/utilities/backgrounds/constants.js.map +1 -0
  267. package/dist/src/utilities/backgrounds/index.d.ts +1 -0
  268. package/dist/src/utilities/backgrounds/index.js +2 -0
  269. package/dist/src/utilities/backgrounds/index.js.map +1 -0
  270. package/dist/src/utilities/borders/constants.d.ts +10586 -0
  271. package/dist/src/utilities/borders/constants.js +309 -0
  272. package/dist/src/utilities/borders/constants.js.map +1 -0
  273. package/dist/src/utilities/borders/index.d.ts +1 -0
  274. package/dist/src/utilities/borders/index.js +2 -0
  275. package/dist/src/utilities/borders/index.js.map +1 -0
  276. package/dist/src/utilities/breakpoints/constants.d.ts +330 -0
  277. package/dist/src/utilities/breakpoints/constants.js +269 -0
  278. package/dist/src/utilities/breakpoints/constants.js.map +1 -0
  279. package/dist/src/utilities/breakpoints/index.d.ts +2 -0
  280. package/dist/src/utilities/breakpoints/index.js +3 -0
  281. package/dist/src/utilities/breakpoints/index.js.map +1 -0
  282. package/dist/src/utilities/breakpoints/types.d.ts +8 -0
  283. package/dist/src/utilities/breakpoints/types.js +2 -0
  284. package/dist/src/utilities/breakpoints/types.js.map +1 -0
  285. package/dist/src/utilities/colors/base.d.ts +778 -0
  286. package/dist/src/utilities/colors/base.js +872 -0
  287. package/dist/src/utilities/colors/base.js.map +1 -0
  288. package/dist/src/utilities/colors/color.d.ts +1122 -0
  289. package/dist/src/utilities/colors/color.js +957 -0
  290. package/dist/src/utilities/colors/color.js.map +1 -0
  291. package/dist/src/utilities/colors/constants.d.ts +1 -0
  292. package/dist/src/utilities/colors/constants.js +2 -0
  293. package/dist/src/utilities/colors/constants.js.map +1 -0
  294. package/dist/src/utilities/colors/index.d.ts +4 -0
  295. package/dist/src/utilities/colors/index.js +29 -0
  296. package/dist/src/utilities/colors/index.js.map +1 -0
  297. package/dist/src/utilities/colors/types.d.ts +3 -0
  298. package/dist/src/utilities/colors/types.js +2 -0
  299. package/dist/src/utilities/colors/types.js.map +1 -0
  300. package/dist/src/utilities/effects/constants.d.ts +641 -0
  301. package/dist/src/utilities/effects/constants.js +83 -0
  302. package/dist/src/utilities/effects/constants.js.map +1 -0
  303. package/dist/src/utilities/effects/index.d.ts +1 -0
  304. package/dist/src/utilities/effects/index.js +2 -0
  305. package/dist/src/utilities/effects/index.js.map +1 -0
  306. package/dist/src/utilities/filters/constants.d.ts +406 -0
  307. package/dist/src/utilities/filters/constants.js +206 -0
  308. package/dist/src/utilities/filters/constants.js.map +1 -0
  309. package/dist/src/utilities/filters/index.d.ts +1 -0
  310. package/dist/src/utilities/filters/index.js +2 -0
  311. package/dist/src/utilities/filters/index.js.map +1 -0
  312. package/dist/src/utilities/flex/constants.d.ts +934 -0
  313. package/dist/src/utilities/flex/constants.js +221 -0
  314. package/dist/src/utilities/flex/constants.js.map +1 -0
  315. package/dist/src/utilities/flex/index.d.ts +1 -0
  316. package/dist/src/utilities/flex/index.js +2 -0
  317. package/dist/src/utilities/flex/index.js.map +1 -0
  318. package/dist/src/utilities/flex/types.d.ts +0 -0
  319. package/dist/src/utilities/flex/types.js +4 -0
  320. package/dist/src/utilities/flex/types.js.map +1 -0
  321. package/dist/src/utilities/index.d.ts +31338 -0
  322. package/dist/src/utilities/index.js +333 -0
  323. package/dist/src/utilities/index.js.map +1 -0
  324. package/dist/src/utilities/interactivity/constants.d.ts +1244 -0
  325. package/dist/src/utilities/interactivity/constants.js +165 -0
  326. package/dist/src/utilities/interactivity/constants.js.map +1 -0
  327. package/dist/src/utilities/interactivity/index.d.ts +1 -0
  328. package/dist/src/utilities/interactivity/index.js +2 -0
  329. package/dist/src/utilities/interactivity/index.js.map +1 -0
  330. package/dist/src/utilities/layout/constants.d.ts +837 -0
  331. package/dist/src/utilities/layout/constants.js +159 -0
  332. package/dist/src/utilities/layout/constants.js.map +1 -0
  333. package/dist/src/utilities/layout/index.d.ts +1 -0
  334. package/dist/src/utilities/layout/index.js +2 -0
  335. package/dist/src/utilities/layout/index.js.map +1 -0
  336. package/dist/src/utilities/layout/types.d.ts +0 -0
  337. package/dist/src/utilities/layout/types.js +2 -0
  338. package/dist/src/utilities/layout/types.js.map +1 -0
  339. package/dist/src/utilities/sizing/constants.d.ts +989 -0
  340. package/dist/src/utilities/sizing/constants.js +53 -0
  341. package/dist/src/utilities/sizing/constants.js.map +1 -0
  342. package/dist/src/utilities/sizing/index.d.ts +2 -0
  343. package/dist/src/utilities/sizing/index.js +3 -0
  344. package/dist/src/utilities/sizing/index.js.map +1 -0
  345. package/dist/src/utilities/sizing/types.d.ts +10 -0
  346. package/dist/src/utilities/sizing/types.js +2 -0
  347. package/dist/src/utilities/sizing/types.js.map +1 -0
  348. package/dist/src/utilities/spacing/constants.d.ts +1779 -0
  349. package/dist/src/utilities/spacing/constants.js +142 -0
  350. package/dist/src/utilities/spacing/constants.js.map +1 -0
  351. package/dist/src/utilities/spacing/index.d.ts +2 -0
  352. package/dist/src/utilities/spacing/index.js +3 -0
  353. package/dist/src/utilities/spacing/index.js.map +1 -0
  354. package/dist/src/utilities/spacing/types.d.ts +15 -0
  355. package/dist/src/utilities/spacing/types.js +8 -0
  356. package/dist/src/utilities/spacing/types.js.map +1 -0
  357. package/dist/src/utilities/svg/constants.d.ts +1062 -0
  358. package/dist/src/utilities/svg/constants.js +34 -0
  359. package/dist/src/utilities/svg/constants.js.map +1 -0
  360. package/dist/src/utilities/transforms/constants.d.ts +247 -0
  361. package/dist/src/utilities/transforms/constants.js +74 -0
  362. package/dist/src/utilities/transforms/constants.js.map +1 -0
  363. package/dist/src/utilities/transforms/index.d.ts +1 -0
  364. package/dist/src/utilities/transforms/index.js +2 -0
  365. package/dist/src/utilities/transforms/index.js.map +1 -0
  366. package/dist/src/utilities/transitions/constants.d.ts +116 -0
  367. package/dist/src/utilities/transitions/constants.js +91 -0
  368. package/dist/src/utilities/transitions/constants.js.map +1 -0
  369. package/dist/src/utilities/transitions/index.d.ts +1 -0
  370. package/dist/src/utilities/transitions/index.js +2 -0
  371. package/dist/src/utilities/transitions/index.js.map +1 -0
  372. package/dist/src/utilities/typography/constants.d.ts +2401 -0
  373. package/dist/src/utilities/typography/constants.js +401 -0
  374. package/dist/src/utilities/typography/constants.js.map +1 -0
  375. package/dist/src/utilities/typography/index.d.ts +1 -0
  376. package/dist/src/utilities/typography/index.js +2 -0
  377. package/dist/src/utilities/typography/index.js.map +1 -0
  378. package/dist/src/utils.d.ts +18 -0
  379. package/dist/src/utils.js +282 -0
  380. package/dist/src/utils.js.map +1 -0
  381. package/dist/src/watcher.d.ts +15 -0
  382. package/dist/src/watcher.js +62 -0
  383. package/dist/src/watcher.js.map +1 -0
  384. package/dist/tsconfig.tsbuildinfo +1 -0
  385. package/dist/utilities.css +1 -0
  386. package/index.css +2 -0
  387. package/package.json +139 -0
  388. package/reset.css +168 -0
  389. package/utilities.css +1 -0
@@ -0,0 +1,4480 @@
1
+ import { SourceMapGenerator } from 'source-map';
2
+ import fs from 'node:fs';
3
+ import path from 'node:path';
4
+ import fg from 'fast-glob';
5
+
6
+ function _arrayLikeToArray(r, a) {
7
+ (null == a || a > r.length) && (a = r.length);
8
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
9
+ return n;
10
+ }
11
+ function _arrayWithHoles(r) {
12
+ if (Array.isArray(r)) return r;
13
+ }
14
+ function _arrayWithoutHoles(r) {
15
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
16
+ }
17
+ function _classCallCheck(a, n) {
18
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
19
+ }
20
+ function _defineProperties(e, r) {
21
+ for (var t = 0; t < r.length; t++) {
22
+ var o = r[t];
23
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
24
+ }
25
+ }
26
+ function _createClass(e, r, t) {
27
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
28
+ writable: false
29
+ }), e;
30
+ }
31
+ function _createForOfIteratorHelper(r, e) {
32
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
33
+ if (!t) {
34
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
35
+ t && (r = t);
36
+ var n = 0,
37
+ F = function () {};
38
+ return {
39
+ s: F,
40
+ n: function () {
41
+ return n >= r.length ? {
42
+ done: true
43
+ } : {
44
+ done: false,
45
+ value: r[n++]
46
+ };
47
+ },
48
+ e: function (r) {
49
+ throw r;
50
+ },
51
+ f: F
52
+ };
53
+ }
54
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
55
+ }
56
+ var o,
57
+ a = true,
58
+ u = false;
59
+ return {
60
+ s: function () {
61
+ t = t.call(r);
62
+ },
63
+ n: function () {
64
+ var r = t.next();
65
+ return a = r.done, r;
66
+ },
67
+ e: function (r) {
68
+ u = true, o = r;
69
+ },
70
+ f: function () {
71
+ try {
72
+ a || null == t.return || t.return();
73
+ } finally {
74
+ if (u) throw o;
75
+ }
76
+ }
77
+ };
78
+ }
79
+ function _defineProperty(e, r, t) {
80
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
81
+ value: t,
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true
85
+ }) : e[r] = t, e;
86
+ }
87
+ function _iterableToArray(r) {
88
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
89
+ }
90
+ function _iterableToArrayLimit(r, l) {
91
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
92
+ if (null != t) {
93
+ var e,
94
+ n,
95
+ i,
96
+ u,
97
+ a = [],
98
+ f = true,
99
+ o = false;
100
+ try {
101
+ if (i = (t = t.call(r)).next, 0 === l) {
102
+ if (Object(t) !== t) return;
103
+ f = !1;
104
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
105
+ } catch (r) {
106
+ o = true, n = r;
107
+ } finally {
108
+ try {
109
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
110
+ } finally {
111
+ if (o) throw n;
112
+ }
113
+ }
114
+ return a;
115
+ }
116
+ }
117
+ function _nonIterableRest() {
118
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
119
+ }
120
+ function _nonIterableSpread() {
121
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
122
+ }
123
+ function ownKeys(e, r) {
124
+ var t = Object.keys(e);
125
+ if (Object.getOwnPropertySymbols) {
126
+ var o = Object.getOwnPropertySymbols(e);
127
+ r && (o = o.filter(function (r) {
128
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
129
+ })), t.push.apply(t, o);
130
+ }
131
+ return t;
132
+ }
133
+ function _objectSpread2(e) {
134
+ for (var r = 1; r < arguments.length; r++) {
135
+ var t = null != arguments[r] ? arguments[r] : {};
136
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
137
+ _defineProperty(e, r, t[r]);
138
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
139
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
140
+ });
141
+ }
142
+ return e;
143
+ }
144
+ function _slicedToArray(r, e) {
145
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
146
+ }
147
+ function _toConsumableArray(r) {
148
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
149
+ }
150
+ function _toPrimitive(t, r) {
151
+ if ("object" != typeof t || !t) return t;
152
+ var e = t[Symbol.toPrimitive];
153
+ if (void 0 !== e) {
154
+ var i = e.call(t, r);
155
+ if ("object" != typeof i) return i;
156
+ throw new TypeError("@@toPrimitive must return a primitive value.");
157
+ }
158
+ return ("string" === r ? String : Number)(t);
159
+ }
160
+ function _toPropertyKey(t) {
161
+ var i = _toPrimitive(t, "string");
162
+ return "symbol" == typeof i ? i : i + "";
163
+ }
164
+ function _unsupportedIterableToArray(r, a) {
165
+ if (r) {
166
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
167
+ var t = {}.toString.call(r).slice(8, -1);
168
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
169
+ }
170
+ }
171
+
172
+ // Where a node came from in an input file. `line` is 1-based, `column` 0-based
173
+ // (the source-map convention). Set on passthrough nodes so `stringify` can emit
174
+ // a source map; generated utilities have no meaningful origin and leave it unset.
175
+
176
+ // Verbatim CSS the transform passes through from the input (author rules the
177
+ // engine doesn't model structurally). Emitted as-is; carries its origin `loc`.
178
+
179
+ function decl(property, value) {
180
+ var important = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
181
+ var loc = arguments.length > 3 ? arguments[3] : undefined;
182
+ return loc ? {
183
+ kind: 'declaration',
184
+ property: property,
185
+ value: value,
186
+ important: important,
187
+ loc: loc
188
+ } : {
189
+ kind: 'declaration',
190
+ property: property,
191
+ value: value,
192
+ important: important
193
+ };
194
+ }
195
+ function rule(selector, nodes, loc) {
196
+ return loc ? {
197
+ kind: 'rule',
198
+ selector: selector,
199
+ nodes: nodes,
200
+ loc: loc
201
+ } : {
202
+ kind: 'rule',
203
+ selector: selector,
204
+ nodes: nodes
205
+ };
206
+ }
207
+ function atRule(name, params, nodes, loc) {
208
+ return loc ? {
209
+ kind: 'at-rule',
210
+ name: name,
211
+ params: params,
212
+ nodes: nodes,
213
+ loc: loc
214
+ } : {
215
+ kind: 'at-rule',
216
+ name: name,
217
+ params: params,
218
+ nodes: nodes
219
+ };
220
+ }
221
+ function raw(text, loc) {
222
+ return loc ? {
223
+ kind: 'raw',
224
+ text: text,
225
+ loc: loc
226
+ } : {
227
+ kind: 'raw',
228
+ text: text
229
+ };
230
+ }
231
+ // Accumulates the output string while tracking the current line/column, so a node
232
+ // carrying a `loc` can be mapped to its origin. Without a map it's just a string
233
+ // builder — `stringify` and `stringifyWithMap` share one write path.
234
+ var Writer = /*#__PURE__*/function () {
235
+ function Writer(map) {
236
+ _classCallCheck(this, Writer);
237
+ _defineProperty(this, "css", '');
238
+ _defineProperty(this, "line", 1);
239
+ _defineProperty(this, "column", 0);
240
+ this.map = map;
241
+ }
242
+ return _createClass(Writer, [{
243
+ key: "emit",
244
+ value: function emit(text) {
245
+ this.css += text;
246
+ var nl = text.indexOf('\n');
247
+ if (nl === -1) {
248
+ this.column += text.length;
249
+ return;
250
+ }
251
+ var last = 0;
252
+ while (nl !== -1) {
253
+ this.line++;
254
+ last = nl + 1;
255
+ nl = text.indexOf('\n', last);
256
+ }
257
+ this.column = text.length - last;
258
+ }
259
+ }, {
260
+ key: "mark",
261
+ value: function mark(loc) {
262
+ if (this.map && loc) {
263
+ this.map.addMapping({
264
+ source: loc.source,
265
+ original: {
266
+ line: loc.line,
267
+ column: loc.column
268
+ },
269
+ generated: {
270
+ line: this.line,
271
+ column: this.column
272
+ }
273
+ });
274
+ }
275
+ }
276
+ }]);
277
+ }();
278
+ function stringify(nodes) {
279
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
280
+ var w = new Writer();
281
+ var _iterator = _createForOfIteratorHelper(nodes),
282
+ _step;
283
+ try {
284
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
285
+ var node = _step.value;
286
+ write(node, options.minify ? -1 : 0, options, w);
287
+ }
288
+ } catch (err) {
289
+ _iterator.e(err);
290
+ } finally {
291
+ _iterator.f();
292
+ }
293
+ return w.css;
294
+ }
295
+
296
+ // Like {@link stringify} but also returns a source map keyed on each node's `loc`.
297
+ function stringifyWithMap(nodes) {
298
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
299
+ var w = new Writer(new SourceMapGenerator());
300
+ var _iterator2 = _createForOfIteratorHelper(nodes),
301
+ _step2;
302
+ try {
303
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
304
+ var node = _step2.value;
305
+ write(node, options.minify ? -1 : 0, options, w);
306
+ }
307
+ } catch (err) {
308
+ _iterator2.e(err);
309
+ } finally {
310
+ _iterator2.f();
311
+ }
312
+ return {
313
+ css: w.css,
314
+ map: w.map
315
+ };
316
+ }
317
+ function write(node, depth, opts, w) {
318
+ var minify = depth < 0;
319
+ var pad = minify ? '' : ' '.repeat(depth);
320
+ var nl = minify ? '' : '\n';
321
+ var sp = minify ? '' : ' ';
322
+ if (node.kind === 'declaration') {
323
+ var bang = node.important ? "".concat(sp, "!important") : '';
324
+ w.emit(pad);
325
+ w.mark(node.loc);
326
+ w.emit("".concat(node.property, ":").concat(sp).concat(node.value).concat(bang, ";").concat(nl));
327
+ return;
328
+ }
329
+ if (node.kind === 'raw') {
330
+ w.emit(pad);
331
+ w.mark(node.loc);
332
+ w.emit("".concat(node.text).concat(nl));
333
+ return;
334
+ }
335
+ var header = node.kind === 'rule' ? node.selector : "@".concat(node.name).concat(node.params ? ' ' + node.params : '');
336
+ w.emit(pad);
337
+ w.mark(node.loc);
338
+ w.emit("".concat(header).concat(sp, "{").concat(nl));
339
+ var inner = minify ? -1 : depth + 1;
340
+ var _iterator3 = _createForOfIteratorHelper(node.nodes),
341
+ _step3;
342
+ try {
343
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
344
+ var child = _step3.value;
345
+ write(child, inner, opts, w);
346
+ }
347
+ } catch (err) {
348
+ _iterator3.e(err);
349
+ } finally {
350
+ _iterator3.f();
351
+ }
352
+ w.emit("".concat(pad, "}").concat(nl));
353
+ }
354
+
355
+ // Parses one raw utility (e.g. `md:hover:-bg-red-500/50!` or `[&_p]:text-[13px]`)
356
+ // into a structured Atom in a single pass. Splitting is bracket/paren aware,
357
+ // so `:` `/` `-` inside arbitrary values are left alone — no regex, no
358
+ // backtracking. Which part is the root and which is the value can't be known from
359
+ // the string alone (`text-red-500` vs `grid-cols-3`), so that split is resolved
360
+ // against the registry through AtomContext.
361
+
362
+ // Split on `sep` at depth 0 only; `[...]` and `(...)` are opaque, and `\` escapes
363
+ // the next character.
364
+ function splitAtTopLevel(input, sep) {
365
+ var out = [];
366
+ var depthBracket = 0;
367
+ var depthParen = 0;
368
+ var start = 0;
369
+ for (var i = 0; i < input.length; i++) {
370
+ var c = input[i];
371
+ if (c === '\\') {
372
+ i++; // skip the escaped char
373
+ continue;
374
+ }
375
+ if (c === '[') depthBracket++;else if (c === ']') depthBracket = Math.max(0, depthBracket - 1);else if (c === '(') depthParen++;else if (c === ')') depthParen = Math.max(0, depthParen - 1);else if (c === sep && depthBracket === 0 && depthParen === 0) {
376
+ out.push(input.slice(start, i));
377
+ start = i + 1;
378
+ }
379
+ }
380
+ out.push(input.slice(start));
381
+ return out;
382
+ }
383
+
384
+ // Content of a `[...]` or `(...)` wrapper, or null when `s` isn't wrapped.
385
+ function unwrap(s, open) {
386
+ var close = open === '[' ? ']' : ')';
387
+ return s.length >= 2 && s[0] === open && s[s.length - 1] === close ? s.slice(1, -1) : null;
388
+ }
389
+ function parseModifier(raw) {
390
+ if (!raw) return null;
391
+ var arb = unwrap(raw, '[');
392
+ if (arb !== null) return {
393
+ kind: 'arbitrary',
394
+ value: arb
395
+ };
396
+ // `(--name)` is shorthand for the custom property it references.
397
+ var paren = unwrap(raw, '(');
398
+ if (paren !== null) return {
399
+ kind: 'arbitrary',
400
+ value: "var(".concat(paren, ")")
401
+ };
402
+ return {
403
+ kind: 'named',
404
+ value: raw
405
+ };
406
+ }
407
+ function splitModifier(base) {
408
+ var parts = splitAtTopLevel(base, '/');
409
+ if (parts.length === 1) return {
410
+ base: base,
411
+ modifier: null
412
+ };
413
+ var modifier = parseModifier(parts.slice(1).join('/'));
414
+ return {
415
+ base: parts[0],
416
+ modifier: modifier
417
+ };
418
+ }
419
+
420
+ // In arbitrary values `_` stands in for a space; `\_` is a literal underscore.
421
+ function decodeUnderscores(value) {
422
+ return value.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
423
+ }
424
+
425
+ // An arbitrary value may lead with a `type:` hint, e.g. `[length:12px]`.
426
+ function parseArbitraryValue(body) {
427
+ var colon = body.indexOf(':');
428
+ if (colon > 0) {
429
+ var maybeType = body.slice(0, colon);
430
+ if (/^[a-z-]+$/.test(maybeType)) {
431
+ return {
432
+ dataType: maybeType,
433
+ value: decodeUnderscores(body.slice(colon + 1))
434
+ };
435
+ }
436
+ }
437
+ return {
438
+ dataType: null,
439
+ value: decodeUnderscores(body)
440
+ };
441
+ }
442
+
443
+ // The `(--name)` shorthand, optionally typed: `(length:--size)`. The custom
444
+ // property name keeps its underscores.
445
+ function parseParenValue(paren) {
446
+ var colon = paren.indexOf(':');
447
+ if (colon > 0 && /^[a-z-]+$/.test(paren.slice(0, colon))) {
448
+ return {
449
+ dataType: paren.slice(0, colon),
450
+ value: "var(".concat(paren.slice(colon + 1), ")")
451
+ };
452
+ }
453
+ return {
454
+ dataType: null,
455
+ value: "var(".concat(paren, ")")
456
+ };
457
+ }
458
+ function parseVariant(raw) {
459
+ var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
460
+ if (!raw) return null;
461
+
462
+ // `[&:hover]`, `[@media(...)]` — the selector is written out; a `&` means it's
463
+ // relative to the element.
464
+ var arb = unwrap(raw, '[');
465
+ if (arb !== null) {
466
+ return {
467
+ kind: 'arbitrary',
468
+ selector: arb,
469
+ relative: arb.includes('&')
470
+ };
471
+ }
472
+ var _splitModifier = splitModifier(raw),
473
+ base = _splitModifier.base,
474
+ modifier = _splitModifier.modifier;
475
+
476
+ // A variant carrying a value: `group-hover`, `data-[open]`, `supports-[display:grid]`.
477
+ var dash = base.indexOf('-');
478
+ if (dash > 0) {
479
+ var _ctx$isDynamicVariant, _ctx$isDynamicVariant2;
480
+ var _root = base.slice(0, dash);
481
+ var rest = base.slice(dash + 1);
482
+ if ((_ctx$isDynamicVariant = ctx.isDynamicVariant) !== null && _ctx$isDynamicVariant !== void 0 && _ctx$isDynamicVariant.call(ctx, _root) || (_ctx$isDynamicVariant2 = ctx.isDynamicVariant) !== null && _ctx$isDynamicVariant2 !== void 0 && _ctx$isDynamicVariant2.call(ctx, _root + '-')) {
483
+ // A variant's `[...]` is a raw condition/attribute, not a typed value.
484
+ var arbVal = unwrap(rest, '[');
485
+ var value = arbVal !== null ? {
486
+ kind: 'arbitrary',
487
+ value: arbVal,
488
+ dataType: null
489
+ } : {
490
+ kind: 'named',
491
+ value: rest
492
+ };
493
+ return {
494
+ kind: 'functional',
495
+ root: _root,
496
+ value: value,
497
+ modifier: modifier
498
+ };
499
+ }
500
+ }
501
+ return {
502
+ kind: 'functional',
503
+ root: base,
504
+ value: null,
505
+ modifier: modifier
506
+ };
507
+ }
508
+
509
+ // Returns null for structurally invalid input (empty or dangling segments).
510
+ // Without a context the root/value split falls back to the first dash, which is
511
+ // enough to test the scanner on its own.
512
+ function parseAtom(raw) {
513
+ var _ctx$isRule, _ctx$isRule2;
514
+ var ctx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
515
+ if (!raw) return null;
516
+ var segments = splitAtTopLevel(raw, ':');
517
+ var utility = segments.pop();
518
+ if (utility === undefined || utility === '') return null;
519
+ var variants = [];
520
+ var _iterator = _createForOfIteratorHelper(segments),
521
+ _step;
522
+ try {
523
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
524
+ var seg = _step.value;
525
+ if (seg === '') return null; // dangling `::`
526
+ var v = parseVariant(seg, ctx);
527
+ if (!v) return null;
528
+ variants.push(v);
529
+ }
530
+ // Written left-to-right (outermost first), stored innermost-first so consumers
531
+ // can wrap the declaration outward.
532
+ } catch (err) {
533
+ _iterator.e(err);
534
+ } finally {
535
+ _iterator.f();
536
+ }
537
+ variants.reverse();
538
+
539
+ // `!` marks important, accepted on either end.
540
+ var body = utility;
541
+ var important = false;
542
+ if (body.endsWith('!')) {
543
+ important = true;
544
+ body = body.slice(0, -1);
545
+ } else if (body.startsWith('!')) {
546
+ important = true;
547
+ body = body.slice(1);
548
+ }
549
+ if (body === '') return null;
550
+
551
+ // Split off a trailing `/modifier` once, up front — it applies uniformly to
552
+ // arbitrary-property, static, and functional atoms.
553
+ var _splitModifier2 = splitModifier(body),
554
+ core0 = _splitModifier2.base,
555
+ modifier = _splitModifier2.modifier;
556
+
557
+ // Arbitrary property: `[color:red]`, `[--my-var:0]` (optionally with modifier).
558
+ var arbProp = unwrap(core0, '[');
559
+ if (arbProp !== null && arbProp.includes(':')) {
560
+ var colon = arbProp.indexOf(':');
561
+ if (colon <= 0) return null;
562
+ return {
563
+ kind: 'arbitrary-property',
564
+ property: arbProp.slice(0, colon),
565
+ value: decodeUnderscores(arbProp.slice(colon + 1)),
566
+ modifier: modifier,
567
+ important: important,
568
+ variants: variants,
569
+ raw: raw
570
+ };
571
+ }
572
+
573
+ // Negative.
574
+ var negative = false;
575
+ var base = core0;
576
+ if (base[0] === '-') {
577
+ negative = true;
578
+ base = base.slice(1);
579
+ if (base === '') return null;
580
+ }
581
+
582
+ // Static utility (only when unambiguous: no negative/modifier).
583
+ if (!negative && modifier === null && (_ctx$isRule = ctx.isRule) !== null && _ctx$isRule !== void 0 && _ctx$isRule.call(ctx, base)) {
584
+ return {
585
+ kind: 'static',
586
+ root: base,
587
+ important: important,
588
+ variants: variants,
589
+ raw: raw
590
+ };
591
+ }
592
+
593
+ // Functional: split root ↔ value. Prefer the longest known functional root;
594
+ // fall back to the first-dash split when no context is supplied.
595
+ var _splitRootValue = splitRootValue(base, ctx),
596
+ root = _splitRootValue.root,
597
+ valueStr = _splitRootValue.valueStr;
598
+ if (root === '') return null;
599
+ var value = null;
600
+ if (valueStr !== null && valueStr !== '') {
601
+ var arbVal = unwrap(valueStr, '[');
602
+ if (arbVal !== null) {
603
+ value = _objectSpread2({
604
+ kind: 'arbitrary'
605
+ }, parseArbitraryValue(arbVal));
606
+ } else {
607
+ var paren = unwrap(valueStr, '(');
608
+ value = paren !== null ? _objectSpread2({
609
+ kind: 'arbitrary'
610
+ }, parseParenValue(paren)) : {
611
+ kind: 'named',
612
+ value: valueStr,
613
+ fraction: null
614
+ };
615
+ }
616
+ } else if ((_ctx$isRule2 = ctx.isRule) !== null && _ctx$isRule2 !== void 0 && _ctx$isRule2.call(ctx, base)) {
617
+ // A bare root that is registered static (reached here due to a modifier).
618
+ return {
619
+ kind: 'static',
620
+ root: base,
621
+ important: important,
622
+ variants: variants,
623
+ raw: raw
624
+ };
625
+ }
626
+ return {
627
+ kind: 'functional',
628
+ root: root,
629
+ value: value,
630
+ modifier: modifier,
631
+ important: important,
632
+ negative: negative,
633
+ variants: variants,
634
+ raw: raw
635
+ };
636
+ }
637
+
638
+ // Splits `bg-red-500` into a root and value. The longest registered root wins
639
+ // (`grid-cols-3` → `grid-cols` + `3`); with no context, split at the first dash.
640
+ function splitRootValue(base, ctx) {
641
+ if (ctx.isDynamicRule) {
642
+ // The whole class is itself the longest possible root (`rounded-t`, `border-x`);
643
+ // prefer it before splitting off a shorter registered prefix (`rounded` + `t`).
644
+ if (ctx.isDynamicRule(base)) return {
645
+ root: base,
646
+ valueStr: null
647
+ };
648
+ var dashes = [];
649
+ for (var i = 0; i < base.length; i++) if (base[i] === '-') dashes.push(i);
650
+ for (var d = dashes.length - 1; d >= 0; d--) {
651
+ var idx = dashes[d];
652
+ var _root2 = base.slice(0, idx);
653
+ if (ctx.isDynamicRule(_root2)) return {
654
+ root: _root2,
655
+ valueStr: base.slice(idx + 1)
656
+ };
657
+ }
658
+ }
659
+ var first = base.indexOf('-');
660
+ if (first <= 0) return {
661
+ root: base,
662
+ valueStr: null
663
+ };
664
+ return {
665
+ root: base.slice(0, first),
666
+ valueStr: base.slice(first + 1)
667
+ };
668
+ }
669
+
670
+ // The resolved token table. Every entry is a CSS custom property (`--color-red-500`,
671
+ // `--spacing`, `--breakpoint-md`, …); utilities read them by namespace and emit
672
+ // `var()` references, so the tokens stay live and themeable at runtime.
673
+
674
+ var Theme = /*#__PURE__*/function () {
675
+ function Theme() {
676
+ _classCallCheck(this, Theme);
677
+ _defineProperty(this, "values", new Map());
678
+ }
679
+ return _createClass(Theme, [{
680
+ key: "add",
681
+ value: function add(name, value) {
682
+ this.values.set(name, value);
683
+ return this;
684
+ }
685
+ }, {
686
+ key: "addAll",
687
+ value: function addAll(entries) {
688
+ for (var name in entries) this.add(name, entries[name]);
689
+ return this;
690
+ }
691
+ }, {
692
+ key: "get",
693
+ value: function get(name) {
694
+ return this.values.get(name);
695
+ }
696
+ }, {
697
+ key: "has",
698
+ value: function has(name) {
699
+ return this.values.has(name);
700
+ }
701
+
702
+ // A `var()` reference to `--<namespace>-<key>` when that token exists.
703
+ }, {
704
+ key: "resolve",
705
+ value: function resolve(namespace, key) {
706
+ var name = "--".concat(namespace, "-").concat(key);
707
+ return this.values.has(name) ? "var(".concat(name, ")") : null;
708
+ }
709
+
710
+ // Bare keys registered under a namespace, e.g. every color name.
711
+ }, {
712
+ key: "keysIn",
713
+ value: function keysIn(namespace) {
714
+ var prefix = "--".concat(namespace, "-");
715
+ var out = [];
716
+ var _iterator = _createForOfIteratorHelper(this.values.keys()),
717
+ _step;
718
+ try {
719
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
720
+ var name = _step.value;
721
+ if (name.startsWith(prefix)) out.push(name.slice(prefix.length));
722
+ }
723
+ } catch (err) {
724
+ _iterator.e(err);
725
+ } finally {
726
+ _iterator.f();
727
+ }
728
+ return out;
729
+ }
730
+ }, {
731
+ key: "entries",
732
+ value: function entries() {
733
+ return _toConsumableArray(this.values.entries());
734
+ }
735
+ }]);
736
+ }();
737
+
738
+ // ─── Charcode constants (avoids string allocation on hot paths) ───────────────
739
+ var CC_TAB = 9,
740
+ CC_LF = 10,
741
+ CC_CR = 13,
742
+ CC_FF = 12,
743
+ CC_SPACE = 32;
744
+ var CC_DQUOTE = 34,
745
+ CC_HASH = 35,
746
+ CC_AMP = 38,
747
+ CC_SQUOTE = 39;
748
+ var CC_LPAREN = 40,
749
+ CC_RPAREN = 41,
750
+ CC_STAR = 42,
751
+ CC_PLUS = 43;
752
+ var CC_COMMA = 44,
753
+ CC_MINUS = 45,
754
+ CC_DOT = 46,
755
+ CC_SLASH = 47;
756
+ var CC_COLON = 58,
757
+ CC_SEMI = 59,
758
+ CC_GT = 62;
759
+ var CC_AT = 64,
760
+ CC_LBRACK = 91,
761
+ CC_BSLASH = 92,
762
+ CC_RBRACK = 93;
763
+ var CC_UNDER = 95,
764
+ CC_LBRACE = 123,
765
+ CC_RBRACE = 125,
766
+ CC_TILDE = 126;
767
+
768
+ // ─── Character predicates (charcode-based, no regex) ─────────────────────────
769
+
770
+ function isWS(c) {
771
+ return c === CC_SPACE || c === CC_TAB || c === CC_LF || c === CC_CR || c === CC_FF;
772
+ }
773
+ function isDigit(c) {
774
+ return c >= 48 && c <= 57;
775
+ }
776
+ function isAlpha(c) {
777
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122;
778
+ }
779
+ function isHex(c) {
780
+ return isDigit(c) || c >= 65 && c <= 70 || c >= 97 && c <= 102;
781
+ }
782
+ /**
783
+ * CSS ident-start: letter | underscore | non-ASCII | hyphen.
784
+ * A leading hyphen is valid (vendor prefixes, custom properties).
785
+ */
786
+ function isNameStart(c) {
787
+ return isAlpha(c) || c === CC_UNDER || c === CC_MINUS || c > 127;
788
+ }
789
+ /** CSS ident-char: ident-start | digit */
790
+ function isNameChar(c) {
791
+ return isAlpha(c) || isDigit(c) || c === CC_UNDER || c === CC_MINUS || c > 127;
792
+ }
793
+
794
+ // ─── Block context ────────────────────────────────────────────────────────────
795
+
796
+ /**
797
+ * Determines what may legally appear inside a block:
798
+ * stylesheet – top-level: rules + at-rules
799
+ * mixed – @media/@supports/@container/@layer: rules + at-rules
800
+ * rule – inside a style rule: declarations + optional CSS nesting
801
+ * keyframes – inside @keyframes: keyframe stops (from/to/%)
802
+ * declarations– @font-face/@page/etc.: declarations only
803
+ */
804
+
805
+ // ─── CssParser ────────────────────────────────────────────────────────────────
806
+
807
+ var CssParser = /*#__PURE__*/function () {
808
+ function CssParser() {
809
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
810
+ _classCallCheck(this, CssParser);
811
+ _defineProperty(this, "input", '');
812
+ _defineProperty(this, "pos", 0);
813
+ _defineProperty(this, "length", 0);
814
+ _defineProperty(this, "line", 1);
815
+ _defineProperty(this, "col", 1);
816
+ _defineProperty(this, "errors", []);
817
+ _defineProperty(this, "warnings", []);
818
+ _defineProperty(this, "stats", CssParser.emptyStats());
819
+ this.options = _objectSpread2({
820
+ parseAtrulePrelude: true,
821
+ parseValue: true,
822
+ parseCustomProperty: true,
823
+ parseRulePrelude: true,
824
+ parseSelector: true,
825
+ includeComments: true,
826
+ includeSourceMaps: true,
827
+ includeSpecificity: true,
828
+ includeVendorPrefixes: true,
829
+ onError: function onError() {/* noop */},
830
+ onWarning: function onWarning() {/* noop */},
831
+ maxDepth: 100,
832
+ maxNodes: 100000,
833
+ enableNesting: true,
834
+ enableCustomProperties: true,
835
+ enableLogicalProperties: true,
836
+ enableContainerQueries: true,
837
+ enableLayerQueries: true,
838
+ enableSupportsQueries: true,
839
+ // middleware — undefined by default (fast path skips them)
840
+ onRule: undefined,
841
+ onAtRule: undefined,
842
+ onDeclaration: undefined,
843
+ onComment: undefined,
844
+ onKeyframe: undefined
845
+ }, options);
846
+ }
847
+
848
+ // ── Public API ────────────────────────────────────────────────────────────
849
+ return _createClass(CssParser, [{
850
+ key: "parse",
851
+ value: function parse(css) {
852
+ var t0 = typeof performance !== 'undefined' ? performance.now() : Date.now();
853
+ this.reset(css);
854
+ var sheet = this.parseStylesheet();
855
+ this.stats.parseTime = (typeof performance !== 'undefined' ? performance.now() : Date.now()) - t0;
856
+ return sheet;
857
+ }
858
+ }, {
859
+ key: "getErrors",
860
+ value: function getErrors() {
861
+ return _toConsumableArray(this.errors);
862
+ }
863
+ }, {
864
+ key: "getWarnings",
865
+ value: function getWarnings() {
866
+ return _toConsumableArray(this.warnings);
867
+ }
868
+ }, {
869
+ key: "getStats",
870
+ value: function getStats() {
871
+ return _objectSpread2({}, this.stats);
872
+ }
873
+ }, {
874
+ key: "toLegacyFormat",
875
+ value: function toLegacyFormat(stylesheet) {
876
+ var _this = this;
877
+ return stylesheet.children.map(function (c) {
878
+ return _this.toLegacyNode(c);
879
+ }).filter(Boolean);
880
+ }
881
+
882
+ // ── Reset ─────────────────────────────────────────────────────────────────
883
+ }, {
884
+ key: "reset",
885
+ value: function reset(css) {
886
+ this.input = css;
887
+ this.pos = 0;
888
+ this.length = css.length;
889
+ this.line = 1;
890
+ this.col = 1;
891
+ this.errors = [];
892
+ this.warnings = [];
893
+ this.stats = CssParser.emptyStats();
894
+ }
895
+ }, {
896
+ key: "parseStylesheet",
897
+ value:
898
+ // ── Stylesheet ────────────────────────────────────────────────────────────
899
+
900
+ function parseStylesheet() {
901
+ var locStart = this.locPos();
902
+ var ss = {
903
+ type: 'stylesheet',
904
+ source: this.input,
905
+ children: [],
906
+ charset: undefined,
907
+ imports: [],
908
+ namespaces: [],
909
+ mediaQueries: [],
910
+ keyframes: [],
911
+ fontFaces: [],
912
+ layers: [],
913
+ containers: [],
914
+ supports: [],
915
+ documents: [],
916
+ pages: [],
917
+ counterStyles: [],
918
+ fontFeatureValues: [],
919
+ viewports: [],
920
+ charsets: []
921
+ };
922
+ while (this.pos < this.length) {
923
+ this.skipWS();
924
+ if (this.pos >= this.length) break;
925
+ var node = this.parseTopNode();
926
+ if (node) {
927
+ ss.children.push(node);
928
+ this.categorize(ss, node);
929
+ this.stats.totalNodes++;
930
+ }
931
+ }
932
+ if (this.options.includeSourceMaps) {
933
+ ss.loc = {
934
+ start: locStart,
935
+ end: this.locPos(),
936
+ source: this.input
937
+ };
938
+ }
939
+ return ss;
940
+ }
941
+
942
+ // ── Top-level node dispatch ───────────────────────────────────────────────
943
+ }, {
944
+ key: "parseTopNode",
945
+ value: function parseTopNode() {
946
+ var c = this.peek();
947
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
948
+ var comment = this.parseComment();
949
+ return this.options.includeComments ? comment : null;
950
+ }
951
+ if (c === CC_AT) return this.parseAtRule();
952
+ // Skip stray closing braces that can appear in malformed CSS
953
+ if (c === CC_RBRACE) {
954
+ this.advance();
955
+ return null;
956
+ }
957
+ return this.parseRule();
958
+ }
959
+
960
+ // ── Block-level node dispatch ─────────────────────────────────────────────
961
+ }, {
962
+ key: "parseBlockNode",
963
+ value: function parseBlockNode(mode) {
964
+ this.skipWS();
965
+ if (this.pos >= this.length || this.peek() === CC_RBRACE) return null;
966
+ var c = this.peek();
967
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
968
+ var comment = this.parseComment();
969
+ return this.options.includeComments ? comment : null;
970
+ }
971
+ if (c === CC_AT) return this.parseAtRule();
972
+ switch (mode) {
973
+ case 'keyframes':
974
+ return this.parseKeyframeStop();
975
+ case 'declarations':
976
+ return this.parseDeclaration();
977
+ case 'mixed':
978
+ case 'stylesheet':
979
+ if (c === CC_RBRACE) return null;
980
+ return this.parseRule();
981
+ case 'rule':
982
+ default:
983
+ // Unambiguous nesting-selector starters
984
+ if (this.isNestingStart(c)) return this.parseRule();
985
+ // Lookahead: first unescaped { at depth 0 → rule, ; or } → declaration
986
+ if (this.lookaheadIsRule()) return this.parseRule();
987
+ // console.log('parse block', c, mode);
988
+ return this.parseDeclaration();
989
+ }
990
+ }
991
+
992
+ // ── At-rule ───────────────────────────────────────────────────────────────
993
+ }, {
994
+ key: "parseAtRule",
995
+ value: function parseAtRule() {
996
+ if (this.peek() !== CC_AT) return null;
997
+ var locStart = this.locPos();
998
+ this.advance(); // '@'
999
+
1000
+ var name = this.readIdent();
1001
+ if (!name) {
1002
+ this.recoverPast(CC_SEMI, CC_RBRACE);
1003
+ return null;
1004
+ }
1005
+ this.skipWS();
1006
+ var preludeText = this.readPrelude();
1007
+ this.skipWS();
1008
+ var baseName = name.replace(/^-(webkit|moz|ms|o)-/, '');
1009
+ var ar = {
1010
+ type: 'atrule',
1011
+ name: name,
1012
+ preludeText: preludeText,
1013
+ prelude: this.options.parseAtrulePrelude ? this.tokenizeValue(preludeText) : []
1014
+ };
1015
+ if (this.options.includeVendorPrefixes) {
1016
+ var vp = name.match(/^-(webkit|moz|ms|o)-/);
1017
+ if (vp) ar.vendorPrefix = vp[0];
1018
+ }
1019
+ if (this.peek() === CC_LBRACE) {
1020
+ var mode = this.modeForAtRule(baseName);
1021
+ var blockStart = this.locPos();
1022
+ var children = this.parseBlockChildren(mode);
1023
+ var blockEnd = this.locPos();
1024
+ ar.block = _objectSpread2({
1025
+ type: 'block',
1026
+ children: children
1027
+ }, this.options.includeSourceMaps ? {
1028
+ loc: {
1029
+ start: blockStart,
1030
+ end: blockEnd
1031
+ }
1032
+ } : {});
1033
+
1034
+ // Populate keyframes shortcut
1035
+ if (baseName === 'keyframes') {
1036
+ ar.keyframes = children.filter(function (n) {
1037
+ return n.type === 'keyframe';
1038
+ });
1039
+ }
1040
+ } else if (this.peek() === CC_SEMI) {
1041
+ this.advance();
1042
+ }
1043
+ this.stats.totalAtRules++;
1044
+ if (this.options.includeSourceMaps) {
1045
+ ar.loc = {
1046
+ start: locStart,
1047
+ end: this.locPos(),
1048
+ source: this.input
1049
+ };
1050
+ }
1051
+ if (this.options.onAtRule) {
1052
+ var result = this.options.onAtRule(ar);
1053
+ if (result === null) return null;
1054
+ if (result) return result;
1055
+ }
1056
+ return ar;
1057
+ }
1058
+ }, {
1059
+ key: "modeForAtRule",
1060
+ value: function modeForAtRule(baseName) {
1061
+ // AWC encodes comments as @comment-XXXXXXXX { --rule-...: "..."; }
1062
+ // which contain only declarations — must NOT use mixed/rule mode or
1063
+ // readUntilLBrace() will consume past the closing } and corrupt state.
1064
+ if (baseName.startsWith('comment')) return 'declarations';
1065
+ switch (baseName) {
1066
+ case 'keyframes':
1067
+ return 'keyframes';
1068
+ case 'font-face':
1069
+ case 'page':
1070
+ case 'counter-style':
1071
+ case 'viewport':
1072
+ case 'theme':
1073
+ case 'utility':
1074
+ return 'declarations';
1075
+ case 'media':
1076
+ case 'supports':
1077
+ case 'container':
1078
+ case 'layer':
1079
+ case 'document':
1080
+ default:
1081
+ return 'mixed';
1082
+ }
1083
+ }
1084
+
1085
+ // ── Regular rule ──────────────────────────────────────────────────────────
1086
+ }, {
1087
+ key: "parseRule",
1088
+ value: function parseRule() {
1089
+ var locStart = this.locPos();
1090
+ var rawSelector = this.readUntilLBrace().trim();
1091
+ if (!rawSelector || this.peek() !== CC_LBRACE) {
1092
+ // Malformed — skip to closing brace
1093
+ if (this.peek() === CC_LBRACE) {
1094
+ this.skipBalancedBraces();
1095
+ }
1096
+ return null;
1097
+ }
1098
+ var mode = this.options.enableNesting ? 'rule' : 'declarations';
1099
+ var children = this.parseBlockChildren(mode);
1100
+ var declarations = [];
1101
+ var nested = [];
1102
+ var _iterator = _createForOfIteratorHelper(children),
1103
+ _step;
1104
+ try {
1105
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1106
+ var child = _step.value;
1107
+ var t = child.type;
1108
+ if (t === 'declaration') declarations.push(child);else if (t === 'rule') nested.push(child);else if (t === 'atrule') nested.push(child);
1109
+ }
1110
+ } catch (err) {
1111
+ _iterator.e(err);
1112
+ } finally {
1113
+ _iterator.f();
1114
+ }
1115
+ var selectors = this.parseSelectorList(rawSelector);
1116
+ this.stats.totalRules++;
1117
+ this.stats.totalSelectors += selectors.length;
1118
+ var rule = {
1119
+ type: 'rule',
1120
+ rawSelector: rawSelector,
1121
+ selectors: selectors,
1122
+ declarations: declarations
1123
+ };
1124
+ if (nested.length > 0) rule.children = nested;
1125
+ if (this.options.includeSpecificity) {
1126
+ rule.specificity = this.calcSpecificity(rawSelector);
1127
+ }
1128
+ if (this.options.includeSourceMaps) {
1129
+ rule.loc = {
1130
+ start: locStart,
1131
+ end: this.locPos(),
1132
+ source: this.input
1133
+ };
1134
+ }
1135
+ if (this.options.onRule) {
1136
+ var result = this.options.onRule(rule);
1137
+ if (result === null) return null;
1138
+ if (result) return result;
1139
+ }
1140
+ return rule;
1141
+ }
1142
+
1143
+ // ── Keyframe stop (from / to / <percentage>) ──────────────────────────────
1144
+ }, {
1145
+ key: "parseKeyframeStop",
1146
+ value: function parseKeyframeStop() {
1147
+ var locStart = this.locPos();
1148
+ var selector = this.readUntilLBrace().trim();
1149
+ if (!selector || this.peek() !== CC_LBRACE) return null;
1150
+ var children = this.parseBlockChildren('declarations');
1151
+ var declarations = children.filter(function (n) {
1152
+ return n.type === 'declaration';
1153
+ });
1154
+ var kf = _objectSpread2({
1155
+ type: 'keyframe',
1156
+ selector: selector,
1157
+ declarations: declarations
1158
+ }, this.options.includeSourceMaps ? {
1159
+ loc: {
1160
+ start: locStart,
1161
+ end: this.locPos()
1162
+ }
1163
+ } : {});
1164
+ if (this.options.onKeyframe) {
1165
+ var result = this.options.onKeyframe(kf);
1166
+ if (result === null) return null;
1167
+ if (result) return result;
1168
+ }
1169
+ return kf;
1170
+ }
1171
+
1172
+ // ── Block (consumes { … }) ────────────────────────────────────────────────
1173
+ }, {
1174
+ key: "parseBlockChildren",
1175
+ value: function parseBlockChildren(mode) {
1176
+ if (this.peek() !== CC_LBRACE) return [];
1177
+ this.advance(); // '{'
1178
+
1179
+ var children = [];
1180
+ while (this.pos < this.length) {
1181
+ this.skipWS();
1182
+ if (this.pos >= this.length || this.peek() === CC_RBRACE) break;
1183
+ var prevPos = this.pos;
1184
+ var node = this.parseBlockNode(mode);
1185
+ // Guard against infinite loop: if nothing was consumed, force-advance
1186
+ if (this.pos === prevPos) {
1187
+ this.advance();
1188
+ continue;
1189
+ }
1190
+ if (node) {
1191
+ children.push(node);
1192
+ this.stats.totalNodes++;
1193
+ }
1194
+ }
1195
+ if (this.pos < this.length && this.peek() === CC_RBRACE) this.advance(); // '}'
1196
+ return children;
1197
+ }
1198
+
1199
+ // ── Declaration ───────────────────────────────────────────────────────────
1200
+ }, {
1201
+ key: "parseDeclaration",
1202
+ value: function parseDeclaration() {
1203
+ var locStart = this.locPos();
1204
+
1205
+ // Property name (supports --custom-props and -vendor-prefixed)
1206
+ var property = this.readIdent();
1207
+ if (!property) {
1208
+ this.recoverTo(CC_SEMI, CC_RBRACE);
1209
+ return null;
1210
+ }
1211
+ this.skipWS();
1212
+ if (this.peek() !== CC_COLON) {
1213
+ this.recoverTo(CC_SEMI, CC_RBRACE);
1214
+ return null;
1215
+ }
1216
+ this.advance(); // ':'
1217
+ this.skipWS();
1218
+ var rawFull = this.readRawValue();
1219
+
1220
+ // Strip !important
1221
+ var rawValue = rawFull;
1222
+ var important = false;
1223
+ var impMatch = rawFull.match(/\s*!important\s*$/i);
1224
+ if (impMatch) {
1225
+ important = true;
1226
+ rawValue = rawFull.slice(0, rawFull.length - impMatch[0].length).trimEnd();
1227
+ }
1228
+ this.skipWS();
1229
+ if (this.pos < this.length && this.peek() === CC_SEMI) this.advance();
1230
+ this.stats.totalDeclarations++;
1231
+ var decl = {
1232
+ type: 'declaration',
1233
+ property: property,
1234
+ rawValue: rawValue,
1235
+ value: this.options.parseValue ? this.tokenizeValue(rawValue) : [],
1236
+ important: important
1237
+ };
1238
+ if (this.options.enableCustomProperties && property.startsWith('--')) {
1239
+ decl.customProperty = true;
1240
+ }
1241
+ if (this.options.includeVendorPrefixes) {
1242
+ var vp = property.match(/^-(webkit|moz|ms|o)-/);
1243
+ if (vp) decl.vendorPrefix = vp[0];
1244
+ }
1245
+ if (this.options.includeSourceMaps) {
1246
+ decl.loc = {
1247
+ start: locStart,
1248
+ end: this.locPos(),
1249
+ source: this.input
1250
+ };
1251
+ }
1252
+ if (this.options.onDeclaration) {
1253
+ var result = this.options.onDeclaration(decl);
1254
+ if (result === null) return null;
1255
+ if (result) return result;
1256
+ }
1257
+ return decl;
1258
+ }
1259
+
1260
+ // ── Comment ───────────────────────────────────────────────────────────────
1261
+ }, {
1262
+ key: "parseComment",
1263
+ value: function parseComment() {
1264
+ var locStart = this.locPos();
1265
+ this.advance(); // '/'
1266
+ this.advance(); // '*'
1267
+ var start = this.pos;
1268
+ while (this.pos < this.length - 1) {
1269
+ if (this.peek() === CC_STAR && this.peek(1) === CC_SLASH) {
1270
+ var _value = this.input.slice(start, this.pos);
1271
+ this.advance();
1272
+ this.advance(); // '*/'
1273
+ this.stats.totalComments++;
1274
+ var _c = _objectSpread2({
1275
+ type: 'comment',
1276
+ value: _value,
1277
+ style: _value.includes('\n') ? 'multi-line' : 'single-line'
1278
+ }, this.options.includeSourceMaps ? {
1279
+ loc: {
1280
+ start: locStart,
1281
+ end: this.locPos()
1282
+ }
1283
+ } : {});
1284
+ if (this.options.onComment) {
1285
+ var result = this.options.onComment(_c);
1286
+ if (result === null) return null;
1287
+ if (result) return result;
1288
+ }
1289
+ return _c;
1290
+ }
1291
+ this.advance();
1292
+ }
1293
+
1294
+ // Unterminated comment
1295
+ var value = this.input.slice(start);
1296
+ this.pos = this.length;
1297
+ this.stats.totalComments++;
1298
+ var c = {
1299
+ type: 'comment',
1300
+ value: value,
1301
+ style: 'multi-line'
1302
+ };
1303
+ if (this.options.onComment) {
1304
+ var _result = this.options.onComment(c);
1305
+ if (_result === null) return null;
1306
+ if (_result) return _result;
1307
+ }
1308
+ return c;
1309
+ }
1310
+
1311
+ // ── Selectors ─────────────────────────────────────────────────────────────
1312
+
1313
+ /**
1314
+ * Splits a raw selector string on commas (respecting parentheses depth)
1315
+ * and returns one CssSelector per part.
1316
+ */
1317
+ }, {
1318
+ key: "parseSelectorList",
1319
+ value: function parseSelectorList(raw) {
1320
+ var parts = [];
1321
+ var depth = 0,
1322
+ start = 0;
1323
+ for (var i = 0; i < raw.length; i++) {
1324
+ var c = raw.charCodeAt(i);
1325
+ if (c === CC_LPAREN || c === CC_LBRACK) depth++;else if (c === CC_RPAREN || c === CC_RBRACK) depth--;else if (c === CC_COMMA && depth === 0) {
1326
+ parts.push(raw.slice(start, i).trim());
1327
+ start = i + 1;
1328
+ }
1329
+ }
1330
+ parts.push(raw.slice(start).trim());
1331
+ return parts.filter(function (p) {
1332
+ return p.length > 0;
1333
+ }).map(function (p) {
1334
+ return {
1335
+ type: 'selector',
1336
+ value: p
1337
+ };
1338
+ });
1339
+ }
1340
+
1341
+ /**
1342
+ * Simple specificity scorer — counts IDs, classes/attributes/pseudos, elements.
1343
+ */
1344
+ }, {
1345
+ key: "calcSpecificity",
1346
+ value: function calcSpecificity(sel) {
1347
+ var ids = 0,
1348
+ classes = 0,
1349
+ elements = 0;
1350
+ var i = 0;
1351
+ while (i < sel.length) {
1352
+ var c = sel.charCodeAt(i);
1353
+ if (c === CC_HASH) {
1354
+ ids++;
1355
+ i++;
1356
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1357
+ } else if (c === CC_DOT) {
1358
+ classes++;
1359
+ i++;
1360
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1361
+ } else if (c === CC_LBRACK) {
1362
+ classes++;
1363
+ while (i < sel.length && sel.charCodeAt(i) !== CC_RBRACK) i++;
1364
+ i++;
1365
+ } else if (c === CC_COLON) {
1366
+ if (sel.charCodeAt(i + 1) === CC_COLON) {
1367
+ elements++;
1368
+ i += 2;
1369
+ } else {
1370
+ // :not(), :is(), :has() — don't double-count the wrapper
1371
+ classes++;
1372
+ i++;
1373
+ }
1374
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1375
+ // skip argument parens
1376
+ if (i < sel.length && sel.charCodeAt(i) === CC_LPAREN) {
1377
+ var d = 1;
1378
+ i++;
1379
+ while (i < sel.length && d > 0) {
1380
+ if (sel.charCodeAt(i) === CC_LPAREN) d++;else if (sel.charCodeAt(i) === CC_RPAREN) d--;
1381
+ i++;
1382
+ }
1383
+ }
1384
+ } else if (isAlpha(c) || c === CC_UNDER) {
1385
+ elements++;
1386
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1387
+ } else {
1388
+ i++;
1389
+ }
1390
+ }
1391
+ return {
1392
+ ids: ids,
1393
+ classes: classes,
1394
+ elements: elements,
1395
+ total: ids * 100 + classes * 10 + elements
1396
+ };
1397
+ }
1398
+
1399
+ // ── Value tokenizer ───────────────────────────────────────────────────────
1400
+
1401
+ /**
1402
+ * Tokenises a raw CSS value string into a flat array of CssValue tokens.
1403
+ * Handles: strings, colors (#hex), numbers/dimensions/percentages,
1404
+ * functions (recursive), identifiers, operators, commas.
1405
+ */
1406
+ }, {
1407
+ key: "tokenizeValue",
1408
+ value: function tokenizeValue(raw) {
1409
+ var tokens = [];
1410
+ var i = 0;
1411
+ var len = raw.length;
1412
+ while (i < len) {
1413
+ var c = raw.charCodeAt(i);
1414
+
1415
+ // Whitespace — skip (no whitespace tokens)
1416
+ if (isWS(c)) {
1417
+ i++;
1418
+ continue;
1419
+ }
1420
+
1421
+ // Quoted string
1422
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1423
+ var q = c;
1424
+ i++;
1425
+ var s = i;
1426
+ while (i < len && raw.charCodeAt(i) !== q) {
1427
+ if (raw.charCodeAt(i) === CC_BSLASH) i++;
1428
+ i++;
1429
+ }
1430
+ tokens.push({
1431
+ type: 'string',
1432
+ value: raw.slice(s, i)
1433
+ });
1434
+ i++; // closing quote
1435
+ continue;
1436
+ }
1437
+
1438
+ // Hex color (#rrggbb / #rgb / #rrggbbaa / #rgba)
1439
+ if (c === CC_HASH) {
1440
+ var _s = i++;
1441
+ while (i < len && isHex(raw.charCodeAt(i))) i++;
1442
+ tokens.push({
1443
+ type: 'color',
1444
+ value: raw.slice(_s, i)
1445
+ });
1446
+ continue;
1447
+ }
1448
+
1449
+ // Number / dimension / percentage
1450
+ // Handles: 10, 1.5, .5, 1e3, +10px, -2em, 50%
1451
+ var isNumStart = isDigit(c) || c === CC_DOT && isDigit(raw.charCodeAt(i + 1)) || (c === CC_PLUS || c === CC_MINUS) && (isDigit(raw.charCodeAt(i + 1)) || raw.charCodeAt(i + 1) === CC_DOT && isDigit(raw.charCodeAt(i + 2)));
1452
+ if (isNumStart) {
1453
+ var _s2 = i;
1454
+ if (c === CC_PLUS || c === CC_MINUS) i++;
1455
+ while (i < len && isDigit(raw.charCodeAt(i))) i++;
1456
+ if (i < len && raw.charCodeAt(i) === CC_DOT) {
1457
+ i++;
1458
+ while (i < len && isDigit(raw.charCodeAt(i))) i++;
1459
+ }
1460
+ // Exponent
1461
+ if (i < len && (raw.charCodeAt(i) === 101 || raw.charCodeAt(i) === 69)) {
1462
+ i++;
1463
+ if (i < len && (raw.charCodeAt(i) === CC_PLUS || raw.charCodeAt(i) === CC_MINUS)) i++;
1464
+ while (i < len && isDigit(raw.charCodeAt(i))) i++;
1465
+ }
1466
+ var num = parseFloat(raw.slice(_s2, i));
1467
+ // Unit / percentage
1468
+ var us = i;
1469
+ while (i < len && (isAlpha(raw.charCodeAt(i)) || raw.charCodeAt(i) === CC_UNDER)) i++;
1470
+ if (i < len && raw[i] === '%') i++;
1471
+ var unit = raw.slice(us, i);
1472
+ if (unit === '%') tokens.push({
1473
+ type: 'percentage',
1474
+ value: num
1475
+ });else if (unit) tokens.push({
1476
+ type: 'dimension',
1477
+ value: num,
1478
+ unit: unit
1479
+ });else tokens.push({
1480
+ type: 'number',
1481
+ value: num
1482
+ });
1483
+ continue;
1484
+ }
1485
+
1486
+ // Identifier or function call
1487
+ if (isNameStart(c)) {
1488
+ var _s3 = i;
1489
+ while (i < len && isNameChar(raw.charCodeAt(i))) i++;
1490
+ var name = raw.slice(_s3, i);
1491
+ if (i < len && raw.charCodeAt(i) === CC_LPAREN) {
1492
+ i++; // '('
1493
+ var as_ = i;
1494
+ var depth = 1;
1495
+ while (i < len && depth > 0) {
1496
+ var ch = raw.charCodeAt(i);
1497
+ if (ch === CC_LPAREN) depth++;else if (ch === CC_RPAREN) depth--;
1498
+ i++;
1499
+ }
1500
+ var argStr = raw.slice(as_, i - 1);
1501
+ var args = name.toLowerCase() === 'url' ? [{
1502
+ type: 'string',
1503
+ value: argStr.replace(/^['"]|['"]$/g, '')
1504
+ }] : this.tokenizeValue(argStr);
1505
+ tokens.push({
1506
+ type: 'function',
1507
+ name: name,
1508
+ value: "".concat(name, "(").concat(argStr, ")"),
1509
+ args: args
1510
+ });
1511
+ } else {
1512
+ tokens.push({
1513
+ type: 'identifier',
1514
+ value: name
1515
+ });
1516
+ }
1517
+ continue;
1518
+ }
1519
+
1520
+ // Comma
1521
+ if (c === CC_COMMA) {
1522
+ tokens.push({
1523
+ type: 'comma',
1524
+ value: ','
1525
+ });
1526
+ i++;
1527
+ continue;
1528
+ }
1529
+
1530
+ // Operator or any other character
1531
+ tokens.push({
1532
+ type: 'operator',
1533
+ value: raw[i]
1534
+ });
1535
+ i++;
1536
+ }
1537
+ this.stats.totalValues += tokens.length;
1538
+ return tokens;
1539
+ }
1540
+
1541
+ // ── Scanner primitives ────────────────────────────────────────────────────
1542
+ }, {
1543
+ key: "peek",
1544
+ value: function peek() {
1545
+ var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1546
+ return this.input.charCodeAt(this.pos + offset);
1547
+ }
1548
+ }, {
1549
+ key: "advance",
1550
+ value: function advance() {
1551
+ if (this.pos < this.length) {
1552
+ if (this.input.charCodeAt(this.pos) === CC_LF) {
1553
+ this.line++;
1554
+ this.col = 1;
1555
+ } else this.col++;
1556
+ this.pos++;
1557
+ }
1558
+ }
1559
+ }, {
1560
+ key: "skipWS",
1561
+ value: function skipWS() {
1562
+ while (this.pos < this.length && isWS(this.peek())) this.advance();
1563
+ }
1564
+
1565
+ /**
1566
+ * Read a CSS identifier (supports `--custom-props` and `-vendor-prefix`).
1567
+ * Returns empty string if the current position isn't the start of an ident.
1568
+ */
1569
+ }, {
1570
+ key: "readIdent",
1571
+ value: function readIdent() {
1572
+ if (this.pos >= this.length) return '';
1573
+ var c = this.peek();
1574
+ // Allow backslash-escape as a valid ident start (e.g. \/ in custom props)
1575
+ if (!isNameStart(c) && c !== CC_BSLASH) return '';
1576
+ var start = this.pos;
1577
+ while (this.pos < this.length) {
1578
+ var ch = this.peek();
1579
+ if (ch === CC_BSLASH) {
1580
+ // CSS escape sequence: consume backslash + following char/codepoint
1581
+ // Preserve raw text (including the backslash) so the generator
1582
+ // can emit valid CSS unchanged.
1583
+ this.advance(); // consume '\'
1584
+ if (this.pos >= this.length) break;
1585
+ var next = this.peek();
1586
+ if (isHex(next)) {
1587
+ // 1–6 hex digits
1588
+ var hexLen = 0;
1589
+ while (this.pos < this.length && isHex(this.peek()) && hexLen < 6) {
1590
+ this.advance();
1591
+ hexLen++;
1592
+ }
1593
+ // optional single whitespace after hex escape
1594
+ if (this.pos < this.length && isWS(this.peek())) this.advance();
1595
+ } else if (next === CC_LF || next === CC_CR || next === CC_FF) {
1596
+ // newline inside escape — skip
1597
+ this.advance();
1598
+ } else {
1599
+ // e.g. \/ — consume the escaped character
1600
+ this.advance();
1601
+ }
1602
+ } else if (isNameChar(ch)) {
1603
+ this.advance();
1604
+ } else {
1605
+ break;
1606
+ }
1607
+ }
1608
+ return this.input.slice(start, this.pos);
1609
+ }
1610
+
1611
+ /**
1612
+ * Read at-rule prelude: raw text from current position up to (but not
1613
+ * including) the next `{` or `;` at depth 0.
1614
+ * Parentheses, brackets, strings and comments are respected.
1615
+ */
1616
+ }, {
1617
+ key: "readPrelude",
1618
+ value: function readPrelude() {
1619
+ var start = this.pos;
1620
+ var depth = 0;
1621
+ while (this.pos < this.length) {
1622
+ var c = this.peek();
1623
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1624
+ this.skipString(c);
1625
+ continue;
1626
+ }
1627
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
1628
+ this.skipMLComment();
1629
+ continue;
1630
+ }
1631
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1632
+ depth++;
1633
+ this.advance();
1634
+ continue;
1635
+ }
1636
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1637
+ depth--;
1638
+ this.advance();
1639
+ continue;
1640
+ }
1641
+ if (depth === 0 && (c === CC_LBRACE || c === CC_SEMI)) break;
1642
+ this.advance();
1643
+ }
1644
+ return this.input.slice(start, this.pos).trim();
1645
+ }
1646
+
1647
+ /**
1648
+ * Read a declaration value: raw text up to `;` or `}` at depth 0.
1649
+ */
1650
+ }, {
1651
+ key: "readRawValue",
1652
+ value: function readRawValue() {
1653
+ var start = this.pos;
1654
+ var depth = 0;
1655
+ while (this.pos < this.length) {
1656
+ var c = this.peek();
1657
+ // Backslash escape: consume '\' + next char as a unit.
1658
+ // This prevents '\"' from being misread as a string delimiter,
1659
+ // '\;' from prematurely terminating the value, and '\(' from
1660
+ // incorrectly incrementing paren depth.
1661
+ if (c === CC_BSLASH) {
1662
+ this.advance(); // consume '\'
1663
+ if (this.pos < this.length) this.advance(); // consume escaped char
1664
+ continue;
1665
+ }
1666
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1667
+ this.skipString(c);
1668
+ continue;
1669
+ }
1670
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
1671
+ this.skipMLComment();
1672
+ continue;
1673
+ }
1674
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1675
+ depth++;
1676
+ this.advance();
1677
+ continue;
1678
+ }
1679
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1680
+ depth--;
1681
+ this.advance();
1682
+ continue;
1683
+ }
1684
+ if (depth === 0 && (c === CC_SEMI || c === CC_RBRACE)) break;
1685
+ this.advance();
1686
+ }
1687
+ return this.input.slice(start, this.pos).trim();
1688
+ }
1689
+
1690
+ /**
1691
+ * Read a selector (rule prelude): raw text up to the first `{` at depth 0.
1692
+ * Parentheses, brackets, strings and comments are respected.
1693
+ */
1694
+ }, {
1695
+ key: "readUntilLBrace",
1696
+ value: function readUntilLBrace() {
1697
+ var start = this.pos;
1698
+ var depth = 0;
1699
+ while (this.pos < this.length) {
1700
+ var c = this.peek();
1701
+ // Backslash escape: consume '\' + next char as a unit.
1702
+ // Prevents '\{' from falsely terminating the selector,
1703
+ // and '\"' from being misread as a string delimiter.
1704
+ if (c === CC_BSLASH) {
1705
+ this.advance(); // consume '\'
1706
+ if (this.pos < this.length) this.advance(); // consume escaped char
1707
+ continue;
1708
+ }
1709
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1710
+ this.skipString(c);
1711
+ continue;
1712
+ }
1713
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
1714
+ this.skipMLComment();
1715
+ continue;
1716
+ }
1717
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1718
+ depth++;
1719
+ this.advance();
1720
+ continue;
1721
+ }
1722
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1723
+ depth--;
1724
+ this.advance();
1725
+ continue;
1726
+ }
1727
+ if (depth === 0 && c === CC_LBRACE) break;
1728
+ this.advance();
1729
+ }
1730
+ return this.input.slice(start, this.pos);
1731
+ }
1732
+
1733
+ /** Skip a quoted string starting at the current position (quote char given). */
1734
+ }, {
1735
+ key: "skipString",
1736
+ value: function skipString(quote) {
1737
+ this.advance(); // opening quote
1738
+ while (this.pos < this.length) {
1739
+ var c = this.peek();
1740
+ if (c === CC_BSLASH) {
1741
+ this.advance();
1742
+ this.advance();
1743
+ continue;
1744
+ }
1745
+ if (c === quote) {
1746
+ this.advance();
1747
+ return;
1748
+ }
1749
+ if (c === CC_LF) return; // unterminated → stop
1750
+ this.advance();
1751
+ }
1752
+ }
1753
+
1754
+ /** Skip a block comment (slash-star ... star-slash) starting at current position. */
1755
+ }, {
1756
+ key: "skipMLComment",
1757
+ value: function skipMLComment() {
1758
+ this.advance();
1759
+ this.advance(); // '/' '*'
1760
+ while (this.pos < this.length - 1) {
1761
+ if (this.peek() === CC_STAR && this.peek(1) === CC_SLASH) {
1762
+ this.advance();
1763
+ this.advance();
1764
+ return;
1765
+ }
1766
+ this.advance();
1767
+ }
1768
+ this.pos = this.length;
1769
+ }
1770
+
1771
+ /** Skip a balanced `{ … }` block (including the opening brace). */
1772
+ }, {
1773
+ key: "skipBalancedBraces",
1774
+ value: function skipBalancedBraces() {
1775
+ if (this.peek() !== CC_LBRACE) return;
1776
+ var depth = 0;
1777
+ while (this.pos < this.length) {
1778
+ var c = this.peek();
1779
+ if (c === CC_LBRACE) depth++;else if (c === CC_RBRACE) {
1780
+ depth--;
1781
+ if (depth === 0) {
1782
+ this.advance();
1783
+ return;
1784
+ }
1785
+ }
1786
+ this.advance();
1787
+ }
1788
+ }
1789
+
1790
+ /**
1791
+ * Lookahead: scan forward from current position and return true if
1792
+ * an unescaped `{` at depth 0 is found before any `;` or `}`.
1793
+ * Used in `rule` block mode to distinguish declarations from nested rules.
1794
+ */
1795
+ }, {
1796
+ key: "lookaheadIsRule",
1797
+ value: function lookaheadIsRule() {
1798
+ var i = this.pos,
1799
+ depth = 0;
1800
+ while (i < this.length) {
1801
+ var c = this.input.charCodeAt(i);
1802
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1803
+ var q = c;
1804
+ i++;
1805
+ while (i < this.length && this.input.charCodeAt(i) !== q) {
1806
+ if (this.input.charCodeAt(i) === CC_BSLASH) i++;
1807
+ i++;
1808
+ }
1809
+ i++;
1810
+ continue;
1811
+ }
1812
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1813
+ depth++;
1814
+ i++;
1815
+ continue;
1816
+ }
1817
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1818
+ depth--;
1819
+ i++;
1820
+ continue;
1821
+ }
1822
+ if (depth === 0) {
1823
+ if (c === CC_LBRACE) return true;
1824
+ if (c === CC_SEMI || c === CC_RBRACE) return false;
1825
+ }
1826
+ i++;
1827
+ }
1828
+ return false;
1829
+ }
1830
+
1831
+ /**
1832
+ * Characters that unambiguously start a CSS nesting selector
1833
+ * (can never be the start of a property name).
1834
+ */
1835
+ }, {
1836
+ key: "isNestingStart",
1837
+ value: function isNestingStart(c) {
1838
+ return c === CC_AMP // & nesting selector
1839
+ || c === CC_DOT // . class
1840
+ || c === CC_HASH // # id
1841
+ || c === CC_LBRACK // [ attribute
1842
+ || c === 42 // * universal
1843
+ || c === CC_GT // > child combinator
1844
+ || c === CC_PLUS // + adjacent sibling
1845
+ || c === CC_TILDE // ~ general sibling
1846
+ || c === CC_COLON; // : pseudo-class / ::pseudo-element
1847
+ }
1848
+
1849
+ /** Advance past chars until one of the given charcodes (exclusive). */
1850
+ }, {
1851
+ key: "recoverTo",
1852
+ value: function recoverTo() {
1853
+ for (var _len = arguments.length, stops = new Array(_len), _key = 0; _key < _len; _key++) {
1854
+ stops[_key] = arguments[_key];
1855
+ }
1856
+ while (this.pos < this.length && !stops.includes(this.peek())) this.advance();
1857
+ }
1858
+
1859
+ /** Advance past chars until one of the given charcodes, then advance one more. */
1860
+ }, {
1861
+ key: "recoverPast",
1862
+ value: function recoverPast() {
1863
+ this.recoverTo.apply(this, arguments);
1864
+ if (this.pos < this.length) this.advance();
1865
+ }
1866
+
1867
+ // ── Location helpers ──────────────────────────────────────────────────────
1868
+ }, {
1869
+ key: "locPos",
1870
+ value: function locPos() {
1871
+ return {
1872
+ line: this.line,
1873
+ column: this.col,
1874
+ offset: this.pos
1875
+ };
1876
+ }
1877
+
1878
+ // ── Stylesheet categorizer ────────────────────────────────────────────────
1879
+ }, {
1880
+ key: "categorize",
1881
+ value: function categorize(ss, node) {
1882
+ var _ar$preludeText, _ar$preludeText2;
1883
+ if (node.type !== 'atrule') return;
1884
+ var ar = node;
1885
+ var base = ar.name.replace(/^-(webkit|moz|ms|o)-/, '');
1886
+ switch (base) {
1887
+ case 'import':
1888
+ ss.imports.push(ar);
1889
+ break;
1890
+ case 'media':
1891
+ ss.mediaQueries.push({
1892
+ type: 'media-query',
1893
+ media: (_ar$preludeText = ar.preludeText) !== null && _ar$preludeText !== void 0 ? _ar$preludeText : '',
1894
+ features: [],
1895
+ loc: ar.loc
1896
+ });
1897
+ break;
1898
+ case 'namespace':
1899
+ ss.namespaces.push(ar);
1900
+ break;
1901
+ case 'keyframes':
1902
+ ss.keyframes.push(ar);
1903
+ break;
1904
+ case 'font-face':
1905
+ ss.fontFaces.push(ar);
1906
+ break;
1907
+ case 'layer':
1908
+ {
1909
+ var layerRule = ar;
1910
+ // preludeText holds the layer name (e.g. "atomic" for "@layer atomic { … }")
1911
+ if (ar.preludeText) layerRule.layerName = ar.preludeText.trim();
1912
+ ss.layers.push(layerRule);
1913
+ break;
1914
+ }
1915
+ case 'container':
1916
+ {
1917
+ var containerRule = ar;
1918
+ if (ar.preludeText) {
1919
+ // "@container main (width > 600px)" → name is the first token
1920
+ var parts = ar.preludeText.trim().match(/^([\w-]+)?\s*(.*)/);
1921
+ if (parts !== null && parts !== void 0 && parts[1]) containerRule.containerName = parts[1];
1922
+ if (parts !== null && parts !== void 0 && parts[2]) containerRule.containerQuery = parts[2].trim();
1923
+ }
1924
+ ss.containers.push(containerRule);
1925
+ break;
1926
+ }
1927
+ case 'supports':
1928
+ ss.supports.push(ar);
1929
+ break;
1930
+ case 'document':
1931
+ ss.documents.push(ar);
1932
+ break;
1933
+ case 'page':
1934
+ ss.pages.push(ar);
1935
+ break;
1936
+ case 'counter-style':
1937
+ ss.counterStyles.push(ar);
1938
+ break;
1939
+ case 'font-feature-values':
1940
+ ss.fontFeatureValues.push(ar);
1941
+ break;
1942
+ case 'viewport':
1943
+ ss.viewports.push(ar);
1944
+ break;
1945
+ case 'charset':
1946
+ ss.charsets.push(ar);
1947
+ ss.charset = (_ar$preludeText2 = ar.preludeText) === null || _ar$preludeText2 === void 0 ? void 0 : _ar$preludeText2.replace(/^['"]|['"]$/g, '');
1948
+ break;
1949
+ }
1950
+ }
1951
+
1952
+ // ── Legacy format ─────────────────────────────────────────────────────────
1953
+ }, {
1954
+ key: "toLegacyNode",
1955
+ value: function toLegacyNode(node) {
1956
+ var _this2 = this;
1957
+ switch (node.type) {
1958
+ case 'rule':
1959
+ {
1960
+ var _r$rawSelector;
1961
+ var r = node;
1962
+ var name = (_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : r.selectors.map(function (s) {
1963
+ return s.value;
1964
+ }).join(', ');
1965
+ return {
1966
+ kind: 'rule',
1967
+ name: name,
1968
+ value: r.declarations.map(function (d) {
1969
+ var _d$rawValue;
1970
+ return "".concat(d.property, ": ").concat((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : d.value.map(function (v) {
1971
+ return String(v.value);
1972
+ }).join(' ')).concat(d.important ? ' !important' : '');
1973
+ }).join('; '),
1974
+ important: false,
1975
+ children: r.declarations.map(function (d) {
1976
+ return _this2.toLegacyNode(d);
1977
+ }).filter(Boolean),
1978
+ loc: r.loc,
1979
+ node: 'rule',
1980
+ cssNode: {},
1981
+ parents: [],
1982
+ selectors: r.selectors.map(function (s) {
1983
+ return {
1984
+ kind: 'rule',
1985
+ name: s.value,
1986
+ value: s.value,
1987
+ loc: s.loc,
1988
+ node: 'selector',
1989
+ cssNode: {},
1990
+ parents: []
1991
+ };
1992
+ })
1993
+ };
1994
+ }
1995
+ case 'atrule':
1996
+ {
1997
+ var _ref, _ar$preludeText3, _ar$prelude, _ar$block$children, _ar$block;
1998
+ var ar = node;
1999
+ return {
2000
+ kind: 'atrule',
2001
+ name: ar.name,
2002
+ value: (_ref = (_ar$preludeText3 = ar.preludeText) !== null && _ar$preludeText3 !== void 0 ? _ar$preludeText3 : (_ar$prelude = ar.prelude) === null || _ar$prelude === void 0 ? void 0 : _ar$prelude.map(function (v) {
2003
+ return String(v.value);
2004
+ }).join(' ')) !== null && _ref !== void 0 ? _ref : '',
2005
+ important: false,
2006
+ children: ((_ar$block$children = (_ar$block = ar.block) === null || _ar$block === void 0 ? void 0 : _ar$block.children) !== null && _ar$block$children !== void 0 ? _ar$block$children : []).map(function (c) {
2007
+ return _this2.toLegacyNode(c);
2008
+ }).filter(Boolean),
2009
+ loc: ar.loc,
2010
+ node: 'atrule',
2011
+ cssNode: {},
2012
+ parents: []
2013
+ };
2014
+ }
2015
+ case 'declaration':
2016
+ {
2017
+ var _d$rawValue2;
2018
+ var d = node;
2019
+ return {
2020
+ kind: 'decl',
2021
+ name: d.property,
2022
+ value: (_d$rawValue2 = d.rawValue) !== null && _d$rawValue2 !== void 0 ? _d$rawValue2 : d.value.map(function (v) {
2023
+ return String(v.value);
2024
+ }).join(' '),
2025
+ important: d.important,
2026
+ children: [],
2027
+ loc: d.loc,
2028
+ node: 'declaration',
2029
+ cssNode: {},
2030
+ parents: []
2031
+ };
2032
+ }
2033
+ case 'comment':
2034
+ {
2035
+ var c = node;
2036
+ return {
2037
+ kind: 'comment',
2038
+ name: undefined,
2039
+ value: c.value,
2040
+ important: false,
2041
+ children: [],
2042
+ loc: c.loc,
2043
+ node: 'comment',
2044
+ cssNode: {},
2045
+ parents: []
2046
+ };
2047
+ }
2048
+ default:
2049
+ return null;
2050
+ }
2051
+ }
2052
+ }], [{
2053
+ key: "emptyStats",
2054
+ value: function emptyStats() {
2055
+ return {
2056
+ totalNodes: 0,
2057
+ totalRules: 0,
2058
+ totalDeclarations: 0,
2059
+ totalAtRules: 0,
2060
+ totalComments: 0,
2061
+ totalSelectors: 0,
2062
+ totalValues: 0,
2063
+ parseTime: 0,
2064
+ memoryUsage: 0,
2065
+ errors: 0,
2066
+ warnings: 0
2067
+ };
2068
+ }
2069
+ }]);
2070
+ }();
2071
+
2072
+ // ─── Public parse helpers ─────────────────────────────────────────────────────
2073
+
2074
+ /** Parse a CSS string into a stylesheet AST. */
2075
+ function parseCss(css, options) {
2076
+ return new CssParser(options).parse(css);
2077
+ }
2078
+
2079
+ // Read `@theme { --color-red-500: …; --spacing: …; }` blocks from CSS into a
2080
+ // Theme. This is the CSS-first way to define tokens; the registry is then
2081
+ // built from the resulting theme.
2082
+ function loadTheme(css) {
2083
+ var theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Theme();
2084
+ var sheet = parseCss(css);
2085
+ var _iterator = _createForOfIteratorHelper(sheet.children),
2086
+ _step;
2087
+ try {
2088
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2089
+ var node = _step.value;
2090
+ if (node.type === 'atrule' && node.name === 'theme' && node.block) {
2091
+ collect(node, theme);
2092
+ }
2093
+ }
2094
+ } catch (err) {
2095
+ _iterator.e(err);
2096
+ } finally {
2097
+ _iterator.f();
2098
+ }
2099
+ return theme;
2100
+ }
2101
+ function collect(atRule, theme) {
2102
+ var _iterator2 = _createForOfIteratorHelper(atRule.block.children),
2103
+ _step2;
2104
+ try {
2105
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2106
+ var child = _step2.value;
2107
+ if (child.type === 'declaration' && isCustomProperty(child)) {
2108
+ var _child$rawValue;
2109
+ theme.add(child.property, ((_child$rawValue = child.rawValue) !== null && _child$rawValue !== void 0 ? _child$rawValue : '').trim());
2110
+ }
2111
+ }
2112
+ } catch (err) {
2113
+ _iterator2.e(err);
2114
+ } finally {
2115
+ _iterator2.f();
2116
+ }
2117
+ }
2118
+ function isCustomProperty(d) {
2119
+ return d.customProperty === true || d.property.startsWith('--');
2120
+ }
2121
+
2122
+ // Emit the theme as `:root { --token: value; … }` so the tokens ship as live
2123
+ // custom properties. Pass `used` to emit only the tokens actually referenced
2124
+ // (plus any they transitively reference) — see {@link collectVarRefs}.
2125
+ function emitTheme(theme) {
2126
+ var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':root';
2127
+ var used = arguments.length > 2 ? arguments[2] : undefined;
2128
+ var entries = used ? usedEntries(theme, used) : theme.entries();
2129
+ return rule(selector, entries.map(function (_ref) {
2130
+ var _ref2 = _slicedToArray(_ref, 2),
2131
+ name = _ref2[0],
2132
+ value = _ref2[1];
2133
+ return decl(name, value);
2134
+ }));
2135
+ }
2136
+ var VAR_REF = /var\(\s*(--[\w-]+)/g;
2137
+
2138
+ // Every `--token` referenced through `var(--token)` across a compiled tree.
2139
+ function collectVarRefs(nodes) {
2140
+ var into = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
2141
+ var _iterator3 = _createForOfIteratorHelper(nodes),
2142
+ _step3;
2143
+ try {
2144
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
2145
+ var node = _step3.value;
2146
+ if (node.kind === 'declaration') {
2147
+ var _iterator4 = _createForOfIteratorHelper(node.value.matchAll(VAR_REF)),
2148
+ _step4;
2149
+ try {
2150
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
2151
+ var m = _step4.value;
2152
+ into.add(m[1]);
2153
+ }
2154
+ } catch (err) {
2155
+ _iterator4.e(err);
2156
+ } finally {
2157
+ _iterator4.f();
2158
+ }
2159
+ } else if (node.kind === 'raw') {
2160
+ var _iterator5 = _createForOfIteratorHelper(node.text.matchAll(VAR_REF)),
2161
+ _step5;
2162
+ try {
2163
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
2164
+ var _m = _step5.value;
2165
+ into.add(_m[1]);
2166
+ }
2167
+ } catch (err) {
2168
+ _iterator5.e(err);
2169
+ } finally {
2170
+ _iterator5.f();
2171
+ }
2172
+ } else {
2173
+ collectVarRefs(node.nodes, into);
2174
+ }
2175
+ }
2176
+ } catch (err) {
2177
+ _iterator3.e(err);
2178
+ } finally {
2179
+ _iterator3.f();
2180
+ }
2181
+ return into;
2182
+ }
2183
+
2184
+ // The theme entries to keep for `used`: the referenced tokens plus the transitive
2185
+ // closure of any tokens their own values reference (e.g. `--color-primary:
2186
+ // var(--color-blue-500)`). Insertion order is preserved.
2187
+ function usedEntries(theme, used) {
2188
+ var keep = new Set();
2189
+ var stack = _toConsumableArray(used);
2190
+ while (stack.length) {
2191
+ var name = stack.pop();
2192
+ if (keep.has(name)) continue;
2193
+ var value = theme.get(name);
2194
+ if (value === undefined) continue; // referenced but not a theme token
2195
+ keep.add(name);
2196
+ var _iterator6 = _createForOfIteratorHelper(value.matchAll(VAR_REF)),
2197
+ _step6;
2198
+ try {
2199
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
2200
+ var m = _step6.value;
2201
+ stack.push(m[1]);
2202
+ }
2203
+ } catch (err) {
2204
+ _iterator6.e(err);
2205
+ } finally {
2206
+ _iterator6.f();
2207
+ }
2208
+ }
2209
+ return theme.entries().filter(function (_ref3) {
2210
+ var _ref4 = _slicedToArray(_ref3, 1),
2211
+ name = _ref4[0];
2212
+ return keep.has(name);
2213
+ });
2214
+ }
2215
+
2216
+ // Reads `@utility` and `@custom-variant` blocks from CSS and registers them into
2217
+ // the registry — the CSS-first way to add utilities and variants, alongside
2218
+ // `@theme` for tokens. Call after loadTheme so functional utilities can resolve
2219
+ // against the theme.
2220
+ function loadDirectives(css, reg) {
2221
+ var sheet = parseCss(css);
2222
+ var _iterator = _createForOfIteratorHelper(sheet.children),
2223
+ _step;
2224
+ try {
2225
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2226
+ var node = _step.value;
2227
+ if (node.type !== 'atrule') continue;
2228
+ if (node.name === 'utility') registerUtility(node, reg);else if (node.name === 'custom-variant') registerVariant(node, reg);
2229
+ }
2230
+ } catch (err) {
2231
+ _iterator.e(err);
2232
+ } finally {
2233
+ _iterator.f();
2234
+ }
2235
+ return reg;
2236
+ }
2237
+ function registerUtility(atRule, reg) {
2238
+ var _atRule$preludeText;
2239
+ var name = ((_atRule$preludeText = atRule.preludeText) !== null && _atRule$preludeText !== void 0 ? _atRule$preludeText : '').trim();
2240
+ if (!name || !atRule.block) return;
2241
+ var decls = atRule.block.children.filter(function (c) {
2242
+ return c.type === 'declaration';
2243
+ }).map(function (d) {
2244
+ var _d$rawValue;
2245
+ return decl(d.property, ((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : '').trim(), d.important === true);
2246
+ });
2247
+ if (decls.length === 0) return;
2248
+
2249
+ // A trailing `-*` marks a functional utility: `tab-*` handles `tab-2`, `tab-[3]`.
2250
+ if (name.endsWith('-*')) {
2251
+ var root = name.slice(0, -2);
2252
+ if (root) reg.dynamicRule(root, function (ctx) {
2253
+ return resolveDeclarations(decls, ctx);
2254
+ });
2255
+ return;
2256
+ }
2257
+ reg.rule(name, decls);
2258
+ }
2259
+
2260
+ // Applies a functional utility's declaration templates to one atom. `--value()`
2261
+ // is required — if it can't resolve, the whole utility is dropped (returns null).
2262
+ // `--modifier()` is optional — a declaration using it is skipped when there's no
2263
+ // matching modifier, so `text-lg` and `text-lg/7` share one definition.
2264
+ function resolveDeclarations(templates, ctx) {
2265
+ var out = [];
2266
+ var _iterator2 = _createForOfIteratorHelper(templates),
2267
+ _step2;
2268
+ try {
2269
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2270
+ var t = _step2.value;
2271
+ var withValue = replaceFn(t.value, '--value', function (args) {
2272
+ return resolveValue(args, ctx);
2273
+ });
2274
+ if (withValue === null) return null;
2275
+ var withModifier = replaceFn(withValue, '--modifier', function (args) {
2276
+ return resolveModifier(args, ctx);
2277
+ });
2278
+ if (withModifier === null) continue;
2279
+ out.push(_objectSpread2(_objectSpread2({}, t), {}, {
2280
+ value: withModifier
2281
+ }));
2282
+ }
2283
+ } catch (err) {
2284
+ _iterator2.e(err);
2285
+ } finally {
2286
+ _iterator2.f();
2287
+ }
2288
+ return out.length ? out : null;
2289
+ }
2290
+ function resolveValue(args, ctx) {
2291
+ var value = ctx.value;
2292
+ if (!value) return null;
2293
+ for (var _i = 0, _splitArgs = splitArgs(args); _i < _splitArgs.length; _i++) {
2294
+ var arg = _splitArgs[_i];
2295
+ var themed = fromTheme(arg, value.kind === 'named' ? value.value : null, ctx);
2296
+ if (themed !== null) return themed;
2297
+ if (value.kind === 'named') {
2298
+ var lit = fromNamed(arg, value.value);
2299
+ if (lit !== null) return lit;
2300
+ } else {
2301
+ var arb = fromArbitrary(arg, value.value, value.dataType);
2302
+ if (arb !== null) return arb;
2303
+ }
2304
+ }
2305
+ return null;
2306
+ }
2307
+ function resolveModifier(args, ctx) {
2308
+ var modifier = ctx.modifier;
2309
+ if (!modifier) return null;
2310
+ for (var _i2 = 0, _splitArgs2 = splitArgs(args); _i2 < _splitArgs2.length; _i2++) {
2311
+ var arg = _splitArgs2[_i2];
2312
+ var themed = fromTheme(arg, modifier.kind === 'named' ? modifier.value : null, ctx);
2313
+ if (themed !== null) return themed;
2314
+ if (modifier.kind === 'named') {
2315
+ var lit = fromNamed(arg, modifier.value);
2316
+ if (lit !== null) return lit;
2317
+ } else {
2318
+ var arb = fromArbitrary(arg, modifier.value, null);
2319
+ if (arb !== null) return arb;
2320
+ }
2321
+ }
2322
+ return null;
2323
+ }
2324
+
2325
+ // `--foo` / `--foo-*` names a theme namespace; the atom's named value keys into
2326
+ // it (`--value(--tab-size)` + `tab-2` → `var(--tab-size-2)`).
2327
+ function fromTheme(arg, key, ctx) {
2328
+ if (key === null || !arg.startsWith('--')) return null;
2329
+ var ns = arg.replace(/-?\*$/, '').slice(2);
2330
+ return ns ? ctx.theme.resolve(ns, key) : null;
2331
+ }
2332
+
2333
+ // A bare value against a data-type keyword (`integer`, `number`, `percentage`) or a
2334
+ // quoted literal (`'inline'`).
2335
+ function fromNamed(arg, value) {
2336
+ if (isQuoted(arg)) return arg.slice(1, -1) === value ? value : null;
2337
+ var rx = NUMERIC[arg];
2338
+ return rx ? rx.test(value) ? value : null : null;
2339
+ }
2340
+
2341
+ // An arbitrary value against `[*]` (anything) or a typed bracket (`[integer]`,
2342
+ // `[length]`), gated on the value's own `type:` hint when it carries one.
2343
+ function fromArbitrary(arg, value, dataType) {
2344
+ if (arg[0] !== '[' || arg[arg.length - 1] !== ']') return null;
2345
+ var want = arg.slice(1, -1);
2346
+ if (want === '*') return value;
2347
+ if (dataType !== null) return dataType === want ? value : null;
2348
+ // Untyped arbitrary: validate against the simple numeric types we can check.
2349
+ var rx = NUMERIC[want];
2350
+ return rx ? rx.test(value) ? value : null : value;
2351
+ }
2352
+ var NUMERIC = {
2353
+ integer: /^-?\d+$/,
2354
+ number: /^-?\d*\.?\d+$/,
2355
+ percentage: /^-?\d*\.?\d+%$/
2356
+ };
2357
+ function isQuoted(s) {
2358
+ return s.length >= 2 && (s[0] === '"' || s[0] === "'") && s[s.length - 1] === s[0];
2359
+ }
2360
+ function splitArgs(args) {
2361
+ return splitAtTopLevel(args, ',').map(function (a) {
2362
+ return a.trim();
2363
+ }).filter(function (a) {
2364
+ return a !== '';
2365
+ });
2366
+ }
2367
+
2368
+ // Replaces every `name(...)` call in `input` (parens balanced, even when nested in
2369
+ // `calc(...)`) with `resolve`'s result. Returns null if any call fails to resolve.
2370
+ function replaceFn(input, name, resolve) {
2371
+ var token = name + '(';
2372
+ var out = '';
2373
+ var i = 0;
2374
+ for (;;) {
2375
+ var start = input.indexOf(token, i);
2376
+ if (start === -1) return out + input.slice(i);
2377
+ out += input.slice(i, start);
2378
+ var depth = 0;
2379
+ var j = start + token.length - 1;
2380
+ for (; j < input.length; j++) {
2381
+ if (input[j] === '(') depth++;else if (input[j] === ')' && --depth === 0) break;
2382
+ }
2383
+ if (j >= input.length) return null; // unbalanced
2384
+ var resolved = resolve(input.slice(start + token.length, j));
2385
+ if (resolved === null) return null;
2386
+ out += resolved;
2387
+ i = j + 1;
2388
+ }
2389
+ }
2390
+ function registerVariant(atRule, reg) {
2391
+ var _atRule$preludeText2;
2392
+ var prelude = ((_atRule$preludeText2 = atRule.preludeText) !== null && _atRule$preludeText2 !== void 0 ? _atRule$preludeText2 : '').trim();
2393
+ if (!prelude) return;
2394
+
2395
+ // `name (condition)` shorthand — the block form isn't supported yet.
2396
+ var paren = prelude.indexOf('(');
2397
+ if (paren === -1 || !prelude.endsWith(')')) return;
2398
+ var name = prelude.slice(0, paren).trim();
2399
+ var condition = prelude.slice(paren + 1, -1).trim();
2400
+ if (!name || !condition) return;
2401
+ reg.variant(name, wrapFor(condition));
2402
+ }
2403
+ function wrapFor(condition) {
2404
+ if (condition[0] === '@') {
2405
+ var cut = condition.search(/[\s(]/);
2406
+ var at = cut === -1 ? condition.slice(1) : condition.slice(1, cut);
2407
+ var params = cut === -1 ? '' : condition.slice(cut).trim();
2408
+ return {
2409
+ atRule: {
2410
+ name: at,
2411
+ params: params
2412
+ }
2413
+ };
2414
+ }
2415
+ return {
2416
+ selector: condition.includes('&') ? condition : "&".concat(condition)
2417
+ };
2418
+ }
2419
+
2420
+ // A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps
2421
+ // the rule in an at-rule (`@media`, `@supports`). It may do both.
2422
+
2423
+ // Holds the theme plus the rule and variant tables, and answers the keyword vs
2424
+ // value-taking questions the atom parser asks.
2425
+ var Registry = /*#__PURE__*/function () {
2426
+ function Registry() {
2427
+ var _this = this;
2428
+ var theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Theme();
2429
+ _classCallCheck(this, Registry);
2430
+ _defineProperty(this, "rules", new Map());
2431
+ _defineProperty(this, "dynamicRules", new Map());
2432
+ _defineProperty(this, "variants", new Map());
2433
+ _defineProperty(this, "dynamicVariants", new Map());
2434
+ _defineProperty(this, "isRule", function (root) {
2435
+ return _this.rules.has(root);
2436
+ });
2437
+ _defineProperty(this, "isDynamicRule", function (root) {
2438
+ return _this.dynamicRules.has(root);
2439
+ });
2440
+ _defineProperty(this, "isVariant", function (root) {
2441
+ return _this.variants.has(root);
2442
+ });
2443
+ _defineProperty(this, "isDynamicVariant", function (root) {
2444
+ return _this.dynamicVariants.has(root);
2445
+ });
2446
+ this.theme = theme;
2447
+ }
2448
+ return _createClass(Registry, [{
2449
+ key: "rule",
2450
+ value: function rule(name, declarations) {
2451
+ this.rules.set(name, declarations);
2452
+ return this;
2453
+ }
2454
+ }, {
2455
+ key: "dynamicRule",
2456
+ value: function dynamicRule(name, handler) {
2457
+ this.dynamicRules.set(name, handler);
2458
+ return this;
2459
+ }
2460
+ }, {
2461
+ key: "variant",
2462
+ value: function variant(name, wrap) {
2463
+ this.variants.set(name, wrap);
2464
+ return this;
2465
+ }
2466
+ }, {
2467
+ key: "dynamicVariant",
2468
+ value: function dynamicVariant(name, handler) {
2469
+ this.dynamicVariants.set(name, handler);
2470
+ return this;
2471
+ }
2472
+ }, {
2473
+ key: "getRule",
2474
+ value: function getRule(root) {
2475
+ var _this$rules$get;
2476
+ return (_this$rules$get = this.rules.get(root)) !== null && _this$rules$get !== void 0 ? _this$rules$get : null;
2477
+ }
2478
+ }, {
2479
+ key: "getDynamicRule",
2480
+ value: function getDynamicRule(root) {
2481
+ var _this$dynamicRules$ge;
2482
+ return (_this$dynamicRules$ge = this.dynamicRules.get(root)) !== null && _this$dynamicRules$ge !== void 0 ? _this$dynamicRules$ge : null;
2483
+ }
2484
+ }, {
2485
+ key: "getVariant",
2486
+ value: function getVariant(name) {
2487
+ var _this$variants$get;
2488
+ return (_this$variants$get = this.variants.get(name)) !== null && _this$variants$get !== void 0 ? _this$variants$get : null;
2489
+ }
2490
+ }, {
2491
+ key: "getDynamicVariant",
2492
+ value: function getDynamicVariant(root) {
2493
+ var _this$dynamicVariants;
2494
+ return (_this$dynamicVariants = this.dynamicVariants.get(root)) !== null && _this$dynamicVariants !== void 0 ? _this$dynamicVariants : null;
2495
+ }
2496
+ }]);
2497
+ }();
2498
+
2499
+ // Turns a parsed atom into CSS. Returns null when the utility or any of its
2500
+ // variants aren't registered, so an unknown class simply produces nothing.
2501
+ function compileAtom(atom, reg) {
2502
+ var declarations = declarationsFor(atom, reg);
2503
+ if (!declarations || declarations.length === 0) return null;
2504
+ if (atom.important) {
2505
+ var _iterator = _createForOfIteratorHelper(declarations),
2506
+ _step;
2507
+ try {
2508
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2509
+ var d = _step.value;
2510
+ d.important = true;
2511
+ }
2512
+ } catch (err) {
2513
+ _iterator.e(err);
2514
+ } finally {
2515
+ _iterator.f();
2516
+ }
2517
+ }
2518
+ var selector = '.' + escapeClass(atom.raw);
2519
+ var atRules = [];
2520
+ var _iterator2 = _createForOfIteratorHelper(atom.variants),
2521
+ _step2;
2522
+ try {
2523
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
2524
+ var variant = _step2.value;
2525
+ var wrap = resolveVariant(variant, reg);
2526
+ if (!wrap) return null;
2527
+ if (wrap.selector) selector = substitute(wrap.selector, selector);
2528
+ if (wrap.atRule) atRules.push(wrap.atRule);
2529
+ }
2530
+ } catch (err) {
2531
+ _iterator2.e(err);
2532
+ } finally {
2533
+ _iterator2.f();
2534
+ }
2535
+ var node = rule(selector, declarations);
2536
+ for (var _i = 0, _atRules = atRules; _i < _atRules.length; _i++) {
2537
+ var ar = _atRules[_i];
2538
+ node = atRule(ar.name, ar.params, [node]);
2539
+ }
2540
+ return [node];
2541
+ }
2542
+ function declarationsFor(atom, reg) {
2543
+ if (atom.kind === 'arbitrary-property') {
2544
+ return [decl(atom.property, atom.value)];
2545
+ }
2546
+ if (atom.kind === 'static') {
2547
+ var decls = reg.getRule(atom.root);
2548
+ return decls ? decls.map(function (d) {
2549
+ return _objectSpread2({}, d);
2550
+ }) : null;
2551
+ }
2552
+ var handler = reg.getDynamicRule(atom.root);
2553
+ if (!handler) return null;
2554
+ return handler({
2555
+ value: atom.value,
2556
+ modifier: atom.modifier,
2557
+ negative: atom.negative,
2558
+ theme: reg.theme
2559
+ });
2560
+ }
2561
+ function resolveVariant(variant, reg) {
2562
+ if (variant.kind === 'arbitrary') return arbitraryVariant(variant.selector);
2563
+ if (variant.kind === 'static') return reg.getVariant(variant.root);
2564
+ // functional: a null value means it's really a static variant (hover, md, …).
2565
+ if (variant.value === null) return reg.getVariant(variant.root);
2566
+ var handler = reg.getDynamicVariant(variant.root);
2567
+ return handler ? handler(variant.value, variant.modifier) : null;
2568
+ }
2569
+
2570
+ // `[&_p]` → `& p`, `[.parent_&]` → `.parent &`, `[@media(...)]` → an at-rule.
2571
+ // A bare selector with no `&` is attached to the element.
2572
+ function arbitraryVariant(source) {
2573
+ if (source[0] === '@') {
2574
+ var cut = source.search(/[\s(]/);
2575
+ var name = cut === -1 ? source.slice(1) : source.slice(1, cut);
2576
+ var params = cut === -1 ? '' : source.slice(cut).trim();
2577
+ return {
2578
+ atRule: {
2579
+ name: name,
2580
+ params: params
2581
+ }
2582
+ };
2583
+ }
2584
+ var sel = spacesFromUnderscores(source);
2585
+ return {
2586
+ selector: sel.includes('&') ? sel : "&".concat(sel)
2587
+ };
2588
+ }
2589
+ function spacesFromUnderscores(s) {
2590
+ return s.replace(/\\_/g, '\0').replace(/_/g, ' ').replace(/\0/g, '_');
2591
+ }
2592
+ function substitute(template, current) {
2593
+ return template.replace(/&/g, current);
2594
+ }
2595
+
2596
+ // Backslash-escape everything outside [A-Za-z0-9_-] so a utility name is a valid
2597
+ // class selector (`hover:bg-red-500/50` → `hover\:bg-red-500\/50`).
2598
+ function escapeClass(name) {
2599
+ return name.replace(/[^a-zA-Z0-9_-]/g, function (c) {
2600
+ return '\\' + c;
2601
+ });
2602
+ }
2603
+
2604
+ var Palettes = {
2605
+ "slate": {
2606
+ "50": "#f8fafc",
2607
+ "100": "#f1f5f9",
2608
+ "200": "#e2e8f0",
2609
+ "300": "#cbd5e1",
2610
+ "400": "#94a3b8",
2611
+ "500": "#64748b",
2612
+ "600": "#475569",
2613
+ "700": "#334155",
2614
+ "800": "#1e293b",
2615
+ "900": "#0f172a",
2616
+ "950": "#020617"
2617
+ },
2618
+ "gray": {
2619
+ "50": "#f9fafb",
2620
+ "100": "#f3f4f6",
2621
+ "200": "#e5e7eb",
2622
+ "300": "#d1d5db",
2623
+ "400": "#9ca3af",
2624
+ "500": "#6b7280",
2625
+ "600": "#4b5563",
2626
+ "700": "#374151",
2627
+ "800": "#1f2937",
2628
+ "900": "#111827",
2629
+ "950": "#030712"
2630
+ },
2631
+ "zinc": {
2632
+ "50": "#fafafa",
2633
+ "100": "#f4f4f5",
2634
+ "200": "#e4e4e7",
2635
+ "300": "#d4d4d8",
2636
+ "400": "#a1a1aa",
2637
+ "500": "#71717a",
2638
+ "600": "#52525b",
2639
+ "700": "#3f3f46",
2640
+ "800": "#27272a",
2641
+ "900": "#18181b",
2642
+ "950": "#09090b"
2643
+ },
2644
+ "neutral": {
2645
+ "50": "#fafafa",
2646
+ "100": "#f5f5f5",
2647
+ "200": "#e5e5e5",
2648
+ "300": "#d4d4d4",
2649
+ "400": "#a3a3a3",
2650
+ "500": "#737373",
2651
+ "600": "#525252",
2652
+ "700": "#404040",
2653
+ "800": "#262626",
2654
+ "900": "#171717",
2655
+ "950": "#0a0a0a"
2656
+ },
2657
+ "stone": {
2658
+ "50": "#fafaf9",
2659
+ "100": "#f5f5f4",
2660
+ "200": "#e7e5e4",
2661
+ "300": "#d6d3d1",
2662
+ "400": "#a8a29e",
2663
+ "500": "#78716c",
2664
+ "600": "#57534e",
2665
+ "700": "#44403c",
2666
+ "800": "#292524",
2667
+ "900": "#1c1917",
2668
+ "950": "#0c0a09"
2669
+ },
2670
+ "red": {
2671
+ "50": "#fef2f2",
2672
+ "100": "#fee2e2",
2673
+ "200": "#fecaca",
2674
+ "300": "#fca5a5",
2675
+ "400": "#f87171",
2676
+ "500": "#ef4444",
2677
+ "600": "#dc2626",
2678
+ "700": "#b91c1c",
2679
+ "800": "#991b1b",
2680
+ "900": "#7f1d1d",
2681
+ "950": "#450a0a"
2682
+ },
2683
+ "orange": {
2684
+ "50": "#fff7ed",
2685
+ "100": "#ffedd5",
2686
+ "200": "#fed7aa",
2687
+ "300": "#fdba74",
2688
+ "400": "#fb923c",
2689
+ "500": "#f97316",
2690
+ "600": "#ea580c",
2691
+ "700": "#c2410c",
2692
+ "800": "#9a3412",
2693
+ "900": "#7c2d12",
2694
+ "950": "#431407"
2695
+ },
2696
+ "amber": {
2697
+ "50": "#fffbeb",
2698
+ "100": "#fef3c7",
2699
+ "200": "#fde68a",
2700
+ "300": "#fcd34d",
2701
+ "400": "#fbbf24",
2702
+ "500": "#f59e0b",
2703
+ "600": "#d97706",
2704
+ "700": "#b45309",
2705
+ "800": "#92400e",
2706
+ "900": "#78350f",
2707
+ "950": "#451a03"
2708
+ },
2709
+ "yellow": {
2710
+ "50": "#fefce8",
2711
+ "100": "#fef9c3",
2712
+ "200": "#fef08a",
2713
+ "300": "#fde047",
2714
+ "400": "#facc15",
2715
+ "500": "#eab308",
2716
+ "600": "#ca8a04",
2717
+ "700": "#a16207",
2718
+ "800": "#854d0e",
2719
+ "900": "#713f12",
2720
+ "950": "#422006"
2721
+ },
2722
+ "lime": {
2723
+ "50": "#f7fee7",
2724
+ "100": "#ecfccb",
2725
+ "200": "#d9f99d",
2726
+ "300": "#bef264",
2727
+ "400": "#a3e635",
2728
+ "500": "#84cc16",
2729
+ "600": "#65a30d",
2730
+ "700": "#4d7c0f",
2731
+ "800": "#3f6212",
2732
+ "900": "#365314",
2733
+ "950": "#1a2e05"
2734
+ },
2735
+ "green": {
2736
+ "50": "#f0fdf4",
2737
+ "100": "#dcfce7",
2738
+ "200": "#bbf7d0",
2739
+ "300": "#86efac",
2740
+ "400": "#4ade80",
2741
+ "500": "#22c55e",
2742
+ "600": "#16a34a",
2743
+ "700": "#15803d",
2744
+ "800": "#166534",
2745
+ "900": "#14532d",
2746
+ "950": "#052e16"
2747
+ },
2748
+ "emerald": {
2749
+ "50": "#ecfdf5",
2750
+ "100": "#d1fae5",
2751
+ "200": "#a7f3d0",
2752
+ "300": "#6ee7b7",
2753
+ "400": "#34d399",
2754
+ "500": "#10b981",
2755
+ "600": "#059669",
2756
+ "700": "#047857",
2757
+ "800": "#065f46",
2758
+ "900": "#064e3b",
2759
+ "950": "#022c22"
2760
+ },
2761
+ "teal": {
2762
+ "50": "#f0fdfa",
2763
+ "100": "#ccfbf1",
2764
+ "200": "#99f6e4",
2765
+ "300": "#5eead4",
2766
+ "400": "#2dd4bf",
2767
+ "500": "#14b8a6",
2768
+ "600": "#0d9488",
2769
+ "700": "#0f766e",
2770
+ "800": "#115e59",
2771
+ "900": "#134e4a",
2772
+ "950": "#042f2e"
2773
+ },
2774
+ "cyan": {
2775
+ "50": "#ecfeff",
2776
+ "100": "#cffafe",
2777
+ "200": "#a5f3fc",
2778
+ "300": "#67e8f9",
2779
+ "400": "#22d3ee",
2780
+ "500": "#06b6d4",
2781
+ "600": "#0891b2",
2782
+ "700": "#0e7490",
2783
+ "800": "#155e75",
2784
+ "900": "#164e63",
2785
+ "950": "#083344"
2786
+ },
2787
+ "sky": {
2788
+ "50": "#f0f9ff",
2789
+ "100": "#e0f2fe",
2790
+ "200": "#bae6fd",
2791
+ "300": "#7dd3fc",
2792
+ "400": "#38bdf8",
2793
+ "500": "#0ea5e9",
2794
+ "600": "#0284c7",
2795
+ "700": "#0369a1",
2796
+ "800": "#075985",
2797
+ "900": "#0c4a6e",
2798
+ "950": "#082f49"
2799
+ },
2800
+ "blue": {
2801
+ "50": "#eff6ff",
2802
+ "100": "#dbeafe",
2803
+ "200": "#bfdbfe",
2804
+ "300": "#93c5fd",
2805
+ "400": "#60a5fa",
2806
+ "500": "#3b82f6",
2807
+ "600": "#2563eb",
2808
+ "700": "#1d4ed8",
2809
+ "800": "#1e40af",
2810
+ "900": "#1e3a8a",
2811
+ "950": "#172554"
2812
+ },
2813
+ "indigo": {
2814
+ "50": "#eef2ff",
2815
+ "100": "#e0e7ff",
2816
+ "200": "#c7d2fe",
2817
+ "300": "#a5b4fc",
2818
+ "400": "#818cf8",
2819
+ "500": "#6366f1",
2820
+ "600": "#4f46e5",
2821
+ "700": "#4338ca",
2822
+ "800": "#3730a3",
2823
+ "900": "#312e81",
2824
+ "950": "#1e1b4b"
2825
+ },
2826
+ "violet": {
2827
+ "50": "#f5f3ff",
2828
+ "100": "#ede9fe",
2829
+ "200": "#ddd6fe",
2830
+ "300": "#c4b5fd",
2831
+ "400": "#a78bfa",
2832
+ "500": "#8b5cf6",
2833
+ "600": "#7c3aed",
2834
+ "700": "#6d28d9",
2835
+ "800": "#5b21b6",
2836
+ "900": "#4c1d95",
2837
+ "950": "#2e1065"
2838
+ },
2839
+ "purple": {
2840
+ "50": "#faf5ff",
2841
+ "100": "#f3e8ff",
2842
+ "200": "#e9d5ff",
2843
+ "300": "#d8b4fe",
2844
+ "400": "#c084fc",
2845
+ "500": "#a855f7",
2846
+ "600": "#9333ea",
2847
+ "700": "#7e22ce",
2848
+ "800": "#6b21a8",
2849
+ "900": "#581c87",
2850
+ "950": "#3b0764"
2851
+ },
2852
+ "fuchsia": {
2853
+ "50": "#fdf4ff",
2854
+ "100": "#fae8ff",
2855
+ "200": "#f5d0fe",
2856
+ "300": "#f0abfc",
2857
+ "400": "#e879f9",
2858
+ "500": "#d946ef",
2859
+ "600": "#c026d3",
2860
+ "700": "#a21caf",
2861
+ "800": "#86198f",
2862
+ "900": "#701a75",
2863
+ "950": "#4a044e"
2864
+ },
2865
+ "pink": {
2866
+ "50": "#fdf2f8",
2867
+ "100": "#fce7f3",
2868
+ "200": "#fbcfe8",
2869
+ "300": "#f9a8d4",
2870
+ "400": "#f472b6",
2871
+ "500": "#ec4899",
2872
+ "600": "#db2777",
2873
+ "700": "#be185d",
2874
+ "800": "#9d174d",
2875
+ "900": "#831843",
2876
+ "950": "#500724"
2877
+ },
2878
+ "rose": {
2879
+ "50": "#fff1f2",
2880
+ "100": "#ffe4e6",
2881
+ "200": "#fecdd3",
2882
+ "300": "#fda4af",
2883
+ "400": "#fb7185",
2884
+ "500": "#f43f5e",
2885
+ "600": "#e11d48",
2886
+ "700": "#be123c",
2887
+ "800": "#9f1239",
2888
+ "900": "#881337",
2889
+ "950": "#4c0519"
2890
+ },
2891
+ "black": {
2892
+ "DEFAULT": "rgb(16,16,16)"
2893
+ },
2894
+ "white": {
2895
+ "DEFAULT": "rgb(255,255,255)"
2896
+ }
2897
+ };
2898
+
2899
+ // The default token set for `createRegistry`. Colours reuse the repo's shared
2900
+ // `Palettes` data; the rest are the usual scales. Projects override any of this
2901
+ // through `@theme`.
2902
+ function defaultTheme() {
2903
+ var theme = new Theme();
2904
+ for (var name in Palettes) {
2905
+ var shades = Palettes[name];
2906
+ for (var shade in shades) {
2907
+ // Scaled colours only (50–950); the palette's black/white carry custom
2908
+ // values, so we set the plain ones below.
2909
+ if (shade !== 'DEFAULT') theme.add("--color-".concat(name, "-").concat(shade), shades[shade]);
2910
+ }
2911
+ }
2912
+ theme.add('--color-black', '#000');
2913
+ theme.add('--color-white', '#fff');
2914
+ theme.addAll({
2915
+ '--spacing': '0.25rem',
2916
+ '--breakpoint-sm': '40rem',
2917
+ '--breakpoint-md': '48rem',
2918
+ '--breakpoint-lg': '64rem',
2919
+ '--breakpoint-xl': '80rem',
2920
+ '--breakpoint-2xl': '96rem',
2921
+ '--radius-DEFAULT': '0.25rem',
2922
+ '--radius-xs': '0.125rem',
2923
+ '--radius-sm': '0.25rem',
2924
+ '--radius-md': '0.375rem',
2925
+ '--radius-lg': '0.5rem',
2926
+ '--radius-xl': '0.75rem',
2927
+ '--radius-2xl': '1rem',
2928
+ '--radius-3xl': '1.5rem',
2929
+ '--text-xs': '0.75rem',
2930
+ '--text-sm': '0.875rem',
2931
+ '--text-base': '1rem',
2932
+ '--text-lg': '1.125rem',
2933
+ '--text-xl': '1.25rem',
2934
+ '--text-2xl': '1.5rem',
2935
+ '--text-3xl': '1.875rem',
2936
+ '--text-4xl': '2.25rem',
2937
+ '--text-5xl': '3rem',
2938
+ '--text-6xl': '3.75rem',
2939
+ '--text-7xl': '4.5rem',
2940
+ '--shadow-sm': '0 1px 2px 0 rgb(0 0 0 / 0.05)',
2941
+ '--shadow-DEFAULT': '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)',
2942
+ '--shadow-md': '0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)',
2943
+ '--shadow-lg': '0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)',
2944
+ '--shadow-xl': '0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)',
2945
+ '--shadow-2xl': '0 25px 50px -12px rgb(0 0 0 / 0.25)'
2946
+ });
2947
+ return theme;
2948
+ }
2949
+
2950
+ // Shared value resolvers and registration helpers used across the utility families.
2951
+
2952
+ var SPECIAL_COLORS = {
2953
+ transparent: 'transparent',
2954
+ current: 'currentColor',
2955
+ inherit: 'inherit'
2956
+ };
2957
+ var CONTENT_SIZES = {
2958
+ auto: 'auto',
2959
+ min: 'min-content',
2960
+ max: 'max-content',
2961
+ fit: 'fit-content',
2962
+ px: '1px',
2963
+ full: '100%'
2964
+ };
2965
+ function colorValue(value, modifier, theme) {
2966
+ var _ref, _theme$resolve;
2967
+ if (!value) return null;
2968
+ var base = value.kind === 'arbitrary' ? value.value : (_ref = (_theme$resolve = theme.resolve('color', value.value)) !== null && _theme$resolve !== void 0 ? _theme$resolve : SPECIAL_COLORS[value.value]) !== null && _ref !== void 0 ? _ref : null;
2969
+ if (!base) return null;
2970
+ if (!modifier) return base;
2971
+ var alpha = modifier.kind === 'named' ? "".concat(modifier.value, "%") : percent(modifier.value);
2972
+ return "color-mix(in oklab, ".concat(base, " ").concat(alpha, ", transparent)");
2973
+ }
2974
+ function percent(raw) {
2975
+ return raw.includes('%') ? raw : "calc(".concat(raw, " * 100%)");
2976
+ }
2977
+ // Length/size values: theme spacing, the `n * --spacing` scale, fractions (`1/2`),
2978
+ // viewport/content keywords, and arbitraries. `axis` picks vw vs vh for `screen`.
2979
+ function sizeValue(value, theme) {
2980
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2981
+ if (!value) return null;
2982
+ var _options$negative = options.negative,
2983
+ negative = _options$negative === void 0 ? false : _options$negative,
2984
+ _options$axis = options.axis,
2985
+ axis = _options$axis === void 0 ? null : _options$axis,
2986
+ _options$modifier = options.modifier,
2987
+ modifier = _options$modifier === void 0 ? null : _options$modifier;
2988
+ var base;
2989
+ if (value.kind === 'arbitrary') {
2990
+ base = value.value;
2991
+ } else if (modifier && modifier.kind === 'named' && /^\d+$/.test(value.value) && /^\d+$/.test(modifier.value)) {
2992
+ base = toPercent(+value.value, +modifier.value);
2993
+ } else {
2994
+ base = namedSize(value.value, theme, axis);
2995
+ }
2996
+ if (!base) return null;
2997
+ return negative ? "calc(".concat(base, " * -1)") : base;
2998
+ }
2999
+ function namedSize(key, theme, axis) {
3000
+ var _CONTENT_SIZES$key;
3001
+ var token = theme.resolve('spacing', key);
3002
+ if (token) return token;
3003
+ if (/^\d+(\.\d+)?$/.test(key) && theme.has('--spacing')) return "calc(var(--spacing) * ".concat(key, ")");
3004
+ var fraction = key.match(/^(\d+)\/(\d+)$/);
3005
+ if (fraction) return toPercent(+fraction[1], +fraction[2]);
3006
+ if (key === 'screen') return axis === 'y' ? '100vh' : '100vw';
3007
+ return (_CONTENT_SIZES$key = CONTENT_SIZES[key]) !== null && _CONTENT_SIZES$key !== void 0 ? _CONTENT_SIZES$key : null;
3008
+ }
3009
+ function toPercent(a, b) {
3010
+ if (b === 0) return '0%';
3011
+ var n = a / b * 100;
3012
+ return "".concat(+n.toFixed(6), "%");
3013
+ }
3014
+
3015
+ // Register a group of static keyword utilities that all set one property:
3016
+ // `keywords(reg, 'justify', 'justify-content', { start: 'flex-start', … })`.
3017
+ // An empty-string key registers the bare root (`underline`).
3018
+ function keywords(reg, root, property, map) {
3019
+ for (var suffix in map) {
3020
+ var name = suffix === '' ? root : "".concat(root, "-").concat(suffix);
3021
+ reg.rule(name, [decl(property, map[suffix])]);
3022
+ }
3023
+ }
3024
+
3025
+ // Register several standalone static utilities keyed by their full class name.
3026
+ function statics(reg, map) {
3027
+ for (var name in map) reg.rule(name, map[name]);
3028
+ }
3029
+
3030
+ // Like {@link keywords} but the map key is the full class name, for groups whose
3031
+ // members don't share a `root-` prefix: `props(reg, 'display', { flex: 'flex', … })`.
3032
+ function props(reg, property, map) {
3033
+ for (var name in map) reg.rule(name, [decl(property, map[name])]);
3034
+ }
3035
+
3036
+ function registerBackgrounds(reg) {
3037
+ reg.dynamicRule('bg', function (_ref) {
3038
+ var value = _ref.value,
3039
+ modifier = _ref.modifier,
3040
+ theme = _ref.theme;
3041
+ var c = colorValue(value, modifier, theme);
3042
+ return c ? [decl('background-color', c)] : null;
3043
+ });
3044
+
3045
+ // Keyword forms of `bg-*` — these win over the colour root above.
3046
+ keywords(reg, 'bg', 'background-repeat', {
3047
+ repeat: 'repeat',
3048
+ 'no-repeat': 'no-repeat',
3049
+ 'repeat-x': 'repeat-x',
3050
+ 'repeat-y': 'repeat-y',
3051
+ 'repeat-round': 'round',
3052
+ 'repeat-space': 'space'
3053
+ });
3054
+ keywords(reg, 'bg', 'background-size', {
3055
+ auto: 'auto',
3056
+ cover: 'cover',
3057
+ contain: 'contain'
3058
+ });
3059
+ keywords(reg, 'bg', 'background-attachment', {
3060
+ fixed: 'fixed',
3061
+ local: 'local',
3062
+ scroll: 'scroll'
3063
+ });
3064
+ keywords(reg, 'bg', 'background-position', {
3065
+ center: 'center',
3066
+ top: 'top',
3067
+ bottom: 'bottom',
3068
+ left: 'left',
3069
+ right: 'right',
3070
+ 'left-top': 'left top',
3071
+ 'right-top': 'right top',
3072
+ 'left-bottom': 'left bottom',
3073
+ 'right-bottom': 'right bottom'
3074
+ });
3075
+ props(reg, 'background-image', {
3076
+ 'bg-none': 'none'
3077
+ });
3078
+ }
3079
+
3080
+ function registerBorders(reg) {
3081
+ border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);
3082
+ border(reg, 'border-x', 'border', ['-left', '-right']);
3083
+ border(reg, 'border-y', 'border', ['-top', '-bottom']);
3084
+ border(reg, 'border-t', 'border', ['-top']);
3085
+ border(reg, 'border-r', 'border', ['-right']);
3086
+ border(reg, 'border-b', 'border', ['-bottom']);
3087
+ border(reg, 'border-l', 'border', ['-left']);
3088
+ border(reg, 'border-s', 'border', ['-inline-start']);
3089
+ border(reg, 'border-e', 'border', ['-inline-end']);
3090
+ keywords(reg, 'border', 'border-style', {
3091
+ solid: 'solid',
3092
+ dashed: 'dashed',
3093
+ dotted: 'dotted',
3094
+ "double": 'double',
3095
+ hidden: 'hidden',
3096
+ none: 'none'
3097
+ });
3098
+ rounded(reg, 'rounded', ['']);
3099
+ rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
3100
+ rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
3101
+ rounded(reg, 'rounded-b', ['-bottom-right', '-bottom-left']);
3102
+ rounded(reg, 'rounded-l', ['-top-left', '-bottom-left']);
3103
+ rounded(reg, 'rounded-tl', ['-top-left']);
3104
+ rounded(reg, 'rounded-tr', ['-top-right']);
3105
+ rounded(reg, 'rounded-br', ['-bottom-right']);
3106
+ rounded(reg, 'rounded-bl', ['-bottom-left']);
3107
+ outline(reg);
3108
+ }
3109
+
3110
+ // `border`, `border-2`, `border-red-500`, `border-[#fff]`, `border-[2px]` all share
3111
+ // one root: a bare value or number is a width, a colour token/arbitrary is a colour.
3112
+ function border(reg, root, base, sides) {
3113
+ reg.dynamicRule(root, function (_ref) {
3114
+ var value = _ref.value,
3115
+ modifier = _ref.modifier,
3116
+ theme = _ref.theme;
3117
+ var width = widthValue(value, '1px' );
3118
+ if (width !== null) return sides.map(function (s) {
3119
+ return decl("".concat(base).concat(s, "-width"), width);
3120
+ });
3121
+ var color = colorFor(value, modifier, theme);
3122
+ return color ? sides.map(function (s) {
3123
+ return decl("".concat(base).concat(s, "-color"), color);
3124
+ }) : null;
3125
+ });
3126
+ }
3127
+ function widthValue(value, bare) {
3128
+ if (value === null) return bare;
3129
+ if (value.kind === 'arbitrary') {
3130
+ if (value.dataType === 'length') return value.value;
3131
+ if (value.dataType === null && /^[\d.]+(px|rem|em|%)$/.test(value.value)) return value.value;
3132
+ return null;
3133
+ }
3134
+ return /^\d+$/.test(value.value) ? "".concat(value.value, "px") : null;
3135
+ }
3136
+ function colorFor(value, modifier, theme) {
3137
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary' && value.dataType === 'length') return null;
3138
+ return colorValue(value, modifier, theme);
3139
+ }
3140
+ function rounded(reg, root, corners) {
3141
+ reg.dynamicRule(root, function (_ref2) {
3142
+ var value = _ref2.value,
3143
+ theme = _ref2.theme;
3144
+ var r = radiusValue(value, theme);
3145
+ return r ? corners.map(function (c) {
3146
+ return decl("border".concat(c, "-radius"), r);
3147
+ }) : null;
3148
+ });
3149
+ }
3150
+ function radiusValue(value, theme) {
3151
+ if (value === null) return theme.resolve('radius', 'DEFAULT');
3152
+ if (value.kind === 'arbitrary') return value.value;
3153
+ if (value.value === 'none') return '0';
3154
+ if (value.value === 'full') return 'calc(infinity * 1px)';
3155
+ return theme.resolve('radius', value.value);
3156
+ }
3157
+ function outline(reg) {
3158
+ keywords(reg, 'outline', 'outline-style', {
3159
+ none: 'none',
3160
+ solid: 'solid',
3161
+ dashed: 'dashed',
3162
+ dotted: 'dotted',
3163
+ "double": 'double'
3164
+ });
3165
+ reg.dynamicRule('outline', function (_ref3) {
3166
+ var value = _ref3.value,
3167
+ modifier = _ref3.modifier,
3168
+ theme = _ref3.theme;
3169
+ if (value === null) return [decl('outline-style', 'solid')];
3170
+ var width = widthValue(value, null);
3171
+ if (width !== null) return [decl('outline-width', width)];
3172
+ var color = colorFor(value, modifier, theme);
3173
+ return color ? [decl('outline-color', color)] : null;
3174
+ });
3175
+ }
3176
+
3177
+ function registerEffects(reg) {
3178
+ reg.dynamicRule('shadow', function (_ref) {
3179
+ var value = _ref.value,
3180
+ theme = _ref.theme;
3181
+ if (value === null) return wrap(theme.resolve('shadow', 'DEFAULT'));
3182
+ if (value.kind === 'arbitrary') return [decl('box-shadow', value.value)];
3183
+ if (value.value === 'none') return [decl('box-shadow', 'none')];
3184
+ return wrap(theme.resolve('shadow', value.value));
3185
+ });
3186
+ reg.dynamicRule('opacity', function (_ref2) {
3187
+ var value = _ref2.value;
3188
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('opacity', value.value)];
3189
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && /^\d+$/.test(value.value)) return [decl('opacity', "".concat(+value.value / 100))];
3190
+ return null;
3191
+ });
3192
+ keywords(reg, 'mix-blend', 'mix-blend-mode', BLEND);
3193
+ keywords(reg, 'bg-blend', 'background-blend-mode', BLEND);
3194
+ keywords(reg, 'cursor', 'cursor', {
3195
+ auto: 'auto',
3196
+ "default": 'default',
3197
+ pointer: 'pointer',
3198
+ wait: 'wait',
3199
+ text: 'text',
3200
+ move: 'move',
3201
+ help: 'help',
3202
+ 'not-allowed': 'not-allowed',
3203
+ progress: 'progress',
3204
+ grab: 'grab',
3205
+ grabbing: 'grabbing'
3206
+ });
3207
+ keywords(reg, 'select', 'user-select', {
3208
+ none: 'none',
3209
+ text: 'text',
3210
+ all: 'all',
3211
+ auto: 'auto'
3212
+ });
3213
+ keywords(reg, 'resize', 'resize', {
3214
+ '': 'both',
3215
+ none: 'none',
3216
+ x: 'horizontal',
3217
+ y: 'vertical'
3218
+ });
3219
+ keywords(reg, 'pointer-events', 'pointer-events', {
3220
+ none: 'none',
3221
+ auto: 'auto'
3222
+ });
3223
+ keywords(reg, 'appearance', 'appearance', {
3224
+ none: 'none',
3225
+ auto: 'auto'
3226
+ });
3227
+ }
3228
+ function wrap(shadow) {
3229
+ return shadow ? [decl('box-shadow', shadow)] : null;
3230
+ }
3231
+ var BLEND = {
3232
+ normal: 'normal',
3233
+ multiply: 'multiply',
3234
+ screen: 'screen',
3235
+ overlay: 'overlay',
3236
+ darken: 'darken',
3237
+ lighten: 'lighten',
3238
+ 'color-dodge': 'color-dodge',
3239
+ 'color-burn': 'color-burn',
3240
+ 'hard-light': 'hard-light',
3241
+ 'soft-light': 'soft-light',
3242
+ difference: 'difference',
3243
+ exclusion: 'exclusion',
3244
+ hue: 'hue',
3245
+ saturation: 'saturation',
3246
+ color: 'color',
3247
+ luminosity: 'luminosity'
3248
+ };
3249
+
3250
+ function registerFlexGrid(reg) {
3251
+ props(reg, 'flex-direction', {
3252
+ 'flex-row': 'row',
3253
+ 'flex-row-reverse': 'row-reverse',
3254
+ 'flex-col': 'column',
3255
+ 'flex-col-reverse': 'column-reverse'
3256
+ });
3257
+ props(reg, 'flex-wrap', {
3258
+ 'flex-wrap': 'wrap',
3259
+ 'flex-wrap-reverse': 'wrap-reverse',
3260
+ 'flex-nowrap': 'nowrap'
3261
+ });
3262
+ props(reg, 'flex', {
3263
+ 'flex-1': '1 1 0%',
3264
+ 'flex-auto': '1 1 auto',
3265
+ 'flex-initial': '0 1 auto',
3266
+ 'flex-none': 'none'
3267
+ });
3268
+ props(reg, 'flex-grow', {
3269
+ grow: '1',
3270
+ 'grow-0': '0'
3271
+ });
3272
+ props(reg, 'flex-shrink', {
3273
+ shrink: '1',
3274
+ 'shrink-0': '0'
3275
+ });
3276
+ reg.dynamicRule('basis', function (_ref) {
3277
+ var value = _ref.value,
3278
+ modifier = _ref.modifier,
3279
+ theme = _ref.theme;
3280
+ var v = sizeValue(value, theme, {
3281
+ modifier: modifier
3282
+ });
3283
+ return v ? [decl('flex-basis', v)] : null;
3284
+ });
3285
+ reg.dynamicRule('order', function (_ref2) {
3286
+ var value = _ref2.value;
3287
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('order', value.value)];
3288
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
3289
+ if (value.value === 'first') return [decl('order', '-9999')];
3290
+ if (value.value === 'last') return [decl('order', '9999')];
3291
+ if (value.value === 'none') return [decl('order', '0')];
3292
+ if (/^\d+$/.test(value.value)) return [decl('order', value.value)];
3293
+ }
3294
+ return null;
3295
+ });
3296
+ keywords(reg, 'justify', 'justify-content', CONTENT);
3297
+ keywords(reg, 'content', 'align-content', CONTENT);
3298
+ keywords(reg, 'items', 'align-items', ALIGN);
3299
+ keywords(reg, 'self', 'align-self', _objectSpread2({
3300
+ auto: 'auto'
3301
+ }, ALIGN));
3302
+ keywords(reg, 'justify-items', 'justify-items', {
3303
+ start: 'start',
3304
+ end: 'end',
3305
+ center: 'center',
3306
+ stretch: 'stretch'
3307
+ });
3308
+ keywords(reg, 'justify-self', 'justify-self', {
3309
+ auto: 'auto',
3310
+ start: 'start',
3311
+ end: 'end',
3312
+ center: 'center',
3313
+ stretch: 'stretch'
3314
+ });
3315
+ keywords(reg, 'place-content', 'place-content', CONTENT);
3316
+ keywords(reg, 'place-items', 'place-items', {
3317
+ start: 'start',
3318
+ end: 'end',
3319
+ center: 'center',
3320
+ stretch: 'stretch',
3321
+ baseline: 'baseline'
3322
+ });
3323
+ keywords(reg, 'place-self', 'place-self', {
3324
+ auto: 'auto',
3325
+ start: 'start',
3326
+ end: 'end',
3327
+ center: 'center',
3328
+ stretch: 'stretch'
3329
+ });
3330
+ gap(reg, 'gap', ['gap']);
3331
+ gap(reg, 'gap-x', ['column-gap']);
3332
+ gap(reg, 'gap-y', ['row-gap']);
3333
+ reg.dynamicRule('grid-cols', function (_ref3) {
3334
+ var value = _ref3.value;
3335
+ return track('grid-template-columns', value);
3336
+ });
3337
+ reg.dynamicRule('grid-rows', function (_ref4) {
3338
+ var value = _ref4.value;
3339
+ return track('grid-template-rows', value);
3340
+ });
3341
+ span(reg, 'col-span', 'grid-column', 'span');
3342
+ span(reg, 'row-span', 'grid-row', 'span');
3343
+ line(reg, 'col-start', 'grid-column-start');
3344
+ line(reg, 'col-end', 'grid-column-end');
3345
+ line(reg, 'row-start', 'grid-row-start');
3346
+ line(reg, 'row-end', 'grid-row-end');
3347
+ props(reg, 'grid-auto-flow', {
3348
+ 'grid-flow-row': 'row',
3349
+ 'grid-flow-col': 'column',
3350
+ 'grid-flow-dense': 'dense',
3351
+ 'grid-flow-row-dense': 'row dense',
3352
+ 'grid-flow-col-dense': 'column dense'
3353
+ });
3354
+ }
3355
+ var CONTENT = {
3356
+ normal: 'normal',
3357
+ start: 'flex-start',
3358
+ end: 'flex-end',
3359
+ center: 'center',
3360
+ between: 'space-between',
3361
+ around: 'space-around',
3362
+ evenly: 'space-evenly',
3363
+ stretch: 'stretch'
3364
+ };
3365
+ var ALIGN = {
3366
+ start: 'flex-start',
3367
+ end: 'flex-end',
3368
+ center: 'center',
3369
+ baseline: 'baseline',
3370
+ stretch: 'stretch'
3371
+ };
3372
+ function gap(reg, root, props) {
3373
+ reg.dynamicRule(root, function (_ref5) {
3374
+ var value = _ref5.value,
3375
+ theme = _ref5.theme;
3376
+ var v = sizeValue(value, theme);
3377
+ return v ? props.map(function (p) {
3378
+ return decl(p, v);
3379
+ }) : null;
3380
+ });
3381
+ }
3382
+ function track(property, value) {
3383
+ if (!value) return null;
3384
+ if (value.kind === 'arbitrary') return [decl(property, value.value)];
3385
+ if (value.value === 'none') return [decl(property, 'none')];
3386
+ if (/^\d+$/.test(value.value)) return [decl(property, "repeat(".concat(value.value, ", minmax(0, 1fr))"))];
3387
+ return null;
3388
+ }
3389
+ function span(reg, root, property, kind) {
3390
+ reg.dynamicRule(root, function (_ref6) {
3391
+ var value = _ref6.value;
3392
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl(property, value.value)];
3393
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
3394
+ if (value.value === 'full') return [decl(property, '1 / -1')];
3395
+ if (/^\d+$/.test(value.value)) return [decl(property, "".concat(kind, " ").concat(value.value, " / ").concat(kind, " ").concat(value.value))];
3396
+ }
3397
+ return null;
3398
+ });
3399
+ }
3400
+ function line(reg, root, property) {
3401
+ reg.dynamicRule(root, function (_ref7) {
3402
+ var value = _ref7.value;
3403
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl(property, value.value)];
3404
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
3405
+ if (value.value === 'auto') return [decl(property, 'auto')];
3406
+ if (/^\d+$/.test(value.value)) return [decl(property, value.value)];
3407
+ }
3408
+ return null;
3409
+ });
3410
+ }
3411
+
3412
+ function registerLayout(reg) {
3413
+ props(reg, 'display', {
3414
+ block: 'block',
3415
+ inline: 'inline',
3416
+ 'inline-block': 'inline-block',
3417
+ flex: 'flex',
3418
+ 'inline-flex': 'inline-flex',
3419
+ grid: 'grid',
3420
+ 'inline-grid': 'inline-grid',
3421
+ table: 'table',
3422
+ 'flow-root': 'flow-root',
3423
+ contents: 'contents',
3424
+ hidden: 'none'
3425
+ });
3426
+ props(reg, 'position', {
3427
+ "static": 'static',
3428
+ fixed: 'fixed',
3429
+ absolute: 'absolute',
3430
+ relative: 'relative',
3431
+ sticky: 'sticky'
3432
+ });
3433
+ keywords(reg, 'overflow', 'overflow', OVERFLOW);
3434
+ keywords(reg, 'overflow-x', 'overflow-x', OVERFLOW);
3435
+ keywords(reg, 'overflow-y', 'overflow-y', OVERFLOW);
3436
+ props(reg, 'visibility', {
3437
+ visible: 'visible',
3438
+ invisible: 'hidden',
3439
+ collapse: 'collapse'
3440
+ });
3441
+ keywords(reg, 'box', 'box-sizing', {
3442
+ border: 'border-box',
3443
+ content: 'content-box'
3444
+ });
3445
+ props(reg, 'isolation', {
3446
+ isolate: 'isolate',
3447
+ 'isolation-auto': 'auto'
3448
+ });
3449
+ keywords(reg, 'object', 'object-fit', {
3450
+ contain: 'contain',
3451
+ cover: 'cover',
3452
+ fill: 'fill',
3453
+ none: 'none',
3454
+ 'scale-down': 'scale-down'
3455
+ });
3456
+ keywords(reg, 'object', 'object-position', {
3457
+ top: 'top',
3458
+ bottom: 'bottom',
3459
+ center: 'center',
3460
+ left: 'left',
3461
+ right: 'right',
3462
+ 'left-top': 'left top',
3463
+ 'right-top': 'right top',
3464
+ 'left-bottom': 'left bottom',
3465
+ 'right-bottom': 'right bottom'
3466
+ });
3467
+ keywords(reg, 'float', 'float', {
3468
+ start: 'inline-start',
3469
+ end: 'inline-end',
3470
+ left: 'left',
3471
+ right: 'right',
3472
+ none: 'none'
3473
+ });
3474
+ keywords(reg, 'clear', 'clear', {
3475
+ start: 'inline-start',
3476
+ end: 'inline-end',
3477
+ left: 'left',
3478
+ right: 'right',
3479
+ both: 'both',
3480
+ none: 'none'
3481
+ });
3482
+ inset(reg, 'inset', ['top', 'right', 'bottom', 'left']);
3483
+ inset(reg, 'inset-x', ['left', 'right']);
3484
+ inset(reg, 'inset-y', ['top', 'bottom']);
3485
+ inset(reg, 'top', ['top']);
3486
+ inset(reg, 'right', ['right']);
3487
+ inset(reg, 'bottom', ['bottom']);
3488
+ inset(reg, 'left', ['left']);
3489
+ inset(reg, 'start', ['inset-inline-start']);
3490
+ inset(reg, 'end', ['inset-inline-end']);
3491
+ reg.dynamicRule('z', function (_ref) {
3492
+ var value = _ref.value;
3493
+ if (!value) return null;
3494
+ if (value.kind === 'arbitrary') return [decl('z-index', value.value)];
3495
+ if (value.value === 'auto') return [decl('z-index', 'auto')];
3496
+ return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
3497
+ });
3498
+ }
3499
+ var OVERFLOW = {
3500
+ auto: 'auto',
3501
+ hidden: 'hidden',
3502
+ clip: 'clip',
3503
+ visible: 'visible',
3504
+ scroll: 'scroll'
3505
+ };
3506
+ function inset(reg, root, props) {
3507
+ reg.dynamicRule(root, function (_ref2) {
3508
+ var value = _ref2.value,
3509
+ negative = _ref2.negative,
3510
+ modifier = _ref2.modifier,
3511
+ theme = _ref2.theme;
3512
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
3513
+ return decl(p, 'auto');
3514
+ });
3515
+ var v = sizeValue(value, theme, {
3516
+ negative: negative,
3517
+ modifier: modifier
3518
+ });
3519
+ return v ? props.map(function (p) {
3520
+ return decl(p, v);
3521
+ }) : null;
3522
+ });
3523
+ }
3524
+
3525
+ function registerSizing(reg) {
3526
+ size(reg, 'w', ['width'], 'x');
3527
+ size(reg, 'h', ['height'], 'y');
3528
+ size(reg, 'size', ['width', 'height'], null);
3529
+ size(reg, 'min-w', ['min-width'], 'x');
3530
+ size(reg, 'min-h', ['min-height'], 'y');
3531
+ size(reg, 'max-w', ['max-width'], 'x');
3532
+ size(reg, 'max-h', ['max-height'], 'y');
3533
+ }
3534
+ function size(reg, root, props, axis) {
3535
+ reg.dynamicRule(root, function (_ref) {
3536
+ var value = _ref.value,
3537
+ modifier = _ref.modifier,
3538
+ theme = _ref.theme;
3539
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'none' && root.startsWith('max')) {
3540
+ return props.map(function (p) {
3541
+ return decl(p, 'none');
3542
+ });
3543
+ }
3544
+ var v = sizeValue(value, theme, {
3545
+ axis: axis,
3546
+ modifier: modifier
3547
+ });
3548
+ return v ? props.map(function (p) {
3549
+ return decl(p, v);
3550
+ }) : null;
3551
+ });
3552
+ }
3553
+
3554
+ function registerSpacing(reg) {
3555
+ for (var _i = 0, _Object$entries = Object.entries(SPACING); _i < _Object$entries.length; _i++) {
3556
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
3557
+ root = _Object$entries$_i[0],
3558
+ props = _Object$entries$_i[1];
3559
+ spacing(reg, root, props, root[0] === 'm');
3560
+ }
3561
+ }
3562
+
3563
+ // `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
3564
+ // `padding-inline`) to match established output; `ps`/`pe` use the logical edges.
3565
+ var SPACING = {
3566
+ p: ['padding'],
3567
+ px: ['padding-left', 'padding-right'],
3568
+ py: ['padding-top', 'padding-bottom'],
3569
+ ps: ['padding-inline-start'],
3570
+ pe: ['padding-inline-end'],
3571
+ pt: ['padding-top'],
3572
+ pr: ['padding-right'],
3573
+ pb: ['padding-bottom'],
3574
+ pl: ['padding-left'],
3575
+ m: ['margin'],
3576
+ mx: ['margin-left', 'margin-right'],
3577
+ my: ['margin-top', 'margin-bottom'],
3578
+ ms: ['margin-inline-start'],
3579
+ me: ['margin-inline-end'],
3580
+ mt: ['margin-top'],
3581
+ mr: ['margin-right'],
3582
+ mb: ['margin-bottom'],
3583
+ ml: ['margin-left'],
3584
+ 'scroll-m': ['scroll-margin'],
3585
+ 'scroll-p': ['scroll-padding']
3586
+ };
3587
+ function spacing(reg, root, props, allowAuto) {
3588
+ reg.dynamicRule(root, function (_ref) {
3589
+ var value = _ref.value,
3590
+ negative = _ref.negative,
3591
+ theme = _ref.theme;
3592
+ if (allowAuto && (value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto') return props.map(function (p) {
3593
+ return decl(p, 'auto');
3594
+ });
3595
+ var v = sizeValue(value, theme, {
3596
+ negative: negative
3597
+ });
3598
+ return v ? props.map(function (p) {
3599
+ return decl(p, v);
3600
+ }) : null;
3601
+ });
3602
+ }
3603
+
3604
+ function registerTypography(reg) {
3605
+ // `text-` is overloaded: a colour token, a font-size token, or an arbitrary of
3606
+ // either kind. Alignment/overflow keywords (`text-center`, `text-ellipsis`) are
3607
+ // registered as statics below, which win over this functional root.
3608
+ reg.dynamicRule('text', function (_ref) {
3609
+ var value = _ref.value,
3610
+ modifier = _ref.modifier,
3611
+ theme = _ref.theme;
3612
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
3613
+ if (theme.resolve('color', value.value) || SPECIAL_COLORS[value.value]) {
3614
+ return [decl('color', colorValue(value, modifier, theme))];
3615
+ }
3616
+ var fs = theme.resolve('text', value.value);
3617
+ return fs ? [decl('font-size', fs)] : null;
3618
+ }
3619
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') {
3620
+ if (value.dataType === 'length') return [decl('font-size', value.value)];
3621
+ var c = colorValue(value, modifier, theme);
3622
+ return c ? [decl('color', c)] : null;
3623
+ }
3624
+ return null;
3625
+ });
3626
+ props(reg, 'text-align', {
3627
+ 'text-left': 'left',
3628
+ 'text-center': 'center',
3629
+ 'text-right': 'right',
3630
+ 'text-justify': 'justify',
3631
+ 'text-start': 'start',
3632
+ 'text-end': 'end'
3633
+ });
3634
+ props(reg, 'text-overflow', {
3635
+ truncate: 'ellipsis',
3636
+ 'text-ellipsis': 'ellipsis',
3637
+ 'text-clip': 'clip'
3638
+ });
3639
+ // `truncate` is the one that also clips and stops wrapping.
3640
+ reg.rule('truncate', [decl('overflow', 'hidden'), decl('text-overflow', 'ellipsis'), decl('white-space', 'nowrap')]);
3641
+ keywords(reg, 'font', 'font-weight', WEIGHTS);
3642
+ props(reg, 'font-family', {
3643
+ 'font-sans': 'ui-sans-serif, system-ui, sans-serif',
3644
+ 'font-serif': 'ui-serif, Georgia, serif',
3645
+ 'font-mono': 'ui-monospace, SFMono-Regular, Menlo, monospace'
3646
+ });
3647
+ props(reg, 'font-style', {
3648
+ italic: 'italic',
3649
+ 'not-italic': 'normal'
3650
+ });
3651
+ props(reg, 'text-decoration-line', {
3652
+ underline: 'underline',
3653
+ overline: 'overline',
3654
+ 'line-through': 'line-through',
3655
+ 'no-underline': 'none'
3656
+ });
3657
+ props(reg, 'text-transform', {
3658
+ uppercase: 'uppercase',
3659
+ lowercase: 'lowercase',
3660
+ capitalize: 'capitalize',
3661
+ 'normal-case': 'none'
3662
+ });
3663
+ keywords(reg, 'whitespace', 'white-space', {
3664
+ normal: 'normal',
3665
+ nowrap: 'nowrap',
3666
+ pre: 'pre',
3667
+ 'pre-line': 'pre-line',
3668
+ 'pre-wrap': 'pre-wrap',
3669
+ 'break-spaces': 'break-spaces'
3670
+ });
3671
+ statics(reg, {
3672
+ 'break-normal': [decl('overflow-wrap', 'normal'), decl('word-break', 'normal')],
3673
+ 'break-words': [decl('overflow-wrap', 'break-word')],
3674
+ 'break-all': [decl('word-break', 'break-all')],
3675
+ 'break-keep': [decl('word-break', 'keep-all')]
3676
+ });
3677
+ keywords(reg, 'list', 'list-style-type', {
3678
+ none: 'none',
3679
+ disc: 'disc',
3680
+ decimal: 'decimal'
3681
+ });
3682
+ keywords(reg, 'list', 'list-style-position', {
3683
+ inside: 'inside',
3684
+ outside: 'outside'
3685
+ });
3686
+ reg.dynamicRule('leading', function (_ref2) {
3687
+ var value = _ref2.value,
3688
+ theme = _ref2.theme;
3689
+ return resolveLeading(value, theme);
3690
+ });
3691
+ reg.dynamicRule('tracking', function (_ref3) {
3692
+ var value = _ref3.value;
3693
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('letter-spacing', value.value)];
3694
+ var t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
3695
+ return t ? [decl('letter-spacing', t)] : null;
3696
+ });
3697
+ }
3698
+ var WEIGHTS = {
3699
+ thin: '100',
3700
+ extralight: '200',
3701
+ light: '300',
3702
+ normal: '400',
3703
+ medium: '500',
3704
+ semibold: '600',
3705
+ bold: '700',
3706
+ extrabold: '800',
3707
+ black: '900'
3708
+ };
3709
+ var LEADING = {
3710
+ none: '1',
3711
+ tight: '1.25',
3712
+ snug: '1.375',
3713
+ normal: '1.5',
3714
+ relaxed: '1.625',
3715
+ loose: '2'
3716
+ };
3717
+ var TRACKING = {
3718
+ tighter: '-0.05em',
3719
+ tight: '-0.025em',
3720
+ normal: '0em',
3721
+ wide: '0.025em',
3722
+ wider: '0.05em',
3723
+ widest: '0.1em'
3724
+ };
3725
+ function resolveLeading(value, theme) {
3726
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'arbitrary') return [decl('line-height', value.value)];
3727
+ if ((value === null || value === void 0 ? void 0 : value.kind) === 'named') {
3728
+ if (LEADING[value.value]) return [decl('line-height', LEADING[value.value])];
3729
+ if (/^\d+$/.test(value.value) && theme.has('--spacing')) {
3730
+ return [decl('line-height', "calc(var(--spacing) * ".concat(value.value, ")"))];
3731
+ }
3732
+ }
3733
+ return null;
3734
+ }
3735
+
3736
+ function registerUtilities(reg) {
3737
+ registerLayout(reg);
3738
+ registerFlexGrid(reg);
3739
+ registerSpacing(reg);
3740
+ registerSizing(reg);
3741
+ registerTypography(reg);
3742
+ registerBackgrounds(reg);
3743
+ registerBorders(reg);
3744
+ registerEffects(reg);
3745
+ }
3746
+
3747
+ function registerVariants(reg) {
3748
+ for (var _i = 0, _Object$entries = Object.entries(PSEUDO); _i < _Object$entries.length; _i++) {
3749
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
3750
+ name = _Object$entries$_i[0],
3751
+ sel = _Object$entries$_i[1];
3752
+ reg.variant(name, {
3753
+ selector: sel
3754
+ });
3755
+ }
3756
+ for (var _i2 = 0, _Object$entries2 = Object.entries(PSEUDO_ELEMENT); _i2 < _Object$entries2.length; _i2++) {
3757
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2),
3758
+ _name = _Object$entries2$_i[0],
3759
+ _sel = _Object$entries2$_i[1];
3760
+ reg.variant(_name, {
3761
+ selector: _sel
3762
+ });
3763
+ }
3764
+ for (var _i3 = 0, _Object$entries3 = Object.entries(MEDIA); _i3 < _Object$entries3.length; _i3++) {
3765
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
3766
+ _name2 = _Object$entries3$_i[0],
3767
+ params = _Object$entries3$_i[1];
3768
+ reg.variant(_name2, {
3769
+ atRule: {
3770
+ name: 'media',
3771
+ params: params
3772
+ }
3773
+ });
3774
+ }
3775
+ reg.variant('rtl', {
3776
+ selector: '&:where([dir="rtl"], [dir="rtl"] *)'
3777
+ });
3778
+ reg.variant('ltr', {
3779
+ selector: '&:where([dir="ltr"], [dir="ltr"] *)'
3780
+ });
3781
+ for (var _i4 = 0, _arr = ['sm', 'md', 'lg', 'xl', '2xl']; _i4 < _arr.length; _i4++) {
3782
+ var bp = _arr[_i4];
3783
+ var min = reg.theme.get("--breakpoint-".concat(bp));
3784
+ if (min) reg.variant(bp, {
3785
+ atRule: {
3786
+ name: 'media',
3787
+ params: "(min-width: ".concat(min, ")")
3788
+ }
3789
+ });
3790
+ }
3791
+
3792
+ // `max-md`, `min-lg` resolve the named breakpoint from the theme; `max-[600px]`
3793
+ // takes the width verbatim. `max-*` overrides the `max-w`/`max-h` utilities here
3794
+ // because it's a variant, not a utility.
3795
+ var width = function width(v) {
3796
+ var _reg$theme$get;
3797
+ var value = named(v);
3798
+ if (!value) return null;
3799
+ return v.kind === 'arbitrary' ? value : (_reg$theme$get = reg.theme.get("--breakpoint-".concat(value))) !== null && _reg$theme$get !== void 0 ? _reg$theme$get : null;
3800
+ };
3801
+ reg.dynamicVariant('min', function (v) {
3802
+ return mediaWidth('min-width', width(v));
3803
+ });
3804
+ reg.dynamicVariant('max', function (v) {
3805
+ return mediaWidth('max-width', width(v));
3806
+ });
3807
+ reg.dynamicVariant('group', function (v) {
3808
+ return relational(v, '.group', ' &');
3809
+ });
3810
+ reg.dynamicVariant('peer', function (v) {
3811
+ return relational(v, '.peer', ' ~ &');
3812
+ });
3813
+ reg.dynamicVariant('data', function (v) {
3814
+ return named(v) ? {
3815
+ selector: "&[data-".concat(named(v), "]")
3816
+ } : null;
3817
+ });
3818
+ reg.dynamicVariant('aria', function (v) {
3819
+ return named(v) ? {
3820
+ selector: "&[aria-".concat(named(v), "]")
3821
+ } : null;
3822
+ });
3823
+ reg.dynamicVariant('has', function (v) {
3824
+ return named(v) ? {
3825
+ selector: "&:has(".concat(named(v), ")")
3826
+ } : null;
3827
+ });
3828
+ reg.dynamicVariant('not', function (v) {
3829
+ return named(v) ? {
3830
+ selector: "&:not(".concat(named(v), ")")
3831
+ } : null;
3832
+ });
3833
+ reg.dynamicVariant('supports', function (v) {
3834
+ return named(v) ? {
3835
+ atRule: {
3836
+ name: 'supports',
3837
+ params: "(".concat(named(v), ")")
3838
+ }
3839
+ } : null;
3840
+ });
3841
+ }
3842
+ function mediaWidth(feature, value) {
3843
+ return value ? {
3844
+ atRule: {
3845
+ name: 'media',
3846
+ params: "(".concat(feature, ": ").concat(value, ")")
3847
+ }
3848
+ } : null;
3849
+ }
3850
+ var PSEUDO = {
3851
+ hover: '&:hover',
3852
+ focus: '&:focus',
3853
+ 'focus-within': '&:focus-within',
3854
+ 'focus-visible': '&:focus-visible',
3855
+ active: '&:active',
3856
+ visited: '&:visited',
3857
+ target: '&:target',
3858
+ disabled: '&:disabled',
3859
+ enabled: '&:enabled',
3860
+ checked: '&:checked',
3861
+ indeterminate: '&:indeterminate',
3862
+ "default": '&:default',
3863
+ required: '&:required',
3864
+ valid: '&:valid',
3865
+ invalid: '&:invalid',
3866
+ 'read-only': '&:read-only',
3867
+ 'placeholder-shown': '&:placeholder-shown',
3868
+ autofill: '&:autofill',
3869
+ empty: '&:empty',
3870
+ first: '&:first-child',
3871
+ last: '&:last-child',
3872
+ only: '&:only-child',
3873
+ odd: '&:nth-child(odd)',
3874
+ even: '&:nth-child(even)',
3875
+ 'first-of-type': '&:first-of-type',
3876
+ 'last-of-type': '&:last-of-type'
3877
+ };
3878
+ var PSEUDO_ELEMENT = {
3879
+ before: '&::before',
3880
+ after: '&::after',
3881
+ placeholder: '&::placeholder',
3882
+ selection: '&::selection',
3883
+ marker: '&::marker',
3884
+ file: '&::file-selector-button',
3885
+ backdrop: '&::backdrop',
3886
+ 'first-line': '&::first-line',
3887
+ 'first-letter': '&::first-letter'
3888
+ };
3889
+ var MEDIA = {
3890
+ dark: '(prefers-color-scheme: dark)',
3891
+ 'motion-reduce': '(prefers-reduced-motion: reduce)',
3892
+ 'motion-safe': '(prefers-reduced-motion: no-preference)',
3893
+ 'contrast-more': '(prefers-contrast: more)',
3894
+ 'contrast-less': '(prefers-contrast: less)',
3895
+ portrait: '(orientation: portrait)',
3896
+ landscape: '(orientation: landscape)',
3897
+ print: 'print'
3898
+ };
3899
+ function named(v) {
3900
+ return v ? v.value : null;
3901
+ }
3902
+
3903
+ // `group-hover` → `.group:hover &`; `group-[.foo]` → `.group.foo &`. A named value
3904
+ // is a pseudo-class, an arbitrary one is a raw selector fragment.
3905
+ function relational(v, base, tail) {
3906
+ var value = named(v);
3907
+ if (!value) return null;
3908
+ var cond = v.kind === 'arbitrary' ? value : ":".concat(value);
3909
+ return {
3910
+ selector: "".concat(base).concat(cond).concat(tail)
3911
+ };
3912
+ }
3913
+
3914
+ // The batteries-included registry: the default token theme plus the utility
3915
+ // families and variants. Projects extend it (`@utility`, `@theme`, JS config) or
3916
+ // build a bare `new Registry(theme)` and register their own.
3917
+ function createRegistry() {
3918
+ var reg = new Registry(defaultTheme());
3919
+ registerUtilities(reg);
3920
+ registerVariants(reg);
3921
+ return reg;
3922
+ }
3923
+
3924
+ // Pulls atom class strings out of arbitrary source (HTML, JSX, template
3925
+ // literals, …). It's deliberately permissive — anything class-shaped is emitted
3926
+ // and the compiler drops what it doesn't recognise. Runs inside `[...]` are kept
3927
+ // whole so arbitrary values and selectors survive; `(` `)` and quotes end a run
3928
+ // so classes inside `clsx('a', 'b')` are found individually.
3929
+
3930
+ var BOUNDARY = new Set([' ', '\t', '\n', '\r', '\f', '"', "'", '`', '<', '>', '=', '{', '}', ';', ',', '(', ')', '|', '\\']);
3931
+ function scanAtoms(source) {
3932
+ var found = new Set();
3933
+ var n = source.length;
3934
+ var i = 0;
3935
+ while (i < n) {
3936
+ if (BOUNDARY.has(source[i])) {
3937
+ i++;
3938
+ continue;
3939
+ }
3940
+ var j = i;
3941
+ var depth = 0;
3942
+ while (j < n) {
3943
+ var c = source[j];
3944
+ if (c === '[') depth++;else if (c === ']') {
3945
+ if (depth === 0) break;
3946
+ depth--;
3947
+ } else if (depth === 0 && BOUNDARY.has(c)) break;
3948
+ j++;
3949
+ }
3950
+ add(found, source.slice(i, j));
3951
+ i = j;
3952
+ }
3953
+ return _toConsumableArray(found);
3954
+ }
3955
+ function add(found, token) {
3956
+ // Trailing sentence/markup punctuation is never part of a class.
3957
+ var cleaned = token.replace(/[.,;:]+$/, '');
3958
+ if (cleaned && /[a-zA-Z]/.test(cleaned)) found.add(cleaned);
3959
+ }
3960
+
3961
+ // Reads `@source` directives from the input CSS: which files to scan for classes.
3962
+ // @source "../src/**/*.html"; — a glob or directory, relative to the CSS file
3963
+ // @source not "../legacy/**"; — exclude
3964
+ // @source inline("flex hidden"); — safelist literal classes, no file involved
3965
+
3966
+ function parseSources(css) {
3967
+ var patterns = [];
3968
+ var inline = [];
3969
+ var _iterator = _createForOfIteratorHelper(parseCss(css).children),
3970
+ _step;
3971
+ try {
3972
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
3973
+ var _node$preludeText;
3974
+ var node = _step.value;
3975
+ if (node.type !== 'atrule' || node.name !== 'source') continue;
3976
+ var raw = ((_node$preludeText = node.preludeText) !== null && _node$preludeText !== void 0 ? _node$preludeText : '').trim();
3977
+ if (!raw) continue;
3978
+ var negate = false;
3979
+ if (raw === 'not' || raw.startsWith('not ') || raw.startsWith('not"') || raw.startsWith("not'")) {
3980
+ negate = true;
3981
+ raw = raw.slice(3).trim();
3982
+ }
3983
+ if (raw.startsWith('inline(') && raw.endsWith(')')) {
3984
+ var _iterator2 = _createForOfIteratorHelper(scanAtoms(unquote(raw.slice(7, -1)))),
3985
+ _step2;
3986
+ try {
3987
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3988
+ var c = _step2.value;
3989
+ inline.push(c);
3990
+ }
3991
+ } catch (err) {
3992
+ _iterator2.e(err);
3993
+ } finally {
3994
+ _iterator2.f();
3995
+ }
3996
+ continue;
3997
+ }
3998
+ var pattern = unquote(raw);
3999
+ if (pattern) patterns.push({
4000
+ pattern: pattern,
4001
+ negate: negate
4002
+ });
4003
+ }
4004
+ } catch (err) {
4005
+ _iterator.e(err);
4006
+ } finally {
4007
+ _iterator.f();
4008
+ }
4009
+ return {
4010
+ patterns: patterns,
4011
+ inline: inline
4012
+ };
4013
+ }
4014
+ function unquote(s) {
4015
+ var t = s.trim();
4016
+ return t.length >= 2 && (t[0] === '"' || t[0] === "'") && t[t.length - 1] === t[0] ? t.slice(1, -1) : t;
4017
+ }
4018
+ var GLOB_CHARS = /[*?{}[\]()!]/;
4019
+ var SOURCE_EXTS = 'html,js,jsx,ts,tsx,mjs,cjs,vue,svelte,astro,md,mdx,php,erb';
4020
+ var DEFAULT_IGNORE = ['**/node_modules/**', '**/.git/**', '**/dist/**'];
4021
+
4022
+ // Expands the parsed patterns to a de-duplicated list of absolute file paths,
4023
+ // relative to `base`. A bare directory path scans its source files recursively;
4024
+ // a plain file path or an explicit glob is honoured as written.
4025
+ function resolveSourceFiles(parsed, base) {
4026
+ var include = [];
4027
+ var ignore = [].concat(DEFAULT_IGNORE);
4028
+ var _iterator3 = _createForOfIteratorHelper(parsed.patterns),
4029
+ _step3;
4030
+ try {
4031
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
4032
+ var _step3$value = _step3.value,
4033
+ pattern = _step3$value.pattern,
4034
+ negate = _step3$value.negate;
4035
+ (negate ? ignore : include).push(expandBareDir(pattern, base));
4036
+ }
4037
+ } catch (err) {
4038
+ _iterator3.e(err);
4039
+ } finally {
4040
+ _iterator3.f();
4041
+ }
4042
+ if (include.length === 0) return [];
4043
+ return fg.sync(include, {
4044
+ cwd: base,
4045
+ ignore: ignore,
4046
+ absolute: true,
4047
+ dot: false,
4048
+ onlyFiles: true
4049
+ });
4050
+ }
4051
+
4052
+ // A pattern with no glob magic that points at a directory becomes `dir/**/*.{exts}`.
4053
+ function expandBareDir(pattern, base) {
4054
+ if (GLOB_CHARS.test(pattern)) return pattern;
4055
+ var abs = path.resolve(base, pattern);
4056
+ try {
4057
+ if (fs.statSync(abs).isDirectory()) return path.join(pattern, "**/*.{".concat(SOURCE_EXTS, "}"));
4058
+ } catch (_unused) {
4059
+ // Missing path: leave as-is so fast-glob simply matches nothing.
4060
+ }
4061
+ return pattern;
4062
+ }
4063
+ function scanSourceFiles(files) {
4064
+ var found = new Set();
4065
+ var _iterator4 = _createForOfIteratorHelper(files),
4066
+ _step4;
4067
+ try {
4068
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
4069
+ var file = _step4.value;
4070
+ var text = void 0;
4071
+ try {
4072
+ text = fs.readFileSync(file, 'utf8');
4073
+ } catch (_unused2) {
4074
+ continue;
4075
+ }
4076
+ var _iterator5 = _createForOfIteratorHelper(scanAtoms(text)),
4077
+ _step5;
4078
+ try {
4079
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
4080
+ var c = _step5.value;
4081
+ found.add(c);
4082
+ }
4083
+ } catch (err) {
4084
+ _iterator5.e(err);
4085
+ } finally {
4086
+ _iterator5.f();
4087
+ }
4088
+ }
4089
+ } catch (err) {
4090
+ _iterator4.e(err);
4091
+ } finally {
4092
+ _iterator4.f();
4093
+ }
4094
+ return _toConsumableArray(found);
4095
+ }
4096
+
4097
+ // Bridges a fluixi-css theme to the `--flx-ui-*` custom properties the Fluixi UI
4098
+ // components read (`@fluixi-ui/tokens`). Each bridge emits `--flx-ui-x: var(--src)`
4099
+ // so a fluixi-css theme *drives* the UI — change the theme, the components follow —
4100
+ // without copying any values across. A bridge is emitted only when its source
4101
+ // token exists, so the UI's own defaults stand in for anything the theme omits.
4102
+
4103
+ // UI space scale ↔ the `--spacing` base (space-4 = 1rem = 0.25rem × 4).
4104
+ var SPACE_STEPS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
4105
+
4106
+ // UI font-size keys ↔ fluixi `--text-*` keys (the UI's `md` is fluixi's `base`).
4107
+ var FONT_SIZE = [['xs', 'xs'], ['sm', 'sm'], ['md', 'base'], ['lg', 'lg'], ['xl', 'xl'], ['2xl', '2xl'], ['3xl', '3xl'], ['4xl', '4xl']];
4108
+ var RADIUS = ['sm', 'md', 'lg', 'xl'];
4109
+ var SHADOW = ['sm', 'md', 'lg', 'xl'];
4110
+ var BREAKPOINT = ['sm', 'md', 'lg', 'xl', '2xl'];
4111
+ function uiTokenBridges(theme) {
4112
+ var out = [];
4113
+ var bridge = function bridge(flx, source) {
4114
+ if (theme.has(source)) out.push(decl("--flx-ui-".concat(flx), "var(".concat(source, ")")));
4115
+ };
4116
+ if (theme.has('--spacing')) {
4117
+ var _iterator = _createForOfIteratorHelper(SPACE_STEPS),
4118
+ _step;
4119
+ try {
4120
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4121
+ var n = _step.value;
4122
+ out.push(decl("--flx-ui-space-".concat(n), n === 0 ? '0px' : "calc(var(--spacing) * ".concat(n, ")")));
4123
+ }
4124
+ } catch (err) {
4125
+ _iterator.e(err);
4126
+ } finally {
4127
+ _iterator.f();
4128
+ }
4129
+ }
4130
+ var _iterator2 = _createForOfIteratorHelper(RADIUS),
4131
+ _step2;
4132
+ try {
4133
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4134
+ var k = _step2.value;
4135
+ bridge("radius-".concat(k), "--radius-".concat(k));
4136
+ }
4137
+ } catch (err) {
4138
+ _iterator2.e(err);
4139
+ } finally {
4140
+ _iterator2.f();
4141
+ }
4142
+ var _iterator3 = _createForOfIteratorHelper(FONT_SIZE),
4143
+ _step3;
4144
+ try {
4145
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
4146
+ var _step3$value = _slicedToArray(_step3.value, 2),
4147
+ flx = _step3$value[0],
4148
+ key = _step3$value[1];
4149
+ bridge("font-size-".concat(flx), "--text-".concat(key));
4150
+ }
4151
+ } catch (err) {
4152
+ _iterator3.e(err);
4153
+ } finally {
4154
+ _iterator3.f();
4155
+ }
4156
+ var _iterator4 = _createForOfIteratorHelper(SHADOW),
4157
+ _step4;
4158
+ try {
4159
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
4160
+ var _k = _step4.value;
4161
+ bridge("shadow-".concat(_k), "--shadow-".concat(_k));
4162
+ }
4163
+ } catch (err) {
4164
+ _iterator4.e(err);
4165
+ } finally {
4166
+ _iterator4.f();
4167
+ }
4168
+ var _iterator5 = _createForOfIteratorHelper(BREAKPOINT),
4169
+ _step5;
4170
+ try {
4171
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
4172
+ var _k2 = _step5.value;
4173
+ bridge("breakpoint-".concat(_k2), "--breakpoint-".concat(_k2));
4174
+ }
4175
+
4176
+ // The functional colour scales are opt-in: a project supplies a Radix-style
4177
+ // `--color-accent-1..12` / `--color-gray-1..12` in its theme and the UI's
4178
+ // semantic colours (`--flx-ui-color-primary`, …) follow. Absent them, the UI's
4179
+ // built-in scales stand.
4180
+ } catch (err) {
4181
+ _iterator5.e(err);
4182
+ } finally {
4183
+ _iterator5.f();
4184
+ }
4185
+ for (var i = 1; i <= 12; i++) {
4186
+ bridge("accent-".concat(i), "--color-accent-".concat(i));
4187
+ bridge("gray-".concat(i), "--color-gray-".concat(i));
4188
+ }
4189
+ return out;
4190
+ }
4191
+
4192
+ // The bridges as a `:root { … }` rule, ready to prepend to the compiled sheet.
4193
+ function emitUiTheme(theme) {
4194
+ var selector = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ':root';
4195
+ return rule(selector, uiTokenBridges(theme));
4196
+ }
4197
+
4198
+ // Directives consumed to build the registry — dropped from the output.
4199
+ var CONSUMED = new Set(['theme', 'utility', 'custom-variant', 'source']);
4200
+ // The at-rule that marks where generated tokens + utilities are spliced in.
4201
+ var MARKER = 'fluixi';
4202
+ // Processes a whole stylesheet: the author's CSS passes through untouched (and
4203
+ // mapped back to source), the `@theme`/`@utility`/`@custom-variant`/`@source`
4204
+ // directives are consumed, and an `@fluixi;` marker is replaced by the generated
4205
+ // token `:root` + utilities. With no marker the generated block is appended.
4206
+ function transform(input) {
4207
+ var _options$registry, _options$classes, _options$from, _options$sources;
4208
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4209
+ var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
4210
+ loadTheme(input, reg.theme);
4211
+ loadDirectives(input, reg);
4212
+ var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
4213
+ var _iterator = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
4214
+ _step;
4215
+ try {
4216
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4217
+ var s = _step.value;
4218
+ var _iterator6 = _createForOfIteratorHelper(scanAtoms(s)),
4219
+ _step6;
4220
+ try {
4221
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
4222
+ var _c = _step6.value;
4223
+ classes.add(_c);
4224
+ }
4225
+ } catch (err) {
4226
+ _iterator6.e(err);
4227
+ } finally {
4228
+ _iterator6.f();
4229
+ }
4230
+ }
4231
+ } catch (err) {
4232
+ _iterator.e(err);
4233
+ } finally {
4234
+ _iterator.f();
4235
+ }
4236
+ var parsed = parseSources(input);
4237
+ var _iterator2 = _createForOfIteratorHelper(parsed.inline),
4238
+ _step2;
4239
+ try {
4240
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4241
+ var _c2 = _step2.value;
4242
+ classes.add(_c2);
4243
+ }
4244
+ } catch (err) {
4245
+ _iterator2.e(err);
4246
+ } finally {
4247
+ _iterator2.f();
4248
+ }
4249
+ var sources = [];
4250
+ if (parsed.patterns.length) {
4251
+ var _options$base;
4252
+ sources = resolveSourceFiles(parsed, (_options$base = options.base) !== null && _options$base !== void 0 ? _options$base : process.cwd());
4253
+ var _iterator3 = _createForOfIteratorHelper(scanSourceFiles(sources)),
4254
+ _step3;
4255
+ try {
4256
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
4257
+ var c = _step3.value;
4258
+ classes.add(c);
4259
+ }
4260
+ } catch (err) {
4261
+ _iterator3.e(err);
4262
+ } finally {
4263
+ _iterator3.f();
4264
+ }
4265
+ }
4266
+ var rules = [];
4267
+ var _iterator4 = _createForOfIteratorHelper(classes),
4268
+ _step4;
4269
+ try {
4270
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
4271
+ var cls = _step4.value;
4272
+ var atom = parseAtom(cls, reg);
4273
+ if (!atom) continue;
4274
+ var compiled = compileAtom(atom, reg);
4275
+ if (compiled) rules.push.apply(rules, _toConsumableArray(compiled));
4276
+ }
4277
+ } catch (err) {
4278
+ _iterator4.e(err);
4279
+ } finally {
4280
+ _iterator4.f();
4281
+ }
4282
+ var uiBlock = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
4283
+ var generated = [];
4284
+ if (options.emitTokens !== false) {
4285
+ var used = collectVarRefs(rules);
4286
+ if (uiBlock) collectVarRefs([uiBlock], used);
4287
+ var tokens = emitTheme(reg.theme, ':root', used);
4288
+ if (tokens.nodes.length) generated.push(tokens);
4289
+ }
4290
+ if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);
4291
+ generated.push.apply(generated, rules);
4292
+ var from = (_options$from = options.from) !== null && _options$from !== void 0 ? _options$from : '<input>';
4293
+ var nodes = [];
4294
+ var injected = false;
4295
+ var _iterator5 = _createForOfIteratorHelper(parseCss(input).children),
4296
+ _step5;
4297
+ try {
4298
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
4299
+ var _node$loc, _node$loc2;
4300
+ var node = _step5.value;
4301
+ if (node.type === 'atrule' && node.name === MARKER) {
4302
+ if (!injected) {
4303
+ nodes.push.apply(nodes, generated);
4304
+ injected = true;
4305
+ }
4306
+ continue;
4307
+ }
4308
+ if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;
4309
+ var start = (_node$loc = node.loc) === null || _node$loc === void 0 ? void 0 : _node$loc.start;
4310
+ var end = (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.end;
4311
+ if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
4312
+ nodes.push(raw(input.slice(start.offset, end.offset), {
4313
+ source: from,
4314
+ line: start.line,
4315
+ column: Math.max(0, start.column - 1)
4316
+ }));
4317
+ }
4318
+ }
4319
+ } catch (err) {
4320
+ _iterator5.e(err);
4321
+ } finally {
4322
+ _iterator5.f();
4323
+ }
4324
+ if (!injected) nodes.push.apply(nodes, generated);
4325
+ if (options.reset) nodes.unshift(raw(options.reset));
4326
+ if (options.sourceMap) {
4327
+ var _stringifyWithMap = stringifyWithMap(nodes, {
4328
+ minify: options.minify
4329
+ }),
4330
+ css = _stringifyWithMap.css,
4331
+ map = _stringifyWithMap.map;
4332
+ map.setSourceContent(from, input);
4333
+ var json = map.toJSON();
4334
+ json.file = from;
4335
+ return {
4336
+ css: css,
4337
+ map: json,
4338
+ classes: _toConsumableArray(classes),
4339
+ sources: sources,
4340
+ registry: reg
4341
+ };
4342
+ }
4343
+ return {
4344
+ css: stringify(nodes, {
4345
+ minify: options.minify
4346
+ }),
4347
+ classes: _toConsumableArray(classes),
4348
+ sources: sources,
4349
+ registry: reg
4350
+ };
4351
+ }
4352
+
4353
+ // Parse, compile and stringify a set of utility classes. Unknown or malformed
4354
+ // classes are skipped.
4355
+ function compileClasses(classes, reg, options) {
4356
+ var nodes = [];
4357
+ var _iterator = _createForOfIteratorHelper(classes),
4358
+ _step;
4359
+ try {
4360
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
4361
+ var cls = _step.value;
4362
+ var atom = parseAtom(cls, reg);
4363
+ if (!atom) continue;
4364
+ var compiled = compileAtom(atom, reg);
4365
+ if (compiled) nodes.push.apply(nodes, _toConsumableArray(compiled));
4366
+ }
4367
+ } catch (err) {
4368
+ _iterator.e(err);
4369
+ } finally {
4370
+ _iterator.f();
4371
+ }
4372
+ return stringify(nodes, options);
4373
+ }
4374
+ // The one-call entry: merge `@theme` tokens from `input`, gather classes (given
4375
+ // and/or scanned), and emit the token `:root` plus the rules they need.
4376
+ function compile(input) {
4377
+ var _options$registry, _options$classes, _options$sources;
4378
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4379
+ var reg = (_options$registry = options.registry) !== null && _options$registry !== void 0 ? _options$registry : createRegistry();
4380
+ loadTheme(input, reg.theme);
4381
+ loadDirectives(input, reg);
4382
+ var classes = new Set((_options$classes = options.classes) !== null && _options$classes !== void 0 ? _options$classes : []);
4383
+ var _iterator2 = _createForOfIteratorHelper((_options$sources = options.sources) !== null && _options$sources !== void 0 ? _options$sources : []),
4384
+ _step2;
4385
+ try {
4386
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
4387
+ var source = _step2.value;
4388
+ var _iterator6 = _createForOfIteratorHelper(scanAtoms(source)),
4389
+ _step6;
4390
+ try {
4391
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
4392
+ var _c = _step6.value;
4393
+ classes.add(_c);
4394
+ }
4395
+ } catch (err) {
4396
+ _iterator6.e(err);
4397
+ } finally {
4398
+ _iterator6.f();
4399
+ }
4400
+ }
4401
+
4402
+ // `@source` directives pull classes from files on disk.
4403
+ } catch (err) {
4404
+ _iterator2.e(err);
4405
+ } finally {
4406
+ _iterator2.f();
4407
+ }
4408
+ var parsedSources = parseSources(input);
4409
+ var _iterator3 = _createForOfIteratorHelper(parsedSources.inline),
4410
+ _step3;
4411
+ try {
4412
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
4413
+ var _c2 = _step3.value;
4414
+ classes.add(_c2);
4415
+ }
4416
+ } catch (err) {
4417
+ _iterator3.e(err);
4418
+ } finally {
4419
+ _iterator3.f();
4420
+ }
4421
+ var sources = [];
4422
+ if (parsedSources.patterns.length) {
4423
+ var _options$base;
4424
+ sources = resolveSourceFiles(parsedSources, (_options$base = options.base) !== null && _options$base !== void 0 ? _options$base : process.cwd());
4425
+ var _iterator4 = _createForOfIteratorHelper(scanSourceFiles(sources)),
4426
+ _step4;
4427
+ try {
4428
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
4429
+ var c = _step4.value;
4430
+ classes.add(c);
4431
+ }
4432
+ } catch (err) {
4433
+ _iterator4.e(err);
4434
+ } finally {
4435
+ _iterator4.f();
4436
+ }
4437
+ }
4438
+ var rules = [];
4439
+ var _iterator5 = _createForOfIteratorHelper(classes),
4440
+ _step5;
4441
+ try {
4442
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
4443
+ var cls = _step5.value;
4444
+ var atom = parseAtom(cls, reg);
4445
+ if (!atom) continue;
4446
+ var compiled = compileAtom(atom, reg);
4447
+ if (compiled) rules.push.apply(rules, _toConsumableArray(compiled));
4448
+ }
4449
+
4450
+ // The `--flx-ui-*` bridge, if requested — its `var()` refs must survive the
4451
+ // token tree-shake, so fold them into the used set.
4452
+ } catch (err) {
4453
+ _iterator5.e(err);
4454
+ } finally {
4455
+ _iterator5.f();
4456
+ }
4457
+ var uiBlock = options.emitUiTokens ? emitUiTheme(reg.theme) : null;
4458
+
4459
+ // Emit only the tokens the compiled rules (and any UI bridge) actually reference.
4460
+ var nodes = [];
4461
+ if (options.emitTokens !== false) {
4462
+ var used = collectVarRefs(rules);
4463
+ if (uiBlock) collectVarRefs([uiBlock], used);
4464
+ var tokens = emitTheme(reg.theme, ':root', used);
4465
+ if (tokens.nodes.length) nodes.push(tokens);
4466
+ }
4467
+ if (uiBlock && uiBlock.nodes.length) nodes.push(uiBlock);
4468
+ nodes.push.apply(nodes, rules);
4469
+ return {
4470
+ css: stringify(nodes, {
4471
+ minify: options.minify
4472
+ }),
4473
+ classes: _toConsumableArray(classes),
4474
+ sources: sources,
4475
+ registry: reg
4476
+ };
4477
+ }
4478
+
4479
+ export { Registry, SPECIAL_COLORS, Theme, atRule, collectVarRefs, colorValue, compile, compileAtom, compileClasses, createRegistry, decl, decodeUnderscores, defaultTheme, emitTheme, emitUiTheme, escapeClass, keywords, loadDirectives, loadTheme, parseAtom, parseSources, parseVariant, props, raw, registerUtilities, registerVariants, resolveSourceFiles, rule, scanAtoms, scanSourceFiles, sizeValue, splitAtTopLevel, statics, stringify, stringifyWithMap, transform, uiTokenBridges };
4480
+ //# sourceMappingURL=index.mjs.map