@tenphi/tasty 0.0.0-snapshot.2c5752e → 0.0.0-snapshot.2dc73be

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 (162) hide show
  1. package/README.md +149 -26
  2. package/dist/chunks/definitions.js +1 -2
  3. package/dist/chunks/definitions.js.map +1 -1
  4. package/dist/config.d.ts +8 -0
  5. package/dist/config.js +15 -1
  6. package/dist/config.js.map +1 -1
  7. package/dist/core/index.d.ts +3 -3
  8. package/dist/core/index.js +4 -4
  9. package/dist/debug.js +1 -1
  10. package/dist/debug.js.map +1 -1
  11. package/dist/hooks/useGlobalStyles.d.ts +3 -0
  12. package/dist/hooks/useGlobalStyles.js +28 -1
  13. package/dist/hooks/useGlobalStyles.js.map +1 -1
  14. package/dist/hooks/useKeyframes.js +18 -3
  15. package/dist/hooks/useKeyframes.js.map +1 -1
  16. package/dist/hooks/useProperty.js +36 -13
  17. package/dist/hooks/useProperty.js.map +1 -1
  18. package/dist/hooks/useRawCSS.js +13 -1
  19. package/dist/hooks/useRawCSS.js.map +1 -1
  20. package/dist/hooks/useStyles.d.ts +5 -0
  21. package/dist/hooks/useStyles.js +87 -8
  22. package/dist/hooks/useStyles.js.map +1 -1
  23. package/dist/index.d.ts +11 -3
  24. package/dist/index.js +4 -4
  25. package/dist/injector/index.d.ts +9 -1
  26. package/dist/injector/index.js +9 -1
  27. package/dist/injector/index.js.map +1 -1
  28. package/dist/injector/injector.d.ts +9 -0
  29. package/dist/injector/injector.js +58 -26
  30. package/dist/injector/injector.js.map +1 -1
  31. package/dist/injector/sheet-manager.d.ts +16 -7
  32. package/dist/injector/sheet-manager.js +24 -9
  33. package/dist/injector/sheet-manager.js.map +1 -1
  34. package/dist/injector/types.d.ts +9 -0
  35. package/dist/parser/classify.js.map +1 -1
  36. package/dist/pipeline/conditions.js +14 -8
  37. package/dist/pipeline/conditions.js.map +1 -1
  38. package/dist/pipeline/index.js +59 -40
  39. package/dist/pipeline/index.js.map +1 -1
  40. package/dist/pipeline/materialize.js +93 -145
  41. package/dist/pipeline/materialize.js.map +1 -1
  42. package/dist/pipeline/parseStateKey.js +35 -14
  43. package/dist/pipeline/parseStateKey.js.map +1 -1
  44. package/dist/pipeline/simplify.js +111 -152
  45. package/dist/pipeline/simplify.js.map +1 -1
  46. package/dist/pipeline/warnings.js +18 -0
  47. package/dist/pipeline/warnings.js.map +1 -0
  48. package/dist/properties/index.js +94 -16
  49. package/dist/properties/index.js.map +1 -1
  50. package/dist/properties/property-type-resolver.d.ts +24 -0
  51. package/dist/properties/property-type-resolver.js +87 -0
  52. package/dist/properties/property-type-resolver.js.map +1 -0
  53. package/dist/ssr/astro.d.ts +29 -0
  54. package/dist/ssr/astro.js +65 -0
  55. package/dist/ssr/astro.js.map +1 -0
  56. package/dist/ssr/async-storage.d.ts +17 -0
  57. package/dist/ssr/async-storage.js +35 -0
  58. package/dist/ssr/async-storage.js.map +1 -0
  59. package/dist/ssr/collect-auto-properties.js +40 -0
  60. package/dist/ssr/collect-auto-properties.js.map +1 -0
  61. package/dist/ssr/collector.d.ts +85 -0
  62. package/dist/ssr/collector.js +173 -0
  63. package/dist/ssr/collector.js.map +1 -0
  64. package/dist/ssr/context.d.ts +8 -0
  65. package/dist/ssr/context.js +14 -0
  66. package/dist/ssr/context.js.map +1 -0
  67. package/dist/ssr/format-global-rules.js +22 -0
  68. package/dist/ssr/format-global-rules.js.map +1 -0
  69. package/dist/ssr/format-keyframes.js +70 -0
  70. package/dist/ssr/format-keyframes.js.map +1 -0
  71. package/dist/ssr/format-property.js +48 -0
  72. package/dist/ssr/format-property.js.map +1 -0
  73. package/dist/ssr/format-rules.js +70 -0
  74. package/dist/ssr/format-rules.js.map +1 -0
  75. package/dist/ssr/hydrate.d.ts +22 -0
  76. package/dist/ssr/hydrate.js +50 -0
  77. package/dist/ssr/hydrate.js.map +1 -0
  78. package/dist/ssr/index.d.ts +5 -0
  79. package/dist/ssr/index.js +12 -0
  80. package/dist/ssr/index.js.map +1 -0
  81. package/dist/ssr/next.d.ts +45 -0
  82. package/dist/ssr/next.js +71 -0
  83. package/dist/ssr/next.js.map +1 -0
  84. package/dist/ssr/ssr-collector-ref.js +12 -0
  85. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  86. package/dist/styles/align.d.ts +1 -1
  87. package/dist/styles/align.js.map +1 -1
  88. package/dist/styles/border.d.ts +1 -1
  89. package/dist/styles/border.js.map +1 -1
  90. package/dist/styles/color.d.ts +2 -2
  91. package/dist/styles/color.js.map +1 -1
  92. package/dist/styles/createStyle.js +1 -1
  93. package/dist/styles/createStyle.js.map +1 -1
  94. package/dist/styles/fade.d.ts +1 -1
  95. package/dist/styles/fade.js.map +1 -1
  96. package/dist/styles/fill.d.ts +14 -16
  97. package/dist/styles/fill.js +6 -5
  98. package/dist/styles/fill.js.map +1 -1
  99. package/dist/styles/flow.d.ts +3 -3
  100. package/dist/styles/flow.js.map +1 -1
  101. package/dist/styles/inset.d.ts +3 -1
  102. package/dist/styles/inset.js +48 -40
  103. package/dist/styles/inset.js.map +1 -1
  104. package/dist/styles/justify.d.ts +1 -1
  105. package/dist/styles/justify.js.map +1 -1
  106. package/dist/styles/margin.d.ts +1 -5
  107. package/dist/styles/margin.js +48 -40
  108. package/dist/styles/margin.js.map +1 -1
  109. package/dist/styles/padding.d.ts +1 -5
  110. package/dist/styles/padding.js +48 -40
  111. package/dist/styles/padding.js.map +1 -1
  112. package/dist/styles/predefined.d.ts +0 -2
  113. package/dist/styles/predefined.js +0 -3
  114. package/dist/styles/predefined.js.map +1 -1
  115. package/dist/styles/preset.js +1 -1
  116. package/dist/styles/preset.js.map +1 -1
  117. package/dist/styles/radius.d.ts +1 -1
  118. package/dist/styles/radius.js.map +1 -1
  119. package/dist/styles/scrollbar.d.ts +9 -5
  120. package/dist/styles/scrollbar.js +25 -82
  121. package/dist/styles/scrollbar.js.map +1 -1
  122. package/dist/styles/shadow.d.ts +2 -2
  123. package/dist/styles/shadow.js.map +1 -1
  124. package/dist/styles/transition.d.ts +1 -1
  125. package/dist/styles/transition.js +27 -7
  126. package/dist/styles/transition.js.map +1 -1
  127. package/dist/styles/types.d.ts +10 -13
  128. package/dist/tasty.d.ts +11 -12
  129. package/dist/tasty.js +16 -1
  130. package/dist/tasty.js.map +1 -1
  131. package/dist/types.d.ts +2 -2
  132. package/dist/utils/colors.d.ts +1 -1
  133. package/dist/utils/colors.js.map +1 -1
  134. package/dist/utils/css-types.d.ts +1 -1
  135. package/dist/utils/dotize.d.ts +1 -1
  136. package/dist/utils/mod-attrs.js.map +1 -1
  137. package/dist/utils/selector-transform.js +32 -0
  138. package/dist/utils/selector-transform.js.map +1 -0
  139. package/dist/utils/string.js.map +1 -1
  140. package/dist/utils/styles.d.ts +8 -14
  141. package/dist/utils/styles.js +175 -30
  142. package/dist/utils/styles.js.map +1 -1
  143. package/dist/zero/babel.d.ts +21 -2
  144. package/dist/zero/babel.js +45 -8
  145. package/dist/zero/babel.js.map +1 -1
  146. package/dist/zero/extractor.js +66 -1
  147. package/dist/zero/extractor.js.map +1 -1
  148. package/dist/zero/next.d.ts +29 -30
  149. package/dist/zero/next.js +49 -39
  150. package/dist/zero/next.js.map +1 -1
  151. package/docs/configuration.md +211 -0
  152. package/docs/debug.md +505 -0
  153. package/docs/injector.md +528 -0
  154. package/docs/ssr.md +372 -0
  155. package/docs/styles.md +574 -0
  156. package/docs/tasty-static.md +376 -0
  157. package/docs/usage.md +695 -0
  158. package/package.json +99 -31
  159. package/tasty.config.ts +14 -0
  160. package/dist/styles/styledScrollbar.d.ts +0 -47
  161. package/dist/styles/styledScrollbar.js +0 -38
  162. package/dist/styles/styledScrollbar.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { Lru } from "../parser/lru.js";
2
- import { not } from "./conditions.js";
2
+ import { getConditionUniqueId, not } from "./conditions.js";
3
3
 
4
4
  //#region src/pipeline/materialize.ts
5
5
  /**
@@ -13,16 +13,13 @@ const conditionCache = new Lru(3e3);
13
13
  * Convert a condition tree to CSS components
14
14
  */
15
15
  function conditionToCSS(node) {
16
- const key = getConditionKey(node);
16
+ const key = getConditionUniqueId(node);
17
17
  const cached = conditionCache.get(key);
18
18
  if (cached) return cached;
19
19
  const result = conditionToCSSInner(node);
20
20
  conditionCache.set(key, result);
21
21
  return result;
22
22
  }
23
- /**
24
- * Create an empty selector variant
25
- */
26
23
  function emptyVariant() {
27
24
  return {
28
25
  modifierConditions: [],
@@ -144,14 +141,31 @@ function pseudoToParsed(state) {
144
141
  };
145
142
  }
146
143
  /**
147
- * Convert parsed pseudo to CSS selector string (for final output)
144
+ * Convert parsed pseudo to CSS selector string (for final output).
145
+ *
146
+ * :not() is normalized to negated :is() at parse time, so pseudo.pseudo
147
+ * never starts with ':not(' here. When negated:
148
+ * - :is(X) → :not(X) (unwrap :is)
149
+ * - :where(X) → :not(X) (unwrap :where)
150
+ * - :has(X) → :not(:has(X))
151
+ * - other → :not(other)
152
+ *
153
+ * When not negated, single-argument :is()/:where() is unwrapped when the
154
+ * inner content is a simple compound selector that can safely append to
155
+ * the base selector (this happens after double-negation of :not()).
148
156
  */
149
157
  function pseudoToCSS(pseudo) {
158
+ const p = pseudo.pseudo;
150
159
  if (pseudo.negated) {
151
- if (pseudo.pseudo.startsWith(":not(")) return pseudo.pseudo.slice(5, -1);
152
- return `:not(${pseudo.pseudo})`;
160
+ if (p.startsWith(":is(") || p.startsWith(":where(")) return `:not(${p.slice(p.indexOf("(") + 1, -1)})`;
161
+ return `:not(${p})`;
162
+ }
163
+ if ((p.startsWith(":is(") || p.startsWith(":where(")) && !p.includes(",")) {
164
+ const inner = p.slice(p.indexOf("(") + 1, -1);
165
+ const ch = inner[0];
166
+ if ((ch === ":" || ch === "." || ch === "[" || ch === "#") && !/\s/.test(inner)) return inner;
153
167
  }
154
- return pseudo.pseudo;
168
+ return p;
155
169
  }
156
170
  /**
157
171
  * Convert media condition to parsed structure(s)
@@ -279,11 +293,12 @@ function innerConditionToVariants(innerCondition, negated, target) {
279
293
  };
280
294
  }
281
295
  /**
282
- * Convert a @parent() inner condition into SelectorVariants with ParentGroups.
296
+ * Convert a @parent() inner condition into a single SelectorVariant with
297
+ * one ParentGroup whose branches represent the inner OR alternatives.
283
298
  *
284
- * Positive: each inner OR branch becomes a separate variant with one :is() group.
285
- * Negated: !(A | B) = !A & !B — all branches become :not() groups collected
286
- * into a single variant so they produce :not([a] *):not([b] *) on one element.
299
+ * Both positive and negated cases produce one variant with one group.
300
+ * Negation simply sets the `negated` flag, which swaps :is() for :not()
301
+ * in the final CSS output — no structural transformation is needed.
287
302
  */
288
303
  function parentConditionToVariants(innerCondition, negated, direct) {
289
304
  const innerCSS = conditionToCSS(innerCondition);
@@ -291,44 +306,23 @@ function parentConditionToVariants(innerCondition, negated, direct) {
291
306
  variants: [],
292
307
  isImpossible: true
293
308
  };
294
- if (negated) {
295
- const v = emptyVariant();
296
- for (const innerVariant of innerCSS.variants) {
297
- const conditions = collectSelectorConditions(innerVariant);
298
- if (conditions.length > 0) v.parentGroups.push({
299
- conditions,
300
- direct,
301
- negated: true
302
- });
303
- }
304
- if (v.parentGroups.length === 0) return {
305
- variants: [emptyVariant()],
306
- isImpossible: false
307
- };
308
- return {
309
- variants: [v],
310
- isImpossible: false
311
- };
312
- }
313
- const variants = [];
309
+ const branches = [];
314
310
  for (const innerVariant of innerCSS.variants) {
315
311
  const conditions = collectSelectorConditions(innerVariant);
316
- if (conditions.length > 0) {
317
- const v = emptyVariant();
318
- v.parentGroups.push({
319
- conditions,
320
- direct,
321
- negated: false
322
- });
323
- variants.push(v);
324
- }
312
+ if (conditions.length > 0) branches.push(conditions);
325
313
  }
326
- if (variants.length === 0) return {
314
+ if (branches.length === 0) return {
327
315
  variants: [emptyVariant()],
328
316
  isImpossible: false
329
317
  };
318
+ const v = emptyVariant();
319
+ v.parentGroups.push({
320
+ branches,
321
+ direct,
322
+ negated
323
+ });
330
324
  return {
331
- variants,
325
+ variants: [v],
332
326
  isImpossible: false
333
327
  };
334
328
  }
@@ -349,10 +343,13 @@ function parentGroupsToCSS(groups) {
349
343
  let result = "";
350
344
  for (const group of groups) {
351
345
  const combinator = group.direct ? " > *" : " *";
352
- let parts = "";
353
- for (const cond of group.conditions) parts += selectorConditionToCSS(cond);
346
+ const selectorArgs = group.branches.map((branch) => {
347
+ let parts = "";
348
+ for (const cond of branch) parts += selectorConditionToCSS(cond);
349
+ return parts + combinator;
350
+ });
354
351
  const wrapper = group.negated ? ":not" : ":is";
355
- result += `${wrapper}(${parts}${combinator})`;
352
+ result += `${wrapper}(${selectorArgs.join(", ")})`;
356
353
  }
357
354
  return result;
358
355
  }
@@ -462,10 +459,18 @@ function hasSelectorConditionContradiction(conditions) {
462
459
  * with opposite negation. E.g. :not([data-hovered] *) and :is([data-hovered] *)
463
460
  * in the same variant is impossible.
464
461
  */
462
+ function getBranchesKey(branches) {
463
+ if (branches.length === 1) {
464
+ const b = branches[0];
465
+ if (b.length === 1) return getSelectorConditionKey(b[0]);
466
+ return b.map(getSelectorConditionKey).sort().join("+");
467
+ }
468
+ return branches.map((b) => b.map(getSelectorConditionKey).sort().join("+")).sort().join(",");
469
+ }
465
470
  function hasParentGroupContradiction(groups) {
466
471
  const byBaseKey = /* @__PURE__ */ new Map();
467
472
  for (const g of groups) {
468
- const baseKey = `${g.direct ? ">" : ""}(${g.conditions.map(getSelectorConditionKey).sort().join(",")})`;
473
+ const baseKey = `${g.direct ? ">" : ""}(${getBranchesKey(g.branches)})`;
469
474
  const existing = byBaseKey.get(baseKey);
470
475
  if (existing !== void 0 && existing !== !g.negated) return true;
471
476
  byBaseKey.set(baseKey, !g.negated);
@@ -505,49 +510,29 @@ function mergeVariants(a, b) {
505
510
  };
506
511
  }
507
512
  /**
508
- * Deduplicate media conditions by their key (subtype + condition + negated)
513
+ * Generic deduplication by a key extraction function.
514
+ * Preserves insertion order, keeping the first occurrence of each key.
509
515
  */
510
- function dedupeMediaConditions(conditions) {
516
+ function dedupeByKey(items, getKey) {
511
517
  const seen = /* @__PURE__ */ new Set();
512
518
  const result = [];
513
- for (const c of conditions) {
514
- const key = `${c.subtype}|${c.condition}|${c.negated}`;
519
+ for (const item of items) {
520
+ const key = getKey(item);
515
521
  if (!seen.has(key)) {
516
522
  seen.add(key);
517
- result.push(c);
523
+ result.push(item);
518
524
  }
519
525
  }
520
526
  return result;
521
527
  }
522
- /**
523
- * Deduplicate container conditions by their key (name + condition + negated)
524
- */
528
+ function dedupeMediaConditions(conditions) {
529
+ return dedupeByKey(conditions, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
530
+ }
525
531
  function dedupeContainerConditions(conditions) {
526
- const seen = /* @__PURE__ */ new Set();
527
- const result = [];
528
- for (const c of conditions) {
529
- const key = `${c.name ?? ""}|${c.condition}|${c.negated}`;
530
- if (!seen.has(key)) {
531
- seen.add(key);
532
- result.push(c);
533
- }
534
- }
535
- return result;
532
+ return dedupeByKey(conditions, (c) => `${c.name ?? ""}|${c.condition}|${c.negated}`);
536
533
  }
537
- /**
538
- * Deduplicate supports conditions by their key (subtype + condition + negated)
539
- */
540
534
  function dedupeSupportsConditions(conditions) {
541
- const seen = /* @__PURE__ */ new Set();
542
- const result = [];
543
- for (const c of conditions) {
544
- const key = `${c.subtype}|${c.condition}|${c.negated}`;
545
- if (!seen.has(key)) {
546
- seen.add(key);
547
- result.push(c);
548
- }
549
- }
550
- return result;
535
+ return dedupeByKey(conditions, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
551
536
  }
552
537
  /**
553
538
  * Check if supports conditions contain contradictions
@@ -644,15 +629,20 @@ function hasContainerStyleContradiction(conditions) {
644
629
  }
645
630
  return false;
646
631
  }
632
+ const variantKeyCache = /* @__PURE__ */ new WeakMap();
647
633
  /**
648
- * Get a unique key for a variant (for deduplication)
634
+ * Get a unique key for a variant (for deduplication).
635
+ * Cached via WeakMap since variants are compared multiple times during
636
+ * deduplication and sorting.
649
637
  */
650
638
  function getVariantKey(v) {
639
+ const cached = variantKeyCache.get(v);
640
+ if (cached !== void 0) return cached;
651
641
  const modifierKey = v.modifierConditions.map(getModifierKey).sort().join("|");
652
642
  const pseudoKey = v.pseudoConditions.map(getPseudoKey).sort().join("|");
653
643
  const ownKey = v.ownConditions.map(getSelectorConditionKey).sort().join("|");
654
644
  const containerKey = v.containerConditions.map((c) => `${c.name ?? ""}:${c.negated ? "!" : ""}${c.condition}`).sort().join("|");
655
- return [
645
+ const key = [
656
646
  modifierKey,
657
647
  pseudoKey,
658
648
  ownKey,
@@ -663,6 +653,14 @@ function getVariantKey(v) {
663
653
  v.parentGroups.map(getParentGroupKey).sort().join("|"),
664
654
  v.startingStyle ? "1" : "0"
665
655
  ].join("###");
656
+ variantKeyCache.set(v, key);
657
+ return key;
658
+ }
659
+ /**
660
+ * Total number of leaf conditions in a variant (for superset / dedup comparisons).
661
+ */
662
+ function variantConditionCount(v) {
663
+ return v.modifierConditions.length + v.pseudoConditions.length + v.ownConditions.length + v.mediaConditions.length + v.containerConditions.length + v.supportsConditions.length + v.rootConditions.length + v.parentGroups.reduce((sum, g) => sum + g.branches.reduce((s, b) => s + b.length, 0), 0);
666
664
  }
667
665
  /**
668
666
  * Check if variant A is a superset of variant B (A is more restrictive)
@@ -685,66 +683,32 @@ function isVariantSuperset(a, b) {
685
683
  if (!isPseudoConditionsSuperset(a.pseudoConditions, b.pseudoConditions)) return false;
686
684
  if (!isSelectorConditionsSuperset(a.ownConditions, b.ownConditions)) return false;
687
685
  if (!isParentGroupsSuperset(a.parentGroups, b.parentGroups)) return false;
688
- const parentConditionCount = (groups) => groups.reduce((sum, g) => sum + g.conditions.length, 0);
689
- return a.mediaConditions.length + a.containerConditions.length + a.supportsConditions.length + a.modifierConditions.length + a.pseudoConditions.length + a.rootConditions.length + parentConditionCount(a.parentGroups) + a.ownConditions.length > b.mediaConditions.length + b.containerConditions.length + b.supportsConditions.length + b.modifierConditions.length + b.pseudoConditions.length + b.rootConditions.length + parentConditionCount(b.parentGroups) + b.ownConditions.length;
686
+ return variantConditionCount(a) > variantConditionCount(b);
690
687
  }
691
688
  /**
692
- * Check if media conditions A is a superset of B
689
+ * Generic superset check: true if every item in B has a matching key in A.
693
690
  */
691
+ function isConditionsSuperset(a, b, getKey) {
692
+ const aKeys = new Set(a.map(getKey));
693
+ return b.every((c) => aKeys.has(getKey(c)));
694
+ }
694
695
  function isMediaConditionsSuperset(a, b) {
695
- const aKeys = new Set(a.map((c) => `${c.subtype}|${c.condition}|${c.negated}`));
696
- for (const c of b) {
697
- const key = `${c.subtype}|${c.condition}|${c.negated}`;
698
- if (!aKeys.has(key)) return false;
699
- }
700
- return true;
696
+ return isConditionsSuperset(a, b, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
701
697
  }
702
- /**
703
- * Check if container conditions A is a superset of B
704
- */
705
698
  function isContainerConditionsSuperset(a, b) {
706
- const aKeys = new Set(a.map((c) => `${c.name ?? ""}|${c.condition}|${c.negated}`));
707
- for (const c of b) {
708
- const key = `${c.name ?? ""}|${c.condition}|${c.negated}`;
709
- if (!aKeys.has(key)) return false;
710
- }
711
- return true;
699
+ return isConditionsSuperset(a, b, (c) => `${c.name ?? ""}|${c.condition}|${c.negated}`);
712
700
  }
713
- /**
714
- * Check if supports conditions A is a superset of B
715
- */
716
701
  function isSupportsConditionsSuperset(a, b) {
717
- const aKeys = new Set(a.map((c) => `${c.subtype}|${c.condition}|${c.negated}`));
718
- for (const c of b) {
719
- const key = `${c.subtype}|${c.condition}|${c.negated}`;
720
- if (!aKeys.has(key)) return false;
721
- }
722
- return true;
702
+ return isConditionsSuperset(a, b, (c) => `${c.subtype}|${c.condition}|${c.negated}`);
723
703
  }
724
- /**
725
- * Check if modifier conditions A is a superset of B
726
- */
727
704
  function isModifierConditionsSuperset(a, b) {
728
- const aKeys = new Set(a.map(getModifierKey));
729
- for (const c of b) if (!aKeys.has(getModifierKey(c))) return false;
730
- return true;
705
+ return isConditionsSuperset(a, b, getModifierKey);
731
706
  }
732
- /**
733
- * Check if pseudo conditions A is a superset of B
734
- */
735
707
  function isPseudoConditionsSuperset(a, b) {
736
- const aKeys = new Set(a.map(getPseudoKey));
737
- for (const c of b) if (!aKeys.has(getPseudoKey(c))) return false;
738
- return true;
708
+ return isConditionsSuperset(a, b, getPseudoKey);
739
709
  }
740
- /**
741
- * Check if selector conditions A is a superset of B.
742
- * Shared by root and own conditions.
743
- */
744
710
  function isSelectorConditionsSuperset(a, b) {
745
- const aKeys = new Set(a.map(getSelectorConditionKey));
746
- for (const c of b) if (!aKeys.has(getSelectorConditionKey(c))) return false;
747
- return true;
711
+ return isConditionsSuperset(a, b, getSelectorConditionKey);
748
712
  }
749
713
  /**
750
714
  * Check if parent groups A is a superset of B.
@@ -752,12 +716,10 @@ function isSelectorConditionsSuperset(a, b) {
752
716
  */
753
717
  function isParentGroupsSuperset(a, b) {
754
718
  if (a.length < b.length) return false;
755
- const aKeys = new Set(a.map(getParentGroupKey));
756
- for (const g of b) if (!aKeys.has(getParentGroupKey(g))) return false;
757
- return true;
719
+ return isConditionsSuperset(a, b, getParentGroupKey);
758
720
  }
759
721
  function getParentGroupKey(g) {
760
- return `${g.negated ? "!" : ""}${g.direct ? ">" : ""}(${g.conditions.map(getSelectorConditionKey).sort().join(",")})`;
722
+ return `${g.negated ? "!" : ""}${g.direct ? ">" : ""}(${getBranchesKey(g.branches)})`;
761
723
  }
762
724
  /**
763
725
  * Deduplicate variants
@@ -776,7 +738,6 @@ function dedupeVariants(variants) {
776
738
  result.push(v);
777
739
  }
778
740
  }
779
- const variantConditionCount = (v) => v.modifierConditions.length + v.pseudoConditions.length + v.ownConditions.length + v.mediaConditions.length + v.containerConditions.length + v.supportsConditions.length + v.rootConditions.length + v.parentGroups.reduce((sum, g) => sum + g.conditions.length, 0);
780
741
  result.sort((a, b) => variantConditionCount(a) - variantConditionCount(b));
781
742
  const filtered = [];
782
743
  for (const candidate of result) {
@@ -850,19 +811,6 @@ function orToCSS(children) {
850
811
  };
851
812
  }
852
813
  /**
853
- * Get a cache key for a condition
854
- */
855
- function getConditionKey(node) {
856
- if (node.kind === "true") return "TRUE";
857
- if (node.kind === "false") return "FALSE";
858
- if (node.kind === "state") return node.uniqueId;
859
- if (node.kind === "compound") {
860
- const childKeys = node.children.map(getConditionKey).sort();
861
- return `${node.operator}(${childKeys.join(",")})`;
862
- }
863
- return "UNKNOWN";
864
- }
865
- /**
866
814
  * Build at-rules array from a variant
867
815
  */
868
816
  function buildAtRulesFromVariant(variant) {