@tenphi/tasty 0.1.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 (359) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +236 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +70 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/cacheKey.mjs +70 -0
  8. package/dist/chunks/cacheKey.mjs.map +1 -0
  9. package/dist/chunks/definitions.d.ts +37 -0
  10. package/dist/chunks/definitions.js +260 -0
  11. package/dist/chunks/definitions.js.map +1 -0
  12. package/dist/chunks/definitions.mjs +260 -0
  13. package/dist/chunks/definitions.mjs.map +1 -0
  14. package/dist/chunks/index.d.ts +3 -0
  15. package/dist/chunks/renderChunk.d.ts +2 -0
  16. package/dist/chunks/renderChunk.js +61 -0
  17. package/dist/chunks/renderChunk.js.map +1 -0
  18. package/dist/chunks/renderChunk.mjs +61 -0
  19. package/dist/chunks/renderChunk.mjs.map +1 -0
  20. package/dist/config.d.ts +279 -0
  21. package/dist/config.js +400 -0
  22. package/dist/config.js.map +1 -0
  23. package/dist/config.mjs +231 -0
  24. package/dist/config.mjs.map +1 -0
  25. package/dist/css-writer.d.mts +45 -0
  26. package/dist/css-writer.mjs +74 -0
  27. package/dist/css-writer.mjs.map +1 -0
  28. package/dist/debug.d.ts +204 -0
  29. package/dist/debug.js +733 -0
  30. package/dist/debug.js.map +1 -0
  31. package/dist/extractor.d.mts +24 -0
  32. package/dist/extractor.mjs +150 -0
  33. package/dist/extractor.mjs.map +1 -0
  34. package/dist/hooks/index.d.ts +5 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +27 -0
  36. package/dist/hooks/useGlobalStyles.js +56 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +54 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +91 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +28 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +40 -0
  48. package/dist/hooks/useStyles.js +169 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +38 -0
  51. package/dist/index.js +30 -0
  52. package/dist/injector/index.d.ts +157 -0
  53. package/dist/injector/index.js +154 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +139 -0
  56. package/dist/injector/injector.js +404 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/injector.mjs +404 -0
  59. package/dist/injector/injector.mjs.map +1 -0
  60. package/dist/injector/sheet-manager.d.ts +127 -0
  61. package/dist/injector/sheet-manager.js +714 -0
  62. package/dist/injector/sheet-manager.js.map +1 -0
  63. package/dist/injector/sheet-manager.mjs +714 -0
  64. package/dist/injector/sheet-manager.mjs.map +1 -0
  65. package/dist/injector/types.d.mts +18 -0
  66. package/dist/injector/types.d.ts +135 -0
  67. package/dist/keyframes/index.js +206 -0
  68. package/dist/keyframes/index.js.map +1 -0
  69. package/dist/keyframes/index.mjs +156 -0
  70. package/dist/keyframes/index.mjs.map +1 -0
  71. package/dist/parser/classify.js +319 -0
  72. package/dist/parser/classify.js.map +1 -0
  73. package/dist/parser/classify.mjs +319 -0
  74. package/dist/parser/classify.mjs.map +1 -0
  75. package/dist/parser/const.js +33 -0
  76. package/dist/parser/const.js.map +1 -0
  77. package/dist/parser/const.mjs +33 -0
  78. package/dist/parser/const.mjs.map +1 -0
  79. package/dist/parser/lru.js +109 -0
  80. package/dist/parser/lru.js.map +1 -0
  81. package/dist/parser/lru.mjs +109 -0
  82. package/dist/parser/lru.mjs.map +1 -0
  83. package/dist/parser/parser.d.ts +25 -0
  84. package/dist/parser/parser.js +116 -0
  85. package/dist/parser/parser.js.map +1 -0
  86. package/dist/parser/parser.mjs +116 -0
  87. package/dist/parser/parser.mjs.map +1 -0
  88. package/dist/parser/tokenizer.js +69 -0
  89. package/dist/parser/tokenizer.js.map +1 -0
  90. package/dist/parser/tokenizer.mjs +69 -0
  91. package/dist/parser/tokenizer.mjs.map +1 -0
  92. package/dist/parser/types.d.mts +37 -0
  93. package/dist/parser/types.d.ts +46 -0
  94. package/dist/parser/types.js +46 -0
  95. package/dist/parser/types.js.map +1 -0
  96. package/dist/parser/types.mjs +46 -0
  97. package/dist/parser/types.mjs.map +1 -0
  98. package/dist/pipeline/conditions.js +377 -0
  99. package/dist/pipeline/conditions.js.map +1 -0
  100. package/dist/pipeline/conditions.mjs +377 -0
  101. package/dist/pipeline/conditions.mjs.map +1 -0
  102. package/dist/pipeline/exclusive.d.ts +1 -0
  103. package/dist/pipeline/exclusive.js +231 -0
  104. package/dist/pipeline/exclusive.js.map +1 -0
  105. package/dist/pipeline/exclusive.mjs +231 -0
  106. package/dist/pipeline/exclusive.mjs.map +1 -0
  107. package/dist/pipeline/index.d.ts +53 -0
  108. package/dist/pipeline/index.js +641 -0
  109. package/dist/pipeline/index.js.map +1 -0
  110. package/dist/pipeline/index.mjs +635 -0
  111. package/dist/pipeline/index.mjs.map +1 -0
  112. package/dist/pipeline/materialize.js +821 -0
  113. package/dist/pipeline/materialize.js.map +1 -0
  114. package/dist/pipeline/materialize.mjs +821 -0
  115. package/dist/pipeline/materialize.mjs.map +1 -0
  116. package/dist/pipeline/parseStateKey.d.ts +1 -0
  117. package/dist/pipeline/parseStateKey.js +418 -0
  118. package/dist/pipeline/parseStateKey.js.map +1 -0
  119. package/dist/pipeline/parseStateKey.mjs +418 -0
  120. package/dist/pipeline/parseStateKey.mjs.map +1 -0
  121. package/dist/pipeline/simplify.js +557 -0
  122. package/dist/pipeline/simplify.js.map +1 -0
  123. package/dist/pipeline/simplify.mjs +557 -0
  124. package/dist/pipeline/simplify.mjs.map +1 -0
  125. package/dist/plugins/index.d.ts +2 -0
  126. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  127. package/dist/plugins/okhsl-plugin.js +371 -0
  128. package/dist/plugins/okhsl-plugin.js.map +1 -0
  129. package/dist/plugins/okhsl-plugin.mjs +345 -0
  130. package/dist/plugins/okhsl-plugin.mjs.map +1 -0
  131. package/dist/plugins/types.d.mts +49 -0
  132. package/dist/plugins/types.d.ts +69 -0
  133. package/dist/properties/index.js +158 -0
  134. package/dist/properties/index.js.map +1 -0
  135. package/dist/properties/index.mjs +141 -0
  136. package/dist/properties/index.mjs.map +1 -0
  137. package/dist/states/index.d.ts +45 -0
  138. package/dist/states/index.js +389 -0
  139. package/dist/states/index.js.map +1 -0
  140. package/dist/states/index.mjs +161 -0
  141. package/dist/states/index.mjs.map +1 -0
  142. package/dist/static/index.d.ts +5 -0
  143. package/dist/static/index.js +5 -0
  144. package/dist/static/tastyStatic.d.ts +46 -0
  145. package/dist/static/tastyStatic.js +31 -0
  146. package/dist/static/tastyStatic.js.map +1 -0
  147. package/dist/static/types.d.ts +49 -0
  148. package/dist/static/types.js +24 -0
  149. package/dist/static/types.js.map +1 -0
  150. package/dist/styles/align.d.ts +15 -0
  151. package/dist/styles/align.js +14 -0
  152. package/dist/styles/align.js.map +1 -0
  153. package/dist/styles/align.mjs +14 -0
  154. package/dist/styles/align.mjs.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +114 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/border.mjs +114 -0
  159. package/dist/styles/border.mjs.map +1 -0
  160. package/dist/styles/color.d.ts +14 -0
  161. package/dist/styles/color.js +23 -0
  162. package/dist/styles/color.js.map +1 -0
  163. package/dist/styles/color.mjs +23 -0
  164. package/dist/styles/color.mjs.map +1 -0
  165. package/dist/styles/createStyle.js +77 -0
  166. package/dist/styles/createStyle.js.map +1 -0
  167. package/dist/styles/createStyle.mjs +77 -0
  168. package/dist/styles/createStyle.mjs.map +1 -0
  169. package/dist/styles/dimension.js +97 -0
  170. package/dist/styles/dimension.js.map +1 -0
  171. package/dist/styles/dimension.mjs +97 -0
  172. package/dist/styles/dimension.mjs.map +1 -0
  173. package/dist/styles/display.d.ts +37 -0
  174. package/dist/styles/display.js +67 -0
  175. package/dist/styles/display.js.map +1 -0
  176. package/dist/styles/display.mjs +67 -0
  177. package/dist/styles/display.mjs.map +1 -0
  178. package/dist/styles/fade.d.ts +15 -0
  179. package/dist/styles/fade.js +58 -0
  180. package/dist/styles/fade.js.map +1 -0
  181. package/dist/styles/fade.mjs +58 -0
  182. package/dist/styles/fade.mjs.map +1 -0
  183. package/dist/styles/fill.d.ts +44 -0
  184. package/dist/styles/fill.js +51 -0
  185. package/dist/styles/fill.js.map +1 -0
  186. package/dist/styles/fill.mjs +51 -0
  187. package/dist/styles/fill.mjs.map +1 -0
  188. package/dist/styles/flow.d.ts +16 -0
  189. package/dist/styles/flow.js +12 -0
  190. package/dist/styles/flow.js.map +1 -0
  191. package/dist/styles/flow.mjs +12 -0
  192. package/dist/styles/flow.mjs.map +1 -0
  193. package/dist/styles/gap.d.ts +31 -0
  194. package/dist/styles/gap.js +37 -0
  195. package/dist/styles/gap.js.map +1 -0
  196. package/dist/styles/gap.mjs +37 -0
  197. package/dist/styles/gap.mjs.map +1 -0
  198. package/dist/styles/height.d.ts +17 -0
  199. package/dist/styles/height.js +20 -0
  200. package/dist/styles/height.js.map +1 -0
  201. package/dist/styles/height.mjs +20 -0
  202. package/dist/styles/height.mjs.map +1 -0
  203. package/dist/styles/index.d.ts +2 -0
  204. package/dist/styles/index.js +9 -0
  205. package/dist/styles/index.js.map +1 -0
  206. package/dist/styles/index.mjs +9 -0
  207. package/dist/styles/index.mjs.map +1 -0
  208. package/dist/styles/inset.d.ts +50 -0
  209. package/dist/styles/inset.js +142 -0
  210. package/dist/styles/inset.js.map +1 -0
  211. package/dist/styles/inset.mjs +142 -0
  212. package/dist/styles/inset.mjs.map +1 -0
  213. package/dist/styles/justify.d.ts +15 -0
  214. package/dist/styles/justify.js +14 -0
  215. package/dist/styles/justify.js.map +1 -0
  216. package/dist/styles/justify.mjs +14 -0
  217. package/dist/styles/justify.mjs.map +1 -0
  218. package/dist/styles/list.d.ts +16 -0
  219. package/dist/styles/list.js +98 -0
  220. package/dist/styles/list.js.map +1 -0
  221. package/dist/styles/margin.d.ts +28 -0
  222. package/dist/styles/margin.js +96 -0
  223. package/dist/styles/margin.js.map +1 -0
  224. package/dist/styles/margin.mjs +96 -0
  225. package/dist/styles/margin.mjs.map +1 -0
  226. package/dist/styles/outline.d.ts +29 -0
  227. package/dist/styles/outline.js +65 -0
  228. package/dist/styles/outline.js.map +1 -0
  229. package/dist/styles/outline.mjs +65 -0
  230. package/dist/styles/outline.mjs.map +1 -0
  231. package/dist/styles/padding.d.ts +28 -0
  232. package/dist/styles/padding.js +96 -0
  233. package/dist/styles/padding.js.map +1 -0
  234. package/dist/styles/padding.mjs +96 -0
  235. package/dist/styles/padding.mjs.map +1 -0
  236. package/dist/styles/predefined.d.ts +74 -0
  237. package/dist/styles/predefined.js +241 -0
  238. package/dist/styles/predefined.js.map +1 -0
  239. package/dist/styles/predefined.mjs +232 -0
  240. package/dist/styles/predefined.mjs.map +1 -0
  241. package/dist/styles/preset.d.ts +47 -0
  242. package/dist/styles/preset.js +126 -0
  243. package/dist/styles/preset.js.map +1 -0
  244. package/dist/styles/preset.mjs +126 -0
  245. package/dist/styles/preset.mjs.map +1 -0
  246. package/dist/styles/radius.d.ts +14 -0
  247. package/dist/styles/radius.js +51 -0
  248. package/dist/styles/radius.js.map +1 -0
  249. package/dist/styles/radius.mjs +51 -0
  250. package/dist/styles/radius.mjs.map +1 -0
  251. package/dist/styles/scrollbar.d.ts +21 -0
  252. package/dist/styles/scrollbar.js +105 -0
  253. package/dist/styles/scrollbar.js.map +1 -0
  254. package/dist/styles/scrollbar.mjs +105 -0
  255. package/dist/styles/scrollbar.mjs.map +1 -0
  256. package/dist/styles/shadow.d.ts +14 -0
  257. package/dist/styles/shadow.js +24 -0
  258. package/dist/styles/shadow.js.map +1 -0
  259. package/dist/styles/shadow.mjs +24 -0
  260. package/dist/styles/shadow.mjs.map +1 -0
  261. package/dist/styles/styledScrollbar.d.ts +47 -0
  262. package/dist/styles/styledScrollbar.js +38 -0
  263. package/dist/styles/styledScrollbar.js.map +1 -0
  264. package/dist/styles/styledScrollbar.mjs +38 -0
  265. package/dist/styles/styledScrollbar.mjs.map +1 -0
  266. package/dist/styles/transition.d.ts +14 -0
  267. package/dist/styles/transition.js +138 -0
  268. package/dist/styles/transition.js.map +1 -0
  269. package/dist/styles/transition.mjs +138 -0
  270. package/dist/styles/transition.mjs.map +1 -0
  271. package/dist/styles/types.d.mts +492 -0
  272. package/dist/styles/types.d.ts +496 -0
  273. package/dist/styles/width.d.ts +17 -0
  274. package/dist/styles/width.js +20 -0
  275. package/dist/styles/width.js.map +1 -0
  276. package/dist/styles/width.mjs +20 -0
  277. package/dist/styles/width.mjs.map +1 -0
  278. package/dist/tasty.d.ts +983 -0
  279. package/dist/tasty.js +191 -0
  280. package/dist/tasty.js.map +1 -0
  281. package/dist/tokens/typography.d.ts +19 -0
  282. package/dist/tokens/typography.js +237 -0
  283. package/dist/tokens/typography.js.map +1 -0
  284. package/dist/types.d.ts +182 -0
  285. package/dist/utils/cache-wrapper.js +26 -0
  286. package/dist/utils/cache-wrapper.js.map +1 -0
  287. package/dist/utils/cache-wrapper.mjs +26 -0
  288. package/dist/utils/cache-wrapper.mjs.map +1 -0
  289. package/dist/utils/case-converter.js +8 -0
  290. package/dist/utils/case-converter.js.map +1 -0
  291. package/dist/utils/case-converter.mjs +8 -0
  292. package/dist/utils/case-converter.mjs.map +1 -0
  293. package/dist/utils/colors.d.ts +5 -0
  294. package/dist/utils/colors.js +9 -0
  295. package/dist/utils/colors.js.map +1 -0
  296. package/dist/utils/dotize.d.ts +26 -0
  297. package/dist/utils/dotize.js +122 -0
  298. package/dist/utils/dotize.js.map +1 -0
  299. package/dist/utils/filter-base-props.d.ts +15 -0
  300. package/dist/utils/filter-base-props.js +45 -0
  301. package/dist/utils/filter-base-props.js.map +1 -0
  302. package/dist/utils/get-display-name.d.ts +7 -0
  303. package/dist/utils/get-display-name.js +10 -0
  304. package/dist/utils/get-display-name.js.map +1 -0
  305. package/dist/utils/hsl-to-rgb.js +38 -0
  306. package/dist/utils/hsl-to-rgb.js.map +1 -0
  307. package/dist/utils/hsl-to-rgb.mjs +38 -0
  308. package/dist/utils/hsl-to-rgb.mjs.map +1 -0
  309. package/dist/utils/is-dev-env.js +19 -0
  310. package/dist/utils/is-dev-env.js.map +1 -0
  311. package/dist/utils/is-dev-env.mjs +19 -0
  312. package/dist/utils/is-dev-env.mjs.map +1 -0
  313. package/dist/utils/merge-styles.d.ts +7 -0
  314. package/dist/utils/merge-styles.js +146 -0
  315. package/dist/utils/merge-styles.js.map +1 -0
  316. package/dist/utils/merge-styles.mjs +146 -0
  317. package/dist/utils/merge-styles.mjs.map +1 -0
  318. package/dist/utils/mod-attrs.d.ts +8 -0
  319. package/dist/utils/mod-attrs.js +21 -0
  320. package/dist/utils/mod-attrs.js.map +1 -0
  321. package/dist/utils/okhsl-to-rgb.js +296 -0
  322. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  323. package/dist/utils/okhsl-to-rgb.mjs +296 -0
  324. package/dist/utils/okhsl-to-rgb.mjs.map +1 -0
  325. package/dist/utils/process-tokens.d.ts +31 -0
  326. package/dist/utils/process-tokens.js +171 -0
  327. package/dist/utils/process-tokens.js.map +1 -0
  328. package/dist/utils/process-tokens.mjs +28 -0
  329. package/dist/utils/process-tokens.mjs.map +1 -0
  330. package/dist/utils/resolve-recipes.d.ts +17 -0
  331. package/dist/utils/resolve-recipes.js +143 -0
  332. package/dist/utils/resolve-recipes.js.map +1 -0
  333. package/dist/utils/resolve-recipes.mjs +143 -0
  334. package/dist/utils/resolve-recipes.mjs.map +1 -0
  335. package/dist/utils/string.js +8 -0
  336. package/dist/utils/string.js.map +1 -0
  337. package/dist/utils/string.mjs +8 -0
  338. package/dist/utils/string.mjs.map +1 -0
  339. package/dist/utils/styles.d.mts +18 -0
  340. package/dist/utils/styles.d.ts +183 -0
  341. package/dist/utils/styles.js +585 -0
  342. package/dist/utils/styles.js.map +1 -0
  343. package/dist/utils/styles.mjs +346 -0
  344. package/dist/utils/styles.mjs.map +1 -0
  345. package/dist/utils/typography.d.ts +36 -0
  346. package/dist/utils/typography.js +53 -0
  347. package/dist/utils/typography.js.map +1 -0
  348. package/dist/utils/warnings.d.ts +16 -0
  349. package/dist/utils/warnings.js +16 -0
  350. package/dist/utils/warnings.js.map +1 -0
  351. package/dist/zero/babel.d.mts +108 -0
  352. package/dist/zero/babel.mjs +282 -0
  353. package/dist/zero/babel.mjs.map +1 -0
  354. package/dist/zero/index.d.mts +3 -0
  355. package/dist/zero/index.mjs +4 -0
  356. package/dist/zero/next.d.mts +60 -0
  357. package/dist/zero/next.mjs +78 -0
  358. package/dist/zero/next.mjs.map +1 -0
  359. package/package.json +127 -0
@@ -0,0 +1,641 @@
1
+ import { Lru } from "../parser/lru.js";
2
+ import { stringifyStyles } from "../utils/styles.js";
3
+ import { createStyle } from "../styles/createStyle.js";
4
+ import { STYLE_HANDLER_MAP } from "../styles/index.js";
5
+ import { createStateParserContext, extractLocalPredefinedStates } from "../states/index.js";
6
+ import { and, falseCondition, not, or, trueCondition } from "./conditions.js";
7
+ import { simplifyCondition } from "./simplify.js";
8
+ import { buildExclusiveConditions, expandExclusiveOrs, expandOrConditions, isValueMapping, parseStyleEntries } from "./exclusive.js";
9
+ import { buildAtRulesFromVariant, conditionToCSS, modifierToCSS, pseudoToCSS, rootConditionsToCSS } from "./materialize.js";
10
+ import { parseStateKey } from "./parseStateKey.js";
11
+
12
+ //#region src/pipeline/index.ts
13
+ /**
14
+ * Tasty Style Rendering Pipeline
15
+ *
16
+ * This is the main entrypoint for the new pipeline implementation.
17
+ * It implements the complete flow from style objects to CSS rules.
18
+ *
19
+ * Pipeline stages:
20
+ * 1. PARSE CONDITIONS - Parse state keys into ConditionNode trees
21
+ * 2. BUILD EXCLUSIVE CONDITIONS - AND with negation of higher-priority conditions
22
+ * 3. SIMPLIFY CONDITIONS - Apply boolean algebra, detect contradictions
23
+ * 4. GROUP BY HANDLER - Collect styles per handler, compute combinations
24
+ * 5. COMPUTE CSS VALUES - Call handlers to get CSS declarations
25
+ * 6. MERGE BY VALUE - Merge rules with identical CSS output
26
+ * 7. MATERIALIZE CSS - Convert conditions to CSS selectors + at-rules
27
+ */
28
+ const pipelineCache = new Lru(5e3);
29
+ /**
30
+ * Clear the pipeline cache (for testing)
31
+ */
32
+ function clearPipelineCache() {
33
+ pipelineCache.clear();
34
+ }
35
+ function runPipeline(styles, parserContext) {
36
+ const allRules = [];
37
+ processStyles(styles, "", parserContext, allRules);
38
+ const seen = /* @__PURE__ */ new Set();
39
+ return allRules.filter((rule) => {
40
+ const key = `${rule.selector}|${rule.declarations}|${JSON.stringify(rule.atRules || [])}|${rule.rootPrefix || ""}`;
41
+ if (seen.has(key)) return false;
42
+ seen.add(key);
43
+ return true;
44
+ });
45
+ }
46
+ /**
47
+ * Process styles at a given nesting level
48
+ */
49
+ function processStyles(styles, selectorSuffix, parserContext, allRules) {
50
+ const keys = Object.keys(styles);
51
+ const selectorKeys = keys.filter((key) => isSelector(key));
52
+ const styleKeys = keys.filter((key) => !isSelector(key) && !key.startsWith("@"));
53
+ for (const key of selectorKeys) {
54
+ const nestedStyles = styles[key];
55
+ if (!nestedStyles || typeof nestedStyles !== "object") continue;
56
+ const suffixes = getAllSelectors(key, nestedStyles);
57
+ if (!suffixes) continue;
58
+ const { $: _$, ...cleanedStyles } = nestedStyles;
59
+ const subLocalStates = extractLocalPredefinedStates(cleanedStyles);
60
+ const hasSubStates = Object.keys(subLocalStates).length > 0;
61
+ const subContext = {
62
+ ...parserContext,
63
+ isSubElement: true,
64
+ localPredefinedStates: hasSubStates ? {
65
+ ...parserContext.localPredefinedStates,
66
+ ...subLocalStates
67
+ } : parserContext.localPredefinedStates
68
+ };
69
+ for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules);
70
+ }
71
+ const handlerQueue = buildHandlerQueue(styleKeys, styles);
72
+ for (const { handler, styleMap } of handlerQueue) {
73
+ const lookupStyles = handler.__lookupStyles;
74
+ const exclusiveByStyle = /* @__PURE__ */ new Map();
75
+ for (const styleName of lookupStyles) {
76
+ const value = styleMap[styleName];
77
+ if (value === void 0) continue;
78
+ if (isValueMapping(value)) {
79
+ const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(parseStyleEntries(styleName, value, (stateKey) => parseStateKey(stateKey, { context: parserContext })))));
80
+ exclusiveByStyle.set(styleName, fullyExpanded);
81
+ } else exclusiveByStyle.set(styleName, [{
82
+ styleKey: styleName,
83
+ stateKey: "",
84
+ value,
85
+ condition: trueCondition(),
86
+ priority: 0,
87
+ exclusiveCondition: trueCondition()
88
+ }]);
89
+ }
90
+ const stateSnapshots = computeStateCombinations(exclusiveByStyle, lookupStyles);
91
+ const computedRules = [];
92
+ for (const snapshot of stateSnapshots) {
93
+ const result = handler(snapshot.values);
94
+ if (!result) continue;
95
+ const results = Array.isArray(result) ? result : [result];
96
+ for (const r of results) {
97
+ if (!r || typeof r !== "object") continue;
98
+ const { $, ...styleProps } = r;
99
+ const declarations = {};
100
+ for (const [prop, val] of Object.entries(styleProps)) if (val != null && val !== "") declarations[prop] = String(val);
101
+ if (Object.keys(declarations).length === 0) continue;
102
+ const suffixes = $ ? (Array.isArray($) ? $ : [$]).map((s) => selectorSuffix + normalizeSelectorSuffix(String(s))) : [selectorSuffix];
103
+ for (const suffix of suffixes) computedRules.push({
104
+ condition: snapshot.condition,
105
+ declarations,
106
+ selectorSuffix: suffix
107
+ });
108
+ }
109
+ }
110
+ const mergedRules = mergeByValue(computedRules);
111
+ for (const rule of mergedRules) {
112
+ const cssRules = materializeComputedRule(rule);
113
+ allRules.push(...cssRules);
114
+ }
115
+ }
116
+ }
117
+ /**
118
+ * Check if a key is a CSS selector
119
+ */
120
+ function isSelector(key) {
121
+ return key.startsWith("&") || key.startsWith(".") || /^[A-Z]/.test(key);
122
+ }
123
+ /**
124
+ * Get all selector suffixes for a sub-element key.
125
+ *
126
+ * Handles three types of selector keys:
127
+ * - `&` prefix: Raw selector suffix (e.g., `&:hover` → `:hover`)
128
+ * - `.` prefix: Class selector (e.g., `.active` → ` .active`)
129
+ * - Uppercase: Sub-element with optional `$` affix pattern
130
+ *
131
+ * @param key - The sub-element key (e.g., 'Label', '&:hover', '.active')
132
+ * @param styles - The styles object, may contain `$` property for selector affix
133
+ * @returns Array of selector suffixes, or null if invalid (with console warning)
134
+ *
135
+ * @example
136
+ * getAllSelectors('Label', {})
137
+ * // → [' [data-element="Label"]']
138
+ *
139
+ * getAllSelectors('Cell', { $: '>, >Body>' })
140
+ * // → ['> [data-element="Cell"]', ' [data-element="Body"] > [data-element="Cell"]']
141
+ */
142
+ function getAllSelectors(key, styles) {
143
+ if (key.startsWith("&")) return [key.slice(1)];
144
+ if (key.startsWith(".")) return [` ${key}`];
145
+ if (/^[A-Z]/.test(key)) {
146
+ const affix = styles?.$;
147
+ if (affix !== void 0) {
148
+ const result = processAffix(String(affix), key);
149
+ if (!result.valid) {
150
+ console.warn(`[Tasty] ${result.reason}`);
151
+ return null;
152
+ }
153
+ return result.selectors;
154
+ }
155
+ return [` [data-element="${key}"]`];
156
+ }
157
+ return null;
158
+ }
159
+ /**
160
+ * Process selector affix pattern and return selector(s)
161
+ *
162
+ * Supports:
163
+ * - Direct child: '>'
164
+ * - Chained elements: '>Body>Row>'
165
+ * - HTML tags: 'a', '>ul>li', 'button:hover'
166
+ * - Pseudo-elements on root: '::before'
167
+ * - Pseudo on sub-element: '@::before', '>@:hover'
168
+ * - Classes: '.active', '>@.active'
169
+ * - Multiple selectors: '>, >Body>'
170
+ * - Sibling combinators (after element): '>Item+', '>Item~'
171
+ */
172
+ function processAffix(affix, key) {
173
+ const trimmed = affix.trim();
174
+ if (!trimmed) return {
175
+ valid: true,
176
+ selectors: [` [data-element="${key}"]`]
177
+ };
178
+ const patterns = trimmed.split(",").map((p) => p.trim());
179
+ const selectors = [];
180
+ for (const pattern of patterns) {
181
+ const validation = validatePattern(pattern);
182
+ if (!validation.valid) return validation;
183
+ const selector = processSinglePattern(pattern, key);
184
+ selectors.push(selector);
185
+ }
186
+ return {
187
+ valid: true,
188
+ selectors
189
+ };
190
+ }
191
+ /**
192
+ * Recognized token patterns for selector affix validation.
193
+ *
194
+ * These patterns are used to tokenize and validate `$` affix strings.
195
+ * Order matters: more specific patterns must come first to avoid
196
+ * partial matches (e.g., `::before` must match before `:` alone).
197
+ *
198
+ * Unrecognized tokens (like `#id`, `*`, or numbers) will cause validation to fail.
199
+ */
200
+ const VALID_TOKEN_PATTERNS = [
201
+ /^[>+~]/,
202
+ /^[A-Z][a-zA-Z0-9]*/,
203
+ /^@/,
204
+ /^::?[a-z][a-z0-9-]*(?:\([^)]*\))?/,
205
+ /^\.[a-zA-Z_-][a-zA-Z0-9_-]*/,
206
+ /^\[[^\]]+\]/,
207
+ /^[a-z][a-z0-9-]*/,
208
+ /^\s+/,
209
+ /^&/
210
+ ];
211
+ /**
212
+ * Scan a pattern for unrecognized tokens.
213
+ *
214
+ * Iterates through the pattern, consuming recognized tokens until
215
+ * either the pattern is fully consumed (valid) or an unrecognized
216
+ * character sequence is found (invalid).
217
+ *
218
+ * @param pattern - The selector pattern to validate
219
+ * @returns The first unrecognized token found, or null if all tokens are valid
220
+ *
221
+ * @example
222
+ * findUnrecognizedTokens('>Body>Row>') // → null (valid)
223
+ * findUnrecognizedTokens('123') // → '123' (invalid)
224
+ * findUnrecognizedTokens('#myId') // → '#' (invalid)
225
+ */
226
+ function findUnrecognizedTokens(pattern) {
227
+ let remaining = pattern;
228
+ while (remaining.length > 0) {
229
+ let matched = false;
230
+ for (const regex of VALID_TOKEN_PATTERNS) {
231
+ const match = remaining.match(regex);
232
+ if (match) {
233
+ remaining = remaining.slice(match[0].length);
234
+ matched = true;
235
+ break;
236
+ }
237
+ }
238
+ if (!matched) {
239
+ const unrecognized = remaining.match(/^[^\s>+~@.:[\]A-Z]+/);
240
+ return unrecognized ? unrecognized[0] : remaining[0];
241
+ }
242
+ }
243
+ return null;
244
+ }
245
+ /**
246
+ * Validate a selector pattern for structural correctness.
247
+ *
248
+ * Checks for:
249
+ * 1. Out-of-scope selectors: Patterns starting with `+` or `~` target siblings
250
+ * of the root element, which is outside the component's DOM scope.
251
+ * 2. Consecutive combinators: Patterns like `>>` or `>+` are malformed CSS.
252
+ * 3. Unrecognized tokens: Characters/sequences not matching valid CSS selectors.
253
+ *
254
+ * @param pattern - A single selector pattern (already split by comma)
255
+ * @returns AffixResult indicating validity and error reason if invalid
256
+ *
257
+ * @example
258
+ * validatePattern('>Body>Row>') // → { valid: true, selectors: [] }
259
+ * validatePattern('+') // → { valid: false, reason: '...outside root scope...' }
260
+ * validatePattern('>>') // → { valid: false, reason: '...consecutive combinators...' }
261
+ */
262
+ function validatePattern(pattern) {
263
+ const trimmed = pattern.trim();
264
+ if (/^[+~]/.test(trimmed)) return {
265
+ valid: false,
266
+ reason: `Selector affix "${pattern}" targets elements outside the root scope. Sibling selectors (+, ~) must be preceded by an element inside the root. Use ">Element+" or ">Element~" instead.`
267
+ };
268
+ if (/[>+~]{2,}/.test(trimmed.replace(/\s+/g, ""))) return {
269
+ valid: false,
270
+ reason: `Selector affix "${pattern}" contains consecutive combinators.`
271
+ };
272
+ const unrecognized = findUnrecognizedTokens(trimmed);
273
+ if (unrecognized) return {
274
+ valid: false,
275
+ reason: `Selector affix "${pattern}" contains unrecognized token "${unrecognized}". Valid tokens: combinators (>, +, ~), element names (Uppercase), @ placeholder, pseudo (:hover, ::before), class (.name), attribute ([attr]).`
276
+ };
277
+ return {
278
+ valid: true,
279
+ selectors: []
280
+ };
281
+ }
282
+ /**
283
+ * Process a single selector pattern into a CSS selector suffix.
284
+ *
285
+ * This is the main transformation function that converts a `$` affix pattern
286
+ * into a valid CSS selector suffix. It handles:
287
+ *
288
+ * 1. `@` placeholder replacement with `[data-element="key"]`
289
+ * 2. Key injection based on pattern ending (see `shouldInjectKey`)
290
+ * 3. Proper spacing for descendant vs direct child selectors
291
+ *
292
+ * @param pattern - A single validated selector pattern
293
+ * @param key - The sub-element key to inject (e.g., 'Label', 'Cell')
294
+ * @returns CSS selector suffix ready to append to the root selector
295
+ *
296
+ * @example
297
+ * processSinglePattern('>', 'Row')
298
+ * // → '> [data-element="Row"]'
299
+ *
300
+ * processSinglePattern('>Body>Row>', 'Cell')
301
+ * // → '> [data-element="Body"] > [data-element="Row"] > [data-element="Cell"]'
302
+ *
303
+ * processSinglePattern('::before', 'Before')
304
+ * // → '::before' (no key injection for pseudo on root)
305
+ *
306
+ * processSinglePattern('>@:hover', 'Item')
307
+ * // → '> [data-element="Item"]:hover'
308
+ */
309
+ function processSinglePattern(pattern, key) {
310
+ const normalized = pattern.replace(/^&/, "").trim();
311
+ if (!normalized) return ` [data-element="${key}"]`;
312
+ const startsWithPseudo = /^::?[a-z]/.test(normalized);
313
+ let result = transformPattern(normalized);
314
+ if (result.includes("@")) {
315
+ result = result.replace(/@ (?=[.:])/g, "@");
316
+ result = result.replace(/@/g, `[data-element="${key}"]`);
317
+ if (!startsWithPseudo && !result.startsWith(" ")) result = " " + result;
318
+ return result;
319
+ }
320
+ if (shouldInjectKey(normalized)) result = result + ` [data-element="${key}"]`;
321
+ if (!startsWithPseudo && !result.startsWith(" ")) result = " " + result;
322
+ return result;
323
+ }
324
+ /**
325
+ * Transform a selector pattern by converting element names and normalizing spacing.
326
+ *
327
+ * This is a character-by-character tokenizer that:
328
+ * - Converts uppercase names to `[data-element="Name"]` selectors
329
+ * - Adds proper spacing around combinators (>, +, ~)
330
+ * - Preserves lowercase tags, classes, pseudos, and attributes as-is
331
+ * - Keeps @ placeholder for later replacement
332
+ *
333
+ * The tokenizer handles these token types in order:
334
+ * 1. Whitespace (skipped)
335
+ * 2. Combinators: >, +, ~ (add surrounding spaces)
336
+ * 3. Uppercase names: Body, Row (convert to [data-element="..."])
337
+ * 4. @ placeholder (keep for later replacement)
338
+ * 5. Pseudo: :hover, ::before (attach to previous token)
339
+ * 6. Tags: a, div, button (keep as-is with spacing)
340
+ * 7. Classes: .active (attach to previous element/tag/placeholder)
341
+ * 8. Attributes: [type="text"] (keep as-is)
342
+ *
343
+ * @param pattern - The raw selector pattern to transform
344
+ * @returns Transformed pattern with proper CSS selector syntax
345
+ *
346
+ * @example
347
+ * transformPattern('>Body>Row>')
348
+ * // → '> [data-element="Body"] > [data-element="Row"] >'
349
+ *
350
+ * transformPattern('button.primary:hover')
351
+ * // → 'button.primary:hover'
352
+ */
353
+ function transformPattern(pattern) {
354
+ let result = "";
355
+ let i = 0;
356
+ while (i < pattern.length) {
357
+ const char = pattern[i];
358
+ if (/\s/.test(char)) {
359
+ i++;
360
+ continue;
361
+ }
362
+ if (/[>+~]/.test(char)) {
363
+ if (result && !result.endsWith(" ")) result += " ";
364
+ result += char;
365
+ i++;
366
+ continue;
367
+ }
368
+ if (/[A-Z]/.test(char)) {
369
+ let name = "";
370
+ while (i < pattern.length && /[a-zA-Z0-9]/.test(pattern[i])) {
371
+ name += pattern[i];
372
+ i++;
373
+ }
374
+ if (result && !result.endsWith(" ")) result += " ";
375
+ result += `[data-element="${name}"]`;
376
+ continue;
377
+ }
378
+ if (char === "@") {
379
+ if (result && !result.endsWith(" ")) result += " ";
380
+ result += "@";
381
+ i++;
382
+ continue;
383
+ }
384
+ if (char === ":") {
385
+ let pseudo = "";
386
+ while (i < pattern.length && !/[\s>+~,@]/.test(pattern[i]) && !/[A-Z]/.test(pattern[i])) {
387
+ pseudo += pattern[i];
388
+ i++;
389
+ }
390
+ result += pseudo;
391
+ continue;
392
+ }
393
+ if (/[a-z]/.test(char)) {
394
+ let tag = "";
395
+ while (i < pattern.length && /[a-z0-9-]/.test(pattern[i])) {
396
+ tag += pattern[i];
397
+ i++;
398
+ }
399
+ if (result && !result.endsWith(" ")) result += " ";
400
+ result += tag;
401
+ continue;
402
+ }
403
+ if (char === ".") {
404
+ const lastNonSpace = result.replace(/\s+$/, "").slice(-1);
405
+ const attachToLast = lastNonSpace === "]" || lastNonSpace === "@" || /[a-zA-Z0-9-]/.test(lastNonSpace);
406
+ if (result && !attachToLast && !result.endsWith(" ")) result += " ";
407
+ let cls = ".";
408
+ i++;
409
+ while (i < pattern.length && /[a-zA-Z0-9_-]/.test(pattern[i])) {
410
+ cls += pattern[i];
411
+ i++;
412
+ }
413
+ result += cls;
414
+ continue;
415
+ }
416
+ if (char === "[") {
417
+ const lastNonSpace = result.replace(/\s+$/, "").slice(-1);
418
+ const attachToLast = lastNonSpace === "]" || lastNonSpace === "@" || /[a-zA-Z0-9-]/.test(lastNonSpace);
419
+ if (result && !attachToLast && !result.endsWith(" ")) result += " ";
420
+ let attr = "";
421
+ let depth = 0;
422
+ while (i < pattern.length) {
423
+ attr += pattern[i];
424
+ if (pattern[i] === "[") depth++;
425
+ if (pattern[i] === "]") depth--;
426
+ i++;
427
+ if (depth === 0) break;
428
+ }
429
+ result += attr;
430
+ continue;
431
+ }
432
+ result += char;
433
+ i++;
434
+ }
435
+ return result;
436
+ }
437
+ /**
438
+ * Determine if the sub-element key should be auto-injected based on pattern ending.
439
+ *
440
+ * Key injection rules (when no @ placeholder is present):
441
+ *
442
+ * | Pattern Ending | Inject Key? | Example | Result |
443
+ * |----------------|-------------|---------|--------|
444
+ * | Combinator (>, +, ~) | Yes | `'>Body>'` | `> [data-element="Body"] > [el]` |
445
+ * | Uppercase element | Yes | `'>Body>Row'` | `> [el1] > [el2] [key]` |
446
+ * | Lowercase tag | Yes | `'>ul>li'` | `> ul > li [key]` |
447
+ * | Pseudo (:hover, ::before) | No | `'::before'` | `::before` |
448
+ * | Class (.active) | No | `'.active'` | `.active` |
449
+ * | Attribute ([type]) | No | `'[type="text"]'` | `[type="text"]` |
450
+ *
451
+ * @param pattern - The normalized pattern (after stripping &)
452
+ * @returns true if key should be injected, false otherwise
453
+ *
454
+ * @example
455
+ * shouldInjectKey('>') // → true (trailing combinator)
456
+ * shouldInjectKey('>Body>Row') // → true (ends with element)
457
+ * shouldInjectKey('>ul>li') // → true (ends with tag)
458
+ * shouldInjectKey('::before') // → false (ends with pseudo)
459
+ * shouldInjectKey('.active') // → false (ends with class)
460
+ * shouldInjectKey('a:hover') // → false (ends with pseudo)
461
+ * shouldInjectKey('button.primary') // → false (ends with class)
462
+ */
463
+ function shouldInjectKey(pattern) {
464
+ const trimmed = pattern.trim();
465
+ if (/[>+~]$/.test(trimmed)) return true;
466
+ if (/(?:^|[\s>+~\]:])[A-Z][a-zA-Z0-9]*$/.test(trimmed)) return true;
467
+ if (/(?<![:.])(?:^|[\s>+~])[a-z][a-z0-9-]*$/.test(trimmed)) return true;
468
+ return false;
469
+ }
470
+ /**
471
+ * Normalize selector suffix from $ property
472
+ */
473
+ function normalizeSelectorSuffix(suffix) {
474
+ if (!suffix) return "";
475
+ return suffix.startsWith("&") ? suffix.slice(1) : suffix;
476
+ }
477
+ /**
478
+ * Build handler queue from style keys
479
+ */
480
+ function buildHandlerQueue(styleKeys, styles) {
481
+ const queue = [];
482
+ const seenHandlers = /* @__PURE__ */ new Set();
483
+ for (const styleName of styleKeys) {
484
+ let handlers = STYLE_HANDLER_MAP[styleName];
485
+ if (!handlers) handlers = STYLE_HANDLER_MAP[styleName] = [createStyle(styleName)];
486
+ for (const handler of handlers) {
487
+ if (seenHandlers.has(handler)) continue;
488
+ seenHandlers.add(handler);
489
+ const lookupStyles = handler.__lookupStyles;
490
+ const styleMap = {};
491
+ for (const name of lookupStyles) {
492
+ const val = styles[name];
493
+ if (val !== void 0) styleMap[name] = val;
494
+ }
495
+ queue.push({
496
+ handler,
497
+ styleMap
498
+ });
499
+ }
500
+ }
501
+ return queue;
502
+ }
503
+ /**
504
+ * Compute all valid state combinations for a handler's lookup styles
505
+ */
506
+ function computeStateCombinations(exclusiveByStyle, lookupStyles) {
507
+ const combinations = cartesianProduct(lookupStyles.map((style) => exclusiveByStyle.get(style) || []));
508
+ const snapshots = [];
509
+ for (const combo of combinations) {
510
+ const simplified = simplifyCondition(and(...combo.map((e) => e.exclusiveCondition)));
511
+ if (simplified.kind === "false") continue;
512
+ const values = {};
513
+ for (const entry of combo) values[entry.styleKey] = entry.value;
514
+ snapshots.push({
515
+ condition: simplified,
516
+ values
517
+ });
518
+ }
519
+ return snapshots;
520
+ }
521
+ /**
522
+ * Cartesian product of arrays
523
+ */
524
+ function cartesianProduct(arrays) {
525
+ if (arrays.length === 0) return [[]];
526
+ const nonEmpty = arrays.filter((a) => a.length > 0);
527
+ if (nonEmpty.length === 0) return [[]];
528
+ return nonEmpty.reduce((acc, arr) => acc.flatMap((combo) => arr.map((item) => [...combo, item])), [[]]);
529
+ }
530
+ /**
531
+ * Merge rules with identical CSS output
532
+ */
533
+ function mergeByValue(rules) {
534
+ const groups = /* @__PURE__ */ new Map();
535
+ for (const rule of rules) {
536
+ const key = `${rule.selectorSuffix}|${JSON.stringify(rule.declarations)}`;
537
+ if (!groups.has(key)) groups.set(key, []);
538
+ groups.get(key).push(rule);
539
+ }
540
+ const merged = [];
541
+ for (const [, groupRules] of groups) if (groupRules.length === 1) merged.push(groupRules[0]);
542
+ else {
543
+ const mergedCondition = simplifyCondition(or(...groupRules.map((r) => r.condition)));
544
+ merged.push({
545
+ condition: mergedCondition,
546
+ declarations: groupRules[0].declarations,
547
+ selectorSuffix: groupRules[0].selectorSuffix
548
+ });
549
+ }
550
+ return merged;
551
+ }
552
+ /**
553
+ * Build selector fragment from a variant (without className prefix)
554
+ */
555
+ function buildSelectorFromVariant(variant, selectorSuffix) {
556
+ let selector = "";
557
+ for (const mod of variant.modifierConditions) selector += modifierToCSS(mod);
558
+ for (const pseudo of variant.pseudoConditions) selector += pseudoToCSS(pseudo);
559
+ selector += selectorSuffix;
560
+ for (const own of variant.ownConditions) if ("attribute" in own) selector += modifierToCSS(own);
561
+ else selector += pseudoToCSS(own);
562
+ return selector;
563
+ }
564
+ /**
565
+ * Materialize a computed rule to final CSS format
566
+ *
567
+ * Returns an array because OR conditions may generate multiple CSS rules
568
+ * (when different branches have different at-rules)
569
+ */
570
+ function materializeComputedRule(rule) {
571
+ const components = conditionToCSS(rule.condition);
572
+ if (components.isImpossible || components.variants.length === 0) return [];
573
+ const declarations = Object.entries(rule.declarations).map(([prop, value]) => `${prop}: ${value};`).join(" ");
574
+ const getRootPrefixKey = (variant) => {
575
+ return variant.rootConditions.map((r) => r.negated ? `!${r.selector}` : r.selector).sort().join("|");
576
+ };
577
+ const byAtRules = /* @__PURE__ */ new Map();
578
+ for (const variant of components.variants) {
579
+ const atRules = buildAtRulesFromVariant(variant);
580
+ const key = atRules.sort().join("|||") + "###" + getRootPrefixKey(variant);
581
+ const group = byAtRules.get(key);
582
+ if (group) group.variants.push(variant);
583
+ else byAtRules.set(key, {
584
+ variants: [variant],
585
+ atRules,
586
+ rootPrefix: rootConditionsToCSS(variant.rootConditions)
587
+ });
588
+ }
589
+ const rules = [];
590
+ for (const [, group] of byAtRules) {
591
+ const selectorFragments = group.variants.map((v) => buildSelectorFromVariant(v, rule.selectorSuffix));
592
+ const cssRule = {
593
+ selector: selectorFragments.length === 1 ? selectorFragments[0] : selectorFragments,
594
+ declarations
595
+ };
596
+ if (group.atRules.length > 0) cssRule.atRules = group.atRules;
597
+ if (group.rootPrefix) cssRule.rootPrefix = group.rootPrefix;
598
+ rules.push(cssRule);
599
+ }
600
+ return rules;
601
+ }
602
+ function renderStyles(styles, classNameOrSelector, options) {
603
+ const directSelector = !!classNameOrSelector;
604
+ if (!styles) return directSelector ? [] : { rules: [] };
605
+ const cacheKey = stringifyStyles(styles);
606
+ let rules = pipelineCache.get(cacheKey);
607
+ if (!rules) {
608
+ rules = runPipeline(styles, createStateParserContext(styles));
609
+ pipelineCache.set(cacheKey, rules);
610
+ }
611
+ if (directSelector) {
612
+ const shouldDouble = options?.doubleSelector ?? false;
613
+ return rules.map((rule) => {
614
+ const result = {
615
+ selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).map((part) => {
616
+ let sel = part ? `${classNameOrSelector}${part}` : classNameOrSelector;
617
+ if (shouldDouble && sel.startsWith(".")) {
618
+ const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
619
+ if (classMatch) sel = classMatch[0] + sel;
620
+ }
621
+ if (rule.rootPrefix) sel = `${rule.rootPrefix} ${sel}`;
622
+ return sel;
623
+ }).join(", "),
624
+ declarations: rule.declarations
625
+ };
626
+ if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
627
+ return result;
628
+ });
629
+ }
630
+ return { rules: rules.map((r) => ({
631
+ selector: Array.isArray(r.selector) ? r.selector.join("|||") : r.selector,
632
+ declarations: r.declarations,
633
+ atRules: r.atRules,
634
+ needsClassName: true,
635
+ rootPrefix: r.rootPrefix
636
+ })) };
637
+ }
638
+
639
+ //#endregion
640
+ export { clearPipelineCache, isSelector, renderStyles };
641
+ //# sourceMappingURL=index.js.map