@tenphi/tasty 0.0.0-snapshot.1f1c00a → 0.0.0-snapshot.1feecc6

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 (94) hide show
  1. package/README.md +403 -380
  2. package/dist/babel-types-Dc5zghyE.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-D9Iq8QQm.js +60 -0
  6. package/dist/chunks/build-config-D9Iq8QQm.js.map +1 -0
  7. package/dist/chunks/{collector-D2ARGT2L.js → collector-Cb8ah2JF.js} +8 -6
  8. package/dist/chunks/collector-Cb8ah2JF.js.map +1 -0
  9. package/dist/chunks/{config-engine-DEmmPPdp.js → config-engine-CMYFZYQh.js} +5 -5
  10. package/dist/chunks/config-engine-CMYFZYQh.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/{css-definitions-DotDkIXt.js → css-definitions-B4aWBkH3.js} +130 -96
  14. package/dist/chunks/css-definitions-B4aWBkH3.js.map +1 -0
  15. package/dist/chunks/{debug-D8pg9RGI.js → debug-D2Pu7Xhy.js} +6 -6
  16. package/dist/chunks/{debug-D8pg9RGI.js.map → debug-D2Pu7Xhy.js.map} +1 -1
  17. package/dist/chunks/{dsl-DRhFWQzo.js → dsl-CsFl9LGn.js} +132 -52
  18. package/dist/chunks/dsl-CsFl9LGn.js.map +1 -0
  19. package/dist/chunks/{react-runtime-BpxlOTbO.js → react-runtime-DHiopXCu.js} +193 -64
  20. package/dist/chunks/react-runtime-DHiopXCu.js.map +1 -0
  21. package/dist/chunks/{runtime-engine-CKFXUH-A.js → runtime-engine-NGCofNXy.js} +72 -53
  22. package/dist/chunks/runtime-engine-NGCofNXy.js.map +1 -0
  23. package/dist/chunks/{runtime-state-BxaLhVdP.js → runtime-state-lZjMbvwV.js} +28 -3
  24. package/dist/chunks/runtime-state-lZjMbvwV.js.map +1 -0
  25. package/dist/chunks/{style-engine-BBbBuSkT.js → style-engine-DnkV_4Jg.js} +488 -146
  26. package/dist/chunks/style-engine-DnkV_4Jg.js.map +1 -0
  27. package/dist/chunks/{zero-engine-gJrKBRiw.js → zero-engine-DcwaCvFs.js} +62 -27
  28. package/dist/chunks/zero-engine-DcwaCvFs.js.map +1 -0
  29. package/dist/{collector-w4mBj5gd.d.ts → collector-D2OT6I2G.d.ts} +2 -2
  30. package/dist/{config-CZWCzBr6.d.ts → config-C4ftFxgI.d.ts} +41 -23
  31. package/dist/core/index.d.ts +4 -4
  32. package/dist/core/index.js +7 -7
  33. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  34. package/dist/{index-G9JuwM9p.d.ts → index-DxQNRj50.d.ts} +65 -21
  35. package/dist/index.d.ts +5 -5
  36. package/dist/index.js +8 -8
  37. package/dist/{merge-styles-VXwJ0Frr.d.ts → merge-styles-D39qBtox.d.ts} +2 -2
  38. package/dist/ssr/astro.js +4 -4
  39. package/dist/ssr/client.d.ts +2 -0
  40. package/dist/ssr/client.js +2 -0
  41. package/dist/ssr/index.d.ts +3 -22
  42. package/dist/ssr/index.js +4 -4
  43. package/dist/ssr/index.js.map +1 -1
  44. package/dist/ssr/next-config.d.ts +1 -1
  45. package/dist/ssr/next-config.js +13 -18
  46. package/dist/ssr/next-config.js.map +1 -1
  47. package/dist/ssr/next.d.ts +1 -1
  48. package/dist/ssr/next.js +3 -3
  49. package/dist/static/index.d.ts +2 -2
  50. package/dist/{types-JEY8PVYP.d.ts → types-CYQIhUg1.d.ts} +10 -8
  51. package/dist/zero/babel.d.ts +73 -2
  52. package/dist/zero/babel.js +51 -48
  53. package/dist/zero/babel.js.map +1 -1
  54. package/dist/zero/index.d.ts +59 -3
  55. package/dist/zero/index.js +25 -2
  56. package/dist/zero/index.js.map +1 -0
  57. package/dist/zero/next.d.ts +2 -1
  58. package/dist/zero/next.js +3 -7
  59. package/dist/zero/next.js.map +1 -1
  60. package/docs/README.md +4 -1
  61. package/docs/adoption.md +25 -17
  62. package/docs/ai-agents.md +43 -34
  63. package/docs/comparison.md +9 -8
  64. package/docs/configuration.md +187 -69
  65. package/docs/debug.md +3 -2
  66. package/docs/design-system.md +117 -15
  67. package/docs/dsl.md +262 -116
  68. package/docs/getting-started.md +81 -24
  69. package/docs/injector.md +41 -40
  70. package/docs/methodology.md +46 -21
  71. package/docs/migration-v3.md +3 -3
  72. package/docs/pipeline.md +22 -19
  73. package/docs/plugins.md +21 -41
  74. package/docs/react-api.md +74 -11
  75. package/docs/runtime-benchmarks.md +11 -11
  76. package/docs/ssr.md +92 -66
  77. package/docs/styles.md +85 -19
  78. package/docs/tasty-static.md +175 -57
  79. package/package.json +45 -32
  80. package/tasty.config.ts +1 -0
  81. package/dist/babel-rZcEwPLM.d.ts +0 -82
  82. package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
  83. package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
  84. package/dist/chunks/build-config-CL4eRu2z.js +0 -42
  85. package/dist/chunks/build-config-CL4eRu2z.js.map +0 -1
  86. package/dist/chunks/collector-D2ARGT2L.js.map +0 -1
  87. package/dist/chunks/config-engine-DEmmPPdp.js.map +0 -1
  88. package/dist/chunks/css-definitions-DotDkIXt.js.map +0 -1
  89. package/dist/chunks/dsl-DRhFWQzo.js.map +0 -1
  90. package/dist/chunks/react-runtime-BpxlOTbO.js.map +0 -1
  91. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +0 -1
  92. package/dist/chunks/runtime-state-BxaLhVdP.js.map +0 -1
  93. package/dist/chunks/style-engine-BBbBuSkT.js.map +0 -1
  94. package/dist/chunks/zero-engine-gJrKBRiw.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { M as toSnakeCase, N as CSS_WIDE_KEYWORDS, T as makeEmptyDetails, _ as stringifyStyles, d as parseColor, f as parseStyle, h as resolveCustomProperties, i as DIRECTIONS, j as normalizeDslName, u as normalizeColorTokenValue, w as Lru } from "./dsl-DRhFWQzo.js";
1
+ import { D as isTransparent, E as makeEmptyDetails, F as normalizeDslName, I as toSnakeCase, L as CSS_WIDE_KEYWORDS, N as isColorKeyword, O as parseAlphaMix, T as Lru, c as getGlobalParser, d as normalizeColorTokenValue, f as parseColor, g as resolveCustomProperties, i as DIRECTIONS, p as parseStyle, u as isDroppedValue, v as stringifyStyles } from "./dsl-CsFl9LGn.js";
2
2
  import { a as warnOnceDev, i as warn, n as isSelector, o as isDevEnv } from "./shared-utils-y-HjvPN4.js";
3
3
  //#region src/config-state.ts
4
4
  let stylesGenerated = false;
@@ -87,6 +87,10 @@ function setGlobalPredefinedStates(states) {
87
87
  function getGlobalPredefinedStates() {
88
88
  return globalPredefinedStates;
89
89
  }
90
+ function clearGlobalPredefinedStates() {
91
+ globalPredefinedStates = {};
92
+ emittedWarnings.clear();
93
+ }
90
94
  const PREDEFINED_STATE_PATTERN = /@[A-Za-z][A-Za-z0-9-]*(?![A-Za-z0-9-:(])/g;
91
95
  function extractPredefinedStateRefs(value) {
92
96
  const matches = value.match(PREDEFINED_STATE_PATTERN);
@@ -130,8 +134,28 @@ function resolvePredefinedState(stateKey, ctx) {
130
134
  function expandDimensionShorthands(condition) {
131
135
  return condition.replace(/\b(?:w|h|is|bs)\b/g, (dimension) => dimension === "w" ? "width" : dimension === "h" ? "height" : dimension === "is" ? "inline-size" : "block-size");
132
136
  }
137
+ const RE_QUERY_UNIT_NUMBER = /(?<![\w.-])(?:\d*\.\d+|\d+)([a-z][a-z0-9]*)\b/g;
133
138
  function expandTastyUnits(value) {
134
- return value.replace(/(\d+(?:\.\d+)?)\s*x\b/g, (_, num) => `calc(var(--gap) * ${num})`);
139
+ const units = getGlobalParser().getUnits();
140
+ if (!units) return value;
141
+ return value.replace(RE_QUERY_UNIT_NUMBER, (token, unit) => {
142
+ if (!Object.prototype.hasOwnProperty.call(units, unit)) return token;
143
+ const resolved = parseStyle(token).groups[0]?.values[0] ?? token;
144
+ if (resolved.includes("var(")) warnOnce(`query-unit-var:${unit}`, `[Tasty] Unit '${unit}' resolves to '${resolved}', which @media and @container conditions cannot read: custom properties are not available there. Write '${token}' as a px, em, or rem length.`);
145
+ return resolved;
146
+ });
147
+ }
148
+ const RE_LENGTH_FEATURE = /^(?:min-|max-)?(?:width|height|inline-size|block-size)$/;
149
+ const RE_QUERY_OPERATOR = /<=|>=|<|>|=/;
150
+ const RE_FEATURE_NAME = /^[a-z][a-z-]*$/;
151
+ function expandQueryUnits(condition) {
152
+ let feature;
153
+ if (RE_QUERY_OPERATOR.test(condition)) feature = condition.split(RE_QUERY_OPERATOR).map((operand) => operand.trim()).find((operand) => RE_FEATURE_NAME.test(operand));
154
+ else {
155
+ const colonIdx = condition.indexOf(":");
156
+ feature = (colonIdx === -1 ? condition : condition.slice(0, colonIdx)).trim();
157
+ }
158
+ return feature && RE_LENGTH_FEATURE.test(feature) ? expandTastyUnits(condition) : condition;
135
159
  }
136
160
  function findTopLevelComma(s) {
137
161
  let depth = 0;
@@ -175,6 +199,16 @@ const CHUNK_NAMES = {
175
199
  };
176
200
  const APPEARANCE_CHUNK_STYLES = [
177
201
  "fill",
202
+ "backgroundColor",
203
+ "image",
204
+ "backgroundImage",
205
+ "backgroundPosition",
206
+ "backgroundSize",
207
+ "backgroundRepeat",
208
+ "backgroundAttachment",
209
+ "backgroundOrigin",
210
+ "backgroundClip",
211
+ "background",
178
212
  "color",
179
213
  "opacity",
180
214
  "border",
@@ -299,6 +333,113 @@ function resetStyleChunks() {
299
333
  for (const [style, chunk] of builtinSnapshot) STYLE_TO_CHUNK.set(style, chunk);
300
334
  }
301
335
  //#endregion
336
+ //#region src/styles/createStyle.ts
337
+ const CACHE = {};
338
+ function createStyle(styleName, cssStyle, converter) {
339
+ const key = `${styleName}.${cssStyle ?? ""}`;
340
+ if (!CACHE[key]) {
341
+ const styleHandler = (styleMap) => {
342
+ let styleValue = styleMap[styleName];
343
+ if (styleValue == null || styleValue === false) return null;
344
+ let finalCssStyle;
345
+ const isColorToken = !cssStyle && typeof styleName === "string" && styleName.startsWith("#");
346
+ if (isColorToken) finalCssStyle = `--${normalizeDslName(styleName.slice(1))}-color`;
347
+ else if (!cssStyle && styleName[0] === "$") finalCssStyle = `--${normalizeDslName(styleName.slice(1))}`;
348
+ else finalCssStyle = cssStyle || toSnakeCase(styleName);
349
+ if (isColorToken) {
350
+ const normalized = normalizeColorTokenValue(styleValue);
351
+ if (normalized === null) return null;
352
+ styleValue = normalized;
353
+ }
354
+ if (converter) {
355
+ const converted = converter(styleValue);
356
+ if (converted) styleValue = converted;
357
+ else if (typeof styleValue !== "string") return null;
358
+ }
359
+ if (typeof styleValue === "string" && finalCssStyle.startsWith("--") && finalCssStyle.endsWith("-color")) {
360
+ styleValue = styleValue.trim();
361
+ return { [finalCssStyle]: parseColor(styleValue).color ?? "" };
362
+ }
363
+ const processed = parseStyle(styleValue);
364
+ return { [finalCssStyle]: processed.output };
365
+ };
366
+ styleHandler.__lookupStyles = [styleName];
367
+ CACHE[key] = styleHandler;
368
+ }
369
+ return CACHE[key];
370
+ }
371
+ //#endregion
372
+ //#region src/styles/animation.ts
373
+ const NON_NAME_KEYWORDS = new Set("none initial inherit unset revert revert-layer auto normal running paused reverse alternate alternate-reverse forwards backwards both infinite ease linear ease-in ease-out ease-in-out step-start step-end".split(" "));
374
+ const RE_NAME = /^(?:--|-?[a-zA-Z_\u0080-￿])[\w\-\u0080-￿]*$/;
375
+ function nameAt(value, start, end) {
376
+ const token = value.slice(start, end);
377
+ return RE_NAME.test(token) && !NON_NAME_KEYWORDS.has(token.toLowerCase()) ? {
378
+ name: token,
379
+ index: start
380
+ } : null;
381
+ }
382
+ function scanAnimationNames(value) {
383
+ const items = [];
384
+ let found = null;
385
+ let start = -1;
386
+ let depth = 0;
387
+ let quote = "";
388
+ for (let i = 0; i < value.length; i++) {
389
+ const ch = value[i];
390
+ if (quote) {
391
+ if (ch === "\\") i++;
392
+ else if (ch === quote) quote = "";
393
+ continue;
394
+ }
395
+ if (depth === 0 && (ch === "," || /\s/.test(ch))) {
396
+ if (start !== -1) found ??= nameAt(value, start, i);
397
+ start = -1;
398
+ if (ch === ",") {
399
+ items.push(found);
400
+ found = null;
401
+ }
402
+ continue;
403
+ }
404
+ if (start === -1) start = i;
405
+ if (ch === "\"" || ch === "'") quote = ch;
406
+ else if (ch === "\\") i++;
407
+ else if (ch === "(") depth++;
408
+ else if (ch === ")" && depth > 0) depth--;
409
+ }
410
+ if (start !== -1) found ??= nameAt(value, start, value.length);
411
+ items.push(found);
412
+ return items;
413
+ }
414
+ function restoreAnimationNameCase(authored, output) {
415
+ if (authored === output || authored === authored.toLowerCase()) return output;
416
+ const authoredNames = scanAnimationNames(authored);
417
+ const outputNames = scanAnimationNames(output);
418
+ if (authoredNames.length !== outputNames.length) return output;
419
+ let result = output;
420
+ for (let i = outputNames.length - 1; i >= 0; i--) {
421
+ const from = outputNames[i];
422
+ const to = authoredNames[i];
423
+ if (!from || !to || from.name === to.name) continue;
424
+ if (from.name !== to.name.toLowerCase()) continue;
425
+ result = result.slice(0, from.index) + to.name + result.slice(from.index + from.name.length);
426
+ }
427
+ return result;
428
+ }
429
+ function animationNameHandler(styleName, property) {
430
+ const base = createStyle(styleName);
431
+ const handler = (styleMap) => {
432
+ const result = base(styleMap);
433
+ const value = styleMap[styleName];
434
+ if (!result || typeof value !== "string") return result;
435
+ return { [property]: restoreAnimationNameCase(value, String(result[property])) };
436
+ };
437
+ handler.__lookupStyles = [styleName];
438
+ return handler;
439
+ }
440
+ const animationStyle = animationNameHandler("animation", "animation");
441
+ const animationNameStyle = animationNameHandler("animationName", "animation-name");
442
+ //#endregion
302
443
  //#region src/styles/const.ts
303
444
  const BORDER_STYLES = [
304
445
  "none",
@@ -314,10 +455,16 @@ const BORDER_STYLES = [
314
455
  ];
315
456
  //#endregion
316
457
  //#region src/styles/shared.ts
458
+ function resolveDefaultValue(value) {
459
+ return parseStyle(value).groups[0]?.values[0] ?? value;
460
+ }
317
461
  function extractCSSWideKeyword(group) {
318
462
  if (group.values.length !== 1 || group.colors.length > 0) return null;
319
463
  return CSS_WIDE_KEYWORDS.has(group.values[0]) ? group.values[0] : null;
320
464
  }
465
+ function isUnset(value) {
466
+ return value == null || value === false;
467
+ }
321
468
  const RE_VAR_REFERENCE = /^var\(/;
322
469
  function assignLineSlots(values, styleKeyword, colorToken) {
323
470
  if (styleKeyword && colorToken) return {
@@ -353,9 +500,9 @@ function processGroup$1(group) {
353
500
  else if (mod === "longhand") modFlags |= 16;
354
501
  else if (lineStyle === void 0 && BORDER_STYLES.includes(mod)) lineStyle = mod;
355
502
  const slots = assignLineSlots(values, lineStyle, colors[0]);
356
- const width = values[0] || "var(--border-width)";
503
+ const width = values[0] || resolveDefaultValue("1bw");
357
504
  const style = slots.style || "solid";
358
- const color = slots.color || "var(--border-color, currentColor)";
505
+ const color = slots.color || "var(--border-color)";
359
506
  return {
360
507
  modFlags,
361
508
  width,
@@ -438,7 +585,7 @@ function borderStyle({ border }) {
438
585
  }
439
586
  const result = {};
440
587
  const fallbackStyle = allDirectionsValue?.style || "solid";
441
- const fallbackColor = allDirectionsValue?.color || "var(--border-color, currentColor)";
588
+ const fallbackColor = allDirectionsValue?.color || "var(--border-color)";
442
589
  for (const dir of DIRECTIONS) {
443
590
  const value = directionMap[dir];
444
591
  if (value) result[`border-${dir}`] = formatBorderValue(value);
@@ -449,10 +596,15 @@ function borderStyle({ border }) {
449
596
  borderStyle.__lookupStyles = ["border"];
450
597
  //#endregion
451
598
  //#region src/styles/dimension.ts
452
- const DEFAULT_MIN_SIZE = "var(--gap)";
599
+ const DEFAULT_MIN_SIZE = "1x";
453
600
  const DEFAULT_MAX_SIZE = "100%";
601
+ const STRETCH_FALLBACKS = [
602
+ "-webkit-fill-available",
603
+ "-moz-available",
604
+ "stretch"
605
+ ];
454
606
  function parseDimensionValue(val) {
455
- if (val == null) return null;
607
+ if (isUnset(val)) return null;
456
608
  if (typeof val === "number") return `${val}px`;
457
609
  if (val === true) return "initial";
458
610
  return parseStyle(String(val)).groups[0]?.values[0] || null;
@@ -461,8 +613,8 @@ function dimensionStyle(name) {
461
613
  const minStyle = `min-${name}`;
462
614
  const maxStyle = `max-${name}`;
463
615
  return ({ value, min, max }) => {
464
- if (value == null && min == null && max == null) return null;
465
- if (value != null && typeof value === "string" && CSS_WIDE_KEYWORDS.has(value)) {
616
+ if (isUnset(value) && isUnset(min) && isUnset(max)) return null;
617
+ if (typeof value === "string" && CSS_WIDE_KEYWORDS.has(value)) {
466
618
  const styles = {
467
619
  [name]: value,
468
620
  [minStyle]: value,
@@ -491,7 +643,7 @@ function dimensionStyle(name) {
491
643
  [minStyle]: "initial",
492
644
  [maxStyle]: "initial"
493
645
  };
494
- if (value != null) {
646
+ if (!isUnset(value)) {
495
647
  let val = value;
496
648
  if (typeof val === "number") val = `${val}px`;
497
649
  val = String(val);
@@ -499,7 +651,7 @@ function dimensionStyle(name) {
499
651
  let flag = false;
500
652
  for (const mod of mods) switch (mod) {
501
653
  case "min":
502
- styles[minStyle] = values[0] || DEFAULT_MIN_SIZE;
654
+ styles[minStyle] = values[0] || resolveDefaultValue(DEFAULT_MIN_SIZE);
503
655
  flag = true;
504
656
  break;
505
657
  case "max":
@@ -525,14 +677,7 @@ function dimensionStyle(name) {
525
677
  styles[maxStyle] = values[2];
526
678
  } else styles[name] = values[0] || "auto";
527
679
  }
528
- if (styles[name] === "stretch") {
529
- if (name === "width") styles[name] = [
530
- "stretch",
531
- "-webkit-fill-available",
532
- "-moz-available"
533
- ];
534
- else styles[name] = "auto";
535
- }
680
+ if (styles[name] === "stretch") styles[name] = STRETCH_FALLBACKS;
536
681
  }
537
682
  const minVal = parseDimensionValue(min);
538
683
  const maxVal = parseDimensionValue(max);
@@ -554,53 +699,20 @@ function blockSizeStyle({ blockSize, minBlockSize, maxBlockSize }) {
554
699
  blockSizeStyle.__lookupStyles = [...BLOCK_SIZE_STYLES];
555
700
  //#endregion
556
701
  //#region src/styles/color.ts
702
+ const RE_HEX_LITERAL = /^#[0-9a-f]+$/i;
557
703
  const RE_READS_CURRENT = /var\(--current-color[,)]|currentcolor/i;
558
704
  function colorStyle({ color }) {
559
705
  if (!color) return null;
560
706
  if (color === true) color = "currentColor";
561
- color = parseColor(color, true).color || resolveCustomProperties(color);
707
+ const resolved = RE_HEX_LITERAL.test(color) ? parseStyle(color).groups[0]?.colors[0] : parseColor(color, true).color;
708
+ if (!resolved && isDroppedValue(color)) return null;
709
+ color = resolved || resolveCustomProperties(color);
562
710
  const styles = { color };
563
711
  if (!RE_READS_CURRENT.test(color)) styles["--current-color"] = color;
564
712
  return styles;
565
713
  }
566
714
  colorStyle.__lookupStyles = ["color"];
567
715
  //#endregion
568
- //#region src/styles/createStyle.ts
569
- const CACHE = {};
570
- function createStyle(styleName, cssStyle, converter) {
571
- const key = `${styleName}.${cssStyle ?? ""}`;
572
- if (!CACHE[key]) {
573
- const styleHandler = (styleMap) => {
574
- let styleValue = styleMap[styleName];
575
- if (styleValue == null || styleValue === false) return null;
576
- let finalCssStyle;
577
- const isColorToken = !cssStyle && typeof styleName === "string" && styleName.startsWith("#");
578
- if (isColorToken) finalCssStyle = `--${normalizeDslName(styleName.slice(1))}-color`;
579
- else if (!cssStyle && styleName[0] === "$") finalCssStyle = `--${normalizeDslName(styleName.slice(1))}`;
580
- else finalCssStyle = cssStyle || toSnakeCase(styleName);
581
- if (isColorToken) {
582
- const normalized = normalizeColorTokenValue(styleValue);
583
- if (normalized === null) return null;
584
- styleValue = normalized;
585
- }
586
- if (converter) {
587
- const converted = converter(styleValue);
588
- if (converted) styleValue = converted;
589
- else if (typeof styleValue !== "string") return null;
590
- }
591
- if (typeof styleValue === "string" && finalCssStyle.startsWith("--") && finalCssStyle.endsWith("-color")) {
592
- styleValue = styleValue.trim();
593
- return { [finalCssStyle]: parseColor(styleValue).color ?? "" };
594
- }
595
- const processed = parseStyle(styleValue);
596
- return { [finalCssStyle]: processed.output };
597
- };
598
- styleHandler.__lookupStyles = [styleName];
599
- CACHE[key] = styleHandler;
600
- }
601
- return CACHE[key];
602
- }
603
- //#endregion
604
716
  //#region src/styles/display.ts
605
717
  function applyTextOverflow(result, textOverflow, whiteSpace) {
606
718
  if (textOverflow === true || textOverflow === "initial") {
@@ -662,7 +774,7 @@ function processGroup(group, isOnlyGroup, gradients) {
662
774
  const { input, values, mods, colors } = group;
663
775
  const transparentColor = colors[0] || DEFAULT_TRANSPARENT_COLOR;
664
776
  const opaqueColor = colors[1] || DEFAULT_OPAQUE_COLOR;
665
- const firstSize = values.length ? values[0] : "calc(2 * var(--gap))";
777
+ const firstSize = values.length ? values[0] : resolveDefaultValue("2x");
666
778
  let namedCount = 0;
667
779
  for (const mod of mods) {
668
780
  const directionIndex = DIRECTIONS.indexOf(mod);
@@ -696,16 +808,39 @@ function fadeStyle({ fade }) {
696
808
  fadeStyle.__lookupStyles = ["fade"];
697
809
  //#endregion
698
810
  //#region src/styles/fill.ts
811
+ function mixFillColors(property, value, groups) {
812
+ warnOnceDev(`fill-mix:${property}:${value}`, `${property}="${value}": mixing colors with a comma is deprecated. Layer the colors as a compound color instead: "#dark 4%, #surface" is "#surface+#dark.04". For any other mix, write color-mix() itself, such as "color-mix(in srgb, #dark $weight, #surface)".` + (groups.length > 2 ? " A mix takes two colors; the rest are ignored." : ""));
813
+ const [first, second] = groups;
814
+ return `color-mix(in srgb, ${first.output}, ${second.output})`;
815
+ }
699
816
  function fillStyle({ fill, backgroundColor, image, backgroundImage, backgroundPosition, backgroundSize, backgroundRepeat, backgroundAttachment, backgroundOrigin, backgroundClip, background }) {
700
817
  if (background) return { background: parseStyle(background).output || background };
701
818
  const result = {};
702
- const colorValue = backgroundColor ?? fill;
819
+ if (fill === true) warnOnceDev("fill-true", "fill: true has no default color and is ignored. Write a color (fill: '#surface'), or false for no fill.");
820
+ const colorProperty = backgroundColor != null ? "backgroundColor" : "fill";
821
+ const colorValue = backgroundColor ?? (typeof fill === "string" ? fill : void 0);
703
822
  if (colorValue) {
704
- const parsed = parseStyle(colorValue);
705
- const firstColor = parsed.groups[0]?.colors[0];
706
- const secondColor = parsed.groups[0]?.colors[1];
707
- result["background-color"] = firstColor || resolveCustomProperties(colorValue);
708
- if (secondColor) result["--tasty-second-fill-color"] = secondColor;
823
+ const { groups } = parseStyle(colorValue);
824
+ if (groups.length > 1) result["background-color"] = mixFillColors(colorProperty, colorValue, groups);
825
+ else {
826
+ const firstColor = groups[0]?.colors[0];
827
+ const secondColor = groups[0]?.colors[1];
828
+ if (firstColor || !isDroppedValue(colorValue)) result["background-color"] = firstColor || resolveCustomProperties(colorValue);
829
+ if (secondColor) {
830
+ const tokens = colorValue.trim().split(/\s+/);
831
+ const [base, overlay] = tokens;
832
+ const join = (compound) => `Join them with a plus instead: "${compound}" paints the second color over the first as one background color.`;
833
+ const makeOpaque = `make it opaque and give it an opacity: "${base}+${overlay}.04".`;
834
+ let fix;
835
+ if (tokens.length !== 2 || base[0] !== "#" || overlay[0] !== "#") fix = join("#surface+#dark.04");
836
+ else if (isTransparent(secondColor)) fix = `"${overlay}" paints nothing, so use the first color alone: "${base}".`;
837
+ else if (overlay.includes(".")) fix = join(`${base}+${overlay}`);
838
+ else if (parseAlphaMix(secondColor) || secondColor.includes("/")) fix = `"${overlay}" is translucent, which would leave a compound see-through, so ${makeOpaque}`;
839
+ else fix = `If "${overlay}" is opaque, it covers the first color, so use it alone: "${overlay}". If it is translucent, ${makeOpaque}`;
840
+ warnOnceDev(`fill-two-colors:${colorProperty}:${colorValue}`, `${colorProperty}="${colorValue}": two colors separated by a space are deprecated. The second one is painted as a background-image layer, which contrast checkers such as axe cannot read. ${fix}`);
841
+ result["--tasty-second-fill-color"] = secondColor;
842
+ }
843
+ }
709
844
  }
710
845
  const gradientLayer = result["--tasty-second-fill-color"] ? "linear-gradient(var(--tasty-second-fill-color), var(--tasty-second-fill-color))" : null;
711
846
  const imageValue = backgroundImage ?? image;
@@ -737,7 +872,9 @@ fillStyle.__lookupStyles = [
737
872
  ];
738
873
  function svgFillStyle({ svgFill }) {
739
874
  if (!svgFill) return null;
740
- svgFill = parseStyle(svgFill).groups[0]?.colors[0] || resolveCustomProperties(svgFill);
875
+ const processed = parseStyle(svgFill);
876
+ if (!processed.groups[0]?.colors[0] && isDroppedValue(svgFill)) return null;
877
+ svgFill = processed.groups[0]?.colors[0] || resolveCustomProperties(svgFill);
741
878
  return { fill: svgFill };
742
879
  }
743
880
  svgFillStyle.__lookupStyles = ["svgFill"];
@@ -814,7 +951,7 @@ function parseSingleValue(val, defaultValue, trueValue) {
814
951
  const strVal = String(val);
815
952
  if (CSS_WIDE_KEYWORDS.has(strVal)) return strVal;
816
953
  const { values } = parseStyle(strVal).groups[0] ?? { values: [] };
817
- return values[0] || defaultValue;
954
+ return values[0] || resolveDefaultValue(defaultValue);
818
955
  }
819
956
  function directionModFlags(mods, spanModifiers) {
820
957
  let flags = 0;
@@ -832,7 +969,7 @@ function directionModFlags(mods, spanModifiers) {
832
969
  return flags;
833
970
  }
834
971
  function applyGroup(dirs, group, modFlags, property, defaultValue) {
835
- const values = group.values.length ? group.values : [defaultValue];
972
+ const values = group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
836
973
  const directions = modFlags & DIRECTION_MASK;
837
974
  const span = modFlags & DIRECTION_SPAN;
838
975
  if (directions && values.length > (span ? 2 : 1)) warnExtraGroupValues(property, group.input, span ? 2 : 1);
@@ -864,11 +1001,11 @@ function optimizeShorthand(property, dirs) {
864
1001
  }
865
1002
  function processDirectionalStyle(config, props) {
866
1003
  const { main, top, right, bottom, left } = props;
867
- if (main == null && top == null && right == null && bottom == null && left == null) return null;
1004
+ if (isUnset(main) && isUnset(top) && isUnset(right) && isUnset(bottom) && isUnset(left)) return null;
868
1005
  const { property, defaultValue, trueValue, defaultInit, individualOnly, directionProperty, spanModifiers } = config;
869
1006
  const dirProp = directionProperty ?? ((dir) => `${property}-${dir}`);
870
1007
  if (individualOnly) {
871
- if (main == null) {
1008
+ if (isUnset(main)) {
872
1009
  const result = {};
873
1010
  if (top != null) {
874
1011
  const val = parseSingleValue(top, defaultValue, trueValue);
@@ -896,7 +1033,7 @@ function processDirectionalStyle(config, props) {
896
1033
  left: defaultInit
897
1034
  };
898
1035
  let useLonghand = false;
899
- if (main != null) {
1036
+ if (!isUnset(main)) {
900
1037
  if (typeof main === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${main}px`;
901
1038
  else {
902
1039
  const strMain = main === true ? trueValue : String(main);
@@ -1018,7 +1155,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
1018
1155
  const modFlags = logicalModFlags(group.mods);
1019
1156
  const hasDirection = modFlags & 3;
1020
1157
  const keyword = extractCSSWideKeyword(group);
1021
- const values = keyword ? [keyword] : group.values.length ? group.values : [defaultValue];
1158
+ const values = keyword ? [keyword] : group.values.length ? group.values : [resolveDefaultValue(defaultValue)];
1022
1159
  if (hasDirection && values.length > 1) warnExtraGroupValues(styleName, group.input, 1, LOGICAL_DIRECTIONS);
1023
1160
  else if (!hasDirection && values.length > 2) warnOnceDev(`extra-logical-axis-values:${styleName}:${group.input}`, `${styleName}="${group.input}": a logical axis takes at most two values in start/end order. The extra values are ignored.`);
1024
1161
  if (modFlags & LOGICAL_LONGHAND) useLonghand = true;
@@ -1041,7 +1178,7 @@ function logicalAxisStyle({ styleName, cssProperty, defaultValue, trueValue, def
1041
1178
  }
1042
1179
  function zeroBorderValue(value) {
1043
1180
  const firstSpace = value.indexOf(" ");
1044
- return firstSpace === -1 ? "0 solid var(--border-color, currentColor)" : `0${value.slice(firstSpace)}`;
1181
+ return firstSpace === -1 ? "0 solid var(--border-color)" : `0${value.slice(firstSpace)}`;
1045
1182
  }
1046
1183
  function logicalBorderStyle(styleName, cssProperty) {
1047
1184
  const handler = ((styles) => {
@@ -1055,7 +1192,7 @@ function logicalBorderStyle(styleName, cssProperty) {
1055
1192
  start: null,
1056
1193
  end: null
1057
1194
  };
1058
- let fallback = "0 solid var(--border-color, currentColor)";
1195
+ let fallback = "0 solid var(--border-color)";
1059
1196
  let useLonghand = false;
1060
1197
  for (const group of groups) {
1061
1198
  const borderValue = parseBorderValue(group.input);
@@ -1096,8 +1233,8 @@ function logicalBorderStyles(styleNames) {
1096
1233
  return Object.fromEntries(styleNames.map((styleName, index) => [styleName, logicalBorderStyle(styleName, `border-${index ? "inline" : "block"}`)]));
1097
1234
  }
1098
1235
  const logicalStyleHandlers = {
1099
- ...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "var(--gap)", "1x", "0"),
1100
- ...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "var(--gap)", "1x", "0"),
1236
+ ...logicalAxisStyles(LOGICAL_PADDING_STYLES, "padding", "1x", "1x", "0"),
1237
+ ...logicalAxisStyles(LOGICAL_MARGIN_STYLES, "margin", "1x", "1x", "0"),
1101
1238
  ...logicalAxisStyles(LOGICAL_INSET_STYLES, "inset", "0", "0", "auto"),
1102
1239
  ...logicalAxisStyles(LOGICAL_SCROLL_MARGIN_STYLES, "scroll-margin", "0", "1x", "0"),
1103
1240
  ...logicalAxisStyles(LOGICAL_SCROLL_PADDING_STYLES, "scroll-padding", "0", "1x", "0"),
@@ -1107,7 +1244,7 @@ const logicalStyleHandlers = {
1107
1244
  //#region src/styles/margin.ts
1108
1245
  const MARGIN_CONFIG = {
1109
1246
  property: "margin",
1110
- defaultValue: "var(--gap)",
1247
+ defaultValue: "1x",
1111
1248
  trueValue: "1x",
1112
1249
  defaultInit: "0"
1113
1250
  };
@@ -1152,12 +1289,12 @@ function outlineStyle({ outline, outlineOffset }) {
1152
1289
  break;
1153
1290
  }
1154
1291
  const slots = assignLineSlots(outlinePart.values, lineStyle, outlinePart.colors[0]);
1155
- result.outline = `${outlinePart.values[0] || "var(--outline-width)"} ${slots.style || "solid"} ${slots.color || "var(--outline-color)"}`;
1292
+ result.outline = `${outlinePart.values[0] || resolveDefaultValue("1ow")} ${slots.style || "solid"} ${slots.color || "var(--outline-color)"}`;
1156
1293
  if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
1157
1294
  }
1158
1295
  }
1159
1296
  }
1160
- if (outlineOffset != null && result["outline-offset"] === void 0) {
1297
+ if (outlineOffset != null && typeof outlineOffset !== "boolean" && result["outline-offset"] === void 0) {
1161
1298
  const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
1162
1299
  result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || resolveCustomProperties(offsetValue);
1163
1300
  }
@@ -1168,7 +1305,7 @@ outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
1168
1305
  //#region src/styles/padding.ts
1169
1306
  const PADDING_CONFIG = {
1170
1307
  property: "padding",
1171
- defaultValue: "var(--gap)",
1308
+ defaultValue: "1x",
1172
1309
  trueValue: "1x",
1173
1310
  defaultInit: "0"
1174
1311
  };
@@ -1262,6 +1399,7 @@ const PRESET_MODIFIERS = /* @__PURE__ */ new Set([
1262
1399
  "normal"
1263
1400
  ]);
1264
1401
  const SANS_FONT = "var(--font-sans, var(--font-sans-fallback))";
1402
+ const MONO_FONT = "var(--font-mono, var(--font-mono-fallback))";
1265
1403
  function toCSS(value, isNumeric) {
1266
1404
  if (value == null) return null;
1267
1405
  if (typeof value === "number") return isNumeric ? `${value}px` : String(value);
@@ -1281,7 +1419,7 @@ function setCSSValue(styles, styleName, presetName, mode) {
1281
1419
  function resolveFontFamily(font, fontFamily) {
1282
1420
  if (fontFamily) return resolveCustomProperties(fontFamily);
1283
1421
  if (font == null || font === false) return null;
1284
- if (font === "monospace") return "var(--font-mono, var(--font-mono-fallback))";
1422
+ if (font === "monospace") return MONO_FONT;
1285
1423
  if (font === true) return SANS_FONT;
1286
1424
  return `${resolveCustomProperties(font)}, ${SANS_FONT}`;
1287
1425
  }
@@ -1293,7 +1431,8 @@ function presetStyle({ preset, fontSize, lineHeight, textTransform, letterSpacin
1293
1431
  const modPart = parts[1];
1294
1432
  const nameTokens = namePart?.all ?? [];
1295
1433
  const isModOnly = nameTokens.length > 0 && nameTokens.every((t) => PRESET_MODIFIERS.has(t));
1296
- const nameToken = namePart?.mods[0] ?? namePart?.values[0] ?? "";
1434
+ const nameMods = namePart?.mods ?? [];
1435
+ const nameToken = nameTokens.find((token) => nameMods.includes(token) || isColorKeyword(token)) ?? namePart?.values[0] ?? "";
1297
1436
  const name = isModOnly || isTokenNameReference("preset", nameToken) ? "inherit" : nameToken || "inherit";
1298
1437
  const modTokens = isModOnly ? nameTokens : modPart?.all ?? [];
1299
1438
  const isStrong = modTokens.includes("strong") || modTokens.includes("bold");
@@ -1350,7 +1489,7 @@ presetStyle.__lookupStyles = [
1350
1489
  ];
1351
1490
  //#endregion
1352
1491
  //#region src/styles/radius.ts
1353
- const PROP = "var(--radius)";
1492
+ const DEFAULT_RADIUS = "1r";
1354
1493
  const SHARP = "var(--sharp-radius)";
1355
1494
  const RADIUS_LONGHANDS = [
1356
1495
  "border-top-left-radius",
@@ -1395,19 +1534,20 @@ function radiusStyle({ radius }) {
1395
1534
  for (const i of corners) result[RADIUS_LONGHANDS[i]] = keyword;
1396
1535
  return result;
1397
1536
  }
1537
+ const defaultRadius = resolveDefaultValue(DEFAULT_RADIUS);
1398
1538
  if (mods.includes("round")) values = ["9999rem"];
1399
1539
  else if (mods.includes("ellipse")) values = ["50%"];
1400
- else if (!values.length) values = [PROP];
1540
+ else if (!values.length) values = [defaultRadius];
1401
1541
  if (mods.includes("leaf")) values = [
1402
1542
  values[1] || SHARP,
1403
- values[0] || PROP,
1543
+ values[0] || defaultRadius,
1404
1544
  values[1] || SHARP,
1405
- values[0] || PROP
1545
+ values[0] || defaultRadius
1406
1546
  ];
1407
1547
  else if (mods.includes("backleaf")) values = [
1408
- values[0] || PROP,
1548
+ values[0] || defaultRadius,
1409
1549
  values[1] || SHARP,
1410
- values[0] || PROP,
1550
+ values[0] || defaultRadius,
1411
1551
  values[1] || SHARP
1412
1552
  ];
1413
1553
  else if (mods.length) {
@@ -1419,7 +1559,7 @@ function radiusStyle({ radius }) {
1419
1559
  "0",
1420
1560
  "0"
1421
1561
  ];
1422
- for (const i of corners) arr[i] = values[0] || PROP;
1562
+ for (const i of corners) arr[i] = values[0] || defaultRadius;
1423
1563
  values = arr;
1424
1564
  }
1425
1565
  }
@@ -1611,7 +1751,6 @@ const MAP = {
1611
1751
  "height"
1612
1752
  ],
1613
1753
  gap: ["gap", "margin"],
1614
- zIndex: ["z-index"],
1615
1754
  inset: [
1616
1755
  "inset",
1617
1756
  "top",
@@ -1620,6 +1759,7 @@ const MAP = {
1620
1759
  "left"
1621
1760
  ]
1622
1761
  };
1762
+ const NAME_ALIASES = { zindex: "z-index" };
1623
1763
  const DEFAULT_EASING = "linear";
1624
1764
  const EASING_KEYWORDS = new Set("ease ease-in ease-out ease-in-out linear step-start step-end".split(" "));
1625
1765
  function isEasing(token) {
@@ -1630,14 +1770,16 @@ function getTiming(name) {
1630
1770
  }
1631
1771
  function transitionStyle({ transition }) {
1632
1772
  if (!transition) return null;
1633
- if (CSS_WIDE_KEYWORDS.has(transition)) return { transition };
1773
+ const keyword = String(transition).trim().toLowerCase();
1774
+ if (keyword === "none" || CSS_WIDE_KEYWORDS.has(keyword)) return { transition: keyword };
1634
1775
  const processed = parseStyle(transition);
1635
1776
  const map = {};
1636
1777
  const named = /* @__PURE__ */ new Set();
1637
1778
  for (const group of processed.groups) {
1638
1779
  const tokens = group.all;
1639
- const name = tokens[0];
1780
+ let name = tokens[0];
1640
1781
  if (!name || isTokenNameReference("transition", name)) continue;
1782
+ name = NAME_ALIASES[name] ?? name;
1641
1783
  let timing;
1642
1784
  let easing;
1643
1785
  let delay;
@@ -1723,6 +1865,8 @@ function predefine() {
1723
1865
  [
1724
1866
  displayStyle,
1725
1867
  transitionStyle,
1868
+ animationStyle,
1869
+ animationNameStyle,
1726
1870
  fillStyle,
1727
1871
  svgFillStyle,
1728
1872
  widthStyle,
@@ -1879,6 +2023,100 @@ const ELEMENT_NAME_RE = /(^|[\s>+~,(])([A-Z][a-zA-Z0-9]*)/g;
1879
2023
  function transformSelectorContent(content) {
1880
2024
  return content.replace(ELEMENT_NAME_RE, (_, prefix, name) => `${prefix}[data-element="${name}"]`);
1881
2025
  }
2026
+ const HTML_TYPE_RE = /^html(?![\w\-|\\\u0080-\uffff])/i;
2027
+ const LEGACY_PSEUDO_ELEMENT_RE = /^:(?:before|after|first-line|first-letter)$/i;
2028
+ function rootStateIndex(selector) {
2029
+ let isRoot = HTML_TYPE_RE.test(selector);
2030
+ let pseudoElementAt = -1;
2031
+ let squareDepth = 0;
2032
+ let parenDepth = 0;
2033
+ let quote = "";
2034
+ let rootFunctionParen = -1;
2035
+ let rootFunctionArgs = -1;
2036
+ for (let i = 0; i < selector.length; i++) {
2037
+ const char = selector[i];
2038
+ if (char === "\\") {
2039
+ i++;
2040
+ continue;
2041
+ }
2042
+ if (quote) {
2043
+ if (char === quote) quote = "";
2044
+ continue;
2045
+ }
2046
+ if (char === "\"" || char === "'") {
2047
+ quote = char;
2048
+ continue;
2049
+ }
2050
+ if (char === "[") squareDepth++;
2051
+ else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
2052
+ else if (char === "(") {
2053
+ if (i === rootFunctionParen && parenDepth === 0) rootFunctionArgs = i + 1;
2054
+ parenDepth++;
2055
+ } else if (char === ")") {
2056
+ parenDepth = Math.max(0, parenDepth - 1);
2057
+ if (parenDepth === 0 && rootFunctionArgs !== -1) {
2058
+ const args = splitSelectorsSafely(selector.slice(rootFunctionArgs, i));
2059
+ if (args.length > 0 && args.every((arg) => rootStateIndex(arg) === arg.length)) isRoot = true;
2060
+ rootFunctionArgs = -1;
2061
+ }
2062
+ }
2063
+ if (squareDepth > 0 || parenDepth > 0) continue;
2064
+ if (/[\s>+~,]/.test(char) || char === "/" && selector[i + 1] === "*") return -1;
2065
+ if (char !== ":" || pseudoElementAt !== -1) continue;
2066
+ if (selector[i + 1] === ":") {
2067
+ pseudoElementAt = i;
2068
+ continue;
2069
+ }
2070
+ const name = (/^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "").toLowerCase();
2071
+ if (name === ":root") isRoot = true;
2072
+ else if (LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
2073
+ else if ((name === ":is" || name === ":where") && selector[i + name.length] === "(") rootFunctionParen = i + name.length;
2074
+ }
2075
+ if (!isRoot) return -1;
2076
+ return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2077
+ }
2078
+ function pseudoElementIndex(selector) {
2079
+ let pseudoElementAt = -1;
2080
+ let newCompound = false;
2081
+ let squareDepth = 0;
2082
+ let parenDepth = 0;
2083
+ let quote = "";
2084
+ for (let i = 0; i < selector.length; i++) {
2085
+ const char = selector[i];
2086
+ if (quote) {
2087
+ if (char === "\\") i++;
2088
+ else if (char === quote) quote = "";
2089
+ continue;
2090
+ }
2091
+ if (char === "/" && selector[i + 1] === "*") {
2092
+ const end = selector.indexOf("*/", i + 2);
2093
+ if (end === -1) break;
2094
+ i = end + 1;
2095
+ continue;
2096
+ }
2097
+ if (squareDepth === 0 && parenDepth === 0) {
2098
+ if (/[\s>+~,]/.test(char)) {
2099
+ newCompound = true;
2100
+ continue;
2101
+ }
2102
+ if (newCompound) {
2103
+ pseudoElementAt = -1;
2104
+ newCompound = false;
2105
+ }
2106
+ if (pseudoElementAt === -1 && char === ":") {
2107
+ const name = /^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "";
2108
+ if (selector[i + 1] === ":" || LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
2109
+ }
2110
+ }
2111
+ if (char === "\\") i++;
2112
+ else if (char === "\"" || char === "'") quote = char;
2113
+ else if (char === "[") squareDepth++;
2114
+ else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
2115
+ else if (char === "(") parenDepth++;
2116
+ else if (char === ")") parenDepth = Math.max(0, parenDepth - 1);
2117
+ }
2118
+ return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2119
+ }
1882
2120
  function splitSelectorsSafely(selectorList) {
1883
2121
  if (!selectorList.includes(",")) {
1884
2122
  const selector = selectorList.trim();
@@ -1925,6 +2163,17 @@ function splitSelectorsSafely(selectorList) {
1925
2163
  }
1926
2164
  //#endregion
1927
2165
  //#region src/pipeline/conditions.ts
2166
+ function getRangeUnit(range) {
2167
+ const lower = range.lowerBound && getBoundUnit(range.lowerBound);
2168
+ const upper = range.upperBound && getBoundUnit(range.upperBound);
2169
+ if (lower === null || upper === null) return null;
2170
+ if (lower !== void 0 && upper !== void 0 && lower !== upper) return null;
2171
+ return lower ?? upper ?? null;
2172
+ }
2173
+ function getBoundUnit(bound) {
2174
+ if (bound.valueNumeric == null) return null;
2175
+ return /[a-z%]*$/i.exec(bound.value)[0].toLowerCase();
2176
+ }
1928
2177
  function buildDimensionCondition(dimension, lowerBound, upperBound, emptyDimension = dimension) {
1929
2178
  if (lowerBound && upperBound) {
1930
2179
  const lowerOp = lowerBound.inclusive ? "<=" : "<";
@@ -2359,8 +2608,12 @@ function hasRangeContradiction(terms) {
2359
2608
  const containerByDim = /* @__PURE__ */ new Map();
2360
2609
  for (const term of terms) {
2361
2610
  if (term.kind !== "state") continue;
2362
- if (term.type === "media" && term.subtype === "dimension") {
2363
- const key = term.dimension || "width";
2611
+ if (term.type !== "media" && term.type !== "container") continue;
2612
+ if (term.subtype !== "dimension") continue;
2613
+ const unit = getRangeUnit(term);
2614
+ if (unit === null) continue;
2615
+ if (term.type === "media") {
2616
+ const key = `${term.dimension || "width"}|${unit}`;
2364
2617
  let group = mediaByDim.get(key);
2365
2618
  if (!group) {
2366
2619
  group = {
@@ -2372,8 +2625,8 @@ function hasRangeContradiction(terms) {
2372
2625
  if (term.negated) group.negated.push(term);
2373
2626
  else group.positive.push(term);
2374
2627
  }
2375
- if (term.type === "container" && term.subtype === "dimension") {
2376
- const key = `${term.containerName || "_"}:${term.dimension || "width"}`;
2628
+ if (term.type === "container") {
2629
+ const key = `${term.containerName || "_"}:${term.dimension || "width"}|${unit}`;
2377
2630
  let group = containerByDim.get(key);
2378
2631
  if (!group) {
2379
2632
  group = {
@@ -2568,8 +2821,12 @@ function mergeRanges(terms) {
2568
2821
  const containerByDim = /* @__PURE__ */ new Map();
2569
2822
  terms.forEach((term, index) => {
2570
2823
  if (term.kind !== "state") return;
2571
- if (term.type === "media" && term.subtype === "dimension" && !term.negated) {
2572
- const key = term.dimension || "width";
2824
+ if (term.type !== "media" && term.type !== "container") return;
2825
+ if (term.subtype !== "dimension" || term.negated) return;
2826
+ const unit = getRangeUnit(term);
2827
+ if (unit === null) return;
2828
+ if (term.type === "media") {
2829
+ const key = `${term.dimension || "width"}|${unit}`;
2573
2830
  let group = mediaByDim.get(key);
2574
2831
  if (!group) {
2575
2832
  group = {
@@ -2581,8 +2838,8 @@ function mergeRanges(terms) {
2581
2838
  group.conditions.push(term);
2582
2839
  group.indices.push(index);
2583
2840
  }
2584
- if (term.type === "container" && term.subtype === "dimension" && !term.negated) {
2585
- const key = `${term.containerName || "_"}:${term.dimension || "width"}`;
2841
+ if (term.type === "container") {
2842
+ const key = `${term.containerName || "_"}:${term.dimension || "width"}|${unit}`;
2586
2843
  let group = containerByDim.get(key);
2587
2844
  if (!group) {
2588
2845
  group = {
@@ -2843,14 +3100,16 @@ function hasMediaContradiction(conditions) {
2843
3100
  if (existing !== void 0 && existing !== !cond.negated) return true;
2844
3101
  polarities.set(key, !cond.negated);
2845
3102
  if (cond.subtype !== "dimension" || cond.negated) continue;
2846
- const dim = cond.dimension || "width";
2847
- let bounds = dimensionsByDim.get(dim);
3103
+ const unit = getRangeUnit(cond);
3104
+ if (unit === null) continue;
3105
+ const rangeKey = `${cond.dimension || "width"}|${unit}`;
3106
+ let bounds = dimensionsByDim.get(rangeKey);
2848
3107
  if (!bounds) {
2849
3108
  bounds = {
2850
3109
  lowerBound: null,
2851
3110
  upperBound: null
2852
3111
  };
2853
- dimensionsByDim.set(dim, bounds);
3112
+ dimensionsByDim.set(rangeKey, bounds);
2854
3113
  }
2855
3114
  if (cond.lowerBound?.valueNumeric != null) {
2856
3115
  const value = cond.lowerBound.valueNumeric;
@@ -3207,13 +3466,16 @@ function optimizeGroups(groups) {
3207
3466
  }, facts);
3208
3467
  });
3209
3468
  }
3210
- function rootGroupsToCSS(groups) {
3469
+ function rootGroupsToStateCSS(groups) {
3211
3470
  if (groups.length === 0) return void 0;
3212
3471
  const optimized = optimizeGroups(groups);
3213
3472
  if (optimized.length === 0) return void 0;
3214
- let prefix = ":root";
3215
- for (const group of optimized) prefix += selectorGroupToCSS(group);
3216
- return wrapWhere(prefix);
3473
+ let state = "";
3474
+ for (const group of optimized) state += selectorGroupToCSS(group);
3475
+ return state;
3476
+ }
3477
+ function rootStateToPrefix(state) {
3478
+ return wrapWhere(`:root${state}`);
3217
3479
  }
3218
3480
  function parentGroupsToCSS(groups) {
3219
3481
  let result = "";
@@ -4230,14 +4492,14 @@ var Parser = class {
4230
4492
  const content = raw.slice(7, -1);
4231
4493
  if (!content.trim()) return trueCondition();
4232
4494
  let condition = expandDimensionShorthands(content);
4233
- condition = expandTastyUnits(condition);
4495
+ condition = expandQueryUnits(condition);
4234
4496
  if (condition.includes(":") && !condition.includes("<") && !condition.includes(">") && !condition.includes("=")) {
4235
4497
  const colonIdx = condition.indexOf(":");
4236
4498
  return createMediaFeatureCondition(condition.slice(0, colonIdx).trim(), condition.slice(colonIdx + 1).trim(), false, raw);
4237
4499
  }
4238
4500
  if (!condition.includes("<") && !condition.includes(">") && !condition.includes("=")) return createMediaFeatureCondition(condition.trim(), void 0, false, raw);
4239
4501
  const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(condition);
4240
- if (!dimension) return createPseudoCondition(raw, false, raw);
4502
+ if (!dimension) return createMediaFeatureCondition(condition.trim(), void 0, false, raw);
4241
4503
  return createMediaDimensionCondition(dimension, lowerBound, upperBound, false, raw);
4242
4504
  }
4243
4505
  parseDimensionCondition(condition) {
@@ -4370,9 +4632,9 @@ var Parser = class {
4370
4632
  }
4371
4633
  if (/^[a-zA-Z][\w-]*\s*\(/.test(condition)) return createContainerRawCondition(condition, containerName, false, raw);
4372
4634
  let expandedCondition = expandDimensionShorthands(condition);
4373
- expandedCondition = expandTastyUnits(expandedCondition);
4635
+ expandedCondition = expandQueryUnits(expandedCondition);
4374
4636
  const { dimension, lowerBound, upperBound } = this.parseDimensionCondition(expandedCondition);
4375
- if (!dimension) return createPseudoCondition(raw, false, raw);
4637
+ if (!dimension) return createContainerRawCondition(`(${expandedCondition.trim()})`, containerName, false, raw);
4376
4638
  return createContainerDimensionCondition(dimension, lowerBound, upperBound, containerName, false, raw);
4377
4639
  }
4378
4640
  parsePredefinedState(raw) {
@@ -4422,6 +4684,38 @@ function parseStateKey(stateKey, options = {}) {
4422
4684
  parseCache.set(cacheKey, result);
4423
4685
  return result;
4424
4686
  }
4687
+ function clearParseCache() {
4688
+ parseCache.clear();
4689
+ }
4690
+ //#endregion
4691
+ //#region src/pipeline/pseudo-element-states.ts
4692
+ const QUOTED_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g;
4693
+ const STRUCTURAL_PSEUDO_RE = /:(?:root|empty|scope|has|(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type))(?![\w-])/i;
4694
+ function leafMismatch(node) {
4695
+ if (node.kind !== "state") return null;
4696
+ if (node.type === "modifier") return "modifiers";
4697
+ if (node.type !== "pseudo") return null;
4698
+ const selector = node.pseudo.replace(QUOTED_RE, "\"\"");
4699
+ if (STRUCTURAL_PSEUDO_RE.test(selector)) return "position in the DOM tree";
4700
+ if (selector.includes("[")) return "attributes";
4701
+ if (selector.includes(".") || selector.includes("#")) return "classes or ids";
4702
+ return null;
4703
+ }
4704
+ function pseudoElementMismatch(condition, target) {
4705
+ const walk = (node, describesTarget) => {
4706
+ if (node.kind === "compound") {
4707
+ for (const child of node.children) {
4708
+ const found = walk(child, describesTarget);
4709
+ if (found) return found;
4710
+ }
4711
+ return null;
4712
+ }
4713
+ if (node.kind !== "state") return null;
4714
+ if (node.type === "own") return target.own || target.root ? walk(node.innerCondition, true) : null;
4715
+ return describesTarget ? leafMismatch(node) : null;
4716
+ };
4717
+ return walk(condition, target.root);
4718
+ }
4425
4719
  //#endregion
4426
4720
  //#region src/pipeline/index.ts
4427
4721
  const RE_UPPER_CASE = /[A-Z]/;
@@ -4432,9 +4726,9 @@ function hasPipelineCacheEntry(cacheKey) {
4432
4726
  function clearPipelineCache() {
4433
4727
  pipelineCache.clear();
4434
4728
  }
4435
- function runPipeline(styles, parserContext) {
4729
+ function runPipeline(styles, parserContext, pseudoElementRoot = false) {
4436
4730
  const allRules = [];
4437
- processStyles(styles, "", parserContext, allRules);
4731
+ processStyles(styles, "", parserContext, allRules, pseudoElementRoot);
4438
4732
  const seen = /* @__PURE__ */ new Set();
4439
4733
  const normal = [];
4440
4734
  const starting = [];
@@ -4450,7 +4744,7 @@ function stableSortByOrder(rules) {
4450
4744
  if (rules.length <= 1) return rules;
4451
4745
  return [...rules].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
4452
4746
  }
4453
- function processStyles(styles, selectorSuffix, parserContext, allRules) {
4747
+ function processStyles(styles, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4454
4748
  const keys = Object.keys(styles);
4455
4749
  const selectorKeys = [];
4456
4750
  const styleKeys = [];
@@ -4466,10 +4760,10 @@ function processStyles(styles, selectorSuffix, parserContext, allRules) {
4466
4760
  }
4467
4761
  styleKeys.push(key);
4468
4762
  }
4469
- processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules);
4470
- processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules);
4763
+ processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot);
4764
+ processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules, pseudoElementRoot);
4471
4765
  }
4472
- function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules) {
4766
+ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4473
4767
  for (const key of selectorKeys) {
4474
4768
  const nestedStyles = styles[key];
4475
4769
  if (!nestedStyles || typeof nestedStyles !== "object") continue;
@@ -4486,30 +4780,34 @@ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserCont
4486
4780
  ...subLocalStates
4487
4781
  } : parserContext.localPredefinedStates
4488
4782
  };
4489
- for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules);
4783
+ for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules, pseudoElementRoot);
4490
4784
  }
4491
4785
  }
4492
- function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules) {
4786
+ function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4787
+ const target = {
4788
+ own: pseudoElementIndex(selectorSuffix) < selectorSuffix.length,
4789
+ root: pseudoElementRoot
4790
+ };
4493
4791
  for (const { handler, styleMap, hasStateMap } of handlerQueue) {
4494
4792
  const lookupStyles = handler.__lookupStyles;
4495
- const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext), lookupStyles) : [{
4793
+ const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target), lookupStyles) : [{
4496
4794
  condition: trueCondition(),
4497
4795
  values: styleMap,
4498
4796
  order: 0
4499
4797
  }], selectorSuffix));
4500
4798
  for (const rule of mergedRules) {
4501
- const cssRules = materializeComputedRule(rule);
4799
+ const cssRules = materializeComputedRule(rule, pseudoElementRoot);
4502
4800
  allRules.push(...cssRules);
4503
4801
  }
4504
4802
  }
4505
4803
  }
4506
- function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
4804
+ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target) {
4507
4805
  const exclusiveByStyle = /* @__PURE__ */ new Map();
4508
4806
  for (const styleName of lookupStyles) {
4509
4807
  const value = styleMap[styleName];
4510
4808
  if (value === void 0) continue;
4511
4809
  if (isValueMapping(value)) {
4512
- const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
4810
+ const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(target.own || target.root ? dropPseudoElementMismatches(styleName, value, parserContext, target) : value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
4513
4811
  exclusiveByStyle.set(styleName, fullyExpanded);
4514
4812
  } else exclusiveByStyle.set(styleName, [{
4515
4813
  styleKey: styleName,
@@ -4522,6 +4820,18 @@ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
4522
4820
  }
4523
4821
  return exclusiveByStyle;
4524
4822
  }
4823
+ function dropPseudoElementMismatches(styleName, valueMap, parserContext, target) {
4824
+ let kept;
4825
+ for (const stateKey of Object.keys(valueMap)) {
4826
+ if (stateKey === "" || stateKey === "_" || isMisusedFallbackKey(stateKey)) continue;
4827
+ const mismatch = pseudoElementMismatch(parseStateKey(stateKey, { context: parserContext }), target);
4828
+ if (!mismatch) continue;
4829
+ emitWarning("PSEUDO_ELEMENT_STATE_IGNORED", `State "${stateKey}" (in "${styleName}") applies to a pseudo-element, which has no ${mismatch}, so it can never match. The state has been ignored. To condition on the element the pseudo-element belongs to, write it in the selector before the pseudo-element.`);
4830
+ kept ??= { ...valueMap };
4831
+ delete kept[stateKey];
4832
+ }
4833
+ return kept ?? valueMap;
4834
+ }
4525
4835
  function invokeHandler(handler, stateSnapshots, selectorSuffix) {
4526
4836
  const computedRules = [];
4527
4837
  for (const snapshot of stateSnapshots) {
@@ -4534,7 +4844,10 @@ function invokeHandler(handler, stateSnapshots, selectorSuffix) {
4534
4844
  const declarations = {};
4535
4845
  for (const [prop, val] of Object.entries(styleProps)) {
4536
4846
  if (RE_UPPER_CASE.test(prop) && !prop.startsWith("--") && isDevEnv()) emitWarning("HANDLER_CAMEL_CASE_KEY", `A style handler returned "${prop}". CSS property names must be kebab-case ("${toSnakeCase(prop)}"). The declaration was emitted verbatim and the browser will ignore it.`);
4537
- if (val != null && val !== "") declarations[prop] = String(val);
4847
+ if (Array.isArray(val)) {
4848
+ const chain = val.filter((v) => v != null && v !== "").map((v) => String(v));
4849
+ if (chain.length) declarations[prop] = chain.length === 1 ? chain[0] : chain;
4850
+ } else if (val != null && val !== "") declarations[prop] = String(val);
4538
4851
  }
4539
4852
  if (Object.keys(declarations).length === 0) continue;
4540
4853
  const suffixes = $ ? (Array.isArray($) ? $ : [$]).map((s) => selectorSuffix + normalizeSelectorSuffix(String(s))) : [selectorSuffix];
@@ -4849,28 +5162,32 @@ function mergeByValue(rules) {
4849
5162
  }
4850
5163
  return merged;
4851
5164
  }
4852
- function buildSelectorFromVariant(variant, selectorSuffix) {
4853
- let selector = "";
5165
+ function buildSelectorFromVariant(variant, selectorSuffix, pseudoElementRoot) {
4854
5166
  let rootSegment = branchToCSS([...variant.modifierConditions, ...variant.pseudoConditions]);
4855
5167
  for (const group of variant.selectorGroups) rootSegment += selectorGroupToCSS(group);
4856
- selector += wrapWhere(rootSegment);
4857
- if (variant.parentGroups.length > 0) selector += parentGroupsToCSS(variant.parentGroups);
5168
+ const parents = variant.parentGroups.length > 0 ? parentGroupsToCSS(variant.parentGroups) : "";
5169
+ const pseudoElementAt = pseudoElementRoot ? parents.length : 0;
5170
+ let selector = pseudoElementRoot ? parents + wrapWhere(rootSegment) : wrapWhere(rootSegment) + parents;
4858
5171
  selector += selectorSuffix;
4859
5172
  const ownOptimized = optimizeGroups(variant.ownGroups);
4860
5173
  let ownSegment = "";
4861
5174
  for (const group of ownOptimized) ownSegment += selectorGroupToCSS(group);
4862
5175
  selector += wrapWhere(ownSegment);
4863
- return selector;
5176
+ return {
5177
+ selector,
5178
+ pseudoElementAt
5179
+ };
4864
5180
  }
4865
- function materializeComputedRule(rule) {
5181
+ function materializeComputedRule(rule, pseudoElementRoot) {
4866
5182
  const components = conditionToCSS(rule.condition);
4867
5183
  if (components.isImpossible || components.variants.length === 0) return [];
4868
- const declarations = Object.entries(rule.declarations).map(([prop, value]) => `${prop}: ${value};`).join(" ");
5184
+ const declarations = Object.entries(rule.declarations).map(([prop, value]) => Array.isArray(value) ? value.map((v) => `${prop}: ${v};`).join(" ") : `${prop}: ${value};`).join(" ");
4869
5185
  const byAtRules = /* @__PURE__ */ new Map();
4870
5186
  for (const variant of components.variants) {
4871
5187
  const atRules = buildAtRulesFromVariant(variant);
4872
5188
  const startingStyle = variant.startingStyle;
4873
- const rootPrefix = rootGroupsToCSS(variant.rootGroups);
5189
+ const rootState = rootGroupsToStateCSS(variant.rootGroups);
5190
+ const rootPrefix = rootState === void 0 ? void 0 : rootStateToPrefix(rootState);
4874
5191
  const key = atRules.sort().join("|||") + "###" + (rootPrefix || "") + "###" + (startingStyle ? "1" : "0");
4875
5192
  const group = byAtRules.get(key);
4876
5193
  if (group) group.variants.push(variant);
@@ -4878,19 +5195,24 @@ function materializeComputedRule(rule) {
4878
5195
  variants: [variant],
4879
5196
  atRules,
4880
5197
  rootPrefix,
5198
+ rootState,
4881
5199
  startingStyle: startingStyle || void 0
4882
5200
  });
4883
5201
  }
4884
5202
  const rules = [];
4885
5203
  for (const [, group] of byAtRules) {
4886
- const selectorFragments = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix));
5204
+ const built = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix, pseudoElementRoot));
4887
5205
  const cssRule = {
4888
- selector: selectorFragments.length === 1 ? selectorFragments[0] : selectorFragments,
5206
+ selector: built.length === 1 ? built[0].selector : built.map((b) => b.selector),
4889
5207
  declarations,
4890
5208
  order: rule.order
4891
5209
  };
5210
+ if (pseudoElementRoot) cssRule.pseudoElementAt = built.map((b) => b.pseudoElementAt);
4892
5211
  if (group.atRules.length > 0) cssRule.atRules = group.atRules;
4893
- if (group.rootPrefix) cssRule.rootPrefix = group.rootPrefix;
5212
+ if (group.rootPrefix) {
5213
+ cssRule.rootPrefix = group.rootPrefix;
5214
+ cssRule.rootState = group.rootState;
5215
+ }
4894
5216
  if (group.startingStyle) cssRule.startingStyle = true;
4895
5217
  rules.push(cssRule);
4896
5218
  }
@@ -4913,31 +5235,51 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
4913
5235
  if (pipelineCacheKey) rules = pipelineCache.get(pipelineCacheKey);
4914
5236
  if (!rules && !styles) return directSelector ? [] : { rules: [] };
4915
5237
  const cacheKey = pipelineCacheKey || stringifyStyles(styles);
4916
- if (!rules) rules = pipelineCache.get(cacheKey);
4917
- if (!rules) {
4918
- rules = runPipeline(styles, createStateParserContext(styles));
4919
- pipelineCache.set(cacheKey, rules);
4920
- }
5238
+ const rulesFor = (pseudoElementRoot) => {
5239
+ const key = pseudoElementRoot ? `${cacheKey}\0::` : cacheKey;
5240
+ let cached = pipelineCache.get(key);
5241
+ if (!cached) {
5242
+ cached = runPipeline(styles, createStateParserContext(styles), pseudoElementRoot);
5243
+ pipelineCache.set(key, cached);
5244
+ }
5245
+ return cached;
5246
+ };
4921
5247
  if (directSelector) {
4922
5248
  const shouldDouble = options?.doubleSelector ?? false;
4923
- return mergeStyleResults(rules.map((rule) => {
5249
+ const items = splitSelectorsSafely(classNameOrSelector);
5250
+ const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => {
5251
+ const at = pseudoElementIndex(base);
5252
+ return {
5253
+ head: base.slice(0, at),
5254
+ pseudoElement: base.slice(at),
5255
+ rootAt: rootStateIndex(base)
5256
+ };
5257
+ });
5258
+ const toResults = (groupRules, group) => groupRules.map((rule) => {
4924
5259
  const result = {
4925
- selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).map((part) => {
4926
- let sel = part ? `${classNameOrSelector}${part}` : classNameOrSelector;
5260
+ selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part, index) => group.map(({ head, pseudoElement, rootAt }) => {
5261
+ const joinsRoot = rule.rootState !== void 0 && rootAt !== -1;
5262
+ const base = joinsRoot ? `${head.slice(0, rootAt)}${wrapWhere(rule.rootState)}${head.slice(rootAt)}` : head;
5263
+ const at = rule.pseudoElementAt?.[index] ?? 0;
5264
+ let sel = pseudoElement ? `${base}${part.slice(0, at)}${pseudoElement}${part.slice(at)}` : `${base}${part}`;
4927
5265
  if (shouldDouble && sel.startsWith(".")) {
4928
5266
  const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
4929
5267
  if (classMatch) sel = classMatch[0] + sel;
4930
5268
  }
4931
- if (rule.rootPrefix) sel = `${rule.rootPrefix} ${sel}`;
5269
+ if (rule.rootPrefix && !joinsRoot) sel = `${rule.rootPrefix} ${sel}`;
4932
5270
  return sel;
4933
- }).join(", "),
5271
+ })).join(", "),
4934
5272
  declarations: rule.declarations
4935
5273
  };
4936
5274
  if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
4937
5275
  if (rule.startingStyle) result.startingStyle = true;
4938
5276
  return result;
4939
- }));
5277
+ });
5278
+ const plain = bases.filter((base) => !base.pseudoElement);
5279
+ const pseudo = bases.filter((base) => base.pseudoElement);
5280
+ return mergeStyleResults([...plain.length > 0 ? toResults(rulesFor(false), plain) : [], ...pseudo.length > 0 ? toResults(rulesFor(true), pseudo) : []]);
4940
5281
  }
5282
+ rules ??= rulesFor(false);
4941
5283
  return { rules: rules.map((r) => ({
4942
5284
  selector: Array.isArray(r.selector) ? r.selector.join("|||") : r.selector,
4943
5285
  declarations: r.declarations,
@@ -5255,6 +5597,6 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
5255
5597
  return renderStyles(chunkName === CHUNK_NAMES.SUBCOMPONENTS ? buildSubcomponentFilteredStyles(styles, styleKeys) : buildFilteredStyles(styles, styleKeys), void 0, void 0, pipelineCacheKey);
5256
5598
  }
5257
5599
  //#endregion
5258
- export { createStyle as A, createStateParserContext as B, splitSelectorsSafely as C, registerHandler as D, normalizeHandlerDefinition as E, FONT_CHUNK_STYLES as F, markStylesGeneratedState as G, setGlobalPredefinedStates as H, LAYOUT_CHUNK_STYLES as I, setGlobalPolyfillsState as J, resetGlobalPolyfillsState as K, POSITION_CHUNK_STYLES as L, CHUNK_NAMES as M, DIMENSION_CHUNK_STYLES as N, resetHandlers as O, DISPLAY_CHUNK_STYLES as P, STYLE_TO_CHUNK as R, camelToKebab as S, defineHandler as T, hasStylesGenerated as U, getGlobalPredefinedStates as V, isFunctionsPolyfillEnabled as W, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, APPEARANCE_CHUNK_STYLES as j, styleHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, resetStylesGeneratedState as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, STYLE_HANDLER_MAP as w, parseStateKey as x, clearPipelineCache as y, resetStyleChunks as z };
5600
+ export { styleHandlers as A, STYLE_TO_CHUNK as B, camelToKebab as C, normalizeHandlerDefinition as D, defineHandler as E, DIMENSION_CHUNK_STYLES as F, setGlobalPredefinedStates as G, clearGlobalPredefinedStates as H, DISPLAY_CHUNK_STYLES as I, markStylesGeneratedState as J, hasStylesGenerated as K, FONT_CHUNK_STYLES as L, createStyle as M, APPEARANCE_CHUNK_STYLES as N, registerHandler as O, CHUNK_NAMES as P, LAYOUT_CHUNK_STYLES as R, parseStateKey as S, STYLE_HANDLER_MAP as T, createStateParserContext as U, resetStyleChunks as V, getGlobalPredefinedStates as W, resetStylesGeneratedState as X, resetGlobalPolyfillsState as Y, setGlobalPolyfillsState as Z, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, scanAnimationNames as j, resetHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, isFunctionsPolyfillEnabled as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, splitSelectorsSafely as w, clearParseCache as x, clearPipelineCache as y, POSITION_CHUNK_STYLES as z };
5259
5601
 
5260
- //# sourceMappingURL=style-engine-BBbBuSkT.js.map
5602
+ //# sourceMappingURL=style-engine-DnkV_4Jg.js.map