@tenphi/tasty 0.0.0-snapshot.2f99c73

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 (242) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +261 -0
  3. package/dist/_virtual/_rolldown/runtime.js +8 -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/definitions.d.ts +37 -0
  8. package/dist/chunks/definitions.js +260 -0
  9. package/dist/chunks/definitions.js.map +1 -0
  10. package/dist/chunks/index.d.ts +3 -0
  11. package/dist/chunks/renderChunk.d.ts +2 -0
  12. package/dist/chunks/renderChunk.js +61 -0
  13. package/dist/chunks/renderChunk.js.map +1 -0
  14. package/dist/config.d.ts +279 -0
  15. package/dist/config.js +400 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/debug.d.ts +204 -0
  18. package/dist/debug.js +733 -0
  19. package/dist/debug.js.map +1 -0
  20. package/dist/hooks/index.d.ts +5 -0
  21. package/dist/hooks/useGlobalStyles.d.ts +27 -0
  22. package/dist/hooks/useGlobalStyles.js +56 -0
  23. package/dist/hooks/useGlobalStyles.js.map +1 -0
  24. package/dist/hooks/useKeyframes.d.ts +56 -0
  25. package/dist/hooks/useKeyframes.js +54 -0
  26. package/dist/hooks/useKeyframes.js.map +1 -0
  27. package/dist/hooks/useProperty.d.ts +79 -0
  28. package/dist/hooks/useProperty.js +91 -0
  29. package/dist/hooks/useProperty.js.map +1 -0
  30. package/dist/hooks/useRawCSS.d.ts +53 -0
  31. package/dist/hooks/useRawCSS.js +28 -0
  32. package/dist/hooks/useRawCSS.js.map +1 -0
  33. package/dist/hooks/useStyles.d.ts +40 -0
  34. package/dist/hooks/useStyles.js +169 -0
  35. package/dist/hooks/useStyles.js.map +1 -0
  36. package/dist/index.d.ts +38 -0
  37. package/dist/index.js +30 -0
  38. package/dist/injector/index.d.ts +157 -0
  39. package/dist/injector/index.js +154 -0
  40. package/dist/injector/index.js.map +1 -0
  41. package/dist/injector/injector.d.ts +139 -0
  42. package/dist/injector/injector.js +404 -0
  43. package/dist/injector/injector.js.map +1 -0
  44. package/dist/injector/sheet-manager.d.ts +127 -0
  45. package/dist/injector/sheet-manager.js +714 -0
  46. package/dist/injector/sheet-manager.js.map +1 -0
  47. package/dist/injector/types.d.ts +135 -0
  48. package/dist/keyframes/index.js +206 -0
  49. package/dist/keyframes/index.js.map +1 -0
  50. package/dist/parser/classify.js +319 -0
  51. package/dist/parser/classify.js.map +1 -0
  52. package/dist/parser/const.js +33 -0
  53. package/dist/parser/const.js.map +1 -0
  54. package/dist/parser/index.d.ts +3 -0
  55. package/dist/parser/index.js +4 -0
  56. package/dist/parser/lru.js +109 -0
  57. package/dist/parser/lru.js.map +1 -0
  58. package/dist/parser/parser.d.ts +25 -0
  59. package/dist/parser/parser.js +116 -0
  60. package/dist/parser/parser.js.map +1 -0
  61. package/dist/parser/tokenizer.js +69 -0
  62. package/dist/parser/tokenizer.js.map +1 -0
  63. package/dist/parser/types.d.ts +51 -0
  64. package/dist/parser/types.js +46 -0
  65. package/dist/parser/types.js.map +1 -0
  66. package/dist/pipeline/conditions.js +398 -0
  67. package/dist/pipeline/conditions.js.map +1 -0
  68. package/dist/pipeline/exclusive.d.ts +1 -0
  69. package/dist/pipeline/exclusive.js +231 -0
  70. package/dist/pipeline/exclusive.js.map +1 -0
  71. package/dist/pipeline/index.d.ts +53 -0
  72. package/dist/pipeline/index.js +642 -0
  73. package/dist/pipeline/index.js.map +1 -0
  74. package/dist/pipeline/materialize.js +894 -0
  75. package/dist/pipeline/materialize.js.map +1 -0
  76. package/dist/pipeline/parseStateKey.d.ts +1 -0
  77. package/dist/pipeline/parseStateKey.js +439 -0
  78. package/dist/pipeline/parseStateKey.js.map +1 -0
  79. package/dist/pipeline/simplify.js +557 -0
  80. package/dist/pipeline/simplify.js.map +1 -0
  81. package/dist/plugins/index.d.ts +2 -0
  82. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  83. package/dist/plugins/okhsl-plugin.js +371 -0
  84. package/dist/plugins/okhsl-plugin.js.map +1 -0
  85. package/dist/plugins/types.d.ts +69 -0
  86. package/dist/properties/index.js +158 -0
  87. package/dist/properties/index.js.map +1 -0
  88. package/dist/states/index.d.ts +45 -0
  89. package/dist/states/index.js +416 -0
  90. package/dist/states/index.js.map +1 -0
  91. package/dist/static/index.d.ts +5 -0
  92. package/dist/static/index.js +5 -0
  93. package/dist/static/tastyStatic.d.ts +46 -0
  94. package/dist/static/tastyStatic.js +31 -0
  95. package/dist/static/tastyStatic.js.map +1 -0
  96. package/dist/static/types.d.ts +49 -0
  97. package/dist/static/types.js +24 -0
  98. package/dist/static/types.js.map +1 -0
  99. package/dist/styles/align.d.ts +15 -0
  100. package/dist/styles/align.js +14 -0
  101. package/dist/styles/align.js.map +1 -0
  102. package/dist/styles/border.d.ts +25 -0
  103. package/dist/styles/border.js +114 -0
  104. package/dist/styles/border.js.map +1 -0
  105. package/dist/styles/color.d.ts +14 -0
  106. package/dist/styles/color.js +23 -0
  107. package/dist/styles/color.js.map +1 -0
  108. package/dist/styles/createStyle.js +77 -0
  109. package/dist/styles/createStyle.js.map +1 -0
  110. package/dist/styles/dimension.js +97 -0
  111. package/dist/styles/dimension.js.map +1 -0
  112. package/dist/styles/display.d.ts +37 -0
  113. package/dist/styles/display.js +67 -0
  114. package/dist/styles/display.js.map +1 -0
  115. package/dist/styles/fade.d.ts +15 -0
  116. package/dist/styles/fade.js +58 -0
  117. package/dist/styles/fade.js.map +1 -0
  118. package/dist/styles/fill.d.ts +44 -0
  119. package/dist/styles/fill.js +51 -0
  120. package/dist/styles/fill.js.map +1 -0
  121. package/dist/styles/flow.d.ts +16 -0
  122. package/dist/styles/flow.js +12 -0
  123. package/dist/styles/flow.js.map +1 -0
  124. package/dist/styles/gap.d.ts +31 -0
  125. package/dist/styles/gap.js +37 -0
  126. package/dist/styles/gap.js.map +1 -0
  127. package/dist/styles/height.d.ts +17 -0
  128. package/dist/styles/height.js +20 -0
  129. package/dist/styles/height.js.map +1 -0
  130. package/dist/styles/index.d.ts +2 -0
  131. package/dist/styles/index.js +9 -0
  132. package/dist/styles/index.js.map +1 -0
  133. package/dist/styles/inset.d.ts +50 -0
  134. package/dist/styles/inset.js +142 -0
  135. package/dist/styles/inset.js.map +1 -0
  136. package/dist/styles/justify.d.ts +15 -0
  137. package/dist/styles/justify.js +14 -0
  138. package/dist/styles/justify.js.map +1 -0
  139. package/dist/styles/list.d.ts +16 -0
  140. package/dist/styles/list.js +98 -0
  141. package/dist/styles/list.js.map +1 -0
  142. package/dist/styles/margin.d.ts +28 -0
  143. package/dist/styles/margin.js +96 -0
  144. package/dist/styles/margin.js.map +1 -0
  145. package/dist/styles/outline.d.ts +29 -0
  146. package/dist/styles/outline.js +65 -0
  147. package/dist/styles/outline.js.map +1 -0
  148. package/dist/styles/padding.d.ts +28 -0
  149. package/dist/styles/padding.js +96 -0
  150. package/dist/styles/padding.js.map +1 -0
  151. package/dist/styles/predefined.d.ts +74 -0
  152. package/dist/styles/predefined.js +241 -0
  153. package/dist/styles/predefined.js.map +1 -0
  154. package/dist/styles/preset.d.ts +47 -0
  155. package/dist/styles/preset.js +126 -0
  156. package/dist/styles/preset.js.map +1 -0
  157. package/dist/styles/radius.d.ts +14 -0
  158. package/dist/styles/radius.js +51 -0
  159. package/dist/styles/radius.js.map +1 -0
  160. package/dist/styles/scrollbar.d.ts +21 -0
  161. package/dist/styles/scrollbar.js +105 -0
  162. package/dist/styles/scrollbar.js.map +1 -0
  163. package/dist/styles/shadow.d.ts +14 -0
  164. package/dist/styles/shadow.js +24 -0
  165. package/dist/styles/shadow.js.map +1 -0
  166. package/dist/styles/styledScrollbar.d.ts +47 -0
  167. package/dist/styles/styledScrollbar.js +38 -0
  168. package/dist/styles/styledScrollbar.js.map +1 -0
  169. package/dist/styles/transition.d.ts +14 -0
  170. package/dist/styles/transition.js +138 -0
  171. package/dist/styles/transition.js.map +1 -0
  172. package/dist/styles/types.d.ts +496 -0
  173. package/dist/styles/width.d.ts +17 -0
  174. package/dist/styles/width.js +20 -0
  175. package/dist/styles/width.js.map +1 -0
  176. package/dist/tasty.d.ts +983 -0
  177. package/dist/tasty.js +191 -0
  178. package/dist/tasty.js.map +1 -0
  179. package/dist/tokens/typography.d.ts +19 -0
  180. package/dist/tokens/typography.js +237 -0
  181. package/dist/tokens/typography.js.map +1 -0
  182. package/dist/types.d.ts +182 -0
  183. package/dist/utils/cache-wrapper.js +26 -0
  184. package/dist/utils/cache-wrapper.js.map +1 -0
  185. package/dist/utils/case-converter.js +8 -0
  186. package/dist/utils/case-converter.js.map +1 -0
  187. package/dist/utils/colors.d.ts +5 -0
  188. package/dist/utils/colors.js +9 -0
  189. package/dist/utils/colors.js.map +1 -0
  190. package/dist/utils/dotize.d.ts +26 -0
  191. package/dist/utils/dotize.js +122 -0
  192. package/dist/utils/dotize.js.map +1 -0
  193. package/dist/utils/filter-base-props.d.ts +15 -0
  194. package/dist/utils/filter-base-props.js +45 -0
  195. package/dist/utils/filter-base-props.js.map +1 -0
  196. package/dist/utils/get-display-name.d.ts +7 -0
  197. package/dist/utils/get-display-name.js +10 -0
  198. package/dist/utils/get-display-name.js.map +1 -0
  199. package/dist/utils/hsl-to-rgb.js +38 -0
  200. package/dist/utils/hsl-to-rgb.js.map +1 -0
  201. package/dist/utils/is-dev-env.js +19 -0
  202. package/dist/utils/is-dev-env.js.map +1 -0
  203. package/dist/utils/merge-styles.d.ts +7 -0
  204. package/dist/utils/merge-styles.js +146 -0
  205. package/dist/utils/merge-styles.js.map +1 -0
  206. package/dist/utils/mod-attrs.d.ts +8 -0
  207. package/dist/utils/mod-attrs.js +21 -0
  208. package/dist/utils/mod-attrs.js.map +1 -0
  209. package/dist/utils/okhsl-to-rgb.js +296 -0
  210. package/dist/utils/okhsl-to-rgb.js.map +1 -0
  211. package/dist/utils/process-tokens.d.ts +31 -0
  212. package/dist/utils/process-tokens.js +171 -0
  213. package/dist/utils/process-tokens.js.map +1 -0
  214. package/dist/utils/resolve-recipes.d.ts +17 -0
  215. package/dist/utils/resolve-recipes.js +143 -0
  216. package/dist/utils/resolve-recipes.js.map +1 -0
  217. package/dist/utils/string.js +8 -0
  218. package/dist/utils/string.js.map +1 -0
  219. package/dist/utils/styles.d.ts +183 -0
  220. package/dist/utils/styles.js +585 -0
  221. package/dist/utils/styles.js.map +1 -0
  222. package/dist/utils/typography.d.ts +36 -0
  223. package/dist/utils/typography.js +53 -0
  224. package/dist/utils/typography.js.map +1 -0
  225. package/dist/utils/warnings.d.ts +16 -0
  226. package/dist/utils/warnings.js +16 -0
  227. package/dist/utils/warnings.js.map +1 -0
  228. package/dist/zero/babel.d.ts +108 -0
  229. package/dist/zero/babel.js +282 -0
  230. package/dist/zero/babel.js.map +1 -0
  231. package/dist/zero/css-writer.d.ts +45 -0
  232. package/dist/zero/css-writer.js +74 -0
  233. package/dist/zero/css-writer.js.map +1 -0
  234. package/dist/zero/extractor.d.ts +25 -0
  235. package/dist/zero/extractor.js +150 -0
  236. package/dist/zero/extractor.js.map +1 -0
  237. package/dist/zero/index.d.ts +3 -0
  238. package/dist/zero/index.js +4 -0
  239. package/dist/zero/next.d.ts +60 -0
  240. package/dist/zero/next.js +78 -0
  241. package/dist/zero/next.js.map +1 -0
  242. package/package.json +133 -0
@@ -0,0 +1,894 @@
1
+ import { Lru } from "../parser/lru.js";
2
+
3
+ //#region src/pipeline/materialize.ts
4
+ /**
5
+ * CSS Materialization
6
+ *
7
+ * Converts condition trees into CSS selectors and at-rules.
8
+ * This is the final stage that produces actual CSS output.
9
+ */
10
+ const conditionCache = new Lru(3e3);
11
+ /**
12
+ * Convert a condition tree to CSS components
13
+ */
14
+ function conditionToCSS(node) {
15
+ const key = getConditionKey(node);
16
+ const cached = conditionCache.get(key);
17
+ if (cached) return cached;
18
+ const result = conditionToCSSInner(node);
19
+ conditionCache.set(key, result);
20
+ return result;
21
+ }
22
+ /**
23
+ * Create an empty selector variant
24
+ */
25
+ function emptyVariant() {
26
+ return {
27
+ modifierConditions: [],
28
+ pseudoConditions: [],
29
+ ownConditions: [],
30
+ mediaConditions: [],
31
+ containerConditions: [],
32
+ supportsConditions: [],
33
+ rootConditions: [],
34
+ parentConditions: [],
35
+ startingStyle: false
36
+ };
37
+ }
38
+ function conditionToCSSInner(node) {
39
+ if (node.kind === "true") return {
40
+ variants: [emptyVariant()],
41
+ isImpossible: false
42
+ };
43
+ if (node.kind === "false") return {
44
+ variants: [],
45
+ isImpossible: true
46
+ };
47
+ if (node.kind === "state") return stateToCSS(node);
48
+ if (node.kind === "compound") if (node.operator === "AND") return andToCSS(node.children);
49
+ else return orToCSS(node.children);
50
+ return {
51
+ variants: [emptyVariant()],
52
+ isImpossible: false
53
+ };
54
+ }
55
+ /**
56
+ * Convert a state condition to CSS
57
+ */
58
+ function stateToCSS(state) {
59
+ switch (state.type) {
60
+ case "media": return {
61
+ variants: mediaToParsed(state).map((mediaCond) => {
62
+ const v = emptyVariant();
63
+ v.mediaConditions.push(mediaCond);
64
+ return v;
65
+ }),
66
+ isImpossible: false
67
+ };
68
+ default: {
69
+ const variant = emptyVariant();
70
+ switch (state.type) {
71
+ case "modifier":
72
+ variant.modifierConditions.push(modifierToParsed(state));
73
+ break;
74
+ case "pseudo":
75
+ variant.pseudoConditions.push(pseudoToParsed(state));
76
+ break;
77
+ case "container":
78
+ variant.containerConditions.push(containerToParsed(state));
79
+ break;
80
+ case "supports":
81
+ variant.supportsConditions.push(supportsToParsed(state));
82
+ break;
83
+ case "root":
84
+ variant.rootConditions.push(rootToParsed(state));
85
+ break;
86
+ case "parent":
87
+ variant.parentConditions.push(parentToParsed(state));
88
+ break;
89
+ case "own":
90
+ variant.ownConditions.push(...ownToParsed(state));
91
+ break;
92
+ case "starting":
93
+ variant.startingStyle = !state.negated;
94
+ break;
95
+ }
96
+ return {
97
+ variants: [variant],
98
+ isImpossible: false
99
+ };
100
+ }
101
+ }
102
+ }
103
+ /**
104
+ * Convert modifier condition to parsed structure
105
+ */
106
+ function modifierToParsed(state) {
107
+ return {
108
+ attribute: state.attribute,
109
+ value: state.value,
110
+ operator: state.operator,
111
+ negated: state.negated ?? false
112
+ };
113
+ }
114
+ /**
115
+ * Convert parsed modifier to CSS selector string (for final output)
116
+ */
117
+ function modifierToCSS(mod) {
118
+ let selector;
119
+ if (mod.value !== void 0) {
120
+ const op = mod.operator || "=";
121
+ selector = `[${mod.attribute}${op}"${mod.value}"]`;
122
+ } else selector = `[${mod.attribute}]`;
123
+ if (mod.negated) return `:not(${selector})`;
124
+ return selector;
125
+ }
126
+ /**
127
+ * Convert pseudo condition to parsed structure
128
+ */
129
+ function pseudoToParsed(state) {
130
+ return {
131
+ pseudo: state.pseudo,
132
+ negated: state.negated ?? false
133
+ };
134
+ }
135
+ /**
136
+ * Convert parsed pseudo to CSS selector string (for final output)
137
+ */
138
+ function pseudoToCSS(pseudo) {
139
+ if (pseudo.negated) {
140
+ if (pseudo.pseudo.startsWith(":not(")) return pseudo.pseudo.slice(5, -1);
141
+ return `:not(${pseudo.pseudo})`;
142
+ }
143
+ return pseudo.pseudo;
144
+ }
145
+ /**
146
+ * Convert media condition to parsed structure(s)
147
+ * Returns an array because negated ranges produce OR branches (two separate conditions)
148
+ */
149
+ function mediaToParsed(state) {
150
+ if (state.subtype === "type") {
151
+ const mediaType = state.mediaType || "all";
152
+ return [{
153
+ subtype: "type",
154
+ negated: state.negated ?? false,
155
+ condition: mediaType,
156
+ mediaType: state.mediaType
157
+ }];
158
+ } else if (state.subtype === "feature") {
159
+ let condition;
160
+ if (state.featureValue) condition = `(${state.feature}: ${state.featureValue})`;
161
+ else condition = `(${state.feature})`;
162
+ return [{
163
+ subtype: "feature",
164
+ negated: state.negated ?? false,
165
+ condition,
166
+ feature: state.feature,
167
+ featureValue: state.featureValue
168
+ }];
169
+ } else return dimensionToMediaParsed(state.dimension || "width", state.lowerBound, state.upperBound, state.negated ?? false);
170
+ }
171
+ /**
172
+ * Convert dimension bounds to parsed media condition(s)
173
+ * Uses CSS Media Queries Level 4 `not (condition)` syntax for negation.
174
+ */
175
+ function dimensionToMediaParsed(dimension, lowerBound, upperBound, negated) {
176
+ let condition;
177
+ if (lowerBound && upperBound) {
178
+ const lowerOp = lowerBound.inclusive ? "<=" : "<";
179
+ const upperOp = upperBound.inclusive ? "<=" : "<";
180
+ condition = `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;
181
+ } else if (upperBound) condition = `(${dimension} ${upperBound.inclusive ? "<=" : "<"} ${upperBound.value})`;
182
+ else if (lowerBound) condition = `(${dimension} ${lowerBound.inclusive ? ">=" : ">"} ${lowerBound.value})`;
183
+ else condition = `(${dimension})`;
184
+ return [{
185
+ subtype: "dimension",
186
+ negated: negated ?? false,
187
+ condition,
188
+ dimension,
189
+ lowerBound,
190
+ upperBound
191
+ }];
192
+ }
193
+ /**
194
+ * Convert container condition to parsed structure
195
+ * This enables structured analysis for contradiction detection and condition combining
196
+ */
197
+ function containerToParsed(state) {
198
+ let condition;
199
+ if (state.subtype === "style") if (state.propertyValue) condition = `style(--${state.property}: ${state.propertyValue})`;
200
+ else condition = `style(--${state.property})`;
201
+ else if (state.subtype === "raw") condition = state.rawCondition;
202
+ else condition = dimensionToContainerCondition(state.dimension || "width", state.lowerBound, state.upperBound);
203
+ return {
204
+ name: state.containerName,
205
+ condition,
206
+ negated: state.negated ?? false,
207
+ subtype: state.subtype,
208
+ property: state.property,
209
+ propertyValue: state.propertyValue
210
+ };
211
+ }
212
+ /**
213
+ * Convert dimension bounds to container query condition (single string)
214
+ * Container queries support "not (condition)", so no need to invert manually
215
+ */
216
+ function dimensionToContainerCondition(dimension, lowerBound, upperBound) {
217
+ if (lowerBound && upperBound) {
218
+ const lowerOp = lowerBound.inclusive ? "<=" : "<";
219
+ const upperOp = upperBound.inclusive ? "<=" : "<";
220
+ return `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;
221
+ } else if (upperBound) return `(${dimension} ${upperBound.inclusive ? "<=" : "<"} ${upperBound.value})`;
222
+ else if (lowerBound) return `(${dimension} ${lowerBound.inclusive ? ">=" : ">"} ${lowerBound.value})`;
223
+ return "(width)";
224
+ }
225
+ /**
226
+ * Convert supports condition to parsed structure
227
+ */
228
+ function supportsToParsed(state) {
229
+ return {
230
+ subtype: state.subtype,
231
+ condition: state.condition,
232
+ negated: state.negated ?? false
233
+ };
234
+ }
235
+ /**
236
+ * Convert root condition to parsed structure
237
+ */
238
+ function rootToParsed(state) {
239
+ return {
240
+ selector: state.selector,
241
+ negated: state.negated ?? false
242
+ };
243
+ }
244
+ /**
245
+ * Convert parsed root conditions to CSS selector prefix (for final output)
246
+ */
247
+ function rootConditionsToCSS(roots) {
248
+ if (roots.length === 0) return void 0;
249
+ let prefix = ":root";
250
+ for (const root of roots) if (root.negated) prefix += `:not(${root.selector})`;
251
+ else prefix += root.selector;
252
+ return prefix;
253
+ }
254
+ /**
255
+ * Convert parent condition to parsed structure
256
+ */
257
+ function parentToParsed(state) {
258
+ return {
259
+ selector: state.selector,
260
+ direct: state.direct,
261
+ negated: state.negated ?? false
262
+ };
263
+ }
264
+ /**
265
+ * Convert parsed parent condition to CSS selector fragment (for final output)
266
+ *
267
+ * Positive: :is([selector] *) or :is([selector] > *)
268
+ * Negative: :not([selector] *) or :not([selector] > *)
269
+ */
270
+ function parentToCSS(parent) {
271
+ const combinator = parent.direct ? " > *" : " *";
272
+ if (parent.negated) return `:not(${parent.selector}${combinator})`;
273
+ return `:is(${parent.selector}${combinator})`;
274
+ }
275
+ /**
276
+ * Convert own condition to parsed structures for sub-element
277
+ */
278
+ function ownToParsed(state) {
279
+ const innerCSS = conditionToCSS(state.innerCondition);
280
+ if (innerCSS.isImpossible || innerCSS.variants.length === 0) return [];
281
+ const allConditions = [];
282
+ for (const variant of innerCSS.variants) {
283
+ for (const mod of variant.modifierConditions) allConditions.push({
284
+ ...mod,
285
+ negated: state.negated ? !mod.negated : mod.negated
286
+ });
287
+ for (const pseudo of variant.pseudoConditions) allConditions.push({
288
+ ...pseudo,
289
+ negated: state.negated ? !pseudo.negated : pseudo.negated
290
+ });
291
+ }
292
+ return allConditions;
293
+ }
294
+ /**
295
+ * Get unique key for a modifier condition
296
+ */
297
+ function getModifierKey(mod) {
298
+ const base = mod.value ? `${mod.attribute}${mod.operator || "="}${mod.value}` : mod.attribute;
299
+ return mod.negated ? `!${base}` : base;
300
+ }
301
+ /**
302
+ * Get unique key for a pseudo condition
303
+ */
304
+ function getPseudoKey(pseudo) {
305
+ return pseudo.negated ? `!${pseudo.pseudo}` : pseudo.pseudo;
306
+ }
307
+ /**
308
+ * Get unique key for a root condition
309
+ */
310
+ function getRootKey(root) {
311
+ return root.negated ? `!${root.selector}` : root.selector;
312
+ }
313
+ /**
314
+ * Deduplicate modifier conditions
315
+ */
316
+ function dedupeModifierConditions(conditions) {
317
+ const seen = /* @__PURE__ */ new Set();
318
+ const result = [];
319
+ for (const c of conditions) {
320
+ const key = getModifierKey(c);
321
+ if (!seen.has(key)) {
322
+ seen.add(key);
323
+ result.push(c);
324
+ }
325
+ }
326
+ return result;
327
+ }
328
+ /**
329
+ * Deduplicate pseudo conditions
330
+ */
331
+ function dedupePseudoConditions(conditions) {
332
+ const seen = /* @__PURE__ */ new Set();
333
+ const result = [];
334
+ for (const c of conditions) {
335
+ const key = getPseudoKey(c);
336
+ if (!seen.has(key)) {
337
+ seen.add(key);
338
+ result.push(c);
339
+ }
340
+ }
341
+ return result;
342
+ }
343
+ /**
344
+ * Deduplicate root conditions
345
+ */
346
+ function dedupeRootConditions(conditions) {
347
+ const seen = /* @__PURE__ */ new Set();
348
+ const result = [];
349
+ for (const c of conditions) {
350
+ const key = getRootKey(c);
351
+ if (!seen.has(key)) {
352
+ seen.add(key);
353
+ result.push(c);
354
+ }
355
+ }
356
+ return result;
357
+ }
358
+ /**
359
+ * Get unique key for a parent condition
360
+ */
361
+ function getParentKey(parent) {
362
+ const base = `${parent.direct ? ">" : ""}${parent.selector}`;
363
+ return parent.negated ? `!${base}` : base;
364
+ }
365
+ /**
366
+ * Deduplicate parent conditions
367
+ */
368
+ function dedupeParentConditions(conditions) {
369
+ const seen = /* @__PURE__ */ new Set();
370
+ const result = [];
371
+ for (const c of conditions) {
372
+ const key = getParentKey(c);
373
+ if (!seen.has(key)) {
374
+ seen.add(key);
375
+ result.push(c);
376
+ }
377
+ }
378
+ return result;
379
+ }
380
+ /**
381
+ * Deduplicate own conditions (modifiers or pseudos)
382
+ */
383
+ function dedupeOwnConditions(conditions) {
384
+ const seen = /* @__PURE__ */ new Set();
385
+ const result = [];
386
+ for (const c of conditions) {
387
+ const key = "attribute" in c ? `mod:${getModifierKey(c)}` : `pseudo:${getPseudoKey(c)}`;
388
+ if (!seen.has(key)) {
389
+ seen.add(key);
390
+ result.push(c);
391
+ }
392
+ }
393
+ return result;
394
+ }
395
+ /**
396
+ * Check for modifier contradiction: same attribute with opposite negation
397
+ */
398
+ function hasModifierContradiction(conditions) {
399
+ const byKey = /* @__PURE__ */ new Map();
400
+ for (const mod of conditions) {
401
+ const baseKey = mod.value ? `${mod.attribute}${mod.operator || "="}${mod.value}` : mod.attribute;
402
+ const existing = byKey.get(baseKey);
403
+ if (existing !== void 0 && existing !== !mod.negated) return true;
404
+ byKey.set(baseKey, !mod.negated);
405
+ }
406
+ return false;
407
+ }
408
+ /**
409
+ * Check for pseudo contradiction: same pseudo with opposite negation
410
+ */
411
+ function hasPseudoContradiction(conditions) {
412
+ const byKey = /* @__PURE__ */ new Map();
413
+ for (const pseudo of conditions) {
414
+ const existing = byKey.get(pseudo.pseudo);
415
+ if (existing !== void 0 && existing !== !pseudo.negated) return true;
416
+ byKey.set(pseudo.pseudo, !pseudo.negated);
417
+ }
418
+ return false;
419
+ }
420
+ /**
421
+ * Check for root condition contradiction: same selector with opposite negation
422
+ */
423
+ function hasRootContradiction(conditions) {
424
+ const byKey = /* @__PURE__ */ new Map();
425
+ for (const root of conditions) {
426
+ const existing = byKey.get(root.selector);
427
+ if (existing !== void 0 && existing !== !root.negated) return true;
428
+ byKey.set(root.selector, !root.negated);
429
+ }
430
+ return false;
431
+ }
432
+ /**
433
+ * Check for parent condition contradiction: same selector+direct with opposite negation
434
+ */
435
+ function hasParentContradiction(conditions) {
436
+ const byKey = /* @__PURE__ */ new Map();
437
+ for (const parent of conditions) {
438
+ const baseKey = `${parent.direct ? ">" : ""}${parent.selector}`;
439
+ const existing = byKey.get(baseKey);
440
+ if (existing !== void 0 && existing !== !parent.negated) return true;
441
+ byKey.set(baseKey, !parent.negated);
442
+ }
443
+ return false;
444
+ }
445
+ /**
446
+ * Check for own condition contradiction
447
+ */
448
+ function hasOwnConditionContradiction(conditions) {
449
+ const modifiers = [];
450
+ const pseudos = [];
451
+ for (const c of conditions) if ("attribute" in c) modifiers.push(c);
452
+ else pseudos.push(c);
453
+ return hasModifierContradiction(modifiers) || hasPseudoContradiction(pseudos);
454
+ }
455
+ /**
456
+ * Merge two selector variants (AND operation)
457
+ * Deduplicates conditions and checks for contradictions
458
+ */
459
+ function mergeVariants(a, b) {
460
+ const mergedMedia = dedupeMediaConditions([...a.mediaConditions, ...b.mediaConditions]);
461
+ if (hasMediaContradiction(mergedMedia)) return null;
462
+ const mergedRoots = dedupeRootConditions([...a.rootConditions, ...b.rootConditions]);
463
+ if (hasRootContradiction(mergedRoots)) return null;
464
+ const mergedModifiers = dedupeModifierConditions([...a.modifierConditions, ...b.modifierConditions]);
465
+ if (hasModifierContradiction(mergedModifiers)) return null;
466
+ const mergedPseudos = dedupePseudoConditions([...a.pseudoConditions, ...b.pseudoConditions]);
467
+ if (hasPseudoContradiction(mergedPseudos)) return null;
468
+ const mergedParents = dedupeParentConditions([...a.parentConditions, ...b.parentConditions]);
469
+ if (hasParentContradiction(mergedParents)) return null;
470
+ const mergedOwn = dedupeOwnConditions([...a.ownConditions, ...b.ownConditions]);
471
+ if (hasOwnConditionContradiction(mergedOwn)) return null;
472
+ const mergedContainers = dedupeContainerConditions([...a.containerConditions, ...b.containerConditions]);
473
+ if (hasContainerStyleContradiction(mergedContainers)) return null;
474
+ const mergedSupports = dedupeSupportsConditions([...a.supportsConditions, ...b.supportsConditions]);
475
+ if (hasSupportsContradiction(mergedSupports)) return null;
476
+ return {
477
+ modifierConditions: mergedModifiers,
478
+ pseudoConditions: mergedPseudos,
479
+ ownConditions: mergedOwn,
480
+ mediaConditions: mergedMedia,
481
+ containerConditions: mergedContainers,
482
+ supportsConditions: mergedSupports,
483
+ rootConditions: mergedRoots,
484
+ parentConditions: mergedParents,
485
+ startingStyle: a.startingStyle || b.startingStyle
486
+ };
487
+ }
488
+ /**
489
+ * Deduplicate media conditions by their key (subtype + condition + negated)
490
+ */
491
+ function dedupeMediaConditions(conditions) {
492
+ const seen = /* @__PURE__ */ new Set();
493
+ const result = [];
494
+ for (const c of conditions) {
495
+ const key = `${c.subtype}|${c.condition}|${c.negated}`;
496
+ if (!seen.has(key)) {
497
+ seen.add(key);
498
+ result.push(c);
499
+ }
500
+ }
501
+ return result;
502
+ }
503
+ /**
504
+ * Deduplicate container conditions by their key (name + condition + negated)
505
+ */
506
+ function dedupeContainerConditions(conditions) {
507
+ const seen = /* @__PURE__ */ new Set();
508
+ const result = [];
509
+ for (const c of conditions) {
510
+ const key = `${c.name ?? ""}|${c.condition}|${c.negated}`;
511
+ if (!seen.has(key)) {
512
+ seen.add(key);
513
+ result.push(c);
514
+ }
515
+ }
516
+ return result;
517
+ }
518
+ /**
519
+ * Deduplicate supports conditions by their key (subtype + condition + negated)
520
+ */
521
+ function dedupeSupportsConditions(conditions) {
522
+ const seen = /* @__PURE__ */ new Set();
523
+ const result = [];
524
+ for (const c of conditions) {
525
+ const key = `${c.subtype}|${c.condition}|${c.negated}`;
526
+ if (!seen.has(key)) {
527
+ seen.add(key);
528
+ result.push(c);
529
+ }
530
+ }
531
+ return result;
532
+ }
533
+ /**
534
+ * Check if supports conditions contain contradictions
535
+ * e.g., @supports(display: grid) AND NOT @supports(display: grid)
536
+ */
537
+ function hasSupportsContradiction(conditions) {
538
+ const conditionMap = /* @__PURE__ */ new Map();
539
+ for (const cond of conditions) {
540
+ const key = `${cond.subtype}|${cond.condition}`;
541
+ const existing = conditionMap.get(key);
542
+ if (existing !== void 0 && existing !== !cond.negated) return true;
543
+ conditionMap.set(key, !cond.negated);
544
+ }
545
+ return false;
546
+ }
547
+ /**
548
+ * Check if a set of media conditions contains contradictions
549
+ * e.g., (prefers-color-scheme: light) AND NOT (prefers-color-scheme: light)
550
+ * or (width >= 900px) AND (width < 600px)
551
+ *
552
+ * Uses parsed media conditions for efficient analysis without regex parsing.
553
+ */
554
+ function hasMediaContradiction(conditions) {
555
+ const featureConditions = /* @__PURE__ */ new Map();
556
+ const typeConditions = /* @__PURE__ */ new Map();
557
+ const dimensionConditions = /* @__PURE__ */ new Map();
558
+ const dimensionsByDim = /* @__PURE__ */ new Map();
559
+ for (const cond of conditions) if (cond.subtype === "type") {
560
+ const key = cond.mediaType || "all";
561
+ const existing = typeConditions.get(key);
562
+ if (existing !== void 0 && existing !== !cond.negated) return true;
563
+ typeConditions.set(key, !cond.negated);
564
+ } else if (cond.subtype === "feature") {
565
+ const key = cond.condition;
566
+ const existing = featureConditions.get(key);
567
+ if (existing !== void 0 && existing !== !cond.negated) return true;
568
+ featureConditions.set(key, !cond.negated);
569
+ } else if (cond.subtype === "dimension") {
570
+ const condKey = cond.condition;
571
+ const existing = dimensionConditions.get(condKey);
572
+ if (existing !== void 0 && existing !== !cond.negated) return true;
573
+ dimensionConditions.set(condKey, !cond.negated);
574
+ if (!cond.negated) {
575
+ const dim = cond.dimension || "width";
576
+ let bounds = dimensionsByDim.get(dim);
577
+ if (!bounds) {
578
+ bounds = {
579
+ lowerBound: null,
580
+ upperBound: null
581
+ };
582
+ dimensionsByDim.set(dim, bounds);
583
+ }
584
+ if (cond.lowerBound?.valueNumeric != null) {
585
+ const value = cond.lowerBound.valueNumeric;
586
+ if (bounds.lowerBound === null || value > bounds.lowerBound) bounds.lowerBound = value;
587
+ }
588
+ if (cond.upperBound?.valueNumeric != null) {
589
+ const value = cond.upperBound.valueNumeric;
590
+ if (bounds.upperBound === null || value < bounds.upperBound) bounds.upperBound = value;
591
+ }
592
+ if (bounds.lowerBound !== null && bounds.upperBound !== null && bounds.lowerBound >= bounds.upperBound) return true;
593
+ }
594
+ }
595
+ return false;
596
+ }
597
+ /**
598
+ * Check if container conditions contain contradictions in style queries
599
+ * e.g., style(--variant: danger) and style(--variant: success) together
600
+ * Same property with different values = always false
601
+ *
602
+ * Uses parsed container conditions for efficient analysis without regex parsing.
603
+ */
604
+ function hasContainerStyleContradiction(conditions) {
605
+ const styleQueries = /* @__PURE__ */ new Map();
606
+ for (const cond of conditions) {
607
+ if (cond.subtype !== "style" || !cond.property) continue;
608
+ const property = cond.property;
609
+ const value = cond.propertyValue;
610
+ if (!styleQueries.has(property)) styleQueries.set(property, {
611
+ hasExistence: false,
612
+ values: /* @__PURE__ */ new Set(),
613
+ hasNegatedExistence: false
614
+ });
615
+ const entry = styleQueries.get(property);
616
+ if (cond.negated) {
617
+ if (value === void 0) entry.hasNegatedExistence = true;
618
+ } else if (value === void 0) entry.hasExistence = true;
619
+ else entry.values.add(value);
620
+ }
621
+ for (const [, entry] of styleQueries) {
622
+ if (entry.hasExistence && entry.hasNegatedExistence) return true;
623
+ if (entry.values.size > 1) return true;
624
+ if (entry.hasNegatedExistence && entry.values.size > 0) return true;
625
+ }
626
+ return false;
627
+ }
628
+ /**
629
+ * Get a unique key for a variant (for deduplication)
630
+ */
631
+ function getVariantKey(v) {
632
+ const modifierKey = v.modifierConditions.map(getModifierKey).sort().join("|");
633
+ const pseudoKey = v.pseudoConditions.map(getPseudoKey).sort().join("|");
634
+ const ownKey = v.ownConditions.map((c) => "attribute" in c ? `mod:${getModifierKey(c)}` : `pseudo:${getPseudoKey(c)}`).sort().join("|");
635
+ const containerKey = v.containerConditions.map((c) => `${c.name ?? ""}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|");
636
+ return [
637
+ modifierKey,
638
+ pseudoKey,
639
+ ownKey,
640
+ v.mediaConditions.map((c) => `${c.subtype}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|"),
641
+ containerKey,
642
+ v.supportsConditions.map((c) => `${c.subtype}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|"),
643
+ v.rootConditions.map(getRootKey).sort().join("|"),
644
+ v.parentConditions.map(getParentKey).sort().join("|"),
645
+ v.startingStyle ? "1" : "0"
646
+ ].join("###");
647
+ }
648
+ /**
649
+ * Check if variant A is a superset of variant B (A is more restrictive)
650
+ *
651
+ * If A has all of B's conditions plus more, then A is redundant
652
+ * because B already covers the same cases (and more).
653
+ *
654
+ * Example:
655
+ * A: :not([size=large]):not([size=medium]):not([size=small])
656
+ * B: :not([size=large])
657
+ * A is a superset of B, so A is redundant when B exists.
658
+ */
659
+ function isVariantSuperset(a, b) {
660
+ if (a.startingStyle !== b.startingStyle) return false;
661
+ if (!isRootConditionsSuperset(a.rootConditions, b.rootConditions)) return false;
662
+ if (!isMediaConditionsSuperset(a.mediaConditions, b.mediaConditions)) return false;
663
+ if (!isContainerConditionsSuperset(a.containerConditions, b.containerConditions)) return false;
664
+ if (!isSupportsConditionsSuperset(a.supportsConditions, b.supportsConditions)) return false;
665
+ if (!isModifierConditionsSuperset(a.modifierConditions, b.modifierConditions)) return false;
666
+ if (!isPseudoConditionsSuperset(a.pseudoConditions, b.pseudoConditions)) return false;
667
+ if (!isOwnConditionsSuperset(a.ownConditions, b.ownConditions)) return false;
668
+ if (!isParentConditionsSuperset(a.parentConditions, b.parentConditions)) return false;
669
+ return a.mediaConditions.length + a.containerConditions.length + a.supportsConditions.length + a.modifierConditions.length + a.pseudoConditions.length + a.rootConditions.length + a.parentConditions.length + a.ownConditions.length > b.mediaConditions.length + b.containerConditions.length + b.supportsConditions.length + b.modifierConditions.length + b.pseudoConditions.length + b.rootConditions.length + b.parentConditions.length + b.ownConditions.length;
670
+ }
671
+ /**
672
+ * Check if media conditions A is a superset of B
673
+ */
674
+ function isMediaConditionsSuperset(a, b) {
675
+ const aKeys = new Set(a.map((c) => `${c.subtype}|${c.condition}|${c.negated}`));
676
+ for (const c of b) {
677
+ const key = `${c.subtype}|${c.condition}|${c.negated}`;
678
+ if (!aKeys.has(key)) return false;
679
+ }
680
+ return true;
681
+ }
682
+ /**
683
+ * Check if container conditions A is a superset of B
684
+ */
685
+ function isContainerConditionsSuperset(a, b) {
686
+ const aKeys = new Set(a.map((c) => `${c.name ?? ""}|${c.condition}|${c.negated}`));
687
+ for (const c of b) {
688
+ const key = `${c.name ?? ""}|${c.condition}|${c.negated}`;
689
+ if (!aKeys.has(key)) return false;
690
+ }
691
+ return true;
692
+ }
693
+ /**
694
+ * Check if supports conditions A is a superset of B
695
+ */
696
+ function isSupportsConditionsSuperset(a, b) {
697
+ const aKeys = new Set(a.map((c) => `${c.subtype}|${c.condition}|${c.negated}`));
698
+ for (const c of b) {
699
+ const key = `${c.subtype}|${c.condition}|${c.negated}`;
700
+ if (!aKeys.has(key)) return false;
701
+ }
702
+ return true;
703
+ }
704
+ /**
705
+ * Check if modifier conditions A is a superset of B
706
+ */
707
+ function isModifierConditionsSuperset(a, b) {
708
+ const aKeys = new Set(a.map(getModifierKey));
709
+ for (const c of b) if (!aKeys.has(getModifierKey(c))) return false;
710
+ return true;
711
+ }
712
+ /**
713
+ * Check if pseudo conditions A is a superset of B
714
+ */
715
+ function isPseudoConditionsSuperset(a, b) {
716
+ const aKeys = new Set(a.map(getPseudoKey));
717
+ for (const c of b) if (!aKeys.has(getPseudoKey(c))) return false;
718
+ return true;
719
+ }
720
+ /**
721
+ * Check if root conditions A is a superset of B
722
+ */
723
+ function isRootConditionsSuperset(a, b) {
724
+ const aKeys = new Set(a.map(getRootKey));
725
+ for (const c of b) if (!aKeys.has(getRootKey(c))) return false;
726
+ return true;
727
+ }
728
+ /**
729
+ * Check if parent conditions A is a superset of B
730
+ */
731
+ function isParentConditionsSuperset(a, b) {
732
+ const aKeys = new Set(a.map(getParentKey));
733
+ for (const c of b) if (!aKeys.has(getParentKey(c))) return false;
734
+ return true;
735
+ }
736
+ /**
737
+ * Check if own conditions A is a superset of B
738
+ */
739
+ function isOwnConditionsSuperset(a, b) {
740
+ const aKeys = new Set(a.map((c) => "attribute" in c ? `mod:${getModifierKey(c)}` : `pseudo:${getPseudoKey(c)}`));
741
+ for (const c of b) {
742
+ const key = "attribute" in c ? `mod:${getModifierKey(c)}` : `pseudo:${getPseudoKey(c)}`;
743
+ if (!aKeys.has(key)) return false;
744
+ }
745
+ return true;
746
+ }
747
+ /**
748
+ * Deduplicate variants
749
+ *
750
+ * Removes:
751
+ * 1. Exact duplicates (same key)
752
+ * 2. Superset variants (more restrictive selectors that are redundant)
753
+ */
754
+ function dedupeVariants(variants) {
755
+ const seen = /* @__PURE__ */ new Set();
756
+ const result = [];
757
+ for (const v of variants) {
758
+ const key = getVariantKey(v);
759
+ if (!seen.has(key)) {
760
+ seen.add(key);
761
+ result.push(v);
762
+ }
763
+ }
764
+ result.sort((a, b) => {
765
+ return a.modifierConditions.length + a.pseudoConditions.length + a.ownConditions.length + a.mediaConditions.length + a.containerConditions.length + a.supportsConditions.length + a.rootConditions.length + a.parentConditions.length - (b.modifierConditions.length + b.pseudoConditions.length + b.ownConditions.length + b.mediaConditions.length + b.containerConditions.length + b.supportsConditions.length + b.rootConditions.length + b.parentConditions.length);
766
+ });
767
+ const filtered = [];
768
+ for (const candidate of result) {
769
+ let isRedundant = false;
770
+ for (const kept of filtered) if (isVariantSuperset(candidate, kept)) {
771
+ isRedundant = true;
772
+ break;
773
+ }
774
+ if (!isRedundant) filtered.push(candidate);
775
+ }
776
+ return filtered;
777
+ }
778
+ /**
779
+ * Combine AND conditions into CSS
780
+ *
781
+ * AND of conditions means cartesian product of variants:
782
+ * (A1 | A2) & (B1 | B2) = A1&B1 | A1&B2 | A2&B1 | A2&B2
783
+ *
784
+ * Variants that result in contradictions (e.g., conflicting media rules)
785
+ * are filtered out.
786
+ */
787
+ function andToCSS(children) {
788
+ let currentVariants = [emptyVariant()];
789
+ for (const child of children) {
790
+ const childCSS = conditionToCSSInner(child);
791
+ if (childCSS.isImpossible || childCSS.variants.length === 0) return {
792
+ variants: [],
793
+ isImpossible: true
794
+ };
795
+ const newVariants = [];
796
+ for (const current of currentVariants) for (const childVariant of childCSS.variants) {
797
+ const merged = mergeVariants(current, childVariant);
798
+ if (merged !== null) newVariants.push(merged);
799
+ }
800
+ if (newVariants.length === 0) return {
801
+ variants: [],
802
+ isImpossible: true
803
+ };
804
+ currentVariants = dedupeVariants(newVariants);
805
+ }
806
+ return {
807
+ variants: currentVariants,
808
+ isImpossible: false
809
+ };
810
+ }
811
+ /**
812
+ * Combine OR conditions into CSS
813
+ *
814
+ * OR in CSS means multiple selector variants (DNF).
815
+ * Each variant becomes a separate selector in the comma-separated list,
816
+ * or multiple CSS rules if they have different at-rules.
817
+ *
818
+ * Note: OR exclusivity is handled at the pipeline level (expandOrConditions),
819
+ * so here we just collect all variants. Any remaining ORs in the condition
820
+ * tree (e.g., from De Morgan expansion) are handled as simple alternatives.
821
+ */
822
+ function orToCSS(children) {
823
+ const allVariants = [];
824
+ for (const child of children) {
825
+ const childCSS = conditionToCSSInner(child);
826
+ if (childCSS.isImpossible) continue;
827
+ allVariants.push(...childCSS.variants);
828
+ }
829
+ if (allVariants.length === 0) return {
830
+ variants: [],
831
+ isImpossible: true
832
+ };
833
+ return {
834
+ variants: dedupeVariants(allVariants),
835
+ isImpossible: false
836
+ };
837
+ }
838
+ /**
839
+ * Get a cache key for a condition
840
+ */
841
+ function getConditionKey(node) {
842
+ if (node.kind === "true") return "TRUE";
843
+ if (node.kind === "false") return "FALSE";
844
+ if (node.kind === "state") return node.uniqueId;
845
+ if (node.kind === "compound") {
846
+ const childKeys = node.children.map(getConditionKey).sort();
847
+ return `${node.operator}(${childKeys.join(",")})`;
848
+ }
849
+ return "UNKNOWN";
850
+ }
851
+ /**
852
+ * Build at-rules array from a variant
853
+ */
854
+ function buildAtRulesFromVariant(variant) {
855
+ const atRules = [];
856
+ if (variant.mediaConditions.length > 0) {
857
+ const conditionParts = variant.mediaConditions.map((c) => {
858
+ if (c.subtype === "type") return c.negated ? `not ${c.condition}` : c.condition;
859
+ else return c.negated ? `(not ${c.condition})` : c.condition;
860
+ });
861
+ atRules.push(`@media ${conditionParts.join(" and ")}`);
862
+ }
863
+ if (variant.containerConditions.length > 0) {
864
+ const byName = /* @__PURE__ */ new Map();
865
+ for (const cond of variant.containerConditions) {
866
+ const group = byName.get(cond.name) || [];
867
+ group.push(cond);
868
+ byName.set(cond.name, group);
869
+ }
870
+ for (const [name, conditions] of byName) {
871
+ const conditionParts = conditions.map((c) => c.negated ? `(not ${c.condition})` : c.condition);
872
+ const namePrefix = name ? `${name} ` : "";
873
+ atRules.push(`@container ${namePrefix}${conditionParts.join(" and ")}`);
874
+ }
875
+ }
876
+ if (variant.supportsConditions.length > 0) {
877
+ const conditionParts = variant.supportsConditions.map((c) => {
878
+ if (c.subtype === "selector") {
879
+ const selectorCond = `selector(${c.condition})`;
880
+ return c.negated ? `(not ${selectorCond})` : selectorCond;
881
+ } else {
882
+ const featureCond = `(${c.condition})`;
883
+ return c.negated ? `(not ${featureCond})` : featureCond;
884
+ }
885
+ });
886
+ atRules.push(`@supports ${conditionParts.join(" and ")}`);
887
+ }
888
+ if (variant.startingStyle) atRules.push("@starting-style");
889
+ return atRules;
890
+ }
891
+
892
+ //#endregion
893
+ export { buildAtRulesFromVariant, conditionToCSS, modifierToCSS, parentToCSS, pseudoToCSS, rootConditionsToCSS };
894
+ //# sourceMappingURL=materialize.js.map